@clawos-dev/clawd 0.2.245 → 0.2.247
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.
|
@@ -92,7 +92,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
92
92
|
0 -6px 16px 0 rgba(0, 0, 0, 0.08),
|
|
93
93
|
0 -3px 6px -4px rgba(0, 0, 0, 0.12),
|
|
94
94
|
0 -9px 28px 8px rgba(0, 0, 0, 0.05)
|
|
95
|
-
`,boxShadowTabsOverflowLeft:"inset 10px 0 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowRight:"inset -10px 0 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowTop:"inset 0 10px 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowBottom:"inset 0 -10px 8px -8px rgba(0, 0, 0, 0.08)"}),r)}var nb=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};const eD={lineHeight:!0,lineHeightSM:!0,lineHeightLG:!0,lineHeightHeading1:!0,lineHeightHeading2:!0,lineHeightHeading3:!0,lineHeightHeading4:!0,lineHeightHeading5:!0,opacityLoading:!0,fontWeightStrong:!0,zIndexPopupBase:!0,zIndexBase:!0,opacityImage:!0},tD={motionBase:!0,motionUnit:!0},nD={screenXS:!0,screenXSMin:!0,screenXSMax:!0,screenSM:!0,screenSMMin:!0,screenSMMax:!0,screenMD:!0,screenMDMin:!0,screenMDMax:!0,screenLG:!0,screenLGMin:!0,screenLGMax:!0,screenXL:!0,screenXLMin:!0,screenXLMax:!0,screenXXL:!0,screenXXLMin:!0},UE=(e,t,n)=>{const r=n.getDerivativeToken(e),{override:i}=t,s=nb(t,["override"]);let o=Object.assign(Object.assign({},r),{override:i});return o=HE(o),s&&Object.entries(s).forEach(([a,l])=>{const{theme:c}=l,u=nb(l,["theme"]);let d=u;c&&(d=UE(Object.assign(Object.assign({},o),u),{override:u},c)),o[a]=d}),o};function WE(){const{token:e,hashed:t,theme:n,override:r,cssVar:i}=st.useContext($E),s=`${Q4}-${t||""}`,o=n||zE,[a,l,c]=H3(o,[Ec,e],{salt:s,override:r,getComputedToken:UE,formatToken:HE,cssVar:i&&{prefix:i.prefix,key:i.key,unitless:eD,ignore:tD,preserve:nD}});return[o,c,t?l:"",a,i]}const rD=()=>({display:"inline-flex",alignItems:"center",color:"inherit",fontStyle:"normal",lineHeight:0,textAlign:"center",textTransform:"none",verticalAlign:"-0.125em",textRendering:"optimizeLegibility","-webkit-font-smoothing":"antialiased","-moz-osx-font-smoothing":"grayscale","> *":{lineHeight:1},svg:{display:"inline-block"}}),iD=e=>({[`.${e}`]:Object.assign(Object.assign({},rD()),{[`.${e} .${e}-icon`]:{display:"block"}})}),sD=(e,t)=>{const[n,r]=WE();return g4({token:r,hashId:"",path:["ant-design-icons",e],nonce:()=>t==null?void 0:t.nonce,layer:{name:"antd"}},()=>iD(e))},oD=Object.assign({},Fa),{useId:rb}=oD,aD=()=>"",lD=typeof rb>"u"?aD:rb;function cD(e,t,n){var r;const i=e||{},s=i.inherit===!1||!t?Object.assign(Object.assign({},vh),{hashed:(r=t==null?void 0:t.hashed)!==null&&r!==void 0?r:vh.hashed,cssVar:t==null?void 0:t.cssVar}):t,o=lD();return lE(()=>{var a,l;if(!e)return t;const c=Object.assign({},s.components);Object.keys(e.components||{}).forEach(f=>{c[f]=Object.assign(Object.assign({},c[f]),e.components[f])});const u=`css-var-${o.replace(/:/g,"")}`,d=((a=i.cssVar)!==null&&a!==void 0?a:s.cssVar)&&Object.assign(Object.assign(Object.assign({prefix:n==null?void 0:n.prefixCls},typeof s.cssVar=="object"?s.cssVar:{}),typeof i.cssVar=="object"?i.cssVar:{}),{key:typeof i.cssVar=="object"&&((l=i.cssVar)===null||l===void 0?void 0:l.key)||u});return Object.assign(Object.assign(Object.assign({},s),i),{token:Object.assign(Object.assign({},s.token),i.token),components:c,cssVar:d})},[i,s],(a,l)=>a.some((c,u)=>{const d=l[u];return!g3(c,d,!0)}))}var uD=["children"],VE=g.createContext({});function dD(e){var t=e.children,n=zg(e,uD);return g.createElement(VE.Provider,{value:n},t)}var hD=function(e){uE(n,e);var t=hE(n);function n(){return Wa(this,n),t.apply(this,arguments)}return Va(n,[{key:"render",value:function(){return this.props.children}}]),n}(g.Component);function fD(e){var t=g.useReducer(function(a){return a+1},0),n=Ze(t,2),r=n[1],i=g.useRef(e),s=av(function(){return i.current}),o=av(function(a){i.current=typeof a=="function"?a(i.current):a,r()});return[s,o]}var Qi="none",$u="appear",Fu="enter",Hu="leave",ib="none",Tr="prepare",aa="start",la="active",O_="end",qE="prepared";function sb(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit".concat(e)]="webkit".concat(t),n["Moz".concat(e)]="moz".concat(t),n["ms".concat(e)]="MS".concat(t),n["O".concat(e)]="o".concat(t.toLowerCase()),n}function pD(e,t){var n={animationend:sb("Animation","AnimationEnd"),transitionend:sb("Transition","TransitionEnd")};return e&&("AnimationEvent"in t||delete n.animationend.animation,"TransitionEvent"in t||delete n.transitionend.transition),n}var mD=pD(Li(),typeof window<"u"?window:{}),KE={};if(Li()){var gD=document.createElement("div");KE=gD.style}var Uu={};function GE(e){if(Uu[e])return Uu[e];var t=mD[e];if(t)for(var n=Object.keys(t),r=n.length,i=0;i<r;i+=1){var s=n[i];if(Object.prototype.hasOwnProperty.call(t,s)&&s in KE)return Uu[e]=t[s],Uu[e]}return""}var XE=GE("animationend"),YE=GE("transitionend"),ZE=!!(XE&&YE),ob=XE||"animationend",ab=YE||"transitionend";function lb(e,t){if(!e)return null;if(Ct(e)==="object"){var n=t.replace(/-\w/g,function(r){return r[1].toUpperCase()});return e[n]}return"".concat(e,"-").concat(t)}const vD=function(e){var t=g.useRef();function n(i){i&&(i.removeEventListener(ab,e),i.removeEventListener(ob,e))}function r(i){t.current&&t.current!==i&&n(t.current),i&&i!==t.current&&(i.addEventListener(ab,e),i.addEventListener(ob,e),t.current=i)}return g.useEffect(function(){return function(){n(t.current)}},[]),[r,n]};var QE=Li()?g.useLayoutEffect:g.useEffect;const _D=function(){var e=g.useRef(null);function t(){Og.cancel(e.current)}function n(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;t();var s=Og(function(){i<=1?r({isCanceled:function(){return s!==e.current}}):n(r,i-1)});e.current=s}return g.useEffect(function(){return function(){t()}},[]),[n,t]};var xD=[Tr,aa,la,O_],yD=[Tr,qE],JE=!1,bD=!0;function eN(e){return e===la||e===O_}const wD=function(e,t,n){var r=lv(ib),i=Ze(r,2),s=i[0],o=i[1],a=_D(),l=Ze(a,2),c=l[0],u=l[1];function d(){o(Tr,!0)}var f=t?yD:xD;return QE(function(){if(s!==ib&&s!==O_){var p=f.indexOf(s),m=f[p+1],v=n(s);v===JE?o(m,!0):m&&c(function(y){function _(){y.isCanceled()||o(m,!0)}v===!0?_():Promise.resolve(v).then(_)})}},[e,s]),g.useEffect(function(){return function(){u()}},[]),[d,s]};function SD(e,t,n,r){var i=r.motionEnter,s=i===void 0?!0:i,o=r.motionAppear,a=o===void 0?!0:o,l=r.motionLeave,c=l===void 0?!0:l,u=r.motionDeadline,d=r.motionLeaveImmediately,f=r.onAppearPrepare,p=r.onEnterPrepare,m=r.onLeavePrepare,v=r.onAppearStart,y=r.onEnterStart,_=r.onLeaveStart,x=r.onAppearActive,b=r.onEnterActive,w=r.onLeaveActive,S=r.onAppearEnd,k=r.onEnterEnd,T=r.onLeaveEnd,N=r.onVisibleChanged,O=lv(),P=Ze(O,2),L=P[0],R=P[1],I=fD(Qi),j=Ze(I,2),B=j[0],$=j[1],F=lv(null),A=Ze(F,2),D=A[0],C=A[1],H=B(),q=g.useRef(!1),M=g.useRef(null);function ne(){return n()}var oe=g.useRef(!1);function V(){$(Qi),C(null,!0)}var pe=av(function(Ue){var tt=B();if(tt!==Qi){var mt=ne();if(!(Ue&&!Ue.deadline&&Ue.target!==mt)){var Xt=oe.current,pn;tt===$u&&Xt?pn=S==null?void 0:S(mt,Ue):tt===Fu&&Xt?pn=k==null?void 0:k(mt,Ue):tt===Hu&&Xt&&(pn=T==null?void 0:T(mt,Ue)),Xt&&pn!==!1&&V()}}}),Oe=vD(pe),re=Ze(Oe,1),Me=re[0],Fe=function(tt){switch(tt){case $u:return be(be(be({},Tr,f),aa,v),la,x);case Fu:return be(be(be({},Tr,p),aa,y),la,b);case Hu:return be(be(be({},Tr,m),aa,_),la,w);default:return{}}},We=g.useMemo(function(){return Fe(H)},[H]),ge=wD(H,!e,function(Ue){if(Ue===Tr){var tt=We[Tr];return tt?tt(ne()):JE}if(wt in We){var mt;C(((mt=We[wt])===null||mt===void 0?void 0:mt.call(We,ne(),null))||null)}return wt===la&&H!==Qi&&(Me(ne()),u>0&&(clearTimeout(M.current),M.current=setTimeout(function(){pe({deadline:!0})},u))),wt===qE&&V(),bD}),Ge=Ze(ge,2),Gt=Ge[0],wt=Ge[1],It=eN(wt);oe.current=It;var ln=g.useRef(null);QE(function(){if(!(q.current&&ln.current===t)){R(t);var Ue=q.current;q.current=!0;var tt;!Ue&&t&&a&&(tt=$u),Ue&&t&&s&&(tt=Fu),(Ue&&!t&&c||!Ue&&d&&!t&&c)&&(tt=Hu);var mt=Fe(tt);tt&&(e||mt[Tr])?($(tt),Gt()):$(Qi),ln.current=t}},[t]),g.useEffect(function(){(H===$u&&!a||H===Fu&&!s||H===Hu&&!c)&&$(Qi)},[a,s,c]),g.useEffect(function(){return function(){q.current=!1,clearTimeout(M.current)}},[]);var Bt=g.useRef(!1);g.useEffect(function(){L&&(Bt.current=!0),L!==void 0&&H===Qi&&((Bt.current||L)&&(N==null||N(L)),Bt.current=!0)},[L,H]);var at=D;return We[Tr]&&wt===aa&&(at=Be({transition:"none"},at)),[H,wt,at,L??t]}function kD(e){var t=e;Ct(e)==="object"&&(t=e.transitionSupport);function n(i,s){return!!(i.motionName&&t&&s!==!1)}var r=g.forwardRef(function(i,s){var o=i.visible,a=o===void 0?!0:o,l=i.removeOnLeave,c=l===void 0?!0:l,u=i.forceRender,d=i.children,f=i.motionName,p=i.leavedClassName,m=i.eventProps,v=g.useContext(VE),y=v.motion,_=n(i,y),x=g.useRef(),b=g.useRef();function w(){try{return x.current instanceof HTMLElement?x.current:Jj(b.current)}catch{return null}}var S=SD(_,a,w,i),k=Ze(S,4),T=k[0],N=k[1],O=k[2],P=k[3],L=g.useRef(P);P&&(L.current=!0);var R=g.useCallback(function(A){x.current=A,r3(s,A)},[s]),I,j=Be(Be({},m),{},{visible:a});if(!d)I=null;else if(T===Qi)P?I=d(Be({},j),R):!c&&L.current&&p?I=d(Be(Be({},j),{},{className:p}),R):u||!c&&!p?I=d(Be(Be({},j),{},{style:{display:"none"}}),R):I=null;else{var B;N===Tr?B="prepare":eN(N)?B="active":N===aa&&(B="start");var $=lb(f,"".concat(T,"-").concat(B));I=d(Be(Be({},j),{},{className:Fj(lb(f,T),be(be({},$,$&&B),f,typeof f=="string")),style:O}),R)}if(g.isValidElement(I)&&i3(I)){var F=s3(I);F||(I=g.cloneElement(I,{ref:R}))}return g.createElement(hD,{ref:b},I)});return r.displayName="CSSMotion",r}const CD=kD(ZE);var cv="add",uv="keep",dv="remove",Up="removed";function ED(e){var t;return e&&Ct(e)==="object"&&"key"in e?t=e:t={key:e},Be(Be({},t),{},{key:String(t.key)})}function hv(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return e.map(ED)}function ND(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=[],r=0,i=t.length,s=hv(e),o=hv(t);s.forEach(function(c){for(var u=!1,d=r;d<i;d+=1){var f=o[d];if(f.key===c.key){r<d&&(n=n.concat(o.slice(r,d).map(function(p){return Be(Be({},p),{},{status:cv})})),r=d),n.push(Be(Be({},f),{},{status:uv})),r+=1,u=!0;break}}u||n.push(Be(Be({},c),{},{status:dv}))}),r<i&&(n=n.concat(o.slice(r).map(function(c){return Be(Be({},c),{},{status:cv})})));var a={};n.forEach(function(c){var u=c.key;a[u]=(a[u]||0)+1});var l=Object.keys(a).filter(function(c){return a[c]>1});return l.forEach(function(c){n=n.filter(function(u){var d=u.key,f=u.status;return d!==c||f!==dv}),n.forEach(function(u){u.key===c&&(u.status=uv)})}),n}var TD=["component","children","onVisibleChanged","onAllRemoved"],PD=["status"],RD=["eventProps","visible","children","motionName","motionAppear","motionEnter","motionLeave","motionLeaveImmediately","motionDeadline","removeOnLeave","leavedClassName","onAppearPrepare","onAppearStart","onAppearActive","onAppearEnd","onEnterStart","onEnterActive","onEnterEnd","onLeaveStart","onLeaveActive","onLeaveEnd"];function ID(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:CD,n=function(r){uE(s,r);var i=hE(s);function s(){var o;Wa(this,s);for(var a=arguments.length,l=new Array(a),c=0;c<a;c++)l[c]=arguments[c];return o=i.call.apply(i,[this].concat(l)),be(Dg(o),"state",{keyEntities:[]}),be(Dg(o),"removeKey",function(u){o.setState(function(d){var f=d.keyEntities.map(function(p){return p.key!==u?p:Be(Be({},p),{},{status:Up})});return{keyEntities:f}},function(){var d=o.state.keyEntities,f=d.filter(function(p){var m=p.status;return m!==Up}).length;f===0&&o.props.onAllRemoved&&o.props.onAllRemoved()})}),o}return Va(s,[{key:"render",value:function(){var a=this,l=this.state.keyEntities,c=this.props,u=c.component,d=c.children,f=c.onVisibleChanged;c.onAllRemoved;var p=zg(c,TD),m=u||g.Fragment,v={};return RD.forEach(function(y){v[y]=p[y],delete p[y]}),delete p.keys,g.createElement(m,p,l.map(function(y,_){var x=y.status,b=zg(y,PD),w=x===cv||x===uv;return g.createElement(t,ph({},v,{key:b.key,visible:w,eventProps:b,onVisibleChanged:function(k){f==null||f(k,{key:b.key}),k||a.removeKey(b.key)}}),function(S,k){return d(Be(Be({},S),{},{index:_}),k)})}))}}],[{key:"getDerivedStateFromProps",value:function(a,l){var c=a.keys,u=l.keyEntities,d=hv(c),f=ND(u,d);return{keyEntities:f.filter(function(p){var m=u.find(function(v){var y=v.key;return p.key===y});return!(m&&m.status===Up&&p.status===dv)})}}}]),s}(g.Component);return be(n,"defaultProps",{component:"div"}),n}ID(ZE);const cb=g.createContext(!0);function MD(e){const t=g.useContext(cb),{children:n}=e,[,r]=WE(),{motion:i}=r,s=g.useRef(!1);return s.current||(s.current=t!==i),s.current?g.createElement(cb.Provider,{value:i},g.createElement(dD,{motion:i},n)):n}const AD=()=>null;var jD=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};const DD=["getTargetContainer","getPopupContainer","renderEmpty","input","pagination","form","select","button"];let tN;function LD(){return tN||sv}function OD(e){return Object.keys(e).some(t=>t.endsWith("Color"))}const BD=e=>{const{prefixCls:t,iconPrefixCls:n,theme:r,holderRender:i}=e;t!==void 0&&(tN=t),r&&OD(r)&&q4(LD(),r)},zD=e=>{const{children:t,csp:n,autoInsertSpaceInButton:r,alert:i,anchor:s,form:o,locale:a,componentSize:l,direction:c,space:u,splitter:d,virtual:f,dropdownMatchSelectWidth:p,popupMatchSelectWidth:m,popupOverflow:v,legacyLocale:y,parentContext:_,iconPrefixCls:x,theme:b,componentDisabled:w,segmented:S,statistic:k,spin:T,calendar:N,carousel:O,cascader:P,collapse:L,typography:R,checkbox:I,descriptions:j,divider:B,drawer:$,skeleton:F,steps:A,image:D,layout:C,list:H,mentions:q,modal:M,progress:ne,result:oe,slider:V,breadcrumb:pe,menu:Oe,pagination:re,input:Me,textArea:Fe,empty:We,badge:ge,radio:Ge,rate:Gt,switch:wt,transfer:It,avatar:ln,message:Bt,tag:at,table:Ue,card:tt,tabs:mt,timeline:Xt,timePicker:pn,upload:U,notification:Z,tree:ve,colorPicker:we,datePicker:Q,rangePicker:Xe,flex:Yt,wave:Zt,dropdown:ue,warning:Ne,tour:Qe,tooltip:Dn,popover:Qt,popconfirm:nl,floatButton:Ao,floatButtonGroup:gu,variant:vu,inputNumber:op,treeSelect:ap}=e,_u=g.useCallback((Tt,$t)=>{const{prefixCls:or}=e;if($t)return $t;const Ln=or||_.getPrefixCls("");return Tt?`${Ln}-${Tt}`:Ln},[_.getPrefixCls,e.prefixCls]),jo=x||_.iconPrefixCls||FE,Do=n||_.csp;sD(jo,Do);const rl=cD(b,_.theme,{prefixCls:_u("")}),il={csp:Do,autoInsertSpaceInButton:r,alert:i,anchor:s,locale:a||y,direction:c,space:u,splitter:d,virtual:f,popupMatchSelectWidth:m??p,popupOverflow:v,getPrefixCls:_u,iconPrefixCls:jo,theme:rl,segmented:S,statistic:k,spin:T,calendar:N,carousel:O,cascader:P,collapse:L,typography:R,checkbox:I,descriptions:j,divider:B,drawer:$,skeleton:F,steps:A,image:D,input:Me,textArea:Fe,layout:C,list:H,mentions:q,modal:M,progress:ne,result:oe,slider:V,breadcrumb:pe,menu:Oe,pagination:re,empty:We,badge:ge,radio:Ge,rate:Gt,switch:wt,transfer:It,avatar:ln,message:Bt,tag:at,table:Ue,card:tt,tabs:mt,timeline:Xt,timePicker:pn,upload:U,notification:Z,tree:ve,colorPicker:we,datePicker:Q,rangePicker:Xe,flex:Yt,wave:Zt,dropdown:ue,warning:Ne,tour:Qe,tooltip:Dn,popover:Qt,popconfirm:nl,floatButton:Ao,floatButtonGroup:gu,variant:vu,inputNumber:op,treeSelect:ap},Ui=Object.assign({},_);Object.keys(il).forEach(Tt=>{il[Tt]!==void 0&&(Ui[Tt]=il[Tt])}),DD.forEach(Tt=>{const $t=e[Tt];$t&&(Ui[Tt]=$t)}),typeof r<"u"&&(Ui.button=Object.assign({autoInsertSpace:r},Ui.button));const Wi=lE(()=>Ui,Ui,(Tt,$t)=>{const or=Object.keys(Tt),Ln=Object.keys($t);return or.length!==Ln.length||or.some(Y=>Tt[Y]!==$t[Y])}),{layer:sl}=g.useContext(kf),xu=g.useMemo(()=>({prefixCls:jo,csp:Do,layer:sl?"antd":void 0}),[jo,Do,sl]);let zt=g.createElement(g.Fragment,null,g.createElement(AD,{dropdownMatchSelectWidth:p}),t);const ol=g.useMemo(()=>{var Tt,$t,or,Ln;return k4(((Tt=Nf.Form)===null||Tt===void 0?void 0:Tt.defaultValidateMessages)||{},((or=($t=Wi.locale)===null||$t===void 0?void 0:$t.Form)===null||or===void 0?void 0:or.defaultValidateMessages)||{},((Ln=Wi.form)===null||Ln===void 0?void 0:Ln.validateMessages)||{},(o==null?void 0:o.validateMessages)||{})},[Wi,o==null?void 0:o.validateMessages]);Object.keys(ol).length>0&&(zt=g.createElement(E4.Provider,{value:ol},zt)),a&&(zt=g.createElement(P4,{locale:a,_ANT_MARK__:T4},zt)),zt=g.createElement(y4.Provider,{value:xu},zt),l&&(zt=g.createElement(G4,{size:l},zt)),zt=g.createElement(MD,null,zt);const al=g.useMemo(()=>{const Tt=rl||{},{algorithm:$t,token:or,components:Ln,cssVar:Y}=Tt,_e=jD(Tt,["algorithm","token","components","cssVar"]),xe=$t&&(!Array.isArray($t)||$t.length>0)?Fg($t):zE,Ye={};Object.entries(Ln||{}).forEach(([oA,aA])=>{const hi=Object.assign({},aA);"algorithm"in hi&&(hi.algorithm===!0?hi.theme=xe:(Array.isArray(hi.algorithm)||typeof hi.algorithm=="function")&&(hi.theme=Fg(hi.algorithm)),delete hi.algorithm),Ye[oA]=hi});const di=Object.assign(Object.assign({},Ec),or);return Object.assign(Object.assign({},_e),{theme:xe,token:di,components:Ye,override:Object.assign({override:di},Ye),cssVar:Y})},[rl]);return b&&(zt=g.createElement($E.Provider,{value:al},zt)),Wi.warning&&(zt=g.createElement(C4.Provider,{value:Wi.warning},zt)),w!==void 0&&(zt=g.createElement(K4,{disabled:w},zt)),g.createElement(Tf.Provider,{value:Wi},zt)},Ka=e=>{const t=g.useContext(Tf),n=g.useContext(DE);return g.createElement(zD,Object.assign({parentContext:t,legacyLocale:n},e))};Ka.ConfigContext=Tf;Ka.SizeContext=Nc;Ka.config=BD;Ka.useConfig=X4;Object.defineProperty(Ka,"SizeContext",{get:()=>Nc});const lr=(e,t)=>new xt(e).setA(t).toRgbString(),Bo=(e,t)=>new xt(e).lighten(t).toHexString(),$D=e=>{const t=Ma(e,{theme:"dark"});return{1:t[0],2:t[1],3:t[2],4:t[3],5:t[6],6:t[5],7:t[4],8:t[6],9:t[5],10:t[4]}},FD=(e,t)=>{const n=e||"#000",r=t||"#fff";return{colorBgBase:n,colorTextBase:r,colorText:lr(r,.85),colorTextSecondary:lr(r,.65),colorTextTertiary:lr(r,.45),colorTextQuaternary:lr(r,.25),colorFill:lr(r,.18),colorFillSecondary:lr(r,.12),colorFillTertiary:lr(r,.08),colorFillQuaternary:lr(r,.04),colorBgSolid:lr(r,.95),colorBgSolidHover:lr(r,1),colorBgSolidActive:lr(r,.9),colorBgElevated:Bo(n,12),colorBgContainer:Bo(n,8),colorBgLayout:Bo(n,0),colorBgSpotlight:Bo(n,26),colorBgBlur:lr(r,.04),colorBorder:Bo(n,26),colorBorderSecondary:Bo(n,19)}},HD=(e,t)=>{const n=Object.keys(D_).map(s=>{const o=Ma(e[s],{theme:"dark"});return Array.from({length:10},()=>1).reduce((a,l,c)=>(a[`${s}-${c+1}`]=o[c],a[`${s}${c+1}`]=o[c],a),{})}).reduce((s,o)=>(s=Object.assign(Object.assign({},s),o),s),{}),r=t??L_(e),i=BE(e,{generateColorPalettes:$D,generateNeutralColorPalettes:FD});return Object.assign(Object.assign(Object.assign(Object.assign({},r),n),i),{colorPrimaryBg:i.colorPrimaryBorder,colorPrimaryBgHover:i.colorPrimaryBorderHover})},ub={defaultSeed:vh.token,defaultAlgorithm:L_,darkAlgorithm:HD};function db({children:e}){const t=N_(),[n,r]=g.useState(t.theme);return g.useEffect(()=>t.onThemeChange(r),[t]),h.jsx(Ka,{theme:{algorithm:n.mode==="dark"?ub.darkAlgorithm:ub.defaultAlgorithm,token:{colorPrimary:n.colorPrimary,colorBgContainer:n.colorBgContainer,colorText:n.colorText,colorBorder:n.colorBorder}},children:e})}const nN=["ready","session:info","session:status","session:event","session:deleted","session:rewound","session:cleared","permission:request","session:question","session:question:cleared","pong","error","subscribed","unsubscribed","auth:ok","tunnel:ready","tunnel:exited","tunnel:unavailable","session:control","session:pty","capability:tokenDeleted","contact:added","contact:pinned","contact:removed","contact:remote-access-updated","inbox:event","friend:reverseTokenOffered","auth:login:done","auth:login:failed","appBuilder:project-updated","appBuilder:publish-progress","appBuilder:publish-failed"],rN=["idle","running","running-idle","stopped","error","observing"],UD=["task-notification","slash-command","local-command","system-reminder","skill-hint","meta-text","attachment-skills","attachment-deferred-tools"],WD=["builtin","global","project","plugin"],VD=["builtin","global","project","policy","plugin"];var qe;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},e.getValidEnumValues=i=>{const s=e.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(const a of s)o[a]=i[a];return e.objectValues(o)},e.objectValues=i=>e.objectKeys(i).map(function(s){return i[s]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},e.find=(i,s)=>{for(const o of i)if(s(o))return o},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}e.joinValues=r,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(qe||(qe={}));var hb;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(hb||(hb={}));const ce=qe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ns=e=>{switch(typeof e){case"undefined":return ce.undefined;case"string":return ce.string;case"number":return Number.isNaN(e)?ce.nan:ce.number;case"boolean":return ce.boolean;case"function":return ce.function;case"bigint":return ce.bigint;case"symbol":return ce.symbol;case"object":return Array.isArray(e)?ce.array:e===null?ce.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?ce.promise:typeof Map<"u"&&e instanceof Map?ce.map:typeof Set<"u"&&e instanceof Set?ce.set:typeof Date<"u"&&e instanceof Date?ce.date:ce.object;default:return ce.unknown}},K=qe.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Ri extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,l=0;for(;l<o.path.length;){const c=o.path[l];l===o.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(o))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return i(this),r}static assert(t){if(!(t instanceof Ri))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,qe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const i of this.issues)if(i.path.length>0){const s=i.path[0];n[s]=n[s]||[],n[s].push(t(i))}else r.push(t(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Ri.create=e=>new Ri(e);const fv=(e,t)=>{let n;switch(e.code){case K.invalid_type:e.received===ce.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case K.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,qe.jsonStringifyReplacer)}`;break;case K.unrecognized_keys:n=`Unrecognized key(s) in object: ${qe.joinValues(e.keys,", ")}`;break;case K.invalid_union:n="Invalid input";break;case K.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${qe.joinValues(e.options)}`;break;case K.invalid_enum_value:n=`Invalid enum value. Expected ${qe.joinValues(e.options)}, received '${e.received}'`;break;case K.invalid_arguments:n="Invalid function arguments";break;case K.invalid_return_type:n="Invalid function return type";break;case K.invalid_date:n="Invalid date";break;case K.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:qe.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case K.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case K.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case K.custom:n="Invalid input";break;case K.invalid_intersection_types:n="Intersection results could not be merged";break;case K.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case K.not_finite:n="Number must be finite";break;default:n=t.defaultError,qe.assertNever(e)}return{message:n}};let qD=fv;function KD(){return qD}const GD=e=>{const{data:t,path:n,errorMaps:r,issueData:i}=e,s=[...n,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let a="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)a=c(o,{data:t,defaultError:a}).message;return{...i,path:s,message:a}};function ie(e,t){const n=KD(),r=GD({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===fv?void 0:fv].filter(i=>!!i)});e.common.issues.push(r)}class Tn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const i of n){if(i.status==="aborted")return ke;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const i of n){const s=await i.key,o=await i.value;r.push({key:s,value:o})}return Tn.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const i of n){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return ke;s.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[s.value]=o.value)}return{status:t.value,value:r}}}const ke=Object.freeze({status:"aborted"}),Al=e=>({status:"dirty",value:e}),Sr=e=>({status:"valid",value:e}),fb=e=>e.status==="aborted",pb=e=>e.status==="dirty",Aa=e=>e.status==="valid",_h=e=>typeof Promise<"u"&&e instanceof Promise;var me;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(me||(me={}));class ii{constructor(t,n,r,i){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const mb=(e,t)=>{if(Aa(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Ri(e.common.issues);return this._error=n,this._error}}};function Ie(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(o,a)=>{const{message:l}=e;return o.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:i}}class He{get description(){return this._def.description}_getType(t){return ns(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:ns(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Tn,ctx:{common:t.parent.common,data:t.data,parsedType:ns(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(_h(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){const r={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ns(t)},i=this._parseSync({data:t,path:r.path,parent:r});return mb(r,i)}"~validate"(t){var r,i;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ns(t)};if(!this["~standard"].async)try{const s=this._parseSync({data:t,path:[],parent:n});return Aa(s)?{value:s.value}:{issues:n.common.issues}}catch(s){(i=(r=s==null?void 0:s.message)==null?void 0:r.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(s=>Aa(s)?{value:s.value}:{issues:n.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ns(t)},i=this._parse({data:t,path:r.path,parent:r}),s=await(_h(i)?i:Promise.resolve(i));return mb(r,s)}refine(t,n){const r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,s)=>{const o=t(i),a=()=>s.addIssue({code:K.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(t,n){return this._refinement((r,i)=>t(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(t){return new uo({schema:this,typeName:Ce.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Ci.create(this,this._def)}nullable(){return ho.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ei.create(this)}promise(){return kh.create(this,this._def)}or(t){return yh.create([this,t],this._def)}and(t){return bh.create(this,t,this._def)}transform(t){return new uo({...Ie(this._def),schema:this,typeName:Ce.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Ch({...Ie(this._def),innerType:this,defaultValue:n,typeName:Ce.ZodDefault})}brand(){return new aN({typeName:Ce.ZodBranded,type:this,...Ie(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new Eh({...Ie(this._def),innerType:this,catchValue:n,typeName:Ce.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return z_.create(this,t)}readonly(){return Nh.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const XD=/^c[^\s-]{8,}$/i,YD=/^[0-9a-z]+$/,ZD=/^[0-9A-HJKMNP-TV-Z]{26}$/i,QD=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,JD=/^[a-z0-9_-]{21}$/i,eL=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,tL=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,nL=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,rL="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Wp;const iL=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,sL=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,oL=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,aL=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,lL=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,cL=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,iN="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",uL=new RegExp(`^${iN}$`);function sN(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function dL(e){return new RegExp(`^${sN(e)}$`)}function hL(e){let t=`${iN}T${sN(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function fL(e,t){return!!((t==="v4"||!t)&&iL.test(e)||(t==="v6"||!t)&&oL.test(e))}function pL(e,t){if(!eL.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function mL(e,t){return!!((t==="v4"||!t)&&sL.test(e)||(t==="v6"||!t)&&aL.test(e))}class bi extends He{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==ce.string){const s=this._getOrReturnCtx(t);return ie(s,{code:K.invalid_type,expected:ce.string,received:s.parsedType}),ke}const r=new Tn;let i;for(const s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),ie(i,{code:K.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),ie(i,{code:K.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){const o=t.data.length>s.value,a=t.data.length<s.value;(o||a)&&(i=this._getOrReturnCtx(t,i),o?ie(i,{code:K.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&ie(i,{code:K.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")nL.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"email",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Wp||(Wp=new RegExp(rL,"u")),Wp.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"emoji",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")QD.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"uuid",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")JD.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"nanoid",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")XD.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"cuid",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")YD.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"cuid2",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")ZD.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"ulid",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),ie(i,{validation:"url",code:K.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"regex",code:K.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),ie(i,{code:K.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),ie(i,{code:K.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),ie(i,{code:K.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?hL(s).test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{code:K.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?uL.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{code:K.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?dL(s).test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{code:K.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?tL.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"duration",code:K.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?fL(t.data,s.version)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"ip",code:K.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?pL(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"jwt",code:K.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?mL(t.data,s.version)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"cidr",code:K.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?lL.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"base64",code:K.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?cL.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"base64url",code:K.invalid_string,message:s.message}),r.dirty()):qe.assertNever(s);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:K.invalid_string,...me.errToObj(r)})}_addCheck(t){return new bi({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...me.errToObj(t)})}url(t){return this._addCheck({kind:"url",...me.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...me.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...me.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...me.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...me.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...me.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...me.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...me.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...me.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...me.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...me.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...me.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...me.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...me.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...me.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...me.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...me.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...me.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...me.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...me.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...me.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...me.errToObj(n)})}nonempty(t){return this.min(1,me.errToObj(t))}trim(){return new bi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new bi({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new bi({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}bi.create=e=>new bi({checks:[],typeName:Ce.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...Ie(e)});function gL(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r,s=Number.parseInt(e.toFixed(i).replace(".","")),o=Number.parseInt(t.toFixed(i).replace(".",""));return s%o/10**i}class ja extends He{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==ce.number){const s=this._getOrReturnCtx(t);return ie(s,{code:K.invalid_type,expected:ce.number,received:s.parsedType}),ke}let r;const i=new Tn;for(const s of this._def.checks)s.kind==="int"?qe.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),ie(r,{code:K.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),ie(r,{code:K.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),ie(r,{code:K.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?gL(t.data,s.value)!==0&&(r=this._getOrReturnCtx(t,r),ie(r,{code:K.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),ie(r,{code:K.not_finite,message:s.message}),i.dirty()):qe.assertNever(s);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,me.toString(n))}gt(t,n){return this.setLimit("min",t,!1,me.toString(n))}lte(t,n){return this.setLimit("max",t,!0,me.toString(n))}lt(t,n){return this.setLimit("max",t,!1,me.toString(n))}setLimit(t,n,r,i){return new ja({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:me.toString(i)}]})}_addCheck(t){return new ja({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:me.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:me.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:me.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:me.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:me.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:me.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:me.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:me.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:me.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&qe.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}ja.create=e=>new ja({checks:[],typeName:Ce.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Ie(e)});class Tc extends He{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==ce.bigint)return this._getInvalidInput(t);let r;const i=new Tn;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),ie(r,{code:K.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),ie(r,{code:K.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),ie(r,{code:K.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):qe.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return ie(n,{code:K.invalid_type,expected:ce.bigint,received:n.parsedType}),ke}gte(t,n){return this.setLimit("min",t,!0,me.toString(n))}gt(t,n){return this.setLimit("min",t,!1,me.toString(n))}lte(t,n){return this.setLimit("max",t,!0,me.toString(n))}lt(t,n){return this.setLimit("max",t,!1,me.toString(n))}setLimit(t,n,r,i){return new Tc({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:me.toString(i)}]})}_addCheck(t){return new Tc({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:me.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:me.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:me.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:me.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:me.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Tc.create=e=>new Tc({checks:[],typeName:Ce.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...Ie(e)});class pv extends He{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==ce.boolean){const r=this._getOrReturnCtx(t);return ie(r,{code:K.invalid_type,expected:ce.boolean,received:r.parsedType}),ke}return Sr(t.data)}}pv.create=e=>new pv({typeName:Ce.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Ie(e)});class xh extends He{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==ce.date){const s=this._getOrReturnCtx(t);return ie(s,{code:K.invalid_type,expected:ce.date,received:s.parsedType}),ke}if(Number.isNaN(t.data.getTime())){const s=this._getOrReturnCtx(t);return ie(s,{code:K.invalid_date}),ke}const r=new Tn;let i;for(const s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),ie(i,{code:K.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),ie(i,{code:K.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):qe.assertNever(s);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new xh({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:me.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:me.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}xh.create=e=>new xh({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:Ce.ZodDate,...Ie(e)});class gb extends He{_parse(t){if(this._getType(t)!==ce.symbol){const r=this._getOrReturnCtx(t);return ie(r,{code:K.invalid_type,expected:ce.symbol,received:r.parsedType}),ke}return Sr(t.data)}}gb.create=e=>new gb({typeName:Ce.ZodSymbol,...Ie(e)});class mv extends He{_parse(t){if(this._getType(t)!==ce.undefined){const r=this._getOrReturnCtx(t);return ie(r,{code:K.invalid_type,expected:ce.undefined,received:r.parsedType}),ke}return Sr(t.data)}}mv.create=e=>new mv({typeName:Ce.ZodUndefined,...Ie(e)});class gv extends He{_parse(t){if(this._getType(t)!==ce.null){const r=this._getOrReturnCtx(t);return ie(r,{code:K.invalid_type,expected:ce.null,received:r.parsedType}),ke}return Sr(t.data)}}gv.create=e=>new gv({typeName:Ce.ZodNull,...Ie(e)});class vb extends He{constructor(){super(...arguments),this._any=!0}_parse(t){return Sr(t.data)}}vb.create=e=>new vb({typeName:Ce.ZodAny,...Ie(e)});class vv extends He{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Sr(t.data)}}vv.create=e=>new vv({typeName:Ce.ZodUnknown,...Ie(e)});class Ss extends He{_parse(t){const n=this._getOrReturnCtx(t);return ie(n,{code:K.invalid_type,expected:ce.never,received:n.parsedType}),ke}}Ss.create=e=>new Ss({typeName:Ce.ZodNever,...Ie(e)});class _b extends He{_parse(t){if(this._getType(t)!==ce.undefined){const r=this._getOrReturnCtx(t);return ie(r,{code:K.invalid_type,expected:ce.void,received:r.parsedType}),ke}return Sr(t.data)}}_b.create=e=>new _b({typeName:Ce.ZodVoid,...Ie(e)});class ei extends He{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==ce.array)return ie(n,{code:K.invalid_type,expected:ce.array,received:n.parsedType}),ke;if(i.exactLength!==null){const o=n.data.length>i.exactLength.value,a=n.data.length<i.exactLength.value;(o||a)&&(ie(n,{code:o?K.too_big:K.too_small,minimum:a?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(ie(n,{code:K.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(ie(n,{code:K.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>i.type._parseAsync(new ii(n,o,n.path,a)))).then(o=>Tn.mergeArray(r,o));const s=[...n.data].map((o,a)=>i.type._parseSync(new ii(n,o,n.path,a)));return Tn.mergeArray(r,s)}get element(){return this._def.type}min(t,n){return new ei({...this._def,minLength:{value:t,message:me.toString(n)}})}max(t,n){return new ei({...this._def,maxLength:{value:t,message:me.toString(n)}})}length(t,n){return new ei({...this._def,exactLength:{value:t,message:me.toString(n)}})}nonempty(t){return this.min(1,t)}}ei.create=(e,t)=>new ei({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ce.ZodArray,...Ie(t)});function Ko(e){if(e instanceof jt){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Ci.create(Ko(r))}return new jt({...e._def,shape:()=>t})}else return e instanceof ei?new ei({...e._def,type:Ko(e.element)}):e instanceof Ci?Ci.create(Ko(e.unwrap())):e instanceof ho?ho.create(Ko(e.unwrap())):e instanceof lo?lo.create(e.items.map(t=>Ko(t))):e}class jt extends He{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=qe.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==ce.object){const c=this._getOrReturnCtx(t);return ie(c,{code:K.invalid_type,expected:ce.object,received:c.parsedType}),ke}const{status:r,ctx:i}=this._processInputParams(t),{shape:s,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ss&&this._def.unknownKeys==="strip"))for(const c in i.data)o.includes(c)||a.push(c);const l=[];for(const c of o){const u=s[c],d=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new ii(i,d,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Ss){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of a)l.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(c==="strict")a.length>0&&(ie(i,{code:K.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of a){const d=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new ii(i,d,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of l){const d=await u.key,f=await u.value;c.push({key:d,value:f,alwaysSet:u.alwaysSet})}return c}).then(c=>Tn.mergeObjectSync(r,c)):Tn.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return me.errToObj,new jt({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var s,o;const i=((o=(s=this._def).errorMap)==null?void 0:o.call(s,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:me.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new jt({...this._def,unknownKeys:"strip"})}passthrough(){return new jt({...this._def,unknownKeys:"passthrough"})}extend(t){return new jt({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new jt({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Ce.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new jt({...this._def,catchall:t})}pick(t){const n={};for(const r of qe.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new jt({...this._def,shape:()=>n})}omit(t){const n={};for(const r of qe.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new jt({...this._def,shape:()=>n})}deepPartial(){return Ko(this)}partial(t){const n={};for(const r of qe.objectKeys(this.shape)){const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}return new jt({...this._def,shape:()=>n})}required(t){const n={};for(const r of qe.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Ci;)s=s._def.innerType;n[r]=s}return new jt({...this._def,shape:()=>n})}keyof(){return oN(qe.objectKeys(this.shape))}}jt.create=(e,t)=>new jt({shape:()=>e,unknownKeys:"strip",catchall:Ss.create(),typeName:Ce.ZodObject,...Ie(t)});jt.strictCreate=(e,t)=>new jt({shape:()=>e,unknownKeys:"strict",catchall:Ss.create(),typeName:Ce.ZodObject,...Ie(t)});jt.lazycreate=(e,t)=>new jt({shape:e,unknownKeys:"strip",catchall:Ss.create(),typeName:Ce.ZodObject,...Ie(t)});class yh extends He{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function i(s){for(const a of s)if(a.result.status==="valid")return a.result;for(const a of s)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(a=>new Ri(a.ctx.common.issues));return ie(n,{code:K.invalid_union,unionErrors:o}),ke}if(n.common.async)return Promise.all(r.map(async s=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const l of r){const c={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!s&&(s={result:u,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;const a=o.map(l=>new Ri(l));return ie(n,{code:K.invalid_union,unionErrors:a}),ke}}get options(){return this._def.options}}yh.create=(e,t)=>new yh({options:e,typeName:Ce.ZodUnion,...Ie(t)});const gi=e=>e instanceof xv?gi(e.schema):e instanceof uo?gi(e.innerType()):e instanceof Sh?[e.value]:e instanceof co?e.options:e instanceof yv?qe.objectValues(e.enum):e instanceof Ch?gi(e._def.innerType):e instanceof mv?[void 0]:e instanceof gv?[null]:e instanceof Ci?[void 0,...gi(e.unwrap())]:e instanceof ho?[null,...gi(e.unwrap())]:e instanceof aN||e instanceof Nh?gi(e.unwrap()):e instanceof Eh?gi(e._def.innerType):[];class B_ extends He{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==ce.object)return ie(n,{code:K.invalid_type,expected:ce.object,received:n.parsedType}),ke;const r=this.discriminator,i=n.data[r],s=this.optionsMap.get(i);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(ie(n,{code:K.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),ke)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const i=new Map;for(const s of n){const o=gi(s.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const a of o){if(i.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);i.set(a,s)}}return new B_({typeName:Ce.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Ie(r)})}}function _v(e,t){const n=ns(e),r=ns(t);if(e===t)return{valid:!0,data:e};if(n===ce.object&&r===ce.object){const i=qe.objectKeys(t),s=qe.objectKeys(e).filter(a=>i.indexOf(a)!==-1),o={...e,...t};for(const a of s){const l=_v(e[a],t[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}else if(n===ce.array&&r===ce.array){if(e.length!==t.length)return{valid:!1};const i=[];for(let s=0;s<e.length;s++){const o=e[s],a=t[s],l=_v(o,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===ce.date&&r===ce.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class bh extends He{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(s,o)=>{if(fb(s)||fb(o))return ke;const a=_v(s.value,o.value);return a.valid?((pb(s)||pb(o))&&n.dirty(),{status:n.value,value:a.data}):(ie(r,{code:K.invalid_intersection_types}),ke)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}bh.create=(e,t,n)=>new bh({left:e,right:t,typeName:Ce.ZodIntersection,...Ie(n)});class lo extends He{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.array)return ie(r,{code:K.invalid_type,expected:ce.array,received:r.parsedType}),ke;if(r.data.length<this._def.items.length)return ie(r,{code:K.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ke;!this._def.rest&&r.data.length>this._def.items.length&&(ie(r,{code:K.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const s=[...r.data].map((o,a)=>{const l=this._def.items[a]||this._def.rest;return l?l._parse(new ii(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>Tn.mergeArray(n,o)):Tn.mergeArray(n,s)}get items(){return this._def.items}rest(t){return new lo({...this._def,rest:t})}}lo.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new lo({items:e,typeName:Ce.ZodTuple,rest:null,...Ie(t)})};class wh extends He{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.object)return ie(r,{code:K.invalid_type,expected:ce.object,received:r.parsedType}),ke;const i=[],s=this._def.keyType,o=this._def.valueType;for(const a in r.data)i.push({key:s._parse(new ii(r,a,r.path,a)),value:o._parse(new ii(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?Tn.mergeObjectAsync(n,i):Tn.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof He?new wh({keyType:t,valueType:n,typeName:Ce.ZodRecord,...Ie(r)}):new wh({keyType:bi.create(),valueType:t,typeName:Ce.ZodRecord,...Ie(n)})}}class xb extends He{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.map)return ie(r,{code:K.invalid_type,expected:ce.map,received:r.parsedType}),ke;const i=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([a,l],c)=>({key:i._parse(new ii(r,a,r.path,[c,"key"])),value:s._parse(new ii(r,l,r.path,[c,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const l of o){const c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return ke;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const l of o){const c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return ke;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}}}}xb.create=(e,t,n)=>new xb({valueType:t,keyType:e,typeName:Ce.ZodMap,...Ie(n)});class Pc extends He{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.set)return ie(r,{code:K.invalid_type,expected:ce.set,received:r.parsedType}),ke;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(ie(r,{code:K.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(ie(r,{code:K.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const s=this._def.valueType;function o(l){const c=new Set;for(const u of l){if(u.status==="aborted")return ke;u.status==="dirty"&&n.dirty(),c.add(u.value)}return{status:n.value,value:c}}const a=[...r.data.values()].map((l,c)=>s._parse(new ii(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(t,n){return new Pc({...this._def,minSize:{value:t,message:me.toString(n)}})}max(t,n){return new Pc({...this._def,maxSize:{value:t,message:me.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Pc.create=(e,t)=>new Pc({valueType:e,minSize:null,maxSize:null,typeName:Ce.ZodSet,...Ie(t)});class xv extends He{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}xv.create=(e,t)=>new xv({getter:e,typeName:Ce.ZodLazy,...Ie(t)});class Sh extends He{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return ie(n,{received:n.data,code:K.invalid_literal,expected:this._def.value}),ke}return{status:"valid",value:t.data}}get value(){return this._def.value}}Sh.create=(e,t)=>new Sh({value:e,typeName:Ce.ZodLiteral,...Ie(t)});function oN(e,t){return new co({values:e,typeName:Ce.ZodEnum,...Ie(t)})}class co extends He{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return ie(n,{expected:qe.joinValues(r),received:n.parsedType,code:K.invalid_type}),ke}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return ie(n,{received:n.data,code:K.invalid_enum_value,options:r}),ke}return Sr(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return co.create(t,{...this._def,...n})}exclude(t,n=this._def){return co.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}co.create=oN;class yv extends He{_parse(t){const n=qe.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==ce.string&&r.parsedType!==ce.number){const i=qe.objectValues(n);return ie(r,{expected:qe.joinValues(i),received:r.parsedType,code:K.invalid_type}),ke}if(this._cache||(this._cache=new Set(qe.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const i=qe.objectValues(n);return ie(r,{received:r.data,code:K.invalid_enum_value,options:i}),ke}return Sr(t.data)}get enum(){return this._def.values}}yv.create=(e,t)=>new yv({values:e,typeName:Ce.ZodNativeEnum,...Ie(t)});class kh extends He{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==ce.promise&&n.common.async===!1)return ie(n,{code:K.invalid_type,expected:ce.promise,received:n.parsedType}),ke;const r=n.parsedType===ce.promise?n.data:Promise.resolve(n.data);return Sr(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}kh.create=(e,t)=>new kh({type:e,typeName:Ce.ZodPromise,...Ie(t)});class uo extends He{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ce.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:o=>{ie(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return ke;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?ke:l.status==="dirty"||n.value==="dirty"?Al(l.value):l});{if(n.value==="aborted")return ke;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?ke:a.status==="dirty"||n.value==="dirty"?Al(a.value):a}}if(i.type==="refinement"){const o=a=>{const l=i.refinement(a,s);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?ke:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?ke:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(i.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Aa(o))return ke;const a=i.transform(o.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Aa(o)?Promise.resolve(i.transform(o.value,s)).then(a=>({status:n.value,value:a})):ke);qe.assertNever(i)}}uo.create=(e,t,n)=>new uo({schema:e,typeName:Ce.ZodEffects,effect:t,...Ie(n)});uo.createWithPreprocess=(e,t,n)=>new uo({schema:t,effect:{type:"preprocess",transform:e},typeName:Ce.ZodEffects,...Ie(n)});class Ci extends He{_parse(t){return this._getType(t)===ce.undefined?Sr(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Ci.create=(e,t)=>new Ci({innerType:e,typeName:Ce.ZodOptional,...Ie(t)});class ho extends He{_parse(t){return this._getType(t)===ce.null?Sr(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}ho.create=(e,t)=>new ho({innerType:e,typeName:Ce.ZodNullable,...Ie(t)});class Ch extends He{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===ce.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Ch.create=(e,t)=>new Ch({innerType:e,typeName:Ce.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Ie(t)});class Eh extends He{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return _h(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ri(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ri(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Eh.create=(e,t)=>new Eh({innerType:e,typeName:Ce.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Ie(t)});class yb extends He{_parse(t){if(this._getType(t)!==ce.nan){const r=this._getOrReturnCtx(t);return ie(r,{code:K.invalid_type,expected:ce.nan,received:r.parsedType}),ke}return{status:"valid",value:t.data}}}yb.create=e=>new yb({typeName:Ce.ZodNaN,...Ie(e)});class aN extends He{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class z_ extends He{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?ke:s.status==="dirty"?(n.dirty(),Al(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?ke:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,n){return new z_({in:t,out:n,typeName:Ce.ZodPipeline})}}class Nh extends He{_parse(t){const n=this._def.innerType._parse(t),r=i=>(Aa(i)&&(i.value=Object.freeze(i.value)),i);return _h(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}Nh.create=(e,t)=>new Nh({innerType:e,typeName:Ce.ZodReadonly,...Ie(t)});var Ce;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Ce||(Ce={}));const E=bi.create,ee=ja.create,Re=pv.create,ec=vv.create;Ss.create;const Ee=ei.create,z=jt.create;yh.create;const Oi=B_.create;bh.create;lo.create;const Pf=wh.create,te=Sh.create,it=co.create;kh.create;Ci.create;ho.create;const vL=["owner"],_L=["agent","owner","user-upload"],lN=z({id:E().min(1),relPath:E().min(1),from:it(_L),label:E().optional(),size:ee().int().nonnegative(),mime:E().min(1),addedAt:ee().int().nonnegative(),lastEditedAt:ee().int().nonnegative().optional(),stale:Re().optional()});z({sessionId:E().min(1),relPath:E().min(1),ttlSeconds:ee().int().positive().nullable().optional(),view:it(["raw","md-rendered"]).optional()});z({url:E().min(1),expiresAt:ee().int().nonnegative().nullable()});z({sessionId:E().min(1),relPath:E().min(1),label:E().optional()});z({entry:lN});z({sessionId:E().min(1),relPath:E().min(1)});z({removed:te(!0)});z({sessionId:E().min(1)});z({entries:Ee(lN)});z({attachmentId:E().min(1),url:E().min(1),relPath:E().min(1),sizeBytes:ee().int().nonnegative(),mimeType:E().min(1)});const cN=it(["owner","guest"]);z({id:E().min(1),kind:cN,displayName:E(),feishuUnionId:E().optional()}).strict();const xL=z({did:E().min(1),displayName:E(),feishuUnionId:E().optional(),principal:cN}).strict(),yL=z({personaId:E(),label:E(),model:E().optional(),public:Re(),iconKey:E().optional(),tool:E().optional(),createdAt:ee(),updatedAt:ee()}).strict(),bL=z({name:E().min(1),description:E().optional()}),wL=z({id:E().min(1)}),SL=z({permissions:z({defaultMode:E().optional(),allow:Ee(E()).optional(),deny:Ee(E()).optional()}).optional(),sandbox:z({enabled:Re().optional(),autoAllowBashIfSandboxed:Re().optional(),allowUnsandboxedCommands:Re().optional(),excludedCommands:Ee(E()).optional(),filesystem:z({denyRead:Ee(E()).optional(),allowRead:Ee(E()).optional(),denyWrite:Ee(E()).optional(),allowWrite:Ee(E()).optional()}).optional(),network:z({allowedDomains:Ee(E()).optional(),allowLocalBinding:Re().optional()}).optional()}).optional()});yL.extend({personality:E().optional(),skills:Ee(bL).optional(),plugins:Ee(wL).optional(),sandboxSettings:SL.nullable().optional()});z({label:E().min(1),personality:E(),model:E().optional(),tool:E().optional(),public:Re().optional(),iconKey:E().optional()}).strict();z({personaId:E().min(1)});z({personaId:E().min(1),patch:z({label:E().min(1).optional(),model:E().optional(),tool:E().optional(),personality:E().optional(),public:Re().optional(),iconKey:E().nullable().optional()}).strict()}).strict();z({writableRoots:Ee(E()).optional(),denyRead:Ee(E()).optional(),network:Re().optional()}).strict();const kL=it(rN),CL=z({input_tokens:ee().int().nonnegative().optional(),cache_read_input_tokens:ee().int().nonnegative().optional(),cache_creation_input_tokens:ee().int().nonnegative().optional(),output_tokens:ee().int().nonnegative().optional()}),EL=z({inputTokens:ee().int().nonnegative(),outputTokens:ee().int().nonnegative(),cacheReadTokens:ee().int().nonnegative().optional(),cacheCreateTokens:ee().int().nonnegative().optional()}),uN={gitBranch:E().optional(),resolvedModel:E().optional(),contextUsage:EL.optional(),contextWindowSize:ee().int().positive().optional()},NL=z(uN),TL=z({id:E().min(1),label:E().min(1),description:E().optional(),contextWindowSize:ee().int().positive(),default:Re().optional()}),PL=z({id:E().min(1),label:E().min(1),description:E().optional()}),RL=z({name:E().min(1),type:it(["string","select","toggle"]),label:E().min(1),description:E().optional(),options:Ee(z({value:E(),label:E(),description:E().optional()})).optional(),default:ec().optional(),scope:it(["core","tool-specific"])});z({tool:E().min(1)});const IL=z({rewind:Re(),subagents:Re(),tui:Re(),observe:Re(),fileSharing:Re(),fork:Re()});z({tool:E().min(1),toolSessionIdLabel:E().optional(),models:Ee(TL),permissionModes:Ee(PL),configSchema:Ee(RL),features:IL});const ML=z({tool:E().min(1),pattern:E().min(1),createdAt:E().min(1).optional()});z({sessionId:E().min(1),cwd:E().min(1),tool:te("claude").or(E().min(1)).default("claude"),toolSessionId:E().optional(),label:E().optional(),model:E().optional(),permissionMode:E().optional(),effort:E().optional(),...uN,permissionRules:Ee(ML).optional(),pinnedAt:ee().int().nonnegative().nullable().optional(),pinSortOrder:ee().int().nullable().optional(),iconKey:E().optional(),forkedFromSessionId:E().min(1).optional(),ephemeral:Re().optional(),ownerPersonaId:E().min(1).optional(),appBuilderProject:E().regex(/^[a-z][a-z0-9-]{0,39}$/).optional(),chatId:E().min(1).optional(),creatorPrincipalId:E().min(1).optional(),creatorDisplayName:E().min(1).optional(),creatorFeishuUnionId:E().min(1).optional(),originOwnerPrincipalId:E().min(1).optional(),originOwnerPersonaId:E().min(1).optional(),dispatchedFromSessionId:E().min(1).optional(),shiftFiredFromSessionId:E().min(1).optional(),createdAt:E().min(1),updatedAt:E().min(1)});const On={seq:ee().int().nonnegative().optional(),ts:E().optional(),uuid:E().optional()},AL=it(UD),jL=z({readCount:ee().int().nonnegative().optional(),searchCount:ee().int().nonnegative().optional(),bashCount:ee().int().nonnegative().optional(),editFileCount:ee().int().nonnegative().optional(),linesAdded:ee().int().nonnegative().optional(),linesRemoved:ee().int().nonnegative().optional(),otherToolCount:ee().int().nonnegative().optional()}),DL=z({oldStart:ee().int().nonnegative(),oldLines:ee().int().nonnegative(),newStart:ee().int().nonnegative(),newLines:ee().int().nonnegative(),lines:Ee(E())}),LL=z({agentId:E().optional(),agentType:E().optional(),status:E().optional(),prompt:E().optional(),filePath:E().optional(),structuredPatch:Ee(DL).optional(),stats:z({durationMs:ee().int().nonnegative().optional(),tokens:ee().int().nonnegative().optional(),toolUseCount:ee().int().nonnegative().optional(),toolStats:jL.optional(),usage:CL.optional()}).optional()}),OL=z({path:E(),content:E(),mtimeMs:ee().optional()}),BL=z({label:E().min(1),description:E().optional()}),dN=z({question:E().min(1),multiSelect:Re(),options:Ee(BL).min(1)});Oi("kind",[z({...On,kind:te("session_init"),toolSessionId:E().optional()}),z({...On,kind:te("thinking"),text:E(),partialId:E().optional()}),z({...On,kind:te("text"),text:E(),partialId:E().optional()}),z({...On,kind:te("user_text"),text:E(),meta:AL.optional(),taskId:E().optional(),parentToolUseId:E().optional(),sender:xL.optional()}),z({...On,kind:te("tool_call"),toolUseId:E(),tool:E(),toolKind:E().optional(),input:ec()}),z({...On,kind:te("tool_result"),toolUseId:E(),output:ec().optional(),error:E().optional(),toolResultExtra:LL.optional(),sourceToolAssistantUUID:E().optional(),askQuestionAnswers:Pf(E(),E()).optional()}),z({...On,kind:te("attachment_memories"),memories:Ee(OL)}),z({...On,kind:te("permission_request"),requestId:E(),tool:E(),input:ec(),toolUseId:E().optional()}),z({...On,kind:te("ask_user_question"),toolUseId:E(),questions:Ee(dN)}),z({...On,kind:te("turn_end")}),z({...On,kind:te("subagent_progress"),toolUseId:E(),agentId:E(),status:it(["started","running","completed","failed"]),description:E().optional(),lastToolName:E().optional(),prompt:E().optional(),stats:z({durationMs:ee().int().nonnegative().optional(),tokens:ee().int().nonnegative().optional(),toolUseCount:ee().int().nonnegative().optional()}).optional()}),z({...On,kind:te("error"),message:E()}),z({...On,kind:te("meta_update"),patch:NL}),z({...On,kind:te("meta-text"),text:E(),metaSource:it(["cc","owner"]).optional()})]);z({cwd:E().min(1).optional(),tool:E().optional(),label:E().optional(),model:E().optional(),permissionMode:E().optional(),effort:E().optional(),iconKey:E().optional(),forkedFromSessionId:E().min(1).optional(),ephemeral:Re().optional(),ownerPersonaId:E().min(1).optional()}).refine(e=>e.cwd!=null||e.ownerPersonaId!=null,{message:"cwd 与 ownerPersonaId 至少传一个"});z({originOnly:Re().optional(),limit:ee().int().positive().optional()});z({sessionId:E().min(1)});z({sessionId:E().min(1),patch:z({label:E().optional(),model:E().optional(),permissionMode:E().optional(),effort:E().optional(),cwd:E().optional(),iconKey:E().optional()})});z({sessionId:E().min(1),text:E()});z({sessionId:E().min(1),userMessageId:E().min(1),dryRun:Re().optional()});z({canRewind:Re(),error:E().optional(),filesChanged:Ee(E()).optional(),insertions:ee().int().nonnegative().optional(),deletions:ee().int().nonnegative().optional()});z({sessionId:E().min(1),userMessageId:E().min(1)});const zL=z({oldStart:ee().int().nonnegative(),oldLines:ee().int().nonnegative(),newStart:ee().int().nonnegative(),newLines:ee().int().nonnegative(),lines:Ee(E())}),$L=z({filePath:E().min(1),hunks:Ee(zL),insertions:ee().int().nonnegative(),deletions:ee().int().nonnegative(),status:it(["modified","added","deleted"]).optional()});z({canRewind:Re(),error:E().optional(),files:Ee($L),totalInsertions:ee().int().nonnegative(),totalDeletions:ee().int().nonnegative()});z({userMessageIds:Ee(E())});z({sessionId:E().min(1),toolSessionId:E().min(1)});z({cwd:E().min(1),toolSessionId:E().min(1),messageUuid:E().min(1)});z({forkedToolSessionId:E().min(1),forkedFilePath:E().min(1)});z({sessionId:E().min(1),toolSessionId:E().min(1),jsonlPath:E().optional()});z({sessionId:E().min(1),afterSeq:ee().int().min(-1)});z({sessionId:E().min(1),permissionRequestId:E().min(1),allow:Re(),permanent:Re().optional(),pattern:E().optional()});z({projectPath:E().min(1)});z({sessionId:E().min(1),limit:ee().int().positive().max(5e3).optional(),offset:ee().int().nonnegative().optional()});z({cwd:E().min(1),toolSessionId:E().min(1)});z({cwd:E().min(1),toolSessionId:E().min(1),subagentId:E().min(1)});z({cwd:E().min(1).optional(),path:E().optional(),showHidden:Re().optional()});z({cwd:E().min(1),path:E().min(1)});z({cwd:E().min(1),tool:E().optional()});z({name:E().min(1),source:it(WD),path:E().optional(),description:E().optional(),plugin:E().optional()});const FL=z({name:E().min(1),source:it(VD),path:E().optional(),description:E().optional(),whenToUse:E().optional(),plugin:E().optional()});z({cwd:E().min(1),tool:E().optional()});z({agents:Ee(FL)});z({sessionId:E().min(1)});z({sessionId:E().min(1),pinned:Re()});z({type:te("peerSession:upsert:ok")});z({sessionId:E().min(1)});z({type:te("peerSession:remove:ok")});z({orderedIds:Ee(E().min(1)).min(1)});z({cwd:E().min(1)});z({isGitRoot:Re(),gitRoot:E().nullable()});z({cwd:E().min(1)});z({branch:E().nullable()});z({cwd:E().min(1)});z({branches:Ee(E()),head:E().nullable()});z({}).optional();const HL=z({cwd:E().min(1),updatedAt:E().min(1)});z({dirs:Ee(HL)});z({type:te("session:question"),sessionId:E().min(1),toolUseId:E().min(1),requestId:E().min(1),questions:Ee(dN).min(1)});z({type:te("session:question:cleared"),sessionId:E().min(1),toolUseId:E().min(1),answers:Pf(E(),E()).optional()});z({sessionId:E().min(1),toolUseId:E().min(1),answers:Pf(E(),E())});z({ok:te(!0)});z({sessionId:E().min(1),toolUseId:E().min(1)});z({ok:te(!0)});z({type:te("auth"),token:E().min(1),scheme:te("bearer").optional(),selfUrl:E().min(1).optional(),clientInfo:z({name:E().min(1),version:E().min(1),instanceId:E().min(1)}).optional()});z({type:te("auth:ok"),version:E().min(1).optional(),protocolVersion:ee().int().nonnegative().optional()});z({type:te("tunnel:ready"),url:E().min(1),subdomain:E().min(1)});z({type:te("tunnel:exited"),code:ee().int().nullable(),subdomain:E().nullable(),url:E().nullable()});z({type:te("tunnel:unavailable"),reason:E().min(1),failedAt:E().min(1)});const UL=z({sessionId:E().min(1),status:kL,freshSpawn:Re(),pendingPermissionRequestIds:Ee(E().min(1)),pendingQuestionToolUseIds:Ee(E().min(1))});z({type:te("info"),version:E(),protocolVersion:ee(),hostname:E(),os:E(),tools:Ee(z({id:E(),available:Re()})),runningSessions:Ee(UL),tokenRole:it(vL).optional(),isLoopback:Re().optional(),httpBaseUrl:E().optional(),httpToken:E().optional()});const WL=6173,VL=6272,Ga=/^[a-z][a-z0-9-]{0,39}$/,tu=z({name:E().regex(Ga,{message:"kebab-case, 小写字母开头,只允许小写字母 / 数字 / -,最长 40 字符"}),port:ee().int().min(WL).max(VL),createdAt:E().datetime(),devCommand:E().min(1),prodUrl:E().url().optional(),readyPattern:E().optional(),publishJob:z({jobId:E().min(1),stage:it(["build","deploy","verify"]),startedAt:ee().int().nonnegative()}).optional()}),qL=["install-pending","installing","starting-dev-server","running","stopped","failed"],hN=it(qL),$_=tu.extend({isRunning:Re(),boundSessionId:E().nullable(),stage:hN.optional(),stageReason:E().optional(),publishJob:z({jobId:E().min(1),stage:it(["build","deploy","verify"]),startedAt:ee().int().nonnegative(),status:it(["in-flight","interrupted"])}).optional()});z({}).strict();z({projects:Ee($_)}).strict();z({sessionId:E().min(1)}).strict();z({project:$_.nullable()}).strict();z({sessionId:E().min(1),name:E()}).strict();z({project:tu}).strict();z({name:E()}).strict();z({}).strict();z({name:E(),newPort:ee().int()}).strict();z({project:tu}).strict();z({name:E().regex(Ga),url:E().url()}).strict();z({project:tu}).strict();z({sessionId:E().min(1),force:Re().optional()}).strict();z({project:tu}).strict();const KL=["installing","failed"];z({sessionId:E().min(1),stage:it(KL),reason:E().optional()}).strict();z({ok:te(!0)}).strict();z({sessionId:E().min(1)}).strict();z({ok:te(!0)}).strict();z({type:te("appBuilder:project-updated"),project:$_,stage:hN,stageReason:E().optional()}).strict();z({name:E().regex(Ga)});z({jobId:E().min(1),status:it(["started","already-publishing"])}).strict();z({name:E().regex(Ga)});z({ok:te(!0)}).strict();z({type:te("appBuilder:publish-progress"),name:E().regex(Ga),jobId:E().min(1),stage:it(["build","deploy","verify"]),status:it(["started","completed"])}).strict();z({type:te("appBuilder:publish-failed"),name:E().regex(Ga),jobId:E().min(1),stage:it(["build","deploy","verify","unknown"]),errorSummary:E()}).strict();const bb=1,GL=Oi("type",[z({type:te("persona"),id:E().min(1)}).strict(),z({type:te("chat"),id:E().min(1)}).strict(),z({type:te("*")}).strict()]),XL=it(["read","send","admin"]),fN=z({resource:GL,actions:Ee(XL).min(1)}).strict(),YL=z({id:E().min(1),secretHash:E().regex(/^[a-f0-9]{64}$/),displayName:E(),grants:Ee(fN),issuedAt:ee().int().nonnegative(),expiresAt:ee().int().positive().optional(),maxUses:ee().int().positive().optional(),usedCount:ee().int().nonnegative(),peerOwnerId:E().min(1).optional(),firstUsedByPeerAt:ee().int().positive().optional(),peerDisplayName:E().optional()}).strict(),ZL=YL.omit({secretHash:!0});it(["TOKEN_INVALID","TOKEN_REVOKED","TOKEN_EXPIRED","TOKEN_EXHAUSTED"]);z({type:te("whoami:ok"),owner:z({id:E(),kind:it(["owner","guest"]),displayName:E(),ownerId:E(),provider:E()}).strict(),capability:ZL,grantedPersonas:Ee(z({id:E().min(1),displayName:E()}).strict())}).strict();z({id:E().min(1),peerDeviceId:E().min(1),senderDeviceId:E().min(1),text:E().min(1),createdAt:ee().int().nonnegative(),readBy:Pf(E().min(1),ee().int().positive()).default({}),origin:z({kind:te("persona"),personaId:E().min(1)}).optional()}).strict();z({peerDeviceId:E().min(1).optional(),id:E().min(1),text:E().min(1),createdAt:ee().int().nonnegative(),origin:z({kind:te("persona"),personaId:E().min(1)}).optional()}).strict();z({peerDeviceId:E().min(1),sinceCreatedAt:ee().int().nonnegative().optional()}).strict();z({peerDeviceId:E().min(1),upToCreatedAt:ee().int().nonnegative()}).strict();z({peerDeviceId:E().min(1).optional(),text:E().min(1)});const QL=z({deviceId:E().min(1),ownerId:E().min(1),provider:E().min(1),displayName:E(),remoteUrl:E().min(1),connectToken:E(),grants:Ee(fN),addedAt:ee().int().nonnegative(),pinnedAt:ee().int().nullable().default(null),remoteAccessAllowed:Re().default(!1)}).strict(),pN=QL;z({deviceId:E().min(1)}).strict();z({type:te("contact:remove:ok"),deviceId:E().min(1)}).strict();z({type:te("contact:list:ok"),contacts:Ee(pN)}).strict();z({type:te("contact:added"),contact:pN}).strict();z({type:te("contact:removed"),deviceId:E().min(1)}).strict();z({deviceId:E().min(1),pinned:Re()}).strict();z({type:te("contact:pin:ok"),deviceId:E().min(1),pinnedAt:ee().int().nullable()}).strict();z({type:te("contact:pinned"),deviceId:E().min(1),pinnedAt:ee().int().nullable()}).strict();z({deviceId:E().min(1),remoteAccessAllowed:Re()}).strict();z({type:te("contact:setRemoteAccess:ok"),deviceId:E().min(1),remoteAccessAllowed:Re()}).strict();z({type:te("contact:remote-access-updated"),deviceId:E().min(1),remoteAccessAllowed:Re()}).strict();z({peerDeviceId:E().min(1).optional(),command:E().min(1),timeoutMs:ee().int().positive().optional()}).strict();z({type:te("peerExec:run:ok"),stdout:E(),stderr:E(),exitCode:ee().int().nullable(),timedOut:Re(),stdoutTruncated:Re(),stderrTruncated:Re()}).strict();const JL=/^[a-z0-9][a-z0-9-]*$/;it(["stopped","starting","running","crashed","invalid"]);const eO=new Set(["localhost","127.0.0.1"]);function tO(e){let t;try{t=new URL(e)}catch{return!1}return!!(t.protocol==="https:"||t.protocol==="http:"&&eO.has(t.hostname))}const Wu=z({id:E().regex(JL),name:E().min(1),version:E().min(1),apiVersion:te("1"),runtime:z({startCommand:E().min(1)}).passthrough().optional(),entry:z({url:E().url().refine(tO,{message:"INVALID_URL_SCHEME: only https or http://localhost is allowed"})}).strict().optional()}).passthrough().superRefine((e,t)=>{var i;const n=!!e.runtime,r=!!((i=e.entry)!=null&&i.url);n&&r&&t.addIssue({code:K.custom,message:"INVALID_MANIFEST: entry.url and runtime cannot coexist"}),!n&&!r&&t.addIssue({code:K.custom,message:"INVALID_MANIFEST: must have either entry.url or runtime"})}),nO=Oi("kind",[z({kind:te("local"),port:ee().int().min(1).max(65535)}),z({kind:te("hosted"),url:E().url()})]);Oi("state",[z({extId:E(),manifest:Wu,state:te("stopped")}),z({extId:E(),manifest:Wu,state:te("starting")}),z({extId:E(),manifest:Wu,state:te("running"),target:nO}),z({extId:E(),manifest:Wu,state:te("crashed")}),z({extId:E(),manifest:ec().nullable(),state:te("invalid"),invalidReason:E().min(1)})]);z({snapshotHash:E().min(1),version:E().min(1),publishedAt:ee()});Oi("kind",[z({kind:te("p2p-tunnel"),ownerPrincipalId:E().min(1),extId:E().min(1)})]);Oi("kind",[z({kind:te("p2p-tunnel"),ownerPrincipalId:E().min(1),extId:E().min(1),snapshotHash:E().min(1)})]);z({extId:E().min(1),name:E().min(1),version:E().min(1),contentHash:E().min(1),publishedAt:ee()});const rO=Oi("kind",[z({kind:te("clean")}),z({kind:te("ready-new-version"),fromVersion:E().min(1),toVersion:E().min(1)}),z({kind:te("error-same-hash"),version:E().min(1)}),z({kind:te("error-version-not-bumped"),localVersion:E().min(1),publishedVersion:E().min(1)}),z({kind:te("error-version-regression"),localVersion:E().min(1),publishedVersion:E().min(1)})]);z({localManifest:z({name:E().min(1),version:E().min(1),contentHash:E().min(1)}),publishState:Oi("kind",[z({kind:te("unpublished")}),z({kind:te("published"),version:E().min(1),contentHash:E().min(1),publishedAt:ee()})]),check:rO});const iO=z({deviceId:E().min(1),name:E().min(1),url:E().min(1)});z({type:te("device:list:ok"),devices:Ee(iO)});z({deviceId:E().min(1),url:E().min(1).optional(),name:E().optional()});z({type:te("device:connect:ok"),deviceId:E(),name:E(),url:E()});const mN=z({ownerId:E().min(1),provider:E().min(1),displayName:E().min(1),avatarUrl:E().optional(),unionId:E().optional()});z({type:te("auth:login:start:ok"),authUrl:E().min(1),state:E().min(1)});z({type:te("auth:getIdentity:ok"),identity:mN.nullable(),deviceId:E().min(1)});z({type:te("auth:logout:ok")});z({type:te("auth:login:done"),identity:mN});z({type:te("auth:login:failed"),reason:E()});const sO=Oi("kind",[z({kind:te("success"),text:E(),filePaths:Ee(E()).optional()}),z({kind:te("failure"),reason:E()})]);z({targetPersona:E().min(1),prompt:E(),targetDeviceId:E().min(1).optional(),model:E().min(1).optional()});z({dispatchId:E().min(1),outcome:sO});const oO=["daemon","main","renderer"],aO=it(oO),lO=["debug","info","warn","error"],cO=it(lO);z({ts:ee().int(),source:aO,level:cO,msg:E(),ownerPrincipalId:E(),deviceId:E(),appVersion:E(),daemonVersion:E().optional(),os:E(),meta_json:E().optional(),sessionId:E().optional()});z({v:te(1),visitorId:E().min(1),displayName:E(),provider:E(),iat:ee(),exp:ee()});const uO=z({visitorId:E(),displayName:E(),avatarUrl:E().optional(),provider:E(),firstSeen:ee(),lastSeen:ee()});z({visitors:Ee(uO)});const dO=new Set(["localhost","127.0.0.1","0.0.0.0","::1"]);let fi=null;function hO(){if(fi!==null)return fi;if(typeof window>"u")return fi=!1,!1;if(dO.has(window.location.hostname)||window.location.protocol==="file:")return fi=!0,!0;if(new URLSearchParams(window.location.search).get("debug")==="1"){fi=!0;try{sessionStorage.setItem("debug","1")}catch{}}else try{fi=sessionStorage.getItem("debug")==="1"}catch{fi=!1}return fi}function De(e,...t){hO()&&console.log(`[${e}][${new Date().toISOString()}]`,...t)}function Vu(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}const fO=e=>{const t=[1e3,2e3,4e3,8e3,16e3,3e4];return t[Math.min(e,t.length-1)]},pO=new Set(["auth:ok","pong","error"]),wb=new Set(nN.filter(e=>!pO.has(e)));let mO=0;const Sb=()=>`r${++mO}`;function gO(e){let t=e.url,n=e.authToken,r=e.selfIdentity;const i=e.clientInfo,s=e.requestTimeoutMs??3e4,o=e.pingIntervalMs??3e4,a=e.watchdogMs??6e4,l=e.authTimeoutMs??1e4,c=e.backoffMs??fO;let u=null,d=!1,f=0,p=null,m=null,v=null,y=null,_=!1,x="disconnected";const b=new Map,w=new Map;let S=null;const k=(D,C)=>{var H;D==="ready"&&(S=C),(H=w.get(D))==null||H.forEach(q=>{try{q(C)}catch{}})},T=D=>{x!==D&&(x=D,k("status",D))},N=(D,C)=>{const H=w.get(D)??new Set;if(H.add(C),w.set(D,H),D==="ready"&&S!==null)try{C(S)}catch{}return()=>H.delete(C)},O=()=>{m&&(clearInterval(m),m=null),v&&(clearTimeout(v),v=null),y&&(clearTimeout(y),y=null)},P=()=>{v&&clearTimeout(v),v=setTimeout(()=>{try{u==null||u.close(4e3,"pong watchdog")}catch{}},a)},L=()=>{m&&clearInterval(m),m=setInterval(()=>{(u==null?void 0:u.readyState)===1&&u.send(JSON.stringify({type:"ping",requestId:Sb()}))},o),P()},R=D=>{for(const[,C]of b)clearTimeout(C.timer),C.reject(new Error(D));b.clear()},I=[],j=()=>{if(I.length===0)return;const D=I.splice(0);for(const C of D)(u==null?void 0:u.readyState)===1&&!_?C.doSend():(clearTimeout(C.timer),C.reject(new Error("NOT_CONNECTED")))},B=D=>{if(I.length===0)return;const C=I.splice(0);for(const H of C)clearTimeout(H.timer),H.reject(new Error(D))},$=()=>{if(d)return;const D=c(f);D<0||(k("daemon:reconnecting",{attempt:f+1,nextDelayMs:D,scheduledAt:Date.now()}),p&&clearTimeout(p),p=setTimeout(()=>{f+=1,A()},D))},F=D=>{P();const C=String(D.type??"");if(C==="auth:ok"){De("daemon-client","auth:ok received → connected",{url:t}),y&&(clearTimeout(y),y=null),_=!1,f=0,T("connected"),k("daemon:connected",{url:t}),L(),j();return}if(C==="pong")return;if(C==="ready"){const q=Number(D.protocolVersion??-1);q!==bb&&k("daemon:version-mismatch",{daemonProtocol:q,supportedProtocol:bb}),k("ready",D);return}const H=D.requestId;if(typeof H=="string"&&b.has(H)){const q=b.get(H);if(b.delete(H),clearTimeout(q.timer),C==="error"){const M=String(D.code??"ERR"),ne=String(D.message??"unknown");q.reject(new Error(`${M}: ${ne}`))}else wb.has(C)&&k(C,D),q.resolve(D);return}wb.has(C)&&k(C,D)},A=()=>{p&&(clearTimeout(p),p=null),De("daemon-client","connect →",{url:t,token:Vu(n),attempt:f}),T("connecting");let D;try{D=new WebSocket(t)}catch(C){T("disconnected"),k("daemon:disconnected",{reason:(C==null?void 0:C.message)??"ws constructor failed"}),$();return}u=D,_=!!n,D.onopen=()=>{if(D!==u){De("daemon-client","onopen → stale (replaced before opened), ignore");return}if(n){De("daemon-client","onopen → send auth frame",{token:Vu(n)});const C={type:"auth",token:n};r!=null&&r.principalId&&(C.selfPrincipalId=r.principalId),r!=null&&r.displayName&&(C.selfDisplayName=r.displayName),i&&(C.clientInfo=i),D.send(JSON.stringify(C)),y=setTimeout(()=>{try{D.close(4001,"auth handshake timeout")}catch{}},l)}else De("daemon-client","onopen → no token, treat as connected (daemon authMode=none)"),f=0,T("connected"),k("daemon:connected",{url:t}),L(),j()},D.onclose=C=>{if(D!==u){De("daemon-client","onclose → stale, ignore",{code:C.code,reason:C.reason});return}const H=C.reason||(C.code===1008?"auth failed":`close ${C.code}`);if(De("daemon-client","onclose →",{code:C.code,reason:H,awaitingAuth:_,manualStop:d}),O(),R(`connection closed: ${H}`),u=null,C.code===4401?T("revoked"):T("disconnected"),k("daemon:disconnected",{reason:H}),C.code===1008||C.code===4401){B(`connection closed: ${H}`);return}d?B(`connection closed: ${H}`):$()},D.onerror=()=>{},D.onmessage=C=>{if(D!==u)return;let H;try{H=JSON.parse(String(C.data))}catch{return}F(H)}};return{start(){d=!1,f=0,A()},stop(){d=!0,p&&(clearTimeout(p),p=null),O();try{u==null||u.close(1e3,"shutdown")}catch{}u=null,R("shutdown"),B("shutdown"),T("disconnected")},switchProfile(D){De("daemon-client","switchProfile →",{url:D.url,token:Vu(D.authToken)},"prev:",{url:t,token:Vu(n)}),t=D.url,n=D.authToken,D.selfIdentity!==void 0&&(r=D.selfIdentity),f=0,d=!0,p&&(clearTimeout(p),p=null),O(),R("switch profile"),B("switch profile");try{u==null||u.close(1e3,"switch profile")}catch{}u=null,d=!1,A()},request(D,C){return new Promise((H,q)=>{const M=Sb(),ne=setTimeout(()=>{b.delete(M);const V=I.findIndex(pe=>pe.timer===ne);V>=0&&I.splice(V,1),q(new Error(`request timeout: ${D}`))},s),oe=()=>{b.set(M,{resolve:V=>H(V),reject:q,timer:ne}),u.send(JSON.stringify({...C,type:D,requestId:M}))};(u==null?void 0:u.readyState)===1&&!_?oe():d||u==null&&p==null?(clearTimeout(ne),q(new Error("NOT_CONNECTED"))):I.push({doSend:oe,reject:q,timer:ne})})},on:N,get isOpen(){return(u==null?void 0:u.readyState)===1&&!_},get url(){return t},getStatus(){return x}}}function vO(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}function _O(e){return e?{id:e.id,mode:e.mode,url:e.url,token:vO(e.token),name:e.name}:null}function qu(e){return e?Array.isArray(e)?e.map(_O):{_notArray:typeof e,_value:e}:null}function kb(e){return e==null?null:typeof e=="object"&&"value"in e?e.value:e}const xO="ws://127.0.0.1:18790",Cb="daemon:profiles",Eb="daemon:active-profile-id";function yO(){return Math.random().toString(36).slice(2,10)}function bO(e){const t=e.trim(),n=t.indexOf("#");if(n<0)return{url:t};const r=t.slice(0,n),i=new URLSearchParams(t.slice(n+1)).get("token")??void 0;return{url:r,token:i}}function wO(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.name=="string"&&(t.mode==="localhost"||t.mode==="remote")&&typeof t.url=="string"&&(t.token===void 0||typeof t.token=="string")}function gN(e){let t={profiles:[],activeId:null},n=!1,r=null;const i=new Set,s=()=>{for(const l of i)l(t)},o=async()=>{De("profile-store","persist →",qu(t.profiles),"active:",t.activeId),await e.kv.set(Cb,t.profiles),await e.kv.set(Eb,t.activeId)},a=async()=>{if(!n){if(r){await r;return}r=(async()=>{var l;try{let c=null;try{const d=await e.kv.get(Cb);c=kb(d)}catch{c=null}let u=null;try{const d=await e.kv.get(Eb);u=kb(d)??null}catch{u=null}if(De("profile-store","ensureLoaded read kv →","profiles:",qu(c),"activeId:",u),Array.isArray(c)&&c.length>0){const d=c.filter(wO),f=u&&d.some(p=>p.id===u)?u:((l=d[0])==null?void 0:l.id)??null;t={profiles:d,activeId:f},n=!0,De("profile-store","ensureLoaded → use kv profiles",qu(d),"active:",f);return}t={profiles:[{id:"default",name:"本机",mode:"localhost",url:xO}],activeId:"default"},De("profile-store","ensureLoaded → fallback synthesized default (NO token)",qu(t.profiles)),n=!0,await o()}finally{r=null}})(),await r}};return{async load(){return await a(),s(),t},async snapshot(){return await a(),t},async upsert(l){var y;await a();let c=l.url,u=l.token;if(c&&c.includes("#")){const _=bO(c);c=_.url,!u&&_.token&&(u=_.token)}const d=l.id?t.profiles.find(_=>_.id===l.id):void 0,f=u!=null&&u.trim()?u.trim():d==null?void 0:d.token;if(l.mode==="remote"&&!f)throw new Error("remote mode requires token");const p=l.id??yO(),m={id:p,name:((y=l.name)==null?void 0:y.trim())||(d==null?void 0:d.name)||(l.mode==="remote"?"远程":"本机"),mode:l.mode,url:c.trim(),token:f};return t={profiles:[...t.profiles.filter(_=>_.id!==p),m],activeId:p},await o(),s(),m},async delete(l){var d;await a();const c=t.profiles.filter(f=>f.id!==l);let u=t.activeId;u===l&&(u=((d=c[0])==null?void 0:d.id)??null),t={profiles:c,activeId:u},await o(),s()},async activate(l){await a(),t.profiles.some(c=>c.id===l)&&(t={...t,activeId:l},await o(),s())},subscribe(l){return i.add(l),()=>i.delete(l)},getActive(){return n?t.profiles.find(l=>l.id===t.activeId)??null:null}}}const Nb="clawd.client-instance-id";let SO={name:"clawd-web",version:"unknown"};function kO(){let e=null;try{e=localStorage.getItem(Nb),e||(e=crypto.randomUUID(),localStorage.setItem(Nb,e))}catch{e=e??crypto.randomUUID()}return{...SO,instanceId:e}}function Tb(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}const vN=g.createContext(null);function CO({host:e,children:t}){const[n,r]=g.useState(null),i=g.useMemo(()=>async()=>{const s=gN(e),o=await s.load(),a=o.profiles.find(c=>c.id===o.activeId)??o.profiles[0];if(!a)throw new Error("DaemonProvider: profile store has no profiles after load");return De("daemon-context","bootstrap → createDaemonClient",{id:a.id,url:a.url,token:Tb(a.token)}),{client:gO({url:a.url,authToken:a.token,clientInfo:kO()}),store:s}},[e]);return g.useEffect(()=>{let s=!0,o=null,a=null;return i().then(l=>{s&&(l.client.start(),o=l,r(l),a=l.store.subscribe(()=>{const c=l.store.getActive();if(!c){De("daemon-context","subscribe → no active profile, skip switchProfile");return}De("daemon-context","subscribe → switchProfile",{id:c.id,url:c.url,token:Tb(c.token)}),l.client.switchProfile({url:c.url,authToken:c.token})}))}),()=>{s=!1,a==null||a(),o==null||o.client.stop()}},[i]),n?h.jsx(vN.Provider,{value:n,children:t}):null}function Rs(){const e=g.useContext(vN);if(!e)throw new Error("useDaemonClient must be used inside <DaemonProvider>");return e.client}function EO(){const e=Rs(),[t,n]=g.useState(void 0);return g.useEffect(()=>e.on("ready",i=>{const s=i.mode,o=s==="tui"?"tui":"sdk";De("daemon-context","useDaemonMode ready.mode =",{rawMode:s,resolved:o}),n(o)}),[e]),t}const _N=g.createContext(null);function NO({cache:e,children:t}){return g.createElement(_N.Provider,{value:e},t)}function ko(){const e=g.useContext(_N);if(!e)throw new Error("useCache must be used inside <CacheProvider>");return e}function si(e){const t=ko(),n=g.useCallback(i=>t.observe(e,()=>i()),[t,e]),r=g.useCallback(()=>t.read(e),[t,e]);return g.useSyncExternalStore(n,r,r)}const xN={actionsLevel:"none",httpBaseUrl:null,httpToken:null},yN=g.createContext(xN);function Rf(){return g.useContext(yN)}function TO(e){return e!=null&&e.httpBaseUrl?{actionsLevel:e.tokenRole==="owner"?"owner":"none",httpBaseUrl:e.httpBaseUrl,httpToken:e.httpToken??null}:xN}function PO(){const e=si("daemon-info");return g.useMemo(()=>TO(e),[e])}function RO({children:e}){const t=PO();return st.createElement(yN.Provider,{value:t},e)}function IO(e,t,n){if(!e.httpBaseUrl)return null;const r=encodeURIComponent(n);return`${e.httpBaseUrl}/session/${encodeURIComponent(t.sessionId)}/files?path=${r}`}function MO(e){const t=new Map;return{observe(n,r){let i=t.get(n);i||(i={data:void 0,hasData:!1,listeners:new Set},t.set(n,i));const s=l=>r(l);i.listeners.add(s);const o=i.listeners.size===1;s(i.hasData?i.data:void 0),o&&e.onFirstObserver(n);let a=!1;return()=>{if(a)return;a=!0;const l=t.get(n);l&&(l.listeners.delete(s),l.listeners.size===0&&(t.delete(n),e.onLastObserver(n)))}},read(n){const r=t.get(n);return r!=null&&r.hasData?r.data:void 0},setData(n,r){const i=t.get(n);if(!i)return;const s=i.hasData?i.data:void 0,o=r(s);i.data=o,i.hasData=!0;for(const a of i.listeners)a(o)}}}function AO(){const e=[],t=new Map,n=r=>{for(const i of e)if(i.pattern.test(r))return i.source;return null};return{register(r,i){e.push({pattern:r,source:i})},activate(r){if(t.has(r))return;const i=n(r);if(!i)throw new Error(`no source registered for key: ${r}`);t.set(r,i.start(r))},deactivate(r){const i=t.get(r);i&&(t.delete(r),i())}}}function jO(e){return{request:(t,n)=>e.request(t,n),onFrame(t){const n=[];for(const r of nN)n.push(e.on(r,i=>t(r,i)));return()=>{for(const r of n)r()}},onConnect(t){return e.on("daemon:connected",()=>t())},get isConnected(){return e.isOpen}}}const DO=e=>({tool:e,models:[{id:"",label:"Default",contextWindowSize:2e5,default:!0}],permissionModes:[{id:"",label:"Default"}],configSchema:[]});function LO(e,t){return{start(n){const r=n.replace(/^capabilities\//,"");let i=!1;const s=async()=>{try{const a=await e.request("capabilities:get",{tool:r});if(i)return;t(n,()=>a)}catch{if(i)return;t(n,()=>DO(r))}},o=e.onConnect(()=>{s()});return s(),()=>{i=!0,o()}}}}function OO(e,t){return{start(n){let r=!1;const i=async()=>{try{const a=await e.request("session:list",void 0);if(r)return;t(n,()=>a.sessions??[])}catch{}},s=e.onFrame((a,l)=>{if(a==="session:info"){const c=l;if(c.chatId!==void 0)return;t(n,u=>[c,...(u??[]).filter(d=>d.sessionId!==c.sessionId)])}else if(a==="session:deleted"){const c=l;t(n,u=>(u??[]).filter(d=>d.sessionId!==c.sessionId))}}),o=e.onConnect(()=>{i()});return i(),()=>{r=!0,s(),o()}}}}const Rc={sessionId:null,events:[],lastSeq:-1,pendingPermissions:[],status:"idle",pendingQuestions:{}};function Vp(e,t){const n=t;if(n.kind==="permission_request"&&typeof n.requestId=="string"){if(e.some(i=>i.requestId===n.requestId))return e;const r={requestId:n.requestId,tool:typeof n.tool=="string"?n.tool:"",input:n.input,...typeof n.toolUseId=="string"&&n.toolUseId?{toolUseId:n.toolUseId}:{}};return[...e,r]}if(n.kind==="tool_result"&&typeof n.toolUseId=="string"&&n.toolUseId){const r=e.findIndex(i=>i.toolUseId===n.toolUseId);if(r>=0)return e.filter((i,s)=>s!==r)}return e}function bN(e,t,n){const r=n===void 0?e.sessionId:n;switch(t.type){case"session:change":return{...Rc,sessionId:t.sessionId};case"session:event":{if(!r||t.sessionId!==r)return e;const i=typeof t.event.seq=="number"?t.event.seq:-1,s=[...e.events,t.event],o=i>e.lastSeq?i:e.lastSeq,a=Vp(e.pendingPermissions,t.event);return{...e,events:s,lastSeq:o,pendingPermissions:a}}case"session:status":return!r||t.sessionId!==r?e:{...e,status:t.status};case"session:events":{if(!r||t.sessionId!==r)return e;const i=t.events.map(o=>o.event),s=i.reduce((o,a)=>Vp(o,a),[]);return{...e,sessionId:t.sessionId,events:i,lastSeq:t.latestSeq,pendingPermissions:s}}case"session:events:append":{if(!r||t.sessionId!==r)return e;const i=new Set;for(const c of e.events){const u=c.seq;typeof u=="number"&&i.add(u)}const s=[];for(const c of t.events)typeof c.seq=="number"&&(i.has(c.seq)||s.push(c.event));const o=t.latestSeq>e.lastSeq?t.latestSeq:e.lastSeq;if(s.length===0)return o===e.lastSeq?e:{...e,lastSeq:o};const a=[...e.events,...s].sort((c,u)=>{const d=c.seq??-1,f=u.seq??-1;return d-f}),l=s.reduce((c,u)=>Vp(c,u),e.pendingPermissions);return{...e,events:a,lastSeq:o,pendingPermissions:l}}case"permission:request":{if(!r||t.sessionId!==r||e.pendingPermissions.some(s=>s.requestId===t.requestId))return e;const i={requestId:t.requestId,tool:t.tool,input:t.input,...t.toolUseId?{toolUseId:t.toolUseId}:{}};return{...e,pendingPermissions:[...e.pendingPermissions,i]}}case"permission:clear":{if(!r||r!==t.sessionId)return e;const i=t.requestId,s=e.pendingPermissions.findIndex(c=>c.requestId===i),o=s>=0?e.pendingPermissions.filter((c,u)=>u!==s):e.pendingPermissions;if(e.events.length===0)return o===e.pendingPermissions?e:{...e,pendingPermissions:o};const a=e.events.length-1,l=e.events[a];return l.kind==="permission_request"&&l.requestId===i?{...e,pendingPermissions:o,events:e.events.slice(0,a)}:o===e.pendingPermissions?e:{...e,pendingPermissions:o}}case"session:question":return!r||t.sessionId!==r?e:{...e,pendingQuestions:{...e.pendingQuestions,[t.toolUseId]:{toolUseId:t.toolUseId,requestId:t.requestId,questions:t.questions}}};case"session:question:clear":{if(!r||t.sessionId!==r||!(t.toolUseId in e.pendingQuestions))return e;const{[t.toolUseId]:i,...s}=e.pendingQuestions;return{...e,pendingQuestions:s}}case"session:question:submitted":{if(!r||t.sessionId!==r)return e;const i=e.pendingQuestions[t.toolUseId];return i?{...e,pendingQuestions:{...e.pendingQuestions,[t.toolUseId]:{...i,submittedAnswers:t.answers}}}:e}case"session:rewound":return!r||t.sessionId!==r?e:{...e,pendingPermissions:[],status:"idle"};case"ready":{if(!r)return e;const i=t.runningSessions.find(o=>o.sessionId===r);if(i!=null&&i.freshSpawn)return{...Rc,sessionId:r};const s=(i==null?void 0:i.status)??"idle";return s===e.status?e:{...e,status:s}}case"daemon:disconnected":return{...e,pendingPermissions:[]};default:return e}}const BO="session/";function zO(e){return{sid:e.slice(BO.length)}}const $O=new Set(rN);function wN(e){return $O.has(e)}function Pb(e){return wN(e)?e:"idle"}function FO(e,t){return{start(n){const{sid:r}=zO(n);let i=!1,s=-1;const o=f=>{t(n,p=>bN(p??Rc,f,r))},a=async f=>{const p=f==="baseline"?-1:s;try{const m=await e.request("session:events",{sessionId:r,afterSeq:p});if(i)return;const v=m.events??[],y=m.latestSeq??-1;if(f==="baseline")o({type:"session:events",sessionId:r,events:v,latestSeq:y}),s=y;else{const _=m.bufferStartSeq??0,x=y<p||_>p+1;o({type:x?"session:events":"session:events:append",sessionId:r,events:v,latestSeq:y}),s=Math.max(s,y)}}catch{}},l=async()=>{try{const f=await e.request("info");if(i)return;o({type:"ready",runningSessions:(f.runningSessions??[]).map(p=>({sessionId:p.sessionId,freshSpawn:p.freshSpawn,status:Pb(p.status)}))})}catch{}},c=async()=>{try{await e.request("session:subscribe",{sessionId:r})}catch{}i||(await a(s<0?"baseline":"delta"),!i&&await l())},u=e.onFrame((f,p)=>{if(!i)if(f==="session:event"){const m=p;if(m.sessionId!==r)return;const v=m.event.seq;De("session-events","push session:event",{sid:r,kind:m.event.kind,seq:v,lastSeqBefore:s}),o({type:"session:event",sessionId:m.sessionId,event:m.event}),typeof v=="number"&&v>s&&(s=v)}else if(f==="session:status"){const m=p;if(m.sessionId!==r)return;if(!wN(m.status)){De("session-events","push session:status drop",{sid:r,status:m.status});return}De("session-events","push session:status",{sid:r,status:m.status}),o({type:"session:status",sessionId:m.sessionId,status:m.status})}else if(f==="session:cleared"){if(p.sessionId!==r)return;De("session-events","push session:cleared",{sid:r}),o({type:"session:change",sessionId:r}),s=-1}else if(f==="permission:request"){const m=p;if(m.sessionId!==r)return;o({type:"permission:request",sessionId:m.sessionId,requestId:m.requestId,tool:m.tool,input:m.input,...typeof m.toolUseId=="string"&&m.toolUseId?{toolUseId:m.toolUseId}:{}})}else if(f==="session:question"){const m=p;if(m.sessionId!==r)return;o({type:"session:question",sessionId:m.sessionId,toolUseId:m.toolUseId,requestId:m.requestId,questions:m.questions})}else if(f==="session:question:cleared"){const m=p;if(m.sessionId!==r)return;m.answers&&Object.keys(m.answers).length>0?o({type:"session:question:submitted",sessionId:m.sessionId,toolUseId:m.toolUseId,answers:m.answers}):o({type:"session:question:clear",sessionId:m.sessionId,toolUseId:m.toolUseId})}else if(f==="session:rewound"){const m=p;if(m.sessionId!==r)return;o({type:"session:rewound",sessionId:m.sessionId,userMessageId:m.userMessageId})}else f==="ready"&&o({type:"ready",runningSessions:(p.runningSessions??[]).map(v=>({sessionId:v.sessionId,freshSpawn:v.freshSpawn,status:Pb(v.status)}))})}),d=e.onConnect(()=>{c()});return e.isConnected&&c(),()=>{i=!0,u(),d(),e.request("session:unsubscribe",{sessionId:r}).catch(()=>{})}}}}const HO=new Set(["tunnel:ready","tunnel:exited","tunnel:unavailable"]);function UO(e,t){return{start(n){let r=!1;const i=async()=>{try{const a=await e.request("info",void 0);if(r)return;t(n,()=>a)}catch{}},s=e.onConnect(()=>{i()}),o=e.onFrame(a=>{HO.has(a)&&i()});return i(),()=>{r=!0,s(),o()}}}}function WO(){return{start(){return()=>{}}}}function VO(e,t){return{start(n){let r=!1;const i=async()=>{try{const o=await e.request("persona:list",{});if(r)return;t(n,()=>o.personas??[])}catch{}},s=e.onConnect(()=>{i()});return i(),()=>{r=!0,s()}}}}function qO(e){const t=jO(e),n=AO();let r=null;const i=(o,a)=>{r==null||r.setData(o,a)};n.register(/^capabilities\//,LO(t,i)),n.register(/^sessions$/,OO(t,i)),n.register(/^session\//,FO(t,i)),n.register(/^personas$/,VO(t,i)),n.register(/^persona-detail\//,WO()),n.register(/^daemon-info$/,UO(t,i));const s=MO({onFirstObserver:o=>{o&&n.activate(o)},onLastObserver:o=>{o&&n.deactivate(o)}});return r=s,{cache:s,channel:t}}class F_{constructor(t){this.client=t}info(){return this.client.request("info")}attachmentSignUrl(t){return this.client.request("attachment.signUrl",t)}attachmentGroupAdd(t,n,r){return this.client.request("attachment.groupAdd",{sessionId:t,relPath:n,...r?{label:r}:{}})}attachmentGroupRemove(t,n){return this.client.request("attachment.groupRemove",{sessionId:t,relPath:n})}attachmentGroupList(t){return this.client.request("attachment.groupList",{sessionId:t})}sessionCreate(t){return this.client.request("session:create",t)}appBuilderListProjects(){return this.client.request("appBuilder:listProjects",{})}appBuilderGetProject(t){return this.client.request("appBuilder:getProject",{sessionId:t})}appBuilderUpdateProjectPort(t,n){return this.client.request("appBuilder:updateProjectPort",{name:t,newPort:n})}appBuilderStartDevServer(t,n){return this.client.request("appBuilder:startDevServer",{sessionId:t,...n!=null&&n.force?{force:!0}:{}})}appBuilderStopDevServer(t){return this.client.request("appBuilder:stopDevServer",{sessionId:t})}appBuilderPublish(t){return this.client.request("appBuilder:publish",{name:t})}appBuilderDismissPublishJob(t){return this.client.request("appBuilder:dismissPublishJob",{name:t})}sessionList(){return this.client.request("session:list")}sessionGet(t){return this.client.request("session:get",{sessionId:t})}sessionUpdate(t,n){return this.client.request("session:update",{sessionId:t,patch:n})}sessionDelete(t){return this.client.request("session:delete",{sessionId:t})}sessionSend(t,n){return this.client.request("session:send",{sessionId:t,text:n})}sessionStop(t){return this.client.request("session:stop",{sessionId:t})}sessionInterrupt(t){return this.client.request("session:interrupt",{sessionId:t})}sessionRewind(t){return this.client.request("session:rewind",t)}sessionRewindableMessageIds(t){return this.client.request("session:rewindable-message-ids",{sessionId:t})}sessionRewindDiff(t){return this.client.request("session:rewind-diff",t)}sessionNew(t){return this.client.request("session:new",{sessionId:t})}sessionFork(t){return this.client.request("session:fork",t)}sessionResume(t,n){return this.client.request("session:resume",{sessionId:t,toolSessionId:n})}sessionObserve(t){return this.client.request("session:observe",t)}sessionEvents(t,n){return this.client.request("session:events",{sessionId:t,afterSeq:n})}sessionSubscribe(t){return this.client.request("session:subscribe",{sessionId:t})}sessionUnsubscribe(t){return this.client.request("session:unsubscribe",{sessionId:t})}pinSession(t,n){return this.client.request("session:pin",{sessionId:t,pinned:n})}reorderPins(t){return this.client.request("session:reorderPins",{orderedIds:t})}peerSessionUpsert(t){return this.client.request("peerSession:upsert",t)}peerSessionRemove(t){return this.client.request("peerSession:remove",{sessionId:t})}permissionRespond(t){return this.client.request("permission:respond",t)}answerQuestion(t){return this.client.request("session:answerQuestion",t)}cancelQuestion(t){return this.client.request("session:cancelQuestion",t)}historyProjects(){return this.client.request("history:projects")}historyList(t){return this.client.request("history:list",{projectPath:t})}historyRead(t){return this.client.request("history:read",t)}historySubagents(t){return this.client.request("history:subagents",t)}historySubagentRead(t){return this.client.request("history:subagent-read",t)}listRecentDirs(){return this.client.request("history:recentDirs",{})}getGitRoot(t){return this.client.request("git:root",{cwd:t})}getGitBranch(t){return this.client.request("git:branch",{cwd:t})}listGitBranches(t){return this.client.request("git:branches",{cwd:t})}personaCreate(t){return this.client.request("persona:create",t)}personaList(){return this.client.request("persona:list",{})}personaGet(t){return this.client.request("persona:get",{personaId:t})}personaUpdate(t,n){return this.client.request("persona:update",{personaId:t,patch:n})}personaDelete(t){return this.client.request("persona:delete",{personaId:t})}visitorList(){return this.client.request("visitor:list",{})}workspaceList(t={}){return this.client.request("workspace:list",t)}workspaceRead(t){return this.client.request("workspace:read",t)}skillsList(t,n){return this.client.request("skills:list",{cwd:t,...n?{tool:n}:{}})}agentsList(t,n){return this.client.request("agents:list",{cwd:t,...n?{tool:n}:{}})}capabilitiesGet(t="claude"){return this.client.request("capabilities:get",{tool:t})}shiftList(){return this.client.request("shift:list")}}function KO(e){const[t,n]=g.useState(e.isOpen?{kind:"connected",url:""}:{kind:"connecting"});return g.useEffect(()=>{const r=e.on("ready",l=>{const c=l;n(u=>({kind:"connected",url:u.kind==="connected"?u.url:"",mode:u.kind==="connected"?u.mode:void 0,daemonVersion:c.version,protocolVersion:c.protocolVersion}))}),i=e.on("daemon:connected",l=>{const c=l;n(u=>({kind:"connected",url:c.url,mode:c.mode,daemonVersion:u.kind==="connected"?u.daemonVersion:void 0,protocolVersion:u.kind==="connected"?u.protocolVersion:void 0}))}),s=e.on("daemon:disconnected",l=>{const c=(l==null?void 0:l.reason)??"";/auth failed|auth timeout|auth required|auth handshake timeout/i.test(c)?n({kind:"auth-failed",reason:c}):n({kind:"disconnected",reason:c})}),o=e.on("daemon:reconnecting",l=>{const c=l;n({kind:"reconnecting",attempt:c.attempt,nextDelayMs:c.nextDelayMs,scheduledAt:c.scheduledAt??Date.now()})}),a=e.on("daemon:version-mismatch",l=>{const c=l;n({kind:"version-mismatch",daemonProtocol:c.daemonProtocol,supportedProtocol:c.supportedProtocol})});return()=>{r(),i(),s(),o(),a()}},[e]),t}function GO(e){const t=ko(),n=si(e.kind==="connected"?"sessions":""),r=g.useCallback(async()=>{t.setData("sessions",i=>i??[])},[t]);return{sessions:n??[],loading:!1,loaded:n!==void 0,error:null,refresh:r}}function Xa(){const e=Rs();return g.useMemo(()=>new F_(e),[e])}function SN(e){return{personaId:e.personaId,label:e.label,model:e.model,tool:e.tool,iconKey:e.iconKey,public:e.public,createdAt:e.createdAt,updatedAt:e.updatedAt}}function kN(){const e=ko(),t=Xa(),n=si("personas")??[],r=g.useMemo(()=>n.map(s=>SN(s)),[n]),i=g.useCallback(async()=>{const s=await t.personaList();e.setData("personas",()=>s.personas??[])},[t,e]);return{personas:r,raw:n,loaded:si("personas")!==void 0,refresh:i}}function CN(e){const{raw:t}=kN(),n=ko(),r=Xa(),i=e?t.find(a=>a.personaId===e)??null:null,s=i?SN(i):null,o=g.useCallback(async()=>{if(!e)return;const a=await r.personaList();n.setData("personas",()=>a.personas??[])},[e,r,n]);return{persona:s,raw:i,loaded:!!s,refresh:o}}function XO(e){const t=Xa(),n=ko(),r=e?`persona-detail/${e}`:"",i=si(r),s=g.useCallback(async()=>{const o={personality:"",skills:[],plugins:[],sandboxSettings:null};if(!e)return o;const a=await t.personaGet(e);let l;if("persona"in a&&a.persona===null)l=o;else{const c=a;l={personality:c.personality??"",skills:c.skills??[],plugins:c.plugins??[],sandboxSettings:c.sandboxSettings??null}}return n.setData(r,()=>l),l},[t,n,e,r]);return g.useEffect(()=>{e&&s()},[e,s]),{personality:(i==null?void 0:i.personality)??"",skills:(i==null?void 0:i.skills)??[],plugins:(i==null?void 0:i.plugins)??[],sandboxSettings:(i==null?void 0:i.sandboxSettings)??null,loaded:i!==void 0,refresh:s}}function EN(){const e=ko(),t=Xa();return g.useCallback(async()=>{const n=await t.personaList();e.setData("personas",()=>n.personas??[])},[e,t])}function YO(){const e=Xa(),t=EN();return g.useCallback(async(n,r)=>{const i=await e.personaUpdate(n,r);return await t(),i},[e,t])}function ZO(){const e=Xa(),t=EN();return g.useCallback(async n=>{await e.personaDelete(n),await t()},[e,t])}const Rb="clawd:sidebar:tree-collapsed";function QO(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function JO(e){const t=QO(e);if(!Array.isArray(t))return new Set;const n=new Set;for(const r of t)typeof r=="string"&&n.add(r);return n}function eB(){const e=N_(),[t,n]=g.useState(()=>new Set),r=g.useRef(t);r.current=t,g.useEffect(()=>{let l=!1;return(async()=>{try{const c=await e.kv.get(Rb);if(l)return;n(JO(c))}catch{}})(),()=>{l=!0}},[e]);const i=g.useCallback(l=>{e.kv.set(Rb,[...l]).catch(()=>{})},[e]),s=g.useCallback(l=>r.current.has(l),[]),o=g.useCallback(l=>{n(c=>{const u=new Set(c);return u.has(l)?u.delete(l):u.add(l),i(u),u})},[i]),a=g.useCallback(l=>{n(c=>{let u=!1;const d=new Set;for(const f of c)l.has(f)?d.add(f):u=!0;return u?(i(d),d):c})},[i]);return{isCollapsed:s,toggle:o,prune:a}}const H_=g.createContext(null);function tB(){const e=g.useContext(H_);if(!e)throw new Error("SessionTreeCollapsedContext.Provider missing — wrap SessionTreeNode tree with <SessionTreeCollapsedContext.Provider value={useSessionTreeCollapsed()}>");return e}/**
|
|
95
|
+
`,boxShadowTabsOverflowLeft:"inset 10px 0 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowRight:"inset -10px 0 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowTop:"inset 0 10px 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowBottom:"inset 0 -10px 8px -8px rgba(0, 0, 0, 0.08)"}),r)}var nb=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};const eD={lineHeight:!0,lineHeightSM:!0,lineHeightLG:!0,lineHeightHeading1:!0,lineHeightHeading2:!0,lineHeightHeading3:!0,lineHeightHeading4:!0,lineHeightHeading5:!0,opacityLoading:!0,fontWeightStrong:!0,zIndexPopupBase:!0,zIndexBase:!0,opacityImage:!0},tD={motionBase:!0,motionUnit:!0},nD={screenXS:!0,screenXSMin:!0,screenXSMax:!0,screenSM:!0,screenSMMin:!0,screenSMMax:!0,screenMD:!0,screenMDMin:!0,screenMDMax:!0,screenLG:!0,screenLGMin:!0,screenLGMax:!0,screenXL:!0,screenXLMin:!0,screenXLMax:!0,screenXXL:!0,screenXXLMin:!0},UE=(e,t,n)=>{const r=n.getDerivativeToken(e),{override:i}=t,s=nb(t,["override"]);let o=Object.assign(Object.assign({},r),{override:i});return o=HE(o),s&&Object.entries(s).forEach(([a,l])=>{const{theme:c}=l,u=nb(l,["theme"]);let d=u;c&&(d=UE(Object.assign(Object.assign({},o),u),{override:u},c)),o[a]=d}),o};function WE(){const{token:e,hashed:t,theme:n,override:r,cssVar:i}=st.useContext($E),s=`${Q4}-${t||""}`,o=n||zE,[a,l,c]=H3(o,[Ec,e],{salt:s,override:r,getComputedToken:UE,formatToken:HE,cssVar:i&&{prefix:i.prefix,key:i.key,unitless:eD,ignore:tD,preserve:nD}});return[o,c,t?l:"",a,i]}const rD=()=>({display:"inline-flex",alignItems:"center",color:"inherit",fontStyle:"normal",lineHeight:0,textAlign:"center",textTransform:"none",verticalAlign:"-0.125em",textRendering:"optimizeLegibility","-webkit-font-smoothing":"antialiased","-moz-osx-font-smoothing":"grayscale","> *":{lineHeight:1},svg:{display:"inline-block"}}),iD=e=>({[`.${e}`]:Object.assign(Object.assign({},rD()),{[`.${e} .${e}-icon`]:{display:"block"}})}),sD=(e,t)=>{const[n,r]=WE();return g4({token:r,hashId:"",path:["ant-design-icons",e],nonce:()=>t==null?void 0:t.nonce,layer:{name:"antd"}},()=>iD(e))},oD=Object.assign({},Fa),{useId:rb}=oD,aD=()=>"",lD=typeof rb>"u"?aD:rb;function cD(e,t,n){var r;const i=e||{},s=i.inherit===!1||!t?Object.assign(Object.assign({},vh),{hashed:(r=t==null?void 0:t.hashed)!==null&&r!==void 0?r:vh.hashed,cssVar:t==null?void 0:t.cssVar}):t,o=lD();return lE(()=>{var a,l;if(!e)return t;const c=Object.assign({},s.components);Object.keys(e.components||{}).forEach(f=>{c[f]=Object.assign(Object.assign({},c[f]),e.components[f])});const u=`css-var-${o.replace(/:/g,"")}`,d=((a=i.cssVar)!==null&&a!==void 0?a:s.cssVar)&&Object.assign(Object.assign(Object.assign({prefix:n==null?void 0:n.prefixCls},typeof s.cssVar=="object"?s.cssVar:{}),typeof i.cssVar=="object"?i.cssVar:{}),{key:typeof i.cssVar=="object"&&((l=i.cssVar)===null||l===void 0?void 0:l.key)||u});return Object.assign(Object.assign(Object.assign({},s),i),{token:Object.assign(Object.assign({},s.token),i.token),components:c,cssVar:d})},[i,s],(a,l)=>a.some((c,u)=>{const d=l[u];return!g3(c,d,!0)}))}var uD=["children"],VE=g.createContext({});function dD(e){var t=e.children,n=zg(e,uD);return g.createElement(VE.Provider,{value:n},t)}var hD=function(e){uE(n,e);var t=hE(n);function n(){return Wa(this,n),t.apply(this,arguments)}return Va(n,[{key:"render",value:function(){return this.props.children}}]),n}(g.Component);function fD(e){var t=g.useReducer(function(a){return a+1},0),n=Ze(t,2),r=n[1],i=g.useRef(e),s=av(function(){return i.current}),o=av(function(a){i.current=typeof a=="function"?a(i.current):a,r()});return[s,o]}var Qi="none",$u="appear",Fu="enter",Hu="leave",ib="none",Tr="prepare",aa="start",la="active",O_="end",qE="prepared";function sb(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit".concat(e)]="webkit".concat(t),n["Moz".concat(e)]="moz".concat(t),n["ms".concat(e)]="MS".concat(t),n["O".concat(e)]="o".concat(t.toLowerCase()),n}function pD(e,t){var n={animationend:sb("Animation","AnimationEnd"),transitionend:sb("Transition","TransitionEnd")};return e&&("AnimationEvent"in t||delete n.animationend.animation,"TransitionEvent"in t||delete n.transitionend.transition),n}var mD=pD(Li(),typeof window<"u"?window:{}),KE={};if(Li()){var gD=document.createElement("div");KE=gD.style}var Uu={};function GE(e){if(Uu[e])return Uu[e];var t=mD[e];if(t)for(var n=Object.keys(t),r=n.length,i=0;i<r;i+=1){var s=n[i];if(Object.prototype.hasOwnProperty.call(t,s)&&s in KE)return Uu[e]=t[s],Uu[e]}return""}var XE=GE("animationend"),YE=GE("transitionend"),ZE=!!(XE&&YE),ob=XE||"animationend",ab=YE||"transitionend";function lb(e,t){if(!e)return null;if(Ct(e)==="object"){var n=t.replace(/-\w/g,function(r){return r[1].toUpperCase()});return e[n]}return"".concat(e,"-").concat(t)}const vD=function(e){var t=g.useRef();function n(i){i&&(i.removeEventListener(ab,e),i.removeEventListener(ob,e))}function r(i){t.current&&t.current!==i&&n(t.current),i&&i!==t.current&&(i.addEventListener(ab,e),i.addEventListener(ob,e),t.current=i)}return g.useEffect(function(){return function(){n(t.current)}},[]),[r,n]};var QE=Li()?g.useLayoutEffect:g.useEffect;const _D=function(){var e=g.useRef(null);function t(){Og.cancel(e.current)}function n(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;t();var s=Og(function(){i<=1?r({isCanceled:function(){return s!==e.current}}):n(r,i-1)});e.current=s}return g.useEffect(function(){return function(){t()}},[]),[n,t]};var xD=[Tr,aa,la,O_],yD=[Tr,qE],JE=!1,bD=!0;function eN(e){return e===la||e===O_}const wD=function(e,t,n){var r=lv(ib),i=Ze(r,2),s=i[0],o=i[1],a=_D(),l=Ze(a,2),c=l[0],u=l[1];function d(){o(Tr,!0)}var f=t?yD:xD;return QE(function(){if(s!==ib&&s!==O_){var p=f.indexOf(s),m=f[p+1],v=n(s);v===JE?o(m,!0):m&&c(function(y){function _(){y.isCanceled()||o(m,!0)}v===!0?_():Promise.resolve(v).then(_)})}},[e,s]),g.useEffect(function(){return function(){u()}},[]),[d,s]};function SD(e,t,n,r){var i=r.motionEnter,s=i===void 0?!0:i,o=r.motionAppear,a=o===void 0?!0:o,l=r.motionLeave,c=l===void 0?!0:l,u=r.motionDeadline,d=r.motionLeaveImmediately,f=r.onAppearPrepare,p=r.onEnterPrepare,m=r.onLeavePrepare,v=r.onAppearStart,y=r.onEnterStart,_=r.onLeaveStart,x=r.onAppearActive,b=r.onEnterActive,w=r.onLeaveActive,S=r.onAppearEnd,k=r.onEnterEnd,T=r.onLeaveEnd,N=r.onVisibleChanged,O=lv(),P=Ze(O,2),L=P[0],R=P[1],I=fD(Qi),j=Ze(I,2),B=j[0],$=j[1],F=lv(null),A=Ze(F,2),D=A[0],C=A[1],H=B(),q=g.useRef(!1),M=g.useRef(null);function ne(){return n()}var oe=g.useRef(!1);function V(){$(Qi),C(null,!0)}var pe=av(function(Ue){var tt=B();if(tt!==Qi){var mt=ne();if(!(Ue&&!Ue.deadline&&Ue.target!==mt)){var Xt=oe.current,pn;tt===$u&&Xt?pn=S==null?void 0:S(mt,Ue):tt===Fu&&Xt?pn=k==null?void 0:k(mt,Ue):tt===Hu&&Xt&&(pn=T==null?void 0:T(mt,Ue)),Xt&&pn!==!1&&V()}}}),Oe=vD(pe),re=Ze(Oe,1),Me=re[0],Fe=function(tt){switch(tt){case $u:return be(be(be({},Tr,f),aa,v),la,x);case Fu:return be(be(be({},Tr,p),aa,y),la,b);case Hu:return be(be(be({},Tr,m),aa,_),la,w);default:return{}}},We=g.useMemo(function(){return Fe(H)},[H]),ge=wD(H,!e,function(Ue){if(Ue===Tr){var tt=We[Tr];return tt?tt(ne()):JE}if(wt in We){var mt;C(((mt=We[wt])===null||mt===void 0?void 0:mt.call(We,ne(),null))||null)}return wt===la&&H!==Qi&&(Me(ne()),u>0&&(clearTimeout(M.current),M.current=setTimeout(function(){pe({deadline:!0})},u))),wt===qE&&V(),bD}),Ge=Ze(ge,2),Gt=Ge[0],wt=Ge[1],It=eN(wt);oe.current=It;var ln=g.useRef(null);QE(function(){if(!(q.current&&ln.current===t)){R(t);var Ue=q.current;q.current=!0;var tt;!Ue&&t&&a&&(tt=$u),Ue&&t&&s&&(tt=Fu),(Ue&&!t&&c||!Ue&&d&&!t&&c)&&(tt=Hu);var mt=Fe(tt);tt&&(e||mt[Tr])?($(tt),Gt()):$(Qi),ln.current=t}},[t]),g.useEffect(function(){(H===$u&&!a||H===Fu&&!s||H===Hu&&!c)&&$(Qi)},[a,s,c]),g.useEffect(function(){return function(){q.current=!1,clearTimeout(M.current)}},[]);var Bt=g.useRef(!1);g.useEffect(function(){L&&(Bt.current=!0),L!==void 0&&H===Qi&&((Bt.current||L)&&(N==null||N(L)),Bt.current=!0)},[L,H]);var at=D;return We[Tr]&&wt===aa&&(at=Be({transition:"none"},at)),[H,wt,at,L??t]}function kD(e){var t=e;Ct(e)==="object"&&(t=e.transitionSupport);function n(i,s){return!!(i.motionName&&t&&s!==!1)}var r=g.forwardRef(function(i,s){var o=i.visible,a=o===void 0?!0:o,l=i.removeOnLeave,c=l===void 0?!0:l,u=i.forceRender,d=i.children,f=i.motionName,p=i.leavedClassName,m=i.eventProps,v=g.useContext(VE),y=v.motion,_=n(i,y),x=g.useRef(),b=g.useRef();function w(){try{return x.current instanceof HTMLElement?x.current:Jj(b.current)}catch{return null}}var S=SD(_,a,w,i),k=Ze(S,4),T=k[0],N=k[1],O=k[2],P=k[3],L=g.useRef(P);P&&(L.current=!0);var R=g.useCallback(function(A){x.current=A,r3(s,A)},[s]),I,j=Be(Be({},m),{},{visible:a});if(!d)I=null;else if(T===Qi)P?I=d(Be({},j),R):!c&&L.current&&p?I=d(Be(Be({},j),{},{className:p}),R):u||!c&&!p?I=d(Be(Be({},j),{},{style:{display:"none"}}),R):I=null;else{var B;N===Tr?B="prepare":eN(N)?B="active":N===aa&&(B="start");var $=lb(f,"".concat(T,"-").concat(B));I=d(Be(Be({},j),{},{className:Fj(lb(f,T),be(be({},$,$&&B),f,typeof f=="string")),style:O}),R)}if(g.isValidElement(I)&&i3(I)){var F=s3(I);F||(I=g.cloneElement(I,{ref:R}))}return g.createElement(hD,{ref:b},I)});return r.displayName="CSSMotion",r}const CD=kD(ZE);var cv="add",uv="keep",dv="remove",Up="removed";function ED(e){var t;return e&&Ct(e)==="object"&&"key"in e?t=e:t={key:e},Be(Be({},t),{},{key:String(t.key)})}function hv(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return e.map(ED)}function ND(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=[],r=0,i=t.length,s=hv(e),o=hv(t);s.forEach(function(c){for(var u=!1,d=r;d<i;d+=1){var f=o[d];if(f.key===c.key){r<d&&(n=n.concat(o.slice(r,d).map(function(p){return Be(Be({},p),{},{status:cv})})),r=d),n.push(Be(Be({},f),{},{status:uv})),r+=1,u=!0;break}}u||n.push(Be(Be({},c),{},{status:dv}))}),r<i&&(n=n.concat(o.slice(r).map(function(c){return Be(Be({},c),{},{status:cv})})));var a={};n.forEach(function(c){var u=c.key;a[u]=(a[u]||0)+1});var l=Object.keys(a).filter(function(c){return a[c]>1});return l.forEach(function(c){n=n.filter(function(u){var d=u.key,f=u.status;return d!==c||f!==dv}),n.forEach(function(u){u.key===c&&(u.status=uv)})}),n}var TD=["component","children","onVisibleChanged","onAllRemoved"],PD=["status"],RD=["eventProps","visible","children","motionName","motionAppear","motionEnter","motionLeave","motionLeaveImmediately","motionDeadline","removeOnLeave","leavedClassName","onAppearPrepare","onAppearStart","onAppearActive","onAppearEnd","onEnterStart","onEnterActive","onEnterEnd","onLeaveStart","onLeaveActive","onLeaveEnd"];function ID(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:CD,n=function(r){uE(s,r);var i=hE(s);function s(){var o;Wa(this,s);for(var a=arguments.length,l=new Array(a),c=0;c<a;c++)l[c]=arguments[c];return o=i.call.apply(i,[this].concat(l)),be(Dg(o),"state",{keyEntities:[]}),be(Dg(o),"removeKey",function(u){o.setState(function(d){var f=d.keyEntities.map(function(p){return p.key!==u?p:Be(Be({},p),{},{status:Up})});return{keyEntities:f}},function(){var d=o.state.keyEntities,f=d.filter(function(p){var m=p.status;return m!==Up}).length;f===0&&o.props.onAllRemoved&&o.props.onAllRemoved()})}),o}return Va(s,[{key:"render",value:function(){var a=this,l=this.state.keyEntities,c=this.props,u=c.component,d=c.children,f=c.onVisibleChanged;c.onAllRemoved;var p=zg(c,TD),m=u||g.Fragment,v={};return RD.forEach(function(y){v[y]=p[y],delete p[y]}),delete p.keys,g.createElement(m,p,l.map(function(y,_){var x=y.status,b=zg(y,PD),w=x===cv||x===uv;return g.createElement(t,ph({},v,{key:b.key,visible:w,eventProps:b,onVisibleChanged:function(k){f==null||f(k,{key:b.key}),k||a.removeKey(b.key)}}),function(S,k){return d(Be(Be({},S),{},{index:_}),k)})}))}}],[{key:"getDerivedStateFromProps",value:function(a,l){var c=a.keys,u=l.keyEntities,d=hv(c),f=ND(u,d);return{keyEntities:f.filter(function(p){var m=u.find(function(v){var y=v.key;return p.key===y});return!(m&&m.status===Up&&p.status===dv)})}}}]),s}(g.Component);return be(n,"defaultProps",{component:"div"}),n}ID(ZE);const cb=g.createContext(!0);function MD(e){const t=g.useContext(cb),{children:n}=e,[,r]=WE(),{motion:i}=r,s=g.useRef(!1);return s.current||(s.current=t!==i),s.current?g.createElement(cb.Provider,{value:i},g.createElement(dD,{motion:i},n)):n}const AD=()=>null;var jD=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};const DD=["getTargetContainer","getPopupContainer","renderEmpty","input","pagination","form","select","button"];let tN;function LD(){return tN||sv}function OD(e){return Object.keys(e).some(t=>t.endsWith("Color"))}const BD=e=>{const{prefixCls:t,iconPrefixCls:n,theme:r,holderRender:i}=e;t!==void 0&&(tN=t),r&&OD(r)&&q4(LD(),r)},zD=e=>{const{children:t,csp:n,autoInsertSpaceInButton:r,alert:i,anchor:s,form:o,locale:a,componentSize:l,direction:c,space:u,splitter:d,virtual:f,dropdownMatchSelectWidth:p,popupMatchSelectWidth:m,popupOverflow:v,legacyLocale:y,parentContext:_,iconPrefixCls:x,theme:b,componentDisabled:w,segmented:S,statistic:k,spin:T,calendar:N,carousel:O,cascader:P,collapse:L,typography:R,checkbox:I,descriptions:j,divider:B,drawer:$,skeleton:F,steps:A,image:D,layout:C,list:H,mentions:q,modal:M,progress:ne,result:oe,slider:V,breadcrumb:pe,menu:Oe,pagination:re,input:Me,textArea:Fe,empty:We,badge:ge,radio:Ge,rate:Gt,switch:wt,transfer:It,avatar:ln,message:Bt,tag:at,table:Ue,card:tt,tabs:mt,timeline:Xt,timePicker:pn,upload:U,notification:Z,tree:ve,colorPicker:we,datePicker:Q,rangePicker:Xe,flex:Yt,wave:Zt,dropdown:ue,warning:Ne,tour:Qe,tooltip:Dn,popover:Qt,popconfirm:nl,floatButton:Ao,floatButtonGroup:gu,variant:vu,inputNumber:op,treeSelect:ap}=e,_u=g.useCallback((Tt,$t)=>{const{prefixCls:or}=e;if($t)return $t;const Ln=or||_.getPrefixCls("");return Tt?`${Ln}-${Tt}`:Ln},[_.getPrefixCls,e.prefixCls]),jo=x||_.iconPrefixCls||FE,Do=n||_.csp;sD(jo,Do);const rl=cD(b,_.theme,{prefixCls:_u("")}),il={csp:Do,autoInsertSpaceInButton:r,alert:i,anchor:s,locale:a||y,direction:c,space:u,splitter:d,virtual:f,popupMatchSelectWidth:m??p,popupOverflow:v,getPrefixCls:_u,iconPrefixCls:jo,theme:rl,segmented:S,statistic:k,spin:T,calendar:N,carousel:O,cascader:P,collapse:L,typography:R,checkbox:I,descriptions:j,divider:B,drawer:$,skeleton:F,steps:A,image:D,input:Me,textArea:Fe,layout:C,list:H,mentions:q,modal:M,progress:ne,result:oe,slider:V,breadcrumb:pe,menu:Oe,pagination:re,empty:We,badge:ge,radio:Ge,rate:Gt,switch:wt,transfer:It,avatar:ln,message:Bt,tag:at,table:Ue,card:tt,tabs:mt,timeline:Xt,timePicker:pn,upload:U,notification:Z,tree:ve,colorPicker:we,datePicker:Q,rangePicker:Xe,flex:Yt,wave:Zt,dropdown:ue,warning:Ne,tour:Qe,tooltip:Dn,popover:Qt,popconfirm:nl,floatButton:Ao,floatButtonGroup:gu,variant:vu,inputNumber:op,treeSelect:ap},Ui=Object.assign({},_);Object.keys(il).forEach(Tt=>{il[Tt]!==void 0&&(Ui[Tt]=il[Tt])}),DD.forEach(Tt=>{const $t=e[Tt];$t&&(Ui[Tt]=$t)}),typeof r<"u"&&(Ui.button=Object.assign({autoInsertSpace:r},Ui.button));const Wi=lE(()=>Ui,Ui,(Tt,$t)=>{const or=Object.keys(Tt),Ln=Object.keys($t);return or.length!==Ln.length||or.some(Y=>Tt[Y]!==$t[Y])}),{layer:sl}=g.useContext(kf),xu=g.useMemo(()=>({prefixCls:jo,csp:Do,layer:sl?"antd":void 0}),[jo,Do,sl]);let zt=g.createElement(g.Fragment,null,g.createElement(AD,{dropdownMatchSelectWidth:p}),t);const ol=g.useMemo(()=>{var Tt,$t,or,Ln;return k4(((Tt=Nf.Form)===null||Tt===void 0?void 0:Tt.defaultValidateMessages)||{},((or=($t=Wi.locale)===null||$t===void 0?void 0:$t.Form)===null||or===void 0?void 0:or.defaultValidateMessages)||{},((Ln=Wi.form)===null||Ln===void 0?void 0:Ln.validateMessages)||{},(o==null?void 0:o.validateMessages)||{})},[Wi,o==null?void 0:o.validateMessages]);Object.keys(ol).length>0&&(zt=g.createElement(E4.Provider,{value:ol},zt)),a&&(zt=g.createElement(P4,{locale:a,_ANT_MARK__:T4},zt)),zt=g.createElement(y4.Provider,{value:xu},zt),l&&(zt=g.createElement(G4,{size:l},zt)),zt=g.createElement(MD,null,zt);const al=g.useMemo(()=>{const Tt=rl||{},{algorithm:$t,token:or,components:Ln,cssVar:Y}=Tt,_e=jD(Tt,["algorithm","token","components","cssVar"]),xe=$t&&(!Array.isArray($t)||$t.length>0)?Fg($t):zE,Ye={};Object.entries(Ln||{}).forEach(([oA,aA])=>{const hi=Object.assign({},aA);"algorithm"in hi&&(hi.algorithm===!0?hi.theme=xe:(Array.isArray(hi.algorithm)||typeof hi.algorithm=="function")&&(hi.theme=Fg(hi.algorithm)),delete hi.algorithm),Ye[oA]=hi});const di=Object.assign(Object.assign({},Ec),or);return Object.assign(Object.assign({},_e),{theme:xe,token:di,components:Ye,override:Object.assign({override:di},Ye),cssVar:Y})},[rl]);return b&&(zt=g.createElement($E.Provider,{value:al},zt)),Wi.warning&&(zt=g.createElement(C4.Provider,{value:Wi.warning},zt)),w!==void 0&&(zt=g.createElement(K4,{disabled:w},zt)),g.createElement(Tf.Provider,{value:Wi},zt)},Ka=e=>{const t=g.useContext(Tf),n=g.useContext(DE);return g.createElement(zD,Object.assign({parentContext:t,legacyLocale:n},e))};Ka.ConfigContext=Tf;Ka.SizeContext=Nc;Ka.config=BD;Ka.useConfig=X4;Object.defineProperty(Ka,"SizeContext",{get:()=>Nc});const lr=(e,t)=>new xt(e).setA(t).toRgbString(),Bo=(e,t)=>new xt(e).lighten(t).toHexString(),$D=e=>{const t=Ma(e,{theme:"dark"});return{1:t[0],2:t[1],3:t[2],4:t[3],5:t[6],6:t[5],7:t[4],8:t[6],9:t[5],10:t[4]}},FD=(e,t)=>{const n=e||"#000",r=t||"#fff";return{colorBgBase:n,colorTextBase:r,colorText:lr(r,.85),colorTextSecondary:lr(r,.65),colorTextTertiary:lr(r,.45),colorTextQuaternary:lr(r,.25),colorFill:lr(r,.18),colorFillSecondary:lr(r,.12),colorFillTertiary:lr(r,.08),colorFillQuaternary:lr(r,.04),colorBgSolid:lr(r,.95),colorBgSolidHover:lr(r,1),colorBgSolidActive:lr(r,.9),colorBgElevated:Bo(n,12),colorBgContainer:Bo(n,8),colorBgLayout:Bo(n,0),colorBgSpotlight:Bo(n,26),colorBgBlur:lr(r,.04),colorBorder:Bo(n,26),colorBorderSecondary:Bo(n,19)}},HD=(e,t)=>{const n=Object.keys(D_).map(s=>{const o=Ma(e[s],{theme:"dark"});return Array.from({length:10},()=>1).reduce((a,l,c)=>(a[`${s}-${c+1}`]=o[c],a[`${s}${c+1}`]=o[c],a),{})}).reduce((s,o)=>(s=Object.assign(Object.assign({},s),o),s),{}),r=t??L_(e),i=BE(e,{generateColorPalettes:$D,generateNeutralColorPalettes:FD});return Object.assign(Object.assign(Object.assign(Object.assign({},r),n),i),{colorPrimaryBg:i.colorPrimaryBorder,colorPrimaryBgHover:i.colorPrimaryBorderHover})},ub={defaultSeed:vh.token,defaultAlgorithm:L_,darkAlgorithm:HD};function db({children:e}){const t=N_(),[n,r]=g.useState(t.theme);return g.useEffect(()=>t.onThemeChange(r),[t]),h.jsx(Ka,{theme:{algorithm:n.mode==="dark"?ub.darkAlgorithm:ub.defaultAlgorithm,token:{colorPrimary:n.colorPrimary,colorBgContainer:n.colorBgContainer,colorText:n.colorText,colorBorder:n.colorBorder}},children:e})}const nN=["ready","session:info","session:status","session:event","session:deleted","session:rewound","session:cleared","permission:request","session:question","session:question:cleared","pong","error","subscribed","unsubscribed","auth:ok","tunnel:ready","tunnel:exited","tunnel:unavailable","session:control","session:pty","capability:tokenDeleted","contact:added","contact:pinned","contact:removed","contact:remote-access-updated","inbox:event","friend:reverseTokenOffered","auth:login:done","auth:login:failed","appBuilder:project-updated","appBuilder:publish-progress","appBuilder:publish-failed"],rN=["idle","running","running-idle","stopped","error","observing"],UD=["task-notification","slash-command","local-command","system-reminder","skill-hint","meta-text","attachment-skills","attachment-deferred-tools"],WD=["builtin","global","project","plugin"],VD=["builtin","global","project","policy","plugin"];var qe;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},e.getValidEnumValues=i=>{const s=e.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(const a of s)o[a]=i[a];return e.objectValues(o)},e.objectValues=i=>e.objectKeys(i).map(function(s){return i[s]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},e.find=(i,s)=>{for(const o of i)if(s(o))return o},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}e.joinValues=r,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(qe||(qe={}));var hb;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(hb||(hb={}));const ce=qe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ns=e=>{switch(typeof e){case"undefined":return ce.undefined;case"string":return ce.string;case"number":return Number.isNaN(e)?ce.nan:ce.number;case"boolean":return ce.boolean;case"function":return ce.function;case"bigint":return ce.bigint;case"symbol":return ce.symbol;case"object":return Array.isArray(e)?ce.array:e===null?ce.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?ce.promise:typeof Map<"u"&&e instanceof Map?ce.map:typeof Set<"u"&&e instanceof Set?ce.set:typeof Date<"u"&&e instanceof Date?ce.date:ce.object;default:return ce.unknown}},K=qe.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Ri extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,l=0;for(;l<o.path.length;){const c=o.path[l];l===o.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(o))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return i(this),r}static assert(t){if(!(t instanceof Ri))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,qe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const i of this.issues)if(i.path.length>0){const s=i.path[0];n[s]=n[s]||[],n[s].push(t(i))}else r.push(t(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Ri.create=e=>new Ri(e);const fv=(e,t)=>{let n;switch(e.code){case K.invalid_type:e.received===ce.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case K.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,qe.jsonStringifyReplacer)}`;break;case K.unrecognized_keys:n=`Unrecognized key(s) in object: ${qe.joinValues(e.keys,", ")}`;break;case K.invalid_union:n="Invalid input";break;case K.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${qe.joinValues(e.options)}`;break;case K.invalid_enum_value:n=`Invalid enum value. Expected ${qe.joinValues(e.options)}, received '${e.received}'`;break;case K.invalid_arguments:n="Invalid function arguments";break;case K.invalid_return_type:n="Invalid function return type";break;case K.invalid_date:n="Invalid date";break;case K.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:qe.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case K.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case K.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case K.custom:n="Invalid input";break;case K.invalid_intersection_types:n="Intersection results could not be merged";break;case K.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case K.not_finite:n="Number must be finite";break;default:n=t.defaultError,qe.assertNever(e)}return{message:n}};let qD=fv;function KD(){return qD}const GD=e=>{const{data:t,path:n,errorMaps:r,issueData:i}=e,s=[...n,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let a="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)a=c(o,{data:t,defaultError:a}).message;return{...i,path:s,message:a}};function ie(e,t){const n=KD(),r=GD({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===fv?void 0:fv].filter(i=>!!i)});e.common.issues.push(r)}class Tn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const i of n){if(i.status==="aborted")return ke;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const i of n){const s=await i.key,o=await i.value;r.push({key:s,value:o})}return Tn.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const i of n){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return ke;s.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[s.value]=o.value)}return{status:t.value,value:r}}}const ke=Object.freeze({status:"aborted"}),Al=e=>({status:"dirty",value:e}),Sr=e=>({status:"valid",value:e}),fb=e=>e.status==="aborted",pb=e=>e.status==="dirty",Aa=e=>e.status==="valid",_h=e=>typeof Promise<"u"&&e instanceof Promise;var me;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(me||(me={}));class ii{constructor(t,n,r,i){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const mb=(e,t)=>{if(Aa(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Ri(e.common.issues);return this._error=n,this._error}}};function Ie(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(o,a)=>{const{message:l}=e;return o.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:i}}class He{get description(){return this._def.description}_getType(t){return ns(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:ns(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Tn,ctx:{common:t.parent.common,data:t.data,parsedType:ns(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(_h(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){const r={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ns(t)},i=this._parseSync({data:t,path:r.path,parent:r});return mb(r,i)}"~validate"(t){var r,i;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ns(t)};if(!this["~standard"].async)try{const s=this._parseSync({data:t,path:[],parent:n});return Aa(s)?{value:s.value}:{issues:n.common.issues}}catch(s){(i=(r=s==null?void 0:s.message)==null?void 0:r.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(s=>Aa(s)?{value:s.value}:{issues:n.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ns(t)},i=this._parse({data:t,path:r.path,parent:r}),s=await(_h(i)?i:Promise.resolve(i));return mb(r,s)}refine(t,n){const r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,s)=>{const o=t(i),a=()=>s.addIssue({code:K.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(t,n){return this._refinement((r,i)=>t(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(t){return new uo({schema:this,typeName:Ce.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Ci.create(this,this._def)}nullable(){return ho.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ei.create(this)}promise(){return kh.create(this,this._def)}or(t){return yh.create([this,t],this._def)}and(t){return bh.create(this,t,this._def)}transform(t){return new uo({...Ie(this._def),schema:this,typeName:Ce.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Ch({...Ie(this._def),innerType:this,defaultValue:n,typeName:Ce.ZodDefault})}brand(){return new aN({typeName:Ce.ZodBranded,type:this,...Ie(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new Eh({...Ie(this._def),innerType:this,catchValue:n,typeName:Ce.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return z_.create(this,t)}readonly(){return Nh.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const XD=/^c[^\s-]{8,}$/i,YD=/^[0-9a-z]+$/,ZD=/^[0-9A-HJKMNP-TV-Z]{26}$/i,QD=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,JD=/^[a-z0-9_-]{21}$/i,eL=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,tL=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,nL=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,rL="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Wp;const iL=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,sL=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,oL=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,aL=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,lL=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,cL=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,iN="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",uL=new RegExp(`^${iN}$`);function sN(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function dL(e){return new RegExp(`^${sN(e)}$`)}function hL(e){let t=`${iN}T${sN(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function fL(e,t){return!!((t==="v4"||!t)&&iL.test(e)||(t==="v6"||!t)&&oL.test(e))}function pL(e,t){if(!eL.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function mL(e,t){return!!((t==="v4"||!t)&&sL.test(e)||(t==="v6"||!t)&&aL.test(e))}class bi extends He{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==ce.string){const s=this._getOrReturnCtx(t);return ie(s,{code:K.invalid_type,expected:ce.string,received:s.parsedType}),ke}const r=new Tn;let i;for(const s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),ie(i,{code:K.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),ie(i,{code:K.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){const o=t.data.length>s.value,a=t.data.length<s.value;(o||a)&&(i=this._getOrReturnCtx(t,i),o?ie(i,{code:K.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&ie(i,{code:K.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")nL.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"email",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Wp||(Wp=new RegExp(rL,"u")),Wp.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"emoji",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")QD.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"uuid",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")JD.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"nanoid",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")XD.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"cuid",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")YD.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"cuid2",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")ZD.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"ulid",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),ie(i,{validation:"url",code:K.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"regex",code:K.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),ie(i,{code:K.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),ie(i,{code:K.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),ie(i,{code:K.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?hL(s).test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{code:K.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?uL.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{code:K.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?dL(s).test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{code:K.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?tL.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"duration",code:K.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?fL(t.data,s.version)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"ip",code:K.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?pL(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"jwt",code:K.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?mL(t.data,s.version)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"cidr",code:K.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?lL.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"base64",code:K.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?cL.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"base64url",code:K.invalid_string,message:s.message}),r.dirty()):qe.assertNever(s);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:K.invalid_string,...me.errToObj(r)})}_addCheck(t){return new bi({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...me.errToObj(t)})}url(t){return this._addCheck({kind:"url",...me.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...me.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...me.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...me.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...me.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...me.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...me.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...me.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...me.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...me.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...me.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...me.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...me.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...me.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...me.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...me.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...me.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...me.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...me.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...me.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...me.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...me.errToObj(n)})}nonempty(t){return this.min(1,me.errToObj(t))}trim(){return new bi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new bi({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new bi({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}bi.create=e=>new bi({checks:[],typeName:Ce.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...Ie(e)});function gL(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r,s=Number.parseInt(e.toFixed(i).replace(".","")),o=Number.parseInt(t.toFixed(i).replace(".",""));return s%o/10**i}class ja extends He{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==ce.number){const s=this._getOrReturnCtx(t);return ie(s,{code:K.invalid_type,expected:ce.number,received:s.parsedType}),ke}let r;const i=new Tn;for(const s of this._def.checks)s.kind==="int"?qe.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),ie(r,{code:K.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),ie(r,{code:K.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),ie(r,{code:K.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?gL(t.data,s.value)!==0&&(r=this._getOrReturnCtx(t,r),ie(r,{code:K.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),ie(r,{code:K.not_finite,message:s.message}),i.dirty()):qe.assertNever(s);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,me.toString(n))}gt(t,n){return this.setLimit("min",t,!1,me.toString(n))}lte(t,n){return this.setLimit("max",t,!0,me.toString(n))}lt(t,n){return this.setLimit("max",t,!1,me.toString(n))}setLimit(t,n,r,i){return new ja({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:me.toString(i)}]})}_addCheck(t){return new ja({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:me.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:me.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:me.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:me.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:me.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:me.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:me.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:me.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:me.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&qe.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}ja.create=e=>new ja({checks:[],typeName:Ce.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Ie(e)});class Tc extends He{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==ce.bigint)return this._getInvalidInput(t);let r;const i=new Tn;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),ie(r,{code:K.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),ie(r,{code:K.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),ie(r,{code:K.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):qe.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return ie(n,{code:K.invalid_type,expected:ce.bigint,received:n.parsedType}),ke}gte(t,n){return this.setLimit("min",t,!0,me.toString(n))}gt(t,n){return this.setLimit("min",t,!1,me.toString(n))}lte(t,n){return this.setLimit("max",t,!0,me.toString(n))}lt(t,n){return this.setLimit("max",t,!1,me.toString(n))}setLimit(t,n,r,i){return new Tc({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:me.toString(i)}]})}_addCheck(t){return new Tc({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:me.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:me.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:me.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:me.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:me.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Tc.create=e=>new Tc({checks:[],typeName:Ce.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...Ie(e)});class pv extends He{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==ce.boolean){const r=this._getOrReturnCtx(t);return ie(r,{code:K.invalid_type,expected:ce.boolean,received:r.parsedType}),ke}return Sr(t.data)}}pv.create=e=>new pv({typeName:Ce.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Ie(e)});class xh extends He{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==ce.date){const s=this._getOrReturnCtx(t);return ie(s,{code:K.invalid_type,expected:ce.date,received:s.parsedType}),ke}if(Number.isNaN(t.data.getTime())){const s=this._getOrReturnCtx(t);return ie(s,{code:K.invalid_date}),ke}const r=new Tn;let i;for(const s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),ie(i,{code:K.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),ie(i,{code:K.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):qe.assertNever(s);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new xh({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:me.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:me.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}xh.create=e=>new xh({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:Ce.ZodDate,...Ie(e)});class gb extends He{_parse(t){if(this._getType(t)!==ce.symbol){const r=this._getOrReturnCtx(t);return ie(r,{code:K.invalid_type,expected:ce.symbol,received:r.parsedType}),ke}return Sr(t.data)}}gb.create=e=>new gb({typeName:Ce.ZodSymbol,...Ie(e)});class mv extends He{_parse(t){if(this._getType(t)!==ce.undefined){const r=this._getOrReturnCtx(t);return ie(r,{code:K.invalid_type,expected:ce.undefined,received:r.parsedType}),ke}return Sr(t.data)}}mv.create=e=>new mv({typeName:Ce.ZodUndefined,...Ie(e)});class gv extends He{_parse(t){if(this._getType(t)!==ce.null){const r=this._getOrReturnCtx(t);return ie(r,{code:K.invalid_type,expected:ce.null,received:r.parsedType}),ke}return Sr(t.data)}}gv.create=e=>new gv({typeName:Ce.ZodNull,...Ie(e)});class vb extends He{constructor(){super(...arguments),this._any=!0}_parse(t){return Sr(t.data)}}vb.create=e=>new vb({typeName:Ce.ZodAny,...Ie(e)});class vv extends He{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Sr(t.data)}}vv.create=e=>new vv({typeName:Ce.ZodUnknown,...Ie(e)});class Ss extends He{_parse(t){const n=this._getOrReturnCtx(t);return ie(n,{code:K.invalid_type,expected:ce.never,received:n.parsedType}),ke}}Ss.create=e=>new Ss({typeName:Ce.ZodNever,...Ie(e)});class _b extends He{_parse(t){if(this._getType(t)!==ce.undefined){const r=this._getOrReturnCtx(t);return ie(r,{code:K.invalid_type,expected:ce.void,received:r.parsedType}),ke}return Sr(t.data)}}_b.create=e=>new _b({typeName:Ce.ZodVoid,...Ie(e)});class ei extends He{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==ce.array)return ie(n,{code:K.invalid_type,expected:ce.array,received:n.parsedType}),ke;if(i.exactLength!==null){const o=n.data.length>i.exactLength.value,a=n.data.length<i.exactLength.value;(o||a)&&(ie(n,{code:o?K.too_big:K.too_small,minimum:a?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(ie(n,{code:K.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(ie(n,{code:K.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>i.type._parseAsync(new ii(n,o,n.path,a)))).then(o=>Tn.mergeArray(r,o));const s=[...n.data].map((o,a)=>i.type._parseSync(new ii(n,o,n.path,a)));return Tn.mergeArray(r,s)}get element(){return this._def.type}min(t,n){return new ei({...this._def,minLength:{value:t,message:me.toString(n)}})}max(t,n){return new ei({...this._def,maxLength:{value:t,message:me.toString(n)}})}length(t,n){return new ei({...this._def,exactLength:{value:t,message:me.toString(n)}})}nonempty(t){return this.min(1,t)}}ei.create=(e,t)=>new ei({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ce.ZodArray,...Ie(t)});function Ko(e){if(e instanceof jt){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Ci.create(Ko(r))}return new jt({...e._def,shape:()=>t})}else return e instanceof ei?new ei({...e._def,type:Ko(e.element)}):e instanceof Ci?Ci.create(Ko(e.unwrap())):e instanceof ho?ho.create(Ko(e.unwrap())):e instanceof lo?lo.create(e.items.map(t=>Ko(t))):e}class jt extends He{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=qe.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==ce.object){const c=this._getOrReturnCtx(t);return ie(c,{code:K.invalid_type,expected:ce.object,received:c.parsedType}),ke}const{status:r,ctx:i}=this._processInputParams(t),{shape:s,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ss&&this._def.unknownKeys==="strip"))for(const c in i.data)o.includes(c)||a.push(c);const l=[];for(const c of o){const u=s[c],d=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new ii(i,d,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Ss){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of a)l.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(c==="strict")a.length>0&&(ie(i,{code:K.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of a){const d=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new ii(i,d,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of l){const d=await u.key,f=await u.value;c.push({key:d,value:f,alwaysSet:u.alwaysSet})}return c}).then(c=>Tn.mergeObjectSync(r,c)):Tn.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return me.errToObj,new jt({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var s,o;const i=((o=(s=this._def).errorMap)==null?void 0:o.call(s,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:me.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new jt({...this._def,unknownKeys:"strip"})}passthrough(){return new jt({...this._def,unknownKeys:"passthrough"})}extend(t){return new jt({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new jt({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Ce.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new jt({...this._def,catchall:t})}pick(t){const n={};for(const r of qe.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new jt({...this._def,shape:()=>n})}omit(t){const n={};for(const r of qe.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new jt({...this._def,shape:()=>n})}deepPartial(){return Ko(this)}partial(t){const n={};for(const r of qe.objectKeys(this.shape)){const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}return new jt({...this._def,shape:()=>n})}required(t){const n={};for(const r of qe.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Ci;)s=s._def.innerType;n[r]=s}return new jt({...this._def,shape:()=>n})}keyof(){return oN(qe.objectKeys(this.shape))}}jt.create=(e,t)=>new jt({shape:()=>e,unknownKeys:"strip",catchall:Ss.create(),typeName:Ce.ZodObject,...Ie(t)});jt.strictCreate=(e,t)=>new jt({shape:()=>e,unknownKeys:"strict",catchall:Ss.create(),typeName:Ce.ZodObject,...Ie(t)});jt.lazycreate=(e,t)=>new jt({shape:e,unknownKeys:"strip",catchall:Ss.create(),typeName:Ce.ZodObject,...Ie(t)});class yh extends He{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function i(s){for(const a of s)if(a.result.status==="valid")return a.result;for(const a of s)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(a=>new Ri(a.ctx.common.issues));return ie(n,{code:K.invalid_union,unionErrors:o}),ke}if(n.common.async)return Promise.all(r.map(async s=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const l of r){const c={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!s&&(s={result:u,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;const a=o.map(l=>new Ri(l));return ie(n,{code:K.invalid_union,unionErrors:a}),ke}}get options(){return this._def.options}}yh.create=(e,t)=>new yh({options:e,typeName:Ce.ZodUnion,...Ie(t)});const gi=e=>e instanceof xv?gi(e.schema):e instanceof uo?gi(e.innerType()):e instanceof Sh?[e.value]:e instanceof co?e.options:e instanceof yv?qe.objectValues(e.enum):e instanceof Ch?gi(e._def.innerType):e instanceof mv?[void 0]:e instanceof gv?[null]:e instanceof Ci?[void 0,...gi(e.unwrap())]:e instanceof ho?[null,...gi(e.unwrap())]:e instanceof aN||e instanceof Nh?gi(e.unwrap()):e instanceof Eh?gi(e._def.innerType):[];class B_ extends He{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==ce.object)return ie(n,{code:K.invalid_type,expected:ce.object,received:n.parsedType}),ke;const r=this.discriminator,i=n.data[r],s=this.optionsMap.get(i);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(ie(n,{code:K.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),ke)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const i=new Map;for(const s of n){const o=gi(s.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const a of o){if(i.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);i.set(a,s)}}return new B_({typeName:Ce.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Ie(r)})}}function _v(e,t){const n=ns(e),r=ns(t);if(e===t)return{valid:!0,data:e};if(n===ce.object&&r===ce.object){const i=qe.objectKeys(t),s=qe.objectKeys(e).filter(a=>i.indexOf(a)!==-1),o={...e,...t};for(const a of s){const l=_v(e[a],t[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}else if(n===ce.array&&r===ce.array){if(e.length!==t.length)return{valid:!1};const i=[];for(let s=0;s<e.length;s++){const o=e[s],a=t[s],l=_v(o,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===ce.date&&r===ce.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class bh extends He{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(s,o)=>{if(fb(s)||fb(o))return ke;const a=_v(s.value,o.value);return a.valid?((pb(s)||pb(o))&&n.dirty(),{status:n.value,value:a.data}):(ie(r,{code:K.invalid_intersection_types}),ke)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}bh.create=(e,t,n)=>new bh({left:e,right:t,typeName:Ce.ZodIntersection,...Ie(n)});class lo extends He{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.array)return ie(r,{code:K.invalid_type,expected:ce.array,received:r.parsedType}),ke;if(r.data.length<this._def.items.length)return ie(r,{code:K.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ke;!this._def.rest&&r.data.length>this._def.items.length&&(ie(r,{code:K.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const s=[...r.data].map((o,a)=>{const l=this._def.items[a]||this._def.rest;return l?l._parse(new ii(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>Tn.mergeArray(n,o)):Tn.mergeArray(n,s)}get items(){return this._def.items}rest(t){return new lo({...this._def,rest:t})}}lo.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new lo({items:e,typeName:Ce.ZodTuple,rest:null,...Ie(t)})};class wh extends He{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.object)return ie(r,{code:K.invalid_type,expected:ce.object,received:r.parsedType}),ke;const i=[],s=this._def.keyType,o=this._def.valueType;for(const a in r.data)i.push({key:s._parse(new ii(r,a,r.path,a)),value:o._parse(new ii(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?Tn.mergeObjectAsync(n,i):Tn.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof He?new wh({keyType:t,valueType:n,typeName:Ce.ZodRecord,...Ie(r)}):new wh({keyType:bi.create(),valueType:t,typeName:Ce.ZodRecord,...Ie(n)})}}class xb extends He{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.map)return ie(r,{code:K.invalid_type,expected:ce.map,received:r.parsedType}),ke;const i=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([a,l],c)=>({key:i._parse(new ii(r,a,r.path,[c,"key"])),value:s._parse(new ii(r,l,r.path,[c,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const l of o){const c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return ke;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const l of o){const c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return ke;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}}}}xb.create=(e,t,n)=>new xb({valueType:t,keyType:e,typeName:Ce.ZodMap,...Ie(n)});class Pc extends He{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.set)return ie(r,{code:K.invalid_type,expected:ce.set,received:r.parsedType}),ke;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(ie(r,{code:K.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(ie(r,{code:K.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const s=this._def.valueType;function o(l){const c=new Set;for(const u of l){if(u.status==="aborted")return ke;u.status==="dirty"&&n.dirty(),c.add(u.value)}return{status:n.value,value:c}}const a=[...r.data.values()].map((l,c)=>s._parse(new ii(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(t,n){return new Pc({...this._def,minSize:{value:t,message:me.toString(n)}})}max(t,n){return new Pc({...this._def,maxSize:{value:t,message:me.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Pc.create=(e,t)=>new Pc({valueType:e,minSize:null,maxSize:null,typeName:Ce.ZodSet,...Ie(t)});class xv extends He{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}xv.create=(e,t)=>new xv({getter:e,typeName:Ce.ZodLazy,...Ie(t)});class Sh extends He{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return ie(n,{received:n.data,code:K.invalid_literal,expected:this._def.value}),ke}return{status:"valid",value:t.data}}get value(){return this._def.value}}Sh.create=(e,t)=>new Sh({value:e,typeName:Ce.ZodLiteral,...Ie(t)});function oN(e,t){return new co({values:e,typeName:Ce.ZodEnum,...Ie(t)})}class co extends He{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return ie(n,{expected:qe.joinValues(r),received:n.parsedType,code:K.invalid_type}),ke}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return ie(n,{received:n.data,code:K.invalid_enum_value,options:r}),ke}return Sr(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return co.create(t,{...this._def,...n})}exclude(t,n=this._def){return co.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}co.create=oN;class yv extends He{_parse(t){const n=qe.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==ce.string&&r.parsedType!==ce.number){const i=qe.objectValues(n);return ie(r,{expected:qe.joinValues(i),received:r.parsedType,code:K.invalid_type}),ke}if(this._cache||(this._cache=new Set(qe.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const i=qe.objectValues(n);return ie(r,{received:r.data,code:K.invalid_enum_value,options:i}),ke}return Sr(t.data)}get enum(){return this._def.values}}yv.create=(e,t)=>new yv({values:e,typeName:Ce.ZodNativeEnum,...Ie(t)});class kh extends He{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==ce.promise&&n.common.async===!1)return ie(n,{code:K.invalid_type,expected:ce.promise,received:n.parsedType}),ke;const r=n.parsedType===ce.promise?n.data:Promise.resolve(n.data);return Sr(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}kh.create=(e,t)=>new kh({type:e,typeName:Ce.ZodPromise,...Ie(t)});class uo extends He{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ce.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:o=>{ie(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return ke;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?ke:l.status==="dirty"||n.value==="dirty"?Al(l.value):l});{if(n.value==="aborted")return ke;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?ke:a.status==="dirty"||n.value==="dirty"?Al(a.value):a}}if(i.type==="refinement"){const o=a=>{const l=i.refinement(a,s);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?ke:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?ke:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(i.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Aa(o))return ke;const a=i.transform(o.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Aa(o)?Promise.resolve(i.transform(o.value,s)).then(a=>({status:n.value,value:a})):ke);qe.assertNever(i)}}uo.create=(e,t,n)=>new uo({schema:e,typeName:Ce.ZodEffects,effect:t,...Ie(n)});uo.createWithPreprocess=(e,t,n)=>new uo({schema:t,effect:{type:"preprocess",transform:e},typeName:Ce.ZodEffects,...Ie(n)});class Ci extends He{_parse(t){return this._getType(t)===ce.undefined?Sr(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Ci.create=(e,t)=>new Ci({innerType:e,typeName:Ce.ZodOptional,...Ie(t)});class ho extends He{_parse(t){return this._getType(t)===ce.null?Sr(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}ho.create=(e,t)=>new ho({innerType:e,typeName:Ce.ZodNullable,...Ie(t)});class Ch extends He{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===ce.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Ch.create=(e,t)=>new Ch({innerType:e,typeName:Ce.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Ie(t)});class Eh extends He{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return _h(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ri(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ri(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Eh.create=(e,t)=>new Eh({innerType:e,typeName:Ce.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Ie(t)});class yb extends He{_parse(t){if(this._getType(t)!==ce.nan){const r=this._getOrReturnCtx(t);return ie(r,{code:K.invalid_type,expected:ce.nan,received:r.parsedType}),ke}return{status:"valid",value:t.data}}}yb.create=e=>new yb({typeName:Ce.ZodNaN,...Ie(e)});class aN extends He{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class z_ extends He{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?ke:s.status==="dirty"?(n.dirty(),Al(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?ke:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,n){return new z_({in:t,out:n,typeName:Ce.ZodPipeline})}}class Nh extends He{_parse(t){const n=this._def.innerType._parse(t),r=i=>(Aa(i)&&(i.value=Object.freeze(i.value)),i);return _h(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}Nh.create=(e,t)=>new Nh({innerType:e,typeName:Ce.ZodReadonly,...Ie(t)});var Ce;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Ce||(Ce={}));const E=bi.create,J=ja.create,Pe=pv.create,ec=vv.create;Ss.create;const Ee=ei.create,z=jt.create;yh.create;const Oi=B_.create;bh.create;lo.create;const Pf=wh.create,te=Sh.create,it=co.create;kh.create;Ci.create;ho.create;const vL=["owner"],_L=["agent","owner","user-upload"],lN=z({id:E().min(1),relPath:E().min(1),from:it(_L),label:E().optional(),size:J().int().nonnegative(),mime:E().min(1),addedAt:J().int().nonnegative(),lastEditedAt:J().int().nonnegative().optional(),stale:Pe().optional()});z({sessionId:E().min(1),relPath:E().min(1),ttlSeconds:J().int().positive().nullable().optional(),view:it(["raw","md-rendered"]).optional()});z({url:E().min(1),expiresAt:J().int().nonnegative().nullable()});z({sessionId:E().min(1),relPath:E().min(1),label:E().optional()});z({entry:lN});z({sessionId:E().min(1),relPath:E().min(1)});z({removed:te(!0)});z({sessionId:E().min(1)});z({entries:Ee(lN)});z({attachmentId:E().min(1),url:E().min(1),relPath:E().min(1),sizeBytes:J().int().nonnegative(),mimeType:E().min(1)});const cN=it(["owner","guest"]);z({id:E().min(1),kind:cN,displayName:E(),feishuUnionId:E().optional()}).strict();const xL=z({did:E().min(1),displayName:E(),feishuUnionId:E().optional(),principal:cN}).strict(),yL=z({personaId:E(),label:E(),model:E().optional(),public:Pe(),iconKey:E().optional(),tool:E().optional(),createdAt:J(),updatedAt:J()}).strict(),bL=z({name:E().min(1),description:E().optional()}),wL=z({id:E().min(1)}),SL=z({permissions:z({defaultMode:E().optional(),allow:Ee(E()).optional(),deny:Ee(E()).optional()}).optional(),sandbox:z({enabled:Pe().optional(),autoAllowBashIfSandboxed:Pe().optional(),allowUnsandboxedCommands:Pe().optional(),excludedCommands:Ee(E()).optional(),filesystem:z({denyRead:Ee(E()).optional(),allowRead:Ee(E()).optional(),denyWrite:Ee(E()).optional(),allowWrite:Ee(E()).optional()}).optional(),network:z({allowedDomains:Ee(E()).optional(),allowLocalBinding:Pe().optional()}).optional()}).optional()});yL.extend({personality:E().optional(),skills:Ee(bL).optional(),plugins:Ee(wL).optional(),sandboxSettings:SL.nullable().optional()});z({label:E().min(1),personality:E(),model:E().optional(),tool:E().optional(),public:Pe().optional(),iconKey:E().optional()}).strict();z({personaId:E().min(1)});z({personaId:E().min(1),patch:z({label:E().min(1).optional(),model:E().optional(),tool:E().optional(),personality:E().optional(),public:Pe().optional(),iconKey:E().nullable().optional()}).strict()}).strict();z({writableRoots:Ee(E()).optional(),denyRead:Ee(E()).optional(),network:Pe().optional()}).strict();const kL=it(rN),CL=z({input_tokens:J().int().nonnegative().optional(),cache_read_input_tokens:J().int().nonnegative().optional(),cache_creation_input_tokens:J().int().nonnegative().optional(),output_tokens:J().int().nonnegative().optional()}),EL=z({inputTokens:J().int().nonnegative(),outputTokens:J().int().nonnegative(),cacheReadTokens:J().int().nonnegative().optional(),cacheCreateTokens:J().int().nonnegative().optional()}),uN={gitBranch:E().optional(),resolvedModel:E().optional(),contextUsage:EL.optional(),contextWindowSize:J().int().positive().optional()},NL=z(uN),TL=z({id:E().min(1),label:E().min(1),description:E().optional(),contextWindowSize:J().int().positive(),default:Pe().optional()}),PL=z({id:E().min(1),label:E().min(1),description:E().optional()}),RL=z({name:E().min(1),type:it(["string","select","toggle"]),label:E().min(1),description:E().optional(),options:Ee(z({value:E(),label:E(),description:E().optional()})).optional(),default:ec().optional(),scope:it(["core","tool-specific"])});z({tool:E().min(1)});const IL=z({rewind:Pe(),subagents:Pe(),tui:Pe(),observe:Pe(),fileSharing:Pe(),fork:Pe()});z({tool:E().min(1),toolSessionIdLabel:E().optional(),models:Ee(TL),permissionModes:Ee(PL),configSchema:Ee(RL),features:IL});const ML=z({tool:E().min(1),pattern:E().min(1),createdAt:E().min(1).optional()});z({sessionId:E().min(1),cwd:E().min(1),tool:te("claude").or(E().min(1)).default("claude"),toolSessionId:E().optional(),label:E().optional(),model:E().optional(),permissionMode:E().optional(),effort:E().optional(),...uN,permissionRules:Ee(ML).optional(),pinnedAt:J().int().nonnegative().nullable().optional(),pinSortOrder:J().int().nullable().optional(),unreadAt:E().min(1).nullable().optional(),iconKey:E().optional(),forkedFromSessionId:E().min(1).optional(),ephemeral:Pe().optional(),ownerPersonaId:E().min(1).optional(),appBuilderProject:E().regex(/^[a-z][a-z0-9-]{0,39}$/).optional(),chatId:E().min(1).optional(),creatorPrincipalId:E().min(1).optional(),creatorDisplayName:E().min(1).optional(),creatorFeishuUnionId:E().min(1).optional(),originOwnerPrincipalId:E().min(1).optional(),originOwnerPersonaId:E().min(1).optional(),dispatchedFromSessionId:E().min(1).optional(),shiftFiredFromSessionId:E().min(1).optional(),createdAt:E().min(1),updatedAt:E().min(1)});const On={seq:J().int().nonnegative().optional(),ts:E().optional(),uuid:E().optional()},AL=it(UD),jL=z({readCount:J().int().nonnegative().optional(),searchCount:J().int().nonnegative().optional(),bashCount:J().int().nonnegative().optional(),editFileCount:J().int().nonnegative().optional(),linesAdded:J().int().nonnegative().optional(),linesRemoved:J().int().nonnegative().optional(),otherToolCount:J().int().nonnegative().optional()}),DL=z({oldStart:J().int().nonnegative(),oldLines:J().int().nonnegative(),newStart:J().int().nonnegative(),newLines:J().int().nonnegative(),lines:Ee(E())}),LL=z({agentId:E().optional(),agentType:E().optional(),status:E().optional(),prompt:E().optional(),filePath:E().optional(),structuredPatch:Ee(DL).optional(),stats:z({durationMs:J().int().nonnegative().optional(),tokens:J().int().nonnegative().optional(),toolUseCount:J().int().nonnegative().optional(),toolStats:jL.optional(),usage:CL.optional()}).optional()}),OL=z({path:E(),content:E(),mtimeMs:J().optional()}),BL=z({label:E().min(1),description:E().optional()}),dN=z({question:E().min(1),multiSelect:Pe(),options:Ee(BL).min(1)});Oi("kind",[z({...On,kind:te("session_init"),toolSessionId:E().optional()}),z({...On,kind:te("thinking"),text:E(),partialId:E().optional()}),z({...On,kind:te("text"),text:E(),partialId:E().optional()}),z({...On,kind:te("user_text"),text:E(),meta:AL.optional(),taskId:E().optional(),parentToolUseId:E().optional(),sender:xL.optional()}),z({...On,kind:te("tool_call"),toolUseId:E(),tool:E(),toolKind:E().optional(),input:ec()}),z({...On,kind:te("tool_result"),toolUseId:E(),output:ec().optional(),error:E().optional(),toolResultExtra:LL.optional(),sourceToolAssistantUUID:E().optional(),askQuestionAnswers:Pf(E(),E()).optional()}),z({...On,kind:te("attachment_memories"),memories:Ee(OL)}),z({...On,kind:te("permission_request"),requestId:E(),tool:E(),input:ec(),toolUseId:E().optional()}),z({...On,kind:te("ask_user_question"),toolUseId:E(),questions:Ee(dN)}),z({...On,kind:te("turn_end")}),z({...On,kind:te("subagent_progress"),toolUseId:E(),agentId:E(),status:it(["started","running","completed","failed"]),description:E().optional(),lastToolName:E().optional(),prompt:E().optional(),stats:z({durationMs:J().int().nonnegative().optional(),tokens:J().int().nonnegative().optional(),toolUseCount:J().int().nonnegative().optional()}).optional()}),z({...On,kind:te("error"),message:E()}),z({...On,kind:te("meta_update"),patch:NL}),z({...On,kind:te("meta-text"),text:E(),metaSource:it(["cc","owner"]).optional()})]);z({cwd:E().min(1).optional(),tool:E().optional(),label:E().optional(),model:E().optional(),permissionMode:E().optional(),effort:E().optional(),iconKey:E().optional(),forkedFromSessionId:E().min(1).optional(),ephemeral:Pe().optional(),ownerPersonaId:E().min(1).optional()}).refine(e=>e.cwd!=null||e.ownerPersonaId!=null,{message:"cwd 与 ownerPersonaId 至少传一个"});z({originOnly:Pe().optional(),limit:J().int().positive().optional(),offset:J().int().nonnegative().optional()});z({sessionId:E().min(1)});z({sessionId:E().min(1),patch:z({label:E().optional(),model:E().optional(),permissionMode:E().optional(),effort:E().optional(),cwd:E().optional(),iconKey:E().optional()})});z({sessionId:E().min(1),text:E()});z({sessionId:E().min(1),userMessageId:E().min(1),dryRun:Pe().optional()});z({canRewind:Pe(),error:E().optional(),filesChanged:Ee(E()).optional(),insertions:J().int().nonnegative().optional(),deletions:J().int().nonnegative().optional()});z({sessionId:E().min(1),userMessageId:E().min(1)});const zL=z({oldStart:J().int().nonnegative(),oldLines:J().int().nonnegative(),newStart:J().int().nonnegative(),newLines:J().int().nonnegative(),lines:Ee(E())}),$L=z({filePath:E().min(1),hunks:Ee(zL),insertions:J().int().nonnegative(),deletions:J().int().nonnegative(),status:it(["modified","added","deleted"]).optional()});z({canRewind:Pe(),error:E().optional(),files:Ee($L),totalInsertions:J().int().nonnegative(),totalDeletions:J().int().nonnegative()});z({userMessageIds:Ee(E())});z({sessionId:E().min(1),toolSessionId:E().min(1)});z({cwd:E().min(1),toolSessionId:E().min(1),messageUuid:E().min(1)});z({forkedToolSessionId:E().min(1),forkedFilePath:E().min(1)});z({sessionId:E().min(1),toolSessionId:E().min(1),jsonlPath:E().optional()});z({sessionId:E().min(1),afterSeq:J().int().min(-1)});z({sessionId:E().min(1),permissionRequestId:E().min(1),allow:Pe(),permanent:Pe().optional(),pattern:E().optional()});z({projectPath:E().min(1)});z({sessionId:E().min(1),limit:J().int().positive().max(5e3).optional(),offset:J().int().nonnegative().optional(),slim:Pe().optional()});z({cwd:E().min(1),toolSessionId:E().min(1)});z({cwd:E().min(1),toolSessionId:E().min(1),subagentId:E().min(1)});z({cwd:E().min(1).optional(),path:E().optional(),showHidden:Pe().optional()});z({cwd:E().min(1),path:E().min(1)});z({cwd:E().min(1),tool:E().optional()});z({name:E().min(1),source:it(WD),path:E().optional(),description:E().optional(),plugin:E().optional()});const FL=z({name:E().min(1),source:it(VD),path:E().optional(),description:E().optional(),whenToUse:E().optional(),plugin:E().optional()});z({cwd:E().min(1),tool:E().optional()});z({agents:Ee(FL)});z({sessionId:E().min(1)});z({sessionId:E().min(1),pinned:Pe()});z({type:te("peerSession:upsert:ok")});z({sessionId:E().min(1)});z({type:te("peerSession:remove:ok")});z({orderedIds:Ee(E().min(1)).min(1)});z({cwd:E().min(1)});z({isGitRoot:Pe(),gitRoot:E().nullable()});z({cwd:E().min(1)});z({branch:E().nullable()});z({cwd:E().min(1)});z({branches:Ee(E()),head:E().nullable()});z({}).optional();const HL=z({cwd:E().min(1),updatedAt:E().min(1)});z({dirs:Ee(HL)});z({type:te("session:question"),sessionId:E().min(1),toolUseId:E().min(1),requestId:E().min(1),questions:Ee(dN).min(1)});z({type:te("session:question:cleared"),sessionId:E().min(1),toolUseId:E().min(1),answers:Pf(E(),E()).optional()});z({sessionId:E().min(1),toolUseId:E().min(1),answers:Pf(E(),E())});z({ok:te(!0)});z({sessionId:E().min(1),toolUseId:E().min(1)});z({ok:te(!0)});z({type:te("auth"),token:E().min(1),scheme:te("bearer").optional(),selfUrl:E().min(1).optional(),clientInfo:z({name:E().min(1),version:E().min(1),instanceId:E().min(1)}).optional()});z({type:te("auth:ok"),version:E().min(1).optional(),protocolVersion:J().int().nonnegative().optional()});z({type:te("tunnel:ready"),url:E().min(1),subdomain:E().min(1)});z({type:te("tunnel:exited"),code:J().int().nullable(),subdomain:E().nullable(),url:E().nullable()});z({type:te("tunnel:unavailable"),reason:E().min(1),failedAt:E().min(1)});const UL=z({sessionId:E().min(1),status:kL,freshSpawn:Pe(),pendingPermissionRequestIds:Ee(E().min(1)),pendingQuestionToolUseIds:Ee(E().min(1))});z({type:te("info"),version:E(),protocolVersion:J(),hostname:E(),os:E(),tools:Ee(z({id:E(),available:Pe()})),runningSessions:Ee(UL),tokenRole:it(vL).optional(),isLoopback:Pe().optional(),httpBaseUrl:E().optional(),httpToken:E().optional()});const WL=6173,VL=6272,Ga=/^[a-z][a-z0-9-]{0,39}$/,tu=z({name:E().regex(Ga,{message:"kebab-case, 小写字母开头,只允许小写字母 / 数字 / -,最长 40 字符"}),port:J().int().min(WL).max(VL),createdAt:E().datetime(),devCommand:E().min(1),prodUrl:E().url().optional(),readyPattern:E().optional(),publishJob:z({jobId:E().min(1),stage:it(["build","deploy","verify"]),startedAt:J().int().nonnegative()}).optional()}),qL=["install-pending","installing","starting-dev-server","running","stopped","failed"],hN=it(qL),$_=tu.extend({isRunning:Pe(),boundSessionId:E().nullable(),stage:hN.optional(),stageReason:E().optional(),publishJob:z({jobId:E().min(1),stage:it(["build","deploy","verify"]),startedAt:J().int().nonnegative(),status:it(["in-flight","interrupted"])}).optional()});z({}).strict();z({projects:Ee($_)}).strict();z({sessionId:E().min(1)}).strict();z({project:$_.nullable()}).strict();z({sessionId:E().min(1),name:E()}).strict();z({project:tu}).strict();z({name:E()}).strict();z({}).strict();z({name:E(),newPort:J().int()}).strict();z({project:tu}).strict();z({name:E().regex(Ga),url:E().url()}).strict();z({project:tu}).strict();z({sessionId:E().min(1),force:Pe().optional()}).strict();z({project:tu}).strict();const KL=["installing","failed"];z({sessionId:E().min(1),stage:it(KL),reason:E().optional()}).strict();z({ok:te(!0)}).strict();z({sessionId:E().min(1)}).strict();z({ok:te(!0)}).strict();z({type:te("appBuilder:project-updated"),project:$_,stage:hN,stageReason:E().optional()}).strict();z({name:E().regex(Ga)});z({jobId:E().min(1),status:it(["started","already-publishing"])}).strict();z({name:E().regex(Ga)});z({ok:te(!0)}).strict();z({type:te("appBuilder:publish-progress"),name:E().regex(Ga),jobId:E().min(1),stage:it(["build","deploy","verify"]),status:it(["started","completed"])}).strict();z({type:te("appBuilder:publish-failed"),name:E().regex(Ga),jobId:E().min(1),stage:it(["build","deploy","verify","unknown"]),errorSummary:E()}).strict();const bb=1,GL=Oi("type",[z({type:te("persona"),id:E().min(1)}).strict(),z({type:te("chat"),id:E().min(1)}).strict(),z({type:te("*")}).strict()]),XL=it(["read","send","admin"]),fN=z({resource:GL,actions:Ee(XL).min(1)}).strict(),YL=z({id:E().min(1),secretHash:E().regex(/^[a-f0-9]{64}$/),displayName:E(),grants:Ee(fN),issuedAt:J().int().nonnegative(),expiresAt:J().int().positive().optional(),maxUses:J().int().positive().optional(),usedCount:J().int().nonnegative(),peerOwnerId:E().min(1).optional(),firstUsedByPeerAt:J().int().positive().optional(),peerDisplayName:E().optional()}).strict(),ZL=YL.omit({secretHash:!0});it(["TOKEN_INVALID","TOKEN_REVOKED","TOKEN_EXPIRED","TOKEN_EXHAUSTED"]);z({type:te("whoami:ok"),owner:z({id:E(),kind:it(["owner","guest"]),displayName:E(),ownerId:E(),provider:E()}).strict(),capability:ZL,grantedPersonas:Ee(z({id:E().min(1),displayName:E()}).strict())}).strict();z({id:E().min(1),peerDeviceId:E().min(1),senderDeviceId:E().min(1),text:E().min(1),createdAt:J().int().nonnegative(),readBy:Pf(E().min(1),J().int().positive()).default({}),origin:z({kind:te("persona"),personaId:E().min(1)}).optional()}).strict();z({peerDeviceId:E().min(1).optional(),id:E().min(1),text:E().min(1),createdAt:J().int().nonnegative(),origin:z({kind:te("persona"),personaId:E().min(1)}).optional()}).strict();z({peerDeviceId:E().min(1),sinceCreatedAt:J().int().nonnegative().optional()}).strict();z({peerDeviceId:E().min(1),upToCreatedAt:J().int().nonnegative()}).strict();z({peerDeviceId:E().min(1).optional(),text:E().min(1)});const QL=z({deviceId:E().min(1),ownerId:E().min(1),provider:E().min(1),displayName:E(),remoteUrl:E().min(1),connectToken:E(),grants:Ee(fN),addedAt:J().int().nonnegative(),pinnedAt:J().int().nullable().default(null),remoteAccessAllowed:Pe().default(!1)}).strict(),pN=QL;z({deviceId:E().min(1)}).strict();z({type:te("contact:remove:ok"),deviceId:E().min(1)}).strict();z({type:te("contact:list:ok"),contacts:Ee(pN)}).strict();z({type:te("contact:added"),contact:pN}).strict();z({type:te("contact:removed"),deviceId:E().min(1)}).strict();z({deviceId:E().min(1),pinned:Pe()}).strict();z({type:te("contact:pin:ok"),deviceId:E().min(1),pinnedAt:J().int().nullable()}).strict();z({type:te("contact:pinned"),deviceId:E().min(1),pinnedAt:J().int().nullable()}).strict();z({deviceId:E().min(1),remoteAccessAllowed:Pe()}).strict();z({type:te("contact:setRemoteAccess:ok"),deviceId:E().min(1),remoteAccessAllowed:Pe()}).strict();z({type:te("contact:remote-access-updated"),deviceId:E().min(1),remoteAccessAllowed:Pe()}).strict();z({peerDeviceId:E().min(1).optional(),command:E().min(1),timeoutMs:J().int().positive().optional()}).strict();z({type:te("peerExec:run:ok"),stdout:E(),stderr:E(),exitCode:J().int().nullable(),timedOut:Pe(),stdoutTruncated:Pe(),stderrTruncated:Pe()}).strict();const JL=/^[a-z0-9][a-z0-9-]*$/;it(["stopped","starting","running","crashed","invalid"]);const eO=new Set(["localhost","127.0.0.1"]);function tO(e){let t;try{t=new URL(e)}catch{return!1}return!!(t.protocol==="https:"||t.protocol==="http:"&&eO.has(t.hostname))}const Wu=z({id:E().regex(JL),name:E().min(1),version:E().min(1),apiVersion:te("1"),runtime:z({startCommand:E().min(1)}).passthrough().optional(),entry:z({url:E().url().refine(tO,{message:"INVALID_URL_SCHEME: only https or http://localhost is allowed"})}).strict().optional()}).passthrough().superRefine((e,t)=>{var i;const n=!!e.runtime,r=!!((i=e.entry)!=null&&i.url);n&&r&&t.addIssue({code:K.custom,message:"INVALID_MANIFEST: entry.url and runtime cannot coexist"}),!n&&!r&&t.addIssue({code:K.custom,message:"INVALID_MANIFEST: must have either entry.url or runtime"})}),nO=Oi("kind",[z({kind:te("local"),port:J().int().min(1).max(65535)}),z({kind:te("hosted"),url:E().url()})]);Oi("state",[z({extId:E(),manifest:Wu,state:te("stopped")}),z({extId:E(),manifest:Wu,state:te("starting")}),z({extId:E(),manifest:Wu,state:te("running"),target:nO}),z({extId:E(),manifest:Wu,state:te("crashed")}),z({extId:E(),manifest:ec().nullable(),state:te("invalid"),invalidReason:E().min(1)})]);z({snapshotHash:E().min(1),version:E().min(1),publishedAt:J()});Oi("kind",[z({kind:te("p2p-tunnel"),ownerPrincipalId:E().min(1),extId:E().min(1)})]);Oi("kind",[z({kind:te("p2p-tunnel"),ownerPrincipalId:E().min(1),extId:E().min(1),snapshotHash:E().min(1)})]);z({extId:E().min(1),name:E().min(1),version:E().min(1),contentHash:E().min(1),publishedAt:J()});const rO=Oi("kind",[z({kind:te("clean")}),z({kind:te("ready-new-version"),fromVersion:E().min(1),toVersion:E().min(1)}),z({kind:te("error-same-hash"),version:E().min(1)}),z({kind:te("error-version-not-bumped"),localVersion:E().min(1),publishedVersion:E().min(1)}),z({kind:te("error-version-regression"),localVersion:E().min(1),publishedVersion:E().min(1)})]);z({localManifest:z({name:E().min(1),version:E().min(1),contentHash:E().min(1)}),publishState:Oi("kind",[z({kind:te("unpublished")}),z({kind:te("published"),version:E().min(1),contentHash:E().min(1),publishedAt:J()})]),check:rO});const iO=z({deviceId:E().min(1),name:E().min(1),url:E().min(1)});z({type:te("device:list:ok"),devices:Ee(iO)});z({deviceId:E().min(1),url:E().min(1).optional(),name:E().optional()});z({type:te("device:connect:ok"),deviceId:E(),name:E(),url:E()});const mN=z({ownerId:E().min(1),provider:E().min(1),displayName:E().min(1),avatarUrl:E().optional(),unionId:E().optional()});z({type:te("auth:login:start:ok"),authUrl:E().min(1),state:E().min(1)});z({type:te("auth:getIdentity:ok"),identity:mN.nullable(),deviceId:E().min(1)});z({type:te("auth:logout:ok")});z({type:te("auth:login:done"),identity:mN});z({type:te("auth:login:failed"),reason:E()});const sO=Oi("kind",[z({kind:te("success"),text:E(),filePaths:Ee(E()).optional()}),z({kind:te("failure"),reason:E()})]);z({targetPersona:E().min(1),prompt:E(),targetDeviceId:E().min(1).optional(),model:E().min(1).optional()});z({dispatchId:E().min(1),outcome:sO});const oO=["daemon","main","renderer"],aO=it(oO),lO=["debug","info","warn","error"],cO=it(lO);z({ts:J().int(),source:aO,level:cO,msg:E(),ownerPrincipalId:E(),deviceId:E(),appVersion:E(),daemonVersion:E().optional(),os:E(),meta_json:E().optional(),sessionId:E().optional()});z({v:te(1),visitorId:E().min(1),displayName:E(),provider:E(),iat:J(),exp:J()});const uO=z({visitorId:E(),displayName:E(),avatarUrl:E().optional(),provider:E(),firstSeen:J(),lastSeen:J()});z({visitors:Ee(uO)});const dO=new Set(["localhost","127.0.0.1","0.0.0.0","::1"]);let fi=null;function hO(){if(fi!==null)return fi;if(typeof window>"u")return fi=!1,!1;if(dO.has(window.location.hostname)||window.location.protocol==="file:")return fi=!0,!0;if(new URLSearchParams(window.location.search).get("debug")==="1"){fi=!0;try{sessionStorage.setItem("debug","1")}catch{}}else try{fi=sessionStorage.getItem("debug")==="1"}catch{fi=!1}return fi}function De(e,...t){hO()&&console.log(`[${e}][${new Date().toISOString()}]`,...t)}function Vu(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}const fO=e=>{const t=[1e3,2e3,4e3,8e3,16e3,3e4];return t[Math.min(e,t.length-1)]},pO=new Set(["auth:ok","pong","error"]),wb=new Set(nN.filter(e=>!pO.has(e)));let mO=0;const Sb=()=>`r${++mO}`;function gO(e){let t=e.url,n=e.authToken,r=e.selfIdentity;const i=e.clientInfo,s=e.requestTimeoutMs??3e4,o=e.pingIntervalMs??3e4,a=e.watchdogMs??6e4,l=e.authTimeoutMs??1e4,c=e.backoffMs??fO;let u=null,d=!1,f=0,p=null,m=null,v=null,y=null,_=!1,x="disconnected";const b=new Map,w=new Map;let S=null;const k=(D,C)=>{var H;D==="ready"&&(S=C),(H=w.get(D))==null||H.forEach(q=>{try{q(C)}catch{}})},T=D=>{x!==D&&(x=D,k("status",D))},N=(D,C)=>{const H=w.get(D)??new Set;if(H.add(C),w.set(D,H),D==="ready"&&S!==null)try{C(S)}catch{}return()=>H.delete(C)},O=()=>{m&&(clearInterval(m),m=null),v&&(clearTimeout(v),v=null),y&&(clearTimeout(y),y=null)},P=()=>{v&&clearTimeout(v),v=setTimeout(()=>{try{u==null||u.close(4e3,"pong watchdog")}catch{}},a)},L=()=>{m&&clearInterval(m),m=setInterval(()=>{(u==null?void 0:u.readyState)===1&&u.send(JSON.stringify({type:"ping",requestId:Sb()}))},o),P()},R=D=>{for(const[,C]of b)clearTimeout(C.timer),C.reject(new Error(D));b.clear()},I=[],j=()=>{if(I.length===0)return;const D=I.splice(0);for(const C of D)(u==null?void 0:u.readyState)===1&&!_?C.doSend():(clearTimeout(C.timer),C.reject(new Error("NOT_CONNECTED")))},B=D=>{if(I.length===0)return;const C=I.splice(0);for(const H of C)clearTimeout(H.timer),H.reject(new Error(D))},$=()=>{if(d)return;const D=c(f);D<0||(k("daemon:reconnecting",{attempt:f+1,nextDelayMs:D,scheduledAt:Date.now()}),p&&clearTimeout(p),p=setTimeout(()=>{f+=1,A()},D))},F=D=>{P();const C=String(D.type??"");if(C==="auth:ok"){De("daemon-client","auth:ok received → connected",{url:t}),y&&(clearTimeout(y),y=null),_=!1,f=0,T("connected"),k("daemon:connected",{url:t}),L(),j();return}if(C==="pong")return;if(C==="ready"){const q=Number(D.protocolVersion??-1);q!==bb&&k("daemon:version-mismatch",{daemonProtocol:q,supportedProtocol:bb}),k("ready",D);return}const H=D.requestId;if(typeof H=="string"&&b.has(H)){const q=b.get(H);if(b.delete(H),clearTimeout(q.timer),C==="error"){const M=String(D.code??"ERR"),ne=String(D.message??"unknown");q.reject(new Error(`${M}: ${ne}`))}else wb.has(C)&&k(C,D),q.resolve(D);return}wb.has(C)&&k(C,D)},A=()=>{p&&(clearTimeout(p),p=null),De("daemon-client","connect →",{url:t,token:Vu(n),attempt:f}),T("connecting");let D;try{D=new WebSocket(t)}catch(C){T("disconnected"),k("daemon:disconnected",{reason:(C==null?void 0:C.message)??"ws constructor failed"}),$();return}u=D,_=!!n,D.onopen=()=>{if(D!==u){De("daemon-client","onopen → stale (replaced before opened), ignore");return}if(n){De("daemon-client","onopen → send auth frame",{token:Vu(n)});const C={type:"auth",token:n};r!=null&&r.principalId&&(C.selfPrincipalId=r.principalId),r!=null&&r.displayName&&(C.selfDisplayName=r.displayName),i&&(C.clientInfo=i),D.send(JSON.stringify(C)),y=setTimeout(()=>{try{D.close(4001,"auth handshake timeout")}catch{}},l)}else De("daemon-client","onopen → no token, treat as connected (daemon authMode=none)"),f=0,T("connected"),k("daemon:connected",{url:t}),L(),j()},D.onclose=C=>{if(D!==u){De("daemon-client","onclose → stale, ignore",{code:C.code,reason:C.reason});return}const H=C.reason||(C.code===1008?"auth failed":`close ${C.code}`);if(De("daemon-client","onclose →",{code:C.code,reason:H,awaitingAuth:_,manualStop:d}),O(),R(`connection closed: ${H}`),u=null,C.code===4401?T("revoked"):T("disconnected"),k("daemon:disconnected",{reason:H}),C.code===1008||C.code===4401){B(`connection closed: ${H}`);return}d?B(`connection closed: ${H}`):$()},D.onerror=()=>{},D.onmessage=C=>{if(D!==u)return;let H;try{H=JSON.parse(String(C.data))}catch{return}F(H)}};return{start(){d=!1,f=0,A()},stop(){d=!0,p&&(clearTimeout(p),p=null),O();try{u==null||u.close(1e3,"shutdown")}catch{}u=null,R("shutdown"),B("shutdown"),T("disconnected")},switchProfile(D){De("daemon-client","switchProfile →",{url:D.url,token:Vu(D.authToken)},"prev:",{url:t,token:Vu(n)}),t=D.url,n=D.authToken,D.selfIdentity!==void 0&&(r=D.selfIdentity),f=0,d=!0,p&&(clearTimeout(p),p=null),O(),R("switch profile"),B("switch profile");try{u==null||u.close(1e3,"switch profile")}catch{}u=null,d=!1,A()},request(D,C){return new Promise((H,q)=>{const M=Sb(),ne=setTimeout(()=>{b.delete(M);const V=I.findIndex(pe=>pe.timer===ne);V>=0&&I.splice(V,1),q(new Error(`request timeout: ${D}`))},s),oe=()=>{b.set(M,{resolve:V=>H(V),reject:q,timer:ne}),u.send(JSON.stringify({...C,type:D,requestId:M}))};(u==null?void 0:u.readyState)===1&&!_?oe():d||u==null&&p==null?(clearTimeout(ne),q(new Error("NOT_CONNECTED"))):I.push({doSend:oe,reject:q,timer:ne})})},on:N,get isOpen(){return(u==null?void 0:u.readyState)===1&&!_},get url(){return t},getStatus(){return x}}}function vO(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}function _O(e){return e?{id:e.id,mode:e.mode,url:e.url,token:vO(e.token),name:e.name}:null}function qu(e){return e?Array.isArray(e)?e.map(_O):{_notArray:typeof e,_value:e}:null}function kb(e){return e==null?null:typeof e=="object"&&"value"in e?e.value:e}const xO="ws://127.0.0.1:18790",Cb="daemon:profiles",Eb="daemon:active-profile-id";function yO(){return Math.random().toString(36).slice(2,10)}function bO(e){const t=e.trim(),n=t.indexOf("#");if(n<0)return{url:t};const r=t.slice(0,n),i=new URLSearchParams(t.slice(n+1)).get("token")??void 0;return{url:r,token:i}}function wO(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.name=="string"&&(t.mode==="localhost"||t.mode==="remote")&&typeof t.url=="string"&&(t.token===void 0||typeof t.token=="string")}function gN(e){let t={profiles:[],activeId:null},n=!1,r=null;const i=new Set,s=()=>{for(const l of i)l(t)},o=async()=>{De("profile-store","persist →",qu(t.profiles),"active:",t.activeId),await e.kv.set(Cb,t.profiles),await e.kv.set(Eb,t.activeId)},a=async()=>{if(!n){if(r){await r;return}r=(async()=>{var l;try{let c=null;try{const d=await e.kv.get(Cb);c=kb(d)}catch{c=null}let u=null;try{const d=await e.kv.get(Eb);u=kb(d)??null}catch{u=null}if(De("profile-store","ensureLoaded read kv →","profiles:",qu(c),"activeId:",u),Array.isArray(c)&&c.length>0){const d=c.filter(wO),f=u&&d.some(p=>p.id===u)?u:((l=d[0])==null?void 0:l.id)??null;t={profiles:d,activeId:f},n=!0,De("profile-store","ensureLoaded → use kv profiles",qu(d),"active:",f);return}t={profiles:[{id:"default",name:"本机",mode:"localhost",url:xO}],activeId:"default"},De("profile-store","ensureLoaded → fallback synthesized default (NO token)",qu(t.profiles)),n=!0,await o()}finally{r=null}})(),await r}};return{async load(){return await a(),s(),t},async snapshot(){return await a(),t},async upsert(l){var y;await a();let c=l.url,u=l.token;if(c&&c.includes("#")){const _=bO(c);c=_.url,!u&&_.token&&(u=_.token)}const d=l.id?t.profiles.find(_=>_.id===l.id):void 0,f=u!=null&&u.trim()?u.trim():d==null?void 0:d.token;if(l.mode==="remote"&&!f)throw new Error("remote mode requires token");const p=l.id??yO(),m={id:p,name:((y=l.name)==null?void 0:y.trim())||(d==null?void 0:d.name)||(l.mode==="remote"?"远程":"本机"),mode:l.mode,url:c.trim(),token:f};return t={profiles:[...t.profiles.filter(_=>_.id!==p),m],activeId:p},await o(),s(),m},async delete(l){var d;await a();const c=t.profiles.filter(f=>f.id!==l);let u=t.activeId;u===l&&(u=((d=c[0])==null?void 0:d.id)??null),t={profiles:c,activeId:u},await o(),s()},async activate(l){await a(),t.profiles.some(c=>c.id===l)&&(t={...t,activeId:l},await o(),s())},subscribe(l){return i.add(l),()=>i.delete(l)},getActive(){return n?t.profiles.find(l=>l.id===t.activeId)??null:null}}}const Nb="clawd.client-instance-id";let SO={name:"clawd-web",version:"unknown"};function kO(){let e=null;try{e=localStorage.getItem(Nb),e||(e=crypto.randomUUID(),localStorage.setItem(Nb,e))}catch{e=e??crypto.randomUUID()}return{...SO,instanceId:e}}function Tb(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}const vN=g.createContext(null);function CO({host:e,children:t}){const[n,r]=g.useState(null),i=g.useMemo(()=>async()=>{const s=gN(e),o=await s.load(),a=o.profiles.find(c=>c.id===o.activeId)??o.profiles[0];if(!a)throw new Error("DaemonProvider: profile store has no profiles after load");return De("daemon-context","bootstrap → createDaemonClient",{id:a.id,url:a.url,token:Tb(a.token)}),{client:gO({url:a.url,authToken:a.token,clientInfo:kO()}),store:s}},[e]);return g.useEffect(()=>{let s=!0,o=null,a=null;return i().then(l=>{s&&(l.client.start(),o=l,r(l),a=l.store.subscribe(()=>{const c=l.store.getActive();if(!c){De("daemon-context","subscribe → no active profile, skip switchProfile");return}De("daemon-context","subscribe → switchProfile",{id:c.id,url:c.url,token:Tb(c.token)}),l.client.switchProfile({url:c.url,authToken:c.token})}))}),()=>{s=!1,a==null||a(),o==null||o.client.stop()}},[i]),n?h.jsx(vN.Provider,{value:n,children:t}):null}function Rs(){const e=g.useContext(vN);if(!e)throw new Error("useDaemonClient must be used inside <DaemonProvider>");return e.client}function EO(){const e=Rs(),[t,n]=g.useState(void 0);return g.useEffect(()=>e.on("ready",i=>{const s=i.mode,o=s==="tui"?"tui":"sdk";De("daemon-context","useDaemonMode ready.mode =",{rawMode:s,resolved:o}),n(o)}),[e]),t}const _N=g.createContext(null);function NO({cache:e,children:t}){return g.createElement(_N.Provider,{value:e},t)}function ko(){const e=g.useContext(_N);if(!e)throw new Error("useCache must be used inside <CacheProvider>");return e}function si(e){const t=ko(),n=g.useCallback(i=>t.observe(e,()=>i()),[t,e]),r=g.useCallback(()=>t.read(e),[t,e]);return g.useSyncExternalStore(n,r,r)}const xN={actionsLevel:"none",httpBaseUrl:null,httpToken:null},yN=g.createContext(xN);function Rf(){return g.useContext(yN)}function TO(e){return e!=null&&e.httpBaseUrl?{actionsLevel:e.tokenRole==="owner"?"owner":"none",httpBaseUrl:e.httpBaseUrl,httpToken:e.httpToken??null}:xN}function PO(){const e=si("daemon-info");return g.useMemo(()=>TO(e),[e])}function RO({children:e}){const t=PO();return st.createElement(yN.Provider,{value:t},e)}function IO(e,t,n){if(!e.httpBaseUrl)return null;const r=encodeURIComponent(n);return`${e.httpBaseUrl}/session/${encodeURIComponent(t.sessionId)}/files?path=${r}`}function MO(e){const t=new Map;return{observe(n,r){let i=t.get(n);i||(i={data:void 0,hasData:!1,listeners:new Set},t.set(n,i));const s=l=>r(l);i.listeners.add(s);const o=i.listeners.size===1;s(i.hasData?i.data:void 0),o&&e.onFirstObserver(n);let a=!1;return()=>{if(a)return;a=!0;const l=t.get(n);l&&(l.listeners.delete(s),l.listeners.size===0&&(t.delete(n),e.onLastObserver(n)))}},read(n){const r=t.get(n);return r!=null&&r.hasData?r.data:void 0},setData(n,r){const i=t.get(n);if(!i)return;const s=i.hasData?i.data:void 0,o=r(s);i.data=o,i.hasData=!0;for(const a of i.listeners)a(o)}}}function AO(){const e=[],t=new Map,n=r=>{for(const i of e)if(i.pattern.test(r))return i.source;return null};return{register(r,i){e.push({pattern:r,source:i})},activate(r){if(t.has(r))return;const i=n(r);if(!i)throw new Error(`no source registered for key: ${r}`);t.set(r,i.start(r))},deactivate(r){const i=t.get(r);i&&(t.delete(r),i())}}}function jO(e){return{request:(t,n)=>e.request(t,n),onFrame(t){const n=[];for(const r of nN)n.push(e.on(r,i=>t(r,i)));return()=>{for(const r of n)r()}},onConnect(t){return e.on("daemon:connected",()=>t())},get isConnected(){return e.isOpen}}}const DO=e=>({tool:e,models:[{id:"",label:"Default",contextWindowSize:2e5,default:!0}],permissionModes:[{id:"",label:"Default"}],configSchema:[]});function LO(e,t){return{start(n){const r=n.replace(/^capabilities\//,"");let i=!1;const s=async()=>{try{const a=await e.request("capabilities:get",{tool:r});if(i)return;t(n,()=>a)}catch{if(i)return;t(n,()=>DO(r))}},o=e.onConnect(()=>{s()});return s(),()=>{i=!0,o()}}}}function OO(e,t){return{start(n){let r=!1;const i=async()=>{try{const a=await e.request("session:list",void 0);if(r)return;t(n,()=>a.sessions??[])}catch{}},s=e.onFrame((a,l)=>{if(a==="session:info"){const c=l;if(c.chatId!==void 0)return;t(n,u=>[c,...(u??[]).filter(d=>d.sessionId!==c.sessionId)])}else if(a==="session:deleted"){const c=l;t(n,u=>(u??[]).filter(d=>d.sessionId!==c.sessionId))}}),o=e.onConnect(()=>{i()});return i(),()=>{r=!0,s(),o()}}}}const Rc={sessionId:null,events:[],lastSeq:-1,pendingPermissions:[],status:"idle",pendingQuestions:{}};function Vp(e,t){const n=t;if(n.kind==="permission_request"&&typeof n.requestId=="string"){if(e.some(i=>i.requestId===n.requestId))return e;const r={requestId:n.requestId,tool:typeof n.tool=="string"?n.tool:"",input:n.input,...typeof n.toolUseId=="string"&&n.toolUseId?{toolUseId:n.toolUseId}:{}};return[...e,r]}if(n.kind==="tool_result"&&typeof n.toolUseId=="string"&&n.toolUseId){const r=e.findIndex(i=>i.toolUseId===n.toolUseId);if(r>=0)return e.filter((i,s)=>s!==r)}return e}function bN(e,t,n){const r=n===void 0?e.sessionId:n;switch(t.type){case"session:change":return{...Rc,sessionId:t.sessionId};case"session:event":{if(!r||t.sessionId!==r)return e;const i=typeof t.event.seq=="number"?t.event.seq:-1,s=[...e.events,t.event],o=i>e.lastSeq?i:e.lastSeq,a=Vp(e.pendingPermissions,t.event);return{...e,events:s,lastSeq:o,pendingPermissions:a}}case"session:status":return!r||t.sessionId!==r?e:{...e,status:t.status};case"session:events":{if(!r||t.sessionId!==r)return e;const i=t.events.map(o=>o.event),s=i.reduce((o,a)=>Vp(o,a),[]);return{...e,sessionId:t.sessionId,events:i,lastSeq:t.latestSeq,pendingPermissions:s}}case"session:events:append":{if(!r||t.sessionId!==r)return e;const i=new Set;for(const c of e.events){const u=c.seq;typeof u=="number"&&i.add(u)}const s=[];for(const c of t.events)typeof c.seq=="number"&&(i.has(c.seq)||s.push(c.event));const o=t.latestSeq>e.lastSeq?t.latestSeq:e.lastSeq;if(s.length===0)return o===e.lastSeq?e:{...e,lastSeq:o};const a=[...e.events,...s].sort((c,u)=>{const d=c.seq??-1,f=u.seq??-1;return d-f}),l=s.reduce((c,u)=>Vp(c,u),e.pendingPermissions);return{...e,events:a,lastSeq:o,pendingPermissions:l}}case"permission:request":{if(!r||t.sessionId!==r||e.pendingPermissions.some(s=>s.requestId===t.requestId))return e;const i={requestId:t.requestId,tool:t.tool,input:t.input,...t.toolUseId?{toolUseId:t.toolUseId}:{}};return{...e,pendingPermissions:[...e.pendingPermissions,i]}}case"permission:clear":{if(!r||r!==t.sessionId)return e;const i=t.requestId,s=e.pendingPermissions.findIndex(c=>c.requestId===i),o=s>=0?e.pendingPermissions.filter((c,u)=>u!==s):e.pendingPermissions;if(e.events.length===0)return o===e.pendingPermissions?e:{...e,pendingPermissions:o};const a=e.events.length-1,l=e.events[a];return l.kind==="permission_request"&&l.requestId===i?{...e,pendingPermissions:o,events:e.events.slice(0,a)}:o===e.pendingPermissions?e:{...e,pendingPermissions:o}}case"session:question":return!r||t.sessionId!==r?e:{...e,pendingQuestions:{...e.pendingQuestions,[t.toolUseId]:{toolUseId:t.toolUseId,requestId:t.requestId,questions:t.questions}}};case"session:question:clear":{if(!r||t.sessionId!==r||!(t.toolUseId in e.pendingQuestions))return e;const{[t.toolUseId]:i,...s}=e.pendingQuestions;return{...e,pendingQuestions:s}}case"session:question:submitted":{if(!r||t.sessionId!==r)return e;const i=e.pendingQuestions[t.toolUseId];return i?{...e,pendingQuestions:{...e.pendingQuestions,[t.toolUseId]:{...i,submittedAnswers:t.answers}}}:e}case"session:rewound":return!r||t.sessionId!==r?e:{...e,pendingPermissions:[],status:"idle"};case"ready":{if(!r)return e;const i=t.runningSessions.find(o=>o.sessionId===r);if(i!=null&&i.freshSpawn)return{...Rc,sessionId:r};const s=(i==null?void 0:i.status)??"idle";return s===e.status?e:{...e,status:s}}case"daemon:disconnected":return{...e,pendingPermissions:[]};default:return e}}const BO="session/";function zO(e){return{sid:e.slice(BO.length)}}const $O=new Set(rN);function wN(e){return $O.has(e)}function Pb(e){return wN(e)?e:"idle"}function FO(e,t){return{start(n){const{sid:r}=zO(n);let i=!1,s=-1;const o=f=>{t(n,p=>bN(p??Rc,f,r))},a=async f=>{const p=f==="baseline"?-1:s;try{const m=await e.request("session:events",{sessionId:r,afterSeq:p});if(i)return;const v=m.events??[],y=m.latestSeq??-1;if(f==="baseline")o({type:"session:events",sessionId:r,events:v,latestSeq:y}),s=y;else{const _=m.bufferStartSeq??0,x=y<p||_>p+1;o({type:x?"session:events":"session:events:append",sessionId:r,events:v,latestSeq:y}),s=Math.max(s,y)}}catch{}},l=async()=>{try{const f=await e.request("info");if(i)return;o({type:"ready",runningSessions:(f.runningSessions??[]).map(p=>({sessionId:p.sessionId,freshSpawn:p.freshSpawn,status:Pb(p.status)}))})}catch{}},c=async()=>{try{await e.request("session:subscribe",{sessionId:r})}catch{}i||(await a(s<0?"baseline":"delta"),!i&&await l())},u=e.onFrame((f,p)=>{if(!i)if(f==="session:event"){const m=p;if(m.sessionId!==r)return;const v=m.event.seq;De("session-events","push session:event",{sid:r,kind:m.event.kind,seq:v,lastSeqBefore:s}),o({type:"session:event",sessionId:m.sessionId,event:m.event}),typeof v=="number"&&v>s&&(s=v)}else if(f==="session:status"){const m=p;if(m.sessionId!==r)return;if(!wN(m.status)){De("session-events","push session:status drop",{sid:r,status:m.status});return}De("session-events","push session:status",{sid:r,status:m.status}),o({type:"session:status",sessionId:m.sessionId,status:m.status})}else if(f==="session:cleared"){if(p.sessionId!==r)return;De("session-events","push session:cleared",{sid:r}),o({type:"session:change",sessionId:r}),s=-1}else if(f==="permission:request"){const m=p;if(m.sessionId!==r)return;o({type:"permission:request",sessionId:m.sessionId,requestId:m.requestId,tool:m.tool,input:m.input,...typeof m.toolUseId=="string"&&m.toolUseId?{toolUseId:m.toolUseId}:{}})}else if(f==="session:question"){const m=p;if(m.sessionId!==r)return;o({type:"session:question",sessionId:m.sessionId,toolUseId:m.toolUseId,requestId:m.requestId,questions:m.questions})}else if(f==="session:question:cleared"){const m=p;if(m.sessionId!==r)return;m.answers&&Object.keys(m.answers).length>0?o({type:"session:question:submitted",sessionId:m.sessionId,toolUseId:m.toolUseId,answers:m.answers}):o({type:"session:question:clear",sessionId:m.sessionId,toolUseId:m.toolUseId})}else if(f==="session:rewound"){const m=p;if(m.sessionId!==r)return;o({type:"session:rewound",sessionId:m.sessionId,userMessageId:m.userMessageId})}else f==="ready"&&o({type:"ready",runningSessions:(p.runningSessions??[]).map(v=>({sessionId:v.sessionId,freshSpawn:v.freshSpawn,status:Pb(v.status)}))})}),d=e.onConnect(()=>{c()});return e.isConnected&&c(),()=>{i=!0,u(),d(),e.request("session:unsubscribe",{sessionId:r}).catch(()=>{})}}}}const HO=new Set(["tunnel:ready","tunnel:exited","tunnel:unavailable"]);function UO(e,t){return{start(n){let r=!1;const i=async()=>{try{const a=await e.request("info",void 0);if(r)return;t(n,()=>a)}catch{}},s=e.onConnect(()=>{i()}),o=e.onFrame(a=>{HO.has(a)&&i()});return i(),()=>{r=!0,s(),o()}}}}function WO(){return{start(){return()=>{}}}}function VO(e,t){return{start(n){let r=!1;const i=async()=>{try{const o=await e.request("persona:list",{});if(r)return;t(n,()=>o.personas??[])}catch{}},s=e.onConnect(()=>{i()});return i(),()=>{r=!0,s()}}}}function qO(e){const t=jO(e),n=AO();let r=null;const i=(o,a)=>{r==null||r.setData(o,a)};n.register(/^capabilities\//,LO(t,i)),n.register(/^sessions$/,OO(t,i)),n.register(/^session\//,FO(t,i)),n.register(/^personas$/,VO(t,i)),n.register(/^persona-detail\//,WO()),n.register(/^daemon-info$/,UO(t,i));const s=MO({onFirstObserver:o=>{o&&n.activate(o)},onLastObserver:o=>{o&&n.deactivate(o)}});return r=s,{cache:s,channel:t}}class F_{constructor(t){this.client=t}info(){return this.client.request("info")}attachmentSignUrl(t){return this.client.request("attachment.signUrl",t)}attachmentGroupAdd(t,n,r){return this.client.request("attachment.groupAdd",{sessionId:t,relPath:n,...r?{label:r}:{}})}attachmentGroupRemove(t,n){return this.client.request("attachment.groupRemove",{sessionId:t,relPath:n})}attachmentGroupList(t){return this.client.request("attachment.groupList",{sessionId:t})}sessionCreate(t){return this.client.request("session:create",t)}appBuilderListProjects(){return this.client.request("appBuilder:listProjects",{})}appBuilderGetProject(t){return this.client.request("appBuilder:getProject",{sessionId:t})}appBuilderUpdateProjectPort(t,n){return this.client.request("appBuilder:updateProjectPort",{name:t,newPort:n})}appBuilderStartDevServer(t,n){return this.client.request("appBuilder:startDevServer",{sessionId:t,...n!=null&&n.force?{force:!0}:{}})}appBuilderStopDevServer(t){return this.client.request("appBuilder:stopDevServer",{sessionId:t})}appBuilderPublish(t){return this.client.request("appBuilder:publish",{name:t})}appBuilderDismissPublishJob(t){return this.client.request("appBuilder:dismissPublishJob",{name:t})}sessionList(){return this.client.request("session:list")}sessionGet(t){return this.client.request("session:get",{sessionId:t})}sessionUpdate(t,n){return this.client.request("session:update",{sessionId:t,patch:n})}sessionDelete(t){return this.client.request("session:delete",{sessionId:t})}sessionSend(t,n){return this.client.request("session:send",{sessionId:t,text:n})}sessionStop(t){return this.client.request("session:stop",{sessionId:t})}sessionInterrupt(t){return this.client.request("session:interrupt",{sessionId:t})}sessionRewind(t){return this.client.request("session:rewind",t)}sessionRewindableMessageIds(t){return this.client.request("session:rewindable-message-ids",{sessionId:t})}sessionRewindDiff(t){return this.client.request("session:rewind-diff",t)}sessionNew(t){return this.client.request("session:new",{sessionId:t})}sessionFork(t){return this.client.request("session:fork",t)}sessionResume(t,n){return this.client.request("session:resume",{sessionId:t,toolSessionId:n})}sessionObserve(t){return this.client.request("session:observe",t)}sessionEvents(t,n){return this.client.request("session:events",{sessionId:t,afterSeq:n})}sessionSubscribe(t){return this.client.request("session:subscribe",{sessionId:t})}sessionUnsubscribe(t){return this.client.request("session:unsubscribe",{sessionId:t})}pinSession(t,n){return this.client.request("session:pin",{sessionId:t,pinned:n})}markSessionRead(t){return this.client.request("session:markRead",{sessionId:t})}reorderPins(t){return this.client.request("session:reorderPins",{orderedIds:t})}peerSessionUpsert(t){return this.client.request("peerSession:upsert",t)}peerSessionRemove(t){return this.client.request("peerSession:remove",{sessionId:t})}permissionRespond(t){return this.client.request("permission:respond",t)}answerQuestion(t){return this.client.request("session:answerQuestion",t)}cancelQuestion(t){return this.client.request("session:cancelQuestion",t)}historyProjects(){return this.client.request("history:projects")}historyList(t){return this.client.request("history:list",{projectPath:t})}historyRead(t){return this.client.request("history:read",t)}historySubagents(t){return this.client.request("history:subagents",t)}historySubagentRead(t){return this.client.request("history:subagent-read",t)}listRecentDirs(){return this.client.request("history:recentDirs",{})}getGitRoot(t){return this.client.request("git:root",{cwd:t})}getGitBranch(t){return this.client.request("git:branch",{cwd:t})}listGitBranches(t){return this.client.request("git:branches",{cwd:t})}personaCreate(t){return this.client.request("persona:create",t)}personaList(){return this.client.request("persona:list",{})}personaGet(t){return this.client.request("persona:get",{personaId:t})}personaUpdate(t,n){return this.client.request("persona:update",{personaId:t,patch:n})}personaDelete(t){return this.client.request("persona:delete",{personaId:t})}visitorList(){return this.client.request("visitor:list",{})}workspaceList(t={}){return this.client.request("workspace:list",t)}workspaceRead(t){return this.client.request("workspace:read",t)}skillsList(t,n){return this.client.request("skills:list",{cwd:t,...n?{tool:n}:{}})}agentsList(t,n){return this.client.request("agents:list",{cwd:t,...n?{tool:n}:{}})}capabilitiesGet(t="claude"){return this.client.request("capabilities:get",{tool:t})}shiftList(){return this.client.request("shift:list")}}function KO(e){const[t,n]=g.useState(e.isOpen?{kind:"connected",url:""}:{kind:"connecting"});return g.useEffect(()=>{const r=e.on("ready",l=>{const c=l;n(u=>({kind:"connected",url:u.kind==="connected"?u.url:"",mode:u.kind==="connected"?u.mode:void 0,daemonVersion:c.version,protocolVersion:c.protocolVersion}))}),i=e.on("daemon:connected",l=>{const c=l;n(u=>({kind:"connected",url:c.url,mode:c.mode,daemonVersion:u.kind==="connected"?u.daemonVersion:void 0,protocolVersion:u.kind==="connected"?u.protocolVersion:void 0}))}),s=e.on("daemon:disconnected",l=>{const c=(l==null?void 0:l.reason)??"";/auth failed|auth timeout|auth required|auth handshake timeout/i.test(c)?n({kind:"auth-failed",reason:c}):n({kind:"disconnected",reason:c})}),o=e.on("daemon:reconnecting",l=>{const c=l;n({kind:"reconnecting",attempt:c.attempt,nextDelayMs:c.nextDelayMs,scheduledAt:c.scheduledAt??Date.now()})}),a=e.on("daemon:version-mismatch",l=>{const c=l;n({kind:"version-mismatch",daemonProtocol:c.daemonProtocol,supportedProtocol:c.supportedProtocol})});return()=>{r(),i(),s(),o(),a()}},[e]),t}function GO(e){const t=ko(),n=si(e.kind==="connected"?"sessions":""),r=g.useCallback(async()=>{t.setData("sessions",i=>i??[])},[t]);return{sessions:n??[],loading:!1,loaded:n!==void 0,error:null,refresh:r}}function Xa(){const e=Rs();return g.useMemo(()=>new F_(e),[e])}function SN(e){return{personaId:e.personaId,label:e.label,model:e.model,tool:e.tool,iconKey:e.iconKey,public:e.public,createdAt:e.createdAt,updatedAt:e.updatedAt}}function kN(){const e=ko(),t=Xa(),n=si("personas")??[],r=g.useMemo(()=>n.map(s=>SN(s)),[n]),i=g.useCallback(async()=>{const s=await t.personaList();e.setData("personas",()=>s.personas??[])},[t,e]);return{personas:r,raw:n,loaded:si("personas")!==void 0,refresh:i}}function CN(e){const{raw:t}=kN(),n=ko(),r=Xa(),i=e?t.find(a=>a.personaId===e)??null:null,s=i?SN(i):null,o=g.useCallback(async()=>{if(!e)return;const a=await r.personaList();n.setData("personas",()=>a.personas??[])},[e,r,n]);return{persona:s,raw:i,loaded:!!s,refresh:o}}function XO(e){const t=Xa(),n=ko(),r=e?`persona-detail/${e}`:"",i=si(r),s=g.useCallback(async()=>{const o={personality:"",skills:[],plugins:[],sandboxSettings:null};if(!e)return o;const a=await t.personaGet(e);let l;if("persona"in a&&a.persona===null)l=o;else{const c=a;l={personality:c.personality??"",skills:c.skills??[],plugins:c.plugins??[],sandboxSettings:c.sandboxSettings??null}}return n.setData(r,()=>l),l},[t,n,e,r]);return g.useEffect(()=>{e&&s()},[e,s]),{personality:(i==null?void 0:i.personality)??"",skills:(i==null?void 0:i.skills)??[],plugins:(i==null?void 0:i.plugins)??[],sandboxSettings:(i==null?void 0:i.sandboxSettings)??null,loaded:i!==void 0,refresh:s}}function EN(){const e=ko(),t=Xa();return g.useCallback(async()=>{const n=await t.personaList();e.setData("personas",()=>n.personas??[])},[e,t])}function YO(){const e=Xa(),t=EN();return g.useCallback(async(n,r)=>{const i=await e.personaUpdate(n,r);return await t(),i},[e,t])}function ZO(){const e=Xa(),t=EN();return g.useCallback(async n=>{await e.personaDelete(n),await t()},[e,t])}const Rb="clawd:sidebar:tree-collapsed";function QO(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function JO(e){const t=QO(e);if(!Array.isArray(t))return new Set;const n=new Set;for(const r of t)typeof r=="string"&&n.add(r);return n}function eB(){const e=N_(),[t,n]=g.useState(()=>new Set),r=g.useRef(t);r.current=t,g.useEffect(()=>{let l=!1;return(async()=>{try{const c=await e.kv.get(Rb);if(l)return;n(JO(c))}catch{}})(),()=>{l=!0}},[e]);const i=g.useCallback(l=>{e.kv.set(Rb,[...l]).catch(()=>{})},[e]),s=g.useCallback(l=>r.current.has(l),[]),o=g.useCallback(l=>{n(c=>{const u=new Set(c);return u.has(l)?u.delete(l):u.add(l),i(u),u})},[i]),a=g.useCallback(l=>{n(c=>{let u=!1;const d=new Set;for(const f of c)l.has(f)?d.add(f):u=!0;return u?(i(d),d):c})},[i]);return{isCollapsed:s,toggle:o,prune:a}}const H_=g.createContext(null);function tB(){const e=g.useContext(H_);if(!e)throw new Error("SessionTreeCollapsedContext.Provider missing — wrap SessionTreeNode tree with <SessionTreeCollapsedContext.Provider value={useSessionTreeCollapsed()}>");return e}/**
|
|
96
96
|
* @license lucide-react v0.577.0 - ISC
|
|
97
97
|
*
|
|
98
98
|
* This source code is licensed under the ISC license.
|
|
@@ -482,7 +482,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
482
482
|
`)},sw=function(){var e=parseInt(document.body.getAttribute(xa)||"0",10);return isFinite(e)?e:0},f8=function(){g.useEffect(function(){return document.body.setAttribute(xa,(sw()+1).toString()),function(){var e=sw()-1;e<=0?document.body.removeAttribute(xa):document.body.setAttribute(xa,e.toString())}},[])},p8=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;f8();var s=g.useMemo(function(){return u8(i)},[i]);return g.createElement(d8,{styles:h8(s,!t,i,n?"":"!important")})},Pv=!1;if(typeof window<"u")try{var Ju=Object.defineProperty({},"passive",{get:function(){return Pv=!0,!0}});window.addEventListener("test",Ju,Ju),window.removeEventListener("test",Ju,Ju)}catch{Pv=!1}var $o=Pv?{passive:!1}:!1,m8=function(e){return e.tagName==="TEXTAREA"},KT=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!m8(e)&&n[t]==="visible")},g8=function(e){return KT(e,"overflowY")},v8=function(e){return KT(e,"overflowX")},ow=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=GT(e,r);if(i){var s=XT(e,r),o=s[1],a=s[2];if(o>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},_8=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},x8=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},GT=function(e,t){return e==="v"?g8(t):v8(t)},XT=function(e,t){return e==="v"?_8(t):x8(t)},y8=function(e,t){return e==="h"&&t==="rtl"?-1:1},b8=function(e,t,n,r,i){var s=y8(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=XT(e,a),m=p[0],v=p[1],y=p[2],_=v-y-s*m;(m||_)&>(e,a)&&(d+=_,f+=m);var x=a.parentNode;a=x&&x.nodeType===Node.DOCUMENT_FRAGMENT_NODE?x.host:x}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},ed=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},aw=function(e){return[e.deltaX,e.deltaY]},lw=function(e){return e&&"current"in e?e.current:e},w8=function(e,t){return e[0]===t[0]&&e[1]===t[1]},S8=function(e){return`
|
|
483
483
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
484
484
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
485
|
-
`)},k8=0,Fo=[];function C8(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState(k8++)[0],s=g.useState(qT)[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=qF([e.lockRef.current],(e.shards||[]).map(lw),!0).filter(Boolean);return v.forEach(function(y){return y.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),v.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(v,y){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var _=ed(v),x=n.current,b="deltaX"in v?v.deltaX:x[0]-_[0],w="deltaY"in v?v.deltaY:x[1]-_[1],S,k=v.target,T=Math.abs(b)>Math.abs(w)?"h":"v";if("touches"in v&&T==="h"&&k.type==="range")return!1;var N=window.getSelection(),O=N&&N.anchorNode,P=O?O===k||O.contains(k):!1;if(P)return!1;var L=ow(T,k);if(!L)return!0;if(L?S=T:(S=T==="v"?"h":"v",L=ow(T,k)),!L)return!1;if(!r.current&&"changedTouches"in v&&(b||w)&&(r.current=S),!S)return!0;var R=r.current||S;return b8(R,y,v,R==="h"?b:w)},[]),l=g.useCallback(function(v){var y=v;if(!(!Fo.length||Fo[Fo.length-1]!==s)){var _="deltaY"in y?aw(y):ed(y),x=t.current.filter(function(S){return S.name===y.type&&(S.target===y.target||y.target===S.shadowParent)&&w8(S.delta,_)})[0];if(x&&x.should){y.cancelable&&y.preventDefault();return}if(!x){var b=(o.current.shards||[]).map(lw).filter(Boolean).filter(function(S){return S.contains(y.target)}),w=b.length>0?a(y,b[0]):!o.current.noIsolation;w&&y.cancelable&&y.preventDefault()}}},[]),c=g.useCallback(function(v,y,_,x){var b={name:v,delta:y,target:_,should:x,shadowParent:E8(_)};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(w){return w!==b})},1)},[]),u=g.useCallback(function(v){n.current=ed(v),r.current=void 0},[]),d=g.useCallback(function(v){c(v.type,aw(v),v.target,a(v,e.lockRef.current))},[]),f=g.useCallback(function(v){c(v.type,ed(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return Fo.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,$o),document.addEventListener("touchmove",l,$o),document.addEventListener("touchstart",u,$o),function(){Fo=Fo.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,$o),document.removeEventListener("touchmove",l,$o),document.removeEventListener("touchstart",u,$o)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(s,{styles:S8(i)}):null,p?g.createElement(p8,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function E8(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const N8=t8(VT,C8);var sx=g.forwardRef(function(e,t){return g.createElement($f,Gr({},e,{ref:t,sideCar:N8}))});sx.classNames=$f.classNames;var Rv=["Enter"," "],T8=["ArrowDown","PageUp","Home"],YT=["ArrowUp","PageDown","End"],P8=[...T8,...YT],R8={ltr:[...Rv,"ArrowRight"],rtl:[...Rv,"ArrowLeft"]},I8={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ou="Menu",[Dc,M8,A8]=iT(ou),[No,ZT]=Eo(ou,[A8,zf,LT]),Ff=zf(),QT=LT(),[j8,To]=No(ou),[D8,au]=No(ou),JT=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=Ff(t),[l,c]=g.useState(null),u=g.useRef(!1),d=Ii(s),f=sT(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(IT,{...a,children:h.jsx(j8,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(D8,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};JT.displayName=ou;var L8="MenuAnchor",ox=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Ff(n);return h.jsx(MT,{...i,...r,ref:t})});ox.displayName=L8;var ax="MenuPortal",[O8,eP]=No(ax,{forceMount:void 0}),tP=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=To(ax,t);return h.jsx(O8,{scope:t,forceMount:n,children:h.jsx(zi,{present:n||s.open,children:h.jsx(ix,{asChild:!0,container:i,children:r})})})};tP.displayName=ax;var vr="MenuContent",[B8,lx]=No(vr),nP=g.forwardRef((e,t)=>{const n=eP(vr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=To(vr,e.__scopeMenu),o=au(vr,e.__scopeMenu);return h.jsx(Dc.Provider,{scope:e.__scopeMenu,children:h.jsx(zi,{present:r||s.open,children:h.jsx(Dc.Slot,{scope:e.__scopeMenu,children:o.modal?h.jsx(z8,{...i,ref:t}):h.jsx($8,{...i,ref:t})})})})}),z8=g.forwardRef((e,t)=>{const n=To(vr,e.__scopeMenu),r=g.useRef(null),i=qt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return HT(s)},[]),h.jsx(cx,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Te(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),$8=g.forwardRef((e,t)=>{const n=To(vr,e.__scopeMenu);return h.jsx(cx,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),F8=Ac("MenuContent.ScrollLock"),cx=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,y=To(vr,n),_=au(vr,n),x=Ff(n),b=QT(n),w=M8(n),[S,k]=g.useState(null),T=g.useRef(null),N=qt(t,T,y.onContentChange),O=g.useRef(0),P=g.useRef(""),L=g.useRef(0),R=g.useRef(null),I=g.useRef("right"),j=g.useRef(0),B=m?sx:g.Fragment,$=m?{as:F8,allowPinchZoom:!0}:void 0,F=D=>{var pe,Oe;const C=P.current+D,H=w().filter(re=>!re.disabled),q=document.activeElement,M=(pe=H.find(re=>re.ref.current===q))==null?void 0:pe.textValue,ne=H.map(re=>re.textValue),oe=J8(ne,C,M),V=(Oe=H.find(re=>re.textValue===oe))==null?void 0:Oe.ref.current;(function re(Me){P.current=Me,window.clearTimeout(O.current),Me!==""&&(O.current=window.setTimeout(()=>re(""),1e3))})(C),V&&setTimeout(()=>V.focus())};g.useEffect(()=>()=>window.clearTimeout(O.current),[]),lT();const A=g.useCallback(D=>{var H,q;return I.current===((H=R.current)==null?void 0:H.side)&&t9(D,(q=R.current)==null?void 0:q.area)},[]);return h.jsx(B8,{scope:n,searchRef:P,onItemEnter:g.useCallback(D=>{A(D)&&D.preventDefault()},[A]),onItemLeave:g.useCallback(D=>{var C;A(D)||((C=T.current)==null||C.focus(),k(null))},[A]),onTriggerLeave:g.useCallback(D=>{A(D)&&D.preventDefault()},[A]),pointerGraceTimerRef:L,onPointerGraceIntentChange:g.useCallback(D=>{R.current=D},[]),children:h.jsx(B,{...$,children:h.jsx(X_,{asChild:!0,trapped:i,onMountAutoFocus:Te(s,D=>{var C;D.preventDefault(),(C=T.current)==null||C.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:h.jsx(jf,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(FF,{asChild:!0,...b,dir:_.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:k,onEntryFocus:Te(l,D=>{_.isUsingKeyboardRef.current||D.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(AT,{role:"menu","aria-orientation":"vertical","data-state":_P(y.open),"data-radix-menu-content":"",dir:_.dir,...x,...v,ref:N,style:{outline:"none",...v.style},onKeyDown:Te(v.onKeyDown,D=>{const H=D.target.closest("[data-radix-menu-content]")===D.currentTarget,q=D.ctrlKey||D.altKey||D.metaKey,M=D.key.length===1;H&&(D.key==="Tab"&&D.preventDefault(),!q&&M&&F(D.key));const ne=T.current;if(D.target!==ne||!P8.includes(D.key))return;D.preventDefault();const V=w().filter(pe=>!pe.disabled).map(pe=>pe.ref.current);YT.includes(D.key)&&V.reverse(),Z8(V)}),onBlur:Te(e.onBlur,D=>{D.currentTarget.contains(D.target)||(window.clearTimeout(O.current),P.current="")}),onPointerMove:Te(e.onPointerMove,Lc(D=>{const C=D.target,H=j.current!==D.clientX;if(D.currentTarget.contains(C)&&H){const q=D.clientX>j.current?"right":"left";I.current=q,j.current=D.clientX}}))})})})})})})});nP.displayName=vr;var H8="MenuGroup",ux=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{role:"group",...r,ref:t})});ux.displayName=H8;var U8="MenuLabel",rP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{...r,ref:t})});rP.displayName=U8;var jh="MenuItem",cw="menu.itemSelect",Hf=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=au(jh,e.__scopeMenu),a=lx(jh,e.__scopeMenu),l=qt(t,s),c=g.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(cw,{bubbles:!0,cancelable:!0});d.addEventListener(cw,p=>r==null?void 0:r(p),{once:!0}),rT(d,f),f.defaultPrevented?c.current=!1:o.onClose()}};return h.jsx(iP,{...i,ref:l,disabled:n,onClick:Te(e.onClick,u),onPointerDown:d=>{var f;(f=e.onPointerDown)==null||f.call(e,d),c.current=!0},onPointerUp:Te(e.onPointerUp,d=>{var f;c.current||(f=d.currentTarget)==null||f.click()}),onKeyDown:Te(e.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||Rv.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});Hf.displayName=jh;var iP=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=lx(jh,n),a=QT(n),l=g.useRef(null),c=qt(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(Dc.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:h.jsx(HF,{asChild:!0,...a,focusable:!r,children:h.jsx(Et.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:Te(e.onPointerMove,Lc(m=>{r?o.onItemLeave(m):(o.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Te(e.onPointerLeave,Lc(m=>o.onItemLeave(m))),onFocus:Te(e.onFocus,()=>d(!0)),onBlur:Te(e.onBlur,()=>d(!1))})})})}),W8="MenuCheckboxItem",sP=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return h.jsx(uP,{scope:e.__scopeMenu,checked:n,children:h.jsx(Hf,{role:"menuitemcheckbox","aria-checked":Dh(n)?"mixed":n,...i,ref:t,"data-state":hx(n),onSelect:Te(i.onSelect,()=>r==null?void 0:r(Dh(n)?!0:!n),{checkForDefaultPrevented:!1})})})});sP.displayName=W8;var oP="MenuRadioGroup",[V8,q8]=No(oP,{value:void 0,onValueChange:()=>{}}),aP=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=Ii(r);return h.jsx(V8,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(ux,{...i,ref:t})})});aP.displayName=oP;var lP="MenuRadioItem",cP=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=q8(lP,e.__scopeMenu),s=n===i.value;return h.jsx(uP,{scope:e.__scopeMenu,checked:s,children:h.jsx(Hf,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":hx(s),onSelect:Te(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});cP.displayName=lP;var dx="MenuItemIndicator",[uP,K8]=No(dx,{checked:!1}),dP=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=K8(dx,n);return h.jsx(zi,{present:r||Dh(s.checked)||s.checked===!0,children:h.jsx(Et.span,{...i,ref:t,"data-state":hx(s.checked)})})});dP.displayName=dx;var G8="MenuSeparator",hP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});hP.displayName=G8;var X8="MenuArrow",fP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Ff(n);return h.jsx(jT,{...i,...r,ref:t})});fP.displayName=X8;var Y8="MenuSub",[pne,pP]=No(Y8),jl="MenuSubTrigger",mP=g.forwardRef((e,t)=>{const n=To(jl,e.__scopeMenu),r=au(jl,e.__scopeMenu),i=pP(jl,e.__scopeMenu),s=lx(jl,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(ox,{asChild:!0,...c,children:h.jsx(iP,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":_P(n.open),...e,ref:ru(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:Te(e.onPointerMove,Lc(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:Te(e.onPointerLeave,Lc(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,y=v==="right",_=y?-5:5,x=f[y?"left":"right"],b=f[y?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+_,y:d.clientY},{x,y:f.top},{x:b,y:f.top},{x:b,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:Te(e.onKeyDown,d=>{var p;const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||R8[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});mP.displayName=jl;var gP="MenuSubContent",vP=g.forwardRef((e,t)=>{const n=eP(vr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=To(vr,e.__scopeMenu),o=au(vr,e.__scopeMenu),a=pP(gP,e.__scopeMenu),l=g.useRef(null),c=qt(t,l);return h.jsx(Dc.Provider,{scope:e.__scopeMenu,children:h.jsx(zi,{present:r||s.open,children:h.jsx(Dc.Slot,{scope:e.__scopeMenu,children:h.jsx(cx,{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:Te(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Te(e.onEscapeKeyDown,u=>{o.onClose(),u.preventDefault()}),onKeyDown:Te(e.onKeyDown,u=>{var p;const d=u.currentTarget.contains(u.target),f=I8[o.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});vP.displayName=gP;function _P(e){return e?"open":"closed"}function Dh(e){return e==="indeterminate"}function hx(e){return Dh(e)?"indeterminate":e?"checked":"unchecked"}function Z8(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Q8(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function J8(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=Q8(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 e9(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 t9(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return e9(n,t)}function Lc(e){return t=>t.pointerType==="mouse"?e(t):void 0}var n9=JT,r9=ox,i9=tP,s9=nP,o9=ux,a9=rP,l9=Hf,c9=sP,u9=aP,d9=cP,h9=dP,f9=hP,p9=fP,m9=mP,g9=vP,Uf="DropdownMenu",[v9]=Eo(Uf,[ZT]),Mn=ZT(),[_9,xP]=v9(Uf),yP=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=Mn(t),c=g.useRef(null),[u,d]=Af({prop:i,defaultProp:s??!1,onChange:o,caller:Uf});return h.jsx(_9,{scope:t,triggerId:to(),triggerRef:c,contentId:to(),open:u,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(n9,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};yP.displayName=Uf;var bP="DropdownMenuTrigger",wP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=xP(bP,n),o=Mn(n);return h.jsx(r9,{asChild:!0,...o,children:h.jsx(Et.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:ru(t,s.triggerRef),onPointerDown:Te(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:Te(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});wP.displayName=bP;var x9="DropdownMenuPortal",SP=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Mn(t);return h.jsx(i9,{...r,...n})};SP.displayName=x9;var kP="DropdownMenuContent",CP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=xP(kP,n),s=Mn(n),o=g.useRef(!1);return h.jsx(s9,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:t,onCloseAutoFocus:Te(e.onCloseAutoFocus,a=>{var l;o.current||(l=i.triggerRef.current)==null||l.focus(),o.current=!1,a.preventDefault()}),onInteractOutside:Te(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)"}})});CP.displayName=kP;var y9="DropdownMenuGroup",b9=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(o9,{...i,...r,ref:t})});b9.displayName=y9;var w9="DropdownMenuLabel",EP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(a9,{...i,...r,ref:t})});EP.displayName=w9;var S9="DropdownMenuItem",NP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(l9,{...i,...r,ref:t})});NP.displayName=S9;var k9="DropdownMenuCheckboxItem",TP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(c9,{...i,...r,ref:t})});TP.displayName=k9;var C9="DropdownMenuRadioGroup",E9=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(u9,{...i,...r,ref:t})});E9.displayName=C9;var N9="DropdownMenuRadioItem",T9=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(d9,{...i,...r,ref:t})});T9.displayName=N9;var P9="DropdownMenuItemIndicator",PP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(h9,{...i,...r,ref:t})});PP.displayName=P9;var R9="DropdownMenuSeparator",RP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(f9,{...i,...r,ref:t})});RP.displayName=R9;var I9="DropdownMenuArrow",M9=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(p9,{...i,...r,ref:t})});M9.displayName=I9;var A9="DropdownMenuSubTrigger",j9=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(m9,{...i,...r,ref:t})});j9.displayName=A9;var D9="DropdownMenuSubContent",L9=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(g9,{...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)"}})});L9.displayName=D9;var O9=yP,B9=wP,z9=SP,IP=CP,MP=EP,AP=NP,jP=TP,$9=PP,DP=RP;const LP=O9,OP=B9,fx=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(z9,{children:h.jsx(IP,{ref:r,sideOffset:t,className:se("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));fx.displayName=IP.displayName;const Ys=g.forwardRef(({className:e,inset:t,...n},r)=>h.jsx(AP,{ref:r,className:se("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-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Ys.displayName=AP.displayName;const F9=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>h.jsxs(jP,{ref:i,checked:n,className:se("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-[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($9,{children:h.jsx(nu,{className:"h-3.5 w-3.5"})})}),t]}));F9.displayName=jP.displayName;const BP=g.forwardRef(({className:e,...t},n)=>h.jsx(DP,{ref:n,className:se("-mx-1 my-1 h-px bg-border",e),...t}));BP.displayName=DP.displayName;const H9=g.forwardRef(({className:e,...t},n)=>h.jsx(MP,{ref:n,className:se("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));H9.displayName=MP.displayName;function U9({iconKey:e,className:t}){const n=tT(e);if(!n)return h.jsx(U_,{className:se("w-3.5 h-3.5 shrink-0 text-text-400",t),"data-testid":"session-icon-default","aria-label":"未分类"});const r=n.Icon;return h.jsx(r,{className:se("w-3.5 h-3.5 shrink-0",n.colorClass,t),"data-testid":`session-icon-${n.key}`,"aria-label":n.label})}var W9=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"}),V9="VisuallyHidden",zP=g.forwardRef((e,t)=>h.jsx(Et.span,{...e,ref:t,style:{...W9,...e.style}}));zP.displayName=V9;var q9=zP,[Wf]=Eo("Tooltip",[zf]),Vf=zf(),$P="TooltipProvider",K9=700,Iv="tooltip.open",[G9,px]=Wf($P),FP=e=>{const{__scopeTooltip:t,delayDuration:n=K9,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(G9,{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})};FP.displayName=$P;var Oc="Tooltip",[X9,qf]=Wf(Oc),HP=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=px(Oc,e.__scopeTooltip),c=Vf(t),[u,d]=g.useState(null),f=to(),p=g.useRef(0),m=o??l.disableHoverableContent,v=a??l.delayDuration,y=g.useRef(!1),[_,x]=Af({prop:r,defaultProp:i??!1,onChange:T=>{T?(l.onOpen(),document.dispatchEvent(new CustomEvent(Iv))):l.onClose(),s==null||s(T)},caller:Oc}),b=g.useMemo(()=>_?y.current?"delayed-open":"instant-open":"closed",[_]),w=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,y.current=!1,x(!0)},[x]),S=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x(!1)},[x]),k=g.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{y.current=!0,x(!0),p.current=0},v)},[v,x]);return g.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),h.jsx(IT,{...c,children:h.jsx(X9,{scope:t,contentId:f,open:_,stateAttribute:b,trigger:u,onTriggerChange:d,onTriggerEnter:g.useCallback(()=>{l.isOpenDelayedRef.current?k():w()},[l.isOpenDelayedRef,k,w]),onTriggerLeave:g.useCallback(()=>{m?S():(window.clearTimeout(p.current),p.current=0)},[S,m]),onOpen:w,onClose:S,disableHoverableContent:m,children:n})})};HP.displayName=Oc;var Mv="TooltipTrigger",UP=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=qf(Mv,n),s=px(Mv,n),o=Vf(n),a=g.useRef(null),l=qt(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(MT,{asChild:!0,...o,children:h.jsx(Et.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:Te(e.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:Te(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:Te(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Te(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Te(e.onBlur,i.onClose),onClick:Te(e.onClick,i.onClose)})})});UP.displayName=Mv;var Y9="TooltipPortal",[mne,Z9]=Wf(Y9,{forceMount:void 0}),La="TooltipContent",WP=g.forwardRef((e,t)=>{const n=Z9(La,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=qf(La,e.__scopeTooltip);return h.jsx(zi,{present:r||o.open,children:o.disableHoverableContent?h.jsx(VP,{side:i,...s,ref:t}):h.jsx(Q9,{side:i,...s,ref:t})})}),Q9=g.forwardRef((e,t)=>{const n=qf(La,e.__scopeTooltip),r=px(La,e.__scopeTooltip),i=g.useRef(null),s=qt(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 y=m.currentTarget,_={x:m.clientX,y:m.clientY},x=rH(_,y.getBoundingClientRect()),b=iH(_,x),w=sH(v.getBoundingClientRect()),S=aH([...b,...w]);a(S),d(!0)},[d]);return g.useEffect(()=>()=>f(),[f]),g.useEffect(()=>{if(l&&u){const m=y=>p(y,u),v=y=>p(y,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 y=v.target,_={x:v.clientX,y:v.clientY},x=(l==null?void 0:l.contains(y))||(u==null?void 0:u.contains(y)),b=!oH(_,o);x?f():b&&(f(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[l,u,o,c,f]),h.jsx(VP,{...e,ref:s})}),[J9,eH]=Wf(Oc,{isInside:!1}),tH=Vz("TooltipContent"),VP=g.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,l=qf(La,n),c=Vf(n),{onClose:u}=l;return g.useEffect(()=>(document.addEventListener(Iv,u),()=>document.removeEventListener(Iv,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(jf,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:h.jsxs(AT,{"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(tH,{children:r}),h.jsx(J9,{scope:n,isInside:!0,children:h.jsx(q9,{id:l.contentId,role:"tooltip",children:i||r})})]})})});WP.displayName=La;var qP="TooltipArrow",nH=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Vf(n);return eH(qP,n).isInside?null:h.jsx(jT,{...i,...r,ref:t})});nH.displayName=qP;function rH(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 iH(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 sH(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 oH(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 aH(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),lH(t)}function lH(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 cH=FP,uH=HP,dH=UP,KP=WP;const mx=cH,gx=uH,vx=dH,Kf=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(KP,{ref:r,sideOffset:t,className:se("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}));Kf.displayName=KP.displayName;function GP({value:e,onChange:t}){return h.jsx(mx,{delayDuration:150,children:h.jsx("div",{className:"flex items-center gap-1 flex-wrap","data-testid":"session-icon-picker",children:eT.map(n=>{const r=n.Icon,i=e===n.key;return h.jsxs(gx,{children:[h.jsx(vx,{asChild:!0,children:h.jsx("button",{type:"button",onClick:()=>t(i?null:n.key),"data-testid":`session-icon-option-${n.key}`,"aria-label":n.label,"aria-pressed":i,className:se("w-8 h-8 rounded-md flex items-center justify-center transition-colors cursor-pointer",i?"bg-text-100/10 ring-1 ring-text-100/30":"hover:bg-text-100/5"),children:h.jsx(r,{className:se("w-4 h-4",n.colorClass)})})}),h.jsx(Kf,{side:"bottom",children:n.label})]},n.key)})})})}function hH({open:e,initialLabel:t,initialIconKey:n,placeholder:r,onSubmit:i,onCancel:s}){const[o,a]=g.useState(t),[l,c]=g.useState(n);return g.useEffect(()=>{e&&(a(t),c(n))},[e,t,n]),g.useEffect(()=>{if(!e)return;const u=d=>{d.key==="Escape"&&s()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[e,s]),e?eu.createPortal(h.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-bg-0/40 backdrop-blur-[2px]",onClick:s,"data-testid":"session-edit-dialog-overlay",children:h.jsxs("div",{"data-testid":"session-edit-dialog",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:u=>u.stopPropagation(),children:[h.jsx("div",{className:"text-[15px] font-semibold text-text-100",children:"Edit session"}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:"Label"}),h.jsx("input",{autoFocus:!0,type:"text",value:o,onChange:u=>a(u.target.value),placeholder:r,"data-testid":"session-edit-dialog-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",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:"Icon"}),h.jsx(GP,{value:l,onChange:c})]}),h.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[h.jsx("button",{type:"button",onClick:s,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:()=>i({label:o.trim(),iconKey:l}),"data-testid":"session-edit-dialog-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",children:"Save"})]})]})}),document.body):null}const fH=10,pH=20,mH=16,gH=20,vH=60,_H=4;function xH({session:e,active:t,hasUnread:n,running:r=!1,awaitingUser:i=!1,onSelect:s,onEdit:o,onDelete:a,onPin:l,depth:c=0,chevron:u,showCopyResume:d=!0,contactDisplayName:f}){const[p,m]=g.useState(!1),v=!!e.pinnedAt,y=c===0,_=fH+c*pH,x=g.useCallback(async()=>{const k=e.toolSessionId;if(!k)return;const N=`cd ${`'${e.cwd.replace(/'/g,"'\\''")}'`} && claude --resume ${k} --permission-mode bypassPermissions`;try{await navigator.clipboard.writeText(N)}catch{}},[e.toolSessionId,e.cwd]),b=e.appBuilderProject?`[app] ${e.appBuilderProject}`:e.label||e.cwd.split("/").filter(Boolean).pop()||e.sessionId.slice(0,8),w=e.originOwnerPrincipalId,S=w?`@${f??`…${w.slice(-8)}`}`:null;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":`session-item-${e.sessionId}`,onClick:s,style:{paddingLeft:_,display:"grid",gridTemplateColumns:`${mH}px ${gH}px 1fr auto ${vH}px`,gridTemplateAreas:'"chev icon name dot time" ". . sub sub sub"',columnGap:`${_H}px`,rowGap:"2px",alignItems:"center"},className:se("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:u??null}),h.jsx("div",{style:{gridArea:"icon"},className:"flex items-center justify-center",children:h.jsx(U9,{iconKey:e.iconKey})}),h.jsxs("div",{style:{gridArea:"name"},className:"flex items-center gap-1 min-w-0",children:[e.dispatchedFromSessionId?h.jsx(OB,{"data-testid":`dispatched-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"dispatched from another session",children:h.jsx("title",{children:"由另一个 session dispatch 派生"})}):null,e.shiftFiredFromSessionId?h.jsx(lB,{"data-testid":`shift-fired-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"fired by clawd-shift scheduler",children:h.jsx("title",{children:"由 shift 排班到点 fire 派生"})}):null,h.jsx("span",{"data-testid":`session-title-${e.sessionId}`,className:se("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:b})]}),i?h.jsx(hB,{"data-testid":`awaiting-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-3 h-3 text-warning shrink-0 animate-pulse",strokeWidth:2.25,"aria-label":"awaiting user"}):n?h.jsx("span",{"data-testid":`unread-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-2 h-2 rounded-full bg-error shrink-0","aria-label":"unread"}):r?h.jsx("span",{"data-testid":`running-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-2 h-2 rounded-full bg-success shrink-0 animate-pulse","aria-label":"running"}):null,h.jsx("span",{style:{gridArea:"time"},className:se("text-[11px] text-text-400/70 text-right shrink-0","transition-opacity duration-150 group-hover:opacity-0"),children:e.updatedAt?Bz(e.updatedAt):""}),h.jsxs("span",{style:{gridArea:"sub"},className:se("flex items-center gap-1.5 text-[11px] text-text-400/70 min-w-0","group-hover:flex-wrap"),children:[S?h.jsx("span",{"data-testid":`session-mirror-chip-${e.sessionId}`,title:`在 ${S.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:S}):null,h.jsx("span",{"data-testid":`session-subtitle-${e.sessionId}`,className:se("block text-[11px] text-text-400/70 truncate font-mono min-w-0","group-hover:whitespace-normal group-hover:overflow-visible group-hover:break-all"),children:e.cwd.replace(/^\/Users\/[^/]+/,"~")})]}),o||a||l?h.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100 transition-opacity",children:h.jsxs(LP,{modal:!1,children:[h.jsx(OP,{asChild:!0,children:h.jsx("button",{type:"button",onClick:k=>k.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(bv,{className:"w-4 h-4"})})}),h.jsxs(fx,{align:"end",onClick:k=>k.stopPropagation(),children:[l&&y&&h.jsxs(Ys,{onSelect:()=>l(e.sessionId,!v),"data-testid":`session-${v?"unpin":"pin"}-${e.sessionId}`,children:[v?h.jsx(v6,{className:"w-3 h-3 mr-2 text-text-400"}):h.jsx(DN,{className:"w-3 h-3 mr-2 text-text-400"}),v?"Unpin":"Pin"]}),o&&h.jsxs(Ys,{onSelect:()=>m(!0),"data-testid":`session-rename-${e.sessionId}`,children:[h.jsx(jN,{className:"w-3 h-3 mr-2 text-text-400"}),"Rename"]}),d&&e.toolSessionId?h.jsxs(Ys,{onSelect:()=>void x(),"data-testid":`session-copy-resume-${e.sessionId}`,children:[h.jsx(Mf,{className:"w-3 h-3 mr-2 text-text-400"}),"Copy Resume Command"]}):null,(l||o||d&&e.toolSessionId)&&a&&h.jsx(BP,{}),a&&h.jsxs(Ys,{onSelect:()=>void a(e.sessionId),className:"text-destructive focus:text-destructive focus:bg-destructive/10","data-testid":`session-delete-${e.sessionId}`,children:[h.jsx(V_,{className:"w-3 h-3 mr-2"}),"Delete"]})]})]})}):null]}),o?h.jsx(hH,{open:p,initialLabel:e.label??"",initialIconKey:e.iconKey??null,placeholder:e.cwd.split("/").pop()||"",onSubmit:k=>{o(e.sessionId,k),m(!1)},onCancel:()=>m(!1)}):null]})}function _x({node:e,depth:t=0,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,getContactDisplayName:u,showCopyResume:d}){const f=e.children.length>0,{isCollapsed:p,toggle:m}=tB(),v=!p(e.session.sessionId),y=g.useCallback(x=>{x.stopPropagation(),m(e.session.sessionId)},[m,e.session.sessionId]),_=f?h.jsx("button",{type:"button",onClick:y,"data-testid":`session-chevron-${e.session.sessionId}`,"aria-label":v?"collapse":"expand","aria-expanded":v,className:"shrink-0 flex items-center justify-center w-4 h-4 text-text-400 hover:text-text-100 cursor-pointer",children:v?h.jsx(ai,{className:"w-3 h-3"}):h.jsx(li,{className:"w-3 h-3"})}):null;return h.jsxs("div",{"data-testid":`session-tree-node-${e.session.sessionId}`,children:[h.jsx(xH,{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,showCopyResume:d,depth:t,chevron:_,contactDisplayName:e.session.originOwnerPrincipalId?u==null?void 0:u(e.session.originOwnerPrincipalId):void 0}),f&&v?h.jsx("div",{"data-testid":`session-tree-children-${e.session.sessionId}`,children:e.children.map(x=>h.jsx(_x,{node:x,depth:t+1,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,getContactDisplayName:u,showCopyResume:d},x.session.sessionId))}):null]})}function yH(e){return e.forkedFromSessionId??e.dispatchedFromSessionId??e.shiftFiredFromSessionId}function XP(e){e=e.filter(s=>!s.ephemeral);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=yH(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(bH).map(i)}function YP(e){return[...e].sort((t,n)=>t.session.updatedAt<n.session.updatedAt?1:t.session.updatedAt>n.session.updatedAt?-1:0)}function bH(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 wH(e,t){if(e.appBuilderProject)return`[app] ${e.appBuilderProject}`;if(e.label)return e.label;const n=e.cwd.split("/").filter(Boolean).pop();return n||((e.ownerPersonaId?t==null?void 0:t(e.ownerPersonaId):void 0)??"")}function uw(e,t){const n=t.trim().toLowerCase();return n===""?!0:e.toLowerCase().includes(n)}function ZP(e){return e.compositionActive||!!e.nativeIsComposing||e.keyCode===229}function QP(e){return e.key==="Enter"&&!e.shiftKey&&!ZP(e)}function SH(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(QP({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}}const kH={isCollapsed:()=>!1,toggle:()=>{},prune:()=>{}};function CH({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:y,showCopyResume:_,treatSessionsAsRoots:x,searchQuery:b}){const[w,S]=g.useState(null),[k,T]=g.useState(()=>new Set),N=p??(R=>k.has(R)),O=g.useCallback(R=>{if(m){m(R);return}T(I=>{const j=new Set(I);return j.has(R)?j.delete(R):j.add(R),j})},[m]),P=g.useMemo(()=>i==null?void 0:i.filter(R=>!R.ephemeral),[i]);if(e.length===0)return h.jsx(EH,{});const L=(b??"").trim();return L?h.jsx(H_.Provider,{value:kH,children:h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(R=>{const I=P?P.filter(F=>F.ownerPersonaId===R.personaId).sort((F,A)=>A.updatedAt>F.updatedAt?1:-1):[],j=uw(R.label,L),B=I.filter(F=>uw(wH(F),L));if(!j&&B.length===0)return null;const $=j?I:B;return h.jsx(dw,{persona:R,active:R.personaId===t,editing:!1,onSelectPersona:n,onSubmitCreateSession:()=>{},onCancelCreateSession:()=>{},personaSessions:$,collapsed:!1,onToggleCollapsed:()=>{},activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:y,showCopyResume:_,treatSessionsAsRoots:x,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f},R.personaId)})})}):h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(R=>{const I=P?P.filter(j=>j.ownerPersonaId===R.personaId).sort((j,B)=>B.updatedAt>j.updatedAt?1:-1):[];return h.jsx(dw,{persona:R,active:R.personaId===t,editing:R.personaId===w,onSelectPersona:n,onStartCreateSession:r?()=>S(R.personaId):void 0,onSubmitCreateSession:j=>{S(null),r==null||r(R.personaId,j)},onCancelCreateSession:()=>S(null),personaSessions:I,collapsed:!N(R.personaId),onToggleCollapsed:()=>O(R.personaId),activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:y,showCopyResume:_,treatSessionsAsRoots:x,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f},R.personaId)})})}function EH(){return h.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-text-400",children:"还没有 persona。点上方 Personas 标题右侧 + 创建第一个。"})}function dw({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:y,onPinSession:_,showCopyResume:x,treatSessionsAsRoots:b,ownerPrincipalId:w,creatorDisplayNameByOwnerId:S}){const k=JP(e.iconKey),T=a.length>0,N=!l,O=g.useMemo(()=>{const R=[],I=new Map;for(const j of a){const B=j.creatorPrincipalId;if(!B||w&&B===w){R.push(j);continue}const $=B,F=(S==null?void 0:S.get($))??`…${$.slice(-8)}`,A=I.get($);A?A.sessions.push(j):I.set($,{groupKey:$,displayName:F,sessions:[j]})}return{self:R,byPeer:[...I.values()]}},[a,w,S]),P=O.byPeer.length>0,L=g.useMemo(()=>N&&!P?YP(XP(a)):[],[N,P,a]);return h.jsxs("div",{"data-testid":`persona-node-${e.personaId}`,children:[h.jsxs("div",{className:se("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:R=>{R.stopPropagation(),c()},"aria-label":N?"collapse":"expand","aria-expanded":N,"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:N?h.jsx(ai,{className:"h-3 w-3"}):h.jsx(li,{className:"h-3 w-3"})}):h.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),h.jsx(k.Component,{className:se("h-3.5 w-3.5 shrink-0",k.colorClass),"aria-hidden":"true"}),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:R=>{R.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(w6,{className:"h-3.5 w-3.5"})}):null]}),n?h.jsx(NH,{personaId:e.personaId,iconKey:e.iconKey,onSubmit:s,onCancel:o}):null,T&&N?h.jsx("div",{"data-testid":`persona-sessions-${e.personaId}`,children:P?h.jsxs(h.Fragment,{children:[O.self.length>0&&h.jsx(hw,{groupKey:`${e.personaId}-self`,label:"我自己",testId:`persona-sessions-${e.personaId}-self`,sessions:O.self,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:y,onPinSession:_,showCopyResume:x}),O.byPeer.map(R=>h.jsx(hw,{groupKey:`${e.personaId}-peer-${R.groupKey}`,label:R.displayName,testId:`persona-sessions-${e.personaId}-peer-${R.groupKey}`,sessions:R.sessions,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:y,onPinSession:_,showCopyResume:x},`${e.personaId}-peer-${R.groupKey}`))]}):L.map(R=>h.jsx(_x,{node:R,depth:b?0:1,activeId:u,unreadIds:p,runningIds:f,awaitingIds:d,onSelect:I=>m==null?void 0:m(I),onDelete:v,onEdit:y,onPin:_,showCopyResume:x},R.session.sessionId))}):null]})}function hw({label:e,testId:t,sessions:n,activeSessionId:r,awaitingIds:i,runningIds:s,unreadIds:o,onSelectSession:a,onDeleteSession:l,onEditSession:c,onPinSession:u,showCopyResume:d}){const[f,p]=g.useState(!1),m=!f,v=g.useMemo(()=>m?YP(XP(n)):[],[m,n]);return h.jsxs("div",{"data-testid":t,children:[h.jsxs("button",{type:"button",onClick:()=>p(y=>!y),"aria-label":m?"collapse":"expand","aria-expanded":m,"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:[m?h.jsx(ai,{className:"h-3 w-3"}):h.jsx(li,{className:"h-3 w-3"}),h.jsx(q_,{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})]}),m&&h.jsx("div",{children:v.map(y=>h.jsx(_x,{node:y,depth:2,activeId:r,unreadIds:o,runningIds:s,awaitingIds:i,onSelect:_=>a==null?void 0:a(_),onDelete:l,onEdit:c,onPin:u,showCopyResume:d},y.session.sessionId))})]})}function NH({personaId:e,iconKey:t,onSubmit:n,onCancel:r}){const[i,s]=g.useState(""),o=g.useRef(null),a=JP(t),l=i.trim(),c=l.length>0;g.useEffect(()=>{var f;(f=o.current)==null||f.focus()},[]);const u=g.useCallback(()=>{c&&n(l)},[c,l,n]),d=SH(u,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(a.Component,{className:se("h-3 w-3 shrink-0",a.colorClass),"aria-hidden":"true"}),h.jsx("input",{ref:o,type:"text",value:i,onChange:f=>s(f.target.value),...d,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:f=>{f.preventDefault(),u()},disabled:!c,"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(nu,{className:"h-3 w-3"})}),h.jsx("button",{type:"button",onMouseDown:f=>{f.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(In,{className:"h-3 w-3"})})]})}function JP(e){const t=tT(e);return t?{Component:t.Icon,colorClass:t.colorClass}:{Component:H6,colorClass:"text-text-400"}}function TH(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function PH(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),r=parseFloat(n.fontSize);return t*r}function RH(e){return e/100*window.innerHeight}function IH(e){return e/100*window.innerWidth}function MH(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 Dl({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=MH(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=PH(t,i);break}case"em":{r=TH(t,i);break}case"vh":{r=RH(i);break}case"vw":{r=IH(i);break}}return r}function En(e){return parseFloat(e.toFixed(3))}function Oa({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 Av(e){const{panels:t}=e,n=Oa({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=Dl({groupSize:n,panelElement:i,styleProp:s.collapsedSize});o=En(u/n*100)}let a;if(s.defaultSize!==void 0){const u=Dl({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=En(u/n*100)}let l=0;if(s.minSize!==void 0){const u=Dl({groupSize:n,panelElement:i,styleProp:s.minSize});l=En(u/n*100)}let c=100;if(s.maxSize!==void 0){const u=Dl({groupSize:n,panelElement:i,styleProp:s.maxSize});c=En(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 rt(e,t="Assertion error"){if(!e)throw Error(t)}function jv(e,t){return Array.from(t).sort(e==="horizontal"?AH:jH)}function AH(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function jH(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function eR(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function tR(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 DH({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}=tR(r,o),c=e==="horizontal"?a:l;c<s&&(s=c,i=o)}return rt(i,"No rect found"),i}let td;function LH(){return td===void 0&&(typeof matchMedia=="function"?td=!!matchMedia("(pointer:coarse)").matches:td=!1),td}function nR(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=jv(n,Array.from(t.children).filter(eR).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 y=r.find(_=>_.element===v);if(y){if(f){const _=f.element.getBoundingClientRect(),x=v.getBoundingClientRect();let b;if(l){const w=n==="horizontal"?new DOMRect(_.right,_.top,0,_.height):new DOMRect(_.left,_.bottom,_.width,0),S=n==="horizontal"?new DOMRect(x.left,x.top,0,x.height):new DOMRect(x.left,x.top,x.width,0);switch(p.length){case 0:{b=[w,S];break}case 1:{const k=p[0],T=DH({orientation:n,rects:[_,x],targetRect:k.element.getBoundingClientRect()});b=[k,T===_?S:w];break}default:{b=p;break}}}else p.length?b=p:b=[n==="horizontal"?new DOMRect(_.right,x.top,x.left-_.right,x.height):new DOMRect(x.left,_.bottom,x.width,x.top-_.bottom)];for(const w of b){let S="width"in w?w:w.element.getBoundingClientRect();const k=LH()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(S.width<k){const N=k-S.width;S=new DOMRect(S.x-N/2,S.y,S.width+N,S.height)}if(S.height<k){const N=k-S.height;S=new DOMRect(S.x,S.y-N/2,S.width,S.height+N)}const T=m<=c||m>u;!a&&!T&&o.push({group:e,groupSize:Oa({group:e}),panels:[f,y],separator:"width"in w?void 0:w,rect:S}),a=!1}}l=!1,f=y,p=[]}}else if(v.hasAttribute("data-separator")){v.ariaDisabled!==null&&(a=!0);const y=i.find(_=>_.element===v);y?p.push(y):(f=void 0,p=[])}else l=!0}return o}var os;class rR{constructor(){yy(this,os,{})}addListener(t,n){const r=ll(this,os)[t];return r===void 0?ll(this,os)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=ll(this,os)[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(){by(this,os,{})}removeListener(t,n){const r=ll(this,os)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}os=new WeakMap;let ya={cursorFlags:0,state:"inactive"};const xx=new rR;function po(){return ya}function OH(e){return xx.addListener("change",e)}function BH(e){const t=ya,n={...ya};n.cursorFlags=e,ya=n,xx.emit("change",{prev:t,next:n})}function ba(e){const t=ya;ya=e,xx.emit("change",{prev:t,next:e})}const zH=e=>e,im=()=>{},iR=1,sR=2,oR=4,aR=8,fw=3,pw=12;let nd;function mw(){return nd===void 0&&(nd=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(nd=!0)),nd}function $H({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&&mw()){const s=(e&iR)!==0,o=(e&sR)!==0,a=(e&oR)!==0,l=(e&aR)!==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 mw()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const gw=new WeakMap;function yx(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=gw.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=po();switch(r.state){case"active":case"hover":{const i=$H({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}}gw.set(e,{prevStyle:t,styleSheet:n})}let Yr=new Map;const lR=new rR;function FH(e){Yr=new Map(Yr),Yr.delete(e)}function vw(e,t){for(const[n]of Yr)if(n.id===e)return n}function xs(e,t){for(const[n,r]of Yr)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Po(){return Yr}function bx(e,t){return lR.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function ji(e,t,n){const r=Yr.get(e);Yr=new Map(Yr),Yr.set(e,t),lR.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:r,next:t})}function cR(e){const t=po();let n=!1;switch(t.state){case"active":ba({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(yx(e),n=!0,t.hitRegions.forEach(r=>{const i=xs(r.group.id,!0);ji(r.group,i,{isUserInteraction:!0})}))}return n}function _w(e){e.defaultPrevented||cR(e.currentTarget)}function HH(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const o=tR(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 UH(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function WH(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:bw(e),b:bw(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();rt(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:yw(xw(n.a)),b:yw(xw(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 VH=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function qH(e){const t=getComputedStyle(uR(e)??e).display;return t==="flex"||t==="inline-flex"}function KH(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||qH(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"||VH.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function xw(e){let t=e.length;for(;t--;){const n=e[t];if(rt(n,"Missing node"),KH(n))return n}return null}function yw(e){return e&&Number(getComputedStyle(e).zIndex)||0}function bw(e){const t=[];for(;e;)t.push(e),e=uR(e);return t}function uR(e){const{parentNode:t}=e;return UH(t)?t.host:t}function GH(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 XH({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!eR(n)||n.contains(e)||e.contains(n))return!0;if(WH(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(GH(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function wx(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=nR(i),o=HH(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&XH({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function YH(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 _n(e,t,n=0){return Math.abs(En(e)-En(t))<=n}function qr(e,t){return _n(e,t)?0:e>t?1:-1}function ca({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(qr(r,l)<0)if(s){const c=(i+l)/2;qr(r,c)<0?r=i:r=l}else r=l;return r=Math.min(a,r),r=En(r),r}function Bc({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(_n(e,0))return t;const o=s==="imperative-api",a=Object.values(t),l=Object.values(i),c=[...a],[u,d]=r;rt(u!=null,"Invalid first pivot index"),rt(d!=null,"Invalid second pivot index");let f=0;switch(s){case"keyboard":{{const v=e<0?d:u,y=n[v];rt(y,`Panel constraints not found for index ${v}`);const{collapsedSize:_=0,collapsible:x,minSize:b=0}=y;if(x){const w=a[v];if(rt(w!=null,`Previous layout not found for panel index ${v}`),_n(w,_)){const S=b-w;qr(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}{const v=e<0?u:d,y=n[v];rt(y,`No panel constraints found for index ${v}`);const{collapsedSize:_=0,collapsible:x,minSize:b=0}=y;if(x){const w=a[v];if(rt(w!=null,`Previous layout not found for panel index ${v}`),_n(w,b)){const S=w-_;qr(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}break}default:{const v=e<0?d:u,y=n[v];rt(y,`Panel constraints not found for index ${v}`);const _=a[v],{collapsible:x,collapsedSize:b,minSize:w}=y;if(x&&qr(_,w)<0)if(e>0){const S=w-b,k=S/2,T=_+e;qr(T,w)<0&&(e=qr(e,k)<=0?0:S)}else{const S=w-b,k=100-S/2,T=_-e;qr(T,w)<0&&(e=qr(100+e,k)>0?0:-S)}break}}{const v=e<0?1:-1;let y=e<0?d:u,_=0;for(;;){const b=a[y];rt(b!=null,`Previous layout not found for panel index ${y}`);const w=ca({overrideDisabledPanels:o,panelConstraints:n[y],prevSize:b,size:100})-b;if(_+=w,y+=v,y<0||y>=n.length)break}const x=Math.min(Math.abs(e),Math.abs(_));e=e<0?0-x:x}{let v=e<0?u:d;for(;v>=0&&v<n.length;){const y=Math.abs(e)-Math.abs(f),_=a[v];rt(_!=null,`Previous layout not found for panel index ${v}`);const x=_-y,b=ca({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:_,size:x});if(!_n(_,b)&&(f+=_-b,c[v]=b,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?v--:v++}}if(YH(l,c))return i;{const v=e<0?d:u,y=a[v];rt(y!=null,`Previous layout not found for panel index ${v}`);const _=y+f,x=ca({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:y,size:_});if(c[v]=x,!_n(x,_)){let b=_-x,w=e<0?d:u;for(;w>=0&&w<n.length;){const S=c[w];rt(S!=null,`Previous layout not found for panel index ${w}`);const k=S+b,T=ca({overrideDisabledPanels:o,panelConstraints:n[w],prevSize:S,size:k});if(_n(S,T)||(b-=T-S,c[w]=T),_n(b,0))break;e>0?w--:w++}}}const p=Object.values(c).reduce((v,y)=>y+v,0);if(!_n(p,100,.1))return i;const m=Object.keys(i);return c.reduce((v,y,_)=>(v[m[_]]=y,v),{})}function mo(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||qr(e[n],t[n])!==0)return!1;return!0}function go({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(!_n(i,100)&&r.length>0)for(let a=0;a<t.length;a++){const l=r[a];rt(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];rt(l!=null,`No layout data found for index ${a}`);const c=r[a];rt(c!=null,`No layout data found for index ${a}`);const u=ca({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});c!=u&&(s+=c-u,r[a]=u)}if(!_n(s,0))for(let a=0;a<t.length;a++){const l=r[a];rt(l!=null,`No layout data found for index ${a}`);const c=l+s,u=ca({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});if(l!==u&&(s-=u-l,r[a]=u,_n(s,0)))break}const o=Object.keys(e);return r.reduce((a,l,c)=>(a[o[c]]=l,a),{})}function dR({groupId:e,panelId:t}){const n=()=>{const l=Po();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(y=>y.id===t),m=p===0,v=p===c.length-1;if(v&&l<f&&(m||c.slice(0,p).every((y,_)=>{const x=d[_];return(x==null?void 0:x.collapsible)&&_n(x.collapsedSize,u[x.panelId])}))){const y=c.slice(0,p).reduce((_,x)=>_+u[x.id],0);return{...u,[t]:En(100-y)}}return Bc({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(),y=o({nextSize:l,panels:f.panels,prevLayout:m,derivedPanelConstraints:d}),_=go({layout:y,panelConstraints:d});mo(m,_)||ji(f,{defaultLayoutDeferred:u,derivedPanelConstraints:d,groupSize:p,layout:_,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&&_n(c,u)},resize:l=>{const{group:c}=n(),{element:u}=i(),d=Oa({group:c}),f=Dl({groupSize:d,panelElement:u,styleProp:l}),p=En(f/d*100);a(p)}}}function ww(e){if(e.defaultPrevented)return;const t=Po();wx(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=dR({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function Ad(e){const t=Po();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 hR({groupId:e}){const t=()=>{const n=Po();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=go({layout:n,panelConstraints:i});return r?a:(mo(a,c)||ji(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:o,layout:c,separatorToPanels:l}),c)}}}function Os(e,t){const n=Ad(e),r=xs(n.id,!0),i=n.separators.find(u=>u.element===e);rt(i,"Matching separator not found");const s=r.separatorToPanels.get(i);rt(s,"Matching panels not found");const o=s.map(u=>n.panels.indexOf(u)),a=hR({groupId:n.id}).getLayout(),l=Bc({delta:t,initialLayout:a,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),c=go({layout:l,panelConstraints:r.derivedPanelConstraints});mo(a,c)||ji(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function Sw(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=Ad(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Os(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Os(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Os(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Os(t,-5);break}case"End":{e.preventDefault(),Os(t,100);break}case"Enter":{e.preventDefault();const r=Ad(t),i=xs(r.id,!0),{derivedPanelConstraints:s,layout:o,separatorToPanels:a}=i,l=r.separators.find(f=>f.element===t);rt(l,"Matching separator not found");const c=a.get(l);rt(c,"Matching panels not found");const u=c[0],d=s.find(f=>f.panelId===u.id);if(rt(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;Os(t,p-f)}break}case"F6":{e.preventDefault();const r=Ad(t).separators.map(o=>o.element),i=Array.from(r).findIndex(o=>o===e.currentTarget);rt(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(),Os(t,-100);break}}}function kw(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=Po(),n=wx(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 fR({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 y=r.get(u),_=i.get(u);if(!y||!_)return;const{defaultLayoutDeferred:x,derivedPanelConstraints:b,groupSize:w,layout:S,separatorToPanels:k}=_;if(b&&S&&k){const T=Bc({delta:v,initialLayout:y,panelConstraints:b,pivotIndices:c.panels.map(N=>p.indexOf(N)),prevLayout:S,trigger:"mouse-or-touch"});if(mo(T,S)){if(v!==0&&!m)switch(f){case"horizontal":{a|=v<0?iR:sR;break}case"vertical":{a|=v<0?oR:aR;break}}}else ji(c.group,{defaultLayoutDeferred:x,derivedPanelConstraints:b,groupSize:w,layout:T,separatorToPanels:k})}});let l=0;t.movementX===0?l|=o&fw:l|=a&fw,t.movementY===0?l|=o&pw:l|=a&pw,BH(l),yx(e)}function Cw(e){const t=Po(),n=po();switch(n.state){case"active":fR({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function Ew(e){var r,i;if(e.defaultPrevented)return;const t=po(),n=Po();switch(t.state){case"active":{if(e.buttons===0){ba({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const o=xs(s.group.id,!0);ji(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))}fR({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=wx(e,n);s.length===0?t.state!=="inactive"&&ba({cursorFlags:0,state:"inactive"}):ba({cursorFlags:0,hitRegions:s,state:"hover"}),yx(e.currentTarget);break}}}function Nw(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(po().state){case"hover":ba({cursorFlags:0,state:"inactive"})}}function Tw(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||cR(e.currentTarget)&&e.preventDefault()}function Pw(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const o=En(s.defaultSize);n+=o,r[s.panelId]=o}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=En((100-n)/i);for(const o of e)o.defaultSize===void 0&&(r[o.panelId]=s)}return r}function ZH(e,t,n){if(!n[0])return;const r=e.panels.find(l=>l.element===t);if(!r||!r.onResize)return;const i=Oa({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,a={asPercentage:En(s/i*100),inPixels:s};r.mutableValues.prevSize=a,r.onResize(a,r.id,o)}function QH(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 JH({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=En(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]=En(f/s*c)}else{const d=En(c/l.length);for(const f of l)u[f]=d}return u}function e7(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 Ho=new Map;function t7(e){let t=!0;rt(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:y,target:_}=v;if(_===e.element){if(t){const x=Oa({group:e});if(x===0)return;const b=xs(e.id);if(!b)return;const w=Av(e),S=b.defaultLayoutDeferred?Pw(w):b.layout,k=JH({group:e,nextGroupSize:x,prevGroupSize:b.groupSize,prevLayout:S}),T=go({layout:k,panelConstraints:w});if(!b.defaultLayoutDeferred&&mo(b.layout,T)&&QH(b.derivedPanelConstraints,w)&&b.groupSize===x)return;ji(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:w,groupSize:x,layout:T,separatorToPanels:b.separatorToPanels})}}else ZH(e,_,y)}});s.observe(e.element),e.panels.forEach(m=>{rt(!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=Oa({group:e}),a=Av(e),l=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(e7(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[l]??c??Pw(a),d=go({layout:u,panelConstraints:a}),f=e.element.ownerDocument;Ho.set(f,(Ho.get(f)??0)+1);const p=new Map;return nR(e).forEach(m=>{m.separator&&p.set(m.separator,m.panels)}),ji(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:a,groupSize:o,layout:d,separatorToPanels:p}),e.separators.forEach(m=>{rt(!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",Sw)}),Ho.get(f)===1&&(f.addEventListener("contextmenu",_w,!0),f.addEventListener("dblclick",ww,!0),f.addEventListener("pointerdown",kw,!0),f.addEventListener("pointerleave",Cw),f.addEventListener("pointermove",Ew),f.addEventListener("pointerout",Nw),f.addEventListener("pointerup",Tw,!0)),function(){t=!1,Ho.set(f,Math.max(0,(Ho.get(f)??0)-1)),FH(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",Sw)}),Ho.get(f)||(f.removeEventListener("contextmenu",_w,!0),f.removeEventListener("dblclick",ww,!0),f.removeEventListener("pointerdown",kw,!0),f.removeEventListener("pointerleave",Cw),f.removeEventListener("pointermove",Ew),f.removeEventListener("pointerout",Nw),f.removeEventListener("pointerup",Tw,!0)),s.disconnect()}}function n7(){const[e,t]=g.useState({}),n=g.useCallback(()=>t({}),[]);return[e,n]}function Sx(e){const t=g.useId();return`${e??t}`}const Ro=typeof window<"u"?g.useLayoutEffect:g.useEffect;function tc(e){const t=g.useRef(e);return Ro(()=>{t.current=e},[e]),g.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function kx(...e){return tc(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function Cx(e){const t=g.useRef({...e});return Ro(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const pR=g.createContext(null);function r7(e,t){const n=g.useRef({getLayout:()=>({}),setLayout:zH});g.useImperativeHandle(t,()=>n.current,[]),Ro(()=>{Object.assign(n.current,hR({groupId:e}))})}function Ex({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=tc(L=>{mo(m.current.onLayoutChange,L)||(m.current.onLayoutChange=L,l==null||l(L))}),y=tc((L,R)=>{mo(m.current.onLayoutChanged,L)||(m.current.onLayoutChanged=L,c==null||c(L,{isUserInteraction:R}))}),_=Sx(a),x=g.useRef(null),[b,w]=n7(),S=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),k=kx(x,s);r7(_,o);const T=tc((L,R)=>{const I=po(),j=vw(L),B=xs(L);if(B){let $=!1;switch(I.state){case"active":{$=I.hitRegions.some(F=>F.group===j);break}}return{flexGrow:B.layout[R]??1,pointerEvents:$?"none":void 0}}if(n!=null&&n[R])return{flexGrow:n==null?void 0:n[R]}}),N=Cx({defaultLayout:n,disableCursor:r}),O=g.useMemo(()=>({get disableCursor(){return!!N.disableCursor},getPanelStyles:T,id:_,orientation:u,registerPanel:L=>{const R=S.current;return R.panels=jv(u,[...R.panels,L]),w(),()=>{R.panels=R.panels.filter(I=>I!==L),w()}},registerSeparator:L=>{const R=S.current;return R.separators=jv(u,[...R.separators,L]),w(),()=>{R.separators=R.separators.filter(I=>I!==L),w()}},updatePanelProps:(L,{disabled:R})=>{const I=S.current.panels.find($=>$.id===L);I&&(I.panelConstraints.disabled=R);const j=vw(_),B=xs(_);j&&B&&ji(j,{...B,derivedPanelConstraints:Av(j)})},updateSeparatorProps:(L,{disabled:R,disableDoubleClick:I})=>{const j=S.current.separators.find(B=>B.id===L);j&&(j.disabled=R,j.disableDoubleClick=I)}}),[T,_,w,u,N]),P=g.useRef(null);return Ro(()=>{const L=x.current;if(L===null)return;const R=S.current;let I;if(N.defaultLayout!==void 0&&Object.keys(N.defaultLayout).length===R.panels.length){I={};for(const C of R.panels){const H=N.defaultLayout[C.id];H!==void 0&&(I[C.id]=H)}}const j={disabled:!!i,element:L,id:_,mutableState:{defaultLayout:I,disableCursor:!!N.disableCursor,expandedPanelSizes:S.current.lastExpandedPanelSizes,layouts:S.current.layouts},orientation:u,panels:R.panels,resizeTargetMinimumSize:R.resizeTargetMinimumSize,separators:R.separators};P.current=j;const B=t7(j),{defaultLayoutDeferred:$,derivedPanelConstraints:F,layout:A}=xs(j.id,!0);!$&&F.length>0&&(v(A),y(A,!1));const D=bx(_,C=>{const{defaultLayoutDeferred:H,derivedPanelConstraints:q,layout:M}=C.next;if(H||q.length===0)return;const ne=j.panels.map(({id:V})=>V).join(",");j.mutableState.layouts[ne]=M,q.forEach(V=>{if(V.collapsible){const{layout:pe}=C.prev??{};if(pe){const Oe=_n(V.collapsedSize,M[V.panelId]),re=_n(V.collapsedSize,pe[V.panelId]);Oe&&!re&&(j.mutableState.expandedPanelSizes[V.panelId]=pe[V.panelId])}}});const oe=po().state!=="active";v(M),oe&&y(M,C.isUserInteraction)});return()=>{P.current=null,B(),D()}},[i,_,y,v,u,b,N]),g.useEffect(()=>{const L=P.current;L&&(L.mutableState.defaultLayout=n,L.mutableState.disableCursor=!!r)}),h.jsx(pR.Provider,{value:O,children:h.jsx("div",{...p,className:t,"data-group":!0,"data-testid":_,id:_,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})})}Ex.displayName="Group";function Nx(){const e=g.useContext(pR);return rt(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function i7(e,t){const{id:n}=Nx(),r=g.useRef({collapse:im,expand:im,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:im});g.useImperativeHandle(t,()=>r.current,[]),Ro(()=>{Object.assign(r.current,dR({groupId:n,panelId:e}))})}function zc({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,y=Sx(l),_=Cx({disabled:s}),x=g.useRef(null),b=kx(x,o),{getPanelStyles:w,id:S,orientation:k,registerPanel:T,updatePanelProps:N}=Nx(),O=d!==null,P=tc((j,B,$)=>{d==null||d(j,l,$)});Ro(()=>{const j=x.current;if(j!==null){const B={element:j,id:y,idIsStable:v,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:O?P:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:c,minSize:u}};return T(B)}},[a,n,r,i,O,y,v,c,u,P,T,_]),g.useEffect(()=>{N(y,{disabled:s})},[s,y,N]),i7(y,f);const L=()=>{const j=w(S,y);if(j)return JSON.stringify(j)},R=g.useSyncExternalStore(j=>bx(S,j),L,L);let I;return R?I=JSON.parse(R):i!==void 0?I={flexGrow:void 0,flexShrink:void 0,flexBasis:i}:I={flexGrow:1},h.jsx("div",{...m,"data-disabled":s||void 0,"data-panel":!0,"data-testid":y,id:y,ref:b,style:{...s7,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...I},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})})}zc.displayName="Panel";const s7={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function o7({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=go({layout:Bc({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=go({layout:Bc({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:o}}function Tx({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:s,style:o,...a}){const l=Sx(s),c=Cx({disabled:n,disableDoubleClick:r}),[u,d]=g.useState({}),[f,p]=g.useState("inactive"),[m,v]=g.useState(!1),y=g.useRef(null),_=kx(y,i),{disableCursor:x,id:b,orientation:w,registerSeparator:S,updateSeparatorProps:k}=Nx(),T=w==="horizontal"?"vertical":"horizontal";Ro(()=>{const P=y.current;if(P!==null){const L={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:P,id:l},R=S(L),I=OH(B=>{p(B.next.state!=="inactive"&&B.next.hitRegions.some($=>$.separator===L)?B.next.state:"inactive")}),j=bx(b,B=>{const{derivedPanelConstraints:$,layout:F,separatorToPanels:A}=B.next,D=A.get(L);if(D){const C=D[0],H=D.indexOf(C);d(o7({layout:F,panelConstraints:$,panelId:C.id,panelIndex:H}))}});return()=>{I(),j(),R()}}},[b,l,S,c]),g.useEffect(()=>{k(l,{disabled:n,disableDoubleClick:r})},[n,r,l,k]);let N;n&&!x&&(N="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":T,"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:_,role:"separator",style:{flexBasis:"auto",cursor:N,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}Tx.displayName="Separator";function a7(e,t,n){const r=g.useRef({sid:null,tsid:void 0});g.useEffect(()=>{const i=r.current;r.current={sid:t,tsid:n},!(!n||i.sid===t&&(i.tsid===void 0||i.tsid===null)&&typeof n=="string")&&e.sessionObserve({sessionId:t,toolSessionId:n}).catch(()=>{})},[e,t,n])}function l7(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 c7=/^Scheduled (?:recurring job|one-shot task) ([0-9a-f]{8}) \(([^)]+)\)/;function u7(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(c7);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 d7=["TaskCreate","TaskUpdate","TaskList","TaskGet"];function h7(e){return d7.includes(e)}function mR(e){return e==="in_progress"||e==="completed"?e:"pending"}function f7(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:mR(n.status),activeForm:i,description:s}]}function p7(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=mR(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 m7(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=f7(t,i.input);break;case"TaskUpdate":t=p7(t,i.input);break}}return{tasks:t,lastEventIndex:n}}function g7(e){const{tasks:t,lastEventIndex:n}=m7(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;const d={agentId:u.agentId,status:u.status};u.description?d.description=u.description:(f=c.progress)!=null&&f.description&&(d.description=c.progress.description),u.lastToolName?d.lastToolName=u.lastToolName:(p=c.progress)!=null&&p.lastToolName&&(d.lastToolName=c.progress.lastToolName),u.stats?d.stats=u.stats:(m=c.progress)!=null&&m.stats&&(d.stats=c.progress.stats),c.progress=d};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}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 v7=/<(system-reminder|related-dir|clawd-shift-fire)\b[^>]*>[\s\S]*?<\/\1>/gi,_7=/<builder-preview\b[^>]*\/>/gi;function gR(e){return e?e.replace(v7,"").replace(_7,"").trim():""}const x7=gR;function y7(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const b7=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,w7=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,S7={};function Rw(e,t){return(S7.jsx?w7:b7).test(e)}const k7=/[ \t\n\f\r]/g;function C7(e){return typeof e=="object"?e.type==="text"?Iw(e.value):!1:Iw(e)}function Iw(e){return e.replace(k7,"")===""}class lu{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}lu.prototype.normal={};lu.prototype.property={};lu.prototype.space=void 0;function vR(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new lu(n,r,t)}function Dv(e){return e.toLowerCase()}class Vn{constructor(t,n){this.attribute=n,this.property=t}}Vn.prototype.attribute="";Vn.prototype.booleanish=!1;Vn.prototype.boolean=!1;Vn.prototype.commaOrSpaceSeparated=!1;Vn.prototype.commaSeparated=!1;Vn.prototype.defined=!1;Vn.prototype.mustUseProperty=!1;Vn.prototype.number=!1;Vn.prototype.overloadedBoolean=!1;Vn.prototype.property="";Vn.prototype.spaceSeparated=!1;Vn.prototype.space=void 0;let E7=0;const Pe=Io(),Mt=Io(),Lv=Io(),X=Io(),lt=Io(),wa=Io(),Xn=Io();function Io(){return 2**++E7}const Ov=Object.freeze(Object.defineProperty({__proto__:null,boolean:Pe,booleanish:Mt,commaOrSpaceSeparated:Xn,commaSeparated:wa,number:X,overloadedBoolean:Lv,spaceSeparated:lt},Symbol.toStringTag,{value:"Module"})),sm=Object.keys(Ov);class Px extends Vn{constructor(t,n,r,i){let s=-1;if(super(t,n),Mw(this,"space",i),typeof r=="number")for(;++s<sm.length;){const o=sm[s];Mw(this,sm[s],(r&Ov[o])===Ov[o])}}}Px.prototype.defined=!0;function Mw(e,t,n){n&&(e[t]=n)}function Qa(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Px(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Dv(r)]=r,n[Dv(s.attribute)]=r}return new lu(t,n,e.space)}const _R=Qa({properties:{ariaActiveDescendant:null,ariaAtomic:Mt,ariaAutoComplete:null,ariaBusy:Mt,ariaChecked:Mt,ariaColCount:X,ariaColIndex:X,ariaColSpan:X,ariaControls:lt,ariaCurrent:null,ariaDescribedBy:lt,ariaDetails:null,ariaDisabled:Mt,ariaDropEffect:lt,ariaErrorMessage:null,ariaExpanded:Mt,ariaFlowTo:lt,ariaGrabbed:Mt,ariaHasPopup:null,ariaHidden:Mt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:lt,ariaLevel:X,ariaLive:null,ariaModal:Mt,ariaMultiLine:Mt,ariaMultiSelectable:Mt,ariaOrientation:null,ariaOwns:lt,ariaPlaceholder:null,ariaPosInSet:X,ariaPressed:Mt,ariaReadOnly:Mt,ariaRelevant:null,ariaRequired:Mt,ariaRoleDescription:lt,ariaRowCount:X,ariaRowIndex:X,ariaRowSpan:X,ariaSelected:Mt,ariaSetSize:X,ariaSort:null,ariaValueMax:X,ariaValueMin:X,ariaValueNow:X,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function xR(e,t){return t in e?e[t]:t}function yR(e,t){return xR(e,t.toLowerCase())}const N7=Qa({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:wa,acceptCharset:lt,accessKey:lt,action:null,allow:null,allowFullScreen:Pe,allowPaymentRequest:Pe,allowUserMedia:Pe,alt:null,as:null,async:Pe,autoCapitalize:null,autoComplete:lt,autoFocus:Pe,autoPlay:Pe,blocking:lt,capture:null,charSet:null,checked:Pe,cite:null,className:lt,cols:X,colSpan:null,content:null,contentEditable:Mt,controls:Pe,controlsList:lt,coords:X|wa,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Pe,defer:Pe,dir:null,dirName:null,disabled:Pe,download:Lv,draggable:Mt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Pe,formTarget:null,headers:lt,height:X,hidden:Lv,high:X,href:null,hrefLang:null,htmlFor:lt,httpEquiv:lt,id:null,imageSizes:null,imageSrcSet:null,inert:Pe,inputMode:null,integrity:null,is:null,isMap:Pe,itemId:null,itemProp:lt,itemRef:lt,itemScope:Pe,itemType:lt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Pe,low:X,manifest:null,max:null,maxLength:X,media:null,method:null,min:null,minLength:X,multiple:Pe,muted:Pe,name:null,nonce:null,noModule:Pe,noValidate:Pe,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:Pe,optimum:X,pattern:null,ping:lt,placeholder:null,playsInline:Pe,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Pe,referrerPolicy:null,rel:lt,required:Pe,reversed:Pe,rows:X,rowSpan:X,sandbox:lt,scope:null,scoped:Pe,seamless:Pe,selected:Pe,shadowRootClonable:Pe,shadowRootDelegatesFocus:Pe,shadowRootMode:null,shape:null,size:X,sizes:null,slot:null,span:X,spellCheck:Mt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:X,step:null,style:null,tabIndex:X,target:null,title:null,translate:null,type:null,typeMustMatch:Pe,useMap:null,value:Mt,width:X,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:lt,axis:null,background:null,bgColor:null,border:X,borderColor:null,bottomMargin:X,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Pe,declare:Pe,event:null,face:null,frame:null,frameBorder:null,hSpace:X,leftMargin:X,link:null,longDesc:null,lowSrc:null,marginHeight:X,marginWidth:X,noResize:Pe,noHref:Pe,noShade:Pe,noWrap:Pe,object:null,profile:null,prompt:null,rev:null,rightMargin:X,rules:null,scheme:null,scrolling:Mt,standby:null,summary:null,text:null,topMargin:X,valueType:null,version:null,vAlign:null,vLink:null,vSpace:X,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Pe,disableRemotePlayback:Pe,prefix:null,property:null,results:X,security:null,unselectable:null},space:"html",transform:yR}),T7=Qa({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:Xn,accentHeight:X,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:X,amplitude:X,arabicForm:null,ascent:X,attributeName:null,attributeType:null,azimuth:X,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:X,by:null,calcMode:null,capHeight:X,className:lt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:X,diffuseConstant:X,direction:null,display:null,dur:null,divisor:X,dominantBaseline:null,download:Pe,dx:null,dy:null,edgeMode:null,editable:null,elevation:X,enableBackground:null,end:null,event:null,exponent:X,externalResourcesRequired:null,fill:null,fillOpacity:X,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:wa,g2:wa,glyphName:wa,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:X,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:X,horizOriginX:X,horizOriginY:X,id:null,ideographic:X,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:X,k:X,k1:X,k2:X,k3:X,k4:X,kernelMatrix:Xn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:X,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:X,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:X,overlineThickness:X,paintOrder:null,panose1:null,path:null,pathLength:X,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:lt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:X,pointsAtY:X,pointsAtZ:X,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Xn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Xn,rev:Xn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Xn,requiredFeatures:Xn,requiredFonts:Xn,requiredFormats:Xn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:X,specularExponent:X,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:X,strikethroughThickness:X,string:null,stroke:null,strokeDashArray:Xn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:X,strokeOpacity:X,strokeWidth:null,style:null,surfaceScale:X,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Xn,tabIndex:X,tableValues:null,target:null,targetX:X,targetY:X,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Xn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:X,underlineThickness:X,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:X,values:null,vAlphabetic:X,vMathematical:X,vectorEffect:null,vHanging:X,vIdeographic:X,version:null,vertAdvY:X,vertOriginX:X,vertOriginY:X,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:X,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:xR}),bR=Qa({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()}}),wR=Qa({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:yR}),SR=Qa({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),P7={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"},R7=/[A-Z]/g,Aw=/-[a-z]/g,I7=/^data[-\w.:]+$/i;function M7(e,t){const n=Dv(t);let r=t,i=Vn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&I7.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(Aw,j7);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!Aw.test(s)){let o=s.replace(R7,A7);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=Px}return new i(r,t)}function A7(e){return"-"+e.toLowerCase()}function j7(e){return e.charAt(1).toUpperCase()}const D7=vR([_R,N7,bR,wR,SR],"html"),Rx=vR([_R,T7,bR,wR,SR],"svg");function L7(e){return e.join(" ").trim()}var Ix={},jw=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,O7=/\n/g,B7=/^\s*/,z7=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,$7=/^:\s*/,F7=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,H7=/^[;\s]*/,U7=/^\s+|\s+$/g,W7=`
|
|
485
|
+
`)},k8=0,Fo=[];function C8(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState(k8++)[0],s=g.useState(qT)[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=qF([e.lockRef.current],(e.shards||[]).map(lw),!0).filter(Boolean);return v.forEach(function(y){return y.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),v.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(v,y){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var _=ed(v),x=n.current,b="deltaX"in v?v.deltaX:x[0]-_[0],w="deltaY"in v?v.deltaY:x[1]-_[1],S,k=v.target,T=Math.abs(b)>Math.abs(w)?"h":"v";if("touches"in v&&T==="h"&&k.type==="range")return!1;var N=window.getSelection(),O=N&&N.anchorNode,P=O?O===k||O.contains(k):!1;if(P)return!1;var L=ow(T,k);if(!L)return!0;if(L?S=T:(S=T==="v"?"h":"v",L=ow(T,k)),!L)return!1;if(!r.current&&"changedTouches"in v&&(b||w)&&(r.current=S),!S)return!0;var R=r.current||S;return b8(R,y,v,R==="h"?b:w)},[]),l=g.useCallback(function(v){var y=v;if(!(!Fo.length||Fo[Fo.length-1]!==s)){var _="deltaY"in y?aw(y):ed(y),x=t.current.filter(function(S){return S.name===y.type&&(S.target===y.target||y.target===S.shadowParent)&&w8(S.delta,_)})[0];if(x&&x.should){y.cancelable&&y.preventDefault();return}if(!x){var b=(o.current.shards||[]).map(lw).filter(Boolean).filter(function(S){return S.contains(y.target)}),w=b.length>0?a(y,b[0]):!o.current.noIsolation;w&&y.cancelable&&y.preventDefault()}}},[]),c=g.useCallback(function(v,y,_,x){var b={name:v,delta:y,target:_,should:x,shadowParent:E8(_)};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(w){return w!==b})},1)},[]),u=g.useCallback(function(v){n.current=ed(v),r.current=void 0},[]),d=g.useCallback(function(v){c(v.type,aw(v),v.target,a(v,e.lockRef.current))},[]),f=g.useCallback(function(v){c(v.type,ed(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return Fo.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,$o),document.addEventListener("touchmove",l,$o),document.addEventListener("touchstart",u,$o),function(){Fo=Fo.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,$o),document.removeEventListener("touchmove",l,$o),document.removeEventListener("touchstart",u,$o)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(s,{styles:S8(i)}):null,p?g.createElement(p8,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function E8(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const N8=t8(VT,C8);var sx=g.forwardRef(function(e,t){return g.createElement($f,Gr({},e,{ref:t,sideCar:N8}))});sx.classNames=$f.classNames;var Rv=["Enter"," "],T8=["ArrowDown","PageUp","Home"],YT=["ArrowUp","PageDown","End"],P8=[...T8,...YT],R8={ltr:[...Rv,"ArrowRight"],rtl:[...Rv,"ArrowLeft"]},I8={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ou="Menu",[Dc,M8,A8]=iT(ou),[No,ZT]=Eo(ou,[A8,zf,LT]),Ff=zf(),QT=LT(),[j8,To]=No(ou),[D8,au]=No(ou),JT=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=Ff(t),[l,c]=g.useState(null),u=g.useRef(!1),d=Ii(s),f=sT(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(IT,{...a,children:h.jsx(j8,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(D8,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};JT.displayName=ou;var L8="MenuAnchor",ox=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Ff(n);return h.jsx(MT,{...i,...r,ref:t})});ox.displayName=L8;var ax="MenuPortal",[O8,eP]=No(ax,{forceMount:void 0}),tP=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=To(ax,t);return h.jsx(O8,{scope:t,forceMount:n,children:h.jsx(zi,{present:n||s.open,children:h.jsx(ix,{asChild:!0,container:i,children:r})})})};tP.displayName=ax;var vr="MenuContent",[B8,lx]=No(vr),nP=g.forwardRef((e,t)=>{const n=eP(vr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=To(vr,e.__scopeMenu),o=au(vr,e.__scopeMenu);return h.jsx(Dc.Provider,{scope:e.__scopeMenu,children:h.jsx(zi,{present:r||s.open,children:h.jsx(Dc.Slot,{scope:e.__scopeMenu,children:o.modal?h.jsx(z8,{...i,ref:t}):h.jsx($8,{...i,ref:t})})})})}),z8=g.forwardRef((e,t)=>{const n=To(vr,e.__scopeMenu),r=g.useRef(null),i=qt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return HT(s)},[]),h.jsx(cx,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Te(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),$8=g.forwardRef((e,t)=>{const n=To(vr,e.__scopeMenu);return h.jsx(cx,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),F8=Ac("MenuContent.ScrollLock"),cx=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,y=To(vr,n),_=au(vr,n),x=Ff(n),b=QT(n),w=M8(n),[S,k]=g.useState(null),T=g.useRef(null),N=qt(t,T,y.onContentChange),O=g.useRef(0),P=g.useRef(""),L=g.useRef(0),R=g.useRef(null),I=g.useRef("right"),j=g.useRef(0),B=m?sx:g.Fragment,$=m?{as:F8,allowPinchZoom:!0}:void 0,F=D=>{var pe,Oe;const C=P.current+D,H=w().filter(re=>!re.disabled),q=document.activeElement,M=(pe=H.find(re=>re.ref.current===q))==null?void 0:pe.textValue,ne=H.map(re=>re.textValue),oe=J8(ne,C,M),V=(Oe=H.find(re=>re.textValue===oe))==null?void 0:Oe.ref.current;(function re(Me){P.current=Me,window.clearTimeout(O.current),Me!==""&&(O.current=window.setTimeout(()=>re(""),1e3))})(C),V&&setTimeout(()=>V.focus())};g.useEffect(()=>()=>window.clearTimeout(O.current),[]),lT();const A=g.useCallback(D=>{var H,q;return I.current===((H=R.current)==null?void 0:H.side)&&t9(D,(q=R.current)==null?void 0:q.area)},[]);return h.jsx(B8,{scope:n,searchRef:P,onItemEnter:g.useCallback(D=>{A(D)&&D.preventDefault()},[A]),onItemLeave:g.useCallback(D=>{var C;A(D)||((C=T.current)==null||C.focus(),k(null))},[A]),onTriggerLeave:g.useCallback(D=>{A(D)&&D.preventDefault()},[A]),pointerGraceTimerRef:L,onPointerGraceIntentChange:g.useCallback(D=>{R.current=D},[]),children:h.jsx(B,{...$,children:h.jsx(X_,{asChild:!0,trapped:i,onMountAutoFocus:Te(s,D=>{var C;D.preventDefault(),(C=T.current)==null||C.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:h.jsx(jf,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(FF,{asChild:!0,...b,dir:_.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:k,onEntryFocus:Te(l,D=>{_.isUsingKeyboardRef.current||D.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(AT,{role:"menu","aria-orientation":"vertical","data-state":_P(y.open),"data-radix-menu-content":"",dir:_.dir,...x,...v,ref:N,style:{outline:"none",...v.style},onKeyDown:Te(v.onKeyDown,D=>{const H=D.target.closest("[data-radix-menu-content]")===D.currentTarget,q=D.ctrlKey||D.altKey||D.metaKey,M=D.key.length===1;H&&(D.key==="Tab"&&D.preventDefault(),!q&&M&&F(D.key));const ne=T.current;if(D.target!==ne||!P8.includes(D.key))return;D.preventDefault();const V=w().filter(pe=>!pe.disabled).map(pe=>pe.ref.current);YT.includes(D.key)&&V.reverse(),Z8(V)}),onBlur:Te(e.onBlur,D=>{D.currentTarget.contains(D.target)||(window.clearTimeout(O.current),P.current="")}),onPointerMove:Te(e.onPointerMove,Lc(D=>{const C=D.target,H=j.current!==D.clientX;if(D.currentTarget.contains(C)&&H){const q=D.clientX>j.current?"right":"left";I.current=q,j.current=D.clientX}}))})})})})})})});nP.displayName=vr;var H8="MenuGroup",ux=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{role:"group",...r,ref:t})});ux.displayName=H8;var U8="MenuLabel",rP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{...r,ref:t})});rP.displayName=U8;var jh="MenuItem",cw="menu.itemSelect",Hf=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=au(jh,e.__scopeMenu),a=lx(jh,e.__scopeMenu),l=qt(t,s),c=g.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(cw,{bubbles:!0,cancelable:!0});d.addEventListener(cw,p=>r==null?void 0:r(p),{once:!0}),rT(d,f),f.defaultPrevented?c.current=!1:o.onClose()}};return h.jsx(iP,{...i,ref:l,disabled:n,onClick:Te(e.onClick,u),onPointerDown:d=>{var f;(f=e.onPointerDown)==null||f.call(e,d),c.current=!0},onPointerUp:Te(e.onPointerUp,d=>{var f;c.current||(f=d.currentTarget)==null||f.click()}),onKeyDown:Te(e.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||Rv.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});Hf.displayName=jh;var iP=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=lx(jh,n),a=QT(n),l=g.useRef(null),c=qt(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(Dc.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:h.jsx(HF,{asChild:!0,...a,focusable:!r,children:h.jsx(Et.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:Te(e.onPointerMove,Lc(m=>{r?o.onItemLeave(m):(o.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Te(e.onPointerLeave,Lc(m=>o.onItemLeave(m))),onFocus:Te(e.onFocus,()=>d(!0)),onBlur:Te(e.onBlur,()=>d(!1))})})})}),W8="MenuCheckboxItem",sP=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return h.jsx(uP,{scope:e.__scopeMenu,checked:n,children:h.jsx(Hf,{role:"menuitemcheckbox","aria-checked":Dh(n)?"mixed":n,...i,ref:t,"data-state":hx(n),onSelect:Te(i.onSelect,()=>r==null?void 0:r(Dh(n)?!0:!n),{checkForDefaultPrevented:!1})})})});sP.displayName=W8;var oP="MenuRadioGroup",[V8,q8]=No(oP,{value:void 0,onValueChange:()=>{}}),aP=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=Ii(r);return h.jsx(V8,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(ux,{...i,ref:t})})});aP.displayName=oP;var lP="MenuRadioItem",cP=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=q8(lP,e.__scopeMenu),s=n===i.value;return h.jsx(uP,{scope:e.__scopeMenu,checked:s,children:h.jsx(Hf,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":hx(s),onSelect:Te(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});cP.displayName=lP;var dx="MenuItemIndicator",[uP,K8]=No(dx,{checked:!1}),dP=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=K8(dx,n);return h.jsx(zi,{present:r||Dh(s.checked)||s.checked===!0,children:h.jsx(Et.span,{...i,ref:t,"data-state":hx(s.checked)})})});dP.displayName=dx;var G8="MenuSeparator",hP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});hP.displayName=G8;var X8="MenuArrow",fP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Ff(n);return h.jsx(jT,{...i,...r,ref:t})});fP.displayName=X8;var Y8="MenuSub",[pne,pP]=No(Y8),jl="MenuSubTrigger",mP=g.forwardRef((e,t)=>{const n=To(jl,e.__scopeMenu),r=au(jl,e.__scopeMenu),i=pP(jl,e.__scopeMenu),s=lx(jl,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(ox,{asChild:!0,...c,children:h.jsx(iP,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":_P(n.open),...e,ref:ru(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:Te(e.onPointerMove,Lc(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:Te(e.onPointerLeave,Lc(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,y=v==="right",_=y?-5:5,x=f[y?"left":"right"],b=f[y?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+_,y:d.clientY},{x,y:f.top},{x:b,y:f.top},{x:b,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:Te(e.onKeyDown,d=>{var p;const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||R8[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});mP.displayName=jl;var gP="MenuSubContent",vP=g.forwardRef((e,t)=>{const n=eP(vr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=To(vr,e.__scopeMenu),o=au(vr,e.__scopeMenu),a=pP(gP,e.__scopeMenu),l=g.useRef(null),c=qt(t,l);return h.jsx(Dc.Provider,{scope:e.__scopeMenu,children:h.jsx(zi,{present:r||s.open,children:h.jsx(Dc.Slot,{scope:e.__scopeMenu,children:h.jsx(cx,{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:Te(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Te(e.onEscapeKeyDown,u=>{o.onClose(),u.preventDefault()}),onKeyDown:Te(e.onKeyDown,u=>{var p;const d=u.currentTarget.contains(u.target),f=I8[o.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});vP.displayName=gP;function _P(e){return e?"open":"closed"}function Dh(e){return e==="indeterminate"}function hx(e){return Dh(e)?"indeterminate":e?"checked":"unchecked"}function Z8(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Q8(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function J8(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=Q8(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 e9(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 t9(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return e9(n,t)}function Lc(e){return t=>t.pointerType==="mouse"?e(t):void 0}var n9=JT,r9=ox,i9=tP,s9=nP,o9=ux,a9=rP,l9=Hf,c9=sP,u9=aP,d9=cP,h9=dP,f9=hP,p9=fP,m9=mP,g9=vP,Uf="DropdownMenu",[v9]=Eo(Uf,[ZT]),Mn=ZT(),[_9,xP]=v9(Uf),yP=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=Mn(t),c=g.useRef(null),[u,d]=Af({prop:i,defaultProp:s??!1,onChange:o,caller:Uf});return h.jsx(_9,{scope:t,triggerId:to(),triggerRef:c,contentId:to(),open:u,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(n9,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};yP.displayName=Uf;var bP="DropdownMenuTrigger",wP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=xP(bP,n),o=Mn(n);return h.jsx(r9,{asChild:!0,...o,children:h.jsx(Et.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:ru(t,s.triggerRef),onPointerDown:Te(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:Te(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});wP.displayName=bP;var x9="DropdownMenuPortal",SP=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Mn(t);return h.jsx(i9,{...r,...n})};SP.displayName=x9;var kP="DropdownMenuContent",CP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=xP(kP,n),s=Mn(n),o=g.useRef(!1);return h.jsx(s9,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:t,onCloseAutoFocus:Te(e.onCloseAutoFocus,a=>{var l;o.current||(l=i.triggerRef.current)==null||l.focus(),o.current=!1,a.preventDefault()}),onInteractOutside:Te(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)"}})});CP.displayName=kP;var y9="DropdownMenuGroup",b9=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(o9,{...i,...r,ref:t})});b9.displayName=y9;var w9="DropdownMenuLabel",EP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(a9,{...i,...r,ref:t})});EP.displayName=w9;var S9="DropdownMenuItem",NP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(l9,{...i,...r,ref:t})});NP.displayName=S9;var k9="DropdownMenuCheckboxItem",TP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(c9,{...i,...r,ref:t})});TP.displayName=k9;var C9="DropdownMenuRadioGroup",E9=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(u9,{...i,...r,ref:t})});E9.displayName=C9;var N9="DropdownMenuRadioItem",T9=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(d9,{...i,...r,ref:t})});T9.displayName=N9;var P9="DropdownMenuItemIndicator",PP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(h9,{...i,...r,ref:t})});PP.displayName=P9;var R9="DropdownMenuSeparator",RP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(f9,{...i,...r,ref:t})});RP.displayName=R9;var I9="DropdownMenuArrow",M9=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(p9,{...i,...r,ref:t})});M9.displayName=I9;var A9="DropdownMenuSubTrigger",j9=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(m9,{...i,...r,ref:t})});j9.displayName=A9;var D9="DropdownMenuSubContent",L9=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(g9,{...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)"}})});L9.displayName=D9;var O9=yP,B9=wP,z9=SP,IP=CP,MP=EP,AP=NP,jP=TP,$9=PP,DP=RP;const LP=O9,OP=B9,fx=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(z9,{children:h.jsx(IP,{ref:r,sideOffset:t,className:se("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));fx.displayName=IP.displayName;const Ys=g.forwardRef(({className:e,inset:t,...n},r)=>h.jsx(AP,{ref:r,className:se("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-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Ys.displayName=AP.displayName;const F9=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>h.jsxs(jP,{ref:i,checked:n,className:se("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-[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($9,{children:h.jsx(nu,{className:"h-3.5 w-3.5"})})}),t]}));F9.displayName=jP.displayName;const BP=g.forwardRef(({className:e,...t},n)=>h.jsx(DP,{ref:n,className:se("-mx-1 my-1 h-px bg-border",e),...t}));BP.displayName=DP.displayName;const H9=g.forwardRef(({className:e,...t},n)=>h.jsx(MP,{ref:n,className:se("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));H9.displayName=MP.displayName;function U9({iconKey:e,className:t}){const n=tT(e);if(!n)return h.jsx(U_,{className:se("w-3.5 h-3.5 shrink-0 text-text-400",t),"data-testid":"session-icon-default","aria-label":"未分类"});const r=n.Icon;return h.jsx(r,{className:se("w-3.5 h-3.5 shrink-0",n.colorClass,t),"data-testid":`session-icon-${n.key}`,"aria-label":n.label})}var W9=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"}),V9="VisuallyHidden",zP=g.forwardRef((e,t)=>h.jsx(Et.span,{...e,ref:t,style:{...W9,...e.style}}));zP.displayName=V9;var q9=zP,[Wf]=Eo("Tooltip",[zf]),Vf=zf(),$P="TooltipProvider",K9=700,Iv="tooltip.open",[G9,px]=Wf($P),FP=e=>{const{__scopeTooltip:t,delayDuration:n=K9,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(G9,{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})};FP.displayName=$P;var Oc="Tooltip",[X9,qf]=Wf(Oc),HP=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=px(Oc,e.__scopeTooltip),c=Vf(t),[u,d]=g.useState(null),f=to(),p=g.useRef(0),m=o??l.disableHoverableContent,v=a??l.delayDuration,y=g.useRef(!1),[_,x]=Af({prop:r,defaultProp:i??!1,onChange:T=>{T?(l.onOpen(),document.dispatchEvent(new CustomEvent(Iv))):l.onClose(),s==null||s(T)},caller:Oc}),b=g.useMemo(()=>_?y.current?"delayed-open":"instant-open":"closed",[_]),w=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,y.current=!1,x(!0)},[x]),S=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x(!1)},[x]),k=g.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{y.current=!0,x(!0),p.current=0},v)},[v,x]);return g.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),h.jsx(IT,{...c,children:h.jsx(X9,{scope:t,contentId:f,open:_,stateAttribute:b,trigger:u,onTriggerChange:d,onTriggerEnter:g.useCallback(()=>{l.isOpenDelayedRef.current?k():w()},[l.isOpenDelayedRef,k,w]),onTriggerLeave:g.useCallback(()=>{m?S():(window.clearTimeout(p.current),p.current=0)},[S,m]),onOpen:w,onClose:S,disableHoverableContent:m,children:n})})};HP.displayName=Oc;var Mv="TooltipTrigger",UP=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=qf(Mv,n),s=px(Mv,n),o=Vf(n),a=g.useRef(null),l=qt(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(MT,{asChild:!0,...o,children:h.jsx(Et.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:Te(e.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:Te(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:Te(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Te(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Te(e.onBlur,i.onClose),onClick:Te(e.onClick,i.onClose)})})});UP.displayName=Mv;var Y9="TooltipPortal",[mne,Z9]=Wf(Y9,{forceMount:void 0}),La="TooltipContent",WP=g.forwardRef((e,t)=>{const n=Z9(La,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=qf(La,e.__scopeTooltip);return h.jsx(zi,{present:r||o.open,children:o.disableHoverableContent?h.jsx(VP,{side:i,...s,ref:t}):h.jsx(Q9,{side:i,...s,ref:t})})}),Q9=g.forwardRef((e,t)=>{const n=qf(La,e.__scopeTooltip),r=px(La,e.__scopeTooltip),i=g.useRef(null),s=qt(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 y=m.currentTarget,_={x:m.clientX,y:m.clientY},x=rH(_,y.getBoundingClientRect()),b=iH(_,x),w=sH(v.getBoundingClientRect()),S=aH([...b,...w]);a(S),d(!0)},[d]);return g.useEffect(()=>()=>f(),[f]),g.useEffect(()=>{if(l&&u){const m=y=>p(y,u),v=y=>p(y,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 y=v.target,_={x:v.clientX,y:v.clientY},x=(l==null?void 0:l.contains(y))||(u==null?void 0:u.contains(y)),b=!oH(_,o);x?f():b&&(f(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[l,u,o,c,f]),h.jsx(VP,{...e,ref:s})}),[J9,eH]=Wf(Oc,{isInside:!1}),tH=Vz("TooltipContent"),VP=g.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,l=qf(La,n),c=Vf(n),{onClose:u}=l;return g.useEffect(()=>(document.addEventListener(Iv,u),()=>document.removeEventListener(Iv,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(jf,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:h.jsxs(AT,{"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(tH,{children:r}),h.jsx(J9,{scope:n,isInside:!0,children:h.jsx(q9,{id:l.contentId,role:"tooltip",children:i||r})})]})})});WP.displayName=La;var qP="TooltipArrow",nH=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Vf(n);return eH(qP,n).isInside?null:h.jsx(jT,{...i,...r,ref:t})});nH.displayName=qP;function rH(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 iH(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 sH(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 oH(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 aH(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),lH(t)}function lH(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 cH=FP,uH=HP,dH=UP,KP=WP;const mx=cH,gx=uH,vx=dH,Kf=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(KP,{ref:r,sideOffset:t,className:se("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}));Kf.displayName=KP.displayName;function GP({value:e,onChange:t}){return h.jsx(mx,{delayDuration:150,children:h.jsx("div",{className:"flex items-center gap-1 flex-wrap","data-testid":"session-icon-picker",children:eT.map(n=>{const r=n.Icon,i=e===n.key;return h.jsxs(gx,{children:[h.jsx(vx,{asChild:!0,children:h.jsx("button",{type:"button",onClick:()=>t(i?null:n.key),"data-testid":`session-icon-option-${n.key}`,"aria-label":n.label,"aria-pressed":i,className:se("w-8 h-8 rounded-md flex items-center justify-center transition-colors cursor-pointer",i?"bg-text-100/10 ring-1 ring-text-100/30":"hover:bg-text-100/5"),children:h.jsx(r,{className:se("w-4 h-4",n.colorClass)})})}),h.jsx(Kf,{side:"bottom",children:n.label})]},n.key)})})})}function hH({open:e,initialLabel:t,initialIconKey:n,placeholder:r,onSubmit:i,onCancel:s}){const[o,a]=g.useState(t),[l,c]=g.useState(n);return g.useEffect(()=>{e&&(a(t),c(n))},[e,t,n]),g.useEffect(()=>{if(!e)return;const u=d=>{d.key==="Escape"&&s()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[e,s]),e?eu.createPortal(h.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-bg-0/40 backdrop-blur-[2px]",onClick:s,"data-testid":"session-edit-dialog-overlay",children:h.jsxs("div",{"data-testid":"session-edit-dialog",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:u=>u.stopPropagation(),children:[h.jsx("div",{className:"text-[15px] font-semibold text-text-100",children:"Edit session"}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:"Label"}),h.jsx("input",{autoFocus:!0,type:"text",value:o,onChange:u=>a(u.target.value),placeholder:r,"data-testid":"session-edit-dialog-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",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:"Icon"}),h.jsx(GP,{value:l,onChange:c})]}),h.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[h.jsx("button",{type:"button",onClick:s,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:()=>i({label:o.trim(),iconKey:l}),"data-testid":"session-edit-dialog-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",children:"Save"})]})]})}),document.body):null}const fH=10,pH=20,mH=16,gH=20,vH=60,_H=4;function xH({session:e,active:t,hasUnread:n,running:r=!1,awaitingUser:i=!1,onSelect:s,onEdit:o,onDelete:a,onPin:l,depth:c=0,chevron:u,showCopyResume:d=!0,contactDisplayName:f}){const[p,m]=g.useState(!1),v=!!e.pinnedAt,y=c===0,_=fH+c*pH,x=g.useCallback(async()=>{const k=e.toolSessionId;if(!k)return;const N=`cd ${`'${e.cwd.replace(/'/g,"'\\''")}'`} && claude --resume ${k} --permission-mode bypassPermissions`;try{await navigator.clipboard.writeText(N)}catch{}},[e.toolSessionId,e.cwd]),b=e.appBuilderProject?`[app] ${e.appBuilderProject}`:e.label||e.cwd.split("/").filter(Boolean).pop()||e.sessionId.slice(0,8),w=e.originOwnerPrincipalId,S=w?`@${f??`…${w.slice(-8)}`}`:null;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":`session-item-${e.sessionId}`,onClick:s,style:{paddingLeft:_,display:"grid",gridTemplateColumns:`${mH}px ${gH}px 1fr auto ${vH}px`,gridTemplateAreas:'"chev icon name dot time" ". . sub sub sub"',columnGap:`${_H}px`,rowGap:"2px",alignItems:"center"},className:se("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:u??null}),h.jsx("div",{style:{gridArea:"icon"},className:"flex items-center justify-center",children:h.jsx(U9,{iconKey:e.iconKey})}),h.jsxs("div",{style:{gridArea:"name"},className:"flex items-center gap-1 min-w-0",children:[e.dispatchedFromSessionId?h.jsx(OB,{"data-testid":`dispatched-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"dispatched from another session",children:h.jsx("title",{children:"由另一个 session dispatch 派生"})}):null,e.shiftFiredFromSessionId?h.jsx(lB,{"data-testid":`shift-fired-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"fired by clawd-shift scheduler",children:h.jsx("title",{children:"由 shift 排班到点 fire 派生"})}):null,h.jsx("span",{"data-testid":`session-title-${e.sessionId}`,className:se("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:b})]}),i?h.jsx(hB,{"data-testid":`awaiting-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-3 h-3 text-warning shrink-0 animate-pulse",strokeWidth:2.25,"aria-label":"awaiting user"}):n?h.jsx("span",{"data-testid":`unread-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-2 h-2 rounded-full bg-error shrink-0","aria-label":"unread"}):r?h.jsx("span",{"data-testid":`running-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-2 h-2 rounded-full bg-success shrink-0 animate-pulse","aria-label":"running"}):null,h.jsx("span",{style:{gridArea:"time"},className:se("text-[11px] text-text-400/70 text-right shrink-0","transition-opacity duration-150 group-hover:opacity-0"),children:e.updatedAt?Bz(e.updatedAt):""}),h.jsxs("span",{style:{gridArea:"sub"},className:se("flex items-center gap-1.5 text-[11px] text-text-400/70 min-w-0","group-hover:flex-wrap"),children:[S?h.jsx("span",{"data-testid":`session-mirror-chip-${e.sessionId}`,title:`在 ${S.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:S}):null,h.jsx("span",{"data-testid":`session-subtitle-${e.sessionId}`,className:se("block text-[11px] text-text-400/70 truncate font-mono min-w-0","group-hover:whitespace-normal group-hover:overflow-visible group-hover:break-all"),children:e.cwd.replace(/^\/Users\/[^/]+/,"~")})]}),o||a||l?h.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100 transition-opacity",children:h.jsxs(LP,{modal:!1,children:[h.jsx(OP,{asChild:!0,children:h.jsx("button",{type:"button",onClick:k=>k.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(bv,{className:"w-4 h-4"})})}),h.jsxs(fx,{align:"end",onClick:k=>k.stopPropagation(),children:[l&&y&&h.jsxs(Ys,{onSelect:()=>l(e.sessionId,!v),"data-testid":`session-${v?"unpin":"pin"}-${e.sessionId}`,children:[v?h.jsx(v6,{className:"w-3 h-3 mr-2 text-text-400"}):h.jsx(DN,{className:"w-3 h-3 mr-2 text-text-400"}),v?"Unpin":"Pin"]}),o&&h.jsxs(Ys,{onSelect:()=>m(!0),"data-testid":`session-rename-${e.sessionId}`,children:[h.jsx(jN,{className:"w-3 h-3 mr-2 text-text-400"}),"Rename"]}),d&&e.toolSessionId?h.jsxs(Ys,{onSelect:()=>void x(),"data-testid":`session-copy-resume-${e.sessionId}`,children:[h.jsx(Mf,{className:"w-3 h-3 mr-2 text-text-400"}),"Copy Resume Command"]}):null,(l||o||d&&e.toolSessionId)&&a&&h.jsx(BP,{}),a&&h.jsxs(Ys,{onSelect:()=>void a(e.sessionId),className:"text-destructive focus:text-destructive focus:bg-destructive/10","data-testid":`session-delete-${e.sessionId}`,children:[h.jsx(V_,{className:"w-3 h-3 mr-2"}),"Delete"]})]})]})}):null]}),o?h.jsx(hH,{open:p,initialLabel:e.label??"",initialIconKey:e.iconKey??null,placeholder:e.cwd.split("/").pop()||"",onSubmit:k=>{o(e.sessionId,k),m(!1)},onCancel:()=>m(!1)}):null]})}function _x({node:e,depth:t=0,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,getContactDisplayName:u,showCopyResume:d}){const f=e.children.length>0,{isCollapsed:p,toggle:m}=tB(),v=!p(e.session.sessionId),y=g.useCallback(x=>{x.stopPropagation(),m(e.session.sessionId)},[m,e.session.sessionId]),_=f?h.jsx("button",{type:"button",onClick:y,"data-testid":`session-chevron-${e.session.sessionId}`,"aria-label":v?"collapse":"expand","aria-expanded":v,className:"shrink-0 flex items-center justify-center w-4 h-4 text-text-400 hover:text-text-100 cursor-pointer",children:v?h.jsx(ai,{className:"w-3 h-3"}):h.jsx(li,{className:"w-3 h-3"})}):null;return h.jsxs("div",{"data-testid":`session-tree-node-${e.session.sessionId}`,children:[h.jsx(xH,{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,showCopyResume:d,depth:t,chevron:_,contactDisplayName:e.session.originOwnerPrincipalId?u==null?void 0:u(e.session.originOwnerPrincipalId):void 0}),f&&v?h.jsx("div",{"data-testid":`session-tree-children-${e.session.sessionId}`,children:e.children.map(x=>h.jsx(_x,{node:x,depth:t+1,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,getContactDisplayName:u,showCopyResume:d},x.session.sessionId))}):null]})}function yH(e){return e.forkedFromSessionId??e.dispatchedFromSessionId??e.shiftFiredFromSessionId}function XP(e){e=e.filter(s=>!s.ephemeral);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=yH(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(bH).map(i)}function YP(e){return[...e].sort((t,n)=>t.session.updatedAt<n.session.updatedAt?1:t.session.updatedAt>n.session.updatedAt?-1:0)}function bH(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 wH(e,t){if(e.appBuilderProject)return`[app] ${e.appBuilderProject}`;if(e.label)return e.label;const n=e.cwd.split("/").filter(Boolean).pop();return n||((e.ownerPersonaId?t==null?void 0:t(e.ownerPersonaId):void 0)??"")}function uw(e,t){const n=t.trim().toLowerCase();return n===""?!0:e.toLowerCase().includes(n)}function ZP(e){return e.compositionActive||!!e.nativeIsComposing||e.keyCode===229}function QP(e){return e.key==="Enter"&&!e.shiftKey&&!ZP(e)}function SH(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(QP({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}}const kH={isCollapsed:()=>!1,toggle:()=>{},prune:()=>{}};function CH({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:y,showCopyResume:_,treatSessionsAsRoots:x,searchQuery:b}){const[w,S]=g.useState(null),[k,T]=g.useState(()=>new Set),N=p??(R=>k.has(R)),O=g.useCallback(R=>{if(m){m(R);return}T(I=>{const j=new Set(I);return j.has(R)?j.delete(R):j.add(R),j})},[m]),P=g.useMemo(()=>i==null?void 0:i.filter(R=>!R.ephemeral),[i]);if(e.length===0)return h.jsx(EH,{});const L=(b??"").trim();return L?h.jsx(H_.Provider,{value:kH,children:h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(R=>{const I=P?P.filter(F=>F.ownerPersonaId===R.personaId).sort((F,A)=>A.updatedAt>F.updatedAt?1:-1):[],j=uw(R.label,L),B=I.filter(F=>uw(wH(F),L));if(!j&&B.length===0)return null;const $=j?I:B;return h.jsx(dw,{persona:R,active:R.personaId===t,editing:!1,onSelectPersona:n,onSubmitCreateSession:()=>{},onCancelCreateSession:()=>{},personaSessions:$,collapsed:!1,onToggleCollapsed:()=>{},activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:y,showCopyResume:_,treatSessionsAsRoots:x,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f},R.personaId)})})}):h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(R=>{const I=P?P.filter(j=>j.ownerPersonaId===R.personaId).sort((j,B)=>B.updatedAt>j.updatedAt?1:-1):[];return h.jsx(dw,{persona:R,active:R.personaId===t,editing:R.personaId===w,onSelectPersona:n,onStartCreateSession:r?()=>S(R.personaId):void 0,onSubmitCreateSession:j=>{S(null),r==null||r(R.personaId,j)},onCancelCreateSession:()=>S(null),personaSessions:I,collapsed:!N(R.personaId),onToggleCollapsed:()=>O(R.personaId),activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:y,showCopyResume:_,treatSessionsAsRoots:x,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f},R.personaId)})})}function EH(){return h.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-text-400",children:"还没有 persona。点上方 Personas 标题右侧 + 创建第一个。"})}function dw({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:y,onPinSession:_,showCopyResume:x,treatSessionsAsRoots:b,ownerPrincipalId:w,creatorDisplayNameByOwnerId:S}){const k=JP(e.iconKey),T=a.length>0,N=!l,O=g.useMemo(()=>{const R=[],I=new Map;for(const j of a){const B=j.creatorPrincipalId;if(!B||w&&B===w){R.push(j);continue}const $=B,F=(S==null?void 0:S.get($))??`…${$.slice(-8)}`,A=I.get($);A?A.sessions.push(j):I.set($,{groupKey:$,displayName:F,sessions:[j]})}return{self:R,byPeer:[...I.values()]}},[a,w,S]),P=O.byPeer.length>0,L=g.useMemo(()=>N&&!P?YP(XP(a)):[],[N,P,a]);return h.jsxs("div",{"data-testid":`persona-node-${e.personaId}`,children:[h.jsxs("div",{className:se("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:R=>{R.stopPropagation(),c()},"aria-label":N?"collapse":"expand","aria-expanded":N,"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:N?h.jsx(ai,{className:"h-3 w-3"}):h.jsx(li,{className:"h-3 w-3"})}):h.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),h.jsx(k.Component,{className:se("h-3.5 w-3.5 shrink-0",k.colorClass),"aria-hidden":"true"}),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:R=>{R.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(w6,{className:"h-3.5 w-3.5"})}):null]}),n?h.jsx(NH,{personaId:e.personaId,iconKey:e.iconKey,onSubmit:s,onCancel:o}):null,T&&N?h.jsx("div",{"data-testid":`persona-sessions-${e.personaId}`,children:P?h.jsxs(h.Fragment,{children:[O.self.length>0&&h.jsx(hw,{groupKey:`${e.personaId}-self`,label:"我自己",testId:`persona-sessions-${e.personaId}-self`,sessions:O.self,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:y,onPinSession:_,showCopyResume:x}),O.byPeer.map(R=>h.jsx(hw,{groupKey:`${e.personaId}-peer-${R.groupKey}`,label:R.displayName,testId:`persona-sessions-${e.personaId}-peer-${R.groupKey}`,sessions:R.sessions,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:y,onPinSession:_,showCopyResume:x},`${e.personaId}-peer-${R.groupKey}`))]}):L.map(R=>h.jsx(_x,{node:R,depth:b?0:1,activeId:u,unreadIds:p,runningIds:f,awaitingIds:d,onSelect:I=>m==null?void 0:m(I),onDelete:v,onEdit:y,onPin:_,showCopyResume:x},R.session.sessionId))}):null]})}function hw({label:e,testId:t,sessions:n,activeSessionId:r,awaitingIds:i,runningIds:s,unreadIds:o,onSelectSession:a,onDeleteSession:l,onEditSession:c,onPinSession:u,showCopyResume:d}){const[f,p]=g.useState(!1),m=!f,v=g.useMemo(()=>m?YP(XP(n)):[],[m,n]);return h.jsxs("div",{"data-testid":t,children:[h.jsxs("button",{type:"button",onClick:()=>p(y=>!y),"aria-label":m?"collapse":"expand","aria-expanded":m,"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:[m?h.jsx(ai,{className:"h-3 w-3"}):h.jsx(li,{className:"h-3 w-3"}),h.jsx(q_,{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})]}),m&&h.jsx("div",{children:v.map(y=>h.jsx(_x,{node:y,depth:2,activeId:r,unreadIds:o,runningIds:s,awaitingIds:i,onSelect:_=>a==null?void 0:a(_),onDelete:l,onEdit:c,onPin:u,showCopyResume:d},y.session.sessionId))})]})}function NH({personaId:e,iconKey:t,onSubmit:n,onCancel:r}){const[i,s]=g.useState(""),o=g.useRef(null),a=JP(t),l=i.trim(),c=l.length>0;g.useEffect(()=>{var f;(f=o.current)==null||f.focus()},[]);const u=g.useCallback(()=>{c&&n(l)},[c,l,n]),d=SH(u,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(a.Component,{className:se("h-3 w-3 shrink-0",a.colorClass),"aria-hidden":"true"}),h.jsx("input",{ref:o,type:"text",value:i,onChange:f=>s(f.target.value),...d,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:f=>{f.preventDefault(),u()},disabled:!c,"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(nu,{className:"h-3 w-3"})}),h.jsx("button",{type:"button",onMouseDown:f=>{f.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(In,{className:"h-3 w-3"})})]})}function JP(e){const t=tT(e);return t?{Component:t.Icon,colorClass:t.colorClass}:{Component:H6,colorClass:"text-text-400"}}function TH(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function PH(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),r=parseFloat(n.fontSize);return t*r}function RH(e){return e/100*window.innerHeight}function IH(e){return e/100*window.innerWidth}function MH(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 Dl({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=MH(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=PH(t,i);break}case"em":{r=TH(t,i);break}case"vh":{r=RH(i);break}case"vw":{r=IH(i);break}}return r}function En(e){return parseFloat(e.toFixed(3))}function Oa({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 Av(e){const{panels:t}=e,n=Oa({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=Dl({groupSize:n,panelElement:i,styleProp:s.collapsedSize});o=En(u/n*100)}let a;if(s.defaultSize!==void 0){const u=Dl({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=En(u/n*100)}let l=0;if(s.minSize!==void 0){const u=Dl({groupSize:n,panelElement:i,styleProp:s.minSize});l=En(u/n*100)}let c=100;if(s.maxSize!==void 0){const u=Dl({groupSize:n,panelElement:i,styleProp:s.maxSize});c=En(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 rt(e,t="Assertion error"){if(!e)throw Error(t)}function jv(e,t){return Array.from(t).sort(e==="horizontal"?AH:jH)}function AH(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function jH(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function eR(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function tR(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 DH({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}=tR(r,o),c=e==="horizontal"?a:l;c<s&&(s=c,i=o)}return rt(i,"No rect found"),i}let td;function LH(){return td===void 0&&(typeof matchMedia=="function"?td=!!matchMedia("(pointer:coarse)").matches:td=!1),td}function nR(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=jv(n,Array.from(t.children).filter(eR).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 y=r.find(_=>_.element===v);if(y){if(f){const _=f.element.getBoundingClientRect(),x=v.getBoundingClientRect();let b;if(l){const w=n==="horizontal"?new DOMRect(_.right,_.top,0,_.height):new DOMRect(_.left,_.bottom,_.width,0),S=n==="horizontal"?new DOMRect(x.left,x.top,0,x.height):new DOMRect(x.left,x.top,x.width,0);switch(p.length){case 0:{b=[w,S];break}case 1:{const k=p[0],T=DH({orientation:n,rects:[_,x],targetRect:k.element.getBoundingClientRect()});b=[k,T===_?S:w];break}default:{b=p;break}}}else p.length?b=p:b=[n==="horizontal"?new DOMRect(_.right,x.top,x.left-_.right,x.height):new DOMRect(x.left,_.bottom,x.width,x.top-_.bottom)];for(const w of b){let S="width"in w?w:w.element.getBoundingClientRect();const k=LH()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(S.width<k){const N=k-S.width;S=new DOMRect(S.x-N/2,S.y,S.width+N,S.height)}if(S.height<k){const N=k-S.height;S=new DOMRect(S.x,S.y-N/2,S.width,S.height+N)}const T=m<=c||m>u;!a&&!T&&o.push({group:e,groupSize:Oa({group:e}),panels:[f,y],separator:"width"in w?void 0:w,rect:S}),a=!1}}l=!1,f=y,p=[]}}else if(v.hasAttribute("data-separator")){v.ariaDisabled!==null&&(a=!0);const y=i.find(_=>_.element===v);y?p.push(y):(f=void 0,p=[])}else l=!0}return o}var os;class rR{constructor(){yy(this,os,{})}addListener(t,n){const r=ll(this,os)[t];return r===void 0?ll(this,os)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=ll(this,os)[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(){by(this,os,{})}removeListener(t,n){const r=ll(this,os)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}os=new WeakMap;let ya={cursorFlags:0,state:"inactive"};const xx=new rR;function po(){return ya}function OH(e){return xx.addListener("change",e)}function BH(e){const t=ya,n={...ya};n.cursorFlags=e,ya=n,xx.emit("change",{prev:t,next:n})}function ba(e){const t=ya;ya=e,xx.emit("change",{prev:t,next:e})}const zH=e=>e,im=()=>{},iR=1,sR=2,oR=4,aR=8,fw=3,pw=12;let nd;function mw(){return nd===void 0&&(nd=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(nd=!0)),nd}function $H({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&&mw()){const s=(e&iR)!==0,o=(e&sR)!==0,a=(e&oR)!==0,l=(e&aR)!==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 mw()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const gw=new WeakMap;function yx(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=gw.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=po();switch(r.state){case"active":case"hover":{const i=$H({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}}gw.set(e,{prevStyle:t,styleSheet:n})}let Yr=new Map;const lR=new rR;function FH(e){Yr=new Map(Yr),Yr.delete(e)}function vw(e,t){for(const[n]of Yr)if(n.id===e)return n}function xs(e,t){for(const[n,r]of Yr)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Po(){return Yr}function bx(e,t){return lR.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function ji(e,t,n){const r=Yr.get(e);Yr=new Map(Yr),Yr.set(e,t),lR.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:r,next:t})}function cR(e){const t=po();let n=!1;switch(t.state){case"active":ba({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(yx(e),n=!0,t.hitRegions.forEach(r=>{const i=xs(r.group.id,!0);ji(r.group,i,{isUserInteraction:!0})}))}return n}function _w(e){e.defaultPrevented||cR(e.currentTarget)}function HH(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const o=tR(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 UH(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function WH(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:bw(e),b:bw(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();rt(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:yw(xw(n.a)),b:yw(xw(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 VH=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function qH(e){const t=getComputedStyle(uR(e)??e).display;return t==="flex"||t==="inline-flex"}function KH(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||qH(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"||VH.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function xw(e){let t=e.length;for(;t--;){const n=e[t];if(rt(n,"Missing node"),KH(n))return n}return null}function yw(e){return e&&Number(getComputedStyle(e).zIndex)||0}function bw(e){const t=[];for(;e;)t.push(e),e=uR(e);return t}function uR(e){const{parentNode:t}=e;return UH(t)?t.host:t}function GH(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 XH({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!eR(n)||n.contains(e)||e.contains(n))return!0;if(WH(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(GH(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function wx(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=nR(i),o=HH(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&XH({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function YH(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 _n(e,t,n=0){return Math.abs(En(e)-En(t))<=n}function qr(e,t){return _n(e,t)?0:e>t?1:-1}function ca({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(qr(r,l)<0)if(s){const c=(i+l)/2;qr(r,c)<0?r=i:r=l}else r=l;return r=Math.min(a,r),r=En(r),r}function Bc({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(_n(e,0))return t;const o=s==="imperative-api",a=Object.values(t),l=Object.values(i),c=[...a],[u,d]=r;rt(u!=null,"Invalid first pivot index"),rt(d!=null,"Invalid second pivot index");let f=0;switch(s){case"keyboard":{{const v=e<0?d:u,y=n[v];rt(y,`Panel constraints not found for index ${v}`);const{collapsedSize:_=0,collapsible:x,minSize:b=0}=y;if(x){const w=a[v];if(rt(w!=null,`Previous layout not found for panel index ${v}`),_n(w,_)){const S=b-w;qr(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}{const v=e<0?u:d,y=n[v];rt(y,`No panel constraints found for index ${v}`);const{collapsedSize:_=0,collapsible:x,minSize:b=0}=y;if(x){const w=a[v];if(rt(w!=null,`Previous layout not found for panel index ${v}`),_n(w,b)){const S=w-_;qr(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}break}default:{const v=e<0?d:u,y=n[v];rt(y,`Panel constraints not found for index ${v}`);const _=a[v],{collapsible:x,collapsedSize:b,minSize:w}=y;if(x&&qr(_,w)<0)if(e>0){const S=w-b,k=S/2,T=_+e;qr(T,w)<0&&(e=qr(e,k)<=0?0:S)}else{const S=w-b,k=100-S/2,T=_-e;qr(T,w)<0&&(e=qr(100+e,k)>0?0:-S)}break}}{const v=e<0?1:-1;let y=e<0?d:u,_=0;for(;;){const b=a[y];rt(b!=null,`Previous layout not found for panel index ${y}`);const w=ca({overrideDisabledPanels:o,panelConstraints:n[y],prevSize:b,size:100})-b;if(_+=w,y+=v,y<0||y>=n.length)break}const x=Math.min(Math.abs(e),Math.abs(_));e=e<0?0-x:x}{let v=e<0?u:d;for(;v>=0&&v<n.length;){const y=Math.abs(e)-Math.abs(f),_=a[v];rt(_!=null,`Previous layout not found for panel index ${v}`);const x=_-y,b=ca({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:_,size:x});if(!_n(_,b)&&(f+=_-b,c[v]=b,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?v--:v++}}if(YH(l,c))return i;{const v=e<0?d:u,y=a[v];rt(y!=null,`Previous layout not found for panel index ${v}`);const _=y+f,x=ca({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:y,size:_});if(c[v]=x,!_n(x,_)){let b=_-x,w=e<0?d:u;for(;w>=0&&w<n.length;){const S=c[w];rt(S!=null,`Previous layout not found for panel index ${w}`);const k=S+b,T=ca({overrideDisabledPanels:o,panelConstraints:n[w],prevSize:S,size:k});if(_n(S,T)||(b-=T-S,c[w]=T),_n(b,0))break;e>0?w--:w++}}}const p=Object.values(c).reduce((v,y)=>y+v,0);if(!_n(p,100,.1))return i;const m=Object.keys(i);return c.reduce((v,y,_)=>(v[m[_]]=y,v),{})}function mo(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||qr(e[n],t[n])!==0)return!1;return!0}function go({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(!_n(i,100)&&r.length>0)for(let a=0;a<t.length;a++){const l=r[a];rt(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];rt(l!=null,`No layout data found for index ${a}`);const c=r[a];rt(c!=null,`No layout data found for index ${a}`);const u=ca({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});c!=u&&(s+=c-u,r[a]=u)}if(!_n(s,0))for(let a=0;a<t.length;a++){const l=r[a];rt(l!=null,`No layout data found for index ${a}`);const c=l+s,u=ca({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});if(l!==u&&(s-=u-l,r[a]=u,_n(s,0)))break}const o=Object.keys(e);return r.reduce((a,l,c)=>(a[o[c]]=l,a),{})}function dR({groupId:e,panelId:t}){const n=()=>{const l=Po();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(y=>y.id===t),m=p===0,v=p===c.length-1;if(v&&l<f&&(m||c.slice(0,p).every((y,_)=>{const x=d[_];return(x==null?void 0:x.collapsible)&&_n(x.collapsedSize,u[x.panelId])}))){const y=c.slice(0,p).reduce((_,x)=>_+u[x.id],0);return{...u,[t]:En(100-y)}}return Bc({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(),y=o({nextSize:l,panels:f.panels,prevLayout:m,derivedPanelConstraints:d}),_=go({layout:y,panelConstraints:d});mo(m,_)||ji(f,{defaultLayoutDeferred:u,derivedPanelConstraints:d,groupSize:p,layout:_,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&&_n(c,u)},resize:l=>{const{group:c}=n(),{element:u}=i(),d=Oa({group:c}),f=Dl({groupSize:d,panelElement:u,styleProp:l}),p=En(f/d*100);a(p)}}}function ww(e){if(e.defaultPrevented)return;const t=Po();wx(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=dR({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function Ad(e){const t=Po();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 hR({groupId:e}){const t=()=>{const n=Po();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=go({layout:n,panelConstraints:i});return r?a:(mo(a,c)||ji(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:o,layout:c,separatorToPanels:l}),c)}}}function Os(e,t){const n=Ad(e),r=xs(n.id,!0),i=n.separators.find(u=>u.element===e);rt(i,"Matching separator not found");const s=r.separatorToPanels.get(i);rt(s,"Matching panels not found");const o=s.map(u=>n.panels.indexOf(u)),a=hR({groupId:n.id}).getLayout(),l=Bc({delta:t,initialLayout:a,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),c=go({layout:l,panelConstraints:r.derivedPanelConstraints});mo(a,c)||ji(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function Sw(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=Ad(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Os(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Os(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Os(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Os(t,-5);break}case"End":{e.preventDefault(),Os(t,100);break}case"Enter":{e.preventDefault();const r=Ad(t),i=xs(r.id,!0),{derivedPanelConstraints:s,layout:o,separatorToPanels:a}=i,l=r.separators.find(f=>f.element===t);rt(l,"Matching separator not found");const c=a.get(l);rt(c,"Matching panels not found");const u=c[0],d=s.find(f=>f.panelId===u.id);if(rt(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;Os(t,p-f)}break}case"F6":{e.preventDefault();const r=Ad(t).separators.map(o=>o.element),i=Array.from(r).findIndex(o=>o===e.currentTarget);rt(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(),Os(t,-100);break}}}function kw(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=Po(),n=wx(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 fR({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 y=r.get(u),_=i.get(u);if(!y||!_)return;const{defaultLayoutDeferred:x,derivedPanelConstraints:b,groupSize:w,layout:S,separatorToPanels:k}=_;if(b&&S&&k){const T=Bc({delta:v,initialLayout:y,panelConstraints:b,pivotIndices:c.panels.map(N=>p.indexOf(N)),prevLayout:S,trigger:"mouse-or-touch"});if(mo(T,S)){if(v!==0&&!m)switch(f){case"horizontal":{a|=v<0?iR:sR;break}case"vertical":{a|=v<0?oR:aR;break}}}else ji(c.group,{defaultLayoutDeferred:x,derivedPanelConstraints:b,groupSize:w,layout:T,separatorToPanels:k})}});let l=0;t.movementX===0?l|=o&fw:l|=a&fw,t.movementY===0?l|=o&pw:l|=a&pw,BH(l),yx(e)}function Cw(e){const t=Po(),n=po();switch(n.state){case"active":fR({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function Ew(e){var r,i;if(e.defaultPrevented)return;const t=po(),n=Po();switch(t.state){case"active":{if(e.buttons===0){ba({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const o=xs(s.group.id,!0);ji(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))}fR({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=wx(e,n);s.length===0?t.state!=="inactive"&&ba({cursorFlags:0,state:"inactive"}):ba({cursorFlags:0,hitRegions:s,state:"hover"}),yx(e.currentTarget);break}}}function Nw(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(po().state){case"hover":ba({cursorFlags:0,state:"inactive"})}}function Tw(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||cR(e.currentTarget)&&e.preventDefault()}function Pw(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const o=En(s.defaultSize);n+=o,r[s.panelId]=o}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=En((100-n)/i);for(const o of e)o.defaultSize===void 0&&(r[o.panelId]=s)}return r}function ZH(e,t,n){if(!n[0])return;const r=e.panels.find(l=>l.element===t);if(!r||!r.onResize)return;const i=Oa({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,a={asPercentage:En(s/i*100),inPixels:s};r.mutableValues.prevSize=a,r.onResize(a,r.id,o)}function QH(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 JH({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=En(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]=En(f/s*c)}else{const d=En(c/l.length);for(const f of l)u[f]=d}return u}function e7(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 Ho=new Map;function t7(e){let t=!0;rt(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:y,target:_}=v;if(_===e.element){if(t){const x=Oa({group:e});if(x===0)return;const b=xs(e.id);if(!b)return;const w=Av(e),S=b.defaultLayoutDeferred?Pw(w):b.layout,k=JH({group:e,nextGroupSize:x,prevGroupSize:b.groupSize,prevLayout:S}),T=go({layout:k,panelConstraints:w});if(!b.defaultLayoutDeferred&&mo(b.layout,T)&&QH(b.derivedPanelConstraints,w)&&b.groupSize===x)return;ji(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:w,groupSize:x,layout:T,separatorToPanels:b.separatorToPanels})}}else ZH(e,_,y)}});s.observe(e.element),e.panels.forEach(m=>{rt(!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=Oa({group:e}),a=Av(e),l=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(e7(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[l]??c??Pw(a),d=go({layout:u,panelConstraints:a}),f=e.element.ownerDocument;Ho.set(f,(Ho.get(f)??0)+1);const p=new Map;return nR(e).forEach(m=>{m.separator&&p.set(m.separator,m.panels)}),ji(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:a,groupSize:o,layout:d,separatorToPanels:p}),e.separators.forEach(m=>{rt(!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",Sw)}),Ho.get(f)===1&&(f.addEventListener("contextmenu",_w,!0),f.addEventListener("dblclick",ww,!0),f.addEventListener("pointerdown",kw,!0),f.addEventListener("pointerleave",Cw),f.addEventListener("pointermove",Ew),f.addEventListener("pointerout",Nw),f.addEventListener("pointerup",Tw,!0)),function(){t=!1,Ho.set(f,Math.max(0,(Ho.get(f)??0)-1)),FH(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",Sw)}),Ho.get(f)||(f.removeEventListener("contextmenu",_w,!0),f.removeEventListener("dblclick",ww,!0),f.removeEventListener("pointerdown",kw,!0),f.removeEventListener("pointerleave",Cw),f.removeEventListener("pointermove",Ew),f.removeEventListener("pointerout",Nw),f.removeEventListener("pointerup",Tw,!0)),s.disconnect()}}function n7(){const[e,t]=g.useState({}),n=g.useCallback(()=>t({}),[]);return[e,n]}function Sx(e){const t=g.useId();return`${e??t}`}const Ro=typeof window<"u"?g.useLayoutEffect:g.useEffect;function tc(e){const t=g.useRef(e);return Ro(()=>{t.current=e},[e]),g.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function kx(...e){return tc(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function Cx(e){const t=g.useRef({...e});return Ro(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const pR=g.createContext(null);function r7(e,t){const n=g.useRef({getLayout:()=>({}),setLayout:zH});g.useImperativeHandle(t,()=>n.current,[]),Ro(()=>{Object.assign(n.current,hR({groupId:e}))})}function Ex({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=tc(L=>{mo(m.current.onLayoutChange,L)||(m.current.onLayoutChange=L,l==null||l(L))}),y=tc((L,R)=>{mo(m.current.onLayoutChanged,L)||(m.current.onLayoutChanged=L,c==null||c(L,{isUserInteraction:R}))}),_=Sx(a),x=g.useRef(null),[b,w]=n7(),S=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),k=kx(x,s);r7(_,o);const T=tc((L,R)=>{const I=po(),j=vw(L),B=xs(L);if(B){let $=!1;switch(I.state){case"active":{$=I.hitRegions.some(F=>F.group===j);break}}return{flexGrow:B.layout[R]??1,pointerEvents:$?"none":void 0}}if(n!=null&&n[R])return{flexGrow:n==null?void 0:n[R]}}),N=Cx({defaultLayout:n,disableCursor:r}),O=g.useMemo(()=>({get disableCursor(){return!!N.disableCursor},getPanelStyles:T,id:_,orientation:u,registerPanel:L=>{const R=S.current;return R.panels=jv(u,[...R.panels,L]),w(),()=>{R.panels=R.panels.filter(I=>I!==L),w()}},registerSeparator:L=>{const R=S.current;return R.separators=jv(u,[...R.separators,L]),w(),()=>{R.separators=R.separators.filter(I=>I!==L),w()}},updatePanelProps:(L,{disabled:R})=>{const I=S.current.panels.find($=>$.id===L);I&&(I.panelConstraints.disabled=R);const j=vw(_),B=xs(_);j&&B&&ji(j,{...B,derivedPanelConstraints:Av(j)})},updateSeparatorProps:(L,{disabled:R,disableDoubleClick:I})=>{const j=S.current.separators.find(B=>B.id===L);j&&(j.disabled=R,j.disableDoubleClick=I)}}),[T,_,w,u,N]),P=g.useRef(null);return Ro(()=>{const L=x.current;if(L===null)return;const R=S.current;let I;if(N.defaultLayout!==void 0&&Object.keys(N.defaultLayout).length===R.panels.length){I={};for(const C of R.panels){const H=N.defaultLayout[C.id];H!==void 0&&(I[C.id]=H)}}const j={disabled:!!i,element:L,id:_,mutableState:{defaultLayout:I,disableCursor:!!N.disableCursor,expandedPanelSizes:S.current.lastExpandedPanelSizes,layouts:S.current.layouts},orientation:u,panels:R.panels,resizeTargetMinimumSize:R.resizeTargetMinimumSize,separators:R.separators};P.current=j;const B=t7(j),{defaultLayoutDeferred:$,derivedPanelConstraints:F,layout:A}=xs(j.id,!0);!$&&F.length>0&&(v(A),y(A,!1));const D=bx(_,C=>{const{defaultLayoutDeferred:H,derivedPanelConstraints:q,layout:M}=C.next;if(H||q.length===0)return;const ne=j.panels.map(({id:V})=>V).join(",");j.mutableState.layouts[ne]=M,q.forEach(V=>{if(V.collapsible){const{layout:pe}=C.prev??{};if(pe){const Oe=_n(V.collapsedSize,M[V.panelId]),re=_n(V.collapsedSize,pe[V.panelId]);Oe&&!re&&(j.mutableState.expandedPanelSizes[V.panelId]=pe[V.panelId])}}});const oe=po().state!=="active";v(M),oe&&y(M,C.isUserInteraction)});return()=>{P.current=null,B(),D()}},[i,_,y,v,u,b,N]),g.useEffect(()=>{const L=P.current;L&&(L.mutableState.defaultLayout=n,L.mutableState.disableCursor=!!r)}),h.jsx(pR.Provider,{value:O,children:h.jsx("div",{...p,className:t,"data-group":!0,"data-testid":_,id:_,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})})}Ex.displayName="Group";function Nx(){const e=g.useContext(pR);return rt(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function i7(e,t){const{id:n}=Nx(),r=g.useRef({collapse:im,expand:im,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:im});g.useImperativeHandle(t,()=>r.current,[]),Ro(()=>{Object.assign(r.current,dR({groupId:n,panelId:e}))})}function zc({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,y=Sx(l),_=Cx({disabled:s}),x=g.useRef(null),b=kx(x,o),{getPanelStyles:w,id:S,orientation:k,registerPanel:T,updatePanelProps:N}=Nx(),O=d!==null,P=tc((j,B,$)=>{d==null||d(j,l,$)});Ro(()=>{const j=x.current;if(j!==null){const B={element:j,id:y,idIsStable:v,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:O?P:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:c,minSize:u}};return T(B)}},[a,n,r,i,O,y,v,c,u,P,T,_]),g.useEffect(()=>{N(y,{disabled:s})},[s,y,N]),i7(y,f);const L=()=>{const j=w(S,y);if(j)return JSON.stringify(j)},R=g.useSyncExternalStore(j=>bx(S,j),L,L);let I;return R?I=JSON.parse(R):i!==void 0?I={flexGrow:void 0,flexShrink:void 0,flexBasis:i}:I={flexGrow:1},h.jsx("div",{...m,"data-disabled":s||void 0,"data-panel":!0,"data-testid":y,id:y,ref:b,style:{...s7,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...I},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})})}zc.displayName="Panel";const s7={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function o7({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=go({layout:Bc({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=go({layout:Bc({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:o}}function Tx({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:s,style:o,...a}){const l=Sx(s),c=Cx({disabled:n,disableDoubleClick:r}),[u,d]=g.useState({}),[f,p]=g.useState("inactive"),[m,v]=g.useState(!1),y=g.useRef(null),_=kx(y,i),{disableCursor:x,id:b,orientation:w,registerSeparator:S,updateSeparatorProps:k}=Nx(),T=w==="horizontal"?"vertical":"horizontal";Ro(()=>{const P=y.current;if(P!==null){const L={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:P,id:l},R=S(L),I=OH(B=>{p(B.next.state!=="inactive"&&B.next.hitRegions.some($=>$.separator===L)?B.next.state:"inactive")}),j=bx(b,B=>{const{derivedPanelConstraints:$,layout:F,separatorToPanels:A}=B.next,D=A.get(L);if(D){const C=D[0],H=D.indexOf(C);d(o7({layout:F,panelConstraints:$,panelId:C.id,panelIndex:H}))}});return()=>{I(),j(),R()}}},[b,l,S,c]),g.useEffect(()=>{k(l,{disabled:n,disableDoubleClick:r})},[n,r,l,k]);let N;n&&!x&&(N="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":T,"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:_,role:"separator",style:{flexBasis:"auto",cursor:N,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}Tx.displayName="Separator";function a7(e,t,n){const r=g.useRef({sid:null,tsid:void 0});g.useEffect(()=>{const i=r.current;r.current={sid:t,tsid:n},!(!n||i.sid===t&&(i.tsid===void 0||i.tsid===null)&&typeof n=="string")&&e.sessionObserve({sessionId:t,toolSessionId:n}).catch(()=>{})},[e,t,n])}function l7(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 c7=/^Scheduled (?:recurring job|one-shot task) ([0-9a-f]{8}) \(([^)]+)\)/;function u7(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(c7);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 d7=["TaskCreate","TaskUpdate","TaskList","TaskGet"];function h7(e){return d7.includes(e)}function mR(e){return e==="in_progress"||e==="completed"?e:"pending"}function f7(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:mR(n.status),activeForm:i,description:s}]}function p7(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=mR(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 m7(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=f7(t,i.input);break;case"TaskUpdate":t=p7(t,i.input);break}}return{tasks:t,lastEventIndex:n}}function g7(e){const{tasks:t,lastEventIndex:n}=m7(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;const d={agentId:u.agentId,status:u.status};u.description?d.description=u.description:(f=c.progress)!=null&&f.description&&(d.description=c.progress.description),u.lastToolName?d.lastToolName=u.lastToolName:(p=c.progress)!=null&&p.lastToolName&&(d.lastToolName=c.progress.lastToolName),u.stats?d.stats=u.stats:(m=c.progress)!=null&&m.stats&&(d.stats=c.progress.stats),c.progress=d};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}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 v7=/<(system-reminder|related-dir|clawd-shift-fire)\b[^>]*>[\s\S]*?<\/\1>/gi,_7=/<builder-preview\b[^>]*\/>/gi;function gR(e){return e?e.replace(v7,"").replace(_7,"").trim():""}const x7=gR;function y7(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const b7=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,w7=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,S7={};function Rw(e,t){return(S7.jsx?w7:b7).test(e)}const k7=/[ \t\n\f\r]/g;function C7(e){return typeof e=="object"?e.type==="text"?Iw(e.value):!1:Iw(e)}function Iw(e){return e.replace(k7,"")===""}class lu{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}lu.prototype.normal={};lu.prototype.property={};lu.prototype.space=void 0;function vR(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new lu(n,r,t)}function Dv(e){return e.toLowerCase()}class Vn{constructor(t,n){this.attribute=n,this.property=t}}Vn.prototype.attribute="";Vn.prototype.booleanish=!1;Vn.prototype.boolean=!1;Vn.prototype.commaOrSpaceSeparated=!1;Vn.prototype.commaSeparated=!1;Vn.prototype.defined=!1;Vn.prototype.mustUseProperty=!1;Vn.prototype.number=!1;Vn.prototype.overloadedBoolean=!1;Vn.prototype.property="";Vn.prototype.spaceSeparated=!1;Vn.prototype.space=void 0;let E7=0;const Re=Io(),Mt=Io(),Lv=Io(),X=Io(),lt=Io(),wa=Io(),Xn=Io();function Io(){return 2**++E7}const Ov=Object.freeze(Object.defineProperty({__proto__:null,boolean:Re,booleanish:Mt,commaOrSpaceSeparated:Xn,commaSeparated:wa,number:X,overloadedBoolean:Lv,spaceSeparated:lt},Symbol.toStringTag,{value:"Module"})),sm=Object.keys(Ov);class Px extends Vn{constructor(t,n,r,i){let s=-1;if(super(t,n),Mw(this,"space",i),typeof r=="number")for(;++s<sm.length;){const o=sm[s];Mw(this,sm[s],(r&Ov[o])===Ov[o])}}}Px.prototype.defined=!0;function Mw(e,t,n){n&&(e[t]=n)}function Qa(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Px(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Dv(r)]=r,n[Dv(s.attribute)]=r}return new lu(t,n,e.space)}const _R=Qa({properties:{ariaActiveDescendant:null,ariaAtomic:Mt,ariaAutoComplete:null,ariaBusy:Mt,ariaChecked:Mt,ariaColCount:X,ariaColIndex:X,ariaColSpan:X,ariaControls:lt,ariaCurrent:null,ariaDescribedBy:lt,ariaDetails:null,ariaDisabled:Mt,ariaDropEffect:lt,ariaErrorMessage:null,ariaExpanded:Mt,ariaFlowTo:lt,ariaGrabbed:Mt,ariaHasPopup:null,ariaHidden:Mt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:lt,ariaLevel:X,ariaLive:null,ariaModal:Mt,ariaMultiLine:Mt,ariaMultiSelectable:Mt,ariaOrientation:null,ariaOwns:lt,ariaPlaceholder:null,ariaPosInSet:X,ariaPressed:Mt,ariaReadOnly:Mt,ariaRelevant:null,ariaRequired:Mt,ariaRoleDescription:lt,ariaRowCount:X,ariaRowIndex:X,ariaRowSpan:X,ariaSelected:Mt,ariaSetSize:X,ariaSort:null,ariaValueMax:X,ariaValueMin:X,ariaValueNow:X,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function xR(e,t){return t in e?e[t]:t}function yR(e,t){return xR(e,t.toLowerCase())}const N7=Qa({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:wa,acceptCharset:lt,accessKey:lt,action:null,allow:null,allowFullScreen:Re,allowPaymentRequest:Re,allowUserMedia:Re,alt:null,as:null,async:Re,autoCapitalize:null,autoComplete:lt,autoFocus:Re,autoPlay:Re,blocking:lt,capture:null,charSet:null,checked:Re,cite:null,className:lt,cols:X,colSpan:null,content:null,contentEditable:Mt,controls:Re,controlsList:lt,coords:X|wa,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Re,defer:Re,dir:null,dirName:null,disabled:Re,download:Lv,draggable:Mt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Re,formTarget:null,headers:lt,height:X,hidden:Lv,high:X,href:null,hrefLang:null,htmlFor:lt,httpEquiv:lt,id:null,imageSizes:null,imageSrcSet:null,inert:Re,inputMode:null,integrity:null,is:null,isMap:Re,itemId:null,itemProp:lt,itemRef:lt,itemScope:Re,itemType:lt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Re,low:X,manifest:null,max:null,maxLength:X,media:null,method:null,min:null,minLength:X,multiple:Re,muted:Re,name:null,nonce:null,noModule:Re,noValidate:Re,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:Re,optimum:X,pattern:null,ping:lt,placeholder:null,playsInline:Re,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Re,referrerPolicy:null,rel:lt,required:Re,reversed:Re,rows:X,rowSpan:X,sandbox:lt,scope:null,scoped:Re,seamless:Re,selected:Re,shadowRootClonable:Re,shadowRootDelegatesFocus:Re,shadowRootMode:null,shape:null,size:X,sizes:null,slot:null,span:X,spellCheck:Mt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:X,step:null,style:null,tabIndex:X,target:null,title:null,translate:null,type:null,typeMustMatch:Re,useMap:null,value:Mt,width:X,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:lt,axis:null,background:null,bgColor:null,border:X,borderColor:null,bottomMargin:X,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Re,declare:Re,event:null,face:null,frame:null,frameBorder:null,hSpace:X,leftMargin:X,link:null,longDesc:null,lowSrc:null,marginHeight:X,marginWidth:X,noResize:Re,noHref:Re,noShade:Re,noWrap:Re,object:null,profile:null,prompt:null,rev:null,rightMargin:X,rules:null,scheme:null,scrolling:Mt,standby:null,summary:null,text:null,topMargin:X,valueType:null,version:null,vAlign:null,vLink:null,vSpace:X,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Re,disableRemotePlayback:Re,prefix:null,property:null,results:X,security:null,unselectable:null},space:"html",transform:yR}),T7=Qa({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:Xn,accentHeight:X,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:X,amplitude:X,arabicForm:null,ascent:X,attributeName:null,attributeType:null,azimuth:X,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:X,by:null,calcMode:null,capHeight:X,className:lt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:X,diffuseConstant:X,direction:null,display:null,dur:null,divisor:X,dominantBaseline:null,download:Re,dx:null,dy:null,edgeMode:null,editable:null,elevation:X,enableBackground:null,end:null,event:null,exponent:X,externalResourcesRequired:null,fill:null,fillOpacity:X,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:wa,g2:wa,glyphName:wa,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:X,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:X,horizOriginX:X,horizOriginY:X,id:null,ideographic:X,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:X,k:X,k1:X,k2:X,k3:X,k4:X,kernelMatrix:Xn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:X,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:X,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:X,overlineThickness:X,paintOrder:null,panose1:null,path:null,pathLength:X,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:lt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:X,pointsAtY:X,pointsAtZ:X,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Xn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Xn,rev:Xn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Xn,requiredFeatures:Xn,requiredFonts:Xn,requiredFormats:Xn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:X,specularExponent:X,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:X,strikethroughThickness:X,string:null,stroke:null,strokeDashArray:Xn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:X,strokeOpacity:X,strokeWidth:null,style:null,surfaceScale:X,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Xn,tabIndex:X,tableValues:null,target:null,targetX:X,targetY:X,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Xn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:X,underlineThickness:X,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:X,values:null,vAlphabetic:X,vMathematical:X,vectorEffect:null,vHanging:X,vIdeographic:X,version:null,vertAdvY:X,vertOriginX:X,vertOriginY:X,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:X,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:xR}),bR=Qa({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()}}),wR=Qa({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:yR}),SR=Qa({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),P7={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"},R7=/[A-Z]/g,Aw=/-[a-z]/g,I7=/^data[-\w.:]+$/i;function M7(e,t){const n=Dv(t);let r=t,i=Vn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&I7.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(Aw,j7);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!Aw.test(s)){let o=s.replace(R7,A7);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=Px}return new i(r,t)}function A7(e){return"-"+e.toLowerCase()}function j7(e){return e.charAt(1).toUpperCase()}const D7=vR([_R,N7,bR,wR,SR],"html"),Rx=vR([_R,T7,bR,wR,SR],"svg");function L7(e){return e.join(" ").trim()}var Ix={},jw=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,O7=/\n/g,B7=/^\s*/,z7=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,$7=/^:\s*/,F7=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,H7=/^[;\s]*/,U7=/^\s+|\s+$/g,W7=`
|
|
486
486
|
`,Dw="/",Lw="*",Vs="",V7="comment",q7="declaration";function K7(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(O7);v&&(n+=v.length);var y=m.lastIndexOf(W7);r=~y?m.length-y: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 y=v[0];return i(y),e=e.slice(y.length),v}}function c(){l(B7)}function u(m){var v;for(m=m||[];v=d();)v!==!1&&m.push(v);return m}function d(){var m=s();if(!(Dw!=e.charAt(0)||Lw!=e.charAt(1))){for(var v=2;Vs!=e.charAt(v)&&(Lw!=e.charAt(v)||Dw!=e.charAt(v+1));)++v;if(v+=2,Vs===e.charAt(v-1))return a("End of comment missing");var y=e.slice(2,v-2);return r+=2,i(y),e=e.slice(v),r+=2,m({type:V7,comment:y})}}function f(){var m=s(),v=l(z7);if(v){if(d(),!l($7))return a("property missing ':'");var y=l(F7),_=m({type:q7,property:Ow(v[0].replace(jw,Vs)),value:y?Ow(y[0].replace(jw,Vs)):Vs});return l(H7),_}}function p(){var m=[];u(m);for(var v;v=f();)v!==!1&&(m.push(v),u(m));return m}return c(),p()}function Ow(e){return e?e.replace(U7,Vs):Vs}var G7=K7,X7=Ud&&Ud.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ix,"__esModule",{value:!0});Ix.default=Z7;const Y7=X7(G7);function Z7(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,Y7.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 Gf={};Object.defineProperty(Gf,"__esModule",{value:!0});Gf.camelCase=void 0;var Q7=/^--[a-zA-Z0-9_-]+$/,J7=/-([a-z])/g,eU=/^[^-]+$/,tU=/^-(webkit|moz|ms|o|khtml)-/,nU=/^-(ms)-/,rU=function(e){return!e||eU.test(e)||Q7.test(e)},iU=function(e,t){return t.toUpperCase()},Bw=function(e,t){return"".concat(t,"-")},sU=function(e,t){return t===void 0&&(t={}),rU(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(nU,Bw):e=e.replace(tU,Bw),e.replace(J7,iU))};Gf.camelCase=sU;var oU=Ud&&Ud.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},aU=oU(Ix),lU=Gf;function Bv(e,t){var n={};return!e||typeof e!="string"||(0,aU.default)(e,function(r,i){r&&i&&(n[(0,lU.camelCase)(r,t)]=i)}),n}Bv.default=Bv;var cU=Bv;const uU=Gc(cU),kR=CR("end"),Mx=CR("start");function CR(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 dU(e){const t=Mx(e),n=kR(e);if(t&&n)return{start:t,end:n}}function nc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?zw(e.position):"start"in e||"end"in e?zw(e):"line"in e||"column"in e?zv(e):""}function zv(e){return $w(e&&e.line)+":"+$w(e&&e.column)}function zw(e){return zv(e&&e.start)+"-"+zv(e&&e.end)}function $w(e){return e&&typeof e=="number"?e:1}class wn 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=nc(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}}wn.prototype.file="";wn.prototype.name="";wn.prototype.reason="";wn.prototype.message="";wn.prototype.stack="";wn.prototype.column=void 0;wn.prototype.line=void 0;wn.prototype.ancestors=void 0;wn.prototype.cause=void 0;wn.prototype.fatal=void 0;wn.prototype.place=void 0;wn.prototype.ruleId=void 0;wn.prototype.source=void 0;const Ax={}.hasOwnProperty,hU=new Map,fU=/[A-Z]/g,pU=new Set(["table","tbody","thead","tfoot","tr"]),mU=new Set(["td","th"]),ER="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function gU(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=kU(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=SU(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"?Rx:D7,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=NR(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function NR(e,t,n){if(t.type==="element")return vU(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return _U(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return yU(e,t,n);if(t.type==="mdxjsEsm")return xU(e,t);if(t.type==="root")return bU(e,t,n);if(t.type==="text")return wU(e,t)}function vU(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Rx,e.schema=i),e.ancestors.push(t);const s=PR(e,t.tagName,!1),o=CU(e,t);let a=Dx(e,t);return pU.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!C7(l):!0})),TR(e,o,s,t),jx(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function _U(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)}$c(e,t.position)}function xU(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);$c(e,t.position)}function yU(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Rx,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:PR(e,t.name,!0),o=EU(e,t),a=Dx(e,t);return TR(e,o,s,t),jx(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function bU(e,t,n){const r={};return jx(r,Dx(e,t)),e.create(t,e.Fragment,r,n)}function wU(e,t){return t.value}function TR(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function jx(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function SU(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 kU(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=Mx(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 CU(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Ax.call(t.properties,i)){const s=NU(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&mU.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 EU(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 $c(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 $c(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function Dx(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:hU;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=NR(e,s,o);a!==void 0&&n.push(a)}return n}function NU(e,t,n){const r=M7(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?y7(n):L7(n)),r.property==="style"){let i=typeof n=="object"?n:TU(e,String(n));return e.stylePropertyNameCase==="css"&&(i=PU(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?P7[r.property]||r.property:r.attribute,n]}}function TU(e,t){try{return uU(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new wn("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=ER+"#cannot-parse-style-attribute",i}}function PR(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=Rw(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=Rw(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Ax.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);$c(e)}function $c(e,t){const n=new wn("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=ER+"#cannot-handle-mdx-estrees-without-createevaluater",n}function PU(e){const t={};let n;for(n in e)Ax.call(e,n)&&(t[RU(n)]=e[n]);return t}function RU(e){let t=e.replace(fU,IU);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function IU(e){return"-"+e.toLowerCase()}const om={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"]},MU={};function Lx(e,t){const n=MU,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return RR(e,r,i)}function RR(e,t,n){if(AU(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 Fw(e.children,t,n)}return Array.isArray(e)?Fw(e,t,n):""}function Fw(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=RR(e[i],t,n);return r.join("")}function AU(e){return!!(e&&typeof e=="object")}const Hw=document.createElement("i");function Ox(e){const t="&"+e+";";Hw.innerHTML=t;const n=Hw.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function tr(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 pr(e,t){return e.length>0?(tr(e,e.length,0,t),e):t}const Uw={}.hasOwnProperty;function IR(e){const t={};let n=-1;for(;++n<e.length;)jU(t,e[n]);return t}function jU(e,t){let n;for(n in t){const i=(Uw.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){Uw.call(i,o)||(i[o]=[]);const a=s[o];DU(i[o],Array.isArray(a)?a:a?[a]:[])}}}function DU(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);tr(e,0,0,r)}function MR(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 Ar(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Cn=js(/[A-Za-z]/),yn=js(/[\dA-Za-z]/),LU=js(/[#-'*+\--9=?A-Z^-~]/);function Lh(e){return e!==null&&(e<32||e===127)}const $v=js(/\d/),OU=js(/[\dA-Fa-f]/),BU=js(/[!-/:-@[-`{-~]/);function ye(e){return e!==null&&e<-2}function ot(e){return e!==null&&(e<0||e===32)}function ze(e){return e===-2||e===-1||e===32}const Xf=js(new RegExp("\\p{P}|\\p{S}","u")),vo=js(/\s/);function js(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Ja(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&yn(e.charCodeAt(n+1))&&yn(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 Ve(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return ze(l)?(e.enter(n),a(l)):t(l)}function a(l){return ze(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const zU={tokenize:$U};function $U(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"),Ve(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 ye(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const FU={tokenize:HU},Ww={tokenize:UU};function HU(e){const t=this,n=[];let r=0,i,s,o;return a;function a(b){if(r<n.length){const w=n[r];return t.containerState=w[1],e.attempt(w[0].continuation,l,c)(b)}return c(b)}function l(b){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&x();const w=t.events.length;let S=w,k;for(;S--;)if(t.events[S][0]==="exit"&&t.events[S][1].type==="chunkFlow"){k=t.events[S][1].end;break}_(r);let T=w;for(;T<t.events.length;)t.events[T][1].end={...k},T++;return tr(t.events,S+1,0,t.events.slice(w)),t.events.length=T,c(b)}return a(b)}function c(b){if(r===n.length){if(!i)return f(b);if(i.currentConstruct&&i.currentConstruct.concrete)return m(b);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Ww,u,d)(b)}function u(b){return i&&x(),_(r),f(b)}function d(b){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(b)}function f(b){return t.containerState={},e.attempt(Ww,p,m)(b)}function p(b){return r++,n.push([t.currentConstruct,t.containerState]),f(b)}function m(b){if(b===null){i&&x(),_(0),e.consume(b);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),v(b)}function v(b){if(b===null){y(e.exit("chunkFlow"),!0),_(0),e.consume(b);return}return ye(b)?(e.consume(b),y(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(b),v)}function y(b,w){const S=t.sliceStream(b);if(w&&S.push(null),b.previous=s,s&&(s.next=b),s=b,i.defineSkip(b.start),i.write(S),t.parser.lazy[b.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 T=t.events.length;let N=T,O,P;for(;N--;)if(t.events[N][0]==="exit"&&t.events[N][1].type==="chunkFlow"){if(O){P=t.events[N][1].end;break}O=!0}for(_(r),k=T;k<t.events.length;)t.events[k][1].end={...P},k++;tr(t.events,N+1,0,t.events.slice(T)),t.events.length=k}}function _(b){let w=n.length;for(;w-- >b;){const S=n[w];t.containerState=S[1],S[0].exit.call(t,e)}n.length=b}function x(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function UU(e,t,n){return Ve(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ba(e){if(e===null||ot(e)||vo(e))return 1;if(Xf(e))return 2}function Yf(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 Fv={name:"attention",resolveAll:WU,tokenize:VU};function WU(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};Vw(d,-l),Vw(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=pr(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=pr(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),c=pr(c,Yf(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=pr(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=pr(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):u=0,tr(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 VU(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Ba(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=Ba(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 Vw(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const qU={name:"autolink",tokenize:KU};function KU(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 Cn(p)?(e.consume(p),o):p===64?n(p):c(p)}function o(p){return p===43||p===45||p===46||yn(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||yn(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||Lh(p)?n(p):(e.consume(p),l)}function c(p){return p===64?(e.consume(p),u):LU(p)?(e.consume(p),c):n(p)}function u(p){return yn(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||yn(p))&&r++<63){const m=p===45?f:d;return e.consume(p),m}return n(p)}}const cu={partial:!0,tokenize:GU};function GU(e,t,n){return r;function r(s){return ze(s)?Ve(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||ye(s)?t(s):n(s)}}const AR={continuation:{tokenize:YU},exit:ZU,name:"blockQuote",tokenize:XU};function XU(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 ze(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function YU(e,t,n){const r=this;return i;function i(o){return ze(o)?Ve(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(AR,t,n)(o)}}function ZU(e){e.exit("blockQuote")}const jR={name:"characterEscape",tokenize:QU};function QU(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 BU(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const DR={name:"characterReference",tokenize:JU};function JU(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=yn,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=OU,u):(e.enter("characterReferenceValue"),s=7,o=$v,u(d))}function u(d){if(d===59&&i){const f=e.exit("characterReferenceValue");return o===yn&&!Ox(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 qw={partial:!0,tokenize:tW},Kw={concrete:!0,name:"codeFenced",tokenize:eW};function eW(e,t,n){const r=this,i={partial:!0,tokenize:S};let s=0,o=0,a;return l;function l(k){return c(k)}function c(k){const T=r.events[r.events.length-1];return s=T&&T[1].type==="linePrefix"?T[2].sliceSerialize(T[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"),ze(k)?Ve(e,d,"whitespace")(k):d(k))}function d(k){return k===null||ye(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(qw,v,w)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(k))}function f(k){return k===null||ye(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(k)):ze(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ve(e,p,"whitespace")(k)):k===96&&k===a?n(k):(e.consume(k),f)}function p(k){return k===null||ye(k)?d(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(k))}function m(k){return k===null||ye(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,w,y)(k)}function y(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),_}function _(k){return s>0&&ze(k)?Ve(e,x,"linePrefix",s+1)(k):x(k)}function x(k){return k===null||ye(k)?e.check(qw,v,w)(k):(e.enter("codeFlowValue"),b(k))}function b(k){return k===null||ye(k)?(e.exit("codeFlowValue"),x(k)):(e.consume(k),b)}function w(k){return e.exit("codeFenced"),t(k)}function S(k,T,N){let O=0;return P;function P(B){return k.enter("lineEnding"),k.consume(B),k.exit("lineEnding"),L}function L(B){return k.enter("codeFencedFence"),ze(B)?Ve(k,R,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):R(B)}function R(B){return B===a?(k.enter("codeFencedFenceSequence"),I(B)):N(B)}function I(B){return B===a?(O++,k.consume(B),I):O>=o?(k.exit("codeFencedFenceSequence"),ze(B)?Ve(k,j,"whitespace")(B):j(B)):N(B)}function j(B){return B===null||ye(B)?(k.exit("codeFencedFence"),T(B)):N(B)}}}function tW(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 am={name:"codeIndented",tokenize:rW},nW={partial:!0,tokenize:iW};function rW(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),Ve(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):ye(c)?e.attempt(nW,o,l)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||ye(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),a)}function l(c){return e.exit("codeIndented"),t(c)}}function iW(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):ye(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):Ve(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):ye(o)?i(o):n(o)}}const sW={name:"codeText",previous:aW,resolve:oW,tokenize:lW};function oW(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 aW(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function lW(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)):ye(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||ye(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 cW{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&&yl(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),yl(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),yl(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);yl(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);yl(this.left,n.reverse())}}}function yl(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 LR(e){const t={};let n=-1,r,i,s,o,a,l,c;const u=new cW(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,uW(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 tr(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function uW(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 y=[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,y.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):y.pop(),f=y.length;f--;){const _=a.slice(y[f],y[f+1]),x=s.pop();l.push([x,x+_.length-1]),e.splice(x,2,_)}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 dW={resolve:fW,tokenize:pW},hW={partial:!0,tokenize:mW};function fW(e){return LR(e),e}function pW(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):ye(a)?e.check(hW,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 mW(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Ve(e,s,"linePrefix")}function s(o){if(o===null||ye(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 OR(e,t,n,r,i,s,o,a,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return d;function d(_){return _===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(_),e.exit(s),f):_===null||_===32||_===41||Lh(_)?n(_):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),v(_))}function f(_){return _===62?(e.enter(s),e.consume(_),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(_))}function p(_){return _===62?(e.exit("chunkString"),e.exit(a),f(_)):_===null||_===60||ye(_)?n(_):(e.consume(_),_===92?m:p)}function m(_){return _===60||_===62||_===92?(e.consume(_),p):p(_)}function v(_){return!u&&(_===null||_===41||ot(_))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(_)):u<c&&_===40?(e.consume(_),u++,v):_===41?(e.consume(_),u--,v):_===null||_===32||_===40||Lh(_)?n(_):(e.consume(_),_===92?y:v)}function y(_){return _===40||_===41||_===92?(e.consume(_),v):v(_)}}function BR(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):ye(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||ye(p)||a++>999?(e.exit("chunkString"),u(p)):(e.consume(p),l||(l=!ze(p)),p===92?f:d)}function f(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function zR(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):ye(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Ve(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(f))}function u(f){return f===o||f===null||ye(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 rc(e,t){let n;return r;function r(i){return ye(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):ze(i)?Ve(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const gW={name:"definition",tokenize:_W},vW={partial:!0,tokenize:xW};function _W(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return BR.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=Ar(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 ot(p)?rc(e,c)(p):c(p)}function c(p){return OR(e,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function u(p){return e.attempt(vW,d,d)(p)}function d(p){return ze(p)?Ve(e,f,"whitespace")(p):f(p)}function f(p){return p===null||ye(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function xW(e,t,n){return r;function r(a){return ot(a)?rc(e,i)(a):n(a)}function i(a){return zR(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return ze(a)?Ve(e,o,"whitespace")(a):o(a)}function o(a){return a===null||ye(a)?t(a):n(a)}}const yW={name:"hardBreakEscape",tokenize:bW};function bW(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return ye(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const wW={name:"headingAtx",resolve:SW,tokenize:kW};function SW(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"},tr(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function kW(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||ot(u)?(e.exit("atxHeadingSequence"),a(u)):n(u)}function a(u){return u===35?(e.enter("atxHeadingSequence"),l(u)):u===null||ye(u)?(e.exit("atxHeading"),t(u)):ze(u)?Ve(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||ot(u)?(e.exit("atxHeadingText"),a(u)):(e.consume(u),c)}}const CW=["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"],Gw=["pre","script","style","textarea"],EW={concrete:!0,name:"htmlFlow",resolveTo:PW,tokenize:RW},NW={partial:!0,tokenize:MW},TW={partial:!0,tokenize:IW};function PW(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 RW(e,t,n){const r=this;let i,s,o,a,l;return c;function c(M){return u(M)}function u(M){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(M),d}function d(M){return M===33?(e.consume(M),f):M===47?(e.consume(M),s=!0,v):M===63?(e.consume(M),i=3,r.interrupt?t:C):Cn(M)?(e.consume(M),o=String.fromCharCode(M),y):n(M)}function f(M){return M===45?(e.consume(M),i=2,p):M===91?(e.consume(M),i=5,a=0,m):Cn(M)?(e.consume(M),i=4,r.interrupt?t:C):n(M)}function p(M){return M===45?(e.consume(M),r.interrupt?t:C):n(M)}function m(M){const ne="CDATA[";return M===ne.charCodeAt(a++)?(e.consume(M),a===ne.length?r.interrupt?t:R:m):n(M)}function v(M){return Cn(M)?(e.consume(M),o=String.fromCharCode(M),y):n(M)}function y(M){if(M===null||M===47||M===62||ot(M)){const ne=M===47,oe=o.toLowerCase();return!ne&&!s&&Gw.includes(oe)?(i=1,r.interrupt?t(M):R(M)):CW.includes(o.toLowerCase())?(i=6,ne?(e.consume(M),_):r.interrupt?t(M):R(M)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(M):s?x(M):b(M))}return M===45||yn(M)?(e.consume(M),o+=String.fromCharCode(M),y):n(M)}function _(M){return M===62?(e.consume(M),r.interrupt?t:R):n(M)}function x(M){return ze(M)?(e.consume(M),x):P(M)}function b(M){return M===47?(e.consume(M),P):M===58||M===95||Cn(M)?(e.consume(M),w):ze(M)?(e.consume(M),b):P(M)}function w(M){return M===45||M===46||M===58||M===95||yn(M)?(e.consume(M),w):S(M)}function S(M){return M===61?(e.consume(M),k):ze(M)?(e.consume(M),S):b(M)}function k(M){return M===null||M===60||M===61||M===62||M===96?n(M):M===34||M===39?(e.consume(M),l=M,T):ze(M)?(e.consume(M),k):N(M)}function T(M){return M===l?(e.consume(M),l=null,O):M===null||ye(M)?n(M):(e.consume(M),T)}function N(M){return M===null||M===34||M===39||M===47||M===60||M===61||M===62||M===96||ot(M)?S(M):(e.consume(M),N)}function O(M){return M===47||M===62||ze(M)?b(M):n(M)}function P(M){return M===62?(e.consume(M),L):n(M)}function L(M){return M===null||ye(M)?R(M):ze(M)?(e.consume(M),L):n(M)}function R(M){return M===45&&i===2?(e.consume(M),$):M===60&&i===1?(e.consume(M),F):M===62&&i===4?(e.consume(M),H):M===63&&i===3?(e.consume(M),C):M===93&&i===5?(e.consume(M),D):ye(M)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(NW,q,I)(M)):M===null||ye(M)?(e.exit("htmlFlowData"),I(M)):(e.consume(M),R)}function I(M){return e.check(TW,j,q)(M)}function j(M){return e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),B}function B(M){return M===null||ye(M)?I(M):(e.enter("htmlFlowData"),R(M))}function $(M){return M===45?(e.consume(M),C):R(M)}function F(M){return M===47?(e.consume(M),o="",A):R(M)}function A(M){if(M===62){const ne=o.toLowerCase();return Gw.includes(ne)?(e.consume(M),H):R(M)}return Cn(M)&&o.length<8?(e.consume(M),o+=String.fromCharCode(M),A):R(M)}function D(M){return M===93?(e.consume(M),C):R(M)}function C(M){return M===62?(e.consume(M),H):M===45&&i===2?(e.consume(M),C):R(M)}function H(M){return M===null||ye(M)?(e.exit("htmlFlowData"),q(M)):(e.consume(M),H)}function q(M){return e.exit("htmlFlow"),t(M)}}function IW(e,t,n){const r=this;return i;function i(o){return ye(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 MW(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(cu,t,n)}}const AW={name:"htmlText",tokenize:jW};function jW(e,t,n){const r=this;let i,s,o;return a;function a(C){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(C),l}function l(C){return C===33?(e.consume(C),c):C===47?(e.consume(C),S):C===63?(e.consume(C),b):Cn(C)?(e.consume(C),N):n(C)}function c(C){return C===45?(e.consume(C),u):C===91?(e.consume(C),s=0,m):Cn(C)?(e.consume(C),x):n(C)}function u(C){return C===45?(e.consume(C),p):n(C)}function d(C){return C===null?n(C):C===45?(e.consume(C),f):ye(C)?(o=d,F(C)):(e.consume(C),d)}function f(C){return C===45?(e.consume(C),p):d(C)}function p(C){return C===62?$(C):C===45?f(C):d(C)}function m(C){const H="CDATA[";return C===H.charCodeAt(s++)?(e.consume(C),s===H.length?v:m):n(C)}function v(C){return C===null?n(C):C===93?(e.consume(C),y):ye(C)?(o=v,F(C)):(e.consume(C),v)}function y(C){return C===93?(e.consume(C),_):v(C)}function _(C){return C===62?$(C):C===93?(e.consume(C),_):v(C)}function x(C){return C===null||C===62?$(C):ye(C)?(o=x,F(C)):(e.consume(C),x)}function b(C){return C===null?n(C):C===63?(e.consume(C),w):ye(C)?(o=b,F(C)):(e.consume(C),b)}function w(C){return C===62?$(C):b(C)}function S(C){return Cn(C)?(e.consume(C),k):n(C)}function k(C){return C===45||yn(C)?(e.consume(C),k):T(C)}function T(C){return ye(C)?(o=T,F(C)):ze(C)?(e.consume(C),T):$(C)}function N(C){return C===45||yn(C)?(e.consume(C),N):C===47||C===62||ot(C)?O(C):n(C)}function O(C){return C===47?(e.consume(C),$):C===58||C===95||Cn(C)?(e.consume(C),P):ye(C)?(o=O,F(C)):ze(C)?(e.consume(C),O):$(C)}function P(C){return C===45||C===46||C===58||C===95||yn(C)?(e.consume(C),P):L(C)}function L(C){return C===61?(e.consume(C),R):ye(C)?(o=L,F(C)):ze(C)?(e.consume(C),L):O(C)}function R(C){return C===null||C===60||C===61||C===62||C===96?n(C):C===34||C===39?(e.consume(C),i=C,I):ye(C)?(o=R,F(C)):ze(C)?(e.consume(C),R):(e.consume(C),j)}function I(C){return C===i?(e.consume(C),i=void 0,B):C===null?n(C):ye(C)?(o=I,F(C)):(e.consume(C),I)}function j(C){return C===null||C===34||C===39||C===60||C===61||C===96?n(C):C===47||C===62||ot(C)?O(C):(e.consume(C),j)}function B(C){return C===47||C===62||ot(C)?O(C):n(C)}function $(C){return C===62?(e.consume(C),e.exit("htmlTextData"),e.exit("htmlText"),t):n(C)}function F(C){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),A}function A(C){return ze(C)?Ve(e,D,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):D(C)}function D(C){return e.enter("htmlTextData"),o(C)}}const Bx={name:"labelEnd",resolveAll:BW,resolveTo:zW,tokenize:$W},DW={tokenize:FW},LW={tokenize:HW},OW={tokenize:UW};function BW(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&&tr(e,0,e.length,n),e}function zW(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=pr(a,e.slice(s+1,s+r+3)),a=pr(a,[["enter",u,t]]),a=pr(a,Yf(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=pr(a,[["exit",u,t],e[o-2],e[o-1],["exit",c,t]]),a=pr(a,e.slice(o+1)),a=pr(a,[["exit",l,t]]),tr(e,s,e.length,a),e}function $W(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(Ar(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(DW,u,o?u:d)(f):f===91?e.attempt(LW,u,o?c:d)(f):o?u(f):d(f)}function c(f){return e.attempt(OW,u,d)(f)}function u(f){return t(f)}function d(f){return s._balanced=!0,n(f)}}function FW(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 ot(d)?rc(e,s)(d):s(d)}function s(d){return d===41?u(d):OR(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function o(d){return ot(d)?rc(e,l)(d):u(d)}function a(d){return n(d)}function l(d){return d===34||d===39||d===40?zR(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):u(d)}function c(d){return ot(d)?rc(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 HW(e,t,n){const r=this;return i;function i(a){return BR.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Ar(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function UW(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 WW={name:"labelStartImage",resolveAll:Bx.resolveAll,tokenize:VW};function VW(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 qW={name:"labelStartLink",resolveAll:Bx.resolveAll,tokenize:KW};function KW(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 lm={name:"lineEnding",tokenize:GW};function GW(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ve(e,t,"linePrefix")}}const jd={name:"thematicBreak",tokenize:XW};function XW(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||ye(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),ze(c)?Ve(e,a,"whitespace")(c):a(c))}}const zn={continuation:{tokenize:JW},exit:tV,name:"list",tokenize:QW},YW={partial:!0,tokenize:nV},ZW={partial:!0,tokenize:eV};function QW(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:$v(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(jd,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 $v(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(cu,r.interrupt?n:u,e.attempt(YW,f,d))}function u(p){return r.containerState.initialBlankLine=!0,s++,f(p)}function d(p){return ze(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 JW(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(cu,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ve(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!ze(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(ZW,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ve(e,e.attempt(zn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function eV(e,t,n){const r=this;return Ve(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 tV(e){e.exit(this.containerState.type)}function nV(e,t,n){const r=this;return Ve(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!ze(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const Xw={name:"setextUnderline",resolveTo:rV,tokenize:iV};function rV(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 iV(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"),ze(c)?Ve(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||ye(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const sV={tokenize:oV};function oV(e){const t=this,n=e.attempt(cu,r,e.attempt(this.parser.constructs.flowInitial,i,Ve(e,e.attempt(this.parser.constructs.flow,i,e.attempt(dW,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 aV={resolveAll:FR()},lV=$R("string"),cV=$R("text");function $R(e){return{resolveAll:FR(e==="text"?uV: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 FR(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 uV(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 dV={42:zn,43:zn,45:zn,48:zn,49:zn,50:zn,51:zn,52:zn,53:zn,54:zn,55:zn,56:zn,57:zn,62:AR},hV={91:gW},fV={[-2]:am,[-1]:am,32:am},pV={35:wW,42:jd,45:[Xw,jd],60:EW,61:Xw,95:jd,96:Kw,126:Kw},mV={38:DR,92:jR},gV={[-5]:lm,[-4]:lm,[-3]:lm,33:WW,38:DR,42:Fv,60:[qU,AW],91:qW,92:[yW,jR],93:Bx,95:Fv,96:sW},vV={null:[Fv,aV]},_V={null:[42,95]},xV={null:[]},yV=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:_V,contentInitial:hV,disable:xV,document:dV,flow:pV,flowInitial:fV,insideSpan:vV,string:mV,text:gV},Symbol.toStringTag,{value:"Module"}));function bV(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:T(S),check:T(k),consume:x,enter:b,exit:w,interrupt:T(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(L){return o=pr(o,L),y(),o[o.length-1]!==null?[]:(N(t,0),c.events=Yf(s,c.events,c),c.events)}function f(L,R){return SV(p(L),R)}function p(L){return wV(o,L)}function m(){const{_bufferIndex:L,_index:R,line:I,column:j,offset:B}=r;return{_bufferIndex:L,_index:R,line:I,column:j,offset:B}}function v(L){i[L.line]=L.column,P()}function y(){let L;for(;r._index<o.length;){const R=o[r._index];if(typeof R=="string")for(L=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===L&&r._bufferIndex<R.length;)_(R.charCodeAt(r._bufferIndex));else _(R)}}function _(L){u=u(L)}function x(L){ye(L)?(r.line++,r.column=1,r.offset+=L===-3?2:1,P()):L!==-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=L}function b(L,R){const I=R||{};return I.type=L,I.start=m(),c.events.push(["enter",I,c]),a.push(I),I}function w(L){const R=a.pop();return R.end=m(),c.events.push(["exit",R,c]),R}function S(L,R){N(L,R.from)}function k(L,R){R.restore()}function T(L,R){return I;function I(j,B,$){let F,A,D,C;return Array.isArray(j)?q(j):"tokenize"in j?q([j]):H(j);function H(V){return pe;function pe(Oe){const re=Oe!==null&&V[Oe],Me=Oe!==null&&V.null,Fe=[...Array.isArray(re)?re:re?[re]:[],...Array.isArray(Me)?Me:Me?[Me]:[]];return q(Fe)(Oe)}}function q(V){return F=V,A=0,V.length===0?$:M(V[A])}function M(V){return pe;function pe(Oe){return C=O(),D=V,V.partial||(c.currentConstruct=V),V.name&&c.parser.constructs.disable.null.includes(V.name)?oe():V.tokenize.call(R?Object.assign(Object.create(c),R):c,l,ne,oe)(Oe)}}function ne(V){return L(D,C),B}function oe(V){return C.restore(),++A<F.length?M(F[A]):$}}}function N(L,R){L.resolveAll&&!s.includes(L)&&s.push(L),L.resolve&&tr(c.events,R,c.events.length-R,L.resolve(c.events.slice(R),c)),L.resolveTo&&(c.events=L.resolveTo(c.events,c))}function O(){const L=m(),R=c.previous,I=c.currentConstruct,j=c.events.length,B=Array.from(a);return{from:j,restore:$};function $(){r=L,c.previous=R,c.currentConstruct=I,c.events.length=j,a=B,P()}}function P(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function wV(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 SV(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=`
|
|
487
487
|
`;break}case-3:{o=`\r
|
|
488
488
|
`;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 kV(e){const r={constructs:IR([yV,...(e||{}).extensions||[]]),content:i(zU),defined:[],document:i(FU),flow:i(sV),lazy:{},string:i(lV),text:i(cV)};return r;function i(s){return o;function o(a){return bV(r,s,a)}}}function CV(e){for(;!LR(e););return e}const Yw=/[\0\t\n\r]/g;function EV(){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(Yw.lastIndex=d,c=Yw.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 NV=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function TV(e){return e.replace(NV,PV)}function PV(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return MR(n.slice(s?2:1),s?16:10)}return Ox(n)||e}const HR={}.hasOwnProperty;function RV(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),IV(n)(CV(kV(n).document().write(EV()(e,t,!0))))}function IV(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(Bt),autolinkProtocol:O,autolinkEmail:O,atxHeading:s(Gt),blockQuote:s(Me),characterEscape:O,characterReference:O,codeFenced:s(Fe),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Fe,o),codeText:s(We,o),codeTextData:O,data:O,codeFlowValue:O,definition:s(ge),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(Ge),hardBreakEscape:s(wt),hardBreakTrailing:s(wt),htmlFlow:s(It,o),htmlFlowData:O,htmlText:s(It,o),htmlTextData:O,image:s(ln),label:o,link:s(Bt),listItem:s(Ue),listItemValue:f,listOrdered:s(at,d),listUnordered:s(at),paragraph:s(tt),reference:M,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(Gt),strong:s(mt),thematicBreak:s(pn)},exit:{atxHeading:l(),atxHeadingSequence:S,autolink:l(),autolinkEmail:re,autolinkProtocol:Oe,blockQuote:l(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:oe,characterReferenceMarkerNumeric:oe,characterReferenceValue:V,characterReference:pe,codeFenced:l(y),codeFencedFence:v,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:P,codeIndented:l(_),codeText:l(B),codeTextData:P,data:P,definition:l(),definitionDestinationString:w,definitionLabelString:x,definitionTitleString:b,emphasis:l(),hardBreakEscape:l(R),hardBreakTrailing:l(R),htmlFlow:l(I),htmlFlowData:P,htmlText:l(j),htmlTextData:P,image:l(F),label:D,labelText:A,lineEnding:L,link:l($),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ne,resourceDestinationString:C,resourceTitleString:H,resource:q,setextHeading:l(N),setextHeadingLineSequence:T,setextHeadingText:k,strong:l(),thematicBreak:l()}};UR(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(U){let Z={type:"root",children:[]};const ve={stack:[Z],tokenStack:[],config:t,enter:a,exit:c,buffer:o,resume:u,data:n},we=[];let Q=-1;for(;++Q<U.length;)if(U[Q][1].type==="listOrdered"||U[Q][1].type==="listUnordered")if(U[Q][0]==="enter")we.push(Q);else{const Xe=we.pop();Q=i(U,Xe,Q)}for(Q=-1;++Q<U.length;){const Xe=t[U[Q][0]];HR.call(Xe,U[Q][1].type)&&Xe[U[Q][1].type].call(Object.assign({sliceSerialize:U[Q][2].sliceSerialize},ve),U[Q][1])}if(ve.tokenStack.length>0){const Xe=ve.tokenStack[ve.tokenStack.length-1];(Xe[1]||Zw).call(ve,void 0,Xe[0])}for(Z.position={start:Gi(U.length>0?U[0][1].start:{line:1,column:1,offset:0}),end:Gi(U.length>0?U[U.length-2][1].end:{line:1,column:1,offset:0})},Q=-1;++Q<t.transforms.length;)Z=t.transforms[Q](Z)||Z;return Z}function i(U,Z,ve){let we=Z-1,Q=-1,Xe=!1,Yt,Zt,ue,Ne;for(;++we<=ve;){const Qe=U[we];switch(Qe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Qe[0]==="enter"?Q++:Q--,Ne=void 0;break}case"lineEndingBlank":{Qe[0]==="enter"&&(Yt&&!Ne&&!Q&&!ue&&(ue=we),Ne=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Ne=void 0}if(!Q&&Qe[0]==="enter"&&Qe[1].type==="listItemPrefix"||Q===-1&&Qe[0]==="exit"&&(Qe[1].type==="listUnordered"||Qe[1].type==="listOrdered")){if(Yt){let Dn=we;for(Zt=void 0;Dn--;){const Qt=U[Dn];if(Qt[1].type==="lineEnding"||Qt[1].type==="lineEndingBlank"){if(Qt[0]==="exit")continue;Zt&&(U[Zt][1].type="lineEndingBlank",Xe=!0),Qt[1].type="lineEnding",Zt=Dn}else if(!(Qt[1].type==="linePrefix"||Qt[1].type==="blockQuotePrefix"||Qt[1].type==="blockQuotePrefixWhitespace"||Qt[1].type==="blockQuoteMarker"||Qt[1].type==="listItemIndent"))break}ue&&(!Zt||ue<Zt)&&(Yt._spread=!0),Yt.end=Object.assign({},Zt?U[Zt][1].start:Qe[1].end),U.splice(Zt||we,0,["exit",Yt,Qe[2]]),we++,ve++}if(Qe[1].type==="listItemPrefix"){const Dn={type:"listItem",_spread:!1,start:Object.assign({},Qe[1].start),end:void 0};Yt=Dn,U.splice(we,0,["enter",Dn,Qe[2]]),we++,ve++,ue=void 0,Ne=!0}}}return U[Z][1]._spread=Xe,ve}function s(U,Z){return ve;function ve(we){a.call(this,U(we),we),Z&&Z.call(this,we)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(U,Z,ve){this.stack[this.stack.length-1].children.push(U),this.stack.push(U),this.tokenStack.push([Z,ve||void 0]),U.position={start:Gi(Z.start),end:void 0}}function l(U){return Z;function Z(ve){U&&U.call(this,ve),c.call(this,ve)}}function c(U,Z){const ve=this.stack.pop(),we=this.tokenStack.pop();if(we)we[0].type!==U.type&&(Z?Z.call(this,U,we[0]):(we[1]||Zw).call(this,U,we[0]));else throw new Error("Cannot close `"+U.type+"` ("+nc({start:U.start,end:U.end})+"): it’s not open");ve.position.end=Gi(U.end)}function u(){return Lx(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(U){if(this.data.expectingFirstListItemValue){const Z=this.stack[this.stack.length-2];Z.start=Number.parseInt(this.sliceSerialize(U),10),this.data.expectingFirstListItemValue=void 0}}function p(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.lang=U}function m(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.meta=U}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function y(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.value=U.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function _(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.value=U.replace(/(\r?\n|\r)$/g,"")}function x(U){const Z=this.resume(),ve=this.stack[this.stack.length-1];ve.label=Z,ve.identifier=Ar(this.sliceSerialize(U)).toLowerCase()}function b(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.title=U}function w(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.url=U}function S(U){const Z=this.stack[this.stack.length-1];if(!Z.depth){const ve=this.sliceSerialize(U).length;Z.depth=ve}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function T(U){const Z=this.stack[this.stack.length-1];Z.depth=this.sliceSerialize(U).codePointAt(0)===61?1:2}function N(){this.data.setextHeadingSlurpLineEnding=void 0}function O(U){const ve=this.stack[this.stack.length-1].children;let we=ve[ve.length-1];(!we||we.type!=="text")&&(we=Xt(),we.position={start:Gi(U.start),end:void 0},ve.push(we)),this.stack.push(we)}function P(U){const Z=this.stack.pop();Z.value+=this.sliceSerialize(U),Z.position.end=Gi(U.end)}function L(U){const Z=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ve=Z.children[Z.children.length-1];ve.position.end=Gi(U.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Z.type)&&(O.call(this,U),P.call(this,U))}function R(){this.data.atHardBreak=!0}function I(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.value=U}function j(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.value=U}function B(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.value=U}function $(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const Z=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=Z,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 Z=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=Z,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function A(U){const Z=this.sliceSerialize(U),ve=this.stack[this.stack.length-2];ve.label=TV(Z),ve.identifier=Ar(Z).toLowerCase()}function D(){const U=this.stack[this.stack.length-1],Z=this.resume(),ve=this.stack[this.stack.length-1];if(this.data.inReference=!0,ve.type==="link"){const we=U.children;ve.children=we}else ve.alt=Z}function C(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.url=U}function H(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.title=U}function q(){this.data.inReference=void 0}function M(){this.data.referenceType="collapsed"}function ne(U){const Z=this.resume(),ve=this.stack[this.stack.length-1];ve.label=Z,ve.identifier=Ar(this.sliceSerialize(U)).toLowerCase(),this.data.referenceType="full"}function oe(U){this.data.characterReferenceType=U.type}function V(U){const Z=this.sliceSerialize(U),ve=this.data.characterReferenceType;let we;ve?(we=MR(Z,ve==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):we=Ox(Z);const Q=this.stack[this.stack.length-1];Q.value+=we}function pe(U){const Z=this.stack.pop();Z.position.end=Gi(U.end)}function Oe(U){P.call(this,U);const Z=this.stack[this.stack.length-1];Z.url=this.sliceSerialize(U)}function re(U){P.call(this,U);const Z=this.stack[this.stack.length-1];Z.url="mailto:"+this.sliceSerialize(U)}function Me(){return{type:"blockquote",children:[]}}function Fe(){return{type:"code",lang:null,meta:null,value:""}}function We(){return{type:"inlineCode",value:""}}function ge(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ge(){return{type:"emphasis",children:[]}}function Gt(){return{type:"heading",depth:0,children:[]}}function wt(){return{type:"break"}}function It(){return{type:"html",value:""}}function ln(){return{type:"image",title:null,url:"",alt:null}}function Bt(){return{type:"link",title:null,url:"",children:[]}}function at(U){return{type:"list",ordered:U.type==="listOrdered",start:null,spread:U._spread,children:[]}}function Ue(U){return{type:"listItem",spread:U._spread,checked:null,children:[]}}function tt(){return{type:"paragraph",children:[]}}function mt(){return{type:"strong",children:[]}}function Xt(){return{type:"text",value:""}}function pn(){return{type:"thematicBreak"}}}function Gi(e){return{line:e.line,column:e.column,offset:e.offset}}function UR(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?UR(e,r):MV(e,r)}}function MV(e,t){let n;for(n in t)if(HR.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 Zw(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+nc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+nc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+nc({start:t.start,end:t.end})+") is still open")}function AV(e){const t=this;t.parser=n;function n(r){return RV(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function jV(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 DV(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -513,7 +513,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
513
513
|
`))}function l(p,m,v,y){const _=v.enter("tableCell"),x=v.enter("phrasing"),b=v.containerPhrasing(p,{...y,before:s,after:s});return x(),_(),b}function c(p,m){return OK(p,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function u(p,m,v){const y=p.children;let _=-1;const x=[],b=m.enter("table");for(;++_<y.length;)x[_]=d(y[_],m,v);return b(),x}function d(p,m,v){const y=p.children;let _=-1;const x=[],b=m.enter("tableRow");for(;++_<y.length;)x[_]=l(y[_],p,m,v);return b(),x}function f(p,m,v){let y=fI.inlineCode(p,m,v);return v.stack.includes("tableCell")&&(y=y.replace(/\|/g,"\\$&")),y}}function kG(){return{exit:{taskListCheckValueChecked:SS,taskListCheckValueUnchecked:SS,paragraph:EG}}}function CG(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:NG}}}function SS(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function EG(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 NG(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=fI.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 TG(){return[oK(),NK(),IK(),vG(),kG()]}function PG(e){return{extensions:[aK(),TK(e),MK(),SG(e),CG()]}}const RG={tokenize:LG,partial:!0},pI={tokenize:OG,partial:!0},mI={tokenize:BG,partial:!0},gI={tokenize:zG,partial:!0},IG={tokenize:$G,partial:!0},vI={name:"wwwAutolink",tokenize:jG,previous:xI},_I={name:"protocolAutolink",tokenize:DG,previous:yI},$i={name:"emailAutolink",tokenize:AG,previous:bI},ui={};function MG(){return{text:ui}}let Bs=48;for(;Bs<123;)ui[Bs]=$i,Bs++,Bs===58?Bs=65:Bs===91&&(Bs=97);ui[43]=$i;ui[45]=$i;ui[46]=$i;ui[95]=$i;ui[72]=[$i,_I];ui[104]=[$i,_I];ui[87]=[$i,vI];ui[119]=[$i,vI];function AG(e,t,n){const r=this;let i,s;return o;function o(d){return!qv(d)||!bI.call(r,r.previous)||Kx(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(d))}function a(d){return qv(d)?(e.consume(d),a):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(IG,u,c)(d):d===45||d===95||yn(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&&Cn(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function jG(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!xI.call(r,r.previous)||Kx(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(RG,e.attempt(pI,e.attempt(mI,s),n),n)(o))}function s(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function DG(e,t,n){const r=this;let i="",s=!1;return o;function o(d){return(d===72||d===104)&&yI.call(r,r.previous)&&!Kx(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),e.consume(d),a):n(d)}function a(d){if(Cn(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||Lh(d)||ot(d)||vo(d)||Xf(d)?n(d):e.attempt(pI,e.attempt(mI,u),n)(d)}function u(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function LG(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 OG(e,t,n){let r,i,s;return o;function o(c){return c===46||c===95?e.check(gI,l,a)(c):c===null||ot(c)||vo(c)||c!==45&&Xf(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 BG(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(gI,t,s)(o):o===null||ot(o)||vo(o)?t(o):(e.consume(o),i)}function s(o){return o===41&&r++,e.consume(o),i}}function zG(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||ot(a)||vo(a)?t(a):n(a)}function i(a){return a===null||a===40||a===91||ot(a)||vo(a)?t(a):r(a)}function s(a){return Cn(a)?o(a):n(a)}function o(a){return a===59?(e.consume(a),r):Cn(a)?(e.consume(a),o):n(a)}}function $G(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return yn(s)?n(s):t(s)}}function xI(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||ot(e)}function yI(e){return!Cn(e)}function bI(e){return!(e===47||qv(e))}function qv(e){return e===43||e===45||e===46||e===95||yn(e)}function Kx(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 FG={tokenize:XG,partial:!0};function HG(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:qG,continuation:{tokenize:KG},exit:GG}},text:{91:{name:"gfmFootnoteCall",tokenize:VG},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:UG,resolveTo:WG}}}}function UG(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=Ar(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 WG(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 VG(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||ot(d))return n(d);if(d===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return i.includes(Ar(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return ot(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 qG(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||ot(m))return n(m);if(m===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return s=Ar(r.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return ot(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),Ve(e,p,"gfmFootnoteDefinitionWhitespace")):n(m)}function p(m){return t(m)}}function KG(e,t,n){return e.check(cu,t,e.attempt(FG,t,n))}function GG(e){e.exit("gfmFootnoteDefinition")}function XG(e,t,n){const r=this;return Ve(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 YG(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&&tr(f,f.length,0,Yf(p,o.slice(c+1,l),a)),tr(f,f.length,0,[["exit",d,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",u,a]]),tr(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=Ba(c);if(m===126)return d>1?l(m):(o.consume(m),d++,p);if(d<2&&!n)return l(m);const y=o.exit("strikethroughSequenceTemporary"),_=Ba(m);return y._open=!_||_===2&&!!v,y._close=!v||v===2&&!!_,a(m)}}}class ZG{constructor(){this.map=[]}add(t,n,r){QG(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 QG(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 JG(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 eX(){return{flow:{null:{name:"table",tokenize:tX,resolveAll:nX}}}}function tX(e,t,n){const r=this;let i=0,s=0,o;return a;function a(P){let L=r.events.length-1;for(;L>-1;){const j=r.events[L][1].type;if(j==="lineEnding"||j==="linePrefix")L--;else break}const R=L>-1?r.events[L][1].type:null,I=R==="tableHead"||R==="tableRow"?k:l;return I===k&&r.parser.lazy[r.now().line]?n(P):I(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):ye(P)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),p):n(P):ze(P)?Ve(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||ot(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,ze(P)?Ve(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):m(P))}function m(P){return P===45||P===58?y(P):P===124?(o=!0,e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),v):S(P)}function v(P){return ze(P)?Ve(e,y,"whitespace")(P):y(P)}function y(P){return P===58?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),_):P===45?(s+=1,_(P)):P===null||ye(P)?w(P):S(P)}function _(P){return P===45?(e.enter("tableDelimiterFiller"),x(P)):S(P)}function x(P){return P===45?(e.consume(P),x):P===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),b):(e.exit("tableDelimiterFiller"),b(P))}function b(P){return ze(P)?Ve(e,w,"whitespace")(P):w(P)}function w(P){return P===124?m(P):P===null||ye(P)?!o||i!==s?S(P):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(P)):S(P)}function S(P){return n(P)}function k(P){return e.enter("tableRow"),T(P)}function T(P){return P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),T):P===null||ye(P)?(e.exit("tableRow"),t(P)):ze(P)?Ve(e,T,"whitespace")(P):(e.enter("data"),N(P))}function N(P){return P===null||P===124||ot(P)?(e.exit("data"),T(P)):(e.consume(P),P===92?O:N)}function O(P){return P===92||P===124?(e.consume(P),N):N(P)}}function nX(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 ZG;for(;++n<e.length;){const p=e[n],m=p[1];p[0]==="enter"?m.type==="tableHead"?(a=!1,l!==0&&(kS(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=od(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=od(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=od(f,t,s,i,n,d)):o[1]!==0&&(d=od(f,t,o,i,n,d)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&kS(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=JG(t.events,n))}return e}function od(e,t,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},Go(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=Go(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=Go(t.events,n[2]),u=Go(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({},Go(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function kS(e,t,n,r,i){const s=[],o=Go(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 Go(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const rX={name:"tasklistCheck",tokenize:sX};function iX(){return{text:{91:rX}}}function sX(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 ot(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 ye(l)?t(l):ze(l)?e.check({tokenize:oX},t,n)(l):n(l)}}function oX(e,t,n){return Ve(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function aX(e){return IR([MG(),HG(),YG(e),eX(),iX()])}const lX={};function Uc(e){const t=this,n=e||lX,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(aX(n)),s.push(TG()),o.push(PG(n))}const cX=/<command-name>([\s\S]*?)<\/command-name>/i,uX=/<command-message>([\s\S]*?)<\/command-message>/i,dX=/<command-args>([\s\S]*?)<\/command-args>/i,hX=/<(local-command-[a-z]+|command-(?:stdout|stderr))>[\s\S]*?<\/\1>/gi;function ep(e){if(!e)return{commandName:null,commandMessage:null,commandArgs:null,body:""};const t=e.match(cX),n=e.match(uX),r=e.match(dX);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(hX,""),i=i.trim(),{commandName:t?t[1].trim():null,commandMessage:n?n[1].trim():null,commandArgs:r?r[1].trim():null,body:i}}const Wc={a:({node:e,...t})=>h.jsx("a",{...t,target:"_blank",rel:"noopener noreferrer"})};function fX({text:e,forkTarget:t}){const{body:n}=ep(e);return n?h.jsxs("div",{className:"group 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(Fc,{remarkPlugins:[Uc],components:Wc,children:n})}),t?h.jsxs("div",{className:"mt-1 flex flex-row items-center gap-1",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(PN,{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(MN,{className:"w-3 h-3",strokeWidth:2}),h.jsx("span",{className:"hidden md:inline",children:"问一下"})]}):null]}):null]}):null}function pX({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(ai,{className:"w-3 h-3"}):h.jsx(li,{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}function wI(e){if(!e)return!1;const n=e.split("#")[0].split("?")[0].toLowerCase();return n.endsWith(".md")||n.endsWith(".markdown")}const mX=new Set(["Write","Edit","MultiEdit","NotebookEdit"]);function Kv(e){return mX.has(e)}function gX({tool:e,relPath:t,scope:n,onShareFile:r}){if(!Kv(e)||!t||!n||!r)return null;const i=wI(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(W_,{className:"h-3.5 w-3.5"})})})}function vX(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 SI(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 _X({url:e,bearerToken:t,alt:n,className:r}){const i=SI(e,t);return h.jsxs("div",{"data-testid":"blob-image","data-state":i.kind,className:se("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(rr,{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(Is,{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 xX({url:e,bearerToken:t,className:n}){const r=SI(e,t);return h.jsxs("div",{"data-testid":"blob-video","data-state":r.kind,className:se("relative inline-flex items-center justify-center rounded-md border border-border bg-bg-0",n),children:[r.kind==="loading"?h.jsx(rr,{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 yX=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg"]),bX=new Set([".mp4",".webm",".mov"]),wX=new Set([".pdf"]);function SX(e){const t=e.lastIndexOf("."),n=t>=0?e.slice(t).toLowerCase():"";return yX.has(n)?"image":bX.has(n)?"video":wX.has(n)?"pdf":"binary"}function kI(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function kX({relPath:e,scope:t,size:n}){const r=Rf();if(r.actionsLevel==="none")return null;const i=IO(r,t,e);if(!i)return null;const s=SX(e);return s==="image"?h.jsx("div",{"data-testid":"file-edit-inline-preview","data-kind":"image",className:"mt-2",children:h.jsx(_X,{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(xX,{url:i,bearerToken:r.httpToken})}):s==="pdf"?h.jsx(CX,{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(Ms,{className:"h-3 w-3"}),h.jsx("span",{className:"font-mono",children:e.split("/").pop()}),h.jsx("span",{children:"·"}),h.jsx("span",{children:kI(n)})]}):null}function CX({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(Ms,{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:kI(n)})]}):null,h.jsx(Ic,{className:"h-3 w-3"})]})}const EX={Bash:LN,Read:Ms,Edit:jN,Write:UB,Grep:wv,Glob:wv};function NX(e){return EX[e]??W6}function TX(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 CI({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=NX(e),m=TX(t),v=vX(t);return h.jsxs("div",{"data-testid":"msg-line-tool","data-tool":e,className:se("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(y=>!y),"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(Is,{className:"w-4 h-4 text-destructive shrink-0"}):h.jsx(p,{className:se("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||!Kv(e)||!v)return null;const _=wI(v)&&l?l:a;return _?h.jsx("span",{role:"button",tabIndex:0,"data-testid":"msg-line-tool-preview","data-clickable":"true",title:m,onClick:x=>{x.stopPropagation(),_(v)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.stopPropagation(),x.preventDefault(),_(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(rr,{"data-testid":"msg-line-tool-pending",className:"w-3 h-3 text-text-400 animate-spin shrink-0"}):null,!f&&o?h.jsx(gX,{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&&Kv(e)?h.jsx(kX,{relPath:v,scope:o}):null]})}var PX=Symbol.for("react.lazy"),$h=Fa[" use ".trim().toString()];function RX(e){return typeof e=="object"&&e!==null&&"then"in e}function EI(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===PX&&"_payload"in e&&RX(e._payload)}function IX(e){const t=AX(e),n=g.forwardRef((r,i)=>{let{children:s,...o}=r;EI(s)&&typeof $h=="function"&&(s=$h(s._payload));const a=g.Children.toArray(s),l=a.find(DX);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 MX=IX("Slot");function AX(e){const t=g.forwardRef((n,r)=>{let{children:i,...s}=n;if(EI(i)&&typeof $h=="function"&&(i=$h(i._payload)),g.isValidElement(i)){const o=OX(i),a=LX(s,i.props);return i.type!==g.Fragment&&(a.ref=r?ru(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 jX=Symbol("radix.slottable");function DX(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===jX}function LX(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 OX(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 CS=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,ES=zN,BX=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return ES(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=CS(u)||CS(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,y]=m;return Array.isArray(y)?y.includes({...s,...a}[v]):{...s,...a}[v]===y})?[...c,d,f]:c},[]);return ES(e,o,l,n==null?void 0:n.class,n==null?void 0:n.className)},zX=BX("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"}}),ni=g.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...i},s)=>{const o=r?MX:"button";return h.jsx(o,{ref:s,className:se(zX({variant:t,size:n}),e),...i})});ni.displayName="Button";function $X({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(M6,{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(AN,{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(ni,{size:"sm",variant:"default",onClick:()=>n(!0,!1),"data-testid":"msg-line-permission-allow",children:"Allow"}),h.jsx(ni,{size:"sm",variant:"outline",onClick:()=>n(!0,!0),"data-testid":"msg-line-permission-allow-always",children:"Allow Always"}),h.jsx(ni,{size:"sm",variant:"destructive",onClick:()=>n(!1,!1),"data-testid":"msg-line-permission-deny",children:"Deny"})]})]})}function FX({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(Mc,{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 NS=/\[attachment:(image|file):([^\]]+)\]/g;function HX(e){const t=[];let n;for(;(n=NS.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(NS,"").trim();return{attachments:t,text:r}}function UX(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(`
|
|
514
514
|
`)+`
|
|
515
515
|
`+e}function WX({text:e,senderDisplayName:t,rewindTarget:n}){const r=gR(e),{attachments:i,text:s}=HX(r),{commandName:o,body:a}=ep(s),l=a.length>0;return l||i.length>0||!!o?o&&!l&&i.length===0?h.jsx("div",{className:"flex min-w-0 max-w-full justify-end py-2 mt-2","data-testid":"msg-line-user",children: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:o})}):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",children:[h.jsxs("div",{className:"min-w-0 max-w-[85%] rounded-2xl rounded-br-sm bg-accent px-3.5 py-2 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:[i.length>0?h.jsx(VX,{attachments:i}):null,o?h.jsx("div",{className:se("flex",l&&"mb-1.5"),children:h.jsx("span",{"data-testid":"user-command-chip",className:"inline-flex items-center rounded-md bg-white/15 px-2 py-0.5 text-[11px] font-mono text-white/90",children:o})}):null,l?h.jsx("div",{className:"text-[14px] text-white font-medium leading-relaxed",children:a}):null]}),t?h.jsx("div",{"data-testid":"user-msg-sender-label",className:"mt-1 text-[11px] text-text-400",children:t}):null,n?h.jsxs("button",{type:"button","data-testid":"user-msg-rewind","aria-label":"rewind to this message",title:"回退到这条消息(会撤销之后 CC 的文件编辑)",onClick:()=>n.onRewind(n.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(ON,{className:"w-3 h-3",strokeWidth:2}),h.jsx("span",{children:"Rewind"})]}):null]}):null}function VX({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(qX,{attachment:t},t.url))})}function qX({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(Ms,{className:"h-3.5 w-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"max-w-[140px] truncate",children:e.fileName})]})}const KX={"task-notification":"子任务通知","slash-command":"斜杠命令","local-command":"本地命令输出","system-reminder":"系统提醒","skill-hint":"Skill 注入","meta-text":"系统消息","attachment-skills":"技能列表","attachment-deferred-tools":"Deferred 工具变更"},GX={"task-notification":Mb,"slash-command":D6,"local-command":LN,"system-reminder":Mb,"skill-hint":Th,"meta-text":RN,"attachment-skills":Th,"attachment-deferred-tools":y6};function XX({metaKind:e,text:t}){const[n,r]=g.useState(!1),i=GX[e];if(e==="slash-command"){const{commandName:o,commandMessage:a,commandArgs:l,body:c}=ep(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:se("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:KX[e]}),h.jsx("span",{className:"truncate text-text-400/80 max-w-[60ch]",children:s}),n?h.jsx(ai,{className:"w-3 h-3 opacity-60 shrink-0"}):h.jsx(li,{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 YX({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:se("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(c6,{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(RN,{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 zr(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 ym(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 NI(e){var i,s,o;const t={};if(!e)return t;t.taskId=zr(e,"task-id"),t.toolUseId=zr(e,"tool-use-id"),t.outputFile=zr(e,"output-file"),t.status=zr(e,"status"),t.summary=zr(e,"summary"),t.result=zr(e,"result");const n=zr(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=zr(e,"worktree");if(r)t.worktreePath=zr(r,"worktreePath"),t.worktreeBranch=zr(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=ym(e,"total_tokens"),l=ym(e,"tool_uses"),c=ym(e,"duration_ms");a!==void 0&&(t.totalTokens=a),l!==void 0&&(t.toolUses=l),c!==void 0&&(t.durationMs=c)}return t}function ZX(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 QX({text:e,taskId:t,parentToolUseId:n}){const r=g.useMemo(()=>NI(e),[e]),[i,s]=g.useState(!1),o=t??r.taskId,a=n??r.toolUseId,l=r.status==="failed"?h.jsx(Is,{className:"w-3.5 h-3.5 text-error"}):r.status==="completed"?h.jsx(If,{className:"w-3.5 h-3.5 text-success"}):h.jsx(U_,{className:"w-3.5 h-3.5 text-text-400"}),c=r.status??"unknown",u=ZX(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:se("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(ai,{className:"w-3.5 h-3.5 mt-[3px] text-text-400 shrink-0"}):h.jsx(li,{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(PN,{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(Fc,{remarkPlugins:[Uc],components:Wc,children:r.result})}):h.jsx("div",{className:"text-[11px] text-text-400 italic",children:"无详细结果"})]}):null]})}const TI=g.createContext(null);function JX({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(TI.Provider,{value:s,children:e})}function PI(){return g.useContext(TI)}function eY(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(`
|
|
516
|
-
`):null}if(typeof e=="object"){const t=e;if(typeof t.text=="string")return t.text}return null}function TS(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 tY(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 nY={readCount:"read",searchCount:"search",bashCount:"bash",editFileCount:"edit",linesAdded:"+lines",linesRemoved:"-lines",otherToolCount:"other"};function rY(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e)){if(!r||r<=0)continue;const i=nY[n]??n;t.push(`${i}:${r}`)}return t}function iY({description:e,input:t,output:n,error:r,pending:i,notifications:s,toolResultExtra:o,progress:a}){const[l,c]=g.useState(!1),u=PI(),d=g.useMemo(()=>{if(!t||typeof t!="object")return null;const N=t;return typeof N.prompt=="string"?N.prompt:null},[t]),f=(o==null?void 0:o.prompt)??d,p=g.useMemo(()=>eY(n),[n]),m=o==null?void 0:o.stats,v=a==null?void 0:a.stats,y=TS((m==null?void 0:m.durationMs)??(v==null?void 0:v.durationMs)),_=tY((m==null?void 0:m.tokens)??(v==null?void 0:v.tokens)),x=rY(m==null?void 0:m.toolStats),b=i&&(a!=null&&a.lastToolName)?`now:${a.lastToolName}`:null,w=!!(o!=null&&o.agentType||y||_||x.length>0||b),S=(o==null?void 0:o.agentId)??(a==null?void 0:a.agentId),k=g.useMemo(()=>s.map(N=>({taskId:N.taskId,text:N.text,parsed:NI(N.text)})),[s]),T=r?h.jsx(Is,{className:"w-3.5 h-3.5 text-error"}):i?h.jsx(rr,{className:"w-3.5 h-3.5 text-blue-400 animate-spin"}):h.jsx(If,{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-has-error":r?"true":"false","data-notification-count":s.length,"data-has-stats":w?"true":"false","data-agent-id":S??"",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/30",children:[h.jsxs("button",{type:"button","aria-expanded":l,onClick:()=>c(N=>!N),className:se("flex w-full min-w-0 items-center gap-2 px-2.5 py-1.5 text-left text-[13px]","hover:bg-bg-200/40 rounded-md transition-colors"),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(K6,{className:"w-3 h-3"})}),h.jsx("span",{className:"shrink-0",children:T}),h.jsx("span",{className:"flex-1 min-w-0 truncate font-medium text-text-200",children:e}),w?null:s.length>0?h.jsxs("span",{className:"text-[11px] text-text-400 tabular-nums shrink-0",children:[s.length," 次通知"]}):null,S&&(u!=null&&u.open)?h.jsx("span",{role:"button",tabIndex:0,"data-testid":"open-subagent-btn-header","data-agent-id":S,"aria-label":"打开子 agent 对话",onClick:N=>{N.stopPropagation(),u.open(S,o==null?void 0:o.agentType)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.stopPropagation(),N.preventDefault(),u.open(S,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(Ic,{className:"w-3.5 h-3.5"})}):null,l?h.jsx(ai,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(li,{className:"w-3.5 h-3.5 text-text-400 shrink-0"})]}),i&&(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,w?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,y?h.jsx("span",{className:"tabular-nums",children:y}):null,_?h.jsx("span",{className:"tabular-nums",children:_}):null,b?h.jsx("span",{"data-testid":"agent-call-stats-now",className:"font-mono tabular-nums text-blue-400",children:b}):null,x.map(N=>h.jsx("span",{className:"font-mono tabular-nums text-text-400/80",children:N},N)),s.length>0?h.jsxs("span",{className:"tabular-nums text-text-400/70",children:["· ",s.length," 次通知"]}):null]}):null,l?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,k.map((N,O)=>{const P=N.parsed,L=TS(P.durationMs);return h.jsxs("div",{"data-testid":"agent-call-notification","data-task-id":N.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:(N.taskId??P.taskId??"未知").slice(0,12)}),h.jsx("span",{className:"uppercase tracking-wide",children:P.status??"unknown"}),L?h.jsxs("span",{className:"tabular-nums",children:["· ",L]}):null,P.totalTokens?h.jsxs("span",{className:"tabular-nums",children:["· ",P.totalTokens," tok"]}):null,P.toolUses?h.jsxs("span",{className:"tabular-nums",children:["· ",P.toolUses," tools"]}):null,P.worktreeBranch?h.jsxs("span",{className:"font-mono",children:["· ",P.worktreeBranch]}):null]}),P.summary?h.jsx("div",{className:"text-[12px] text-text-300",children:P.summary}):null,P.result?h.jsx("div",{"data-testid":"agent-call-notification-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(Fc,{remarkPlugins:[Uc],components:Wc,children:P.result})}):null]},`${N.taskId??"n"}-${O}`)}),f?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:f})]}):null,p?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(Fc,{remarkPlugins:[Uc],components:Wc,children:p})})]}):null,!p&&k.length===0&&!r&&!f?h.jsx("div",{className:"text-[11px] text-text-400 italic",children:"无详细信息"}):null,S&&(u!=null&&u.open)?h.jsx("div",{className:"flex justify-end",children:h.jsxs("button",{type:"button","data-testid":"open-subagent-btn","data-agent-id":S,onClick:()=>u.open(S,o==null?void 0:o.agentType),className:se("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(Ic,{className:"w-3 h-3"}),h.jsx("span",{children:"打开子 agent 对话"})]})}):null]}):null]})}function RI({title:e,items:t,live:n,progressColor:r="bg-green-500",listKind:i,children:s}){const[o,a]=g.useState(!!n),l=t.length,c=t.filter(d=>d.status==="completed").length,u=l>0?Math.round(c/l*100):0;return h.jsxs("div",{"data-testid":"msg-line-checklist","data-list-kind":i,className:"min-w-0 max-w-full py-1",children:[h.jsxs("button",{type:"button",onClick:()=>a(d=>!d),"aria-expanded":o,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:[o?h.jsx(ai,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(li,{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:[c,"/",l]}),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:se("h-full rounded-full transition-all duration-300",r),style:{width:`${u}%`}})})]}),o?h.jsxs("div",{"data-testid":"checklist-body",className:"ml-6 mt-0.5",children:[h.jsx("div",{className:"space-y-px",children:t.map((d,f)=>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:d.status==="completed"?h.jsx(nu,{className:"w-3.5 h-3.5 text-green-500"}):d.status==="in_progress"&&n?h.jsx(rr,{className:"w-3.5 h-3.5 text-blue-400 animate-spin"}):h.jsx("span",{className:"w-2 h-2 rounded-full border border-text-400/40"})}),h.jsx("span",{className:se("min-w-0 text-[13px] leading-snug break-words [overflow-wrap:anywhere]",d.status==="completed"?"text-text-400 line-through":"text-text-200"),children:d.status==="in_progress"&&d.activeForm?d.activeForm:d.content})]},`${f}-${d.content}`))}),s]}):null]})}function sY({todos:e,live:t}){return h.jsx(RI,{title:"Tasks",items:e,live:t,progressColor:"bg-green-500",listKind:"todo"})}function oY({tasks:e,live:t}){return h.jsx(RI,{title:"Plan",items:e,live:t,progressColor:"bg-blue-500",listKind:"plan"})}function aY(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 lY(e){return(e.split("/").pop()??e)||e}function cY({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(mB,{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(uY,{memory:t},t.path))})]})}function uY({memory:e}){const[t,n]=g.useState(!1),r=aY(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:se("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(ai,{className:"w-3 h-3 text-text-400 shrink-0"}):h.jsx(li,{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:lY(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 dY({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,y=v||p,_=!n&&!v,x=(S,k)=>{const T={labels:new Set,freeText:""};if(!v||!i)return T;const N=i[S];if(typeof N!="string")return T;const O=N.split(",").map(I=>I.trim()).filter(Boolean),P=new Set(k.map(I=>I.label)),L=new Set,R=[];for(const I of O)P.has(I)?L.add(I):R.push(I);return{labels:L,freeText:R.join(", ")}},b=g.useMemo(()=>t.every(S=>{if((c[S.question]??"").trim().length>0)return!0;if(S.multiSelect){const T=a[S.question];return!!(T&&T.size>0)}return typeof s[S.question]=="string"&&s[S.question].length>0}),[t,s,a,c]),w=async()=>{if(!b||d||y||_||!n)return;const S={};for(const k of t){const T=(c[k.question]??"").trim();if(k.multiSelect){const N=a[k.question],O=N?k.options.filter(P=>N.has(P.label)).map(P=>P.label):[];if(T.length>0&&O.push(T),O.length===0)continue;S[k.question]=O.join(", ")}else if(T.length>0)S[k.question]=T;else{const N=s[k.question];typeof N=="string"&&(S[k.question]=N)}}f(!0);try{await n(S),m(!0)}finally{f(!1)}};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(PB,{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((S,k)=>{const T=`q-${k}`,N=`${e}-${k}`,O=x(S.question,S.options),P=y||_,L=c[S.question]??"",R=v?O.freeText:p?(c[S.question]??"").trim():"";return h.jsxs("div",{"data-testid":"msg-line-question-item",children:[S.question?h.jsx("div",{className:"text-text-200 mb-1.5",children:S.question}):null,h.jsx("div",{className:"flex flex-col gap-1",children:S.options.map((I,j)=>{var F;const B=`${T}-${j}`,$=v?O.labels.has(I.label):S.multiSelect?!!((F=a[S.question])!=null&&F.has(I.label)):s[S.question]===I.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:S.multiSelect?"checkbox":"radio",name:N,value:I.label,checked:$,disabled:y||_,onChange:()=>{y||_||(S.multiSelect?l(A=>{const D=new Set(A[S.question]??[]);return D.has(I.label)?D.delete(I.label):D.add(I.label),{...A,[S.question]:D}}):o(A=>({...A,[S.question]:I.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:I.label}),I.description?h.jsx("span",{className:"text-[12px] text-text-400 [overflow-wrap:anywhere]",children:I.description}):null]})]},B)})}),P?R.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:R}):null:h.jsx("textarea",{rows:3,value:L,placeholder:"或自行输入回答...",onChange:I=>{const j=I.target.value;u(B=>({...B,[S.question]:j}))},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(ni,{size:"sm",variant:"default",onClick:()=>void w(),disabled:!b||d||y||_,"data-testid":"msg-line-question-submit",children:y?"已提交 / Submitted":_?"已结束 / Ended":"提交 / Submit"}),r&&!y&&!_?h.jsx(ni,{size:"sm",variant:"ghost",onClick:()=>void r(),disabled:d,"data-testid":"msg-line-question-cancel",children:"跳过 / Skip"}):null]})]})}function hY({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(dY,{toolUseId:e,questions:t,onSubmit:i?a:void 0,...s?{onCancel:l}:{},submittedAnswers:o})}function fY(){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 du=fY();function II({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}){const y=g.useMemo(()=>g7(e),[e]);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,y.map(_=>pY(_,{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}))]})}function pY(e,t){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}=t,y=`${e.kind}-${e.seq}`;switch(e.kind){case"session-init":return null;case"user-text":{const _=typeof e.uuid=="string"?e.uuid:void 0,x=!!(n&&_&&(!r||r.has(_)));return h.jsx(WX,{text:e.text,senderDisplayName:e.senderDisplayName,rewindTarget:x&&_&&n?{userMessageId:_,onRewind:n}:void 0},y)}case"user-meta":return h.jsx(XX,{metaKind:e.metaKind,text:e.text},y);case"meta-text":return h.jsx(YX,{text:e.text,metaSource:e.metaSource},y);case"agent-notification":return h.jsx(QX,{text:e.text,taskId:e.taskId,parentToolUseId:e.parentToolUseId},y);case"assistant-text":{const _=typeof e.uuid=="string"?e.uuid:void 0,x=_&&(o||a)?{messageUuid:_,onFork:o,onQuickAsk:a}:void 0;return h.jsx(fX,{text:x7(e.text),forkTarget:x},y)}case"assistant-thinking":return h.jsx(pX,{text:e.text},y);case"permission-inline":return h.jsx($X,{tool:e.tool,input:e.input,onRespond:i??(()=>{}),onInterrupt:s},y);case"error":return h.jsx(FX,{message:e.message},y);case"turn-end":return null;case"merged-tool":return mY(e,y,{fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v});case"merged-agent":return h.jsx(iY,{description:e.description,input:e.input,output:e.output,error:e.error,pending:e.pending,notifications:e.notifications,toolResultExtra:e.toolResultExtra,progress:e.progress},y);case"plan-card":return h.jsx(oY,{tasks:e.tasks},y);case"todo-checklist":return h.jsx(sY,{todos:e.todos},y);case"memory-callout":return h.jsx(cY,{memories:e.memories},y);case"question-card":{const _=d===void 0||d.has(e.toolUseId);return h.jsx(hY,{toolUseId:e.toolUseId,questions:e.questions,historicalAnswers:e.submittedAnswers,realtimeAnswers:l==null?void 0:l[e.toolUseId],onSubmit:_?c:void 0,..._&&u?{onCancel:u}:{}},y)}default:return null}}function mY(e,t,n){const r=du.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(st.Fragment,{children:i??h.jsx(CI,{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)}function Ld(e){return e==="codex"?"Codex":"Claude Code"}const gY={builtin:"Commands",global:"Global",project:"Project",plugin:"Plugin"},PS={builtin:0,global:1,project:2,plugin:3};function vY({query:e,skills:t,activeIndex:n,onActiveIndexChange:r,onSelect:i,onEmpty:s}){const o=g.useRef(null),a=g.useMemo(()=>MI(t,e),[t,e]),l=g.useMemo(()=>{const c=new Set;let u=null;for(let d=0;d<a.length;d++)a[d].source!==u&&(c.add(d),u=a[d].source);return c},[a]);return g.useEffect(()=>{a.length===0&&(s==null||s())},[a.length,s]),g.useEffect(()=>{var c;try{(c=o.current)==null||c.scrollIntoView({block:"nearest"})}catch{}},[n]),a.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:a.map((c,u)=>{const d=u===n,f=l.has(u);return h.jsxs(st.Fragment,{children:[f?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:gY[c.source]}):null,h.jsxs("div",{ref:d?o:void 0,"data-testid":`cc-skill-item-${c.name}`,onMouseEnter:()=>r(u),onClick:()=>i(c),className:se("flex items-center gap-2.5 px-4 py-2 cursor-pointer transition-colors duration-75",d?"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:["/",c.name]}),c.description?h.jsx("span",{className:"text-[11px] text-text-300 truncate ml-auto",children:c.description}):null]})]},`${c.source}/${c.name}`)})})}function MI(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)=>(PS[i.source]??9)-(PS[s.source]??9)),r.slice(0,30)}const _Y={builtin:"Built-in",global:"Global",project:"Project",policy:"Policy",plugin:"Plugin",persona:"My personas",contact:"People","remote-persona":"Remote personas"},RS={builtin:0,global:1,project:2,policy:3,plugin:4,persona:5,contact:6,"remote-persona":7};function Fh(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 xY(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 yY(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 bY(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 AI(e,t){const n=t.trim().toLowerCase(),r=n?e.filter(i=>yY(i).includes(n)):e.slice();return r.sort((i,s)=>(RS[Fh(i)]??9)-(RS[Fh(s)]??9)),r.slice(0,30)}function IS({query:e,entries:t,activeIndex:n,onActiveIndexChange:r,onSelect:i,onEmpty:s}){const o=g.useRef(null),a=g.useMemo(()=>AI(t,e),[t,e]),l=g.useMemo(()=>{const c=new Set;let u=null;for(let d=0;d<a.length;d++){const f=Fh(a[d]);f!==u&&(c.add(d),u=f)}return c},[a]);return g.useEffect(()=>{a.length===0&&(s==null||s())},[a.length,s]),g.useEffect(()=>{var c;try{(c=o.current)==null||c.scrollIntoView({block:"nearest"})}catch{}},[n]),a.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:a.map((c,u)=>{const d=u===n,f=l.has(u),p=Fh(c),m=bY(c);return h.jsxs(st.Fragment,{children:[f?h.jsx("div",{"data-testid":`cc-agent-group-header-${p}`,"data-source":p,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:_Y[p]}):null,h.jsxs("div",{ref:d?o:void 0,"data-testid":m.testid,onMouseEnter:()=>r(u),onClick:()=>i(c),className:se("flex items-center gap-2.5 px-4 py-2 cursor-pointer transition-colors duration-75",d?"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:m.displayName}),m.description?h.jsx("span",{className:"text-[11px] text-text-300 truncate ml-2",children:m.description}):null,m.whenToUse?h.jsx("span",{className:"text-[10px] text-text-400/70 italic truncate ml-auto",children:m.whenToUse}):null,m.plugin?h.jsx("span",{className:"text-[10px] text-text-400/70 ml-2 shrink-0",children:m.plugin}):null]})]},xY(c))})})}function wY({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:se("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:se("h-7 w-7 rounded object-cover",o&&"cursor-pointer hover:opacity-80",s&&"opacity-40")}),s?h.jsx(rr,{"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(rr,{"data-testid":`attachment-spinner-${e.id}`,className:"h-3.5 w-3.5 animate-spin text-text-400"}):h.jsx(Ms,{className:"h-3.5 w-3.5 text-text-400"})}),h.jsx("span",{className:se("max-w-[120px] truncate text-text-200",s&&"text-text-400"),title:e.error??e.fileName,children:e.fileName}),i?h.jsx(Is,{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(In,{className:"h-3 w-3"})})]})}function SY({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(wY,{attachment:r,onRemove:()=>t(r.id),onOpenPreview:n?()=>n(r):void 0},r.id))})}class Ll extends Error{constructor(t,n,r){super(n),this.code=t,this.status=r,this.name="UploadAttachmentError"}}async function kY(e){if(!e.httpBaseUrl)throw new Ll("TUNNEL_NOT_READY","daemon httpBaseUrl unavailable");if(!e.httpToken)throw new Ll("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 Ll("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 Ll(i,s,r.status)}return await r.json()}const MS=25*1024*1024,CY="image/*,.txt,.md,.markdown,.csv,.json,.log,.yaml,.yml,.html,.xml,.pdf",EY=["image/","text/"],NY=new Set(["application/json","application/xml","application/x-yaml","application/yaml","application/pdf"]),TY=new Set(["txt","md","markdown","csv","json","log","yaml","yml","html","xml","pdf"]);function PY(e){var r;const t=(e.type||"").toLowerCase();if(t&&EY.some(i=>t.startsWith(i))||t&&NY.has(t))return!0;const n=((r=e.name.split(".").pop())==null?void 0:r.toLowerCase())??"";return n.length>0&&TY.has(n)}let RY=0;const IY=()=>`att-${++RY}-${Date.now()}`;function MY(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 AY(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:IY(),fileName:d.name,mimeType:d.type||"application/octet-stream"};if(!PY(d)){c.push({...f,url:null,status:"error",error:"不支持的文件类型"});continue}if(d.size>MS){c.push({...f,url:null,status:"error",error:`超过 ${Math.round(MS/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 MY(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 kY({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 Ll?f.code:"UPLOAD_FAILED",m=f.message??"upload failed";n(v=>v.map(y=>y.id===d.id?{...y,status:"error",error:`${p}: ${m}`}:y))}}))},[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}}const Gv=new Map,jY=[];function AS(e){if(e)return Gv.get(e)}function jS(e,t){e&&(t.draft.length===0&&t.attachments.length===0?Gv.delete(e):Gv.set(e,t))}function DY(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 LY({api:e,cwd:t,sessionKey:n,onSend:r,disabled:i,onNewSession:s,onClearSession:o,tool:a,spawnableContacts:l=jY,ensureRemotePersonas:c,remotePersonasByDeviceId:u}){const d=AS(n),[f,p]=g.useState((d==null?void 0:d.draft)??""),[m,v]=g.useState(!1),y=g.useRef(null),_=g.useRef(!1),x=g.useCallback(()=>{_.current=!0},[]),b=g.useCallback(()=>{_.current=!1},[]),w=Rf(),{attachments:S,setAttachments:k,addFiles:T,removeAttachment:N,clearAttachments:O}=AY({httpBaseUrl:w.httpBaseUrl,httpToken:w.httpToken,sessionId:n,initial:(d==null?void 0:d.attachments)??[]}),[P,L]=g.useState([]),[R,I]=g.useState(!1),[j,B]=g.useState(0),[$,F]=g.useState(!1),[A,D]=g.useState([]),[C,H]=g.useState(!1),[q,M]=g.useState(0),[ne,oe]=g.useState(!1),[V,pe]=g.useState([]),[Oe,re]=g.useState(!1),[Me,Fe]=g.useState(null),[We,ge]=g.useState(!1),Ge=g.useRef(null),Gt=g.useMemo(()=>{const ue=[];return s&&ue.push({name:"new",source:"builtin",description:"在当前目录下新建会话"}),o&&n&&ue.push({name:"clear",source:"builtin",description:"清除当前会话"}),ue},[s,o,n]),wt=g.useMemo(()=>[...Gt,...P],[Gt,P]),It=g.useMemo(()=>{const ue=f.match(/^\/(\S*)$/);return ue?ue[1]:null},[f]),ln=It!==null&&!$,Bt=g.useMemo(()=>It!==null?MI(wt,It):[],[wt,It]),at=g.useMemo(()=>{const ue=f.match(/^@(\S*)$/);return ue?ue[1]:null},[f]),Ue=at!==null&&!ne,tt=g.useMemo(()=>Me?((u==null?void 0:u.get(Me.deviceId))??[]).map(Ne=>({kind:"remote-persona",persona:Ne,deviceId:Me.deviceId})):[...A.map(ue=>({kind:"cc-agent",agent:ue})),...V.map(ue=>({kind:"persona",persona:ue})),...l.map(ue=>({kind:"contact",contact:ue}))],[Me,u,A,V,l]),mt=g.useMemo(()=>at!==null?AI(tt,at):[],[tt,at]),Xt=g.useRef(f);g.useEffect(()=>{f!==Xt.current&&(F(!1),oe(!1),Xt.current=f)},[f]);const pn=g.useCallback(()=>{F(!0)},[]),U=g.useCallback(()=>{oe(!0)},[]),Z=g.useRef(f),ve=g.useRef(S);g.useEffect(()=>{Z.current=f},[f]),g.useEffect(()=>{ve.current=S},[S]);const we=g.useRef(n);g.useEffect(()=>{const ue=we.current;if(ue===n)return;jS(ue,{draft:Z.current,attachments:ve.current});const Ne=AS(n);p((Ne==null?void 0:Ne.draft)??""),k((Ne==null?void 0:Ne.attachments)??[]),B(0),M(0),F(!1),oe(!1),Fe(null),Ge.current=null,ge(!1),queueMicrotask(()=>{Ne!=null&&Ne.draft?jI(y.current):Wo(y.current)}),we.current=n},[n,k]),g.useEffect(()=>()=>{jS(we.current,{draft:Z.current,attachments:ve.current})},[]),g.useEffect(()=>{B(0)},[It]),g.useEffect(()=>{M(0)},[at]),g.useEffect(()=>{at===null&&Me&&(Fe(null),Ge.current=null,ge(!1))},[at,Me]),g.useEffect(()=>{if(!ln||R)return;if(!e){I(!0);return}let ue=!1;return(async()=>{try{const Ne=await e.skillsList(t,a);ue||(L(Ne.skills??[]),I(!0))}catch{ue||I(!0)}})(),()=>{ue=!0}},[ln,R,e,t,a]),g.useEffect(()=>{if(!Ue||C)return;if(!e){H(!0);return}let ue=!1;return(async()=>{try{const Ne=await e.agentsList(t,a);ue||(D(Ne.agents??[]),H(!0))}catch{ue||H(!0)}})(),()=>{ue=!0}},[Ue,C,e,t,a]),g.useEffect(()=>{if(!Ue||Oe)return;if(!e){re(!0);return}let ue=!1;return(async()=>{try{const Ne=await e.personaList();ue||(pe((Ne.personas??[]).map(Qe=>({personaId:Qe.personaId,label:Qe.label,iconKey:Qe.iconKey}))),re(!0))}catch{ue||re(!0)}})(),()=>{ue=!0}},[Ue,Oe,e]);const Q=g.useCallback(ue=>{switch(ue.kind){case"persona":p(`@persona/${ue.persona.personaId} `);break;case"cc-agent":p(`@"${ue.agent.name} (agent)" `);break;case"contact":{const Ne=ue.contact.deviceId;Fe({deviceId:Ne,displayName:ue.contact.displayName}),Ge.current=Ne,ge(!0),Promise.resolve(c==null?void 0:c(Ne)).finally(()=>{Ge.current===Ne&&ge(!1)}),p("@"),oe(!1),setTimeout(()=>{var Qe;return(Qe=y.current)==null?void 0:Qe.focus()},0);return}case"remote-persona":p(`@persona/${ue.persona.personaId}@${ue.deviceId} `),Fe(null);break}oe(!1),setTimeout(()=>{var Ne;return(Ne=y.current)==null?void 0:Ne.focus()},0)},[c]),Xe=g.useCallback(()=>{Fe(null),Ge.current=null,ge(!1),p("@"),setTimeout(()=>{var ue;return(ue=y.current)==null?void 0:ue.focus()},0)},[]),Yt=g.useCallback(ue=>{if(ue.source==="builtin"&&ue.name==="new"&&s){p(""),O(),Wo(y.current),s(t);return}if(ue.source==="builtin"&&ue.name==="clear"&&o){p(""),O(),Wo(y.current),o();return}p(`/${ue.name} `),setTimeout(()=>{var Ne;return(Ne=y.current)==null?void 0:Ne.focus()},0)},[s,t,O,o]),Zt=g.useCallback(async()=>{const ue=f.trim(),Ne=S.filter(Qe=>Qe.status==="done");if(!(!ue&&Ne.length===0)&&!(m||i)){if(ue==="/new"&&s){v(!0);try{await s(t),p(""),O(),Wo(y.current)}finally{v(!1)}return}if(ue==="/clear"&&o){v(!0);try{await o(),p(""),O(),Wo(y.current)}finally{v(!1)}return}v(!0);try{const Qe=a==="codex"?DY(ue,P):ue,Dn=UX(Qe,S);await r(Dn),p(""),O(),Wo(y.current)}finally{v(!1)}}},[f,S,m,i,r,s,t,O,o,a,P]);return{draft:f,setDraft:p,sending:m,textareaRef:y,isComposingRef:_,onCompositionStart:x,onCompositionEnd:b,attachments:S,addFiles:T,removeAttachment:N,skillSelectorVisible:ln,filteredSkills:Bt,slashQuery:It??"",activeSkillIdx:j,setActiveSkillIdx:B,selectSkill:Yt,dismissSkillSelector:pn,agentSelectorVisible:Ue,filteredAgents:mt,mentionQuery:at,activeAgentIdx:q,setActiveAgentIdx:M,selectAgent:Q,dismissAgentSelector:U,drilldown:Me,drilldownLoading:We,exitDrilldown:Xe,doSend:Zt}}const OY=120;function jI(e){e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,OY)}px`)}function Wo(e){e&&(e.style.height="auto")}const BY={spawnableContacts:[],ensureRemotePersonas:()=>Promise.resolve(),remotePersonasByDeviceId:new Map},zY=g.createContext(BY);function $Y(){return g.useContext(zY)}function FY({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{DS(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(Mf,{className:"h-3 w-3"}),r?"Copied":"Copy"]}),h.jsxs("button",{type:"button",onClick:()=>DS(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(zB,{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(In,{className:"h-3 w-3"})})]})]})})}function DS(e,t){const n=document.createElement("a");n.href=e,n.download=t||"image",n.click()}function HY({meta:e,api:t,cwd:n,tool:r,onSend:i,sessionKey:s,disabled:o=!1,placeholder:a,className:l,awaitingUser:c=!1,onAbort:u,onNewSession:d,onClearSession:f}){const p=(e==null?void 0:e.streamInProgress)??!1,m=g.useRef(null),v=$Y(),y=LY({...t?{api:t}:{},cwd:n,...r?{tool:r}:{},sessionKey:s,onSend:i,disabled:o,...d?{onNewSession:d}:{},...f?{onClearSession:f}:{},spawnableContacts:v.spawnableContacts,ensureRemotePersonas:v.ensureRemotePersonas,remotePersonasByDeviceId:v.remotePersonasByDeviceId}),{draft:_,setDraft:x,sending:b,textareaRef:w,attachments:S,addFiles:k,removeAttachment:T,skillSelectorVisible:N,filteredSkills:O,slashQuery:P,activeSkillIdx:L,setActiveSkillIdx:R,selectSkill:I,dismissSkillSelector:j,agentSelectorVisible:B,filteredAgents:$,mentionQuery:F,activeAgentIdx:A,setActiveAgentIdx:D,selectAgent:C,dismissAgentSelector:H,drilldown:q,drilldownLoading:M,exitDrilldown:ne,doSend:oe}=y,V=!!t,pe=b||o||p,re=(_.trim().length>0||S.some(Q=>Q.status==="done"))&&!o&&!b&&!c,Me=a??(c?"Answer the question above first...":pe?"Queue a message...":`Message ${Ld(r)}...`),Fe=g.useRef(!1),We=g.useCallback(()=>{Fe.current=!0},[]),ge=g.useCallback(()=>{Fe.current=!1},[]),Ge=g.useCallback(Q=>{if(N&&O.length>0){if(Q.key==="ArrowDown")return Q.preventDefault(),R(L>=O.length-1?0:L+1),!0;if(Q.key==="ArrowUp")return Q.preventDefault(),R(L<=0?O.length-1:L-1),!0;if(Q.key==="Tab"||Q.key==="Enter"&&!Q.shiftKey){Q.preventDefault();const Xe=O[L];return Xe&&I(Xe),!0}if(Q.key==="Escape")return Q.preventDefault(),j(),!0}return!1},[N,O,L,R,I,j]),Gt=g.useCallback(Q=>{if(B&&$.length>0){if(Q.key==="ArrowDown")return Q.preventDefault(),D(A>=$.length-1?0:A+1),!0;if(Q.key==="ArrowUp")return Q.preventDefault(),D(A<=0?$.length-1:A-1),!0;if(Q.key==="Tab"||Q.key==="Enter"&&!Q.shiftKey){Q.preventDefault();const Xe=$[A];return Xe&&C(Xe),!0}if(Q.key==="Escape")return Q.preventDefault(),q?ne():H(),!0}return!1},[B,$,A,D,C,H,q,ne]),wt=g.useCallback(Q=>{const Xe=Q.nativeEvent;Q.key==="Enter"&&ZP({compositionActive:Fe.current,nativeIsComposing:Xe.isComposing,keyCode:Xe.keyCode})||Ge(Q)||Gt(Q)||QP({key:Q.key,shiftKey:Q.shiftKey,compositionActive:Fe.current,nativeIsComposing:Xe.isComposing,keyCode:Xe.keyCode})&&(Q.preventDefault(),re&&oe())},[Ge,Gt,re,oe]),It=g.useCallback(Q=>{x(Q.target.value),jI(Q.target)},[x]),ln=g.useCallback(Q=>{Q.target.files&&k(Q.target.files),Q.target.value=""},[k]),Bt=g.useCallback(Q=>{if(!V)return;const Xe=Array.from(Q.clipboardData.items).map(Yt=>Yt.getAsFile()).filter(Yt=>!!(Yt&&Yt.type.startsWith("image/")));Xe.length!==0&&(Q.preventDefault(),k(Xe))},[k,V]),[at,Ue]=g.useState(null),tt=g.useCallback(Q=>{Q.previewUrl&&Ue({url:Q.previewUrl,name:Q.fileName})},[]),[mt,Xt]=g.useState(!1),pn=g.useCallback(Q=>{V&&(Q.preventDefault(),Xt(!0))},[V]),U=g.useCallback(()=>Xt(!1),[]),Z=g.useCallback(Q=>{V&&(Q.preventDefault(),Xt(!1),Q.dataTransfer.files.length>0&&k(Q.dataTransfer.files))},[k,V]),ve=p&&!c&&typeof u=="function",we=o||c;return h.jsxs("div",{"data-testid":"chat-input",className:se("shrink-0 border-t border-bg-300/20 px-4 py-3",l),onDragOver:pn,onDragLeave:U,onDrop:Z,children:[h.jsxs("div",{className:"max-w-3xl mx-auto relative",children:[V?h.jsx("input",{ref:m,type:"file",multiple:!0,accept:CY,hidden:!0,onChange:ln,"data-testid":"chat-input-file"}):null,h.jsxs("div",{"data-testid":"chat-input-bare",className:se("flex flex-col gap-2"),children:[c||b||p?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:c?"Waiting for your answer":`${r==="codex"?"Codex":"Claude"} is working`})]}):null,N?h.jsx(vY,{query:P,skills:O,activeIndex:L,onActiveIndexChange:R,onSelect:I}):null,B?q?!v.remotePersonasByDeviceId.has(q.deviceId)&&M?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:`正在加载 @${q.displayName} 的 persona…`}):$.length>0?h.jsx(IS,{query:F??"",entries:$,activeIndex:A,onActiveIndexChange:D,onSelect:C}):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:`@${q.displayName} 暂无可派活的 persona(可能离线或未公开)`}):h.jsx(IS,{query:F??"",entries:$,activeIndex:A,onActiveIndexChange:D,onSelect:C}):null,S.length>0?h.jsx(SY,{attachments:S,onRemove:T,onOpenPreview:tt}):null,h.jsxs("div",{"data-testid":"bare-chat-input-frame",className:se("flex items-end gap-2 rounded-xl border border-bg-300 bg-bg-50 px-3 py-2 transition-colors duration-200",we?"opacity-60":null,mt?"border-accent/60 bg-accent/5":null),children:[V?h.jsx("button",{type:"button",onClick:()=>{var Q;return(Q=m.current)==null?void 0:Q.click()},disabled:pe,"data-testid":"chat-input-attach","aria-label":"attach files",className:se("flex h-8 w-8 shrink-0 self-end items-center justify-center rounded-md transition-colors",pe?"cursor-default text-text-400/50":"cursor-pointer text-text-400 hover:bg-text-100/5 hover:text-text-200"),children:h.jsx(f6,{className:"h-4 w-4"})}):null,h.jsx("textarea",{ref:w,"data-testid":"chat-input-textarea",value:_,onChange:It,onKeyDown:wt,onCompositionStart:We,onCompositionEnd:ge,onPaste:Bt,placeholder:Me,disabled:we,readOnly:we,rows:1,className:"flex-1 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 shrink-0 pb-0.5",children:[ve?h.jsx("button",{type:"button",onClick:u,"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(AN,{className:"w-3.5 h-3.5",strokeWidth:2.5})}):null,h.jsx("button",{type:"button",onClick:()=>{re&&oe()},disabled:!re,"data-testid":"chat-input-send","aria-label":"send",className:se("h-8 w-8 rounded-full flex items-center justify-center transition-colors",re?"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(uB,{className:"w-4 h-4",strokeWidth:2.5})})]})]})]})]}),at?h.jsx(FY,{url:at.url,fileName:at.name,onClose:()=>Ue(null)}):null]})}function UY(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function WY({meta:e,tool:t,connState:n,onOpenConfig:r,models:i,liveGitBranch:s,liveWorktreeRoot:o,onForceStop:a,cronActiveCount:l,onCronClick:c,onOpenFiles:u,onTogglePin:d,isHolded:f=!1,onToggleHold:p,personaName:m,onOpenPersona:v,className:y}){const _=e.procAlive??!1,x=e.streamInProgress??!1,b=e.permissionMode,w=b&&b!=="default"?b:null,S=w==="bypassPermissions"?"YOLO":w==="plan"?"Plan":null,k=e.model??"",T=VY(i,k),N=e.contextPct??null,O=N==null?"":N>=80?"text-red-400":N>=50?"text-amber-400":"text-text-500",P=s!==void 0?s:e.gitBranch??null,L=o??e.cwd??"",I=!!e.sessionLabel&&e.sessionLabel!==e.sessionId?e.sessionLabel:UY(L),j=L,B=e.pinnedAt!=null;return h.jsxs("div",{"data-testid":"chat-header",className:se("relative flex flex-col justify-center shrink-0 px-4 pr-14 py-2 gap-1",y),children:[h.jsxs("div",{className:"flex items-center min-w-0 gap-2 text-[13px]",children:[d?h.jsx("button",{type:"button",onClick:()=>d(!B),"data-testid":"chat-header-pin-toggle","data-pinned":B?"true":"false","aria-pressed":B,title:B?"Unpin session":"Pin session",className:se("shrink-0 inline-flex items-center justify-center h-5 w-5 rounded-md cursor-pointer transition-colors",B?"text-amber-400 hover:bg-amber-500/10":"text-text-500 hover:text-text-200 hover:bg-text-100/5"),children:h.jsx(DN,{className:se("w-3.5 h-3.5",B&&"fill-current")})}):null,p?h.jsx("button",{type:"button",onClick:()=>p(!f),"data-testid":"chat-header-hold-toggle","data-holded":f?"true":"false","aria-pressed":f,title:f?"Release hold":"Hold session",className:se("shrink-0 inline-flex items-center justify-center h-5 w-5 rounded-md cursor-pointer transition-colors",f?"text-amber-400 hover:bg-amber-500/10":"text-text-500 hover:text-text-200 hover:bg-text-100/5"),children:h.jsx(xB,{className:se("w-3.5 h-3.5",f&&"fill-current")})}):null,h.jsx("span",{className:"font-semibold text-text-100 truncate","data-testid":"chat-header-worktree",title:j,children:I}),P?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-500 shrink-0",children:":"}),h.jsx("span",{className:"font-mono text-text-300 truncate","data-testid":"chat-header-git",title:P,children:P})]}):null]}),h.jsxs("div",{className:"flex items-center min-w-0 gap-2 text-[11px]",children:[S?h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("desktop"),"data-testid":"chat-header-mode-chip",className:se("hidden md:inline-flex shrink-0 px-2 py-0.5 rounded-md font-semibold cursor-pointer transition-colors",w==="bypassPermissions"?"bg-red-500/15 text-red-400 hover:bg-red-500/25":"bg-blue-500/15 text-blue-400 hover:bg-blue-500/25"),children:S}),h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("mobile"),"aria-hidden":"true",tabIndex:-1,className:se("inline-flex md:hidden shrink-0 px-2 py-0.5 rounded-md font-semibold cursor-pointer transition-colors",w==="bypassPermissions"?"bg-red-500/15 text-red-400 hover:bg-red-500/25":"bg-blue-500/15 text-blue-400 hover:bg-blue-500/25"),children:S})]}):null,k||i?h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("desktop"),"data-testid":"chat-header-model-chip",className:"hidden md:inline-flex shrink-0 font-mono text-text-400 cursor-pointer hover:text-text-200 transition-colors",children:T}),h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("mobile"),"aria-hidden":"true",tabIndex:-1,className:"inline-flex md:hidden shrink-0 font-mono text-text-400 cursor-pointer hover:text-text-200 transition-colors",children:T})]}):null,N!=null?h.jsxs("span",{className:se("shrink-0 font-mono",O),"data-testid":"chat-header-ctx",children:["ctx:",N,"%"]}):null,h.jsxs("span",{"data-testid":"chat-header-proc-status",className:"inline-flex items-center gap-1 text-text-500 shrink-0",title:x?`${Ld(t)} 正在跑当前 turn`:_?`${Ld(t)} 进程仍活,等下一轮输入`:`${Ld(t)} 进程未运行(发送消息会自动启动)`,children:[h.jsx("span",{className:se("w-1.5 h-1.5 rounded-full",x?"bg-green-500":"bg-text-400/50")}),h.jsx("span",{children:x?"running":"idle"})]}),_&&a?h.jsxs("button",{type:"button",onClick:a,"data-testid":"chat-header-force-stop",title:t==="codex"?"强制停止 Codex 进程":"强制停止 Claude Code 进程(会丢失 initialize / 预热缓存)",className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-400 hover:bg-red-500/10 hover:text-red-400 transition-colors cursor-pointer",children:[h.jsx(d6,{className:"w-3 h-3"}),h.jsx("span",{children:"Stop"})]}):null,m&&v||u||l&&l>0&&c?h.jsx("span",{className:"text-text-500 shrink-0","aria-hidden":"true",children:"·"}):null,m&&v?h.jsxs("button",{type:"button",onClick:v,"data-testid":"chat-header-persona",title:m,className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-300 hover:bg-bg-200 hover:text-text-100 transition-colors cursor-pointer",children:[h.jsx(q_,{className:"w-3 h-3"}),h.jsx("span",{className:"truncate max-w-[80px] md:max-w-[120px]",children:m})]}):null,u?h.jsxs("button",{type:"button",onClick:u,"data-testid":"chat-header-files",title:"Edited Files",className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-300 hover:bg-bg-200 hover:text-text-100 transition-colors cursor-pointer",children:[h.jsx(qB,{className:"w-3 h-3"}),h.jsx("span",{className:"hidden md:inline",children:"Edited Files"})]}):null,l&&l>0&&c?h.jsxs("button",{type:"button","data-testid":"chat-header-cron-button",onClick:c,"aria-label":"Cron tasks",title:`${l} active cron task${l===1?"":"s"}`,className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-400 hover:bg-accent-dim hover:text-accent transition-colors cursor-pointer",children:[h.jsx(MB,{className:"w-3 h-3"}),h.jsx("span",{"data-testid":"chat-header-cron-badge",className:"font-mono",children:l})]}):null]}),r?h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button","aria-label":"Session settings","data-testid":"chat-header-settings",onClick:()=>r("desktop"),title:"Session settings",className:"hidden md:flex absolute right-4 top-3 z-10 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(bv,{className:"w-4 h-4"})}),h.jsx("button",{type:"button","aria-label":"Session settings","data-testid":"chat-header-settings-mobile",onClick:()=>r("mobile"),title:"Session settings",className:"flex md:hidden absolute right-4 top-3 z-10 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(bv,{className:"w-4 h-4"})})]}):null]})}function VY(e,t){if(!t)return"default";const n=t.toLowerCase(),r=[["opus","Opus"],["sonnet","Sonnet"],["haiku","Haiku"]];for(const[a,l]of r){if(!n.includes(a))continue;const c=n.match(new RegExp(`${a}-(\\d+)-(\\d+)`));return c?`${l} ${c[1]}.${c[2]}`:l}const i=e??[],s=i.find(a=>a.id===t);if(s)return s.label;const o=i.find(a=>a.id&&t.toLowerCase().includes(a.id.toLowerCase()));return o?o.label:t}function qY(e){return e==="TodoWrite"}function KY(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 GY(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":LS(r,l,"assistant-text",a.text,a.partialId,a.uuid);break;case"thinking":LS(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,senderDisplayName:(s=a.sender)==null?void 0:s.displayName});break}case"tool_call":DI(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":r.push({kind:"turn-end",seq:l});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 DI(e,t,n,r,i,s){if(qY(r)){const o=KY(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(h7(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 LS(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 XY="AskUserQuestion";function LI(e,t=0,n){const r=[],i=new Map;let s=t;for(const o of e){const a=s++,l=o.toolUseId??`hist-${a}`;switch(o.kind){case"user-text":o.meta==="task-notification"?r.push({kind:"agent-notification",seq:a,text:o.text??"",taskId:o.taskId,parentToolUseId:o.parentToolUseId}):o.meta?r.push({kind:"user-meta",seq:a,metaKind:o.meta,text:o.text??""}):r.push({kind:"user-text",seq:a,text:o.text??"",uuid:o.uuid});break;case"assistant-text":r.push({kind:"assistant-text",seq:a,text:o.text??"",uuid:o.uuid});break;case"tool_call":{if(o.tool===XY){const c=o.input??{},u=Array.isArray(c.questions)?c.questions:[];i.set(l,r.length),r.push({kind:"question-card",seq:a,toolUseId:l,questions:u});break}DI(r,a,l,o.tool??"",o.input,n);break}case"tool_result":{const c=i.get(l);if(c!==void 0){if(o.askQuestionAnswers){const d=r[c];d.submittedAnswers=o.askQuestionAnswers}i.delete(l);break}const u={kind:"tool-result",seq:a,toolUseId:l,output:o.output};o.toolResultExtra&&(u.toolResultExtra=o.toolResultExtra),r.push(u);break}case"attachment_memories":o.memories&&o.memories.length>0&&r.push({kind:"memory-callout",seq:a,memories:o.memories});break}}return r}function YY({api:e,cwd:t,toolSessionId:n}){const r=PI(),i=(r==null?void 0:r.state.agentId)??null,s=r==null?void 0:r.state.agentType,[o,a]=g.useState([]),[l,c]=g.useState(!1),[u,d]=g.useState(null);g.useEffect(()=>{if(!i)return;let p=!1;return c(!0),d(null),a([]),e.historySubagentRead({cwd:t,toolSessionId:n,subagentId:i}).then(m=>{p||a(m.messages??[])}).catch(m=>{p||d(m instanceof Error?m.message:String(m))}).finally(()=>{p||c(!1)}),()=>{p=!0}},[i,t,n,e]);const f=g.useMemo(()=>o.length>0?LI(o,0,"claude"):[],[o]);return!r||!i?null:h.jsxs("div",{"data-testid":"subagent-drawer","data-agent-id":i,className:se("fixed inset-y-0 right-0 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:[s?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:s}):null,h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate",title:i,children:i})]}),h.jsx("button",{type:"button","aria-label":"关闭",onClick:()=>r.close(),className:"p-1 rounded hover:bg-bg-200/50 text-text-400 hover:text-text-200",children:h.jsx(In,{className:"w-4 h-4"})})]}),!l&&!u&&o.length>0?h.jsxs("div",{className:"text-[11px] text-text-400",children:[o.length," 条消息 · 首条为主会话派发的任务指令"]}):null]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden px-3 py-2",children:l?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(rr,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"加载中…"})]}):u?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-error",children:[h.jsx(Is,{className:"w-3.5 h-3.5"}),h.jsx("span",{children:u})]}):f.length===0?h.jsx("div",{className:"text-[12px] text-text-400 italic",children:"无消息"}):h.jsx(II,{lines:f})})]})}function OS(e,t){let n=0;for(const r of e.lines)r.startsWith(t)&&n++;return n}function ZY(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+=OS(m,"+"),p.deletions+=OS(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 QY({open:e,onOpenChange:t,api:n,sessionId:r,userMessageId:i,lines:s,procAlive:o,onApplied:a,onNoChanges:l}){const c=g.useMemo(()=>ZY(s,i),[s,i]),[u,d]=g.useState(null),[f,p]=g.useState(!1),[m,v]=g.useState(!1),[y,_]=g.useState(null);g.useEffect(()=>{if(!e)return;let k=!1;return p(!0),d(null),(async()=>{try{const T=await n.sessionRewindDiff({sessionId:r,userMessageId:i});k||(d(T),!T.canRewind&&!T.error&&T.files.length===0&&(l==null||l(i)))}catch{k||d(null)}finally{k||p(!1)}})(),()=>{k=!0}},[e,n,r,i]);const x=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(T=>({filePath:T.filePath,hunks:T.hunks,insertions:T.insertions,deletions:T.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]),b=g.useCallback(async()=>{v(!0),_(null);try{const k=await n.sessionRewind({sessionId:r,userMessageId:i,dryRun:!1});if(!k.canRewind){_(k.error??"回退失败");return}a==null||a(),t(!1)}catch(k){_(k.message||"回退失败")}finally{v(!1)}},[n,r,i,a,t]);if(!e)return null;const w=x.files.length>0,S=!f&&!m&&x.anchorFound&&w&&!y;return h.jsxs("div",{"data-testid":"rewind-preview-drawer",className:"fixed right-0 top-0 bottom-0 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(ON,{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(In,{className:"w-4 h-4"})})]}),y?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(Mc,{className:"w-4 h-4 shrink-0 mt-0.5"}),h.jsx("span",{children:y})]}):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(rr,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"正在读取快照…"})]}):x.anchorFound?w?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:x.files.length})," ","个文件,",h.jsxs("span",{className:"text-green-500 font-mono",children:["+",x.totalInsertions]})," / ",h.jsxs("span",{className:"text-red-400 font-mono",children:["-",x.totalDeletions]})]}),x.source==="local"?h.jsx("div",{"data-testid":"rewind-source-hint",className:"mt-1 text-text-400 text-[11px]",children:"基于对话里 tool_result 估算(未读到 CC 快照,数字可能与实际磁盘略有差异)"}):null]}),x.files.map(k=>h.jsx(eZ,{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:[w&&x.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(Mc,{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:!S,onClick:()=>void b(),"data-testid":"rewind-apply",className:se("h-8 px-3 rounded-md text-[12px] font-medium transition-colors",S?"bg-accent text-white hover:bg-accent-hover cursor-pointer":"bg-bg-200 text-text-400 cursor-not-allowed"),children:m?"回退中…":"确认回退"})]})]})]})}function JY(e){return e.replace(/^\/Users\/[^/]+/,"~")}function eZ({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(ai,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(li,{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:JY(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(tZ,{hunk:r},`${r.oldStart}-${r.oldLines}-${r.newStart}-${r.newLines}`))}):null]})}function tZ({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:se("px-3 whitespace-pre",s),children:n.length>0?n:" "},r)})]})}var tp="Dialog",[OI]=Eo(tp),[nZ,Or]=OI(tp),BI=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!0}=e,a=g.useRef(null),l=g.useRef(null),[c,u]=Af({prop:r,defaultProp:i??!1,onChange:s,caller:tp});return h.jsx(nZ,{scope:t,triggerRef:a,contentRef:l,contentId:to(),titleId:to(),descriptionId:to(),open:c,onOpenChange:u,onOpenToggle:g.useCallback(()=>u(d=>!d),[u]),modal:o,children:n})};BI.displayName=tp;var zI="DialogTrigger",rZ=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Or(zI,n),s=qt(t,i.triggerRef);return h.jsx(Et.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Yx(i.open),...r,ref:s,onClick:Te(e.onClick,i.onOpenToggle)})});rZ.displayName=zI;var Gx="DialogPortal",[iZ,$I]=OI(Gx,{forceMount:void 0}),FI=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,s=Or(Gx,t);return h.jsx(iZ,{scope:t,forceMount:n,children:g.Children.map(r,o=>h.jsx(zi,{present:n||s.open,children:h.jsx(ix,{asChild:!0,container:i,children:o})}))})};FI.displayName=Gx;var Hh="DialogOverlay",HI=g.forwardRef((e,t)=>{const n=$I(Hh,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=Or(Hh,e.__scopeDialog);return s.modal?h.jsx(zi,{present:r||s.open,children:h.jsx(oZ,{...i,ref:t})}):null});HI.displayName=Hh;var sZ=Ac("DialogOverlay.RemoveScroll"),oZ=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Or(Hh,n);return h.jsx(sx,{as:sZ,allowPinchZoom:!0,shards:[i.contentRef],children:h.jsx(Et.div,{"data-state":Yx(i.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),_o="DialogContent",UI=g.forwardRef((e,t)=>{const n=$I(_o,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=Or(_o,e.__scopeDialog);return h.jsx(zi,{present:r||s.open,children:s.modal?h.jsx(aZ,{...i,ref:t}):h.jsx(lZ,{...i,ref:t})})});UI.displayName=_o;var aZ=g.forwardRef((e,t)=>{const n=Or(_o,e.__scopeDialog),r=g.useRef(null),i=qt(t,n.contentRef,r);return g.useEffect(()=>{const s=r.current;if(s)return HT(s)},[]),h.jsx(WI,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Te(e.onCloseAutoFocus,s=>{var o;s.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Te(e.onPointerDownOutside,s=>{const o=s.detail.originalEvent,a=o.button===0&&o.ctrlKey===!0;(o.button===2||a)&&s.preventDefault()}),onFocusOutside:Te(e.onFocusOutside,s=>s.preventDefault())})}),lZ=g.forwardRef((e,t)=>{const n=Or(_o,e.__scopeDialog),r=g.useRef(!1),i=g.useRef(!1);return h.jsx(WI,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,a;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),WI=g.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,...o}=e,a=Or(_o,n),l=g.useRef(null),c=qt(t,l);return lT(),h.jsxs(h.Fragment,{children:[h.jsx(X_,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:h.jsx(jf,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Yx(a.open),...o,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),h.jsxs(h.Fragment,{children:[h.jsx(cZ,{titleId:a.titleId}),h.jsx(dZ,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Xx="DialogTitle",VI=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Or(Xx,n);return h.jsx(Et.h2,{id:i.titleId,...r,ref:t})});VI.displayName=Xx;var qI="DialogDescription",KI=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Or(qI,n);return h.jsx(Et.p,{id:i.descriptionId,...r,ref:t})});KI.displayName=qI;var GI="DialogClose",XI=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Or(GI,n);return h.jsx(Et.button,{type:"button",...r,ref:t,onClick:Te(e.onClick,()=>i.onOpenChange(!1))})});XI.displayName=GI;function Yx(e){return e?"open":"closed"}var YI="DialogTitleWarning",[gne,ZI]=zz(YI,{contentName:_o,titleName:Xx,docsSlug:"dialog"}),cZ=({titleId:e})=>{const t=ZI(YI),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
516
|
+
`):null}if(typeof e=="object"){const t=e;if(typeof t.text=="string")return t.text}return null}function TS(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 tY(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 nY={readCount:"read",searchCount:"search",bashCount:"bash",editFileCount:"edit",linesAdded:"+lines",linesRemoved:"-lines",otherToolCount:"other"};function rY(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e)){if(!r||r<=0)continue;const i=nY[n]??n;t.push(`${i}:${r}`)}return t}function iY({description:e,input:t,output:n,error:r,pending:i,notifications:s,toolResultExtra:o,progress:a}){const[l,c]=g.useState(!1),u=PI(),d=g.useMemo(()=>{if(!t||typeof t!="object")return null;const N=t;return typeof N.prompt=="string"?N.prompt:null},[t]),f=(o==null?void 0:o.prompt)??d,p=g.useMemo(()=>eY(n),[n]),m=o==null?void 0:o.stats,v=a==null?void 0:a.stats,y=TS((m==null?void 0:m.durationMs)??(v==null?void 0:v.durationMs)),_=tY((m==null?void 0:m.tokens)??(v==null?void 0:v.tokens)),x=rY(m==null?void 0:m.toolStats),b=i&&(a!=null&&a.lastToolName)?`now:${a.lastToolName}`:null,w=!!(o!=null&&o.agentType||y||_||x.length>0||b),S=(o==null?void 0:o.agentId)??(a==null?void 0:a.agentId),k=g.useMemo(()=>s.map(N=>({taskId:N.taskId,text:N.text,parsed:NI(N.text)})),[s]),T=r?h.jsx(Is,{className:"w-3.5 h-3.5 text-error"}):i?h.jsx(rr,{className:"w-3.5 h-3.5 text-blue-400 animate-spin"}):h.jsx(If,{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-has-error":r?"true":"false","data-notification-count":s.length,"data-has-stats":w?"true":"false","data-agent-id":S??"",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/30",children:[h.jsxs("button",{type:"button","aria-expanded":l,onClick:()=>c(N=>!N),className:se("flex w-full min-w-0 items-center gap-2 px-2.5 py-1.5 text-left text-[13px]","hover:bg-bg-200/40 rounded-md transition-colors"),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(K6,{className:"w-3 h-3"})}),h.jsx("span",{className:"shrink-0",children:T}),h.jsx("span",{className:"flex-1 min-w-0 truncate font-medium text-text-200",children:e}),w?null:s.length>0?h.jsxs("span",{className:"text-[11px] text-text-400 tabular-nums shrink-0",children:[s.length," 次通知"]}):null,S&&(u!=null&&u.open)?h.jsx("span",{role:"button",tabIndex:0,"data-testid":"open-subagent-btn-header","data-agent-id":S,"aria-label":"打开子 agent 对话",onClick:N=>{N.stopPropagation(),u.open(S,o==null?void 0:o.agentType)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.stopPropagation(),N.preventDefault(),u.open(S,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(Ic,{className:"w-3.5 h-3.5"})}):null,l?h.jsx(ai,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(li,{className:"w-3.5 h-3.5 text-text-400 shrink-0"})]}),i&&(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,w?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,y?h.jsx("span",{className:"tabular-nums",children:y}):null,_?h.jsx("span",{className:"tabular-nums",children:_}):null,b?h.jsx("span",{"data-testid":"agent-call-stats-now",className:"font-mono tabular-nums text-blue-400",children:b}):null,x.map(N=>h.jsx("span",{className:"font-mono tabular-nums text-text-400/80",children:N},N)),s.length>0?h.jsxs("span",{className:"tabular-nums text-text-400/70",children:["· ",s.length," 次通知"]}):null]}):null,l?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,k.map((N,O)=>{const P=N.parsed,L=TS(P.durationMs);return h.jsxs("div",{"data-testid":"agent-call-notification","data-task-id":N.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:(N.taskId??P.taskId??"未知").slice(0,12)}),h.jsx("span",{className:"uppercase tracking-wide",children:P.status??"unknown"}),L?h.jsxs("span",{className:"tabular-nums",children:["· ",L]}):null,P.totalTokens?h.jsxs("span",{className:"tabular-nums",children:["· ",P.totalTokens," tok"]}):null,P.toolUses?h.jsxs("span",{className:"tabular-nums",children:["· ",P.toolUses," tools"]}):null,P.worktreeBranch?h.jsxs("span",{className:"font-mono",children:["· ",P.worktreeBranch]}):null]}),P.summary?h.jsx("div",{className:"text-[12px] text-text-300",children:P.summary}):null,P.result?h.jsx("div",{"data-testid":"agent-call-notification-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(Fc,{remarkPlugins:[Uc],components:Wc,children:P.result})}):null]},`${N.taskId??"n"}-${O}`)}),f?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:f})]}):null,p?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(Fc,{remarkPlugins:[Uc],components:Wc,children:p})})]}):null,!p&&k.length===0&&!r&&!f?h.jsx("div",{className:"text-[11px] text-text-400 italic",children:"无详细信息"}):null,S&&(u!=null&&u.open)?h.jsx("div",{className:"flex justify-end",children:h.jsxs("button",{type:"button","data-testid":"open-subagent-btn","data-agent-id":S,onClick:()=>u.open(S,o==null?void 0:o.agentType),className:se("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(Ic,{className:"w-3 h-3"}),h.jsx("span",{children:"打开子 agent 对话"})]})}):null]}):null]})}function RI({title:e,items:t,live:n,progressColor:r="bg-green-500",listKind:i,children:s}){const[o,a]=g.useState(!!n),l=t.length,c=t.filter(d=>d.status==="completed").length,u=l>0?Math.round(c/l*100):0;return h.jsxs("div",{"data-testid":"msg-line-checklist","data-list-kind":i,className:"min-w-0 max-w-full py-1",children:[h.jsxs("button",{type:"button",onClick:()=>a(d=>!d),"aria-expanded":o,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:[o?h.jsx(ai,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(li,{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:[c,"/",l]}),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:se("h-full rounded-full transition-all duration-300",r),style:{width:`${u}%`}})})]}),o?h.jsxs("div",{"data-testid":"checklist-body",className:"ml-6 mt-0.5",children:[h.jsx("div",{className:"space-y-px",children:t.map((d,f)=>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:d.status==="completed"?h.jsx(nu,{className:"w-3.5 h-3.5 text-green-500"}):d.status==="in_progress"&&n?h.jsx(rr,{className:"w-3.5 h-3.5 text-blue-400 animate-spin"}):h.jsx("span",{className:"w-2 h-2 rounded-full border border-text-400/40"})}),h.jsx("span",{className:se("min-w-0 text-[13px] leading-snug break-words [overflow-wrap:anywhere]",d.status==="completed"?"text-text-400 line-through":"text-text-200"),children:d.status==="in_progress"&&d.activeForm?d.activeForm:d.content})]},`${f}-${d.content}`))}),s]}):null]})}function sY({todos:e,live:t}){return h.jsx(RI,{title:"Tasks",items:e,live:t,progressColor:"bg-green-500",listKind:"todo"})}function oY({tasks:e,live:t}){return h.jsx(RI,{title:"Plan",items:e,live:t,progressColor:"bg-blue-500",listKind:"plan"})}function aY(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 lY(e){return(e.split("/").pop()??e)||e}function cY({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(mB,{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(uY,{memory:t},t.path))})]})}function uY({memory:e}){const[t,n]=g.useState(!1),r=aY(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:se("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(ai,{className:"w-3 h-3 text-text-400 shrink-0"}):h.jsx(li,{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:lY(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 dY({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,y=v||p,_=!n&&!v,x=(S,k)=>{const T={labels:new Set,freeText:""};if(!v||!i)return T;const N=i[S];if(typeof N!="string")return T;const O=N.split(",").map(I=>I.trim()).filter(Boolean),P=new Set(k.map(I=>I.label)),L=new Set,R=[];for(const I of O)P.has(I)?L.add(I):R.push(I);return{labels:L,freeText:R.join(", ")}},b=g.useMemo(()=>t.every(S=>{if((c[S.question]??"").trim().length>0)return!0;if(S.multiSelect){const T=a[S.question];return!!(T&&T.size>0)}return typeof s[S.question]=="string"&&s[S.question].length>0}),[t,s,a,c]),w=async()=>{if(!b||d||y||_||!n)return;const S={};for(const k of t){const T=(c[k.question]??"").trim();if(k.multiSelect){const N=a[k.question],O=N?k.options.filter(P=>N.has(P.label)).map(P=>P.label):[];if(T.length>0&&O.push(T),O.length===0)continue;S[k.question]=O.join(", ")}else if(T.length>0)S[k.question]=T;else{const N=s[k.question];typeof N=="string"&&(S[k.question]=N)}}f(!0);try{await n(S),m(!0)}finally{f(!1)}};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(PB,{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((S,k)=>{const T=`q-${k}`,N=`${e}-${k}`,O=x(S.question,S.options),P=y||_,L=c[S.question]??"",R=v?O.freeText:p?(c[S.question]??"").trim():"";return h.jsxs("div",{"data-testid":"msg-line-question-item",children:[S.question?h.jsx("div",{className:"text-text-200 mb-1.5",children:S.question}):null,h.jsx("div",{className:"flex flex-col gap-1",children:S.options.map((I,j)=>{var F;const B=`${T}-${j}`,$=v?O.labels.has(I.label):S.multiSelect?!!((F=a[S.question])!=null&&F.has(I.label)):s[S.question]===I.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:S.multiSelect?"checkbox":"radio",name:N,value:I.label,checked:$,disabled:y||_,onChange:()=>{y||_||(S.multiSelect?l(A=>{const D=new Set(A[S.question]??[]);return D.has(I.label)?D.delete(I.label):D.add(I.label),{...A,[S.question]:D}}):o(A=>({...A,[S.question]:I.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:I.label}),I.description?h.jsx("span",{className:"text-[12px] text-text-400 [overflow-wrap:anywhere]",children:I.description}):null]})]},B)})}),P?R.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:R}):null:h.jsx("textarea",{rows:3,value:L,placeholder:"或自行输入回答...",onChange:I=>{const j=I.target.value;u(B=>({...B,[S.question]:j}))},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(ni,{size:"sm",variant:"default",onClick:()=>void w(),disabled:!b||d||y||_,"data-testid":"msg-line-question-submit",children:y?"已提交 / Submitted":_?"已结束 / Ended":"提交 / Submit"}),r&&!y&&!_?h.jsx(ni,{size:"sm",variant:"ghost",onClick:()=>void r(),disabled:d,"data-testid":"msg-line-question-cancel",children:"跳过 / Skip"}):null]})]})}function hY({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(dY,{toolUseId:e,questions:t,onSubmit:i?a:void 0,...s?{onCancel:l}:{},submittedAnswers:o})}function fY(){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 du=fY();function II({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}){const y=g.useMemo(()=>g7(e),[e]);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,y.map(_=>pY(_,{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}))]})}function pY(e,t){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}=t,y=`${e.kind}-${e.seq}`;switch(e.kind){case"session-init":return null;case"user-text":{const _=typeof e.uuid=="string"?e.uuid:void 0,x=!!(n&&_&&(!r||r.has(_)));return h.jsx(WX,{text:e.text,senderDisplayName:e.senderDisplayName,rewindTarget:x&&_&&n?{userMessageId:_,onRewind:n}:void 0},y)}case"user-meta":return h.jsx(XX,{metaKind:e.metaKind,text:e.text},y);case"meta-text":return h.jsx(YX,{text:e.text,metaSource:e.metaSource},y);case"agent-notification":return h.jsx(QX,{text:e.text,taskId:e.taskId,parentToolUseId:e.parentToolUseId},y);case"assistant-text":{const _=typeof e.uuid=="string"?e.uuid:void 0,x=_&&(o||a)?{messageUuid:_,onFork:o,onQuickAsk:a}:void 0;return h.jsx(fX,{text:x7(e.text),forkTarget:x},y)}case"assistant-thinking":return h.jsx(pX,{text:e.text},y);case"permission-inline":return h.jsx($X,{tool:e.tool,input:e.input,onRespond:i??(()=>{}),onInterrupt:s},y);case"error":return h.jsx(FX,{message:e.message},y);case"turn-end":return null;case"merged-tool":return mY(e,y,{fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v});case"merged-agent":return h.jsx(iY,{description:e.description,input:e.input,output:e.output,error:e.error,pending:e.pending,notifications:e.notifications,toolResultExtra:e.toolResultExtra,progress:e.progress},y);case"plan-card":return h.jsx(oY,{tasks:e.tasks},y);case"todo-checklist":return h.jsx(sY,{todos:e.todos},y);case"memory-callout":return h.jsx(cY,{memories:e.memories},y);case"question-card":{const _=d===void 0||d.has(e.toolUseId);return h.jsx(hY,{toolUseId:e.toolUseId,questions:e.questions,historicalAnswers:e.submittedAnswers,realtimeAnswers:l==null?void 0:l[e.toolUseId],onSubmit:_?c:void 0,..._&&u?{onCancel:u}:{}},y)}default:return null}}function mY(e,t,n){const r=du.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(st.Fragment,{children:i??h.jsx(CI,{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)}function Ld(e){return e==="codex"?"Codex":"Claude Code"}const gY={builtin:"Commands",global:"Global",project:"Project",plugin:"Plugin"},PS={builtin:0,global:1,project:2,plugin:3};function vY({query:e,skills:t,activeIndex:n,onActiveIndexChange:r,onSelect:i,onEmpty:s}){const o=g.useRef(null),a=g.useMemo(()=>MI(t,e),[t,e]),l=g.useMemo(()=>{const c=new Set;let u=null;for(let d=0;d<a.length;d++)a[d].source!==u&&(c.add(d),u=a[d].source);return c},[a]);return g.useEffect(()=>{a.length===0&&(s==null||s())},[a.length,s]),g.useEffect(()=>{var c;try{(c=o.current)==null||c.scrollIntoView({block:"nearest"})}catch{}},[n]),a.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:a.map((c,u)=>{const d=u===n,f=l.has(u);return h.jsxs(st.Fragment,{children:[f?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:gY[c.source]}):null,h.jsxs("div",{ref:d?o:void 0,"data-testid":`cc-skill-item-${c.name}`,onMouseEnter:()=>r(u),onClick:()=>i(c),className:se("flex items-center gap-2.5 px-4 py-2 cursor-pointer transition-colors duration-75",d?"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:["/",c.name]}),c.description?h.jsx("span",{className:"text-[11px] text-text-300 truncate ml-auto",children:c.description}):null]})]},`${c.source}/${c.name}`)})})}function MI(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)=>(PS[i.source]??9)-(PS[s.source]??9)),r.slice(0,30)}const _Y={builtin:"Built-in",global:"Global",project:"Project",policy:"Policy",plugin:"Plugin",persona:"My personas",contact:"People","remote-persona":"Remote personas"},RS={builtin:0,global:1,project:2,policy:3,plugin:4,persona:5,contact:6,"remote-persona":7};function Fh(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 xY(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 yY(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 bY(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 AI(e,t){const n=t.trim().toLowerCase(),r=n?e.filter(i=>yY(i).includes(n)):e.slice();return r.sort((i,s)=>(RS[Fh(i)]??9)-(RS[Fh(s)]??9)),r.slice(0,30)}function IS({query:e,entries:t,activeIndex:n,onActiveIndexChange:r,onSelect:i,onEmpty:s}){const o=g.useRef(null),a=g.useMemo(()=>AI(t,e),[t,e]),l=g.useMemo(()=>{const c=new Set;let u=null;for(let d=0;d<a.length;d++){const f=Fh(a[d]);f!==u&&(c.add(d),u=f)}return c},[a]);return g.useEffect(()=>{a.length===0&&(s==null||s())},[a.length,s]),g.useEffect(()=>{var c;try{(c=o.current)==null||c.scrollIntoView({block:"nearest"})}catch{}},[n]),a.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:a.map((c,u)=>{const d=u===n,f=l.has(u),p=Fh(c),m=bY(c);return h.jsxs(st.Fragment,{children:[f?h.jsx("div",{"data-testid":`cc-agent-group-header-${p}`,"data-source":p,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:_Y[p]}):null,h.jsxs("div",{ref:d?o:void 0,"data-testid":m.testid,onMouseEnter:()=>r(u),onClick:()=>i(c),className:se("flex items-center gap-2.5 px-4 py-2 cursor-pointer transition-colors duration-75",d?"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:m.displayName}),m.description?h.jsx("span",{className:"text-[11px] text-text-300 truncate ml-2",children:m.description}):null,m.whenToUse?h.jsx("span",{className:"text-[10px] text-text-400/70 italic truncate ml-auto",children:m.whenToUse}):null,m.plugin?h.jsx("span",{className:"text-[10px] text-text-400/70 ml-2 shrink-0",children:m.plugin}):null]})]},xY(c))})})}function wY({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:se("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:se("h-7 w-7 rounded object-cover",o&&"cursor-pointer hover:opacity-80",s&&"opacity-40")}),s?h.jsx(rr,{"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(rr,{"data-testid":`attachment-spinner-${e.id}`,className:"h-3.5 w-3.5 animate-spin text-text-400"}):h.jsx(Ms,{className:"h-3.5 w-3.5 text-text-400"})}),h.jsx("span",{className:se("max-w-[120px] truncate text-text-200",s&&"text-text-400"),title:e.error??e.fileName,children:e.fileName}),i?h.jsx(Is,{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(In,{className:"h-3 w-3"})})]})}function SY({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(wY,{attachment:r,onRemove:()=>t(r.id),onOpenPreview:n?()=>n(r):void 0},r.id))})}class Ll extends Error{constructor(t,n,r){super(n),this.code=t,this.status=r,this.name="UploadAttachmentError"}}async function kY(e){if(!e.httpBaseUrl)throw new Ll("TUNNEL_NOT_READY","daemon httpBaseUrl unavailable");if(!e.httpToken)throw new Ll("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 Ll("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 Ll(i,s,r.status)}return await r.json()}const MS=25*1024*1024,CY="image/*,.txt,.md,.markdown,.csv,.json,.log,.yaml,.yml,.html,.xml,.pdf",EY=["image/","text/"],NY=new Set(["application/json","application/xml","application/x-yaml","application/yaml","application/pdf"]),TY=new Set(["txt","md","markdown","csv","json","log","yaml","yml","html","xml","pdf"]);function PY(e){var r;const t=(e.type||"").toLowerCase();if(t&&EY.some(i=>t.startsWith(i))||t&&NY.has(t))return!0;const n=((r=e.name.split(".").pop())==null?void 0:r.toLowerCase())??"";return n.length>0&&TY.has(n)}let RY=0;const IY=()=>`att-${++RY}-${Date.now()}`;function MY(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 AY(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:IY(),fileName:d.name,mimeType:d.type||"application/octet-stream"};if(!PY(d)){c.push({...f,url:null,status:"error",error:"不支持的文件类型"});continue}if(d.size>MS){c.push({...f,url:null,status:"error",error:`超过 ${Math.round(MS/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 MY(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 kY({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 Ll?f.code:"UPLOAD_FAILED",m=f.message??"upload failed";n(v=>v.map(y=>y.id===d.id?{...y,status:"error",error:`${p}: ${m}`}:y))}}))},[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}}const Gv=new Map,jY=[];function AS(e){if(e)return Gv.get(e)}function jS(e,t){e&&(t.draft.length===0&&t.attachments.length===0?Gv.delete(e):Gv.set(e,t))}function DY(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 LY({api:e,cwd:t,sessionKey:n,onSend:r,disabled:i,onNewSession:s,onClearSession:o,tool:a,spawnableContacts:l=jY,ensureRemotePersonas:c,remotePersonasByDeviceId:u}){const d=AS(n),[f,p]=g.useState((d==null?void 0:d.draft)??""),[m,v]=g.useState(!1),y=g.useRef(null),_=g.useRef(!1),x=g.useCallback(()=>{_.current=!0},[]),b=g.useCallback(()=>{_.current=!1},[]),w=Rf(),{attachments:S,setAttachments:k,addFiles:T,removeAttachment:N,clearAttachments:O}=AY({httpBaseUrl:w.httpBaseUrl,httpToken:w.httpToken,sessionId:n,initial:(d==null?void 0:d.attachments)??[]}),[P,L]=g.useState([]),[R,I]=g.useState(!1),[j,B]=g.useState(0),[$,F]=g.useState(!1),[A,D]=g.useState([]),[C,H]=g.useState(!1),[q,M]=g.useState(0),[ne,oe]=g.useState(!1),[V,pe]=g.useState([]),[Oe,re]=g.useState(!1),[Me,Fe]=g.useState(null),[We,ge]=g.useState(!1),Ge=g.useRef(null),Gt=g.useMemo(()=>{const ue=[];return s&&ue.push({name:"new",source:"builtin",description:"在当前目录下新建会话"}),o&&n&&ue.push({name:"clear",source:"builtin",description:"清除当前会话"}),ue},[s,o,n]),wt=g.useMemo(()=>[...Gt,...P],[Gt,P]),It=g.useMemo(()=>{const ue=f.match(/^\/(\S*)$/);return ue?ue[1]:null},[f]),ln=It!==null&&!$,Bt=g.useMemo(()=>It!==null?MI(wt,It):[],[wt,It]),at=g.useMemo(()=>{const ue=f.match(/^@(\S*)$/);return ue?ue[1]:null},[f]),Ue=at!==null&&!ne,tt=g.useMemo(()=>Me?((u==null?void 0:u.get(Me.deviceId))??[]).map(Ne=>({kind:"remote-persona",persona:Ne,deviceId:Me.deviceId})):[...A.map(ue=>({kind:"cc-agent",agent:ue})),...V.map(ue=>({kind:"persona",persona:ue})),...l.map(ue=>({kind:"contact",contact:ue}))],[Me,u,A,V,l]),mt=g.useMemo(()=>at!==null?AI(tt,at):[],[tt,at]),Xt=g.useRef(f);g.useEffect(()=>{f!==Xt.current&&(F(!1),oe(!1),Xt.current=f)},[f]);const pn=g.useCallback(()=>{F(!0)},[]),U=g.useCallback(()=>{oe(!0)},[]),Z=g.useRef(f),ve=g.useRef(S);g.useEffect(()=>{Z.current=f},[f]),g.useEffect(()=>{ve.current=S},[S]);const we=g.useRef(n);g.useEffect(()=>{const ue=we.current;if(ue===n)return;jS(ue,{draft:Z.current,attachments:ve.current});const Ne=AS(n);p((Ne==null?void 0:Ne.draft)??""),k((Ne==null?void 0:Ne.attachments)??[]),B(0),M(0),F(!1),oe(!1),Fe(null),Ge.current=null,ge(!1),queueMicrotask(()=>{Ne!=null&&Ne.draft?jI(y.current):Wo(y.current)}),we.current=n},[n,k]),g.useEffect(()=>()=>{jS(we.current,{draft:Z.current,attachments:ve.current})},[]),g.useEffect(()=>{B(0)},[It]),g.useEffect(()=>{M(0)},[at]),g.useEffect(()=>{at===null&&Me&&(Fe(null),Ge.current=null,ge(!1))},[at,Me]),g.useEffect(()=>{if(!ln||R)return;if(!e){I(!0);return}let ue=!1;return(async()=>{try{const Ne=await e.skillsList(t,a);ue||(L(Ne.skills??[]),I(!0))}catch{ue||I(!0)}})(),()=>{ue=!0}},[ln,R,e,t,a]),g.useEffect(()=>{if(!Ue||C)return;if(!e){H(!0);return}let ue=!1;return(async()=>{try{const Ne=await e.agentsList(t,a);ue||(D(Ne.agents??[]),H(!0))}catch{ue||H(!0)}})(),()=>{ue=!0}},[Ue,C,e,t,a]),g.useEffect(()=>{if(!Ue||Oe)return;if(!e){re(!0);return}let ue=!1;return(async()=>{try{const Ne=await e.personaList();ue||(pe((Ne.personas??[]).map(Qe=>({personaId:Qe.personaId,label:Qe.label,iconKey:Qe.iconKey}))),re(!0))}catch{ue||re(!0)}})(),()=>{ue=!0}},[Ue,Oe,e]);const Q=g.useCallback(ue=>{switch(ue.kind){case"persona":p(`@persona/${ue.persona.personaId} `);break;case"cc-agent":p(`@"${ue.agent.name} (agent)" `);break;case"contact":{const Ne=ue.contact.deviceId;Fe({deviceId:Ne,displayName:ue.contact.displayName}),Ge.current=Ne,ge(!0),Promise.resolve(c==null?void 0:c(Ne)).finally(()=>{Ge.current===Ne&&ge(!1)}),p("@"),oe(!1),setTimeout(()=>{var Qe;return(Qe=y.current)==null?void 0:Qe.focus()},0);return}case"remote-persona":p(`@persona/${ue.persona.personaId}@${ue.deviceId} `),Fe(null);break}oe(!1),setTimeout(()=>{var Ne;return(Ne=y.current)==null?void 0:Ne.focus()},0)},[c]),Xe=g.useCallback(()=>{Fe(null),Ge.current=null,ge(!1),p("@"),setTimeout(()=>{var ue;return(ue=y.current)==null?void 0:ue.focus()},0)},[]),Yt=g.useCallback(ue=>{if(ue.source==="builtin"&&ue.name==="new"&&s){p(""),O(),Wo(y.current),s(t);return}if(ue.source==="builtin"&&ue.name==="clear"&&o){p(""),O(),Wo(y.current),o();return}p(`/${ue.name} `),setTimeout(()=>{var Ne;return(Ne=y.current)==null?void 0:Ne.focus()},0)},[s,t,O,o]),Zt=g.useCallback(async()=>{const ue=f.trim(),Ne=S.filter(Qe=>Qe.status==="done");if(!(!ue&&Ne.length===0)&&!(m||i)){if(ue==="/new"&&s){v(!0);try{await s(t),p(""),O(),Wo(y.current)}finally{v(!1)}return}if(ue==="/clear"&&o){v(!0);try{await o(),p(""),O(),Wo(y.current)}finally{v(!1)}return}v(!0);try{const Qe=a==="codex"?DY(ue,P):ue,Dn=UX(Qe,S);await r(Dn),p(""),O(),Wo(y.current)}finally{v(!1)}}},[f,S,m,i,r,s,t,O,o,a,P]);return{draft:f,setDraft:p,sending:m,textareaRef:y,isComposingRef:_,onCompositionStart:x,onCompositionEnd:b,attachments:S,addFiles:T,removeAttachment:N,skillSelectorVisible:ln,filteredSkills:Bt,slashQuery:It??"",activeSkillIdx:j,setActiveSkillIdx:B,selectSkill:Yt,dismissSkillSelector:pn,agentSelectorVisible:Ue,filteredAgents:mt,mentionQuery:at,activeAgentIdx:q,setActiveAgentIdx:M,selectAgent:Q,dismissAgentSelector:U,drilldown:Me,drilldownLoading:We,exitDrilldown:Xe,doSend:Zt}}const OY=120;function jI(e){e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,OY)}px`)}function Wo(e){e&&(e.style.height="auto")}const BY={spawnableContacts:[],ensureRemotePersonas:()=>Promise.resolve(),remotePersonasByDeviceId:new Map},zY=g.createContext(BY);function $Y(){return g.useContext(zY)}function FY({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{DS(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(Mf,{className:"h-3 w-3"}),r?"Copied":"Copy"]}),h.jsxs("button",{type:"button",onClick:()=>DS(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(zB,{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(In,{className:"h-3 w-3"})})]})]})})}function DS(e,t){const n=document.createElement("a");n.href=e,n.download=t||"image",n.click()}function HY({meta:e,api:t,cwd:n,tool:r,onSend:i,sessionKey:s,disabled:o=!1,placeholder:a,className:l,awaitingUser:c=!1,onAbort:u,onNewSession:d,onClearSession:f}){const p=(e==null?void 0:e.streamInProgress)??!1,m=g.useRef(null),v=$Y(),y=LY({...t?{api:t}:{},cwd:n,...r?{tool:r}:{},sessionKey:s,onSend:i,disabled:o,...d?{onNewSession:d}:{},...f?{onClearSession:f}:{},spawnableContacts:v.spawnableContacts,ensureRemotePersonas:v.ensureRemotePersonas,remotePersonasByDeviceId:v.remotePersonasByDeviceId}),{draft:_,setDraft:x,sending:b,textareaRef:w,attachments:S,addFiles:k,removeAttachment:T,skillSelectorVisible:N,filteredSkills:O,slashQuery:P,activeSkillIdx:L,setActiveSkillIdx:R,selectSkill:I,dismissSkillSelector:j,agentSelectorVisible:B,filteredAgents:$,mentionQuery:F,activeAgentIdx:A,setActiveAgentIdx:D,selectAgent:C,dismissAgentSelector:H,drilldown:q,drilldownLoading:M,exitDrilldown:ne,doSend:oe}=y,V=!!t,pe=b||o||p,re=(_.trim().length>0||S.some(Q=>Q.status==="done"))&&!o&&!b&&!c,Me=a??(c?"Answer the question above first...":pe?"Queue a message...":`Message ${Ld(r)}...`),Fe=g.useRef(!1),We=g.useCallback(()=>{Fe.current=!0},[]),ge=g.useCallback(()=>{Fe.current=!1},[]),Ge=g.useCallback(Q=>{if(N&&O.length>0){if(Q.key==="ArrowDown")return Q.preventDefault(),R(L>=O.length-1?0:L+1),!0;if(Q.key==="ArrowUp")return Q.preventDefault(),R(L<=0?O.length-1:L-1),!0;if(Q.key==="Tab"||Q.key==="Enter"&&!Q.shiftKey){Q.preventDefault();const Xe=O[L];return Xe&&I(Xe),!0}if(Q.key==="Escape")return Q.preventDefault(),j(),!0}return!1},[N,O,L,R,I,j]),Gt=g.useCallback(Q=>{if(B&&$.length>0){if(Q.key==="ArrowDown")return Q.preventDefault(),D(A>=$.length-1?0:A+1),!0;if(Q.key==="ArrowUp")return Q.preventDefault(),D(A<=0?$.length-1:A-1),!0;if(Q.key==="Tab"||Q.key==="Enter"&&!Q.shiftKey){Q.preventDefault();const Xe=$[A];return Xe&&C(Xe),!0}if(Q.key==="Escape")return Q.preventDefault(),q?ne():H(),!0}return!1},[B,$,A,D,C,H,q,ne]),wt=g.useCallback(Q=>{const Xe=Q.nativeEvent;Q.key==="Enter"&&ZP({compositionActive:Fe.current,nativeIsComposing:Xe.isComposing,keyCode:Xe.keyCode})||Ge(Q)||Gt(Q)||QP({key:Q.key,shiftKey:Q.shiftKey,compositionActive:Fe.current,nativeIsComposing:Xe.isComposing,keyCode:Xe.keyCode})&&(Q.preventDefault(),re&&oe())},[Ge,Gt,re,oe]),It=g.useCallback(Q=>{x(Q.target.value),jI(Q.target)},[x]),ln=g.useCallback(Q=>{Q.target.files&&k(Q.target.files),Q.target.value=""},[k]),Bt=g.useCallback(Q=>{if(!V)return;const Xe=Array.from(Q.clipboardData.items).map(Yt=>Yt.getAsFile()).filter(Yt=>!!(Yt&&Yt.type.startsWith("image/")));Xe.length!==0&&(Q.preventDefault(),k(Xe))},[k,V]),[at,Ue]=g.useState(null),tt=g.useCallback(Q=>{Q.previewUrl&&Ue({url:Q.previewUrl,name:Q.fileName})},[]),[mt,Xt]=g.useState(!1),pn=g.useCallback(Q=>{V&&(Q.preventDefault(),Xt(!0))},[V]),U=g.useCallback(()=>Xt(!1),[]),Z=g.useCallback(Q=>{V&&(Q.preventDefault(),Xt(!1),Q.dataTransfer.files.length>0&&k(Q.dataTransfer.files))},[k,V]),ve=p&&!c&&typeof u=="function",we=o||c;return h.jsxs("div",{"data-testid":"chat-input",className:se("shrink-0 border-t border-bg-300/20 px-4 py-3",l),onDragOver:pn,onDragLeave:U,onDrop:Z,children:[h.jsxs("div",{className:"max-w-3xl mx-auto relative",children:[V?h.jsx("input",{ref:m,type:"file",multiple:!0,accept:CY,hidden:!0,onChange:ln,"data-testid":"chat-input-file"}):null,h.jsxs("div",{"data-testid":"chat-input-bare",className:se("flex flex-col gap-2"),children:[c||b||p?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:c?"Waiting for your answer":`${r==="codex"?"Codex":"Claude"} is working`})]}):null,N?h.jsx(vY,{query:P,skills:O,activeIndex:L,onActiveIndexChange:R,onSelect:I}):null,B?q?!v.remotePersonasByDeviceId.has(q.deviceId)&&M?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:`正在加载 @${q.displayName} 的 persona…`}):$.length>0?h.jsx(IS,{query:F??"",entries:$,activeIndex:A,onActiveIndexChange:D,onSelect:C}):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:`@${q.displayName} 暂无可派活的 persona(可能离线或未公开)`}):h.jsx(IS,{query:F??"",entries:$,activeIndex:A,onActiveIndexChange:D,onSelect:C}):null,S.length>0?h.jsx(SY,{attachments:S,onRemove:T,onOpenPreview:tt}):null,h.jsxs("div",{"data-testid":"bare-chat-input-frame",className:se("flex items-end gap-2 rounded-xl border border-bg-300 bg-bg-50 px-3 py-2 transition-colors duration-200",we?"opacity-60":null,mt?"border-accent/60 bg-accent/5":null),children:[V?h.jsx("button",{type:"button",onClick:()=>{var Q;return(Q=m.current)==null?void 0:Q.click()},disabled:pe,"data-testid":"chat-input-attach","aria-label":"attach files",className:se("flex h-8 w-8 shrink-0 self-end items-center justify-center rounded-md transition-colors",pe?"cursor-default text-text-400/50":"cursor-pointer text-text-400 hover:bg-text-100/5 hover:text-text-200"),children:h.jsx(f6,{className:"h-4 w-4"})}):null,h.jsx("textarea",{ref:w,"data-testid":"chat-input-textarea",value:_,onChange:It,onKeyDown:wt,onCompositionStart:We,onCompositionEnd:ge,onPaste:Bt,placeholder:Me,disabled:we,readOnly:we,rows:1,className:"flex-1 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 shrink-0 pb-0.5",children:[ve?h.jsx("button",{type:"button",onClick:u,"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(AN,{className:"w-3.5 h-3.5",strokeWidth:2.5})}):null,h.jsx("button",{type:"button",onClick:()=>{re&&oe()},disabled:!re,"data-testid":"chat-input-send","aria-label":"send",className:se("h-8 w-8 rounded-full flex items-center justify-center transition-colors",re?"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(uB,{className:"w-4 h-4",strokeWidth:2.5})})]})]})]})]}),at?h.jsx(FY,{url:at.url,fileName:at.name,onClose:()=>Ue(null)}):null]})}function UY(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function WY({meta:e,tool:t,connState:n,onOpenConfig:r,models:i,liveGitBranch:s,liveWorktreeRoot:o,onForceStop:a,cronActiveCount:l,onCronClick:c,onOpenFiles:u,onTogglePin:d,isHolded:f=!1,onToggleHold:p,personaName:m,onOpenPersona:v,className:y}){const _=e.procAlive??!1,x=e.streamInProgress??!1,b=e.permissionMode,w=b&&b!=="default"?b:null,S=w==="bypassPermissions"?"YOLO":w==="plan"?"Plan":null,k=e.model??"",T=VY(i,k),N=e.contextPct??null,O=N==null?"":N>=80?"text-red-400":N>=50?"text-amber-400":"text-text-500",P=s!==void 0?s:e.gitBranch??null,L=o??e.cwd??"",I=!!e.sessionLabel&&e.sessionLabel!==e.sessionId?e.sessionLabel:UY(L),j=L,B=e.pinnedAt!=null;return h.jsxs("div",{"data-testid":"chat-header",className:se("relative flex flex-col justify-center shrink-0 px-4 pr-14 py-2 gap-1",y),children:[h.jsxs("div",{className:"flex items-center min-w-0 gap-2 text-[13px]",children:[d?h.jsx("button",{type:"button",onClick:()=>d(!B),"data-testid":"chat-header-pin-toggle","data-pinned":B?"true":"false","aria-pressed":B,title:B?"Unpin session":"Pin session",className:se("shrink-0 inline-flex items-center justify-center h-5 w-5 rounded-md cursor-pointer transition-colors",B?"text-amber-400 hover:bg-amber-500/10":"text-text-500 hover:text-text-200 hover:bg-text-100/5"),children:h.jsx(DN,{className:se("w-3.5 h-3.5",B&&"fill-current")})}):null,p?h.jsx("button",{type:"button",onClick:()=>p(!f),"data-testid":"chat-header-hold-toggle","data-holded":f?"true":"false","aria-pressed":f,title:f?"Release hold":"Hold session",className:se("shrink-0 inline-flex items-center justify-center h-5 w-5 rounded-md cursor-pointer transition-colors",f?"text-amber-400 hover:bg-amber-500/10":"text-text-500 hover:text-text-200 hover:bg-text-100/5"),children:h.jsx(xB,{className:se("w-3.5 h-3.5",f&&"fill-current")})}):null,h.jsx("span",{className:"font-semibold text-text-100 truncate","data-testid":"chat-header-worktree",title:j,children:I}),P?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-500 shrink-0",children:":"}),h.jsx("span",{className:"font-mono text-text-300 truncate","data-testid":"chat-header-git",title:P,children:P})]}):null]}),h.jsxs("div",{className:"flex items-center min-w-0 gap-2 text-[11px]",children:[S?h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("desktop"),"data-testid":"chat-header-mode-chip",className:se("hidden md:inline-flex shrink-0 px-2 py-0.5 rounded-md font-semibold cursor-pointer transition-colors",w==="bypassPermissions"?"bg-red-500/15 text-red-400 hover:bg-red-500/25":"bg-blue-500/15 text-blue-400 hover:bg-blue-500/25"),children:S}),h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("mobile"),"aria-hidden":"true",tabIndex:-1,className:se("inline-flex md:hidden shrink-0 px-2 py-0.5 rounded-md font-semibold cursor-pointer transition-colors",w==="bypassPermissions"?"bg-red-500/15 text-red-400 hover:bg-red-500/25":"bg-blue-500/15 text-blue-400 hover:bg-blue-500/25"),children:S})]}):null,k||i?h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("desktop"),"data-testid":"chat-header-model-chip",className:"hidden md:inline-flex shrink-0 font-mono text-text-400 cursor-pointer hover:text-text-200 transition-colors",children:T}),h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("mobile"),"aria-hidden":"true",tabIndex:-1,className:"inline-flex md:hidden shrink-0 font-mono text-text-400 cursor-pointer hover:text-text-200 transition-colors",children:T})]}):null,N!=null?h.jsxs("span",{className:se("shrink-0 font-mono",O),"data-testid":"chat-header-ctx",children:["ctx:",N,"%"]}):null,h.jsxs("span",{"data-testid":"chat-header-proc-status",className:"inline-flex items-center gap-1 text-text-500 shrink-0",title:x?`${Ld(t)} 正在跑当前 turn`:_?`${Ld(t)} 进程仍活,等下一轮输入`:`${Ld(t)} 进程未运行(发送消息会自动启动)`,children:[h.jsx("span",{className:se("w-1.5 h-1.5 rounded-full",x?"bg-green-500":"bg-text-400/50")}),h.jsx("span",{children:x?"running":"idle"})]}),_&&a?h.jsxs("button",{type:"button",onClick:a,"data-testid":"chat-header-force-stop",title:t==="codex"?"强制停止 Codex 进程":"强制停止 Claude Code 进程(会丢失 initialize / 预热缓存)",className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-400 hover:bg-red-500/10 hover:text-red-400 transition-colors cursor-pointer",children:[h.jsx(d6,{className:"w-3 h-3"}),h.jsx("span",{children:"Stop"})]}):null,m&&v||u||l&&l>0&&c?h.jsx("span",{className:"text-text-500 shrink-0","aria-hidden":"true",children:"·"}):null,m&&v?h.jsxs("button",{type:"button",onClick:v,"data-testid":"chat-header-persona",title:m,className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-300 hover:bg-bg-200 hover:text-text-100 transition-colors cursor-pointer",children:[h.jsx(q_,{className:"w-3 h-3"}),h.jsx("span",{className:"truncate max-w-[80px] md:max-w-[120px]",children:m})]}):null,u?h.jsxs("button",{type:"button",onClick:u,"data-testid":"chat-header-files",title:"Edited Files",className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-300 hover:bg-bg-200 hover:text-text-100 transition-colors cursor-pointer",children:[h.jsx(qB,{className:"w-3 h-3"}),h.jsx("span",{className:"hidden md:inline",children:"Edited Files"})]}):null,l&&l>0&&c?h.jsxs("button",{type:"button","data-testid":"chat-header-cron-button",onClick:c,"aria-label":"Cron tasks",title:`${l} active cron task${l===1?"":"s"}`,className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-400 hover:bg-accent-dim hover:text-accent transition-colors cursor-pointer",children:[h.jsx(MB,{className:"w-3 h-3"}),h.jsx("span",{"data-testid":"chat-header-cron-badge",className:"font-mono",children:l})]}):null]}),r?h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button","aria-label":"Session settings","data-testid":"chat-header-settings",onClick:()=>r("desktop"),title:"Session settings",className:"hidden md:flex absolute right-4 top-3 z-10 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(bv,{className:"w-4 h-4"})}),h.jsx("button",{type:"button","aria-label":"Session settings","data-testid":"chat-header-settings-mobile",onClick:()=>r("mobile"),title:"Session settings",className:"flex md:hidden absolute right-4 top-3 z-10 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(bv,{className:"w-4 h-4"})})]}):null]})}function VY(e,t){if(!t)return"default";const n=t.toLowerCase(),r=[["opus","Opus"],["sonnet","Sonnet"],["haiku","Haiku"]];for(const[a,l]of r){if(!n.includes(a))continue;const c=n.match(new RegExp(`${a}-(\\d+)-(\\d+)`));return c?`${l} ${c[1]}.${c[2]}`:l}const i=e??[],s=i.find(a=>a.id===t);if(s)return s.label;const o=i.find(a=>a.id&&t.toLowerCase().includes(a.id.toLowerCase()));return o?o.label:t}function qY(e){return e==="TodoWrite"}function KY(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 GY(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":LS(r,l,"assistant-text",a.text,a.partialId,a.uuid);break;case"thinking":LS(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,senderDisplayName:(s=a.sender)==null?void 0:s.displayName});break}case"tool_call":DI(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":r.push({kind:"turn-end",seq:l});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 DI(e,t,n,r,i,s){if(qY(r)){const o=KY(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(h7(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 LS(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 XY="AskUserQuestion";function LI(e,t=0,n){const r=[],i=new Map;let s=t;for(const o of e){const a=s++,l=o.toolUseId??`hist-${a}`;switch(o.kind){case"user-text":o.meta==="task-notification"?r.push({kind:"agent-notification",seq:a,text:o.text??"",taskId:o.taskId,parentToolUseId:o.parentToolUseId}):o.meta?r.push({kind:"user-meta",seq:a,metaKind:o.meta,text:o.text??""}):r.push({kind:"user-text",seq:a,text:o.text??"",uuid:o.uuid});break;case"assistant-text":r.push({kind:"assistant-text",seq:a,text:o.text??"",uuid:o.uuid});break;case"tool_call":{if(o.tool===XY){const c=o.input??{},u=Array.isArray(c.questions)?c.questions:[];i.set(l,r.length),r.push({kind:"question-card",seq:a,toolUseId:l,questions:u});break}DI(r,a,l,o.tool??"",o.input,n);break}case"tool_result":{const c=i.get(l);if(c!==void 0){if(o.askQuestionAnswers){const d=r[c];d.submittedAnswers=o.askQuestionAnswers}i.delete(l);break}const u={kind:"tool-result",seq:a,toolUseId:l,output:o.output};o.error!==void 0&&(u.error=o.error),o.toolResultExtra&&(u.toolResultExtra=o.toolResultExtra),r.push(u);break}case"attachment_memories":o.memories&&o.memories.length>0&&r.push({kind:"memory-callout",seq:a,memories:o.memories});break}}return r}function YY({api:e,cwd:t,toolSessionId:n}){const r=PI(),i=(r==null?void 0:r.state.agentId)??null,s=r==null?void 0:r.state.agentType,[o,a]=g.useState([]),[l,c]=g.useState(!1),[u,d]=g.useState(null);g.useEffect(()=>{if(!i)return;let p=!1;return c(!0),d(null),a([]),e.historySubagentRead({cwd:t,toolSessionId:n,subagentId:i}).then(m=>{p||a(m.messages??[])}).catch(m=>{p||d(m instanceof Error?m.message:String(m))}).finally(()=>{p||c(!1)}),()=>{p=!0}},[i,t,n,e]);const f=g.useMemo(()=>o.length>0?LI(o,0,"claude"):[],[o]);return!r||!i?null:h.jsxs("div",{"data-testid":"subagent-drawer","data-agent-id":i,className:se("fixed inset-y-0 right-0 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:[s?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:s}):null,h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate",title:i,children:i})]}),h.jsx("button",{type:"button","aria-label":"关闭",onClick:()=>r.close(),className:"p-1 rounded hover:bg-bg-200/50 text-text-400 hover:text-text-200",children:h.jsx(In,{className:"w-4 h-4"})})]}),!l&&!u&&o.length>0?h.jsxs("div",{className:"text-[11px] text-text-400",children:[o.length," 条消息 · 首条为主会话派发的任务指令"]}):null]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden px-3 py-2",children:l?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(rr,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"加载中…"})]}):u?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-error",children:[h.jsx(Is,{className:"w-3.5 h-3.5"}),h.jsx("span",{children:u})]}):f.length===0?h.jsx("div",{className:"text-[12px] text-text-400 italic",children:"无消息"}):h.jsx(II,{lines:f})})]})}function OS(e,t){let n=0;for(const r of e.lines)r.startsWith(t)&&n++;return n}function ZY(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+=OS(m,"+"),p.deletions+=OS(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 QY({open:e,onOpenChange:t,api:n,sessionId:r,userMessageId:i,lines:s,procAlive:o,onApplied:a,onNoChanges:l}){const c=g.useMemo(()=>ZY(s,i),[s,i]),[u,d]=g.useState(null),[f,p]=g.useState(!1),[m,v]=g.useState(!1),[y,_]=g.useState(null);g.useEffect(()=>{if(!e)return;let k=!1;return p(!0),d(null),(async()=>{try{const T=await n.sessionRewindDiff({sessionId:r,userMessageId:i});k||(d(T),!T.canRewind&&!T.error&&T.files.length===0&&(l==null||l(i)))}catch{k||d(null)}finally{k||p(!1)}})(),()=>{k=!0}},[e,n,r,i]);const x=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(T=>({filePath:T.filePath,hunks:T.hunks,insertions:T.insertions,deletions:T.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]),b=g.useCallback(async()=>{v(!0),_(null);try{const k=await n.sessionRewind({sessionId:r,userMessageId:i,dryRun:!1});if(!k.canRewind){_(k.error??"回退失败");return}a==null||a(),t(!1)}catch(k){_(k.message||"回退失败")}finally{v(!1)}},[n,r,i,a,t]);if(!e)return null;const w=x.files.length>0,S=!f&&!m&&x.anchorFound&&w&&!y;return h.jsxs("div",{"data-testid":"rewind-preview-drawer",className:"fixed right-0 top-0 bottom-0 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(ON,{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(In,{className:"w-4 h-4"})})]}),y?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(Mc,{className:"w-4 h-4 shrink-0 mt-0.5"}),h.jsx("span",{children:y})]}):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(rr,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"正在读取快照…"})]}):x.anchorFound?w?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:x.files.length})," ","个文件,",h.jsxs("span",{className:"text-green-500 font-mono",children:["+",x.totalInsertions]})," / ",h.jsxs("span",{className:"text-red-400 font-mono",children:["-",x.totalDeletions]})]}),x.source==="local"?h.jsx("div",{"data-testid":"rewind-source-hint",className:"mt-1 text-text-400 text-[11px]",children:"基于对话里 tool_result 估算(未读到 CC 快照,数字可能与实际磁盘略有差异)"}):null]}),x.files.map(k=>h.jsx(eZ,{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:[w&&x.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(Mc,{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:!S,onClick:()=>void b(),"data-testid":"rewind-apply",className:se("h-8 px-3 rounded-md text-[12px] font-medium transition-colors",S?"bg-accent text-white hover:bg-accent-hover cursor-pointer":"bg-bg-200 text-text-400 cursor-not-allowed"),children:m?"回退中…":"确认回退"})]})]})]})}function JY(e){return e.replace(/^\/Users\/[^/]+/,"~")}function eZ({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(ai,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(li,{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:JY(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(tZ,{hunk:r},`${r.oldStart}-${r.oldLines}-${r.newStart}-${r.newLines}`))}):null]})}function tZ({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:se("px-3 whitespace-pre",s),children:n.length>0?n:" "},r)})]})}var tp="Dialog",[OI]=Eo(tp),[nZ,Or]=OI(tp),BI=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!0}=e,a=g.useRef(null),l=g.useRef(null),[c,u]=Af({prop:r,defaultProp:i??!1,onChange:s,caller:tp});return h.jsx(nZ,{scope:t,triggerRef:a,contentRef:l,contentId:to(),titleId:to(),descriptionId:to(),open:c,onOpenChange:u,onOpenToggle:g.useCallback(()=>u(d=>!d),[u]),modal:o,children:n})};BI.displayName=tp;var zI="DialogTrigger",rZ=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Or(zI,n),s=qt(t,i.triggerRef);return h.jsx(Et.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Yx(i.open),...r,ref:s,onClick:Te(e.onClick,i.onOpenToggle)})});rZ.displayName=zI;var Gx="DialogPortal",[iZ,$I]=OI(Gx,{forceMount:void 0}),FI=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,s=Or(Gx,t);return h.jsx(iZ,{scope:t,forceMount:n,children:g.Children.map(r,o=>h.jsx(zi,{present:n||s.open,children:h.jsx(ix,{asChild:!0,container:i,children:o})}))})};FI.displayName=Gx;var Hh="DialogOverlay",HI=g.forwardRef((e,t)=>{const n=$I(Hh,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=Or(Hh,e.__scopeDialog);return s.modal?h.jsx(zi,{present:r||s.open,children:h.jsx(oZ,{...i,ref:t})}):null});HI.displayName=Hh;var sZ=Ac("DialogOverlay.RemoveScroll"),oZ=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Or(Hh,n);return h.jsx(sx,{as:sZ,allowPinchZoom:!0,shards:[i.contentRef],children:h.jsx(Et.div,{"data-state":Yx(i.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),_o="DialogContent",UI=g.forwardRef((e,t)=>{const n=$I(_o,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=Or(_o,e.__scopeDialog);return h.jsx(zi,{present:r||s.open,children:s.modal?h.jsx(aZ,{...i,ref:t}):h.jsx(lZ,{...i,ref:t})})});UI.displayName=_o;var aZ=g.forwardRef((e,t)=>{const n=Or(_o,e.__scopeDialog),r=g.useRef(null),i=qt(t,n.contentRef,r);return g.useEffect(()=>{const s=r.current;if(s)return HT(s)},[]),h.jsx(WI,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Te(e.onCloseAutoFocus,s=>{var o;s.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Te(e.onPointerDownOutside,s=>{const o=s.detail.originalEvent,a=o.button===0&&o.ctrlKey===!0;(o.button===2||a)&&s.preventDefault()}),onFocusOutside:Te(e.onFocusOutside,s=>s.preventDefault())})}),lZ=g.forwardRef((e,t)=>{const n=Or(_o,e.__scopeDialog),r=g.useRef(!1),i=g.useRef(!1);return h.jsx(WI,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,a;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),WI=g.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,...o}=e,a=Or(_o,n),l=g.useRef(null),c=qt(t,l);return lT(),h.jsxs(h.Fragment,{children:[h.jsx(X_,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:h.jsx(jf,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Yx(a.open),...o,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),h.jsxs(h.Fragment,{children:[h.jsx(cZ,{titleId:a.titleId}),h.jsx(dZ,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Xx="DialogTitle",VI=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Or(Xx,n);return h.jsx(Et.h2,{id:i.titleId,...r,ref:t})});VI.displayName=Xx;var qI="DialogDescription",KI=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Or(qI,n);return h.jsx(Et.p,{id:i.descriptionId,...r,ref:t})});KI.displayName=qI;var GI="DialogClose",XI=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Or(GI,n);return h.jsx(Et.button,{type:"button",...r,ref:t,onClick:Te(e.onClick,()=>i.onOpenChange(!1))})});XI.displayName=GI;function Yx(e){return e?"open":"closed"}var YI="DialogTitleWarning",[gne,ZI]=zz(YI,{contentName:_o,titleName:Xx,docsSlug:"dialog"}),cZ=({titleId:e})=>{const t=ZI(YI),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
517
517
|
|
|
518
518
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
519
519
|
|
|
@@ -534,15 +534,15 @@ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){t
|
|
|
534
534
|
|
|
535
535
|
`+e.stack):new Error(e.message+`
|
|
536
536
|
|
|
537
|
-
`+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)}},jZ=new AZ;function Od(e){DZ(e)||jZ.onUnexpectedError(e)}var Jv="Canceled";function DZ(e){return e instanceof LZ?!0:e instanceof Error&&e.name===Jv&&e.message===Jv}var LZ=class extends Error{constructor(){super(Jv),this.name=this.message}};function OZ(e){return new Error(`Illegal argument: ${e}`)}var HS=class e0 extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof e0)return t;let n=new e0;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},t0=class _M extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,_M.prototype)}};function Kn(e,t=0){return e[e.length-(1+t)]}var BZ;(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})(BZ||(BZ={}));function zZ(e,t){let n=this,r=!1,i;return function(){return r||(r=!0,t||(i=e.apply(n,arguments))),i}}var xM;(e=>{function t(w){return w&&typeof w=="object"&&typeof w[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(w){yield w}e.single=i;function s(w){return t(w)?w:i(w)}e.wrap=s;function o(w){return w||n}e.from=o;function*a(w){for(let S=w.length-1;S>=0;S--)yield w[S]}e.reverse=a;function l(w){return!w||w[Symbol.iterator]().next().done===!0}e.isEmpty=l;function c(w){return w[Symbol.iterator]().next().value}e.first=c;function u(w,S){let k=0;for(let T of w)if(S(T,k++))return!0;return!1}e.some=u;function d(w,S){for(let k of w)if(S(k))return k}e.find=d;function*f(w,S){for(let k of w)S(k)&&(yield k)}e.filter=f;function*p(w,S){let k=0;for(let T of w)yield S(T,k++)}e.map=p;function*m(w,S){let k=0;for(let T of w)yield*S(T,k++)}e.flatMap=m;function*v(...w){for(let S of w)yield*S}e.concat=v;function y(w,S,k){let T=k;for(let N of w)T=S(T,N);return T}e.reduce=y;function*_(w,S,k=w.length){for(S<0&&(S+=w.length),k<0?k+=w.length:k>w.length&&(k=w.length);S<k;S++)yield w[S]}e.slice=_;function x(w,S=Number.POSITIVE_INFINITY){let k=[];if(S===0)return[k,w];let T=w[Symbol.iterator]();for(let N=0;N<S;N++){let O=T.next();if(O.done)return[k,e.empty()];k.push(O.value)}return[k,{[Symbol.iterator](){return T}}]}e.consume=x;async function b(w){let S=[];for await(let k of w)S.push(k);return Promise.resolve(S)}e.asyncToArray=b})(xM||(xM={}));function xo(e){if(xM.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 $Z(...e){return pt(()=>xo(e))}function pt(e){return{dispose:zZ(()=>{e()})}}var yM=class bM{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{xo(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?bM.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)}};yM.DISABLE_DISPOSED_WARNING=!1;var ys=yM,Le=class{constructor(){this._store=new ys,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)}};Le.None=Object.freeze({dispose(){}});var za=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}},wi=typeof window=="object"?window:globalThis,n0=class r0{constructor(t){this.element=t,this.next=r0.Undefined,this.prev=r0.Undefined}};n0.Undefined=new n0(void 0);var gt=n0,US=class{constructor(){this._first=gt.Undefined,this._last=gt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===gt.Undefined}clear(){let e=this._first;for(;e!==gt.Undefined;){let t=e.next;e.prev=gt.Undefined,e.next=gt.Undefined,e=t}this._first=gt.Undefined,this._last=gt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new gt(e);if(this._first===gt.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!==gt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==gt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==gt.Undefined&&e.next!==gt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===gt.Undefined&&e.next===gt.Undefined?(this._first=gt.Undefined,this._last=gt.Undefined):e.next===gt.Undefined?(this._last=this._last.prev,this._last.next=gt.Undefined):e.prev===gt.Undefined&&(this._first=this._first.next,this._first.prev=gt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==gt.Undefined;)yield e.element,e=e.next}},FZ=globalThis.performance&&typeof globalThis.performance.now=="function",HZ=class wM{static create(t){return new wM(t)}constructor(t){this._now=FZ&&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}},dn;(e=>{e.None=()=>Le.None;function t(R,I){return d(R,()=>{},0,void 0,!0,void 0,I)}e.defer=t;function n(R){return(I,j=null,B)=>{let $=!1,F;return F=R(A=>{if(!$)return F?F.dispose():$=!0,I.call(j,A)},null,B),$&&F.dispose(),F}}e.once=n;function r(R,I,j){return c((B,$=null,F)=>R(A=>B.call($,I(A)),null,F),j)}e.map=r;function i(R,I,j){return c((B,$=null,F)=>R(A=>{I(A),B.call($,A)},null,F),j)}e.forEach=i;function s(R,I,j){return c((B,$=null,F)=>R(A=>I(A)&&B.call($,A),null,F),j)}e.filter=s;function o(R){return R}e.signal=o;function a(...R){return(I,j=null,B)=>{let $=$Z(...R.map(F=>F(A=>I.call(j,A))));return u($,B)}}e.any=a;function l(R,I,j,B){let $=j;return r(R,F=>($=I($,F),$),B)}e.reduce=l;function c(R,I){let j,B={onWillAddFirstListener(){j=R($.fire,$)},onDidRemoveLastListener(){j==null||j.dispose()}},$=new J(B);return I==null||I.add($),$.event}function u(R,I){return I instanceof Array?I.push(R):I&&I.add(R),R}function d(R,I,j=100,B=!1,$=!1,F,A){let D,C,H,q=0,M,ne={leakWarningThreshold:F,onWillAddFirstListener(){D=R(V=>{q++,C=I(C,V),B&&!H&&(oe.fire(C),C=void 0),M=()=>{let pe=C;C=void 0,H=void 0,(!B||q>1)&&oe.fire(pe),q=0},typeof j=="number"?(clearTimeout(H),H=setTimeout(M,j)):H===void 0&&(H=0,queueMicrotask(M))})},onWillRemoveListener(){$&&q>0&&(M==null||M())},onDidRemoveLastListener(){M=void 0,D.dispose()}},oe=new J(ne);return A==null||A.add(oe),oe.event}e.debounce=d;function f(R,I=0,j){return e.debounce(R,(B,$)=>B?(B.push($),B):[$],I,void 0,!0,void 0,j)}e.accumulate=f;function p(R,I=(B,$)=>B===$,j){let B=!0,$;return s(R,F=>{let A=B||!I(F,$);return B=!1,$=F,A},j)}e.latch=p;function m(R,I,j){return[e.filter(R,I,j),e.filter(R,B=>!I(B),j)]}e.split=m;function v(R,I=!1,j=[],B){let $=j.slice(),F=R(C=>{$?$.push(C):D.fire(C)});B&&B.add(F);let A=()=>{$==null||$.forEach(C=>D.fire(C)),$=null},D=new J({onWillAddFirstListener(){F||(F=R(C=>D.fire(C)),B&&B.add(F))},onDidAddFirstListener(){$&&(I?setTimeout(A):A())},onDidRemoveLastListener(){F&&F.dispose(),F=null}});return B&&B.add(D),D.event}e.buffer=v;function y(R,I){return(j,B,$)=>{let F=I(new x);return R(function(A){let D=F.evaluate(A);D!==_&&j.call(B,D)},void 0,$)}}e.chain=y;let _=Symbol("HaltChainable");class x{constructor(){this.steps=[]}map(I){return this.steps.push(I),this}forEach(I){return this.steps.push(j=>(I(j),j)),this}filter(I){return this.steps.push(j=>I(j)?j:_),this}reduce(I,j){let B=j;return this.steps.push($=>(B=I(B,$),B)),this}latch(I=(j,B)=>j===B){let j=!0,B;return this.steps.push($=>{let F=j||!I($,B);return j=!1,B=$,F?$:_}),this}evaluate(I){for(let j of this.steps)if(I=j(I),I===_)break;return I}}function b(R,I,j=B=>B){let B=(...D)=>A.fire(j(...D)),$=()=>R.on(I,B),F=()=>R.removeListener(I,B),A=new J({onWillAddFirstListener:$,onDidRemoveLastListener:F});return A.event}e.fromNodeEventEmitter=b;function w(R,I,j=B=>B){let B=(...D)=>A.fire(j(...D)),$=()=>R.addEventListener(I,B),F=()=>R.removeEventListener(I,B),A=new J({onWillAddFirstListener:$,onDidRemoveLastListener:F});return A.event}e.fromDOMEventEmitter=w;function S(R){return new Promise(I=>n(R)(I))}e.toPromise=S;function k(R){let I=new J;return R.then(j=>{I.fire(j)},()=>{I.fire(void 0)}).finally(()=>{I.dispose()}),I.event}e.fromPromise=k;function T(R,I){return R(j=>I.fire(j))}e.forward=T;function N(R,I,j){return I(j),R(B=>I(B))}e.runAndSubscribe=N;class O{constructor(I,j){this._observable=I,this._counter=0,this._hasChanged=!1;let B={onWillAddFirstListener:()=>{I.addObserver(this)},onDidRemoveLastListener:()=>{I.removeObserver(this)}};this.emitter=new J(B),j&&j.add(this.emitter)}beginUpdate(I){this._counter++}handlePossibleChange(I){}handleChange(I,j){this._hasChanged=!0}endUpdate(I){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function P(R,I){return new O(R,I).emitter.event}e.fromObservable=P;function L(R){return(I,j,B)=>{let $=0,F=!1,A={beginUpdate(){$++},endUpdate(){$--,$===0&&(R.reportChanges(),F&&(F=!1,I.call(j)))},handlePossibleChange(){},handleChange(){F=!0}};R.addObserver(A),R.reportChanges();let D={dispose(){R.removeObserver(A)}};return B instanceof ys?B.add(D):Array.isArray(B)&&B.push(D),D}}e.fromObservableLight=L})(dn||(dn={}));var i0=class s0{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${s0._idPool++}`,s0.all.add(this)}start(t){this._stopWatch=new HZ,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}}};i0.all=new Set,i0._idPool=0;var UZ=i0,WZ=-1,SM=class kM{constructor(t,n,r=(kM._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 KZ(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}};SM._idPool=1;var VZ=SM,qZ=class CM{constructor(t){this.value=t}static create(){let t=new Error;return new CM(t.stack??"")}print(){console.warn(this.value.split(`
|
|
537
|
+
`+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)}},jZ=new AZ;function Od(e){DZ(e)||jZ.onUnexpectedError(e)}var Jv="Canceled";function DZ(e){return e instanceof LZ?!0:e instanceof Error&&e.name===Jv&&e.message===Jv}var LZ=class extends Error{constructor(){super(Jv),this.name=this.message}};function OZ(e){return new Error(`Illegal argument: ${e}`)}var HS=class e0 extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof e0)return t;let n=new e0;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},t0=class _M extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,_M.prototype)}};function Kn(e,t=0){return e[e.length-(1+t)]}var BZ;(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})(BZ||(BZ={}));function zZ(e,t){let n=this,r=!1,i;return function(){return r||(r=!0,t||(i=e.apply(n,arguments))),i}}var xM;(e=>{function t(w){return w&&typeof w=="object"&&typeof w[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(w){yield w}e.single=i;function s(w){return t(w)?w:i(w)}e.wrap=s;function o(w){return w||n}e.from=o;function*a(w){for(let S=w.length-1;S>=0;S--)yield w[S]}e.reverse=a;function l(w){return!w||w[Symbol.iterator]().next().done===!0}e.isEmpty=l;function c(w){return w[Symbol.iterator]().next().value}e.first=c;function u(w,S){let k=0;for(let T of w)if(S(T,k++))return!0;return!1}e.some=u;function d(w,S){for(let k of w)if(S(k))return k}e.find=d;function*f(w,S){for(let k of w)S(k)&&(yield k)}e.filter=f;function*p(w,S){let k=0;for(let T of w)yield S(T,k++)}e.map=p;function*m(w,S){let k=0;for(let T of w)yield*S(T,k++)}e.flatMap=m;function*v(...w){for(let S of w)yield*S}e.concat=v;function y(w,S,k){let T=k;for(let N of w)T=S(T,N);return T}e.reduce=y;function*_(w,S,k=w.length){for(S<0&&(S+=w.length),k<0?k+=w.length:k>w.length&&(k=w.length);S<k;S++)yield w[S]}e.slice=_;function x(w,S=Number.POSITIVE_INFINITY){let k=[];if(S===0)return[k,w];let T=w[Symbol.iterator]();for(let N=0;N<S;N++){let O=T.next();if(O.done)return[k,e.empty()];k.push(O.value)}return[k,{[Symbol.iterator](){return T}}]}e.consume=x;async function b(w){let S=[];for await(let k of w)S.push(k);return Promise.resolve(S)}e.asyncToArray=b})(xM||(xM={}));function xo(e){if(xM.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 $Z(...e){return pt(()=>xo(e))}function pt(e){return{dispose:zZ(()=>{e()})}}var yM=class bM{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{xo(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?bM.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)}};yM.DISABLE_DISPOSED_WARNING=!1;var ys=yM,Le=class{constructor(){this._store=new ys,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)}};Le.None=Object.freeze({dispose(){}});var za=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}},wi=typeof window=="object"?window:globalThis,n0=class r0{constructor(t){this.element=t,this.next=r0.Undefined,this.prev=r0.Undefined}};n0.Undefined=new n0(void 0);var gt=n0,US=class{constructor(){this._first=gt.Undefined,this._last=gt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===gt.Undefined}clear(){let e=this._first;for(;e!==gt.Undefined;){let t=e.next;e.prev=gt.Undefined,e.next=gt.Undefined,e=t}this._first=gt.Undefined,this._last=gt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new gt(e);if(this._first===gt.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!==gt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==gt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==gt.Undefined&&e.next!==gt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===gt.Undefined&&e.next===gt.Undefined?(this._first=gt.Undefined,this._last=gt.Undefined):e.next===gt.Undefined?(this._last=this._last.prev,this._last.next=gt.Undefined):e.prev===gt.Undefined&&(this._first=this._first.next,this._first.prev=gt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==gt.Undefined;)yield e.element,e=e.next}},FZ=globalThis.performance&&typeof globalThis.performance.now=="function",HZ=class wM{static create(t){return new wM(t)}constructor(t){this._now=FZ&&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}},dn;(e=>{e.None=()=>Le.None;function t(R,I){return d(R,()=>{},0,void 0,!0,void 0,I)}e.defer=t;function n(R){return(I,j=null,B)=>{let $=!1,F;return F=R(A=>{if(!$)return F?F.dispose():$=!0,I.call(j,A)},null,B),$&&F.dispose(),F}}e.once=n;function r(R,I,j){return c((B,$=null,F)=>R(A=>B.call($,I(A)),null,F),j)}e.map=r;function i(R,I,j){return c((B,$=null,F)=>R(A=>{I(A),B.call($,A)},null,F),j)}e.forEach=i;function s(R,I,j){return c((B,$=null,F)=>R(A=>I(A)&&B.call($,A),null,F),j)}e.filter=s;function o(R){return R}e.signal=o;function a(...R){return(I,j=null,B)=>{let $=$Z(...R.map(F=>F(A=>I.call(j,A))));return u($,B)}}e.any=a;function l(R,I,j,B){let $=j;return r(R,F=>($=I($,F),$),B)}e.reduce=l;function c(R,I){let j,B={onWillAddFirstListener(){j=R($.fire,$)},onDidRemoveLastListener(){j==null||j.dispose()}},$=new ee(B);return I==null||I.add($),$.event}function u(R,I){return I instanceof Array?I.push(R):I&&I.add(R),R}function d(R,I,j=100,B=!1,$=!1,F,A){let D,C,H,q=0,M,ne={leakWarningThreshold:F,onWillAddFirstListener(){D=R(V=>{q++,C=I(C,V),B&&!H&&(oe.fire(C),C=void 0),M=()=>{let pe=C;C=void 0,H=void 0,(!B||q>1)&&oe.fire(pe),q=0},typeof j=="number"?(clearTimeout(H),H=setTimeout(M,j)):H===void 0&&(H=0,queueMicrotask(M))})},onWillRemoveListener(){$&&q>0&&(M==null||M())},onDidRemoveLastListener(){M=void 0,D.dispose()}},oe=new ee(ne);return A==null||A.add(oe),oe.event}e.debounce=d;function f(R,I=0,j){return e.debounce(R,(B,$)=>B?(B.push($),B):[$],I,void 0,!0,void 0,j)}e.accumulate=f;function p(R,I=(B,$)=>B===$,j){let B=!0,$;return s(R,F=>{let A=B||!I(F,$);return B=!1,$=F,A},j)}e.latch=p;function m(R,I,j){return[e.filter(R,I,j),e.filter(R,B=>!I(B),j)]}e.split=m;function v(R,I=!1,j=[],B){let $=j.slice(),F=R(C=>{$?$.push(C):D.fire(C)});B&&B.add(F);let A=()=>{$==null||$.forEach(C=>D.fire(C)),$=null},D=new ee({onWillAddFirstListener(){F||(F=R(C=>D.fire(C)),B&&B.add(F))},onDidAddFirstListener(){$&&(I?setTimeout(A):A())},onDidRemoveLastListener(){F&&F.dispose(),F=null}});return B&&B.add(D),D.event}e.buffer=v;function y(R,I){return(j,B,$)=>{let F=I(new x);return R(function(A){let D=F.evaluate(A);D!==_&&j.call(B,D)},void 0,$)}}e.chain=y;let _=Symbol("HaltChainable");class x{constructor(){this.steps=[]}map(I){return this.steps.push(I),this}forEach(I){return this.steps.push(j=>(I(j),j)),this}filter(I){return this.steps.push(j=>I(j)?j:_),this}reduce(I,j){let B=j;return this.steps.push($=>(B=I(B,$),B)),this}latch(I=(j,B)=>j===B){let j=!0,B;return this.steps.push($=>{let F=j||!I($,B);return j=!1,B=$,F?$:_}),this}evaluate(I){for(let j of this.steps)if(I=j(I),I===_)break;return I}}function b(R,I,j=B=>B){let B=(...D)=>A.fire(j(...D)),$=()=>R.on(I,B),F=()=>R.removeListener(I,B),A=new ee({onWillAddFirstListener:$,onDidRemoveLastListener:F});return A.event}e.fromNodeEventEmitter=b;function w(R,I,j=B=>B){let B=(...D)=>A.fire(j(...D)),$=()=>R.addEventListener(I,B),F=()=>R.removeEventListener(I,B),A=new ee({onWillAddFirstListener:$,onDidRemoveLastListener:F});return A.event}e.fromDOMEventEmitter=w;function S(R){return new Promise(I=>n(R)(I))}e.toPromise=S;function k(R){let I=new ee;return R.then(j=>{I.fire(j)},()=>{I.fire(void 0)}).finally(()=>{I.dispose()}),I.event}e.fromPromise=k;function T(R,I){return R(j=>I.fire(j))}e.forward=T;function N(R,I,j){return I(j),R(B=>I(B))}e.runAndSubscribe=N;class O{constructor(I,j){this._observable=I,this._counter=0,this._hasChanged=!1;let B={onWillAddFirstListener:()=>{I.addObserver(this)},onDidRemoveLastListener:()=>{I.removeObserver(this)}};this.emitter=new ee(B),j&&j.add(this.emitter)}beginUpdate(I){this._counter++}handlePossibleChange(I){}handleChange(I,j){this._hasChanged=!0}endUpdate(I){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function P(R,I){return new O(R,I).emitter.event}e.fromObservable=P;function L(R){return(I,j,B)=>{let $=0,F=!1,A={beginUpdate(){$++},endUpdate(){$--,$===0&&(R.reportChanges(),F&&(F=!1,I.call(j)))},handlePossibleChange(){},handleChange(){F=!0}};R.addObserver(A),R.reportChanges();let D={dispose(){R.removeObserver(A)}};return B instanceof ys?B.add(D):Array.isArray(B)&&B.push(D),D}}e.fromObservableLight=L})(dn||(dn={}));var i0=class s0{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${s0._idPool++}`,s0.all.add(this)}start(t){this._stopWatch=new HZ,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}}};i0.all=new Set,i0._idPool=0;var UZ=i0,WZ=-1,SM=class kM{constructor(t,n,r=(kM._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 KZ(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}};SM._idPool=1;var VZ=SM,qZ=class CM{constructor(t){this.value=t}static create(){let t=new Error;return new CM(t.stack??"")}print(){console.warn(this.value.split(`
|
|
538
538
|
`).slice(2).join(`
|
|
539
|
-
`))}},KZ=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},GZ=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},XZ=0,wm=class{constructor(e){this.value=e,this.id=XZ++}},YZ=2,ZZ,J=class{constructor(e){var t,n,r,i;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new VZ((e==null?void 0:e.onListenerError)??Od,((n=this._options)==null?void 0:n.leakWarningThreshold)??WZ):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new UZ(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 GZ(`${d}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(((o=this._options)==null?void 0:o.onListenerError)||Od)(p),Le.None}if(this._disposed)return Le.None;t&&(e=e.bind(t));let r=new wm(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=qZ.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof wm?(this._deliveryQueue??(this._deliveryQueue=new QZ),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=pt(()=>{i==null||i(),this._removeListener(r)});return n instanceof ys?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*YZ<=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)||Od;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 wm)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}},QZ=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}},o0=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new J,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new J,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}};o0.INSTANCE=new o0;var ry=o0;function JZ(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}ry.INSTANCE.onDidChangeZoomLevel;function eQ(e){return ry.INSTANCE.getZoomFactor(e)}ry.INSTANCE.onDidChangeFullscreen;var tl=typeof navigator=="object"?navigator.userAgent:"",a0=tl.indexOf("Firefox")>=0,tQ=tl.indexOf("AppleWebKit")>=0,iy=tl.indexOf("Chrome")>=0,nQ=!iy&&tl.indexOf("Safari")>=0;tl.indexOf("Electron/")>=0;tl.indexOf("Android")>=0;var Sm=!1;if(typeof wi.matchMedia=="function"){let e=wi.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=wi.matchMedia("(display-mode: fullscreen)");Sm=e.matches,JZ(wi,e,({matches:n})=>{Sm&&t.matches||(Sm=n)})}var ua="en",l0=!1,c0=!1,Bd=!1,EM=!1,ad,zd=ua,WS=ua,rQ,Cr,no=globalThis,un,zk;typeof no.vscode<"u"&&typeof no.vscode.process<"u"?un=no.vscode.process:typeof process<"u"&&typeof((zk=process==null?void 0:process.versions)==null?void 0:zk.node)=="string"&&(un=process);var $k,iQ=typeof(($k=un==null?void 0:un.versions)==null?void 0:$k.electron)=="string",sQ=iQ&&(un==null?void 0:un.type)==="renderer",Fk;if(typeof un=="object"){l0=un.platform==="win32",c0=un.platform==="darwin",Bd=un.platform==="linux",Bd&&un.env.SNAP&&un.env.SNAP_REVISION,un.env.CI||un.env.BUILD_ARTIFACTSTAGINGDIRECTORY,ad=ua,zd=ua;let e=un.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);ad=t.userLocale,WS=t.osLocale,zd=t.resolvedLanguage||ua,rQ=(Fk=t.languagePack)==null?void 0:Fk.translationsConfigFile}catch{}EM=!0}else typeof navigator=="object"&&!sQ?(Cr=navigator.userAgent,l0=Cr.indexOf("Windows")>=0,c0=Cr.indexOf("Macintosh")>=0,(Cr.indexOf("Macintosh")>=0||Cr.indexOf("iPad")>=0||Cr.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Bd=Cr.indexOf("Linux")>=0,(Cr==null?void 0:Cr.indexOf("Mobi"))>=0,zd=globalThis._VSCODE_NLS_LANGUAGE||ua,ad=navigator.language.toLowerCase(),WS=ad):console.error("Unable to resolve platform.");var NM=l0,ri=c0,oQ=Bd,VS=EM,oi=Cr,Xi=zd,aQ;(e=>{function t(){return Xi}e.value=t;function n(){return Xi.length===2?Xi==="en":Xi.length>=3?Xi[0]==="e"&&Xi[1]==="n"&&Xi[2]==="-":!1}e.isDefaultVariant=n;function r(){return Xi==="en"}e.isDefault=r})(aQ||(aQ={}));var lQ=typeof no.postMessage=="function"&&!no.importScripts;(()=>{if(lQ){let e=[];no.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}),no.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var cQ=!!(oi&&oi.indexOf("Chrome")>=0);oi&&oi.indexOf("Firefox")>=0;!cQ&&oi&&oi.indexOf("Safari")>=0;oi&&oi.indexOf("Edg/")>=0;oi&&oi.indexOf("Android")>=0;var Vo=typeof navigator=="object"?navigator:{};VS||document.queryCommandSupported&&document.queryCommandSupported("copy")||Vo&&Vo.clipboard&&Vo.clipboard.writeText,VS||Vo&&Vo.clipboard&&Vo.clipboard.readText;var sy=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}},km=new sy,qS=new sy,KS=new sy,uQ=new Array(230),TM;(e=>{function t(a){return km.keyCodeToStr(a)}e.toString=t;function n(a){return km.strToKeyCode(a)}e.fromString=n;function r(a){return qS.keyCodeToStr(a)}e.toUserSettingsUS=r;function i(a){return KS.keyCodeToStr(a)}e.toUserSettingsGeneral=i;function s(a){return qS.strToKeyCode(a)||KS.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 km.keyCodeToStr(a)}e.toElectronAccelerator=o})(TM||(TM={}));var dQ=class PM{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 PM&&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 hQ([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},hQ=class{constructor(e){if(e.length===0)throw OZ("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 fQ(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return TM.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(a0)switch(t){case 59:return 85;case 60:if(oQ)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(ri)return 57;break}else if(tQ&&(ri&&t===93||!ri&&t===92))return 57;return uQ[t]||0}var pQ=ri?256:2048,mQ=512,gQ=1024,vQ=ri?2048:256,GS=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=fQ(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|=pQ),this.altKey&&(t|=mQ),this.shiftKey&&(t|=gQ),this.metaKey&&(t|=vQ),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new dQ(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},XS=new WeakMap;function _Q(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 xQ=class{static getSameOriginWindowChain(e){let t=XS.get(e);if(!t){t=[],XS.set(e,t);let n=e,r;do r=_Q(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}}},ld=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=xQ.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},YS=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(iy){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?a0&&!ri?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof s.wheelDeltaX<"u")nQ&&NM?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?a0&&!ri?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()}},RM=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),yQ;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof bQ?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:dn.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:RM})})(yQ||(yQ={}));var bQ=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?RM:(this._emitter||(this._emitter=new J),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},oy=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 t0("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new t0("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},wQ=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 t0("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=pt(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},SQ;(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})(SQ||(SQ={}));var ZS=class ur{static fromArray(t){return new ur(n=>{n.emitMany(t)})}static fromPromise(t){return new ur(async n=>{n.emitMany(await t)})}static fromPromises(t){return new ur(async n=>{await Promise.all(t.map(async r=>n.emitOne(await r)))})}static merge(t){return new ur(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 J,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 dn.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 ur(async r=>{for await(let i of t)r.emitOne(n(i))})}map(t){return ur.map(this,t)}static filter(t,n){return new ur(async r=>{for await(let i of t)n(i)&&r.emitOne(i)})}filter(t){return ur.filter(this,t)}static coalesce(t){return ur.filter(t,n=>!!n)}coalesce(){return ur.coalesce(this)}static async toPromise(t){let n=[];for await(let r of t)n.push(r);return n}toPromise(){return ur.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())}};ZS.EMPTY=ZS.fromArray([]);var{getWindow:Zr,getWindowId:kQ,onDidRegisterWindow:CQ}=function(){let e=new Map,t={window:wi,disposables:new ys};e.set(wi.vscodeWindowId,t);let n=new J,r=new J,i=new J;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 Le.None;let a=new ys,l={window:o,disposables:a.add(new ys)};return e.set(o.vscodeWindowId,l),a.add(pt(()=>{e.delete(o.vscodeWindowId),r.fire(o)})),a.add(Se(o,en.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:wi},getDocument(o){return Zr(o).document}}}(),EQ=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 Se(e,t,n,r){return new EQ(e,t,n,r)}var QS=function(e,t,n,r){return Se(e,t,n,r)},ay,NQ=class extends wQ{constructor(e){super(),this.defaultTarget=e&&Zr(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},JS=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){Od(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(JS.sort),o.shift().execute();r.set(s,!1)};ay=(s,o,a=0)=>{let l=kQ(s),c=new JS(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 TQ(e){let t=e.getBoundingClientRect(),n=Zr(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var en={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"},PQ=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=Bn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Bn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Bn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Bn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Bn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Bn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Bn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Bn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Bn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Bn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Bn(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=Bn(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=Bn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Bn(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 Bn(e){return typeof e=="number"?`${e}px`:e}function sc(e){return new PQ(e)}var IM=class{constructor(){this._hooks=new ys,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(pt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{s=Zr(e)}this._hooks.add(Se(s,en.POINTER_MOVE,o=>{if(o.buttons!==n){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(Se(s,en.POINTER_UP,o=>this.stopMonitoring(!0)))}};function RQ(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 Hr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Hr||(Hr={}));var Ol=class vn extends Le{constructor(){super(),this.dispatched=!1,this.targets=new US,this.ignoreTargets=new US,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(dn.runAndSubscribe(CQ,({window:t,disposables:n})=>{n.add(Se(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),n.add(Se(t.document,"touchend",r=>this.onTouchEnd(t,r))),n.add(Se(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:wi,disposables:this._store}))}static addTarget(t){if(!vn.isTouchDevice())return Le.None;vn.INSTANCE||(vn.INSTANCE=new vn);let n=vn.INSTANCE.targets.push(t);return pt(n)}static ignoreTarget(t){if(!vn.isTouchDevice())return Le.None;vn.INSTANCE||(vn.INSTANCE=new vn);let n=vn.INSTANCE.ignoreTargets.push(t);return pt(n)}static isTouchDevice(){return"ontouchstart"in wi||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(Hr.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<vn.HOLD_DELAY&&Math.abs(l.initialPageX-Kn(l.rollingPageX))<30&&Math.abs(l.initialPageY-Kn(l.rollingPageY))<30){let u=this.newGestureEvent(Hr.Tap,l.initialTarget);u.pageX=Kn(l.rollingPageX),u.pageY=Kn(l.rollingPageY),this.dispatchEvent(u)}else if(c>=vn.HOLD_DELAY&&Math.abs(l.initialPageX-Kn(l.rollingPageX))<30&&Math.abs(l.initialPageY-Kn(l.rollingPageY))<30){let u=this.newGestureEvent(Hr.Contextmenu,l.initialTarget);u.pageX=Kn(l.rollingPageX),u.pageY=Kn(l.rollingPageY),this.dispatchEvent(u)}else if(i===1){let u=Kn(l.rollingPageX),d=Kn(l.rollingPageY),f=Kn(l.rollingTimestamps)-l.rollingTimestamps[0],p=u-l.rollingPageX[0],m=d-l.rollingPageY[0],v=[...this.targets].filter(y=>l.initialTarget instanceof Node&&y.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(Hr.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===Hr.Tap){let n=new Date().getTime(),r=0;n-this._lastSetTapCountTime>vn.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===Hr.Change||t.type===Hr.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=ay(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=vn.SCROLL_FRICTION*d,a+=vn.SCROLL_FRICTION*d,i>0&&(m=!1,f=s*i*d),a>0&&(m=!1,p=l*a*d);let v=this.newGestureEvent(Hr.Change);v.translationX=f,v.translationY=p,n.forEach(y=>y.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(Hr.Change,o.initialTarget);a.translationX=s.pageX-Kn(o.rollingPageX),a.translationY=s.pageY-Kn(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)}};Ol.SCROLL_FRICTION=-.005,Ol.HOLD_DELAY=700,Ol.CLEAR_TAP_COUNT_TIME=400,Nt([RQ],Ol,"isTouchDevice",1);var IQ=Ol,ly=class extends Le{onclick(e,t){this._register(Se(e,en.CLICK,n=>t(new ld(Zr(e),n))))}onmousedown(e,t){this._register(Se(e,en.MOUSE_DOWN,n=>t(new ld(Zr(e),n))))}onmouseover(e,t){this._register(Se(e,en.MOUSE_OVER,n=>t(new ld(Zr(e),n))))}onmouseleave(e,t){this._register(Se(e,en.MOUSE_LEAVE,n=>t(new ld(Zr(e),n))))}onkeydown(e,t){this._register(Se(e,en.KEY_DOWN,n=>t(new GS(n))))}onkeyup(e,t){this._register(Se(e,en.KEY_UP,n=>t(new GS(n))))}oninput(e,t){this._register(Se(e,en.INPUT,t))}onblur(e,t){this._register(Se(e,en.BLUR,t))}onfocus(e,t){this._register(Se(e,en.FOCUS,t))}onchange(e,t){this._register(Se(e,en.CHANGE,t))}ignoreGesture(e){return IQ.ignoreTarget(e)}},ek=11,MQ=class extends ly{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=ek+"px",this.domNode.style.height=ek+"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 IM),this._register(QS(this.bgDomNode,en.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(QS(this.domNode,en.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new NQ),this._pointerdownScheduleRepeatTimer=this._register(new oy)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Zr(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()}},AQ=class u0{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 u0(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 u0(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}}},jQ=class extends Le{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new J),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new AQ(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 nk(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=nk.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)))}},tk=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Cm(e,t){let n=t-e;return function(r){return e+n*OQ(r)}}function DQ(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var nk=class d0{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),DQ(Cm(t,i),Cm(s,n),.33)}return Cm(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 tk(r,i,!1)}return new tk(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return d0.start(t,n,r)}static start(t,n,r){r=r+10;let i=Date.now()-10;return new d0(t,n,i,r)}};function LQ(e){return Math.pow(e,3)}function OQ(e){return 1-LQ(1-e)}var BQ=class extends Le{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 oy)}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":"")))}},zQ=140,MM=class extends ly{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 BQ(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new IM),this._shouldRender=!0,this.domNode=sc(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(Se(this.domNode.domNode,en.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new MQ(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=sc(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(Se(this.slider.domNode,en.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=TQ(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(NM&&o>zQ){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()}},AM=class h0{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 h0(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=h0._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)}},$Q=class extends MM{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new AM(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}},FQ=class extends MM{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new AM(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}},HQ=500,rk=50,UQ=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},f0=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(iy){let n=Zr(t.browserEvent),r=eQ(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 UQ(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}};f0.INSTANCE=new f0;var WQ=f0,VQ=class extends ly{constructor(e,t,n){super(),this._onScroll=this._register(new J),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new J),this.onWillScroll=this._onWillScroll.event,this._options=KQ(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 FQ(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new $Q(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=sc(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=sc(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=sc(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 oy),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=xo(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,ri&&(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 YS(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=xo(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new YS(n))};this._mouseWheelToDispose.push(Se(this._listenOnDomNode,en.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var i;if((i=e.browserEvent)!=null&&i.defaultPrevented)return;let t=WQ.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=!ri&&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=rk*s,d=l.scrollTop-(u<0?Math.floor(u):Math.ceil(u));this._verticalScrollbar.writeScrollPosition(c,d)}if(o){let u=rk*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(),HQ)}},qQ=class extends VQ{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 KQ(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,ri&&(t.className+=" mac"),t}var p0=class extends Le{constructor(e,t,n,r,i,s,o,a){super(),this._bufferService=n,this._optionsService=o,this._renderService=a,this._onRequestScrollLines=this._register(new J),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let l=this._register(new jQ({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>ay(r.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{l.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new qQ(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(dn.runAndSubscribe(s.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=s.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(pt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(pt(()=>this._styleElement.remove())),this._register(dn.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(`
|
|
539
|
+
`))}},KZ=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},GZ=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},XZ=0,wm=class{constructor(e){this.value=e,this.id=XZ++}},YZ=2,ZZ,ee=class{constructor(e){var t,n,r,i;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new VZ((e==null?void 0:e.onListenerError)??Od,((n=this._options)==null?void 0:n.leakWarningThreshold)??WZ):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new UZ(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 GZ(`${d}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(((o=this._options)==null?void 0:o.onListenerError)||Od)(p),Le.None}if(this._disposed)return Le.None;t&&(e=e.bind(t));let r=new wm(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=qZ.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof wm?(this._deliveryQueue??(this._deliveryQueue=new QZ),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=pt(()=>{i==null||i(),this._removeListener(r)});return n instanceof ys?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*YZ<=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)||Od;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 wm)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}},QZ=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}},o0=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new ee,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new ee,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}};o0.INSTANCE=new o0;var ry=o0;function JZ(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}ry.INSTANCE.onDidChangeZoomLevel;function eQ(e){return ry.INSTANCE.getZoomFactor(e)}ry.INSTANCE.onDidChangeFullscreen;var tl=typeof navigator=="object"?navigator.userAgent:"",a0=tl.indexOf("Firefox")>=0,tQ=tl.indexOf("AppleWebKit")>=0,iy=tl.indexOf("Chrome")>=0,nQ=!iy&&tl.indexOf("Safari")>=0;tl.indexOf("Electron/")>=0;tl.indexOf("Android")>=0;var Sm=!1;if(typeof wi.matchMedia=="function"){let e=wi.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=wi.matchMedia("(display-mode: fullscreen)");Sm=e.matches,JZ(wi,e,({matches:n})=>{Sm&&t.matches||(Sm=n)})}var ua="en",l0=!1,c0=!1,Bd=!1,EM=!1,ad,zd=ua,WS=ua,rQ,Cr,no=globalThis,un,zk;typeof no.vscode<"u"&&typeof no.vscode.process<"u"?un=no.vscode.process:typeof process<"u"&&typeof((zk=process==null?void 0:process.versions)==null?void 0:zk.node)=="string"&&(un=process);var $k,iQ=typeof(($k=un==null?void 0:un.versions)==null?void 0:$k.electron)=="string",sQ=iQ&&(un==null?void 0:un.type)==="renderer",Fk;if(typeof un=="object"){l0=un.platform==="win32",c0=un.platform==="darwin",Bd=un.platform==="linux",Bd&&un.env.SNAP&&un.env.SNAP_REVISION,un.env.CI||un.env.BUILD_ARTIFACTSTAGINGDIRECTORY,ad=ua,zd=ua;let e=un.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);ad=t.userLocale,WS=t.osLocale,zd=t.resolvedLanguage||ua,rQ=(Fk=t.languagePack)==null?void 0:Fk.translationsConfigFile}catch{}EM=!0}else typeof navigator=="object"&&!sQ?(Cr=navigator.userAgent,l0=Cr.indexOf("Windows")>=0,c0=Cr.indexOf("Macintosh")>=0,(Cr.indexOf("Macintosh")>=0||Cr.indexOf("iPad")>=0||Cr.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Bd=Cr.indexOf("Linux")>=0,(Cr==null?void 0:Cr.indexOf("Mobi"))>=0,zd=globalThis._VSCODE_NLS_LANGUAGE||ua,ad=navigator.language.toLowerCase(),WS=ad):console.error("Unable to resolve platform.");var NM=l0,ri=c0,oQ=Bd,VS=EM,oi=Cr,Xi=zd,aQ;(e=>{function t(){return Xi}e.value=t;function n(){return Xi.length===2?Xi==="en":Xi.length>=3?Xi[0]==="e"&&Xi[1]==="n"&&Xi[2]==="-":!1}e.isDefaultVariant=n;function r(){return Xi==="en"}e.isDefault=r})(aQ||(aQ={}));var lQ=typeof no.postMessage=="function"&&!no.importScripts;(()=>{if(lQ){let e=[];no.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}),no.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var cQ=!!(oi&&oi.indexOf("Chrome")>=0);oi&&oi.indexOf("Firefox")>=0;!cQ&&oi&&oi.indexOf("Safari")>=0;oi&&oi.indexOf("Edg/")>=0;oi&&oi.indexOf("Android")>=0;var Vo=typeof navigator=="object"?navigator:{};VS||document.queryCommandSupported&&document.queryCommandSupported("copy")||Vo&&Vo.clipboard&&Vo.clipboard.writeText,VS||Vo&&Vo.clipboard&&Vo.clipboard.readText;var sy=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}},km=new sy,qS=new sy,KS=new sy,uQ=new Array(230),TM;(e=>{function t(a){return km.keyCodeToStr(a)}e.toString=t;function n(a){return km.strToKeyCode(a)}e.fromString=n;function r(a){return qS.keyCodeToStr(a)}e.toUserSettingsUS=r;function i(a){return KS.keyCodeToStr(a)}e.toUserSettingsGeneral=i;function s(a){return qS.strToKeyCode(a)||KS.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 km.keyCodeToStr(a)}e.toElectronAccelerator=o})(TM||(TM={}));var dQ=class PM{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 PM&&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 hQ([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},hQ=class{constructor(e){if(e.length===0)throw OZ("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 fQ(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return TM.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(a0)switch(t){case 59:return 85;case 60:if(oQ)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(ri)return 57;break}else if(tQ&&(ri&&t===93||!ri&&t===92))return 57;return uQ[t]||0}var pQ=ri?256:2048,mQ=512,gQ=1024,vQ=ri?2048:256,GS=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=fQ(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|=pQ),this.altKey&&(t|=mQ),this.shiftKey&&(t|=gQ),this.metaKey&&(t|=vQ),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new dQ(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},XS=new WeakMap;function _Q(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 xQ=class{static getSameOriginWindowChain(e){let t=XS.get(e);if(!t){t=[],XS.set(e,t);let n=e,r;do r=_Q(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}}},ld=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=xQ.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},YS=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(iy){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?a0&&!ri?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof s.wheelDeltaX<"u")nQ&&NM?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?a0&&!ri?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()}},RM=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),yQ;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof bQ?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:dn.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:RM})})(yQ||(yQ={}));var bQ=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?RM:(this._emitter||(this._emitter=new ee),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},oy=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 t0("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new t0("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},wQ=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 t0("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=pt(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},SQ;(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})(SQ||(SQ={}));var ZS=class ur{static fromArray(t){return new ur(n=>{n.emitMany(t)})}static fromPromise(t){return new ur(async n=>{n.emitMany(await t)})}static fromPromises(t){return new ur(async n=>{await Promise.all(t.map(async r=>n.emitOne(await r)))})}static merge(t){return new ur(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 ee,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 dn.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 ur(async r=>{for await(let i of t)r.emitOne(n(i))})}map(t){return ur.map(this,t)}static filter(t,n){return new ur(async r=>{for await(let i of t)n(i)&&r.emitOne(i)})}filter(t){return ur.filter(this,t)}static coalesce(t){return ur.filter(t,n=>!!n)}coalesce(){return ur.coalesce(this)}static async toPromise(t){let n=[];for await(let r of t)n.push(r);return n}toPromise(){return ur.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())}};ZS.EMPTY=ZS.fromArray([]);var{getWindow:Zr,getWindowId:kQ,onDidRegisterWindow:CQ}=function(){let e=new Map,t={window:wi,disposables:new ys};e.set(wi.vscodeWindowId,t);let n=new ee,r=new ee,i=new ee;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 Le.None;let a=new ys,l={window:o,disposables:a.add(new ys)};return e.set(o.vscodeWindowId,l),a.add(pt(()=>{e.delete(o.vscodeWindowId),r.fire(o)})),a.add(Se(o,en.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:wi},getDocument(o){return Zr(o).document}}}(),EQ=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 Se(e,t,n,r){return new EQ(e,t,n,r)}var QS=function(e,t,n,r){return Se(e,t,n,r)},ay,NQ=class extends wQ{constructor(e){super(),this.defaultTarget=e&&Zr(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},JS=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){Od(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(JS.sort),o.shift().execute();r.set(s,!1)};ay=(s,o,a=0)=>{let l=kQ(s),c=new JS(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 TQ(e){let t=e.getBoundingClientRect(),n=Zr(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var en={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"},PQ=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=Bn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Bn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Bn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Bn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Bn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Bn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Bn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Bn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Bn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Bn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Bn(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=Bn(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=Bn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Bn(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 Bn(e){return typeof e=="number"?`${e}px`:e}function sc(e){return new PQ(e)}var IM=class{constructor(){this._hooks=new ys,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(pt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{s=Zr(e)}this._hooks.add(Se(s,en.POINTER_MOVE,o=>{if(o.buttons!==n){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(Se(s,en.POINTER_UP,o=>this.stopMonitoring(!0)))}};function RQ(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 Hr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Hr||(Hr={}));var Ol=class vn extends Le{constructor(){super(),this.dispatched=!1,this.targets=new US,this.ignoreTargets=new US,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(dn.runAndSubscribe(CQ,({window:t,disposables:n})=>{n.add(Se(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),n.add(Se(t.document,"touchend",r=>this.onTouchEnd(t,r))),n.add(Se(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:wi,disposables:this._store}))}static addTarget(t){if(!vn.isTouchDevice())return Le.None;vn.INSTANCE||(vn.INSTANCE=new vn);let n=vn.INSTANCE.targets.push(t);return pt(n)}static ignoreTarget(t){if(!vn.isTouchDevice())return Le.None;vn.INSTANCE||(vn.INSTANCE=new vn);let n=vn.INSTANCE.ignoreTargets.push(t);return pt(n)}static isTouchDevice(){return"ontouchstart"in wi||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(Hr.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<vn.HOLD_DELAY&&Math.abs(l.initialPageX-Kn(l.rollingPageX))<30&&Math.abs(l.initialPageY-Kn(l.rollingPageY))<30){let u=this.newGestureEvent(Hr.Tap,l.initialTarget);u.pageX=Kn(l.rollingPageX),u.pageY=Kn(l.rollingPageY),this.dispatchEvent(u)}else if(c>=vn.HOLD_DELAY&&Math.abs(l.initialPageX-Kn(l.rollingPageX))<30&&Math.abs(l.initialPageY-Kn(l.rollingPageY))<30){let u=this.newGestureEvent(Hr.Contextmenu,l.initialTarget);u.pageX=Kn(l.rollingPageX),u.pageY=Kn(l.rollingPageY),this.dispatchEvent(u)}else if(i===1){let u=Kn(l.rollingPageX),d=Kn(l.rollingPageY),f=Kn(l.rollingTimestamps)-l.rollingTimestamps[0],p=u-l.rollingPageX[0],m=d-l.rollingPageY[0],v=[...this.targets].filter(y=>l.initialTarget instanceof Node&&y.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(Hr.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===Hr.Tap){let n=new Date().getTime(),r=0;n-this._lastSetTapCountTime>vn.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===Hr.Change||t.type===Hr.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=ay(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=vn.SCROLL_FRICTION*d,a+=vn.SCROLL_FRICTION*d,i>0&&(m=!1,f=s*i*d),a>0&&(m=!1,p=l*a*d);let v=this.newGestureEvent(Hr.Change);v.translationX=f,v.translationY=p,n.forEach(y=>y.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(Hr.Change,o.initialTarget);a.translationX=s.pageX-Kn(o.rollingPageX),a.translationY=s.pageY-Kn(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)}};Ol.SCROLL_FRICTION=-.005,Ol.HOLD_DELAY=700,Ol.CLEAR_TAP_COUNT_TIME=400,Nt([RQ],Ol,"isTouchDevice",1);var IQ=Ol,ly=class extends Le{onclick(e,t){this._register(Se(e,en.CLICK,n=>t(new ld(Zr(e),n))))}onmousedown(e,t){this._register(Se(e,en.MOUSE_DOWN,n=>t(new ld(Zr(e),n))))}onmouseover(e,t){this._register(Se(e,en.MOUSE_OVER,n=>t(new ld(Zr(e),n))))}onmouseleave(e,t){this._register(Se(e,en.MOUSE_LEAVE,n=>t(new ld(Zr(e),n))))}onkeydown(e,t){this._register(Se(e,en.KEY_DOWN,n=>t(new GS(n))))}onkeyup(e,t){this._register(Se(e,en.KEY_UP,n=>t(new GS(n))))}oninput(e,t){this._register(Se(e,en.INPUT,t))}onblur(e,t){this._register(Se(e,en.BLUR,t))}onfocus(e,t){this._register(Se(e,en.FOCUS,t))}onchange(e,t){this._register(Se(e,en.CHANGE,t))}ignoreGesture(e){return IQ.ignoreTarget(e)}},ek=11,MQ=class extends ly{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=ek+"px",this.domNode.style.height=ek+"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 IM),this._register(QS(this.bgDomNode,en.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(QS(this.domNode,en.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new NQ),this._pointerdownScheduleRepeatTimer=this._register(new oy)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Zr(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()}},AQ=class u0{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 u0(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 u0(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}}},jQ=class extends Le{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new ee),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new AQ(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 nk(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=nk.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)))}},tk=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Cm(e,t){let n=t-e;return function(r){return e+n*OQ(r)}}function DQ(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var nk=class d0{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),DQ(Cm(t,i),Cm(s,n),.33)}return Cm(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 tk(r,i,!1)}return new tk(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return d0.start(t,n,r)}static start(t,n,r){r=r+10;let i=Date.now()-10;return new d0(t,n,i,r)}};function LQ(e){return Math.pow(e,3)}function OQ(e){return 1-LQ(1-e)}var BQ=class extends Le{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 oy)}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":"")))}},zQ=140,MM=class extends ly{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 BQ(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new IM),this._shouldRender=!0,this.domNode=sc(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(Se(this.domNode.domNode,en.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new MQ(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=sc(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(Se(this.slider.domNode,en.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=TQ(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(NM&&o>zQ){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()}},AM=class h0{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 h0(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=h0._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)}},$Q=class extends MM{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new AM(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}},FQ=class extends MM{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new AM(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}},HQ=500,rk=50,UQ=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},f0=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(iy){let n=Zr(t.browserEvent),r=eQ(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 UQ(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}};f0.INSTANCE=new f0;var WQ=f0,VQ=class extends ly{constructor(e,t,n){super(),this._onScroll=this._register(new ee),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new ee),this.onWillScroll=this._onWillScroll.event,this._options=KQ(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 FQ(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new $Q(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=sc(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=sc(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=sc(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 oy),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=xo(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,ri&&(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 YS(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=xo(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new YS(n))};this._mouseWheelToDispose.push(Se(this._listenOnDomNode,en.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var i;if((i=e.browserEvent)!=null&&i.defaultPrevented)return;let t=WQ.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=!ri&&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=rk*s,d=l.scrollTop-(u<0?Math.floor(u):Math.ceil(u));this._verticalScrollbar.writeScrollPosition(c,d)}if(o){let u=rk*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(),HQ)}},qQ=class extends VQ{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 KQ(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,ri&&(t.className+=" mac"),t}var p0=class extends Le{constructor(e,t,n,r,i,s,o,a){super(),this._bufferService=n,this._optionsService=o,this._renderService=a,this._onRequestScrollLines=this._register(new ee),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let l=this._register(new jQ({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>ay(r.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{l.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new qQ(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(dn.runAndSubscribe(s.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=s.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(pt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(pt(()=>this._styleElement.remove())),this._register(dn.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(`
|
|
540
540
|
`)})),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}};p0=Nt([ae(2,An),ae(3,Fi),ae(4,fM),ae(5,el),ae(6,jn),ae(7,Hi)],p0);var m0=class extends Le{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(pt(()=>{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()}};m0=Nt([ae(1,An),ae(2,Fi),ae(3,fu),ae(4,Hi)],m0);var GQ=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)}},$r={full:0,left:0,center:0,right:0},Yi={full:0,left:0,center:0,right:0},wl={full:0,left:0,center:0,right:0},Wh=class extends Le{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 GQ,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(pt(()=>{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);Yi.full=this._canvas.width,Yi.left=e,Yi.center=t,Yi.right=e,this._refreshDrawHeightConstants(),wl.full=1,wl.left=1,wl.center=1+Yi.left,wl.right=1+Yi.left+Yi.center}_refreshDrawHeightConstants(){$r.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);$r.left=t,$r.center=t,$r.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*$r.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*$r.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*$r.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*$r.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(wl[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-$r[e.position||"full"]/2),Yi[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+$r[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}))}};Wh=Nt([ae(2,An),ae(3,fu),ae(4,Hi),ae(5,jn),ae(6,el),ae(7,Fi)],Wh);var W;(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=`
|
|
541
|
-
`,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=""))(W||(W={}));var $d;(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=""))($d||($d={}));var jM;(e=>e.ST=`${W.ESC}\\`)(jM||(jM={}));var g0=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(`${W.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)}}};g0=Nt([ae(2,An),ae(3,jn),ae(4,Mo),ae(5,Hi)],g0);var nn=0,rn=0,sn=0,St=0,ik={css:"#00000000",rgba:0},Lt;(e=>{function t(i,s,o,a){return a!==void 0?`#${zs(i)}${zs(s)}${zs(o)}${zs(a)}`:`#${zs(i)}${zs(s)}${zs(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})(Lt||(Lt={}));var dt;(e=>{function t(l,c){if(St=(c.rgba&255)/255,St===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;nn=p+Math.round((u-p)*St),rn=m+Math.round((d-m)*St),sn=v+Math.round((f-v)*St);let y=Lt.toCss(nn,rn,sn),_=Lt.toRgba(nn,rn,sn);return{css:y,rgba:_}}e.blend=t;function n(l){return(l.rgba&255)===255}e.isOpaque=n;function r(l,c,u){let d=Fd.ensureContrastRatio(l.rgba,c.rgba,u);if(d)return Lt.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=r;function i(l){let c=(l.rgba|255)>>>0;return[nn,rn,sn]=Fd.toChannels(c),{css:Lt.toCss(nn,rn,sn),rgba:c}}e.opaque=i;function s(l,c){return St=Math.round(c*255),[nn,rn,sn]=Fd.toChannels(l.rgba),{css:Lt.toCss(nn,rn,sn,St),rgba:Lt.toRgba(nn,rn,sn,St)}}e.opacity=s;function o(l,c){return St=l.rgba&255,s(l,St*c/255)}e.multiplyOpacity=o;function a(l){return[l.rgba>>24&255,l.rgba>>16&255,l.rgba>>8&255]}e.toColorRGB=a})(dt||(dt={}));var vt;(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 nn=parseInt(i.slice(1,2).repeat(2),16),rn=parseInt(i.slice(2,3).repeat(2),16),sn=parseInt(i.slice(3,4).repeat(2),16),Lt.toColor(nn,rn,sn);case 5:return nn=parseInt(i.slice(1,2).repeat(2),16),rn=parseInt(i.slice(2,3).repeat(2),16),sn=parseInt(i.slice(3,4).repeat(2),16),St=parseInt(i.slice(4,5).repeat(2),16),Lt.toColor(nn,rn,sn,St);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 nn=parseInt(s[1]),rn=parseInt(s[2]),sn=parseInt(s[3]),St=Math.round((s[5]===void 0?1:parseFloat(s[5]))*255),Lt.toColor(nn,rn,sn,St);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),[nn,rn,sn,St]=t.getImageData(0,0,1,1).data,St!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Lt.toRgba(nn,rn,sn,St),css:i}}e.toColor=r})(vt||(vt={}));var Sn;(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})(Sn||(Sn={}));var Fd;(e=>{function t(o,a){if(St=(a&255)/255,St===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 nn=d+Math.round((l-d)*St),rn=f+Math.round((c-f)*St),sn=p+Math.round((u-p)*St),Lt.toRgba(nn,rn,sn)}e.blend=t;function n(o,a,l){let c=Sn.relativeLuminance(o>>8),u=Sn.relativeLuminance(a>>8);if(mi(c,u)<l){if(u<c){let p=r(o,a,l),m=mi(c,Sn.relativeLuminance(p>>8));if(m<l){let v=i(o,a,l),y=mi(c,Sn.relativeLuminance(v>>8));return m>y?p:v}return p}let d=i(o,a,l),f=mi(c,Sn.relativeLuminance(d>>8));if(f<l){let p=r(o,a,l),m=mi(c,Sn.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=mi(Sn.relativeLuminance2(f,p,m),Sn.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=mi(Sn.relativeLuminance2(f,p,m),Sn.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=mi(Sn.relativeLuminance2(f,p,m),Sn.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=mi(Sn.relativeLuminance2(f,p,m),Sn.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})(Fd||(Fd={}));function zs(e){let t=e.toString(16);return t.length<2?"0"+t:t}function mi(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var XQ=class extends hu{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()]}},Vh=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new _r}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||us.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++)Vh._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||us.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}};Vh=Nt([ae(0,An)],Vh);function YQ(e){return 57508<=e&&e<=57558}function ZQ(e){return 9472<=e&&e<=9631}function QQ(e){return YQ(e)||ZQ(e)}function JQ(){return{css:{canvas:cd(),cell:cd()},device:{canvas:cd(),cell:cd(),char:{width:0,height:0,left:0,top:0}}}}function cd(){return{width:0,height:0}}var v0=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 _r,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,y=0,_="",x=0,b=0,w=0,S=0,k=!1,T=0,N=!1,O=0,P=0,L=[],R=c!==-1&&u!==-1;for(let I=0;I<m;I++){e.loadCell(I,this._workCell);let j=this._workCell.getWidth();if(j===0)continue;let B=!1,$=I>=P,F=I,A=this._workCell;if(f.length>0&&I===f[0][0]&&$){let ge=f.shift(),Ge=this._isCellInSelection(ge[0],t);for(x=ge[0]+1;x<ge[1];x++)$&&($=Ge===this._isCellInSelection(x,t));$&&($=!n||s<ge[0]||s>=ge[1]),$?(B=!0,A=new XQ(this._workCell,e.translateToString(!0,ge[0],ge[1]),ge[1]-ge[0]),F=ge[1]-1,j=A.getWidth()):P=ge[1]}let D=this._isCellInSelection(I,t),C=n&&I===s,H=R&&I>=c&&I<=u,q=!1;this._decorationService.forEachDecorationAtCell(I,t,void 0,ge=>{q=!0});let M=A.getChars()||us;if(M===" "&&(A.isUnderline()||A.isOverline())&&(M=" "),O=j*a-l.get(M,A.isBold(),A.isItalic()),!v)v=this._document.createElement("span");else if(y&&(D&&N||!D&&!N&&A.bg===b)&&(D&&N&&p.selectionForeground||A.fg===w)&&A.extended.ext===S&&H===k&&O===T&&!C&&!B&&!q&&$){A.isInvisible()?_+=us:_+=M,y++;continue}else y&&(v.textContent=_),v=this._document.createElement("span"),y=0,_="";if(b=A.bg,w=A.fg,S=A.extended.ext,k=H,T=O,N=D,B&&s>=I&&s<=F&&(s=I),!this._coreService.isCursorHidden&&C&&this._coreService.isCursorInitialized){if(L.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&L.push("xterm-cursor-blink"),L.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(i)switch(i){case"outline":L.push("xterm-cursor-outline");break;case"block":L.push("xterm-cursor-block");break;case"bar":L.push("xterm-cursor-bar");break;case"underline":L.push("xterm-cursor-underline");break}}if(A.isBold()&&L.push("xterm-bold"),A.isItalic()&&L.push("xterm-italic"),A.isDim()&&L.push("xterm-dim"),A.isInvisible()?_=us:_=A.getChars()||us,A.isUnderline()&&(L.push(`xterm-underline-${A.extended.underlineStyle}`),_===" "&&(_=" "),!A.isUnderlineColorDefault()))if(A.isUnderlineColorRGB())v.style.textDecorationColor=`rgb(${hu.toColorRGB(A.getUnderlineColor()).join(",")})`;else{let ge=A.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&A.isBold()&&ge<8&&(ge+=8),v.style.textDecorationColor=p.ansi[ge].css}A.isOverline()&&(L.push("xterm-overline"),_===" "&&(_=" ")),A.isStrikethrough()&&L.push("xterm-strikethrough"),H&&(v.style.textDecoration="underline");let ne=A.getFgColor(),oe=A.getFgColorMode(),V=A.getBgColor(),pe=A.getBgColorMode(),Oe=!!A.isInverse();if(Oe){let ge=ne;ne=V,V=ge;let Ge=oe;oe=pe,pe=Ge}let re,Me,Fe=!1;this._decorationService.forEachDecorationAtCell(I,t,void 0,ge=>{ge.options.layer!=="top"&&Fe||(ge.backgroundColorRGB&&(pe=50331648,V=ge.backgroundColorRGB.rgba>>8&16777215,re=ge.backgroundColorRGB),ge.foregroundColorRGB&&(oe=50331648,ne=ge.foregroundColorRGB.rgba>>8&16777215,Me=ge.foregroundColorRGB),Fe=ge.options.layer==="top")}),!Fe&&D&&(re=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,V=re.rgba>>8&16777215,pe=50331648,Fe=!0,p.selectionForeground&&(oe=50331648,ne=p.selectionForeground.rgba>>8&16777215,Me=p.selectionForeground)),Fe&&L.push("xterm-decoration-top");let We;switch(pe){case 16777216:case 33554432:We=p.ansi[V],L.push(`xterm-bg-${V}`);break;case 50331648:We=Lt.toColor(V>>16,V>>8&255,V&255),this._addStyle(v,`background-color:#${sk((V>>>0).toString(16),"0",6)}`);break;case 0:default:Oe?(We=p.foreground,L.push("xterm-bg-257")):We=p.background}switch(re||A.isDim()&&(re=dt.multiplyOpacity(We,.5)),oe){case 16777216:case 33554432:A.isBold()&&ne<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ne+=8),this._applyMinimumContrast(v,We,p.ansi[ne],A,re,void 0)||L.push(`xterm-fg-${ne}`);break;case 50331648:let ge=Lt.toColor(ne>>16&255,ne>>8&255,ne&255);this._applyMinimumContrast(v,We,ge,A,re,Me)||this._addStyle(v,`color:#${sk(ne.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(v,We,p.foreground,A,re,Me)||Oe&&L.push("xterm-fg-257")}L.length&&(v.className=L.join(" "),L.length=0),!C&&!B&&!q&&$?y++:v.textContent=_,O!==this.defaultSpacing&&(v.style.letterSpacing=`${O}px`),d.push(v),I=F}return v&&y&&(v.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,s){if(this._optionsService.rawOptions.minimumContrastRatio===1||QQ(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=dt.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]}};v0=Nt([ae(1,gM),ae(2,jn),ae(3,Fi),ae(4,Mo),ae(5,fu),ae(6,el)],v0);function sk(e,t,n){for(;e.length<n;)e=t+e;return e}var eJ=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}},tJ=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 nJ(){return new tJ}var Em="xterm-dom-renderer-owner-",cr="xterm-rows",ud="xterm-fg-",ok="xterm-bg-",Sl="xterm-focus",dd="xterm-selection",rJ=1,_0=class extends Le{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=rJ++,this._rowElements=[],this._selectionRenderModel=nJ(),this.onRequestRedraw=this._register(new J).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(cr),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(dd),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=JQ(),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(v0,document),this._element.classList.add(Em+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(pt(()=>{this._element.classList.remove(Em+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new eJ(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} .${cr} 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} .${cr} { 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} .${cr} .xterm-dim { color: ${dt.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} .${cr}.${Sl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${cr}.${Sl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${cr}.${Sl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${cr} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${cr} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${cr} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${cr} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${cr} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${dd} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${dd} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${dd} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[s,o]of e.ansi.entries())t+=`${this._terminalSelector} .${ud}${s} { color: ${o.css}; }${this._terminalSelector} .${ud}${s}.xterm-dim { color: ${dt.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${ok}${s} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${ud}257 { color: ${dt.opaque(e.background).css}; }${this._terminalSelector} .${ud}257.xterm-dim { color: ${dt.multiplyOpacity(dt.opaque(e.background),.5).css}; }${this._terminalSelector} .${ok}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(Sl),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Sl),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`.${Em}${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],y=a.lines.get(m);if(!v||!y)break;v.replaceChildren(...this._rowFactory.createRow(y,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))}}};_0=Nt([ae(7,ty),ae(8,rp),ae(9,jn),ae(10,An),ae(11,Mo),ae(12,Fi),ae(13,el)],_0);var x0=class extends Le{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new J),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new sJ(this._optionsService))}catch{this._measureStrategy=this._register(new iJ(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())}};x0=Nt([ae(2,jn)],x0);var DM=class extends Le{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)}},iJ=class extends DM{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}},sJ=class extends DM{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}},oJ=class extends Le{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 aJ(this._window)),this._onDprChange=this._register(new J),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new J),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(dn.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Se(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Se(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}},aJ=class extends Le{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new za),this._onDprChange=this._register(new J),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(pt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Se(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)}},lJ=class extends Le{constructor(){super(),this.linkProviders=[],this._register(pt(()=>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 cy(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 cJ(e,t,n,r,i,s,o,a,l){if(!s)return;let c=cy(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 y0=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return cJ(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=cy(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])}}};y0=Nt([ae(0,Hi),ae(1,rp)],y0);var uJ=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=[]}},LM={};yZ(LM,{getSafariVersion:()=>hJ,isChromeOS:()=>$M,isFirefox:()=>OM,isIpad:()=>fJ,isIphone:()=>pJ,isLegacyEdge:()=>dJ,isLinux:()=>uy,isMac:()=>qh,isNode:()=>ip,isSafari:()=>BM,isWindows:()=>zM});var ip=typeof process<"u"&&"title"in process,pu=ip?"node":navigator.userAgent,mu=ip?"node":navigator.platform,OM=pu.includes("Firefox"),dJ=pu.includes("Edge"),BM=/^((?!chrome|android).)*safari/i.test(pu);function hJ(){if(!BM)return 0;let e=pu.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var qh=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(mu),fJ=mu==="iPad",pJ=mu==="iPhone",zM=["Windows","Win16","Win32","WinCE"].includes(mu),uy=mu.indexOf("Linux")>=0,$M=/\bCrOS\b/.test(pu),FM=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()}},mJ=class extends FM{_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())}}},gJ=class extends FM{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Kh=!ip&&"requestIdleCallback"in window?gJ:mJ,vJ=class{constructor(){this._queue=new Kh}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},b0=class extends Le{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 za),this._pausedResizeTask=new vJ,this._observerDisposable=this._register(new za),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 J),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new J),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new J),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new J),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new uJ((c,u)=>this._renderRows(c,u),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new _J(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(pt(()=>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=pt(()=>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()}};b0=Nt([ae(2,jn),ae(3,rp),ae(4,Mo),ae(5,fu),ae(6,An),ae(7,Fi),ae(8,el)],b0);var _J=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 xJ(e,t,n,r){let i=n.buffer.x,s=n.buffer.y;if(!n.buffer.hasScrollback)return wJ(i,s,e,t,n,r)+sp(s,t,n,r)+SJ(i,s,e,t,n,r);let o;if(s===t)return o=i>e?"D":"C",qc(Math.abs(i-e),Vc(o,r));o=s>t?"D":"C";let a=Math.abs(s-t),l=bJ(s>t?e:i,n)+(a-1)*n.cols+1+yJ(s>t?i:e);return qc(l,Vc(o,r))}function yJ(e,t){return e-1}function bJ(e,t){return t.cols-e}function wJ(e,t,n,r,i,s){return sp(t,r,i,s).length===0?"":qc(UM(e,t,e,t-yo(t,i),!1,i).length,Vc("D",s))}function sp(e,t,n,r){let i=e-yo(e,n),s=t-yo(t,n),o=Math.abs(i-s)-kJ(e,t,n);return qc(o,Vc(HM(e,t),r))}function SJ(e,t,n,r,i,s){let o;sp(t,r,i,s).length>0?o=r-yo(r,i):o=t;let a=r,l=CJ(e,t,n,r,i,s);return qc(UM(e,o,n,a,l==="C",i).length,Vc(l,s))}function kJ(e,t,n){var o;let r=0,i=e-yo(e,n),s=t-yo(t,n);for(let a=0;a<Math.abs(i-s);a++){let l=HM(e,t)==="A"?-1:1;(o=n.buffer.lines.get(i+l*a))!=null&&o.isWrapped&&r++}return r}function yo(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 CJ(e,t,n,r,i,s){let o;return sp(n,r,i,s).length>0?o=r-yo(r,i):o=t,e<n&&o<=r||e>=n&&o<r?"C":"D"}function HM(e,t){return e>t?"A":"B"}function UM(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 Vc(e,t){let n=t?"O":"[";return W.ESC+n+e}function qc(e,t){e=Math.floor(e);let n="";for(let r=0;r<e;r++)n+=t;return n}var EJ=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 ak(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 Nm=50,NJ=15,TJ=50,PJ=500,RJ=" ",IJ=new RegExp(RJ,"g"),w0=class extends Le{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 _r,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new J),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new J),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new J),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new J),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 EJ(this._bufferService),this._activeSelectionMode=0,this._register(pt(()=>{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(IJ," ")).join(zM?`\r
|
|
541
|
+
`,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=""))(W||(W={}));var $d;(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=""))($d||($d={}));var jM;(e=>e.ST=`${W.ESC}\\`)(jM||(jM={}));var g0=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(`${W.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)}}};g0=Nt([ae(2,An),ae(3,jn),ae(4,Mo),ae(5,Hi)],g0);var nn=0,rn=0,sn=0,St=0,ik={css:"#00000000",rgba:0},Lt;(e=>{function t(i,s,o,a){return a!==void 0?`#${zs(i)}${zs(s)}${zs(o)}${zs(a)}`:`#${zs(i)}${zs(s)}${zs(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})(Lt||(Lt={}));var dt;(e=>{function t(l,c){if(St=(c.rgba&255)/255,St===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;nn=p+Math.round((u-p)*St),rn=m+Math.round((d-m)*St),sn=v+Math.round((f-v)*St);let y=Lt.toCss(nn,rn,sn),_=Lt.toRgba(nn,rn,sn);return{css:y,rgba:_}}e.blend=t;function n(l){return(l.rgba&255)===255}e.isOpaque=n;function r(l,c,u){let d=Fd.ensureContrastRatio(l.rgba,c.rgba,u);if(d)return Lt.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=r;function i(l){let c=(l.rgba|255)>>>0;return[nn,rn,sn]=Fd.toChannels(c),{css:Lt.toCss(nn,rn,sn),rgba:c}}e.opaque=i;function s(l,c){return St=Math.round(c*255),[nn,rn,sn]=Fd.toChannels(l.rgba),{css:Lt.toCss(nn,rn,sn,St),rgba:Lt.toRgba(nn,rn,sn,St)}}e.opacity=s;function o(l,c){return St=l.rgba&255,s(l,St*c/255)}e.multiplyOpacity=o;function a(l){return[l.rgba>>24&255,l.rgba>>16&255,l.rgba>>8&255]}e.toColorRGB=a})(dt||(dt={}));var vt;(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 nn=parseInt(i.slice(1,2).repeat(2),16),rn=parseInt(i.slice(2,3).repeat(2),16),sn=parseInt(i.slice(3,4).repeat(2),16),Lt.toColor(nn,rn,sn);case 5:return nn=parseInt(i.slice(1,2).repeat(2),16),rn=parseInt(i.slice(2,3).repeat(2),16),sn=parseInt(i.slice(3,4).repeat(2),16),St=parseInt(i.slice(4,5).repeat(2),16),Lt.toColor(nn,rn,sn,St);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 nn=parseInt(s[1]),rn=parseInt(s[2]),sn=parseInt(s[3]),St=Math.round((s[5]===void 0?1:parseFloat(s[5]))*255),Lt.toColor(nn,rn,sn,St);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),[nn,rn,sn,St]=t.getImageData(0,0,1,1).data,St!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Lt.toRgba(nn,rn,sn,St),css:i}}e.toColor=r})(vt||(vt={}));var Sn;(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})(Sn||(Sn={}));var Fd;(e=>{function t(o,a){if(St=(a&255)/255,St===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 nn=d+Math.round((l-d)*St),rn=f+Math.round((c-f)*St),sn=p+Math.round((u-p)*St),Lt.toRgba(nn,rn,sn)}e.blend=t;function n(o,a,l){let c=Sn.relativeLuminance(o>>8),u=Sn.relativeLuminance(a>>8);if(mi(c,u)<l){if(u<c){let p=r(o,a,l),m=mi(c,Sn.relativeLuminance(p>>8));if(m<l){let v=i(o,a,l),y=mi(c,Sn.relativeLuminance(v>>8));return m>y?p:v}return p}let d=i(o,a,l),f=mi(c,Sn.relativeLuminance(d>>8));if(f<l){let p=r(o,a,l),m=mi(c,Sn.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=mi(Sn.relativeLuminance2(f,p,m),Sn.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=mi(Sn.relativeLuminance2(f,p,m),Sn.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=mi(Sn.relativeLuminance2(f,p,m),Sn.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=mi(Sn.relativeLuminance2(f,p,m),Sn.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})(Fd||(Fd={}));function zs(e){let t=e.toString(16);return t.length<2?"0"+t:t}function mi(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var XQ=class extends hu{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()]}},Vh=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new _r}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||us.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++)Vh._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||us.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}};Vh=Nt([ae(0,An)],Vh);function YQ(e){return 57508<=e&&e<=57558}function ZQ(e){return 9472<=e&&e<=9631}function QQ(e){return YQ(e)||ZQ(e)}function JQ(){return{css:{canvas:cd(),cell:cd()},device:{canvas:cd(),cell:cd(),char:{width:0,height:0,left:0,top:0}}}}function cd(){return{width:0,height:0}}var v0=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 _r,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,y=0,_="",x=0,b=0,w=0,S=0,k=!1,T=0,N=!1,O=0,P=0,L=[],R=c!==-1&&u!==-1;for(let I=0;I<m;I++){e.loadCell(I,this._workCell);let j=this._workCell.getWidth();if(j===0)continue;let B=!1,$=I>=P,F=I,A=this._workCell;if(f.length>0&&I===f[0][0]&&$){let ge=f.shift(),Ge=this._isCellInSelection(ge[0],t);for(x=ge[0]+1;x<ge[1];x++)$&&($=Ge===this._isCellInSelection(x,t));$&&($=!n||s<ge[0]||s>=ge[1]),$?(B=!0,A=new XQ(this._workCell,e.translateToString(!0,ge[0],ge[1]),ge[1]-ge[0]),F=ge[1]-1,j=A.getWidth()):P=ge[1]}let D=this._isCellInSelection(I,t),C=n&&I===s,H=R&&I>=c&&I<=u,q=!1;this._decorationService.forEachDecorationAtCell(I,t,void 0,ge=>{q=!0});let M=A.getChars()||us;if(M===" "&&(A.isUnderline()||A.isOverline())&&(M=" "),O=j*a-l.get(M,A.isBold(),A.isItalic()),!v)v=this._document.createElement("span");else if(y&&(D&&N||!D&&!N&&A.bg===b)&&(D&&N&&p.selectionForeground||A.fg===w)&&A.extended.ext===S&&H===k&&O===T&&!C&&!B&&!q&&$){A.isInvisible()?_+=us:_+=M,y++;continue}else y&&(v.textContent=_),v=this._document.createElement("span"),y=0,_="";if(b=A.bg,w=A.fg,S=A.extended.ext,k=H,T=O,N=D,B&&s>=I&&s<=F&&(s=I),!this._coreService.isCursorHidden&&C&&this._coreService.isCursorInitialized){if(L.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&L.push("xterm-cursor-blink"),L.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(i)switch(i){case"outline":L.push("xterm-cursor-outline");break;case"block":L.push("xterm-cursor-block");break;case"bar":L.push("xterm-cursor-bar");break;case"underline":L.push("xterm-cursor-underline");break}}if(A.isBold()&&L.push("xterm-bold"),A.isItalic()&&L.push("xterm-italic"),A.isDim()&&L.push("xterm-dim"),A.isInvisible()?_=us:_=A.getChars()||us,A.isUnderline()&&(L.push(`xterm-underline-${A.extended.underlineStyle}`),_===" "&&(_=" "),!A.isUnderlineColorDefault()))if(A.isUnderlineColorRGB())v.style.textDecorationColor=`rgb(${hu.toColorRGB(A.getUnderlineColor()).join(",")})`;else{let ge=A.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&A.isBold()&&ge<8&&(ge+=8),v.style.textDecorationColor=p.ansi[ge].css}A.isOverline()&&(L.push("xterm-overline"),_===" "&&(_=" ")),A.isStrikethrough()&&L.push("xterm-strikethrough"),H&&(v.style.textDecoration="underline");let ne=A.getFgColor(),oe=A.getFgColorMode(),V=A.getBgColor(),pe=A.getBgColorMode(),Oe=!!A.isInverse();if(Oe){let ge=ne;ne=V,V=ge;let Ge=oe;oe=pe,pe=Ge}let re,Me,Fe=!1;this._decorationService.forEachDecorationAtCell(I,t,void 0,ge=>{ge.options.layer!=="top"&&Fe||(ge.backgroundColorRGB&&(pe=50331648,V=ge.backgroundColorRGB.rgba>>8&16777215,re=ge.backgroundColorRGB),ge.foregroundColorRGB&&(oe=50331648,ne=ge.foregroundColorRGB.rgba>>8&16777215,Me=ge.foregroundColorRGB),Fe=ge.options.layer==="top")}),!Fe&&D&&(re=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,V=re.rgba>>8&16777215,pe=50331648,Fe=!0,p.selectionForeground&&(oe=50331648,ne=p.selectionForeground.rgba>>8&16777215,Me=p.selectionForeground)),Fe&&L.push("xterm-decoration-top");let We;switch(pe){case 16777216:case 33554432:We=p.ansi[V],L.push(`xterm-bg-${V}`);break;case 50331648:We=Lt.toColor(V>>16,V>>8&255,V&255),this._addStyle(v,`background-color:#${sk((V>>>0).toString(16),"0",6)}`);break;case 0:default:Oe?(We=p.foreground,L.push("xterm-bg-257")):We=p.background}switch(re||A.isDim()&&(re=dt.multiplyOpacity(We,.5)),oe){case 16777216:case 33554432:A.isBold()&&ne<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ne+=8),this._applyMinimumContrast(v,We,p.ansi[ne],A,re,void 0)||L.push(`xterm-fg-${ne}`);break;case 50331648:let ge=Lt.toColor(ne>>16&255,ne>>8&255,ne&255);this._applyMinimumContrast(v,We,ge,A,re,Me)||this._addStyle(v,`color:#${sk(ne.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(v,We,p.foreground,A,re,Me)||Oe&&L.push("xterm-fg-257")}L.length&&(v.className=L.join(" "),L.length=0),!C&&!B&&!q&&$?y++:v.textContent=_,O!==this.defaultSpacing&&(v.style.letterSpacing=`${O}px`),d.push(v),I=F}return v&&y&&(v.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,s){if(this._optionsService.rawOptions.minimumContrastRatio===1||QQ(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=dt.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]}};v0=Nt([ae(1,gM),ae(2,jn),ae(3,Fi),ae(4,Mo),ae(5,fu),ae(6,el)],v0);function sk(e,t,n){for(;e.length<n;)e=t+e;return e}var eJ=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}},tJ=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 nJ(){return new tJ}var Em="xterm-dom-renderer-owner-",cr="xterm-rows",ud="xterm-fg-",ok="xterm-bg-",Sl="xterm-focus",dd="xterm-selection",rJ=1,_0=class extends Le{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=rJ++,this._rowElements=[],this._selectionRenderModel=nJ(),this.onRequestRedraw=this._register(new ee).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(cr),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(dd),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=JQ(),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(v0,document),this._element.classList.add(Em+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(pt(()=>{this._element.classList.remove(Em+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new eJ(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} .${cr} 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} .${cr} { 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} .${cr} .xterm-dim { color: ${dt.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} .${cr}.${Sl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${cr}.${Sl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${cr}.${Sl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${cr} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${cr} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${cr} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${cr} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${cr} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${dd} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${dd} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${dd} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[s,o]of e.ansi.entries())t+=`${this._terminalSelector} .${ud}${s} { color: ${o.css}; }${this._terminalSelector} .${ud}${s}.xterm-dim { color: ${dt.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${ok}${s} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${ud}257 { color: ${dt.opaque(e.background).css}; }${this._terminalSelector} .${ud}257.xterm-dim { color: ${dt.multiplyOpacity(dt.opaque(e.background),.5).css}; }${this._terminalSelector} .${ok}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(Sl),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Sl),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`.${Em}${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],y=a.lines.get(m);if(!v||!y)break;v.replaceChildren(...this._rowFactory.createRow(y,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))}}};_0=Nt([ae(7,ty),ae(8,rp),ae(9,jn),ae(10,An),ae(11,Mo),ae(12,Fi),ae(13,el)],_0);var x0=class extends Le{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new ee),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new sJ(this._optionsService))}catch{this._measureStrategy=this._register(new iJ(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())}};x0=Nt([ae(2,jn)],x0);var DM=class extends Le{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)}},iJ=class extends DM{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}},sJ=class extends DM{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}},oJ=class extends Le{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 aJ(this._window)),this._onDprChange=this._register(new ee),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new ee),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(dn.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Se(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Se(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}},aJ=class extends Le{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new za),this._onDprChange=this._register(new ee),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(pt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Se(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)}},lJ=class extends Le{constructor(){super(),this.linkProviders=[],this._register(pt(()=>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 cy(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 cJ(e,t,n,r,i,s,o,a,l){if(!s)return;let c=cy(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 y0=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return cJ(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=cy(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])}}};y0=Nt([ae(0,Hi),ae(1,rp)],y0);var uJ=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=[]}},LM={};yZ(LM,{getSafariVersion:()=>hJ,isChromeOS:()=>$M,isFirefox:()=>OM,isIpad:()=>fJ,isIphone:()=>pJ,isLegacyEdge:()=>dJ,isLinux:()=>uy,isMac:()=>qh,isNode:()=>ip,isSafari:()=>BM,isWindows:()=>zM});var ip=typeof process<"u"&&"title"in process,pu=ip?"node":navigator.userAgent,mu=ip?"node":navigator.platform,OM=pu.includes("Firefox"),dJ=pu.includes("Edge"),BM=/^((?!chrome|android).)*safari/i.test(pu);function hJ(){if(!BM)return 0;let e=pu.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var qh=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(mu),fJ=mu==="iPad",pJ=mu==="iPhone",zM=["Windows","Win16","Win32","WinCE"].includes(mu),uy=mu.indexOf("Linux")>=0,$M=/\bCrOS\b/.test(pu),FM=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()}},mJ=class extends FM{_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())}}},gJ=class extends FM{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Kh=!ip&&"requestIdleCallback"in window?gJ:mJ,vJ=class{constructor(){this._queue=new Kh}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},b0=class extends Le{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 za),this._pausedResizeTask=new vJ,this._observerDisposable=this._register(new za),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 ee),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new ee),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new ee),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new ee),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new uJ((c,u)=>this._renderRows(c,u),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new _J(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(pt(()=>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=pt(()=>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()}};b0=Nt([ae(2,jn),ae(3,rp),ae(4,Mo),ae(5,fu),ae(6,An),ae(7,Fi),ae(8,el)],b0);var _J=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 xJ(e,t,n,r){let i=n.buffer.x,s=n.buffer.y;if(!n.buffer.hasScrollback)return wJ(i,s,e,t,n,r)+sp(s,t,n,r)+SJ(i,s,e,t,n,r);let o;if(s===t)return o=i>e?"D":"C",qc(Math.abs(i-e),Vc(o,r));o=s>t?"D":"C";let a=Math.abs(s-t),l=bJ(s>t?e:i,n)+(a-1)*n.cols+1+yJ(s>t?i:e);return qc(l,Vc(o,r))}function yJ(e,t){return e-1}function bJ(e,t){return t.cols-e}function wJ(e,t,n,r,i,s){return sp(t,r,i,s).length===0?"":qc(UM(e,t,e,t-yo(t,i),!1,i).length,Vc("D",s))}function sp(e,t,n,r){let i=e-yo(e,n),s=t-yo(t,n),o=Math.abs(i-s)-kJ(e,t,n);return qc(o,Vc(HM(e,t),r))}function SJ(e,t,n,r,i,s){let o;sp(t,r,i,s).length>0?o=r-yo(r,i):o=t;let a=r,l=CJ(e,t,n,r,i,s);return qc(UM(e,o,n,a,l==="C",i).length,Vc(l,s))}function kJ(e,t,n){var o;let r=0,i=e-yo(e,n),s=t-yo(t,n);for(let a=0;a<Math.abs(i-s);a++){let l=HM(e,t)==="A"?-1:1;(o=n.buffer.lines.get(i+l*a))!=null&&o.isWrapped&&r++}return r}function yo(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 CJ(e,t,n,r,i,s){let o;return sp(n,r,i,s).length>0?o=r-yo(r,i):o=t,e<n&&o<=r||e>=n&&o<r?"C":"D"}function HM(e,t){return e>t?"A":"B"}function UM(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 Vc(e,t){let n=t?"O":"[";return W.ESC+n+e}function qc(e,t){e=Math.floor(e);let n="";for(let r=0;r<e;r++)n+=t;return n}var EJ=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 ak(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 Nm=50,NJ=15,TJ=50,PJ=500,RJ=" ",IJ=new RegExp(RJ,"g"),w0=class extends Le{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 _r,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new ee),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new ee),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new ee),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new ee),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 EJ(this._bufferService),this._activeSelectionMode=0,this._register(pt(()=>{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(IJ," ")).join(zM?`\r
|
|
542
542
|
`:`
|
|
543
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),uy&&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=ak(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=cy(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,-Nm),Nm),t/=Nm,t/Math.abs(t)+Math.round(t*(NJ-1)))}shouldForceSelection(e){return qh?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(),TJ)}_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&&!(qh&&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<PJ&&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=xJ(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 y=e[0],_=e[0];s.getWidth(y)===0&&(u++,y--),s.getWidth(_)===2&&(d++,_++);let x=s.getString(_).length;for(x>1&&(p+=x-1,l+=x-1);y>0&&a>0&&!this._isCharWordSeparator(s.loadCell(y-1,this._workCell));){s.loadCell(y-1,this._workCell);let b=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,y--):b>1&&(f+=b-1,a-=b-1),a--,y--}for(;_<s.length&&l+1<o.length&&!this._isCharWordSeparator(s.loadCell(_+1,this._workCell));){s.loadCell(_+1,this._workCell);let b=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,_++):b>1&&(p+=b-1,l+=b-1),l++,_++}}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 y=i.lines.get(e[1]-1);if(y&&s.isWrapped&&y.getCodePoint(this._bufferService.cols-1)!==32){let _=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(_){let x=this._bufferService.cols-_.start;m-=x,v+=x}}}if(r&&m+v===this._bufferService.cols&&s.getCodePoint(this._bufferService.cols-1)!==32){let y=i.lines.get(e[1]+1);if(y!=null&&y.isWrapped&&y.getCodePoint(0)!==32){let _=this._getWordAt([0,e[1]+1],!1,!1,!0);_&&(v+=_.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=ak(n,this._bufferService.cols)}};w0=Nt([ae(3,An),ae(4,Mo),ae(5,ny),ae(6,jn),ae(7,Hi),ae(8,Fi)],w0);var lk=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={}}},ck=class{constructor(){this._color=new lk,this._css=new lk}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()}},Ht=Object.freeze((()=>{let e=[vt.toColor("#2e3436"),vt.toColor("#cc0000"),vt.toColor("#4e9a06"),vt.toColor("#c4a000"),vt.toColor("#3465a4"),vt.toColor("#75507b"),vt.toColor("#06989a"),vt.toColor("#d3d7cf"),vt.toColor("#555753"),vt.toColor("#ef2929"),vt.toColor("#8ae234"),vt.toColor("#fce94f"),vt.toColor("#729fcf"),vt.toColor("#ad7fa8"),vt.toColor("#34e2e2"),vt.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:Lt.toCss(r,i,s),rgba:Lt.toRgba(r,i,s)})}for(let n=0;n<24;n++){let r=8+n*10;e.push({css:Lt.toCss(r,r,r),rgba:Lt.toRgba(r,r,r)})}return e})()),Hs=vt.toColor("#ffffff"),Bl=vt.toColor("#000000"),uk=vt.toColor("#ffffff"),dk=Bl,kl={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},MJ=Hs,S0=class extends Le{constructor(e){super(),this._optionsService=e,this._contrastCache=new ck,this._halfContrastCache=new ck,this._onChangeColors=this._register(new J),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Hs,background:Bl,cursor:uk,cursorAccent:dk,selectionForeground:void 0,selectionBackgroundTransparent:kl,selectionBackgroundOpaque:dt.blend(Bl,kl),selectionInactiveBackgroundTransparent:kl,selectionInactiveBackgroundOpaque:dt.blend(Bl,kl),scrollbarSliderBackground:dt.opacity(Hs,.2),scrollbarSliderHoverBackground:dt.opacity(Hs,.4),scrollbarSliderActiveBackground:dt.opacity(Hs,.5),overviewRulerBorder:Hs,ansi:Ht.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=nt(e.foreground,Hs),t.background=nt(e.background,Bl),t.cursor=dt.blend(t.background,nt(e.cursor,uk)),t.cursorAccent=dt.blend(t.background,nt(e.cursorAccent,dk)),t.selectionBackgroundTransparent=nt(e.selectionBackground,kl),t.selectionBackgroundOpaque=dt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=nt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=dt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?nt(e.selectionForeground,ik):void 0,t.selectionForeground===ik&&(t.selectionForeground=void 0),dt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=dt.opacity(t.selectionBackgroundTransparent,.3)),dt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=dt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=nt(e.scrollbarSliderBackground,dt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=nt(e.scrollbarSliderHoverBackground,dt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=nt(e.scrollbarSliderActiveBackground,dt.opacity(t.foreground,.5)),t.overviewRulerBorder=nt(e.overviewRulerBorder,MJ),t.ansi=Ht.slice(),t.ansi[0]=nt(e.black,Ht[0]),t.ansi[1]=nt(e.red,Ht[1]),t.ansi[2]=nt(e.green,Ht[2]),t.ansi[3]=nt(e.yellow,Ht[3]),t.ansi[4]=nt(e.blue,Ht[4]),t.ansi[5]=nt(e.magenta,Ht[5]),t.ansi[6]=nt(e.cyan,Ht[6]),t.ansi[7]=nt(e.white,Ht[7]),t.ansi[8]=nt(e.brightBlack,Ht[8]),t.ansi[9]=nt(e.brightRed,Ht[9]),t.ansi[10]=nt(e.brightGreen,Ht[10]),t.ansi[11]=nt(e.brightYellow,Ht[11]),t.ansi[12]=nt(e.brightBlue,Ht[12]),t.ansi[13]=nt(e.brightMagenta,Ht[13]),t.ansi[14]=nt(e.brightCyan,Ht[14]),t.ansi[15]=nt(e.brightWhite,Ht[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]=nt(e.extendedAnsi[r],Ht[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()}}};S0=Nt([ae(0,jn)],S0);function nt(e,t){if(e!==void 0)try{return vt.toColor(e)}catch{}return t}var AJ=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)}},jJ=class{constructor(){this._services=new AJ,this._services.set(ty,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=NZ(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)}},DJ={trace:0,debug:1,info:2,warn:3,error:4,off:5},LJ="xterm.js: ",k0=class extends Le{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=DJ[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?"":LJ)+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)}};k0=Nt([ae(0,jn)],k0);var hk=class extends Le{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new J),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new J),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new J),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}},Ae=3,At=Object.freeze(new hu),hd=0,Tm=2,zl=class WM{constructor(t,n,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Ae);let i=n||_r.fromCharData([0,cM,1,0]);for(let s=0;s<t;++s)this.setCell(s,i);this.length=t}get(t){let n=this._data[t*Ae+0],r=n&2097151;return[this._data[t*Ae+1],n&2097152?this._combined[t]:r?rs(r):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,n){this._data[t*Ae+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*Ae+0]=t|2097152|n[2]<<22):this._data[t*Ae+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*Ae+0]>>22}hasWidth(t){return this._data[t*Ae+0]&12582912}getFg(t){return this._data[t*Ae+1]}getBg(t){return this._data[t*Ae+2]}hasContent(t){return this._data[t*Ae+0]&4194303}getCodePoint(t){let n=this._data[t*Ae+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*Ae+0]&2097152}getString(t){let n=this._data[t*Ae+0];return n&2097152?this._combined[t]:n&2097151?rs(n&2097151):""}isProtected(t){return this._data[t*Ae+2]&536870912}loadCell(t,n){return hd=t*Ae,n.content=this._data[hd+0],n.fg=this._data[hd+1],n.bg=this._data[hd+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*Ae+0]=n.content,this._data[t*Ae+1]=n.fg,this._data[t*Ae+2]=n.bg}setCellFromCodepoint(t,n,r,i){i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*Ae+0]=n|r<<22,this._data[t*Ae+1]=i.fg,this._data[t*Ae+2]=i.bg}addCodepointToCell(t,n,r){let i=this._data[t*Ae+0];i&2097152?this._combined[t]+=rs(n):i&2097151?(this._combined[t]=rs(i&2097151)+rs(n),i&=-2097152,i|=2097152):i=n|1<<22,r&&(i&=-12582913,i|=r<<22),this._data[t*Ae+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 _r;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 _r;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*Tm<this._data.buffer.byteLength;let r=t*Ae;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*Tm<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Tm<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 WM(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*Ae+0]&4194303)return t+(this._data[t*Ae+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Ae+0]&4194303||this._data[t*Ae+2]&50331648)return t+(this._data[t*Ae+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<Ae;c++)this._data[(r+l)*Ae+c]=o[(n+l)*Ae+c];o[(n+l)*Ae+2]&268435456&&(this._extendedAttrs[r+l]=t._extendedAttrs[n+l])}else for(let l=0;l<i;l++){for(let c=0;c<Ae;c++)this._data[(r+l)*Ae+c]=o[(n+l)*Ae+c];o[(n+l)*Ae+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*Ae+0],a=o&2097151,l=o&2097152?this._combined[n]:a?rs(a):us;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 OJ(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=Kc(u,d,t),p=1,m=0;for(;p<u.length;){let y=Kc(u,p,t),_=y-m,x=n-f,b=Math.min(_,x);u[d].copyCellsFrom(u[p],m,f,b,!1),f+=b,f===n&&(d++,f=0),m+=b,m===y&&(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 y=u.length-1;y>0&&(y>d||u[y].getTrimmedLength()===0);y--)v++;v>0&&(o.push(a+u.length-v),o.push(v)),a+=u.length-1}return o}function BJ(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 zJ(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 $J(e,t,n){let r=[],i=e.map((l,c)=>Kc(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=Kc(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 Kc(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 VM=class qM{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=qM._nextId++,this._onDispose=this.register(new J),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),xo(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};VM._nextId=1;var FJ=VM,Kt={},Us=Kt.B;Kt[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Kt.A={"#":"£"};Kt.B=void 0;Kt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Kt.C=Kt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Kt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Kt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Kt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Kt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Kt.E=Kt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Kt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Kt.H=Kt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Kt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var fk=4294967295,pk=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=At.clone(),this.savedCharset=Us,this.markers=[],this._nullCell=_r.fromCharData([0,cM,1,0]),this._whitespaceCell=_r.fromCharData([0,us,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Kh,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new hk(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 Uh),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 Uh),this._whitespaceCell}getBlankLine(e,t){return new zl(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>fk?fk:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=At);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 hk(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(At),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 zl(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 zl(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=OJ(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(At),n);if(r.length>0){let i=BJ(this.lines,r);zJ(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(At),i=n;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new zl(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(At),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 b=this.ybase+this.y;if(b>=o&&b<o+l.length)continue}let c=l[l.length-1].getTrimmedLength(),u=$J(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 b=0;b<d;b++){let w=this.getBlankLine(At,!0);p.push(w)}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 y=l.length-d-1,_=c;for(;y>=0;){let b=Math.min(_,v);if(l[m]===void 0)break;if(l[m].copyCellsFrom(l[y],_-b,v-b,b,!0),v-=b,v===0&&(m--,v=u[m]),_-=b,_===0){y--;let w=Math.max(y,0);_=Kc(l,w,this._cols)}}for(let b=0;b<l.length;b++)u[b]<e&&l[b].setCell(u[b],r);let x=d-f;for(;x-- >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 y=d.newLines.length-1;y>=0;y--)this.lines.set(v--,d.newLines[y]);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 FJ(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)}},HJ=class extends Le{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new J),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 pk(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new pk(!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)}},KM=2,GM=1,C0=class extends Le{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new J),this.onResize=this._onResize.event,this._onScroll=this._register(new J),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,KM),this.rows=Math.max(e.rawOptions.rows||0,GM),this.buffers=this._register(new HJ(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))}};C0=Nt([ae(0,jn)],C0);var qo={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:qh,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},UJ=["normal","bold","100","200","300","400","500","600","700","800","900"],WJ=class extends Le{constructor(e){super(),this._onOptionChange=this._register(new J),this.onOptionChange=this._onOptionChange.event;let t={...qo};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(pt(()=>{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 qo))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,r)=>{if(!(n in qo))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=qo[e]),!VJ(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=qo[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=UJ.includes(t)?t:qo[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 VJ(e){return e==="block"||e==="underline"||e==="bar"}function $l(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]&&$l(e[r],t-1);return n}var mk=Object.freeze({insertMode:!1}),gk=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),E0=class extends Le{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 J),this.onData=this._onData.event,this._onUserInput=this._register(new J),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new J),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new J),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=$l(mk),this.decPrivateModes=$l(gk)}reset(){this.modes=$l(mk),this.decPrivateModes=$l(gk)}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))}};E0=Nt([ae(0,An),ae(1,pM),ae(2,jn)],E0);var vk={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 Pm(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 Rm=String.fromCharCode,_k={DEFAULT:e=>{let t=[Pm(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Rm(t[0])}${Rm(t[1])}${Rm(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Pm(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Pm(e,!0)};${e.x};${e.y}${t}`}},N0=class extends Le{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 J),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(vk))this.addProtocol(r,vk[r]);for(let r of Object.keys(_k))this.addEncoding(r,_k[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)}};N0=Nt([ae(0,An),ae(1,Mo),ae(2,jn)],N0);var Im=[[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]],qJ=[[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]],Ut;function KJ(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 GJ=class{constructor(){if(this.version="6",!Ut){Ut=new Uint8Array(65536),Ut.fill(1),Ut[0]=0,Ut.fill(0,1,32),Ut.fill(0,127,160),Ut.fill(2,4352,4448),Ut[9001]=2,Ut[9002]=2,Ut.fill(2,11904,42192),Ut[12351]=1,Ut.fill(2,44032,55204),Ut.fill(2,63744,64256),Ut.fill(2,65040,65050),Ut.fill(2,65072,65136),Ut.fill(2,65280,65377),Ut.fill(2,65504,65511);for(let e=0;e<Im.length;++e)Ut.fill(0,Im[e][0],Im[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ut[e]:KJ(e,qJ)?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=Zs.extractWidth(t);i===0?r=!1:i>n&&(n=i)}return Zs.createPropertyValue(0,n,r)}},Zs=class Hd{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new J,this.onChange=this._onChange.event;let t=new GJ;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=Hd.extractWidth(a);Hd.extractShouldJoin(a)&&(l-=Hd.extractWidth(r)),n+=l,r=a}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},XJ=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 xk(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 Cl=2147483647,YJ=256,XM=class T0{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>YJ)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 T0;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 T0(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>Cl?Cl: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>Cl?Cl: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,Cl):t}},El=[],ZJ=class{constructor(){this._state=0,this._active=El,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=El}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=El,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||El,!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",np(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=El,this._id=-1,this._state=0}}},Gn=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+=np(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}},Nl=[],QJ=class{constructor(){this._handlers=Object.create(null),this._active=Nl,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Nl}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=Nl,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Nl,!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",np(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=Nl,this._ident=0}},Fl=new XM;Fl.addParam(0);var yk=class{constructor(e){this._handler=e,this._data="",this._params=Fl,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Fl,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=np(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=Fl,this._data="",this._hitLimit=!1,n));return this._params=Fl,this._data="",this._hitLimit=!1,t}},JJ=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}},dr=160,eee=function(){let e=new JJ(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(dr,0,2,0),e.add(dr,8,5,8),e.add(dr,6,0,6),e.add(dr,11,0,11),e.add(dr,13,13,13),e}(),tee=class extends Le{constructor(e=eee){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 XM,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(pt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new ZJ),this._dcsParser=this._register(new QJ),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:dr)],i>>4){case 2:for(let f=a+1;;++f){if(f>=t||(r=e[f])<32||r>126&&r<dr){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(r=e[f])<32||r>126&&r<dr){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(r=e[f])<32||r>126&&r<dr){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(r=e[f])<32||r>126&&r<dr){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<dr){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<dr){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}}},nee=/^([\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})$/,ree=/^[\da-f]+$/;function bk(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=nee.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),ree.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 Mm(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 iee(e,t=16){let[n,r,i]=e;return`rgb:${Mm(n,t)}/${Mm(r,t)}/${Mm(i,t)}`}var see={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Zi=131072,wk=10;function Sk(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 kk=5e3,Ck=0,oee=class extends Le{constructor(e,t,n,r,i,s,o,a,l=new tee){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 CZ,this._utf8Decoder=new EZ,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=At.clone(),this._eraseAttrDataInternal=At.clone(),this._onRequestBell=this._register(new J),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new J),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new J),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new J),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new J),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new J),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new J),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new J),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new J),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new J),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new J),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new J),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new J),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 P0(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(W.BEL,()=>this.bell()),this._parser.setExecuteHandler(W.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(W.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(W.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(W.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(W.BS,()=>this.backspace()),this._parser.setExecuteHandler(W.HT,()=>this.tab()),this._parser.setExecuteHandler(W.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(W.SI,()=>this.shiftIn()),this._parser.setExecuteHandler($d.IND,()=>this.index()),this._parser.setExecuteHandler($d.NEL,()=>this.nextLine()),this._parser.setExecuteHandler($d.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Gn(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new Gn(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new Gn(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new Gn(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new Gn(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new Gn(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new Gn(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new Gn(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new Gn(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new Gn(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new Gn(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new Gn(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 Kt)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 yk((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"),kk))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${kk} 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>Zi&&(s=this._parseStack.position+Zi)}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<Zi&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Zi))),o||this._dirtyRowTracker.clearRange(),e.length>Zi)for(let c=s;c<e.length;c+=Zi){let u=c+Zi<e.length?c+Zi: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 _=s[String.fromCharCode(r)];_&&(r=_.charCodeAt(0))}let m=this._unicodeService.charProperties(r,f);i=Zs.extractWidth(m);let v=Zs.extractShouldJoin(m),y=v?Zs.extractWidth(f):0;if(f=m,o&&this._onA11yChar.fire(rs(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-y>a){if(l){let _=d,x=this._activeBuffer.x-y;for(this._activeBuffer.x=y,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),y>0&&d instanceof zl&&d.copyCellsFrom(_,x,0,y,!1);x<a;)_.setCellFromCodepoint(x++,0,1,u)}else if(this._activeBuffer.x=a-1,i===2)continue}if(v&&this._activeBuffer.x){let _=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-_,r,i);for(let x=i-y;--x>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(c&&(d.insertCells(this._activeBuffer.x,i-y,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=>Sk(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new yk(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Gn(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(At));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=Zs.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(W.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(W.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(W.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(W.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(W.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,Us),this._charsetService.setgCharset(1,Us),this._charsetService.setgCharset(2,Us),this._charsetService.setgCharset(3,Us);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,y)=>(o.triggerDataEvent(`${W.ESC}[${t?"":"?"}${v};${y}$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|=hu.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=At.fg,e.bg=At.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|=At.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=At.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|=At.fg&16777215,r.bg&=-67108864,r.bg|=At.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${W.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${W.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(`${W.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=At.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(!Sk(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(`${W.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>wk&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>wk&&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(Ek(s))if(i==="?")t.push({type:0,index:s});else{let o=bk(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=bk(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]);Ek(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,Us),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(see[e[0]],Kt[e[1]]||Us),!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=At.clone(),this._eraseAttrDataInternal=At.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 _r;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(`${W.ESC}${o}${W.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)}},P0=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&&(Ck=e,e=t,t=Ck),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};P0=Nt([ae(0,An)],P0);function Ek(e){return 0<=e&&e<256}var aee=5e7,Nk=12,lee=50,cee=class extends Le{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 J),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>aee)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>=Nk?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>=Nk)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>lee&&(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()}},R0=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)))}};R0=Nt([ae(0,An)],R0);var Tk=!1,uee=class extends Le{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new za),this._onBinary=this._register(new J),this.onBinary=this._onBinary.event,this._onData=this._register(new J),this.onData=this._onData.event,this._onLineFeed=this._register(new J),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new J),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new J),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new J),this._instantiationService=new jJ,this.optionsService=this._register(new WJ(e)),this._instantiationService.setService(jn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(C0)),this._instantiationService.setService(An,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(k0)),this._instantiationService.setService(pM,this._logService),this.coreService=this._register(this._instantiationService.createInstance(E0)),this._instantiationService.setService(Mo,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(N0)),this._instantiationService.setService(fM,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Zs)),this._instantiationService.setService(RZ,this.unicodeService),this._charsetService=this._instantiationService.createInstance(XJ),this._instantiationService.setService(PZ,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(R0),this._instantiationService.setService(mM,this._oscLinkService),this._inputHandler=this._register(new oee(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(dn.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(dn.forward(this._bufferService.onResize,this._onResize)),this._register(dn.forward(this.coreService.onData,this._onData)),this._register(dn.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 cee((t,n)=>this._inputHandler.parse(t,n))),this._register(dn.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new J),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&&!Tk&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Tk=!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,KM),t=Math.max(t,GM),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(xk.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(xk(this._bufferService),!1))),this._windowsWrappingHeuristics.value=pt(()=>{for(let t of e)t.dispose()})}}},dee={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 hee(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=W.ESC+"OA":i.key=W.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?i.key=W.ESC+"OD":i.key=W.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?i.key=W.ESC+"OC":i.key=W.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?i.key=W.ESC+"OB":i.key=W.ESC+"[B");break;case 8:i.key=e.ctrlKey?"\b":W.DEL,e.altKey&&(i.key=W.ESC+i.key);break;case 9:if(e.shiftKey){i.key=W.ESC+"[Z";break}i.key=W.HT,i.cancel=!0;break;case 13:i.key=e.altKey?W.ESC+W.CR:W.CR,i.cancel=!0;break;case 27:i.key=W.ESC,e.altKey&&(i.key=W.ESC+W.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;s?i.key=W.ESC+"[1;"+(s+1)+"D":t?i.key=W.ESC+"OD":i.key=W.ESC+"[D";break;case 39:if(e.metaKey)break;s?i.key=W.ESC+"[1;"+(s+1)+"C":t?i.key=W.ESC+"OC":i.key=W.ESC+"[C";break;case 38:if(e.metaKey)break;s?i.key=W.ESC+"[1;"+(s+1)+"A":t?i.key=W.ESC+"OA":i.key=W.ESC+"[A";break;case 40:if(e.metaKey)break;s?i.key=W.ESC+"[1;"+(s+1)+"B":t?i.key=W.ESC+"OB":i.key=W.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=W.ESC+"[2~");break;case 46:s?i.key=W.ESC+"[3;"+(s+1)+"~":i.key=W.ESC+"[3~";break;case 36:s?i.key=W.ESC+"[1;"+(s+1)+"H":t?i.key=W.ESC+"OH":i.key=W.ESC+"[H";break;case 35:s?i.key=W.ESC+"[1;"+(s+1)+"F":t?i.key=W.ESC+"OF":i.key=W.ESC+"[F";break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=W.ESC+"[5;"+(s+1)+"~":i.key=W.ESC+"[5~";break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=W.ESC+"[6;"+(s+1)+"~":i.key=W.ESC+"[6~";break;case 112:s?i.key=W.ESC+"[1;"+(s+1)+"P":i.key=W.ESC+"OP";break;case 113:s?i.key=W.ESC+"[1;"+(s+1)+"Q":i.key=W.ESC+"OQ";break;case 114:s?i.key=W.ESC+"[1;"+(s+1)+"R":i.key=W.ESC+"OR";break;case 115:s?i.key=W.ESC+"[1;"+(s+1)+"S":i.key=W.ESC+"OS";break;case 116:s?i.key=W.ESC+"[15;"+(s+1)+"~":i.key=W.ESC+"[15~";break;case 117:s?i.key=W.ESC+"[17;"+(s+1)+"~":i.key=W.ESC+"[17~";break;case 118:s?i.key=W.ESC+"[18;"+(s+1)+"~":i.key=W.ESC+"[18~";break;case 119:s?i.key=W.ESC+"[19;"+(s+1)+"~":i.key=W.ESC+"[19~";break;case 120:s?i.key=W.ESC+"[20;"+(s+1)+"~":i.key=W.ESC+"[20~";break;case 121:s?i.key=W.ESC+"[21;"+(s+1)+"~":i.key=W.ESC+"[21~";break;case 122:s?i.key=W.ESC+"[23;"+(s+1)+"~":i.key=W.ESC+"[23~";break;case 123:s?i.key=W.ESC+"[24;"+(s+1)+"~":i.key=W.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=W.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=W.DEL:e.keyCode===219?i.key=W.ESC:e.keyCode===220?i.key=W.FS:e.keyCode===221&&(i.key=W.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let a=(o=dee[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(a)i.key=W.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=W.ESC+c}else if(e.keyCode===32)i.key=W.ESC+(e.ctrlKey?W.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let l=e.code.slice(3,4);e.shiftKey||(l=l.toLowerCase()),i.key=W.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=W.US),e.key==="@"&&(i.key=W.NUL));break}return i}var Pt=0,fee=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Kh,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Kh,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||(Pt=this._search(t),Pt===-1)||this._getKey(this._array[Pt])!==t)return!1;do if(this._array[Pt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Pt),!0;while(++Pt<this._array.length&&this._getKey(this._array[Pt])===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&&(Pt=this._search(e),!(Pt<0||Pt>=this._array.length)&&this._getKey(this._array[Pt])===e))do yield this._array[Pt];while(++Pt<this._array.length&&this._getKey(this._array[Pt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Pt=this._search(e),!(Pt<0||Pt>=this._array.length)&&this._getKey(this._array[Pt])===e))do t(this._array[Pt]);while(++Pt<this._array.length&&this._getKey(this._array[Pt])===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}},Am=0,Pk=0,pee=class extends Le{constructor(){super(),this._decorations=new fee(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new J),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new J),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(pt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new mee(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=>{Am=i.options.x??0,Pk=Am+(i.options.width??1),e>=Am&&e<Pk&&(!n||(i.options.layer??"bottom")===n)&&r(i)})}},mee=class extends ys{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new J),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new J),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=vt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=vt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},gee=1e3,vee=class{constructor(e,t=gee){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)}},Rk=20,Gh=class extends Le{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 vee(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(`
|
|
543
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),uy&&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=ak(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=cy(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,-Nm),Nm),t/=Nm,t/Math.abs(t)+Math.round(t*(NJ-1)))}shouldForceSelection(e){return qh?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(),TJ)}_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&&!(qh&&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<PJ&&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=xJ(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 y=e[0],_=e[0];s.getWidth(y)===0&&(u++,y--),s.getWidth(_)===2&&(d++,_++);let x=s.getString(_).length;for(x>1&&(p+=x-1,l+=x-1);y>0&&a>0&&!this._isCharWordSeparator(s.loadCell(y-1,this._workCell));){s.loadCell(y-1,this._workCell);let b=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,y--):b>1&&(f+=b-1,a-=b-1),a--,y--}for(;_<s.length&&l+1<o.length&&!this._isCharWordSeparator(s.loadCell(_+1,this._workCell));){s.loadCell(_+1,this._workCell);let b=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,_++):b>1&&(p+=b-1,l+=b-1),l++,_++}}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 y=i.lines.get(e[1]-1);if(y&&s.isWrapped&&y.getCodePoint(this._bufferService.cols-1)!==32){let _=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(_){let x=this._bufferService.cols-_.start;m-=x,v+=x}}}if(r&&m+v===this._bufferService.cols&&s.getCodePoint(this._bufferService.cols-1)!==32){let y=i.lines.get(e[1]+1);if(y!=null&&y.isWrapped&&y.getCodePoint(0)!==32){let _=this._getWordAt([0,e[1]+1],!1,!1,!0);_&&(v+=_.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=ak(n,this._bufferService.cols)}};w0=Nt([ae(3,An),ae(4,Mo),ae(5,ny),ae(6,jn),ae(7,Hi),ae(8,Fi)],w0);var lk=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={}}},ck=class{constructor(){this._color=new lk,this._css=new lk}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()}},Ht=Object.freeze((()=>{let e=[vt.toColor("#2e3436"),vt.toColor("#cc0000"),vt.toColor("#4e9a06"),vt.toColor("#c4a000"),vt.toColor("#3465a4"),vt.toColor("#75507b"),vt.toColor("#06989a"),vt.toColor("#d3d7cf"),vt.toColor("#555753"),vt.toColor("#ef2929"),vt.toColor("#8ae234"),vt.toColor("#fce94f"),vt.toColor("#729fcf"),vt.toColor("#ad7fa8"),vt.toColor("#34e2e2"),vt.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:Lt.toCss(r,i,s),rgba:Lt.toRgba(r,i,s)})}for(let n=0;n<24;n++){let r=8+n*10;e.push({css:Lt.toCss(r,r,r),rgba:Lt.toRgba(r,r,r)})}return e})()),Hs=vt.toColor("#ffffff"),Bl=vt.toColor("#000000"),uk=vt.toColor("#ffffff"),dk=Bl,kl={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},MJ=Hs,S0=class extends Le{constructor(e){super(),this._optionsService=e,this._contrastCache=new ck,this._halfContrastCache=new ck,this._onChangeColors=this._register(new ee),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Hs,background:Bl,cursor:uk,cursorAccent:dk,selectionForeground:void 0,selectionBackgroundTransparent:kl,selectionBackgroundOpaque:dt.blend(Bl,kl),selectionInactiveBackgroundTransparent:kl,selectionInactiveBackgroundOpaque:dt.blend(Bl,kl),scrollbarSliderBackground:dt.opacity(Hs,.2),scrollbarSliderHoverBackground:dt.opacity(Hs,.4),scrollbarSliderActiveBackground:dt.opacity(Hs,.5),overviewRulerBorder:Hs,ansi:Ht.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=nt(e.foreground,Hs),t.background=nt(e.background,Bl),t.cursor=dt.blend(t.background,nt(e.cursor,uk)),t.cursorAccent=dt.blend(t.background,nt(e.cursorAccent,dk)),t.selectionBackgroundTransparent=nt(e.selectionBackground,kl),t.selectionBackgroundOpaque=dt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=nt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=dt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?nt(e.selectionForeground,ik):void 0,t.selectionForeground===ik&&(t.selectionForeground=void 0),dt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=dt.opacity(t.selectionBackgroundTransparent,.3)),dt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=dt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=nt(e.scrollbarSliderBackground,dt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=nt(e.scrollbarSliderHoverBackground,dt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=nt(e.scrollbarSliderActiveBackground,dt.opacity(t.foreground,.5)),t.overviewRulerBorder=nt(e.overviewRulerBorder,MJ),t.ansi=Ht.slice(),t.ansi[0]=nt(e.black,Ht[0]),t.ansi[1]=nt(e.red,Ht[1]),t.ansi[2]=nt(e.green,Ht[2]),t.ansi[3]=nt(e.yellow,Ht[3]),t.ansi[4]=nt(e.blue,Ht[4]),t.ansi[5]=nt(e.magenta,Ht[5]),t.ansi[6]=nt(e.cyan,Ht[6]),t.ansi[7]=nt(e.white,Ht[7]),t.ansi[8]=nt(e.brightBlack,Ht[8]),t.ansi[9]=nt(e.brightRed,Ht[9]),t.ansi[10]=nt(e.brightGreen,Ht[10]),t.ansi[11]=nt(e.brightYellow,Ht[11]),t.ansi[12]=nt(e.brightBlue,Ht[12]),t.ansi[13]=nt(e.brightMagenta,Ht[13]),t.ansi[14]=nt(e.brightCyan,Ht[14]),t.ansi[15]=nt(e.brightWhite,Ht[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]=nt(e.extendedAnsi[r],Ht[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()}}};S0=Nt([ae(0,jn)],S0);function nt(e,t){if(e!==void 0)try{return vt.toColor(e)}catch{}return t}var AJ=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)}},jJ=class{constructor(){this._services=new AJ,this._services.set(ty,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=NZ(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)}},DJ={trace:0,debug:1,info:2,warn:3,error:4,off:5},LJ="xterm.js: ",k0=class extends Le{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=DJ[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?"":LJ)+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)}};k0=Nt([ae(0,jn)],k0);var hk=class extends Le{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new ee),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new ee),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new ee),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}},Ae=3,At=Object.freeze(new hu),hd=0,Tm=2,zl=class WM{constructor(t,n,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Ae);let i=n||_r.fromCharData([0,cM,1,0]);for(let s=0;s<t;++s)this.setCell(s,i);this.length=t}get(t){let n=this._data[t*Ae+0],r=n&2097151;return[this._data[t*Ae+1],n&2097152?this._combined[t]:r?rs(r):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,n){this._data[t*Ae+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*Ae+0]=t|2097152|n[2]<<22):this._data[t*Ae+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*Ae+0]>>22}hasWidth(t){return this._data[t*Ae+0]&12582912}getFg(t){return this._data[t*Ae+1]}getBg(t){return this._data[t*Ae+2]}hasContent(t){return this._data[t*Ae+0]&4194303}getCodePoint(t){let n=this._data[t*Ae+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*Ae+0]&2097152}getString(t){let n=this._data[t*Ae+0];return n&2097152?this._combined[t]:n&2097151?rs(n&2097151):""}isProtected(t){return this._data[t*Ae+2]&536870912}loadCell(t,n){return hd=t*Ae,n.content=this._data[hd+0],n.fg=this._data[hd+1],n.bg=this._data[hd+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*Ae+0]=n.content,this._data[t*Ae+1]=n.fg,this._data[t*Ae+2]=n.bg}setCellFromCodepoint(t,n,r,i){i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*Ae+0]=n|r<<22,this._data[t*Ae+1]=i.fg,this._data[t*Ae+2]=i.bg}addCodepointToCell(t,n,r){let i=this._data[t*Ae+0];i&2097152?this._combined[t]+=rs(n):i&2097151?(this._combined[t]=rs(i&2097151)+rs(n),i&=-2097152,i|=2097152):i=n|1<<22,r&&(i&=-12582913,i|=r<<22),this._data[t*Ae+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 _r;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 _r;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*Tm<this._data.buffer.byteLength;let r=t*Ae;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*Tm<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Tm<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 WM(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*Ae+0]&4194303)return t+(this._data[t*Ae+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Ae+0]&4194303||this._data[t*Ae+2]&50331648)return t+(this._data[t*Ae+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<Ae;c++)this._data[(r+l)*Ae+c]=o[(n+l)*Ae+c];o[(n+l)*Ae+2]&268435456&&(this._extendedAttrs[r+l]=t._extendedAttrs[n+l])}else for(let l=0;l<i;l++){for(let c=0;c<Ae;c++)this._data[(r+l)*Ae+c]=o[(n+l)*Ae+c];o[(n+l)*Ae+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*Ae+0],a=o&2097151,l=o&2097152?this._combined[n]:a?rs(a):us;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 OJ(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=Kc(u,d,t),p=1,m=0;for(;p<u.length;){let y=Kc(u,p,t),_=y-m,x=n-f,b=Math.min(_,x);u[d].copyCellsFrom(u[p],m,f,b,!1),f+=b,f===n&&(d++,f=0),m+=b,m===y&&(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 y=u.length-1;y>0&&(y>d||u[y].getTrimmedLength()===0);y--)v++;v>0&&(o.push(a+u.length-v),o.push(v)),a+=u.length-1}return o}function BJ(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 zJ(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 $J(e,t,n){let r=[],i=e.map((l,c)=>Kc(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=Kc(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 Kc(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 VM=class qM{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=qM._nextId++,this._onDispose=this.register(new ee),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),xo(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};VM._nextId=1;var FJ=VM,Kt={},Us=Kt.B;Kt[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Kt.A={"#":"£"};Kt.B=void 0;Kt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Kt.C=Kt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Kt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Kt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Kt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Kt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Kt.E=Kt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Kt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Kt.H=Kt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Kt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var fk=4294967295,pk=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=At.clone(),this.savedCharset=Us,this.markers=[],this._nullCell=_r.fromCharData([0,cM,1,0]),this._whitespaceCell=_r.fromCharData([0,us,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Kh,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new hk(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 Uh),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 Uh),this._whitespaceCell}getBlankLine(e,t){return new zl(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>fk?fk:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=At);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 hk(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(At),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 zl(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 zl(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=OJ(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(At),n);if(r.length>0){let i=BJ(this.lines,r);zJ(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(At),i=n;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new zl(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(At),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 b=this.ybase+this.y;if(b>=o&&b<o+l.length)continue}let c=l[l.length-1].getTrimmedLength(),u=$J(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 b=0;b<d;b++){let w=this.getBlankLine(At,!0);p.push(w)}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 y=l.length-d-1,_=c;for(;y>=0;){let b=Math.min(_,v);if(l[m]===void 0)break;if(l[m].copyCellsFrom(l[y],_-b,v-b,b,!0),v-=b,v===0&&(m--,v=u[m]),_-=b,_===0){y--;let w=Math.max(y,0);_=Kc(l,w,this._cols)}}for(let b=0;b<l.length;b++)u[b]<e&&l[b].setCell(u[b],r);let x=d-f;for(;x-- >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 y=d.newLines.length-1;y>=0;y--)this.lines.set(v--,d.newLines[y]);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 FJ(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)}},HJ=class extends Le{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new ee),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 pk(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new pk(!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)}},KM=2,GM=1,C0=class extends Le{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new ee),this.onResize=this._onResize.event,this._onScroll=this._register(new ee),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,KM),this.rows=Math.max(e.rawOptions.rows||0,GM),this.buffers=this._register(new HJ(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))}};C0=Nt([ae(0,jn)],C0);var qo={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:qh,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},UJ=["normal","bold","100","200","300","400","500","600","700","800","900"],WJ=class extends Le{constructor(e){super(),this._onOptionChange=this._register(new ee),this.onOptionChange=this._onOptionChange.event;let t={...qo};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(pt(()=>{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 qo))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,r)=>{if(!(n in qo))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=qo[e]),!VJ(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=qo[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=UJ.includes(t)?t:qo[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 VJ(e){return e==="block"||e==="underline"||e==="bar"}function $l(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]&&$l(e[r],t-1);return n}var mk=Object.freeze({insertMode:!1}),gk=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),E0=class extends Le{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 ee),this.onData=this._onData.event,this._onUserInput=this._register(new ee),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ee),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ee),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=$l(mk),this.decPrivateModes=$l(gk)}reset(){this.modes=$l(mk),this.decPrivateModes=$l(gk)}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))}};E0=Nt([ae(0,An),ae(1,pM),ae(2,jn)],E0);var vk={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 Pm(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 Rm=String.fromCharCode,_k={DEFAULT:e=>{let t=[Pm(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Rm(t[0])}${Rm(t[1])}${Rm(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Pm(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Pm(e,!0)};${e.x};${e.y}${t}`}},N0=class extends Le{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 ee),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(vk))this.addProtocol(r,vk[r]);for(let r of Object.keys(_k))this.addEncoding(r,_k[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)}};N0=Nt([ae(0,An),ae(1,Mo),ae(2,jn)],N0);var Im=[[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]],qJ=[[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]],Ut;function KJ(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 GJ=class{constructor(){if(this.version="6",!Ut){Ut=new Uint8Array(65536),Ut.fill(1),Ut[0]=0,Ut.fill(0,1,32),Ut.fill(0,127,160),Ut.fill(2,4352,4448),Ut[9001]=2,Ut[9002]=2,Ut.fill(2,11904,42192),Ut[12351]=1,Ut.fill(2,44032,55204),Ut.fill(2,63744,64256),Ut.fill(2,65040,65050),Ut.fill(2,65072,65136),Ut.fill(2,65280,65377),Ut.fill(2,65504,65511);for(let e=0;e<Im.length;++e)Ut.fill(0,Im[e][0],Im[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ut[e]:KJ(e,qJ)?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=Zs.extractWidth(t);i===0?r=!1:i>n&&(n=i)}return Zs.createPropertyValue(0,n,r)}},Zs=class Hd{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ee,this.onChange=this._onChange.event;let t=new GJ;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=Hd.extractWidth(a);Hd.extractShouldJoin(a)&&(l-=Hd.extractWidth(r)),n+=l,r=a}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},XJ=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 xk(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 Cl=2147483647,YJ=256,XM=class T0{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>YJ)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 T0;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 T0(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>Cl?Cl: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>Cl?Cl: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,Cl):t}},El=[],ZJ=class{constructor(){this._state=0,this._active=El,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=El}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=El,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||El,!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",np(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=El,this._id=-1,this._state=0}}},Gn=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+=np(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}},Nl=[],QJ=class{constructor(){this._handlers=Object.create(null),this._active=Nl,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Nl}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=Nl,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Nl,!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",np(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=Nl,this._ident=0}},Fl=new XM;Fl.addParam(0);var yk=class{constructor(e){this._handler=e,this._data="",this._params=Fl,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Fl,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=np(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=Fl,this._data="",this._hitLimit=!1,n));return this._params=Fl,this._data="",this._hitLimit=!1,t}},JJ=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}},dr=160,eee=function(){let e=new JJ(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(dr,0,2,0),e.add(dr,8,5,8),e.add(dr,6,0,6),e.add(dr,11,0,11),e.add(dr,13,13,13),e}(),tee=class extends Le{constructor(e=eee){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 XM,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(pt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new ZJ),this._dcsParser=this._register(new QJ),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:dr)],i>>4){case 2:for(let f=a+1;;++f){if(f>=t||(r=e[f])<32||r>126&&r<dr){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(r=e[f])<32||r>126&&r<dr){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(r=e[f])<32||r>126&&r<dr){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(r=e[f])<32||r>126&&r<dr){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<dr){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<dr){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}}},nee=/^([\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})$/,ree=/^[\da-f]+$/;function bk(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=nee.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),ree.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 Mm(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 iee(e,t=16){let[n,r,i]=e;return`rgb:${Mm(n,t)}/${Mm(r,t)}/${Mm(i,t)}`}var see={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Zi=131072,wk=10;function Sk(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 kk=5e3,Ck=0,oee=class extends Le{constructor(e,t,n,r,i,s,o,a,l=new tee){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 CZ,this._utf8Decoder=new EZ,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=At.clone(),this._eraseAttrDataInternal=At.clone(),this._onRequestBell=this._register(new ee),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ee),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ee),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ee),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ee),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ee),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ee),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ee),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ee),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ee),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ee),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ee),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ee),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 P0(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(W.BEL,()=>this.bell()),this._parser.setExecuteHandler(W.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(W.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(W.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(W.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(W.BS,()=>this.backspace()),this._parser.setExecuteHandler(W.HT,()=>this.tab()),this._parser.setExecuteHandler(W.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(W.SI,()=>this.shiftIn()),this._parser.setExecuteHandler($d.IND,()=>this.index()),this._parser.setExecuteHandler($d.NEL,()=>this.nextLine()),this._parser.setExecuteHandler($d.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Gn(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new Gn(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new Gn(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new Gn(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new Gn(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new Gn(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new Gn(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new Gn(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new Gn(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new Gn(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new Gn(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new Gn(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 Kt)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 yk((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"),kk))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${kk} 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>Zi&&(s=this._parseStack.position+Zi)}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<Zi&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Zi))),o||this._dirtyRowTracker.clearRange(),e.length>Zi)for(let c=s;c<e.length;c+=Zi){let u=c+Zi<e.length?c+Zi: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 _=s[String.fromCharCode(r)];_&&(r=_.charCodeAt(0))}let m=this._unicodeService.charProperties(r,f);i=Zs.extractWidth(m);let v=Zs.extractShouldJoin(m),y=v?Zs.extractWidth(f):0;if(f=m,o&&this._onA11yChar.fire(rs(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-y>a){if(l){let _=d,x=this._activeBuffer.x-y;for(this._activeBuffer.x=y,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),y>0&&d instanceof zl&&d.copyCellsFrom(_,x,0,y,!1);x<a;)_.setCellFromCodepoint(x++,0,1,u)}else if(this._activeBuffer.x=a-1,i===2)continue}if(v&&this._activeBuffer.x){let _=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-_,r,i);for(let x=i-y;--x>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(c&&(d.insertCells(this._activeBuffer.x,i-y,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=>Sk(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new yk(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Gn(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(At));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=Zs.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(W.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(W.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(W.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(W.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(W.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,Us),this._charsetService.setgCharset(1,Us),this._charsetService.setgCharset(2,Us),this._charsetService.setgCharset(3,Us);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,y)=>(o.triggerDataEvent(`${W.ESC}[${t?"":"?"}${v};${y}$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|=hu.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=At.fg,e.bg=At.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|=At.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=At.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|=At.fg&16777215,r.bg&=-67108864,r.bg|=At.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${W.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${W.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(`${W.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=At.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(!Sk(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(`${W.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>wk&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>wk&&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(Ek(s))if(i==="?")t.push({type:0,index:s});else{let o=bk(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=bk(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]);Ek(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,Us),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(see[e[0]],Kt[e[1]]||Us),!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=At.clone(),this._eraseAttrDataInternal=At.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 _r;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(`${W.ESC}${o}${W.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)}},P0=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&&(Ck=e,e=t,t=Ck),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};P0=Nt([ae(0,An)],P0);function Ek(e){return 0<=e&&e<256}var aee=5e7,Nk=12,lee=50,cee=class extends Le{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 ee),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>aee)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>=Nk?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>=Nk)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>lee&&(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()}},R0=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)))}};R0=Nt([ae(0,An)],R0);var Tk=!1,uee=class extends Le{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new za),this._onBinary=this._register(new ee),this.onBinary=this._onBinary.event,this._onData=this._register(new ee),this.onData=this._onData.event,this._onLineFeed=this._register(new ee),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ee),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ee),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ee),this._instantiationService=new jJ,this.optionsService=this._register(new WJ(e)),this._instantiationService.setService(jn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(C0)),this._instantiationService.setService(An,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(k0)),this._instantiationService.setService(pM,this._logService),this.coreService=this._register(this._instantiationService.createInstance(E0)),this._instantiationService.setService(Mo,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(N0)),this._instantiationService.setService(fM,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Zs)),this._instantiationService.setService(RZ,this.unicodeService),this._charsetService=this._instantiationService.createInstance(XJ),this._instantiationService.setService(PZ,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(R0),this._instantiationService.setService(mM,this._oscLinkService),this._inputHandler=this._register(new oee(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(dn.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(dn.forward(this._bufferService.onResize,this._onResize)),this._register(dn.forward(this.coreService.onData,this._onData)),this._register(dn.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 cee((t,n)=>this._inputHandler.parse(t,n))),this._register(dn.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ee),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&&!Tk&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Tk=!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,KM),t=Math.max(t,GM),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(xk.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(xk(this._bufferService),!1))),this._windowsWrappingHeuristics.value=pt(()=>{for(let t of e)t.dispose()})}}},dee={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 hee(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=W.ESC+"OA":i.key=W.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?i.key=W.ESC+"OD":i.key=W.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?i.key=W.ESC+"OC":i.key=W.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?i.key=W.ESC+"OB":i.key=W.ESC+"[B");break;case 8:i.key=e.ctrlKey?"\b":W.DEL,e.altKey&&(i.key=W.ESC+i.key);break;case 9:if(e.shiftKey){i.key=W.ESC+"[Z";break}i.key=W.HT,i.cancel=!0;break;case 13:i.key=e.altKey?W.ESC+W.CR:W.CR,i.cancel=!0;break;case 27:i.key=W.ESC,e.altKey&&(i.key=W.ESC+W.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;s?i.key=W.ESC+"[1;"+(s+1)+"D":t?i.key=W.ESC+"OD":i.key=W.ESC+"[D";break;case 39:if(e.metaKey)break;s?i.key=W.ESC+"[1;"+(s+1)+"C":t?i.key=W.ESC+"OC":i.key=W.ESC+"[C";break;case 38:if(e.metaKey)break;s?i.key=W.ESC+"[1;"+(s+1)+"A":t?i.key=W.ESC+"OA":i.key=W.ESC+"[A";break;case 40:if(e.metaKey)break;s?i.key=W.ESC+"[1;"+(s+1)+"B":t?i.key=W.ESC+"OB":i.key=W.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=W.ESC+"[2~");break;case 46:s?i.key=W.ESC+"[3;"+(s+1)+"~":i.key=W.ESC+"[3~";break;case 36:s?i.key=W.ESC+"[1;"+(s+1)+"H":t?i.key=W.ESC+"OH":i.key=W.ESC+"[H";break;case 35:s?i.key=W.ESC+"[1;"+(s+1)+"F":t?i.key=W.ESC+"OF":i.key=W.ESC+"[F";break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=W.ESC+"[5;"+(s+1)+"~":i.key=W.ESC+"[5~";break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=W.ESC+"[6;"+(s+1)+"~":i.key=W.ESC+"[6~";break;case 112:s?i.key=W.ESC+"[1;"+(s+1)+"P":i.key=W.ESC+"OP";break;case 113:s?i.key=W.ESC+"[1;"+(s+1)+"Q":i.key=W.ESC+"OQ";break;case 114:s?i.key=W.ESC+"[1;"+(s+1)+"R":i.key=W.ESC+"OR";break;case 115:s?i.key=W.ESC+"[1;"+(s+1)+"S":i.key=W.ESC+"OS";break;case 116:s?i.key=W.ESC+"[15;"+(s+1)+"~":i.key=W.ESC+"[15~";break;case 117:s?i.key=W.ESC+"[17;"+(s+1)+"~":i.key=W.ESC+"[17~";break;case 118:s?i.key=W.ESC+"[18;"+(s+1)+"~":i.key=W.ESC+"[18~";break;case 119:s?i.key=W.ESC+"[19;"+(s+1)+"~":i.key=W.ESC+"[19~";break;case 120:s?i.key=W.ESC+"[20;"+(s+1)+"~":i.key=W.ESC+"[20~";break;case 121:s?i.key=W.ESC+"[21;"+(s+1)+"~":i.key=W.ESC+"[21~";break;case 122:s?i.key=W.ESC+"[23;"+(s+1)+"~":i.key=W.ESC+"[23~";break;case 123:s?i.key=W.ESC+"[24;"+(s+1)+"~":i.key=W.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=W.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=W.DEL:e.keyCode===219?i.key=W.ESC:e.keyCode===220?i.key=W.FS:e.keyCode===221&&(i.key=W.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let a=(o=dee[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(a)i.key=W.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=W.ESC+c}else if(e.keyCode===32)i.key=W.ESC+(e.ctrlKey?W.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let l=e.code.slice(3,4);e.shiftKey||(l=l.toLowerCase()),i.key=W.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=W.US),e.key==="@"&&(i.key=W.NUL));break}return i}var Pt=0,fee=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Kh,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Kh,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||(Pt=this._search(t),Pt===-1)||this._getKey(this._array[Pt])!==t)return!1;do if(this._array[Pt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Pt),!0;while(++Pt<this._array.length&&this._getKey(this._array[Pt])===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&&(Pt=this._search(e),!(Pt<0||Pt>=this._array.length)&&this._getKey(this._array[Pt])===e))do yield this._array[Pt];while(++Pt<this._array.length&&this._getKey(this._array[Pt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Pt=this._search(e),!(Pt<0||Pt>=this._array.length)&&this._getKey(this._array[Pt])===e))do t(this._array[Pt]);while(++Pt<this._array.length&&this._getKey(this._array[Pt])===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}},Am=0,Pk=0,pee=class extends Le{constructor(){super(),this._decorations=new fee(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new ee),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ee),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(pt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new mee(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=>{Am=i.options.x??0,Pk=Am+(i.options.width??1),e>=Am&&e<Pk&&(!n||(i.options.layer??"bottom")===n)&&r(i)})}},mee=class extends ys{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new ee),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new ee),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=vt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=vt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},gee=1e3,vee=class{constructor(e,t=gee){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)}},Rk=20,Gh=class extends Le{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 vee(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(`
|
|
544
544
|
`))),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(Se(i,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(pt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Rk+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
545
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Rk+1&&(this._liveRegion.textContent+=Yv.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})`}};Gh=Nt([ae(1,ty),ae(2,Fi),ae(3,Hi)],Gh);var I0=class extends Le{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 J),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new J),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(pt(()=>{var s;xo(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(Se(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Se(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Se(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Se(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&&_ee(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,xo(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}}};I0=Nt([ae(1,ny),ae(2,Hi),ae(3,An),ae(4,vM)],I0);function _ee(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 xee=class extends uee{constructor(e={}){super(e),this._linkifier=this._register(new za),this.browser=LM,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new za),this._onCursorMove=this._register(new J),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new J),this.onKey=this._onKey.event,this._onRender=this._register(new J),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new J),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new J),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new J),this.onBell=this._onBell.event,this._onFocus=this._register(new J),this._onBlur=this._register(new J),this._onA11yCharEmitter=this._register(new J),this._onA11yTabEmitter=this._register(new J),this._onWillOpen=this._register(new J),this._setup(),this._decorationService=this._instantiationService.createInstance(pee),this._instantiationService.setService(fu,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(lJ),this._instantiationService.setService(vM,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Qv)),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(dn.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(dn.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(dn.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(dn.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(pt(()=>{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=dt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${W.ESC}]${r};${iee(i)}${jM.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(s=>s.ansi[t.index]=Lt.toColor(...t.color));else{let s=n;this._themeService.modifyColors(o=>o[s]=Lt.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(Gh,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(W.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(W.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(Se(this.element,"copy",t=>{this.hasSelection()&&SZ(t,this._selectionService)}));let e=t=>kZ(t,this.textarea,this.coreService,this.optionsService);this._register(Se(this.textarea,"paste",e)),this._register(Se(this.element,"paste",e)),OM?this._register(Se(this.element,"mousedown",t=>{t.button===2&&$S(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Se(this.element,"contextmenu",t=>{$S(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),uy&&this._register(Se(this.element,"auxclick",t=>{t.button===1&&lM(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Se(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Se(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Se(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Se(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Se(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Se(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Se(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(Se(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",Xv.get()),$M||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(oJ,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Fi,this._coreBrowserService),this._register(Se(this.textarea,"focus",s=>this._handleTextAreaFocus(s))),this._register(Se(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(x0,this._document,this._helperContainer),this._instantiationService.setService(rp,this._charSizeService),this._themeService=this._instantiationService.createInstance(S0),this._instantiationService.setService(el,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Vh),this._instantiationService.setService(gM,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(b0,this.rows,this.screenElement)),this._instantiationService.setService(Hi,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(g0,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(y0),this._instantiationService.setService(ny,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(I0,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(p0,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(w0,this.element,this.screenElement,r)),this._instantiationService.setService(MZ,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(dn.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var s;this._selectionService.refresh(),(s=this._viewport)==null||s.queueSync()})),this._register(this._instantiationService.createInstance(m0,this.screenElement)),this._register(Se(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(Gh,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",s=>this._handleScreenReaderModeOptionChange(s))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Wh,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",s=>{!this._overviewRulerRenderer&&s&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Wh,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(_0,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(Se(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(Se(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=W.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){aM(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=hee(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===W.ETX||n.key===W.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)&&(yee(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(At));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(W.ESC+"[I"):this.coreService.triggerDataEvent(W.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(`${W.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(`${W.ESC}[6;${i};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function yee(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var bee=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)}},wee=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 _r)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Ik=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 wee(t)}getNullCell(){return new _r}},See=class extends Le{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new J),this.onBufferChange=this._onBufferChange.event,this._normal=new Ik(this._core.buffers.normal,"normal"),this._alternate=new Ik(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)}},kee=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)}},Cee=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}},Eee=["cols","rows"],Fr=0,Nee=class extends Le{constructor(e){super(),this._core=this._register(new xee(e)),this._addonManager=this._register(new bee),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(Eee.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 kee(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Cee(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 See(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
|
|
545
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Rk+1&&(this._liveRegion.textContent+=Yv.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})`}};Gh=Nt([ae(1,ty),ae(2,Fi),ae(3,Hi)],Gh);var I0=class extends Le{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 ee),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new ee),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(pt(()=>{var s;xo(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(Se(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Se(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Se(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Se(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&&_ee(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,xo(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}}};I0=Nt([ae(1,ny),ae(2,Hi),ae(3,An),ae(4,vM)],I0);function _ee(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 xee=class extends uee{constructor(e={}){super(e),this._linkifier=this._register(new za),this.browser=LM,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new za),this._onCursorMove=this._register(new ee),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ee),this.onKey=this._onKey.event,this._onRender=this._register(new ee),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ee),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ee),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ee),this.onBell=this._onBell.event,this._onFocus=this._register(new ee),this._onBlur=this._register(new ee),this._onA11yCharEmitter=this._register(new ee),this._onA11yTabEmitter=this._register(new ee),this._onWillOpen=this._register(new ee),this._setup(),this._decorationService=this._instantiationService.createInstance(pee),this._instantiationService.setService(fu,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(lJ),this._instantiationService.setService(vM,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Qv)),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(dn.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(dn.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(dn.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(dn.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(pt(()=>{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=dt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${W.ESC}]${r};${iee(i)}${jM.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(s=>s.ansi[t.index]=Lt.toColor(...t.color));else{let s=n;this._themeService.modifyColors(o=>o[s]=Lt.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(Gh,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(W.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(W.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(Se(this.element,"copy",t=>{this.hasSelection()&&SZ(t,this._selectionService)}));let e=t=>kZ(t,this.textarea,this.coreService,this.optionsService);this._register(Se(this.textarea,"paste",e)),this._register(Se(this.element,"paste",e)),OM?this._register(Se(this.element,"mousedown",t=>{t.button===2&&$S(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Se(this.element,"contextmenu",t=>{$S(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),uy&&this._register(Se(this.element,"auxclick",t=>{t.button===1&&lM(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Se(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Se(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Se(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Se(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Se(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Se(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Se(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(Se(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",Xv.get()),$M||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(oJ,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Fi,this._coreBrowserService),this._register(Se(this.textarea,"focus",s=>this._handleTextAreaFocus(s))),this._register(Se(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(x0,this._document,this._helperContainer),this._instantiationService.setService(rp,this._charSizeService),this._themeService=this._instantiationService.createInstance(S0),this._instantiationService.setService(el,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Vh),this._instantiationService.setService(gM,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(b0,this.rows,this.screenElement)),this._instantiationService.setService(Hi,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(g0,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(y0),this._instantiationService.setService(ny,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(I0,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(p0,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(w0,this.element,this.screenElement,r)),this._instantiationService.setService(MZ,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(dn.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var s;this._selectionService.refresh(),(s=this._viewport)==null||s.queueSync()})),this._register(this._instantiationService.createInstance(m0,this.screenElement)),this._register(Se(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(Gh,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",s=>this._handleScreenReaderModeOptionChange(s))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Wh,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",s=>{!this._overviewRulerRenderer&&s&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Wh,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(_0,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(Se(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(Se(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=W.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){aM(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=hee(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===W.ETX||n.key===W.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)&&(yee(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(At));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(W.ESC+"[I"):this.coreService.triggerDataEvent(W.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(`${W.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(`${W.ESC}[6;${i};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function yee(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var bee=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)}},wee=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 _r)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Ik=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 wee(t)}getNullCell(){return new _r}},See=class extends Le{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ee),this.onBufferChange=this._onBufferChange.event,this._normal=new Ik(this._core.buffers.normal,"normal"),this._alternate=new Ik(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)}},kee=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)}},Cee=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}},Eee=["cols","rows"],Fr=0,Nee=class extends Le{constructor(e){super(),this._core=this._register(new xee(e)),this._addonManager=this._register(new bee),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(Eee.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 kee(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Cee(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 See(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
|
|
546
546
|
`,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 Xv.get()},set promptLabel(e){Xv.set(e)},get tooMuchOutput(){return Yv.get()},set tooMuchOutput(e){Yv.set(e)}}}_verifyIntegers(...e){for(Fr of e)if(Fr===1/0||isNaN(Fr)||Fr%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Fr of e)if(Fr&&(Fr===1/0||isNaN(Fr)||Fr%1!==0||Fr<0))throw new Error("This API only accepts positive integers")}};/**
|
|
547
547
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
548
548
|
* @license MIT
|