@clawos-dev/clawd 0.2.469 → 0.2.470

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.
@@ -503,42 +503,42 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
503
503
  `)},yS=function(){var e=parseInt(document.body.getAttribute(Da)||"0",10);return isFinite(e)?e:0},IH=function(){g.useEffect(function(){return document.body.setAttribute(Da,(yS()+1).toString()),function(){var e=yS()-1;e<=0?document.body.removeAttribute(Da):document.body.setAttribute(Da,e.toString())}},[])},PH=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;IH();var s=g.useMemo(function(){return EH(i)},[i]);return g.createElement(NH,{styles:TH(s,!t,i,n?"":"!important")})},C0=!1;if(typeof window<"u")try{var bd=Object.defineProperty({},"passive",{get:function(){return C0=!0,!0}});window.addEventListener("test",bd,bd),window.removeEventListener("test",bd,bd)}catch{C0=!1}var ra=C0?{passive:!1}:!1,RH=function(e){return e.tagName==="TEXTAREA"},DP=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!RH(e)&&n[t]==="visible")},MH=function(e){return DP(e,"overflowY")},AH=function(e){return DP(e,"overflowX")},bS=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=OP(e,r);if(i){var s=BP(e,r),o=s[1],a=s[2];if(o>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},jH=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},LH=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},OP=function(e,t){return e==="v"?MH(t):AH(t)},BP=function(e,t){return e==="v"?jH(t):LH(t)},DH=function(e,t){return e==="h"&&t==="rtl"?-1:1},OH=function(e,t,n,r,i){var s=DH(e,window.getComputedStyle(t).direction),o=s*r,a=n.target,l=t.contains(a),c=!1,u=o>0,d=0,f=0;do{if(!a)break;var p=BP(e,a),m=p[0],v=p[1],w=p[2],x=v-w-s*m;(m||x)&&OP(e,a)&&(d+=x,f+=m);var _=a.parentNode;a=_&&_.nodeType===Node.DOCUMENT_FRAGMENT_NODE?_.host:_}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(u&&Math.abs(d)<1||!u&&Math.abs(f)<1)&&(c=!0),c},wd=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},wS=function(e){return[e.deltaX,e.deltaY]},SS=function(e){return e&&"current"in e?e.current:e},BH=function(e,t){return e[0]===t[0]&&e[1]===t[1]},zH=function(e){return`
504
504
  .block-interactivity-`.concat(e,` {pointer-events: none;}
505
505
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
506
- `)},$H=0,ia=[];function FH(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState($H++)[0],s=g.useState(LP)[0],o=g.useRef(e);g.useEffect(function(){o.current=e},[e]),g.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var v=lH([e.lockRef.current],(e.shards||[]).map(SS),!0).filter(Boolean);return v.forEach(function(w){return w.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),v.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(v,w){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var x=wd(v),_=n.current,y="deltaX"in v?v.deltaX:_[0]-x[0],S="deltaY"in v?v.deltaY:_[1]-x[1],C,k=v.target,N=Math.abs(y)>Math.abs(S)?"h":"v";if("touches"in v&&N==="h"&&k.type==="range")return!1;var T=window.getSelection(),O=T&&T.anchorNode,P=O?O===k||O.contains(k):!1;if(P)return!1;var D=bS(N,k);if(!D)return!0;if(D?C=N:(C=N==="v"?"h":"v",D=bS(N,k)),!D)return!1;if(!r.current&&"changedTouches"in v&&(y||S)&&(r.current=C),!C)return!0;var R=r.current||C;return OH(R,w,v,R==="h"?y:S)},[]),l=g.useCallback(function(v){var w=v;if(!(!ia.length||ia[ia.length-1]!==s)){var x="deltaY"in w?wS(w):wd(w),_=t.current.filter(function(C){return C.name===w.type&&(C.target===w.target||w.target===C.shadowParent)&&BH(C.delta,x)})[0];if(_&&_.should){w.cancelable&&w.preventDefault();return}if(!_){var y=(o.current.shards||[]).map(SS).filter(Boolean).filter(function(C){return C.contains(w.target)}),S=y.length>0?a(w,y[0]):!o.current.noIsolation;S&&w.cancelable&&w.preventDefault()}}},[]),c=g.useCallback(function(v,w,x,_){var y={name:v,delta:w,target:x,should:_,shadowParent:HH(x)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(S){return S!==y})},1)},[]),u=g.useCallback(function(v){n.current=wd(v),r.current=void 0},[]),d=g.useCallback(function(v){c(v.type,wS(v),v.target,a(v,e.lockRef.current))},[]),f=g.useCallback(function(v){c(v.type,wd(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return ia.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,ra),document.addEventListener("touchmove",l,ra),document.addEventListener("touchstart",u,ra),function(){ia=ia.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,ra),document.removeEventListener("touchmove",l,ra),document.removeEventListener("touchstart",u,ra)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(s,{styles:zH(i)}):null,p?g.createElement(PH,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function HH(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const UH=vH(jP,FH);var my=g.forwardRef(function(e,t){return g.createElement(_p,ri({},e,{ref:t,sideCar:UH}))});my.classNames=_p.classNames;var E0=["Enter"," "],WH=["ArrowDown","PageUp","Home"],zP=["ArrowUp","PageDown","End"],VH=[...WH,...zP],qH={ltr:[...E0,"ArrowRight"],rtl:[...E0,"ArrowLeft"]},KH={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Tu="Menu",[su,GH,YH]=GI(Tu),[Ho,$P]=Fo(Tu,[YH,xp,CP]),Iu=xp(),FP=CP(),[HP,qs]=Ho(Tu),[XH,Pu]=Ho(Tu),UP=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=Iu(t),[l,c]=g.useState(null),u=g.useRef(!1),d=gi(s),f=YI(i);return g.useEffect(()=>{const p=()=>{u.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>u.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),h.jsx(fy,{...a,children:h.jsx(HP,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(XH,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};UP.displayName=Tu;var QH="MenuAnchor",gy=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Iu(n);return h.jsx(bP,{...i,...r,ref:t})});gy.displayName=QH;var vy="MenuPortal",[ZH,WP]=Ho(vy,{forceMount:void 0}),VP=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=qs(vy,t);return h.jsx(ZH,{scope:t,forceMount:n,children:h.jsx(Ji,{present:n||s.open,children:h.jsx(py,{asChild:!0,container:i,children:r})})})};VP.displayName=vy;var br="MenuContent",[JH,xy]=Ho(br),qP=g.forwardRef((e,t)=>{const n=WP(br,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=qs(br,e.__scopeMenu),o=Pu(br,e.__scopeMenu);return h.jsx(su.Provider,{scope:e.__scopeMenu,children:h.jsx(Ji,{present:r||s.open,children:h.jsx(su.Slot,{scope:e.__scopeMenu,children:o.modal?h.jsx(eU,{...i,ref:t}):h.jsx(tU,{...i,ref:t})})})})}),eU=g.forwardRef((e,t)=>{const n=qs(br,e.__scopeMenu),r=g.useRef(null),i=Jt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return RP(s)},[]),h.jsx(_y,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Re(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),tU=g.forwardRef((e,t)=>{const n=qs(br,e.__scopeMenu);return h.jsx(_y,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),nU=ru("MenuContent.ScrollLock"),_y=g.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...v}=e,w=qs(br,n),x=Pu(br,n),_=Iu(n),y=FP(n),S=GH(n),[C,k]=g.useState(null),N=g.useRef(null),T=Jt(t,N,w.onContentChange),O=g.useRef(0),P=g.useRef(""),D=g.useRef(0),R=g.useRef(null),A=g.useRef("right"),M=g.useRef(0),L=m?my:g.Fragment,$=m?{as:nU,allowPinchZoom:!0}:void 0,F=z=>{var ge,Pe;const E=P.current+z,H=S().filter(he=>!he.disabled),q=document.activeElement,j=(ge=H.find(he=>he.ref.current===q))==null?void 0:ge.textValue,ne=H.map(he=>he.textValue),ie=pU(ne,E,j),K=(Pe=H.find(he=>he.textValue===ie))==null?void 0:Pe.ref.current;(function he(Ae){P.current=Ae,window.clearTimeout(O.current),Ae!==""&&(O.current=window.setTimeout(()=>he(""),1e3))})(E),K&&setTimeout(()=>K.focus())};g.useEffect(()=>()=>window.clearTimeout(O.current),[]),ZI();const B=g.useCallback(z=>{var H,q;return A.current===((H=R.current)==null?void 0:H.side)&&gU(z,(q=R.current)==null?void 0:q.area)},[]);return h.jsx(JH,{scope:n,searchRef:P,onItemEnter:g.useCallback(z=>{B(z)&&z.preventDefault()},[B]),onItemLeave:g.useCallback(z=>{var E;B(z)||((E=N.current)==null||E.focus(),k(null))},[B]),onTriggerLeave:g.useCallback(z=>{B(z)&&z.preventDefault()},[B]),pointerGraceTimerRef:D,onPointerGraceIntentChange:g.useCallback(z=>{R.current=z},[]),children:h.jsx(L,{...$,children:h.jsx(iy,{asChild:!0,trapped:i,onMountAutoFocus:Re(s,z=>{var E;z.preventDefault(),(E=N.current)==null||E.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:h.jsx(fp,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(rH,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:Re(l,z=>{x.isUsingKeyboardRef.current||z.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(wP,{role:"menu","aria-orientation":"vertical","data-state":cR(w.open),"data-radix-menu-content":"",dir:x.dir,..._,...v,ref:T,style:{outline:"none",...v.style},onKeyDown:Re(v.onKeyDown,z=>{const H=z.target.closest("[data-radix-menu-content]")===z.currentTarget,q=z.ctrlKey||z.altKey||z.metaKey,j=z.key.length===1;H&&(z.key==="Tab"&&z.preventDefault(),!q&&j&&F(z.key));const ne=N.current;if(z.target!==ne||!VH.includes(z.key))return;z.preventDefault();const K=S().filter(ge=>!ge.disabled).map(ge=>ge.ref.current);zP.includes(z.key)&&K.reverse(),hU(K)}),onBlur:Re(e.onBlur,z=>{z.currentTarget.contains(z.target)||(window.clearTimeout(O.current),P.current="")}),onPointerMove:Re(e.onPointerMove,ou(z=>{const E=z.target,H=M.current!==z.clientX;if(z.currentTarget.contains(E)&&H){const q=z.clientX>M.current?"right":"left";A.current=q,M.current=z.clientX}}))})})})})})})});qP.displayName=br;var rU="MenuGroup",yy=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(It.div,{role:"group",...r,ref:t})});yy.displayName=rU;var iU="MenuLabel",KP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(It.div,{...r,ref:t})});KP.displayName=iU;var af="MenuItem",kS="menu.itemSelect",yp=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=Pu(af,e.__scopeMenu),a=xy(af,e.__scopeMenu),l=Jt(t,s),c=g.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(kS,{bubbles:!0,cancelable:!0});d.addEventListener(kS,p=>r==null?void 0:r(p),{once:!0}),KI(d,f),f.defaultPrevented?c.current=!1:o.onClose()}};return h.jsx(GP,{...i,ref:l,disabled:n,onClick:Re(e.onClick,u),onPointerDown:d=>{var f;(f=e.onPointerDown)==null||f.call(e,d),c.current=!0},onPointerUp:Re(e.onPointerUp,d=>{var f;c.current||(f=d.currentTarget)==null||f.click()}),onKeyDown:Re(e.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||E0.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});yp.displayName=af;var GP=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=xy(af,n),a=FP(n),l=g.useRef(null),c=Jt(t,l),[u,d]=g.useState(!1),[f,p]=g.useState("");return g.useEffect(()=>{const m=l.current;m&&p((m.textContent??"").trim())},[s.children]),h.jsx(su.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:h.jsx(iH,{asChild:!0,...a,focusable:!r,children:h.jsx(It.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:Re(e.onPointerMove,ou(m=>{r?o.onItemLeave(m):(o.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Re(e.onPointerLeave,ou(m=>o.onItemLeave(m))),onFocus:Re(e.onFocus,()=>d(!0)),onBlur:Re(e.onBlur,()=>d(!1))})})})}),sU="MenuCheckboxItem",YP=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return h.jsx(eR,{scope:e.__scopeMenu,checked:n,children:h.jsx(yp,{role:"menuitemcheckbox","aria-checked":lf(n)?"mixed":n,...i,ref:t,"data-state":Sy(n),onSelect:Re(i.onSelect,()=>r==null?void 0:r(lf(n)?!0:!n),{checkForDefaultPrevented:!1})})})});YP.displayName=sU;var XP="MenuRadioGroup",[oU,aU]=Ho(XP,{value:void 0,onValueChange:()=>{}}),QP=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=gi(r);return h.jsx(oU,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(yy,{...i,ref:t})})});QP.displayName=XP;var ZP="MenuRadioItem",JP=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=aU(ZP,e.__scopeMenu),s=n===i.value;return h.jsx(eR,{scope:e.__scopeMenu,checked:s,children:h.jsx(yp,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Sy(s),onSelect:Re(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});JP.displayName=ZP;var by="MenuItemIndicator",[eR,lU]=Ho(by,{checked:!1}),tR=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=lU(by,n);return h.jsx(Ji,{present:r||lf(s.checked)||s.checked===!0,children:h.jsx(It.span,{...i,ref:t,"data-state":Sy(s.checked)})})});tR.displayName=by;var cU="MenuSeparator",nR=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(It.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});nR.displayName=cU;var uU="MenuArrow",rR=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Iu(n);return h.jsx(SP,{...i,...r,ref:t})});rR.displayName=uU;var wy="MenuSub",[dU,iR]=Ho(wy),sR=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=qs(wy,t),o=Iu(t),[a,l]=g.useState(null),[c,u]=g.useState(null),d=gi(i);return g.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),h.jsx(fy,{...o,children:h.jsx(HP,{scope:t,open:r,onOpenChange:d,content:c,onContentChange:u,children:h.jsx(dU,{scope:t,contentId:$i(),triggerId:$i(),trigger:a,onTriggerChange:l,children:n})})})};sR.displayName=wy;var rc="MenuSubTrigger",oR=g.forwardRef((e,t)=>{const n=qs(rc,e.__scopeMenu),r=Pu(rc,e.__scopeMenu),i=iR(rc,e.__scopeMenu),s=xy(rc,e.__scopeMenu),o=g.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},u=g.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return g.useEffect(()=>u,[u]),g.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),h.jsx(gy,{asChild:!0,...c,children:h.jsx(GP,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":cR(n.open),...e,ref:ku(t,i.onTriggerChange),onClick:d=>{var f;(f=e.onClick)==null||f.call(e,d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Re(e.onPointerMove,ou(d=>{s.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:Re(e.onPointerLeave,ou(d=>{var p,m;u();const f=(p=n.content)==null?void 0:p.getBoundingClientRect();if(f){const v=(m=n.content)==null?void 0:m.dataset.side,w=v==="right",x=w?-5:5,_=f[w?"left":"right"],y=f[w?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+x,y:d.clientY},{x:_,y:f.top},{x:y,y:f.top},{x:y,y:f.bottom},{x:_,y:f.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Re(e.onKeyDown,d=>{var p;const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||qH[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});oR.displayName=rc;var aR="MenuSubContent",lR=g.forwardRef((e,t)=>{const n=WP(br,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=qs(br,e.__scopeMenu),o=Pu(br,e.__scopeMenu),a=iR(aR,e.__scopeMenu),l=g.useRef(null),c=Jt(t,l);return h.jsx(su.Provider,{scope:e.__scopeMenu,children:h.jsx(Ji,{present:r||s.open,children:h.jsx(su.Slot,{scope:e.__scopeMenu,children:h.jsx(_y,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:c,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var d;o.isUsingKeyboardRef.current&&((d=l.current)==null||d.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:Re(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Re(e.onEscapeKeyDown,u=>{o.onClose(),u.preventDefault()}),onKeyDown:Re(e.onKeyDown,u=>{var p;const d=u.currentTarget.contains(u.target),f=KH[o.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});lR.displayName=aR;function cR(e){return e?"open":"closed"}function lf(e){return e==="indeterminate"}function Sy(e){return lf(e)?"indeterminate":e?"checked":"unchecked"}function hU(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function fU(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function pU(e,t,n){const i=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let o=fU(e,Math.max(s,0));i.length===1&&(o=o.filter(c=>c!==n));const l=o.find(c=>c.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function mU(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(i=!i)}return i}function gU(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return mU(n,t)}function ou(e){return t=>t.pointerType==="mouse"?e(t):void 0}var vU=UP,xU=gy,_U=VP,yU=qP,bU=yy,wU=KP,SU=yp,kU=YP,CU=QP,EU=JP,NU=tR,TU=nR,IU=rR,PU=sR,RU=oR,MU=lR,bp="DropdownMenu",[AU]=Fo(bp,[$P]),En=$P(),[jU,uR]=AU(bp),dR=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=En(t),c=g.useRef(null),[u,d]=Cu({prop:i,defaultProp:s??!1,onChange:o,caller:bp});return h.jsx(jU,{scope:t,triggerId:$i(),triggerRef:c,contentId:$i(),open:u,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(vU,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};dR.displayName=bp;var hR="DropdownMenuTrigger",fR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=uR(hR,n),o=En(n);return h.jsx(xU,{asChild:!0,...o,children:h.jsx(It.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:ku(t,s.triggerRef),onPointerDown:Re(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:Re(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});fR.displayName=hR;var LU="DropdownMenuPortal",pR=e=>{const{__scopeDropdownMenu:t,...n}=e,r=En(t);return h.jsx(_U,{...r,...n})};pR.displayName=LU;var mR="DropdownMenuContent",gR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=uR(mR,n),s=En(n),o=g.useRef(!1);return h.jsx(yU,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:t,onCloseAutoFocus:Re(e.onCloseAutoFocus,a=>{var l;o.current||(l=i.triggerRef.current)==null||l.focus(),o.current=!1,a.preventDefault()}),onInteractOutside:Re(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!i.modal||u)&&(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)"}})});gR.displayName=mR;var DU="DropdownMenuGroup",OU=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(bU,{...i,...r,ref:t})});OU.displayName=DU;var BU="DropdownMenuLabel",vR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(wU,{...i,...r,ref:t})});vR.displayName=BU;var zU="DropdownMenuItem",xR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(SU,{...i,...r,ref:t})});xR.displayName=zU;var $U="DropdownMenuCheckboxItem",_R=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(kU,{...i,...r,ref:t})});_R.displayName=$U;var FU="DropdownMenuRadioGroup",HU=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(CU,{...i,...r,ref:t})});HU.displayName=FU;var UU="DropdownMenuRadioItem",WU=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(EU,{...i,...r,ref:t})});WU.displayName=UU;var VU="DropdownMenuItemIndicator",yR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(NU,{...i,...r,ref:t})});yR.displayName=VU;var qU="DropdownMenuSeparator",bR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(TU,{...i,...r,ref:t})});bR.displayName=qU;var KU="DropdownMenuArrow",GU=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(IU,{...i,...r,ref:t})});GU.displayName=KU;var YU=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,o=En(t),[a,l]=Cu({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return h.jsx(PU,{...o,open:a,onOpenChange:l,children:n})},XU="DropdownMenuSubTrigger",wR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(RU,{...i,...r,ref:t})});wR.displayName=XU;var QU="DropdownMenuSubContent",SR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(MU,{...i,...r,ref:t,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)"}})});SR.displayName=QU;var ZU=dR,JU=fR,kR=pR,CR=gR,ER=vR,NR=xR,TR=_R,eW=yR,IR=bR,tW=YU,PR=wR,RR=SR;const ky=ZU,Cy=JU,wp=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(kR,{children:h.jsx(CR,{ref:r,sideOffset:t,className:re("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));wp.displayName=CR.displayName;const nW=tW,MR=g.forwardRef(({className:e,...t},n)=>h.jsx(PR,{ref:n,className:re("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100 data-[state=open]:bg-bg-200","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...t}));MR.displayName=PR.displayName;const AR=g.forwardRef(({className:e,...t},n)=>h.jsx(kR,{children:h.jsx(RR,{ref:n,className:re("z-50 min-w-[6rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...t})}));AR.displayName=RR.displayName;const Ri=g.forwardRef(({className:e,inset:t,...n},r)=>h.jsx(NR,{ref:r,className:re("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Ri.displayName=NR.displayName;const rW=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>h.jsxs(TR,{ref:i,checked:n,className:re("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-7 pr-2 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[h.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:h.jsx(eW,{children:h.jsx(wl,{className:"h-3.5 w-3.5"})})}),t]}));rW.displayName=TR.displayName;const jR=g.forwardRef(({className:e,...t},n)=>h.jsx(IR,{ref:n,className:re("-mx-1 my-1 h-px bg-border",e),...t}));jR.displayName=IR.displayName;const iW=g.forwardRef(({className:e,...t},n)=>h.jsx(ER,{ref:n,className:re("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));iW.displayName=ER.displayName;function sW({tool:e,className:t}){const n=QF(e);return h.jsx("span",{"data-testid":n?`session-icon-${e}`:"session-icon-default","aria-label":n?ny(e):"未知引擎",className:re("w-3.5 h-3.5 shrink-0 inline-flex items-center justify-center",hp(e),t),children:h.jsx(dp,{tool:e,className:"w-full h-full"})})}function oW({sessionId:e,hasUnread:t,running:n=!1,awaitingUser:r=!1,style:i}){return r?h.jsx(S$,{"data-testid":`awaiting-dot-${e}`,style:i,className:"w-3 h-3 text-warning shrink-0 animate-pulse",strokeWidth:2.25,"aria-label":"awaiting user"}):t?h.jsx("span",{"data-testid":`unread-dot-${e}`,style:i,className:"w-2 h-2 rounded-full bg-error shrink-0","aria-label":"unread"}):n?h.jsx("span",{"data-testid":`running-dot-${e}`,style:i,className:"w-2 h-2 rounded-full bg-success shrink-0 animate-pulse","aria-label":"running"}):null}function LR(e){return e.compositionActive||!!e.nativeIsComposing||e.keyCode===229}function DR(e){return e.key==="Enter"&&!e.shiftKey&&!LR(e)}function Ru(e,t){const n=g.useRef(!1),r=g.useCallback(()=>{n.current=!0},[]),i=g.useCallback(()=>{setTimeout(()=>{n.current=!1},0)},[]);return{onKeyDown:g.useCallback(o=>{const a=o.nativeEvent;if(DR({key:o.key,shiftKey:o.shiftKey,compositionActive:n.current,nativeIsComposing:a.isComposing,keyCode:a.keyCode})){o.preventDefault(),e();return}t&&o.key==="Escape"&&(o.preventDefault(),t())},[e,t]),onCompositionStart:r,onCompositionEnd:i}}function aW({open:e,initialLabel:t,placeholder:n,onSubmit:r,onCancel:i,title:s="Edit session",fieldLabel:o="Label",testId:a="session-edit-dialog",requireNonEmpty:l=!1}){const[c,u]=g.useState(t);g.useEffect(()=>{e&&u(t)},[e,t]);const d=c.trim(),f=l&&d==="",p=()=>{f||r({label:d})},m=Ru(p,i);return e?fl.createPortal(h.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-bg-0/40 backdrop-blur-[2px]",onClick:i,"data-testid":`${a}-overlay`,children:h.jsxs("div",{"data-testid":a,className:"w-[420px] max-w-[calc(100vw-32px)] rounded-2xl border border-text-100/[0.12] flex flex-col gap-4 p-5",style:{backgroundColor:"var(--bg-0)",boxShadow:"0 12px 40px rgba(0,0,0,0.04)"},onClick:v=>v.stopPropagation(),children:[h.jsx("div",{className:"text-[15px] font-semibold text-text-100",children:s}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:o}),h.jsx("input",{autoFocus:!0,type:"text",value:c,onChange:v=>u(v.target.value),...m,placeholder:n,"data-testid":`${a}-label`,className:"w-full px-3 py-2 text-[13px] bg-bg-50 border border-bg-300 rounded-lg focus:outline-none focus:border-text-300 transition-colors"})]}),h.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[h.jsx("button",{type:"button",onClick:i,className:"px-4 py-1.5 text-[12px] text-text-300 rounded-lg hover:bg-text-100/5 transition-colors cursor-pointer",children:"Cancel"}),h.jsx("button",{type:"button",onClick:p,disabled:f,"data-testid":`${a}-save`,className:"px-4 py-1.5 text-[12px] font-medium text-bg-0 rounded-lg bg-text-100 hover:bg-text-200 transition-colors cursor-pointer disabled:cursor-not-allowed disabled:opacity-40",children:"Save"})]})]})}),document.body):null}var lW=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),cW="VisuallyHidden",OR=g.forwardRef((e,t)=>h.jsx(It.span,{...e,ref:t,style:{...lW,...e.style}}));OR.displayName=cW;var uW=OR,[Sp]=Fo("Tooltip",[xp]),kp=xp(),BR="TooltipProvider",dW=700,N0="tooltip.open",[hW,Ey]=Sp(BR),zR=e=>{const{__scopeTooltip:t,delayDuration:n=dW,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=g.useRef(!0),a=g.useRef(!1),l=g.useRef(0);return g.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),h.jsx(hW,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:g.useCallback(()=>{window.clearTimeout(l.current),o.current=!1},[]),onClose:g.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:g.useCallback(c=>{a.current=c},[]),disableHoverableContent:i,children:s})};zR.displayName=BR;var au="Tooltip",[fW,Cp]=Sp(au),$R=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=Ey(au,e.__scopeTooltip),c=kp(t),[u,d]=g.useState(null),f=$i(),p=g.useRef(0),m=o??l.disableHoverableContent,v=a??l.delayDuration,w=g.useRef(!1),[x,_]=Cu({prop:r,defaultProp:i??!1,onChange:N=>{N?(l.onOpen(),document.dispatchEvent(new CustomEvent(N0))):l.onClose(),s==null||s(N)},caller:au}),y=g.useMemo(()=>x?w.current?"delayed-open":"instant-open":"closed",[x]),S=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,w.current=!1,_(!0)},[_]),C=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,_(!1)},[_]),k=g.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{w.current=!0,_(!0),p.current=0},v)},[v,_]);return g.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),h.jsx(fy,{...c,children:h.jsx(fW,{scope:t,contentId:f,open:x,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:g.useCallback(()=>{l.isOpenDelayedRef.current?k():S()},[l.isOpenDelayedRef,k,S]),onTriggerLeave:g.useCallback(()=>{m?C():(window.clearTimeout(p.current),p.current=0)},[C,m]),onOpen:S,onClose:C,disableHoverableContent:m,children:n})})};$R.displayName=au;var T0="TooltipTrigger",FR=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Cp(T0,n),s=Ey(T0,n),o=kp(n),a=g.useRef(null),l=Jt(t,a,i.onTriggerChange),c=g.useRef(!1),u=g.useRef(!1),d=g.useCallback(()=>c.current=!1,[]);return g.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),h.jsx(bP,{asChild:!0,...o,children:h.jsx(It.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:Re(e.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:Re(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:Re(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Re(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Re(e.onBlur,i.onClose),onClick:Re(e.onClick,i.onClose)})})});FR.displayName=T0;var pW="TooltipPortal",[Rae,mW]=Sp(pW,{forceMount:void 0}),Ja="TooltipContent",HR=g.forwardRef((e,t)=>{const n=mW(Ja,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=Cp(Ja,e.__scopeTooltip);return h.jsx(Ji,{present:r||o.open,children:o.disableHoverableContent?h.jsx(UR,{side:i,...s,ref:t}):h.jsx(gW,{side:i,...s,ref:t})})}),gW=g.forwardRef((e,t)=>{const n=Cp(Ja,e.__scopeTooltip),r=Ey(Ja,e.__scopeTooltip),i=g.useRef(null),s=Jt(t,i),[o,a]=g.useState(null),{trigger:l,onClose:c}=n,u=i.current,{onPointerInTransitChange:d}=r,f=g.useCallback(()=>{a(null),d(!1)},[d]),p=g.useCallback((m,v)=>{const w=m.currentTarget,x={x:m.clientX,y:m.clientY},_=bW(x,w.getBoundingClientRect()),y=wW(x,_),S=SW(v.getBoundingClientRect()),C=CW([...y,...S]);a(C),d(!0)},[d]);return g.useEffect(()=>()=>f(),[f]),g.useEffect(()=>{if(l&&u){const m=w=>p(w,u),v=w=>p(w,l);return l.addEventListener("pointerleave",m),u.addEventListener("pointerleave",v),()=>{l.removeEventListener("pointerleave",m),u.removeEventListener("pointerleave",v)}}},[l,u,p,f]),g.useEffect(()=>{if(o){const m=v=>{const w=v.target,x={x:v.clientX,y:v.clientY},_=(l==null?void 0:l.contains(w))||(u==null?void 0:u.contains(w)),y=!kW(x,o);_?f():y&&(f(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[l,u,o,c,f]),h.jsx(UR,{...e,ref:s})}),[vW,xW]=Sp(au,{isInside:!1}),_W=a9("TooltipContent"),UR=g.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,l=Cp(Ja,n),c=kp(n),{onClose:u}=l;return g.useEffect(()=>(document.addEventListener(N0,u),()=>document.removeEventListener(N0,u)),[u]),g.useEffect(()=>{if(l.trigger){const d=f=>{const p=f.target;p!=null&&p.contains(l.trigger)&&u()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,u]),h.jsx(fp,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:h.jsxs(wP,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[h.jsx(_W,{children:r}),h.jsx(vW,{scope:n,isInside:!0,children:h.jsx(uW,{id:l.contentId,role:"tooltip",children:i||r})})]})})});HR.displayName=Ja;var WR="TooltipArrow",yW=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=kp(n);return xW(WR,n).isInside?null:h.jsx(SP,{...i,...r,ref:t})});yW.displayName=WR;function bW(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function wW(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function SW(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function kW(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(i=!i)}return i}function CW(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),EW(t)}function EW(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],o=t[t.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var NW=zR,TW=$R,IW=FR,VR=HR;const cf=NW,Ep=TW,Np=IW,Mu=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(VR,{ref:r,sideOffset:t,className:re("z-50 overflow-hidden rounded-sm border border-border bg-bg-0 px-2 py-1 text-xs text-text-300 shadow-md",e),...n}));Mu.displayName=VR.displayName;const PW={held:!1,indexBySessionId:new Map},RW=g.createContext(PW);function MW(){return g.useContext(RW)}const AW=Array.from({length:9},(e,t)=>({id:`switch-session-${t+1}`,combo:{key:String(t+1),mod:!0},label:`切换到第 ${t+1} 个会话`,group:"会话",desktopOnly:!0,hiddenInList:!0})),jW=[{id:"new-session",combo:{key:"n",mod:!0},label:"新建任务",description:"打开快捷新建弹窗",group:"通用",desktopOnly:!0},{id:"open-search",combo:{key:"k",mod:!0},label:"全局搜索",description:"搜会话内容 / persona / 联系人",group:"通用",desktopOnly:!0},{id:"search-tab-prev",combo:{key:"ArrowLeft",mod:!0},label:"搜索:上一组",description:"搜索浮层里切到左边那个 tab(会话 / persona / 联系人)",group:"通用"},{id:"search-tab-next",combo:{key:"ArrowRight",mod:!0},label:"搜索:下一组",description:"搜索浮层里切到右边那个 tab",group:"通用"},...AW,{id:"archive-session",combo:{key:"Backspace",mod:!0,shift:!0},label:"归档当前会话",description:"归档当前聊天区的会话,Enter 确认 / Esc 取消",group:"会话",desktopOnly:!0},{id:"tab-prev",combo:{key:"ArrowLeft",mod:!0,shift:!0},label:"上一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"tab-next",combo:{key:"ArrowRight",mod:!0,shift:!0},label:"下一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"send-message",combo:{key:"Enter"},label:"发送消息",description:"在输入框中发送当前内容",group:"输入",displayOnly:!0},{id:"newline",combo:{key:"Enter",shift:!0},label:"换行",description:"在输入框中插入换行",group:"输入",displayOnly:!0},{id:"interrupt",combo:{key:"Escape"},label:"打断回复",description:"打断当前回复;2 秒内按两次停止任务",group:"输入",displayOnly:!0}];jW.filter(e=>!e.displayOnly);function LW(){return/Mac|iP(hone|od|ad)/.test(navigator.platform)}const DW=10,OW=20,BW=16,CS=20,ES=60,zW=4;function Sd({testId:e,label:t,children:n}){return h.jsxs(Ep,{children:[h.jsx(Np,{asChild:!0,children:h.jsx("span",{"data-testid":e,role:"img","aria-label":t,tabIndex:0,className:"inline-flex shrink-0",children:n})}),h.jsx(Mu,{side:"bottom",children:t})]})}function $W({session:e,active:t,hasUnread:n,running:r=!1,awaitingUser:i=!1,onSelect:s,onEdit:o,onDelete:a,onPin:l,onArchive:c,quickAction:u,depth:d=0,chevron:f,showCopyResume:p=!0,contactDisplayName:m,ownerPrincipalId:v,creatorDisplayName:w,dispatchedFromSessionTitle:x}){const[_,y]=g.useState(!1),S=MW(),C=S.held?S.indexBySessionId.get(e.sessionId):void 0,k=!!e.pinnedAt,N=d===0,T=d===0&&!!c,O=DW+d*OW;let P=null;u==="pin"&&N&&l?P={icon:k?h.jsx(Vw,{className:"w-4 h-4"}):h.jsx(qw,{className:"w-4 h-4"}),label:k?"取消置顶":"置顶",run:()=>l(e.sessionId,!k)}:u==="archive"&&T&&c?P={icon:h.jsx(Hw,{className:"w-4 h-4"}),label:"归档",run:()=>c(e.sessionId,!0)}:u==="rename"&&o&&(P={icon:h.jsx(v0,{className:"w-4 h-4"}),label:"重命名",run:()=>y(!0)});const D=g.useCallback(async()=>{const $=VI(e);if($)try{await navigator.clipboard.writeText($)}catch{}},[e]),R=ry(e),A=e.originOwnerPrincipalId,M=A?`@${m??`…${A.slice(-8)}`}`:null,L=!!(e.ownerPersonaId&&v&&e.creatorPrincipalId&&e.creatorPrincipalId!==v&&!e.larkChatId&&!e.shiftFiredFromSessionId&&!e.dispatchedFromSessionId);return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":`session-item-${e.sessionId}`,onClick:s,style:{paddingLeft:O,display:"grid",gridTemplateColumns:f?`${BW}px ${CS}px 1fr auto ${ES}px`:`${CS}px 1fr auto ${ES}px`,gridTemplateAreas:f?'"chev icon name dot time"':'"icon name dot time"',columnGap:`${zW}px`,alignItems:"center"},className:re("group relative rounded-lg cursor-pointer transition-all duration-150 pr-2.5 py-1.5",t?"bg-accent-dim":"hover:bg-sidebar-hover-bg"),children:[t?h.jsx("span",{"aria-hidden":"true",className:"absolute left-0 top-1/2 -translate-y-1/2 w-[3px] h-7 rounded-r-full bg-accent"}):null,h.jsx("div",{style:{gridArea:"chev"},className:"flex items-center justify-center",children:f??null}),h.jsx("div",{style:{gridArea:"icon"},className:"flex items-center justify-center",children:h.jsx(sW,{tool:e.tool})}),h.jsxs("div",{style:{gridArea:"name"},className:"flex items-center gap-1 min-w-0",children:[h.jsxs(cf,{delayDuration:200,skipDelayDuration:100,children:[e.dispatchedFromSessionId?h.jsx(Sd,{testId:`dispatched-icon-${e.sessionId}`,label:`来自【${x??"另一会话"}】dispatch`,children:h.jsx(U$,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.shiftFiredFromSessionId?h.jsx(Sd,{testId:`shift-fired-icon-${e.sessionId}`,label:"定时任务",children:h.jsx(g$,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.larkChatId?h.jsx(Sd,{testId:`lark-chat-icon-${e.sessionId}`,label:e.larkChatType==="p2p"?"来自飞书DM":"来自飞书群",children:h.jsx(g8,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,L?h.jsx(Sd,{testId:`guest-created-icon-${e.sessionId}`,label:w?`${w}创建`:"其他人创建",children:h.jsx(J8,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null]}),h.jsx("span",{"data-testid":`session-title-${e.sessionId}`,className:re("text-[13px] truncate min-w-0","group-hover:whitespace-normal group-hover:overflow-visible group-hover:break-words",t?"text-text-100 font-medium":"text-text-200"),children:R}),M?h.jsx("span",{"data-testid":`session-mirror-chip-${e.sessionId}`,title:`在 ${M.replace(/^@/,"")} 的设备上`,className:"shrink-0 inline-flex items-center px-1.5 py-0 rounded text-[10px] bg-accent-dim/40 text-accent border border-accent/20 max-w-[120px] truncate",children:M}):null]}),h.jsx(oW,{sessionId:e.sessionId,hasUnread:n,running:r,awaitingUser:i,style:{gridArea:"dot"}}),C!=null?h.jsx("span",{style:{gridArea:"time"},"data-testid":`session-quick-switch-badge-${e.sessionId}`,className:"text-right shrink-0 transition-opacity duration-150 group-hover:opacity-0",children:h.jsx("span",{className:"inline-flex items-center justify-center h-[18px] px-1.5 rounded-[5px] border border-border bg-bg-200/70 text-[11px] text-text-200 font-medium leading-none",children:LW()?`⌘${C}`:`Ctrl+${C}`})}):h.jsx("span",{style:{gridArea:"time"},className:re("text-[11px] text-text-400/70 text-right shrink-0","transition-opacity duration-150 group-hover:opacity-0"),children:e.updatedAt?ZF(e.updatedAt):""}),o||a||l||c?h.jsxs("div",{className:"absolute right-2 top-[3px] flex items-center opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100 transition-opacity",children:[P?h.jsx(cf,{delayDuration:200,skipDelayDuration:100,children:h.jsxs(Ep,{children:[h.jsx(Np,{asChild:!0,children:h.jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),P.run()},className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":P.label,"data-testid":`quick-action-${u}-${e.sessionId}`,children:P.icon})}),h.jsx(Mu,{side:"bottom",children:P.label})]})}):null,h.jsxs(ky,{modal:!1,children:[h.jsx(Cy,{asChild:!0,children:h.jsx("button",{type:"button",onClick:$=>$.stopPropagation(),className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"session actions","data-testid":`session-menu-${e.sessionId}`,children:h.jsx(yI,{className:"w-4 h-4"})})}),h.jsxs(wp,{align:"end",onClick:$=>$.stopPropagation(),children:[l&&N&&h.jsxs(Ri,{onSelect:()=>l(e.sessionId,!k),"data-testid":`session-${k?"unpin":"pin"}-${e.sessionId}`,children:[k?h.jsx(Vw,{className:"w-3 h-3 mr-2 text-text-400"}):h.jsx(qw,{className:"w-3 h-3 mr-2 text-text-400"}),k?"Unpin":"Pin"]}),T&&c&&h.jsxs(Ri,{onSelect:()=>c(e.sessionId,!0),"data-testid":`session-archive-${e.sessionId}`,children:[h.jsx(Hw,{className:"w-3 h-3 mr-2 text-text-400"}),"Archive"]}),o&&h.jsxs(Ri,{onSelect:()=>y(!0),"data-testid":`session-rename-${e.sessionId}`,children:[h.jsx(v0,{className:"w-3 h-3 mr-2 text-text-400"}),"Rename"]}),p&&e.toolSessionId?h.jsxs(Ri,{onSelect:()=>void D(),"data-testid":`session-copy-resume-${e.sessionId}`,children:[h.jsx(up,{className:"w-3 h-3 mr-2 text-text-400"}),"Copy Resume Command"]}):null,(l||o||p&&e.toolSessionId)&&a&&h.jsx(jR,{}),a&&h.jsxs(Ri,{onSelect:()=>void a(e.sessionId),className:"text-destructive focus:text-destructive focus:bg-destructive/10","data-testid":`session-delete-${e.sessionId}`,children:[h.jsx(J_,{className:"w-3 h-3 mr-2"}),"Delete"]})]})]})]}):null]}),o?h.jsx(aW,{open:_,initialLabel:e.label??"",placeholder:e.cwd.split("/").pop()||"",onSubmit:$=>{o(e.sessionId,$),y(!1)},onCancel:()=>y(!1)}):null]})}function Ny({node:e,depth:t=0,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:v,getSessionDisplayName:w,parentSession:x}){const _=e.children.length>0,{isCollapsed:y,toggle:S}=c$(),C=!y(e.session.sessionId),k=g.useCallback(T=>{T.stopPropagation(),S(e.session.sessionId)},[S,e.session.sessionId]),N=_?h.jsx("button",{type:"button",onClick:k,"data-testid":`session-chevron-${e.session.sessionId}`,"aria-label":C?"collapse":"expand","aria-expanded":C,className:"shrink-0 flex items-center justify-center w-4 h-4 text-text-400 hover:text-text-100 cursor-pointer",children:C?h.jsx(Yn,{className:"w-3 h-3"}):h.jsx(Bn,{className:"w-3 h-3"})}):null;return h.jsxs("div",{"data-testid":`session-tree-node-${e.session.sessionId}`,children:[h.jsx($W,{session:e.session,active:n===e.session.sessionId,hasUnread:(r==null?void 0:r.has(e.session.sessionId))??!1,running:(i==null?void 0:i.has(e.session.sessionId))??!1,awaitingUser:(s==null?void 0:s.has(e.session.sessionId))??!1,onSelect:()=>o(e.session.sessionId),onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,showCopyResume:p,ownerPrincipalId:m,creatorDisplayName:e.session.creatorPrincipalId?v==null?void 0:v(e.session.creatorPrincipalId):void 0,dispatchedFromSessionTitle:e.session.dispatchedFromSessionId?(w==null?void 0:w(e.session.dispatchedFromSessionId))??((x==null?void 0:x.sessionId)===e.session.dispatchedFromSessionId?ry(x):void 0):void 0,depth:t,chevron:N,contactDisplayName:e.session.originOwnerPrincipalId?f==null?void 0:f(e.session.originOwnerPrincipalId):void 0}),_&&C?h.jsx("div",{"data-testid":`session-tree-children-${e.session.sessionId}`,children:e.children.map(T=>h.jsx(Ny,{node:T,depth:t+1,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:v,getSessionDisplayName:w,parentSession:e.session},T.session.sessionId))}):null]})}function FW(e){return e.forkedFromSessionId??e.dispatchedFromSessionId??e.shiftFiredFromSessionId}function qR(e){e=e.filter(s=>!s.ephemeral&&s.deployId===void 0);const t=new Map;for(const s of e)t.set(s.sessionId,s);const n=new Map,r=[];for(const s of e){const o=FW(s);if(o&&t.has(o)){const a=n.get(o)??[];a.push(s),n.set(o,a)}else r.push(s)}const i=s=>{const a=[...n.get(s.sessionId)??[]].sort((l,c)=>l.createdAt<c.createdAt?-1:l.createdAt>c.createdAt?1:0);return{session:s,children:a.map(i)}};return[...r].sort(HW).map(i)}function KR(e){return[...e].sort((t,n)=>t.session.updatedAt<n.session.updatedAt?1:t.session.updatedAt>n.session.updatedAt?-1:0)}function HW(e,t){const n=typeof e.pinnedAt=="number",r=typeof t.pinnedAt=="number";if(n&&r){const i=typeof e.pinSortOrder=="number",s=typeof t.pinSortOrder=="number";return i&&s?e.pinSortOrder-t.pinSortOrder:i?-1:s?1:t.pinnedAt-e.pinnedAt}return n?-1:r||e.updatedAt<t.updatedAt?1:e.updatedAt>t.updatedAt?-1:0}function UW(e){return e.appBuilderProject?`[app] ${e.appBuilderProject}`:e.label?e.label:e.aiLabel?e.aiLabel:e.cwd.split("/").filter(Boolean).pop()??""}function NS(e,t){const n=t.trim().toLowerCase();return n===""?!0:e.toLowerCase().includes(n)}const WW={isCollapsed:()=>!1,toggle:()=>{},prune:()=>{}};function VW({personas:e,activePersonaId:t,onSelectPersona:n,onCreateSession:r,sessions:i,activeSessionId:s,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,isPersonaExpanded:p,onTogglePersonaExpanded:m,onEditSession:v,onPinSession:w,showCopyResume:x,treatSessionsAsRoots:_,searchQuery:y}){const[S,C]=g.useState(null),[k,N]=g.useState(()=>new Set),T=p??(L=>k.has(L)),O=g.useCallback(L=>{if(m){m(L);return}N($=>{const F=new Set($);return F.has(L)?F.delete(L):F.add(L),F})},[m]),P=g.useMemo(()=>i==null?void 0:i.filter(L=>!L.ephemeral),[i]),D=g.useMemo(()=>new Map((P??[]).map(L=>[L.sessionId,ry(L)])),[P]),R=g.useCallback(L=>f==null?void 0:f.get(L),[f]),A=g.useCallback(L=>D.get(L),[D]);if(e.length===0)return h.jsx(qW,{});const M=(y??"").trim();return M?h.jsx(X_.Provider,{value:WW,children:h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(L=>{const $=P?P.filter(E=>E.ownerPersonaId===L.personaId).sort((E,H)=>H.updatedAt>E.updatedAt?1:-1):[],F=NS(L.label,M),B=$.filter(E=>NS(UW(E),M));if(!F&&B.length===0)return null;const z=F?$:B;return h.jsx(TS,{persona:L,active:L.personaId===t,editing:!1,onSelectPersona:n,onSubmitCreateSession:()=>{},onCancelCreateSession:()=>{},personaSessions:z,collapsed:!1,onToggleCollapsed:()=>{},activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:w,showCopyResume:x,treatSessionsAsRoots:_,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:R,getSessionDisplayName:A},L.personaId)})})}):h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(L=>{const $=P?P.filter(F=>F.ownerPersonaId===L.personaId).sort((F,B)=>B.updatedAt>F.updatedAt?1:-1):[];return h.jsx(TS,{persona:L,active:L.personaId===t,editing:L.personaId===S,onSelectPersona:n,onStartCreateSession:r?()=>C(L.personaId):void 0,onSubmitCreateSession:F=>{C(null),r==null||r(L.personaId,F)},onCancelCreateSession:()=>C(null),personaSessions:$,collapsed:!T(L.personaId),onToggleCollapsed:()=>O(L.personaId),activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:w,showCopyResume:x,treatSessionsAsRoots:_,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:R,getSessionDisplayName:A},L.personaId)})})}function qW(){return h.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-text-400",children:"还没有 persona。点上方 Personas 标题右侧 + 创建第一个。"})}function TS({persona:e,active:t,editing:n,onSelectPersona:r,onStartCreateSession:i,onSubmitCreateSession:s,onCancelCreateSession:o,personaSessions:a,collapsed:l,onToggleCollapsed:c,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:w,onPinSession:x,showCopyResume:_,treatSessionsAsRoots:y,ownerPrincipalId:S,creatorDisplayNameByOwnerId:C,getCreatorDisplayName:k,getSessionDisplayName:N}){const T=a.length>0,O=!l,P=g.useMemo(()=>{const A=[],M=new Map;for(const L of a){const $=L.creatorPrincipalId;if(L.larkChatId!=null||!$||S&&$===S){A.push(L);continue}const F=$,B=(C==null?void 0:C.get(F))??`…${F.slice(-8)}`,z=M.get(F);z?z.sessions.push(L):M.set(F,{groupKey:F,displayName:B,sessions:[L]})}return{self:A,byPeer:[...M.values()]}},[a,S,C]),D=P.byPeer.length>0,R=g.useMemo(()=>O&&!D?KR(qR(a)):[],[O,D,a]);return h.jsxs("div",{"data-testid":`persona-node-${e.personaId}`,children:[h.jsxs("div",{className:re("group flex items-center gap-1 px-2 py-1.5 cursor-pointer",t?"bg-accent-dim text-text-100":"hover:bg-bg-200 text-text-200"),onClick:()=>r==null?void 0:r(e.personaId),role:"button",tabIndex:0,children:[T?h.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),c()},"aria-label":O?"collapse":"expand","aria-expanded":O,"data-testid":`persona-chevron-${e.personaId}`,className:"flex h-4 w-4 shrink-0 items-center justify-center text-text-400 hover:text-text-100",children:O?h.jsx(Yn,{className:"h-3 w-3"}):h.jsx(Bn,{className:"h-3 w-3"})}):h.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),h.jsx(dp,{tool:e.tool,className:re("h-3.5 w-3.5 shrink-0",hp(e.tool))}),h.jsx("span",{className:"flex-1 truncate text-[13px]",children:e.label}),T?h.jsx("span",{className:"shrink-0 text-[10px] text-text-400 tabular-nums","aria-label":`${a.length} sessions`,children:a.length}):null,i?h.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),i()},"aria-label":"新建会话",title:"新建会话","data-testid":`persona-create-session-${e.personaId}`,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded text-text-400 opacity-0 hover:bg-text-100/10 hover:text-text-100 focus-visible:opacity-100 group-hover:opacity-100",children:h.jsx(I8,{className:"h-3.5 w-3.5"})}):null]}),n?h.jsx(KW,{personaId:e.personaId,tool:e.tool,onSubmit:s,onCancel:o}):null,T&&O?h.jsx("div",{"data-testid":`persona-sessions-${e.personaId}`,children:D?h.jsxs(h.Fragment,{children:[P.self.length>0&&h.jsx(IS,{groupKey:`${e.personaId}-self`,label:"我自己",testId:`persona-sessions-${e.personaId}-self`,sessions:P.self,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:w,onPinSession:x,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N}),P.byPeer.map(A=>h.jsx(IS,{groupKey:`${e.personaId}-peer-${A.groupKey}`,label:A.displayName,testId:`persona-sessions-${e.personaId}-peer-${A.groupKey}`,sessions:A.sessions,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:w,onPinSession:x,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N},`${e.personaId}-peer-${A.groupKey}`))]}):R.map(A=>h.jsx(Ny,{node:A,depth:y?0:1,activeId:u,unreadIds:p,runningIds:f,awaitingIds:d,onSelect:M=>m==null?void 0:m(M),onDelete:v,onEdit:w,onPin:x,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N},A.session.sessionId))}):null]})}function IS({label:e,testId:t,sessions:n,activeSessionId:r,awaitingIds:i,runningIds:s,unreadIds:o,onSelectSession:a,onDeleteSession:l,onEditSession:c,onPinSession:u,showCopyResume:d,ownerPrincipalId:f,getCreatorDisplayName:p,getSessionDisplayName:m}){const[v,w]=g.useState(!1),x=!v,_=g.useMemo(()=>x?KR(qR(n)):[],[x,n]);return h.jsxs("div",{"data-testid":t,children:[h.jsxs("button",{type:"button",onClick:()=>w(y=>!y),"aria-label":x?"collapse":"expand","aria-expanded":x,"data-testid":`${t}-chevron`,className:"flex items-center gap-1 w-full pl-7 pr-2 py-0.5 text-[11px] text-text-400 hover:text-text-200 transition-colors",children:[x?h.jsx(Yn,{className:"h-3 w-3"}):h.jsx(Bn,{className:"h-3 w-3"}),h.jsx(NI,{className:"h-3 w-3","aria-hidden":!0}),h.jsx("span",{className:"truncate",children:e}),h.jsx("span",{className:"ml-auto tabular-nums",children:n.length})]}),x&&h.jsx("div",{children:_.map(y=>h.jsx(Ny,{node:y,depth:2,activeId:r,unreadIds:o,runningIds:s,awaitingIds:i,onSelect:S=>a==null?void 0:a(S),onDelete:l,onEdit:c,onPin:u,showCopyResume:d,ownerPrincipalId:f,getCreatorDisplayName:p,getSessionDisplayName:m},y.session.sessionId))})]})}function KW({personaId:e,tool:t,onSubmit:n,onCancel:r}){const[i,s]=g.useState(""),o=g.useRef(null),a=i.trim(),l=a.length>0;g.useEffect(()=>{var d;(d=o.current)==null||d.focus()},[]);const c=g.useCallback(()=>{l&&n(a)},[l,a,n]),u=Ru(c,r);return h.jsxs("div",{className:"flex items-center gap-1.5 pl-9 pr-2 py-1","data-testid":`persona-new-session-row-${e}`,children:[h.jsx(dp,{tool:t,className:re("h-3 w-3 shrink-0",hp(t))}),h.jsx("input",{ref:o,type:"text",value:i,onChange:d=>s(d.target.value),...u,onBlur:r,placeholder:"session label...","data-testid":`persona-new-session-input-${e}`,className:"flex-1 min-w-0 bg-bg-100 border border-text-100/15 rounded px-1.5 py-0.5 text-[12px] text-text-100 placeholder:text-text-400 focus:outline-none focus:border-text-100/40"}),h.jsx("button",{type:"button",onMouseDown:d=>{d.preventDefault(),c()},disabled:!l,"aria-label":"确认",title:"确认(Enter)","data-testid":`persona-new-session-confirm-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-text-300",children:h.jsx(wl,{className:"h-3 w-3"})}),h.jsx("button",{type:"button",onMouseDown:d=>{d.preventDefault(),r()},"aria-label":"取消",title:"取消(Esc)","data-testid":`persona-new-session-cancel-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100",children:h.jsx(Ir,{className:"h-3 w-3"})})]})}function GW(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function YW(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),r=parseFloat(n.fontSize);return t*r}function XW(e){return e/100*window.innerHeight}function QW(e){return e/100*window.innerWidth}function ZW(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function ic({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=ZW(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=YW(t,i);break}case"em":{r=GW(t,i);break}case"vh":{r=XW(i);break}case"vw":{r=QW(i);break}}return r}function Mn(e){return parseFloat(e.toFixed(3))}function el({group:e}){const{orientation:t,panels:n}=e;return n.reduce((r,i)=>(r+=t==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,r),0)}function I0(e){const{panels:t}=e,n=el({group:e});return n===0?t.map(r=>({groupResizeBehavior:r.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:r.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:r.panelConstraints.disabled,minSize:0,maxSize:100,panelId:r.id})):t.map(r=>{const{element:i,panelConstraints:s}=r;let o=0;if(s.collapsedSize!==void 0){const u=ic({groupSize:n,panelElement:i,styleProp:s.collapsedSize});o=Mn(u/n*100)}let a;if(s.defaultSize!==void 0){const u=ic({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=Mn(u/n*100)}let l=0;if(s.minSize!==void 0){const u=ic({groupSize:n,panelElement:i,styleProp:s.minSize});l=Mn(u/n*100)}let c=100;if(s.maxSize!==void 0){const u=ic({groupSize:n,panelElement:i,styleProp:s.maxSize});c=Mn(u/n*100)}return{groupResizeBehavior:s.groupResizeBehavior,collapsedSize:o,collapsible:s.collapsible===!0,defaultSize:a,disabled:s.disabled,minSize:l,maxSize:c,panelId:r.id}})}function st(e,t="Assertion error"){if(!e)throw Error(t)}function P0(e,t){return Array.from(t).sort(e==="horizontal"?JW:eV)}function JW(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function eV(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function GR(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function YR(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function tV({orientation:e,rects:t,targetRect:n}){const r={x:n.x+n.width/2,y:n.y+n.height/2};let i,s=Number.MAX_VALUE;for(const o of t){const{x:a,y:l}=YR(r,o),c=e==="horizontal"?a:l;c<s&&(s=c,i=o)}return st(i,"No rect found"),i}let kd;function nV(){return kd===void 0&&(typeof matchMedia=="function"?kd=!!matchMedia("(pointer:coarse)").matches:kd=!1),kd}function XR(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=P0(n,Array.from(t.children).filter(GR).map(m=>({element:m}))).map(({element:m})=>m),o=[];let a=!1,l=!1,c=-1,u=-1,d=0,f,p=[];{let m=-1;for(const v of s)v.hasAttribute("data-panel")&&(m++,v.hasAttribute("data-disabled")||(d++,c===-1&&(c=m),u=m))}if(d>1){let m=-1;for(const v of s)if(v.hasAttribute("data-panel")){m++;const w=r.find(x=>x.element===v);if(w){if(f){const x=f.element.getBoundingClientRect(),_=v.getBoundingClientRect();let y;if(l){const S=n==="horizontal"?new DOMRect(x.right,x.top,0,x.height):new DOMRect(x.left,x.bottom,x.width,0),C=n==="horizontal"?new DOMRect(_.left,_.top,0,_.height):new DOMRect(_.left,_.top,_.width,0);switch(p.length){case 0:{y=[S,C];break}case 1:{const k=p[0],N=tV({orientation:n,rects:[x,_],targetRect:k.element.getBoundingClientRect()});y=[k,N===x?C:S];break}default:{y=p;break}}}else p.length?y=p:y=[n==="horizontal"?new DOMRect(x.right,_.top,_.left-x.right,_.height):new DOMRect(_.left,x.bottom,_.width,_.top-x.bottom)];for(const S of y){let C="width"in S?S:S.element.getBoundingClientRect();const k=nV()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(C.width<k){const T=k-C.width;C=new DOMRect(C.x-T/2,C.y,C.width+T,C.height)}if(C.height<k){const T=k-C.height;C=new DOMRect(C.x,C.y-T/2,C.width,C.height+T)}const N=m<=c||m>u;!a&&!N&&o.push({group:e,groupSize:el({group:e}),panels:[f,w],separator:"width"in S?void 0:S,rect:C}),a=!1}}l=!1,f=w,p=[]}}else if(v.hasAttribute("data-separator")){v.ariaDisabled!==null&&(a=!0);const w=i.find(x=>x.element===v);w?p.push(w):(f=void 0,p=[])}else l=!0}return o}var _s;class QR{constructor(){I1(this,_s,{})}addListener(t,n){const r=Rl(this,_s)[t];return r===void 0?Rl(this,_s)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=Rl(this,_s)[t];if(r!==void 0)if(r.length===1)r[0].call(null,n);else{let i=!1,s=null;const o=Array.from(r);for(let a=0;a<o.length;a++){const l=o[a];try{l.call(null,n)}catch(c){s===null&&(i=!0,s=c)}}if(i)throw s}}removeAllListeners(){P1(this,_s,{})}removeListener(t,n){const r=Rl(this,_s)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}_s=new WeakMap;let Oa={cursorFlags:0,state:"inactive"};const Ty=new QR;function Io(){return Oa}function rV(e){return Ty.addListener("change",e)}function iV(e){const t=Oa,n={...Oa};n.cursorFlags=e,Oa=n,Ty.emit("change",{prev:t,next:n})}function Ba(e){const t=Oa;Oa=e,Ty.emit("change",{prev:t,next:e})}const sV=e=>e,qm=()=>{},ZR=1,JR=2,e5=4,t5=8,PS=3,RS=12;let Cd;function MS(){return Cd===void 0&&(Cd=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(Cd=!0)),Cd}function oV({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case"active":case"hover":t.forEach(s=>{if(!s.mutableState.disableCursor)switch(s.orientation){case"horizontal":{r++;break}case"vertical":{i++;break}}})}if(!(r===0&&i===0)){switch(n){case"active":{if(e&&MS()){const s=(e&ZR)!==0,o=(e&JR)!==0,a=(e&e5)!==0,l=(e&t5)!==0;if(s)return a?"se-resize":l?"ne-resize":"e-resize";if(o)return a?"sw-resize":l?"nw-resize":"w-resize";if(a)return"s-resize";if(l)return"n-resize"}break}}return MS()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const AS=new WeakMap;function Iy(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=AS.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));const r=Io();switch(r.state){case"active":case"hover":{const i=oV({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(o=>o.group),state:r.state}),s=`*, *:hover {cursor: ${i} !important; }`;if(t===s)return;t=s,i?n.cssRules.length===0?n.insertRule(s):n.replaceSync(s):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}AS.set(e,{prevStyle:t,styleSheet:n})}let si=new Map;const n5=new QR;function aV(e){si=new Map(si),si.delete(e)}function jS(e,t){for(const[n]of si)if(n.id===e)return n}function As(e,t){for(const[n,r]of si)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Uo(){return si}function Py(e,t){return n5.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function Gi(e,t,n){const r=si.get(e);si=new Map(si),si.set(e,t),n5.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:r,next:t})}function r5(e){const t=Io();let n=!1;switch(t.state){case"active":Ba({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(Iy(e),n=!0,t.hitRegions.forEach(r=>{const i=As(r.group.id,!0);Gi(r.group,i,{isUserInteraction:!0})}))}return n}function LS(e){e.defaultPrevented||r5(e.currentTarget)}function lV(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const o=YR(n,s.rect);switch(e){case"horizontal":{o.x<=i.x&&(r=s,i=o);break}case"vertical":{o.y<=i.y&&(r=s,i=o);break}}}return r?{distance:i,hitRegion:r}:void 0}function cV(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function uV(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:BS(e),b:BS(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();st(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:OS(DS(n.a)),b:OS(DS(n.b))};if(i.a===i.b){const s=r.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const l=s[a];if(l===o.a)return 1;if(l===o.b)return-1}}return Math.sign(i.a-i.b)}const dV=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function hV(e){const t=getComputedStyle(i5(e)??e).display;return t==="flex"||t==="inline-flex"}function fV(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||hV(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||dV.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function DS(e){let t=e.length;for(;t--;){const n=e[t];if(st(n,"Missing node"),fV(n))return n}return null}function OS(e){return e&&Number(getComputedStyle(e).zIndex)||0}function BS(e){const t=[];for(;e;)t.push(e),e=i5(e);return t}function i5(e){const{parentNode:t}=e;return cV(t)?t.host:t}function pV(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function mV({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!GR(n)||n.contains(e)||e.contains(n))return!0;if(uV(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(pV(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Ry(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=XR(i),o=lV(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&mV({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function gV(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function wn(e,t,n=0){return Math.abs(Mn(e)-Mn(t))<=n}function ti(e,t){return wn(e,t)?0:e>t?1:-1}function Ea({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){const{collapsedSize:i=0,collapsible:s,disabled:o,maxSize:a=100,minSize:l=0}=t;if(o&&!e)return n;if(ti(r,l)<0)if(s){const c=(i+l)/2;ti(r,c)<0?r=i:r=l}else r=l;return r=Math.min(a,r),r=Mn(r),r}function lu({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(wn(e,0))return t;const o=s==="imperative-api",a=Object.values(t),l=Object.values(i),c=[...a],[u,d]=r;st(u!=null,"Invalid first pivot index"),st(d!=null,"Invalid second pivot index");let f=0;switch(s){case"keyboard":{{const v=e<0?d:u,w=n[v];st(w,`Panel constraints not found for index ${v}`);const{collapsedSize:x=0,collapsible:_,minSize:y=0}=w;if(_){const S=a[v];if(st(S!=null,`Previous layout not found for panel index ${v}`),wn(S,x)){const C=y-S;ti(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}{const v=e<0?u:d,w=n[v];st(w,`No panel constraints found for index ${v}`);const{collapsedSize:x=0,collapsible:_,minSize:y=0}=w;if(_){const S=a[v];if(st(S!=null,`Previous layout not found for panel index ${v}`),wn(S,y)){const C=S-x;ti(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}break}default:{const v=e<0?d:u,w=n[v];st(w,`Panel constraints not found for index ${v}`);const x=a[v],{collapsible:_,collapsedSize:y,minSize:S}=w;if(_&&ti(x,S)<0)if(e>0){const C=S-y,k=C/2,N=x+e;ti(N,S)<0&&(e=ti(e,k)<=0?0:C)}else{const C=S-y,k=100-C/2,N=x-e;ti(N,S)<0&&(e=ti(100+e,k)>0?0:-C)}break}}{const v=e<0?1:-1;let w=e<0?d:u,x=0;for(;;){const y=a[w];st(y!=null,`Previous layout not found for panel index ${w}`);const S=Ea({overrideDisabledPanels:o,panelConstraints:n[w],prevSize:y,size:100})-y;if(x+=S,w+=v,w<0||w>=n.length)break}const _=Math.min(Math.abs(e),Math.abs(x));e=e<0?0-_:_}{let v=e<0?u:d;for(;v>=0&&v<n.length;){const w=Math.abs(e)-Math.abs(f),x=a[v];st(x!=null,`Previous layout not found for panel index ${v}`);const _=x-w,y=Ea({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:x,size:_});if(!wn(x,y)&&(f+=x-y,c[v]=y,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?v--:v++}}if(gV(l,c))return i;{const v=e<0?d:u,w=a[v];st(w!=null,`Previous layout not found for panel index ${v}`);const x=w+f,_=Ea({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:w,size:x});if(c[v]=_,!wn(_,x)){let y=x-_,S=e<0?d:u;for(;S>=0&&S<n.length;){const C=c[S];st(C!=null,`Previous layout not found for panel index ${S}`);const k=C+y,N=Ea({overrideDisabledPanels:o,panelConstraints:n[S],prevSize:C,size:k});if(wn(C,N)||(y-=N-C,c[S]=N),wn(y,0))break;e>0?S--:S++}}}const p=Object.values(c).reduce((v,w)=>w+v,0);if(!wn(p,100,.1))return i;const m=Object.keys(i);return c.reduce((v,w,x)=>(v[m[x]]=w,v),{})}function Po(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||ti(e[n],t[n])!==0)return!1;return!0}function Ro({layout:e,panelConstraints:t}){const n=Object.values(e),r=[...n],i=r.reduce((a,l)=>a+l,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(a=>`${a}%`).join(", ")}`);if(!wn(i,100)&&r.length>0)for(let a=0;a<t.length;a++){const l=r[a];st(l!=null,`No layout data found for index ${a}`);const c=100/i*l;r[a]=c}let s=0;for(let a=0;a<t.length;a++){const l=n[a];st(l!=null,`No layout data found for index ${a}`);const c=r[a];st(c!=null,`No layout data found for index ${a}`);const u=Ea({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});c!=u&&(s+=c-u,r[a]=u)}if(!wn(s,0))for(let a=0;a<t.length;a++){const l=r[a];st(l!=null,`No layout data found for index ${a}`);const c=l+s,u=Ea({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});if(l!==u&&(s-=u-l,r[a]=u,wn(s,0)))break}const o=Object.keys(e);return r.reduce((a,l,c)=>(a[o[c]]=l,a),{})}function s5({groupId:e,panelId:t}){const n=()=>{const l=Uo();for(const[c,{defaultLayoutDeferred:u,derivedPanelConstraints:d,layout:f,groupSize:p,separatorToPanels:m}]of l)if(c.id===e)return{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:c,groupSize:p,layout:f,separatorToPanels:m};throw Error(`Group ${e} not found`)},r=()=>{const l=n().derivedPanelConstraints.find(c=>c.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const l=n().group.panels.find(c=>c.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const l=n().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:l,panels:c,prevLayout:u,derivedPanelConstraints:d})=>{const f=s(),p=c.findIndex(w=>w.id===t),m=p===0,v=p===c.length-1;if(v&&l<f&&(m||c.slice(0,p).every((w,x)=>{const _=d[x];return(_==null?void 0:_.collapsible)&&wn(_.collapsedSize,u[_.panelId])}))){const w=c.slice(0,p).reduce((x,_)=>x+u[_.id],0);return{...u,[t]:Mn(100-w)}}return lu({delta:v?f-l:l-f,initialLayout:u,panelConstraints:d,pivotIndices:v?[p-1,p]:[p,p+1],prevLayout:u,trigger:"imperative-api"})},a=l=>{const c=s();if(l===c)return;const{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:f,groupSize:p,layout:m,separatorToPanels:v}=n(),w=o({nextSize:l,panels:f.panels,prevLayout:m,derivedPanelConstraints:d}),x=Ro({layout:w,panelConstraints:d});Po(m,x)||Gi(f,{defaultLayoutDeferred:u,derivedPanelConstraints:d,groupSize:p,layout:x,separatorToPanels:v})};return{collapse:()=>{const{collapsible:l,collapsedSize:c}=r(),{mutableValues:u}=i(),d=s();l&&d!==c&&(u.expandToSize=d,a(c))},expand:()=>{const{collapsible:l,collapsedSize:c,minSize:u}=r(),{mutableValues:d}=i(),f=s();if(l&&f===c){let p=d.expandToSize??u;p===0&&(p=1),a(p)}},getSize:()=>{const{group:l}=n(),c=s(),{element:u}=i(),d=l.orientation==="horizontal"?u.offsetWidth:u.offsetHeight;return{asPercentage:c,inPixels:d}},isCollapsed:()=>{const{collapsible:l,collapsedSize:c}=r(),u=s();return l&&wn(c,u)},resize:l=>{const{group:c}=n(),{element:u}=i(),d=el({group:c}),f=ic({groupSize:d,panelElement:u,styleProp:l}),p=Mn(f/d*100);a(p)}}}function zS(e){if(e.defaultPrevented)return;const t=Uo();Ry(e,t).forEach(n=>{if(n.separator&&!n.separator.disableDoubleClick){const r=n.panels.find(i=>i.panelConstraints.defaultSize!==void 0);if(r){const i=r.panelConstraints.defaultSize,s=s5({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function oh(e){const t=Uo();for(const[n]of t)if(n.separators.some(r=>r.element===e))return n;throw Error("Could not find parent Group for separator element")}function o5({groupId:e}){const t=()=>{const n=Uo();for(const[r,i]of n)if(r.id===e)return{group:r,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:r}=t();return n?{}:r},setLayout(n){const{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:s,groupSize:o,layout:a,separatorToPanels:l}=t(),c=Ro({layout:n,panelConstraints:i});return r?a:(Po(a,c)||Gi(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:o,layout:c,separatorToPanels:l}),c)}}}function eo(e,t){const n=oh(e),r=As(n.id,!0),i=n.separators.find(u=>u.element===e);st(i,"Matching separator not found");const s=r.separatorToPanels.get(i);st(s,"Matching panels not found");const o=s.map(u=>n.panels.indexOf(u)),a=o5({groupId:n.id}).getLayout(),l=lu({delta:t,initialLayout:a,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),c=Ro({layout:l,panelConstraints:r.derivedPanelConstraints});Po(a,c)||Gi(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function $S(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=oh(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&eo(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&eo(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&eo(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&eo(t,-5);break}case"End":{e.preventDefault(),eo(t,100);break}case"Enter":{e.preventDefault();const r=oh(t),i=As(r.id,!0),{derivedPanelConstraints:s,layout:o,separatorToPanels:a}=i,l=r.separators.find(f=>f.element===t);st(l,"Matching separator not found");const c=a.get(l);st(c,"Matching panels not found");const u=c[0],d=s.find(f=>f.panelId===u.id);if(st(d,"Panel metadata not found"),d.collapsible){const f=o[u.id],p=d.collapsedSize===f?r.mutableState.expandedPanelSizes[u.id]??d.minSize:d.collapsedSize;eo(t,p-f)}break}case"F6":{e.preventDefault();const r=oh(t).separators.map(o=>o.element),i=Array.from(r).findIndex(o=>o===e.currentTarget);st(i!==null,"Index not found");const s=e.shiftKey?i>0?i-1:r.length-1:i+1<r.length?i+1:0;r[s].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),eo(t,-100);break}}}function FS(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=Uo(),n=Ry(e,t),r=new Map;let i=!1;n.forEach(s=>{s.separator&&(i||(i=!0,s.separator.element.focus({focusVisible:!1,preventScroll:!0})));const o=t.get(s.group);o&&r.set(s.group,o.layout)}),Ba({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function a5({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:s,prevCursorFlags:o}){let a=0;n.forEach(c=>{const{group:u,groupSize:d}=c,{orientation:f,panels:p}=u,{disableCursor:m}=u.mutableState;let v=0;s?f==="horizontal"?v=(t.clientX-s.x)/d*100:v=(t.clientY-s.y)/d*100:f==="horizontal"?v=t.clientX<0?-100:100:v=t.clientY<0?-100:100;const w=r.get(u),x=i.get(u);if(!w||!x)return;const{defaultLayoutDeferred:_,derivedPanelConstraints:y,groupSize:S,layout:C,separatorToPanels:k}=x;if(y&&C&&k){const N=lu({delta:v,initialLayout:w,panelConstraints:y,pivotIndices:c.panels.map(T=>p.indexOf(T)),prevLayout:C,trigger:"mouse-or-touch"});if(Po(N,C)){if(v!==0&&!m)switch(f){case"horizontal":{a|=v<0?ZR:JR;break}case"vertical":{a|=v<0?e5:t5;break}}}else Gi(c.group,{defaultLayoutDeferred:_,derivedPanelConstraints:y,groupSize:S,layout:N,separatorToPanels:k})}});let l=0;t.movementX===0?l|=o&PS:l|=a&PS,t.movementY===0?l|=o&RS:l|=a&RS,iV(l),Iy(e)}function HS(e){const t=Uo(),n=Io();switch(n.state){case"active":a5({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function US(e){var r,i;if(e.defaultPrevented)return;const t=Io(),n=Uo();switch(t.state){case"active":{if(e.buttons===0){Ba({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const o=As(s.group.id,!0);Gi(s.group,o,{isUserInteraction:!0})});return}for(const s of t.hitRegions)if(s.separator){const{element:o}=s.separator;(r=o.hasPointerCapture)!=null&&r.call(o,e.pointerId)||((i=o.setPointerCapture)==null||i.call(o,e.pointerId))}a5({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=Ry(e,n);s.length===0?t.state!=="inactive"&&Ba({cursorFlags:0,state:"inactive"}):Ba({cursorFlags:0,hitRegions:s,state:"hover"}),Iy(e.currentTarget);break}}}function WS(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Io().state){case"hover":Ba({cursorFlags:0,state:"inactive"})}}function VS(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||r5(e.currentTarget)&&e.preventDefault()}function qS(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const o=Mn(s.defaultSize);n+=o,r[s.panelId]=o}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=Mn((100-n)/i);for(const o of e)o.defaultSize===void 0&&(r[o.panelId]=s)}return r}function vV(e,t,n){if(!n[0])return;const r=e.panels.find(l=>l.element===t);if(!r||!r.onResize)return;const i=el({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,a={asPercentage:Mn(s/i*100),inPixels:s};r.mutableValues.prevSize=a,r.onResize(a,r.id,o)}function xV(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function _V({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,s=0,o=!1;const a=new Map,l=[];for(const d of e.panels){const f=r[d.id]??0;switch(d.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{o=!0;const p=f/100*n,m=Mn(p/t*100);a.set(d.id,m),i+=m;break}case"preserve-relative-size":default:{l.push(d.id),s+=f;break}}}if(!o||l.length===0)return r;const c=100-i,u={...r};if(a.forEach((d,f)=>{u[f]=d}),s>0)for(const d of l){const f=r[d]??0;u[d]=Mn(f/s*c)}else{const d=Mn(c/l.length);for(const f of l)u[f]=d}return u}function yV(e,t){const n=e.map(i=>i.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n)if(!r.includes(i))return!1;return!0}const sa=new Map;function bV(e){let t=!0;st(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,s=new n(m=>{for(const v of m){const{borderBoxSize:w,target:x}=v;if(x===e.element){if(t){const _=el({group:e});if(_===0)return;const y=As(e.id);if(!y)return;const S=I0(e),C=y.defaultLayoutDeferred?qS(S):y.layout,k=_V({group:e,nextGroupSize:_,prevGroupSize:y.groupSize,prevLayout:C}),N=Ro({layout:k,panelConstraints:S});if(!y.defaultLayoutDeferred&&Po(y.layout,N)&&xV(y.derivedPanelConstraints,S)&&y.groupSize===_)return;Gi(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:S,groupSize:_,layout:N,separatorToPanels:y.separatorToPanels})}}else vV(e,x,w)}});s.observe(e.element),e.panels.forEach(m=>{st(!r.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),r.add(m.id),m.onResize&&s.observe(m.element)});const o=el({group:e}),a=I0(e),l=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(yV(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[l]??c??qS(a),d=Ro({layout:u,panelConstraints:a}),f=e.element.ownerDocument;sa.set(f,(sa.get(f)??0)+1);const p=new Map;return XR(e).forEach(m=>{m.separator&&p.set(m.separator,m.panels)}),Gi(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:a,groupSize:o,layout:d,separatorToPanels:p}),e.separators.forEach(m=>{st(!i.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),i.add(m.id),m.element.addEventListener("keydown",$S)}),sa.get(f)===1&&(f.addEventListener("contextmenu",LS,!0),f.addEventListener("dblclick",zS,!0),f.addEventListener("pointerdown",FS,!0),f.addEventListener("pointerleave",HS),f.addEventListener("pointermove",US),f.addEventListener("pointerout",WS),f.addEventListener("pointerup",VS,!0)),function(){t=!1,sa.set(f,Math.max(0,(sa.get(f)??0)-1)),aV(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",$S)}),sa.get(f)||(f.removeEventListener("contextmenu",LS,!0),f.removeEventListener("dblclick",zS,!0),f.removeEventListener("pointerdown",FS,!0),f.removeEventListener("pointerleave",HS),f.removeEventListener("pointermove",US),f.removeEventListener("pointerout",WS),f.removeEventListener("pointerup",VS,!0)),s.disconnect()}}function wV(){const[e,t]=g.useState({}),n=g.useCallback(()=>t({}),[]);return[e,n]}function My(e){const t=g.useId();return`${e??t}`}const Wo=typeof window<"u"?g.useLayoutEffect:g.useEffect;function kc(e){const t=g.useRef(e);return Wo(()=>{t.current=e},[e]),g.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function Ay(...e){return kc(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function jy(e){const t=g.useRef({...e});return Wo(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const l5=g.createContext(null);function SV(e,t){const n=g.useRef({getLayout:()=>({}),setLayout:sV});g.useImperativeHandle(t,()=>n.current,[]),Wo(()=>{Object.assign(n.current,o5({groupId:e}))})}function Ly({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:s,groupRef:o,id:a,onLayoutChange:l,onLayoutChanged:c,orientation:u="horizontal",resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){const m=g.useRef({onLayoutChange:{},onLayoutChanged:{}}),v=kc(D=>{Po(m.current.onLayoutChange,D)||(m.current.onLayoutChange=D,l==null||l(D))}),w=kc((D,R)=>{Po(m.current.onLayoutChanged,D)||(m.current.onLayoutChanged=D,c==null||c(D,{isUserInteraction:R}))}),x=My(a),_=g.useRef(null),[y,S]=wV(),C=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),k=Ay(_,s);SV(x,o);const N=kc((D,R)=>{const A=Io(),M=jS(D),L=As(D);if(L){let $=!1;switch(A.state){case"active":{$=A.hitRegions.some(F=>F.group===M);break}}return{flexGrow:L.layout[R]??1,pointerEvents:$?"none":void 0}}if(n!=null&&n[R])return{flexGrow:n==null?void 0:n[R]}}),T=jy({defaultLayout:n,disableCursor:r}),O=g.useMemo(()=>({get disableCursor(){return!!T.disableCursor},getPanelStyles:N,id:x,orientation:u,registerPanel:D=>{const R=C.current;return R.panels=P0(u,[...R.panels,D]),S(),()=>{R.panels=R.panels.filter(A=>A!==D),S()}},registerSeparator:D=>{const R=C.current;return R.separators=P0(u,[...R.separators,D]),S(),()=>{R.separators=R.separators.filter(A=>A!==D),S()}},updatePanelProps:(D,{disabled:R})=>{const A=C.current.panels.find($=>$.id===D);A&&(A.panelConstraints.disabled=R);const M=jS(x),L=As(x);M&&L&&Gi(M,{...L,derivedPanelConstraints:I0(M)})},updateSeparatorProps:(D,{disabled:R,disableDoubleClick:A})=>{const M=C.current.separators.find(L=>L.id===D);M&&(M.disabled=R,M.disableDoubleClick=A)}}),[N,x,S,u,T]),P=g.useRef(null);return Wo(()=>{const D=_.current;if(D===null)return;const R=C.current;let A;if(T.defaultLayout!==void 0&&Object.keys(T.defaultLayout).length===R.panels.length){A={};for(const E of R.panels){const H=T.defaultLayout[E.id];H!==void 0&&(A[E.id]=H)}}const M={disabled:!!i,element:D,id:x,mutableState:{defaultLayout:A,disableCursor:!!T.disableCursor,expandedPanelSizes:C.current.lastExpandedPanelSizes,layouts:C.current.layouts},orientation:u,panels:R.panels,resizeTargetMinimumSize:R.resizeTargetMinimumSize,separators:R.separators};P.current=M;const L=bV(M),{defaultLayoutDeferred:$,derivedPanelConstraints:F,layout:B}=As(M.id,!0);!$&&F.length>0&&(v(B),w(B,!1));const z=Py(x,E=>{const{defaultLayoutDeferred:H,derivedPanelConstraints:q,layout:j}=E.next;if(H||q.length===0)return;const ne=M.panels.map(({id:K})=>K).join(",");M.mutableState.layouts[ne]=j,q.forEach(K=>{if(K.collapsible){const{layout:ge}=E.prev??{};if(ge){const Pe=wn(K.collapsedSize,j[K.panelId]),he=wn(K.collapsedSize,ge[K.panelId]);Pe&&!he&&(M.mutableState.expandedPanelSizes[K.panelId]=ge[K.panelId])}}});const ie=Io().state!=="active";v(j),ie&&w(j,E.isUserInteraction)});return()=>{P.current=null,L(),z()}},[i,x,w,v,u,y,T]),g.useEffect(()=>{const D=P.current;D&&(D.mutableState.defaultLayout=n,D.mutableState.disableCursor=!!r)}),h.jsx(l5.Provider,{value:O,children:h.jsx("div",{...p,className:t,"data-group":!0,"data-testid":x,id:x,ref:k,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:u==="horizontal"?"pan-y":"pan-x"},children:e})})}Ly.displayName="Group";function Dy(){const e=g.useContext(l5);return st(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function kV(e,t){const{id:n}=Dy(),r=g.useRef({collapse:qm,expand:qm,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:qm});g.useImperativeHandle(t,()=>r.current,[]),Wo(()=>{Object.assign(r.current,s5({groupId:n,panelId:e}))})}function uf({children:e,className:t,collapsedSize:n="0%",collapsible:r=!1,defaultSize:i,disabled:s,elementRef:o,groupResizeBehavior:a="preserve-relative-size",id:l,maxSize:c="100%",minSize:u="0%",onResize:d,panelRef:f,style:p,...m}){const v=!!l,w=My(l),x=jy({disabled:s}),_=g.useRef(null),y=Ay(_,o),{getPanelStyles:S,id:C,orientation:k,registerPanel:N,updatePanelProps:T}=Dy(),O=d!==null,P=kc((M,L,$)=>{d==null||d(M,l,$)});Wo(()=>{const M=_.current;if(M!==null){const L={element:M,id:w,idIsStable:v,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:O?P:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:r,defaultSize:i,disabled:x.disabled,maxSize:c,minSize:u}};return N(L)}},[a,n,r,i,O,w,v,c,u,P,N,x]),g.useEffect(()=>{T(w,{disabled:s})},[s,w,T]),kV(w,f);const D=()=>{const M=S(C,w);if(M)return JSON.stringify(M)},R=g.useSyncExternalStore(M=>Py(C,M),D,D);let A;return R?A=JSON.parse(R):i!==void 0?A={flexGrow:void 0,flexShrink:void 0,flexBasis:i}:A={flexGrow:1},h.jsx("div",{...m,"data-disabled":s||void 0,"data-panel":!0,"data-testid":w,id:w,ref:y,style:{...CV,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...A},children:h.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...p,touchAction:k==="horizontal"?"pan-y":"pan-x"},children:e})})}uf.displayName="Panel";const CV={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function EV({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,s;const o=e[n],a=t.find(l=>l.panelId===n);if(a){const l=a.maxSize,c=a.collapsible?a.collapsedSize:a.minSize,u=[r,r+1];s=Ro({layout:lu({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=Ro({layout:lu({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:o}}function c5({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:s,style:o,...a}){const l=My(s),c=jy({disabled:n,disableDoubleClick:r}),[u,d]=g.useState({}),[f,p]=g.useState("inactive"),[m,v]=g.useState(!1),w=g.useRef(null),x=Ay(w,i),{disableCursor:_,id:y,orientation:S,registerSeparator:C,updateSeparatorProps:k}=Dy(),N=S==="horizontal"?"vertical":"horizontal";Wo(()=>{const P=w.current;if(P!==null){const D={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:P,id:l},R=C(D),A=rV(L=>{p(L.next.state!=="inactive"&&L.next.hitRegions.some($=>$.separator===D)?L.next.state:"inactive")}),M=Py(y,L=>{const{derivedPanelConstraints:$,layout:F,separatorToPanels:B}=L.next,z=B.get(D);if(z){const E=z[0],H=z.indexOf(E);d(EV({layout:F,panelConstraints:$,panelId:E.id,panelIndex:H}))}});return()=>{A(),M(),R()}}},[y,l,C,c]),g.useEffect(()=>{k(l,{disabled:n,disableDoubleClick:r})},[n,r,l,k]);let T;n&&!_&&(T="not-allowed");let O;if(n)O="disabled";else switch(f){case"active":{O="active";break}default:m?O="focus":O=f}return h.jsx("div",{...a,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":N,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":O,"data-testid":l,id:l,onBlur:()=>v(!1),onFocus:()=>v(!0),ref:x,role:"separator",style:{flexBasis:"auto",cursor:T,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}c5.displayName="Separator";function NV(e,t,n,r=!0){const i=g.useRef({sid:null,tsid:void 0});g.useEffect(()=>{const s=i.current;i.current={sid:t,tsid:n},!(!r||!n||s.sid===t&&(s.tsid===void 0||s.tsid===null)&&typeof n=="string")&&e.sessionObserve({sessionId:t,toolSessionId:n}).catch(()=>{})},[e,t,n,r])}function TV(e,t,n){const r=g.useRef(e),i=g.useRef(t),s=g.useRef(n);s.current=n,g.useEffect(()=>{const o=r.current,a=i.current;r.current=e,i.current=t;const l=o!==e,c=typeof a=="string"&&t==null;!l&&!c||s.current()},[e,t])}const IV=/^Scheduled (?:recurring job|one-shot task) ([0-9a-f]{8}) \(([^)]+)\)/;function PV(e){const t=new Map,n=new Map,r=new Map;for(const i of e)if(i.kind==="tool_call"&&i.tool==="CronCreate"){const s=i.input;if(!s||typeof s.cron!="string"||typeof s.prompt!="string")continue;const o=i.ts;t.set(i.toolUseId,{cron:s.cron,prompt:s.prompt,recurring:s.recurring!==!1,ts:typeof o=="string"?o:"",toolUseId:i.toolUseId})}else if(i.kind==="tool_call"&&i.tool==="CronDelete"){const s=i.input;if(!s||typeof s.id!="string")continue;n.set(i.toolUseId,s.id)}else if(i.kind==="tool_result"){const s=t.get(i.toolUseId);if(s){if(t.delete(i.toolUseId),i.error||typeof i.output!="string")continue;const a=i.output.match(IV);if(!a)continue;r.set(a[1],{id:a[1],cron:s.cron,prompt:s.prompt,recurring:s.recurring,humanSchedule:a[2],createdAt:s.ts,toolUseId:s.toolUseId});continue}const o=n.get(i.toolUseId);o!==void 0&&(n.delete(i.toolUseId),i.error||r.delete(o))}return Array.from(r.values()).sort((i,s)=>i.createdAt.localeCompare(s.createdAt))}const RV=["TaskCreate","TaskUpdate","TaskList","TaskGet"];function MV(e){return RV.includes(e)}function u5(e){return e==="in_progress"||e==="completed"?e:"pending"}function AV(e,t){if(!t||typeof t!="object")return e;const n=t,r=typeof n.subject=="string"&&n.subject?n.subject:typeof n.content=="string"&&n.content?n.content:null;if(!r)return e;const i=typeof n.activeForm=="string"?n.activeForm:void 0,s=typeof n.description=="string"?n.description:void 0;return[...e,{id:String(e.length+1),content:r,status:u5(n.status),activeForm:i,description:s}]}function jV(e,t){if(!t||typeof t!="object")return e;const n=t,r=typeof n.taskId=="string"&&n.taskId?n.taskId:typeof n.id=="string"&&n.id?n.id:null;if(!r)return e;const i=e.findIndex(a=>a.id===r);if(i<0)return e;const s=[...e],o={...s[i]};return"status"in n&&(o.status=u5(n.status)),typeof n.subject=="string"&&(o.content=n.subject),typeof n.content=="string"&&(o.content=n.content),typeof n.activeForm=="string"&&(o.activeForm=n.activeForm),typeof n.description=="string"&&(o.description=n.description),s[i]=o,s}function LV(e){let t=[],n=-1;for(let r=0;r<e.length;r++){const i=e[r];if(i.kind==="task-event")switch(n=r,i.name){case"TaskCreate":t=AV(t,i.input);break;case"TaskUpdate":t=jV(t,i.input);break}}return{tasks:t,lastEventIndex:n}}function d5(e){var n;if(e.error)return!1;if(e.pending)return!0;if(e.notifications.length>0)return!1;const t=(n=e.progress)==null?void 0:n.status;return t==="running"?!0:t==="started"?DV(e.input):!1}function DV(e){return!e||typeof e!="object"?!1:e.run_in_background===!0}function OV(e){return e.filter(t=>t.kind==="merged-agent"&&d5(t))}function h5(e){const{tasks:t,lastEventIndex:n}=LV(e);let r=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind==="todo-checklist"){r=c;break}const i=[],s=new Map,o=new Map,a=new Map,l=(c,u)=>{var f,p,m,v,w;if(((f=c.progress)==null?void 0:f.status)==="completed"||((p=c.progress)==null?void 0:p.status)==="failed")return;const d={agentId:u.agentId,status:u.status};u.description?d.description=u.description:(m=c.progress)!=null&&m.description&&(d.description=c.progress.description),u.lastToolName?d.lastToolName=u.lastToolName:(v=c.progress)!=null&&v.lastToolName&&(d.lastToolName=c.progress.lastToolName),u.stats?d.stats=u.stats:(w=c.progress)!=null&&w.stats&&(d.stats=c.progress.stats),c.progress=d,(u.status==="completed"||u.status==="failed")&&(c.pending=!1)};for(let c=0;c<e.length;c++){const u=e[c];switch(u.kind){case"tool-call":{const d={kind:"merged-tool",seq:u.seq,tool:u.tool,toolKind:u.toolKind,toolUseId:u.toolUseId,input:u.input,pending:!0};s.set(u.toolUseId,i.length),i.push(d);break}case"tool-result":{const d=s.get(u.toolUseId);if(d!==void 0){const p=i[d];p.output=u.output,p.error=u.error,p.pending=!1,s.delete(u.toolUseId);break}const f=o.get(u.toolUseId);if(f!==void 0){const p=i[f];p.output=u.output,p.error=u.error,p.pending=!1,u.toolResultExtra&&(p.toolResultExtra=u.toolResultExtra);break}break}case"agent-call":{const d={kind:"merged-agent",seq:u.seq,toolUseId:u.toolUseId,description:u.description,input:u.input,pending:!0,notifications:[]};o.set(u.toolUseId,i.length),i.push(d);const f=a.get(u.toolUseId);f&&(l(d,f),a.delete(u.toolUseId));break}case"agent-progress":{const d=o.get(u.toolUseId);if(d!==void 0){l(i[d],u);break}const f=a.get(u.toolUseId);if((f==null?void 0:f.status)==="completed"||(f==null?void 0:f.status)==="failed")break;a.set(u.toolUseId,u);break}case"agent-notification":{const d=u.parentToolUseId;if(d){const f=o.get(d);if(f!==void 0){i[f].notifications.push({text:u.text,taskId:u.taskId});break}}i.push({kind:"agent-notification",seq:u.seq,text:u.text,taskId:u.taskId,parentToolUseId:u.parentToolUseId});break}case"todo-checklist":{c===r&&u.todos.length>0&&i.push({kind:"todo-checklist",seq:u.seq,toolUseId:u.toolUseId,todos:u.todos});break}case"task-event":{c===n&&t.length>0&&i.push({kind:"plan-card",seq:u.seq,tasks:t});break}default:i.push(u)}}return i}const BV=new Set(["permission-inline","question-card"]);function zV(e){return e.kind==="user-text"?!0:e.kind!=="user-meta"?!1:e.metaKind==="slash-command"||op(e.metaKind)}function $V(e){return e.kind==="user-text"&&e.continuesTurn===!0}function FV(e,t={}){const n=[];let r=null;const i=(s,o)=>{r&&(n.push(HV(r,s,o)),r=null)};for(const s of e){if(s.kind==="turn-end"){i(s,!0);continue}if(zV(s)&&(r===null||!$V(s))){i(void 0,!0),r={query:s,body:[]};continue}r===null?r={body:[s]}:r.body.push(s)}return i(void 0,t.closeTrailing===!0),n}function HV(e,t,n){const{query:r,body:i}=e,s=UV(i,t,n),o=WV(i,s),a=qV(i,o),l=r??i[0]??t,c={kind:"turn",seq:l?l.seq:0,status:s,process:a,tail:o};return r&&(c.query=r),(t==null?void 0:t.durationMs)!==void 0&&(c.durationMs=t.durationMs),c}function UV(e,t,n){if(!n)return"running";if((t==null?void 0:t.reason)==="interrupted")return"interrupted";const r=R0(e,i=>i.kind==="error");return r>=0&&!e.slice(r+1).some(s=>s.kind==="assistant-text")?"error":"done"}function WV(e,t){if(t==="running"){const r=[];for(let i=e.length-1;i>=0&&BV.has(e[i].kind);i--)r.unshift(e[i]);return r}const n=t==="error"?R0(e,r=>r.kind==="error"):R0(e,r=>r.kind==="assistant-text");return n>=0?[e[n]]:[]}const VV=new Set(["assistant-thinking","user-meta"]);function qV(e,t){const n=new Set(t),r=[];let i=null;const s=()=>{i&&(r.push({kind:"tool-group",seq:i[0].seq,items:i}),i=null)};for(const o of e){if(n.has(o)){s();continue}if(o.kind==="merged-tool"){i?i.push(o):i=[o];continue}if(VV.has(o.kind)){r.push(o);continue}s(),r.push(o)}return s(),r}function R0(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}const KV={Read:["正在读取","已读取"],Bash:["正在运行","已运行"],Grep:["正在搜索","已搜索"],Glob:["正在搜索","已搜索"],Edit:["正在编辑","已编辑"],Write:["正在写入","已写入"],WebFetch:["正在抓取","已抓取"],WebSearch:["正在搜索","已搜索"],Skill:["正在读取","已读取"]};function GV(e){if(!e||typeof e!="object")return"";const t=e,n=t.command??t.file_path??t.path??t.pattern??t.query??t.url??t.description;if(typeof n=="string")return n;for(const r of Object.values(t))if(typeof r=="string"&&r)return r;return""}function f5(e){const t=KV[e.tool],n=t?e.pending?t[0]:t[1]:e.pending?`正在执行 ${e.tool}`:`已执行 ${e.tool}`,r=GV(e.input);return r?`${n} ${r}`:n}function YV({item:e,renderItemDetail:t}){const[n,r]=g.useState(!1),i=n?Yn:Bn,s=n?(t==null?void 0:t(e))??null:null;return h.jsxs("div",{className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>r(o=>!o),"aria-expanded":n,"data-testid":"tool-call-group-row",className:re("flex w-full items-center gap-1.5 text-left cursor-pointer min-w-0 py-0.5 text-[13px] hover:text-text-200",e.error?"text-destructive/80":"text-text-400"),children:[e.pending?h.jsx(Ln,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):h.jsx(i,{className:"w-3.5 h-3.5 shrink-0 opacity-60"}),h.jsx("span",{className:"truncate min-w-0",children:f5(e)})]}),n?h.jsx("div",{"data-testid":"tool-call-group-row-detail",className:"pl-5 py-1 min-w-0 space-y-1.5 text-[12px] text-text-300",children:s!==null?s:h.jsxs(h.Fragment,{children:[h.jsx("pre",{className:"min-w-0 max-w-full overflow-auto whitespace-pre-wrap font-mono",children:JSON.stringify(e.input,null,2)}),e.output!==void 0?h.jsx("pre",{className:"min-w-0 max-w-full overflow-auto whitespace-pre-wrap font-mono text-text-400",children:typeof e.output=="string"?e.output:JSON.stringify(e.output,null,2)}):null,e.error?h.jsx("pre",{className:"min-w-0 max-w-full overflow-auto whitespace-pre-wrap font-mono text-destructive",children:e.error}):null]})}):null]})}function XV({items:e,renderItemDetail:t}){const[n,r]=g.useState(!1);if(e.length===0)return null;const i=e.some(l=>l.pending),s=i?[...e].reverse().find(l=>l.pending):e[e.length-1],o=!i&&e.length>1?` 等 ${e.length} 项`:"",a=n?Yn:Bn;return h.jsxs("div",{"data-testid":"tool-call-group",className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>r(l=>!l),"aria-expanded":n,"data-testid":"tool-call-group-header",className:"flex w-full items-center gap-1.5 text-left cursor-pointer min-w-0 py-0.5 text-[13px] text-text-400 hover:text-text-200",children:[i&&!n?h.jsx(Ln,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):h.jsx(a,{className:"w-3.5 h-3.5 shrink-0"}),n?h.jsx("span",{className:"min-w-0 truncate opacity-70",children:i?"正在执行":`${e.length} 项`}):h.jsxs("span",{className:re("truncate min-w-0",i&&"text-text-300"),children:[f5(s),o]})]}),n?h.jsx("div",{className:"mt-0.5 flex flex-col pl-5",children:e.map(l=>h.jsx(YV,{item:l,renderItemDetail:t},l.toolUseId))}):null]})}function QV(e){const t=Math.round(e/1e3);if(t<60)return`${t}秒`;const n=Math.floor(t/60),r=t%60;return r>0?`${n}分${r}秒`:`${n}分钟`}function ZV(e,t){const n=t!==void 0?`耗时 ${QV(t)}`:"";switch(e){case"interrupted":return n?`已中断 · ${n}`:"已中断";case"error":return n?`出错 · ${n}`:"出错";default:return n||"已完成"}}function JV({status:e="done",durationMs:t,defaultExpanded:n=!1,children:r}){const[i,s]=g.useState(n),o=i?Yn:Bn;return h.jsxs("div",{"data-testid":"turn-process-block",className:"min-w-0 max-w-full border-t border-border pt-2",children:[h.jsxs("button",{type:"button",onClick:()=>s(a=>!a),"aria-expanded":i,"data-testid":"turn-process-block-header",className:re("flex w-full items-center gap-1 text-left cursor-pointer min-w-0 py-0.5 text-[13px]",e!=="done"?"text-destructive/80 hover:text-destructive":"text-text-400 hover:text-text-200"),children:[h.jsx("span",{className:"truncate min-w-0",children:ZV(e,t)}),h.jsx(o,{className:"w-3.5 h-3.5 shrink-0"})]}),i?h.jsx("div",{"data-testid":"turn-process-body",className:"mt-2 flex flex-col gap-2 border-l-2 border-border pl-3",children:r}):null]})}const eq=/<(system-reminder|related-dir|clawd-shift-fire)\b[^>]*>[\s\S]*?<\/\1>/gi,tq=/<builder-preview\b[^>]*\/>/gi,nq=/<(clawd-dispatch-task|clawd-dispatch-result)\b[^>]*>([\s\S]*?)<\/\1>/gi,rq=/<\/?(brief|detail|files)>/gi;function p5(e){return e?e.replace(nq,(t,n,r)=>fz(r.replace(rq,"")).trim()).replace(eq,"").replace(tq,"").trim():""}const iq=p5;function sq(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const oq=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,aq=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,lq={};function KS(e,t){return(lq.jsx?aq:oq).test(e)}const cq=/[ \t\n\f\r]/g;function uq(e){return typeof e=="object"?e.type==="text"?GS(e.value):!1:GS(e)}function GS(e){return e.replace(cq,"")===""}class Au{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Au.prototype.normal={};Au.prototype.property={};Au.prototype.space=void 0;function m5(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Au(n,r,t)}function M0(e){return e.toLowerCase()}class Xn{constructor(t,n){this.attribute=n,this.property=t}}Xn.prototype.attribute="";Xn.prototype.booleanish=!1;Xn.prototype.boolean=!1;Xn.prototype.commaOrSpaceSeparated=!1;Xn.prototype.commaSeparated=!1;Xn.prototype.defined=!1;Xn.prototype.mustUseProperty=!1;Xn.prototype.number=!1;Xn.prototype.overloadedBoolean=!1;Xn.prototype.property="";Xn.prototype.spaceSeparated=!1;Xn.prototype.space=void 0;let dq=0;const Le=Vo(),Bt=Vo(),A0=Vo(),Q=Vo(),dt=Vo(),za=Vo(),er=Vo();function Vo(){return 2**++dq}const j0=Object.freeze(Object.defineProperty({__proto__:null,boolean:Le,booleanish:Bt,commaOrSpaceSeparated:er,commaSeparated:za,number:Q,overloadedBoolean:A0,spaceSeparated:dt},Symbol.toStringTag,{value:"Module"})),Km=Object.keys(j0);class Oy extends Xn{constructor(t,n,r,i){let s=-1;if(super(t,n),YS(this,"space",i),typeof r=="number")for(;++s<Km.length;){const o=Km[s];YS(this,Km[s],(r&j0[o])===j0[o])}}}Oy.prototype.defined=!0;function YS(e,t,n){n&&(e[t]=n)}function Cl(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Oy(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[M0(r)]=r,n[M0(s.attribute)]=r}return new Au(t,n,e.space)}const g5=Cl({properties:{ariaActiveDescendant:null,ariaAtomic:Bt,ariaAutoComplete:null,ariaBusy:Bt,ariaChecked:Bt,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:dt,ariaCurrent:null,ariaDescribedBy:dt,ariaDetails:null,ariaDisabled:Bt,ariaDropEffect:dt,ariaErrorMessage:null,ariaExpanded:Bt,ariaFlowTo:dt,ariaGrabbed:Bt,ariaHasPopup:null,ariaHidden:Bt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:dt,ariaLevel:Q,ariaLive:null,ariaModal:Bt,ariaMultiLine:Bt,ariaMultiSelectable:Bt,ariaOrientation:null,ariaOwns:dt,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:Bt,ariaReadOnly:Bt,ariaRelevant:null,ariaRequired:Bt,ariaRoleDescription:dt,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:Bt,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function v5(e,t){return t in e?e[t]:t}function x5(e,t){return v5(e,t.toLowerCase())}const hq=Cl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:za,acceptCharset:dt,accessKey:dt,action:null,allow:null,allowFullScreen:Le,allowPaymentRequest:Le,allowUserMedia:Le,alt:null,as:null,async:Le,autoCapitalize:null,autoComplete:dt,autoFocus:Le,autoPlay:Le,blocking:dt,capture:null,charSet:null,checked:Le,cite:null,className:dt,cols:Q,colSpan:null,content:null,contentEditable:Bt,controls:Le,controlsList:dt,coords:Q|za,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Le,defer:Le,dir:null,dirName:null,disabled:Le,download:A0,draggable:Bt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Le,formTarget:null,headers:dt,height:Q,hidden:A0,high:Q,href:null,hrefLang:null,htmlFor:dt,httpEquiv:dt,id:null,imageSizes:null,imageSrcSet:null,inert:Le,inputMode:null,integrity:null,is:null,isMap:Le,itemId:null,itemProp:dt,itemRef:dt,itemScope:Le,itemType:dt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Le,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:Le,muted:Le,name:null,nonce:null,noModule:Le,noValidate:Le,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:Le,optimum:Q,pattern:null,ping:dt,placeholder:null,playsInline:Le,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Le,referrerPolicy:null,rel:dt,required:Le,reversed:Le,rows:Q,rowSpan:Q,sandbox:dt,scope:null,scoped:Le,seamless:Le,selected:Le,shadowRootClonable:Le,shadowRootDelegatesFocus:Le,shadowRootMode:null,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:Bt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:Le,useMap:null,value:Bt,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:dt,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Le,declare:Le,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:Le,noHref:Le,noShade:Le,noWrap:Le,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:Bt,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Le,disableRemotePlayback:Le,prefix:null,property:null,results:Q,security:null,unselectable:null},space:"html",transform:x5}),fq=Cl({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",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:er,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:dt,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:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:Le,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,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:za,g2:za,glyphName:za,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:er,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Q,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:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:dt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:er,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:er,rev:er,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:er,requiredFeatures:er,requiredFonts:er,requiredFormats:er,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:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:er,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:er,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:er,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:v5}),_5=Cl({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()}}),y5=Cl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:x5}),b5=Cl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),pq={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"},mq=/[A-Z]/g,XS=/-[a-z]/g,gq=/^data[-\w.:]+$/i;function vq(e,t){const n=M0(t);let r=t,i=Xn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&gq.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(XS,_q);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!XS.test(s)){let o=s.replace(mq,xq);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=Oy}return new i(r,t)}function xq(e){return"-"+e.toLowerCase()}function _q(e){return e.charAt(1).toUpperCase()}const yq=m5([g5,hq,_5,y5,b5],"html"),By=m5([g5,fq,_5,y5,b5],"svg");function bq(e){return e.join(" ").trim()}var zy={},QS=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,wq=/\n/g,Sq=/^\s*/,kq=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Cq=/^:\s*/,Eq=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,Nq=/^[;\s]*/,Tq=/^\s+|\s+$/g,Iq=`
507
- `,ZS="/",JS="*",lo="",Pq="comment",Rq="declaration";function Mq(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function i(m){var v=m.match(wq);v&&(n+=v.length);var w=m.lastIndexOf(Iq);r=~w?m.length-w:r+m.length}function s(){var m={line:n,column:r};return function(v){return v.position=new o(m),c(),v}}function o(m){this.start=m,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function a(m){var v=new Error(t.source+":"+n+":"+r+": "+m);if(v.reason=m,v.filename=t.source,v.line=n,v.column=r,v.source=e,!t.silent)throw v}function l(m){var v=m.exec(e);if(v){var w=v[0];return i(w),e=e.slice(w.length),v}}function c(){l(Sq)}function u(m){var v;for(m=m||[];v=d();)v!==!1&&m.push(v);return m}function d(){var m=s();if(!(ZS!=e.charAt(0)||JS!=e.charAt(1))){for(var v=2;lo!=e.charAt(v)&&(JS!=e.charAt(v)||ZS!=e.charAt(v+1));)++v;if(v+=2,lo===e.charAt(v-1))return a("End of comment missing");var w=e.slice(2,v-2);return r+=2,i(w),e=e.slice(v),r+=2,m({type:Pq,comment:w})}}function f(){var m=s(),v=l(kq);if(v){if(d(),!l(Cq))return a("property missing ':'");var w=l(Eq),x=m({type:Rq,property:ek(v[0].replace(QS,lo)),value:w?ek(w[0].replace(QS,lo)):lo});return l(Nq),x}}function p(){var m=[];u(m);for(var v;v=f();)v!==!1&&(m.push(v),u(m));return m}return c(),p()}function ek(e){return e?e.replace(Tq,lo):lo}var Aq=Mq,jq=gh&&gh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(zy,"__esModule",{value:!0});zy.default=Dq;const Lq=jq(Aq);function Dq(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,Lq.default)(e),i=typeof t=="function";return r.forEach(s=>{if(s.type!=="declaration")return;const{property:o,value:a}=s;i?t(o,a,s):a&&(n=n||{},n[o]=a)}),n}var Tp={};Object.defineProperty(Tp,"__esModule",{value:!0});Tp.camelCase=void 0;var Oq=/^--[a-zA-Z0-9_-]+$/,Bq=/-([a-z])/g,zq=/^[^-]+$/,$q=/^-(webkit|moz|ms|o|khtml)-/,Fq=/^-(ms)-/,Hq=function(e){return!e||zq.test(e)||Oq.test(e)},Uq=function(e,t){return t.toUpperCase()},tk=function(e,t){return"".concat(t,"-")},Wq=function(e,t){return t===void 0&&(t={}),Hq(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(Fq,tk):e=e.replace($q,tk),e.replace(Bq,Uq))};Tp.camelCase=Wq;var Vq=gh&&gh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},qq=Vq(zy),Kq=Tp;function L0(e,t){var n={};return!e||typeof e!="string"||(0,qq.default)(e,function(r,i){r&&i&&(n[(0,Kq.camelCase)(r,t)]=i)}),n}L0.default=L0;var Gq=L0;const Yq=mu(Gq),w5=S5("end"),$y=S5("start");function S5(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Xq(e){const t=$y(e),n=w5(e);if(t&&n)return{start:t,end:n}}function Cc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?nk(e.position):"start"in e||"end"in e?nk(e):"line"in e||"column"in e?D0(e):""}function D0(e){return rk(e&&e.line)+":"+rk(e&&e.column)}function nk(e){return D0(e&&e.start)+"-"+D0(e&&e.end)}function rk(e){return e&&typeof e=="number"?e:1}class Nn extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=Cc(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Nn.prototype.file="";Nn.prototype.name="";Nn.prototype.reason="";Nn.prototype.message="";Nn.prototype.stack="";Nn.prototype.column=void 0;Nn.prototype.line=void 0;Nn.prototype.ancestors=void 0;Nn.prototype.cause=void 0;Nn.prototype.fatal=void 0;Nn.prototype.place=void 0;Nn.prototype.ruleId=void 0;Nn.prototype.source=void 0;const Fy={}.hasOwnProperty,Qq=new Map,Zq=/[A-Z]/g,Jq=new Set(["table","tbody","thead","tfoot","tr"]),eK=new Set(["td","th"]),k5="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function tK(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=cK(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=lK(n,t.jsx,t.jsxs)}const 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"?By:yq,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=C5(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function C5(e,t,n){if(t.type==="element")return nK(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return rK(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return sK(e,t,n);if(t.type==="mdxjsEsm")return iK(e,t);if(t.type==="root")return oK(e,t,n);if(t.type==="text")return aK(e,t)}function nK(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=By,e.schema=i),e.ancestors.push(t);const s=N5(e,t.tagName,!1),o=uK(e,t);let a=Uy(e,t);return Jq.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!uq(l):!0})),E5(e,o,s,t),Hy(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function rK(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}cu(e,t.position)}function iK(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);cu(e,t.position)}function sK(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=By,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:N5(e,t.name,!0),o=dK(e,t),a=Uy(e,t);return E5(e,o,s,t),Hy(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function oK(e,t,n){const r={};return Hy(r,Uy(e,t)),e.create(t,e.Fragment,r,n)}function aK(e,t){return t.value}function E5(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Hy(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function lK(e,t,n){return r;function r(i,s,o,a){const c=Array.isArray(o.children)?n:t;return a?c(s,o,a):c(s,o)}}function cK(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=$y(r);return t(i,s,o,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function uK(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Fy.call(t.properties,i)){const s=hK(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&eK.has(t.tagName)?r=a:n[o]=a}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function dK(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else cu(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,s=e.evaluater.evaluateExpression(a.expression)}else cu(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function Uy(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:Qq;for(;++r<t.children.length;){const s=t.children[r];let o;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const c=i.get(l)||0;o=l+"-"+c,i.set(l,c+1)}}const a=C5(e,s,o);a!==void 0&&n.push(a)}return n}function hK(e,t,n){const r=vq(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?sq(n):bq(n)),r.property==="style"){let i=typeof n=="object"?n:fK(e,String(n));return e.stylePropertyNameCase==="css"&&(i=pK(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?pq[r.property]||r.property:r.attribute,n]}}function fK(e,t){try{return Yq(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new Nn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=k5+"#cannot-parse-style-attribute",i}}function N5(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const a=KS(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=o}else r=KS(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Fy.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);cu(e)}function cu(e,t){const n=new Nn("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=k5+"#cannot-handle-mdx-estrees-without-createevaluater",n}function pK(e){const t={};let n;for(n in e)Fy.call(e,n)&&(t[mK(n)]=e[n]);return t}function mK(e){let t=e.replace(Zq,gK);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function gK(e){return"-"+e.toLowerCase()}const Gm={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"]},vK={};function Wy(e,t){const n=vK,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return T5(e,r,i)}function T5(e,t,n){if(xK(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 ik(e.children,t,n)}return Array.isArray(e)?ik(e,t,n):""}function ik(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=T5(e[i],t,n);return r.join("")}function xK(e){return!!(e&&typeof e=="object")}const sk=document.createElement("i");function Vy(e){const t="&"+e+";";sk.innerHTML=t;const n=sk.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function or(e,t,n,r){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t: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);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function xr(e,t){return e.length>0?(or(e,e.length,0,t),e):t}const ok={}.hasOwnProperty;function I5(e){const t={};let n=-1;for(;++n<e.length;)_K(t,e[n]);return t}function _K(e,t){let n;for(n in t){const i=(ok.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){ok.call(i,o)||(i[o]=[]);const a=s[o];yK(i[o],Array.isArray(a)?a:a?[a]:[])}}}function yK(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);or(e,0,0,r)}function P5(e,t){const 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 Fr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Rn=Ks(/[A-Za-z]/),kn=Ks(/[\dA-Za-z]/),bK=Ks(/[#-'*+\--9=?A-Z^-~]/);function df(e){return e!==null&&(e<32||e===127)}const O0=Ks(/\d/),wK=Ks(/[\dA-Fa-f]/),SK=Ks(/[!-/:-@[-`{-~]/);function we(e){return e!==null&&e<-2}function ct(e){return e!==null&&(e<0||e===32)}function Ue(e){return e===-2||e===-1||e===32}const Ip=Ks(new RegExp("\\p{P}|\\p{S}","u")),Mo=Ks(/\s/);function Ks(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function El(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&kn(e.charCodeAt(n+1))&&kn(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function qe(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return Ue(l)?(e.enter(n),a(l)):t(l)}function a(l){return Ue(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const kK={tokenize:CK};function CK(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),qe(e,t,"linePrefix")}function i(a){return e.enter("paragraph"),s(a)}function s(a){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return we(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const EK={tokenize:NK},ak={tokenize:TK};function NK(e){const t=this,n=[];let r=0,i,s,o;return a;function a(y){if(r<n.length){const S=n[r];return t.containerState=S[1],e.attempt(S[0].continuation,l,c)(y)}return c(y)}function l(y){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&_();const S=t.events.length;let C=S,k;for(;C--;)if(t.events[C][0]==="exit"&&t.events[C][1].type==="chunkFlow"){k=t.events[C][1].end;break}x(r);let N=S;for(;N<t.events.length;)t.events[N][1].end={...k},N++;return or(t.events,C+1,0,t.events.slice(S)),t.events.length=N,c(y)}return a(y)}function c(y){if(r===n.length){if(!i)return f(y);if(i.currentConstruct&&i.currentConstruct.concrete)return m(y);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(ak,u,d)(y)}function u(y){return i&&_(),x(r),f(y)}function d(y){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(y)}function f(y){return t.containerState={},e.attempt(ak,p,m)(y)}function p(y){return r++,n.push([t.currentConstruct,t.containerState]),f(y)}function m(y){if(y===null){i&&_(),x(0),e.consume(y);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),v(y)}function v(y){if(y===null){w(e.exit("chunkFlow"),!0),x(0),e.consume(y);return}return we(y)?(e.consume(y),w(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(y),v)}function w(y,S){const C=t.sliceStream(y);if(S&&C.push(null),y.previous=s,s&&(s.next=y),s=y,i.defineSkip(y.start),i.write(C),t.parser.lazy[y.start.line]){let k=i.events.length;for(;k--;)if(i.events[k][1].start.offset<o&&(!i.events[k][1].end||i.events[k][1].end.offset>o))return;const N=t.events.length;let T=N,O,P;for(;T--;)if(t.events[T][0]==="exit"&&t.events[T][1].type==="chunkFlow"){if(O){P=t.events[T][1].end;break}O=!0}for(x(r),k=N;k<t.events.length;)t.events[k][1].end={...P},k++;or(t.events,T+1,0,t.events.slice(N)),t.events.length=k}}function x(y){let S=n.length;for(;S-- >y;){const C=n[S];t.containerState=C[1],C[0].exit.call(t,e)}n.length=y}function _(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function TK(e,t,n){return qe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function tl(e){if(e===null||ct(e)||Mo(e))return 1;if(Ip(e))return 2}function Pp(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const B0={name:"attention",resolveAll:IK,tokenize:PK};function IK(e,t){let n=-1,r,i,s,o,a,l,c,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;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const d={...e[r][1].end},f={...e[n][1].start};lk(d,-l),lk(f,l),o={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:f},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[n][1].start={...a.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=xr(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=xr(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),c=xr(c,Pp(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=xr(c,[["exit",s,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,c=xr(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):u=0,or(e,r-1,n-r+3,c),n=r+c.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function PK(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=tl(r);let s;return o;function o(l){return s=l,e.enter("attentionSequence"),a(l)}function a(l){if(l===s)return e.consume(l),a;const c=e.exit("attentionSequence"),u=tl(l),d=!u||u===2&&i||n.includes(l),f=!i||i===2&&u||n.includes(r);return c._open=!!(s===42?d:d&&(i||!f)),c._close=!!(s===42?f:f&&(u||!d)),t(l)}}function lk(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const RK={name:"autolink",tokenize:MK};function MK(e,t,n){let r=0;return i;function i(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(p){return Rn(p)?(e.consume(p),o):p===64?n(p):c(p)}function o(p){return p===43||p===45||p===46||kn(p)?(r=1,a(p)):c(p)}function a(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||kn(p))&&r++<32?(e.consume(p),a):(r=0,c(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||df(p)?n(p):(e.consume(p),l)}function c(p){return p===64?(e.consume(p),u):bK(p)?(e.consume(p),c):n(p)}function u(p){return kn(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,u):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):f(p)}function f(p){if((p===45||kn(p))&&r++<63){const m=p===45?f:d;return e.consume(p),m}return n(p)}}const ju={partial:!0,tokenize:AK};function AK(e,t,n){return r;function r(s){return Ue(s)?qe(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||we(s)?t(s):n(s)}}const R5={continuation:{tokenize:LK},exit:DK,name:"blockQuote",tokenize:jK};function jK(e,t,n){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return Ue(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function LK(e,t,n){const r=this;return i;function i(o){return Ue(o)?qe(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(R5,t,n)(o)}}function DK(e){e.exit("blockQuote")}const M5={name:"characterEscape",tokenize:OK};function OK(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return SK(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const A5={name:"characterReference",tokenize:BK};function BK(e,t,n){const r=this;let i=0,s,o;return a;function a(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),l}function l(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),s=31,o=kn,u(d))}function c(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=wK,u):(e.enter("characterReferenceValue"),s=7,o=O0,u(d))}function u(d){if(d===59&&i){const f=e.exit("characterReferenceValue");return o===kn&&!Vy(r.sliceSerialize(f))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(d)&&i++<s?(e.consume(d),u):n(d)}}const ck={partial:!0,tokenize:$K},uk={concrete:!0,name:"codeFenced",tokenize:zK};function zK(e,t,n){const r=this,i={partial:!0,tokenize:C};let s=0,o=0,a;return l;function l(k){return c(k)}function c(k){const N=r.events[r.events.length-1];return s=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[1],!0).length:0,a=k,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),u(k)}function u(k){return k===a?(o++,e.consume(k),u):o<3?n(k):(e.exit("codeFencedFenceSequence"),Ue(k)?qe(e,d,"whitespace")(k):d(k))}function d(k){return k===null||we(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(ck,v,S)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(k))}function f(k){return k===null||we(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(k)):Ue(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),qe(e,p,"whitespace")(k)):k===96&&k===a?n(k):(e.consume(k),f)}function p(k){return k===null||we(k)?d(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(k))}function m(k){return k===null||we(k)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(k)):k===96&&k===a?n(k):(e.consume(k),m)}function v(k){return e.attempt(i,S,w)(k)}function w(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),x}function x(k){return s>0&&Ue(k)?qe(e,_,"linePrefix",s+1)(k):_(k)}function _(k){return k===null||we(k)?e.check(ck,v,S)(k):(e.enter("codeFlowValue"),y(k))}function y(k){return k===null||we(k)?(e.exit("codeFlowValue"),_(k)):(e.consume(k),y)}function S(k){return e.exit("codeFenced"),t(k)}function C(k,N,T){let O=0;return P;function P(L){return k.enter("lineEnding"),k.consume(L),k.exit("lineEnding"),D}function D(L){return k.enter("codeFencedFence"),Ue(L)?qe(k,R,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):R(L)}function R(L){return L===a?(k.enter("codeFencedFenceSequence"),A(L)):T(L)}function A(L){return L===a?(O++,k.consume(L),A):O>=o?(k.exit("codeFencedFenceSequence"),Ue(L)?qe(k,M,"whitespace")(L):M(L)):T(L)}function M(L){return L===null||we(L)?(k.exit("codeFencedFence"),N(L)):T(L)}}}function $K(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Ym={name:"codeIndented",tokenize:HK},FK={partial:!0,tokenize:UK};function HK(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),qe(e,s,"linePrefix",5)(c)}function s(c){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?o(c):n(c)}function o(c){return c===null?l(c):we(c)?e.attempt(FK,o,l)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||we(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),a)}function l(c){return e.exit("codeIndented"),t(c)}}function UK(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):we(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):qe(e,s,"linePrefix",5)(o)}function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):we(o)?i(o):n(o)}}const WK={name:"codeText",previous:qK,resolve:VK,tokenize:KK};function VK(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 qK(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function KK(e,t,n){let r=0,i,s;return o;function o(d){return e.enter("codeText"),e.enter("codeTextSequence"),a(d)}function a(d){return d===96?(e.consume(d),r++,a):(e.exit("codeTextSequence"),l(d))}function l(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),l):d===96?(s=e.enter("codeTextSequence"),i=0,u(d)):we(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):(e.enter("codeTextData"),c(d))}function c(d){return d===null||d===32||d===96||we(d)?(e.exit("codeTextData"),l(d)):(e.consume(d),c)}function u(d){return d===96?(e.consume(d),i++,u):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(s.type="codeTextData",c(d))}}class GK{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Ul(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Ul(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Ul(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Ul(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Ul(this.left,n.reverse())}}}function Ul(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 j5(e){const t={};let n=-1,r,i,s,o,a,l,c;const u=new GK(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"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,YK(u,n)),n=t[n],c=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=u.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(u.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...u.get(i)[1].start},a=u.slice(i,n),a.unshift(r),u.splice(i,n-i+1,a))}}return or(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function YK(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],c={};let u,d,f=-1,p=n,m=0,v=0;const w=[v];for(;p;){for(;e.get(++i)[1]!==p;);s.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<a.length;)a[f][0]==="exit"&&a[f-1][0]==="enter"&&a[f][1].type===a[f-1][1].type&&a[f][1].start.line!==a[f][1].end.line&&(v=f+1,w.push(v),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):w.pop(),f=w.length;f--;){const x=a.slice(w[f],w[f+1]),_=s.pop();l.push([_,_+x.length-1]),e.splice(_,2,x)}for(l.reverse(),f=-1;++f<l.length;)c[m+l[f][0]]=m+l[f][1],m+=l[f][1]-l[f][0]-1;return c}const XK={resolve:ZK,tokenize:JK},QK={partial:!0,tokenize:eG};function ZK(e){return j5(e),e}function JK(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):we(a)?e.check(QK,o,s)(a):(e.consume(a),i)}function s(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function o(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function eG(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),qe(e,s,"linePrefix")}function s(o){if(o===null||we(o))return n(o);const 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(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function L5(e,t,n,r,i,s,o,a,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return d;function d(x){return x===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(x),e.exit(s),f):x===null||x===32||x===41||df(x)?n(x):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),v(x))}function f(x){return x===62?(e.enter(s),e.consume(x),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(x))}function p(x){return x===62?(e.exit("chunkString"),e.exit(a),f(x)):x===null||x===60||we(x)?n(x):(e.consume(x),x===92?m:p)}function m(x){return x===60||x===62||x===92?(e.consume(x),p):p(x)}function v(x){return!u&&(x===null||x===41||ct(x))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(x)):u<c&&x===40?(e.consume(x),u++,v):x===41?(e.consume(x),u--,v):x===null||x===32||x===40||df(x)?n(x):(e.consume(x),x===92?w:v)}function w(x){return x===40||x===41||x===92?(e.consume(x),v):v(x)}}function D5(e,t,n,r,i,s){const o=this;let a=0,l;return c;function c(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(s),u}function u(p){return a>999||p===null||p===91||p===93&&!l||p===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(p):p===93?(e.exit(s),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):we(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||we(p)||a++>999?(e.exit("chunkString"),u(p)):(e.consume(p),l||(l=!Ue(p)),p===92?f:d)}function f(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function O5(e,t,n,r,i,s){let o;return a;function a(f){return f===34||f===39||f===40?(e.enter(r),e.enter(i),e.consume(f),e.exit(i),o=f===40?41:f,l):n(f)}function l(f){return f===o?(e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):(e.enter(s),c(f))}function c(f){return f===o?(e.exit(s),l(o)):f===null?n(f):we(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),qe(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(f))}function u(f){return f===o||f===null||we(f)?(e.exit("chunkString"),c(f)):(e.consume(f),f===92?d:u)}function d(f){return f===o||f===92?(e.consume(f),u):u(f)}}function Ec(e,t){let n;return r;function r(i){return we(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Ue(i)?qe(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const tG={name:"definition",tokenize:rG},nG={partial:!0,tokenize:iG};function rG(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return D5.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=Fr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return ct(p)?Ec(e,c)(p):c(p)}function c(p){return L5(e,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function u(p){return e.attempt(nG,d,d)(p)}function d(p){return Ue(p)?qe(e,f,"whitespace")(p):f(p)}function f(p){return p===null||we(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function iG(e,t,n){return r;function r(a){return ct(a)?Ec(e,i)(a):n(a)}function i(a){return O5(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return Ue(a)?qe(e,o,"whitespace")(a):o(a)}function o(a){return a===null||we(a)?t(a):n(a)}}const sG={name:"hardBreakEscape",tokenize:oG};function oG(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return we(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const aG={name:"headingAtx",resolve:lG,tokenize:cG};function lG(e,t){let n=e.length-2,r=3,i,s;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},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},or(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function cG(e,t,n){let r=0;return i;function i(u){return e.enter("atxHeading"),s(u)}function s(u){return e.enter("atxHeadingSequence"),o(u)}function o(u){return u===35&&r++<6?(e.consume(u),o):u===null||ct(u)?(e.exit("atxHeadingSequence"),a(u)):n(u)}function a(u){return u===35?(e.enter("atxHeadingSequence"),l(u)):u===null||we(u)?(e.exit("atxHeading"),t(u)):Ue(u)?qe(e,a,"whitespace")(u):(e.enter("atxHeadingText"),c(u))}function l(u){return u===35?(e.consume(u),l):(e.exit("atxHeadingSequence"),a(u))}function c(u){return u===null||u===35||ct(u)?(e.exit("atxHeadingText"),a(u)):(e.consume(u),c)}}const uG=["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"],dk=["pre","script","style","textarea"],dG={concrete:!0,name:"htmlFlow",resolveTo:pG,tokenize:mG},hG={partial:!0,tokenize:vG},fG={partial:!0,tokenize:gG};function pG(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 mG(e,t,n){const r=this;let i,s,o,a,l;return c;function c(j){return u(j)}function u(j){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(j),d}function d(j){return j===33?(e.consume(j),f):j===47?(e.consume(j),s=!0,v):j===63?(e.consume(j),i=3,r.interrupt?t:E):Rn(j)?(e.consume(j),o=String.fromCharCode(j),w):n(j)}function f(j){return j===45?(e.consume(j),i=2,p):j===91?(e.consume(j),i=5,a=0,m):Rn(j)?(e.consume(j),i=4,r.interrupt?t:E):n(j)}function p(j){return j===45?(e.consume(j),r.interrupt?t:E):n(j)}function m(j){const ne="CDATA[";return j===ne.charCodeAt(a++)?(e.consume(j),a===ne.length?r.interrupt?t:R:m):n(j)}function v(j){return Rn(j)?(e.consume(j),o=String.fromCharCode(j),w):n(j)}function w(j){if(j===null||j===47||j===62||ct(j)){const ne=j===47,ie=o.toLowerCase();return!ne&&!s&&dk.includes(ie)?(i=1,r.interrupt?t(j):R(j)):uG.includes(o.toLowerCase())?(i=6,ne?(e.consume(j),x):r.interrupt?t(j):R(j)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(j):s?_(j):y(j))}return j===45||kn(j)?(e.consume(j),o+=String.fromCharCode(j),w):n(j)}function x(j){return j===62?(e.consume(j),r.interrupt?t:R):n(j)}function _(j){return Ue(j)?(e.consume(j),_):P(j)}function y(j){return j===47?(e.consume(j),P):j===58||j===95||Rn(j)?(e.consume(j),S):Ue(j)?(e.consume(j),y):P(j)}function S(j){return j===45||j===46||j===58||j===95||kn(j)?(e.consume(j),S):C(j)}function C(j){return j===61?(e.consume(j),k):Ue(j)?(e.consume(j),C):y(j)}function k(j){return j===null||j===60||j===61||j===62||j===96?n(j):j===34||j===39?(e.consume(j),l=j,N):Ue(j)?(e.consume(j),k):T(j)}function N(j){return j===l?(e.consume(j),l=null,O):j===null||we(j)?n(j):(e.consume(j),N)}function T(j){return j===null||j===34||j===39||j===47||j===60||j===61||j===62||j===96||ct(j)?C(j):(e.consume(j),T)}function O(j){return j===47||j===62||Ue(j)?y(j):n(j)}function P(j){return j===62?(e.consume(j),D):n(j)}function D(j){return j===null||we(j)?R(j):Ue(j)?(e.consume(j),D):n(j)}function R(j){return j===45&&i===2?(e.consume(j),$):j===60&&i===1?(e.consume(j),F):j===62&&i===4?(e.consume(j),H):j===63&&i===3?(e.consume(j),E):j===93&&i===5?(e.consume(j),z):we(j)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(hG,q,A)(j)):j===null||we(j)?(e.exit("htmlFlowData"),A(j)):(e.consume(j),R)}function A(j){return e.check(fG,M,q)(j)}function M(j){return e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),L}function L(j){return j===null||we(j)?A(j):(e.enter("htmlFlowData"),R(j))}function $(j){return j===45?(e.consume(j),E):R(j)}function F(j){return j===47?(e.consume(j),o="",B):R(j)}function B(j){if(j===62){const ne=o.toLowerCase();return dk.includes(ne)?(e.consume(j),H):R(j)}return Rn(j)&&o.length<8?(e.consume(j),o+=String.fromCharCode(j),B):R(j)}function z(j){return j===93?(e.consume(j),E):R(j)}function E(j){return j===62?(e.consume(j),H):j===45&&i===2?(e.consume(j),E):R(j)}function H(j){return j===null||we(j)?(e.exit("htmlFlowData"),q(j)):(e.consume(j),H)}function q(j){return e.exit("htmlFlow"),t(j)}}function gG(e,t,n){const r=this;return i;function i(o){return we(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function vG(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(ju,t,n)}}const xG={name:"htmlText",tokenize:_G};function _G(e,t,n){const r=this;let i,s,o;return a;function a(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),l}function l(E){return E===33?(e.consume(E),c):E===47?(e.consume(E),C):E===63?(e.consume(E),y):Rn(E)?(e.consume(E),T):n(E)}function c(E){return E===45?(e.consume(E),u):E===91?(e.consume(E),s=0,m):Rn(E)?(e.consume(E),_):n(E)}function u(E){return E===45?(e.consume(E),p):n(E)}function d(E){return E===null?n(E):E===45?(e.consume(E),f):we(E)?(o=d,F(E)):(e.consume(E),d)}function f(E){return E===45?(e.consume(E),p):d(E)}function p(E){return E===62?$(E):E===45?f(E):d(E)}function m(E){const H="CDATA[";return E===H.charCodeAt(s++)?(e.consume(E),s===H.length?v:m):n(E)}function v(E){return E===null?n(E):E===93?(e.consume(E),w):we(E)?(o=v,F(E)):(e.consume(E),v)}function w(E){return E===93?(e.consume(E),x):v(E)}function x(E){return E===62?$(E):E===93?(e.consume(E),x):v(E)}function _(E){return E===null||E===62?$(E):we(E)?(o=_,F(E)):(e.consume(E),_)}function y(E){return E===null?n(E):E===63?(e.consume(E),S):we(E)?(o=y,F(E)):(e.consume(E),y)}function S(E){return E===62?$(E):y(E)}function C(E){return Rn(E)?(e.consume(E),k):n(E)}function k(E){return E===45||kn(E)?(e.consume(E),k):N(E)}function N(E){return we(E)?(o=N,F(E)):Ue(E)?(e.consume(E),N):$(E)}function T(E){return E===45||kn(E)?(e.consume(E),T):E===47||E===62||ct(E)?O(E):n(E)}function O(E){return E===47?(e.consume(E),$):E===58||E===95||Rn(E)?(e.consume(E),P):we(E)?(o=O,F(E)):Ue(E)?(e.consume(E),O):$(E)}function P(E){return E===45||E===46||E===58||E===95||kn(E)?(e.consume(E),P):D(E)}function D(E){return E===61?(e.consume(E),R):we(E)?(o=D,F(E)):Ue(E)?(e.consume(E),D):O(E)}function R(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),i=E,A):we(E)?(o=R,F(E)):Ue(E)?(e.consume(E),R):(e.consume(E),M)}function A(E){return E===i?(e.consume(E),i=void 0,L):E===null?n(E):we(E)?(o=A,F(E)):(e.consume(E),A)}function M(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||ct(E)?O(E):(e.consume(E),M)}function L(E){return E===47||E===62||ct(E)?O(E):n(E)}function $(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function F(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),B}function B(E){return Ue(E)?qe(e,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):z(E)}function z(E){return e.enter("htmlTextData"),o(E)}}const qy={name:"labelEnd",resolveAll:SG,resolveTo:kG,tokenize:CG},yG={tokenize:EG},bG={tokenize:NG},wG={tokenize:TG};function SG(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&or(e,0,e.length,n),e}function kG(e,t){let n=e.length,r=0,i,s,o,a;for(;n--;)if(i=e[n][1],s){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&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},u={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",l,t],["enter",c,t]],a=xr(a,e.slice(s+1,s+r+3)),a=xr(a,[["enter",u,t]]),a=xr(a,Pp(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=xr(a,[["exit",u,t],e[o-2],e[o-1],["exit",c,t]]),a=xr(a,e.slice(o+1)),a=xr(a,[["exit",l,t]]),or(e,s,e.length,a),e}function CG(e,t,n){const r=this;let i=r.events.length,s,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return a;function a(f){return s?s._inactive?d(f):(o=r.parser.defined.includes(Fr(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelEnd"),l):n(f)}function l(f){return f===40?e.attempt(yG,u,o?u:d)(f):f===91?e.attempt(bG,u,o?c:d)(f):o?u(f):d(f)}function c(f){return e.attempt(wG,u,d)(f)}function u(f){return t(f)}function d(f){return s._balanced=!0,n(f)}}function EG(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),i}function i(d){return ct(d)?Ec(e,s)(d):s(d)}function s(d){return d===41?u(d):L5(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function o(d){return ct(d)?Ec(e,l)(d):u(d)}function a(d){return n(d)}function l(d){return d===34||d===39||d===40?O5(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):u(d)}function c(d){return ct(d)?Ec(e,u)(d):u(d)}function u(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function NG(e,t,n){const r=this;return i;function i(a){return D5.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Fr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function TG(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const IG={name:"labelStartImage",resolveAll:qy.resolveAll,tokenize:PG};function PG(e,t,n){const r=this;return i;function i(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),s}function s(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const RG={name:"labelStartLink",resolveAll:qy.resolveAll,tokenize:MG};function MG(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const Xm={name:"lineEnding",tokenize:AG};function AG(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),qe(e,t,"linePrefix")}}const ah={name:"thematicBreak",tokenize:jG};function jG(e,t,n){let r=0,i;return s;function s(c){return e.enter("thematicBreak"),o(c)}function o(c){return i=c,a(c)}function a(c){return c===i?(e.enter("thematicBreakSequence"),l(c)):r>=3&&(c===null||we(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),Ue(c)?qe(e,a,"whitespace")(c):a(c))}}const Un={continuation:{tokenize:BG},exit:$G,name:"list",tokenize:OG},LG={partial:!0,tokenize:FG},DG={partial:!0,tokenize:zG};function OG(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a(p){const m=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:O0(p)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(ah,n,c)(p):c(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return n(p)}function l(p){return O0(p)&&++o<10?(e.consume(p),l):(!r.interrupt||o<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):n(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(ju,r.interrupt?n:u,e.attempt(LG,f,d))}function u(p){return r.containerState.initialBlankLine=!0,s++,f(p)}function d(p){return Ue(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),f):n(p)}function f(p){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function BG(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(ju,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,qe(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!Ue(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(DG,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,qe(e,e.attempt(Un,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function zG(e,t,n){const r=this;return qe(e,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function $G(e){e.exit(this.containerState.type)}function FG(e,t,n){const r=this;return qe(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!Ue(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const hk={name:"setextUnderline",resolveTo:HG,tokenize:UG};function HG(e,t){let n=e.length,r,i,s;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),!s&&e[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",o,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function UG(e,t,n){const r=this;let i;return s;function s(c){let u=r.events.length,d;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){d=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),i=c,o(c)):n(c)}function o(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===i?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),Ue(c)?qe(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||we(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const WG={tokenize:VG};function VG(e){const t=this,n=e.attempt(ju,r,e.attempt(this.parser.constructs.flowInitial,i,qe(e,e.attempt(this.parser.constructs.flow,i,e.attempt(XK,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const qG={resolveAll:z5()},KG=B5("string"),GG=B5("text");function B5(e){return{resolveAll:z5(e==="text"?YG:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,o,a);return o;function o(u){return c(u)?s(u):a(u)}function a(u){if(u===null){n.consume(u);return}return n.enter("data"),n.consume(u),l}function l(u){return c(u)?(n.exit("data"),s(u)):(n.consume(u),l)}function c(u){if(u===null)return!0;const d=i[u];let f=-1;if(d)for(;++f<d.length;){const p=d[f];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function z5(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function YG(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,o=-1,a=0,l;for(;s--;){const c=i[s];if(typeof c=="string"){for(o=c.length;c.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(c===-2)l=!0,a++;else if(c!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const c={type:n===e.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}const XG={42:Un,43:Un,45:Un,48:Un,49:Un,50:Un,51:Un,52:Un,53:Un,54:Un,55:Un,56:Un,57:Un,62:R5},QG={91:tG},ZG={[-2]:Ym,[-1]:Ym,32:Ym},JG={35:aG,42:ah,45:[hk,ah],60:dG,61:hk,95:ah,96:uk,126:uk},eY={38:A5,92:M5},tY={[-5]:Xm,[-4]:Xm,[-3]:Xm,33:IG,38:A5,42:B0,60:[RK,xG],91:RG,92:[sG,M5],93:qy,95:B0,96:WK},nY={null:[B0,qG]},rY={null:[42,95]},iY={null:[]},sY=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:rY,contentInitial:QG,disable:iY,document:XG,flow:JG,flowInitial:ZG,insideSpan:nY,string:eY,text:tY},Symbol.toStringTag,{value:"Module"}));function oY(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],a=[];const l={attempt:N(C),check:N(k),consume:_,enter:y,exit:S,interrupt:N(k,{interrupt:!0})},c={code:null,containerState:{},defineSkip:v,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d};let u=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function d(D){return o=xr(o,D),w(),o[o.length-1]!==null?[]:(T(t,0),c.events=Pp(s,c.events,c),c.events)}function f(D,R){return lY(p(D),R)}function p(D){return aY(o,D)}function m(){const{_bufferIndex:D,_index:R,line:A,column:M,offset:L}=r;return{_bufferIndex:D,_index:R,line:A,column:M,offset:L}}function v(D){i[D.line]=D.column,P()}function w(){let D;for(;r._index<o.length;){const R=o[r._index];if(typeof R=="string")for(D=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===D&&r._bufferIndex<R.length;)x(R.charCodeAt(r._bufferIndex));else x(R)}}function x(D){u=u(D)}function _(D){we(D)?(r.line++,r.column=1,r.offset+=D===-3?2:1,P()):D!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=D}function y(D,R){const A=R||{};return A.type=D,A.start=m(),c.events.push(["enter",A,c]),a.push(A),A}function S(D){const R=a.pop();return R.end=m(),c.events.push(["exit",R,c]),R}function C(D,R){T(D,R.from)}function k(D,R){R.restore()}function N(D,R){return A;function A(M,L,$){let F,B,z,E;return Array.isArray(M)?q(M):"tokenize"in M?q([M]):H(M);function H(K){return ge;function ge(Pe){const he=Pe!==null&&K[Pe],Ae=Pe!==null&&K.null,je=[...Array.isArray(he)?he:he?[he]:[],...Array.isArray(Ae)?Ae:Ae?[Ae]:[]];return q(je)(Pe)}}function q(K){return F=K,B=0,K.length===0?$:j(K[B])}function j(K){return ge;function ge(Pe){return E=O(),z=K,K.partial||(c.currentConstruct=K),K.name&&c.parser.constructs.disable.null.includes(K.name)?ie():K.tokenize.call(R?Object.assign(Object.create(c),R):c,l,ne,ie)(Pe)}}function ne(K){return D(z,E),L}function ie(K){return E.restore(),++B<F.length?j(F[B]):$}}}function T(D,R){D.resolveAll&&!s.includes(D)&&s.push(D),D.resolve&&or(c.events,R,c.events.length-R,D.resolve(c.events.slice(R),c)),D.resolveTo&&(c.events=D.resolveTo(c.events,c))}function O(){const D=m(),R=c.previous,A=c.currentConstruct,M=c.events.length,L=Array.from(a);return{from:M,restore:$};function $(){r=D,c.previous=R,c.currentConstruct=A,c.events.length=M,a=L,P()}}function P(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function aY(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,s)];else{if(o=e.slice(n,i),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}s>0&&o.push(e[i].slice(0,s))}return o}function lY(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
506
+ `)},$H=0,ia=[];function FH(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState($H++)[0],s=g.useState(LP)[0],o=g.useRef(e);g.useEffect(function(){o.current=e},[e]),g.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var v=lH([e.lockRef.current],(e.shards||[]).map(SS),!0).filter(Boolean);return v.forEach(function(w){return w.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),v.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(v,w){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var x=wd(v),_=n.current,y="deltaX"in v?v.deltaX:_[0]-x[0],S="deltaY"in v?v.deltaY:_[1]-x[1],C,k=v.target,N=Math.abs(y)>Math.abs(S)?"h":"v";if("touches"in v&&N==="h"&&k.type==="range")return!1;var T=window.getSelection(),O=T&&T.anchorNode,P=O?O===k||O.contains(k):!1;if(P)return!1;var D=bS(N,k);if(!D)return!0;if(D?C=N:(C=N==="v"?"h":"v",D=bS(N,k)),!D)return!1;if(!r.current&&"changedTouches"in v&&(y||S)&&(r.current=C),!C)return!0;var R=r.current||C;return OH(R,w,v,R==="h"?y:S)},[]),l=g.useCallback(function(v){var w=v;if(!(!ia.length||ia[ia.length-1]!==s)){var x="deltaY"in w?wS(w):wd(w),_=t.current.filter(function(C){return C.name===w.type&&(C.target===w.target||w.target===C.shadowParent)&&BH(C.delta,x)})[0];if(_&&_.should){w.cancelable&&w.preventDefault();return}if(!_){var y=(o.current.shards||[]).map(SS).filter(Boolean).filter(function(C){return C.contains(w.target)}),S=y.length>0?a(w,y[0]):!o.current.noIsolation;S&&w.cancelable&&w.preventDefault()}}},[]),c=g.useCallback(function(v,w,x,_){var y={name:v,delta:w,target:x,should:_,shadowParent:HH(x)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(S){return S!==y})},1)},[]),u=g.useCallback(function(v){n.current=wd(v),r.current=void 0},[]),d=g.useCallback(function(v){c(v.type,wS(v),v.target,a(v,e.lockRef.current))},[]),f=g.useCallback(function(v){c(v.type,wd(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return ia.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,ra),document.addEventListener("touchmove",l,ra),document.addEventListener("touchstart",u,ra),function(){ia=ia.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,ra),document.removeEventListener("touchmove",l,ra),document.removeEventListener("touchstart",u,ra)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(s,{styles:zH(i)}):null,p?g.createElement(PH,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function HH(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const UH=vH(jP,FH);var my=g.forwardRef(function(e,t){return g.createElement(_p,ri({},e,{ref:t,sideCar:UH}))});my.classNames=_p.classNames;var E0=["Enter"," "],WH=["ArrowDown","PageUp","Home"],zP=["ArrowUp","PageDown","End"],VH=[...WH,...zP],qH={ltr:[...E0,"ArrowRight"],rtl:[...E0,"ArrowLeft"]},KH={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Tu="Menu",[su,GH,YH]=GI(Tu),[Ho,$P]=Fo(Tu,[YH,xp,CP]),Iu=xp(),FP=CP(),[HP,qs]=Ho(Tu),[XH,Pu]=Ho(Tu),UP=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=Iu(t),[l,c]=g.useState(null),u=g.useRef(!1),d=gi(s),f=YI(i);return g.useEffect(()=>{const p=()=>{u.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>u.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),h.jsx(fy,{...a,children:h.jsx(HP,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(XH,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};UP.displayName=Tu;var QH="MenuAnchor",gy=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Iu(n);return h.jsx(bP,{...i,...r,ref:t})});gy.displayName=QH;var vy="MenuPortal",[ZH,WP]=Ho(vy,{forceMount:void 0}),VP=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=qs(vy,t);return h.jsx(ZH,{scope:t,forceMount:n,children:h.jsx(Ji,{present:n||s.open,children:h.jsx(py,{asChild:!0,container:i,children:r})})})};VP.displayName=vy;var br="MenuContent",[JH,xy]=Ho(br),qP=g.forwardRef((e,t)=>{const n=WP(br,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=qs(br,e.__scopeMenu),o=Pu(br,e.__scopeMenu);return h.jsx(su.Provider,{scope:e.__scopeMenu,children:h.jsx(Ji,{present:r||s.open,children:h.jsx(su.Slot,{scope:e.__scopeMenu,children:o.modal?h.jsx(eU,{...i,ref:t}):h.jsx(tU,{...i,ref:t})})})})}),eU=g.forwardRef((e,t)=>{const n=qs(br,e.__scopeMenu),r=g.useRef(null),i=Jt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return RP(s)},[]),h.jsx(_y,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Re(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),tU=g.forwardRef((e,t)=>{const n=qs(br,e.__scopeMenu);return h.jsx(_y,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),nU=ru("MenuContent.ScrollLock"),_y=g.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...v}=e,w=qs(br,n),x=Pu(br,n),_=Iu(n),y=FP(n),S=GH(n),[C,k]=g.useState(null),N=g.useRef(null),T=Jt(t,N,w.onContentChange),O=g.useRef(0),P=g.useRef(""),D=g.useRef(0),R=g.useRef(null),A=g.useRef("right"),M=g.useRef(0),L=m?my:g.Fragment,$=m?{as:nU,allowPinchZoom:!0}:void 0,F=z=>{var ge,Pe;const E=P.current+z,H=S().filter(he=>!he.disabled),q=document.activeElement,j=(ge=H.find(he=>he.ref.current===q))==null?void 0:ge.textValue,ne=H.map(he=>he.textValue),ie=pU(ne,E,j),K=(Pe=H.find(he=>he.textValue===ie))==null?void 0:Pe.ref.current;(function he(Ae){P.current=Ae,window.clearTimeout(O.current),Ae!==""&&(O.current=window.setTimeout(()=>he(""),1e3))})(E),K&&setTimeout(()=>K.focus())};g.useEffect(()=>()=>window.clearTimeout(O.current),[]),ZI();const B=g.useCallback(z=>{var H,q;return A.current===((H=R.current)==null?void 0:H.side)&&gU(z,(q=R.current)==null?void 0:q.area)},[]);return h.jsx(JH,{scope:n,searchRef:P,onItemEnter:g.useCallback(z=>{B(z)&&z.preventDefault()},[B]),onItemLeave:g.useCallback(z=>{var E;B(z)||((E=N.current)==null||E.focus(),k(null))},[B]),onTriggerLeave:g.useCallback(z=>{B(z)&&z.preventDefault()},[B]),pointerGraceTimerRef:D,onPointerGraceIntentChange:g.useCallback(z=>{R.current=z},[]),children:h.jsx(L,{...$,children:h.jsx(iy,{asChild:!0,trapped:i,onMountAutoFocus:Re(s,z=>{var E;z.preventDefault(),(E=N.current)==null||E.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:h.jsx(fp,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(rH,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:Re(l,z=>{x.isUsingKeyboardRef.current||z.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(wP,{role:"menu","aria-orientation":"vertical","data-state":cR(w.open),"data-radix-menu-content":"",dir:x.dir,..._,...v,ref:T,style:{outline:"none",...v.style},onKeyDown:Re(v.onKeyDown,z=>{const H=z.target.closest("[data-radix-menu-content]")===z.currentTarget,q=z.ctrlKey||z.altKey||z.metaKey,j=z.key.length===1;H&&(z.key==="Tab"&&z.preventDefault(),!q&&j&&F(z.key));const ne=N.current;if(z.target!==ne||!VH.includes(z.key))return;z.preventDefault();const K=S().filter(ge=>!ge.disabled).map(ge=>ge.ref.current);zP.includes(z.key)&&K.reverse(),hU(K)}),onBlur:Re(e.onBlur,z=>{z.currentTarget.contains(z.target)||(window.clearTimeout(O.current),P.current="")}),onPointerMove:Re(e.onPointerMove,ou(z=>{const E=z.target,H=M.current!==z.clientX;if(z.currentTarget.contains(E)&&H){const q=z.clientX>M.current?"right":"left";A.current=q,M.current=z.clientX}}))})})})})})})});qP.displayName=br;var rU="MenuGroup",yy=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(It.div,{role:"group",...r,ref:t})});yy.displayName=rU;var iU="MenuLabel",KP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(It.div,{...r,ref:t})});KP.displayName=iU;var af="MenuItem",kS="menu.itemSelect",yp=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=Pu(af,e.__scopeMenu),a=xy(af,e.__scopeMenu),l=Jt(t,s),c=g.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(kS,{bubbles:!0,cancelable:!0});d.addEventListener(kS,p=>r==null?void 0:r(p),{once:!0}),KI(d,f),f.defaultPrevented?c.current=!1:o.onClose()}};return h.jsx(GP,{...i,ref:l,disabled:n,onClick:Re(e.onClick,u),onPointerDown:d=>{var f;(f=e.onPointerDown)==null||f.call(e,d),c.current=!0},onPointerUp:Re(e.onPointerUp,d=>{var f;c.current||(f=d.currentTarget)==null||f.click()}),onKeyDown:Re(e.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||E0.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});yp.displayName=af;var GP=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=xy(af,n),a=FP(n),l=g.useRef(null),c=Jt(t,l),[u,d]=g.useState(!1),[f,p]=g.useState("");return g.useEffect(()=>{const m=l.current;m&&p((m.textContent??"").trim())},[s.children]),h.jsx(su.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:h.jsx(iH,{asChild:!0,...a,focusable:!r,children:h.jsx(It.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:Re(e.onPointerMove,ou(m=>{r?o.onItemLeave(m):(o.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Re(e.onPointerLeave,ou(m=>o.onItemLeave(m))),onFocus:Re(e.onFocus,()=>d(!0)),onBlur:Re(e.onBlur,()=>d(!1))})})})}),sU="MenuCheckboxItem",YP=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return h.jsx(eR,{scope:e.__scopeMenu,checked:n,children:h.jsx(yp,{role:"menuitemcheckbox","aria-checked":lf(n)?"mixed":n,...i,ref:t,"data-state":Sy(n),onSelect:Re(i.onSelect,()=>r==null?void 0:r(lf(n)?!0:!n),{checkForDefaultPrevented:!1})})})});YP.displayName=sU;var XP="MenuRadioGroup",[oU,aU]=Ho(XP,{value:void 0,onValueChange:()=>{}}),QP=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=gi(r);return h.jsx(oU,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(yy,{...i,ref:t})})});QP.displayName=XP;var ZP="MenuRadioItem",JP=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=aU(ZP,e.__scopeMenu),s=n===i.value;return h.jsx(eR,{scope:e.__scopeMenu,checked:s,children:h.jsx(yp,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Sy(s),onSelect:Re(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});JP.displayName=ZP;var by="MenuItemIndicator",[eR,lU]=Ho(by,{checked:!1}),tR=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=lU(by,n);return h.jsx(Ji,{present:r||lf(s.checked)||s.checked===!0,children:h.jsx(It.span,{...i,ref:t,"data-state":Sy(s.checked)})})});tR.displayName=by;var cU="MenuSeparator",nR=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(It.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});nR.displayName=cU;var uU="MenuArrow",rR=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Iu(n);return h.jsx(SP,{...i,...r,ref:t})});rR.displayName=uU;var wy="MenuSub",[dU,iR]=Ho(wy),sR=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=qs(wy,t),o=Iu(t),[a,l]=g.useState(null),[c,u]=g.useState(null),d=gi(i);return g.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),h.jsx(fy,{...o,children:h.jsx(HP,{scope:t,open:r,onOpenChange:d,content:c,onContentChange:u,children:h.jsx(dU,{scope:t,contentId:$i(),triggerId:$i(),trigger:a,onTriggerChange:l,children:n})})})};sR.displayName=wy;var rc="MenuSubTrigger",oR=g.forwardRef((e,t)=>{const n=qs(rc,e.__scopeMenu),r=Pu(rc,e.__scopeMenu),i=iR(rc,e.__scopeMenu),s=xy(rc,e.__scopeMenu),o=g.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},u=g.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return g.useEffect(()=>u,[u]),g.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),h.jsx(gy,{asChild:!0,...c,children:h.jsx(GP,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":cR(n.open),...e,ref:ku(t,i.onTriggerChange),onClick:d=>{var f;(f=e.onClick)==null||f.call(e,d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Re(e.onPointerMove,ou(d=>{s.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:Re(e.onPointerLeave,ou(d=>{var p,m;u();const f=(p=n.content)==null?void 0:p.getBoundingClientRect();if(f){const v=(m=n.content)==null?void 0:m.dataset.side,w=v==="right",x=w?-5:5,_=f[w?"left":"right"],y=f[w?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+x,y:d.clientY},{x:_,y:f.top},{x:y,y:f.top},{x:y,y:f.bottom},{x:_,y:f.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Re(e.onKeyDown,d=>{var p;const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||qH[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});oR.displayName=rc;var aR="MenuSubContent",lR=g.forwardRef((e,t)=>{const n=WP(br,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=qs(br,e.__scopeMenu),o=Pu(br,e.__scopeMenu),a=iR(aR,e.__scopeMenu),l=g.useRef(null),c=Jt(t,l);return h.jsx(su.Provider,{scope:e.__scopeMenu,children:h.jsx(Ji,{present:r||s.open,children:h.jsx(su.Slot,{scope:e.__scopeMenu,children:h.jsx(_y,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:c,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var d;o.isUsingKeyboardRef.current&&((d=l.current)==null||d.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:Re(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Re(e.onEscapeKeyDown,u=>{o.onClose(),u.preventDefault()}),onKeyDown:Re(e.onKeyDown,u=>{var p;const d=u.currentTarget.contains(u.target),f=KH[o.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});lR.displayName=aR;function cR(e){return e?"open":"closed"}function lf(e){return e==="indeterminate"}function Sy(e){return lf(e)?"indeterminate":e?"checked":"unchecked"}function hU(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function fU(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function pU(e,t,n){const i=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let o=fU(e,Math.max(s,0));i.length===1&&(o=o.filter(c=>c!==n));const l=o.find(c=>c.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function mU(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(i=!i)}return i}function gU(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return mU(n,t)}function ou(e){return t=>t.pointerType==="mouse"?e(t):void 0}var vU=UP,xU=gy,_U=VP,yU=qP,bU=yy,wU=KP,SU=yp,kU=YP,CU=QP,EU=JP,NU=tR,TU=nR,IU=rR,PU=sR,RU=oR,MU=lR,bp="DropdownMenu",[AU]=Fo(bp,[$P]),En=$P(),[jU,uR]=AU(bp),dR=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=En(t),c=g.useRef(null),[u,d]=Cu({prop:i,defaultProp:s??!1,onChange:o,caller:bp});return h.jsx(jU,{scope:t,triggerId:$i(),triggerRef:c,contentId:$i(),open:u,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(vU,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};dR.displayName=bp;var hR="DropdownMenuTrigger",fR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=uR(hR,n),o=En(n);return h.jsx(xU,{asChild:!0,...o,children:h.jsx(It.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:ku(t,s.triggerRef),onPointerDown:Re(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:Re(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});fR.displayName=hR;var LU="DropdownMenuPortal",pR=e=>{const{__scopeDropdownMenu:t,...n}=e,r=En(t);return h.jsx(_U,{...r,...n})};pR.displayName=LU;var mR="DropdownMenuContent",gR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=uR(mR,n),s=En(n),o=g.useRef(!1);return h.jsx(yU,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:t,onCloseAutoFocus:Re(e.onCloseAutoFocus,a=>{var l;o.current||(l=i.triggerRef.current)==null||l.focus(),o.current=!1,a.preventDefault()}),onInteractOutside:Re(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!i.modal||u)&&(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)"}})});gR.displayName=mR;var DU="DropdownMenuGroup",OU=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(bU,{...i,...r,ref:t})});OU.displayName=DU;var BU="DropdownMenuLabel",vR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(wU,{...i,...r,ref:t})});vR.displayName=BU;var zU="DropdownMenuItem",xR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(SU,{...i,...r,ref:t})});xR.displayName=zU;var $U="DropdownMenuCheckboxItem",_R=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(kU,{...i,...r,ref:t})});_R.displayName=$U;var FU="DropdownMenuRadioGroup",HU=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(CU,{...i,...r,ref:t})});HU.displayName=FU;var UU="DropdownMenuRadioItem",WU=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(EU,{...i,...r,ref:t})});WU.displayName=UU;var VU="DropdownMenuItemIndicator",yR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(NU,{...i,...r,ref:t})});yR.displayName=VU;var qU="DropdownMenuSeparator",bR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(TU,{...i,...r,ref:t})});bR.displayName=qU;var KU="DropdownMenuArrow",GU=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(IU,{...i,...r,ref:t})});GU.displayName=KU;var YU=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,o=En(t),[a,l]=Cu({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return h.jsx(PU,{...o,open:a,onOpenChange:l,children:n})},XU="DropdownMenuSubTrigger",wR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(RU,{...i,...r,ref:t})});wR.displayName=XU;var QU="DropdownMenuSubContent",SR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(MU,{...i,...r,ref:t,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)"}})});SR.displayName=QU;var ZU=dR,JU=fR,kR=pR,CR=gR,ER=vR,NR=xR,TR=_R,eW=yR,IR=bR,tW=YU,PR=wR,RR=SR;const ky=ZU,Cy=JU,wp=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(kR,{children:h.jsx(CR,{ref:r,sideOffset:t,className:re("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));wp.displayName=CR.displayName;const nW=tW,MR=g.forwardRef(({className:e,...t},n)=>h.jsx(PR,{ref:n,className:re("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100 data-[state=open]:bg-bg-200","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...t}));MR.displayName=PR.displayName;const AR=g.forwardRef(({className:e,...t},n)=>h.jsx(kR,{children:h.jsx(RR,{ref:n,className:re("z-50 min-w-[6rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...t})}));AR.displayName=RR.displayName;const Ri=g.forwardRef(({className:e,inset:t,...n},r)=>h.jsx(NR,{ref:r,className:re("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Ri.displayName=NR.displayName;const rW=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>h.jsxs(TR,{ref:i,checked:n,className:re("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-7 pr-2 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[h.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:h.jsx(eW,{children:h.jsx(wl,{className:"h-3.5 w-3.5"})})}),t]}));rW.displayName=TR.displayName;const jR=g.forwardRef(({className:e,...t},n)=>h.jsx(IR,{ref:n,className:re("-mx-1 my-1 h-px bg-border",e),...t}));jR.displayName=IR.displayName;const iW=g.forwardRef(({className:e,...t},n)=>h.jsx(ER,{ref:n,className:re("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));iW.displayName=ER.displayName;function sW({tool:e,className:t}){const n=QF(e);return h.jsx("span",{"data-testid":n?`session-icon-${e}`:"session-icon-default","aria-label":n?ny(e):"未知引擎",className:re("w-3.5 h-3.5 shrink-0 inline-flex items-center justify-center",hp(e),t),children:h.jsx(dp,{tool:e,className:"w-full h-full"})})}function oW({sessionId:e,hasUnread:t,running:n=!1,awaitingUser:r=!1,style:i}){return r?h.jsx(S$,{"data-testid":`awaiting-dot-${e}`,style:i,className:"w-3 h-3 text-warning shrink-0 animate-pulse",strokeWidth:2.25,"aria-label":"awaiting user"}):t?h.jsx("span",{"data-testid":`unread-dot-${e}`,style:i,className:"w-2 h-2 rounded-full bg-error shrink-0","aria-label":"unread"}):n?h.jsx("span",{"data-testid":`running-dot-${e}`,style:i,className:"w-2 h-2 rounded-full bg-success shrink-0 animate-pulse","aria-label":"running"}):null}function LR(e){return e.compositionActive||!!e.nativeIsComposing||e.keyCode===229}function DR(e){return e.key==="Enter"&&!e.shiftKey&&!LR(e)}function Ru(e,t){const n=g.useRef(!1),r=g.useCallback(()=>{n.current=!0},[]),i=g.useCallback(()=>{setTimeout(()=>{n.current=!1},0)},[]);return{onKeyDown:g.useCallback(o=>{const a=o.nativeEvent;if(DR({key:o.key,shiftKey:o.shiftKey,compositionActive:n.current,nativeIsComposing:a.isComposing,keyCode:a.keyCode})){o.preventDefault(),e();return}t&&o.key==="Escape"&&(o.preventDefault(),t())},[e,t]),onCompositionStart:r,onCompositionEnd:i}}function aW({open:e,initialLabel:t,placeholder:n,onSubmit:r,onCancel:i,title:s="Edit session",fieldLabel:o="Label",testId:a="session-edit-dialog",requireNonEmpty:l=!1}){const[c,u]=g.useState(t);g.useEffect(()=>{e&&u(t)},[e,t]);const d=c.trim(),f=l&&d==="",p=()=>{f||r({label:d})},m=Ru(p,i);return e?fl.createPortal(h.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-bg-0/40 backdrop-blur-[2px]",onClick:i,"data-testid":`${a}-overlay`,children:h.jsxs("div",{"data-testid":a,className:"w-[420px] max-w-[calc(100vw-32px)] rounded-2xl border border-text-100/[0.12] flex flex-col gap-4 p-5",style:{backgroundColor:"var(--bg-0)",boxShadow:"0 12px 40px rgba(0,0,0,0.04)"},onClick:v=>v.stopPropagation(),children:[h.jsx("div",{className:"text-[15px] font-semibold text-text-100",children:s}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:o}),h.jsx("input",{autoFocus:!0,type:"text",value:c,onChange:v=>u(v.target.value),...m,placeholder:n,"data-testid":`${a}-label`,className:"w-full px-3 py-2 text-[13px] bg-bg-50 border border-bg-300 rounded-lg focus:outline-none focus:border-text-300 transition-colors"})]}),h.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[h.jsx("button",{type:"button",onClick:i,className:"px-4 py-1.5 text-[12px] text-text-300 rounded-lg hover:bg-text-100/5 transition-colors cursor-pointer",children:"Cancel"}),h.jsx("button",{type:"button",onClick:p,disabled:f,"data-testid":`${a}-save`,className:"px-4 py-1.5 text-[12px] font-medium text-bg-0 rounded-lg bg-text-100 hover:bg-text-200 transition-colors cursor-pointer disabled:cursor-not-allowed disabled:opacity-40",children:"Save"})]})]})}),document.body):null}var lW=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),cW="VisuallyHidden",OR=g.forwardRef((e,t)=>h.jsx(It.span,{...e,ref:t,style:{...lW,...e.style}}));OR.displayName=cW;var uW=OR,[Sp]=Fo("Tooltip",[xp]),kp=xp(),BR="TooltipProvider",dW=700,N0="tooltip.open",[hW,Ey]=Sp(BR),zR=e=>{const{__scopeTooltip:t,delayDuration:n=dW,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=g.useRef(!0),a=g.useRef(!1),l=g.useRef(0);return g.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),h.jsx(hW,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:g.useCallback(()=>{window.clearTimeout(l.current),o.current=!1},[]),onClose:g.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:g.useCallback(c=>{a.current=c},[]),disableHoverableContent:i,children:s})};zR.displayName=BR;var au="Tooltip",[fW,Cp]=Sp(au),$R=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=Ey(au,e.__scopeTooltip),c=kp(t),[u,d]=g.useState(null),f=$i(),p=g.useRef(0),m=o??l.disableHoverableContent,v=a??l.delayDuration,w=g.useRef(!1),[x,_]=Cu({prop:r,defaultProp:i??!1,onChange:N=>{N?(l.onOpen(),document.dispatchEvent(new CustomEvent(N0))):l.onClose(),s==null||s(N)},caller:au}),y=g.useMemo(()=>x?w.current?"delayed-open":"instant-open":"closed",[x]),S=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,w.current=!1,_(!0)},[_]),C=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,_(!1)},[_]),k=g.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{w.current=!0,_(!0),p.current=0},v)},[v,_]);return g.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),h.jsx(fy,{...c,children:h.jsx(fW,{scope:t,contentId:f,open:x,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:g.useCallback(()=>{l.isOpenDelayedRef.current?k():S()},[l.isOpenDelayedRef,k,S]),onTriggerLeave:g.useCallback(()=>{m?C():(window.clearTimeout(p.current),p.current=0)},[C,m]),onOpen:S,onClose:C,disableHoverableContent:m,children:n})})};$R.displayName=au;var T0="TooltipTrigger",FR=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Cp(T0,n),s=Ey(T0,n),o=kp(n),a=g.useRef(null),l=Jt(t,a,i.onTriggerChange),c=g.useRef(!1),u=g.useRef(!1),d=g.useCallback(()=>c.current=!1,[]);return g.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),h.jsx(bP,{asChild:!0,...o,children:h.jsx(It.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:Re(e.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:Re(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:Re(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Re(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Re(e.onBlur,i.onClose),onClick:Re(e.onClick,i.onClose)})})});FR.displayName=T0;var pW="TooltipPortal",[Rae,mW]=Sp(pW,{forceMount:void 0}),Ja="TooltipContent",HR=g.forwardRef((e,t)=>{const n=mW(Ja,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=Cp(Ja,e.__scopeTooltip);return h.jsx(Ji,{present:r||o.open,children:o.disableHoverableContent?h.jsx(UR,{side:i,...s,ref:t}):h.jsx(gW,{side:i,...s,ref:t})})}),gW=g.forwardRef((e,t)=>{const n=Cp(Ja,e.__scopeTooltip),r=Ey(Ja,e.__scopeTooltip),i=g.useRef(null),s=Jt(t,i),[o,a]=g.useState(null),{trigger:l,onClose:c}=n,u=i.current,{onPointerInTransitChange:d}=r,f=g.useCallback(()=>{a(null),d(!1)},[d]),p=g.useCallback((m,v)=>{const w=m.currentTarget,x={x:m.clientX,y:m.clientY},_=bW(x,w.getBoundingClientRect()),y=wW(x,_),S=SW(v.getBoundingClientRect()),C=CW([...y,...S]);a(C),d(!0)},[d]);return g.useEffect(()=>()=>f(),[f]),g.useEffect(()=>{if(l&&u){const m=w=>p(w,u),v=w=>p(w,l);return l.addEventListener("pointerleave",m),u.addEventListener("pointerleave",v),()=>{l.removeEventListener("pointerleave",m),u.removeEventListener("pointerleave",v)}}},[l,u,p,f]),g.useEffect(()=>{if(o){const m=v=>{const w=v.target,x={x:v.clientX,y:v.clientY},_=(l==null?void 0:l.contains(w))||(u==null?void 0:u.contains(w)),y=!kW(x,o);_?f():y&&(f(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[l,u,o,c,f]),h.jsx(UR,{...e,ref:s})}),[vW,xW]=Sp(au,{isInside:!1}),_W=a9("TooltipContent"),UR=g.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,l=Cp(Ja,n),c=kp(n),{onClose:u}=l;return g.useEffect(()=>(document.addEventListener(N0,u),()=>document.removeEventListener(N0,u)),[u]),g.useEffect(()=>{if(l.trigger){const d=f=>{const p=f.target;p!=null&&p.contains(l.trigger)&&u()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,u]),h.jsx(fp,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:h.jsxs(wP,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[h.jsx(_W,{children:r}),h.jsx(vW,{scope:n,isInside:!0,children:h.jsx(uW,{id:l.contentId,role:"tooltip",children:i||r})})]})})});HR.displayName=Ja;var WR="TooltipArrow",yW=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=kp(n);return xW(WR,n).isInside?null:h.jsx(SP,{...i,...r,ref:t})});yW.displayName=WR;function bW(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function wW(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function SW(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function kW(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(i=!i)}return i}function CW(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),EW(t)}function EW(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],o=t[t.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var NW=zR,TW=$R,IW=FR,VR=HR;const cf=NW,Ep=TW,Np=IW,Mu=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(VR,{ref:r,sideOffset:t,className:re("z-50 overflow-hidden rounded-sm border border-border bg-bg-0 px-2 py-1 text-xs text-text-300 shadow-md",e),...n}));Mu.displayName=VR.displayName;const PW={held:!1,indexBySessionId:new Map},RW=g.createContext(PW);function MW(){return g.useContext(RW)}const AW=Array.from({length:9},(e,t)=>({id:`switch-session-${t+1}`,combo:{key:String(t+1),mod:!0},label:`切换到第 ${t+1} 个会话`,group:"会话",desktopOnly:!0,hiddenInList:!0})),jW=[{id:"new-session",combo:{key:"n",mod:!0},label:"新建任务",description:"打开快捷新建弹窗",group:"通用",desktopOnly:!0},{id:"open-search",combo:{key:"k",mod:!0},label:"全局搜索",description:"搜会话内容 / persona / 联系人",group:"通用",desktopOnly:!0},{id:"search-tab-prev",combo:{key:"ArrowLeft",mod:!0},label:"搜索:上一组",description:"搜索浮层里切到左边那个 tab(会话 / persona / 联系人)",group:"通用"},{id:"search-tab-next",combo:{key:"ArrowRight",mod:!0},label:"搜索:下一组",description:"搜索浮层里切到右边那个 tab",group:"通用"},...AW,{id:"archive-session",combo:{key:"Backspace",mod:!0,shift:!0},label:"归档当前会话",description:"归档当前聊天区的会话,Enter 确认 / Esc 取消",group:"会话",desktopOnly:!0},{id:"tab-prev",combo:{key:"ArrowLeft",mod:!0,shift:!0},label:"上一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"tab-next",combo:{key:"ArrowRight",mod:!0,shift:!0},label:"下一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"send-message",combo:{key:"Enter"},label:"发送消息",description:"在输入框中发送当前内容",group:"输入",displayOnly:!0},{id:"newline",combo:{key:"Enter",shift:!0},label:"换行",description:"在输入框中插入换行",group:"输入",displayOnly:!0},{id:"interrupt",combo:{key:"Escape"},label:"打断回复",description:"打断当前回复;2 秒内按两次停止任务",group:"输入",displayOnly:!0}];jW.filter(e=>!e.displayOnly);function LW(){return/Mac|iP(hone|od|ad)/.test(navigator.platform)}const DW=10,OW=20,BW=16,CS=20,ES=60,zW=4;function Sd({testId:e,label:t,children:n}){return h.jsxs(Ep,{children:[h.jsx(Np,{asChild:!0,children:h.jsx("span",{"data-testid":e,role:"img","aria-label":t,tabIndex:0,className:"inline-flex shrink-0",children:n})}),h.jsx(Mu,{side:"bottom",children:t})]})}function $W({session:e,active:t,hasUnread:n,running:r=!1,awaitingUser:i=!1,onSelect:s,onEdit:o,onDelete:a,onPin:l,onArchive:c,quickAction:u,depth:d=0,chevron:f,showCopyResume:p=!0,contactDisplayName:m,ownerPrincipalId:v,creatorDisplayName:w,dispatchedFromSessionTitle:x}){const[_,y]=g.useState(!1),S=MW(),C=S.held?S.indexBySessionId.get(e.sessionId):void 0,k=!!e.pinnedAt,N=d===0,T=d===0&&!!c,O=DW+d*OW;let P=null;u==="pin"&&N&&l?P={icon:k?h.jsx(Vw,{className:"w-4 h-4"}):h.jsx(qw,{className:"w-4 h-4"}),label:k?"取消置顶":"置顶",run:()=>l(e.sessionId,!k)}:u==="archive"&&T&&c?P={icon:h.jsx(Hw,{className:"w-4 h-4"}),label:"归档",run:()=>c(e.sessionId,!0)}:u==="rename"&&o&&(P={icon:h.jsx(v0,{className:"w-4 h-4"}),label:"重命名",run:()=>y(!0)});const D=g.useCallback(async()=>{const $=VI(e);if($)try{await navigator.clipboard.writeText($)}catch{}},[e]),R=ry(e),A=e.originOwnerPrincipalId,M=A?`@${m??`…${A.slice(-8)}`}`:null,L=!!(e.ownerPersonaId&&v&&e.creatorPrincipalId&&e.creatorPrincipalId!==v&&!e.larkChatId&&!e.shiftFiredFromSessionId&&!e.dispatchedFromSessionId);return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":`session-item-${e.sessionId}`,onClick:s,style:{paddingLeft:O,display:"grid",gridTemplateColumns:f?`${BW}px ${CS}px 1fr auto ${ES}px`:`${CS}px 1fr auto ${ES}px`,gridTemplateAreas:f?'"chev icon name dot time"':'"icon name dot time"',columnGap:`${zW}px`,alignItems:"center"},className:re("group relative rounded-lg cursor-pointer transition-all duration-150 pr-2.5 py-1.5",t?"bg-accent-dim":"hover:bg-sidebar-hover-bg"),children:[t?h.jsx("span",{"aria-hidden":"true",className:"absolute left-0 top-1/2 -translate-y-1/2 w-[3px] h-7 rounded-r-full bg-accent"}):null,h.jsx("div",{style:{gridArea:"chev"},className:"flex items-center justify-center",children:f??null}),h.jsx("div",{style:{gridArea:"icon"},className:"flex items-center justify-center",children:h.jsx(sW,{tool:e.tool})}),h.jsxs("div",{style:{gridArea:"name"},className:"flex items-center gap-1 min-w-0",children:[h.jsxs(cf,{delayDuration:200,skipDelayDuration:100,children:[e.dispatchedFromSessionId?h.jsx(Sd,{testId:`dispatched-icon-${e.sessionId}`,label:`来自【${x??"另一会话"}】dispatch`,children:h.jsx(U$,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.shiftFiredFromSessionId?h.jsx(Sd,{testId:`shift-fired-icon-${e.sessionId}`,label:"定时任务",children:h.jsx(g$,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.larkChatId?h.jsx(Sd,{testId:`lark-chat-icon-${e.sessionId}`,label:e.larkChatType==="p2p"?"来自飞书DM":"来自飞书群",children:h.jsx(g8,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,L?h.jsx(Sd,{testId:`guest-created-icon-${e.sessionId}`,label:w?`${w}创建`:"其他人创建",children:h.jsx(J8,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null]}),h.jsx("span",{"data-testid":`session-title-${e.sessionId}`,className:re("text-[13px] truncate min-w-0","group-hover:whitespace-normal group-hover:overflow-visible group-hover:break-words",t?"text-text-100 font-medium":"text-text-200"),children:R}),M?h.jsx("span",{"data-testid":`session-mirror-chip-${e.sessionId}`,title:`在 ${M.replace(/^@/,"")} 的设备上`,className:"shrink-0 inline-flex items-center px-1.5 py-0 rounded text-[10px] bg-accent-dim/40 text-accent border border-accent/20 max-w-[120px] truncate",children:M}):null]}),h.jsx(oW,{sessionId:e.sessionId,hasUnread:n,running:r,awaitingUser:i,style:{gridArea:"dot"}}),C!=null?h.jsx("span",{style:{gridArea:"time"},"data-testid":`session-quick-switch-badge-${e.sessionId}`,className:"text-right shrink-0 transition-opacity duration-150 group-hover:opacity-0",children:h.jsx("span",{className:"inline-flex items-center justify-center h-[18px] px-1.5 rounded-[5px] border border-border bg-bg-200/70 text-[11px] text-text-200 font-medium leading-none",children:LW()?`⌘${C}`:`Ctrl+${C}`})}):h.jsx("span",{style:{gridArea:"time"},className:re("text-[11px] text-text-400/70 text-right shrink-0","transition-opacity duration-150 group-hover:opacity-0"),children:e.updatedAt?ZF(e.updatedAt):""}),o||a||l||c?h.jsxs("div",{className:"absolute right-2 top-[3px] flex items-center opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100 transition-opacity",children:[P?h.jsx(cf,{delayDuration:200,skipDelayDuration:100,children:h.jsxs(Ep,{children:[h.jsx(Np,{asChild:!0,children:h.jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),P.run()},className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":P.label,"data-testid":`quick-action-${u}-${e.sessionId}`,children:P.icon})}),h.jsx(Mu,{side:"bottom",children:P.label})]})}):null,h.jsxs(ky,{modal:!1,children:[h.jsx(Cy,{asChild:!0,children:h.jsx("button",{type:"button",onClick:$=>$.stopPropagation(),className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"session actions","data-testid":`session-menu-${e.sessionId}`,children:h.jsx(yI,{className:"w-4 h-4"})})}),h.jsxs(wp,{align:"end",onClick:$=>$.stopPropagation(),children:[l&&N&&h.jsxs(Ri,{onSelect:()=>l(e.sessionId,!k),"data-testid":`session-${k?"unpin":"pin"}-${e.sessionId}`,children:[k?h.jsx(Vw,{className:"w-3 h-3 mr-2 text-text-400"}):h.jsx(qw,{className:"w-3 h-3 mr-2 text-text-400"}),k?"Unpin":"Pin"]}),T&&c&&h.jsxs(Ri,{onSelect:()=>c(e.sessionId,!0),"data-testid":`session-archive-${e.sessionId}`,children:[h.jsx(Hw,{className:"w-3 h-3 mr-2 text-text-400"}),"Archive"]}),o&&h.jsxs(Ri,{onSelect:()=>y(!0),"data-testid":`session-rename-${e.sessionId}`,children:[h.jsx(v0,{className:"w-3 h-3 mr-2 text-text-400"}),"Rename"]}),p&&e.toolSessionId?h.jsxs(Ri,{onSelect:()=>void D(),"data-testid":`session-copy-resume-${e.sessionId}`,children:[h.jsx(up,{className:"w-3 h-3 mr-2 text-text-400"}),"Copy Resume Command"]}):null,(l||o||p&&e.toolSessionId)&&a&&h.jsx(jR,{}),a&&h.jsxs(Ri,{onSelect:()=>void a(e.sessionId),className:"text-destructive focus:text-destructive focus:bg-destructive/10","data-testid":`session-delete-${e.sessionId}`,children:[h.jsx(J_,{className:"w-3 h-3 mr-2"}),"Delete"]})]})]})]}):null]}),o?h.jsx(aW,{open:_,initialLabel:e.label??"",placeholder:e.cwd.split("/").pop()||"",onSubmit:$=>{o(e.sessionId,$),y(!1)},onCancel:()=>y(!1)}):null]})}function Ny({node:e,depth:t=0,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:v,getSessionDisplayName:w,parentSession:x}){const _=e.children.length>0,{isCollapsed:y,toggle:S}=c$(),C=!y(e.session.sessionId),k=g.useCallback(T=>{T.stopPropagation(),S(e.session.sessionId)},[S,e.session.sessionId]),N=_?h.jsx("button",{type:"button",onClick:k,"data-testid":`session-chevron-${e.session.sessionId}`,"aria-label":C?"collapse":"expand","aria-expanded":C,className:"shrink-0 flex items-center justify-center w-4 h-4 text-text-400 hover:text-text-100 cursor-pointer",children:C?h.jsx(Yn,{className:"w-3 h-3"}):h.jsx(Bn,{className:"w-3 h-3"})}):null;return h.jsxs("div",{"data-testid":`session-tree-node-${e.session.sessionId}`,children:[h.jsx($W,{session:e.session,active:n===e.session.sessionId,hasUnread:(r==null?void 0:r.has(e.session.sessionId))??!1,running:(i==null?void 0:i.has(e.session.sessionId))??!1,awaitingUser:(s==null?void 0:s.has(e.session.sessionId))??!1,onSelect:()=>o(e.session.sessionId),onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,showCopyResume:p,ownerPrincipalId:m,creatorDisplayName:e.session.creatorPrincipalId?v==null?void 0:v(e.session.creatorPrincipalId):void 0,dispatchedFromSessionTitle:e.session.dispatchedFromSessionId?(w==null?void 0:w(e.session.dispatchedFromSessionId))??((x==null?void 0:x.sessionId)===e.session.dispatchedFromSessionId?ry(x):void 0):void 0,depth:t,chevron:N,contactDisplayName:e.session.originOwnerPrincipalId?f==null?void 0:f(e.session.originOwnerPrincipalId):void 0}),_&&C?h.jsx("div",{"data-testid":`session-tree-children-${e.session.sessionId}`,children:e.children.map(T=>h.jsx(Ny,{node:T,depth:t+1,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:v,getSessionDisplayName:w,parentSession:e.session},T.session.sessionId))}):null]})}function FW(e){return e.forkedFromSessionId??e.dispatchedFromSessionId??e.shiftFiredFromSessionId}function qR(e){e=e.filter(s=>!s.ephemeral&&s.deployId===void 0);const t=new Map;for(const s of e)t.set(s.sessionId,s);const n=new Map,r=[];for(const s of e){const o=FW(s);if(o&&t.has(o)){const a=n.get(o)??[];a.push(s),n.set(o,a)}else r.push(s)}const i=s=>{const a=[...n.get(s.sessionId)??[]].sort((l,c)=>l.createdAt<c.createdAt?-1:l.createdAt>c.createdAt?1:0);return{session:s,children:a.map(i)}};return[...r].sort(HW).map(i)}function KR(e){return[...e].sort((t,n)=>t.session.updatedAt<n.session.updatedAt?1:t.session.updatedAt>n.session.updatedAt?-1:0)}function HW(e,t){const n=typeof e.pinnedAt=="number",r=typeof t.pinnedAt=="number";if(n&&r){const i=typeof e.pinSortOrder=="number",s=typeof t.pinSortOrder=="number";return i&&s?e.pinSortOrder-t.pinSortOrder:i?-1:s?1:t.pinnedAt-e.pinnedAt}return n?-1:r||e.updatedAt<t.updatedAt?1:e.updatedAt>t.updatedAt?-1:0}function UW(e){return e.appBuilderProject?`[app] ${e.appBuilderProject}`:e.label?e.label:e.aiLabel?e.aiLabel:e.cwd.split("/").filter(Boolean).pop()??""}function NS(e,t){const n=t.trim().toLowerCase();return n===""?!0:e.toLowerCase().includes(n)}const WW={isCollapsed:()=>!1,toggle:()=>{},prune:()=>{}};function VW({personas:e,activePersonaId:t,onSelectPersona:n,onCreateSession:r,sessions:i,activeSessionId:s,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,isPersonaExpanded:p,onTogglePersonaExpanded:m,onEditSession:v,onPinSession:w,showCopyResume:x,treatSessionsAsRoots:_,searchQuery:y}){const[S,C]=g.useState(null),[k,N]=g.useState(()=>new Set),T=p??(L=>k.has(L)),O=g.useCallback(L=>{if(m){m(L);return}N($=>{const F=new Set($);return F.has(L)?F.delete(L):F.add(L),F})},[m]),P=g.useMemo(()=>i==null?void 0:i.filter(L=>!L.ephemeral),[i]),D=g.useMemo(()=>new Map((P??[]).map(L=>[L.sessionId,ry(L)])),[P]),R=g.useCallback(L=>f==null?void 0:f.get(L),[f]),A=g.useCallback(L=>D.get(L),[D]);if(e.length===0)return h.jsx(qW,{});const M=(y??"").trim();return M?h.jsx(X_.Provider,{value:WW,children:h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(L=>{const $=P?P.filter(E=>E.ownerPersonaId===L.personaId).sort((E,H)=>H.updatedAt>E.updatedAt?1:-1):[],F=NS(L.label,M),B=$.filter(E=>NS(UW(E),M));if(!F&&B.length===0)return null;const z=F?$:B;return h.jsx(TS,{persona:L,active:L.personaId===t,editing:!1,onSelectPersona:n,onSubmitCreateSession:()=>{},onCancelCreateSession:()=>{},personaSessions:z,collapsed:!1,onToggleCollapsed:()=>{},activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:w,showCopyResume:x,treatSessionsAsRoots:_,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:R,getSessionDisplayName:A},L.personaId)})})}):h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(L=>{const $=P?P.filter(F=>F.ownerPersonaId===L.personaId).sort((F,B)=>B.updatedAt>F.updatedAt?1:-1):[];return h.jsx(TS,{persona:L,active:L.personaId===t,editing:L.personaId===S,onSelectPersona:n,onStartCreateSession:r?()=>C(L.personaId):void 0,onSubmitCreateSession:F=>{C(null),r==null||r(L.personaId,F)},onCancelCreateSession:()=>C(null),personaSessions:$,collapsed:!T(L.personaId),onToggleCollapsed:()=>O(L.personaId),activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:w,showCopyResume:x,treatSessionsAsRoots:_,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:R,getSessionDisplayName:A},L.personaId)})})}function qW(){return h.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-text-400",children:"还没有 persona。点上方 Personas 标题右侧 + 创建第一个。"})}function TS({persona:e,active:t,editing:n,onSelectPersona:r,onStartCreateSession:i,onSubmitCreateSession:s,onCancelCreateSession:o,personaSessions:a,collapsed:l,onToggleCollapsed:c,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:w,onPinSession:x,showCopyResume:_,treatSessionsAsRoots:y,ownerPrincipalId:S,creatorDisplayNameByOwnerId:C,getCreatorDisplayName:k,getSessionDisplayName:N}){const T=a.length>0,O=!l,P=g.useMemo(()=>{const A=[],M=new Map;for(const L of a){const $=L.creatorPrincipalId;if(L.larkChatId!=null||!$||S&&$===S){A.push(L);continue}const F=$,B=(C==null?void 0:C.get(F))??`…${F.slice(-8)}`,z=M.get(F);z?z.sessions.push(L):M.set(F,{groupKey:F,displayName:B,sessions:[L]})}return{self:A,byPeer:[...M.values()]}},[a,S,C]),D=P.byPeer.length>0,R=g.useMemo(()=>O&&!D?KR(qR(a)):[],[O,D,a]);return h.jsxs("div",{"data-testid":`persona-node-${e.personaId}`,children:[h.jsxs("div",{className:re("group flex items-center gap-1 px-2 py-1.5 cursor-pointer",t?"bg-accent-dim text-text-100":"hover:bg-bg-200 text-text-200"),onClick:()=>r==null?void 0:r(e.personaId),role:"button",tabIndex:0,children:[T?h.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),c()},"aria-label":O?"collapse":"expand","aria-expanded":O,"data-testid":`persona-chevron-${e.personaId}`,className:"flex h-4 w-4 shrink-0 items-center justify-center text-text-400 hover:text-text-100",children:O?h.jsx(Yn,{className:"h-3 w-3"}):h.jsx(Bn,{className:"h-3 w-3"})}):h.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),h.jsx(dp,{tool:e.tool,className:re("h-3.5 w-3.5 shrink-0",hp(e.tool))}),h.jsx("span",{className:"flex-1 truncate text-[13px]",children:e.label}),T?h.jsx("span",{className:"shrink-0 text-[10px] text-text-400 tabular-nums","aria-label":`${a.length} sessions`,children:a.length}):null,i?h.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),i()},"aria-label":"新建会话",title:"新建会话","data-testid":`persona-create-session-${e.personaId}`,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded text-text-400 opacity-0 hover:bg-text-100/10 hover:text-text-100 focus-visible:opacity-100 group-hover:opacity-100",children:h.jsx(I8,{className:"h-3.5 w-3.5"})}):null]}),n?h.jsx(KW,{personaId:e.personaId,tool:e.tool,onSubmit:s,onCancel:o}):null,T&&O?h.jsx("div",{"data-testid":`persona-sessions-${e.personaId}`,children:D?h.jsxs(h.Fragment,{children:[P.self.length>0&&h.jsx(IS,{groupKey:`${e.personaId}-self`,label:"我自己",testId:`persona-sessions-${e.personaId}-self`,sessions:P.self,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:w,onPinSession:x,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N}),P.byPeer.map(A=>h.jsx(IS,{groupKey:`${e.personaId}-peer-${A.groupKey}`,label:A.displayName,testId:`persona-sessions-${e.personaId}-peer-${A.groupKey}`,sessions:A.sessions,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:w,onPinSession:x,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N},`${e.personaId}-peer-${A.groupKey}`))]}):R.map(A=>h.jsx(Ny,{node:A,depth:y?0:1,activeId:u,unreadIds:p,runningIds:f,awaitingIds:d,onSelect:M=>m==null?void 0:m(M),onDelete:v,onEdit:w,onPin:x,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N},A.session.sessionId))}):null]})}function IS({label:e,testId:t,sessions:n,activeSessionId:r,awaitingIds:i,runningIds:s,unreadIds:o,onSelectSession:a,onDeleteSession:l,onEditSession:c,onPinSession:u,showCopyResume:d,ownerPrincipalId:f,getCreatorDisplayName:p,getSessionDisplayName:m}){const[v,w]=g.useState(!1),x=!v,_=g.useMemo(()=>x?KR(qR(n)):[],[x,n]);return h.jsxs("div",{"data-testid":t,children:[h.jsxs("button",{type:"button",onClick:()=>w(y=>!y),"aria-label":x?"collapse":"expand","aria-expanded":x,"data-testid":`${t}-chevron`,className:"flex items-center gap-1 w-full pl-7 pr-2 py-0.5 text-[11px] text-text-400 hover:text-text-200 transition-colors",children:[x?h.jsx(Yn,{className:"h-3 w-3"}):h.jsx(Bn,{className:"h-3 w-3"}),h.jsx(NI,{className:"h-3 w-3","aria-hidden":!0}),h.jsx("span",{className:"truncate",children:e}),h.jsx("span",{className:"ml-auto tabular-nums",children:n.length})]}),x&&h.jsx("div",{children:_.map(y=>h.jsx(Ny,{node:y,depth:2,activeId:r,unreadIds:o,runningIds:s,awaitingIds:i,onSelect:S=>a==null?void 0:a(S),onDelete:l,onEdit:c,onPin:u,showCopyResume:d,ownerPrincipalId:f,getCreatorDisplayName:p,getSessionDisplayName:m},y.session.sessionId))})]})}function KW({personaId:e,tool:t,onSubmit:n,onCancel:r}){const[i,s]=g.useState(""),o=g.useRef(null),a=i.trim(),l=a.length>0;g.useEffect(()=>{var d;(d=o.current)==null||d.focus()},[]);const c=g.useCallback(()=>{l&&n(a)},[l,a,n]),u=Ru(c,r);return h.jsxs("div",{className:"flex items-center gap-1.5 pl-9 pr-2 py-1","data-testid":`persona-new-session-row-${e}`,children:[h.jsx(dp,{tool:t,className:re("h-3 w-3 shrink-0",hp(t))}),h.jsx("input",{ref:o,type:"text",value:i,onChange:d=>s(d.target.value),...u,onBlur:r,placeholder:"session label...","data-testid":`persona-new-session-input-${e}`,className:"flex-1 min-w-0 bg-bg-100 border border-text-100/15 rounded px-1.5 py-0.5 text-[12px] text-text-100 placeholder:text-text-400 focus:outline-none focus:border-text-100/40"}),h.jsx("button",{type:"button",onMouseDown:d=>{d.preventDefault(),c()},disabled:!l,"aria-label":"确认",title:"确认(Enter)","data-testid":`persona-new-session-confirm-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-text-300",children:h.jsx(wl,{className:"h-3 w-3"})}),h.jsx("button",{type:"button",onMouseDown:d=>{d.preventDefault(),r()},"aria-label":"取消",title:"取消(Esc)","data-testid":`persona-new-session-cancel-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100",children:h.jsx(Ir,{className:"h-3 w-3"})})]})}function GW(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function YW(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),r=parseFloat(n.fontSize);return t*r}function XW(e){return e/100*window.innerHeight}function QW(e){return e/100*window.innerWidth}function ZW(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function ic({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=ZW(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=YW(t,i);break}case"em":{r=GW(t,i);break}case"vh":{r=XW(i);break}case"vw":{r=QW(i);break}}return r}function Mn(e){return parseFloat(e.toFixed(3))}function el({group:e}){const{orientation:t,panels:n}=e;return n.reduce((r,i)=>(r+=t==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,r),0)}function I0(e){const{panels:t}=e,n=el({group:e});return n===0?t.map(r=>({groupResizeBehavior:r.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:r.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:r.panelConstraints.disabled,minSize:0,maxSize:100,panelId:r.id})):t.map(r=>{const{element:i,panelConstraints:s}=r;let o=0;if(s.collapsedSize!==void 0){const u=ic({groupSize:n,panelElement:i,styleProp:s.collapsedSize});o=Mn(u/n*100)}let a;if(s.defaultSize!==void 0){const u=ic({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=Mn(u/n*100)}let l=0;if(s.minSize!==void 0){const u=ic({groupSize:n,panelElement:i,styleProp:s.minSize});l=Mn(u/n*100)}let c=100;if(s.maxSize!==void 0){const u=ic({groupSize:n,panelElement:i,styleProp:s.maxSize});c=Mn(u/n*100)}return{groupResizeBehavior:s.groupResizeBehavior,collapsedSize:o,collapsible:s.collapsible===!0,defaultSize:a,disabled:s.disabled,minSize:l,maxSize:c,panelId:r.id}})}function st(e,t="Assertion error"){if(!e)throw Error(t)}function P0(e,t){return Array.from(t).sort(e==="horizontal"?JW:eV)}function JW(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function eV(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function GR(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function YR(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function tV({orientation:e,rects:t,targetRect:n}){const r={x:n.x+n.width/2,y:n.y+n.height/2};let i,s=Number.MAX_VALUE;for(const o of t){const{x:a,y:l}=YR(r,o),c=e==="horizontal"?a:l;c<s&&(s=c,i=o)}return st(i,"No rect found"),i}let kd;function nV(){return kd===void 0&&(typeof matchMedia=="function"?kd=!!matchMedia("(pointer:coarse)").matches:kd=!1),kd}function XR(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=P0(n,Array.from(t.children).filter(GR).map(m=>({element:m}))).map(({element:m})=>m),o=[];let a=!1,l=!1,c=-1,u=-1,d=0,f,p=[];{let m=-1;for(const v of s)v.hasAttribute("data-panel")&&(m++,v.hasAttribute("data-disabled")||(d++,c===-1&&(c=m),u=m))}if(d>1){let m=-1;for(const v of s)if(v.hasAttribute("data-panel")){m++;const w=r.find(x=>x.element===v);if(w){if(f){const x=f.element.getBoundingClientRect(),_=v.getBoundingClientRect();let y;if(l){const S=n==="horizontal"?new DOMRect(x.right,x.top,0,x.height):new DOMRect(x.left,x.bottom,x.width,0),C=n==="horizontal"?new DOMRect(_.left,_.top,0,_.height):new DOMRect(_.left,_.top,_.width,0);switch(p.length){case 0:{y=[S,C];break}case 1:{const k=p[0],N=tV({orientation:n,rects:[x,_],targetRect:k.element.getBoundingClientRect()});y=[k,N===x?C:S];break}default:{y=p;break}}}else p.length?y=p:y=[n==="horizontal"?new DOMRect(x.right,_.top,_.left-x.right,_.height):new DOMRect(_.left,x.bottom,_.width,_.top-x.bottom)];for(const S of y){let C="width"in S?S:S.element.getBoundingClientRect();const k=nV()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(C.width<k){const T=k-C.width;C=new DOMRect(C.x-T/2,C.y,C.width+T,C.height)}if(C.height<k){const T=k-C.height;C=new DOMRect(C.x,C.y-T/2,C.width,C.height+T)}const N=m<=c||m>u;!a&&!N&&o.push({group:e,groupSize:el({group:e}),panels:[f,w],separator:"width"in S?void 0:S,rect:C}),a=!1}}l=!1,f=w,p=[]}}else if(v.hasAttribute("data-separator")){v.ariaDisabled!==null&&(a=!0);const w=i.find(x=>x.element===v);w?p.push(w):(f=void 0,p=[])}else l=!0}return o}var _s;class QR{constructor(){I1(this,_s,{})}addListener(t,n){const r=Rl(this,_s)[t];return r===void 0?Rl(this,_s)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=Rl(this,_s)[t];if(r!==void 0)if(r.length===1)r[0].call(null,n);else{let i=!1,s=null;const o=Array.from(r);for(let a=0;a<o.length;a++){const l=o[a];try{l.call(null,n)}catch(c){s===null&&(i=!0,s=c)}}if(i)throw s}}removeAllListeners(){P1(this,_s,{})}removeListener(t,n){const r=Rl(this,_s)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}_s=new WeakMap;let Oa={cursorFlags:0,state:"inactive"};const Ty=new QR;function Io(){return Oa}function rV(e){return Ty.addListener("change",e)}function iV(e){const t=Oa,n={...Oa};n.cursorFlags=e,Oa=n,Ty.emit("change",{prev:t,next:n})}function Ba(e){const t=Oa;Oa=e,Ty.emit("change",{prev:t,next:e})}const sV=e=>e,qm=()=>{},ZR=1,JR=2,e5=4,t5=8,PS=3,RS=12;let Cd;function MS(){return Cd===void 0&&(Cd=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(Cd=!0)),Cd}function oV({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case"active":case"hover":t.forEach(s=>{if(!s.mutableState.disableCursor)switch(s.orientation){case"horizontal":{r++;break}case"vertical":{i++;break}}})}if(!(r===0&&i===0)){switch(n){case"active":{if(e&&MS()){const s=(e&ZR)!==0,o=(e&JR)!==0,a=(e&e5)!==0,l=(e&t5)!==0;if(s)return a?"se-resize":l?"ne-resize":"e-resize";if(o)return a?"sw-resize":l?"nw-resize":"w-resize";if(a)return"s-resize";if(l)return"n-resize"}break}}return MS()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const AS=new WeakMap;function Iy(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=AS.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));const r=Io();switch(r.state){case"active":case"hover":{const i=oV({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(o=>o.group),state:r.state}),s=`*, *:hover {cursor: ${i} !important; }`;if(t===s)return;t=s,i?n.cssRules.length===0?n.insertRule(s):n.replaceSync(s):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}AS.set(e,{prevStyle:t,styleSheet:n})}let si=new Map;const n5=new QR;function aV(e){si=new Map(si),si.delete(e)}function jS(e,t){for(const[n]of si)if(n.id===e)return n}function As(e,t){for(const[n,r]of si)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Uo(){return si}function Py(e,t){return n5.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function Gi(e,t,n){const r=si.get(e);si=new Map(si),si.set(e,t),n5.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:r,next:t})}function r5(e){const t=Io();let n=!1;switch(t.state){case"active":Ba({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(Iy(e),n=!0,t.hitRegions.forEach(r=>{const i=As(r.group.id,!0);Gi(r.group,i,{isUserInteraction:!0})}))}return n}function LS(e){e.defaultPrevented||r5(e.currentTarget)}function lV(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const o=YR(n,s.rect);switch(e){case"horizontal":{o.x<=i.x&&(r=s,i=o);break}case"vertical":{o.y<=i.y&&(r=s,i=o);break}}}return r?{distance:i,hitRegion:r}:void 0}function cV(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function uV(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:BS(e),b:BS(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();st(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:OS(DS(n.a)),b:OS(DS(n.b))};if(i.a===i.b){const s=r.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const l=s[a];if(l===o.a)return 1;if(l===o.b)return-1}}return Math.sign(i.a-i.b)}const dV=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function hV(e){const t=getComputedStyle(i5(e)??e).display;return t==="flex"||t==="inline-flex"}function fV(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||hV(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||dV.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function DS(e){let t=e.length;for(;t--;){const n=e[t];if(st(n,"Missing node"),fV(n))return n}return null}function OS(e){return e&&Number(getComputedStyle(e).zIndex)||0}function BS(e){const t=[];for(;e;)t.push(e),e=i5(e);return t}function i5(e){const{parentNode:t}=e;return cV(t)?t.host:t}function pV(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function mV({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!GR(n)||n.contains(e)||e.contains(n))return!0;if(uV(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(pV(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Ry(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=XR(i),o=lV(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&mV({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function gV(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function wn(e,t,n=0){return Math.abs(Mn(e)-Mn(t))<=n}function ti(e,t){return wn(e,t)?0:e>t?1:-1}function Ea({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){const{collapsedSize:i=0,collapsible:s,disabled:o,maxSize:a=100,minSize:l=0}=t;if(o&&!e)return n;if(ti(r,l)<0)if(s){const c=(i+l)/2;ti(r,c)<0?r=i:r=l}else r=l;return r=Math.min(a,r),r=Mn(r),r}function lu({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(wn(e,0))return t;const o=s==="imperative-api",a=Object.values(t),l=Object.values(i),c=[...a],[u,d]=r;st(u!=null,"Invalid first pivot index"),st(d!=null,"Invalid second pivot index");let f=0;switch(s){case"keyboard":{{const v=e<0?d:u,w=n[v];st(w,`Panel constraints not found for index ${v}`);const{collapsedSize:x=0,collapsible:_,minSize:y=0}=w;if(_){const S=a[v];if(st(S!=null,`Previous layout not found for panel index ${v}`),wn(S,x)){const C=y-S;ti(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}{const v=e<0?u:d,w=n[v];st(w,`No panel constraints found for index ${v}`);const{collapsedSize:x=0,collapsible:_,minSize:y=0}=w;if(_){const S=a[v];if(st(S!=null,`Previous layout not found for panel index ${v}`),wn(S,y)){const C=S-x;ti(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}break}default:{const v=e<0?d:u,w=n[v];st(w,`Panel constraints not found for index ${v}`);const x=a[v],{collapsible:_,collapsedSize:y,minSize:S}=w;if(_&&ti(x,S)<0)if(e>0){const C=S-y,k=C/2,N=x+e;ti(N,S)<0&&(e=ti(e,k)<=0?0:C)}else{const C=S-y,k=100-C/2,N=x-e;ti(N,S)<0&&(e=ti(100+e,k)>0?0:-C)}break}}{const v=e<0?1:-1;let w=e<0?d:u,x=0;for(;;){const y=a[w];st(y!=null,`Previous layout not found for panel index ${w}`);const S=Ea({overrideDisabledPanels:o,panelConstraints:n[w],prevSize:y,size:100})-y;if(x+=S,w+=v,w<0||w>=n.length)break}const _=Math.min(Math.abs(e),Math.abs(x));e=e<0?0-_:_}{let v=e<0?u:d;for(;v>=0&&v<n.length;){const w=Math.abs(e)-Math.abs(f),x=a[v];st(x!=null,`Previous layout not found for panel index ${v}`);const _=x-w,y=Ea({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:x,size:_});if(!wn(x,y)&&(f+=x-y,c[v]=y,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?v--:v++}}if(gV(l,c))return i;{const v=e<0?d:u,w=a[v];st(w!=null,`Previous layout not found for panel index ${v}`);const x=w+f,_=Ea({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:w,size:x});if(c[v]=_,!wn(_,x)){let y=x-_,S=e<0?d:u;for(;S>=0&&S<n.length;){const C=c[S];st(C!=null,`Previous layout not found for panel index ${S}`);const k=C+y,N=Ea({overrideDisabledPanels:o,panelConstraints:n[S],prevSize:C,size:k});if(wn(C,N)||(y-=N-C,c[S]=N),wn(y,0))break;e>0?S--:S++}}}const p=Object.values(c).reduce((v,w)=>w+v,0);if(!wn(p,100,.1))return i;const m=Object.keys(i);return c.reduce((v,w,x)=>(v[m[x]]=w,v),{})}function Po(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||ti(e[n],t[n])!==0)return!1;return!0}function Ro({layout:e,panelConstraints:t}){const n=Object.values(e),r=[...n],i=r.reduce((a,l)=>a+l,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(a=>`${a}%`).join(", ")}`);if(!wn(i,100)&&r.length>0)for(let a=0;a<t.length;a++){const l=r[a];st(l!=null,`No layout data found for index ${a}`);const c=100/i*l;r[a]=c}let s=0;for(let a=0;a<t.length;a++){const l=n[a];st(l!=null,`No layout data found for index ${a}`);const c=r[a];st(c!=null,`No layout data found for index ${a}`);const u=Ea({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});c!=u&&(s+=c-u,r[a]=u)}if(!wn(s,0))for(let a=0;a<t.length;a++){const l=r[a];st(l!=null,`No layout data found for index ${a}`);const c=l+s,u=Ea({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});if(l!==u&&(s-=u-l,r[a]=u,wn(s,0)))break}const o=Object.keys(e);return r.reduce((a,l,c)=>(a[o[c]]=l,a),{})}function s5({groupId:e,panelId:t}){const n=()=>{const l=Uo();for(const[c,{defaultLayoutDeferred:u,derivedPanelConstraints:d,layout:f,groupSize:p,separatorToPanels:m}]of l)if(c.id===e)return{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:c,groupSize:p,layout:f,separatorToPanels:m};throw Error(`Group ${e} not found`)},r=()=>{const l=n().derivedPanelConstraints.find(c=>c.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const l=n().group.panels.find(c=>c.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const l=n().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:l,panels:c,prevLayout:u,derivedPanelConstraints:d})=>{const f=s(),p=c.findIndex(w=>w.id===t),m=p===0,v=p===c.length-1;if(v&&l<f&&(m||c.slice(0,p).every((w,x)=>{const _=d[x];return(_==null?void 0:_.collapsible)&&wn(_.collapsedSize,u[_.panelId])}))){const w=c.slice(0,p).reduce((x,_)=>x+u[_.id],0);return{...u,[t]:Mn(100-w)}}return lu({delta:v?f-l:l-f,initialLayout:u,panelConstraints:d,pivotIndices:v?[p-1,p]:[p,p+1],prevLayout:u,trigger:"imperative-api"})},a=l=>{const c=s();if(l===c)return;const{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:f,groupSize:p,layout:m,separatorToPanels:v}=n(),w=o({nextSize:l,panels:f.panels,prevLayout:m,derivedPanelConstraints:d}),x=Ro({layout:w,panelConstraints:d});Po(m,x)||Gi(f,{defaultLayoutDeferred:u,derivedPanelConstraints:d,groupSize:p,layout:x,separatorToPanels:v})};return{collapse:()=>{const{collapsible:l,collapsedSize:c}=r(),{mutableValues:u}=i(),d=s();l&&d!==c&&(u.expandToSize=d,a(c))},expand:()=>{const{collapsible:l,collapsedSize:c,minSize:u}=r(),{mutableValues:d}=i(),f=s();if(l&&f===c){let p=d.expandToSize??u;p===0&&(p=1),a(p)}},getSize:()=>{const{group:l}=n(),c=s(),{element:u}=i(),d=l.orientation==="horizontal"?u.offsetWidth:u.offsetHeight;return{asPercentage:c,inPixels:d}},isCollapsed:()=>{const{collapsible:l,collapsedSize:c}=r(),u=s();return l&&wn(c,u)},resize:l=>{const{group:c}=n(),{element:u}=i(),d=el({group:c}),f=ic({groupSize:d,panelElement:u,styleProp:l}),p=Mn(f/d*100);a(p)}}}function zS(e){if(e.defaultPrevented)return;const t=Uo();Ry(e,t).forEach(n=>{if(n.separator&&!n.separator.disableDoubleClick){const r=n.panels.find(i=>i.panelConstraints.defaultSize!==void 0);if(r){const i=r.panelConstraints.defaultSize,s=s5({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function oh(e){const t=Uo();for(const[n]of t)if(n.separators.some(r=>r.element===e))return n;throw Error("Could not find parent Group for separator element")}function o5({groupId:e}){const t=()=>{const n=Uo();for(const[r,i]of n)if(r.id===e)return{group:r,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:r}=t();return n?{}:r},setLayout(n){const{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:s,groupSize:o,layout:a,separatorToPanels:l}=t(),c=Ro({layout:n,panelConstraints:i});return r?a:(Po(a,c)||Gi(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:o,layout:c,separatorToPanels:l}),c)}}}function eo(e,t){const n=oh(e),r=As(n.id,!0),i=n.separators.find(u=>u.element===e);st(i,"Matching separator not found");const s=r.separatorToPanels.get(i);st(s,"Matching panels not found");const o=s.map(u=>n.panels.indexOf(u)),a=o5({groupId:n.id}).getLayout(),l=lu({delta:t,initialLayout:a,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),c=Ro({layout:l,panelConstraints:r.derivedPanelConstraints});Po(a,c)||Gi(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function $S(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=oh(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&eo(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&eo(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&eo(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&eo(t,-5);break}case"End":{e.preventDefault(),eo(t,100);break}case"Enter":{e.preventDefault();const r=oh(t),i=As(r.id,!0),{derivedPanelConstraints:s,layout:o,separatorToPanels:a}=i,l=r.separators.find(f=>f.element===t);st(l,"Matching separator not found");const c=a.get(l);st(c,"Matching panels not found");const u=c[0],d=s.find(f=>f.panelId===u.id);if(st(d,"Panel metadata not found"),d.collapsible){const f=o[u.id],p=d.collapsedSize===f?r.mutableState.expandedPanelSizes[u.id]??d.minSize:d.collapsedSize;eo(t,p-f)}break}case"F6":{e.preventDefault();const r=oh(t).separators.map(o=>o.element),i=Array.from(r).findIndex(o=>o===e.currentTarget);st(i!==null,"Index not found");const s=e.shiftKey?i>0?i-1:r.length-1:i+1<r.length?i+1:0;r[s].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),eo(t,-100);break}}}function FS(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=Uo(),n=Ry(e,t),r=new Map;let i=!1;n.forEach(s=>{s.separator&&(i||(i=!0,s.separator.element.focus({focusVisible:!1,preventScroll:!0})));const o=t.get(s.group);o&&r.set(s.group,o.layout)}),Ba({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function a5({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:s,prevCursorFlags:o}){let a=0;n.forEach(c=>{const{group:u,groupSize:d}=c,{orientation:f,panels:p}=u,{disableCursor:m}=u.mutableState;let v=0;s?f==="horizontal"?v=(t.clientX-s.x)/d*100:v=(t.clientY-s.y)/d*100:f==="horizontal"?v=t.clientX<0?-100:100:v=t.clientY<0?-100:100;const w=r.get(u),x=i.get(u);if(!w||!x)return;const{defaultLayoutDeferred:_,derivedPanelConstraints:y,groupSize:S,layout:C,separatorToPanels:k}=x;if(y&&C&&k){const N=lu({delta:v,initialLayout:w,panelConstraints:y,pivotIndices:c.panels.map(T=>p.indexOf(T)),prevLayout:C,trigger:"mouse-or-touch"});if(Po(N,C)){if(v!==0&&!m)switch(f){case"horizontal":{a|=v<0?ZR:JR;break}case"vertical":{a|=v<0?e5:t5;break}}}else Gi(c.group,{defaultLayoutDeferred:_,derivedPanelConstraints:y,groupSize:S,layout:N,separatorToPanels:k})}});let l=0;t.movementX===0?l|=o&PS:l|=a&PS,t.movementY===0?l|=o&RS:l|=a&RS,iV(l),Iy(e)}function HS(e){const t=Uo(),n=Io();switch(n.state){case"active":a5({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function US(e){var r,i;if(e.defaultPrevented)return;const t=Io(),n=Uo();switch(t.state){case"active":{if(e.buttons===0){Ba({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const o=As(s.group.id,!0);Gi(s.group,o,{isUserInteraction:!0})});return}for(const s of t.hitRegions)if(s.separator){const{element:o}=s.separator;(r=o.hasPointerCapture)!=null&&r.call(o,e.pointerId)||((i=o.setPointerCapture)==null||i.call(o,e.pointerId))}a5({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=Ry(e,n);s.length===0?t.state!=="inactive"&&Ba({cursorFlags:0,state:"inactive"}):Ba({cursorFlags:0,hitRegions:s,state:"hover"}),Iy(e.currentTarget);break}}}function WS(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Io().state){case"hover":Ba({cursorFlags:0,state:"inactive"})}}function VS(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||r5(e.currentTarget)&&e.preventDefault()}function qS(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const o=Mn(s.defaultSize);n+=o,r[s.panelId]=o}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=Mn((100-n)/i);for(const o of e)o.defaultSize===void 0&&(r[o.panelId]=s)}return r}function vV(e,t,n){if(!n[0])return;const r=e.panels.find(l=>l.element===t);if(!r||!r.onResize)return;const i=el({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,a={asPercentage:Mn(s/i*100),inPixels:s};r.mutableValues.prevSize=a,r.onResize(a,r.id,o)}function xV(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function _V({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,s=0,o=!1;const a=new Map,l=[];for(const d of e.panels){const f=r[d.id]??0;switch(d.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{o=!0;const p=f/100*n,m=Mn(p/t*100);a.set(d.id,m),i+=m;break}case"preserve-relative-size":default:{l.push(d.id),s+=f;break}}}if(!o||l.length===0)return r;const c=100-i,u={...r};if(a.forEach((d,f)=>{u[f]=d}),s>0)for(const d of l){const f=r[d]??0;u[d]=Mn(f/s*c)}else{const d=Mn(c/l.length);for(const f of l)u[f]=d}return u}function yV(e,t){const n=e.map(i=>i.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n)if(!r.includes(i))return!1;return!0}const sa=new Map;function bV(e){let t=!0;st(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,s=new n(m=>{for(const v of m){const{borderBoxSize:w,target:x}=v;if(x===e.element){if(t){const _=el({group:e});if(_===0)return;const y=As(e.id);if(!y)return;const S=I0(e),C=y.defaultLayoutDeferred?qS(S):y.layout,k=_V({group:e,nextGroupSize:_,prevGroupSize:y.groupSize,prevLayout:C}),N=Ro({layout:k,panelConstraints:S});if(!y.defaultLayoutDeferred&&Po(y.layout,N)&&xV(y.derivedPanelConstraints,S)&&y.groupSize===_)return;Gi(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:S,groupSize:_,layout:N,separatorToPanels:y.separatorToPanels})}}else vV(e,x,w)}});s.observe(e.element),e.panels.forEach(m=>{st(!r.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),r.add(m.id),m.onResize&&s.observe(m.element)});const o=el({group:e}),a=I0(e),l=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(yV(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[l]??c??qS(a),d=Ro({layout:u,panelConstraints:a}),f=e.element.ownerDocument;sa.set(f,(sa.get(f)??0)+1);const p=new Map;return XR(e).forEach(m=>{m.separator&&p.set(m.separator,m.panels)}),Gi(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:a,groupSize:o,layout:d,separatorToPanels:p}),e.separators.forEach(m=>{st(!i.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),i.add(m.id),m.element.addEventListener("keydown",$S)}),sa.get(f)===1&&(f.addEventListener("contextmenu",LS,!0),f.addEventListener("dblclick",zS,!0),f.addEventListener("pointerdown",FS,!0),f.addEventListener("pointerleave",HS),f.addEventListener("pointermove",US),f.addEventListener("pointerout",WS),f.addEventListener("pointerup",VS,!0)),function(){t=!1,sa.set(f,Math.max(0,(sa.get(f)??0)-1)),aV(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",$S)}),sa.get(f)||(f.removeEventListener("contextmenu",LS,!0),f.removeEventListener("dblclick",zS,!0),f.removeEventListener("pointerdown",FS,!0),f.removeEventListener("pointerleave",HS),f.removeEventListener("pointermove",US),f.removeEventListener("pointerout",WS),f.removeEventListener("pointerup",VS,!0)),s.disconnect()}}function wV(){const[e,t]=g.useState({}),n=g.useCallback(()=>t({}),[]);return[e,n]}function My(e){const t=g.useId();return`${e??t}`}const Wo=typeof window<"u"?g.useLayoutEffect:g.useEffect;function kc(e){const t=g.useRef(e);return Wo(()=>{t.current=e},[e]),g.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function Ay(...e){return kc(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function jy(e){const t=g.useRef({...e});return Wo(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const l5=g.createContext(null);function SV(e,t){const n=g.useRef({getLayout:()=>({}),setLayout:sV});g.useImperativeHandle(t,()=>n.current,[]),Wo(()=>{Object.assign(n.current,o5({groupId:e}))})}function Ly({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:s,groupRef:o,id:a,onLayoutChange:l,onLayoutChanged:c,orientation:u="horizontal",resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){const m=g.useRef({onLayoutChange:{},onLayoutChanged:{}}),v=kc(D=>{Po(m.current.onLayoutChange,D)||(m.current.onLayoutChange=D,l==null||l(D))}),w=kc((D,R)=>{Po(m.current.onLayoutChanged,D)||(m.current.onLayoutChanged=D,c==null||c(D,{isUserInteraction:R}))}),x=My(a),_=g.useRef(null),[y,S]=wV(),C=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),k=Ay(_,s);SV(x,o);const N=kc((D,R)=>{const A=Io(),M=jS(D),L=As(D);if(L){let $=!1;switch(A.state){case"active":{$=A.hitRegions.some(F=>F.group===M);break}}return{flexGrow:L.layout[R]??1,pointerEvents:$?"none":void 0}}if(n!=null&&n[R])return{flexGrow:n==null?void 0:n[R]}}),T=jy({defaultLayout:n,disableCursor:r}),O=g.useMemo(()=>({get disableCursor(){return!!T.disableCursor},getPanelStyles:N,id:x,orientation:u,registerPanel:D=>{const R=C.current;return R.panels=P0(u,[...R.panels,D]),S(),()=>{R.panels=R.panels.filter(A=>A!==D),S()}},registerSeparator:D=>{const R=C.current;return R.separators=P0(u,[...R.separators,D]),S(),()=>{R.separators=R.separators.filter(A=>A!==D),S()}},updatePanelProps:(D,{disabled:R})=>{const A=C.current.panels.find($=>$.id===D);A&&(A.panelConstraints.disabled=R);const M=jS(x),L=As(x);M&&L&&Gi(M,{...L,derivedPanelConstraints:I0(M)})},updateSeparatorProps:(D,{disabled:R,disableDoubleClick:A})=>{const M=C.current.separators.find(L=>L.id===D);M&&(M.disabled=R,M.disableDoubleClick=A)}}),[N,x,S,u,T]),P=g.useRef(null);return Wo(()=>{const D=_.current;if(D===null)return;const R=C.current;let A;if(T.defaultLayout!==void 0&&Object.keys(T.defaultLayout).length===R.panels.length){A={};for(const E of R.panels){const H=T.defaultLayout[E.id];H!==void 0&&(A[E.id]=H)}}const M={disabled:!!i,element:D,id:x,mutableState:{defaultLayout:A,disableCursor:!!T.disableCursor,expandedPanelSizes:C.current.lastExpandedPanelSizes,layouts:C.current.layouts},orientation:u,panels:R.panels,resizeTargetMinimumSize:R.resizeTargetMinimumSize,separators:R.separators};P.current=M;const L=bV(M),{defaultLayoutDeferred:$,derivedPanelConstraints:F,layout:B}=As(M.id,!0);!$&&F.length>0&&(v(B),w(B,!1));const z=Py(x,E=>{const{defaultLayoutDeferred:H,derivedPanelConstraints:q,layout:j}=E.next;if(H||q.length===0)return;const ne=M.panels.map(({id:K})=>K).join(",");M.mutableState.layouts[ne]=j,q.forEach(K=>{if(K.collapsible){const{layout:ge}=E.prev??{};if(ge){const Pe=wn(K.collapsedSize,j[K.panelId]),he=wn(K.collapsedSize,ge[K.panelId]);Pe&&!he&&(M.mutableState.expandedPanelSizes[K.panelId]=ge[K.panelId])}}});const ie=Io().state!=="active";v(j),ie&&w(j,E.isUserInteraction)});return()=>{P.current=null,L(),z()}},[i,x,w,v,u,y,T]),g.useEffect(()=>{const D=P.current;D&&(D.mutableState.defaultLayout=n,D.mutableState.disableCursor=!!r)}),h.jsx(l5.Provider,{value:O,children:h.jsx("div",{...p,className:t,"data-group":!0,"data-testid":x,id:x,ref:k,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:u==="horizontal"?"pan-y":"pan-x"},children:e})})}Ly.displayName="Group";function Dy(){const e=g.useContext(l5);return st(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function kV(e,t){const{id:n}=Dy(),r=g.useRef({collapse:qm,expand:qm,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:qm});g.useImperativeHandle(t,()=>r.current,[]),Wo(()=>{Object.assign(r.current,s5({groupId:n,panelId:e}))})}function uf({children:e,className:t,collapsedSize:n="0%",collapsible:r=!1,defaultSize:i,disabled:s,elementRef:o,groupResizeBehavior:a="preserve-relative-size",id:l,maxSize:c="100%",minSize:u="0%",onResize:d,panelRef:f,style:p,...m}){const v=!!l,w=My(l),x=jy({disabled:s}),_=g.useRef(null),y=Ay(_,o),{getPanelStyles:S,id:C,orientation:k,registerPanel:N,updatePanelProps:T}=Dy(),O=d!==null,P=kc((M,L,$)=>{d==null||d(M,l,$)});Wo(()=>{const M=_.current;if(M!==null){const L={element:M,id:w,idIsStable:v,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:O?P:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:r,defaultSize:i,disabled:x.disabled,maxSize:c,minSize:u}};return N(L)}},[a,n,r,i,O,w,v,c,u,P,N,x]),g.useEffect(()=>{T(w,{disabled:s})},[s,w,T]),kV(w,f);const D=()=>{const M=S(C,w);if(M)return JSON.stringify(M)},R=g.useSyncExternalStore(M=>Py(C,M),D,D);let A;return R?A=JSON.parse(R):i!==void 0?A={flexGrow:void 0,flexShrink:void 0,flexBasis:i}:A={flexGrow:1},h.jsx("div",{...m,"data-disabled":s||void 0,"data-panel":!0,"data-testid":w,id:w,ref:y,style:{...CV,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...A},children:h.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...p,touchAction:k==="horizontal"?"pan-y":"pan-x"},children:e})})}uf.displayName="Panel";const CV={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function EV({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,s;const o=e[n],a=t.find(l=>l.panelId===n);if(a){const l=a.maxSize,c=a.collapsible?a.collapsedSize:a.minSize,u=[r,r+1];s=Ro({layout:lu({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=Ro({layout:lu({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:o}}function c5({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:s,style:o,...a}){const l=My(s),c=jy({disabled:n,disableDoubleClick:r}),[u,d]=g.useState({}),[f,p]=g.useState("inactive"),[m,v]=g.useState(!1),w=g.useRef(null),x=Ay(w,i),{disableCursor:_,id:y,orientation:S,registerSeparator:C,updateSeparatorProps:k}=Dy(),N=S==="horizontal"?"vertical":"horizontal";Wo(()=>{const P=w.current;if(P!==null){const D={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:P,id:l},R=C(D),A=rV(L=>{p(L.next.state!=="inactive"&&L.next.hitRegions.some($=>$.separator===D)?L.next.state:"inactive")}),M=Py(y,L=>{const{derivedPanelConstraints:$,layout:F,separatorToPanels:B}=L.next,z=B.get(D);if(z){const E=z[0],H=z.indexOf(E);d(EV({layout:F,panelConstraints:$,panelId:E.id,panelIndex:H}))}});return()=>{A(),M(),R()}}},[y,l,C,c]),g.useEffect(()=>{k(l,{disabled:n,disableDoubleClick:r})},[n,r,l,k]);let T;n&&!_&&(T="not-allowed");let O;if(n)O="disabled";else switch(f){case"active":{O="active";break}default:m?O="focus":O=f}return h.jsx("div",{...a,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":N,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":O,"data-testid":l,id:l,onBlur:()=>v(!1),onFocus:()=>v(!0),ref:x,role:"separator",style:{flexBasis:"auto",cursor:T,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}c5.displayName="Separator";function u5(e,t){const n=zo(),r=e?`session/${e}`:"",i=pi(r)??eu,s=g.useCallback(d=>{!e||!r||n.setData(r,f=>dI(f??eu,d,e))},[n,r,e]),o=g.useCallback(()=>{e&&s({type:"session:change",sessionId:e})},[s,e]),a=g.useCallback(d=>{e&&s({type:"permission:clear",sessionId:e,requestId:d})},[s,e]),l=g.useCallback(d=>{e&&s({type:"permission:request",sessionId:e,requestId:d.requestId,tool:d.tool,input:d.input,...d.toolUseId?{toolUseId:d.toolUseId}:{}})},[s,e]),c=g.useCallback(d=>{e&&s({type:"session:question:clear",sessionId:e,toolUseId:d})},[s,e]),u=g.useCallback((d,f)=>{e&&s({type:"session:question:submitted",sessionId:e,toolUseId:d,answers:f})},[s,e]);return{...i,reset:o,clearPermission:a,restorePermission:l,clearQuestion:c,markQuestionSubmitted:u}}function NV(e){return e.kind!=="user-text"?!1:e.meta===void 0||e.meta==="slash-command"||op(e.meta)}function TV(e,t={}){let n=0;if(t.implicitCloseOnUserText){for(const r of e)NV(r)&&n++;return n}for(const r of e)r.kind==="turn-end"&&n++;return n}const IV=50;function PV({api:e,sessionId:t,toolSessionId:n,initialTurns:r,implicitCloseOnUserText:i,pageSize:s=IV}){const[o,a]=g.useState({messages:[],total:0,loading:!1,error:null}),l=g.useRef(n),c=g.useRef(null),u=g.useRef(0),d=g.useRef(!0);return g.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),g.useEffect(()=>{const f=l.current;if(l.current=n,!(c.current!==t)&&!(typeof f=="string"&&f!==n))return;if(a({messages:[],total:0,loading:!1,error:null}),!t){c.current=null;return}c.current=t;const v=++u.current;a(w=>({...w,loading:!0,error:null})),(async()=>{let w=[],x=!1,_=r===void 0?{}:{limit:s},y=Number.POSITIVE_INFINITY;for(;;){let S;try{S=await e.historyRead({sessionId:t,..._})}catch(D){if(v!==u.current||!d.current)return;const R=D.message??"history load failed";a(x?A=>({...A,error:R}):{messages:[],total:0,loading:!1,error:R});return}if(v!==u.current||!d.current)return;w=[...S.messages??[],...w];const C=S.total??0,k=typeof S.offset=="number"?S.offset:0,N=k>=y,T=k<=0||N;y=k;const O=r!==void 0&&TV(w,{implicitCloseOnUserText:i})>=r;if(x?a({messages:w,total:C,loading:!1,error:null}):(T||O)&&(x=!0,a({messages:w,total:C,loading:!1,error:null})),T)return;const P=Math.max(0,k-s);_={offset:P,limit:k-P}}})()},[e,t,n,s,r]),o}const RV=["TaskCreate","TaskUpdate","TaskList","TaskGet"];function MV(e){return RV.includes(e)}function d5(e){return e==="in_progress"||e==="completed"?e:"pending"}function AV(e,t){if(!t||typeof t!="object")return e;const n=t,r=typeof n.subject=="string"&&n.subject?n.subject:typeof n.content=="string"&&n.content?n.content:null;if(!r)return e;const i=typeof n.activeForm=="string"?n.activeForm:void 0,s=typeof n.description=="string"?n.description:void 0;return[...e,{id:String(e.length+1),content:r,status:d5(n.status),activeForm:i,description:s}]}function jV(e,t){if(!t||typeof t!="object")return e;const n=t,r=typeof n.taskId=="string"&&n.taskId?n.taskId:typeof n.id=="string"&&n.id?n.id:null;if(!r)return e;const i=e.findIndex(a=>a.id===r);if(i<0)return e;const s=[...e],o={...s[i]};return"status"in n&&(o.status=d5(n.status)),typeof n.subject=="string"&&(o.content=n.subject),typeof n.content=="string"&&(o.content=n.content),typeof n.activeForm=="string"&&(o.activeForm=n.activeForm),typeof n.description=="string"&&(o.description=n.description),s[i]=o,s}function LV(e){let t=[],n=-1;for(let r=0;r<e.length;r++){const i=e[r];if(i.kind==="task-event")switch(n=r,i.name){case"TaskCreate":t=AV(t,i.input);break;case"TaskUpdate":t=jV(t,i.input);break}}return{tasks:t,lastEventIndex:n}}function DV(e){return e==="TodoWrite"}function OV(e){if(!e||typeof e!="object")return null;const t=e;if(!Array.isArray(t.todos))return null;const n=[];for(const r of t.todos){if(!r||typeof r!="object")continue;const i=r,s=typeof i.content=="string"?i.content:"";if(!s)continue;const o=i.status==="in_progress"||i.status==="completed"?i.status:"pending",a=typeof i.activeForm=="string"?i.activeForm:void 0;n.push({content:s,status:o,activeForm:a})}return n}function BV(e,t,n){var s;const r=[],i=new Map;for(let o=0;o<e.length;o++){const a=e[o],l=typeof a.seq=="number"?a.seq:o;switch(a.kind){case"session_init":r.push({kind:"session-init",seq:l,toolSessionId:a.toolSessionId});break;case"text":KS(r,l,"assistant-text",a.text,a.partialId,a.uuid);break;case"thinking":KS(r,l,"assistant-thinking",a.text,a.partialId);break;case"user_text":{a.meta==="task-notification"?r.push({kind:"agent-notification",seq:l,text:a.text,taskId:a.taskId,parentToolUseId:a.parentToolUseId}):a.meta?r.push({kind:"user-meta",seq:l,metaKind:a.meta,text:a.text}):r.push({kind:"user-text",seq:l,text:a.text,uuid:a.uuid,...a.sender&&(a.sender.principal!=="owner"||iI.test(a.text))?{senderDisplayName:a.sender.displayName}:{},senderPrincipal:((s=a.sender)==null?void 0:s.principal)==="guest"?"guest":"owner"});break}case"tool_call":h5(r,l,a.toolUseId,a.tool,a.input,a.toolKind);break;case"tool_result":{const c=i.get(a.toolUseId);if(c!==void 0){if(a.askQuestionAnswers){const d=r[c];d.submittedAnswers=a.askQuestionAnswers}i.delete(a.toolUseId);break}const u={kind:"tool-result",seq:l,toolUseId:a.toolUseId,output:a.output,error:a.error};a.toolResultExtra&&(u.toolResultExtra=a.toolResultExtra),r.push(u);break}case"attachment_memories":r.push({kind:"memory-callout",seq:l,memories:a.memories});break;case"permission_request":{if(!t||a.requestId!==t)break;r.push({kind:"permission-inline",seq:l,requestId:a.requestId,tool:a.tool,input:a.input});break}case"ask_user_question":i.set(a.toolUseId,r.length),r.push({kind:"question-card",seq:l,toolUseId:a.toolUseId,questions:a.questions});break;case"turn_end":{const c={kind:"turn-end",seq:l};a.durationMs!==void 0&&(c.durationMs=a.durationMs),a.reason!==void 0&&(c.reason=a.reason),r.push(c);break}case"subagent_progress":{const c={kind:"agent-progress",seq:l,toolUseId:a.toolUseId,agentId:a.agentId,status:a.status};a.description&&(c.description=a.description),a.lastToolName&&(c.lastToolName=a.lastToolName),a.prompt&&(c.prompt=a.prompt),a.stats&&(c.stats=a.stats),r.push(c);break}case"error":r.push({kind:"error",seq:l,message:a.message});break}}return r}function h5(e,t,n,r,i,s){if(DV(r)){const o=OV(i);if(o){e.push({kind:"todo-checklist",seq:t,toolUseId:n,todos:o});return}}if(r==="Agent"){const o=i??{},a=typeof o.description=="string"&&o.description?o.description:typeof o.subagent_type=="string"&&o.subagent_type?o.subagent_type:"Subagent";e.push({kind:"agent-call",seq:t,toolUseId:n,description:a,input:i});return}if(MV(r)){e.push({kind:"task-event",seq:t,toolUseId:n,name:r,input:i});return}e.push({kind:"tool-call",seq:t,toolUseId:n,tool:r,toolKind:s,input:i})}function KS(e,t,n,r,i,s){let o=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind===n){o=c;break}const a=o>=0?e[o]:null;if(i){if(a&&a.partialId===i){const u=n==="assistant-text"?{kind:n,seq:a.seq,text:a.text+r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:a.text+r,partialId:i};e[o]=u;return}const c=n==="assistant-text"?{kind:n,seq:t,text:r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r,partialId:i};e.push(c);return}if(a&&a.partialId){const c=n==="assistant-text"?{kind:n,seq:a.seq,text:r,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:r};e[o]=c;return}const l=n==="assistant-text"?{kind:n,seq:t,text:r,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r};e.push(l)}const zV="AskUserQuestion";function f5(e,t=0,n){var o;const r=[],i=new Map;let s=t;for(const a of e){const l=s++,c=a.toolUseId??`hist-${l}`;switch(a.kind){case"user-text":if(a.meta==="task-notification")r.push({kind:"agent-notification",seq:l,text:a.text??"",taskId:a.taskId,parentToolUseId:a.parentToolUseId});else if(a.meta)r.push({kind:"user-meta",seq:l,metaKind:a.meta,text:a.text??""});else{const u=iI.exec(a.text??""),d=(o=sz.exec(a.text??""))==null?void 0:o[1],f=(u==null?void 0:u[2])??d,p=(u==null?void 0:u[1])==="guest"||d?"guest":"owner";r.push({kind:"user-text",seq:l,text:a.text??"",uuid:a.uuid,...f?{senderDisplayName:f}:{},senderPrincipal:p})}break;case"assistant-text":r.push({kind:"assistant-text",seq:l,text:a.text??"",uuid:a.uuid});break;case"tool_call":{if(a.tool===zV){const u=a.input??{},d=Array.isArray(u.questions)?u.questions:[];i.set(c,r.length),r.push({kind:"question-card",seq:l,toolUseId:c,questions:d});break}h5(r,l,c,a.tool??"",a.input,n);break}case"tool_result":{const u=i.get(c);if(u!==void 0){if(a.askQuestionAnswers){const f=r[u];f.submittedAnswers=a.askQuestionAnswers}i.delete(c);break}const d={kind:"tool-result",seq:l,toolUseId:c,output:a.output};a.error!==void 0&&(d.error=a.error),a.toolResultExtra&&(d.toolResultExtra=a.toolResultExtra),r.push(d);break}case"attachment_memories":a.memories&&a.memories.length>0&&r.push({kind:"memory-callout",seq:l,memories:a.memories});break;case"summary":break;case"turn-end":{const u={kind:"turn-end",seq:l};typeof a.durationMs=="number"&&(u.durationMs=a.durationMs),r.push(u);break}}}return r}const $V=5e5;function FV(e){const t=$V-e.length;return e.map(n=>({...n,seq:n.seq+t}))}const HV=/<command-name>([\s\S]*?)<\/command-name>/i,UV=/<command-message>([\s\S]*?)<\/command-message>/i,WV=/<command-args>([\s\S]*?)<\/command-args>/i,VV=/<(local-command-[a-z]+|command-(?:stdout|stderr))>[\s\S]*?<\/\1>/gi;function Tp(e){if(!e)return{commandName:null,commandMessage:null,commandArgs:null,body:""};const t=e.match(HV),n=e.match(UV),r=e.match(WV);let i=e;return t&&(i=i.replace(t[0],"")),n&&(i=i.replace(n[0],"")),r&&(i=i.replace(r[0],"")),i=i.replace(VV,""),i=i.trim(),{commandName:t?t[1].trim():null,commandMessage:n?n[1].trim():null,commandArgs:r?r[1].trim():null,body:i}}function GS(e){const t=Tp(e);return t.commandName?t.commandArgs?`${t.commandName} ${t.commandArgs}`:t.commandName:e}function YS(e){return e.kind==="user-text"?!0:e.kind!=="user-meta"?!1:e.metaKind==="slash-command"||op(e.metaKind)}function qV(e,t){const n=t.find(YS);if(!n)return e;const r=GS(n.text);for(let s=e.length-1;s>=0;s--){const o=e[s];if(YS(o)&&GS(o.text)===r)return e.slice(0,s)}const i=e[e.length-1];return i!==void 0&&i.kind!=="turn-end"?[...e,{kind:"turn-end",seq:i.seq+1}]:e}function KV(e){return e==="running"||e==="observing"}function p5(e){return e==="running"||e==="running-idle"||e==="observing"}const GV=1e6,YV=5;function XV(e){if(!e)return;const t=e.contextUsage,n=e.contextWindowSize;if(!t||!n||n<=0)return;const r=t.inputTokens+(t.cacheReadTokens??0)+(t.cacheCreateTokens??0);if(!(r<=0))return Math.round(r/n*100)}function m5(e){const t=_i(),n=g.useMemo(()=>new Y_(t),[t]),r=pi("sessions"),i=g.useMemo(()=>r==null?void 0:r.find(E=>E.sessionId===e),[r,e]),s=i==null?void 0:i.toolSessionId,o=i==null?void 0:i.tool,a=u5(e),{events:l,pendingPermissions:c,queued:u,status:d,clearPermission:f,restorePermission:p}=a,m=jz(),v=PV({api:n,sessionId:e,toolSessionId:s,initialTurns:m==="owner"?void 0:YV,implicitCloseOnUserText:o==="codex"}),w=g.useMemo(()=>v.messages.filter(E=>!E.isSidechain),[v.messages]),x=g.useMemo(()=>FV(f5(w,0,o)),[w,o]),_=c[0]??null,y=g.useMemo(()=>BV(l,(_==null?void 0:_.requestId)??null),[l,_==null?void 0:_.requestId]),S=g.useMemo(()=>qV(x,y),[x,y]),C=g.useMemo(()=>y.map((E,H)=>({...E,seq:GV+H})),[y]),k=g.useMemo(()=>[...S,...C],[S,C]),N=p5(d),T=KV(d),O=(i==null?void 0:i.resolvedModel)??(i==null?void 0:i.model),P=g.useMemo(()=>({sessionLabel:(i==null?void 0:i.label)||(i==null?void 0:i.aiLabel)||(i==null?void 0:i.larkChatName)||(i==null?void 0:i.larkChatId)||e,sessionId:e,...i!=null&&i.larkChatId?{larkChatName:i.larkChatName??i.larkChatId,larkChatType:i.larkChatType??"group"}:{},...O?{model:O}:{},...(()=>{const E=i==null?void 0:i.gitBranch;return E?{gitBranch:E}:{}})(),...(()=>{const E=XV(i);return E!==void 0?{contextPct:E}:{}})(),...i!=null&&i.cwd?{cwd:i.cwd}:{},...(()=>{const E=i==null?void 0:i.permissionMode;return E?{permissionMode:E}:{}})(),procAlive:N,streamInProgress:T,pinnedAt:(i==null?void 0:i.pinnedAt)??null}),[i,e,O,N,T]),D=g.useMemo(()=>t.isOpen?d==="error"?{kind:"error",message:"session error"}:{kind:"ready"}:{kind:"closed"},[t.isOpen,d]),R=g.useCallback(async(E,H)=>{await n.sessionSend(e,E,H)},[n,e]),A=g.useCallback(async E=>{await n.sessionDequeue(e,E)},[n,e]),M=g.useCallback(async()=>(await n.sessionInterrupt(e)).queued??[],[n,e]),L=g.useCallback(async E=>{if(!(i!=null&&i.cwd)||!s)throw new Error("fork requires sessionFile with cwd + toolSessionId");await n.sessionFork({cwd:i.cwd,toolSessionId:s,messageUuid:E})},[n,i==null?void 0:i.cwd,s]),$=g.useCallback(async E=>{await n.sessionRewind({sessionId:e,userMessageId:E,dryRun:!1})},[n,e]),F=g.useCallback(async E=>{await n.sessionUpdate(e,{model:E})},[n,e]),B=g.useCallback(async()=>{await n.sessionNew(e)},[n,e]),z=g.useCallback(async(E,H)=>{const q=c.find(j=>j.requestId===E);q&&f(E);try{await n.permissionRespond({sessionId:e,permissionRequestId:E,allow:H==="allow"})}catch(j){throw!((j==null?void 0:j.message)??"").startsWith("PERMISSION_REQUEST_STALE")&&q&&p(q),j}},[n,e,c,f,p]);return g.useMemo(()=>({lines:k,connState:D,meta:P,historyLoading:v.loading,historyError:v.error,pendingPermissions:c,queued:u,sendText:R,dequeue:A,interrupt:M,fork:L,rewind:$,switchModel:F,clearSession:B,respondPermission:z}),[k,D,P,v.loading,v.error,c,u,R,A,M,L,$,F,B,z])}function QV(e,t,n,r=!0){const i=g.useRef({sid:null,tsid:void 0});g.useEffect(()=>{const s=i.current;i.current={sid:t,tsid:n},!(!r||!n||s.sid===t&&(s.tsid===void 0||s.tsid===null)&&typeof n=="string")&&e.sessionObserve({sessionId:t,toolSessionId:n}).catch(()=>{})},[e,t,n,r])}function ZV(e,t,n){const r=g.useRef(e),i=g.useRef(t),s=g.useRef(n);s.current=n,g.useEffect(()=>{const o=r.current,a=i.current;r.current=e,i.current=t;const l=o!==e,c=typeof a=="string"&&t==null;!l&&!c||s.current()},[e,t])}const JV=/^Scheduled (?:recurring job|one-shot task) ([0-9a-f]{8}) \(([^)]+)\)/;function eq(e){const t=new Map,n=new Map,r=new Map;for(const i of e)if(i.kind==="tool_call"&&i.tool==="CronCreate"){const s=i.input;if(!s||typeof s.cron!="string"||typeof s.prompt!="string")continue;const o=i.ts;t.set(i.toolUseId,{cron:s.cron,prompt:s.prompt,recurring:s.recurring!==!1,ts:typeof o=="string"?o:"",toolUseId:i.toolUseId})}else if(i.kind==="tool_call"&&i.tool==="CronDelete"){const s=i.input;if(!s||typeof s.id!="string")continue;n.set(i.toolUseId,s.id)}else if(i.kind==="tool_result"){const s=t.get(i.toolUseId);if(s){if(t.delete(i.toolUseId),i.error||typeof i.output!="string")continue;const a=i.output.match(JV);if(!a)continue;r.set(a[1],{id:a[1],cron:s.cron,prompt:s.prompt,recurring:s.recurring,humanSchedule:a[2],createdAt:s.ts,toolUseId:s.toolUseId});continue}const o=n.get(i.toolUseId);o!==void 0&&(n.delete(i.toolUseId),i.error||r.delete(o))}return Array.from(r.values()).sort((i,s)=>i.createdAt.localeCompare(s.createdAt))}function g5(e){var n;if(e.error)return!1;if(e.pending)return!0;if(e.notifications.length>0)return!1;const t=(n=e.progress)==null?void 0:n.status;return t==="running"?!0:t==="started"?tq(e.input):!1}function tq(e){return!e||typeof e!="object"?!1:e.run_in_background===!0}function nq(e){return e.filter(t=>t.kind==="merged-agent"&&g5(t))}function v5(e){const{tasks:t,lastEventIndex:n}=LV(e);let r=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind==="todo-checklist"){r=c;break}const i=[],s=new Map,o=new Map,a=new Map,l=(c,u)=>{var f,p,m,v,w;if(((f=c.progress)==null?void 0:f.status)==="completed"||((p=c.progress)==null?void 0:p.status)==="failed")return;const d={agentId:u.agentId,status:u.status};u.description?d.description=u.description:(m=c.progress)!=null&&m.description&&(d.description=c.progress.description),u.lastToolName?d.lastToolName=u.lastToolName:(v=c.progress)!=null&&v.lastToolName&&(d.lastToolName=c.progress.lastToolName),u.stats?d.stats=u.stats:(w=c.progress)!=null&&w.stats&&(d.stats=c.progress.stats),c.progress=d,(u.status==="completed"||u.status==="failed")&&(c.pending=!1)};for(let c=0;c<e.length;c++){const u=e[c];switch(u.kind){case"tool-call":{const d={kind:"merged-tool",seq:u.seq,tool:u.tool,toolKind:u.toolKind,toolUseId:u.toolUseId,input:u.input,pending:!0};s.set(u.toolUseId,i.length),i.push(d);break}case"tool-result":{const d=s.get(u.toolUseId);if(d!==void 0){const p=i[d];p.output=u.output,p.error=u.error,p.pending=!1,s.delete(u.toolUseId);break}const f=o.get(u.toolUseId);if(f!==void 0){const p=i[f];p.output=u.output,p.error=u.error,p.pending=!1,u.toolResultExtra&&(p.toolResultExtra=u.toolResultExtra);break}break}case"agent-call":{const d={kind:"merged-agent",seq:u.seq,toolUseId:u.toolUseId,description:u.description,input:u.input,pending:!0,notifications:[]};o.set(u.toolUseId,i.length),i.push(d);const f=a.get(u.toolUseId);f&&(l(d,f),a.delete(u.toolUseId));break}case"agent-progress":{const d=o.get(u.toolUseId);if(d!==void 0){l(i[d],u);break}const f=a.get(u.toolUseId);if((f==null?void 0:f.status)==="completed"||(f==null?void 0:f.status)==="failed")break;a.set(u.toolUseId,u);break}case"agent-notification":{const d=u.parentToolUseId;if(d){const f=o.get(d);if(f!==void 0){i[f].notifications.push({text:u.text,taskId:u.taskId});break}}i.push({kind:"agent-notification",seq:u.seq,text:u.text,taskId:u.taskId,parentToolUseId:u.parentToolUseId});break}case"todo-checklist":{c===r&&u.todos.length>0&&i.push({kind:"todo-checklist",seq:u.seq,toolUseId:u.toolUseId,todos:u.todos});break}case"task-event":{c===n&&t.length>0&&i.push({kind:"plan-card",seq:u.seq,tasks:t});break}default:i.push(u)}}return i}const rq=new Set(["permission-inline","question-card"]);function iq(e){return e.kind==="user-text"?!0:e.kind!=="user-meta"?!1:e.metaKind==="slash-command"||op(e.metaKind)}function sq(e){return e.kind==="user-text"&&e.continuesTurn===!0}function oq(e,t={}){const n=[];let r=null;const i=(s,o)=>{r&&(n.push(aq(r,s,o)),r=null)};for(const s of e){if(s.kind==="turn-end"){i(s,!0);continue}if(iq(s)&&(r===null||!sq(s))){i(void 0,!0),r={query:s,body:[]};continue}r===null?r={body:[s]}:r.body.push(s)}return i(void 0,t.closeTrailing===!0),n}function aq(e,t,n){const{query:r,body:i}=e,s=lq(i,t,n),o=cq(i,s),a=dq(i,o),l=r??i[0]??t,c={kind:"turn",seq:l?l.seq:0,status:s,process:a,tail:o};return r&&(c.query=r),(t==null?void 0:t.durationMs)!==void 0&&(c.durationMs=t.durationMs),c}function lq(e,t,n){if(!n)return"running";if((t==null?void 0:t.reason)==="interrupted")return"interrupted";const r=R0(e,i=>i.kind==="error");return r>=0&&!e.slice(r+1).some(s=>s.kind==="assistant-text")?"error":"done"}function cq(e,t){if(t==="running"){const r=[];for(let i=e.length-1;i>=0&&rq.has(e[i].kind);i--)r.unshift(e[i]);return r}const n=t==="error"?R0(e,r=>r.kind==="error"):R0(e,r=>r.kind==="assistant-text");return n>=0?[e[n]]:[]}const uq=new Set(["assistant-thinking","user-meta"]);function dq(e,t){const n=new Set(t),r=[];let i=null;const s=()=>{i&&(r.push({kind:"tool-group",seq:i[0].seq,items:i}),i=null)};for(const o of e){if(n.has(o)){s();continue}if(o.kind==="merged-tool"){i?i.push(o):i=[o];continue}if(uq.has(o.kind)){r.push(o);continue}s(),r.push(o)}return s(),r}function R0(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}const hq={Read:["正在读取","已读取"],Bash:["正在运行","已运行"],Grep:["正在搜索","已搜索"],Glob:["正在搜索","已搜索"],Edit:["正在编辑","已编辑"],Write:["正在写入","已写入"],WebFetch:["正在抓取","已抓取"],WebSearch:["正在搜索","已搜索"],Skill:["正在读取","已读取"]};function fq(e){if(!e||typeof e!="object")return"";const t=e,n=t.command??t.file_path??t.path??t.pattern??t.query??t.url??t.description;if(typeof n=="string")return n;for(const r of Object.values(t))if(typeof r=="string"&&r)return r;return""}function x5(e){const t=hq[e.tool],n=t?e.pending?t[0]:t[1]:e.pending?`正在执行 ${e.tool}`:`已执行 ${e.tool}`,r=fq(e.input);return r?`${n} ${r}`:n}function pq({item:e,renderItemDetail:t}){const[n,r]=g.useState(!1),i=n?Yn:Bn,s=n?(t==null?void 0:t(e))??null:null;return h.jsxs("div",{className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>r(o=>!o),"aria-expanded":n,"data-testid":"tool-call-group-row",className:re("flex w-full items-center gap-1.5 text-left cursor-pointer min-w-0 py-0.5 text-[13px] hover:text-text-200",e.error?"text-destructive/80":"text-text-400"),children:[e.pending?h.jsx(Ln,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):h.jsx(i,{className:"w-3.5 h-3.5 shrink-0 opacity-60"}),h.jsx("span",{className:"truncate min-w-0",children:x5(e)})]}),n?h.jsx("div",{"data-testid":"tool-call-group-row-detail",className:"pl-5 py-1 min-w-0 space-y-1.5 text-[12px] text-text-300",children:s!==null?s:h.jsxs(h.Fragment,{children:[h.jsx("pre",{className:"min-w-0 max-w-full overflow-auto whitespace-pre-wrap font-mono",children:JSON.stringify(e.input,null,2)}),e.output!==void 0?h.jsx("pre",{className:"min-w-0 max-w-full overflow-auto whitespace-pre-wrap font-mono text-text-400",children:typeof e.output=="string"?e.output:JSON.stringify(e.output,null,2)}):null,e.error?h.jsx("pre",{className:"min-w-0 max-w-full overflow-auto whitespace-pre-wrap font-mono text-destructive",children:e.error}):null]})}):null]})}function mq({items:e,renderItemDetail:t}){const[n,r]=g.useState(!1);if(e.length===0)return null;const i=e.some(l=>l.pending),s=i?[...e].reverse().find(l=>l.pending):e[e.length-1],o=!i&&e.length>1?` 等 ${e.length} 项`:"",a=n?Yn:Bn;return h.jsxs("div",{"data-testid":"tool-call-group",className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>r(l=>!l),"aria-expanded":n,"data-testid":"tool-call-group-header",className:"flex w-full items-center gap-1.5 text-left cursor-pointer min-w-0 py-0.5 text-[13px] text-text-400 hover:text-text-200",children:[i&&!n?h.jsx(Ln,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):h.jsx(a,{className:"w-3.5 h-3.5 shrink-0"}),n?h.jsx("span",{className:"min-w-0 truncate opacity-70",children:i?"正在执行":`${e.length} 项`}):h.jsxs("span",{className:re("truncate min-w-0",i&&"text-text-300"),children:[x5(s),o]})]}),n?h.jsx("div",{className:"mt-0.5 flex flex-col pl-5",children:e.map(l=>h.jsx(pq,{item:l,renderItemDetail:t},l.toolUseId))}):null]})}function gq(e){const t=Math.round(e/1e3);if(t<60)return`${t}秒`;const n=Math.floor(t/60),r=t%60;return r>0?`${n}分${r}秒`:`${n}分钟`}function vq(e,t){const n=t!==void 0?`耗时 ${gq(t)}`:"";switch(e){case"interrupted":return n?`已中断 · ${n}`:"已中断";case"error":return n?`出错 · ${n}`:"出错";default:return n||"已完成"}}function xq({status:e="done",durationMs:t,defaultExpanded:n=!1,children:r}){const[i,s]=g.useState(n),o=i?Yn:Bn;return h.jsxs("div",{"data-testid":"turn-process-block",className:"min-w-0 max-w-full border-t border-border pt-2",children:[h.jsxs("button",{type:"button",onClick:()=>s(a=>!a),"aria-expanded":i,"data-testid":"turn-process-block-header",className:re("flex w-full items-center gap-1 text-left cursor-pointer min-w-0 py-0.5 text-[13px]",e!=="done"?"text-destructive/80 hover:text-destructive":"text-text-400 hover:text-text-200"),children:[h.jsx("span",{className:"truncate min-w-0",children:vq(e,t)}),h.jsx(o,{className:"w-3.5 h-3.5 shrink-0"})]}),i?h.jsx("div",{"data-testid":"turn-process-body",className:"mt-2 flex flex-col gap-2 border-l-2 border-border pl-3",children:r}):null]})}const _q=/<(system-reminder|related-dir|clawd-shift-fire)\b[^>]*>[\s\S]*?<\/\1>/gi,yq=/<builder-preview\b[^>]*\/>/gi,bq=/<(clawd-dispatch-task|clawd-dispatch-result)\b[^>]*>([\s\S]*?)<\/\1>/gi,wq=/<\/?(brief|detail|files)>/gi;function _5(e){return e?e.replace(bq,(t,n,r)=>fz(r.replace(wq,"")).trim()).replace(_q,"").replace(yq,"").trim():""}const Sq=_5;function kq(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Cq=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Eq=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Nq={};function XS(e,t){return(Nq.jsx?Eq:Cq).test(e)}const Tq=/[ \t\n\f\r]/g;function Iq(e){return typeof e=="object"?e.type==="text"?QS(e.value):!1:QS(e)}function QS(e){return e.replace(Tq,"")===""}class Au{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Au.prototype.normal={};Au.prototype.property={};Au.prototype.space=void 0;function y5(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Au(n,r,t)}function M0(e){return e.toLowerCase()}class Xn{constructor(t,n){this.attribute=n,this.property=t}}Xn.prototype.attribute="";Xn.prototype.booleanish=!1;Xn.prototype.boolean=!1;Xn.prototype.commaOrSpaceSeparated=!1;Xn.prototype.commaSeparated=!1;Xn.prototype.defined=!1;Xn.prototype.mustUseProperty=!1;Xn.prototype.number=!1;Xn.prototype.overloadedBoolean=!1;Xn.prototype.property="";Xn.prototype.spaceSeparated=!1;Xn.prototype.space=void 0;let Pq=0;const Le=Vo(),Bt=Vo(),A0=Vo(),Q=Vo(),dt=Vo(),za=Vo(),er=Vo();function Vo(){return 2**++Pq}const j0=Object.freeze(Object.defineProperty({__proto__:null,boolean:Le,booleanish:Bt,commaOrSpaceSeparated:er,commaSeparated:za,number:Q,overloadedBoolean:A0,spaceSeparated:dt},Symbol.toStringTag,{value:"Module"})),Km=Object.keys(j0);class Oy extends Xn{constructor(t,n,r,i){let s=-1;if(super(t,n),ZS(this,"space",i),typeof r=="number")for(;++s<Km.length;){const o=Km[s];ZS(this,Km[s],(r&j0[o])===j0[o])}}}Oy.prototype.defined=!0;function ZS(e,t,n){n&&(e[t]=n)}function Cl(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Oy(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[M0(r)]=r,n[M0(s.attribute)]=r}return new Au(t,n,e.space)}const b5=Cl({properties:{ariaActiveDescendant:null,ariaAtomic:Bt,ariaAutoComplete:null,ariaBusy:Bt,ariaChecked:Bt,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:dt,ariaCurrent:null,ariaDescribedBy:dt,ariaDetails:null,ariaDisabled:Bt,ariaDropEffect:dt,ariaErrorMessage:null,ariaExpanded:Bt,ariaFlowTo:dt,ariaGrabbed:Bt,ariaHasPopup:null,ariaHidden:Bt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:dt,ariaLevel:Q,ariaLive:null,ariaModal:Bt,ariaMultiLine:Bt,ariaMultiSelectable:Bt,ariaOrientation:null,ariaOwns:dt,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:Bt,ariaReadOnly:Bt,ariaRelevant:null,ariaRequired:Bt,ariaRoleDescription:dt,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:Bt,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function w5(e,t){return t in e?e[t]:t}function S5(e,t){return w5(e,t.toLowerCase())}const Rq=Cl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:za,acceptCharset:dt,accessKey:dt,action:null,allow:null,allowFullScreen:Le,allowPaymentRequest:Le,allowUserMedia:Le,alt:null,as:null,async:Le,autoCapitalize:null,autoComplete:dt,autoFocus:Le,autoPlay:Le,blocking:dt,capture:null,charSet:null,checked:Le,cite:null,className:dt,cols:Q,colSpan:null,content:null,contentEditable:Bt,controls:Le,controlsList:dt,coords:Q|za,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Le,defer:Le,dir:null,dirName:null,disabled:Le,download:A0,draggable:Bt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Le,formTarget:null,headers:dt,height:Q,hidden:A0,high:Q,href:null,hrefLang:null,htmlFor:dt,httpEquiv:dt,id:null,imageSizes:null,imageSrcSet:null,inert:Le,inputMode:null,integrity:null,is:null,isMap:Le,itemId:null,itemProp:dt,itemRef:dt,itemScope:Le,itemType:dt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Le,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:Le,muted:Le,name:null,nonce:null,noModule:Le,noValidate:Le,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:Le,optimum:Q,pattern:null,ping:dt,placeholder:null,playsInline:Le,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Le,referrerPolicy:null,rel:dt,required:Le,reversed:Le,rows:Q,rowSpan:Q,sandbox:dt,scope:null,scoped:Le,seamless:Le,selected:Le,shadowRootClonable:Le,shadowRootDelegatesFocus:Le,shadowRootMode:null,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:Bt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:Le,useMap:null,value:Bt,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:dt,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Le,declare:Le,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:Le,noHref:Le,noShade:Le,noWrap:Le,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:Bt,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Le,disableRemotePlayback:Le,prefix:null,property:null,results:Q,security:null,unselectable:null},space:"html",transform:S5}),Mq=Cl({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",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:er,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:dt,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:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:Le,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,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:za,g2:za,glyphName:za,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:er,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Q,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:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:dt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:er,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:er,rev:er,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:er,requiredFeatures:er,requiredFonts:er,requiredFormats:er,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:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:er,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:er,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:er,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:w5}),k5=Cl({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()}}),C5=Cl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:S5}),E5=Cl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Aq={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"},jq=/[A-Z]/g,JS=/-[a-z]/g,Lq=/^data[-\w.:]+$/i;function Dq(e,t){const n=M0(t);let r=t,i=Xn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Lq.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(JS,Bq);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!JS.test(s)){let o=s.replace(jq,Oq);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=Oy}return new i(r,t)}function Oq(e){return"-"+e.toLowerCase()}function Bq(e){return e.charAt(1).toUpperCase()}const zq=y5([b5,Rq,k5,C5,E5],"html"),By=y5([b5,Mq,k5,C5,E5],"svg");function $q(e){return e.join(" ").trim()}var zy={},ek=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Fq=/\n/g,Hq=/^\s*/,Uq=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Wq=/^:\s*/,Vq=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,qq=/^[;\s]*/,Kq=/^\s+|\s+$/g,Gq=`
507
+ `,tk="/",nk="*",lo="",Yq="comment",Xq="declaration";function Qq(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function i(m){var v=m.match(Fq);v&&(n+=v.length);var w=m.lastIndexOf(Gq);r=~w?m.length-w:r+m.length}function s(){var m={line:n,column:r};return function(v){return v.position=new o(m),c(),v}}function o(m){this.start=m,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function a(m){var v=new Error(t.source+":"+n+":"+r+": "+m);if(v.reason=m,v.filename=t.source,v.line=n,v.column=r,v.source=e,!t.silent)throw v}function l(m){var v=m.exec(e);if(v){var w=v[0];return i(w),e=e.slice(w.length),v}}function c(){l(Hq)}function u(m){var v;for(m=m||[];v=d();)v!==!1&&m.push(v);return m}function d(){var m=s();if(!(tk!=e.charAt(0)||nk!=e.charAt(1))){for(var v=2;lo!=e.charAt(v)&&(nk!=e.charAt(v)||tk!=e.charAt(v+1));)++v;if(v+=2,lo===e.charAt(v-1))return a("End of comment missing");var w=e.slice(2,v-2);return r+=2,i(w),e=e.slice(v),r+=2,m({type:Yq,comment:w})}}function f(){var m=s(),v=l(Uq);if(v){if(d(),!l(Wq))return a("property missing ':'");var w=l(Vq),x=m({type:Xq,property:rk(v[0].replace(ek,lo)),value:w?rk(w[0].replace(ek,lo)):lo});return l(qq),x}}function p(){var m=[];u(m);for(var v;v=f();)v!==!1&&(m.push(v),u(m));return m}return c(),p()}function rk(e){return e?e.replace(Kq,lo):lo}var Zq=Qq,Jq=gh&&gh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(zy,"__esModule",{value:!0});zy.default=tK;const eK=Jq(Zq);function tK(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,eK.default)(e),i=typeof t=="function";return r.forEach(s=>{if(s.type!=="declaration")return;const{property:o,value:a}=s;i?t(o,a,s):a&&(n=n||{},n[o]=a)}),n}var Ip={};Object.defineProperty(Ip,"__esModule",{value:!0});Ip.camelCase=void 0;var nK=/^--[a-zA-Z0-9_-]+$/,rK=/-([a-z])/g,iK=/^[^-]+$/,sK=/^-(webkit|moz|ms|o|khtml)-/,oK=/^-(ms)-/,aK=function(e){return!e||iK.test(e)||nK.test(e)},lK=function(e,t){return t.toUpperCase()},ik=function(e,t){return"".concat(t,"-")},cK=function(e,t){return t===void 0&&(t={}),aK(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(oK,ik):e=e.replace(sK,ik),e.replace(rK,lK))};Ip.camelCase=cK;var uK=gh&&gh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},dK=uK(zy),hK=Ip;function L0(e,t){var n={};return!e||typeof e!="string"||(0,dK.default)(e,function(r,i){r&&i&&(n[(0,hK.camelCase)(r,t)]=i)}),n}L0.default=L0;var fK=L0;const pK=mu(fK),N5=T5("end"),$y=T5("start");function T5(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function mK(e){const t=$y(e),n=N5(e);if(t&&n)return{start:t,end:n}}function Cc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?sk(e.position):"start"in e||"end"in e?sk(e):"line"in e||"column"in e?D0(e):""}function D0(e){return ok(e&&e.line)+":"+ok(e&&e.column)}function sk(e){return D0(e&&e.start)+"-"+D0(e&&e.end)}function ok(e){return e&&typeof e=="number"?e:1}class Nn extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=Cc(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Nn.prototype.file="";Nn.prototype.name="";Nn.prototype.reason="";Nn.prototype.message="";Nn.prototype.stack="";Nn.prototype.column=void 0;Nn.prototype.line=void 0;Nn.prototype.ancestors=void 0;Nn.prototype.cause=void 0;Nn.prototype.fatal=void 0;Nn.prototype.place=void 0;Nn.prototype.ruleId=void 0;Nn.prototype.source=void 0;const Fy={}.hasOwnProperty,gK=new Map,vK=/[A-Z]/g,xK=new Set(["table","tbody","thead","tfoot","tr"]),_K=new Set(["td","th"]),I5="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function yK(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=TK(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=NK(n,t.jsx,t.jsxs)}const 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"?By:zq,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=P5(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function P5(e,t,n){if(t.type==="element")return bK(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return wK(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return kK(e,t,n);if(t.type==="mdxjsEsm")return SK(e,t);if(t.type==="root")return CK(e,t,n);if(t.type==="text")return EK(e,t)}function bK(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=By,e.schema=i),e.ancestors.push(t);const s=M5(e,t.tagName,!1),o=IK(e,t);let a=Uy(e,t);return xK.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!Iq(l):!0})),R5(e,o,s,t),Hy(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function wK(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}cu(e,t.position)}function SK(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);cu(e,t.position)}function kK(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=By,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:M5(e,t.name,!0),o=PK(e,t),a=Uy(e,t);return R5(e,o,s,t),Hy(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function CK(e,t,n){const r={};return Hy(r,Uy(e,t)),e.create(t,e.Fragment,r,n)}function EK(e,t){return t.value}function R5(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Hy(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function NK(e,t,n){return r;function r(i,s,o,a){const c=Array.isArray(o.children)?n:t;return a?c(s,o,a):c(s,o)}}function TK(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=$y(r);return t(i,s,o,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function IK(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Fy.call(t.properties,i)){const s=RK(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&_K.has(t.tagName)?r=a:n[o]=a}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function PK(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else cu(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,s=e.evaluater.evaluateExpression(a.expression)}else cu(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function Uy(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:gK;for(;++r<t.children.length;){const s=t.children[r];let o;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const c=i.get(l)||0;o=l+"-"+c,i.set(l,c+1)}}const a=P5(e,s,o);a!==void 0&&n.push(a)}return n}function RK(e,t,n){const r=Dq(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?kq(n):$q(n)),r.property==="style"){let i=typeof n=="object"?n:MK(e,String(n));return e.stylePropertyNameCase==="css"&&(i=AK(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Aq[r.property]||r.property:r.attribute,n]}}function MK(e,t){try{return pK(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new Nn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=I5+"#cannot-parse-style-attribute",i}}function M5(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const a=XS(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=o}else r=XS(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Fy.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);cu(e)}function cu(e,t){const n=new Nn("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=I5+"#cannot-handle-mdx-estrees-without-createevaluater",n}function AK(e){const t={};let n;for(n in e)Fy.call(e,n)&&(t[jK(n)]=e[n]);return t}function jK(e){let t=e.replace(vK,LK);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function LK(e){return"-"+e.toLowerCase()}const Gm={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"]},DK={};function Wy(e,t){const n=DK,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return A5(e,r,i)}function A5(e,t,n){if(OK(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 ak(e.children,t,n)}return Array.isArray(e)?ak(e,t,n):""}function ak(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=A5(e[i],t,n);return r.join("")}function OK(e){return!!(e&&typeof e=="object")}const lk=document.createElement("i");function Vy(e){const t="&"+e+";";lk.innerHTML=t;const n=lk.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function or(e,t,n,r){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t: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);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function xr(e,t){return e.length>0?(or(e,e.length,0,t),e):t}const ck={}.hasOwnProperty;function j5(e){const t={};let n=-1;for(;++n<e.length;)BK(t,e[n]);return t}function BK(e,t){let n;for(n in t){const i=(ck.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){ck.call(i,o)||(i[o]=[]);const a=s[o];zK(i[o],Array.isArray(a)?a:a?[a]:[])}}}function zK(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);or(e,0,0,r)}function L5(e,t){const 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 Fr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Rn=Ks(/[A-Za-z]/),kn=Ks(/[\dA-Za-z]/),$K=Ks(/[#-'*+\--9=?A-Z^-~]/);function df(e){return e!==null&&(e<32||e===127)}const O0=Ks(/\d/),FK=Ks(/[\dA-Fa-f]/),HK=Ks(/[!-/:-@[-`{-~]/);function we(e){return e!==null&&e<-2}function ct(e){return e!==null&&(e<0||e===32)}function Ue(e){return e===-2||e===-1||e===32}const Pp=Ks(new RegExp("\\p{P}|\\p{S}","u")),Mo=Ks(/\s/);function Ks(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function El(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&kn(e.charCodeAt(n+1))&&kn(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function qe(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return Ue(l)?(e.enter(n),a(l)):t(l)}function a(l){return Ue(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const UK={tokenize:WK};function WK(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),qe(e,t,"linePrefix")}function i(a){return e.enter("paragraph"),s(a)}function s(a){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return we(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const VK={tokenize:qK},uk={tokenize:KK};function qK(e){const t=this,n=[];let r=0,i,s,o;return a;function a(y){if(r<n.length){const S=n[r];return t.containerState=S[1],e.attempt(S[0].continuation,l,c)(y)}return c(y)}function l(y){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&_();const S=t.events.length;let C=S,k;for(;C--;)if(t.events[C][0]==="exit"&&t.events[C][1].type==="chunkFlow"){k=t.events[C][1].end;break}x(r);let N=S;for(;N<t.events.length;)t.events[N][1].end={...k},N++;return or(t.events,C+1,0,t.events.slice(S)),t.events.length=N,c(y)}return a(y)}function c(y){if(r===n.length){if(!i)return f(y);if(i.currentConstruct&&i.currentConstruct.concrete)return m(y);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(uk,u,d)(y)}function u(y){return i&&_(),x(r),f(y)}function d(y){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(y)}function f(y){return t.containerState={},e.attempt(uk,p,m)(y)}function p(y){return r++,n.push([t.currentConstruct,t.containerState]),f(y)}function m(y){if(y===null){i&&_(),x(0),e.consume(y);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),v(y)}function v(y){if(y===null){w(e.exit("chunkFlow"),!0),x(0),e.consume(y);return}return we(y)?(e.consume(y),w(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(y),v)}function w(y,S){const C=t.sliceStream(y);if(S&&C.push(null),y.previous=s,s&&(s.next=y),s=y,i.defineSkip(y.start),i.write(C),t.parser.lazy[y.start.line]){let k=i.events.length;for(;k--;)if(i.events[k][1].start.offset<o&&(!i.events[k][1].end||i.events[k][1].end.offset>o))return;const N=t.events.length;let T=N,O,P;for(;T--;)if(t.events[T][0]==="exit"&&t.events[T][1].type==="chunkFlow"){if(O){P=t.events[T][1].end;break}O=!0}for(x(r),k=N;k<t.events.length;)t.events[k][1].end={...P},k++;or(t.events,T+1,0,t.events.slice(N)),t.events.length=k}}function x(y){let S=n.length;for(;S-- >y;){const C=n[S];t.containerState=C[1],C[0].exit.call(t,e)}n.length=y}function _(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function KK(e,t,n){return qe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function tl(e){if(e===null||ct(e)||Mo(e))return 1;if(Pp(e))return 2}function Rp(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const B0={name:"attention",resolveAll:GK,tokenize:YK};function GK(e,t){let n=-1,r,i,s,o,a,l,c,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;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const d={...e[r][1].end},f={...e[n][1].start};dk(d,-l),dk(f,l),o={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:f},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[n][1].start={...a.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=xr(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=xr(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),c=xr(c,Rp(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=xr(c,[["exit",s,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,c=xr(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):u=0,or(e,r-1,n-r+3,c),n=r+c.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function YK(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=tl(r);let s;return o;function o(l){return s=l,e.enter("attentionSequence"),a(l)}function a(l){if(l===s)return e.consume(l),a;const c=e.exit("attentionSequence"),u=tl(l),d=!u||u===2&&i||n.includes(l),f=!i||i===2&&u||n.includes(r);return c._open=!!(s===42?d:d&&(i||!f)),c._close=!!(s===42?f:f&&(u||!d)),t(l)}}function dk(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const XK={name:"autolink",tokenize:QK};function QK(e,t,n){let r=0;return i;function i(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(p){return Rn(p)?(e.consume(p),o):p===64?n(p):c(p)}function o(p){return p===43||p===45||p===46||kn(p)?(r=1,a(p)):c(p)}function a(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||kn(p))&&r++<32?(e.consume(p),a):(r=0,c(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||df(p)?n(p):(e.consume(p),l)}function c(p){return p===64?(e.consume(p),u):$K(p)?(e.consume(p),c):n(p)}function u(p){return kn(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,u):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):f(p)}function f(p){if((p===45||kn(p))&&r++<63){const m=p===45?f:d;return e.consume(p),m}return n(p)}}const ju={partial:!0,tokenize:ZK};function ZK(e,t,n){return r;function r(s){return Ue(s)?qe(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||we(s)?t(s):n(s)}}const D5={continuation:{tokenize:eG},exit:tG,name:"blockQuote",tokenize:JK};function JK(e,t,n){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return Ue(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function eG(e,t,n){const r=this;return i;function i(o){return Ue(o)?qe(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(D5,t,n)(o)}}function tG(e){e.exit("blockQuote")}const O5={name:"characterEscape",tokenize:nG};function nG(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return HK(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const B5={name:"characterReference",tokenize:rG};function rG(e,t,n){const r=this;let i=0,s,o;return a;function a(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),l}function l(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),s=31,o=kn,u(d))}function c(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=FK,u):(e.enter("characterReferenceValue"),s=7,o=O0,u(d))}function u(d){if(d===59&&i){const f=e.exit("characterReferenceValue");return o===kn&&!Vy(r.sliceSerialize(f))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(d)&&i++<s?(e.consume(d),u):n(d)}}const hk={partial:!0,tokenize:sG},fk={concrete:!0,name:"codeFenced",tokenize:iG};function iG(e,t,n){const r=this,i={partial:!0,tokenize:C};let s=0,o=0,a;return l;function l(k){return c(k)}function c(k){const N=r.events[r.events.length-1];return s=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[1],!0).length:0,a=k,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),u(k)}function u(k){return k===a?(o++,e.consume(k),u):o<3?n(k):(e.exit("codeFencedFenceSequence"),Ue(k)?qe(e,d,"whitespace")(k):d(k))}function d(k){return k===null||we(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(hk,v,S)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(k))}function f(k){return k===null||we(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(k)):Ue(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),qe(e,p,"whitespace")(k)):k===96&&k===a?n(k):(e.consume(k),f)}function p(k){return k===null||we(k)?d(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(k))}function m(k){return k===null||we(k)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(k)):k===96&&k===a?n(k):(e.consume(k),m)}function v(k){return e.attempt(i,S,w)(k)}function w(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),x}function x(k){return s>0&&Ue(k)?qe(e,_,"linePrefix",s+1)(k):_(k)}function _(k){return k===null||we(k)?e.check(hk,v,S)(k):(e.enter("codeFlowValue"),y(k))}function y(k){return k===null||we(k)?(e.exit("codeFlowValue"),_(k)):(e.consume(k),y)}function S(k){return e.exit("codeFenced"),t(k)}function C(k,N,T){let O=0;return P;function P(L){return k.enter("lineEnding"),k.consume(L),k.exit("lineEnding"),D}function D(L){return k.enter("codeFencedFence"),Ue(L)?qe(k,R,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):R(L)}function R(L){return L===a?(k.enter("codeFencedFenceSequence"),A(L)):T(L)}function A(L){return L===a?(O++,k.consume(L),A):O>=o?(k.exit("codeFencedFenceSequence"),Ue(L)?qe(k,M,"whitespace")(L):M(L)):T(L)}function M(L){return L===null||we(L)?(k.exit("codeFencedFence"),N(L)):T(L)}}}function sG(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Ym={name:"codeIndented",tokenize:aG},oG={partial:!0,tokenize:lG};function aG(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),qe(e,s,"linePrefix",5)(c)}function s(c){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?o(c):n(c)}function o(c){return c===null?l(c):we(c)?e.attempt(oG,o,l)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||we(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),a)}function l(c){return e.exit("codeIndented"),t(c)}}function lG(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):we(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):qe(e,s,"linePrefix",5)(o)}function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):we(o)?i(o):n(o)}}const cG={name:"codeText",previous:dG,resolve:uG,tokenize:hG};function uG(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 dG(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function hG(e,t,n){let r=0,i,s;return o;function o(d){return e.enter("codeText"),e.enter("codeTextSequence"),a(d)}function a(d){return d===96?(e.consume(d),r++,a):(e.exit("codeTextSequence"),l(d))}function l(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),l):d===96?(s=e.enter("codeTextSequence"),i=0,u(d)):we(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):(e.enter("codeTextData"),c(d))}function c(d){return d===null||d===32||d===96||we(d)?(e.exit("codeTextData"),l(d)):(e.consume(d),c)}function u(d){return d===96?(e.consume(d),i++,u):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(s.type="codeTextData",c(d))}}class fG{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Ul(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Ul(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Ul(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Ul(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Ul(this.left,n.reverse())}}}function Ul(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 z5(e){const t={};let n=-1,r,i,s,o,a,l,c;const u=new fG(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"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,pG(u,n)),n=t[n],c=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=u.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(u.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...u.get(i)[1].start},a=u.slice(i,n),a.unshift(r),u.splice(i,n-i+1,a))}}return or(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function pG(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],c={};let u,d,f=-1,p=n,m=0,v=0;const w=[v];for(;p;){for(;e.get(++i)[1]!==p;);s.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<a.length;)a[f][0]==="exit"&&a[f-1][0]==="enter"&&a[f][1].type===a[f-1][1].type&&a[f][1].start.line!==a[f][1].end.line&&(v=f+1,w.push(v),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):w.pop(),f=w.length;f--;){const x=a.slice(w[f],w[f+1]),_=s.pop();l.push([_,_+x.length-1]),e.splice(_,2,x)}for(l.reverse(),f=-1;++f<l.length;)c[m+l[f][0]]=m+l[f][1],m+=l[f][1]-l[f][0]-1;return c}const mG={resolve:vG,tokenize:xG},gG={partial:!0,tokenize:_G};function vG(e){return z5(e),e}function xG(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):we(a)?e.check(gG,o,s)(a):(e.consume(a),i)}function s(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function o(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function _G(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),qe(e,s,"linePrefix")}function s(o){if(o===null||we(o))return n(o);const 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(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function $5(e,t,n,r,i,s,o,a,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return d;function d(x){return x===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(x),e.exit(s),f):x===null||x===32||x===41||df(x)?n(x):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),v(x))}function f(x){return x===62?(e.enter(s),e.consume(x),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(x))}function p(x){return x===62?(e.exit("chunkString"),e.exit(a),f(x)):x===null||x===60||we(x)?n(x):(e.consume(x),x===92?m:p)}function m(x){return x===60||x===62||x===92?(e.consume(x),p):p(x)}function v(x){return!u&&(x===null||x===41||ct(x))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(x)):u<c&&x===40?(e.consume(x),u++,v):x===41?(e.consume(x),u--,v):x===null||x===32||x===40||df(x)?n(x):(e.consume(x),x===92?w:v)}function w(x){return x===40||x===41||x===92?(e.consume(x),v):v(x)}}function F5(e,t,n,r,i,s){const o=this;let a=0,l;return c;function c(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(s),u}function u(p){return a>999||p===null||p===91||p===93&&!l||p===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(p):p===93?(e.exit(s),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):we(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||we(p)||a++>999?(e.exit("chunkString"),u(p)):(e.consume(p),l||(l=!Ue(p)),p===92?f:d)}function f(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function H5(e,t,n,r,i,s){let o;return a;function a(f){return f===34||f===39||f===40?(e.enter(r),e.enter(i),e.consume(f),e.exit(i),o=f===40?41:f,l):n(f)}function l(f){return f===o?(e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):(e.enter(s),c(f))}function c(f){return f===o?(e.exit(s),l(o)):f===null?n(f):we(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),qe(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(f))}function u(f){return f===o||f===null||we(f)?(e.exit("chunkString"),c(f)):(e.consume(f),f===92?d:u)}function d(f){return f===o||f===92?(e.consume(f),u):u(f)}}function Ec(e,t){let n;return r;function r(i){return we(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Ue(i)?qe(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const yG={name:"definition",tokenize:wG},bG={partial:!0,tokenize:SG};function wG(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return F5.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=Fr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return ct(p)?Ec(e,c)(p):c(p)}function c(p){return $5(e,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function u(p){return e.attempt(bG,d,d)(p)}function d(p){return Ue(p)?qe(e,f,"whitespace")(p):f(p)}function f(p){return p===null||we(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function SG(e,t,n){return r;function r(a){return ct(a)?Ec(e,i)(a):n(a)}function i(a){return H5(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return Ue(a)?qe(e,o,"whitespace")(a):o(a)}function o(a){return a===null||we(a)?t(a):n(a)}}const kG={name:"hardBreakEscape",tokenize:CG};function CG(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return we(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const EG={name:"headingAtx",resolve:NG,tokenize:TG};function NG(e,t){let n=e.length-2,r=3,i,s;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},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},or(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function TG(e,t,n){let r=0;return i;function i(u){return e.enter("atxHeading"),s(u)}function s(u){return e.enter("atxHeadingSequence"),o(u)}function o(u){return u===35&&r++<6?(e.consume(u),o):u===null||ct(u)?(e.exit("atxHeadingSequence"),a(u)):n(u)}function a(u){return u===35?(e.enter("atxHeadingSequence"),l(u)):u===null||we(u)?(e.exit("atxHeading"),t(u)):Ue(u)?qe(e,a,"whitespace")(u):(e.enter("atxHeadingText"),c(u))}function l(u){return u===35?(e.consume(u),l):(e.exit("atxHeadingSequence"),a(u))}function c(u){return u===null||u===35||ct(u)?(e.exit("atxHeadingText"),a(u)):(e.consume(u),c)}}const IG=["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"],pk=["pre","script","style","textarea"],PG={concrete:!0,name:"htmlFlow",resolveTo:AG,tokenize:jG},RG={partial:!0,tokenize:DG},MG={partial:!0,tokenize:LG};function AG(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 jG(e,t,n){const r=this;let i,s,o,a,l;return c;function c(j){return u(j)}function u(j){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(j),d}function d(j){return j===33?(e.consume(j),f):j===47?(e.consume(j),s=!0,v):j===63?(e.consume(j),i=3,r.interrupt?t:E):Rn(j)?(e.consume(j),o=String.fromCharCode(j),w):n(j)}function f(j){return j===45?(e.consume(j),i=2,p):j===91?(e.consume(j),i=5,a=0,m):Rn(j)?(e.consume(j),i=4,r.interrupt?t:E):n(j)}function p(j){return j===45?(e.consume(j),r.interrupt?t:E):n(j)}function m(j){const ne="CDATA[";return j===ne.charCodeAt(a++)?(e.consume(j),a===ne.length?r.interrupt?t:R:m):n(j)}function v(j){return Rn(j)?(e.consume(j),o=String.fromCharCode(j),w):n(j)}function w(j){if(j===null||j===47||j===62||ct(j)){const ne=j===47,ie=o.toLowerCase();return!ne&&!s&&pk.includes(ie)?(i=1,r.interrupt?t(j):R(j)):IG.includes(o.toLowerCase())?(i=6,ne?(e.consume(j),x):r.interrupt?t(j):R(j)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(j):s?_(j):y(j))}return j===45||kn(j)?(e.consume(j),o+=String.fromCharCode(j),w):n(j)}function x(j){return j===62?(e.consume(j),r.interrupt?t:R):n(j)}function _(j){return Ue(j)?(e.consume(j),_):P(j)}function y(j){return j===47?(e.consume(j),P):j===58||j===95||Rn(j)?(e.consume(j),S):Ue(j)?(e.consume(j),y):P(j)}function S(j){return j===45||j===46||j===58||j===95||kn(j)?(e.consume(j),S):C(j)}function C(j){return j===61?(e.consume(j),k):Ue(j)?(e.consume(j),C):y(j)}function k(j){return j===null||j===60||j===61||j===62||j===96?n(j):j===34||j===39?(e.consume(j),l=j,N):Ue(j)?(e.consume(j),k):T(j)}function N(j){return j===l?(e.consume(j),l=null,O):j===null||we(j)?n(j):(e.consume(j),N)}function T(j){return j===null||j===34||j===39||j===47||j===60||j===61||j===62||j===96||ct(j)?C(j):(e.consume(j),T)}function O(j){return j===47||j===62||Ue(j)?y(j):n(j)}function P(j){return j===62?(e.consume(j),D):n(j)}function D(j){return j===null||we(j)?R(j):Ue(j)?(e.consume(j),D):n(j)}function R(j){return j===45&&i===2?(e.consume(j),$):j===60&&i===1?(e.consume(j),F):j===62&&i===4?(e.consume(j),H):j===63&&i===3?(e.consume(j),E):j===93&&i===5?(e.consume(j),z):we(j)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(RG,q,A)(j)):j===null||we(j)?(e.exit("htmlFlowData"),A(j)):(e.consume(j),R)}function A(j){return e.check(MG,M,q)(j)}function M(j){return e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),L}function L(j){return j===null||we(j)?A(j):(e.enter("htmlFlowData"),R(j))}function $(j){return j===45?(e.consume(j),E):R(j)}function F(j){return j===47?(e.consume(j),o="",B):R(j)}function B(j){if(j===62){const ne=o.toLowerCase();return pk.includes(ne)?(e.consume(j),H):R(j)}return Rn(j)&&o.length<8?(e.consume(j),o+=String.fromCharCode(j),B):R(j)}function z(j){return j===93?(e.consume(j),E):R(j)}function E(j){return j===62?(e.consume(j),H):j===45&&i===2?(e.consume(j),E):R(j)}function H(j){return j===null||we(j)?(e.exit("htmlFlowData"),q(j)):(e.consume(j),H)}function q(j){return e.exit("htmlFlow"),t(j)}}function LG(e,t,n){const r=this;return i;function i(o){return we(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function DG(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(ju,t,n)}}const OG={name:"htmlText",tokenize:BG};function BG(e,t,n){const r=this;let i,s,o;return a;function a(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),l}function l(E){return E===33?(e.consume(E),c):E===47?(e.consume(E),C):E===63?(e.consume(E),y):Rn(E)?(e.consume(E),T):n(E)}function c(E){return E===45?(e.consume(E),u):E===91?(e.consume(E),s=0,m):Rn(E)?(e.consume(E),_):n(E)}function u(E){return E===45?(e.consume(E),p):n(E)}function d(E){return E===null?n(E):E===45?(e.consume(E),f):we(E)?(o=d,F(E)):(e.consume(E),d)}function f(E){return E===45?(e.consume(E),p):d(E)}function p(E){return E===62?$(E):E===45?f(E):d(E)}function m(E){const H="CDATA[";return E===H.charCodeAt(s++)?(e.consume(E),s===H.length?v:m):n(E)}function v(E){return E===null?n(E):E===93?(e.consume(E),w):we(E)?(o=v,F(E)):(e.consume(E),v)}function w(E){return E===93?(e.consume(E),x):v(E)}function x(E){return E===62?$(E):E===93?(e.consume(E),x):v(E)}function _(E){return E===null||E===62?$(E):we(E)?(o=_,F(E)):(e.consume(E),_)}function y(E){return E===null?n(E):E===63?(e.consume(E),S):we(E)?(o=y,F(E)):(e.consume(E),y)}function S(E){return E===62?$(E):y(E)}function C(E){return Rn(E)?(e.consume(E),k):n(E)}function k(E){return E===45||kn(E)?(e.consume(E),k):N(E)}function N(E){return we(E)?(o=N,F(E)):Ue(E)?(e.consume(E),N):$(E)}function T(E){return E===45||kn(E)?(e.consume(E),T):E===47||E===62||ct(E)?O(E):n(E)}function O(E){return E===47?(e.consume(E),$):E===58||E===95||Rn(E)?(e.consume(E),P):we(E)?(o=O,F(E)):Ue(E)?(e.consume(E),O):$(E)}function P(E){return E===45||E===46||E===58||E===95||kn(E)?(e.consume(E),P):D(E)}function D(E){return E===61?(e.consume(E),R):we(E)?(o=D,F(E)):Ue(E)?(e.consume(E),D):O(E)}function R(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),i=E,A):we(E)?(o=R,F(E)):Ue(E)?(e.consume(E),R):(e.consume(E),M)}function A(E){return E===i?(e.consume(E),i=void 0,L):E===null?n(E):we(E)?(o=A,F(E)):(e.consume(E),A)}function M(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||ct(E)?O(E):(e.consume(E),M)}function L(E){return E===47||E===62||ct(E)?O(E):n(E)}function $(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function F(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),B}function B(E){return Ue(E)?qe(e,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):z(E)}function z(E){return e.enter("htmlTextData"),o(E)}}const qy={name:"labelEnd",resolveAll:HG,resolveTo:UG,tokenize:WG},zG={tokenize:VG},$G={tokenize:qG},FG={tokenize:KG};function HG(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&or(e,0,e.length,n),e}function UG(e,t){let n=e.length,r=0,i,s,o,a;for(;n--;)if(i=e[n][1],s){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&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},u={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",l,t],["enter",c,t]],a=xr(a,e.slice(s+1,s+r+3)),a=xr(a,[["enter",u,t]]),a=xr(a,Rp(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=xr(a,[["exit",u,t],e[o-2],e[o-1],["exit",c,t]]),a=xr(a,e.slice(o+1)),a=xr(a,[["exit",l,t]]),or(e,s,e.length,a),e}function WG(e,t,n){const r=this;let i=r.events.length,s,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return a;function a(f){return s?s._inactive?d(f):(o=r.parser.defined.includes(Fr(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelEnd"),l):n(f)}function l(f){return f===40?e.attempt(zG,u,o?u:d)(f):f===91?e.attempt($G,u,o?c:d)(f):o?u(f):d(f)}function c(f){return e.attempt(FG,u,d)(f)}function u(f){return t(f)}function d(f){return s._balanced=!0,n(f)}}function VG(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),i}function i(d){return ct(d)?Ec(e,s)(d):s(d)}function s(d){return d===41?u(d):$5(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function o(d){return ct(d)?Ec(e,l)(d):u(d)}function a(d){return n(d)}function l(d){return d===34||d===39||d===40?H5(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):u(d)}function c(d){return ct(d)?Ec(e,u)(d):u(d)}function u(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function qG(e,t,n){const r=this;return i;function i(a){return F5.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Fr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function KG(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const GG={name:"labelStartImage",resolveAll:qy.resolveAll,tokenize:YG};function YG(e,t,n){const r=this;return i;function i(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),s}function s(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const XG={name:"labelStartLink",resolveAll:qy.resolveAll,tokenize:QG};function QG(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const Xm={name:"lineEnding",tokenize:ZG};function ZG(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),qe(e,t,"linePrefix")}}const ah={name:"thematicBreak",tokenize:JG};function JG(e,t,n){let r=0,i;return s;function s(c){return e.enter("thematicBreak"),o(c)}function o(c){return i=c,a(c)}function a(c){return c===i?(e.enter("thematicBreakSequence"),l(c)):r>=3&&(c===null||we(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),Ue(c)?qe(e,a,"whitespace")(c):a(c))}}const Un={continuation:{tokenize:rY},exit:sY,name:"list",tokenize:nY},eY={partial:!0,tokenize:oY},tY={partial:!0,tokenize:iY};function nY(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a(p){const m=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:O0(p)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(ah,n,c)(p):c(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return n(p)}function l(p){return O0(p)&&++o<10?(e.consume(p),l):(!r.interrupt||o<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):n(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(ju,r.interrupt?n:u,e.attempt(eY,f,d))}function u(p){return r.containerState.initialBlankLine=!0,s++,f(p)}function d(p){return Ue(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),f):n(p)}function f(p){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function rY(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(ju,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,qe(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!Ue(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(tY,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,qe(e,e.attempt(Un,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function iY(e,t,n){const r=this;return qe(e,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function sY(e){e.exit(this.containerState.type)}function oY(e,t,n){const r=this;return qe(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!Ue(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const mk={name:"setextUnderline",resolveTo:aY,tokenize:lY};function aY(e,t){let n=e.length,r,i,s;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),!s&&e[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",o,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function lY(e,t,n){const r=this;let i;return s;function s(c){let u=r.events.length,d;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){d=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),i=c,o(c)):n(c)}function o(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===i?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),Ue(c)?qe(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||we(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const cY={tokenize:uY};function uY(e){const t=this,n=e.attempt(ju,r,e.attempt(this.parser.constructs.flowInitial,i,qe(e,e.attempt(this.parser.constructs.flow,i,e.attempt(mG,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const dY={resolveAll:W5()},hY=U5("string"),fY=U5("text");function U5(e){return{resolveAll:W5(e==="text"?pY:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,o,a);return o;function o(u){return c(u)?s(u):a(u)}function a(u){if(u===null){n.consume(u);return}return n.enter("data"),n.consume(u),l}function l(u){return c(u)?(n.exit("data"),s(u)):(n.consume(u),l)}function c(u){if(u===null)return!0;const d=i[u];let f=-1;if(d)for(;++f<d.length;){const p=d[f];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function W5(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function pY(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,o=-1,a=0,l;for(;s--;){const c=i[s];if(typeof c=="string"){for(o=c.length;c.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(c===-2)l=!0,a++;else if(c!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const c={type:n===e.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}const mY={42:Un,43:Un,45:Un,48:Un,49:Un,50:Un,51:Un,52:Un,53:Un,54:Un,55:Un,56:Un,57:Un,62:D5},gY={91:yG},vY={[-2]:Ym,[-1]:Ym,32:Ym},xY={35:EG,42:ah,45:[mk,ah],60:PG,61:mk,95:ah,96:fk,126:fk},_Y={38:B5,92:O5},yY={[-5]:Xm,[-4]:Xm,[-3]:Xm,33:GG,38:B5,42:B0,60:[XK,OG],91:XG,92:[kG,O5],93:qy,95:B0,96:cG},bY={null:[B0,dY]},wY={null:[42,95]},SY={null:[]},kY=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:wY,contentInitial:gY,disable:SY,document:mY,flow:xY,flowInitial:vY,insideSpan:bY,string:_Y,text:yY},Symbol.toStringTag,{value:"Module"}));function CY(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],a=[];const l={attempt:N(C),check:N(k),consume:_,enter:y,exit:S,interrupt:N(k,{interrupt:!0})},c={code:null,containerState:{},defineSkip:v,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d};let u=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function d(D){return o=xr(o,D),w(),o[o.length-1]!==null?[]:(T(t,0),c.events=Rp(s,c.events,c),c.events)}function f(D,R){return NY(p(D),R)}function p(D){return EY(o,D)}function m(){const{_bufferIndex:D,_index:R,line:A,column:M,offset:L}=r;return{_bufferIndex:D,_index:R,line:A,column:M,offset:L}}function v(D){i[D.line]=D.column,P()}function w(){let D;for(;r._index<o.length;){const R=o[r._index];if(typeof R=="string")for(D=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===D&&r._bufferIndex<R.length;)x(R.charCodeAt(r._bufferIndex));else x(R)}}function x(D){u=u(D)}function _(D){we(D)?(r.line++,r.column=1,r.offset+=D===-3?2:1,P()):D!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=D}function y(D,R){const A=R||{};return A.type=D,A.start=m(),c.events.push(["enter",A,c]),a.push(A),A}function S(D){const R=a.pop();return R.end=m(),c.events.push(["exit",R,c]),R}function C(D,R){T(D,R.from)}function k(D,R){R.restore()}function N(D,R){return A;function A(M,L,$){let F,B,z,E;return Array.isArray(M)?q(M):"tokenize"in M?q([M]):H(M);function H(K){return ge;function ge(Pe){const he=Pe!==null&&K[Pe],Ae=Pe!==null&&K.null,je=[...Array.isArray(he)?he:he?[he]:[],...Array.isArray(Ae)?Ae:Ae?[Ae]:[]];return q(je)(Pe)}}function q(K){return F=K,B=0,K.length===0?$:j(K[B])}function j(K){return ge;function ge(Pe){return E=O(),z=K,K.partial||(c.currentConstruct=K),K.name&&c.parser.constructs.disable.null.includes(K.name)?ie():K.tokenize.call(R?Object.assign(Object.create(c),R):c,l,ne,ie)(Pe)}}function ne(K){return D(z,E),L}function ie(K){return E.restore(),++B<F.length?j(F[B]):$}}}function T(D,R){D.resolveAll&&!s.includes(D)&&s.push(D),D.resolve&&or(c.events,R,c.events.length-R,D.resolve(c.events.slice(R),c)),D.resolveTo&&(c.events=D.resolveTo(c.events,c))}function O(){const D=m(),R=c.previous,A=c.currentConstruct,M=c.events.length,L=Array.from(a);return{from:M,restore:$};function $(){r=D,c.previous=R,c.currentConstruct=A,c.events.length=M,a=L,P()}}function P(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function EY(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,s)];else{if(o=e.slice(n,i),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}s>0&&o.push(e[i].slice(0,s))}return o}function NY(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
508
508
  `;break}case-3:{o=`\r
509
- `;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function cY(e){const r={constructs:I5([sY,...(e||{}).extensions||[]]),content:i(kK),defined:[],document:i(EK),flow:i(WG),lazy:{},string:i(KG),text:i(GG)};return r;function i(s){return o;function o(a){return oY(r,s,a)}}}function uY(e){for(;!j5(e););return e}const fk=/[\0\t\n\r]/g;function dY(){let e=1,t="",n=!0,r;return i;function i(s,o,a){const l=[];let c,u,d,f,p;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),d=0,t="",n&&(s.charCodeAt(0)===65279&&d++,n=void 0);d<s.length;){if(fk.lastIndex=d,c=fk.exec(s),f=c&&c.index!==void 0?c.index:s.length,p=s.charCodeAt(f),!c){t=s.slice(d);break}if(p===10&&d===f&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),d<f&&(l.push(s.slice(d,f)),e+=f-d),p){case 0:{l.push(65533),e++;break}case 9:{for(u=Math.ceil(e/4)*4,l.push(-2);e++<u;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}d=f+1}return a&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const hY=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function fY(e){return e.replace(hY,pY)}function pY(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return P5(n.slice(s?2:1),s?16:10)}return Vy(n)||e}const $5={}.hasOwnProperty;function mY(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),gY(n)(uY(cY(n).document().write(dY()(e,t,!0))))}function gY(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(ut),autolinkProtocol:O,autolinkEmail:O,atxHeading:s(Rt),blockQuote:s(Ae),characterEscape:O,characterReference:O,codeFenced:s(je),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(je,o),codeText:s($e,o),codeTextData:O,data:O,codeFlowValue:O,definition:s(_e),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(tt),hardBreakEscape:s(Xe),hardBreakTrailing:s(Xe),htmlFlow:s(ot,o),htmlFlowData:O,htmlText:s(ot,o),htmlTextData:O,image:s(xn),label:o,link:s(ut),listItem:s(Ke),listItemValue:f,listOrdered:s(Ct,d),listUnordered:s(Ct),paragraph:s(at),reference:j,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(Rt),strong:s(Dt),thematicBreak:s(Tn)},exit:{atxHeading:l(),atxHeadingSequence:C,autolink:l(),autolinkEmail:he,autolinkProtocol:Pe,blockQuote:l(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:ie,characterReferenceMarkerNumeric:ie,characterReferenceValue:K,characterReference:ge,codeFenced:l(w),codeFencedFence:v,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:P,codeIndented:l(x),codeText:l(L),codeTextData:P,data:P,definition:l(),definitionDestinationString:S,definitionLabelString:_,definitionTitleString:y,emphasis:l(),hardBreakEscape:l(R),hardBreakTrailing:l(R),htmlFlow:l(A),htmlFlowData:P,htmlText:l(M),htmlTextData:P,image:l(F),label:z,labelText:B,lineEnding:D,link:l($),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ne,resourceDestinationString:E,resourceTitleString:H,resource:q,setextHeading:l(T),setextHeadingLineSequence:N,setextHeadingText:k,strong:l(),thematicBreak:l()}};F5(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(U){let J={type:"root",children:[]};const ye={stack:[J],tokenStack:[],config:t,enter:a,exit:c,buffer:o,resume:u,data:n},Ce=[];let Fe=-1;for(;++Fe<U.length;)if(U[Fe][1].type==="listOrdered"||U[Fe][1].type==="listUnordered")if(U[Fe][0]==="enter")Ce.push(Fe);else{const xt=Ce.pop();Fe=i(U,xt,Fe)}for(Fe=-1;++Fe<U.length;){const xt=t[U[Fe][0]];$5.call(xt,U[Fe][1].type)&&xt[U[Fe][1].type].call(Object.assign({sliceSerialize:U[Fe][2].sliceSerialize},ye),U[Fe][1])}if(ye.tokenStack.length>0){const xt=ye.tokenStack[ye.tokenStack.length-1];(xt[1]||pk).call(ye,void 0,xt[0])}for(J.position={start:as(U.length>0?U[0][1].start:{line:1,column:1,offset:0}),end:as(U.length>0?U[U.length-2][1].end:{line:1,column:1,offset:0})},Fe=-1;++Fe<t.transforms.length;)J=t.transforms[Fe](J)||J;return J}function i(U,J,ye){let Ce=J-1,Fe=-1,xt=!1,un,qt,dn,se;for(;++Ce<=ye;){const be=U[Ce];switch(be[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{be[0]==="enter"?Fe++:Fe--,se=void 0;break}case"lineEndingBlank":{be[0]==="enter"&&(un&&!se&&!Fe&&!dn&&(dn=Ce),se=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:se=void 0}if(!Fe&&be[0]==="enter"&&be[1].type==="listItemPrefix"||Fe===-1&&be[0]==="exit"&&(be[1].type==="listUnordered"||be[1].type==="listOrdered")){if(un){let lt=Ce;for(qt=void 0;lt--;){const Mt=U[lt];if(Mt[1].type==="lineEnding"||Mt[1].type==="lineEndingBlank"){if(Mt[0]==="exit")continue;qt&&(U[qt][1].type="lineEndingBlank",xt=!0),Mt[1].type="lineEnding",qt=lt}else if(!(Mt[1].type==="linePrefix"||Mt[1].type==="blockQuotePrefix"||Mt[1].type==="blockQuotePrefixWhitespace"||Mt[1].type==="blockQuoteMarker"||Mt[1].type==="listItemIndent"))break}dn&&(!qt||dn<qt)&&(un._spread=!0),un.end=Object.assign({},qt?U[qt][1].start:be[1].end),U.splice(qt||Ce,0,["exit",un,be[2]]),Ce++,ye++}if(be[1].type==="listItemPrefix"){const lt={type:"listItem",_spread:!1,start:Object.assign({},be[1].start),end:void 0};un=lt,U.splice(Ce,0,["enter",lt,be[2]]),Ce++,ye++,dn=void 0,se=!0}}}return U[J][1]._spread=xt,ye}function s(U,J){return ye;function ye(Ce){a.call(this,U(Ce),Ce),J&&J.call(this,Ce)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(U,J,ye){this.stack[this.stack.length-1].children.push(U),this.stack.push(U),this.tokenStack.push([J,ye||void 0]),U.position={start:as(J.start),end:void 0}}function l(U){return J;function J(ye){U&&U.call(this,ye),c.call(this,ye)}}function c(U,J){const ye=this.stack.pop(),Ce=this.tokenStack.pop();if(Ce)Ce[0].type!==U.type&&(J?J.call(this,U,Ce[0]):(Ce[1]||pk).call(this,U,Ce[0]));else throw new Error("Cannot close `"+U.type+"` ("+Cc({start:U.start,end:U.end})+"): it’s not open");ye.position.end=as(U.end)}function u(){return Wy(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(U){if(this.data.expectingFirstListItemValue){const J=this.stack[this.stack.length-2];J.start=Number.parseInt(this.sliceSerialize(U),10),this.data.expectingFirstListItemValue=void 0}}function p(){const U=this.resume(),J=this.stack[this.stack.length-1];J.lang=U}function m(){const U=this.resume(),J=this.stack[this.stack.length-1];J.meta=U}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function w(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U.replace(/(\r?\n|\r)$/g,"")}function _(U){const J=this.resume(),ye=this.stack[this.stack.length-1];ye.label=J,ye.identifier=Fr(this.sliceSerialize(U)).toLowerCase()}function y(){const U=this.resume(),J=this.stack[this.stack.length-1];J.title=U}function S(){const U=this.resume(),J=this.stack[this.stack.length-1];J.url=U}function C(U){const J=this.stack[this.stack.length-1];if(!J.depth){const ye=this.sliceSerialize(U).length;J.depth=ye}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function N(U){const J=this.stack[this.stack.length-1];J.depth=this.sliceSerialize(U).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function O(U){const ye=this.stack[this.stack.length-1].children;let Ce=ye[ye.length-1];(!Ce||Ce.type!=="text")&&(Ce=Vt(),Ce.position={start:as(U.start),end:void 0},ye.push(Ce)),this.stack.push(Ce)}function P(U){const J=this.stack.pop();J.value+=this.sliceSerialize(U),J.position.end=as(U.end)}function D(U){const J=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ye=J.children[J.children.length-1];ye.position.end=as(U.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(J.type)&&(O.call(this,U),P.call(this,U))}function R(){this.data.atHardBreak=!0}function A(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U}function M(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U}function L(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U}function $(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const J=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=J,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function F(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const J=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=J,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function B(U){const J=this.sliceSerialize(U),ye=this.stack[this.stack.length-2];ye.label=fY(J),ye.identifier=Fr(J).toLowerCase()}function z(){const U=this.stack[this.stack.length-1],J=this.resume(),ye=this.stack[this.stack.length-1];if(this.data.inReference=!0,ye.type==="link"){const Ce=U.children;ye.children=Ce}else ye.alt=J}function E(){const U=this.resume(),J=this.stack[this.stack.length-1];J.url=U}function H(){const U=this.resume(),J=this.stack[this.stack.length-1];J.title=U}function q(){this.data.inReference=void 0}function j(){this.data.referenceType="collapsed"}function ne(U){const J=this.resume(),ye=this.stack[this.stack.length-1];ye.label=J,ye.identifier=Fr(this.sliceSerialize(U)).toLowerCase(),this.data.referenceType="full"}function ie(U){this.data.characterReferenceType=U.type}function K(U){const J=this.sliceSerialize(U),ye=this.data.characterReferenceType;let Ce;ye?(Ce=P5(J,ye==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ce=Vy(J);const Fe=this.stack[this.stack.length-1];Fe.value+=Ce}function ge(U){const J=this.stack.pop();J.position.end=as(U.end)}function Pe(U){P.call(this,U);const J=this.stack[this.stack.length-1];J.url=this.sliceSerialize(U)}function he(U){P.call(this,U);const J=this.stack[this.stack.length-1];J.url="mailto:"+this.sliceSerialize(U)}function Ae(){return{type:"blockquote",children:[]}}function je(){return{type:"code",lang:null,meta:null,value:""}}function $e(){return{type:"inlineCode",value:""}}function _e(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function tt(){return{type:"emphasis",children:[]}}function Rt(){return{type:"heading",depth:0,children:[]}}function Xe(){return{type:"break"}}function ot(){return{type:"html",value:""}}function xn(){return{type:"image",title:null,url:"",alt:null}}function ut(){return{type:"link",title:null,url:"",children:[]}}function Ct(U){return{type:"list",ordered:U.type==="listOrdered",start:null,spread:U._spread,children:[]}}function Ke(U){return{type:"listItem",spread:U._spread,checked:null,children:[]}}function at(){return{type:"paragraph",children:[]}}function Dt(){return{type:"strong",children:[]}}function Vt(){return{type:"text",value:""}}function Tn(){return{type:"thematicBreak"}}}function as(e){return{line:e.line,column:e.column,offset:e.offset}}function F5(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?F5(e,r):vY(e,r)}}function vY(e,t){let n;for(n in t)if($5.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function pk(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Cc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Cc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Cc({start:t.start,end:t.end})+") is still open")}function xY(e){const t=this;t.parser=n;function n(r){return mY(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function _Y(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function yY(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
510
- `}]}function bY(e,t){const n=t.value?t.value+`
511
- `:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function wY(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function SY(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function kY(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=El(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let o,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=s+1,a+=1,e.footnoteCounts.set(r,a);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)}function CY(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function EY(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function H5(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function NY(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return H5(e,t);const i={src:El(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)}function TY(e,t){const n={src:El(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function IY(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function PY(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return H5(e,t);const i={href:El(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function RY(e,t){const n={href:El(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function MY(e,t,n){const r=e.all(t),i=n?AY(n):U5(t),s={},o=[];if(typeof t.checked=="boolean"){const u=r[0];let d;u&&u.type==="element"&&u.tagName==="p"?d=u:(d={type:"element",tagName:"p",properties:{},children:[]},r.unshift(d)),d.children.length>0&&d.children.unshift({type:"text",value:" "}),d.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const u=r[a];(i||a!==0||u.type!=="element"||u.tagName!=="p")&&o.push({type:"text",value:`
509
+ `;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function TY(e){const r={constructs:j5([kY,...(e||{}).extensions||[]]),content:i(UK),defined:[],document:i(VK),flow:i(cY),lazy:{},string:i(hY),text:i(fY)};return r;function i(s){return o;function o(a){return CY(r,s,a)}}}function IY(e){for(;!z5(e););return e}const gk=/[\0\t\n\r]/g;function PY(){let e=1,t="",n=!0,r;return i;function i(s,o,a){const l=[];let c,u,d,f,p;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),d=0,t="",n&&(s.charCodeAt(0)===65279&&d++,n=void 0);d<s.length;){if(gk.lastIndex=d,c=gk.exec(s),f=c&&c.index!==void 0?c.index:s.length,p=s.charCodeAt(f),!c){t=s.slice(d);break}if(p===10&&d===f&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),d<f&&(l.push(s.slice(d,f)),e+=f-d),p){case 0:{l.push(65533),e++;break}case 9:{for(u=Math.ceil(e/4)*4,l.push(-2);e++<u;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}d=f+1}return a&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const RY=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function MY(e){return e.replace(RY,AY)}function AY(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return L5(n.slice(s?2:1),s?16:10)}return Vy(n)||e}const V5={}.hasOwnProperty;function jY(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),LY(n)(IY(TY(n).document().write(PY()(e,t,!0))))}function LY(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(ut),autolinkProtocol:O,autolinkEmail:O,atxHeading:s(Rt),blockQuote:s(Ae),characterEscape:O,characterReference:O,codeFenced:s(je),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(je,o),codeText:s($e,o),codeTextData:O,data:O,codeFlowValue:O,definition:s(_e),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(tt),hardBreakEscape:s(Xe),hardBreakTrailing:s(Xe),htmlFlow:s(ot,o),htmlFlowData:O,htmlText:s(ot,o),htmlTextData:O,image:s(xn),label:o,link:s(ut),listItem:s(Ke),listItemValue:f,listOrdered:s(Ct,d),listUnordered:s(Ct),paragraph:s(at),reference:j,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(Rt),strong:s(Dt),thematicBreak:s(Tn)},exit:{atxHeading:l(),atxHeadingSequence:C,autolink:l(),autolinkEmail:he,autolinkProtocol:Pe,blockQuote:l(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:ie,characterReferenceMarkerNumeric:ie,characterReferenceValue:K,characterReference:ge,codeFenced:l(w),codeFencedFence:v,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:P,codeIndented:l(x),codeText:l(L),codeTextData:P,data:P,definition:l(),definitionDestinationString:S,definitionLabelString:_,definitionTitleString:y,emphasis:l(),hardBreakEscape:l(R),hardBreakTrailing:l(R),htmlFlow:l(A),htmlFlowData:P,htmlText:l(M),htmlTextData:P,image:l(F),label:z,labelText:B,lineEnding:D,link:l($),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ne,resourceDestinationString:E,resourceTitleString:H,resource:q,setextHeading:l(T),setextHeadingLineSequence:N,setextHeadingText:k,strong:l(),thematicBreak:l()}};q5(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(U){let J={type:"root",children:[]};const ye={stack:[J],tokenStack:[],config:t,enter:a,exit:c,buffer:o,resume:u,data:n},Ce=[];let Fe=-1;for(;++Fe<U.length;)if(U[Fe][1].type==="listOrdered"||U[Fe][1].type==="listUnordered")if(U[Fe][0]==="enter")Ce.push(Fe);else{const xt=Ce.pop();Fe=i(U,xt,Fe)}for(Fe=-1;++Fe<U.length;){const xt=t[U[Fe][0]];V5.call(xt,U[Fe][1].type)&&xt[U[Fe][1].type].call(Object.assign({sliceSerialize:U[Fe][2].sliceSerialize},ye),U[Fe][1])}if(ye.tokenStack.length>0){const xt=ye.tokenStack[ye.tokenStack.length-1];(xt[1]||vk).call(ye,void 0,xt[0])}for(J.position={start:as(U.length>0?U[0][1].start:{line:1,column:1,offset:0}),end:as(U.length>0?U[U.length-2][1].end:{line:1,column:1,offset:0})},Fe=-1;++Fe<t.transforms.length;)J=t.transforms[Fe](J)||J;return J}function i(U,J,ye){let Ce=J-1,Fe=-1,xt=!1,un,qt,dn,se;for(;++Ce<=ye;){const be=U[Ce];switch(be[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{be[0]==="enter"?Fe++:Fe--,se=void 0;break}case"lineEndingBlank":{be[0]==="enter"&&(un&&!se&&!Fe&&!dn&&(dn=Ce),se=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:se=void 0}if(!Fe&&be[0]==="enter"&&be[1].type==="listItemPrefix"||Fe===-1&&be[0]==="exit"&&(be[1].type==="listUnordered"||be[1].type==="listOrdered")){if(un){let lt=Ce;for(qt=void 0;lt--;){const Mt=U[lt];if(Mt[1].type==="lineEnding"||Mt[1].type==="lineEndingBlank"){if(Mt[0]==="exit")continue;qt&&(U[qt][1].type="lineEndingBlank",xt=!0),Mt[1].type="lineEnding",qt=lt}else if(!(Mt[1].type==="linePrefix"||Mt[1].type==="blockQuotePrefix"||Mt[1].type==="blockQuotePrefixWhitespace"||Mt[1].type==="blockQuoteMarker"||Mt[1].type==="listItemIndent"))break}dn&&(!qt||dn<qt)&&(un._spread=!0),un.end=Object.assign({},qt?U[qt][1].start:be[1].end),U.splice(qt||Ce,0,["exit",un,be[2]]),Ce++,ye++}if(be[1].type==="listItemPrefix"){const lt={type:"listItem",_spread:!1,start:Object.assign({},be[1].start),end:void 0};un=lt,U.splice(Ce,0,["enter",lt,be[2]]),Ce++,ye++,dn=void 0,se=!0}}}return U[J][1]._spread=xt,ye}function s(U,J){return ye;function ye(Ce){a.call(this,U(Ce),Ce),J&&J.call(this,Ce)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(U,J,ye){this.stack[this.stack.length-1].children.push(U),this.stack.push(U),this.tokenStack.push([J,ye||void 0]),U.position={start:as(J.start),end:void 0}}function l(U){return J;function J(ye){U&&U.call(this,ye),c.call(this,ye)}}function c(U,J){const ye=this.stack.pop(),Ce=this.tokenStack.pop();if(Ce)Ce[0].type!==U.type&&(J?J.call(this,U,Ce[0]):(Ce[1]||vk).call(this,U,Ce[0]));else throw new Error("Cannot close `"+U.type+"` ("+Cc({start:U.start,end:U.end})+"): it’s not open");ye.position.end=as(U.end)}function u(){return Wy(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(U){if(this.data.expectingFirstListItemValue){const J=this.stack[this.stack.length-2];J.start=Number.parseInt(this.sliceSerialize(U),10),this.data.expectingFirstListItemValue=void 0}}function p(){const U=this.resume(),J=this.stack[this.stack.length-1];J.lang=U}function m(){const U=this.resume(),J=this.stack[this.stack.length-1];J.meta=U}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function w(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U.replace(/(\r?\n|\r)$/g,"")}function _(U){const J=this.resume(),ye=this.stack[this.stack.length-1];ye.label=J,ye.identifier=Fr(this.sliceSerialize(U)).toLowerCase()}function y(){const U=this.resume(),J=this.stack[this.stack.length-1];J.title=U}function S(){const U=this.resume(),J=this.stack[this.stack.length-1];J.url=U}function C(U){const J=this.stack[this.stack.length-1];if(!J.depth){const ye=this.sliceSerialize(U).length;J.depth=ye}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function N(U){const J=this.stack[this.stack.length-1];J.depth=this.sliceSerialize(U).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function O(U){const ye=this.stack[this.stack.length-1].children;let Ce=ye[ye.length-1];(!Ce||Ce.type!=="text")&&(Ce=Vt(),Ce.position={start:as(U.start),end:void 0},ye.push(Ce)),this.stack.push(Ce)}function P(U){const J=this.stack.pop();J.value+=this.sliceSerialize(U),J.position.end=as(U.end)}function D(U){const J=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ye=J.children[J.children.length-1];ye.position.end=as(U.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(J.type)&&(O.call(this,U),P.call(this,U))}function R(){this.data.atHardBreak=!0}function A(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U}function M(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U}function L(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U}function $(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const J=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=J,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function F(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const J=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=J,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function B(U){const J=this.sliceSerialize(U),ye=this.stack[this.stack.length-2];ye.label=MY(J),ye.identifier=Fr(J).toLowerCase()}function z(){const U=this.stack[this.stack.length-1],J=this.resume(),ye=this.stack[this.stack.length-1];if(this.data.inReference=!0,ye.type==="link"){const Ce=U.children;ye.children=Ce}else ye.alt=J}function E(){const U=this.resume(),J=this.stack[this.stack.length-1];J.url=U}function H(){const U=this.resume(),J=this.stack[this.stack.length-1];J.title=U}function q(){this.data.inReference=void 0}function j(){this.data.referenceType="collapsed"}function ne(U){const J=this.resume(),ye=this.stack[this.stack.length-1];ye.label=J,ye.identifier=Fr(this.sliceSerialize(U)).toLowerCase(),this.data.referenceType="full"}function ie(U){this.data.characterReferenceType=U.type}function K(U){const J=this.sliceSerialize(U),ye=this.data.characterReferenceType;let Ce;ye?(Ce=L5(J,ye==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ce=Vy(J);const Fe=this.stack[this.stack.length-1];Fe.value+=Ce}function ge(U){const J=this.stack.pop();J.position.end=as(U.end)}function Pe(U){P.call(this,U);const J=this.stack[this.stack.length-1];J.url=this.sliceSerialize(U)}function he(U){P.call(this,U);const J=this.stack[this.stack.length-1];J.url="mailto:"+this.sliceSerialize(U)}function Ae(){return{type:"blockquote",children:[]}}function je(){return{type:"code",lang:null,meta:null,value:""}}function $e(){return{type:"inlineCode",value:""}}function _e(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function tt(){return{type:"emphasis",children:[]}}function Rt(){return{type:"heading",depth:0,children:[]}}function Xe(){return{type:"break"}}function ot(){return{type:"html",value:""}}function xn(){return{type:"image",title:null,url:"",alt:null}}function ut(){return{type:"link",title:null,url:"",children:[]}}function Ct(U){return{type:"list",ordered:U.type==="listOrdered",start:null,spread:U._spread,children:[]}}function Ke(U){return{type:"listItem",spread:U._spread,checked:null,children:[]}}function at(){return{type:"paragraph",children:[]}}function Dt(){return{type:"strong",children:[]}}function Vt(){return{type:"text",value:""}}function Tn(){return{type:"thematicBreak"}}}function as(e){return{line:e.line,column:e.column,offset:e.offset}}function q5(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?q5(e,r):DY(e,r)}}function DY(e,t){let n;for(n in t)if(V5.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function vk(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Cc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Cc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Cc({start:t.start,end:t.end})+") is still open")}function OY(e){const t=this;t.parser=n;function n(r){return jY(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function BY(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function zY(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
510
+ `}]}function $Y(e,t){const n=t.value?t.value+`
511
+ `:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function FY(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function HY(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function UY(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=El(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let o,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=s+1,a+=1,e.footnoteCounts.set(r,a);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)}function WY(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function VY(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function K5(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function qY(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return K5(e,t);const i={src:El(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)}function KY(e,t){const n={src:El(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function GY(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function YY(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return K5(e,t);const i={href:El(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function XY(e,t){const n={href:El(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function QY(e,t,n){const r=e.all(t),i=n?ZY(n):G5(t),s={},o=[];if(typeof t.checked=="boolean"){const u=r[0];let d;u&&u.type==="element"&&u.tagName==="p"?d=u:(d={type:"element",tagName:"p",properties:{},children:[]},r.unshift(d)),d.children.length>0&&d.children.unshift({type:"text",value:" "}),d.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const u=r[a];(i||a!==0||u.type!=="element"||u.tagName!=="p")&&o.push({type:"text",value:`
512
512
  `}),u.type==="element"&&u.tagName==="p"&&!i?o.push(...u.children):o.push(u)}const l=r[r.length-1];l&&(i||l.type!=="element"||l.tagName!=="p")&&o.push({type:"text",value:`
513
- `});const c={type:"element",tagName:"li",properties:s,children:o};return e.patch(t,c),e.applyData(t,c)}function AY(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=U5(n[r])}return t}function U5(e){const t=e.spread;return t??e.children.length>1}function jY(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const o=r[i];if(o.type==="element"&&o.tagName==="li"&&o.properties&&Array.isArray(o.properties.className)&&o.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)}function LY(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function DY(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function OY(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function BY(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const o={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],o),i.push(o)}if(n.length>0){const o={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=$y(t.children[1]),l=w5(t.children[t.children.length-1]);a&&l&&(o.position={start:a,end:l}),i.push(o)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function zY(e,t,n){const r=n?n.children:void 0,s=(r?r.indexOf(t):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,a=o?o.length:t.children.length;let l=-1;const c=[];for(;++l<a;){const d=t.children[l],f={},p=o?o[l]:void 0;p&&(f.align=p);let m={type:"element",tagName:s,properties:f,children:[]};d&&(m.children=e.all(d),e.patch(d,m),m=e.applyData(d,m)),c.push(m)}const u={type:"element",tagName:"tr",properties:{},children:e.wrap(c,!0)};return e.patch(t,u),e.applyData(t,u)}function $Y(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const mk=9,gk=32;function FY(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(vk(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(vk(t.slice(i),i>0,!1)),s.join("")}function vk(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===mk||s===gk;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===mk||s===gk;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function HY(e,t){const n={type:"text",value:FY(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function UY(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const WY={blockquote:_Y,break:yY,code:bY,delete:wY,emphasis:SY,footnoteReference:kY,heading:CY,html:EY,imageReference:NY,image:TY,inlineCode:IY,linkReference:PY,link:RY,listItem:MY,list:jY,paragraph:LY,root:DY,strong:OY,table:BY,tableCell:$Y,tableRow:zY,text:HY,thematicBreak:UY,toml:Ed,yaml:Ed,definition:Ed,footnoteDefinition:Ed};function Ed(){}const W5=-1,Rp=0,Nc=1,hf=2,Ky=3,Gy=4,Yy=5,Xy=6,V5=7,q5=8,xk=typeof self=="object"?self:globalThis,VY=(e,t)=>{const n=(i,s)=>(e.set(s,i),i),r=i=>{if(e.has(i))return e.get(i);const[s,o]=t[i];switch(s){case Rp:case W5:return n(o,i);case Nc:{const a=n([],i);for(const l of o)a.push(r(l));return a}case hf:{const a=n({},i);for(const[l,c]of o)a[r(l)]=r(c);return a}case Ky:return n(new Date(o),i);case Gy:{const{source:a,flags:l}=o;return n(new RegExp(a,l),i)}case Yy:{const a=n(new Map,i);for(const[l,c]of o)a.set(r(l),r(c));return a}case Xy:{const a=n(new Set,i);for(const l of o)a.add(r(l));return a}case V5:{const{name:a,message:l}=o;return n(new xk[a](l),i)}case q5:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:a}=new Uint8Array(o);return n(new DataView(a),o)}}return n(new xk[s](o),i)};return r},_k=e=>VY(new Map,e)(0),oa="",{toString:qY}={},{keys:KY}=Object,Wl=e=>{const t=typeof e;if(t!=="object"||!e)return[Rp,t];const n=qY.call(e).slice(8,-1);switch(n){case"Array":return[Nc,oa];case"Object":return[hf,oa];case"Date":return[Ky,oa];case"RegExp":return[Gy,oa];case"Map":return[Yy,oa];case"Set":return[Xy,oa];case"DataView":return[Nc,n]}return n.includes("Array")?[Nc,n]:n.includes("Error")?[V5,n]:[hf,n]},Nd=([e,t])=>e===Rp&&(t==="function"||t==="symbol"),GY=(e,t,n,r)=>{const i=(o,a)=>{const l=r.push(o)-1;return n.set(a,l),l},s=o=>{if(n.has(o))return n.get(o);let[a,l]=Wl(o);switch(a){case Rp:{let u=o;switch(l){case"bigint":a=q5,u=o.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);u=null;break;case"undefined":return i([W5],o)}return i([a,u],o)}case Nc:{if(l){let f=o;return l==="DataView"?f=new Uint8Array(o.buffer):l==="ArrayBuffer"&&(f=new Uint8Array(o)),i([l,[...f]],o)}const u=[],d=i([a,u],o);for(const f of o)u.push(s(f));return d}case hf:{if(l)switch(l){case"BigInt":return i([l,o.toString()],o);case"Boolean":case"Number":case"String":return i([l,o.valueOf()],o)}if(t&&"toJSON"in o)return s(o.toJSON());const u=[],d=i([a,u],o);for(const f of KY(o))(e||!Nd(Wl(o[f])))&&u.push([s(f),s(o[f])]);return d}case Ky:return i([a,o.toISOString()],o);case Gy:{const{source:u,flags:d}=o;return i([a,{source:u,flags:d}],o)}case Yy:{const u=[],d=i([a,u],o);for(const[f,p]of o)(e||!(Nd(Wl(f))||Nd(Wl(p))))&&u.push([s(f),s(p)]);return d}case Xy:{const u=[],d=i([a,u],o);for(const f of o)(e||!Nd(Wl(f)))&&u.push(s(f));return d}}const{message:c}=o;return i([a,{name:l,message:c}],o)};return s},yk=(e,{json:t,lossy:n}={})=>{const r=[];return GY(!(t||n),!!t,new Map,r)(e),r},ff=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?_k(yk(e,t)):structuredClone(e):(e,t)=>_k(yk(e,t));function YY(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function XY(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function QY(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||YY,r=e.options.footnoteBackLabel||XY,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[];let l=-1;for(;++l<e.footnoteOrder.length;){const c=e.footnoteById.get(e.footnoteOrder[l]);if(!c)continue;const u=e.all(c),d=String(c.identifier).toUpperCase(),f=El(d.toLowerCase());let p=0;const m=[],v=e.footnoteCounts.get(d);for(;v!==void 0&&++p<=v;){m.length>0&&m.push({type:"text",value:" "});let _=typeof n=="string"?n:n(l,p);typeof _=="string"&&(_={type:"text",value:_}),m.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+f+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,p),className:["data-footnote-backref"]},children:Array.isArray(_)?_:[_]})}const w=u[u.length-1];if(w&&w.type==="element"&&w.tagName==="p"){const _=w.children[w.children.length-1];_&&_.type==="text"?_.value+=" ":w.children.push({type:"text",value:" "}),w.children.push(...m)}else u.push(...m);const x={type:"element",tagName:"li",properties:{id:t+"fn-"+f},children:e.wrap(u,!0)};e.patch(c,x),a.push(x)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...ff(o),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
513
+ `});const c={type:"element",tagName:"li",properties:s,children:o};return e.patch(t,c),e.applyData(t,c)}function ZY(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=G5(n[r])}return t}function G5(e){const t=e.spread;return t??e.children.length>1}function JY(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const o=r[i];if(o.type==="element"&&o.tagName==="li"&&o.properties&&Array.isArray(o.properties.className)&&o.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)}function eX(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function tX(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function nX(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function rX(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const o={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],o),i.push(o)}if(n.length>0){const o={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=$y(t.children[1]),l=N5(t.children[t.children.length-1]);a&&l&&(o.position={start:a,end:l}),i.push(o)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function iX(e,t,n){const r=n?n.children:void 0,s=(r?r.indexOf(t):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,a=o?o.length:t.children.length;let l=-1;const c=[];for(;++l<a;){const d=t.children[l],f={},p=o?o[l]:void 0;p&&(f.align=p);let m={type:"element",tagName:s,properties:f,children:[]};d&&(m.children=e.all(d),e.patch(d,m),m=e.applyData(d,m)),c.push(m)}const u={type:"element",tagName:"tr",properties:{},children:e.wrap(c,!0)};return e.patch(t,u),e.applyData(t,u)}function sX(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const xk=9,_k=32;function oX(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(yk(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(yk(t.slice(i),i>0,!1)),s.join("")}function yk(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===xk||s===_k;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===xk||s===_k;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function aX(e,t){const n={type:"text",value:oX(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function lX(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const cX={blockquote:BY,break:zY,code:$Y,delete:FY,emphasis:HY,footnoteReference:UY,heading:WY,html:VY,imageReference:qY,image:KY,inlineCode:GY,linkReference:YY,link:XY,listItem:QY,list:JY,paragraph:eX,root:tX,strong:nX,table:rX,tableCell:sX,tableRow:iX,text:aX,thematicBreak:lX,toml:Ed,yaml:Ed,definition:Ed,footnoteDefinition:Ed};function Ed(){}const Y5=-1,Mp=0,Nc=1,hf=2,Ky=3,Gy=4,Yy=5,Xy=6,X5=7,Q5=8,bk=typeof self=="object"?self:globalThis,uX=(e,t)=>{const n=(i,s)=>(e.set(s,i),i),r=i=>{if(e.has(i))return e.get(i);const[s,o]=t[i];switch(s){case Mp:case Y5:return n(o,i);case Nc:{const a=n([],i);for(const l of o)a.push(r(l));return a}case hf:{const a=n({},i);for(const[l,c]of o)a[r(l)]=r(c);return a}case Ky:return n(new Date(o),i);case Gy:{const{source:a,flags:l}=o;return n(new RegExp(a,l),i)}case Yy:{const a=n(new Map,i);for(const[l,c]of o)a.set(r(l),r(c));return a}case Xy:{const a=n(new Set,i);for(const l of o)a.add(r(l));return a}case X5:{const{name:a,message:l}=o;return n(new bk[a](l),i)}case Q5:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:a}=new Uint8Array(o);return n(new DataView(a),o)}}return n(new bk[s](o),i)};return r},wk=e=>uX(new Map,e)(0),oa="",{toString:dX}={},{keys:hX}=Object,Wl=e=>{const t=typeof e;if(t!=="object"||!e)return[Mp,t];const n=dX.call(e).slice(8,-1);switch(n){case"Array":return[Nc,oa];case"Object":return[hf,oa];case"Date":return[Ky,oa];case"RegExp":return[Gy,oa];case"Map":return[Yy,oa];case"Set":return[Xy,oa];case"DataView":return[Nc,n]}return n.includes("Array")?[Nc,n]:n.includes("Error")?[X5,n]:[hf,n]},Nd=([e,t])=>e===Mp&&(t==="function"||t==="symbol"),fX=(e,t,n,r)=>{const i=(o,a)=>{const l=r.push(o)-1;return n.set(a,l),l},s=o=>{if(n.has(o))return n.get(o);let[a,l]=Wl(o);switch(a){case Mp:{let u=o;switch(l){case"bigint":a=Q5,u=o.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);u=null;break;case"undefined":return i([Y5],o)}return i([a,u],o)}case Nc:{if(l){let f=o;return l==="DataView"?f=new Uint8Array(o.buffer):l==="ArrayBuffer"&&(f=new Uint8Array(o)),i([l,[...f]],o)}const u=[],d=i([a,u],o);for(const f of o)u.push(s(f));return d}case hf:{if(l)switch(l){case"BigInt":return i([l,o.toString()],o);case"Boolean":case"Number":case"String":return i([l,o.valueOf()],o)}if(t&&"toJSON"in o)return s(o.toJSON());const u=[],d=i([a,u],o);for(const f of hX(o))(e||!Nd(Wl(o[f])))&&u.push([s(f),s(o[f])]);return d}case Ky:return i([a,o.toISOString()],o);case Gy:{const{source:u,flags:d}=o;return i([a,{source:u,flags:d}],o)}case Yy:{const u=[],d=i([a,u],o);for(const[f,p]of o)(e||!(Nd(Wl(f))||Nd(Wl(p))))&&u.push([s(f),s(p)]);return d}case Xy:{const u=[],d=i([a,u],o);for(const f of o)(e||!Nd(Wl(f)))&&u.push(s(f));return d}}const{message:c}=o;return i([a,{name:l,message:c}],o)};return s},Sk=(e,{json:t,lossy:n}={})=>{const r=[];return fX(!(t||n),!!t,new Map,r)(e),r},ff=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?wk(Sk(e,t)):structuredClone(e):(e,t)=>wk(Sk(e,t));function pX(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function mX(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function gX(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||pX,r=e.options.footnoteBackLabel||mX,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[];let l=-1;for(;++l<e.footnoteOrder.length;){const c=e.footnoteById.get(e.footnoteOrder[l]);if(!c)continue;const u=e.all(c),d=String(c.identifier).toUpperCase(),f=El(d.toLowerCase());let p=0;const m=[],v=e.footnoteCounts.get(d);for(;v!==void 0&&++p<=v;){m.length>0&&m.push({type:"text",value:" "});let _=typeof n=="string"?n:n(l,p);typeof _=="string"&&(_={type:"text",value:_}),m.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+f+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,p),className:["data-footnote-backref"]},children:Array.isArray(_)?_:[_]})}const w=u[u.length-1];if(w&&w.type==="element"&&w.tagName==="p"){const _=w.children[w.children.length-1];_&&_.type==="text"?_.value+=" ":w.children.push({type:"text",value:" "}),w.children.push(...m)}else u.push(...m);const x={type:"element",tagName:"li",properties:{id:t+"fn-"+f},children:e.wrap(u,!0)};e.patch(c,x),a.push(x)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...ff(o),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
514
514
  `},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:`
515
- `}]}}const Mp=function(e){if(e==null)return tX;if(typeof e=="function")return Ap(e);if(typeof e=="object")return Array.isArray(e)?ZY(e):JY(e);if(typeof e=="string")return eX(e);throw new Error("Expected function, string, or object as test")};function ZY(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Mp(e[n]);return Ap(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function JY(e){const t=e;return Ap(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function eX(e){return Ap(t);function t(n){return n&&n.type===e}}function Ap(e){return t;function t(n,r,i){return!!(nX(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function tX(){return!0}function nX(e){return e!==null&&typeof e=="object"&&"type"in e}const K5=[],rX=!0,z0=!1,iX="skip";function G5(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=Mp(i),o=r?-1:1;a(e,void 0,[])();function a(l,c,u){const d=l&&typeof l=="object"?l:{};if(typeof d.type=="string"){const p=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(f,"name",{value:"node ("+(l.type+(p?"<"+p+">":""))+")"})}return f;function f(){let p=K5,m,v,w;if((!t||s(l,c,u[u.length-1]||void 0))&&(p=sX(n(l,u)),p[0]===z0))return p;if("children"in l&&l.children){const x=l;if(x.children&&p[0]!==iX)for(v=(r?x.children.length:-1)+o,w=u.concat(x);v>-1&&v<x.children.length;){const _=x.children[v];if(m=a(_,v,w)(),m[0]===z0)return m;v=typeof m[1]=="number"?m[1]:v+o}}return p}}}function sX(e){return Array.isArray(e)?e:typeof e=="number"?[rX,e]:e==null?K5:[e]}function Qy(e,t,n,r){let i,s,o;typeof t=="function"&&typeof n!="function"?(s=void 0,o=t,i=n):(s=t,o=n,i=r),G5(e,s,a,i);function a(l,c){const u=c[c.length-1],d=u?u.children.indexOf(l):void 0;return o(l,d,u)}}const $0={}.hasOwnProperty,oX={};function aX(e,t){const n=t||oX,r=new Map,i=new Map,s=new Map,o={...WY,...n.handlers},a={all:c,applyData:cX,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:o,one:l,options:n,patch:lX,wrap:dX};return Qy(e,function(u){if(u.type==="definition"||u.type==="footnoteDefinition"){const d=u.type==="definition"?r:i,f=String(u.identifier).toUpperCase();d.has(f)||d.set(f,u)}}),a;function l(u,d){const f=u.type,p=a.handlers[f];if($0.call(a.handlers,f)&&p)return p(a,u,d);if(a.options.passThrough&&a.options.passThrough.includes(f)){if("children"in u){const{children:v,...w}=u,x=ff(w);return x.children=a.all(u),x}return ff(u)}return(a.options.unknownHandler||uX)(a,u,d)}function c(u){const d=[];if("children"in u){const f=u.children;let p=-1;for(;++p<f.length;){const m=a.one(f[p],u);if(m){if(p&&f[p-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=bk(m.value)),!Array.isArray(m)&&m.type==="element")){const v=m.children[0];v&&v.type==="text"&&(v.value=bk(v.value))}Array.isArray(m)?d.push(...m):d.push(m)}}}return d}}function lX(e,t){e.position&&(t.position=Xq(e))}function cX(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,s=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const o="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:o}}n.type==="element"&&s&&Object.assign(n.properties,ff(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function uX(e,t){const n=t.data||{},r="value"in t&&!($0.call(n,"hProperties")||$0.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function dX(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
515
+ `}]}}const Ap=function(e){if(e==null)return yX;if(typeof e=="function")return jp(e);if(typeof e=="object")return Array.isArray(e)?vX(e):xX(e);if(typeof e=="string")return _X(e);throw new Error("Expected function, string, or object as test")};function vX(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Ap(e[n]);return jp(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function xX(e){const t=e;return jp(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function _X(e){return jp(t);function t(n){return n&&n.type===e}}function jp(e){return t;function t(n,r,i){return!!(bX(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function yX(){return!0}function bX(e){return e!==null&&typeof e=="object"&&"type"in e}const Z5=[],wX=!0,z0=!1,SX="skip";function J5(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=Ap(i),o=r?-1:1;a(e,void 0,[])();function a(l,c,u){const d=l&&typeof l=="object"?l:{};if(typeof d.type=="string"){const p=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(f,"name",{value:"node ("+(l.type+(p?"<"+p+">":""))+")"})}return f;function f(){let p=Z5,m,v,w;if((!t||s(l,c,u[u.length-1]||void 0))&&(p=kX(n(l,u)),p[0]===z0))return p;if("children"in l&&l.children){const x=l;if(x.children&&p[0]!==SX)for(v=(r?x.children.length:-1)+o,w=u.concat(x);v>-1&&v<x.children.length;){const _=x.children[v];if(m=a(_,v,w)(),m[0]===z0)return m;v=typeof m[1]=="number"?m[1]:v+o}}return p}}}function kX(e){return Array.isArray(e)?e:typeof e=="number"?[wX,e]:e==null?Z5:[e]}function Qy(e,t,n,r){let i,s,o;typeof t=="function"&&typeof n!="function"?(s=void 0,o=t,i=n):(s=t,o=n,i=r),J5(e,s,a,i);function a(l,c){const u=c[c.length-1],d=u?u.children.indexOf(l):void 0;return o(l,d,u)}}const $0={}.hasOwnProperty,CX={};function EX(e,t){const n=t||CX,r=new Map,i=new Map,s=new Map,o={...cX,...n.handlers},a={all:c,applyData:TX,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:o,one:l,options:n,patch:NX,wrap:PX};return Qy(e,function(u){if(u.type==="definition"||u.type==="footnoteDefinition"){const d=u.type==="definition"?r:i,f=String(u.identifier).toUpperCase();d.has(f)||d.set(f,u)}}),a;function l(u,d){const f=u.type,p=a.handlers[f];if($0.call(a.handlers,f)&&p)return p(a,u,d);if(a.options.passThrough&&a.options.passThrough.includes(f)){if("children"in u){const{children:v,...w}=u,x=ff(w);return x.children=a.all(u),x}return ff(u)}return(a.options.unknownHandler||IX)(a,u,d)}function c(u){const d=[];if("children"in u){const f=u.children;let p=-1;for(;++p<f.length;){const m=a.one(f[p],u);if(m){if(p&&f[p-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=kk(m.value)),!Array.isArray(m)&&m.type==="element")){const v=m.children[0];v&&v.type==="text"&&(v.value=kk(v.value))}Array.isArray(m)?d.push(...m):d.push(m)}}}return d}}function NX(e,t){e.position&&(t.position=mK(e))}function TX(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,s=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const o="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:o}}n.type==="element"&&s&&Object.assign(n.properties,ff(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function IX(e,t){const n=t.data||{},r="value"in t&&!($0.call(n,"hProperties")||$0.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function PX(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
516
516
  `});++r<e.length;)r&&n.push({type:"text",value:`
517
517
  `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
518
- `}),n}function bk(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function wk(e,t){const n=aX(e,t),r=n.one(e,void 0),i=QY(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&s.children.push({type:"text",value:`
519
- `},i),s}function hX(e,t){return e&&"run"in e?async function(n,r){const i=wk(n,{file:r,...t});await e.run(i,r)}:function(n,r){return wk(n,{file:r,...e||t})}}function Sk(e){if(e)throw e}var lh=Object.prototype.hasOwnProperty,Y5=Object.prototype.toString,kk=Object.defineProperty,Ck=Object.getOwnPropertyDescriptor,Ek=function(t){return typeof Array.isArray=="function"?Array.isArray(t):Y5.call(t)==="[object Array]"},Nk=function(t){if(!t||Y5.call(t)!=="[object Object]")return!1;var n=lh.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&lh.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var i;for(i in t);return typeof i>"u"||lh.call(t,i)},Tk=function(t,n){kk&&n.name==="__proto__"?kk(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},Ik=function(t,n){if(n==="__proto__")if(lh.call(t,n)){if(Ck)return Ck(t,n).value}else return;return t[n]},fX=function e(){var t,n,r,i,s,o,a=arguments[0],l=1,c=arguments.length,u=!1;for(typeof a=="boolean"&&(u=a,a=arguments[1]||{},l=2),(a==null||typeof a!="object"&&typeof a!="function")&&(a={});l<c;++l)if(t=arguments[l],t!=null)for(n in t)r=Ik(a,n),i=Ik(t,n),a!==i&&(u&&i&&(Nk(i)||(s=Ek(i)))?(s?(s=!1,o=r&&Ek(r)?r:[]):o=r&&Nk(r)?r:{},Tk(a,{name:n,newValue:e(u,o,i)})):typeof i<"u"&&Tk(a,{name:n,newValue:i}));return a};const Qm=mu(fX);function F0(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function pX(){const e=[],t={run:n,use:r};return t;function n(...i){let s=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);a(null,...i);function a(l,...c){const u=e[++s];let d=-1;if(l){o(l);return}for(;++d<i.length;)(c[d]===null||c[d]===void 0)&&(c[d]=i[d]);i=c,u?mX(u,a)(...c):o(null,...c)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function mX(e,t){let n;return r;function r(...o){const a=e.length>o.length;let l;a&&o.push(i);try{l=e.apply(this,o)}catch(c){const u=c;if(a&&n)throw u;return i(u)}a||(l&&l.then&&typeof l.then=="function"?l.then(s,i):l instanceof Error?i(l):s(l))}function i(o,...a){n||(n=!0,t(o,...a))}function s(o){i(null,o)}}const Jr={basename:gX,dirname:vX,extname:xX,join:_X,sep:"/"};function gX(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Lu(e);let n=0,r=-1,i=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,a=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else o<0&&(s=!0,o=i+1),a>-1&&(e.codePointAt(i)===t.codePointAt(a--)?a<0&&(r=i):(a=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function vX(e){if(Lu(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function xX(e){Lu(e);let t=e.length,n=-1,r=0,i=-1,s=0,o;for(;t--;){const a=e.codePointAt(t);if(a===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),a===46?i<0?i=t:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||n<0||s===0||s===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function _X(...e){let t=-1,n;for(;++t<e.length;)Lu(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":yX(n)}function yX(e){Lu(e);const t=e.codePointAt(0)===47;let n=bX(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function bX(e,t){let n="",r=0,i=-1,s=0,o=-1,a,l;for(;++o<=e.length;){if(o<e.length)a=e.codePointAt(o);else{if(a===47)break;a=47}if(a===47){if(!(i===o-1||s===1))if(i!==o-1&&s===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",r=0):(n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/")),i=o,s=0;continue}}else if(n.length>0){n="",r=0,i=o,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,s=0}else a===46&&s>-1?s++:s=-1}return n}function Lu(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const wX={cwd:SX};function SX(){return"/"}function H0(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function kX(e){if(typeof e=="string")e=new URL(e);else if(!H0(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return CX(e)}function CX(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const Zm=["history","path","basename","stem","extname","dirname"];class X5{constructor(t){let n;t?H0(t)?n={path:t}:typeof t=="string"||EX(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":wX.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Zm.length;){const s=Zm[r];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s])}let i;for(i in n)Zm.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Jr.basename(this.path):void 0}set basename(t){eg(t,"basename"),Jm(t,"basename"),this.path=Jr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Jr.dirname(this.path):void 0}set dirname(t){Pk(this.basename,"dirname"),this.path=Jr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Jr.extname(this.path):void 0}set extname(t){if(Jm(t,"extname"),Pk(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Jr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){H0(t)&&(t=kX(t)),eg(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Jr.basename(this.path,this.extname):void 0}set stem(t){eg(t,"stem"),Jm(t,"stem"),this.path=Jr.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new Nn(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Jm(e,t){if(e&&e.includes(Jr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Jr.sep+"`")}function eg(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Pk(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function EX(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const NX=function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s},TX={}.hasOwnProperty;class Zy extends NX{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=pX()}copy(){const t=new Zy;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Qm(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(rg("data",this.frozen),this.namespace[t]=n,this):TX.call(this.namespace,t)&&this.namespace[t]||void 0:t?(rg("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Td(t),r=this.parser||this.Parser;return tg("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),tg("process",this.parser||this.Parser),ng("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,o){const a=Td(t),l=r.parse(a);r.run(l,a,function(u,d,f){if(u||!d||!f)return c(u);const p=d,m=r.stringify(p,f);RX(m)?f.value=m:f.result=m,c(u,f)});function c(u,d){u||!d?o(u):s?s(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),tg("processSync",this.parser||this.Parser),ng("processSync",this.compiler||this.Compiler),this.process(t,i),Mk("processSync","process",n),r;function i(s,o){n=!0,Sk(s),r=o}}run(t,n,r){Rk(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?s(void 0,r):new Promise(s);function s(o,a){const l=Td(n);i.run(t,l,c);function c(u,d,f){const p=d||t;u?a(u):o?o(p):r(void 0,p,f)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),Mk("runSync","run",r),i;function s(o,a){Sk(o),i=a,r=!0}}stringify(t,n){this.freeze();const r=Td(n),i=this.compiler||this.Compiler;return ng("stringify",i),Rk(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(rg("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?a(t):o(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(c){if(typeof c=="function")l(c,[]);else if(typeof c=="object")if(Array.isArray(c)){const[u,...d]=c;l(u,d)}else o(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function o(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(c.plugins),c.settings&&(i.settings=Qm(!0,i.settings,c.settings))}function a(c){let u=-1;if(c!=null)if(Array.isArray(c))for(;++u<c.length;){const d=c[u];s(d)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,u){let d=-1,f=-1;for(;++d<r.length;)if(r[d][0]===c){f=d;break}if(f===-1)r.push([c,...u]);else if(u.length>0){let[p,...m]=u;const v=r[f][1];F0(v)&&F0(p)&&(p=Qm(!0,v,p)),r[f]=[c,p,...m]}}}}const IX=new Zy().freeze();function tg(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function ng(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function rg(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Rk(e){if(!F0(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Mk(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Td(e){return PX(e)?e:new X5(e)}function PX(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function RX(e){return typeof e=="string"||MX(e)}function MX(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const AX="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Ak=[],jk={allowDangerousHtml:!0},jX=/^(https?|ircs?|mailto|xmpp)$/i,LX=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function nl(e){const t=DX(e),n=OX(e);return BX(t.runSync(t.parse(n),n),e)}function DX(e){const t=e.rehypePlugins||Ak,n=e.remarkPlugins||Ak,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...jk}:jk;return IX().use(xY).use(n).use(hX,r).use(t)}function OX(e){const t=e.children||"",n=new X5;return typeof t=="string"&&(n.value=t),n}function BX(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,o=t.skipHtml,a=t.unwrapDisallowed,l=t.urlTransform||Q5;for(const u of LX)Object.hasOwn(t,u.from)&&(""+u.from+(u.to?"use `"+u.to+"` instead":"remove it")+AX+u.id,void 0);return Qy(e,c),tK(e,{Fragment:h.Fragment,components:i,ignoreInvalidStyle:!0,jsx:h.jsx,jsxs:h.jsxs,passKeys:!0,passNode:!0});function c(u,d,f){if(u.type==="raw"&&f&&typeof d=="number")return o?f.children.splice(d,1):f.children[d]={type:"text",value:u.value},d;if(u.type==="element"){let p;for(p in Gm)if(Object.hasOwn(Gm,p)&&Object.hasOwn(u.properties,p)){const m=u.properties[p],v=Gm[p];(v===null||v.includes(u.tagName))&&(u.properties[p]=l(String(m||""),p,u))}}if(u.type==="element"){let p=n?!n.includes(u.tagName):s?s.includes(u.tagName):!1;if(!p&&r&&typeof d=="number"&&(p=!r(u,d,f)),p&&f&&typeof d=="number")return a&&u.children?f.children.splice(d,1,...u.children):f.children.splice(d,1),d}}}function Q5(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||jX.test(e.slice(0,t))?e:""}function Lk(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function zX(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function $X(e,t,n){const i=Mp((n||{}).ignore||[]),s=FX(t);let o=-1;for(;++o<s.length;)G5(e,"text",a);function a(c,u){let d=-1,f;for(;++d<u.length;){const p=u[d],m=f?f.children:void 0;if(i(p,m?m.indexOf(p):void 0,f))return;f=p}if(f)return l(c,u)}function l(c,u){const d=u[u.length-1],f=s[o][0],p=s[o][1];let m=0;const w=d.children.indexOf(c);let x=!1,_=[];f.lastIndex=0;let y=f.exec(c.value);for(;y;){const S=y.index,C={index:y.index,input:y.input,stack:[...u,c]};let k=p(...y,C);if(typeof k=="string"&&(k=k.length>0?{type:"text",value:k}:void 0),k===!1?f.lastIndex=S+1:(m!==S&&_.push({type:"text",value:c.value.slice(m,S)}),Array.isArray(k)?_.push(...k):k&&_.push(k),m=S+y[0].length,x=!0),!f.global)break;y=f.exec(c.value)}return x?(m<c.value.length&&_.push({type:"text",value:c.value.slice(m)}),d.children.splice(w,1,..._)):_=[c],w+_.length}}function FX(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const i=n[r];t.push([HX(i[0]),UX(i[1])])}return t}function HX(e){return typeof e=="string"?new RegExp(zX(e),"g"):e}function UX(e){return typeof e=="function"?e:function(){return e}}const ig="phrasing",sg=["autolink","link","image","label"];function WX(){return{transforms:[QX],enter:{literalAutolink:qX,literalAutolinkEmail:og,literalAutolinkHttp:og,literalAutolinkWww:og},exit:{literalAutolink:XX,literalAutolinkEmail:YX,literalAutolinkHttp:KX,literalAutolinkWww:GX}}}function VX(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:ig,notInConstruct:sg},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:ig,notInConstruct:sg},{character:":",before:"[ps]",after:"\\/",inConstruct:ig,notInConstruct:sg}]}}function qX(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function og(e){this.config.enter.autolinkProtocol.call(this,e)}function KX(e){this.config.exit.autolinkProtocol.call(this,e)}function GX(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function YX(e){this.config.exit.autolinkEmail.call(this,e)}function XX(e){this.exit(e)}function QX(e){$X(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,ZX],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),JX]],{ignore:["link","linkReference"]})}function ZX(e,t,n,r,i){let s="";if(!Z5(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!eQ(n)))return!1;const o=tQ(n+r);if(!o[0])return!1;const a={type:"link",title:null,url:s+t+o[0],children:[{type:"text",value:t+o[0]}]};return o[1]?[a,{type:"text",value:o[1]}]:a}function JX(e,t,n,r){return!Z5(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function eQ(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function tQ(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const i=Lk(e,"(");let s=Lk(e,")");for(;r!==-1&&i>s;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),s++;return[e,n]}function Z5(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Mo(n)||Ip(n))&&(!t||n!==47)}J5.peek=uQ;function nQ(){this.buffer()}function rQ(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function iQ(){this.buffer()}function sQ(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function oQ(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Fr(this.sliceSerialize(e)).toLowerCase(),n.label=t}function aQ(e){this.exit(e)}function lQ(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Fr(this.sliceSerialize(e)).toLowerCase(),n.label=t}function cQ(e){this.exit(e)}function uQ(){return"["}function J5(e,t,n,r){const i=n.createTracker(r);let s=i.move("[^");const o=n.enter("footnoteReference"),a=n.enter("reference");return s+=i.move(n.safe(n.associationId(e),{after:"]",before:s})),a(),o(),s+=i.move("]"),s}function dQ(){return{enter:{gfmFootnoteCallString:nQ,gfmFootnoteCall:rQ,gfmFootnoteDefinitionLabelString:iQ,gfmFootnoteDefinition:sQ},exit:{gfmFootnoteCallString:oQ,gfmFootnoteCall:aQ,gfmFootnoteDefinitionLabelString:lQ,gfmFootnoteDefinition:cQ}}}function hQ(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:J5},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,o){const a=s.createTracker(o);let l=a.move("[^");const c=s.enter("footnoteDefinition"),u=s.enter("label");return l+=a.move(s.safe(s.associationId(r),{before:l,after:"]"})),u(),l+=a.move("]:"),r.children&&r.children.length>0&&(a.shift(4),l+=a.move((t?`
520
- `:" ")+s.indentLines(s.containerFlow(r,a.current()),t?eM:fQ))),c(),l}}function fQ(e,t,n){return t===0?e:eM(e,t,n)}function eM(e,t,n){return(n?"":" ")+e}const pQ=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];tM.peek=_Q;function mQ(){return{canContainEols:["delete"],enter:{strikethrough:vQ},exit:{strikethrough:xQ}}}function gQ(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:pQ}],handlers:{delete:tM}}}function vQ(e){this.enter({type:"delete",children:[]},e)}function xQ(e){this.exit(e)}function tM(e,t,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let o=i.move("~~");return o+=n.containerPhrasing(e,{...i.current(),before:o,after:"~"}),o+=i.move("~~"),s(),o}function _Q(){return"~"}function yQ(e){return e.length}function bQ(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||yQ,s=[],o=[],a=[],l=[];let c=0,u=-1;for(;++u<e.length;){const v=[],w=[];let x=-1;for(e[u].length>c&&(c=e[u].length);++x<e[u].length;){const _=wQ(e[u][x]);if(n.alignDelimiters!==!1){const y=i(_);w[x]=y,(l[x]===void 0||y>l[x])&&(l[x]=y)}v.push(_)}o[u]=v,a[u]=w}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<c;)s[d]=Dk(r[d]);else{const v=Dk(r);for(;++d<c;)s[d]=v}d=-1;const f=[],p=[];for(;++d<c;){const v=s[d];let w="",x="";v===99?(w=":",x=":"):v===108?w=":":v===114&&(x=":");let _=n.alignDelimiters===!1?1:Math.max(1,l[d]-w.length-x.length);const y=w+"-".repeat(_)+x;n.alignDelimiters!==!1&&(_=w.length+_+x.length,_>l[d]&&(l[d]=_),p[d]=_),f[d]=y}o.splice(1,0,f),a.splice(1,0,p),u=-1;const m=[];for(;++u<o.length;){const v=o[u],w=a[u];d=-1;const x=[];for(;++d<c;){const _=v[d]||"";let y="",S="";if(n.alignDelimiters!==!1){const C=l[d]-(w[d]||0),k=s[d];k===114?y=" ".repeat(C):k===99?C%2?(y=" ".repeat(C/2+.5),S=" ".repeat(C/2-.5)):(y=" ".repeat(C/2),S=y):S=" ".repeat(C)}n.delimiterStart!==!1&&!d&&x.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&_==="")&&(n.delimiterStart!==!1||d)&&x.push(" "),n.alignDelimiters!==!1&&x.push(y),x.push(_),n.alignDelimiters!==!1&&x.push(S),n.padding!==!1&&x.push(" "),(n.delimiterEnd!==!1||d!==c-1)&&x.push("|")}m.push(n.delimiterEnd===!1?x.join("").replace(/ +$/,""):x.join(""))}return m.join(`
521
- `)}function wQ(e){return e==null?"":String(e)}function Dk(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function SQ(e,t,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const o=n.indentLines(n.containerFlow(e,s.current()),kQ);return i(),o}function kQ(e,t,n){return">"+(n?"":" ")+e}function CQ(e,t){return Ok(e,t.inConstruct,!0)&&!Ok(e,t.notInConstruct,!1)}function Ok(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function Bk(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
522
- `&&CQ(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
523
- `}function EQ(e,t){const n=String(e);let r=n.indexOf(t),i=r,s=0,o=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>o&&(o=s):s=1,i=r+t.length,r=n.indexOf(t,i);return o}function NQ(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function TQ(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function IQ(e,t,n,r){const i=TQ(n),s=e.value||"",o=i==="`"?"GraveAccent":"Tilde";if(NQ(e,n)){const d=n.enter("codeIndented"),f=n.indentLines(s,PQ);return d(),f}const a=n.createTracker(r),l=i.repeat(Math.max(EQ(s,i)+1,3)),c=n.enter("codeFenced");let u=a.move(l);if(e.lang){const d=n.enter(`codeFencedLang${o}`);u+=a.move(n.safe(e.lang,{before:u,after:" ",encode:["`"],...a.current()})),d()}if(e.lang&&e.meta){const d=n.enter(`codeFencedMeta${o}`);u+=a.move(" "),u+=a.move(n.safe(e.meta,{before:u,after:`
518
+ `}),n}function kk(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Ck(e,t){const n=EX(e,t),r=n.one(e,void 0),i=gX(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&s.children.push({type:"text",value:`
519
+ `},i),s}function RX(e,t){return e&&"run"in e?async function(n,r){const i=Ck(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Ck(n,{file:r,...e||t})}}function Ek(e){if(e)throw e}var lh=Object.prototype.hasOwnProperty,eM=Object.prototype.toString,Nk=Object.defineProperty,Tk=Object.getOwnPropertyDescriptor,Ik=function(t){return typeof Array.isArray=="function"?Array.isArray(t):eM.call(t)==="[object Array]"},Pk=function(t){if(!t||eM.call(t)!=="[object Object]")return!1;var n=lh.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&lh.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var i;for(i in t);return typeof i>"u"||lh.call(t,i)},Rk=function(t,n){Nk&&n.name==="__proto__"?Nk(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},Mk=function(t,n){if(n==="__proto__")if(lh.call(t,n)){if(Tk)return Tk(t,n).value}else return;return t[n]},MX=function e(){var t,n,r,i,s,o,a=arguments[0],l=1,c=arguments.length,u=!1;for(typeof a=="boolean"&&(u=a,a=arguments[1]||{},l=2),(a==null||typeof a!="object"&&typeof a!="function")&&(a={});l<c;++l)if(t=arguments[l],t!=null)for(n in t)r=Mk(a,n),i=Mk(t,n),a!==i&&(u&&i&&(Pk(i)||(s=Ik(i)))?(s?(s=!1,o=r&&Ik(r)?r:[]):o=r&&Pk(r)?r:{},Rk(a,{name:n,newValue:e(u,o,i)})):typeof i<"u"&&Rk(a,{name:n,newValue:i}));return a};const Qm=mu(MX);function F0(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function AX(){const e=[],t={run:n,use:r};return t;function n(...i){let s=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);a(null,...i);function a(l,...c){const u=e[++s];let d=-1;if(l){o(l);return}for(;++d<i.length;)(c[d]===null||c[d]===void 0)&&(c[d]=i[d]);i=c,u?jX(u,a)(...c):o(null,...c)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function jX(e,t){let n;return r;function r(...o){const a=e.length>o.length;let l;a&&o.push(i);try{l=e.apply(this,o)}catch(c){const u=c;if(a&&n)throw u;return i(u)}a||(l&&l.then&&typeof l.then=="function"?l.then(s,i):l instanceof Error?i(l):s(l))}function i(o,...a){n||(n=!0,t(o,...a))}function s(o){i(null,o)}}const Jr={basename:LX,dirname:DX,extname:OX,join:BX,sep:"/"};function LX(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Lu(e);let n=0,r=-1,i=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,a=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else o<0&&(s=!0,o=i+1),a>-1&&(e.codePointAt(i)===t.codePointAt(a--)?a<0&&(r=i):(a=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function DX(e){if(Lu(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function OX(e){Lu(e);let t=e.length,n=-1,r=0,i=-1,s=0,o;for(;t--;){const a=e.codePointAt(t);if(a===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),a===46?i<0?i=t:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||n<0||s===0||s===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function BX(...e){let t=-1,n;for(;++t<e.length;)Lu(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":zX(n)}function zX(e){Lu(e);const t=e.codePointAt(0)===47;let n=$X(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function $X(e,t){let n="",r=0,i=-1,s=0,o=-1,a,l;for(;++o<=e.length;){if(o<e.length)a=e.codePointAt(o);else{if(a===47)break;a=47}if(a===47){if(!(i===o-1||s===1))if(i!==o-1&&s===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",r=0):(n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/")),i=o,s=0;continue}}else if(n.length>0){n="",r=0,i=o,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,s=0}else a===46&&s>-1?s++:s=-1}return n}function Lu(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const FX={cwd:HX};function HX(){return"/"}function H0(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function UX(e){if(typeof e=="string")e=new URL(e);else if(!H0(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return WX(e)}function WX(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const Zm=["history","path","basename","stem","extname","dirname"];class tM{constructor(t){let n;t?H0(t)?n={path:t}:typeof t=="string"||VX(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":FX.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Zm.length;){const s=Zm[r];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s])}let i;for(i in n)Zm.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Jr.basename(this.path):void 0}set basename(t){eg(t,"basename"),Jm(t,"basename"),this.path=Jr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Jr.dirname(this.path):void 0}set dirname(t){Ak(this.basename,"dirname"),this.path=Jr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Jr.extname(this.path):void 0}set extname(t){if(Jm(t,"extname"),Ak(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Jr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){H0(t)&&(t=UX(t)),eg(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Jr.basename(this.path,this.extname):void 0}set stem(t){eg(t,"stem"),Jm(t,"stem"),this.path=Jr.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new Nn(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Jm(e,t){if(e&&e.includes(Jr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Jr.sep+"`")}function eg(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Ak(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function VX(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const qX=function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s},KX={}.hasOwnProperty;class Zy extends qX{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=AX()}copy(){const t=new Zy;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Qm(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(rg("data",this.frozen),this.namespace[t]=n,this):KX.call(this.namespace,t)&&this.namespace[t]||void 0:t?(rg("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Td(t),r=this.parser||this.Parser;return tg("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),tg("process",this.parser||this.Parser),ng("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,o){const a=Td(t),l=r.parse(a);r.run(l,a,function(u,d,f){if(u||!d||!f)return c(u);const p=d,m=r.stringify(p,f);XX(m)?f.value=m:f.result=m,c(u,f)});function c(u,d){u||!d?o(u):s?s(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),tg("processSync",this.parser||this.Parser),ng("processSync",this.compiler||this.Compiler),this.process(t,i),Lk("processSync","process",n),r;function i(s,o){n=!0,Ek(s),r=o}}run(t,n,r){jk(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?s(void 0,r):new Promise(s);function s(o,a){const l=Td(n);i.run(t,l,c);function c(u,d,f){const p=d||t;u?a(u):o?o(p):r(void 0,p,f)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),Lk("runSync","run",r),i;function s(o,a){Ek(o),i=a,r=!0}}stringify(t,n){this.freeze();const r=Td(n),i=this.compiler||this.Compiler;return ng("stringify",i),jk(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(rg("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?a(t):o(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(c){if(typeof c=="function")l(c,[]);else if(typeof c=="object")if(Array.isArray(c)){const[u,...d]=c;l(u,d)}else o(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function o(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(c.plugins),c.settings&&(i.settings=Qm(!0,i.settings,c.settings))}function a(c){let u=-1;if(c!=null)if(Array.isArray(c))for(;++u<c.length;){const d=c[u];s(d)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,u){let d=-1,f=-1;for(;++d<r.length;)if(r[d][0]===c){f=d;break}if(f===-1)r.push([c,...u]);else if(u.length>0){let[p,...m]=u;const v=r[f][1];F0(v)&&F0(p)&&(p=Qm(!0,v,p)),r[f]=[c,p,...m]}}}}const GX=new Zy().freeze();function tg(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function ng(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function rg(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function jk(e){if(!F0(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Lk(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Td(e){return YX(e)?e:new tM(e)}function YX(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function XX(e){return typeof e=="string"||QX(e)}function QX(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const ZX="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Dk=[],Ok={allowDangerousHtml:!0},JX=/^(https?|ircs?|mailto|xmpp)$/i,eQ=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function nl(e){const t=tQ(e),n=nQ(e);return rQ(t.runSync(t.parse(n),n),e)}function tQ(e){const t=e.rehypePlugins||Dk,n=e.remarkPlugins||Dk,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Ok}:Ok;return GX().use(OY).use(n).use(RX,r).use(t)}function nQ(e){const t=e.children||"",n=new tM;return typeof t=="string"&&(n.value=t),n}function rQ(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,o=t.skipHtml,a=t.unwrapDisallowed,l=t.urlTransform||nM;for(const u of eQ)Object.hasOwn(t,u.from)&&(""+u.from+(u.to?"use `"+u.to+"` instead":"remove it")+ZX+u.id,void 0);return Qy(e,c),yK(e,{Fragment:h.Fragment,components:i,ignoreInvalidStyle:!0,jsx:h.jsx,jsxs:h.jsxs,passKeys:!0,passNode:!0});function c(u,d,f){if(u.type==="raw"&&f&&typeof d=="number")return o?f.children.splice(d,1):f.children[d]={type:"text",value:u.value},d;if(u.type==="element"){let p;for(p in Gm)if(Object.hasOwn(Gm,p)&&Object.hasOwn(u.properties,p)){const m=u.properties[p],v=Gm[p];(v===null||v.includes(u.tagName))&&(u.properties[p]=l(String(m||""),p,u))}}if(u.type==="element"){let p=n?!n.includes(u.tagName):s?s.includes(u.tagName):!1;if(!p&&r&&typeof d=="number"&&(p=!r(u,d,f)),p&&f&&typeof d=="number")return a&&u.children?f.children.splice(d,1,...u.children):f.children.splice(d,1),d}}}function nM(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||JX.test(e.slice(0,t))?e:""}function Bk(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function iQ(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function sQ(e,t,n){const i=Ap((n||{}).ignore||[]),s=oQ(t);let o=-1;for(;++o<s.length;)J5(e,"text",a);function a(c,u){let d=-1,f;for(;++d<u.length;){const p=u[d],m=f?f.children:void 0;if(i(p,m?m.indexOf(p):void 0,f))return;f=p}if(f)return l(c,u)}function l(c,u){const d=u[u.length-1],f=s[o][0],p=s[o][1];let m=0;const w=d.children.indexOf(c);let x=!1,_=[];f.lastIndex=0;let y=f.exec(c.value);for(;y;){const S=y.index,C={index:y.index,input:y.input,stack:[...u,c]};let k=p(...y,C);if(typeof k=="string"&&(k=k.length>0?{type:"text",value:k}:void 0),k===!1?f.lastIndex=S+1:(m!==S&&_.push({type:"text",value:c.value.slice(m,S)}),Array.isArray(k)?_.push(...k):k&&_.push(k),m=S+y[0].length,x=!0),!f.global)break;y=f.exec(c.value)}return x?(m<c.value.length&&_.push({type:"text",value:c.value.slice(m)}),d.children.splice(w,1,..._)):_=[c],w+_.length}}function oQ(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const i=n[r];t.push([aQ(i[0]),lQ(i[1])])}return t}function aQ(e){return typeof e=="string"?new RegExp(iQ(e),"g"):e}function lQ(e){return typeof e=="function"?e:function(){return e}}const ig="phrasing",sg=["autolink","link","image","label"];function cQ(){return{transforms:[gQ],enter:{literalAutolink:dQ,literalAutolinkEmail:og,literalAutolinkHttp:og,literalAutolinkWww:og},exit:{literalAutolink:mQ,literalAutolinkEmail:pQ,literalAutolinkHttp:hQ,literalAutolinkWww:fQ}}}function uQ(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:ig,notInConstruct:sg},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:ig,notInConstruct:sg},{character:":",before:"[ps]",after:"\\/",inConstruct:ig,notInConstruct:sg}]}}function dQ(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function og(e){this.config.enter.autolinkProtocol.call(this,e)}function hQ(e){this.config.exit.autolinkProtocol.call(this,e)}function fQ(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function pQ(e){this.config.exit.autolinkEmail.call(this,e)}function mQ(e){this.exit(e)}function gQ(e){sQ(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,vQ],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),xQ]],{ignore:["link","linkReference"]})}function vQ(e,t,n,r,i){let s="";if(!rM(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!_Q(n)))return!1;const o=yQ(n+r);if(!o[0])return!1;const a={type:"link",title:null,url:s+t+o[0],children:[{type:"text",value:t+o[0]}]};return o[1]?[a,{type:"text",value:o[1]}]:a}function xQ(e,t,n,r){return!rM(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function _Q(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function yQ(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const i=Bk(e,"(");let s=Bk(e,")");for(;r!==-1&&i>s;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),s++;return[e,n]}function rM(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Mo(n)||Pp(n))&&(!t||n!==47)}iM.peek=IQ;function bQ(){this.buffer()}function wQ(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function SQ(){this.buffer()}function kQ(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function CQ(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Fr(this.sliceSerialize(e)).toLowerCase(),n.label=t}function EQ(e){this.exit(e)}function NQ(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Fr(this.sliceSerialize(e)).toLowerCase(),n.label=t}function TQ(e){this.exit(e)}function IQ(){return"["}function iM(e,t,n,r){const i=n.createTracker(r);let s=i.move("[^");const o=n.enter("footnoteReference"),a=n.enter("reference");return s+=i.move(n.safe(n.associationId(e),{after:"]",before:s})),a(),o(),s+=i.move("]"),s}function PQ(){return{enter:{gfmFootnoteCallString:bQ,gfmFootnoteCall:wQ,gfmFootnoteDefinitionLabelString:SQ,gfmFootnoteDefinition:kQ},exit:{gfmFootnoteCallString:CQ,gfmFootnoteCall:EQ,gfmFootnoteDefinitionLabelString:NQ,gfmFootnoteDefinition:TQ}}}function RQ(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:iM},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,o){const a=s.createTracker(o);let l=a.move("[^");const c=s.enter("footnoteDefinition"),u=s.enter("label");return l+=a.move(s.safe(s.associationId(r),{before:l,after:"]"})),u(),l+=a.move("]:"),r.children&&r.children.length>0&&(a.shift(4),l+=a.move((t?`
520
+ `:" ")+s.indentLines(s.containerFlow(r,a.current()),t?sM:MQ))),c(),l}}function MQ(e,t,n){return t===0?e:sM(e,t,n)}function sM(e,t,n){return(n?"":" ")+e}const AQ=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];oM.peek=BQ;function jQ(){return{canContainEols:["delete"],enter:{strikethrough:DQ},exit:{strikethrough:OQ}}}function LQ(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:AQ}],handlers:{delete:oM}}}function DQ(e){this.enter({type:"delete",children:[]},e)}function OQ(e){this.exit(e)}function oM(e,t,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let o=i.move("~~");return o+=n.containerPhrasing(e,{...i.current(),before:o,after:"~"}),o+=i.move("~~"),s(),o}function BQ(){return"~"}function zQ(e){return e.length}function $Q(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||zQ,s=[],o=[],a=[],l=[];let c=0,u=-1;for(;++u<e.length;){const v=[],w=[];let x=-1;for(e[u].length>c&&(c=e[u].length);++x<e[u].length;){const _=FQ(e[u][x]);if(n.alignDelimiters!==!1){const y=i(_);w[x]=y,(l[x]===void 0||y>l[x])&&(l[x]=y)}v.push(_)}o[u]=v,a[u]=w}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<c;)s[d]=zk(r[d]);else{const v=zk(r);for(;++d<c;)s[d]=v}d=-1;const f=[],p=[];for(;++d<c;){const v=s[d];let w="",x="";v===99?(w=":",x=":"):v===108?w=":":v===114&&(x=":");let _=n.alignDelimiters===!1?1:Math.max(1,l[d]-w.length-x.length);const y=w+"-".repeat(_)+x;n.alignDelimiters!==!1&&(_=w.length+_+x.length,_>l[d]&&(l[d]=_),p[d]=_),f[d]=y}o.splice(1,0,f),a.splice(1,0,p),u=-1;const m=[];for(;++u<o.length;){const v=o[u],w=a[u];d=-1;const x=[];for(;++d<c;){const _=v[d]||"";let y="",S="";if(n.alignDelimiters!==!1){const C=l[d]-(w[d]||0),k=s[d];k===114?y=" ".repeat(C):k===99?C%2?(y=" ".repeat(C/2+.5),S=" ".repeat(C/2-.5)):(y=" ".repeat(C/2),S=y):S=" ".repeat(C)}n.delimiterStart!==!1&&!d&&x.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&_==="")&&(n.delimiterStart!==!1||d)&&x.push(" "),n.alignDelimiters!==!1&&x.push(y),x.push(_),n.alignDelimiters!==!1&&x.push(S),n.padding!==!1&&x.push(" "),(n.delimiterEnd!==!1||d!==c-1)&&x.push("|")}m.push(n.delimiterEnd===!1?x.join("").replace(/ +$/,""):x.join(""))}return m.join(`
521
+ `)}function FQ(e){return e==null?"":String(e)}function zk(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function HQ(e,t,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const o=n.indentLines(n.containerFlow(e,s.current()),UQ);return i(),o}function UQ(e,t,n){return">"+(n?"":" ")+e}function WQ(e,t){return $k(e,t.inConstruct,!0)&&!$k(e,t.notInConstruct,!1)}function $k(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function Fk(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
522
+ `&&WQ(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
523
+ `}function VQ(e,t){const n=String(e);let r=n.indexOf(t),i=r,s=0,o=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>o&&(o=s):s=1,i=r+t.length,r=n.indexOf(t,i);return o}function qQ(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function KQ(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function GQ(e,t,n,r){const i=KQ(n),s=e.value||"",o=i==="`"?"GraveAccent":"Tilde";if(qQ(e,n)){const d=n.enter("codeIndented"),f=n.indentLines(s,YQ);return d(),f}const a=n.createTracker(r),l=i.repeat(Math.max(VQ(s,i)+1,3)),c=n.enter("codeFenced");let u=a.move(l);if(e.lang){const d=n.enter(`codeFencedLang${o}`);u+=a.move(n.safe(e.lang,{before:u,after:" ",encode:["`"],...a.current()})),d()}if(e.lang&&e.meta){const d=n.enter(`codeFencedMeta${o}`);u+=a.move(" "),u+=a.move(n.safe(e.meta,{before:u,after:`
524
524
  `,encode:["`"],...a.current()})),d()}return u+=a.move(`
525
525
  `),s&&(u+=a.move(s+`
526
- `)),u+=a.move(l),c(),u}function PQ(e,t,n){return(n?"":" ")+e}function Jy(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function RQ(e,t,n,r){const i=Jy(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("definition");let a=n.enter("label");const l=n.createTracker(r);let c=l.move("[");return c+=l.move(n.safe(n.associationId(e),{before:c,after:"]",...l.current()})),c+=l.move("]: "),a(),!e.url||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(a=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":`
527
- `,...l.current()}))),a(),e.title&&(a=n.enter(`title${s}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),a()),o(),c}function MQ(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function uu(e){return"&#x"+e.toString(16).toUpperCase()+";"}function pf(e,t,n){const r=tl(e),i=tl(t);return r===void 0?i===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}nM.peek=AQ;function nM(e,t,n,r){const i=MQ(n),s=n.enter("emphasis"),o=n.createTracker(r),a=o.move(i);let l=o.move(n.containerPhrasing(e,{after:i,before:a,...o.current()}));const c=l.charCodeAt(0),u=pf(r.before.charCodeAt(r.before.length-1),c,i);u.inside&&(l=uu(c)+l.slice(1));const d=l.charCodeAt(l.length-1),f=pf(r.after.charCodeAt(0),d,i);f.inside&&(l=l.slice(0,-1)+uu(d));const p=o.move(i);return s(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},a+l+p}function AQ(e,t,n){return n.options.emphasis||"*"}function jQ(e,t){let n=!1;return Qy(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,z0}),!!((!e.depth||e.depth<3)&&Wy(e)&&(t.options.setext||n))}function LQ(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(jQ(e,n)){const u=n.enter("headingSetext"),d=n.enter("phrasing"),f=n.containerPhrasing(e,{...s.current(),before:`
526
+ `)),u+=a.move(l),c(),u}function YQ(e,t,n){return(n?"":" ")+e}function Jy(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function XQ(e,t,n,r){const i=Jy(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("definition");let a=n.enter("label");const l=n.createTracker(r);let c=l.move("[");return c+=l.move(n.safe(n.associationId(e),{before:c,after:"]",...l.current()})),c+=l.move("]: "),a(),!e.url||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(a=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":`
527
+ `,...l.current()}))),a(),e.title&&(a=n.enter(`title${s}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),a()),o(),c}function QQ(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function uu(e){return"&#x"+e.toString(16).toUpperCase()+";"}function pf(e,t,n){const r=tl(e),i=tl(t);return r===void 0?i===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}aM.peek=ZQ;function aM(e,t,n,r){const i=QQ(n),s=n.enter("emphasis"),o=n.createTracker(r),a=o.move(i);let l=o.move(n.containerPhrasing(e,{after:i,before:a,...o.current()}));const c=l.charCodeAt(0),u=pf(r.before.charCodeAt(r.before.length-1),c,i);u.inside&&(l=uu(c)+l.slice(1));const d=l.charCodeAt(l.length-1),f=pf(r.after.charCodeAt(0),d,i);f.inside&&(l=l.slice(0,-1)+uu(d));const p=o.move(i);return s(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},a+l+p}function ZQ(e,t,n){return n.options.emphasis||"*"}function JQ(e,t){let n=!1;return Qy(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,z0}),!!((!e.depth||e.depth<3)&&Wy(e)&&(t.options.setext||n))}function eZ(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(JQ(e,n)){const u=n.enter("headingSetext"),d=n.enter("phrasing"),f=n.containerPhrasing(e,{...s.current(),before:`
528
528
  `,after:`
529
529
  `});return d(),u(),f+`
530
530
  `+(i===1?"=":"-").repeat(f.length-(Math.max(f.lastIndexOf("\r"),f.lastIndexOf(`
531
531
  `))+1))}const o="#".repeat(i),a=n.enter("headingAtx"),l=n.enter("phrasing");s.move(o+" ");let c=n.containerPhrasing(e,{before:"# ",after:`
532
- `,...s.current()});return/^[\t ]/.test(c)&&(c=uu(c.charCodeAt(0))+c.slice(1)),c=c?o+" "+c:o,n.options.closeAtx&&(c+=" "+o),l(),a(),c}rM.peek=DQ;function rM(e){return e.value||""}function DQ(){return"<"}iM.peek=OQ;function iM(e,t,n,r){const i=Jy(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("image");let a=n.enter("label");const l=n.createTracker(r);let c=l.move("![");return c+=l.move(n.safe(e.alt,{before:c,after:"]",...l.current()})),c+=l.move("]("),a(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(a=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),a(),e.title&&(a=n.enter(`title${s}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),a()),c+=l.move(")"),o(),c}function OQ(){return"!"}sM.peek=BQ;function sM(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("![");const c=n.safe(e.alt,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),o();const u=n.stack;n.stack=[],o=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return o(),n.stack=u,s(),i==="full"||!c||c!==d?l+=a.move(d+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function BQ(){return"!"}oM.peek=zQ;function oM(e,t,n){let r=e.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const o=n.unsafe[s],a=n.compilePattern(o);let l;if(o.atBreak)for(;l=a.exec(r);){let c=l.index;r.charCodeAt(c)===10&&r.charCodeAt(c-1)===13&&c--,r=r.slice(0,c)+" "+r.slice(l.index+1)}}return i+r+i}function zQ(){return"`"}function aM(e,t){const n=Wy(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}lM.peek=$Q;function lM(e,t,n,r){const i=Jy(n),s=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let a,l;if(aM(e,n)){const u=n.stack;n.stack=[],a=n.enter("autolink");let d=o.move("<");return d+=o.move(n.containerPhrasing(e,{before:d,after:">",...o.current()})),d+=o.move(">"),a(),n.stack=u,d}a=n.enter("link"),l=n.enter("label");let c=o.move("[");return c+=o.move(n.containerPhrasing(e,{before:c,after:"](",...o.current()})),c+=o.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),c+=o.move("<"),c+=o.move(n.safe(e.url,{before:c,after:">",...o.current()})),c+=o.move(">")):(l=n.enter("destinationRaw"),c+=o.move(n.safe(e.url,{before:c,after:e.title?" ":")",...o.current()}))),l(),e.title&&(l=n.enter(`title${s}`),c+=o.move(" "+i),c+=o.move(n.safe(e.title,{before:c,after:i,...o.current()})),c+=o.move(i),l()),c+=o.move(")"),a(),c}function $Q(e,t,n){return aM(e,n)?"<":"["}cM.peek=FQ;function cM(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("[");const c=n.containerPhrasing(e,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),o();const u=n.stack;n.stack=[],o=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return o(),n.stack=u,s(),i==="full"||!c||c!==d?l+=a.move(d+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function FQ(){return"["}function e1(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function HQ(e){const t=e1(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function UQ(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function uM(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function WQ(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let o=e.ordered?UQ(n):e1(n);const a=e.ordered?o==="."?")":".":HQ(n);let l=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){const u=e.children?e.children[0]:void 0;if((o==="*"||o==="-")&&u&&(!u.children||!u.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),uM(n)===o&&u){let d=-1;for(;++d<e.children.length;){const f=e.children[d];if(f&&f.type==="listItem"&&f.children&&f.children[0]&&f.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(o=a),n.bulletCurrent=o;const c=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=s,i(),c}function VQ(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function qQ(e,t,n,r){const i=VQ(n);let s=n.bulletCurrent||e1(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let o=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);const a=n.createTracker(r);a.move(s+" ".repeat(o-s.length)),a.shift(o);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,a.current()),u);return l(),c;function u(d,f,p){return f?(p?"":" ".repeat(o))+d:(p?s:s+" ".repeat(o-s.length))+d}}function KQ(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),o=n.containerPhrasing(e,r);return s(),i(),o}const GQ=Mp(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function YQ(e,t,n,r){return(e.children.some(function(o){return GQ(o)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function XQ(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}dM.peek=QQ;function dM(e,t,n,r){const i=XQ(n),s=n.enter("strong"),o=n.createTracker(r),a=o.move(i+i);let l=o.move(n.containerPhrasing(e,{after:i,before:a,...o.current()}));const c=l.charCodeAt(0),u=pf(r.before.charCodeAt(r.before.length-1),c,i);u.inside&&(l=uu(c)+l.slice(1));const d=l.charCodeAt(l.length-1),f=pf(r.after.charCodeAt(0),d,i);f.inside&&(l=l.slice(0,-1)+uu(d));const p=o.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},a+l+p}function QQ(e,t,n){return n.options.strong||"*"}function ZQ(e,t,n,r){return n.safe(e.value,r)}function JQ(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function eZ(e,t,n){const r=(uM(n)+(n.options.ruleSpaces?" ":"")).repeat(JQ(n));return n.options.ruleSpaces?r.slice(0,-1):r}const hM={blockquote:SQ,break:Bk,code:IQ,definition:RQ,emphasis:nM,hardBreak:Bk,heading:LQ,html:rM,image:iM,imageReference:sM,inlineCode:oM,link:lM,linkReference:cM,list:WQ,listItem:qQ,paragraph:KQ,root:YQ,strong:dM,text:ZQ,thematicBreak:eZ};function tZ(){return{enter:{table:nZ,tableData:zk,tableHeader:zk,tableRow:iZ},exit:{codeText:sZ,table:rZ,tableData:ag,tableHeader:ag,tableRow:ag}}}function nZ(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function rZ(e){this.exit(e),this.data.inTable=void 0}function iZ(e){this.enter({type:"tableRow",children:[]},e)}function ag(e){this.exit(e)}function zk(e){this.enter({type:"tableCell",children:[]},e)}function sZ(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,oZ));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function oZ(e,t){return t==="|"?t:e}function aZ(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
532
+ `,...s.current()});return/^[\t ]/.test(c)&&(c=uu(c.charCodeAt(0))+c.slice(1)),c=c?o+" "+c:o,n.options.closeAtx&&(c+=" "+o),l(),a(),c}lM.peek=tZ;function lM(e){return e.value||""}function tZ(){return"<"}cM.peek=nZ;function cM(e,t,n,r){const i=Jy(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("image");let a=n.enter("label");const l=n.createTracker(r);let c=l.move("![");return c+=l.move(n.safe(e.alt,{before:c,after:"]",...l.current()})),c+=l.move("]("),a(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(a=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),a(),e.title&&(a=n.enter(`title${s}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),a()),c+=l.move(")"),o(),c}function nZ(){return"!"}uM.peek=rZ;function uM(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("![");const c=n.safe(e.alt,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),o();const u=n.stack;n.stack=[],o=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return o(),n.stack=u,s(),i==="full"||!c||c!==d?l+=a.move(d+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function rZ(){return"!"}dM.peek=iZ;function dM(e,t,n){let r=e.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const o=n.unsafe[s],a=n.compilePattern(o);let l;if(o.atBreak)for(;l=a.exec(r);){let c=l.index;r.charCodeAt(c)===10&&r.charCodeAt(c-1)===13&&c--,r=r.slice(0,c)+" "+r.slice(l.index+1)}}return i+r+i}function iZ(){return"`"}function hM(e,t){const n=Wy(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}fM.peek=sZ;function fM(e,t,n,r){const i=Jy(n),s=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let a,l;if(hM(e,n)){const u=n.stack;n.stack=[],a=n.enter("autolink");let d=o.move("<");return d+=o.move(n.containerPhrasing(e,{before:d,after:">",...o.current()})),d+=o.move(">"),a(),n.stack=u,d}a=n.enter("link"),l=n.enter("label");let c=o.move("[");return c+=o.move(n.containerPhrasing(e,{before:c,after:"](",...o.current()})),c+=o.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),c+=o.move("<"),c+=o.move(n.safe(e.url,{before:c,after:">",...o.current()})),c+=o.move(">")):(l=n.enter("destinationRaw"),c+=o.move(n.safe(e.url,{before:c,after:e.title?" ":")",...o.current()}))),l(),e.title&&(l=n.enter(`title${s}`),c+=o.move(" "+i),c+=o.move(n.safe(e.title,{before:c,after:i,...o.current()})),c+=o.move(i),l()),c+=o.move(")"),a(),c}function sZ(e,t,n){return hM(e,n)?"<":"["}pM.peek=oZ;function pM(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("[");const c=n.containerPhrasing(e,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),o();const u=n.stack;n.stack=[],o=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return o(),n.stack=u,s(),i==="full"||!c||c!==d?l+=a.move(d+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function oZ(){return"["}function e1(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function aZ(e){const t=e1(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function lZ(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function mM(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function cZ(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let o=e.ordered?lZ(n):e1(n);const a=e.ordered?o==="."?")":".":aZ(n);let l=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){const u=e.children?e.children[0]:void 0;if((o==="*"||o==="-")&&u&&(!u.children||!u.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),mM(n)===o&&u){let d=-1;for(;++d<e.children.length;){const f=e.children[d];if(f&&f.type==="listItem"&&f.children&&f.children[0]&&f.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(o=a),n.bulletCurrent=o;const c=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=s,i(),c}function uZ(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function dZ(e,t,n,r){const i=uZ(n);let s=n.bulletCurrent||e1(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let o=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);const a=n.createTracker(r);a.move(s+" ".repeat(o-s.length)),a.shift(o);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,a.current()),u);return l(),c;function u(d,f,p){return f?(p?"":" ".repeat(o))+d:(p?s:s+" ".repeat(o-s.length))+d}}function hZ(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),o=n.containerPhrasing(e,r);return s(),i(),o}const fZ=Ap(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function pZ(e,t,n,r){return(e.children.some(function(o){return fZ(o)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function mZ(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}gM.peek=gZ;function gM(e,t,n,r){const i=mZ(n),s=n.enter("strong"),o=n.createTracker(r),a=o.move(i+i);let l=o.move(n.containerPhrasing(e,{after:i,before:a,...o.current()}));const c=l.charCodeAt(0),u=pf(r.before.charCodeAt(r.before.length-1),c,i);u.inside&&(l=uu(c)+l.slice(1));const d=l.charCodeAt(l.length-1),f=pf(r.after.charCodeAt(0),d,i);f.inside&&(l=l.slice(0,-1)+uu(d));const p=o.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},a+l+p}function gZ(e,t,n){return n.options.strong||"*"}function vZ(e,t,n,r){return n.safe(e.value,r)}function xZ(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function _Z(e,t,n){const r=(mM(n)+(n.options.ruleSpaces?" ":"")).repeat(xZ(n));return n.options.ruleSpaces?r.slice(0,-1):r}const vM={blockquote:HQ,break:Fk,code:GQ,definition:XQ,emphasis:aM,hardBreak:Fk,heading:eZ,html:lM,image:cM,imageReference:uM,inlineCode:dM,link:fM,linkReference:pM,list:cZ,listItem:dZ,paragraph:hZ,root:pZ,strong:gM,text:vZ,thematicBreak:_Z};function yZ(){return{enter:{table:bZ,tableData:Hk,tableHeader:Hk,tableRow:SZ},exit:{codeText:kZ,table:wZ,tableData:ag,tableHeader:ag,tableRow:ag}}}function bZ(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function wZ(e){this.exit(e),this.data.inTable=void 0}function SZ(e){this.enter({type:"tableRow",children:[]},e)}function ag(e){this.exit(e)}function Hk(e){this.enter({type:"tableCell",children:[]},e)}function kZ(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,CZ));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function CZ(e,t){return t==="|"?t:e}function EZ(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
533
533
  `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:f,table:o,tableCell:l,tableRow:a}};function o(p,m,v,w){return c(u(p,v,w),p.align)}function a(p,m,v,w){const x=d(p,v,w),_=c([x]);return _.slice(0,_.indexOf(`
534
- `))}function l(p,m,v,w){const x=v.enter("tableCell"),_=v.enter("phrasing"),y=v.containerPhrasing(p,{...w,before:s,after:s});return _(),x(),y}function c(p,m){return bQ(p,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function u(p,m,v){const w=p.children;let x=-1;const _=[],y=m.enter("table");for(;++x<w.length;)_[x]=d(w[x],m,v);return y(),_}function d(p,m,v){const w=p.children;let x=-1;const _=[],y=m.enter("tableRow");for(;++x<w.length;)_[x]=l(w[x],p,m,v);return y(),_}function f(p,m,v){let w=hM.inlineCode(p,m,v);return v.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function lZ(){return{exit:{taskListCheckValueChecked:$k,taskListCheckValueUnchecked:$k,paragraph:uZ}}}function cZ(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:dZ}}}function $k(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function uZ(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,o;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function dZ(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(o);let l=hM.listItem(e,t,n,{...r,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(u){return u+o}}function hZ(){return[WX(),dQ(),mQ(),tZ(),lZ()]}function fZ(e){return{extensions:[VX(),hQ(e),gQ(),aZ(e),cZ()]}}const pZ={tokenize:yZ,partial:!0},fM={tokenize:bZ,partial:!0},pM={tokenize:wZ,partial:!0},mM={tokenize:SZ,partial:!0},mZ={tokenize:kZ,partial:!0},gM={name:"wwwAutolink",tokenize:xZ,previous:xM},vM={name:"protocolAutolink",tokenize:_Z,previous:_M},es={name:"emailAutolink",tokenize:vZ,previous:yM},bi={};function gZ(){return{text:bi}}let to=48;for(;to<123;)bi[to]=es,to++,to===58?to=65:to===91&&(to=97);bi[43]=es;bi[45]=es;bi[46]=es;bi[95]=es;bi[72]=[es,vM];bi[104]=[es,vM];bi[87]=[es,gM];bi[119]=[es,gM];function vZ(e,t,n){const r=this;let i,s;return o;function o(d){return!U0(d)||!yM.call(r,r.previous)||t1(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(d))}function a(d){return U0(d)?(e.consume(d),a):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(mZ,u,c)(d):d===45||d===95||kn(d)?(s=!0,e.consume(d),l):u(d)}function c(d){return e.consume(d),i=!0,l}function u(d){return s&&i&&Rn(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function xZ(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!xM.call(r,r.previous)||t1(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(pZ,e.attempt(fM,e.attempt(pM,s),n),n)(o))}function s(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function _Z(e,t,n){const r=this;let i="",s=!1;return o;function o(d){return(d===72||d===104)&&_M.call(r,r.previous)&&!t1(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),e.consume(d),a):n(d)}function a(d){if(Rn(d)&&i.length<5)return i+=String.fromCodePoint(d),e.consume(d),a;if(d===58){const f=i.toLowerCase();if(f==="http"||f==="https")return e.consume(d),l}return n(d)}function l(d){return d===47?(e.consume(d),s?c:(s=!0,l)):n(d)}function c(d){return d===null||df(d)||ct(d)||Mo(d)||Ip(d)?n(d):e.attempt(fM,e.attempt(pM,u),n)(d)}function u(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function yZ(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),s):n(o)}function s(o){return o===null?n(o):t(o)}}function bZ(e,t,n){let r,i,s;return o;function o(c){return c===46||c===95?e.check(mM,l,a)(c):c===null||ct(c)||Mo(c)||c!==45&&Ip(c)?l(c):(s=!0,e.consume(c),o)}function a(c){return c===95?r=!0:(i=r,r=void 0),e.consume(c),o}function l(c){return i||r||!s?n(c):t(c)}}function wZ(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(mM,t,s)(o):o===null||ct(o)||Mo(o)?t(o):(e.consume(o),i)}function s(o){return o===41&&r++,e.consume(o),i}}function SZ(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),s):a===93?(e.consume(a),i):a===60||a===null||ct(a)||Mo(a)?t(a):n(a)}function i(a){return a===null||a===40||a===91||ct(a)||Mo(a)?t(a):r(a)}function s(a){return Rn(a)?o(a):n(a)}function o(a){return a===59?(e.consume(a),r):Rn(a)?(e.consume(a),o):n(a)}}function kZ(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return kn(s)?n(s):t(s)}}function xM(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||ct(e)}function _M(e){return!Rn(e)}function yM(e){return!(e===47||U0(e))}function U0(e){return e===43||e===45||e===46||e===95||kn(e)}function t1(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const CZ={tokenize:AZ,partial:!0};function EZ(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:PZ,continuation:{tokenize:RZ},exit:MZ}},text:{91:{name:"gfmFootnoteCall",tokenize:IZ},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:NZ,resolveTo:TZ}}}}function NZ(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);const c=Fr(r.sliceSerialize({start:o.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function TZ(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function IZ(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(d){if(s>999||d===93&&!o||d===null||d===91||ct(d))return n(d);if(d===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return i.includes(Fr(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return ct(d)||(o=!0),s++,e.consume(d),d===92?u:c}function u(d){return d===91||d===92||d===93?(e.consume(d),s++,c):c(d)}}function PZ(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,a;return l;function l(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",u):n(m)}function u(m){if(o>999||m===93&&!a||m===null||m===91||ct(m))return n(m);if(m===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return s=Fr(r.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return ct(m)||(a=!0),o++,e.consume(m),m===92?d:u}function d(m){return m===91||m===92||m===93?(e.consume(m),o++,u):u(m)}function f(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),qe(e,p,"gfmFootnoteDefinitionWhitespace")):n(m)}function p(m){return t(m)}}function RZ(e,t,n){return e.check(ju,t,e.attempt(CZ,t,n))}function MZ(e){e.exit("gfmFootnoteDefinition")}function AZ(e,t,n){const r=this;return qe(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(s):n(s)}}function jZ(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},d={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},f=[["enter",u,a],["enter",o[c][1],a],["exit",o[c][1],a],["enter",d,a]],p=a.parser.constructs.insideSpan.null;p&&or(f,f.length,0,Pp(p,o.slice(c+1,l),a)),or(f,f.length,0,[["exit",d,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",u,a]]),or(o,c-1,l-c+3,f),l=c+f.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function s(o,a,l){const c=this.previous,u=this.events;let d=0;return f;function f(m){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(m):(o.enter("strikethroughSequenceTemporary"),p(m))}function p(m){const v=tl(c);if(m===126)return d>1?l(m):(o.consume(m),d++,p);if(d<2&&!n)return l(m);const w=o.exit("strikethroughSequenceTemporary"),x=tl(m);return w._open=!x||x===2&&!!v,w._close=!v||v===2&&!!x,a(m)}}}class LZ{constructor(){this.map=[]}add(t,n,r){DZ(this,t,n,r)}consume(t){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function DZ(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function OZ(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function BZ(){return{flow:{null:{name:"table",tokenize:zZ,resolveAll:$Z}}}}function zZ(e,t,n){const r=this;let i=0,s=0,o;return a;function a(P){let D=r.events.length-1;for(;D>-1;){const M=r.events[D][1].type;if(M==="lineEnding"||M==="linePrefix")D--;else break}const R=D>-1?r.events[D][1].type:null,A=R==="tableHead"||R==="tableRow"?k:l;return A===k&&r.parser.lazy[r.now().line]?n(P):A(P)}function l(P){return e.enter("tableHead"),e.enter("tableRow"),c(P)}function c(P){return P===124||(o=!0,s+=1),u(P)}function u(P){return P===null?n(P):we(P)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),p):n(P):Ue(P)?qe(e,u,"whitespace")(P):(s+=1,o&&(o=!1,i+=1),P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),o=!0,u):(e.enter("data"),d(P)))}function d(P){return P===null||P===124||ct(P)?(e.exit("data"),u(P)):(e.consume(P),P===92?f:d)}function f(P){return P===92||P===124?(e.consume(P),d):d(P)}function p(P){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(P):(e.enter("tableDelimiterRow"),o=!1,Ue(P)?qe(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):m(P))}function m(P){return P===45||P===58?w(P):P===124?(o=!0,e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),v):C(P)}function v(P){return Ue(P)?qe(e,w,"whitespace")(P):w(P)}function w(P){return P===58?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),x):P===45?(s+=1,x(P)):P===null||we(P)?S(P):C(P)}function x(P){return P===45?(e.enter("tableDelimiterFiller"),_(P)):C(P)}function _(P){return P===45?(e.consume(P),_):P===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),y):(e.exit("tableDelimiterFiller"),y(P))}function y(P){return Ue(P)?qe(e,S,"whitespace")(P):S(P)}function S(P){return P===124?m(P):P===null||we(P)?!o||i!==s?C(P):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(P)):C(P)}function C(P){return n(P)}function k(P){return e.enter("tableRow"),N(P)}function N(P){return P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),N):P===null||we(P)?(e.exit("tableRow"),t(P)):Ue(P)?qe(e,N,"whitespace")(P):(e.enter("data"),T(P))}function T(P){return P===null||P===124||ct(P)?(e.exit("data"),N(P)):(e.consume(P),P===92?O:T)}function O(P){return P===92||P===124?(e.consume(P),T):T(P)}}function $Z(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,c,u,d;const f=new LZ;for(;++n<e.length;){const p=e[n],m=p[1];p[0]==="enter"?m.type==="tableHead"?(a=!1,l!==0&&(Fk(f,t,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",c,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,d=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,u={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",u,t]])),i=m.type==="tableDelimiterRow"?2:u?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],d=Id(f,t,s,i,void 0,d),s=[0,0,0,0]),o[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],d=Id(f,t,s,i,void 0,d)),s=o,o=[s[1],n,0,0])):m.type==="tableHead"?(a=!0,l=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(l=n,s[1]!==0?(o[0]=o[1],d=Id(f,t,s,i,n,d)):o[1]!==0&&(d=Id(f,t,o,i,n,d)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&Fk(f,t,l,c,u),f.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=OZ(t.events,n))}return e}function Id(e,t,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},da(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=da(t.events,n[1]);if(s={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const c=da(t.events,n[2]),u=da(t.events,n[3]),d={type:a,start:Object.assign({},c),end:Object.assign({},u)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const f=t.events[n[2]],p=t.events[n[3]];if(f[1].end=Object.assign({},p[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,v=n[3]-n[2]-1;e.add(m,v,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return i!==void 0&&(s.end=Object.assign({},da(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function Fk(e,t,n,r,i){const s=[],o=da(t.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,t])),r.end=Object.assign({},o),s.push(["exit",r,t]),e.add(n+1,0,s)}function da(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const FZ={name:"tasklistCheck",tokenize:UZ};function HZ(){return{text:{91:FZ}}}function UZ(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),s)}function s(l){return ct(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(l)}function a(l){return we(l)?t(l):Ue(l)?e.check({tokenize:WZ},t,n)(l):n(l)}}function WZ(e,t,n){return qe(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function VZ(e){return I5([gZ(),EZ(),jZ(e),BZ(),HZ()])}const qZ={};function rl(e){const t=this,n=e||qZ,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(VZ(n)),s.push(hZ()),o.push(fZ(n))}const KZ=/<command-name>([\s\S]*?)<\/command-name>/i,GZ=/<command-message>([\s\S]*?)<\/command-message>/i,YZ=/<command-args>([\s\S]*?)<\/command-args>/i,XZ=/<(local-command-[a-z]+|command-(?:stdout|stderr))>[\s\S]*?<\/\1>/gi;function jp(e){if(!e)return{commandName:null,commandMessage:null,commandArgs:null,body:""};const t=e.match(KZ),n=e.match(GZ),r=e.match(YZ);let i=e;return t&&(i=i.replace(t[0],"")),n&&(i=i.replace(n[0],"")),r&&(i=i.replace(r[0],"")),i=i.replace(XZ,""),i=i.trim(),{commandName:t?t[1].trim():null,commandMessage:n?n[1].trim():null,commandArgs:r?r[1].trim():null,body:i}}function Lp(e){if(!e)return!1;const n=e.split("#")[0].split("?")[0].toLowerCase();return n.endsWith(".md")||n.endsWith(".markdown")}function QZ(e){if(!e)return null;let t;if(e.startsWith("file://")){const n=e.slice(7);t=n.startsWith("/")?n:`/${n.split("/").slice(1).join("/")}`}else{if(/^[a-z][a-z0-9+.-]*:/i.test(e))return null;if(e.startsWith("/"))t=e;else return null}try{return decodeURIComponent(t)}catch{return t}}const ZZ=/\.(png|jpe?g|webp|gif|svg)$/i;function JZ(e,t){if((typeof t=="string"?t:null)!==e)return!1;try{const r=new URL(e);return ZZ.test(r.pathname)}catch{return!1}}function eJ(e){try{return new URL(e).pathname.split("/").filter(Boolean).pop()??""}catch{return""}}const Fs={a:({node:e,href:t,children:n,...r})=>typeof t=="string"&&JZ(t,n)?h.jsxs("span",{className:"my-1 inline-flex flex-col items-start gap-1 align-top",children:[h.jsx("img",{src:t,alt:eJ(t),className:"max-w-full h-auto rounded border border-border"}),h.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"max-w-full truncate text-[11px] text-text-300 underline decoration-dotted underline-offset-2 hover:text-text-100",children:t})]}):h.jsx("a",{...r,href:t,target:"_blank",rel:"noopener noreferrer",children:n})};function bM(e){return e.startsWith("file://")?e:Q5(e)}function wM(e){return{...Fs,a:t=>{const{href:n,children:r}=t,i=typeof n=="string"?QZ(n):null;if(i===null){const s=Fs.a;return h.jsx(s,{...t})}return h.jsx("a",{href:n,"data-testid":"assistant-file-link",title:i,onClick:s=>{s.preventDefault(),e(i)},children:r})}}}function tJ({text:e,forkTarget:t,onOpenFilePath:n}){const{body:r}=jp(e),i=Qe.useMemo(()=>n?wM(n):Fs,[n]);return r?h.jsxs("div",{className:"group relative flex min-w-0 max-w-full flex-col items-start","data-testid":"msg-line-assistant-wrapper",children:[h.jsx("div",{"data-testid":"msg-line-assistant",className:"assistant-markdown w-full min-w-0 max-w-full py-1 break-words",children:h.jsx(nl,{remarkPlugins:[rl],components:i,...n?{urlTransform:bM}:{},children:r})}),t?h.jsxs("div",{className:"mt-1 flex flex-row items-center gap-1 md:absolute md:top-full md:mt-0 md:pt-0.5 md:z-10 md:rounded-md md:pointer-events-none md:group-hover:pointer-events-auto md:group-hover:bg-bg-100",children:[t.onFork?h.jsxs("button",{type:"button","data-testid":"assistant-msg-fork","aria-label":"fork from this message",title:"从这条消息派生新 session(截断之后的对话)",onClick:()=>t.onFork(t.messageUuid),className:"inline-flex items-center justify-start gap-1 h-7 w-7 md:h-6 md:w-auto md:px-1.5 rounded-md text-[11px] text-text-400/60 md:text-text-400 hover:bg-text-100/5 hover:text-text-200 md:opacity-0 md:group-hover:opacity-100 md:transition-opacity cursor-pointer",children:[h.jsx(Q_,{className:"w-3 h-3",strokeWidth:2}),h.jsx("span",{className:"hidden md:inline",children:"Fork"})]}):null,t.onQuickAsk?h.jsxs("button",{type:"button","data-testid":"assistant-msg-quick-ask","aria-label":"quick ask from this message",title:"快速问答:从这条消息派生临时会话,关闭即删",onClick:()=>t.onQuickAsk(t.messageUuid),className:"inline-flex items-center justify-start gap-1 h-7 w-7 md:h-6 md:w-auto md:px-1.5 rounded-md text-[11px] text-text-400/60 md:text-text-400 hover:bg-text-100/5 hover:text-text-200 md:opacity-0 md:group-hover:opacity-100 md:transition-opacity cursor-pointer",children:[h.jsx(h8,{className:"w-3 h-3",strokeWidth:2}),h.jsx("span",{className:"hidden md:inline",children:"问一下"})]}):null]}):null]}):null}function nJ({text:e}){const[t,n]=g.useState(!1);return e?h.jsxs("div",{"data-testid":"msg-line-thinking",className:"text-[12px] text-text-400",children:[h.jsxs("button",{type:"button",onClick:()=>n(r=>!r),className:"flex items-center gap-1 hover:text-text-300 transition-colors cursor-pointer","aria-expanded":t,"data-testid":"msg-line-thinking-toggle",children:[t?h.jsx(Yn,{className:"w-3 h-3"}):h.jsx(Bn,{className:"w-3 h-3"}),h.jsx("span",{children:"💭 Thinking"})]}),t?h.jsx("div",{className:"ml-4 mt-1 italic text-text-400 whitespace-pre-wrap break-words",children:e}):null]}):null}const rJ=new Set(["Write","Edit","MultiEdit","NotebookEdit"]);function W0(e){return rJ.has(e)}function iJ({tool:e,relPath:t,scope:n,onShareFile:r}){if(!W0(e)||!t||!n||!r)return null;const i=Lp(t)?"md-rendered":"raw";return h.jsx("span",{"data-testid":"file-edit-hover-row",className:"inline-flex shrink-0 items-center gap-1",children:h.jsx("span",{role:"button",tabIndex:0,"data-testid":"file-edit-share-btn","aria-label":"Share link",title:"Share link",onClick:s=>{s.stopPropagation(),r(t,i)},onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.stopPropagation(),s.preventDefault(),r(t,i))},className:"inline-flex h-3.5 w-3.5 items-center justify-center text-text-400 hover:text-text-200 cursor-pointer",children:h.jsx(Z_,{className:"h-3.5 w-3.5"})})})}function sJ(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.file_path=="string"&&t.file_path||typeof t.notebook_path=="string"&&t.notebook_path||typeof t.path=="string"&&t.path||null||null}function SM(e,t){const[n,r]=g.useState({kind:"idle"});return g.useEffect(()=>{let i=!1,s=null;r({kind:"loading"});const o={};return t&&(o.Authorization=`Bearer ${t}`),fetch(e,{headers:o,credentials:"omit"}).then(async a=>{if(!a.ok)throw new Error(`HTTP ${a.status}`);return a.blob()}).then(a=>{if(i)return;const l=URL.createObjectURL(a);s=l,r({kind:"ready",objectUrl:l})}).catch(a=>{i||r({kind:"error",message:a.message})}),()=>{i=!0,s&&URL.revokeObjectURL(s)}},[e,t]),n}function oJ({url:e,bearerToken:t,alt:n,className:r}){const i=SM(e,t);return h.jsxs("div",{"data-testid":"blob-image","data-state":i.kind,className:re("relative inline-flex items-center justify-center rounded-md border border-border bg-bg-0",r),children:[i.kind==="loading"?h.jsx("div",{className:"flex h-24 w-32 items-center justify-center",children:h.jsx(Ln,{className:"h-4 w-4 animate-spin text-text-400"})}):null,i.kind==="error"?h.jsxs("div",{className:"flex h-24 w-32 items-center justify-center gap-1 px-2 text-[11px] text-text-400",children:[h.jsx(Qi,{className:"h-3 w-3"}),h.jsx("span",{title:i.message,children:"加载失败"})]}):null,i.kind==="ready"?h.jsx("img",{src:i.objectUrl,alt:n,className:"block max-h-[180px] max-w-[420px] rounded-md object-contain"}):null]})}function aJ({url:e,bearerToken:t,className:n}){const r=SM(e,t);return h.jsxs("div",{"data-testid":"blob-video","data-state":r.kind,className:re("relative inline-flex items-center justify-center rounded-md border border-border bg-bg-0",n),children:[r.kind==="loading"?h.jsx(Ln,{className:"h-4 w-4 animate-spin text-text-400"}):null,r.kind==="error"?h.jsx("span",{className:"px-2 text-[11px] text-text-400",children:"加载失败"}):null,r.kind==="ready"?h.jsx("video",{src:r.objectUrl,controls:!0,className:"block max-h-[240px] max-w-[420px] rounded-md"}):null]})}const lJ=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg"]),cJ=new Set([".mp4",".webm",".mov"]),uJ=new Set([".pdf"]);function dJ(e){const t=e.lastIndexOf("."),n=t>=0?e.slice(t).toLowerCase():"";return lJ.has(n)?"image":cJ.has(n)?"video":uJ.has(n)?"pdf":"binary"}function kM(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function hJ({relPath:e,scope:t,size:n}){const r=ap();if(r.actionsLevel==="none")return null;const i=zz(r,t,e);if(!i)return null;const s=dJ(e);return s==="image"?h.jsx("div",{"data-testid":"file-edit-inline-preview","data-kind":"image",className:"mt-2",children:h.jsx(oJ,{url:i,bearerToken:r.httpToken,alt:e})}):s==="video"?h.jsx("div",{"data-testid":"file-edit-inline-preview","data-kind":"video",className:"mt-2",children:h.jsx(aJ,{url:i,bearerToken:r.httpToken})}):s==="pdf"?h.jsx(fJ,{relPath:e,url:i,size:n}):typeof n=="number"&&n>=1024*1024?h.jsxs("div",{"data-testid":"file-edit-inline-preview","data-kind":"binary",className:"mt-2 inline-flex items-center gap-1.5 rounded border border-border bg-bg-50 px-2 py-1 text-[11px] text-text-400",children:[h.jsx(mi,{className:"h-3 w-3"}),h.jsx("span",{className:"font-mono",children:e.split("/").pop()}),h.jsx("span",{children:"·"}),h.jsx("span",{children:kM(n)})]}):null}function fJ({relPath:e,url:t,size:n}){return h.jsxs("a",{"data-testid":"file-edit-inline-preview","data-kind":"pdf",href:t,target:"_blank",rel:"noopener noreferrer",className:"mt-2 inline-flex items-center gap-1.5 rounded border border-border bg-bg-50 px-2 py-1 text-[11px] text-text-300 hover:bg-bg-100",children:[h.jsx(mi,{className:"h-3 w-3"}),h.jsx("span",{className:"font-mono",children:e.split("/").pop()}),typeof n=="number"?h.jsxs(h.Fragment,{children:[h.jsx("span",{children:"·"}),h.jsx("span",{children:kM(n)})]}):null,h.jsx(tu,{className:"h-3 w-3"})]})}const pJ={Bash:CI,Read:mi,Edit:v0,Write:Y$,Grep:Kw,Glob:Kw};function mJ(e){return pJ[e]??nF}function gJ(e){if(!e||typeof e!="object")return"";const t=e,n=t.command??t.file_path??t.path??t.pattern??t.query??t.url??t.description;if(typeof n=="string")return n;for(const r of Object.values(t))if(typeof r=="string"&&r)return r;return""}function CM({tool:e,input:t,output:n,error:r,pending:i=!1,expandedBody:s,fileScope:o,onOpenInTab:a,onPreviewMarkdown:l,onShareFile:c}){const[u,d]=g.useState(!1),f=!!r,p=mJ(e),m=gJ(t),v=sJ(t);return h.jsxs("div",{"data-testid":"msg-line-tool","data-tool":e,className:re("group min-w-0 max-w-full rounded-md border px-3 py-2 text-[13px]",f?"border-destructive/40 bg-destructive/5":"border-border bg-bg-50"),children:[h.jsxs("button",{type:"button",onClick:()=>d(w=>!w),"aria-expanded":u,"data-testid":"msg-line-tool-header",className:"flex w-full items-center gap-2 text-left cursor-pointer min-w-0",children:[f?h.jsx(Qi,{className:"w-4 h-4 text-destructive shrink-0"}):h.jsx(p,{className:re("w-4 h-4 shrink-0",i?"text-text-400":"text-text-300")}),h.jsx("span",{className:"font-medium text-text-100 shrink-0",children:e}),m?(()=>{if(f||!W0(e)||!v)return null;const x=Lp(v)&&l?l:a;return x?h.jsx("span",{role:"button",tabIndex:0,"data-testid":"msg-line-tool-preview","data-clickable":"true",title:m,onClick:_=>{_.stopPropagation(),x(v)},onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.stopPropagation(),_.preventDefault(),x(v))},className:"text-[12px] text-accent font-mono truncate min-w-0 max-w-full cursor-pointer underline underline-offset-2 hover:opacity-80",children:m}):null})()??h.jsx("span",{"data-testid":"msg-line-tool-preview",className:"text-[12px] text-text-400 font-mono truncate min-w-0 max-w-full",title:m,children:m}):null,h.jsx("span",{"aria-hidden":"true","data-testid":"msg-line-tool-header-spacer",className:"flex-1 min-w-0 self-stretch"}),i?h.jsx(Ln,{"data-testid":"msg-line-tool-pending",className:"w-3 h-3 text-text-400 animate-spin shrink-0"}):null,!f&&o?h.jsx(iJ,{tool:e,relPath:v,scope:o,...c?{onShareFile:c}:{}}):null]}),u?s!==void 0?h.jsxs("div",{"data-testid":"msg-line-tool-body",className:"mt-2 min-w-0 text-[12px]",children:[s,f?h.jsxs("div",{className:"mt-2",children:[h.jsx("div",{className:"text-destructive mb-0.5",children:"error"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-destructive/40 rounded p-2 overflow-auto text-destructive",children:String(r)})]}):null]}):h.jsxs("div",{"data-testid":"msg-line-tool-body",className:"mt-2 min-w-0 space-y-1 text-[12px]",children:[h.jsxs("div",{children:[h.jsx("div",{className:"text-text-400 mb-0.5",children:"input"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-border rounded p-2 overflow-auto text-text-200",children:JSON.stringify(t,null,2)})]}),n!==void 0?h.jsxs("div",{children:[h.jsx("div",{className:"text-text-400 mb-0.5",children:"output"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-border rounded p-2 overflow-auto text-text-200",children:typeof n=="string"?n:JSON.stringify(n,null,2)})]}):null,f?h.jsxs("div",{children:[h.jsx("div",{className:"text-destructive mb-0.5",children:"error"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-destructive/40 rounded p-2 overflow-auto text-destructive",children:String(r)})]}):null]}):null,!f&&o&&v&&W0(e)?h.jsx(hJ,{relPath:v,scope:o}):null]})}var vJ=Symbol.for("react.lazy"),mf=ul[" use ".trim().toString()];function xJ(e){return typeof e=="object"&&e!==null&&"then"in e}function EM(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===vJ&&"_payload"in e&&xJ(e._payload)}function _J(e){const t=bJ(e),n=g.forwardRef((r,i)=>{let{children:s,...o}=r;EM(s)&&typeof mf=="function"&&(s=mf(s._payload));const a=g.Children.toArray(s),l=a.find(SJ);if(l){const c=l.props.children,u=a.map(d=>d===l?g.Children.count(c)>1?g.Children.only(null):g.isValidElement(c)?c.props.children:null:d);return h.jsx(t,{...o,ref:i,children:g.isValidElement(c)?g.cloneElement(c,void 0,u):null})}return h.jsx(t,{...o,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}var yJ=_J("Slot");function bJ(e){const t=g.forwardRef((n,r)=>{let{children:i,...s}=n;if(EM(i)&&typeof mf=="function"&&(i=mf(i._payload)),g.isValidElement(i)){const o=CJ(i),a=kJ(s,i.props);return i.type!==g.Fragment&&(a.ref=r?ku(r,o):o),g.cloneElement(i,a)}return g.Children.count(i)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var wJ=Symbol("radix.slottable");function SJ(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===wJ}function kJ(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function CJ(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const Hk=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Uk=II,EJ=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return Uk(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:s}=t,o=Object.keys(i).map(c=>{const u=n==null?void 0:n[c],d=s==null?void 0:s[c];if(u===null)return null;const f=Hk(u)||Hk(d);return i[c][f]}),a=n&&Object.entries(n).reduce((c,u)=>{let[d,f]=u;return f===void 0||(c[d]=f),c},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((c,u)=>{let{class:d,className:f,...p}=u;return Object.entries(p).every(m=>{let[v,w]=m;return Array.isArray(w)?w.includes({...s,...a}[v]):{...s,...a}[v]===w})?[...c,d,f]:c},[]);return Uk(e,o,l,n==null?void 0:n.class,n==null?void 0:n.className)},NJ=EJ("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-accent text-accent-contrast hover:bg-accent-hover",destructive:"bg-destructive text-white hover:bg-destructive-hover",outline:"border border-border bg-transparent text-text-100 hover:bg-bg-200",ghost:"bg-transparent text-text-200 hover:bg-bg-200 hover:text-text-100"},size:{sm:"h-8 px-3 text-xs",md:"h-9 px-4",lg:"h-11 px-6 text-base"}},defaultVariants:{variant:"default",size:"md"}}),di=g.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...i},s)=>{const o=r?yJ:"button";return h.jsx(o,{ref:s,className:re(NJ({variant:t,size:n}),e),...i})});di.displayName="Button";function TJ({tool:e,input:t,onRespond:n,onInterrupt:r}){return h.jsxs("div",{"data-testid":"msg-line-permission",className:"min-w-0 max-w-full rounded-md border border-warning/40 bg-warning-dim/60 px-3 py-2.5 text-[13px]",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 mb-1.5",children:[h.jsx($8,{className:"w-4 h-4 text-warning shrink-0"}),h.jsxs("span",{className:"min-w-0 font-medium text-text-100 truncate",children:["权限请求:",e]}),r?h.jsx("button",{type:"button",onClick:r,"data-testid":"msg-line-permission-interrupt","aria-label":"interrupt current turn",title:"中断当前轮次(不杀进程)",className:"ml-auto h-6 w-6 rounded-md flex items-center justify-center text-text-400 hover:bg-text-100/10 hover:text-text-200 transition-colors cursor-pointer",children:h.jsx(SI,{className:"w-3.5 h-3.5",strokeWidth:2})}):null]}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-border rounded p-2 mb-2 max-h-[140px] overflow-auto text-[12px] text-text-200",children:JSON.stringify(t,null,2)}),h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsx(di,{size:"sm",variant:"default",onClick:()=>n(!0,!1),"data-testid":"msg-line-permission-allow",children:"Allow"}),h.jsx(di,{size:"sm",variant:"outline",onClick:()=>n(!0,!0),"data-testid":"msg-line-permission-allow-always",children:"Allow Always"}),h.jsx(di,{size:"sm",variant:"destructive",onClick:()=>n(!1,!1),"data-testid":"msg-line-permission-deny",children:"Deny"})]})]})}function IJ({message:e}){return h.jsxs("div",{"data-testid":"msg-line-error",className:"flex min-w-0 max-w-full items-start gap-2 text-destructive text-[13px] rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2",children:[h.jsx(nu,{className:"w-4 h-4 shrink-0 mt-0.5"}),h.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:e})]})}const Wk=/\[attachment:(image|file):([^\]]+)\]/g;function NM(e){const t=[];let n;for(;(n=Wk.exec(e))!==null;){const i=n[2],s=decodeURIComponent(i.split("/").pop()??"file");t.push({type:n[1],url:i,fileName:s})}const r=e.replace(Wk,"").trim();return{attachments:t,text:r}}function PJ(e,t){const n=t.filter(i=>i.status==="done"&&i.url);return n.length===0?e:n.map(i=>`[attachment:${i.mimeType.startsWith("image/")?"image":"file"}:${i.url}]`).join(`
534
+ `))}function l(p,m,v,w){const x=v.enter("tableCell"),_=v.enter("phrasing"),y=v.containerPhrasing(p,{...w,before:s,after:s});return _(),x(),y}function c(p,m){return $Q(p,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function u(p,m,v){const w=p.children;let x=-1;const _=[],y=m.enter("table");for(;++x<w.length;)_[x]=d(w[x],m,v);return y(),_}function d(p,m,v){const w=p.children;let x=-1;const _=[],y=m.enter("tableRow");for(;++x<w.length;)_[x]=l(w[x],p,m,v);return y(),_}function f(p,m,v){let w=vM.inlineCode(p,m,v);return v.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function NZ(){return{exit:{taskListCheckValueChecked:Uk,taskListCheckValueUnchecked:Uk,paragraph:IZ}}}function TZ(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:PZ}}}function Uk(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function IZ(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,o;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function PZ(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(o);let l=vM.listItem(e,t,n,{...r,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(u){return u+o}}function RZ(){return[cQ(),PQ(),jQ(),yZ(),NZ()]}function MZ(e){return{extensions:[uQ(),RQ(e),LQ(),EZ(e),TZ()]}}const AZ={tokenize:zZ,partial:!0},xM={tokenize:$Z,partial:!0},_M={tokenize:FZ,partial:!0},yM={tokenize:HZ,partial:!0},jZ={tokenize:UZ,partial:!0},bM={name:"wwwAutolink",tokenize:OZ,previous:SM},wM={name:"protocolAutolink",tokenize:BZ,previous:kM},es={name:"emailAutolink",tokenize:DZ,previous:CM},bi={};function LZ(){return{text:bi}}let to=48;for(;to<123;)bi[to]=es,to++,to===58?to=65:to===91&&(to=97);bi[43]=es;bi[45]=es;bi[46]=es;bi[95]=es;bi[72]=[es,wM];bi[104]=[es,wM];bi[87]=[es,bM];bi[119]=[es,bM];function DZ(e,t,n){const r=this;let i,s;return o;function o(d){return!U0(d)||!CM.call(r,r.previous)||t1(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(d))}function a(d){return U0(d)?(e.consume(d),a):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(jZ,u,c)(d):d===45||d===95||kn(d)?(s=!0,e.consume(d),l):u(d)}function c(d){return e.consume(d),i=!0,l}function u(d){return s&&i&&Rn(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function OZ(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!SM.call(r,r.previous)||t1(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(AZ,e.attempt(xM,e.attempt(_M,s),n),n)(o))}function s(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function BZ(e,t,n){const r=this;let i="",s=!1;return o;function o(d){return(d===72||d===104)&&kM.call(r,r.previous)&&!t1(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),e.consume(d),a):n(d)}function a(d){if(Rn(d)&&i.length<5)return i+=String.fromCodePoint(d),e.consume(d),a;if(d===58){const f=i.toLowerCase();if(f==="http"||f==="https")return e.consume(d),l}return n(d)}function l(d){return d===47?(e.consume(d),s?c:(s=!0,l)):n(d)}function c(d){return d===null||df(d)||ct(d)||Mo(d)||Pp(d)?n(d):e.attempt(xM,e.attempt(_M,u),n)(d)}function u(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function zZ(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),s):n(o)}function s(o){return o===null?n(o):t(o)}}function $Z(e,t,n){let r,i,s;return o;function o(c){return c===46||c===95?e.check(yM,l,a)(c):c===null||ct(c)||Mo(c)||c!==45&&Pp(c)?l(c):(s=!0,e.consume(c),o)}function a(c){return c===95?r=!0:(i=r,r=void 0),e.consume(c),o}function l(c){return i||r||!s?n(c):t(c)}}function FZ(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(yM,t,s)(o):o===null||ct(o)||Mo(o)?t(o):(e.consume(o),i)}function s(o){return o===41&&r++,e.consume(o),i}}function HZ(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),s):a===93?(e.consume(a),i):a===60||a===null||ct(a)||Mo(a)?t(a):n(a)}function i(a){return a===null||a===40||a===91||ct(a)||Mo(a)?t(a):r(a)}function s(a){return Rn(a)?o(a):n(a)}function o(a){return a===59?(e.consume(a),r):Rn(a)?(e.consume(a),o):n(a)}}function UZ(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return kn(s)?n(s):t(s)}}function SM(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||ct(e)}function kM(e){return!Rn(e)}function CM(e){return!(e===47||U0(e))}function U0(e){return e===43||e===45||e===46||e===95||kn(e)}function t1(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const WZ={tokenize:ZZ,partial:!0};function VZ(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:YZ,continuation:{tokenize:XZ},exit:QZ}},text:{91:{name:"gfmFootnoteCall",tokenize:GZ},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:qZ,resolveTo:KZ}}}}function qZ(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);const c=Fr(r.sliceSerialize({start:o.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function KZ(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function GZ(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(d){if(s>999||d===93&&!o||d===null||d===91||ct(d))return n(d);if(d===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return i.includes(Fr(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return ct(d)||(o=!0),s++,e.consume(d),d===92?u:c}function u(d){return d===91||d===92||d===93?(e.consume(d),s++,c):c(d)}}function YZ(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,a;return l;function l(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",u):n(m)}function u(m){if(o>999||m===93&&!a||m===null||m===91||ct(m))return n(m);if(m===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return s=Fr(r.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return ct(m)||(a=!0),o++,e.consume(m),m===92?d:u}function d(m){return m===91||m===92||m===93?(e.consume(m),o++,u):u(m)}function f(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),qe(e,p,"gfmFootnoteDefinitionWhitespace")):n(m)}function p(m){return t(m)}}function XZ(e,t,n){return e.check(ju,t,e.attempt(WZ,t,n))}function QZ(e){e.exit("gfmFootnoteDefinition")}function ZZ(e,t,n){const r=this;return qe(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(s):n(s)}}function JZ(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},d={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},f=[["enter",u,a],["enter",o[c][1],a],["exit",o[c][1],a],["enter",d,a]],p=a.parser.constructs.insideSpan.null;p&&or(f,f.length,0,Rp(p,o.slice(c+1,l),a)),or(f,f.length,0,[["exit",d,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",u,a]]),or(o,c-1,l-c+3,f),l=c+f.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function s(o,a,l){const c=this.previous,u=this.events;let d=0;return f;function f(m){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(m):(o.enter("strikethroughSequenceTemporary"),p(m))}function p(m){const v=tl(c);if(m===126)return d>1?l(m):(o.consume(m),d++,p);if(d<2&&!n)return l(m);const w=o.exit("strikethroughSequenceTemporary"),x=tl(m);return w._open=!x||x===2&&!!v,w._close=!v||v===2&&!!x,a(m)}}}class eJ{constructor(){this.map=[]}add(t,n,r){tJ(this,t,n,r)}consume(t){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function tJ(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function nJ(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function rJ(){return{flow:{null:{name:"table",tokenize:iJ,resolveAll:sJ}}}}function iJ(e,t,n){const r=this;let i=0,s=0,o;return a;function a(P){let D=r.events.length-1;for(;D>-1;){const M=r.events[D][1].type;if(M==="lineEnding"||M==="linePrefix")D--;else break}const R=D>-1?r.events[D][1].type:null,A=R==="tableHead"||R==="tableRow"?k:l;return A===k&&r.parser.lazy[r.now().line]?n(P):A(P)}function l(P){return e.enter("tableHead"),e.enter("tableRow"),c(P)}function c(P){return P===124||(o=!0,s+=1),u(P)}function u(P){return P===null?n(P):we(P)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),p):n(P):Ue(P)?qe(e,u,"whitespace")(P):(s+=1,o&&(o=!1,i+=1),P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),o=!0,u):(e.enter("data"),d(P)))}function d(P){return P===null||P===124||ct(P)?(e.exit("data"),u(P)):(e.consume(P),P===92?f:d)}function f(P){return P===92||P===124?(e.consume(P),d):d(P)}function p(P){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(P):(e.enter("tableDelimiterRow"),o=!1,Ue(P)?qe(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):m(P))}function m(P){return P===45||P===58?w(P):P===124?(o=!0,e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),v):C(P)}function v(P){return Ue(P)?qe(e,w,"whitespace")(P):w(P)}function w(P){return P===58?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),x):P===45?(s+=1,x(P)):P===null||we(P)?S(P):C(P)}function x(P){return P===45?(e.enter("tableDelimiterFiller"),_(P)):C(P)}function _(P){return P===45?(e.consume(P),_):P===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),y):(e.exit("tableDelimiterFiller"),y(P))}function y(P){return Ue(P)?qe(e,S,"whitespace")(P):S(P)}function S(P){return P===124?m(P):P===null||we(P)?!o||i!==s?C(P):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(P)):C(P)}function C(P){return n(P)}function k(P){return e.enter("tableRow"),N(P)}function N(P){return P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),N):P===null||we(P)?(e.exit("tableRow"),t(P)):Ue(P)?qe(e,N,"whitespace")(P):(e.enter("data"),T(P))}function T(P){return P===null||P===124||ct(P)?(e.exit("data"),N(P)):(e.consume(P),P===92?O:T)}function O(P){return P===92||P===124?(e.consume(P),T):T(P)}}function sJ(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,c,u,d;const f=new eJ;for(;++n<e.length;){const p=e[n],m=p[1];p[0]==="enter"?m.type==="tableHead"?(a=!1,l!==0&&(Wk(f,t,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",c,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,d=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,u={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",u,t]])),i=m.type==="tableDelimiterRow"?2:u?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],d=Id(f,t,s,i,void 0,d),s=[0,0,0,0]),o[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],d=Id(f,t,s,i,void 0,d)),s=o,o=[s[1],n,0,0])):m.type==="tableHead"?(a=!0,l=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(l=n,s[1]!==0?(o[0]=o[1],d=Id(f,t,s,i,n,d)):o[1]!==0&&(d=Id(f,t,o,i,n,d)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&Wk(f,t,l,c,u),f.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=nJ(t.events,n))}return e}function Id(e,t,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},da(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=da(t.events,n[1]);if(s={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const c=da(t.events,n[2]),u=da(t.events,n[3]),d={type:a,start:Object.assign({},c),end:Object.assign({},u)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const f=t.events[n[2]],p=t.events[n[3]];if(f[1].end=Object.assign({},p[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,v=n[3]-n[2]-1;e.add(m,v,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return i!==void 0&&(s.end=Object.assign({},da(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function Wk(e,t,n,r,i){const s=[],o=da(t.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,t])),r.end=Object.assign({},o),s.push(["exit",r,t]),e.add(n+1,0,s)}function da(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const oJ={name:"tasklistCheck",tokenize:lJ};function aJ(){return{text:{91:oJ}}}function lJ(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),s)}function s(l){return ct(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(l)}function a(l){return we(l)?t(l):Ue(l)?e.check({tokenize:cJ},t,n)(l):n(l)}}function cJ(e,t,n){return qe(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function uJ(e){return j5([LZ(),VZ(),JZ(e),rJ(),aJ()])}const dJ={};function rl(e){const t=this,n=e||dJ,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(uJ(n)),s.push(RZ()),o.push(MZ(n))}function Lp(e){if(!e)return!1;const n=e.split("#")[0].split("?")[0].toLowerCase();return n.endsWith(".md")||n.endsWith(".markdown")}function hJ(e){if(!e)return null;let t;if(e.startsWith("file://")){const n=e.slice(7);t=n.startsWith("/")?n:`/${n.split("/").slice(1).join("/")}`}else{if(/^[a-z][a-z0-9+.-]*:/i.test(e))return null;if(e.startsWith("/"))t=e;else return null}try{return decodeURIComponent(t)}catch{return t}}const fJ=/\.(png|jpe?g|webp|gif|svg)$/i;function pJ(e,t){if((typeof t=="string"?t:null)!==e)return!1;try{const r=new URL(e);return fJ.test(r.pathname)}catch{return!1}}function mJ(e){try{return new URL(e).pathname.split("/").filter(Boolean).pop()??""}catch{return""}}const Fs={a:({node:e,href:t,children:n,...r})=>typeof t=="string"&&pJ(t,n)?h.jsxs("span",{className:"my-1 inline-flex flex-col items-start gap-1 align-top",children:[h.jsx("img",{src:t,alt:mJ(t),className:"max-w-full h-auto rounded border border-border"}),h.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"max-w-full truncate text-[11px] text-text-300 underline decoration-dotted underline-offset-2 hover:text-text-100",children:t})]}):h.jsx("a",{...r,href:t,target:"_blank",rel:"noopener noreferrer",children:n})};function EM(e){return e.startsWith("file://")?e:nM(e)}function NM(e){return{...Fs,a:t=>{const{href:n,children:r}=t,i=typeof n=="string"?hJ(n):null;if(i===null){const s=Fs.a;return h.jsx(s,{...t})}return h.jsx("a",{href:n,"data-testid":"assistant-file-link",title:i,onClick:s=>{s.preventDefault(),e(i)},children:r})}}}function gJ({text:e,forkTarget:t,onOpenFilePath:n}){const{body:r}=Tp(e),i=Qe.useMemo(()=>n?NM(n):Fs,[n]);return r?h.jsxs("div",{className:"group relative flex min-w-0 max-w-full flex-col items-start","data-testid":"msg-line-assistant-wrapper",children:[h.jsx("div",{"data-testid":"msg-line-assistant",className:"assistant-markdown w-full min-w-0 max-w-full py-1 break-words",children:h.jsx(nl,{remarkPlugins:[rl],components:i,...n?{urlTransform:EM}:{},children:r})}),t?h.jsxs("div",{className:"mt-1 flex flex-row items-center gap-1 md:absolute md:top-full md:mt-0 md:pt-0.5 md:z-10 md:rounded-md md:pointer-events-none md:group-hover:pointer-events-auto md:group-hover:bg-bg-100",children:[t.onFork?h.jsxs("button",{type:"button","data-testid":"assistant-msg-fork","aria-label":"fork from this message",title:"从这条消息派生新 session(截断之后的对话)",onClick:()=>t.onFork(t.messageUuid),className:"inline-flex items-center justify-start gap-1 h-7 w-7 md:h-6 md:w-auto md:px-1.5 rounded-md text-[11px] text-text-400/60 md:text-text-400 hover:bg-text-100/5 hover:text-text-200 md:opacity-0 md:group-hover:opacity-100 md:transition-opacity cursor-pointer",children:[h.jsx(Q_,{className:"w-3 h-3",strokeWidth:2}),h.jsx("span",{className:"hidden md:inline",children:"Fork"})]}):null,t.onQuickAsk?h.jsxs("button",{type:"button","data-testid":"assistant-msg-quick-ask","aria-label":"quick ask from this message",title:"快速问答:从这条消息派生临时会话,关闭即删",onClick:()=>t.onQuickAsk(t.messageUuid),className:"inline-flex items-center justify-start gap-1 h-7 w-7 md:h-6 md:w-auto md:px-1.5 rounded-md text-[11px] text-text-400/60 md:text-text-400 hover:bg-text-100/5 hover:text-text-200 md:opacity-0 md:group-hover:opacity-100 md:transition-opacity cursor-pointer",children:[h.jsx(h8,{className:"w-3 h-3",strokeWidth:2}),h.jsx("span",{className:"hidden md:inline",children:"问一下"})]}):null]}):null]}):null}function vJ({text:e}){const[t,n]=g.useState(!1);return e?h.jsxs("div",{"data-testid":"msg-line-thinking",className:"text-[12px] text-text-400",children:[h.jsxs("button",{type:"button",onClick:()=>n(r=>!r),className:"flex items-center gap-1 hover:text-text-300 transition-colors cursor-pointer","aria-expanded":t,"data-testid":"msg-line-thinking-toggle",children:[t?h.jsx(Yn,{className:"w-3 h-3"}):h.jsx(Bn,{className:"w-3 h-3"}),h.jsx("span",{children:"💭 Thinking"})]}),t?h.jsx("div",{className:"ml-4 mt-1 italic text-text-400 whitespace-pre-wrap break-words",children:e}):null]}):null}const xJ=new Set(["Write","Edit","MultiEdit","NotebookEdit"]);function W0(e){return xJ.has(e)}function _J({tool:e,relPath:t,scope:n,onShareFile:r}){if(!W0(e)||!t||!n||!r)return null;const i=Lp(t)?"md-rendered":"raw";return h.jsx("span",{"data-testid":"file-edit-hover-row",className:"inline-flex shrink-0 items-center gap-1",children:h.jsx("span",{role:"button",tabIndex:0,"data-testid":"file-edit-share-btn","aria-label":"Share link",title:"Share link",onClick:s=>{s.stopPropagation(),r(t,i)},onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.stopPropagation(),s.preventDefault(),r(t,i))},className:"inline-flex h-3.5 w-3.5 items-center justify-center text-text-400 hover:text-text-200 cursor-pointer",children:h.jsx(Z_,{className:"h-3.5 w-3.5"})})})}function yJ(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.file_path=="string"&&t.file_path||typeof t.notebook_path=="string"&&t.notebook_path||typeof t.path=="string"&&t.path||null||null}function TM(e,t){const[n,r]=g.useState({kind:"idle"});return g.useEffect(()=>{let i=!1,s=null;r({kind:"loading"});const o={};return t&&(o.Authorization=`Bearer ${t}`),fetch(e,{headers:o,credentials:"omit"}).then(async a=>{if(!a.ok)throw new Error(`HTTP ${a.status}`);return a.blob()}).then(a=>{if(i)return;const l=URL.createObjectURL(a);s=l,r({kind:"ready",objectUrl:l})}).catch(a=>{i||r({kind:"error",message:a.message})}),()=>{i=!0,s&&URL.revokeObjectURL(s)}},[e,t]),n}function bJ({url:e,bearerToken:t,alt:n,className:r}){const i=TM(e,t);return h.jsxs("div",{"data-testid":"blob-image","data-state":i.kind,className:re("relative inline-flex items-center justify-center rounded-md border border-border bg-bg-0",r),children:[i.kind==="loading"?h.jsx("div",{className:"flex h-24 w-32 items-center justify-center",children:h.jsx(Ln,{className:"h-4 w-4 animate-spin text-text-400"})}):null,i.kind==="error"?h.jsxs("div",{className:"flex h-24 w-32 items-center justify-center gap-1 px-2 text-[11px] text-text-400",children:[h.jsx(Qi,{className:"h-3 w-3"}),h.jsx("span",{title:i.message,children:"加载失败"})]}):null,i.kind==="ready"?h.jsx("img",{src:i.objectUrl,alt:n,className:"block max-h-[180px] max-w-[420px] rounded-md object-contain"}):null]})}function wJ({url:e,bearerToken:t,className:n}){const r=TM(e,t);return h.jsxs("div",{"data-testid":"blob-video","data-state":r.kind,className:re("relative inline-flex items-center justify-center rounded-md border border-border bg-bg-0",n),children:[r.kind==="loading"?h.jsx(Ln,{className:"h-4 w-4 animate-spin text-text-400"}):null,r.kind==="error"?h.jsx("span",{className:"px-2 text-[11px] text-text-400",children:"加载失败"}):null,r.kind==="ready"?h.jsx("video",{src:r.objectUrl,controls:!0,className:"block max-h-[240px] max-w-[420px] rounded-md"}):null]})}const SJ=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg"]),kJ=new Set([".mp4",".webm",".mov"]),CJ=new Set([".pdf"]);function EJ(e){const t=e.lastIndexOf("."),n=t>=0?e.slice(t).toLowerCase():"";return SJ.has(n)?"image":kJ.has(n)?"video":CJ.has(n)?"pdf":"binary"}function IM(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function NJ({relPath:e,scope:t,size:n}){const r=ap();if(r.actionsLevel==="none")return null;const i=zz(r,t,e);if(!i)return null;const s=EJ(e);return s==="image"?h.jsx("div",{"data-testid":"file-edit-inline-preview","data-kind":"image",className:"mt-2",children:h.jsx(bJ,{url:i,bearerToken:r.httpToken,alt:e})}):s==="video"?h.jsx("div",{"data-testid":"file-edit-inline-preview","data-kind":"video",className:"mt-2",children:h.jsx(wJ,{url:i,bearerToken:r.httpToken})}):s==="pdf"?h.jsx(TJ,{relPath:e,url:i,size:n}):typeof n=="number"&&n>=1024*1024?h.jsxs("div",{"data-testid":"file-edit-inline-preview","data-kind":"binary",className:"mt-2 inline-flex items-center gap-1.5 rounded border border-border bg-bg-50 px-2 py-1 text-[11px] text-text-400",children:[h.jsx(mi,{className:"h-3 w-3"}),h.jsx("span",{className:"font-mono",children:e.split("/").pop()}),h.jsx("span",{children:"·"}),h.jsx("span",{children:IM(n)})]}):null}function TJ({relPath:e,url:t,size:n}){return h.jsxs("a",{"data-testid":"file-edit-inline-preview","data-kind":"pdf",href:t,target:"_blank",rel:"noopener noreferrer",className:"mt-2 inline-flex items-center gap-1.5 rounded border border-border bg-bg-50 px-2 py-1 text-[11px] text-text-300 hover:bg-bg-100",children:[h.jsx(mi,{className:"h-3 w-3"}),h.jsx("span",{className:"font-mono",children:e.split("/").pop()}),typeof n=="number"?h.jsxs(h.Fragment,{children:[h.jsx("span",{children:"·"}),h.jsx("span",{children:IM(n)})]}):null,h.jsx(tu,{className:"h-3 w-3"})]})}const IJ={Bash:CI,Read:mi,Edit:v0,Write:Y$,Grep:Kw,Glob:Kw};function PJ(e){return IJ[e]??nF}function RJ(e){if(!e||typeof e!="object")return"";const t=e,n=t.command??t.file_path??t.path??t.pattern??t.query??t.url??t.description;if(typeof n=="string")return n;for(const r of Object.values(t))if(typeof r=="string"&&r)return r;return""}function PM({tool:e,input:t,output:n,error:r,pending:i=!1,expandedBody:s,fileScope:o,onOpenInTab:a,onPreviewMarkdown:l,onShareFile:c}){const[u,d]=g.useState(!1),f=!!r,p=PJ(e),m=RJ(t),v=yJ(t);return h.jsxs("div",{"data-testid":"msg-line-tool","data-tool":e,className:re("group min-w-0 max-w-full rounded-md border px-3 py-2 text-[13px]",f?"border-destructive/40 bg-destructive/5":"border-border bg-bg-50"),children:[h.jsxs("button",{type:"button",onClick:()=>d(w=>!w),"aria-expanded":u,"data-testid":"msg-line-tool-header",className:"flex w-full items-center gap-2 text-left cursor-pointer min-w-0",children:[f?h.jsx(Qi,{className:"w-4 h-4 text-destructive shrink-0"}):h.jsx(p,{className:re("w-4 h-4 shrink-0",i?"text-text-400":"text-text-300")}),h.jsx("span",{className:"font-medium text-text-100 shrink-0",children:e}),m?(()=>{if(f||!W0(e)||!v)return null;const x=Lp(v)&&l?l:a;return x?h.jsx("span",{role:"button",tabIndex:0,"data-testid":"msg-line-tool-preview","data-clickable":"true",title:m,onClick:_=>{_.stopPropagation(),x(v)},onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.stopPropagation(),_.preventDefault(),x(v))},className:"text-[12px] text-accent font-mono truncate min-w-0 max-w-full cursor-pointer underline underline-offset-2 hover:opacity-80",children:m}):null})()??h.jsx("span",{"data-testid":"msg-line-tool-preview",className:"text-[12px] text-text-400 font-mono truncate min-w-0 max-w-full",title:m,children:m}):null,h.jsx("span",{"aria-hidden":"true","data-testid":"msg-line-tool-header-spacer",className:"flex-1 min-w-0 self-stretch"}),i?h.jsx(Ln,{"data-testid":"msg-line-tool-pending",className:"w-3 h-3 text-text-400 animate-spin shrink-0"}):null,!f&&o?h.jsx(_J,{tool:e,relPath:v,scope:o,...c?{onShareFile:c}:{}}):null]}),u?s!==void 0?h.jsxs("div",{"data-testid":"msg-line-tool-body",className:"mt-2 min-w-0 text-[12px]",children:[s,f?h.jsxs("div",{className:"mt-2",children:[h.jsx("div",{className:"text-destructive mb-0.5",children:"error"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-destructive/40 rounded p-2 overflow-auto text-destructive",children:String(r)})]}):null]}):h.jsxs("div",{"data-testid":"msg-line-tool-body",className:"mt-2 min-w-0 space-y-1 text-[12px]",children:[h.jsxs("div",{children:[h.jsx("div",{className:"text-text-400 mb-0.5",children:"input"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-border rounded p-2 overflow-auto text-text-200",children:JSON.stringify(t,null,2)})]}),n!==void 0?h.jsxs("div",{children:[h.jsx("div",{className:"text-text-400 mb-0.5",children:"output"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-border rounded p-2 overflow-auto text-text-200",children:typeof n=="string"?n:JSON.stringify(n,null,2)})]}):null,f?h.jsxs("div",{children:[h.jsx("div",{className:"text-destructive mb-0.5",children:"error"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-destructive/40 rounded p-2 overflow-auto text-destructive",children:String(r)})]}):null]}):null,!f&&o&&v&&W0(e)?h.jsx(NJ,{relPath:v,scope:o}):null]})}var MJ=Symbol.for("react.lazy"),mf=ul[" use ".trim().toString()];function AJ(e){return typeof e=="object"&&e!==null&&"then"in e}function RM(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===MJ&&"_payload"in e&&AJ(e._payload)}function jJ(e){const t=DJ(e),n=g.forwardRef((r,i)=>{let{children:s,...o}=r;RM(s)&&typeof mf=="function"&&(s=mf(s._payload));const a=g.Children.toArray(s),l=a.find(BJ);if(l){const c=l.props.children,u=a.map(d=>d===l?g.Children.count(c)>1?g.Children.only(null):g.isValidElement(c)?c.props.children:null:d);return h.jsx(t,{...o,ref:i,children:g.isValidElement(c)?g.cloneElement(c,void 0,u):null})}return h.jsx(t,{...o,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}var LJ=jJ("Slot");function DJ(e){const t=g.forwardRef((n,r)=>{let{children:i,...s}=n;if(RM(i)&&typeof mf=="function"&&(i=mf(i._payload)),g.isValidElement(i)){const o=$J(i),a=zJ(s,i.props);return i.type!==g.Fragment&&(a.ref=r?ku(r,o):o),g.cloneElement(i,a)}return g.Children.count(i)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var OJ=Symbol("radix.slottable");function BJ(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===OJ}function zJ(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function $J(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const Vk=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,qk=II,FJ=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return qk(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:s}=t,o=Object.keys(i).map(c=>{const u=n==null?void 0:n[c],d=s==null?void 0:s[c];if(u===null)return null;const f=Vk(u)||Vk(d);return i[c][f]}),a=n&&Object.entries(n).reduce((c,u)=>{let[d,f]=u;return f===void 0||(c[d]=f),c},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((c,u)=>{let{class:d,className:f,...p}=u;return Object.entries(p).every(m=>{let[v,w]=m;return Array.isArray(w)?w.includes({...s,...a}[v]):{...s,...a}[v]===w})?[...c,d,f]:c},[]);return qk(e,o,l,n==null?void 0:n.class,n==null?void 0:n.className)},HJ=FJ("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-accent text-accent-contrast hover:bg-accent-hover",destructive:"bg-destructive text-white hover:bg-destructive-hover",outline:"border border-border bg-transparent text-text-100 hover:bg-bg-200",ghost:"bg-transparent text-text-200 hover:bg-bg-200 hover:text-text-100"},size:{sm:"h-8 px-3 text-xs",md:"h-9 px-4",lg:"h-11 px-6 text-base"}},defaultVariants:{variant:"default",size:"md"}}),di=g.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...i},s)=>{const o=r?LJ:"button";return h.jsx(o,{ref:s,className:re(HJ({variant:t,size:n}),e),...i})});di.displayName="Button";function UJ({tool:e,input:t,onRespond:n,onInterrupt:r}){return h.jsxs("div",{"data-testid":"msg-line-permission",className:"min-w-0 max-w-full rounded-md border border-warning/40 bg-warning-dim/60 px-3 py-2.5 text-[13px]",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 mb-1.5",children:[h.jsx($8,{className:"w-4 h-4 text-warning shrink-0"}),h.jsxs("span",{className:"min-w-0 font-medium text-text-100 truncate",children:["权限请求:",e]}),r?h.jsx("button",{type:"button",onClick:r,"data-testid":"msg-line-permission-interrupt","aria-label":"interrupt current turn",title:"中断当前轮次(不杀进程)",className:"ml-auto h-6 w-6 rounded-md flex items-center justify-center text-text-400 hover:bg-text-100/10 hover:text-text-200 transition-colors cursor-pointer",children:h.jsx(SI,{className:"w-3.5 h-3.5",strokeWidth:2})}):null]}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-border rounded p-2 mb-2 max-h-[140px] overflow-auto text-[12px] text-text-200",children:JSON.stringify(t,null,2)}),h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsx(di,{size:"sm",variant:"default",onClick:()=>n(!0,!1),"data-testid":"msg-line-permission-allow",children:"Allow"}),h.jsx(di,{size:"sm",variant:"outline",onClick:()=>n(!0,!0),"data-testid":"msg-line-permission-allow-always",children:"Allow Always"}),h.jsx(di,{size:"sm",variant:"destructive",onClick:()=>n(!1,!1),"data-testid":"msg-line-permission-deny",children:"Deny"})]})]})}function WJ({message:e}){return h.jsxs("div",{"data-testid":"msg-line-error",className:"flex min-w-0 max-w-full items-start gap-2 text-destructive text-[13px] rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2",children:[h.jsx(nu,{className:"w-4 h-4 shrink-0 mt-0.5"}),h.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:e})]})}const Kk=/\[attachment:(image|file):([^\]]+)\]/g;function MM(e){const t=[];let n;for(;(n=Kk.exec(e))!==null;){const i=n[2],s=decodeURIComponent(i.split("/").pop()??"file");t.push({type:n[1],url:i,fileName:s})}const r=e.replace(Kk,"").trim();return{attachments:t,text:r}}function VJ(e,t){const n=t.filter(i=>i.status==="done"&&i.url);return n.length===0?e:n.map(i=>`[attachment:${i.mimeType.startsWith("image/")?"image":"file"}:${i.url}]`).join(`
535
535
  `)+`
536
- `+e}const RJ=/\[skill:(.+?):(\/[^\]]+)\]/g;function MJ(e){const t=[],n=e.replace(RJ,(r,i)=>(t.push(i),""));return{skills:t,text:t.length>0?n.trim():e}}function AJ({text:e,senderDisplayName:t,senderPrincipal:n,rewindTarget:r}){const i=n==="guest",s=p5(e),{attachments:o,text:a}=NM(s),{skills:l,text:c}=MJ(a),{commandName:u,body:d}=jp(c),f=d.length>0;return f||o.length>0||!!u||l.length>0?(u||l.length>0)&&!f&&o.length===0?h.jsxs("div",{className:"flex min-w-0 max-w-full justify-end gap-1.5 py-2 mt-2","data-testid":"msg-line-user","data-sender-principal":i?"guest":"owner",children:[l.map((m,v)=>h.jsxs("span",{"data-testid":"user-skill-chip",className:"inline-flex items-center rounded-md bg-bg-200/60 px-2 py-0.5 text-[11px] font-mono text-text-300",children:["/",m]},`${m}-${v}`)),u?h.jsx("span",{className:"inline-flex items-center rounded-md bg-bg-200/60 px-2 py-0.5 text-[11px] font-mono text-text-300",children:u}):null]}):h.jsxs("div",{className:"group flex min-w-0 max-w-full flex-col items-end py-2 mt-2","data-testid":"msg-line-user","data-sender-principal":i?"guest":"owner",children:[h.jsxs("div",{"data-testid":"user-msg-bubble",className:re("min-w-0 max-w-[85%] rounded-2xl rounded-br-sm px-3.5 py-2 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",i?"border border-border bg-bg-200":"bg-accent"),children:[o.length>0?h.jsx(jJ,{attachments:o}):null,l.length>0?h.jsx("div",{className:re("flex flex-wrap gap-1.5",(f||u)&&"mb-1.5"),children:l.map((m,v)=>h.jsxs("span",{"data-testid":"user-skill-chip",className:re("inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-mono",i?"bg-text-100/10 text-text-200":"bg-white/15 text-white/90"),children:["/",m]},`${m}-${v}`))}):null,u?h.jsx("div",{className:re("flex",f&&"mb-1.5"),children:h.jsx("span",{"data-testid":"user-command-chip",className:re("inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-mono",i?"bg-text-100/10 text-text-200":"bg-white/15 text-white/90"),children:u})}):null,f?h.jsx("div",{className:re("text-[14px] font-medium leading-relaxed",i?"text-text-100":"text-white"),children:d}):null]}),t?h.jsx("div",{"data-testid":"user-msg-sender-label",className:"mt-1 text-[11px] text-text-400",children:t}):null,r?h.jsxs("button",{type:"button","data-testid":"user-msg-rewind","aria-label":"rewind to this message",title:"回退到这条消息(会撤销之后 CC 的文件编辑)",onClick:()=>r.onRewind(r.userMessageId),className:"mt-1 inline-flex items-center gap-1 h-6 px-1.5 rounded-md text-[11px] text-text-400 hover:bg-text-100/5 hover:text-text-200 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:[h.jsx(EI,{className:"w-3 h-3",strokeWidth:2}),h.jsx("span",{children:"Rewind"})]}):null]}):null}function jJ({attachments:e}){return h.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5","data-testid":"user-attachment-row",children:e.map(t=>h.jsx(LJ,{attachment:t},t.url))})}function LJ({attachment:e}){return e.type==="image"?h.jsx("img",{src:e.url,alt:e.fileName,"data-testid":"user-attachment-image",className:"h-16 w-16 rounded object-cover shrink-0 border border-bg-300/50"}):h.jsxs("div",{"data-testid":"user-attachment-file",className:"flex items-center gap-1.5 rounded-md border border-bg-300 bg-bg-100/60 px-2 py-1 text-[12px] text-text-200",children:[h.jsx(mi,{className:"h-3.5 w-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"max-w-[140px] truncate",children:e.fileName})]})}const DJ={"task-notification":"子任务通知","slash-command":"斜杠命令","local-command":"本地命令输出","system-reminder":"系统提醒","skill-hint":"Skill 注入","meta-text":"系统消息","attachment-skills":"技能列表","attachment-deferred-tools":"Deferred 工具变更","dispatch-task":"委派任务","dispatch-result":"委派回报"},OJ={"task-notification":Uw,"slash-command":V8,"local-command":CI,"system-reminder":Uw,"skill-hint":x0,"meta-text":wI,"attachment-skills":x0,"attachment-deferred-tools":N8,"dispatch-task":kI,"dispatch-result":bI};function TM({metaKind:e,text:t}){const[n,r]=g.useState(!1),i=OJ[e];if(e==="slash-command"){const{commandName:o,commandMessage:a,commandArgs:l,body:c}=jp(t),u=o??(a?`/${a}`:null),d=!!(l&&l.length>0),f=c.length>0;return!u&&!d&&!f?null:h.jsxs("div",{"data-testid":"msg-line-user-meta","data-meta-kind":e,className:"flex min-w-0 max-w-full flex-col items-end gap-0.5 py-1",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 max-w-full",children:[u?h.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-md bg-bg-200/60 px-2 py-0.5 text-[11px] font-mono text-text-300 shrink-0",children:[h.jsx(i,{className:"w-3 h-3 opacity-70"}),u]}):null,d?h.jsx("span",{"data-testid":"user-meta-command-args",className:"min-w-0 text-[12px] text-text-200 whitespace-pre-wrap break-words max-w-[70ch] [overflow-wrap:anywhere]",children:l}):null]}),f?h.jsx("span",{className:"ml-2 max-w-[60%] truncate text-[11px] text-text-400",children:c}):null]})}const s=t.replace(/\s+/g," ").trim().slice(0,80);return h.jsxs("div",{"data-testid":"msg-line-user-meta","data-meta-kind":e,className:"flex min-w-0 max-w-full flex-col items-start gap-1 py-1",children:[h.jsxs("button",{type:"button","aria-expanded":n,onClick:()=>r(o=>!o),className:re("group inline-flex items-center gap-1.5 rounded-md border border-bg-200/60 bg-bg-100/40","px-2 py-1 text-[11px] text-text-400 hover:bg-bg-200/40 transition-colors max-w-full"),children:[h.jsx(i,{className:"w-3 h-3 opacity-70 shrink-0"}),h.jsx("span",{className:"font-medium shrink-0",children:DJ[e]}),h.jsx("span",{className:"truncate text-text-400/80 max-w-[60ch]",children:s}),n?h.jsx(Yn,{className:"w-3 h-3 opacity-60 shrink-0"}):h.jsx(Bn,{className:"w-3 h-3 opacity-60 shrink-0"})]}),n?h.jsx("pre",{"data-testid":"user-meta-body",className:"w-full max-w-full whitespace-pre-wrap break-words text-[11px] text-text-400 bg-bg-50/60 rounded-md p-2 border border-bg-200/60 [overflow-wrap:anywhere]",children:t}):null]})}function Vk(e){return e.ordinal===null?e.label:`#${e.ordinal} ${e.label}`}function BJ({text:e,metaKind:t,resolveDispatchLine:n,onOpenFilePath:r}){const i=g.useMemo(()=>lz(e),[e]);return i.length===0?h.jsx(TM,{metaKind:t,text:e}):h.jsx("div",{"data-testid":"msg-line-dispatch-group",className:"my-1 flex min-w-0 max-w-full flex-col gap-1.5",children:i.map((s,o)=>h.jsx($J,{block:s,...n?{resolveDispatchLine:n}:{},...r?{onOpenFilePath:r}:{}},`${s.kind}-${s.dispatchId}-${o}`))})}function zJ(e){return e?{shell:"border-error/40 bg-error-dim",rail:"bg-error/55",hover:"hover:bg-error/10",icon:"text-error",title:"text-error",chevron:"text-error/70",seam:"border-error/25"}:{shell:"border-accent/35 bg-accent-dim",rail:"bg-accent/45",hover:"hover:bg-accent/10",icon:"text-accent",title:"text-accent",chevron:"text-accent/70",seam:"border-accent/20"}}function $J({block:e,resolveDispatchLine:t,onOpenFilePath:n}){const[r,i]=g.useState(!1),s=g.useMemo(()=>n?wM(n):Fs,[n]),o=e.kind==="task",a=t==null?void 0:t(e.dispatchId),l=o&&typeof e.round=="number"&&e.round>=2,c=e.status==="failure",u=zJ(c);return h.jsxs("div",{"data-testid":"msg-line-dispatch","data-dispatch-kind":e.kind,"data-dispatch-id":e.dispatchId,"data-round":e.round??"","data-status":e.status??"","data-open":r?"true":"false",className:re("flex min-w-0 max-w-full overflow-hidden rounded-lg border",u.shell),children:[h.jsx("span",{"data-testid":"dispatch-rail","aria-hidden":"true",className:re("w-[3px] shrink-0 self-stretch",u.rail)}),h.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[h.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>i(d=>!d),className:re("flex w-full min-w-0 cursor-pointer items-start gap-2 px-3 py-2 text-left transition-colors",u.hover),children:[h.jsx("span",{className:re("mt-[2px] shrink-0",u.icon),children:o?h.jsx(kI,{className:"h-3.5 w-3.5"}):h.jsx(bI,{className:"h-3.5 w-3.5"})}),h.jsxs("span",{className:"min-w-0 flex-1",children:[h.jsxs("span",{"data-testid":"dispatch-header",className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[h.jsx("span",{className:re("text-[12px] font-semibold",u.title),children:o?"委派任务":"委派回报"}),a?h.jsxs("span",{"data-testid":"dispatch-line","data-line-ordinal":a.ordinal??"",title:`来自 ${Vk(a)}`,className:"min-w-0 truncate text-[11px] text-text-300",children:[h.jsx("span",{className:"text-text-400",children:"来自"})," ",h.jsx("span",{className:"tabular-nums",children:Vk(a)})]}):null,l?h.jsxs("span",{"data-testid":"dispatch-round",className:"inline-flex items-center gap-1 rounded-md bg-bg-200/70 px-1.5 py-0.5 text-[10px] text-text-300",children:[h.jsx(R8,{className:"h-3 w-3"}),"续派第 ",e.round," 轮"]}):null,c?h.jsxs("span",{"data-testid":"dispatch-status",className:"inline-flex items-center gap-1 text-[11px] text-error",children:[h.jsx(Qi,{className:"h-3.5 w-3.5"}),"失败"]}):null,e.filePaths.length>0?h.jsxs("span",{"data-testid":"dispatch-file-count",className:"inline-flex items-center gap-1 text-[11px] text-text-400",children:[h.jsx(mi,{className:"h-3 w-3"}),e.filePaths.length," 个产物"]}):null]}),h.jsx("span",{"data-testid":"dispatch-brief",className:"mt-1 block whitespace-pre-wrap break-words text-[12px] leading-relaxed text-text-200 [overflow-wrap:anywhere]",children:e.brief}),e.briefIsDerived?h.jsxs("span",{"data-testid":"dispatch-brief-derived",title:"发送方没写摘要,这段是从正文首段自动截取的",className:"mt-1 inline-flex items-center gap-1 text-[10px] text-text-400 italic",children:[h.jsx(H8,{className:"h-2.5 w-2.5"}),"自动摘要(发送方未填)"]}):null]}),h.jsx("span",{className:re("mt-[3px] shrink-0",u.chevron),children:r?h.jsx(Yn,{className:"h-3.5 w-3.5"}):h.jsx(Bn,{className:"h-3.5 w-3.5"})})]}),r?h.jsxs(h.Fragment,{children:[h.jsx("div",{"data-testid":"dispatch-body",className:re("min-w-0 space-y-2 border-t bg-bg-200/35 py-2.5 pl-4 pr-3",u.seam),children:h.jsxs("div",{"data-testid":"dispatch-detail-indent",className:"min-w-0 border-l border-border/70 pl-3",children:[h.jsx("div",{"data-testid":"dispatch-detail",className:"assistant-markdown markdown-attached min-w-0 break-words",children:h.jsx(nl,{remarkPlugins:[rl],components:s,...n?{urlTransform:bM}:{},children:e.detail})}),e.filePaths.length>0?h.jsxs("div",{"data-testid":"dispatch-files",className:"flex min-w-0 flex-col gap-1 pt-2",children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"产物"}),e.filePaths.map(d=>h.jsx(FJ,{path:d,...n?{onOpenFilePath:n}:{}},d))]}):null]})}),h.jsxs("button",{type:"button","data-testid":"dispatch-collapse-foot",onClick:()=>i(!1),className:re("flex w-full cursor-pointer items-center justify-between gap-2 border-t bg-bg-200/35 px-3 py-1 text-[10px] text-text-400 transition-colors hover:bg-bg-200/60",u.seam),children:[h.jsx("span",{className:"min-w-0 truncate",children:e.dispatchId?h.jsxs(h.Fragment,{children:[h.jsx("span",{children:"台账 "}),h.jsx("span",{"data-testid":"dispatch-id",className:"font-mono",children:e.dispatchId})]}):null}),h.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1",children:["收起",h.jsx(xI,{className:"h-3 w-3"})]})]})]}):null]})]})}function FJ({path:e,onOpenFilePath:t}){const n="inline-flex min-w-0 items-center gap-1.5 text-left text-[11px] font-mono text-text-300";return t?h.jsxs("button",{type:"button","data-testid":"dispatch-file-path",title:e,onClick:()=>t(e),className:re(n,"hover:text-text-100 hover:underline"),children:[h.jsx(mi,{className:"h-3 w-3 shrink-0 text-text-400"}),h.jsx("span",{className:"truncate",children:e})]}):h.jsxs("span",{"data-testid":"dispatch-file-path",title:e,className:n,children:[h.jsx(mi,{className:"h-3 w-3 shrink-0 text-text-400"}),h.jsx("span",{className:"truncate",children:e})]})}function HJ({text:e,metaSource:t}){return t==="owner"?h.jsx("div",{className:"flex min-w-0 max-w-full flex-col items-start py-1.5","data-testid":"msg-line-owner-meta",children:h.jsxs("div",{className:re("inline-flex min-w-0 max-w-[85%] items-start gap-2 rounded-md","border-l-[3px] border-accent bg-accent-dim px-3 py-2"),children:[h.jsx(p8,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-accent","aria-label":"补充信息"}),h.jsx("span",{className:"min-w-0 text-[12px] leading-relaxed text-text-100 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:e})]})}):h.jsxs("div",{className:"flex min-w-0 max-w-full items-start gap-1.5 py-1 text-[11px] text-text-400","data-testid":"msg-line-cc-meta",children:[h.jsx(wI,{className:"mt-0.5 h-3 w-3 shrink-0"}),h.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:e})]})}function Gr(e,t){const r=new RegExp(`<${t}\\b[^>]*>([\\s\\S]*?)</${t}>`,"i").exec(e);if(!r)return;const i=r[1].trim();return i||void 0}function lg(e,t){const r=new RegExp(`${t}\\s*=\\s*"([^"]+)"`,"i").exec(e);if(!r)return;const i=Number(r[1]);return Number.isFinite(i)?i:void 0}function IM(e){var i,s,o;const t={};if(!e)return t;t.taskId=Gr(e,"task-id"),t.toolUseId=Gr(e,"tool-use-id"),t.outputFile=Gr(e,"output-file"),t.status=Gr(e,"status"),t.summary=Gr(e,"summary"),t.result=Gr(e,"result");const n=Gr(e,"usage");if(n){const a=(i=/<total_tokens>\s*(\d+)\s*<\/total_tokens>/i.exec(n))==null?void 0:i[1],l=(s=/<tool_uses>\s*(\d+)\s*<\/tool_uses>/i.exec(n))==null?void 0:s[1],c=(o=/<duration_ms>\s*(\d+)\s*<\/duration_ms>/i.exec(n))==null?void 0:o[1];a&&(t.totalTokens=Number(a)),l&&(t.toolUses=Number(l)),c&&(t.durationMs=Number(c))}const r=Gr(e,"worktree");if(r)t.worktreePath=Gr(r,"worktreePath"),t.worktreeBranch=Gr(r,"worktreeBranch");else{const a=/<worktree\b([^>]*)\/>/i.exec(e);if(a){const l=a[1],c=/worktreePath\s*=\s*"([^"]+)"/i.exec(l),u=/worktreeBranch\s*=\s*"([^"]+)"/i.exec(l);c&&(t.worktreePath=c[1]),u&&(t.worktreeBranch=u[1])}}if(t.totalTokens===void 0&&t.toolUses===void 0&&t.durationMs===void 0){const a=lg(e,"total_tokens"),l=lg(e,"tool_uses"),c=lg(e,"duration_ms");a!==void 0&&(t.totalTokens=a),l!==void 0&&(t.toolUses=l),c!==void 0&&(t.durationMs=c)}return t}function UJ(e){if(!e||!Number.isFinite(e))return null;if(e<1e3)return`${e}ms`;const t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;const n=Math.floor(t/60),r=Math.round(t-n*60);return`${n}m${r.toString().padStart(2,"0")}s`}function WJ({text:e,taskId:t,parentToolUseId:n}){const r=g.useMemo(()=>IM(e),[e]),[i,s]=g.useState(!1),o=t??r.taskId,a=n??r.toolUseId,l=r.status==="failed"?h.jsx(Qi,{className:"w-3.5 h-3.5 text-error"}):r.status==="completed"?h.jsx(cp,{className:"w-3.5 h-3.5 text-success"}):h.jsx(lp,{className:"w-3.5 h-3.5 text-text-400"}),c=r.status??"unknown",u=UJ(r.durationMs);return h.jsxs("div",{"data-testid":"msg-line-agent-notification","data-task-id":o??"","data-parent-tool-use-id":a??"",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/40",children:[h.jsxs("button",{type:"button","aria-expanded":i,onClick:()=>s(d=>!d),className:re("flex w-full min-w-0 items-start gap-2 px-2.5 py-1.5 text-left text-[12px]","hover:bg-bg-200/40 rounded-md transition-colors"),children:[h.jsx("span",{className:"mt-[2px] shrink-0",children:l}),h.jsxs("span",{className:"flex-1 min-w-0",children:[h.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[h.jsx("span",{className:"font-medium text-text-200",children:"子任务"}),h.jsx("span",{className:"text-text-400 text-[11px] font-mono",children:o?o.slice(0,12):"未知"}),h.jsx("span",{className:"text-text-400 text-[11px] uppercase tracking-wide",children:c}),u?h.jsxs("span",{className:"text-text-400 text-[11px] tabular-nums",children:["· ",u]}):null,r.totalTokens?h.jsxs("span",{className:"text-text-400 text-[11px] tabular-nums",children:["· ",r.totalTokens," tok"]}):null,r.toolUses?h.jsxs("span",{className:"text-text-400 text-[11px] tabular-nums",children:["· ",r.toolUses," tools"]}):null]}),r.summary?h.jsx("span",{className:"block truncate text-text-300 text-[12px] mt-0.5",children:r.summary}):null]}),i?h.jsx(Yn,{className:"w-3.5 h-3.5 mt-[3px] text-text-400 shrink-0"}):h.jsx(Bn,{className:"w-3.5 h-3.5 mt-[3px] text-text-400 shrink-0"})]}),i?h.jsxs("div",{"data-testid":"agent-notification-body",className:"min-w-0 border-t border-bg-200/60 px-3 py-2 text-[12px] text-text-300 space-y-2",children:[r.worktreePath||r.worktreeBranch?h.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-400",children:[h.jsx(Q_,{className:"w-3 h-3"}),r.worktreeBranch?h.jsx("span",{className:"font-mono",children:r.worktreeBranch}):null,r.worktreePath?h.jsx("span",{className:"truncate font-mono",children:r.worktreePath}):null]}):null,r.outputFile?h.jsxs("div",{className:"text-[11px] text-text-400",children:[h.jsx("span",{children:"输出文件:"}),h.jsx("span",{className:"font-mono",children:r.outputFile})]}):null,a?h.jsxs("div",{className:"text-[11px] text-text-400",children:[h.jsx("span",{children:"父工具调用:"}),h.jsx("span",{className:"font-mono",children:a})]}):null,r.result?h.jsx("div",{"data-testid":"agent-notification-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(nl,{remarkPlugins:[rl],components:Fs,children:r.result})}):h.jsx("div",{className:"text-[11px] text-text-400 italic",children:"无详细结果"})]}):null]})}const PM=g.createContext(null);function VJ({children:e}){const[t,n]=g.useState({agentId:null}),r=g.useCallback((o,a)=>{n({agentId:o,agentType:a})},[]),i=g.useCallback(()=>{n(o=>({agentId:null,agentType:o.agentType}))},[]),s=g.useMemo(()=>({state:t,open:r,close:i}),[t,r,i]);return h.jsx(PM.Provider,{value:s,children:e})}function RM(){return g.useContext(PM)}function qJ(e){if(e==null)return null;if(typeof e=="string")return e;if(Array.isArray(e)){const t=[];for(const n of e)if(n&&typeof n=="object"){const r=n;r.type==="text"&&typeof r.text=="string"&&t.push(r.text)}else typeof n=="string"&&t.push(n);return t.length?t.join(`
537
- `):null}if(typeof e=="object"){const t=e;if(typeof t.text=="string")return t.text}return null}function qk(e){if(!e||!Number.isFinite(e))return null;if(e<1e3)return`${e}ms`;const t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;const n=Math.floor(t/60),r=Math.round(t-n*60);return`${n}m${r.toString().padStart(2,"0")}s`}function KJ(e){return!e||!Number.isFinite(e)?null:e<1e3?`${e} tok`:e<1e4?`${(e/1e3).toFixed(1)}k tok`:`${Math.round(e/1e3)}k tok`}const GJ={readCount:"read",searchCount:"search",bashCount:"bash",editFileCount:"edit",linesAdded:"+lines",linesRemoved:"-lines",otherToolCount:"other"};function YJ(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e)){if(!r||r<=0)continue;const i=GJ[n]??n;t.push(`${i}:${r}`)}return t}function XJ({expandable:e,expanded:t,onToggle:n,children:r}){const i=re("flex w-full min-w-0 items-center gap-2 px-2.5 py-1.5 text-left text-[13px] rounded-md",e&&"hover:bg-bg-200/40 transition-colors");return e?h.jsx("button",{type:"button","aria-expanded":t,onClick:n,className:i,children:r}):h.jsx("div",{className:i,children:r})}function MM({description:e,input:t,output:n,error:r,pending:i,notifications:s,toolResultExtra:o,progress:a,expandable:l=!0}){const[c,u]=g.useState(!1),d=RM(),f=g.useMemo(()=>{if(!t||typeof t!="object")return null;const R=t;return typeof R.prompt=="string"?R.prompt:null},[t]),p=g.useMemo(()=>{if(!t||typeof t!="object")return;const R=t.agentId;return typeof R=="string"&&R.length>0?R:void 0},[t]),m=(o==null?void 0:o.prompt)??f,v=g.useMemo(()=>qJ(n),[n]),w=o==null?void 0:o.stats,x=a==null?void 0:a.stats,_=qk((w==null?void 0:w.durationMs)??(x==null?void 0:x.durationMs)),y=KJ((w==null?void 0:w.tokens)??(x==null?void 0:x.tokens)),S=YJ(w==null?void 0:w.toolStats),C=d5({pending:i,error:r,notifications:s,progress:a,input:t}),k=C&&(a!=null&&a.lastToolName)?`now:${a.lastToolName}`:null,N=!!(o!=null&&o.agentType||_||y||S.length>0||k),T=(o==null?void 0:o.agentId)??(a==null?void 0:a.agentId)??p,O=!!(r||(a==null?void 0:a.status)==="failed"),P=g.useMemo(()=>s.map(R=>({taskId:R.taskId,text:R.text,parsed:IM(R.text)})),[s]),D=O?h.jsx(Qi,{className:"w-3.5 h-3.5 text-error"}):C?h.jsx(Ln,{className:"w-3.5 h-3.5 text-blue-400 animate-spin"}):h.jsx(cp,{className:"w-3.5 h-3.5 text-green-500"});return h.jsxs("div",{"data-testid":"msg-line-agent-call","data-pending":i?"true":"false","data-active":C?"true":"false","data-has-error":O?"true":"false","data-notification-count":s.length,"data-has-stats":N?"true":"false","data-agent-id":T??"",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/30",children:[h.jsxs(XJ,{expandable:l,expanded:c,onToggle:()=>u(R=>!R),children:[h.jsx("span",{className:"w-5 h-5 flex items-center justify-center text-[10px] rounded bg-violet-500/10 text-violet-500 shrink-0","aria-hidden":!0,children:h.jsx(sF,{className:"w-3 h-3"})}),h.jsx("span",{className:"shrink-0",children:D}),h.jsx("span",{className:"flex-1 min-w-0 truncate font-medium text-text-200",children:e}),N?null:s.length>0?h.jsxs("span",{className:"text-[11px] text-text-400 tabular-nums shrink-0",children:[s.length," 次通知"]}):null,T&&(d!=null&&d.open)?h.jsx("span",{role:"button",tabIndex:0,"data-testid":"open-subagent-btn-header","data-agent-id":T,"aria-label":"打开子 agent 对话",onClick:R=>{R.stopPropagation(),d.open(T,o==null?void 0:o.agentType)},onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.stopPropagation(),R.preventDefault(),d.open(T,o==null?void 0:o.agentType))},className:"shrink-0 inline-flex items-center justify-center w-3.5 h-3.5 text-text-400 hover:text-text-200",children:h.jsx(tu,{className:"w-3.5 h-3.5"})}):null,l?c?h.jsx(Yn,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(Bn,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):null]}),C&&(a!=null&&a.description)?h.jsx("div",{"data-testid":"agent-call-progress-desc",className:"px-3 pt-0 pb-1 text-[12px] text-text-300 truncate",children:a.description}):null,N?h.jsxs("div",{"data-testid":"agent-call-stats",className:"flex items-center gap-1.5 flex-wrap px-3 pb-1.5 pt-0 text-[11px] text-text-400",children:[o!=null&&o.agentType?h.jsx("span",{"data-testid":"agent-call-stats-type",className:"inline-flex items-center rounded-sm bg-violet-500/10 px-1.5 py-0.5 text-violet-400 font-medium",children:o.agentType}):null,_?h.jsx("span",{className:"tabular-nums",children:_}):null,y?h.jsx("span",{className:"tabular-nums",children:y}):null,k?h.jsx("span",{"data-testid":"agent-call-stats-now",className:"font-mono tabular-nums text-blue-400",children:k}):null,S.map(R=>h.jsx("span",{className:"font-mono tabular-nums text-text-400/80",children:R},R)),s.length>0?h.jsxs("span",{className:"tabular-nums text-text-400/70",children:["· ",s.length," 次通知"]}):null]}):null,c?h.jsxs("div",{"data-testid":"agent-call-body",className:"min-w-0 border-t border-bg-200/60 px-3 py-2 space-y-3",children:[r?h.jsx("div",{className:"text-[12px] text-error whitespace-pre-wrap",children:r}):null,P.map((R,A)=>{const M=R.parsed,L=qk(M.durationMs);return h.jsxs("div",{"data-testid":"agent-call-notification","data-task-id":R.taskId??"",className:"min-w-0 rounded-md border border-bg-200/60 bg-bg-0/40 p-2 space-y-1.5",children:[h.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-400 flex-wrap",children:[h.jsx("span",{className:"font-mono",children:(R.taskId??M.taskId??"未知").slice(0,12)}),h.jsx("span",{className:"uppercase tracking-wide",children:M.status??"unknown"}),L?h.jsxs("span",{className:"tabular-nums",children:["· ",L]}):null,M.totalTokens?h.jsxs("span",{className:"tabular-nums",children:["· ",M.totalTokens," tok"]}):null,M.toolUses?h.jsxs("span",{className:"tabular-nums",children:["· ",M.toolUses," tools"]}):null,M.worktreeBranch?h.jsxs("span",{className:"font-mono",children:["· ",M.worktreeBranch]}):null]}),M.summary?h.jsx("div",{className:"text-[12px] text-text-300",children:M.summary}):null,M.result?h.jsx("div",{"data-testid":"agent-call-notification-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(nl,{remarkPlugins:[rl],components:Fs,children:M.result})}):null]},`${R.taskId??"n"}-${A}`)}),m?h.jsxs("div",{"data-testid":"agent-call-prompt-block",className:"min-w-0 space-y-1",children:[h.jsx("div",{className:"text-[11px] text-text-400 font-medium",children:"任务指令"}),h.jsx("pre",{"data-testid":"agent-call-prompt",className:"max-w-full whitespace-pre-wrap break-words text-[11px] text-text-300 bg-bg-50/60 rounded p-2 border border-bg-200/60 max-h-64 overflow-auto [overflow-wrap:anywhere]",children:m})]}):null,v?h.jsxs("div",{"data-testid":"agent-call-result-block",className:"min-w-0 space-y-1",children:[h.jsx("div",{className:"text-[11px] text-text-400 font-medium",children:"子 agent 报告"}),h.jsx("div",{"data-testid":"agent-call-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(nl,{remarkPlugins:[rl],components:Fs,children:v})})]}):null,!v&&P.length===0&&!r&&!m?h.jsx("div",{className:"text-[11px] text-text-400 italic",children:"无详细信息"}):null,T&&(d!=null&&d.open)?h.jsx("div",{className:"flex justify-end",children:h.jsxs("button",{type:"button","data-testid":"open-subagent-btn","data-agent-id":T,onClick:()=>d.open(T,o==null?void 0:o.agentType),className:re("inline-flex items-center gap-1 rounded-md border border-bg-200/60","bg-bg-100/40 hover:bg-bg-200/40 transition-colors","px-2 py-1 text-[11px] text-text-300"),children:[h.jsx(tu,{className:"w-3 h-3"}),h.jsx("span",{children:"打开子 agent 对话"})]})}):null]}):null]})}function AM({title:e,items:t,progressColor:n="bg-green-500",listKind:r}){const[i,s]=g.useState(!1),o=t.length,a=t.filter(c=>c.status==="completed").length,l=o>0?Math.round(a/o*100):0;return h.jsxs("div",{"data-testid":"msg-line-checklist","data-list-kind":r,className:"min-w-0 max-w-full py-1",children:[h.jsxs("button",{type:"button",onClick:()=>s(c=>!c),"aria-expanded":i,className:"flex items-center gap-2.5 w-full text-left rounded-md px-1.5 py-1 hover:bg-text-100/5 cursor-pointer",children:[i?h.jsx(Yn,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(Bn,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"text-[13px] font-medium text-text-200",children:e}),h.jsxs("span",{className:"text-[11px] text-text-400 tabular-nums",children:[a,"/",o]}),h.jsx("div",{className:"flex-1 max-w-[120px] h-1.5 rounded-full bg-text-100/10 overflow-hidden",children:h.jsx("div",{className:re("h-full rounded-full transition-all duration-300",n),style:{width:`${l}%`}})})]}),i?h.jsx("div",{"data-testid":"checklist-body",className:"ml-6 mt-0.5",children:h.jsx("div",{className:"space-y-px",children:t.map((c,u)=>h.jsxs("div",{className:"flex min-w-0 items-start gap-2 py-0.5 px-1",children:[h.jsx("span",{className:"w-4 h-4 mt-0.5 flex items-center justify-center shrink-0",children:c.status==="completed"?h.jsx(wl,{className:"w-3.5 h-3.5 text-green-500"}):h.jsx("span",{className:"w-2 h-2 rounded-full border border-text-400/40"})}),h.jsx("span",{className:re("min-w-0 text-[13px] leading-snug break-words [overflow-wrap:anywhere]",c.status==="completed"?"text-text-400 line-through":"text-text-200"),children:c.status==="in_progress"&&c.activeForm?c.activeForm:c.content})]},`${u}-${c.content}`))})}):null]})}function QJ({todos:e}){return h.jsx(AM,{title:"Tasks",items:e,progressColor:"bg-green-500",listKind:"todo"})}function ZJ({tasks:e}){return h.jsx(AM,{title:"Plan",items:e,progressColor:"bg-blue-500",listKind:"plan"})}function JJ(e){if(!e||!Number.isFinite(e))return null;const t=Date.now()-e;if(t<0)return null;const n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);if(i<24)return`${i}h ago`;const s=Math.floor(i/24);if(s<7)return`${s}d ago`;const o=Math.floor(s/7);return o<5?`${o}w ago`:new Date(e).toISOString().slice(0,10)}function eee(e){return(e.split("/").pop()??e)||e}function tee({memories:e}){return!e||e.length===0?null:h.jsxs("div",{"data-testid":"memory-callout",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/30",children:[h.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5 text-[12px] text-text-300 border-b border-bg-200/60",children:[h.jsx(E$,{className:"w-3.5 h-3.5 text-amber-500 shrink-0"}),h.jsx("span",{className:"font-medium",children:"项目记忆"}),h.jsxs("span",{className:"text-text-400 tabular-nums",children:["· ",e.length]})]}),h.jsx("ul",{className:"divide-y divide-bg-200/40",children:e.map(t=>h.jsx(nee,{memory:t},t.path))})]})}function nee({memory:e}){const[t,n]=g.useState(!1),r=JJ(e.mtimeMs),i=e.content.replace(/\s+/g," ").trim().slice(0,80);return h.jsxs("li",{className:"px-2.5 py-1.5",children:[h.jsxs("button",{type:"button","aria-expanded":t,onClick:()=>n(s=>!s),className:re("flex w-full items-center gap-1.5 text-left text-[12px]","hover:bg-bg-200/30 rounded-sm py-0.5"),children:[t?h.jsx(Yn,{className:"w-3 h-3 text-text-400 shrink-0"}):h.jsx(Bn,{className:"w-3 h-3 text-text-400 shrink-0"}),h.jsx("span",{className:"font-mono text-text-300 shrink-0 max-w-[20ch] truncate",title:e.path,children:eee(e.path)}),h.jsx("span",{className:"flex-1 min-w-0 truncate text-text-400/80",children:i}),r?h.jsx("span",{className:"shrink-0 text-[11px] text-text-400 tabular-nums",children:r}):null]}),t?h.jsx("pre",{"data-testid":"memory-callout-body",className:"mt-1 max-w-full whitespace-pre-wrap break-words text-[12px] text-text-300 bg-bg-50/60 rounded-md p-2 border border-bg-200/60 [overflow-wrap:anywhere]",children:e.content}):null]})}function ree({toolUseId:e,questions:t,onSubmit:n,onCancel:r,submittedAnswers:i}){const[s,o]=g.useState({}),[a,l]=g.useState({}),[c,u]=g.useState({}),[d,f]=g.useState(!1),[p,m]=g.useState(!1),v=i!==void 0&&Object.keys(i).length>0,w=v||p,x=!n&&!v,_=(k,N)=>{const T={labels:new Set,freeText:""};if(!v||!i)return T;const O=i[k];if(typeof O!="string")return T;const P=O.split(",").map(M=>M.trim()).filter(Boolean),D=new Set(N.map(M=>M.label)),R=new Set,A=[];for(const M of P)D.has(M)?R.add(M):A.push(M);return{labels:R,freeText:A.join(", ")}},y=g.useMemo(()=>t.every(k=>{if((c[k.question]??"").trim().length>0)return!0;if(k.multiSelect){const T=a[k.question];return!!(T&&T.size>0)}return typeof s[k.question]=="string"&&s[k.question].length>0}),[t,s,a,c]),S=async()=>{if(!y||d||w||x||!n)return;const k={};for(const N of t){const T=(c[N.question]??"").trim();if(N.multiSelect){const O=a[N.question],P=O?N.options.filter(D=>O.has(D.label)).map(D=>D.label):[];if(T.length>0&&P.push(T),P.length===0)continue;k[N.question]=P.join(", ")}else if(T.length>0)k[N.question]=T;else{const O=s[N.question];typeof O=="string"&&(k[N.question]=O)}}f(!0);try{await n(k),m(!0)}finally{f(!1)}},C=Ru(()=>{S()});return h.jsxs("div",{"data-testid":"msg-line-question","data-tool-use-id":e,className:"min-w-0 max-w-full rounded-md border border-accent/40 bg-accent/5 px-3 py-2.5 text-[13px]",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 mb-2",children:[h.jsx(O$,{className:"w-4 h-4 text-accent shrink-0"}),h.jsx("span",{className:"min-w-0 font-medium text-text-100",children:"需要你的回答 / Need your answer"}),t.length>1?h.jsxs("span",{className:"ml-auto text-[12px] text-text-400","data-testid":"msg-line-question-count",children:[t.length," 个问题"]}):null]}),h.jsx("div",{className:"flex flex-col gap-3 mb-3",children:t.map((k,N)=>{const T=`q-${N}`,O=`${e}-${N}`,P=_(k.question,k.options),D=w||x,R=c[k.question]??"",A=v?P.freeText:p?(c[k.question]??"").trim():"";return h.jsxs("div",{"data-testid":"msg-line-question-item",children:[k.question?h.jsx("div",{className:"text-text-200 mb-1.5",children:k.question}):null,h.jsx("div",{className:"flex flex-col gap-1",children:k.options.map((M,L)=>{var B;const $=`${T}-${L}`,F=v?P.labels.has(M.label):k.multiSelect?!!((B=a[k.question])!=null&&B.has(M.label)):s[k.question]===M.label;return h.jsxs("label",{className:"flex min-w-0 items-start gap-2 cursor-pointer select-none py-1 px-2 rounded hover:bg-bg-100",children:[h.jsx("input",{type:k.multiSelect?"checkbox":"radio",name:O,value:M.label,checked:F,disabled:w||x,onChange:()=>{w||x||(k.multiSelect?l(z=>{const E=new Set(z[k.question]??[]);return E.has(M.label)?E.delete(M.label):E.add(M.label),{...z,[k.question]:E}}):o(z=>({...z,[k.question]:M.label})))},className:"mt-0.5","data-testid":"msg-line-question-option"}),h.jsxs("span",{className:"flex min-w-0 flex-col",children:[h.jsx("span",{className:"text-text-100 [overflow-wrap:anywhere]",children:M.label}),M.description?h.jsx("span",{className:"text-[12px] text-text-400 [overflow-wrap:anywhere]",children:M.description}):null]})]},$)})}),D?A.length>0?h.jsx("div",{className:"mt-2 rounded-lg border border-accent/15 bg-bg-100/60 px-3 py-2 text-[13px] leading-relaxed text-text-200 [overflow-wrap:anywhere]","data-testid":"msg-line-question-freetext-result",children:A}):null:h.jsx("textarea",{rows:3,value:R,placeholder:"或自行输入回答...",onChange:M=>{const L=M.target.value;u($=>({...$,[k.question]:L}))},...C,className:"mt-2 w-full resize-y rounded-lg border border-accent/20 bg-bg-000/60 px-3 py-2 text-[13px] leading-relaxed text-text-100 placeholder:text-text-400 outline-none transition-colors focus:border-accent/60 focus:bg-bg-000","data-testid":"msg-line-question-freetext"})]},T)})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(di,{size:"sm",variant:"default",onClick:()=>void S(),disabled:!y||d||w||x,"data-testid":"msg-line-question-submit",children:w?"已提交 / Submitted":x?"已结束 / Ended":"提交 / Submit"}),r&&!w&&!x?h.jsx(di,{size:"sm",variant:"ghost",onClick:()=>void r(),disabled:d,"data-testid":"msg-line-question-cancel",children:"跳过 / Skip"}):null]})]})}function iee({toolUseId:e,questions:t,historicalAnswers:n,realtimeAnswers:r,onSubmit:i,onCancel:s}){const o=r??n,a=g.useCallback(async c=>{i&&await i(e,c)},[i,e]),l=g.useCallback(async()=>{s&&await s(e)},[s,e]);return h.jsx(ree,{toolUseId:e,questions:t,onSubmit:i?a:void 0,...s?{onCancel:l}:{},submittedAnswers:o})}function see(){const e=new Map,t=(n,r)=>`${n}::${r}`;return{register(n,r,i){e.set(t(n,r),i)},resolve(n,r){return n?e.get(t(n,r))??null:null},reset(){e.clear()}}}const Nl=see();function jM({lines:e,onPermissionRespond:t,onPermissionInterrupt:n,topSlot:r,onRewind:i,rewindableUserMessageIds:s,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v,onOpenFilePath:w,resolveDispatchLine:x,turnCollapse:_,dockedAgentToolUseIds:y}){const S=g.useMemo(()=>h5(e),[e]),C=g.useMemo(()=>_?FV(S,_):null,[S,_]),k={onRewind:i,rewindableUserMessageIds:s,onPermissionRespond:t,onPermissionInterrupt:n,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v,onOpenFilePath:w,resolveDispatchLine:x,dockedAgentToolUseIds:y};return h.jsxs("div",{"data-testid":"message-list",className:"flex w-full min-w-0 max-w-full flex-col gap-2 px-4 py-3",children:[r,C!==null?C.map(N=>oee(N,k)):S.map(N=>gf(N,k))]})}function oee(e,t){const n=`turn-${e.seq}`,r=e.query?gf(e.query,t):null,i=e.process.map(o=>aee(o,t)),s=e.tail.map(o=>gf(o,t));return e.status==="running"?h.jsxs(Qe.Fragment,{children:[r,i,s]},n):h.jsxs(Qe.Fragment,{children:[r,h.jsx(JV,{status:e.status,...e.durationMs!==void 0?{durationMs:e.durationMs}:{},children:i}),s]},n)}function aee(e,t){return e.kind==="tool-group"?h.jsx(XV,{items:e.items,renderItemDetail:n=>lee(n,t)},`tool-group-${e.seq}`):gf(e,t)}function lee(e,t){const n=Nl.resolve(e.toolKind,e.tool);return n?n.render({input:e.input,output:e.output,error:e.error,pending:e.pending,toolUseId:e.toolUseId,...t.fileSharingScope?{fileScope:t.fileSharingScope}:{},...t.onShareFile?{onShareFile:t.onShareFile}:{},...t.onOpenInTab?{onOpenInTab:t.onOpenInTab}:{},...t.onPreviewMarkdown?{onPreviewMarkdown:t.onPreviewMarkdown}:{}}):null}function gf(e,t){var y;const{onRewind:n,rewindableUserMessageIds:r,onPermissionRespond:i,onPermissionInterrupt:s,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v,onOpenFilePath:w,resolveDispatchLine:x}=t,_=`${e.kind}-${e.seq}`;switch(e.kind){case"session-init":return null;case"user-text":{const S=typeof e.uuid=="string"?e.uuid:void 0,C=!!(n&&S&&(!r||r.has(S)));return h.jsx(AJ,{text:e.text,senderDisplayName:e.senderDisplayName,senderPrincipal:e.senderPrincipal,rewindTarget:C&&S&&n?{userMessageId:S,onRewind:n}:void 0},_)}case"user-meta":return op(e.metaKind)?h.jsx(BJ,{text:e.text,metaKind:e.metaKind,...x?{resolveDispatchLine:x}:{},...w?{onOpenFilePath:w}:{}},_):h.jsx(TM,{metaKind:e.metaKind,text:e.text},_);case"meta-text":return h.jsx(HJ,{text:e.text,metaSource:e.metaSource},_);case"agent-notification":return h.jsx(WJ,{text:e.text,taskId:e.taskId,parentToolUseId:e.parentToolUseId},_);case"assistant-text":{const S=typeof e.uuid=="string"?e.uuid:void 0,C=S&&(o||a)?{messageUuid:S,onFork:o,onQuickAsk:a}:void 0;return h.jsx(tJ,{text:iq(e.text),forkTarget:C,...w?{onOpenFilePath:w}:{}},_)}case"assistant-thinking":return h.jsx(nJ,{text:e.text},_);case"permission-inline":return h.jsx(TJ,{tool:e.tool,input:e.input,onRespond:i??(()=>{}),onInterrupt:s},_);case"error":return h.jsx(IJ,{message:e.message},_);case"turn-end":return null;case"merged-tool":return cee(e,_,{fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v});case"merged-agent":return(y=t.dockedAgentToolUseIds)!=null&&y.has(e.toolUseId)?null:h.jsx(MM,{description:e.description,input:e.input,output:e.output,error:e.error,pending:e.pending,notifications:e.notifications,toolResultExtra:e.toolResultExtra,progress:e.progress},_);case"plan-card":return h.jsx(ZJ,{tasks:e.tasks},_);case"todo-checklist":return h.jsx(QJ,{todos:e.todos},_);case"memory-callout":return h.jsx(tee,{memories:e.memories},_);case"question-card":{const S=d===void 0||d.has(e.toolUseId);return h.jsx(iee,{toolUseId:e.toolUseId,questions:e.questions,historicalAnswers:e.submittedAnswers,realtimeAnswers:l==null?void 0:l[e.toolUseId],onSubmit:S?c:void 0,...S&&u?{onCancel:u}:{}},_)}default:return null}}function cee(e,t,n){const r=Nl.resolve(e.toolKind,e.tool),i=r?r.render({input:e.input,output:e.output,error:e.error,pending:e.pending,toolUseId:e.toolUseId,...n.fileSharingScope?{fileScope:n.fileSharingScope}:{},...n.onShareFile?{onShareFile:n.onShareFile}:{},...n.onOpenInTab?{onOpenInTab:n.onOpenInTab}:{},...n.onPreviewMarkdown?{onPreviewMarkdown:n.onPreviewMarkdown}:{}}):null;return h.jsx(Qe.Fragment,{children:i??h.jsx(CM,{tool:e.tool,input:e.input,output:e.output,error:e.error,pending:e.pending,...n.fileSharingScope?{fileScope:n.fileSharingScope}:{},...n.onShareFile?{onShareFile:n.onShareFile}:{},...n.onOpenInTab?{onOpenInTab:n.onOpenInTab}:{},...n.onPreviewMarkdown?{onPreviewMarkdown:n.onPreviewMarkdown}:{}})},t)}const uee={builtin:"Commands",global:"Global",project:"Project",plugin:"Plugin"},Kk={builtin:0,global:1,project:2,plugin:3};function dee({query:e,skills:t,activeIndex:n,onActiveIndexChange:r,onSelect:i}){const s=g.useRef(null),o=g.useMemo(()=>LM(t,e),[t,e]),a=g.useMemo(()=>{const l=new Set;let c=null;for(let u=0;u<o.length;u++)o[u].source!==c&&(l.add(u),c=o[u].source);return l},[o]);return g.useEffect(()=>{var l;try{(l=s.current)==null||l.scrollIntoView({block:"nearest"})}catch{}},[n]),o.length===0?null:h.jsx("div",{"data-testid":"cc-skill-selector",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 max-h-[320px] overflow-y-auto rounded-2xl border border-bg-300 bg-bg-50 shadow-lg",children:o.map((l,c)=>{const u=c===n,d=a.has(c);return h.jsxs(Qe.Fragment,{children:[d?h.jsx("div",{className:"sticky top-0 z-10 bg-bg-50/95 backdrop-blur-sm px-4 py-2 text-[10px] font-semibold uppercase tracking-wider text-text-400/70 border-b border-bg-200/60",children:uee[l.source]}):null,h.jsxs("div",{ref:u?s:void 0,"data-testid":`cc-skill-item-${l.name}`,onMouseEnter:()=>r(c),onClick:()=>i(l),className:re("flex items-center gap-2.5 px-4 py-2 cursor-pointer transition-colors duration-75",u?"bg-[var(--text-100-dim)]":"hover:bg-bg-100/60"),children:[h.jsxs("code",{className:"text-[12px] font-mono font-semibold text-text-100 shrink-0",children:["/",l.name]}),l.description?h.jsx("span",{className:"text-[11px] text-text-300 truncate ml-auto",children:l.description}):null]})]},`${l.source}/${l.name}`)})})}function LM(e,t){const n=t.trim().toLowerCase(),r=n?e.filter(i=>i.name.toLowerCase().includes(n)||(i.description??"").toLowerCase().includes(n)):e.slice();return r.sort((i,s)=>(Kk[i.source]??9)-(Kk[s.source]??9)),r.slice(0,30)}const hee=g.createContext(null);function fee(){return g.useContext(hee)}const pee={builtin:"Built-in",global:"Global",project:"Project",policy:"Policy",plugin:"Plugin",persona:"My personas",contact:"People","remote-persona":"Remote personas"},Gk={builtin:0,global:1,project:2,policy:3,plugin:4,persona:5,contact:6,"remote-persona":7};function vf(e){switch(e.kind){case"persona":return"persona";case"contact":return"contact";case"remote-persona":return"remote-persona";case"cc-agent":return e.agent.source}}function mee(e){switch(e.kind){case"persona":return`persona/${e.persona.personaId}`;case"contact":return`contact/${e.contact.deviceId}`;case"remote-persona":return`remote/${e.deviceId}/${e.persona.personaId}`;case"cc-agent":return`${e.agent.source}/${e.agent.name}`}}function gee(e){switch(e.kind){case"persona":return`${e.persona.personaId} ${e.persona.label}`.toLowerCase();case"contact":return`${e.contact.displayName} ${e.contact.deviceId}`.toLowerCase();case"remote-persona":return`${e.persona.personaId} ${e.persona.label}`.toLowerCase();case"cc-agent":{const t=e.agent;return`${t.name} ${t.description??""} ${t.whenToUse??""}`.toLowerCase()}}}function vee(e){switch(e.kind){case"persona":return{displayName:`@persona/${e.persona.personaId}`,description:e.persona.label,testid:`cc-agent-item-persona-${e.persona.personaId}`};case"contact":return{displayName:`@${e.contact.displayName}`,description:e.contact.deviceId,testid:`cc-agent-item-contact-${e.contact.deviceId}`};case"remote-persona":return{displayName:`@persona/${e.persona.personaId}`,description:e.persona.label,testid:`cc-agent-item-remote-${e.deviceId}-${e.persona.personaId}`};case"cc-agent":return{displayName:`@${e.agent.name}`,description:e.agent.description,whenToUse:e.agent.whenToUse,plugin:e.agent.plugin,testid:`cc-agent-item-${e.agent.name}`}}}function DM(e,t){const n=t.trim().toLowerCase(),r=n?e.filter(i=>gee(i).includes(n)):e.slice();return r.sort((i,s)=>(Gk[vf(i)]??9)-(Gk[vf(s)]??9)),r.slice(0,30)}function Yk({query:e,entries:t,activeIndex:n,onActiveIndexChange:r,onSelect:i}){const s=g.useRef(null),o=g.useMemo(()=>DM(t,e),[t,e]),a=g.useMemo(()=>{const l=new Set;let c=null;for(let u=0;u<o.length;u++){const d=vf(o[u]);d!==c&&(l.add(u),c=d)}return l},[o]);return g.useEffect(()=>{var l;try{(l=s.current)==null||l.scrollIntoView({block:"nearest"})}catch{}},[n]),o.length===0?null:h.jsx("div",{"data-testid":"cc-agent-selector",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 max-h-[320px] overflow-y-auto rounded-2xl border border-bg-300 bg-bg-50 shadow-lg",children:o.map((l,c)=>{const u=c===n,d=a.has(c),f=vf(l),p=vee(l);return h.jsxs(Qe.Fragment,{children:[d?h.jsx("div",{"data-testid":`cc-agent-group-header-${f}`,"data-source":f,className:"sticky top-0 z-10 bg-bg-50/95 backdrop-blur-sm px-4 py-2 text-[10px] font-semibold uppercase tracking-wider text-text-400/70 border-b border-bg-200/60",children:pee[f]}):null,h.jsxs("div",{ref:u?s:void 0,"data-testid":p.testid,onMouseEnter:()=>r(c),onClick:()=>i(l),className:re("flex items-center gap-2.5 px-4 py-2 cursor-pointer transition-colors duration-75",u?"bg-[var(--text-100-dim)]":"hover:bg-bg-100/60"),children:[h.jsx("code",{className:"text-[12px] font-mono font-semibold text-text-100 shrink-0",children:p.displayName}),p.description?h.jsx("span",{className:"text-[11px] text-text-300 truncate ml-2",children:p.description}):null,p.whenToUse?h.jsx("span",{className:"text-[10px] text-text-400/70 italic truncate ml-auto",children:p.whenToUse}):null,p.plugin?h.jsx("span",{className:"text-[10px] text-text-400/70 ml-2 shrink-0",children:p.plugin}):null]})]},mee(l))})})}function xee({attachment:e,onRemove:t,onOpenPreview:n}){const r=e.mimeType.startsWith("image/"),i=e.status==="error",s=e.status==="uploading",o=r&&e.status==="done"&&!!e.previewUrl&&!!n;return h.jsxs("div",{"data-testid":`attachment-pill-${e.id}`,className:re("group relative flex items-center gap-1.5 rounded-lg border px-2 py-1.5 text-[12px] transition-colors",i?"border-red-400/40 bg-red-500/5":"border-bg-300 bg-bg-100"),children:[r&&e.previewUrl?h.jsxs("div",{className:"relative h-7 w-7 shrink-0",children:[h.jsx("img",{src:e.previewUrl,alt:e.fileName,onClick:o?n:void 0,"data-testid":`attachment-thumb-${e.id}`,className:re("h-7 w-7 rounded object-cover",o&&"cursor-pointer hover:opacity-80",s&&"opacity-40")}),s?h.jsx(Ln,{"data-testid":`attachment-spinner-${e.id}`,className:"absolute inset-0 m-auto h-3.5 w-3.5 animate-spin text-text-200"}):null]}):h.jsx("div",{className:"relative flex h-7 w-7 items-center justify-center rounded bg-text-100/5 shrink-0",children:s?h.jsx(Ln,{"data-testid":`attachment-spinner-${e.id}`,className:"h-3.5 w-3.5 animate-spin text-text-400"}):h.jsx(mi,{className:"h-3.5 w-3.5 text-text-400"})}),h.jsx("span",{className:re("max-w-[120px] truncate text-text-200",s&&"text-text-400"),title:e.error??e.fileName,children:e.fileName}),i?h.jsx(Qi,{className:"h-3 w-3 text-red-400 shrink-0"}):null,h.jsx("button",{type:"button",onClick:t,"data-testid":`attachment-remove-${e.id}`,className:"flex h-4 w-4 items-center justify-center rounded-full text-text-400 hover:text-text-100 hover:bg-text-100/10 transition-colors cursor-pointer shrink-0","aria-label":"remove",children:h.jsx(Ir,{className:"h-3 w-3"})})]})}function _ee({attachments:e,onRemove:t,onOpenPreview:n}){return e.length===0?null:h.jsx("div",{"data-testid":"attachment-row",className:"flex flex-wrap gap-1.5 mb-2 px-1",children:e.map(r=>h.jsx(xee,{attachment:r,onRemove:()=>t(r.id),onOpenPreview:n?()=>n(r):void 0},r.id))})}class sc extends Error{constructor(t,n,r){super(n),this.code=t,this.status=r,this.name="UploadAttachmentError"}}async function yee(e){if(!e.httpBaseUrl)throw new sc("TUNNEL_NOT_READY","daemon httpBaseUrl unavailable");if(!e.httpToken)throw new sc("NO_AUTH","daemon httpToken unavailable");const t=new URLSearchParams({sessionId:e.sessionId,fileName:e.file.name,mimeType:e.file.type||"application/octet-stream"}),n=`${e.httpBaseUrl.replace(/\/$/,"")}/attachments/upload?${t.toString()}`;let r;try{r=await fetch(n,{method:"POST",headers:{Authorization:`Bearer ${e.httpToken}`,"Content-Type":e.file.type||"application/octet-stream"},body:e.file})}catch(i){throw new sc("NETWORK_ERROR",i.message)}if(!r.ok){let i="UPLOAD_FAILED",s=`HTTP ${r.status}`;try{const o=await r.json();o.code&&(i=o.code),o.message&&(s=o.message)}catch{}throw new sc(i,s,r.status)}return await r.json()}const Xk=25*1024*1024,bee="image/*,.txt,.md,.markdown,.csv,.json,.log,.yaml,.yml,.html,.xml,.pdf",wee=["image/","text/"],See=new Set(["application/json","application/xml","application/x-yaml","application/yaml","application/pdf"]),kee=new Set(["txt","md","markdown","csv","json","log","yaml","yml","html","xml","pdf"]);function Cee(e){var r;const t=(e.type||"").toLowerCase();if(t&&wee.some(i=>t.startsWith(i))||t&&See.has(t))return!0;const n=((r=e.name.split(".").pop())==null?void 0:r.toLowerCase())??"";return n.length>0&&kee.has(n)}let Eee=0;const Nee=()=>`att-${++Eee}-${Date.now()}`;function Tee(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(typeof r.result=="string"?r.result:""),r.onerror=()=>n(r.error??new Error("read failed")),r.readAsDataURL(e)})}function Iee(e){const[t,n]=g.useState(e.initial??[]),r=g.useCallback(async o=>{const a=Array.from(o);if(a.length===0)return;const l=[],c=[],u=[];for(const d of a){const f={id:Nee(),fileName:d.name,mimeType:d.type||"application/octet-stream"};if(!Cee(d)){c.push({...f,url:null,status:"error",error:"不支持的文件类型"});continue}if(d.size>Xk){c.push({...f,url:null,status:"error",error:`超过 ${Math.round(Xk/1024/1024)}MB 上限`});continue}if(e.sessionId==null){u.push({id:f.id,file:d,mimeType:f.mimeType}),c.push({...f,url:null,status:"uploading"});continue}const p=f.mimeType.startsWith("image/")?URL.createObjectURL(d):void 0;c.push({...f,url:null,status:"uploading",...p?{previewUrl:p}:{}}),l.push({id:f.id,file:d})}n(d=>[...d,...c]);for(const d of u)try{const f=await Tee(d.file);n(p=>p.map(m=>m.id===d.id?{...m,url:f,status:"done",...d.mimeType.startsWith("image/")?{previewUrl:f}:{}}:m))}catch(f){n(p=>p.map(m=>m.id===d.id?{...m,status:"error",error:f.message??"read failed"}:m))}l.length!==0&&await Promise.all(l.map(async d=>{try{const f=await yee({httpBaseUrl:e.httpBaseUrl,httpToken:e.httpToken,sessionId:e.sessionId,file:d.file});n(p=>p.map(m=>m.id===d.id?{...m,url:f.url,status:"done"}:m))}catch(f){const p=f instanceof sc?f.code:"UPLOAD_FAILED",m=f.message??"upload failed";n(v=>v.map(w=>w.id===d.id?{...w,status:"error",error:`${p}: ${m}`}:w))}}))},[e.sessionId,e.httpBaseUrl,e.httpToken]),i=g.useCallback(o=>{n(a=>a.filter(l=>l.id!==o))},[]),s=g.useCallback(()=>{n([])},[]);return{attachments:t,setAttachments:n,addFiles:r,removeAttachment:i,clearAttachments:s}}function Pee(e,t){return[...e.map(n=>n.text),t].map(n=>n.trim()).filter(Boolean).join(`
536
+ `+e}const qJ=/\[skill:(.+?):(\/[^\]]+)\]/g;function KJ(e){const t=[],n=e.replace(qJ,(r,i)=>(t.push(i),""));return{skills:t,text:t.length>0?n.trim():e}}function GJ({text:e,senderDisplayName:t,senderPrincipal:n,rewindTarget:r}){const i=n==="guest",s=_5(e),{attachments:o,text:a}=MM(s),{skills:l,text:c}=KJ(a),{commandName:u,body:d}=Tp(c),f=d.length>0;return f||o.length>0||!!u||l.length>0?(u||l.length>0)&&!f&&o.length===0?h.jsxs("div",{className:"flex min-w-0 max-w-full justify-end gap-1.5 py-2 mt-2","data-testid":"msg-line-user","data-sender-principal":i?"guest":"owner",children:[l.map((m,v)=>h.jsxs("span",{"data-testid":"user-skill-chip",className:"inline-flex items-center rounded-md bg-bg-200/60 px-2 py-0.5 text-[11px] font-mono text-text-300",children:["/",m]},`${m}-${v}`)),u?h.jsx("span",{className:"inline-flex items-center rounded-md bg-bg-200/60 px-2 py-0.5 text-[11px] font-mono text-text-300",children:u}):null]}):h.jsxs("div",{className:"group flex min-w-0 max-w-full flex-col items-end py-2 mt-2","data-testid":"msg-line-user","data-sender-principal":i?"guest":"owner",children:[h.jsxs("div",{"data-testid":"user-msg-bubble",className:re("min-w-0 max-w-[85%] rounded-2xl rounded-br-sm px-3.5 py-2 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",i?"border border-border bg-bg-200":"bg-accent"),children:[o.length>0?h.jsx(YJ,{attachments:o}):null,l.length>0?h.jsx("div",{className:re("flex flex-wrap gap-1.5",(f||u)&&"mb-1.5"),children:l.map((m,v)=>h.jsxs("span",{"data-testid":"user-skill-chip",className:re("inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-mono",i?"bg-text-100/10 text-text-200":"bg-white/15 text-white/90"),children:["/",m]},`${m}-${v}`))}):null,u?h.jsx("div",{className:re("flex",f&&"mb-1.5"),children:h.jsx("span",{"data-testid":"user-command-chip",className:re("inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-mono",i?"bg-text-100/10 text-text-200":"bg-white/15 text-white/90"),children:u})}):null,f?h.jsx("div",{className:re("text-[14px] font-medium leading-relaxed",i?"text-text-100":"text-white"),children:d}):null]}),t?h.jsx("div",{"data-testid":"user-msg-sender-label",className:"mt-1 text-[11px] text-text-400",children:t}):null,r?h.jsxs("button",{type:"button","data-testid":"user-msg-rewind","aria-label":"rewind to this message",title:"回退到这条消息(会撤销之后 CC 的文件编辑)",onClick:()=>r.onRewind(r.userMessageId),className:"mt-1 inline-flex items-center gap-1 h-6 px-1.5 rounded-md text-[11px] text-text-400 hover:bg-text-100/5 hover:text-text-200 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:[h.jsx(EI,{className:"w-3 h-3",strokeWidth:2}),h.jsx("span",{children:"Rewind"})]}):null]}):null}function YJ({attachments:e}){return h.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5","data-testid":"user-attachment-row",children:e.map(t=>h.jsx(XJ,{attachment:t},t.url))})}function XJ({attachment:e}){return e.type==="image"?h.jsx("img",{src:e.url,alt:e.fileName,"data-testid":"user-attachment-image",className:"h-16 w-16 rounded object-cover shrink-0 border border-bg-300/50"}):h.jsxs("div",{"data-testid":"user-attachment-file",className:"flex items-center gap-1.5 rounded-md border border-bg-300 bg-bg-100/60 px-2 py-1 text-[12px] text-text-200",children:[h.jsx(mi,{className:"h-3.5 w-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"max-w-[140px] truncate",children:e.fileName})]})}const QJ={"task-notification":"子任务通知","slash-command":"斜杠命令","local-command":"本地命令输出","system-reminder":"系统提醒","skill-hint":"Skill 注入","meta-text":"系统消息","attachment-skills":"技能列表","attachment-deferred-tools":"Deferred 工具变更","dispatch-task":"委派任务","dispatch-result":"委派回报"},ZJ={"task-notification":Uw,"slash-command":V8,"local-command":CI,"system-reminder":Uw,"skill-hint":x0,"meta-text":wI,"attachment-skills":x0,"attachment-deferred-tools":N8,"dispatch-task":kI,"dispatch-result":bI};function AM({metaKind:e,text:t}){const[n,r]=g.useState(!1),i=ZJ[e];if(e==="slash-command"){const{commandName:o,commandMessage:a,commandArgs:l,body:c}=Tp(t),u=o??(a?`/${a}`:null),d=!!(l&&l.length>0),f=c.length>0;return!u&&!d&&!f?null:h.jsxs("div",{"data-testid":"msg-line-user-meta","data-meta-kind":e,className:"flex min-w-0 max-w-full flex-col items-end gap-0.5 py-1",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 max-w-full",children:[u?h.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-md bg-bg-200/60 px-2 py-0.5 text-[11px] font-mono text-text-300 shrink-0",children:[h.jsx(i,{className:"w-3 h-3 opacity-70"}),u]}):null,d?h.jsx("span",{"data-testid":"user-meta-command-args",className:"min-w-0 text-[12px] text-text-200 whitespace-pre-wrap break-words max-w-[70ch] [overflow-wrap:anywhere]",children:l}):null]}),f?h.jsx("span",{className:"ml-2 max-w-[60%] truncate text-[11px] text-text-400",children:c}):null]})}const s=t.replace(/\s+/g," ").trim().slice(0,80);return h.jsxs("div",{"data-testid":"msg-line-user-meta","data-meta-kind":e,className:"flex min-w-0 max-w-full flex-col items-start gap-1 py-1",children:[h.jsxs("button",{type:"button","aria-expanded":n,onClick:()=>r(o=>!o),className:re("group inline-flex items-center gap-1.5 rounded-md border border-bg-200/60 bg-bg-100/40","px-2 py-1 text-[11px] text-text-400 hover:bg-bg-200/40 transition-colors max-w-full"),children:[h.jsx(i,{className:"w-3 h-3 opacity-70 shrink-0"}),h.jsx("span",{className:"font-medium shrink-0",children:QJ[e]}),h.jsx("span",{className:"truncate text-text-400/80 max-w-[60ch]",children:s}),n?h.jsx(Yn,{className:"w-3 h-3 opacity-60 shrink-0"}):h.jsx(Bn,{className:"w-3 h-3 opacity-60 shrink-0"})]}),n?h.jsx("pre",{"data-testid":"user-meta-body",className:"w-full max-w-full whitespace-pre-wrap break-words text-[11px] text-text-400 bg-bg-50/60 rounded-md p-2 border border-bg-200/60 [overflow-wrap:anywhere]",children:t}):null]})}function Gk(e){return e.ordinal===null?e.label:`#${e.ordinal} ${e.label}`}function JJ({text:e,metaKind:t,resolveDispatchLine:n,onOpenFilePath:r}){const i=g.useMemo(()=>lz(e),[e]);return i.length===0?h.jsx(AM,{metaKind:t,text:e}):h.jsx("div",{"data-testid":"msg-line-dispatch-group",className:"my-1 flex min-w-0 max-w-full flex-col gap-1.5",children:i.map((s,o)=>h.jsx(tee,{block:s,...n?{resolveDispatchLine:n}:{},...r?{onOpenFilePath:r}:{}},`${s.kind}-${s.dispatchId}-${o}`))})}function eee(e){return e?{shell:"border-error/40 bg-error-dim",rail:"bg-error/55",hover:"hover:bg-error/10",icon:"text-error",title:"text-error",chevron:"text-error/70",seam:"border-error/25"}:{shell:"border-accent/35 bg-accent-dim",rail:"bg-accent/45",hover:"hover:bg-accent/10",icon:"text-accent",title:"text-accent",chevron:"text-accent/70",seam:"border-accent/20"}}function tee({block:e,resolveDispatchLine:t,onOpenFilePath:n}){const[r,i]=g.useState(!1),s=g.useMemo(()=>n?NM(n):Fs,[n]),o=e.kind==="task",a=t==null?void 0:t(e.dispatchId),l=o&&typeof e.round=="number"&&e.round>=2,c=e.status==="failure",u=eee(c);return h.jsxs("div",{"data-testid":"msg-line-dispatch","data-dispatch-kind":e.kind,"data-dispatch-id":e.dispatchId,"data-round":e.round??"","data-status":e.status??"","data-open":r?"true":"false",className:re("flex min-w-0 max-w-full overflow-hidden rounded-lg border",u.shell),children:[h.jsx("span",{"data-testid":"dispatch-rail","aria-hidden":"true",className:re("w-[3px] shrink-0 self-stretch",u.rail)}),h.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[h.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>i(d=>!d),className:re("flex w-full min-w-0 cursor-pointer items-start gap-2 px-3 py-2 text-left transition-colors",u.hover),children:[h.jsx("span",{className:re("mt-[2px] shrink-0",u.icon),children:o?h.jsx(kI,{className:"h-3.5 w-3.5"}):h.jsx(bI,{className:"h-3.5 w-3.5"})}),h.jsxs("span",{className:"min-w-0 flex-1",children:[h.jsxs("span",{"data-testid":"dispatch-header",className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[h.jsx("span",{className:re("text-[12px] font-semibold",u.title),children:o?"委派任务":"委派回报"}),a?h.jsxs("span",{"data-testid":"dispatch-line","data-line-ordinal":a.ordinal??"",title:`来自 ${Gk(a)}`,className:"min-w-0 truncate text-[11px] text-text-300",children:[h.jsx("span",{className:"text-text-400",children:"来自"})," ",h.jsx("span",{className:"tabular-nums",children:Gk(a)})]}):null,l?h.jsxs("span",{"data-testid":"dispatch-round",className:"inline-flex items-center gap-1 rounded-md bg-bg-200/70 px-1.5 py-0.5 text-[10px] text-text-300",children:[h.jsx(R8,{className:"h-3 w-3"}),"续派第 ",e.round," 轮"]}):null,c?h.jsxs("span",{"data-testid":"dispatch-status",className:"inline-flex items-center gap-1 text-[11px] text-error",children:[h.jsx(Qi,{className:"h-3.5 w-3.5"}),"失败"]}):null,e.filePaths.length>0?h.jsxs("span",{"data-testid":"dispatch-file-count",className:"inline-flex items-center gap-1 text-[11px] text-text-400",children:[h.jsx(mi,{className:"h-3 w-3"}),e.filePaths.length," 个产物"]}):null]}),h.jsx("span",{"data-testid":"dispatch-brief",className:"mt-1 block whitespace-pre-wrap break-words text-[12px] leading-relaxed text-text-200 [overflow-wrap:anywhere]",children:e.brief}),e.briefIsDerived?h.jsxs("span",{"data-testid":"dispatch-brief-derived",title:"发送方没写摘要,这段是从正文首段自动截取的",className:"mt-1 inline-flex items-center gap-1 text-[10px] text-text-400 italic",children:[h.jsx(H8,{className:"h-2.5 w-2.5"}),"自动摘要(发送方未填)"]}):null]}),h.jsx("span",{className:re("mt-[3px] shrink-0",u.chevron),children:r?h.jsx(Yn,{className:"h-3.5 w-3.5"}):h.jsx(Bn,{className:"h-3.5 w-3.5"})})]}),r?h.jsxs(h.Fragment,{children:[h.jsx("div",{"data-testid":"dispatch-body",className:re("min-w-0 space-y-2 border-t bg-bg-200/35 py-2.5 pl-4 pr-3",u.seam),children:h.jsxs("div",{"data-testid":"dispatch-detail-indent",className:"min-w-0 border-l border-border/70 pl-3",children:[h.jsx("div",{"data-testid":"dispatch-detail",className:"assistant-markdown markdown-attached min-w-0 break-words",children:h.jsx(nl,{remarkPlugins:[rl],components:s,...n?{urlTransform:EM}:{},children:e.detail})}),e.filePaths.length>0?h.jsxs("div",{"data-testid":"dispatch-files",className:"flex min-w-0 flex-col gap-1 pt-2",children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"产物"}),e.filePaths.map(d=>h.jsx(nee,{path:d,...n?{onOpenFilePath:n}:{}},d))]}):null]})}),h.jsxs("button",{type:"button","data-testid":"dispatch-collapse-foot",onClick:()=>i(!1),className:re("flex w-full cursor-pointer items-center justify-between gap-2 border-t bg-bg-200/35 px-3 py-1 text-[10px] text-text-400 transition-colors hover:bg-bg-200/60",u.seam),children:[h.jsx("span",{className:"min-w-0 truncate",children:e.dispatchId?h.jsxs(h.Fragment,{children:[h.jsx("span",{children:"台账 "}),h.jsx("span",{"data-testid":"dispatch-id",className:"font-mono",children:e.dispatchId})]}):null}),h.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1",children:["收起",h.jsx(xI,{className:"h-3 w-3"})]})]})]}):null]})]})}function nee({path:e,onOpenFilePath:t}){const n="inline-flex min-w-0 items-center gap-1.5 text-left text-[11px] font-mono text-text-300";return t?h.jsxs("button",{type:"button","data-testid":"dispatch-file-path",title:e,onClick:()=>t(e),className:re(n,"hover:text-text-100 hover:underline"),children:[h.jsx(mi,{className:"h-3 w-3 shrink-0 text-text-400"}),h.jsx("span",{className:"truncate",children:e})]}):h.jsxs("span",{"data-testid":"dispatch-file-path",title:e,className:n,children:[h.jsx(mi,{className:"h-3 w-3 shrink-0 text-text-400"}),h.jsx("span",{className:"truncate",children:e})]})}function ree({text:e,metaSource:t}){return t==="owner"?h.jsx("div",{className:"flex min-w-0 max-w-full flex-col items-start py-1.5","data-testid":"msg-line-owner-meta",children:h.jsxs("div",{className:re("inline-flex min-w-0 max-w-[85%] items-start gap-2 rounded-md","border-l-[3px] border-accent bg-accent-dim px-3 py-2"),children:[h.jsx(p8,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-accent","aria-label":"补充信息"}),h.jsx("span",{className:"min-w-0 text-[12px] leading-relaxed text-text-100 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:e})]})}):h.jsxs("div",{className:"flex min-w-0 max-w-full items-start gap-1.5 py-1 text-[11px] text-text-400","data-testid":"msg-line-cc-meta",children:[h.jsx(wI,{className:"mt-0.5 h-3 w-3 shrink-0"}),h.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:e})]})}function Gr(e,t){const r=new RegExp(`<${t}\\b[^>]*>([\\s\\S]*?)</${t}>`,"i").exec(e);if(!r)return;const i=r[1].trim();return i||void 0}function lg(e,t){const r=new RegExp(`${t}\\s*=\\s*"([^"]+)"`,"i").exec(e);if(!r)return;const i=Number(r[1]);return Number.isFinite(i)?i:void 0}function jM(e){var i,s,o;const t={};if(!e)return t;t.taskId=Gr(e,"task-id"),t.toolUseId=Gr(e,"tool-use-id"),t.outputFile=Gr(e,"output-file"),t.status=Gr(e,"status"),t.summary=Gr(e,"summary"),t.result=Gr(e,"result");const n=Gr(e,"usage");if(n){const a=(i=/<total_tokens>\s*(\d+)\s*<\/total_tokens>/i.exec(n))==null?void 0:i[1],l=(s=/<tool_uses>\s*(\d+)\s*<\/tool_uses>/i.exec(n))==null?void 0:s[1],c=(o=/<duration_ms>\s*(\d+)\s*<\/duration_ms>/i.exec(n))==null?void 0:o[1];a&&(t.totalTokens=Number(a)),l&&(t.toolUses=Number(l)),c&&(t.durationMs=Number(c))}const r=Gr(e,"worktree");if(r)t.worktreePath=Gr(r,"worktreePath"),t.worktreeBranch=Gr(r,"worktreeBranch");else{const a=/<worktree\b([^>]*)\/>/i.exec(e);if(a){const l=a[1],c=/worktreePath\s*=\s*"([^"]+)"/i.exec(l),u=/worktreeBranch\s*=\s*"([^"]+)"/i.exec(l);c&&(t.worktreePath=c[1]),u&&(t.worktreeBranch=u[1])}}if(t.totalTokens===void 0&&t.toolUses===void 0&&t.durationMs===void 0){const a=lg(e,"total_tokens"),l=lg(e,"tool_uses"),c=lg(e,"duration_ms");a!==void 0&&(t.totalTokens=a),l!==void 0&&(t.toolUses=l),c!==void 0&&(t.durationMs=c)}return t}function iee(e){if(!e||!Number.isFinite(e))return null;if(e<1e3)return`${e}ms`;const t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;const n=Math.floor(t/60),r=Math.round(t-n*60);return`${n}m${r.toString().padStart(2,"0")}s`}function see({text:e,taskId:t,parentToolUseId:n}){const r=g.useMemo(()=>jM(e),[e]),[i,s]=g.useState(!1),o=t??r.taskId,a=n??r.toolUseId,l=r.status==="failed"?h.jsx(Qi,{className:"w-3.5 h-3.5 text-error"}):r.status==="completed"?h.jsx(cp,{className:"w-3.5 h-3.5 text-success"}):h.jsx(lp,{className:"w-3.5 h-3.5 text-text-400"}),c=r.status??"unknown",u=iee(r.durationMs);return h.jsxs("div",{"data-testid":"msg-line-agent-notification","data-task-id":o??"","data-parent-tool-use-id":a??"",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/40",children:[h.jsxs("button",{type:"button","aria-expanded":i,onClick:()=>s(d=>!d),className:re("flex w-full min-w-0 items-start gap-2 px-2.5 py-1.5 text-left text-[12px]","hover:bg-bg-200/40 rounded-md transition-colors"),children:[h.jsx("span",{className:"mt-[2px] shrink-0",children:l}),h.jsxs("span",{className:"flex-1 min-w-0",children:[h.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[h.jsx("span",{className:"font-medium text-text-200",children:"子任务"}),h.jsx("span",{className:"text-text-400 text-[11px] font-mono",children:o?o.slice(0,12):"未知"}),h.jsx("span",{className:"text-text-400 text-[11px] uppercase tracking-wide",children:c}),u?h.jsxs("span",{className:"text-text-400 text-[11px] tabular-nums",children:["· ",u]}):null,r.totalTokens?h.jsxs("span",{className:"text-text-400 text-[11px] tabular-nums",children:["· ",r.totalTokens," tok"]}):null,r.toolUses?h.jsxs("span",{className:"text-text-400 text-[11px] tabular-nums",children:["· ",r.toolUses," tools"]}):null]}),r.summary?h.jsx("span",{className:"block truncate text-text-300 text-[12px] mt-0.5",children:r.summary}):null]}),i?h.jsx(Yn,{className:"w-3.5 h-3.5 mt-[3px] text-text-400 shrink-0"}):h.jsx(Bn,{className:"w-3.5 h-3.5 mt-[3px] text-text-400 shrink-0"})]}),i?h.jsxs("div",{"data-testid":"agent-notification-body",className:"min-w-0 border-t border-bg-200/60 px-3 py-2 text-[12px] text-text-300 space-y-2",children:[r.worktreePath||r.worktreeBranch?h.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-400",children:[h.jsx(Q_,{className:"w-3 h-3"}),r.worktreeBranch?h.jsx("span",{className:"font-mono",children:r.worktreeBranch}):null,r.worktreePath?h.jsx("span",{className:"truncate font-mono",children:r.worktreePath}):null]}):null,r.outputFile?h.jsxs("div",{className:"text-[11px] text-text-400",children:[h.jsx("span",{children:"输出文件:"}),h.jsx("span",{className:"font-mono",children:r.outputFile})]}):null,a?h.jsxs("div",{className:"text-[11px] text-text-400",children:[h.jsx("span",{children:"父工具调用:"}),h.jsx("span",{className:"font-mono",children:a})]}):null,r.result?h.jsx("div",{"data-testid":"agent-notification-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(nl,{remarkPlugins:[rl],components:Fs,children:r.result})}):h.jsx("div",{className:"text-[11px] text-text-400 italic",children:"无详细结果"})]}):null]})}const LM=g.createContext(null);function oee({children:e}){const[t,n]=g.useState({agentId:null}),r=g.useCallback((o,a)=>{n({agentId:o,agentType:a})},[]),i=g.useCallback(()=>{n(o=>({agentId:null,agentType:o.agentType}))},[]),s=g.useMemo(()=>({state:t,open:r,close:i}),[t,r,i]);return h.jsx(LM.Provider,{value:s,children:e})}function DM(){return g.useContext(LM)}function aee(e){if(e==null)return null;if(typeof e=="string")return e;if(Array.isArray(e)){const t=[];for(const n of e)if(n&&typeof n=="object"){const r=n;r.type==="text"&&typeof r.text=="string"&&t.push(r.text)}else typeof n=="string"&&t.push(n);return t.length?t.join(`
537
+ `):null}if(typeof e=="object"){const t=e;if(typeof t.text=="string")return t.text}return null}function Yk(e){if(!e||!Number.isFinite(e))return null;if(e<1e3)return`${e}ms`;const t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;const n=Math.floor(t/60),r=Math.round(t-n*60);return`${n}m${r.toString().padStart(2,"0")}s`}function lee(e){return!e||!Number.isFinite(e)?null:e<1e3?`${e} tok`:e<1e4?`${(e/1e3).toFixed(1)}k tok`:`${Math.round(e/1e3)}k tok`}const cee={readCount:"read",searchCount:"search",bashCount:"bash",editFileCount:"edit",linesAdded:"+lines",linesRemoved:"-lines",otherToolCount:"other"};function uee(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e)){if(!r||r<=0)continue;const i=cee[n]??n;t.push(`${i}:${r}`)}return t}function dee({expandable:e,expanded:t,onToggle:n,children:r}){const i=re("flex w-full min-w-0 items-center gap-2 px-2.5 py-1.5 text-left text-[13px] rounded-md",e&&"hover:bg-bg-200/40 transition-colors");return e?h.jsx("button",{type:"button","aria-expanded":t,onClick:n,className:i,children:r}):h.jsx("div",{className:i,children:r})}function OM({description:e,input:t,output:n,error:r,pending:i,notifications:s,toolResultExtra:o,progress:a,expandable:l=!0}){const[c,u]=g.useState(!1),d=DM(),f=g.useMemo(()=>{if(!t||typeof t!="object")return null;const R=t;return typeof R.prompt=="string"?R.prompt:null},[t]),p=g.useMemo(()=>{if(!t||typeof t!="object")return;const R=t.agentId;return typeof R=="string"&&R.length>0?R:void 0},[t]),m=(o==null?void 0:o.prompt)??f,v=g.useMemo(()=>aee(n),[n]),w=o==null?void 0:o.stats,x=a==null?void 0:a.stats,_=Yk((w==null?void 0:w.durationMs)??(x==null?void 0:x.durationMs)),y=lee((w==null?void 0:w.tokens)??(x==null?void 0:x.tokens)),S=uee(w==null?void 0:w.toolStats),C=g5({pending:i,error:r,notifications:s,progress:a,input:t}),k=C&&(a!=null&&a.lastToolName)?`now:${a.lastToolName}`:null,N=!!(o!=null&&o.agentType||_||y||S.length>0||k),T=(o==null?void 0:o.agentId)??(a==null?void 0:a.agentId)??p,O=!!(r||(a==null?void 0:a.status)==="failed"),P=g.useMemo(()=>s.map(R=>({taskId:R.taskId,text:R.text,parsed:jM(R.text)})),[s]),D=O?h.jsx(Qi,{className:"w-3.5 h-3.5 text-error"}):C?h.jsx(Ln,{className:"w-3.5 h-3.5 text-blue-400 animate-spin"}):h.jsx(cp,{className:"w-3.5 h-3.5 text-green-500"});return h.jsxs("div",{"data-testid":"msg-line-agent-call","data-pending":i?"true":"false","data-active":C?"true":"false","data-has-error":O?"true":"false","data-notification-count":s.length,"data-has-stats":N?"true":"false","data-agent-id":T??"",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/30",children:[h.jsxs(dee,{expandable:l,expanded:c,onToggle:()=>u(R=>!R),children:[h.jsx("span",{className:"w-5 h-5 flex items-center justify-center text-[10px] rounded bg-violet-500/10 text-violet-500 shrink-0","aria-hidden":!0,children:h.jsx(sF,{className:"w-3 h-3"})}),h.jsx("span",{className:"shrink-0",children:D}),h.jsx("span",{className:"flex-1 min-w-0 truncate font-medium text-text-200",children:e}),N?null:s.length>0?h.jsxs("span",{className:"text-[11px] text-text-400 tabular-nums shrink-0",children:[s.length," 次通知"]}):null,T&&(d!=null&&d.open)?h.jsx("span",{role:"button",tabIndex:0,"data-testid":"open-subagent-btn-header","data-agent-id":T,"aria-label":"打开子 agent 对话",onClick:R=>{R.stopPropagation(),d.open(T,o==null?void 0:o.agentType)},onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.stopPropagation(),R.preventDefault(),d.open(T,o==null?void 0:o.agentType))},className:"shrink-0 inline-flex items-center justify-center w-3.5 h-3.5 text-text-400 hover:text-text-200",children:h.jsx(tu,{className:"w-3.5 h-3.5"})}):null,l?c?h.jsx(Yn,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(Bn,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):null]}),C&&(a!=null&&a.description)?h.jsx("div",{"data-testid":"agent-call-progress-desc",className:"px-3 pt-0 pb-1 text-[12px] text-text-300 truncate",children:a.description}):null,N?h.jsxs("div",{"data-testid":"agent-call-stats",className:"flex items-center gap-1.5 flex-wrap px-3 pb-1.5 pt-0 text-[11px] text-text-400",children:[o!=null&&o.agentType?h.jsx("span",{"data-testid":"agent-call-stats-type",className:"inline-flex items-center rounded-sm bg-violet-500/10 px-1.5 py-0.5 text-violet-400 font-medium",children:o.agentType}):null,_?h.jsx("span",{className:"tabular-nums",children:_}):null,y?h.jsx("span",{className:"tabular-nums",children:y}):null,k?h.jsx("span",{"data-testid":"agent-call-stats-now",className:"font-mono tabular-nums text-blue-400",children:k}):null,S.map(R=>h.jsx("span",{className:"font-mono tabular-nums text-text-400/80",children:R},R)),s.length>0?h.jsxs("span",{className:"tabular-nums text-text-400/70",children:["· ",s.length," 次通知"]}):null]}):null,c?h.jsxs("div",{"data-testid":"agent-call-body",className:"min-w-0 border-t border-bg-200/60 px-3 py-2 space-y-3",children:[r?h.jsx("div",{className:"text-[12px] text-error whitespace-pre-wrap",children:r}):null,P.map((R,A)=>{const M=R.parsed,L=Yk(M.durationMs);return h.jsxs("div",{"data-testid":"agent-call-notification","data-task-id":R.taskId??"",className:"min-w-0 rounded-md border border-bg-200/60 bg-bg-0/40 p-2 space-y-1.5",children:[h.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-400 flex-wrap",children:[h.jsx("span",{className:"font-mono",children:(R.taskId??M.taskId??"未知").slice(0,12)}),h.jsx("span",{className:"uppercase tracking-wide",children:M.status??"unknown"}),L?h.jsxs("span",{className:"tabular-nums",children:["· ",L]}):null,M.totalTokens?h.jsxs("span",{className:"tabular-nums",children:["· ",M.totalTokens," tok"]}):null,M.toolUses?h.jsxs("span",{className:"tabular-nums",children:["· ",M.toolUses," tools"]}):null,M.worktreeBranch?h.jsxs("span",{className:"font-mono",children:["· ",M.worktreeBranch]}):null]}),M.summary?h.jsx("div",{className:"text-[12px] text-text-300",children:M.summary}):null,M.result?h.jsx("div",{"data-testid":"agent-call-notification-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(nl,{remarkPlugins:[rl],components:Fs,children:M.result})}):null]},`${R.taskId??"n"}-${A}`)}),m?h.jsxs("div",{"data-testid":"agent-call-prompt-block",className:"min-w-0 space-y-1",children:[h.jsx("div",{className:"text-[11px] text-text-400 font-medium",children:"任务指令"}),h.jsx("pre",{"data-testid":"agent-call-prompt",className:"max-w-full whitespace-pre-wrap break-words text-[11px] text-text-300 bg-bg-50/60 rounded p-2 border border-bg-200/60 max-h-64 overflow-auto [overflow-wrap:anywhere]",children:m})]}):null,v?h.jsxs("div",{"data-testid":"agent-call-result-block",className:"min-w-0 space-y-1",children:[h.jsx("div",{className:"text-[11px] text-text-400 font-medium",children:"子 agent 报告"}),h.jsx("div",{"data-testid":"agent-call-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(nl,{remarkPlugins:[rl],components:Fs,children:v})})]}):null,!v&&P.length===0&&!r&&!m?h.jsx("div",{className:"text-[11px] text-text-400 italic",children:"无详细信息"}):null,T&&(d!=null&&d.open)?h.jsx("div",{className:"flex justify-end",children:h.jsxs("button",{type:"button","data-testid":"open-subagent-btn","data-agent-id":T,onClick:()=>d.open(T,o==null?void 0:o.agentType),className:re("inline-flex items-center gap-1 rounded-md border border-bg-200/60","bg-bg-100/40 hover:bg-bg-200/40 transition-colors","px-2 py-1 text-[11px] text-text-300"),children:[h.jsx(tu,{className:"w-3 h-3"}),h.jsx("span",{children:"打开子 agent 对话"})]})}):null]}):null]})}function BM({title:e,items:t,progressColor:n="bg-green-500",listKind:r}){const[i,s]=g.useState(!1),o=t.length,a=t.filter(c=>c.status==="completed").length,l=o>0?Math.round(a/o*100):0;return h.jsxs("div",{"data-testid":"msg-line-checklist","data-list-kind":r,className:"min-w-0 max-w-full py-1",children:[h.jsxs("button",{type:"button",onClick:()=>s(c=>!c),"aria-expanded":i,className:"flex items-center gap-2.5 w-full text-left rounded-md px-1.5 py-1 hover:bg-text-100/5 cursor-pointer",children:[i?h.jsx(Yn,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(Bn,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"text-[13px] font-medium text-text-200",children:e}),h.jsxs("span",{className:"text-[11px] text-text-400 tabular-nums",children:[a,"/",o]}),h.jsx("div",{className:"flex-1 max-w-[120px] h-1.5 rounded-full bg-text-100/10 overflow-hidden",children:h.jsx("div",{className:re("h-full rounded-full transition-all duration-300",n),style:{width:`${l}%`}})})]}),i?h.jsx("div",{"data-testid":"checklist-body",className:"ml-6 mt-0.5",children:h.jsx("div",{className:"space-y-px",children:t.map((c,u)=>h.jsxs("div",{className:"flex min-w-0 items-start gap-2 py-0.5 px-1",children:[h.jsx("span",{className:"w-4 h-4 mt-0.5 flex items-center justify-center shrink-0",children:c.status==="completed"?h.jsx(wl,{className:"w-3.5 h-3.5 text-green-500"}):h.jsx("span",{className:"w-2 h-2 rounded-full border border-text-400/40"})}),h.jsx("span",{className:re("min-w-0 text-[13px] leading-snug break-words [overflow-wrap:anywhere]",c.status==="completed"?"text-text-400 line-through":"text-text-200"),children:c.status==="in_progress"&&c.activeForm?c.activeForm:c.content})]},`${u}-${c.content}`))})}):null]})}function hee({todos:e}){return h.jsx(BM,{title:"Tasks",items:e,progressColor:"bg-green-500",listKind:"todo"})}function fee({tasks:e}){return h.jsx(BM,{title:"Plan",items:e,progressColor:"bg-blue-500",listKind:"plan"})}function pee(e){if(!e||!Number.isFinite(e))return null;const t=Date.now()-e;if(t<0)return null;const n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);if(i<24)return`${i}h ago`;const s=Math.floor(i/24);if(s<7)return`${s}d ago`;const o=Math.floor(s/7);return o<5?`${o}w ago`:new Date(e).toISOString().slice(0,10)}function mee(e){return(e.split("/").pop()??e)||e}function gee({memories:e}){return!e||e.length===0?null:h.jsxs("div",{"data-testid":"memory-callout",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/30",children:[h.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5 text-[12px] text-text-300 border-b border-bg-200/60",children:[h.jsx(E$,{className:"w-3.5 h-3.5 text-amber-500 shrink-0"}),h.jsx("span",{className:"font-medium",children:"项目记忆"}),h.jsxs("span",{className:"text-text-400 tabular-nums",children:["· ",e.length]})]}),h.jsx("ul",{className:"divide-y divide-bg-200/40",children:e.map(t=>h.jsx(vee,{memory:t},t.path))})]})}function vee({memory:e}){const[t,n]=g.useState(!1),r=pee(e.mtimeMs),i=e.content.replace(/\s+/g," ").trim().slice(0,80);return h.jsxs("li",{className:"px-2.5 py-1.5",children:[h.jsxs("button",{type:"button","aria-expanded":t,onClick:()=>n(s=>!s),className:re("flex w-full items-center gap-1.5 text-left text-[12px]","hover:bg-bg-200/30 rounded-sm py-0.5"),children:[t?h.jsx(Yn,{className:"w-3 h-3 text-text-400 shrink-0"}):h.jsx(Bn,{className:"w-3 h-3 text-text-400 shrink-0"}),h.jsx("span",{className:"font-mono text-text-300 shrink-0 max-w-[20ch] truncate",title:e.path,children:mee(e.path)}),h.jsx("span",{className:"flex-1 min-w-0 truncate text-text-400/80",children:i}),r?h.jsx("span",{className:"shrink-0 text-[11px] text-text-400 tabular-nums",children:r}):null]}),t?h.jsx("pre",{"data-testid":"memory-callout-body",className:"mt-1 max-w-full whitespace-pre-wrap break-words text-[12px] text-text-300 bg-bg-50/60 rounded-md p-2 border border-bg-200/60 [overflow-wrap:anywhere]",children:e.content}):null]})}function xee({toolUseId:e,questions:t,onSubmit:n,onCancel:r,submittedAnswers:i}){const[s,o]=g.useState({}),[a,l]=g.useState({}),[c,u]=g.useState({}),[d,f]=g.useState(!1),[p,m]=g.useState(!1),v=i!==void 0&&Object.keys(i).length>0,w=v||p,x=!n&&!v,_=(k,N)=>{const T={labels:new Set,freeText:""};if(!v||!i)return T;const O=i[k];if(typeof O!="string")return T;const P=O.split(",").map(M=>M.trim()).filter(Boolean),D=new Set(N.map(M=>M.label)),R=new Set,A=[];for(const M of P)D.has(M)?R.add(M):A.push(M);return{labels:R,freeText:A.join(", ")}},y=g.useMemo(()=>t.every(k=>{if((c[k.question]??"").trim().length>0)return!0;if(k.multiSelect){const T=a[k.question];return!!(T&&T.size>0)}return typeof s[k.question]=="string"&&s[k.question].length>0}),[t,s,a,c]),S=async()=>{if(!y||d||w||x||!n)return;const k={};for(const N of t){const T=(c[N.question]??"").trim();if(N.multiSelect){const O=a[N.question],P=O?N.options.filter(D=>O.has(D.label)).map(D=>D.label):[];if(T.length>0&&P.push(T),P.length===0)continue;k[N.question]=P.join(", ")}else if(T.length>0)k[N.question]=T;else{const O=s[N.question];typeof O=="string"&&(k[N.question]=O)}}f(!0);try{await n(k),m(!0)}finally{f(!1)}},C=Ru(()=>{S()});return h.jsxs("div",{"data-testid":"msg-line-question","data-tool-use-id":e,className:"min-w-0 max-w-full rounded-md border border-accent/40 bg-accent/5 px-3 py-2.5 text-[13px]",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 mb-2",children:[h.jsx(O$,{className:"w-4 h-4 text-accent shrink-0"}),h.jsx("span",{className:"min-w-0 font-medium text-text-100",children:"需要你的回答 / Need your answer"}),t.length>1?h.jsxs("span",{className:"ml-auto text-[12px] text-text-400","data-testid":"msg-line-question-count",children:[t.length," 个问题"]}):null]}),h.jsx("div",{className:"flex flex-col gap-3 mb-3",children:t.map((k,N)=>{const T=`q-${N}`,O=`${e}-${N}`,P=_(k.question,k.options),D=w||x,R=c[k.question]??"",A=v?P.freeText:p?(c[k.question]??"").trim():"";return h.jsxs("div",{"data-testid":"msg-line-question-item",children:[k.question?h.jsx("div",{className:"text-text-200 mb-1.5",children:k.question}):null,h.jsx("div",{className:"flex flex-col gap-1",children:k.options.map((M,L)=>{var B;const $=`${T}-${L}`,F=v?P.labels.has(M.label):k.multiSelect?!!((B=a[k.question])!=null&&B.has(M.label)):s[k.question]===M.label;return h.jsxs("label",{className:"flex min-w-0 items-start gap-2 cursor-pointer select-none py-1 px-2 rounded hover:bg-bg-100",children:[h.jsx("input",{type:k.multiSelect?"checkbox":"radio",name:O,value:M.label,checked:F,disabled:w||x,onChange:()=>{w||x||(k.multiSelect?l(z=>{const E=new Set(z[k.question]??[]);return E.has(M.label)?E.delete(M.label):E.add(M.label),{...z,[k.question]:E}}):o(z=>({...z,[k.question]:M.label})))},className:"mt-0.5","data-testid":"msg-line-question-option"}),h.jsxs("span",{className:"flex min-w-0 flex-col",children:[h.jsx("span",{className:"text-text-100 [overflow-wrap:anywhere]",children:M.label}),M.description?h.jsx("span",{className:"text-[12px] text-text-400 [overflow-wrap:anywhere]",children:M.description}):null]})]},$)})}),D?A.length>0?h.jsx("div",{className:"mt-2 rounded-lg border border-accent/15 bg-bg-100/60 px-3 py-2 text-[13px] leading-relaxed text-text-200 [overflow-wrap:anywhere]","data-testid":"msg-line-question-freetext-result",children:A}):null:h.jsx("textarea",{rows:3,value:R,placeholder:"或自行输入回答...",onChange:M=>{const L=M.target.value;u($=>({...$,[k.question]:L}))},...C,className:"mt-2 w-full resize-y rounded-lg border border-accent/20 bg-bg-000/60 px-3 py-2 text-[13px] leading-relaxed text-text-100 placeholder:text-text-400 outline-none transition-colors focus:border-accent/60 focus:bg-bg-000","data-testid":"msg-line-question-freetext"})]},T)})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(di,{size:"sm",variant:"default",onClick:()=>void S(),disabled:!y||d||w||x,"data-testid":"msg-line-question-submit",children:w?"已提交 / Submitted":x?"已结束 / Ended":"提交 / Submit"}),r&&!w&&!x?h.jsx(di,{size:"sm",variant:"ghost",onClick:()=>void r(),disabled:d,"data-testid":"msg-line-question-cancel",children:"跳过 / Skip"}):null]})]})}function _ee({toolUseId:e,questions:t,historicalAnswers:n,realtimeAnswers:r,onSubmit:i,onCancel:s}){const o=r??n,a=g.useCallback(async c=>{i&&await i(e,c)},[i,e]),l=g.useCallback(async()=>{s&&await s(e)},[s,e]);return h.jsx(xee,{toolUseId:e,questions:t,onSubmit:i?a:void 0,...s?{onCancel:l}:{},submittedAnswers:o})}function yee(){const e=new Map,t=(n,r)=>`${n}::${r}`;return{register(n,r,i){e.set(t(n,r),i)},resolve(n,r){return n?e.get(t(n,r))??null:null},reset(){e.clear()}}}const Nl=yee();function zM({lines:e,onPermissionRespond:t,onPermissionInterrupt:n,topSlot:r,onRewind:i,rewindableUserMessageIds:s,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v,onOpenFilePath:w,resolveDispatchLine:x,turnCollapse:_,dockedAgentToolUseIds:y}){const S=g.useMemo(()=>v5(e),[e]),C=g.useMemo(()=>_?oq(S,_):null,[S,_]),k={onRewind:i,rewindableUserMessageIds:s,onPermissionRespond:t,onPermissionInterrupt:n,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v,onOpenFilePath:w,resolveDispatchLine:x,dockedAgentToolUseIds:y};return h.jsxs("div",{"data-testid":"message-list",className:"flex w-full min-w-0 max-w-full flex-col gap-2 px-4 py-3",children:[r,C!==null?C.map(N=>bee(N,k)):S.map(N=>gf(N,k))]})}function bee(e,t){const n=`turn-${e.seq}`,r=e.query?gf(e.query,t):null,i=e.process.map(o=>wee(o,t)),s=e.tail.map(o=>gf(o,t));return e.status==="running"?h.jsxs(Qe.Fragment,{children:[r,i,s]},n):h.jsxs(Qe.Fragment,{children:[r,h.jsx(xq,{status:e.status,...e.durationMs!==void 0?{durationMs:e.durationMs}:{},children:i}),s]},n)}function wee(e,t){return e.kind==="tool-group"?h.jsx(mq,{items:e.items,renderItemDetail:n=>See(n,t)},`tool-group-${e.seq}`):gf(e,t)}function See(e,t){const n=Nl.resolve(e.toolKind,e.tool);return n?n.render({input:e.input,output:e.output,error:e.error,pending:e.pending,toolUseId:e.toolUseId,...t.fileSharingScope?{fileScope:t.fileSharingScope}:{},...t.onShareFile?{onShareFile:t.onShareFile}:{},...t.onOpenInTab?{onOpenInTab:t.onOpenInTab}:{},...t.onPreviewMarkdown?{onPreviewMarkdown:t.onPreviewMarkdown}:{}}):null}function gf(e,t){var y;const{onRewind:n,rewindableUserMessageIds:r,onPermissionRespond:i,onPermissionInterrupt:s,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v,onOpenFilePath:w,resolveDispatchLine:x}=t,_=`${e.kind}-${e.seq}`;switch(e.kind){case"session-init":return null;case"user-text":{const S=typeof e.uuid=="string"?e.uuid:void 0,C=!!(n&&S&&(!r||r.has(S)));return h.jsx(GJ,{text:e.text,senderDisplayName:e.senderDisplayName,senderPrincipal:e.senderPrincipal,rewindTarget:C&&S&&n?{userMessageId:S,onRewind:n}:void 0},_)}case"user-meta":return op(e.metaKind)?h.jsx(JJ,{text:e.text,metaKind:e.metaKind,...x?{resolveDispatchLine:x}:{},...w?{onOpenFilePath:w}:{}},_):h.jsx(AM,{metaKind:e.metaKind,text:e.text},_);case"meta-text":return h.jsx(ree,{text:e.text,metaSource:e.metaSource},_);case"agent-notification":return h.jsx(see,{text:e.text,taskId:e.taskId,parentToolUseId:e.parentToolUseId},_);case"assistant-text":{const S=typeof e.uuid=="string"?e.uuid:void 0,C=S&&(o||a)?{messageUuid:S,onFork:o,onQuickAsk:a}:void 0;return h.jsx(gJ,{text:Sq(e.text),forkTarget:C,...w?{onOpenFilePath:w}:{}},_)}case"assistant-thinking":return h.jsx(vJ,{text:e.text},_);case"permission-inline":return h.jsx(UJ,{tool:e.tool,input:e.input,onRespond:i??(()=>{}),onInterrupt:s},_);case"error":return h.jsx(WJ,{message:e.message},_);case"turn-end":return null;case"merged-tool":return kee(e,_,{fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v});case"merged-agent":return(y=t.dockedAgentToolUseIds)!=null&&y.has(e.toolUseId)?null:h.jsx(OM,{description:e.description,input:e.input,output:e.output,error:e.error,pending:e.pending,notifications:e.notifications,toolResultExtra:e.toolResultExtra,progress:e.progress},_);case"plan-card":return h.jsx(fee,{tasks:e.tasks},_);case"todo-checklist":return h.jsx(hee,{todos:e.todos},_);case"memory-callout":return h.jsx(gee,{memories:e.memories},_);case"question-card":{const S=d===void 0||d.has(e.toolUseId);return h.jsx(_ee,{toolUseId:e.toolUseId,questions:e.questions,historicalAnswers:e.submittedAnswers,realtimeAnswers:l==null?void 0:l[e.toolUseId],onSubmit:S?c:void 0,...S&&u?{onCancel:u}:{}},_)}default:return null}}function kee(e,t,n){const r=Nl.resolve(e.toolKind,e.tool),i=r?r.render({input:e.input,output:e.output,error:e.error,pending:e.pending,toolUseId:e.toolUseId,...n.fileSharingScope?{fileScope:n.fileSharingScope}:{},...n.onShareFile?{onShareFile:n.onShareFile}:{},...n.onOpenInTab?{onOpenInTab:n.onOpenInTab}:{},...n.onPreviewMarkdown?{onPreviewMarkdown:n.onPreviewMarkdown}:{}}):null;return h.jsx(Qe.Fragment,{children:i??h.jsx(PM,{tool:e.tool,input:e.input,output:e.output,error:e.error,pending:e.pending,...n.fileSharingScope?{fileScope:n.fileSharingScope}:{},...n.onShareFile?{onShareFile:n.onShareFile}:{},...n.onOpenInTab?{onOpenInTab:n.onOpenInTab}:{},...n.onPreviewMarkdown?{onPreviewMarkdown:n.onPreviewMarkdown}:{}})},t)}const Cee={builtin:"Commands",global:"Global",project:"Project",plugin:"Plugin"},Xk={builtin:0,global:1,project:2,plugin:3};function Eee({query:e,skills:t,activeIndex:n,onActiveIndexChange:r,onSelect:i}){const s=g.useRef(null),o=g.useMemo(()=>$M(t,e),[t,e]),a=g.useMemo(()=>{const l=new Set;let c=null;for(let u=0;u<o.length;u++)o[u].source!==c&&(l.add(u),c=o[u].source);return l},[o]);return g.useEffect(()=>{var l;try{(l=s.current)==null||l.scrollIntoView({block:"nearest"})}catch{}},[n]),o.length===0?null:h.jsx("div",{"data-testid":"cc-skill-selector",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 max-h-[320px] overflow-y-auto rounded-2xl border border-bg-300 bg-bg-50 shadow-lg",children:o.map((l,c)=>{const u=c===n,d=a.has(c);return h.jsxs(Qe.Fragment,{children:[d?h.jsx("div",{className:"sticky top-0 z-10 bg-bg-50/95 backdrop-blur-sm px-4 py-2 text-[10px] font-semibold uppercase tracking-wider text-text-400/70 border-b border-bg-200/60",children:Cee[l.source]}):null,h.jsxs("div",{ref:u?s:void 0,"data-testid":`cc-skill-item-${l.name}`,onMouseEnter:()=>r(c),onClick:()=>i(l),className:re("flex items-center gap-2.5 px-4 py-2 cursor-pointer transition-colors duration-75",u?"bg-[var(--text-100-dim)]":"hover:bg-bg-100/60"),children:[h.jsxs("code",{className:"text-[12px] font-mono font-semibold text-text-100 shrink-0",children:["/",l.name]}),l.description?h.jsx("span",{className:"text-[11px] text-text-300 truncate ml-auto",children:l.description}):null]})]},`${l.source}/${l.name}`)})})}function $M(e,t){const n=t.trim().toLowerCase(),r=n?e.filter(i=>i.name.toLowerCase().includes(n)||(i.description??"").toLowerCase().includes(n)):e.slice();return r.sort((i,s)=>(Xk[i.source]??9)-(Xk[s.source]??9)),r.slice(0,30)}const Nee=g.createContext(null);function Tee(){return g.useContext(Nee)}const Iee={builtin:"Built-in",global:"Global",project:"Project",policy:"Policy",plugin:"Plugin",persona:"My personas",contact:"People","remote-persona":"Remote personas"},Qk={builtin:0,global:1,project:2,policy:3,plugin:4,persona:5,contact:6,"remote-persona":7};function vf(e){switch(e.kind){case"persona":return"persona";case"contact":return"contact";case"remote-persona":return"remote-persona";case"cc-agent":return e.agent.source}}function Pee(e){switch(e.kind){case"persona":return`persona/${e.persona.personaId}`;case"contact":return`contact/${e.contact.deviceId}`;case"remote-persona":return`remote/${e.deviceId}/${e.persona.personaId}`;case"cc-agent":return`${e.agent.source}/${e.agent.name}`}}function Ree(e){switch(e.kind){case"persona":return`${e.persona.personaId} ${e.persona.label}`.toLowerCase();case"contact":return`${e.contact.displayName} ${e.contact.deviceId}`.toLowerCase();case"remote-persona":return`${e.persona.personaId} ${e.persona.label}`.toLowerCase();case"cc-agent":{const t=e.agent;return`${t.name} ${t.description??""} ${t.whenToUse??""}`.toLowerCase()}}}function Mee(e){switch(e.kind){case"persona":return{displayName:`@persona/${e.persona.personaId}`,description:e.persona.label,testid:`cc-agent-item-persona-${e.persona.personaId}`};case"contact":return{displayName:`@${e.contact.displayName}`,description:e.contact.deviceId,testid:`cc-agent-item-contact-${e.contact.deviceId}`};case"remote-persona":return{displayName:`@persona/${e.persona.personaId}`,description:e.persona.label,testid:`cc-agent-item-remote-${e.deviceId}-${e.persona.personaId}`};case"cc-agent":return{displayName:`@${e.agent.name}`,description:e.agent.description,whenToUse:e.agent.whenToUse,plugin:e.agent.plugin,testid:`cc-agent-item-${e.agent.name}`}}}function FM(e,t){const n=t.trim().toLowerCase(),r=n?e.filter(i=>Ree(i).includes(n)):e.slice();return r.sort((i,s)=>(Qk[vf(i)]??9)-(Qk[vf(s)]??9)),r.slice(0,30)}function Zk({query:e,entries:t,activeIndex:n,onActiveIndexChange:r,onSelect:i}){const s=g.useRef(null),o=g.useMemo(()=>FM(t,e),[t,e]),a=g.useMemo(()=>{const l=new Set;let c=null;for(let u=0;u<o.length;u++){const d=vf(o[u]);d!==c&&(l.add(u),c=d)}return l},[o]);return g.useEffect(()=>{var l;try{(l=s.current)==null||l.scrollIntoView({block:"nearest"})}catch{}},[n]),o.length===0?null:h.jsx("div",{"data-testid":"cc-agent-selector",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 max-h-[320px] overflow-y-auto rounded-2xl border border-bg-300 bg-bg-50 shadow-lg",children:o.map((l,c)=>{const u=c===n,d=a.has(c),f=vf(l),p=Mee(l);return h.jsxs(Qe.Fragment,{children:[d?h.jsx("div",{"data-testid":`cc-agent-group-header-${f}`,"data-source":f,className:"sticky top-0 z-10 bg-bg-50/95 backdrop-blur-sm px-4 py-2 text-[10px] font-semibold uppercase tracking-wider text-text-400/70 border-b border-bg-200/60",children:Iee[f]}):null,h.jsxs("div",{ref:u?s:void 0,"data-testid":p.testid,onMouseEnter:()=>r(c),onClick:()=>i(l),className:re("flex items-center gap-2.5 px-4 py-2 cursor-pointer transition-colors duration-75",u?"bg-[var(--text-100-dim)]":"hover:bg-bg-100/60"),children:[h.jsx("code",{className:"text-[12px] font-mono font-semibold text-text-100 shrink-0",children:p.displayName}),p.description?h.jsx("span",{className:"text-[11px] text-text-300 truncate ml-2",children:p.description}):null,p.whenToUse?h.jsx("span",{className:"text-[10px] text-text-400/70 italic truncate ml-auto",children:p.whenToUse}):null,p.plugin?h.jsx("span",{className:"text-[10px] text-text-400/70 ml-2 shrink-0",children:p.plugin}):null]})]},Pee(l))})})}function Aee({attachment:e,onRemove:t,onOpenPreview:n}){const r=e.mimeType.startsWith("image/"),i=e.status==="error",s=e.status==="uploading",o=r&&e.status==="done"&&!!e.previewUrl&&!!n;return h.jsxs("div",{"data-testid":`attachment-pill-${e.id}`,className:re("group relative flex items-center gap-1.5 rounded-lg border px-2 py-1.5 text-[12px] transition-colors",i?"border-red-400/40 bg-red-500/5":"border-bg-300 bg-bg-100"),children:[r&&e.previewUrl?h.jsxs("div",{className:"relative h-7 w-7 shrink-0",children:[h.jsx("img",{src:e.previewUrl,alt:e.fileName,onClick:o?n:void 0,"data-testid":`attachment-thumb-${e.id}`,className:re("h-7 w-7 rounded object-cover",o&&"cursor-pointer hover:opacity-80",s&&"opacity-40")}),s?h.jsx(Ln,{"data-testid":`attachment-spinner-${e.id}`,className:"absolute inset-0 m-auto h-3.5 w-3.5 animate-spin text-text-200"}):null]}):h.jsx("div",{className:"relative flex h-7 w-7 items-center justify-center rounded bg-text-100/5 shrink-0",children:s?h.jsx(Ln,{"data-testid":`attachment-spinner-${e.id}`,className:"h-3.5 w-3.5 animate-spin text-text-400"}):h.jsx(mi,{className:"h-3.5 w-3.5 text-text-400"})}),h.jsx("span",{className:re("max-w-[120px] truncate text-text-200",s&&"text-text-400"),title:e.error??e.fileName,children:e.fileName}),i?h.jsx(Qi,{className:"h-3 w-3 text-red-400 shrink-0"}):null,h.jsx("button",{type:"button",onClick:t,"data-testid":`attachment-remove-${e.id}`,className:"flex h-4 w-4 items-center justify-center rounded-full text-text-400 hover:text-text-100 hover:bg-text-100/10 transition-colors cursor-pointer shrink-0","aria-label":"remove",children:h.jsx(Ir,{className:"h-3 w-3"})})]})}function jee({attachments:e,onRemove:t,onOpenPreview:n}){return e.length===0?null:h.jsx("div",{"data-testid":"attachment-row",className:"flex flex-wrap gap-1.5 mb-2 px-1",children:e.map(r=>h.jsx(Aee,{attachment:r,onRemove:()=>t(r.id),onOpenPreview:n?()=>n(r):void 0},r.id))})}class sc extends Error{constructor(t,n,r){super(n),this.code=t,this.status=r,this.name="UploadAttachmentError"}}async function Lee(e){if(!e.httpBaseUrl)throw new sc("TUNNEL_NOT_READY","daemon httpBaseUrl unavailable");if(!e.httpToken)throw new sc("NO_AUTH","daemon httpToken unavailable");const t=new URLSearchParams({sessionId:e.sessionId,fileName:e.file.name,mimeType:e.file.type||"application/octet-stream"}),n=`${e.httpBaseUrl.replace(/\/$/,"")}/attachments/upload?${t.toString()}`;let r;try{r=await fetch(n,{method:"POST",headers:{Authorization:`Bearer ${e.httpToken}`,"Content-Type":e.file.type||"application/octet-stream"},body:e.file})}catch(i){throw new sc("NETWORK_ERROR",i.message)}if(!r.ok){let i="UPLOAD_FAILED",s=`HTTP ${r.status}`;try{const o=await r.json();o.code&&(i=o.code),o.message&&(s=o.message)}catch{}throw new sc(i,s,r.status)}return await r.json()}const Jk=25*1024*1024,Dee="image/*,.txt,.md,.markdown,.csv,.json,.log,.yaml,.yml,.html,.xml,.pdf",Oee=["image/","text/"],Bee=new Set(["application/json","application/xml","application/x-yaml","application/yaml","application/pdf"]),zee=new Set(["txt","md","markdown","csv","json","log","yaml","yml","html","xml","pdf"]);function $ee(e){var r;const t=(e.type||"").toLowerCase();if(t&&Oee.some(i=>t.startsWith(i))||t&&Bee.has(t))return!0;const n=((r=e.name.split(".").pop())==null?void 0:r.toLowerCase())??"";return n.length>0&&zee.has(n)}let Fee=0;const Hee=()=>`att-${++Fee}-${Date.now()}`;function Uee(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(typeof r.result=="string"?r.result:""),r.onerror=()=>n(r.error??new Error("read failed")),r.readAsDataURL(e)})}function Wee(e){const[t,n]=g.useState(e.initial??[]),r=g.useCallback(async o=>{const a=Array.from(o);if(a.length===0)return;const l=[],c=[],u=[];for(const d of a){const f={id:Hee(),fileName:d.name,mimeType:d.type||"application/octet-stream"};if(!$ee(d)){c.push({...f,url:null,status:"error",error:"不支持的文件类型"});continue}if(d.size>Jk){c.push({...f,url:null,status:"error",error:`超过 ${Math.round(Jk/1024/1024)}MB 上限`});continue}if(e.sessionId==null){u.push({id:f.id,file:d,mimeType:f.mimeType}),c.push({...f,url:null,status:"uploading"});continue}const p=f.mimeType.startsWith("image/")?URL.createObjectURL(d):void 0;c.push({...f,url:null,status:"uploading",...p?{previewUrl:p}:{}}),l.push({id:f.id,file:d})}n(d=>[...d,...c]);for(const d of u)try{const f=await Uee(d.file);n(p=>p.map(m=>m.id===d.id?{...m,url:f,status:"done",...d.mimeType.startsWith("image/")?{previewUrl:f}:{}}:m))}catch(f){n(p=>p.map(m=>m.id===d.id?{...m,status:"error",error:f.message??"read failed"}:m))}l.length!==0&&await Promise.all(l.map(async d=>{try{const f=await Lee({httpBaseUrl:e.httpBaseUrl,httpToken:e.httpToken,sessionId:e.sessionId,file:d.file});n(p=>p.map(m=>m.id===d.id?{...m,url:f.url,status:"done"}:m))}catch(f){const p=f instanceof sc?f.code:"UPLOAD_FAILED",m=f.message??"upload failed";n(v=>v.map(w=>w.id===d.id?{...w,status:"error",error:`${p}: ${m}`}:w))}}))},[e.sessionId,e.httpBaseUrl,e.httpToken]),i=g.useCallback(o=>{n(a=>a.filter(l=>l.id!==o))},[]),s=g.useCallback(()=>{n([])},[]);return{attachments:t,setAttachments:n,addFiles:r,removeAttachment:i,clearAttachments:s}}function Vee(e,t){return[...e.map(n=>n.text),t].map(n=>n.trim()).filter(Boolean).join(`
538
538
 
539
- `)}function Ree(e){const t=NM(e);return{text:t.text,attachments:t.attachments.map((n,r)=>({id:`queued-${r}-${n.fileName}`,fileName:n.fileName,mimeType:n.type==="image"?"image/*":"application/octet-stream",url:n.url,status:"done"}))}}const V0=new Map,Mee=[];function Qk(e){if(e)return V0.get(e)}function Zk(e,t){e&&(t.draft.length===0&&t.attachments.length===0?V0.delete(e):V0.set(e,t))}const Jk=new Set;function Aee(e,t){return e.trim().length>0?`${e.trimEnd()}
539
+ `)}function qee(e){const t=MM(e);return{text:t.text,attachments:t.attachments.map((n,r)=>({id:`queued-${r}-${n.fileName}`,fileName:n.fileName,mimeType:n.type==="image"?"image/*":"application/octet-stream",url:n.url,status:"done"}))}}const V0=new Map,Kee=[];function eC(e){if(e)return V0.get(e)}function tC(e,t){e&&(t.draft.length===0&&t.attachments.length===0?V0.delete(e):V0.set(e,t))}const nC=new Set;function Gee(e,t){return e.trim().length>0?`${e.trimEnd()}
540
540
 
541
- ${t}`:t}function jee(e){return Jk.add(e),()=>Jk.delete(e)}function Lee(e,t){return e.replace(/(^|\s)\/(\S+)/g,(n,r,i)=>{const s=t.find(o=>o.name===i&&o.path);return s!=null&&s.path?`${r}[skill:${i}:${s.path}]`:n})}function Dee({api:e,cwd:t,sessionKey:n,onSend:r,disabled:i,onNewSession:s,onClearSession:o,tool:a,spawnableContacts:l=Mee,ensureRemotePersonas:c,remotePersonasByDeviceId:u}){const d=Qk(n),[f,p]=g.useState((d==null?void 0:d.draft)??""),[m,v]=g.useState(!1),w=g.useRef(null),x=g.useRef(!1),_=g.useCallback(()=>{x.current=!0},[]),y=g.useCallback(()=>{x.current=!1},[]),S=ap(),{attachments:C,setAttachments:k,addFiles:N,removeAttachment:T,clearAttachments:O}=Iee({httpBaseUrl:S.httpBaseUrl,httpToken:S.httpToken,sessionId:n,initial:(d==null?void 0:d.attachments)??[]}),[P,D]=g.useState([]),[R,A]=g.useState(!1),[M,L]=g.useState(0),[$,F]=g.useState(!1),[B,z]=g.useState([]),[E,H]=g.useState(!1),[q,j]=g.useState(0),[ne,ie]=g.useState(!1),[K,ge]=g.useState([]),[Pe,he]=g.useState(!1),[Ae,je]=g.useState(null),[$e,_e]=g.useState(!1),tt=g.useRef(null),Rt=g.useMemo(()=>{const se=[];return s&&se.push({name:"new",source:"builtin",description:"在当前目录下新建会话"}),o&&n&&se.push({name:"clear",source:"builtin",description:"清除当前会话"}),se},[s,o,n]),Xe=g.useMemo(()=>[...Rt,...P],[Rt,P]),ot=g.useMemo(()=>{const se=f.match(/^\/(\S*)$/);return se?se[1]:null},[f]),xn=ot!==null&&!$,ut=g.useMemo(()=>ot!==null?LM(Xe,ot):[],[Xe,ot]),Ct=g.useMemo(()=>{const se=f.match(/^@(\S*)$/);return se?se[1]:null},[f]),Ke=Ct!==null&&!ne,at=g.useMemo(()=>Ae?((u==null?void 0:u.get(Ae.deviceId))??[]).map(be=>({kind:"remote-persona",persona:be,deviceId:Ae.deviceId})):[...B.map(se=>({kind:"cc-agent",agent:se})),...K.map(se=>({kind:"persona",persona:se})),...l.map(se=>({kind:"contact",contact:se}))],[Ae,u,B,K,l]),Dt=g.useMemo(()=>Ct!==null?DM(at,Ct):[],[at,Ct]),Vt=g.useRef(f);g.useEffect(()=>{f!==Vt.current&&(F(!1),ie(!1),Vt.current=f)},[f]);const Tn=g.useCallback(()=>{F(!0)},[]),U=g.useCallback(()=>{ie(!0)},[]),J=g.useRef(f),ye=g.useRef(C);g.useEffect(()=>{J.current=f},[f]),g.useEffect(()=>{ye.current=C},[C]);const Ce=g.useRef(n);g.useEffect(()=>{if(n!==null)return jee((se,be)=>{se===n&&(p(lt=>Aee(lt,be)),queueMicrotask(()=>ch(w.current)))})},[n]),g.useEffect(()=>{const se=Ce.current;if(se===n)return;Zk(se,{draft:J.current,attachments:ye.current});const be=Qk(n);p((be==null?void 0:be.draft)??""),k((be==null?void 0:be.attachments)??[]),L(0),j(0),F(!1),ie(!1),je(null),tt.current=null,_e(!1),queueMicrotask(()=>{be!=null&&be.draft?ch(w.current):aa(w.current)}),Ce.current=n},[n,k]),g.useEffect(()=>()=>{Zk(Ce.current,{draft:J.current,attachments:ye.current})},[]),g.useEffect(()=>{L(0)},[ot]),g.useEffect(()=>{j(0)},[Ct]),g.useEffect(()=>{Ct===null&&Ae&&(je(null),tt.current=null,_e(!1))},[Ct,Ae]),g.useEffect(()=>{if(!xn||R)return;if(!e){A(!0);return}let se=!1;return(async()=>{try{const be=await e.skillsList(t,a);se||(D(be.skills??[]),A(!0))}catch{se||A(!0)}})(),()=>{se=!0}},[xn,R,e,t,a]),g.useEffect(()=>{if(!Ke||E)return;if(!e){H(!0);return}let se=!1;return(async()=>{try{const be=await e.agentsList(t,a);se||(z(be.agents??[]),H(!0))}catch{se||H(!0)}})(),()=>{se=!0}},[Ke,E,e,t,a]),g.useEffect(()=>{if(!Ke||Pe)return;if(!e){he(!0);return}let se=!1;return(async()=>{try{const be=await e.personaList();se||(ge((be.personas??[]).filter(lt=>lt.personaId!==UT).map(lt=>({personaId:lt.personaId,label:lt.label}))),he(!0))}catch{se||he(!0)}})(),()=>{se=!0}},[Ke,Pe,e]);const Fe=g.useCallback(se=>{switch(se.kind){case"persona":p(`@persona/${se.persona.personaId} `);break;case"cc-agent":p(`@"${se.agent.name} (agent)" `);break;case"contact":{const be=se.contact.deviceId;je({deviceId:be,displayName:se.contact.displayName}),tt.current=be,_e(!0),Promise.resolve(c==null?void 0:c(be)).finally(()=>{tt.current===be&&_e(!1)}),p("@"),ie(!1),setTimeout(()=>{var lt;return(lt=w.current)==null?void 0:lt.focus()},0);return}case"remote-persona":p(`@persona/${se.persona.personaId}@${se.deviceId} `),je(null);break}ie(!1),setTimeout(()=>{var be;return(be=w.current)==null?void 0:be.focus()},0)},[c]),xt=g.useCallback(()=>{je(null),tt.current=null,_e(!1),p("@"),setTimeout(()=>{var se;return(se=w.current)==null?void 0:se.focus()},0)},[]),un=g.useCallback(se=>{if(se.source==="builtin"&&se.name==="new"&&s){p(""),O(),aa(w.current),s(t);return}if(se.source==="builtin"&&se.name==="clear"&&o){p(""),O(),aa(w.current),o();return}p(`/${se.name} `),setTimeout(()=>{var be;return(be=w.current)==null?void 0:be.focus()},0)},[s,t,O,o]),qt=g.useCallback(async()=>{const se=f.trim(),be=C.filter(Mt=>Mt.status==="done");if(!se&&be.length===0||m||i)return;if(se==="/new"&&s){v(!0);try{await s(t),p(""),O(),aa(w.current)}finally{v(!1)}return}if(se==="/clear"&&o){v(!0);try{await o(),p(""),O(),aa(w.current)}finally{v(!1)}return}const lt=a==="codex"?Lee(se,P):se;v(!0);try{const Mt=PJ(lt,C);await r(Mt,{queueWhileRunning:!0}),p(""),O(),aa(w.current)}finally{v(!1)}},[f,C,m,i,r,s,t,O,o,a,P]),dn=g.useCallback(se=>{const{text:be,attachments:lt}=Ree(se);if(p(be),lt.length>0){const Mt=new Set(ye.current.map(Pr=>Pr.id));k([...ye.current,...lt.filter(Pr=>!Mt.has(Pr.id))])}queueMicrotask(()=>ch(w.current))},[k]);return{draft:f,setDraft:p,sending:m,textareaRef:w,isComposingRef:x,onCompositionStart:_,onCompositionEnd:y,attachments:C,addFiles:N,removeAttachment:T,skillSelectorVisible:xn,filteredSkills:ut,slashQuery:ot??"",activeSkillIdx:M,setActiveSkillIdx:L,selectSkill:un,dismissSkillSelector:Tn,agentSelectorVisible:Ke,filteredAgents:Dt,mentionQuery:Ct,activeAgentIdx:q,setActiveAgentIdx:j,selectAgent:Fe,dismissAgentSelector:U,drilldown:Ae,drilldownLoading:$e,exitDrilldown:xt,doSend:qt,restoreTextToDraft:dn}}const Oee=120;function ch(e){e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,Oee)}px`)}function aa(e){e&&(e.style.height="auto")}function Bee({items:e,restoreDisabled:t,onRestore:n,onRemove:r}){return e.length===0?null:h.jsxs("div",{"data-testid":"chat-input-queue",className:"flex flex-col",children:[h.jsx("div",{className:"px-1 pb-1 text-[11px] text-text-400",children:`排队中 · ${e.length} 条(这一轮跑完连起来一起发出)`}),e.map((i,s)=>h.jsxs("div",{"data-testid":`chat-input-queue-item-${i.id}`,className:"flex items-center gap-2 rounded-md px-1 py-1 transition-colors hover:bg-text-100/5",children:[h.jsx("span",{className:"shrink-0 w-4 text-center text-[11px] text-text-400 tabular-nums",children:s+1}),h.jsx("button",{type:"button","data-testid":`chat-input-queue-restore-${i.id}`,disabled:t,title:t?"先清空输入框再取回这条":"取回输入框继续改",onClick:()=>n(i.id),className:"flex-1 min-w-0 text-left text-[12.5px] text-text-200 truncate hover:text-text-100 disabled:cursor-not-allowed disabled:hover:text-text-200",children:i.text.trim()||"(空消息)"}),h.jsx("button",{type:"button","aria-label":"移出队列","data-testid":`chat-input-queue-remove-${i.id}`,onClick:()=>r(i.id),className:"shrink-0 p-0.5 rounded text-text-400 hover:text-text-100 hover:bg-text-100/10",children:h.jsx(Ir,{className:"w-3.5 h-3.5"})})]},i.id))]})}const zee="[--color-border:#E6E6E6] [--bg-300:#E6E6E6] dark:[--color-border:#424242] dark:[--bg-300:#424242]",$ee={spawnableContacts:[],ensureRemotePersonas:()=>Promise.resolve(),remotePersonasByDeviceId:new Map},Fee=g.createContext($ee);function Hee(){return g.useContext(Fee)}function Uee({url:e,fileName:t,onClose:n}){const[r,i]=g.useState(!1);g.useEffect(()=>{const o=a=>{a.key==="Escape"&&n()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[n]);const s=async()=>{try{const a=await(await fetch(e)).blob();await navigator.clipboard.write([new ClipboardItem({[a.type]:a})]),i(!0),setTimeout(()=>i(!1),2e3)}catch{eC(e,t)}};return h.jsx("div",{"data-testid":"image-lightbox",className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/60",onClick:n,role:"dialog","aria-modal":"true",children:h.jsxs("div",{className:"relative",onClick:o=>o.stopPropagation(),children:[h.jsx("img",{src:e,alt:t,className:"max-h-[90vh] max-w-[92vw] rounded-lg object-contain shadow-2xl"}),h.jsxs("div",{className:"absolute right-2 top-2 flex items-center gap-1.5",children:[h.jsxs("button",{type:"button",onClick:s,"data-testid":"image-lightbox-copy",className:"flex cursor-pointer items-center gap-1 rounded-full border border-bg-300 bg-bg-50/95 px-2 py-0.5 text-[11px] font-medium text-text-200 shadow transition-colors hover:bg-bg-100",children:[h.jsx(up,{className:"h-3 w-3"}),r?"Copied":"Copy"]}),h.jsxs("button",{type:"button",onClick:()=>eC(e,t),"data-testid":"image-lightbox-save",className:"flex cursor-pointer items-center gap-1 rounded-full border border-bg-300 bg-bg-50/95 px-2 py-0.5 text-[11px] font-medium text-text-200 shadow transition-colors hover:bg-bg-100",children:[h.jsx(V$,{className:"h-3.5 w-3.5"}),"Save"]}),h.jsx("button",{type:"button",onClick:n,"data-testid":"image-lightbox-close","aria-label":"close",className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded-full border border-bg-300 bg-bg-50/95 text-text-300 transition-colors hover:bg-bg-100 hover:text-text-100",children:h.jsx(Ir,{className:"h-3 w-3"})})]})]})})}function eC(e,t){const n=document.createElement("a");n.href=e,n.download=t||"image",n.click()}const tC=1e3,OM=`bg-bg-50 ${zee}`,nC=`mx-2 -mb-3 rounded-t-xl border border-b-0 border-border px-3 pt-2 pb-4 ${OM}`,Wee=5e3;function Pd(e){if(!e)return"null";if(e===document.body)return"body";const t=e.getAttribute("data-testid"),n=typeof e.className=="string"&&e.className.trim()?`.${e.className.trim().split(/\s+/).slice(0,3).join(".")}`:"";return`${e.tagName.toLowerCase()}${e.id?`#${e.id}`:""}${t?`[${t}]`:""}${n}`}function Vee({meta:e,api:t,cwd:n,tool:r,onSend:i,sessionKey:s,queued:o,onDequeue:a,disabled:l=!1,placeholder:c,className:u,awaitingUser:d=!1,onAbort:f,onNewSession:p,onClearSession:m,configSlot:v,aboveSlot:w}){const x=(e==null?void 0:e.streamInProgress)??!1,_=(e==null?void 0:e.contextPct)??null,y=_==null?"":_>=80?"text-red-400":_>=50?"text-amber-400":"text-text-500",S=g.useRef(null),C=Hee(),k=Dee({...t?{api:t}:{},cwd:n,...r?{tool:r}:{},sessionKey:s,onSend:i,disabled:l,...p?{onNewSession:p}:{},...m?{onClearSession:m}:{},spawnableContacts:C.spawnableContacts,ensureRemotePersonas:C.ensureRemotePersonas,remotePersonasByDeviceId:C.remotePersonasByDeviceId}),{draft:N,setDraft:T,sending:O,textareaRef:P,attachments:D,addFiles:R,removeAttachment:A,skillSelectorVisible:M,filteredSkills:L,slashQuery:$,activeSkillIdx:F,setActiveSkillIdx:B,selectSkill:z,dismissSkillSelector:E,agentSelectorVisible:H,filteredAgents:q,mentionQuery:j,activeAgentIdx:ne,setActiveAgentIdx:ie,selectAgent:K,dismissAgentSelector:ge,drilldown:Pe,drilldownLoading:he,exitDrilldown:Ae,doSend:je,restoreTextToDraft:$e}=k,_e=g.useCallback(()=>{(async()=>{const ae=await(f==null?void 0:f());ae&&ae.length>0&&$e(Pee(ae,N))})()},[f,$e,N]),tt=g.useCallback(ae=>{const Ze=o==null?void 0:o.find(hn=>hn.id===ae);!Ze||!a||N.trim().length>0||(a(ae),$e(Ze.text))},[o,a,N,$e]),Rt=fee();g.useEffect(()=>{if(!Rt||Rt.signal===0||s===null||Rt.sessionId!==s)return;const{signal:ae}=Rt;console.log("[chat-focus] 收到聚焦信号",{sessionKey:s,signal:ae,delayMs:tC,activeElement:Pd(document.activeElement)});let Ze=null,hn=null,Ys=null;const Ko=setTimeout(()=>{if(Ze=P.current,!Ze){console.warn("[chat-focus] textarea 已不在,放弃聚焦",{sessionKey:s,signal:ae});return}Ze.focus(),console.log("[chat-focus] focus() 已执行",{sessionKey:s,signal:ae,landed:document.activeElement===Ze,activeElement:Pd(document.activeElement)}),hn=Go=>{const Si=Pd(Go.relatedTarget);setTimeout(()=>{console.warn("[chat-focus] STOLEN 输入框失焦",{sessionKey:s,signal:ae,relatedTarget:Si,activeElementAfterTick:Pd(document.activeElement)})},0)},Ze.addEventListener("blur",hn,{once:!0}),Ys=setTimeout(()=>{Ze&&hn&&Ze.removeEventListener("blur",hn)},Wee)},tC);return()=>{clearTimeout(Ko),Ys&&clearTimeout(Ys),Ze&&hn&&Ze.removeEventListener("blur",hn)}},[Rt==null?void 0:Rt.signal]);const Xe=!!t,ot=O||l||x,ut=(N.trim().length>0||D.some(ae=>ae.status==="done"))&&!l&&!O&&!d,Ct=c??(d?"Answer the question above first...":ot?"Queue a message...":`Message ${ny(r)}...`),Ke=g.useRef(!1),at=g.useCallback(()=>{Ke.current=!0},[]),Dt=g.useCallback(()=>{Ke.current=!1},[]),Vt=g.useCallback(ae=>{if(M&&L.length>0){if(ae.key==="ArrowDown")return ae.preventDefault(),B(F>=L.length-1?0:F+1),!0;if(ae.key==="ArrowUp")return ae.preventDefault(),B(F<=0?L.length-1:F-1),!0;if(ae.key==="Tab"||ae.key==="Enter"&&!ae.shiftKey){ae.preventDefault();const Ze=L[F];return Ze&&z(Ze),!0}if(ae.key==="Escape")return ae.preventDefault(),E(),!0}return!1},[M,L,F,B,z,E]),Tn=g.useCallback(ae=>{if(H&&q.length>0){if(ae.key==="ArrowDown")return ae.preventDefault(),ie(ne>=q.length-1?0:ne+1),!0;if(ae.key==="ArrowUp")return ae.preventDefault(),ie(ne<=0?q.length-1:ne-1),!0;if(ae.key==="Tab"||ae.key==="Enter"&&!ae.shiftKey){ae.preventDefault();const Ze=q[ne];return Ze&&K(Ze),!0}if(ae.key==="Escape")return ae.preventDefault(),Pe?Ae():ge(),!0}return!1},[H,q,ne,ie,K,ge,Pe,Ae]),U=g.useCallback(ae=>{const Ze=ae.nativeEvent;ae.key==="Enter"&&LR({compositionActive:Ke.current,nativeIsComposing:Ze.isComposing,keyCode:Ze.keyCode})||Vt(ae)||Tn(ae)||DR({key:ae.key,shiftKey:ae.shiftKey,compositionActive:Ke.current,nativeIsComposing:Ze.isComposing,keyCode:Ze.keyCode})&&(ae.preventDefault(),ut&&je())},[Vt,Tn,ut,je]),J=g.useCallback(ae=>{T(ae.target.value),ch(ae.target)},[T]),ye=g.useCallback(ae=>{ae.target.files&&R(ae.target.files),ae.target.value=""},[R]),Ce=g.useCallback(ae=>{if(!Xe)return;const Ze=Array.from(ae.clipboardData.items).map(hn=>hn.getAsFile()).filter(hn=>!!(hn&&hn.type.startsWith("image/")));Ze.length!==0&&(ae.preventDefault(),R(Ze))},[R,Xe]),[Fe,xt]=g.useState(null),un=g.useCallback(ae=>{ae.previewUrl&&xt({url:ae.previewUrl,name:ae.fileName})},[]),[qt,dn]=g.useState(!1),se=g.useCallback(ae=>{Xe&&(ae.preventDefault(),dn(!0))},[Xe]),be=g.useCallback(()=>dn(!1),[]),lt=g.useCallback(ae=>{Xe&&(ae.preventDefault(),dn(!1),ae.dataTransfer.files.length>0&&R(ae.dataTransfer.files))},[R,Xe]),Mt=x&&!d&&typeof f=="function",Pr=l||d;return h.jsxs("div",{"data-testid":"chat-input",className:re("shrink-0 border-t border-bg-300/20 px-4 py-3",u),onDragOver:se,onDragLeave:be,onDrop:lt,children:[h.jsxs("div",{className:"max-w-3xl mx-auto relative",children:[Xe?h.jsx("input",{ref:S,type:"file",multiple:!0,accept:bee,hidden:!0,onChange:ye,"data-testid":"chat-input-file"}):null,h.jsxs("div",{"data-testid":"chat-input-bare",className:re("flex flex-col gap-2"),children:[d||O||x?h.jsxs("div",{"data-testid":"chat-input-status-bar",className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsxs("div",{className:"flex gap-1",children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"0ms"}}),h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"150ms"}}),h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"300ms"}})]}),h.jsx("span",{children:d?"Waiting for your answer":`${r==="codex"?"Codex":"Claude"} is working`})]}):null,M?h.jsx(dee,{query:$,skills:L,activeIndex:F,onActiveIndexChange:B,onSelect:z}):null,H?Pe?!C.remotePersonasByDeviceId.has(Pe.deviceId)&&he?h.jsx("div",{"data-testid":"cc-agent-remote-loading",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 rounded-2xl border border-bg-300 bg-bg-50 px-4 py-3 text-[12px] text-text-300 shadow-lg",children:`正在加载 @${Pe.displayName} 的 persona…`}):q.length>0?h.jsx(Yk,{query:j??"",entries:q,activeIndex:ne,onActiveIndexChange:ie,onSelect:K}):h.jsx("div",{"data-testid":"cc-agent-remote-empty",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 rounded-2xl border border-bg-300 bg-bg-50 px-4 py-3 text-[12px] text-text-300 shadow-lg",children:`@${Pe.displayName} 暂无可派活的 persona(可能离线或未公开)`}):h.jsx(Yk,{query:j??"",entries:q,activeIndex:ne,onActiveIndexChange:ie,onSelect:K}):null,o&&o.length>0?h.jsx("div",{"data-testid":"chat-input-queue-header",className:nC,children:h.jsx(Bee,{items:o,restoreDisabled:N.trim().length>0||!a,onRestore:tt,onRemove:ae=>void(a==null?void 0:a(ae))})}):null,D.length>0?h.jsx(_ee,{attachments:D,onRemove:A,onOpenPreview:un}):null,w?h.jsx("div",{"data-testid":"chat-input-above-slot",className:nC,children:w}):null,h.jsxs("div",{"data-testid":"bare-chat-input-frame",className:re("relative flex flex-col gap-1 rounded-xl border border-border px-3 py-2 transition-colors duration-200",OM,Pr?"opacity-60":null,qt?"border-accent/60 bg-accent/5":null),children:[h.jsx("textarea",{ref:P,"data-testid":"chat-input-textarea",value:N,onChange:J,onKeyDown:U,onCompositionStart:at,onCompositionEnd:Dt,onPaste:Ce,placeholder:Ct,disabled:Pr,readOnly:Pr,rows:1,className:"w-full resize-none bg-transparent border-0 outline-none text-[14px] text-text-100 placeholder:text-text-400 leading-relaxed py-1 min-h-[22px] max-h-[120px] overflow-y-auto disabled:cursor-not-allowed"}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[Xe?h.jsx("button",{type:"button",onClick:()=>{var ae;return(ae=S.current)==null?void 0:ae.click()},disabled:ot,"data-testid":"chat-input-attach","aria-label":"attach files",className:re("flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors",ot?"cursor-default text-text-400/50":"cursor-pointer text-text-400 hover:bg-text-100/5 hover:text-text-200"),children:h.jsx(b8,{className:"h-4 w-4"})}):null,h.jsx("div",{className:"flex-1 min-w-0"}),_!=null?h.jsxs("span",{"data-testid":"chat-input-ctx",className:re("shrink-0 text-[11px] tabular-nums",y),children:["ctx:",_,"%"]}):null,v,Mt?h.jsx("button",{type:"button",onClick:_e,"data-testid":"chat-input-abort","aria-label":"interrupt",title:"中断当前轮次(不杀进程)",className:"h-8 w-8 rounded-full flex items-center justify-center border border-text-400/40 text-text-400 hover:bg-text-100/5 hover:text-text-100 transition-colors cursor-pointer",children:h.jsx(SI,{className:"w-3.5 h-3.5",strokeWidth:2.5})}):null,h.jsx("button",{type:"button",onClick:()=>{ut&&je()},disabled:!ut,"data-testid":"chat-input-send","aria-label":"send",className:re("h-8 w-8 rounded-full flex items-center justify-center transition-colors",ut?"bg-accent text-white hover:bg-accent-hover cursor-pointer shadow-sm":"bg-[var(--text-400-dim)] text-[var(--text-400-dim-fg)] cursor-default"),children:h.jsx(b$,{className:"w-4 h-4",strokeWidth:2.5})})]})]})]})]}),Fe?h.jsx(Uee,{url:Fe.url,fileName:Fe.name,onClose:()=>xt(null)}):null]})}function qee(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function Kee({meta:e,tool:t,connState:n,variant:r="full",onOpenConfig:i,liveWorktreeRoot:s,ephemeral:o=!1,onPromote:a,className:l}){const c=s??e.cwd??"",d=!!e.sessionLabel&&e.sessionLabel!==e.sessionId?e.sessionLabel:qee(c),f=c;return r==="quickask"?h.jsxs("div",{"data-testid":"chat-header","data-variant":"quickask",className:re("flex items-center shrink-0 px-3 py-2 gap-2",l),children:[a?h.jsx("button",{type:"button","data-testid":"chat-header-promote","data-promoted":o?"false":"true",disabled:!o,onClick:a,title:o?"保留为正式会话":"已保留为正式会话",className:re("shrink-0 inline-flex items-center justify-center h-5 w-5 rounded-md transition-colors",o?"text-text-500 hover:text-text-200 hover:bg-text-100/5 cursor-pointer":"text-amber-400"),children:h.jsx(T$,{className:re("w-3.5 h-3.5",!o&&"fill-current")})}):null,h.jsx("span",{className:"font-semibold text-text-100 truncate text-[13px]","data-testid":"chat-header-worktree",title:f,children:d})]}):h.jsxs("div",{"data-testid":"chat-header","data-variant":"full",className:re("relative flex items-center shrink-0 px-4 pr-[4.5rem] md:pr-4 py-2.5",l),children:[h.jsx("span",{className:"font-semibold text-text-100 truncate text-[13px]","data-testid":"chat-header-worktree",title:f,children:d}),h.jsx("div",{className:"absolute right-4 top-1/2 -translate-y-1/2 z-10 flex items-center gap-1",children:i?h.jsx("button",{type:"button","aria-label":"Session settings","data-testid":"chat-header-settings-mobile",onClick:i,title:"Session settings",className:"flex md:hidden h-7 w-7 items-center justify-center rounded-md bg-transparent text-text-300 transition-colors duration-150 hover:bg-bg-200 hover:text-text-100 cursor-pointer outline-none",children:h.jsx(yI,{className:"w-4 h-4"})}):null})]})}function Gee({testid:e,children:t}){return h.jsx("div",{"data-testid":e,className:"h-full min-w-0 border-l border-border bg-bg-100 flex flex-col",children:t})}function Yee({title:e,onBack:t,onCollapse:n,collapseLabel:r="collapse session info",collapseTitle:i="收起会话信息"}){const s=o=>h.jsx("button",{type:"button","data-testid":"session-info-collapse",onClick:n,"aria-label":r,title:i,className:`p-1 rounded text-text-400 hover:text-text-100 hover:bg-text-100/10 ${o}`,children:h.jsx(Ww,{className:"w-4 h-4"})});return h.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b border-border shrink-0",children:[t?h.jsx("button",{type:"button","data-testid":"session-info-back",onClick:t,"aria-label":"返回会话信息",className:"p-1 -ml-1 rounded text-text-400 hover:text-text-100 hover:bg-text-100/10",children:h.jsx(_$,{className:"w-4 h-4"})}):n?s("-ml-1"):h.jsx(Ww,{className:"w-4 h-4 text-text-300"}),h.jsx("span",{className:"flex-1 text-[13px] font-medium text-text-100 truncate",children:e}),t&&n?s(""):null]})}function cg({icon:e,label:t,meta:n,active:r,onClick:i,testid:s}){return h.jsxs("button",{type:"button","data-testid":s,onClick:i,"aria-current":r?"true":void 0,className:`w-full flex items-center gap-2.5 px-2 py-1.5 rounded-md cursor-pointer text-left ${r?"bg-text-100/10":"hover:bg-text-100/5"}`,children:[h.jsx("span",{className:"w-4 h-4 shrink-0 text-text-300 inline-flex items-center justify-center",children:e}),h.jsx("span",{className:"flex-1 text-[12.5px] text-text-100",children:t}),n?h.jsx("span",{className:"shrink-0 text-[11px] text-text-400 font-mono",children:n}):null]})}let Xee=null;function Qee(){return Xee}function oc({label:e,labelTitle:t,children:n}){return h.jsxs("div",{className:"flex items-start gap-2 px-2 py-1",children:[h.jsx("span",{className:"w-14 shrink-0 truncate text-[11px] text-text-400 pt-0.5",...t?{title:t}:{},children:e}),h.jsx("span",{className:"flex-1 min-w-0 text-[12px] text-text-100",children:n})]})}function rC({label:e,labelTitle:t,value:n,testid:r}){const[i,s]=g.useState(!1),o=g.useRef(null);g.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]);const a=()=>{typeof navigator>"u"||!navigator.clipboard||navigator.clipboard.writeText(n).then(()=>{s(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>s(!1),2e3)},()=>{})};return h.jsx(oc,{label:e,labelTitle:t,children:h.jsxs("button",{type:"button",onClick:a,"data-testid":r,title:i?"已复制":`复制:${n}`,className:"w-full flex items-center gap-1.5 text-left group cursor-pointer",children:[h.jsx("span",{className:"font-mono text-[11px] text-text-300 truncate flex-1 min-w-0",children:n}),i?h.jsx(wl,{className:"w-3 h-3 shrink-0 text-accent"}):h.jsx(up,{className:"w-3 h-3 shrink-0 text-text-400 opacity-0 group-hover:opacity-100 transition-opacity"})]})})}function Zee({session:e,meta:t,liveGitBranch:n,liveWorktreeRoot:r,personaName:i,onOpenPersona:s,onOpenFiles:o,cronActiveCount:a,onCronClick:l,onForceStop:c,viewerRole:u="owner",toolSessionIdLabel:d="tool session id",drill:f=null,onCollapse:p}){const m=n!==void 0?n:t.gitBranch??null,v=t.procAlive??!1,w=VI(e),x=w!=null&&e.originOwnerPrincipalId==null&&u!=="guest",[_,y]=g.useState(null),S=g.useRef(null);g.useEffect(()=>()=>{S.current&&clearTimeout(S.current)},[]);const C=async()=>{if(!x)return;const k=Qee();let N;try{k||(await navigator.clipboard.writeText(w),N="命令已复制")}catch{N="操作失败"}y(N),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>y(null),2500)};return h.jsxs(Gee,{testid:"session-info-panel",children:[h.jsx(Yee,{title:f?f.title:"会话信息",...f?{onBack:f.onBack}:{},...p?{onCollapse:p}:{}}),f?h.jsx("div",{"data-testid":"session-info-drill",className:"flex-1 min-h-0 overflow-y-auto",children:f.content}):h.jsxs("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:[m?h.jsx(oc,{label:"分支",children:h.jsxs("span",{"data-testid":"session-info-branch",className:"inline-flex items-center gap-1 font-mono text-[11.5px] min-w-0",title:r??void 0,children:[h.jsx(Q_,{className:"w-3 h-3 shrink-0 text-text-400"}),h.jsx("span",{className:"truncate",children:m})]})}):null,i&&s?h.jsx(oc,{label:"persona",children:h.jsxs("button",{type:"button","data-testid":"session-info-persona",onClick:s,className:"inline-flex items-center gap-1 hover:text-accent cursor-pointer",children:[h.jsx(NI,{className:"w-3 h-3"}),h.jsx("span",{className:"truncate",children:i})]})}):null,h.jsx(oc,{label:"引擎",children:h.jsxs("span",{className:"inline-flex items-center gap-1.5","data-testid":"session-info-engine",children:[h.jsx(dp,{tool:e.tool,className:re("w-3.5 h-3.5 shrink-0",hp(e.tool))}),h.jsxs("span",{className:"truncate",children:[ny(e.tool),t.model?` · ${t.model}`:""]})]})}),h.jsx(oc,{label:"cwd",children:h.jsx("span",{"data-testid":"session-info-cwd",className:"font-mono text-[11px] text-text-300 truncate block",title:e.cwd,children:e.cwd})}),h.jsx(rC,{label:"session id",value:e.sessionId,testid:"session-info-session-id"}),e.toolSessionId?h.jsx(rC,{label:`${e.tool||"claude"} id`,labelTitle:d,value:e.toolSessionId,testid:"session-info-tool-session-id"}):null,h.jsx("div",{className:"my-2 border-t border-border"}),o?h.jsx(cg,{icon:h.jsx(Z$,{className:"w-3.5 h-3.5"}),label:"Edited Files",onClick:o,testid:"session-info-files"}):null,a&&a>0&&l?h.jsx(cg,{icon:h.jsx($$,{className:"w-3.5 h-3.5"}),label:"定时任务",meta:String(a),onClick:l,testid:"session-info-cron"}):null,x?h.jsx(cg,{icon:h.jsx(K8,{className:"w-3.5 h-3.5"}),label:"终端",meta:_,onClick:()=>void C(),testid:"session-info-terminal"}):null]}),v&&c?h.jsx("div",{className:"shrink-0 border-t border-border px-3 py-2.5",children:h.jsxs("button",{type:"button","data-testid":"session-info-force-stop",onClick:c,title:e.tool==="codex"?"强制停止 Codex 进程":"强制停止 Claude Code 进程(会丢失 initialize / 预热缓存)",className:"inline-flex items-center gap-1.5 h-6 px-2.5 rounded-md text-text-400 hover:bg-red-500/10 hover:text-red-400 transition-colors text-[12px] cursor-pointer",children:[h.jsx(x8,{className:"w-3.5 h-3.5"}),h.jsx("span",{children:"强制停止"})]})}):null]})}const Jee=g.createContext({container:null});function ete(){return g.useContext(Jee)}const n1="fixed top-0 md:top-10 bottom-0 right-0";function tte(e){return e==="TodoWrite"}function nte(e){if(!e||typeof e!="object")return null;const t=e;if(!Array.isArray(t.todos))return null;const n=[];for(const r of t.todos){if(!r||typeof r!="object")continue;const i=r,s=typeof i.content=="string"?i.content:"";if(!s)continue;const o=i.status==="in_progress"||i.status==="completed"?i.status:"pending",a=typeof i.activeForm=="string"?i.activeForm:void 0;n.push({content:s,status:o,activeForm:a})}return n}function rte(e,t,n){var s;const r=[],i=new Map;for(let o=0;o<e.length;o++){const a=e[o],l=typeof a.seq=="number"?a.seq:o;switch(a.kind){case"session_init":r.push({kind:"session-init",seq:l,toolSessionId:a.toolSessionId});break;case"text":iC(r,l,"assistant-text",a.text,a.partialId,a.uuid);break;case"thinking":iC(r,l,"assistant-thinking",a.text,a.partialId);break;case"user_text":{a.meta==="task-notification"?r.push({kind:"agent-notification",seq:l,text:a.text,taskId:a.taskId,parentToolUseId:a.parentToolUseId}):a.meta?r.push({kind:"user-meta",seq:l,metaKind:a.meta,text:a.text}):r.push({kind:"user-text",seq:l,text:a.text,uuid:a.uuid,...a.sender&&(a.sender.principal!=="owner"||iI.test(a.text))?{senderDisplayName:a.sender.displayName}:{},senderPrincipal:((s=a.sender)==null?void 0:s.principal)==="guest"?"guest":"owner"});break}case"tool_call":BM(r,l,a.toolUseId,a.tool,a.input,a.toolKind);break;case"tool_result":{const c=i.get(a.toolUseId);if(c!==void 0){if(a.askQuestionAnswers){const d=r[c];d.submittedAnswers=a.askQuestionAnswers}i.delete(a.toolUseId);break}const u={kind:"tool-result",seq:l,toolUseId:a.toolUseId,output:a.output,error:a.error};a.toolResultExtra&&(u.toolResultExtra=a.toolResultExtra),r.push(u);break}case"attachment_memories":r.push({kind:"memory-callout",seq:l,memories:a.memories});break;case"permission_request":{if(!t||a.requestId!==t)break;r.push({kind:"permission-inline",seq:l,requestId:a.requestId,tool:a.tool,input:a.input});break}case"ask_user_question":i.set(a.toolUseId,r.length),r.push({kind:"question-card",seq:l,toolUseId:a.toolUseId,questions:a.questions});break;case"turn_end":{const c={kind:"turn-end",seq:l};a.durationMs!==void 0&&(c.durationMs=a.durationMs),a.reason!==void 0&&(c.reason=a.reason),r.push(c);break}case"subagent_progress":{const c={kind:"agent-progress",seq:l,toolUseId:a.toolUseId,agentId:a.agentId,status:a.status};a.description&&(c.description=a.description),a.lastToolName&&(c.lastToolName=a.lastToolName),a.prompt&&(c.prompt=a.prompt),a.stats&&(c.stats=a.stats),r.push(c);break}case"error":r.push({kind:"error",seq:l,message:a.message});break}}return r}function BM(e,t,n,r,i,s){if(tte(r)){const o=nte(i);if(o){e.push({kind:"todo-checklist",seq:t,toolUseId:n,todos:o});return}}if(r==="Agent"){const o=i??{},a=typeof o.description=="string"&&o.description?o.description:typeof o.subagent_type=="string"&&o.subagent_type?o.subagent_type:"Subagent";e.push({kind:"agent-call",seq:t,toolUseId:n,description:a,input:i});return}if(MV(r)){e.push({kind:"task-event",seq:t,toolUseId:n,name:r,input:i});return}e.push({kind:"tool-call",seq:t,toolUseId:n,tool:r,toolKind:s,input:i})}function iC(e,t,n,r,i,s){let o=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind===n){o=c;break}const a=o>=0?e[o]:null;if(i){if(a&&a.partialId===i){const u=n==="assistant-text"?{kind:n,seq:a.seq,text:a.text+r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:a.text+r,partialId:i};e[o]=u;return}const c=n==="assistant-text"?{kind:n,seq:t,text:r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r,partialId:i};e.push(c);return}if(a&&a.partialId){const c=n==="assistant-text"?{kind:n,seq:a.seq,text:r,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:r};e[o]=c;return}const l=n==="assistant-text"?{kind:n,seq:t,text:r,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r};e.push(l)}const ite="AskUserQuestion";function zM(e,t=0,n){var o;const r=[],i=new Map;let s=t;for(const a of e){const l=s++,c=a.toolUseId??`hist-${l}`;switch(a.kind){case"user-text":if(a.meta==="task-notification")r.push({kind:"agent-notification",seq:l,text:a.text??"",taskId:a.taskId,parentToolUseId:a.parentToolUseId});else if(a.meta)r.push({kind:"user-meta",seq:l,metaKind:a.meta,text:a.text??""});else{const u=iI.exec(a.text??""),d=(o=sz.exec(a.text??""))==null?void 0:o[1],f=(u==null?void 0:u[2])??d,p=(u==null?void 0:u[1])==="guest"||d?"guest":"owner";r.push({kind:"user-text",seq:l,text:a.text??"",uuid:a.uuid,...f?{senderDisplayName:f}:{},senderPrincipal:p})}break;case"assistant-text":r.push({kind:"assistant-text",seq:l,text:a.text??"",uuid:a.uuid});break;case"tool_call":{if(a.tool===ite){const u=a.input??{},d=Array.isArray(u.questions)?u.questions:[];i.set(c,r.length),r.push({kind:"question-card",seq:l,toolUseId:c,questions:d});break}BM(r,l,c,a.tool??"",a.input,n);break}case"tool_result":{const u=i.get(c);if(u!==void 0){if(a.askQuestionAnswers){const f=r[u];f.submittedAnswers=a.askQuestionAnswers}i.delete(c);break}const d={kind:"tool-result",seq:l,toolUseId:c,output:a.output};a.error!==void 0&&(d.error=a.error),a.toolResultExtra&&(d.toolResultExtra=a.toolResultExtra),r.push(d);break}case"attachment_memories":a.memories&&a.memories.length>0&&r.push({kind:"memory-callout",seq:l,memories:a.memories});break;case"summary":break;case"turn-end":{const u={kind:"turn-end",seq:l};typeof a.durationMs=="number"&&(u.durationMs=a.durationMs),r.push(u);break}}}return r}const ste=5e5;function ote(e){const t=ste-e.length;return e.map(n=>({...n,seq:n.seq+t}))}function ate({api:e,cwd:t,toolSessionId:n,toolKind:r="claude"}){const i=RM(),s=(i==null?void 0:i.state.agentId)??null,o=i==null?void 0:i.state.agentType,[a,l]=g.useState([]),[c,u]=g.useState(!1),[d,f]=g.useState(null);g.useEffect(()=>{if(!s)return;let m=!1;return u(!0),f(null),l([]),e.historySubagentRead({cwd:t,toolSessionId:n,subagentId:s}).then(v=>{m||l(v.messages??[])}).catch(v=>{m||f(v instanceof Error?v.message:String(v))}).finally(()=>{m||u(!1)}),()=>{m=!0}},[s,t,n,e]);const p=g.useMemo(()=>a.length>0?zM(a,0,r):[],[a,r]);return!i||!s?null:h.jsxs("div",{"data-testid":"subagent-drawer","data-agent-id":s,className:re(n1,"z-50 w-[min(560px,92vw)]","flex flex-col border-l border-bg-200/60 bg-bg-50 shadow-xl"),style:{paddingTop:"env(safe-area-inset-top)"},children:[h.jsxs("div",{className:"flex flex-col gap-0.5 px-3 py-2 border-b border-bg-200/60",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o?h.jsx("span",{className:"inline-flex items-center rounded-sm bg-violet-500/10 px-1.5 py-0.5 text-[11px] text-violet-400 font-medium",children:o}):null,h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate",title:s,children:s})]}),h.jsx("button",{type:"button","aria-label":"关闭",onClick:()=>i.close(),className:"p-1 rounded hover:bg-bg-200/50 text-text-400 hover:text-text-200",children:h.jsx(Ir,{className:"w-4 h-4"})})]}),!c&&!d&&a.length>0?h.jsxs("div",{className:"text-[11px] text-text-400",children:[a.length," 条消息 · 首条为主会话派发的任务指令"]}):null]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden px-3 py-2",children:c?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(Ln,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"加载中…"})]}):d?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-error",children:[h.jsx(Qi,{className:"w-3.5 h-3.5"}),h.jsx("span",{children:d})]}):p.length===0?h.jsx("div",{className:"text-[12px] text-text-400 italic",children:"无消息"}):h.jsx(jM,{lines:p})})]})}function sC(e,t){let n=0;for(const r of e.lines)r.startsWith(t)&&n++;return n}function lte(e,t){const n=e.findIndex(c=>c.kind==="user-text"&&c.uuid===t);if(n<0)return{userMessageId:t,files:[],totalInsertions:0,totalDeletions:0,anchorFound:!1};let r=e.length;for(let c=n+1;c<e.length;c++)if(e[c].kind==="user-text"){r=c;break}const i=[],s=new Map;for(let c=n+1;c<r;c++){const u=e[c];if(u.kind!=="tool-result")continue;const d=u.toolResultExtra;if(!(d!=null&&d.filePath)||!d.structuredPatch||d.structuredPatch.length===0)continue;const f=d.filePath;let p=s.get(f);p||(p={filePath:f,hunks:[],insertions:0,deletions:0},s.set(f,p),i.push(f));for(const m of d.structuredPatch)p.hunks.push(m),p.insertions+=sC(m,"+"),p.deletions+=sC(m,"-")}const o=i.map(c=>s.get(c)),a=o.reduce((c,u)=>c+u.insertions,0),l=o.reduce((c,u)=>c+u.deletions,0);return{userMessageId:t,files:o,totalInsertions:a,totalDeletions:l,anchorFound:!0}}function cte({open:e,onOpenChange:t,api:n,sessionId:r,userMessageId:i,lines:s,procAlive:o,onApplied:a,onNoChanges:l}){const c=g.useMemo(()=>lte(s,i),[s,i]),[u,d]=g.useState(null),[f,p]=g.useState(!1),[m,v]=g.useState(!1),[w,x]=g.useState(null);g.useEffect(()=>{if(!e)return;let k=!1;return p(!0),d(null),(async()=>{try{const N=await n.sessionRewindDiff({sessionId:r,userMessageId:i});k||(d(N),!N.canRewind&&!N.error&&N.files.length===0&&(l==null||l(i)))}catch{k||d(null)}finally{k||p(!1)}})(),()=>{k=!0}},[e,n,r,i]);const _=g.useMemo(()=>{if(u){const k=!u.canRewind&&!u.error&&u.files.length===0;if(u.canRewind||k)return{source:"rpc",anchorFound:!0,files:u.files.map(N=>({filePath:N.filePath,hunks:N.hunks,insertions:N.insertions,deletions:N.deletions})),totalInsertions:u.totalInsertions,totalDeletions:u.totalDeletions}}return{source:"local",anchorFound:c.anchorFound,files:c.files,totalInsertions:c.totalInsertions,totalDeletions:c.totalDeletions,rpcError:u==null?void 0:u.error}},[u,c]),y=g.useCallback(async()=>{v(!0),x(null);try{const k=await n.sessionRewind({sessionId:r,userMessageId:i,dryRun:!1});if(!k.canRewind){x(k.error??"回退失败");return}a==null||a(),t(!1)}catch(k){x(k.message||"回退失败")}finally{v(!1)}},[n,r,i,a,t]);if(!e)return null;const S=_.files.length>0,C=!f&&!m&&_.anchorFound&&S&&!w;return h.jsxs("div",{"data-testid":"rewind-preview-drawer",className:`${n1} z-40 flex flex-col border-l border-bg-300/40 bg-bg-0 shadow-xl`,style:{width:480,minWidth:480},children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bg-300/30 shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(EI,{className:"w-4 h-4 text-text-300"}),h.jsx("span",{className:"text-[14px] font-semibold text-text-100",children:"Rewind 预览"})]}),h.jsx("button",{type:"button",onClick:()=>t(!1),"data-testid":"rewind-drawer-close",className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:bg-text-100/5 hover:text-text-200 cursor-pointer","aria-label":"close",children:h.jsx(Ir,{className:"w-4 h-4"})})]}),w?h.jsxs("div",{"data-testid":"rewind-error-banner",className:"mx-4 mt-3 flex items-start gap-2 rounded-md border border-red-400/40 bg-red-500/10 px-3 py-2 text-[12px] text-red-400",children:[h.jsx(nu,{className:"w-4 h-4 shrink-0 mt-0.5"}),h.jsx("span",{children:w})]}):null,h.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-3",children:f?h.jsxs("div",{"data-testid":"rewind-loading",className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(Ln,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"正在读取快照…"})]}):_.anchorFound?S?h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":"rewind-summary",className:"rounded-md border border-bg-300 bg-bg-100/40 px-3 py-2 text-[12px] text-text-200",children:[h.jsxs("div",{children:["将回退 ",h.jsx("span",{className:"font-semibold text-text-100",children:_.files.length})," ","个文件,",h.jsxs("span",{className:"text-green-500 font-mono",children:["+",_.totalInsertions]})," / ",h.jsxs("span",{className:"text-red-400 font-mono",children:["-",_.totalDeletions]})]}),_.source==="local"?h.jsx("div",{"data-testid":"rewind-source-hint",className:"mt-1 text-text-400 text-[11px]",children:"基于对话里 tool_result 估算(未读到 CC 快照,数字可能与实际磁盘略有差异)"}):null]}),_.files.map(k=>h.jsx(dte,{file:k},k.filePath))]}):h.jsxs("div",{"data-testid":"rewind-no-changes",className:"rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300 space-y-1",children:[h.jsx("div",{children:"磁盘上的文件已经和这个时刻的快照完全一致——没有需要回退的改动。"}),h.jsx("div",{className:"text-text-400 text-[11px]",children:"可能这条消息之后 Claude 没落盘编辑,或之前已经 rewind 过了。"})]}):h.jsx("div",{"data-testid":"rewind-no-anchor",className:"rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300",children:"未能在当前消息流中找到对应的用户消息(可能已被历史裁剪)。"})}),h.jsxs("div",{className:"flex flex-col gap-2 px-4 py-3 border-t border-bg-300/30 shrink-0",children:[S&&_.anchorFound&&!o?h.jsxs("div",{"data-testid":"rewind-needs-cc",className:"flex items-start gap-2 rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300",children:[h.jsx(nu,{className:"w-4 h-4 shrink-0 mt-0.5 text-warning"}),h.jsx("span",{children:'Claude Code 进程当前未运行。点击"确认回退"时会自动启动它再执行 — 可能需要等一两秒。'})]}):null,h.jsxs("div",{className:"flex items-center justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:()=>t(!1),className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),h.jsx("button",{type:"button",disabled:!C,onClick:()=>void y(),"data-testid":"rewind-apply",className:re("h-8 px-3 rounded-md text-[12px] font-medium transition-colors",C?"bg-accent text-white hover:bg-accent-hover cursor-pointer":"bg-bg-200 text-text-400 cursor-not-allowed"),children:m?"回退中…":"确认回退"})]})]})]})}function ute(e){return e.replace(/^\/Users\/[^/]+/,"~")}function dte({file:e}){const[t,n]=g.useState(!0);return h.jsxs("div",{"data-testid":"rewind-file-block","data-file":e.filePath,className:"rounded-md border border-bg-300 overflow-hidden bg-bg-0",children:[h.jsxs("button",{type:"button",onClick:()=>n(r=>!r),className:"w-full flex items-center gap-1.5 px-3 py-2 text-[12px] hover:bg-text-100/5 cursor-pointer",children:[t?h.jsx(Yn,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(Bn,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"font-mono text-text-200 truncate flex-1 text-left",title:e.filePath,children:ute(e.filePath)}),h.jsxs("span",{className:"font-mono shrink-0 text-text-400",children:[h.jsxs("span",{className:"text-green-500",children:["+",e.insertions]})," ",h.jsxs("span",{className:"text-red-400",children:["-",e.deletions]})]})]}),t?h.jsx("div",{className:"border-t border-bg-300",children:e.hunks.map(r=>h.jsx(hte,{hunk:r},`${r.oldStart}-${r.oldLines}-${r.newStart}-${r.newLines}`))}):null]})}function hte({hunk:e}){const t=`@@ -${e.oldStart},${e.oldLines} +${e.newStart},${e.newLines} @@`;return h.jsxs("div",{className:"text-[11px] font-mono leading-relaxed",children:[h.jsx("div",{className:"px-3 py-1 text-text-400 bg-bg-100/40 border-b border-bg-300",children:t}),e.lines.map((n,r)=>{const i=n.charAt(0),s=i==="+"?"bg-green-500/10 text-green-300":i==="-"?"bg-red-500/10 text-red-300":"text-text-300";return h.jsx("div",{className:re("px-3 whitespace-pre",s),children:n.length>0?n:" "},r)})]})}function fte({jobs:e}){return e.length===0?h.jsx("div",{"data-testid":"cron-job-list-empty",className:"px-4 py-3 text-sm text-text-500",children:"当前会话暂无活跃 cron 任务"}):h.jsx("ul",{"data-testid":"cron-job-list",className:"flex flex-col gap-2",children:e.map(t=>h.jsxs("li",{"data-testid":`cron-job-${t.id}`,className:"flex flex-col gap-1 rounded-md border border-border px-3 py-2",children:[h.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[h.jsx("span",{className:"font-mono text-text-300",children:t.id}),h.jsx("span",{className:"text-text-500",children:"·"}),h.jsx("span",{className:"text-text-400",children:t.humanSchedule}),t.recurring?h.jsx("span",{"data-testid":`cron-job-${t.id}-recurring-badge`,className:"ml-auto rounded-md bg-accent-dim px-2 py-0.5 text-accent",children:"recurring"}):null]}),h.jsx("div",{className:"text-sm text-text-200 truncate",title:t.prompt,children:t.prompt})]},t.id))})}const pte={idle:"还没启动","turn-running":"正在 run 中","turn-idle":"进程活着,等输入",exited:"进程已退出",crashed:"启动失败 / 异常退出"};function mte({sessionStatus:e}){switch(e){case"idle":return"idle";case"running":return"turn-running";case"running-idle":return"turn-idle";case"observing":return"turn-running";case"stopped":return"exited";case"error":return"crashed"}}function gte(e){return e==="running"||e==="observing"}function $M(e){return e==="running"||e==="running-idle"||e==="observing"}/**
541
+ ${t}`:t}function Yee(e){return nC.add(e),()=>nC.delete(e)}function Xee(e,t){return e.replace(/(^|\s)\/(\S+)/g,(n,r,i)=>{const s=t.find(o=>o.name===i&&o.path);return s!=null&&s.path?`${r}[skill:${i}:${s.path}]`:n})}function Qee({api:e,cwd:t,sessionKey:n,onSend:r,disabled:i,onNewSession:s,onClearSession:o,tool:a,spawnableContacts:l=Kee,ensureRemotePersonas:c,remotePersonasByDeviceId:u}){const d=eC(n),[f,p]=g.useState((d==null?void 0:d.draft)??""),[m,v]=g.useState(!1),w=g.useRef(null),x=g.useRef(!1),_=g.useCallback(()=>{x.current=!0},[]),y=g.useCallback(()=>{x.current=!1},[]),S=ap(),{attachments:C,setAttachments:k,addFiles:N,removeAttachment:T,clearAttachments:O}=Wee({httpBaseUrl:S.httpBaseUrl,httpToken:S.httpToken,sessionId:n,initial:(d==null?void 0:d.attachments)??[]}),[P,D]=g.useState([]),[R,A]=g.useState(!1),[M,L]=g.useState(0),[$,F]=g.useState(!1),[B,z]=g.useState([]),[E,H]=g.useState(!1),[q,j]=g.useState(0),[ne,ie]=g.useState(!1),[K,ge]=g.useState([]),[Pe,he]=g.useState(!1),[Ae,je]=g.useState(null),[$e,_e]=g.useState(!1),tt=g.useRef(null),Rt=g.useMemo(()=>{const se=[];return s&&se.push({name:"new",source:"builtin",description:"在当前目录下新建会话"}),o&&n&&se.push({name:"clear",source:"builtin",description:"清除当前会话"}),se},[s,o,n]),Xe=g.useMemo(()=>[...Rt,...P],[Rt,P]),ot=g.useMemo(()=>{const se=f.match(/^\/(\S*)$/);return se?se[1]:null},[f]),xn=ot!==null&&!$,ut=g.useMemo(()=>ot!==null?$M(Xe,ot):[],[Xe,ot]),Ct=g.useMemo(()=>{const se=f.match(/^@(\S*)$/);return se?se[1]:null},[f]),Ke=Ct!==null&&!ne,at=g.useMemo(()=>Ae?((u==null?void 0:u.get(Ae.deviceId))??[]).map(be=>({kind:"remote-persona",persona:be,deviceId:Ae.deviceId})):[...B.map(se=>({kind:"cc-agent",agent:se})),...K.map(se=>({kind:"persona",persona:se})),...l.map(se=>({kind:"contact",contact:se}))],[Ae,u,B,K,l]),Dt=g.useMemo(()=>Ct!==null?FM(at,Ct):[],[at,Ct]),Vt=g.useRef(f);g.useEffect(()=>{f!==Vt.current&&(F(!1),ie(!1),Vt.current=f)},[f]);const Tn=g.useCallback(()=>{F(!0)},[]),U=g.useCallback(()=>{ie(!0)},[]),J=g.useRef(f),ye=g.useRef(C);g.useEffect(()=>{J.current=f},[f]),g.useEffect(()=>{ye.current=C},[C]);const Ce=g.useRef(n);g.useEffect(()=>{if(n!==null)return Yee((se,be)=>{se===n&&(p(lt=>Gee(lt,be)),queueMicrotask(()=>ch(w.current)))})},[n]),g.useEffect(()=>{const se=Ce.current;if(se===n)return;tC(se,{draft:J.current,attachments:ye.current});const be=eC(n);p((be==null?void 0:be.draft)??""),k((be==null?void 0:be.attachments)??[]),L(0),j(0),F(!1),ie(!1),je(null),tt.current=null,_e(!1),queueMicrotask(()=>{be!=null&&be.draft?ch(w.current):aa(w.current)}),Ce.current=n},[n,k]),g.useEffect(()=>()=>{tC(Ce.current,{draft:J.current,attachments:ye.current})},[]),g.useEffect(()=>{L(0)},[ot]),g.useEffect(()=>{j(0)},[Ct]),g.useEffect(()=>{Ct===null&&Ae&&(je(null),tt.current=null,_e(!1))},[Ct,Ae]),g.useEffect(()=>{if(!xn||R)return;if(!e){A(!0);return}let se=!1;return(async()=>{try{const be=await e.skillsList(t,a);se||(D(be.skills??[]),A(!0))}catch{se||A(!0)}})(),()=>{se=!0}},[xn,R,e,t,a]),g.useEffect(()=>{if(!Ke||E)return;if(!e){H(!0);return}let se=!1;return(async()=>{try{const be=await e.agentsList(t,a);se||(z(be.agents??[]),H(!0))}catch{se||H(!0)}})(),()=>{se=!0}},[Ke,E,e,t,a]),g.useEffect(()=>{if(!Ke||Pe)return;if(!e){he(!0);return}let se=!1;return(async()=>{try{const be=await e.personaList();se||(ge((be.personas??[]).filter(lt=>lt.personaId!==UT).map(lt=>({personaId:lt.personaId,label:lt.label}))),he(!0))}catch{se||he(!0)}})(),()=>{se=!0}},[Ke,Pe,e]);const Fe=g.useCallback(se=>{switch(se.kind){case"persona":p(`@persona/${se.persona.personaId} `);break;case"cc-agent":p(`@"${se.agent.name} (agent)" `);break;case"contact":{const be=se.contact.deviceId;je({deviceId:be,displayName:se.contact.displayName}),tt.current=be,_e(!0),Promise.resolve(c==null?void 0:c(be)).finally(()=>{tt.current===be&&_e(!1)}),p("@"),ie(!1),setTimeout(()=>{var lt;return(lt=w.current)==null?void 0:lt.focus()},0);return}case"remote-persona":p(`@persona/${se.persona.personaId}@${se.deviceId} `),je(null);break}ie(!1),setTimeout(()=>{var be;return(be=w.current)==null?void 0:be.focus()},0)},[c]),xt=g.useCallback(()=>{je(null),tt.current=null,_e(!1),p("@"),setTimeout(()=>{var se;return(se=w.current)==null?void 0:se.focus()},0)},[]),un=g.useCallback(se=>{if(se.source==="builtin"&&se.name==="new"&&s){p(""),O(),aa(w.current),s(t);return}if(se.source==="builtin"&&se.name==="clear"&&o){p(""),O(),aa(w.current),o();return}p(`/${se.name} `),setTimeout(()=>{var be;return(be=w.current)==null?void 0:be.focus()},0)},[s,t,O,o]),qt=g.useCallback(async()=>{const se=f.trim(),be=C.filter(Mt=>Mt.status==="done");if(!se&&be.length===0||m||i)return;if(se==="/new"&&s){v(!0);try{await s(t),p(""),O(),aa(w.current)}finally{v(!1)}return}if(se==="/clear"&&o){v(!0);try{await o(),p(""),O(),aa(w.current)}finally{v(!1)}return}const lt=a==="codex"?Xee(se,P):se;v(!0);try{const Mt=VJ(lt,C);await r(Mt,{queueWhileRunning:!0}),p(""),O(),aa(w.current)}finally{v(!1)}},[f,C,m,i,r,s,t,O,o,a,P]),dn=g.useCallback(se=>{const{text:be,attachments:lt}=qee(se);if(p(be),lt.length>0){const Mt=new Set(ye.current.map(Pr=>Pr.id));k([...ye.current,...lt.filter(Pr=>!Mt.has(Pr.id))])}queueMicrotask(()=>ch(w.current))},[k]);return{draft:f,setDraft:p,sending:m,textareaRef:w,isComposingRef:x,onCompositionStart:_,onCompositionEnd:y,attachments:C,addFiles:N,removeAttachment:T,skillSelectorVisible:xn,filteredSkills:ut,slashQuery:ot??"",activeSkillIdx:M,setActiveSkillIdx:L,selectSkill:un,dismissSkillSelector:Tn,agentSelectorVisible:Ke,filteredAgents:Dt,mentionQuery:Ct,activeAgentIdx:q,setActiveAgentIdx:j,selectAgent:Fe,dismissAgentSelector:U,drilldown:Ae,drilldownLoading:$e,exitDrilldown:xt,doSend:qt,restoreTextToDraft:dn}}const Zee=120;function ch(e){e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,Zee)}px`)}function aa(e){e&&(e.style.height="auto")}function Jee({items:e,restoreDisabled:t,onRestore:n,onRemove:r}){return e.length===0?null:h.jsxs("div",{"data-testid":"chat-input-queue",className:"flex flex-col",children:[h.jsx("div",{className:"px-1 pb-1 text-[11px] text-text-400",children:`排队中 · ${e.length} 条(这一轮跑完连起来一起发出)`}),e.map((i,s)=>h.jsxs("div",{"data-testid":`chat-input-queue-item-${i.id}`,className:"flex items-center gap-2 rounded-md px-1 py-1 transition-colors hover:bg-text-100/5",children:[h.jsx("span",{className:"shrink-0 w-4 text-center text-[11px] text-text-400 tabular-nums",children:s+1}),h.jsx("button",{type:"button","data-testid":`chat-input-queue-restore-${i.id}`,disabled:t,title:t?"先清空输入框再取回这条":"取回输入框继续改",onClick:()=>n(i.id),className:"flex-1 min-w-0 text-left text-[12.5px] text-text-200 truncate hover:text-text-100 disabled:cursor-not-allowed disabled:hover:text-text-200",children:i.text.trim()||"(空消息)"}),h.jsx("button",{type:"button","aria-label":"移出队列","data-testid":`chat-input-queue-remove-${i.id}`,onClick:()=>r(i.id),className:"shrink-0 p-0.5 rounded text-text-400 hover:text-text-100 hover:bg-text-100/10",children:h.jsx(Ir,{className:"w-3.5 h-3.5"})})]},i.id))]})}const ete="[--color-border:#E6E6E6] [--bg-300:#E6E6E6] dark:[--color-border:#424242] dark:[--bg-300:#424242]",tte={spawnableContacts:[],ensureRemotePersonas:()=>Promise.resolve(),remotePersonasByDeviceId:new Map},nte=g.createContext(tte);function rte(){return g.useContext(nte)}function ite({url:e,fileName:t,onClose:n}){const[r,i]=g.useState(!1);g.useEffect(()=>{const o=a=>{a.key==="Escape"&&n()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[n]);const s=async()=>{try{const a=await(await fetch(e)).blob();await navigator.clipboard.write([new ClipboardItem({[a.type]:a})]),i(!0),setTimeout(()=>i(!1),2e3)}catch{rC(e,t)}};return h.jsx("div",{"data-testid":"image-lightbox",className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/60",onClick:n,role:"dialog","aria-modal":"true",children:h.jsxs("div",{className:"relative",onClick:o=>o.stopPropagation(),children:[h.jsx("img",{src:e,alt:t,className:"max-h-[90vh] max-w-[92vw] rounded-lg object-contain shadow-2xl"}),h.jsxs("div",{className:"absolute right-2 top-2 flex items-center gap-1.5",children:[h.jsxs("button",{type:"button",onClick:s,"data-testid":"image-lightbox-copy",className:"flex cursor-pointer items-center gap-1 rounded-full border border-bg-300 bg-bg-50/95 px-2 py-0.5 text-[11px] font-medium text-text-200 shadow transition-colors hover:bg-bg-100",children:[h.jsx(up,{className:"h-3 w-3"}),r?"Copied":"Copy"]}),h.jsxs("button",{type:"button",onClick:()=>rC(e,t),"data-testid":"image-lightbox-save",className:"flex cursor-pointer items-center gap-1 rounded-full border border-bg-300 bg-bg-50/95 px-2 py-0.5 text-[11px] font-medium text-text-200 shadow transition-colors hover:bg-bg-100",children:[h.jsx(V$,{className:"h-3.5 w-3.5"}),"Save"]}),h.jsx("button",{type:"button",onClick:n,"data-testid":"image-lightbox-close","aria-label":"close",className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded-full border border-bg-300 bg-bg-50/95 text-text-300 transition-colors hover:bg-bg-100 hover:text-text-100",children:h.jsx(Ir,{className:"h-3 w-3"})})]})]})})}function rC(e,t){const n=document.createElement("a");n.href=e,n.download=t||"image",n.click()}const iC=1e3,HM=`bg-bg-50 ${ete}`,sC=`mx-2 -mb-3 rounded-t-xl border border-b-0 border-border px-3 pt-2 pb-4 ${HM}`,ste=5e3;function Pd(e){if(!e)return"null";if(e===document.body)return"body";const t=e.getAttribute("data-testid"),n=typeof e.className=="string"&&e.className.trim()?`.${e.className.trim().split(/\s+/).slice(0,3).join(".")}`:"";return`${e.tagName.toLowerCase()}${e.id?`#${e.id}`:""}${t?`[${t}]`:""}${n}`}function ote({meta:e,api:t,cwd:n,tool:r,onSend:i,sessionKey:s,queued:o,onDequeue:a,disabled:l=!1,placeholder:c,className:u,awaitingUser:d=!1,onAbort:f,onNewSession:p,onClearSession:m,configSlot:v,aboveSlot:w}){const x=(e==null?void 0:e.streamInProgress)??!1,_=(e==null?void 0:e.contextPct)??null,y=_==null?"":_>=80?"text-red-400":_>=50?"text-amber-400":"text-text-500",S=g.useRef(null),C=rte(),k=Qee({...t?{api:t}:{},cwd:n,...r?{tool:r}:{},sessionKey:s,onSend:i,disabled:l,...p?{onNewSession:p}:{},...m?{onClearSession:m}:{},spawnableContacts:C.spawnableContacts,ensureRemotePersonas:C.ensureRemotePersonas,remotePersonasByDeviceId:C.remotePersonasByDeviceId}),{draft:N,setDraft:T,sending:O,textareaRef:P,attachments:D,addFiles:R,removeAttachment:A,skillSelectorVisible:M,filteredSkills:L,slashQuery:$,activeSkillIdx:F,setActiveSkillIdx:B,selectSkill:z,dismissSkillSelector:E,agentSelectorVisible:H,filteredAgents:q,mentionQuery:j,activeAgentIdx:ne,setActiveAgentIdx:ie,selectAgent:K,dismissAgentSelector:ge,drilldown:Pe,drilldownLoading:he,exitDrilldown:Ae,doSend:je,restoreTextToDraft:$e}=k,_e=g.useCallback(()=>{(async()=>{const ae=await(f==null?void 0:f());ae&&ae.length>0&&$e(Vee(ae,N))})()},[f,$e,N]),tt=g.useCallback(ae=>{const Ze=o==null?void 0:o.find(hn=>hn.id===ae);!Ze||!a||N.trim().length>0||(a(ae),$e(Ze.text))},[o,a,N,$e]),Rt=Tee();g.useEffect(()=>{if(!Rt||Rt.signal===0||s===null||Rt.sessionId!==s)return;const{signal:ae}=Rt;console.log("[chat-focus] 收到聚焦信号",{sessionKey:s,signal:ae,delayMs:iC,activeElement:Pd(document.activeElement)});let Ze=null,hn=null,Ys=null;const Ko=setTimeout(()=>{if(Ze=P.current,!Ze){console.warn("[chat-focus] textarea 已不在,放弃聚焦",{sessionKey:s,signal:ae});return}Ze.focus(),console.log("[chat-focus] focus() 已执行",{sessionKey:s,signal:ae,landed:document.activeElement===Ze,activeElement:Pd(document.activeElement)}),hn=Go=>{const Si=Pd(Go.relatedTarget);setTimeout(()=>{console.warn("[chat-focus] STOLEN 输入框失焦",{sessionKey:s,signal:ae,relatedTarget:Si,activeElementAfterTick:Pd(document.activeElement)})},0)},Ze.addEventListener("blur",hn,{once:!0}),Ys=setTimeout(()=>{Ze&&hn&&Ze.removeEventListener("blur",hn)},ste)},iC);return()=>{clearTimeout(Ko),Ys&&clearTimeout(Ys),Ze&&hn&&Ze.removeEventListener("blur",hn)}},[Rt==null?void 0:Rt.signal]);const Xe=!!t,ot=O||l||x,ut=(N.trim().length>0||D.some(ae=>ae.status==="done"))&&!l&&!O&&!d,Ct=c??(d?"Answer the question above first...":ot?"Queue a message...":`Message ${ny(r)}...`),Ke=g.useRef(!1),at=g.useCallback(()=>{Ke.current=!0},[]),Dt=g.useCallback(()=>{Ke.current=!1},[]),Vt=g.useCallback(ae=>{if(M&&L.length>0){if(ae.key==="ArrowDown")return ae.preventDefault(),B(F>=L.length-1?0:F+1),!0;if(ae.key==="ArrowUp")return ae.preventDefault(),B(F<=0?L.length-1:F-1),!0;if(ae.key==="Tab"||ae.key==="Enter"&&!ae.shiftKey){ae.preventDefault();const Ze=L[F];return Ze&&z(Ze),!0}if(ae.key==="Escape")return ae.preventDefault(),E(),!0}return!1},[M,L,F,B,z,E]),Tn=g.useCallback(ae=>{if(H&&q.length>0){if(ae.key==="ArrowDown")return ae.preventDefault(),ie(ne>=q.length-1?0:ne+1),!0;if(ae.key==="ArrowUp")return ae.preventDefault(),ie(ne<=0?q.length-1:ne-1),!0;if(ae.key==="Tab"||ae.key==="Enter"&&!ae.shiftKey){ae.preventDefault();const Ze=q[ne];return Ze&&K(Ze),!0}if(ae.key==="Escape")return ae.preventDefault(),Pe?Ae():ge(),!0}return!1},[H,q,ne,ie,K,ge,Pe,Ae]),U=g.useCallback(ae=>{const Ze=ae.nativeEvent;ae.key==="Enter"&&LR({compositionActive:Ke.current,nativeIsComposing:Ze.isComposing,keyCode:Ze.keyCode})||Vt(ae)||Tn(ae)||DR({key:ae.key,shiftKey:ae.shiftKey,compositionActive:Ke.current,nativeIsComposing:Ze.isComposing,keyCode:Ze.keyCode})&&(ae.preventDefault(),ut&&je())},[Vt,Tn,ut,je]),J=g.useCallback(ae=>{T(ae.target.value),ch(ae.target)},[T]),ye=g.useCallback(ae=>{ae.target.files&&R(ae.target.files),ae.target.value=""},[R]),Ce=g.useCallback(ae=>{if(!Xe)return;const Ze=Array.from(ae.clipboardData.items).map(hn=>hn.getAsFile()).filter(hn=>!!(hn&&hn.type.startsWith("image/")));Ze.length!==0&&(ae.preventDefault(),R(Ze))},[R,Xe]),[Fe,xt]=g.useState(null),un=g.useCallback(ae=>{ae.previewUrl&&xt({url:ae.previewUrl,name:ae.fileName})},[]),[qt,dn]=g.useState(!1),se=g.useCallback(ae=>{Xe&&(ae.preventDefault(),dn(!0))},[Xe]),be=g.useCallback(()=>dn(!1),[]),lt=g.useCallback(ae=>{Xe&&(ae.preventDefault(),dn(!1),ae.dataTransfer.files.length>0&&R(ae.dataTransfer.files))},[R,Xe]),Mt=x&&!d&&typeof f=="function",Pr=l||d;return h.jsxs("div",{"data-testid":"chat-input",className:re("shrink-0 border-t border-bg-300/20 px-4 py-3",u),onDragOver:se,onDragLeave:be,onDrop:lt,children:[h.jsxs("div",{className:"max-w-3xl mx-auto relative",children:[Xe?h.jsx("input",{ref:S,type:"file",multiple:!0,accept:Dee,hidden:!0,onChange:ye,"data-testid":"chat-input-file"}):null,h.jsxs("div",{"data-testid":"chat-input-bare",className:re("flex flex-col gap-2"),children:[d||O||x?h.jsxs("div",{"data-testid":"chat-input-status-bar",className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsxs("div",{className:"flex gap-1",children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"0ms"}}),h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"150ms"}}),h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"300ms"}})]}),h.jsx("span",{children:d?"Waiting for your answer":`${r==="codex"?"Codex":"Claude"} is working`})]}):null,M?h.jsx(Eee,{query:$,skills:L,activeIndex:F,onActiveIndexChange:B,onSelect:z}):null,H?Pe?!C.remotePersonasByDeviceId.has(Pe.deviceId)&&he?h.jsx("div",{"data-testid":"cc-agent-remote-loading",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 rounded-2xl border border-bg-300 bg-bg-50 px-4 py-3 text-[12px] text-text-300 shadow-lg",children:`正在加载 @${Pe.displayName} 的 persona…`}):q.length>0?h.jsx(Zk,{query:j??"",entries:q,activeIndex:ne,onActiveIndexChange:ie,onSelect:K}):h.jsx("div",{"data-testid":"cc-agent-remote-empty",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 rounded-2xl border border-bg-300 bg-bg-50 px-4 py-3 text-[12px] text-text-300 shadow-lg",children:`@${Pe.displayName} 暂无可派活的 persona(可能离线或未公开)`}):h.jsx(Zk,{query:j??"",entries:q,activeIndex:ne,onActiveIndexChange:ie,onSelect:K}):null,o&&o.length>0?h.jsx("div",{"data-testid":"chat-input-queue-header",className:sC,children:h.jsx(Jee,{items:o,restoreDisabled:N.trim().length>0||!a,onRestore:tt,onRemove:ae=>void(a==null?void 0:a(ae))})}):null,D.length>0?h.jsx(jee,{attachments:D,onRemove:A,onOpenPreview:un}):null,w?h.jsx("div",{"data-testid":"chat-input-above-slot",className:sC,children:w}):null,h.jsxs("div",{"data-testid":"bare-chat-input-frame",className:re("relative flex flex-col gap-1 rounded-xl border border-border px-3 py-2 transition-colors duration-200",HM,Pr?"opacity-60":null,qt?"border-accent/60 bg-accent/5":null),children:[h.jsx("textarea",{ref:P,"data-testid":"chat-input-textarea",value:N,onChange:J,onKeyDown:U,onCompositionStart:at,onCompositionEnd:Dt,onPaste:Ce,placeholder:Ct,disabled:Pr,readOnly:Pr,rows:1,className:"w-full resize-none bg-transparent border-0 outline-none text-[14px] text-text-100 placeholder:text-text-400 leading-relaxed py-1 min-h-[22px] max-h-[120px] overflow-y-auto disabled:cursor-not-allowed"}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[Xe?h.jsx("button",{type:"button",onClick:()=>{var ae;return(ae=S.current)==null?void 0:ae.click()},disabled:ot,"data-testid":"chat-input-attach","aria-label":"attach files",className:re("flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors",ot?"cursor-default text-text-400/50":"cursor-pointer text-text-400 hover:bg-text-100/5 hover:text-text-200"),children:h.jsx(b8,{className:"h-4 w-4"})}):null,h.jsx("div",{className:"flex-1 min-w-0"}),_!=null?h.jsxs("span",{"data-testid":"chat-input-ctx",className:re("shrink-0 text-[11px] tabular-nums",y),children:["ctx:",_,"%"]}):null,v,Mt?h.jsx("button",{type:"button",onClick:_e,"data-testid":"chat-input-abort","aria-label":"interrupt",title:"中断当前轮次(不杀进程)",className:"h-8 w-8 rounded-full flex items-center justify-center border border-text-400/40 text-text-400 hover:bg-text-100/5 hover:text-text-100 transition-colors cursor-pointer",children:h.jsx(SI,{className:"w-3.5 h-3.5",strokeWidth:2.5})}):null,h.jsx("button",{type:"button",onClick:()=>{ut&&je()},disabled:!ut,"data-testid":"chat-input-send","aria-label":"send",className:re("h-8 w-8 rounded-full flex items-center justify-center transition-colors",ut?"bg-accent text-white hover:bg-accent-hover cursor-pointer shadow-sm":"bg-[var(--text-400-dim)] text-[var(--text-400-dim-fg)] cursor-default"),children:h.jsx(b$,{className:"w-4 h-4",strokeWidth:2.5})})]})]})]})]}),Fe?h.jsx(ite,{url:Fe.url,fileName:Fe.name,onClose:()=>xt(null)}):null]})}function ate(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function lte({meta:e,tool:t,connState:n,variant:r="full",onOpenConfig:i,liveWorktreeRoot:s,ephemeral:o=!1,onPromote:a,className:l}){const c=s??e.cwd??"",d=!!e.sessionLabel&&e.sessionLabel!==e.sessionId?e.sessionLabel:ate(c),f=c;return r==="quickask"?h.jsxs("div",{"data-testid":"chat-header","data-variant":"quickask",className:re("flex items-center shrink-0 px-3 py-2 gap-2",l),children:[a?h.jsx("button",{type:"button","data-testid":"chat-header-promote","data-promoted":o?"false":"true",disabled:!o,onClick:a,title:o?"保留为正式会话":"已保留为正式会话",className:re("shrink-0 inline-flex items-center justify-center h-5 w-5 rounded-md transition-colors",o?"text-text-500 hover:text-text-200 hover:bg-text-100/5 cursor-pointer":"text-amber-400"),children:h.jsx(T$,{className:re("w-3.5 h-3.5",!o&&"fill-current")})}):null,h.jsx("span",{className:"font-semibold text-text-100 truncate text-[13px]","data-testid":"chat-header-worktree",title:f,children:d})]}):h.jsxs("div",{"data-testid":"chat-header","data-variant":"full",className:re("relative flex items-center shrink-0 px-4 pr-[4.5rem] md:pr-4 py-2.5",l),children:[h.jsx("span",{className:"font-semibold text-text-100 truncate text-[13px]","data-testid":"chat-header-worktree",title:f,children:d}),h.jsx("div",{className:"absolute right-4 top-1/2 -translate-y-1/2 z-10 flex items-center gap-1",children:i?h.jsx("button",{type:"button","aria-label":"Session settings","data-testid":"chat-header-settings-mobile",onClick:i,title:"Session settings",className:"flex md:hidden h-7 w-7 items-center justify-center rounded-md bg-transparent text-text-300 transition-colors duration-150 hover:bg-bg-200 hover:text-text-100 cursor-pointer outline-none",children:h.jsx(yI,{className:"w-4 h-4"})}):null})]})}function cte({testid:e,children:t}){return h.jsx("div",{"data-testid":e,className:"h-full min-w-0 border-l border-border bg-bg-100 flex flex-col",children:t})}function ute({title:e,onBack:t,onCollapse:n,collapseLabel:r="collapse session info",collapseTitle:i="收起会话信息"}){const s=o=>h.jsx("button",{type:"button","data-testid":"session-info-collapse",onClick:n,"aria-label":r,title:i,className:`p-1 rounded text-text-400 hover:text-text-100 hover:bg-text-100/10 ${o}`,children:h.jsx(Ww,{className:"w-4 h-4"})});return h.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b border-border shrink-0",children:[t?h.jsx("button",{type:"button","data-testid":"session-info-back",onClick:t,"aria-label":"返回会话信息",className:"p-1 -ml-1 rounded text-text-400 hover:text-text-100 hover:bg-text-100/10",children:h.jsx(_$,{className:"w-4 h-4"})}):n?s("-ml-1"):h.jsx(Ww,{className:"w-4 h-4 text-text-300"}),h.jsx("span",{className:"flex-1 text-[13px] font-medium text-text-100 truncate",children:e}),t&&n?s(""):null]})}function cg({icon:e,label:t,meta:n,active:r,onClick:i,testid:s}){return h.jsxs("button",{type:"button","data-testid":s,onClick:i,"aria-current":r?"true":void 0,className:`w-full flex items-center gap-2.5 px-2 py-1.5 rounded-md cursor-pointer text-left ${r?"bg-text-100/10":"hover:bg-text-100/5"}`,children:[h.jsx("span",{className:"w-4 h-4 shrink-0 text-text-300 inline-flex items-center justify-center",children:e}),h.jsx("span",{className:"flex-1 text-[12.5px] text-text-100",children:t}),n?h.jsx("span",{className:"shrink-0 text-[11px] text-text-400 font-mono",children:n}):null]})}let dte=null;function hte(){return dte}function oc({label:e,labelTitle:t,children:n}){return h.jsxs("div",{className:"flex items-start gap-2 px-2 py-1",children:[h.jsx("span",{className:"w-14 shrink-0 truncate text-[11px] text-text-400 pt-0.5",...t?{title:t}:{},children:e}),h.jsx("span",{className:"flex-1 min-w-0 text-[12px] text-text-100",children:n})]})}function oC({label:e,labelTitle:t,value:n,testid:r}){const[i,s]=g.useState(!1),o=g.useRef(null);g.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]);const a=()=>{typeof navigator>"u"||!navigator.clipboard||navigator.clipboard.writeText(n).then(()=>{s(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>s(!1),2e3)},()=>{})};return h.jsx(oc,{label:e,labelTitle:t,children:h.jsxs("button",{type:"button",onClick:a,"data-testid":r,title:i?"已复制":`复制:${n}`,className:"w-full flex items-center gap-1.5 text-left group cursor-pointer",children:[h.jsx("span",{className:"font-mono text-[11px] text-text-300 truncate flex-1 min-w-0",children:n}),i?h.jsx(wl,{className:"w-3 h-3 shrink-0 text-accent"}):h.jsx(up,{className:"w-3 h-3 shrink-0 text-text-400 opacity-0 group-hover:opacity-100 transition-opacity"})]})})}function fte({session:e,meta:t,liveGitBranch:n,liveWorktreeRoot:r,personaName:i,onOpenPersona:s,onOpenFiles:o,cronActiveCount:a,onCronClick:l,onForceStop:c,viewerRole:u="owner",toolSessionIdLabel:d="tool session id",drill:f=null,onCollapse:p}){const m=n!==void 0?n:t.gitBranch??null,v=t.procAlive??!1,w=VI(e),x=w!=null&&e.originOwnerPrincipalId==null&&u!=="guest",[_,y]=g.useState(null),S=g.useRef(null);g.useEffect(()=>()=>{S.current&&clearTimeout(S.current)},[]);const C=async()=>{if(!x)return;const k=hte();let N;try{k||(await navigator.clipboard.writeText(w),N="命令已复制")}catch{N="操作失败"}y(N),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>y(null),2500)};return h.jsxs(cte,{testid:"session-info-panel",children:[h.jsx(ute,{title:f?f.title:"会话信息",...f?{onBack:f.onBack}:{},...p?{onCollapse:p}:{}}),f?h.jsx("div",{"data-testid":"session-info-drill",className:"flex-1 min-h-0 overflow-y-auto",children:f.content}):h.jsxs("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:[m?h.jsx(oc,{label:"分支",children:h.jsxs("span",{"data-testid":"session-info-branch",className:"inline-flex items-center gap-1 font-mono text-[11.5px] min-w-0",title:r??void 0,children:[h.jsx(Q_,{className:"w-3 h-3 shrink-0 text-text-400"}),h.jsx("span",{className:"truncate",children:m})]})}):null,i&&s?h.jsx(oc,{label:"persona",children:h.jsxs("button",{type:"button","data-testid":"session-info-persona",onClick:s,className:"inline-flex items-center gap-1 hover:text-accent cursor-pointer",children:[h.jsx(NI,{className:"w-3 h-3"}),h.jsx("span",{className:"truncate",children:i})]})}):null,h.jsx(oc,{label:"引擎",children:h.jsxs("span",{className:"inline-flex items-center gap-1.5","data-testid":"session-info-engine",children:[h.jsx(dp,{tool:e.tool,className:re("w-3.5 h-3.5 shrink-0",hp(e.tool))}),h.jsxs("span",{className:"truncate",children:[ny(e.tool),t.model?` · ${t.model}`:""]})]})}),h.jsx(oc,{label:"cwd",children:h.jsx("span",{"data-testid":"session-info-cwd",className:"font-mono text-[11px] text-text-300 truncate block",title:e.cwd,children:e.cwd})}),h.jsx(oC,{label:"session id",value:e.sessionId,testid:"session-info-session-id"}),e.toolSessionId?h.jsx(oC,{label:`${e.tool||"claude"} id`,labelTitle:d,value:e.toolSessionId,testid:"session-info-tool-session-id"}):null,h.jsx("div",{className:"my-2 border-t border-border"}),o?h.jsx(cg,{icon:h.jsx(Z$,{className:"w-3.5 h-3.5"}),label:"Edited Files",onClick:o,testid:"session-info-files"}):null,a&&a>0&&l?h.jsx(cg,{icon:h.jsx($$,{className:"w-3.5 h-3.5"}),label:"定时任务",meta:String(a),onClick:l,testid:"session-info-cron"}):null,x?h.jsx(cg,{icon:h.jsx(K8,{className:"w-3.5 h-3.5"}),label:"终端",meta:_,onClick:()=>void C(),testid:"session-info-terminal"}):null]}),v&&c?h.jsx("div",{className:"shrink-0 border-t border-border px-3 py-2.5",children:h.jsxs("button",{type:"button","data-testid":"session-info-force-stop",onClick:c,title:e.tool==="codex"?"强制停止 Codex 进程":"强制停止 Claude Code 进程(会丢失 initialize / 预热缓存)",className:"inline-flex items-center gap-1.5 h-6 px-2.5 rounded-md text-text-400 hover:bg-red-500/10 hover:text-red-400 transition-colors text-[12px] cursor-pointer",children:[h.jsx(x8,{className:"w-3.5 h-3.5"}),h.jsx("span",{children:"强制停止"})]})}):null]})}const pte=g.createContext({container:null});function mte(){return g.useContext(pte)}const n1="fixed top-0 md:top-10 bottom-0 right-0";function gte({api:e,cwd:t,toolSessionId:n,toolKind:r="claude"}){const i=DM(),s=(i==null?void 0:i.state.agentId)??null,o=i==null?void 0:i.state.agentType,[a,l]=g.useState([]),[c,u]=g.useState(!1),[d,f]=g.useState(null);g.useEffect(()=>{if(!s)return;let m=!1;return u(!0),f(null),l([]),e.historySubagentRead({cwd:t,toolSessionId:n,subagentId:s}).then(v=>{m||l(v.messages??[])}).catch(v=>{m||f(v instanceof Error?v.message:String(v))}).finally(()=>{m||u(!1)}),()=>{m=!0}},[s,t,n,e]);const p=g.useMemo(()=>a.length>0?f5(a,0,r):[],[a,r]);return!i||!s?null:h.jsxs("div",{"data-testid":"subagent-drawer","data-agent-id":s,className:re(n1,"z-50 w-[min(560px,92vw)]","flex flex-col border-l border-bg-200/60 bg-bg-50 shadow-xl"),style:{paddingTop:"env(safe-area-inset-top)"},children:[h.jsxs("div",{className:"flex flex-col gap-0.5 px-3 py-2 border-b border-bg-200/60",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o?h.jsx("span",{className:"inline-flex items-center rounded-sm bg-violet-500/10 px-1.5 py-0.5 text-[11px] text-violet-400 font-medium",children:o}):null,h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate",title:s,children:s})]}),h.jsx("button",{type:"button","aria-label":"关闭",onClick:()=>i.close(),className:"p-1 rounded hover:bg-bg-200/50 text-text-400 hover:text-text-200",children:h.jsx(Ir,{className:"w-4 h-4"})})]}),!c&&!d&&a.length>0?h.jsxs("div",{className:"text-[11px] text-text-400",children:[a.length," 条消息 · 首条为主会话派发的任务指令"]}):null]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden px-3 py-2",children:c?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(Ln,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"加载中…"})]}):d?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-error",children:[h.jsx(Qi,{className:"w-3.5 h-3.5"}),h.jsx("span",{children:d})]}):p.length===0?h.jsx("div",{className:"text-[12px] text-text-400 italic",children:"无消息"}):h.jsx(zM,{lines:p})})]})}function aC(e,t){let n=0;for(const r of e.lines)r.startsWith(t)&&n++;return n}function vte(e,t){const n=e.findIndex(c=>c.kind==="user-text"&&c.uuid===t);if(n<0)return{userMessageId:t,files:[],totalInsertions:0,totalDeletions:0,anchorFound:!1};let r=e.length;for(let c=n+1;c<e.length;c++)if(e[c].kind==="user-text"){r=c;break}const i=[],s=new Map;for(let c=n+1;c<r;c++){const u=e[c];if(u.kind!=="tool-result")continue;const d=u.toolResultExtra;if(!(d!=null&&d.filePath)||!d.structuredPatch||d.structuredPatch.length===0)continue;const f=d.filePath;let p=s.get(f);p||(p={filePath:f,hunks:[],insertions:0,deletions:0},s.set(f,p),i.push(f));for(const m of d.structuredPatch)p.hunks.push(m),p.insertions+=aC(m,"+"),p.deletions+=aC(m,"-")}const o=i.map(c=>s.get(c)),a=o.reduce((c,u)=>c+u.insertions,0),l=o.reduce((c,u)=>c+u.deletions,0);return{userMessageId:t,files:o,totalInsertions:a,totalDeletions:l,anchorFound:!0}}function xte({open:e,onOpenChange:t,api:n,sessionId:r,userMessageId:i,lines:s,procAlive:o,onApplied:a,onNoChanges:l}){const c=g.useMemo(()=>vte(s,i),[s,i]),[u,d]=g.useState(null),[f,p]=g.useState(!1),[m,v]=g.useState(!1),[w,x]=g.useState(null);g.useEffect(()=>{if(!e)return;let k=!1;return p(!0),d(null),(async()=>{try{const N=await n.sessionRewindDiff({sessionId:r,userMessageId:i});k||(d(N),!N.canRewind&&!N.error&&N.files.length===0&&(l==null||l(i)))}catch{k||d(null)}finally{k||p(!1)}})(),()=>{k=!0}},[e,n,r,i]);const _=g.useMemo(()=>{if(u){const k=!u.canRewind&&!u.error&&u.files.length===0;if(u.canRewind||k)return{source:"rpc",anchorFound:!0,files:u.files.map(N=>({filePath:N.filePath,hunks:N.hunks,insertions:N.insertions,deletions:N.deletions})),totalInsertions:u.totalInsertions,totalDeletions:u.totalDeletions}}return{source:"local",anchorFound:c.anchorFound,files:c.files,totalInsertions:c.totalInsertions,totalDeletions:c.totalDeletions,rpcError:u==null?void 0:u.error}},[u,c]),y=g.useCallback(async()=>{v(!0),x(null);try{const k=await n.sessionRewind({sessionId:r,userMessageId:i,dryRun:!1});if(!k.canRewind){x(k.error??"回退失败");return}a==null||a(),t(!1)}catch(k){x(k.message||"回退失败")}finally{v(!1)}},[n,r,i,a,t]);if(!e)return null;const S=_.files.length>0,C=!f&&!m&&_.anchorFound&&S&&!w;return h.jsxs("div",{"data-testid":"rewind-preview-drawer",className:`${n1} z-40 flex flex-col border-l border-bg-300/40 bg-bg-0 shadow-xl`,style:{width:480,minWidth:480},children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bg-300/30 shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(EI,{className:"w-4 h-4 text-text-300"}),h.jsx("span",{className:"text-[14px] font-semibold text-text-100",children:"Rewind 预览"})]}),h.jsx("button",{type:"button",onClick:()=>t(!1),"data-testid":"rewind-drawer-close",className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:bg-text-100/5 hover:text-text-200 cursor-pointer","aria-label":"close",children:h.jsx(Ir,{className:"w-4 h-4"})})]}),w?h.jsxs("div",{"data-testid":"rewind-error-banner",className:"mx-4 mt-3 flex items-start gap-2 rounded-md border border-red-400/40 bg-red-500/10 px-3 py-2 text-[12px] text-red-400",children:[h.jsx(nu,{className:"w-4 h-4 shrink-0 mt-0.5"}),h.jsx("span",{children:w})]}):null,h.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-3",children:f?h.jsxs("div",{"data-testid":"rewind-loading",className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(Ln,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"正在读取快照…"})]}):_.anchorFound?S?h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":"rewind-summary",className:"rounded-md border border-bg-300 bg-bg-100/40 px-3 py-2 text-[12px] text-text-200",children:[h.jsxs("div",{children:["将回退 ",h.jsx("span",{className:"font-semibold text-text-100",children:_.files.length})," ","个文件,",h.jsxs("span",{className:"text-green-500 font-mono",children:["+",_.totalInsertions]})," / ",h.jsxs("span",{className:"text-red-400 font-mono",children:["-",_.totalDeletions]})]}),_.source==="local"?h.jsx("div",{"data-testid":"rewind-source-hint",className:"mt-1 text-text-400 text-[11px]",children:"基于对话里 tool_result 估算(未读到 CC 快照,数字可能与实际磁盘略有差异)"}):null]}),_.files.map(k=>h.jsx(yte,{file:k},k.filePath))]}):h.jsxs("div",{"data-testid":"rewind-no-changes",className:"rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300 space-y-1",children:[h.jsx("div",{children:"磁盘上的文件已经和这个时刻的快照完全一致——没有需要回退的改动。"}),h.jsx("div",{className:"text-text-400 text-[11px]",children:"可能这条消息之后 Claude 没落盘编辑,或之前已经 rewind 过了。"})]}):h.jsx("div",{"data-testid":"rewind-no-anchor",className:"rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300",children:"未能在当前消息流中找到对应的用户消息(可能已被历史裁剪)。"})}),h.jsxs("div",{className:"flex flex-col gap-2 px-4 py-3 border-t border-bg-300/30 shrink-0",children:[S&&_.anchorFound&&!o?h.jsxs("div",{"data-testid":"rewind-needs-cc",className:"flex items-start gap-2 rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300",children:[h.jsx(nu,{className:"w-4 h-4 shrink-0 mt-0.5 text-warning"}),h.jsx("span",{children:'Claude Code 进程当前未运行。点击"确认回退"时会自动启动它再执行 — 可能需要等一两秒。'})]}):null,h.jsxs("div",{className:"flex items-center justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:()=>t(!1),className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),h.jsx("button",{type:"button",disabled:!C,onClick:()=>void y(),"data-testid":"rewind-apply",className:re("h-8 px-3 rounded-md text-[12px] font-medium transition-colors",C?"bg-accent text-white hover:bg-accent-hover cursor-pointer":"bg-bg-200 text-text-400 cursor-not-allowed"),children:m?"回退中…":"确认回退"})]})]})]})}function _te(e){return e.replace(/^\/Users\/[^/]+/,"~")}function yte({file:e}){const[t,n]=g.useState(!0);return h.jsxs("div",{"data-testid":"rewind-file-block","data-file":e.filePath,className:"rounded-md border border-bg-300 overflow-hidden bg-bg-0",children:[h.jsxs("button",{type:"button",onClick:()=>n(r=>!r),className:"w-full flex items-center gap-1.5 px-3 py-2 text-[12px] hover:bg-text-100/5 cursor-pointer",children:[t?h.jsx(Yn,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(Bn,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"font-mono text-text-200 truncate flex-1 text-left",title:e.filePath,children:_te(e.filePath)}),h.jsxs("span",{className:"font-mono shrink-0 text-text-400",children:[h.jsxs("span",{className:"text-green-500",children:["+",e.insertions]})," ",h.jsxs("span",{className:"text-red-400",children:["-",e.deletions]})]})]}),t?h.jsx("div",{className:"border-t border-bg-300",children:e.hunks.map(r=>h.jsx(bte,{hunk:r},`${r.oldStart}-${r.oldLines}-${r.newStart}-${r.newLines}`))}):null]})}function bte({hunk:e}){const t=`@@ -${e.oldStart},${e.oldLines} +${e.newStart},${e.newLines} @@`;return h.jsxs("div",{className:"text-[11px] font-mono leading-relaxed",children:[h.jsx("div",{className:"px-3 py-1 text-text-400 bg-bg-100/40 border-b border-bg-300",children:t}),e.lines.map((n,r)=>{const i=n.charAt(0),s=i==="+"?"bg-green-500/10 text-green-300":i==="-"?"bg-red-500/10 text-red-300":"text-text-300";return h.jsx("div",{className:re("px-3 whitespace-pre",s),children:n.length>0?n:" "},r)})]})}function wte({jobs:e}){return e.length===0?h.jsx("div",{"data-testid":"cron-job-list-empty",className:"px-4 py-3 text-sm text-text-500",children:"当前会话暂无活跃 cron 任务"}):h.jsx("ul",{"data-testid":"cron-job-list",className:"flex flex-col gap-2",children:e.map(t=>h.jsxs("li",{"data-testid":`cron-job-${t.id}`,className:"flex flex-col gap-1 rounded-md border border-border px-3 py-2",children:[h.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[h.jsx("span",{className:"font-mono text-text-300",children:t.id}),h.jsx("span",{className:"text-text-500",children:"·"}),h.jsx("span",{className:"text-text-400",children:t.humanSchedule}),t.recurring?h.jsx("span",{"data-testid":`cron-job-${t.id}-recurring-badge`,className:"ml-auto rounded-md bg-accent-dim px-2 py-0.5 text-accent",children:"recurring"}):null]}),h.jsx("div",{className:"text-sm text-text-200 truncate",title:t.prompt,children:t.prompt})]},t.id))})}const Ste={idle:"还没启动","turn-running":"正在 run 中","turn-idle":"进程活着,等输入",exited:"进程已退出",crashed:"启动失败 / 异常退出"};function kte({sessionStatus:e}){switch(e){case"idle":return"idle";case"running":return"turn-running";case"running-idle":return"turn-idle";case"observing":return"turn-running";case"stopped":return"exited";case"error":return"crashed"}}/**
542
542
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
543
543
  * @license MIT
544
544
  *
@@ -549,21 +549,21 @@ ${t}`:t}function jee(e){return Jk.add(e),()=>Jk.delete(e)}function Lee(e,t){retu
549
549
  * Fabrice Bellard's javascript vt100 for jslinux:
550
550
  * http://bellard.org/jslinux/
551
551
  * Copyright (c) 2011 Fabrice Bellard
552
- */var FM=Object.defineProperty,vte=Object.getOwnPropertyDescriptor,xte=(e,t)=>{for(var n in t)FM(e,n,{get:t[n],enumerable:!0})},Pt=(e,t,n,r)=>{for(var i=r>1?void 0:r?vte(t,n):t,s=e.length-1,o;s>=0;s--)(o=e[s])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&FM(t,n,i),i},le=(e,t)=>(n,r)=>t(n,r,e),oC="Terminal input",q0={get:()=>oC,set:e=>oC=e},aC="Too much output to announce, navigate to rows manually to read",K0={get:()=>aC,set:e=>aC=e};function _te(e){return e.replace(/\r?\n/g,"\r")}function yte(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function bte(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function wte(e,t,n,r){if(e.stopPropagation(),e.clipboardData){let i=e.clipboardData.getData("text/plain");HM(i,t,n,r)}}function HM(e,t,n,r){e=_te(e),e=yte(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function UM(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,s=e.clientY-r.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${i}px`,t.style.top=`${s}px`,t.style.zIndex="1000",t.focus()}function lC(e,t,n,r,i){UM(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function gs(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Dp(e,t=0,n=e.length){let r="";for(let i=t;i<n;++i){let s=e[i];s>65535?(s-=65536,r+=String.fromCharCode((s>>10)+55296)+String.fromCharCode(s%1024+56320)):r+=String.fromCharCode(s)}return r}var Ste=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let s=e.charCodeAt(i++);56320<=s&&s<=57343?t[r++]=(this._interim-55296)*1024+s-56320+65536:(t[r++]=this._interim,t[r++]=s),this._interim=0}for(let s=i;s<n;++s){let o=e.charCodeAt(s);if(55296<=o&&o<=56319){if(++s>=n)return this._interim=o,r;let a=e.charCodeAt(s);56320<=a&&a<=57343?t[r++]=(o-55296)*1024+a-56320+65536:(t[r++]=o,t[r++]=a);continue}o!==65279&&(t[r++]=o)}return r}},kte=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,s,o,a,l=0,c=0;if(this.interim[0]){let f=!1,p=this.interim[0];p&=(p&224)===192?31:(p&240)===224?15:7;let m=0,v;for(;(v=this.interim[++m]&63)&&m<4;)p<<=6,p|=v;let w=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,x=w-m;for(;c<x;){if(c>=n)return 0;if(v=e[c++],(v&192)!==128){c--,f=!0;break}else this.interim[m++]=v,p<<=6,p|=v&63}f||(w===2?p<128?c--:t[r++]=p:w===3?p<2048||p>=55296&&p<=57343||p===65279||(t[r++]=p):p<65536||p>1114111||(t[r++]=p)),this.interim.fill(0)}let u=n-4,d=c;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((s=e[d+1])&128)&&!((o=e[d+2])&128)&&!((a=e[d+3])&128);)t[r++]=i,t[r++]=s,t[r++]=o,t[r++]=a,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)===192){if(d>=n)return this.interim[0]=i,r;if(s=e[d++],(s&192)!==128){d--;continue}if(l=(i&31)<<6|s&63,l<128){d--;continue}t[r++]=l}else if((i&240)===224){if(d>=n)return this.interim[0]=i,r;if(s=e[d++],(s&192)!==128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=s,r;if(o=e[d++],(o&192)!==128){d--;continue}if(l=(i&15)<<12|(s&63)<<6|o&63,l<2048||l>=55296&&l<=57343||l===65279)continue;t[r++]=l}else if((i&248)===240){if(d>=n)return this.interim[0]=i,r;if(s=e[d++],(s&192)!==128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=s,r;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=s,this.interim[2]=o,r;if(a=e[d++],(a&192)!==128){d--;continue}if(l=(i&7)<<18|(s&63)<<12|(o&63)<<6|a&63,l<65536||l>1114111)continue;t[r++]=l}}return r}},WM="",Ss=" ",Du=class VM{constructor(){this.fg=0,this.bg=0,this.extended=new xf}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new VM;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},xf=class qM{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new qM(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},wr=class KM extends Du{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new xf,this.combinedData=""}static fromCharData(t){let n=new KM;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?gs(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let r=t[1].charCodeAt(0);if(55296<=r&&r<=56319){let i=t[1].charCodeAt(1);56320<=i&&i<=57343?this.content=(r-55296)*1024+i-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},cC="di$target",G0="di$dependencies",ug=new Map;function Cte(e){return e[G0]||[]}function cn(e){if(ug.has(e))return ug.get(e);let t=function(n,r,i){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Ete(t,n,i)};return t._id=e,ug.set(e,t),t}function Ete(e,t,n){t[cC]===t?t[G0].push({id:e,index:n}):(t[G0]=[{id:e,index:n}],t[cC]=t)}var zn=cn("BufferService"),GM=cn("CoreMouseService"),qo=cn("CoreService"),Nte=cn("CharsetService"),r1=cn("InstantiationService"),YM=cn("LogService"),$n=cn("OptionsService"),XM=cn("OscLinkService"),Tte=cn("UnicodeService"),Ou=cn("DecorationService"),Y0=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var u;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,s=new wr,o=n.getTrimmedLength(),a=-1,l=-1,c=!1;for(let d=0;d<o;d++)if(!(l===-1&&!n.hasContent(d))){if(n.loadCell(d,s),s.hasExtendedAttrs()&&s.extended.urlId)if(l===-1){l=d,a=s.extended.urlId;continue}else c=s.extended.urlId!==a;else l!==-1&&(c=!0);if(c||l!==-1&&d===o-1){let f=(u=this._oscLinkService.getLinkData(a))==null?void 0:u.uri;if(f){let p={start:{x:l+1,y:e},end:{x:d+(!c&&d===o-1?1:0),y:e}},m=!1;if(!(i!=null&&i.allowNonHttpProtocols))try{let v=new URL(f);["http:","https:"].includes(v.protocol)||(m=!0)}catch{m=!0}m||r.push({text:f,range:p,activate:(v,w)=>i?i.activate(v,w,p):Ite(v,w),hover:(v,w)=>{var x;return(x=i==null?void 0:i.hover)==null?void 0:x.call(i,v,w,p)},leave:(v,w)=>{var x;return(x=i==null?void 0:i.leave)==null?void 0:x.call(i,v,w,p)}})}c=!1,s.hasExtendedAttrs()&&s.extended.urlId?(l=d,a=s.extended.urlId):(l=-1,a=-1)}}t(r)}};Y0=Pt([le(0,zn),le(1,$n),le(2,XM)],Y0);function Ite(e,t){if(confirm(`Do you want to navigate to ${t}?
552
+ */var UM=Object.defineProperty,Cte=Object.getOwnPropertyDescriptor,Ete=(e,t)=>{for(var n in t)UM(e,n,{get:t[n],enumerable:!0})},Pt=(e,t,n,r)=>{for(var i=r>1?void 0:r?Cte(t,n):t,s=e.length-1,o;s>=0;s--)(o=e[s])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&UM(t,n,i),i},le=(e,t)=>(n,r)=>t(n,r,e),lC="Terminal input",q0={get:()=>lC,set:e=>lC=e},cC="Too much output to announce, navigate to rows manually to read",K0={get:()=>cC,set:e=>cC=e};function Nte(e){return e.replace(/\r?\n/g,"\r")}function Tte(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Ite(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Pte(e,t,n,r){if(e.stopPropagation(),e.clipboardData){let i=e.clipboardData.getData("text/plain");WM(i,t,n,r)}}function WM(e,t,n,r){e=Nte(e),e=Tte(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function VM(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,s=e.clientY-r.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${i}px`,t.style.top=`${s}px`,t.style.zIndex="1000",t.focus()}function uC(e,t,n,r,i){VM(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function gs(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Dp(e,t=0,n=e.length){let r="";for(let i=t;i<n;++i){let s=e[i];s>65535?(s-=65536,r+=String.fromCharCode((s>>10)+55296)+String.fromCharCode(s%1024+56320)):r+=String.fromCharCode(s)}return r}var Rte=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let s=e.charCodeAt(i++);56320<=s&&s<=57343?t[r++]=(this._interim-55296)*1024+s-56320+65536:(t[r++]=this._interim,t[r++]=s),this._interim=0}for(let s=i;s<n;++s){let o=e.charCodeAt(s);if(55296<=o&&o<=56319){if(++s>=n)return this._interim=o,r;let a=e.charCodeAt(s);56320<=a&&a<=57343?t[r++]=(o-55296)*1024+a-56320+65536:(t[r++]=o,t[r++]=a);continue}o!==65279&&(t[r++]=o)}return r}},Mte=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,s,o,a,l=0,c=0;if(this.interim[0]){let f=!1,p=this.interim[0];p&=(p&224)===192?31:(p&240)===224?15:7;let m=0,v;for(;(v=this.interim[++m]&63)&&m<4;)p<<=6,p|=v;let w=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,x=w-m;for(;c<x;){if(c>=n)return 0;if(v=e[c++],(v&192)!==128){c--,f=!0;break}else this.interim[m++]=v,p<<=6,p|=v&63}f||(w===2?p<128?c--:t[r++]=p:w===3?p<2048||p>=55296&&p<=57343||p===65279||(t[r++]=p):p<65536||p>1114111||(t[r++]=p)),this.interim.fill(0)}let u=n-4,d=c;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((s=e[d+1])&128)&&!((o=e[d+2])&128)&&!((a=e[d+3])&128);)t[r++]=i,t[r++]=s,t[r++]=o,t[r++]=a,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)===192){if(d>=n)return this.interim[0]=i,r;if(s=e[d++],(s&192)!==128){d--;continue}if(l=(i&31)<<6|s&63,l<128){d--;continue}t[r++]=l}else if((i&240)===224){if(d>=n)return this.interim[0]=i,r;if(s=e[d++],(s&192)!==128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=s,r;if(o=e[d++],(o&192)!==128){d--;continue}if(l=(i&15)<<12|(s&63)<<6|o&63,l<2048||l>=55296&&l<=57343||l===65279)continue;t[r++]=l}else if((i&248)===240){if(d>=n)return this.interim[0]=i,r;if(s=e[d++],(s&192)!==128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=s,r;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=s,this.interim[2]=o,r;if(a=e[d++],(a&192)!==128){d--;continue}if(l=(i&7)<<18|(s&63)<<12|(o&63)<<6|a&63,l<65536||l>1114111)continue;t[r++]=l}}return r}},qM="",Ss=" ",Du=class KM{constructor(){this.fg=0,this.bg=0,this.extended=new xf}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new KM;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},xf=class GM{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new GM(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},wr=class YM extends Du{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new xf,this.combinedData=""}static fromCharData(t){let n=new YM;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?gs(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let r=t[1].charCodeAt(0);if(55296<=r&&r<=56319){let i=t[1].charCodeAt(1);56320<=i&&i<=57343?this.content=(r-55296)*1024+i-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},dC="di$target",G0="di$dependencies",ug=new Map;function Ate(e){return e[G0]||[]}function cn(e){if(ug.has(e))return ug.get(e);let t=function(n,r,i){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");jte(t,n,i)};return t._id=e,ug.set(e,t),t}function jte(e,t,n){t[dC]===t?t[G0].push({id:e,index:n}):(t[G0]=[{id:e,index:n}],t[dC]=t)}var zn=cn("BufferService"),XM=cn("CoreMouseService"),qo=cn("CoreService"),Lte=cn("CharsetService"),r1=cn("InstantiationService"),QM=cn("LogService"),$n=cn("OptionsService"),ZM=cn("OscLinkService"),Dte=cn("UnicodeService"),Ou=cn("DecorationService"),Y0=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var u;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,s=new wr,o=n.getTrimmedLength(),a=-1,l=-1,c=!1;for(let d=0;d<o;d++)if(!(l===-1&&!n.hasContent(d))){if(n.loadCell(d,s),s.hasExtendedAttrs()&&s.extended.urlId)if(l===-1){l=d,a=s.extended.urlId;continue}else c=s.extended.urlId!==a;else l!==-1&&(c=!0);if(c||l!==-1&&d===o-1){let f=(u=this._oscLinkService.getLinkData(a))==null?void 0:u.uri;if(f){let p={start:{x:l+1,y:e},end:{x:d+(!c&&d===o-1?1:0),y:e}},m=!1;if(!(i!=null&&i.allowNonHttpProtocols))try{let v=new URL(f);["http:","https:"].includes(v.protocol)||(m=!0)}catch{m=!0}m||r.push({text:f,range:p,activate:(v,w)=>i?i.activate(v,w,p):Ote(v,w),hover:(v,w)=>{var x;return(x=i==null?void 0:i.hover)==null?void 0:x.call(i,v,w,p)},leave:(v,w)=>{var x;return(x=i==null?void 0:i.leave)==null?void 0:x.call(i,v,w,p)}})}c=!1,s.hasExtendedAttrs()&&s.extended.urlId?(l=d,a=s.extended.urlId):(l=-1,a=-1)}}t(r)}};Y0=Pt([le(0,zn),le(1,$n),le(2,ZM)],Y0);function Ote(e,t){if(confirm(`Do you want to navigate to ${t}?
553
553
 
554
- WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Op=cn("CharSizeService"),ts=cn("CoreBrowserService"),i1=cn("MouseService"),ns=cn("RenderService"),Pte=cn("SelectionService"),QM=cn("CharacterJoinerService"),Tl=cn("ThemeService"),ZM=cn("LinkProviderService"),Rte=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?uC.isErrorNoTelemetry(e)?new uC(e.message+`
554
+ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Op=cn("CharSizeService"),ts=cn("CoreBrowserService"),i1=cn("MouseService"),ns=cn("RenderService"),Bte=cn("SelectionService"),JM=cn("CharacterJoinerService"),Tl=cn("ThemeService"),eA=cn("LinkProviderService"),zte=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?hC.isErrorNoTelemetry(e)?new hC(e.message+`
555
555
 
556
556
  `+e.stack):new Error(e.message+`
557
557
 
558
- `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},Mte=new Rte;function uh(e){Ate(e)||Mte.onUnexpectedError(e)}var X0="Canceled";function Ate(e){return e instanceof jte?!0:e instanceof Error&&e.name===X0&&e.message===X0}var jte=class extends Error{constructor(){super(X0),this.name=this.message}};function Lte(e){return new Error(`Illegal argument: ${e}`)}var uC=class Q0 extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Q0)return t;let n=new Q0;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Z0=class JM extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,JM.prototype)}};function Zn(e,t=0){return e[e.length-(1+t)]}var Dte;(e=>{function t(s){return s<0}e.isLessThan=t;function n(s){return s<=0}e.isLessThanOrEqual=n;function r(s){return s>0}e.isGreaterThan=r;function i(s){return s===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Dte||(Dte={}));function Ote(e,t){let n=this,r=!1,i;return function(){return r||(r=!0,t||(i=e.apply(n,arguments))),i}}var eA;(e=>{function t(S){return S&&typeof S=="object"&&typeof S[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(S){yield S}e.single=i;function s(S){return t(S)?S:i(S)}e.wrap=s;function o(S){return S||n}e.from=o;function*a(S){for(let C=S.length-1;C>=0;C--)yield S[C]}e.reverse=a;function l(S){return!S||S[Symbol.iterator]().next().done===!0}e.isEmpty=l;function c(S){return S[Symbol.iterator]().next().value}e.first=c;function u(S,C){let k=0;for(let N of S)if(C(N,k++))return!0;return!1}e.some=u;function d(S,C){for(let k of S)if(C(k))return k}e.find=d;function*f(S,C){for(let k of S)C(k)&&(yield k)}e.filter=f;function*p(S,C){let k=0;for(let N of S)yield C(N,k++)}e.map=p;function*m(S,C){let k=0;for(let N of S)yield*C(N,k++)}e.flatMap=m;function*v(...S){for(let C of S)yield*C}e.concat=v;function w(S,C,k){let N=k;for(let T of S)N=C(N,T);return N}e.reduce=w;function*x(S,C,k=S.length){for(C<0&&(C+=S.length),k<0?k+=S.length:k>S.length&&(k=S.length);C<k;C++)yield S[C]}e.slice=x;function _(S,C=Number.POSITIVE_INFINITY){let k=[];if(C===0)return[k,S];let N=S[Symbol.iterator]();for(let T=0;T<C;T++){let O=N.next();if(O.done)return[k,e.empty()];k.push(O.value)}return[k,{[Symbol.iterator](){return N}}]}e.consume=_;async function y(S){let C=[];for await(let k of S)C.push(k);return Promise.resolve(C)}e.asyncToArray=y})(eA||(eA={}));function Ao(e){if(eA.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(r){t.push(r)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Bte(...e){return vt(()=>Ao(e))}function vt(e){return{dispose:Ote(()=>{e()})}}var tA=class nA{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Ao(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?nA.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};tA.DISABLE_DISPOSED_WARNING=!1;var js=tA,ze=class{constructor(){this._store=new js,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};ze.None=Object.freeze({dispose(){}});var il=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Li=typeof window=="object"?window:globalThis,J0=class ex{constructor(t){this.element=t,this.next=ex.Undefined,this.prev=ex.Undefined}};J0.Undefined=new J0(void 0);var _t=J0,dC=class{constructor(){this._first=_t.Undefined,this._last=_t.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===_t.Undefined}clear(){let e=this._first;for(;e!==_t.Undefined;){let t=e.next;e.prev=_t.Undefined,e.next=_t.Undefined,e=t}this._first=_t.Undefined,this._last=_t.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new _t(e);if(this._first===_t.Undefined)this._first=n,this._last=n;else if(t){let i=this._last;this._last=n,n.prev=i,i.next=n}else{let i=this._first;this._first=n,n.next=i,i.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==_t.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==_t.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==_t.Undefined&&e.next!==_t.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===_t.Undefined&&e.next===_t.Undefined?(this._first=_t.Undefined,this._last=_t.Undefined):e.next===_t.Undefined?(this._last=this._last.prev,this._last.next=_t.Undefined):e.prev===_t.Undefined&&(this._first=this._first.next,this._first.prev=_t.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==_t.Undefined;)yield e.element,e=e.next}},zte=globalThis.performance&&typeof globalThis.performance.now=="function",$te=class rA{static create(t){return new rA(t)}constructor(t){this._now=zte&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},mn;(e=>{e.None=()=>ze.None;function t(R,A){return d(R,()=>{},0,void 0,!0,void 0,A)}e.defer=t;function n(R){return(A,M=null,L)=>{let $=!1,F;return F=R(B=>{if(!$)return F?F.dispose():$=!0,A.call(M,B)},null,L),$&&F.dispose(),F}}e.once=n;function r(R,A,M){return c((L,$=null,F)=>R(B=>L.call($,A(B)),null,F),M)}e.map=r;function i(R,A,M){return c((L,$=null,F)=>R(B=>{A(B),L.call($,B)},null,F),M)}e.forEach=i;function s(R,A,M){return c((L,$=null,F)=>R(B=>A(B)&&L.call($,B),null,F),M)}e.filter=s;function o(R){return R}e.signal=o;function a(...R){return(A,M=null,L)=>{let $=Bte(...R.map(F=>F(B=>A.call(M,B))));return u($,L)}}e.any=a;function l(R,A,M,L){let $=M;return r(R,F=>($=A($,F),$),L)}e.reduce=l;function c(R,A){let M,L={onWillAddFirstListener(){M=R($.fire,$)},onDidRemoveLastListener(){M==null||M.dispose()}},$=new te(L);return A==null||A.add($),$.event}function u(R,A){return A instanceof Array?A.push(R):A&&A.add(R),R}function d(R,A,M=100,L=!1,$=!1,F,B){let z,E,H,q=0,j,ne={leakWarningThreshold:F,onWillAddFirstListener(){z=R(K=>{q++,E=A(E,K),L&&!H&&(ie.fire(E),E=void 0),j=()=>{let ge=E;E=void 0,H=void 0,(!L||q>1)&&ie.fire(ge),q=0},typeof M=="number"?(clearTimeout(H),H=setTimeout(j,M)):H===void 0&&(H=0,queueMicrotask(j))})},onWillRemoveListener(){$&&q>0&&(j==null||j())},onDidRemoveLastListener(){j=void 0,z.dispose()}},ie=new te(ne);return B==null||B.add(ie),ie.event}e.debounce=d;function f(R,A=0,M){return e.debounce(R,(L,$)=>L?(L.push($),L):[$],A,void 0,!0,void 0,M)}e.accumulate=f;function p(R,A=(L,$)=>L===$,M){let L=!0,$;return s(R,F=>{let B=L||!A(F,$);return L=!1,$=F,B},M)}e.latch=p;function m(R,A,M){return[e.filter(R,A,M),e.filter(R,L=>!A(L),M)]}e.split=m;function v(R,A=!1,M=[],L){let $=M.slice(),F=R(E=>{$?$.push(E):z.fire(E)});L&&L.add(F);let B=()=>{$==null||$.forEach(E=>z.fire(E)),$=null},z=new te({onWillAddFirstListener(){F||(F=R(E=>z.fire(E)),L&&L.add(F))},onDidAddFirstListener(){$&&(A?setTimeout(B):B())},onDidRemoveLastListener(){F&&F.dispose(),F=null}});return L&&L.add(z),z.event}e.buffer=v;function w(R,A){return(M,L,$)=>{let F=A(new _);return R(function(B){let z=F.evaluate(B);z!==x&&M.call(L,z)},void 0,$)}}e.chain=w;let x=Symbol("HaltChainable");class _{constructor(){this.steps=[]}map(A){return this.steps.push(A),this}forEach(A){return this.steps.push(M=>(A(M),M)),this}filter(A){return this.steps.push(M=>A(M)?M:x),this}reduce(A,M){let L=M;return this.steps.push($=>(L=A(L,$),L)),this}latch(A=(M,L)=>M===L){let M=!0,L;return this.steps.push($=>{let F=M||!A($,L);return M=!1,L=$,F?$:x}),this}evaluate(A){for(let M of this.steps)if(A=M(A),A===x)break;return A}}function y(R,A,M=L=>L){let L=(...z)=>B.fire(M(...z)),$=()=>R.on(A,L),F=()=>R.removeListener(A,L),B=new te({onWillAddFirstListener:$,onDidRemoveLastListener:F});return B.event}e.fromNodeEventEmitter=y;function S(R,A,M=L=>L){let L=(...z)=>B.fire(M(...z)),$=()=>R.addEventListener(A,L),F=()=>R.removeEventListener(A,L),B=new te({onWillAddFirstListener:$,onDidRemoveLastListener:F});return B.event}e.fromDOMEventEmitter=S;function C(R){return new Promise(A=>n(R)(A))}e.toPromise=C;function k(R){let A=new te;return R.then(M=>{A.fire(M)},()=>{A.fire(void 0)}).finally(()=>{A.dispose()}),A.event}e.fromPromise=k;function N(R,A){return R(M=>A.fire(M))}e.forward=N;function T(R,A,M){return A(M),R(L=>A(L))}e.runAndSubscribe=T;class O{constructor(A,M){this._observable=A,this._counter=0,this._hasChanged=!1;let L={onWillAddFirstListener:()=>{A.addObserver(this)},onDidRemoveLastListener:()=>{A.removeObserver(this)}};this.emitter=new te(L),M&&M.add(this.emitter)}beginUpdate(A){this._counter++}handlePossibleChange(A){}handleChange(A,M){this._hasChanged=!0}endUpdate(A){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function P(R,A){return new O(R,A).emitter.event}e.fromObservable=P;function D(R){return(A,M,L)=>{let $=0,F=!1,B={beginUpdate(){$++},endUpdate(){$--,$===0&&(R.reportChanges(),F&&(F=!1,A.call(M)))},handlePossibleChange(){},handleChange(){F=!0}};R.addObserver(B),R.reportChanges();let z={dispose(){R.removeObserver(B)}};return L instanceof js?L.add(z):Array.isArray(L)&&L.push(z),z}}e.fromObservableLight=D})(mn||(mn={}));var tx=class nx{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${nx._idPool++}`,nx.all.add(this)}start(t){this._stopWatch=new $te,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};tx.all=new Set,tx._idPool=0;var Fte=tx,Hte=-1,iA=class sA{constructor(t,n,r=(sA._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,n){let r=this.threshold;if(r<=0||n<r)return;this._stacks||(this._stacks=new Map);let i=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,i+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=r*.5;let[s,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(s);let l=new Vte(a,s);this._errorHandler(l)}return()=>{let s=this._stacks.get(t.value)||0;this._stacks.set(t.value,s-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[r,i]of this._stacks)(!t||n<i)&&(t=[r,i],n=i);return t}};iA._idPool=1;var Ute=iA,Wte=class oA{constructor(t){this.value=t}static create(){let t=new Error;return new oA(t.stack??"")}print(){console.warn(this.value.split(`
558
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},$te=new zte;function uh(e){Fte(e)||$te.onUnexpectedError(e)}var X0="Canceled";function Fte(e){return e instanceof Hte?!0:e instanceof Error&&e.name===X0&&e.message===X0}var Hte=class extends Error{constructor(){super(X0),this.name=this.message}};function Ute(e){return new Error(`Illegal argument: ${e}`)}var hC=class Q0 extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Q0)return t;let n=new Q0;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Z0=class tA extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,tA.prototype)}};function Zn(e,t=0){return e[e.length-(1+t)]}var Wte;(e=>{function t(s){return s<0}e.isLessThan=t;function n(s){return s<=0}e.isLessThanOrEqual=n;function r(s){return s>0}e.isGreaterThan=r;function i(s){return s===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Wte||(Wte={}));function Vte(e,t){let n=this,r=!1,i;return function(){return r||(r=!0,t||(i=e.apply(n,arguments))),i}}var nA;(e=>{function t(S){return S&&typeof S=="object"&&typeof S[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(S){yield S}e.single=i;function s(S){return t(S)?S:i(S)}e.wrap=s;function o(S){return S||n}e.from=o;function*a(S){for(let C=S.length-1;C>=0;C--)yield S[C]}e.reverse=a;function l(S){return!S||S[Symbol.iterator]().next().done===!0}e.isEmpty=l;function c(S){return S[Symbol.iterator]().next().value}e.first=c;function u(S,C){let k=0;for(let N of S)if(C(N,k++))return!0;return!1}e.some=u;function d(S,C){for(let k of S)if(C(k))return k}e.find=d;function*f(S,C){for(let k of S)C(k)&&(yield k)}e.filter=f;function*p(S,C){let k=0;for(let N of S)yield C(N,k++)}e.map=p;function*m(S,C){let k=0;for(let N of S)yield*C(N,k++)}e.flatMap=m;function*v(...S){for(let C of S)yield*C}e.concat=v;function w(S,C,k){let N=k;for(let T of S)N=C(N,T);return N}e.reduce=w;function*x(S,C,k=S.length){for(C<0&&(C+=S.length),k<0?k+=S.length:k>S.length&&(k=S.length);C<k;C++)yield S[C]}e.slice=x;function _(S,C=Number.POSITIVE_INFINITY){let k=[];if(C===0)return[k,S];let N=S[Symbol.iterator]();for(let T=0;T<C;T++){let O=N.next();if(O.done)return[k,e.empty()];k.push(O.value)}return[k,{[Symbol.iterator](){return N}}]}e.consume=_;async function y(S){let C=[];for await(let k of S)C.push(k);return Promise.resolve(C)}e.asyncToArray=y})(nA||(nA={}));function Ao(e){if(nA.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(r){t.push(r)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function qte(...e){return vt(()=>Ao(e))}function vt(e){return{dispose:Vte(()=>{e()})}}var rA=class iA{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Ao(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?iA.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};rA.DISABLE_DISPOSED_WARNING=!1;var js=rA,ze=class{constructor(){this._store=new js,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};ze.None=Object.freeze({dispose(){}});var il=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Li=typeof window=="object"?window:globalThis,J0=class ex{constructor(t){this.element=t,this.next=ex.Undefined,this.prev=ex.Undefined}};J0.Undefined=new J0(void 0);var _t=J0,fC=class{constructor(){this._first=_t.Undefined,this._last=_t.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===_t.Undefined}clear(){let e=this._first;for(;e!==_t.Undefined;){let t=e.next;e.prev=_t.Undefined,e.next=_t.Undefined,e=t}this._first=_t.Undefined,this._last=_t.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new _t(e);if(this._first===_t.Undefined)this._first=n,this._last=n;else if(t){let i=this._last;this._last=n,n.prev=i,i.next=n}else{let i=this._first;this._first=n,n.next=i,i.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==_t.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==_t.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==_t.Undefined&&e.next!==_t.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===_t.Undefined&&e.next===_t.Undefined?(this._first=_t.Undefined,this._last=_t.Undefined):e.next===_t.Undefined?(this._last=this._last.prev,this._last.next=_t.Undefined):e.prev===_t.Undefined&&(this._first=this._first.next,this._first.prev=_t.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==_t.Undefined;)yield e.element,e=e.next}},Kte=globalThis.performance&&typeof globalThis.performance.now=="function",Gte=class sA{static create(t){return new sA(t)}constructor(t){this._now=Kte&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},mn;(e=>{e.None=()=>ze.None;function t(R,A){return d(R,()=>{},0,void 0,!0,void 0,A)}e.defer=t;function n(R){return(A,M=null,L)=>{let $=!1,F;return F=R(B=>{if(!$)return F?F.dispose():$=!0,A.call(M,B)},null,L),$&&F.dispose(),F}}e.once=n;function r(R,A,M){return c((L,$=null,F)=>R(B=>L.call($,A(B)),null,F),M)}e.map=r;function i(R,A,M){return c((L,$=null,F)=>R(B=>{A(B),L.call($,B)},null,F),M)}e.forEach=i;function s(R,A,M){return c((L,$=null,F)=>R(B=>A(B)&&L.call($,B),null,F),M)}e.filter=s;function o(R){return R}e.signal=o;function a(...R){return(A,M=null,L)=>{let $=qte(...R.map(F=>F(B=>A.call(M,B))));return u($,L)}}e.any=a;function l(R,A,M,L){let $=M;return r(R,F=>($=A($,F),$),L)}e.reduce=l;function c(R,A){let M,L={onWillAddFirstListener(){M=R($.fire,$)},onDidRemoveLastListener(){M==null||M.dispose()}},$=new te(L);return A==null||A.add($),$.event}function u(R,A){return A instanceof Array?A.push(R):A&&A.add(R),R}function d(R,A,M=100,L=!1,$=!1,F,B){let z,E,H,q=0,j,ne={leakWarningThreshold:F,onWillAddFirstListener(){z=R(K=>{q++,E=A(E,K),L&&!H&&(ie.fire(E),E=void 0),j=()=>{let ge=E;E=void 0,H=void 0,(!L||q>1)&&ie.fire(ge),q=0},typeof M=="number"?(clearTimeout(H),H=setTimeout(j,M)):H===void 0&&(H=0,queueMicrotask(j))})},onWillRemoveListener(){$&&q>0&&(j==null||j())},onDidRemoveLastListener(){j=void 0,z.dispose()}},ie=new te(ne);return B==null||B.add(ie),ie.event}e.debounce=d;function f(R,A=0,M){return e.debounce(R,(L,$)=>L?(L.push($),L):[$],A,void 0,!0,void 0,M)}e.accumulate=f;function p(R,A=(L,$)=>L===$,M){let L=!0,$;return s(R,F=>{let B=L||!A(F,$);return L=!1,$=F,B},M)}e.latch=p;function m(R,A,M){return[e.filter(R,A,M),e.filter(R,L=>!A(L),M)]}e.split=m;function v(R,A=!1,M=[],L){let $=M.slice(),F=R(E=>{$?$.push(E):z.fire(E)});L&&L.add(F);let B=()=>{$==null||$.forEach(E=>z.fire(E)),$=null},z=new te({onWillAddFirstListener(){F||(F=R(E=>z.fire(E)),L&&L.add(F))},onDidAddFirstListener(){$&&(A?setTimeout(B):B())},onDidRemoveLastListener(){F&&F.dispose(),F=null}});return L&&L.add(z),z.event}e.buffer=v;function w(R,A){return(M,L,$)=>{let F=A(new _);return R(function(B){let z=F.evaluate(B);z!==x&&M.call(L,z)},void 0,$)}}e.chain=w;let x=Symbol("HaltChainable");class _{constructor(){this.steps=[]}map(A){return this.steps.push(A),this}forEach(A){return this.steps.push(M=>(A(M),M)),this}filter(A){return this.steps.push(M=>A(M)?M:x),this}reduce(A,M){let L=M;return this.steps.push($=>(L=A(L,$),L)),this}latch(A=(M,L)=>M===L){let M=!0,L;return this.steps.push($=>{let F=M||!A($,L);return M=!1,L=$,F?$:x}),this}evaluate(A){for(let M of this.steps)if(A=M(A),A===x)break;return A}}function y(R,A,M=L=>L){let L=(...z)=>B.fire(M(...z)),$=()=>R.on(A,L),F=()=>R.removeListener(A,L),B=new te({onWillAddFirstListener:$,onDidRemoveLastListener:F});return B.event}e.fromNodeEventEmitter=y;function S(R,A,M=L=>L){let L=(...z)=>B.fire(M(...z)),$=()=>R.addEventListener(A,L),F=()=>R.removeEventListener(A,L),B=new te({onWillAddFirstListener:$,onDidRemoveLastListener:F});return B.event}e.fromDOMEventEmitter=S;function C(R){return new Promise(A=>n(R)(A))}e.toPromise=C;function k(R){let A=new te;return R.then(M=>{A.fire(M)},()=>{A.fire(void 0)}).finally(()=>{A.dispose()}),A.event}e.fromPromise=k;function N(R,A){return R(M=>A.fire(M))}e.forward=N;function T(R,A,M){return A(M),R(L=>A(L))}e.runAndSubscribe=T;class O{constructor(A,M){this._observable=A,this._counter=0,this._hasChanged=!1;let L={onWillAddFirstListener:()=>{A.addObserver(this)},onDidRemoveLastListener:()=>{A.removeObserver(this)}};this.emitter=new te(L),M&&M.add(this.emitter)}beginUpdate(A){this._counter++}handlePossibleChange(A){}handleChange(A,M){this._hasChanged=!0}endUpdate(A){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function P(R,A){return new O(R,A).emitter.event}e.fromObservable=P;function D(R){return(A,M,L)=>{let $=0,F=!1,B={beginUpdate(){$++},endUpdate(){$--,$===0&&(R.reportChanges(),F&&(F=!1,A.call(M)))},handlePossibleChange(){},handleChange(){F=!0}};R.addObserver(B),R.reportChanges();let z={dispose(){R.removeObserver(B)}};return L instanceof js?L.add(z):Array.isArray(L)&&L.push(z),z}}e.fromObservableLight=D})(mn||(mn={}));var tx=class nx{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${nx._idPool++}`,nx.all.add(this)}start(t){this._stopWatch=new Gte,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};tx.all=new Set,tx._idPool=0;var Yte=tx,Xte=-1,oA=class aA{constructor(t,n,r=(aA._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,n){let r=this.threshold;if(r<=0||n<r)return;this._stacks||(this._stacks=new Map);let i=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,i+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=r*.5;let[s,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(s);let l=new Jte(a,s);this._errorHandler(l)}return()=>{let s=this._stacks.get(t.value)||0;this._stacks.set(t.value,s-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[r,i]of this._stacks)(!t||n<i)&&(t=[r,i],n=i);return t}};oA._idPool=1;var Qte=oA,Zte=class lA{constructor(t){this.value=t}static create(){let t=new Error;return new lA(t.stack??"")}print(){console.warn(this.value.split(`
559
559
  `).slice(2).join(`
560
- `))}},Vte=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},qte=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Kte=0,dg=class{constructor(e){this.value=e,this.id=Kte++}},Gte=2,Yte,te=class{constructor(e){var t,n,r,i;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new Ute((e==null?void 0:e.onListenerError)??uh,((n=this._options)==null?void 0:n.leakWarningThreshold)??Hte):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new Fte(this._options._profName):void 0,this._deliveryQueue=(i=this._options)==null?void 0:i.deliveryQueue}dispose(){var e,t,n,r;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(n=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||n.call(t),(r=this._leakageMon)==null||r.dispose())}get event(){return this._event??(this._event=(e,t,n)=>{var o,a,l,c,u;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let d=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(d);let f=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],p=new qte(`${d}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(((o=this._options)==null?void 0:o.onListenerError)||uh)(p),ze.None}if(this._disposed)return ze.None;t&&(e=e.bind(t));let r=new dg(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Wte.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof dg?(this._deliveryQueue??(this._deliveryQueue=new Xte),this._listeners=[this._listeners,r]):this._listeners.push(r):((l=(a=this._options)==null?void 0:a.onWillAddFirstListener)==null||l.call(a,this),this._listeners=r,(u=(c=this._options)==null?void 0:c.onDidAddFirstListener)==null||u.call(c,this)),this._size++;let s=vt(()=>{i==null||i(),this._removeListener(r)});return n instanceof js?n.add(s):Array.isArray(n)&&n.push(s),s}),this._event}_removeListener(e){var i,s,o,a;if((s=(i=this._options)==null?void 0:i.onWillRemoveListener)==null||s.call(i,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(a=(o=this._options)==null?void 0:o.onDidRemoveLastListener)==null||a.call(o,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)),new Error("Attempted to dispose unknown listener");this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*Gte<=t.length){let l=0;for(let c=0;c<t.length;c++)t[c]?t[l++]=t[c]:r&&(this._deliveryQueue.end--,l<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=l}}_deliver(e,t){var r;if(!e)return;let n=((r=this._options)==null?void 0:r.onListenerError)||uh;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,n,r,i;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(n=this._perfMon)==null||n.stop()),(r=this._perfMon)==null||r.start(this._size),this._listeners)if(this._listeners instanceof dg)this._deliver(this._listeners,e);else{let s=this._deliveryQueue;s.enqueue(this,e,this._listeners.length),this._deliverQueue(s)}(i=this._perfMon)==null||i.stop()}hasListeners(){return this._size>0}},Xte=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}},rx=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new te,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new te,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let r=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let r=this.getWindowId(n);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};rx.INSTANCE=new rx;var s1=rx;function Qte(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}s1.INSTANCE.onDidChangeZoomLevel;function Zte(e){return s1.INSTANCE.getZoomFactor(e)}s1.INSTANCE.onDidChangeFullscreen;var Il=typeof navigator=="object"?navigator.userAgent:"",ix=Il.indexOf("Firefox")>=0,Jte=Il.indexOf("AppleWebKit")>=0,o1=Il.indexOf("Chrome")>=0,ene=!o1&&Il.indexOf("Safari")>=0;Il.indexOf("Electron/")>=0;Il.indexOf("Android")>=0;var hg=!1;if(typeof Li.matchMedia=="function"){let e=Li.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Li.matchMedia("(display-mode: fullscreen)");hg=e.matches,Qte(Li,e,({matches:n})=>{hg&&t.matches||(hg=n)})}var Na="en",sx=!1,ox=!1,dh=!1,aA=!1,Rd,hh=Na,hC=Na,tne,Ar,xo=globalThis,pn,p2;typeof xo.vscode<"u"&&typeof xo.vscode.process<"u"?pn=xo.vscode.process:typeof process<"u"&&typeof((p2=process==null?void 0:process.versions)==null?void 0:p2.node)=="string"&&(pn=process);var m2,nne=typeof((m2=pn==null?void 0:pn.versions)==null?void 0:m2.electron)=="string",rne=nne&&(pn==null?void 0:pn.type)==="renderer",g2;if(typeof pn=="object"){sx=pn.platform==="win32",ox=pn.platform==="darwin",dh=pn.platform==="linux",dh&&pn.env.SNAP&&pn.env.SNAP_REVISION,pn.env.CI||pn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Rd=Na,hh=Na;let e=pn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Rd=t.userLocale,hC=t.osLocale,hh=t.resolvedLanguage||Na,tne=(g2=t.languagePack)==null?void 0:g2.translationsConfigFile}catch{}aA=!0}else typeof navigator=="object"&&!rne?(Ar=navigator.userAgent,sx=Ar.indexOf("Windows")>=0,ox=Ar.indexOf("Macintosh")>=0,(Ar.indexOf("Macintosh")>=0||Ar.indexOf("iPad")>=0||Ar.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,dh=Ar.indexOf("Linux")>=0,(Ar==null?void 0:Ar.indexOf("Mobi"))>=0,hh=globalThis._VSCODE_NLS_LANGUAGE||Na,Rd=navigator.language.toLowerCase(),hC=Rd):console.error("Unable to resolve platform.");var lA=sx,hi=ox,ine=dh,fC=aA,vi=Ar,ls=hh,sne;(e=>{function t(){return ls}e.value=t;function n(){return ls.length===2?ls==="en":ls.length>=3?ls[0]==="e"&&ls[1]==="n"&&ls[2]==="-":!1}e.isDefaultVariant=n;function r(){return ls==="en"}e.isDefault=r})(sne||(sne={}));var one=typeof xo.postMessage=="function"&&!xo.importScripts;(()=>{if(one){let e=[];xo.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let r=0,i=e.length;r<i;r++){let s=e[r];if(s.id===n.data.vscodeScheduleAsyncWork){e.splice(r,1),s.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),xo.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var ane=!!(vi&&vi.indexOf("Chrome")>=0);vi&&vi.indexOf("Firefox")>=0;!ane&&vi&&vi.indexOf("Safari")>=0;vi&&vi.indexOf("Edg/")>=0;vi&&vi.indexOf("Android")>=0;var la=typeof navigator=="object"?navigator:{};fC||document.queryCommandSupported&&document.queryCommandSupported("copy")||la&&la.clipboard&&la.clipboard.writeText,fC||la&&la.clipboard&&la.clipboard.readText;var a1=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}},fg=new a1,pC=new a1,mC=new a1,lne=new Array(230),cA;(e=>{function t(a){return fg.keyCodeToStr(a)}e.toString=t;function n(a){return fg.strToKeyCode(a)}e.fromString=n;function r(a){return pC.keyCodeToStr(a)}e.toUserSettingsUS=r;function i(a){return mC.keyCodeToStr(a)}e.toUserSettingsGeneral=i;function s(a){return pC.strToKeyCode(a)||mC.strToKeyCode(a)}e.fromUserSettings=s;function o(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return fg.keyCodeToStr(a)}e.toElectronAccelerator=o})(cA||(cA={}));var cne=class uA{constructor(t,n,r,i,s){this.ctrlKey=t,this.shiftKey=n,this.altKey=r,this.metaKey=i,this.keyCode=s}equals(t){return t instanceof uA&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",r=this.altKey?"1":"0",i=this.metaKey?"1":"0";return`K${t}${n}${r}${i}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new une([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},une=class{constructor(e){if(e.length===0)throw Lte("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 dne(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return cA.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(ix)switch(t){case 59:return 85;case 60:if(ine)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(hi)return 57;break}else if(Jte&&(hi&&t===93||!hi&&t===92))return 57;return lne[t]||0}var hne=hi?256:2048,fne=512,pne=1024,mne=hi?2048:256,gC=class{constructor(e){var n;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=(n=t.getModifierState)==null?void 0:n.call(t,"AltGraph"),this.keyCode=dne(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|=hne),this.altKey&&(t|=fne),this.shiftKey&&(t|=pne),this.metaKey&&(t|=mne),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new cne(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},vC=new WeakMap;function gne(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 vne=class{static getSameOriginWindowChain(e){let t=vC.get(e);if(!t){t=[],vC.set(e,t);let n=e,r;do r=gne(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 s of i){let o=s.window.deref();if(n+=(o==null?void 0:o.scrollY)??0,r+=(o==null?void 0:o.scrollX)??0,o===t||!s.iframeElement)break;let a=s.iframeElement.getBoundingClientRect();n+=a.top,r+=a.left}return{top:n,left:r}}},Md=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=vne.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},xC=class{constructor(e,t=0,n=0){var i;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(o1){let s=navigator.userAgent.match(/Chrome\/(\d+)/);r=(s?parseInt(s[1]):123)<=122}if(e){let s=e,o=e,a=((i=e.view)==null?void 0:i.devicePixelRatio)||1;if(typeof s.wheelDeltaY<"u")r?this.deltaY=s.wheelDeltaY/(120*a):this.deltaY=s.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(e.type==="wheel"){let l=e;l.deltaMode===l.DOM_DELTA_LINE?ix&&!hi?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof s.wheelDeltaX<"u")ene&&lA?this.deltaX=-(s.wheelDeltaX/120):r?this.deltaX=s.wheelDeltaX/(120*a):this.deltaX=s.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let l=e;l.deltaMode===l.DOM_DELTA_LINE?ix&&!hi?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*a):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},dA=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),xne;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof _ne?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:mn.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:dA})})(xne||(xne={}));var _ne=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?dA:(this._emitter||(this._emitter=new te),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},l1=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 Z0("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Z0("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},yne=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new Z0("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=vt(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},bne;(e=>{async function t(r){let i,s=await Promise.all(r.map(o=>o.then(a=>a,a=>{i||(i=a)})));if(typeof i<"u")throw i;return s}e.settled=t;function n(r){return new Promise(async(i,s)=>{try{await r(i,s)}catch(o){s(o)}})}e.withAsyncBody=n})(bne||(bne={}));var _C=class pr{static fromArray(t){return new pr(n=>{n.emitMany(t)})}static fromPromise(t){return new pr(async n=>{n.emitMany(await t)})}static fromPromises(t){return new pr(async n=>{await Promise.all(t.map(async r=>n.emitOne(await r)))})}static merge(t){return new pr(async n=>{await Promise.all(t.map(async r=>{for await(let i of r)n.emitOne(i)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new te,queueMicrotask(async()=>{let r={emitOne:i=>this.emitOne(i),emitMany:i=>this.emitMany(i),reject:i=>this.reject(i)};try{await Promise.resolve(t(r)),this.resolve()}catch(i){this.reject(i)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await mn.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var n;return(n=this._onReturn)==null||n.call(this),{done:!0,value:void 0}}}}static map(t,n){return new pr(async r=>{for await(let i of t)r.emitOne(n(i))})}map(t){return pr.map(this,t)}static filter(t,n){return new pr(async r=>{for await(let i of t)n(i)&&r.emitOne(i)})}filter(t){return pr.filter(this,t)}static coalesce(t){return pr.filter(t,n=>!!n)}coalesce(){return pr.coalesce(this)}static async toPromise(t){let n=[];for await(let r of t)n.push(r);return n}toPromise(){return pr.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};_C.EMPTY=_C.fromArray([]);var{getWindow:oi,getWindowId:wne,onDidRegisterWindow:Sne}=function(){let e=new Map,t={window:Li,disposables:new js};e.set(Li.vscodeWindowId,t);let n=new te,r=new te,i=new te;function s(o,a){return(typeof o=="number"?e.get(o):void 0)??(a?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(o){if(e.has(o.vscodeWindowId))return ze.None;let a=new js,l={window:o,disposables:a.add(new js)};return e.set(o.vscodeWindowId,l),a.add(vt(()=>{e.delete(o.vscodeWindowId),r.fire(o)})),a.add(Ee(o,nn.BEFORE_UNLOAD,()=>{i.fire(o)})),n.fire(l),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.has(o)},getWindowById:s,getWindow(o){var c;let a=o;if((c=a==null?void 0:a.ownerDocument)!=null&&c.defaultView)return a.ownerDocument.defaultView.window;let l=o;return l!=null&&l.view?l.view.window:Li},getDocument(o){return oi(o).document}}}(),kne=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,this._handler=null)}};function Ee(e,t,n,r){return new kne(e,t,n,r)}var yC=function(e,t,n,r){return Ee(e,t,n,r)},c1,Cne=class extends yne{constructor(e){super(),this.defaultTarget=e&&oi(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},bC=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){uh(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=s=>{n.set(s,!1);let o=e.get(s)??[];for(t.set(s,o),e.set(s,[]),r.set(s,!0);o.length>0;)o.sort(bC.sort),o.shift().execute();r.set(s,!1)};c1=(s,o,a=0)=>{let l=wne(s),c=new bC(o,a),u=e.get(l);return u||(u=[],e.set(l,u)),u.push(c),n.get(l)||(n.set(l,!0),s.requestAnimationFrame(()=>i(l))),c}})();function Ene(e){let t=e.getBoundingClientRect(),n=oi(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var nn={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},Nne=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=Hn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Hn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Hn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Hn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Hn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Hn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Hn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Hn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Hn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Hn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Hn(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=Hn(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=Hn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Hn(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 Hn(e){return typeof e=="number"?`${e}px`:e}function Tc(e){return new Nne(e)}var hA=class{constructor(){this._hooks=new js,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 s=e;try{e.setPointerCapture(t),this._hooks.add(vt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{s=oi(e)}this._hooks.add(Ee(s,nn.POINTER_MOVE,o=>{if(o.buttons!==n){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(Ee(s,nn.POINTER_UP,o=>this.stopMonitoring(!0)))}};function Tne(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 new Error("not supported");let s=`$memoize$${t}`;n[r]=function(...o){return this.hasOwnProperty(s)||Object.defineProperty(this,s,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,o)}),this[s]}}var Qr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Qr||(Qr={}));var ac=class bn extends ze{constructor(){super(),this.dispatched=!1,this.targets=new dC,this.ignoreTargets=new dC,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(mn.runAndSubscribe(Sne,({window:t,disposables:n})=>{n.add(Ee(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),n.add(Ee(t.document,"touchend",r=>this.onTouchEnd(t,r))),n.add(Ee(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:Li,disposables:this._store}))}static addTarget(t){if(!bn.isTouchDevice())return ze.None;bn.INSTANCE||(bn.INSTANCE=new bn);let n=bn.INSTANCE.targets.push(t);return vt(n)}static ignoreTarget(t){if(!bn.isTouchDevice())return ze.None;bn.INSTANCE||(bn.INSTANCE=new bn);let n=bn.INSTANCE.ignoreTargets.push(t);return vt(n)}static isTouchDevice(){return"ontouchstart"in Li||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,i=t.targetTouches.length;r<i;r++){let s=t.targetTouches.item(r);this.activeTouches[s.identifier]={id:s.identifier,initialTarget:s.target,initialTimeStamp:n,initialPageX:s.pageX,initialPageY:s.pageY,rollingTimestamps:[n],rollingPageX:[s.pageX],rollingPageY:[s.pageY]};let o=this.newGestureEvent(Qr.Start,s.target);o.pageX=s.pageX,o.pageY=s.pageY,this.dispatchEvent(o)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let r=Date.now(),i=Object.keys(this.activeTouches).length;for(let s=0,o=n.changedTouches.length;s<o;s++){let a=n.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let l=this.activeTouches[a.identifier],c=Date.now()-l.initialTimeStamp;if(c<bn.HOLD_DELAY&&Math.abs(l.initialPageX-Zn(l.rollingPageX))<30&&Math.abs(l.initialPageY-Zn(l.rollingPageY))<30){let u=this.newGestureEvent(Qr.Tap,l.initialTarget);u.pageX=Zn(l.rollingPageX),u.pageY=Zn(l.rollingPageY),this.dispatchEvent(u)}else if(c>=bn.HOLD_DELAY&&Math.abs(l.initialPageX-Zn(l.rollingPageX))<30&&Math.abs(l.initialPageY-Zn(l.rollingPageY))<30){let u=this.newGestureEvent(Qr.Contextmenu,l.initialTarget);u.pageX=Zn(l.rollingPageX),u.pageY=Zn(l.rollingPageY),this.dispatchEvent(u)}else if(i===1){let u=Zn(l.rollingPageX),d=Zn(l.rollingPageY),f=Zn(l.rollingTimestamps)-l.rollingTimestamps[0],p=u-l.rollingPageX[0],m=d-l.rollingPageY[0],v=[...this.targets].filter(w=>l.initialTarget instanceof Node&&w.contains(l.initialTarget));this.inertia(t,v,r,Math.abs(p)/f,p>0?1:-1,u,Math.abs(m)/f,m>0?1:-1,d)}this.dispatchEvent(this.newGestureEvent(Qr.End,l.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let r=document.createEvent("CustomEvent");return r.initEvent(t,!1,!0),r.initialTarget=n,r.tapCount=0,r}dispatchEvent(t){if(t.type===Qr.Tap){let n=new Date().getTime(),r=0;n-this._lastSetTapCountTime>bn.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===Qr.Change||t.type===Qr.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let n=[];for(let r of this.targets)if(r.contains(t.initialTarget)){let i=0,s=t.initialTarget;for(;s&&s!==r;)i++,s=s.parentElement;n.push([i,r])}n.sort((r,i)=>r[0]-i[0]);for(let[r,i]of n)i.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,i,s,o,a,l,c){this.handle=c1(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=bn.SCROLL_FRICTION*d,a+=bn.SCROLL_FRICTION*d,i>0&&(m=!1,f=s*i*d),a>0&&(m=!1,p=l*a*d);let v=this.newGestureEvent(Qr.Change);v.translationX=f,v.translationY=p,n.forEach(w=>w.dispatchEvent(v)),m||this.inertia(t,n,u,i,s,o+f,a,l,c+p)})}onTouchMove(t){let n=Date.now();for(let r=0,i=t.changedTouches.length;r<i;r++){let s=t.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(String(s.identifier))){console.warn("end of an UNKNOWN touch",s);continue}let o=this.activeTouches[s.identifier],a=this.newGestureEvent(Qr.Change,o.initialTarget);a.translationX=s.pageX-Zn(o.rollingPageX),a.translationY=s.pageY-Zn(o.rollingPageY),a.pageX=s.pageX,a.pageY=s.pageY,this.dispatchEvent(a),o.rollingPageX.length>3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(s.pageX),o.rollingPageY.push(s.pageY),o.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};ac.SCROLL_FRICTION=-.005,ac.HOLD_DELAY=700,ac.CLEAR_TAP_COUNT_TIME=400,Pt([Tne],ac,"isTouchDevice",1);var Ine=ac,u1=class extends ze{onclick(e,t){this._register(Ee(e,nn.CLICK,n=>t(new Md(oi(e),n))))}onmousedown(e,t){this._register(Ee(e,nn.MOUSE_DOWN,n=>t(new Md(oi(e),n))))}onmouseover(e,t){this._register(Ee(e,nn.MOUSE_OVER,n=>t(new Md(oi(e),n))))}onmouseleave(e,t){this._register(Ee(e,nn.MOUSE_LEAVE,n=>t(new Md(oi(e),n))))}onkeydown(e,t){this._register(Ee(e,nn.KEY_DOWN,n=>t(new gC(n))))}onkeyup(e,t){this._register(Ee(e,nn.KEY_UP,n=>t(new gC(n))))}oninput(e,t){this._register(Ee(e,nn.INPUT,t))}onblur(e,t){this._register(Ee(e,nn.BLUR,t))}onfocus(e,t){this._register(Ee(e,nn.FOCUS,t))}onchange(e,t){this._register(Ee(e,nn.CHANGE,t))}ignoreGesture(e){return Ine.ignoreTarget(e)}},wC=11,Pne=class extends u1{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=wC+"px",this.domNode.style.height=wC+"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 hA),this._register(yC(this.bgDomNode,nn.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(yC(this.domNode,nn.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Cne),this._pointerdownScheduleRepeatTimer=this._register(new l1)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,oi(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Rne=class ax{constructor(t,n,r,i,s,o,a){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,r=r|0,i=i|0,s=s|0,o=o|0,a=a|0),this.rawScrollLeft=i,this.rawScrollTop=a,n<0&&(n=0),i+n>r&&(i=r-n),i<0&&(i=0),s<0&&(s=0),a+s>o&&(a=o-s),a<0&&(a=0),this.width=n,this.scrollWidth=r,this.scrollLeft=i,this.height=s,this.scrollHeight=o,this.scrollTop=a}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new ax(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 ax(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(t,n){let r=this.width!==t.width,i=this.scrollWidth!==t.scrollWidth,s=this.scrollLeft!==t.scrollLeft,o=this.height!==t.height,a=this.scrollHeight!==t.scrollHeight,l=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:r,scrollWidthChanged:i,scrollLeftChanged:s,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:l}}},Mne=class extends ze{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Rne(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var r;let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),(r=this._smoothScrolling)==null||r.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(),this._smoothScrolling=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;t?r=new kC(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=kC.start(this._state,n,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)))}},SC=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function pg(e,t){let n=t-e;return function(r){return e+n*Lne(r)}}function Ane(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var kC=class lx{constructor(t,n,r,i){this.from=t,this.to=n,this.duration=i,this.startTime=r,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(t,n,r){if(Math.abs(t-n)>2.5*r){let i,s;return t<n?(i=t+.75*r,s=n-.75*r):(i=t-.75*r,s=n+.75*r),Ane(pg(t,i),pg(s,n),.33)}return pg(t,n)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let n=(t-this.startTime)/this.duration;if(n<1){let r=this.scrollLeft(n),i=this.scrollTop(n);return new SC(r,i,!1)}return new SC(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return lx.start(t,n,r)}static start(t,n,r){r=r+10;let i=Date.now()-10;return new lx(t,n,i,r)}};function jne(e){return Math.pow(e,3)}function Lne(e){return 1-jne(1-e)}var Dne=class extends ze{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 l1)}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?!0: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(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},One=140,fA=class extends u1{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 Dne(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new hA),this._shouldRender=!0,this.domNode=Tc(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(Ee(this.domNode.domNode,nn.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Pne(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=Tc(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(Ee(this.slider.domNode,nn.POINTER_DOWN,i=>{i.button===0&&(i.preventDefault(),this._sliderPointerDown(i))})),this.onclick(this.slider.domNode,i=>{i.leftButton&&i.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 i=Ene(this.domNode.domNode);t=e.pageX-i.left,n=e.pageY-i.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,i=>{let s=this._sliderOrthogonalPointerPosition(i),o=Math.abs(s-n);if(lA&&o>One){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let a=this._sliderPointerPosition(i)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(a))},()=>{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()}},pA=class cx{constructor(t,n,r,i,s,o){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=i,this._scrollSize=s,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new cx(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,r,i,s){let o=Math.max(0,r-t),a=Math.max(0,o-2*n),l=i>0&&i>r;if(!l)return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(r*a/i))),u=(a-c)/(i-r),d=s*u;return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(c),computedSliderRatio:u,computedSliderPosition:Math.round(d)}}_refreshComputedValues(){let t=cx._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(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,r=this._scrollPosition;return n<this._computedSliderPosition?r-=this._visibleSize:r+=this._visibleSize,r}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+t;return Math.round(n/this._computedSliderRatio)}},Bne=class extends fA{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new pA(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 new 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}},zne=class extends fA{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new pA(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 new 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}},$ne=500,CC=50,Fne=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},ux=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,n=0,r=1,i=this._rear;do{let s=i===this._front?t:Math.pow(2,-r);if(t-=s,n+=this._memory[i].score*s,i===this._front)break;i=(this._capacity+i-1)%this._capacity,r++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(o1){let n=oi(t.browserEvent),r=Zte(n);this.accept(Date.now(),t.deltaX*r,t.deltaY*r)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,n,r){let i=null,s=new Fne(t,n,r);this._front===-1&&this._rear===-1?(this._memory[0]=s,this._front=0,this._rear=0):(i=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]=s),s.score=this._computeScore(s,i)}_computeScore(t,n){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let r=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(r+=.25),n){let i=Math.abs(t.deltaX),s=Math.abs(t.deltaY),o=Math.abs(n.deltaX),a=Math.abs(n.deltaY),l=Math.max(Math.min(i,o),1),c=Math.max(Math.min(s,a),1),u=Math.max(i,o),d=Math.max(s,a);u%l===0&&d%c===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};ux.INSTANCE=new ux;var Hne=ux,Une=class extends u1{constructor(e,t,n){super(),this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new te),this.onWillScroll=this._onWillScroll.event,this._options=Vne(t),this._scrollable=n,this._register(this._scrollable.onScroll(i=>{this._onWillScroll.fire(i),this._onDidScroll(i),this._onScroll.fire(i)}));let r={onMouseWheel:i=>this._onMouseWheel(i),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new zne(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new Bne(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=Tc(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Tc(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Tc(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,i=>this._onMouseOver(i)),this.onmouseleave(this._listenOnDomNode,i=>this._onMouseLeave(i)),this._hideTimeout=this._register(new l1),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Ao(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,hi&&(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 xC(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Ao(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new xC(n))};this._mouseWheelToDispose.push(Ee(this._listenOnDomNode,nn.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var i;if((i=e.browserEvent)!=null&&i.defaultPrevented)return;let t=Hne.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let s=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+s===0?o=s=0:Math.abs(s)>=Math.abs(o)?o=0:s=0),this._options.flipAxes&&([s,o]=[o,s]);let a=!hi&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=s,s=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,s=s*this._options.fastScrollSensitivity);let l=this._scrollable.getFutureScrollPosition(),c={};if(s){let u=CC*s,d=l.scrollTop-(u<0?Math.floor(u):Math.ceil(u));this._verticalScrollbar.writeScrollPosition(c,d)}if(o){let u=CC*o,d=l.scrollLeft-(u<0?Math.floor(u):Math.ceil(u));this._horizontalScrollbar.writeScrollPosition(c,d)}c=this._scrollable.validateScrollPosition(c),(l.scrollLeft!==c.scrollLeft||l.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),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 new 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":"",s=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${s}${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(),$ne)}},Wne=class extends Une{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 Vne(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,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:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,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:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,hi&&(t.className+=" mac"),t}var dx=class extends ze{constructor(e,t,n,r,i,s,o,a){super(),this._bufferService=n,this._optionsService=o,this._renderService=a,this._onRequestScrollLines=this._register(new te),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let l=this._register(new Mne({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>c1(r.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{l.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Wne(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},l)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(mn.runAndSubscribe(s.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=s.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(vt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(vt(()=>this._styleElement.remove())),this._register(mn.runAndSubscribe(s.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${s.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${s.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${s.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
561
- `)})),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(c=>this._handleScroll(c)))}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(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.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}};dx=Pt([le(2,zn),le(3,ts),le(4,GM),le(5,Tl),le(6,$n),le(7,ns)],dx);var hx=class extends ze{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(s=>this._removeDecoration(s))),this._register(vt(()=>{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){var r;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((r=e==null?void 0:e.options)==null?void 0:r.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){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};hx=Pt([le(1,zn),le(2,ts),le(3,Ou),le(4,ns)],hx);var qne=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)}},Yr={full:0,left:0,center:0,right:0},cs={full:0,left:0,center:0,right:0},Vl={full:0,left:0,center:0,right:0},_f=class extends ze{constructor(e,t,n,r,i,s,o,a){var c;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=s,this._themeService=o,this._coreBrowserService=a,this._colorZoneStore=new qne,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(),(c=this._viewportElement.parentElement)==null||c.insertBefore(this._canvas,this._viewportElement),this._register(vt(()=>{var u;return(u=this._canvas)==null?void 0:u.remove()}));let l=this._canvas.getContext("2d");if(l)this._ctx=l;else throw new 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(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);cs.full=this._canvas.width,cs.left=e,cs.center=t,cs.right=e,this._refreshDrawHeightConstants(),Vl.full=1,Vl.left=1,Vl.center=1+cs.left,Vl.right=1+cs.left+cs.center}_refreshDrawHeightConstants(){Yr.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);Yr.left=t,Yr.center=t,Yr.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Yr.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Yr.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Yr.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Yr.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 t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);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(Vl[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Yr[e.position||"full"]/2),cs[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Yr[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}))}};_f=Pt([le(2,zn),le(3,Ou),le(4,ns),le(5,$n),le(6,Tl),le(7,ts)],_f);var V;(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=`
562
- `,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=""))(V||(V={}));var fh;(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="Ÿ"))(fh||(fh={}));var mA;(e=>e.ST=`${V.ESC}\\`)(mA||(mA={}));var fx=class{constructor(e,t,n,r,i,s){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=s,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 t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!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(`${V.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 t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,r=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,i=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=i+"px",this._compositionView.style.top=r+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let s=this._compositionView.getBoundingClientRect();this._textarea.style.left=i+"px",this._textarea.style.top=r+"px",this._textarea.style.width=Math.max(s.width,1)+"px",this._textarea.style.height=Math.max(s.height,1)+"px",this._textarea.style.lineHeight=s.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};fx=Pt([le(2,zn),le(3,$n),le(4,qo),le(5,ns)],fx);var sn=0,on=0,an=0,Et=0,EC={css:"#00000000",rgba:0},Ht;(e=>{function t(i,s,o,a){return a!==void 0?`#${no(i)}${no(s)}${no(o)}${no(a)}`:`#${no(i)}${no(s)}${no(o)}`}e.toCss=t;function n(i,s,o,a=255){return(i<<24|s<<16|o<<8|a)>>>0}e.toRgba=n;function r(i,s,o,a){return{css:e.toCss(i,s,o,a),rgba:e.toRgba(i,s,o,a)}}e.toColor=r})(Ht||(Ht={}));var pt;(e=>{function t(l,c){if(Et=(c.rgba&255)/255,Et===1)return{css:c.css,rgba:c.rgba};let u=c.rgba>>24&255,d=c.rgba>>16&255,f=c.rgba>>8&255,p=l.rgba>>24&255,m=l.rgba>>16&255,v=l.rgba>>8&255;sn=p+Math.round((u-p)*Et),on=m+Math.round((d-m)*Et),an=v+Math.round((f-v)*Et);let w=Ht.toCss(sn,on,an),x=Ht.toRgba(sn,on,an);return{css:w,rgba:x}}e.blend=t;function n(l){return(l.rgba&255)===255}e.isOpaque=n;function r(l,c,u){let d=ph.ensureContrastRatio(l.rgba,c.rgba,u);if(d)return Ht.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=r;function i(l){let c=(l.rgba|255)>>>0;return[sn,on,an]=ph.toChannels(c),{css:Ht.toCss(sn,on,an),rgba:c}}e.opaque=i;function s(l,c){return Et=Math.round(c*255),[sn,on,an]=ph.toChannels(l.rgba),{css:Ht.toCss(sn,on,an,Et),rgba:Ht.toRgba(sn,on,an,Et)}}e.opacity=s;function o(l,c){return Et=l.rgba&255,s(l,Et*c/255)}e.multiplyOpacity=o;function a(l){return[l.rgba>>24&255,l.rgba>>16&255,l.rgba>>8&255]}e.toColorRGB=a})(pt||(pt={}));var yt;(e=>{let t,n;try{let i=document.createElement("canvas");i.width=1,i.height=1;let s=i.getContext("2d",{willReadFrequently:!0});s&&(t=s,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function r(i){if(i.match(/#[\da-f]{3,8}/i))switch(i.length){case 4:return sn=parseInt(i.slice(1,2).repeat(2),16),on=parseInt(i.slice(2,3).repeat(2),16),an=parseInt(i.slice(3,4).repeat(2),16),Ht.toColor(sn,on,an);case 5:return sn=parseInt(i.slice(1,2).repeat(2),16),on=parseInt(i.slice(2,3).repeat(2),16),an=parseInt(i.slice(3,4).repeat(2),16),Et=parseInt(i.slice(4,5).repeat(2),16),Ht.toColor(sn,on,an,Et);case 7:return{css:i,rgba:(parseInt(i.slice(1),16)<<8|255)>>>0};case 9:return{css:i,rgba:parseInt(i.slice(1),16)>>>0}}let s=i.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(s)return sn=parseInt(s[1]),on=parseInt(s[2]),an=parseInt(s[3]),Et=Math.round((s[5]===void 0?1:parseFloat(s[5]))*255),Ht.toColor(sn,on,an,Et);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=i,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[sn,on,an,Et]=t.getImageData(0,0,1,1).data,Et!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ht.toRgba(sn,on,an,Et),css:i}}e.toColor=r})(yt||(yt={}));var In;(e=>{function t(r){return n(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function n(r,i,s){let o=r/255,a=i/255,l=s/255,c=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),u=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4);return c*.2126+u*.7152+d*.0722}e.relativeLuminance2=n})(In||(In={}));var ph;(e=>{function t(o,a){if(Et=(a&255)/255,Et===1)return a;let l=a>>24&255,c=a>>16&255,u=a>>8&255,d=o>>24&255,f=o>>16&255,p=o>>8&255;return sn=d+Math.round((l-d)*Et),on=f+Math.round((c-f)*Et),an=p+Math.round((u-p)*Et),Ht.toRgba(sn,on,an)}e.blend=t;function n(o,a,l){let c=In.relativeLuminance(o>>8),u=In.relativeLuminance(a>>8);if(Ni(c,u)<l){if(u<c){let p=r(o,a,l),m=Ni(c,In.relativeLuminance(p>>8));if(m<l){let v=i(o,a,l),w=Ni(c,In.relativeLuminance(v>>8));return m>w?p:v}return p}let d=i(o,a,l),f=Ni(c,In.relativeLuminance(d>>8));if(f<l){let p=r(o,a,l),m=Ni(c,In.relativeLuminance(p>>8));return f>m?d:p}return d}}e.ensureContrastRatio=n;function r(o,a,l){let c=o>>24&255,u=o>>16&255,d=o>>8&255,f=a>>24&255,p=a>>16&255,m=a>>8&255,v=Ni(In.relativeLuminance2(f,p,m),In.relativeLuminance2(c,u,d));for(;v<l&&(f>0||p>0||m>0);)f-=Math.max(0,Math.ceil(f*.1)),p-=Math.max(0,Math.ceil(p*.1)),m-=Math.max(0,Math.ceil(m*.1)),v=Ni(In.relativeLuminance2(f,p,m),In.relativeLuminance2(c,u,d));return(f<<24|p<<16|m<<8|255)>>>0}e.reduceLuminance=r;function i(o,a,l){let c=o>>24&255,u=o>>16&255,d=o>>8&255,f=a>>24&255,p=a>>16&255,m=a>>8&255,v=Ni(In.relativeLuminance2(f,p,m),In.relativeLuminance2(c,u,d));for(;v<l&&(f<255||p<255||m<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),v=Ni(In.relativeLuminance2(f,p,m),In.relativeLuminance2(c,u,d));return(f<<24|p<<16|m<<8|255)>>>0}e.increaseLuminance=i;function s(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=s})(ph||(ph={}));function no(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Ni(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Kne=class extends Du{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 new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},yf=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new wr}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,s=0,o=0,a=t.getFg(0),l=t.getBg(0);for(let c=0;c<t.getTrimmedLength();c++)if(t.loadCell(c,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==a||this._workCell.bg!==l){if(c-i>1){let u=this._getJoinedRanges(r,o,s,t,i);for(let d=0;d<u.length;d++)n.push(u[d])}i=c,o=s,a=this._workCell.fg,l=this._workCell.bg}s+=this._workCell.getChars().length||Ss.length}if(this._bufferService.cols-i>1){let c=this._getJoinedRanges(r,o,s,t,i);for(let u=0;u<c.length;u++)n.push(c[u])}return n}_getJoinedRanges(e,t,n,r,i){let s=e.substring(t,n),o=[];try{o=this._characterJoiners[0].handler(s)}catch(a){console.error(a)}for(let a=1;a<this._characterJoiners.length;a++)try{let l=this._characterJoiners[a].handler(s);for(let c=0;c<l.length;c++)yf._mergeRanges(o,l[c])}catch(l){console.error(l)}return this._stringRangesToCellRanges(o,r,i),o}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,s=0,o=e[r];if(o){for(let a=n;a<this._bufferService.cols;a++){let l=t.getWidth(a),c=t.getString(a).length||Ss.length;if(l!==0){if(!i&&o[0]<=s&&(o[0]=a,i=!0),o[1]<=s){if(o[1]=a,o=e[++r],!o)break;o[0]<=s?(o[0]=a,i=!0):i=!1}s+=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}};yf=Pt([le(0,zn)],yf);function Gne(e){return 57508<=e&&e<=57558}function Yne(e){return 9472<=e&&e<=9631}function Xne(e){return Gne(e)||Yne(e)}function Qne(){return{css:{canvas:Ad(),cell:Ad()},device:{canvas:Ad(),cell:Ad(),char:{width:0,height:0,left:0,top:0}}}}function Ad(){return{width:0,height:0}}var px=class{constructor(e,t,n,r,i,s,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=s,this._themeService=o,this._workCell=new wr,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,s,o,a,l,c,u){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();n&&m<s+1&&(m=s+1);let v,w=0,x="",_=0,y=0,S=0,C=0,k=!1,N=0,T=!1,O=0,P=0,D=[],R=c!==-1&&u!==-1;for(let A=0;A<m;A++){e.loadCell(A,this._workCell);let M=this._workCell.getWidth();if(M===0)continue;let L=!1,$=A>=P,F=A,B=this._workCell;if(f.length>0&&A===f[0][0]&&$){let _e=f.shift(),tt=this._isCellInSelection(_e[0],t);for(_=_e[0]+1;_<_e[1];_++)$&&($=tt===this._isCellInSelection(_,t));$&&($=!n||s<_e[0]||s>=_e[1]),$?(L=!0,B=new Kne(this._workCell,e.translateToString(!0,_e[0],_e[1]),_e[1]-_e[0]),F=_e[1]-1,M=B.getWidth()):P=_e[1]}let z=this._isCellInSelection(A,t),E=n&&A===s,H=R&&A>=c&&A<=u,q=!1;this._decorationService.forEachDecorationAtCell(A,t,void 0,_e=>{q=!0});let j=B.getChars()||Ss;if(j===" "&&(B.isUnderline()||B.isOverline())&&(j=" "),O=M*a-l.get(j,B.isBold(),B.isItalic()),!v)v=this._document.createElement("span");else if(w&&(z&&T||!z&&!T&&B.bg===y)&&(z&&T&&p.selectionForeground||B.fg===S)&&B.extended.ext===C&&H===k&&O===N&&!E&&!L&&!q&&$){B.isInvisible()?x+=Ss:x+=j,w++;continue}else w&&(v.textContent=x),v=this._document.createElement("span"),w=0,x="";if(y=B.bg,S=B.fg,C=B.extended.ext,k=H,N=O,T=z,L&&s>=A&&s<=F&&(s=A),!this._coreService.isCursorHidden&&E&&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}}if(B.isBold()&&D.push("xterm-bold"),B.isItalic()&&D.push("xterm-italic"),B.isDim()&&D.push("xterm-dim"),B.isInvisible()?x=Ss:x=B.getChars()||Ss,B.isUnderline()&&(D.push(`xterm-underline-${B.extended.underlineStyle}`),x===" "&&(x=" "),!B.isUnderlineColorDefault()))if(B.isUnderlineColorRGB())v.style.textDecorationColor=`rgb(${Du.toColorRGB(B.getUnderlineColor()).join(",")})`;else{let _e=B.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&B.isBold()&&_e<8&&(_e+=8),v.style.textDecorationColor=p.ansi[_e].css}B.isOverline()&&(D.push("xterm-overline"),x===" "&&(x=" ")),B.isStrikethrough()&&D.push("xterm-strikethrough"),H&&(v.style.textDecoration="underline");let ne=B.getFgColor(),ie=B.getFgColorMode(),K=B.getBgColor(),ge=B.getBgColorMode(),Pe=!!B.isInverse();if(Pe){let _e=ne;ne=K,K=_e;let tt=ie;ie=ge,ge=tt}let he,Ae,je=!1;this._decorationService.forEachDecorationAtCell(A,t,void 0,_e=>{_e.options.layer!=="top"&&je||(_e.backgroundColorRGB&&(ge=50331648,K=_e.backgroundColorRGB.rgba>>8&16777215,he=_e.backgroundColorRGB),_e.foregroundColorRGB&&(ie=50331648,ne=_e.foregroundColorRGB.rgba>>8&16777215,Ae=_e.foregroundColorRGB),je=_e.options.layer==="top")}),!je&&z&&(he=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,K=he.rgba>>8&16777215,ge=50331648,je=!0,p.selectionForeground&&(ie=50331648,ne=p.selectionForeground.rgba>>8&16777215,Ae=p.selectionForeground)),je&&D.push("xterm-decoration-top");let $e;switch(ge){case 16777216:case 33554432:$e=p.ansi[K],D.push(`xterm-bg-${K}`);break;case 50331648:$e=Ht.toColor(K>>16,K>>8&255,K&255),this._addStyle(v,`background-color:#${NC((K>>>0).toString(16),"0",6)}`);break;case 0:default:Pe?($e=p.foreground,D.push("xterm-bg-257")):$e=p.background}switch(he||B.isDim()&&(he=pt.multiplyOpacity($e,.5)),ie){case 16777216:case 33554432:B.isBold()&&ne<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ne+=8),this._applyMinimumContrast(v,$e,p.ansi[ne],B,he,void 0)||D.push(`xterm-fg-${ne}`);break;case 50331648:let _e=Ht.toColor(ne>>16&255,ne>>8&255,ne&255);this._applyMinimumContrast(v,$e,_e,B,he,Ae)||this._addStyle(v,`color:#${NC(ne.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(v,$e,p.foreground,B,he,Ae)||Pe&&D.push("xterm-fg-257")}D.length&&(v.className=D.join(" "),D.length=0),!E&&!L&&!q&&$?w++:v.textContent=x,O!==this.defaultSpacing&&(v.style.letterSpacing=`${O}px`),d.push(v),A=F}return v&&w&&(v.textContent=x),d}_applyMinimumContrast(e,t,n,r,i,s){if(this._optionsService.rawOptions.minimumContrastRatio===1||Xne(r.getCode()))return!1;let o=this._getContrastCache(r),a;if(!i&&!s&&(a=o.getColor(t.rgba,n.rgba)),a===void 0){let l=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);a=pt.ensureContrastRatio(i||t,s||n,l),o.setColor((i||t).rgba,(s||n).rgba,a??null)}return a?(this._addStyle(e,`color:${a.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]}};px=Pt([le(1,QM),le(2,$n),le(3,ts),le(4,qo),le(5,Ou),le(6,Tl)],px);function NC(e,t,n){for(;e.length<n;)e=t+e;return e}var Zne=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 s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold",s.style.fontStyle="italic",this._measureElements=[n,r,i,s],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(s),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 o=this._measure(e,0);return o>0&&(this._flat[r]=o),o}let i=e;t&&(i+="B"),n&&(i+="I");let s=this._holey.get(i);if(s===void 0){let o=0;t&&(o|=1),n&&(o|=2),s=this._measure(e,o),s>0&&this._holey.set(i,s)}return s}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},Jne=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,s=t[1]-i,o=n[1]-i,a=Math.max(s,0),l=Math.min(o,e.rows-1);if(a>=e.rows||l<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=s,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=l,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 ere(){return new Jne}var mg="xterm-dom-renderer-owner-",fr="xterm-rows",jd="xterm-fg-",TC="xterm-bg-",ql="xterm-focus",Ld="xterm-selection",tre=1,mx=class extends ze{constructor(e,t,n,r,i,s,o,a,l,c,u,d,f,p){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=s,this._linkifier2=o,this._charSizeService=l,this._optionsService=c,this._bufferService=u,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=tre++,this._rowElements=[],this._selectionRenderModel=ere(),this.onRequestRedraw=this._register(new te).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(fr),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(Ld),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=Qne(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(m=>this._injectCss(m))),this._injectCss(this._themeService.colors),this._rowFactory=a.createInstance(px,document),this._element.classList.add(mg+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(m=>this._handleLinkHover(m))),this._register(this._linkifier2.onHideLinkUnderline(m=>this._handleLinkLeave(m))),this._register(vt(()=>{this._element.classList.remove(mg+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Zne(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 n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${fr} 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} .${fr} { 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} .${fr} .xterm-dim { color: ${pt.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} .${fr}.${ql} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${fr}.${ql} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${fr}.${ql} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${fr} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${fr} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${fr} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${fr} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${fr} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Ld} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ld} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ld} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[s,o]of e.ansi.entries())t+=`${this._terminalSelector} .${jd}${s} { color: ${o.css}; }${this._terminalSelector} .${jd}${s}.xterm-dim { color: ${pt.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${TC}${s} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${jd}257 { color: ${pt.opaque(e.background).css}; }${this._terminalSelector} .${jd}257.xterm-dim { color: ${pt.multiplyOpacity(pt.opaque(e.background),.5).css}; }${this._terminalSelector} .${TC}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 n=this._rowElements.length;n<=t;n++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}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(ql),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(ql),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,s=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(n){let l=e[0]>t[0];a.appendChild(this._createSelectionElement(s,l?t[0]:e[0],l?e[0]:t[0],o-s+1))}else{let l=r===s?e[0]:0,c=s===i?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(s,l,c));let u=o-s-1;if(a.appendChild(this._createSelectionElement(s+1,0,this._bufferService.cols,u)),s!==o){let d=i===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,d))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement("div"),s=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return s+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-s),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${s}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),s=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let l=e;l<=t;l++){let c=l+n.ydisp,u=this._rowElements[l],d=n.lines.get(c);if(!u||!d)break;u.replaceChildren(...this._rowFactory.createRow(d,c,c===r,o,a,i,s,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${mg}${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,s){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 a=this._bufferService.buffer,l=a.ybase+a.y,c=Math.min(a.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=n;p<=r;++p){let m=p+a.ydisp,v=this._rowElements[p],w=a.lines.get(m);if(!v||!w)break;v.replaceChildren(...this._rowFactory.createRow(w,m,m===l,d,f,c,u,this.dimensions.css.cell.width,this._widthCache,s?p===n?e:0:-1,s?(p===r?t:i)-1:-1))}}};mx=Pt([le(7,r1),le(8,Op),le(9,$n),le(10,zn),le(11,qo),le(12,ts),le(13,Tl)],mx);var gx=class extends ze{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new te),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new rre(this._optionsService))}catch{this._measureStrategy=this._register(new nre(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())}};gx=Pt([le(2,$n)],gx);var gA=class extends ze{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)}},nre=class extends gA{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}},rre=class extends gA{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 new 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}},ire=class extends ze{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 sre(this._window)),this._onDprChange=this._register(new te),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new te),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(mn.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ee(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ee(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}},sre=class extends ze{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new il),this._onDprChange=this._register(new te),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(vt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ee(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.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)}},ore=class extends ze{constructor(){super(),this.linkProviders=[],this._register(vt(()=>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 d1(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),s=parseInt(i.getPropertyValue("padding-left")),o=parseInt(i.getPropertyValue("padding-top"));return[t.clientX-r.left-s,t.clientY-r.top-o]}function are(e,t,n,r,i,s,o,a,l){if(!s)return;let c=d1(e,t,n);if(c)return c[0]=Math.ceil((c[0]+(l?o/2:0))/o),c[1]=Math.ceil(c[1]/a),c[0]=Math.min(Math.max(c[0],1),r+(l?1:0)),c[1]=Math.min(Math.max(c[1],1),i),c}var vx=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return are(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=d1(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])}}};vx=Pt([le(0,ns),le(1,Op)],vx);var lre=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):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=[]}},vA={};xte(vA,{getSafariVersion:()=>ure,isChromeOS:()=>bA,isFirefox:()=>xA,isIpad:()=>dre,isIphone:()=>hre,isLegacyEdge:()=>cre,isLinux:()=>h1,isMac:()=>bf,isNode:()=>Bp,isSafari:()=>_A,isWindows:()=>yA});var Bp=typeof process<"u"&&"title"in process,Bu=Bp?"node":navigator.userAgent,zu=Bp?"node":navigator.platform,xA=Bu.includes("Firefox"),cre=Bu.includes("Edge"),_A=/^((?!chrome|android).)*safari/i.test(Bu);function ure(){if(!_A)return 0;let e=Bu.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var bf=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(zu),dre=zu==="iPad",hre=zu==="iPhone",yA=["Windows","Win16","Win32","WinCE"].includes(zu),h1=zu.indexOf("Linux")>=0,bA=/\bCrOS\b/.test(Bu),wA=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),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(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()}},fre=class extends wA{_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())}}},pre=class extends wA{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},wf=!Bp&&"requestIdleCallback"in window?pre:fre,mre=class{constructor(){this._queue=new wf}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},xx=class extends ze{constructor(e,t,n,r,i,s,o,a,l){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=i,this._coreBrowserService=a,this._renderer=this._register(new il),this._pausedResizeTask=new mre,this._observerDisposable=this._register(new il),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 te),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new te),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new te),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new te),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new lre((c,u)=>this._renderRows(c,u),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new gre(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(vt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var c;return(c=this._renderer.value)==null?void 0:c.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(s.onDecorationRegistered(()=>this._fullRefresh())),this._register(s.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(l.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=vt(()=>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),this._needsSelectionRefresh=!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(t=>this.refreshRows(t.start,t.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(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),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(()=>{var n;return(n=this._renderer.value)==null?void 0:n.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,n){var r;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,(r=this._renderer.value)==null||r.handleSelectionChanged(e,t,n)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};xx=Pt([le(2,$n),le(3,Op),le(4,qo),le(5,Ou),le(6,zn),le(7,ts),le(8,Tl)],xx);var gre=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 vre(e,t,n,r){let i=n.buffer.x,s=n.buffer.y;if(!n.buffer.hasScrollback)return yre(i,s,e,t,n,r)+zp(s,t,n,r)+bre(i,s,e,t,n,r);let o;if(s===t)return o=i>e?"D":"C",hu(Math.abs(i-e),du(o,r));o=s>t?"D":"C";let a=Math.abs(s-t),l=_re(s>t?e:i,n)+(a-1)*n.cols+1+xre(s>t?i:e);return hu(l,du(o,r))}function xre(e,t){return e-1}function _re(e,t){return t.cols-e}function yre(e,t,n,r,i,s){return zp(t,r,i,s).length===0?"":hu(kA(e,t,e,t-jo(t,i),!1,i).length,du("D",s))}function zp(e,t,n,r){let i=e-jo(e,n),s=t-jo(t,n),o=Math.abs(i-s)-wre(e,t,n);return hu(o,du(SA(e,t),r))}function bre(e,t,n,r,i,s){let o;zp(t,r,i,s).length>0?o=r-jo(r,i):o=t;let a=r,l=Sre(e,t,n,r,i,s);return hu(kA(e,o,n,a,l==="C",i).length,du(l,s))}function wre(e,t,n){var o;let r=0,i=e-jo(e,n),s=t-jo(t,n);for(let a=0;a<Math.abs(i-s);a++){let l=SA(e,t)==="A"?-1:1;(o=n.buffer.lines.get(i+l*a))!=null&&o.isWrapped&&r++}return r}function jo(e,t){let n=0,r=t.buffer.lines.get(e),i=r==null?void 0:r.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r==null?void 0:r.isWrapped;return n}function Sre(e,t,n,r,i,s){let o;return zp(n,r,i,s).length>0?o=r-jo(r,i):o=t,e<n&&o<=r||e>=n&&o<r?"C":"D"}function SA(e,t){return e>t?"A":"B"}function kA(e,t,n,r,i,s){let o=e,a=t,l="";for(;(o!==n||a!==r)&&a>=0&&a<s.buffer.lines.length;)o+=i?1:-1,i&&o>s.cols-1?(l+=s.buffer.translateBufferLineToString(a,!1,e,o),o=0,e=0,a++):!i&&o<0&&(l+=s.buffer.translateBufferLineToString(a,!1,0,e+1),o=s.cols-1,e=o,a--);return l+s.buffer.translateBufferLineToString(a,!1,e,o)}function du(e,t){let n=t?"O":"[";return V.ESC+n+e}function hu(e,t){e=Math.floor(e);let n="";for(let r=0;r<e;r++)n+=t;return n}var kre=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 IC(e,t){if(e.start.y>e.end.y)throw new 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 gg=50,Cre=15,Ere=50,Nre=500,Tre=" ",Ire=new RegExp(Tre,"g"),_x=class extends ze{constructor(e,t,n,r,i,s,o,a,l){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=s,this._optionsService=o,this._renderService=a,this._coreBrowserService=l,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new wr,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new te),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new te),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new te),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new te),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new kre(this._bufferService),this._activeSelectionMode=0,this._register(vt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.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],s=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let a=n.translateBufferLineToString(o,!0,i,s);r.push(a)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let s=e[1]+1;s<=t[1]-1;s++){let o=n.lines.get(s),a=n.translateBufferLineToString(s,!0);o!=null&&o.isWrapped?r[r.length-1]+=a:r.push(a)}if(e[1]!==t[1]){let s=n.lines.get(t[1]),o=n.translateBufferLineToString(t[1],!0,0,t[0]);s&&s.isWrapped?r[r.length-1]+=o:r.push(o)}}return r.map(i=>i.replace(Ire," ")).join(yA?`\r
560
+ `))}},Jte=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},ene=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},tne=0,dg=class{constructor(e){this.value=e,this.id=tne++}},nne=2,rne,te=class{constructor(e){var t,n,r,i;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new Qte((e==null?void 0:e.onListenerError)??uh,((n=this._options)==null?void 0:n.leakWarningThreshold)??Xte):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new Yte(this._options._profName):void 0,this._deliveryQueue=(i=this._options)==null?void 0:i.deliveryQueue}dispose(){var e,t,n,r;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(n=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||n.call(t),(r=this._leakageMon)==null||r.dispose())}get event(){return this._event??(this._event=(e,t,n)=>{var o,a,l,c,u;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let d=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(d);let f=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],p=new ene(`${d}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(((o=this._options)==null?void 0:o.onListenerError)||uh)(p),ze.None}if(this._disposed)return ze.None;t&&(e=e.bind(t));let r=new dg(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Zte.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof dg?(this._deliveryQueue??(this._deliveryQueue=new ine),this._listeners=[this._listeners,r]):this._listeners.push(r):((l=(a=this._options)==null?void 0:a.onWillAddFirstListener)==null||l.call(a,this),this._listeners=r,(u=(c=this._options)==null?void 0:c.onDidAddFirstListener)==null||u.call(c,this)),this._size++;let s=vt(()=>{i==null||i(),this._removeListener(r)});return n instanceof js?n.add(s):Array.isArray(n)&&n.push(s),s}),this._event}_removeListener(e){var i,s,o,a;if((s=(i=this._options)==null?void 0:i.onWillRemoveListener)==null||s.call(i,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(a=(o=this._options)==null?void 0:o.onDidRemoveLastListener)==null||a.call(o,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)),new Error("Attempted to dispose unknown listener");this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*nne<=t.length){let l=0;for(let c=0;c<t.length;c++)t[c]?t[l++]=t[c]:r&&(this._deliveryQueue.end--,l<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=l}}_deliver(e,t){var r;if(!e)return;let n=((r=this._options)==null?void 0:r.onListenerError)||uh;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,n,r,i;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(n=this._perfMon)==null||n.stop()),(r=this._perfMon)==null||r.start(this._size),this._listeners)if(this._listeners instanceof dg)this._deliver(this._listeners,e);else{let s=this._deliveryQueue;s.enqueue(this,e,this._listeners.length),this._deliverQueue(s)}(i=this._perfMon)==null||i.stop()}hasListeners(){return this._size>0}},ine=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}},rx=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new te,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new te,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let r=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let r=this.getWindowId(n);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};rx.INSTANCE=new rx;var s1=rx;function sne(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}s1.INSTANCE.onDidChangeZoomLevel;function one(e){return s1.INSTANCE.getZoomFactor(e)}s1.INSTANCE.onDidChangeFullscreen;var Il=typeof navigator=="object"?navigator.userAgent:"",ix=Il.indexOf("Firefox")>=0,ane=Il.indexOf("AppleWebKit")>=0,o1=Il.indexOf("Chrome")>=0,lne=!o1&&Il.indexOf("Safari")>=0;Il.indexOf("Electron/")>=0;Il.indexOf("Android")>=0;var hg=!1;if(typeof Li.matchMedia=="function"){let e=Li.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Li.matchMedia("(display-mode: fullscreen)");hg=e.matches,sne(Li,e,({matches:n})=>{hg&&t.matches||(hg=n)})}var Na="en",sx=!1,ox=!1,dh=!1,cA=!1,Rd,hh=Na,pC=Na,cne,Ar,xo=globalThis,pn,p2;typeof xo.vscode<"u"&&typeof xo.vscode.process<"u"?pn=xo.vscode.process:typeof process<"u"&&typeof((p2=process==null?void 0:process.versions)==null?void 0:p2.node)=="string"&&(pn=process);var m2,une=typeof((m2=pn==null?void 0:pn.versions)==null?void 0:m2.electron)=="string",dne=une&&(pn==null?void 0:pn.type)==="renderer",g2;if(typeof pn=="object"){sx=pn.platform==="win32",ox=pn.platform==="darwin",dh=pn.platform==="linux",dh&&pn.env.SNAP&&pn.env.SNAP_REVISION,pn.env.CI||pn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Rd=Na,hh=Na;let e=pn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Rd=t.userLocale,pC=t.osLocale,hh=t.resolvedLanguage||Na,cne=(g2=t.languagePack)==null?void 0:g2.translationsConfigFile}catch{}cA=!0}else typeof navigator=="object"&&!dne?(Ar=navigator.userAgent,sx=Ar.indexOf("Windows")>=0,ox=Ar.indexOf("Macintosh")>=0,(Ar.indexOf("Macintosh")>=0||Ar.indexOf("iPad")>=0||Ar.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,dh=Ar.indexOf("Linux")>=0,(Ar==null?void 0:Ar.indexOf("Mobi"))>=0,hh=globalThis._VSCODE_NLS_LANGUAGE||Na,Rd=navigator.language.toLowerCase(),pC=Rd):console.error("Unable to resolve platform.");var uA=sx,hi=ox,hne=dh,mC=cA,vi=Ar,ls=hh,fne;(e=>{function t(){return ls}e.value=t;function n(){return ls.length===2?ls==="en":ls.length>=3?ls[0]==="e"&&ls[1]==="n"&&ls[2]==="-":!1}e.isDefaultVariant=n;function r(){return ls==="en"}e.isDefault=r})(fne||(fne={}));var pne=typeof xo.postMessage=="function"&&!xo.importScripts;(()=>{if(pne){let e=[];xo.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let r=0,i=e.length;r<i;r++){let s=e[r];if(s.id===n.data.vscodeScheduleAsyncWork){e.splice(r,1),s.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),xo.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var mne=!!(vi&&vi.indexOf("Chrome")>=0);vi&&vi.indexOf("Firefox")>=0;!mne&&vi&&vi.indexOf("Safari")>=0;vi&&vi.indexOf("Edg/")>=0;vi&&vi.indexOf("Android")>=0;var la=typeof navigator=="object"?navigator:{};mC||document.queryCommandSupported&&document.queryCommandSupported("copy")||la&&la.clipboard&&la.clipboard.writeText,mC||la&&la.clipboard&&la.clipboard.readText;var a1=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}},fg=new a1,gC=new a1,vC=new a1,gne=new Array(230),dA;(e=>{function t(a){return fg.keyCodeToStr(a)}e.toString=t;function n(a){return fg.strToKeyCode(a)}e.fromString=n;function r(a){return gC.keyCodeToStr(a)}e.toUserSettingsUS=r;function i(a){return vC.keyCodeToStr(a)}e.toUserSettingsGeneral=i;function s(a){return gC.strToKeyCode(a)||vC.strToKeyCode(a)}e.fromUserSettings=s;function o(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return fg.keyCodeToStr(a)}e.toElectronAccelerator=o})(dA||(dA={}));var vne=class hA{constructor(t,n,r,i,s){this.ctrlKey=t,this.shiftKey=n,this.altKey=r,this.metaKey=i,this.keyCode=s}equals(t){return t instanceof hA&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",r=this.altKey?"1":"0",i=this.metaKey?"1":"0";return`K${t}${n}${r}${i}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new xne([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},xne=class{constructor(e){if(e.length===0)throw Ute("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 _ne(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return dA.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(ix)switch(t){case 59:return 85;case 60:if(hne)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(hi)return 57;break}else if(ane&&(hi&&t===93||!hi&&t===92))return 57;return gne[t]||0}var yne=hi?256:2048,bne=512,wne=1024,Sne=hi?2048:256,xC=class{constructor(e){var n;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=(n=t.getModifierState)==null?void 0:n.call(t,"AltGraph"),this.keyCode=_ne(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|=yne),this.altKey&&(t|=bne),this.shiftKey&&(t|=wne),this.metaKey&&(t|=Sne),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new vne(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},_C=new WeakMap;function kne(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 Cne=class{static getSameOriginWindowChain(e){let t=_C.get(e);if(!t){t=[],_C.set(e,t);let n=e,r;do r=kne(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 s of i){let o=s.window.deref();if(n+=(o==null?void 0:o.scrollY)??0,r+=(o==null?void 0:o.scrollX)??0,o===t||!s.iframeElement)break;let a=s.iframeElement.getBoundingClientRect();n+=a.top,r+=a.left}return{top:n,left:r}}},Md=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=Cne.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},yC=class{constructor(e,t=0,n=0){var i;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(o1){let s=navigator.userAgent.match(/Chrome\/(\d+)/);r=(s?parseInt(s[1]):123)<=122}if(e){let s=e,o=e,a=((i=e.view)==null?void 0:i.devicePixelRatio)||1;if(typeof s.wheelDeltaY<"u")r?this.deltaY=s.wheelDeltaY/(120*a):this.deltaY=s.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(e.type==="wheel"){let l=e;l.deltaMode===l.DOM_DELTA_LINE?ix&&!hi?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof s.wheelDeltaX<"u")lne&&uA?this.deltaX=-(s.wheelDeltaX/120):r?this.deltaX=s.wheelDeltaX/(120*a):this.deltaX=s.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let l=e;l.deltaMode===l.DOM_DELTA_LINE?ix&&!hi?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*a):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},fA=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),Ene;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof Nne?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:mn.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:fA})})(Ene||(Ene={}));var Nne=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?fA:(this._emitter||(this._emitter=new te),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},l1=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 Z0("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Z0("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Tne=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new Z0("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=vt(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Ine;(e=>{async function t(r){let i,s=await Promise.all(r.map(o=>o.then(a=>a,a=>{i||(i=a)})));if(typeof i<"u")throw i;return s}e.settled=t;function n(r){return new Promise(async(i,s)=>{try{await r(i,s)}catch(o){s(o)}})}e.withAsyncBody=n})(Ine||(Ine={}));var bC=class pr{static fromArray(t){return new pr(n=>{n.emitMany(t)})}static fromPromise(t){return new pr(async n=>{n.emitMany(await t)})}static fromPromises(t){return new pr(async n=>{await Promise.all(t.map(async r=>n.emitOne(await r)))})}static merge(t){return new pr(async n=>{await Promise.all(t.map(async r=>{for await(let i of r)n.emitOne(i)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new te,queueMicrotask(async()=>{let r={emitOne:i=>this.emitOne(i),emitMany:i=>this.emitMany(i),reject:i=>this.reject(i)};try{await Promise.resolve(t(r)),this.resolve()}catch(i){this.reject(i)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await mn.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var n;return(n=this._onReturn)==null||n.call(this),{done:!0,value:void 0}}}}static map(t,n){return new pr(async r=>{for await(let i of t)r.emitOne(n(i))})}map(t){return pr.map(this,t)}static filter(t,n){return new pr(async r=>{for await(let i of t)n(i)&&r.emitOne(i)})}filter(t){return pr.filter(this,t)}static coalesce(t){return pr.filter(t,n=>!!n)}coalesce(){return pr.coalesce(this)}static async toPromise(t){let n=[];for await(let r of t)n.push(r);return n}toPromise(){return pr.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};bC.EMPTY=bC.fromArray([]);var{getWindow:oi,getWindowId:Pne,onDidRegisterWindow:Rne}=function(){let e=new Map,t={window:Li,disposables:new js};e.set(Li.vscodeWindowId,t);let n=new te,r=new te,i=new te;function s(o,a){return(typeof o=="number"?e.get(o):void 0)??(a?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(o){if(e.has(o.vscodeWindowId))return ze.None;let a=new js,l={window:o,disposables:a.add(new js)};return e.set(o.vscodeWindowId,l),a.add(vt(()=>{e.delete(o.vscodeWindowId),r.fire(o)})),a.add(Ee(o,nn.BEFORE_UNLOAD,()=>{i.fire(o)})),n.fire(l),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.has(o)},getWindowById:s,getWindow(o){var c;let a=o;if((c=a==null?void 0:a.ownerDocument)!=null&&c.defaultView)return a.ownerDocument.defaultView.window;let l=o;return l!=null&&l.view?l.view.window:Li},getDocument(o){return oi(o).document}}}(),Mne=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,this._handler=null)}};function Ee(e,t,n,r){return new Mne(e,t,n,r)}var wC=function(e,t,n,r){return Ee(e,t,n,r)},c1,Ane=class extends Tne{constructor(e){super(),this.defaultTarget=e&&oi(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},SC=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){uh(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=s=>{n.set(s,!1);let o=e.get(s)??[];for(t.set(s,o),e.set(s,[]),r.set(s,!0);o.length>0;)o.sort(SC.sort),o.shift().execute();r.set(s,!1)};c1=(s,o,a=0)=>{let l=Pne(s),c=new SC(o,a),u=e.get(l);return u||(u=[],e.set(l,u)),u.push(c),n.get(l)||(n.set(l,!0),s.requestAnimationFrame(()=>i(l))),c}})();function jne(e){let t=e.getBoundingClientRect(),n=oi(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var nn={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},Lne=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=Hn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Hn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Hn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Hn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Hn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Hn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Hn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Hn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Hn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Hn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Hn(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=Hn(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=Hn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Hn(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 Hn(e){return typeof e=="number"?`${e}px`:e}function Tc(e){return new Lne(e)}var pA=class{constructor(){this._hooks=new js,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 s=e;try{e.setPointerCapture(t),this._hooks.add(vt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{s=oi(e)}this._hooks.add(Ee(s,nn.POINTER_MOVE,o=>{if(o.buttons!==n){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(Ee(s,nn.POINTER_UP,o=>this.stopMonitoring(!0)))}};function Dne(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 new Error("not supported");let s=`$memoize$${t}`;n[r]=function(...o){return this.hasOwnProperty(s)||Object.defineProperty(this,s,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,o)}),this[s]}}var Qr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Qr||(Qr={}));var ac=class bn extends ze{constructor(){super(),this.dispatched=!1,this.targets=new fC,this.ignoreTargets=new fC,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(mn.runAndSubscribe(Rne,({window:t,disposables:n})=>{n.add(Ee(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),n.add(Ee(t.document,"touchend",r=>this.onTouchEnd(t,r))),n.add(Ee(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:Li,disposables:this._store}))}static addTarget(t){if(!bn.isTouchDevice())return ze.None;bn.INSTANCE||(bn.INSTANCE=new bn);let n=bn.INSTANCE.targets.push(t);return vt(n)}static ignoreTarget(t){if(!bn.isTouchDevice())return ze.None;bn.INSTANCE||(bn.INSTANCE=new bn);let n=bn.INSTANCE.ignoreTargets.push(t);return vt(n)}static isTouchDevice(){return"ontouchstart"in Li||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,i=t.targetTouches.length;r<i;r++){let s=t.targetTouches.item(r);this.activeTouches[s.identifier]={id:s.identifier,initialTarget:s.target,initialTimeStamp:n,initialPageX:s.pageX,initialPageY:s.pageY,rollingTimestamps:[n],rollingPageX:[s.pageX],rollingPageY:[s.pageY]};let o=this.newGestureEvent(Qr.Start,s.target);o.pageX=s.pageX,o.pageY=s.pageY,this.dispatchEvent(o)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let r=Date.now(),i=Object.keys(this.activeTouches).length;for(let s=0,o=n.changedTouches.length;s<o;s++){let a=n.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let l=this.activeTouches[a.identifier],c=Date.now()-l.initialTimeStamp;if(c<bn.HOLD_DELAY&&Math.abs(l.initialPageX-Zn(l.rollingPageX))<30&&Math.abs(l.initialPageY-Zn(l.rollingPageY))<30){let u=this.newGestureEvent(Qr.Tap,l.initialTarget);u.pageX=Zn(l.rollingPageX),u.pageY=Zn(l.rollingPageY),this.dispatchEvent(u)}else if(c>=bn.HOLD_DELAY&&Math.abs(l.initialPageX-Zn(l.rollingPageX))<30&&Math.abs(l.initialPageY-Zn(l.rollingPageY))<30){let u=this.newGestureEvent(Qr.Contextmenu,l.initialTarget);u.pageX=Zn(l.rollingPageX),u.pageY=Zn(l.rollingPageY),this.dispatchEvent(u)}else if(i===1){let u=Zn(l.rollingPageX),d=Zn(l.rollingPageY),f=Zn(l.rollingTimestamps)-l.rollingTimestamps[0],p=u-l.rollingPageX[0],m=d-l.rollingPageY[0],v=[...this.targets].filter(w=>l.initialTarget instanceof Node&&w.contains(l.initialTarget));this.inertia(t,v,r,Math.abs(p)/f,p>0?1:-1,u,Math.abs(m)/f,m>0?1:-1,d)}this.dispatchEvent(this.newGestureEvent(Qr.End,l.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let r=document.createEvent("CustomEvent");return r.initEvent(t,!1,!0),r.initialTarget=n,r.tapCount=0,r}dispatchEvent(t){if(t.type===Qr.Tap){let n=new Date().getTime(),r=0;n-this._lastSetTapCountTime>bn.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===Qr.Change||t.type===Qr.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let n=[];for(let r of this.targets)if(r.contains(t.initialTarget)){let i=0,s=t.initialTarget;for(;s&&s!==r;)i++,s=s.parentElement;n.push([i,r])}n.sort((r,i)=>r[0]-i[0]);for(let[r,i]of n)i.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,i,s,o,a,l,c){this.handle=c1(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=bn.SCROLL_FRICTION*d,a+=bn.SCROLL_FRICTION*d,i>0&&(m=!1,f=s*i*d),a>0&&(m=!1,p=l*a*d);let v=this.newGestureEvent(Qr.Change);v.translationX=f,v.translationY=p,n.forEach(w=>w.dispatchEvent(v)),m||this.inertia(t,n,u,i,s,o+f,a,l,c+p)})}onTouchMove(t){let n=Date.now();for(let r=0,i=t.changedTouches.length;r<i;r++){let s=t.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(String(s.identifier))){console.warn("end of an UNKNOWN touch",s);continue}let o=this.activeTouches[s.identifier],a=this.newGestureEvent(Qr.Change,o.initialTarget);a.translationX=s.pageX-Zn(o.rollingPageX),a.translationY=s.pageY-Zn(o.rollingPageY),a.pageX=s.pageX,a.pageY=s.pageY,this.dispatchEvent(a),o.rollingPageX.length>3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(s.pageX),o.rollingPageY.push(s.pageY),o.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};ac.SCROLL_FRICTION=-.005,ac.HOLD_DELAY=700,ac.CLEAR_TAP_COUNT_TIME=400,Pt([Dne],ac,"isTouchDevice",1);var One=ac,u1=class extends ze{onclick(e,t){this._register(Ee(e,nn.CLICK,n=>t(new Md(oi(e),n))))}onmousedown(e,t){this._register(Ee(e,nn.MOUSE_DOWN,n=>t(new Md(oi(e),n))))}onmouseover(e,t){this._register(Ee(e,nn.MOUSE_OVER,n=>t(new Md(oi(e),n))))}onmouseleave(e,t){this._register(Ee(e,nn.MOUSE_LEAVE,n=>t(new Md(oi(e),n))))}onkeydown(e,t){this._register(Ee(e,nn.KEY_DOWN,n=>t(new xC(n))))}onkeyup(e,t){this._register(Ee(e,nn.KEY_UP,n=>t(new xC(n))))}oninput(e,t){this._register(Ee(e,nn.INPUT,t))}onblur(e,t){this._register(Ee(e,nn.BLUR,t))}onfocus(e,t){this._register(Ee(e,nn.FOCUS,t))}onchange(e,t){this._register(Ee(e,nn.CHANGE,t))}ignoreGesture(e){return One.ignoreTarget(e)}},kC=11,Bne=class extends u1{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=kC+"px",this.domNode.style.height=kC+"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 pA),this._register(wC(this.bgDomNode,nn.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(wC(this.domNode,nn.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Ane),this._pointerdownScheduleRepeatTimer=this._register(new l1)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,oi(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},zne=class ax{constructor(t,n,r,i,s,o,a){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,r=r|0,i=i|0,s=s|0,o=o|0,a=a|0),this.rawScrollLeft=i,this.rawScrollTop=a,n<0&&(n=0),i+n>r&&(i=r-n),i<0&&(i=0),s<0&&(s=0),a+s>o&&(a=o-s),a<0&&(a=0),this.width=n,this.scrollWidth=r,this.scrollLeft=i,this.height=s,this.scrollHeight=o,this.scrollTop=a}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new ax(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 ax(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(t,n){let r=this.width!==t.width,i=this.scrollWidth!==t.scrollWidth,s=this.scrollLeft!==t.scrollLeft,o=this.height!==t.height,a=this.scrollHeight!==t.scrollHeight,l=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:r,scrollWidthChanged:i,scrollLeftChanged:s,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:l}}},$ne=class extends ze{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new zne(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var r;let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),(r=this._smoothScrolling)==null||r.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(),this._smoothScrolling=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;t?r=new EC(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=EC.start(this._state,n,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)))}},CC=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function pg(e,t){let n=t-e;return function(r){return e+n*Une(r)}}function Fne(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var EC=class lx{constructor(t,n,r,i){this.from=t,this.to=n,this.duration=i,this.startTime=r,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(t,n,r){if(Math.abs(t-n)>2.5*r){let i,s;return t<n?(i=t+.75*r,s=n-.75*r):(i=t-.75*r,s=n+.75*r),Fne(pg(t,i),pg(s,n),.33)}return pg(t,n)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let n=(t-this.startTime)/this.duration;if(n<1){let r=this.scrollLeft(n),i=this.scrollTop(n);return new CC(r,i,!1)}return new CC(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return lx.start(t,n,r)}static start(t,n,r){r=r+10;let i=Date.now()-10;return new lx(t,n,i,r)}};function Hne(e){return Math.pow(e,3)}function Une(e){return 1-Hne(1-e)}var Wne=class extends ze{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 l1)}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?!0: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(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},Vne=140,mA=class extends u1{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 Wne(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new pA),this._shouldRender=!0,this.domNode=Tc(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(Ee(this.domNode.domNode,nn.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Bne(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=Tc(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(Ee(this.slider.domNode,nn.POINTER_DOWN,i=>{i.button===0&&(i.preventDefault(),this._sliderPointerDown(i))})),this.onclick(this.slider.domNode,i=>{i.leftButton&&i.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 i=jne(this.domNode.domNode);t=e.pageX-i.left,n=e.pageY-i.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,i=>{let s=this._sliderOrthogonalPointerPosition(i),o=Math.abs(s-n);if(uA&&o>Vne){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let a=this._sliderPointerPosition(i)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(a))},()=>{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()}},gA=class cx{constructor(t,n,r,i,s,o){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=i,this._scrollSize=s,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new cx(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,r,i,s){let o=Math.max(0,r-t),a=Math.max(0,o-2*n),l=i>0&&i>r;if(!l)return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(r*a/i))),u=(a-c)/(i-r),d=s*u;return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(c),computedSliderRatio:u,computedSliderPosition:Math.round(d)}}_refreshComputedValues(){let t=cx._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(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,r=this._scrollPosition;return n<this._computedSliderPosition?r-=this._visibleSize:r+=this._visibleSize,r}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+t;return Math.round(n/this._computedSliderRatio)}},qne=class extends mA{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new gA(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 new 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}},Kne=class extends mA{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new gA(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 new 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}},Gne=500,NC=50,Yne=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},ux=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,n=0,r=1,i=this._rear;do{let s=i===this._front?t:Math.pow(2,-r);if(t-=s,n+=this._memory[i].score*s,i===this._front)break;i=(this._capacity+i-1)%this._capacity,r++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(o1){let n=oi(t.browserEvent),r=one(n);this.accept(Date.now(),t.deltaX*r,t.deltaY*r)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,n,r){let i=null,s=new Yne(t,n,r);this._front===-1&&this._rear===-1?(this._memory[0]=s,this._front=0,this._rear=0):(i=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]=s),s.score=this._computeScore(s,i)}_computeScore(t,n){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let r=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(r+=.25),n){let i=Math.abs(t.deltaX),s=Math.abs(t.deltaY),o=Math.abs(n.deltaX),a=Math.abs(n.deltaY),l=Math.max(Math.min(i,o),1),c=Math.max(Math.min(s,a),1),u=Math.max(i,o),d=Math.max(s,a);u%l===0&&d%c===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};ux.INSTANCE=new ux;var Xne=ux,Qne=class extends u1{constructor(e,t,n){super(),this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new te),this.onWillScroll=this._onWillScroll.event,this._options=Jne(t),this._scrollable=n,this._register(this._scrollable.onScroll(i=>{this._onWillScroll.fire(i),this._onDidScroll(i),this._onScroll.fire(i)}));let r={onMouseWheel:i=>this._onMouseWheel(i),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Kne(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new qne(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=Tc(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Tc(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Tc(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,i=>this._onMouseOver(i)),this.onmouseleave(this._listenOnDomNode,i=>this._onMouseLeave(i)),this._hideTimeout=this._register(new l1),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Ao(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,hi&&(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 yC(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Ao(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new yC(n))};this._mouseWheelToDispose.push(Ee(this._listenOnDomNode,nn.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var i;if((i=e.browserEvent)!=null&&i.defaultPrevented)return;let t=Xne.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let s=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+s===0?o=s=0:Math.abs(s)>=Math.abs(o)?o=0:s=0),this._options.flipAxes&&([s,o]=[o,s]);let a=!hi&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=s,s=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,s=s*this._options.fastScrollSensitivity);let l=this._scrollable.getFutureScrollPosition(),c={};if(s){let u=NC*s,d=l.scrollTop-(u<0?Math.floor(u):Math.ceil(u));this._verticalScrollbar.writeScrollPosition(c,d)}if(o){let u=NC*o,d=l.scrollLeft-(u<0?Math.floor(u):Math.ceil(u));this._horizontalScrollbar.writeScrollPosition(c,d)}c=this._scrollable.validateScrollPosition(c),(l.scrollLeft!==c.scrollLeft||l.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),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 new 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":"",s=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${s}${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(),Gne)}},Zne=class extends Qne{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 Jne(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,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:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,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:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,hi&&(t.className+=" mac"),t}var dx=class extends ze{constructor(e,t,n,r,i,s,o,a){super(),this._bufferService=n,this._optionsService=o,this._renderService=a,this._onRequestScrollLines=this._register(new te),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let l=this._register(new $ne({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>c1(r.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{l.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Zne(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},l)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(mn.runAndSubscribe(s.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=s.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(vt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(vt(()=>this._styleElement.remove())),this._register(mn.runAndSubscribe(s.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${s.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${s.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${s.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
561
+ `)})),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(c=>this._handleScroll(c)))}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(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.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}};dx=Pt([le(2,zn),le(3,ts),le(4,XM),le(5,Tl),le(6,$n),le(7,ns)],dx);var hx=class extends ze{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(s=>this._removeDecoration(s))),this._register(vt(()=>{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){var r;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((r=e==null?void 0:e.options)==null?void 0:r.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){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};hx=Pt([le(1,zn),le(2,ts),le(3,Ou),le(4,ns)],hx);var ere=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)}},Yr={full:0,left:0,center:0,right:0},cs={full:0,left:0,center:0,right:0},Vl={full:0,left:0,center:0,right:0},_f=class extends ze{constructor(e,t,n,r,i,s,o,a){var c;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=s,this._themeService=o,this._coreBrowserService=a,this._colorZoneStore=new ere,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(),(c=this._viewportElement.parentElement)==null||c.insertBefore(this._canvas,this._viewportElement),this._register(vt(()=>{var u;return(u=this._canvas)==null?void 0:u.remove()}));let l=this._canvas.getContext("2d");if(l)this._ctx=l;else throw new 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(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);cs.full=this._canvas.width,cs.left=e,cs.center=t,cs.right=e,this._refreshDrawHeightConstants(),Vl.full=1,Vl.left=1,Vl.center=1+cs.left,Vl.right=1+cs.left+cs.center}_refreshDrawHeightConstants(){Yr.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);Yr.left=t,Yr.center=t,Yr.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Yr.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Yr.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Yr.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Yr.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 t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);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(Vl[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Yr[e.position||"full"]/2),cs[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Yr[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}))}};_f=Pt([le(2,zn),le(3,Ou),le(4,ns),le(5,$n),le(6,Tl),le(7,ts)],_f);var V;(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=`
562
+ `,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=""))(V||(V={}));var fh;(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="Ÿ"))(fh||(fh={}));var vA;(e=>e.ST=`${V.ESC}\\`)(vA||(vA={}));var fx=class{constructor(e,t,n,r,i,s){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=s,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 t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!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(`${V.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 t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,r=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,i=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=i+"px",this._compositionView.style.top=r+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let s=this._compositionView.getBoundingClientRect();this._textarea.style.left=i+"px",this._textarea.style.top=r+"px",this._textarea.style.width=Math.max(s.width,1)+"px",this._textarea.style.height=Math.max(s.height,1)+"px",this._textarea.style.lineHeight=s.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};fx=Pt([le(2,zn),le(3,$n),le(4,qo),le(5,ns)],fx);var sn=0,on=0,an=0,Et=0,TC={css:"#00000000",rgba:0},Ht;(e=>{function t(i,s,o,a){return a!==void 0?`#${no(i)}${no(s)}${no(o)}${no(a)}`:`#${no(i)}${no(s)}${no(o)}`}e.toCss=t;function n(i,s,o,a=255){return(i<<24|s<<16|o<<8|a)>>>0}e.toRgba=n;function r(i,s,o,a){return{css:e.toCss(i,s,o,a),rgba:e.toRgba(i,s,o,a)}}e.toColor=r})(Ht||(Ht={}));var pt;(e=>{function t(l,c){if(Et=(c.rgba&255)/255,Et===1)return{css:c.css,rgba:c.rgba};let u=c.rgba>>24&255,d=c.rgba>>16&255,f=c.rgba>>8&255,p=l.rgba>>24&255,m=l.rgba>>16&255,v=l.rgba>>8&255;sn=p+Math.round((u-p)*Et),on=m+Math.round((d-m)*Et),an=v+Math.round((f-v)*Et);let w=Ht.toCss(sn,on,an),x=Ht.toRgba(sn,on,an);return{css:w,rgba:x}}e.blend=t;function n(l){return(l.rgba&255)===255}e.isOpaque=n;function r(l,c,u){let d=ph.ensureContrastRatio(l.rgba,c.rgba,u);if(d)return Ht.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=r;function i(l){let c=(l.rgba|255)>>>0;return[sn,on,an]=ph.toChannels(c),{css:Ht.toCss(sn,on,an),rgba:c}}e.opaque=i;function s(l,c){return Et=Math.round(c*255),[sn,on,an]=ph.toChannels(l.rgba),{css:Ht.toCss(sn,on,an,Et),rgba:Ht.toRgba(sn,on,an,Et)}}e.opacity=s;function o(l,c){return Et=l.rgba&255,s(l,Et*c/255)}e.multiplyOpacity=o;function a(l){return[l.rgba>>24&255,l.rgba>>16&255,l.rgba>>8&255]}e.toColorRGB=a})(pt||(pt={}));var yt;(e=>{let t,n;try{let i=document.createElement("canvas");i.width=1,i.height=1;let s=i.getContext("2d",{willReadFrequently:!0});s&&(t=s,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function r(i){if(i.match(/#[\da-f]{3,8}/i))switch(i.length){case 4:return sn=parseInt(i.slice(1,2).repeat(2),16),on=parseInt(i.slice(2,3).repeat(2),16),an=parseInt(i.slice(3,4).repeat(2),16),Ht.toColor(sn,on,an);case 5:return sn=parseInt(i.slice(1,2).repeat(2),16),on=parseInt(i.slice(2,3).repeat(2),16),an=parseInt(i.slice(3,4).repeat(2),16),Et=parseInt(i.slice(4,5).repeat(2),16),Ht.toColor(sn,on,an,Et);case 7:return{css:i,rgba:(parseInt(i.slice(1),16)<<8|255)>>>0};case 9:return{css:i,rgba:parseInt(i.slice(1),16)>>>0}}let s=i.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(s)return sn=parseInt(s[1]),on=parseInt(s[2]),an=parseInt(s[3]),Et=Math.round((s[5]===void 0?1:parseFloat(s[5]))*255),Ht.toColor(sn,on,an,Et);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=i,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[sn,on,an,Et]=t.getImageData(0,0,1,1).data,Et!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ht.toRgba(sn,on,an,Et),css:i}}e.toColor=r})(yt||(yt={}));var In;(e=>{function t(r){return n(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function n(r,i,s){let o=r/255,a=i/255,l=s/255,c=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),u=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4);return c*.2126+u*.7152+d*.0722}e.relativeLuminance2=n})(In||(In={}));var ph;(e=>{function t(o,a){if(Et=(a&255)/255,Et===1)return a;let l=a>>24&255,c=a>>16&255,u=a>>8&255,d=o>>24&255,f=o>>16&255,p=o>>8&255;return sn=d+Math.round((l-d)*Et),on=f+Math.round((c-f)*Et),an=p+Math.round((u-p)*Et),Ht.toRgba(sn,on,an)}e.blend=t;function n(o,a,l){let c=In.relativeLuminance(o>>8),u=In.relativeLuminance(a>>8);if(Ni(c,u)<l){if(u<c){let p=r(o,a,l),m=Ni(c,In.relativeLuminance(p>>8));if(m<l){let v=i(o,a,l),w=Ni(c,In.relativeLuminance(v>>8));return m>w?p:v}return p}let d=i(o,a,l),f=Ni(c,In.relativeLuminance(d>>8));if(f<l){let p=r(o,a,l),m=Ni(c,In.relativeLuminance(p>>8));return f>m?d:p}return d}}e.ensureContrastRatio=n;function r(o,a,l){let c=o>>24&255,u=o>>16&255,d=o>>8&255,f=a>>24&255,p=a>>16&255,m=a>>8&255,v=Ni(In.relativeLuminance2(f,p,m),In.relativeLuminance2(c,u,d));for(;v<l&&(f>0||p>0||m>0);)f-=Math.max(0,Math.ceil(f*.1)),p-=Math.max(0,Math.ceil(p*.1)),m-=Math.max(0,Math.ceil(m*.1)),v=Ni(In.relativeLuminance2(f,p,m),In.relativeLuminance2(c,u,d));return(f<<24|p<<16|m<<8|255)>>>0}e.reduceLuminance=r;function i(o,a,l){let c=o>>24&255,u=o>>16&255,d=o>>8&255,f=a>>24&255,p=a>>16&255,m=a>>8&255,v=Ni(In.relativeLuminance2(f,p,m),In.relativeLuminance2(c,u,d));for(;v<l&&(f<255||p<255||m<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),v=Ni(In.relativeLuminance2(f,p,m),In.relativeLuminance2(c,u,d));return(f<<24|p<<16|m<<8|255)>>>0}e.increaseLuminance=i;function s(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=s})(ph||(ph={}));function no(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Ni(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var tre=class extends Du{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 new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},yf=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new wr}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,s=0,o=0,a=t.getFg(0),l=t.getBg(0);for(let c=0;c<t.getTrimmedLength();c++)if(t.loadCell(c,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==a||this._workCell.bg!==l){if(c-i>1){let u=this._getJoinedRanges(r,o,s,t,i);for(let d=0;d<u.length;d++)n.push(u[d])}i=c,o=s,a=this._workCell.fg,l=this._workCell.bg}s+=this._workCell.getChars().length||Ss.length}if(this._bufferService.cols-i>1){let c=this._getJoinedRanges(r,o,s,t,i);for(let u=0;u<c.length;u++)n.push(c[u])}return n}_getJoinedRanges(e,t,n,r,i){let s=e.substring(t,n),o=[];try{o=this._characterJoiners[0].handler(s)}catch(a){console.error(a)}for(let a=1;a<this._characterJoiners.length;a++)try{let l=this._characterJoiners[a].handler(s);for(let c=0;c<l.length;c++)yf._mergeRanges(o,l[c])}catch(l){console.error(l)}return this._stringRangesToCellRanges(o,r,i),o}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,s=0,o=e[r];if(o){for(let a=n;a<this._bufferService.cols;a++){let l=t.getWidth(a),c=t.getString(a).length||Ss.length;if(l!==0){if(!i&&o[0]<=s&&(o[0]=a,i=!0),o[1]<=s){if(o[1]=a,o=e[++r],!o)break;o[0]<=s?(o[0]=a,i=!0):i=!1}s+=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}};yf=Pt([le(0,zn)],yf);function nre(e){return 57508<=e&&e<=57558}function rre(e){return 9472<=e&&e<=9631}function ire(e){return nre(e)||rre(e)}function sre(){return{css:{canvas:Ad(),cell:Ad()},device:{canvas:Ad(),cell:Ad(),char:{width:0,height:0,left:0,top:0}}}}function Ad(){return{width:0,height:0}}var px=class{constructor(e,t,n,r,i,s,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=s,this._themeService=o,this._workCell=new wr,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,s,o,a,l,c,u){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();n&&m<s+1&&(m=s+1);let v,w=0,x="",_=0,y=0,S=0,C=0,k=!1,N=0,T=!1,O=0,P=0,D=[],R=c!==-1&&u!==-1;for(let A=0;A<m;A++){e.loadCell(A,this._workCell);let M=this._workCell.getWidth();if(M===0)continue;let L=!1,$=A>=P,F=A,B=this._workCell;if(f.length>0&&A===f[0][0]&&$){let _e=f.shift(),tt=this._isCellInSelection(_e[0],t);for(_=_e[0]+1;_<_e[1];_++)$&&($=tt===this._isCellInSelection(_,t));$&&($=!n||s<_e[0]||s>=_e[1]),$?(L=!0,B=new tre(this._workCell,e.translateToString(!0,_e[0],_e[1]),_e[1]-_e[0]),F=_e[1]-1,M=B.getWidth()):P=_e[1]}let z=this._isCellInSelection(A,t),E=n&&A===s,H=R&&A>=c&&A<=u,q=!1;this._decorationService.forEachDecorationAtCell(A,t,void 0,_e=>{q=!0});let j=B.getChars()||Ss;if(j===" "&&(B.isUnderline()||B.isOverline())&&(j=" "),O=M*a-l.get(j,B.isBold(),B.isItalic()),!v)v=this._document.createElement("span");else if(w&&(z&&T||!z&&!T&&B.bg===y)&&(z&&T&&p.selectionForeground||B.fg===S)&&B.extended.ext===C&&H===k&&O===N&&!E&&!L&&!q&&$){B.isInvisible()?x+=Ss:x+=j,w++;continue}else w&&(v.textContent=x),v=this._document.createElement("span"),w=0,x="";if(y=B.bg,S=B.fg,C=B.extended.ext,k=H,N=O,T=z,L&&s>=A&&s<=F&&(s=A),!this._coreService.isCursorHidden&&E&&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}}if(B.isBold()&&D.push("xterm-bold"),B.isItalic()&&D.push("xterm-italic"),B.isDim()&&D.push("xterm-dim"),B.isInvisible()?x=Ss:x=B.getChars()||Ss,B.isUnderline()&&(D.push(`xterm-underline-${B.extended.underlineStyle}`),x===" "&&(x=" "),!B.isUnderlineColorDefault()))if(B.isUnderlineColorRGB())v.style.textDecorationColor=`rgb(${Du.toColorRGB(B.getUnderlineColor()).join(",")})`;else{let _e=B.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&B.isBold()&&_e<8&&(_e+=8),v.style.textDecorationColor=p.ansi[_e].css}B.isOverline()&&(D.push("xterm-overline"),x===" "&&(x=" ")),B.isStrikethrough()&&D.push("xterm-strikethrough"),H&&(v.style.textDecoration="underline");let ne=B.getFgColor(),ie=B.getFgColorMode(),K=B.getBgColor(),ge=B.getBgColorMode(),Pe=!!B.isInverse();if(Pe){let _e=ne;ne=K,K=_e;let tt=ie;ie=ge,ge=tt}let he,Ae,je=!1;this._decorationService.forEachDecorationAtCell(A,t,void 0,_e=>{_e.options.layer!=="top"&&je||(_e.backgroundColorRGB&&(ge=50331648,K=_e.backgroundColorRGB.rgba>>8&16777215,he=_e.backgroundColorRGB),_e.foregroundColorRGB&&(ie=50331648,ne=_e.foregroundColorRGB.rgba>>8&16777215,Ae=_e.foregroundColorRGB),je=_e.options.layer==="top")}),!je&&z&&(he=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,K=he.rgba>>8&16777215,ge=50331648,je=!0,p.selectionForeground&&(ie=50331648,ne=p.selectionForeground.rgba>>8&16777215,Ae=p.selectionForeground)),je&&D.push("xterm-decoration-top");let $e;switch(ge){case 16777216:case 33554432:$e=p.ansi[K],D.push(`xterm-bg-${K}`);break;case 50331648:$e=Ht.toColor(K>>16,K>>8&255,K&255),this._addStyle(v,`background-color:#${IC((K>>>0).toString(16),"0",6)}`);break;case 0:default:Pe?($e=p.foreground,D.push("xterm-bg-257")):$e=p.background}switch(he||B.isDim()&&(he=pt.multiplyOpacity($e,.5)),ie){case 16777216:case 33554432:B.isBold()&&ne<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ne+=8),this._applyMinimumContrast(v,$e,p.ansi[ne],B,he,void 0)||D.push(`xterm-fg-${ne}`);break;case 50331648:let _e=Ht.toColor(ne>>16&255,ne>>8&255,ne&255);this._applyMinimumContrast(v,$e,_e,B,he,Ae)||this._addStyle(v,`color:#${IC(ne.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(v,$e,p.foreground,B,he,Ae)||Pe&&D.push("xterm-fg-257")}D.length&&(v.className=D.join(" "),D.length=0),!E&&!L&&!q&&$?w++:v.textContent=x,O!==this.defaultSpacing&&(v.style.letterSpacing=`${O}px`),d.push(v),A=F}return v&&w&&(v.textContent=x),d}_applyMinimumContrast(e,t,n,r,i,s){if(this._optionsService.rawOptions.minimumContrastRatio===1||ire(r.getCode()))return!1;let o=this._getContrastCache(r),a;if(!i&&!s&&(a=o.getColor(t.rgba,n.rgba)),a===void 0){let l=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);a=pt.ensureContrastRatio(i||t,s||n,l),o.setColor((i||t).rgba,(s||n).rgba,a??null)}return a?(this._addStyle(e,`color:${a.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]}};px=Pt([le(1,JM),le(2,$n),le(3,ts),le(4,qo),le(5,Ou),le(6,Tl)],px);function IC(e,t,n){for(;e.length<n;)e=t+e;return e}var ore=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 s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold",s.style.fontStyle="italic",this._measureElements=[n,r,i,s],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(s),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 o=this._measure(e,0);return o>0&&(this._flat[r]=o),o}let i=e;t&&(i+="B"),n&&(i+="I");let s=this._holey.get(i);if(s===void 0){let o=0;t&&(o|=1),n&&(o|=2),s=this._measure(e,o),s>0&&this._holey.set(i,s)}return s}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},are=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,s=t[1]-i,o=n[1]-i,a=Math.max(s,0),l=Math.min(o,e.rows-1);if(a>=e.rows||l<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=s,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=l,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 lre(){return new are}var mg="xterm-dom-renderer-owner-",fr="xterm-rows",jd="xterm-fg-",PC="xterm-bg-",ql="xterm-focus",Ld="xterm-selection",cre=1,mx=class extends ze{constructor(e,t,n,r,i,s,o,a,l,c,u,d,f,p){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=s,this._linkifier2=o,this._charSizeService=l,this._optionsService=c,this._bufferService=u,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=cre++,this._rowElements=[],this._selectionRenderModel=lre(),this.onRequestRedraw=this._register(new te).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(fr),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(Ld),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=sre(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(m=>this._injectCss(m))),this._injectCss(this._themeService.colors),this._rowFactory=a.createInstance(px,document),this._element.classList.add(mg+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(m=>this._handleLinkHover(m))),this._register(this._linkifier2.onHideLinkUnderline(m=>this._handleLinkLeave(m))),this._register(vt(()=>{this._element.classList.remove(mg+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new ore(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 n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${fr} 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} .${fr} { 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} .${fr} .xterm-dim { color: ${pt.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} .${fr}.${ql} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${fr}.${ql} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${fr}.${ql} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${fr} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${fr} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${fr} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${fr} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${fr} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Ld} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ld} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ld} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[s,o]of e.ansi.entries())t+=`${this._terminalSelector} .${jd}${s} { color: ${o.css}; }${this._terminalSelector} .${jd}${s}.xterm-dim { color: ${pt.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${PC}${s} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${jd}257 { color: ${pt.opaque(e.background).css}; }${this._terminalSelector} .${jd}257.xterm-dim { color: ${pt.multiplyOpacity(pt.opaque(e.background),.5).css}; }${this._terminalSelector} .${PC}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 n=this._rowElements.length;n<=t;n++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}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(ql),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(ql),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,s=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(n){let l=e[0]>t[0];a.appendChild(this._createSelectionElement(s,l?t[0]:e[0],l?e[0]:t[0],o-s+1))}else{let l=r===s?e[0]:0,c=s===i?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(s,l,c));let u=o-s-1;if(a.appendChild(this._createSelectionElement(s+1,0,this._bufferService.cols,u)),s!==o){let d=i===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,d))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement("div"),s=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return s+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-s),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${s}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),s=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let l=e;l<=t;l++){let c=l+n.ydisp,u=this._rowElements[l],d=n.lines.get(c);if(!u||!d)break;u.replaceChildren(...this._rowFactory.createRow(d,c,c===r,o,a,i,s,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${mg}${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,s){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 a=this._bufferService.buffer,l=a.ybase+a.y,c=Math.min(a.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=n;p<=r;++p){let m=p+a.ydisp,v=this._rowElements[p],w=a.lines.get(m);if(!v||!w)break;v.replaceChildren(...this._rowFactory.createRow(w,m,m===l,d,f,c,u,this.dimensions.css.cell.width,this._widthCache,s?p===n?e:0:-1,s?(p===r?t:i)-1:-1))}}};mx=Pt([le(7,r1),le(8,Op),le(9,$n),le(10,zn),le(11,qo),le(12,ts),le(13,Tl)],mx);var gx=class extends ze{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new te),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new dre(this._optionsService))}catch{this._measureStrategy=this._register(new ure(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())}};gx=Pt([le(2,$n)],gx);var xA=class extends ze{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)}},ure=class extends xA{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}},dre=class extends xA{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 new 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}},hre=class extends ze{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 fre(this._window)),this._onDprChange=this._register(new te),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new te),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(mn.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ee(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ee(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}},fre=class extends ze{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new il),this._onDprChange=this._register(new te),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(vt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ee(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.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)}},pre=class extends ze{constructor(){super(),this.linkProviders=[],this._register(vt(()=>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 d1(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),s=parseInt(i.getPropertyValue("padding-left")),o=parseInt(i.getPropertyValue("padding-top"));return[t.clientX-r.left-s,t.clientY-r.top-o]}function mre(e,t,n,r,i,s,o,a,l){if(!s)return;let c=d1(e,t,n);if(c)return c[0]=Math.ceil((c[0]+(l?o/2:0))/o),c[1]=Math.ceil(c[1]/a),c[0]=Math.min(Math.max(c[0],1),r+(l?1:0)),c[1]=Math.min(Math.max(c[1],1),i),c}var vx=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return mre(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=d1(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])}}};vx=Pt([le(0,ns),le(1,Op)],vx);var gre=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):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=[]}},_A={};Ete(_A,{getSafariVersion:()=>xre,isChromeOS:()=>SA,isFirefox:()=>yA,isIpad:()=>_re,isIphone:()=>yre,isLegacyEdge:()=>vre,isLinux:()=>h1,isMac:()=>bf,isNode:()=>Bp,isSafari:()=>bA,isWindows:()=>wA});var Bp=typeof process<"u"&&"title"in process,Bu=Bp?"node":navigator.userAgent,zu=Bp?"node":navigator.platform,yA=Bu.includes("Firefox"),vre=Bu.includes("Edge"),bA=/^((?!chrome|android).)*safari/i.test(Bu);function xre(){if(!bA)return 0;let e=Bu.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var bf=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(zu),_re=zu==="iPad",yre=zu==="iPhone",wA=["Windows","Win16","Win32","WinCE"].includes(zu),h1=zu.indexOf("Linux")>=0,SA=/\bCrOS\b/.test(Bu),kA=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),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(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()}},bre=class extends kA{_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())}}},wre=class extends kA{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},wf=!Bp&&"requestIdleCallback"in window?wre:bre,Sre=class{constructor(){this._queue=new wf}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},xx=class extends ze{constructor(e,t,n,r,i,s,o,a,l){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=i,this._coreBrowserService=a,this._renderer=this._register(new il),this._pausedResizeTask=new Sre,this._observerDisposable=this._register(new il),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 te),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new te),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new te),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new te),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new gre((c,u)=>this._renderRows(c,u),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new kre(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(vt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var c;return(c=this._renderer.value)==null?void 0:c.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(s.onDecorationRegistered(()=>this._fullRefresh())),this._register(s.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(l.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=vt(()=>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),this._needsSelectionRefresh=!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(t=>this.refreshRows(t.start,t.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(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),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(()=>{var n;return(n=this._renderer.value)==null?void 0:n.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,n){var r;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,(r=this._renderer.value)==null||r.handleSelectionChanged(e,t,n)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};xx=Pt([le(2,$n),le(3,Op),le(4,qo),le(5,Ou),le(6,zn),le(7,ts),le(8,Tl)],xx);var kre=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 Cre(e,t,n,r){let i=n.buffer.x,s=n.buffer.y;if(!n.buffer.hasScrollback)return Tre(i,s,e,t,n,r)+zp(s,t,n,r)+Ire(i,s,e,t,n,r);let o;if(s===t)return o=i>e?"D":"C",hu(Math.abs(i-e),du(o,r));o=s>t?"D":"C";let a=Math.abs(s-t),l=Nre(s>t?e:i,n)+(a-1)*n.cols+1+Ere(s>t?i:e);return hu(l,du(o,r))}function Ere(e,t){return e-1}function Nre(e,t){return t.cols-e}function Tre(e,t,n,r,i,s){return zp(t,r,i,s).length===0?"":hu(EA(e,t,e,t-jo(t,i),!1,i).length,du("D",s))}function zp(e,t,n,r){let i=e-jo(e,n),s=t-jo(t,n),o=Math.abs(i-s)-Pre(e,t,n);return hu(o,du(CA(e,t),r))}function Ire(e,t,n,r,i,s){let o;zp(t,r,i,s).length>0?o=r-jo(r,i):o=t;let a=r,l=Rre(e,t,n,r,i,s);return hu(EA(e,o,n,a,l==="C",i).length,du(l,s))}function Pre(e,t,n){var o;let r=0,i=e-jo(e,n),s=t-jo(t,n);for(let a=0;a<Math.abs(i-s);a++){let l=CA(e,t)==="A"?-1:1;(o=n.buffer.lines.get(i+l*a))!=null&&o.isWrapped&&r++}return r}function jo(e,t){let n=0,r=t.buffer.lines.get(e),i=r==null?void 0:r.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r==null?void 0:r.isWrapped;return n}function Rre(e,t,n,r,i,s){let o;return zp(n,r,i,s).length>0?o=r-jo(r,i):o=t,e<n&&o<=r||e>=n&&o<r?"C":"D"}function CA(e,t){return e>t?"A":"B"}function EA(e,t,n,r,i,s){let o=e,a=t,l="";for(;(o!==n||a!==r)&&a>=0&&a<s.buffer.lines.length;)o+=i?1:-1,i&&o>s.cols-1?(l+=s.buffer.translateBufferLineToString(a,!1,e,o),o=0,e=0,a++):!i&&o<0&&(l+=s.buffer.translateBufferLineToString(a,!1,0,e+1),o=s.cols-1,e=o,a--);return l+s.buffer.translateBufferLineToString(a,!1,e,o)}function du(e,t){let n=t?"O":"[";return V.ESC+n+e}function hu(e,t){e=Math.floor(e);let n="";for(let r=0;r<e;r++)n+=t;return n}var Mre=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 RC(e,t){if(e.start.y>e.end.y)throw new 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 gg=50,Are=15,jre=50,Lre=500,Dre=" ",Ore=new RegExp(Dre,"g"),_x=class extends ze{constructor(e,t,n,r,i,s,o,a,l){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=s,this._optionsService=o,this._renderService=a,this._coreBrowserService=l,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new wr,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new te),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new te),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new te),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new te),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new Mre(this._bufferService),this._activeSelectionMode=0,this._register(vt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.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],s=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let a=n.translateBufferLineToString(o,!0,i,s);r.push(a)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let s=e[1]+1;s<=t[1]-1;s++){let o=n.lines.get(s),a=n.translateBufferLineToString(s,!0);o!=null&&o.isWrapped?r[r.length-1]+=a:r.push(a)}if(e[1]!==t[1]){let s=n.lines.get(t[1]),o=n.translateBufferLineToString(t[1],!0,0,t[0]);s&&s.isWrapped?r[r.length-1]+=o:r.push(o)}}return r.map(i=>i.replace(Ore," ")).join(wA?`\r
563
563
  `:`
564
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),h1&&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){var i,s;let n=(s=(i=this._linkifier.currentLink)==null?void 0:i.link)==null?void 0:s.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=IC(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=d1(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,-gg),gg),t/=gg,t/Math.abs(t)+Math.round(t*(Cre-1)))}shouldForceSelection(e){return bf?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(),Ere)}_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&&!(bf&&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 r=n.lines.get(this._model.selectionEnd[1]);r&&r.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<Nre&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let r=vre(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(r,!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(t=>this._handleTrim(t))}_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,s=i.lines.get(e[1]);if(!s)return;let o=i.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(s,e[0]),l=a,c=e[0]-a,u=0,d=0,f=0,p=0;if(o.charAt(a)===" "){for(;a>0&&o.charAt(a-1)===" ";)a--;for(;l<o.length&&o.charAt(l+1)===" ";)l++}else{let w=e[0],x=e[0];s.getWidth(w)===0&&(u++,w--),s.getWidth(x)===2&&(d++,x++);let _=s.getString(x).length;for(_>1&&(p+=_-1,l+=_-1);w>0&&a>0&&!this._isCharWordSeparator(s.loadCell(w-1,this._workCell));){s.loadCell(w-1,this._workCell);let y=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,w--):y>1&&(f+=y-1,a-=y-1),a--,w--}for(;x<s.length&&l+1<o.length&&!this._isCharWordSeparator(s.loadCell(x+1,this._workCell));){s.loadCell(x+1,this._workCell);let y=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,x++):y>1&&(p+=y-1,l+=y-1),l++,x++}}l++;let m=a+c-u+f,v=Math.min(this._bufferService.cols,l-a+u+d-f-p);if(!(!t&&o.slice(a,l).trim()==="")){if(n&&m===0&&s.getCodePoint(0)!==32){let w=i.lines.get(e[1]-1);if(w&&s.isWrapped&&w.getCodePoint(this._bufferService.cols-1)!==32){let x=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(x){let _=this._bufferService.cols-x.start;m-=_,v+=_}}}if(r&&m+v===this._bufferService.cols&&s.getCodePoint(this._bufferService.cols-1)!==32){let w=i.lines.get(e[1]+1);if(w!=null&&w.isWrapped&&w.getCodePoint(0)!==32){let x=this._getWordAt([0,e[1]+1],!1,!1,!0);x&&(v+=x.length)}}return{start:m,length:v}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=IC(n,this._bufferService.cols)}};_x=Pt([le(3,zn),le(4,qo),le(5,i1),le(6,$n),le(7,ns),le(8,ts)],_x);var PC=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={}}},RC=class{constructor(){this._color=new PC,this._css=new PC}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()}},Yt=Object.freeze((()=>{let e=[yt.toColor("#2e3436"),yt.toColor("#cc0000"),yt.toColor("#4e9a06"),yt.toColor("#c4a000"),yt.toColor("#3465a4"),yt.toColor("#75507b"),yt.toColor("#06989a"),yt.toColor("#d3d7cf"),yt.toColor("#555753"),yt.toColor("#ef2929"),yt.toColor("#8ae234"),yt.toColor("#fce94f"),yt.toColor("#729fcf"),yt.toColor("#ad7fa8"),yt.toColor("#34e2e2"),yt.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],s=t[n%6];e.push({css:Ht.toCss(r,i,s),rgba:Ht.toRgba(r,i,s)})}for(let n=0;n<24;n++){let r=8+n*10;e.push({css:Ht.toCss(r,r,r),rgba:Ht.toRgba(r,r,r)})}return e})()),so=yt.toColor("#ffffff"),lc=yt.toColor("#000000"),MC=yt.toColor("#ffffff"),AC=lc,Kl={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Pre=so,yx=class extends ze{constructor(e){super(),this._optionsService=e,this._contrastCache=new RC,this._halfContrastCache=new RC,this._onChangeColors=this._register(new te),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:so,background:lc,cursor:MC,cursorAccent:AC,selectionForeground:void 0,selectionBackgroundTransparent:Kl,selectionBackgroundOpaque:pt.blend(lc,Kl),selectionInactiveBackgroundTransparent:Kl,selectionInactiveBackgroundOpaque:pt.blend(lc,Kl),scrollbarSliderBackground:pt.opacity(so,.2),scrollbarSliderHoverBackground:pt.opacity(so,.4),scrollbarSliderActiveBackground:pt.opacity(so,.5),overviewRulerBorder:so,ansi:Yt.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=it(e.foreground,so),t.background=it(e.background,lc),t.cursor=pt.blend(t.background,it(e.cursor,MC)),t.cursorAccent=pt.blend(t.background,it(e.cursorAccent,AC)),t.selectionBackgroundTransparent=it(e.selectionBackground,Kl),t.selectionBackgroundOpaque=pt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=it(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=pt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?it(e.selectionForeground,EC):void 0,t.selectionForeground===EC&&(t.selectionForeground=void 0),pt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=pt.opacity(t.selectionBackgroundTransparent,.3)),pt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=pt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=it(e.scrollbarSliderBackground,pt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=it(e.scrollbarSliderHoverBackground,pt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=it(e.scrollbarSliderActiveBackground,pt.opacity(t.foreground,.5)),t.overviewRulerBorder=it(e.overviewRulerBorder,Pre),t.ansi=Yt.slice(),t.ansi[0]=it(e.black,Yt[0]),t.ansi[1]=it(e.red,Yt[1]),t.ansi[2]=it(e.green,Yt[2]),t.ansi[3]=it(e.yellow,Yt[3]),t.ansi[4]=it(e.blue,Yt[4]),t.ansi[5]=it(e.magenta,Yt[5]),t.ansi[6]=it(e.cyan,Yt[6]),t.ansi[7]=it(e.white,Yt[7]),t.ansi[8]=it(e.brightBlack,Yt[8]),t.ansi[9]=it(e.brightRed,Yt[9]),t.ansi[10]=it(e.brightGreen,Yt[10]),t.ansi[11]=it(e.brightYellow,Yt[11]),t.ansi[12]=it(e.brightBlue,Yt[12]),t.ansi[13]=it(e.brightMagenta,Yt[13]),t.ansi[14]=it(e.brightCyan,Yt[14]),t.ansi[15]=it(e.brightWhite,Yt[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]=it(e.extendedAnsi[r],Yt[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 t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];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()}}};yx=Pt([le(0,$n)],yx);function it(e,t){if(e!==void 0)try{return yt.toColor(e)}catch{}return t}var Rre=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)}},Mre=class{constructor(){this._services=new Rre,this._services.set(r1,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=Cte(e).sort((s,o)=>s.index-o.index),r=[];for(let s of n){let o=this._services.get(s.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${s.id._id}.`);r.push(o)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},Are={trace:0,debug:1,info:2,warn:3,error:4,off:5},jre="xterm.js: ",bx=class extends ze{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Are[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?"":jre)+t,...n)}trace(e,...t){var n;this._logLevel<=0&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var n;this._logLevel<=1&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var n;this._logLevel<=2&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var n;this._logLevel<=3&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var n;this._logLevel<=4&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.error.bind(this._optionsService.options.logger))??console.error,e,t)}};bx=Pt([le(0,$n)],bx);var jC=class extends ze{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new te),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new te),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new te),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new 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 new 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 r=e;r<this._length-t;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+n.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<n.length;r++)this._array[this._getCyclicIndex(e+r)]=n[r];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let r=this._length+n.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}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 new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let i=t-1;i>=0;i--)this.set(e+i+n,this.get(e+i));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}},Oe=3,zt=Object.freeze(new Du),Dd=0,vg=2,cc=class CA{constructor(t,n,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Oe);let i=n||wr.fromCharData([0,WM,1,0]);for(let s=0;s<t;++s)this.setCell(s,i);this.length=t}get(t){let n=this._data[t*Oe+0],r=n&2097151;return[this._data[t*Oe+1],n&2097152?this._combined[t]:r?gs(r):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,n){this._data[t*Oe+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*Oe+0]=t|2097152|n[2]<<22):this._data[t*Oe+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*Oe+0]>>22}hasWidth(t){return this._data[t*Oe+0]&12582912}getFg(t){return this._data[t*Oe+1]}getBg(t){return this._data[t*Oe+2]}hasContent(t){return this._data[t*Oe+0]&4194303}getCodePoint(t){let n=this._data[t*Oe+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*Oe+0]&2097152}getString(t){let n=this._data[t*Oe+0];return n&2097152?this._combined[t]:n&2097151?gs(n&2097151):""}isProtected(t){return this._data[t*Oe+2]&536870912}loadCell(t,n){return Dd=t*Oe,n.content=this._data[Dd+0],n.fg=this._data[Dd+1],n.bg=this._data[Dd+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*Oe+0]=n.content,this._data[t*Oe+1]=n.fg,this._data[t*Oe+2]=n.bg}setCellFromCodepoint(t,n,r,i){i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*Oe+0]=n|r<<22,this._data[t*Oe+1]=i.fg,this._data[t*Oe+2]=i.bg}addCodepointToCell(t,n,r){let i=this._data[t*Oe+0];i&2097152?this._combined[t]+=gs(n):i&2097151?(this._combined[t]=gs(i&2097151)+gs(n),i&=-2097152,i|=2097152):i=n|1<<22,r&&(i&=-12582913,i|=r<<22),this._data[t*Oe+0]=i}insertCells(t,n,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length-t){let i=new wr;for(let s=this.length-t-n-1;s>=0;--s)this.setCell(t+n+s,this.loadCell(t+s,i));for(let s=0;s<n;++s)this.setCell(t+s,r)}else for(let i=t;i<this.length;++i)this.setCell(i,r);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,r)}deleteCells(t,n,r){if(t%=this.length,n<this.length-t){let i=new wr;for(let s=0;s<this.length-t-n;++s)this.setCell(t+s,this.loadCell(t+n+s,i));for(let s=this.length-n;s<this.length;++s)this.setCell(s,r)}else for(let i=t;i<this.length;++i)this.setCell(i,r);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,r)}replaceCells(t,n,r,i=!1){if(i){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.isProtected(t)||this.setCell(t,r),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.setCell(t++,r)}resize(t,n){if(t===this.length)return this._data.length*4*vg<this._data.buffer.byteLength;let r=t*Oe;if(t>this.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let i=new Uint32Array(r);i.set(this._data),this._data=i}for(let i=this.length;i<t;++i)this.setCell(i,n)}else{this._data=this._data.subarray(0,r);let i=Object.keys(this._combined);for(let o=0;o<i.length;o++){let a=parseInt(i[o],10);a>=t&&delete this._combined[a]}let s=Object.keys(this._extendedAttrs);for(let o=0;o<s.length;o++){let a=parseInt(s[o],10);a>=t&&delete this._extendedAttrs[a]}}return this.length=t,r*4*vg<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*vg<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,n=!1){if(n){for(let r=0;r<this.length;++r)this.isProtected(r)||this.setCell(r,t);return}this._combined={},this._extendedAttrs={};for(let r=0;r<this.length;++r)this.setCell(r,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let n in t._combined)this._combined[n]=t._combined[n];this._extendedAttrs={};for(let n in t._extendedAttrs)this._extendedAttrs[n]=t._extendedAttrs[n];this.isWrapped=t.isWrapped}clone(){let t=new CA(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let n in this._combined)t._combined[n]=this._combined[n];for(let n in this._extendedAttrs)t._extendedAttrs[n]=this._extendedAttrs[n];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Oe+0]&4194303)return t+(this._data[t*Oe+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Oe+0]&4194303||this._data[t*Oe+2]&50331648)return t+(this._data[t*Oe+0]>>22);return 0}copyCellsFrom(t,n,r,i,s){let o=t._data;if(s)for(let l=i-1;l>=0;l--){for(let c=0;c<Oe;c++)this._data[(r+l)*Oe+c]=o[(n+l)*Oe+c];o[(n+l)*Oe+2]&268435456&&(this._extendedAttrs[r+l]=t._extendedAttrs[n+l])}else for(let l=0;l<i;l++){for(let c=0;c<Oe;c++)this._data[(r+l)*Oe+c]=o[(n+l)*Oe+c];o[(n+l)*Oe+2]&268435456&&(this._extendedAttrs[r+l]=t._extendedAttrs[n+l])}let a=Object.keys(t._combined);for(let l=0;l<a.length;l++){let c=parseInt(a[l],10);c>=n&&(this._combined[c-n+r]=t._combined[c])}}translateToString(t,n,r,i){n=n??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),i&&(i.length=0);let s="";for(;n<r;){let o=this._data[n*Oe+0],a=o&2097151,l=o&2097152?this._combined[n]:a?gs(a):Ss;if(s+=l,i)for(let c=0;c<l.length;++c)i.push(n);n+=o>>22||1}return i&&i.push(n),s}};function Lre(e,t,n,r,i,s){let o=[];for(let a=0;a<e.length-1;a++){let l=a,c=e.get(++l);if(!c.isWrapped)continue;let u=[e.get(a)];for(;l<e.length&&c.isWrapped;)u.push(c),c=e.get(++l);if(!s&&r>=a&&r<l){a+=u.length-1;continue}let d=0,f=fu(u,d,t),p=1,m=0;for(;p<u.length;){let w=fu(u,p,t),x=w-m,_=n-f,y=Math.min(x,_);u[d].copyCellsFrom(u[p],m,f,y,!1),f+=y,f===n&&(d++,f=0),m+=y,m===w&&(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 v=0;for(let w=u.length-1;w>0&&(w>d||u[w].getTrimmedLength()===0);w--)v++;v>0&&(o.push(a+u.length-v),o.push(v)),a+=u.length-1}return o}function Dre(e,t){let n=[],r=0,i=t[r],s=0;for(let o=0;o<e.length;o++)if(i===o){let a=t[++r];e.onDeleteEmitter.fire({index:o-s,amount:a}),o+=a-1,s+=a,i=t[++r]}else n.push(o);return{layout:n,countRemoved:s}}function Ore(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let r=0;r<n.length;r++)e.set(r,n[r]);e.length=t.length}function Bre(e,t,n){let r=[],i=e.map((l,c)=>fu(e,c,t)).reduce((l,c)=>l+c),s=0,o=0,a=0;for(;a<i;){if(i-a<n){r.push(i-a);break}s+=n;let l=fu(e,o,t);s>l&&(s-=l,o++);let c=e[o].getWidth(s-1)===2;c&&s--;let u=c?n-1:n;r.push(u),a+=u}return r}function fu(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 EA=class NA{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=NA._nextId++,this._onDispose=this.register(new te),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Ao(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};EA._nextId=1;var zre=EA,en={},oo=en.B;en[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:"≥","{":"π","|":"≠","}":"£","~":"·"};en.A={"#":"£"};en.B=void 0;en[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};en.C=en[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};en.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};en.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};en.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};en.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};en.E=en[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};en.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};en.H=en[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};en["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var LC=4294967295,DC=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=zt.clone(),this.savedCharset=oo,this.markers=[],this._nullCell=wr.fromCharData([0,WM,1,0]),this._whitespaceCell=wr.fromCharData([0,Ss,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new wf,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new jC(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 xf),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 xf),this._whitespaceCell}getBlankLine(e,t){return new cc(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>LC?LC:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=zt);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 jC(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(zt),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 o=0;o<this.lines.length;o++)r+=+this.lines.get(o).resize(e,n);let s=0;if(this._rows<t)for(let o=this._rows;o<t;o++)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 cc(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+s+1?(this.ybase--,s++,this.ydisp>0&&this.ydisp--):this.lines.push(new cc(e,n)));else for(let o=this._rows;o>t;o--)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 o=this.lines.length-i;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),s&&(this.y+=s),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 s=0;s<this.lines.length;s++)r+=+this.lines.get(s).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=Lre(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(zt),n);if(r.length>0){let i=Dre(this.lines,r);Ore(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(zt),i=n;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new cc(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(zt),i=[],s=0;for(let o=this.lines.length-1;o>=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let l=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),l.unshift(a);if(!n){let y=this.ybase+this.y;if(y>=o&&y<o+l.length)continue}let c=l[l.length-1].getTrimmedLength(),u=Bre(l,this._cols,e),d=u.length-l.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+d):f=Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let y=0;y<d;y++){let S=this.getBlankLine(zt,!0);p.push(S)}p.length>0&&(i.push({start:o+l.length+s,newLines:p}),s+=p.length),l.push(...p);let m=u.length-1,v=u[m];v===0&&(m--,v=u[m]);let w=l.length-d-1,x=c;for(;w>=0;){let y=Math.min(x,v);if(l[m]===void 0)break;if(l[m].copyCellsFrom(l[w],x-y,v-y,y,!0),v-=y,v===0&&(m--,v=u[m]),x-=y,x===0){w--;let S=Math.max(w,0);x=fu(l,S,this._cols)}}for(let y=0;y<l.length;y++)u[y]<e&&l[y].setCell(u[y],r);let _=d-f;for(;_-- >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+s)-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 o=[],a=[];for(let v=0;v<this.lines.length;v++)a.push(this.lines.get(v));let l=this.lines.length,c=l-1,u=0,d=i[u];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+s);let f=0;for(let v=Math.min(this.lines.maxLength-1,l+s-1);v>=0;v--)if(d&&d.start>c+f){for(let w=d.newLines.length-1;w>=0;w--)this.lines.set(v--,d.newLines[w]);v++,o.push({index:c+1,amount:d.newLines.length}),f+=d.newLines.length,d=i[++u]}else this.lines.set(v,a[c--]);let p=0;for(let v=o.length-1;v>=0;v--)o[v].index+=p,this.lines.onInsertEmitter.fire(o[v]),p+=o[v].amount;let m=Math.max(0,l+s-this.lines.maxLength);m>0&&this.lines.onTrimEmitter.fire(m)}}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]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(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 zre(e);return this.markers.push(t),t.register(this.lines.onTrim(n=>{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.line<n.index+n.amount&&t.dispose(),t.line>n.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},$re=class extends ze{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new te),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 DC(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new DC(!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)}},TA=2,IA=1,wx=class extends ze{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new te),this.onResize=this._onResize.event,this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,TA),this.rows=Math.max(e.rawOptions.rows||0,IA),this.buffers=this._register(new $re(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.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,s=n.ybase+n.scrollBottom;if(n.scrollTop===0){let o=n.lines.isFull;s===n.lines.length-1?o?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(s+1,0,r.clone()),o?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let o=s-i+1;n.lines.shiftElements(i+1,o-1,-1),n.lines.set(s,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))}};wx=Pt([le(0,$n)],wx);var ca={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:bf,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Fre=["normal","bold","100","200","300","400","500","600","700","800","900"],Hre=class extends ze{constructor(e){super(),this._onOptionChange=this._register(new te),this.onOptionChange=this._onOptionChange.event;let t={...ca};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(vt(()=>{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=n=>{if(!(n in ca))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,r)=>{if(!(n in ca))throw new Error(`No option with key "${n}"`);r=this._sanitizeAndValidateOption(n,r),this.rawOptions[n]!==r&&(this.rawOptions[n]=r,this._onOptionChange.fire(n))};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||(t=ca[e]),!Ure(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=ca[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=Fre.includes(t)?t:ca[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new 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 new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function Ure(e){return e==="block"||e==="underline"||e==="bar"}function uc(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]&&uc(e[r],t-1);return n}var OC=Object.freeze({insertMode:!1}),BC=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Sx=class extends ze{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 te),this.onData=this._onData.event,this._onUserInput=this._register(new te),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new te),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new te),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=uc(OC),this.decPrivateModes=uc(BC)}reset(){this.modes=uc(OC),this.decPrivateModes=uc(BC)}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(r=>r.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(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Sx=Pt([le(0,zn),le(1,YM),le(2,$n)],Sx);var zC={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 xg(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 _g=String.fromCharCode,$C={DEFAULT:e=>{let t=[xg(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${_g(t[0])}${_g(t[1])}${_g(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${xg(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${xg(e,!0)};${e.x};${e.y}${t}`}},kx=class extends ze{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 te),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(zC))this.addProtocol(r,zC[r]);for(let r of Object.keys($C))this.addEncoding(r,$C[r]);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 new 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 new 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)}};kx=Pt([le(0,zn),le(1,qo),le(2,$n)],kx);var yg=[[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]],Wre=[[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]],Xt;function Vre(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 qre=class{constructor(){if(this.version="6",!Xt){Xt=new Uint8Array(65536),Xt.fill(1),Xt[0]=0,Xt.fill(0,1,32),Xt.fill(0,127,160),Xt.fill(2,4352,4448),Xt[9001]=2,Xt[9002]=2,Xt.fill(2,11904,42192),Xt[12351]=1,Xt.fill(2,44032,55204),Xt.fill(2,63744,64256),Xt.fill(2,65040,65050),Xt.fill(2,65072,65136),Xt.fill(2,65280,65377),Xt.fill(2,65504,65511);for(let e=0;e<yg.length;++e)Xt.fill(0,yg[e][0],yg[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Xt[e]:Vre(e,Wre)?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 i=po.extractWidth(t);i===0?r=!1:i>n&&(n=i)}return po.createPropertyValue(0,n,r)}},po=class mh{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new te,this.onChange=this._onChange.event;let t=new qre;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,r=!1){return(t&16777215)<<3|(n&3)<<1|(r?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let s=0;s<i;++s){let o=t.charCodeAt(s);if(55296<=o&&o<=56319){if(++s>=i)return n+this.wcwidth(o);let c=t.charCodeAt(s);56320<=c&&c<=57343?o=(o-55296)*1024+c-56320+65536:n+=this.wcwidth(c)}let a=this.charProperties(o,r),l=mh.extractWidth(a);mh.extractShouldJoin(a)&&(l-=mh.extractWidth(r)),n+=l,r=a}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},Kre=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 FC(e){var r;let t=(r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:r.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 Gl=2147483647,Gre=256,PA=class Cx{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>Gre)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new Cx;if(!t.length)return n;for(let r=Array.isArray(t[0])?1:0;r<t.length;++r){let i=t[r];if(Array.isArray(i))for(let s=0;s<i.length;++s)n.addSubParam(i[s]);else n.addParam(i)}return n}clone(){let t=new Cx(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 t=[];for(let n=0;n<this.length;++n){t.push(this.params[n]);let r=this._subParamsIdx[n]>>8,i=this._subParamsIdx[n]&255;i-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,i))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Gl?Gl:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>Gl?Gl:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-n>0?this._subParams.subarray(n,r):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let r=this._subParamsIdx[n]>>8,i=this._subParamsIdx[n]&255;i-r>0&&(t[n]=this._subParams.slice(r,i))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,i=r[n-1];r[n-1]=~i?Math.min(i*10+t,Gl):t}},Yl=[],Yre=class{constructor(){this._state=0,this._active=Yl,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 r=n.indexOf(t);r!==-1&&n.splice(r,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=Yl}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=Yl,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Yl,!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",Dp(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 r=e[t++];if(r===59){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+r-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=Yl,this._id=-1,this._state=0}}},Jn=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+=Dp(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(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},Xl=[],Xre=class{constructor(){this._handlers=Object.create(null),this._active=Xl,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Xl}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,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=Xl,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Xl,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",Dp(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=Xl,this._ident=0}},dc=new PA;dc.addParam(0);var HC=class{constructor(e){this._handler=e,this._data="",this._params=dc,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():dc,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Dp(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(n=>(this._params=dc,this._data="",this._hitLimit=!1,n));return this._params=dc,this._data="",this._hitLimit=!1,t}},Qre=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}},mr=160,Zre=function(){let e=new Qre(4095),t=Array.apply(null,Array(256)).map((a,l)=>l),n=(a,l)=>t.slice(a,l),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let s=n(0,14),o;e.setDefault(1,0),e.addMany(r,0,2,0);for(o in s)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(mr,0,2,0),e.add(mr,8,5,8),e.add(mr,6,0,6),e.add(mr,11,0,11),e.add(mr,13,13,13),e}(),Jre=class extends ze{constructor(e=Zre){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 PA,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(vt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Yre),this._dcsParser=this._register(new Xre),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 new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let i=0;i<e.intermediates.length;++i){let s=e.intermediates.charCodeAt(i);if(32>s||s>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=s}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new 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 i=r.indexOf(t);i!==-1&&r.splice(i,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 i=r.indexOf(t);i!==-1&&r.splice(i,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,s=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,s=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let a=this._parseStack.handlers,l=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&l>-1){for(;l>=0&&(o=a[l](this._params),o!==!0);l--)if(o instanceof Promise)return this._parseStack.handlerPos=l,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&l>-1){for(;l>=0&&(o=a[l](),o!==!0);l--)if(o instanceof Promise)return this._parseStack.handlerPos=l,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,s=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let a=s;a<t;++a){switch(r=e[a],i=this._transitions.table[this.currentState<<8|(r<160?r:mr)],i>>4){case 2:for(let f=a+1;;++f){if(f>=t||(r=e[f])<32||r>126&&r<mr){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(r=e[f])<32||r>126&&r<mr){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(r=e[f])<32||r>126&&r<mr){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(r=e[f])<32||r>126&&r<mr){this._printHandler(e,a,f),a=f-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:a,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let l=this._csiHandlers[this._collect<<8|r],c=l?l.length-1:-1;for(;c>=0&&(o=l[c](this._params),o!==!0);c--)if(o instanceof Promise)return this._preserveStack(3,l,c,i,a),o;c<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(++a<t&&(r=e[a])>47&&r<60);a--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let u=this._escHandlers[this._collect<<8|r],d=u?u.length-1:-1;for(;d>=0&&(o=u[d](),o!==!0);d--)if(o instanceof Promise)return this._preserveStack(4,u,d,i,a),o;d<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 f=a+1;;++f)if(f>=t||(r=e[f])===24||r===26||r===27||r>127&&r<mr){this._dcsParser.put(e,a,f),a=f-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,a),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 f=a+1;;f++)if(f>=t||(r=e[f])<32||r>127&&r<mr){this._oscParser.put(e,a,f),a=f-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,a),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},eie=/^([\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})$/,tie=/^[\da-f]+$/;function UC(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=eie.exec(t);if(n){let r=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/r*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/r*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/r*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),tie.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,r=[0,0,0];for(let i=0;i<3;++i){let s=parseInt(t.slice(n*i,n*i+n),16);r[i]=n===1?s<<4:n===2?s:n===3?s>>4:s>>8}return r}}function bg(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 nie(e,t=16){let[n,r,i]=e;return`rgb:${bg(n,t)}/${bg(r,t)}/${bg(i,t)}`}var rie={"(":0,")":1,"*":2,"+":3,"-":1,".":2},us=131072,WC=10;function VC(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 qC=5e3,KC=0,iie=class extends ze{constructor(e,t,n,r,i,s,o,a,l=new Jre){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=s,this._coreMouseService=o,this._unicodeService=a,this._parser=l,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Ste,this._utf8Decoder=new kte,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=zt.clone(),this._eraseAttrDataInternal=zt.clone(),this._onRequestBell=this._register(new te),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new te),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new te),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new te),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new te),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new te),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new te),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new te),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new te),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new te),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new te),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new te),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 Ex(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,u)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:u.toArray()})}),this._parser.setEscHandlerFallback(c=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(c)})}),this._parser.setExecuteHandlerFallback(c=>{this._logService.debug("Unknown EXECUTE code: ",{code:c})}),this._parser.setOscHandlerFallback((c,u,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:u,data:d})}),this._parser.setDcsHandlerFallback((c,u,d)=>{u==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:u,payload:d})}),this._parser.setPrintHandler((c,u,d)=>this.print(c,u,d)),this._parser.registerCsiHandler({final:"@"},c=>this.insertChars(c)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},c=>this.scrollLeft(c)),this._parser.registerCsiHandler({final:"A"},c=>this.cursorUp(c)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},c=>this.scrollRight(c)),this._parser.registerCsiHandler({final:"B"},c=>this.cursorDown(c)),this._parser.registerCsiHandler({final:"C"},c=>this.cursorForward(c)),this._parser.registerCsiHandler({final:"D"},c=>this.cursorBackward(c)),this._parser.registerCsiHandler({final:"E"},c=>this.cursorNextLine(c)),this._parser.registerCsiHandler({final:"F"},c=>this.cursorPrecedingLine(c)),this._parser.registerCsiHandler({final:"G"},c=>this.cursorCharAbsolute(c)),this._parser.registerCsiHandler({final:"H"},c=>this.cursorPosition(c)),this._parser.registerCsiHandler({final:"I"},c=>this.cursorForwardTab(c)),this._parser.registerCsiHandler({final:"J"},c=>this.eraseInDisplay(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},c=>this.eraseInDisplay(c,!0)),this._parser.registerCsiHandler({final:"K"},c=>this.eraseInLine(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},c=>this.eraseInLine(c,!0)),this._parser.registerCsiHandler({final:"L"},c=>this.insertLines(c)),this._parser.registerCsiHandler({final:"M"},c=>this.deleteLines(c)),this._parser.registerCsiHandler({final:"P"},c=>this.deleteChars(c)),this._parser.registerCsiHandler({final:"S"},c=>this.scrollUp(c)),this._parser.registerCsiHandler({final:"T"},c=>this.scrollDown(c)),this._parser.registerCsiHandler({final:"X"},c=>this.eraseChars(c)),this._parser.registerCsiHandler({final:"Z"},c=>this.cursorBackwardTab(c)),this._parser.registerCsiHandler({final:"`"},c=>this.charPosAbsolute(c)),this._parser.registerCsiHandler({final:"a"},c=>this.hPositionRelative(c)),this._parser.registerCsiHandler({final:"b"},c=>this.repeatPrecedingCharacter(c)),this._parser.registerCsiHandler({final:"c"},c=>this.sendDeviceAttributesPrimary(c)),this._parser.registerCsiHandler({prefix:">",final:"c"},c=>this.sendDeviceAttributesSecondary(c)),this._parser.registerCsiHandler({final:"d"},c=>this.linePosAbsolute(c)),this._parser.registerCsiHandler({final:"e"},c=>this.vPositionRelative(c)),this._parser.registerCsiHandler({final:"f"},c=>this.hVPosition(c)),this._parser.registerCsiHandler({final:"g"},c=>this.tabClear(c)),this._parser.registerCsiHandler({final:"h"},c=>this.setMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"h"},c=>this.setModePrivate(c)),this._parser.registerCsiHandler({final:"l"},c=>this.resetMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"l"},c=>this.resetModePrivate(c)),this._parser.registerCsiHandler({final:"m"},c=>this.charAttributes(c)),this._parser.registerCsiHandler({final:"n"},c=>this.deviceStatus(c)),this._parser.registerCsiHandler({prefix:"?",final:"n"},c=>this.deviceStatusPrivate(c)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},c=>this.softReset(c)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},c=>this.setCursorStyle(c)),this._parser.registerCsiHandler({final:"r"},c=>this.setScrollRegion(c)),this._parser.registerCsiHandler({final:"s"},c=>this.saveCursor(c)),this._parser.registerCsiHandler({final:"t"},c=>this.windowOptions(c)),this._parser.registerCsiHandler({final:"u"},c=>this.restoreCursor(c)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},c=>this.insertColumns(c)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},c=>this.deleteColumns(c)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},c=>this.selectProtected(c)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},c=>this.requestMode(c,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},c=>this.requestMode(c,!1)),this._parser.setExecuteHandler(V.BEL,()=>this.bell()),this._parser.setExecuteHandler(V.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(V.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(V.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(V.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(V.BS,()=>this.backspace()),this._parser.setExecuteHandler(V.HT,()=>this.tab()),this._parser.setExecuteHandler(V.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(V.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(fh.IND,()=>this.index()),this._parser.setExecuteHandler(fh.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(fh.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Jn(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new Jn(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new Jn(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new Jn(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new Jn(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new Jn(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new Jn(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new Jn(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new Jn(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new Jn(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new Jn(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new Jn(c=>this.restoreCursorColor(c))),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 c in en)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(c=>(this._logService.error("Parsing error: ",c),c)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new HC((c,u)=>this.requestStatusString(c,u)))}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((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),qC))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${qC} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,s=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>us&&(s=this._parseStack.position+us)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,c=>String.fromCharCode(c)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(c=>c.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<us&&(this._parseBuffer=new Uint32Array(Math.min(e.length,us))),o||this._dirtyRowTracker.clearRange(),e.length>us)for(let c=s;c<e.length;c+=us){let u=c+us<e.length?c+us:e.length,d=typeof e=="string"?this._stringDecoder.decode(e.substring(c,u),this._parseBuffer):this._utf8Decoder.decode(e.subarray(c,u),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,d))return this._preserveStack(r,i,d,c),this._logSlowResolvingAsync(n),n}else if(!o){let c=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,c))return this._preserveStack(r,i,c,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let a=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),l=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);l<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(l,this._bufferService.rows-1),end:Math.min(a,this._bufferService.rows-1)})}print(e,t,n){let r,i,s=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,l=this._coreService.decPrivateModes.wraparound,c=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&&s){let x=s[String.fromCharCode(r)];x&&(r=x.charCodeAt(0))}let m=this._unicodeService.charProperties(r,f);i=po.extractWidth(m);let v=po.extractShouldJoin(m),w=v?po.extractWidth(f):0;if(f=m,o&&this._onA11yChar.fire(gs(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-w>a){if(l){let x=d,_=this._activeBuffer.x-w;for(this._activeBuffer.x=w,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),w>0&&d instanceof cc&&d.copyCellsFrom(x,_,0,w,!1);_<a;)x.setCellFromCodepoint(_++,0,1,u)}else if(this._activeBuffer.x=a-1,i===2)continue}if(v&&this._activeBuffer.x){let x=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-x,r,i);for(let _=i-w;--_>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(c&&(d.insertCells(this._activeBuffer.x,i-w,this._activeBuffer.getNullCell(u)),d.getWidth(a-1)===2&&d.setCellFromCodepoint(a-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<a&&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,n=>VC(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new HC(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Jn(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(){var e;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&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.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 s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(s.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){var r;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--&&!((r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n))!=null&&r.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 i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,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(zt));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 n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.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 n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.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 n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.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 n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.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=po.extractWidth(t),i=this._activeBuffer.x-r,s=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(s.length*n),a=0;for(let c=0;c<s.length;){let u=s.codePointAt(c)||0;o[a++]=u,c+=u>65535?2:1}let l=a;for(let c=1;c<n;++c)o.copyWithin(l,0,a),l+=a;return this.print(o,0,l),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(V.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(V.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(V.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(V.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(V.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,oo),this._charsetService.setgCharset(1,oo),this._charsetService.setgCharset(2,oo),this._charsetService.setgCharset(3,oo);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){(v=>(v[v.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",v[v.SET=1]="SET",v[v.RESET=2]="RESET",v[v.PERMANENTLY_SET=3]="PERMANENTLY_SET",v[v.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:s}=this._coreMouseService,o=this._coreService,{buffers:a,cols:l}=this._bufferService,{active:c,alt:u}=a,d=this._optionsService.rawOptions,f=(v,w)=>(o.triggerDataEvent(`${V.ESC}[${t?"":"?"}${v};${w}$y`),!0),p=v=>v?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?l===80?2:l===132?1:0: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(s==="SGR")):m===1015?f(m,4):m===1016?f(m,p(s==="SGR_PIXELS")):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(c===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|=Du.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,s=0;do{if(r[s+i]=e.params[t+s],e.hasSubParams(t+s)){let o=e.getSubParams(t+s),a=0;do r[1]===5&&(i=1),r[s+a+1+i]=o[a];while(++a<o.length&&a+s+1+i<r.length);break}if(r[1]===5&&s+i>=2||r[1]===2&&s+i>=5)break;r[1]&&(i=1)}while(++s+t<e.length&&s+i<r.length);for(let o=2;o<r.length;++o)r[o]===-1&&(r[o]=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 s}_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=zt.fg,e.bg=zt.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|=16777216|n-90|8):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=16777216|n-100|8):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|=zt.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=zt.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|=zt.fg&16777215,r.bg&=-67108864,r.bg|=zt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${V.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${V.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${V.ESC}[?${t};${n}R`);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=zt.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 n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}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(!VC(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(`${V.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>WC&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>WC&&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 r=n.shift(),i=n.shift();if(/^\d+$/.exec(r)){let s=parseInt(r);if(GC(s))if(i==="?")t.push({type:0,index:s});else{let o=UC(i);o&&t.push({type:1,index:s,color:o})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),r,i=n.findIndex(s=>s.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 r=0;r<n.length&&!(t>=this._specialColors.length);++r,++t)if(n[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let i=UC(n[r]);i&&this._onColor.fire([{type:1,index:this._specialColors[t],color:i}])}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 r=0;r<n.length;++r)if(/^\d+$/.exec(n[r])){let i=parseInt(n[r]);GC(i)&&t.push({type:2,index:i})}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,oo),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(rie[e[0]],en[e[1]]||oo),!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=zt.clone(),this._eraseAttrDataInternal=zt.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 wr;e.content=1<<22|69,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=o=>(this._coreService.triggerDataEvent(`${V.ESC}${o}${V.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"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?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Ex=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&&(KC=e,e=t,t=KC),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Ex=Pt([le(0,zn)],Ex);function GC(e){return 0<=e&&e<256}var sie=5e7,YC=12,oie=50,aie=class extends ze{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 te),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 r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>sie)throw new 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 r=this._writeBuffer[this._bufferOffset],i=this._action(r,t);if(i){let o=a=>performance.now()-n>=YC?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(n,a);i.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(o);return}let s=this._callbacks[this._bufferOffset];if(s&&s(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-n>=YC)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>oie&&(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()}},Nx=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 a=t.addMarker(t.ybase+t.y),l={data:e,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(l,a)),this._dataByLinkId.set(l.id,l),l.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 s=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[s]};return s.onDispose(()=>this._removeMarkerFromLink(o,s)),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(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);n.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(n,r))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.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)))}};Nx=Pt([le(0,zn)],Nx);var XC=!1,lie=class extends ze{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new il),this._onBinary=this._register(new te),this.onBinary=this._onBinary.event,this._onData=this._register(new te),this.onData=this._onData.event,this._onLineFeed=this._register(new te),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new te),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new te),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new te),this._instantiationService=new Mre,this.optionsService=this._register(new Hre(e)),this._instantiationService.setService($n,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(wx)),this._instantiationService.setService(zn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(bx)),this._instantiationService.setService(YM,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Sx)),this._instantiationService.setService(qo,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(kx)),this._instantiationService.setService(GM,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(po)),this._instantiationService.setService(Tte,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Kre),this._instantiationService.setService(Nte,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Nx),this._instantiationService.setService(XM,this._oscLinkService),this._inputHandler=this._register(new iie(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(mn.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(mn.forward(this._bufferService.onResize,this._onResize)),this._register(mn.forward(this.coreService.onData,this._onData)),this._register(mn.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 aie((t,n)=>this._inputHandler.parse(t,n))),this._register(mn.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new te),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.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&&!XC&&(this._logService.warn("writeSync is unreliable and will be removed soon."),XC=!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,TA),t=Math.max(t,IA),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(FC.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(FC(this._bufferService),!1))),this._windowsWrappingHeuristics.value=vt(()=>{for(let t of e)t.dispose()})}}},cie={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 uie(e,t,n,r){var o;let i={type:0,cancel:!1,key:void 0},s=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?i.key=V.ESC+"OA":i.key=V.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?i.key=V.ESC+"OD":i.key=V.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?i.key=V.ESC+"OC":i.key=V.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?i.key=V.ESC+"OB":i.key=V.ESC+"[B");break;case 8:i.key=e.ctrlKey?"\b":V.DEL,e.altKey&&(i.key=V.ESC+i.key);break;case 9:if(e.shiftKey){i.key=V.ESC+"[Z";break}i.key=V.HT,i.cancel=!0;break;case 13:i.key=e.altKey?V.ESC+V.CR:V.CR,i.cancel=!0;break;case 27:i.key=V.ESC,e.altKey&&(i.key=V.ESC+V.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;s?i.key=V.ESC+"[1;"+(s+1)+"D":t?i.key=V.ESC+"OD":i.key=V.ESC+"[D";break;case 39:if(e.metaKey)break;s?i.key=V.ESC+"[1;"+(s+1)+"C":t?i.key=V.ESC+"OC":i.key=V.ESC+"[C";break;case 38:if(e.metaKey)break;s?i.key=V.ESC+"[1;"+(s+1)+"A":t?i.key=V.ESC+"OA":i.key=V.ESC+"[A";break;case 40:if(e.metaKey)break;s?i.key=V.ESC+"[1;"+(s+1)+"B":t?i.key=V.ESC+"OB":i.key=V.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=V.ESC+"[2~");break;case 46:s?i.key=V.ESC+"[3;"+(s+1)+"~":i.key=V.ESC+"[3~";break;case 36:s?i.key=V.ESC+"[1;"+(s+1)+"H":t?i.key=V.ESC+"OH":i.key=V.ESC+"[H";break;case 35:s?i.key=V.ESC+"[1;"+(s+1)+"F":t?i.key=V.ESC+"OF":i.key=V.ESC+"[F";break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=V.ESC+"[5;"+(s+1)+"~":i.key=V.ESC+"[5~";break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=V.ESC+"[6;"+(s+1)+"~":i.key=V.ESC+"[6~";break;case 112:s?i.key=V.ESC+"[1;"+(s+1)+"P":i.key=V.ESC+"OP";break;case 113:s?i.key=V.ESC+"[1;"+(s+1)+"Q":i.key=V.ESC+"OQ";break;case 114:s?i.key=V.ESC+"[1;"+(s+1)+"R":i.key=V.ESC+"OR";break;case 115:s?i.key=V.ESC+"[1;"+(s+1)+"S":i.key=V.ESC+"OS";break;case 116:s?i.key=V.ESC+"[15;"+(s+1)+"~":i.key=V.ESC+"[15~";break;case 117:s?i.key=V.ESC+"[17;"+(s+1)+"~":i.key=V.ESC+"[17~";break;case 118:s?i.key=V.ESC+"[18;"+(s+1)+"~":i.key=V.ESC+"[18~";break;case 119:s?i.key=V.ESC+"[19;"+(s+1)+"~":i.key=V.ESC+"[19~";break;case 120:s?i.key=V.ESC+"[20;"+(s+1)+"~":i.key=V.ESC+"[20~";break;case 121:s?i.key=V.ESC+"[21;"+(s+1)+"~":i.key=V.ESC+"[21~";break;case 122:s?i.key=V.ESC+"[23;"+(s+1)+"~":i.key=V.ESC+"[23~";break;case 123:s?i.key=V.ESC+"[24;"+(s+1)+"~":i.key=V.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=V.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=V.DEL:e.keyCode===219?i.key=V.ESC:e.keyCode===220?i.key=V.FS:e.keyCode===221&&(i.key=V.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let a=(o=cie[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(a)i.key=V.ESC+a;else if(e.keyCode>=65&&e.keyCode<=90){let l=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(l);e.shiftKey&&(c=c.toUpperCase()),i.key=V.ESC+c}else if(e.keyCode===32)i.key=V.ESC+(e.ctrlKey?V.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let l=e.code.slice(3,4);e.shiftKey||(l=l.toLowerCase()),i.key=V.ESC+l,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=V.US),e.key==="@"&&(i.key=V.NUL));break}return i}var jt=0,die=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new wf,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new wf,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((i,s)=>this._getKey(i)-this._getKey(s)),t=0,n=0,r=new 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||(jt=this._search(t),jt===-1)||this._getKey(this._array[jt])!==t)return!1;do if(this._array[jt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(jt),!0;while(++jt<this._array.length&&this._getKey(this._array[jt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((i,s)=>i-s),t=0,n=new 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&&(jt=this._search(e),!(jt<0||jt>=this._array.length)&&this._getKey(this._array[jt])===e))do yield this._array[jt];while(++jt<this._array.length&&this._getKey(this._array[jt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(jt=this._search(e),!(jt<0||jt>=this._array.length)&&this._getKey(this._array[jt])===e))do t(this._array[jt]);while(++jt<this._array.length&&this._getKey(this._array[jt])===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}},wg=0,QC=0,hie=class extends ze{constructor(){super(),this._decorations=new die(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new te),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new te),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(vt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new fie(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.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 s of this._decorations.getKeyIterator(t))r=s.options.x??0,i=r+(s.options.width??1),e>=r&&e<i&&(!n||(s.options.layer??"bottom")===n)&&(yield s)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,i=>{wg=i.options.x??0,QC=wg+(i.options.width??1),e>=wg&&e<QC&&(!n||(i.options.layer??"bottom")===n)&&r(i)})}},fie=class extends js{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new te),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new te),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=yt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=yt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},pie=1e3,mie=class{constructor(e,t=pie){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?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let i=r-this._lastRefreshMs,s=this._debounceThresholdMS-i;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},s)}}_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)}},ZC=20,Sf=class extends ze{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 s=0;s<this._terminal.rows;s++)this._rowElements[s]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[s]);if(this._topBoundaryFocusListener=s=>this._handleBoundaryFocus(s,0),this._bottomBoundaryFocusListener=s=>this._handleBoundaryFocus(s,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 mie(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(s=>this._handleResize(s.rows))),this._register(this._terminal.onRender(s=>this._refreshRows(s.start,s.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(s=>this._handleChar(s))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
565
- `))),this._register(this._terminal.onA11yTab(s=>this._handleTab(s))),this._register(this._terminal.onKey(s=>this._handleKey(s.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Ee(i,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(vt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<ZC+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
566
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===ZC+1&&(this._liveRegion.textContent+=K0.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\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 s=n.lines.get(n.ydisp+i),o=[],a=(s==null?void 0:s.translateToString(!0,void 0,void 0,o))||"",l=(n.ydisp+i+1).toString(),c=this._rowElements[i];c&&(a.length===0?(c.textContent=" ",this._rowColumns.set(c,[0,1])):(c.textContent=a,this._rowColumns.set(c,o)),c.setAttribute("aria-posinset",l),c.setAttribute("aria-setsize",r),this._alignRowWidth(c))}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],i=n.getAttribute("aria-posinset"),s=t===0?"1":`${this._terminal.buffer.lines.length}`;if(i===s||e.relatedTarget!==r)return;let o,a;if(t===0?(o=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(o=this._rowElements.shift(),a=n,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let l=this._createAccessibilityTreeNode();this._rowElements.unshift(l),this._rowContainer.insertAdjacentElement("afterbegin",l)}else{let l=this._createAccessibilityTreeNode();this._rowElements.push(l),this._rowContainer.appendChild(l)}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(){var a;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:((a=r.textContent)==null?void 0:a.length)??0}),!this._rowContainer.contains(n.node))return;let i=({node:l,offset:c})=>{let u=l instanceof Text?l.parentNode:l,d=parseInt(u==null?void 0:u.getAttribute("aria-posinset"),10)-1;if(isNaN(d))return console.warn("row is invalid. Race condition?"),null;let f=this._rowColumns.get(u);if(!f)return console.warn("columns is null. Race condition?"),null;let p=c<f.length?f[c]:f.slice(-1)[0]+1;return p>=this._terminal.cols&&(++d,p=0),{row:d,column:p}},s=i(t),o=i(n);if(!(!s||!o)){if(s.row>o.row||s.row===o.row&&s.column>=o.column)throw new Error("invalid range");this._terminal.select(s.column,s.row,(o.row-s.row)*this._terminal.cols-s.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);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){var i,s;e.style.transform="";let t=e.getBoundingClientRect().width,n=(s=(i=this._rowColumns.get(e))==null?void 0:i.slice(-1))==null?void 0:s[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};Sf=Pt([le(1,r1),le(2,ts),le(3,ns)],Sf);var Tx=class extends ze{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 te),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new te),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(vt(()=>{var s;Ao(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(s=this._activeProviderReplies)==null||s.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Ee(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ee(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ee(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ee(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 r=0;r<n.length;r++){let i=n[r];if(i.classList.contains("xterm"))break;if(i.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){var r,i;(!this._activeProviderReplies||!t)&&((r=this._activeProviderReplies)==null||r.forEach(s=>{s==null||s.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[s,o]of this._linkProviderService.linkProviders.entries())t?(i=this._activeProviderReplies)!=null&&i.get(s)&&(n=this._checkLinkProviderResult(s,e,n)):o.provideLinks(e.y,a=>{var c,u;if(this._isMouseOut)return;let l=a==null?void 0:a.map(d=>({link:d}));(c=this._activeProviderReplies)==null||c.set(s,l),n=this._checkLinkProviderResult(s,e,n),((u=this._activeProviderReplies)==null?void 0:u.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 s=0;s<i.length;s++){let o=i[s],a=o.link.range.start.y<e?0:o.link.range.start.x,l=o.link.range.end.y>e?this._bufferService.cols:o.link.range.end.x;for(let c=a;c<=l;c++){if(n.has(c)){i.splice(s--,1);break}n.add(c)}}}}_checkLinkProviderResult(e,t,n){var s;if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let o=0;o<e;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(i=!0);if(!i&&r){let o=r.find(a=>this._linkAtPosition(a.link,t));o&&(n=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let o=0;o<this._activeProviderReplies.size;o++){let a=(s=this._activeProviderReplies.get(o))==null?void 0:s.find(l=>this._linkAtPosition(l.link,t));if(a){n=!0,this._handleNewLink(a);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&&gie(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,Ao(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var n,r;return(r=(n=this._currentLink)==null?void 0:n.state)==null?void 0:r.decorations.pointerCursor},set:n=>{var r;(r=this._currentLink)!=null&&r.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>{var n,r;return(r=(n=this._currentLink)==null?void 0:n.state)==null?void 0:r.decorations.underline},set:n=>{var r,i,s;(r=this._currentLink)!=null&&r.state&&((s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline)!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let r=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,i=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=i&&(this._clearCurrentLink(r,i),this._lastMouseEvent)){let s=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);s&&this._askForLink(s,!1)}})))}_linkHover(e,t,n){var r;(r=this._currentLink)!=null&&r.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){var r;(r=this._currentLink)!=null&&r.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}}};Tx=Pt([le(1,i1),le(2,ns),le(3,zn),le(4,ZM)],Tx);function gie(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 vie=class extends lie{constructor(e={}){super(e),this._linkifier=this._register(new il),this.browser=vA,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new il),this._onCursorMove=this._register(new te),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new te),this.onKey=this._onKey.event,this._onRender=this._register(new te),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new te),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new te),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new te),this.onBell=this._onBell.event,this._onFocus=this._register(new te),this._onBlur=this._register(new te),this._onA11yCharEmitter=this._register(new te),this._onA11yTabEmitter=this._register(new te),this._onWillOpen=this._register(new te),this._setup(),this._decorationService=this._instantiationService.createInstance(hie),this._instantiationService.setService(Ou,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(ore),this._instantiationService.setService(ZM,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Y0)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(mn.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(mn.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(mn.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(mn.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(vt(()=>{var t,n;this._customKeyEventHandler=void 0,(n=(t=this.element)==null?void 0:t.parentNode)==null||n.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 n,r="";switch(t.index){case 256:n="foreground",r="10";break;case 257:n="background",r="11";break;case 258:n="cursor",r="12";break;default:n="ansi",r="4;"+t.index}switch(t.type){case 0:let i=pt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${V.ESC}]${r};${nie(i)}${mA.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(s=>s.ansi[t.index]=Ht.toColor(...t.color));else{let s=n;this._themeService.modifyColors(o=>o[s]=Ht.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(Sf,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(V.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(V.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),s=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,a=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=o+"px",this.textarea.style.width=s+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ee(this.element,"copy",t=>{this.hasSelection()&&bte(t,this._selectionService)}));let e=t=>wte(t,this.textarea,this.coreService,this.optionsService);this._register(Ee(this.textarea,"paste",e)),this._register(Ee(this.element,"paste",e)),xA?this._register(Ee(this.element,"mousedown",t=>{t.button===2&&lC(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ee(this.element,"contextmenu",t=>{lC(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),h1&&this._register(Ee(this.element,"auxclick",t=>{t.button===1&&UM(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ee(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ee(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ee(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ee(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ee(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ee(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ee(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var i;if(!e)throw new 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"),((i=this.element)==null?void 0:i.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(Ee(this.screenElement,"mousemove",s=>this.updateCursorStyle(s))),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",q0.get()),bA||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(ire,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(ts,this._coreBrowserService),this._register(Ee(this.textarea,"focus",s=>this._handleTextAreaFocus(s))),this._register(Ee(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(gx,this._document,this._helperContainer),this._instantiationService.setService(Op,this._charSizeService),this._themeService=this._instantiationService.createInstance(yx),this._instantiationService.setService(Tl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(yf),this._instantiationService.setService(QM,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(xx,this.rows,this.screenElement)),this._instantiationService.setService(ns,this._renderService),this._register(this._renderService.onRenderedViewportChange(s=>this._onRender.fire(s))),this.onResize(s=>this._renderService.resize(s.cols,s.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(fx,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(vx),this._instantiationService.setService(i1,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Tx,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(dx,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(s=>{super.scrollLines(s,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(_x,this.element,this.screenElement,r)),this._instantiationService.setService(Pte,this._selectionService),this._register(this._selectionService.onRequestScrollLines(s=>this.scrollLines(s.amount,s.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(s=>this._renderService.handleSelectionChanged(s.start,s.end,s.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(s=>{this.textarea.value=s,this.textarea.focus(),this.textarea.select()})),this._register(mn.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var s;this._selectionService.refresh(),(s=this._viewport)==null||s.queueSync()})),this._register(this._instantiationService.createInstance(hx,this.screenElement)),this._register(Ee(this.element,"mousedown",s=>this._selectionService.handleMouseDown(s))),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(Sf,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",s=>this._handleScreenReaderModeOptionChange(s))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(_f,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",s=>{!this._overviewRulerRenderer&&s&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(_f,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(mx,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(s){var c,u,d,f,p;let o=e._mouseService.getMouseReportCoords(s,e.screenElement);if(!o)return!1;let a,l;switch(s.overrideType||s.type){case"mousemove":l=32,s.buttons===void 0?(a=3,s.button!==void 0&&(a=s.button<3?s.button:3)):a=s.buttons&1?0:s.buttons&4?1:s.buttons&2?2:3;break;case"mouseup":l=0,a=s.button<3?s.button:3;break;case"mousedown":l=1,a=s.button<3?s.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(s)===!1)return!1;let m=s.deltaY;if(m===0||e.coreMouseService.consumeWheelEvent(s,(f=(d=(u=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:u.device)==null?void 0:d.cell)==null?void 0:f.height,(p=e._coreBrowserService)==null?void 0:p.dpr)===0)return!1;l=m<0?0:1,a=4;break;default:return!1}return l===void 0||a===void 0||a>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:a,action:l,ctrl:s.ctrlKey,alt:s.altKey,shift:s.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:s=>(n(s),s.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(s)),wheel:s=>(n(s),this.cancel(s,!0)),mousedrag:s=>{s.buttons&&n(s)},mousemove:s=>{s.buttons||n(s)}};this._register(this.coreMouseService.onProtocolChange(s=>{s?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(s)),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()),s&8?r.mousemove||(t.addEventListener("mousemove",i.mousemove),r.mousemove=i.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),s&16?r.wheel||(t.addEventListener("wheel",i.wheel,{passive:!1}),r.wheel=i.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),s&2?r.mouseup||(r.mouseup=i.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),s&4?r.mousedrag||(r.mousedrag=i.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ee(t,"mousedown",s=>{if(s.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(s)))return n(s),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(s)})),this._register(Ee(t,"wheel",s=>{var o,a,l,c,u;if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(s)===!1)return!1;if(!this.buffer.hasScrollback){if(s.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(s,(c=(l=(a=(o=e._renderService)==null?void 0:o.dimensions)==null?void 0:a.device)==null?void 0:l.cell)==null?void 0:c.height,(u=e._coreBrowserService)==null?void 0:u.dpr)===0)return this.cancel(s,!0);let d=V.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(s.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(d,!0),this.cancel(s,!0)}}},{passive:!1}))}refresh(e,t){var n;(n=this._renderService)==null||n.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.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){HM(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 new 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 new 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(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var n;(n=this._selectionService)==null||n.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=uie(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let r=this.rows-1;return this.scrollLines(n.type===2?-r:r),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===V.ETX||n.key===V.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)&&(xie(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){var n;(n=this._charSizeService)==null||n.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(zt));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(V.ESC+"[I"):this.coreService.triggerDataEvent(V.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${V.ESC}[4;${n};${t}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),i=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${V.ESC}[6;${i};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function xie(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var _ie=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 new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},yie=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 wr)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},JC=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 yie(t)}getNullCell(){return new wr}},bie=class extends ze{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new te),this.onBufferChange=this._onBufferChange.event,this._normal=new JC(this._core.buffers.normal,"normal"),this._alternate=new JC(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 new 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)}},wie=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,r)=>t(n,r.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)}},Sie=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}},kie=["cols","rows"],Xr=0,Cie=class extends ze{constructor(e){super(),this._core=this._register(new vie(e)),this._addonManager=this._register(new _ie),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],n=(r,i)=>{this._checkReadonlyOptions(r),this._core.options[r]=i};for(let r in this._core.options){let i={get:t.bind(this,r),set:n.bind(this,r)};Object.defineProperty(this._publicOptions,r,i)}}_checkReadonlyOptions(e){if(kie.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new 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||(this._parser=new wie(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Sie(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._buffer=this._register(new bie(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
564
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),h1&&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){var i,s;let n=(s=(i=this._linkifier.currentLink)==null?void 0:i.link)==null?void 0:s.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=RC(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=d1(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,-gg),gg),t/=gg,t/Math.abs(t)+Math.round(t*(Are-1)))}shouldForceSelection(e){return bf?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(),jre)}_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&&!(bf&&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 r=n.lines.get(this._model.selectionEnd[1]);r&&r.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<Lre&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let r=Cre(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(r,!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(t=>this._handleTrim(t))}_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,s=i.lines.get(e[1]);if(!s)return;let o=i.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(s,e[0]),l=a,c=e[0]-a,u=0,d=0,f=0,p=0;if(o.charAt(a)===" "){for(;a>0&&o.charAt(a-1)===" ";)a--;for(;l<o.length&&o.charAt(l+1)===" ";)l++}else{let w=e[0],x=e[0];s.getWidth(w)===0&&(u++,w--),s.getWidth(x)===2&&(d++,x++);let _=s.getString(x).length;for(_>1&&(p+=_-1,l+=_-1);w>0&&a>0&&!this._isCharWordSeparator(s.loadCell(w-1,this._workCell));){s.loadCell(w-1,this._workCell);let y=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,w--):y>1&&(f+=y-1,a-=y-1),a--,w--}for(;x<s.length&&l+1<o.length&&!this._isCharWordSeparator(s.loadCell(x+1,this._workCell));){s.loadCell(x+1,this._workCell);let y=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,x++):y>1&&(p+=y-1,l+=y-1),l++,x++}}l++;let m=a+c-u+f,v=Math.min(this._bufferService.cols,l-a+u+d-f-p);if(!(!t&&o.slice(a,l).trim()==="")){if(n&&m===0&&s.getCodePoint(0)!==32){let w=i.lines.get(e[1]-1);if(w&&s.isWrapped&&w.getCodePoint(this._bufferService.cols-1)!==32){let x=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(x){let _=this._bufferService.cols-x.start;m-=_,v+=_}}}if(r&&m+v===this._bufferService.cols&&s.getCodePoint(this._bufferService.cols-1)!==32){let w=i.lines.get(e[1]+1);if(w!=null&&w.isWrapped&&w.getCodePoint(0)!==32){let x=this._getWordAt([0,e[1]+1],!1,!1,!0);x&&(v+=x.length)}}return{start:m,length:v}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=RC(n,this._bufferService.cols)}};_x=Pt([le(3,zn),le(4,qo),le(5,i1),le(6,$n),le(7,ns),le(8,ts)],_x);var MC=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={}}},AC=class{constructor(){this._color=new MC,this._css=new MC}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()}},Yt=Object.freeze((()=>{let e=[yt.toColor("#2e3436"),yt.toColor("#cc0000"),yt.toColor("#4e9a06"),yt.toColor("#c4a000"),yt.toColor("#3465a4"),yt.toColor("#75507b"),yt.toColor("#06989a"),yt.toColor("#d3d7cf"),yt.toColor("#555753"),yt.toColor("#ef2929"),yt.toColor("#8ae234"),yt.toColor("#fce94f"),yt.toColor("#729fcf"),yt.toColor("#ad7fa8"),yt.toColor("#34e2e2"),yt.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],s=t[n%6];e.push({css:Ht.toCss(r,i,s),rgba:Ht.toRgba(r,i,s)})}for(let n=0;n<24;n++){let r=8+n*10;e.push({css:Ht.toCss(r,r,r),rgba:Ht.toRgba(r,r,r)})}return e})()),so=yt.toColor("#ffffff"),lc=yt.toColor("#000000"),jC=yt.toColor("#ffffff"),LC=lc,Kl={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Bre=so,yx=class extends ze{constructor(e){super(),this._optionsService=e,this._contrastCache=new AC,this._halfContrastCache=new AC,this._onChangeColors=this._register(new te),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:so,background:lc,cursor:jC,cursorAccent:LC,selectionForeground:void 0,selectionBackgroundTransparent:Kl,selectionBackgroundOpaque:pt.blend(lc,Kl),selectionInactiveBackgroundTransparent:Kl,selectionInactiveBackgroundOpaque:pt.blend(lc,Kl),scrollbarSliderBackground:pt.opacity(so,.2),scrollbarSliderHoverBackground:pt.opacity(so,.4),scrollbarSliderActiveBackground:pt.opacity(so,.5),overviewRulerBorder:so,ansi:Yt.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=it(e.foreground,so),t.background=it(e.background,lc),t.cursor=pt.blend(t.background,it(e.cursor,jC)),t.cursorAccent=pt.blend(t.background,it(e.cursorAccent,LC)),t.selectionBackgroundTransparent=it(e.selectionBackground,Kl),t.selectionBackgroundOpaque=pt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=it(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=pt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?it(e.selectionForeground,TC):void 0,t.selectionForeground===TC&&(t.selectionForeground=void 0),pt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=pt.opacity(t.selectionBackgroundTransparent,.3)),pt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=pt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=it(e.scrollbarSliderBackground,pt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=it(e.scrollbarSliderHoverBackground,pt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=it(e.scrollbarSliderActiveBackground,pt.opacity(t.foreground,.5)),t.overviewRulerBorder=it(e.overviewRulerBorder,Bre),t.ansi=Yt.slice(),t.ansi[0]=it(e.black,Yt[0]),t.ansi[1]=it(e.red,Yt[1]),t.ansi[2]=it(e.green,Yt[2]),t.ansi[3]=it(e.yellow,Yt[3]),t.ansi[4]=it(e.blue,Yt[4]),t.ansi[5]=it(e.magenta,Yt[5]),t.ansi[6]=it(e.cyan,Yt[6]),t.ansi[7]=it(e.white,Yt[7]),t.ansi[8]=it(e.brightBlack,Yt[8]),t.ansi[9]=it(e.brightRed,Yt[9]),t.ansi[10]=it(e.brightGreen,Yt[10]),t.ansi[11]=it(e.brightYellow,Yt[11]),t.ansi[12]=it(e.brightBlue,Yt[12]),t.ansi[13]=it(e.brightMagenta,Yt[13]),t.ansi[14]=it(e.brightCyan,Yt[14]),t.ansi[15]=it(e.brightWhite,Yt[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]=it(e.extendedAnsi[r],Yt[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 t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];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()}}};yx=Pt([le(0,$n)],yx);function it(e,t){if(e!==void 0)try{return yt.toColor(e)}catch{}return t}var zre=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)}},$re=class{constructor(){this._services=new zre,this._services.set(r1,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=Ate(e).sort((s,o)=>s.index-o.index),r=[];for(let s of n){let o=this._services.get(s.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${s.id._id}.`);r.push(o)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},Fre={trace:0,debug:1,info:2,warn:3,error:4,off:5},Hre="xterm.js: ",bx=class extends ze{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Fre[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?"":Hre)+t,...n)}trace(e,...t){var n;this._logLevel<=0&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var n;this._logLevel<=1&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var n;this._logLevel<=2&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var n;this._logLevel<=3&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var n;this._logLevel<=4&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.error.bind(this._optionsService.options.logger))??console.error,e,t)}};bx=Pt([le(0,$n)],bx);var DC=class extends ze{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new te),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new te),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new te),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new 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 new 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 r=e;r<this._length-t;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+n.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<n.length;r++)this._array[this._getCyclicIndex(e+r)]=n[r];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let r=this._length+n.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}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 new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let i=t-1;i>=0;i--)this.set(e+i+n,this.get(e+i));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}},Oe=3,zt=Object.freeze(new Du),Dd=0,vg=2,cc=class NA{constructor(t,n,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Oe);let i=n||wr.fromCharData([0,qM,1,0]);for(let s=0;s<t;++s)this.setCell(s,i);this.length=t}get(t){let n=this._data[t*Oe+0],r=n&2097151;return[this._data[t*Oe+1],n&2097152?this._combined[t]:r?gs(r):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,n){this._data[t*Oe+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*Oe+0]=t|2097152|n[2]<<22):this._data[t*Oe+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*Oe+0]>>22}hasWidth(t){return this._data[t*Oe+0]&12582912}getFg(t){return this._data[t*Oe+1]}getBg(t){return this._data[t*Oe+2]}hasContent(t){return this._data[t*Oe+0]&4194303}getCodePoint(t){let n=this._data[t*Oe+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*Oe+0]&2097152}getString(t){let n=this._data[t*Oe+0];return n&2097152?this._combined[t]:n&2097151?gs(n&2097151):""}isProtected(t){return this._data[t*Oe+2]&536870912}loadCell(t,n){return Dd=t*Oe,n.content=this._data[Dd+0],n.fg=this._data[Dd+1],n.bg=this._data[Dd+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*Oe+0]=n.content,this._data[t*Oe+1]=n.fg,this._data[t*Oe+2]=n.bg}setCellFromCodepoint(t,n,r,i){i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*Oe+0]=n|r<<22,this._data[t*Oe+1]=i.fg,this._data[t*Oe+2]=i.bg}addCodepointToCell(t,n,r){let i=this._data[t*Oe+0];i&2097152?this._combined[t]+=gs(n):i&2097151?(this._combined[t]=gs(i&2097151)+gs(n),i&=-2097152,i|=2097152):i=n|1<<22,r&&(i&=-12582913,i|=r<<22),this._data[t*Oe+0]=i}insertCells(t,n,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length-t){let i=new wr;for(let s=this.length-t-n-1;s>=0;--s)this.setCell(t+n+s,this.loadCell(t+s,i));for(let s=0;s<n;++s)this.setCell(t+s,r)}else for(let i=t;i<this.length;++i)this.setCell(i,r);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,r)}deleteCells(t,n,r){if(t%=this.length,n<this.length-t){let i=new wr;for(let s=0;s<this.length-t-n;++s)this.setCell(t+s,this.loadCell(t+n+s,i));for(let s=this.length-n;s<this.length;++s)this.setCell(s,r)}else for(let i=t;i<this.length;++i)this.setCell(i,r);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,r)}replaceCells(t,n,r,i=!1){if(i){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.isProtected(t)||this.setCell(t,r),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.setCell(t++,r)}resize(t,n){if(t===this.length)return this._data.length*4*vg<this._data.buffer.byteLength;let r=t*Oe;if(t>this.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let i=new Uint32Array(r);i.set(this._data),this._data=i}for(let i=this.length;i<t;++i)this.setCell(i,n)}else{this._data=this._data.subarray(0,r);let i=Object.keys(this._combined);for(let o=0;o<i.length;o++){let a=parseInt(i[o],10);a>=t&&delete this._combined[a]}let s=Object.keys(this._extendedAttrs);for(let o=0;o<s.length;o++){let a=parseInt(s[o],10);a>=t&&delete this._extendedAttrs[a]}}return this.length=t,r*4*vg<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*vg<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,n=!1){if(n){for(let r=0;r<this.length;++r)this.isProtected(r)||this.setCell(r,t);return}this._combined={},this._extendedAttrs={};for(let r=0;r<this.length;++r)this.setCell(r,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let n in t._combined)this._combined[n]=t._combined[n];this._extendedAttrs={};for(let n in t._extendedAttrs)this._extendedAttrs[n]=t._extendedAttrs[n];this.isWrapped=t.isWrapped}clone(){let t=new NA(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let n in this._combined)t._combined[n]=this._combined[n];for(let n in this._extendedAttrs)t._extendedAttrs[n]=this._extendedAttrs[n];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Oe+0]&4194303)return t+(this._data[t*Oe+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Oe+0]&4194303||this._data[t*Oe+2]&50331648)return t+(this._data[t*Oe+0]>>22);return 0}copyCellsFrom(t,n,r,i,s){let o=t._data;if(s)for(let l=i-1;l>=0;l--){for(let c=0;c<Oe;c++)this._data[(r+l)*Oe+c]=o[(n+l)*Oe+c];o[(n+l)*Oe+2]&268435456&&(this._extendedAttrs[r+l]=t._extendedAttrs[n+l])}else for(let l=0;l<i;l++){for(let c=0;c<Oe;c++)this._data[(r+l)*Oe+c]=o[(n+l)*Oe+c];o[(n+l)*Oe+2]&268435456&&(this._extendedAttrs[r+l]=t._extendedAttrs[n+l])}let a=Object.keys(t._combined);for(let l=0;l<a.length;l++){let c=parseInt(a[l],10);c>=n&&(this._combined[c-n+r]=t._combined[c])}}translateToString(t,n,r,i){n=n??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),i&&(i.length=0);let s="";for(;n<r;){let o=this._data[n*Oe+0],a=o&2097151,l=o&2097152?this._combined[n]:a?gs(a):Ss;if(s+=l,i)for(let c=0;c<l.length;++c)i.push(n);n+=o>>22||1}return i&&i.push(n),s}};function Ure(e,t,n,r,i,s){let o=[];for(let a=0;a<e.length-1;a++){let l=a,c=e.get(++l);if(!c.isWrapped)continue;let u=[e.get(a)];for(;l<e.length&&c.isWrapped;)u.push(c),c=e.get(++l);if(!s&&r>=a&&r<l){a+=u.length-1;continue}let d=0,f=fu(u,d,t),p=1,m=0;for(;p<u.length;){let w=fu(u,p,t),x=w-m,_=n-f,y=Math.min(x,_);u[d].copyCellsFrom(u[p],m,f,y,!1),f+=y,f===n&&(d++,f=0),m+=y,m===w&&(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 v=0;for(let w=u.length-1;w>0&&(w>d||u[w].getTrimmedLength()===0);w--)v++;v>0&&(o.push(a+u.length-v),o.push(v)),a+=u.length-1}return o}function Wre(e,t){let n=[],r=0,i=t[r],s=0;for(let o=0;o<e.length;o++)if(i===o){let a=t[++r];e.onDeleteEmitter.fire({index:o-s,amount:a}),o+=a-1,s+=a,i=t[++r]}else n.push(o);return{layout:n,countRemoved:s}}function Vre(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let r=0;r<n.length;r++)e.set(r,n[r]);e.length=t.length}function qre(e,t,n){let r=[],i=e.map((l,c)=>fu(e,c,t)).reduce((l,c)=>l+c),s=0,o=0,a=0;for(;a<i;){if(i-a<n){r.push(i-a);break}s+=n;let l=fu(e,o,t);s>l&&(s-=l,o++);let c=e[o].getWidth(s-1)===2;c&&s--;let u=c?n-1:n;r.push(u),a+=u}return r}function fu(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 TA=class IA{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=IA._nextId++,this._onDispose=this.register(new te),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Ao(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};TA._nextId=1;var Kre=TA,en={},oo=en.B;en[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:"≥","{":"π","|":"≠","}":"£","~":"·"};en.A={"#":"£"};en.B=void 0;en[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};en.C=en[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};en.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};en.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};en.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};en.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};en.E=en[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};en.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};en.H=en[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};en["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var OC=4294967295,BC=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=zt.clone(),this.savedCharset=oo,this.markers=[],this._nullCell=wr.fromCharData([0,qM,1,0]),this._whitespaceCell=wr.fromCharData([0,Ss,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new wf,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new DC(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 xf),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 xf),this._whitespaceCell}getBlankLine(e,t){return new cc(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>OC?OC:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=zt);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 DC(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(zt),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 o=0;o<this.lines.length;o++)r+=+this.lines.get(o).resize(e,n);let s=0;if(this._rows<t)for(let o=this._rows;o<t;o++)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 cc(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+s+1?(this.ybase--,s++,this.ydisp>0&&this.ydisp--):this.lines.push(new cc(e,n)));else for(let o=this._rows;o>t;o--)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 o=this.lines.length-i;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),s&&(this.y+=s),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 s=0;s<this.lines.length;s++)r+=+this.lines.get(s).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=Ure(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(zt),n);if(r.length>0){let i=Wre(this.lines,r);Vre(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(zt),i=n;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new cc(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(zt),i=[],s=0;for(let o=this.lines.length-1;o>=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let l=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),l.unshift(a);if(!n){let y=this.ybase+this.y;if(y>=o&&y<o+l.length)continue}let c=l[l.length-1].getTrimmedLength(),u=qre(l,this._cols,e),d=u.length-l.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+d):f=Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let y=0;y<d;y++){let S=this.getBlankLine(zt,!0);p.push(S)}p.length>0&&(i.push({start:o+l.length+s,newLines:p}),s+=p.length),l.push(...p);let m=u.length-1,v=u[m];v===0&&(m--,v=u[m]);let w=l.length-d-1,x=c;for(;w>=0;){let y=Math.min(x,v);if(l[m]===void 0)break;if(l[m].copyCellsFrom(l[w],x-y,v-y,y,!0),v-=y,v===0&&(m--,v=u[m]),x-=y,x===0){w--;let S=Math.max(w,0);x=fu(l,S,this._cols)}}for(let y=0;y<l.length;y++)u[y]<e&&l[y].setCell(u[y],r);let _=d-f;for(;_-- >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+s)-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 o=[],a=[];for(let v=0;v<this.lines.length;v++)a.push(this.lines.get(v));let l=this.lines.length,c=l-1,u=0,d=i[u];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+s);let f=0;for(let v=Math.min(this.lines.maxLength-1,l+s-1);v>=0;v--)if(d&&d.start>c+f){for(let w=d.newLines.length-1;w>=0;w--)this.lines.set(v--,d.newLines[w]);v++,o.push({index:c+1,amount:d.newLines.length}),f+=d.newLines.length,d=i[++u]}else this.lines.set(v,a[c--]);let p=0;for(let v=o.length-1;v>=0;v--)o[v].index+=p,this.lines.onInsertEmitter.fire(o[v]),p+=o[v].amount;let m=Math.max(0,l+s-this.lines.maxLength);m>0&&this.lines.onTrimEmitter.fire(m)}}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]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(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 Kre(e);return this.markers.push(t),t.register(this.lines.onTrim(n=>{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.line<n.index+n.amount&&t.dispose(),t.line>n.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},Gre=class extends ze{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new te),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 BC(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new BC(!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)}},PA=2,RA=1,wx=class extends ze{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new te),this.onResize=this._onResize.event,this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,PA),this.rows=Math.max(e.rawOptions.rows||0,RA),this.buffers=this._register(new Gre(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.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,s=n.ybase+n.scrollBottom;if(n.scrollTop===0){let o=n.lines.isFull;s===n.lines.length-1?o?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(s+1,0,r.clone()),o?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let o=s-i+1;n.lines.shiftElements(i+1,o-1,-1),n.lines.set(s,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))}};wx=Pt([le(0,$n)],wx);var ca={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:bf,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Yre=["normal","bold","100","200","300","400","500","600","700","800","900"],Xre=class extends ze{constructor(e){super(),this._onOptionChange=this._register(new te),this.onOptionChange=this._onOptionChange.event;let t={...ca};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(vt(()=>{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=n=>{if(!(n in ca))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,r)=>{if(!(n in ca))throw new Error(`No option with key "${n}"`);r=this._sanitizeAndValidateOption(n,r),this.rawOptions[n]!==r&&(this.rawOptions[n]=r,this._onOptionChange.fire(n))};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||(t=ca[e]),!Qre(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=ca[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=Yre.includes(t)?t:ca[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new 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 new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function Qre(e){return e==="block"||e==="underline"||e==="bar"}function uc(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]&&uc(e[r],t-1);return n}var zC=Object.freeze({insertMode:!1}),$C=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Sx=class extends ze{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 te),this.onData=this._onData.event,this._onUserInput=this._register(new te),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new te),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new te),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=uc(zC),this.decPrivateModes=uc($C)}reset(){this.modes=uc(zC),this.decPrivateModes=uc($C)}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(r=>r.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(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Sx=Pt([le(0,zn),le(1,QM),le(2,$n)],Sx);var FC={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 xg(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 _g=String.fromCharCode,HC={DEFAULT:e=>{let t=[xg(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${_g(t[0])}${_g(t[1])}${_g(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${xg(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${xg(e,!0)};${e.x};${e.y}${t}`}},kx=class extends ze{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 te),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(FC))this.addProtocol(r,FC[r]);for(let r of Object.keys(HC))this.addEncoding(r,HC[r]);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 new 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 new 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)}};kx=Pt([le(0,zn),le(1,qo),le(2,$n)],kx);var yg=[[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]],Zre=[[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]],Xt;function Jre(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 eie=class{constructor(){if(this.version="6",!Xt){Xt=new Uint8Array(65536),Xt.fill(1),Xt[0]=0,Xt.fill(0,1,32),Xt.fill(0,127,160),Xt.fill(2,4352,4448),Xt[9001]=2,Xt[9002]=2,Xt.fill(2,11904,42192),Xt[12351]=1,Xt.fill(2,44032,55204),Xt.fill(2,63744,64256),Xt.fill(2,65040,65050),Xt.fill(2,65072,65136),Xt.fill(2,65280,65377),Xt.fill(2,65504,65511);for(let e=0;e<yg.length;++e)Xt.fill(0,yg[e][0],yg[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Xt[e]:Jre(e,Zre)?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 i=po.extractWidth(t);i===0?r=!1:i>n&&(n=i)}return po.createPropertyValue(0,n,r)}},po=class mh{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new te,this.onChange=this._onChange.event;let t=new eie;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,r=!1){return(t&16777215)<<3|(n&3)<<1|(r?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let s=0;s<i;++s){let o=t.charCodeAt(s);if(55296<=o&&o<=56319){if(++s>=i)return n+this.wcwidth(o);let c=t.charCodeAt(s);56320<=c&&c<=57343?o=(o-55296)*1024+c-56320+65536:n+=this.wcwidth(c)}let a=this.charProperties(o,r),l=mh.extractWidth(a);mh.extractShouldJoin(a)&&(l-=mh.extractWidth(r)),n+=l,r=a}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},tie=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 UC(e){var r;let t=(r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:r.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 Gl=2147483647,nie=256,MA=class Cx{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>nie)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new Cx;if(!t.length)return n;for(let r=Array.isArray(t[0])?1:0;r<t.length;++r){let i=t[r];if(Array.isArray(i))for(let s=0;s<i.length;++s)n.addSubParam(i[s]);else n.addParam(i)}return n}clone(){let t=new Cx(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 t=[];for(let n=0;n<this.length;++n){t.push(this.params[n]);let r=this._subParamsIdx[n]>>8,i=this._subParamsIdx[n]&255;i-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,i))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Gl?Gl:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>Gl?Gl:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-n>0?this._subParams.subarray(n,r):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let r=this._subParamsIdx[n]>>8,i=this._subParamsIdx[n]&255;i-r>0&&(t[n]=this._subParams.slice(r,i))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,i=r[n-1];r[n-1]=~i?Math.min(i*10+t,Gl):t}},Yl=[],rie=class{constructor(){this._state=0,this._active=Yl,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 r=n.indexOf(t);r!==-1&&n.splice(r,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=Yl}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=Yl,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Yl,!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",Dp(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 r=e[t++];if(r===59){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+r-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=Yl,this._id=-1,this._state=0}}},Jn=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+=Dp(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(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},Xl=[],iie=class{constructor(){this._handlers=Object.create(null),this._active=Xl,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Xl}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,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=Xl,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Xl,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",Dp(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=Xl,this._ident=0}},dc=new MA;dc.addParam(0);var WC=class{constructor(e){this._handler=e,this._data="",this._params=dc,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():dc,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Dp(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(n=>(this._params=dc,this._data="",this._hitLimit=!1,n));return this._params=dc,this._data="",this._hitLimit=!1,t}},sie=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}},mr=160,oie=function(){let e=new sie(4095),t=Array.apply(null,Array(256)).map((a,l)=>l),n=(a,l)=>t.slice(a,l),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let s=n(0,14),o;e.setDefault(1,0),e.addMany(r,0,2,0);for(o in s)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(mr,0,2,0),e.add(mr,8,5,8),e.add(mr,6,0,6),e.add(mr,11,0,11),e.add(mr,13,13,13),e}(),aie=class extends ze{constructor(e=oie){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 MA,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(vt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new rie),this._dcsParser=this._register(new iie),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 new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let i=0;i<e.intermediates.length;++i){let s=e.intermediates.charCodeAt(i);if(32>s||s>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=s}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new 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 i=r.indexOf(t);i!==-1&&r.splice(i,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 i=r.indexOf(t);i!==-1&&r.splice(i,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,s=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,s=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let a=this._parseStack.handlers,l=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&l>-1){for(;l>=0&&(o=a[l](this._params),o!==!0);l--)if(o instanceof Promise)return this._parseStack.handlerPos=l,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&l>-1){for(;l>=0&&(o=a[l](),o!==!0);l--)if(o instanceof Promise)return this._parseStack.handlerPos=l,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,s=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let a=s;a<t;++a){switch(r=e[a],i=this._transitions.table[this.currentState<<8|(r<160?r:mr)],i>>4){case 2:for(let f=a+1;;++f){if(f>=t||(r=e[f])<32||r>126&&r<mr){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(r=e[f])<32||r>126&&r<mr){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(r=e[f])<32||r>126&&r<mr){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(r=e[f])<32||r>126&&r<mr){this._printHandler(e,a,f),a=f-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:a,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let l=this._csiHandlers[this._collect<<8|r],c=l?l.length-1:-1;for(;c>=0&&(o=l[c](this._params),o!==!0);c--)if(o instanceof Promise)return this._preserveStack(3,l,c,i,a),o;c<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(++a<t&&(r=e[a])>47&&r<60);a--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let u=this._escHandlers[this._collect<<8|r],d=u?u.length-1:-1;for(;d>=0&&(o=u[d](),o!==!0);d--)if(o instanceof Promise)return this._preserveStack(4,u,d,i,a),o;d<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 f=a+1;;++f)if(f>=t||(r=e[f])===24||r===26||r===27||r>127&&r<mr){this._dcsParser.put(e,a,f),a=f-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,a),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 f=a+1;;f++)if(f>=t||(r=e[f])<32||r>127&&r<mr){this._oscParser.put(e,a,f),a=f-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,a),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},lie=/^([\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})$/,cie=/^[\da-f]+$/;function VC(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=lie.exec(t);if(n){let r=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/r*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/r*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/r*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),cie.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,r=[0,0,0];for(let i=0;i<3;++i){let s=parseInt(t.slice(n*i,n*i+n),16);r[i]=n===1?s<<4:n===2?s:n===3?s>>4:s>>8}return r}}function bg(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 uie(e,t=16){let[n,r,i]=e;return`rgb:${bg(n,t)}/${bg(r,t)}/${bg(i,t)}`}var die={"(":0,")":1,"*":2,"+":3,"-":1,".":2},us=131072,qC=10;function KC(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 GC=5e3,YC=0,hie=class extends ze{constructor(e,t,n,r,i,s,o,a,l=new aie){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=s,this._coreMouseService=o,this._unicodeService=a,this._parser=l,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Rte,this._utf8Decoder=new Mte,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=zt.clone(),this._eraseAttrDataInternal=zt.clone(),this._onRequestBell=this._register(new te),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new te),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new te),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new te),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new te),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new te),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new te),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new te),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new te),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new te),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new te),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new te),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 Ex(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,u)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:u.toArray()})}),this._parser.setEscHandlerFallback(c=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(c)})}),this._parser.setExecuteHandlerFallback(c=>{this._logService.debug("Unknown EXECUTE code: ",{code:c})}),this._parser.setOscHandlerFallback((c,u,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:u,data:d})}),this._parser.setDcsHandlerFallback((c,u,d)=>{u==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:u,payload:d})}),this._parser.setPrintHandler((c,u,d)=>this.print(c,u,d)),this._parser.registerCsiHandler({final:"@"},c=>this.insertChars(c)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},c=>this.scrollLeft(c)),this._parser.registerCsiHandler({final:"A"},c=>this.cursorUp(c)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},c=>this.scrollRight(c)),this._parser.registerCsiHandler({final:"B"},c=>this.cursorDown(c)),this._parser.registerCsiHandler({final:"C"},c=>this.cursorForward(c)),this._parser.registerCsiHandler({final:"D"},c=>this.cursorBackward(c)),this._parser.registerCsiHandler({final:"E"},c=>this.cursorNextLine(c)),this._parser.registerCsiHandler({final:"F"},c=>this.cursorPrecedingLine(c)),this._parser.registerCsiHandler({final:"G"},c=>this.cursorCharAbsolute(c)),this._parser.registerCsiHandler({final:"H"},c=>this.cursorPosition(c)),this._parser.registerCsiHandler({final:"I"},c=>this.cursorForwardTab(c)),this._parser.registerCsiHandler({final:"J"},c=>this.eraseInDisplay(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},c=>this.eraseInDisplay(c,!0)),this._parser.registerCsiHandler({final:"K"},c=>this.eraseInLine(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},c=>this.eraseInLine(c,!0)),this._parser.registerCsiHandler({final:"L"},c=>this.insertLines(c)),this._parser.registerCsiHandler({final:"M"},c=>this.deleteLines(c)),this._parser.registerCsiHandler({final:"P"},c=>this.deleteChars(c)),this._parser.registerCsiHandler({final:"S"},c=>this.scrollUp(c)),this._parser.registerCsiHandler({final:"T"},c=>this.scrollDown(c)),this._parser.registerCsiHandler({final:"X"},c=>this.eraseChars(c)),this._parser.registerCsiHandler({final:"Z"},c=>this.cursorBackwardTab(c)),this._parser.registerCsiHandler({final:"`"},c=>this.charPosAbsolute(c)),this._parser.registerCsiHandler({final:"a"},c=>this.hPositionRelative(c)),this._parser.registerCsiHandler({final:"b"},c=>this.repeatPrecedingCharacter(c)),this._parser.registerCsiHandler({final:"c"},c=>this.sendDeviceAttributesPrimary(c)),this._parser.registerCsiHandler({prefix:">",final:"c"},c=>this.sendDeviceAttributesSecondary(c)),this._parser.registerCsiHandler({final:"d"},c=>this.linePosAbsolute(c)),this._parser.registerCsiHandler({final:"e"},c=>this.vPositionRelative(c)),this._parser.registerCsiHandler({final:"f"},c=>this.hVPosition(c)),this._parser.registerCsiHandler({final:"g"},c=>this.tabClear(c)),this._parser.registerCsiHandler({final:"h"},c=>this.setMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"h"},c=>this.setModePrivate(c)),this._parser.registerCsiHandler({final:"l"},c=>this.resetMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"l"},c=>this.resetModePrivate(c)),this._parser.registerCsiHandler({final:"m"},c=>this.charAttributes(c)),this._parser.registerCsiHandler({final:"n"},c=>this.deviceStatus(c)),this._parser.registerCsiHandler({prefix:"?",final:"n"},c=>this.deviceStatusPrivate(c)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},c=>this.softReset(c)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},c=>this.setCursorStyle(c)),this._parser.registerCsiHandler({final:"r"},c=>this.setScrollRegion(c)),this._parser.registerCsiHandler({final:"s"},c=>this.saveCursor(c)),this._parser.registerCsiHandler({final:"t"},c=>this.windowOptions(c)),this._parser.registerCsiHandler({final:"u"},c=>this.restoreCursor(c)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},c=>this.insertColumns(c)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},c=>this.deleteColumns(c)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},c=>this.selectProtected(c)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},c=>this.requestMode(c,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},c=>this.requestMode(c,!1)),this._parser.setExecuteHandler(V.BEL,()=>this.bell()),this._parser.setExecuteHandler(V.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(V.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(V.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(V.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(V.BS,()=>this.backspace()),this._parser.setExecuteHandler(V.HT,()=>this.tab()),this._parser.setExecuteHandler(V.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(V.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(fh.IND,()=>this.index()),this._parser.setExecuteHandler(fh.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(fh.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Jn(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new Jn(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new Jn(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new Jn(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new Jn(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new Jn(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new Jn(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new Jn(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new Jn(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new Jn(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new Jn(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new Jn(c=>this.restoreCursorColor(c))),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 c in en)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(c=>(this._logService.error("Parsing error: ",c),c)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new WC((c,u)=>this.requestStatusString(c,u)))}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((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),GC))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${GC} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,s=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>us&&(s=this._parseStack.position+us)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,c=>String.fromCharCode(c)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(c=>c.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<us&&(this._parseBuffer=new Uint32Array(Math.min(e.length,us))),o||this._dirtyRowTracker.clearRange(),e.length>us)for(let c=s;c<e.length;c+=us){let u=c+us<e.length?c+us:e.length,d=typeof e=="string"?this._stringDecoder.decode(e.substring(c,u),this._parseBuffer):this._utf8Decoder.decode(e.subarray(c,u),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,d))return this._preserveStack(r,i,d,c),this._logSlowResolvingAsync(n),n}else if(!o){let c=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,c))return this._preserveStack(r,i,c,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let a=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),l=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);l<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(l,this._bufferService.rows-1),end:Math.min(a,this._bufferService.rows-1)})}print(e,t,n){let r,i,s=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,l=this._coreService.decPrivateModes.wraparound,c=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&&s){let x=s[String.fromCharCode(r)];x&&(r=x.charCodeAt(0))}let m=this._unicodeService.charProperties(r,f);i=po.extractWidth(m);let v=po.extractShouldJoin(m),w=v?po.extractWidth(f):0;if(f=m,o&&this._onA11yChar.fire(gs(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-w>a){if(l){let x=d,_=this._activeBuffer.x-w;for(this._activeBuffer.x=w,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),w>0&&d instanceof cc&&d.copyCellsFrom(x,_,0,w,!1);_<a;)x.setCellFromCodepoint(_++,0,1,u)}else if(this._activeBuffer.x=a-1,i===2)continue}if(v&&this._activeBuffer.x){let x=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-x,r,i);for(let _=i-w;--_>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(c&&(d.insertCells(this._activeBuffer.x,i-w,this._activeBuffer.getNullCell(u)),d.getWidth(a-1)===2&&d.setCellFromCodepoint(a-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<a&&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,n=>KC(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new WC(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Jn(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(){var e;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&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.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 s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(s.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){var r;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--&&!((r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n))!=null&&r.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 i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,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(zt));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 n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.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 n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.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 n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.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 n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.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=po.extractWidth(t),i=this._activeBuffer.x-r,s=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(s.length*n),a=0;for(let c=0;c<s.length;){let u=s.codePointAt(c)||0;o[a++]=u,c+=u>65535?2:1}let l=a;for(let c=1;c<n;++c)o.copyWithin(l,0,a),l+=a;return this.print(o,0,l),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(V.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(V.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(V.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(V.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(V.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,oo),this._charsetService.setgCharset(1,oo),this._charsetService.setgCharset(2,oo),this._charsetService.setgCharset(3,oo);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){(v=>(v[v.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",v[v.SET=1]="SET",v[v.RESET=2]="RESET",v[v.PERMANENTLY_SET=3]="PERMANENTLY_SET",v[v.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:s}=this._coreMouseService,o=this._coreService,{buffers:a,cols:l}=this._bufferService,{active:c,alt:u}=a,d=this._optionsService.rawOptions,f=(v,w)=>(o.triggerDataEvent(`${V.ESC}[${t?"":"?"}${v};${w}$y`),!0),p=v=>v?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?l===80?2:l===132?1:0: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(s==="SGR")):m===1015?f(m,4):m===1016?f(m,p(s==="SGR_PIXELS")):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(c===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|=Du.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,s=0;do{if(r[s+i]=e.params[t+s],e.hasSubParams(t+s)){let o=e.getSubParams(t+s),a=0;do r[1]===5&&(i=1),r[s+a+1+i]=o[a];while(++a<o.length&&a+s+1+i<r.length);break}if(r[1]===5&&s+i>=2||r[1]===2&&s+i>=5)break;r[1]&&(i=1)}while(++s+t<e.length&&s+i<r.length);for(let o=2;o<r.length;++o)r[o]===-1&&(r[o]=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 s}_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=zt.fg,e.bg=zt.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|=16777216|n-90|8):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=16777216|n-100|8):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|=zt.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=zt.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|=zt.fg&16777215,r.bg&=-67108864,r.bg|=zt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${V.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${V.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${V.ESC}[?${t};${n}R`);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=zt.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 n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}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(!KC(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(`${V.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>qC&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>qC&&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 r=n.shift(),i=n.shift();if(/^\d+$/.exec(r)){let s=parseInt(r);if(XC(s))if(i==="?")t.push({type:0,index:s});else{let o=VC(i);o&&t.push({type:1,index:s,color:o})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),r,i=n.findIndex(s=>s.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 r=0;r<n.length&&!(t>=this._specialColors.length);++r,++t)if(n[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let i=VC(n[r]);i&&this._onColor.fire([{type:1,index:this._specialColors[t],color:i}])}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 r=0;r<n.length;++r)if(/^\d+$/.exec(n[r])){let i=parseInt(n[r]);XC(i)&&t.push({type:2,index:i})}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,oo),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(die[e[0]],en[e[1]]||oo),!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=zt.clone(),this._eraseAttrDataInternal=zt.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 wr;e.content=1<<22|69,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=o=>(this._coreService.triggerDataEvent(`${V.ESC}${o}${V.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"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?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Ex=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&&(YC=e,e=t,t=YC),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Ex=Pt([le(0,zn)],Ex);function XC(e){return 0<=e&&e<256}var fie=5e7,QC=12,pie=50,mie=class extends ze{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 te),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 r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>fie)throw new 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 r=this._writeBuffer[this._bufferOffset],i=this._action(r,t);if(i){let o=a=>performance.now()-n>=QC?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(n,a);i.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(o);return}let s=this._callbacks[this._bufferOffset];if(s&&s(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-n>=QC)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>pie&&(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()}},Nx=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 a=t.addMarker(t.ybase+t.y),l={data:e,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(l,a)),this._dataByLinkId.set(l.id,l),l.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 s=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[s]};return s.onDispose(()=>this._removeMarkerFromLink(o,s)),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(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);n.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(n,r))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.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)))}};Nx=Pt([le(0,zn)],Nx);var ZC=!1,gie=class extends ze{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new il),this._onBinary=this._register(new te),this.onBinary=this._onBinary.event,this._onData=this._register(new te),this.onData=this._onData.event,this._onLineFeed=this._register(new te),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new te),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new te),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new te),this._instantiationService=new $re,this.optionsService=this._register(new Xre(e)),this._instantiationService.setService($n,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(wx)),this._instantiationService.setService(zn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(bx)),this._instantiationService.setService(QM,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Sx)),this._instantiationService.setService(qo,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(kx)),this._instantiationService.setService(XM,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(po)),this._instantiationService.setService(Dte,this.unicodeService),this._charsetService=this._instantiationService.createInstance(tie),this._instantiationService.setService(Lte,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Nx),this._instantiationService.setService(ZM,this._oscLinkService),this._inputHandler=this._register(new hie(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(mn.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(mn.forward(this._bufferService.onResize,this._onResize)),this._register(mn.forward(this.coreService.onData,this._onData)),this._register(mn.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 mie((t,n)=>this._inputHandler.parse(t,n))),this._register(mn.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new te),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.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&&!ZC&&(this._logService.warn("writeSync is unreliable and will be removed soon."),ZC=!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,PA),t=Math.max(t,RA),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(UC.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(UC(this._bufferService),!1))),this._windowsWrappingHeuristics.value=vt(()=>{for(let t of e)t.dispose()})}}},vie={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 xie(e,t,n,r){var o;let i={type:0,cancel:!1,key:void 0},s=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?i.key=V.ESC+"OA":i.key=V.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?i.key=V.ESC+"OD":i.key=V.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?i.key=V.ESC+"OC":i.key=V.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?i.key=V.ESC+"OB":i.key=V.ESC+"[B");break;case 8:i.key=e.ctrlKey?"\b":V.DEL,e.altKey&&(i.key=V.ESC+i.key);break;case 9:if(e.shiftKey){i.key=V.ESC+"[Z";break}i.key=V.HT,i.cancel=!0;break;case 13:i.key=e.altKey?V.ESC+V.CR:V.CR,i.cancel=!0;break;case 27:i.key=V.ESC,e.altKey&&(i.key=V.ESC+V.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;s?i.key=V.ESC+"[1;"+(s+1)+"D":t?i.key=V.ESC+"OD":i.key=V.ESC+"[D";break;case 39:if(e.metaKey)break;s?i.key=V.ESC+"[1;"+(s+1)+"C":t?i.key=V.ESC+"OC":i.key=V.ESC+"[C";break;case 38:if(e.metaKey)break;s?i.key=V.ESC+"[1;"+(s+1)+"A":t?i.key=V.ESC+"OA":i.key=V.ESC+"[A";break;case 40:if(e.metaKey)break;s?i.key=V.ESC+"[1;"+(s+1)+"B":t?i.key=V.ESC+"OB":i.key=V.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=V.ESC+"[2~");break;case 46:s?i.key=V.ESC+"[3;"+(s+1)+"~":i.key=V.ESC+"[3~";break;case 36:s?i.key=V.ESC+"[1;"+(s+1)+"H":t?i.key=V.ESC+"OH":i.key=V.ESC+"[H";break;case 35:s?i.key=V.ESC+"[1;"+(s+1)+"F":t?i.key=V.ESC+"OF":i.key=V.ESC+"[F";break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=V.ESC+"[5;"+(s+1)+"~":i.key=V.ESC+"[5~";break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=V.ESC+"[6;"+(s+1)+"~":i.key=V.ESC+"[6~";break;case 112:s?i.key=V.ESC+"[1;"+(s+1)+"P":i.key=V.ESC+"OP";break;case 113:s?i.key=V.ESC+"[1;"+(s+1)+"Q":i.key=V.ESC+"OQ";break;case 114:s?i.key=V.ESC+"[1;"+(s+1)+"R":i.key=V.ESC+"OR";break;case 115:s?i.key=V.ESC+"[1;"+(s+1)+"S":i.key=V.ESC+"OS";break;case 116:s?i.key=V.ESC+"[15;"+(s+1)+"~":i.key=V.ESC+"[15~";break;case 117:s?i.key=V.ESC+"[17;"+(s+1)+"~":i.key=V.ESC+"[17~";break;case 118:s?i.key=V.ESC+"[18;"+(s+1)+"~":i.key=V.ESC+"[18~";break;case 119:s?i.key=V.ESC+"[19;"+(s+1)+"~":i.key=V.ESC+"[19~";break;case 120:s?i.key=V.ESC+"[20;"+(s+1)+"~":i.key=V.ESC+"[20~";break;case 121:s?i.key=V.ESC+"[21;"+(s+1)+"~":i.key=V.ESC+"[21~";break;case 122:s?i.key=V.ESC+"[23;"+(s+1)+"~":i.key=V.ESC+"[23~";break;case 123:s?i.key=V.ESC+"[24;"+(s+1)+"~":i.key=V.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=V.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=V.DEL:e.keyCode===219?i.key=V.ESC:e.keyCode===220?i.key=V.FS:e.keyCode===221&&(i.key=V.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let a=(o=vie[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(a)i.key=V.ESC+a;else if(e.keyCode>=65&&e.keyCode<=90){let l=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(l);e.shiftKey&&(c=c.toUpperCase()),i.key=V.ESC+c}else if(e.keyCode===32)i.key=V.ESC+(e.ctrlKey?V.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let l=e.code.slice(3,4);e.shiftKey||(l=l.toLowerCase()),i.key=V.ESC+l,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=V.US),e.key==="@"&&(i.key=V.NUL));break}return i}var jt=0,_ie=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new wf,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new wf,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((i,s)=>this._getKey(i)-this._getKey(s)),t=0,n=0,r=new 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||(jt=this._search(t),jt===-1)||this._getKey(this._array[jt])!==t)return!1;do if(this._array[jt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(jt),!0;while(++jt<this._array.length&&this._getKey(this._array[jt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((i,s)=>i-s),t=0,n=new 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&&(jt=this._search(e),!(jt<0||jt>=this._array.length)&&this._getKey(this._array[jt])===e))do yield this._array[jt];while(++jt<this._array.length&&this._getKey(this._array[jt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(jt=this._search(e),!(jt<0||jt>=this._array.length)&&this._getKey(this._array[jt])===e))do t(this._array[jt]);while(++jt<this._array.length&&this._getKey(this._array[jt])===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}},wg=0,JC=0,yie=class extends ze{constructor(){super(),this._decorations=new _ie(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new te),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new te),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(vt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new bie(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.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 s of this._decorations.getKeyIterator(t))r=s.options.x??0,i=r+(s.options.width??1),e>=r&&e<i&&(!n||(s.options.layer??"bottom")===n)&&(yield s)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,i=>{wg=i.options.x??0,JC=wg+(i.options.width??1),e>=wg&&e<JC&&(!n||(i.options.layer??"bottom")===n)&&r(i)})}},bie=class extends js{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new te),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new te),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=yt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=yt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},wie=1e3,Sie=class{constructor(e,t=wie){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?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let i=r-this._lastRefreshMs,s=this._debounceThresholdMS-i;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},s)}}_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)}},e2=20,Sf=class extends ze{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 s=0;s<this._terminal.rows;s++)this._rowElements[s]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[s]);if(this._topBoundaryFocusListener=s=>this._handleBoundaryFocus(s,0),this._bottomBoundaryFocusListener=s=>this._handleBoundaryFocus(s,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 Sie(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(s=>this._handleResize(s.rows))),this._register(this._terminal.onRender(s=>this._refreshRows(s.start,s.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(s=>this._handleChar(s))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
565
+ `))),this._register(this._terminal.onA11yTab(s=>this._handleTab(s))),this._register(this._terminal.onKey(s=>this._handleKey(s.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Ee(i,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(vt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<e2+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
566
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===e2+1&&(this._liveRegion.textContent+=K0.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\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 s=n.lines.get(n.ydisp+i),o=[],a=(s==null?void 0:s.translateToString(!0,void 0,void 0,o))||"",l=(n.ydisp+i+1).toString(),c=this._rowElements[i];c&&(a.length===0?(c.textContent=" ",this._rowColumns.set(c,[0,1])):(c.textContent=a,this._rowColumns.set(c,o)),c.setAttribute("aria-posinset",l),c.setAttribute("aria-setsize",r),this._alignRowWidth(c))}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],i=n.getAttribute("aria-posinset"),s=t===0?"1":`${this._terminal.buffer.lines.length}`;if(i===s||e.relatedTarget!==r)return;let o,a;if(t===0?(o=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(o=this._rowElements.shift(),a=n,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let l=this._createAccessibilityTreeNode();this._rowElements.unshift(l),this._rowContainer.insertAdjacentElement("afterbegin",l)}else{let l=this._createAccessibilityTreeNode();this._rowElements.push(l),this._rowContainer.appendChild(l)}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(){var a;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:((a=r.textContent)==null?void 0:a.length)??0}),!this._rowContainer.contains(n.node))return;let i=({node:l,offset:c})=>{let u=l instanceof Text?l.parentNode:l,d=parseInt(u==null?void 0:u.getAttribute("aria-posinset"),10)-1;if(isNaN(d))return console.warn("row is invalid. Race condition?"),null;let f=this._rowColumns.get(u);if(!f)return console.warn("columns is null. Race condition?"),null;let p=c<f.length?f[c]:f.slice(-1)[0]+1;return p>=this._terminal.cols&&(++d,p=0),{row:d,column:p}},s=i(t),o=i(n);if(!(!s||!o)){if(s.row>o.row||s.row===o.row&&s.column>=o.column)throw new Error("invalid range");this._terminal.select(s.column,s.row,(o.row-s.row)*this._terminal.cols-s.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);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){var i,s;e.style.transform="";let t=e.getBoundingClientRect().width,n=(s=(i=this._rowColumns.get(e))==null?void 0:i.slice(-1))==null?void 0:s[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};Sf=Pt([le(1,r1),le(2,ts),le(3,ns)],Sf);var Tx=class extends ze{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 te),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new te),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(vt(()=>{var s;Ao(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(s=this._activeProviderReplies)==null||s.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Ee(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ee(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ee(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ee(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 r=0;r<n.length;r++){let i=n[r];if(i.classList.contains("xterm"))break;if(i.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){var r,i;(!this._activeProviderReplies||!t)&&((r=this._activeProviderReplies)==null||r.forEach(s=>{s==null||s.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[s,o]of this._linkProviderService.linkProviders.entries())t?(i=this._activeProviderReplies)!=null&&i.get(s)&&(n=this._checkLinkProviderResult(s,e,n)):o.provideLinks(e.y,a=>{var c,u;if(this._isMouseOut)return;let l=a==null?void 0:a.map(d=>({link:d}));(c=this._activeProviderReplies)==null||c.set(s,l),n=this._checkLinkProviderResult(s,e,n),((u=this._activeProviderReplies)==null?void 0:u.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 s=0;s<i.length;s++){let o=i[s],a=o.link.range.start.y<e?0:o.link.range.start.x,l=o.link.range.end.y>e?this._bufferService.cols:o.link.range.end.x;for(let c=a;c<=l;c++){if(n.has(c)){i.splice(s--,1);break}n.add(c)}}}}_checkLinkProviderResult(e,t,n){var s;if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let o=0;o<e;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(i=!0);if(!i&&r){let o=r.find(a=>this._linkAtPosition(a.link,t));o&&(n=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let o=0;o<this._activeProviderReplies.size;o++){let a=(s=this._activeProviderReplies.get(o))==null?void 0:s.find(l=>this._linkAtPosition(l.link,t));if(a){n=!0,this._handleNewLink(a);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&&kie(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,Ao(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var n,r;return(r=(n=this._currentLink)==null?void 0:n.state)==null?void 0:r.decorations.pointerCursor},set:n=>{var r;(r=this._currentLink)!=null&&r.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>{var n,r;return(r=(n=this._currentLink)==null?void 0:n.state)==null?void 0:r.decorations.underline},set:n=>{var r,i,s;(r=this._currentLink)!=null&&r.state&&((s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline)!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let r=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,i=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=i&&(this._clearCurrentLink(r,i),this._lastMouseEvent)){let s=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);s&&this._askForLink(s,!1)}})))}_linkHover(e,t,n){var r;(r=this._currentLink)!=null&&r.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){var r;(r=this._currentLink)!=null&&r.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}}};Tx=Pt([le(1,i1),le(2,ns),le(3,zn),le(4,eA)],Tx);function kie(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 Cie=class extends gie{constructor(e={}){super(e),this._linkifier=this._register(new il),this.browser=_A,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new il),this._onCursorMove=this._register(new te),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new te),this.onKey=this._onKey.event,this._onRender=this._register(new te),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new te),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new te),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new te),this.onBell=this._onBell.event,this._onFocus=this._register(new te),this._onBlur=this._register(new te),this._onA11yCharEmitter=this._register(new te),this._onA11yTabEmitter=this._register(new te),this._onWillOpen=this._register(new te),this._setup(),this._decorationService=this._instantiationService.createInstance(yie),this._instantiationService.setService(Ou,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(pre),this._instantiationService.setService(eA,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Y0)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(mn.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(mn.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(mn.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(mn.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(vt(()=>{var t,n;this._customKeyEventHandler=void 0,(n=(t=this.element)==null?void 0:t.parentNode)==null||n.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 n,r="";switch(t.index){case 256:n="foreground",r="10";break;case 257:n="background",r="11";break;case 258:n="cursor",r="12";break;default:n="ansi",r="4;"+t.index}switch(t.type){case 0:let i=pt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${V.ESC}]${r};${uie(i)}${vA.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(s=>s.ansi[t.index]=Ht.toColor(...t.color));else{let s=n;this._themeService.modifyColors(o=>o[s]=Ht.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(Sf,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(V.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(V.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),s=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,a=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=o+"px",this.textarea.style.width=s+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ee(this.element,"copy",t=>{this.hasSelection()&&Ite(t,this._selectionService)}));let e=t=>Pte(t,this.textarea,this.coreService,this.optionsService);this._register(Ee(this.textarea,"paste",e)),this._register(Ee(this.element,"paste",e)),yA?this._register(Ee(this.element,"mousedown",t=>{t.button===2&&uC(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ee(this.element,"contextmenu",t=>{uC(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),h1&&this._register(Ee(this.element,"auxclick",t=>{t.button===1&&VM(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ee(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ee(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ee(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ee(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ee(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ee(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ee(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var i;if(!e)throw new 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"),((i=this.element)==null?void 0:i.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(Ee(this.screenElement,"mousemove",s=>this.updateCursorStyle(s))),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",q0.get()),SA||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(hre,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(ts,this._coreBrowserService),this._register(Ee(this.textarea,"focus",s=>this._handleTextAreaFocus(s))),this._register(Ee(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(gx,this._document,this._helperContainer),this._instantiationService.setService(Op,this._charSizeService),this._themeService=this._instantiationService.createInstance(yx),this._instantiationService.setService(Tl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(yf),this._instantiationService.setService(JM,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(xx,this.rows,this.screenElement)),this._instantiationService.setService(ns,this._renderService),this._register(this._renderService.onRenderedViewportChange(s=>this._onRender.fire(s))),this.onResize(s=>this._renderService.resize(s.cols,s.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(fx,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(vx),this._instantiationService.setService(i1,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Tx,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(dx,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(s=>{super.scrollLines(s,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(_x,this.element,this.screenElement,r)),this._instantiationService.setService(Bte,this._selectionService),this._register(this._selectionService.onRequestScrollLines(s=>this.scrollLines(s.amount,s.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(s=>this._renderService.handleSelectionChanged(s.start,s.end,s.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(s=>{this.textarea.value=s,this.textarea.focus(),this.textarea.select()})),this._register(mn.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var s;this._selectionService.refresh(),(s=this._viewport)==null||s.queueSync()})),this._register(this._instantiationService.createInstance(hx,this.screenElement)),this._register(Ee(this.element,"mousedown",s=>this._selectionService.handleMouseDown(s))),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(Sf,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",s=>this._handleScreenReaderModeOptionChange(s))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(_f,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",s=>{!this._overviewRulerRenderer&&s&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(_f,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(mx,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(s){var c,u,d,f,p;let o=e._mouseService.getMouseReportCoords(s,e.screenElement);if(!o)return!1;let a,l;switch(s.overrideType||s.type){case"mousemove":l=32,s.buttons===void 0?(a=3,s.button!==void 0&&(a=s.button<3?s.button:3)):a=s.buttons&1?0:s.buttons&4?1:s.buttons&2?2:3;break;case"mouseup":l=0,a=s.button<3?s.button:3;break;case"mousedown":l=1,a=s.button<3?s.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(s)===!1)return!1;let m=s.deltaY;if(m===0||e.coreMouseService.consumeWheelEvent(s,(f=(d=(u=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:u.device)==null?void 0:d.cell)==null?void 0:f.height,(p=e._coreBrowserService)==null?void 0:p.dpr)===0)return!1;l=m<0?0:1,a=4;break;default:return!1}return l===void 0||a===void 0||a>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:a,action:l,ctrl:s.ctrlKey,alt:s.altKey,shift:s.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:s=>(n(s),s.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(s)),wheel:s=>(n(s),this.cancel(s,!0)),mousedrag:s=>{s.buttons&&n(s)},mousemove:s=>{s.buttons||n(s)}};this._register(this.coreMouseService.onProtocolChange(s=>{s?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(s)),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()),s&8?r.mousemove||(t.addEventListener("mousemove",i.mousemove),r.mousemove=i.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),s&16?r.wheel||(t.addEventListener("wheel",i.wheel,{passive:!1}),r.wheel=i.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),s&2?r.mouseup||(r.mouseup=i.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),s&4?r.mousedrag||(r.mousedrag=i.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ee(t,"mousedown",s=>{if(s.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(s)))return n(s),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(s)})),this._register(Ee(t,"wheel",s=>{var o,a,l,c,u;if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(s)===!1)return!1;if(!this.buffer.hasScrollback){if(s.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(s,(c=(l=(a=(o=e._renderService)==null?void 0:o.dimensions)==null?void 0:a.device)==null?void 0:l.cell)==null?void 0:c.height,(u=e._coreBrowserService)==null?void 0:u.dpr)===0)return this.cancel(s,!0);let d=V.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(s.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(d,!0),this.cancel(s,!0)}}},{passive:!1}))}refresh(e,t){var n;(n=this._renderService)==null||n.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.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){WM(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 new 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 new 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(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var n;(n=this._selectionService)==null||n.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=xie(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let r=this.rows-1;return this.scrollLines(n.type===2?-r:r),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===V.ETX||n.key===V.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)&&(Eie(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){var n;(n=this._charSizeService)==null||n.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(zt));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(V.ESC+"[I"):this.coreService.triggerDataEvent(V.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${V.ESC}[4;${n};${t}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),i=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${V.ESC}[6;${i};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function Eie(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var Nie=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 new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},Tie=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 wr)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},t2=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 Tie(t)}getNullCell(){return new wr}},Iie=class extends ze{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new te),this.onBufferChange=this._onBufferChange.event,this._normal=new t2(this._core.buffers.normal,"normal"),this._alternate=new t2(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 new 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)}},Pie=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,r)=>t(n,r.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)}},Rie=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}},Mie=["cols","rows"],Xr=0,Aie=class extends ze{constructor(e){super(),this._core=this._register(new Cie(e)),this._addonManager=this._register(new Nie),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],n=(r,i)=>{this._checkReadonlyOptions(r),this._core.options[r]=i};for(let r in this._core.options){let i={get:t.bind(this,r),set:n.bind(this,r)};Object.defineProperty(this._publicOptions,r,i)}}_checkReadonlyOptions(e){if(Mie.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new 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||(this._parser=new Pie(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Rie(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._buffer=this._register(new Iie(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
567
567
  `,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 q0.get()},set promptLabel(e){q0.set(e)},get tooMuchOutput(){return K0.get()},set tooMuchOutput(e){K0.set(e)}}}_verifyIntegers(...e){for(Xr of e)if(Xr===1/0||isNaN(Xr)||Xr%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Xr of e)if(Xr&&(Xr===1/0||isNaN(Xr)||Xr%1!==0||Xr<0))throw new Error("This API only accepts positive integers")}};/**
568
568
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
569
569
  * @license MIT
@@ -575,7 +575,7 @@ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){t
575
575
  * Fabrice Bellard's javascript vt100 for jslinux:
576
576
  * http://bellard.org/jslinux/
577
577
  * Copyright (c) 2011 Fabrice Bellard
578
- */var Eie=2,Nie=1,Tie=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var d;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((d=this._terminal.options.overviewRuler)==null?void 0:d.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),i=Math.max(0,parseInt(n.getPropertyValue("width"))),s=window.getComputedStyle(this._terminal.element),o={top:parseInt(s.getPropertyValue("padding-top")),bottom:parseInt(s.getPropertyValue("padding-bottom")),right:parseInt(s.getPropertyValue("padding-right")),left:parseInt(s.getPropertyValue("padding-left"))},a=o.top+o.bottom,l=o.right+o.left,c=r-a,u=i-l-t;return{cols:Math.max(Eie,Math.floor(u/e.css.cell.width)),rows:Math.max(Nie,Math.floor(c/e.css.cell.height))}}};let Sg;function kg(){return{count:0,byteSum:0,firstT:null,lastT:null}}const Cg=32,e2=320;function Iie({sessionId:e,client:t}){const n=g.useRef(null),r=g.useRef(null),i=g.useRef(null),s=g.useRef([]),o=g.useRef(kg()),a=g.useRef(!1),[l,c]=g.useState("collapsed"),[u,d]=g.useState(null);g.useEffect(()=>{const v=n.current;if(!v)return;let w=!1;const x=(N,T)=>getComputedStyle(document.documentElement).getPropertyValue(N).trim()||T,_=x("--bg-0","#1B1B1B"),y=x("--text-100","#ECECEC"),S=new Cie({fontFamily:"ui-monospace, SF Mono, Menlo, monospace",fontSize:12,lineHeight:1.2,theme:{background:_,foreground:y},minimumContrastRatio:4.5,cursorBlink:!0,convertEol:!1,scrollback:5e3,allowProposedApi:!0,cols:120,rows:40}),C=new Tie;S.loadAddon(C),Me("xterm-mount",{sessionId:e,hostChildCount:v.childNodes.length}),Sg!==e&&(Me("xterm-trace",`===== SWITCH ${Sg??"(initial)"} → ${e} =====`),Sg=e),Me("xterm-trace","effect-setup-start",{sessionId:e,t:performance.now()}),o.current=kg(),S.open(v);const k=S.onData(N=>{const T=btoa(unescape(encodeURIComponent(N)));t.request("session:pty:input",{sessionId:e,data:T}).catch(()=>{})});return(async()=>{var A;let N=0,T=null,O=null;try{Me("xterm-trace","snapshot-rpc-start",{sessionId:e,t:performance.now()});const M=await t.request("session:pty:snapshot",{sessionId:e});if(Me("xterm-trace","snapshot-rpc-resolved",{sessionId:e,cancelled:w,byteLen:((A=M==null?void 0:M.data)==null?void 0:A.length)??0,atSeq:M==null?void 0:M.atSeq,t:performance.now()}),w)return;if(M!=null&&M.ok&&typeof M.data=="string"&&M.data.length>0){const L=atob(M.data),$=new Uint8Array(L.length);for(let F=0;F<L.length;F++)$[F]=L.charCodeAt(F);T=$}M!=null&&M.ok&&typeof M.atSeq=="number"&&(N=M.atSeq),M!=null&&M.ok&&M.popupKind!=null&&(O=M.popupKind)}catch{}if(w)return;r.current=S,i.current=C;let P=!1,D;const R=S.onRender(()=>{if(!P){P=!0;try{C.fit(),T&&S.write(T),Me("xterm-trace","snapshot-flush",{sessionId:e,atSeq:N,pendingFrameCount:s.current.length,frameStatsBeforeFlush:{...o.current},t:performance.now()}),o.current=kg();const M=s.current;s.current=[];let L=0;for(const $ of M){if($.seq!==void 0&&$.seq<=N){L++;continue}S.write($.bytes)}L>0&&Me("xterm-trace","snapshot-flush-dropped",{sessionId:e,dropped:L,atSeq:N}),a.current=!0,O!=null&&(d(O),c("expanded"),requestAnimationFrame(()=>S.focus())),t.request("session:pty:resize",{sessionId:e,cols:S.cols,rows:S.rows}).catch(()=>{})}catch{}S.scrollToBottom(),D?D():setTimeout(()=>D==null?void 0:D(),0)}});D=()=>R.dispose()})(),()=>{Me("xterm-trace","cleanup-start",{sessionId:e,pendingFrameCount:s.current.length,termReady:a.current,frameStatsThisMount:{...o.current},t:performance.now()}),w=!0,k.dispose(),S.dispose(),r.current=null,i.current=null,a.current=!1,s.current=[],Me("xterm-trace","cleanup-cleared-pending",{sessionId:e,t:performance.now()})}},[e,t]),g.useEffect(()=>{const v=t.on("session:pty",x=>{const _=x;if(_.sessionId!==e||typeof _.data!="string")return;const y=o.current;y.count++,y.byteSum+=_.data.length;const S=performance.now();y.firstT===null&&(y.firstT=S),y.lastT=S;try{const C=atob(_.data),k=new Uint8Array(C.length);for(let N=0;N<C.length;N++)k[N]=C.charCodeAt(N);a.current&&r.current?r.current.write(k):s.current.push({seq:_.seq,bytes:k})}catch{}}),w=t.on("session:control",x=>{const _=x;if(_.sessionId===e)switch(_.kind){case"popup_open":(_.popupKind==="permission"||_.popupKind==="question")&&(d(_.popupKind),c("expanded"),requestAnimationFrame(()=>{var y;return(y=r.current)==null?void 0:y.focus()}));break;case"popup_close":d(null),c("collapsed");break}});return()=>{v(),w(),Me("xterm-trace","cleanup-off-listener",{sessionId:e,t:performance.now()})}},[e,t]),g.useEffect(()=>{const v=n.current;if(!v)return;let w=0,x=0;const _=()=>{const S=i.current,C=r.current;if(!(!S||!C)){try{S.fit()}catch{return}try{C.refresh(0,C.rows-1)}catch{}C.cols===w&&C.rows===x||(w=C.cols,x=C.rows,t.request("session:pty:resize",{sessionId:e,cols:C.cols,rows:C.rows}).catch(()=>{}))}},y=new ResizeObserver(()=>_());return y.observe(v),()=>y.disconnect()},[e,t]);const f=()=>{c(v=>{const w=v==="collapsed"?"expanded":"collapsed";return w==="expanded"&&requestAnimationFrame(()=>{var x;return(x=r.current)==null?void 0:x.focus()}),w})},p=l==="expanded"?e2:Cg,m=e2-Cg;return h.jsxs("div",{className:"border-t border-border bg-bg-0 overflow-hidden",style:{height:p},"data-testid":"xterm-panel","data-state":l,"data-mode":"tui","data-popup-kind":u??"",children:[h.jsxs("button",{type:"button",onClick:f,className:"flex items-center justify-between w-full px-3 py-1 text-xs text-text-200 bg-bg-200 hover:bg-bg-300 cursor-pointer border-b border-border",style:{height:Cg,flexShrink:0},"data-testid":"xterm-panel-toggle",children:[h.jsxs("span",{className:"font-mono",children:[u==="permission"&&"⚠️ CC 需要权限确认 — 在下方终端按数字键 / Enter 选择",u==="question"&&"❓ CC 在问问题 — 在下方终端用 ↑/↓ + Enter 选择",u===null&&(l==="collapsed"?"▴ 展开原生 TUI 终端":"▾ 收起 TUI 终端")]}),h.jsx("span",{className:"text-text-200 text-[10px] opacity-60",children:l==="expanded"?"点击收起":"点击展开"})]}),h.jsx("div",{ref:n,className:"p-1",style:{height:m},"data-testid":"xterm-panel-host"})]})}function RA(e,t){const n=zo(),r=e?`session/${e}`:"",i=pi(r)??eu,s=g.useCallback(d=>{!e||!r||n.setData(r,f=>dI(f??eu,d,e))},[n,r,e]),o=g.useCallback(()=>{e&&s({type:"session:change",sessionId:e})},[s,e]),a=g.useCallback(d=>{e&&s({type:"permission:clear",sessionId:e,requestId:d})},[s,e]),l=g.useCallback(d=>{e&&s({type:"permission:request",sessionId:e,requestId:d.requestId,tool:d.tool,input:d.input,...d.toolUseId?{toolUseId:d.toolUseId}:{}})},[s,e]),c=g.useCallback(d=>{e&&s({type:"session:question:clear",sessionId:e,toolUseId:d})},[s,e]),u=g.useCallback((d,f)=>{e&&s({type:"session:question:submitted",sessionId:e,toolUseId:d,answers:f})},[s,e]);return{...i,reset:o,clearPermission:a,restorePermission:l,clearQuestion:c,markQuestionSubmitted:u}}function f1(e){const t=pi(e?`capabilities/${e}`:"");return e?{capabilities:t??null,loading:!t}:{capabilities:null,loading:!1}}function Pie(e){return e.kind!=="user-text"?!1:e.meta===void 0||e.meta==="slash-command"||op(e.meta)}function Rie(e,t={}){let n=0;if(t.implicitCloseOnUserText){for(const r of e)Pie(r)&&n++;return n}for(const r of e)r.kind==="turn-end"&&n++;return n}const Mie=50;function Aie({api:e,sessionId:t,toolSessionId:n,initialTurns:r,implicitCloseOnUserText:i,pageSize:s=Mie}){const[o,a]=g.useState({messages:[],total:0,loading:!1,error:null}),l=g.useRef(n),c=g.useRef(null),u=g.useRef(0),d=g.useRef(!0);return g.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),g.useEffect(()=>{const f=l.current;if(l.current=n,!(c.current!==t)&&!(typeof f=="string"&&f!==n))return;if(a({messages:[],total:0,loading:!1,error:null}),!t){c.current=null;return}c.current=t;const v=++u.current;a(w=>({...w,loading:!0,error:null})),(async()=>{let w=[],x=!1,_=r===void 0?{}:{limit:s},y=Number.POSITIVE_INFINITY;for(;;){let S;try{S=await e.historyRead({sessionId:t,..._})}catch(D){if(v!==u.current||!d.current)return;const R=D.message??"history load failed";a(x?A=>({...A,error:R}):{messages:[],total:0,loading:!1,error:R});return}if(v!==u.current||!d.current)return;w=[...S.messages??[],...w];const C=S.total??0,k=typeof S.offset=="number"?S.offset:0,N=k>=y,T=k<=0||N;y=k;const O=r!==void 0&&Rie(w,{implicitCloseOnUserText:i})>=r;if(x?a({messages:w,total:C,loading:!1,error:null}):(T||O)&&(x=!0,a({messages:w,total:C,loading:!1,error:null})),T)return;const P=Math.max(0,k-s);_={offset:P,limit:k-P}}})()},[e,t,n,s,r]),o}function t2(e){const t=jp(e);return t.commandName?t.commandArgs?`${t.commandName} ${t.commandArgs}`:t.commandName:e}function n2(e){return e.kind==="user-text"?!0:e.kind!=="user-meta"?!1:e.metaKind==="slash-command"||op(e.metaKind)}function jie(e,t){const n=t.find(n2);if(!n)return e;const r=t2(n.text);for(let s=e.length-1;s>=0;s--){const o=e[s];if(n2(o)&&t2(o.text)===r)return e.slice(0,s)}const i=e[e.length-1];return i!==void 0&&i.kind!=="turn-end"?[...e,{kind:"turn-end",seq:i.seq+1}]:e}const Lie=1e6,Die=5;function Oie(e){if(!e)return;const t=e.contextUsage,n=e.contextWindowSize;if(!t||!n||n<=0)return;const r=t.inputTokens+(t.cacheReadTokens??0)+(t.cacheCreateTokens??0);if(!(r<=0))return Math.round(r/n*100)}function MA(e){const t=_i(),n=g.useMemo(()=>new Y_(t),[t]),r=pi("sessions"),i=g.useMemo(()=>r==null?void 0:r.find(E=>E.sessionId===e),[r,e]),s=i==null?void 0:i.toolSessionId,o=i==null?void 0:i.tool,a=RA(e),{events:l,pendingPermissions:c,queued:u,status:d,clearPermission:f,restorePermission:p}=a,m=jz(),v=Aie({api:n,sessionId:e,toolSessionId:s,initialTurns:m==="owner"?void 0:Die,implicitCloseOnUserText:o==="codex"}),w=g.useMemo(()=>v.messages.filter(E=>!E.isSidechain),[v.messages]),x=g.useMemo(()=>ote(zM(w,0,o)),[w,o]),_=c[0]??null,y=g.useMemo(()=>rte(l,(_==null?void 0:_.requestId)??null),[l,_==null?void 0:_.requestId]),S=g.useMemo(()=>jie(x,y),[x,y]),C=g.useMemo(()=>y.map((E,H)=>({...E,seq:Lie+H})),[y]),k=g.useMemo(()=>[...S,...C],[S,C]),N=$M(d),T=gte(d),O=(i==null?void 0:i.resolvedModel)??(i==null?void 0:i.model),P=g.useMemo(()=>({sessionLabel:(i==null?void 0:i.label)||(i==null?void 0:i.aiLabel)||(i==null?void 0:i.larkChatName)||(i==null?void 0:i.larkChatId)||e,sessionId:e,...i!=null&&i.larkChatId?{larkChatName:i.larkChatName??i.larkChatId,larkChatType:i.larkChatType??"group"}:{},...O?{model:O}:{},...(()=>{const E=i==null?void 0:i.gitBranch;return E?{gitBranch:E}:{}})(),...(()=>{const E=Oie(i);return E!==void 0?{contextPct:E}:{}})(),...i!=null&&i.cwd?{cwd:i.cwd}:{},...(()=>{const E=i==null?void 0:i.permissionMode;return E?{permissionMode:E}:{}})(),procAlive:N,streamInProgress:T,pinnedAt:(i==null?void 0:i.pinnedAt)??null}),[i,e,O,N,T]),D=g.useMemo(()=>t.isOpen?d==="error"?{kind:"error",message:"session error"}:{kind:"ready"}:{kind:"closed"},[t.isOpen,d]),R=g.useCallback(async(E,H)=>{await n.sessionSend(e,E,H)},[n,e]),A=g.useCallback(async E=>{await n.sessionDequeue(e,E)},[n,e]),M=g.useCallback(async()=>(await n.sessionInterrupt(e)).queued??[],[n,e]),L=g.useCallback(async E=>{if(!(i!=null&&i.cwd)||!s)throw new Error("fork requires sessionFile with cwd + toolSessionId");await n.sessionFork({cwd:i.cwd,toolSessionId:s,messageUuid:E})},[n,i==null?void 0:i.cwd,s]),$=g.useCallback(async E=>{await n.sessionRewind({sessionId:e,userMessageId:E,dryRun:!1})},[n,e]),F=g.useCallback(async E=>{await n.sessionUpdate(e,{model:E})},[n,e]),B=g.useCallback(async()=>{await n.sessionNew(e)},[n,e]),z=g.useCallback(async(E,H)=>{const q=c.find(j=>j.requestId===E);q&&f(E);try{await n.permissionRespond({sessionId:e,permissionRequestId:E,allow:H==="allow"})}catch(j){throw!((j==null?void 0:j.message)??"").startsWith("PERMISSION_REQUEST_STALE")&&q&&p(q),j}},[n,e,c,f,p]);return g.useMemo(()=>({lines:k,connState:D,meta:P,historyLoading:v.loading,historyError:v.error,pendingPermissions:c,queued:u,sendText:R,dequeue:A,interrupt:M,fork:L,rewind:$,switchModel:F,clearSession:B,respondPermission:z}),[k,D,P,v.loading,v.error,c,u,R,A,M,L,$,F,B,z])}function Bie({api:e,scope:t,sessionId:n,onShareFile:r,onOpenInTab:i,onPreviewMarkdown:s}){const[o,a]=g.useState([]),[l,c]=g.useState(null);g.useEffect(()=>{let d=!1;return(async()=>{try{const f=await e.attachmentGroupList(n);if(d)return;a(f.entries)}catch(f){d||c(f.message)}})(),()=>{d=!0}},[e,n]);async function u(d){try{await e.attachmentGroupRemove(n,d.relPath),a(f=>d.from==="owner"?f.filter(p=>p.relPath!==d.relPath):f.map(p=>p.relPath===d.relPath?{...p,stale:!0}:p))}catch(f){c(f.message)}}return h.jsx(cf,{delayDuration:120,children:h.jsx("div",{"data-testid":"files-panel-body",className:"flex h-full flex-col",children:h.jsxs("div",{className:"flex-1 overflow-y-auto",children:[h.jsx(zie,{title:`Session files (${o.length})`,subtitle:"agent Write/Edit 自动入清单",children:o.length===0?h.jsx(Fie,{text:"还没有文件。agent Write/Edit 会自动加入清单。"}):o.map(d=>h.jsx($ie,{entry:d,onShareLink:()=>r(d.relPath),...i?{onOpenInTab:()=>i(d.relPath)}:{},...s&&!d.stale&&Lp(d.relPath)?{onPreview:()=>s(d.relPath)}:{},onRemove:()=>u(d)},d.id))}),l?h.jsx("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-[11px] text-destructive",children:l}):null]})})})}function zie({title:e,subtitle:t,children:n}){return h.jsxs("div",{className:"border-b border-border last:border-b-0",children:[h.jsx("div",{className:"sticky top-0 z-10 flex items-start justify-between bg-bg-100 px-4 py-2",children:h.jsxs("div",{className:"flex-1",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-text-300",children:e}),t?h.jsx("div",{className:"mt-0.5 text-[11px] text-text-400",children:t}):null]})}),h.jsx("div",{className:"flex flex-col",children:n})]})}function $ie({entry:e,onShareLink:t,onOpenInTab:n,onPreview:r,onRemove:i}){var c;const s=(c=e.mime)!=null&&c.startsWith("image/")?s8:mi,o=e.relPath.lastIndexOf("/"),a=o>=0?e.relPath.slice(0,o+1):"",l=o>=0?e.relPath.slice(o+1):e.relPath;return h.jsxs("div",{"data-testid":"files-panel-row",className:re("group flex items-center gap-2 px-4 py-2 hover:bg-bg-200",e.stale&&"opacity-50"),children:[h.jsx(s,{className:"h-4 w-4 shrink-0 text-text-400"}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsxs(Ep,{children:[h.jsx(Np,{asChild:!0,children:r?h.jsxs("button",{type:"button","data-testid":"files-panel-preview",onClick:r,className:"flex min-w-0 items-baseline text-left text-[13px] text-text-100 hover:text-accent hover:underline underline-offset-2 cursor-pointer",children:[a?h.jsx("span",{className:"truncate text-text-400",children:a}):null,h.jsx("span",{className:"shrink-0",children:l})]}):h.jsxs("span",{className:"flex min-w-0 items-baseline text-[13px] text-text-100",children:[a?h.jsx("span",{className:"truncate text-text-400",children:a}):null,h.jsx("span",{className:"shrink-0",children:l})]})}),h.jsx(Mu,{side:"top",align:"start",className:"max-w-[380px] break-all",children:e.relPath})]}),e.stale&&h.jsx("span",{className:"rounded bg-text-100/10 px-1 py-0 text-[10px] uppercase text-text-400",children:"stale"})]}),h.jsxs("div",{className:"flex items-center gap-1.5 truncate text-[11px] text-text-400",children:[h.jsx("span",{children:e.from}),h.jsx("span",{children:"·"}),h.jsx("span",{children:Hie(e.addedAt)})]})]}),!e.stale&&h.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:[n?h.jsx(Eg,{icon:h.jsx(tu,{className:"h-3.5 w-3.5"}),title:"Open in tab",onClick:n}):null,h.jsx(Eg,{icon:h.jsx(Z_,{className:"h-3.5 w-3.5"}),title:"Share link",onClick:t}),e.from==="owner"&&h.jsx(Eg,{icon:h.jsx(J_,{className:"h-3.5 w-3.5"}),title:"Remove",onClick:i})]})]})}function Eg({icon:e,title:t,onClick:n}){return h.jsx("button",{type:"button",onClick:n,title:t,"aria-label":t,className:"flex h-7 w-7 items-center justify-center rounded text-text-400 hover:bg-text-100/10 hover:text-text-100",children:e})}function Fie({text:e}){return h.jsx("div",{className:"px-4 py-3 text-[12px] italic text-text-400",children:e})}function Hie(e){const t=Date.now()-e;return t<6e4?`${Math.max(1,Math.floor(t/1e3))}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}var $u={},Uie=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},AA={},ur={};let p1;const Wie=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];ur.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17};ur.getSymbolTotalCodewords=function(t){return Wie[t]};ur.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};ur.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');p1=t};ur.isKanjiModeEnabled=function(){return typeof p1<"u"};ur.toSJIS=function(t){return p1(t)};var $p={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},e.from=function(r,i){if(e.isValid(r))return r;try{return t(r)}catch{return i}}})($p);function jA(){this.buffer=[],this.length=0}jA.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var Vie=jA;function Fu(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}Fu.prototype.set=function(e,t,n,r){const i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)};Fu.prototype.get=function(e,t){return this.data[e*this.size+t]};Fu.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n};Fu.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var qie=Fu,LA={};(function(e){const t=ur.getSymbolSize;e.getRowColCoords=function(r){if(r===1)return[];const i=Math.floor(r/7)+2,s=t(r),o=s===145?26:Math.ceil((s-13)/(2*i-2))*2,a=[s-7];for(let l=1;l<i-1;l++)a[l]=a[l-1]-o;return a.push(6),a.reverse()},e.getPositions=function(r){const i=[],s=e.getRowColCoords(r),o=s.length;for(let a=0;a<o;a++)for(let l=0;l<o;l++)a===0&&l===0||a===0&&l===o-1||a===o-1&&l===0||i.push([s[a],s[l]]);return i}})(LA);var DA={};const Kie=ur.getSymbolSize,r2=7;DA.getPositions=function(t){const n=Kie(t);return[[0,0],[n-r2,0],[0,n-r2]]};var OA={};(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(i){return i!=null&&i!==""&&!isNaN(i)&&i>=0&&i<=7},e.from=function(i){return e.isValid(i)?parseInt(i,10):void 0},e.getPenaltyN1=function(i){const s=i.size;let o=0,a=0,l=0,c=null,u=null;for(let d=0;d<s;d++){a=l=0,c=u=null;for(let f=0;f<s;f++){let p=i.get(d,f);p===c?a++:(a>=5&&(o+=t.N1+(a-5)),c=p,a=1),p=i.get(f,d),p===u?l++:(l>=5&&(o+=t.N1+(l-5)),u=p,l=1)}a>=5&&(o+=t.N1+(a-5)),l>=5&&(o+=t.N1+(l-5))}return o},e.getPenaltyN2=function(i){const s=i.size;let o=0;for(let a=0;a<s-1;a++)for(let l=0;l<s-1;l++){const c=i.get(a,l)+i.get(a,l+1)+i.get(a+1,l)+i.get(a+1,l+1);(c===4||c===0)&&o++}return o*t.N2},e.getPenaltyN3=function(i){const s=i.size;let o=0,a=0,l=0;for(let c=0;c<s;c++){a=l=0;for(let u=0;u<s;u++)a=a<<1&2047|i.get(c,u),u>=10&&(a===1488||a===93)&&o++,l=l<<1&2047|i.get(u,c),u>=10&&(l===1488||l===93)&&o++}return o*t.N3},e.getPenaltyN4=function(i){let s=0;const o=i.data.length;for(let l=0;l<o;l++)s+=i.data[l];return Math.abs(Math.ceil(s*100/o/5)-10)*t.N4};function n(r,i,s){switch(r){case e.Patterns.PATTERN000:return(i+s)%2===0;case e.Patterns.PATTERN001:return i%2===0;case e.Patterns.PATTERN010:return s%3===0;case e.Patterns.PATTERN011:return(i+s)%3===0;case e.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(s/3))%2===0;case e.Patterns.PATTERN101:return i*s%2+i*s%3===0;case e.Patterns.PATTERN110:return(i*s%2+i*s%3)%2===0;case e.Patterns.PATTERN111:return(i*s%3+(i+s)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}e.applyMask=function(i,s){const o=s.size;for(let a=0;a<o;a++)for(let l=0;l<o;l++)s.isReserved(l,a)||s.xor(l,a,n(i,l,a))},e.getBestMask=function(i,s){const o=Object.keys(e.Patterns).length;let a=0,l=1/0;for(let c=0;c<o;c++){s(c),e.applyMask(c,i);const u=e.getPenaltyN1(i)+e.getPenaltyN2(i)+e.getPenaltyN3(i)+e.getPenaltyN4(i);e.applyMask(c,i),u<l&&(l=u,a=c)}return a}})(OA);var Fp={};const ks=$p,Od=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],Bd=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];Fp.getBlocksCount=function(t,n){switch(n){case ks.L:return Od[(t-1)*4+0];case ks.M:return Od[(t-1)*4+1];case ks.Q:return Od[(t-1)*4+2];case ks.H:return Od[(t-1)*4+3];default:return}};Fp.getTotalCodewordsCount=function(t,n){switch(n){case ks.L:return Bd[(t-1)*4+0];case ks.M:return Bd[(t-1)*4+1];case ks.Q:return Bd[(t-1)*4+2];case ks.H:return Bd[(t-1)*4+3];default:return}};var BA={},Hp={};const Ic=new Uint8Array(512),kf=new Uint8Array(256);(function(){let t=1;for(let n=0;n<255;n++)Ic[n]=t,kf[t]=n,t<<=1,t&256&&(t^=285);for(let n=255;n<512;n++)Ic[n]=Ic[n-255]})();Hp.log=function(t){if(t<1)throw new Error("log("+t+")");return kf[t]};Hp.exp=function(t){return Ic[t]};Hp.mul=function(t,n){return t===0||n===0?0:Ic[kf[t]+kf[n]]};(function(e){const t=Hp;e.mul=function(r,i){const s=new Uint8Array(r.length+i.length-1);for(let o=0;o<r.length;o++)for(let a=0;a<i.length;a++)s[o+a]^=t.mul(r[o],i[a]);return s},e.mod=function(r,i){let s=new Uint8Array(r);for(;s.length-i.length>=0;){const o=s[0];for(let l=0;l<i.length;l++)s[l]^=t.mul(i[l],o);let a=0;for(;a<s.length&&s[a]===0;)a++;s=s.slice(a)}return s},e.generateECPolynomial=function(r){let i=new Uint8Array([1]);for(let s=0;s<r;s++)i=e.mul(i,new Uint8Array([1,t.exp(s)]));return i}})(BA);const zA=BA;function m1(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}m1.prototype.initialize=function(t){this.degree=t,this.genPoly=zA.generateECPolynomial(this.degree)};m1.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(t.length+this.degree);n.set(t);const r=zA.mod(n,this.genPoly),i=this.degree-r.length;if(i>0){const s=new Uint8Array(this.degree);return s.set(r,i),s}return r};var Gie=m1,$A={},Gs={},g1={};g1.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var wi={};const FA="[0-9]+",Yie="[A-Z $%*+\\-./:]+";let pu="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";pu=pu.replace(/u/g,"\\u");const Xie="(?:(?![A-Z0-9 $%*+\\-./:]|"+pu+`)(?:.|[\r
578
+ */var jie=2,Lie=1,Die=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var d;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((d=this._terminal.options.overviewRuler)==null?void 0:d.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),i=Math.max(0,parseInt(n.getPropertyValue("width"))),s=window.getComputedStyle(this._terminal.element),o={top:parseInt(s.getPropertyValue("padding-top")),bottom:parseInt(s.getPropertyValue("padding-bottom")),right:parseInt(s.getPropertyValue("padding-right")),left:parseInt(s.getPropertyValue("padding-left"))},a=o.top+o.bottom,l=o.right+o.left,c=r-a,u=i-l-t;return{cols:Math.max(jie,Math.floor(u/e.css.cell.width)),rows:Math.max(Lie,Math.floor(c/e.css.cell.height))}}};let Sg;function kg(){return{count:0,byteSum:0,firstT:null,lastT:null}}const Cg=32,n2=320;function Oie({sessionId:e,client:t}){const n=g.useRef(null),r=g.useRef(null),i=g.useRef(null),s=g.useRef([]),o=g.useRef(kg()),a=g.useRef(!1),[l,c]=g.useState("collapsed"),[u,d]=g.useState(null);g.useEffect(()=>{const v=n.current;if(!v)return;let w=!1;const x=(N,T)=>getComputedStyle(document.documentElement).getPropertyValue(N).trim()||T,_=x("--bg-0","#1B1B1B"),y=x("--text-100","#ECECEC"),S=new Aie({fontFamily:"ui-monospace, SF Mono, Menlo, monospace",fontSize:12,lineHeight:1.2,theme:{background:_,foreground:y},minimumContrastRatio:4.5,cursorBlink:!0,convertEol:!1,scrollback:5e3,allowProposedApi:!0,cols:120,rows:40}),C=new Die;S.loadAddon(C),Me("xterm-mount",{sessionId:e,hostChildCount:v.childNodes.length}),Sg!==e&&(Me("xterm-trace",`===== SWITCH ${Sg??"(initial)"} → ${e} =====`),Sg=e),Me("xterm-trace","effect-setup-start",{sessionId:e,t:performance.now()}),o.current=kg(),S.open(v);const k=S.onData(N=>{const T=btoa(unescape(encodeURIComponent(N)));t.request("session:pty:input",{sessionId:e,data:T}).catch(()=>{})});return(async()=>{var A;let N=0,T=null,O=null;try{Me("xterm-trace","snapshot-rpc-start",{sessionId:e,t:performance.now()});const M=await t.request("session:pty:snapshot",{sessionId:e});if(Me("xterm-trace","snapshot-rpc-resolved",{sessionId:e,cancelled:w,byteLen:((A=M==null?void 0:M.data)==null?void 0:A.length)??0,atSeq:M==null?void 0:M.atSeq,t:performance.now()}),w)return;if(M!=null&&M.ok&&typeof M.data=="string"&&M.data.length>0){const L=atob(M.data),$=new Uint8Array(L.length);for(let F=0;F<L.length;F++)$[F]=L.charCodeAt(F);T=$}M!=null&&M.ok&&typeof M.atSeq=="number"&&(N=M.atSeq),M!=null&&M.ok&&M.popupKind!=null&&(O=M.popupKind)}catch{}if(w)return;r.current=S,i.current=C;let P=!1,D;const R=S.onRender(()=>{if(!P){P=!0;try{C.fit(),T&&S.write(T),Me("xterm-trace","snapshot-flush",{sessionId:e,atSeq:N,pendingFrameCount:s.current.length,frameStatsBeforeFlush:{...o.current},t:performance.now()}),o.current=kg();const M=s.current;s.current=[];let L=0;for(const $ of M){if($.seq!==void 0&&$.seq<=N){L++;continue}S.write($.bytes)}L>0&&Me("xterm-trace","snapshot-flush-dropped",{sessionId:e,dropped:L,atSeq:N}),a.current=!0,O!=null&&(d(O),c("expanded"),requestAnimationFrame(()=>S.focus())),t.request("session:pty:resize",{sessionId:e,cols:S.cols,rows:S.rows}).catch(()=>{})}catch{}S.scrollToBottom(),D?D():setTimeout(()=>D==null?void 0:D(),0)}});D=()=>R.dispose()})(),()=>{Me("xterm-trace","cleanup-start",{sessionId:e,pendingFrameCount:s.current.length,termReady:a.current,frameStatsThisMount:{...o.current},t:performance.now()}),w=!0,k.dispose(),S.dispose(),r.current=null,i.current=null,a.current=!1,s.current=[],Me("xterm-trace","cleanup-cleared-pending",{sessionId:e,t:performance.now()})}},[e,t]),g.useEffect(()=>{const v=t.on("session:pty",x=>{const _=x;if(_.sessionId!==e||typeof _.data!="string")return;const y=o.current;y.count++,y.byteSum+=_.data.length;const S=performance.now();y.firstT===null&&(y.firstT=S),y.lastT=S;try{const C=atob(_.data),k=new Uint8Array(C.length);for(let N=0;N<C.length;N++)k[N]=C.charCodeAt(N);a.current&&r.current?r.current.write(k):s.current.push({seq:_.seq,bytes:k})}catch{}}),w=t.on("session:control",x=>{const _=x;if(_.sessionId===e)switch(_.kind){case"popup_open":(_.popupKind==="permission"||_.popupKind==="question")&&(d(_.popupKind),c("expanded"),requestAnimationFrame(()=>{var y;return(y=r.current)==null?void 0:y.focus()}));break;case"popup_close":d(null),c("collapsed");break}});return()=>{v(),w(),Me("xterm-trace","cleanup-off-listener",{sessionId:e,t:performance.now()})}},[e,t]),g.useEffect(()=>{const v=n.current;if(!v)return;let w=0,x=0;const _=()=>{const S=i.current,C=r.current;if(!(!S||!C)){try{S.fit()}catch{return}try{C.refresh(0,C.rows-1)}catch{}C.cols===w&&C.rows===x||(w=C.cols,x=C.rows,t.request("session:pty:resize",{sessionId:e,cols:C.cols,rows:C.rows}).catch(()=>{}))}},y=new ResizeObserver(()=>_());return y.observe(v),()=>y.disconnect()},[e,t]);const f=()=>{c(v=>{const w=v==="collapsed"?"expanded":"collapsed";return w==="expanded"&&requestAnimationFrame(()=>{var x;return(x=r.current)==null?void 0:x.focus()}),w})},p=l==="expanded"?n2:Cg,m=n2-Cg;return h.jsxs("div",{className:"border-t border-border bg-bg-0 overflow-hidden",style:{height:p},"data-testid":"xterm-panel","data-state":l,"data-mode":"tui","data-popup-kind":u??"",children:[h.jsxs("button",{type:"button",onClick:f,className:"flex items-center justify-between w-full px-3 py-1 text-xs text-text-200 bg-bg-200 hover:bg-bg-300 cursor-pointer border-b border-border",style:{height:Cg,flexShrink:0},"data-testid":"xterm-panel-toggle",children:[h.jsxs("span",{className:"font-mono",children:[u==="permission"&&"⚠️ CC 需要权限确认 — 在下方终端按数字键 / Enter 选择",u==="question"&&"❓ CC 在问问题 — 在下方终端用 ↑/↓ + Enter 选择",u===null&&(l==="collapsed"?"▴ 展开原生 TUI 终端":"▾ 收起 TUI 终端")]}),h.jsx("span",{className:"text-text-200 text-[10px] opacity-60",children:l==="expanded"?"点击收起":"点击展开"})]}),h.jsx("div",{ref:n,className:"p-1",style:{height:m},"data-testid":"xterm-panel-host"})]})}function f1(e){const t=pi(e?`capabilities/${e}`:"");return e?{capabilities:t??null,loading:!t}:{capabilities:null,loading:!1}}function Bie({api:e,scope:t,sessionId:n,onShareFile:r,onOpenInTab:i,onPreviewMarkdown:s}){const[o,a]=g.useState([]),[l,c]=g.useState(null);g.useEffect(()=>{let d=!1;return(async()=>{try{const f=await e.attachmentGroupList(n);if(d)return;a(f.entries)}catch(f){d||c(f.message)}})(),()=>{d=!0}},[e,n]);async function u(d){try{await e.attachmentGroupRemove(n,d.relPath),a(f=>d.from==="owner"?f.filter(p=>p.relPath!==d.relPath):f.map(p=>p.relPath===d.relPath?{...p,stale:!0}:p))}catch(f){c(f.message)}}return h.jsx(cf,{delayDuration:120,children:h.jsx("div",{"data-testid":"files-panel-body",className:"flex h-full flex-col",children:h.jsxs("div",{className:"flex-1 overflow-y-auto",children:[h.jsx(zie,{title:`Session files (${o.length})`,subtitle:"agent Write/Edit 自动入清单",children:o.length===0?h.jsx(Fie,{text:"还没有文件。agent Write/Edit 会自动加入清单。"}):o.map(d=>h.jsx($ie,{entry:d,onShareLink:()=>r(d.relPath),...i?{onOpenInTab:()=>i(d.relPath)}:{},...s&&!d.stale&&Lp(d.relPath)?{onPreview:()=>s(d.relPath)}:{},onRemove:()=>u(d)},d.id))}),l?h.jsx("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-[11px] text-destructive",children:l}):null]})})})}function zie({title:e,subtitle:t,children:n}){return h.jsxs("div",{className:"border-b border-border last:border-b-0",children:[h.jsx("div",{className:"sticky top-0 z-10 flex items-start justify-between bg-bg-100 px-4 py-2",children:h.jsxs("div",{className:"flex-1",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-text-300",children:e}),t?h.jsx("div",{className:"mt-0.5 text-[11px] text-text-400",children:t}):null]})}),h.jsx("div",{className:"flex flex-col",children:n})]})}function $ie({entry:e,onShareLink:t,onOpenInTab:n,onPreview:r,onRemove:i}){var c;const s=(c=e.mime)!=null&&c.startsWith("image/")?s8:mi,o=e.relPath.lastIndexOf("/"),a=o>=0?e.relPath.slice(0,o+1):"",l=o>=0?e.relPath.slice(o+1):e.relPath;return h.jsxs("div",{"data-testid":"files-panel-row",className:re("group flex items-center gap-2 px-4 py-2 hover:bg-bg-200",e.stale&&"opacity-50"),children:[h.jsx(s,{className:"h-4 w-4 shrink-0 text-text-400"}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsxs(Ep,{children:[h.jsx(Np,{asChild:!0,children:r?h.jsxs("button",{type:"button","data-testid":"files-panel-preview",onClick:r,className:"flex min-w-0 items-baseline text-left text-[13px] text-text-100 hover:text-accent hover:underline underline-offset-2 cursor-pointer",children:[a?h.jsx("span",{className:"truncate text-text-400",children:a}):null,h.jsx("span",{className:"shrink-0",children:l})]}):h.jsxs("span",{className:"flex min-w-0 items-baseline text-[13px] text-text-100",children:[a?h.jsx("span",{className:"truncate text-text-400",children:a}):null,h.jsx("span",{className:"shrink-0",children:l})]})}),h.jsx(Mu,{side:"top",align:"start",className:"max-w-[380px] break-all",children:e.relPath})]}),e.stale&&h.jsx("span",{className:"rounded bg-text-100/10 px-1 py-0 text-[10px] uppercase text-text-400",children:"stale"})]}),h.jsxs("div",{className:"flex items-center gap-1.5 truncate text-[11px] text-text-400",children:[h.jsx("span",{children:e.from}),h.jsx("span",{children:"·"}),h.jsx("span",{children:Hie(e.addedAt)})]})]}),!e.stale&&h.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:[n?h.jsx(Eg,{icon:h.jsx(tu,{className:"h-3.5 w-3.5"}),title:"Open in tab",onClick:n}):null,h.jsx(Eg,{icon:h.jsx(Z_,{className:"h-3.5 w-3.5"}),title:"Share link",onClick:t}),e.from==="owner"&&h.jsx(Eg,{icon:h.jsx(J_,{className:"h-3.5 w-3.5"}),title:"Remove",onClick:i})]})]})}function Eg({icon:e,title:t,onClick:n}){return h.jsx("button",{type:"button",onClick:n,title:t,"aria-label":t,className:"flex h-7 w-7 items-center justify-center rounded text-text-400 hover:bg-text-100/10 hover:text-text-100",children:e})}function Fie({text:e}){return h.jsx("div",{className:"px-4 py-3 text-[12px] italic text-text-400",children:e})}function Hie(e){const t=Date.now()-e;return t<6e4?`${Math.max(1,Math.floor(t/1e3))}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}var $u={},Uie=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},AA={},ur={};let p1;const Wie=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];ur.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17};ur.getSymbolTotalCodewords=function(t){return Wie[t]};ur.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};ur.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');p1=t};ur.isKanjiModeEnabled=function(){return typeof p1<"u"};ur.toSJIS=function(t){return p1(t)};var $p={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},e.from=function(r,i){if(e.isValid(r))return r;try{return t(r)}catch{return i}}})($p);function jA(){this.buffer=[],this.length=0}jA.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var Vie=jA;function Fu(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}Fu.prototype.set=function(e,t,n,r){const i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)};Fu.prototype.get=function(e,t){return this.data[e*this.size+t]};Fu.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n};Fu.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var qie=Fu,LA={};(function(e){const t=ur.getSymbolSize;e.getRowColCoords=function(r){if(r===1)return[];const i=Math.floor(r/7)+2,s=t(r),o=s===145?26:Math.ceil((s-13)/(2*i-2))*2,a=[s-7];for(let l=1;l<i-1;l++)a[l]=a[l-1]-o;return a.push(6),a.reverse()},e.getPositions=function(r){const i=[],s=e.getRowColCoords(r),o=s.length;for(let a=0;a<o;a++)for(let l=0;l<o;l++)a===0&&l===0||a===0&&l===o-1||a===o-1&&l===0||i.push([s[a],s[l]]);return i}})(LA);var DA={};const Kie=ur.getSymbolSize,r2=7;DA.getPositions=function(t){const n=Kie(t);return[[0,0],[n-r2,0],[0,n-r2]]};var OA={};(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(i){return i!=null&&i!==""&&!isNaN(i)&&i>=0&&i<=7},e.from=function(i){return e.isValid(i)?parseInt(i,10):void 0},e.getPenaltyN1=function(i){const s=i.size;let o=0,a=0,l=0,c=null,u=null;for(let d=0;d<s;d++){a=l=0,c=u=null;for(let f=0;f<s;f++){let p=i.get(d,f);p===c?a++:(a>=5&&(o+=t.N1+(a-5)),c=p,a=1),p=i.get(f,d),p===u?l++:(l>=5&&(o+=t.N1+(l-5)),u=p,l=1)}a>=5&&(o+=t.N1+(a-5)),l>=5&&(o+=t.N1+(l-5))}return o},e.getPenaltyN2=function(i){const s=i.size;let o=0;for(let a=0;a<s-1;a++)for(let l=0;l<s-1;l++){const c=i.get(a,l)+i.get(a,l+1)+i.get(a+1,l)+i.get(a+1,l+1);(c===4||c===0)&&o++}return o*t.N2},e.getPenaltyN3=function(i){const s=i.size;let o=0,a=0,l=0;for(let c=0;c<s;c++){a=l=0;for(let u=0;u<s;u++)a=a<<1&2047|i.get(c,u),u>=10&&(a===1488||a===93)&&o++,l=l<<1&2047|i.get(u,c),u>=10&&(l===1488||l===93)&&o++}return o*t.N3},e.getPenaltyN4=function(i){let s=0;const o=i.data.length;for(let l=0;l<o;l++)s+=i.data[l];return Math.abs(Math.ceil(s*100/o/5)-10)*t.N4};function n(r,i,s){switch(r){case e.Patterns.PATTERN000:return(i+s)%2===0;case e.Patterns.PATTERN001:return i%2===0;case e.Patterns.PATTERN010:return s%3===0;case e.Patterns.PATTERN011:return(i+s)%3===0;case e.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(s/3))%2===0;case e.Patterns.PATTERN101:return i*s%2+i*s%3===0;case e.Patterns.PATTERN110:return(i*s%2+i*s%3)%2===0;case e.Patterns.PATTERN111:return(i*s%3+(i+s)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}e.applyMask=function(i,s){const o=s.size;for(let a=0;a<o;a++)for(let l=0;l<o;l++)s.isReserved(l,a)||s.xor(l,a,n(i,l,a))},e.getBestMask=function(i,s){const o=Object.keys(e.Patterns).length;let a=0,l=1/0;for(let c=0;c<o;c++){s(c),e.applyMask(c,i);const u=e.getPenaltyN1(i)+e.getPenaltyN2(i)+e.getPenaltyN3(i)+e.getPenaltyN4(i);e.applyMask(c,i),u<l&&(l=u,a=c)}return a}})(OA);var Fp={};const ks=$p,Od=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],Bd=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];Fp.getBlocksCount=function(t,n){switch(n){case ks.L:return Od[(t-1)*4+0];case ks.M:return Od[(t-1)*4+1];case ks.Q:return Od[(t-1)*4+2];case ks.H:return Od[(t-1)*4+3];default:return}};Fp.getTotalCodewordsCount=function(t,n){switch(n){case ks.L:return Bd[(t-1)*4+0];case ks.M:return Bd[(t-1)*4+1];case ks.Q:return Bd[(t-1)*4+2];case ks.H:return Bd[(t-1)*4+3];default:return}};var BA={},Hp={};const Ic=new Uint8Array(512),kf=new Uint8Array(256);(function(){let t=1;for(let n=0;n<255;n++)Ic[n]=t,kf[t]=n,t<<=1,t&256&&(t^=285);for(let n=255;n<512;n++)Ic[n]=Ic[n-255]})();Hp.log=function(t){if(t<1)throw new Error("log("+t+")");return kf[t]};Hp.exp=function(t){return Ic[t]};Hp.mul=function(t,n){return t===0||n===0?0:Ic[kf[t]+kf[n]]};(function(e){const t=Hp;e.mul=function(r,i){const s=new Uint8Array(r.length+i.length-1);for(let o=0;o<r.length;o++)for(let a=0;a<i.length;a++)s[o+a]^=t.mul(r[o],i[a]);return s},e.mod=function(r,i){let s=new Uint8Array(r);for(;s.length-i.length>=0;){const o=s[0];for(let l=0;l<i.length;l++)s[l]^=t.mul(i[l],o);let a=0;for(;a<s.length&&s[a]===0;)a++;s=s.slice(a)}return s},e.generateECPolynomial=function(r){let i=new Uint8Array([1]);for(let s=0;s<r;s++)i=e.mul(i,new Uint8Array([1,t.exp(s)]));return i}})(BA);const zA=BA;function m1(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}m1.prototype.initialize=function(t){this.degree=t,this.genPoly=zA.generateECPolynomial(this.degree)};m1.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(t.length+this.degree);n.set(t);const r=zA.mod(n,this.genPoly),i=this.degree-r.length;if(i>0){const s=new Uint8Array(this.degree);return s.set(r,i),s}return r};var Gie=m1,$A={},Gs={},g1={};g1.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var wi={};const FA="[0-9]+",Yie="[A-Z $%*+\\-./:]+";let pu="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";pu=pu.replace(/u/g,"\\u");const Xie="(?:(?![A-Z0-9 $%*+\\-./:]|"+pu+`)(?:.|[\r
579
579
  ]))+`;wi.KANJI=new RegExp(pu,"g");wi.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");wi.BYTE=new RegExp(Xie,"g");wi.NUMERIC=new RegExp(FA,"g");wi.ALPHANUMERIC=new RegExp(Yie,"g");const Qie=new RegExp("^"+pu+"$"),Zie=new RegExp("^"+FA+"$"),Jie=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");wi.testKanji=function(t){return Qie.test(t)};wi.testNumeric=function(t){return Zie.test(t)};wi.testAlphanumeric=function(t){return Jie.test(t)};(function(e){const t=g1,n=wi;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(s,o){if(!s.ccBits)throw new Error("Invalid mode: "+s);if(!t.isValid(o))throw new Error("Invalid version: "+o);return o>=1&&o<10?s.ccBits[0]:o<27?s.ccBits[1]:s.ccBits[2]},e.getBestModeForData=function(s){return n.testNumeric(s)?e.NUMERIC:n.testAlphanumeric(s)?e.ALPHANUMERIC:n.testKanji(s)?e.KANJI:e.BYTE},e.toString=function(s){if(s&&s.id)return s.id;throw new Error("Invalid mode")},e.isValid=function(s){return s&&s.bit&&s.ccBits};function r(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+i)}}e.from=function(s,o){if(e.isValid(s))return s;try{return r(s)}catch{return o}}})(Gs);(function(e){const t=ur,n=Fp,r=$p,i=Gs,s=g1,o=7973,a=t.getBCHDigit(o);function l(f,p,m){for(let v=1;v<=40;v++)if(p<=e.getCapacity(v,m,f))return v}function c(f,p){return i.getCharCountIndicator(f,p)+4}function u(f,p){let m=0;return f.forEach(function(v){const w=c(v.mode,p);m+=w+v.getBitsLength()}),m}function d(f,p){for(let m=1;m<=40;m++)if(u(f,m)<=e.getCapacity(m,p,i.MIXED))return m}e.from=function(p,m){return s.isValid(p)?parseInt(p,10):m},e.getCapacity=function(p,m,v){if(!s.isValid(p))throw new Error("Invalid QR Code version");typeof v>"u"&&(v=i.BYTE);const w=t.getSymbolTotalCodewords(p),x=n.getTotalCodewordsCount(p,m),_=(w-x)*8;if(v===i.MIXED)return _;const y=_-c(v,p);switch(v){case i.NUMERIC:return Math.floor(y/10*3);case i.ALPHANUMERIC:return Math.floor(y/11*2);case i.KANJI:return Math.floor(y/13);case i.BYTE:default:return Math.floor(y/8)}},e.getBestVersionForData=function(p,m){let v;const w=r.from(m,r.M);if(Array.isArray(p)){if(p.length>1)return d(p,w);if(p.length===0)return 1;v=p[0]}else v=p;return l(v.mode,v.getLength(),w)},e.getEncodedBits=function(p){if(!s.isValid(p)||p<7)throw new Error("Invalid QR Code version");let m=p<<12;for(;t.getBCHDigit(m)-a>=0;)m^=o<<t.getBCHDigit(m)-a;return p<<12|m}})($A);var HA={};const Ix=ur,UA=1335,ese=21522,i2=Ix.getBCHDigit(UA);HA.getEncodedBits=function(t,n){const r=t.bit<<3|n;let i=r<<10;for(;Ix.getBCHDigit(i)-i2>=0;)i^=UA<<Ix.getBCHDigit(i)-i2;return(r<<10|i)^ese};var WA={};const tse=Gs;function sl(e){this.mode=tse.NUMERIC,this.data=e.toString()}sl.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)};sl.prototype.getLength=function(){return this.data.length};sl.prototype.getBitsLength=function(){return sl.getBitsLength(this.data.length)};sl.prototype.write=function(t){let n,r,i;for(n=0;n+3<=this.data.length;n+=3)r=this.data.substr(n,3),i=parseInt(r,10),t.put(i,10);const s=this.data.length-n;s>0&&(r=this.data.substr(n),i=parseInt(r,10),t.put(i,s*3+1))};var nse=sl;const rse=Gs,Ng=["0","1","2","3","4","5","6","7","8","9","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"," ","$","%","*","+","-",".","/",":"];function ol(e){this.mode=rse.ALPHANUMERIC,this.data=e}ol.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};ol.prototype.getLength=function(){return this.data.length};ol.prototype.getBitsLength=function(){return ol.getBitsLength(this.data.length)};ol.prototype.write=function(t){let n;for(n=0;n+2<=this.data.length;n+=2){let r=Ng.indexOf(this.data[n])*45;r+=Ng.indexOf(this.data[n+1]),t.put(r,11)}this.data.length%2&&t.put(Ng.indexOf(this.data[n]),6)};var ise=ol;const sse=Gs;function al(e){this.mode=sse.BYTE,typeof e=="string"?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}al.getBitsLength=function(t){return t*8};al.prototype.getLength=function(){return this.data.length};al.prototype.getBitsLength=function(){return al.getBitsLength(this.data.length)};al.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)};var ose=al;const ase=Gs,lse=ur;function ll(e){this.mode=ase.KANJI,this.data=e}ll.getBitsLength=function(t){return t*13};ll.prototype.getLength=function(){return this.data.length};ll.prototype.getBitsLength=function(){return ll.getBitsLength(this.data.length)};ll.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=lse.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
580
580
  Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}};var cse=ll,VA={exports:{}};(function(e){var t={single_source_shortest_paths:function(n,r,i){var s={},o={};o[r]=0;var a=t.PriorityQueue.make();a.push(r,0);for(var l,c,u,d,f,p,m,v,w;!a.empty();){l=a.pop(),c=l.value,d=l.cost,f=n[c]||{};for(u in f)f.hasOwnProperty(u)&&(p=f[u],m=d+p,v=o[u],w=typeof o[u]>"u",(w||v>m)&&(o[u]=m,a.push(u,m),s[u]=c))}if(typeof i<"u"&&typeof o[i]>"u"){var x=["Could not find a path from ",r," to ",i,"."].join("");throw new Error(x)}return s},extract_shortest_path_from_predecessor_list:function(n,r){for(var i=[],s=r;s;)i.push(s),n[s],s=n[s];return i.reverse(),i},find_path:function(n,r,i){var s=t.single_source_shortest_paths(n,r,i);return t.extract_shortest_path_from_predecessor_list(s,i)},PriorityQueue:{make:function(n){var r=t.PriorityQueue,i={},s;n=n||{};for(s in r)r.hasOwnProperty(s)&&(i[s]=r[s]);return i.queue=[],i.sorter=n.sorter||r.default_sorter,i},default_sorter:function(n,r){return n.cost-r.cost},push:function(n,r){var i={value:n,cost:r};this.queue.push(i),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(VA);var use=VA.exports;(function(e){const t=Gs,n=nse,r=ise,i=ose,s=cse,o=wi,a=ur,l=use;function c(x){return unescape(encodeURIComponent(x)).length}function u(x,_,y){const S=[];let C;for(;(C=x.exec(y))!==null;)S.push({data:C[0],index:C.index,mode:_,length:C[0].length});return S}function d(x){const _=u(o.NUMERIC,t.NUMERIC,x),y=u(o.ALPHANUMERIC,t.ALPHANUMERIC,x);let S,C;return a.isKanjiModeEnabled()?(S=u(o.BYTE,t.BYTE,x),C=u(o.KANJI,t.KANJI,x)):(S=u(o.BYTE_KANJI,t.BYTE,x),C=[]),_.concat(y,S,C).sort(function(N,T){return N.index-T.index}).map(function(N){return{data:N.data,mode:N.mode,length:N.length}})}function f(x,_){switch(_){case t.NUMERIC:return n.getBitsLength(x);case t.ALPHANUMERIC:return r.getBitsLength(x);case t.KANJI:return s.getBitsLength(x);case t.BYTE:return i.getBitsLength(x)}}function p(x){return x.reduce(function(_,y){const S=_.length-1>=0?_[_.length-1]:null;return S&&S.mode===y.mode?(_[_.length-1].data+=y.data,_):(_.push(y),_)},[])}function m(x){const _=[];for(let y=0;y<x.length;y++){const S=x[y];switch(S.mode){case t.NUMERIC:_.push([S,{data:S.data,mode:t.ALPHANUMERIC,length:S.length},{data:S.data,mode:t.BYTE,length:S.length}]);break;case t.ALPHANUMERIC:_.push([S,{data:S.data,mode:t.BYTE,length:S.length}]);break;case t.KANJI:_.push([S,{data:S.data,mode:t.BYTE,length:c(S.data)}]);break;case t.BYTE:_.push([{data:S.data,mode:t.BYTE,length:c(S.data)}])}}return _}function v(x,_){const y={},S={start:{}};let C=["start"];for(let k=0;k<x.length;k++){const N=x[k],T=[];for(let O=0;O<N.length;O++){const P=N[O],D=""+k+O;T.push(D),y[D]={node:P,lastCount:0},S[D]={};for(let R=0;R<C.length;R++){const A=C[R];y[A]&&y[A].node.mode===P.mode?(S[A][D]=f(y[A].lastCount+P.length,P.mode)-f(y[A].lastCount,P.mode),y[A].lastCount+=P.length):(y[A]&&(y[A].lastCount=P.length),S[A][D]=f(P.length,P.mode)+4+t.getCharCountIndicator(P.mode,_))}}C=T}for(let k=0;k<C.length;k++)S[C[k]].end=0;return{map:S,table:y}}function w(x,_){let y;const S=t.getBestModeForData(x);if(y=t.from(_,S),y!==t.BYTE&&y.bit<S.bit)throw new Error('"'+x+'" cannot be encoded with mode '+t.toString(y)+`.
581
581
  Suggested mode is: `+t.toString(S));switch(y===t.KANJI&&!a.isKanjiModeEnabled()&&(y=t.BYTE),y){case t.NUMERIC:return new n(x);case t.ALPHANUMERIC:return new r(x);case t.KANJI:return new s(x);case t.BYTE:return new i(x)}}e.fromArray=function(_){return _.reduce(function(y,S){return typeof S=="string"?y.push(w(S,null)):S.data&&y.push(w(S.data,S.mode)),y},[])},e.fromString=function(_,y){const S=d(_,a.isKanjiModeEnabled()),C=m(S),k=v(C,y),N=l.find_path(k.map,"start","end"),T=[];for(let O=1;O<N.length-1;O++)T.push(k.table[N[O]].node);return e.fromArray(p(T))},e.rawSplit=function(_){return e.fromArray(d(_,a.isKanjiModeEnabled()))}})(WA);const Up=ur,Tg=$p,dse=Vie,hse=qie,fse=LA,pse=DA,Px=OA,Rx=Fp,mse=Gie,Cf=$A,gse=HA,vse=Gs,Ig=WA;function xse(e,t){const n=e.size,r=pse.getPositions(t);for(let i=0;i<r.length;i++){const s=r[i][0],o=r[i][1];for(let a=-1;a<=7;a++)if(!(s+a<=-1||n<=s+a))for(let l=-1;l<=7;l++)o+l<=-1||n<=o+l||(a>=0&&a<=6&&(l===0||l===6)||l>=0&&l<=6&&(a===0||a===6)||a>=2&&a<=4&&l>=2&&l<=4?e.set(s+a,o+l,!0,!0):e.set(s+a,o+l,!1,!0))}}function _se(e){const t=e.size;for(let n=8;n<t-8;n++){const r=n%2===0;e.set(n,6,r,!0),e.set(6,n,r,!0)}}function yse(e,t){const n=fse.getPositions(t);for(let r=0;r<n.length;r++){const i=n[r][0],s=n[r][1];for(let o=-2;o<=2;o++)for(let a=-2;a<=2;a++)o===-2||o===2||a===-2||a===2||o===0&&a===0?e.set(i+o,s+a,!0,!0):e.set(i+o,s+a,!1,!0)}}function bse(e,t){const n=e.size,r=Cf.getEncodedBits(t);let i,s,o;for(let a=0;a<18;a++)i=Math.floor(a/3),s=a%3+n-8-3,o=(r>>a&1)===1,e.set(i,s,o,!0),e.set(s,i,o,!0)}function Pg(e,t,n){const r=e.size,i=gse.getEncodedBits(t,n);let s,o;for(s=0;s<15;s++)o=(i>>s&1)===1,s<6?e.set(s,8,o,!0):s<8?e.set(s+1,8,o,!0):e.set(r-15+s,8,o,!0),s<8?e.set(8,r-s-1,o,!0):s<9?e.set(8,15-s-1+1,o,!0):e.set(8,15-s-1,o,!0);e.set(r-8,8,1,!0)}function wse(e,t){const n=e.size;let r=-1,i=n-1,s=7,o=0;for(let a=n-1;a>0;a-=2)for(a===6&&a--;;){for(let l=0;l<2;l++)if(!e.isReserved(i,a-l)){let c=!1;o<t.length&&(c=(t[o]>>>s&1)===1),e.set(i,a-l,c),s--,s===-1&&(o++,s=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function Sse(e,t,n){const r=new dse;n.forEach(function(l){r.put(l.mode.bit,4),r.put(l.getLength(),vse.getCharCountIndicator(l.mode,e)),l.write(r)});const i=Up.getSymbolTotalCodewords(e),s=Rx.getTotalCodewordsCount(e,t),o=(i-s)*8;for(r.getLengthInBits()+4<=o&&r.put(0,4);r.getLengthInBits()%8!==0;)r.putBit(0);const a=(o-r.getLengthInBits())/8;for(let l=0;l<a;l++)r.put(l%2?17:236,8);return kse(r,e,t)}function kse(e,t,n){const r=Up.getSymbolTotalCodewords(t),i=Rx.getTotalCodewordsCount(t,n),s=r-i,o=Rx.getBlocksCount(t,n),a=r%o,l=o-a,c=Math.floor(r/o),u=Math.floor(s/o),d=u+1,f=c-u,p=new mse(f);let m=0;const v=new Array(o),w=new Array(o);let x=0;const _=new Uint8Array(e.buffer);for(let N=0;N<o;N++){const T=N<l?u:d;v[N]=_.slice(m,m+T),w[N]=p.encode(v[N]),m+=T,x=Math.max(x,T)}const y=new Uint8Array(r);let S=0,C,k;for(C=0;C<x;C++)for(k=0;k<o;k++)C<v[k].length&&(y[S++]=v[k][C]);for(C=0;C<f;C++)for(k=0;k<o;k++)y[S++]=w[k][C];return y}function Cse(e,t,n,r){let i;if(Array.isArray(e))i=Ig.fromArray(e);else if(typeof e=="string"){let c=t;if(!c){const u=Ig.rawSplit(e);c=Cf.getBestVersionForData(u,n)}i=Ig.fromString(e,c||40)}else throw new Error("Invalid data");const s=Cf.getBestVersionForData(i,n);if(!s)throw new Error("The amount of data is too big to be stored in a QR Code");if(!t)t=s;else if(t<s)throw new Error(`
@@ -586,4 +586,4 @@ Minimum version required to store current data is: `+s+`.
586
586
 
587
587
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
588
588
 
589
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return g.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Bse="DialogDescriptionWarning",zse=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${c3(Bse).contentName}}.`;return g.useEffect(()=>{var s;const i=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},$se=XA,Fse=JA,u3=e3,d3=t3,h3=r3,f3=s3,Hse=a3;const w1=$se,Use=Fse,p3=g.forwardRef(({className:e,...t},n)=>h.jsx(u3,{ref:n,className:re("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",e),...t}));p3.displayName=u3.displayName;const Vp=g.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(Use,{children:[h.jsx(p3,{}),h.jsxs(d3,{ref:r,className:re("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2","gap-4 rounded-lg border border-border bg-elevated p-6 shadow-lg",e),...n,children:[t,h.jsxs(Hse,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-accent",children:[h.jsx(Ir,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Vp.displayName=d3.displayName;const qp=({className:e,...t})=>h.jsx("div",{className:re("flex flex-col space-y-1.5 text-left",e),...t});qp.displayName="DialogHeader";const S1=({className:e,...t})=>h.jsx("div",{className:re("flex flex-row justify-end gap-2",e),...t});S1.displayName="DialogFooter";const Kp=g.forwardRef(({className:e,...t},n)=>h.jsx(h3,{ref:n,className:re("text-lg font-semibold leading-none text-text-100",e),...t}));Kp.displayName=h3.displayName;const m3=g.forwardRef(({className:e,...t},n)=>h.jsx(f3,{ref:n,className:re("text-sm text-text-300",e),...t}));m3.displayName=f3.displayName;function Wse({persona:e,open:t,onClose:n,onDelete:r,embedded:i,onLoadPersonality:s,onSavePersonality:o,onLoadPersonalityLocal:a,onSavePersonalityLocal:l,hasPersonalityLocal:c=!1,onDirtyChange:u,initialPersonality:d,onShareCapability:f,readOnly:p=!1,larkBot:m}){const[v,w]=g.useState(!1),[x,_]=g.useState(!1),y=v||x,S=Qe.useRef(u);g.useEffect(()=>{S.current=u}),g.useEffect(()=>{var k;(k=S.current)==null||k.call(S,y)},[y]);const C=()=>{y&&!window.confirm("修改未保存,确定关闭?")||n()};return t?h.jsxs(h.Fragment,{children:[!i&&h.jsx("div",{className:"absolute inset-0 z-30 bg-black/30",onClick:C,"aria-hidden":"true"}),h.jsxs("aside",{className:i?"flex h-full w-full flex-col bg-bg-0":"absolute right-0 top-0 z-40 flex h-full w-[420px] flex-col bg-bg-0 border-l border-border shadow-xl","data-testid":"persona-settings-drawer",children:[h.jsxs("header",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h.jsx(O8,{className:"h-4 w-4 text-text-300"}),h.jsx("span",{className:"text-[13px] font-medium text-text-100 truncate",children:"Persona 设置"})]}),h.jsx("button",{type:"button",onClick:C,"aria-label":"关闭",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-text-100",children:h.jsx(Ir,{className:"h-4 w-4"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-6 flex flex-col gap-4",children:[h.jsxs("header",{className:"flex items-start justify-between gap-3",children:[h.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h2",{className:"text-lg font-semibold text-text-100 truncate",children:e.label}),e.public?h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-bg-200 px-1.5 py-0.5 text-[10px] text-text-200",children:[h.jsx(r8,{className:"h-3 w-3"})," 公开"]}):h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-error-dim px-1.5 py-0.5 text-[10px] text-error",children:[h.jsx(t8,{className:"h-3 w-3"})," 已关闭"]})]}),h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate","data-testid":"persona-id-subtitle",children:e.personaId})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[f?h.jsxs("button",{type:"button",onClick:f,"aria-label":"分享给他人",title:"分享给他人",className:"inline-flex items-center gap-1 rounded-sm px-2 py-1.5 text-xs text-text-200 hover:bg-bg-200 hover:text-text-100",children:[h.jsx(Z_,{className:"h-3.5 w-3.5"}),"分享"]}):null,r?h.jsx("button",{type:"button",onClick:r,"aria-label":"删除 persona",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-error",children:h.jsx(J_,{className:"h-4 w-4"})}):null]})]}),h.jsx("hr",{className:"border-border"}),m?h.jsxs(h.Fragment,{children:[h.jsx(Kse,{...m}),h.jsx("hr",{className:"border-border"})]}):null,s?h.jsxs(h.Fragment,{children:[h.jsx(a2,{onLoad:s,...o&&!e.personalityManaged?{onSave:o}:{},onDirtyChange:w,initialPersonality:d,readOnly:p||!!e.personalityManaged,title:e.personalityManaged?"内置人格":"人格 (Personality)",hint:e.personalityManaged?p?"这个 persona 自带的人格,随 clawd 版本更新。":"这个 persona 自带的人格,随 clawd 版本更新——在这里改不会保留,要加自己的规则请写下面的「你的补充」。":void 0,testIdPrefix:"persona-personality"}),(e.personalityManaged||c)&&a?h.jsx(a2,{onLoad:a,...l?{onSave:l}:{},onDirtyChange:_,readOnly:p,title:p?"补充设定":"你的补充",hint:p?"这个 persona 的补充设定,由它的主人维护。与内置人格叠加生效。":"写入 <persona-dir>/.clawd/personality.local.md,不会被更新覆盖。与内置人格叠加生效,冲突时以你写的为准;对 owner 和访客会话都生效,要区分对象请在正文里写明。只对新启动的 sub-session 生效。",placeholder:"例:回答一律先给结论,再展开。",testIdPrefix:"persona-personality-local"}):null,h.jsx("hr",{className:"border-border"})]}):null,h.jsx(Gse,{settings:e.sandboxSettings??null}),h.jsx("hr",{className:"border-border"}),h.jsx(Yse,{skills:e.skills??[]}),h.jsx("hr",{className:"border-border"}),h.jsx(Xse,{plugins:e.plugins??[]})]})]})]}):null}function o2({qrUrl:e,busy:t,onCancel:n,title:r="扫码关联飞书 Bot",hint:i="用手机飞书扫码,按页面提示创建应用。确认后自动完成关联。"}){const[s,o]=g.useState(null);return g.useEffect(()=>{let a=!1;return $u.toDataURL(e,{width:240,margin:1}).then(l=>{a||o(l)}).catch(()=>{a||o(null)}),()=>{a=!0}},[e]),h.jsx(w1,{open:!0,onOpenChange:a=>a||n==null?void 0:n(),children:h.jsxs(Vp,{className:"max-w-xs","data-testid":"lark-bot-qr-dialog",onInteractOutside:a=>a.preventDefault(),onEscapeKeyDown:a=>a.preventDefault(),children:[h.jsx(qp,{children:h.jsx(Kp,{children:r})}),h.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s?h.jsx("img",{src:s,alt:"飞书扫码创建应用二维码",className:"h-60 w-60 rounded bg-white p-2","data-testid":"lark-bot-qr-img"}):h.jsx("div",{className:"flex h-60 w-60 items-center justify-center text-[12px] text-text-400",children:"二维码生成中…"}),h.jsx("span",{className:"text-center text-[12px] text-text-300",children:i}),n?h.jsx("button",{type:"button",disabled:t,onClick:n,className:"rounded border border-border px-3 py-1.5 text-[12px] text-text-300 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-cancel",children:"取消"}):null]})]})})}const Vse={expired:"二维码已过期,请重新扫码。",cancelled:"已取消。",access_denied:"你在飞书上取消了本次授权。",lark_protocol_error:"飞书返回了未预期的响应,请重试。",cloud_unreachable:"云端暂时不可达,请稍后重试。",internal_error:"关联失败。若飞书中已创建应用,可在开发者后台删除后重试,或改用手动绑定填入其凭证。"},qse=new Set(["expired","access_denied","lark_protocol_error","cloud_unreachable","internal_error"]);function Kse({status:e,onProvision:t,onCancelProvision:n,onBindManual:r,onUnbind:i,onUpgrade:s}){const[o,a]=g.useState(!1),[l,c]=g.useState(null),[u,d]=g.useState(""),[f,p]=g.useState(""),[m,v]=g.useState(null),w=k=>{k&&(a(!0),c(null),k().catch(N=>c(N instanceof Error?N.message:String(N))).finally(()=>a(!1)))},x=()=>{v(null),w(t)},_=!o&&!!u&&!!f,y=()=>{!_||!r||w(()=>r({appId:u,appSecret:f}))},S=Ru(y),C=h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx(lp,{className:"h-3.5 w-3.5 text-text-400","aria-hidden":!0}),h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"飞书 Bot"})]});return e?h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[C,e.state==="unbound"||e.state==="provisioning"?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"关联一个飞书 bot 后,这个 persona 就是它:拉进群后群成员 @ 它提问、或直接私聊它, 推理跑在你本机,回复自动发回去。"}),t?h.jsx("button",{type:"button",disabled:o||e.state==="provisioning",onClick:x,className:"self-start rounded border border-border bg-bg-200 px-3 py-1.5 text-[12px] font-medium text-text-100 hover:bg-bg-300 disabled:opacity-50","data-testid":"lark-bot-provision",children:e.state==="provisioning"?"等待扫码…":"扫码关联飞书 Bot"}):null,e.state==="unbound"&&e.errorReason&&!m?h.jsxs("div",{className:"flex flex-col gap-1.5 rounded border border-error bg-error-dim px-2 py-1.5","data-testid":"lark-bot-provision-error",children:[h.jsx("span",{className:"text-[11px] text-error",children:Vse[e.errorReason]}),h.jsxs("div",{className:"flex gap-1.5",children:[qse.has(e.errorReason)&&t?h.jsx("button",{type:"button",disabled:o,onClick:x,className:"rounded border border-border px-2 py-1 text-[11px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-retry",children:"重新扫码"}):null,h.jsx("button",{type:"button",onClick:()=>v(e.errorReason??null),className:"rounded border border-border px-2 py-1 text-[11px] text-text-300 hover:bg-bg-200","data-testid":"lark-bot-provision-error-dismiss",children:"知道了"})]})]}):null,e.state==="provisioning"&&e.qrUrl?h.jsx(o2,{qrUrl:e.qrUrl,busy:o,onCancel:n?()=>w(n):void 0}):null,r&&e.state==="unbound"?h.jsxs("details",{"data-testid":"lark-bot-manual-details",children:[h.jsx("summary",{className:"cursor-pointer text-[11px] text-text-400 hover:text-text-300",children:"已有飞书应用?手动填入凭证"}),h.jsxs("div",{className:"mt-1.5 flex flex-col gap-1.5","data-testid":"lark-bot-manual-form",children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"先在飞书开放平台(open.feishu.cn)创建企业自建应用并启用机器人能力,再填入凭证:"}),h.jsx("input",{value:u,onChange:k=>d(k.target.value),...S,placeholder:"App ID(cli_ 开头)",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-appid"}),h.jsx("input",{value:f,onChange:k=>p(k.target.value),...S,type:"password",placeholder:"App Secret",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-secret"}),h.jsx("button",{type:"button",disabled:!_,onClick:y,className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-manual-submit",children:o?"绑定中…":"绑定"})]})]}):null]}):null,e.state==="bound"||e.state==="broken"?h.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.state==="bound"&&e.needsUpgrade?h.jsxs("div",{className:"flex flex-col gap-1.5 rounded border border-warning/30 bg-warning-dim px-2 py-1.5","data-testid":"lark-bot-upgrade-notice",children:[h.jsx("span",{className:"text-[11px] text-warning",children:"这个 bot 的权限配置有更新,扫码重新授权后生效。在此之前,新增能力对它不起作用。"}),s?h.jsx("button",{type:"button",disabled:o,onClick:()=>w(s),className:"self-start rounded border border-warning/30 bg-warning/10 px-2 py-1 text-[11px] text-warning hover:bg-warning/20 disabled:opacity-50","data-testid":"lark-bot-upgrade",children:"更新授权"}):null]}):null,e.state==="bound"&&e.upgradeQrUrl?h.jsx(o2,{qrUrl:e.upgradeQrUrl,busy:o,onCancel:n?()=>w(n):void 0,title:"扫码更新授权",hint:"用手机飞书扫码,确认页会列出将要添加的权限。期间 bot 照常服务,不会中断。"}):null,e.state==="broken"?h.jsxs("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-broken",children:["Bot 凭证失效:",e.brokenReason??"未知原因","。请解绑后重新填入有效凭证绑定。"]}):null,h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-200",children:[h.jsx("span",{className:"font-medium text-text-100",children:e.botName??"未命名 bot"}),e.appId?h.jsx("span",{className:"text-[11px] text-text-400",children:e.appId}):null]}),h.jsx("span",{className:"text-[11px] text-text-400",children:"把 bot 拉进任意飞书群,群成员 @ 它即可提问。"}),e.groups.length>0?h.jsx("ul",{className:"flex flex-col gap-0.5","data-testid":"lark-bot-groups",children:e.groups.map(k=>h.jsxs("li",{className:"text-[11px] text-text-300 truncate",children:["· ",k.chatName??k.chatId]},k.chatId))}):h.jsx("span",{className:"text-[11px] text-text-400","data-testid":"lark-bot-groups-empty",children:"还没有服务中的群。"}),i?h.jsx("button",{type:"button",disabled:o,onClick:()=>w(i),className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-error hover:bg-error-dim disabled:opacity-50","data-testid":"lark-bot-unbind",children:"解绑"}):null]}):null,l?h.jsx("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-error",children:l}):null]}):h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[C,h.jsx("span",{className:"text-[11px] text-text-400",children:"状态加载中…"})]})}function Gse({settings:e}){var t,n,r,i,s,o,a,l,c,u,d,f,p;return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-sandbox-setting-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Sandbox Setting"}),h.jsx("span",{className:"text-[11px] text-text-400",children:"约束此 persona 的沙箱权限(只读,需通过文件修改)。"})]}),e==null?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-sandbox-setting-empty",children:"暂无 sandbox 配置"}):h.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md border border-border bg-bg-100 px-3 py-2",children:[h.jsx(zd,{label:"权限默认模式",value:((t=e.permissions)==null?void 0:t.defaultMode)??"—"}),h.jsx(zd,{label:"沙箱启用",value:Mg((n=e.sandbox)==null?void 0:n.enabled)}),h.jsx(zd,{label:"沙箱内自动放行 Bash",value:Mg((r=e.sandbox)==null?void 0:r.autoAllowBashIfSandboxed)}),h.jsx(zd,{label:"允许非沙箱命令",value:Mg((i=e.sandbox)==null?void 0:i.allowUnsandboxedCommands)}),h.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border pt-1.5",children:[h.jsx(Ql,{label:"沙箱外命令",paths:(s=e.sandbox)==null?void 0:s.excludedCommands}),h.jsx(Ql,{label:"允许读取",paths:(a=(o=e.sandbox)==null?void 0:o.filesystem)==null?void 0:a.allowRead}),h.jsx(Ql,{label:"拒绝读取",paths:(c=(l=e.sandbox)==null?void 0:l.filesystem)==null?void 0:c.denyRead}),h.jsx(Ql,{label:"允许写入",paths:(d=(u=e.sandbox)==null?void 0:u.filesystem)==null?void 0:d.allowWrite}),h.jsx(Ql,{label:"拒绝写入",paths:(p=(f=e.sandbox)==null?void 0:f.filesystem)==null?void 0:p.denyWrite})]})]})]})}function Mg(e){return e===!0?"是":e===!1?"否":"—"}function zd({label:e,value:t}){return h.jsxs("div",{className:"flex items-center justify-between gap-3 text-[12px]",children:[h.jsx("span",{className:"text-text-300",children:e}),h.jsx("span",{className:"font-mono text-text-100",children:t})]})}function Ql({label:e,paths:t}){const n=!t||t.length===0;return h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[11px] text-text-300",children:e}),n?h.jsx("span",{className:"text-[11px] text-text-400",children:"—"}):h.jsx("div",{className:"flex flex-wrap gap-1",children:t.map((r,i)=>h.jsx("span",{className:"rounded-sm border border-border bg-bg-0 px-1.5 py-0.5 font-mono text-[11px] text-text-200",children:r},`${e}-${i}-${r}`))})]})}function Yse({skills:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-skills-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Persona Skills"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 私有 skills(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/skills/"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-skills-empty",children:"暂无 skills"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsxs("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-skill-row",children:[h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.name}),t.description?h.jsx("span",{className:"text-[12px] text-text-300",children:t.description}):h.jsx("span",{className:"text-[11px] text-text-400 italic",children:"无描述"})]},t.name))})]})}function Xse({plugins:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-plugins-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Enabled Plugins"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 已启用的插件(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/settings.json"})," ","的 ",h.jsx("code",{className:"font-mono",children:"enabledPlugins"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-plugins-empty",children:"暂无启用插件"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsx("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-plugin-row",children:h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.id})},t.id))})]})}function a2({onLoad:e,onSave:t,onDirtyChange:n,initialPersonality:r,readOnly:i=!1,title:s,hint:o,placeholder:a,testIdPrefix:l}){const c=r!==void 0,[u,d]=g.useState(c),[f,p]=g.useState(c?r:""),[m,v]=g.useState(c?r:""),[w,x]=g.useState(null),[_,y]=g.useState(!1),[S,C]=g.useState(null),k=Qe.useRef(e),N=Qe.useRef(t),T=Qe.useRef(n);Qe.useEffect(()=>{k.current=e,N.current=t,T.current=n});const O=Qe.useCallback(()=>{d(!1),x(null),k.current().then(M=>{p(M),v(M),d(!0)}).catch(M=>{x(M instanceof Error?M.message:String(M))})},[]);Qe.useEffect(()=>{c||O()},[c,O]);const P=!i&&u&&m!==f;Qe.useEffect(()=>{i||T.current(P)},[P,i]);const D=()=>{N.current&&(y(!0),C(null),N.current(m).then(()=>{p(m),y(!1)}).catch(M=>{C(M instanceof Error?M.message:String(M)),y(!1)}))},R=()=>{v(f),C(null)},A=Ru(()=>{!P||_||D()},()=>{!P||_||R()});return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":`${l}-section`,children:[h.jsx("span",{className:"text-[12px] font-medium text-text-200",children:s}),w?h.jsxs("div",{"data-testid":`${l}-load-error`,className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error flex items-center justify-between gap-2",children:[h.jsxs("span",{children:["加载失败:",w]}),h.jsx("button",{type:"button",onClick:O,className:"rounded-sm border border-error px-2 py-0.5 text-[11px] hover:bg-error/10",children:"重试"})]}):null,S?h.jsxs("div",{"data-testid":`${l}-save-error`,className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error",children:["保存失败:",S]}):null,h.jsx("textarea",{"data-testid":`${l}-textarea`,value:m,onChange:M=>v(M.target.value),...A,readOnly:i,disabled:!i&&(!u||_),placeholder:u?a??"":"加载中…",rows:8,className:"min-h-[8rem] max-h-[18rem] resize-y rounded-md border border-border bg-bg-100 px-2 py-1.5 font-mono text-[11px] text-text-100 disabled:opacity-60"}),o?h.jsx("p",{className:"text-[10px] text-text-400",children:o}):i?null:h.jsxs("p",{className:"text-[10px] text-text-400",children:["写入到 ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/CLAUDE.md"}),"。 修改只对新启动的 sub-session 生效。"]}),u&&P?h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:R,disabled:_,className:"rounded-sm border border-border px-2 py-1 text-[12px] text-text-200 hover:bg-bg-200 disabled:opacity-60",children:"放弃"}),h.jsx("button",{type:"button",onClick:D,disabled:_,"data-testid":`${l}-save-btn`,className:"rounded-sm bg-accent-dim px-2 py-1 text-[12px] text-text-100 hover:opacity-90 disabled:opacity-60",children:_?"保存中…":"保存"})]}):null]})}const Qse={state:"unbound",groups:[]};function Zse(e,t){const[n,r]=g.useState(null);g.useEffect(()=>{if(!e)return;let c=!1;r(null);const u=async()=>{try{const p=await e.request("larkBot:status",{personaId:t});c||r(p)}catch{c||r(Qse)}};u();const d=e.on("larkBot:state",p=>{const m=p;if(m.personaId!==t)return;const{personaId:v,...w}=m;r(w)}),f=e.on("daemon:connected",()=>{u()});return()=>{c=!0,d(),f()}},[e,t]);const i=g.useCallback(async()=>{e&&await e.request("larkBot:provision",{personaId:t})},[e,t]),s=g.useCallback(async()=>{e&&await e.request("larkBot:provisionCancel",{personaId:t})},[e,t]),o=g.useCallback(async c=>{e&&await e.request("larkBot:bindManual",{personaId:t,...c})},[e,t]),a=g.useCallback(async()=>{e&&await e.request("larkBot:upgrade",{personaId:t})},[e,t]),l=g.useCallback(async()=>{e&&await e.request("larkBot:unbind",{personaId:t})},[e,t]);return{status:n,provision:i,cancelProvision:s,bindManual:o,unbind:l,upgrade:a}}function Jse(e,t="owner"){var k;const{persona:n}=mI(e),r=r$(e),i=i$(),s=s$(),{httpBaseUrl:o}=ap(),a=_i(),l=Zse(t==="guest"?null:a,e),{capabilities:c}=f1((n==null?void 0:n.tool)??"claude"),u=g.useMemo(()=>!(n!=null&&n.public)||!o||/^https?:\/\/(127\.0\.0\.1|localhost|0\.0\.0\.0|\[?::1\]?)([:/]|$)/i.test(o)?null:`${o}/s/${e}`,[n==null?void 0:n.public,o,e]),d=g.useCallback((N,T)=>{i(e,T).catch(O=>{Me("persona",`${N} failed`,O)})},[i,e]),f=g.useCallback(N=>d("togglePublic",{public:N}),[d]),p=g.useCallback(async N=>{await i(e,{codexSandbox:{network:N}}),await r.refresh()},[i,e,r]),m=g.useCallback(N=>d("changeTool",{tool:N}),[d]),v=g.useCallback(N=>d("changeModel",{model:N}),[d]),w=g.useCallback(N=>d("changeEffort",{effort:N}),[d]),x=g.useCallback(()=>!n||!confirm(`删除 persona "${n.label}"?`)?!1:(s(e).catch(N=>{Me("persona","delete failed",N)}),!0),[n,s,e]),_=g.useCallback(async()=>r.loaded?r.personality:(await r.refresh()).personality,[r]),y=g.useCallback(async N=>{await i(e,{personality:N}),await r.refresh()},[i,e,r]),S=g.useCallback(async()=>r.loaded?r.personalityLocal:(await r.refresh()).personalityLocal,[r]),C=g.useCallback(async N=>{await i(e,{personalityLocal:N}),await r.refresh()},[i,e,r]);return{persona:n,detail:r,models:(c==null?void 0:c.models)??[],configSchema:(c==null?void 0:c.configSchema)??[],larkBot:l,guestShareUrl:u,changeTool:m,changeModel:v,changeEffort:w,togglePublic:f,guestNetwork:((k=r.codexSandbox)==null?void 0:k.network)??!1,toggleGuestNetwork:p,remove:x,loadPersonality:_,savePersonality:y,loadPersonalityLocal:S,savePersonalityLocal:C}}function eoe({personaId:e,open:t,onClose:n,api:r,embedded:i,onDirtyChange:s,onShareCapability:o,viewerRole:a="owner"}){const l=Jse(e,a),{persona:c,detail:u}=l,d=g.useCallback(()=>{l.remove()&&n()},[l,n]);if(!c)return null;const f=a==="guest";return h.jsx(Wse,{embedded:i,persona:{...c,skills:u.skills,plugins:u.plugins,sandboxSettings:u.sandboxSettings,personalityManaged:u.personalityManaged},open:t,onClose:n,onLoadPersonality:l.loadPersonality,onLoadPersonalityLocal:l.loadPersonalityLocal,hasPersonalityLocal:u.personalityLocal!=="",onDirtyChange:s,readOnly:f,...f?{}:{onTogglePublic:l.togglePublic,guestShareUrl:l.guestShareUrl,onChangeTool:l.changeTool,onChangeModel:l.changeModel,onChangeEffort:l.changeEffort,models:l.models,configSchema:l.configSchema,onDelete:d,onSavePersonality:l.savePersonality,onSavePersonalityLocal:l.savePersonalityLocal,larkBot:{status:l.larkBot.status,onProvision:l.larkBot.provision,onCancelProvision:l.larkBot.cancelProvision,onBindManual:l.larkBot.bindManual,onUnbind:l.larkBot.unbind,onUpgrade:l.larkBot.upgrade},...o?{onShareCapability:o}:{}}})}const toe=new Map,noe=g.createContext(toe);function roe(){const e=g.useContext(noe);return g.useCallback(t=>e.get(t),[e])}function ioe(e){try{const t=new URL(e);return t.protocol==="ws:"?t.protocol="http:":t.protocol==="wss:"&&(t.protocol="https:"),`${t.protocol}//${t.host}`}catch{return e}}function soe(e,t){try{const n=new URL(e),r=new URL(t);return n.protocol=r.protocol,n.host=r.host,n.toString()}catch{return e}}async function k1(e,t,n,r,i){const s=await e.attachmentSignUrl({sessionId:n,relPath:r,...i!==void 0?{ttlSeconds:i}:{}});return soe(s.url,ioe(t.url))}async function l2(e,t,n,r,i=60,s){const o=window.open("about:blank","_blank");try{s&&await s();const a=await k1(e,t,n,r,i);o?o.location.href=a:window.open(a,"_blank")}catch(a){throw o&&o.close(),a}}async function ooe(e){var t;try{if((t=navigator.clipboard)!=null&&t.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.setAttribute("readonly",""),document.body.appendChild(n),n.select();const r=document.execCommand("copy");return document.body.removeChild(n),r}catch{return!1}}const aoe={...Fs,h1:({node:e,...t})=>h.jsx("h1",{...t,className:"mt-4 mb-3 text-[18px] font-semibold leading-tight text-text-100"}),h2:({node:e,...t})=>h.jsx("h2",{...t,className:"mt-4 mb-2 text-[16px] font-semibold leading-tight text-text-100"}),h3:({node:e,...t})=>h.jsx("h3",{...t,className:"mt-3 mb-2 text-[14px] font-semibold leading-tight text-text-100"}),h4:({node:e,...t})=>h.jsx("h4",{...t,className:"mt-3 mb-1 text-[13px] font-semibold text-text-100"}),h5:({node:e,...t})=>h.jsx("h5",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-100"}),h6:({node:e,...t})=>h.jsx("h6",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-300"}),p:({node:e,...t})=>h.jsx("p",{...t,className:"my-2 leading-relaxed"}),ul:({node:e,...t})=>h.jsx("ul",{...t,className:"my-2 list-disc space-y-1 pl-5"}),ol:({node:e,...t})=>h.jsx("ol",{...t,className:"my-2 list-decimal space-y-1 pl-5"}),li:({node:e,...t})=>h.jsx("li",{...t,className:"leading-relaxed"}),blockquote:({node:e,...t})=>h.jsx("blockquote",{...t,className:"my-2 border-l-2 border-border pl-3 italic text-text-300"}),code:({node:e,className:t,children:n,...r})=>t?h.jsx("code",{...r,className:`${t} font-mono text-[12px]`,children:n}):h.jsx("code",{...r,className:"rounded bg-bg-50 px-1 py-0.5 font-mono text-[12px] text-text-100",children:n}),pre:({node:e,...t})=>h.jsx("pre",{...t,className:"my-2 overflow-auto rounded border border-border bg-bg-0 p-3 text-[12px] font-mono text-text-100"}),hr:({node:e,...t})=>h.jsx("hr",{...t,className:"my-3 border-border"}),table:({node:e,...t})=>h.jsx("table",{...t,className:"my-2 w-full border-collapse text-[12px]"}),thead:({node:e,...t})=>h.jsx("thead",{...t,className:"bg-bg-50"}),th:({node:e,...t})=>h.jsx("th",{...t,className:"border border-border px-2 py-1 text-left font-semibold"}),td:({node:e,...t})=>h.jsx("td",{...t,className:"border border-border px-2 py-1"}),strong:({node:e,...t})=>h.jsx("strong",{...t,className:"font-semibold text-text-100"}),em:({node:e,...t})=>h.jsx("em",{...t,className:"italic"})};function loe(e){const t=e.split("/");return t[t.length-1]||e}function g3({relPath:e,loadMarkdown:t,headerRight:n,showTitleBar:r=!1}){const[i,s]=g.useState(null),[o,a]=g.useState(null),[l,c]=g.useState(!1);return g.useEffect(()=>{if(!e)return;let u=!1;return c(!0),a(null),s(null),(async()=>{try{const d=await t(e);if(u)return;s(d)}catch(d){if(u)return;a(d.message||String(d))}finally{u||c(!1)}})(),()=>{u=!0}},[e,t]),h.jsxs("div",{className:"flex flex-col h-full",children:[r&&e?h.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[h.jsx("div",{"data-testid":"md-preview-title",className:"truncate text-[13px] font-medium text-text-100",title:e,children:loe(e)}),h.jsx("div",{className:"flex items-center gap-1",children:n})]}):null,h.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 text-[13px] text-text-100",children:l?h.jsx("div",{"data-testid":"md-preview-loading",className:"text-text-400",children:"Loading…"}):o?h.jsx("div",{"data-testid":"md-preview-error",className:"text-destructive whitespace-pre-wrap",children:o}):i!==null?h.jsx("div",{"data-testid":"md-preview-content",className:"max-w-none",children:h.jsx(nl,{remarkPlugins:[rl],components:aoe,children:i})}):null})]})}function coe({open:e,onOpenChange:t,relPath:n,loadMarkdown:r,onShare:i}){return e?h.jsx("div",{"data-testid":"md-preview-drawer",className:`${n1} z-50 flex w-1/2 max-w-[900px] flex-col border-l border-border bg-elevated shadow-2xl`,children:h.jsx(g3,{relPath:n,loadMarkdown:r,showTitleBar:!0,headerRight:h.jsxs(h.Fragment,{children:[i?h.jsx("button",{type:"button","data-testid":"md-preview-share","aria-label":"Share rendered preview link",onClick:i,className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(c8,{className:"h-4 w-4"})}):null,h.jsx("button",{type:"button","aria-label":"Close preview",onClick:()=>t(!1),className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(Ir,{className:"h-4 w-4"})})]})})}):null}function uoe({left:e,right:t,stage:n,onExpand:r,onCollapse:i}){const s=n==="stopped",[o,a]=g.useState(!1);async function l(){if(!o){a(!0);try{await r()}catch{}finally{a(!1)}}}async function c(){if(!o){a(!0);try{await i()}catch{}finally{a(!1)}}}return h.jsxs("div",{className:"flex h-full w-full min-h-0","data-testid":"two-pane-layout",children:[h.jsxs("div",{className:"relative flex min-w-0 flex-1 flex-col","data-testid":"two-pane-left",children:[s&&h.jsx("button",{type:"button",disabled:o,className:"absolute right-14 top-2 z-10 rounded border border-border bg-elevated px-2 py-1 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50 disabled:cursor-not-allowed",onClick:l,children:o?"启动中…":"展开预览"}),e]}),!s&&h.jsxs("div",{className:"flex w-1/2 min-w-[320px] flex-col border-l border-bg-200","data-testid":"two-pane-right",children:[h.jsx("div",{className:"flex items-center justify-end gap-2 border-b border-bg-200 bg-bg-50 px-2 py-1",children:h.jsx("button",{type:"button",disabled:o,className:"rounded px-2 py-1 text-[12px] text-text-300 hover:bg-bg-100 disabled:opacity-50",onClick:c,children:"收起预览"})}),h.jsx("div",{className:"min-h-0 flex-1",children:t})]})]})}const doe=6173,hoe=6182;function foe({open:e,onOpenChange:t,projectName:n,currentPort:r,allUsedPorts:i,onUpdate:s}){const o=[];for(let v=doe;v<=hoe;v++)(v===r||!i.includes(v))&&o.push(v);const[a,l]=g.useState(r),[c,u]=g.useState(!1),[d,f]=g.useState(null),p=a!==r&&!c;async function m(){if(p){u(!0),f(null);try{await s(a),t(!1)}catch(v){f((v==null?void 0:v.message)??String(v))}finally{u(!1)}}}return h.jsx(w1,{open:e,onOpenChange:t,children:h.jsxs(Vp,{className:"max-w-md",children:[h.jsxs(qp,{children:[h.jsxs(Kp,{children:["改端口 · ",n]}),h.jsxs(m3,{children:["手改通常发生在系统其他进程占了默认分配的端口、dev server 起不来时。 提交后 daemon 会停 dev server → 写 ",h.jsx("code",{className:"mx-1 rounded bg-bg-100 px-1 py-0.5 text-[11px]",children:".clawd-project.json"})," → 用新端口重新起。"]})]}),h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsx("label",{className:"text-xs text-text-400",children:"新端口(仅显示段内可用 + 当前端口)"}),h.jsx("select",{className:"h-9 rounded-md border border-border bg-elevated px-3 py-1 text-sm text-text-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent",value:a,onChange:v=>l(Number(v.target.value)),disabled:c,children:o.map(v=>h.jsxs("option",{value:v,children:[v,v===r?"(当前)":""]},v))}),o.length===1&&h.jsx("div",{className:"text-[11px] text-text-400",children:"端口段已全被其它 project 占用,没有可换的;先删一个 idle project 释放端口。"}),d&&h.jsx("div",{className:"rounded border border-destructive/30 bg-destructive/5 px-3 py-2 text-[12px] text-destructive",children:d})]}),h.jsxs(S1,{children:[h.jsx(di,{variant:"ghost",onClick:()=>t(!1),disabled:c,children:"取消"}),h.jsx(di,{onClick:m,disabled:!p,children:c?"应用中…":"应用新端口"})]})]})})}const c2=[{stage:"build",label:"构建"},{stage:"deploy",label:"部署到阿里云"},{stage:"verify",label:"验证可访问性"}];function poe({currentStage:e,onCancel:t}){const n=c2.findIndex(r=>r.stage===e);return h.jsxs("div",{"data-testid":"publish-progress",className:"flex items-center gap-3 border-b border-bg-200 bg-bg-50 px-3 py-1.5 text-[12px]",children:[c2.map((r,i)=>{const s=i<n,o=i===n,a=s?"text-text-300":o?"text-text-200":"text-text-500/50";return h.jsxs("span",{className:`flex items-center gap-1 ${a}`,children:[s?h.jsx(cp,{className:"size-3.5"}):o?h.jsx(Ln,{className:"size-3.5 animate-spin"}):h.jsx(_I,{className:"size-3.5"}),h.jsxs("span",{children:[r.label,o?"中…":""]})]},r.stage)}),h.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded px-2 py-0.5 text-[11px] text-text-400 hover:bg-bg-100 hover:text-text-200",children:"取消"})]})}const moe={build:"构建",deploy:"部署",verify:"验证"};function goe({stage:e,onRetry:t,onDismiss:n}){return h.jsxs("div",{"data-testid":"publish-interrupted-banner",className:"flex items-center gap-2 border-b border-yellow-400/40 bg-yellow-400/10 px-3 py-1.5 text-[12px]",children:[h.jsx(nu,{className:"size-3.5 text-yellow-500"}),h.jsxs("span",{className:"text-text-200",children:["上次发布在 ",h.jsxs("strong",{className:"font-medium",children:["[",moe[e],"]"]})," ","阶段被中断(daemon 重启)"]}),h.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded bg-accent-main-100 px-2 py-0.5 text-[11px] text-oncolor-100 hover:opacity-90",children:"重新发布"}),h.jsx("button",{type:"button",onClick:n,className:"rounded px-2 py-0.5 text-[11px] text-text-400 hover:bg-bg-100 hover:text-text-200",children:"取消"})]})}const voe={build:"构建",deploy:"部署",verify:"验证",unknown:"未知"};function xoe({stage:e,onFocusChat:t,onClose:n}){return h.jsxs("div",{"data-testid":"publish-failed-banner",className:"flex items-center gap-2 border-b border-destructive/40 bg-destructive/10 px-3 py-1.5 text-[12px]",children:[h.jsx(Qi,{className:"size-3.5 text-destructive"}),h.jsxs("button",{type:"button",onClick:t,className:"flex-1 text-left text-text-200 hover:underline",children:["发布失败:",h.jsxs("strong",{className:"font-medium",children:["[",voe[e],"]"]})," ","已通知 assistant 接管 →"]}),h.jsx("button",{type:"button",onClick:n,"aria-label":"关闭失败提示",className:"rounded p-0.5 text-text-400 hover:bg-bg-100 hover:text-text-200",children:h.jsx(Ir,{className:"size-3.5"})})]})}const u2={"install-pending":{label:"等装依赖…",step:"1/3"},installing:{label:"安装依赖中…(可能要几十秒到几分钟)",step:"2/3"},"starting-dev-server":{label:"启动 dev server…(等监听端口才挂 iframe)",step:"3/3"}};function _oe({project:e,previewHost:t,previewScheme:n,onUpdatePort:r,allUsedPorts:i,publishSlot:s,publishInFlightStage:o,onDismissPublishJob:a,onRetryPublish:l,publishFailureBanner:c,onPublishFailureBannerClose:u,onPublishFailureBannerFocusChat:d}){var x,_;const[f,p]=g.useState(!1);if(!e)return h.jsx("div",{className:"flex h-full w-full items-center justify-center p-6 text-center text-[13px] text-text-400",children:"未绑定 project"});const m=e.stage??(e.isRunning?"running":"stopped"),v=t?`${n}://${t}/preview/${e.port}/`:null,w=e.prodUrl??null;return h.jsxs("div",{className:"flex h-full w-full flex-col","data-testid":"preview-pane",children:[h.jsxs("header",{className:"flex items-center justify-between gap-2 border-b border-bg-200 bg-bg-50 px-3 py-1.5",children:[h.jsxs("div",{className:"flex items-center gap-2 text-[12px]",children:[h.jsx("span",{className:"font-medium text-text-200",children:e.name}),h.jsx("span",{className:"rounded bg-bg-100 px-1.5 py-0.5 text-[11px] text-text-400",children:e.port}),h.jsx("span",{className:"text-[10px] uppercase tracking-wider text-text-500",children:m==="running"?"dev":m})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[w?h.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",title:`打开线上:${w}`,className:"inline-flex items-center gap-1 rounded border border-bg-200 px-2 py-0.5 text-[11px] text-text-300 hover:bg-bg-100",children:[h.jsx(tu,{className:"size-3"}),"打开线上"]}):null,s,h.jsxs(ky,{children:[h.jsx(Cy,{asChild:!0,children:h.jsx("button",{type:"button","aria-label":"Project settings",className:"rounded p-1 text-text-400 hover:bg-bg-100",children:h.jsx(L8,{className:"size-3.5"})})}),h.jsxs(wp,{align:"end",children:[h.jsx(Ri,{onSelect:()=>p(!0),children:"Update Port…"}),h.jsxs(Ri,{disabled:!0,title:"rename not supported yet",onSelect:y=>y.preventDefault(),children:["Name: ",e.name]})]})]})]})]}),c?h.jsx(xoe,{stage:c.stage,onClose:()=>u==null?void 0:u(),onFocusChat:()=>d==null?void 0:d()}):null,((x=e.publishJob)==null?void 0:x.status)==="in-flight"?h.jsx(poe,{currentStage:o??e.publishJob.stage,onCancel:()=>void(a==null?void 0:a())}):null,((_=e.publishJob)==null?void 0:_.status)==="interrupted"?h.jsx(goe,{stage:e.publishJob.stage,onRetry:()=>void(l==null?void 0:l()),onDismiss:()=>void(a==null?void 0:a())}):null,h.jsx("div",{className:"min-h-0 flex-1",children:m==="failed"?h.jsx(yoe,{reason:e.stageReason}):m==="stopped"?null:m==="running"?v?h.jsx("iframe",{"data-testid":"preview-iframe",className:"size-full border-0 bg-white",src:v,title:"preview"}):h.jsx(d2,{label:"等 tunnel 起来…",step:"-"}):h.jsx(d2,{label:u2[m].label,step:u2[m].step})}),h.jsx(foe,{open:f,onOpenChange:p,projectName:e.name,currentPort:e.port,allUsedPorts:i,onUpdate:async y=>{await r(y)}})]})}function d2({label:e,step:t}){return h.jsxs("div",{"data-testid":"preview-spinner",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(Ln,{className:"size-6 animate-spin text-accent-main-100"}),h.jsx("div",{className:"text-[13px] text-text-200",children:e}),h.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-500",children:t}),h.jsx("div",{className:"mt-2 max-w-[300px] text-[11px] text-text-500",children:"左侧 chat 可看 assistant 详细进度"})]})}function yoe({reason:e}){return h.jsxs("div",{"data-testid":"preview-failed",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(Qi,{className:"size-6 text-destructive"}),h.jsx("div",{className:"text-[13px] text-text-200",children:"project 启动失败"}),h.jsx("div",{className:"max-w-[400px] text-[12px] text-text-400",children:e??"未知原因 —— 看 ~/.clawd/clawd.log 排查"}),h.jsx("div",{className:"mt-1 max-w-[300px] text-[11px] text-text-500",children:"左侧 chat 可看 assistant 详细进度 / 跟它说怎么修"})]})}function boe({error:e,onClose:t}){const[n,r]=g.useState(!1),i=async()=>{var a;if(!e)return;const s=e.message;let o=!1;try{(a=navigator.clipboard)!=null&&a.writeText&&(await navigator.clipboard.writeText(s),o=!0)}catch{o=!1}if(!o){const l=document.createElement("textarea");l.value=s,l.style.position="fixed",l.style.opacity="0",document.body.appendChild(l),l.select();try{document.execCommand("copy"),o=!0}catch{o=!1}finally{document.body.removeChild(l)}}o&&(r(!0),setTimeout(()=>r(!1),1500))};return h.jsx(w1,{open:!!e,onOpenChange:s=>{s||(r(!1),t())},children:h.jsxs(Vp,{className:"max-w-lg",children:[h.jsx(qp,{children:h.jsx(Kp,{children:(e==null?void 0:e.title)??"错误"})}),h.jsx("pre",{"data-testid":"rpc-error-message",className:"max-h-72 overflow-auto whitespace-pre-wrap break-words rounded border border-bg-200 bg-bg-50 px-3 py-2 text-[12px] text-text-200",children:(e==null?void 0:e.message)??""}),h.jsxs(S1,{children:[h.jsx(di,{variant:"ghost",onClick:i,className:"gap-1.5",children:n?h.jsxs(h.Fragment,{children:[h.jsx(wl,{className:"size-3.5"}),"已复制"]}):h.jsxs(h.Fragment,{children:[h.jsx(up,{className:"size-3.5"}),"复制"]})}),h.jsx(di,{onClick:t,children:"关闭"})]})]})})}function woe(e,t){for(const n of[e,t])if(n)try{const r=new URL(n),i=r.protocol==="https:"||r.protocol==="wss:"?"https":"http";return{host:r.host,scheme:i}}catch{}return{host:null,scheme:"https"}}const Soe={codex:"on-request",claude:"bypassPermissions"};function koe(e){const t={cwd:e.cwd,permissionMode:e.sourcePermissionMode??Soe[e.sourceTool??"claude"]??"bypassPermissions",forkedFromSessionId:e.sourceSessionId};return e.sourceOwnerPersonaId&&(t.ownerPersonaId=e.sourceOwnerPersonaId),e.sourceTool&&(t.tool=e.sourceTool),e.sourceProjectPath&&(t.projectPath=e.sourceProjectPath),t}async function Coe(e,t,n,r={}){if(!t.toolSessionId)return null;const i=await e.sessionCreate({...koe({cwd:t.cwd,sourceSessionId:t.sessionId,sourcePermissionMode:t.permissionMode,sourceOwnerPersonaId:t.ownerPersonaId,sourceTool:t.tool,sourceProjectPath:t.projectPath}),...r.ephemeral?{ephemeral:!0}:{}});try{const{forkedToolSessionId:s}=await e.sessionFork({cwd:t.cwd,toolSessionId:t.toolSessionId,messageUuid:n,targetCwd:i.cwd});await e.sessionResume(i.sessionId,s)}catch(s){throw e.sessionDelete(i.sessionId).catch(o=>Me("quick-ask","fork rollback failed",o)),s}return i}async function Eoe(e,t,n){return Coe(e,t,n,{ephemeral:!0})}function $d(e){return e!=null&&e.ephemeral!==!1}async function Noe(e,t){return t.stillEphemeral?(await e.sessionUpdate(t.sessionId,{ephemeral:!1}),!0):!1}const Toe=300;function Ioe(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function Poe(e,t){const n=T_(),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>{let a=!1;return(async()=>{try{const l=await n.kv.get(e);if(a)return;const c=Ioe(l);typeof c=="number"&&Number.isFinite(c)&&c>0?i(c):i(t)}catch{a||i(t)}})(),()=>{a=!0}},[n,e,t]);const o=g.useCallback(a=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{s.current=null,n.kv.set(e,a).catch(()=>{})},Toe)},[n,e]);return g.useEffect(()=>()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),{initialSize:r??t,setSize:o,loading:r===null}}function Roe(){return{quickAsk:null,mds:[],active:null}}function Moe(e,t){return{...e,quickAsk:{sessionId:t.sessionId,ephemeral:!0},active:"quick-ask"}}function Aoe(e,t){const n=e.mds.includes(t);return{...e,mds:n?e.mds:[...e.mds,t],active:{kind:"md",relPath:t}}}function joe(e){if(!e.quickAsk)return e;const t=e.active==="quick-ask",n=e.mds[0],r=t?n?{kind:"md",relPath:n}:null:e.active;return{...e,quickAsk:null,active:r}}function Loe(e){return e.quickAsk?{...e,quickAsk:{...e.quickAsk,ephemeral:!1}}:e}function Doe(e,t){const n=e.mds.indexOf(t);if(n<0)return e;const r=e.mds.filter(l=>l!==t);if(!(e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===t))return{...e,mds:r};const s=r[n],o=n>0?r[n-1]:void 0;let a=null;return s?a={kind:"md",relPath:s}:o?a={kind:"md",relPath:o}:e.quickAsk&&(a="quick-ask"),{...e,mds:r,active:a}}function Ooe(e,t){return{...e,active:t}}function Boe(e,t){return e===null||t===null||e==="quick-ask"||t==="quick-ask"?e===t:e.relPath===t.relPath}function v3(e){return e.quickAsk!==null||e.mds.length>0}function zoe(e){return e.split("/").pop()||e}function $oe({state:e,api:t,onSwitchTab:n,onCloseQuickAsk:r,onCloseMd:i,loadMarkdown:s,quickAskSession:o,onPromoteQuickAsk:a}){if(!v3(e))return null;const l=[];e.quickAsk&&l.push({id:"quick-ask",label:"问一下",title:"问一下",icon:h.jsx(x0,{className:"w-3.5 h-3.5"})});for(const c of e.mds)l.push({id:{kind:"md",relPath:c},label:zoe(c),title:c,icon:h.jsx(mi,{className:"w-3.5 h-3.5"})});return h.jsxs("div",{className:"flex flex-col h-full bg-bg-50/60 border-l border-border-strong",children:[h.jsx(cf,{delayDuration:200,skipDelayDuration:100,children:h.jsx("div",{className:["flex items-stretch h-9 border-b border-text-100/10 shrink-0 overflow-x-auto","[scrollbar-width:none] [-ms-overflow-style:none]","[&::-webkit-scrollbar]:hidden"].join(" "),role:"tablist",children:l.map(c=>{const u=Boe(e.active,c.id),d=c.id==="quick-ask"?"quick-ask":`md:${c.id.relPath}`;return h.jsxs(Ep,{children:[h.jsx(Np,{asChild:!0,children:h.jsxs("div",{role:"tab","aria-selected":u,"data-tab-title":c.title,onClick:()=>n(c.id),className:["group relative flex items-center gap-2 px-3 h-full cursor-pointer select-none","text-[12px] max-w-[180px] shrink-0 transition-colors duration-100",u?"text-text-100":"text-text-400 hover:text-text-100 hover:bg-text-100/[0.04]"].join(" "),children:[c.icon,h.jsx("span",{className:"truncate",children:c.label}),h.jsx("button",{type:"button","aria-label":`关闭 ${c.label}`,className:["ml-1 rounded p-0.5 shrink-0 transition-opacity","hover:bg-text-100/10",u?"opacity-70 hover:opacity-100":"opacity-0 group-hover:opacity-70"].join(" "),onClick:f=>{f.stopPropagation(),c.id==="quick-ask"?r():i(c.id.relPath)},children:h.jsx(Ir,{className:"w-3 h-3"})}),u?h.jsx("span",{"aria-hidden":"true",className:"absolute left-2 right-2 -bottom-px h-[2px] rounded-full bg-accent"}):null]})}),h.jsx(Mu,{side:"bottom",align:"start",className:"max-w-sm break-all",children:c.title})]},d)})})}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[e.quickAsk&&o?h.jsx("div",{className:"absolute inset-0",style:{display:e.active==="quick-ask"?"block":"none"},children:h.jsx(Xoe,{session:o,api:t,...a?{onPromoteQuickAsk:a}:{}})}):null,e.mds.map(c=>{const u=e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===c;return h.jsx("div",{className:"absolute inset-0",style:{display:u?"block":"none"},children:h.jsx(g3,{relPath:c,loadMarkdown:s,showTitleBar:!1})},`md-body:${c}`)})]})]})}function Foe(e){const t=e instanceof Error?e.message:String(e);return t.length>200?`${t.slice(0,200)}…`:t}function Hoe({state:e,extras:t}){const{api:n,session:r}=t,i=_i(),[s,o]=g.useState(Roe()),[a,l]=g.useState(null),c=r.ownerPersonaId!==UT,u=g.useRef(s);u.current=s;const d=g.useRef(!1),f=g.useCallback(async T=>{const O=u.current.quickAsk;l(null);let P;try{P=await Eoe(n,r,T)}catch(D){Me("quick-ask","fork failed",D),d.current||l(Foe(D));return}if(!P){d.current||l("这条会话还没准备好(没有可派生的对话记录),稍后再试");return}if(d.current){n.sessionDelete(P.sessionId).catch(()=>{});return}$d(O)&&n.sessionDelete(O.sessionId).catch(()=>{}),o(D=>Moe(D,{sessionId:P.sessionId}))},[n,r]),p=g.useCallback(async T=>{const O=u.current.quickAsk,P=(O==null?void 0:O.sessionId)===T;try{await Noe(n,{sessionId:T,stillEphemeral:P&&$d(O)})&&o(R=>Loe(R))}catch(D){Me("quick-ask","promote failed",D)}},[n]),m=g.useCallback(T=>{o(O=>Aoe(O,T))},[]),v=g.useCallback(T=>{o(O=>Ooe(O,T))},[]),w=g.useCallback(()=>{const T=u.current.quickAsk;$d(T)&&n.sessionDelete(T.sessionId).catch(()=>{}),o(O=>joe(O))},[n]),x=g.useCallback(T=>{o(O=>Doe(O,T))},[]);g.useEffect(()=>()=>{d.current=!0;const T=u.current.quickAsk;$d(T)&&n.sessionDelete(T.sessionId).catch(()=>{})},[]);const _=pi("sessions")??[],y=s.quickAsk?_.find(T=>T.sessionId===s.quickAsk.sessionId)??{sessionId:s.quickAsk.sessionId,cwd:r.cwd,tool:r.tool}:null,S=g.useCallback(async T=>{const O=await k1(n,i,r.sessionId,T,60),P=await fetch(O);if(!P.ok)throw new Error(`fetch ${P.status} ${P.statusText}`);return P.text()},[n,i,r.sessionId]),C=h.jsx(C1,{state:e,extras:t,onQuickAskInternal:f,onPreviewMdInternal:m}),{initialSize:k,setSize:N}=Poe("chat-panel-right-slot-width",480);return h.jsxs(Ly,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:[h.jsx(uf,{id:"chat",minSize:"400px",children:h.jsxs("div",{className:"relative flex flex-col min-w-0 min-h-0 h-full",children:[C,a?h.jsxs("div",{"data-testid":"quick-ask-error",className:"absolute bottom-24 left-1/2 z-10 -translate-x-1/2 max-w-[90%] rounded-md border border-border bg-bg-200 px-3 py-2 text-[12px] text-text-300 shadow-lg",children:[h.jsxs("span",{className:"mr-2",children:["问一下没能打开:",a]}),h.jsx("button",{type:"button","aria-label":"关闭提示",onClick:()=>l(null),className:"text-text-400 hover:text-text-200 cursor-pointer",children:"✕"})]}):null]})}),v3(s)?h.jsxs(h.Fragment,{children:[h.jsx(c5,{className:"w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),h.jsx(uf,{id:"right-slot",defaultSize:`${k}px`,minSize:"360px",maxSize:"800px",onResize:T=>N(T.inPixels),children:h.jsx($oe,{state:s,api:n,onSwitchTab:v,onCloseQuickAsk:w,onCloseMd:x,loadMarkdown:S,quickAskSession:y,...c?{onPromoteQuickAsk:p}:{}})})]}):null]})}const h2=4;function Uoe({children:e,onHeightChange:t}){const n=g.useRef(null),[r,i]=g.useState(0);return g.useEffect(()=>{const s=n.current;if(!s)return;const o=()=>i(s.offsetHeight>0?s.offsetHeight+h2*2:0);if(o(),typeof ResizeObserver>"u")return;const a=new ResizeObserver(o);return a.observe(s),()=>a.disconnect()},[]),g.useEffect(()=>{t==null||t(r)},[r,t]),h.jsx("div",{"data-testid":"chat-floating-dock","data-height":r,className:"relative z-20 h-0 shrink-0",children:h.jsx("div",{ref:n,className:"absolute left-4 right-4 flex flex-col items-end gap-1",style:{bottom:h2},children:e})})}const Woe=250;function Voe(e){if(!e||!Number.isFinite(e))return null;const t=e/1e3;if(t<60)return`${t.toFixed(0)}s`;const n=Math.floor(t/60);return`${n}m${Math.round(t-n*60).toString().padStart(2,"0")}s`}function qoe({agents:e}){var a,l,c;const[t,n]=g.useState(!1);if(e.length===0)return null;const r=e.length===1?e[0]:null,i=r?r.description:`${e.length} 个后台任务`,s=r?Voe((l=(a=r.progress)==null?void 0:a.stats)==null?void 0:l.durationMs):null,o=r?(c=r.progress)==null?void 0:c.lastToolName:null;return h.jsxs("div",{"data-testid":"running-agents-chip","data-agent-count":e.length,className:"relative",children:[t?h.jsx("div",{"data-testid":"running-agents-popover",className:"absolute bottom-full right-0 z-20 mb-1 w-[min(560px,80vw)]",children:h.jsx("div",{className:"min-w-0 overflow-y-auto rounded-lg border border-bg-200/60 bg-bg-100 px-2 py-1 shadow-lg",style:{maxHeight:Woe},children:e.map(u=>h.jsx(MM,{expandable:!1,description:u.description,input:u.input,output:u.output,...u.error!==void 0?{error:u.error}:{},pending:u.pending,notifications:u.notifications,...u.toolResultExtra?{toolResultExtra:u.toolResultExtra}:{},...u.progress?{progress:u.progress}:{}},u.toolUseId))})}):null,h.jsxs("button",{type:"button","data-testid":"running-agents-chip-toggle","aria-expanded":t,onClick:()=>n(u=>!u),className:re("flex max-w-[min(560px,80vw)] min-w-0 items-center gap-2 rounded-full","border border-bg-200/60 bg-bg-100/95 px-3 py-1 text-[12px] shadow-md backdrop-blur","hover:bg-bg-200/95 transition-colors"),children:[h.jsx(Ln,{className:"w-3 h-3 shrink-0 animate-spin text-blue-400"}),h.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-text-200",children:i}),s?h.jsx("span",{className:"shrink-0 tabular-nums text-text-400",children:s}):null,o?h.jsxs("span",{className:"shrink-0 font-mono tabular-nums text-blue-400",children:["now:",o]}):null,h.jsx(xI,{className:re("w-3.5 h-3.5 shrink-0 text-text-400 transition-transform",t&&"rotate-180")})]})]})}const Koe={closeTrailing:!1},Goe={closeTrailing:!0};function Yoe(e){return e?Koe:Goe}function Xoe({session:e,api:t,onPromoteQuickAsk:n}){const r=MA(e.sessionId);return h.jsx(C1,{state:r,extras:{session:e,api:t,...n?{onPromoteQuickAsk:n}:{}}})}function Qoe({extras:e}){const t=MA(e.session.sessionId);if(e.session.appBuilderProject){const n=h.jsx(C1,{state:t,extras:e});return h.jsx(Zoe,{state:t,chat:n,extras:e})}return h.jsx(Hoe,{state:t,extras:e})}function Zoe({state:e,chat:t,extras:n}){var T;const r=pi("daemon-info"),i=_i(),s=n.api,o=n.session,a=o.appBuilderProject,[l,c]=g.useState(null),u=g.useCallback(()=>{s.appBuilderGetProject(o.sessionId).then(O=>c(O.project)).catch(()=>c(null))},[s,o.sessionId]);g.useEffect(()=>{u()},[u]);const[d,f]=g.useState([]),p=g.useCallback(()=>{s.appBuilderListProjects().then(O=>f(O.projects)).catch(()=>f([]))},[s]);g.useEffect(()=>{p()},[p]),g.useEffect(()=>i.on("appBuilder:project-updated",P=>{const D=P;D!=null&&D.project&&(D.project.name===a&&c(D.project),f(R=>{const A=R.findIndex(L=>L.name===D.project.name);if(A<0)return[...R,D.project];const M=R.slice();return M[A]=D.project,M}))}),[i,a]);const{host:m,scheme:v}=woe(i.url,r==null?void 0:r.tunnelUrl),[w,x]=g.useState(void 0),[_,y]=g.useState(null);g.useEffect(()=>{const O=i.on("appBuilder:publish-progress",D=>{const R=D;!R||R.name!==a||R.status==="started"&&x(R.stage)}),P=i.on("appBuilder:publish-failed",D=>{const R=D;!R||R.name!==a||(x(void 0),y({stage:R.stage}))});return()=>{O(),P()}},[i,a]),g.useEffect(()=>{x(void 0),y(null)},[a]);const[S,C]=g.useState(null),k=h.jsx("button",{type:"button",className:"rounded bg-accent-main-100 px-2.5 py-1 text-[12px] text-oncolor-100 hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50",disabled:((T=l==null?void 0:l.publishJob)==null?void 0:T.status)==="in-flight",onClick:async()=>{try{await s.appBuilderPublish(a)}catch(O){C({title:"发布请求失败",message:(O==null?void 0:O.message)??String(O)})}},children:"发布上线"}),N=(l==null?void 0:l.stage)??(l!=null&&l.isRunning?"running":"stopped");return h.jsxs(h.Fragment,{children:[h.jsx(uoe,{left:t,stage:N,onExpand:async()=>{await s.appBuilderStartDevServer(o.sessionId)},onCollapse:async()=>{await s.appBuilderStopDevServer(o.sessionId)},right:h.jsx(_oe,{project:l,previewHost:m,previewScheme:v,allUsedPorts:d.map(O=>O.port),onUpdatePort:async O=>{await s.appBuilderUpdateProjectPort(a,O),p()},publishSlot:k,publishInFlightStage:w,onDismissPublishJob:async()=>{try{await s.appBuilderDismissPublishJob(a)}catch(O){C({title:"取消发布失败",message:(O==null?void 0:O.message)??String(O)})}},onRetryPublish:async()=>{try{await s.appBuilderPublish(a)}catch(O){C({title:"重新发布失败",message:(O==null?void 0:O.message)??String(O)})}},publishFailureBanner:_,onPublishFailureBannerClose:()=>y(null),onPublishFailureBannerFocusChat:()=>{}})}),h.jsx(boe,{error:S,onClose:()=>C(null)})]})}function Joe({headerMeta:e,connState:t,liveWorktreeRoot:n,onOpenConfig:r,variant:i="full",ephemeral:s,onPromote:o,hideHeader:a=!1,flatProcess:l=!1,lines:c,pendingPermissions:u,procAlive:d,rewindableUserMessageIds:f,onPermissionRespond:p,onPermissionInterrupt:m,onRewind:v,onFork:w,onQuickAsk:x,topSlot:_,realtimeQuestionAnswers:y,onSubmitQuestion:S,onCancelQuestion:C,liveQuestionToolUseIds:k,api:N,cwd:T,tool:O,sessionKey:P,onSend:D,awaitingUser:R,queued:A,onDequeue:M,onAbort:L,onNewSession:$,onClearSession:F,configSlot:B,chatRootRef:z,chatBodyRef:E,drawers:H,xtermSlot:q,fileSharingScope:j,onShareFile:ne,onOpenInTab:ie,onPreviewMarkdown:K,onOpenFilePath:ge,resolveDispatchLine:Pe}){const[he,Ae]=g.useState(0),je=g.useMemo(()=>i==="full"?OV(h5(c)):[],[c,i]),$e=g.useMemo(()=>new Set(je.map(_e=>_e.toolUseId)),[je]);return h.jsx(VJ,{children:h.jsxs("div",{ref:z,"data-cc-chat-root":"",className:"flex flex-col h-full bg-bg-100",children:[a?null:h.jsx(Kee,{meta:e,...O?{tool:O}:{},connState:t,variant:i,...n!==void 0?{liveWorktreeRoot:n}:{},...i==="full"&&r?{onOpenConfig:r}:{},...i==="quickask"?{ephemeral:s??!1,...o?{onPromote:o}:{}}:{}}),h.jsx("div",{ref:E,"data-testid":"chat-body",className:"flex-1 overflow-y-auto min-h-0",style:{overflowAnchor:"none",paddingBottom:he},children:h.jsx(jM,{lines:c,...p?{onPermissionRespond:p}:{},...m&&d?{onPermissionInterrupt:m}:{},topSlot:_,...v?{onRewind:v}:{},rewindableUserMessageIds:f,...w?{onFork:w}:{},...x?{onQuickAsk:x}:{},realtimeQuestionAnswers:y,onSubmitQuestion:S,...C?{onCancelQuestion:C}:{},liveQuestionToolUseIds:k,...j?{fileSharingScope:j}:{},...ne?{onShareFile:ne}:{},...ie?{onOpenInTab:ie}:{},...K?{onPreviewMarkdown:K}:{},...ge?{onOpenFilePath:ge}:{},...Pe?{resolveDispatchLine:Pe}:{},...i==="full"&&!l?{turnCollapse:Yoe(d)}:{},dockedAgentToolUseIds:$e})}),q,h.jsx(Uoe,{onHeightChange:Ae,children:h.jsx(qoe,{agents:je})}),e.larkChatName?h.jsx("div",{className:"mx-3 mb-3 rounded-lg border border-border bg-bg-200 px-3 py-2 text-[12px] text-text-400","data-testid":"lark-readonly-notice",children:e.larkChatType==="p2p"?`此会话由与「${e.larkChatName}」的飞书私聊驱动——对方消息触发,这里仅供观察。`:`此会话由飞书群「${e.larkChatName}」驱动——群成员 @ bot 提问触发,这里仅供观察。`}):h.jsx(Vee,{meta:e,...N?{api:N}:{},cwd:T,...O?{tool:O}:{},sessionKey:P,onSend:D,awaitingUser:R,...A?{queued:A}:{},...M?{onDequeue:M}:{},...L?{onAbort:L}:{},...$?{onNewSession:$}:{},...F?{onClearSession:F}:{},...B?{configSlot:B}:{}}),H]})})}function C1({state:e,extras:t,onQuickAskInternal:n,onPreviewMdInternal:r}){const{session:i,api:s,liveGitBranch:o,liveWorktreeRoot:a,onNewSession:l,onTurnEnd:c,onOpenConfig:u,onFork:d,onQuickAsk:f,viewerRole:p,onPromoteQuickAsk:m,configSlot:v,hideHeader:w,flatProcess:x}=t,{capabilities:_}=f1(i.tool||"claude"),y=(_==null?void 0:_.features)??uI(i.tool),[S,C]=g.useState(null),[k,N]=g.useState(null),T=ap(),O=!!s&&T.actionsLevel==="owner"&&y.fileSharing,P=mI(i.ownerPersonaId??null).persona,D=(P==null?void 0:P.label)??null,R=!!D&&!!i.ownerPersonaId,A=roe(),M=g.useCallback((Y,ve)=>{C({kind:Y,text:ve}),setTimeout(()=>{C(Se=>(Se==null?void 0:Se.text)===ve?null:Se)},2e3)},[]),L=_i(),$=Az(),F=RA(i.sessionId,i.toolSessionId),{events:B,pendingQuestions:z,clearQuestion:E,markQuestionSubmitted:H,status:q}=F,j=e.historyLoading,ne=$M(q);g.useEffect(()=>{Me("chat-panel","sessionStatus",{sessionId:i.sessionId,sessionStatus:q,procAlive:ne})},[q,ne,i.sessionId]);const ie=e.lines,K=e.pendingPermissions,ge=K[0]??null,Pe=g.useMemo(()=>PV(B),[B]),[he,Ae]=g.useState(null),[je,$e]=g.useState(()=>new Set);NV(s,i.sessionId,i.toolSessionId,y.observe);const _e=g.useRef(i.sessionId);g.useEffect(()=>{if(_e.current=i.sessionId,!y.rewind){Ae(null);return}let Y=!1;return Ae(null),(async()=>{try{const ve=await s.sessionRewindableMessageIds(i.sessionId);if(Y)return;Ae(new Set(ve.userMessageIds))}catch{Y||Ae(null)}})(),()=>{Y=!0}},[s,i.sessionId,y.rewind]);const tt=g.useCallback(()=>{const Y=i.sessionId;s.sessionRewindableMessageIds(Y).then(ve=>{_e.current===Y&&Ae(new Set(ve.userMessageIds))}).catch(()=>{})},[s,i.sessionId]),Rt=g.useMemo(()=>{if(he!==null){const Je=new Set(he);for(const Rr of je)Je.delete(Rr);return Je}const Y=new Set(["Edit","Write","MultiEdit","NotebookEdit"]),ve=new Set;let Se=null;for(const Je of ie)Je.kind==="user-text"?Se=Je.uuid??null:Se&&Je.kind==="tool-call"&&Y.has(Je.tool)&&!je.has(Se)&&ve.add(Se);return ve},[ie,je,he]),Xe=g.useRef(c);Xe.current=c,TV(i.sessionId,i.toolSessionId,()=>{Ke(null),$e(new Set)});const ot=mte({sessionStatus:q}),xn=g.useRef(null);g.useEffect(()=>{var Se;const Y=xn.current,ve=(Y==null?void 0:Y.sid)===i.sessionId;ve&&Y.phase===ot||(xn.current={sid:i.sessionId,phase:ot},Me("session-phase",ot,{sid:i.sessionId,phase:ot,prev:ve?Y.phase:null,desc:pte[ot]}),ve&&Y.phase==="turn-running"&&ot!=="turn-running"&&((Se=Xe.current)==null||Se.call(Xe),tt()))},[ot,i.sessionId,tt]);const ut=g.useCallback(async()=>{const Y=await s.sessionInterrupt(i.sessionId).catch(()=>{});return(Y==null?void 0:Y.queued)??[]},[s,i.sessionId]),[Ct,Ke]=g.useState(null),at=g.useCallback(Y=>{Ke(Y)},[]),[Dt,Vt]=g.useState(!1),Tn=g.useCallback(()=>{s.sessionStop(i.sessionId).catch(()=>{}),Vt(!1)},[s,i.sessionId]);g.useCallback(Y=>{s.pinSession(i.sessionId,Y).catch(ve=>{Me("chat-panel","pinSession failed",{err:ve==null?void 0:ve.message})})},[s,i.sessionId]);const U=m?"quickask":"full",{container:J,onCollapse:ye}=ete(),Ce=g.useRef(0),Fe=g.useRef(null);g.useEffect(()=>{const Y=ve=>{if(ve.key!=="Escape")return;if(!ne){Ce.current=0;return}if(ve.isComposing)return;const Je=ve.target;if(Je&&Je.closest("[data-cc-chat-root]")!==Fe.current)return;const Rr=Date.now();Rr-Ce.current<2e3?(Ce.current=0,Vt(!0)):(Ce.current=Rr,ut())};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[ut,ne]);const xt=g.useRef(null),un=g.useRef(!0),qt=g.useRef(void 0),dn=g.useRef(0),se=g.useRef(0),be=g.useRef(void 0);g.useEffect(()=>{N(null)},[i.sessionId]),g.useEffect(()=>{const Y=xt.current;if(!Y)return;const ve=150,Se=Je=>{Date.now()<se.current&&(Je.preventDefault(),se.current=Date.now()+ve)};return Y.addEventListener("wheel",Se,{passive:!1}),()=>Y.removeEventListener("wheel",Se)},[]),g.useEffect(()=>{const Y=xt.current;if(!Y)return;const ve=32,Se=()=>{const Je=Y.scrollHeight-Y.scrollTop-Y.clientHeight;un.current=Je<=ve};return Y.addEventListener("scroll",Se,{passive:!0}),()=>Y.removeEventListener("scroll",Se)},[]),g.useLayoutEffect(()=>{var Zo;const Y=xt.current;if(!Y)return;const ve=be.current!==i.sessionId;ve&&(be.current=i.sessionId,un.current=!0,qt.current=void 0,dn.current=0,se.current=0);const Se=qt.current,Je=(Zo=ie[0])==null?void 0:Zo.seq;qt.current=Je,!ve&&Se!==void 0&&Je!==void 0&&Je<Se?(Y.scrollTop=Y.scrollHeight-dn.current,se.current=Date.now()+200):un.current&&(Y.scrollTop=Y.scrollHeight),dn.current=Y.scrollHeight-Y.scrollTop},[ie,ge==null?void 0:ge.requestId,i.sessionId]);const lt=g.useMemo(()=>{const Y={};for(const[ve,Se]of Object.entries(z))Se.submittedAnswers&&(Y[ve]=Se.submittedAnswers);return Y},[z]),Mt=g.useMemo(()=>new Set(Object.keys(z)),[z]),Pr=g.useCallback(async(Y,ve)=>{try{await s.answerQuestion({sessionId:i.sessionId,toolUseId:Y,answers:ve}),H(Y,ve)}catch{}},[s,i.sessionId,H]),ae=g.useCallback(async Y=>{try{await s.cancelQuestion({sessionId:i.sessionId,toolUseId:Y}),E(Y)}catch{}},[s,i.sessionId,E]),Ze=g.useCallback(async(Y,ve)=>{var Se;if(ge)try{await((Se=e.respondPermission)==null?void 0:Se.call(e,ge.requestId,Y?"allow":"deny"))}catch{}},[e,ge]),hn=g.useCallback(async()=>{const Y=i.sessionId;try{await s.sessionStop(Y)}catch{}e.clearSession?await e.clearSession():await s.sessionNew(Y)},[e,s,i.sessionId]),Ys=g.useMemo(()=>e.historyError?h.jsxs("div",{className:"flex justify-center py-2 text-[12px] text-text-400","data-testid":"history-error",children:["历史未加载完(",e.historyError,");切走再切回可重试"]}):j&&ie.length===0?h.jsx("div",{className:"flex justify-center py-4","data-testid":"history-loading",children:h.jsx(Ln,{className:"w-4 h-4 text-text-400 animate-spin"})}):null,[j,ie.length,e.historyError]),Ko=e.meta,Go=h.jsxs(h.Fragment,{children:[i.toolSessionId&&y.subagents?h.jsx(ate,{api:s,cwd:i.cwd,toolSessionId:i.toolSessionId,toolKind:i.tool??"claude"}):null,Ct&&y.rewind?h.jsx(cte,{open:!0,onOpenChange:Y=>{Y||Ke(null)},api:s,sessionId:i.sessionId,userMessageId:Ct,lines:ie,procAlive:ne,onNoChanges:Y=>{$e(ve=>{if(ve.has(Y))return ve;const Se=new Set(ve);return Se.add(Y),Se})}}):null,Dt?h.jsx(eae,{onConfirm:Tn,onCancel:()=>Vt(!1)}):null]}),Si={kind:"session",sessionId:i.sessionId},Xs=g.useCallback(async Y=>{if(s)try{await l2(s,L,i.sessionId,Y)}catch(ve){const Se=ve.message;Me("chat-panel","open-in-tab failed",{err:Se}),M("err",`Open in tab 失败:${Se}`)}},[s,L,i.sessionId,M]),[Pl,Yo]=g.useState(!1),[qr,rs]=g.useState(null),Qs=g.useCallback(Y=>{if(r){r(Y);return}rs(Y),Yo(!0)},[r]),Gp=g.useCallback(Y=>{if(!s)return;const ve=async()=>{try{await s.attachmentGroupAdd(i.sessionId,Y)}catch(Je){Me("chat-panel","file-link groupAdd skipped",{err:Je.message})}},Se=Je=>{const Rr=Je.message;Me("chat-panel","file-link open failed",{err:Rr}),M("err",`打开文件失败:${Rr}`)};if(Lp(Y)){ve().then(()=>Qs(Y),Se);return}l2(s,L,i.sessionId,Y,60,ve).catch(Se)},[s,L,i.sessionId,Qs,M]),Kt=g.useCallback(async Y=>{if(!s)throw new Error("daemon api not ready");const ve=await k1(s,L,i.sessionId,Y,60),Se=await fetch(ve);if(!Se.ok)throw new Error(`fetch ${Se.status} ${Se.statusText}`);return await Se.text()},[s,L,i.sessionId]),Xo=g.useCallback(async(Y,ve)=>{if(s)try{const{url:Se}=await s.attachmentSignUrl({sessionId:i.sessionId,relPath:Y,ttlSeconds:86400,...ve?{view:ve}:{}}),Je=await ooe(Se);M(Je?"ok":"err",Je?"分享链接已复制到剪贴板(24h 有效)":"复制失败:请手动复制")}catch(Se){const Je=Se.message;Me("chat-panel","share-file failed",{err:Je}),M("err",`生成分享链接失败:${Je}`)}},[s,i.sessionId,M]),Qo=g.useCallback(()=>N(null),[]),At=k==="files"&&O&&s?{title:"Edited Files",onBack:Qo,content:h.jsx(Bie,{api:s,scope:Si,sessionId:i.sessionId,onShareFile:Xo,onOpenInTab:Xs,onPreviewMarkdown:Qs})}:k==="cron"?{title:`定时任务${Pe.length?` (${Pe.length})`:""}`,onBack:Qo,content:h.jsx("div",{className:"p-3",children:h.jsx(fte,{jobs:Pe})})}:k==="persona"&&R&&s&&i.ownerPersonaId?{title:`Persona · ${D??""}`,onBack:Qo,content:h.jsx(eoe,{personaId:i.ownerPersonaId,open:!0,onClose:Qo,api:s,embedded:!0,...p?{viewerRole:p}:{}},i.ownerPersonaId)}:null,Ot=U==="full"?h.jsx(Zee,{session:i,meta:Ko,...o!==void 0?{liveGitBranch:o}:{},...a!==void 0?{liveWorktreeRoot:a}:{},...R?{personaName:D}:{},...R?{onOpenPersona:()=>N("persona")}:{},...O?{onOpenFiles:()=>N("files")}:{},cronActiveCount:Pe.length,onCronClick:()=>N("cron"),onForceStop:()=>Vt(!0),...p?{viewerRole:p}:{},..._!=null&&_.toolSessionIdLabel?{toolSessionIdLabel:_.toolSessionIdLabel}:{},drill:At,...ye?{onCollapse:ye}:{}}):null;return h.jsxs(h.Fragment,{children:[J&&Ot?fl.createPortal(Ot,J):null,h.jsx(Joe,{headerMeta:Ko,connState:e.connState,...a!==void 0?{liveWorktreeRoot:a}:{},...u?{onOpenConfig:u}:{},variant:U,...w?{hideHeader:w}:{},...x?{flatProcess:x}:{},...U==="quickask"?{ephemeral:i.ephemeral!==!1,onPromote:()=>void(m==null?void 0:m(i.sessionId))}:{},lines:ie,pendingPermissions:K,procAlive:ne,rewindableUserMessageIds:Rt,onPermissionRespond:Ze,onPermissionInterrupt:ut,onRewind:y.rewind?at:void 0,...d&&y.fork?{onFork:d}:{},...n&&y.fork?{onQuickAsk:n}:f&&y.fork?{onQuickAsk:f}:{},topSlot:Ys,realtimeQuestionAnswers:lt,onSubmitQuestion:Pr,onCancelQuestion:ae,liveQuestionToolUseIds:Mt,api:s,cwd:i.cwd,...i.tool?{tool:i.tool}:{},sessionKey:i.sessionId,onSend:e.sendText,queued:e.queued,onDequeue:e.dequeue,awaitingUser:K.length>0||Object.values(z).some(Y=>!Y.submittedAnswers),onAbort:ut,...l?{onNewSession:l}:{},onClearSession:hn,...v?{configSlot:v}:{},chatRootRef:Fe,chatBodyRef:xt,drawers:Go,xtermSlot:$==="tui"&&ne&&y.tui?h.jsx(Iie,{sessionId:i.sessionId,client:L},i.sessionId):null,fileSharingScope:Si,...s?{onShareFile:Xo}:{},...s?{onOpenInTab:Xs}:{},...s?{onPreviewMarkdown:Qs}:{},...s?{onOpenFilePath:Gp}:{},resolveDispatchLine:A}),s?h.jsx(coe,{open:Pl,onOpenChange:Yo,relPath:qr,loadMarkdown:Kt,onShare:qr?()=>void Xo(qr,"md-rendered"):void 0}):null,S?h.jsx("div",{"data-testid":"share-toast",role:"status","aria-live":"polite",className:S.kind==="ok"?"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-emerald-500/40 bg-emerald-500/10 px-3 py-2 text-[12px] text-emerald-700 shadow-md dark:text-emerald-300":"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px] text-destructive shadow-md",children:S.text}):null]})}function eae({onConfirm:e,onCancel:t}){return h.jsx("div",{role:"dialog","aria-modal":"true","data-testid":"force-stop-confirm",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:t,children:h.jsxs("div",{className:"max-w-sm w-[92%] rounded-lg border border-red-400/40 bg-bg-0 p-4 shadow-xl",onClick:n=>n.stopPropagation(),children:[h.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[h.jsx(nu,{className:"w-5 h-5 text-red-500 shrink-0 mt-0.5"}),h.jsx("div",{className:"text-[14px] text-text-100",children:"强制停止会话进程?会丢失 initialize / 预热缓存,下一次发送需要重新 spawn。"})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:t,className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),h.jsx("button",{type:"button","data-testid":"force-stop-confirm-ok",onClick:e,className:"h-8 px-3 rounded-md bg-red-500 text-white text-[12px] font-medium hover:bg-red-600 cursor-pointer",children:"强制停止"})]})]})})}function tae(e,t,n){const r=e?t.find(s=>s.id===e):void 0;if(r!=null&&r.efforts&&r.efforts.length>0)return{options:r.efforts,defaultValue:r.defaultEffort??""};const i=n.find(s=>s.name==="effort");return{options:(i==null?void 0:i.options)??[],defaultValue:typeof(i==null?void 0:i.default)=="string"?i.default:""}}function nae(e,t,n){var l;if(!t)return((l=(e??[]).find(c=>c.id===""))==null?void 0:l.label)??"未指定";const r=t.toLowerCase(),i=[["opus","Opus"],["fable","Fable"],["sonnet","Sonnet"],["haiku","Haiku"]];for(const[c,u]of i){if(!r.includes(c))continue;const d=r.match(new RegExp(`${c}-(\\d+)(?:-(\\d+))?`));return d?d[2]?`${u} ${d[1]}.${d[2]}`:`${u} ${d[1]}`:u}const s=e??[],o=s.find(c=>c.id===t);if(o)return o.label;const a=s.find(c=>c.id&&t.toLowerCase().includes(c.id.toLowerCase()));return a?a.label:t}function rae(e,t){var m,v,w,x;const{models:n,modes:r,configSchema:i}=t,s=e.resolvedModel??e.model,o=tae(s,n,i),a=o.options,l=a.some(_=>_.value===e.effort)?e.effort:o.defaultValue,c=e.effort===""&&e.resolvedEffort?((m=a.find(_=>_.value===e.resolvedEffort))==null?void 0:m.label)??e.resolvedEffort:((v=a.find(_=>_.value===l))==null?void 0:v.label)??null,u=((w=i.find(_=>_.name==="permissionMode"))==null?void 0:w.default)??"",d=r.some(_=>_.id===e.permissionMode)?e.permissionMode:u,p=d===u?null:((x=r.find(_=>_.id===d))==null?void 0:x.label)??null;return{modelLabel:nae(n,s),effortOptions:a,effortValue:l,effortLabel:c,modeValue:d,modeLabel:p,modeTone:p===null?null:d==="bypassPermissions"?"danger":"info"}}function iae({models:e=[],modes:t=[],configSchema:n=[],model:r,resolvedModel:i,resolvedEffort:s,effort:o,permissionMode:a,onPatch:l}){var p;const c=rae({model:r,resolvedModel:i,resolvedEffort:s,effort:o,permissionMode:a},{models:e,modes:t,configSchema:n}),u=i??r,d=e.map(m=>{const v=m.id===""&&i?`${m.description?`${m.description};`:""}当前:${i}`:m.description;return{value:m.id,label:m.label,...v?{description:v}:{}}}),f=t.map(m=>({value:m.id,label:m.label,...m.description?{description:m.description}:{}}));return h.jsxs(ky,{children:[h.jsx(Cy,{asChild:!0,children:h.jsxs("button",{type:"button","data-testid":"session-config-chip",title:"Model / reasoning effort / permission mode",className:"inline-flex items-center gap-1 h-7 px-2.5 rounded-full text-[11px] text-text-400 transition-colors outline-none cursor-pointer hover:bg-text-100/5 hover:text-text-200 data-[state=open]:bg-text-100/5",children:[h.jsx("span",{className:"truncate max-w-[120px]","data-testid":"session-config-chip-model",children:u||c.modelLabel}),c.effortLabel?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-500",children:"·"}),h.jsx("span",{className:"truncate max-w-[80px]","data-testid":"session-config-chip-effort",children:c.effortLabel})]}):null,c.modeLabel?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-500",children:"·"}),h.jsx("span",{"data-testid":"session-config-chip-mode","data-tone":c.modeTone,className:re("font-semibold",c.modeTone==="danger"?"text-red-400":"text-blue-400"),children:c.modeLabel})]}):null]})}),h.jsxs(wp,{side:"top",align:"end",className:"w-[230px]","data-testid":"session-config-menu",children:[h.jsx(Ag,{testid:"session-config-model",label:"Model",current:r,currentLabel:c.modelLabel,options:d,onSelect:m=>l({model:m})}),h.jsx(Ag,{testid:"session-config-effort",label:"Reasoning effort",current:c.effortValue,currentLabel:c.effortLabel??"—",options:c.effortOptions,onSelect:m=>l({effort:m})}),f.length>0?h.jsx(Ag,{testid:"session-config-mode",label:"Permission mode",current:c.modeValue,currentLabel:((p=t.find(m=>m.id===c.modeValue))==null?void 0:p.label)??"—",currentTone:c.modeTone,options:f,onSelect:m=>l({permissionMode:m})}):null]})]})}function Ag({testid:e,label:t,current:n,currentLabel:r,currentTone:i,options:s,onSelect:o}){const a=s.length===0;return h.jsxs(nW,{children:[h.jsxs(MR,{"data-testid":e,disabled:a,className:"gap-2 text-[12px]",children:[h.jsx("span",{className:"flex-1 text-text-200",children:t}),h.jsx("span",{className:re("truncate max-w-[100px]",i==="danger"?"text-red-400 font-semibold":i==="info"?"text-blue-400 font-semibold":"text-text-400"),children:r}),h.jsx(Bn,{className:"w-3.5 h-3.5 shrink-0 text-text-500"})]}),h.jsx(AR,{className:"w-[220px] max-h-[320px] overflow-y-auto",children:s.map(l=>{const c=l.value===n;return h.jsxs(Ri,{"data-testid":`${e}-option-${l.value||"default"}`,onSelect:()=>o(l.value),className:"items-start gap-2",children:[h.jsxs("span",{className:"flex-1 min-w-0",children:[h.jsx("span",{className:re("block text-[12px]",c?"text-text-100 font-medium":"text-text-300"),children:l.label}),l.description?h.jsx("span",{className:"block text-[11px] text-text-400 mt-0.5",children:l.description}):null]}),c?h.jsx(wl,{className:"w-3.5 h-3.5 shrink-0 text-accent mt-0.5"}):null]},l.value||"default")})})]})}function sae(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitBranch(t);i(l.branch??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{branch:r,loading:s,refresh:()=>void a()}}function oae(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitRoot(t);i(l.gitRoot??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{worktreeRoot:r,loading:s,refresh:()=>void a()}}function aae({api:e,session:t,focused:n,totalPanes:r,onFocus:i,onClose:s,onNewSession:o,onOpenConfig:a,onFork:l,onQuickAsk:c,className:u,viewerRole:d="owner",hideHeader:f}){const{capabilities:p}=f1(t.tool),[m,v]=g.useState(0),{branch:w}=sae(e,t.cwd,m),{worktreeRoot:x}=oae(e,t.cwd,m),_=r>1,y=S=>{e.sessionUpdate(t.sessionId,S).catch(C=>{console.error("[session-config] session:update failed",t.sessionId,C)})};return h.jsxs("div",{className:`group/pane relative flex-1 ${u??"flex"} flex-row min-w-0 min-h-0 overflow-hidden ${_?`rounded-md border transition-colors ${n?"border-accent ring-1 ring-accent":"border-border"}`:""}`,onMouseDown:i,"data-testid":`session-pane-${t.sessionId}`,children:[h.jsx(Ly,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:h.jsx(uf,{id:"chat",minSize:"400px",children:h.jsx("div",{className:"flex flex-col min-w-0 min-h-0 h-full",children:h.jsx(lae,{api:e,session:t,liveGitBranch:w,liveWorktreeRoot:x,onNewSession:o,onTurnEnd:()=>v(S=>S+1),onOpenConfig:a,onFork:l,onQuickAsk:c,viewerRole:d,hideHeader:f,configSlot:p?h.jsx(iae,{models:p.models,modes:p.permissionModes,configSchema:p.configSchema,model:t.model??"",...t.resolvedModel?{resolvedModel:t.resolvedModel}:{},...t.resolvedEffort?{resolvedEffort:t.resolvedEffort}:{},effort:t.effort??"",permissionMode:t.permissionMode??"",onPatch:y}):null})})})}),_&&h.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),s()},className:"absolute top-1.5 right-1.5 z-10 p-1 rounded-md bg-bg-100/80 backdrop-blur-sm border border-border opacity-0 group-hover/pane:opacity-100 transition-opacity text-text-400 hover:text-text-100 hover:bg-bg-200","aria-label":"close pane","data-testid":`session-pane-close-${t.sessionId}`,children:h.jsx(Ir,{className:"w-3.5 h-3.5"})})]})}function lae({api:e,session:t,liveGitBranch:n,liveWorktreeRoot:r,onNewSession:i,onTurnEnd:s,onOpenConfig:o,onFork:a,onQuickAsk:l,viewerRole:c,configSlot:u,hideHeader:d}){return h.jsx(Qoe,{extras:{session:t,api:e,...n!==void 0?{liveGitBranch:n}:{},...r!==void 0?{liveWorktreeRoot:r}:{},onNewSession:i,onTurnEnd:s,onOpenConfig:o,...a?{onFork:f=>{a(f)}}:{},...l?{onQuickAsk:f=>{l(f)}}:{},...c?{viewerRole:c}:{},...u?{configSlot:u}:{},...d?{hideHeader:d}:{}}})}function cae({personas:e,sessions:t,api:n,selfPrincipalId:r,selectedPersonaId:i,selectedSessionId:s,selectedSession:o,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,onCloseSession:f}){return h.jsxs("div",{className:"flex h-screen min-h-0 bg-bg-50","data-testid":"guest-share-page",children:[h.jsx("aside",{className:"w-[280px] shrink-0 overflow-y-auto border-r border-border bg-bg-50",children:h.jsx(VW,{personas:e,sessions:t,activePersonaId:i,activeSessionId:s,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,showCopyResume:!1,treatSessionsAsRoots:!0,...r?{ownerPrincipalId:r}:{},isPersonaExpanded:()=>!0})}),h.jsx("main",{className:"flex-1 min-w-0 min-h-0 flex",children:o?h.jsx(aae,{api:n,session:o,focused:!0,totalPanes:1,onFocus:()=>{},onClose:f,onNewSession:()=>{},onOpenConfig:()=>{},viewerRole:"guest"}):h.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-xs text-text-400","data-testid":"guest-share-empty",children:"选择左侧 persona 开始对话"})})]})}function uae(){const e=_i(),t=g.useMemo(()=>new Y_(e),[e]),n=t$(e),{sessions:r,refresh:i}=n$(n),{personas:s}=pI(),o=l$(),a=g.useMemo(()=>{const S=window.location.pathname.match(/^\/s\/([^/]+)/);return S?decodeURIComponent(S[1]):null},[]),l=g.useMemo(()=>r.filter(S=>!S.ephemeral&&S.larkChatId==null),[r]),c=g.useMemo(()=>a?s.filter(S=>S.personaId===a):s,[s,a]),[u,d]=g.useState(null),[f,p]=g.useState(null),[m,v]=g.useState(null);g.useEffect(()=>{let S=!1;return e.request("whoami",{}).then(C=>{S||d(C.capability.id)}).catch(()=>{}),()=>{S=!0}},[e]),g.useEffect(()=>{a&&p(a)},[a]);const w=g.useCallback(async(S,C)=>{const k=await t.sessionCreate({ownerPersonaId:S,...C.trim()?{label:C.trim()}:{}});await i(),p(S),v(k.sessionId)},[t,i]),x=g.useCallback(async S=>{await t.sessionDelete(S),await i(),v(C=>C===S?null:C)},[t,i]),_=g.useCallback(async(S,C)=>{await t.sessionUpdate(S,{label:C.label}),await i()},[t,i]),y=g.useMemo(()=>l.find(S=>S.sessionId===m)??null,[l,m]);return h.jsx(X_.Provider,{value:o,children:h.jsx(cae,{personas:c,sessions:l,api:t,selfPrincipalId:u,selectedPersonaId:f,selectedSessionId:m,selectedSession:y,onSelectPersona:p,onSelectSession:v,onCreateSession:(S,C)=>void w(S,C),onDeleteSession:S=>void x(S),onEditSession:(S,C)=>void _(S,C),onCloseSession:()=>v(null)})})}const f2="https://app.ttcadvisory.com";function dae({onAuthed:e}){const[t,n]=g.useState(!1),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>()=>{s.current&&window.removeEventListener("message",s.current)},[]);const o=g.useCallback(()=>{s.current&&(window.removeEventListener("message",s.current),s.current=null),n(!0),i(null);const a=window.location.origin,l=`${f2}/auth/authorize?callback_url=${encodeURIComponent(a)}&auto=1`,c=async d=>{if(d.origin!==f2)return;const f=d.data;if((f==null?void 0:f.type)==="AUTH_CANCEL"){u(),n(!1);return}if(!((f==null?void 0:f.type)!=="AUTH_SUCCESS"||!f.token)){u();try{const p=await fetch(`${window.location.origin}/share/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ttcToken:f.token})});if(!p.ok){const v=await p.json().catch(()=>({}));throw new Error(v.code??`exchange failed (${p.status})`)}const m=await p.json();if(!m.visitorToken)throw new Error("no visitorToken in response");e(m.visitorToken)}catch(p){i(p instanceof Error?p.message:String(p)),n(!1)}}},u=()=>{window.removeEventListener("message",c),s.current=null};s.current=d=>void c(d),window.addEventListener("message",s.current),window.open(l,"ttc-login","width=480,height=640")},[e]);return h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 font-sans text-text-100","data-testid":"guest-login",children:h.jsxs("div",{className:"flex w-full max-w-xs flex-col gap-3 rounded-lg border border-border bg-bg-100 px-5 py-6",children:[h.jsx("h1",{className:"text-base font-semibold",children:"登录后进入分享"}),h.jsx("p",{className:"text-[11px] leading-snug text-text-400",children:"使用飞书账号登录,即可在浏览器里与分享给你的 persona 交互,无需安装。"}),r?h.jsxs("p",{className:"text-[11px] leading-snug text-error","data-testid":"guest-login-error",children:["登录失败:",r]}):null,h.jsx("button",{type:"button",disabled:t,onClick:()=>o(),"data-testid":"guest-login-button",className:"w-full rounded border border-border bg-bg-50 px-2 py-1.5 text-xs text-text-200 transition-colors hover:bg-text-100/5 hover:text-text-100 disabled:opacity-50",children:t?"请在弹窗中完成授权…":"飞书登录"})]})})}const Ax="clawd-visitor:token";function hae(e,t){const r=`${e.protocol==="https:"?"wss:":"ws:"}//${e.host}`;return t!=null&&t.devPath?`${r}${t.devPath}`:r}function fae(){return{async getUrl(e){const t=localStorage.getItem(Ax);if(!t)throw new Error("NO_VISITOR_TOKEN");const n=hae(window.location,{});return await sI(e).upsert({id:"guest",name:"访客",mode:"remote",url:n,token:t}),{url:n}}}}function pae(e){const t=n=>{document.documentElement.classList.toggle("dark",n==="dark")};return t(e.theme.mode),e.onThemeChange(n=>t(n.mode))}function mae(){const e=_i(),t=g.useMemo(()=>e$(e),[e]);return h.jsx(Lz,{cache:t.cache,children:h.jsx(Bz,{children:h.jsx(uae,{})})})}function gae({host:e}){const[t]=g.useState(()=>localStorage.getItem(Ax)),[n,r]=g.useState(!1),[i,s]=g.useState(null);return g.useEffect(()=>pae(e),[e]),g.useEffect(()=>{if(!t)return;let o=!1;return fae().getUrl(e).then(()=>{o||r(!0)}).catch(a=>{o||s(a instanceof Error?a.message:String(a))}),()=>{o=!0}},[e,t]),t?h.jsx(Fb,{host:e,children:h.jsx(yw,{children:i?h.jsxs("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-center text-xs text-error","data-testid":"guest-share-connect-error",children:["连接失败:",i]}):n?h.jsx(Mz,{host:e,children:h.jsx(mae,{})}):h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-xs text-text-400",children:"正在连接…"})})}):h.jsx(Fb,{host:e,children:h.jsx(yw,{children:h.jsx(dae,{onAuthed:o=>{localStorage.setItem(Ax,o),window.location.reload()}})})})}function vae({filePath:e,oldString:t,newString:n,content:r}){const i=g.useMemo(()=>r!=null?r.split(/\r?\n/).map(s=>({type:"add",text:s})):xae(t??"",n??""),[t,n,r]);return h.jsxs("div",{"data-testid":"inline-diff",className:"min-w-0 max-w-full rounded-lg border border-bg-300/60 bg-bg-50 overflow-hidden text-[12px] font-mono",children:[h.jsx("div",{className:"flex min-w-0 items-center gap-2 px-3 py-1.5 border-b border-bg-300/40 bg-bg-100/30",children:h.jsx("span",{className:"min-w-0 text-text-400 truncate",title:e,children:e})}),h.jsx("div",{className:"max-h-[320px] max-w-full overflow-auto",children:i.map((s,o)=>h.jsxs("div",{"data-testid":`diff-line-${s.type}`,className:re("flex min-w-max gap-2 px-3 py-0.5 whitespace-pre",s.type==="add"?"bg-success/10 text-success":s.type==="remove"?"bg-error/10 text-error":"text-text-300"),children:[h.jsx("span",{className:"w-3 shrink-0 select-none opacity-60",children:s.type==="add"?"+":s.type==="remove"?"-":" "}),h.jsx("span",{className:"flex-1",children:s.text||" "})]},o))})]})}function xae(e,t){const n=e.split(/\r?\n/),r=t.split(/\r?\n/),i=n.length,s=r.length,o=Array.from({length:i+1},()=>new Array(s+1).fill(0));for(let u=i-1;u>=0;u--)for(let d=s-1;d>=0;d--)o[u][d]=n[u]===r[d]?o[u+1][d+1]+1:Math.max(o[u+1][d],o[u][d+1]);const a=[];let l=0,c=0;for(;l<i&&c<s;)n[l]===r[c]?(a.push({type:"equal",text:n[l]}),l++,c++):o[l+1][c]>=o[l][c+1]?(a.push({type:"remove",text:n[l]}),l++):(a.push({type:"add",text:r[c]}),c++);for(;l<i;)a.push({type:"remove",text:n[l++]});for(;c<s;)a.push({type:"add",text:r[c++]});return a}function _ae({items:e}){return e.length===0?null:h.jsxs("div",{"data-testid":"todo-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-1.5",children:"Todos"}),h.jsx("ul",{className:"flex flex-col gap-1",children:e.map((t,n)=>{const r=t.status==="in_progress"&&t.activeForm||t.content;return h.jsxs("li",{"data-testid":`todo-item-${t.status}`,className:"flex items-start gap-2",children:[h.jsx(yae,{status:t.status}),h.jsx("span",{className:re("flex-1 leading-snug",t.status==="completed"?"text-text-400 line-through":t.status==="in_progress"?"text-text-100 font-medium":"text-text-200"),children:r})]},n)})})]})}function yae({status:e}){return e==="completed"?h.jsx(cp,{className:"w-3.5 h-3.5 text-success mt-0.5 shrink-0"}):e==="in_progress"?h.jsx(Ln,{className:"w-3.5 h-3.5 text-warning mt-0.5 shrink-0 animate-spin"}):h.jsx(_I,{className:"w-3.5 h-3.5 text-text-400 mt-0.5 shrink-0"})}function bae(e){const t=e??{};return Array.isArray(t.todos)?t.todos.map(n=>{if(!n||typeof n!="object")return null;const r=n,i=typeof r.content=="string"?r.content:"",s=r.status==="pending"||r.status==="in_progress"||r.status==="completed"?r.status:"pending",o=typeof r.activeForm=="string"?r.activeForm:void 0;return{content:i,status:s,activeForm:o}}).filter(n=>n!==null):[]}function wae({description:e,prompt:t,subagentType:n}){return h.jsxs("div",{"data-testid":"task-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsxs("div",{className:"flex items-center gap-2 text-text-200 font-medium",children:[h.jsx(lp,{className:"w-3.5 h-3.5 text-accent shrink-0"}),h.jsx("span",{className:"truncate",children:e||"subagent task"}),n?h.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded-md text-[10px] font-mono bg-accent/10 text-accent",children:n}):null]}),t?h.jsx("div",{className:"mt-1 text-[12px] text-text-400 leading-snug line-clamp-3",children:t}):null]})}function Sae(e){const t=e??{};return{description:typeof t.description=="string"?t.description:"",prompt:typeof t.prompt=="string"?t.prompt:void 0,subagentType:typeof t.subagent_type=="string"?t.subagent_type:void 0}}const kae={render:({input:e})=>Qe.createElement(_ae,{items:bae(e)})},Cae={render:({input:e})=>{const{description:t,prompt:n,subagentType:r}=Sae(e);return Qe.createElement(wae,{description:t,prompt:n,subagentType:r})}},x3={render:({input:e,output:t,error:n,pending:r,fileScope:i,onShareFile:s,onOpenInTab:o,onPreviewMarkdown:a})=>{const l=Nae(e),c=l?Qe.createElement(vae,{filePath:l.filePath,oldString:l.oldString,newString:l.newString,content:l.content}):void 0;return Qe.createElement(CM,{tool:Eae(e),input:e,output:t,error:n,pending:r,expandedBody:c,...i?{fileScope:i}:{},...s?{onShareFile:s}:{},...o?{onOpenInTab:o}:{},...a?{onPreviewMarkdown:a}:{}})}};function Eae(e){const t=e??{};return"content"in t&&t.content!==void 0?"Write":("old_string"in t&&t.old_string!==void 0,"Edit")}function Nae(e){const t=e??{},n=typeof t.file_path=="string"?t.file_path:null;if(!n)return null;const r=typeof t.old_string=="string"?t.old_string:void 0,i=typeof t.new_string=="string"?t.new_string:void 0,s=typeof t.content=="string"?t.content:void 0;return r==null&&i==null&&s==null?null:{filePath:n,oldString:r,newString:i,content:s}}Nl.register("claude","TodoWrite",kae);Nl.register("claude","Task",Cae);Nl.register("claude","Edit",x3);Nl.register("claude","Write",x3);const _3=document.getElementById("root");if(!_3)throw new Error("guest-main: #root not found");const Tae=Jj({});jg.createRoot(_3).render(h.jsx(Qe.StrictMode,{children:h.jsx(gae,{host:Tae})}));
589
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return g.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Bse="DialogDescriptionWarning",zse=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${c3(Bse).contentName}}.`;return g.useEffect(()=>{var s;const i=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},$se=XA,Fse=JA,u3=e3,d3=t3,h3=r3,f3=s3,Hse=a3;const w1=$se,Use=Fse,p3=g.forwardRef(({className:e,...t},n)=>h.jsx(u3,{ref:n,className:re("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",e),...t}));p3.displayName=u3.displayName;const Vp=g.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(Use,{children:[h.jsx(p3,{}),h.jsxs(d3,{ref:r,className:re("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2","gap-4 rounded-lg border border-border bg-elevated p-6 shadow-lg",e),...n,children:[t,h.jsxs(Hse,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-accent",children:[h.jsx(Ir,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Vp.displayName=d3.displayName;const qp=({className:e,...t})=>h.jsx("div",{className:re("flex flex-col space-y-1.5 text-left",e),...t});qp.displayName="DialogHeader";const S1=({className:e,...t})=>h.jsx("div",{className:re("flex flex-row justify-end gap-2",e),...t});S1.displayName="DialogFooter";const Kp=g.forwardRef(({className:e,...t},n)=>h.jsx(h3,{ref:n,className:re("text-lg font-semibold leading-none text-text-100",e),...t}));Kp.displayName=h3.displayName;const m3=g.forwardRef(({className:e,...t},n)=>h.jsx(f3,{ref:n,className:re("text-sm text-text-300",e),...t}));m3.displayName=f3.displayName;function Wse({persona:e,open:t,onClose:n,onDelete:r,embedded:i,onLoadPersonality:s,onSavePersonality:o,onLoadPersonalityLocal:a,onSavePersonalityLocal:l,hasPersonalityLocal:c=!1,onDirtyChange:u,initialPersonality:d,onShareCapability:f,readOnly:p=!1,larkBot:m}){const[v,w]=g.useState(!1),[x,_]=g.useState(!1),y=v||x,S=Qe.useRef(u);g.useEffect(()=>{S.current=u}),g.useEffect(()=>{var k;(k=S.current)==null||k.call(S,y)},[y]);const C=()=>{y&&!window.confirm("修改未保存,确定关闭?")||n()};return t?h.jsxs(h.Fragment,{children:[!i&&h.jsx("div",{className:"absolute inset-0 z-30 bg-black/30",onClick:C,"aria-hidden":"true"}),h.jsxs("aside",{className:i?"flex h-full w-full flex-col bg-bg-0":"absolute right-0 top-0 z-40 flex h-full w-[420px] flex-col bg-bg-0 border-l border-border shadow-xl","data-testid":"persona-settings-drawer",children:[h.jsxs("header",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h.jsx(O8,{className:"h-4 w-4 text-text-300"}),h.jsx("span",{className:"text-[13px] font-medium text-text-100 truncate",children:"Persona 设置"})]}),h.jsx("button",{type:"button",onClick:C,"aria-label":"关闭",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-text-100",children:h.jsx(Ir,{className:"h-4 w-4"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-6 flex flex-col gap-4",children:[h.jsxs("header",{className:"flex items-start justify-between gap-3",children:[h.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h2",{className:"text-lg font-semibold text-text-100 truncate",children:e.label}),e.public?h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-bg-200 px-1.5 py-0.5 text-[10px] text-text-200",children:[h.jsx(r8,{className:"h-3 w-3"})," 公开"]}):h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-error-dim px-1.5 py-0.5 text-[10px] text-error",children:[h.jsx(t8,{className:"h-3 w-3"})," 已关闭"]})]}),h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate","data-testid":"persona-id-subtitle",children:e.personaId})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[f?h.jsxs("button",{type:"button",onClick:f,"aria-label":"分享给他人",title:"分享给他人",className:"inline-flex items-center gap-1 rounded-sm px-2 py-1.5 text-xs text-text-200 hover:bg-bg-200 hover:text-text-100",children:[h.jsx(Z_,{className:"h-3.5 w-3.5"}),"分享"]}):null,r?h.jsx("button",{type:"button",onClick:r,"aria-label":"删除 persona",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-error",children:h.jsx(J_,{className:"h-4 w-4"})}):null]})]}),h.jsx("hr",{className:"border-border"}),m?h.jsxs(h.Fragment,{children:[h.jsx(Kse,{...m}),h.jsx("hr",{className:"border-border"})]}):null,s?h.jsxs(h.Fragment,{children:[h.jsx(a2,{onLoad:s,...o&&!e.personalityManaged?{onSave:o}:{},onDirtyChange:w,initialPersonality:d,readOnly:p||!!e.personalityManaged,title:e.personalityManaged?"内置人格":"人格 (Personality)",hint:e.personalityManaged?p?"这个 persona 自带的人格,随 clawd 版本更新。":"这个 persona 自带的人格,随 clawd 版本更新——在这里改不会保留,要加自己的规则请写下面的「你的补充」。":void 0,testIdPrefix:"persona-personality"}),(e.personalityManaged||c)&&a?h.jsx(a2,{onLoad:a,...l?{onSave:l}:{},onDirtyChange:_,readOnly:p,title:p?"补充设定":"你的补充",hint:p?"这个 persona 的补充设定,由它的主人维护。与内置人格叠加生效。":"写入 <persona-dir>/.clawd/personality.local.md,不会被更新覆盖。与内置人格叠加生效,冲突时以你写的为准;对 owner 和访客会话都生效,要区分对象请在正文里写明。只对新启动的 sub-session 生效。",placeholder:"例:回答一律先给结论,再展开。",testIdPrefix:"persona-personality-local"}):null,h.jsx("hr",{className:"border-border"})]}):null,h.jsx(Gse,{settings:e.sandboxSettings??null}),h.jsx("hr",{className:"border-border"}),h.jsx(Yse,{skills:e.skills??[]}),h.jsx("hr",{className:"border-border"}),h.jsx(Xse,{plugins:e.plugins??[]})]})]})]}):null}function o2({qrUrl:e,busy:t,onCancel:n,title:r="扫码关联飞书 Bot",hint:i="用手机飞书扫码,按页面提示创建应用。确认后自动完成关联。"}){const[s,o]=g.useState(null);return g.useEffect(()=>{let a=!1;return $u.toDataURL(e,{width:240,margin:1}).then(l=>{a||o(l)}).catch(()=>{a||o(null)}),()=>{a=!0}},[e]),h.jsx(w1,{open:!0,onOpenChange:a=>a||n==null?void 0:n(),children:h.jsxs(Vp,{className:"max-w-xs","data-testid":"lark-bot-qr-dialog",onInteractOutside:a=>a.preventDefault(),onEscapeKeyDown:a=>a.preventDefault(),children:[h.jsx(qp,{children:h.jsx(Kp,{children:r})}),h.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s?h.jsx("img",{src:s,alt:"飞书扫码创建应用二维码",className:"h-60 w-60 rounded bg-white p-2","data-testid":"lark-bot-qr-img"}):h.jsx("div",{className:"flex h-60 w-60 items-center justify-center text-[12px] text-text-400",children:"二维码生成中…"}),h.jsx("span",{className:"text-center text-[12px] text-text-300",children:i}),n?h.jsx("button",{type:"button",disabled:t,onClick:n,className:"rounded border border-border px-3 py-1.5 text-[12px] text-text-300 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-cancel",children:"取消"}):null]})]})})}const Vse={expired:"二维码已过期,请重新扫码。",cancelled:"已取消。",access_denied:"你在飞书上取消了本次授权。",lark_protocol_error:"飞书返回了未预期的响应,请重试。",cloud_unreachable:"云端暂时不可达,请稍后重试。",internal_error:"关联失败。若飞书中已创建应用,可在开发者后台删除后重试,或改用手动绑定填入其凭证。"},qse=new Set(["expired","access_denied","lark_protocol_error","cloud_unreachable","internal_error"]);function Kse({status:e,onProvision:t,onCancelProvision:n,onBindManual:r,onUnbind:i,onUpgrade:s}){const[o,a]=g.useState(!1),[l,c]=g.useState(null),[u,d]=g.useState(""),[f,p]=g.useState(""),[m,v]=g.useState(null),w=k=>{k&&(a(!0),c(null),k().catch(N=>c(N instanceof Error?N.message:String(N))).finally(()=>a(!1)))},x=()=>{v(null),w(t)},_=!o&&!!u&&!!f,y=()=>{!_||!r||w(()=>r({appId:u,appSecret:f}))},S=Ru(y),C=h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx(lp,{className:"h-3.5 w-3.5 text-text-400","aria-hidden":!0}),h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"飞书 Bot"})]});return e?h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[C,e.state==="unbound"||e.state==="provisioning"?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"关联一个飞书 bot 后,这个 persona 就是它:拉进群后群成员 @ 它提问、或直接私聊它, 推理跑在你本机,回复自动发回去。"}),t?h.jsx("button",{type:"button",disabled:o||e.state==="provisioning",onClick:x,className:"self-start rounded border border-border bg-bg-200 px-3 py-1.5 text-[12px] font-medium text-text-100 hover:bg-bg-300 disabled:opacity-50","data-testid":"lark-bot-provision",children:e.state==="provisioning"?"等待扫码…":"扫码关联飞书 Bot"}):null,e.state==="unbound"&&e.errorReason&&!m?h.jsxs("div",{className:"flex flex-col gap-1.5 rounded border border-error bg-error-dim px-2 py-1.5","data-testid":"lark-bot-provision-error",children:[h.jsx("span",{className:"text-[11px] text-error",children:Vse[e.errorReason]}),h.jsxs("div",{className:"flex gap-1.5",children:[qse.has(e.errorReason)&&t?h.jsx("button",{type:"button",disabled:o,onClick:x,className:"rounded border border-border px-2 py-1 text-[11px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-retry",children:"重新扫码"}):null,h.jsx("button",{type:"button",onClick:()=>v(e.errorReason??null),className:"rounded border border-border px-2 py-1 text-[11px] text-text-300 hover:bg-bg-200","data-testid":"lark-bot-provision-error-dismiss",children:"知道了"})]})]}):null,e.state==="provisioning"&&e.qrUrl?h.jsx(o2,{qrUrl:e.qrUrl,busy:o,onCancel:n?()=>w(n):void 0}):null,r&&e.state==="unbound"?h.jsxs("details",{"data-testid":"lark-bot-manual-details",children:[h.jsx("summary",{className:"cursor-pointer text-[11px] text-text-400 hover:text-text-300",children:"已有飞书应用?手动填入凭证"}),h.jsxs("div",{className:"mt-1.5 flex flex-col gap-1.5","data-testid":"lark-bot-manual-form",children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"先在飞书开放平台(open.feishu.cn)创建企业自建应用并启用机器人能力,再填入凭证:"}),h.jsx("input",{value:u,onChange:k=>d(k.target.value),...S,placeholder:"App ID(cli_ 开头)",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-appid"}),h.jsx("input",{value:f,onChange:k=>p(k.target.value),...S,type:"password",placeholder:"App Secret",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-secret"}),h.jsx("button",{type:"button",disabled:!_,onClick:y,className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-manual-submit",children:o?"绑定中…":"绑定"})]})]}):null]}):null,e.state==="bound"||e.state==="broken"?h.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.state==="bound"&&e.needsUpgrade?h.jsxs("div",{className:"flex flex-col gap-1.5 rounded border border-warning/30 bg-warning-dim px-2 py-1.5","data-testid":"lark-bot-upgrade-notice",children:[h.jsx("span",{className:"text-[11px] text-warning",children:"这个 bot 的权限配置有更新,扫码重新授权后生效。在此之前,新增能力对它不起作用。"}),s?h.jsx("button",{type:"button",disabled:o,onClick:()=>w(s),className:"self-start rounded border border-warning/30 bg-warning/10 px-2 py-1 text-[11px] text-warning hover:bg-warning/20 disabled:opacity-50","data-testid":"lark-bot-upgrade",children:"更新授权"}):null]}):null,e.state==="bound"&&e.upgradeQrUrl?h.jsx(o2,{qrUrl:e.upgradeQrUrl,busy:o,onCancel:n?()=>w(n):void 0,title:"扫码更新授权",hint:"用手机飞书扫码,确认页会列出将要添加的权限。期间 bot 照常服务,不会中断。"}):null,e.state==="broken"?h.jsxs("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-broken",children:["Bot 凭证失效:",e.brokenReason??"未知原因","。请解绑后重新填入有效凭证绑定。"]}):null,h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-200",children:[h.jsx("span",{className:"font-medium text-text-100",children:e.botName??"未命名 bot"}),e.appId?h.jsx("span",{className:"text-[11px] text-text-400",children:e.appId}):null]}),h.jsx("span",{className:"text-[11px] text-text-400",children:"把 bot 拉进任意飞书群,群成员 @ 它即可提问。"}),e.groups.length>0?h.jsx("ul",{className:"flex flex-col gap-0.5","data-testid":"lark-bot-groups",children:e.groups.map(k=>h.jsxs("li",{className:"text-[11px] text-text-300 truncate",children:["· ",k.chatName??k.chatId]},k.chatId))}):h.jsx("span",{className:"text-[11px] text-text-400","data-testid":"lark-bot-groups-empty",children:"还没有服务中的群。"}),i?h.jsx("button",{type:"button",disabled:o,onClick:()=>w(i),className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-error hover:bg-error-dim disabled:opacity-50","data-testid":"lark-bot-unbind",children:"解绑"}):null]}):null,l?h.jsx("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-error",children:l}):null]}):h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[C,h.jsx("span",{className:"text-[11px] text-text-400",children:"状态加载中…"})]})}function Gse({settings:e}){var t,n,r,i,s,o,a,l,c,u,d,f,p;return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-sandbox-setting-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Sandbox Setting"}),h.jsx("span",{className:"text-[11px] text-text-400",children:"约束此 persona 的沙箱权限(只读,需通过文件修改)。"})]}),e==null?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-sandbox-setting-empty",children:"暂无 sandbox 配置"}):h.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md border border-border bg-bg-100 px-3 py-2",children:[h.jsx(zd,{label:"权限默认模式",value:((t=e.permissions)==null?void 0:t.defaultMode)??"—"}),h.jsx(zd,{label:"沙箱启用",value:Mg((n=e.sandbox)==null?void 0:n.enabled)}),h.jsx(zd,{label:"沙箱内自动放行 Bash",value:Mg((r=e.sandbox)==null?void 0:r.autoAllowBashIfSandboxed)}),h.jsx(zd,{label:"允许非沙箱命令",value:Mg((i=e.sandbox)==null?void 0:i.allowUnsandboxedCommands)}),h.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border pt-1.5",children:[h.jsx(Ql,{label:"沙箱外命令",paths:(s=e.sandbox)==null?void 0:s.excludedCommands}),h.jsx(Ql,{label:"允许读取",paths:(a=(o=e.sandbox)==null?void 0:o.filesystem)==null?void 0:a.allowRead}),h.jsx(Ql,{label:"拒绝读取",paths:(c=(l=e.sandbox)==null?void 0:l.filesystem)==null?void 0:c.denyRead}),h.jsx(Ql,{label:"允许写入",paths:(d=(u=e.sandbox)==null?void 0:u.filesystem)==null?void 0:d.allowWrite}),h.jsx(Ql,{label:"拒绝写入",paths:(p=(f=e.sandbox)==null?void 0:f.filesystem)==null?void 0:p.denyWrite})]})]})]})}function Mg(e){return e===!0?"是":e===!1?"否":"—"}function zd({label:e,value:t}){return h.jsxs("div",{className:"flex items-center justify-between gap-3 text-[12px]",children:[h.jsx("span",{className:"text-text-300",children:e}),h.jsx("span",{className:"font-mono text-text-100",children:t})]})}function Ql({label:e,paths:t}){const n=!t||t.length===0;return h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[11px] text-text-300",children:e}),n?h.jsx("span",{className:"text-[11px] text-text-400",children:"—"}):h.jsx("div",{className:"flex flex-wrap gap-1",children:t.map((r,i)=>h.jsx("span",{className:"rounded-sm border border-border bg-bg-0 px-1.5 py-0.5 font-mono text-[11px] text-text-200",children:r},`${e}-${i}-${r}`))})]})}function Yse({skills:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-skills-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Persona Skills"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 私有 skills(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/skills/"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-skills-empty",children:"暂无 skills"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsxs("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-skill-row",children:[h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.name}),t.description?h.jsx("span",{className:"text-[12px] text-text-300",children:t.description}):h.jsx("span",{className:"text-[11px] text-text-400 italic",children:"无描述"})]},t.name))})]})}function Xse({plugins:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-plugins-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Enabled Plugins"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 已启用的插件(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/settings.json"})," ","的 ",h.jsx("code",{className:"font-mono",children:"enabledPlugins"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-plugins-empty",children:"暂无启用插件"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsx("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-plugin-row",children:h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.id})},t.id))})]})}function a2({onLoad:e,onSave:t,onDirtyChange:n,initialPersonality:r,readOnly:i=!1,title:s,hint:o,placeholder:a,testIdPrefix:l}){const c=r!==void 0,[u,d]=g.useState(c),[f,p]=g.useState(c?r:""),[m,v]=g.useState(c?r:""),[w,x]=g.useState(null),[_,y]=g.useState(!1),[S,C]=g.useState(null),k=Qe.useRef(e),N=Qe.useRef(t),T=Qe.useRef(n);Qe.useEffect(()=>{k.current=e,N.current=t,T.current=n});const O=Qe.useCallback(()=>{d(!1),x(null),k.current().then(M=>{p(M),v(M),d(!0)}).catch(M=>{x(M instanceof Error?M.message:String(M))})},[]);Qe.useEffect(()=>{c||O()},[c,O]);const P=!i&&u&&m!==f;Qe.useEffect(()=>{i||T.current(P)},[P,i]);const D=()=>{N.current&&(y(!0),C(null),N.current(m).then(()=>{p(m),y(!1)}).catch(M=>{C(M instanceof Error?M.message:String(M)),y(!1)}))},R=()=>{v(f),C(null)},A=Ru(()=>{!P||_||D()},()=>{!P||_||R()});return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":`${l}-section`,children:[h.jsx("span",{className:"text-[12px] font-medium text-text-200",children:s}),w?h.jsxs("div",{"data-testid":`${l}-load-error`,className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error flex items-center justify-between gap-2",children:[h.jsxs("span",{children:["加载失败:",w]}),h.jsx("button",{type:"button",onClick:O,className:"rounded-sm border border-error px-2 py-0.5 text-[11px] hover:bg-error/10",children:"重试"})]}):null,S?h.jsxs("div",{"data-testid":`${l}-save-error`,className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error",children:["保存失败:",S]}):null,h.jsx("textarea",{"data-testid":`${l}-textarea`,value:m,onChange:M=>v(M.target.value),...A,readOnly:i,disabled:!i&&(!u||_),placeholder:u?a??"":"加载中…",rows:8,className:"min-h-[8rem] max-h-[18rem] resize-y rounded-md border border-border bg-bg-100 px-2 py-1.5 font-mono text-[11px] text-text-100 disabled:opacity-60"}),o?h.jsx("p",{className:"text-[10px] text-text-400",children:o}):i?null:h.jsxs("p",{className:"text-[10px] text-text-400",children:["写入到 ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/CLAUDE.md"}),"。 修改只对新启动的 sub-session 生效。"]}),u&&P?h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:R,disabled:_,className:"rounded-sm border border-border px-2 py-1 text-[12px] text-text-200 hover:bg-bg-200 disabled:opacity-60",children:"放弃"}),h.jsx("button",{type:"button",onClick:D,disabled:_,"data-testid":`${l}-save-btn`,className:"rounded-sm bg-accent-dim px-2 py-1 text-[12px] text-text-100 hover:opacity-90 disabled:opacity-60",children:_?"保存中…":"保存"})]}):null]})}const Qse={state:"unbound",groups:[]};function Zse(e,t){const[n,r]=g.useState(null);g.useEffect(()=>{if(!e)return;let c=!1;r(null);const u=async()=>{try{const p=await e.request("larkBot:status",{personaId:t});c||r(p)}catch{c||r(Qse)}};u();const d=e.on("larkBot:state",p=>{const m=p;if(m.personaId!==t)return;const{personaId:v,...w}=m;r(w)}),f=e.on("daemon:connected",()=>{u()});return()=>{c=!0,d(),f()}},[e,t]);const i=g.useCallback(async()=>{e&&await e.request("larkBot:provision",{personaId:t})},[e,t]),s=g.useCallback(async()=>{e&&await e.request("larkBot:provisionCancel",{personaId:t})},[e,t]),o=g.useCallback(async c=>{e&&await e.request("larkBot:bindManual",{personaId:t,...c})},[e,t]),a=g.useCallback(async()=>{e&&await e.request("larkBot:upgrade",{personaId:t})},[e,t]),l=g.useCallback(async()=>{e&&await e.request("larkBot:unbind",{personaId:t})},[e,t]);return{status:n,provision:i,cancelProvision:s,bindManual:o,unbind:l,upgrade:a}}function Jse(e,t="owner"){var k;const{persona:n}=mI(e),r=r$(e),i=i$(),s=s$(),{httpBaseUrl:o}=ap(),a=_i(),l=Zse(t==="guest"?null:a,e),{capabilities:c}=f1((n==null?void 0:n.tool)??"claude"),u=g.useMemo(()=>!(n!=null&&n.public)||!o||/^https?:\/\/(127\.0\.0\.1|localhost|0\.0\.0\.0|\[?::1\]?)([:/]|$)/i.test(o)?null:`${o}/s/${e}`,[n==null?void 0:n.public,o,e]),d=g.useCallback((N,T)=>{i(e,T).catch(O=>{Me("persona",`${N} failed`,O)})},[i,e]),f=g.useCallback(N=>d("togglePublic",{public:N}),[d]),p=g.useCallback(async N=>{await i(e,{codexSandbox:{network:N}}),await r.refresh()},[i,e,r]),m=g.useCallback(N=>d("changeTool",{tool:N}),[d]),v=g.useCallback(N=>d("changeModel",{model:N}),[d]),w=g.useCallback(N=>d("changeEffort",{effort:N}),[d]),x=g.useCallback(()=>!n||!confirm(`删除 persona "${n.label}"?`)?!1:(s(e).catch(N=>{Me("persona","delete failed",N)}),!0),[n,s,e]),_=g.useCallback(async()=>r.loaded?r.personality:(await r.refresh()).personality,[r]),y=g.useCallback(async N=>{await i(e,{personality:N}),await r.refresh()},[i,e,r]),S=g.useCallback(async()=>r.loaded?r.personalityLocal:(await r.refresh()).personalityLocal,[r]),C=g.useCallback(async N=>{await i(e,{personalityLocal:N}),await r.refresh()},[i,e,r]);return{persona:n,detail:r,models:(c==null?void 0:c.models)??[],configSchema:(c==null?void 0:c.configSchema)??[],larkBot:l,guestShareUrl:u,changeTool:m,changeModel:v,changeEffort:w,togglePublic:f,guestNetwork:((k=r.codexSandbox)==null?void 0:k.network)??!1,toggleGuestNetwork:p,remove:x,loadPersonality:_,savePersonality:y,loadPersonalityLocal:S,savePersonalityLocal:C}}function eoe({personaId:e,open:t,onClose:n,api:r,embedded:i,onDirtyChange:s,onShareCapability:o,viewerRole:a="owner"}){const l=Jse(e,a),{persona:c,detail:u}=l,d=g.useCallback(()=>{l.remove()&&n()},[l,n]);if(!c)return null;const f=a==="guest";return h.jsx(Wse,{embedded:i,persona:{...c,skills:u.skills,plugins:u.plugins,sandboxSettings:u.sandboxSettings,personalityManaged:u.personalityManaged},open:t,onClose:n,onLoadPersonality:l.loadPersonality,onLoadPersonalityLocal:l.loadPersonalityLocal,hasPersonalityLocal:u.personalityLocal!=="",onDirtyChange:s,readOnly:f,...f?{}:{onTogglePublic:l.togglePublic,guestShareUrl:l.guestShareUrl,onChangeTool:l.changeTool,onChangeModel:l.changeModel,onChangeEffort:l.changeEffort,models:l.models,configSchema:l.configSchema,onDelete:d,onSavePersonality:l.savePersonality,onSavePersonalityLocal:l.savePersonalityLocal,larkBot:{status:l.larkBot.status,onProvision:l.larkBot.provision,onCancelProvision:l.larkBot.cancelProvision,onBindManual:l.larkBot.bindManual,onUnbind:l.larkBot.unbind,onUpgrade:l.larkBot.upgrade},...o?{onShareCapability:o}:{}}})}const toe=new Map,noe=g.createContext(toe);function roe(){const e=g.useContext(noe);return g.useCallback(t=>e.get(t),[e])}function ioe(e){try{const t=new URL(e);return t.protocol==="ws:"?t.protocol="http:":t.protocol==="wss:"&&(t.protocol="https:"),`${t.protocol}//${t.host}`}catch{return e}}function soe(e,t){try{const n=new URL(e),r=new URL(t);return n.protocol=r.protocol,n.host=r.host,n.toString()}catch{return e}}async function k1(e,t,n,r,i){const s=await e.attachmentSignUrl({sessionId:n,relPath:r,...i!==void 0?{ttlSeconds:i}:{}});return soe(s.url,ioe(t.url))}async function l2(e,t,n,r,i=60,s){const o=window.open("about:blank","_blank");try{s&&await s();const a=await k1(e,t,n,r,i);o?o.location.href=a:window.open(a,"_blank")}catch(a){throw o&&o.close(),a}}async function ooe(e){var t;try{if((t=navigator.clipboard)!=null&&t.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.setAttribute("readonly",""),document.body.appendChild(n),n.select();const r=document.execCommand("copy");return document.body.removeChild(n),r}catch{return!1}}const aoe={...Fs,h1:({node:e,...t})=>h.jsx("h1",{...t,className:"mt-4 mb-3 text-[18px] font-semibold leading-tight text-text-100"}),h2:({node:e,...t})=>h.jsx("h2",{...t,className:"mt-4 mb-2 text-[16px] font-semibold leading-tight text-text-100"}),h3:({node:e,...t})=>h.jsx("h3",{...t,className:"mt-3 mb-2 text-[14px] font-semibold leading-tight text-text-100"}),h4:({node:e,...t})=>h.jsx("h4",{...t,className:"mt-3 mb-1 text-[13px] font-semibold text-text-100"}),h5:({node:e,...t})=>h.jsx("h5",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-100"}),h6:({node:e,...t})=>h.jsx("h6",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-300"}),p:({node:e,...t})=>h.jsx("p",{...t,className:"my-2 leading-relaxed"}),ul:({node:e,...t})=>h.jsx("ul",{...t,className:"my-2 list-disc space-y-1 pl-5"}),ol:({node:e,...t})=>h.jsx("ol",{...t,className:"my-2 list-decimal space-y-1 pl-5"}),li:({node:e,...t})=>h.jsx("li",{...t,className:"leading-relaxed"}),blockquote:({node:e,...t})=>h.jsx("blockquote",{...t,className:"my-2 border-l-2 border-border pl-3 italic text-text-300"}),code:({node:e,className:t,children:n,...r})=>t?h.jsx("code",{...r,className:`${t} font-mono text-[12px]`,children:n}):h.jsx("code",{...r,className:"rounded bg-bg-50 px-1 py-0.5 font-mono text-[12px] text-text-100",children:n}),pre:({node:e,...t})=>h.jsx("pre",{...t,className:"my-2 overflow-auto rounded border border-border bg-bg-0 p-3 text-[12px] font-mono text-text-100"}),hr:({node:e,...t})=>h.jsx("hr",{...t,className:"my-3 border-border"}),table:({node:e,...t})=>h.jsx("table",{...t,className:"my-2 w-full border-collapse text-[12px]"}),thead:({node:e,...t})=>h.jsx("thead",{...t,className:"bg-bg-50"}),th:({node:e,...t})=>h.jsx("th",{...t,className:"border border-border px-2 py-1 text-left font-semibold"}),td:({node:e,...t})=>h.jsx("td",{...t,className:"border border-border px-2 py-1"}),strong:({node:e,...t})=>h.jsx("strong",{...t,className:"font-semibold text-text-100"}),em:({node:e,...t})=>h.jsx("em",{...t,className:"italic"})};function loe(e){const t=e.split("/");return t[t.length-1]||e}function g3({relPath:e,loadMarkdown:t,headerRight:n,showTitleBar:r=!1}){const[i,s]=g.useState(null),[o,a]=g.useState(null),[l,c]=g.useState(!1);return g.useEffect(()=>{if(!e)return;let u=!1;return c(!0),a(null),s(null),(async()=>{try{const d=await t(e);if(u)return;s(d)}catch(d){if(u)return;a(d.message||String(d))}finally{u||c(!1)}})(),()=>{u=!0}},[e,t]),h.jsxs("div",{className:"flex flex-col h-full",children:[r&&e?h.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[h.jsx("div",{"data-testid":"md-preview-title",className:"truncate text-[13px] font-medium text-text-100",title:e,children:loe(e)}),h.jsx("div",{className:"flex items-center gap-1",children:n})]}):null,h.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 text-[13px] text-text-100",children:l?h.jsx("div",{"data-testid":"md-preview-loading",className:"text-text-400",children:"Loading…"}):o?h.jsx("div",{"data-testid":"md-preview-error",className:"text-destructive whitespace-pre-wrap",children:o}):i!==null?h.jsx("div",{"data-testid":"md-preview-content",className:"max-w-none",children:h.jsx(nl,{remarkPlugins:[rl],components:aoe,children:i})}):null})]})}function coe({open:e,onOpenChange:t,relPath:n,loadMarkdown:r,onShare:i}){return e?h.jsx("div",{"data-testid":"md-preview-drawer",className:`${n1} z-50 flex w-1/2 max-w-[900px] flex-col border-l border-border bg-elevated shadow-2xl`,children:h.jsx(g3,{relPath:n,loadMarkdown:r,showTitleBar:!0,headerRight:h.jsxs(h.Fragment,{children:[i?h.jsx("button",{type:"button","data-testid":"md-preview-share","aria-label":"Share rendered preview link",onClick:i,className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(c8,{className:"h-4 w-4"})}):null,h.jsx("button",{type:"button","aria-label":"Close preview",onClick:()=>t(!1),className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(Ir,{className:"h-4 w-4"})})]})})}):null}function uoe({left:e,right:t,stage:n,onExpand:r,onCollapse:i}){const s=n==="stopped",[o,a]=g.useState(!1);async function l(){if(!o){a(!0);try{await r()}catch{}finally{a(!1)}}}async function c(){if(!o){a(!0);try{await i()}catch{}finally{a(!1)}}}return h.jsxs("div",{className:"flex h-full w-full min-h-0","data-testid":"two-pane-layout",children:[h.jsxs("div",{className:"relative flex min-w-0 flex-1 flex-col","data-testid":"two-pane-left",children:[s&&h.jsx("button",{type:"button",disabled:o,className:"absolute right-14 top-2 z-10 rounded border border-border bg-elevated px-2 py-1 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50 disabled:cursor-not-allowed",onClick:l,children:o?"启动中…":"展开预览"}),e]}),!s&&h.jsxs("div",{className:"flex w-1/2 min-w-[320px] flex-col border-l border-bg-200","data-testid":"two-pane-right",children:[h.jsx("div",{className:"flex items-center justify-end gap-2 border-b border-bg-200 bg-bg-50 px-2 py-1",children:h.jsx("button",{type:"button",disabled:o,className:"rounded px-2 py-1 text-[12px] text-text-300 hover:bg-bg-100 disabled:opacity-50",onClick:c,children:"收起预览"})}),h.jsx("div",{className:"min-h-0 flex-1",children:t})]})]})}const doe=6173,hoe=6182;function foe({open:e,onOpenChange:t,projectName:n,currentPort:r,allUsedPorts:i,onUpdate:s}){const o=[];for(let v=doe;v<=hoe;v++)(v===r||!i.includes(v))&&o.push(v);const[a,l]=g.useState(r),[c,u]=g.useState(!1),[d,f]=g.useState(null),p=a!==r&&!c;async function m(){if(p){u(!0),f(null);try{await s(a),t(!1)}catch(v){f((v==null?void 0:v.message)??String(v))}finally{u(!1)}}}return h.jsx(w1,{open:e,onOpenChange:t,children:h.jsxs(Vp,{className:"max-w-md",children:[h.jsxs(qp,{children:[h.jsxs(Kp,{children:["改端口 · ",n]}),h.jsxs(m3,{children:["手改通常发生在系统其他进程占了默认分配的端口、dev server 起不来时。 提交后 daemon 会停 dev server → 写 ",h.jsx("code",{className:"mx-1 rounded bg-bg-100 px-1 py-0.5 text-[11px]",children:".clawd-project.json"})," → 用新端口重新起。"]})]}),h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsx("label",{className:"text-xs text-text-400",children:"新端口(仅显示段内可用 + 当前端口)"}),h.jsx("select",{className:"h-9 rounded-md border border-border bg-elevated px-3 py-1 text-sm text-text-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent",value:a,onChange:v=>l(Number(v.target.value)),disabled:c,children:o.map(v=>h.jsxs("option",{value:v,children:[v,v===r?"(当前)":""]},v))}),o.length===1&&h.jsx("div",{className:"text-[11px] text-text-400",children:"端口段已全被其它 project 占用,没有可换的;先删一个 idle project 释放端口。"}),d&&h.jsx("div",{className:"rounded border border-destructive/30 bg-destructive/5 px-3 py-2 text-[12px] text-destructive",children:d})]}),h.jsxs(S1,{children:[h.jsx(di,{variant:"ghost",onClick:()=>t(!1),disabled:c,children:"取消"}),h.jsx(di,{onClick:m,disabled:!p,children:c?"应用中…":"应用新端口"})]})]})})}const c2=[{stage:"build",label:"构建"},{stage:"deploy",label:"部署到阿里云"},{stage:"verify",label:"验证可访问性"}];function poe({currentStage:e,onCancel:t}){const n=c2.findIndex(r=>r.stage===e);return h.jsxs("div",{"data-testid":"publish-progress",className:"flex items-center gap-3 border-b border-bg-200 bg-bg-50 px-3 py-1.5 text-[12px]",children:[c2.map((r,i)=>{const s=i<n,o=i===n,a=s?"text-text-300":o?"text-text-200":"text-text-500/50";return h.jsxs("span",{className:`flex items-center gap-1 ${a}`,children:[s?h.jsx(cp,{className:"size-3.5"}):o?h.jsx(Ln,{className:"size-3.5 animate-spin"}):h.jsx(_I,{className:"size-3.5"}),h.jsxs("span",{children:[r.label,o?"中…":""]})]},r.stage)}),h.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded px-2 py-0.5 text-[11px] text-text-400 hover:bg-bg-100 hover:text-text-200",children:"取消"})]})}const moe={build:"构建",deploy:"部署",verify:"验证"};function goe({stage:e,onRetry:t,onDismiss:n}){return h.jsxs("div",{"data-testid":"publish-interrupted-banner",className:"flex items-center gap-2 border-b border-yellow-400/40 bg-yellow-400/10 px-3 py-1.5 text-[12px]",children:[h.jsx(nu,{className:"size-3.5 text-yellow-500"}),h.jsxs("span",{className:"text-text-200",children:["上次发布在 ",h.jsxs("strong",{className:"font-medium",children:["[",moe[e],"]"]})," ","阶段被中断(daemon 重启)"]}),h.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded bg-accent-main-100 px-2 py-0.5 text-[11px] text-oncolor-100 hover:opacity-90",children:"重新发布"}),h.jsx("button",{type:"button",onClick:n,className:"rounded px-2 py-0.5 text-[11px] text-text-400 hover:bg-bg-100 hover:text-text-200",children:"取消"})]})}const voe={build:"构建",deploy:"部署",verify:"验证",unknown:"未知"};function xoe({stage:e,onFocusChat:t,onClose:n}){return h.jsxs("div",{"data-testid":"publish-failed-banner",className:"flex items-center gap-2 border-b border-destructive/40 bg-destructive/10 px-3 py-1.5 text-[12px]",children:[h.jsx(Qi,{className:"size-3.5 text-destructive"}),h.jsxs("button",{type:"button",onClick:t,className:"flex-1 text-left text-text-200 hover:underline",children:["发布失败:",h.jsxs("strong",{className:"font-medium",children:["[",voe[e],"]"]})," ","已通知 assistant 接管 →"]}),h.jsx("button",{type:"button",onClick:n,"aria-label":"关闭失败提示",className:"rounded p-0.5 text-text-400 hover:bg-bg-100 hover:text-text-200",children:h.jsx(Ir,{className:"size-3.5"})})]})}const u2={"install-pending":{label:"等装依赖…",step:"1/3"},installing:{label:"安装依赖中…(可能要几十秒到几分钟)",step:"2/3"},"starting-dev-server":{label:"启动 dev server…(等监听端口才挂 iframe)",step:"3/3"}};function _oe({project:e,previewHost:t,previewScheme:n,onUpdatePort:r,allUsedPorts:i,publishSlot:s,publishInFlightStage:o,onDismissPublishJob:a,onRetryPublish:l,publishFailureBanner:c,onPublishFailureBannerClose:u,onPublishFailureBannerFocusChat:d}){var x,_;const[f,p]=g.useState(!1);if(!e)return h.jsx("div",{className:"flex h-full w-full items-center justify-center p-6 text-center text-[13px] text-text-400",children:"未绑定 project"});const m=e.stage??(e.isRunning?"running":"stopped"),v=t?`${n}://${t}/preview/${e.port}/`:null,w=e.prodUrl??null;return h.jsxs("div",{className:"flex h-full w-full flex-col","data-testid":"preview-pane",children:[h.jsxs("header",{className:"flex items-center justify-between gap-2 border-b border-bg-200 bg-bg-50 px-3 py-1.5",children:[h.jsxs("div",{className:"flex items-center gap-2 text-[12px]",children:[h.jsx("span",{className:"font-medium text-text-200",children:e.name}),h.jsx("span",{className:"rounded bg-bg-100 px-1.5 py-0.5 text-[11px] text-text-400",children:e.port}),h.jsx("span",{className:"text-[10px] uppercase tracking-wider text-text-500",children:m==="running"?"dev":m})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[w?h.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",title:`打开线上:${w}`,className:"inline-flex items-center gap-1 rounded border border-bg-200 px-2 py-0.5 text-[11px] text-text-300 hover:bg-bg-100",children:[h.jsx(tu,{className:"size-3"}),"打开线上"]}):null,s,h.jsxs(ky,{children:[h.jsx(Cy,{asChild:!0,children:h.jsx("button",{type:"button","aria-label":"Project settings",className:"rounded p-1 text-text-400 hover:bg-bg-100",children:h.jsx(L8,{className:"size-3.5"})})}),h.jsxs(wp,{align:"end",children:[h.jsx(Ri,{onSelect:()=>p(!0),children:"Update Port…"}),h.jsxs(Ri,{disabled:!0,title:"rename not supported yet",onSelect:y=>y.preventDefault(),children:["Name: ",e.name]})]})]})]})]}),c?h.jsx(xoe,{stage:c.stage,onClose:()=>u==null?void 0:u(),onFocusChat:()=>d==null?void 0:d()}):null,((x=e.publishJob)==null?void 0:x.status)==="in-flight"?h.jsx(poe,{currentStage:o??e.publishJob.stage,onCancel:()=>void(a==null?void 0:a())}):null,((_=e.publishJob)==null?void 0:_.status)==="interrupted"?h.jsx(goe,{stage:e.publishJob.stage,onRetry:()=>void(l==null?void 0:l()),onDismiss:()=>void(a==null?void 0:a())}):null,h.jsx("div",{className:"min-h-0 flex-1",children:m==="failed"?h.jsx(yoe,{reason:e.stageReason}):m==="stopped"?null:m==="running"?v?h.jsx("iframe",{"data-testid":"preview-iframe",className:"size-full border-0 bg-white",src:v,title:"preview"}):h.jsx(d2,{label:"等 tunnel 起来…",step:"-"}):h.jsx(d2,{label:u2[m].label,step:u2[m].step})}),h.jsx(foe,{open:f,onOpenChange:p,projectName:e.name,currentPort:e.port,allUsedPorts:i,onUpdate:async y=>{await r(y)}})]})}function d2({label:e,step:t}){return h.jsxs("div",{"data-testid":"preview-spinner",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(Ln,{className:"size-6 animate-spin text-accent-main-100"}),h.jsx("div",{className:"text-[13px] text-text-200",children:e}),h.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-500",children:t}),h.jsx("div",{className:"mt-2 max-w-[300px] text-[11px] text-text-500",children:"左侧 chat 可看 assistant 详细进度"})]})}function yoe({reason:e}){return h.jsxs("div",{"data-testid":"preview-failed",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(Qi,{className:"size-6 text-destructive"}),h.jsx("div",{className:"text-[13px] text-text-200",children:"project 启动失败"}),h.jsx("div",{className:"max-w-[400px] text-[12px] text-text-400",children:e??"未知原因 —— 看 ~/.clawd/clawd.log 排查"}),h.jsx("div",{className:"mt-1 max-w-[300px] text-[11px] text-text-500",children:"左侧 chat 可看 assistant 详细进度 / 跟它说怎么修"})]})}function boe({error:e,onClose:t}){const[n,r]=g.useState(!1),i=async()=>{var a;if(!e)return;const s=e.message;let o=!1;try{(a=navigator.clipboard)!=null&&a.writeText&&(await navigator.clipboard.writeText(s),o=!0)}catch{o=!1}if(!o){const l=document.createElement("textarea");l.value=s,l.style.position="fixed",l.style.opacity="0",document.body.appendChild(l),l.select();try{document.execCommand("copy"),o=!0}catch{o=!1}finally{document.body.removeChild(l)}}o&&(r(!0),setTimeout(()=>r(!1),1500))};return h.jsx(w1,{open:!!e,onOpenChange:s=>{s||(r(!1),t())},children:h.jsxs(Vp,{className:"max-w-lg",children:[h.jsx(qp,{children:h.jsx(Kp,{children:(e==null?void 0:e.title)??"错误"})}),h.jsx("pre",{"data-testid":"rpc-error-message",className:"max-h-72 overflow-auto whitespace-pre-wrap break-words rounded border border-bg-200 bg-bg-50 px-3 py-2 text-[12px] text-text-200",children:(e==null?void 0:e.message)??""}),h.jsxs(S1,{children:[h.jsx(di,{variant:"ghost",onClick:i,className:"gap-1.5",children:n?h.jsxs(h.Fragment,{children:[h.jsx(wl,{className:"size-3.5"}),"已复制"]}):h.jsxs(h.Fragment,{children:[h.jsx(up,{className:"size-3.5"}),"复制"]})}),h.jsx(di,{onClick:t,children:"关闭"})]})]})})}function woe(e,t){for(const n of[e,t])if(n)try{const r=new URL(n),i=r.protocol==="https:"||r.protocol==="wss:"?"https":"http";return{host:r.host,scheme:i}}catch{}return{host:null,scheme:"https"}}const h2=4;function Soe({children:e,onHeightChange:t}){const n=g.useRef(null),[r,i]=g.useState(0);return g.useEffect(()=>{const s=n.current;if(!s)return;const o=()=>i(s.offsetHeight>0?s.offsetHeight+h2*2:0);if(o(),typeof ResizeObserver>"u")return;const a=new ResizeObserver(o);return a.observe(s),()=>a.disconnect()},[]),g.useEffect(()=>{t==null||t(r)},[r,t]),h.jsx("div",{"data-testid":"chat-floating-dock","data-height":r,className:"relative z-20 h-0 shrink-0",children:h.jsx("div",{ref:n,className:"absolute left-4 right-4 flex flex-col items-end gap-1",style:{bottom:h2},children:e})})}const koe=250;function Coe(e){if(!e||!Number.isFinite(e))return null;const t=e/1e3;if(t<60)return`${t.toFixed(0)}s`;const n=Math.floor(t/60);return`${n}m${Math.round(t-n*60).toString().padStart(2,"0")}s`}function Eoe({agents:e}){var a,l,c;const[t,n]=g.useState(!1);if(e.length===0)return null;const r=e.length===1?e[0]:null,i=r?r.description:`${e.length} 个后台任务`,s=r?Coe((l=(a=r.progress)==null?void 0:a.stats)==null?void 0:l.durationMs):null,o=r?(c=r.progress)==null?void 0:c.lastToolName:null;return h.jsxs("div",{"data-testid":"running-agents-chip","data-agent-count":e.length,className:"relative",children:[t?h.jsx("div",{"data-testid":"running-agents-popover",className:"absolute bottom-full right-0 z-20 mb-1 w-[min(560px,80vw)]",children:h.jsx("div",{className:"min-w-0 overflow-y-auto rounded-lg border border-bg-200/60 bg-bg-100 px-2 py-1 shadow-lg",style:{maxHeight:koe},children:e.map(u=>h.jsx(OM,{expandable:!1,description:u.description,input:u.input,output:u.output,...u.error!==void 0?{error:u.error}:{},pending:u.pending,notifications:u.notifications,...u.toolResultExtra?{toolResultExtra:u.toolResultExtra}:{},...u.progress?{progress:u.progress}:{}},u.toolUseId))})}):null,h.jsxs("button",{type:"button","data-testid":"running-agents-chip-toggle","aria-expanded":t,onClick:()=>n(u=>!u),className:re("flex max-w-[min(560px,80vw)] min-w-0 items-center gap-2 rounded-full","border border-bg-200/60 bg-bg-100/95 px-3 py-1 text-[12px] shadow-md backdrop-blur","hover:bg-bg-200/95 transition-colors"),children:[h.jsx(Ln,{className:"w-3 h-3 shrink-0 animate-spin text-blue-400"}),h.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-text-200",children:i}),s?h.jsx("span",{className:"shrink-0 tabular-nums text-text-400",children:s}):null,o?h.jsxs("span",{className:"shrink-0 font-mono tabular-nums text-blue-400",children:["now:",o]}):null,h.jsx(xI,{className:re("w-3.5 h-3.5 shrink-0 text-text-400 transition-transform",t&&"rotate-180")})]})]})}const Noe={closeTrailing:!1},Toe={closeTrailing:!0};function Ioe(e){return e?Noe:Toe}function Poe({session:e,api:t,onPromoteQuickAsk:n}){const r=m5(e.sessionId);return h.jsx(C1,{state:r,extras:{session:e,api:t,...n?{onPromoteQuickAsk:n}:{}}})}function Roe({state:e,chat:t,extras:n}){var T;const r=pi("daemon-info"),i=_i(),s=n.api,o=n.session,a=o.appBuilderProject,[l,c]=g.useState(null),u=g.useCallback(()=>{s.appBuilderGetProject(o.sessionId).then(O=>c(O.project)).catch(()=>c(null))},[s,o.sessionId]);g.useEffect(()=>{u()},[u]);const[d,f]=g.useState([]),p=g.useCallback(()=>{s.appBuilderListProjects().then(O=>f(O.projects)).catch(()=>f([]))},[s]);g.useEffect(()=>{p()},[p]),g.useEffect(()=>i.on("appBuilder:project-updated",P=>{const D=P;D!=null&&D.project&&(D.project.name===a&&c(D.project),f(R=>{const A=R.findIndex(L=>L.name===D.project.name);if(A<0)return[...R,D.project];const M=R.slice();return M[A]=D.project,M}))}),[i,a]);const{host:m,scheme:v}=woe(i.url,r==null?void 0:r.tunnelUrl),[w,x]=g.useState(void 0),[_,y]=g.useState(null);g.useEffect(()=>{const O=i.on("appBuilder:publish-progress",D=>{const R=D;!R||R.name!==a||R.status==="started"&&x(R.stage)}),P=i.on("appBuilder:publish-failed",D=>{const R=D;!R||R.name!==a||(x(void 0),y({stage:R.stage}))});return()=>{O(),P()}},[i,a]),g.useEffect(()=>{x(void 0),y(null)},[a]);const[S,C]=g.useState(null),k=h.jsx("button",{type:"button",className:"rounded bg-accent-main-100 px-2.5 py-1 text-[12px] text-oncolor-100 hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50",disabled:((T=l==null?void 0:l.publishJob)==null?void 0:T.status)==="in-flight",onClick:async()=>{try{await s.appBuilderPublish(a)}catch(O){C({title:"发布请求失败",message:(O==null?void 0:O.message)??String(O)})}},children:"发布上线"}),N=(l==null?void 0:l.stage)??(l!=null&&l.isRunning?"running":"stopped");return h.jsxs(h.Fragment,{children:[h.jsx(uoe,{left:t,stage:N,onExpand:async()=>{await s.appBuilderStartDevServer(o.sessionId)},onCollapse:async()=>{await s.appBuilderStopDevServer(o.sessionId)},right:h.jsx(_oe,{project:l,previewHost:m,previewScheme:v,allUsedPorts:d.map(O=>O.port),onUpdatePort:async O=>{await s.appBuilderUpdateProjectPort(a,O),p()},publishSlot:k,publishInFlightStage:w,onDismissPublishJob:async()=>{try{await s.appBuilderDismissPublishJob(a)}catch(O){C({title:"取消发布失败",message:(O==null?void 0:O.message)??String(O)})}},onRetryPublish:async()=>{try{await s.appBuilderPublish(a)}catch(O){C({title:"重新发布失败",message:(O==null?void 0:O.message)??String(O)})}},publishFailureBanner:_,onPublishFailureBannerClose:()=>y(null),onPublishFailureBannerFocusChat:()=>{}})}),h.jsx(boe,{error:S,onClose:()=>C(null)})]})}function Moe({headerMeta:e,connState:t,liveWorktreeRoot:n,onOpenConfig:r,variant:i="full",ephemeral:s,onPromote:o,hideHeader:a=!1,flatProcess:l=!1,lines:c,pendingPermissions:u,procAlive:d,rewindableUserMessageIds:f,onPermissionRespond:p,onPermissionInterrupt:m,onRewind:v,onFork:w,onQuickAsk:x,topSlot:_,realtimeQuestionAnswers:y,onSubmitQuestion:S,onCancelQuestion:C,liveQuestionToolUseIds:k,api:N,cwd:T,tool:O,sessionKey:P,onSend:D,awaitingUser:R,queued:A,onDequeue:M,onAbort:L,onNewSession:$,onClearSession:F,configSlot:B,chatRootRef:z,chatBodyRef:E,drawers:H,xtermSlot:q,fileSharingScope:j,onShareFile:ne,onOpenInTab:ie,onPreviewMarkdown:K,onOpenFilePath:ge,resolveDispatchLine:Pe}){const[he,Ae]=g.useState(0),je=g.useMemo(()=>i==="full"?nq(v5(c)):[],[c,i]),$e=g.useMemo(()=>new Set(je.map(_e=>_e.toolUseId)),[je]);return h.jsx(oee,{children:h.jsxs("div",{ref:z,"data-cc-chat-root":"",className:"flex flex-col h-full bg-bg-100",children:[a?null:h.jsx(lte,{meta:e,...O?{tool:O}:{},connState:t,variant:i,...n!==void 0?{liveWorktreeRoot:n}:{},...i==="full"&&r?{onOpenConfig:r}:{},...i==="quickask"?{ephemeral:s??!1,...o?{onPromote:o}:{}}:{}}),h.jsx("div",{ref:E,"data-testid":"chat-body",className:"flex-1 overflow-y-auto min-h-0",style:{overflowAnchor:"none",paddingBottom:he},children:h.jsx(zM,{lines:c,...p?{onPermissionRespond:p}:{},...m&&d?{onPermissionInterrupt:m}:{},topSlot:_,...v?{onRewind:v}:{},rewindableUserMessageIds:f,...w?{onFork:w}:{},...x?{onQuickAsk:x}:{},realtimeQuestionAnswers:y,onSubmitQuestion:S,...C?{onCancelQuestion:C}:{},liveQuestionToolUseIds:k,...j?{fileSharingScope:j}:{},...ne?{onShareFile:ne}:{},...ie?{onOpenInTab:ie}:{},...K?{onPreviewMarkdown:K}:{},...ge?{onOpenFilePath:ge}:{},...Pe?{resolveDispatchLine:Pe}:{},...i==="full"&&!l?{turnCollapse:Ioe(d)}:{},dockedAgentToolUseIds:$e})}),q,h.jsx(Soe,{onHeightChange:Ae,children:h.jsx(Eoe,{agents:je})}),e.larkChatName?h.jsx("div",{className:"mx-3 mb-3 rounded-lg border border-border bg-bg-200 px-3 py-2 text-[12px] text-text-400","data-testid":"lark-readonly-notice",children:e.larkChatType==="p2p"?`此会话由与「${e.larkChatName}」的飞书私聊驱动——对方消息触发,这里仅供观察。`:`此会话由飞书群「${e.larkChatName}」驱动——群成员 @ bot 提问触发,这里仅供观察。`}):h.jsx(ote,{meta:e,...N?{api:N}:{},cwd:T,...O?{tool:O}:{},sessionKey:P,onSend:D,awaitingUser:R,...A?{queued:A}:{},...M?{onDequeue:M}:{},...L?{onAbort:L}:{},...$?{onNewSession:$}:{},...F?{onClearSession:F}:{},...B?{configSlot:B}:{}}),H]})})}function C1({state:e,extras:t,onQuickAskInternal:n,onPreviewMdInternal:r}){const{session:i,api:s,liveGitBranch:o,liveWorktreeRoot:a,onNewSession:l,onTurnEnd:c,onOpenConfig:u,onFork:d,onQuickAsk:f,viewerRole:p,onPromoteQuickAsk:m,configSlot:v,hideHeader:w,flatProcess:x}=t,{capabilities:_}=f1(i.tool||"claude"),y=(_==null?void 0:_.features)??uI(i.tool),[S,C]=g.useState(null),[k,N]=g.useState(null),T=ap(),O=!!s&&T.actionsLevel==="owner"&&y.fileSharing,P=mI(i.ownerPersonaId??null).persona,D=(P==null?void 0:P.label)??null,R=!!D&&!!i.ownerPersonaId,A=roe(),M=g.useCallback((Y,ve)=>{C({kind:Y,text:ve}),setTimeout(()=>{C(Se=>(Se==null?void 0:Se.text)===ve?null:Se)},2e3)},[]),L=_i(),$=Az(),F=u5(i.sessionId,i.toolSessionId),{events:B,pendingQuestions:z,clearQuestion:E,markQuestionSubmitted:H,status:q}=F,j=e.historyLoading,ne=p5(q);g.useEffect(()=>{Me("chat-panel","sessionStatus",{sessionId:i.sessionId,sessionStatus:q,procAlive:ne})},[q,ne,i.sessionId]);const ie=e.lines,K=e.pendingPermissions,ge=K[0]??null,Pe=g.useMemo(()=>eq(B),[B]),[he,Ae]=g.useState(null),[je,$e]=g.useState(()=>new Set);QV(s,i.sessionId,i.toolSessionId,y.observe);const _e=g.useRef(i.sessionId);g.useEffect(()=>{if(_e.current=i.sessionId,!y.rewind){Ae(null);return}let Y=!1;return Ae(null),(async()=>{try{const ve=await s.sessionRewindableMessageIds(i.sessionId);if(Y)return;Ae(new Set(ve.userMessageIds))}catch{Y||Ae(null)}})(),()=>{Y=!0}},[s,i.sessionId,y.rewind]);const tt=g.useCallback(()=>{const Y=i.sessionId;s.sessionRewindableMessageIds(Y).then(ve=>{_e.current===Y&&Ae(new Set(ve.userMessageIds))}).catch(()=>{})},[s,i.sessionId]),Rt=g.useMemo(()=>{if(he!==null){const Je=new Set(he);for(const Rr of je)Je.delete(Rr);return Je}const Y=new Set(["Edit","Write","MultiEdit","NotebookEdit"]),ve=new Set;let Se=null;for(const Je of ie)Je.kind==="user-text"?Se=Je.uuid??null:Se&&Je.kind==="tool-call"&&Y.has(Je.tool)&&!je.has(Se)&&ve.add(Se);return ve},[ie,je,he]),Xe=g.useRef(c);Xe.current=c,ZV(i.sessionId,i.toolSessionId,()=>{Ke(null),$e(new Set)});const ot=kte({sessionStatus:q}),xn=g.useRef(null);g.useEffect(()=>{var Se;const Y=xn.current,ve=(Y==null?void 0:Y.sid)===i.sessionId;ve&&Y.phase===ot||(xn.current={sid:i.sessionId,phase:ot},Me("session-phase",ot,{sid:i.sessionId,phase:ot,prev:ve?Y.phase:null,desc:Ste[ot]}),ve&&Y.phase==="turn-running"&&ot!=="turn-running"&&((Se=Xe.current)==null||Se.call(Xe),tt()))},[ot,i.sessionId,tt]);const ut=g.useCallback(async()=>{const Y=await s.sessionInterrupt(i.sessionId).catch(()=>{});return(Y==null?void 0:Y.queued)??[]},[s,i.sessionId]),[Ct,Ke]=g.useState(null),at=g.useCallback(Y=>{Ke(Y)},[]),[Dt,Vt]=g.useState(!1),Tn=g.useCallback(()=>{s.sessionStop(i.sessionId).catch(()=>{}),Vt(!1)},[s,i.sessionId]);g.useCallback(Y=>{s.pinSession(i.sessionId,Y).catch(ve=>{Me("chat-panel","pinSession failed",{err:ve==null?void 0:ve.message})})},[s,i.sessionId]);const U=m?"quickask":"full",{container:J,onCollapse:ye}=mte(),Ce=g.useRef(0),Fe=g.useRef(null);g.useEffect(()=>{const Y=ve=>{if(ve.key!=="Escape")return;if(!ne){Ce.current=0;return}if(ve.isComposing)return;const Je=ve.target;if(Je&&Je.closest("[data-cc-chat-root]")!==Fe.current)return;const Rr=Date.now();Rr-Ce.current<2e3?(Ce.current=0,Vt(!0)):(Ce.current=Rr,ut())};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[ut,ne]);const xt=g.useRef(null),un=g.useRef(!0),qt=g.useRef(void 0),dn=g.useRef(0),se=g.useRef(0),be=g.useRef(void 0);g.useEffect(()=>{N(null)},[i.sessionId]),g.useEffect(()=>{const Y=xt.current;if(!Y)return;const ve=150,Se=Je=>{Date.now()<se.current&&(Je.preventDefault(),se.current=Date.now()+ve)};return Y.addEventListener("wheel",Se,{passive:!1}),()=>Y.removeEventListener("wheel",Se)},[]),g.useEffect(()=>{const Y=xt.current;if(!Y)return;const ve=32,Se=()=>{const Je=Y.scrollHeight-Y.scrollTop-Y.clientHeight;un.current=Je<=ve};return Y.addEventListener("scroll",Se,{passive:!0}),()=>Y.removeEventListener("scroll",Se)},[]),g.useLayoutEffect(()=>{var Zo;const Y=xt.current;if(!Y)return;const ve=be.current!==i.sessionId;ve&&(be.current=i.sessionId,un.current=!0,qt.current=void 0,dn.current=0,se.current=0);const Se=qt.current,Je=(Zo=ie[0])==null?void 0:Zo.seq;qt.current=Je,!ve&&Se!==void 0&&Je!==void 0&&Je<Se?(Y.scrollTop=Y.scrollHeight-dn.current,se.current=Date.now()+200):un.current&&(Y.scrollTop=Y.scrollHeight),dn.current=Y.scrollHeight-Y.scrollTop},[ie,ge==null?void 0:ge.requestId,i.sessionId]);const lt=g.useMemo(()=>{const Y={};for(const[ve,Se]of Object.entries(z))Se.submittedAnswers&&(Y[ve]=Se.submittedAnswers);return Y},[z]),Mt=g.useMemo(()=>new Set(Object.keys(z)),[z]),Pr=g.useCallback(async(Y,ve)=>{try{await s.answerQuestion({sessionId:i.sessionId,toolUseId:Y,answers:ve}),H(Y,ve)}catch{}},[s,i.sessionId,H]),ae=g.useCallback(async Y=>{try{await s.cancelQuestion({sessionId:i.sessionId,toolUseId:Y}),E(Y)}catch{}},[s,i.sessionId,E]),Ze=g.useCallback(async(Y,ve)=>{var Se;if(ge)try{await((Se=e.respondPermission)==null?void 0:Se.call(e,ge.requestId,Y?"allow":"deny"))}catch{}},[e,ge]),hn=g.useCallback(async()=>{const Y=i.sessionId;try{await s.sessionStop(Y)}catch{}e.clearSession?await e.clearSession():await s.sessionNew(Y)},[e,s,i.sessionId]),Ys=g.useMemo(()=>e.historyError?h.jsxs("div",{className:"flex justify-center py-2 text-[12px] text-text-400","data-testid":"history-error",children:["历史未加载完(",e.historyError,");切走再切回可重试"]}):j&&ie.length===0?h.jsx("div",{className:"flex justify-center py-4","data-testid":"history-loading",children:h.jsx(Ln,{className:"w-4 h-4 text-text-400 animate-spin"})}):null,[j,ie.length,e.historyError]),Ko=e.meta,Go=h.jsxs(h.Fragment,{children:[i.toolSessionId&&y.subagents?h.jsx(gte,{api:s,cwd:i.cwd,toolSessionId:i.toolSessionId,toolKind:i.tool??"claude"}):null,Ct&&y.rewind?h.jsx(xte,{open:!0,onOpenChange:Y=>{Y||Ke(null)},api:s,sessionId:i.sessionId,userMessageId:Ct,lines:ie,procAlive:ne,onNoChanges:Y=>{$e(ve=>{if(ve.has(Y))return ve;const Se=new Set(ve);return Se.add(Y),Se})}}):null,Dt?h.jsx(Aoe,{onConfirm:Tn,onCancel:()=>Vt(!1)}):null]}),Si={kind:"session",sessionId:i.sessionId},Xs=g.useCallback(async Y=>{if(s)try{await l2(s,L,i.sessionId,Y)}catch(ve){const Se=ve.message;Me("chat-panel","open-in-tab failed",{err:Se}),M("err",`Open in tab 失败:${Se}`)}},[s,L,i.sessionId,M]),[Pl,Yo]=g.useState(!1),[qr,rs]=g.useState(null),Qs=g.useCallback(Y=>{if(r){r(Y);return}rs(Y),Yo(!0)},[r]),Gp=g.useCallback(Y=>{if(!s)return;const ve=async()=>{try{await s.attachmentGroupAdd(i.sessionId,Y)}catch(Je){Me("chat-panel","file-link groupAdd skipped",{err:Je.message})}},Se=Je=>{const Rr=Je.message;Me("chat-panel","file-link open failed",{err:Rr}),M("err",`打开文件失败:${Rr}`)};if(Lp(Y)){ve().then(()=>Qs(Y),Se);return}l2(s,L,i.sessionId,Y,60,ve).catch(Se)},[s,L,i.sessionId,Qs,M]),Kt=g.useCallback(async Y=>{if(!s)throw new Error("daemon api not ready");const ve=await k1(s,L,i.sessionId,Y,60),Se=await fetch(ve);if(!Se.ok)throw new Error(`fetch ${Se.status} ${Se.statusText}`);return await Se.text()},[s,L,i.sessionId]),Xo=g.useCallback(async(Y,ve)=>{if(s)try{const{url:Se}=await s.attachmentSignUrl({sessionId:i.sessionId,relPath:Y,ttlSeconds:86400,...ve?{view:ve}:{}}),Je=await ooe(Se);M(Je?"ok":"err",Je?"分享链接已复制到剪贴板(24h 有效)":"复制失败:请手动复制")}catch(Se){const Je=Se.message;Me("chat-panel","share-file failed",{err:Je}),M("err",`生成分享链接失败:${Je}`)}},[s,i.sessionId,M]),Qo=g.useCallback(()=>N(null),[]),At=k==="files"&&O&&s?{title:"Edited Files",onBack:Qo,content:h.jsx(Bie,{api:s,scope:Si,sessionId:i.sessionId,onShareFile:Xo,onOpenInTab:Xs,onPreviewMarkdown:Qs})}:k==="cron"?{title:`定时任务${Pe.length?` (${Pe.length})`:""}`,onBack:Qo,content:h.jsx("div",{className:"p-3",children:h.jsx(wte,{jobs:Pe})})}:k==="persona"&&R&&s&&i.ownerPersonaId?{title:`Persona · ${D??""}`,onBack:Qo,content:h.jsx(eoe,{personaId:i.ownerPersonaId,open:!0,onClose:Qo,api:s,embedded:!0,...p?{viewerRole:p}:{}},i.ownerPersonaId)}:null,Ot=U==="full"?h.jsx(fte,{session:i,meta:Ko,...o!==void 0?{liveGitBranch:o}:{},...a!==void 0?{liveWorktreeRoot:a}:{},...R?{personaName:D}:{},...R?{onOpenPersona:()=>N("persona")}:{},...O?{onOpenFiles:()=>N("files")}:{},cronActiveCount:Pe.length,onCronClick:()=>N("cron"),onForceStop:()=>Vt(!0),...p?{viewerRole:p}:{},..._!=null&&_.toolSessionIdLabel?{toolSessionIdLabel:_.toolSessionIdLabel}:{},drill:At,...ye?{onCollapse:ye}:{}}):null;return h.jsxs(h.Fragment,{children:[J&&Ot?fl.createPortal(Ot,J):null,h.jsx(Moe,{headerMeta:Ko,connState:e.connState,...a!==void 0?{liveWorktreeRoot:a}:{},...u?{onOpenConfig:u}:{},variant:U,...w?{hideHeader:w}:{},...x?{flatProcess:x}:{},...U==="quickask"?{ephemeral:i.ephemeral!==!1,onPromote:()=>void(m==null?void 0:m(i.sessionId))}:{},lines:ie,pendingPermissions:K,procAlive:ne,rewindableUserMessageIds:Rt,onPermissionRespond:Ze,onPermissionInterrupt:ut,onRewind:y.rewind?at:void 0,...d&&y.fork?{onFork:d}:{},...n&&y.fork?{onQuickAsk:n}:f&&y.fork?{onQuickAsk:f}:{},topSlot:Ys,realtimeQuestionAnswers:lt,onSubmitQuestion:Pr,onCancelQuestion:ae,liveQuestionToolUseIds:Mt,api:s,cwd:i.cwd,...i.tool?{tool:i.tool}:{},sessionKey:i.sessionId,onSend:e.sendText,queued:e.queued,onDequeue:e.dequeue,awaitingUser:K.length>0||Object.values(z).some(Y=>!Y.submittedAnswers),onAbort:ut,...l?{onNewSession:l}:{},onClearSession:hn,...v?{configSlot:v}:{},chatRootRef:Fe,chatBodyRef:xt,drawers:Go,xtermSlot:$==="tui"&&ne&&y.tui?h.jsx(Oie,{sessionId:i.sessionId,client:L},i.sessionId):null,fileSharingScope:Si,...s?{onShareFile:Xo}:{},...s?{onOpenInTab:Xs}:{},...s?{onPreviewMarkdown:Qs}:{},...s?{onOpenFilePath:Gp}:{},resolveDispatchLine:A}),s?h.jsx(coe,{open:Pl,onOpenChange:Yo,relPath:qr,loadMarkdown:Kt,onShare:qr?()=>void Xo(qr,"md-rendered"):void 0}):null,S?h.jsx("div",{"data-testid":"share-toast",role:"status","aria-live":"polite",className:S.kind==="ok"?"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-emerald-500/40 bg-emerald-500/10 px-3 py-2 text-[12px] text-emerald-700 shadow-md dark:text-emerald-300":"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px] text-destructive shadow-md",children:S.text}):null]})}function Aoe({onConfirm:e,onCancel:t}){return h.jsx("div",{role:"dialog","aria-modal":"true","data-testid":"force-stop-confirm",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:t,children:h.jsxs("div",{className:"max-w-sm w-[92%] rounded-lg border border-red-400/40 bg-bg-0 p-4 shadow-xl",onClick:n=>n.stopPropagation(),children:[h.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[h.jsx(nu,{className:"w-5 h-5 text-red-500 shrink-0 mt-0.5"}),h.jsx("div",{className:"text-[14px] text-text-100",children:"强制停止会话进程?会丢失 initialize / 预热缓存,下一次发送需要重新 spawn。"})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:t,className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),h.jsx("button",{type:"button","data-testid":"force-stop-confirm-ok",onClick:e,className:"h-8 px-3 rounded-md bg-red-500 text-white text-[12px] font-medium hover:bg-red-600 cursor-pointer",children:"强制停止"})]})]})})}const joe={codex:"on-request",claude:"bypassPermissions"};function Loe(e){const t={cwd:e.cwd,permissionMode:e.sourcePermissionMode??joe[e.sourceTool??"claude"]??"bypassPermissions",forkedFromSessionId:e.sourceSessionId};return e.sourceOwnerPersonaId&&(t.ownerPersonaId=e.sourceOwnerPersonaId),e.sourceTool&&(t.tool=e.sourceTool),e.sourceProjectPath&&(t.projectPath=e.sourceProjectPath),t}async function Doe(e,t,n,r={}){if(!t.toolSessionId)return null;const i=await e.sessionCreate({...Loe({cwd:t.cwd,sourceSessionId:t.sessionId,sourcePermissionMode:t.permissionMode,sourceOwnerPersonaId:t.ownerPersonaId,sourceTool:t.tool,sourceProjectPath:t.projectPath}),...r.ephemeral?{ephemeral:!0}:{}});try{const{forkedToolSessionId:s}=await e.sessionFork({cwd:t.cwd,toolSessionId:t.toolSessionId,messageUuid:n,targetCwd:i.cwd});await e.sessionResume(i.sessionId,s)}catch(s){throw e.sessionDelete(i.sessionId).catch(o=>Me("quick-ask","fork rollback failed",o)),s}return i}async function Ooe(e,t,n){return Doe(e,t,n,{ephemeral:!0})}function $d(e){return e!=null&&e.ephemeral!==!1}async function Boe(e,t){return t.stillEphemeral?(await e.sessionUpdate(t.sessionId,{ephemeral:!1}),!0):!1}const zoe=300;function $oe(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function Foe(e,t){const n=T_(),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>{let a=!1;return(async()=>{try{const l=await n.kv.get(e);if(a)return;const c=$oe(l);typeof c=="number"&&Number.isFinite(c)&&c>0?i(c):i(t)}catch{a||i(t)}})(),()=>{a=!0}},[n,e,t]);const o=g.useCallback(a=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{s.current=null,n.kv.set(e,a).catch(()=>{})},zoe)},[n,e]);return g.useEffect(()=>()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),{initialSize:r??t,setSize:o,loading:r===null}}function Hoe(){return{quickAsk:null,mds:[],active:null}}function Uoe(e,t){return{...e,quickAsk:{sessionId:t.sessionId,ephemeral:!0},active:"quick-ask"}}function Woe(e,t){const n=e.mds.includes(t);return{...e,mds:n?e.mds:[...e.mds,t],active:{kind:"md",relPath:t}}}function Voe(e){if(!e.quickAsk)return e;const t=e.active==="quick-ask",n=e.mds[0],r=t?n?{kind:"md",relPath:n}:null:e.active;return{...e,quickAsk:null,active:r}}function qoe(e){return e.quickAsk?{...e,quickAsk:{...e.quickAsk,ephemeral:!1}}:e}function Koe(e,t){const n=e.mds.indexOf(t);if(n<0)return e;const r=e.mds.filter(l=>l!==t);if(!(e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===t))return{...e,mds:r};const s=r[n],o=n>0?r[n-1]:void 0;let a=null;return s?a={kind:"md",relPath:s}:o?a={kind:"md",relPath:o}:e.quickAsk&&(a="quick-ask"),{...e,mds:r,active:a}}function Goe(e,t){return{...e,active:t}}function Yoe(e,t){return e===null||t===null||e==="quick-ask"||t==="quick-ask"?e===t:e.relPath===t.relPath}function v3(e){return e.quickAsk!==null||e.mds.length>0}function Xoe(e){return e.split("/").pop()||e}function Qoe({state:e,api:t,onSwitchTab:n,onCloseQuickAsk:r,onCloseMd:i,loadMarkdown:s,quickAskSession:o,onPromoteQuickAsk:a}){if(!v3(e))return null;const l=[];e.quickAsk&&l.push({id:"quick-ask",label:"问一下",title:"问一下",icon:h.jsx(x0,{className:"w-3.5 h-3.5"})});for(const c of e.mds)l.push({id:{kind:"md",relPath:c},label:Xoe(c),title:c,icon:h.jsx(mi,{className:"w-3.5 h-3.5"})});return h.jsxs("div",{className:"flex flex-col h-full bg-bg-50/60 border-l border-border-strong",children:[h.jsx(cf,{delayDuration:200,skipDelayDuration:100,children:h.jsx("div",{className:["flex items-stretch h-9 border-b border-text-100/10 shrink-0 overflow-x-auto","[scrollbar-width:none] [-ms-overflow-style:none]","[&::-webkit-scrollbar]:hidden"].join(" "),role:"tablist",children:l.map(c=>{const u=Yoe(e.active,c.id),d=c.id==="quick-ask"?"quick-ask":`md:${c.id.relPath}`;return h.jsxs(Ep,{children:[h.jsx(Np,{asChild:!0,children:h.jsxs("div",{role:"tab","aria-selected":u,"data-tab-title":c.title,onClick:()=>n(c.id),className:["group relative flex items-center gap-2 px-3 h-full cursor-pointer select-none","text-[12px] max-w-[180px] shrink-0 transition-colors duration-100",u?"text-text-100":"text-text-400 hover:text-text-100 hover:bg-text-100/[0.04]"].join(" "),children:[c.icon,h.jsx("span",{className:"truncate",children:c.label}),h.jsx("button",{type:"button","aria-label":`关闭 ${c.label}`,className:["ml-1 rounded p-0.5 shrink-0 transition-opacity","hover:bg-text-100/10",u?"opacity-70 hover:opacity-100":"opacity-0 group-hover:opacity-70"].join(" "),onClick:f=>{f.stopPropagation(),c.id==="quick-ask"?r():i(c.id.relPath)},children:h.jsx(Ir,{className:"w-3 h-3"})}),u?h.jsx("span",{"aria-hidden":"true",className:"absolute left-2 right-2 -bottom-px h-[2px] rounded-full bg-accent"}):null]})}),h.jsx(Mu,{side:"bottom",align:"start",className:"max-w-sm break-all",children:c.title})]},d)})})}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[e.quickAsk&&o?h.jsx("div",{className:"absolute inset-0",style:{display:e.active==="quick-ask"?"block":"none"},children:h.jsx(Poe,{session:o,api:t,...a?{onPromoteQuickAsk:a}:{}})}):null,e.mds.map(c=>{const u=e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===c;return h.jsx("div",{className:"absolute inset-0",style:{display:u?"block":"none"},children:h.jsx(g3,{relPath:c,loadMarkdown:s,showTitleBar:!1})},`md-body:${c}`)})]})]})}function Zoe(e){const t=e instanceof Error?e.message:String(e);return t.length>200?`${t.slice(0,200)}…`:t}function Joe({state:e,extras:t}){const{api:n,session:r}=t,i=_i(),[s,o]=g.useState(Hoe()),[a,l]=g.useState(null),c=r.ownerPersonaId!==UT,u=g.useRef(s);u.current=s;const d=g.useRef(!1),f=g.useCallback(async T=>{const O=u.current.quickAsk;l(null);let P;try{P=await Ooe(n,r,T)}catch(D){Me("quick-ask","fork failed",D),d.current||l(Zoe(D));return}if(!P){d.current||l("这条会话还没准备好(没有可派生的对话记录),稍后再试");return}if(d.current){n.sessionDelete(P.sessionId).catch(()=>{});return}$d(O)&&n.sessionDelete(O.sessionId).catch(()=>{}),o(D=>Uoe(D,{sessionId:P.sessionId}))},[n,r]),p=g.useCallback(async T=>{const O=u.current.quickAsk,P=(O==null?void 0:O.sessionId)===T;try{await Boe(n,{sessionId:T,stillEphemeral:P&&$d(O)})&&o(R=>qoe(R))}catch(D){Me("quick-ask","promote failed",D)}},[n]),m=g.useCallback(T=>{o(O=>Woe(O,T))},[]),v=g.useCallback(T=>{o(O=>Goe(O,T))},[]),w=g.useCallback(()=>{const T=u.current.quickAsk;$d(T)&&n.sessionDelete(T.sessionId).catch(()=>{}),o(O=>Voe(O))},[n]),x=g.useCallback(T=>{o(O=>Koe(O,T))},[]);g.useEffect(()=>()=>{d.current=!0;const T=u.current.quickAsk;$d(T)&&n.sessionDelete(T.sessionId).catch(()=>{})},[]);const _=pi("sessions")??[],y=s.quickAsk?_.find(T=>T.sessionId===s.quickAsk.sessionId)??{sessionId:s.quickAsk.sessionId,cwd:r.cwd,tool:r.tool}:null,S=g.useCallback(async T=>{const O=await k1(n,i,r.sessionId,T,60),P=await fetch(O);if(!P.ok)throw new Error(`fetch ${P.status} ${P.statusText}`);return P.text()},[n,i,r.sessionId]),C=h.jsx(C1,{state:e,extras:t,onQuickAskInternal:f,onPreviewMdInternal:m}),{initialSize:k,setSize:N}=Foe("chat-panel-right-slot-width",480);return h.jsxs(Ly,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:[h.jsx(uf,{id:"chat",minSize:"400px",children:h.jsxs("div",{className:"relative flex flex-col min-w-0 min-h-0 h-full",children:[C,a?h.jsxs("div",{"data-testid":"quick-ask-error",className:"absolute bottom-24 left-1/2 z-10 -translate-x-1/2 max-w-[90%] rounded-md border border-border bg-bg-200 px-3 py-2 text-[12px] text-text-300 shadow-lg",children:[h.jsxs("span",{className:"mr-2",children:["问一下没能打开:",a]}),h.jsx("button",{type:"button","aria-label":"关闭提示",onClick:()=>l(null),className:"text-text-400 hover:text-text-200 cursor-pointer",children:"✕"})]}):null]})}),v3(s)?h.jsxs(h.Fragment,{children:[h.jsx(c5,{className:"w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),h.jsx(uf,{id:"right-slot",defaultSize:`${k}px`,minSize:"360px",maxSize:"800px",onResize:T=>N(T.inPixels),children:h.jsx(Qoe,{state:s,api:n,onSwitchTab:v,onCloseQuickAsk:w,onCloseMd:x,loadMarkdown:S,quickAskSession:y,...c?{onPromoteQuickAsk:p}:{}})})]}):null]})}function eae({extras:e}){const t=m5(e.session.sessionId);if(e.session.appBuilderProject){const n=h.jsx(C1,{state:t,extras:e});return h.jsx(Roe,{state:t,chat:n,extras:e})}return h.jsx(Joe,{state:t,extras:e})}function tae(e,t,n){const r=e?t.find(s=>s.id===e):void 0;if(r!=null&&r.efforts&&r.efforts.length>0)return{options:r.efforts,defaultValue:r.defaultEffort??""};const i=n.find(s=>s.name==="effort");return{options:(i==null?void 0:i.options)??[],defaultValue:typeof(i==null?void 0:i.default)=="string"?i.default:""}}function nae(e,t,n){var l;if(!t)return((l=(e??[]).find(c=>c.id===""))==null?void 0:l.label)??"未指定";const r=t.toLowerCase(),i=[["opus","Opus"],["fable","Fable"],["sonnet","Sonnet"],["haiku","Haiku"]];for(const[c,u]of i){if(!r.includes(c))continue;const d=r.match(new RegExp(`${c}-(\\d+)(?:-(\\d+))?`));return d?d[2]?`${u} ${d[1]}.${d[2]}`:`${u} ${d[1]}`:u}const s=e??[],o=s.find(c=>c.id===t);if(o)return o.label;const a=s.find(c=>c.id&&t.toLowerCase().includes(c.id.toLowerCase()));return a?a.label:t}function rae(e,t){var m,v,w,x;const{models:n,modes:r,configSchema:i}=t,s=e.resolvedModel??e.model,o=tae(s,n,i),a=o.options,l=a.some(_=>_.value===e.effort)?e.effort:o.defaultValue,c=e.effort===""&&e.resolvedEffort?((m=a.find(_=>_.value===e.resolvedEffort))==null?void 0:m.label)??e.resolvedEffort:((v=a.find(_=>_.value===l))==null?void 0:v.label)??null,u=((w=i.find(_=>_.name==="permissionMode"))==null?void 0:w.default)??"",d=r.some(_=>_.id===e.permissionMode)?e.permissionMode:u,p=d===u?null:((x=r.find(_=>_.id===d))==null?void 0:x.label)??null;return{modelLabel:nae(n,s),effortOptions:a,effortValue:l,effortLabel:c,modeValue:d,modeLabel:p,modeTone:p===null?null:d==="bypassPermissions"?"danger":"info"}}function iae({models:e=[],modes:t=[],configSchema:n=[],model:r,resolvedModel:i,resolvedEffort:s,effort:o,permissionMode:a,onPatch:l}){var p;const c=rae({model:r,resolvedModel:i,resolvedEffort:s,effort:o,permissionMode:a},{models:e,modes:t,configSchema:n}),u=i??r,d=e.map(m=>{const v=m.id===""&&i?`${m.description?`${m.description};`:""}当前:${i}`:m.description;return{value:m.id,label:m.label,...v?{description:v}:{}}}),f=t.map(m=>({value:m.id,label:m.label,...m.description?{description:m.description}:{}}));return h.jsxs(ky,{children:[h.jsx(Cy,{asChild:!0,children:h.jsxs("button",{type:"button","data-testid":"session-config-chip",title:"Model / reasoning effort / permission mode",className:"inline-flex items-center gap-1 h-7 px-2.5 rounded-full text-[11px] text-text-400 transition-colors outline-none cursor-pointer hover:bg-text-100/5 hover:text-text-200 data-[state=open]:bg-text-100/5",children:[h.jsx("span",{className:"truncate max-w-[120px]","data-testid":"session-config-chip-model",children:u||c.modelLabel}),c.effortLabel?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-500",children:"·"}),h.jsx("span",{className:"truncate max-w-[80px]","data-testid":"session-config-chip-effort",children:c.effortLabel})]}):null,c.modeLabel?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-500",children:"·"}),h.jsx("span",{"data-testid":"session-config-chip-mode","data-tone":c.modeTone,className:re("font-semibold",c.modeTone==="danger"?"text-red-400":"text-blue-400"),children:c.modeLabel})]}):null]})}),h.jsxs(wp,{side:"top",align:"end",className:"w-[230px]","data-testid":"session-config-menu",children:[h.jsx(Ag,{testid:"session-config-model",label:"Model",current:r,currentLabel:c.modelLabel,options:d,onSelect:m=>l({model:m})}),h.jsx(Ag,{testid:"session-config-effort",label:"Reasoning effort",current:c.effortValue,currentLabel:c.effortLabel??"—",options:c.effortOptions,onSelect:m=>l({effort:m})}),f.length>0?h.jsx(Ag,{testid:"session-config-mode",label:"Permission mode",current:c.modeValue,currentLabel:((p=t.find(m=>m.id===c.modeValue))==null?void 0:p.label)??"—",currentTone:c.modeTone,options:f,onSelect:m=>l({permissionMode:m})}):null]})]})}function Ag({testid:e,label:t,current:n,currentLabel:r,currentTone:i,options:s,onSelect:o}){const a=s.length===0;return h.jsxs(nW,{children:[h.jsxs(MR,{"data-testid":e,disabled:a,className:"gap-2 text-[12px]",children:[h.jsx("span",{className:"flex-1 text-text-200",children:t}),h.jsx("span",{className:re("truncate max-w-[100px]",i==="danger"?"text-red-400 font-semibold":i==="info"?"text-blue-400 font-semibold":"text-text-400"),children:r}),h.jsx(Bn,{className:"w-3.5 h-3.5 shrink-0 text-text-500"})]}),h.jsx(AR,{className:"w-[220px] max-h-[320px] overflow-y-auto",children:s.map(l=>{const c=l.value===n;return h.jsxs(Ri,{"data-testid":`${e}-option-${l.value||"default"}`,onSelect:()=>o(l.value),className:"items-start gap-2",children:[h.jsxs("span",{className:"flex-1 min-w-0",children:[h.jsx("span",{className:re("block text-[12px]",c?"text-text-100 font-medium":"text-text-300"),children:l.label}),l.description?h.jsx("span",{className:"block text-[11px] text-text-400 mt-0.5",children:l.description}):null]}),c?h.jsx(wl,{className:"w-3.5 h-3.5 shrink-0 text-accent mt-0.5"}):null]},l.value||"default")})})]})}function sae(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitBranch(t);i(l.branch??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{branch:r,loading:s,refresh:()=>void a()}}function oae(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitRoot(t);i(l.gitRoot??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{worktreeRoot:r,loading:s,refresh:()=>void a()}}function aae({api:e,session:t,focused:n,totalPanes:r,onFocus:i,onClose:s,onNewSession:o,onOpenConfig:a,onFork:l,onQuickAsk:c,className:u,viewerRole:d="owner",hideHeader:f}){const{capabilities:p}=f1(t.tool),[m,v]=g.useState(0),{branch:w}=sae(e,t.cwd,m),{worktreeRoot:x}=oae(e,t.cwd,m),_=r>1,y=S=>{e.sessionUpdate(t.sessionId,S).catch(C=>{console.error("[session-config] session:update failed",t.sessionId,C)})};return h.jsxs("div",{className:`group/pane relative flex-1 ${u??"flex"} flex-row min-w-0 min-h-0 overflow-hidden ${_?`rounded-md border transition-colors ${n?"border-accent ring-1 ring-accent":"border-border"}`:""}`,onMouseDown:i,"data-testid":`session-pane-${t.sessionId}`,children:[h.jsx(Ly,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:h.jsx(uf,{id:"chat",minSize:"400px",children:h.jsx("div",{className:"flex flex-col min-w-0 min-h-0 h-full",children:h.jsx(lae,{api:e,session:t,liveGitBranch:w,liveWorktreeRoot:x,onNewSession:o,onTurnEnd:()=>v(S=>S+1),onOpenConfig:a,onFork:l,onQuickAsk:c,viewerRole:d,hideHeader:f,configSlot:p?h.jsx(iae,{models:p.models,modes:p.permissionModes,configSchema:p.configSchema,model:t.model??"",...t.resolvedModel?{resolvedModel:t.resolvedModel}:{},...t.resolvedEffort?{resolvedEffort:t.resolvedEffort}:{},effort:t.effort??"",permissionMode:t.permissionMode??"",onPatch:y}):null})})})}),_&&h.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),s()},className:"absolute top-1.5 right-1.5 z-10 p-1 rounded-md bg-bg-100/80 backdrop-blur-sm border border-border opacity-0 group-hover/pane:opacity-100 transition-opacity text-text-400 hover:text-text-100 hover:bg-bg-200","aria-label":"close pane","data-testid":`session-pane-close-${t.sessionId}`,children:h.jsx(Ir,{className:"w-3.5 h-3.5"})})]})}function lae({api:e,session:t,liveGitBranch:n,liveWorktreeRoot:r,onNewSession:i,onTurnEnd:s,onOpenConfig:o,onFork:a,onQuickAsk:l,viewerRole:c,configSlot:u,hideHeader:d}){return h.jsx(eae,{extras:{session:t,api:e,...n!==void 0?{liveGitBranch:n}:{},...r!==void 0?{liveWorktreeRoot:r}:{},onNewSession:i,onTurnEnd:s,onOpenConfig:o,...a?{onFork:f=>{a(f)}}:{},...l?{onQuickAsk:f=>{l(f)}}:{},...c?{viewerRole:c}:{},...u?{configSlot:u}:{},...d?{hideHeader:d}:{}}})}function cae({personas:e,sessions:t,api:n,selfPrincipalId:r,selectedPersonaId:i,selectedSessionId:s,selectedSession:o,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,onCloseSession:f}){return h.jsxs("div",{className:"flex h-screen min-h-0 bg-bg-50","data-testid":"guest-share-page",children:[h.jsx("aside",{className:"w-[280px] shrink-0 overflow-y-auto border-r border-border bg-bg-50",children:h.jsx(VW,{personas:e,sessions:t,activePersonaId:i,activeSessionId:s,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,showCopyResume:!1,treatSessionsAsRoots:!0,...r?{ownerPrincipalId:r}:{},isPersonaExpanded:()=>!0})}),h.jsx("main",{className:"flex-1 min-w-0 min-h-0 flex",children:o?h.jsx(aae,{api:n,session:o,focused:!0,totalPanes:1,onFocus:()=>{},onClose:f,onNewSession:()=>{},onOpenConfig:()=>{},viewerRole:"guest"}):h.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-xs text-text-400","data-testid":"guest-share-empty",children:"选择左侧 persona 开始对话"})})]})}function uae(){const e=_i(),t=g.useMemo(()=>new Y_(e),[e]),n=t$(e),{sessions:r,refresh:i}=n$(n),{personas:s}=pI(),o=l$(),a=g.useMemo(()=>{const S=window.location.pathname.match(/^\/s\/([^/]+)/);return S?decodeURIComponent(S[1]):null},[]),l=g.useMemo(()=>r.filter(S=>!S.ephemeral&&S.larkChatId==null),[r]),c=g.useMemo(()=>a?s.filter(S=>S.personaId===a):s,[s,a]),[u,d]=g.useState(null),[f,p]=g.useState(null),[m,v]=g.useState(null);g.useEffect(()=>{let S=!1;return e.request("whoami",{}).then(C=>{S||d(C.capability.id)}).catch(()=>{}),()=>{S=!0}},[e]),g.useEffect(()=>{a&&p(a)},[a]);const w=g.useCallback(async(S,C)=>{const k=await t.sessionCreate({ownerPersonaId:S,...C.trim()?{label:C.trim()}:{}});await i(),p(S),v(k.sessionId)},[t,i]),x=g.useCallback(async S=>{await t.sessionDelete(S),await i(),v(C=>C===S?null:C)},[t,i]),_=g.useCallback(async(S,C)=>{await t.sessionUpdate(S,{label:C.label}),await i()},[t,i]),y=g.useMemo(()=>l.find(S=>S.sessionId===m)??null,[l,m]);return h.jsx(X_.Provider,{value:o,children:h.jsx(cae,{personas:c,sessions:l,api:t,selfPrincipalId:u,selectedPersonaId:f,selectedSessionId:m,selectedSession:y,onSelectPersona:p,onSelectSession:v,onCreateSession:(S,C)=>void w(S,C),onDeleteSession:S=>void x(S),onEditSession:(S,C)=>void _(S,C),onCloseSession:()=>v(null)})})}const f2="https://app.ttcadvisory.com";function dae({onAuthed:e}){const[t,n]=g.useState(!1),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>()=>{s.current&&window.removeEventListener("message",s.current)},[]);const o=g.useCallback(()=>{s.current&&(window.removeEventListener("message",s.current),s.current=null),n(!0),i(null);const a=window.location.origin,l=`${f2}/auth/authorize?callback_url=${encodeURIComponent(a)}&auto=1`,c=async d=>{if(d.origin!==f2)return;const f=d.data;if((f==null?void 0:f.type)==="AUTH_CANCEL"){u(),n(!1);return}if(!((f==null?void 0:f.type)!=="AUTH_SUCCESS"||!f.token)){u();try{const p=await fetch(`${window.location.origin}/share/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ttcToken:f.token})});if(!p.ok){const v=await p.json().catch(()=>({}));throw new Error(v.code??`exchange failed (${p.status})`)}const m=await p.json();if(!m.visitorToken)throw new Error("no visitorToken in response");e(m.visitorToken)}catch(p){i(p instanceof Error?p.message:String(p)),n(!1)}}},u=()=>{window.removeEventListener("message",c),s.current=null};s.current=d=>void c(d),window.addEventListener("message",s.current),window.open(l,"ttc-login","width=480,height=640")},[e]);return h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 font-sans text-text-100","data-testid":"guest-login",children:h.jsxs("div",{className:"flex w-full max-w-xs flex-col gap-3 rounded-lg border border-border bg-bg-100 px-5 py-6",children:[h.jsx("h1",{className:"text-base font-semibold",children:"登录后进入分享"}),h.jsx("p",{className:"text-[11px] leading-snug text-text-400",children:"使用飞书账号登录,即可在浏览器里与分享给你的 persona 交互,无需安装。"}),r?h.jsxs("p",{className:"text-[11px] leading-snug text-error","data-testid":"guest-login-error",children:["登录失败:",r]}):null,h.jsx("button",{type:"button",disabled:t,onClick:()=>o(),"data-testid":"guest-login-button",className:"w-full rounded border border-border bg-bg-50 px-2 py-1.5 text-xs text-text-200 transition-colors hover:bg-text-100/5 hover:text-text-100 disabled:opacity-50",children:t?"请在弹窗中完成授权…":"飞书登录"})]})})}const Ax="clawd-visitor:token";function hae(e,t){const r=`${e.protocol==="https:"?"wss:":"ws:"}//${e.host}`;return t!=null&&t.devPath?`${r}${t.devPath}`:r}function fae(){return{async getUrl(e){const t=localStorage.getItem(Ax);if(!t)throw new Error("NO_VISITOR_TOKEN");const n=hae(window.location,{});return await sI(e).upsert({id:"guest",name:"访客",mode:"remote",url:n,token:t}),{url:n}}}}function pae(e){const t=n=>{document.documentElement.classList.toggle("dark",n==="dark")};return t(e.theme.mode),e.onThemeChange(n=>t(n.mode))}function mae(){const e=_i(),t=g.useMemo(()=>e$(e),[e]);return h.jsx(Lz,{cache:t.cache,children:h.jsx(Bz,{children:h.jsx(uae,{})})})}function gae({host:e}){const[t]=g.useState(()=>localStorage.getItem(Ax)),[n,r]=g.useState(!1),[i,s]=g.useState(null);return g.useEffect(()=>pae(e),[e]),g.useEffect(()=>{if(!t)return;let o=!1;return fae().getUrl(e).then(()=>{o||r(!0)}).catch(a=>{o||s(a instanceof Error?a.message:String(a))}),()=>{o=!0}},[e,t]),t?h.jsx(Fb,{host:e,children:h.jsx(yw,{children:i?h.jsxs("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-center text-xs text-error","data-testid":"guest-share-connect-error",children:["连接失败:",i]}):n?h.jsx(Mz,{host:e,children:h.jsx(mae,{})}):h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-xs text-text-400",children:"正在连接…"})})}):h.jsx(Fb,{host:e,children:h.jsx(yw,{children:h.jsx(dae,{onAuthed:o=>{localStorage.setItem(Ax,o),window.location.reload()}})})})}function vae({filePath:e,oldString:t,newString:n,content:r}){const i=g.useMemo(()=>r!=null?r.split(/\r?\n/).map(s=>({type:"add",text:s})):xae(t??"",n??""),[t,n,r]);return h.jsxs("div",{"data-testid":"inline-diff",className:"min-w-0 max-w-full rounded-lg border border-bg-300/60 bg-bg-50 overflow-hidden text-[12px] font-mono",children:[h.jsx("div",{className:"flex min-w-0 items-center gap-2 px-3 py-1.5 border-b border-bg-300/40 bg-bg-100/30",children:h.jsx("span",{className:"min-w-0 text-text-400 truncate",title:e,children:e})}),h.jsx("div",{className:"max-h-[320px] max-w-full overflow-auto",children:i.map((s,o)=>h.jsxs("div",{"data-testid":`diff-line-${s.type}`,className:re("flex min-w-max gap-2 px-3 py-0.5 whitespace-pre",s.type==="add"?"bg-success/10 text-success":s.type==="remove"?"bg-error/10 text-error":"text-text-300"),children:[h.jsx("span",{className:"w-3 shrink-0 select-none opacity-60",children:s.type==="add"?"+":s.type==="remove"?"-":" "}),h.jsx("span",{className:"flex-1",children:s.text||" "})]},o))})]})}function xae(e,t){const n=e.split(/\r?\n/),r=t.split(/\r?\n/),i=n.length,s=r.length,o=Array.from({length:i+1},()=>new Array(s+1).fill(0));for(let u=i-1;u>=0;u--)for(let d=s-1;d>=0;d--)o[u][d]=n[u]===r[d]?o[u+1][d+1]+1:Math.max(o[u+1][d],o[u][d+1]);const a=[];let l=0,c=0;for(;l<i&&c<s;)n[l]===r[c]?(a.push({type:"equal",text:n[l]}),l++,c++):o[l+1][c]>=o[l][c+1]?(a.push({type:"remove",text:n[l]}),l++):(a.push({type:"add",text:r[c]}),c++);for(;l<i;)a.push({type:"remove",text:n[l++]});for(;c<s;)a.push({type:"add",text:r[c++]});return a}function _ae({items:e}){return e.length===0?null:h.jsxs("div",{"data-testid":"todo-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-1.5",children:"Todos"}),h.jsx("ul",{className:"flex flex-col gap-1",children:e.map((t,n)=>{const r=t.status==="in_progress"&&t.activeForm||t.content;return h.jsxs("li",{"data-testid":`todo-item-${t.status}`,className:"flex items-start gap-2",children:[h.jsx(yae,{status:t.status}),h.jsx("span",{className:re("flex-1 leading-snug",t.status==="completed"?"text-text-400 line-through":t.status==="in_progress"?"text-text-100 font-medium":"text-text-200"),children:r})]},n)})})]})}function yae({status:e}){return e==="completed"?h.jsx(cp,{className:"w-3.5 h-3.5 text-success mt-0.5 shrink-0"}):e==="in_progress"?h.jsx(Ln,{className:"w-3.5 h-3.5 text-warning mt-0.5 shrink-0 animate-spin"}):h.jsx(_I,{className:"w-3.5 h-3.5 text-text-400 mt-0.5 shrink-0"})}function bae(e){const t=e??{};return Array.isArray(t.todos)?t.todos.map(n=>{if(!n||typeof n!="object")return null;const r=n,i=typeof r.content=="string"?r.content:"",s=r.status==="pending"||r.status==="in_progress"||r.status==="completed"?r.status:"pending",o=typeof r.activeForm=="string"?r.activeForm:void 0;return{content:i,status:s,activeForm:o}}).filter(n=>n!==null):[]}function wae({description:e,prompt:t,subagentType:n}){return h.jsxs("div",{"data-testid":"task-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsxs("div",{className:"flex items-center gap-2 text-text-200 font-medium",children:[h.jsx(lp,{className:"w-3.5 h-3.5 text-accent shrink-0"}),h.jsx("span",{className:"truncate",children:e||"subagent task"}),n?h.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded-md text-[10px] font-mono bg-accent/10 text-accent",children:n}):null]}),t?h.jsx("div",{className:"mt-1 text-[12px] text-text-400 leading-snug line-clamp-3",children:t}):null]})}function Sae(e){const t=e??{};return{description:typeof t.description=="string"?t.description:"",prompt:typeof t.prompt=="string"?t.prompt:void 0,subagentType:typeof t.subagent_type=="string"?t.subagent_type:void 0}}const kae={render:({input:e})=>Qe.createElement(_ae,{items:bae(e)})},Cae={render:({input:e})=>{const{description:t,prompt:n,subagentType:r}=Sae(e);return Qe.createElement(wae,{description:t,prompt:n,subagentType:r})}},x3={render:({input:e,output:t,error:n,pending:r,fileScope:i,onShareFile:s,onOpenInTab:o,onPreviewMarkdown:a})=>{const l=Nae(e),c=l?Qe.createElement(vae,{filePath:l.filePath,oldString:l.oldString,newString:l.newString,content:l.content}):void 0;return Qe.createElement(PM,{tool:Eae(e),input:e,output:t,error:n,pending:r,expandedBody:c,...i?{fileScope:i}:{},...s?{onShareFile:s}:{},...o?{onOpenInTab:o}:{},...a?{onPreviewMarkdown:a}:{}})}};function Eae(e){const t=e??{};return"content"in t&&t.content!==void 0?"Write":("old_string"in t&&t.old_string!==void 0,"Edit")}function Nae(e){const t=e??{},n=typeof t.file_path=="string"?t.file_path:null;if(!n)return null;const r=typeof t.old_string=="string"?t.old_string:void 0,i=typeof t.new_string=="string"?t.new_string:void 0,s=typeof t.content=="string"?t.content:void 0;return r==null&&i==null&&s==null?null:{filePath:n,oldString:r,newString:i,content:s}}Nl.register("claude","TodoWrite",kae);Nl.register("claude","Task",Cae);Nl.register("claude","Edit",x3);Nl.register("claude","Write",x3);const _3=document.getElementById("root");if(!_3)throw new Error("guest-main: #root not found");const Tae=Jj({});jg.createRoot(_3).render(h.jsx(Qe.StrictMode,{children:h.jsx(gae,{host:Tae})}));