@clawos-dev/clawd 0.2.562 → 0.2.563
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-builder-plugin/mcp-server.cjs +7 -2
- package/dist/cli.cjs +13 -7
- package/dist/dispatch/mcp-server.cjs +6 -1
- package/dist/persona-defaults/persona-app-builder/mcp/clawd-app-builder/mcp-server.cjs +7 -2
- package/dist/persona-defaults/persona-dataclaw-builder/mcp/clawd-app-builder/mcp-server.cjs +7 -2
- package/dist/share-ui/assets/{guest-CbQApsnE.js → guest-D6s6EWWc.js} +11 -11
- package/dist/share-ui/guest.html +1 -1
- package/package.json +1 -1
|
@@ -22,7 +22,7 @@ var C1=e=>{throw TypeError(e)};var E1=(e,t,n)=>t.has(e)||C1("Cannot "+n);var Rl=
|
|
|
22
22
|
*
|
|
23
23
|
* This source code is licensed under the MIT license found in the
|
|
24
24
|
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/(function(e){function t(j,O){var E=j.length;j.push(O);e:for(;0<E;){var H=E-1>>>1,q=j[H];if(0<i(q,O))j[H]=O,j[E]=q,E=H;else break e}}function n(j){return j.length===0?null:j[0]}function r(j){if(j.length===0)return null;var O=j[0],E=j.pop();if(E!==O){j[0]=E;e:for(var H=0,q=j.length,L=q>>>1;H<L;){var re=2*(H+1)-1,se=j[re],K=re+1,
|
|
25
|
+
*/(function(e){function t(j,O){var E=j.length;j.push(O);e:for(;0<E;){var H=E-1>>>1,q=j[H];if(0<i(q,O))j[H]=O,j[E]=q,E=H;else break e}}function n(j){return j.length===0?null:j[0]}function r(j){if(j.length===0)return null;var O=j[0],E=j.pop();if(E!==O){j[0]=E;e:for(var H=0,q=j.length,L=q>>>1;H<L;){var re=2*(H+1)-1,se=j[re],K=re+1,ge=j[K];if(0>i(se,E))K<q&&0>i(ge,se)?(j[H]=ge,j[K]=E,H=K):(j[H]=se,j[re]=E,H=re);else if(K<q&&0>i(ge,E))j[H]=ge,j[K]=E,H=K;else break e}}return O}function i(j,O){var E=j.sortIndex-O.sortIndex;return E!==0?E:j.id-O.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();e.unstable_now=function(){return o.now()-a}}var l=[],c=[],u=1,d=null,f=3,p=!1,m=!1,v=!1,w=typeof setTimeout=="function"?setTimeout:null,_=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function b(j){for(var O=n(c);O!==null;){if(O.callback===null)r(c);else if(O.startTime<=j)r(c),O.sortIndex=O.expirationTime,t(l,O);else break;O=n(c)}}function S(j){if(v=!1,b(j),!m)if(n(l)!==null)m=!0,$(C);else{var O=n(c);O!==null&&F(S,O.startTime-j)}}function C(j,O){m=!1,v&&(v=!1,_(T),T=-1),p=!0;var E=f;try{for(b(O),d=n(l);d!==null&&(!(d.expirationTime>O)||j&&!B());){var H=d.callback;if(typeof H=="function"){d.callback=null,f=d.priorityLevel;var q=H(d.expirationTime<=O);O=e.unstable_now(),typeof q=="function"?d.callback=q:d===n(l)&&r(l),b(O)}else r(l);d=n(l)}if(d!==null)var L=!0;else{var re=n(c);re!==null&&F(S,re.startTime-O),L=!1}return L}finally{d=null,f=E,p=!1}}var k=!1,N=null,T=-1,z=5,P=-1;function B(){return!(e.unstable_now()-P<z)}function A(){if(N!==null){var j=e.unstable_now();P=j;var O=!0;try{O=N(!0,j)}finally{O?R():(k=!1,N=null)}}else k=!1}var R;if(typeof x=="function")R=function(){x(A)};else if(typeof MessageChannel<"u"){var M=new MessageChannel,D=M.port2;M.port1.onmessage=A,R=function(){D.postMessage(null)}}else R=function(){w(A,0)};function $(j){N=j,k||(k=!0,R())}function F(j,O){T=w(function(){j(e.unstable_now())},O)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(j){j.callback=null},e.unstable_continueExecution=function(){m||p||(m=!0,$(C))},e.unstable_forceFrameRate=function(j){0>j||125<j?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):z=0<j?Math.floor(1e3/j):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_getFirstCallbackNode=function(){return n(l)},e.unstable_next=function(j){switch(f){case 1:case 2:case 3:var O=3;break;default:O=f}var E=f;f=O;try{return j()}finally{f=E}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(j,O){switch(j){case 1:case 2:case 3:case 4:case 5:break;default:j=3}var E=f;f=j;try{return O()}finally{f=E}},e.unstable_scheduleCallback=function(j,O,E){var H=e.unstable_now();switch(typeof E=="object"&&E!==null?(E=E.delay,E=typeof E=="number"&&0<E?H+E:H):E=H,j){case 1:var q=-1;break;case 2:q=250;break;case 5:q=1073741823;break;case 4:q=1e4;break;default:q=5e3}return q=E+q,j={id:u++,callback:O,priorityLevel:j,startTime:E,expirationTime:q,sortIndex:-1},E>H?(j.sortIndex=E,t(c,j),n(l)===null&&j===n(c)&&(v?(_(T),T=-1):v=!0,F(S,E-H))):(j.sortIndex=q,t(l,j),m||p||(m=!0,$(C))),j},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(j){var O=f;return function(){var E=f;f=O;try{return j.apply(this,arguments)}finally{f=E}}}})(T2);N2.exports=T2;var G4=N2.exports;/**
|
|
26
26
|
* @license React
|
|
27
27
|
* react-dom.production.min.js
|
|
28
28
|
*
|
|
@@ -92,8 +92,8 @@ 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 cw=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 _O={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},xO={motionBase:!0,motionUnit:!0},yO={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},gT=(e,t,n)=>{const r=n.getDerivativeToken(e),{override:i}=t,s=cw(t,["override"]);let o=Object.assign(Object.assign({},r),{override:i});return o=mT(o),s&&Object.entries(s).forEach(([a,l])=>{const{theme:c}=l,u=cw(l,["theme"]);let d=u;c&&(d=gT(Object.assign(Object.assign({},o),u),{override:u},c)),o[a]=d}),o};function vT(){const{token:e,hashed:t,theme:n,override:r,cssVar:i}=Ge.useContext(fT),s=`${gO}-${t||""}`,o=n||hT,[a,l,c]=oj(o,[Xc,e],{salt:s,override:r,getComputedToken:gT,formatToken:mT,cssVar:i&&{prefix:i.prefix,key:i.key,unitless:_O,ignore:xO,preserve:yO}});return[o,c,t?l:"",a,i]}const bO=()=>({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"}}),wO=e=>({[`.${e}`]:Object.assign(Object.assign({},bO()),{[`.${e} .${e}-icon`]:{display:"block"}})}),SO=(e,t)=>{const[n,r]=vT();return Lj({token:r,hashId:"",path:["ant-design-icons",e],nonce:()=>t==null?void 0:t.nonce,layer:{name:"antd"}},()=>wO(e))},kO=Object.assign({},cl),{useId:uw}=kO,CO=()=>"",EO=typeof uw>"u"?CO:uw;function NO(e,t,n){var r;const i=e||{},s=i.inherit===!1||!t?Object.assign(Object.assign({},Uh),{hashed:(r=t==null?void 0:t.hashed)!==null&&r!==void 0?r:Uh.hashed,cssVar:t==null?void 0:t.cssVar}):t,o=EO();return DN(()=>{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!LD(c,d,!0)}))}var TO=["children"],_T=g.createContext({});function IO(e){var t=e.children,n=Pv(e,TO);return g.createElement(_T.Provider,{value:n},t)}var PO=function(e){ON(n,e);var t=zN(n);function n(){return fl(this,n),t.apply(this,arguments)}return pl(n,[{key:"render",value:function(){return this.props.children}}]),n}(g.Component);function RO(e){var t=g.useReducer(function(a){return a+1},0),n=et(t,2),r=n[1],i=g.useRef(e),s=Zv(function(){return i.current}),o=Zv(function(a){i.current=typeof a=="function"?a(i.current):a,r()});return[s,o]}var us="none",ad="appear",ld="enter",cd="leave",dw="none",Or="prepare",wa="start",Sa="active",Dx="end",xT="prepared";function hw(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 MO(e,t){var n={animationend:hw("Animation","AnimationEnd"),transitionend:hw("Transition","TransitionEnd")};return e&&("AnimationEvent"in t||delete n.animationend.animation,"TransitionEvent"in t||delete n.transitionend.transition),n}var AO=MO(Gi(),typeof window<"u"?window:{}),yT={};if(Gi()){var LO=document.createElement("div");yT=LO.style}var ud={};function bT(e){if(ud[e])return ud[e];var t=AO[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 yT)return ud[e]=t[s],ud[e]}return""}var wT=bT("animationend"),ST=bT("transitionend"),kT=!!(wT&&ST),fw=wT||"animationend",pw=ST||"transitionend";function mw(e,t){if(!e)return null;if(Pt(e)==="object"){var n=t.replace(/-\w/g,function(r){return r[1].toUpperCase()});return e[n]}return"".concat(e,"-").concat(t)}const DO=function(e){var t=g.useRef();function n(i){i&&(i.removeEventListener(pw,e),i.removeEventListener(fw,e))}function r(i){t.current&&t.current!==i&&n(t.current),i&&i!==t.current&&(i.addEventListener(pw,e),i.addEventListener(fw,e),t.current=i)}return g.useEffect(function(){return function(){n(t.current)}},[]),[r,n]};var CT=Gi()?g.useLayoutEffect:g.useEffect;const jO=function(){var e=g.useRef(null);function t(){Tv.cancel(e.current)}function n(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;t();var s=Tv(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 OO=[Or,wa,Sa,Dx],BO=[Or,xT],ET=!1,zO=!0;function NT(e){return e===Sa||e===Dx}const $O=function(e,t,n){var r=Jv(dw),i=et(r,2),s=i[0],o=i[1],a=jO(),l=et(a,2),c=l[0],u=l[1];function d(){o(Or,!0)}var f=t?BO:OO;return CT(function(){if(s!==dw&&s!==Dx){var p=f.indexOf(s),m=f[p+1],v=n(s);v===ET?o(m,!0):m&&c(function(w){function _(){w.isCanceled()||o(m,!0)}v===!0?_():Promise.resolve(v).then(_)})}},[e,s]),g.useEffect(function(){return function(){u()}},[]),[d,s]};function FO(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,w=r.onEnterStart,_=r.onLeaveStart,x=r.onAppearActive,b=r.onEnterActive,S=r.onLeaveActive,C=r.onAppearEnd,k=r.onEnterEnd,N=r.onLeaveEnd,T=r.onVisibleChanged,z=Jv(),P=et(z,2),B=P[0],A=P[1],R=RO(us),M=et(R,2),D=M[0],$=M[1],F=Jv(null),j=et(F,2),O=j[0],E=j[1],H=D(),q=g.useRef(!1),L=g.useRef(null);function re(){return n()}var se=g.useRef(!1);function K(){$(us),E(null,!0)}var me=Zv(function(qe){var ot=D();if(ot!==us){var Et=re();if(!(qe&&!qe.deadline&&qe.target!==Et)){var _n=se.current,Tn;ot===ad&&_n?Tn=C==null?void 0:C(Et,qe):ot===ld&&_n?Tn=k==null?void 0:k(Et,qe):ot===cd&&_n&&(Tn=N==null?void 0:N(Et,qe)),_n&&Tn!==!1&&K()}}}),Re=DO(me),ce=et(Re,1),Le=ce[0],Oe=function(ot){switch(ot){case ad:return Ce(Ce(Ce({},Or,f),wa,v),Sa,x);case ld:return Ce(Ce(Ce({},Or,p),wa,w),Sa,b);case cd:return Ce(Ce(Ce({},Or,m),wa,_),Sa,S);default:return{}}},Ae=g.useMemo(function(){return Oe(H)},[H]),_e=$O(H,!e,function(qe){if(qe===Or){var ot=Ae[Or];return ot?ot(re()):ET}if(tt in Ae){var Et;E(((Et=Ae[tt])===null||Et===void 0?void 0:Et.call(Ae,re(),null))||null)}return tt===Sa&&H!==us&&(Le(re()),u>0&&(clearTimeout(L.current),L.current=setTimeout(function(){me({deadline:!0})},u))),tt===xT&&K(),zO}),Qe=et(_e,2),kt=Qe[0],tt=Qe[1],At=NT(tt);se.current=At;var Jt=g.useRef(null);CT(function(){if(!(q.current&&Jt.current===t)){A(t);var qe=q.current;q.current=!0;var ot;!qe&&t&&a&&(ot=ad),qe&&t&&s&&(ot=ld),(qe&&!t&&c||!qe&&d&&!t&&c)&&(ot=cd);var Et=Oe(ot);ot&&(e||Et[Or])?($(ot),kt()):$(us),Jt.current=t}},[t]),g.useEffect(function(){(H===ad&&!a||H===ld&&!s||H===cd&&!c)&&$(us)},[a,s,c]),g.useEffect(function(){return function(){q.current=!1,clearTimeout(L.current)}},[]);var nt=g.useRef(!1);g.useEffect(function(){B&&(nt.current=!0),B!==void 0&&H===us&&((nt.current||B)&&(T==null||T(B)),nt.current=!0)},[B,H]);var Ct=O;return Ae[Or]&&tt===wa&&(Ct=He({transition:"none"},Ct)),[H,tt,Ct,B??t]}function HO(e){var t=e;Pt(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(_T),w=v.motion,_=n(i,w),x=g.useRef(),b=g.useRef();function S(){try{return x.current instanceof HTMLElement?x.current:vD(b.current)}catch{return null}}var C=FO(_,a,S,i),k=et(C,4),N=k[0],T=k[1],z=k[2],P=k[3],B=g.useRef(P);P&&(B.current=!0);var A=g.useCallback(function(j){x.current=j,bD(s,j)},[s]),R,M=He(He({},m),{},{visible:a});if(!d)R=null;else if(N===us)P?R=d(He({},M),A):!c&&B.current&&p?R=d(He(He({},M),{},{className:p}),A):u||!c&&!p?R=d(He(He({},M),{},{style:{display:"none"}}),A):R=null;else{var D;T===Or?D="prepare":NT(T)?D="active":T===wa&&(D="start");var $=mw(f,"".concat(N,"-").concat(D));R=d(He(He({},M),{},{className:sD(mw(f,N),Ce(Ce({},$,$&&D),f,typeof f=="string")),style:z}),A)}if(g.isValidElement(R)&&wD(R)){var F=SD(R);F||(R=g.cloneElement(R,{ref:A}))}return g.createElement(PO,{ref:b},R)});return r.displayName="CSSMotion",r}const UO=HO(kT);var e0="add",t0="keep",n0="remove",Em="removed";function WO(e){var t;return e&&Pt(e)==="object"&&"key"in e?t=e:t={key:e},He(He({},t),{},{key:String(t.key)})}function r0(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return e.map(WO)}function VO(){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=r0(e),o=r0(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 He(He({},p),{},{status:e0})})),r=d),n.push(He(He({},f),{},{status:t0})),r+=1,u=!0;break}}u||n.push(He(He({},c),{},{status:n0}))}),r<i&&(n=n.concat(o.slice(r).map(function(c){return He(He({},c),{},{status:e0})})));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!==n0}),n.forEach(function(u){u.key===c&&(u.status=t0)})}),n}var qO=["component","children","onVisibleChanged","onAllRemoved"],KO=["status"],GO=["eventProps","visible","children","motionName","motionAppear","motionEnter","motionLeave","motionLeaveImmediately","motionDeadline","removeOnLeave","leavedClassName","onAppearPrepare","onAppearStart","onAppearActive","onAppearEnd","onEnterStart","onEnterActive","onEnterEnd","onLeaveStart","onLeaveActive","onLeaveEnd"];function YO(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:UO,n=function(r){ON(s,r);var i=zN(s);function s(){var o;fl(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)),Ce(Ev(o),"state",{keyEntities:[]}),Ce(Ev(o),"removeKey",function(u){o.setState(function(d){var f=d.keyEntities.map(function(p){return p.key!==u?p:He(He({},p),{},{status:Em})});return{keyEntities:f}},function(){var d=o.state.keyEntities,f=d.filter(function(p){var m=p.status;return m!==Em}).length;f===0&&o.props.onAllRemoved&&o.props.onAllRemoved()})}),o}return pl(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=Pv(c,qO),m=u||g.Fragment,v={};return GO.forEach(function(w){v[w]=p[w],delete p[w]}),delete p.keys,g.createElement(m,p,l.map(function(w,_){var x=w.status,b=Pv(w,KO),S=x===e0||x===t0;return g.createElement(t,$h({},v,{key:b.key,visible:S,eventProps:b,onVisibleChanged:function(k){f==null||f(k,{key:b.key}),k||a.removeKey(b.key)}}),function(C,k){return d(He(He({},C),{},{index:_}),k)})}))}}],[{key:"getDerivedStateFromProps",value:function(a,l){var c=a.keys,u=l.keyEntities,d=r0(c),f=VO(u,d);return{keyEntities:f.filter(function(p){var m=u.find(function(v){var w=v.key;return p.key===w});return!(m&&m.status===Em&&p.status===n0)})}}}]),s}(g.Component);return Ce(n,"defaultProps",{component:"div"}),n}YO(kT);const gw=g.createContext(!0);function XO(e){const t=g.useContext(gw),{children:n}=e,[,r]=vT(),{motion:i}=r,s=g.useRef(!1);return s.current||(s.current=t!==i),s.current?g.createElement(gw.Provider,{value:i},g.createElement(IO,{motion:i},n)):n}const QO=()=>null;var ZO=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 JO=["getTargetContainer","getPopupContainer","renderEmpty","input","pagination","form","select","button"];let TT;function e6(){return TT||Xv}function t6(e){return Object.keys(e).some(t=>t.endsWith("Color"))}const n6=e=>{const{prefixCls:t,iconPrefixCls:n,theme:r,holderRender:i}=e;t!==void 0&&(TT=t),r&&t6(r)&&uO(e6(),r)},r6=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:w,parentContext:_,iconPrefixCls:x,theme:b,componentDisabled:S,segmented:C,statistic:k,spin:N,calendar:T,carousel:z,cascader:P,collapse:B,typography:A,checkbox:R,descriptions:M,divider:D,drawer:$,skeleton:F,steps:j,image:O,layout:E,list:H,mentions:q,modal:L,progress:re,result:se,slider:K,breadcrumb:me,menu:Re,pagination:ce,input:Le,textArea:Oe,empty:Ae,badge:_e,radio:Qe,rate:kt,switch:tt,transfer:At,avatar:Jt,message:nt,tag:Ct,table:qe,card:ot,tabs:Et,timeline:_n,timePicker:Tn,upload:U,notification:J,tree:xe,colorPicker:Ie,datePicker:Fe,rangePicker:Nt,flex:en,wave:tn,dropdown:nn,warning:oe,tour:ye,tooltip:rt,popover:mt,popconfirm:fr,floatButton:ae,floatButtonGroup:Je,variant:hn,inputNumber:Ys,treeSelect:Nl}=e,Yo=g.useCallback((Lt,Dt)=>{const{prefixCls:In}=e;if(Dt)return Dt;const pr=In||_.getPrefixCls("");return Lt?`${pr}-${Lt}`:pr},[_.getPrefixCls,e.prefixCls]),ts=x||_.iconPrefixCls||pT,Xs=n||_.csp;SO(ts,Xs);const Tl=NO(b,_.theme,{prefixCls:Yo("")}),Xo={csp:Xs,autoInsertSpaceInButton:r,alert:i,anchor:s,locale:a||w,direction:c,space:u,splitter:d,virtual:f,popupMatchSelectWidth:m??p,popupOverflow:v,getPrefixCls:Yo,iconPrefixCls:ts,theme:Tl,segmented:C,statistic:k,spin:N,calendar:T,carousel:z,cascader:P,collapse:B,typography:A,checkbox:R,descriptions:M,divider:D,drawer:$,skeleton:F,steps:j,image:O,input:Le,textArea:Oe,layout:E,list:H,mentions:q,modal:L,progress:re,result:se,slider:K,breadcrumb:me,menu:Re,pagination:ce,empty:Ae,badge:_e,radio:Qe,rate:kt,switch:tt,transfer:At,avatar:Jt,message:nt,tag:Ct,table:qe,card:ot,tabs:Et,timeline:_n,timePicker:Tn,upload:U,notification:J,tree:xe,colorPicker:Ie,datePicker:Fe,rangePicker:Nt,flex:en,wave:tn,dropdown:nn,warning:oe,tour:ye,tooltip:rt,popover:mt,popconfirm:fr,floatButton:ae,floatButtonGroup:Je,variant:hn,inputNumber:Ys,treeSelect:Nl},bi=Object.assign({},_);Object.keys(Xo).forEach(Lt=>{Xo[Lt]!==void 0&&(bi[Lt]=Xo[Lt])}),JO.forEach(Lt=>{const Dt=e[Lt];Dt&&(bi[Lt]=Dt)}),typeof r<"u"&&(bi.button=Object.assign({autoInsertSpace:r},bi.button));const ns=DN(()=>bi,bi,(Lt,Dt)=>{const In=Object.keys(Lt),pr=Object.keys(Dt);return In.length!==pr.length||In.some(Zs=>Lt[Zs]!==Dt[Zs])}),{layer:Il}=g.useContext(np),Pl=g.useMemo(()=>({prefixCls:ts,csp:Xs,layer:Il?"antd":void 0}),[ts,Xs,Il]);let Vt=g.createElement(g.Fragment,null,g.createElement(QO,{dropdownMatchSelectWidth:p}),t);const Qs=g.useMemo(()=>{var Lt,Dt,In,pr;return Hj(((Lt=sp.Form)===null||Lt===void 0?void 0:Lt.defaultValidateMessages)||{},((In=(Dt=ns.locale)===null||Dt===void 0?void 0:Dt.Form)===null||In===void 0?void 0:In.defaultValidateMessages)||{},((pr=ns.form)===null||pr===void 0?void 0:pr.validateMessages)||{},(o==null?void 0:o.validateMessages)||{})},[ns,o==null?void 0:o.validateMessages]);Object.keys(Qs).length>0&&(Vt=g.createElement(Wj.Provider,{value:Qs},Vt)),a&&(Vt=g.createElement(Kj,{locale:a,_ANT_MARK__:qj},Vt)),Vt=g.createElement(Bj.Provider,{value:Pl},Vt),l&&(Vt=g.createElement(hO,{size:l},Vt)),Vt=g.createElement(XO,null,Vt);const Wp=g.useMemo(()=>{const Lt=Tl||{},{algorithm:Dt,token:In,components:pr,cssVar:Zs}=Lt,ee=ZO(Lt,["algorithm","token","components","cssVar"]),we=Dt&&(!Array.isArray(Dt)||Dt.length>0)?Mv(Dt):hT,ke={};Object.entries(pr||{}).forEach(([Gr,$u])=>{const wi=Object.assign({},$u);"algorithm"in wi&&(wi.algorithm===!0?wi.theme=we:(Array.isArray(wi.algorithm)||typeof wi.algorithm=="function")&&(wi.theme=Mv(wi.algorithm)),delete wi.algorithm),ke[Gr]=wi});const Ze=Object.assign(Object.assign({},Xc),In);return Object.assign(Object.assign({},ee),{theme:we,token:Ze,components:ke,override:Object.assign({override:Ze},ke),cssVar:Zs})},[Tl]);return b&&(Vt=g.createElement(fT.Provider,{value:Wp},Vt)),ns.warning&&(Vt=g.createElement(Uj.Provider,{value:ns.warning},Vt)),S!==void 0&&(Vt=g.createElement(dO,{disabled:S},Vt)),g.createElement(op.Provider,{value:ns},Vt)},gl=e=>{const t=g.useContext(op),n=g.useContext(lT);return g.createElement(r6,Object.assign({parentContext:t,legacyLocale:n},e))};gl.ConfigContext=op;gl.SizeContext=Qc;gl.config=n6;gl.useConfig=fO;Object.defineProperty(gl,"SizeContext",{get:()=>Qc});const gr=(e,t)=>new bt(e).setA(t).toRgbString(),Jo=(e,t)=>new bt(e).lighten(t).toHexString(),i6=e=>{const t=Ga(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]}},s6=(e,t)=>{const n=e||"#000",r=t||"#fff";return{colorBgBase:n,colorTextBase:r,colorText:gr(r,.85),colorTextSecondary:gr(r,.65),colorTextTertiary:gr(r,.45),colorTextQuaternary:gr(r,.25),colorFill:gr(r,.18),colorFillSecondary:gr(r,.12),colorFillTertiary:gr(r,.08),colorFillQuaternary:gr(r,.04),colorBgSolid:gr(r,.95),colorBgSolidHover:gr(r,1),colorBgSolidActive:gr(r,.9),colorBgElevated:Jo(n,12),colorBgContainer:Jo(n,8),colorBgLayout:Jo(n,0),colorBgSpotlight:Jo(n,26),colorBgBlur:gr(r,.04),colorBorder:Jo(n,26),colorBorderSecondary:Jo(n,19)}},o6=(e,t)=>{const n=Object.keys(Ax).map(s=>{const o=Ga(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??Lx(e),i=dT(e,{generateColorPalettes:i6,generateNeutralColorPalettes:s6});return Object.assign(Object.assign(Object.assign(Object.assign({},r),n),i),{colorPrimaryBg:i.colorPrimaryBorder,colorPrimaryBgHover:i.colorPrimaryBorderHover})},vw={defaultSeed:Uh.token,defaultAlgorithm:Lx,darkAlgorithm:o6};function _w({children:e}){const t=Cx(),[n,r]=g.useState(t.theme);return g.useEffect(()=>t.onThemeChange(r),[t]),h.jsx(gl,{theme:{algorithm:n.mode==="dark"?vw.darkAlgorithm:vw.defaultAlgorithm,token:{colorPrimary:n.colorPrimary,colorBgContainer:n.colorBgContainer,colorText:n.colorText,colorBorder:n.colorBorder}},children:e})}var Ye;(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})(Ye||(Ye={}));var xw;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(xw||(xw={}));const he=Ye.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ps=e=>{switch(typeof e){case"undefined":return he.undefined;case"string":return he.string;case"number":return Number.isNaN(e)?he.nan:he.number;case"boolean":return he.boolean;case"function":return he.function;case"bigint":return he.bigint;case"symbol":return he.symbol;case"object":return Array.isArray(e)?he.array:e===null?he.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?he.promise:typeof Map<"u"&&e instanceof Map?he.map:typeof Set<"u"&&e instanceof Set?he.set:typeof Date<"u"&&e instanceof Date?he.date:he.object;default:return he.unknown}},Y=Ye.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 Hi 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 Hi))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ye.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()}}Hi.create=e=>new Hi(e);const i0=(e,t)=>{let n;switch(e.code){case Y.invalid_type:e.received===he.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case Y.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Ye.jsonStringifyReplacer)}`;break;case Y.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ye.joinValues(e.keys,", ")}`;break;case Y.invalid_union:n="Invalid input";break;case Y.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ye.joinValues(e.options)}`;break;case Y.invalid_enum_value:n=`Invalid enum value. Expected ${Ye.joinValues(e.options)}, received '${e.received}'`;break;case Y.invalid_arguments:n="Invalid function arguments";break;case Y.invalid_return_type:n="Invalid function return type";break;case Y.invalid_date:n="Invalid date";break;case Y.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}"`:Ye.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case Y.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 Y.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 Y.custom:n="Invalid input";break;case Y.invalid_intersection_types:n="Intersection results could not be merged";break;case Y.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case Y.not_finite:n="Number must be finite";break;default:n=t.defaultError,Ye.assertNever(e)}return{message:n}};let a6=i0;function l6(){return a6}const c6=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=l6(),r=c6({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===i0?void 0:i0].filter(i=>!!i)});e.common.issues.push(r)}class Dn{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 Ne;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 Dn.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 Ne;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 Ne=Object.freeze({status:"aborted"}),nc=e=>({status:"dirty",value:e}),Rr=e=>({status:"valid",value:e}),yw=e=>e.status==="aborted",bw=e=>e.status==="dirty",Ya=e=>e.status==="valid",Wh=e=>typeof Promise<"u"&&e instanceof Promise;var ve;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(ve||(ve={}));class pi{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 ww=(e,t)=>{if(Ya(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 Hi(e.common.issues);return this._error=n,this._error}}};function je(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 Ve{get description(){return this._def.description}_getType(t){return ps(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:ps(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Dn,ctx:{common:t.parent.common,data:t.data,parsedType:ps(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(Wh(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:ps(t)},i=this._parseSync({data:t,path:r.path,parent:r});return ww(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:ps(t)};if(!this["~standard"].async)try{const s=this._parseSync({data:t,path:[],parent:n});return Ya(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=>Ya(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:ps(t)},i=this._parse({data:t,path:r.path,parent:r}),s=await(Wh(i)?i:Promise.resolve(i));return ww(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:Y.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 Os({schema:this,typeName:Te.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 Di.create(this,this._def)}nullable(){return To.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return di.create(this)}promise(){return Xh.create(this,this._def)}or(t){return qh.create([this,t],this._def)}and(t){return Kh.create(this,t,this._def)}transform(t){return new Os({...je(this._def),schema:this,typeName:Te.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Qh({...je(this._def),innerType:this,defaultValue:n,typeName:Te.ZodDefault})}brand(){return new MT({typeName:Te.ZodBranded,type:this,...je(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new Zh({...je(this._def),innerType:this,catchValue:n,typeName:Te.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return Ox.create(this,t)}readonly(){return Jh.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const u6=/^c[^\s-]{8,}$/i,d6=/^[0-9a-z]+$/,h6=/^[0-9A-HJKMNP-TV-Z]{26}$/i,f6=/^[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,p6=/^[a-z0-9_-]{21}$/i,m6=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,g6=/^[-+]?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)?)??$/,v6=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,_6="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Nm;const x6=/^(?:(?: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])$/,y6=/^(?:(?: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])$/,b6=/^(([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]))$/,w6=/^(([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])$/,S6=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,k6=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,IT="((\\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])))",C6=new RegExp(`^${IT}$`);function PT(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 E6(e){return new RegExp(`^${PT(e)}$`)}function N6(e){let t=`${IT}T${PT(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 T6(e,t){return!!((t==="v4"||!t)&&x6.test(e)||(t==="v6"||!t)&&b6.test(e))}function I6(e,t){if(!m6.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 P6(e,t){return!!((t==="v4"||!t)&&y6.test(e)||(t==="v6"||!t)&&w6.test(e))}class Ri extends Ve{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==he.string){const s=this._getOrReturnCtx(t);return ie(s,{code:Y.invalid_type,expected:he.string,received:s.parsedType}),Ne}const r=new Dn;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:Y.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:Y.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:Y.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&ie(i,{code:Y.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")v6.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"email",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Nm||(Nm=new RegExp(_6,"u")),Nm.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"emoji",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")f6.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"uuid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")p6.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"nanoid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")u6.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"cuid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")d6.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"cuid2",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")h6.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"ulid",code:Y.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:Y.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:Y.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:Y.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:Y.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:Y.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?N6(s).test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?C6.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?E6(s).test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?g6.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"duration",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?T6(t.data,s.version)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"ip",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?I6(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"jwt",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?P6(t.data,s.version)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"cidr",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?S6.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"base64",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?k6.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"base64url",code:Y.invalid_string,message:s.message}),r.dirty()):Ye.assertNever(s);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:Y.invalid_string,...ve.errToObj(r)})}_addCheck(t){return new Ri({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...ve.errToObj(t)})}url(t){return this._addCheck({kind:"url",...ve.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...ve.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...ve.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...ve.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...ve.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...ve.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...ve.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...ve.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...ve.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...ve.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...ve.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...ve.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,...ve.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,...ve.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...ve.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...ve.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...ve.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...ve.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...ve.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...ve.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...ve.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...ve.errToObj(n)})}nonempty(t){return this.min(1,ve.errToObj(t))}trim(){return new Ri({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ri({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ri({...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}}Ri.create=e=>new Ri({checks:[],typeName:Te.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...je(e)});function R6(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 Xa extends Ve{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)!==he.number){const s=this._getOrReturnCtx(t);return ie(s,{code:Y.invalid_type,expected:he.number,received:s.parsedType}),Ne}let r;const i=new Dn;for(const s of this._def.checks)s.kind==="int"?Ye.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),ie(r,{code:Y.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:Y.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:Y.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?R6(t.data,s.value)!==0&&(r=this._getOrReturnCtx(t,r),ie(r,{code:Y.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:Y.not_finite,message:s.message}),i.dirty()):Ye.assertNever(s);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,ve.toString(n))}gt(t,n){return this.setLimit("min",t,!1,ve.toString(n))}lte(t,n){return this.setLimit("max",t,!0,ve.toString(n))}lt(t,n){return this.setLimit("max",t,!1,ve.toString(n))}setLimit(t,n,r,i){return new Xa({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ve.toString(i)}]})}_addCheck(t){return new Xa({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:ve.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ve.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ve.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ve.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ve.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:ve.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:ve.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ve.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ve.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"&&Ye.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)}}Xa.create=e=>new Xa({checks:[],typeName:Te.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...je(e)});class Zc extends Ve{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)!==he.bigint)return this._getInvalidInput(t);let r;const i=new Dn;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:Y.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:Y.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:Y.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Ye.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return ie(n,{code:Y.invalid_type,expected:he.bigint,received:n.parsedType}),Ne}gte(t,n){return this.setLimit("min",t,!0,ve.toString(n))}gt(t,n){return this.setLimit("min",t,!1,ve.toString(n))}lte(t,n){return this.setLimit("max",t,!0,ve.toString(n))}lt(t,n){return this.setLimit("max",t,!1,ve.toString(n))}setLimit(t,n,r,i){return new Zc({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ve.toString(i)}]})}_addCheck(t){return new Zc({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ve.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ve.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ve.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ve.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:ve.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}}Zc.create=e=>new Zc({checks:[],typeName:Te.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...je(e)});class s0 extends Ve{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==he.boolean){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:he.boolean,received:r.parsedType}),Ne}return Rr(t.data)}}s0.create=e=>new s0({typeName:Te.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...je(e)});class Vh extends Ve{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==he.date){const s=this._getOrReturnCtx(t);return ie(s,{code:Y.invalid_type,expected:he.date,received:s.parsedType}),Ne}if(Number.isNaN(t.data.getTime())){const s=this._getOrReturnCtx(t);return ie(s,{code:Y.invalid_date}),Ne}const r=new Dn;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:Y.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:Y.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):Ye.assertNever(s);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Vh({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:ve.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:ve.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}}Vh.create=e=>new Vh({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:Te.ZodDate,...je(e)});class Sw extends Ve{_parse(t){if(this._getType(t)!==he.symbol){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:he.symbol,received:r.parsedType}),Ne}return Rr(t.data)}}Sw.create=e=>new Sw({typeName:Te.ZodSymbol,...je(e)});class o0 extends Ve{_parse(t){if(this._getType(t)!==he.undefined){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:he.undefined,received:r.parsedType}),Ne}return Rr(t.data)}}o0.create=e=>new o0({typeName:Te.ZodUndefined,...je(e)});class a0 extends Ve{_parse(t){if(this._getType(t)!==he.null){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:he.null,received:r.parsedType}),Ne}return Rr(t.data)}}a0.create=e=>new a0({typeName:Te.ZodNull,...je(e)});class kw extends Ve{constructor(){super(...arguments),this._any=!0}_parse(t){return Rr(t.data)}}kw.create=e=>new kw({typeName:Te.ZodAny,...je(e)});class l0 extends Ve{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Rr(t.data)}}l0.create=e=>new l0({typeName:Te.ZodUnknown,...je(e)});class js extends Ve{_parse(t){const n=this._getOrReturnCtx(t);return ie(n,{code:Y.invalid_type,expected:he.never,received:n.parsedType}),Ne}}js.create=e=>new js({typeName:Te.ZodNever,...je(e)});class Cw extends Ve{_parse(t){if(this._getType(t)!==he.undefined){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:he.void,received:r.parsedType}),Ne}return Rr(t.data)}}Cw.create=e=>new Cw({typeName:Te.ZodVoid,...je(e)});class di extends Ve{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==he.array)return ie(n,{code:Y.invalid_type,expected:he.array,received:n.parsedType}),Ne;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?Y.too_big:Y.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:Y.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:Y.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 pi(n,o,n.path,a)))).then(o=>Dn.mergeArray(r,o));const s=[...n.data].map((o,a)=>i.type._parseSync(new pi(n,o,n.path,a)));return Dn.mergeArray(r,s)}get element(){return this._def.type}min(t,n){return new di({...this._def,minLength:{value:t,message:ve.toString(n)}})}max(t,n){return new di({...this._def,maxLength:{value:t,message:ve.toString(n)}})}length(t,n){return new di({...this._def,exactLength:{value:t,message:ve.toString(n)}})}nonempty(t){return this.min(1,t)}}di.create=(e,t)=>new di({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Te.ZodArray,...je(t)});function la(e){if(e instanceof $t){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Di.create(la(r))}return new $t({...e._def,shape:()=>t})}else return e instanceof di?new di({...e._def,type:la(e.element)}):e instanceof Di?Di.create(la(e.unwrap())):e instanceof To?To.create(la(e.unwrap())):e instanceof Eo?Eo.create(e.items.map(t=>la(t))):e}class $t extends Ve{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=Ye.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==he.object){const c=this._getOrReturnCtx(t);return ie(c,{code:Y.invalid_type,expected:he.object,received:c.parsedType}),Ne}const{status:r,ctx:i}=this._processInputParams(t),{shape:s,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof js&&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 pi(i,d,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof js){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:Y.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 pi(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=>Dn.mergeObjectSync(r,c)):Dn.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return ve.errToObj,new $t({...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:ve.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new $t({...this._def,unknownKeys:"strip"})}passthrough(){return new $t({...this._def,unknownKeys:"passthrough"})}extend(t){return new $t({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new $t({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Te.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new $t({...this._def,catchall:t})}pick(t){const n={};for(const r of Ye.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new $t({...this._def,shape:()=>n})}omit(t){const n={};for(const r of Ye.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new $t({...this._def,shape:()=>n})}deepPartial(){return la(this)}partial(t){const n={};for(const r of Ye.objectKeys(this.shape)){const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}return new $t({...this._def,shape:()=>n})}required(t){const n={};for(const r of Ye.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Di;)s=s._def.innerType;n[r]=s}return new $t({...this._def,shape:()=>n})}keyof(){return RT(Ye.objectKeys(this.shape))}}$t.create=(e,t)=>new $t({shape:()=>e,unknownKeys:"strip",catchall:js.create(),typeName:Te.ZodObject,...je(t)});$t.strictCreate=(e,t)=>new $t({shape:()=>e,unknownKeys:"strict",catchall:js.create(),typeName:Te.ZodObject,...je(t)});$t.lazycreate=(e,t)=>new $t({shape:e,unknownKeys:"strip",catchall:js.create(),typeName:Te.ZodObject,...je(t)});class qh extends Ve{_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 Hi(a.ctx.common.issues));return ie(n,{code:Y.invalid_union,unionErrors:o}),Ne}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 Hi(l));return ie(n,{code:Y.invalid_union,unionErrors:a}),Ne}}get options(){return this._def.options}}qh.create=(e,t)=>new qh({options:e,typeName:Te.ZodUnion,...je(t)});const Ei=e=>e instanceof u0?Ei(e.schema):e instanceof Os?Ei(e.innerType()):e instanceof Yh?[e.value]:e instanceof No?e.options:e instanceof d0?Ye.objectValues(e.enum):e instanceof Qh?Ei(e._def.innerType):e instanceof o0?[void 0]:e instanceof a0?[null]:e instanceof Di?[void 0,...Ei(e.unwrap())]:e instanceof To?[null,...Ei(e.unwrap())]:e instanceof MT||e instanceof Jh?Ei(e.unwrap()):e instanceof Zh?Ei(e._def.innerType):[];class jx extends Ve{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==he.object)return ie(n,{code:Y.invalid_type,expected:he.object,received:n.parsedType}),Ne;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:Y.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Ne)}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=Ei(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 jx({typeName:Te.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...je(r)})}}function c0(e,t){const n=ps(e),r=ps(t);if(e===t)return{valid:!0,data:e};if(n===he.object&&r===he.object){const i=Ye.objectKeys(t),s=Ye.objectKeys(e).filter(a=>i.indexOf(a)!==-1),o={...e,...t};for(const a of s){const l=c0(e[a],t[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}else if(n===he.array&&r===he.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=c0(o,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===he.date&&r===he.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Kh extends Ve{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(s,o)=>{if(yw(s)||yw(o))return Ne;const a=c0(s.value,o.value);return a.valid?((bw(s)||bw(o))&&n.dirty(),{status:n.value,value:a.data}):(ie(r,{code:Y.invalid_intersection_types}),Ne)};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}))}}Kh.create=(e,t,n)=>new Kh({left:e,right:t,typeName:Te.ZodIntersection,...je(n)});class Eo extends Ve{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==he.array)return ie(r,{code:Y.invalid_type,expected:he.array,received:r.parsedType}),Ne;if(r.data.length<this._def.items.length)return ie(r,{code:Y.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Ne;!this._def.rest&&r.data.length>this._def.items.length&&(ie(r,{code:Y.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 pi(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>Dn.mergeArray(n,o)):Dn.mergeArray(n,s)}get items(){return this._def.items}rest(t){return new Eo({...this._def,rest:t})}}Eo.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Eo({items:e,typeName:Te.ZodTuple,rest:null,...je(t)})};class Gh extends Ve{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!==he.object)return ie(r,{code:Y.invalid_type,expected:he.object,received:r.parsedType}),Ne;const i=[],s=this._def.keyType,o=this._def.valueType;for(const a in r.data)i.push({key:s._parse(new pi(r,a,r.path,a)),value:o._parse(new pi(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?Dn.mergeObjectAsync(n,i):Dn.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof Ve?new Gh({keyType:t,valueType:n,typeName:Te.ZodRecord,...je(r)}):new Gh({keyType:Ri.create(),valueType:t,typeName:Te.ZodRecord,...je(n)})}}class Ew extends Ve{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!==he.map)return ie(r,{code:Y.invalid_type,expected:he.map,received:r.parsedType}),Ne;const i=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([a,l],c)=>({key:i._parse(new pi(r,a,r.path,[c,"key"])),value:s._parse(new pi(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 Ne;(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 Ne;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}}}}Ew.create=(e,t,n)=>new Ew({valueType:t,keyType:e,typeName:Te.ZodMap,...je(n)});class Jc extends Ve{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==he.set)return ie(r,{code:Y.invalid_type,expected:he.set,received:r.parsedType}),Ne;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(ie(r,{code:Y.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:Y.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 Ne;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 pi(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(t,n){return new Jc({...this._def,minSize:{value:t,message:ve.toString(n)}})}max(t,n){return new Jc({...this._def,maxSize:{value:t,message:ve.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Jc.create=(e,t)=>new Jc({valueType:e,minSize:null,maxSize:null,typeName:Te.ZodSet,...je(t)});class u0 extends Ve{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})}}u0.create=(e,t)=>new u0({getter:e,typeName:Te.ZodLazy,...je(t)});class Yh extends Ve{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return ie(n,{received:n.data,code:Y.invalid_literal,expected:this._def.value}),Ne}return{status:"valid",value:t.data}}get value(){return this._def.value}}Yh.create=(e,t)=>new Yh({value:e,typeName:Te.ZodLiteral,...je(t)});function RT(e,t){return new No({values:e,typeName:Te.ZodEnum,...je(t)})}class No extends Ve{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return ie(n,{expected:Ye.joinValues(r),received:n.parsedType,code:Y.invalid_type}),Ne}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:Y.invalid_enum_value,options:r}),Ne}return Rr(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 No.create(t,{...this._def,...n})}exclude(t,n=this._def){return No.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}No.create=RT;class d0 extends Ve{_parse(t){const n=Ye.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==he.string&&r.parsedType!==he.number){const i=Ye.objectValues(n);return ie(r,{expected:Ye.joinValues(i),received:r.parsedType,code:Y.invalid_type}),Ne}if(this._cache||(this._cache=new Set(Ye.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const i=Ye.objectValues(n);return ie(r,{received:r.data,code:Y.invalid_enum_value,options:i}),Ne}return Rr(t.data)}get enum(){return this._def.values}}d0.create=(e,t)=>new d0({values:e,typeName:Te.ZodNativeEnum,...je(t)});class Xh extends Ve{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==he.promise&&n.common.async===!1)return ie(n,{code:Y.invalid_type,expected:he.promise,received:n.parsedType}),Ne;const r=n.parsedType===he.promise?n.data:Promise.resolve(n.data);return Rr(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Xh.create=(e,t)=>new Xh({type:e,typeName:Te.ZodPromise,...je(t)});class Os extends Ve{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Te.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 Ne;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?Ne:l.status==="dirty"||n.value==="dirty"?nc(l.value):l});{if(n.value==="aborted")return Ne;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?Ne:a.status==="dirty"||n.value==="dirty"?nc(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"?Ne:(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"?Ne:(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(!Ya(o))return Ne;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=>Ya(o)?Promise.resolve(i.transform(o.value,s)).then(a=>({status:n.value,value:a})):Ne);Ye.assertNever(i)}}Os.create=(e,t,n)=>new Os({schema:e,typeName:Te.ZodEffects,effect:t,...je(n)});Os.createWithPreprocess=(e,t,n)=>new Os({schema:t,effect:{type:"preprocess",transform:e},typeName:Te.ZodEffects,...je(n)});class Di extends Ve{_parse(t){return this._getType(t)===he.undefined?Rr(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Di.create=(e,t)=>new Di({innerType:e,typeName:Te.ZodOptional,...je(t)});class To extends Ve{_parse(t){return this._getType(t)===he.null?Rr(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}To.create=(e,t)=>new To({innerType:e,typeName:Te.ZodNullable,...je(t)});class Qh extends Ve{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===he.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Qh.create=(e,t)=>new Qh({innerType:e,typeName:Te.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...je(t)});class Zh extends Ve{_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 Wh(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Hi(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Hi(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Zh.create=(e,t)=>new Zh({innerType:e,typeName:Te.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...je(t)});class Nw extends Ve{_parse(t){if(this._getType(t)!==he.nan){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:he.nan,received:r.parsedType}),Ne}return{status:"valid",value:t.data}}}Nw.create=e=>new Nw({typeName:Te.ZodNaN,...je(e)});class MT extends Ve{_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 Ox extends Ve{_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"?Ne:s.status==="dirty"?(n.dirty(),nc(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"?Ne: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 Ox({in:t,out:n,typeName:Te.ZodPipeline})}}class Jh extends Ve{_parse(t){const n=this._def.innerType._parse(t),r=i=>(Ya(i)&&(i.value=Object.freeze(i.value)),i);return Wh(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}Jh.create=(e,t)=>new Jh({innerType:e,typeName:Te.ZodReadonly,...je(t)});var Te;(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"})(Te||(Te={}));const y=Ri.create,W=Xa.create,ge=s0.create,ji=l0.create;js.create;const Z=di.create,I=$t.create;qh.create;const lr=jx.create;Kh.create;Eo.create;const Mr=Gh.create,G=Yh.create,be=No.create;Xh.create;Di.create;To.create;const M6=Os.createWithPreprocess;new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");const A6=["owner"],L6=["agent","owner","user-upload"],AT=I({id:y().min(1),relPath:y().min(1),from:be(L6),label:y().optional(),size:W().int().nonnegative(),mime:y().min(1),addedAt:W().int().nonnegative(),lastEditedAt:W().int().nonnegative().optional(),stale:ge().optional()});I({sessionId:y().min(1),relPath:y().min(1),ttlSeconds:W().int().positive().nullable().optional(),view:be(["raw","md-rendered"]).optional()});I({url:y().min(1),expiresAt:W().int().nonnegative().nullable()});I({sessionId:y().min(1),relPath:y().min(1),label:y().optional(),origin:G("agent").optional()});I({entry:AT});I({sessionId:y().min(1),relPath:y().min(1)});I({removed:G(!0)});I({sessionId:y().min(1)});I({entries:Z(AT)});I({attachmentId:y().min(1),url:y().min(1),relPath:y().min(1),sizeBytes:W().int().nonnegative(),mimeType:y().min(1)});const D6=lr("type",[I({type:G("persona"),id:y().min(1)}).strict(),I({type:G("chat"),id:y().min(1)}).strict(),I({type:G("*")}).strict()]),j6=be(["read","send","admin"]),Bx=I({resource:D6,actions:Z(j6).min(1)}).strict(),O6=I({id:y().min(1),secretHash:y().regex(/^[a-f0-9]{64}$/),displayName:y(),grants:Z(Bx),issuedAt:W().int().nonnegative(),expiresAt:W().int().positive().optional(),maxUses:W().int().positive().optional(),usedCount:W().int().nonnegative(),peerOwnerId:y().min(1).optional(),firstUsedByPeerAt:W().int().positive().optional(),peerDisplayName:y().optional()}).strict(),B6=O6.omit({secretHash:!0});I({type:G("whoami:ok"),owner:I({id:y(),kind:be(["owner","guest"]),displayName:y(),ownerId:y(),provider:y()}).strict(),capability:B6,grantedPersonas:Z(I({id:y().min(1),displayName:y()}).strict())}).strict();I({selfUrl:y().min(1)});I({type:G("contact:handshake:ok"),owner:I({id:y(),ownerId:y(),provider:y(),displayName:y()}),grants:Z(Bx)});const z6=lr("status",[I({status:G("authorized"),login:y().min(1),source:be(["git","file"])}).strict(),I({status:G("missing")}).strict(),I({status:G("invalid"),message:y().min(1)}).strict(),I({status:G("pending"),authUrl:y().url()}).strict()]);I({token:y().min(1)}).strict();I({returnTo:y().url().optional()}).strict();const $6=I({name:y().min(1),from:y().optional(),version:y().optional(),min:y().optional()}),F6=I({name:y().min(1),env:Z(y().min(1)).min(1)}),zx=y().regex(/^[a-z0-9-]+$/,"连接器名只能是小写字母、数字和短横线"),LT=["proxy","env"],DT=["mcp","cli"],H6=["bearer","lark-sidecar"],U6=["none","shared","personal"],jT=["oauth","fields"],$x=y().regex(/^[A-Z][A-Z0-9_]*$/,"要填的变量名只能是大写字母、数字和下划线,且以字母开头"),W6=I({name:zx,kind:be(LT),runner:be(DT),protocol:be(H6).optional(),id:y().min(1),credentialSource:be(U6).optional(),auth:be(jT).optional(),fields:Z($x).default([]),http:I({url:y().min(1),headers:Mr(y(),y())}).optional()}),V6=e=>{if(!e||typeof e!="object")return e;let t=e;if("clis"in t&&Array.isArray(t.clis)){const{clis:n,...r}=t;t="packages"in r?r:{...r,packages:n}}if("assets"in t&&Array.isArray(t.assets)&&t.assets.length===0){const{assets:n,...r}=t;t=r}return t},OT={packages:Z($6),secrets:Z(F6),connectors:Z(W6).default([])};I(OT);const Fx=M6(V6,I({version:G(1),...OT}).strict()),q6=I({target:y().min(1),reason:y().min(1),file:y().min(1),quote:y().min(1)});I({version:G(1),manifest:Fx}).strict();const K6=["hard","soft"],BT=be(K6),G6=be(["scanning","done","failed"]),zT=I({id:y().min(1),manifest:Fx,scanSessionId:y().optional(),status:G6,evidence:Z(q6).default([]),notes:Z(y()).default([]),head:y().min(1).optional(),baseKind:BT.default("hard"),base:y().min(1).optional(),startedAt:W(),finishedAt:W().optional(),error:y().optional()}).strict(),$T=I({head:y().min(1),contentHead:y().min(1),scanId:y().min(1),at:W()}).strict();I({version:G(2),scans:Z(zT),released:$T.optional()}).strict();const Y6=I({url:y().min(1),branch:y().min(1),head:y().min(1),dirty:ge(),ahead:W()}).strict(),X6=I({env:y().min(1),setAt:W().optional()}).strict(),Q6=["pending","running","done","failed","waiting","skipped"],Z6=be(Q6),J6=["build","smoke","deploy"],eB=be(J6),tB=I({key:eB,status:Z6,url:y().optional(),jobId:W().optional(),startedAt:W().optional(),completedAt:W().optional()}).strict(),nB=I({runId:W(),headSha:y().min(1),status:be(["queued","running","completed"]),htmlUrl:y().min(1),jobs:Z(tB)}).strict();I({personaId:y().min(1),github:z6.optional(),repo:Y6.optional(),scans:Z(zT).default([]),released:$T.optional(),secrets:Z(X6).optional(),run:nB.optional(),historyError:y().optional()}).strict();I({sha:y().min(1),actionsUrl:y().min(1)}).strict();const FT=I({personaId:y().min(1)}).strict();FT.extend({scanBase:BT.optional()}).strict();FT.extend({scanId:y().min(1)}).strict();I({personaId:y().min(1),scanId:y().min(1),patch:I({manifest:Fx.optional()}).strict()}).strict();I({personaId:y().min(1),scanId:y().min(1),name:y().min(1),values:Mr(y(),y())}).strict();I({personaId:y().min(1),jobId:W()}).strict();I({personaId:y().min(1),kind:be(["package","secret","connector"]),item:Mr(y(),ji()),evidence:I({reason:y().min(1),file:y().min(1),quote:y().min(1)})}).strict();I({personaId:y().min(1),notes:Z(y()).default([])}).strict();I({deviceId:y().min(1),remoteAccessAllowed:ge()}).strict();I({type:G("contact:setRemoteAccess:ok"),deviceId:y().min(1),remoteAccessAllowed:ge()}).strict();I({type:G("contact:remote-access-updated"),deviceId:y().min(1),remoteAccessAllowed:ge()}).strict();I({personaId:y().min(1)}).strict();const rB=["connected","missing","reauth"],iB=["link","fill"],sB=I({name:zx,id:y().min(1),kind:be(LT),runner:be(DT),auth:be(jT),status:be(rB),action:be(iB),authUrl:y().optional(),fields:Z($x)}).strict();I({connectors:Z(sB)}).strict();I({personaId:y().min(1),name:zx,values:Mr($x,y().min(1))}).strict();const oB=I({deviceId:y().min(1),ownerId:y().min(1),provider:y().min(1),displayName:y(),remoteUrl:y().min(1),connectToken:y(),grants:Z(Bx),addedAt:W().int().nonnegative(),pinnedAt:W().int().nullable().default(null),remoteAccessAllowed:ge().default(!1),note:y().default("")}).strict(),HT=oB;I({deviceId:y().min(1)}).strict();I({type:G("contact:remove:ok"),deviceId:y().min(1)}).strict();I({type:G("contact:list:ok"),contacts:Z(HT)}).strict();I({type:G("contact:added"),contact:HT}).strict();I({type:G("contact:removed"),deviceId:y().min(1)}).strict();I({deviceId:y().min(1),pinned:ge()}).strict();I({deviceId:y().min(1),note:y()}).strict();I({type:G("contact:setNote:ok"),deviceId:y().min(1),note:y()}).strict();I({type:G("contact:pin:ok"),deviceId:y().min(1),pinnedAt:W().int().nullable()}).strict();I({type:G("contact:pinned"),deviceId:y().min(1),pinnedAt:W().int().nullable()}).strict();const aB=I({deviceId:y().min(1),name:y().min(1),url:y().min(1)});I({type:G("device:list:ok"),devices:Z(aB)});I({deviceId:y().min(1),url:y().min(1).optional(),name:y().optional()});I({type:G("device:connect:ok"),deviceId:y(),name:y(),url:y()});const UT=I({ownerId:y().min(1),provider:y().min(1),displayName:y().min(1),avatarUrl:y().optional(),unionId:y().optional()});I({type:G("auth:login:start:ok"),authUrl:y().min(1),state:y().min(1)});I({type:G("auth:getIdentity:ok"),identity:UT.nullable(),deviceId:y().min(1)});I({type:G("auth:logout:ok")});const WT=y().nullable();I({type:G("auth:apiKey:get:ok"),apiKey:y().nullable(),createdAt:y().nullable(),gatewayUrl:WT});I({type:G("auth:apiKey:regenerate:ok"),apiKey:y().min(1),createdAt:y().min(1),gatewayUrl:WT});I({type:G("auth:apiKey:revoke:ok"),revoked:ge()});I({type:G("auth:login:done"),identity:UT});I({type:G("auth:login:failed"),reason:y()});const Hx=lr("kind",[I({kind:G("success"),text:y(),brief:y().optional(),filePaths:Z(y()).optional()}),I({kind:G("failure"),reason:y(),brief:y().optional()})]);I({targetPersona:y().min(1).optional(),dispatchId:y().min(1).optional(),prompt:y(),brief:y().optional(),targetDeviceId:y().min(1).optional(),model:y().min(1).optional(),tool:y().min(1).optional(),sessionLabel:y().min(1).max(60).optional(),meta:Mr(ji()).optional()}).refine(e=>e.targetPersona!==void 0||e.dispatchId!==void 0,{message:"either targetPersona (new dispatch) or dispatchId (follow-up) is required"}).refine(e=>!(e.dispatchId!==void 0&&e.targetDeviceId!==void 0),{message:"cross-device dispatch cannot be continued (dispatchId + targetDeviceId are mutually exclusive)"}).refine(e=>!(e.tool!==void 0&&e.targetDeviceId!==void 0),{message:"engine override is not supported for cross-device dispatch (tool + targetDeviceId are mutually exclusive)"}).refine(e=>!(e.dispatchId!==void 0&&(e.tool!==void 0||e.model!==void 0)),{message:"a follow-up dispatch cannot change engine or model (dispatchId excludes tool / model); start a new dispatch instead"});I({dispatchId:y().min(1),outcome:Hx});const lB=["running","completed","failed"],Ux=be(lB),cB=I({dispatchId:y().min(1),sourceSessionId:y().min(1),sourcePersonaId:y().min(1).optional(),targetPersonaId:y().min(1),targetDeviceId:y().min(1).optional(),workerSessionId:y().min(1).optional(),taskText:y(),taskBrief:y().optional(),round:W().int().positive().optional(),status:Ux,outcome:Hx.optional(),meta:Mr(ji()).optional(),createdAt:y().min(1),completedAt:y().min(1).optional(),deliveredAt:y().min(1).optional()});I({sourceSessionId:y().min(1).optional(),relatedSessionId:y().min(1).optional()});I({records:Z(cB)});I({dispatchId:y().min(1)});I({type:G("personaDispatch:get:ok"),status:Ux,outcome:Hx.optional()});const uB=/^[a-z0-9][a-z0-9-]*$/;be(["stopped","starting","running","crashed","invalid"]);const dB=new Set(["localhost","127.0.0.1"]);function hB(e){let t;try{t=new URL(e)}catch{return!1}return!!(t.protocol==="https:"||t.protocol==="http:"&&dB.has(t.hostname))}const dd=I({id:y().regex(uB),name:y().min(1),version:y().min(1),apiVersion:G("1"),runtime:I({startCommand:y().min(1)}).passthrough().optional(),entry:I({url:y().url().refine(hB,{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:Y.custom,message:"INVALID_MANIFEST: entry.url and runtime cannot coexist"}),!n&&!r&&t.addIssue({code:Y.custom,message:"INVALID_MANIFEST: must have either entry.url or runtime"})}),fB=lr("kind",[I({kind:G("local"),port:W().int().min(1).max(65535)}),I({kind:G("hosted"),url:y().url()})]);lr("state",[I({extId:y(),manifest:dd,state:G("stopped")}),I({extId:y(),manifest:dd,state:G("starting")}),I({extId:y(),manifest:dd,state:G("running"),target:fB}),I({extId:y(),manifest:dd,state:G("crashed")}),I({extId:y(),manifest:ji().nullable(),state:G("invalid"),invalidReason:y().min(1)})]);I({snapshotHash:y().min(1),version:y().min(1),publishedAt:W()});const pB=lr("kind",[I({kind:G("p2p-tunnel"),ownerPrincipalId:y().min(1),extId:y().min(1)})]);lr("kind",[I({kind:G("p2p-tunnel"),ownerPrincipalId:y().min(1),extId:y().min(1),snapshotHash:y().min(1)})]);I({extId:y().min(1),name:y().min(1),version:y().min(1),contentHash:y().min(1),publishedAt:W()});const mB=lr("kind",[I({kind:G("clean")}),I({kind:G("ready-new-version"),fromVersion:y().min(1),toVersion:y().min(1)}),I({kind:G("error-same-hash"),version:y().min(1)}),I({kind:G("error-version-not-bumped"),localVersion:y().min(1),publishedVersion:y().min(1)}),I({kind:G("error-version-regression"),localVersion:y().min(1),publishedVersion:y().min(1)})]);I({localManifest:I({name:y().min(1),version:y().min(1),contentHash:y().min(1)}),publishState:lr("kind",[I({kind:G("unpublished")}),I({kind:G("published"),version:y().min(1),contentHash:y().min(1),publishedAt:W()})]),check:mB});I({extId:y().min(1),newVersion:y().min(1).nullish()});I({extId:y().min(1)});I({extId:y().min(1),snapshotHash:y().min(1)});I({channelRef:pB,snapshotHash:y().min(1),zipBase64:y().min(1)});I({id:y().min(1),peerDeviceId:y().min(1),senderDeviceId:y().min(1),text:y().min(1),createdAt:W().int().nonnegative(),readBy:Mr(y().min(1),W().int().positive()).default({}),origin:I({kind:G("persona"),personaId:y().min(1)}).optional()}).strict();I({peerDeviceId:y().min(1).optional(),id:y().min(1),text:y().min(1),createdAt:W().int().nonnegative(),origin:I({kind:G("persona"),personaId:y().min(1)}).optional()}).strict();I({peerDeviceId:y().min(1),sinceCreatedAt:W().int().nonnegative().optional()}).strict();I({peerDeviceId:y().min(1),upToCreatedAt:W().int().nonnegative()}).strict();I({peerDeviceId:y().min(1).optional(),text:y().min(1)});I({peerDeviceId:y().min(1).optional(),command:y().min(1),timeoutMs:W().int().positive().optional()}).strict();I({type:G("peerExec:run:ok"),stdout:y(),stderr:y(),exitCode:W().int().nullable(),timedOut:ge(),stdoutTruncated:ge(),stderrTruncated:ge()}).strict();const VT=lr("kind",[I({kind:G("at"),at:y().min(1)}),I({kind:G("every"),everyMs:W().int().positive(),anchorMs:W().int().nonnegative().optional()}),I({kind:G("cron"),expr:y().min(1),tz:y().min(1).optional()})]),xu=y().trim().min(1);I({personaId:xu,name:y().min(1),schedule:VT,prompt:y().min(1),targetPersona:y().min(1).optional(),timeoutMs:W().int().positive().optional()});I({personaId:xu,onlyMine:ge().optional()});I({personaId:xu,shiftId:y().min(1)});const gB=I({name:y().min(1).optional(),schedule:VT.optional(),prompt:y().min(1).optional(),targetPersona:y().min(1).optional(),timeoutMs:W().int().positive().optional(),enabled:ge().optional()});I({personaId:xu,shiftId:y().min(1),patch:gB});I({personaId:xu,shiftId:y().min(1),limit:W().int().positive().optional()});const qT="persona-master",Wx=I({personaId:y().min(1),deviceId:y().min(1).optional()}),KT=I({id:y().min(1),name:y().min(1),memberPersonas:Z(Wx),memberContactDeviceIds:Z(y().min(1)),createdAt:y().min(1),updatedAt:y().min(1)}),GT=y().trim().min(1);I({name:GT,memberPersonas:Z(Wx).default([]),memberContactDeviceIds:Z(y().min(1)).default([])});I({channelId:y().min(1),name:GT.optional(),memberPersonas:Z(Wx).optional(),memberContactDeviceIds:Z(y().min(1)).optional()});I({channelId:y().min(1)});I({channels:Z(KT)});I({channel:KT});I({ok:G(!0),removedTopics:W().int().min(0)});const Wt=y().trim().min(1),Vx=["master-confirmed","owner-needed"],qx=["open","resolved"],vB=Vx[0];Vx[1];qx[0];const _B=qx[1],xB=be(Vx),yB=be(qx),bB=I({id:Wt.optional(),resolves:Wt.optional(),type:xB,status:yB,question:Wt,recommendation:Wt}).superRefine((e,t)=>{e.type===vB&&e.status!==_B&&t.addIssue({code:Y.custom,path:["status"],message:"master-confirmed decisions must be resolved"})}),wB=["planning","running","done"],SB=be(wB),YT=I({at:y().min(1),actor:y().min(1),action:y().min(1),target:y().optional(),reason:y().min(1),artifacts:Z(Wt).optional(),decision:bB.optional()}),kB=I({rejectCount:W().int().min(0),accepted:ge().default(!1),ordinal:W().int().min(1).optional(),overrideCount:W().int().min(0).optional()}),Kx=I({id:y().min(1),channelId:y().min(1),title:y(),masterSessionId:y().min(1),goal:y(),boundaries:y(),acceptanceCriteria:Z(y()),activity:Z(YT),lineMeta:Mr(kB),nextLineOrdinal:W().int().min(1).optional(),state:SB,createdAt:y().min(1),updatedAt:y().min(1)}),CB=I({lineId:y().min(1),dispatchId:y().min(1),workerSessionId:y().optional(),assignee:y().min(1),focus:y(),status:Ux,acceptance:Z(y()),rejectCount:W().int().min(0),accepted:ge(),ordinal:W().int().min(1).nullable()});I({channelId:y().min(1)});I({topicId:y().min(1).optional(),sessionId:y().min(1).optional()}).refine(e=>e.topicId!==void 0||e.sessionId!==void 0,{message:"either topicId or sessionId is required"});I({channelId:y().min(1),title:Wt.optional()});I({topicId:y().min(1),title:Wt.optional(),goal:Wt,boundaries:y(),acceptanceCriteria:Z(Wt).min(1)});I({topicId:y().min(1),action:Wt,target:Wt.optional(),reason:Wt,artifacts:Z(Wt).optional(),decision:YT.shape.decision});I({topicId:y().min(1),lineId:Wt,reason:Wt});I({topicId:y().min(1),lineId:Wt,reason:Wt,artifacts:Z(Wt).optional(),watcherVerdict:be(["pass","fail"]),overrideReason:Wt.optional()}).refine(e=>e.watcherVerdict!=="fail"||!!e.overrideReason,{message:"watcherVerdict=fail 时必须给 overrideReason(推翻 watcher 的理由)",path:["overrideReason"]});I({topicId:y().min(1),state:be(["done"])});I({topicId:y().min(1),title:Wt});I({topicId:y().min(1)});const EB=Kx.extend({lineCount:W().int().min(0)});I({topics:Z(EB)});I({topic:Kx,lines:Z(CB)});I({topicId:y().min(1),masterSessionId:y().min(1)});I({rejectCount:W().int().min(1),needsOwnerAttention:ge()});I({acceptedLines:W().int().min(1),totalLines:W().int().min(1),allAccepted:ge(),overrides:W().int().min(0),needsOwnerAttention:ge()});I({topic:Kx});I({ok:G(!0),removedMasterSessionId:y().min(1).nullable(),removedWorkerSessionIds:Z(y().min(1))});const NB=["ask","allow","deny"],XT=be(NB),TB=I({id:y().min(1),desc:y().min(1),action:XT});I({rules:Z(TB)});I({ruleId:y().min(1)});I({action:XT,desc:y(),source:y().min(1)});const IB=["created","review-requested"],QT=/^[A-Za-z0-9._-]+$/,vl=y().min(1).regex(QT),_l=y().min(1).regex(QT),yu=W().int().positive();I({role:be(IB)});I({owner:vl,repo:_l,number:yu});I({owner:vl,repo:_l,number:yu,expectedHeadSha:y().min(1)});I({owner:vl,repo:_l,number:yu,body:y().min(1)});I({owner:vl,repo:_l,number:yu,ready:ge()});I({owner:vl,repo:_l});I({owner:vl,repo:_l,number:yu,reviewers:Z(y().min(1)).min(1)});I({personaId:y().min(1)});I({personaId:y().min(1)});const PB=["expired","cancelled","access_denied","lark_protocol_error","cloud_unreachable","internal_error"],RB=be(PB);I({personaId:y().min(1),appId:y().min(1),appSecret:y().min(1),botName:y().min(1).optional()});const MB=I({chatId:y().min(1),chatName:y().optional(),lastActiveAt:W().int().optional()}),AB=I({state:be(["unbound","provisioning","bound","broken"]),appId:y().optional(),botName:y().optional(),brokenReason:y().optional(),qrUrl:y().optional(),errorReason:RB.optional(),groups:Z(MB),needsUpgrade:ge().optional(),upgradeQrUrl:y().optional()});AB.extend({personaId:y().min(1)});I({});I({onboardingCompletedAt:W()});const ap=["claude","codex","pi"];I({});I({tools:Z(I({id:be(ap),available:ge(),version:y().optional(),path:y().optional()}))});I({});const LB=I({tool:be(ap),cwd:y(),toolSessionId:y(),label:y().optional(),createdAt:y(),updatedAt:y(),turns:W()});I({candidates:Z(LB)});I({});I({registered:ge()});I({tool:be(ap)});const Tw=I({usedPercent:W(),windowDurationMins:W().optional(),resetsAt:W().optional()}).strict(),DB=lr("kind",[I({kind:G("claude"),loggedIn:ge(),authMethod:y().optional(),apiProvider:y().optional(),apiKeySource:y().optional(),email:y().optional(),orgName:y().optional(),subscriptionType:y().optional()}).strict(),I({kind:G("codex"),login:lr("type",[I({type:G("none")}).strict(),I({type:G("apiKey")}).strict(),I({type:G("chatgpt"),email:y(),planType:y()}).strict()]),provider:I({name:y(),baseUrl:y().optional()}).strict(),rateLimits:I({primary:Tw.optional(),secondary:Tw.optional()}).strict().optional()}).strict(),I({kind:G("pi"),providers:Z(I({id:y(),modelCount:W(),credential:be(["api_key","oauth"]).optional(),oauthExpiresAt:W().optional()}).strict())}).strict()]);I({tool:be(ap),installed:ge(),version:y().optional(),path:y().optional(),account:DB.optional(),error:y().optional(),modelsLoadedAt:W().optional()}).strict();I({apiKey:y().min(1)}).strict();I({ok:G(!0)}).strict();const jB=["tiny","small","medium","large"],OB=be(jB),BB=I({personaId:y(),label:y(),model:y().optional(),effort:y().optional(),public:ge(),iconKey:y().optional(),tool:y().optional(),size:y().optional(),taskConcurrency:W().int().positive().optional(),createdAt:W(),updatedAt:W(),cloud:I({gatewayUrl:y().min(1),personaId:y().min(1)}).strict().optional()}).strict(),zB=I({name:y().min(1),description:y().optional()}),$B=I({id:y().min(1)}),ZT=I({writableRoots:Z(y()).optional(),denyRead:Z(y()).optional(),network:ge().optional()}).strict(),FB=I({permissions:I({defaultMode:y().optional(),allow:Z(y()).optional(),deny:Z(y()).optional()}).optional(),sandbox:I({enabled:ge().optional(),autoAllowBashIfSandboxed:ge().optional(),allowUnsandboxedCommands:ge().optional(),excludedCommands:Z(y()).optional(),filesystem:I({denyRead:Z(y()).optional(),allowRead:Z(y()).optional(),denyWrite:Z(y()).optional(),allowWrite:Z(y()).optional()}).optional(),network:I({allowedDomains:Z(y()).optional(),allowLocalBinding:ge().optional()}).optional()}).optional()});BB.extend({personality:y().optional(),personalityLocal:y().optional(),personalityManaged:ge().optional(),skills:Z(zB).optional(),plugins:Z($B).optional(),sandboxSettings:FB.nullable().optional(),codexSandbox:ZT.nullable().optional()});I({slug:y().regex(/^[a-z0-9]+(-[a-z0-9]+)*$/).max(32),label:y().min(1),personality:y(),model:y().optional(),effort:y().optional(),tool:y().optional(),public:ge().optional(),iconKey:y().optional()}).strict();I({personaId:y().min(1)});I({personaId:y().min(1),patch:I({label:y().min(1).optional(),model:y().optional(),effort:y().optional(),tool:y().optional(),size:OB.optional(),personality:y().optional(),personalityLocal:y().optional(),public:ge().optional(),iconKey:y().nullable().optional(),codexSandbox:ZT.optional()}).strict()}).strict();const JT=["ready","session:info","session:status","session:event","session:deleted","session:rewound","session:cleared","session:queue","permission:request","session:question","session:question:cleared","pong","error","subscribed","unsubscribed","auth:ok","tunnel:ready","tunnel:exited","tunnel:unavailable","session:control","session:pty","contact:added","contact:pinned","contact:removed","contact:remote-access-updated","contact:note-updated","org-mesh:progress","channel:changed","inbox:event","friend:reverseTokenOffered","auth:login:done","auth:login:failed","larkBot:state"],eI=["idle","running","running-idle","stopped","error","observing"],HB=["task-notification","slash-command","local-command","system-reminder","skill-hint","meta-text","attachment-skills","attachment-deferred-tools","dispatch-task","dispatch-result"];function lp(e){return e==="dispatch-task"||e==="dispatch-result"}const UB=["builtin","global","project","plugin"],WB=["builtin","global","project","policy","plugin"],tI=be(["owner","guest"]);I({id:y().min(1),kind:tI,displayName:y(),feishuUnionId:y().optional()}).strict();const VB=I({did:y().min(1),displayName:y(),feishuUnionId:y().optional(),principal:tI}).strict(),qB=be(eI),KB=I({inputTokens:W().int().nonnegative(),outputTokens:W().int().nonnegative(),cacheReadTokens:W().int().nonnegative().optional(),cacheCreateTokens:W().int().nonnegative().optional()}),nI={gitBranch:y().optional(),resolvedModel:y().optional(),resolvedEffort:y().optional(),contextUsage:KB.optional(),contextWindowSize:W().int().positive().optional(),aiLabel:y().optional()},GB=I(nI),rI=I({value:y(),label:y(),description:y().optional()}),YB=I({id:y().min(1),label:y().min(1),description:y().optional(),contextWindowSize:W().int().positive(),default:ge().optional(),efforts:Z(rI).optional(),defaultEffort:y().optional(),group:y().optional()}),XB=I({id:y().min(1),label:y().min(1),description:y().optional()}),QB=I({name:y().min(1),type:be(["string","select","toggle"]),label:y().min(1),description:y().optional(),options:Z(rI).optional(),default:ji().optional(),scope:be(["core","tool-specific"])});I({tool:y().min(1),refresh:ge().optional()});const ZB=I({rewind:ge(),subagents:ge(),tui:ge(),observe:ge(),fileSharing:ge(),fork:ge()});I({tool:y().min(1),toolSessionIdLabel:y().optional(),models:Z(YB),permissionModes:Z(XB),configSchema:Z(QB),features:ZB});const JB=I({tool:y().min(1),pattern:y().min(1),createdAt:y().min(1).optional()});I({sessionId:y().min(1),cwd:y().min(1),tool:G("claude").or(y().min(1)).default("claude"),toolSessionId:y().optional(),label:y().optional(),model:y().optional(),permissionMode:y().optional(),effort:y().optional(),...nI,aiLabelGeneratedAt:y().optional(),permissionRules:Z(JB).optional(),pinnedAt:W().int().nonnegative().nullable().optional(),archivedAt:W().int().nonnegative().nullable().optional(),pinSortOrder:W().int().nullable().optional(),unreadAt:y().min(1).nullable().optional(),iconKey:y().optional(),forkedFromSessionId:y().min(1).optional(),ephemeral:ge().optional(),deployId:y().min(1).optional(),ownerPersonaId:y().min(1).optional(),projectPath:y().min(1).optional(),chatId:y().min(1).optional(),creatorPrincipalId:y().min(1).optional(),creatorDisplayName:y().min(1).optional(),creatorFeishuUnionId:y().min(1).optional(),originOwnerPrincipalId:y().min(1).optional(),originOwnerPersonaId:y().min(1).optional(),dispatchedFromSessionId:y().min(1).optional(),shiftFiredFromSessionId:y().min(1).optional(),larkChatId:y().min(1).optional(),larkChatName:y().min(1).optional(),larkChatType:be(["p2p","group"]).optional(),createdAt:y().min(1),updatedAt:y().min(1)});const Fn={seq:W().int().nonnegative().optional(),ts:y().optional(),uuid:y().optional()},ez=be(HB),tz=I({readCount:W().int().nonnegative().optional(),searchCount:W().int().nonnegative().optional(),bashCount:W().int().nonnegative().optional(),editFileCount:W().int().nonnegative().optional(),linesAdded:W().int().nonnegative().optional(),linesRemoved:W().int().nonnegative().optional(),otherToolCount:W().int().nonnegative().optional()}),nz=I({oldStart:W().int().nonnegative(),oldLines:W().int().nonnegative(),newStart:W().int().nonnegative(),newLines:W().int().nonnegative(),lines:Z(y())}),rz=I({agentId:y().optional(),agentType:y().optional(),status:y().optional(),prompt:y().optional(),filePath:y().optional(),structuredPatch:Z(nz).optional(),stats:I({durationMs:W().int().nonnegative().optional(),tokens:W().int().nonnegative().optional(),toolUseCount:W().int().nonnegative().optional(),toolStats:tz.optional()}).optional()}),iz=I({path:y(),content:y(),mtimeMs:W().optional()}),sz=I({label:y().min(1),description:y().optional()}),iI=I({question:y().min(1),multiSelect:ge(),options:Z(sz).min(1)}),oz=["completed","interrupted"];lr("kind",[I({...Fn,kind:G("session_init"),toolSessionId:y().optional()}),I({...Fn,kind:G("thinking"),text:y(),partialId:y().optional()}),I({...Fn,kind:G("text"),text:y(),partialId:y().optional()}),I({...Fn,kind:G("user_text"),text:y(),meta:ez.optional(),taskId:y().optional(),parentToolUseId:y().optional(),sender:VB.optional()}),I({...Fn,kind:G("tool_call"),toolUseId:y(),tool:y(),toolKind:y().optional(),input:ji()}),I({...Fn,kind:G("tool_result"),toolUseId:y(),output:ji().optional(),error:y().optional(),toolResultExtra:rz.optional(),sourceToolAssistantUUID:y().optional(),askQuestionAnswers:Mr(y(),y()).optional()}),I({...Fn,kind:G("attachment_memories"),memories:Z(iz)}),I({...Fn,kind:G("permission_request"),requestId:y(),tool:y(),input:ji(),toolUseId:y().optional()}),I({...Fn,kind:G("ask_user_question"),toolUseId:y(),questions:Z(iI)}),I({...Fn,kind:G("turn_end"),durationMs:W().int().nonnegative().optional(),reason:be(oz).optional()}),I({...Fn,kind:G("subagent_progress"),toolUseId:y(),agentId:y(),status:be(["started","running","completed","failed"]),description:y().optional(),lastToolName:y().optional(),prompt:y().optional(),stats:I({durationMs:W().int().nonnegative().optional(),tokens:W().int().nonnegative().optional(),toolUseCount:W().int().nonnegative().optional()}).optional()}),I({...Fn,kind:G("error"),message:y()}),I({...Fn,kind:G("meta_update"),patch:GB}),I({...Fn,kind:G("meta-text"),text:y(),metaSource:be(["cc","owner"]).optional()})]);I({cwd:y().min(1).optional(),tool:y().optional(),label:y().optional(),aiLabel:y().optional(),model:y().optional(),permissionMode:y().optional(),effort:y().optional(),iconKey:y().optional(),forkedFromSessionId:y().min(1).optional(),ephemeral:ge().optional(),ownerPersonaId:y().min(1).optional(),projectPath:y().min(1).optional()}).refine(e=>e.cwd!=null||e.ownerPersonaId!=null||e.projectPath!=null,{message:"cwd / ownerPersonaId / projectPath 至少传一个"});I({path:y().min(1),name:y().min(1),createdAt:y().datetime(),pinnedAt:W().optional()});I({path:y().min(1),pinnedAt:W().nullable()});I({path:y().min(1)});I({path:y().min(1).optional(),name:y().min(1).optional()}).refine(e=>e.path!=null||e.name!=null,{message:"path 与 name 至少给一个"});I({cwd:y().min(1),tool:y().min(1),toolSessionId:y().min(1),label:y().optional(),aiLabel:y().optional(),iconKey:y().optional(),createdAt:y().datetime(),updatedAt:y().datetime(),ownerPersonaId:y().min(1).optional()});I({originOnly:ge().optional(),ownerPersonaId:y().min(1).optional(),limit:W().int().positive().optional(),offset:W().int().nonnegative().optional()});I({sessionId:y().min(1)});I({sessionId:y().min(1),patch:I({label:y().optional(),model:y().optional(),permissionMode:y().optional(),effort:y().optional(),cwd:y().optional(),iconKey:y().optional(),ephemeral:G(!1).optional()})});I({id:y().min(1),text:y(),queuedAt:W(),senderDisplayName:y().optional()});I({sessionId:y().min(1),text:y(),queueWhileRunning:ge().optional()});I({sessionId:y().min(1),id:y().min(1).optional()});I({sessionId:y().min(1),userMessageId:y().min(1),dryRun:ge().optional()});I({canRewind:ge(),error:y().optional(),filesChanged:Z(y()).optional(),insertions:W().int().nonnegative().optional(),deletions:W().int().nonnegative().optional()});I({sessionId:y().min(1),userMessageId:y().min(1)});const az=I({oldStart:W().int().nonnegative(),oldLines:W().int().nonnegative(),newStart:W().int().nonnegative(),newLines:W().int().nonnegative(),lines:Z(y())}),lz=I({filePath:y().min(1),hunks:Z(az),insertions:W().int().nonnegative(),deletions:W().int().nonnegative(),status:be(["modified","added","deleted"]).optional()});I({canRewind:ge(),error:y().optional(),files:Z(lz),totalInsertions:W().int().nonnegative(),totalDeletions:W().int().nonnegative()});I({userMessageIds:Z(y())});I({sessionId:y().min(1),toolSessionId:y().min(1)});I({cwd:y().min(1),toolSessionId:y().min(1),messageUuid:y().min(1),targetCwd:y().min(1).optional()});I({forkedToolSessionId:y().min(1),forkedFilePath:y().min(1)});I({sessionId:y().min(1),toolSessionId:y().min(1),jsonlPath:y().optional()});I({sessionId:y().min(1),afterSeq:W().int().min(-1)});I({sessionId:y().min(1),permissionRequestId:y().min(1),allow:ge(),permanent:ge().optional(),pattern:y().optional()});I({projectPath:y().min(1)});I({sessionId:y().min(1),limit:W().int().positive().max(5e3).optional(),offset:W().int().nonnegative().optional(),slim:ge().optional()});I({cwd:y().min(1),toolSessionId:y().min(1)});I({cwd:y().min(1),toolSessionId:y().min(1),subagentId:y().min(1)});I({cwd:y().min(1).optional(),path:y().optional(),showHidden:ge().optional()});I({cwd:y().min(1),path:y().min(1)});I({cwd:y().min(1),tool:y().optional()});I({name:y().min(1),source:be(UB),path:y().optional(),description:y().optional(),plugin:y().optional()});const cz=I({name:y().min(1),source:be(WB),path:y().optional(),description:y().optional(),whenToUse:y().optional(),plugin:y().optional()});I({cwd:y().min(1),tool:y().optional()});I({agents:Z(cz)});I({sessionId:y().optional()});I({sessionId:y().min(1).optional()});I({sessionId:y().min(1),pinned:ge()});I({sessionId:y().min(1),archived:ge()});I({query:y().min(1),sessionIds:Z(y().min(1)),limit:W().int().positive().max(50).optional()});const uz=I({sessionId:y().min(1),snippet:y()});I({type:G("session:searchContent"),matches:Z(uz)});I({type:G("peerSession:upsert:ok")});I({sessionId:y().min(1)});I({type:G("peerSession:remove:ok")});I({orderedIds:Z(y().min(1)).min(1)});I({cwd:y().min(1)});I({isGitRoot:ge(),gitRoot:y().nullable()});I({cwd:y().min(1)});I({branch:y().nullable()});I({cwd:y().min(1)});I({branches:Z(y()),head:y().nullable()});const dz=I({cwd:y().min(1),updatedAt:y().min(1)});I({dirs:Z(dz)});I({type:G("session:question"),sessionId:y().min(1),toolUseId:y().min(1),requestId:y().min(1),questions:Z(iI).min(1)});I({type:G("session:question:cleared"),sessionId:y().min(1),toolUseId:y().min(1),answers:Mr(y(),y()).optional()});I({sessionId:y().min(1),toolUseId:y().min(1),answers:Mr(y(),y())});I({ok:G(!0)});I({sessionId:y().min(1),toolUseId:y().min(1)});I({ok:G(!0)});const sI=I({name:y().min(1),version:y().min(1),instanceId:y().min(1),deviceLabel:y().transform(e=>e.trim().slice(0,64)).optional()});I({type:G("auth"),token:y().min(1),scheme:G("bearer").optional(),clientInfo:sI.optional()});I({type:G("auth:ok"),version:y().min(1).optional(),protocolVersion:W().int().nonnegative().optional()});const hz=I({clientId:y().min(1),connectedAt:W().int().nonnegative(),self:ge(),clientInfo:sI.optional()});I({type:G("device:connections:ok"),connections:Z(hz)});I({type:G("tunnel:ready"),url:y().min(1),subdomain:y().min(1)});I({type:G("tunnel:exited"),code:W().int().nullable(),subdomain:y().nullable(),url:y().nullable()});I({type:G("tunnel:unavailable"),reason:y().min(1),failedAt:y().min(1)});const fz=I({sessionId:y().min(1),status:qB,freshSpawn:ge(),pendingPermissionRequestIds:Z(y().min(1)),pendingQuestionToolUseIds:Z(y().min(1))});I({type:G("info"),version:y(),protocolVersion:W(),hostname:y(),os:y(),tools:Z(I({id:y(),available:ge()})),runningSessions:Z(fz),tokenRole:be(A6).optional(),isLoopback:ge().optional(),httpBaseUrl:y().optional(),httpToken:y().optional(),daemonSource:be(["ota","packaged"]).optional(),globalCliVersion:y().nullable().optional()});I({});I({method:y().min(1).optional()});const pz=["allowed","conditional","denied"],mz=be(pz),gz=I({name:y().min(1),status:mz,description:y().min(1),args:Z(I({name:y(),required:ge()})).nullable(),argsSchema:Mr(ji()).optional(),reason:y().optional()});I({type:G("meta:methods"),methods:Z(gz)});const Iw=1,vz=I({usedBytes:W().int().nonnegative(),sizeBytes:W().int().positive(),measuredAt:W().int().nonnegative()}).strict();I({volume:vz.nullable()}).strict();const _z=["daemon","main","renderer"],xz=be(_z),yz=["debug","info","warn","error"],bz=be(yz);I({ts:W().int(),source:xz,level:bz,msg:y(),ownerPrincipalId:y(),deviceId:y(),appVersion:y(),daemonVersion:y().optional(),os:y(),meta_json:y().optional(),sessionId:y().optional()});I({v:G(1),visitorId:y().min(1),displayName:y(),provider:y(),iat:W(),exp:W()});const wz=I({visitorId:y(),displayName:y(),avatarUrl:y().optional(),provider:y(),firstSeen:W(),lastSeen:W()});I({visitors:Z(wz)});const Sz=/<system-reminder>此消息来自飞书群成员 (.+?)<\/system-reminder>\s*$/,oI=/<system-reminder>此消息来自 (owner|guest):(.+?)<\/system-reminder>\s*$/,kz="clawd-dispatch-task",Cz="clawd-dispatch-result",Pw=120;function Ez(e){if(!e)return[];const t=[];for(const n of["task","result"]){const r=n==="task"?kz:Cz,i=new RegExp(`<${r}\\b([^>]*)>([\\s\\S]*?)</${r}>`,"gi");for(let s=i.exec(e);s!==null;s=i.exec(e))t.push({at:s.index,block:Nz(n,s[1]??"",s[2]??"")})}return t.sort((n,r)=>n.at-r.at).map(n=>n.block)}function Nz(e,t,n){var c;const r=Lz(t),i=h0(Az(Tm(n,"detail")??n)),s=(c=Tm(n,"brief"))==null?void 0:c.trim(),o=s&&s.length>0?h0(s):Tz(i),a=r.round!==void 0?Number.parseInt(r.round,10):void 0,l=r.status;return{kind:e,dispatchId:r["dispatch-id"]??"",...r.from?{from:r.from}:{},...e==="task"&&a!==void 0&&Number.isFinite(a)?{round:a}:{},...e==="result"&&(l==="success"||l==="failure")?{status:l}:{},brief:o,briefIsDerived:!(s&&s.length>0),detail:i,filePaths:Mz(Tm(n,"files"))}}function Tz(e){const t=e.split(/\n\s*\n/).map(r=>r.trim()).find(r=>r.length>0);if(!t)return"";const n=t.replace(/\s+/g," ");return n.length>Pw?`${n.slice(0,Pw)}…`:n}const Iz="clawd-dispatch-task|clawd-dispatch-result|brief|detail|files",Pz=new RegExp(`<\\\\(\\\\*)(/?)(${Iz})\\b`,"g");function Rz(e){return h0(e)}function h0(e){return e.replace(Pz,"<$1$2$3")}function Tm(e,t){const n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`,"i").exec(e);return n?n[1]??"":null}function Mz(e){return e?e.split(`
|
|
96
|
-
`).map(t=>t.trim()).filter(t=>t.startsWith("- ")).map(t=>t.slice(2).trim()).filter(t=>t.length>0):[]}function Az(e){return e.replace(/^\n/,"").replace(/\n$/,"")}function Lz(e){const t={},n=/([a-z-]+)="([^"]*)"/gi;for(let r=n.exec(e);r!==null;r=n.exec(e))t[r[1]]=Dz(r[2]??"");return t}function Dz(e){return e.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}const f0="-cloud",jz=`codex${f0}`;function Oz(e){return e==="codex"||e===jz}function Bz(e){return typeof e=="string"&&e.length>f0.length&&e.endsWith(f0)}const zz=new Set(["localhost","127.0.0.1","0.0.0.0","::1"]);let Si=null;function $z(){if(Si!==null)return Si;if(typeof window>"u")return Si=!1,!1;if(zz.has(window.location.hostname)||window.location.protocol==="file:")return Si=!0,!0;if(new URLSearchParams(window.location.search).get("debug")==="1"){Si=!0;try{sessionStorage.setItem("debug","1")}catch{}}else try{Si=sessionStorage.getItem("debug")==="1"}catch{Si=!1}return Si}function Me(e,...t){$z()&&console.log(`[${e}][${new Date().toISOString()}]`,...t)}function hd(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 Fz=e=>{const t=[1e3,2e3,4e3,8e3,16e3,3e4];return t[Math.min(e,t.length-1)]},Hz=new Set(["auth:ok","pong","error"]),Rw=new Set(JT.filter(e=>!Hz.has(e)));let Uz=0;const Mw=()=>`r${++Uz}`;function Wz(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??Fz;let u=null,d=!1,f=0,p=null,m=null,v=null,w=null,_=!1,x="disconnected";const b=new Map,S=new Map;let C=null;const k=(O,E)=>{var H;O==="ready"&&(C=E),(H=S.get(O))==null||H.forEach(q=>{try{q(E)}catch{}})},N=O=>{x!==O&&(x=O,k("status",O))},T=(O,E)=>{const H=S.get(O)??new Set;if(H.add(E),S.set(O,H),O==="ready"&&C!==null)try{E(C)}catch{}return()=>H.delete(E)},z=()=>{m&&(clearInterval(m),m=null),v&&(clearTimeout(v),v=null),w&&(clearTimeout(w),w=null)},P=()=>{v&&clearTimeout(v),v=setTimeout(()=>{try{u==null||u.close(4e3,"pong watchdog")}catch{}},a)},B=()=>{m&&clearInterval(m),m=setInterval(()=>{(u==null?void 0:u.readyState)===1&&u.send(JSON.stringify({type:"ping",requestId:Mw()}))},o),P()},A=O=>{for(const[,E]of b)clearTimeout(E.timer),E.reject(new Error(O));b.clear()},R=[],M=()=>{if(R.length===0)return;const O=R.splice(0);for(const E of O)(u==null?void 0:u.readyState)===1&&!_?E.doSend():(clearTimeout(E.timer),E.reject(new Error("NOT_CONNECTED")))},D=O=>{if(R.length===0)return;const E=R.splice(0);for(const H of E)clearTimeout(H.timer),H.reject(new Error(O))},$=()=>{if(d)return;const O=c(f);if(O<0){D("connection closed: not reconnecting");return}k("daemon:reconnecting",{attempt:f+1,nextDelayMs:O,scheduledAt:Date.now()}),p&&clearTimeout(p),p=setTimeout(()=>{f+=1,j()},O)},F=O=>{P();const E=String(O.type??"");if(E==="auth:ok"){Me("daemon-client","auth:ok received → connected",{url:t}),w&&(clearTimeout(w),w=null),_=!1,f=0,N("connected"),k("daemon:connected",{url:t}),B(),M();return}if(E==="pong")return;if(E==="ready"){const q=Number(O.protocolVersion??-1);q!==Iw&&k("daemon:version-mismatch",{daemonProtocol:q,supportedProtocol:Iw}),k("ready",O);return}const H=O.requestId;if(typeof H=="string"&&b.has(H)){const q=b.get(H);if(b.delete(H),clearTimeout(q.timer),E==="error"){const L=String(O.code??"ERR"),re=String(O.message??"unknown");q.reject(new Error(`${L}: ${re}`))}else Rw.has(E)&&k(E,O),q.resolve(O);return}Rw.has(E)&&k(E,O)},j=()=>{p&&(clearTimeout(p),p=null),Me("daemon-client","connect →",{url:t,token:hd(n),attempt:f}),N("connecting");let O;try{O=new WebSocket(t)}catch(E){N("disconnected"),k("daemon:disconnected",{reason:(E==null?void 0:E.message)??"ws constructor failed"}),$();return}u=O,_=!!n,O.onopen=()=>{if(O!==u){Me("daemon-client","onopen → stale (replaced before opened), ignore");return}if(n){Me("daemon-client","onopen → send auth frame",{token:hd(n)});const E={type:"auth",token:n};r!=null&&r.principalId&&(E.selfPrincipalId=r.principalId),r!=null&&r.displayName&&(E.selfDisplayName=r.displayName),i&&(E.clientInfo=i),O.send(JSON.stringify(E)),w=setTimeout(()=>{try{O.close(4001,"auth handshake timeout")}catch{}},l)}else Me("daemon-client","onopen → no token, treat as connected (daemon authMode=none)"),f=0,N("connected"),k("daemon:connected",{url:t}),B(),M()},O.onclose=E=>{if(O!==u){Me("daemon-client","onclose → stale, ignore",{code:E.code,reason:E.reason});return}const H=E.reason||(E.code===1008?"auth failed":`close ${E.code}`);if(Me("daemon-client","onclose →",{code:E.code,reason:H,awaitingAuth:_,manualStop:d}),z(),A(`connection closed: ${H}`),u=null,E.code===4401?N("revoked"):N("disconnected"),k("daemon:disconnected",{reason:H}),E.code===1008||E.code===4401){D(`connection closed: ${H}`);return}d?D(`connection closed: ${H}`):$()},O.onerror=()=>{},O.onmessage=E=>{if(O!==u)return;let H;try{H=JSON.parse(String(E.data))}catch{return}F(H)}};return{start(){d=!1,f=0,j()},stop(){d=!0,p&&(clearTimeout(p),p=null),z();try{u==null||u.close(1e3,"shutdown")}catch{}u=null,A("shutdown"),D("shutdown"),N("disconnected")},switchProfile(O){Me("daemon-client","switchProfile →",{url:O.url,token:hd(O.authToken)},"prev:",{url:t,token:hd(n)}),t=O.url,n=O.authToken,O.selfIdentity!==void 0&&(r=O.selfIdentity),f=0,d=!0,p&&(clearTimeout(p),p=null),z(),A("switch profile"),D("switch profile");try{u==null||u.close(1e3,"switch profile")}catch{}u=null,d=!1,j()},request(O,E){return new Promise((H,q)=>{const L=Mw(),re=setTimeout(()=>{b.delete(L);const K=R.findIndex(me=>me.timer===re);K>=0&&R.splice(K,1),q(new Error(`request timeout: ${O}`))},s),se=()=>{b.set(L,{resolve:K=>H(K),reject:q,timer:re}),u.send(JSON.stringify({...E,type:O,requestId:L}))};(u==null?void 0:u.readyState)===1&&!_?se():d||u==null&&p==null?(clearTimeout(re),q(new Error("NOT_CONNECTED"))):R.push({doSend:se,reject:q,timer:re})})},on:T,get isOpen(){return(u==null?void 0:u.readyState)===1&&!_},get url(){return t},getStatus(){return x}}}function Vz(e){const t=e.trim(),n=t.indexOf("#");if(n<0)return{url:t};const r=t.slice(0,n),i=t.slice(n+1),o=new URLSearchParams(i).get("token")??void 0;return{url:r,token:o??void 0}}function qz(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 Kz(e){return e?{id:e.id,mode:e.mode,url:e.url,token:qz(e.token),name:e.name}:null}function fd(e){return e?Array.isArray(e)?e.map(Kz):{_notArray:typeof e,_value:e}:null}function Aw(e){return e==null?null:typeof e=="object"&&"value"in e?e.value:e}const Gz="ws://127.0.0.1:18790",Lw="daemon:profiles",Dw="daemon:active-profile-id";function Yz(){return Math.random().toString(36).slice(2,10)}function Xz(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 aI(e){let t={profiles:[],activeId:null},n=!1,r=null;const i=new Set,s=()=>{for(const l of i)l(t)},o=async()=>{Me("profile-store","persist →",fd(t.profiles),"active:",t.activeId),await e.kv.set(Lw,t.profiles),await e.kv.set(Dw,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(Lw);c=Aw(d)}catch{c=null}let u=null;try{const d=await e.kv.get(Dw);u=Aw(d)??null}catch{u=null}if(Me("profile-store","ensureLoaded read kv →","profiles:",fd(c),"activeId:",u),Array.isArray(c)&&c.length>0){const d=c.filter(Xz),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,Me("profile-store","ensureLoaded → use kv profiles",fd(d),"active:",f);return}t={profiles:[{id:"default",name:"本机",mode:"localhost",url:Gz}],activeId:"default"},Me("profile-store","ensureLoaded → fallback synthesized default (NO token)",fd(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 w;await a();let c=l.url,u=l.token;if(c&&c.includes("#")){const _=Vz(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??Yz(),m={id:p,name:((w=l.name)==null?void 0:w.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 jw="clawd.client-instance-id";let Qz={name:"clawd-web",version:"unknown"};function Zz(){let e=null;try{e=localStorage.getItem(jw),e||(e=crypto.randomUUID(),localStorage.setItem(jw,e))}catch{e=e??crypto.randomUUID()}return{...Qz,instanceId:e}}function Ow(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 lI=g.createContext(null);function Jz({host:e,children:t}){const[n,r]=g.useState(null),i=g.useMemo(()=>async()=>{const s=aI(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 Me("daemon-context","bootstrap → createDaemonClient",{id:a.id,url:a.url,token:Ow(a.token)}),{client:Wz({url:a.url,authToken:a.token,clientInfo:Zz()}),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){Me("daemon-context","subscribe → no active profile, skip switchProfile");return}Me("daemon-context","subscribe → switchProfile",{id:c.id,url:c.url,token:Ow(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(lI.Provider,{value:n,children:t}):null}function Yi(){const e=g.useContext(lI);if(!e)throw new Error("useDaemonClient must be used inside <DaemonProvider>");return e.client}function e$(){const e=Yi(),[t,n]=g.useState(void 0);return g.useEffect(()=>e.on("ready",i=>{const s=i.mode,o=s==="tui"?"tui":"sdk";Me("daemon-context","useDaemonMode ready.mode =",{rawMode:s,resolved:o}),n(o)}),[e]),t}function t$(){const e=Yi(),[t,n]=g.useState(void 0);return g.useEffect(()=>e.on("ready",i=>{const s=i;s.version!==void 0&&n(s.principalKind==="guest"?"guest":"owner")}),[e]),t}const cI=g.createContext(null);function n$({cache:e,children:t}){return g.createElement(cI.Provider,{value:e},t)}function $o(){const e=g.useContext(cI);if(!e)throw new Error("useCache must be used inside <CacheProvider>");return e}function Ui(e){const t=$o(),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 uI={actionsLevel:"none",httpBaseUrl:null,httpToken:null},dI=g.createContext(uI);function cp(){return g.useContext(dI)}function r$(e){return e!=null&&e.httpBaseUrl?{actionsLevel:e.tokenRole==="owner"?"owner":"none",httpBaseUrl:e.httpBaseUrl,httpToken:e.httpToken??null}:uI}function i$(){const e=Ui("daemon-info");return g.useMemo(()=>r$(e),[e])}function s$({children:e}){const t=i$();return Ge.createElement(dI.Provider,{value:t},e)}function o$(e,t,n){if(!e.httpBaseUrl)return null;const r=encodeURIComponent(n);return`${e.httpBaseUrl}/session/${encodeURIComponent(t.sessionId)}/files?path=${r}`}function a$(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 l$(){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 c$(e){return{request:(t,n)=>e.request(t,n),onFrame(t){const n=[];for(const r of JT)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}}}function hI(e){const t=(e??"claude")==="claude";return{rewind:t,subagents:t,tui:t,observe:t,fileSharing:t,fork:t}}const u$=e=>({tool:e,models:[{id:"",label:"未指定",contextWindowSize:2e5,default:!0}],permissionModes:[{id:"",label:"未指定"}],configSchema:[],features:hI(e)});function d$(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,()=>u$(r))}},o=e.onConnect(()=>{s()});return s(),()=>{i=!0,o()}}}}function h$(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 eu={sessionId:null,events:[],lastSeq:-1,pendingPermissions:[],status:"idle",pendingQuestions:{},queued:[]};function Im(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 fI(e,t,n){const r=n===void 0?e.sessionId:n;switch(t.type){case"session:change":return{...eu,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=Im(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:queue":return!r||t.sessionId!==r?e:{...e,queued:t.items};case"session:events":{if(!r||t.sessionId!==r)return e;const i=t.events.map(o=>o.event),s=i.reduce((o,a)=>Im(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)=>Im(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{...eu,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 f$="session/";function p$(e){return{sid:e.slice(f$.length)}}const m$=new Set(eI);function pI(e){return m$.has(e)}function Bw(e){return pI(e)?e:"idle"}function g$(e,t){return{start(n){const{sid:r}=p$(n);let i=!1,s=-1;const o=f=>{t(n,p=>fI(p??eu,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??[],w=m.latestSeq??-1;if(f==="baseline")o({type:"session:events",sessionId:r,events:v,latestSeq:w}),s=w;else{const _=m.bufferStartSeq??0,x=w<p||_>p+1;o({type:x?"session:events":"session:events:append",sessionId:r,events:v,latestSeq:w}),s=Math.max(s,w)}}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:Bw(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;Me("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(!pI(m.status)){Me("session-events","push session:status drop",{sid:r,status:m.status});return}Me("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;Me("session-events","push session:cleared",{sid:r}),o({type:"session:change",sessionId:r}),s=-1}else if(f==="session:queue"){const m=p;if(m.sessionId!==r)return;Me("session-events","push session:queue",{sid:r,count:m.items.length}),o({type:"session:queue",sessionId:m.sessionId,items:m.items})}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:Bw(v.status)}))})}),d=e.onConnect(()=>{c()});return e.isConnected&&c(),()=>{i=!0,u(),d(),e.request("session:unsubscribe",{sessionId:r}).catch(()=>{})}}}}const v$=new Set(["tunnel:ready","tunnel:exited","tunnel:unavailable"]);function _$(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=>{v$.has(a)&&i()});return i(),()=>{r=!0,s(),o()}}}}function x$(){return{start(){return()=>{}}}}function y$(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 b$(e){const t=c$(e),n=l$();let r=null;const i=(o,a)=>{r==null||r.setData(o,a)};n.register(/^capabilities\//,d$(t,i)),n.register(/^sessions$/,h$(t,i)),n.register(/^session\//,g$(t,i)),n.register(/^personas$/,y$(t,i)),n.register(/^persona-detail\//,x$()),n.register(/^daemon-info$/,_$(t,i));const s=a$({onFirstObserver:o=>{o&&n.activate(o)},onLastObserver:o=>{o&&n.deactivate(o)}});return r=s,{cache:s,channel:t}}class Gx{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)}projectList(){return this.client.request("project:list")}projectCreate(t){return this.client.request("project:create",{...t.path?{path:t.path}:{},...t.name?{name:t.name}:{}})}projectPatch(t){return this.client.request("project:patch",t)}projectReveal(t){return this.client.request("project:reveal",{path: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,r){return this.client.request("session:send",{sessionId:t,text:n,...r!=null&&r.queueWhileRunning?{queueWhileRunning:!0}:{}})}sessionDequeue(t,n){return this.client.request("session:dequeue",{sessionId:t,...n?{id: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})}searchSessionContent(t){return this.client.request("session:searchContent",t)}archiveSession(t,n){return this.client.request("session:archive",{sessionId:t,archived: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})}larkBotBindManual(t,n,r){return this.client.request("larkBot:bindManual",{personaId:t,appId:n,appSecret:r})}larkBotUnbind(t){return this.client.request("larkBot:unbind",{personaId:t})}larkBotStatus(t){return this.client.request("larkBot:status",{personaId:t})}toolsProbe(){return this.client.request("tools:probe",{})}sessionExternalScan(){return this.client.request("session:externalScan",{})}sessionImportExternal(t){return this.client.request("session:importExternal",t)}onboardingComplete(){return this.client.request("onboarding:complete",{})}onboardingIosInterest(){return this.client.request("onboarding:iosInterest",{})}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",n){return this.client.request("capabilities:get",{tool:t,...n!=null&&n.refresh?{refresh:!0}:{}})}engineStatus(t){return this.client.request("engine:status",{tool:t})}engineConnectPool(t){return this.client.request("engine:connectPool",{apiKey:t})}shiftList(){return this.client.request("shift:list")}deployGet(t){return this.client.request("deploy:get",{personaId:t})}deployScan(t,n){return this.client.request("deploy:scan",{personaId:t,...n?{scanBase:n}:{}})}deployPatch(t,n,r){return this.client.request("deploy:patch",{personaId:t,scanId:n,patch:r})}deployPutSecret(t,n,r,i){return this.client.request("deploy:putSecret",{personaId:t,scanId:n,name:r,values:i})}deployRerunJob(t,n){return this.client.request("deploy:rerunJob",{personaId:t,jobId:n})}deployRelease(t,n){return this.client.request("deploy:release",{personaId:t,scanId:n})}cloudConnectorsList(t){return this.client.request("cloud:connectors:list",{personaId:t})}cloudVolumeGet(){return this.client.request("cloud:volume:get",{})}cloudConnectorFill(t,n,r){return this.client.request("cloud:connectors:fill",{personaId:t,name:n,values:r})}channelList(){return this.client.request("channel:list")}channelCreate(t){return this.client.request("channel:create",t)}channelUpdate(t){return this.client.request("channel:update",t)}channelDelete(t){return this.client.request("channel:delete",t)}topicList(t){return this.client.request("topic:list",t)}topicGet(t){return this.client.request("topic:get",t)}topicCreate(t){return this.client.request("topic:create",t)}topicClose(t){return this.client.request("topic:close",t)}topicRename(t){return this.client.request("topic:rename",t)}topicDelete(t){return this.client.request("topic:delete",t)}personaDispatchList(t){return this.client.request("personaDispatch:list",t)}githubAuthGet(){return this.client.request("githubAuth:get")}githubAuthOauthStart(t){return this.client.request("githubAuth:oauthStart",t?{returnTo:t}:{})}githubAuthAuthorize(t){return this.client.request("githubAuth:authorize",{token:t})}githubStatus(){return this.client.request("github:status")}githubPrList(t){return this.client.request("github:prList",{role:t})}githubPrDetail(t){return this.client.request("github:prDetail",{...t})}githubPrMerge(t){return this.client.request("github:prMerge",{...t})}githubPrComment(t){return this.client.request("github:prComment",{...t})}githubPrSetReady(t){return this.client.request("github:prSetReady",{...t})}githubCollaborators(t){return this.client.request("github:collaborators",{...t})}githubPrRequestReviewers(t){return this.client.request("github:prRequestReviewers",{...t})}}function w$(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,daemonSource:c.daemonSource,globalCliVersion:c.globalCliVersion,onboardingCompletedAt:c.onboardingCompletedAt}))}),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,daemonSource:u.kind==="connected"?u.daemonSource:void 0,globalCliVersion:u.kind==="connected"?u.globalCliVersion:void 0,onboardingCompletedAt:u.kind==="connected"?u.onboardingCompletedAt: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 S$(e){const t=$o(),n=Ui(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 xl(){const e=Yi();return g.useMemo(()=>new Gx(e),[e])}function mI(e){return{personaId:e.personaId,label:e.label,model:e.model,effort:e.effort,tool:e.tool,...e.size!==void 0?{size:e.size}:{},public:e.public,createdAt:e.createdAt,updatedAt:e.updatedAt,...e.cloud?{cloud:e.cloud}:{}}}function gI(){const e=$o(),t=xl(),n=Ui("personas")??[],r=g.useMemo(()=>n.map(s=>mI(s)),[n]),i=g.useCallback(async()=>{const s=await t.personaList();e.setData("personas",()=>s.personas??[])},[t,e]);return{personas:r,raw:n,loaded:Ui("personas")!==void 0,refresh:i}}function vI(e){const{raw:t}=gI(),n=$o(),r=xl(),i=e?t.find(a=>a.personaId===e)??null:null,s=i?mI(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 k$(e){const t=xl(),n=$o(),r=e?`persona-detail/${e}`:"",i=Ui(r),s=g.useCallback(async()=>{const o={personality:"",personalityLocal:"",personalityManaged:!1,skills:[],plugins:[],sandboxSettings:null,codexSandbox:null};if(!e)return o;let a=null;try{a=await t.personaGet(e)}catch(c){Me("personas","personaGet failed → empty detail",{personaId:e,err:c}),a=null}const l=a?{personality:a.personality??"",personalityLocal:a.personalityLocal??"",personalityManaged:a.personalityManaged??!1,skills:a.skills??[],plugins:a.plugins??[],sandboxSettings:a.sandboxSettings??null,codexSandbox:a.codexSandbox??null}:o;return n.setData(r,()=>l),l},[t,n,e,r]);return g.useEffect(()=>{e&&s()},[e,s]),{personality:(i==null?void 0:i.personality)??"",personalityLocal:(i==null?void 0:i.personalityLocal)??"",personalityManaged:(i==null?void 0:i.personalityManaged)??!1,skills:(i==null?void 0:i.skills)??[],plugins:(i==null?void 0:i.plugins)??[],sandboxSettings:(i==null?void 0:i.sandboxSettings)??null,codexSandbox:(i==null?void 0:i.codexSandbox)??null,loaded:i!==void 0,refresh:s}}function _I(){const e=$o(),t=xl();return g.useCallback(async()=>{const n=await t.personaList();e.setData("personas",()=>n.personas??[])},[e,t])}function C$(){const e=xl(),t=_I();return g.useCallback(async(n,r)=>{const i=await e.personaUpdate(n,r);return await t(),i},[e,t])}function E$(){const e=xl(),t=_I();return g.useCallback(async n=>{await e.personaDelete(n),await t()},[e,t])}const zw="clawd:sidebar:tree-collapsed";function N$(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function T$(e){const t=N$(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 I$(){const e=Cx(),[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(zw);if(l)return;n(T$(c))}catch{}})(),()=>{l=!0}},[e]);const i=g.useCallback(l=>{e.kv.set(zw,[...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 Yx=g.createContext(null);function P$(){const e=g.useContext(Yx);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 cw=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 _O={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},xO={motionBase:!0,motionUnit:!0},yO={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},gT=(e,t,n)=>{const r=n.getDerivativeToken(e),{override:i}=t,s=cw(t,["override"]);let o=Object.assign(Object.assign({},r),{override:i});return o=mT(o),s&&Object.entries(s).forEach(([a,l])=>{const{theme:c}=l,u=cw(l,["theme"]);let d=u;c&&(d=gT(Object.assign(Object.assign({},o),u),{override:u},c)),o[a]=d}),o};function vT(){const{token:e,hashed:t,theme:n,override:r,cssVar:i}=Ge.useContext(fT),s=`${gO}-${t||""}`,o=n||hT,[a,l,c]=oj(o,[Xc,e],{salt:s,override:r,getComputedToken:gT,formatToken:mT,cssVar:i&&{prefix:i.prefix,key:i.key,unitless:_O,ignore:xO,preserve:yO}});return[o,c,t?l:"",a,i]}const bO=()=>({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"}}),wO=e=>({[`.${e}`]:Object.assign(Object.assign({},bO()),{[`.${e} .${e}-icon`]:{display:"block"}})}),SO=(e,t)=>{const[n,r]=vT();return Lj({token:r,hashId:"",path:["ant-design-icons",e],nonce:()=>t==null?void 0:t.nonce,layer:{name:"antd"}},()=>wO(e))},kO=Object.assign({},cl),{useId:uw}=kO,CO=()=>"",EO=typeof uw>"u"?CO:uw;function NO(e,t,n){var r;const i=e||{},s=i.inherit===!1||!t?Object.assign(Object.assign({},Uh),{hashed:(r=t==null?void 0:t.hashed)!==null&&r!==void 0?r:Uh.hashed,cssVar:t==null?void 0:t.cssVar}):t,o=EO();return DN(()=>{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!LD(c,d,!0)}))}var TO=["children"],_T=g.createContext({});function IO(e){var t=e.children,n=Pv(e,TO);return g.createElement(_T.Provider,{value:n},t)}var PO=function(e){ON(n,e);var t=zN(n);function n(){return fl(this,n),t.apply(this,arguments)}return pl(n,[{key:"render",value:function(){return this.props.children}}]),n}(g.Component);function RO(e){var t=g.useReducer(function(a){return a+1},0),n=et(t,2),r=n[1],i=g.useRef(e),s=Zv(function(){return i.current}),o=Zv(function(a){i.current=typeof a=="function"?a(i.current):a,r()});return[s,o]}var us="none",ad="appear",ld="enter",cd="leave",dw="none",Or="prepare",wa="start",Sa="active",Dx="end",xT="prepared";function hw(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 MO(e,t){var n={animationend:hw("Animation","AnimationEnd"),transitionend:hw("Transition","TransitionEnd")};return e&&("AnimationEvent"in t||delete n.animationend.animation,"TransitionEvent"in t||delete n.transitionend.transition),n}var AO=MO(Gi(),typeof window<"u"?window:{}),yT={};if(Gi()){var LO=document.createElement("div");yT=LO.style}var ud={};function bT(e){if(ud[e])return ud[e];var t=AO[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 yT)return ud[e]=t[s],ud[e]}return""}var wT=bT("animationend"),ST=bT("transitionend"),kT=!!(wT&&ST),fw=wT||"animationend",pw=ST||"transitionend";function mw(e,t){if(!e)return null;if(Pt(e)==="object"){var n=t.replace(/-\w/g,function(r){return r[1].toUpperCase()});return e[n]}return"".concat(e,"-").concat(t)}const DO=function(e){var t=g.useRef();function n(i){i&&(i.removeEventListener(pw,e),i.removeEventListener(fw,e))}function r(i){t.current&&t.current!==i&&n(t.current),i&&i!==t.current&&(i.addEventListener(pw,e),i.addEventListener(fw,e),t.current=i)}return g.useEffect(function(){return function(){n(t.current)}},[]),[r,n]};var CT=Gi()?g.useLayoutEffect:g.useEffect;const jO=function(){var e=g.useRef(null);function t(){Tv.cancel(e.current)}function n(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;t();var s=Tv(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 OO=[Or,wa,Sa,Dx],BO=[Or,xT],ET=!1,zO=!0;function NT(e){return e===Sa||e===Dx}const $O=function(e,t,n){var r=Jv(dw),i=et(r,2),s=i[0],o=i[1],a=jO(),l=et(a,2),c=l[0],u=l[1];function d(){o(Or,!0)}var f=t?BO:OO;return CT(function(){if(s!==dw&&s!==Dx){var p=f.indexOf(s),m=f[p+1],v=n(s);v===ET?o(m,!0):m&&c(function(w){function _(){w.isCanceled()||o(m,!0)}v===!0?_():Promise.resolve(v).then(_)})}},[e,s]),g.useEffect(function(){return function(){u()}},[]),[d,s]};function FO(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,w=r.onEnterStart,_=r.onLeaveStart,x=r.onAppearActive,b=r.onEnterActive,S=r.onLeaveActive,C=r.onAppearEnd,k=r.onEnterEnd,N=r.onLeaveEnd,T=r.onVisibleChanged,z=Jv(),P=et(z,2),B=P[0],A=P[1],R=RO(us),M=et(R,2),D=M[0],$=M[1],F=Jv(null),j=et(F,2),O=j[0],E=j[1],H=D(),q=g.useRef(!1),L=g.useRef(null);function re(){return n()}var se=g.useRef(!1);function K(){$(us),E(null,!0)}var ge=Zv(function(qe){var ot=D();if(ot!==us){var Et=re();if(!(qe&&!qe.deadline&&qe.target!==Et)){var _n=se.current,Tn;ot===ad&&_n?Tn=C==null?void 0:C(Et,qe):ot===ld&&_n?Tn=k==null?void 0:k(Et,qe):ot===cd&&_n&&(Tn=N==null?void 0:N(Et,qe)),_n&&Tn!==!1&&K()}}}),Re=DO(ge),ce=et(Re,1),Le=ce[0],Oe=function(ot){switch(ot){case ad:return Ce(Ce(Ce({},Or,f),wa,v),Sa,x);case ld:return Ce(Ce(Ce({},Or,p),wa,w),Sa,b);case cd:return Ce(Ce(Ce({},Or,m),wa,_),Sa,S);default:return{}}},Ae=g.useMemo(function(){return Oe(H)},[H]),_e=$O(H,!e,function(qe){if(qe===Or){var ot=Ae[Or];return ot?ot(re()):ET}if(tt in Ae){var Et;E(((Et=Ae[tt])===null||Et===void 0?void 0:Et.call(Ae,re(),null))||null)}return tt===Sa&&H!==us&&(Le(re()),u>0&&(clearTimeout(L.current),L.current=setTimeout(function(){ge({deadline:!0})},u))),tt===xT&&K(),zO}),Qe=et(_e,2),kt=Qe[0],tt=Qe[1],At=NT(tt);se.current=At;var Jt=g.useRef(null);CT(function(){if(!(q.current&&Jt.current===t)){A(t);var qe=q.current;q.current=!0;var ot;!qe&&t&&a&&(ot=ad),qe&&t&&s&&(ot=ld),(qe&&!t&&c||!qe&&d&&!t&&c)&&(ot=cd);var Et=Oe(ot);ot&&(e||Et[Or])?($(ot),kt()):$(us),Jt.current=t}},[t]),g.useEffect(function(){(H===ad&&!a||H===ld&&!s||H===cd&&!c)&&$(us)},[a,s,c]),g.useEffect(function(){return function(){q.current=!1,clearTimeout(L.current)}},[]);var nt=g.useRef(!1);g.useEffect(function(){B&&(nt.current=!0),B!==void 0&&H===us&&((nt.current||B)&&(T==null||T(B)),nt.current=!0)},[B,H]);var Ct=O;return Ae[Or]&&tt===wa&&(Ct=He({transition:"none"},Ct)),[H,tt,Ct,B??t]}function HO(e){var t=e;Pt(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(_T),w=v.motion,_=n(i,w),x=g.useRef(),b=g.useRef();function S(){try{return x.current instanceof HTMLElement?x.current:vD(b.current)}catch{return null}}var C=FO(_,a,S,i),k=et(C,4),N=k[0],T=k[1],z=k[2],P=k[3],B=g.useRef(P);P&&(B.current=!0);var A=g.useCallback(function(j){x.current=j,bD(s,j)},[s]),R,M=He(He({},m),{},{visible:a});if(!d)R=null;else if(N===us)P?R=d(He({},M),A):!c&&B.current&&p?R=d(He(He({},M),{},{className:p}),A):u||!c&&!p?R=d(He(He({},M),{},{style:{display:"none"}}),A):R=null;else{var D;T===Or?D="prepare":NT(T)?D="active":T===wa&&(D="start");var $=mw(f,"".concat(N,"-").concat(D));R=d(He(He({},M),{},{className:sD(mw(f,N),Ce(Ce({},$,$&&D),f,typeof f=="string")),style:z}),A)}if(g.isValidElement(R)&&wD(R)){var F=SD(R);F||(R=g.cloneElement(R,{ref:A}))}return g.createElement(PO,{ref:b},R)});return r.displayName="CSSMotion",r}const UO=HO(kT);var e0="add",t0="keep",n0="remove",Em="removed";function WO(e){var t;return e&&Pt(e)==="object"&&"key"in e?t=e:t={key:e},He(He({},t),{},{key:String(t.key)})}function r0(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return e.map(WO)}function VO(){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=r0(e),o=r0(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 He(He({},p),{},{status:e0})})),r=d),n.push(He(He({},f),{},{status:t0})),r+=1,u=!0;break}}u||n.push(He(He({},c),{},{status:n0}))}),r<i&&(n=n.concat(o.slice(r).map(function(c){return He(He({},c),{},{status:e0})})));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!==n0}),n.forEach(function(u){u.key===c&&(u.status=t0)})}),n}var qO=["component","children","onVisibleChanged","onAllRemoved"],KO=["status"],GO=["eventProps","visible","children","motionName","motionAppear","motionEnter","motionLeave","motionLeaveImmediately","motionDeadline","removeOnLeave","leavedClassName","onAppearPrepare","onAppearStart","onAppearActive","onAppearEnd","onEnterStart","onEnterActive","onEnterEnd","onLeaveStart","onLeaveActive","onLeaveEnd"];function YO(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:UO,n=function(r){ON(s,r);var i=zN(s);function s(){var o;fl(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)),Ce(Ev(o),"state",{keyEntities:[]}),Ce(Ev(o),"removeKey",function(u){o.setState(function(d){var f=d.keyEntities.map(function(p){return p.key!==u?p:He(He({},p),{},{status:Em})});return{keyEntities:f}},function(){var d=o.state.keyEntities,f=d.filter(function(p){var m=p.status;return m!==Em}).length;f===0&&o.props.onAllRemoved&&o.props.onAllRemoved()})}),o}return pl(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=Pv(c,qO),m=u||g.Fragment,v={};return GO.forEach(function(w){v[w]=p[w],delete p[w]}),delete p.keys,g.createElement(m,p,l.map(function(w,_){var x=w.status,b=Pv(w,KO),S=x===e0||x===t0;return g.createElement(t,$h({},v,{key:b.key,visible:S,eventProps:b,onVisibleChanged:function(k){f==null||f(k,{key:b.key}),k||a.removeKey(b.key)}}),function(C,k){return d(He(He({},C),{},{index:_}),k)})}))}}],[{key:"getDerivedStateFromProps",value:function(a,l){var c=a.keys,u=l.keyEntities,d=r0(c),f=VO(u,d);return{keyEntities:f.filter(function(p){var m=u.find(function(v){var w=v.key;return p.key===w});return!(m&&m.status===Em&&p.status===n0)})}}}]),s}(g.Component);return Ce(n,"defaultProps",{component:"div"}),n}YO(kT);const gw=g.createContext(!0);function XO(e){const t=g.useContext(gw),{children:n}=e,[,r]=vT(),{motion:i}=r,s=g.useRef(!1);return s.current||(s.current=t!==i),s.current?g.createElement(gw.Provider,{value:i},g.createElement(IO,{motion:i},n)):n}const QO=()=>null;var ZO=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 JO=["getTargetContainer","getPopupContainer","renderEmpty","input","pagination","form","select","button"];let TT;function e6(){return TT||Xv}function t6(e){return Object.keys(e).some(t=>t.endsWith("Color"))}const n6=e=>{const{prefixCls:t,iconPrefixCls:n,theme:r,holderRender:i}=e;t!==void 0&&(TT=t),r&&t6(r)&&uO(e6(),r)},r6=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:w,parentContext:_,iconPrefixCls:x,theme:b,componentDisabled:S,segmented:C,statistic:k,spin:N,calendar:T,carousel:z,cascader:P,collapse:B,typography:A,checkbox:R,descriptions:M,divider:D,drawer:$,skeleton:F,steps:j,image:O,layout:E,list:H,mentions:q,modal:L,progress:re,result:se,slider:K,breadcrumb:ge,menu:Re,pagination:ce,input:Le,textArea:Oe,empty:Ae,badge:_e,radio:Qe,rate:kt,switch:tt,transfer:At,avatar:Jt,message:nt,tag:Ct,table:qe,card:ot,tabs:Et,timeline:_n,timePicker:Tn,upload:U,notification:J,tree:xe,colorPicker:Ie,datePicker:Fe,rangePicker:Nt,flex:en,wave:tn,dropdown:nn,warning:oe,tour:ye,tooltip:rt,popover:mt,popconfirm:fr,floatButton:ae,floatButtonGroup:Je,variant:hn,inputNumber:Ys,treeSelect:Nl}=e,Yo=g.useCallback((Lt,Dt)=>{const{prefixCls:In}=e;if(Dt)return Dt;const pr=In||_.getPrefixCls("");return Lt?`${pr}-${Lt}`:pr},[_.getPrefixCls,e.prefixCls]),ts=x||_.iconPrefixCls||pT,Xs=n||_.csp;SO(ts,Xs);const Tl=NO(b,_.theme,{prefixCls:Yo("")}),Xo={csp:Xs,autoInsertSpaceInButton:r,alert:i,anchor:s,locale:a||w,direction:c,space:u,splitter:d,virtual:f,popupMatchSelectWidth:m??p,popupOverflow:v,getPrefixCls:Yo,iconPrefixCls:ts,theme:Tl,segmented:C,statistic:k,spin:N,calendar:T,carousel:z,cascader:P,collapse:B,typography:A,checkbox:R,descriptions:M,divider:D,drawer:$,skeleton:F,steps:j,image:O,input:Le,textArea:Oe,layout:E,list:H,mentions:q,modal:L,progress:re,result:se,slider:K,breadcrumb:ge,menu:Re,pagination:ce,empty:Ae,badge:_e,radio:Qe,rate:kt,switch:tt,transfer:At,avatar:Jt,message:nt,tag:Ct,table:qe,card:ot,tabs:Et,timeline:_n,timePicker:Tn,upload:U,notification:J,tree:xe,colorPicker:Ie,datePicker:Fe,rangePicker:Nt,flex:en,wave:tn,dropdown:nn,warning:oe,tour:ye,tooltip:rt,popover:mt,popconfirm:fr,floatButton:ae,floatButtonGroup:Je,variant:hn,inputNumber:Ys,treeSelect:Nl},bi=Object.assign({},_);Object.keys(Xo).forEach(Lt=>{Xo[Lt]!==void 0&&(bi[Lt]=Xo[Lt])}),JO.forEach(Lt=>{const Dt=e[Lt];Dt&&(bi[Lt]=Dt)}),typeof r<"u"&&(bi.button=Object.assign({autoInsertSpace:r},bi.button));const ns=DN(()=>bi,bi,(Lt,Dt)=>{const In=Object.keys(Lt),pr=Object.keys(Dt);return In.length!==pr.length||In.some(Zs=>Lt[Zs]!==Dt[Zs])}),{layer:Il}=g.useContext(np),Pl=g.useMemo(()=>({prefixCls:ts,csp:Xs,layer:Il?"antd":void 0}),[ts,Xs,Il]);let Vt=g.createElement(g.Fragment,null,g.createElement(QO,{dropdownMatchSelectWidth:p}),t);const Qs=g.useMemo(()=>{var Lt,Dt,In,pr;return Hj(((Lt=sp.Form)===null||Lt===void 0?void 0:Lt.defaultValidateMessages)||{},((In=(Dt=ns.locale)===null||Dt===void 0?void 0:Dt.Form)===null||In===void 0?void 0:In.defaultValidateMessages)||{},((pr=ns.form)===null||pr===void 0?void 0:pr.validateMessages)||{},(o==null?void 0:o.validateMessages)||{})},[ns,o==null?void 0:o.validateMessages]);Object.keys(Qs).length>0&&(Vt=g.createElement(Wj.Provider,{value:Qs},Vt)),a&&(Vt=g.createElement(Kj,{locale:a,_ANT_MARK__:qj},Vt)),Vt=g.createElement(Bj.Provider,{value:Pl},Vt),l&&(Vt=g.createElement(hO,{size:l},Vt)),Vt=g.createElement(XO,null,Vt);const Wp=g.useMemo(()=>{const Lt=Tl||{},{algorithm:Dt,token:In,components:pr,cssVar:Zs}=Lt,ee=ZO(Lt,["algorithm","token","components","cssVar"]),we=Dt&&(!Array.isArray(Dt)||Dt.length>0)?Mv(Dt):hT,ke={};Object.entries(pr||{}).forEach(([Gr,$u])=>{const wi=Object.assign({},$u);"algorithm"in wi&&(wi.algorithm===!0?wi.theme=we:(Array.isArray(wi.algorithm)||typeof wi.algorithm=="function")&&(wi.theme=Mv(wi.algorithm)),delete wi.algorithm),ke[Gr]=wi});const Ze=Object.assign(Object.assign({},Xc),In);return Object.assign(Object.assign({},ee),{theme:we,token:Ze,components:ke,override:Object.assign({override:Ze},ke),cssVar:Zs})},[Tl]);return b&&(Vt=g.createElement(fT.Provider,{value:Wp},Vt)),ns.warning&&(Vt=g.createElement(Uj.Provider,{value:ns.warning},Vt)),S!==void 0&&(Vt=g.createElement(dO,{disabled:S},Vt)),g.createElement(op.Provider,{value:ns},Vt)},gl=e=>{const t=g.useContext(op),n=g.useContext(lT);return g.createElement(r6,Object.assign({parentContext:t,legacyLocale:n},e))};gl.ConfigContext=op;gl.SizeContext=Qc;gl.config=n6;gl.useConfig=fO;Object.defineProperty(gl,"SizeContext",{get:()=>Qc});const gr=(e,t)=>new bt(e).setA(t).toRgbString(),Jo=(e,t)=>new bt(e).lighten(t).toHexString(),i6=e=>{const t=Ga(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]}},s6=(e,t)=>{const n=e||"#000",r=t||"#fff";return{colorBgBase:n,colorTextBase:r,colorText:gr(r,.85),colorTextSecondary:gr(r,.65),colorTextTertiary:gr(r,.45),colorTextQuaternary:gr(r,.25),colorFill:gr(r,.18),colorFillSecondary:gr(r,.12),colorFillTertiary:gr(r,.08),colorFillQuaternary:gr(r,.04),colorBgSolid:gr(r,.95),colorBgSolidHover:gr(r,1),colorBgSolidActive:gr(r,.9),colorBgElevated:Jo(n,12),colorBgContainer:Jo(n,8),colorBgLayout:Jo(n,0),colorBgSpotlight:Jo(n,26),colorBgBlur:gr(r,.04),colorBorder:Jo(n,26),colorBorderSecondary:Jo(n,19)}},o6=(e,t)=>{const n=Object.keys(Ax).map(s=>{const o=Ga(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??Lx(e),i=dT(e,{generateColorPalettes:i6,generateNeutralColorPalettes:s6});return Object.assign(Object.assign(Object.assign(Object.assign({},r),n),i),{colorPrimaryBg:i.colorPrimaryBorder,colorPrimaryBgHover:i.colorPrimaryBorderHover})},vw={defaultSeed:Uh.token,defaultAlgorithm:Lx,darkAlgorithm:o6};function _w({children:e}){const t=Cx(),[n,r]=g.useState(t.theme);return g.useEffect(()=>t.onThemeChange(r),[t]),h.jsx(gl,{theme:{algorithm:n.mode==="dark"?vw.darkAlgorithm:vw.defaultAlgorithm,token:{colorPrimary:n.colorPrimary,colorBgContainer:n.colorBgContainer,colorText:n.colorText,colorBorder:n.colorBorder}},children:e})}var Ye;(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})(Ye||(Ye={}));var xw;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(xw||(xw={}));const he=Ye.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ps=e=>{switch(typeof e){case"undefined":return he.undefined;case"string":return he.string;case"number":return Number.isNaN(e)?he.nan:he.number;case"boolean":return he.boolean;case"function":return he.function;case"bigint":return he.bigint;case"symbol":return he.symbol;case"object":return Array.isArray(e)?he.array:e===null?he.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?he.promise:typeof Map<"u"&&e instanceof Map?he.map:typeof Set<"u"&&e instanceof Set?he.set:typeof Date<"u"&&e instanceof Date?he.date:he.object;default:return he.unknown}},Y=Ye.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 Hi 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 Hi))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ye.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()}}Hi.create=e=>new Hi(e);const i0=(e,t)=>{let n;switch(e.code){case Y.invalid_type:e.received===he.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case Y.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Ye.jsonStringifyReplacer)}`;break;case Y.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ye.joinValues(e.keys,", ")}`;break;case Y.invalid_union:n="Invalid input";break;case Y.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ye.joinValues(e.options)}`;break;case Y.invalid_enum_value:n=`Invalid enum value. Expected ${Ye.joinValues(e.options)}, received '${e.received}'`;break;case Y.invalid_arguments:n="Invalid function arguments";break;case Y.invalid_return_type:n="Invalid function return type";break;case Y.invalid_date:n="Invalid date";break;case Y.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}"`:Ye.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case Y.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 Y.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 Y.custom:n="Invalid input";break;case Y.invalid_intersection_types:n="Intersection results could not be merged";break;case Y.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case Y.not_finite:n="Number must be finite";break;default:n=t.defaultError,Ye.assertNever(e)}return{message:n}};let a6=i0;function l6(){return a6}const c6=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=l6(),r=c6({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===i0?void 0:i0].filter(i=>!!i)});e.common.issues.push(r)}class Dn{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 Ne;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 Dn.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 Ne;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 Ne=Object.freeze({status:"aborted"}),nc=e=>({status:"dirty",value:e}),Rr=e=>({status:"valid",value:e}),yw=e=>e.status==="aborted",bw=e=>e.status==="dirty",Ya=e=>e.status==="valid",Wh=e=>typeof Promise<"u"&&e instanceof Promise;var ve;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(ve||(ve={}));class pi{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 ww=(e,t)=>{if(Ya(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 Hi(e.common.issues);return this._error=n,this._error}}};function je(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 Ve{get description(){return this._def.description}_getType(t){return ps(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:ps(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Dn,ctx:{common:t.parent.common,data:t.data,parsedType:ps(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(Wh(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:ps(t)},i=this._parseSync({data:t,path:r.path,parent:r});return ww(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:ps(t)};if(!this["~standard"].async)try{const s=this._parseSync({data:t,path:[],parent:n});return Ya(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=>Ya(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:ps(t)},i=this._parse({data:t,path:r.path,parent:r}),s=await(Wh(i)?i:Promise.resolve(i));return ww(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:Y.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 Os({schema:this,typeName:Te.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 Di.create(this,this._def)}nullable(){return To.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return di.create(this)}promise(){return Xh.create(this,this._def)}or(t){return qh.create([this,t],this._def)}and(t){return Kh.create(this,t,this._def)}transform(t){return new Os({...je(this._def),schema:this,typeName:Te.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Qh({...je(this._def),innerType:this,defaultValue:n,typeName:Te.ZodDefault})}brand(){return new MT({typeName:Te.ZodBranded,type:this,...je(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new Zh({...je(this._def),innerType:this,catchValue:n,typeName:Te.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return Ox.create(this,t)}readonly(){return Jh.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const u6=/^c[^\s-]{8,}$/i,d6=/^[0-9a-z]+$/,h6=/^[0-9A-HJKMNP-TV-Z]{26}$/i,f6=/^[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,p6=/^[a-z0-9_-]{21}$/i,m6=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,g6=/^[-+]?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)?)??$/,v6=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,_6="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Nm;const x6=/^(?:(?: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])$/,y6=/^(?:(?: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])$/,b6=/^(([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]))$/,w6=/^(([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])$/,S6=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,k6=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,IT="((\\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])))",C6=new RegExp(`^${IT}$`);function PT(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 E6(e){return new RegExp(`^${PT(e)}$`)}function N6(e){let t=`${IT}T${PT(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 T6(e,t){return!!((t==="v4"||!t)&&x6.test(e)||(t==="v6"||!t)&&b6.test(e))}function I6(e,t){if(!m6.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 P6(e,t){return!!((t==="v4"||!t)&&y6.test(e)||(t==="v6"||!t)&&w6.test(e))}class Ri extends Ve{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==he.string){const s=this._getOrReturnCtx(t);return ie(s,{code:Y.invalid_type,expected:he.string,received:s.parsedType}),Ne}const r=new Dn;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:Y.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:Y.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:Y.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&ie(i,{code:Y.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")v6.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"email",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Nm||(Nm=new RegExp(_6,"u")),Nm.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"emoji",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")f6.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"uuid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")p6.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"nanoid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")u6.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"cuid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")d6.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"cuid2",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")h6.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"ulid",code:Y.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:Y.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:Y.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:Y.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:Y.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:Y.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?N6(s).test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?C6.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?E6(s).test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?g6.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"duration",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?T6(t.data,s.version)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"ip",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?I6(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"jwt",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?P6(t.data,s.version)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"cidr",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?S6.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"base64",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?k6.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"base64url",code:Y.invalid_string,message:s.message}),r.dirty()):Ye.assertNever(s);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:Y.invalid_string,...ve.errToObj(r)})}_addCheck(t){return new Ri({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...ve.errToObj(t)})}url(t){return this._addCheck({kind:"url",...ve.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...ve.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...ve.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...ve.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...ve.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...ve.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...ve.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...ve.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...ve.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...ve.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...ve.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...ve.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,...ve.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,...ve.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...ve.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...ve.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...ve.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...ve.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...ve.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...ve.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...ve.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...ve.errToObj(n)})}nonempty(t){return this.min(1,ve.errToObj(t))}trim(){return new Ri({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ri({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ri({...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}}Ri.create=e=>new Ri({checks:[],typeName:Te.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...je(e)});function R6(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 Xa extends Ve{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)!==he.number){const s=this._getOrReturnCtx(t);return ie(s,{code:Y.invalid_type,expected:he.number,received:s.parsedType}),Ne}let r;const i=new Dn;for(const s of this._def.checks)s.kind==="int"?Ye.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),ie(r,{code:Y.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:Y.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:Y.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?R6(t.data,s.value)!==0&&(r=this._getOrReturnCtx(t,r),ie(r,{code:Y.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:Y.not_finite,message:s.message}),i.dirty()):Ye.assertNever(s);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,ve.toString(n))}gt(t,n){return this.setLimit("min",t,!1,ve.toString(n))}lte(t,n){return this.setLimit("max",t,!0,ve.toString(n))}lt(t,n){return this.setLimit("max",t,!1,ve.toString(n))}setLimit(t,n,r,i){return new Xa({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ve.toString(i)}]})}_addCheck(t){return new Xa({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:ve.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ve.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ve.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ve.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ve.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:ve.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:ve.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ve.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ve.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"&&Ye.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)}}Xa.create=e=>new Xa({checks:[],typeName:Te.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...je(e)});class Zc extends Ve{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)!==he.bigint)return this._getInvalidInput(t);let r;const i=new Dn;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:Y.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:Y.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:Y.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Ye.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return ie(n,{code:Y.invalid_type,expected:he.bigint,received:n.parsedType}),Ne}gte(t,n){return this.setLimit("min",t,!0,ve.toString(n))}gt(t,n){return this.setLimit("min",t,!1,ve.toString(n))}lte(t,n){return this.setLimit("max",t,!0,ve.toString(n))}lt(t,n){return this.setLimit("max",t,!1,ve.toString(n))}setLimit(t,n,r,i){return new Zc({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ve.toString(i)}]})}_addCheck(t){return new Zc({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ve.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ve.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ve.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ve.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:ve.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}}Zc.create=e=>new Zc({checks:[],typeName:Te.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...je(e)});class s0 extends Ve{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==he.boolean){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:he.boolean,received:r.parsedType}),Ne}return Rr(t.data)}}s0.create=e=>new s0({typeName:Te.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...je(e)});class Vh extends Ve{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==he.date){const s=this._getOrReturnCtx(t);return ie(s,{code:Y.invalid_type,expected:he.date,received:s.parsedType}),Ne}if(Number.isNaN(t.data.getTime())){const s=this._getOrReturnCtx(t);return ie(s,{code:Y.invalid_date}),Ne}const r=new Dn;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:Y.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:Y.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):Ye.assertNever(s);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Vh({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:ve.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:ve.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}}Vh.create=e=>new Vh({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:Te.ZodDate,...je(e)});class Sw extends Ve{_parse(t){if(this._getType(t)!==he.symbol){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:he.symbol,received:r.parsedType}),Ne}return Rr(t.data)}}Sw.create=e=>new Sw({typeName:Te.ZodSymbol,...je(e)});class o0 extends Ve{_parse(t){if(this._getType(t)!==he.undefined){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:he.undefined,received:r.parsedType}),Ne}return Rr(t.data)}}o0.create=e=>new o0({typeName:Te.ZodUndefined,...je(e)});class a0 extends Ve{_parse(t){if(this._getType(t)!==he.null){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:he.null,received:r.parsedType}),Ne}return Rr(t.data)}}a0.create=e=>new a0({typeName:Te.ZodNull,...je(e)});class kw extends Ve{constructor(){super(...arguments),this._any=!0}_parse(t){return Rr(t.data)}}kw.create=e=>new kw({typeName:Te.ZodAny,...je(e)});class l0 extends Ve{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Rr(t.data)}}l0.create=e=>new l0({typeName:Te.ZodUnknown,...je(e)});class js extends Ve{_parse(t){const n=this._getOrReturnCtx(t);return ie(n,{code:Y.invalid_type,expected:he.never,received:n.parsedType}),Ne}}js.create=e=>new js({typeName:Te.ZodNever,...je(e)});class Cw extends Ve{_parse(t){if(this._getType(t)!==he.undefined){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:he.void,received:r.parsedType}),Ne}return Rr(t.data)}}Cw.create=e=>new Cw({typeName:Te.ZodVoid,...je(e)});class di extends Ve{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==he.array)return ie(n,{code:Y.invalid_type,expected:he.array,received:n.parsedType}),Ne;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?Y.too_big:Y.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:Y.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:Y.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 pi(n,o,n.path,a)))).then(o=>Dn.mergeArray(r,o));const s=[...n.data].map((o,a)=>i.type._parseSync(new pi(n,o,n.path,a)));return Dn.mergeArray(r,s)}get element(){return this._def.type}min(t,n){return new di({...this._def,minLength:{value:t,message:ve.toString(n)}})}max(t,n){return new di({...this._def,maxLength:{value:t,message:ve.toString(n)}})}length(t,n){return new di({...this._def,exactLength:{value:t,message:ve.toString(n)}})}nonempty(t){return this.min(1,t)}}di.create=(e,t)=>new di({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Te.ZodArray,...je(t)});function la(e){if(e instanceof $t){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Di.create(la(r))}return new $t({...e._def,shape:()=>t})}else return e instanceof di?new di({...e._def,type:la(e.element)}):e instanceof Di?Di.create(la(e.unwrap())):e instanceof To?To.create(la(e.unwrap())):e instanceof Eo?Eo.create(e.items.map(t=>la(t))):e}class $t extends Ve{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=Ye.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==he.object){const c=this._getOrReturnCtx(t);return ie(c,{code:Y.invalid_type,expected:he.object,received:c.parsedType}),Ne}const{status:r,ctx:i}=this._processInputParams(t),{shape:s,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof js&&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 pi(i,d,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof js){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:Y.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 pi(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=>Dn.mergeObjectSync(r,c)):Dn.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return ve.errToObj,new $t({...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:ve.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new $t({...this._def,unknownKeys:"strip"})}passthrough(){return new $t({...this._def,unknownKeys:"passthrough"})}extend(t){return new $t({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new $t({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Te.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new $t({...this._def,catchall:t})}pick(t){const n={};for(const r of Ye.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new $t({...this._def,shape:()=>n})}omit(t){const n={};for(const r of Ye.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new $t({...this._def,shape:()=>n})}deepPartial(){return la(this)}partial(t){const n={};for(const r of Ye.objectKeys(this.shape)){const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}return new $t({...this._def,shape:()=>n})}required(t){const n={};for(const r of Ye.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Di;)s=s._def.innerType;n[r]=s}return new $t({...this._def,shape:()=>n})}keyof(){return RT(Ye.objectKeys(this.shape))}}$t.create=(e,t)=>new $t({shape:()=>e,unknownKeys:"strip",catchall:js.create(),typeName:Te.ZodObject,...je(t)});$t.strictCreate=(e,t)=>new $t({shape:()=>e,unknownKeys:"strict",catchall:js.create(),typeName:Te.ZodObject,...je(t)});$t.lazycreate=(e,t)=>new $t({shape:e,unknownKeys:"strip",catchall:js.create(),typeName:Te.ZodObject,...je(t)});class qh extends Ve{_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 Hi(a.ctx.common.issues));return ie(n,{code:Y.invalid_union,unionErrors:o}),Ne}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 Hi(l));return ie(n,{code:Y.invalid_union,unionErrors:a}),Ne}}get options(){return this._def.options}}qh.create=(e,t)=>new qh({options:e,typeName:Te.ZodUnion,...je(t)});const Ei=e=>e instanceof u0?Ei(e.schema):e instanceof Os?Ei(e.innerType()):e instanceof Yh?[e.value]:e instanceof No?e.options:e instanceof d0?Ye.objectValues(e.enum):e instanceof Qh?Ei(e._def.innerType):e instanceof o0?[void 0]:e instanceof a0?[null]:e instanceof Di?[void 0,...Ei(e.unwrap())]:e instanceof To?[null,...Ei(e.unwrap())]:e instanceof MT||e instanceof Jh?Ei(e.unwrap()):e instanceof Zh?Ei(e._def.innerType):[];class jx extends Ve{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==he.object)return ie(n,{code:Y.invalid_type,expected:he.object,received:n.parsedType}),Ne;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:Y.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Ne)}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=Ei(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 jx({typeName:Te.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...je(r)})}}function c0(e,t){const n=ps(e),r=ps(t);if(e===t)return{valid:!0,data:e};if(n===he.object&&r===he.object){const i=Ye.objectKeys(t),s=Ye.objectKeys(e).filter(a=>i.indexOf(a)!==-1),o={...e,...t};for(const a of s){const l=c0(e[a],t[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}else if(n===he.array&&r===he.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=c0(o,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===he.date&&r===he.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Kh extends Ve{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(s,o)=>{if(yw(s)||yw(o))return Ne;const a=c0(s.value,o.value);return a.valid?((bw(s)||bw(o))&&n.dirty(),{status:n.value,value:a.data}):(ie(r,{code:Y.invalid_intersection_types}),Ne)};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}))}}Kh.create=(e,t,n)=>new Kh({left:e,right:t,typeName:Te.ZodIntersection,...je(n)});class Eo extends Ve{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==he.array)return ie(r,{code:Y.invalid_type,expected:he.array,received:r.parsedType}),Ne;if(r.data.length<this._def.items.length)return ie(r,{code:Y.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Ne;!this._def.rest&&r.data.length>this._def.items.length&&(ie(r,{code:Y.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 pi(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>Dn.mergeArray(n,o)):Dn.mergeArray(n,s)}get items(){return this._def.items}rest(t){return new Eo({...this._def,rest:t})}}Eo.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Eo({items:e,typeName:Te.ZodTuple,rest:null,...je(t)})};class Gh extends Ve{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!==he.object)return ie(r,{code:Y.invalid_type,expected:he.object,received:r.parsedType}),Ne;const i=[],s=this._def.keyType,o=this._def.valueType;for(const a in r.data)i.push({key:s._parse(new pi(r,a,r.path,a)),value:o._parse(new pi(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?Dn.mergeObjectAsync(n,i):Dn.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof Ve?new Gh({keyType:t,valueType:n,typeName:Te.ZodRecord,...je(r)}):new Gh({keyType:Ri.create(),valueType:t,typeName:Te.ZodRecord,...je(n)})}}class Ew extends Ve{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!==he.map)return ie(r,{code:Y.invalid_type,expected:he.map,received:r.parsedType}),Ne;const i=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([a,l],c)=>({key:i._parse(new pi(r,a,r.path,[c,"key"])),value:s._parse(new pi(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 Ne;(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 Ne;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}}}}Ew.create=(e,t,n)=>new Ew({valueType:t,keyType:e,typeName:Te.ZodMap,...je(n)});class Jc extends Ve{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==he.set)return ie(r,{code:Y.invalid_type,expected:he.set,received:r.parsedType}),Ne;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(ie(r,{code:Y.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:Y.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 Ne;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 pi(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(t,n){return new Jc({...this._def,minSize:{value:t,message:ve.toString(n)}})}max(t,n){return new Jc({...this._def,maxSize:{value:t,message:ve.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Jc.create=(e,t)=>new Jc({valueType:e,minSize:null,maxSize:null,typeName:Te.ZodSet,...je(t)});class u0 extends Ve{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})}}u0.create=(e,t)=>new u0({getter:e,typeName:Te.ZodLazy,...je(t)});class Yh extends Ve{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return ie(n,{received:n.data,code:Y.invalid_literal,expected:this._def.value}),Ne}return{status:"valid",value:t.data}}get value(){return this._def.value}}Yh.create=(e,t)=>new Yh({value:e,typeName:Te.ZodLiteral,...je(t)});function RT(e,t){return new No({values:e,typeName:Te.ZodEnum,...je(t)})}class No extends Ve{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return ie(n,{expected:Ye.joinValues(r),received:n.parsedType,code:Y.invalid_type}),Ne}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:Y.invalid_enum_value,options:r}),Ne}return Rr(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 No.create(t,{...this._def,...n})}exclude(t,n=this._def){return No.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}No.create=RT;class d0 extends Ve{_parse(t){const n=Ye.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==he.string&&r.parsedType!==he.number){const i=Ye.objectValues(n);return ie(r,{expected:Ye.joinValues(i),received:r.parsedType,code:Y.invalid_type}),Ne}if(this._cache||(this._cache=new Set(Ye.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const i=Ye.objectValues(n);return ie(r,{received:r.data,code:Y.invalid_enum_value,options:i}),Ne}return Rr(t.data)}get enum(){return this._def.values}}d0.create=(e,t)=>new d0({values:e,typeName:Te.ZodNativeEnum,...je(t)});class Xh extends Ve{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==he.promise&&n.common.async===!1)return ie(n,{code:Y.invalid_type,expected:he.promise,received:n.parsedType}),Ne;const r=n.parsedType===he.promise?n.data:Promise.resolve(n.data);return Rr(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Xh.create=(e,t)=>new Xh({type:e,typeName:Te.ZodPromise,...je(t)});class Os extends Ve{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Te.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 Ne;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?Ne:l.status==="dirty"||n.value==="dirty"?nc(l.value):l});{if(n.value==="aborted")return Ne;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?Ne:a.status==="dirty"||n.value==="dirty"?nc(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"?Ne:(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"?Ne:(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(!Ya(o))return Ne;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=>Ya(o)?Promise.resolve(i.transform(o.value,s)).then(a=>({status:n.value,value:a})):Ne);Ye.assertNever(i)}}Os.create=(e,t,n)=>new Os({schema:e,typeName:Te.ZodEffects,effect:t,...je(n)});Os.createWithPreprocess=(e,t,n)=>new Os({schema:t,effect:{type:"preprocess",transform:e},typeName:Te.ZodEffects,...je(n)});class Di extends Ve{_parse(t){return this._getType(t)===he.undefined?Rr(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Di.create=(e,t)=>new Di({innerType:e,typeName:Te.ZodOptional,...je(t)});class To extends Ve{_parse(t){return this._getType(t)===he.null?Rr(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}To.create=(e,t)=>new To({innerType:e,typeName:Te.ZodNullable,...je(t)});class Qh extends Ve{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===he.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Qh.create=(e,t)=>new Qh({innerType:e,typeName:Te.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...je(t)});class Zh extends Ve{_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 Wh(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Hi(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Hi(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Zh.create=(e,t)=>new Zh({innerType:e,typeName:Te.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...je(t)});class Nw extends Ve{_parse(t){if(this._getType(t)!==he.nan){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:he.nan,received:r.parsedType}),Ne}return{status:"valid",value:t.data}}}Nw.create=e=>new Nw({typeName:Te.ZodNaN,...je(e)});class MT extends Ve{_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 Ox extends Ve{_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"?Ne:s.status==="dirty"?(n.dirty(),nc(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"?Ne: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 Ox({in:t,out:n,typeName:Te.ZodPipeline})}}class Jh extends Ve{_parse(t){const n=this._def.innerType._parse(t),r=i=>(Ya(i)&&(i.value=Object.freeze(i.value)),i);return Wh(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}Jh.create=(e,t)=>new Jh({innerType:e,typeName:Te.ZodReadonly,...je(t)});var Te;(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"})(Te||(Te={}));const y=Ri.create,W=Xa.create,me=s0.create,ji=l0.create;js.create;const Z=di.create,I=$t.create;qh.create;const lr=jx.create;Kh.create;Eo.create;const Mr=Gh.create,G=Yh.create,be=No.create;Xh.create;Di.create;To.create;const M6=Os.createWithPreprocess;new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");const A6=["owner"],L6=["agent","owner","user-upload"],AT=I({id:y().min(1),relPath:y().min(1),from:be(L6),label:y().optional(),size:W().int().nonnegative(),mime:y().min(1),addedAt:W().int().nonnegative(),lastEditedAt:W().int().nonnegative().optional(),stale:me().optional()});I({sessionId:y().min(1),relPath:y().min(1),ttlSeconds:W().int().positive().nullable().optional(),view:be(["raw","md-rendered"]).optional()});I({url:y().min(1),expiresAt:W().int().nonnegative().nullable()});I({sessionId:y().min(1),relPath:y().min(1),label:y().optional(),origin:G("agent").optional()});I({entry:AT});I({sessionId:y().min(1),relPath:y().min(1)});I({removed:G(!0)});I({sessionId:y().min(1)});I({entries:Z(AT)});I({attachmentId:y().min(1),url:y().min(1),relPath:y().min(1),sizeBytes:W().int().nonnegative(),mimeType:y().min(1)});const D6=lr("type",[I({type:G("persona"),id:y().min(1)}).strict(),I({type:G("chat"),id:y().min(1)}).strict(),I({type:G("*")}).strict()]),j6=be(["read","send","admin"]),Bx=I({resource:D6,actions:Z(j6).min(1)}).strict(),O6=I({id:y().min(1),secretHash:y().regex(/^[a-f0-9]{64}$/),displayName:y(),grants:Z(Bx),issuedAt:W().int().nonnegative(),expiresAt:W().int().positive().optional(),maxUses:W().int().positive().optional(),usedCount:W().int().nonnegative(),peerOwnerId:y().min(1).optional(),firstUsedByPeerAt:W().int().positive().optional(),peerDisplayName:y().optional()}).strict(),B6=O6.omit({secretHash:!0});I({type:G("whoami:ok"),owner:I({id:y(),kind:be(["owner","guest"]),displayName:y(),ownerId:y(),provider:y()}).strict(),capability:B6,grantedPersonas:Z(I({id:y().min(1),displayName:y()}).strict())}).strict();I({selfUrl:y().min(1)});I({type:G("contact:handshake:ok"),owner:I({id:y(),ownerId:y(),provider:y(),displayName:y()}),grants:Z(Bx)});const z6=lr("status",[I({status:G("authorized"),login:y().min(1),source:be(["git","file"])}).strict(),I({status:G("missing")}).strict(),I({status:G("invalid"),message:y().min(1)}).strict(),I({status:G("pending"),authUrl:y().url()}).strict()]);I({token:y().min(1)}).strict();I({returnTo:y().url().optional()}).strict();const $6=I({name:y().min(1),from:y().optional(),version:y().optional(),min:y().optional(),library:me().optional()}),F6=I({name:y().min(1),env:Z(y().min(1)).min(1)}),zx=y().regex(/^[a-z0-9-]+$/,"连接器名只能是小写字母、数字和短横线"),LT=["proxy","env"],DT=["mcp","cli"],H6=["bearer","lark-sidecar"],U6=["none","shared","personal"],jT=["oauth","fields"],$x=y().regex(/^[A-Z][A-Z0-9_]*$/,"要填的变量名只能是大写字母、数字和下划线,且以字母开头"),W6=I({name:zx,kind:be(LT),runner:be(DT),protocol:be(H6).optional(),id:y().min(1),credentialSource:be(U6).optional(),auth:be(jT).optional(),fields:Z($x).default([]),http:I({url:y().min(1),headers:Mr(y(),y())}).optional()}),V6=e=>{if(!e||typeof e!="object")return e;let t=e;if("clis"in t&&Array.isArray(t.clis)){const{clis:n,...r}=t;t="packages"in r?r:{...r,packages:n}}if("assets"in t&&Array.isArray(t.assets)&&t.assets.length===0){const{assets:n,...r}=t;t=r}return t},OT={packages:Z($6),secrets:Z(F6),connectors:Z(W6).default([])};I(OT);const Fx=M6(V6,I({version:G(1),...OT}).strict()),q6=I({target:y().min(1),reason:y().min(1),file:y().min(1),quote:y().min(1)});I({version:G(1),manifest:Fx}).strict();const K6=["hard","soft"],BT=be(K6),G6=be(["scanning","done","failed"]),zT=I({id:y().min(1),manifest:Fx,scanSessionId:y().optional(),status:G6,evidence:Z(q6).default([]),notes:Z(y()).default([]),head:y().min(1).optional(),baseKind:BT.default("hard"),base:y().min(1).optional(),startedAt:W(),finishedAt:W().optional(),error:y().optional()}).strict(),$T=I({head:y().min(1),contentHead:y().min(1),scanId:y().min(1),at:W()}).strict();I({version:G(2),scans:Z(zT),released:$T.optional()}).strict();const Y6=I({url:y().min(1),branch:y().min(1),head:y().min(1),dirty:me(),ahead:W()}).strict(),X6=I({env:y().min(1),setAt:W().optional()}).strict(),Q6=["pending","running","done","failed","waiting","skipped"],Z6=be(Q6),J6=["build","smoke","deploy"],eB=be(J6),tB=I({key:eB,status:Z6,url:y().optional(),jobId:W().optional(),startedAt:W().optional(),completedAt:W().optional()}).strict(),nB=I({runId:W(),headSha:y().min(1),status:be(["queued","running","completed"]),htmlUrl:y().min(1),jobs:Z(tB)}).strict();I({personaId:y().min(1),github:z6.optional(),repo:Y6.optional(),scans:Z(zT).default([]),released:$T.optional(),secrets:Z(X6).optional(),run:nB.optional(),historyError:y().optional()}).strict();I({sha:y().min(1),actionsUrl:y().min(1)}).strict();const FT=I({personaId:y().min(1)}).strict();FT.extend({scanBase:BT.optional()}).strict();FT.extend({scanId:y().min(1)}).strict();I({personaId:y().min(1),scanId:y().min(1),patch:I({manifest:Fx.optional()}).strict()}).strict();I({personaId:y().min(1),scanId:y().min(1),name:y().min(1),values:Mr(y(),y())}).strict();I({personaId:y().min(1),jobId:W()}).strict();I({personaId:y().min(1),kind:be(["package","secret","connector"]),item:Mr(y(),ji()),evidence:I({reason:y().min(1),file:y().min(1),quote:y().min(1)})}).strict();I({personaId:y().min(1),notes:Z(y()).default([])}).strict();I({deviceId:y().min(1),remoteAccessAllowed:me()}).strict();I({type:G("contact:setRemoteAccess:ok"),deviceId:y().min(1),remoteAccessAllowed:me()}).strict();I({type:G("contact:remote-access-updated"),deviceId:y().min(1),remoteAccessAllowed:me()}).strict();I({personaId:y().min(1)}).strict();const rB=["connected","missing","reauth"],iB=["link","fill"],sB=I({name:zx,id:y().min(1),kind:be(LT),runner:be(DT),auth:be(jT),status:be(rB),action:be(iB),authUrl:y().optional(),fields:Z($x)}).strict();I({connectors:Z(sB)}).strict();I({personaId:y().min(1),name:zx,values:Mr($x,y().min(1))}).strict();const oB=I({deviceId:y().min(1),ownerId:y().min(1),provider:y().min(1),displayName:y(),remoteUrl:y().min(1),connectToken:y(),grants:Z(Bx),addedAt:W().int().nonnegative(),pinnedAt:W().int().nullable().default(null),remoteAccessAllowed:me().default(!1),note:y().default("")}).strict(),HT=oB;I({deviceId:y().min(1)}).strict();I({type:G("contact:remove:ok"),deviceId:y().min(1)}).strict();I({type:G("contact:list:ok"),contacts:Z(HT)}).strict();I({type:G("contact:added"),contact:HT}).strict();I({type:G("contact:removed"),deviceId:y().min(1)}).strict();I({deviceId:y().min(1),pinned:me()}).strict();I({deviceId:y().min(1),note:y()}).strict();I({type:G("contact:setNote:ok"),deviceId:y().min(1),note:y()}).strict();I({type:G("contact:pin:ok"),deviceId:y().min(1),pinnedAt:W().int().nullable()}).strict();I({type:G("contact:pinned"),deviceId:y().min(1),pinnedAt:W().int().nullable()}).strict();const aB=I({deviceId:y().min(1),name:y().min(1),url:y().min(1)});I({type:G("device:list:ok"),devices:Z(aB)});I({deviceId:y().min(1),url:y().min(1).optional(),name:y().optional()});I({type:G("device:connect:ok"),deviceId:y(),name:y(),url:y()});const UT=I({ownerId:y().min(1),provider:y().min(1),displayName:y().min(1),avatarUrl:y().optional(),unionId:y().optional()});I({type:G("auth:login:start:ok"),authUrl:y().min(1),state:y().min(1)});I({type:G("auth:getIdentity:ok"),identity:UT.nullable(),deviceId:y().min(1)});I({type:G("auth:logout:ok")});const WT=y().nullable();I({type:G("auth:apiKey:get:ok"),apiKey:y().nullable(),createdAt:y().nullable(),gatewayUrl:WT});I({type:G("auth:apiKey:regenerate:ok"),apiKey:y().min(1),createdAt:y().min(1),gatewayUrl:WT});I({type:G("auth:apiKey:revoke:ok"),revoked:me()});I({type:G("auth:login:done"),identity:UT});I({type:G("auth:login:failed"),reason:y()});const Hx=lr("kind",[I({kind:G("success"),text:y(),brief:y().optional(),filePaths:Z(y()).optional()}),I({kind:G("failure"),reason:y(),brief:y().optional()})]);I({targetPersona:y().min(1).optional(),dispatchId:y().min(1).optional(),prompt:y(),brief:y().optional(),targetDeviceId:y().min(1).optional(),model:y().min(1).optional(),tool:y().min(1).optional(),sessionLabel:y().min(1).max(60).optional(),meta:Mr(ji()).optional()}).refine(e=>e.targetPersona!==void 0||e.dispatchId!==void 0,{message:"either targetPersona (new dispatch) or dispatchId (follow-up) is required"}).refine(e=>!(e.dispatchId!==void 0&&e.targetDeviceId!==void 0),{message:"cross-device dispatch cannot be continued (dispatchId + targetDeviceId are mutually exclusive)"}).refine(e=>!(e.tool!==void 0&&e.targetDeviceId!==void 0),{message:"engine override is not supported for cross-device dispatch (tool + targetDeviceId are mutually exclusive)"}).refine(e=>!(e.dispatchId!==void 0&&(e.tool!==void 0||e.model!==void 0)),{message:"a follow-up dispatch cannot change engine or model (dispatchId excludes tool / model); start a new dispatch instead"});I({dispatchId:y().min(1),outcome:Hx});const lB=["running","completed","failed"],Ux=be(lB),cB=I({dispatchId:y().min(1),sourceSessionId:y().min(1),sourcePersonaId:y().min(1).optional(),targetPersonaId:y().min(1),targetDeviceId:y().min(1).optional(),workerSessionId:y().min(1).optional(),taskText:y(),taskBrief:y().optional(),round:W().int().positive().optional(),status:Ux,outcome:Hx.optional(),meta:Mr(ji()).optional(),createdAt:y().min(1),completedAt:y().min(1).optional(),deliveredAt:y().min(1).optional()});I({sourceSessionId:y().min(1).optional(),relatedSessionId:y().min(1).optional()});I({records:Z(cB)});I({dispatchId:y().min(1)});I({type:G("personaDispatch:get:ok"),status:Ux,outcome:Hx.optional()});const uB=/^[a-z0-9][a-z0-9-]*$/;be(["stopped","starting","running","crashed","invalid"]);const dB=new Set(["localhost","127.0.0.1"]);function hB(e){let t;try{t=new URL(e)}catch{return!1}return!!(t.protocol==="https:"||t.protocol==="http:"&&dB.has(t.hostname))}const dd=I({id:y().regex(uB),name:y().min(1),version:y().min(1),apiVersion:G("1"),runtime:I({startCommand:y().min(1)}).passthrough().optional(),entry:I({url:y().url().refine(hB,{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:Y.custom,message:"INVALID_MANIFEST: entry.url and runtime cannot coexist"}),!n&&!r&&t.addIssue({code:Y.custom,message:"INVALID_MANIFEST: must have either entry.url or runtime"})}),fB=lr("kind",[I({kind:G("local"),port:W().int().min(1).max(65535)}),I({kind:G("hosted"),url:y().url()})]);lr("state",[I({extId:y(),manifest:dd,state:G("stopped")}),I({extId:y(),manifest:dd,state:G("starting")}),I({extId:y(),manifest:dd,state:G("running"),target:fB}),I({extId:y(),manifest:dd,state:G("crashed")}),I({extId:y(),manifest:ji().nullable(),state:G("invalid"),invalidReason:y().min(1)})]);I({snapshotHash:y().min(1),version:y().min(1),publishedAt:W()});const pB=lr("kind",[I({kind:G("p2p-tunnel"),ownerPrincipalId:y().min(1),extId:y().min(1)})]);lr("kind",[I({kind:G("p2p-tunnel"),ownerPrincipalId:y().min(1),extId:y().min(1),snapshotHash:y().min(1)})]);I({extId:y().min(1),name:y().min(1),version:y().min(1),contentHash:y().min(1),publishedAt:W()});const mB=lr("kind",[I({kind:G("clean")}),I({kind:G("ready-new-version"),fromVersion:y().min(1),toVersion:y().min(1)}),I({kind:G("error-same-hash"),version:y().min(1)}),I({kind:G("error-version-not-bumped"),localVersion:y().min(1),publishedVersion:y().min(1)}),I({kind:G("error-version-regression"),localVersion:y().min(1),publishedVersion:y().min(1)})]);I({localManifest:I({name:y().min(1),version:y().min(1),contentHash:y().min(1)}),publishState:lr("kind",[I({kind:G("unpublished")}),I({kind:G("published"),version:y().min(1),contentHash:y().min(1),publishedAt:W()})]),check:mB});I({extId:y().min(1),newVersion:y().min(1).nullish()});I({extId:y().min(1)});I({extId:y().min(1),snapshotHash:y().min(1)});I({channelRef:pB,snapshotHash:y().min(1),zipBase64:y().min(1)});I({id:y().min(1),peerDeviceId:y().min(1),senderDeviceId:y().min(1),text:y().min(1),createdAt:W().int().nonnegative(),readBy:Mr(y().min(1),W().int().positive()).default({}),origin:I({kind:G("persona"),personaId:y().min(1)}).optional()}).strict();I({peerDeviceId:y().min(1).optional(),id:y().min(1),text:y().min(1),createdAt:W().int().nonnegative(),origin:I({kind:G("persona"),personaId:y().min(1)}).optional()}).strict();I({peerDeviceId:y().min(1),sinceCreatedAt:W().int().nonnegative().optional()}).strict();I({peerDeviceId:y().min(1),upToCreatedAt:W().int().nonnegative()}).strict();I({peerDeviceId:y().min(1).optional(),text:y().min(1)});I({peerDeviceId:y().min(1).optional(),command:y().min(1),timeoutMs:W().int().positive().optional()}).strict();I({type:G("peerExec:run:ok"),stdout:y(),stderr:y(),exitCode:W().int().nullable(),timedOut:me(),stdoutTruncated:me(),stderrTruncated:me()}).strict();const VT=lr("kind",[I({kind:G("at"),at:y().min(1)}),I({kind:G("every"),everyMs:W().int().positive(),anchorMs:W().int().nonnegative().optional()}),I({kind:G("cron"),expr:y().min(1),tz:y().min(1).optional()})]),xu=y().trim().min(1);I({personaId:xu,name:y().min(1),schedule:VT,prompt:y().min(1),targetPersona:y().min(1).optional(),timeoutMs:W().int().positive().optional()});I({personaId:xu,onlyMine:me().optional()});I({personaId:xu,shiftId:y().min(1)});const gB=I({name:y().min(1).optional(),schedule:VT.optional(),prompt:y().min(1).optional(),targetPersona:y().min(1).optional(),timeoutMs:W().int().positive().optional(),enabled:me().optional()});I({personaId:xu,shiftId:y().min(1),patch:gB});I({personaId:xu,shiftId:y().min(1),limit:W().int().positive().optional()});const qT="persona-master",Wx=I({personaId:y().min(1),deviceId:y().min(1).optional()}),KT=I({id:y().min(1),name:y().min(1),memberPersonas:Z(Wx),memberContactDeviceIds:Z(y().min(1)),createdAt:y().min(1),updatedAt:y().min(1)}),GT=y().trim().min(1);I({name:GT,memberPersonas:Z(Wx).default([]),memberContactDeviceIds:Z(y().min(1)).default([])});I({channelId:y().min(1),name:GT.optional(),memberPersonas:Z(Wx).optional(),memberContactDeviceIds:Z(y().min(1)).optional()});I({channelId:y().min(1)});I({channels:Z(KT)});I({channel:KT});I({ok:G(!0),removedTopics:W().int().min(0)});const Wt=y().trim().min(1),Vx=["master-confirmed","owner-needed"],qx=["open","resolved"],vB=Vx[0];Vx[1];qx[0];const _B=qx[1],xB=be(Vx),yB=be(qx),bB=I({id:Wt.optional(),resolves:Wt.optional(),type:xB,status:yB,question:Wt,recommendation:Wt}).superRefine((e,t)=>{e.type===vB&&e.status!==_B&&t.addIssue({code:Y.custom,path:["status"],message:"master-confirmed decisions must be resolved"})}),wB=["planning","running","done"],SB=be(wB),YT=I({at:y().min(1),actor:y().min(1),action:y().min(1),target:y().optional(),reason:y().min(1),artifacts:Z(Wt).optional(),decision:bB.optional()}),kB=I({rejectCount:W().int().min(0),accepted:me().default(!1),ordinal:W().int().min(1).optional(),overrideCount:W().int().min(0).optional()}),Kx=I({id:y().min(1),channelId:y().min(1),title:y(),masterSessionId:y().min(1),goal:y(),boundaries:y(),acceptanceCriteria:Z(y()),activity:Z(YT),lineMeta:Mr(kB),nextLineOrdinal:W().int().min(1).optional(),state:SB,createdAt:y().min(1),updatedAt:y().min(1)}),CB=I({lineId:y().min(1),dispatchId:y().min(1),workerSessionId:y().optional(),assignee:y().min(1),focus:y(),status:Ux,acceptance:Z(y()),rejectCount:W().int().min(0),accepted:me(),ordinal:W().int().min(1).nullable()});I({channelId:y().min(1)});I({topicId:y().min(1).optional(),sessionId:y().min(1).optional()}).refine(e=>e.topicId!==void 0||e.sessionId!==void 0,{message:"either topicId or sessionId is required"});I({channelId:y().min(1),title:Wt.optional()});I({topicId:y().min(1),title:Wt.optional(),goal:Wt,boundaries:y(),acceptanceCriteria:Z(Wt).min(1)});I({topicId:y().min(1),action:Wt,target:Wt.optional(),reason:Wt,artifacts:Z(Wt).optional(),decision:YT.shape.decision});I({topicId:y().min(1),lineId:Wt,reason:Wt});I({topicId:y().min(1),lineId:Wt,reason:Wt,artifacts:Z(Wt).optional(),watcherVerdict:be(["pass","fail"]),overrideReason:Wt.optional()}).refine(e=>e.watcherVerdict!=="fail"||!!e.overrideReason,{message:"watcherVerdict=fail 时必须给 overrideReason(推翻 watcher 的理由)",path:["overrideReason"]});I({topicId:y().min(1),state:be(["done"])});I({topicId:y().min(1),title:Wt});I({topicId:y().min(1)});const EB=Kx.extend({lineCount:W().int().min(0)});I({topics:Z(EB)});I({topic:Kx,lines:Z(CB)});I({topicId:y().min(1),masterSessionId:y().min(1)});I({rejectCount:W().int().min(1),needsOwnerAttention:me()});I({acceptedLines:W().int().min(1),totalLines:W().int().min(1),allAccepted:me(),overrides:W().int().min(0),needsOwnerAttention:me()});I({topic:Kx});I({ok:G(!0),removedMasterSessionId:y().min(1).nullable(),removedWorkerSessionIds:Z(y().min(1))});const NB=["ask","allow","deny"],XT=be(NB),TB=I({id:y().min(1),desc:y().min(1),action:XT});I({rules:Z(TB)});I({ruleId:y().min(1)});I({action:XT,desc:y(),source:y().min(1)});const IB=["created","review-requested"],QT=/^[A-Za-z0-9._-]+$/,vl=y().min(1).regex(QT),_l=y().min(1).regex(QT),yu=W().int().positive();I({role:be(IB)});I({owner:vl,repo:_l,number:yu});I({owner:vl,repo:_l,number:yu,expectedHeadSha:y().min(1)});I({owner:vl,repo:_l,number:yu,body:y().min(1)});I({owner:vl,repo:_l,number:yu,ready:me()});I({owner:vl,repo:_l});I({owner:vl,repo:_l,number:yu,reviewers:Z(y().min(1)).min(1)});I({personaId:y().min(1)});I({personaId:y().min(1)});const PB=["expired","cancelled","access_denied","lark_protocol_error","cloud_unreachable","internal_error"],RB=be(PB);I({personaId:y().min(1),appId:y().min(1),appSecret:y().min(1),botName:y().min(1).optional()});const MB=I({chatId:y().min(1),chatName:y().optional(),lastActiveAt:W().int().optional()}),AB=I({state:be(["unbound","provisioning","bound","broken"]),appId:y().optional(),botName:y().optional(),brokenReason:y().optional(),qrUrl:y().optional(),errorReason:RB.optional(),groups:Z(MB),needsUpgrade:me().optional(),upgradeQrUrl:y().optional()});AB.extend({personaId:y().min(1)});I({});I({onboardingCompletedAt:W()});const ap=["claude","codex","pi"];I({});I({tools:Z(I({id:be(ap),available:me(),version:y().optional(),path:y().optional()}))});I({});const LB=I({tool:be(ap),cwd:y(),toolSessionId:y(),label:y().optional(),createdAt:y(),updatedAt:y(),turns:W()});I({candidates:Z(LB)});I({});I({registered:me()});I({tool:be(ap)});const Tw=I({usedPercent:W(),windowDurationMins:W().optional(),resetsAt:W().optional()}).strict(),DB=lr("kind",[I({kind:G("claude"),loggedIn:me(),authMethod:y().optional(),apiProvider:y().optional(),apiKeySource:y().optional(),email:y().optional(),orgName:y().optional(),subscriptionType:y().optional()}).strict(),I({kind:G("codex"),login:lr("type",[I({type:G("none")}).strict(),I({type:G("apiKey")}).strict(),I({type:G("chatgpt"),email:y(),planType:y()}).strict()]),provider:I({name:y(),baseUrl:y().optional()}).strict(),rateLimits:I({primary:Tw.optional(),secondary:Tw.optional()}).strict().optional()}).strict(),I({kind:G("pi"),providers:Z(I({id:y(),modelCount:W(),credential:be(["api_key","oauth"]).optional(),oauthExpiresAt:W().optional()}).strict())}).strict()]);I({tool:be(ap),installed:me(),version:y().optional(),path:y().optional(),account:DB.optional(),error:y().optional(),modelsLoadedAt:W().optional()}).strict();I({apiKey:y().min(1)}).strict();I({ok:G(!0)}).strict();const jB=["tiny","small","medium","large"],OB=be(jB),BB=I({personaId:y(),label:y(),model:y().optional(),effort:y().optional(),public:me(),iconKey:y().optional(),tool:y().optional(),size:y().optional(),taskConcurrency:W().int().positive().optional(),createdAt:W(),updatedAt:W(),cloud:I({gatewayUrl:y().min(1),personaId:y().min(1)}).strict().optional()}).strict(),zB=I({name:y().min(1),description:y().optional()}),$B=I({id:y().min(1)}),ZT=I({writableRoots:Z(y()).optional(),denyRead:Z(y()).optional(),network:me().optional()}).strict(),FB=I({permissions:I({defaultMode:y().optional(),allow:Z(y()).optional(),deny:Z(y()).optional()}).optional(),sandbox:I({enabled:me().optional(),autoAllowBashIfSandboxed:me().optional(),allowUnsandboxedCommands:me().optional(),excludedCommands:Z(y()).optional(),filesystem:I({denyRead:Z(y()).optional(),allowRead:Z(y()).optional(),denyWrite:Z(y()).optional(),allowWrite:Z(y()).optional()}).optional(),network:I({allowedDomains:Z(y()).optional(),allowLocalBinding:me().optional()}).optional()}).optional()});BB.extend({personality:y().optional(),personalityLocal:y().optional(),personalityManaged:me().optional(),skills:Z(zB).optional(),plugins:Z($B).optional(),sandboxSettings:FB.nullable().optional(),codexSandbox:ZT.nullable().optional()});I({slug:y().regex(/^[a-z0-9]+(-[a-z0-9]+)*$/).max(32),label:y().min(1),personality:y(),model:y().optional(),effort:y().optional(),tool:y().optional(),public:me().optional(),iconKey:y().optional()}).strict();I({personaId:y().min(1)});I({personaId:y().min(1),patch:I({label:y().min(1).optional(),model:y().optional(),effort:y().optional(),tool:y().optional(),size:OB.optional(),personality:y().optional(),personalityLocal:y().optional(),public:me().optional(),iconKey:y().nullable().optional(),codexSandbox:ZT.optional()}).strict()}).strict();const JT=["ready","session:info","session:status","session:event","session:deleted","session:rewound","session:cleared","session:queue","permission:request","session:question","session:question:cleared","pong","error","subscribed","unsubscribed","auth:ok","tunnel:ready","tunnel:exited","tunnel:unavailable","session:control","session:pty","contact:added","contact:pinned","contact:removed","contact:remote-access-updated","contact:note-updated","org-mesh:progress","channel:changed","inbox:event","friend:reverseTokenOffered","auth:login:done","auth:login:failed","larkBot:state"],eI=["idle","running","running-idle","stopped","error","observing"],HB=["task-notification","slash-command","local-command","system-reminder","skill-hint","meta-text","attachment-skills","attachment-deferred-tools","dispatch-task","dispatch-result"];function lp(e){return e==="dispatch-task"||e==="dispatch-result"}const UB=["builtin","global","project","plugin"],WB=["builtin","global","project","policy","plugin"],tI=be(["owner","guest"]);I({id:y().min(1),kind:tI,displayName:y(),feishuUnionId:y().optional()}).strict();const VB=I({did:y().min(1),displayName:y(),feishuUnionId:y().optional(),principal:tI}).strict(),qB=be(eI),KB=I({inputTokens:W().int().nonnegative(),outputTokens:W().int().nonnegative(),cacheReadTokens:W().int().nonnegative().optional(),cacheCreateTokens:W().int().nonnegative().optional()}),nI={gitBranch:y().optional(),resolvedModel:y().optional(),resolvedEffort:y().optional(),contextUsage:KB.optional(),contextWindowSize:W().int().positive().optional(),aiLabel:y().optional()},GB=I(nI),rI=I({value:y(),label:y(),description:y().optional()}),YB=I({id:y().min(1),label:y().min(1),description:y().optional(),contextWindowSize:W().int().positive(),default:me().optional(),efforts:Z(rI).optional(),defaultEffort:y().optional(),group:y().optional()}),XB=I({id:y().min(1),label:y().min(1),description:y().optional()}),QB=I({name:y().min(1),type:be(["string","select","toggle"]),label:y().min(1),description:y().optional(),options:Z(rI).optional(),default:ji().optional(),scope:be(["core","tool-specific"])});I({tool:y().min(1),refresh:me().optional()});const ZB=I({rewind:me(),subagents:me(),tui:me(),observe:me(),fileSharing:me(),fork:me()});I({tool:y().min(1),toolSessionIdLabel:y().optional(),models:Z(YB),permissionModes:Z(XB),configSchema:Z(QB),features:ZB});const JB=I({tool:y().min(1),pattern:y().min(1),createdAt:y().min(1).optional()});I({sessionId:y().min(1),cwd:y().min(1),tool:G("claude").or(y().min(1)).default("claude"),toolSessionId:y().optional(),label:y().optional(),model:y().optional(),permissionMode:y().optional(),effort:y().optional(),...nI,aiLabelGeneratedAt:y().optional(),permissionRules:Z(JB).optional(),pinnedAt:W().int().nonnegative().nullable().optional(),archivedAt:W().int().nonnegative().nullable().optional(),pinSortOrder:W().int().nullable().optional(),unreadAt:y().min(1).nullable().optional(),iconKey:y().optional(),forkedFromSessionId:y().min(1).optional(),ephemeral:me().optional(),deployId:y().min(1).optional(),ownerPersonaId:y().min(1).optional(),projectPath:y().min(1).optional(),chatId:y().min(1).optional(),creatorPrincipalId:y().min(1).optional(),creatorDisplayName:y().min(1).optional(),creatorFeishuUnionId:y().min(1).optional(),originOwnerPrincipalId:y().min(1).optional(),originOwnerPersonaId:y().min(1).optional(),dispatchedFromSessionId:y().min(1).optional(),shiftFiredFromSessionId:y().min(1).optional(),larkChatId:y().min(1).optional(),larkChatName:y().min(1).optional(),larkChatType:be(["p2p","group"]).optional(),createdAt:y().min(1),updatedAt:y().min(1)});const Fn={seq:W().int().nonnegative().optional(),ts:y().optional(),uuid:y().optional()},ez=be(HB),tz=I({readCount:W().int().nonnegative().optional(),searchCount:W().int().nonnegative().optional(),bashCount:W().int().nonnegative().optional(),editFileCount:W().int().nonnegative().optional(),linesAdded:W().int().nonnegative().optional(),linesRemoved:W().int().nonnegative().optional(),otherToolCount:W().int().nonnegative().optional()}),nz=I({oldStart:W().int().nonnegative(),oldLines:W().int().nonnegative(),newStart:W().int().nonnegative(),newLines:W().int().nonnegative(),lines:Z(y())}),rz=I({agentId:y().optional(),agentType:y().optional(),status:y().optional(),prompt:y().optional(),filePath:y().optional(),structuredPatch:Z(nz).optional(),stats:I({durationMs:W().int().nonnegative().optional(),tokens:W().int().nonnegative().optional(),toolUseCount:W().int().nonnegative().optional(),toolStats:tz.optional()}).optional()}),iz=I({path:y(),content:y(),mtimeMs:W().optional()}),sz=I({label:y().min(1),description:y().optional()}),iI=I({question:y().min(1),multiSelect:me(),options:Z(sz).min(1)}),oz=["completed","interrupted"];lr("kind",[I({...Fn,kind:G("session_init"),toolSessionId:y().optional()}),I({...Fn,kind:G("thinking"),text:y(),partialId:y().optional()}),I({...Fn,kind:G("text"),text:y(),partialId:y().optional()}),I({...Fn,kind:G("user_text"),text:y(),meta:ez.optional(),taskId:y().optional(),parentToolUseId:y().optional(),sender:VB.optional()}),I({...Fn,kind:G("tool_call"),toolUseId:y(),tool:y(),toolKind:y().optional(),input:ji()}),I({...Fn,kind:G("tool_result"),toolUseId:y(),output:ji().optional(),error:y().optional(),toolResultExtra:rz.optional(),sourceToolAssistantUUID:y().optional(),askQuestionAnswers:Mr(y(),y()).optional()}),I({...Fn,kind:G("attachment_memories"),memories:Z(iz)}),I({...Fn,kind:G("permission_request"),requestId:y(),tool:y(),input:ji(),toolUseId:y().optional()}),I({...Fn,kind:G("ask_user_question"),toolUseId:y(),questions:Z(iI)}),I({...Fn,kind:G("turn_end"),durationMs:W().int().nonnegative().optional(),reason:be(oz).optional()}),I({...Fn,kind:G("subagent_progress"),toolUseId:y(),agentId:y(),status:be(["started","running","completed","failed"]),description:y().optional(),lastToolName:y().optional(),prompt:y().optional(),stats:I({durationMs:W().int().nonnegative().optional(),tokens:W().int().nonnegative().optional(),toolUseCount:W().int().nonnegative().optional()}).optional()}),I({...Fn,kind:G("error"),message:y()}),I({...Fn,kind:G("meta_update"),patch:GB}),I({...Fn,kind:G("meta-text"),text:y(),metaSource:be(["cc","owner"]).optional()})]);I({cwd:y().min(1).optional(),tool:y().optional(),label:y().optional(),aiLabel:y().optional(),model:y().optional(),permissionMode:y().optional(),effort:y().optional(),iconKey:y().optional(),forkedFromSessionId:y().min(1).optional(),ephemeral:me().optional(),ownerPersonaId:y().min(1).optional(),projectPath:y().min(1).optional()}).refine(e=>e.cwd!=null||e.ownerPersonaId!=null||e.projectPath!=null,{message:"cwd / ownerPersonaId / projectPath 至少传一个"});I({path:y().min(1),name:y().min(1),createdAt:y().datetime(),pinnedAt:W().optional()});I({path:y().min(1),pinnedAt:W().nullable()});I({path:y().min(1)});I({path:y().min(1).optional(),name:y().min(1).optional()}).refine(e=>e.path!=null||e.name!=null,{message:"path 与 name 至少给一个"});I({cwd:y().min(1),tool:y().min(1),toolSessionId:y().min(1),label:y().optional(),aiLabel:y().optional(),iconKey:y().optional(),createdAt:y().datetime(),updatedAt:y().datetime(),ownerPersonaId:y().min(1).optional()});I({originOnly:me().optional(),ownerPersonaId:y().min(1).optional(),limit:W().int().positive().optional(),offset:W().int().nonnegative().optional()});I({sessionId:y().min(1)});I({sessionId:y().min(1),patch:I({label:y().optional(),model:y().optional(),permissionMode:y().optional(),effort:y().optional(),cwd:y().optional(),iconKey:y().optional(),ephemeral:G(!1).optional()})});I({id:y().min(1),text:y(),queuedAt:W(),senderDisplayName:y().optional()});I({sessionId:y().min(1),text:y(),queueWhileRunning:me().optional()});I({sessionId:y().min(1),id:y().min(1).optional()});I({sessionId:y().min(1),userMessageId:y().min(1),dryRun:me().optional()});I({canRewind:me(),error:y().optional(),filesChanged:Z(y()).optional(),insertions:W().int().nonnegative().optional(),deletions:W().int().nonnegative().optional()});I({sessionId:y().min(1),userMessageId:y().min(1)});const az=I({oldStart:W().int().nonnegative(),oldLines:W().int().nonnegative(),newStart:W().int().nonnegative(),newLines:W().int().nonnegative(),lines:Z(y())}),lz=I({filePath:y().min(1),hunks:Z(az),insertions:W().int().nonnegative(),deletions:W().int().nonnegative(),status:be(["modified","added","deleted"]).optional()});I({canRewind:me(),error:y().optional(),files:Z(lz),totalInsertions:W().int().nonnegative(),totalDeletions:W().int().nonnegative()});I({userMessageIds:Z(y())});I({sessionId:y().min(1),toolSessionId:y().min(1)});I({cwd:y().min(1),toolSessionId:y().min(1),messageUuid:y().min(1),targetCwd:y().min(1).optional()});I({forkedToolSessionId:y().min(1),forkedFilePath:y().min(1)});I({sessionId:y().min(1),toolSessionId:y().min(1),jsonlPath:y().optional()});I({sessionId:y().min(1),afterSeq:W().int().min(-1)});I({sessionId:y().min(1),permissionRequestId:y().min(1),allow:me(),permanent:me().optional(),pattern:y().optional()});I({projectPath:y().min(1)});I({sessionId:y().min(1),limit:W().int().positive().max(5e3).optional(),offset:W().int().nonnegative().optional(),slim:me().optional()});I({cwd:y().min(1),toolSessionId:y().min(1)});I({cwd:y().min(1),toolSessionId:y().min(1),subagentId:y().min(1)});I({cwd:y().min(1).optional(),path:y().optional(),showHidden:me().optional()});I({cwd:y().min(1),path:y().min(1)});I({cwd:y().min(1),tool:y().optional()});I({name:y().min(1),source:be(UB),path:y().optional(),description:y().optional(),plugin:y().optional()});const cz=I({name:y().min(1),source:be(WB),path:y().optional(),description:y().optional(),whenToUse:y().optional(),plugin:y().optional()});I({cwd:y().min(1),tool:y().optional()});I({agents:Z(cz)});I({sessionId:y().optional()});I({sessionId:y().min(1).optional()});I({sessionId:y().min(1),pinned:me()});I({sessionId:y().min(1),archived:me()});I({query:y().min(1),sessionIds:Z(y().min(1)),limit:W().int().positive().max(50).optional()});const uz=I({sessionId:y().min(1),snippet:y()});I({type:G("session:searchContent"),matches:Z(uz)});I({type:G("peerSession:upsert:ok")});I({sessionId:y().min(1)});I({type:G("peerSession:remove:ok")});I({orderedIds:Z(y().min(1)).min(1)});I({cwd:y().min(1)});I({isGitRoot:me(),gitRoot:y().nullable()});I({cwd:y().min(1)});I({branch:y().nullable()});I({cwd:y().min(1)});I({branches:Z(y()),head:y().nullable()});const dz=I({cwd:y().min(1),updatedAt:y().min(1)});I({dirs:Z(dz)});I({type:G("session:question"),sessionId:y().min(1),toolUseId:y().min(1),requestId:y().min(1),questions:Z(iI).min(1)});I({type:G("session:question:cleared"),sessionId:y().min(1),toolUseId:y().min(1),answers:Mr(y(),y()).optional()});I({sessionId:y().min(1),toolUseId:y().min(1),answers:Mr(y(),y())});I({ok:G(!0)});I({sessionId:y().min(1),toolUseId:y().min(1)});I({ok:G(!0)});const sI=I({name:y().min(1),version:y().min(1),instanceId:y().min(1),deviceLabel:y().transform(e=>e.trim().slice(0,64)).optional()});I({type:G("auth"),token:y().min(1),scheme:G("bearer").optional(),clientInfo:sI.optional()});I({type:G("auth:ok"),version:y().min(1).optional(),protocolVersion:W().int().nonnegative().optional()});const hz=I({clientId:y().min(1),connectedAt:W().int().nonnegative(),self:me(),clientInfo:sI.optional()});I({type:G("device:connections:ok"),connections:Z(hz)});I({type:G("tunnel:ready"),url:y().min(1),subdomain:y().min(1)});I({type:G("tunnel:exited"),code:W().int().nullable(),subdomain:y().nullable(),url:y().nullable()});I({type:G("tunnel:unavailable"),reason:y().min(1),failedAt:y().min(1)});const fz=I({sessionId:y().min(1),status:qB,freshSpawn:me(),pendingPermissionRequestIds:Z(y().min(1)),pendingQuestionToolUseIds:Z(y().min(1))});I({type:G("info"),version:y(),protocolVersion:W(),hostname:y(),os:y(),tools:Z(I({id:y(),available:me()})),runningSessions:Z(fz),tokenRole:be(A6).optional(),isLoopback:me().optional(),httpBaseUrl:y().optional(),httpToken:y().optional(),daemonSource:be(["ota","packaged"]).optional(),globalCliVersion:y().nullable().optional()});I({});I({method:y().min(1).optional()});const pz=["allowed","conditional","denied"],mz=be(pz),gz=I({name:y().min(1),status:mz,description:y().min(1),args:Z(I({name:y(),required:me()})).nullable(),argsSchema:Mr(ji()).optional(),reason:y().optional()});I({type:G("meta:methods"),methods:Z(gz)});const Iw=1,vz=I({usedBytes:W().int().nonnegative(),sizeBytes:W().int().positive(),measuredAt:W().int().nonnegative()}).strict();I({volume:vz.nullable()}).strict();const _z=["daemon","main","renderer"],xz=be(_z),yz=["debug","info","warn","error"],bz=be(yz);I({ts:W().int(),source:xz,level:bz,msg:y(),ownerPrincipalId:y(),deviceId:y(),appVersion:y(),daemonVersion:y().optional(),os:y(),meta_json:y().optional(),sessionId:y().optional()});I({v:G(1),visitorId:y().min(1),displayName:y(),provider:y(),iat:W(),exp:W()});const wz=I({visitorId:y(),displayName:y(),avatarUrl:y().optional(),provider:y(),firstSeen:W(),lastSeen:W()});I({visitors:Z(wz)});const Sz=/<system-reminder>此消息来自飞书群成员 (.+?)<\/system-reminder>\s*$/,oI=/<system-reminder>此消息来自 (owner|guest):(.+?)<\/system-reminder>\s*$/,kz="clawd-dispatch-task",Cz="clawd-dispatch-result",Pw=120;function Ez(e){if(!e)return[];const t=[];for(const n of["task","result"]){const r=n==="task"?kz:Cz,i=new RegExp(`<${r}\\b([^>]*)>([\\s\\S]*?)</${r}>`,"gi");for(let s=i.exec(e);s!==null;s=i.exec(e))t.push({at:s.index,block:Nz(n,s[1]??"",s[2]??"")})}return t.sort((n,r)=>n.at-r.at).map(n=>n.block)}function Nz(e,t,n){var c;const r=Lz(t),i=h0(Az(Tm(n,"detail")??n)),s=(c=Tm(n,"brief"))==null?void 0:c.trim(),o=s&&s.length>0?h0(s):Tz(i),a=r.round!==void 0?Number.parseInt(r.round,10):void 0,l=r.status;return{kind:e,dispatchId:r["dispatch-id"]??"",...r.from?{from:r.from}:{},...e==="task"&&a!==void 0&&Number.isFinite(a)?{round:a}:{},...e==="result"&&(l==="success"||l==="failure")?{status:l}:{},brief:o,briefIsDerived:!(s&&s.length>0),detail:i,filePaths:Mz(Tm(n,"files"))}}function Tz(e){const t=e.split(/\n\s*\n/).map(r=>r.trim()).find(r=>r.length>0);if(!t)return"";const n=t.replace(/\s+/g," ");return n.length>Pw?`${n.slice(0,Pw)}…`:n}const Iz="clawd-dispatch-task|clawd-dispatch-result|brief|detail|files",Pz=new RegExp(`<\\\\(\\\\*)(/?)(${Iz})\\b`,"g");function Rz(e){return h0(e)}function h0(e){return e.replace(Pz,"<$1$2$3")}function Tm(e,t){const n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`,"i").exec(e);return n?n[1]??"":null}function Mz(e){return e?e.split(`
|
|
96
|
+
`).map(t=>t.trim()).filter(t=>t.startsWith("- ")).map(t=>t.slice(2).trim()).filter(t=>t.length>0):[]}function Az(e){return e.replace(/^\n/,"").replace(/\n$/,"")}function Lz(e){const t={},n=/([a-z-]+)="([^"]*)"/gi;for(let r=n.exec(e);r!==null;r=n.exec(e))t[r[1]]=Dz(r[2]??"");return t}function Dz(e){return e.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}const f0="-cloud",jz=`codex${f0}`;function Oz(e){return e==="codex"||e===jz}function Bz(e){return typeof e=="string"&&e.length>f0.length&&e.endsWith(f0)}const zz=new Set(["localhost","127.0.0.1","0.0.0.0","::1"]);let Si=null;function $z(){if(Si!==null)return Si;if(typeof window>"u")return Si=!1,!1;if(zz.has(window.location.hostname)||window.location.protocol==="file:")return Si=!0,!0;if(new URLSearchParams(window.location.search).get("debug")==="1"){Si=!0;try{sessionStorage.setItem("debug","1")}catch{}}else try{Si=sessionStorage.getItem("debug")==="1"}catch{Si=!1}return Si}function Me(e,...t){$z()&&console.log(`[${e}][${new Date().toISOString()}]`,...t)}function hd(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 Fz=e=>{const t=[1e3,2e3,4e3,8e3,16e3,3e4];return t[Math.min(e,t.length-1)]},Hz=new Set(["auth:ok","pong","error"]),Rw=new Set(JT.filter(e=>!Hz.has(e)));let Uz=0;const Mw=()=>`r${++Uz}`;function Wz(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??Fz;let u=null,d=!1,f=0,p=null,m=null,v=null,w=null,_=!1,x="disconnected";const b=new Map,S=new Map;let C=null;const k=(O,E)=>{var H;O==="ready"&&(C=E),(H=S.get(O))==null||H.forEach(q=>{try{q(E)}catch{}})},N=O=>{x!==O&&(x=O,k("status",O))},T=(O,E)=>{const H=S.get(O)??new Set;if(H.add(E),S.set(O,H),O==="ready"&&C!==null)try{E(C)}catch{}return()=>H.delete(E)},z=()=>{m&&(clearInterval(m),m=null),v&&(clearTimeout(v),v=null),w&&(clearTimeout(w),w=null)},P=()=>{v&&clearTimeout(v),v=setTimeout(()=>{try{u==null||u.close(4e3,"pong watchdog")}catch{}},a)},B=()=>{m&&clearInterval(m),m=setInterval(()=>{(u==null?void 0:u.readyState)===1&&u.send(JSON.stringify({type:"ping",requestId:Mw()}))},o),P()},A=O=>{for(const[,E]of b)clearTimeout(E.timer),E.reject(new Error(O));b.clear()},R=[],M=()=>{if(R.length===0)return;const O=R.splice(0);for(const E of O)(u==null?void 0:u.readyState)===1&&!_?E.doSend():(clearTimeout(E.timer),E.reject(new Error("NOT_CONNECTED")))},D=O=>{if(R.length===0)return;const E=R.splice(0);for(const H of E)clearTimeout(H.timer),H.reject(new Error(O))},$=()=>{if(d)return;const O=c(f);if(O<0){D("connection closed: not reconnecting");return}k("daemon:reconnecting",{attempt:f+1,nextDelayMs:O,scheduledAt:Date.now()}),p&&clearTimeout(p),p=setTimeout(()=>{f+=1,j()},O)},F=O=>{P();const E=String(O.type??"");if(E==="auth:ok"){Me("daemon-client","auth:ok received → connected",{url:t}),w&&(clearTimeout(w),w=null),_=!1,f=0,N("connected"),k("daemon:connected",{url:t}),B(),M();return}if(E==="pong")return;if(E==="ready"){const q=Number(O.protocolVersion??-1);q!==Iw&&k("daemon:version-mismatch",{daemonProtocol:q,supportedProtocol:Iw}),k("ready",O);return}const H=O.requestId;if(typeof H=="string"&&b.has(H)){const q=b.get(H);if(b.delete(H),clearTimeout(q.timer),E==="error"){const L=String(O.code??"ERR"),re=String(O.message??"unknown");q.reject(new Error(`${L}: ${re}`))}else Rw.has(E)&&k(E,O),q.resolve(O);return}Rw.has(E)&&k(E,O)},j=()=>{p&&(clearTimeout(p),p=null),Me("daemon-client","connect →",{url:t,token:hd(n),attempt:f}),N("connecting");let O;try{O=new WebSocket(t)}catch(E){N("disconnected"),k("daemon:disconnected",{reason:(E==null?void 0:E.message)??"ws constructor failed"}),$();return}u=O,_=!!n,O.onopen=()=>{if(O!==u){Me("daemon-client","onopen → stale (replaced before opened), ignore");return}if(n){Me("daemon-client","onopen → send auth frame",{token:hd(n)});const E={type:"auth",token:n};r!=null&&r.principalId&&(E.selfPrincipalId=r.principalId),r!=null&&r.displayName&&(E.selfDisplayName=r.displayName),i&&(E.clientInfo=i),O.send(JSON.stringify(E)),w=setTimeout(()=>{try{O.close(4001,"auth handshake timeout")}catch{}},l)}else Me("daemon-client","onopen → no token, treat as connected (daemon authMode=none)"),f=0,N("connected"),k("daemon:connected",{url:t}),B(),M()},O.onclose=E=>{if(O!==u){Me("daemon-client","onclose → stale, ignore",{code:E.code,reason:E.reason});return}const H=E.reason||(E.code===1008?"auth failed":`close ${E.code}`);if(Me("daemon-client","onclose →",{code:E.code,reason:H,awaitingAuth:_,manualStop:d}),z(),A(`connection closed: ${H}`),u=null,E.code===4401?N("revoked"):N("disconnected"),k("daemon:disconnected",{reason:H}),E.code===1008||E.code===4401){D(`connection closed: ${H}`);return}d?D(`connection closed: ${H}`):$()},O.onerror=()=>{},O.onmessage=E=>{if(O!==u)return;let H;try{H=JSON.parse(String(E.data))}catch{return}F(H)}};return{start(){d=!1,f=0,j()},stop(){d=!0,p&&(clearTimeout(p),p=null),z();try{u==null||u.close(1e3,"shutdown")}catch{}u=null,A("shutdown"),D("shutdown"),N("disconnected")},switchProfile(O){Me("daemon-client","switchProfile →",{url:O.url,token:hd(O.authToken)},"prev:",{url:t,token:hd(n)}),t=O.url,n=O.authToken,O.selfIdentity!==void 0&&(r=O.selfIdentity),f=0,d=!0,p&&(clearTimeout(p),p=null),z(),A("switch profile"),D("switch profile");try{u==null||u.close(1e3,"switch profile")}catch{}u=null,d=!1,j()},request(O,E){return new Promise((H,q)=>{const L=Mw(),re=setTimeout(()=>{b.delete(L);const K=R.findIndex(ge=>ge.timer===re);K>=0&&R.splice(K,1),q(new Error(`request timeout: ${O}`))},s),se=()=>{b.set(L,{resolve:K=>H(K),reject:q,timer:re}),u.send(JSON.stringify({...E,type:O,requestId:L}))};(u==null?void 0:u.readyState)===1&&!_?se():d||u==null&&p==null?(clearTimeout(re),q(new Error("NOT_CONNECTED"))):R.push({doSend:se,reject:q,timer:re})})},on:T,get isOpen(){return(u==null?void 0:u.readyState)===1&&!_},get url(){return t},getStatus(){return x}}}function Vz(e){const t=e.trim(),n=t.indexOf("#");if(n<0)return{url:t};const r=t.slice(0,n),i=t.slice(n+1),o=new URLSearchParams(i).get("token")??void 0;return{url:r,token:o??void 0}}function qz(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 Kz(e){return e?{id:e.id,mode:e.mode,url:e.url,token:qz(e.token),name:e.name}:null}function fd(e){return e?Array.isArray(e)?e.map(Kz):{_notArray:typeof e,_value:e}:null}function Aw(e){return e==null?null:typeof e=="object"&&"value"in e?e.value:e}const Gz="ws://127.0.0.1:18790",Lw="daemon:profiles",Dw="daemon:active-profile-id";function Yz(){return Math.random().toString(36).slice(2,10)}function Xz(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 aI(e){let t={profiles:[],activeId:null},n=!1,r=null;const i=new Set,s=()=>{for(const l of i)l(t)},o=async()=>{Me("profile-store","persist →",fd(t.profiles),"active:",t.activeId),await e.kv.set(Lw,t.profiles),await e.kv.set(Dw,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(Lw);c=Aw(d)}catch{c=null}let u=null;try{const d=await e.kv.get(Dw);u=Aw(d)??null}catch{u=null}if(Me("profile-store","ensureLoaded read kv →","profiles:",fd(c),"activeId:",u),Array.isArray(c)&&c.length>0){const d=c.filter(Xz),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,Me("profile-store","ensureLoaded → use kv profiles",fd(d),"active:",f);return}t={profiles:[{id:"default",name:"本机",mode:"localhost",url:Gz}],activeId:"default"},Me("profile-store","ensureLoaded → fallback synthesized default (NO token)",fd(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 w;await a();let c=l.url,u=l.token;if(c&&c.includes("#")){const _=Vz(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??Yz(),m={id:p,name:((w=l.name)==null?void 0:w.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 jw="clawd.client-instance-id";let Qz={name:"clawd-web",version:"unknown"};function Zz(){let e=null;try{e=localStorage.getItem(jw),e||(e=crypto.randomUUID(),localStorage.setItem(jw,e))}catch{e=e??crypto.randomUUID()}return{...Qz,instanceId:e}}function Ow(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 lI=g.createContext(null);function Jz({host:e,children:t}){const[n,r]=g.useState(null),i=g.useMemo(()=>async()=>{const s=aI(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 Me("daemon-context","bootstrap → createDaemonClient",{id:a.id,url:a.url,token:Ow(a.token)}),{client:Wz({url:a.url,authToken:a.token,clientInfo:Zz()}),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){Me("daemon-context","subscribe → no active profile, skip switchProfile");return}Me("daemon-context","subscribe → switchProfile",{id:c.id,url:c.url,token:Ow(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(lI.Provider,{value:n,children:t}):null}function Yi(){const e=g.useContext(lI);if(!e)throw new Error("useDaemonClient must be used inside <DaemonProvider>");return e.client}function e$(){const e=Yi(),[t,n]=g.useState(void 0);return g.useEffect(()=>e.on("ready",i=>{const s=i.mode,o=s==="tui"?"tui":"sdk";Me("daemon-context","useDaemonMode ready.mode =",{rawMode:s,resolved:o}),n(o)}),[e]),t}function t$(){const e=Yi(),[t,n]=g.useState(void 0);return g.useEffect(()=>e.on("ready",i=>{const s=i;s.version!==void 0&&n(s.principalKind==="guest"?"guest":"owner")}),[e]),t}const cI=g.createContext(null);function n$({cache:e,children:t}){return g.createElement(cI.Provider,{value:e},t)}function $o(){const e=g.useContext(cI);if(!e)throw new Error("useCache must be used inside <CacheProvider>");return e}function Ui(e){const t=$o(),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 uI={actionsLevel:"none",httpBaseUrl:null,httpToken:null},dI=g.createContext(uI);function cp(){return g.useContext(dI)}function r$(e){return e!=null&&e.httpBaseUrl?{actionsLevel:e.tokenRole==="owner"?"owner":"none",httpBaseUrl:e.httpBaseUrl,httpToken:e.httpToken??null}:uI}function i$(){const e=Ui("daemon-info");return g.useMemo(()=>r$(e),[e])}function s$({children:e}){const t=i$();return Ge.createElement(dI.Provider,{value:t},e)}function o$(e,t,n){if(!e.httpBaseUrl)return null;const r=encodeURIComponent(n);return`${e.httpBaseUrl}/session/${encodeURIComponent(t.sessionId)}/files?path=${r}`}function a$(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 l$(){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 c$(e){return{request:(t,n)=>e.request(t,n),onFrame(t){const n=[];for(const r of JT)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}}}function hI(e){const t=(e??"claude")==="claude";return{rewind:t,subagents:t,tui:t,observe:t,fileSharing:t,fork:t}}const u$=e=>({tool:e,models:[{id:"",label:"未指定",contextWindowSize:2e5,default:!0}],permissionModes:[{id:"",label:"未指定"}],configSchema:[],features:hI(e)});function d$(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,()=>u$(r))}},o=e.onConnect(()=>{s()});return s(),()=>{i=!0,o()}}}}function h$(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 eu={sessionId:null,events:[],lastSeq:-1,pendingPermissions:[],status:"idle",pendingQuestions:{},queued:[]};function Im(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 fI(e,t,n){const r=n===void 0?e.sessionId:n;switch(t.type){case"session:change":return{...eu,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=Im(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:queue":return!r||t.sessionId!==r?e:{...e,queued:t.items};case"session:events":{if(!r||t.sessionId!==r)return e;const i=t.events.map(o=>o.event),s=i.reduce((o,a)=>Im(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)=>Im(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{...eu,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 f$="session/";function p$(e){return{sid:e.slice(f$.length)}}const m$=new Set(eI);function pI(e){return m$.has(e)}function Bw(e){return pI(e)?e:"idle"}function g$(e,t){return{start(n){const{sid:r}=p$(n);let i=!1,s=-1;const o=f=>{t(n,p=>fI(p??eu,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??[],w=m.latestSeq??-1;if(f==="baseline")o({type:"session:events",sessionId:r,events:v,latestSeq:w}),s=w;else{const _=m.bufferStartSeq??0,x=w<p||_>p+1;o({type:x?"session:events":"session:events:append",sessionId:r,events:v,latestSeq:w}),s=Math.max(s,w)}}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:Bw(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;Me("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(!pI(m.status)){Me("session-events","push session:status drop",{sid:r,status:m.status});return}Me("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;Me("session-events","push session:cleared",{sid:r}),o({type:"session:change",sessionId:r}),s=-1}else if(f==="session:queue"){const m=p;if(m.sessionId!==r)return;Me("session-events","push session:queue",{sid:r,count:m.items.length}),o({type:"session:queue",sessionId:m.sessionId,items:m.items})}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:Bw(v.status)}))})}),d=e.onConnect(()=>{c()});return e.isConnected&&c(),()=>{i=!0,u(),d(),e.request("session:unsubscribe",{sessionId:r}).catch(()=>{})}}}}const v$=new Set(["tunnel:ready","tunnel:exited","tunnel:unavailable"]);function _$(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=>{v$.has(a)&&i()});return i(),()=>{r=!0,s(),o()}}}}function x$(){return{start(){return()=>{}}}}function y$(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 b$(e){const t=c$(e),n=l$();let r=null;const i=(o,a)=>{r==null||r.setData(o,a)};n.register(/^capabilities\//,d$(t,i)),n.register(/^sessions$/,h$(t,i)),n.register(/^session\//,g$(t,i)),n.register(/^personas$/,y$(t,i)),n.register(/^persona-detail\//,x$()),n.register(/^daemon-info$/,_$(t,i));const s=a$({onFirstObserver:o=>{o&&n.activate(o)},onLastObserver:o=>{o&&n.deactivate(o)}});return r=s,{cache:s,channel:t}}class Gx{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)}projectList(){return this.client.request("project:list")}projectCreate(t){return this.client.request("project:create",{...t.path?{path:t.path}:{},...t.name?{name:t.name}:{}})}projectPatch(t){return this.client.request("project:patch",t)}projectReveal(t){return this.client.request("project:reveal",{path: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,r){return this.client.request("session:send",{sessionId:t,text:n,...r!=null&&r.queueWhileRunning?{queueWhileRunning:!0}:{}})}sessionDequeue(t,n){return this.client.request("session:dequeue",{sessionId:t,...n?{id: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})}searchSessionContent(t){return this.client.request("session:searchContent",t)}archiveSession(t,n){return this.client.request("session:archive",{sessionId:t,archived: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})}larkBotBindManual(t,n,r){return this.client.request("larkBot:bindManual",{personaId:t,appId:n,appSecret:r})}larkBotUnbind(t){return this.client.request("larkBot:unbind",{personaId:t})}larkBotStatus(t){return this.client.request("larkBot:status",{personaId:t})}toolsProbe(){return this.client.request("tools:probe",{})}sessionExternalScan(){return this.client.request("session:externalScan",{})}sessionImportExternal(t){return this.client.request("session:importExternal",t)}onboardingComplete(){return this.client.request("onboarding:complete",{})}onboardingIosInterest(){return this.client.request("onboarding:iosInterest",{})}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",n){return this.client.request("capabilities:get",{tool:t,...n!=null&&n.refresh?{refresh:!0}:{}})}engineStatus(t){return this.client.request("engine:status",{tool:t})}engineConnectPool(t){return this.client.request("engine:connectPool",{apiKey:t})}shiftList(){return this.client.request("shift:list")}deployGet(t){return this.client.request("deploy:get",{personaId:t})}deployScan(t,n){return this.client.request("deploy:scan",{personaId:t,...n?{scanBase:n}:{}})}deployPatch(t,n,r){return this.client.request("deploy:patch",{personaId:t,scanId:n,patch:r})}deployPutSecret(t,n,r,i){return this.client.request("deploy:putSecret",{personaId:t,scanId:n,name:r,values:i})}deployRerunJob(t,n){return this.client.request("deploy:rerunJob",{personaId:t,jobId:n})}deployRelease(t,n){return this.client.request("deploy:release",{personaId:t,scanId:n})}cloudConnectorsList(t){return this.client.request("cloud:connectors:list",{personaId:t})}cloudVolumeGet(){return this.client.request("cloud:volume:get",{})}cloudConnectorFill(t,n,r){return this.client.request("cloud:connectors:fill",{personaId:t,name:n,values:r})}channelList(){return this.client.request("channel:list")}channelCreate(t){return this.client.request("channel:create",t)}channelUpdate(t){return this.client.request("channel:update",t)}channelDelete(t){return this.client.request("channel:delete",t)}topicList(t){return this.client.request("topic:list",t)}topicGet(t){return this.client.request("topic:get",t)}topicCreate(t){return this.client.request("topic:create",t)}topicClose(t){return this.client.request("topic:close",t)}topicRename(t){return this.client.request("topic:rename",t)}topicDelete(t){return this.client.request("topic:delete",t)}personaDispatchList(t){return this.client.request("personaDispatch:list",t)}githubAuthGet(){return this.client.request("githubAuth:get")}githubAuthOauthStart(t){return this.client.request("githubAuth:oauthStart",t?{returnTo:t}:{})}githubAuthAuthorize(t){return this.client.request("githubAuth:authorize",{token:t})}githubStatus(){return this.client.request("github:status")}githubPrList(t){return this.client.request("github:prList",{role:t})}githubPrDetail(t){return this.client.request("github:prDetail",{...t})}githubPrMerge(t){return this.client.request("github:prMerge",{...t})}githubPrComment(t){return this.client.request("github:prComment",{...t})}githubPrSetReady(t){return this.client.request("github:prSetReady",{...t})}githubCollaborators(t){return this.client.request("github:collaborators",{...t})}githubPrRequestReviewers(t){return this.client.request("github:prRequestReviewers",{...t})}}function w$(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,daemonSource:c.daemonSource,globalCliVersion:c.globalCliVersion,onboardingCompletedAt:c.onboardingCompletedAt}))}),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,daemonSource:u.kind==="connected"?u.daemonSource:void 0,globalCliVersion:u.kind==="connected"?u.globalCliVersion:void 0,onboardingCompletedAt:u.kind==="connected"?u.onboardingCompletedAt: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 S$(e){const t=$o(),n=Ui(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 xl(){const e=Yi();return g.useMemo(()=>new Gx(e),[e])}function mI(e){return{personaId:e.personaId,label:e.label,model:e.model,effort:e.effort,tool:e.tool,...e.size!==void 0?{size:e.size}:{},public:e.public,createdAt:e.createdAt,updatedAt:e.updatedAt,...e.cloud?{cloud:e.cloud}:{}}}function gI(){const e=$o(),t=xl(),n=Ui("personas")??[],r=g.useMemo(()=>n.map(s=>mI(s)),[n]),i=g.useCallback(async()=>{const s=await t.personaList();e.setData("personas",()=>s.personas??[])},[t,e]);return{personas:r,raw:n,loaded:Ui("personas")!==void 0,refresh:i}}function vI(e){const{raw:t}=gI(),n=$o(),r=xl(),i=e?t.find(a=>a.personaId===e)??null:null,s=i?mI(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 k$(e){const t=xl(),n=$o(),r=e?`persona-detail/${e}`:"",i=Ui(r),s=g.useCallback(async()=>{const o={personality:"",personalityLocal:"",personalityManaged:!1,skills:[],plugins:[],sandboxSettings:null,codexSandbox:null};if(!e)return o;let a=null;try{a=await t.personaGet(e)}catch(c){Me("personas","personaGet failed → empty detail",{personaId:e,err:c}),a=null}const l=a?{personality:a.personality??"",personalityLocal:a.personalityLocal??"",personalityManaged:a.personalityManaged??!1,skills:a.skills??[],plugins:a.plugins??[],sandboxSettings:a.sandboxSettings??null,codexSandbox:a.codexSandbox??null}:o;return n.setData(r,()=>l),l},[t,n,e,r]);return g.useEffect(()=>{e&&s()},[e,s]),{personality:(i==null?void 0:i.personality)??"",personalityLocal:(i==null?void 0:i.personalityLocal)??"",personalityManaged:(i==null?void 0:i.personalityManaged)??!1,skills:(i==null?void 0:i.skills)??[],plugins:(i==null?void 0:i.plugins)??[],sandboxSettings:(i==null?void 0:i.sandboxSettings)??null,codexSandbox:(i==null?void 0:i.codexSandbox)??null,loaded:i!==void 0,refresh:s}}function _I(){const e=$o(),t=xl();return g.useCallback(async()=>{const n=await t.personaList();e.setData("personas",()=>n.personas??[])},[e,t])}function C$(){const e=xl(),t=_I();return g.useCallback(async(n,r)=>{const i=await e.personaUpdate(n,r);return await t(),i},[e,t])}function E$(){const e=xl(),t=_I();return g.useCallback(async n=>{await e.personaDelete(n),await t()},[e,t])}const zw="clawd:sidebar:tree-collapsed";function N$(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function T$(e){const t=N$(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 I$(){const e=Cx(),[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(zw);if(l)return;n(T$(c))}catch{}})(),()=>{l=!0}},[e]);const i=g.useCallback(l=>{e.kv.set(zw,[...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 Yx=g.createContext(null);function P$(){const e=g.useContext(Yx);if(!e)throw new Error("SessionTreeCollapsedContext.Provider missing — wrap SessionTreeNode tree with <SessionTreeCollapsedContext.Provider value={useSessionTreeCollapsed()}>");return e}/**
|
|
97
97
|
* @license lucide-react v0.577.0 - ISC
|
|
98
98
|
*
|
|
99
99
|
* This source code is licensed under the ISC license.
|
|
@@ -468,7 +468,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
468
468
|
*
|
|
469
469
|
* This source code is licensed under the ISC license.
|
|
470
470
|
* See the LICENSE file in the root directory of this source tree.
|
|
471
|
-
*/const TF=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],IF=ue("zap",TF);function II(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=II(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function PI(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=II(e))&&(r&&(r+=" "),r+=t);return r}const PF=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},RF=(e,t)=>({classGroupId:e,validator:t}),RI=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),nf="-",Kw=[],MF="arbitrary..",AF=e=>{const t=DF(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return LF(o);const a=o.split(nf),l=a[0]===""&&a.length>1?1:0;return MI(a,l,t)},getConflictingClassGroupIds:(o,a)=>{if(a){const l=r[o],c=n[o];return l?c?PF(c,l):l:c||Kw}return n[o]||Kw}}},MI=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const i=e[t],s=n.nextPart.get(i);if(s){const c=MI(e,t+1,s);if(c)return c}const o=n.validators;if(o===null)return;const a=t===0?e.join(nf):e.slice(t).join(nf),l=o.length;for(let c=0;c<l;c++){const u=o[c];if(u.validator(a))return u.classGroupId}},LF=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?MF+r:void 0})(),DF=e=>{const{theme:t,classGroups:n}=e;return jF(n,t)},jF=(e,t)=>{const n=RI();for(const r in e){const i=e[r];ty(i,n,r,t)}return n},ty=(e,t,n,r)=>{const i=e.length;for(let s=0;s<i;s++){const o=e[s];OF(o,t,n,r)}},OF=(e,t,n,r)=>{if(typeof e=="string"){BF(e,t,n);return}if(typeof e=="function"){zF(e,t,n,r);return}$F(e,t,n,r)},BF=(e,t,n)=>{const r=e===""?t:AI(t,e);r.classGroupId=n},zF=(e,t,n,r)=>{if(FF(e)){ty(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(RF(n,e))},$F=(e,t,n,r)=>{const i=Object.entries(e),s=i.length;for(let o=0;o<s;o++){const[a,l]=i[o];ty(l,AI(t,a),n,r)}},AI=(e,t)=>{let n=e;const r=t.split(nf),i=r.length;for(let s=0;s<i;s++){const o=r[s];let a=n.nextPart.get(o);a||(a=RI(),n.nextPart.set(o,a)),n=a}return n},FF=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,HF=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const i=(s,o)=>{n[s]=o,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(s){let o=n[s];if(o!==void 0)return o;if((o=r[s])!==void 0)return i(s,o),o},set(s,o){s in n?n[s]=o:i(s,o)}}},g0="!",Gw=":",UF=[],Yw=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),WF=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=i=>{const s=[];let o=0,a=0,l=0,c;const u=i.length;for(let v=0;v<u;v++){const w=i[v];if(o===0&&a===0){if(w===Gw){s.push(i.slice(l,v)),l=v+1;continue}if(w==="/"){c=v;continue}}w==="["?o++:w==="]"?o--:w==="("?a++:w===")"&&a--}const d=s.length===0?i:i.slice(l);let f=d,p=!1;d.endsWith(g0)?(f=d.slice(0,-1),p=!0):d.startsWith(g0)&&(f=d.slice(1),p=!0);const m=c&&c>l?c-l:void 0;return Yw(s,p,f,m)};if(t){const i=t+Gw,s=r;r=o=>o.startsWith(i)?s(o.slice(i.length)):Yw(UF,!1,o,void 0,!0)}if(n){const i=r;r=s=>n({className:s,parseClassName:i})}return r},VF=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let i=[];for(let s=0;s<n.length;s++){const o=n[s],a=o[0]==="[",l=t.has(o);a||l?(i.length>0&&(i.sort(),r.push(...i),i=[]),r.push(o)):i.push(o)}return i.length>0&&(i.sort(),r.push(...i)),r}},qF=e=>({cache:HF(e.cacheSize),parseClassName:WF(e),sortModifiers:VF(e),...AF(e)}),KF=/\s+/,GF=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:s}=t,o=[],a=e.trim().split(KF);let l="";for(let c=a.length-1;c>=0;c-=1){const u=a[c],{isExternal:d,modifiers:f,hasImportantModifier:p,baseClassName:m,maybePostfixModifierPosition:v}=n(u);if(d){l=u+(l.length>0?" "+l:l);continue}let w=!!v,_=r(w?m.substring(0,v):m);if(!_){if(!w){l=u+(l.length>0?" "+l:l);continue}if(_=r(m),!_){l=u+(l.length>0?" "+l:l);continue}w=!1}const x=f.length===0?"":f.length===1?f[0]:s(f).join(":"),b=p?x+g0:x,S=b+_;if(o.indexOf(S)>-1)continue;o.push(S);const C=i(_,w);for(let k=0;k<C.length;++k){const N=C[k];o.push(b+N)}l=u+(l.length>0?" "+l:l)}return l},YF=(...e)=>{let t=0,n,r,i="";for(;t<e.length;)(n=e[t++])&&(r=LI(n))&&(i&&(i+=" "),i+=r);return i},LI=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=LI(e[r]))&&(n&&(n+=" "),n+=t);return n},XF=(e,...t)=>{let n,r,i,s;const o=l=>{const c=t.reduce((u,d)=>d(u),e());return n=qF(c),r=n.cache.get,i=n.cache.set,s=a,a(l)},a=l=>{const c=r(l);if(c)return c;const u=GF(l,n);return i(l,u),u};return s=o,(...l)=>s(YF(...l))},QF=[],qt=e=>{const t=n=>n[e]||QF;return t.isThemeGetter=!0,t},DI=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,jI=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ZF=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,JF=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,e9=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,t9=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,n9=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,r9=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,is=e=>ZF.test(e),ze=e=>!!e&&!Number.isNaN(Number(e)),ss=e=>!!e&&Number.isInteger(Number(e)),Pm=e=>e.endsWith("%")&&ze(e.slice(0,-1)),ki=e=>JF.test(e),OI=()=>!0,i9=e=>e9.test(e)&&!t9.test(e),ny=()=>!1,s9=e=>n9.test(e),o9=e=>r9.test(e),a9=e=>!fe(e)&&!pe(e),l9=e=>Vs(e,$I,ny),fe=e=>DI.test(e),Js=e=>Vs(e,FI,i9),Xw=e=>Vs(e,g9,ze),c9=e=>Vs(e,UI,OI),u9=e=>Vs(e,HI,ny),Qw=e=>Vs(e,BI,ny),d9=e=>Vs(e,zI,o9),pd=e=>Vs(e,WI,s9),pe=e=>jI.test(e),Hl=e=>Ho(e,FI),h9=e=>Ho(e,HI),Zw=e=>Ho(e,BI),f9=e=>Ho(e,$I),p9=e=>Ho(e,zI),md=e=>Ho(e,WI,!0),m9=e=>Ho(e,UI,!0),Vs=(e,t,n)=>{const r=DI.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Ho=(e,t,n=!1)=>{const r=jI.exec(e);return r?r[1]?t(r[1]):n:!1},BI=e=>e==="position"||e==="percentage",zI=e=>e==="image"||e==="url",$I=e=>e==="length"||e==="size"||e==="bg-size",FI=e=>e==="length",g9=e=>e==="number",HI=e=>e==="family-name",UI=e=>e==="number"||e==="weight",WI=e=>e==="shadow",v9=()=>{const e=qt("color"),t=qt("font"),n=qt("text"),r=qt("font-weight"),i=qt("tracking"),s=qt("leading"),o=qt("breakpoint"),a=qt("container"),l=qt("spacing"),c=qt("radius"),u=qt("shadow"),d=qt("inset-shadow"),f=qt("text-shadow"),p=qt("drop-shadow"),m=qt("blur"),v=qt("perspective"),w=qt("aspect"),_=qt("ease"),x=qt("animate"),b=()=>["auto","avoid","all","avoid-page","page","left","right","column"],S=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],C=()=>[...S(),pe,fe],k=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],T=()=>[pe,fe,l],z=()=>[is,"full","auto",...T()],P=()=>[ss,"none","subgrid",pe,fe],B=()=>["auto",{span:["full",ss,pe,fe]},ss,pe,fe],A=()=>[ss,"auto",pe,fe],R=()=>["auto","min","max","fr",pe,fe],M=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],D=()=>["start","end","center","stretch","center-safe","end-safe"],$=()=>["auto",...T()],F=()=>[is,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],j=()=>[is,"screen","full","dvw","lvw","svw","min","max","fit",...T()],O=()=>[is,"screen","full","lh","dvh","lvh","svh","min","max","fit",...T()],E=()=>[e,pe,fe],H=()=>[...S(),Zw,Qw,{position:[pe,fe]}],q=()=>["no-repeat",{repeat:["","x","y","space","round"]}],L=()=>["auto","cover","contain",f9,l9,{size:[pe,fe]}],re=()=>[Pm,Hl,Js],se=()=>["","none","full",c,pe,fe],K=()=>["",ze,Hl,Js],me=()=>["solid","dashed","dotted","double"],Re=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ce=()=>[ze,Pm,Zw,Qw],Le=()=>["","none",m,pe,fe],Oe=()=>["none",ze,pe,fe],Ae=()=>["none",ze,pe,fe],_e=()=>[ze,pe,fe],Qe=()=>[is,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ki],breakpoint:[ki],color:[OI],container:[ki],"drop-shadow":[ki],ease:["in","out","in-out"],font:[a9],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ki],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ki],shadow:[ki],spacing:["px",ze],text:[ki],"text-shadow":[ki],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",is,fe,pe,w]}],container:["container"],columns:[{columns:[ze,fe,pe,a]}],"break-after":[{"break-after":b()}],"break-before":[{"break-before":b()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:C()}],overflow:[{overflow:k()}],"overflow-x":[{"overflow-x":k()}],"overflow-y":[{"overflow-y":k()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:z()}],"inset-x":[{"inset-x":z()}],"inset-y":[{"inset-y":z()}],start:[{"inset-s":z(),start:z()}],end:[{"inset-e":z(),end:z()}],"inset-bs":[{"inset-bs":z()}],"inset-be":[{"inset-be":z()}],top:[{top:z()}],right:[{right:z()}],bottom:[{bottom:z()}],left:[{left:z()}],visibility:["visible","invisible","collapse"],z:[{z:[ss,"auto",pe,fe]}],basis:[{basis:[is,"full","auto",a,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ze,is,"auto","initial","none",fe]}],grow:[{grow:["",ze,pe,fe]}],shrink:[{shrink:["",ze,pe,fe]}],order:[{order:[ss,"first","last","none",pe,fe]}],"grid-cols":[{"grid-cols":P()}],"col-start-end":[{col:B()}],"col-start":[{"col-start":A()}],"col-end":[{"col-end":A()}],"grid-rows":[{"grid-rows":P()}],"row-start-end":[{row:B()}],"row-start":[{"row-start":A()}],"row-end":[{"row-end":A()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":R()}],"auto-rows":[{"auto-rows":R()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...M(),"normal"]}],"justify-items":[{"justify-items":[...D(),"normal"]}],"justify-self":[{"justify-self":["auto",...D()]}],"align-content":[{content:["normal",...M()]}],"align-items":[{items:[...D(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...D(),{baseline:["","last"]}]}],"place-content":[{"place-content":M()}],"place-items":[{"place-items":[...D(),"baseline"]}],"place-self":[{"place-self":["auto",...D()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pbs:[{pbs:T()}],pbe:[{pbe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:$()}],mx:[{mx:$()}],my:[{my:$()}],ms:[{ms:$()}],me:[{me:$()}],mbs:[{mbs:$()}],mbe:[{mbe:$()}],mt:[{mt:$()}],mr:[{mr:$()}],mb:[{mb:$()}],ml:[{ml:$()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],"inline-size":[{inline:["auto",...j()]}],"min-inline-size":[{"min-inline":["auto",...j()]}],"max-inline-size":[{"max-inline":["none",...j()]}],"block-size":[{block:["auto",...O()]}],"min-block-size":[{"min-block":["auto",...O()]}],"max-block-size":[{"max-block":["none",...O()]}],w:[{w:[a,"screen",...F()]}],"min-w":[{"min-w":[a,"screen","none",...F()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[o]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh",...F()]}],"font-size":[{text:["base",n,Hl,Js]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,m9,c9]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Pm,fe]}],"font-family":[{font:[h9,u9,t]}],"font-features":[{"font-features":[fe]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,pe,fe]}],"line-clamp":[{"line-clamp":[ze,"none",pe,Xw]}],leading:[{leading:[s,...T()]}],"list-image":[{"list-image":["none",pe,fe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",pe,fe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:E()}],"text-color":[{text:E()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...me(),"wavy"]}],"text-decoration-thickness":[{decoration:[ze,"from-font","auto",pe,Js]}],"text-decoration-color":[{decoration:E()}],"underline-offset":[{"underline-offset":[ze,"auto",pe,fe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",pe,fe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",pe,fe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:H()}],"bg-repeat":[{bg:q()}],"bg-size":[{bg:L()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ss,pe,fe],radial:["",pe,fe],conic:[ss,pe,fe]},p9,d9]}],"bg-color":[{bg:E()}],"gradient-from-pos":[{from:re()}],"gradient-via-pos":[{via:re()}],"gradient-to-pos":[{to:re()}],"gradient-from":[{from:E()}],"gradient-via":[{via:E()}],"gradient-to":[{to:E()}],rounded:[{rounded:se()}],"rounded-s":[{"rounded-s":se()}],"rounded-e":[{"rounded-e":se()}],"rounded-t":[{"rounded-t":se()}],"rounded-r":[{"rounded-r":se()}],"rounded-b":[{"rounded-b":se()}],"rounded-l":[{"rounded-l":se()}],"rounded-ss":[{"rounded-ss":se()}],"rounded-se":[{"rounded-se":se()}],"rounded-ee":[{"rounded-ee":se()}],"rounded-es":[{"rounded-es":se()}],"rounded-tl":[{"rounded-tl":se()}],"rounded-tr":[{"rounded-tr":se()}],"rounded-br":[{"rounded-br":se()}],"rounded-bl":[{"rounded-bl":se()}],"border-w":[{border:K()}],"border-w-x":[{"border-x":K()}],"border-w-y":[{"border-y":K()}],"border-w-s":[{"border-s":K()}],"border-w-e":[{"border-e":K()}],"border-w-bs":[{"border-bs":K()}],"border-w-be":[{"border-be":K()}],"border-w-t":[{"border-t":K()}],"border-w-r":[{"border-r":K()}],"border-w-b":[{"border-b":K()}],"border-w-l":[{"border-l":K()}],"divide-x":[{"divide-x":K()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":K()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...me(),"hidden","none"]}],"divide-style":[{divide:[...me(),"hidden","none"]}],"border-color":[{border:E()}],"border-color-x":[{"border-x":E()}],"border-color-y":[{"border-y":E()}],"border-color-s":[{"border-s":E()}],"border-color-e":[{"border-e":E()}],"border-color-bs":[{"border-bs":E()}],"border-color-be":[{"border-be":E()}],"border-color-t":[{"border-t":E()}],"border-color-r":[{"border-r":E()}],"border-color-b":[{"border-b":E()}],"border-color-l":[{"border-l":E()}],"divide-color":[{divide:E()}],"outline-style":[{outline:[...me(),"none","hidden"]}],"outline-offset":[{"outline-offset":[ze,pe,fe]}],"outline-w":[{outline:["",ze,Hl,Js]}],"outline-color":[{outline:E()}],shadow:[{shadow:["","none",u,md,pd]}],"shadow-color":[{shadow:E()}],"inset-shadow":[{"inset-shadow":["none",d,md,pd]}],"inset-shadow-color":[{"inset-shadow":E()}],"ring-w":[{ring:K()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:E()}],"ring-offset-w":[{"ring-offset":[ze,Js]}],"ring-offset-color":[{"ring-offset":E()}],"inset-ring-w":[{"inset-ring":K()}],"inset-ring-color":[{"inset-ring":E()}],"text-shadow":[{"text-shadow":["none",f,md,pd]}],"text-shadow-color":[{"text-shadow":E()}],opacity:[{opacity:[ze,pe,fe]}],"mix-blend":[{"mix-blend":[...Re(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Re()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[ze]}],"mask-image-linear-from-pos":[{"mask-linear-from":ce()}],"mask-image-linear-to-pos":[{"mask-linear-to":ce()}],"mask-image-linear-from-color":[{"mask-linear-from":E()}],"mask-image-linear-to-color":[{"mask-linear-to":E()}],"mask-image-t-from-pos":[{"mask-t-from":ce()}],"mask-image-t-to-pos":[{"mask-t-to":ce()}],"mask-image-t-from-color":[{"mask-t-from":E()}],"mask-image-t-to-color":[{"mask-t-to":E()}],"mask-image-r-from-pos":[{"mask-r-from":ce()}],"mask-image-r-to-pos":[{"mask-r-to":ce()}],"mask-image-r-from-color":[{"mask-r-from":E()}],"mask-image-r-to-color":[{"mask-r-to":E()}],"mask-image-b-from-pos":[{"mask-b-from":ce()}],"mask-image-b-to-pos":[{"mask-b-to":ce()}],"mask-image-b-from-color":[{"mask-b-from":E()}],"mask-image-b-to-color":[{"mask-b-to":E()}],"mask-image-l-from-pos":[{"mask-l-from":ce()}],"mask-image-l-to-pos":[{"mask-l-to":ce()}],"mask-image-l-from-color":[{"mask-l-from":E()}],"mask-image-l-to-color":[{"mask-l-to":E()}],"mask-image-x-from-pos":[{"mask-x-from":ce()}],"mask-image-x-to-pos":[{"mask-x-to":ce()}],"mask-image-x-from-color":[{"mask-x-from":E()}],"mask-image-x-to-color":[{"mask-x-to":E()}],"mask-image-y-from-pos":[{"mask-y-from":ce()}],"mask-image-y-to-pos":[{"mask-y-to":ce()}],"mask-image-y-from-color":[{"mask-y-from":E()}],"mask-image-y-to-color":[{"mask-y-to":E()}],"mask-image-radial":[{"mask-radial":[pe,fe]}],"mask-image-radial-from-pos":[{"mask-radial-from":ce()}],"mask-image-radial-to-pos":[{"mask-radial-to":ce()}],"mask-image-radial-from-color":[{"mask-radial-from":E()}],"mask-image-radial-to-color":[{"mask-radial-to":E()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":S()}],"mask-image-conic-pos":[{"mask-conic":[ze]}],"mask-image-conic-from-pos":[{"mask-conic-from":ce()}],"mask-image-conic-to-pos":[{"mask-conic-to":ce()}],"mask-image-conic-from-color":[{"mask-conic-from":E()}],"mask-image-conic-to-color":[{"mask-conic-to":E()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:H()}],"mask-repeat":[{mask:q()}],"mask-size":[{mask:L()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",pe,fe]}],filter:[{filter:["","none",pe,fe]}],blur:[{blur:Le()}],brightness:[{brightness:[ze,pe,fe]}],contrast:[{contrast:[ze,pe,fe]}],"drop-shadow":[{"drop-shadow":["","none",p,md,pd]}],"drop-shadow-color":[{"drop-shadow":E()}],grayscale:[{grayscale:["",ze,pe,fe]}],"hue-rotate":[{"hue-rotate":[ze,pe,fe]}],invert:[{invert:["",ze,pe,fe]}],saturate:[{saturate:[ze,pe,fe]}],sepia:[{sepia:["",ze,pe,fe]}],"backdrop-filter":[{"backdrop-filter":["","none",pe,fe]}],"backdrop-blur":[{"backdrop-blur":Le()}],"backdrop-brightness":[{"backdrop-brightness":[ze,pe,fe]}],"backdrop-contrast":[{"backdrop-contrast":[ze,pe,fe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",ze,pe,fe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ze,pe,fe]}],"backdrop-invert":[{"backdrop-invert":["",ze,pe,fe]}],"backdrop-opacity":[{"backdrop-opacity":[ze,pe,fe]}],"backdrop-saturate":[{"backdrop-saturate":[ze,pe,fe]}],"backdrop-sepia":[{"backdrop-sepia":["",ze,pe,fe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",pe,fe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[ze,"initial",pe,fe]}],ease:[{ease:["linear","initial",_,pe,fe]}],delay:[{delay:[ze,pe,fe]}],animate:[{animate:["none",x,pe,fe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,pe,fe]}],"perspective-origin":[{"perspective-origin":C()}],rotate:[{rotate:Oe()}],"rotate-x":[{"rotate-x":Oe()}],"rotate-y":[{"rotate-y":Oe()}],"rotate-z":[{"rotate-z":Oe()}],scale:[{scale:Ae()}],"scale-x":[{"scale-x":Ae()}],"scale-y":[{"scale-y":Ae()}],"scale-z":[{"scale-z":Ae()}],"scale-3d":["scale-3d"],skew:[{skew:_e()}],"skew-x":[{"skew-x":_e()}],"skew-y":[{"skew-y":_e()}],transform:[{transform:[pe,fe,"","none","gpu","cpu"]}],"transform-origin":[{origin:C()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Qe()}],"translate-x":[{"translate-x":Qe()}],"translate-y":[{"translate-y":Qe()}],"translate-z":[{"translate-z":Qe()}],"translate-none":["translate-none"],accent:[{accent:E()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:E()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",pe,fe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mbs":[{"scroll-mbs":T()}],"scroll-mbe":[{"scroll-mbe":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pbs":[{"scroll-pbs":T()}],"scroll-pbe":[{"scroll-pbe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",pe,fe]}],fill:[{fill:["none",...E()]}],"stroke-w":[{stroke:[ze,Hl,Js,Xw]}],stroke:[{stroke:["none",...E()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},_9=XF(v9);function ne(...e){return _9(PI(e))}const x9={path:"m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z"},Jw={path:"M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"},y9="M2 2H17V12H12V17H7V22H2ZM7 7V12H12V7ZM17 12H22V22H17Z",VI={claude:x9.path,codex:Jw.path,"codex-cloud":Jw.path,pi:y9},b9=new Set(["pi"]);function w9(e){return e!=null&&e in VI}function dp({tool:e,className:t}){const n=e?VI[e]:void 0;return n?h.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:t,"aria-hidden":"true",children:h.jsx("path",{d:n,fillRule:e&&b9.has(e)?"evenodd":void 0})}):h.jsx(up,{className:t})}function ry(e){return e==="codex"?"Codex":e==="codex-cloud"?"Codex(云上)":e==="pi"?"pi":"Claude Code"}function hp(e){return e==="claude"?"text-engine-claude":e==="codex"?"text-engine-codex":e==="codex-cloud"?"text-engine-codex-cloud":e==="pi"?"text-engine-pi":"text-text-400"}function iy(e){return e.label||e.aiLabel||e.larkChatName||e.larkChatId||e.cwd.split("/").filter(Boolean).pop()||e.sessionId.slice(0,8)}function S9(e){const t=new Date(e),n=Date.now()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return"just now";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);return s<7?`${s}d ago`:t.toLocaleDateString()}function k9(e){return`'${e.replace(/'/g,"'\\''")}'`}function C9(e){return e.toolSessionId?e.tool==="codex"?`codex resume ${e.toolSessionId}`:e.tool==="pi"?`pi --session-id ${e.toolSessionId}`:`claude --resume ${e.toolSessionId} --permission-mode bypassPermissions`:null}function qI(e){const t=C9(e);return!t||!e.cwd?null:`cd ${k9(e.cwd)} && ${t}`}function Pe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}function eS(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function wu(...e){return t=>{let n=!1;const r=e.map(i=>{const s=eS(i,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let i=0;i<r.length;i++){const s=r[i];typeof s=="function"?s():eS(e[i],null)}}}}function Qt(...e){return g.useCallback(wu(...e),e)}function E9(e,t){const n=g.createContext(t),r=s=>{const{children:o,...a}=s,l=g.useMemo(()=>a,Object.values(a));return h.jsx(n.Provider,{value:l,children:o})};r.displayName=e+"Provider";function i(s){const o=g.useContext(n);if(o)return o;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,i]}function Uo(e,t=[]){let n=[];function r(s,o){const a=g.createContext(o),l=n.length;n=[...n,o];const c=d=>{var _;const{scope:f,children:p,...m}=d,v=((_=f==null?void 0:f[e])==null?void 0:_[l])||a,w=g.useMemo(()=>m,Object.values(m));return h.jsx(v.Provider,{value:w,children:p})};c.displayName=s+"Provider";function u(d,f){var v;const p=((v=f==null?void 0:f[e])==null?void 0:v[l])||a,m=g.useContext(p);if(m)return m;if(o!==void 0)return o;throw new Error(`\`${d}\` must be used within \`${s}\``)}return[c,u]}const i=()=>{const s=n.map(o=>g.createContext(o));return function(a){const l=(a==null?void 0:a[e])||s;return g.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return i.scopeName=e,[r,N9(i,...t)]}function N9(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const o=r.reduce((a,{useScope:l,scopeName:c})=>{const d=l(s)[`__scope${c}`];return{...a,...d}},{});return g.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return n.scopeName=t.scopeName,n}var Bs=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},T9=cl[" useInsertionEffect ".trim().toString()]||Bs;function Su({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[i,s,o]=I9({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:i;{const u=g.useRef(e!==void 0);g.useEffect(()=>{const d=u.current;d!==a&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=a},[a,r])}const c=g.useCallback(u=>{var d;if(a){const f=P9(u)?u(e):u;f!==e&&((d=o.current)==null||d.call(o,f))}else s(u)},[a,e,s,o]);return[l,c]}function I9({defaultProp:e,onChange:t}){const[n,r]=g.useState(e),i=g.useRef(n),s=g.useRef(t);return T9(()=>{s.current=t},[t]),g.useEffect(()=>{var o;i.current!==n&&((o=s.current)==null||o.call(s,n),i.current=n)},[n,i]),[n,r,s]}function P9(e){return typeof e=="function"}function tu(e){const t=R9(e),n=g.forwardRef((r,i)=>{const{children:s,...o}=r,a=g.Children.toArray(s),l=a.find(A9);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}function R9(e){const t=g.forwardRef((n,r)=>{const{children:i,...s}=n;if(g.isValidElement(i)){const o=D9(i),a=L9(s,i.props);return i.type!==g.Fragment&&(a.ref=r?wu(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 KI=Symbol("radix.slottable");function M9(e){const t=({children:n})=>h.jsx(h.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=KI,t}function A9(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===KI}function L9(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 D9(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)}var j9=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Rt=j9.reduce((e,t)=>{const n=tu(`Primitive.${t}`),r=g.forwardRef((i,s)=>{const{asChild:o,...a}=i,l=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),h.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function GI(e,t){e&&hl.flushSync(()=>e.dispatchEvent(t))}function YI(e){const t=e+"CollectionProvider",[n,r]=Uo(t),[i,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=v=>{const{scope:w,children:_}=v,x=Ge.useRef(null),b=Ge.useRef(new Map).current;return h.jsx(i,{scope:w,itemMap:b,collectionRef:x,children:_})};o.displayName=t;const a=e+"CollectionSlot",l=tu(a),c=Ge.forwardRef((v,w)=>{const{scope:_,children:x}=v,b=s(a,_),S=Qt(w,b.collectionRef);return h.jsx(l,{ref:S,children:x})});c.displayName=a;const u=e+"CollectionItemSlot",d="data-radix-collection-item",f=tu(u),p=Ge.forwardRef((v,w)=>{const{scope:_,children:x,...b}=v,S=Ge.useRef(null),C=Qt(w,S),k=s(u,_);return Ge.useEffect(()=>(k.itemMap.set(S,{ref:S,...b}),()=>void k.itemMap.delete(S))),h.jsx(f,{[d]:"",ref:C,children:x})});p.displayName=u;function m(v){const w=s(e+"CollectionConsumer",v);return Ge.useCallback(()=>{const x=w.collectionRef.current;if(!x)return[];const b=Array.from(x.querySelectorAll(`[${d}]`));return Array.from(w.itemMap.values()).sort((k,N)=>b.indexOf(k.ref.current)-b.indexOf(N.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:o,Slot:c,ItemSlot:p},m,r]}var O9=g.createContext(void 0);function XI(e){const t=g.useContext(O9);return e||t||"ltr"}function gi(e){const t=g.useRef(e);return g.useEffect(()=>{t.current=e}),g.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function B9(e,t=globalThis==null?void 0:globalThis.document){const n=gi(e);g.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var z9="DismissableLayer",v0="dismissableLayer.update",$9="dismissableLayer.pointerDownOutside",F9="dismissableLayer.focusOutside",tS,QI=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),fp=g.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:o,onDismiss:a,...l}=e,c=g.useContext(QI),[u,d]=g.useState(null),f=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=g.useState({}),m=Qt(t,N=>d(N)),v=Array.from(c.layers),[w]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),_=v.indexOf(w),x=u?v.indexOf(u):-1,b=c.layersWithOutsidePointerEventsDisabled.size>0,S=x>=_,C=W9(N=>{const T=N.target,z=[...c.branches].some(P=>P.contains(T));!S||z||(i==null||i(N),o==null||o(N),N.defaultPrevented||a==null||a())},f),k=V9(N=>{const T=N.target;[...c.branches].some(P=>P.contains(T))||(s==null||s(N),o==null||o(N),N.defaultPrevented||a==null||a())},f);return B9(N=>{x===c.layers.size-1&&(r==null||r(N),!N.defaultPrevented&&a&&(N.preventDefault(),a()))},f),g.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(tS=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),nS(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=tS)}},[u,f,n,c]),g.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),nS())},[u,c]),g.useEffect(()=>{const N=()=>p({});return document.addEventListener(v0,N),()=>document.removeEventListener(v0,N)},[]),h.jsx(Rt.div,{...l,ref:m,style:{pointerEvents:b?S?"auto":"none":void 0,...e.style},onFocusCapture:Pe(e.onFocusCapture,k.onFocusCapture),onBlurCapture:Pe(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:Pe(e.onPointerDownCapture,C.onPointerDownCapture)})});fp.displayName=z9;var H9="DismissableLayerBranch",U9=g.forwardRef((e,t)=>{const n=g.useContext(QI),r=g.useRef(null),i=Qt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),h.jsx(Rt.div,{...e,ref:i})});U9.displayName=H9;function W9(e,t=globalThis==null?void 0:globalThis.document){const n=gi(e),r=g.useRef(!1),i=g.useRef(()=>{});return g.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){ZI($9,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",i.current),i.current=l,t.addEventListener("click",i.current,{once:!0})):l()}else t.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",s),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function V9(e,t=globalThis==null?void 0:globalThis.document){const n=gi(e),r=g.useRef(!1);return g.useEffect(()=>{const i=s=>{s.target&&!r.current&&ZI(F9,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function nS(){const e=new CustomEvent(v0);document.dispatchEvent(e)}function ZI(e,t,n,{discrete:r}){const i=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?GI(i,s):i.dispatchEvent(s)}var Rm=0;function JI(){g.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??rS()),document.body.insertAdjacentElement("beforeend",e[1]??rS()),Rm++,()=>{Rm===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Rm--}},[])}function rS(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Mm="focusScope.autoFocusOnMount",Am="focusScope.autoFocusOnUnmount",iS={bubbles:!1,cancelable:!0},q9="FocusScope",sy=g.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:s,...o}=e,[a,l]=g.useState(null),c=gi(i),u=gi(s),d=g.useRef(null),f=Qt(t,v=>l(v)),p=g.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;g.useEffect(()=>{if(r){let v=function(b){if(p.paused||!a)return;const S=b.target;a.contains(S)?d.current=S:ds(d.current,{select:!0})},w=function(b){if(p.paused||!a)return;const S=b.relatedTarget;S!==null&&(a.contains(S)||ds(d.current,{select:!0}))},_=function(b){if(document.activeElement===document.body)for(const C of b)C.removedNodes.length>0&&ds(a)};document.addEventListener("focusin",v),document.addEventListener("focusout",w);const x=new MutationObserver(_);return a&&x.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",w),x.disconnect()}}},[r,a,p.paused]),g.useEffect(()=>{if(a){oS.add(p);const v=document.activeElement;if(!a.contains(v)){const _=new CustomEvent(Mm,iS);a.addEventListener(Mm,c),a.dispatchEvent(_),_.defaultPrevented||(K9(Z9(eP(a)),{select:!0}),document.activeElement===v&&ds(a))}return()=>{a.removeEventListener(Mm,c),setTimeout(()=>{const _=new CustomEvent(Am,iS);a.addEventListener(Am,u),a.dispatchEvent(_),_.defaultPrevented||ds(v??document.body,{select:!0}),a.removeEventListener(Am,u),oS.remove(p)},0)}}},[a,c,u,p]);const m=g.useCallback(v=>{if(!n&&!r||p.paused)return;const w=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,_=document.activeElement;if(w&&_){const x=v.currentTarget,[b,S]=G9(x);b&&S?!v.shiftKey&&_===S?(v.preventDefault(),n&&ds(b,{select:!0})):v.shiftKey&&_===b&&(v.preventDefault(),n&&ds(S,{select:!0})):_===x&&v.preventDefault()}},[n,r,p.paused]);return h.jsx(Rt.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});sy.displayName=q9;function K9(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(ds(r,{select:t}),document.activeElement!==n)return}function G9(e){const t=eP(e),n=sS(t,e),r=sS(t.reverse(),e);return[n,r]}function eP(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function sS(e,t){for(const n of e)if(!Y9(n,{upTo:t}))return n}function Y9(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function X9(e){return e instanceof HTMLInputElement&&"select"in e}function ds(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&X9(e)&&t&&e.select()}}var oS=Q9();function Q9(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=aS(e,t),e.unshift(t)},remove(t){var n;e=aS(e,t),(n=e[0])==null||n.resume()}}}function aS(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Z9(e){return e.filter(t=>t.tagName!=="A")}var J9=cl[" useId ".trim().toString()]||(()=>{}),e7=0;function Oi(e){const[t,n]=g.useState(J9());return Bs(()=>{n(r=>r??String(e7++))},[e]),t?`radix-${t}`:""}const t7=["top","right","bottom","left"],zs=Math.min,nr=Math.max,rf=Math.round,gd=Math.floor,hi=e=>({x:e,y:e}),n7={left:"right",right:"left",bottom:"top",top:"bottom"};function _0(e,t,n){return nr(e,zs(t,n))}function Wi(e,t){return typeof e=="function"?e(t):e}function Vi(e){return e.split("-")[0]}function yl(e){return e.split("-")[1]}function oy(e){return e==="x"?"y":"x"}function ay(e){return e==="y"?"height":"width"}function oi(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function ly(e){return oy(oi(e))}function r7(e,t,n){n===void 0&&(n=!1);const r=yl(e),i=ly(e),s=ay(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=sf(o)),[o,sf(o)]}function i7(e){const t=sf(e);return[x0(e),t,x0(t)]}function x0(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const lS=["left","right"],cS=["right","left"],s7=["top","bottom"],o7=["bottom","top"];function a7(e,t,n){switch(e){case"top":case"bottom":return n?t?cS:lS:t?lS:cS;case"left":case"right":return t?s7:o7;default:return[]}}function l7(e,t,n,r){const i=yl(e);let s=a7(Vi(e),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),t&&(s=s.concat(s.map(x0)))),s}function sf(e){const t=Vi(e);return n7[t]+e.slice(t.length)}function c7(e){return{top:0,right:0,bottom:0,left:0,...e}}function tP(e){return typeof e!="number"?c7(e):{top:e,right:e,bottom:e,left:e}}function of(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function uS(e,t,n){let{reference:r,floating:i}=e;const s=oi(t),o=ly(t),a=ay(o),l=Vi(t),c=s==="y",u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[a]/2-i[a]/2;let p;switch(l){case"top":p={x:u,y:r.y-i.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:d};break;case"left":p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(yl(t)){case"start":p[o]-=f*(n&&c?-1:1);break;case"end":p[o]+=f*(n&&c?-1:1);break}return p}async function u7(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:o,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=Wi(t,e),m=tP(p),w=a[f?d==="floating"?"reference":"floating":d],_=of(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(w)))==null||n?w:w.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),x=d==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,b=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),S=await(s.isElement==null?void 0:s.isElement(b))?await(s.getScale==null?void 0:s.getScale(b))||{x:1,y:1}:{x:1,y:1},C=of(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:x,offsetParent:b,strategy:l}):x);return{top:(_.top-C.top+m.top)/S.y,bottom:(C.bottom-_.bottom+m.bottom)/S.y,left:(_.left-C.left+m.left)/S.x,right:(C.right-_.right+m.right)/S.x}}const d7=50,h7=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,a=o.detectOverflow?o:{...o,detectOverflow:u7},l=await(o.isRTL==null?void 0:o.isRTL(t));let c=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=uS(c,r,l),f=r,p=0;const m={};for(let v=0;v<s.length;v++){const w=s[v];if(!w)continue;const{name:_,fn:x}=w,{x:b,y:S,data:C,reset:k}=await x({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:c,platform:a,elements:{reference:e,floating:t}});u=b??u,d=S??d,m[_]={...m[_],...C},k&&p<d7&&(p++,typeof k=="object"&&(k.placement&&(f=k.placement),k.rects&&(c=k.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):k.rects),{x:u,y:d}=uS(c,f,l)),v=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},f7=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:o,elements:a,middlewareData:l}=t,{element:c,padding:u=0}=Wi(e,t)||{};if(c==null)return{};const d=tP(u),f={x:n,y:r},p=ly(i),m=ay(p),v=await o.getDimensions(c),w=p==="y",_=w?"top":"left",x=w?"bottom":"right",b=w?"clientHeight":"clientWidth",S=s.reference[m]+s.reference[p]-f[p]-s.floating[m],C=f[p]-s.reference[p],k=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let N=k?k[b]:0;(!N||!await(o.isElement==null?void 0:o.isElement(k)))&&(N=a.floating[b]||s.floating[m]);const T=S/2-C/2,z=N/2-v[m]/2-1,P=zs(d[_],z),B=zs(d[x],z),A=P,R=N-v[m]-B,M=N/2-v[m]/2+T,D=_0(A,M,R),$=!l.arrow&&yl(i)!=null&&M!==D&&s.reference[m]/2-(M<A?P:B)-v[m]/2<0,F=$?M<A?M-A:M-R:0;return{[p]:f[p]+F,data:{[p]:D,centerOffset:M-D-F,...$&&{alignmentOffset:F}},reset:$}}}),p7=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:v=!0,...w}=Wi(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const _=Vi(i),x=oi(a),b=Vi(a)===a,S=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=f||(b||!v?[sf(a)]:i7(a)),k=m!=="none";!f&&k&&C.push(...l7(a,v,m,S));const N=[a,...C],T=await l.detectOverflow(t,w),z=[];let P=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&z.push(T[_]),d){const M=r7(i,o,S);z.push(T[M[0]],T[M[1]])}if(P=[...P,{placement:i,overflows:z}],!z.every(M=>M<=0)){var B,A;const M=(((B=s.flip)==null?void 0:B.index)||0)+1,D=N[M];if(D&&(!(d==="alignment"?x!==oi(D):!1)||P.every(j=>oi(j.placement)===x?j.overflows[0]>0:!0)))return{data:{index:M,overflows:P},reset:{placement:D}};let $=(A=P.filter(F=>F.overflows[0]<=0).sort((F,j)=>F.overflows[1]-j.overflows[1])[0])==null?void 0:A.placement;if(!$)switch(p){case"bestFit":{var R;const F=(R=P.filter(j=>{if(k){const O=oi(j.placement);return O===x||O==="y"}return!0}).map(j=>[j.placement,j.overflows.filter(O=>O>0).reduce((O,E)=>O+E,0)]).sort((j,O)=>j[1]-O[1])[0])==null?void 0:R[0];F&&($=F);break}case"initialPlacement":$=a;break}if(i!==$)return{reset:{placement:$}}}return{}}}};function dS(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function hS(e){return t7.some(t=>e[t]>=0)}const m7=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=Wi(e,t);switch(i){case"referenceHidden":{const o=await r.detectOverflow(t,{...s,elementContext:"reference"}),a=dS(o,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:hS(a)}}}case"escaped":{const o=await r.detectOverflow(t,{...s,altBoundary:!0}),a=dS(o,n.floating);return{data:{escapedOffsets:a,escaped:hS(a)}}}default:return{}}}}},nP=new Set(["left","top"]);async function g7(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Vi(n),a=yl(n),l=oi(n)==="y",c=nP.has(o)?-1:1,u=s&&l?-1:1,d=Wi(t,e);let{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),l?{x:p*u,y:f*c}:{x:f*c,y:p*u}}const v7=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:o,middlewareData:a}=t,l=await g7(t,e);return o===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:{...l,placement:o}}}}},_7=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:s}=t,{mainAxis:o=!0,crossAxis:a=!1,limiter:l={fn:_=>{let{x,y:b}=_;return{x,y:b}}},...c}=Wi(e,t),u={x:n,y:r},d=await s.detectOverflow(t,c),f=oi(Vi(i)),p=oy(f);let m=u[p],v=u[f];if(o){const _=p==="y"?"top":"left",x=p==="y"?"bottom":"right",b=m+d[_],S=m-d[x];m=_0(b,m,S)}if(a){const _=f==="y"?"top":"left",x=f==="y"?"bottom":"right",b=v+d[_],S=v-d[x];v=_0(b,v,S)}const w=l.fn({...t,[p]:m,[f]:v});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[p]:o,[f]:a}}}}}},x7=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:s,middlewareData:o}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=Wi(e,t),u={x:n,y:r},d=oi(i),f=oy(d);let p=u[f],m=u[d];const v=Wi(a,t),w=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(l){const b=f==="y"?"height":"width",S=s.reference[f]-s.floating[b]+w.mainAxis,C=s.reference[f]+s.reference[b]-w.mainAxis;p<S?p=S:p>C&&(p=C)}if(c){var _,x;const b=f==="y"?"width":"height",S=nP.has(Vi(i)),C=s.reference[d]-s.floating[b]+(S&&((_=o.offset)==null?void 0:_[d])||0)+(S?0:w.crossAxis),k=s.reference[d]+s.reference[b]+(S?0:((x=o.offset)==null?void 0:x[d])||0)-(S?w.crossAxis:0);m<C?m=C:m>k&&(m=k)}return{[f]:p,[d]:m}}}},y7=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:s,platform:o,elements:a}=t,{apply:l=()=>{},...c}=Wi(e,t),u=await o.detectOverflow(t,c),d=Vi(i),f=yl(i),p=oi(i)==="y",{width:m,height:v}=s.floating;let w,_;d==="top"||d==="bottom"?(w=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(_=d,w=f==="end"?"top":"bottom");const x=v-u.top-u.bottom,b=m-u.left-u.right,S=zs(v-u[w],x),C=zs(m-u[_],b),k=!t.middlewareData.shift;let N=S,T=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(T=b),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(N=x),k&&!f){const P=nr(u.left,0),B=nr(u.right,0),A=nr(u.top,0),R=nr(u.bottom,0);p?T=m-2*(P!==0||B!==0?P+B:nr(u.left,u.right)):N=v-2*(A!==0||R!==0?A+R:nr(u.top,u.bottom))}await l({...t,availableWidth:T,availableHeight:N});const z=await o.getDimensions(a.floating);return m!==z.width||v!==z.height?{reset:{rects:!0}}:{}}}};function pp(){return typeof window<"u"}function bl(e){return rP(e)?(e.nodeName||"").toLowerCase():"#document"}function sr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function _i(e){var t;return(t=(rP(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function rP(e){return pp()?e instanceof Node||e instanceof sr(e).Node:!1}function Wr(e){return pp()?e instanceof Element||e instanceof sr(e).Element:!1}function Xi(e){return pp()?e instanceof HTMLElement||e instanceof sr(e).HTMLElement:!1}function fS(e){return!pp()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof sr(e).ShadowRoot}function ku(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Vr(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function b7(e){return/^(table|td|th)$/.test(bl(e))}function mp(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const w7=/transform|translate|scale|rotate|perspective|filter/,S7=/paint|layout|strict|content/,eo=e=>!!e&&e!=="none";let Lm;function cy(e){const t=Wr(e)?Vr(e):e;return eo(t.transform)||eo(t.translate)||eo(t.scale)||eo(t.rotate)||eo(t.perspective)||!uy()&&(eo(t.backdropFilter)||eo(t.filter))||w7.test(t.willChange||"")||S7.test(t.contain||"")}function k7(e){let t=$s(e);for(;Xi(t)&&!Qa(t);){if(cy(t))return t;if(mp(t))return null;t=$s(t)}return null}function uy(){return Lm==null&&(Lm=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Lm}function Qa(e){return/^(html|body|#document)$/.test(bl(e))}function Vr(e){return sr(e).getComputedStyle(e)}function gp(e){return Wr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $s(e){if(bl(e)==="html")return e;const t=e.assignedSlot||e.parentNode||fS(e)&&e.host||_i(e);return fS(t)?t.host:t}function iP(e){const t=$s(e);return Qa(t)?e.ownerDocument?e.ownerDocument.body:e.body:Xi(t)&&ku(t)?t:iP(t)}function nu(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=iP(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),o=sr(i);if(s){const a=y0(o);return t.concat(o,o.visualViewport||[],ku(i)?i:[],a&&n?nu(a):[])}else return t.concat(i,nu(i,[],n))}function y0(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function sP(e){const t=Vr(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Xi(e),s=i?e.offsetWidth:n,o=i?e.offsetHeight:r,a=rf(n)!==s||rf(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function dy(e){return Wr(e)?e:e.contextElement}function Aa(e){const t=dy(e);if(!Xi(t))return hi(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=sP(t);let o=(s?rf(n.width):n.width)/r,a=(s?rf(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const C7=hi(0);function oP(e){const t=sr(e);return!uy()||!t.visualViewport?C7:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function E7(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==sr(e)?!1:t}function Io(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=dy(e);let o=hi(1);t&&(r?Wr(r)&&(o=Aa(r)):o=Aa(e));const a=E7(s,n,r)?oP(s):hi(0);let l=(i.left+a.x)/o.x,c=(i.top+a.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(s){const f=sr(s),p=r&&Wr(r)?sr(r):r;let m=f,v=y0(m);for(;v&&r&&p!==m;){const w=Aa(v),_=v.getBoundingClientRect(),x=Vr(v),b=_.left+(v.clientLeft+parseFloat(x.paddingLeft))*w.x,S=_.top+(v.clientTop+parseFloat(x.paddingTop))*w.y;l*=w.x,c*=w.y,u*=w.x,d*=w.y,l+=b,c+=S,m=sr(v),v=y0(m)}}return of({width:u,height:d,x:l,y:c})}function vp(e,t){const n=gp(e).scrollLeft;return t?t.left+n:Io(_i(e)).left+n}function aP(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-vp(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function N7(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",o=_i(r),a=t?mp(t.floating):!1;if(r===o||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=hi(1);const u=hi(0),d=Xi(r);if((d||!d&&!s)&&((bl(r)!=="body"||ku(o))&&(l=gp(r)),d)){const p=Io(r);c=Aa(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const f=o&&!d&&!s?aP(o,l):hi(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-l.scrollTop*c.y+u.y+f.y}}function T7(e){return Array.from(e.getClientRects())}function I7(e){const t=_i(e),n=gp(e),r=e.ownerDocument.body,i=nr(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=nr(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+vp(e);const a=-n.scrollTop;return Vr(r).direction==="rtl"&&(o+=nr(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:a}}const pS=25;function P7(e,t){const n=sr(e),r=_i(e),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;const u=uy();(!u||u&&t==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}const c=vp(r);if(c<=0){const u=r.ownerDocument,d=u.body,f=getComputedStyle(d),p=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,m=Math.abs(r.clientWidth-d.clientWidth-p);m<=pS&&(s-=m)}else c<=pS&&(s+=c);return{width:s,height:o,x:a,y:l}}function R7(e,t){const n=Io(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=Xi(e)?Aa(e):hi(1),o=e.clientWidth*s.x,a=e.clientHeight*s.y,l=i*s.x,c=r*s.y;return{width:o,height:a,x:l,y:c}}function mS(e,t,n){let r;if(t==="viewport")r=P7(e,n);else if(t==="document")r=I7(_i(e));else if(Wr(t))r=R7(t,n);else{const i=oP(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return of(r)}function lP(e,t){const n=$s(e);return n===t||!Wr(n)||Qa(n)?!1:Vr(n).position==="fixed"||lP(n,t)}function M7(e,t){const n=t.get(e);if(n)return n;let r=nu(e,[],!1).filter(a=>Wr(a)&&bl(a)!=="body"),i=null;const s=Vr(e).position==="fixed";let o=s?$s(e):e;for(;Wr(o)&&!Qa(o);){const a=Vr(o),l=cy(o);!l&&a.position==="fixed"&&(i=null),(s?!l&&!i:!l&&a.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||ku(o)&&!l&&lP(e,o))?r=r.filter(u=>u!==o):i=a,o=$s(o)}return t.set(e,r),r}function A7(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[...n==="clippingAncestors"?mp(t)?[]:M7(t,this._c):[].concat(n),r],a=mS(t,o[0],i);let l=a.top,c=a.right,u=a.bottom,d=a.left;for(let f=1;f<o.length;f++){const p=mS(t,o[f],i);l=nr(p.top,l),c=zs(p.right,c),u=zs(p.bottom,u),d=nr(p.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function L7(e){const{width:t,height:n}=sP(e);return{width:t,height:n}}function D7(e,t,n){const r=Xi(t),i=_i(t),s=n==="fixed",o=Io(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=hi(0);function c(){l.x=vp(i)}if(r||!r&&!s)if((bl(t)!=="body"||ku(i))&&(a=gp(t)),r){const p=Io(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else i&&c();s&&!r&&i&&c();const u=i&&!r&&!s?aP(i,a):hi(0),d=o.left+a.scrollLeft-l.x-u.x,f=o.top+a.scrollTop-l.y-u.y;return{x:d,y:f,width:o.width,height:o.height}}function Dm(e){return Vr(e).position==="static"}function gS(e,t){if(!Xi(e)||Vr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return _i(e)===n&&(n=n.ownerDocument.body),n}function cP(e,t){const n=sr(e);if(mp(e))return n;if(!Xi(e)){let i=$s(e);for(;i&&!Qa(i);){if(Wr(i)&&!Dm(i))return i;i=$s(i)}return n}let r=gS(e,t);for(;r&&b7(r)&&Dm(r);)r=gS(r,t);return r&&Qa(r)&&Dm(r)&&!cy(r)?n:r||k7(e)||n}const j7=async function(e){const t=this.getOffsetParent||cP,n=this.getDimensions,r=await n(e.floating);return{reference:D7(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function O7(e){return Vr(e).direction==="rtl"}const B7={convertOffsetParentRelativeRectToViewportRelativeRect:N7,getDocumentElement:_i,getClippingRect:A7,getOffsetParent:cP,getElementRects:j7,getClientRects:T7,getDimensions:L7,getScale:Aa,isElement:Wr,isRTL:O7};function uP(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function z7(e,t){let n=null,r;const i=_i(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=c;if(a||t(),!f||!p)return;const m=gd(d),v=gd(i.clientWidth-(u+f)),w=gd(i.clientHeight-(d+p)),_=gd(u),b={rootMargin:-m+"px "+-v+"px "+-w+"px "+-_+"px",threshold:nr(0,zs(1,l))||1};let S=!0;function C(k){const N=k[0].intersectionRatio;if(N!==l){if(!S)return o();N?o(!1,N):r=setTimeout(()=>{o(!1,1e-7)},1e3)}N===1&&!uP(c,e.getBoundingClientRect())&&o(),S=!1}try{n=new IntersectionObserver(C,{...b,root:i.ownerDocument})}catch{n=new IntersectionObserver(C,b)}n.observe(e)}return o(!0),s}function $7(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=dy(e),u=i||s?[...c?nu(c):[],...t?nu(t):[]]:[];u.forEach(_=>{i&&_.addEventListener("scroll",n,{passive:!0}),s&&_.addEventListener("resize",n)});const d=c&&a?z7(c,n):null;let f=-1,p=null;o&&(p=new ResizeObserver(_=>{let[x]=_;x&&x.target===c&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var b;(b=p)==null||b.observe(t)})),n()}),c&&!l&&p.observe(c),t&&p.observe(t));let m,v=l?Io(e):null;l&&w();function w(){const _=Io(e);v&&!uP(v,_)&&n(),v=_,m=requestAnimationFrame(w)}return n(),()=>{var _;u.forEach(x=>{i&&x.removeEventListener("scroll",n),s&&x.removeEventListener("resize",n)}),d==null||d(),(_=p)==null||_.disconnect(),p=null,l&&cancelAnimationFrame(m)}}const F7=v7,H7=_7,U7=p7,W7=y7,V7=m7,vS=f7,q7=x7,K7=(e,t,n)=>{const r=new Map,i={platform:B7,...n},s={...i.platform,_c:r};return h7(e,t,{...i,platform:s})};var G7=typeof document<"u",Y7=function(){},nh=G7?g.useLayoutEffect:Y7;function af(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!af(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&e.$$typeof)&&!af(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function dP(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function _S(e,t){const n=dP(e);return Math.round(t*n)/n}function jm(e){const t=g.useRef(e);return nh(()=>{t.current=e}),t}function X7(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[u,d]=g.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=g.useState(r);af(f,r)||p(r);const[m,v]=g.useState(null),[w,_]=g.useState(null),x=g.useCallback(j=>{j!==k.current&&(k.current=j,v(j))},[]),b=g.useCallback(j=>{j!==N.current&&(N.current=j,_(j))},[]),S=s||m,C=o||w,k=g.useRef(null),N=g.useRef(null),T=g.useRef(u),z=l!=null,P=jm(l),B=jm(i),A=jm(c),R=g.useCallback(()=>{if(!k.current||!N.current)return;const j={placement:t,strategy:n,middleware:f};B.current&&(j.platform=B.current),K7(k.current,N.current,j).then(O=>{const E={...O,isPositioned:A.current!==!1};M.current&&!af(T.current,E)&&(T.current=E,hl.flushSync(()=>{d(E)}))})},[f,t,n,B,A]);nh(()=>{c===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(j=>({...j,isPositioned:!1})))},[c]);const M=g.useRef(!1);nh(()=>(M.current=!0,()=>{M.current=!1}),[]),nh(()=>{if(S&&(k.current=S),C&&(N.current=C),S&&C){if(P.current)return P.current(S,C,R);R()}},[S,C,R,P,z]);const D=g.useMemo(()=>({reference:k,floating:N,setReference:x,setFloating:b}),[x,b]),$=g.useMemo(()=>({reference:S,floating:C}),[S,C]),F=g.useMemo(()=>{const j={position:n,left:0,top:0};if(!$.floating)return j;const O=_S($.floating,u.x),E=_S($.floating,u.y);return a?{...j,transform:"translate("+O+"px, "+E+"px)",...dP($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:O,top:E}},[n,a,$.floating,u.x,u.y]);return g.useMemo(()=>({...u,update:R,refs:D,elements:$,floatingStyles:F}),[u,R,D,$,F])}const Q7=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?vS({element:r.current,padding:i}).fn(n):{}:r?vS({element:r,padding:i}).fn(n):{}}}},Z7=(e,t)=>{const n=F7(e);return{name:n.name,fn:n.fn,options:[e,t]}},J7=(e,t)=>{const n=H7(e);return{name:n.name,fn:n.fn,options:[e,t]}},eH=(e,t)=>({fn:q7(e).fn,options:[e,t]}),tH=(e,t)=>{const n=U7(e);return{name:n.name,fn:n.fn,options:[e,t]}},nH=(e,t)=>{const n=W7(e);return{name:n.name,fn:n.fn,options:[e,t]}},rH=(e,t)=>{const n=V7(e);return{name:n.name,fn:n.fn,options:[e,t]}},iH=(e,t)=>{const n=Q7(e);return{name:n.name,fn:n.fn,options:[e,t]}};var sH="Arrow",hP=g.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...s}=e;return h.jsx(Rt.svg,{...s,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:h.jsx("polygon",{points:"0,0 30,0 15,10"})})});hP.displayName=sH;var oH=hP;function aH(e){const[t,n]=g.useState(void 0);return Bs(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let o,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;o=c.inlineSize,a=c.blockSize}else o=e.offsetWidth,a=e.offsetHeight;n({width:o,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var hy="Popper",[fP,_p]=Uo(hy),[lH,pP]=fP(hy),mP=e=>{const{__scopePopper:t,children:n}=e,[r,i]=g.useState(null);return h.jsx(lH,{scope:t,anchor:r,onAnchorChange:i,children:n})};mP.displayName=hy;var gP="PopperAnchor",vP=g.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,s=pP(gP,n),o=g.useRef(null),a=Qt(t,o),l=g.useRef(null);return g.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||o.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:h.jsx(Rt.div,{...i,ref:a})});vP.displayName=gP;var fy="PopperContent",[cH,uH]=fP(fy),_P=g.forwardRef((e,t)=>{var me,Re,ce,Le,Oe,Ae;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:o=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:p="optimized",onPlaced:m,...v}=e,w=pP(fy,n),[_,x]=g.useState(null),b=Qt(t,_e=>x(_e)),[S,C]=g.useState(null),k=aH(S),N=(k==null?void 0:k.width)??0,T=(k==null?void 0:k.height)??0,z=r+(s!=="center"?"-"+s:""),P=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},B=Array.isArray(c)?c:[c],A=B.length>0,R={padding:P,boundary:B.filter(hH),altBoundary:A},{refs:M,floatingStyles:D,placement:$,isPositioned:F,middlewareData:j}=X7({strategy:"fixed",placement:z,whileElementsMounted:(..._e)=>$7(..._e,{animationFrame:p==="always"}),elements:{reference:w.anchor},middleware:[Z7({mainAxis:i+T,alignmentAxis:o}),l&&J7({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?eH():void 0,...R}),l&&tH({...R}),nH({...R,apply:({elements:_e,rects:Qe,availableWidth:kt,availableHeight:tt})=>{const{width:At,height:Jt}=Qe.reference,nt=_e.floating.style;nt.setProperty("--radix-popper-available-width",`${kt}px`),nt.setProperty("--radix-popper-available-height",`${tt}px`),nt.setProperty("--radix-popper-anchor-width",`${At}px`),nt.setProperty("--radix-popper-anchor-height",`${Jt}px`)}}),S&&iH({element:S,padding:a}),fH({arrowWidth:N,arrowHeight:T}),f&&rH({strategy:"referenceHidden",...R})]}),[O,E]=bP($),H=gi(m);Bs(()=>{F&&(H==null||H())},[F,H]);const q=(me=j.arrow)==null?void 0:me.x,L=(Re=j.arrow)==null?void 0:Re.y,re=((ce=j.arrow)==null?void 0:ce.centerOffset)!==0,[se,K]=g.useState();return Bs(()=>{_&&K(window.getComputedStyle(_).zIndex)},[_]),h.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...D,transform:F?D.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:se,"--radix-popper-transform-origin":[(Le=j.transformOrigin)==null?void 0:Le.x,(Oe=j.transformOrigin)==null?void 0:Oe.y].join(" "),...((Ae=j.hide)==null?void 0:Ae.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:h.jsx(cH,{scope:n,placedSide:O,onArrowChange:C,arrowX:q,arrowY:L,shouldHideArrow:re,children:h.jsx(Rt.div,{"data-side":O,"data-align":E,...v,ref:b,style:{...v.style,animation:F?void 0:"none"}})})})});_P.displayName=fy;var xP="PopperArrow",dH={top:"bottom",right:"left",bottom:"top",left:"right"},yP=g.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,s=uH(xP,r),o=dH[s.placedSide];return h.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:h.jsx(oH,{...i,ref:n,style:{...i.style,display:"block"}})})});yP.displayName=xP;function hH(e){return e!==null}var fH=e=>({name:"transformOrigin",options:e,fn(t){var w,_,x;const{placement:n,rects:r,middlewareData:i}=t,o=((w=i.arrow)==null?void 0:w.centerOffset)!==0,a=o?0:e.arrowWidth,l=o?0:e.arrowHeight,[c,u]=bP(n),d={start:"0%",center:"50%",end:"100%"}[u],f=(((_=i.arrow)==null?void 0:_.x)??0)+a/2,p=(((x=i.arrow)==null?void 0:x.y)??0)+l/2;let m="",v="";return c==="bottom"?(m=o?d:`${f}px`,v=`${-l}px`):c==="top"?(m=o?d:`${f}px`,v=`${r.floating.height+l}px`):c==="right"?(m=`${-l}px`,v=o?d:`${p}px`):c==="left"&&(m=`${r.floating.width+l}px`,v=o?d:`${p}px`),{data:{x:m,y:v}}}});function bP(e){const[t,n="center"]=e.split("-");return[t,n]}var py=mP,wP=vP,SP=_P,kP=yP,pH="Portal",my=g.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[i,s]=g.useState(!1);Bs(()=>s(!0),[]);const o=n||i&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return o?Sv.createPortal(h.jsx(Rt.div,{...r,ref:t}),o):null});my.displayName=pH;function mH(e,t){return g.useReducer((n,r)=>t[n][r]??n,e)}var Qi=e=>{const{present:t,children:n}=e,r=gH(t),i=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),s=Qt(r.ref,vH(i));return typeof n=="function"||r.isPresent?g.cloneElement(i,{ref:s}):null};Qi.displayName="Presence";function gH(e){const[t,n]=g.useState(),r=g.useRef(null),i=g.useRef(e),s=g.useRef("none"),o=e?"mounted":"unmounted",[a,l]=mH(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const c=vd(r.current);s.current=a==="mounted"?c:"none"},[a]),Bs(()=>{const c=r.current,u=i.current;if(u!==e){const f=s.current,p=vd(c);e?l("MOUNT"):p==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&f!==p?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,l]),Bs(()=>{if(t){let c;const u=t.ownerDocument.defaultView??window,d=p=>{const v=vd(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&v&&(l("ANIMATION_END"),!i.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",c=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},f=p=>{p.target===t&&(s.current=vd(r.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{u.clearTimeout(c),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:g.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function vd(e){return(e==null?void 0:e.animationName)||"none"}function vH(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)}var Om="rovingFocusGroup.onEntryFocus",_H={bubbles:!1,cancelable:!0},Cu="RovingFocusGroup",[b0,CP,xH]=YI(Cu),[yH,EP]=Uo(Cu,[xH]),[bH,wH]=yH(Cu),NP=g.forwardRef((e,t)=>h.jsx(b0.Provider,{scope:e.__scopeRovingFocusGroup,children:h.jsx(b0.Slot,{scope:e.__scopeRovingFocusGroup,children:h.jsx(SH,{...e,ref:t})})}));NP.displayName=Cu;var SH=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...d}=e,f=g.useRef(null),p=Qt(t,f),m=XI(s),[v,w]=Su({prop:o,defaultProp:a??null,onChange:l,caller:Cu}),[_,x]=g.useState(!1),b=gi(c),S=CP(n),C=g.useRef(!1),[k,N]=g.useState(0);return g.useEffect(()=>{const T=f.current;if(T)return T.addEventListener(Om,b),()=>T.removeEventListener(Om,b)},[b]),h.jsx(bH,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:v,onItemFocus:g.useCallback(T=>w(T),[w]),onItemShiftTab:g.useCallback(()=>x(!0),[]),onFocusableItemAdd:g.useCallback(()=>N(T=>T+1),[]),onFocusableItemRemove:g.useCallback(()=>N(T=>T-1),[]),children:h.jsx(Rt.div,{tabIndex:_||k===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:"none",...e.style},onMouseDown:Pe(e.onMouseDown,()=>{C.current=!0}),onFocus:Pe(e.onFocus,T=>{const z=!C.current;if(T.target===T.currentTarget&&z&&!_){const P=new CustomEvent(Om,_H);if(T.currentTarget.dispatchEvent(P),!P.defaultPrevented){const B=S().filter($=>$.focusable),A=B.find($=>$.active),R=B.find($=>$.id===v),D=[A,R,...B].filter(Boolean).map($=>$.ref.current);PP(D,u)}}C.current=!1}),onBlur:Pe(e.onBlur,()=>x(!1))})})}),TP="RovingFocusGroupItem",IP=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:o,...a}=e,l=Oi(),c=s||l,u=wH(TP,n),d=u.currentTabStopId===c,f=CP(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:v}=u;return g.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),h.jsx(b0.ItemSlot,{scope:n,id:c,focusable:r,active:i,children:h.jsx(Rt.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...a,ref:t,onMouseDown:Pe(e.onMouseDown,w=>{r?u.onItemFocus(c):w.preventDefault()}),onFocus:Pe(e.onFocus,()=>u.onItemFocus(c)),onKeyDown:Pe(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){u.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const _=EH(w,u.orientation,u.dir);if(_!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let b=f().filter(S=>S.focusable).map(S=>S.ref.current);if(_==="last")b.reverse();else if(_==="prev"||_==="next"){_==="prev"&&b.reverse();const S=b.indexOf(w.currentTarget);b=u.loop?NH(b,S+1):b.slice(S+1)}setTimeout(()=>PP(b))}}),children:typeof o=="function"?o({isCurrentTabStop:d,hasTabStop:v!=null}):o})})});IP.displayName=TP;var kH={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function CH(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function EH(e,t,n){const r=CH(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return kH[r]}function PP(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function NH(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var TH=NP,IH=IP,PH=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ea=new WeakMap,_d=new WeakMap,xd={},Bm=0,RP=function(e){return e&&(e.host||RP(e.parentNode))},RH=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=RP(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},MH=function(e,t,n,r){var i=RH(t,Array.isArray(e)?e:[e]);xd[n]||(xd[n]=new WeakMap);var s=xd[n],o=[],a=new Set,l=new Set(i),c=function(d){!d||a.has(d)||(a.add(d),c(d.parentNode))};i.forEach(c);var u=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(f){if(a.has(f))u(f);else try{var p=f.getAttribute(r),m=p!==null&&p!=="false",v=(ea.get(f)||0)+1,w=(s.get(f)||0)+1;ea.set(f,v),s.set(f,w),o.push(f),v===1&&m&&_d.set(f,!0),w===1&&f.setAttribute(n,"true"),m||f.setAttribute(r,"true")}catch(_){console.error("aria-hidden: cannot operate on ",f,_)}})};return u(t),a.clear(),Bm++,function(){o.forEach(function(d){var f=ea.get(d)-1,p=s.get(d)-1;ea.set(d,f),s.set(d,p),f||(_d.has(d)||d.removeAttribute(r),_d.delete(d)),p||d.removeAttribute(n)}),Bm--,Bm||(ea=new WeakMap,ea=new WeakMap,_d=new WeakMap,xd={})}},MP=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=PH(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),MH(r,i,n,"aria-hidden")):function(){return null}},si=function(){return si=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},si.apply(this,arguments)};function AP(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}function AH(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}var rh="right-scroll-bar-position",ih="width-before-scroll-bar",LH="with-scroll-bars-hidden",DH="--removed-body-scroll-bar-size";function zm(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function jH(e,t){var n=g.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=t,n.facade}var OH=typeof window<"u"?g.useLayoutEffect:g.useEffect,xS=new WeakMap;function BH(e,t){var n=jH(null,function(r){return e.forEach(function(i){return zm(i,r)})});return OH(function(){var r=xS.get(n);if(r){var i=new Set(r),s=new Set(e),o=n.current;i.forEach(function(a){s.has(a)||zm(a,null)}),s.forEach(function(a){i.has(a)||zm(a,o)})}xS.set(n,e)},[e]),n}function zH(e){return e}function $H(e,t){t===void 0&&(t=zH);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var o=t(s,r);return n.push(o),function(){n=n.filter(function(a){return a!==o})}},assignSyncMedium:function(s){for(r=!0;n.length;){var o=n;n=[],o.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var o=[];if(n.length){var a=n;n=[],a.forEach(s),o=n}var l=function(){var u=o;o=[],u.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(u){o.push(u),c()},filter:function(u){return o=o.filter(u),n}}}};return i}function FH(e){e===void 0&&(e={});var t=$H(null);return t.options=si({async:!0,ssr:!1},e),t}var LP=function(e){var t=e.sideCar,n=AP(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return g.createElement(r,si({},n))};LP.isSideCarExport=!0;function HH(e,t){return e.useMedium(t),LP}var DP=FH(),$m=function(){},xp=g.forwardRef(function(e,t){var n=g.useRef(null),r=g.useState({onScrollCapture:$m,onWheelCapture:$m,onTouchMoveCapture:$m}),i=r[0],s=r[1],o=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,v=e.inert,w=e.allowPinchZoom,_=e.as,x=_===void 0?"div":_,b=e.gapMode,S=AP(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=f,k=BH([n,t]),N=si(si({},S),i);return g.createElement(g.Fragment,null,u&&g.createElement(C,{sideCar:DP,removeScrollBar:c,shards:d,noRelative:p,noIsolation:m,inert:v,setCallbacks:s,allowPinchZoom:!!w,lockRef:n,gapMode:b}),o?g.cloneElement(g.Children.only(a),si(si({},N),{ref:k})):g.createElement(x,si({},N,{className:l,ref:k}),a))});xp.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};xp.classNames={fullWidth:ih,zeroRight:rh};var UH=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function WH(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=UH();return t&&e.setAttribute("nonce",t),e}function VH(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function qH(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var KH=function(){var e=0,t=null;return{add:function(n){e==0&&(t=WH())&&(VH(t,n),qH(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},GH=function(){var e=KH();return function(t,n){g.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},jP=function(){var e=GH(),t=function(n){var r=n.styles,i=n.dynamic;return e(r,i),null};return t},YH={left:0,top:0,right:0,gap:0},Fm=function(e){return parseInt(e||"",10)||0},XH=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[Fm(n),Fm(r),Fm(i)]},QH=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return YH;var t=XH(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},ZH=jP(),La="data-scroll-locked",JH=function(e,t,n,r){var i=e.left,s=e.top,o=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
471
|
+
*/const TF=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],IF=ue("zap",TF);function II(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=II(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function PI(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=II(e))&&(r&&(r+=" "),r+=t);return r}const PF=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},RF=(e,t)=>({classGroupId:e,validator:t}),RI=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),nf="-",Kw=[],MF="arbitrary..",AF=e=>{const t=DF(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return LF(o);const a=o.split(nf),l=a[0]===""&&a.length>1?1:0;return MI(a,l,t)},getConflictingClassGroupIds:(o,a)=>{if(a){const l=r[o],c=n[o];return l?c?PF(c,l):l:c||Kw}return n[o]||Kw}}},MI=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const i=e[t],s=n.nextPart.get(i);if(s){const c=MI(e,t+1,s);if(c)return c}const o=n.validators;if(o===null)return;const a=t===0?e.join(nf):e.slice(t).join(nf),l=o.length;for(let c=0;c<l;c++){const u=o[c];if(u.validator(a))return u.classGroupId}},LF=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?MF+r:void 0})(),DF=e=>{const{theme:t,classGroups:n}=e;return jF(n,t)},jF=(e,t)=>{const n=RI();for(const r in e){const i=e[r];ty(i,n,r,t)}return n},ty=(e,t,n,r)=>{const i=e.length;for(let s=0;s<i;s++){const o=e[s];OF(o,t,n,r)}},OF=(e,t,n,r)=>{if(typeof e=="string"){BF(e,t,n);return}if(typeof e=="function"){zF(e,t,n,r);return}$F(e,t,n,r)},BF=(e,t,n)=>{const r=e===""?t:AI(t,e);r.classGroupId=n},zF=(e,t,n,r)=>{if(FF(e)){ty(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(RF(n,e))},$F=(e,t,n,r)=>{const i=Object.entries(e),s=i.length;for(let o=0;o<s;o++){const[a,l]=i[o];ty(l,AI(t,a),n,r)}},AI=(e,t)=>{let n=e;const r=t.split(nf),i=r.length;for(let s=0;s<i;s++){const o=r[s];let a=n.nextPart.get(o);a||(a=RI(),n.nextPart.set(o,a)),n=a}return n},FF=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,HF=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const i=(s,o)=>{n[s]=o,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(s){let o=n[s];if(o!==void 0)return o;if((o=r[s])!==void 0)return i(s,o),o},set(s,o){s in n?n[s]=o:i(s,o)}}},g0="!",Gw=":",UF=[],Yw=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),WF=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=i=>{const s=[];let o=0,a=0,l=0,c;const u=i.length;for(let v=0;v<u;v++){const w=i[v];if(o===0&&a===0){if(w===Gw){s.push(i.slice(l,v)),l=v+1;continue}if(w==="/"){c=v;continue}}w==="["?o++:w==="]"?o--:w==="("?a++:w===")"&&a--}const d=s.length===0?i:i.slice(l);let f=d,p=!1;d.endsWith(g0)?(f=d.slice(0,-1),p=!0):d.startsWith(g0)&&(f=d.slice(1),p=!0);const m=c&&c>l?c-l:void 0;return Yw(s,p,f,m)};if(t){const i=t+Gw,s=r;r=o=>o.startsWith(i)?s(o.slice(i.length)):Yw(UF,!1,o,void 0,!0)}if(n){const i=r;r=s=>n({className:s,parseClassName:i})}return r},VF=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let i=[];for(let s=0;s<n.length;s++){const o=n[s],a=o[0]==="[",l=t.has(o);a||l?(i.length>0&&(i.sort(),r.push(...i),i=[]),r.push(o)):i.push(o)}return i.length>0&&(i.sort(),r.push(...i)),r}},qF=e=>({cache:HF(e.cacheSize),parseClassName:WF(e),sortModifiers:VF(e),...AF(e)}),KF=/\s+/,GF=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:s}=t,o=[],a=e.trim().split(KF);let l="";for(let c=a.length-1;c>=0;c-=1){const u=a[c],{isExternal:d,modifiers:f,hasImportantModifier:p,baseClassName:m,maybePostfixModifierPosition:v}=n(u);if(d){l=u+(l.length>0?" "+l:l);continue}let w=!!v,_=r(w?m.substring(0,v):m);if(!_){if(!w){l=u+(l.length>0?" "+l:l);continue}if(_=r(m),!_){l=u+(l.length>0?" "+l:l);continue}w=!1}const x=f.length===0?"":f.length===1?f[0]:s(f).join(":"),b=p?x+g0:x,S=b+_;if(o.indexOf(S)>-1)continue;o.push(S);const C=i(_,w);for(let k=0;k<C.length;++k){const N=C[k];o.push(b+N)}l=u+(l.length>0?" "+l:l)}return l},YF=(...e)=>{let t=0,n,r,i="";for(;t<e.length;)(n=e[t++])&&(r=LI(n))&&(i&&(i+=" "),i+=r);return i},LI=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=LI(e[r]))&&(n&&(n+=" "),n+=t);return n},XF=(e,...t)=>{let n,r,i,s;const o=l=>{const c=t.reduce((u,d)=>d(u),e());return n=qF(c),r=n.cache.get,i=n.cache.set,s=a,a(l)},a=l=>{const c=r(l);if(c)return c;const u=GF(l,n);return i(l,u),u};return s=o,(...l)=>s(YF(...l))},QF=[],qt=e=>{const t=n=>n[e]||QF;return t.isThemeGetter=!0,t},DI=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,jI=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ZF=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,JF=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,e9=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,t9=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,n9=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,r9=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,is=e=>ZF.test(e),ze=e=>!!e&&!Number.isNaN(Number(e)),ss=e=>!!e&&Number.isInteger(Number(e)),Pm=e=>e.endsWith("%")&&ze(e.slice(0,-1)),ki=e=>JF.test(e),OI=()=>!0,i9=e=>e9.test(e)&&!t9.test(e),ny=()=>!1,s9=e=>n9.test(e),o9=e=>r9.test(e),a9=e=>!fe(e)&&!pe(e),l9=e=>Vs(e,$I,ny),fe=e=>DI.test(e),Js=e=>Vs(e,FI,i9),Xw=e=>Vs(e,g9,ze),c9=e=>Vs(e,UI,OI),u9=e=>Vs(e,HI,ny),Qw=e=>Vs(e,BI,ny),d9=e=>Vs(e,zI,o9),pd=e=>Vs(e,WI,s9),pe=e=>jI.test(e),Hl=e=>Ho(e,FI),h9=e=>Ho(e,HI),Zw=e=>Ho(e,BI),f9=e=>Ho(e,$I),p9=e=>Ho(e,zI),md=e=>Ho(e,WI,!0),m9=e=>Ho(e,UI,!0),Vs=(e,t,n)=>{const r=DI.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Ho=(e,t,n=!1)=>{const r=jI.exec(e);return r?r[1]?t(r[1]):n:!1},BI=e=>e==="position"||e==="percentage",zI=e=>e==="image"||e==="url",$I=e=>e==="length"||e==="size"||e==="bg-size",FI=e=>e==="length",g9=e=>e==="number",HI=e=>e==="family-name",UI=e=>e==="number"||e==="weight",WI=e=>e==="shadow",v9=()=>{const e=qt("color"),t=qt("font"),n=qt("text"),r=qt("font-weight"),i=qt("tracking"),s=qt("leading"),o=qt("breakpoint"),a=qt("container"),l=qt("spacing"),c=qt("radius"),u=qt("shadow"),d=qt("inset-shadow"),f=qt("text-shadow"),p=qt("drop-shadow"),m=qt("blur"),v=qt("perspective"),w=qt("aspect"),_=qt("ease"),x=qt("animate"),b=()=>["auto","avoid","all","avoid-page","page","left","right","column"],S=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],C=()=>[...S(),pe,fe],k=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],T=()=>[pe,fe,l],z=()=>[is,"full","auto",...T()],P=()=>[ss,"none","subgrid",pe,fe],B=()=>["auto",{span:["full",ss,pe,fe]},ss,pe,fe],A=()=>[ss,"auto",pe,fe],R=()=>["auto","min","max","fr",pe,fe],M=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],D=()=>["start","end","center","stretch","center-safe","end-safe"],$=()=>["auto",...T()],F=()=>[is,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],j=()=>[is,"screen","full","dvw","lvw","svw","min","max","fit",...T()],O=()=>[is,"screen","full","lh","dvh","lvh","svh","min","max","fit",...T()],E=()=>[e,pe,fe],H=()=>[...S(),Zw,Qw,{position:[pe,fe]}],q=()=>["no-repeat",{repeat:["","x","y","space","round"]}],L=()=>["auto","cover","contain",f9,l9,{size:[pe,fe]}],re=()=>[Pm,Hl,Js],se=()=>["","none","full",c,pe,fe],K=()=>["",ze,Hl,Js],ge=()=>["solid","dashed","dotted","double"],Re=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ce=()=>[ze,Pm,Zw,Qw],Le=()=>["","none",m,pe,fe],Oe=()=>["none",ze,pe,fe],Ae=()=>["none",ze,pe,fe],_e=()=>[ze,pe,fe],Qe=()=>[is,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ki],breakpoint:[ki],color:[OI],container:[ki],"drop-shadow":[ki],ease:["in","out","in-out"],font:[a9],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ki],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ki],shadow:[ki],spacing:["px",ze],text:[ki],"text-shadow":[ki],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",is,fe,pe,w]}],container:["container"],columns:[{columns:[ze,fe,pe,a]}],"break-after":[{"break-after":b()}],"break-before":[{"break-before":b()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:C()}],overflow:[{overflow:k()}],"overflow-x":[{"overflow-x":k()}],"overflow-y":[{"overflow-y":k()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:z()}],"inset-x":[{"inset-x":z()}],"inset-y":[{"inset-y":z()}],start:[{"inset-s":z(),start:z()}],end:[{"inset-e":z(),end:z()}],"inset-bs":[{"inset-bs":z()}],"inset-be":[{"inset-be":z()}],top:[{top:z()}],right:[{right:z()}],bottom:[{bottom:z()}],left:[{left:z()}],visibility:["visible","invisible","collapse"],z:[{z:[ss,"auto",pe,fe]}],basis:[{basis:[is,"full","auto",a,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ze,is,"auto","initial","none",fe]}],grow:[{grow:["",ze,pe,fe]}],shrink:[{shrink:["",ze,pe,fe]}],order:[{order:[ss,"first","last","none",pe,fe]}],"grid-cols":[{"grid-cols":P()}],"col-start-end":[{col:B()}],"col-start":[{"col-start":A()}],"col-end":[{"col-end":A()}],"grid-rows":[{"grid-rows":P()}],"row-start-end":[{row:B()}],"row-start":[{"row-start":A()}],"row-end":[{"row-end":A()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":R()}],"auto-rows":[{"auto-rows":R()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...M(),"normal"]}],"justify-items":[{"justify-items":[...D(),"normal"]}],"justify-self":[{"justify-self":["auto",...D()]}],"align-content":[{content:["normal",...M()]}],"align-items":[{items:[...D(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...D(),{baseline:["","last"]}]}],"place-content":[{"place-content":M()}],"place-items":[{"place-items":[...D(),"baseline"]}],"place-self":[{"place-self":["auto",...D()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pbs:[{pbs:T()}],pbe:[{pbe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:$()}],mx:[{mx:$()}],my:[{my:$()}],ms:[{ms:$()}],me:[{me:$()}],mbs:[{mbs:$()}],mbe:[{mbe:$()}],mt:[{mt:$()}],mr:[{mr:$()}],mb:[{mb:$()}],ml:[{ml:$()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],"inline-size":[{inline:["auto",...j()]}],"min-inline-size":[{"min-inline":["auto",...j()]}],"max-inline-size":[{"max-inline":["none",...j()]}],"block-size":[{block:["auto",...O()]}],"min-block-size":[{"min-block":["auto",...O()]}],"max-block-size":[{"max-block":["none",...O()]}],w:[{w:[a,"screen",...F()]}],"min-w":[{"min-w":[a,"screen","none",...F()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[o]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh",...F()]}],"font-size":[{text:["base",n,Hl,Js]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,m9,c9]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Pm,fe]}],"font-family":[{font:[h9,u9,t]}],"font-features":[{"font-features":[fe]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,pe,fe]}],"line-clamp":[{"line-clamp":[ze,"none",pe,Xw]}],leading:[{leading:[s,...T()]}],"list-image":[{"list-image":["none",pe,fe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",pe,fe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:E()}],"text-color":[{text:E()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ge(),"wavy"]}],"text-decoration-thickness":[{decoration:[ze,"from-font","auto",pe,Js]}],"text-decoration-color":[{decoration:E()}],"underline-offset":[{"underline-offset":[ze,"auto",pe,fe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",pe,fe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",pe,fe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:H()}],"bg-repeat":[{bg:q()}],"bg-size":[{bg:L()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ss,pe,fe],radial:["",pe,fe],conic:[ss,pe,fe]},p9,d9]}],"bg-color":[{bg:E()}],"gradient-from-pos":[{from:re()}],"gradient-via-pos":[{via:re()}],"gradient-to-pos":[{to:re()}],"gradient-from":[{from:E()}],"gradient-via":[{via:E()}],"gradient-to":[{to:E()}],rounded:[{rounded:se()}],"rounded-s":[{"rounded-s":se()}],"rounded-e":[{"rounded-e":se()}],"rounded-t":[{"rounded-t":se()}],"rounded-r":[{"rounded-r":se()}],"rounded-b":[{"rounded-b":se()}],"rounded-l":[{"rounded-l":se()}],"rounded-ss":[{"rounded-ss":se()}],"rounded-se":[{"rounded-se":se()}],"rounded-ee":[{"rounded-ee":se()}],"rounded-es":[{"rounded-es":se()}],"rounded-tl":[{"rounded-tl":se()}],"rounded-tr":[{"rounded-tr":se()}],"rounded-br":[{"rounded-br":se()}],"rounded-bl":[{"rounded-bl":se()}],"border-w":[{border:K()}],"border-w-x":[{"border-x":K()}],"border-w-y":[{"border-y":K()}],"border-w-s":[{"border-s":K()}],"border-w-e":[{"border-e":K()}],"border-w-bs":[{"border-bs":K()}],"border-w-be":[{"border-be":K()}],"border-w-t":[{"border-t":K()}],"border-w-r":[{"border-r":K()}],"border-w-b":[{"border-b":K()}],"border-w-l":[{"border-l":K()}],"divide-x":[{"divide-x":K()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":K()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ge(),"hidden","none"]}],"divide-style":[{divide:[...ge(),"hidden","none"]}],"border-color":[{border:E()}],"border-color-x":[{"border-x":E()}],"border-color-y":[{"border-y":E()}],"border-color-s":[{"border-s":E()}],"border-color-e":[{"border-e":E()}],"border-color-bs":[{"border-bs":E()}],"border-color-be":[{"border-be":E()}],"border-color-t":[{"border-t":E()}],"border-color-r":[{"border-r":E()}],"border-color-b":[{"border-b":E()}],"border-color-l":[{"border-l":E()}],"divide-color":[{divide:E()}],"outline-style":[{outline:[...ge(),"none","hidden"]}],"outline-offset":[{"outline-offset":[ze,pe,fe]}],"outline-w":[{outline:["",ze,Hl,Js]}],"outline-color":[{outline:E()}],shadow:[{shadow:["","none",u,md,pd]}],"shadow-color":[{shadow:E()}],"inset-shadow":[{"inset-shadow":["none",d,md,pd]}],"inset-shadow-color":[{"inset-shadow":E()}],"ring-w":[{ring:K()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:E()}],"ring-offset-w":[{"ring-offset":[ze,Js]}],"ring-offset-color":[{"ring-offset":E()}],"inset-ring-w":[{"inset-ring":K()}],"inset-ring-color":[{"inset-ring":E()}],"text-shadow":[{"text-shadow":["none",f,md,pd]}],"text-shadow-color":[{"text-shadow":E()}],opacity:[{opacity:[ze,pe,fe]}],"mix-blend":[{"mix-blend":[...Re(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Re()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[ze]}],"mask-image-linear-from-pos":[{"mask-linear-from":ce()}],"mask-image-linear-to-pos":[{"mask-linear-to":ce()}],"mask-image-linear-from-color":[{"mask-linear-from":E()}],"mask-image-linear-to-color":[{"mask-linear-to":E()}],"mask-image-t-from-pos":[{"mask-t-from":ce()}],"mask-image-t-to-pos":[{"mask-t-to":ce()}],"mask-image-t-from-color":[{"mask-t-from":E()}],"mask-image-t-to-color":[{"mask-t-to":E()}],"mask-image-r-from-pos":[{"mask-r-from":ce()}],"mask-image-r-to-pos":[{"mask-r-to":ce()}],"mask-image-r-from-color":[{"mask-r-from":E()}],"mask-image-r-to-color":[{"mask-r-to":E()}],"mask-image-b-from-pos":[{"mask-b-from":ce()}],"mask-image-b-to-pos":[{"mask-b-to":ce()}],"mask-image-b-from-color":[{"mask-b-from":E()}],"mask-image-b-to-color":[{"mask-b-to":E()}],"mask-image-l-from-pos":[{"mask-l-from":ce()}],"mask-image-l-to-pos":[{"mask-l-to":ce()}],"mask-image-l-from-color":[{"mask-l-from":E()}],"mask-image-l-to-color":[{"mask-l-to":E()}],"mask-image-x-from-pos":[{"mask-x-from":ce()}],"mask-image-x-to-pos":[{"mask-x-to":ce()}],"mask-image-x-from-color":[{"mask-x-from":E()}],"mask-image-x-to-color":[{"mask-x-to":E()}],"mask-image-y-from-pos":[{"mask-y-from":ce()}],"mask-image-y-to-pos":[{"mask-y-to":ce()}],"mask-image-y-from-color":[{"mask-y-from":E()}],"mask-image-y-to-color":[{"mask-y-to":E()}],"mask-image-radial":[{"mask-radial":[pe,fe]}],"mask-image-radial-from-pos":[{"mask-radial-from":ce()}],"mask-image-radial-to-pos":[{"mask-radial-to":ce()}],"mask-image-radial-from-color":[{"mask-radial-from":E()}],"mask-image-radial-to-color":[{"mask-radial-to":E()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":S()}],"mask-image-conic-pos":[{"mask-conic":[ze]}],"mask-image-conic-from-pos":[{"mask-conic-from":ce()}],"mask-image-conic-to-pos":[{"mask-conic-to":ce()}],"mask-image-conic-from-color":[{"mask-conic-from":E()}],"mask-image-conic-to-color":[{"mask-conic-to":E()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:H()}],"mask-repeat":[{mask:q()}],"mask-size":[{mask:L()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",pe,fe]}],filter:[{filter:["","none",pe,fe]}],blur:[{blur:Le()}],brightness:[{brightness:[ze,pe,fe]}],contrast:[{contrast:[ze,pe,fe]}],"drop-shadow":[{"drop-shadow":["","none",p,md,pd]}],"drop-shadow-color":[{"drop-shadow":E()}],grayscale:[{grayscale:["",ze,pe,fe]}],"hue-rotate":[{"hue-rotate":[ze,pe,fe]}],invert:[{invert:["",ze,pe,fe]}],saturate:[{saturate:[ze,pe,fe]}],sepia:[{sepia:["",ze,pe,fe]}],"backdrop-filter":[{"backdrop-filter":["","none",pe,fe]}],"backdrop-blur":[{"backdrop-blur":Le()}],"backdrop-brightness":[{"backdrop-brightness":[ze,pe,fe]}],"backdrop-contrast":[{"backdrop-contrast":[ze,pe,fe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",ze,pe,fe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ze,pe,fe]}],"backdrop-invert":[{"backdrop-invert":["",ze,pe,fe]}],"backdrop-opacity":[{"backdrop-opacity":[ze,pe,fe]}],"backdrop-saturate":[{"backdrop-saturate":[ze,pe,fe]}],"backdrop-sepia":[{"backdrop-sepia":["",ze,pe,fe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",pe,fe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[ze,"initial",pe,fe]}],ease:[{ease:["linear","initial",_,pe,fe]}],delay:[{delay:[ze,pe,fe]}],animate:[{animate:["none",x,pe,fe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,pe,fe]}],"perspective-origin":[{"perspective-origin":C()}],rotate:[{rotate:Oe()}],"rotate-x":[{"rotate-x":Oe()}],"rotate-y":[{"rotate-y":Oe()}],"rotate-z":[{"rotate-z":Oe()}],scale:[{scale:Ae()}],"scale-x":[{"scale-x":Ae()}],"scale-y":[{"scale-y":Ae()}],"scale-z":[{"scale-z":Ae()}],"scale-3d":["scale-3d"],skew:[{skew:_e()}],"skew-x":[{"skew-x":_e()}],"skew-y":[{"skew-y":_e()}],transform:[{transform:[pe,fe,"","none","gpu","cpu"]}],"transform-origin":[{origin:C()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Qe()}],"translate-x":[{"translate-x":Qe()}],"translate-y":[{"translate-y":Qe()}],"translate-z":[{"translate-z":Qe()}],"translate-none":["translate-none"],accent:[{accent:E()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:E()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",pe,fe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mbs":[{"scroll-mbs":T()}],"scroll-mbe":[{"scroll-mbe":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pbs":[{"scroll-pbs":T()}],"scroll-pbe":[{"scroll-pbe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",pe,fe]}],fill:[{fill:["none",...E()]}],"stroke-w":[{stroke:[ze,Hl,Js,Xw]}],stroke:[{stroke:["none",...E()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},_9=XF(v9);function ne(...e){return _9(PI(e))}const x9={path:"m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z"},Jw={path:"M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"},y9="M2 2H17V12H12V17H7V22H2ZM7 7V12H12V7ZM17 12H22V22H17Z",VI={claude:x9.path,codex:Jw.path,"codex-cloud":Jw.path,pi:y9},b9=new Set(["pi"]);function w9(e){return e!=null&&e in VI}function dp({tool:e,className:t}){const n=e?VI[e]:void 0;return n?h.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:t,"aria-hidden":"true",children:h.jsx("path",{d:n,fillRule:e&&b9.has(e)?"evenodd":void 0})}):h.jsx(up,{className:t})}function ry(e){return e==="codex"?"Codex":e==="codex-cloud"?"Codex(云上)":e==="pi"?"pi":"Claude Code"}function hp(e){return e==="claude"?"text-engine-claude":e==="codex"?"text-engine-codex":e==="codex-cloud"?"text-engine-codex-cloud":e==="pi"?"text-engine-pi":"text-text-400"}function iy(e){return e.label||e.aiLabel||e.larkChatName||e.larkChatId||e.cwd.split("/").filter(Boolean).pop()||e.sessionId.slice(0,8)}function S9(e){const t=new Date(e),n=Date.now()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return"just now";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);return s<7?`${s}d ago`:t.toLocaleDateString()}function k9(e){return`'${e.replace(/'/g,"'\\''")}'`}function C9(e){return e.toolSessionId?e.tool==="codex"?`codex resume ${e.toolSessionId}`:e.tool==="pi"?`pi --session-id ${e.toolSessionId}`:`claude --resume ${e.toolSessionId} --permission-mode bypassPermissions`:null}function qI(e){const t=C9(e);return!t||!e.cwd?null:`cd ${k9(e.cwd)} && ${t}`}function Pe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}function eS(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function wu(...e){return t=>{let n=!1;const r=e.map(i=>{const s=eS(i,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let i=0;i<r.length;i++){const s=r[i];typeof s=="function"?s():eS(e[i],null)}}}}function Qt(...e){return g.useCallback(wu(...e),e)}function E9(e,t){const n=g.createContext(t),r=s=>{const{children:o,...a}=s,l=g.useMemo(()=>a,Object.values(a));return h.jsx(n.Provider,{value:l,children:o})};r.displayName=e+"Provider";function i(s){const o=g.useContext(n);if(o)return o;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,i]}function Uo(e,t=[]){let n=[];function r(s,o){const a=g.createContext(o),l=n.length;n=[...n,o];const c=d=>{var _;const{scope:f,children:p,...m}=d,v=((_=f==null?void 0:f[e])==null?void 0:_[l])||a,w=g.useMemo(()=>m,Object.values(m));return h.jsx(v.Provider,{value:w,children:p})};c.displayName=s+"Provider";function u(d,f){var v;const p=((v=f==null?void 0:f[e])==null?void 0:v[l])||a,m=g.useContext(p);if(m)return m;if(o!==void 0)return o;throw new Error(`\`${d}\` must be used within \`${s}\``)}return[c,u]}const i=()=>{const s=n.map(o=>g.createContext(o));return function(a){const l=(a==null?void 0:a[e])||s;return g.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return i.scopeName=e,[r,N9(i,...t)]}function N9(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const o=r.reduce((a,{useScope:l,scopeName:c})=>{const d=l(s)[`__scope${c}`];return{...a,...d}},{});return g.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return n.scopeName=t.scopeName,n}var Bs=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},T9=cl[" useInsertionEffect ".trim().toString()]||Bs;function Su({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[i,s,o]=I9({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:i;{const u=g.useRef(e!==void 0);g.useEffect(()=>{const d=u.current;d!==a&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=a},[a,r])}const c=g.useCallback(u=>{var d;if(a){const f=P9(u)?u(e):u;f!==e&&((d=o.current)==null||d.call(o,f))}else s(u)},[a,e,s,o]);return[l,c]}function I9({defaultProp:e,onChange:t}){const[n,r]=g.useState(e),i=g.useRef(n),s=g.useRef(t);return T9(()=>{s.current=t},[t]),g.useEffect(()=>{var o;i.current!==n&&((o=s.current)==null||o.call(s,n),i.current=n)},[n,i]),[n,r,s]}function P9(e){return typeof e=="function"}function tu(e){const t=R9(e),n=g.forwardRef((r,i)=>{const{children:s,...o}=r,a=g.Children.toArray(s),l=a.find(A9);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}function R9(e){const t=g.forwardRef((n,r)=>{const{children:i,...s}=n;if(g.isValidElement(i)){const o=D9(i),a=L9(s,i.props);return i.type!==g.Fragment&&(a.ref=r?wu(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 KI=Symbol("radix.slottable");function M9(e){const t=({children:n})=>h.jsx(h.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=KI,t}function A9(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===KI}function L9(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 D9(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)}var j9=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Rt=j9.reduce((e,t)=>{const n=tu(`Primitive.${t}`),r=g.forwardRef((i,s)=>{const{asChild:o,...a}=i,l=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),h.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function GI(e,t){e&&hl.flushSync(()=>e.dispatchEvent(t))}function YI(e){const t=e+"CollectionProvider",[n,r]=Uo(t),[i,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=v=>{const{scope:w,children:_}=v,x=Ge.useRef(null),b=Ge.useRef(new Map).current;return h.jsx(i,{scope:w,itemMap:b,collectionRef:x,children:_})};o.displayName=t;const a=e+"CollectionSlot",l=tu(a),c=Ge.forwardRef((v,w)=>{const{scope:_,children:x}=v,b=s(a,_),S=Qt(w,b.collectionRef);return h.jsx(l,{ref:S,children:x})});c.displayName=a;const u=e+"CollectionItemSlot",d="data-radix-collection-item",f=tu(u),p=Ge.forwardRef((v,w)=>{const{scope:_,children:x,...b}=v,S=Ge.useRef(null),C=Qt(w,S),k=s(u,_);return Ge.useEffect(()=>(k.itemMap.set(S,{ref:S,...b}),()=>void k.itemMap.delete(S))),h.jsx(f,{[d]:"",ref:C,children:x})});p.displayName=u;function m(v){const w=s(e+"CollectionConsumer",v);return Ge.useCallback(()=>{const x=w.collectionRef.current;if(!x)return[];const b=Array.from(x.querySelectorAll(`[${d}]`));return Array.from(w.itemMap.values()).sort((k,N)=>b.indexOf(k.ref.current)-b.indexOf(N.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:o,Slot:c,ItemSlot:p},m,r]}var O9=g.createContext(void 0);function XI(e){const t=g.useContext(O9);return e||t||"ltr"}function gi(e){const t=g.useRef(e);return g.useEffect(()=>{t.current=e}),g.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function B9(e,t=globalThis==null?void 0:globalThis.document){const n=gi(e);g.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var z9="DismissableLayer",v0="dismissableLayer.update",$9="dismissableLayer.pointerDownOutside",F9="dismissableLayer.focusOutside",tS,QI=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),fp=g.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:o,onDismiss:a,...l}=e,c=g.useContext(QI),[u,d]=g.useState(null),f=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=g.useState({}),m=Qt(t,N=>d(N)),v=Array.from(c.layers),[w]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),_=v.indexOf(w),x=u?v.indexOf(u):-1,b=c.layersWithOutsidePointerEventsDisabled.size>0,S=x>=_,C=W9(N=>{const T=N.target,z=[...c.branches].some(P=>P.contains(T));!S||z||(i==null||i(N),o==null||o(N),N.defaultPrevented||a==null||a())},f),k=V9(N=>{const T=N.target;[...c.branches].some(P=>P.contains(T))||(s==null||s(N),o==null||o(N),N.defaultPrevented||a==null||a())},f);return B9(N=>{x===c.layers.size-1&&(r==null||r(N),!N.defaultPrevented&&a&&(N.preventDefault(),a()))},f),g.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(tS=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),nS(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=tS)}},[u,f,n,c]),g.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),nS())},[u,c]),g.useEffect(()=>{const N=()=>p({});return document.addEventListener(v0,N),()=>document.removeEventListener(v0,N)},[]),h.jsx(Rt.div,{...l,ref:m,style:{pointerEvents:b?S?"auto":"none":void 0,...e.style},onFocusCapture:Pe(e.onFocusCapture,k.onFocusCapture),onBlurCapture:Pe(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:Pe(e.onPointerDownCapture,C.onPointerDownCapture)})});fp.displayName=z9;var H9="DismissableLayerBranch",U9=g.forwardRef((e,t)=>{const n=g.useContext(QI),r=g.useRef(null),i=Qt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),h.jsx(Rt.div,{...e,ref:i})});U9.displayName=H9;function W9(e,t=globalThis==null?void 0:globalThis.document){const n=gi(e),r=g.useRef(!1),i=g.useRef(()=>{});return g.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){ZI($9,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",i.current),i.current=l,t.addEventListener("click",i.current,{once:!0})):l()}else t.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",s),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function V9(e,t=globalThis==null?void 0:globalThis.document){const n=gi(e),r=g.useRef(!1);return g.useEffect(()=>{const i=s=>{s.target&&!r.current&&ZI(F9,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function nS(){const e=new CustomEvent(v0);document.dispatchEvent(e)}function ZI(e,t,n,{discrete:r}){const i=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?GI(i,s):i.dispatchEvent(s)}var Rm=0;function JI(){g.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??rS()),document.body.insertAdjacentElement("beforeend",e[1]??rS()),Rm++,()=>{Rm===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Rm--}},[])}function rS(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Mm="focusScope.autoFocusOnMount",Am="focusScope.autoFocusOnUnmount",iS={bubbles:!1,cancelable:!0},q9="FocusScope",sy=g.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:s,...o}=e,[a,l]=g.useState(null),c=gi(i),u=gi(s),d=g.useRef(null),f=Qt(t,v=>l(v)),p=g.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;g.useEffect(()=>{if(r){let v=function(b){if(p.paused||!a)return;const S=b.target;a.contains(S)?d.current=S:ds(d.current,{select:!0})},w=function(b){if(p.paused||!a)return;const S=b.relatedTarget;S!==null&&(a.contains(S)||ds(d.current,{select:!0}))},_=function(b){if(document.activeElement===document.body)for(const C of b)C.removedNodes.length>0&&ds(a)};document.addEventListener("focusin",v),document.addEventListener("focusout",w);const x=new MutationObserver(_);return a&&x.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",w),x.disconnect()}}},[r,a,p.paused]),g.useEffect(()=>{if(a){oS.add(p);const v=document.activeElement;if(!a.contains(v)){const _=new CustomEvent(Mm,iS);a.addEventListener(Mm,c),a.dispatchEvent(_),_.defaultPrevented||(K9(Z9(eP(a)),{select:!0}),document.activeElement===v&&ds(a))}return()=>{a.removeEventListener(Mm,c),setTimeout(()=>{const _=new CustomEvent(Am,iS);a.addEventListener(Am,u),a.dispatchEvent(_),_.defaultPrevented||ds(v??document.body,{select:!0}),a.removeEventListener(Am,u),oS.remove(p)},0)}}},[a,c,u,p]);const m=g.useCallback(v=>{if(!n&&!r||p.paused)return;const w=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,_=document.activeElement;if(w&&_){const x=v.currentTarget,[b,S]=G9(x);b&&S?!v.shiftKey&&_===S?(v.preventDefault(),n&&ds(b,{select:!0})):v.shiftKey&&_===b&&(v.preventDefault(),n&&ds(S,{select:!0})):_===x&&v.preventDefault()}},[n,r,p.paused]);return h.jsx(Rt.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});sy.displayName=q9;function K9(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(ds(r,{select:t}),document.activeElement!==n)return}function G9(e){const t=eP(e),n=sS(t,e),r=sS(t.reverse(),e);return[n,r]}function eP(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function sS(e,t){for(const n of e)if(!Y9(n,{upTo:t}))return n}function Y9(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function X9(e){return e instanceof HTMLInputElement&&"select"in e}function ds(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&X9(e)&&t&&e.select()}}var oS=Q9();function Q9(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=aS(e,t),e.unshift(t)},remove(t){var n;e=aS(e,t),(n=e[0])==null||n.resume()}}}function aS(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Z9(e){return e.filter(t=>t.tagName!=="A")}var J9=cl[" useId ".trim().toString()]||(()=>{}),e7=0;function Oi(e){const[t,n]=g.useState(J9());return Bs(()=>{n(r=>r??String(e7++))},[e]),t?`radix-${t}`:""}const t7=["top","right","bottom","left"],zs=Math.min,nr=Math.max,rf=Math.round,gd=Math.floor,hi=e=>({x:e,y:e}),n7={left:"right",right:"left",bottom:"top",top:"bottom"};function _0(e,t,n){return nr(e,zs(t,n))}function Wi(e,t){return typeof e=="function"?e(t):e}function Vi(e){return e.split("-")[0]}function yl(e){return e.split("-")[1]}function oy(e){return e==="x"?"y":"x"}function ay(e){return e==="y"?"height":"width"}function oi(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function ly(e){return oy(oi(e))}function r7(e,t,n){n===void 0&&(n=!1);const r=yl(e),i=ly(e),s=ay(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=sf(o)),[o,sf(o)]}function i7(e){const t=sf(e);return[x0(e),t,x0(t)]}function x0(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const lS=["left","right"],cS=["right","left"],s7=["top","bottom"],o7=["bottom","top"];function a7(e,t,n){switch(e){case"top":case"bottom":return n?t?cS:lS:t?lS:cS;case"left":case"right":return t?s7:o7;default:return[]}}function l7(e,t,n,r){const i=yl(e);let s=a7(Vi(e),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),t&&(s=s.concat(s.map(x0)))),s}function sf(e){const t=Vi(e);return n7[t]+e.slice(t.length)}function c7(e){return{top:0,right:0,bottom:0,left:0,...e}}function tP(e){return typeof e!="number"?c7(e):{top:e,right:e,bottom:e,left:e}}function of(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function uS(e,t,n){let{reference:r,floating:i}=e;const s=oi(t),o=ly(t),a=ay(o),l=Vi(t),c=s==="y",u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[a]/2-i[a]/2;let p;switch(l){case"top":p={x:u,y:r.y-i.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:d};break;case"left":p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(yl(t)){case"start":p[o]-=f*(n&&c?-1:1);break;case"end":p[o]+=f*(n&&c?-1:1);break}return p}async function u7(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:o,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=Wi(t,e),m=tP(p),w=a[f?d==="floating"?"reference":"floating":d],_=of(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(w)))==null||n?w:w.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),x=d==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,b=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),S=await(s.isElement==null?void 0:s.isElement(b))?await(s.getScale==null?void 0:s.getScale(b))||{x:1,y:1}:{x:1,y:1},C=of(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:x,offsetParent:b,strategy:l}):x);return{top:(_.top-C.top+m.top)/S.y,bottom:(C.bottom-_.bottom+m.bottom)/S.y,left:(_.left-C.left+m.left)/S.x,right:(C.right-_.right+m.right)/S.x}}const d7=50,h7=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,a=o.detectOverflow?o:{...o,detectOverflow:u7},l=await(o.isRTL==null?void 0:o.isRTL(t));let c=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=uS(c,r,l),f=r,p=0;const m={};for(let v=0;v<s.length;v++){const w=s[v];if(!w)continue;const{name:_,fn:x}=w,{x:b,y:S,data:C,reset:k}=await x({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:c,platform:a,elements:{reference:e,floating:t}});u=b??u,d=S??d,m[_]={...m[_],...C},k&&p<d7&&(p++,typeof k=="object"&&(k.placement&&(f=k.placement),k.rects&&(c=k.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):k.rects),{x:u,y:d}=uS(c,f,l)),v=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},f7=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:o,elements:a,middlewareData:l}=t,{element:c,padding:u=0}=Wi(e,t)||{};if(c==null)return{};const d=tP(u),f={x:n,y:r},p=ly(i),m=ay(p),v=await o.getDimensions(c),w=p==="y",_=w?"top":"left",x=w?"bottom":"right",b=w?"clientHeight":"clientWidth",S=s.reference[m]+s.reference[p]-f[p]-s.floating[m],C=f[p]-s.reference[p],k=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let N=k?k[b]:0;(!N||!await(o.isElement==null?void 0:o.isElement(k)))&&(N=a.floating[b]||s.floating[m]);const T=S/2-C/2,z=N/2-v[m]/2-1,P=zs(d[_],z),B=zs(d[x],z),A=P,R=N-v[m]-B,M=N/2-v[m]/2+T,D=_0(A,M,R),$=!l.arrow&&yl(i)!=null&&M!==D&&s.reference[m]/2-(M<A?P:B)-v[m]/2<0,F=$?M<A?M-A:M-R:0;return{[p]:f[p]+F,data:{[p]:D,centerOffset:M-D-F,...$&&{alignmentOffset:F}},reset:$}}}),p7=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:v=!0,...w}=Wi(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const _=Vi(i),x=oi(a),b=Vi(a)===a,S=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=f||(b||!v?[sf(a)]:i7(a)),k=m!=="none";!f&&k&&C.push(...l7(a,v,m,S));const N=[a,...C],T=await l.detectOverflow(t,w),z=[];let P=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&z.push(T[_]),d){const M=r7(i,o,S);z.push(T[M[0]],T[M[1]])}if(P=[...P,{placement:i,overflows:z}],!z.every(M=>M<=0)){var B,A;const M=(((B=s.flip)==null?void 0:B.index)||0)+1,D=N[M];if(D&&(!(d==="alignment"?x!==oi(D):!1)||P.every(j=>oi(j.placement)===x?j.overflows[0]>0:!0)))return{data:{index:M,overflows:P},reset:{placement:D}};let $=(A=P.filter(F=>F.overflows[0]<=0).sort((F,j)=>F.overflows[1]-j.overflows[1])[0])==null?void 0:A.placement;if(!$)switch(p){case"bestFit":{var R;const F=(R=P.filter(j=>{if(k){const O=oi(j.placement);return O===x||O==="y"}return!0}).map(j=>[j.placement,j.overflows.filter(O=>O>0).reduce((O,E)=>O+E,0)]).sort((j,O)=>j[1]-O[1])[0])==null?void 0:R[0];F&&($=F);break}case"initialPlacement":$=a;break}if(i!==$)return{reset:{placement:$}}}return{}}}};function dS(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function hS(e){return t7.some(t=>e[t]>=0)}const m7=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=Wi(e,t);switch(i){case"referenceHidden":{const o=await r.detectOverflow(t,{...s,elementContext:"reference"}),a=dS(o,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:hS(a)}}}case"escaped":{const o=await r.detectOverflow(t,{...s,altBoundary:!0}),a=dS(o,n.floating);return{data:{escapedOffsets:a,escaped:hS(a)}}}default:return{}}}}},nP=new Set(["left","top"]);async function g7(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Vi(n),a=yl(n),l=oi(n)==="y",c=nP.has(o)?-1:1,u=s&&l?-1:1,d=Wi(t,e);let{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),l?{x:p*u,y:f*c}:{x:f*c,y:p*u}}const v7=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:o,middlewareData:a}=t,l=await g7(t,e);return o===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:{...l,placement:o}}}}},_7=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:s}=t,{mainAxis:o=!0,crossAxis:a=!1,limiter:l={fn:_=>{let{x,y:b}=_;return{x,y:b}}},...c}=Wi(e,t),u={x:n,y:r},d=await s.detectOverflow(t,c),f=oi(Vi(i)),p=oy(f);let m=u[p],v=u[f];if(o){const _=p==="y"?"top":"left",x=p==="y"?"bottom":"right",b=m+d[_],S=m-d[x];m=_0(b,m,S)}if(a){const _=f==="y"?"top":"left",x=f==="y"?"bottom":"right",b=v+d[_],S=v-d[x];v=_0(b,v,S)}const w=l.fn({...t,[p]:m,[f]:v});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[p]:o,[f]:a}}}}}},x7=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:s,middlewareData:o}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=Wi(e,t),u={x:n,y:r},d=oi(i),f=oy(d);let p=u[f],m=u[d];const v=Wi(a,t),w=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(l){const b=f==="y"?"height":"width",S=s.reference[f]-s.floating[b]+w.mainAxis,C=s.reference[f]+s.reference[b]-w.mainAxis;p<S?p=S:p>C&&(p=C)}if(c){var _,x;const b=f==="y"?"width":"height",S=nP.has(Vi(i)),C=s.reference[d]-s.floating[b]+(S&&((_=o.offset)==null?void 0:_[d])||0)+(S?0:w.crossAxis),k=s.reference[d]+s.reference[b]+(S?0:((x=o.offset)==null?void 0:x[d])||0)-(S?w.crossAxis:0);m<C?m=C:m>k&&(m=k)}return{[f]:p,[d]:m}}}},y7=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:s,platform:o,elements:a}=t,{apply:l=()=>{},...c}=Wi(e,t),u=await o.detectOverflow(t,c),d=Vi(i),f=yl(i),p=oi(i)==="y",{width:m,height:v}=s.floating;let w,_;d==="top"||d==="bottom"?(w=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(_=d,w=f==="end"?"top":"bottom");const x=v-u.top-u.bottom,b=m-u.left-u.right,S=zs(v-u[w],x),C=zs(m-u[_],b),k=!t.middlewareData.shift;let N=S,T=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(T=b),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(N=x),k&&!f){const P=nr(u.left,0),B=nr(u.right,0),A=nr(u.top,0),R=nr(u.bottom,0);p?T=m-2*(P!==0||B!==0?P+B:nr(u.left,u.right)):N=v-2*(A!==0||R!==0?A+R:nr(u.top,u.bottom))}await l({...t,availableWidth:T,availableHeight:N});const z=await o.getDimensions(a.floating);return m!==z.width||v!==z.height?{reset:{rects:!0}}:{}}}};function pp(){return typeof window<"u"}function bl(e){return rP(e)?(e.nodeName||"").toLowerCase():"#document"}function sr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function _i(e){var t;return(t=(rP(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function rP(e){return pp()?e instanceof Node||e instanceof sr(e).Node:!1}function Wr(e){return pp()?e instanceof Element||e instanceof sr(e).Element:!1}function Xi(e){return pp()?e instanceof HTMLElement||e instanceof sr(e).HTMLElement:!1}function fS(e){return!pp()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof sr(e).ShadowRoot}function ku(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Vr(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function b7(e){return/^(table|td|th)$/.test(bl(e))}function mp(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const w7=/transform|translate|scale|rotate|perspective|filter/,S7=/paint|layout|strict|content/,eo=e=>!!e&&e!=="none";let Lm;function cy(e){const t=Wr(e)?Vr(e):e;return eo(t.transform)||eo(t.translate)||eo(t.scale)||eo(t.rotate)||eo(t.perspective)||!uy()&&(eo(t.backdropFilter)||eo(t.filter))||w7.test(t.willChange||"")||S7.test(t.contain||"")}function k7(e){let t=$s(e);for(;Xi(t)&&!Qa(t);){if(cy(t))return t;if(mp(t))return null;t=$s(t)}return null}function uy(){return Lm==null&&(Lm=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Lm}function Qa(e){return/^(html|body|#document)$/.test(bl(e))}function Vr(e){return sr(e).getComputedStyle(e)}function gp(e){return Wr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $s(e){if(bl(e)==="html")return e;const t=e.assignedSlot||e.parentNode||fS(e)&&e.host||_i(e);return fS(t)?t.host:t}function iP(e){const t=$s(e);return Qa(t)?e.ownerDocument?e.ownerDocument.body:e.body:Xi(t)&&ku(t)?t:iP(t)}function nu(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=iP(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),o=sr(i);if(s){const a=y0(o);return t.concat(o,o.visualViewport||[],ku(i)?i:[],a&&n?nu(a):[])}else return t.concat(i,nu(i,[],n))}function y0(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function sP(e){const t=Vr(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Xi(e),s=i?e.offsetWidth:n,o=i?e.offsetHeight:r,a=rf(n)!==s||rf(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function dy(e){return Wr(e)?e:e.contextElement}function Aa(e){const t=dy(e);if(!Xi(t))return hi(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=sP(t);let o=(s?rf(n.width):n.width)/r,a=(s?rf(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const C7=hi(0);function oP(e){const t=sr(e);return!uy()||!t.visualViewport?C7:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function E7(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==sr(e)?!1:t}function Io(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=dy(e);let o=hi(1);t&&(r?Wr(r)&&(o=Aa(r)):o=Aa(e));const a=E7(s,n,r)?oP(s):hi(0);let l=(i.left+a.x)/o.x,c=(i.top+a.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(s){const f=sr(s),p=r&&Wr(r)?sr(r):r;let m=f,v=y0(m);for(;v&&r&&p!==m;){const w=Aa(v),_=v.getBoundingClientRect(),x=Vr(v),b=_.left+(v.clientLeft+parseFloat(x.paddingLeft))*w.x,S=_.top+(v.clientTop+parseFloat(x.paddingTop))*w.y;l*=w.x,c*=w.y,u*=w.x,d*=w.y,l+=b,c+=S,m=sr(v),v=y0(m)}}return of({width:u,height:d,x:l,y:c})}function vp(e,t){const n=gp(e).scrollLeft;return t?t.left+n:Io(_i(e)).left+n}function aP(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-vp(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function N7(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",o=_i(r),a=t?mp(t.floating):!1;if(r===o||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=hi(1);const u=hi(0),d=Xi(r);if((d||!d&&!s)&&((bl(r)!=="body"||ku(o))&&(l=gp(r)),d)){const p=Io(r);c=Aa(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const f=o&&!d&&!s?aP(o,l):hi(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-l.scrollTop*c.y+u.y+f.y}}function T7(e){return Array.from(e.getClientRects())}function I7(e){const t=_i(e),n=gp(e),r=e.ownerDocument.body,i=nr(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=nr(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+vp(e);const a=-n.scrollTop;return Vr(r).direction==="rtl"&&(o+=nr(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:a}}const pS=25;function P7(e,t){const n=sr(e),r=_i(e),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;const u=uy();(!u||u&&t==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}const c=vp(r);if(c<=0){const u=r.ownerDocument,d=u.body,f=getComputedStyle(d),p=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,m=Math.abs(r.clientWidth-d.clientWidth-p);m<=pS&&(s-=m)}else c<=pS&&(s+=c);return{width:s,height:o,x:a,y:l}}function R7(e,t){const n=Io(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=Xi(e)?Aa(e):hi(1),o=e.clientWidth*s.x,a=e.clientHeight*s.y,l=i*s.x,c=r*s.y;return{width:o,height:a,x:l,y:c}}function mS(e,t,n){let r;if(t==="viewport")r=P7(e,n);else if(t==="document")r=I7(_i(e));else if(Wr(t))r=R7(t,n);else{const i=oP(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return of(r)}function lP(e,t){const n=$s(e);return n===t||!Wr(n)||Qa(n)?!1:Vr(n).position==="fixed"||lP(n,t)}function M7(e,t){const n=t.get(e);if(n)return n;let r=nu(e,[],!1).filter(a=>Wr(a)&&bl(a)!=="body"),i=null;const s=Vr(e).position==="fixed";let o=s?$s(e):e;for(;Wr(o)&&!Qa(o);){const a=Vr(o),l=cy(o);!l&&a.position==="fixed"&&(i=null),(s?!l&&!i:!l&&a.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||ku(o)&&!l&&lP(e,o))?r=r.filter(u=>u!==o):i=a,o=$s(o)}return t.set(e,r),r}function A7(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[...n==="clippingAncestors"?mp(t)?[]:M7(t,this._c):[].concat(n),r],a=mS(t,o[0],i);let l=a.top,c=a.right,u=a.bottom,d=a.left;for(let f=1;f<o.length;f++){const p=mS(t,o[f],i);l=nr(p.top,l),c=zs(p.right,c),u=zs(p.bottom,u),d=nr(p.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function L7(e){const{width:t,height:n}=sP(e);return{width:t,height:n}}function D7(e,t,n){const r=Xi(t),i=_i(t),s=n==="fixed",o=Io(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=hi(0);function c(){l.x=vp(i)}if(r||!r&&!s)if((bl(t)!=="body"||ku(i))&&(a=gp(t)),r){const p=Io(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else i&&c();s&&!r&&i&&c();const u=i&&!r&&!s?aP(i,a):hi(0),d=o.left+a.scrollLeft-l.x-u.x,f=o.top+a.scrollTop-l.y-u.y;return{x:d,y:f,width:o.width,height:o.height}}function Dm(e){return Vr(e).position==="static"}function gS(e,t){if(!Xi(e)||Vr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return _i(e)===n&&(n=n.ownerDocument.body),n}function cP(e,t){const n=sr(e);if(mp(e))return n;if(!Xi(e)){let i=$s(e);for(;i&&!Qa(i);){if(Wr(i)&&!Dm(i))return i;i=$s(i)}return n}let r=gS(e,t);for(;r&&b7(r)&&Dm(r);)r=gS(r,t);return r&&Qa(r)&&Dm(r)&&!cy(r)?n:r||k7(e)||n}const j7=async function(e){const t=this.getOffsetParent||cP,n=this.getDimensions,r=await n(e.floating);return{reference:D7(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function O7(e){return Vr(e).direction==="rtl"}const B7={convertOffsetParentRelativeRectToViewportRelativeRect:N7,getDocumentElement:_i,getClippingRect:A7,getOffsetParent:cP,getElementRects:j7,getClientRects:T7,getDimensions:L7,getScale:Aa,isElement:Wr,isRTL:O7};function uP(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function z7(e,t){let n=null,r;const i=_i(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=c;if(a||t(),!f||!p)return;const m=gd(d),v=gd(i.clientWidth-(u+f)),w=gd(i.clientHeight-(d+p)),_=gd(u),b={rootMargin:-m+"px "+-v+"px "+-w+"px "+-_+"px",threshold:nr(0,zs(1,l))||1};let S=!0;function C(k){const N=k[0].intersectionRatio;if(N!==l){if(!S)return o();N?o(!1,N):r=setTimeout(()=>{o(!1,1e-7)},1e3)}N===1&&!uP(c,e.getBoundingClientRect())&&o(),S=!1}try{n=new IntersectionObserver(C,{...b,root:i.ownerDocument})}catch{n=new IntersectionObserver(C,b)}n.observe(e)}return o(!0),s}function $7(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=dy(e),u=i||s?[...c?nu(c):[],...t?nu(t):[]]:[];u.forEach(_=>{i&&_.addEventListener("scroll",n,{passive:!0}),s&&_.addEventListener("resize",n)});const d=c&&a?z7(c,n):null;let f=-1,p=null;o&&(p=new ResizeObserver(_=>{let[x]=_;x&&x.target===c&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var b;(b=p)==null||b.observe(t)})),n()}),c&&!l&&p.observe(c),t&&p.observe(t));let m,v=l?Io(e):null;l&&w();function w(){const _=Io(e);v&&!uP(v,_)&&n(),v=_,m=requestAnimationFrame(w)}return n(),()=>{var _;u.forEach(x=>{i&&x.removeEventListener("scroll",n),s&&x.removeEventListener("resize",n)}),d==null||d(),(_=p)==null||_.disconnect(),p=null,l&&cancelAnimationFrame(m)}}const F7=v7,H7=_7,U7=p7,W7=y7,V7=m7,vS=f7,q7=x7,K7=(e,t,n)=>{const r=new Map,i={platform:B7,...n},s={...i.platform,_c:r};return h7(e,t,{...i,platform:s})};var G7=typeof document<"u",Y7=function(){},nh=G7?g.useLayoutEffect:Y7;function af(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!af(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&e.$$typeof)&&!af(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function dP(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function _S(e,t){const n=dP(e);return Math.round(t*n)/n}function jm(e){const t=g.useRef(e);return nh(()=>{t.current=e}),t}function X7(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[u,d]=g.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=g.useState(r);af(f,r)||p(r);const[m,v]=g.useState(null),[w,_]=g.useState(null),x=g.useCallback(j=>{j!==k.current&&(k.current=j,v(j))},[]),b=g.useCallback(j=>{j!==N.current&&(N.current=j,_(j))},[]),S=s||m,C=o||w,k=g.useRef(null),N=g.useRef(null),T=g.useRef(u),z=l!=null,P=jm(l),B=jm(i),A=jm(c),R=g.useCallback(()=>{if(!k.current||!N.current)return;const j={placement:t,strategy:n,middleware:f};B.current&&(j.platform=B.current),K7(k.current,N.current,j).then(O=>{const E={...O,isPositioned:A.current!==!1};M.current&&!af(T.current,E)&&(T.current=E,hl.flushSync(()=>{d(E)}))})},[f,t,n,B,A]);nh(()=>{c===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(j=>({...j,isPositioned:!1})))},[c]);const M=g.useRef(!1);nh(()=>(M.current=!0,()=>{M.current=!1}),[]),nh(()=>{if(S&&(k.current=S),C&&(N.current=C),S&&C){if(P.current)return P.current(S,C,R);R()}},[S,C,R,P,z]);const D=g.useMemo(()=>({reference:k,floating:N,setReference:x,setFloating:b}),[x,b]),$=g.useMemo(()=>({reference:S,floating:C}),[S,C]),F=g.useMemo(()=>{const j={position:n,left:0,top:0};if(!$.floating)return j;const O=_S($.floating,u.x),E=_S($.floating,u.y);return a?{...j,transform:"translate("+O+"px, "+E+"px)",...dP($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:O,top:E}},[n,a,$.floating,u.x,u.y]);return g.useMemo(()=>({...u,update:R,refs:D,elements:$,floatingStyles:F}),[u,R,D,$,F])}const Q7=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?vS({element:r.current,padding:i}).fn(n):{}:r?vS({element:r,padding:i}).fn(n):{}}}},Z7=(e,t)=>{const n=F7(e);return{name:n.name,fn:n.fn,options:[e,t]}},J7=(e,t)=>{const n=H7(e);return{name:n.name,fn:n.fn,options:[e,t]}},eH=(e,t)=>({fn:q7(e).fn,options:[e,t]}),tH=(e,t)=>{const n=U7(e);return{name:n.name,fn:n.fn,options:[e,t]}},nH=(e,t)=>{const n=W7(e);return{name:n.name,fn:n.fn,options:[e,t]}},rH=(e,t)=>{const n=V7(e);return{name:n.name,fn:n.fn,options:[e,t]}},iH=(e,t)=>{const n=Q7(e);return{name:n.name,fn:n.fn,options:[e,t]}};var sH="Arrow",hP=g.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...s}=e;return h.jsx(Rt.svg,{...s,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:h.jsx("polygon",{points:"0,0 30,0 15,10"})})});hP.displayName=sH;var oH=hP;function aH(e){const[t,n]=g.useState(void 0);return Bs(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let o,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;o=c.inlineSize,a=c.blockSize}else o=e.offsetWidth,a=e.offsetHeight;n({width:o,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var hy="Popper",[fP,_p]=Uo(hy),[lH,pP]=fP(hy),mP=e=>{const{__scopePopper:t,children:n}=e,[r,i]=g.useState(null);return h.jsx(lH,{scope:t,anchor:r,onAnchorChange:i,children:n})};mP.displayName=hy;var gP="PopperAnchor",vP=g.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,s=pP(gP,n),o=g.useRef(null),a=Qt(t,o),l=g.useRef(null);return g.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||o.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:h.jsx(Rt.div,{...i,ref:a})});vP.displayName=gP;var fy="PopperContent",[cH,uH]=fP(fy),_P=g.forwardRef((e,t)=>{var ge,Re,ce,Le,Oe,Ae;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:o=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:p="optimized",onPlaced:m,...v}=e,w=pP(fy,n),[_,x]=g.useState(null),b=Qt(t,_e=>x(_e)),[S,C]=g.useState(null),k=aH(S),N=(k==null?void 0:k.width)??0,T=(k==null?void 0:k.height)??0,z=r+(s!=="center"?"-"+s:""),P=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},B=Array.isArray(c)?c:[c],A=B.length>0,R={padding:P,boundary:B.filter(hH),altBoundary:A},{refs:M,floatingStyles:D,placement:$,isPositioned:F,middlewareData:j}=X7({strategy:"fixed",placement:z,whileElementsMounted:(..._e)=>$7(..._e,{animationFrame:p==="always"}),elements:{reference:w.anchor},middleware:[Z7({mainAxis:i+T,alignmentAxis:o}),l&&J7({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?eH():void 0,...R}),l&&tH({...R}),nH({...R,apply:({elements:_e,rects:Qe,availableWidth:kt,availableHeight:tt})=>{const{width:At,height:Jt}=Qe.reference,nt=_e.floating.style;nt.setProperty("--radix-popper-available-width",`${kt}px`),nt.setProperty("--radix-popper-available-height",`${tt}px`),nt.setProperty("--radix-popper-anchor-width",`${At}px`),nt.setProperty("--radix-popper-anchor-height",`${Jt}px`)}}),S&&iH({element:S,padding:a}),fH({arrowWidth:N,arrowHeight:T}),f&&rH({strategy:"referenceHidden",...R})]}),[O,E]=bP($),H=gi(m);Bs(()=>{F&&(H==null||H())},[F,H]);const q=(ge=j.arrow)==null?void 0:ge.x,L=(Re=j.arrow)==null?void 0:Re.y,re=((ce=j.arrow)==null?void 0:ce.centerOffset)!==0,[se,K]=g.useState();return Bs(()=>{_&&K(window.getComputedStyle(_).zIndex)},[_]),h.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...D,transform:F?D.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:se,"--radix-popper-transform-origin":[(Le=j.transformOrigin)==null?void 0:Le.x,(Oe=j.transformOrigin)==null?void 0:Oe.y].join(" "),...((Ae=j.hide)==null?void 0:Ae.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:h.jsx(cH,{scope:n,placedSide:O,onArrowChange:C,arrowX:q,arrowY:L,shouldHideArrow:re,children:h.jsx(Rt.div,{"data-side":O,"data-align":E,...v,ref:b,style:{...v.style,animation:F?void 0:"none"}})})})});_P.displayName=fy;var xP="PopperArrow",dH={top:"bottom",right:"left",bottom:"top",left:"right"},yP=g.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,s=uH(xP,r),o=dH[s.placedSide];return h.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:h.jsx(oH,{...i,ref:n,style:{...i.style,display:"block"}})})});yP.displayName=xP;function hH(e){return e!==null}var fH=e=>({name:"transformOrigin",options:e,fn(t){var w,_,x;const{placement:n,rects:r,middlewareData:i}=t,o=((w=i.arrow)==null?void 0:w.centerOffset)!==0,a=o?0:e.arrowWidth,l=o?0:e.arrowHeight,[c,u]=bP(n),d={start:"0%",center:"50%",end:"100%"}[u],f=(((_=i.arrow)==null?void 0:_.x)??0)+a/2,p=(((x=i.arrow)==null?void 0:x.y)??0)+l/2;let m="",v="";return c==="bottom"?(m=o?d:`${f}px`,v=`${-l}px`):c==="top"?(m=o?d:`${f}px`,v=`${r.floating.height+l}px`):c==="right"?(m=`${-l}px`,v=o?d:`${p}px`):c==="left"&&(m=`${r.floating.width+l}px`,v=o?d:`${p}px`),{data:{x:m,y:v}}}});function bP(e){const[t,n="center"]=e.split("-");return[t,n]}var py=mP,wP=vP,SP=_P,kP=yP,pH="Portal",my=g.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[i,s]=g.useState(!1);Bs(()=>s(!0),[]);const o=n||i&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return o?Sv.createPortal(h.jsx(Rt.div,{...r,ref:t}),o):null});my.displayName=pH;function mH(e,t){return g.useReducer((n,r)=>t[n][r]??n,e)}var Qi=e=>{const{present:t,children:n}=e,r=gH(t),i=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),s=Qt(r.ref,vH(i));return typeof n=="function"||r.isPresent?g.cloneElement(i,{ref:s}):null};Qi.displayName="Presence";function gH(e){const[t,n]=g.useState(),r=g.useRef(null),i=g.useRef(e),s=g.useRef("none"),o=e?"mounted":"unmounted",[a,l]=mH(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const c=vd(r.current);s.current=a==="mounted"?c:"none"},[a]),Bs(()=>{const c=r.current,u=i.current;if(u!==e){const f=s.current,p=vd(c);e?l("MOUNT"):p==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&f!==p?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,l]),Bs(()=>{if(t){let c;const u=t.ownerDocument.defaultView??window,d=p=>{const v=vd(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&v&&(l("ANIMATION_END"),!i.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",c=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},f=p=>{p.target===t&&(s.current=vd(r.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{u.clearTimeout(c),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:g.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function vd(e){return(e==null?void 0:e.animationName)||"none"}function vH(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)}var Om="rovingFocusGroup.onEntryFocus",_H={bubbles:!1,cancelable:!0},Cu="RovingFocusGroup",[b0,CP,xH]=YI(Cu),[yH,EP]=Uo(Cu,[xH]),[bH,wH]=yH(Cu),NP=g.forwardRef((e,t)=>h.jsx(b0.Provider,{scope:e.__scopeRovingFocusGroup,children:h.jsx(b0.Slot,{scope:e.__scopeRovingFocusGroup,children:h.jsx(SH,{...e,ref:t})})}));NP.displayName=Cu;var SH=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...d}=e,f=g.useRef(null),p=Qt(t,f),m=XI(s),[v,w]=Su({prop:o,defaultProp:a??null,onChange:l,caller:Cu}),[_,x]=g.useState(!1),b=gi(c),S=CP(n),C=g.useRef(!1),[k,N]=g.useState(0);return g.useEffect(()=>{const T=f.current;if(T)return T.addEventListener(Om,b),()=>T.removeEventListener(Om,b)},[b]),h.jsx(bH,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:v,onItemFocus:g.useCallback(T=>w(T),[w]),onItemShiftTab:g.useCallback(()=>x(!0),[]),onFocusableItemAdd:g.useCallback(()=>N(T=>T+1),[]),onFocusableItemRemove:g.useCallback(()=>N(T=>T-1),[]),children:h.jsx(Rt.div,{tabIndex:_||k===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:"none",...e.style},onMouseDown:Pe(e.onMouseDown,()=>{C.current=!0}),onFocus:Pe(e.onFocus,T=>{const z=!C.current;if(T.target===T.currentTarget&&z&&!_){const P=new CustomEvent(Om,_H);if(T.currentTarget.dispatchEvent(P),!P.defaultPrevented){const B=S().filter($=>$.focusable),A=B.find($=>$.active),R=B.find($=>$.id===v),D=[A,R,...B].filter(Boolean).map($=>$.ref.current);PP(D,u)}}C.current=!1}),onBlur:Pe(e.onBlur,()=>x(!1))})})}),TP="RovingFocusGroupItem",IP=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:o,...a}=e,l=Oi(),c=s||l,u=wH(TP,n),d=u.currentTabStopId===c,f=CP(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:v}=u;return g.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),h.jsx(b0.ItemSlot,{scope:n,id:c,focusable:r,active:i,children:h.jsx(Rt.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...a,ref:t,onMouseDown:Pe(e.onMouseDown,w=>{r?u.onItemFocus(c):w.preventDefault()}),onFocus:Pe(e.onFocus,()=>u.onItemFocus(c)),onKeyDown:Pe(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){u.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const _=EH(w,u.orientation,u.dir);if(_!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let b=f().filter(S=>S.focusable).map(S=>S.ref.current);if(_==="last")b.reverse();else if(_==="prev"||_==="next"){_==="prev"&&b.reverse();const S=b.indexOf(w.currentTarget);b=u.loop?NH(b,S+1):b.slice(S+1)}setTimeout(()=>PP(b))}}),children:typeof o=="function"?o({isCurrentTabStop:d,hasTabStop:v!=null}):o})})});IP.displayName=TP;var kH={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function CH(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function EH(e,t,n){const r=CH(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return kH[r]}function PP(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function NH(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var TH=NP,IH=IP,PH=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ea=new WeakMap,_d=new WeakMap,xd={},Bm=0,RP=function(e){return e&&(e.host||RP(e.parentNode))},RH=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=RP(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},MH=function(e,t,n,r){var i=RH(t,Array.isArray(e)?e:[e]);xd[n]||(xd[n]=new WeakMap);var s=xd[n],o=[],a=new Set,l=new Set(i),c=function(d){!d||a.has(d)||(a.add(d),c(d.parentNode))};i.forEach(c);var u=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(f){if(a.has(f))u(f);else try{var p=f.getAttribute(r),m=p!==null&&p!=="false",v=(ea.get(f)||0)+1,w=(s.get(f)||0)+1;ea.set(f,v),s.set(f,w),o.push(f),v===1&&m&&_d.set(f,!0),w===1&&f.setAttribute(n,"true"),m||f.setAttribute(r,"true")}catch(_){console.error("aria-hidden: cannot operate on ",f,_)}})};return u(t),a.clear(),Bm++,function(){o.forEach(function(d){var f=ea.get(d)-1,p=s.get(d)-1;ea.set(d,f),s.set(d,p),f||(_d.has(d)||d.removeAttribute(r),_d.delete(d)),p||d.removeAttribute(n)}),Bm--,Bm||(ea=new WeakMap,ea=new WeakMap,_d=new WeakMap,xd={})}},MP=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=PH(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),MH(r,i,n,"aria-hidden")):function(){return null}},si=function(){return si=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},si.apply(this,arguments)};function AP(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}function AH(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}var rh="right-scroll-bar-position",ih="width-before-scroll-bar",LH="with-scroll-bars-hidden",DH="--removed-body-scroll-bar-size";function zm(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function jH(e,t){var n=g.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=t,n.facade}var OH=typeof window<"u"?g.useLayoutEffect:g.useEffect,xS=new WeakMap;function BH(e,t){var n=jH(null,function(r){return e.forEach(function(i){return zm(i,r)})});return OH(function(){var r=xS.get(n);if(r){var i=new Set(r),s=new Set(e),o=n.current;i.forEach(function(a){s.has(a)||zm(a,null)}),s.forEach(function(a){i.has(a)||zm(a,o)})}xS.set(n,e)},[e]),n}function zH(e){return e}function $H(e,t){t===void 0&&(t=zH);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var o=t(s,r);return n.push(o),function(){n=n.filter(function(a){return a!==o})}},assignSyncMedium:function(s){for(r=!0;n.length;){var o=n;n=[],o.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var o=[];if(n.length){var a=n;n=[],a.forEach(s),o=n}var l=function(){var u=o;o=[],u.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(u){o.push(u),c()},filter:function(u){return o=o.filter(u),n}}}};return i}function FH(e){e===void 0&&(e={});var t=$H(null);return t.options=si({async:!0,ssr:!1},e),t}var LP=function(e){var t=e.sideCar,n=AP(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return g.createElement(r,si({},n))};LP.isSideCarExport=!0;function HH(e,t){return e.useMedium(t),LP}var DP=FH(),$m=function(){},xp=g.forwardRef(function(e,t){var n=g.useRef(null),r=g.useState({onScrollCapture:$m,onWheelCapture:$m,onTouchMoveCapture:$m}),i=r[0],s=r[1],o=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,v=e.inert,w=e.allowPinchZoom,_=e.as,x=_===void 0?"div":_,b=e.gapMode,S=AP(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=f,k=BH([n,t]),N=si(si({},S),i);return g.createElement(g.Fragment,null,u&&g.createElement(C,{sideCar:DP,removeScrollBar:c,shards:d,noRelative:p,noIsolation:m,inert:v,setCallbacks:s,allowPinchZoom:!!w,lockRef:n,gapMode:b}),o?g.cloneElement(g.Children.only(a),si(si({},N),{ref:k})):g.createElement(x,si({},N,{className:l,ref:k}),a))});xp.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};xp.classNames={fullWidth:ih,zeroRight:rh};var UH=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function WH(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=UH();return t&&e.setAttribute("nonce",t),e}function VH(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function qH(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var KH=function(){var e=0,t=null;return{add:function(n){e==0&&(t=WH())&&(VH(t,n),qH(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},GH=function(){var e=KH();return function(t,n){g.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},jP=function(){var e=GH(),t=function(n){var r=n.styles,i=n.dynamic;return e(r,i),null};return t},YH={left:0,top:0,right:0,gap:0},Fm=function(e){return parseInt(e||"",10)||0},XH=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[Fm(n),Fm(r),Fm(i)]},QH=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return YH;var t=XH(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},ZH=jP(),La="data-scroll-locked",JH=function(e,t,n,r){var i=e.left,s=e.top,o=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
472
472
|
.`.concat(LH,` {
|
|
473
473
|
overflow: hidden `).concat(r,`;
|
|
474
474
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
@@ -508,10 +508,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
508
508
|
`)},yS=function(){var e=parseInt(document.body.getAttribute(La)||"0",10);return isFinite(e)?e:0},eU=function(){g.useEffect(function(){return document.body.setAttribute(La,(yS()+1).toString()),function(){var e=yS()-1;e<=0?document.body.removeAttribute(La):document.body.setAttribute(La,e.toString())}},[])},tU=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;eU();var s=g.useMemo(function(){return QH(i)},[i]);return g.createElement(ZH,{styles:JH(s,!t,i,n?"":"!important")})},w0=!1;if(typeof window<"u")try{var yd=Object.defineProperty({},"passive",{get:function(){return w0=!0,!0}});window.addEventListener("test",yd,yd),window.removeEventListener("test",yd,yd)}catch{w0=!1}var ta=w0?{passive:!1}:!1,nU=function(e){return e.tagName==="TEXTAREA"},OP=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!nU(e)&&n[t]==="visible")},rU=function(e){return OP(e,"overflowY")},iU=function(e){return OP(e,"overflowX")},bS=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=BP(e,r);if(i){var s=zP(e,r),o=s[1],a=s[2];if(o>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},sU=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},oU=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},BP=function(e,t){return e==="v"?rU(t):iU(t)},zP=function(e,t){return e==="v"?sU(t):oU(t)},aU=function(e,t){return e==="h"&&t==="rtl"?-1:1},lU=function(e,t,n,r,i){var s=aU(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=zP(e,a),m=p[0],v=p[1],w=p[2],_=v-w-s*m;(m||_)&&BP(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},bd=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},wS=function(e){return[e.deltaX,e.deltaY]},SS=function(e){return e&&"current"in e?e.current:e},cU=function(e,t){return e[0]===t[0]&&e[1]===t[1]},uU=function(e){return`
|
|
509
509
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
510
510
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
511
|
-
`)},dU=0,na=[];function hU(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState(dU++)[0],s=g.useState(jP)[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=AH([e.lockRef.current],(e.shards||[]).map(SS),!0).filter(Boolean);return v.forEach(function(w){return w.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),v.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(v,w){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var _=bd(v),x=n.current,b="deltaX"in v?v.deltaX:x[0]-_[0],S="deltaY"in v?v.deltaY:x[1]-_[1],C,k=v.target,N=Math.abs(b)>Math.abs(S)?"h":"v";if("touches"in v&&N==="h"&&k.type==="range")return!1;var T=window.getSelection(),z=T&&T.anchorNode,P=z?z===k||z.contains(k):!1;if(P)return!1;var B=bS(N,k);if(!B)return!0;if(B?C=N:(C=N==="v"?"h":"v",B=bS(N,k)),!B)return!1;if(!r.current&&"changedTouches"in v&&(b||S)&&(r.current=C),!C)return!0;var A=r.current||C;return lU(A,w,v,A==="h"?b:S)},[]),l=g.useCallback(function(v){var w=v;if(!(!na.length||na[na.length-1]!==s)){var _="deltaY"in w?wS(w):bd(w),x=t.current.filter(function(C){return C.name===w.type&&(C.target===w.target||w.target===C.shadowParent)&&cU(C.delta,_)})[0];if(x&&x.should){w.cancelable&&w.preventDefault();return}if(!x){var b=(o.current.shards||[]).map(SS).filter(Boolean).filter(function(C){return C.contains(w.target)}),S=b.length>0?a(w,b[0]):!o.current.noIsolation;S&&w.cancelable&&w.preventDefault()}}},[]),c=g.useCallback(function(v,w,_,x){var b={name:v,delta:w,target:_,should:x,shadowParent:fU(_)};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(S){return S!==b})},1)},[]),u=g.useCallback(function(v){n.current=bd(v),r.current=void 0},[]),d=g.useCallback(function(v){c(v.type,wS(v),v.target,a(v,e.lockRef.current))},[]),f=g.useCallback(function(v){c(v.type,bd(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return na.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,ta),document.addEventListener("touchmove",l,ta),document.addEventListener("touchstart",u,ta),function(){na=na.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,ta),document.removeEventListener("touchmove",l,ta),document.removeEventListener("touchstart",u,ta)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(s,{styles:uU(i)}):null,p?g.createElement(tU,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function fU(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const pU=HH(DP,hU);var gy=g.forwardRef(function(e,t){return g.createElement(xp,si({},e,{ref:t,sideCar:pU}))});gy.classNames=xp.classNames;var S0=["Enter"," "],mU=["ArrowDown","PageUp","Home"],$P=["ArrowUp","PageDown","End"],gU=[...mU,...$P],vU={ltr:[...S0,"ArrowRight"],rtl:[...S0,"ArrowLeft"]},_U={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Eu="Menu",[ru,xU,yU]=YI(Eu),[Wo,FP]=Uo(Eu,[yU,_p,EP]),Nu=_p(),HP=EP(),[UP,qs]=Wo(Eu),[bU,Tu]=Wo(Eu),WP=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=Nu(t),[l,c]=g.useState(null),u=g.useRef(!1),d=gi(s),f=XI(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(py,{...a,children:h.jsx(UP,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(bU,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};WP.displayName=Eu;var wU="MenuAnchor",vy=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Nu(n);return h.jsx(wP,{...i,...r,ref:t})});vy.displayName=wU;var _y="MenuPortal",[SU,VP]=Wo(_y,{forceMount:void 0}),qP=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=qs(_y,t);return h.jsx(SU,{scope:t,forceMount:n,children:h.jsx(Qi,{present:n||s.open,children:h.jsx(my,{asChild:!0,container:i,children:r})})})};qP.displayName=_y;var Cr="MenuContent",[kU,xy]=Wo(Cr),KP=g.forwardRef((e,t)=>{const n=VP(Cr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=qs(Cr,e.__scopeMenu),o=Tu(Cr,e.__scopeMenu);return h.jsx(ru.Provider,{scope:e.__scopeMenu,children:h.jsx(Qi,{present:r||s.open,children:h.jsx(ru.Slot,{scope:e.__scopeMenu,children:o.modal?h.jsx(CU,{...i,ref:t}):h.jsx(EU,{...i,ref:t})})})})}),CU=g.forwardRef((e,t)=>{const n=qs(Cr,e.__scopeMenu),r=g.useRef(null),i=Qt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return MP(s)},[]),h.jsx(yy,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),EU=g.forwardRef((e,t)=>{const n=qs(Cr,e.__scopeMenu);return h.jsx(yy,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),NU=tu("MenuContent.ScrollLock"),yy=g.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...v}=e,w=qs(Cr,n),_=Tu(Cr,n),x=Nu(n),b=HP(n),S=xU(n),[C,k]=g.useState(null),N=g.useRef(null),T=Qt(t,N,w.onContentChange),z=g.useRef(0),P=g.useRef(""),B=g.useRef(0),A=g.useRef(null),R=g.useRef("right"),M=g.useRef(0),D=m?gy:g.Fragment,$=m?{as:NU,allowPinchZoom:!0}:void 0,F=O=>{var me,Re;const E=P.current+O,H=S().filter(ce=>!ce.disabled),q=document.activeElement,L=(me=H.find(ce=>ce.ref.current===q))==null?void 0:me.textValue,re=H.map(ce=>ce.textValue),se=zU(re,E,L),K=(Re=H.find(ce=>ce.textValue===se))==null?void 0:Re.ref.current;(function ce(Le){P.current=Le,window.clearTimeout(z.current),Le!==""&&(z.current=window.setTimeout(()=>ce(""),1e3))})(E),K&&setTimeout(()=>K.focus())};g.useEffect(()=>()=>window.clearTimeout(z.current),[]),JI();const j=g.useCallback(O=>{var H,q;return R.current===((H=A.current)==null?void 0:H.side)&&FU(O,(q=A.current)==null?void 0:q.area)},[]);return h.jsx(kU,{scope:n,searchRef:P,onItemEnter:g.useCallback(O=>{j(O)&&O.preventDefault()},[j]),onItemLeave:g.useCallback(O=>{var E;j(O)||((E=N.current)==null||E.focus(),k(null))},[j]),onTriggerLeave:g.useCallback(O=>{j(O)&&O.preventDefault()},[j]),pointerGraceTimerRef:B,onPointerGraceIntentChange:g.useCallback(O=>{A.current=O},[]),children:h.jsx(D,{...$,children:h.jsx(sy,{asChild:!0,trapped:i,onMountAutoFocus:Pe(s,O=>{var E;O.preventDefault(),(E=N.current)==null||E.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:h.jsx(fp,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(TH,{asChild:!0,...b,dir:_.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:Pe(l,O=>{_.isUsingKeyboardRef.current||O.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(SP,{role:"menu","aria-orientation":"vertical","data-state":uR(w.open),"data-radix-menu-content":"",dir:_.dir,...x,...v,ref:T,style:{outline:"none",...v.style},onKeyDown:Pe(v.onKeyDown,O=>{const H=O.target.closest("[data-radix-menu-content]")===O.currentTarget,q=O.ctrlKey||O.altKey||O.metaKey,L=O.key.length===1;H&&(O.key==="Tab"&&O.preventDefault(),!q&&L&&F(O.key));const re=N.current;if(O.target!==re||!gU.includes(O.key))return;O.preventDefault();const K=S().filter(me=>!me.disabled).map(me=>me.ref.current);$P.includes(O.key)&&K.reverse(),OU(K)}),onBlur:Pe(e.onBlur,O=>{O.currentTarget.contains(O.target)||(window.clearTimeout(z.current),P.current="")}),onPointerMove:Pe(e.onPointerMove,iu(O=>{const E=O.target,H=M.current!==O.clientX;if(O.currentTarget.contains(E)&&H){const q=O.clientX>M.current?"right":"left";R.current=q,M.current=O.clientX}}))})})})})})})});KP.displayName=Cr;var TU="MenuGroup",by=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Rt.div,{role:"group",...r,ref:t})});by.displayName=TU;var IU="MenuLabel",GP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Rt.div,{...r,ref:t})});GP.displayName=IU;var lf="MenuItem",kS="menu.itemSelect",yp=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=Tu(lf,e.__scopeMenu),a=xy(lf,e.__scopeMenu),l=Qt(t,s),c=g.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(kS,{bubbles:!0,cancelable:!0});d.addEventListener(kS,p=>r==null?void 0:r(p),{once:!0}),GI(d,f),f.defaultPrevented?c.current=!1:o.onClose()}};return h.jsx(YP,{...i,ref:l,disabled:n,onClick:Pe(e.onClick,u),onPointerDown:d=>{var f;(f=e.onPointerDown)==null||f.call(e,d),c.current=!0},onPointerUp:Pe(e.onPointerUp,d=>{var f;c.current||(f=d.currentTarget)==null||f.click()}),onKeyDown:Pe(e.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||S0.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});yp.displayName=lf;var YP=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=xy(lf,n),a=HP(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(ru.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:h.jsx(IH,{asChild:!0,...a,focusable:!r,children:h.jsx(Rt.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:Pe(e.onPointerMove,iu(m=>{r?o.onItemLeave(m):(o.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Pe(e.onPointerLeave,iu(m=>o.onItemLeave(m))),onFocus:Pe(e.onFocus,()=>d(!0)),onBlur:Pe(e.onBlur,()=>d(!1))})})})}),PU="MenuCheckboxItem",XP=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return h.jsx(tR,{scope:e.__scopeMenu,checked:n,children:h.jsx(yp,{role:"menuitemcheckbox","aria-checked":cf(n)?"mixed":n,...i,ref:t,"data-state":ky(n),onSelect:Pe(i.onSelect,()=>r==null?void 0:r(cf(n)?!0:!n),{checkForDefaultPrevented:!1})})})});XP.displayName=PU;var QP="MenuRadioGroup",[RU,MU]=Wo(QP,{value:void 0,onValueChange:()=>{}}),ZP=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=gi(r);return h.jsx(RU,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(by,{...i,ref:t})})});ZP.displayName=QP;var JP="MenuRadioItem",eR=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=MU(JP,e.__scopeMenu),s=n===i.value;return h.jsx(tR,{scope:e.__scopeMenu,checked:s,children:h.jsx(yp,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":ky(s),onSelect:Pe(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});eR.displayName=JP;var wy="MenuItemIndicator",[tR,AU]=Wo(wy,{checked:!1}),nR=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=AU(wy,n);return h.jsx(Qi,{present:r||cf(s.checked)||s.checked===!0,children:h.jsx(Rt.span,{...i,ref:t,"data-state":ky(s.checked)})})});nR.displayName=wy;var LU="MenuSeparator",rR=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Rt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});rR.displayName=LU;var DU="MenuArrow",iR=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Nu(n);return h.jsx(kP,{...i,...r,ref:t})});iR.displayName=DU;var Sy="MenuSub",[jU,sR]=Wo(Sy),oR=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=qs(Sy,t),o=Nu(t),[a,l]=g.useState(null),[c,u]=g.useState(null),d=gi(i);return g.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),h.jsx(py,{...o,children:h.jsx(UP,{scope:t,open:r,onOpenChange:d,content:c,onContentChange:u,children:h.jsx(jU,{scope:t,contentId:Oi(),triggerId:Oi(),trigger:a,onTriggerChange:l,children:n})})})};oR.displayName=Sy;var rc="MenuSubTrigger",aR=g.forwardRef((e,t)=>{const n=qs(rc,e.__scopeMenu),r=Tu(rc,e.__scopeMenu),i=sR(rc,e.__scopeMenu),s=xy(rc,e.__scopeMenu),o=g.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},u=g.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return g.useEffect(()=>u,[u]),g.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),h.jsx(vy,{asChild:!0,...c,children:h.jsx(YP,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":uR(n.open),...e,ref:wu(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:Pe(e.onPointerMove,iu(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:Pe(e.onPointerLeave,iu(d=>{var p,m;u();const f=(p=n.content)==null?void 0:p.getBoundingClientRect();if(f){const v=(m=n.content)==null?void 0:m.dataset.side,w=v==="right",_=w?-5:5,x=f[w?"left":"right"],b=f[w?"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:Pe(e.onKeyDown,d=>{var p;const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||vU[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});aR.displayName=rc;var lR="MenuSubContent",cR=g.forwardRef((e,t)=>{const n=VP(Cr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=qs(Cr,e.__scopeMenu),o=Tu(Cr,e.__scopeMenu),a=sR(lR,e.__scopeMenu),l=g.useRef(null),c=Qt(t,l);return h.jsx(ru.Provider,{scope:e.__scopeMenu,children:h.jsx(Qi,{present:r||s.open,children:h.jsx(ru.Slot,{scope:e.__scopeMenu,children:h.jsx(yy,{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:Pe(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Pe(e.onEscapeKeyDown,u=>{o.onClose(),u.preventDefault()}),onKeyDown:Pe(e.onKeyDown,u=>{var p;const d=u.currentTarget.contains(u.target),f=_U[o.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});cR.displayName=lR;function uR(e){return e?"open":"closed"}function cf(e){return e==="indeterminate"}function ky(e){return cf(e)?"indeterminate":e?"checked":"unchecked"}function OU(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function BU(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function zU(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=BU(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 $U(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 FU(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return $U(n,t)}function iu(e){return t=>t.pointerType==="mouse"?e(t):void 0}var HU=WP,UU=vy,WU=qP,VU=KP,qU=by,KU=GP,GU=yp,YU=XP,XU=ZP,QU=eR,ZU=nR,JU=rR,eW=iR,tW=oR,nW=aR,rW=cR,bp="DropdownMenu",[iW]=Uo(bp,[FP]),En=FP(),[sW,dR]=iW(bp),hR=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=En(t),c=g.useRef(null),[u,d]=Su({prop:i,defaultProp:s??!1,onChange:o,caller:bp});return h.jsx(sW,{scope:t,triggerId:Oi(),triggerRef:c,contentId:Oi(),open:u,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(HU,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};hR.displayName=bp;var fR="DropdownMenuTrigger",pR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=dR(fR,n),o=En(n);return h.jsx(UU,{asChild:!0,...o,children:h.jsx(Rt.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:wu(t,s.triggerRef),onPointerDown:Pe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:Pe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});pR.displayName=fR;var oW="DropdownMenuPortal",mR=e=>{const{__scopeDropdownMenu:t,...n}=e,r=En(t);return h.jsx(WU,{...r,...n})};mR.displayName=oW;var gR="DropdownMenuContent",vR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=dR(gR,n),s=En(n),o=g.useRef(!1);return h.jsx(VU,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:t,onCloseAutoFocus:Pe(e.onCloseAutoFocus,a=>{var l;o.current||(l=i.triggerRef.current)==null||l.focus(),o.current=!1,a.preventDefault()}),onInteractOutside:Pe(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)"}})});vR.displayName=gR;var aW="DropdownMenuGroup",lW=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(qU,{...i,...r,ref:t})});lW.displayName=aW;var cW="DropdownMenuLabel",_R=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(KU,{...i,...r,ref:t})});_R.displayName=cW;var uW="DropdownMenuItem",xR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(GU,{...i,...r,ref:t})});xR.displayName=uW;var dW="DropdownMenuCheckboxItem",yR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(YU,{...i,...r,ref:t})});yR.displayName=dW;var hW="DropdownMenuRadioGroup",fW=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(XU,{...i,...r,ref:t})});fW.displayName=hW;var pW="DropdownMenuRadioItem",mW=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(QU,{...i,...r,ref:t})});mW.displayName=pW;var gW="DropdownMenuItemIndicator",bR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(ZU,{...i,...r,ref:t})});bR.displayName=gW;var vW="DropdownMenuSeparator",wR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(JU,{...i,...r,ref:t})});wR.displayName=vW;var _W="DropdownMenuArrow",xW=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(eW,{...i,...r,ref:t})});xW.displayName=_W;var yW=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,o=En(t),[a,l]=Su({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return h.jsx(tW,{...o,open:a,onOpenChange:l,children:n})},bW="DropdownMenuSubTrigger",SR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(nW,{...i,...r,ref:t})});SR.displayName=bW;var wW="DropdownMenuSubContent",kR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(rW,{...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)"}})});kR.displayName=wW;var SW=hR,kW=pR,CR=mR,ER=vR,NR=_R,TR=xR,IR=yR,CW=bR,PR=wR,EW=yW,RR=SR,MR=kR;const AR=SW,LR=kW,Cy=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(CR,{children:h.jsx(ER,{ref:r,sideOffset:t,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));Cy.displayName=ER.displayName;const NW=EW,DR=g.forwardRef(({className:e,...t},n)=>h.jsx(RR,{ref:n,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100 data-[state=open]:bg-bg-200","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...t}));DR.displayName=RR.displayName;const jR=g.forwardRef(({className:e,...t},n)=>h.jsx(CR,{children:h.jsx(MR,{ref:n,className:ne("z-50 min-w-[6rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...t})}));jR.displayName=MR.displayName;const co=g.forwardRef(({className:e,inset:t,...n},r)=>h.jsx(TR,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));co.displayName=TR.displayName;const TW=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>h.jsxs(IR,{ref:i,checked:n,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-7 pr-2 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[h.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:h.jsx(CW,{children:h.jsx(bu,{className:"h-3.5 w-3.5"})})}),t]}));TW.displayName=IR.displayName;const Ey=g.forwardRef(({className:e,...t},n)=>h.jsx(PR,{ref:n,className:ne("-mx-1 my-1 h-px bg-border",e),...t}));Ey.displayName=PR.displayName;const OR=g.forwardRef(({className:e,...t},n)=>h.jsx(NR,{ref:n,className:ne("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));OR.displayName=NR.displayName;function IW({tool:e,className:t}){const n=w9(e);return h.jsx("span",{"data-testid":n?`session-icon-${e}`:"session-icon-default","aria-label":n?ry(e):"未知引擎",className:ne("w-3.5 h-3.5 shrink-0 inline-flex items-center justify-center",hp(e),t),children:h.jsx(dp,{tool:e,className:"w-full h-full"})})}function PW({sessionId:e,hasUnread:t,running:n=!1,awaitingUser:r=!1,style:i}){return r?h.jsx(q$,{"data-testid":`awaiting-dot-${e}`,style:i,className:"w-3 h-3 text-warning shrink-0 animate-pulse",strokeWidth:2.25,"aria-label":"awaiting user"}):t?h.jsx("span",{"data-testid":`unread-dot-${e}`,style:i,className:"w-2 h-2 rounded-full bg-error shrink-0","aria-label":"unread"}):n?h.jsx("span",{"data-testid":`running-dot-${e}`,style:i,className:"w-2 h-2 rounded-full bg-success shrink-0 animate-pulse","aria-label":"running"}):null}function BR(e){return e.compositionActive||!!e.nativeIsComposing||e.keyCode===229}function zR(e){return e.key==="Enter"&&!e.shiftKey&&!BR(e)}function Iu(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(zR({key:o.key,shiftKey:o.shiftKey,compositionActive:n.current,nativeIsComposing:a.isComposing,keyCode:a.keyCode})){o.preventDefault(),e();return}t&&o.key==="Escape"&&(o.preventDefault(),t())},[e,t]),onCompositionStart:r,onCompositionEnd:i}}function RW({open:e,initialLabel:t,placeholder:n,onSubmit:r,onCancel:i,title:s="Edit session",fieldLabel:o="Label",testId:a="session-edit-dialog",requireNonEmpty:l=!1}){const[c,u]=g.useState(t);g.useEffect(()=>{e&&u(t)},[e,t]);const d=c.trim(),f=l&&d==="",p=()=>{f||r({label:d})},m=Iu(p,i);return e?hl.createPortal(h.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-bg-0/40 backdrop-blur-[2px]",onClick:i,"data-testid":`${a}-overlay`,children:h.jsxs("div",{"data-testid":a,className:"w-[420px] max-w-[calc(100vw-32px)] rounded-2xl border border-text-100/[0.12] flex flex-col gap-4 p-5",style:{backgroundColor:"var(--bg-0)",boxShadow:"0 12px 40px rgba(0,0,0,0.04)"},onClick:v=>v.stopPropagation(),children:[h.jsx("div",{className:"text-[15px] font-semibold text-text-100",children:s}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:o}),h.jsx("input",{autoFocus:!0,type:"text",value:c,onChange:v=>u(v.target.value),...m,placeholder:n,"data-testid":`${a}-label`,className:"w-full px-3 py-2 text-[13px] bg-bg-50 border border-bg-300 rounded-lg focus:outline-none focus:border-text-300 transition-colors"})]}),h.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[h.jsx("button",{type:"button",onClick:i,className:"px-4 py-1.5 text-[12px] text-text-300 rounded-lg hover:bg-text-100/5 transition-colors cursor-pointer",children:"Cancel"}),h.jsx("button",{type:"button",onClick:p,disabled:f,"data-testid":`${a}-save`,className:"px-4 py-1.5 text-[12px] font-medium text-bg-0 rounded-lg bg-text-100 hover:bg-text-200 transition-colors cursor-pointer disabled:cursor-not-allowed disabled:opacity-40",children:"Save"})]})]})}),document.body):null}var MW=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"}),AW="VisuallyHidden",$R=g.forwardRef((e,t)=>h.jsx(Rt.span,{...e,ref:t,style:{...MW,...e.style}}));$R.displayName=AW;var LW=$R,[wp]=Uo("Tooltip",[_p]),Sp=_p(),FR="TooltipProvider",DW=700,k0="tooltip.open",[jW,Ny]=wp(FR),HR=e=>{const{__scopeTooltip:t,delayDuration:n=DW,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=g.useRef(!0),a=g.useRef(!1),l=g.useRef(0);return g.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),h.jsx(jW,{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})};HR.displayName=FR;var su="Tooltip",[OW,kp]=wp(su),UR=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=Ny(su,e.__scopeTooltip),c=Sp(t),[u,d]=g.useState(null),f=Oi(),p=g.useRef(0),m=o??l.disableHoverableContent,v=a??l.delayDuration,w=g.useRef(!1),[_,x]=Su({prop:r,defaultProp:i??!1,onChange:N=>{N?(l.onOpen(),document.dispatchEvent(new CustomEvent(k0))):l.onClose(),s==null||s(N)},caller:su}),b=g.useMemo(()=>_?w.current?"delayed-open":"instant-open":"closed",[_]),S=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,w.current=!1,x(!0)},[x]),C=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x(!1)},[x]),k=g.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{w.current=!0,x(!0),p.current=0},v)},[v,x]);return g.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),h.jsx(py,{...c,children:h.jsx(OW,{scope:t,contentId:f,open:_,stateAttribute:b,trigger:u,onTriggerChange:d,onTriggerEnter:g.useCallback(()=>{l.isOpenDelayedRef.current?k():S()},[l.isOpenDelayedRef,k,S]),onTriggerLeave:g.useCallback(()=>{m?C():(window.clearTimeout(p.current),p.current=0)},[C,m]),onOpen:S,onClose:C,disableHoverableContent:m,children:n})})};UR.displayName=su;var C0="TooltipTrigger",WR=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=kp(C0,n),s=Ny(C0,n),o=Sp(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(wP,{asChild:!0,...o,children:h.jsx(Rt.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:Pe(e.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:Pe(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:Pe(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Pe(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Pe(e.onBlur,i.onClose),onClick:Pe(e.onClick,i.onClose)})})});WR.displayName=C0;var BW="TooltipPortal",[Zae,zW]=wp(BW,{forceMount:void 0}),Za="TooltipContent",VR=g.forwardRef((e,t)=>{const n=zW(Za,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=kp(Za,e.__scopeTooltip);return h.jsx(Qi,{present:r||o.open,children:o.disableHoverableContent?h.jsx(qR,{side:i,...s,ref:t}):h.jsx($W,{side:i,...s,ref:t})})}),$W=g.forwardRef((e,t)=>{const n=kp(Za,e.__scopeTooltip),r=Ny(Za,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 w=m.currentTarget,_={x:m.clientX,y:m.clientY},x=VW(_,w.getBoundingClientRect()),b=qW(_,x),S=KW(v.getBoundingClientRect()),C=YW([...b,...S]);a(C),d(!0)},[d]);return g.useEffect(()=>()=>f(),[f]),g.useEffect(()=>{if(l&&u){const m=w=>p(w,u),v=w=>p(w,l);return l.addEventListener("pointerleave",m),u.addEventListener("pointerleave",v),()=>{l.removeEventListener("pointerleave",m),u.removeEventListener("pointerleave",v)}}},[l,u,p,f]),g.useEffect(()=>{if(o){const m=v=>{const w=v.target,_={x:v.clientX,y:v.clientY},x=(l==null?void 0:l.contains(w))||(u==null?void 0:u.contains(w)),b=!GW(_,o);x?f():b&&(f(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[l,u,o,c,f]),h.jsx(qR,{...e,ref:s})}),[FW,HW]=wp(su,{isInside:!1}),UW=M9("TooltipContent"),qR=g.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,l=kp(Za,n),c=Sp(n),{onClose:u}=l;return g.useEffect(()=>(document.addEventListener(k0,u),()=>document.removeEventListener(k0,u)),[u]),g.useEffect(()=>{if(l.trigger){const d=f=>{const p=f.target;p!=null&&p.contains(l.trigger)&&u()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,u]),h.jsx(fp,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:h.jsxs(SP,{"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(UW,{children:r}),h.jsx(FW,{scope:n,isInside:!0,children:h.jsx(LW,{id:l.contentId,role:"tooltip",children:i||r})})]})})});VR.displayName=Za;var KR="TooltipArrow",WW=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Sp(n);return HW(KR,n).isInside?null:h.jsx(kP,{...i,...r,ref:t})});WW.displayName=KR;function VW(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 qW(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 KW(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 GW(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 YW(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),XW(t)}function XW(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 QW=HR,ZW=UR,JW=WR,GR=VR;const uf=QW,Cp=ZW,Ep=JW,Pu=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(GR,{ref:r,sideOffset:t,className:ne("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}));Pu.displayName=GR.displayName;const eV={held:!1,indexBySessionId:new Map},tV=g.createContext(eV);function nV(){return g.useContext(tV)}const rV=Array.from({length:9},(e,t)=>({id:`switch-session-${t+1}`,combo:{key:String(t+1),mod:!0},label:`切换到第 ${t+1} 个会话`,group:"会话",desktopOnly:!0,hiddenInList:!0})),iV=[{id:"new-session",combo:{key:"n",mod:!0},label:"新建任务",description:"打开快捷新建弹窗",group:"通用",desktopOnly:!0},{id:"open-search",combo:{key:"k",mod:!0},label:"全局搜索",description:"搜会话内容 / persona / 联系人",group:"通用",desktopOnly:!0},{id:"search-tab-prev",combo:{key:"ArrowLeft",mod:!0},label:"搜索:上一组",description:"搜索浮层里切到左边那个 tab(会话 / persona / 联系人)",group:"通用"},{id:"search-tab-next",combo:{key:"ArrowRight",mod:!0},label:"搜索:下一组",description:"搜索浮层里切到右边那个 tab",group:"通用"},...rV,{id:"archive-session",combo:{key:"Backspace",mod:!0,shift:!0},label:"归档当前会话",description:"归档当前聊天区的会话,Enter 确认 / Esc 取消",group:"会话",desktopOnly:!0},{id:"tab-prev",combo:{key:"ArrowLeft",mod:!0,shift:!0},label:"上一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"tab-next",combo:{key:"ArrowRight",mod:!0,shift:!0},label:"下一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"toggle-hive",combo:{key:"h",mod:!0,shift:!0},label:"Hive 看板",description:"全屏看所有 agent 在干什么;Esc 或点任意行退出",group:"通用"},{id:"send-message",combo:{key:"Enter"},label:"发送消息",description:"在输入框中发送当前内容",group:"输入",displayOnly:!0},{id:"newline",combo:{key:"Enter",shift:!0},label:"换行",description:"在输入框中插入换行",group:"输入",displayOnly:!0},{id:"interrupt",combo:{key:"Escape"},label:"打断回复",description:"打断当前回复;2 秒内按两次停止任务",group:"输入",displayOnly:!0}];iV.filter(e=>!e.displayOnly);function sV(){return/Mac|iP(hone|od|ad)/.test(navigator.platform)}const oV=10,aV=20,lV=16,CS=20,ES=60,cV=4;function wd({testId:e,label:t,children:n}){return h.jsxs(Cp,{children:[h.jsx(Ep,{asChild:!0,children:h.jsx("span",{"data-testid":e,role:"img","aria-label":t,tabIndex:0,className:"inline-flex shrink-0",children:n})}),h.jsx(Pu,{side:"bottom",children:t})]})}function uV({session:e,active:t,hasUnread:n,running:r=!1,awaitingUser:i=!1,onSelect:s,onEdit:o,onDelete:a,onPin:l,onArchive:c,quickAction:u,depth:d=0,chevron:f,showCopyResume:p=!0,contactDisplayName:m,ownerPrincipalId:v,creatorDisplayName:w,dispatchedFromSessionTitle:_}){const[x,b]=g.useState(!1),S=nV(),C=S.held?S.indexBySessionId.get(e.sessionId):void 0,k=!!e.pinnedAt,N=d===0,T=d===0&&!!c,z=oV+d*aV;let P=null;u==="pin"&&N&&l?P={icon:k?h.jsx(Ww,{className:"w-4 h-4"}):h.jsx(Vw,{className:"w-4 h-4"}),label:k?"取消置顶":"置顶",run:()=>l(e.sessionId,!k)}:u==="archive"&&T&&c?P={icon:h.jsx(Fw,{className:"w-4 h-4"}),label:"归档",run:()=>c(e.sessionId,!0)}:u==="rename"&&o&&(P={icon:h.jsx(p0,{className:"w-4 h-4"}),label:"重命名",run:()=>b(!0)});const B=g.useCallback(async()=>{const $=qI(e);if($)try{await navigator.clipboard.writeText($)}catch{}},[e]),A=iy(e),R=e.originOwnerPrincipalId,M=R?`@${m??`…${R.slice(-8)}`}`:null,D=!!(e.ownerPersonaId&&v&&e.creatorPrincipalId&&e.creatorPrincipalId!==v&&!e.larkChatId&&!e.shiftFiredFromSessionId&&!e.dispatchedFromSessionId);return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":`session-item-${e.sessionId}`,onClick:s,style:{paddingLeft:z,display:"grid",gridTemplateColumns:f?`${lV}px ${CS}px 1fr auto ${ES}px`:`${CS}px 1fr auto ${ES}px`,gridTemplateAreas:f?'"chev icon name dot time"':'"icon name dot time"',columnGap:`${cV}px`,alignItems:"center"},className:ne("group relative rounded-lg cursor-pointer transition-all duration-150 pr-2.5 py-1.5",t?"bg-accent-dim":"hover:bg-sidebar-hover-bg"),children:[t?h.jsx("span",{"aria-hidden":"true",className:"absolute left-0 top-1/2 -translate-y-1/2 w-[3px] h-7 rounded-r-full bg-accent"}):null,h.jsx("div",{style:{gridArea:"chev"},className:"flex items-center justify-center",children:f??null}),h.jsx("div",{style:{gridArea:"icon"},className:"flex items-center justify-center",children:h.jsx(IW,{tool:e.tool})}),h.jsxs("div",{style:{gridArea:"name"},className:"flex items-center gap-1 min-w-0",children:[h.jsxs(uf,{delayDuration:200,skipDelayDuration:100,children:[e.dispatchedFromSessionId?h.jsx(wd,{testId:`dispatched-icon-${e.sessionId}`,label:`来自【${_??"另一会话"}】dispatch`,children:h.jsx(f8,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.shiftFiredFromSessionId?h.jsx(wd,{testId:`shift-fired-icon-${e.sessionId}`,label:"定时任务",children:h.jsx(O$,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.larkChatId?h.jsx(wd,{testId:`lark-chat-icon-${e.sessionId}`,label:e.larkChatType==="p2p"?"来自飞书DM":"来自飞书群",children:h.jsx(H8,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,D?h.jsx(wd,{testId:`guest-created-icon-${e.sessionId}`,label:w?`${w}创建`:"其他人创建",children:h.jsx(SF,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null]}),h.jsx("span",{"data-testid":`session-title-${e.sessionId}`,className:ne("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:A}),M?h.jsx("span",{"data-testid":`session-mirror-chip-${e.sessionId}`,title:`在 ${M.replace(/^@/,"")} 的设备上`,className:"shrink-0 inline-flex items-center px-1.5 py-0 rounded text-[10px] bg-accent-dim/40 text-accent border border-accent/20 max-w-[120px] truncate",children:M}):null]}),h.jsx(PW,{sessionId:e.sessionId,hasUnread:n,running:r,awaitingUser:i,style:{gridArea:"dot"}}),C!=null?h.jsx("span",{style:{gridArea:"time"},"data-testid":`session-quick-switch-badge-${e.sessionId}`,className:"text-right shrink-0 transition-opacity duration-150 group-hover:opacity-0",children:h.jsx("span",{className:"inline-flex items-center justify-center h-[18px] px-1.5 rounded-[5px] border border-border bg-bg-200/70 text-[11px] text-text-200 font-medium leading-none",children:sV()?`⌘${C}`:`Ctrl+${C}`})}):h.jsx("span",{style:{gridArea:"time"},className:ne("text-[11px] text-text-400/70 text-right shrink-0","transition-opacity duration-150 group-hover:opacity-0"),children:e.updatedAt?S9(e.updatedAt):""}),o||a||l||c?h.jsxs("div",{className:"absolute right-2 top-[3px] flex items-center opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100 transition-opacity",children:[P?h.jsx(uf,{delayDuration:200,skipDelayDuration:100,children:h.jsxs(Cp,{children:[h.jsx(Ep,{asChild:!0,children:h.jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),P.run()},className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":P.label,"data-testid":`quick-action-${u}-${e.sessionId}`,children:P.icon})}),h.jsx(Pu,{side:"bottom",children:P.label})]})}):null,h.jsxs(AR,{modal:!1,children:[h.jsx(LR,{asChild:!0,children:h.jsx("button",{type:"button",onClick:$=>$.stopPropagation(),className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"session actions","data-testid":`session-menu-${e.sessionId}`,children:h.jsx(bI,{className:"w-4 h-4"})})}),h.jsxs(Cy,{align:"end",onClick:$=>$.stopPropagation(),children:[l&&N&&h.jsxs(co,{onSelect:()=>l(e.sessionId,!k),"data-testid":`session-${k?"unpin":"pin"}-${e.sessionId}`,children:[k?h.jsx(Ww,{className:"w-3 h-3 mr-2 text-text-400"}):h.jsx(Vw,{className:"w-3 h-3 mr-2 text-text-400"}),k?"Unpin":"Pin"]}),T&&c&&h.jsxs(co,{onSelect:()=>c(e.sessionId,!0),"data-testid":`session-archive-${e.sessionId}`,children:[h.jsx(Fw,{className:"w-3 h-3 mr-2 text-text-400"}),"Archive"]}),o&&h.jsxs(co,{onSelect:()=>b(!0),"data-testid":`session-rename-${e.sessionId}`,children:[h.jsx(p0,{className:"w-3 h-3 mr-2 text-text-400"}),"Rename"]}),p&&e.toolSessionId?h.jsxs(co,{onSelect:()=>void B(),"data-testid":`session-copy-resume-${e.sessionId}`,children:[h.jsx(Qx,{className:"w-3 h-3 mr-2 text-text-400"}),"Copy Resume Command"]}):null,(l||o||p&&e.toolSessionId)&&a&&h.jsx(Ey,{}),a&&h.jsxs(co,{onSelect:()=>void a(e.sessionId),className:"text-destructive focus:text-destructive focus:bg-destructive/10","data-testid":`session-delete-${e.sessionId}`,children:[h.jsx(ey,{className:"w-3 h-3 mr-2"}),"Delete"]})]})]})]}):null]}),o?h.jsx(RW,{open:x,initialLabel:e.label??"",placeholder:e.cwd.split("/").pop()||"",onSubmit:$=>{o(e.sessionId,$),b(!1)},onCancel:()=>b(!1)}):null]})}function Ty({node:e,depth:t=0,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:v,getSessionDisplayName:w,parentSession:_}){const x=e.children.length>0,{isCollapsed:b,toggle:S}=P$(),C=!b(e.session.sessionId),k=g.useCallback(T=>{T.stopPropagation(),S(e.session.sessionId)},[S,e.session.sessionId]),N=x?h.jsx("button",{type:"button",onClick:k,"data-testid":`session-chevron-${e.session.sessionId}`,"aria-label":C?"collapse":"expand","aria-expanded":C,className:"shrink-0 flex items-center justify-center w-4 h-4 text-text-400 hover:text-text-100 cursor-pointer",children:C?h.jsx(Yn,{className:"w-3 h-3"}):h.jsx(Bn,{className:"w-3 h-3"})}):null;return h.jsxs("div",{"data-testid":`session-tree-node-${e.session.sessionId}`,children:[h.jsx(uV,{session:e.session,active:n===e.session.sessionId,hasUnread:(r==null?void 0:r.has(e.session.sessionId))??!1,running:(i==null?void 0:i.has(e.session.sessionId))??!1,awaitingUser:(s==null?void 0:s.has(e.session.sessionId))??!1,onSelect:()=>o(e.session.sessionId),onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,showCopyResume:p,ownerPrincipalId:m,creatorDisplayName:e.session.creatorPrincipalId?v==null?void 0:v(e.session.creatorPrincipalId):void 0,dispatchedFromSessionTitle:e.session.dispatchedFromSessionId?(w==null?void 0:w(e.session.dispatchedFromSessionId))??((_==null?void 0:_.sessionId)===e.session.dispatchedFromSessionId?iy(_):void 0):void 0,depth:t,chevron:N,contactDisplayName:e.session.originOwnerPrincipalId?f==null?void 0:f(e.session.originOwnerPrincipalId):void 0}),x&&C?h.jsx("div",{"data-testid":`session-tree-children-${e.session.sessionId}`,children:e.children.map(T=>h.jsx(Ty,{node:T,depth:t+1,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:v,getSessionDisplayName:w,parentSession:e.session},T.session.sessionId))}):null]})}function dV(e){return e.forkedFromSessionId??e.dispatchedFromSessionId??e.shiftFiredFromSessionId}function Iy(e,t){return e.updatedAt<t.updatedAt?1:e.updatedAt>t.updatedAt?-1:0}function YR(e){e=e.filter(s=>!s.ephemeral&&s.deployId===void 0);const t=new Map;for(const s of e)t.set(s.sessionId,s);const n=new Map,r=[];for(const s of e){const o=dV(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(Iy);return{session:s,children:a.map(i)}};return[...r].sort(hV).map(i)}function XR(e){return[...e].sort((t,n)=>Iy(t.session,n.session))}function hV(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?1:Iy(e,t)}function fV(e){return e.label?e.label:e.aiLabel?e.aiLabel:e.cwd.split("/").filter(Boolean).pop()??""}function NS(e,t){const n=t.trim().toLowerCase();return n===""?!0:e.toLowerCase().includes(n)}const pV={isCollapsed:()=>!1,toggle:()=>{},prune:()=>{}};function mV({personas:e,activePersonaId:t,onSelectPersona:n,onCreateSession:r,sessions:i,activeSessionId:s,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,isPersonaExpanded:p,onTogglePersonaExpanded:m,onEditSession:v,onPinSession:w,showCopyResume:_,treatSessionsAsRoots:x,searchQuery:b}){const[S,C]=g.useState(null),[k,N]=g.useState(()=>new Set),T=p??(D=>k.has(D)),z=g.useCallback(D=>{if(m){m(D);return}N($=>{const F=new Set($);return F.has(D)?F.delete(D):F.add(D),F})},[m]),P=g.useMemo(()=>i==null?void 0:i.filter(D=>!D.ephemeral),[i]),B=g.useMemo(()=>new Map((P??[]).map(D=>[D.sessionId,iy(D)])),[P]),A=g.useCallback(D=>f==null?void 0:f.get(D),[f]),R=g.useCallback(D=>B.get(D),[B]);if(e.length===0)return h.jsx(gV,{});const M=(b??"").trim();return M?h.jsx(Yx.Provider,{value:pV,children:h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(D=>{const $=P?P.filter(E=>E.ownerPersonaId===D.personaId).sort((E,H)=>H.updatedAt>E.updatedAt?1:-1):[],F=NS(D.label,M),j=$.filter(E=>NS(fV(E),M));if(!F&&j.length===0)return null;const O=F?$:j;return h.jsx(TS,{persona:D,active:D.personaId===t,editing:!1,onSelectPersona:n,onSubmitCreateSession:()=>{},onCancelCreateSession:()=>{},personaSessions:O,collapsed:!1,onToggleCollapsed:()=>{},activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:w,showCopyResume:_,treatSessionsAsRoots:x,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:A,getSessionDisplayName:R},D.personaId)})})}):h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(D=>{const $=P?P.filter(F=>F.ownerPersonaId===D.personaId).sort((F,j)=>j.updatedAt>F.updatedAt?1:-1):[];return h.jsx(TS,{persona:D,active:D.personaId===t,editing:D.personaId===S,onSelectPersona:n,onStartCreateSession:r?()=>C(D.personaId):void 0,onSubmitCreateSession:F=>{C(null),r==null||r(D.personaId,F)},onCancelCreateSession:()=>C(null),personaSessions:$,collapsed:!T(D.personaId),onToggleCollapsed:()=>z(D.personaId),activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:w,showCopyResume:_,treatSessionsAsRoots:x,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:A,getSessionDisplayName:R},D.personaId)})})}function gV(){return h.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-text-400",children:"还没有 persona。点上方 Personas 标题右侧 + 创建第一个。"})}function TS({persona:e,active:t,editing:n,onSelectPersona:r,onStartCreateSession:i,onSubmitCreateSession:s,onCancelCreateSession:o,personaSessions:a,collapsed:l,onToggleCollapsed:c,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:w,onPinSession:_,showCopyResume:x,treatSessionsAsRoots:b,ownerPrincipalId:S,creatorDisplayNameByOwnerId:C,getCreatorDisplayName:k,getSessionDisplayName:N}){const T=a.length>0,z=!l,P=g.useMemo(()=>{const R=[],M=new Map;for(const D of a){const $=D.creatorPrincipalId;if(D.larkChatId!=null||!$||S&&$===S){R.push(D);continue}const F=$,j=(C==null?void 0:C.get(F))??`…${F.slice(-8)}`,O=M.get(F);O?O.sessions.push(D):M.set(F,{groupKey:F,displayName:j,sessions:[D]})}return{self:R,byPeer:[...M.values()]}},[a,S,C]),B=P.byPeer.length>0,A=g.useMemo(()=>z&&!B?XR(YR(a)):[],[z,B,a]);return h.jsxs("div",{"data-testid":`persona-node-${e.personaId}`,children:[h.jsxs("div",{className:ne("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":z?"collapse":"expand","aria-expanded":z,"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:z?h.jsx(Yn,{className:"h-3 w-3"}):h.jsx(Bn,{className:"h-3 w-3"})}):h.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),h.jsx(dp,{tool:e.tool,className:ne("h-3.5 w-3.5 shrink-0",hp(e.tool))}),h.jsx("span",{className:"flex-1 truncate text-[13px]",children:e.label}),T?h.jsx("span",{className:"shrink-0 text-[10px] text-text-400 tabular-nums","aria-label":`${a.length} sessions`,children:a.length}):null,i?h.jsx("button",{type:"button",onClick: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(tF,{className:"h-3.5 w-3.5"})}):null]}),n?h.jsx(vV,{personaId:e.personaId,tool:e.tool,onSubmit:s,onCancel:o}):null,T&&z?h.jsx("div",{"data-testid":`persona-sessions-${e.personaId}`,children:B?h.jsxs(h.Fragment,{children:[P.self.length>0&&h.jsx(IS,{groupKey:`${e.personaId}-self`,label:"我自己",testId:`persona-sessions-${e.personaId}-self`,sessions:P.self,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:w,onPinSession:_,showCopyResume:x,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N}),P.byPeer.map(R=>h.jsx(IS,{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:w,onPinSession:_,showCopyResume:x,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N},`${e.personaId}-peer-${R.groupKey}`))]}):A.map(R=>h.jsx(Ty,{node:R,depth:b?0:1,activeId:u,unreadIds:p,runningIds:f,awaitingIds:d,onSelect:M=>m==null?void 0:m(M),onDelete:v,onEdit:w,onPin:_,showCopyResume:x,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N},R.session.sessionId))}):null]})}function IS({label:e,testId:t,sessions:n,activeSessionId:r,awaitingIds:i,runningIds:s,unreadIds:o,onSelectSession:a,onDeleteSession:l,onEditSession:c,onPinSession:u,showCopyResume:d,ownerPrincipalId:f,getCreatorDisplayName:p,getSessionDisplayName:m}){const[v,w]=g.useState(!1),_=!v,x=g.useMemo(()=>_?XR(YR(n)):[],[_,n]);return h.jsxs("div",{"data-testid":t,children:[h.jsxs("button",{type:"button",onClick:()=>w(b=>!b),"aria-label":_?"collapse":"expand","aria-expanded":_,"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:[_?h.jsx(Yn,{className:"h-3 w-3"}):h.jsx(Bn,{className:"h-3 w-3"}),h.jsx(TI,{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})]}),_&&h.jsx("div",{children:x.map(b=>h.jsx(Ty,{node:b,depth:2,activeId:r,unreadIds:o,runningIds:s,awaitingIds:i,onSelect:S=>a==null?void 0:a(S),onDelete:l,onEdit:c,onPin:u,showCopyResume:d,ownerPrincipalId:f,getCreatorDisplayName:p,getSessionDisplayName:m},b.session.sessionId))})]})}function vV({personaId:e,tool:t,onSubmit:n,onCancel:r}){const[i,s]=g.useState(""),o=g.useRef(null),a=i.trim(),l=a.length>0;g.useEffect(()=>{var d;(d=o.current)==null||d.focus()},[]);const c=g.useCallback(()=>{l&&n(a)},[l,a,n]),u=Iu(c,r);return h.jsxs("div",{className:"flex items-center gap-1.5 pl-9 pr-2 py-1","data-testid":`persona-new-session-row-${e}`,children:[h.jsx(dp,{tool:t,className:ne("h-3 w-3 shrink-0",hp(t))}),h.jsx("input",{ref:o,type:"text",value:i,onChange:d=>s(d.target.value),...u,onBlur:r,placeholder:"session label...","data-testid":`persona-new-session-input-${e}`,className:"flex-1 min-w-0 bg-bg-100 border border-text-100/15 rounded px-1.5 py-0.5 text-[12px] text-text-100 placeholder:text-text-400 focus:outline-none focus:border-text-100/40"}),h.jsx("button",{type:"button",onMouseDown:d=>{d.preventDefault(),c()},disabled:!l,"aria-label":"确认",title:"确认(Enter)","data-testid":`persona-new-session-confirm-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-text-300",children:h.jsx(bu,{className:"h-3 w-3"})}),h.jsx("button",{type:"button",onMouseDown:d=>{d.preventDefault(),r()},"aria-label":"取消",title:"取消(Esc)","data-testid":`persona-new-session-cancel-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100",children:h.jsx(qr,{className:"h-3 w-3"})})]})}function _V(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function xV(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),r=parseFloat(n.fontSize);return t*r}function yV(e){return e/100*window.innerHeight}function bV(e){return e/100*window.innerWidth}function wV(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function ic({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=wV(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=xV(t,i);break}case"em":{r=_V(t,i);break}case"vh":{r=yV(i);break}case"vw":{r=bV(i);break}}return r}function An(e){return parseFloat(e.toFixed(3))}function Ja({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 E0(e){const{panels:t}=e,n=Ja({group:e});return n===0?t.map(r=>({groupResizeBehavior:r.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:r.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:r.panelConstraints.disabled,minSize:0,maxSize:100,panelId:r.id})):t.map(r=>{const{element:i,panelConstraints:s}=r;let o=0;if(s.collapsedSize!==void 0){const u=ic({groupSize:n,panelElement:i,styleProp:s.collapsedSize});o=An(u/n*100)}let a;if(s.defaultSize!==void 0){const u=ic({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=An(u/n*100)}let l=0;if(s.minSize!==void 0){const u=ic({groupSize:n,panelElement:i,styleProp:s.minSize});l=An(u/n*100)}let c=100;if(s.maxSize!==void 0){const u=ic({groupSize:n,panelElement:i,styleProp:s.maxSize});c=An(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 lt(e,t="Assertion error"){if(!e)throw Error(t)}function N0(e,t){return Array.from(t).sort(e==="horizontal"?SV:kV)}function SV(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function kV(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function QR(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function ZR(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 CV({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}=ZR(r,o),c=e==="horizontal"?a:l;c<s&&(s=c,i=o)}return lt(i,"No rect found"),i}let Sd;function EV(){return Sd===void 0&&(typeof matchMedia=="function"?Sd=!!matchMedia("(pointer:coarse)").matches:Sd=!1),Sd}function JR(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=N0(n,Array.from(t.children).filter(QR).map(m=>({element:m}))).map(({element:m})=>m),o=[];let a=!1,l=!1,c=-1,u=-1,d=0,f,p=[];{let m=-1;for(const v of s)v.hasAttribute("data-panel")&&(m++,v.hasAttribute("data-disabled")||(d++,c===-1&&(c=m),u=m))}if(d>1){let m=-1;for(const v of s)if(v.hasAttribute("data-panel")){m++;const w=r.find(_=>_.element===v);if(w){if(f){const _=f.element.getBoundingClientRect(),x=v.getBoundingClientRect();let b;if(l){const S=n==="horizontal"?new DOMRect(_.right,_.top,0,_.height):new DOMRect(_.left,_.bottom,_.width,0),C=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=[S,C];break}case 1:{const k=p[0],N=CV({orientation:n,rects:[_,x],targetRect:k.element.getBoundingClientRect()});b=[k,N===_?C:S];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 S of b){let C="width"in S?S:S.element.getBoundingClientRect();const k=EV()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(C.width<k){const T=k-C.width;C=new DOMRect(C.x-T/2,C.y,C.width+T,C.height)}if(C.height<k){const T=k-C.height;C=new DOMRect(C.x,C.y-T/2,C.width,C.height+T)}const N=m<=c||m>u;!a&&!N&&o.push({group:e,groupSize:Ja({group:e}),panels:[f,w],separator:"width"in S?void 0:S,rect:C}),a=!1}}l=!1,f=w,p=[]}}else if(v.hasAttribute("data-separator")){v.ariaDisabled!==null&&(a=!0);const w=i.find(_=>_.element===v);w?p.push(w):(f=void 0,p=[])}else l=!0}return o}var _s;class eM{constructor(){N1(this,_s,{})}addListener(t,n){const r=Rl(this,_s)[t];return r===void 0?Rl(this,_s)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=Rl(this,_s)[t];if(r!==void 0)if(r.length===1)r[0].call(null,n);else{let i=!1,s=null;const o=Array.from(r);for(let a=0;a<o.length;a++){const l=o[a];try{l.call(null,n)}catch(c){s===null&&(i=!0,s=c)}}if(i)throw s}}removeAllListeners(){T1(this,_s,{})}removeListener(t,n){const r=Rl(this,_s)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}_s=new WeakMap;let Da={cursorFlags:0,state:"inactive"};const Py=new eM;function Po(){return Da}function NV(e){return Py.addListener("change",e)}function TV(e){const t=Da,n={...Da};n.cursorFlags=e,Da=n,Py.emit("change",{prev:t,next:n})}function ja(e){const t=Da;Da=e,Py.emit("change",{prev:t,next:e})}const IV=e=>e,Hm=()=>{},tM=1,nM=2,rM=4,iM=8,PS=3,RS=12;let kd;function MS(){return kd===void 0&&(kd=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(kd=!0)),kd}function PV({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case"active":case"hover":t.forEach(s=>{if(!s.mutableState.disableCursor)switch(s.orientation){case"horizontal":{r++;break}case"vertical":{i++;break}}})}if(!(r===0&&i===0)){switch(n){case"active":{if(e&&MS()){const s=(e&tM)!==0,o=(e&nM)!==0,a=(e&rM)!==0,l=(e&iM)!==0;if(s)return a?"se-resize":l?"ne-resize":"e-resize";if(o)return a?"sw-resize":l?"nw-resize":"w-resize";if(a)return"s-resize";if(l)return"n-resize"}break}}return MS()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const AS=new WeakMap;function Ry(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=AS.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));const r=Po();switch(r.state){case"active":case"hover":{const i=PV({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(o=>o.group),state:r.state}),s=`*, *:hover {cursor: ${i} !important; }`;if(t===s)return;t=s,i?n.cssRules.length===0?n.insertRule(s):n.replaceSync(s):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}AS.set(e,{prevStyle:t,styleSheet:n})}let ai=new Map;const sM=new eM;function RV(e){ai=new Map(ai),ai.delete(e)}function LS(e,t){for(const[n]of ai)if(n.id===e)return n}function Ms(e,t){for(const[n,r]of ai)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Vo(){return ai}function My(e,t){return sM.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function qi(e,t,n){const r=ai.get(e);ai=new Map(ai),ai.set(e,t),sM.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:r,next:t})}function oM(e){const t=Po();let n=!1;switch(t.state){case"active":ja({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(Ry(e),n=!0,t.hitRegions.forEach(r=>{const i=Ms(r.group.id,!0);qi(r.group,i,{isUserInteraction:!0})}))}return n}function DS(e){e.defaultPrevented||oM(e.currentTarget)}function MV(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const o=ZR(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 AV(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function LV(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:BS(e),b:BS(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();lt(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:OS(jS(n.a)),b:OS(jS(n.b))};if(i.a===i.b){const s=r.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const l=s[a];if(l===o.a)return 1;if(l===o.b)return-1}}return Math.sign(i.a-i.b)}const DV=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function jV(e){const t=getComputedStyle(aM(e)??e).display;return t==="flex"||t==="inline-flex"}function OV(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||jV(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||DV.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function jS(e){let t=e.length;for(;t--;){const n=e[t];if(lt(n,"Missing node"),OV(n))return n}return null}function OS(e){return e&&Number(getComputedStyle(e).zIndex)||0}function BS(e){const t=[];for(;e;)t.push(e),e=aM(e);return t}function aM(e){const{parentNode:t}=e;return AV(t)?t.host:t}function BV(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 zV({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!QR(n)||n.contains(e)||e.contains(n))return!0;if(LV(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(BV(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Ay(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=JR(i),o=MV(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&zV({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function $V(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function wn(e,t,n=0){return Math.abs(An(e)-An(t))<=n}function ri(e,t){return wn(e,t)?0:e>t?1:-1}function ka({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(ri(r,l)<0)if(s){const c=(i+l)/2;ri(r,c)<0?r=i:r=l}else r=l;return r=Math.min(a,r),r=An(r),r}function ou({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(wn(e,0))return t;const o=s==="imperative-api",a=Object.values(t),l=Object.values(i),c=[...a],[u,d]=r;lt(u!=null,"Invalid first pivot index"),lt(d!=null,"Invalid second pivot index");let f=0;switch(s){case"keyboard":{{const v=e<0?d:u,w=n[v];lt(w,`Panel constraints not found for index ${v}`);const{collapsedSize:_=0,collapsible:x,minSize:b=0}=w;if(x){const S=a[v];if(lt(S!=null,`Previous layout not found for panel index ${v}`),wn(S,_)){const C=b-S;ri(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}{const v=e<0?u:d,w=n[v];lt(w,`No panel constraints found for index ${v}`);const{collapsedSize:_=0,collapsible:x,minSize:b=0}=w;if(x){const S=a[v];if(lt(S!=null,`Previous layout not found for panel index ${v}`),wn(S,b)){const C=S-_;ri(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}break}default:{const v=e<0?d:u,w=n[v];lt(w,`Panel constraints not found for index ${v}`);const _=a[v],{collapsible:x,collapsedSize:b,minSize:S}=w;if(x&&ri(_,S)<0)if(e>0){const C=S-b,k=C/2,N=_+e;ri(N,S)<0&&(e=ri(e,k)<=0?0:C)}else{const C=S-b,k=100-C/2,N=_-e;ri(N,S)<0&&(e=ri(100+e,k)>0?0:-C)}break}}{const v=e<0?1:-1;let w=e<0?d:u,_=0;for(;;){const b=a[w];lt(b!=null,`Previous layout not found for panel index ${w}`);const S=ka({overrideDisabledPanels:o,panelConstraints:n[w],prevSize:b,size:100})-b;if(_+=S,w+=v,w<0||w>=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 w=Math.abs(e)-Math.abs(f),_=a[v];lt(_!=null,`Previous layout not found for panel index ${v}`);const x=_-w,b=ka({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:_,size:x});if(!wn(_,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($V(l,c))return i;{const v=e<0?d:u,w=a[v];lt(w!=null,`Previous layout not found for panel index ${v}`);const _=w+f,x=ka({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:w,size:_});if(c[v]=x,!wn(x,_)){let b=_-x,S=e<0?d:u;for(;S>=0&&S<n.length;){const C=c[S];lt(C!=null,`Previous layout not found for panel index ${S}`);const k=C+b,N=ka({overrideDisabledPanels:o,panelConstraints:n[S],prevSize:C,size:k});if(wn(C,N)||(b-=N-C,c[S]=N),wn(b,0))break;e>0?S--:S++}}}const p=Object.values(c).reduce((v,w)=>w+v,0);if(!wn(p,100,.1))return i;const m=Object.keys(i);return c.reduce((v,w,_)=>(v[m[_]]=w,v),{})}function Ro(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||ri(e[n],t[n])!==0)return!1;return!0}function Mo({layout:e,panelConstraints:t}){const n=Object.values(e),r=[...n],i=r.reduce((a,l)=>a+l,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(a=>`${a}%`).join(", ")}`);if(!wn(i,100)&&r.length>0)for(let a=0;a<t.length;a++){const l=r[a];lt(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];lt(l!=null,`No layout data found for index ${a}`);const c=r[a];lt(c!=null,`No layout data found for index ${a}`);const u=ka({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});c!=u&&(s+=c-u,r[a]=u)}if(!wn(s,0))for(let a=0;a<t.length;a++){const l=r[a];lt(l!=null,`No layout data found for index ${a}`);const c=l+s,u=ka({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});if(l!==u&&(s-=u-l,r[a]=u,wn(s,0)))break}const o=Object.keys(e);return r.reduce((a,l,c)=>(a[o[c]]=l,a),{})}function lM({groupId:e,panelId:t}){const n=()=>{const l=Vo();for(const[c,{defaultLayoutDeferred:u,derivedPanelConstraints:d,layout:f,groupSize:p,separatorToPanels:m}]of l)if(c.id===e)return{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:c,groupSize:p,layout:f,separatorToPanels:m};throw Error(`Group ${e} not found`)},r=()=>{const l=n().derivedPanelConstraints.find(c=>c.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const l=n().group.panels.find(c=>c.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const l=n().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:l,panels:c,prevLayout:u,derivedPanelConstraints:d})=>{const f=s(),p=c.findIndex(w=>w.id===t),m=p===0,v=p===c.length-1;if(v&&l<f&&(m||c.slice(0,p).every((w,_)=>{const x=d[_];return(x==null?void 0:x.collapsible)&&wn(x.collapsedSize,u[x.panelId])}))){const w=c.slice(0,p).reduce((_,x)=>_+u[x.id],0);return{...u,[t]:An(100-w)}}return ou({delta:v?f-l:l-f,initialLayout:u,panelConstraints:d,pivotIndices:v?[p-1,p]:[p,p+1],prevLayout:u,trigger:"imperative-api"})},a=l=>{const c=s();if(l===c)return;const{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:f,groupSize:p,layout:m,separatorToPanels:v}=n(),w=o({nextSize:l,panels:f.panels,prevLayout:m,derivedPanelConstraints:d}),_=Mo({layout:w,panelConstraints:d});Ro(m,_)||qi(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&&wn(c,u)},resize:l=>{const{group:c}=n(),{element:u}=i(),d=Ja({group:c}),f=ic({groupSize:d,panelElement:u,styleProp:l}),p=An(f/d*100);a(p)}}}function zS(e){if(e.defaultPrevented)return;const t=Vo();Ay(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=lM({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function sh(e){const t=Vo();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 cM({groupId:e}){const t=()=>{const n=Vo();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=Mo({layout:n,panelConstraints:i});return r?a:(Ro(a,c)||qi(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:o,layout:c,separatorToPanels:l}),c)}}}function to(e,t){const n=sh(e),r=Ms(n.id,!0),i=n.separators.find(u=>u.element===e);lt(i,"Matching separator not found");const s=r.separatorToPanels.get(i);lt(s,"Matching panels not found");const o=s.map(u=>n.panels.indexOf(u)),a=cM({groupId:n.id}).getLayout(),l=ou({delta:t,initialLayout:a,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),c=Mo({layout:l,panelConstraints:r.derivedPanelConstraints});Ro(a,c)||qi(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function $S(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=sh(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&to(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&to(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&to(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&to(t,-5);break}case"End":{e.preventDefault(),to(t,100);break}case"Enter":{e.preventDefault();const r=sh(t),i=Ms(r.id,!0),{derivedPanelConstraints:s,layout:o,separatorToPanels:a}=i,l=r.separators.find(f=>f.element===t);lt(l,"Matching separator not found");const c=a.get(l);lt(c,"Matching panels not found");const u=c[0],d=s.find(f=>f.panelId===u.id);if(lt(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;to(t,p-f)}break}case"F6":{e.preventDefault();const r=sh(t).separators.map(o=>o.element),i=Array.from(r).findIndex(o=>o===e.currentTarget);lt(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(),to(t,-100);break}}}function FS(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=Vo(),n=Ay(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)}),ja({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function uM({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:s,prevCursorFlags:o}){let a=0;n.forEach(c=>{const{group:u,groupSize:d}=c,{orientation:f,panels:p}=u,{disableCursor:m}=u.mutableState;let v=0;s?f==="horizontal"?v=(t.clientX-s.x)/d*100:v=(t.clientY-s.y)/d*100:f==="horizontal"?v=t.clientX<0?-100:100:v=t.clientY<0?-100:100;const w=r.get(u),_=i.get(u);if(!w||!_)return;const{defaultLayoutDeferred:x,derivedPanelConstraints:b,groupSize:S,layout:C,separatorToPanels:k}=_;if(b&&C&&k){const N=ou({delta:v,initialLayout:w,panelConstraints:b,pivotIndices:c.panels.map(T=>p.indexOf(T)),prevLayout:C,trigger:"mouse-or-touch"});if(Ro(N,C)){if(v!==0&&!m)switch(f){case"horizontal":{a|=v<0?tM:nM;break}case"vertical":{a|=v<0?rM:iM;break}}}else qi(c.group,{defaultLayoutDeferred:x,derivedPanelConstraints:b,groupSize:S,layout:N,separatorToPanels:k})}});let l=0;t.movementX===0?l|=o&PS:l|=a&PS,t.movementY===0?l|=o&RS:l|=a&RS,TV(l),Ry(e)}function HS(e){const t=Vo(),n=Po();switch(n.state){case"active":uM({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function US(e){var r,i;if(e.defaultPrevented)return;const t=Po(),n=Vo();switch(t.state){case"active":{if(e.buttons===0){ja({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const o=Ms(s.group.id,!0);qi(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))}uM({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=Ay(e,n);s.length===0?t.state!=="inactive"&&ja({cursorFlags:0,state:"inactive"}):ja({cursorFlags:0,hitRegions:s,state:"hover"}),Ry(e.currentTarget);break}}}function WS(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Po().state){case"hover":ja({cursorFlags:0,state:"inactive"})}}function VS(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||oM(e.currentTarget)&&e.preventDefault()}function qS(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const o=An(s.defaultSize);n+=o,r[s.panelId]=o}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=An((100-n)/i);for(const o of e)o.defaultSize===void 0&&(r[o.panelId]=s)}return r}function FV(e,t,n){if(!n[0])return;const r=e.panels.find(l=>l.element===t);if(!r||!r.onResize)return;const i=Ja({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,a={asPercentage:An(s/i*100),inPixels:s};r.mutableValues.prevSize=a,r.onResize(a,r.id,o)}function HV(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 UV({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=An(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]=An(f/s*c)}else{const d=An(c/l.length);for(const f of l)u[f]=d}return u}function WV(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 ra=new Map;function VV(e){let t=!0;lt(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,s=new n(m=>{for(const v of m){const{borderBoxSize:w,target:_}=v;if(_===e.element){if(t){const x=Ja({group:e});if(x===0)return;const b=Ms(e.id);if(!b)return;const S=E0(e),C=b.defaultLayoutDeferred?qS(S):b.layout,k=UV({group:e,nextGroupSize:x,prevGroupSize:b.groupSize,prevLayout:C}),N=Mo({layout:k,panelConstraints:S});if(!b.defaultLayoutDeferred&&Ro(b.layout,N)&&HV(b.derivedPanelConstraints,S)&&b.groupSize===x)return;qi(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:S,groupSize:x,layout:N,separatorToPanels:b.separatorToPanels})}}else FV(e,_,w)}});s.observe(e.element),e.panels.forEach(m=>{lt(!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=Ja({group:e}),a=E0(e),l=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(WV(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[l]??c??qS(a),d=Mo({layout:u,panelConstraints:a}),f=e.element.ownerDocument;ra.set(f,(ra.get(f)??0)+1);const p=new Map;return JR(e).forEach(m=>{m.separator&&p.set(m.separator,m.panels)}),qi(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:a,groupSize:o,layout:d,separatorToPanels:p}),e.separators.forEach(m=>{lt(!i.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),i.add(m.id),m.element.addEventListener("keydown",$S)}),ra.get(f)===1&&(f.addEventListener("contextmenu",DS,!0),f.addEventListener("dblclick",zS,!0),f.addEventListener("pointerdown",FS,!0),f.addEventListener("pointerleave",HS),f.addEventListener("pointermove",US),f.addEventListener("pointerout",WS),f.addEventListener("pointerup",VS,!0)),function(){t=!1,ra.set(f,Math.max(0,(ra.get(f)??0)-1)),RV(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",$S)}),ra.get(f)||(f.removeEventListener("contextmenu",DS,!0),f.removeEventListener("dblclick",zS,!0),f.removeEventListener("pointerdown",FS,!0),f.removeEventListener("pointerleave",HS),f.removeEventListener("pointermove",US),f.removeEventListener("pointerout",WS),f.removeEventListener("pointerup",VS,!0)),s.disconnect()}}function qV(){const[e,t]=g.useState({}),n=g.useCallback(()=>t({}),[]);return[e,n]}function Ly(e){const t=g.useId();return`${e??t}`}const qo=typeof window<"u"?g.useLayoutEffect:g.useEffect;function kc(e){const t=g.useRef(e);return qo(()=>{t.current=e},[e]),g.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function Dy(...e){return kc(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function jy(e){const t=g.useRef({...e});return qo(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const dM=g.createContext(null);function KV(e,t){const n=g.useRef({getLayout:()=>({}),setLayout:IV});g.useImperativeHandle(t,()=>n.current,[]),qo(()=>{Object.assign(n.current,cM({groupId:e}))})}function Oy({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:s,groupRef:o,id:a,onLayoutChange:l,onLayoutChanged:c,orientation:u="horizontal",resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){const m=g.useRef({onLayoutChange:{},onLayoutChanged:{}}),v=kc(B=>{Ro(m.current.onLayoutChange,B)||(m.current.onLayoutChange=B,l==null||l(B))}),w=kc((B,A)=>{Ro(m.current.onLayoutChanged,B)||(m.current.onLayoutChanged=B,c==null||c(B,{isUserInteraction:A}))}),_=Ly(a),x=g.useRef(null),[b,S]=qV(),C=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),k=Dy(x,s);KV(_,o);const N=kc((B,A)=>{const R=Po(),M=LS(B),D=Ms(B);if(D){let $=!1;switch(R.state){case"active":{$=R.hitRegions.some(F=>F.group===M);break}}return{flexGrow:D.layout[A]??1,pointerEvents:$?"none":void 0}}if(n!=null&&n[A])return{flexGrow:n==null?void 0:n[A]}}),T=jy({defaultLayout:n,disableCursor:r}),z=g.useMemo(()=>({get disableCursor(){return!!T.disableCursor},getPanelStyles:N,id:_,orientation:u,registerPanel:B=>{const A=C.current;return A.panels=N0(u,[...A.panels,B]),S(),()=>{A.panels=A.panels.filter(R=>R!==B),S()}},registerSeparator:B=>{const A=C.current;return A.separators=N0(u,[...A.separators,B]),S(),()=>{A.separators=A.separators.filter(R=>R!==B),S()}},updatePanelProps:(B,{disabled:A})=>{const R=C.current.panels.find($=>$.id===B);R&&(R.panelConstraints.disabled=A);const M=LS(_),D=Ms(_);M&&D&&qi(M,{...D,derivedPanelConstraints:E0(M)})},updateSeparatorProps:(B,{disabled:A,disableDoubleClick:R})=>{const M=C.current.separators.find(D=>D.id===B);M&&(M.disabled=A,M.disableDoubleClick=R)}}),[N,_,S,u,T]),P=g.useRef(null);return qo(()=>{const B=x.current;if(B===null)return;const A=C.current;let R;if(T.defaultLayout!==void 0&&Object.keys(T.defaultLayout).length===A.panels.length){R={};for(const E of A.panels){const H=T.defaultLayout[E.id];H!==void 0&&(R[E.id]=H)}}const M={disabled:!!i,element:B,id:_,mutableState:{defaultLayout:R,disableCursor:!!T.disableCursor,expandedPanelSizes:C.current.lastExpandedPanelSizes,layouts:C.current.layouts},orientation:u,panels:A.panels,resizeTargetMinimumSize:A.resizeTargetMinimumSize,separators:A.separators};P.current=M;const D=VV(M),{defaultLayoutDeferred:$,derivedPanelConstraints:F,layout:j}=Ms(M.id,!0);!$&&F.length>0&&(v(j),w(j,!1));const O=My(_,E=>{const{defaultLayoutDeferred:H,derivedPanelConstraints:q,layout:L}=E.next;if(H||q.length===0)return;const re=M.panels.map(({id:K})=>K).join(",");M.mutableState.layouts[re]=L,q.forEach(K=>{if(K.collapsible){const{layout:me}=E.prev??{};if(me){const Re=wn(K.collapsedSize,L[K.panelId]),ce=wn(K.collapsedSize,me[K.panelId]);Re&&!ce&&(M.mutableState.expandedPanelSizes[K.panelId]=me[K.panelId])}}});const se=Po().state!=="active";v(L),se&&w(L,E.isUserInteraction)});return()=>{P.current=null,D(),O()}},[i,_,w,v,u,b,T]),g.useEffect(()=>{const B=P.current;B&&(B.mutableState.defaultLayout=n,B.mutableState.disableCursor=!!r)}),h.jsx(dM.Provider,{value:z,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})})}Oy.displayName="Group";function By(){const e=g.useContext(dM);return lt(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function GV(e,t){const{id:n}=By(),r=g.useRef({collapse:Hm,expand:Hm,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Hm});g.useImperativeHandle(t,()=>r.current,[]),qo(()=>{Object.assign(r.current,lM({groupId:n,panelId:e}))})}function df({children:e,className:t,collapsedSize:n="0%",collapsible:r=!1,defaultSize:i,disabled:s,elementRef:o,groupResizeBehavior:a="preserve-relative-size",id:l,maxSize:c="100%",minSize:u="0%",onResize:d,panelRef:f,style:p,...m}){const v=!!l,w=Ly(l),_=jy({disabled:s}),x=g.useRef(null),b=Dy(x,o),{getPanelStyles:S,id:C,orientation:k,registerPanel:N,updatePanelProps:T}=By(),z=d!==null,P=kc((M,D,$)=>{d==null||d(M,l,$)});qo(()=>{const M=x.current;if(M!==null){const D={element:M,id:w,idIsStable:v,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:z?P:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:c,minSize:u}};return N(D)}},[a,n,r,i,z,w,v,c,u,P,N,_]),g.useEffect(()=>{T(w,{disabled:s})},[s,w,T]),GV(w,f);const B=()=>{const M=S(C,w);if(M)return JSON.stringify(M)},A=g.useSyncExternalStore(M=>My(C,M),B,B);let R;return A?R=JSON.parse(A):i!==void 0?R={flexGrow:void 0,flexShrink:void 0,flexBasis:i}:R={flexGrow:1},h.jsx("div",{...m,"data-disabled":s||void 0,"data-panel":!0,"data-testid":w,id:w,ref:b,style:{...YV,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...R},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})})}df.displayName="Panel";const YV={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function XV({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=Mo({layout:ou({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=Mo({layout:ou({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:o}}function hM({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:s,style:o,...a}){const l=Ly(s),c=jy({disabled:n,disableDoubleClick:r}),[u,d]=g.useState({}),[f,p]=g.useState("inactive"),[m,v]=g.useState(!1),w=g.useRef(null),_=Dy(w,i),{disableCursor:x,id:b,orientation:S,registerSeparator:C,updateSeparatorProps:k}=By(),N=S==="horizontal"?"vertical":"horizontal";qo(()=>{const P=w.current;if(P!==null){const B={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:P,id:l},A=C(B),R=NV(D=>{p(D.next.state!=="inactive"&&D.next.hitRegions.some($=>$.separator===B)?D.next.state:"inactive")}),M=My(b,D=>{const{derivedPanelConstraints:$,layout:F,separatorToPanels:j}=D.next,O=j.get(B);if(O){const E=O[0],H=O.indexOf(E);d(XV({layout:F,panelConstraints:$,panelId:E.id,panelIndex:H}))}});return()=>{R(),M(),A()}}},[b,l,C,c]),g.useEffect(()=>{k(l,{disabled:n,disableDoubleClick:r})},[n,r,l,k]);let T;n&&!x&&(T="not-allowed");let z;if(n)z="disabled";else switch(f){case"active":{z="active";break}default:m?z="focus":z=f}return h.jsx("div",{...a,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":N,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":z,"data-testid":l,id:l,onBlur:()=>v(!1),onFocus:()=>v(!0),ref:_,role:"separator",style:{flexBasis:"auto",cursor:T,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}hM.displayName="Separator";function QV(e){if(!e)return;const t=e.contextUsage,n=e.contextWindowSize;if(!t||!n||n<=0)return;const r=t.inputTokens+(t.cacheReadTokens??0)+(t.cacheCreateTokens??0);if(!(r<=0))return Math.round(r/n*100)}function fM(e,t){const n=$o(),r=e?`session/${e}`:"",i=Ui(r)??eu,s=g.useCallback(d=>{!e||!r||n.setData(r,f=>fI(f??eu,d,e))},[n,r,e]),o=g.useCallback(()=>{e&&s({type:"session:change",sessionId:e})},[s,e]),a=g.useCallback(d=>{e&&s({type:"permission:clear",sessionId:e,requestId:d})},[s,e]),l=g.useCallback(d=>{e&&s({type:"permission:request",sessionId:e,requestId:d.requestId,tool:d.tool,input:d.input,...d.toolUseId?{toolUseId:d.toolUseId}:{}})},[s,e]),c=g.useCallback(d=>{e&&s({type:"session:question:clear",sessionId:e,toolUseId:d})},[s,e]),u=g.useCallback((d,f)=>{e&&s({type:"session:question:submitted",sessionId:e,toolUseId:d,answers:f})},[s,e]);return{...i,reset:o,clearPermission:a,restorePermission:l,clearQuestion:c,markQuestionSubmitted:u}}function ZV(e){return e.kind!=="user-text"?!1:e.meta===void 0||e.meta==="slash-command"||lp(e.meta)}function JV(e,t={}){let n=0;if(t.implicitCloseOnUserText){for(const r of e)ZV(r)&&n++;return n}for(const r of e)r.kind==="turn-end"&&n++;return n}const eq=50;function tq({api:e,sessionId:t,toolSessionId:n,initialTurns:r,implicitCloseOnUserText:i,pageSize:s=eq}){const[o,a]=g.useState({messages:[],total:0,loading:!1,error:null}),l=g.useRef(n),c=g.useRef(null),u=g.useRef(0),d=g.useRef(!0);return g.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),g.useEffect(()=>{const f=l.current;if(l.current=n,!(c.current!==t)&&!(typeof f=="string"&&f!==n))return;if(a({messages:[],total:0,loading:!1,error:null}),!t){c.current=null;return}c.current=t;const v=++u.current;a(w=>({...w,loading:!0,error:null})),(async()=>{let w=[],_=!1,x=r===void 0?{}:{limit:s},b=Number.POSITIVE_INFINITY;for(;;){let S;try{S=await e.historyRead({sessionId:t,...x})}catch(B){if(v!==u.current||!d.current)return;const A=B.message??"history load failed";a(_?R=>({...R,error:A}):{messages:[],total:0,loading:!1,error:A});return}if(v!==u.current||!d.current)return;w=[...S.messages??[],...w];const C=S.total??0,k=typeof S.offset=="number"?S.offset:0,N=k>=b,T=k<=0||N;b=k;const z=r!==void 0&&JV(w,{implicitCloseOnUserText:i})>=r;if(_?a({messages:w,total:C,loading:!1,error:null}):(T||z)&&(_=!0,a({messages:w,total:C,loading:!1,error:null})),T)return;const P=Math.max(0,k-s);x={offset:P,limit:k-P}}})()},[e,t,n,s,r]),o}const nq=["TaskCreate","TaskUpdate","TaskList","TaskGet"];function rq(e){return nq.includes(e)}function pM(e){return e==="in_progress"||e==="completed"?e:"pending"}function iq(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:pM(n.status),activeForm:i,description:s}]}function sq(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=pM(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 oq(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=iq(t,i.input);break;case"TaskUpdate":t=sq(t,i.input);break}}return{tasks:t,lastEventIndex:n}}function aq(e){return e==="TodoWrite"}function lq(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 cq(e,t,n){var s;const r=[],i=new Map;for(let o=0;o<e.length;o++){const a=e[o],l=typeof a.seq=="number"?a.seq:o;switch(a.kind){case"session_init":r.push({kind:"session-init",seq:l,toolSessionId:a.toolSessionId});break;case"text":KS(r,l,"assistant-text",a.text,a.partialId,a.uuid);break;case"thinking":KS(r,l,"assistant-thinking",a.text,a.partialId);break;case"user_text":{a.meta==="task-notification"?r.push({kind:"agent-notification",seq:l,text:a.text,taskId:a.taskId,parentToolUseId:a.parentToolUseId}):a.meta?r.push({kind:"user-meta",seq:l,metaKind:a.meta,text:a.text}):r.push({kind:"user-text",seq:l,text:a.text,uuid:a.uuid,...a.sender&&(a.sender.principal!=="owner"||oI.test(a.text))?{senderDisplayName:a.sender.displayName}:{},senderPrincipal:((s=a.sender)==null?void 0:s.principal)==="guest"?"guest":"owner"});break}case"tool_call":mM(r,l,a.toolUseId,a.tool,a.input,a.toolKind);break;case"tool_result":{const c=i.get(a.toolUseId);if(c!==void 0){if(a.askQuestionAnswers){const d=r[c];d.submittedAnswers=a.askQuestionAnswers}i.delete(a.toolUseId);break}const u={kind:"tool-result",seq:l,toolUseId:a.toolUseId,output:a.output,error:a.error};a.toolResultExtra&&(u.toolResultExtra=a.toolResultExtra),r.push(u);break}case"attachment_memories":r.push({kind:"memory-callout",seq:l,memories:a.memories});break;case"permission_request":{if(!t||a.requestId!==t)break;r.push({kind:"permission-inline",seq:l,requestId:a.requestId,tool:a.tool,input:a.input});break}case"ask_user_question":i.set(a.toolUseId,r.length),r.push({kind:"question-card",seq:l,toolUseId:a.toolUseId,questions:a.questions});break;case"turn_end":{const c={kind:"turn-end",seq:l};a.durationMs!==void 0&&(c.durationMs=a.durationMs),a.reason!==void 0&&(c.reason=a.reason),r.push(c);break}case"subagent_progress":{const c={kind:"agent-progress",seq:l,toolUseId:a.toolUseId,agentId:a.agentId,status:a.status};a.description&&(c.description=a.description),a.lastToolName&&(c.lastToolName=a.lastToolName),a.prompt&&(c.prompt=a.prompt),a.stats&&(c.stats=a.stats),r.push(c);break}case"error":r.push({kind:"error",seq:l,message:a.message});break}}return r}function mM(e,t,n,r,i,s){if(aq(r)){const o=lq(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(rq(r)){e.push({kind:"task-event",seq:t,toolUseId:n,name:r,input:i});return}e.push({kind:"tool-call",seq:t,toolUseId:n,tool:r,toolKind:s,input:i})}function KS(e,t,n,r,i,s){let o=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind===n){o=c;break}const a=o>=0?e[o]:null;if(i){if(a&&a.partialId===i){const u=n==="assistant-text"?{kind:n,seq:a.seq,text:a.text+r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:a.text+r,partialId:i};e[o]=u;return}const c=n==="assistant-text"?{kind:n,seq:t,text:r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r,partialId:i};e.push(c);return}if(a&&a.partialId){const c=n==="assistant-text"?{kind:n,seq:a.seq,text:r,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:r};e[o]=c;return}const l=n==="assistant-text"?{kind:n,seq:t,text:r,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r};e.push(l)}const uq="AskUserQuestion";function gM(e,t=0,n){var o;const r=[],i=new Map;let s=t;for(const a of e){const l=s++,c=a.toolUseId??`hist-${l}`;switch(a.kind){case"user-text":if(a.meta==="task-notification")r.push({kind:"agent-notification",seq:l,text:a.text??"",taskId:a.taskId,parentToolUseId:a.parentToolUseId});else if(a.meta)r.push({kind:"user-meta",seq:l,metaKind:a.meta,text:a.text??""});else{const u=oI.exec(a.text??""),d=(o=Sz.exec(a.text??""))==null?void 0:o[1],f=(u==null?void 0:u[2])??d,p=(u==null?void 0:u[1])==="guest"||d?"guest":"owner";r.push({kind:"user-text",seq:l,text:a.text??"",uuid:a.uuid,...f?{senderDisplayName:f}:{},senderPrincipal:p})}break;case"assistant-text":r.push({kind:"assistant-text",seq:l,text:a.text??"",uuid:a.uuid});break;case"tool_call":{if(a.tool===uq){const u=a.input??{},d=Array.isArray(u.questions)?u.questions:[];i.set(c,r.length),r.push({kind:"question-card",seq:l,toolUseId:c,questions:d});break}mM(r,l,c,a.tool??"",a.input,n);break}case"tool_result":{const u=i.get(c);if(u!==void 0){if(a.askQuestionAnswers){const f=r[u];f.submittedAnswers=a.askQuestionAnswers}i.delete(c);break}const d={kind:"tool-result",seq:l,toolUseId:c,output:a.output};a.error!==void 0&&(d.error=a.error),a.toolResultExtra&&(d.toolResultExtra=a.toolResultExtra),r.push(d);break}case"attachment_memories":a.memories&&a.memories.length>0&&r.push({kind:"memory-callout",seq:l,memories:a.memories});break;case"summary":break;case"turn-end":{const u={kind:"turn-end",seq:l};typeof a.durationMs=="number"&&(u.durationMs=a.durationMs),r.push(u);break}}}return r}const dq=5e5;function hq(e){const t=dq-e.length;return e.map(n=>({...n,seq:n.seq+t}))}const fq=/<command-name>([\s\S]*?)<\/command-name>/i,pq=/<command-message>([\s\S]*?)<\/command-message>/i,mq=/<command-args>([\s\S]*?)<\/command-args>/i,gq=/<(local-command-[a-z]+|command-(?:stdout|stderr))>[\s\S]*?<\/\1>/gi;function Np(e){if(!e)return{commandName:null,commandMessage:null,commandArgs:null,body:""};const t=e.match(fq),n=e.match(pq),r=e.match(mq);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(gq,""),i=i.trim(),{commandName:t?t[1].trim():null,commandMessage:n?n[1].trim():null,commandArgs:r?r[1].trim():null,body:i}}function GS(e){const t=Np(e);return t.commandName?t.commandArgs?`${t.commandName} ${t.commandArgs}`:t.commandName:e}function YS(e){return e.kind==="user-text"?!0:e.kind!=="user-meta"?!1:e.metaKind==="slash-command"||lp(e.metaKind)}function vq(e,t){const n=t.find(YS);if(!n)return e;const r=GS(n.text);for(let s=e.length-1;s>=0;s--){const o=e[s];if(YS(o)&&GS(o.text)===r)return e.slice(0,s)}const i=e[e.length-1];return i!==void 0&&i.kind!=="turn-end"?[...e,{kind:"turn-end",seq:i.seq+1}]:e}function _q(e){return e==="running"||e==="observing"}function vM(e){return e==="running"||e==="running-idle"||e==="observing"}const xq=1e6,yq=5;function _M(e){const t=Yi(),n=g.useMemo(()=>new Gx(t),[t]),r=Ui("sessions"),i=g.useMemo(()=>r==null?void 0:r.find(E=>E.sessionId===e),[r,e]),s=i==null?void 0:i.toolSessionId,o=i==null?void 0:i.tool,a=fM(e),{events:l,pendingPermissions:c,queued:u,status:d,clearPermission:f,restorePermission:p}=a,m=t$(),v=tq({api:n,sessionId:e,toolSessionId:s,initialTurns:m==="owner"?void 0:yq,implicitCloseOnUserText:o==="codex"}),w=g.useMemo(()=>v.messages.filter(E=>!E.isSidechain),[v.messages]),_=g.useMemo(()=>hq(gM(w,0,o)),[w,o]),x=c[0]??null,b=g.useMemo(()=>cq(l,(x==null?void 0:x.requestId)??null),[l,x==null?void 0:x.requestId]),S=g.useMemo(()=>vq(_,b),[_,b]),C=g.useMemo(()=>b.map((E,H)=>({...E,seq:xq+H})),[b]),k=g.useMemo(()=>[...S,...C],[S,C]),N=vM(d),T=_q(d),z=(i==null?void 0:i.resolvedModel)??(i==null?void 0:i.model),P=g.useMemo(()=>({sessionLabel:(i==null?void 0:i.label)||(i==null?void 0:i.aiLabel)||(i==null?void 0:i.larkChatName)||(i==null?void 0:i.larkChatId)||e,sessionId:e,...i!=null&&i.larkChatId?{larkChatName:i.larkChatName??i.larkChatId,larkChatType:i.larkChatType??"group"}:{},...z?{model:z}:{},...(()=>{const E=i==null?void 0:i.gitBranch;return E?{gitBranch:E}:{}})(),...(()=>{const E=QV(i);return E!==void 0?{contextPct:E}:{}})(),...i!=null&&i.cwd?{cwd:i.cwd}:{},...(()=>{const E=i==null?void 0:i.permissionMode;return E?{permissionMode:E}:{}})(),procAlive:N,streamInProgress:T,pinnedAt:(i==null?void 0:i.pinnedAt)??null}),[i,e,z,N,T]),B=g.useMemo(()=>t.isOpen?d==="error"?{kind:"error",message:"session error"}:{kind:"ready"}:{kind:"closed"},[t.isOpen,d]),A=g.useCallback(async(E,H)=>{await n.sessionSend(e,E,H)},[n,e]),R=g.useCallback(async E=>{await n.sessionDequeue(e,E)},[n,e]),M=g.useCallback(async()=>(await n.sessionInterrupt(e)).queued??[],[n,e]),D=g.useCallback(async E=>{if(!(i!=null&&i.cwd)||!s)throw new Error("fork requires sessionFile with cwd + toolSessionId");await n.sessionFork({cwd:i.cwd,toolSessionId:s,messageUuid:E})},[n,i==null?void 0:i.cwd,s]),$=g.useCallback(async E=>{await n.sessionRewind({sessionId:e,userMessageId:E,dryRun:!1})},[n,e]),F=g.useCallback(async E=>{await n.sessionUpdate(e,{model:E})},[n,e]),j=g.useCallback(async()=>{await n.sessionNew(e)},[n,e]),O=g.useCallback(async(E,H)=>{const q=c.find(L=>L.requestId===E);q&&f(E);try{await n.permissionRespond({sessionId:e,permissionRequestId:E,allow:H==="allow"})}catch(L){throw!((L==null?void 0:L.message)??"").startsWith("PERMISSION_REQUEST_STALE")&&q&&p(q),L}},[n,e,c,f,p]);return g.useMemo(()=>({lines:k,connState:B,meta:P,historyLoading:v.loading,historyError:v.error,pendingPermissions:c,queued:u,sendText:A,dequeue:R,interrupt:M,fork:D,rewind:$,switchModel:F,clearSession:j,respondPermission:O}),[k,B,P,v.loading,v.error,c,u,A,R,M,D,$,F,j,O])}const bq={codex:"on-request",claude:"bypassPermissions",pi:"never"};function wq(e){const t={cwd:e.cwd,permissionMode:e.sourcePermissionMode??bq[e.sourceTool??"claude"]??"bypassPermissions",forkedFromSessionId:e.sourceSessionId};return e.sourceOwnerPersonaId&&(t.ownerPersonaId=e.sourceOwnerPersonaId),e.sourceTool&&(t.tool=e.sourceTool),e.sourceProjectPath&&(t.projectPath=e.sourceProjectPath),t}async function Sq(e,t,n,r={}){if(!t.toolSessionId)return null;const i=await e.sessionCreate({...wq({cwd:t.cwd,sourceSessionId:t.sessionId,sourcePermissionMode:t.permissionMode,sourceOwnerPersonaId:t.ownerPersonaId,sourceTool:t.tool,sourceProjectPath:t.projectPath}),...r.ephemeral?{ephemeral:!0}:{}});try{const{forkedToolSessionId:s}=await e.sessionFork({cwd:t.cwd,toolSessionId:t.toolSessionId,messageUuid:n,targetCwd:i.cwd});await e.sessionResume(i.sessionId,s)}catch(s){throw e.sessionDelete(i.sessionId).catch(o=>Me("quick-ask","fork rollback failed",o)),s}return i}async function kq(e,t,n){return Sq(e,t,n,{ephemeral:!0})}function Cd(e){return e!=null&&e.ephemeral!==!1}async function Cq(e,t){return t.stillEphemeral?(await e.sessionUpdate(t.sessionId,{ephemeral:!1}),!0):!1}function Eq(e){try{const t=new URL(e);return t.protocol==="ws:"?t.protocol="http:":t.protocol==="wss:"&&(t.protocol="https:"),`${t.protocol}//${t.host}`}catch{return e}}function Nq(e,t){try{const n=new URL(e),r=new URL(t);return n.protocol=r.protocol,n.host=r.host,n.toString()}catch{return e}}async function zy(e,t,n,r,i){const s=await e.attachmentSignUrl({sessionId:n,relPath:r,...i!==void 0?{ttlSeconds:i}:{}});return Nq(s.url,Eq(t.url))}async function XS(e,t,n,r,i=60,s){const o=window.open("about:blank","_blank");try{s&&await s();const a=await zy(e,t,n,r,i);o?o.location.href=a:window.open(a,"_blank")}catch(a){throw o&&o.close(),a}}async function Tq(e){var t;try{if((t=navigator.clipboard)!=null&&t.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.setAttribute("readonly",""),document.body.appendChild(n),n.select();const r=document.execCommand("copy");return document.body.removeChild(n),r}catch{return!1}}const Iq=300;function Pq(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function Rq(e,t){const n=Cx(),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>{let a=!1;return(async()=>{try{const l=await n.kv.get(e);if(a)return;const c=Pq(l);typeof c=="number"&&Number.isFinite(c)&&c>0?i(c):i(t)}catch{a||i(t)}})(),()=>{a=!0}},[n,e,t]);const o=g.useCallback(a=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{s.current=null,n.kv.set(e,a).catch(()=>{})},Iq)},[n,e]);return g.useEffect(()=>()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),{initialSize:r??t,setSize:o,loading:r===null}}function Mq(){return{quickAsk:null,mds:[],active:null}}function Aq(e,t){return{...e,quickAsk:{sessionId:t.sessionId,ephemeral:!0},active:"quick-ask"}}function Lq(e,t){const n=e.mds.includes(t);return{...e,mds:n?e.mds:[...e.mds,t],active:{kind:"md",relPath:t}}}function Dq(e){if(!e.quickAsk)return e;const t=e.active==="quick-ask",n=e.mds[0],r=t?n?{kind:"md",relPath:n}:null:e.active;return{...e,quickAsk:null,active:r}}function jq(e){return e.quickAsk?{...e,quickAsk:{...e.quickAsk,ephemeral:!1}}:e}function Oq(e,t){const n=e.mds.indexOf(t);if(n<0)return e;const r=e.mds.filter(l=>l!==t);if(!(e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===t))return{...e,mds:r};const s=r[n],o=n>0?r[n-1]:void 0;let a=null;return s?a={kind:"md",relPath:s}:o?a={kind:"md",relPath:o}:e.quickAsk&&(a="quick-ask"),{...e,mds:r,active:a}}function Bq(e,t){return{...e,active:t}}function zq(e,t){return e===null||t===null||e==="quick-ask"||t==="quick-ask"?e===t:e.relPath===t.relPath}function xM(e){return e.quickAsk!==null||e.mds.length>0}function $q(e,t,n,r=!0){const i=g.useRef({sid:null,tsid:void 0});g.useEffect(()=>{const s=i.current;i.current={sid:t,tsid:n},!(!r||!n||s.sid===t&&(s.tsid===void 0||s.tsid===null)&&typeof n=="string")&&e.sessionObserve({sessionId:t,toolSessionId:n}).catch(()=>{})},[e,t,n,r])}function Fq(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 Hq=/^Scheduled (?:recurring job|one-shot task) ([0-9a-f]{8}) \(([^)]+)\)/;function Uq(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(Hq);if(!a)continue;r.set(a[1],{id:a[1],cron:s.cron,prompt:s.prompt,recurring:s.recurring,humanSchedule:a[2],createdAt:s.ts,toolUseId:s.toolUseId});continue}const o=n.get(i.toolUseId);o!==void 0&&(n.delete(i.toolUseId),i.error||r.delete(o))}return Array.from(r.values()).sort((i,s)=>i.createdAt.localeCompare(s.createdAt))}function yM(e){var n;if(e.error)return!1;if(e.pending)return!0;if(e.notifications.length>0)return!1;const t=(n=e.progress)==null?void 0:n.status;return t==="running"?!0:t==="started"?Wq(e.input):!1}function Wq(e){return!e||typeof e!="object"?!1:e.run_in_background===!0}function Vq(e){return e.filter(t=>t.kind==="merged-agent"&&yM(t))}function bM(e){var d;const{tasks:t,lastEventIndex:n}=oq(e);let r=-1;for(let f=e.length-1;f>=0;f--)if(e[f].kind==="todo-checklist"){r=f;break}const i=[],s=new Map,o=new Map,a=new Map,l=new Map,c=new Map,u=(f,p)=>{var x,b,S,C,k,N;const m=i[f],v=c.get(f),w=v!==void 0&&v!==p.toolUseId;if(!w&&(((x=m.progress)==null?void 0:x.status)==="completed"||((b=m.progress)==null?void 0:b.status)==="failed"))return;if(c.set(f,p.toolUseId),l.set(p.agentId,f),w&&(m.pending=!0,(S=m.toolResultExtra)!=null&&S.stats)){const{stats:T,...z}=m.toolResultExtra;m.toolResultExtra=z}const _={agentId:p.agentId,status:p.status};p.description?_.description=p.description:(C=m.progress)!=null&&C.description&&(_.description=m.progress.description),p.lastToolName?_.lastToolName=p.lastToolName:!w&&((k=m.progress)!=null&&k.lastToolName)&&(_.lastToolName=m.progress.lastToolName),p.stats?_.stats=p.stats:!w&&((N=m.progress)!=null&&N.stats)&&(_.stats=m.progress.stats),m.progress=_,(p.status==="completed"||p.status==="failed")&&(m.pending=!1)};for(let f=0;f<e.length;f++){const p=e[f];switch(p.kind){case"tool-call":{const m={kind:"merged-tool",seq:p.seq,tool:p.tool,toolKind:p.toolKind,toolUseId:p.toolUseId,input:p.input,pending:!0};s.set(p.toolUseId,i.length),i.push(m);break}case"tool-result":{const m=s.get(p.toolUseId);if(m!==void 0){const w=i[m];w.output=p.output,w.error=p.error,w.pending=!1,s.delete(p.toolUseId);break}const v=o.get(p.toolUseId);if(v!==void 0){const w=i[v];w.output=p.output,w.error=p.error,w.pending=!1,p.toolResultExtra&&(w.toolResultExtra=p.toolResultExtra),(d=p.toolResultExtra)!=null&&d.agentId&&(l.set(p.toolResultExtra.agentId,v),c.set(v,p.toolUseId));break}break}case"agent-call":{const m={kind:"merged-agent",seq:p.seq,toolUseId:p.toolUseId,description:p.description,input:p.input,pending:!0,notifications:[]},v=i.length;o.set(p.toolUseId,v),i.push(m);const w=a.get(p.toolUseId);w&&(u(v,w),a.delete(p.toolUseId));break}case"agent-progress":{const m=o.get(p.toolUseId)??l.get(p.agentId);if(m!==void 0){u(m,p);break}const v=a.get(p.toolUseId);if((v==null?void 0:v.status)==="completed"||(v==null?void 0:v.status)==="failed")break;a.set(p.toolUseId,p);break}case"agent-notification":{const m=(p.parentToolUseId?o.get(p.parentToolUseId):void 0)??(p.taskId?l.get(p.taskId):void 0);if(m!==void 0){i[m].notifications.push({text:p.text,taskId:p.taskId});break}i.push({kind:"agent-notification",seq:p.seq,text:p.text,taskId:p.taskId,parentToolUseId:p.parentToolUseId});break}case"todo-checklist":{f===r&&p.todos.length>0&&i.push({kind:"todo-checklist",seq:p.seq,toolUseId:p.toolUseId,todos:p.todos});break}case"task-event":{f===n&&t.length>0&&i.push({kind:"plan-card",seq:p.seq,tasks:t});break}default:i.push(p)}}return i}const qq=new Set(["permission-inline","question-card"]);function Kq(e){return e.kind==="user-text"?!0:e.kind!=="user-meta"?!1:e.metaKind==="slash-command"||lp(e.metaKind)}function Gq(e){return e.kind==="user-text"&&e.continuesTurn===!0}function Yq(e,t={}){const n=[];let r=null;const i=(s,o)=>{r&&(n.push(Xq(r,s,o)),r=null)};for(const s of e){if(s.kind==="turn-end"){i(s,!0);continue}if(Kq(s)&&(r===null||!Gq(s))){i(void 0,!0),r={query:s,body:[]};continue}r===null?r={body:[s]}:r.body.push(s)}return i(void 0,t.closeTrailing===!0),n}function Xq(e,t,n){const{query:r,body:i}=e,s=Qq(i,t,n),o=Zq(i,s),a=eK(i,o),l=r??i[0]??t,c={kind:"turn",seq:l?l.seq:0,status:s,process:a,tail:o};return r&&(c.query=r),(t==null?void 0:t.durationMs)!==void 0&&(c.durationMs=t.durationMs),c}function Qq(e,t,n){if(!n)return"running";if((t==null?void 0:t.reason)==="interrupted")return"interrupted";const r=T0(e,i=>i.kind==="error");return r>=0&&!e.slice(r+1).some(s=>s.kind==="assistant-text")?"error":"done"}function Zq(e,t){if(t==="running"){const r=[];for(let i=e.length-1;i>=0&&qq.has(e[i].kind);i--)r.unshift(e[i]);return r}const n=t==="error"?T0(e,r=>r.kind==="error"):T0(e,r=>r.kind==="assistant-text");return n>=0?[e[n]]:[]}const Jq=new Set(["assistant-thinking","user-meta"]);function eK(e,t){const n=new Set(t),r=[];let i=null;const s=()=>{i&&(r.push({kind:"tool-group",seq:i[0].seq,items:i}),i=null)};for(const o of e){if(n.has(o)){s();continue}if(o.kind==="merged-tool"){i?i.push(o):i=[o];continue}if(Jq.has(o.kind)){r.push(o);continue}s(),r.push(o)}return s(),r}function T0(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}const tK={Read:["正在读取","已读取"],Bash:["正在运行","已运行"],Grep:["正在搜索","已搜索"],Glob:["正在搜索","已搜索"],Edit:["正在编辑","已编辑"],Write:["正在写入","已写入"],WebFetch:["正在抓取","已抓取"],WebSearch:["正在搜索","已搜索"],Skill:["正在读取","已读取"]};function nK(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 wM(e){const t=tK[e.tool],n=t?e.pending?t[0]:t[1]:e.pending?`正在执行 ${e.tool}`:`已执行 ${e.tool}`,r=nK(e.input);return r?`${n} ${r}`:n}function rK({item:e,renderItemDetail:t}){const[n,r]=g.useState(!1),i=n?Yn:Bn,s=n?(t==null?void 0:t(e))??null:null;return h.jsxs("div",{className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>r(o=>!o),"aria-expanded":n,"data-testid":"tool-call-group-row",className:ne("flex w-full items-center gap-1.5 text-left cursor-pointer min-w-0 py-0.5 text-[13px] hover:text-text-200",e.error?"text-destructive/80":"text-text-400"),children:[e.pending?h.jsx(cr,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):h.jsx(i,{className:"w-3.5 h-3.5 shrink-0 opacity-60"}),h.jsx("span",{className:"truncate min-w-0",children:wM(e)})]}),n?h.jsx("div",{"data-testid":"tool-call-group-row-detail",className:"pl-5 py-1 min-w-0 space-y-1.5 text-[12px] text-text-300",children:s!==null?s:h.jsxs(h.Fragment,{children:[h.jsx("pre",{className:"min-w-0 max-w-full overflow-auto whitespace-pre-wrap font-mono",children:JSON.stringify(e.input,null,2)}),e.output!==void 0?h.jsx("pre",{className:"min-w-0 max-w-full overflow-auto whitespace-pre-wrap font-mono text-text-400",children:typeof e.output=="string"?e.output:JSON.stringify(e.output,null,2)}):null,e.error?h.jsx("pre",{className:"min-w-0 max-w-full overflow-auto whitespace-pre-wrap font-mono text-destructive",children:e.error}):null]})}):null]})}function iK({items:e,renderItemDetail:t}){const[n,r]=g.useState(!1);if(e.length===0)return null;const i=e.some(l=>l.pending),s=i?[...e].reverse().find(l=>l.pending):e[e.length-1],o=!i&&e.length>1?` 等 ${e.length} 项`:"",a=n?Yn:Bn;return h.jsxs("div",{"data-testid":"tool-call-group",className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>r(l=>!l),"aria-expanded":n,"data-testid":"tool-call-group-header",className:"flex w-full items-center gap-1.5 text-left cursor-pointer min-w-0 py-0.5 text-[13px] text-text-400 hover:text-text-200",children:[i&&!n?h.jsx(cr,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):h.jsx(a,{className:"w-3.5 h-3.5 shrink-0"}),n?h.jsx("span",{className:"min-w-0 truncate opacity-70",children:i?"正在执行":`${e.length} 项`}):h.jsxs("span",{className:ne("truncate min-w-0",i&&"text-text-300"),children:[wM(s),o]})]}),n?h.jsx("div",{className:"mt-0.5 flex flex-col pl-5",children:e.map(l=>h.jsx(rK,{item:l,renderItemDetail:t},l.toolUseId))}):null]})}function sK(e){const t=Math.round(e/1e3);if(t<60)return`${t}秒`;const n=Math.floor(t/60),r=t%60;return r>0?`${n}分${r}秒`:`${n}分钟`}function oK(e,t){const n=t!==void 0?`耗时 ${sK(t)}`:"";switch(e){case"interrupted":return n?`已中断 · ${n}`:"已中断";case"error":return n?`出错 · ${n}`:"出错";default:return n||"已完成"}}function aK({status:e="done",durationMs:t,defaultExpanded:n=!1,children:r}){const[i,s]=g.useState(n),o=i?Yn:Bn;return h.jsxs("div",{"data-testid":"turn-process-block",className:"min-w-0 max-w-full border-t border-border pt-2",children:[h.jsxs("button",{type:"button",onClick:()=>s(a=>!a),"aria-expanded":i,"data-testid":"turn-process-block-header",className:ne("flex w-full items-center gap-1 text-left cursor-pointer min-w-0 py-0.5 text-[13px]",e!=="done"?"text-destructive/80 hover:text-destructive":"text-text-400 hover:text-text-200"),children:[h.jsx("span",{className:"truncate min-w-0",children:oK(e,t)}),h.jsx(o,{className:"w-3.5 h-3.5 shrink-0"})]}),i?h.jsx("div",{"data-testid":"turn-process-body",className:"mt-2 flex flex-col gap-2 border-l-2 border-border pl-3",children:r}):null]})}const lK=/<(system-reminder|related-dir|clawd-shift-fire)\b[^>]*>[\s\S]*?<\/\1>/gi,cK=/<builder-preview\b[^>]*\/>/gi,uK=/<(clawd-dispatch-task|clawd-dispatch-result)\b[^>]*>([\s\S]*?)<\/\1>/gi,dK=/<\/?(brief|detail|files)>/gi;function SM(e){return e?e.replace(uK,(t,n,r)=>Rz(r.replace(dK,"")).trim()).replace(lK,"").replace(cK,"").trim():""}const hK=SM;function fK(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const pK=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,mK=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,gK={};function QS(e,t){return(gK.jsx?mK:pK).test(e)}const vK=/[ \t\n\f\r]/g;function _K(e){return typeof e=="object"?e.type==="text"?ZS(e.value):!1:ZS(e)}function ZS(e){return e.replace(vK,"")===""}class Ru{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Ru.prototype.normal={};Ru.prototype.property={};Ru.prototype.space=void 0;function kM(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Ru(n,r,t)}function I0(e){return e.toLowerCase()}class Xn{constructor(t,n){this.attribute=n,this.property=t}}Xn.prototype.attribute="";Xn.prototype.booleanish=!1;Xn.prototype.boolean=!1;Xn.prototype.commaOrSpaceSeparated=!1;Xn.prototype.commaSeparated=!1;Xn.prototype.defined=!1;Xn.prototype.mustUseProperty=!1;Xn.prototype.number=!1;Xn.prototype.overloadedBoolean=!1;Xn.prototype.property="";Xn.prototype.spaceSeparated=!1;Xn.prototype.space=void 0;let xK=0;const De=Ko(),Bt=Ko(),P0=Ko(),Q=Ko(),ut=Ko(),Oa=Ko(),er=Ko();function Ko(){return 2**++xK}const R0=Object.freeze(Object.defineProperty({__proto__:null,boolean:De,booleanish:Bt,commaOrSpaceSeparated:er,commaSeparated:Oa,number:Q,overloadedBoolean:P0,spaceSeparated:ut},Symbol.toStringTag,{value:"Module"})),Um=Object.keys(R0);class $y extends Xn{constructor(t,n,r,i){let s=-1;if(super(t,n),JS(this,"space",i),typeof r=="number")for(;++s<Um.length;){const o=Um[s];JS(this,Um[s],(r&R0[o])===R0[o])}}}$y.prototype.defined=!0;function JS(e,t,n){n&&(e[t]=n)}function wl(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new $y(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[I0(r)]=r,n[I0(s.attribute)]=r}return new Ru(t,n,e.space)}const CM=wl({properties:{ariaActiveDescendant:null,ariaAtomic:Bt,ariaAutoComplete:null,ariaBusy:Bt,ariaChecked:Bt,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:ut,ariaCurrent:null,ariaDescribedBy:ut,ariaDetails:null,ariaDisabled:Bt,ariaDropEffect:ut,ariaErrorMessage:null,ariaExpanded:Bt,ariaFlowTo:ut,ariaGrabbed:Bt,ariaHasPopup:null,ariaHidden:Bt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ut,ariaLevel:Q,ariaLive:null,ariaModal:Bt,ariaMultiLine:Bt,ariaMultiSelectable:Bt,ariaOrientation:null,ariaOwns:ut,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:Bt,ariaReadOnly:Bt,ariaRelevant:null,ariaRequired:Bt,ariaRoleDescription:ut,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:Bt,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function EM(e,t){return t in e?e[t]:t}function NM(e,t){return EM(e,t.toLowerCase())}const yK=wl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Oa,acceptCharset:ut,accessKey:ut,action:null,allow:null,allowFullScreen:De,allowPaymentRequest:De,allowUserMedia:De,alt:null,as:null,async:De,autoCapitalize:null,autoComplete:ut,autoFocus:De,autoPlay:De,blocking:ut,capture:null,charSet:null,checked:De,cite:null,className:ut,cols:Q,colSpan:null,content:null,contentEditable:Bt,controls:De,controlsList:ut,coords:Q|Oa,crossOrigin:null,data:null,dateTime:null,decoding:null,default:De,defer:De,dir:null,dirName:null,disabled:De,download:P0,draggable:Bt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:De,formTarget:null,headers:ut,height:Q,hidden:P0,high:Q,href:null,hrefLang:null,htmlFor:ut,httpEquiv:ut,id:null,imageSizes:null,imageSrcSet:null,inert:De,inputMode:null,integrity:null,is:null,isMap:De,itemId:null,itemProp:ut,itemRef:ut,itemScope:De,itemType:ut,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:De,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:De,muted:De,name:null,nonce:null,noModule:De,noValidate:De,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:De,optimum:Q,pattern:null,ping:ut,placeholder:null,playsInline:De,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:De,referrerPolicy:null,rel:ut,required:De,reversed:De,rows:Q,rowSpan:Q,sandbox:ut,scope:null,scoped:De,seamless:De,selected:De,shadowRootClonable:De,shadowRootDelegatesFocus:De,shadowRootMode:null,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:Bt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:De,useMap:null,value:Bt,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ut,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:De,declare:De,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:De,noHref:De,noShade:De,noWrap:De,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:Bt,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:De,disableRemotePlayback:De,prefix:null,property:null,results:Q,security:null,unselectable:null},space:"html",transform:NM}),bK=wl({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:er,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:ut,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:De,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Oa,g2:Oa,glyphName:Oa,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:er,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ut,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:er,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:er,rev:er,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:er,requiredFeatures:er,requiredFonts:er,requiredFormats:er,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:er,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:er,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:er,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:EM}),TM=wl({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()}}),IM=wl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:NM}),PM=wl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),wK={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"},SK=/[A-Z]/g,ek=/-[a-z]/g,kK=/^data[-\w.:]+$/i;function CK(e,t){const n=I0(t);let r=t,i=Xn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&kK.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(ek,NK);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!ek.test(s)){let o=s.replace(SK,EK);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=$y}return new i(r,t)}function EK(e){return"-"+e.toLowerCase()}function NK(e){return e.charAt(1).toUpperCase()}const TK=kM([CM,yK,TM,IM,PM],"html"),Fy=kM([CM,bK,TM,IM,PM],"svg");function IK(e){return e.join(" ").trim()}var Hy={},tk=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,PK=/\n/g,RK=/^\s*/,MK=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,AK=/^:\s*/,LK=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,DK=/^[;\s]*/,jK=/^\s+|\s+$/g,OK=`
|
|
512
|
-
`,nk="/",rk="*",uo="",BK="comment",zK="declaration";function $K(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(PK);v&&(n+=v.length);var w=m.lastIndexOf(OK);r=~w?m.length-w:r+m.length}function s(){var m={line:n,column:r};return function(v){return v.position=new o(m),c(),v}}function o(m){this.start=m,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function a(m){var v=new Error(t.source+":"+n+":"+r+": "+m);if(v.reason=m,v.filename=t.source,v.line=n,v.column=r,v.source=e,!t.silent)throw v}function l(m){var v=m.exec(e);if(v){var w=v[0];return i(w),e=e.slice(w.length),v}}function c(){l(RK)}function u(m){var v;for(m=m||[];v=d();)v!==!1&&m.push(v);return m}function d(){var m=s();if(!(nk!=e.charAt(0)||rk!=e.charAt(1))){for(var v=2;uo!=e.charAt(v)&&(rk!=e.charAt(v)||nk!=e.charAt(v+1));)++v;if(v+=2,uo===e.charAt(v-1))return a("End of comment missing");var w=e.slice(2,v-2);return r+=2,i(w),e=e.slice(v),r+=2,m({type:BK,comment:w})}}function f(){var m=s(),v=l(MK);if(v){if(d(),!l(AK))return a("property missing ':'");var w=l(LK),_=m({type:zK,property:ik(v[0].replace(tk,uo)),value:w?ik(w[0].replace(tk,uo)):uo});return l(DK),_}}function p(){var m=[];u(m);for(var v;v=f();)v!==!1&&(m.push(v),u(m));return m}return c(),p()}function ik(e){return e?e.replace(jK,uo):uo}var FK=$K,HK=mh&&mh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Hy,"__esModule",{value:!0});Hy.default=WK;const UK=HK(FK);function WK(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,UK.default)(e),i=typeof t=="function";return r.forEach(s=>{if(s.type!=="declaration")return;const{property:o,value:a}=s;i?t(o,a,s):a&&(n=n||{},n[o]=a)}),n}var Tp={};Object.defineProperty(Tp,"__esModule",{value:!0});Tp.camelCase=void 0;var VK=/^--[a-zA-Z0-9_-]+$/,qK=/-([a-z])/g,KK=/^[^-]+$/,GK=/^-(webkit|moz|ms|o|khtml)-/,YK=/^-(ms)-/,XK=function(e){return!e||KK.test(e)||VK.test(e)},QK=function(e,t){return t.toUpperCase()},sk=function(e,t){return"".concat(t,"-")},ZK=function(e,t){return t===void 0&&(t={}),XK(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(YK,sk):e=e.replace(GK,sk),e.replace(qK,QK))};Tp.camelCase=ZK;var JK=mh&&mh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},eG=JK(Hy),tG=Tp;function M0(e,t){var n={};return!e||typeof e!="string"||(0,eG.default)(e,function(r,i){r&&i&&(n[(0,tG.camelCase)(r,t)]=i)}),n}M0.default=M0;var nG=M0;const rG=fu(nG),RM=MM("end"),Uy=MM("start");function MM(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 iG(e){const t=Uy(e),n=RM(e);if(t&&n)return{start:t,end:n}}function Cc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?ok(e.position):"start"in e||"end"in e?ok(e):"line"in e||"column"in e?A0(e):""}function A0(e){return ak(e&&e.line)+":"+ak(e&&e.column)}function ok(e){return A0(e&&e.start)+"-"+A0(e&&e.end)}function ak(e){return e&&typeof e=="number"?e:1}class Nn extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=Cc(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Nn.prototype.file="";Nn.prototype.name="";Nn.prototype.reason="";Nn.prototype.message="";Nn.prototype.stack="";Nn.prototype.column=void 0;Nn.prototype.line=void 0;Nn.prototype.ancestors=void 0;Nn.prototype.cause=void 0;Nn.prototype.fatal=void 0;Nn.prototype.place=void 0;Nn.prototype.ruleId=void 0;Nn.prototype.source=void 0;const Wy={}.hasOwnProperty,sG=new Map,oG=/[A-Z]/g,aG=new Set(["table","tbody","thead","tfoot","tr"]),lG=new Set(["td","th"]),AM="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function cG(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=vG(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=gG(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"?Fy:TK,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=LM(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function LM(e,t,n){if(t.type==="element")return uG(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return dG(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return fG(e,t,n);if(t.type==="mdxjsEsm")return hG(e,t);if(t.type==="root")return pG(e,t,n);if(t.type==="text")return mG(e,t)}function uG(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Fy,e.schema=i),e.ancestors.push(t);const s=jM(e,t.tagName,!1),o=_G(e,t);let a=qy(e,t);return aG.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!_K(l):!0})),DM(e,o,s,t),Vy(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function dG(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)}au(e,t.position)}function hG(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);au(e,t.position)}function fG(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Fy,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:jM(e,t.name,!0),o=xG(e,t),a=qy(e,t);return DM(e,o,s,t),Vy(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function pG(e,t,n){const r={};return Vy(r,qy(e,t)),e.create(t,e.Fragment,r,n)}function mG(e,t){return t.value}function DM(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Vy(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function gG(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 vG(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=Uy(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 _G(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Wy.call(t.properties,i)){const s=yG(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&lG.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 xG(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 au(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 au(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function qy(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:sG;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=LM(e,s,o);a!==void 0&&n.push(a)}return n}function yG(e,t,n){const r=CK(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?fK(n):IK(n)),r.property==="style"){let i=typeof n=="object"?n:bG(e,String(n));return e.stylePropertyNameCase==="css"&&(i=wG(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?wK[r.property]||r.property:r.attribute,n]}}function bG(e,t){try{return rG(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new Nn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=AM+"#cannot-parse-style-attribute",i}}function jM(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=QS(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=QS(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Wy.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);au(e)}function au(e,t){const n=new Nn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=AM+"#cannot-handle-mdx-estrees-without-createevaluater",n}function wG(e){const t={};let n;for(n in e)Wy.call(e,n)&&(t[SG(n)]=e[n]);return t}function SG(e){let t=e.replace(oG,kG);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function kG(e){return"-"+e.toLowerCase()}const Wm={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"]},CG={};function Ky(e,t){const n=CG,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return OM(e,r,i)}function OM(e,t,n){if(EG(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 lk(e.children,t,n)}return Array.isArray(e)?lk(e,t,n):""}function lk(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=OM(e[i],t,n);return r.join("")}function EG(e){return!!(e&&typeof e=="object")}const ck=document.createElement("i");function Gy(e){const t="&"+e+";";ck.innerHTML=t;const n=ck.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function or(e,t,n,r){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function wr(e,t){return e.length>0?(or(e,e.length,0,t),e):t}const uk={}.hasOwnProperty;function BM(e){const t={};let n=-1;for(;++n<e.length;)NG(t,e[n]);return t}function NG(e,t){let n;for(n in t){const i=(uk.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){uk.call(i,o)||(i[o]=[]);const a=s[o];TG(i[o],Array.isArray(a)?a:a?[a]:[])}}}function TG(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);or(e,0,0,r)}function zM(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 Hr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Mn=Ks(/[A-Za-z]/),kn=Ks(/[\dA-Za-z]/),IG=Ks(/[#-'*+\--9=?A-Z^-~]/);function hf(e){return e!==null&&(e<32||e===127)}const L0=Ks(/\d/),PG=Ks(/[\dA-Fa-f]/),RG=Ks(/[!-/:-@[-`{-~]/);function Se(e){return e!==null&&e<-2}function ct(e){return e!==null&&(e<0||e===32)}function Ue(e){return e===-2||e===-1||e===32}const Ip=Ks(new RegExp("\\p{P}|\\p{S}","u")),Ao=Ks(/\s/);function Ks(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Sl(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&kn(e.charCodeAt(n+1))&&kn(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function Ke(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return Ue(l)?(e.enter(n),a(l)):t(l)}function a(l){return Ue(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const MG={tokenize:AG};function AG(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"),Ke(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 Se(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const LG={tokenize:DG},dk={tokenize:jG};function DG(e){const t=this,n=[];let r=0,i,s,o;return a;function a(b){if(r<n.length){const S=n[r];return t.containerState=S[1],e.attempt(S[0].continuation,l,c)(b)}return c(b)}function l(b){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&x();const S=t.events.length;let C=S,k;for(;C--;)if(t.events[C][0]==="exit"&&t.events[C][1].type==="chunkFlow"){k=t.events[C][1].end;break}_(r);let N=S;for(;N<t.events.length;)t.events[N][1].end={...k},N++;return or(t.events,C+1,0,t.events.slice(S)),t.events.length=N,c(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(dk,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(dk,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){w(e.exit("chunkFlow"),!0),_(0),e.consume(b);return}return Se(b)?(e.consume(b),w(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(b),v)}function w(b,S){const C=t.sliceStream(b);if(S&&C.push(null),b.previous=s,s&&(s.next=b),s=b,i.defineSkip(b.start),i.write(C),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 N=t.events.length;let T=N,z,P;for(;T--;)if(t.events[T][0]==="exit"&&t.events[T][1].type==="chunkFlow"){if(z){P=t.events[T][1].end;break}z=!0}for(_(r),k=N;k<t.events.length;)t.events[k][1].end={...P},k++;or(t.events,T+1,0,t.events.slice(N)),t.events.length=k}}function _(b){let S=n.length;for(;S-- >b;){const C=n[S];t.containerState=C[1],C[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 jG(e,t,n){return Ke(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function el(e){if(e===null||ct(e)||Ao(e))return 1;if(Ip(e))return 2}function Pp(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const D0={name:"attention",resolveAll:OG,tokenize:BG};function OG(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};hk(d,-l),hk(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=wr(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=wr(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),c=wr(c,Pp(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=wr(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=wr(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):u=0,or(e,r-1,n-r+3,c),n=r+c.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function BG(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=el(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=el(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 hk(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const zG={name:"autolink",tokenize:$G};function $G(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 Mn(p)?(e.consume(p),o):p===64?n(p):c(p)}function o(p){return p===43||p===45||p===46||kn(p)?(r=1,a(p)):c(p)}function a(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||kn(p))&&r++<32?(e.consume(p),a):(r=0,c(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||hf(p)?n(p):(e.consume(p),l)}function c(p){return p===64?(e.consume(p),u):IG(p)?(e.consume(p),c):n(p)}function u(p){return kn(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,u):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):f(p)}function f(p){if((p===45||kn(p))&&r++<63){const m=p===45?f:d;return e.consume(p),m}return n(p)}}const Mu={partial:!0,tokenize:FG};function FG(e,t,n){return r;function r(s){return Ue(s)?Ke(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||Se(s)?t(s):n(s)}}const $M={continuation:{tokenize:UG},exit:WG,name:"blockQuote",tokenize:HG};function HG(e,t,n){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return Ue(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function UG(e,t,n){const r=this;return i;function i(o){return Ue(o)?Ke(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt($M,t,n)(o)}}function WG(e){e.exit("blockQuote")}const FM={name:"characterEscape",tokenize:VG};function VG(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 RG(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const HM={name:"characterReference",tokenize:qG};function qG(e,t,n){const r=this;let i=0,s,o;return a;function a(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),l}function l(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),s=31,o=kn,u(d))}function c(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=PG,u):(e.enter("characterReferenceValue"),s=7,o=L0,u(d))}function u(d){if(d===59&&i){const f=e.exit("characterReferenceValue");return o===kn&&!Gy(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 fk={partial:!0,tokenize:GG},pk={concrete:!0,name:"codeFenced",tokenize:KG};function KG(e,t,n){const r=this,i={partial:!0,tokenize:C};let s=0,o=0,a;return l;function l(k){return c(k)}function c(k){const N=r.events[r.events.length-1];return s=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[1],!0).length:0,a=k,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),u(k)}function u(k){return k===a?(o++,e.consume(k),u):o<3?n(k):(e.exit("codeFencedFenceSequence"),Ue(k)?Ke(e,d,"whitespace")(k):d(k))}function d(k){return k===null||Se(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(fk,v,S)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(k))}function f(k){return k===null||Se(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(k)):Ue(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ke(e,p,"whitespace")(k)):k===96&&k===a?n(k):(e.consume(k),f)}function p(k){return k===null||Se(k)?d(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(k))}function m(k){return k===null||Se(k)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(k)):k===96&&k===a?n(k):(e.consume(k),m)}function v(k){return e.attempt(i,S,w)(k)}function w(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),_}function _(k){return s>0&&Ue(k)?Ke(e,x,"linePrefix",s+1)(k):x(k)}function x(k){return k===null||Se(k)?e.check(fk,v,S)(k):(e.enter("codeFlowValue"),b(k))}function b(k){return k===null||Se(k)?(e.exit("codeFlowValue"),x(k)):(e.consume(k),b)}function S(k){return e.exit("codeFenced"),t(k)}function C(k,N,T){let z=0;return P;function P(D){return k.enter("lineEnding"),k.consume(D),k.exit("lineEnding"),B}function B(D){return k.enter("codeFencedFence"),Ue(D)?Ke(k,A,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):A(D)}function A(D){return D===a?(k.enter("codeFencedFenceSequence"),R(D)):T(D)}function R(D){return D===a?(z++,k.consume(D),R):z>=o?(k.exit("codeFencedFenceSequence"),Ue(D)?Ke(k,M,"whitespace")(D):M(D)):T(D)}function M(D){return D===null||Se(D)?(k.exit("codeFencedFence"),N(D)):T(D)}}}function GG(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 Vm={name:"codeIndented",tokenize:XG},YG={partial:!0,tokenize:QG};function XG(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),Ke(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):Se(c)?e.attempt(YG,o,l)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||Se(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),a)}function l(c){return e.exit("codeIndented"),t(c)}}function QG(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):Se(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):Ke(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):Se(o)?i(o):n(o)}}const ZG={name:"codeText",previous:eY,resolve:JG,tokenize:tY};function JG(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 eY(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function tY(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)):Se(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||Se(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 nY{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Ul(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Ul(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Ul(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Ul(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Ul(this.left,n.reverse())}}}function Ul(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function UM(e){const t={};let n=-1,r,i,s,o,a,l,c;const u=new nY(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,rY(u,n)),n=t[n],c=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=u.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(u.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...u.get(i)[1].start},a=u.slice(i,n),a.unshift(r),u.splice(i,n-i+1,a))}}return or(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function rY(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],c={};let u,d,f=-1,p=n,m=0,v=0;const w=[v];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<a.length;)a[f][0]==="exit"&&a[f-1][0]==="enter"&&a[f][1].type===a[f-1][1].type&&a[f][1].start.line!==a[f][1].end.line&&(v=f+1,w.push(v),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):w.pop(),f=w.length;f--;){const _=a.slice(w[f],w[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 iY={resolve:oY,tokenize:aY},sY={partial:!0,tokenize:lY};function oY(e){return UM(e),e}function aY(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):Se(a)?e.check(sY,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 lY(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Ke(e,s,"linePrefix")}function s(o){if(o===null||Se(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 WM(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||hf(_)?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||Se(_)?n(_):(e.consume(_),_===92?m:p)}function m(_){return _===60||_===62||_===92?(e.consume(_),p):p(_)}function v(_){return!u&&(_===null||_===41||ct(_))?(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||hf(_)?n(_):(e.consume(_),_===92?w:v)}function w(_){return _===40||_===41||_===92?(e.consume(_),v):v(_)}}function VM(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):Se(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||Se(p)||a++>999?(e.exit("chunkString"),u(p)):(e.consume(p),l||(l=!Ue(p)),p===92?f:d)}function f(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function qM(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):Se(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Ke(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(f))}function u(f){return f===o||f===null||Se(f)?(e.exit("chunkString"),c(f)):(e.consume(f),f===92?d:u)}function d(f){return f===o||f===92?(e.consume(f),u):u(f)}}function Ec(e,t){let n;return r;function r(i){return Se(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Ue(i)?Ke(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const cY={name:"definition",tokenize:dY},uY={partial:!0,tokenize:hY};function dY(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return VM.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=Hr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return ct(p)?Ec(e,c)(p):c(p)}function c(p){return WM(e,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function u(p){return e.attempt(uY,d,d)(p)}function d(p){return Ue(p)?Ke(e,f,"whitespace")(p):f(p)}function f(p){return p===null||Se(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function hY(e,t,n){return r;function r(a){return ct(a)?Ec(e,i)(a):n(a)}function i(a){return qM(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return Ue(a)?Ke(e,o,"whitespace")(a):o(a)}function o(a){return a===null||Se(a)?t(a):n(a)}}const fY={name:"hardBreakEscape",tokenize:pY};function pY(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return Se(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const mY={name:"headingAtx",resolve:gY,tokenize:vY};function gY(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},or(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function vY(e,t,n){let r=0;return i;function i(u){return e.enter("atxHeading"),s(u)}function s(u){return e.enter("atxHeadingSequence"),o(u)}function o(u){return u===35&&r++<6?(e.consume(u),o):u===null||ct(u)?(e.exit("atxHeadingSequence"),a(u)):n(u)}function a(u){return u===35?(e.enter("atxHeadingSequence"),l(u)):u===null||Se(u)?(e.exit("atxHeading"),t(u)):Ue(u)?Ke(e,a,"whitespace")(u):(e.enter("atxHeadingText"),c(u))}function l(u){return u===35?(e.consume(u),l):(e.exit("atxHeadingSequence"),a(u))}function c(u){return u===null||u===35||ct(u)?(e.exit("atxHeadingText"),a(u)):(e.consume(u),c)}}const _Y=["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"],mk=["pre","script","style","textarea"],xY={concrete:!0,name:"htmlFlow",resolveTo:wY,tokenize:SY},yY={partial:!0,tokenize:CY},bY={partial:!0,tokenize:kY};function wY(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 SY(e,t,n){const r=this;let i,s,o,a,l;return c;function c(L){return u(L)}function u(L){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(L),d}function d(L){return L===33?(e.consume(L),f):L===47?(e.consume(L),s=!0,v):L===63?(e.consume(L),i=3,r.interrupt?t:E):Mn(L)?(e.consume(L),o=String.fromCharCode(L),w):n(L)}function f(L){return L===45?(e.consume(L),i=2,p):L===91?(e.consume(L),i=5,a=0,m):Mn(L)?(e.consume(L),i=4,r.interrupt?t:E):n(L)}function p(L){return L===45?(e.consume(L),r.interrupt?t:E):n(L)}function m(L){const re="CDATA[";return L===re.charCodeAt(a++)?(e.consume(L),a===re.length?r.interrupt?t:A:m):n(L)}function v(L){return Mn(L)?(e.consume(L),o=String.fromCharCode(L),w):n(L)}function w(L){if(L===null||L===47||L===62||ct(L)){const re=L===47,se=o.toLowerCase();return!re&&!s&&mk.includes(se)?(i=1,r.interrupt?t(L):A(L)):_Y.includes(o.toLowerCase())?(i=6,re?(e.consume(L),_):r.interrupt?t(L):A(L)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(L):s?x(L):b(L))}return L===45||kn(L)?(e.consume(L),o+=String.fromCharCode(L),w):n(L)}function _(L){return L===62?(e.consume(L),r.interrupt?t:A):n(L)}function x(L){return Ue(L)?(e.consume(L),x):P(L)}function b(L){return L===47?(e.consume(L),P):L===58||L===95||Mn(L)?(e.consume(L),S):Ue(L)?(e.consume(L),b):P(L)}function S(L){return L===45||L===46||L===58||L===95||kn(L)?(e.consume(L),S):C(L)}function C(L){return L===61?(e.consume(L),k):Ue(L)?(e.consume(L),C):b(L)}function k(L){return L===null||L===60||L===61||L===62||L===96?n(L):L===34||L===39?(e.consume(L),l=L,N):Ue(L)?(e.consume(L),k):T(L)}function N(L){return L===l?(e.consume(L),l=null,z):L===null||Se(L)?n(L):(e.consume(L),N)}function T(L){return L===null||L===34||L===39||L===47||L===60||L===61||L===62||L===96||ct(L)?C(L):(e.consume(L),T)}function z(L){return L===47||L===62||Ue(L)?b(L):n(L)}function P(L){return L===62?(e.consume(L),B):n(L)}function B(L){return L===null||Se(L)?A(L):Ue(L)?(e.consume(L),B):n(L)}function A(L){return L===45&&i===2?(e.consume(L),$):L===60&&i===1?(e.consume(L),F):L===62&&i===4?(e.consume(L),H):L===63&&i===3?(e.consume(L),E):L===93&&i===5?(e.consume(L),O):Se(L)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(yY,q,R)(L)):L===null||Se(L)?(e.exit("htmlFlowData"),R(L)):(e.consume(L),A)}function R(L){return e.check(bY,M,q)(L)}function M(L){return e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),D}function D(L){return L===null||Se(L)?R(L):(e.enter("htmlFlowData"),A(L))}function $(L){return L===45?(e.consume(L),E):A(L)}function F(L){return L===47?(e.consume(L),o="",j):A(L)}function j(L){if(L===62){const re=o.toLowerCase();return mk.includes(re)?(e.consume(L),H):A(L)}return Mn(L)&&o.length<8?(e.consume(L),o+=String.fromCharCode(L),j):A(L)}function O(L){return L===93?(e.consume(L),E):A(L)}function E(L){return L===62?(e.consume(L),H):L===45&&i===2?(e.consume(L),E):A(L)}function H(L){return L===null||Se(L)?(e.exit("htmlFlowData"),q(L)):(e.consume(L),H)}function q(L){return e.exit("htmlFlow"),t(L)}}function kY(e,t,n){const r=this;return i;function i(o){return Se(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 CY(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Mu,t,n)}}const EY={name:"htmlText",tokenize:NY};function NY(e,t,n){const r=this;let i,s,o;return a;function a(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),l}function l(E){return E===33?(e.consume(E),c):E===47?(e.consume(E),C):E===63?(e.consume(E),b):Mn(E)?(e.consume(E),T):n(E)}function c(E){return E===45?(e.consume(E),u):E===91?(e.consume(E),s=0,m):Mn(E)?(e.consume(E),x):n(E)}function u(E){return E===45?(e.consume(E),p):n(E)}function d(E){return E===null?n(E):E===45?(e.consume(E),f):Se(E)?(o=d,F(E)):(e.consume(E),d)}function f(E){return E===45?(e.consume(E),p):d(E)}function p(E){return E===62?$(E):E===45?f(E):d(E)}function m(E){const H="CDATA[";return E===H.charCodeAt(s++)?(e.consume(E),s===H.length?v:m):n(E)}function v(E){return E===null?n(E):E===93?(e.consume(E),w):Se(E)?(o=v,F(E)):(e.consume(E),v)}function w(E){return E===93?(e.consume(E),_):v(E)}function _(E){return E===62?$(E):E===93?(e.consume(E),_):v(E)}function x(E){return E===null||E===62?$(E):Se(E)?(o=x,F(E)):(e.consume(E),x)}function b(E){return E===null?n(E):E===63?(e.consume(E),S):Se(E)?(o=b,F(E)):(e.consume(E),b)}function S(E){return E===62?$(E):b(E)}function C(E){return Mn(E)?(e.consume(E),k):n(E)}function k(E){return E===45||kn(E)?(e.consume(E),k):N(E)}function N(E){return Se(E)?(o=N,F(E)):Ue(E)?(e.consume(E),N):$(E)}function T(E){return E===45||kn(E)?(e.consume(E),T):E===47||E===62||ct(E)?z(E):n(E)}function z(E){return E===47?(e.consume(E),$):E===58||E===95||Mn(E)?(e.consume(E),P):Se(E)?(o=z,F(E)):Ue(E)?(e.consume(E),z):$(E)}function P(E){return E===45||E===46||E===58||E===95||kn(E)?(e.consume(E),P):B(E)}function B(E){return E===61?(e.consume(E),A):Se(E)?(o=B,F(E)):Ue(E)?(e.consume(E),B):z(E)}function A(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),i=E,R):Se(E)?(o=A,F(E)):Ue(E)?(e.consume(E),A):(e.consume(E),M)}function R(E){return E===i?(e.consume(E),i=void 0,D):E===null?n(E):Se(E)?(o=R,F(E)):(e.consume(E),R)}function M(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||ct(E)?z(E):(e.consume(E),M)}function D(E){return E===47||E===62||ct(E)?z(E):n(E)}function $(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function F(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),j}function j(E){return Ue(E)?Ke(e,O,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):O(E)}function O(E){return e.enter("htmlTextData"),o(E)}}const Yy={name:"labelEnd",resolveAll:RY,resolveTo:MY,tokenize:AY},TY={tokenize:LY},IY={tokenize:DY},PY={tokenize:jY};function RY(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&or(e,0,e.length,n),e}function MY(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=wr(a,e.slice(s+1,s+r+3)),a=wr(a,[["enter",u,t]]),a=wr(a,Pp(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=wr(a,[["exit",u,t],e[o-2],e[o-1],["exit",c,t]]),a=wr(a,e.slice(o+1)),a=wr(a,[["exit",l,t]]),or(e,s,e.length,a),e}function AY(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(Hr(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(TY,u,o?u:d)(f):f===91?e.attempt(IY,u,o?c:d)(f):o?u(f):d(f)}function c(f){return e.attempt(PY,u,d)(f)}function u(f){return t(f)}function d(f){return s._balanced=!0,n(f)}}function LY(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),i}function i(d){return ct(d)?Ec(e,s)(d):s(d)}function s(d){return d===41?u(d):WM(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function o(d){return ct(d)?Ec(e,l)(d):u(d)}function a(d){return n(d)}function l(d){return d===34||d===39||d===40?qM(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):u(d)}function c(d){return ct(d)?Ec(e,u)(d):u(d)}function u(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function DY(e,t,n){const r=this;return i;function i(a){return VM.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Hr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function jY(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 OY={name:"labelStartImage",resolveAll:Yy.resolveAll,tokenize:BY};function BY(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 zY={name:"labelStartLink",resolveAll:Yy.resolveAll,tokenize:$Y};function $Y(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 qm={name:"lineEnding",tokenize:FY};function FY(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ke(e,t,"linePrefix")}}const oh={name:"thematicBreak",tokenize:HY};function HY(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||Se(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),Ue(c)?Ke(e,a,"whitespace")(c):a(c))}}const Un={continuation:{tokenize:qY},exit:GY,name:"list",tokenize:VY},UY={partial:!0,tokenize:YY},WY={partial:!0,tokenize:KY};function VY(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:L0(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(oh,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 L0(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(Mu,r.interrupt?n:u,e.attempt(UY,f,d))}function u(p){return r.containerState.initialBlankLine=!0,s++,f(p)}function d(p){return Ue(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),f):n(p)}function f(p){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function qY(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Mu,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ke(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!Ue(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(WY,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ke(e,e.attempt(Un,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function KY(e,t,n){const r=this;return Ke(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 GY(e){e.exit(this.containerState.type)}function YY(e,t,n){const r=this;return Ke(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!Ue(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const gk={name:"setextUnderline",resolveTo:XY,tokenize:QY};function XY(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 QY(e,t,n){const r=this;let i;return s;function s(c){let u=r.events.length,d;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){d=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),i=c,o(c)):n(c)}function o(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===i?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),Ue(c)?Ke(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||Se(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const ZY={tokenize:JY};function JY(e){const t=this,n=e.attempt(Mu,r,e.attempt(this.parser.constructs.flowInitial,i,Ke(e,e.attempt(this.parser.constructs.flow,i,e.attempt(iY,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 eX={resolveAll:GM()},tX=KM("string"),nX=KM("text");function KM(e){return{resolveAll:GM(e==="text"?rX: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 GM(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 rX(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 iX={42:Un,43:Un,45:Un,48:Un,49:Un,50:Un,51:Un,52:Un,53:Un,54:Un,55:Un,56:Un,57:Un,62:$M},sX={91:cY},oX={[-2]:Vm,[-1]:Vm,32:Vm},aX={35:mY,42:oh,45:[gk,oh],60:xY,61:gk,95:oh,96:pk,126:pk},lX={38:HM,92:FM},cX={[-5]:qm,[-4]:qm,[-3]:qm,33:OY,38:HM,42:D0,60:[zG,EY],91:zY,92:[fY,FM],93:Yy,95:D0,96:ZG},uX={null:[D0,eX]},dX={null:[42,95]},hX={null:[]},fX=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:dX,contentInitial:sX,disable:hX,document:iX,flow:aX,flowInitial:oX,insideSpan:uX,string:lX,text:cX},Symbol.toStringTag,{value:"Module"}));function pX(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],a=[];const l={attempt:N(C),check:N(k),consume:x,enter:b,exit:S,interrupt:N(k,{interrupt:!0})},c={code:null,containerState:{},defineSkip:v,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d};let u=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function d(B){return o=wr(o,B),w(),o[o.length-1]!==null?[]:(T(t,0),c.events=Pp(s,c.events,c),c.events)}function f(B,A){return gX(p(B),A)}function p(B){return mX(o,B)}function m(){const{_bufferIndex:B,_index:A,line:R,column:M,offset:D}=r;return{_bufferIndex:B,_index:A,line:R,column:M,offset:D}}function v(B){i[B.line]=B.column,P()}function w(){let B;for(;r._index<o.length;){const A=o[r._index];if(typeof A=="string")for(B=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===B&&r._bufferIndex<A.length;)_(A.charCodeAt(r._bufferIndex));else _(A)}}function _(B){u=u(B)}function x(B){Se(B)?(r.line++,r.column=1,r.offset+=B===-3?2:1,P()):B!==-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=B}function b(B,A){const R=A||{};return R.type=B,R.start=m(),c.events.push(["enter",R,c]),a.push(R),R}function S(B){const A=a.pop();return A.end=m(),c.events.push(["exit",A,c]),A}function C(B,A){T(B,A.from)}function k(B,A){A.restore()}function N(B,A){return R;function R(M,D,$){let F,j,O,E;return Array.isArray(M)?q(M):"tokenize"in M?q([M]):H(M);function H(K){return me;function me(Re){const ce=Re!==null&&K[Re],Le=Re!==null&&K.null,Oe=[...Array.isArray(ce)?ce:ce?[ce]:[],...Array.isArray(Le)?Le:Le?[Le]:[]];return q(Oe)(Re)}}function q(K){return F=K,j=0,K.length===0?$:L(K[j])}function L(K){return me;function me(Re){return E=z(),O=K,K.partial||(c.currentConstruct=K),K.name&&c.parser.constructs.disable.null.includes(K.name)?se():K.tokenize.call(A?Object.assign(Object.create(c),A):c,l,re,se)(Re)}}function re(K){return B(O,E),D}function se(K){return E.restore(),++j<F.length?L(F[j]):$}}}function T(B,A){B.resolveAll&&!s.includes(B)&&s.push(B),B.resolve&&or(c.events,A,c.events.length-A,B.resolve(c.events.slice(A),c)),B.resolveTo&&(c.events=B.resolveTo(c.events,c))}function z(){const B=m(),A=c.previous,R=c.currentConstruct,M=c.events.length,D=Array.from(a);return{from:M,restore:$};function $(){r=B,c.previous=A,c.currentConstruct=R,c.events.length=M,a=D,P()}}function P(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function mX(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 gX(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=`
|
|
511
|
+
`)},dU=0,na=[];function hU(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState(dU++)[0],s=g.useState(jP)[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=AH([e.lockRef.current],(e.shards||[]).map(SS),!0).filter(Boolean);return v.forEach(function(w){return w.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),v.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(v,w){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var _=bd(v),x=n.current,b="deltaX"in v?v.deltaX:x[0]-_[0],S="deltaY"in v?v.deltaY:x[1]-_[1],C,k=v.target,N=Math.abs(b)>Math.abs(S)?"h":"v";if("touches"in v&&N==="h"&&k.type==="range")return!1;var T=window.getSelection(),z=T&&T.anchorNode,P=z?z===k||z.contains(k):!1;if(P)return!1;var B=bS(N,k);if(!B)return!0;if(B?C=N:(C=N==="v"?"h":"v",B=bS(N,k)),!B)return!1;if(!r.current&&"changedTouches"in v&&(b||S)&&(r.current=C),!C)return!0;var A=r.current||C;return lU(A,w,v,A==="h"?b:S)},[]),l=g.useCallback(function(v){var w=v;if(!(!na.length||na[na.length-1]!==s)){var _="deltaY"in w?wS(w):bd(w),x=t.current.filter(function(C){return C.name===w.type&&(C.target===w.target||w.target===C.shadowParent)&&cU(C.delta,_)})[0];if(x&&x.should){w.cancelable&&w.preventDefault();return}if(!x){var b=(o.current.shards||[]).map(SS).filter(Boolean).filter(function(C){return C.contains(w.target)}),S=b.length>0?a(w,b[0]):!o.current.noIsolation;S&&w.cancelable&&w.preventDefault()}}},[]),c=g.useCallback(function(v,w,_,x){var b={name:v,delta:w,target:_,should:x,shadowParent:fU(_)};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(S){return S!==b})},1)},[]),u=g.useCallback(function(v){n.current=bd(v),r.current=void 0},[]),d=g.useCallback(function(v){c(v.type,wS(v),v.target,a(v,e.lockRef.current))},[]),f=g.useCallback(function(v){c(v.type,bd(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return na.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,ta),document.addEventListener("touchmove",l,ta),document.addEventListener("touchstart",u,ta),function(){na=na.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,ta),document.removeEventListener("touchmove",l,ta),document.removeEventListener("touchstart",u,ta)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(s,{styles:uU(i)}):null,p?g.createElement(tU,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function fU(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const pU=HH(DP,hU);var gy=g.forwardRef(function(e,t){return g.createElement(xp,si({},e,{ref:t,sideCar:pU}))});gy.classNames=xp.classNames;var S0=["Enter"," "],mU=["ArrowDown","PageUp","Home"],$P=["ArrowUp","PageDown","End"],gU=[...mU,...$P],vU={ltr:[...S0,"ArrowRight"],rtl:[...S0,"ArrowLeft"]},_U={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Eu="Menu",[ru,xU,yU]=YI(Eu),[Wo,FP]=Uo(Eu,[yU,_p,EP]),Nu=_p(),HP=EP(),[UP,qs]=Wo(Eu),[bU,Tu]=Wo(Eu),WP=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=Nu(t),[l,c]=g.useState(null),u=g.useRef(!1),d=gi(s),f=XI(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(py,{...a,children:h.jsx(UP,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(bU,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};WP.displayName=Eu;var wU="MenuAnchor",vy=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Nu(n);return h.jsx(wP,{...i,...r,ref:t})});vy.displayName=wU;var _y="MenuPortal",[SU,VP]=Wo(_y,{forceMount:void 0}),qP=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=qs(_y,t);return h.jsx(SU,{scope:t,forceMount:n,children:h.jsx(Qi,{present:n||s.open,children:h.jsx(my,{asChild:!0,container:i,children:r})})})};qP.displayName=_y;var Cr="MenuContent",[kU,xy]=Wo(Cr),KP=g.forwardRef((e,t)=>{const n=VP(Cr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=qs(Cr,e.__scopeMenu),o=Tu(Cr,e.__scopeMenu);return h.jsx(ru.Provider,{scope:e.__scopeMenu,children:h.jsx(Qi,{present:r||s.open,children:h.jsx(ru.Slot,{scope:e.__scopeMenu,children:o.modal?h.jsx(CU,{...i,ref:t}):h.jsx(EU,{...i,ref:t})})})})}),CU=g.forwardRef((e,t)=>{const n=qs(Cr,e.__scopeMenu),r=g.useRef(null),i=Qt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return MP(s)},[]),h.jsx(yy,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),EU=g.forwardRef((e,t)=>{const n=qs(Cr,e.__scopeMenu);return h.jsx(yy,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),NU=tu("MenuContent.ScrollLock"),yy=g.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...v}=e,w=qs(Cr,n),_=Tu(Cr,n),x=Nu(n),b=HP(n),S=xU(n),[C,k]=g.useState(null),N=g.useRef(null),T=Qt(t,N,w.onContentChange),z=g.useRef(0),P=g.useRef(""),B=g.useRef(0),A=g.useRef(null),R=g.useRef("right"),M=g.useRef(0),D=m?gy:g.Fragment,$=m?{as:NU,allowPinchZoom:!0}:void 0,F=O=>{var ge,Re;const E=P.current+O,H=S().filter(ce=>!ce.disabled),q=document.activeElement,L=(ge=H.find(ce=>ce.ref.current===q))==null?void 0:ge.textValue,re=H.map(ce=>ce.textValue),se=zU(re,E,L),K=(Re=H.find(ce=>ce.textValue===se))==null?void 0:Re.ref.current;(function ce(Le){P.current=Le,window.clearTimeout(z.current),Le!==""&&(z.current=window.setTimeout(()=>ce(""),1e3))})(E),K&&setTimeout(()=>K.focus())};g.useEffect(()=>()=>window.clearTimeout(z.current),[]),JI();const j=g.useCallback(O=>{var H,q;return R.current===((H=A.current)==null?void 0:H.side)&&FU(O,(q=A.current)==null?void 0:q.area)},[]);return h.jsx(kU,{scope:n,searchRef:P,onItemEnter:g.useCallback(O=>{j(O)&&O.preventDefault()},[j]),onItemLeave:g.useCallback(O=>{var E;j(O)||((E=N.current)==null||E.focus(),k(null))},[j]),onTriggerLeave:g.useCallback(O=>{j(O)&&O.preventDefault()},[j]),pointerGraceTimerRef:B,onPointerGraceIntentChange:g.useCallback(O=>{A.current=O},[]),children:h.jsx(D,{...$,children:h.jsx(sy,{asChild:!0,trapped:i,onMountAutoFocus:Pe(s,O=>{var E;O.preventDefault(),(E=N.current)==null||E.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:h.jsx(fp,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(TH,{asChild:!0,...b,dir:_.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:Pe(l,O=>{_.isUsingKeyboardRef.current||O.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(SP,{role:"menu","aria-orientation":"vertical","data-state":uR(w.open),"data-radix-menu-content":"",dir:_.dir,...x,...v,ref:T,style:{outline:"none",...v.style},onKeyDown:Pe(v.onKeyDown,O=>{const H=O.target.closest("[data-radix-menu-content]")===O.currentTarget,q=O.ctrlKey||O.altKey||O.metaKey,L=O.key.length===1;H&&(O.key==="Tab"&&O.preventDefault(),!q&&L&&F(O.key));const re=N.current;if(O.target!==re||!gU.includes(O.key))return;O.preventDefault();const K=S().filter(ge=>!ge.disabled).map(ge=>ge.ref.current);$P.includes(O.key)&&K.reverse(),OU(K)}),onBlur:Pe(e.onBlur,O=>{O.currentTarget.contains(O.target)||(window.clearTimeout(z.current),P.current="")}),onPointerMove:Pe(e.onPointerMove,iu(O=>{const E=O.target,H=M.current!==O.clientX;if(O.currentTarget.contains(E)&&H){const q=O.clientX>M.current?"right":"left";R.current=q,M.current=O.clientX}}))})})})})})})});KP.displayName=Cr;var TU="MenuGroup",by=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Rt.div,{role:"group",...r,ref:t})});by.displayName=TU;var IU="MenuLabel",GP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Rt.div,{...r,ref:t})});GP.displayName=IU;var lf="MenuItem",kS="menu.itemSelect",yp=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=Tu(lf,e.__scopeMenu),a=xy(lf,e.__scopeMenu),l=Qt(t,s),c=g.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(kS,{bubbles:!0,cancelable:!0});d.addEventListener(kS,p=>r==null?void 0:r(p),{once:!0}),GI(d,f),f.defaultPrevented?c.current=!1:o.onClose()}};return h.jsx(YP,{...i,ref:l,disabled:n,onClick:Pe(e.onClick,u),onPointerDown:d=>{var f;(f=e.onPointerDown)==null||f.call(e,d),c.current=!0},onPointerUp:Pe(e.onPointerUp,d=>{var f;c.current||(f=d.currentTarget)==null||f.click()}),onKeyDown:Pe(e.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||S0.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});yp.displayName=lf;var YP=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=xy(lf,n),a=HP(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(ru.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:h.jsx(IH,{asChild:!0,...a,focusable:!r,children:h.jsx(Rt.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:Pe(e.onPointerMove,iu(m=>{r?o.onItemLeave(m):(o.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Pe(e.onPointerLeave,iu(m=>o.onItemLeave(m))),onFocus:Pe(e.onFocus,()=>d(!0)),onBlur:Pe(e.onBlur,()=>d(!1))})})})}),PU="MenuCheckboxItem",XP=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return h.jsx(tR,{scope:e.__scopeMenu,checked:n,children:h.jsx(yp,{role:"menuitemcheckbox","aria-checked":cf(n)?"mixed":n,...i,ref:t,"data-state":ky(n),onSelect:Pe(i.onSelect,()=>r==null?void 0:r(cf(n)?!0:!n),{checkForDefaultPrevented:!1})})})});XP.displayName=PU;var QP="MenuRadioGroup",[RU,MU]=Wo(QP,{value:void 0,onValueChange:()=>{}}),ZP=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=gi(r);return h.jsx(RU,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(by,{...i,ref:t})})});ZP.displayName=QP;var JP="MenuRadioItem",eR=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=MU(JP,e.__scopeMenu),s=n===i.value;return h.jsx(tR,{scope:e.__scopeMenu,checked:s,children:h.jsx(yp,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":ky(s),onSelect:Pe(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});eR.displayName=JP;var wy="MenuItemIndicator",[tR,AU]=Wo(wy,{checked:!1}),nR=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=AU(wy,n);return h.jsx(Qi,{present:r||cf(s.checked)||s.checked===!0,children:h.jsx(Rt.span,{...i,ref:t,"data-state":ky(s.checked)})})});nR.displayName=wy;var LU="MenuSeparator",rR=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Rt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});rR.displayName=LU;var DU="MenuArrow",iR=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Nu(n);return h.jsx(kP,{...i,...r,ref:t})});iR.displayName=DU;var Sy="MenuSub",[jU,sR]=Wo(Sy),oR=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=qs(Sy,t),o=Nu(t),[a,l]=g.useState(null),[c,u]=g.useState(null),d=gi(i);return g.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),h.jsx(py,{...o,children:h.jsx(UP,{scope:t,open:r,onOpenChange:d,content:c,onContentChange:u,children:h.jsx(jU,{scope:t,contentId:Oi(),triggerId:Oi(),trigger:a,onTriggerChange:l,children:n})})})};oR.displayName=Sy;var rc="MenuSubTrigger",aR=g.forwardRef((e,t)=>{const n=qs(rc,e.__scopeMenu),r=Tu(rc,e.__scopeMenu),i=sR(rc,e.__scopeMenu),s=xy(rc,e.__scopeMenu),o=g.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},u=g.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return g.useEffect(()=>u,[u]),g.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),h.jsx(vy,{asChild:!0,...c,children:h.jsx(YP,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":uR(n.open),...e,ref:wu(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:Pe(e.onPointerMove,iu(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:Pe(e.onPointerLeave,iu(d=>{var p,m;u();const f=(p=n.content)==null?void 0:p.getBoundingClientRect();if(f){const v=(m=n.content)==null?void 0:m.dataset.side,w=v==="right",_=w?-5:5,x=f[w?"left":"right"],b=f[w?"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:Pe(e.onKeyDown,d=>{var p;const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||vU[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});aR.displayName=rc;var lR="MenuSubContent",cR=g.forwardRef((e,t)=>{const n=VP(Cr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=qs(Cr,e.__scopeMenu),o=Tu(Cr,e.__scopeMenu),a=sR(lR,e.__scopeMenu),l=g.useRef(null),c=Qt(t,l);return h.jsx(ru.Provider,{scope:e.__scopeMenu,children:h.jsx(Qi,{present:r||s.open,children:h.jsx(ru.Slot,{scope:e.__scopeMenu,children:h.jsx(yy,{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:Pe(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Pe(e.onEscapeKeyDown,u=>{o.onClose(),u.preventDefault()}),onKeyDown:Pe(e.onKeyDown,u=>{var p;const d=u.currentTarget.contains(u.target),f=_U[o.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});cR.displayName=lR;function uR(e){return e?"open":"closed"}function cf(e){return e==="indeterminate"}function ky(e){return cf(e)?"indeterminate":e?"checked":"unchecked"}function OU(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function BU(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function zU(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=BU(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 $U(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 FU(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return $U(n,t)}function iu(e){return t=>t.pointerType==="mouse"?e(t):void 0}var HU=WP,UU=vy,WU=qP,VU=KP,qU=by,KU=GP,GU=yp,YU=XP,XU=ZP,QU=eR,ZU=nR,JU=rR,eW=iR,tW=oR,nW=aR,rW=cR,bp="DropdownMenu",[iW]=Uo(bp,[FP]),En=FP(),[sW,dR]=iW(bp),hR=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=En(t),c=g.useRef(null),[u,d]=Su({prop:i,defaultProp:s??!1,onChange:o,caller:bp});return h.jsx(sW,{scope:t,triggerId:Oi(),triggerRef:c,contentId:Oi(),open:u,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(HU,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};hR.displayName=bp;var fR="DropdownMenuTrigger",pR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=dR(fR,n),o=En(n);return h.jsx(UU,{asChild:!0,...o,children:h.jsx(Rt.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:wu(t,s.triggerRef),onPointerDown:Pe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:Pe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});pR.displayName=fR;var oW="DropdownMenuPortal",mR=e=>{const{__scopeDropdownMenu:t,...n}=e,r=En(t);return h.jsx(WU,{...r,...n})};mR.displayName=oW;var gR="DropdownMenuContent",vR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=dR(gR,n),s=En(n),o=g.useRef(!1);return h.jsx(VU,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:t,onCloseAutoFocus:Pe(e.onCloseAutoFocus,a=>{var l;o.current||(l=i.triggerRef.current)==null||l.focus(),o.current=!1,a.preventDefault()}),onInteractOutside:Pe(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)"}})});vR.displayName=gR;var aW="DropdownMenuGroup",lW=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(qU,{...i,...r,ref:t})});lW.displayName=aW;var cW="DropdownMenuLabel",_R=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(KU,{...i,...r,ref:t})});_R.displayName=cW;var uW="DropdownMenuItem",xR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(GU,{...i,...r,ref:t})});xR.displayName=uW;var dW="DropdownMenuCheckboxItem",yR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(YU,{...i,...r,ref:t})});yR.displayName=dW;var hW="DropdownMenuRadioGroup",fW=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(XU,{...i,...r,ref:t})});fW.displayName=hW;var pW="DropdownMenuRadioItem",mW=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(QU,{...i,...r,ref:t})});mW.displayName=pW;var gW="DropdownMenuItemIndicator",bR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(ZU,{...i,...r,ref:t})});bR.displayName=gW;var vW="DropdownMenuSeparator",wR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(JU,{...i,...r,ref:t})});wR.displayName=vW;var _W="DropdownMenuArrow",xW=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(eW,{...i,...r,ref:t})});xW.displayName=_W;var yW=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,o=En(t),[a,l]=Su({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return h.jsx(tW,{...o,open:a,onOpenChange:l,children:n})},bW="DropdownMenuSubTrigger",SR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(nW,{...i,...r,ref:t})});SR.displayName=bW;var wW="DropdownMenuSubContent",kR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=En(n);return h.jsx(rW,{...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)"}})});kR.displayName=wW;var SW=hR,kW=pR,CR=mR,ER=vR,NR=_R,TR=xR,IR=yR,CW=bR,PR=wR,EW=yW,RR=SR,MR=kR;const AR=SW,LR=kW,Cy=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(CR,{children:h.jsx(ER,{ref:r,sideOffset:t,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));Cy.displayName=ER.displayName;const NW=EW,DR=g.forwardRef(({className:e,...t},n)=>h.jsx(RR,{ref:n,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100 data-[state=open]:bg-bg-200","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...t}));DR.displayName=RR.displayName;const jR=g.forwardRef(({className:e,...t},n)=>h.jsx(CR,{children:h.jsx(MR,{ref:n,className:ne("z-50 min-w-[6rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...t})}));jR.displayName=MR.displayName;const co=g.forwardRef(({className:e,inset:t,...n},r)=>h.jsx(TR,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));co.displayName=TR.displayName;const TW=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>h.jsxs(IR,{ref:i,checked:n,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-7 pr-2 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[h.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:h.jsx(CW,{children:h.jsx(bu,{className:"h-3.5 w-3.5"})})}),t]}));TW.displayName=IR.displayName;const Ey=g.forwardRef(({className:e,...t},n)=>h.jsx(PR,{ref:n,className:ne("-mx-1 my-1 h-px bg-border",e),...t}));Ey.displayName=PR.displayName;const OR=g.forwardRef(({className:e,...t},n)=>h.jsx(NR,{ref:n,className:ne("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));OR.displayName=NR.displayName;function IW({tool:e,className:t}){const n=w9(e);return h.jsx("span",{"data-testid":n?`session-icon-${e}`:"session-icon-default","aria-label":n?ry(e):"未知引擎",className:ne("w-3.5 h-3.5 shrink-0 inline-flex items-center justify-center",hp(e),t),children:h.jsx(dp,{tool:e,className:"w-full h-full"})})}function PW({sessionId:e,hasUnread:t,running:n=!1,awaitingUser:r=!1,style:i}){return r?h.jsx(q$,{"data-testid":`awaiting-dot-${e}`,style:i,className:"w-3 h-3 text-warning shrink-0 animate-pulse",strokeWidth:2.25,"aria-label":"awaiting user"}):t?h.jsx("span",{"data-testid":`unread-dot-${e}`,style:i,className:"w-2 h-2 rounded-full bg-error shrink-0","aria-label":"unread"}):n?h.jsx("span",{"data-testid":`running-dot-${e}`,style:i,className:"w-2 h-2 rounded-full bg-success shrink-0 animate-pulse","aria-label":"running"}):null}function BR(e){return e.compositionActive||!!e.nativeIsComposing||e.keyCode===229}function zR(e){return e.key==="Enter"&&!e.shiftKey&&!BR(e)}function Iu(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(zR({key:o.key,shiftKey:o.shiftKey,compositionActive:n.current,nativeIsComposing:a.isComposing,keyCode:a.keyCode})){o.preventDefault(),e();return}t&&o.key==="Escape"&&(o.preventDefault(),t())},[e,t]),onCompositionStart:r,onCompositionEnd:i}}function RW({open:e,initialLabel:t,placeholder:n,onSubmit:r,onCancel:i,title:s="Edit session",fieldLabel:o="Label",testId:a="session-edit-dialog",requireNonEmpty:l=!1}){const[c,u]=g.useState(t);g.useEffect(()=>{e&&u(t)},[e,t]);const d=c.trim(),f=l&&d==="",p=()=>{f||r({label:d})},m=Iu(p,i);return e?hl.createPortal(h.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-bg-0/40 backdrop-blur-[2px]",onClick:i,"data-testid":`${a}-overlay`,children:h.jsxs("div",{"data-testid":a,className:"w-[420px] max-w-[calc(100vw-32px)] rounded-2xl border border-text-100/[0.12] flex flex-col gap-4 p-5",style:{backgroundColor:"var(--bg-0)",boxShadow:"0 12px 40px rgba(0,0,0,0.04)"},onClick:v=>v.stopPropagation(),children:[h.jsx("div",{className:"text-[15px] font-semibold text-text-100",children:s}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:o}),h.jsx("input",{autoFocus:!0,type:"text",value:c,onChange:v=>u(v.target.value),...m,placeholder:n,"data-testid":`${a}-label`,className:"w-full px-3 py-2 text-[13px] bg-bg-50 border border-bg-300 rounded-lg focus:outline-none focus:border-text-300 transition-colors"})]}),h.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[h.jsx("button",{type:"button",onClick:i,className:"px-4 py-1.5 text-[12px] text-text-300 rounded-lg hover:bg-text-100/5 transition-colors cursor-pointer",children:"Cancel"}),h.jsx("button",{type:"button",onClick:p,disabled:f,"data-testid":`${a}-save`,className:"px-4 py-1.5 text-[12px] font-medium text-bg-0 rounded-lg bg-text-100 hover:bg-text-200 transition-colors cursor-pointer disabled:cursor-not-allowed disabled:opacity-40",children:"Save"})]})]})}),document.body):null}var MW=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"}),AW="VisuallyHidden",$R=g.forwardRef((e,t)=>h.jsx(Rt.span,{...e,ref:t,style:{...MW,...e.style}}));$R.displayName=AW;var LW=$R,[wp]=Uo("Tooltip",[_p]),Sp=_p(),FR="TooltipProvider",DW=700,k0="tooltip.open",[jW,Ny]=wp(FR),HR=e=>{const{__scopeTooltip:t,delayDuration:n=DW,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=g.useRef(!0),a=g.useRef(!1),l=g.useRef(0);return g.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),h.jsx(jW,{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})};HR.displayName=FR;var su="Tooltip",[OW,kp]=wp(su),UR=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=Ny(su,e.__scopeTooltip),c=Sp(t),[u,d]=g.useState(null),f=Oi(),p=g.useRef(0),m=o??l.disableHoverableContent,v=a??l.delayDuration,w=g.useRef(!1),[_,x]=Su({prop:r,defaultProp:i??!1,onChange:N=>{N?(l.onOpen(),document.dispatchEvent(new CustomEvent(k0))):l.onClose(),s==null||s(N)},caller:su}),b=g.useMemo(()=>_?w.current?"delayed-open":"instant-open":"closed",[_]),S=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,w.current=!1,x(!0)},[x]),C=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x(!1)},[x]),k=g.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{w.current=!0,x(!0),p.current=0},v)},[v,x]);return g.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),h.jsx(py,{...c,children:h.jsx(OW,{scope:t,contentId:f,open:_,stateAttribute:b,trigger:u,onTriggerChange:d,onTriggerEnter:g.useCallback(()=>{l.isOpenDelayedRef.current?k():S()},[l.isOpenDelayedRef,k,S]),onTriggerLeave:g.useCallback(()=>{m?C():(window.clearTimeout(p.current),p.current=0)},[C,m]),onOpen:S,onClose:C,disableHoverableContent:m,children:n})})};UR.displayName=su;var C0="TooltipTrigger",WR=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=kp(C0,n),s=Ny(C0,n),o=Sp(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(wP,{asChild:!0,...o,children:h.jsx(Rt.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:Pe(e.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:Pe(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:Pe(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Pe(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Pe(e.onBlur,i.onClose),onClick:Pe(e.onClick,i.onClose)})})});WR.displayName=C0;var BW="TooltipPortal",[Zae,zW]=wp(BW,{forceMount:void 0}),Za="TooltipContent",VR=g.forwardRef((e,t)=>{const n=zW(Za,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=kp(Za,e.__scopeTooltip);return h.jsx(Qi,{present:r||o.open,children:o.disableHoverableContent?h.jsx(qR,{side:i,...s,ref:t}):h.jsx($W,{side:i,...s,ref:t})})}),$W=g.forwardRef((e,t)=>{const n=kp(Za,e.__scopeTooltip),r=Ny(Za,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 w=m.currentTarget,_={x:m.clientX,y:m.clientY},x=VW(_,w.getBoundingClientRect()),b=qW(_,x),S=KW(v.getBoundingClientRect()),C=YW([...b,...S]);a(C),d(!0)},[d]);return g.useEffect(()=>()=>f(),[f]),g.useEffect(()=>{if(l&&u){const m=w=>p(w,u),v=w=>p(w,l);return l.addEventListener("pointerleave",m),u.addEventListener("pointerleave",v),()=>{l.removeEventListener("pointerleave",m),u.removeEventListener("pointerleave",v)}}},[l,u,p,f]),g.useEffect(()=>{if(o){const m=v=>{const w=v.target,_={x:v.clientX,y:v.clientY},x=(l==null?void 0:l.contains(w))||(u==null?void 0:u.contains(w)),b=!GW(_,o);x?f():b&&(f(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[l,u,o,c,f]),h.jsx(qR,{...e,ref:s})}),[FW,HW]=wp(su,{isInside:!1}),UW=M9("TooltipContent"),qR=g.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,l=kp(Za,n),c=Sp(n),{onClose:u}=l;return g.useEffect(()=>(document.addEventListener(k0,u),()=>document.removeEventListener(k0,u)),[u]),g.useEffect(()=>{if(l.trigger){const d=f=>{const p=f.target;p!=null&&p.contains(l.trigger)&&u()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,u]),h.jsx(fp,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:h.jsxs(SP,{"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(UW,{children:r}),h.jsx(FW,{scope:n,isInside:!0,children:h.jsx(LW,{id:l.contentId,role:"tooltip",children:i||r})})]})})});VR.displayName=Za;var KR="TooltipArrow",WW=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Sp(n);return HW(KR,n).isInside?null:h.jsx(kP,{...i,...r,ref:t})});WW.displayName=KR;function VW(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 qW(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 KW(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 GW(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 YW(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),XW(t)}function XW(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 QW=HR,ZW=UR,JW=WR,GR=VR;const uf=QW,Cp=ZW,Ep=JW,Pu=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(GR,{ref:r,sideOffset:t,className:ne("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}));Pu.displayName=GR.displayName;const eV={held:!1,indexBySessionId:new Map},tV=g.createContext(eV);function nV(){return g.useContext(tV)}const rV=Array.from({length:9},(e,t)=>({id:`switch-session-${t+1}`,combo:{key:String(t+1),mod:!0},label:`切换到第 ${t+1} 个会话`,group:"会话",desktopOnly:!0,hiddenInList:!0})),iV=[{id:"new-session",combo:{key:"n",mod:!0},label:"新建任务",description:"打开快捷新建弹窗",group:"通用",desktopOnly:!0},{id:"open-search",combo:{key:"k",mod:!0},label:"全局搜索",description:"搜会话内容 / persona / 联系人",group:"通用",desktopOnly:!0},{id:"search-tab-prev",combo:{key:"ArrowLeft",mod:!0},label:"搜索:上一组",description:"搜索浮层里切到左边那个 tab(会话 / persona / 联系人)",group:"通用"},{id:"search-tab-next",combo:{key:"ArrowRight",mod:!0},label:"搜索:下一组",description:"搜索浮层里切到右边那个 tab",group:"通用"},...rV,{id:"archive-session",combo:{key:"Backspace",mod:!0,shift:!0},label:"归档当前会话",description:"归档当前聊天区的会话,Enter 确认 / Esc 取消",group:"会话",desktopOnly:!0},{id:"tab-prev",combo:{key:"ArrowLeft",mod:!0,shift:!0},label:"上一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"tab-next",combo:{key:"ArrowRight",mod:!0,shift:!0},label:"下一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"toggle-hive",combo:{key:"h",mod:!0,shift:!0},label:"Hive 看板",description:"全屏看所有 agent 在干什么;Esc 或点任意行退出",group:"通用"},{id:"send-message",combo:{key:"Enter"},label:"发送消息",description:"在输入框中发送当前内容",group:"输入",displayOnly:!0},{id:"newline",combo:{key:"Enter",shift:!0},label:"换行",description:"在输入框中插入换行",group:"输入",displayOnly:!0},{id:"interrupt",combo:{key:"Escape"},label:"打断回复",description:"打断当前回复;2 秒内按两次停止任务",group:"输入",displayOnly:!0}];iV.filter(e=>!e.displayOnly);function sV(){return/Mac|iP(hone|od|ad)/.test(navigator.platform)}const oV=10,aV=20,lV=16,CS=20,ES=60,cV=4;function wd({testId:e,label:t,children:n}){return h.jsxs(Cp,{children:[h.jsx(Ep,{asChild:!0,children:h.jsx("span",{"data-testid":e,role:"img","aria-label":t,tabIndex:0,className:"inline-flex shrink-0",children:n})}),h.jsx(Pu,{side:"bottom",children:t})]})}function uV({session:e,active:t,hasUnread:n,running:r=!1,awaitingUser:i=!1,onSelect:s,onEdit:o,onDelete:a,onPin:l,onArchive:c,quickAction:u,depth:d=0,chevron:f,showCopyResume:p=!0,contactDisplayName:m,ownerPrincipalId:v,creatorDisplayName:w,dispatchedFromSessionTitle:_}){const[x,b]=g.useState(!1),S=nV(),C=S.held?S.indexBySessionId.get(e.sessionId):void 0,k=!!e.pinnedAt,N=d===0,T=d===0&&!!c,z=oV+d*aV;let P=null;u==="pin"&&N&&l?P={icon:k?h.jsx(Ww,{className:"w-4 h-4"}):h.jsx(Vw,{className:"w-4 h-4"}),label:k?"取消置顶":"置顶",run:()=>l(e.sessionId,!k)}:u==="archive"&&T&&c?P={icon:h.jsx(Fw,{className:"w-4 h-4"}),label:"归档",run:()=>c(e.sessionId,!0)}:u==="rename"&&o&&(P={icon:h.jsx(p0,{className:"w-4 h-4"}),label:"重命名",run:()=>b(!0)});const B=g.useCallback(async()=>{const $=qI(e);if($)try{await navigator.clipboard.writeText($)}catch{}},[e]),A=iy(e),R=e.originOwnerPrincipalId,M=R?`@${m??`…${R.slice(-8)}`}`:null,D=!!(e.ownerPersonaId&&v&&e.creatorPrincipalId&&e.creatorPrincipalId!==v&&!e.larkChatId&&!e.shiftFiredFromSessionId&&!e.dispatchedFromSessionId);return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":`session-item-${e.sessionId}`,onClick:s,style:{paddingLeft:z,display:"grid",gridTemplateColumns:f?`${lV}px ${CS}px 1fr auto ${ES}px`:`${CS}px 1fr auto ${ES}px`,gridTemplateAreas:f?'"chev icon name dot time"':'"icon name dot time"',columnGap:`${cV}px`,alignItems:"center"},className:ne("group relative rounded-lg cursor-pointer transition-all duration-150 pr-2.5 py-1.5",t?"bg-accent-dim":"hover:bg-sidebar-hover-bg"),children:[t?h.jsx("span",{"aria-hidden":"true",className:"absolute left-0 top-1/2 -translate-y-1/2 w-[3px] h-7 rounded-r-full bg-accent"}):null,h.jsx("div",{style:{gridArea:"chev"},className:"flex items-center justify-center",children:f??null}),h.jsx("div",{style:{gridArea:"icon"},className:"flex items-center justify-center",children:h.jsx(IW,{tool:e.tool})}),h.jsxs("div",{style:{gridArea:"name"},className:"flex items-center gap-1 min-w-0",children:[h.jsxs(uf,{delayDuration:200,skipDelayDuration:100,children:[e.dispatchedFromSessionId?h.jsx(wd,{testId:`dispatched-icon-${e.sessionId}`,label:`来自【${_??"另一会话"}】dispatch`,children:h.jsx(f8,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.shiftFiredFromSessionId?h.jsx(wd,{testId:`shift-fired-icon-${e.sessionId}`,label:"定时任务",children:h.jsx(O$,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.larkChatId?h.jsx(wd,{testId:`lark-chat-icon-${e.sessionId}`,label:e.larkChatType==="p2p"?"来自飞书DM":"来自飞书群",children:h.jsx(H8,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,D?h.jsx(wd,{testId:`guest-created-icon-${e.sessionId}`,label:w?`${w}创建`:"其他人创建",children:h.jsx(SF,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null]}),h.jsx("span",{"data-testid":`session-title-${e.sessionId}`,className:ne("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:A}),M?h.jsx("span",{"data-testid":`session-mirror-chip-${e.sessionId}`,title:`在 ${M.replace(/^@/,"")} 的设备上`,className:"shrink-0 inline-flex items-center px-1.5 py-0 rounded text-[10px] bg-accent-dim/40 text-accent border border-accent/20 max-w-[120px] truncate",children:M}):null]}),h.jsx(PW,{sessionId:e.sessionId,hasUnread:n,running:r,awaitingUser:i,style:{gridArea:"dot"}}),C!=null?h.jsx("span",{style:{gridArea:"time"},"data-testid":`session-quick-switch-badge-${e.sessionId}`,className:"text-right shrink-0 transition-opacity duration-150 group-hover:opacity-0",children:h.jsx("span",{className:"inline-flex items-center justify-center h-[18px] px-1.5 rounded-[5px] border border-border bg-bg-200/70 text-[11px] text-text-200 font-medium leading-none",children:sV()?`⌘${C}`:`Ctrl+${C}`})}):h.jsx("span",{style:{gridArea:"time"},className:ne("text-[11px] text-text-400/70 text-right shrink-0","transition-opacity duration-150 group-hover:opacity-0"),children:e.updatedAt?S9(e.updatedAt):""}),o||a||l||c?h.jsxs("div",{className:"absolute right-2 top-[3px] flex items-center opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100 transition-opacity",children:[P?h.jsx(uf,{delayDuration:200,skipDelayDuration:100,children:h.jsxs(Cp,{children:[h.jsx(Ep,{asChild:!0,children:h.jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),P.run()},className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":P.label,"data-testid":`quick-action-${u}-${e.sessionId}`,children:P.icon})}),h.jsx(Pu,{side:"bottom",children:P.label})]})}):null,h.jsxs(AR,{modal:!1,children:[h.jsx(LR,{asChild:!0,children:h.jsx("button",{type:"button",onClick:$=>$.stopPropagation(),className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"session actions","data-testid":`session-menu-${e.sessionId}`,children:h.jsx(bI,{className:"w-4 h-4"})})}),h.jsxs(Cy,{align:"end",onClick:$=>$.stopPropagation(),children:[l&&N&&h.jsxs(co,{onSelect:()=>l(e.sessionId,!k),"data-testid":`session-${k?"unpin":"pin"}-${e.sessionId}`,children:[k?h.jsx(Ww,{className:"w-3 h-3 mr-2 text-text-400"}):h.jsx(Vw,{className:"w-3 h-3 mr-2 text-text-400"}),k?"Unpin":"Pin"]}),T&&c&&h.jsxs(co,{onSelect:()=>c(e.sessionId,!0),"data-testid":`session-archive-${e.sessionId}`,children:[h.jsx(Fw,{className:"w-3 h-3 mr-2 text-text-400"}),"Archive"]}),o&&h.jsxs(co,{onSelect:()=>b(!0),"data-testid":`session-rename-${e.sessionId}`,children:[h.jsx(p0,{className:"w-3 h-3 mr-2 text-text-400"}),"Rename"]}),p&&e.toolSessionId?h.jsxs(co,{onSelect:()=>void B(),"data-testid":`session-copy-resume-${e.sessionId}`,children:[h.jsx(Qx,{className:"w-3 h-3 mr-2 text-text-400"}),"Copy Resume Command"]}):null,(l||o||p&&e.toolSessionId)&&a&&h.jsx(Ey,{}),a&&h.jsxs(co,{onSelect:()=>void a(e.sessionId),className:"text-destructive focus:text-destructive focus:bg-destructive/10","data-testid":`session-delete-${e.sessionId}`,children:[h.jsx(ey,{className:"w-3 h-3 mr-2"}),"Delete"]})]})]})]}):null]}),o?h.jsx(RW,{open:x,initialLabel:e.label??"",placeholder:e.cwd.split("/").pop()||"",onSubmit:$=>{o(e.sessionId,$),b(!1)},onCancel:()=>b(!1)}):null]})}function Ty({node:e,depth:t=0,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:v,getSessionDisplayName:w,parentSession:_}){const x=e.children.length>0,{isCollapsed:b,toggle:S}=P$(),C=!b(e.session.sessionId),k=g.useCallback(T=>{T.stopPropagation(),S(e.session.sessionId)},[S,e.session.sessionId]),N=x?h.jsx("button",{type:"button",onClick:k,"data-testid":`session-chevron-${e.session.sessionId}`,"aria-label":C?"collapse":"expand","aria-expanded":C,className:"shrink-0 flex items-center justify-center w-4 h-4 text-text-400 hover:text-text-100 cursor-pointer",children:C?h.jsx(Yn,{className:"w-3 h-3"}):h.jsx(Bn,{className:"w-3 h-3"})}):null;return h.jsxs("div",{"data-testid":`session-tree-node-${e.session.sessionId}`,children:[h.jsx(uV,{session:e.session,active:n===e.session.sessionId,hasUnread:(r==null?void 0:r.has(e.session.sessionId))??!1,running:(i==null?void 0:i.has(e.session.sessionId))??!1,awaitingUser:(s==null?void 0:s.has(e.session.sessionId))??!1,onSelect:()=>o(e.session.sessionId),onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,showCopyResume:p,ownerPrincipalId:m,creatorDisplayName:e.session.creatorPrincipalId?v==null?void 0:v(e.session.creatorPrincipalId):void 0,dispatchedFromSessionTitle:e.session.dispatchedFromSessionId?(w==null?void 0:w(e.session.dispatchedFromSessionId))??((_==null?void 0:_.sessionId)===e.session.dispatchedFromSessionId?iy(_):void 0):void 0,depth:t,chevron:N,contactDisplayName:e.session.originOwnerPrincipalId?f==null?void 0:f(e.session.originOwnerPrincipalId):void 0}),x&&C?h.jsx("div",{"data-testid":`session-tree-children-${e.session.sessionId}`,children:e.children.map(T=>h.jsx(Ty,{node:T,depth:t+1,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:v,getSessionDisplayName:w,parentSession:e.session},T.session.sessionId))}):null]})}function dV(e){return e.forkedFromSessionId??e.dispatchedFromSessionId??e.shiftFiredFromSessionId}function Iy(e,t){return e.updatedAt<t.updatedAt?1:e.updatedAt>t.updatedAt?-1:0}function YR(e){e=e.filter(s=>!s.ephemeral&&s.deployId===void 0);const t=new Map;for(const s of e)t.set(s.sessionId,s);const n=new Map,r=[];for(const s of e){const o=dV(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(Iy);return{session:s,children:a.map(i)}};return[...r].sort(hV).map(i)}function XR(e){return[...e].sort((t,n)=>Iy(t.session,n.session))}function hV(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?1:Iy(e,t)}function fV(e){return e.label?e.label:e.aiLabel?e.aiLabel:e.cwd.split("/").filter(Boolean).pop()??""}function NS(e,t){const n=t.trim().toLowerCase();return n===""?!0:e.toLowerCase().includes(n)}const pV={isCollapsed:()=>!1,toggle:()=>{},prune:()=>{}};function mV({personas:e,activePersonaId:t,onSelectPersona:n,onCreateSession:r,sessions:i,activeSessionId:s,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,isPersonaExpanded:p,onTogglePersonaExpanded:m,onEditSession:v,onPinSession:w,showCopyResume:_,treatSessionsAsRoots:x,searchQuery:b}){const[S,C]=g.useState(null),[k,N]=g.useState(()=>new Set),T=p??(D=>k.has(D)),z=g.useCallback(D=>{if(m){m(D);return}N($=>{const F=new Set($);return F.has(D)?F.delete(D):F.add(D),F})},[m]),P=g.useMemo(()=>i==null?void 0:i.filter(D=>!D.ephemeral),[i]),B=g.useMemo(()=>new Map((P??[]).map(D=>[D.sessionId,iy(D)])),[P]),A=g.useCallback(D=>f==null?void 0:f.get(D),[f]),R=g.useCallback(D=>B.get(D),[B]);if(e.length===0)return h.jsx(gV,{});const M=(b??"").trim();return M?h.jsx(Yx.Provider,{value:pV,children:h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(D=>{const $=P?P.filter(E=>E.ownerPersonaId===D.personaId).sort((E,H)=>H.updatedAt>E.updatedAt?1:-1):[],F=NS(D.label,M),j=$.filter(E=>NS(fV(E),M));if(!F&&j.length===0)return null;const O=F?$:j;return h.jsx(TS,{persona:D,active:D.personaId===t,editing:!1,onSelectPersona:n,onSubmitCreateSession:()=>{},onCancelCreateSession:()=>{},personaSessions:O,collapsed:!1,onToggleCollapsed:()=>{},activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:w,showCopyResume:_,treatSessionsAsRoots:x,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:A,getSessionDisplayName:R},D.personaId)})})}):h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(D=>{const $=P?P.filter(F=>F.ownerPersonaId===D.personaId).sort((F,j)=>j.updatedAt>F.updatedAt?1:-1):[];return h.jsx(TS,{persona:D,active:D.personaId===t,editing:D.personaId===S,onSelectPersona:n,onStartCreateSession:r?()=>C(D.personaId):void 0,onSubmitCreateSession:F=>{C(null),r==null||r(D.personaId,F)},onCancelCreateSession:()=>C(null),personaSessions:$,collapsed:!T(D.personaId),onToggleCollapsed:()=>z(D.personaId),activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:w,showCopyResume:_,treatSessionsAsRoots:x,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:A,getSessionDisplayName:R},D.personaId)})})}function gV(){return h.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-text-400",children:"还没有 persona。点上方 Personas 标题右侧 + 创建第一个。"})}function TS({persona:e,active:t,editing:n,onSelectPersona:r,onStartCreateSession:i,onSubmitCreateSession:s,onCancelCreateSession:o,personaSessions:a,collapsed:l,onToggleCollapsed:c,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:w,onPinSession:_,showCopyResume:x,treatSessionsAsRoots:b,ownerPrincipalId:S,creatorDisplayNameByOwnerId:C,getCreatorDisplayName:k,getSessionDisplayName:N}){const T=a.length>0,z=!l,P=g.useMemo(()=>{const R=[],M=new Map;for(const D of a){const $=D.creatorPrincipalId;if(D.larkChatId!=null||!$||S&&$===S){R.push(D);continue}const F=$,j=(C==null?void 0:C.get(F))??`…${F.slice(-8)}`,O=M.get(F);O?O.sessions.push(D):M.set(F,{groupKey:F,displayName:j,sessions:[D]})}return{self:R,byPeer:[...M.values()]}},[a,S,C]),B=P.byPeer.length>0,A=g.useMemo(()=>z&&!B?XR(YR(a)):[],[z,B,a]);return h.jsxs("div",{"data-testid":`persona-node-${e.personaId}`,children:[h.jsxs("div",{className:ne("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":z?"collapse":"expand","aria-expanded":z,"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:z?h.jsx(Yn,{className:"h-3 w-3"}):h.jsx(Bn,{className:"h-3 w-3"})}):h.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),h.jsx(dp,{tool:e.tool,className:ne("h-3.5 w-3.5 shrink-0",hp(e.tool))}),h.jsx("span",{className:"flex-1 truncate text-[13px]",children:e.label}),T?h.jsx("span",{className:"shrink-0 text-[10px] text-text-400 tabular-nums","aria-label":`${a.length} sessions`,children:a.length}):null,i?h.jsx("button",{type:"button",onClick: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(tF,{className:"h-3.5 w-3.5"})}):null]}),n?h.jsx(vV,{personaId:e.personaId,tool:e.tool,onSubmit:s,onCancel:o}):null,T&&z?h.jsx("div",{"data-testid":`persona-sessions-${e.personaId}`,children:B?h.jsxs(h.Fragment,{children:[P.self.length>0&&h.jsx(IS,{groupKey:`${e.personaId}-self`,label:"我自己",testId:`persona-sessions-${e.personaId}-self`,sessions:P.self,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:w,onPinSession:_,showCopyResume:x,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N}),P.byPeer.map(R=>h.jsx(IS,{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:w,onPinSession:_,showCopyResume:x,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N},`${e.personaId}-peer-${R.groupKey}`))]}):A.map(R=>h.jsx(Ty,{node:R,depth:b?0:1,activeId:u,unreadIds:p,runningIds:f,awaitingIds:d,onSelect:M=>m==null?void 0:m(M),onDelete:v,onEdit:w,onPin:_,showCopyResume:x,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N},R.session.sessionId))}):null]})}function IS({label:e,testId:t,sessions:n,activeSessionId:r,awaitingIds:i,runningIds:s,unreadIds:o,onSelectSession:a,onDeleteSession:l,onEditSession:c,onPinSession:u,showCopyResume:d,ownerPrincipalId:f,getCreatorDisplayName:p,getSessionDisplayName:m}){const[v,w]=g.useState(!1),_=!v,x=g.useMemo(()=>_?XR(YR(n)):[],[_,n]);return h.jsxs("div",{"data-testid":t,children:[h.jsxs("button",{type:"button",onClick:()=>w(b=>!b),"aria-label":_?"collapse":"expand","aria-expanded":_,"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:[_?h.jsx(Yn,{className:"h-3 w-3"}):h.jsx(Bn,{className:"h-3 w-3"}),h.jsx(TI,{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})]}),_&&h.jsx("div",{children:x.map(b=>h.jsx(Ty,{node:b,depth:2,activeId:r,unreadIds:o,runningIds:s,awaitingIds:i,onSelect:S=>a==null?void 0:a(S),onDelete:l,onEdit:c,onPin:u,showCopyResume:d,ownerPrincipalId:f,getCreatorDisplayName:p,getSessionDisplayName:m},b.session.sessionId))})]})}function vV({personaId:e,tool:t,onSubmit:n,onCancel:r}){const[i,s]=g.useState(""),o=g.useRef(null),a=i.trim(),l=a.length>0;g.useEffect(()=>{var d;(d=o.current)==null||d.focus()},[]);const c=g.useCallback(()=>{l&&n(a)},[l,a,n]),u=Iu(c,r);return h.jsxs("div",{className:"flex items-center gap-1.5 pl-9 pr-2 py-1","data-testid":`persona-new-session-row-${e}`,children:[h.jsx(dp,{tool:t,className:ne("h-3 w-3 shrink-0",hp(t))}),h.jsx("input",{ref:o,type:"text",value:i,onChange:d=>s(d.target.value),...u,onBlur:r,placeholder:"session label...","data-testid":`persona-new-session-input-${e}`,className:"flex-1 min-w-0 bg-bg-100 border border-text-100/15 rounded px-1.5 py-0.5 text-[12px] text-text-100 placeholder:text-text-400 focus:outline-none focus:border-text-100/40"}),h.jsx("button",{type:"button",onMouseDown:d=>{d.preventDefault(),c()},disabled:!l,"aria-label":"确认",title:"确认(Enter)","data-testid":`persona-new-session-confirm-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-text-300",children:h.jsx(bu,{className:"h-3 w-3"})}),h.jsx("button",{type:"button",onMouseDown:d=>{d.preventDefault(),r()},"aria-label":"取消",title:"取消(Esc)","data-testid":`persona-new-session-cancel-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100",children:h.jsx(qr,{className:"h-3 w-3"})})]})}function _V(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function xV(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),r=parseFloat(n.fontSize);return t*r}function yV(e){return e/100*window.innerHeight}function bV(e){return e/100*window.innerWidth}function wV(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function ic({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=wV(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=xV(t,i);break}case"em":{r=_V(t,i);break}case"vh":{r=yV(i);break}case"vw":{r=bV(i);break}}return r}function An(e){return parseFloat(e.toFixed(3))}function Ja({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 E0(e){const{panels:t}=e,n=Ja({group:e});return n===0?t.map(r=>({groupResizeBehavior:r.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:r.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:r.panelConstraints.disabled,minSize:0,maxSize:100,panelId:r.id})):t.map(r=>{const{element:i,panelConstraints:s}=r;let o=0;if(s.collapsedSize!==void 0){const u=ic({groupSize:n,panelElement:i,styleProp:s.collapsedSize});o=An(u/n*100)}let a;if(s.defaultSize!==void 0){const u=ic({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=An(u/n*100)}let l=0;if(s.minSize!==void 0){const u=ic({groupSize:n,panelElement:i,styleProp:s.minSize});l=An(u/n*100)}let c=100;if(s.maxSize!==void 0){const u=ic({groupSize:n,panelElement:i,styleProp:s.maxSize});c=An(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 lt(e,t="Assertion error"){if(!e)throw Error(t)}function N0(e,t){return Array.from(t).sort(e==="horizontal"?SV:kV)}function SV(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function kV(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function QR(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function ZR(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 CV({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}=ZR(r,o),c=e==="horizontal"?a:l;c<s&&(s=c,i=o)}return lt(i,"No rect found"),i}let Sd;function EV(){return Sd===void 0&&(typeof matchMedia=="function"?Sd=!!matchMedia("(pointer:coarse)").matches:Sd=!1),Sd}function JR(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=N0(n,Array.from(t.children).filter(QR).map(m=>({element:m}))).map(({element:m})=>m),o=[];let a=!1,l=!1,c=-1,u=-1,d=0,f,p=[];{let m=-1;for(const v of s)v.hasAttribute("data-panel")&&(m++,v.hasAttribute("data-disabled")||(d++,c===-1&&(c=m),u=m))}if(d>1){let m=-1;for(const v of s)if(v.hasAttribute("data-panel")){m++;const w=r.find(_=>_.element===v);if(w){if(f){const _=f.element.getBoundingClientRect(),x=v.getBoundingClientRect();let b;if(l){const S=n==="horizontal"?new DOMRect(_.right,_.top,0,_.height):new DOMRect(_.left,_.bottom,_.width,0),C=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=[S,C];break}case 1:{const k=p[0],N=CV({orientation:n,rects:[_,x],targetRect:k.element.getBoundingClientRect()});b=[k,N===_?C:S];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 S of b){let C="width"in S?S:S.element.getBoundingClientRect();const k=EV()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(C.width<k){const T=k-C.width;C=new DOMRect(C.x-T/2,C.y,C.width+T,C.height)}if(C.height<k){const T=k-C.height;C=new DOMRect(C.x,C.y-T/2,C.width,C.height+T)}const N=m<=c||m>u;!a&&!N&&o.push({group:e,groupSize:Ja({group:e}),panels:[f,w],separator:"width"in S?void 0:S,rect:C}),a=!1}}l=!1,f=w,p=[]}}else if(v.hasAttribute("data-separator")){v.ariaDisabled!==null&&(a=!0);const w=i.find(_=>_.element===v);w?p.push(w):(f=void 0,p=[])}else l=!0}return o}var _s;class eM{constructor(){N1(this,_s,{})}addListener(t,n){const r=Rl(this,_s)[t];return r===void 0?Rl(this,_s)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=Rl(this,_s)[t];if(r!==void 0)if(r.length===1)r[0].call(null,n);else{let i=!1,s=null;const o=Array.from(r);for(let a=0;a<o.length;a++){const l=o[a];try{l.call(null,n)}catch(c){s===null&&(i=!0,s=c)}}if(i)throw s}}removeAllListeners(){T1(this,_s,{})}removeListener(t,n){const r=Rl(this,_s)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}_s=new WeakMap;let Da={cursorFlags:0,state:"inactive"};const Py=new eM;function Po(){return Da}function NV(e){return Py.addListener("change",e)}function TV(e){const t=Da,n={...Da};n.cursorFlags=e,Da=n,Py.emit("change",{prev:t,next:n})}function ja(e){const t=Da;Da=e,Py.emit("change",{prev:t,next:e})}const IV=e=>e,Hm=()=>{},tM=1,nM=2,rM=4,iM=8,PS=3,RS=12;let kd;function MS(){return kd===void 0&&(kd=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(kd=!0)),kd}function PV({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case"active":case"hover":t.forEach(s=>{if(!s.mutableState.disableCursor)switch(s.orientation){case"horizontal":{r++;break}case"vertical":{i++;break}}})}if(!(r===0&&i===0)){switch(n){case"active":{if(e&&MS()){const s=(e&tM)!==0,o=(e&nM)!==0,a=(e&rM)!==0,l=(e&iM)!==0;if(s)return a?"se-resize":l?"ne-resize":"e-resize";if(o)return a?"sw-resize":l?"nw-resize":"w-resize";if(a)return"s-resize";if(l)return"n-resize"}break}}return MS()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const AS=new WeakMap;function Ry(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=AS.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));const r=Po();switch(r.state){case"active":case"hover":{const i=PV({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(o=>o.group),state:r.state}),s=`*, *:hover {cursor: ${i} !important; }`;if(t===s)return;t=s,i?n.cssRules.length===0?n.insertRule(s):n.replaceSync(s):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}AS.set(e,{prevStyle:t,styleSheet:n})}let ai=new Map;const sM=new eM;function RV(e){ai=new Map(ai),ai.delete(e)}function LS(e,t){for(const[n]of ai)if(n.id===e)return n}function Ms(e,t){for(const[n,r]of ai)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Vo(){return ai}function My(e,t){return sM.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function qi(e,t,n){const r=ai.get(e);ai=new Map(ai),ai.set(e,t),sM.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:r,next:t})}function oM(e){const t=Po();let n=!1;switch(t.state){case"active":ja({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(Ry(e),n=!0,t.hitRegions.forEach(r=>{const i=Ms(r.group.id,!0);qi(r.group,i,{isUserInteraction:!0})}))}return n}function DS(e){e.defaultPrevented||oM(e.currentTarget)}function MV(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const o=ZR(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 AV(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function LV(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:BS(e),b:BS(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();lt(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:OS(jS(n.a)),b:OS(jS(n.b))};if(i.a===i.b){const s=r.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const l=s[a];if(l===o.a)return 1;if(l===o.b)return-1}}return Math.sign(i.a-i.b)}const DV=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function jV(e){const t=getComputedStyle(aM(e)??e).display;return t==="flex"||t==="inline-flex"}function OV(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||jV(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||DV.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function jS(e){let t=e.length;for(;t--;){const n=e[t];if(lt(n,"Missing node"),OV(n))return n}return null}function OS(e){return e&&Number(getComputedStyle(e).zIndex)||0}function BS(e){const t=[];for(;e;)t.push(e),e=aM(e);return t}function aM(e){const{parentNode:t}=e;return AV(t)?t.host:t}function BV(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 zV({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!QR(n)||n.contains(e)||e.contains(n))return!0;if(LV(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(BV(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Ay(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=JR(i),o=MV(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&zV({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function $V(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function wn(e,t,n=0){return Math.abs(An(e)-An(t))<=n}function ri(e,t){return wn(e,t)?0:e>t?1:-1}function ka({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(ri(r,l)<0)if(s){const c=(i+l)/2;ri(r,c)<0?r=i:r=l}else r=l;return r=Math.min(a,r),r=An(r),r}function ou({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(wn(e,0))return t;const o=s==="imperative-api",a=Object.values(t),l=Object.values(i),c=[...a],[u,d]=r;lt(u!=null,"Invalid first pivot index"),lt(d!=null,"Invalid second pivot index");let f=0;switch(s){case"keyboard":{{const v=e<0?d:u,w=n[v];lt(w,`Panel constraints not found for index ${v}`);const{collapsedSize:_=0,collapsible:x,minSize:b=0}=w;if(x){const S=a[v];if(lt(S!=null,`Previous layout not found for panel index ${v}`),wn(S,_)){const C=b-S;ri(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}{const v=e<0?u:d,w=n[v];lt(w,`No panel constraints found for index ${v}`);const{collapsedSize:_=0,collapsible:x,minSize:b=0}=w;if(x){const S=a[v];if(lt(S!=null,`Previous layout not found for panel index ${v}`),wn(S,b)){const C=S-_;ri(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}break}default:{const v=e<0?d:u,w=n[v];lt(w,`Panel constraints not found for index ${v}`);const _=a[v],{collapsible:x,collapsedSize:b,minSize:S}=w;if(x&&ri(_,S)<0)if(e>0){const C=S-b,k=C/2,N=_+e;ri(N,S)<0&&(e=ri(e,k)<=0?0:C)}else{const C=S-b,k=100-C/2,N=_-e;ri(N,S)<0&&(e=ri(100+e,k)>0?0:-C)}break}}{const v=e<0?1:-1;let w=e<0?d:u,_=0;for(;;){const b=a[w];lt(b!=null,`Previous layout not found for panel index ${w}`);const S=ka({overrideDisabledPanels:o,panelConstraints:n[w],prevSize:b,size:100})-b;if(_+=S,w+=v,w<0||w>=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 w=Math.abs(e)-Math.abs(f),_=a[v];lt(_!=null,`Previous layout not found for panel index ${v}`);const x=_-w,b=ka({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:_,size:x});if(!wn(_,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($V(l,c))return i;{const v=e<0?d:u,w=a[v];lt(w!=null,`Previous layout not found for panel index ${v}`);const _=w+f,x=ka({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:w,size:_});if(c[v]=x,!wn(x,_)){let b=_-x,S=e<0?d:u;for(;S>=0&&S<n.length;){const C=c[S];lt(C!=null,`Previous layout not found for panel index ${S}`);const k=C+b,N=ka({overrideDisabledPanels:o,panelConstraints:n[S],prevSize:C,size:k});if(wn(C,N)||(b-=N-C,c[S]=N),wn(b,0))break;e>0?S--:S++}}}const p=Object.values(c).reduce((v,w)=>w+v,0);if(!wn(p,100,.1))return i;const m=Object.keys(i);return c.reduce((v,w,_)=>(v[m[_]]=w,v),{})}function Ro(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||ri(e[n],t[n])!==0)return!1;return!0}function Mo({layout:e,panelConstraints:t}){const n=Object.values(e),r=[...n],i=r.reduce((a,l)=>a+l,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(a=>`${a}%`).join(", ")}`);if(!wn(i,100)&&r.length>0)for(let a=0;a<t.length;a++){const l=r[a];lt(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];lt(l!=null,`No layout data found for index ${a}`);const c=r[a];lt(c!=null,`No layout data found for index ${a}`);const u=ka({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});c!=u&&(s+=c-u,r[a]=u)}if(!wn(s,0))for(let a=0;a<t.length;a++){const l=r[a];lt(l!=null,`No layout data found for index ${a}`);const c=l+s,u=ka({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});if(l!==u&&(s-=u-l,r[a]=u,wn(s,0)))break}const o=Object.keys(e);return r.reduce((a,l,c)=>(a[o[c]]=l,a),{})}function lM({groupId:e,panelId:t}){const n=()=>{const l=Vo();for(const[c,{defaultLayoutDeferred:u,derivedPanelConstraints:d,layout:f,groupSize:p,separatorToPanels:m}]of l)if(c.id===e)return{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:c,groupSize:p,layout:f,separatorToPanels:m};throw Error(`Group ${e} not found`)},r=()=>{const l=n().derivedPanelConstraints.find(c=>c.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const l=n().group.panels.find(c=>c.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const l=n().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:l,panels:c,prevLayout:u,derivedPanelConstraints:d})=>{const f=s(),p=c.findIndex(w=>w.id===t),m=p===0,v=p===c.length-1;if(v&&l<f&&(m||c.slice(0,p).every((w,_)=>{const x=d[_];return(x==null?void 0:x.collapsible)&&wn(x.collapsedSize,u[x.panelId])}))){const w=c.slice(0,p).reduce((_,x)=>_+u[x.id],0);return{...u,[t]:An(100-w)}}return ou({delta:v?f-l:l-f,initialLayout:u,panelConstraints:d,pivotIndices:v?[p-1,p]:[p,p+1],prevLayout:u,trigger:"imperative-api"})},a=l=>{const c=s();if(l===c)return;const{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:f,groupSize:p,layout:m,separatorToPanels:v}=n(),w=o({nextSize:l,panels:f.panels,prevLayout:m,derivedPanelConstraints:d}),_=Mo({layout:w,panelConstraints:d});Ro(m,_)||qi(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&&wn(c,u)},resize:l=>{const{group:c}=n(),{element:u}=i(),d=Ja({group:c}),f=ic({groupSize:d,panelElement:u,styleProp:l}),p=An(f/d*100);a(p)}}}function zS(e){if(e.defaultPrevented)return;const t=Vo();Ay(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=lM({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function sh(e){const t=Vo();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 cM({groupId:e}){const t=()=>{const n=Vo();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=Mo({layout:n,panelConstraints:i});return r?a:(Ro(a,c)||qi(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:o,layout:c,separatorToPanels:l}),c)}}}function to(e,t){const n=sh(e),r=Ms(n.id,!0),i=n.separators.find(u=>u.element===e);lt(i,"Matching separator not found");const s=r.separatorToPanels.get(i);lt(s,"Matching panels not found");const o=s.map(u=>n.panels.indexOf(u)),a=cM({groupId:n.id}).getLayout(),l=ou({delta:t,initialLayout:a,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),c=Mo({layout:l,panelConstraints:r.derivedPanelConstraints});Ro(a,c)||qi(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function $S(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=sh(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&to(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&to(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&to(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&to(t,-5);break}case"End":{e.preventDefault(),to(t,100);break}case"Enter":{e.preventDefault();const r=sh(t),i=Ms(r.id,!0),{derivedPanelConstraints:s,layout:o,separatorToPanels:a}=i,l=r.separators.find(f=>f.element===t);lt(l,"Matching separator not found");const c=a.get(l);lt(c,"Matching panels not found");const u=c[0],d=s.find(f=>f.panelId===u.id);if(lt(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;to(t,p-f)}break}case"F6":{e.preventDefault();const r=sh(t).separators.map(o=>o.element),i=Array.from(r).findIndex(o=>o===e.currentTarget);lt(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(),to(t,-100);break}}}function FS(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=Vo(),n=Ay(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)}),ja({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function uM({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:s,prevCursorFlags:o}){let a=0;n.forEach(c=>{const{group:u,groupSize:d}=c,{orientation:f,panels:p}=u,{disableCursor:m}=u.mutableState;let v=0;s?f==="horizontal"?v=(t.clientX-s.x)/d*100:v=(t.clientY-s.y)/d*100:f==="horizontal"?v=t.clientX<0?-100:100:v=t.clientY<0?-100:100;const w=r.get(u),_=i.get(u);if(!w||!_)return;const{defaultLayoutDeferred:x,derivedPanelConstraints:b,groupSize:S,layout:C,separatorToPanels:k}=_;if(b&&C&&k){const N=ou({delta:v,initialLayout:w,panelConstraints:b,pivotIndices:c.panels.map(T=>p.indexOf(T)),prevLayout:C,trigger:"mouse-or-touch"});if(Ro(N,C)){if(v!==0&&!m)switch(f){case"horizontal":{a|=v<0?tM:nM;break}case"vertical":{a|=v<0?rM:iM;break}}}else qi(c.group,{defaultLayoutDeferred:x,derivedPanelConstraints:b,groupSize:S,layout:N,separatorToPanels:k})}});let l=0;t.movementX===0?l|=o&PS:l|=a&PS,t.movementY===0?l|=o&RS:l|=a&RS,TV(l),Ry(e)}function HS(e){const t=Vo(),n=Po();switch(n.state){case"active":uM({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function US(e){var r,i;if(e.defaultPrevented)return;const t=Po(),n=Vo();switch(t.state){case"active":{if(e.buttons===0){ja({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const o=Ms(s.group.id,!0);qi(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))}uM({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=Ay(e,n);s.length===0?t.state!=="inactive"&&ja({cursorFlags:0,state:"inactive"}):ja({cursorFlags:0,hitRegions:s,state:"hover"}),Ry(e.currentTarget);break}}}function WS(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Po().state){case"hover":ja({cursorFlags:0,state:"inactive"})}}function VS(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||oM(e.currentTarget)&&e.preventDefault()}function qS(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const o=An(s.defaultSize);n+=o,r[s.panelId]=o}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=An((100-n)/i);for(const o of e)o.defaultSize===void 0&&(r[o.panelId]=s)}return r}function FV(e,t,n){if(!n[0])return;const r=e.panels.find(l=>l.element===t);if(!r||!r.onResize)return;const i=Ja({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,a={asPercentage:An(s/i*100),inPixels:s};r.mutableValues.prevSize=a,r.onResize(a,r.id,o)}function HV(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 UV({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=An(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]=An(f/s*c)}else{const d=An(c/l.length);for(const f of l)u[f]=d}return u}function WV(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 ra=new Map;function VV(e){let t=!0;lt(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,s=new n(m=>{for(const v of m){const{borderBoxSize:w,target:_}=v;if(_===e.element){if(t){const x=Ja({group:e});if(x===0)return;const b=Ms(e.id);if(!b)return;const S=E0(e),C=b.defaultLayoutDeferred?qS(S):b.layout,k=UV({group:e,nextGroupSize:x,prevGroupSize:b.groupSize,prevLayout:C}),N=Mo({layout:k,panelConstraints:S});if(!b.defaultLayoutDeferred&&Ro(b.layout,N)&&HV(b.derivedPanelConstraints,S)&&b.groupSize===x)return;qi(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:S,groupSize:x,layout:N,separatorToPanels:b.separatorToPanels})}}else FV(e,_,w)}});s.observe(e.element),e.panels.forEach(m=>{lt(!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=Ja({group:e}),a=E0(e),l=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(WV(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[l]??c??qS(a),d=Mo({layout:u,panelConstraints:a}),f=e.element.ownerDocument;ra.set(f,(ra.get(f)??0)+1);const p=new Map;return JR(e).forEach(m=>{m.separator&&p.set(m.separator,m.panels)}),qi(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:a,groupSize:o,layout:d,separatorToPanels:p}),e.separators.forEach(m=>{lt(!i.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),i.add(m.id),m.element.addEventListener("keydown",$S)}),ra.get(f)===1&&(f.addEventListener("contextmenu",DS,!0),f.addEventListener("dblclick",zS,!0),f.addEventListener("pointerdown",FS,!0),f.addEventListener("pointerleave",HS),f.addEventListener("pointermove",US),f.addEventListener("pointerout",WS),f.addEventListener("pointerup",VS,!0)),function(){t=!1,ra.set(f,Math.max(0,(ra.get(f)??0)-1)),RV(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",$S)}),ra.get(f)||(f.removeEventListener("contextmenu",DS,!0),f.removeEventListener("dblclick",zS,!0),f.removeEventListener("pointerdown",FS,!0),f.removeEventListener("pointerleave",HS),f.removeEventListener("pointermove",US),f.removeEventListener("pointerout",WS),f.removeEventListener("pointerup",VS,!0)),s.disconnect()}}function qV(){const[e,t]=g.useState({}),n=g.useCallback(()=>t({}),[]);return[e,n]}function Ly(e){const t=g.useId();return`${e??t}`}const qo=typeof window<"u"?g.useLayoutEffect:g.useEffect;function kc(e){const t=g.useRef(e);return qo(()=>{t.current=e},[e]),g.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function Dy(...e){return kc(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function jy(e){const t=g.useRef({...e});return qo(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const dM=g.createContext(null);function KV(e,t){const n=g.useRef({getLayout:()=>({}),setLayout:IV});g.useImperativeHandle(t,()=>n.current,[]),qo(()=>{Object.assign(n.current,cM({groupId:e}))})}function Oy({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:s,groupRef:o,id:a,onLayoutChange:l,onLayoutChanged:c,orientation:u="horizontal",resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){const m=g.useRef({onLayoutChange:{},onLayoutChanged:{}}),v=kc(B=>{Ro(m.current.onLayoutChange,B)||(m.current.onLayoutChange=B,l==null||l(B))}),w=kc((B,A)=>{Ro(m.current.onLayoutChanged,B)||(m.current.onLayoutChanged=B,c==null||c(B,{isUserInteraction:A}))}),_=Ly(a),x=g.useRef(null),[b,S]=qV(),C=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),k=Dy(x,s);KV(_,o);const N=kc((B,A)=>{const R=Po(),M=LS(B),D=Ms(B);if(D){let $=!1;switch(R.state){case"active":{$=R.hitRegions.some(F=>F.group===M);break}}return{flexGrow:D.layout[A]??1,pointerEvents:$?"none":void 0}}if(n!=null&&n[A])return{flexGrow:n==null?void 0:n[A]}}),T=jy({defaultLayout:n,disableCursor:r}),z=g.useMemo(()=>({get disableCursor(){return!!T.disableCursor},getPanelStyles:N,id:_,orientation:u,registerPanel:B=>{const A=C.current;return A.panels=N0(u,[...A.panels,B]),S(),()=>{A.panels=A.panels.filter(R=>R!==B),S()}},registerSeparator:B=>{const A=C.current;return A.separators=N0(u,[...A.separators,B]),S(),()=>{A.separators=A.separators.filter(R=>R!==B),S()}},updatePanelProps:(B,{disabled:A})=>{const R=C.current.panels.find($=>$.id===B);R&&(R.panelConstraints.disabled=A);const M=LS(_),D=Ms(_);M&&D&&qi(M,{...D,derivedPanelConstraints:E0(M)})},updateSeparatorProps:(B,{disabled:A,disableDoubleClick:R})=>{const M=C.current.separators.find(D=>D.id===B);M&&(M.disabled=A,M.disableDoubleClick=R)}}),[N,_,S,u,T]),P=g.useRef(null);return qo(()=>{const B=x.current;if(B===null)return;const A=C.current;let R;if(T.defaultLayout!==void 0&&Object.keys(T.defaultLayout).length===A.panels.length){R={};for(const E of A.panels){const H=T.defaultLayout[E.id];H!==void 0&&(R[E.id]=H)}}const M={disabled:!!i,element:B,id:_,mutableState:{defaultLayout:R,disableCursor:!!T.disableCursor,expandedPanelSizes:C.current.lastExpandedPanelSizes,layouts:C.current.layouts},orientation:u,panels:A.panels,resizeTargetMinimumSize:A.resizeTargetMinimumSize,separators:A.separators};P.current=M;const D=VV(M),{defaultLayoutDeferred:$,derivedPanelConstraints:F,layout:j}=Ms(M.id,!0);!$&&F.length>0&&(v(j),w(j,!1));const O=My(_,E=>{const{defaultLayoutDeferred:H,derivedPanelConstraints:q,layout:L}=E.next;if(H||q.length===0)return;const re=M.panels.map(({id:K})=>K).join(",");M.mutableState.layouts[re]=L,q.forEach(K=>{if(K.collapsible){const{layout:ge}=E.prev??{};if(ge){const Re=wn(K.collapsedSize,L[K.panelId]),ce=wn(K.collapsedSize,ge[K.panelId]);Re&&!ce&&(M.mutableState.expandedPanelSizes[K.panelId]=ge[K.panelId])}}});const se=Po().state!=="active";v(L),se&&w(L,E.isUserInteraction)});return()=>{P.current=null,D(),O()}},[i,_,w,v,u,b,T]),g.useEffect(()=>{const B=P.current;B&&(B.mutableState.defaultLayout=n,B.mutableState.disableCursor=!!r)}),h.jsx(dM.Provider,{value:z,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})})}Oy.displayName="Group";function By(){const e=g.useContext(dM);return lt(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function GV(e,t){const{id:n}=By(),r=g.useRef({collapse:Hm,expand:Hm,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Hm});g.useImperativeHandle(t,()=>r.current,[]),qo(()=>{Object.assign(r.current,lM({groupId:n,panelId:e}))})}function df({children:e,className:t,collapsedSize:n="0%",collapsible:r=!1,defaultSize:i,disabled:s,elementRef:o,groupResizeBehavior:a="preserve-relative-size",id:l,maxSize:c="100%",minSize:u="0%",onResize:d,panelRef:f,style:p,...m}){const v=!!l,w=Ly(l),_=jy({disabled:s}),x=g.useRef(null),b=Dy(x,o),{getPanelStyles:S,id:C,orientation:k,registerPanel:N,updatePanelProps:T}=By(),z=d!==null,P=kc((M,D,$)=>{d==null||d(M,l,$)});qo(()=>{const M=x.current;if(M!==null){const D={element:M,id:w,idIsStable:v,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:z?P:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:c,minSize:u}};return N(D)}},[a,n,r,i,z,w,v,c,u,P,N,_]),g.useEffect(()=>{T(w,{disabled:s})},[s,w,T]),GV(w,f);const B=()=>{const M=S(C,w);if(M)return JSON.stringify(M)},A=g.useSyncExternalStore(M=>My(C,M),B,B);let R;return A?R=JSON.parse(A):i!==void 0?R={flexGrow:void 0,flexShrink:void 0,flexBasis:i}:R={flexGrow:1},h.jsx("div",{...m,"data-disabled":s||void 0,"data-panel":!0,"data-testid":w,id:w,ref:b,style:{...YV,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...R},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})})}df.displayName="Panel";const YV={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function XV({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=Mo({layout:ou({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=Mo({layout:ou({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:o}}function hM({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:s,style:o,...a}){const l=Ly(s),c=jy({disabled:n,disableDoubleClick:r}),[u,d]=g.useState({}),[f,p]=g.useState("inactive"),[m,v]=g.useState(!1),w=g.useRef(null),_=Dy(w,i),{disableCursor:x,id:b,orientation:S,registerSeparator:C,updateSeparatorProps:k}=By(),N=S==="horizontal"?"vertical":"horizontal";qo(()=>{const P=w.current;if(P!==null){const B={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:P,id:l},A=C(B),R=NV(D=>{p(D.next.state!=="inactive"&&D.next.hitRegions.some($=>$.separator===B)?D.next.state:"inactive")}),M=My(b,D=>{const{derivedPanelConstraints:$,layout:F,separatorToPanels:j}=D.next,O=j.get(B);if(O){const E=O[0],H=O.indexOf(E);d(XV({layout:F,panelConstraints:$,panelId:E.id,panelIndex:H}))}});return()=>{R(),M(),A()}}},[b,l,C,c]),g.useEffect(()=>{k(l,{disabled:n,disableDoubleClick:r})},[n,r,l,k]);let T;n&&!x&&(T="not-allowed");let z;if(n)z="disabled";else switch(f){case"active":{z="active";break}default:m?z="focus":z=f}return h.jsx("div",{...a,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":N,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":z,"data-testid":l,id:l,onBlur:()=>v(!1),onFocus:()=>v(!0),ref:_,role:"separator",style:{flexBasis:"auto",cursor:T,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}hM.displayName="Separator";function QV(e){if(!e)return;const t=e.contextUsage,n=e.contextWindowSize;if(!t||!n||n<=0)return;const r=t.inputTokens+(t.cacheReadTokens??0)+(t.cacheCreateTokens??0);if(!(r<=0))return Math.round(r/n*100)}function fM(e,t){const n=$o(),r=e?`session/${e}`:"",i=Ui(r)??eu,s=g.useCallback(d=>{!e||!r||n.setData(r,f=>fI(f??eu,d,e))},[n,r,e]),o=g.useCallback(()=>{e&&s({type:"session:change",sessionId:e})},[s,e]),a=g.useCallback(d=>{e&&s({type:"permission:clear",sessionId:e,requestId:d})},[s,e]),l=g.useCallback(d=>{e&&s({type:"permission:request",sessionId:e,requestId:d.requestId,tool:d.tool,input:d.input,...d.toolUseId?{toolUseId:d.toolUseId}:{}})},[s,e]),c=g.useCallback(d=>{e&&s({type:"session:question:clear",sessionId:e,toolUseId:d})},[s,e]),u=g.useCallback((d,f)=>{e&&s({type:"session:question:submitted",sessionId:e,toolUseId:d,answers:f})},[s,e]);return{...i,reset:o,clearPermission:a,restorePermission:l,clearQuestion:c,markQuestionSubmitted:u}}function ZV(e){return e.kind!=="user-text"?!1:e.meta===void 0||e.meta==="slash-command"||lp(e.meta)}function JV(e,t={}){let n=0;if(t.implicitCloseOnUserText){for(const r of e)ZV(r)&&n++;return n}for(const r of e)r.kind==="turn-end"&&n++;return n}const eq=50;function tq({api:e,sessionId:t,toolSessionId:n,initialTurns:r,implicitCloseOnUserText:i,pageSize:s=eq}){const[o,a]=g.useState({messages:[],total:0,loading:!1,error:null}),l=g.useRef(n),c=g.useRef(null),u=g.useRef(0),d=g.useRef(!0);return g.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),g.useEffect(()=>{const f=l.current;if(l.current=n,!(c.current!==t)&&!(typeof f=="string"&&f!==n))return;if(a({messages:[],total:0,loading:!1,error:null}),!t){c.current=null;return}c.current=t;const v=++u.current;a(w=>({...w,loading:!0,error:null})),(async()=>{let w=[],_=!1,x=r===void 0?{}:{limit:s},b=Number.POSITIVE_INFINITY;for(;;){let S;try{S=await e.historyRead({sessionId:t,...x})}catch(B){if(v!==u.current||!d.current)return;const A=B.message??"history load failed";a(_?R=>({...R,error:A}):{messages:[],total:0,loading:!1,error:A});return}if(v!==u.current||!d.current)return;w=[...S.messages??[],...w];const C=S.total??0,k=typeof S.offset=="number"?S.offset:0,N=k>=b,T=k<=0||N;b=k;const z=r!==void 0&&JV(w,{implicitCloseOnUserText:i})>=r;if(_?a({messages:w,total:C,loading:!1,error:null}):(T||z)&&(_=!0,a({messages:w,total:C,loading:!1,error:null})),T)return;const P=Math.max(0,k-s);x={offset:P,limit:k-P}}})()},[e,t,n,s,r]),o}const nq=["TaskCreate","TaskUpdate","TaskList","TaskGet"];function rq(e){return nq.includes(e)}function pM(e){return e==="in_progress"||e==="completed"?e:"pending"}function iq(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:pM(n.status),activeForm:i,description:s}]}function sq(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=pM(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 oq(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=iq(t,i.input);break;case"TaskUpdate":t=sq(t,i.input);break}}return{tasks:t,lastEventIndex:n}}function aq(e){return e==="TodoWrite"}function lq(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 cq(e,t,n){var s;const r=[],i=new Map;for(let o=0;o<e.length;o++){const a=e[o],l=typeof a.seq=="number"?a.seq:o;switch(a.kind){case"session_init":r.push({kind:"session-init",seq:l,toolSessionId:a.toolSessionId});break;case"text":KS(r,l,"assistant-text",a.text,a.partialId,a.uuid);break;case"thinking":KS(r,l,"assistant-thinking",a.text,a.partialId);break;case"user_text":{a.meta==="task-notification"?r.push({kind:"agent-notification",seq:l,text:a.text,taskId:a.taskId,parentToolUseId:a.parentToolUseId}):a.meta?r.push({kind:"user-meta",seq:l,metaKind:a.meta,text:a.text}):r.push({kind:"user-text",seq:l,text:a.text,uuid:a.uuid,...a.sender&&(a.sender.principal!=="owner"||oI.test(a.text))?{senderDisplayName:a.sender.displayName}:{},senderPrincipal:((s=a.sender)==null?void 0:s.principal)==="guest"?"guest":"owner"});break}case"tool_call":mM(r,l,a.toolUseId,a.tool,a.input,a.toolKind);break;case"tool_result":{const c=i.get(a.toolUseId);if(c!==void 0){if(a.askQuestionAnswers){const d=r[c];d.submittedAnswers=a.askQuestionAnswers}i.delete(a.toolUseId);break}const u={kind:"tool-result",seq:l,toolUseId:a.toolUseId,output:a.output,error:a.error};a.toolResultExtra&&(u.toolResultExtra=a.toolResultExtra),r.push(u);break}case"attachment_memories":r.push({kind:"memory-callout",seq:l,memories:a.memories});break;case"permission_request":{if(!t||a.requestId!==t)break;r.push({kind:"permission-inline",seq:l,requestId:a.requestId,tool:a.tool,input:a.input});break}case"ask_user_question":i.set(a.toolUseId,r.length),r.push({kind:"question-card",seq:l,toolUseId:a.toolUseId,questions:a.questions});break;case"turn_end":{const c={kind:"turn-end",seq:l};a.durationMs!==void 0&&(c.durationMs=a.durationMs),a.reason!==void 0&&(c.reason=a.reason),r.push(c);break}case"subagent_progress":{const c={kind:"agent-progress",seq:l,toolUseId:a.toolUseId,agentId:a.agentId,status:a.status};a.description&&(c.description=a.description),a.lastToolName&&(c.lastToolName=a.lastToolName),a.prompt&&(c.prompt=a.prompt),a.stats&&(c.stats=a.stats),r.push(c);break}case"error":r.push({kind:"error",seq:l,message:a.message});break}}return r}function mM(e,t,n,r,i,s){if(aq(r)){const o=lq(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(rq(r)){e.push({kind:"task-event",seq:t,toolUseId:n,name:r,input:i});return}e.push({kind:"tool-call",seq:t,toolUseId:n,tool:r,toolKind:s,input:i})}function KS(e,t,n,r,i,s){let o=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind===n){o=c;break}const a=o>=0?e[o]:null;if(i){if(a&&a.partialId===i){const u=n==="assistant-text"?{kind:n,seq:a.seq,text:a.text+r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:a.text+r,partialId:i};e[o]=u;return}const c=n==="assistant-text"?{kind:n,seq:t,text:r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r,partialId:i};e.push(c);return}if(a&&a.partialId){const c=n==="assistant-text"?{kind:n,seq:a.seq,text:r,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:r};e[o]=c;return}const l=n==="assistant-text"?{kind:n,seq:t,text:r,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r};e.push(l)}const uq="AskUserQuestion";function gM(e,t=0,n){var o;const r=[],i=new Map;let s=t;for(const a of e){const l=s++,c=a.toolUseId??`hist-${l}`;switch(a.kind){case"user-text":if(a.meta==="task-notification")r.push({kind:"agent-notification",seq:l,text:a.text??"",taskId:a.taskId,parentToolUseId:a.parentToolUseId});else if(a.meta)r.push({kind:"user-meta",seq:l,metaKind:a.meta,text:a.text??""});else{const u=oI.exec(a.text??""),d=(o=Sz.exec(a.text??""))==null?void 0:o[1],f=(u==null?void 0:u[2])??d,p=(u==null?void 0:u[1])==="guest"||d?"guest":"owner";r.push({kind:"user-text",seq:l,text:a.text??"",uuid:a.uuid,...f?{senderDisplayName:f}:{},senderPrincipal:p})}break;case"assistant-text":r.push({kind:"assistant-text",seq:l,text:a.text??"",uuid:a.uuid});break;case"tool_call":{if(a.tool===uq){const u=a.input??{},d=Array.isArray(u.questions)?u.questions:[];i.set(c,r.length),r.push({kind:"question-card",seq:l,toolUseId:c,questions:d});break}mM(r,l,c,a.tool??"",a.input,n);break}case"tool_result":{const u=i.get(c);if(u!==void 0){if(a.askQuestionAnswers){const f=r[u];f.submittedAnswers=a.askQuestionAnswers}i.delete(c);break}const d={kind:"tool-result",seq:l,toolUseId:c,output:a.output};a.error!==void 0&&(d.error=a.error),a.toolResultExtra&&(d.toolResultExtra=a.toolResultExtra),r.push(d);break}case"attachment_memories":a.memories&&a.memories.length>0&&r.push({kind:"memory-callout",seq:l,memories:a.memories});break;case"summary":break;case"turn-end":{const u={kind:"turn-end",seq:l};typeof a.durationMs=="number"&&(u.durationMs=a.durationMs),r.push(u);break}}}return r}const dq=5e5;function hq(e){const t=dq-e.length;return e.map(n=>({...n,seq:n.seq+t}))}const fq=/<command-name>([\s\S]*?)<\/command-name>/i,pq=/<command-message>([\s\S]*?)<\/command-message>/i,mq=/<command-args>([\s\S]*?)<\/command-args>/i,gq=/<(local-command-[a-z]+|command-(?:stdout|stderr))>[\s\S]*?<\/\1>/gi;function Np(e){if(!e)return{commandName:null,commandMessage:null,commandArgs:null,body:""};const t=e.match(fq),n=e.match(pq),r=e.match(mq);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(gq,""),i=i.trim(),{commandName:t?t[1].trim():null,commandMessage:n?n[1].trim():null,commandArgs:r?r[1].trim():null,body:i}}function GS(e){const t=Np(e);return t.commandName?t.commandArgs?`${t.commandName} ${t.commandArgs}`:t.commandName:e}function YS(e){return e.kind==="user-text"?!0:e.kind!=="user-meta"?!1:e.metaKind==="slash-command"||lp(e.metaKind)}function vq(e,t){const n=t.find(YS);if(!n)return e;const r=GS(n.text);for(let s=e.length-1;s>=0;s--){const o=e[s];if(YS(o)&&GS(o.text)===r)return e.slice(0,s)}const i=e[e.length-1];return i!==void 0&&i.kind!=="turn-end"?[...e,{kind:"turn-end",seq:i.seq+1}]:e}function _q(e){return e==="running"||e==="observing"}function vM(e){return e==="running"||e==="running-idle"||e==="observing"}const xq=1e6,yq=5;function _M(e){const t=Yi(),n=g.useMemo(()=>new Gx(t),[t]),r=Ui("sessions"),i=g.useMemo(()=>r==null?void 0:r.find(E=>E.sessionId===e),[r,e]),s=i==null?void 0:i.toolSessionId,o=i==null?void 0:i.tool,a=fM(e),{events:l,pendingPermissions:c,queued:u,status:d,clearPermission:f,restorePermission:p}=a,m=t$(),v=tq({api:n,sessionId:e,toolSessionId:s,initialTurns:m==="owner"?void 0:yq,implicitCloseOnUserText:o==="codex"}),w=g.useMemo(()=>v.messages.filter(E=>!E.isSidechain),[v.messages]),_=g.useMemo(()=>hq(gM(w,0,o)),[w,o]),x=c[0]??null,b=g.useMemo(()=>cq(l,(x==null?void 0:x.requestId)??null),[l,x==null?void 0:x.requestId]),S=g.useMemo(()=>vq(_,b),[_,b]),C=g.useMemo(()=>b.map((E,H)=>({...E,seq:xq+H})),[b]),k=g.useMemo(()=>[...S,...C],[S,C]),N=vM(d),T=_q(d),z=(i==null?void 0:i.resolvedModel)??(i==null?void 0:i.model),P=g.useMemo(()=>({sessionLabel:(i==null?void 0:i.label)||(i==null?void 0:i.aiLabel)||(i==null?void 0:i.larkChatName)||(i==null?void 0:i.larkChatId)||e,sessionId:e,...i!=null&&i.larkChatId?{larkChatName:i.larkChatName??i.larkChatId,larkChatType:i.larkChatType??"group"}:{},...z?{model:z}:{},...(()=>{const E=i==null?void 0:i.gitBranch;return E?{gitBranch:E}:{}})(),...(()=>{const E=QV(i);return E!==void 0?{contextPct:E}:{}})(),...i!=null&&i.cwd?{cwd:i.cwd}:{},...(()=>{const E=i==null?void 0:i.permissionMode;return E?{permissionMode:E}:{}})(),procAlive:N,streamInProgress:T,pinnedAt:(i==null?void 0:i.pinnedAt)??null}),[i,e,z,N,T]),B=g.useMemo(()=>t.isOpen?d==="error"?{kind:"error",message:"session error"}:{kind:"ready"}:{kind:"closed"},[t.isOpen,d]),A=g.useCallback(async(E,H)=>{await n.sessionSend(e,E,H)},[n,e]),R=g.useCallback(async E=>{await n.sessionDequeue(e,E)},[n,e]),M=g.useCallback(async()=>(await n.sessionInterrupt(e)).queued??[],[n,e]),D=g.useCallback(async E=>{if(!(i!=null&&i.cwd)||!s)throw new Error("fork requires sessionFile with cwd + toolSessionId");await n.sessionFork({cwd:i.cwd,toolSessionId:s,messageUuid:E})},[n,i==null?void 0:i.cwd,s]),$=g.useCallback(async E=>{await n.sessionRewind({sessionId:e,userMessageId:E,dryRun:!1})},[n,e]),F=g.useCallback(async E=>{await n.sessionUpdate(e,{model:E})},[n,e]),j=g.useCallback(async()=>{await n.sessionNew(e)},[n,e]),O=g.useCallback(async(E,H)=>{const q=c.find(L=>L.requestId===E);q&&f(E);try{await n.permissionRespond({sessionId:e,permissionRequestId:E,allow:H==="allow"})}catch(L){throw!((L==null?void 0:L.message)??"").startsWith("PERMISSION_REQUEST_STALE")&&q&&p(q),L}},[n,e,c,f,p]);return g.useMemo(()=>({lines:k,connState:B,meta:P,historyLoading:v.loading,historyError:v.error,pendingPermissions:c,queued:u,sendText:A,dequeue:R,interrupt:M,fork:D,rewind:$,switchModel:F,clearSession:j,respondPermission:O}),[k,B,P,v.loading,v.error,c,u,A,R,M,D,$,F,j,O])}const bq={codex:"on-request",claude:"bypassPermissions",pi:"never"};function wq(e){const t={cwd:e.cwd,permissionMode:e.sourcePermissionMode??bq[e.sourceTool??"claude"]??"bypassPermissions",forkedFromSessionId:e.sourceSessionId};return e.sourceOwnerPersonaId&&(t.ownerPersonaId=e.sourceOwnerPersonaId),e.sourceTool&&(t.tool=e.sourceTool),e.sourceProjectPath&&(t.projectPath=e.sourceProjectPath),t}async function Sq(e,t,n,r={}){if(!t.toolSessionId)return null;const i=await e.sessionCreate({...wq({cwd:t.cwd,sourceSessionId:t.sessionId,sourcePermissionMode:t.permissionMode,sourceOwnerPersonaId:t.ownerPersonaId,sourceTool:t.tool,sourceProjectPath:t.projectPath}),...r.ephemeral?{ephemeral:!0}:{}});try{const{forkedToolSessionId:s}=await e.sessionFork({cwd:t.cwd,toolSessionId:t.toolSessionId,messageUuid:n,targetCwd:i.cwd});await e.sessionResume(i.sessionId,s)}catch(s){throw e.sessionDelete(i.sessionId).catch(o=>Me("quick-ask","fork rollback failed",o)),s}return i}async function kq(e,t,n){return Sq(e,t,n,{ephemeral:!0})}function Cd(e){return e!=null&&e.ephemeral!==!1}async function Cq(e,t){return t.stillEphemeral?(await e.sessionUpdate(t.sessionId,{ephemeral:!1}),!0):!1}function Eq(e){try{const t=new URL(e);return t.protocol==="ws:"?t.protocol="http:":t.protocol==="wss:"&&(t.protocol="https:"),`${t.protocol}//${t.host}`}catch{return e}}function Nq(e,t){try{const n=new URL(e),r=new URL(t);return n.protocol=r.protocol,n.host=r.host,n.toString()}catch{return e}}async function zy(e,t,n,r,i){const s=await e.attachmentSignUrl({sessionId:n,relPath:r,...i!==void 0?{ttlSeconds:i}:{}});return Nq(s.url,Eq(t.url))}async function XS(e,t,n,r,i=60,s){const o=window.open("about:blank","_blank");try{s&&await s();const a=await zy(e,t,n,r,i);o?o.location.href=a:window.open(a,"_blank")}catch(a){throw o&&o.close(),a}}async function Tq(e){var t;try{if((t=navigator.clipboard)!=null&&t.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.setAttribute("readonly",""),document.body.appendChild(n),n.select();const r=document.execCommand("copy");return document.body.removeChild(n),r}catch{return!1}}const Iq=300;function Pq(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function Rq(e,t){const n=Cx(),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>{let a=!1;return(async()=>{try{const l=await n.kv.get(e);if(a)return;const c=Pq(l);typeof c=="number"&&Number.isFinite(c)&&c>0?i(c):i(t)}catch{a||i(t)}})(),()=>{a=!0}},[n,e,t]);const o=g.useCallback(a=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{s.current=null,n.kv.set(e,a).catch(()=>{})},Iq)},[n,e]);return g.useEffect(()=>()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),{initialSize:r??t,setSize:o,loading:r===null}}function Mq(){return{quickAsk:null,mds:[],active:null}}function Aq(e,t){return{...e,quickAsk:{sessionId:t.sessionId,ephemeral:!0},active:"quick-ask"}}function Lq(e,t){const n=e.mds.includes(t);return{...e,mds:n?e.mds:[...e.mds,t],active:{kind:"md",relPath:t}}}function Dq(e){if(!e.quickAsk)return e;const t=e.active==="quick-ask",n=e.mds[0],r=t?n?{kind:"md",relPath:n}:null:e.active;return{...e,quickAsk:null,active:r}}function jq(e){return e.quickAsk?{...e,quickAsk:{...e.quickAsk,ephemeral:!1}}:e}function Oq(e,t){const n=e.mds.indexOf(t);if(n<0)return e;const r=e.mds.filter(l=>l!==t);if(!(e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===t))return{...e,mds:r};const s=r[n],o=n>0?r[n-1]:void 0;let a=null;return s?a={kind:"md",relPath:s}:o?a={kind:"md",relPath:o}:e.quickAsk&&(a="quick-ask"),{...e,mds:r,active:a}}function Bq(e,t){return{...e,active:t}}function zq(e,t){return e===null||t===null||e==="quick-ask"||t==="quick-ask"?e===t:e.relPath===t.relPath}function xM(e){return e.quickAsk!==null||e.mds.length>0}function $q(e,t,n,r=!0){const i=g.useRef({sid:null,tsid:void 0});g.useEffect(()=>{const s=i.current;i.current={sid:t,tsid:n},!(!r||!n||s.sid===t&&(s.tsid===void 0||s.tsid===null)&&typeof n=="string")&&e.sessionObserve({sessionId:t,toolSessionId:n}).catch(()=>{})},[e,t,n,r])}function Fq(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 Hq=/^Scheduled (?:recurring job|one-shot task) ([0-9a-f]{8}) \(([^)]+)\)/;function Uq(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(Hq);if(!a)continue;r.set(a[1],{id:a[1],cron:s.cron,prompt:s.prompt,recurring:s.recurring,humanSchedule:a[2],createdAt:s.ts,toolUseId:s.toolUseId});continue}const o=n.get(i.toolUseId);o!==void 0&&(n.delete(i.toolUseId),i.error||r.delete(o))}return Array.from(r.values()).sort((i,s)=>i.createdAt.localeCompare(s.createdAt))}function yM(e){var n;if(e.error)return!1;if(e.pending)return!0;if(e.notifications.length>0)return!1;const t=(n=e.progress)==null?void 0:n.status;return t==="running"?!0:t==="started"?Wq(e.input):!1}function Wq(e){return!e||typeof e!="object"?!1:e.run_in_background===!0}function Vq(e){return e.filter(t=>t.kind==="merged-agent"&&yM(t))}function bM(e){var d;const{tasks:t,lastEventIndex:n}=oq(e);let r=-1;for(let f=e.length-1;f>=0;f--)if(e[f].kind==="todo-checklist"){r=f;break}const i=[],s=new Map,o=new Map,a=new Map,l=new Map,c=new Map,u=(f,p)=>{var x,b,S,C,k,N;const m=i[f],v=c.get(f),w=v!==void 0&&v!==p.toolUseId;if(!w&&(((x=m.progress)==null?void 0:x.status)==="completed"||((b=m.progress)==null?void 0:b.status)==="failed"))return;if(c.set(f,p.toolUseId),l.set(p.agentId,f),w&&(m.pending=!0,(S=m.toolResultExtra)!=null&&S.stats)){const{stats:T,...z}=m.toolResultExtra;m.toolResultExtra=z}const _={agentId:p.agentId,status:p.status};p.description?_.description=p.description:(C=m.progress)!=null&&C.description&&(_.description=m.progress.description),p.lastToolName?_.lastToolName=p.lastToolName:!w&&((k=m.progress)!=null&&k.lastToolName)&&(_.lastToolName=m.progress.lastToolName),p.stats?_.stats=p.stats:!w&&((N=m.progress)!=null&&N.stats)&&(_.stats=m.progress.stats),m.progress=_,(p.status==="completed"||p.status==="failed")&&(m.pending=!1)};for(let f=0;f<e.length;f++){const p=e[f];switch(p.kind){case"tool-call":{const m={kind:"merged-tool",seq:p.seq,tool:p.tool,toolKind:p.toolKind,toolUseId:p.toolUseId,input:p.input,pending:!0};s.set(p.toolUseId,i.length),i.push(m);break}case"tool-result":{const m=s.get(p.toolUseId);if(m!==void 0){const w=i[m];w.output=p.output,w.error=p.error,w.pending=!1,s.delete(p.toolUseId);break}const v=o.get(p.toolUseId);if(v!==void 0){const w=i[v];w.output=p.output,w.error=p.error,w.pending=!1,p.toolResultExtra&&(w.toolResultExtra=p.toolResultExtra),(d=p.toolResultExtra)!=null&&d.agentId&&(l.set(p.toolResultExtra.agentId,v),c.set(v,p.toolUseId));break}break}case"agent-call":{const m={kind:"merged-agent",seq:p.seq,toolUseId:p.toolUseId,description:p.description,input:p.input,pending:!0,notifications:[]},v=i.length;o.set(p.toolUseId,v),i.push(m);const w=a.get(p.toolUseId);w&&(u(v,w),a.delete(p.toolUseId));break}case"agent-progress":{const m=o.get(p.toolUseId)??l.get(p.agentId);if(m!==void 0){u(m,p);break}const v=a.get(p.toolUseId);if((v==null?void 0:v.status)==="completed"||(v==null?void 0:v.status)==="failed")break;a.set(p.toolUseId,p);break}case"agent-notification":{const m=(p.parentToolUseId?o.get(p.parentToolUseId):void 0)??(p.taskId?l.get(p.taskId):void 0);if(m!==void 0){i[m].notifications.push({text:p.text,taskId:p.taskId});break}i.push({kind:"agent-notification",seq:p.seq,text:p.text,taskId:p.taskId,parentToolUseId:p.parentToolUseId});break}case"todo-checklist":{f===r&&p.todos.length>0&&i.push({kind:"todo-checklist",seq:p.seq,toolUseId:p.toolUseId,todos:p.todos});break}case"task-event":{f===n&&t.length>0&&i.push({kind:"plan-card",seq:p.seq,tasks:t});break}default:i.push(p)}}return i}const qq=new Set(["permission-inline","question-card"]);function Kq(e){return e.kind==="user-text"?!0:e.kind!=="user-meta"?!1:e.metaKind==="slash-command"||lp(e.metaKind)}function Gq(e){return e.kind==="user-text"&&e.continuesTurn===!0}function Yq(e,t={}){const n=[];let r=null;const i=(s,o)=>{r&&(n.push(Xq(r,s,o)),r=null)};for(const s of e){if(s.kind==="turn-end"){i(s,!0);continue}if(Kq(s)&&(r===null||!Gq(s))){i(void 0,!0),r={query:s,body:[]};continue}r===null?r={body:[s]}:r.body.push(s)}return i(void 0,t.closeTrailing===!0),n}function Xq(e,t,n){const{query:r,body:i}=e,s=Qq(i,t,n),o=Zq(i,s),a=eK(i,o),l=r??i[0]??t,c={kind:"turn",seq:l?l.seq:0,status:s,process:a,tail:o};return r&&(c.query=r),(t==null?void 0:t.durationMs)!==void 0&&(c.durationMs=t.durationMs),c}function Qq(e,t,n){if(!n)return"running";if((t==null?void 0:t.reason)==="interrupted")return"interrupted";const r=T0(e,i=>i.kind==="error");return r>=0&&!e.slice(r+1).some(s=>s.kind==="assistant-text")?"error":"done"}function Zq(e,t){if(t==="running"){const r=[];for(let i=e.length-1;i>=0&&qq.has(e[i].kind);i--)r.unshift(e[i]);return r}const n=t==="error"?T0(e,r=>r.kind==="error"):T0(e,r=>r.kind==="assistant-text");return n>=0?[e[n]]:[]}const Jq=new Set(["assistant-thinking","user-meta"]);function eK(e,t){const n=new Set(t),r=[];let i=null;const s=()=>{i&&(r.push({kind:"tool-group",seq:i[0].seq,items:i}),i=null)};for(const o of e){if(n.has(o)){s();continue}if(o.kind==="merged-tool"){i?i.push(o):i=[o];continue}if(Jq.has(o.kind)){r.push(o);continue}s(),r.push(o)}return s(),r}function T0(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}const tK={Read:["正在读取","已读取"],Bash:["正在运行","已运行"],Grep:["正在搜索","已搜索"],Glob:["正在搜索","已搜索"],Edit:["正在编辑","已编辑"],Write:["正在写入","已写入"],WebFetch:["正在抓取","已抓取"],WebSearch:["正在搜索","已搜索"],Skill:["正在读取","已读取"]};function nK(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 wM(e){const t=tK[e.tool],n=t?e.pending?t[0]:t[1]:e.pending?`正在执行 ${e.tool}`:`已执行 ${e.tool}`,r=nK(e.input);return r?`${n} ${r}`:n}function rK({item:e,renderItemDetail:t}){const[n,r]=g.useState(!1),i=n?Yn:Bn,s=n?(t==null?void 0:t(e))??null:null;return h.jsxs("div",{className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>r(o=>!o),"aria-expanded":n,"data-testid":"tool-call-group-row",className:ne("flex w-full items-center gap-1.5 text-left cursor-pointer min-w-0 py-0.5 text-[13px] hover:text-text-200",e.error?"text-destructive/80":"text-text-400"),children:[e.pending?h.jsx(cr,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):h.jsx(i,{className:"w-3.5 h-3.5 shrink-0 opacity-60"}),h.jsx("span",{className:"truncate min-w-0",children:wM(e)})]}),n?h.jsx("div",{"data-testid":"tool-call-group-row-detail",className:"pl-5 py-1 min-w-0 space-y-1.5 text-[12px] text-text-300",children:s!==null?s:h.jsxs(h.Fragment,{children:[h.jsx("pre",{className:"min-w-0 max-w-full overflow-auto whitespace-pre-wrap font-mono",children:JSON.stringify(e.input,null,2)}),e.output!==void 0?h.jsx("pre",{className:"min-w-0 max-w-full overflow-auto whitespace-pre-wrap font-mono text-text-400",children:typeof e.output=="string"?e.output:JSON.stringify(e.output,null,2)}):null,e.error?h.jsx("pre",{className:"min-w-0 max-w-full overflow-auto whitespace-pre-wrap font-mono text-destructive",children:e.error}):null]})}):null]})}function iK({items:e,renderItemDetail:t}){const[n,r]=g.useState(!1);if(e.length===0)return null;const i=e.some(l=>l.pending),s=i?[...e].reverse().find(l=>l.pending):e[e.length-1],o=!i&&e.length>1?` 等 ${e.length} 项`:"",a=n?Yn:Bn;return h.jsxs("div",{"data-testid":"tool-call-group",className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>r(l=>!l),"aria-expanded":n,"data-testid":"tool-call-group-header",className:"flex w-full items-center gap-1.5 text-left cursor-pointer min-w-0 py-0.5 text-[13px] text-text-400 hover:text-text-200",children:[i&&!n?h.jsx(cr,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):h.jsx(a,{className:"w-3.5 h-3.5 shrink-0"}),n?h.jsx("span",{className:"min-w-0 truncate opacity-70",children:i?"正在执行":`${e.length} 项`}):h.jsxs("span",{className:ne("truncate min-w-0",i&&"text-text-300"),children:[wM(s),o]})]}),n?h.jsx("div",{className:"mt-0.5 flex flex-col pl-5",children:e.map(l=>h.jsx(rK,{item:l,renderItemDetail:t},l.toolUseId))}):null]})}function sK(e){const t=Math.round(e/1e3);if(t<60)return`${t}秒`;const n=Math.floor(t/60),r=t%60;return r>0?`${n}分${r}秒`:`${n}分钟`}function oK(e,t){const n=t!==void 0?`耗时 ${sK(t)}`:"";switch(e){case"interrupted":return n?`已中断 · ${n}`:"已中断";case"error":return n?`出错 · ${n}`:"出错";default:return n||"已完成"}}function aK({status:e="done",durationMs:t,defaultExpanded:n=!1,children:r}){const[i,s]=g.useState(n),o=i?Yn:Bn;return h.jsxs("div",{"data-testid":"turn-process-block",className:"min-w-0 max-w-full border-t border-border pt-2",children:[h.jsxs("button",{type:"button",onClick:()=>s(a=>!a),"aria-expanded":i,"data-testid":"turn-process-block-header",className:ne("flex w-full items-center gap-1 text-left cursor-pointer min-w-0 py-0.5 text-[13px]",e!=="done"?"text-destructive/80 hover:text-destructive":"text-text-400 hover:text-text-200"),children:[h.jsx("span",{className:"truncate min-w-0",children:oK(e,t)}),h.jsx(o,{className:"w-3.5 h-3.5 shrink-0"})]}),i?h.jsx("div",{"data-testid":"turn-process-body",className:"mt-2 flex flex-col gap-2 border-l-2 border-border pl-3",children:r}):null]})}const lK=/<(system-reminder|related-dir|clawd-shift-fire)\b[^>]*>[\s\S]*?<\/\1>/gi,cK=/<builder-preview\b[^>]*\/>/gi,uK=/<(clawd-dispatch-task|clawd-dispatch-result)\b[^>]*>([\s\S]*?)<\/\1>/gi,dK=/<\/?(brief|detail|files)>/gi;function SM(e){return e?e.replace(uK,(t,n,r)=>Rz(r.replace(dK,"")).trim()).replace(lK,"").replace(cK,"").trim():""}const hK=SM;function fK(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const pK=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,mK=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,gK={};function QS(e,t){return(gK.jsx?mK:pK).test(e)}const vK=/[ \t\n\f\r]/g;function _K(e){return typeof e=="object"?e.type==="text"?ZS(e.value):!1:ZS(e)}function ZS(e){return e.replace(vK,"")===""}class Ru{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Ru.prototype.normal={};Ru.prototype.property={};Ru.prototype.space=void 0;function kM(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Ru(n,r,t)}function I0(e){return e.toLowerCase()}class Xn{constructor(t,n){this.attribute=n,this.property=t}}Xn.prototype.attribute="";Xn.prototype.booleanish=!1;Xn.prototype.boolean=!1;Xn.prototype.commaOrSpaceSeparated=!1;Xn.prototype.commaSeparated=!1;Xn.prototype.defined=!1;Xn.prototype.mustUseProperty=!1;Xn.prototype.number=!1;Xn.prototype.overloadedBoolean=!1;Xn.prototype.property="";Xn.prototype.spaceSeparated=!1;Xn.prototype.space=void 0;let xK=0;const De=Ko(),Bt=Ko(),P0=Ko(),Q=Ko(),ut=Ko(),Oa=Ko(),er=Ko();function Ko(){return 2**++xK}const R0=Object.freeze(Object.defineProperty({__proto__:null,boolean:De,booleanish:Bt,commaOrSpaceSeparated:er,commaSeparated:Oa,number:Q,overloadedBoolean:P0,spaceSeparated:ut},Symbol.toStringTag,{value:"Module"})),Um=Object.keys(R0);class $y extends Xn{constructor(t,n,r,i){let s=-1;if(super(t,n),JS(this,"space",i),typeof r=="number")for(;++s<Um.length;){const o=Um[s];JS(this,Um[s],(r&R0[o])===R0[o])}}}$y.prototype.defined=!0;function JS(e,t,n){n&&(e[t]=n)}function wl(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new $y(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[I0(r)]=r,n[I0(s.attribute)]=r}return new Ru(t,n,e.space)}const CM=wl({properties:{ariaActiveDescendant:null,ariaAtomic:Bt,ariaAutoComplete:null,ariaBusy:Bt,ariaChecked:Bt,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:ut,ariaCurrent:null,ariaDescribedBy:ut,ariaDetails:null,ariaDisabled:Bt,ariaDropEffect:ut,ariaErrorMessage:null,ariaExpanded:Bt,ariaFlowTo:ut,ariaGrabbed:Bt,ariaHasPopup:null,ariaHidden:Bt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ut,ariaLevel:Q,ariaLive:null,ariaModal:Bt,ariaMultiLine:Bt,ariaMultiSelectable:Bt,ariaOrientation:null,ariaOwns:ut,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:Bt,ariaReadOnly:Bt,ariaRelevant:null,ariaRequired:Bt,ariaRoleDescription:ut,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:Bt,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function EM(e,t){return t in e?e[t]:t}function NM(e,t){return EM(e,t.toLowerCase())}const yK=wl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Oa,acceptCharset:ut,accessKey:ut,action:null,allow:null,allowFullScreen:De,allowPaymentRequest:De,allowUserMedia:De,alt:null,as:null,async:De,autoCapitalize:null,autoComplete:ut,autoFocus:De,autoPlay:De,blocking:ut,capture:null,charSet:null,checked:De,cite:null,className:ut,cols:Q,colSpan:null,content:null,contentEditable:Bt,controls:De,controlsList:ut,coords:Q|Oa,crossOrigin:null,data:null,dateTime:null,decoding:null,default:De,defer:De,dir:null,dirName:null,disabled:De,download:P0,draggable:Bt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:De,formTarget:null,headers:ut,height:Q,hidden:P0,high:Q,href:null,hrefLang:null,htmlFor:ut,httpEquiv:ut,id:null,imageSizes:null,imageSrcSet:null,inert:De,inputMode:null,integrity:null,is:null,isMap:De,itemId:null,itemProp:ut,itemRef:ut,itemScope:De,itemType:ut,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:De,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:De,muted:De,name:null,nonce:null,noModule:De,noValidate:De,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:De,optimum:Q,pattern:null,ping:ut,placeholder:null,playsInline:De,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:De,referrerPolicy:null,rel:ut,required:De,reversed:De,rows:Q,rowSpan:Q,sandbox:ut,scope:null,scoped:De,seamless:De,selected:De,shadowRootClonable:De,shadowRootDelegatesFocus:De,shadowRootMode:null,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:Bt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:De,useMap:null,value:Bt,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ut,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:De,declare:De,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:De,noHref:De,noShade:De,noWrap:De,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:Bt,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:De,disableRemotePlayback:De,prefix:null,property:null,results:Q,security:null,unselectable:null},space:"html",transform:NM}),bK=wl({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:er,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:ut,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:De,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Oa,g2:Oa,glyphName:Oa,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:er,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ut,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:er,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:er,rev:er,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:er,requiredFeatures:er,requiredFonts:er,requiredFormats:er,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:er,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:er,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:er,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:EM}),TM=wl({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()}}),IM=wl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:NM}),PM=wl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),wK={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"},SK=/[A-Z]/g,ek=/-[a-z]/g,kK=/^data[-\w.:]+$/i;function CK(e,t){const n=I0(t);let r=t,i=Xn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&kK.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(ek,NK);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!ek.test(s)){let o=s.replace(SK,EK);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=$y}return new i(r,t)}function EK(e){return"-"+e.toLowerCase()}function NK(e){return e.charAt(1).toUpperCase()}const TK=kM([CM,yK,TM,IM,PM],"html"),Fy=kM([CM,bK,TM,IM,PM],"svg");function IK(e){return e.join(" ").trim()}var Hy={},tk=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,PK=/\n/g,RK=/^\s*/,MK=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,AK=/^:\s*/,LK=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,DK=/^[;\s]*/,jK=/^\s+|\s+$/g,OK=`
|
|
512
|
+
`,nk="/",rk="*",uo="",BK="comment",zK="declaration";function $K(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(PK);v&&(n+=v.length);var w=m.lastIndexOf(OK);r=~w?m.length-w:r+m.length}function s(){var m={line:n,column:r};return function(v){return v.position=new o(m),c(),v}}function o(m){this.start=m,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function a(m){var v=new Error(t.source+":"+n+":"+r+": "+m);if(v.reason=m,v.filename=t.source,v.line=n,v.column=r,v.source=e,!t.silent)throw v}function l(m){var v=m.exec(e);if(v){var w=v[0];return i(w),e=e.slice(w.length),v}}function c(){l(RK)}function u(m){var v;for(m=m||[];v=d();)v!==!1&&m.push(v);return m}function d(){var m=s();if(!(nk!=e.charAt(0)||rk!=e.charAt(1))){for(var v=2;uo!=e.charAt(v)&&(rk!=e.charAt(v)||nk!=e.charAt(v+1));)++v;if(v+=2,uo===e.charAt(v-1))return a("End of comment missing");var w=e.slice(2,v-2);return r+=2,i(w),e=e.slice(v),r+=2,m({type:BK,comment:w})}}function f(){var m=s(),v=l(MK);if(v){if(d(),!l(AK))return a("property missing ':'");var w=l(LK),_=m({type:zK,property:ik(v[0].replace(tk,uo)),value:w?ik(w[0].replace(tk,uo)):uo});return l(DK),_}}function p(){var m=[];u(m);for(var v;v=f();)v!==!1&&(m.push(v),u(m));return m}return c(),p()}function ik(e){return e?e.replace(jK,uo):uo}var FK=$K,HK=mh&&mh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Hy,"__esModule",{value:!0});Hy.default=WK;const UK=HK(FK);function WK(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,UK.default)(e),i=typeof t=="function";return r.forEach(s=>{if(s.type!=="declaration")return;const{property:o,value:a}=s;i?t(o,a,s):a&&(n=n||{},n[o]=a)}),n}var Tp={};Object.defineProperty(Tp,"__esModule",{value:!0});Tp.camelCase=void 0;var VK=/^--[a-zA-Z0-9_-]+$/,qK=/-([a-z])/g,KK=/^[^-]+$/,GK=/^-(webkit|moz|ms|o|khtml)-/,YK=/^-(ms)-/,XK=function(e){return!e||KK.test(e)||VK.test(e)},QK=function(e,t){return t.toUpperCase()},sk=function(e,t){return"".concat(t,"-")},ZK=function(e,t){return t===void 0&&(t={}),XK(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(YK,sk):e=e.replace(GK,sk),e.replace(qK,QK))};Tp.camelCase=ZK;var JK=mh&&mh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},eG=JK(Hy),tG=Tp;function M0(e,t){var n={};return!e||typeof e!="string"||(0,eG.default)(e,function(r,i){r&&i&&(n[(0,tG.camelCase)(r,t)]=i)}),n}M0.default=M0;var nG=M0;const rG=fu(nG),RM=MM("end"),Uy=MM("start");function MM(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 iG(e){const t=Uy(e),n=RM(e);if(t&&n)return{start:t,end:n}}function Cc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?ok(e.position):"start"in e||"end"in e?ok(e):"line"in e||"column"in e?A0(e):""}function A0(e){return ak(e&&e.line)+":"+ak(e&&e.column)}function ok(e){return A0(e&&e.start)+"-"+A0(e&&e.end)}function ak(e){return e&&typeof e=="number"?e:1}class Nn extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=Cc(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Nn.prototype.file="";Nn.prototype.name="";Nn.prototype.reason="";Nn.prototype.message="";Nn.prototype.stack="";Nn.prototype.column=void 0;Nn.prototype.line=void 0;Nn.prototype.ancestors=void 0;Nn.prototype.cause=void 0;Nn.prototype.fatal=void 0;Nn.prototype.place=void 0;Nn.prototype.ruleId=void 0;Nn.prototype.source=void 0;const Wy={}.hasOwnProperty,sG=new Map,oG=/[A-Z]/g,aG=new Set(["table","tbody","thead","tfoot","tr"]),lG=new Set(["td","th"]),AM="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function cG(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=vG(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=gG(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"?Fy:TK,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=LM(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function LM(e,t,n){if(t.type==="element")return uG(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return dG(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return fG(e,t,n);if(t.type==="mdxjsEsm")return hG(e,t);if(t.type==="root")return pG(e,t,n);if(t.type==="text")return mG(e,t)}function uG(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Fy,e.schema=i),e.ancestors.push(t);const s=jM(e,t.tagName,!1),o=_G(e,t);let a=qy(e,t);return aG.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!_K(l):!0})),DM(e,o,s,t),Vy(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function dG(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)}au(e,t.position)}function hG(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);au(e,t.position)}function fG(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Fy,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:jM(e,t.name,!0),o=xG(e,t),a=qy(e,t);return DM(e,o,s,t),Vy(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function pG(e,t,n){const r={};return Vy(r,qy(e,t)),e.create(t,e.Fragment,r,n)}function mG(e,t){return t.value}function DM(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Vy(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function gG(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 vG(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=Uy(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 _G(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Wy.call(t.properties,i)){const s=yG(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&lG.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 xG(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 au(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 au(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function qy(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:sG;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=LM(e,s,o);a!==void 0&&n.push(a)}return n}function yG(e,t,n){const r=CK(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?fK(n):IK(n)),r.property==="style"){let i=typeof n=="object"?n:bG(e,String(n));return e.stylePropertyNameCase==="css"&&(i=wG(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?wK[r.property]||r.property:r.attribute,n]}}function bG(e,t){try{return rG(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new Nn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=AM+"#cannot-parse-style-attribute",i}}function jM(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=QS(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=QS(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Wy.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);au(e)}function au(e,t){const n=new Nn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=AM+"#cannot-handle-mdx-estrees-without-createevaluater",n}function wG(e){const t={};let n;for(n in e)Wy.call(e,n)&&(t[SG(n)]=e[n]);return t}function SG(e){let t=e.replace(oG,kG);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function kG(e){return"-"+e.toLowerCase()}const Wm={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"]},CG={};function Ky(e,t){const n=CG,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return OM(e,r,i)}function OM(e,t,n){if(EG(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 lk(e.children,t,n)}return Array.isArray(e)?lk(e,t,n):""}function lk(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=OM(e[i],t,n);return r.join("")}function EG(e){return!!(e&&typeof e=="object")}const ck=document.createElement("i");function Gy(e){const t="&"+e+";";ck.innerHTML=t;const n=ck.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function or(e,t,n,r){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function wr(e,t){return e.length>0?(or(e,e.length,0,t),e):t}const uk={}.hasOwnProperty;function BM(e){const t={};let n=-1;for(;++n<e.length;)NG(t,e[n]);return t}function NG(e,t){let n;for(n in t){const i=(uk.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){uk.call(i,o)||(i[o]=[]);const a=s[o];TG(i[o],Array.isArray(a)?a:a?[a]:[])}}}function TG(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);or(e,0,0,r)}function zM(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 Hr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Mn=Ks(/[A-Za-z]/),kn=Ks(/[\dA-Za-z]/),IG=Ks(/[#-'*+\--9=?A-Z^-~]/);function hf(e){return e!==null&&(e<32||e===127)}const L0=Ks(/\d/),PG=Ks(/[\dA-Fa-f]/),RG=Ks(/[!-/:-@[-`{-~]/);function Se(e){return e!==null&&e<-2}function ct(e){return e!==null&&(e<0||e===32)}function Ue(e){return e===-2||e===-1||e===32}const Ip=Ks(new RegExp("\\p{P}|\\p{S}","u")),Ao=Ks(/\s/);function Ks(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Sl(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&kn(e.charCodeAt(n+1))&&kn(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function Ke(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return Ue(l)?(e.enter(n),a(l)):t(l)}function a(l){return Ue(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const MG={tokenize:AG};function AG(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"),Ke(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 Se(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const LG={tokenize:DG},dk={tokenize:jG};function DG(e){const t=this,n=[];let r=0,i,s,o;return a;function a(b){if(r<n.length){const S=n[r];return t.containerState=S[1],e.attempt(S[0].continuation,l,c)(b)}return c(b)}function l(b){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&x();const S=t.events.length;let C=S,k;for(;C--;)if(t.events[C][0]==="exit"&&t.events[C][1].type==="chunkFlow"){k=t.events[C][1].end;break}_(r);let N=S;for(;N<t.events.length;)t.events[N][1].end={...k},N++;return or(t.events,C+1,0,t.events.slice(S)),t.events.length=N,c(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(dk,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(dk,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){w(e.exit("chunkFlow"),!0),_(0),e.consume(b);return}return Se(b)?(e.consume(b),w(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(b),v)}function w(b,S){const C=t.sliceStream(b);if(S&&C.push(null),b.previous=s,s&&(s.next=b),s=b,i.defineSkip(b.start),i.write(C),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 N=t.events.length;let T=N,z,P;for(;T--;)if(t.events[T][0]==="exit"&&t.events[T][1].type==="chunkFlow"){if(z){P=t.events[T][1].end;break}z=!0}for(_(r),k=N;k<t.events.length;)t.events[k][1].end={...P},k++;or(t.events,T+1,0,t.events.slice(N)),t.events.length=k}}function _(b){let S=n.length;for(;S-- >b;){const C=n[S];t.containerState=C[1],C[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 jG(e,t,n){return Ke(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function el(e){if(e===null||ct(e)||Ao(e))return 1;if(Ip(e))return 2}function Pp(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const D0={name:"attention",resolveAll:OG,tokenize:BG};function OG(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};hk(d,-l),hk(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=wr(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=wr(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),c=wr(c,Pp(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=wr(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=wr(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):u=0,or(e,r-1,n-r+3,c),n=r+c.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function BG(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=el(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=el(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 hk(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const zG={name:"autolink",tokenize:$G};function $G(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 Mn(p)?(e.consume(p),o):p===64?n(p):c(p)}function o(p){return p===43||p===45||p===46||kn(p)?(r=1,a(p)):c(p)}function a(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||kn(p))&&r++<32?(e.consume(p),a):(r=0,c(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||hf(p)?n(p):(e.consume(p),l)}function c(p){return p===64?(e.consume(p),u):IG(p)?(e.consume(p),c):n(p)}function u(p){return kn(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,u):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):f(p)}function f(p){if((p===45||kn(p))&&r++<63){const m=p===45?f:d;return e.consume(p),m}return n(p)}}const Mu={partial:!0,tokenize:FG};function FG(e,t,n){return r;function r(s){return Ue(s)?Ke(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||Se(s)?t(s):n(s)}}const $M={continuation:{tokenize:UG},exit:WG,name:"blockQuote",tokenize:HG};function HG(e,t,n){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return Ue(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function UG(e,t,n){const r=this;return i;function i(o){return Ue(o)?Ke(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt($M,t,n)(o)}}function WG(e){e.exit("blockQuote")}const FM={name:"characterEscape",tokenize:VG};function VG(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 RG(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const HM={name:"characterReference",tokenize:qG};function qG(e,t,n){const r=this;let i=0,s,o;return a;function a(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),l}function l(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),s=31,o=kn,u(d))}function c(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=PG,u):(e.enter("characterReferenceValue"),s=7,o=L0,u(d))}function u(d){if(d===59&&i){const f=e.exit("characterReferenceValue");return o===kn&&!Gy(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 fk={partial:!0,tokenize:GG},pk={concrete:!0,name:"codeFenced",tokenize:KG};function KG(e,t,n){const r=this,i={partial:!0,tokenize:C};let s=0,o=0,a;return l;function l(k){return c(k)}function c(k){const N=r.events[r.events.length-1];return s=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[1],!0).length:0,a=k,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),u(k)}function u(k){return k===a?(o++,e.consume(k),u):o<3?n(k):(e.exit("codeFencedFenceSequence"),Ue(k)?Ke(e,d,"whitespace")(k):d(k))}function d(k){return k===null||Se(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(fk,v,S)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(k))}function f(k){return k===null||Se(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(k)):Ue(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ke(e,p,"whitespace")(k)):k===96&&k===a?n(k):(e.consume(k),f)}function p(k){return k===null||Se(k)?d(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(k))}function m(k){return k===null||Se(k)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(k)):k===96&&k===a?n(k):(e.consume(k),m)}function v(k){return e.attempt(i,S,w)(k)}function w(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),_}function _(k){return s>0&&Ue(k)?Ke(e,x,"linePrefix",s+1)(k):x(k)}function x(k){return k===null||Se(k)?e.check(fk,v,S)(k):(e.enter("codeFlowValue"),b(k))}function b(k){return k===null||Se(k)?(e.exit("codeFlowValue"),x(k)):(e.consume(k),b)}function S(k){return e.exit("codeFenced"),t(k)}function C(k,N,T){let z=0;return P;function P(D){return k.enter("lineEnding"),k.consume(D),k.exit("lineEnding"),B}function B(D){return k.enter("codeFencedFence"),Ue(D)?Ke(k,A,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):A(D)}function A(D){return D===a?(k.enter("codeFencedFenceSequence"),R(D)):T(D)}function R(D){return D===a?(z++,k.consume(D),R):z>=o?(k.exit("codeFencedFenceSequence"),Ue(D)?Ke(k,M,"whitespace")(D):M(D)):T(D)}function M(D){return D===null||Se(D)?(k.exit("codeFencedFence"),N(D)):T(D)}}}function GG(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 Vm={name:"codeIndented",tokenize:XG},YG={partial:!0,tokenize:QG};function XG(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),Ke(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):Se(c)?e.attempt(YG,o,l)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||Se(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),a)}function l(c){return e.exit("codeIndented"),t(c)}}function QG(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):Se(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):Ke(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):Se(o)?i(o):n(o)}}const ZG={name:"codeText",previous:eY,resolve:JG,tokenize:tY};function JG(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 eY(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function tY(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)):Se(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||Se(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 nY{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Ul(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Ul(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Ul(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Ul(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Ul(this.left,n.reverse())}}}function Ul(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function UM(e){const t={};let n=-1,r,i,s,o,a,l,c;const u=new nY(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,rY(u,n)),n=t[n],c=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=u.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(u.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...u.get(i)[1].start},a=u.slice(i,n),a.unshift(r),u.splice(i,n-i+1,a))}}return or(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function rY(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],c={};let u,d,f=-1,p=n,m=0,v=0;const w=[v];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<a.length;)a[f][0]==="exit"&&a[f-1][0]==="enter"&&a[f][1].type===a[f-1][1].type&&a[f][1].start.line!==a[f][1].end.line&&(v=f+1,w.push(v),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):w.pop(),f=w.length;f--;){const _=a.slice(w[f],w[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 iY={resolve:oY,tokenize:aY},sY={partial:!0,tokenize:lY};function oY(e){return UM(e),e}function aY(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):Se(a)?e.check(sY,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 lY(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Ke(e,s,"linePrefix")}function s(o){if(o===null||Se(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 WM(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||hf(_)?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||Se(_)?n(_):(e.consume(_),_===92?m:p)}function m(_){return _===60||_===62||_===92?(e.consume(_),p):p(_)}function v(_){return!u&&(_===null||_===41||ct(_))?(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||hf(_)?n(_):(e.consume(_),_===92?w:v)}function w(_){return _===40||_===41||_===92?(e.consume(_),v):v(_)}}function VM(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):Se(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||Se(p)||a++>999?(e.exit("chunkString"),u(p)):(e.consume(p),l||(l=!Ue(p)),p===92?f:d)}function f(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function qM(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):Se(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Ke(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(f))}function u(f){return f===o||f===null||Se(f)?(e.exit("chunkString"),c(f)):(e.consume(f),f===92?d:u)}function d(f){return f===o||f===92?(e.consume(f),u):u(f)}}function Ec(e,t){let n;return r;function r(i){return Se(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Ue(i)?Ke(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const cY={name:"definition",tokenize:dY},uY={partial:!0,tokenize:hY};function dY(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return VM.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=Hr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return ct(p)?Ec(e,c)(p):c(p)}function c(p){return WM(e,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function u(p){return e.attempt(uY,d,d)(p)}function d(p){return Ue(p)?Ke(e,f,"whitespace")(p):f(p)}function f(p){return p===null||Se(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function hY(e,t,n){return r;function r(a){return ct(a)?Ec(e,i)(a):n(a)}function i(a){return qM(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return Ue(a)?Ke(e,o,"whitespace")(a):o(a)}function o(a){return a===null||Se(a)?t(a):n(a)}}const fY={name:"hardBreakEscape",tokenize:pY};function pY(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return Se(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const mY={name:"headingAtx",resolve:gY,tokenize:vY};function gY(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},or(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function vY(e,t,n){let r=0;return i;function i(u){return e.enter("atxHeading"),s(u)}function s(u){return e.enter("atxHeadingSequence"),o(u)}function o(u){return u===35&&r++<6?(e.consume(u),o):u===null||ct(u)?(e.exit("atxHeadingSequence"),a(u)):n(u)}function a(u){return u===35?(e.enter("atxHeadingSequence"),l(u)):u===null||Se(u)?(e.exit("atxHeading"),t(u)):Ue(u)?Ke(e,a,"whitespace")(u):(e.enter("atxHeadingText"),c(u))}function l(u){return u===35?(e.consume(u),l):(e.exit("atxHeadingSequence"),a(u))}function c(u){return u===null||u===35||ct(u)?(e.exit("atxHeadingText"),a(u)):(e.consume(u),c)}}const _Y=["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"],mk=["pre","script","style","textarea"],xY={concrete:!0,name:"htmlFlow",resolveTo:wY,tokenize:SY},yY={partial:!0,tokenize:CY},bY={partial:!0,tokenize:kY};function wY(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 SY(e,t,n){const r=this;let i,s,o,a,l;return c;function c(L){return u(L)}function u(L){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(L),d}function d(L){return L===33?(e.consume(L),f):L===47?(e.consume(L),s=!0,v):L===63?(e.consume(L),i=3,r.interrupt?t:E):Mn(L)?(e.consume(L),o=String.fromCharCode(L),w):n(L)}function f(L){return L===45?(e.consume(L),i=2,p):L===91?(e.consume(L),i=5,a=0,m):Mn(L)?(e.consume(L),i=4,r.interrupt?t:E):n(L)}function p(L){return L===45?(e.consume(L),r.interrupt?t:E):n(L)}function m(L){const re="CDATA[";return L===re.charCodeAt(a++)?(e.consume(L),a===re.length?r.interrupt?t:A:m):n(L)}function v(L){return Mn(L)?(e.consume(L),o=String.fromCharCode(L),w):n(L)}function w(L){if(L===null||L===47||L===62||ct(L)){const re=L===47,se=o.toLowerCase();return!re&&!s&&mk.includes(se)?(i=1,r.interrupt?t(L):A(L)):_Y.includes(o.toLowerCase())?(i=6,re?(e.consume(L),_):r.interrupt?t(L):A(L)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(L):s?x(L):b(L))}return L===45||kn(L)?(e.consume(L),o+=String.fromCharCode(L),w):n(L)}function _(L){return L===62?(e.consume(L),r.interrupt?t:A):n(L)}function x(L){return Ue(L)?(e.consume(L),x):P(L)}function b(L){return L===47?(e.consume(L),P):L===58||L===95||Mn(L)?(e.consume(L),S):Ue(L)?(e.consume(L),b):P(L)}function S(L){return L===45||L===46||L===58||L===95||kn(L)?(e.consume(L),S):C(L)}function C(L){return L===61?(e.consume(L),k):Ue(L)?(e.consume(L),C):b(L)}function k(L){return L===null||L===60||L===61||L===62||L===96?n(L):L===34||L===39?(e.consume(L),l=L,N):Ue(L)?(e.consume(L),k):T(L)}function N(L){return L===l?(e.consume(L),l=null,z):L===null||Se(L)?n(L):(e.consume(L),N)}function T(L){return L===null||L===34||L===39||L===47||L===60||L===61||L===62||L===96||ct(L)?C(L):(e.consume(L),T)}function z(L){return L===47||L===62||Ue(L)?b(L):n(L)}function P(L){return L===62?(e.consume(L),B):n(L)}function B(L){return L===null||Se(L)?A(L):Ue(L)?(e.consume(L),B):n(L)}function A(L){return L===45&&i===2?(e.consume(L),$):L===60&&i===1?(e.consume(L),F):L===62&&i===4?(e.consume(L),H):L===63&&i===3?(e.consume(L),E):L===93&&i===5?(e.consume(L),O):Se(L)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(yY,q,R)(L)):L===null||Se(L)?(e.exit("htmlFlowData"),R(L)):(e.consume(L),A)}function R(L){return e.check(bY,M,q)(L)}function M(L){return e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),D}function D(L){return L===null||Se(L)?R(L):(e.enter("htmlFlowData"),A(L))}function $(L){return L===45?(e.consume(L),E):A(L)}function F(L){return L===47?(e.consume(L),o="",j):A(L)}function j(L){if(L===62){const re=o.toLowerCase();return mk.includes(re)?(e.consume(L),H):A(L)}return Mn(L)&&o.length<8?(e.consume(L),o+=String.fromCharCode(L),j):A(L)}function O(L){return L===93?(e.consume(L),E):A(L)}function E(L){return L===62?(e.consume(L),H):L===45&&i===2?(e.consume(L),E):A(L)}function H(L){return L===null||Se(L)?(e.exit("htmlFlowData"),q(L)):(e.consume(L),H)}function q(L){return e.exit("htmlFlow"),t(L)}}function kY(e,t,n){const r=this;return i;function i(o){return Se(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 CY(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Mu,t,n)}}const EY={name:"htmlText",tokenize:NY};function NY(e,t,n){const r=this;let i,s,o;return a;function a(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),l}function l(E){return E===33?(e.consume(E),c):E===47?(e.consume(E),C):E===63?(e.consume(E),b):Mn(E)?(e.consume(E),T):n(E)}function c(E){return E===45?(e.consume(E),u):E===91?(e.consume(E),s=0,m):Mn(E)?(e.consume(E),x):n(E)}function u(E){return E===45?(e.consume(E),p):n(E)}function d(E){return E===null?n(E):E===45?(e.consume(E),f):Se(E)?(o=d,F(E)):(e.consume(E),d)}function f(E){return E===45?(e.consume(E),p):d(E)}function p(E){return E===62?$(E):E===45?f(E):d(E)}function m(E){const H="CDATA[";return E===H.charCodeAt(s++)?(e.consume(E),s===H.length?v:m):n(E)}function v(E){return E===null?n(E):E===93?(e.consume(E),w):Se(E)?(o=v,F(E)):(e.consume(E),v)}function w(E){return E===93?(e.consume(E),_):v(E)}function _(E){return E===62?$(E):E===93?(e.consume(E),_):v(E)}function x(E){return E===null||E===62?$(E):Se(E)?(o=x,F(E)):(e.consume(E),x)}function b(E){return E===null?n(E):E===63?(e.consume(E),S):Se(E)?(o=b,F(E)):(e.consume(E),b)}function S(E){return E===62?$(E):b(E)}function C(E){return Mn(E)?(e.consume(E),k):n(E)}function k(E){return E===45||kn(E)?(e.consume(E),k):N(E)}function N(E){return Se(E)?(o=N,F(E)):Ue(E)?(e.consume(E),N):$(E)}function T(E){return E===45||kn(E)?(e.consume(E),T):E===47||E===62||ct(E)?z(E):n(E)}function z(E){return E===47?(e.consume(E),$):E===58||E===95||Mn(E)?(e.consume(E),P):Se(E)?(o=z,F(E)):Ue(E)?(e.consume(E),z):$(E)}function P(E){return E===45||E===46||E===58||E===95||kn(E)?(e.consume(E),P):B(E)}function B(E){return E===61?(e.consume(E),A):Se(E)?(o=B,F(E)):Ue(E)?(e.consume(E),B):z(E)}function A(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),i=E,R):Se(E)?(o=A,F(E)):Ue(E)?(e.consume(E),A):(e.consume(E),M)}function R(E){return E===i?(e.consume(E),i=void 0,D):E===null?n(E):Se(E)?(o=R,F(E)):(e.consume(E),R)}function M(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||ct(E)?z(E):(e.consume(E),M)}function D(E){return E===47||E===62||ct(E)?z(E):n(E)}function $(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function F(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),j}function j(E){return Ue(E)?Ke(e,O,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):O(E)}function O(E){return e.enter("htmlTextData"),o(E)}}const Yy={name:"labelEnd",resolveAll:RY,resolveTo:MY,tokenize:AY},TY={tokenize:LY},IY={tokenize:DY},PY={tokenize:jY};function RY(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&or(e,0,e.length,n),e}function MY(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=wr(a,e.slice(s+1,s+r+3)),a=wr(a,[["enter",u,t]]),a=wr(a,Pp(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=wr(a,[["exit",u,t],e[o-2],e[o-1],["exit",c,t]]),a=wr(a,e.slice(o+1)),a=wr(a,[["exit",l,t]]),or(e,s,e.length,a),e}function AY(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(Hr(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(TY,u,o?u:d)(f):f===91?e.attempt(IY,u,o?c:d)(f):o?u(f):d(f)}function c(f){return e.attempt(PY,u,d)(f)}function u(f){return t(f)}function d(f){return s._balanced=!0,n(f)}}function LY(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),i}function i(d){return ct(d)?Ec(e,s)(d):s(d)}function s(d){return d===41?u(d):WM(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function o(d){return ct(d)?Ec(e,l)(d):u(d)}function a(d){return n(d)}function l(d){return d===34||d===39||d===40?qM(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):u(d)}function c(d){return ct(d)?Ec(e,u)(d):u(d)}function u(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function DY(e,t,n){const r=this;return i;function i(a){return VM.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Hr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function jY(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 OY={name:"labelStartImage",resolveAll:Yy.resolveAll,tokenize:BY};function BY(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 zY={name:"labelStartLink",resolveAll:Yy.resolveAll,tokenize:$Y};function $Y(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 qm={name:"lineEnding",tokenize:FY};function FY(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ke(e,t,"linePrefix")}}const oh={name:"thematicBreak",tokenize:HY};function HY(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||Se(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),Ue(c)?Ke(e,a,"whitespace")(c):a(c))}}const Un={continuation:{tokenize:qY},exit:GY,name:"list",tokenize:VY},UY={partial:!0,tokenize:YY},WY={partial:!0,tokenize:KY};function VY(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:L0(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(oh,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 L0(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(Mu,r.interrupt?n:u,e.attempt(UY,f,d))}function u(p){return r.containerState.initialBlankLine=!0,s++,f(p)}function d(p){return Ue(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),f):n(p)}function f(p){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function qY(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Mu,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ke(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!Ue(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(WY,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ke(e,e.attempt(Un,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function KY(e,t,n){const r=this;return Ke(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 GY(e){e.exit(this.containerState.type)}function YY(e,t,n){const r=this;return Ke(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!Ue(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const gk={name:"setextUnderline",resolveTo:XY,tokenize:QY};function XY(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 QY(e,t,n){const r=this;let i;return s;function s(c){let u=r.events.length,d;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){d=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),i=c,o(c)):n(c)}function o(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===i?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),Ue(c)?Ke(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||Se(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const ZY={tokenize:JY};function JY(e){const t=this,n=e.attempt(Mu,r,e.attempt(this.parser.constructs.flowInitial,i,Ke(e,e.attempt(this.parser.constructs.flow,i,e.attempt(iY,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 eX={resolveAll:GM()},tX=KM("string"),nX=KM("text");function KM(e){return{resolveAll:GM(e==="text"?rX: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 GM(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 rX(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 iX={42:Un,43:Un,45:Un,48:Un,49:Un,50:Un,51:Un,52:Un,53:Un,54:Un,55:Un,56:Un,57:Un,62:$M},sX={91:cY},oX={[-2]:Vm,[-1]:Vm,32:Vm},aX={35:mY,42:oh,45:[gk,oh],60:xY,61:gk,95:oh,96:pk,126:pk},lX={38:HM,92:FM},cX={[-5]:qm,[-4]:qm,[-3]:qm,33:OY,38:HM,42:D0,60:[zG,EY],91:zY,92:[fY,FM],93:Yy,95:D0,96:ZG},uX={null:[D0,eX]},dX={null:[42,95]},hX={null:[]},fX=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:dX,contentInitial:sX,disable:hX,document:iX,flow:aX,flowInitial:oX,insideSpan:uX,string:lX,text:cX},Symbol.toStringTag,{value:"Module"}));function pX(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],a=[];const l={attempt:N(C),check:N(k),consume:x,enter:b,exit:S,interrupt:N(k,{interrupt:!0})},c={code:null,containerState:{},defineSkip:v,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d};let u=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function d(B){return o=wr(o,B),w(),o[o.length-1]!==null?[]:(T(t,0),c.events=Pp(s,c.events,c),c.events)}function f(B,A){return gX(p(B),A)}function p(B){return mX(o,B)}function m(){const{_bufferIndex:B,_index:A,line:R,column:M,offset:D}=r;return{_bufferIndex:B,_index:A,line:R,column:M,offset:D}}function v(B){i[B.line]=B.column,P()}function w(){let B;for(;r._index<o.length;){const A=o[r._index];if(typeof A=="string")for(B=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===B&&r._bufferIndex<A.length;)_(A.charCodeAt(r._bufferIndex));else _(A)}}function _(B){u=u(B)}function x(B){Se(B)?(r.line++,r.column=1,r.offset+=B===-3?2:1,P()):B!==-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=B}function b(B,A){const R=A||{};return R.type=B,R.start=m(),c.events.push(["enter",R,c]),a.push(R),R}function S(B){const A=a.pop();return A.end=m(),c.events.push(["exit",A,c]),A}function C(B,A){T(B,A.from)}function k(B,A){A.restore()}function N(B,A){return R;function R(M,D,$){let F,j,O,E;return Array.isArray(M)?q(M):"tokenize"in M?q([M]):H(M);function H(K){return ge;function ge(Re){const ce=Re!==null&&K[Re],Le=Re!==null&&K.null,Oe=[...Array.isArray(ce)?ce:ce?[ce]:[],...Array.isArray(Le)?Le:Le?[Le]:[]];return q(Oe)(Re)}}function q(K){return F=K,j=0,K.length===0?$:L(K[j])}function L(K){return ge;function ge(Re){return E=z(),O=K,K.partial||(c.currentConstruct=K),K.name&&c.parser.constructs.disable.null.includes(K.name)?se():K.tokenize.call(A?Object.assign(Object.create(c),A):c,l,re,se)(Re)}}function re(K){return B(O,E),D}function se(K){return E.restore(),++j<F.length?L(F[j]):$}}}function T(B,A){B.resolveAll&&!s.includes(B)&&s.push(B),B.resolve&&or(c.events,A,c.events.length-A,B.resolve(c.events.slice(A),c)),B.resolveTo&&(c.events=B.resolveTo(c.events,c))}function z(){const B=m(),A=c.previous,R=c.currentConstruct,M=c.events.length,D=Array.from(a);return{from:M,restore:$};function $(){r=B,c.previous=A,c.currentConstruct=R,c.events.length=M,a=D,P()}}function P(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function mX(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 gX(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=`
|
|
513
513
|
`;break}case-3:{o=`\r
|
|
514
|
-
`;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 vX(e){const r={constructs:BM([fX,...(e||{}).extensions||[]]),content:i(MG),defined:[],document:i(LG),flow:i(ZY),lazy:{},string:i(tX),text:i(nX)};return r;function i(s){return o;function o(a){return pX(r,s,a)}}}function _X(e){for(;!UM(e););return e}const vk=/[\0\t\n\r]/g;function xX(){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(vk.lastIndex=d,c=vk.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 yX=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function bX(e){return e.replace(yX,wX)}function wX(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return zM(n.slice(s?2:1),s?16:10)}return Gy(n)||e}const YM={}.hasOwnProperty;function SX(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),kX(n)(_X(vX(n).document().write(xX()(e,t,!0))))}function kX(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(nt),autolinkProtocol:z,autolinkEmail:z,atxHeading:s(kt),blockQuote:s(Le),characterEscape:z,characterReference:z,codeFenced:s(Oe),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Oe,o),codeText:s(Ae,o),codeTextData:z,data:z,codeFlowValue:z,definition:s(_e),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(Qe),hardBreakEscape:s(tt),hardBreakTrailing:s(tt),htmlFlow:s(At,o),htmlFlowData:z,htmlText:s(At,o),htmlTextData:z,image:s(Jt),label:o,link:s(nt),listItem:s(qe),listItemValue:f,listOrdered:s(Ct,d),listUnordered:s(Ct),paragraph:s(ot),reference:L,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(kt),strong:s(Et),thematicBreak:s(Tn)},exit:{atxHeading:l(),atxHeadingSequence:C,autolink:l(),autolinkEmail:ce,autolinkProtocol:Re,blockQuote:l(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:se,characterReferenceMarkerNumeric:se,characterReferenceValue:K,characterReference:me,codeFenced:l(w),codeFencedFence:v,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:P,codeIndented:l(_),codeText:l(D),codeTextData:P,data:P,definition:l(),definitionDestinationString:S,definitionLabelString:x,definitionTitleString:b,emphasis:l(),hardBreakEscape:l(A),hardBreakTrailing:l(A),htmlFlow:l(R),htmlFlowData:P,htmlText:l(M),htmlTextData:P,image:l(F),label:O,labelText:j,lineEnding:B,link:l($),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:re,resourceDestinationString:E,resourceTitleString:H,resource:q,setextHeading:l(T),setextHeadingLineSequence:N,setextHeadingText:k,strong:l(),thematicBreak:l()}};XM(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(U){let J={type:"root",children:[]};const xe={stack:[J],tokenStack:[],config:t,enter:a,exit:c,buffer:o,resume:u,data:n},Ie=[];let Fe=-1;for(;++Fe<U.length;)if(U[Fe][1].type==="listOrdered"||U[Fe][1].type==="listUnordered")if(U[Fe][0]==="enter")Ie.push(Fe);else{const Nt=Ie.pop();Fe=i(U,Nt,Fe)}for(Fe=-1;++Fe<U.length;){const Nt=t[U[Fe][0]];YM.call(Nt,U[Fe][1].type)&&Nt[U[Fe][1].type].call(Object.assign({sliceSerialize:U[Fe][2].sliceSerialize},xe),U[Fe][1])}if(xe.tokenStack.length>0){const Nt=xe.tokenStack[xe.tokenStack.length-1];(Nt[1]||_k).call(xe,void 0,Nt[0])}for(J.position={start:os(U.length>0?U[0][1].start:{line:1,column:1,offset:0}),end:os(U.length>0?U[U.length-2][1].end:{line:1,column:1,offset:0})},Fe=-1;++Fe<t.transforms.length;)J=t.transforms[Fe](J)||J;return J}function i(U,J,xe){let Ie=J-1,Fe=-1,Nt=!1,en,tn,nn,oe;for(;++Ie<=xe;){const ye=U[Ie];switch(ye[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ye[0]==="enter"?Fe++:Fe--,oe=void 0;break}case"lineEndingBlank":{ye[0]==="enter"&&(en&&!oe&&!Fe&&!nn&&(nn=Ie),oe=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:oe=void 0}if(!Fe&&ye[0]==="enter"&&ye[1].type==="listItemPrefix"||Fe===-1&&ye[0]==="exit"&&(ye[1].type==="listUnordered"||ye[1].type==="listOrdered")){if(en){let rt=Ie;for(tn=void 0;rt--;){const mt=U[rt];if(mt[1].type==="lineEnding"||mt[1].type==="lineEndingBlank"){if(mt[0]==="exit")continue;tn&&(U[tn][1].type="lineEndingBlank",Nt=!0),mt[1].type="lineEnding",tn=rt}else if(!(mt[1].type==="linePrefix"||mt[1].type==="blockQuotePrefix"||mt[1].type==="blockQuotePrefixWhitespace"||mt[1].type==="blockQuoteMarker"||mt[1].type==="listItemIndent"))break}nn&&(!tn||nn<tn)&&(en._spread=!0),en.end=Object.assign({},tn?U[tn][1].start:ye[1].end),U.splice(tn||Ie,0,["exit",en,ye[2]]),Ie++,xe++}if(ye[1].type==="listItemPrefix"){const rt={type:"listItem",_spread:!1,start:Object.assign({},ye[1].start),end:void 0};en=rt,U.splice(Ie,0,["enter",rt,ye[2]]),Ie++,xe++,nn=void 0,oe=!0}}}return U[J][1]._spread=Nt,xe}function s(U,J){return xe;function xe(Ie){a.call(this,U(Ie),Ie),J&&J.call(this,Ie)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(U,J,xe){this.stack[this.stack.length-1].children.push(U),this.stack.push(U),this.tokenStack.push([J,xe||void 0]),U.position={start:os(J.start),end:void 0}}function l(U){return J;function J(xe){U&&U.call(this,xe),c.call(this,xe)}}function c(U,J){const xe=this.stack.pop(),Ie=this.tokenStack.pop();if(Ie)Ie[0].type!==U.type&&(J?J.call(this,U,Ie[0]):(Ie[1]||_k).call(this,U,Ie[0]));else throw new Error("Cannot close `"+U.type+"` ("+Cc({start:U.start,end:U.end})+"): it’s not open");xe.position.end=os(U.end)}function u(){return Ky(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(U){if(this.data.expectingFirstListItemValue){const J=this.stack[this.stack.length-2];J.start=Number.parseInt(this.sliceSerialize(U),10),this.data.expectingFirstListItemValue=void 0}}function p(){const U=this.resume(),J=this.stack[this.stack.length-1];J.lang=U}function m(){const U=this.resume(),J=this.stack[this.stack.length-1];J.meta=U}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function w(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function _(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U.replace(/(\r?\n|\r)$/g,"")}function x(U){const J=this.resume(),xe=this.stack[this.stack.length-1];xe.label=J,xe.identifier=Hr(this.sliceSerialize(U)).toLowerCase()}function b(){const U=this.resume(),J=this.stack[this.stack.length-1];J.title=U}function S(){const U=this.resume(),J=this.stack[this.stack.length-1];J.url=U}function C(U){const J=this.stack[this.stack.length-1];if(!J.depth){const xe=this.sliceSerialize(U).length;J.depth=xe}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function N(U){const J=this.stack[this.stack.length-1];J.depth=this.sliceSerialize(U).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function z(U){const xe=this.stack[this.stack.length-1].children;let Ie=xe[xe.length-1];(!Ie||Ie.type!=="text")&&(Ie=_n(),Ie.position={start:os(U.start),end:void 0},xe.push(Ie)),this.stack.push(Ie)}function P(U){const J=this.stack.pop();J.value+=this.sliceSerialize(U),J.position.end=os(U.end)}function B(U){const J=this.stack[this.stack.length-1];if(this.data.atHardBreak){const xe=J.children[J.children.length-1];xe.position.end=os(U.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(J.type)&&(z.call(this,U),P.call(this,U))}function A(){this.data.atHardBreak=!0}function R(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U}function M(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U}function D(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U}function $(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const J=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=J,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function F(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const J=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=J,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function j(U){const J=this.sliceSerialize(U),xe=this.stack[this.stack.length-2];xe.label=bX(J),xe.identifier=Hr(J).toLowerCase()}function O(){const U=this.stack[this.stack.length-1],J=this.resume(),xe=this.stack[this.stack.length-1];if(this.data.inReference=!0,xe.type==="link"){const Ie=U.children;xe.children=Ie}else xe.alt=J}function E(){const U=this.resume(),J=this.stack[this.stack.length-1];J.url=U}function H(){const U=this.resume(),J=this.stack[this.stack.length-1];J.title=U}function q(){this.data.inReference=void 0}function L(){this.data.referenceType="collapsed"}function re(U){const J=this.resume(),xe=this.stack[this.stack.length-1];xe.label=J,xe.identifier=Hr(this.sliceSerialize(U)).toLowerCase(),this.data.referenceType="full"}function se(U){this.data.characterReferenceType=U.type}function K(U){const J=this.sliceSerialize(U),xe=this.data.characterReferenceType;let Ie;xe?(Ie=zM(J,xe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ie=Gy(J);const Fe=this.stack[this.stack.length-1];Fe.value+=Ie}function me(U){const J=this.stack.pop();J.position.end=os(U.end)}function Re(U){P.call(this,U);const J=this.stack[this.stack.length-1];J.url=this.sliceSerialize(U)}function ce(U){P.call(this,U);const J=this.stack[this.stack.length-1];J.url="mailto:"+this.sliceSerialize(U)}function Le(){return{type:"blockquote",children:[]}}function Oe(){return{type:"code",lang:null,meta:null,value:""}}function Ae(){return{type:"inlineCode",value:""}}function _e(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Qe(){return{type:"emphasis",children:[]}}function kt(){return{type:"heading",depth:0,children:[]}}function tt(){return{type:"break"}}function At(){return{type:"html",value:""}}function Jt(){return{type:"image",title:null,url:"",alt:null}}function nt(){return{type:"link",title:null,url:"",children:[]}}function Ct(U){return{type:"list",ordered:U.type==="listOrdered",start:null,spread:U._spread,children:[]}}function qe(U){return{type:"listItem",spread:U._spread,checked:null,children:[]}}function ot(){return{type:"paragraph",children:[]}}function Et(){return{type:"strong",children:[]}}function _n(){return{type:"text",value:""}}function Tn(){return{type:"thematicBreak"}}}function os(e){return{line:e.line,column:e.column,offset:e.offset}}function XM(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?XM(e,r):CX(e,r)}}function CX(e,t){let n;for(n in t)if(YM.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 _k(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Cc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Cc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Cc({start:t.start,end:t.end})+") is still open")}function EX(e){const t=this;t.parser=n;function n(r){return SX(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function NX(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 TX(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
514
|
+
`;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 vX(e){const r={constructs:BM([fX,...(e||{}).extensions||[]]),content:i(MG),defined:[],document:i(LG),flow:i(ZY),lazy:{},string:i(tX),text:i(nX)};return r;function i(s){return o;function o(a){return pX(r,s,a)}}}function _X(e){for(;!UM(e););return e}const vk=/[\0\t\n\r]/g;function xX(){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(vk.lastIndex=d,c=vk.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 yX=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function bX(e){return e.replace(yX,wX)}function wX(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return zM(n.slice(s?2:1),s?16:10)}return Gy(n)||e}const YM={}.hasOwnProperty;function SX(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),kX(n)(_X(vX(n).document().write(xX()(e,t,!0))))}function kX(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(nt),autolinkProtocol:z,autolinkEmail:z,atxHeading:s(kt),blockQuote:s(Le),characterEscape:z,characterReference:z,codeFenced:s(Oe),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Oe,o),codeText:s(Ae,o),codeTextData:z,data:z,codeFlowValue:z,definition:s(_e),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(Qe),hardBreakEscape:s(tt),hardBreakTrailing:s(tt),htmlFlow:s(At,o),htmlFlowData:z,htmlText:s(At,o),htmlTextData:z,image:s(Jt),label:o,link:s(nt),listItem:s(qe),listItemValue:f,listOrdered:s(Ct,d),listUnordered:s(Ct),paragraph:s(ot),reference:L,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(kt),strong:s(Et),thematicBreak:s(Tn)},exit:{atxHeading:l(),atxHeadingSequence:C,autolink:l(),autolinkEmail:ce,autolinkProtocol:Re,blockQuote:l(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:se,characterReferenceMarkerNumeric:se,characterReferenceValue:K,characterReference:ge,codeFenced:l(w),codeFencedFence:v,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:P,codeIndented:l(_),codeText:l(D),codeTextData:P,data:P,definition:l(),definitionDestinationString:S,definitionLabelString:x,definitionTitleString:b,emphasis:l(),hardBreakEscape:l(A),hardBreakTrailing:l(A),htmlFlow:l(R),htmlFlowData:P,htmlText:l(M),htmlTextData:P,image:l(F),label:O,labelText:j,lineEnding:B,link:l($),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:re,resourceDestinationString:E,resourceTitleString:H,resource:q,setextHeading:l(T),setextHeadingLineSequence:N,setextHeadingText:k,strong:l(),thematicBreak:l()}};XM(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(U){let J={type:"root",children:[]};const xe={stack:[J],tokenStack:[],config:t,enter:a,exit:c,buffer:o,resume:u,data:n},Ie=[];let Fe=-1;for(;++Fe<U.length;)if(U[Fe][1].type==="listOrdered"||U[Fe][1].type==="listUnordered")if(U[Fe][0]==="enter")Ie.push(Fe);else{const Nt=Ie.pop();Fe=i(U,Nt,Fe)}for(Fe=-1;++Fe<U.length;){const Nt=t[U[Fe][0]];YM.call(Nt,U[Fe][1].type)&&Nt[U[Fe][1].type].call(Object.assign({sliceSerialize:U[Fe][2].sliceSerialize},xe),U[Fe][1])}if(xe.tokenStack.length>0){const Nt=xe.tokenStack[xe.tokenStack.length-1];(Nt[1]||_k).call(xe,void 0,Nt[0])}for(J.position={start:os(U.length>0?U[0][1].start:{line:1,column:1,offset:0}),end:os(U.length>0?U[U.length-2][1].end:{line:1,column:1,offset:0})},Fe=-1;++Fe<t.transforms.length;)J=t.transforms[Fe](J)||J;return J}function i(U,J,xe){let Ie=J-1,Fe=-1,Nt=!1,en,tn,nn,oe;for(;++Ie<=xe;){const ye=U[Ie];switch(ye[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ye[0]==="enter"?Fe++:Fe--,oe=void 0;break}case"lineEndingBlank":{ye[0]==="enter"&&(en&&!oe&&!Fe&&!nn&&(nn=Ie),oe=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:oe=void 0}if(!Fe&&ye[0]==="enter"&&ye[1].type==="listItemPrefix"||Fe===-1&&ye[0]==="exit"&&(ye[1].type==="listUnordered"||ye[1].type==="listOrdered")){if(en){let rt=Ie;for(tn=void 0;rt--;){const mt=U[rt];if(mt[1].type==="lineEnding"||mt[1].type==="lineEndingBlank"){if(mt[0]==="exit")continue;tn&&(U[tn][1].type="lineEndingBlank",Nt=!0),mt[1].type="lineEnding",tn=rt}else if(!(mt[1].type==="linePrefix"||mt[1].type==="blockQuotePrefix"||mt[1].type==="blockQuotePrefixWhitespace"||mt[1].type==="blockQuoteMarker"||mt[1].type==="listItemIndent"))break}nn&&(!tn||nn<tn)&&(en._spread=!0),en.end=Object.assign({},tn?U[tn][1].start:ye[1].end),U.splice(tn||Ie,0,["exit",en,ye[2]]),Ie++,xe++}if(ye[1].type==="listItemPrefix"){const rt={type:"listItem",_spread:!1,start:Object.assign({},ye[1].start),end:void 0};en=rt,U.splice(Ie,0,["enter",rt,ye[2]]),Ie++,xe++,nn=void 0,oe=!0}}}return U[J][1]._spread=Nt,xe}function s(U,J){return xe;function xe(Ie){a.call(this,U(Ie),Ie),J&&J.call(this,Ie)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(U,J,xe){this.stack[this.stack.length-1].children.push(U),this.stack.push(U),this.tokenStack.push([J,xe||void 0]),U.position={start:os(J.start),end:void 0}}function l(U){return J;function J(xe){U&&U.call(this,xe),c.call(this,xe)}}function c(U,J){const xe=this.stack.pop(),Ie=this.tokenStack.pop();if(Ie)Ie[0].type!==U.type&&(J?J.call(this,U,Ie[0]):(Ie[1]||_k).call(this,U,Ie[0]));else throw new Error("Cannot close `"+U.type+"` ("+Cc({start:U.start,end:U.end})+"): it’s not open");xe.position.end=os(U.end)}function u(){return Ky(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(U){if(this.data.expectingFirstListItemValue){const J=this.stack[this.stack.length-2];J.start=Number.parseInt(this.sliceSerialize(U),10),this.data.expectingFirstListItemValue=void 0}}function p(){const U=this.resume(),J=this.stack[this.stack.length-1];J.lang=U}function m(){const U=this.resume(),J=this.stack[this.stack.length-1];J.meta=U}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function w(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function _(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U.replace(/(\r?\n|\r)$/g,"")}function x(U){const J=this.resume(),xe=this.stack[this.stack.length-1];xe.label=J,xe.identifier=Hr(this.sliceSerialize(U)).toLowerCase()}function b(){const U=this.resume(),J=this.stack[this.stack.length-1];J.title=U}function S(){const U=this.resume(),J=this.stack[this.stack.length-1];J.url=U}function C(U){const J=this.stack[this.stack.length-1];if(!J.depth){const xe=this.sliceSerialize(U).length;J.depth=xe}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function N(U){const J=this.stack[this.stack.length-1];J.depth=this.sliceSerialize(U).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function z(U){const xe=this.stack[this.stack.length-1].children;let Ie=xe[xe.length-1];(!Ie||Ie.type!=="text")&&(Ie=_n(),Ie.position={start:os(U.start),end:void 0},xe.push(Ie)),this.stack.push(Ie)}function P(U){const J=this.stack.pop();J.value+=this.sliceSerialize(U),J.position.end=os(U.end)}function B(U){const J=this.stack[this.stack.length-1];if(this.data.atHardBreak){const xe=J.children[J.children.length-1];xe.position.end=os(U.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(J.type)&&(z.call(this,U),P.call(this,U))}function A(){this.data.atHardBreak=!0}function R(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U}function M(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U}function D(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U}function $(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const J=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=J,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function F(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const J=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=J,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function j(U){const J=this.sliceSerialize(U),xe=this.stack[this.stack.length-2];xe.label=bX(J),xe.identifier=Hr(J).toLowerCase()}function O(){const U=this.stack[this.stack.length-1],J=this.resume(),xe=this.stack[this.stack.length-1];if(this.data.inReference=!0,xe.type==="link"){const Ie=U.children;xe.children=Ie}else xe.alt=J}function E(){const U=this.resume(),J=this.stack[this.stack.length-1];J.url=U}function H(){const U=this.resume(),J=this.stack[this.stack.length-1];J.title=U}function q(){this.data.inReference=void 0}function L(){this.data.referenceType="collapsed"}function re(U){const J=this.resume(),xe=this.stack[this.stack.length-1];xe.label=J,xe.identifier=Hr(this.sliceSerialize(U)).toLowerCase(),this.data.referenceType="full"}function se(U){this.data.characterReferenceType=U.type}function K(U){const J=this.sliceSerialize(U),xe=this.data.characterReferenceType;let Ie;xe?(Ie=zM(J,xe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ie=Gy(J);const Fe=this.stack[this.stack.length-1];Fe.value+=Ie}function ge(U){const J=this.stack.pop();J.position.end=os(U.end)}function Re(U){P.call(this,U);const J=this.stack[this.stack.length-1];J.url=this.sliceSerialize(U)}function ce(U){P.call(this,U);const J=this.stack[this.stack.length-1];J.url="mailto:"+this.sliceSerialize(U)}function Le(){return{type:"blockquote",children:[]}}function Oe(){return{type:"code",lang:null,meta:null,value:""}}function Ae(){return{type:"inlineCode",value:""}}function _e(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Qe(){return{type:"emphasis",children:[]}}function kt(){return{type:"heading",depth:0,children:[]}}function tt(){return{type:"break"}}function At(){return{type:"html",value:""}}function Jt(){return{type:"image",title:null,url:"",alt:null}}function nt(){return{type:"link",title:null,url:"",children:[]}}function Ct(U){return{type:"list",ordered:U.type==="listOrdered",start:null,spread:U._spread,children:[]}}function qe(U){return{type:"listItem",spread:U._spread,checked:null,children:[]}}function ot(){return{type:"paragraph",children:[]}}function Et(){return{type:"strong",children:[]}}function _n(){return{type:"text",value:""}}function Tn(){return{type:"thematicBreak"}}}function os(e){return{line:e.line,column:e.column,offset:e.offset}}function XM(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?XM(e,r):CX(e,r)}}function CX(e,t){let n;for(n in t)if(YM.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 _k(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Cc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Cc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Cc({start:t.start,end:t.end})+") is still open")}function EX(e){const t=this;t.parser=n;function n(r){return SX(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function NX(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 TX(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
515
515
|
`}]}function IX(e,t){const n=t.value?t.value+`
|
|
516
516
|
`:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function PX(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function RX(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function MX(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=Sl(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let o,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=s+1,a+=1,e.footnoteCounts.set(r,a);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)}function AX(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function LX(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function QM(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function DX(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return QM(e,t);const i={src:Sl(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)}function jX(e,t){const n={src:Sl(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function OX(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function BX(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return QM(e,t);const i={href:Sl(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function zX(e,t){const n={href:Sl(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function $X(e,t,n){const r=e.all(t),i=n?FX(n):ZM(t),s={},o=[];if(typeof t.checked=="boolean"){const u=r[0];let d;u&&u.type==="element"&&u.tagName==="p"?d=u:(d={type:"element",tagName:"p",properties:{},children:[]},r.unshift(d)),d.children.length>0&&d.children.unshift({type:"text",value:" "}),d.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const u=r[a];(i||a!==0||u.type!=="element"||u.tagName!=="p")&&o.push({type:"text",value:`
|
|
517
517
|
`}),u.type==="element"&&u.tagName==="p"&&!i?o.push(...u.children):o.push(u)}const l=r[r.length-1];l&&(i||l.type!=="element"||l.tagName!=="p")&&o.push({type:"text",value:`
|
|
@@ -543,7 +543,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
543
543
|
|
|
544
544
|
`)}function Bte(e){const t=jA(e);return{text:t.text,attachments:t.attachments.map((n,r)=>({id:`queued-${r}-${n.fileName}`,fileName:n.fileName,mimeType:n.type==="image"?"image/*":"application/octet-stream",url:n.url,status:"done"}))}}const H0=new Map,zte=[];function tC(e){if(e)return H0.get(e)}function nC(e,t){e&&(t.draft.length===0&&t.attachments.length===0?H0.delete(e):H0.set(e,t))}const rC=new Set;function $te(e,t){return e.trim().length>0?`${e.trimEnd()}
|
|
545
545
|
|
|
546
|
-
${t}`:t}function Fte(e){return rC.add(e),()=>rC.delete(e)}function Hte(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 Ute({api:e,cwd:t,sessionKey:n,onSend:r,disabled:i,onNewSession:s,onClearSession:o,tool:a,spawnableContacts:l=zte,ensureRemotePersonas:c,remotePersonasByDeviceId:u}){const d=tC(n),[f,p]=g.useState((d==null?void 0:d.draft)??""),[m,v]=g.useState(!1),w=g.useRef(null),_=g.useRef(!1),x=g.useCallback(()=>{_.current=!0},[]),b=g.useCallback(()=>{_.current=!1},[]),S=cp(),{attachments:C,setAttachments:k,addFiles:N,removeAttachment:T,clearAttachments:z}=jte({httpBaseUrl:S.httpBaseUrl,httpToken:S.httpToken,sessionId:n,initial:(d==null?void 0:d.attachments)??[]}),[P,B]=g.useState([]),[A,R]=g.useState(!1),[M,D]=g.useState(0),[$,F]=g.useState(!1),[j,O]=g.useState([]),[E,H]=g.useState(!1),[q,L]=g.useState(0),[re,se]=g.useState(!1),[K,me]=g.useState([]),[Re,ce]=g.useState(!1),[Le,Oe]=g.useState(null),[Ae,_e]=g.useState(!1),Qe=g.useRef(null),kt=g.useMemo(()=>{const oe=[];return s&&oe.push({name:"new",source:"builtin",description:"在当前目录下新建会话"}),o&&n&&oe.push({name:"clear",source:"builtin",description:"清除当前会话"}),oe},[s,o,n]),tt=g.useMemo(()=>[...kt,...P],[kt,P]),At=g.useMemo(()=>{const oe=f.match(/^\/(\S*)$/);return oe?oe[1]:null},[f]),Jt=At!==null&&!$,nt=g.useMemo(()=>At!==null?WA(tt,At):[],[tt,At]),Ct=g.useMemo(()=>{const oe=f.match(/^@(\S*)$/);return oe?oe[1]:null},[f]),qe=Ct!==null&&!re,ot=g.useMemo(()=>Le?((u==null?void 0:u.get(Le.deviceId))??[]).map(ye=>({kind:"remote-persona",persona:ye,deviceId:Le.deviceId})):[...j.map(oe=>({kind:"cc-agent",agent:oe})),...K.map(oe=>({kind:"persona",persona:oe})),...l.map(oe=>({kind:"contact",contact:oe}))],[Le,u,j,K,l]),Et=g.useMemo(()=>Ct!==null?VA(ot,Ct):[],[ot,Ct]),_n=g.useRef(f);g.useEffect(()=>{f!==_n.current&&(F(!1),se(!1),_n.current=f)},[f]);const Tn=g.useCallback(()=>{F(!0)},[]),U=g.useCallback(()=>{se(!0)},[]),J=g.useRef(f),xe=g.useRef(C);g.useEffect(()=>{J.current=f},[f]),g.useEffect(()=>{xe.current=C},[C]);const Ie=g.useRef(n);g.useEffect(()=>{if(n!==null)return Fte((oe,ye)=>{oe===n&&(p(rt=>$te(rt,ye)),queueMicrotask(()=>lh(w.current)))})},[n]),g.useEffect(()=>{const oe=Ie.current;if(oe===n)return;nC(oe,{draft:J.current,attachments:xe.current});const ye=tC(n);p((ye==null?void 0:ye.draft)??""),k((ye==null?void 0:ye.attachments)??[]),D(0),L(0),F(!1),se(!1),Oe(null),Qe.current=null,_e(!1),queueMicrotask(()=>{ye!=null&&ye.draft?lh(w.current):sa(w.current)}),Ie.current=n},[n,k]),g.useEffect(()=>()=>{nC(Ie.current,{draft:J.current,attachments:xe.current})},[]),g.useEffect(()=>{D(0)},[At]),g.useEffect(()=>{L(0)},[Ct]),g.useEffect(()=>{Ct===null&&Le&&(Oe(null),Qe.current=null,_e(!1))},[Ct,Le]),g.useEffect(()=>{if(!Jt||A)return;if(!e){R(!0);return}let oe=!1;return(async()=>{try{const ye=await e.skillsList(t,a);oe||(B(ye.skills??[]),R(!0))}catch{oe||R(!0)}})(),()=>{oe=!0}},[Jt,A,e,t,a]),g.useEffect(()=>{if(!qe||E)return;if(!e){H(!0);return}let oe=!1;return(async()=>{try{const ye=await e.agentsList(t,a);oe||(O(ye.agents??[]),H(!0))}catch{oe||H(!0)}})(),()=>{oe=!0}},[qe,E,e,t,a]),g.useEffect(()=>{if(!qe||Re)return;if(!e){ce(!0);return}let oe=!1;return(async()=>{try{const ye=await e.personaList();oe||(me((ye.personas??[]).filter(rt=>rt.personaId!==qT).map(rt=>({personaId:rt.personaId,label:rt.label}))),ce(!0))}catch{oe||ce(!0)}})(),()=>{oe=!0}},[qe,Re,e]);const Fe=g.useCallback(oe=>{switch(oe.kind){case"persona":p(`@persona/${oe.persona.personaId} `);break;case"cc-agent":p(`@"${oe.agent.name} (agent)" `);break;case"contact":{const ye=oe.contact.deviceId;Oe({deviceId:ye,displayName:oe.contact.displayName}),Qe.current=ye,_e(!0),Promise.resolve(c==null?void 0:c(ye)).finally(()=>{Qe.current===ye&&_e(!1)}),p("@"),se(!1),setTimeout(()=>{var rt;return(rt=w.current)==null?void 0:rt.focus()},0);return}case"remote-persona":p(`@persona/${oe.persona.personaId}@${oe.deviceId} `),Oe(null);break}se(!1),setTimeout(()=>{var ye;return(ye=w.current)==null?void 0:ye.focus()},0)},[c]),Nt=g.useCallback(()=>{Oe(null),Qe.current=null,_e(!1),p("@"),setTimeout(()=>{var oe;return(oe=w.current)==null?void 0:oe.focus()},0)},[]),en=g.useCallback(oe=>{if(oe.source==="builtin"&&oe.name==="new"&&s){p(""),z(),sa(w.current),s(t);return}if(oe.source==="builtin"&&oe.name==="clear"&&o){p(""),z(),sa(w.current),o();return}p(`/${oe.name} `),setTimeout(()=>{var ye;return(ye=w.current)==null?void 0:ye.focus()},0)},[s,t,z,o]),tn=g.useCallback(async()=>{const oe=f.trim(),ye=C.filter(mt=>mt.status==="done");if(!oe&&ye.length===0||m||i)return;if(oe==="/new"&&s){v(!0);try{await s(t),p(""),z(),sa(w.current)}finally{v(!1)}return}if(oe==="/clear"&&o){v(!0);try{await o(),p(""),z(),sa(w.current)}finally{v(!1)}return}const rt=a==="codex"||a==="pi"?Hte(oe,P):oe;v(!0);try{const mt=Lee(rt,C);await r(mt,{queueWhileRunning:!0}),p(""),z(),sa(w.current)}finally{v(!1)}},[f,C,m,i,r,s,t,z,o,a,P]),nn=g.useCallback(oe=>{const{text:ye,attachments:rt}=Bte(oe);if(p(ye),rt.length>0){const mt=new Set(xe.current.map(fr=>fr.id));k([...xe.current,...rt.filter(fr=>!mt.has(fr.id))])}queueMicrotask(()=>lh(w.current))},[k]);return{draft:f,setDraft:p,sending:m,textareaRef:w,isComposingRef:_,onCompositionStart:x,onCompositionEnd:b,attachments:C,addFiles:N,removeAttachment:T,skillSelectorVisible:Jt,filteredSkills:nt,slashQuery:At??"",activeSkillIdx:M,setActiveSkillIdx:D,selectSkill:en,dismissSkillSelector:Tn,agentSelectorVisible:qe,filteredAgents:Et,mentionQuery:Ct,activeAgentIdx:q,setActiveAgentIdx:L,selectAgent:Fe,dismissAgentSelector:U,drilldown:Le,drilldownLoading:Ae,exitDrilldown:Nt,doSend:tn,restoreTextToDraft:nn}}const Wte=120;function lh(e){e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,Wte)}px`)}function sa(e){e&&(e.style.height="auto")}function Vte({items:e,restoreDisabled:t,onRestore:n,onRemove:r}){return e.length===0?null:h.jsxs("div",{"data-testid":"chat-input-queue",className:"flex flex-col",children:[h.jsx("div",{className:"px-1 pb-1 text-[11px] text-text-400",children:`排队中 · ${e.length} 条(这一轮跑完连起来一起发出)`}),e.map((i,s)=>h.jsxs("div",{"data-testid":`chat-input-queue-item-${i.id}`,className:"flex items-center gap-2 rounded-md px-1 py-1 transition-colors hover:bg-text-100/5",children:[h.jsx("span",{className:"shrink-0 w-4 text-center text-[11px] text-text-400 tabular-nums",children:s+1}),h.jsx("button",{type:"button","data-testid":`chat-input-queue-restore-${i.id}`,disabled:t,title:t?"先清空输入框再取回这条":"取回输入框继续改",onClick:()=>n(i.id),className:"flex-1 min-w-0 text-left text-[12.5px] text-text-200 truncate hover:text-text-100 disabled:cursor-not-allowed disabled:hover:text-text-200",children:i.text.trim()||"(空消息)"}),h.jsx("button",{type:"button","aria-label":"移出队列","data-testid":`chat-input-queue-remove-${i.id}`,onClick:()=>r(i.id),className:"shrink-0 p-0.5 rounded text-text-400 hover:text-text-100 hover:bg-text-100/10",children:h.jsx(qr,{className:"w-3.5 h-3.5"})})]},i.id))]})}const qte="[--color-border:#E6E6E6] [--bg-300:#E6E6E6] dark:[--color-border:#424242] dark:[--bg-300:#424242]",Kte={spawnableContacts:[],ensureRemotePersonas:()=>Promise.resolve(),remotePersonasByDeviceId:new Map},Gte=g.createContext(Kte);function Yte(){return g.useContext(Gte)}function Xte({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{iC(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(Qx,{className:"h-3 w-3"}),r?"Copied":"Copy"]}),h.jsxs("button",{type:"button",onClick:()=>iC(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(m8,{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(qr,{className:"h-3 w-3"})})]})]})})}function iC(e,t){const n=document.createElement("a");n.href=e,n.download=t||"image",n.click()}const sC=1e3,qA=`bg-bg-50 ${qte}`,oC=`mx-2 -mb-3 rounded-t-xl border border-b-0 border-border px-3 pt-2 pb-4 ${qA}`,Qte=5e3;function Pd(e){if(!e)return"null";if(e===document.body)return"body";const t=e.getAttribute("data-testid"),n=typeof e.className=="string"&&e.className.trim()?`.${e.className.trim().split(/\s+/).slice(0,3).join(".")}`:"";return`${e.tagName.toLowerCase()}${e.id?`#${e.id}`:""}${t?`[${t}]`:""}${n}`}function Zte({meta:e,api:t,cwd:n,tool:r,onSend:i,sessionKey:s,queued:o,onDequeue:a,disabled:l=!1,placeholder:c,className:u,awaitingUser:d=!1,onAbort:f,onNewSession:p,onClearSession:m,configSlot:v,aboveSlot:w}){const _=(e==null?void 0:e.streamInProgress)??!1,x=(e==null?void 0:e.contextPct)??null,b=x==null?"":x>=80?"text-red-400":x>=50?"text-amber-400":"text-text-500",S=g.useRef(null),C=Yte(),k=Ute({...t?{api:t}:{},cwd:n,...r?{tool:r}:{},sessionKey:s,onSend:i,disabled:l,...p?{onNewSession:p}:{},...m?{onClearSession:m}:{},spawnableContacts:C.spawnableContacts,ensureRemotePersonas:C.ensureRemotePersonas,remotePersonasByDeviceId:C.remotePersonasByDeviceId}),{draft:N,setDraft:T,sending:z,textareaRef:P,attachments:B,addFiles:A,removeAttachment:R,skillSelectorVisible:M,filteredSkills:D,slashQuery:$,activeSkillIdx:F,setActiveSkillIdx:j,selectSkill:O,dismissSkillSelector:E,agentSelectorVisible:H,filteredAgents:q,mentionQuery:L,activeAgentIdx:re,setActiveAgentIdx:se,selectAgent:K,dismissAgentSelector:me,drilldown:Re,drilldownLoading:ce,exitDrilldown:Le,doSend:Oe,restoreTextToDraft:Ae}=k,_e=g.useCallback(()=>{(async()=>{const ae=await(f==null?void 0:f());ae&&ae.length>0&&Ae(Ote(ae,N))})()},[f,Ae,N]),Qe=g.useCallback(ae=>{const Je=o==null?void 0:o.find(hn=>hn.id===ae);!Je||!a||N.trim().length>0||(a(ae),Ae(Je.text))},[o,a,N,Ae]),kt=yte();g.useEffect(()=>{if(!kt||kt.signal===0||s===null||kt.sessionId!==s)return;const{signal:ae}=kt;console.log("[chat-focus] 收到聚焦信号",{sessionKey:s,signal:ae,delayMs:sC,activeElement:Pd(document.activeElement)});let Je=null,hn=null,Ys=null;const Nl=setTimeout(()=>{if(Je=P.current,!Je){console.warn("[chat-focus] textarea 已不在,放弃聚焦",{sessionKey:s,signal:ae});return}Je.focus(),console.log("[chat-focus] focus() 已执行",{sessionKey:s,signal:ae,landed:document.activeElement===Je,activeElement:Pd(document.activeElement)}),hn=Yo=>{const ts=Pd(Yo.relatedTarget);setTimeout(()=>{console.warn("[chat-focus] STOLEN 输入框失焦",{sessionKey:s,signal:ae,relatedTarget:ts,activeElementAfterTick:Pd(document.activeElement)})},0)},Je.addEventListener("blur",hn,{once:!0}),Ys=setTimeout(()=>{Je&&hn&&Je.removeEventListener("blur",hn)},Qte)},sC);return()=>{clearTimeout(Nl),Ys&&clearTimeout(Ys),Je&&hn&&Je.removeEventListener("blur",hn)}},[kt==null?void 0:kt.signal]);const tt=!!t,At=z||l||_,nt=(N.trim().length>0||B.some(ae=>ae.status==="done"))&&!l&&!z&&!d,Ct=c??(d?"Answer the question above first...":At?"Queue a message...":`Message ${ry(r)}...`),qe=g.useRef(!1),ot=g.useCallback(()=>{qe.current=!0},[]),Et=g.useCallback(()=>{qe.current=!1},[]),_n=g.useCallback(ae=>{if(M&&D.length>0){if(ae.key==="ArrowDown")return ae.preventDefault(),j(F>=D.length-1?0:F+1),!0;if(ae.key==="ArrowUp")return ae.preventDefault(),j(F<=0?D.length-1:F-1),!0;if(ae.key==="Tab"||ae.key==="Enter"&&!ae.shiftKey){ae.preventDefault();const Je=D[F];return Je&&O(Je),!0}if(ae.key==="Escape")return ae.preventDefault(),E(),!0}return!1},[M,D,F,j,O,E]),Tn=g.useCallback(ae=>{if(H&&q.length>0){if(ae.key==="ArrowDown")return ae.preventDefault(),se(re>=q.length-1?0:re+1),!0;if(ae.key==="ArrowUp")return ae.preventDefault(),se(re<=0?q.length-1:re-1),!0;if(ae.key==="Tab"||ae.key==="Enter"&&!ae.shiftKey){ae.preventDefault();const Je=q[re];return Je&&K(Je),!0}if(ae.key==="Escape")return ae.preventDefault(),Re?Le():me(),!0}return!1},[H,q,re,se,K,me,Re,Le]),U=g.useCallback(ae=>{const Je=ae.nativeEvent;ae.key==="Enter"&&BR({compositionActive:qe.current,nativeIsComposing:Je.isComposing,keyCode:Je.keyCode})||_n(ae)||Tn(ae)||zR({key:ae.key,shiftKey:ae.shiftKey,compositionActive:qe.current,nativeIsComposing:Je.isComposing,keyCode:Je.keyCode})&&(ae.preventDefault(),nt&&Oe())},[_n,Tn,nt,Oe]),J=g.useCallback(ae=>{T(ae.target.value),lh(ae.target)},[T]),xe=g.useCallback(ae=>{ae.target.files&&A(ae.target.files),ae.target.value=""},[A]),Ie=g.useCallback(ae=>{if(!tt)return;const Je=Array.from(ae.clipboardData.items).map(hn=>hn.getAsFile()).filter(hn=>!!(hn&&hn.type.startsWith("image/")));Je.length!==0&&(ae.preventDefault(),A(Je))},[A,tt]),[Fe,Nt]=g.useState(null),en=g.useCallback(ae=>{ae.previewUrl&&Nt({url:ae.previewUrl,name:ae.fileName})},[]),[tn,nn]=g.useState(!1),oe=g.useCallback(ae=>{tt&&(ae.preventDefault(),nn(!0))},[tt]),ye=g.useCallback(()=>nn(!1),[]),rt=g.useCallback(ae=>{tt&&(ae.preventDefault(),nn(!1),ae.dataTransfer.files.length>0&&A(ae.dataTransfer.files))},[A,tt]),mt=_&&!d&&typeof f=="function",fr=l||d;return h.jsxs("div",{"data-testid":"chat-input",className:ne("shrink-0 border-t border-bg-300/20 px-4 py-3",u),onDragOver:oe,onDragLeave:ye,onDrop:rt,children:[h.jsxs("div",{className:"max-w-3xl mx-auto relative",children:[tt?h.jsx("input",{ref:S,type:"file",multiple:!0,accept:Tte,hidden:!0,onChange:xe,"data-testid":"chat-input-file"}):null,h.jsxs("div",{"data-testid":"chat-input-bare",className:ne("flex flex-col gap-2"),children:[d||z||_?h.jsxs("div",{"data-testid":"chat-input-status-bar",className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsxs("div",{className:"flex gap-1",children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"0ms"}}),h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"150ms"}}),h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"300ms"}})]}),h.jsx("span",{children:d?"Waiting for your answer":`${Oz(r)?"Codex":r==="pi"?"pi":"Claude"} is working`})]}):null,M?h.jsx(_te,{query:$,skills:D,activeIndex:F,onActiveIndexChange:j,onSelect:O}):null,H?Re?!C.remotePersonasByDeviceId.has(Re.deviceId)&&ce?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:`正在加载 @${Re.displayName} 的 persona…`}):q.length>0?h.jsx(Jk,{query:L??"",entries:q,activeIndex:re,onActiveIndexChange:se,onSelect:K}):h.jsx("div",{"data-testid":"cc-agent-remote-empty",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 rounded-2xl border border-bg-300 bg-bg-50 px-4 py-3 text-[12px] text-text-300 shadow-lg",children:`@${Re.displayName} 暂无可派活的 persona(可能离线或未公开)`}):h.jsx(Jk,{query:L??"",entries:q,activeIndex:re,onActiveIndexChange:se,onSelect:K}):null,o&&o.length>0?h.jsx("div",{"data-testid":"chat-input-queue-header",className:oC,children:h.jsx(Vte,{items:o,restoreDisabled:N.trim().length>0||!a,onRestore:Qe,onRemove:ae=>void(a==null?void 0:a(ae))})}):null,B.length>0?h.jsx(Ete,{attachments:B,onRemove:R,onOpenPreview:en}):null,w?h.jsx("div",{"data-testid":"chat-input-above-slot",className:oC,children:w}):null,h.jsxs("div",{"data-testid":"bare-chat-input-frame",className:ne("relative flex flex-col gap-1 rounded-xl border border-border px-3 py-2 transition-colors duration-200",qA,fr?"opacity-60":null,tn?"border-accent/60 bg-accent/5":null),children:[h.jsx("textarea",{ref:P,"data-testid":"chat-input-textarea",value:N,onChange:J,onKeyDown:U,onCompositionStart:ot,onCompositionEnd:Et,onPaste:Ie,placeholder:Ct,disabled:fr,readOnly:fr,rows:1,className:"w-full resize-none bg-transparent border-0 outline-none text-[14px] text-text-100 placeholder:text-text-400 leading-relaxed py-1 min-h-[22px] max-h-[120px] overflow-y-auto disabled:cursor-not-allowed"}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[tt?h.jsx("button",{type:"button",onClick:()=>{var ae;return(ae=S.current)==null?void 0:ae.click()},disabled:At,"data-testid":"chat-input-attach","aria-label":"attach files",className:ne("flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors",At?"cursor-default text-text-400/50":"cursor-pointer text-text-400 hover:bg-text-100/5 hover:text-text-200"),children:h.jsx(K8,{className:"h-4 w-4"})}):null,h.jsx("div",{className:"flex-1 min-w-0"}),x!=null?h.jsxs("span",{"data-testid":"chat-input-ctx",className:ne("shrink-0 text-[11px] tabular-nums",b),children:["ctx:",x,"%"]}):null,v,mt?h.jsx("button",{type:"button",onClick:_e,"data-testid":"chat-input-abort","aria-label":"interrupt",title:"中断当前轮次(不杀进程)",className:"h-8 w-8 rounded-full flex items-center justify-center border border-text-400/40 text-text-400 hover:bg-text-100/5 hover:text-text-100 transition-colors cursor-pointer",children:h.jsx(kI,{className:"w-3.5 h-3.5",strokeWidth:2.5})}):null,h.jsx("button",{type:"button",onClick:()=>{nt&&Oe()},disabled:!nt,"data-testid":"chat-input-send","aria-label":"send",className:ne("h-8 w-8 rounded-full flex items-center justify-center transition-colors",nt?"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(W$,{className:"w-4 h-4",strokeWidth:2.5})})]})]})]})]}),Fe?h.jsx(Xte,{url:Fe.url,fileName:Fe.name,onClose:()=>Nt(null)}):null]})}function Jte(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function ene({meta:e,tool:t,connState:n,variant:r="full",onOpenConfig:i,liveWorktreeRoot:s,ephemeral:o=!1,onPromote:a,cloudVolume:l,className:c}){const u=s??e.cwd??"",f=!!e.sessionLabel&&e.sessionLabel!==e.sessionId?e.sessionLabel:Jte(u),p=u;return r==="quickask"?h.jsxs("div",{"data-testid":"chat-header","data-variant":"quickask",className:ne("flex items-center shrink-0 px-3 py-2 gap-2",c),children:[a?h.jsx("button",{type:"button","data-testid":"chat-header-promote","data-promoted":o?"false":"true",disabled:!o,onClick:a,title:o?"保留为正式会话":"已保留为正式会话",className:ne("shrink-0 inline-flex items-center justify-center h-5 w-5 rounded-md transition-colors",o?"text-text-500 hover:text-text-200 hover:bg-text-100/5 cursor-pointer":"text-amber-400"),children:h.jsx(Q$,{className:ne("w-3.5 h-3.5",!o&&"fill-current")})}):null,h.jsx("span",{className:"font-semibold text-text-100 truncate text-[13px]","data-testid":"chat-header-worktree",title:p,children:f})]}):h.jsxs("div",{"data-testid":"chat-header","data-variant":"full",className:ne("relative flex items-center shrink-0 px-4 py-2.5",l?"pr-36 md:pr-32":"pr-[4.5rem] md:pr-4",c),children:[h.jsx("span",{className:"font-semibold text-text-100 truncate text-[13px]","data-testid":"chat-header-worktree",title:p,children:f}),h.jsxs("div",{className:"absolute right-4 top-1/2 -translate-y-1/2 z-10 flex items-center gap-1",children:[l,i?h.jsx("button",{type:"button","aria-label":"Session settings","data-testid":"chat-header-settings-mobile",onClick:i,title:"Session settings",className:"flex md:hidden h-7 w-7 items-center justify-center rounded-md bg-transparent text-text-300 transition-colors duration-150 hover:bg-bg-200 hover:text-text-100 cursor-pointer outline-none",children:h.jsx(bI,{className:"w-4 h-4"})}):null]})]})}function tne({testid:e,children:t}){return h.jsx("div",{"data-testid":e,className:"h-full min-w-0 border-l border-border bg-bg-100 flex flex-col",children:t})}function nne({title:e,onBack:t,onCollapse:n,collapseLabel:r="collapse session info",collapseTitle:i="收起会话信息"}){const s=o=>h.jsx("button",{type:"button","data-testid":"session-info-collapse",onClick:n,"aria-label":r,title:i,className:`p-1 rounded text-text-400 hover:text-text-100 hover:bg-text-100/10 ${o}`,children:h.jsx(Uw,{className:"w-4 h-4"})});return h.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b border-border shrink-0",children:[t?h.jsx("button",{type:"button","data-testid":"session-info-back",onClick:t,"aria-label":"返回会话信息",className:"p-1 -ml-1 rounded text-text-400 hover:text-text-100 hover:bg-text-100/10",children:h.jsx($$,{className:"w-4 h-4"})}):n?s("-ml-1"):h.jsx(Uw,{className:"w-4 h-4 text-text-300"}),h.jsx("span",{className:"flex-1 text-[13px] font-medium text-text-100 truncate",children:e}),t&&n?s(""):null]})}function sg({icon:e,label:t,meta:n,onClick:r,testid:i}){return h.jsxs("button",{type:"button","data-testid":i,onClick:r,className:"w-full flex items-center gap-2.5 px-2 py-1.5 rounded-md cursor-pointer text-left hover:bg-text-100/5",children:[h.jsx("span",{className:"w-4 h-4 shrink-0 text-text-300 inline-flex items-center justify-center",children:e}),h.jsx("span",{className:"flex-1 text-[12.5px] text-text-100",children:t}),n?h.jsx("span",{className:"shrink-0 text-[11px] text-text-400 font-mono",children:n}):null]})}let rne=null;function ine(){return rne}function oc({label:e,labelTitle:t,children:n}){return h.jsxs("div",{className:"flex items-start gap-2 px-2 py-1",children:[h.jsx("span",{className:"w-14 shrink-0 truncate text-[11px] text-text-400 pt-0.5",...t?{title:t}:{},children:e}),h.jsx("span",{className:"flex-1 min-w-0 text-[12px] text-text-100",children:n})]})}function aC({label:e,labelTitle:t,value:n,testid:r}){const[i,s]=g.useState(!1),o=g.useRef(null);g.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]);const a=()=>{typeof navigator>"u"||!navigator.clipboard||navigator.clipboard.writeText(n).then(()=>{s(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>s(!1),2e3)},()=>{})};return h.jsx(oc,{label:e,labelTitle:t,children:h.jsxs("button",{type:"button",onClick:a,"data-testid":r,title:i?"已复制":`复制:${n}`,className:"w-full flex items-center gap-1.5 text-left group cursor-pointer",children:[h.jsx("span",{className:"font-mono text-[11px] text-text-300 truncate flex-1 min-w-0",children:n}),i?h.jsx(bu,{className:"w-3 h-3 shrink-0 text-accent"}):h.jsx(Qx,{className:"w-3 h-3 shrink-0 text-text-400 opacity-0 group-hover:opacity-100 transition-opacity"})]})})}function sne({session:e,meta:t,liveGitBranch:n,liveWorktreeRoot:r,personaName:i,onOpenPersona:s,onOpenFiles:o,cronActiveCount:a,onCronClick:l,onForceStop:c,viewerRole:u="owner",toolSessionIdLabel:d="tool session id",drill:f=null,onCollapse:p,title:m="会话信息",leadingEntries:v}){const w=n!==void 0?n:t.gitBranch??null,_=t.procAlive??!1,x=qI(e),b=x!=null&&e.originOwnerPrincipalId==null&&u!=="guest",[S,C]=g.useState(null),k=g.useRef(null);g.useEffect(()=>()=>{k.current&&clearTimeout(k.current)},[]);const N=async()=>{if(!b)return;const T=ine();let z;try{T||(await navigator.clipboard.writeText(x),z="命令已复制")}catch{z="操作失败"}C(z),k.current&&clearTimeout(k.current),k.current=setTimeout(()=>C(null),2500)};return h.jsxs(tne,{testid:"session-info-panel",children:[h.jsx(nne,{title:f?f.title:m,...f?{onBack:f.onBack}:{},...p?{onCollapse:p}:{},collapseTitle:`收起${m}`}),f?h.jsx("div",{"data-testid":"session-info-drill",className:"flex-1 min-h-0 overflow-y-auto",children:f.content}):h.jsxs("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:[w?h.jsx(oc,{label:"分支",children:h.jsxs("span",{"data-testid":"session-info-branch",className:"inline-flex items-center gap-1 font-mono text-[11.5px] min-w-0",title:r??void 0,children:[h.jsx(Zx,{className:"w-3 h-3 shrink-0 text-text-400"}),h.jsx("span",{className:"truncate",children:w})]})}):null,i&&s?h.jsx(oc,{label:"persona",children:h.jsxs("button",{type:"button","data-testid":"session-info-persona",onClick:s,className:"inline-flex items-center gap-1 hover:text-accent cursor-pointer",children:[h.jsx(TI,{className:"w-3 h-3"}),h.jsx("span",{className:"truncate",children:i})]})}):null,h.jsx(oc,{label:"引擎",children:h.jsxs("span",{className:"inline-flex items-center gap-1.5","data-testid":"session-info-engine",children:[h.jsx(dp,{tool:e.tool,className:ne("w-3.5 h-3.5 shrink-0",hp(e.tool))}),h.jsxs("span",{className:"truncate",children:[ry(e.tool),t.model?` · ${t.model}`:""]})]})}),h.jsx(oc,{label:"cwd",children:h.jsx("span",{"data-testid":"session-info-cwd",className:"font-mono text-[11px] text-text-300 truncate block",title:e.cwd,children:e.cwd})}),h.jsx(aC,{label:"session id",value:e.sessionId,testid:"session-info-session-id"}),e.toolSessionId?h.jsx(aC,{label:`${e.tool||"claude"} id`,labelTitle:d,value:e.toolSessionId,testid:"session-info-tool-session-id"}):null,h.jsx("div",{className:"my-2 border-t border-border"}),v,o?h.jsx(sg,{icon:h.jsx(w8,{className:"w-3.5 h-3.5"}),label:"Edited Files",onClick:o,testid:"session-info-files"}):null,a&&a>0&&l?h.jsx(sg,{icon:h.jsx(u8,{className:"w-3.5 h-3.5"}),label:"定时任务",meta:String(a),onClick:l,testid:"session-info-cron"}):null,b?h.jsx(sg,{icon:h.jsx(vF,{className:"w-3.5 h-3.5"}),label:"终端",meta:S,onClick:()=>void N(),testid:"session-info-terminal"}):null]}),_&&c?h.jsx("div",{className:"shrink-0 border-t border-border px-3 py-2.5",children:h.jsxs("button",{type:"button","data-testid":"session-info-force-stop",onClick:c,title:e.tool==="codex"?"强制停止 Codex 进程":"强制停止 Claude Code 进程(会丢失 initialize / 预热缓存)",className:"inline-flex items-center gap-1.5 h-6 px-2.5 rounded-md text-text-400 hover:bg-red-500/10 hover:text-red-400 transition-colors text-[12px] cursor-pointer",children:[h.jsx(W8,{className:"w-3.5 h-3.5"}),h.jsx("span",{children:"强制停止"})]})}):null]})}const one=g.createContext({container:null});function ane(){return g.useContext(one)}const s1="fixed top-0 md:top-10 bottom-0 right-0";function lne({api:e,cwd:t,toolSessionId:n,toolKind:r="claude"}){const i=$A(),s=(i==null?void 0:i.state.agentId)??null,o=i==null?void 0:i.state.agentType,[a,l]=g.useState([]),[c,u]=g.useState(!1),[d,f]=g.useState(null);g.useEffect(()=>{if(!s)return;let m=!1;return u(!0),f(null),l([]),e.historySubagentRead({cwd:t,toolSessionId:n,subagentId:s}).then(v=>{m||l(v.messages??[])}).catch(v=>{m||f(v instanceof Error?v.message:String(v))}).finally(()=>{m||u(!1)}),()=>{m=!0}},[s,t,n,e]);const p=g.useMemo(()=>a.length>0?gM(a,0,r):[],[a,r]);return!i||!s?null:h.jsxs("div",{"data-testid":"subagent-drawer","data-agent-id":s,className:ne(s1,"z-50 w-[min(560px,92vw)]","flex flex-col border-l border-bg-200/60 bg-bg-50 shadow-xl"),style:{paddingTop:"env(safe-area-inset-top)"},children:[h.jsxs("div",{className:"flex flex-col gap-0.5 px-3 py-2 border-b border-bg-200/60",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o?h.jsx("span",{className:"inline-flex items-center rounded-sm bg-violet-500/10 px-1.5 py-0.5 text-[11px] text-violet-400 font-medium",children:o}):null,h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate",title:s,children:s})]}),h.jsx("button",{type:"button","aria-label":"关闭",onClick:()=>i.close(),className:"p-1 rounded hover:bg-bg-200/50 text-text-400 hover:text-text-200",children:h.jsx(qr,{className:"w-4 h-4"})})]}),!c&&!d&&a.length>0?h.jsxs("div",{className:"text-[11px] text-text-400",children:[a.length," 条消息 · 首条为主会话派发的任务指令"]}):null]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden px-3 py-2",children:c?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(cr,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"加载中…"})]}):d?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-error",children:[h.jsx(Fo,{className:"w-3.5 h-3.5"}),h.jsx("span",{children:d})]}):p.length===0?h.jsx("div",{className:"text-[12px] text-text-400 italic",children:"无消息"}):h.jsx(UA,{lines:p})})]})}function lC(e,t){let n=0;for(const r of e.lines)r.startsWith(t)&&n++;return n}function cne(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+=lC(m,"+"),p.deletions+=lC(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 une({open:e,onOpenChange:t,api:n,sessionId:r,userMessageId:i,lines:s,procAlive:o,onApplied:a,onNoChanges:l}){const c=g.useMemo(()=>cne(s,i),[s,i]),[u,d]=g.useState(null),[f,p]=g.useState(!1),[m,v]=g.useState(!1),[w,_]=g.useState(null);g.useEffect(()=>{if(!e)return;let k=!1;return p(!0),d(null),(async()=>{try{const N=await n.sessionRewindDiff({sessionId:r,userMessageId:i});k||(d(N),!N.canRewind&&!N.error&&N.files.length===0&&(l==null||l(i)))}catch{k||d(null)}finally{k||p(!1)}})(),()=>{k=!0}},[e,n,r,i]);const 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(N=>({filePath:N.filePath,hunks:N.hunks,insertions:N.insertions,deletions:N.deletions})),totalInsertions:u.totalInsertions,totalDeletions:u.totalDeletions}}return{source:"local",anchorFound:c.anchorFound,files:c.files,totalInsertions:c.totalInsertions,totalDeletions:c.totalDeletions,rpcError:u==null?void 0:u.error}},[u,c]),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 S=x.files.length>0,C=!f&&!m&&x.anchorFound&&S&&!w;return h.jsxs("div",{"data-testid":"rewind-preview-drawer",className:`${s1} 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(NI,{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(qr,{className:"w-4 h-4"})})]}),w?h.jsxs("div",{"data-testid":"rewind-error-banner",className:"mx-4 mt-3 flex items-start gap-2 rounded-md border border-red-400/40 bg-red-500/10 px-3 py-2 text-[12px] text-red-400",children:[h.jsx(tf,{className:"w-4 h-4 shrink-0 mt-0.5"}),h.jsx("span",{children:w})]}):null,h.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-3",children:f?h.jsxs("div",{"data-testid":"rewind-loading",className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(cr,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"正在读取快照…"})]}):x.anchorFound?S?h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":"rewind-summary",className:"rounded-md border border-bg-300 bg-bg-100/40 px-3 py-2 text-[12px] text-text-200",children:[h.jsxs("div",{children:["将回退 ",h.jsx("span",{className:"font-semibold text-text-100",children: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(hne,{file:k},k.filePath))]}):h.jsxs("div",{"data-testid":"rewind-no-changes",className:"rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300 space-y-1",children:[h.jsx("div",{children:"磁盘上的文件已经和这个时刻的快照完全一致——没有需要回退的改动。"}),h.jsx("div",{className:"text-text-400 text-[11px]",children:"可能这条消息之后 Claude 没落盘编辑,或之前已经 rewind 过了。"})]}):h.jsx("div",{"data-testid":"rewind-no-anchor",className:"rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300",children:"未能在当前消息流中找到对应的用户消息(可能已被历史裁剪)。"})}),h.jsxs("div",{className:"flex flex-col gap-2 px-4 py-3 border-t border-bg-300/30 shrink-0",children:[S&&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(tf,{className:"w-4 h-4 shrink-0 mt-0.5 text-warning"}),h.jsx("span",{children:'Claude Code 进程当前未运行。点击"确认回退"时会自动启动它再执行 — 可能需要等一两秒。'})]}):null,h.jsxs("div",{className:"flex items-center justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:()=>t(!1),className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),h.jsx("button",{type:"button",disabled:!C,onClick:()=>void b(),"data-testid":"rewind-apply",className:ne("h-8 px-3 rounded-md text-[12px] font-medium transition-colors",C?"bg-accent text-white hover:bg-accent-hover cursor-pointer":"bg-bg-200 text-text-400 cursor-not-allowed"),children:m?"回退中…":"确认回退"})]})]})]})}function dne(e){return e.replace(/^\/Users\/[^/]+/,"~")}function hne({file:e}){const[t,n]=g.useState(!0);return h.jsxs("div",{"data-testid":"rewind-file-block","data-file":e.filePath,className:"rounded-md border border-bg-300 overflow-hidden bg-bg-0",children:[h.jsxs("button",{type:"button",onClick:()=>n(r=>!r),className:"w-full flex items-center gap-1.5 px-3 py-2 text-[12px] hover:bg-text-100/5 cursor-pointer",children:[t?h.jsx(Yn,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(Bn,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"font-mono text-text-200 truncate flex-1 text-left",title:e.filePath,children:dne(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(fne,{hunk:r},`${r.oldStart}-${r.oldLines}-${r.newStart}-${r.newLines}`))}):null]})}function fne({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:ne("px-3 whitespace-pre",s),children:n.length>0?n:" "},r)})]})}function pne({jobs:e}){return e.length===0?h.jsx("div",{"data-testid":"cron-job-list-empty",className:"px-4 py-3 text-sm text-text-500",children:"当前会话暂无活跃 cron 任务"}):h.jsx("ul",{"data-testid":"cron-job-list",className:"flex flex-col gap-2",children:e.map(t=>h.jsxs("li",{"data-testid":`cron-job-${t.id}`,className:"flex flex-col gap-1 rounded-md border border-border px-3 py-2",children:[h.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[h.jsx("span",{className:"font-mono text-text-300",children:t.id}),h.jsx("span",{className:"text-text-500",children:"·"}),h.jsx("span",{className:"text-text-400",children:t.humanSchedule}),t.recurring?h.jsx("span",{"data-testid":`cron-job-${t.id}-recurring-badge`,className:"ml-auto rounded-md bg-accent-dim px-2 py-0.5 text-accent",children:"recurring"}):null]}),h.jsx("div",{className:"text-sm text-text-200 truncate",title:t.prompt,children:t.prompt})]},t.id))})}const mne={idle:"还没启动","turn-running":"正在 run 中","turn-idle":"进程活着,等输入",exited:"进程已退出",crashed:"启动失败 / 异常退出"};function gne({sessionStatus:e}){switch(e){case"idle":return"idle";case"running":return"turn-running";case"running-idle":return"turn-idle";case"observing":return"turn-running";case"stopped":return"exited";case"error":return"crashed"}}/**
|
|
546
|
+
${t}`:t}function Fte(e){return rC.add(e),()=>rC.delete(e)}function Hte(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 Ute({api:e,cwd:t,sessionKey:n,onSend:r,disabled:i,onNewSession:s,onClearSession:o,tool:a,spawnableContacts:l=zte,ensureRemotePersonas:c,remotePersonasByDeviceId:u}){const d=tC(n),[f,p]=g.useState((d==null?void 0:d.draft)??""),[m,v]=g.useState(!1),w=g.useRef(null),_=g.useRef(!1),x=g.useCallback(()=>{_.current=!0},[]),b=g.useCallback(()=>{_.current=!1},[]),S=cp(),{attachments:C,setAttachments:k,addFiles:N,removeAttachment:T,clearAttachments:z}=jte({httpBaseUrl:S.httpBaseUrl,httpToken:S.httpToken,sessionId:n,initial:(d==null?void 0:d.attachments)??[]}),[P,B]=g.useState([]),[A,R]=g.useState(!1),[M,D]=g.useState(0),[$,F]=g.useState(!1),[j,O]=g.useState([]),[E,H]=g.useState(!1),[q,L]=g.useState(0),[re,se]=g.useState(!1),[K,ge]=g.useState([]),[Re,ce]=g.useState(!1),[Le,Oe]=g.useState(null),[Ae,_e]=g.useState(!1),Qe=g.useRef(null),kt=g.useMemo(()=>{const oe=[];return s&&oe.push({name:"new",source:"builtin",description:"在当前目录下新建会话"}),o&&n&&oe.push({name:"clear",source:"builtin",description:"清除当前会话"}),oe},[s,o,n]),tt=g.useMemo(()=>[...kt,...P],[kt,P]),At=g.useMemo(()=>{const oe=f.match(/^\/(\S*)$/);return oe?oe[1]:null},[f]),Jt=At!==null&&!$,nt=g.useMemo(()=>At!==null?WA(tt,At):[],[tt,At]),Ct=g.useMemo(()=>{const oe=f.match(/^@(\S*)$/);return oe?oe[1]:null},[f]),qe=Ct!==null&&!re,ot=g.useMemo(()=>Le?((u==null?void 0:u.get(Le.deviceId))??[]).map(ye=>({kind:"remote-persona",persona:ye,deviceId:Le.deviceId})):[...j.map(oe=>({kind:"cc-agent",agent:oe})),...K.map(oe=>({kind:"persona",persona:oe})),...l.map(oe=>({kind:"contact",contact:oe}))],[Le,u,j,K,l]),Et=g.useMemo(()=>Ct!==null?VA(ot,Ct):[],[ot,Ct]),_n=g.useRef(f);g.useEffect(()=>{f!==_n.current&&(F(!1),se(!1),_n.current=f)},[f]);const Tn=g.useCallback(()=>{F(!0)},[]),U=g.useCallback(()=>{se(!0)},[]),J=g.useRef(f),xe=g.useRef(C);g.useEffect(()=>{J.current=f},[f]),g.useEffect(()=>{xe.current=C},[C]);const Ie=g.useRef(n);g.useEffect(()=>{if(n!==null)return Fte((oe,ye)=>{oe===n&&(p(rt=>$te(rt,ye)),queueMicrotask(()=>lh(w.current)))})},[n]),g.useEffect(()=>{const oe=Ie.current;if(oe===n)return;nC(oe,{draft:J.current,attachments:xe.current});const ye=tC(n);p((ye==null?void 0:ye.draft)??""),k((ye==null?void 0:ye.attachments)??[]),D(0),L(0),F(!1),se(!1),Oe(null),Qe.current=null,_e(!1),queueMicrotask(()=>{ye!=null&&ye.draft?lh(w.current):sa(w.current)}),Ie.current=n},[n,k]),g.useEffect(()=>()=>{nC(Ie.current,{draft:J.current,attachments:xe.current})},[]),g.useEffect(()=>{D(0)},[At]),g.useEffect(()=>{L(0)},[Ct]),g.useEffect(()=>{Ct===null&&Le&&(Oe(null),Qe.current=null,_e(!1))},[Ct,Le]),g.useEffect(()=>{if(!Jt||A)return;if(!e){R(!0);return}let oe=!1;return(async()=>{try{const ye=await e.skillsList(t,a);oe||(B(ye.skills??[]),R(!0))}catch{oe||R(!0)}})(),()=>{oe=!0}},[Jt,A,e,t,a]),g.useEffect(()=>{if(!qe||E)return;if(!e){H(!0);return}let oe=!1;return(async()=>{try{const ye=await e.agentsList(t,a);oe||(O(ye.agents??[]),H(!0))}catch{oe||H(!0)}})(),()=>{oe=!0}},[qe,E,e,t,a]),g.useEffect(()=>{if(!qe||Re)return;if(!e){ce(!0);return}let oe=!1;return(async()=>{try{const ye=await e.personaList();oe||(ge((ye.personas??[]).filter(rt=>rt.personaId!==qT).map(rt=>({personaId:rt.personaId,label:rt.label}))),ce(!0))}catch{oe||ce(!0)}})(),()=>{oe=!0}},[qe,Re,e]);const Fe=g.useCallback(oe=>{switch(oe.kind){case"persona":p(`@persona/${oe.persona.personaId} `);break;case"cc-agent":p(`@"${oe.agent.name} (agent)" `);break;case"contact":{const ye=oe.contact.deviceId;Oe({deviceId:ye,displayName:oe.contact.displayName}),Qe.current=ye,_e(!0),Promise.resolve(c==null?void 0:c(ye)).finally(()=>{Qe.current===ye&&_e(!1)}),p("@"),se(!1),setTimeout(()=>{var rt;return(rt=w.current)==null?void 0:rt.focus()},0);return}case"remote-persona":p(`@persona/${oe.persona.personaId}@${oe.deviceId} `),Oe(null);break}se(!1),setTimeout(()=>{var ye;return(ye=w.current)==null?void 0:ye.focus()},0)},[c]),Nt=g.useCallback(()=>{Oe(null),Qe.current=null,_e(!1),p("@"),setTimeout(()=>{var oe;return(oe=w.current)==null?void 0:oe.focus()},0)},[]),en=g.useCallback(oe=>{if(oe.source==="builtin"&&oe.name==="new"&&s){p(""),z(),sa(w.current),s(t);return}if(oe.source==="builtin"&&oe.name==="clear"&&o){p(""),z(),sa(w.current),o();return}p(`/${oe.name} `),setTimeout(()=>{var ye;return(ye=w.current)==null?void 0:ye.focus()},0)},[s,t,z,o]),tn=g.useCallback(async()=>{const oe=f.trim(),ye=C.filter(mt=>mt.status==="done");if(!oe&&ye.length===0||m||i)return;if(oe==="/new"&&s){v(!0);try{await s(t),p(""),z(),sa(w.current)}finally{v(!1)}return}if(oe==="/clear"&&o){v(!0);try{await o(),p(""),z(),sa(w.current)}finally{v(!1)}return}const rt=a==="codex"||a==="pi"?Hte(oe,P):oe;v(!0);try{const mt=Lee(rt,C);await r(mt,{queueWhileRunning:!0}),p(""),z(),sa(w.current)}finally{v(!1)}},[f,C,m,i,r,s,t,z,o,a,P]),nn=g.useCallback(oe=>{const{text:ye,attachments:rt}=Bte(oe);if(p(ye),rt.length>0){const mt=new Set(xe.current.map(fr=>fr.id));k([...xe.current,...rt.filter(fr=>!mt.has(fr.id))])}queueMicrotask(()=>lh(w.current))},[k]);return{draft:f,setDraft:p,sending:m,textareaRef:w,isComposingRef:_,onCompositionStart:x,onCompositionEnd:b,attachments:C,addFiles:N,removeAttachment:T,skillSelectorVisible:Jt,filteredSkills:nt,slashQuery:At??"",activeSkillIdx:M,setActiveSkillIdx:D,selectSkill:en,dismissSkillSelector:Tn,agentSelectorVisible:qe,filteredAgents:Et,mentionQuery:Ct,activeAgentIdx:q,setActiveAgentIdx:L,selectAgent:Fe,dismissAgentSelector:U,drilldown:Le,drilldownLoading:Ae,exitDrilldown:Nt,doSend:tn,restoreTextToDraft:nn}}const Wte=120;function lh(e){e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,Wte)}px`)}function sa(e){e&&(e.style.height="auto")}function Vte({items:e,restoreDisabled:t,onRestore:n,onRemove:r}){return e.length===0?null:h.jsxs("div",{"data-testid":"chat-input-queue",className:"flex flex-col",children:[h.jsx("div",{className:"px-1 pb-1 text-[11px] text-text-400",children:`排队中 · ${e.length} 条(这一轮跑完连起来一起发出)`}),e.map((i,s)=>h.jsxs("div",{"data-testid":`chat-input-queue-item-${i.id}`,className:"flex items-center gap-2 rounded-md px-1 py-1 transition-colors hover:bg-text-100/5",children:[h.jsx("span",{className:"shrink-0 w-4 text-center text-[11px] text-text-400 tabular-nums",children:s+1}),h.jsx("button",{type:"button","data-testid":`chat-input-queue-restore-${i.id}`,disabled:t,title:t?"先清空输入框再取回这条":"取回输入框继续改",onClick:()=>n(i.id),className:"flex-1 min-w-0 text-left text-[12.5px] text-text-200 truncate hover:text-text-100 disabled:cursor-not-allowed disabled:hover:text-text-200",children:i.text.trim()||"(空消息)"}),h.jsx("button",{type:"button","aria-label":"移出队列","data-testid":`chat-input-queue-remove-${i.id}`,onClick:()=>r(i.id),className:"shrink-0 p-0.5 rounded text-text-400 hover:text-text-100 hover:bg-text-100/10",children:h.jsx(qr,{className:"w-3.5 h-3.5"})})]},i.id))]})}const qte="[--color-border:#E6E6E6] [--bg-300:#E6E6E6] dark:[--color-border:#424242] dark:[--bg-300:#424242]",Kte={spawnableContacts:[],ensureRemotePersonas:()=>Promise.resolve(),remotePersonasByDeviceId:new Map},Gte=g.createContext(Kte);function Yte(){return g.useContext(Gte)}function Xte({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{iC(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(Qx,{className:"h-3 w-3"}),r?"Copied":"Copy"]}),h.jsxs("button",{type:"button",onClick:()=>iC(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(m8,{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(qr,{className:"h-3 w-3"})})]})]})})}function iC(e,t){const n=document.createElement("a");n.href=e,n.download=t||"image",n.click()}const sC=1e3,qA=`bg-bg-50 ${qte}`,oC=`mx-2 -mb-3 rounded-t-xl border border-b-0 border-border px-3 pt-2 pb-4 ${qA}`,Qte=5e3;function Pd(e){if(!e)return"null";if(e===document.body)return"body";const t=e.getAttribute("data-testid"),n=typeof e.className=="string"&&e.className.trim()?`.${e.className.trim().split(/\s+/).slice(0,3).join(".")}`:"";return`${e.tagName.toLowerCase()}${e.id?`#${e.id}`:""}${t?`[${t}]`:""}${n}`}function Zte({meta:e,api:t,cwd:n,tool:r,onSend:i,sessionKey:s,queued:o,onDequeue:a,disabled:l=!1,placeholder:c,className:u,awaitingUser:d=!1,onAbort:f,onNewSession:p,onClearSession:m,configSlot:v,aboveSlot:w}){const _=(e==null?void 0:e.streamInProgress)??!1,x=(e==null?void 0:e.contextPct)??null,b=x==null?"":x>=80?"text-red-400":x>=50?"text-amber-400":"text-text-500",S=g.useRef(null),C=Yte(),k=Ute({...t?{api:t}:{},cwd:n,...r?{tool:r}:{},sessionKey:s,onSend:i,disabled:l,...p?{onNewSession:p}:{},...m?{onClearSession:m}:{},spawnableContacts:C.spawnableContacts,ensureRemotePersonas:C.ensureRemotePersonas,remotePersonasByDeviceId:C.remotePersonasByDeviceId}),{draft:N,setDraft:T,sending:z,textareaRef:P,attachments:B,addFiles:A,removeAttachment:R,skillSelectorVisible:M,filteredSkills:D,slashQuery:$,activeSkillIdx:F,setActiveSkillIdx:j,selectSkill:O,dismissSkillSelector:E,agentSelectorVisible:H,filteredAgents:q,mentionQuery:L,activeAgentIdx:re,setActiveAgentIdx:se,selectAgent:K,dismissAgentSelector:ge,drilldown:Re,drilldownLoading:ce,exitDrilldown:Le,doSend:Oe,restoreTextToDraft:Ae}=k,_e=g.useCallback(()=>{(async()=>{const ae=await(f==null?void 0:f());ae&&ae.length>0&&Ae(Ote(ae,N))})()},[f,Ae,N]),Qe=g.useCallback(ae=>{const Je=o==null?void 0:o.find(hn=>hn.id===ae);!Je||!a||N.trim().length>0||(a(ae),Ae(Je.text))},[o,a,N,Ae]),kt=yte();g.useEffect(()=>{if(!kt||kt.signal===0||s===null||kt.sessionId!==s)return;const{signal:ae}=kt;console.log("[chat-focus] 收到聚焦信号",{sessionKey:s,signal:ae,delayMs:sC,activeElement:Pd(document.activeElement)});let Je=null,hn=null,Ys=null;const Nl=setTimeout(()=>{if(Je=P.current,!Je){console.warn("[chat-focus] textarea 已不在,放弃聚焦",{sessionKey:s,signal:ae});return}Je.focus(),console.log("[chat-focus] focus() 已执行",{sessionKey:s,signal:ae,landed:document.activeElement===Je,activeElement:Pd(document.activeElement)}),hn=Yo=>{const ts=Pd(Yo.relatedTarget);setTimeout(()=>{console.warn("[chat-focus] STOLEN 输入框失焦",{sessionKey:s,signal:ae,relatedTarget:ts,activeElementAfterTick:Pd(document.activeElement)})},0)},Je.addEventListener("blur",hn,{once:!0}),Ys=setTimeout(()=>{Je&&hn&&Je.removeEventListener("blur",hn)},Qte)},sC);return()=>{clearTimeout(Nl),Ys&&clearTimeout(Ys),Je&&hn&&Je.removeEventListener("blur",hn)}},[kt==null?void 0:kt.signal]);const tt=!!t,At=z||l||_,nt=(N.trim().length>0||B.some(ae=>ae.status==="done"))&&!l&&!z&&!d,Ct=c??(d?"Answer the question above first...":At?"Queue a message...":`Message ${ry(r)}...`),qe=g.useRef(!1),ot=g.useCallback(()=>{qe.current=!0},[]),Et=g.useCallback(()=>{qe.current=!1},[]),_n=g.useCallback(ae=>{if(M&&D.length>0){if(ae.key==="ArrowDown")return ae.preventDefault(),j(F>=D.length-1?0:F+1),!0;if(ae.key==="ArrowUp")return ae.preventDefault(),j(F<=0?D.length-1:F-1),!0;if(ae.key==="Tab"||ae.key==="Enter"&&!ae.shiftKey){ae.preventDefault();const Je=D[F];return Je&&O(Je),!0}if(ae.key==="Escape")return ae.preventDefault(),E(),!0}return!1},[M,D,F,j,O,E]),Tn=g.useCallback(ae=>{if(H&&q.length>0){if(ae.key==="ArrowDown")return ae.preventDefault(),se(re>=q.length-1?0:re+1),!0;if(ae.key==="ArrowUp")return ae.preventDefault(),se(re<=0?q.length-1:re-1),!0;if(ae.key==="Tab"||ae.key==="Enter"&&!ae.shiftKey){ae.preventDefault();const Je=q[re];return Je&&K(Je),!0}if(ae.key==="Escape")return ae.preventDefault(),Re?Le():ge(),!0}return!1},[H,q,re,se,K,ge,Re,Le]),U=g.useCallback(ae=>{const Je=ae.nativeEvent;ae.key==="Enter"&&BR({compositionActive:qe.current,nativeIsComposing:Je.isComposing,keyCode:Je.keyCode})||_n(ae)||Tn(ae)||zR({key:ae.key,shiftKey:ae.shiftKey,compositionActive:qe.current,nativeIsComposing:Je.isComposing,keyCode:Je.keyCode})&&(ae.preventDefault(),nt&&Oe())},[_n,Tn,nt,Oe]),J=g.useCallback(ae=>{T(ae.target.value),lh(ae.target)},[T]),xe=g.useCallback(ae=>{ae.target.files&&A(ae.target.files),ae.target.value=""},[A]),Ie=g.useCallback(ae=>{if(!tt)return;const Je=Array.from(ae.clipboardData.items).map(hn=>hn.getAsFile()).filter(hn=>!!(hn&&hn.type.startsWith("image/")));Je.length!==0&&(ae.preventDefault(),A(Je))},[A,tt]),[Fe,Nt]=g.useState(null),en=g.useCallback(ae=>{ae.previewUrl&&Nt({url:ae.previewUrl,name:ae.fileName})},[]),[tn,nn]=g.useState(!1),oe=g.useCallback(ae=>{tt&&(ae.preventDefault(),nn(!0))},[tt]),ye=g.useCallback(()=>nn(!1),[]),rt=g.useCallback(ae=>{tt&&(ae.preventDefault(),nn(!1),ae.dataTransfer.files.length>0&&A(ae.dataTransfer.files))},[A,tt]),mt=_&&!d&&typeof f=="function",fr=l||d;return h.jsxs("div",{"data-testid":"chat-input",className:ne("shrink-0 border-t border-bg-300/20 px-4 py-3",u),onDragOver:oe,onDragLeave:ye,onDrop:rt,children:[h.jsxs("div",{className:"max-w-3xl mx-auto relative",children:[tt?h.jsx("input",{ref:S,type:"file",multiple:!0,accept:Tte,hidden:!0,onChange:xe,"data-testid":"chat-input-file"}):null,h.jsxs("div",{"data-testid":"chat-input-bare",className:ne("flex flex-col gap-2"),children:[d||z||_?h.jsxs("div",{"data-testid":"chat-input-status-bar",className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsxs("div",{className:"flex gap-1",children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"0ms"}}),h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"150ms"}}),h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"300ms"}})]}),h.jsx("span",{children:d?"Waiting for your answer":`${Oz(r)?"Codex":r==="pi"?"pi":"Claude"} is working`})]}):null,M?h.jsx(_te,{query:$,skills:D,activeIndex:F,onActiveIndexChange:j,onSelect:O}):null,H?Re?!C.remotePersonasByDeviceId.has(Re.deviceId)&&ce?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:`正在加载 @${Re.displayName} 的 persona…`}):q.length>0?h.jsx(Jk,{query:L??"",entries:q,activeIndex:re,onActiveIndexChange:se,onSelect:K}):h.jsx("div",{"data-testid":"cc-agent-remote-empty",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 rounded-2xl border border-bg-300 bg-bg-50 px-4 py-3 text-[12px] text-text-300 shadow-lg",children:`@${Re.displayName} 暂无可派活的 persona(可能离线或未公开)`}):h.jsx(Jk,{query:L??"",entries:q,activeIndex:re,onActiveIndexChange:se,onSelect:K}):null,o&&o.length>0?h.jsx("div",{"data-testid":"chat-input-queue-header",className:oC,children:h.jsx(Vte,{items:o,restoreDisabled:N.trim().length>0||!a,onRestore:Qe,onRemove:ae=>void(a==null?void 0:a(ae))})}):null,B.length>0?h.jsx(Ete,{attachments:B,onRemove:R,onOpenPreview:en}):null,w?h.jsx("div",{"data-testid":"chat-input-above-slot",className:oC,children:w}):null,h.jsxs("div",{"data-testid":"bare-chat-input-frame",className:ne("relative flex flex-col gap-1 rounded-xl border border-border px-3 py-2 transition-colors duration-200",qA,fr?"opacity-60":null,tn?"border-accent/60 bg-accent/5":null),children:[h.jsx("textarea",{ref:P,"data-testid":"chat-input-textarea",value:N,onChange:J,onKeyDown:U,onCompositionStart:ot,onCompositionEnd:Et,onPaste:Ie,placeholder:Ct,disabled:fr,readOnly:fr,rows:1,className:"w-full resize-none bg-transparent border-0 outline-none text-[14px] text-text-100 placeholder:text-text-400 leading-relaxed py-1 min-h-[22px] max-h-[120px] overflow-y-auto disabled:cursor-not-allowed"}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[tt?h.jsx("button",{type:"button",onClick:()=>{var ae;return(ae=S.current)==null?void 0:ae.click()},disabled:At,"data-testid":"chat-input-attach","aria-label":"attach files",className:ne("flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors",At?"cursor-default text-text-400/50":"cursor-pointer text-text-400 hover:bg-text-100/5 hover:text-text-200"),children:h.jsx(K8,{className:"h-4 w-4"})}):null,h.jsx("div",{className:"flex-1 min-w-0"}),x!=null?h.jsxs("span",{"data-testid":"chat-input-ctx",className:ne("shrink-0 text-[11px] tabular-nums",b),children:["ctx:",x,"%"]}):null,v,mt?h.jsx("button",{type:"button",onClick:_e,"data-testid":"chat-input-abort","aria-label":"interrupt",title:"中断当前轮次(不杀进程)",className:"h-8 w-8 rounded-full flex items-center justify-center border border-text-400/40 text-text-400 hover:bg-text-100/5 hover:text-text-100 transition-colors cursor-pointer",children:h.jsx(kI,{className:"w-3.5 h-3.5",strokeWidth:2.5})}):null,h.jsx("button",{type:"button",onClick:()=>{nt&&Oe()},disabled:!nt,"data-testid":"chat-input-send","aria-label":"send",className:ne("h-8 w-8 rounded-full flex items-center justify-center transition-colors",nt?"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(W$,{className:"w-4 h-4",strokeWidth:2.5})})]})]})]})]}),Fe?h.jsx(Xte,{url:Fe.url,fileName:Fe.name,onClose:()=>Nt(null)}):null]})}function Jte(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function ene({meta:e,tool:t,connState:n,variant:r="full",onOpenConfig:i,liveWorktreeRoot:s,ephemeral:o=!1,onPromote:a,cloudVolume:l,className:c}){const u=s??e.cwd??"",f=!!e.sessionLabel&&e.sessionLabel!==e.sessionId?e.sessionLabel:Jte(u),p=u;return r==="quickask"?h.jsxs("div",{"data-testid":"chat-header","data-variant":"quickask",className:ne("flex items-center shrink-0 px-3 py-2 gap-2",c),children:[a?h.jsx("button",{type:"button","data-testid":"chat-header-promote","data-promoted":o?"false":"true",disabled:!o,onClick:a,title:o?"保留为正式会话":"已保留为正式会话",className:ne("shrink-0 inline-flex items-center justify-center h-5 w-5 rounded-md transition-colors",o?"text-text-500 hover:text-text-200 hover:bg-text-100/5 cursor-pointer":"text-amber-400"),children:h.jsx(Q$,{className:ne("w-3.5 h-3.5",!o&&"fill-current")})}):null,h.jsx("span",{className:"font-semibold text-text-100 truncate text-[13px]","data-testid":"chat-header-worktree",title:p,children:f})]}):h.jsxs("div",{"data-testid":"chat-header","data-variant":"full",className:ne("relative flex items-center shrink-0 px-4 py-2.5",l?"pr-36 md:pr-32":"pr-[4.5rem] md:pr-4",c),children:[h.jsx("span",{className:"font-semibold text-text-100 truncate text-[13px]","data-testid":"chat-header-worktree",title:p,children:f}),h.jsxs("div",{className:"absolute right-4 top-1/2 -translate-y-1/2 z-10 flex items-center gap-1",children:[l,i?h.jsx("button",{type:"button","aria-label":"Session settings","data-testid":"chat-header-settings-mobile",onClick:i,title:"Session settings",className:"flex md:hidden h-7 w-7 items-center justify-center rounded-md bg-transparent text-text-300 transition-colors duration-150 hover:bg-bg-200 hover:text-text-100 cursor-pointer outline-none",children:h.jsx(bI,{className:"w-4 h-4"})}):null]})]})}function tne({testid:e,children:t}){return h.jsx("div",{"data-testid":e,className:"h-full min-w-0 border-l border-border bg-bg-100 flex flex-col",children:t})}function nne({title:e,onBack:t,onCollapse:n,collapseLabel:r="collapse session info",collapseTitle:i="收起会话信息"}){const s=o=>h.jsx("button",{type:"button","data-testid":"session-info-collapse",onClick:n,"aria-label":r,title:i,className:`p-1 rounded text-text-400 hover:text-text-100 hover:bg-text-100/10 ${o}`,children:h.jsx(Uw,{className:"w-4 h-4"})});return h.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b border-border shrink-0",children:[t?h.jsx("button",{type:"button","data-testid":"session-info-back",onClick:t,"aria-label":"返回会话信息",className:"p-1 -ml-1 rounded text-text-400 hover:text-text-100 hover:bg-text-100/10",children:h.jsx($$,{className:"w-4 h-4"})}):n?s("-ml-1"):h.jsx(Uw,{className:"w-4 h-4 text-text-300"}),h.jsx("span",{className:"flex-1 text-[13px] font-medium text-text-100 truncate",children:e}),t&&n?s(""):null]})}function sg({icon:e,label:t,meta:n,onClick:r,testid:i}){return h.jsxs("button",{type:"button","data-testid":i,onClick:r,className:"w-full flex items-center gap-2.5 px-2 py-1.5 rounded-md cursor-pointer text-left hover:bg-text-100/5",children:[h.jsx("span",{className:"w-4 h-4 shrink-0 text-text-300 inline-flex items-center justify-center",children:e}),h.jsx("span",{className:"flex-1 text-[12.5px] text-text-100",children:t}),n?h.jsx("span",{className:"shrink-0 text-[11px] text-text-400 font-mono",children:n}):null]})}let rne=null;function ine(){return rne}function oc({label:e,labelTitle:t,children:n}){return h.jsxs("div",{className:"flex items-start gap-2 px-2 py-1",children:[h.jsx("span",{className:"w-14 shrink-0 truncate text-[11px] text-text-400 pt-0.5",...t?{title:t}:{},children:e}),h.jsx("span",{className:"flex-1 min-w-0 text-[12px] text-text-100",children:n})]})}function aC({label:e,labelTitle:t,value:n,testid:r}){const[i,s]=g.useState(!1),o=g.useRef(null);g.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]);const a=()=>{typeof navigator>"u"||!navigator.clipboard||navigator.clipboard.writeText(n).then(()=>{s(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>s(!1),2e3)},()=>{})};return h.jsx(oc,{label:e,labelTitle:t,children:h.jsxs("button",{type:"button",onClick:a,"data-testid":r,title:i?"已复制":`复制:${n}`,className:"w-full flex items-center gap-1.5 text-left group cursor-pointer",children:[h.jsx("span",{className:"font-mono text-[11px] text-text-300 truncate flex-1 min-w-0",children:n}),i?h.jsx(bu,{className:"w-3 h-3 shrink-0 text-accent"}):h.jsx(Qx,{className:"w-3 h-3 shrink-0 text-text-400 opacity-0 group-hover:opacity-100 transition-opacity"})]})})}function sne({session:e,meta:t,liveGitBranch:n,liveWorktreeRoot:r,personaName:i,onOpenPersona:s,onOpenFiles:o,cronActiveCount:a,onCronClick:l,onForceStop:c,viewerRole:u="owner",toolSessionIdLabel:d="tool session id",drill:f=null,onCollapse:p,title:m="会话信息",leadingEntries:v}){const w=n!==void 0?n:t.gitBranch??null,_=t.procAlive??!1,x=qI(e),b=x!=null&&e.originOwnerPrincipalId==null&&u!=="guest",[S,C]=g.useState(null),k=g.useRef(null);g.useEffect(()=>()=>{k.current&&clearTimeout(k.current)},[]);const N=async()=>{if(!b)return;const T=ine();let z;try{T||(await navigator.clipboard.writeText(x),z="命令已复制")}catch{z="操作失败"}C(z),k.current&&clearTimeout(k.current),k.current=setTimeout(()=>C(null),2500)};return h.jsxs(tne,{testid:"session-info-panel",children:[h.jsx(nne,{title:f?f.title:m,...f?{onBack:f.onBack}:{},...p?{onCollapse:p}:{},collapseTitle:`收起${m}`}),f?h.jsx("div",{"data-testid":"session-info-drill",className:"flex-1 min-h-0 overflow-y-auto",children:f.content}):h.jsxs("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:[w?h.jsx(oc,{label:"分支",children:h.jsxs("span",{"data-testid":"session-info-branch",className:"inline-flex items-center gap-1 font-mono text-[11.5px] min-w-0",title:r??void 0,children:[h.jsx(Zx,{className:"w-3 h-3 shrink-0 text-text-400"}),h.jsx("span",{className:"truncate",children:w})]})}):null,i&&s?h.jsx(oc,{label:"persona",children:h.jsxs("button",{type:"button","data-testid":"session-info-persona",onClick:s,className:"inline-flex items-center gap-1 hover:text-accent cursor-pointer",children:[h.jsx(TI,{className:"w-3 h-3"}),h.jsx("span",{className:"truncate",children:i})]})}):null,h.jsx(oc,{label:"引擎",children:h.jsxs("span",{className:"inline-flex items-center gap-1.5","data-testid":"session-info-engine",children:[h.jsx(dp,{tool:e.tool,className:ne("w-3.5 h-3.5 shrink-0",hp(e.tool))}),h.jsxs("span",{className:"truncate",children:[ry(e.tool),t.model?` · ${t.model}`:""]})]})}),h.jsx(oc,{label:"cwd",children:h.jsx("span",{"data-testid":"session-info-cwd",className:"font-mono text-[11px] text-text-300 truncate block",title:e.cwd,children:e.cwd})}),h.jsx(aC,{label:"session id",value:e.sessionId,testid:"session-info-session-id"}),e.toolSessionId?h.jsx(aC,{label:`${e.tool||"claude"} id`,labelTitle:d,value:e.toolSessionId,testid:"session-info-tool-session-id"}):null,h.jsx("div",{className:"my-2 border-t border-border"}),v,o?h.jsx(sg,{icon:h.jsx(w8,{className:"w-3.5 h-3.5"}),label:"Edited Files",onClick:o,testid:"session-info-files"}):null,a&&a>0&&l?h.jsx(sg,{icon:h.jsx(u8,{className:"w-3.5 h-3.5"}),label:"定时任务",meta:String(a),onClick:l,testid:"session-info-cron"}):null,b?h.jsx(sg,{icon:h.jsx(vF,{className:"w-3.5 h-3.5"}),label:"终端",meta:S,onClick:()=>void N(),testid:"session-info-terminal"}):null]}),_&&c?h.jsx("div",{className:"shrink-0 border-t border-border px-3 py-2.5",children:h.jsxs("button",{type:"button","data-testid":"session-info-force-stop",onClick:c,title:e.tool==="codex"?"强制停止 Codex 进程":"强制停止 Claude Code 进程(会丢失 initialize / 预热缓存)",className:"inline-flex items-center gap-1.5 h-6 px-2.5 rounded-md text-text-400 hover:bg-red-500/10 hover:text-red-400 transition-colors text-[12px] cursor-pointer",children:[h.jsx(W8,{className:"w-3.5 h-3.5"}),h.jsx("span",{children:"强制停止"})]})}):null]})}const one=g.createContext({container:null});function ane(){return g.useContext(one)}const s1="fixed top-0 md:top-10 bottom-0 right-0";function lne({api:e,cwd:t,toolSessionId:n,toolKind:r="claude"}){const i=$A(),s=(i==null?void 0:i.state.agentId)??null,o=i==null?void 0:i.state.agentType,[a,l]=g.useState([]),[c,u]=g.useState(!1),[d,f]=g.useState(null);g.useEffect(()=>{if(!s)return;let m=!1;return u(!0),f(null),l([]),e.historySubagentRead({cwd:t,toolSessionId:n,subagentId:s}).then(v=>{m||l(v.messages??[])}).catch(v=>{m||f(v instanceof Error?v.message:String(v))}).finally(()=>{m||u(!1)}),()=>{m=!0}},[s,t,n,e]);const p=g.useMemo(()=>a.length>0?gM(a,0,r):[],[a,r]);return!i||!s?null:h.jsxs("div",{"data-testid":"subagent-drawer","data-agent-id":s,className:ne(s1,"z-50 w-[min(560px,92vw)]","flex flex-col border-l border-bg-200/60 bg-bg-50 shadow-xl"),style:{paddingTop:"env(safe-area-inset-top)"},children:[h.jsxs("div",{className:"flex flex-col gap-0.5 px-3 py-2 border-b border-bg-200/60",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o?h.jsx("span",{className:"inline-flex items-center rounded-sm bg-violet-500/10 px-1.5 py-0.5 text-[11px] text-violet-400 font-medium",children:o}):null,h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate",title:s,children:s})]}),h.jsx("button",{type:"button","aria-label":"关闭",onClick:()=>i.close(),className:"p-1 rounded hover:bg-bg-200/50 text-text-400 hover:text-text-200",children:h.jsx(qr,{className:"w-4 h-4"})})]}),!c&&!d&&a.length>0?h.jsxs("div",{className:"text-[11px] text-text-400",children:[a.length," 条消息 · 首条为主会话派发的任务指令"]}):null]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden px-3 py-2",children:c?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(cr,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"加载中…"})]}):d?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-error",children:[h.jsx(Fo,{className:"w-3.5 h-3.5"}),h.jsx("span",{children:d})]}):p.length===0?h.jsx("div",{className:"text-[12px] text-text-400 italic",children:"无消息"}):h.jsx(UA,{lines:p})})]})}function lC(e,t){let n=0;for(const r of e.lines)r.startsWith(t)&&n++;return n}function cne(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+=lC(m,"+"),p.deletions+=lC(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 une({open:e,onOpenChange:t,api:n,sessionId:r,userMessageId:i,lines:s,procAlive:o,onApplied:a,onNoChanges:l}){const c=g.useMemo(()=>cne(s,i),[s,i]),[u,d]=g.useState(null),[f,p]=g.useState(!1),[m,v]=g.useState(!1),[w,_]=g.useState(null);g.useEffect(()=>{if(!e)return;let k=!1;return p(!0),d(null),(async()=>{try{const N=await n.sessionRewindDiff({sessionId:r,userMessageId:i});k||(d(N),!N.canRewind&&!N.error&&N.files.length===0&&(l==null||l(i)))}catch{k||d(null)}finally{k||p(!1)}})(),()=>{k=!0}},[e,n,r,i]);const 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(N=>({filePath:N.filePath,hunks:N.hunks,insertions:N.insertions,deletions:N.deletions})),totalInsertions:u.totalInsertions,totalDeletions:u.totalDeletions}}return{source:"local",anchorFound:c.anchorFound,files:c.files,totalInsertions:c.totalInsertions,totalDeletions:c.totalDeletions,rpcError:u==null?void 0:u.error}},[u,c]),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 S=x.files.length>0,C=!f&&!m&&x.anchorFound&&S&&!w;return h.jsxs("div",{"data-testid":"rewind-preview-drawer",className:`${s1} 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(NI,{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(qr,{className:"w-4 h-4"})})]}),w?h.jsxs("div",{"data-testid":"rewind-error-banner",className:"mx-4 mt-3 flex items-start gap-2 rounded-md border border-red-400/40 bg-red-500/10 px-3 py-2 text-[12px] text-red-400",children:[h.jsx(tf,{className:"w-4 h-4 shrink-0 mt-0.5"}),h.jsx("span",{children:w})]}):null,h.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-3",children:f?h.jsxs("div",{"data-testid":"rewind-loading",className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(cr,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"正在读取快照…"})]}):x.anchorFound?S?h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":"rewind-summary",className:"rounded-md border border-bg-300 bg-bg-100/40 px-3 py-2 text-[12px] text-text-200",children:[h.jsxs("div",{children:["将回退 ",h.jsx("span",{className:"font-semibold text-text-100",children: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(hne,{file:k},k.filePath))]}):h.jsxs("div",{"data-testid":"rewind-no-changes",className:"rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300 space-y-1",children:[h.jsx("div",{children:"磁盘上的文件已经和这个时刻的快照完全一致——没有需要回退的改动。"}),h.jsx("div",{className:"text-text-400 text-[11px]",children:"可能这条消息之后 Claude 没落盘编辑,或之前已经 rewind 过了。"})]}):h.jsx("div",{"data-testid":"rewind-no-anchor",className:"rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300",children:"未能在当前消息流中找到对应的用户消息(可能已被历史裁剪)。"})}),h.jsxs("div",{className:"flex flex-col gap-2 px-4 py-3 border-t border-bg-300/30 shrink-0",children:[S&&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(tf,{className:"w-4 h-4 shrink-0 mt-0.5 text-warning"}),h.jsx("span",{children:'Claude Code 进程当前未运行。点击"确认回退"时会自动启动它再执行 — 可能需要等一两秒。'})]}):null,h.jsxs("div",{className:"flex items-center justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:()=>t(!1),className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),h.jsx("button",{type:"button",disabled:!C,onClick:()=>void b(),"data-testid":"rewind-apply",className:ne("h-8 px-3 rounded-md text-[12px] font-medium transition-colors",C?"bg-accent text-white hover:bg-accent-hover cursor-pointer":"bg-bg-200 text-text-400 cursor-not-allowed"),children:m?"回退中…":"确认回退"})]})]})]})}function dne(e){return e.replace(/^\/Users\/[^/]+/,"~")}function hne({file:e}){const[t,n]=g.useState(!0);return h.jsxs("div",{"data-testid":"rewind-file-block","data-file":e.filePath,className:"rounded-md border border-bg-300 overflow-hidden bg-bg-0",children:[h.jsxs("button",{type:"button",onClick:()=>n(r=>!r),className:"w-full flex items-center gap-1.5 px-3 py-2 text-[12px] hover:bg-text-100/5 cursor-pointer",children:[t?h.jsx(Yn,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(Bn,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"font-mono text-text-200 truncate flex-1 text-left",title:e.filePath,children:dne(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(fne,{hunk:r},`${r.oldStart}-${r.oldLines}-${r.newStart}-${r.newLines}`))}):null]})}function fne({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:ne("px-3 whitespace-pre",s),children:n.length>0?n:" "},r)})]})}function pne({jobs:e}){return e.length===0?h.jsx("div",{"data-testid":"cron-job-list-empty",className:"px-4 py-3 text-sm text-text-500",children:"当前会话暂无活跃 cron 任务"}):h.jsx("ul",{"data-testid":"cron-job-list",className:"flex flex-col gap-2",children:e.map(t=>h.jsxs("li",{"data-testid":`cron-job-${t.id}`,className:"flex flex-col gap-1 rounded-md border border-border px-3 py-2",children:[h.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[h.jsx("span",{className:"font-mono text-text-300",children:t.id}),h.jsx("span",{className:"text-text-500",children:"·"}),h.jsx("span",{className:"text-text-400",children:t.humanSchedule}),t.recurring?h.jsx("span",{"data-testid":`cron-job-${t.id}-recurring-badge`,className:"ml-auto rounded-md bg-accent-dim px-2 py-0.5 text-accent",children:"recurring"}):null]}),h.jsx("div",{className:"text-sm text-text-200 truncate",title:t.prompt,children:t.prompt})]},t.id))})}const mne={idle:"还没启动","turn-running":"正在 run 中","turn-idle":"进程活着,等输入",exited:"进程已退出",crashed:"启动失败 / 异常退出"};function gne({sessionStatus:e}){switch(e){case"idle":return"idle";case"running":return"turn-running";case"running-idle":return"turn-idle";case"observing":return"turn-running";case"stopped":return"exited";case"error":return"crashed"}}/**
|
|
547
547
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
548
548
|
* @license MIT
|
|
549
549
|
*
|
|
@@ -560,11 +560,11 @@ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){t
|
|
|
560
560
|
|
|
561
561
|
`+e.stack):new Error(e.message+`
|
|
562
562
|
|
|
563
|
-
`+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)}},Mne=new Rne;function ch(e){Ane(e)||Mne.onUnexpectedError(e)}var K0="Canceled";function Ane(e){return e instanceof Lne?!0:e instanceof Error&&e.name===K0&&e.message===K0}var Lne=class extends Error{constructor(){super(K0),this.name=this.message}};function Dne(e){return new Error(`Illegal argument: ${e}`)}var fC=class G0 extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof G0)return t;let n=new G0;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Y0=class s5 extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,s5.prototype)}};function Zn(e,t=0){return e[e.length-(1+t)]}var jne;(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})(jne||(jne={}));function One(e,t){let n=this,r=!1,i;return function(){return r||(r=!0,t||(i=e.apply(n,arguments))),i}}var o5;(e=>{function t(S){return S&&typeof S=="object"&&typeof S[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(S){yield S}e.single=i;function s(S){return t(S)?S:i(S)}e.wrap=s;function o(S){return S||n}e.from=o;function*a(S){for(let C=S.length-1;C>=0;C--)yield S[C]}e.reverse=a;function l(S){return!S||S[Symbol.iterator]().next().done===!0}e.isEmpty=l;function c(S){return S[Symbol.iterator]().next().value}e.first=c;function u(S,C){let k=0;for(let N of S)if(C(N,k++))return!0;return!1}e.some=u;function d(S,C){for(let k of S)if(C(k))return k}e.find=d;function*f(S,C){for(let k of S)C(k)&&(yield k)}e.filter=f;function*p(S,C){let k=0;for(let N of S)yield C(N,k++)}e.map=p;function*m(S,C){let k=0;for(let N of S)yield*C(N,k++)}e.flatMap=m;function*v(...S){for(let C of S)yield*C}e.concat=v;function w(S,C,k){let N=k;for(let T of S)N=C(N,T);return N}e.reduce=w;function*_(S,C,k=S.length){for(C<0&&(C+=S.length),k<0?k+=S.length:k>S.length&&(k=S.length);C<k;C++)yield S[C]}e.slice=_;function x(S,C=Number.POSITIVE_INFINITY){let k=[];if(C===0)return[k,S];let N=S[Symbol.iterator]();for(let T=0;T<C;T++){let z=N.next();if(z.done)return[k,e.empty()];k.push(z.value)}return[k,{[Symbol.iterator](){return N}}]}e.consume=x;async function b(S){let C=[];for await(let k of S)C.push(k);return Promise.resolve(C)}e.asyncToArray=b})(o5||(o5={}));function Lo(e){if(o5.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 Bne(...e){return vt(()=>Lo(e))}function vt(e){return{dispose:One(()=>{e()})}}var a5=class l5{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{Lo(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?l5.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)}};a5.DISABLE_DISPOSED_WARNING=!1;var As=a5,$e=class{constructor(){this._store=new As,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)}};$e.None=Object.freeze({dispose(){}});var rl=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}},Mi=typeof window=="object"?window:globalThis,X0=class Q0{constructor(t){this.element=t,this.next=Q0.Undefined,this.prev=Q0.Undefined}};X0.Undefined=new X0(void 0);var _t=X0,pC=class{constructor(){this._first=_t.Undefined,this._last=_t.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===_t.Undefined}clear(){let e=this._first;for(;e!==_t.Undefined;){let t=e.next;e.prev=_t.Undefined,e.next=_t.Undefined,e=t}this._first=_t.Undefined,this._last=_t.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new _t(e);if(this._first===_t.Undefined)this._first=n,this._last=n;else if(t){let i=this._last;this._last=n,n.prev=i,i.next=n}else{let i=this._first;this._first=n,n.next=i,i.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==_t.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==_t.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==_t.Undefined&&e.next!==_t.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===_t.Undefined&&e.next===_t.Undefined?(this._first=_t.Undefined,this._last=_t.Undefined):e.next===_t.Undefined?(this._last=this._last.prev,this._last.next=_t.Undefined):e.prev===_t.Undefined&&(this._first=this._first.next,this._first.prev=_t.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==_t.Undefined;)yield e.element,e=e.next}},zne=globalThis.performance&&typeof globalThis.performance.now=="function",$ne=class c5{static create(t){return new c5(t)}constructor(t){this._now=zne&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},mn;(e=>{e.None=()=>$e.None;function t(A,R){return d(A,()=>{},0,void 0,!0,void 0,R)}e.defer=t;function n(A){return(R,M=null,D)=>{let $=!1,F;return F=A(j=>{if(!$)return F?F.dispose():$=!0,R.call(M,j)},null,D),$&&F.dispose(),F}}e.once=n;function r(A,R,M){return c((D,$=null,F)=>A(j=>D.call($,R(j)),null,F),M)}e.map=r;function i(A,R,M){return c((D,$=null,F)=>A(j=>{R(j),D.call($,j)},null,F),M)}e.forEach=i;function s(A,R,M){return c((D,$=null,F)=>A(j=>R(j)&&D.call($,j),null,F),M)}e.filter=s;function o(A){return A}e.signal=o;function a(...A){return(R,M=null,D)=>{let $=Bne(...A.map(F=>F(j=>R.call(M,j))));return u($,D)}}e.any=a;function l(A,R,M,D){let $=M;return r(A,F=>($=R($,F),$),D)}e.reduce=l;function c(A,R){let M,D={onWillAddFirstListener(){M=A($.fire,$)},onDidRemoveLastListener(){M==null||M.dispose()}},$=new te(D);return R==null||R.add($),$.event}function u(A,R){return R instanceof Array?R.push(A):R&&R.add(A),A}function d(A,R,M=100,D=!1,$=!1,F,j){let O,E,H,q=0,L,re={leakWarningThreshold:F,onWillAddFirstListener(){O=A(K=>{q++,E=R(E,K),D&&!H&&(se.fire(E),E=void 0),L=()=>{let me=E;E=void 0,H=void 0,(!D||q>1)&&se.fire(me),q=0},typeof M=="number"?(clearTimeout(H),H=setTimeout(L,M)):H===void 0&&(H=0,queueMicrotask(L))})},onWillRemoveListener(){$&&q>0&&(L==null||L())},onDidRemoveLastListener(){L=void 0,O.dispose()}},se=new te(re);return j==null||j.add(se),se.event}e.debounce=d;function f(A,R=0,M){return e.debounce(A,(D,$)=>D?(D.push($),D):[$],R,void 0,!0,void 0,M)}e.accumulate=f;function p(A,R=(D,$)=>D===$,M){let D=!0,$;return s(A,F=>{let j=D||!R(F,$);return D=!1,$=F,j},M)}e.latch=p;function m(A,R,M){return[e.filter(A,R,M),e.filter(A,D=>!R(D),M)]}e.split=m;function v(A,R=!1,M=[],D){let $=M.slice(),F=A(E=>{$?$.push(E):O.fire(E)});D&&D.add(F);let j=()=>{$==null||$.forEach(E=>O.fire(E)),$=null},O=new te({onWillAddFirstListener(){F||(F=A(E=>O.fire(E)),D&&D.add(F))},onDidAddFirstListener(){$&&(R?setTimeout(j):j())},onDidRemoveLastListener(){F&&F.dispose(),F=null}});return D&&D.add(O),O.event}e.buffer=v;function w(A,R){return(M,D,$)=>{let F=R(new x);return A(function(j){let O=F.evaluate(j);O!==_&&M.call(D,O)},void 0,$)}}e.chain=w;let _=Symbol("HaltChainable");class x{constructor(){this.steps=[]}map(R){return this.steps.push(R),this}forEach(R){return this.steps.push(M=>(R(M),M)),this}filter(R){return this.steps.push(M=>R(M)?M:_),this}reduce(R,M){let D=M;return this.steps.push($=>(D=R(D,$),D)),this}latch(R=(M,D)=>M===D){let M=!0,D;return this.steps.push($=>{let F=M||!R($,D);return M=!1,D=$,F?$:_}),this}evaluate(R){for(let M of this.steps)if(R=M(R),R===_)break;return R}}function b(A,R,M=D=>D){let D=(...O)=>j.fire(M(...O)),$=()=>A.on(R,D),F=()=>A.removeListener(R,D),j=new te({onWillAddFirstListener:$,onDidRemoveLastListener:F});return j.event}e.fromNodeEventEmitter=b;function S(A,R,M=D=>D){let D=(...O)=>j.fire(M(...O)),$=()=>A.addEventListener(R,D),F=()=>A.removeEventListener(R,D),j=new te({onWillAddFirstListener:$,onDidRemoveLastListener:F});return j.event}e.fromDOMEventEmitter=S;function C(A){return new Promise(R=>n(A)(R))}e.toPromise=C;function k(A){let R=new te;return A.then(M=>{R.fire(M)},()=>{R.fire(void 0)}).finally(()=>{R.dispose()}),R.event}e.fromPromise=k;function N(A,R){return A(M=>R.fire(M))}e.forward=N;function T(A,R,M){return R(M),A(D=>R(D))}e.runAndSubscribe=T;class z{constructor(R,M){this._observable=R,this._counter=0,this._hasChanged=!1;let D={onWillAddFirstListener:()=>{R.addObserver(this)},onDidRemoveLastListener:()=>{R.removeObserver(this)}};this.emitter=new te(D),M&&M.add(this.emitter)}beginUpdate(R){this._counter++}handlePossibleChange(R){}handleChange(R,M){this._hasChanged=!0}endUpdate(R){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function P(A,R){return new z(A,R).emitter.event}e.fromObservable=P;function B(A){return(R,M,D)=>{let $=0,F=!1,j={beginUpdate(){$++},endUpdate(){$--,$===0&&(A.reportChanges(),F&&(F=!1,R.call(M)))},handlePossibleChange(){},handleChange(){F=!0}};A.addObserver(j),A.reportChanges();let O={dispose(){A.removeObserver(j)}};return D instanceof As?D.add(O):Array.isArray(D)&&D.push(O),O}}e.fromObservableLight=B})(mn||(mn={}));var Z0=class J0{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${J0._idPool++}`,J0.all.add(this)}start(t){this._stopWatch=new $ne,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}}};Z0.all=new Set,Z0._idPool=0;var Fne=Z0,Hne=-1,u5=class d5{constructor(t,n,r=(d5._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 Vne(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}};u5._idPool=1;var Une=u5,Wne=class h5{constructor(t){this.value=t}static create(){let t=new Error;return new h5(t.stack??"")}print(){console.warn(this.value.split(`
|
|
563
|
+
`+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)}},Mne=new Rne;function ch(e){Ane(e)||Mne.onUnexpectedError(e)}var K0="Canceled";function Ane(e){return e instanceof Lne?!0:e instanceof Error&&e.name===K0&&e.message===K0}var Lne=class extends Error{constructor(){super(K0),this.name=this.message}};function Dne(e){return new Error(`Illegal argument: ${e}`)}var fC=class G0 extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof G0)return t;let n=new G0;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Y0=class s5 extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,s5.prototype)}};function Zn(e,t=0){return e[e.length-(1+t)]}var jne;(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})(jne||(jne={}));function One(e,t){let n=this,r=!1,i;return function(){return r||(r=!0,t||(i=e.apply(n,arguments))),i}}var o5;(e=>{function t(S){return S&&typeof S=="object"&&typeof S[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(S){yield S}e.single=i;function s(S){return t(S)?S:i(S)}e.wrap=s;function o(S){return S||n}e.from=o;function*a(S){for(let C=S.length-1;C>=0;C--)yield S[C]}e.reverse=a;function l(S){return!S||S[Symbol.iterator]().next().done===!0}e.isEmpty=l;function c(S){return S[Symbol.iterator]().next().value}e.first=c;function u(S,C){let k=0;for(let N of S)if(C(N,k++))return!0;return!1}e.some=u;function d(S,C){for(let k of S)if(C(k))return k}e.find=d;function*f(S,C){for(let k of S)C(k)&&(yield k)}e.filter=f;function*p(S,C){let k=0;for(let N of S)yield C(N,k++)}e.map=p;function*m(S,C){let k=0;for(let N of S)yield*C(N,k++)}e.flatMap=m;function*v(...S){for(let C of S)yield*C}e.concat=v;function w(S,C,k){let N=k;for(let T of S)N=C(N,T);return N}e.reduce=w;function*_(S,C,k=S.length){for(C<0&&(C+=S.length),k<0?k+=S.length:k>S.length&&(k=S.length);C<k;C++)yield S[C]}e.slice=_;function x(S,C=Number.POSITIVE_INFINITY){let k=[];if(C===0)return[k,S];let N=S[Symbol.iterator]();for(let T=0;T<C;T++){let z=N.next();if(z.done)return[k,e.empty()];k.push(z.value)}return[k,{[Symbol.iterator](){return N}}]}e.consume=x;async function b(S){let C=[];for await(let k of S)C.push(k);return Promise.resolve(C)}e.asyncToArray=b})(o5||(o5={}));function Lo(e){if(o5.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 Bne(...e){return vt(()=>Lo(e))}function vt(e){return{dispose:One(()=>{e()})}}var a5=class l5{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{Lo(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?l5.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)}};a5.DISABLE_DISPOSED_WARNING=!1;var As=a5,$e=class{constructor(){this._store=new As,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)}};$e.None=Object.freeze({dispose(){}});var rl=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}},Mi=typeof window=="object"?window:globalThis,X0=class Q0{constructor(t){this.element=t,this.next=Q0.Undefined,this.prev=Q0.Undefined}};X0.Undefined=new X0(void 0);var _t=X0,pC=class{constructor(){this._first=_t.Undefined,this._last=_t.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===_t.Undefined}clear(){let e=this._first;for(;e!==_t.Undefined;){let t=e.next;e.prev=_t.Undefined,e.next=_t.Undefined,e=t}this._first=_t.Undefined,this._last=_t.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new _t(e);if(this._first===_t.Undefined)this._first=n,this._last=n;else if(t){let i=this._last;this._last=n,n.prev=i,i.next=n}else{let i=this._first;this._first=n,n.next=i,i.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==_t.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==_t.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==_t.Undefined&&e.next!==_t.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===_t.Undefined&&e.next===_t.Undefined?(this._first=_t.Undefined,this._last=_t.Undefined):e.next===_t.Undefined?(this._last=this._last.prev,this._last.next=_t.Undefined):e.prev===_t.Undefined&&(this._first=this._first.next,this._first.prev=_t.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==_t.Undefined;)yield e.element,e=e.next}},zne=globalThis.performance&&typeof globalThis.performance.now=="function",$ne=class c5{static create(t){return new c5(t)}constructor(t){this._now=zne&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},mn;(e=>{e.None=()=>$e.None;function t(A,R){return d(A,()=>{},0,void 0,!0,void 0,R)}e.defer=t;function n(A){return(R,M=null,D)=>{let $=!1,F;return F=A(j=>{if(!$)return F?F.dispose():$=!0,R.call(M,j)},null,D),$&&F.dispose(),F}}e.once=n;function r(A,R,M){return c((D,$=null,F)=>A(j=>D.call($,R(j)),null,F),M)}e.map=r;function i(A,R,M){return c((D,$=null,F)=>A(j=>{R(j),D.call($,j)},null,F),M)}e.forEach=i;function s(A,R,M){return c((D,$=null,F)=>A(j=>R(j)&&D.call($,j),null,F),M)}e.filter=s;function o(A){return A}e.signal=o;function a(...A){return(R,M=null,D)=>{let $=Bne(...A.map(F=>F(j=>R.call(M,j))));return u($,D)}}e.any=a;function l(A,R,M,D){let $=M;return r(A,F=>($=R($,F),$),D)}e.reduce=l;function c(A,R){let M,D={onWillAddFirstListener(){M=A($.fire,$)},onDidRemoveLastListener(){M==null||M.dispose()}},$=new te(D);return R==null||R.add($),$.event}function u(A,R){return R instanceof Array?R.push(A):R&&R.add(A),A}function d(A,R,M=100,D=!1,$=!1,F,j){let O,E,H,q=0,L,re={leakWarningThreshold:F,onWillAddFirstListener(){O=A(K=>{q++,E=R(E,K),D&&!H&&(se.fire(E),E=void 0),L=()=>{let ge=E;E=void 0,H=void 0,(!D||q>1)&&se.fire(ge),q=0},typeof M=="number"?(clearTimeout(H),H=setTimeout(L,M)):H===void 0&&(H=0,queueMicrotask(L))})},onWillRemoveListener(){$&&q>0&&(L==null||L())},onDidRemoveLastListener(){L=void 0,O.dispose()}},se=new te(re);return j==null||j.add(se),se.event}e.debounce=d;function f(A,R=0,M){return e.debounce(A,(D,$)=>D?(D.push($),D):[$],R,void 0,!0,void 0,M)}e.accumulate=f;function p(A,R=(D,$)=>D===$,M){let D=!0,$;return s(A,F=>{let j=D||!R(F,$);return D=!1,$=F,j},M)}e.latch=p;function m(A,R,M){return[e.filter(A,R,M),e.filter(A,D=>!R(D),M)]}e.split=m;function v(A,R=!1,M=[],D){let $=M.slice(),F=A(E=>{$?$.push(E):O.fire(E)});D&&D.add(F);let j=()=>{$==null||$.forEach(E=>O.fire(E)),$=null},O=new te({onWillAddFirstListener(){F||(F=A(E=>O.fire(E)),D&&D.add(F))},onDidAddFirstListener(){$&&(R?setTimeout(j):j())},onDidRemoveLastListener(){F&&F.dispose(),F=null}});return D&&D.add(O),O.event}e.buffer=v;function w(A,R){return(M,D,$)=>{let F=R(new x);return A(function(j){let O=F.evaluate(j);O!==_&&M.call(D,O)},void 0,$)}}e.chain=w;let _=Symbol("HaltChainable");class x{constructor(){this.steps=[]}map(R){return this.steps.push(R),this}forEach(R){return this.steps.push(M=>(R(M),M)),this}filter(R){return this.steps.push(M=>R(M)?M:_),this}reduce(R,M){let D=M;return this.steps.push($=>(D=R(D,$),D)),this}latch(R=(M,D)=>M===D){let M=!0,D;return this.steps.push($=>{let F=M||!R($,D);return M=!1,D=$,F?$:_}),this}evaluate(R){for(let M of this.steps)if(R=M(R),R===_)break;return R}}function b(A,R,M=D=>D){let D=(...O)=>j.fire(M(...O)),$=()=>A.on(R,D),F=()=>A.removeListener(R,D),j=new te({onWillAddFirstListener:$,onDidRemoveLastListener:F});return j.event}e.fromNodeEventEmitter=b;function S(A,R,M=D=>D){let D=(...O)=>j.fire(M(...O)),$=()=>A.addEventListener(R,D),F=()=>A.removeEventListener(R,D),j=new te({onWillAddFirstListener:$,onDidRemoveLastListener:F});return j.event}e.fromDOMEventEmitter=S;function C(A){return new Promise(R=>n(A)(R))}e.toPromise=C;function k(A){let R=new te;return A.then(M=>{R.fire(M)},()=>{R.fire(void 0)}).finally(()=>{R.dispose()}),R.event}e.fromPromise=k;function N(A,R){return A(M=>R.fire(M))}e.forward=N;function T(A,R,M){return R(M),A(D=>R(D))}e.runAndSubscribe=T;class z{constructor(R,M){this._observable=R,this._counter=0,this._hasChanged=!1;let D={onWillAddFirstListener:()=>{R.addObserver(this)},onDidRemoveLastListener:()=>{R.removeObserver(this)}};this.emitter=new te(D),M&&M.add(this.emitter)}beginUpdate(R){this._counter++}handlePossibleChange(R){}handleChange(R,M){this._hasChanged=!0}endUpdate(R){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function P(A,R){return new z(A,R).emitter.event}e.fromObservable=P;function B(A){return(R,M,D)=>{let $=0,F=!1,j={beginUpdate(){$++},endUpdate(){$--,$===0&&(A.reportChanges(),F&&(F=!1,R.call(M)))},handlePossibleChange(){},handleChange(){F=!0}};A.addObserver(j),A.reportChanges();let O={dispose(){A.removeObserver(j)}};return D instanceof As?D.add(O):Array.isArray(D)&&D.push(O),O}}e.fromObservableLight=B})(mn||(mn={}));var Z0=class J0{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${J0._idPool++}`,J0.all.add(this)}start(t){this._stopWatch=new $ne,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}}};Z0.all=new Set,Z0._idPool=0;var Fne=Z0,Hne=-1,u5=class d5{constructor(t,n,r=(d5._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 Vne(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}};u5._idPool=1;var Une=u5,Wne=class h5{constructor(t){this.value=t}static create(){let t=new Error;return new h5(t.stack??"")}print(){console.warn(this.value.split(`
|
|
564
564
|
`).slice(2).join(`
|
|
565
565
|
`))}},Vne=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},qne=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Kne=0,ag=class{constructor(e){this.value=e,this.id=Kne++}},Gne=2,Yne,te=class{constructor(e){var t,n,r,i;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new Une((e==null?void 0:e.onListenerError)??ch,((n=this._options)==null?void 0:n.leakWarningThreshold)??Hne):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new Fne(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 qne(`${d}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(((o=this._options)==null?void 0:o.onListenerError)||ch)(p),$e.None}if(this._disposed)return $e.None;t&&(e=e.bind(t));let r=new ag(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Wne.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof ag?(this._deliveryQueue??(this._deliveryQueue=new Xne),this._listeners=[this._listeners,r]):this._listeners.push(r):((l=(a=this._options)==null?void 0:a.onWillAddFirstListener)==null||l.call(a,this),this._listeners=r,(u=(c=this._options)==null?void 0:c.onDidAddFirstListener)==null||u.call(c,this)),this._size++;let s=vt(()=>{i==null||i(),this._removeListener(r)});return n instanceof As?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*Gne<=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)||ch;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 ag)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}},Xne=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}},e_=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new te,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new te,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let r=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let r=this.getWindowId(n);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};e_.INSTANCE=new e_;var l1=e_;function Qne(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}l1.INSTANCE.onDidChangeZoomLevel;function Zne(e){return l1.INSTANCE.getZoomFactor(e)}l1.INSTANCE.onDidChangeFullscreen;var El=typeof navigator=="object"?navigator.userAgent:"",t_=El.indexOf("Firefox")>=0,Jne=El.indexOf("AppleWebKit")>=0,c1=El.indexOf("Chrome")>=0,ere=!c1&&El.indexOf("Safari")>=0;El.indexOf("Electron/")>=0;El.indexOf("Android")>=0;var lg=!1;if(typeof Mi.matchMedia=="function"){let e=Mi.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Mi.matchMedia("(display-mode: fullscreen)");lg=e.matches,Qne(Mi,e,({matches:n})=>{lg&&t.matches||(lg=n)})}var Ca="en",n_=!1,r_=!1,uh=!1,f5=!1,Rd,dh=Ca,mC=Ca,tre,Lr,yo=globalThis,pn,h2;typeof yo.vscode<"u"&&typeof yo.vscode.process<"u"?pn=yo.vscode.process:typeof process<"u"&&typeof((h2=process==null?void 0:process.versions)==null?void 0:h2.node)=="string"&&(pn=process);var f2,nre=typeof((f2=pn==null?void 0:pn.versions)==null?void 0:f2.electron)=="string",rre=nre&&(pn==null?void 0:pn.type)==="renderer",p2;if(typeof pn=="object"){n_=pn.platform==="win32",r_=pn.platform==="darwin",uh=pn.platform==="linux",uh&&pn.env.SNAP&&pn.env.SNAP_REVISION,pn.env.CI||pn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Rd=Ca,dh=Ca;let e=pn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Rd=t.userLocale,mC=t.osLocale,dh=t.resolvedLanguage||Ca,tre=(p2=t.languagePack)==null?void 0:p2.translationsConfigFile}catch{}f5=!0}else typeof navigator=="object"&&!rre?(Lr=navigator.userAgent,n_=Lr.indexOf("Windows")>=0,r_=Lr.indexOf("Macintosh")>=0,(Lr.indexOf("Macintosh")>=0||Lr.indexOf("iPad")>=0||Lr.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,uh=Lr.indexOf("Linux")>=0,(Lr==null?void 0:Lr.indexOf("Mobi"))>=0,dh=globalThis._VSCODE_NLS_LANGUAGE||Ca,Rd=navigator.language.toLowerCase(),mC=Rd):console.error("Unable to resolve platform.");var p5=n_,fi=r_,ire=uh,gC=f5,vi=Lr,as=dh,sre;(e=>{function t(){return as}e.value=t;function n(){return as.length===2?as==="en":as.length>=3?as[0]==="e"&&as[1]==="n"&&as[2]==="-":!1}e.isDefaultVariant=n;function r(){return as==="en"}e.isDefault=r})(sre||(sre={}));var ore=typeof yo.postMessage=="function"&&!yo.importScripts;(()=>{if(ore){let e=[];yo.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}),yo.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var are=!!(vi&&vi.indexOf("Chrome")>=0);vi&&vi.indexOf("Firefox")>=0;!are&&vi&&vi.indexOf("Safari")>=0;vi&&vi.indexOf("Edg/")>=0;vi&&vi.indexOf("Android")>=0;var oa=typeof navigator=="object"?navigator:{};gC||document.queryCommandSupported&&document.queryCommandSupported("copy")||oa&&oa.clipboard&&oa.clipboard.writeText,gC||oa&&oa.clipboard&&oa.clipboard.readText;var u1=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}},cg=new u1,vC=new u1,_C=new u1,lre=new Array(230),m5;(e=>{function t(a){return cg.keyCodeToStr(a)}e.toString=t;function n(a){return cg.strToKeyCode(a)}e.fromString=n;function r(a){return vC.keyCodeToStr(a)}e.toUserSettingsUS=r;function i(a){return _C.keyCodeToStr(a)}e.toUserSettingsGeneral=i;function s(a){return vC.strToKeyCode(a)||_C.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 cg.keyCodeToStr(a)}e.toElectronAccelerator=o})(m5||(m5={}));var cre=class g5{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 g5&&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 ure([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},ure=class{constructor(e){if(e.length===0)throw Dne("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 dre(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return m5.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(t_)switch(t){case 59:return 85;case 60:if(ire)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(fi)return 57;break}else if(Jne&&(fi&&t===93||!fi&&t===92))return 57;return lre[t]||0}var hre=fi?256:2048,fre=512,pre=1024,mre=fi?2048:256,xC=class{constructor(e){var n;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(n=t.getModifierState)==null?void 0:n.call(t,"AltGraph"),this.keyCode=dre(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|=hre),this.altKey&&(t|=fre),this.shiftKey&&(t|=pre),this.metaKey&&(t|=mre),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new cre(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},yC=new WeakMap;function gre(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 vre=class{static getSameOriginWindowChain(e){let t=yC.get(e);if(!t){t=[],yC.set(e,t);let n=e,r;do r=gre(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,i=this.getSameOriginWindowChain(e);for(let s of i){let o=s.window.deref();if(n+=(o==null?void 0:o.scrollY)??0,r+=(o==null?void 0:o.scrollX)??0,o===t||!s.iframeElement)break;let a=s.iframeElement.getBoundingClientRect();n+=a.top,r+=a.left}return{top:n,left:r}}},Md=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=vre.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},bC=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(c1){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?t_&&!fi?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof s.wheelDeltaX<"u")ere&&p5?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?t_&&!fi?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()}},v5=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),_re;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof xre?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:mn.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:v5})})(_re||(_re={}));var xre=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?v5:(this._emitter||(this._emitter=new te),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},d1=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 Y0("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Y0("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},yre=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 Y0("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=vt(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},bre;(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})(bre||(bre={}));var wC=class _r{static fromArray(t){return new _r(n=>{n.emitMany(t)})}static fromPromise(t){return new _r(async n=>{n.emitMany(await t)})}static fromPromises(t){return new _r(async n=>{await Promise.all(t.map(async r=>n.emitOne(await r)))})}static merge(t){return new _r(async n=>{await Promise.all(t.map(async r=>{for await(let i of r)n.emitOne(i)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new te,queueMicrotask(async()=>{let r={emitOne:i=>this.emitOne(i),emitMany:i=>this.emitMany(i),reject:i=>this.reject(i)};try{await Promise.resolve(t(r)),this.resolve()}catch(i){this.reject(i)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await mn.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var n;return(n=this._onReturn)==null||n.call(this),{done:!0,value:void 0}}}}static map(t,n){return new _r(async r=>{for await(let i of t)r.emitOne(n(i))})}map(t){return _r.map(this,t)}static filter(t,n){return new _r(async r=>{for await(let i of t)n(i)&&r.emitOne(i)})}filter(t){return _r.filter(this,t)}static coalesce(t){return _r.filter(t,n=>!!n)}coalesce(){return _r.coalesce(this)}static async toPromise(t){let n=[];for await(let r of t)n.push(r);return n}toPromise(){return _r.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())}};wC.EMPTY=wC.fromArray([]);var{getWindow:li,getWindowId:wre,onDidRegisterWindow:Sre}=function(){let e=new Map,t={window:Mi,disposables:new As};e.set(Mi.vscodeWindowId,t);let n=new te,r=new te,i=new te;function s(o,a){return(typeof o=="number"?e.get(o):void 0)??(a?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(o){if(e.has(o.vscodeWindowId))return $e.None;let a=new As,l={window:o,disposables:a.add(new As)};return e.set(o.vscodeWindowId,l),a.add(vt(()=>{e.delete(o.vscodeWindowId),r.fire(o)})),a.add(Ee(o,sn.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:Mi},getDocument(o){return li(o).document}}}(),kre=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Ee(e,t,n,r){return new kre(e,t,n,r)}var SC=function(e,t,n,r){return Ee(e,t,n,r)},h1,Cre=class extends yre{constructor(e){super(),this.defaultTarget=e&&li(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},kC=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){ch(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(kC.sort),o.shift().execute();r.set(s,!1)};h1=(s,o,a=0)=>{let l=wre(s),c=new kC(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 Ere(e){let t=e.getBoundingClientRect(),n=li(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var sn={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"},Nre=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=Hn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Hn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Hn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Hn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Hn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Hn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Hn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Hn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Hn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Hn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Hn(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=Hn(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=Hn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Hn(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function Hn(e){return typeof e=="number"?`${e}px`:e}function Tc(e){return new Nre(e)}var _5=class{constructor(){this._hooks=new As,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let s=e;try{e.setPointerCapture(t),this._hooks.add(vt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{s=li(e)}this._hooks.add(Ee(s,sn.POINTER_MOVE,o=>{if(o.buttons!==n){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(Ee(s,sn.POINTER_UP,o=>this.stopMonitoring(!0)))}};function Tre(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 Jr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Jr||(Jr={}));var ac=class bn extends $e{constructor(){super(),this.dispatched=!1,this.targets=new pC,this.ignoreTargets=new pC,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(mn.runAndSubscribe(Sre,({window:t,disposables:n})=>{n.add(Ee(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),n.add(Ee(t.document,"touchend",r=>this.onTouchEnd(t,r))),n.add(Ee(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:Mi,disposables:this._store}))}static addTarget(t){if(!bn.isTouchDevice())return $e.None;bn.INSTANCE||(bn.INSTANCE=new bn);let n=bn.INSTANCE.targets.push(t);return vt(n)}static ignoreTarget(t){if(!bn.isTouchDevice())return $e.None;bn.INSTANCE||(bn.INSTANCE=new bn);let n=bn.INSTANCE.ignoreTargets.push(t);return vt(n)}static isTouchDevice(){return"ontouchstart"in Mi||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(Jr.Start,s.target);o.pageX=s.pageX,o.pageY=s.pageY,this.dispatchEvent(o)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let r=Date.now(),i=Object.keys(this.activeTouches).length;for(let s=0,o=n.changedTouches.length;s<o;s++){let a=n.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let l=this.activeTouches[a.identifier],c=Date.now()-l.initialTimeStamp;if(c<bn.HOLD_DELAY&&Math.abs(l.initialPageX-Zn(l.rollingPageX))<30&&Math.abs(l.initialPageY-Zn(l.rollingPageY))<30){let u=this.newGestureEvent(Jr.Tap,l.initialTarget);u.pageX=Zn(l.rollingPageX),u.pageY=Zn(l.rollingPageY),this.dispatchEvent(u)}else if(c>=bn.HOLD_DELAY&&Math.abs(l.initialPageX-Zn(l.rollingPageX))<30&&Math.abs(l.initialPageY-Zn(l.rollingPageY))<30){let u=this.newGestureEvent(Jr.Contextmenu,l.initialTarget);u.pageX=Zn(l.rollingPageX),u.pageY=Zn(l.rollingPageY),this.dispatchEvent(u)}else if(i===1){let u=Zn(l.rollingPageX),d=Zn(l.rollingPageY),f=Zn(l.rollingTimestamps)-l.rollingTimestamps[0],p=u-l.rollingPageX[0],m=d-l.rollingPageY[0],v=[...this.targets].filter(w=>l.initialTarget instanceof Node&&w.contains(l.initialTarget));this.inertia(t,v,r,Math.abs(p)/f,p>0?1:-1,u,Math.abs(m)/f,m>0?1:-1,d)}this.dispatchEvent(this.newGestureEvent(Jr.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===Jr.Tap){let n=new Date().getTime(),r=0;n-this._lastSetTapCountTime>bn.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===Jr.Change||t.type===Jr.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=h1(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=bn.SCROLL_FRICTION*d,a+=bn.SCROLL_FRICTION*d,i>0&&(m=!1,f=s*i*d),a>0&&(m=!1,p=l*a*d);let v=this.newGestureEvent(Jr.Change);v.translationX=f,v.translationY=p,n.forEach(w=>w.dispatchEvent(v)),m||this.inertia(t,n,u,i,s,o+f,a,l,c+p)})}onTouchMove(t){let n=Date.now();for(let r=0,i=t.changedTouches.length;r<i;r++){let s=t.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(String(s.identifier))){console.warn("end of an UNKNOWN touch",s);continue}let o=this.activeTouches[s.identifier],a=this.newGestureEvent(Jr.Change,o.initialTarget);a.translationX=s.pageX-Zn(o.rollingPageX),a.translationY=s.pageY-Zn(o.rollingPageY),a.pageX=s.pageX,a.pageY=s.pageY,this.dispatchEvent(a),o.rollingPageX.length>3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(s.pageX),o.rollingPageY.push(s.pageY),o.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};ac.SCROLL_FRICTION=-.005,ac.HOLD_DELAY=700,ac.CLEAR_TAP_COUNT_TIME=400,Mt([Tre],ac,"isTouchDevice",1);var Ire=ac,f1=class extends $e{onclick(e,t){this._register(Ee(e,sn.CLICK,n=>t(new Md(li(e),n))))}onmousedown(e,t){this._register(Ee(e,sn.MOUSE_DOWN,n=>t(new Md(li(e),n))))}onmouseover(e,t){this._register(Ee(e,sn.MOUSE_OVER,n=>t(new Md(li(e),n))))}onmouseleave(e,t){this._register(Ee(e,sn.MOUSE_LEAVE,n=>t(new Md(li(e),n))))}onkeydown(e,t){this._register(Ee(e,sn.KEY_DOWN,n=>t(new xC(n))))}onkeyup(e,t){this._register(Ee(e,sn.KEY_UP,n=>t(new xC(n))))}oninput(e,t){this._register(Ee(e,sn.INPUT,t))}onblur(e,t){this._register(Ee(e,sn.BLUR,t))}onfocus(e,t){this._register(Ee(e,sn.FOCUS,t))}onchange(e,t){this._register(Ee(e,sn.CHANGE,t))}ignoreGesture(e){return Ire.ignoreTarget(e)}},CC=11,Pre=class extends f1{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=CC+"px",this.domNode.style.height=CC+"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 _5),this._register(SC(this.bgDomNode,sn.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(SC(this.domNode,sn.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Cre),this._pointerdownScheduleRepeatTimer=this._register(new d1)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,li(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()}},Rre=class i_{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 i_(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 i_(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}}},Mre=class extends $e{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Rre(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 NC(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=NC.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)))}},EC=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function ug(e,t){let n=t-e;return function(r){return e+n*Dre(r)}}function Are(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var NC=class s_{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),Are(ug(t,i),ug(s,n),.33)}return ug(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 EC(r,i,!1)}return new EC(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return s_.start(t,n,r)}static start(t,n,r){r=r+10;let i=Date.now()-10;return new s_(t,n,i,r)}};function Lre(e){return Math.pow(e,3)}function Dre(e){return 1-Lre(1-e)}var jre=class extends $e{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 d1)}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":"")))}},Ore=140,x5=class extends f1{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 jre(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new _5),this._shouldRender=!0,this.domNode=Tc(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Ee(this.domNode.domNode,sn.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Pre(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=Tc(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ee(this.slider.domNode,sn.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=Ere(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(p5&&o>Ore){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()}},y5=class o_{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 o_(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=o_._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)}},Bre=class extends x5{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new y5(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}},zre=class extends x5{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new y5(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}},$re=500,TC=50,Fre=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},a_=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(c1){let n=li(t.browserEvent),r=Zne(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 Fre(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}};a_.INSTANCE=new a_;var Hre=a_,Ure=class extends f1{constructor(e,t,n){super(),this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new te),this.onWillScroll=this._onWillScroll.event,this._options=Vre(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 zre(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new Bre(this._scrollable,this._options,r)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Tc(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Tc(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Tc(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,i=>this._onMouseOver(i)),this.onmouseleave(this._listenOnDomNode,i=>this._onMouseLeave(i)),this._hideTimeout=this._register(new d1),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Lo(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,fi&&(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 bC(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Lo(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new bC(n))};this._mouseWheelToDispose.push(Ee(this._listenOnDomNode,sn.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var i;if((i=e.browserEvent)!=null&&i.defaultPrevented)return;let t=Hre.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=!fi&&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=TC*s,d=l.scrollTop-(u<0?Math.floor(u):Math.ceil(u));this._verticalScrollbar.writeScrollPosition(c,d)}if(o){let u=TC*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(),$re)}},Wre=class extends Ure{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 Vre(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,fi&&(t.className+=" mac"),t}var l_=class extends $e{constructor(e,t,n,r,i,s,o,a){super(),this._bufferService=n,this._optionsService=o,this._renderService=a,this._onRequestScrollLines=this._register(new te),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let l=this._register(new Mre({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>h1(r.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{l.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Wre(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},l)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(mn.runAndSubscribe(s.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=s.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(vt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(vt(()=>this._styleElement.remove())),this._register(mn.runAndSubscribe(s.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${s.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${s.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${s.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
566
566
|
`)})),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}};l_=Mt([le(2,zn),le(3,Ji),le(4,e5),le(5,Cl),le(6,$n),le(7,es)],l_);var c_=class extends $e{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(s=>this._removeDecoration(s))),this._register(vt(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var r;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((r=e==null?void 0:e.options)==null?void 0:r.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};c_=Mt([le(1,zn),le(2,Ji),le(3,Du),le(4,es)],c_);var qre=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)}},Qr={full:0,left:0,center:0,right:0},ls={full:0,left:0,center:0,right:0},Vl={full:0,left:0,center:0,right:0},yf=class extends $e{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 qre,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(c=this._viewportElement.parentElement)==null||c.insertBefore(this._canvas,this._viewportElement),this._register(vt(()=>{var u;return(u=this._canvas)==null?void 0:u.remove()}));let l=this._canvas.getContext("2d");if(l)this._ctx=l;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);ls.full=this._canvas.width,ls.left=e,ls.center=t,ls.right=e,this._refreshDrawHeightConstants(),Vl.full=1,Vl.left=1,Vl.center=1+ls.left,Vl.right=1+ls.left+ls.center}_refreshDrawHeightConstants(){Qr.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);Qr.left=t,Qr.center=t,Qr.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Qr.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Qr.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Qr.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Qr.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Vl[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Qr[e.position||"full"]/2),ls[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Qr[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}))}};yf=Mt([le(2,zn),le(3,Du),le(4,es),le(5,$n),le(6,Cl),le(7,Ji)],yf);var V;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
|
|
567
|
-
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(V||(V={}));var hh;(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=""))(hh||(hh={}));var b5;(e=>e.ST=`${V.ESC}\\`)(b5||(b5={}));var u_=class{constructor(e,t,n,r,i,s){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=s,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${V.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,r=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,i=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=i+"px",this._compositionView.style.top=r+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let s=this._compositionView.getBoundingClientRect();this._textarea.style.left=i+"px",this._textarea.style.top=r+"px",this._textarea.style.width=Math.max(s.width,1)+"px",this._textarea.style.height=Math.max(s.height,1)+"px",this._textarea.style.lineHeight=s.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};u_=Mt([le(2,zn),le(3,$n),le(4,Go),le(5,es)],u_);var an=0,ln=0,cn=0,Tt=0,IC={css:"#00000000",rgba:0},Ht;(e=>{function t(i,s,o,a){return a!==void 0?`#${ro(i)}${ro(s)}${ro(o)}${ro(a)}`:`#${ro(i)}${ro(s)}${ro(o)}`}e.toCss=t;function n(i,s,o,a=255){return(i<<24|s<<16|o<<8|a)>>>0}e.toRgba=n;function r(i,s,o,a){return{css:e.toCss(i,s,o,a),rgba:e.toRgba(i,s,o,a)}}e.toColor=r})(Ht||(Ht={}));var ft;(e=>{function t(l,c){if(Tt=(c.rgba&255)/255,Tt===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;an=p+Math.round((u-p)*Tt),ln=m+Math.round((d-m)*Tt),cn=v+Math.round((f-v)*Tt);let w=Ht.toCss(an,ln,cn),_=Ht.toRgba(an,ln,cn);return{css:w,rgba:_}}e.blend=t;function n(l){return(l.rgba&255)===255}e.isOpaque=n;function r(l,c,u){let d=fh.ensureContrastRatio(l.rgba,c.rgba,u);if(d)return Ht.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=r;function i(l){let c=(l.rgba|255)>>>0;return[an,ln,cn]=fh.toChannels(c),{css:Ht.toCss(an,ln,cn),rgba:c}}e.opaque=i;function s(l,c){return Tt=Math.round(c*255),[an,ln,cn]=fh.toChannels(l.rgba),{css:Ht.toCss(an,ln,cn,Tt),rgba:Ht.toRgba(an,ln,cn,Tt)}}e.opacity=s;function o(l,c){return Tt=l.rgba&255,s(l,Tt*c/255)}e.multiplyOpacity=o;function a(l){return[l.rgba>>24&255,l.rgba>>16&255,l.rgba>>8&255]}e.toColorRGB=a})(ft||(ft={}));var xt;(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 an=parseInt(i.slice(1,2).repeat(2),16),ln=parseInt(i.slice(2,3).repeat(2),16),cn=parseInt(i.slice(3,4).repeat(2),16),Ht.toColor(an,ln,cn);case 5:return an=parseInt(i.slice(1,2).repeat(2),16),ln=parseInt(i.slice(2,3).repeat(2),16),cn=parseInt(i.slice(3,4).repeat(2),16),Tt=parseInt(i.slice(4,5).repeat(2),16),Ht.toColor(an,ln,cn,Tt);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 an=parseInt(s[1]),ln=parseInt(s[2]),cn=parseInt(s[3]),Tt=Math.round((s[5]===void 0?1:parseFloat(s[5]))*255),Ht.toColor(an,ln,cn,Tt);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),[an,ln,cn,Tt]=t.getImageData(0,0,1,1).data,Tt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ht.toRgba(an,ln,cn,Tt),css:i}}e.toColor=r})(xt||(xt={}));var Pn;(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})(Pn||(Pn={}));var fh;(e=>{function t(o,a){if(Tt=(a&255)/255,Tt===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 an=d+Math.round((l-d)*Tt),ln=f+Math.round((c-f)*Tt),cn=p+Math.round((u-p)*Tt),Ht.toRgba(an,ln,cn)}e.blend=t;function n(o,a,l){let c=Pn.relativeLuminance(o>>8),u=Pn.relativeLuminance(a>>8);if(Ci(c,u)<l){if(u<c){let p=r(o,a,l),m=Ci(c,Pn.relativeLuminance(p>>8));if(m<l){let v=i(o,a,l),w=Ci(c,Pn.relativeLuminance(v>>8));return m>w?p:v}return p}let d=i(o,a,l),f=Ci(c,Pn.relativeLuminance(d>>8));if(f<l){let p=r(o,a,l),m=Ci(c,Pn.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=Ci(Pn.relativeLuminance2(f,p,m),Pn.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=Ci(Pn.relativeLuminance2(f,p,m),Pn.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=Ci(Pn.relativeLuminance2(f,p,m),Pn.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=Ci(Pn.relativeLuminance2(f,p,m),Pn.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})(fh||(fh={}));function ro(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Ci(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Kre=class extends Lu{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()]}},bf=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Er}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||ws.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++)bf._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||ws.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}};bf=Mt([le(0,zn)],bf);function Gre(e){return 57508<=e&&e<=57558}function Yre(e){return 9472<=e&&e<=9631}function Xre(e){return Gre(e)||Yre(e)}function Qre(){return{css:{canvas:Ad(),cell:Ad()},device:{canvas:Ad(),cell:Ad(),char:{width:0,height:0,left:0,top:0}}}}function Ad(){return{width:0,height:0}}var d_=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 Er,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,s,o,a,l,c,u){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();n&&m<s+1&&(m=s+1);let v,w=0,_="",x=0,b=0,S=0,C=0,k=!1,N=0,T=!1,z=0,P=0,B=[],A=c!==-1&&u!==-1;for(let R=0;R<m;R++){e.loadCell(R,this._workCell);let M=this._workCell.getWidth();if(M===0)continue;let D=!1,$=R>=P,F=R,j=this._workCell;if(f.length>0&&R===f[0][0]&&$){let _e=f.shift(),Qe=this._isCellInSelection(_e[0],t);for(x=_e[0]+1;x<_e[1];x++)$&&($=Qe===this._isCellInSelection(x,t));$&&($=!n||s<_e[0]||s>=_e[1]),$?(D=!0,j=new Kre(this._workCell,e.translateToString(!0,_e[0],_e[1]),_e[1]-_e[0]),F=_e[1]-1,M=j.getWidth()):P=_e[1]}let O=this._isCellInSelection(R,t),E=n&&R===s,H=A&&R>=c&&R<=u,q=!1;this._decorationService.forEachDecorationAtCell(R,t,void 0,_e=>{q=!0});let L=j.getChars()||ws;if(L===" "&&(j.isUnderline()||j.isOverline())&&(L=" "),z=M*a-l.get(L,j.isBold(),j.isItalic()),!v)v=this._document.createElement("span");else if(w&&(O&&T||!O&&!T&&j.bg===b)&&(O&&T&&p.selectionForeground||j.fg===S)&&j.extended.ext===C&&H===k&&z===N&&!E&&!D&&!q&&$){j.isInvisible()?_+=ws:_+=L,w++;continue}else w&&(v.textContent=_),v=this._document.createElement("span"),w=0,_="";if(b=j.bg,S=j.fg,C=j.extended.ext,k=H,N=z,T=O,D&&s>=R&&s<=F&&(s=R),!this._coreService.isCursorHidden&&E&&this._coreService.isCursorInitialized){if(B.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&B.push("xterm-cursor-blink"),B.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(i)switch(i){case"outline":B.push("xterm-cursor-outline");break;case"block":B.push("xterm-cursor-block");break;case"bar":B.push("xterm-cursor-bar");break;case"underline":B.push("xterm-cursor-underline");break}}if(j.isBold()&&B.push("xterm-bold"),j.isItalic()&&B.push("xterm-italic"),j.isDim()&&B.push("xterm-dim"),j.isInvisible()?_=ws:_=j.getChars()||ws,j.isUnderline()&&(B.push(`xterm-underline-${j.extended.underlineStyle}`),_===" "&&(_=" "),!j.isUnderlineColorDefault()))if(j.isUnderlineColorRGB())v.style.textDecorationColor=`rgb(${Lu.toColorRGB(j.getUnderlineColor()).join(",")})`;else{let _e=j.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&j.isBold()&&_e<8&&(_e+=8),v.style.textDecorationColor=p.ansi[_e].css}j.isOverline()&&(B.push("xterm-overline"),_===" "&&(_=" ")),j.isStrikethrough()&&B.push("xterm-strikethrough"),H&&(v.style.textDecoration="underline");let re=j.getFgColor(),se=j.getFgColorMode(),K=j.getBgColor(),me=j.getBgColorMode(),Re=!!j.isInverse();if(Re){let _e=re;re=K,K=_e;let Qe=se;se=me,me=Qe}let ce,Le,Oe=!1;this._decorationService.forEachDecorationAtCell(R,t,void 0,_e=>{_e.options.layer!=="top"&&Oe||(_e.backgroundColorRGB&&(me=50331648,K=_e.backgroundColorRGB.rgba>>8&16777215,ce=_e.backgroundColorRGB),_e.foregroundColorRGB&&(se=50331648,re=_e.foregroundColorRGB.rgba>>8&16777215,Le=_e.foregroundColorRGB),Oe=_e.options.layer==="top")}),!Oe&&O&&(ce=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,K=ce.rgba>>8&16777215,me=50331648,Oe=!0,p.selectionForeground&&(se=50331648,re=p.selectionForeground.rgba>>8&16777215,Le=p.selectionForeground)),Oe&&B.push("xterm-decoration-top");let Ae;switch(me){case 16777216:case 33554432:Ae=p.ansi[K],B.push(`xterm-bg-${K}`);break;case 50331648:Ae=Ht.toColor(K>>16,K>>8&255,K&255),this._addStyle(v,`background-color:#${PC((K>>>0).toString(16),"0",6)}`);break;case 0:default:Re?(Ae=p.foreground,B.push("xterm-bg-257")):Ae=p.background}switch(ce||j.isDim()&&(ce=ft.multiplyOpacity(Ae,.5)),se){case 16777216:case 33554432:j.isBold()&&re<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(re+=8),this._applyMinimumContrast(v,Ae,p.ansi[re],j,ce,void 0)||B.push(`xterm-fg-${re}`);break;case 50331648:let _e=Ht.toColor(re>>16&255,re>>8&255,re&255);this._applyMinimumContrast(v,Ae,_e,j,ce,Le)||this._addStyle(v,`color:#${PC(re.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(v,Ae,p.foreground,j,ce,Le)||Re&&B.push("xterm-fg-257")}B.length&&(v.className=B.join(" "),B.length=0),!E&&!D&&!q&&$?w++:v.textContent=_,z!==this.defaultSpacing&&(v.style.letterSpacing=`${z}px`),d.push(v),R=F}return v&&w&&(v.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,s){if(this._optionsService.rawOptions.minimumContrastRatio===1||Xre(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=ft.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]}};d_=Mt([le(1,r5),le(2,$n),le(3,Ji),le(4,Go),le(5,Du),le(6,Cl)],d_);function PC(e,t,n){for(;e.length<n;)e=t+e;return e}var Zre=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}},Jre=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 eie(){return new Jre}var dg="xterm-dom-renderer-owner-",vr="xterm-rows",Ld="xterm-fg-",RC="xterm-bg-",ql="xterm-focus",Dd="xterm-selection",tie=1,h_=class extends $e{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=tie++,this._rowElements=[],this._selectionRenderModel=eie(),this.onRequestRedraw=this._register(new te).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(vr),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=Qre(),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(d_,document),this._element.classList.add(dg+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(m=>this._handleLinkHover(m))),this._register(this._linkifier2.onHideLinkUnderline(m=>this._handleLinkLeave(m))),this._register(vt(()=>{this._element.classList.remove(dg+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Zre(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} .${vr} 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} .${vr} { 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} .${vr} .xterm-dim { color: ${ft.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} .${vr}.${ql} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${vr}.${ql} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${vr}.${ql} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${vr} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${vr} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${vr} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${vr} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${vr} .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} .${Ld}${s} { color: ${o.css}; }${this._terminalSelector} .${Ld}${s}.xterm-dim { color: ${ft.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${RC}${s} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${Ld}257 { color: ${ft.opaque(e.background).css}; }${this._terminalSelector} .${Ld}257.xterm-dim { color: ${ft.multiplyOpacity(ft.opaque(e.background),.5).css}; }${this._terminalSelector} .${RC}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(ql),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(ql),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,s=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(n){let l=e[0]>t[0];a.appendChild(this._createSelectionElement(s,l?t[0]:e[0],l?e[0]:t[0],o-s+1))}else{let l=r===s?e[0]:0,c=s===i?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(s,l,c));let u=o-s-1;if(a.appendChild(this._createSelectionElement(s+1,0,this._bufferService.cols,u)),s!==o){let d=i===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,d))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement("div"),s=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return s+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-s),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${s}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),s=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let l=e;l<=t;l++){let c=l+n.ydisp,u=this._rowElements[l],d=n.lines.get(c);if(!u||!d)break;u.replaceChildren(...this._rowFactory.createRow(d,c,c===r,o,a,i,s,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${dg}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,s){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let a=this._bufferService.buffer,l=a.ybase+a.y,c=Math.min(a.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=n;p<=r;++p){let m=p+a.ydisp,v=this._rowElements[p],w=a.lines.get(m);if(!v||!w)break;v.replaceChildren(...this._rowFactory.createRow(w,m,m===l,d,f,c,u,this.dimensions.css.cell.width,this._widthCache,s?p===n?e:0:-1,s?(p===r?t:i)-1:-1))}}};h_=Mt([le(7,o1),le(8,jp),le(9,$n),le(10,zn),le(11,Go),le(12,Ji),le(13,Cl)],h_);var f_=class extends $e{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new te),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new rie(this._optionsService))}catch{this._measureStrategy=this._register(new nie(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())}};f_=Mt([le(2,$n)],f_);var w5=class extends $e{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)}},nie=class extends w5{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}},rie=class extends w5{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}},iie=class extends $e{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 sie(this._window)),this._onDprChange=this._register(new te),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new te),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(mn.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ee(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ee(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},sie=class extends $e{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new rl),this._onDprChange=this._register(new te),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(vt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ee(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},oie=class extends $e{constructor(){super(),this.linkProviders=[],this._register(vt(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function p1(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 aie(e,t,n,r,i,s,o,a,l){if(!s)return;let c=p1(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 p_=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return aie(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=p1(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])}}};p_=Mt([le(0,es),le(1,jp)],p_);var lie=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=[]}},S5={};_ne(S5,{getSafariVersion:()=>uie,isChromeOS:()=>N5,isFirefox:()=>k5,isIpad:()=>die,isIphone:()=>hie,isLegacyEdge:()=>cie,isLinux:()=>m1,isMac:()=>wf,isNode:()=>Op,isSafari:()=>C5,isWindows:()=>E5});var Op=typeof process<"u"&&"title"in process,ju=Op?"node":navigator.userAgent,Ou=Op?"node":navigator.platform,k5=ju.includes("Firefox"),cie=ju.includes("Edge"),C5=/^((?!chrome|android).)*safari/i.test(ju);function uie(){if(!C5)return 0;let e=ju.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var wf=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Ou),die=Ou==="iPad",hie=Ou==="iPhone",E5=["Windows","Win16","Win32","WinCE"].includes(Ou),m1=Ou.indexOf("Linux")>=0,N5=/\bCrOS\b/.test(ju),T5=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()}},fie=class extends T5{_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())}}},pie=class extends T5{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Sf=!Op&&"requestIdleCallback"in window?pie:fie,mie=class{constructor(){this._queue=new Sf}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},m_=class extends $e{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 rl),this._pausedResizeTask=new mie,this._observerDisposable=this._register(new rl),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new te),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new te),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new te),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new te),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new lie((c,u)=>this._renderRows(c,u),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new gie(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(vt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var c;return(c=this._renderer.value)==null?void 0:c.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(s.onDecorationRegistered(()=>this._fullRefresh())),this._register(s.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(l.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=vt(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var n;return(n=this._renderer.value)==null?void 0:n.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,n){var r;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,(r=this._renderer.value)==null||r.handleSelectionChanged(e,t,n)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};m_=Mt([le(2,$n),le(3,jp),le(4,Go),le(5,Du),le(6,zn),le(7,Ji),le(8,Cl)],m_);var gie=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 vie(e,t,n,r){let i=n.buffer.x,s=n.buffer.y;if(!n.buffer.hasScrollback)return yie(i,s,e,t,n,r)+Bp(s,t,n,r)+bie(i,s,e,t,n,r);let o;if(s===t)return o=i>e?"D":"C",uu(Math.abs(i-e),cu(o,r));o=s>t?"D":"C";let a=Math.abs(s-t),l=xie(s>t?e:i,n)+(a-1)*n.cols+1+_ie(s>t?i:e);return uu(l,cu(o,r))}function _ie(e,t){return e-1}function xie(e,t){return t.cols-e}function yie(e,t,n,r,i,s){return Bp(t,r,i,s).length===0?"":uu(P5(e,t,e,t-Do(t,i),!1,i).length,cu("D",s))}function Bp(e,t,n,r){let i=e-Do(e,n),s=t-Do(t,n),o=Math.abs(i-s)-wie(e,t,n);return uu(o,cu(I5(e,t),r))}function bie(e,t,n,r,i,s){let o;Bp(t,r,i,s).length>0?o=r-Do(r,i):o=t;let a=r,l=Sie(e,t,n,r,i,s);return uu(P5(e,o,n,a,l==="C",i).length,cu(l,s))}function wie(e,t,n){var o;let r=0,i=e-Do(e,n),s=t-Do(t,n);for(let a=0;a<Math.abs(i-s);a++){let l=I5(e,t)==="A"?-1:1;(o=n.buffer.lines.get(i+l*a))!=null&&o.isWrapped&&r++}return r}function Do(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 Sie(e,t,n,r,i,s){let o;return Bp(n,r,i,s).length>0?o=r-Do(r,i):o=t,e<n&&o<=r||e>=n&&o<r?"C":"D"}function I5(e,t){return e>t?"A":"B"}function P5(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 cu(e,t){let n=t?"O":"[";return V.ESC+n+e}function uu(e,t){e=Math.floor(e);let n="";for(let r=0;r<e;r++)n+=t;return n}var kie=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 MC(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 hg=50,Cie=15,Eie=50,Nie=500,Tie=" ",Iie=new RegExp(Tie,"g"),g_=class extends $e{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 Er,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new te),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new te),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new te),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new te),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new kie(this._bufferService),this._activeSelectionMode=0,this._register(vt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let i=e[0]<t[0]?e[0]:t[0],s=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let a=n.translateBufferLineToString(o,!0,i,s);r.push(a)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let s=e[1]+1;s<=t[1]-1;s++){let o=n.lines.get(s),a=n.translateBufferLineToString(s,!0);o!=null&&o.isWrapped?r[r.length-1]+=a:r.push(a)}if(e[1]!==t[1]){let s=n.lines.get(t[1]),o=n.translateBufferLineToString(t[1],!0,0,t[0]);s&&s.isWrapped?r[r.length-1]+=o:r.push(o)}}return r.map(i=>i.replace(Iie," ")).join(E5?`\r
|
|
567
|
+
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(V||(V={}));var hh;(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=""))(hh||(hh={}));var b5;(e=>e.ST=`${V.ESC}\\`)(b5||(b5={}));var u_=class{constructor(e,t,n,r,i,s){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=s,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${V.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,r=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,i=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=i+"px",this._compositionView.style.top=r+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let s=this._compositionView.getBoundingClientRect();this._textarea.style.left=i+"px",this._textarea.style.top=r+"px",this._textarea.style.width=Math.max(s.width,1)+"px",this._textarea.style.height=Math.max(s.height,1)+"px",this._textarea.style.lineHeight=s.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};u_=Mt([le(2,zn),le(3,$n),le(4,Go),le(5,es)],u_);var an=0,ln=0,cn=0,Tt=0,IC={css:"#00000000",rgba:0},Ht;(e=>{function t(i,s,o,a){return a!==void 0?`#${ro(i)}${ro(s)}${ro(o)}${ro(a)}`:`#${ro(i)}${ro(s)}${ro(o)}`}e.toCss=t;function n(i,s,o,a=255){return(i<<24|s<<16|o<<8|a)>>>0}e.toRgba=n;function r(i,s,o,a){return{css:e.toCss(i,s,o,a),rgba:e.toRgba(i,s,o,a)}}e.toColor=r})(Ht||(Ht={}));var ft;(e=>{function t(l,c){if(Tt=(c.rgba&255)/255,Tt===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;an=p+Math.round((u-p)*Tt),ln=m+Math.round((d-m)*Tt),cn=v+Math.round((f-v)*Tt);let w=Ht.toCss(an,ln,cn),_=Ht.toRgba(an,ln,cn);return{css:w,rgba:_}}e.blend=t;function n(l){return(l.rgba&255)===255}e.isOpaque=n;function r(l,c,u){let d=fh.ensureContrastRatio(l.rgba,c.rgba,u);if(d)return Ht.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=r;function i(l){let c=(l.rgba|255)>>>0;return[an,ln,cn]=fh.toChannels(c),{css:Ht.toCss(an,ln,cn),rgba:c}}e.opaque=i;function s(l,c){return Tt=Math.round(c*255),[an,ln,cn]=fh.toChannels(l.rgba),{css:Ht.toCss(an,ln,cn,Tt),rgba:Ht.toRgba(an,ln,cn,Tt)}}e.opacity=s;function o(l,c){return Tt=l.rgba&255,s(l,Tt*c/255)}e.multiplyOpacity=o;function a(l){return[l.rgba>>24&255,l.rgba>>16&255,l.rgba>>8&255]}e.toColorRGB=a})(ft||(ft={}));var xt;(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 an=parseInt(i.slice(1,2).repeat(2),16),ln=parseInt(i.slice(2,3).repeat(2),16),cn=parseInt(i.slice(3,4).repeat(2),16),Ht.toColor(an,ln,cn);case 5:return an=parseInt(i.slice(1,2).repeat(2),16),ln=parseInt(i.slice(2,3).repeat(2),16),cn=parseInt(i.slice(3,4).repeat(2),16),Tt=parseInt(i.slice(4,5).repeat(2),16),Ht.toColor(an,ln,cn,Tt);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 an=parseInt(s[1]),ln=parseInt(s[2]),cn=parseInt(s[3]),Tt=Math.round((s[5]===void 0?1:parseFloat(s[5]))*255),Ht.toColor(an,ln,cn,Tt);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),[an,ln,cn,Tt]=t.getImageData(0,0,1,1).data,Tt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ht.toRgba(an,ln,cn,Tt),css:i}}e.toColor=r})(xt||(xt={}));var Pn;(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})(Pn||(Pn={}));var fh;(e=>{function t(o,a){if(Tt=(a&255)/255,Tt===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 an=d+Math.round((l-d)*Tt),ln=f+Math.round((c-f)*Tt),cn=p+Math.round((u-p)*Tt),Ht.toRgba(an,ln,cn)}e.blend=t;function n(o,a,l){let c=Pn.relativeLuminance(o>>8),u=Pn.relativeLuminance(a>>8);if(Ci(c,u)<l){if(u<c){let p=r(o,a,l),m=Ci(c,Pn.relativeLuminance(p>>8));if(m<l){let v=i(o,a,l),w=Ci(c,Pn.relativeLuminance(v>>8));return m>w?p:v}return p}let d=i(o,a,l),f=Ci(c,Pn.relativeLuminance(d>>8));if(f<l){let p=r(o,a,l),m=Ci(c,Pn.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=Ci(Pn.relativeLuminance2(f,p,m),Pn.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=Ci(Pn.relativeLuminance2(f,p,m),Pn.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=Ci(Pn.relativeLuminance2(f,p,m),Pn.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=Ci(Pn.relativeLuminance2(f,p,m),Pn.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})(fh||(fh={}));function ro(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Ci(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Kre=class extends Lu{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()]}},bf=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Er}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||ws.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++)bf._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||ws.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}};bf=Mt([le(0,zn)],bf);function Gre(e){return 57508<=e&&e<=57558}function Yre(e){return 9472<=e&&e<=9631}function Xre(e){return Gre(e)||Yre(e)}function Qre(){return{css:{canvas:Ad(),cell:Ad()},device:{canvas:Ad(),cell:Ad(),char:{width:0,height:0,left:0,top:0}}}}function Ad(){return{width:0,height:0}}var d_=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 Er,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,s,o,a,l,c,u){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();n&&m<s+1&&(m=s+1);let v,w=0,_="",x=0,b=0,S=0,C=0,k=!1,N=0,T=!1,z=0,P=0,B=[],A=c!==-1&&u!==-1;for(let R=0;R<m;R++){e.loadCell(R,this._workCell);let M=this._workCell.getWidth();if(M===0)continue;let D=!1,$=R>=P,F=R,j=this._workCell;if(f.length>0&&R===f[0][0]&&$){let _e=f.shift(),Qe=this._isCellInSelection(_e[0],t);for(x=_e[0]+1;x<_e[1];x++)$&&($=Qe===this._isCellInSelection(x,t));$&&($=!n||s<_e[0]||s>=_e[1]),$?(D=!0,j=new Kre(this._workCell,e.translateToString(!0,_e[0],_e[1]),_e[1]-_e[0]),F=_e[1]-1,M=j.getWidth()):P=_e[1]}let O=this._isCellInSelection(R,t),E=n&&R===s,H=A&&R>=c&&R<=u,q=!1;this._decorationService.forEachDecorationAtCell(R,t,void 0,_e=>{q=!0});let L=j.getChars()||ws;if(L===" "&&(j.isUnderline()||j.isOverline())&&(L=" "),z=M*a-l.get(L,j.isBold(),j.isItalic()),!v)v=this._document.createElement("span");else if(w&&(O&&T||!O&&!T&&j.bg===b)&&(O&&T&&p.selectionForeground||j.fg===S)&&j.extended.ext===C&&H===k&&z===N&&!E&&!D&&!q&&$){j.isInvisible()?_+=ws:_+=L,w++;continue}else w&&(v.textContent=_),v=this._document.createElement("span"),w=0,_="";if(b=j.bg,S=j.fg,C=j.extended.ext,k=H,N=z,T=O,D&&s>=R&&s<=F&&(s=R),!this._coreService.isCursorHidden&&E&&this._coreService.isCursorInitialized){if(B.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&B.push("xterm-cursor-blink"),B.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(i)switch(i){case"outline":B.push("xterm-cursor-outline");break;case"block":B.push("xterm-cursor-block");break;case"bar":B.push("xterm-cursor-bar");break;case"underline":B.push("xterm-cursor-underline");break}}if(j.isBold()&&B.push("xterm-bold"),j.isItalic()&&B.push("xterm-italic"),j.isDim()&&B.push("xterm-dim"),j.isInvisible()?_=ws:_=j.getChars()||ws,j.isUnderline()&&(B.push(`xterm-underline-${j.extended.underlineStyle}`),_===" "&&(_=" "),!j.isUnderlineColorDefault()))if(j.isUnderlineColorRGB())v.style.textDecorationColor=`rgb(${Lu.toColorRGB(j.getUnderlineColor()).join(",")})`;else{let _e=j.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&j.isBold()&&_e<8&&(_e+=8),v.style.textDecorationColor=p.ansi[_e].css}j.isOverline()&&(B.push("xterm-overline"),_===" "&&(_=" ")),j.isStrikethrough()&&B.push("xterm-strikethrough"),H&&(v.style.textDecoration="underline");let re=j.getFgColor(),se=j.getFgColorMode(),K=j.getBgColor(),ge=j.getBgColorMode(),Re=!!j.isInverse();if(Re){let _e=re;re=K,K=_e;let Qe=se;se=ge,ge=Qe}let ce,Le,Oe=!1;this._decorationService.forEachDecorationAtCell(R,t,void 0,_e=>{_e.options.layer!=="top"&&Oe||(_e.backgroundColorRGB&&(ge=50331648,K=_e.backgroundColorRGB.rgba>>8&16777215,ce=_e.backgroundColorRGB),_e.foregroundColorRGB&&(se=50331648,re=_e.foregroundColorRGB.rgba>>8&16777215,Le=_e.foregroundColorRGB),Oe=_e.options.layer==="top")}),!Oe&&O&&(ce=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,K=ce.rgba>>8&16777215,ge=50331648,Oe=!0,p.selectionForeground&&(se=50331648,re=p.selectionForeground.rgba>>8&16777215,Le=p.selectionForeground)),Oe&&B.push("xterm-decoration-top");let Ae;switch(ge){case 16777216:case 33554432:Ae=p.ansi[K],B.push(`xterm-bg-${K}`);break;case 50331648:Ae=Ht.toColor(K>>16,K>>8&255,K&255),this._addStyle(v,`background-color:#${PC((K>>>0).toString(16),"0",6)}`);break;case 0:default:Re?(Ae=p.foreground,B.push("xterm-bg-257")):Ae=p.background}switch(ce||j.isDim()&&(ce=ft.multiplyOpacity(Ae,.5)),se){case 16777216:case 33554432:j.isBold()&&re<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(re+=8),this._applyMinimumContrast(v,Ae,p.ansi[re],j,ce,void 0)||B.push(`xterm-fg-${re}`);break;case 50331648:let _e=Ht.toColor(re>>16&255,re>>8&255,re&255);this._applyMinimumContrast(v,Ae,_e,j,ce,Le)||this._addStyle(v,`color:#${PC(re.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(v,Ae,p.foreground,j,ce,Le)||Re&&B.push("xterm-fg-257")}B.length&&(v.className=B.join(" "),B.length=0),!E&&!D&&!q&&$?w++:v.textContent=_,z!==this.defaultSpacing&&(v.style.letterSpacing=`${z}px`),d.push(v),R=F}return v&&w&&(v.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,s){if(this._optionsService.rawOptions.minimumContrastRatio===1||Xre(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=ft.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]}};d_=Mt([le(1,r5),le(2,$n),le(3,Ji),le(4,Go),le(5,Du),le(6,Cl)],d_);function PC(e,t,n){for(;e.length<n;)e=t+e;return e}var Zre=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}},Jre=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 eie(){return new Jre}var dg="xterm-dom-renderer-owner-",vr="xterm-rows",Ld="xterm-fg-",RC="xterm-bg-",ql="xterm-focus",Dd="xterm-selection",tie=1,h_=class extends $e{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=tie++,this._rowElements=[],this._selectionRenderModel=eie(),this.onRequestRedraw=this._register(new te).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(vr),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=Qre(),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(d_,document),this._element.classList.add(dg+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(m=>this._handleLinkHover(m))),this._register(this._linkifier2.onHideLinkUnderline(m=>this._handleLinkLeave(m))),this._register(vt(()=>{this._element.classList.remove(dg+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Zre(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} .${vr} 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} .${vr} { 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} .${vr} .xterm-dim { color: ${ft.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} .${vr}.${ql} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${vr}.${ql} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${vr}.${ql} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${vr} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${vr} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${vr} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${vr} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${vr} .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} .${Ld}${s} { color: ${o.css}; }${this._terminalSelector} .${Ld}${s}.xterm-dim { color: ${ft.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${RC}${s} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${Ld}257 { color: ${ft.opaque(e.background).css}; }${this._terminalSelector} .${Ld}257.xterm-dim { color: ${ft.multiplyOpacity(ft.opaque(e.background),.5).css}; }${this._terminalSelector} .${RC}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(ql),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(ql),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,s=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(n){let l=e[0]>t[0];a.appendChild(this._createSelectionElement(s,l?t[0]:e[0],l?e[0]:t[0],o-s+1))}else{let l=r===s?e[0]:0,c=s===i?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(s,l,c));let u=o-s-1;if(a.appendChild(this._createSelectionElement(s+1,0,this._bufferService.cols,u)),s!==o){let d=i===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,d))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement("div"),s=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return s+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-s),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${s}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),s=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let l=e;l<=t;l++){let c=l+n.ydisp,u=this._rowElements[l],d=n.lines.get(c);if(!u||!d)break;u.replaceChildren(...this._rowFactory.createRow(d,c,c===r,o,a,i,s,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${dg}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,s){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let a=this._bufferService.buffer,l=a.ybase+a.y,c=Math.min(a.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=n;p<=r;++p){let m=p+a.ydisp,v=this._rowElements[p],w=a.lines.get(m);if(!v||!w)break;v.replaceChildren(...this._rowFactory.createRow(w,m,m===l,d,f,c,u,this.dimensions.css.cell.width,this._widthCache,s?p===n?e:0:-1,s?(p===r?t:i)-1:-1))}}};h_=Mt([le(7,o1),le(8,jp),le(9,$n),le(10,zn),le(11,Go),le(12,Ji),le(13,Cl)],h_);var f_=class extends $e{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new te),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new rie(this._optionsService))}catch{this._measureStrategy=this._register(new nie(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())}};f_=Mt([le(2,$n)],f_);var w5=class extends $e{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)}},nie=class extends w5{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}},rie=class extends w5{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}},iie=class extends $e{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 sie(this._window)),this._onDprChange=this._register(new te),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new te),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(mn.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ee(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ee(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},sie=class extends $e{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new rl),this._onDprChange=this._register(new te),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(vt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ee(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},oie=class extends $e{constructor(){super(),this.linkProviders=[],this._register(vt(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function p1(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 aie(e,t,n,r,i,s,o,a,l){if(!s)return;let c=p1(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 p_=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return aie(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=p1(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])}}};p_=Mt([le(0,es),le(1,jp)],p_);var lie=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=[]}},S5={};_ne(S5,{getSafariVersion:()=>uie,isChromeOS:()=>N5,isFirefox:()=>k5,isIpad:()=>die,isIphone:()=>hie,isLegacyEdge:()=>cie,isLinux:()=>m1,isMac:()=>wf,isNode:()=>Op,isSafari:()=>C5,isWindows:()=>E5});var Op=typeof process<"u"&&"title"in process,ju=Op?"node":navigator.userAgent,Ou=Op?"node":navigator.platform,k5=ju.includes("Firefox"),cie=ju.includes("Edge"),C5=/^((?!chrome|android).)*safari/i.test(ju);function uie(){if(!C5)return 0;let e=ju.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var wf=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Ou),die=Ou==="iPad",hie=Ou==="iPhone",E5=["Windows","Win16","Win32","WinCE"].includes(Ou),m1=Ou.indexOf("Linux")>=0,N5=/\bCrOS\b/.test(ju),T5=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()}},fie=class extends T5{_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())}}},pie=class extends T5{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Sf=!Op&&"requestIdleCallback"in window?pie:fie,mie=class{constructor(){this._queue=new Sf}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},m_=class extends $e{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 rl),this._pausedResizeTask=new mie,this._observerDisposable=this._register(new rl),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new te),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new te),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new te),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new te),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new lie((c,u)=>this._renderRows(c,u),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new gie(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(vt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var c;return(c=this._renderer.value)==null?void 0:c.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(s.onDecorationRegistered(()=>this._fullRefresh())),this._register(s.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(l.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=vt(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var n;return(n=this._renderer.value)==null?void 0:n.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,n){var r;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,(r=this._renderer.value)==null||r.handleSelectionChanged(e,t,n)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};m_=Mt([le(2,$n),le(3,jp),le(4,Go),le(5,Du),le(6,zn),le(7,Ji),le(8,Cl)],m_);var gie=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 vie(e,t,n,r){let i=n.buffer.x,s=n.buffer.y;if(!n.buffer.hasScrollback)return yie(i,s,e,t,n,r)+Bp(s,t,n,r)+bie(i,s,e,t,n,r);let o;if(s===t)return o=i>e?"D":"C",uu(Math.abs(i-e),cu(o,r));o=s>t?"D":"C";let a=Math.abs(s-t),l=xie(s>t?e:i,n)+(a-1)*n.cols+1+_ie(s>t?i:e);return uu(l,cu(o,r))}function _ie(e,t){return e-1}function xie(e,t){return t.cols-e}function yie(e,t,n,r,i,s){return Bp(t,r,i,s).length===0?"":uu(P5(e,t,e,t-Do(t,i),!1,i).length,cu("D",s))}function Bp(e,t,n,r){let i=e-Do(e,n),s=t-Do(t,n),o=Math.abs(i-s)-wie(e,t,n);return uu(o,cu(I5(e,t),r))}function bie(e,t,n,r,i,s){let o;Bp(t,r,i,s).length>0?o=r-Do(r,i):o=t;let a=r,l=Sie(e,t,n,r,i,s);return uu(P5(e,o,n,a,l==="C",i).length,cu(l,s))}function wie(e,t,n){var o;let r=0,i=e-Do(e,n),s=t-Do(t,n);for(let a=0;a<Math.abs(i-s);a++){let l=I5(e,t)==="A"?-1:1;(o=n.buffer.lines.get(i+l*a))!=null&&o.isWrapped&&r++}return r}function Do(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 Sie(e,t,n,r,i,s){let o;return Bp(n,r,i,s).length>0?o=r-Do(r,i):o=t,e<n&&o<=r||e>=n&&o<r?"C":"D"}function I5(e,t){return e>t?"A":"B"}function P5(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 cu(e,t){let n=t?"O":"[";return V.ESC+n+e}function uu(e,t){e=Math.floor(e);let n="";for(let r=0;r<e;r++)n+=t;return n}var kie=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 MC(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 hg=50,Cie=15,Eie=50,Nie=500,Tie=" ",Iie=new RegExp(Tie,"g"),g_=class extends $e{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 Er,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new te),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new te),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new te),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new te),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new kie(this._bufferService),this._activeSelectionMode=0,this._register(vt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let i=e[0]<t[0]?e[0]:t[0],s=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let a=n.translateBufferLineToString(o,!0,i,s);r.push(a)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let s=e[1]+1;s<=t[1]-1;s++){let o=n.lines.get(s),a=n.translateBufferLineToString(s,!0);o!=null&&o.isWrapped?r[r.length-1]+=a:r.push(a)}if(e[1]!==t[1]){let s=n.lines.get(t[1]),o=n.translateBufferLineToString(t[1],!0,0,t[0]);s&&s.isWrapped?r[r.length-1]+=o:r.push(o)}}return r.map(i=>i.replace(Iie," ")).join(E5?`\r
|
|
568
568
|
`:`
|
|
569
569
|
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),m1&&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=MC(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=p1(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,-hg),hg),t/=hg,t/Math.abs(t)+Math.round(t*(Cie-1)))}shouldForceSelection(e){return wf?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(),Eie)}_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&&!(wf&&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<Nie&&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=vie(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(r,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,s=i.lines.get(e[1]);if(!s)return;let o=i.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(s,e[0]),l=a,c=e[0]-a,u=0,d=0,f=0,p=0;if(o.charAt(a)===" "){for(;a>0&&o.charAt(a-1)===" ";)a--;for(;l<o.length&&o.charAt(l+1)===" ";)l++}else{let w=e[0],_=e[0];s.getWidth(w)===0&&(u++,w--),s.getWidth(_)===2&&(d++,_++);let x=s.getString(_).length;for(x>1&&(p+=x-1,l+=x-1);w>0&&a>0&&!this._isCharWordSeparator(s.loadCell(w-1,this._workCell));){s.loadCell(w-1,this._workCell);let b=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,w--):b>1&&(f+=b-1,a-=b-1),a--,w--}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 w=i.lines.get(e[1]-1);if(w&&s.isWrapped&&w.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 w=i.lines.get(e[1]+1);if(w!=null&&w.isWrapped&&w.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=MC(n,this._bufferService.cols)}};g_=Mt([le(3,zn),le(4,Go),le(5,a1),le(6,$n),le(7,es),le(8,Ji)],g_);var AC=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={}}},LC=class{constructor(){this._color=new AC,this._css=new AC}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()}},Kt=Object.freeze((()=>{let e=[xt.toColor("#2e3436"),xt.toColor("#cc0000"),xt.toColor("#4e9a06"),xt.toColor("#c4a000"),xt.toColor("#3465a4"),xt.toColor("#75507b"),xt.toColor("#06989a"),xt.toColor("#d3d7cf"),xt.toColor("#555753"),xt.toColor("#ef2929"),xt.toColor("#8ae234"),xt.toColor("#fce94f"),xt.toColor("#729fcf"),xt.toColor("#ad7fa8"),xt.toColor("#34e2e2"),xt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],s=t[n%6];e.push({css:Ht.toCss(r,i,s),rgba:Ht.toRgba(r,i,s)})}for(let n=0;n<24;n++){let r=8+n*10;e.push({css:Ht.toCss(r,r,r),rgba:Ht.toRgba(r,r,r)})}return e})()),oo=xt.toColor("#ffffff"),lc=xt.toColor("#000000"),DC=xt.toColor("#ffffff"),jC=lc,Kl={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Pie=oo,v_=class extends $e{constructor(e){super(),this._optionsService=e,this._contrastCache=new LC,this._halfContrastCache=new LC,this._onChangeColors=this._register(new te),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:oo,background:lc,cursor:DC,cursorAccent:jC,selectionForeground:void 0,selectionBackgroundTransparent:Kl,selectionBackgroundOpaque:ft.blend(lc,Kl),selectionInactiveBackgroundTransparent:Kl,selectionInactiveBackgroundOpaque:ft.blend(lc,Kl),scrollbarSliderBackground:ft.opacity(oo,.2),scrollbarSliderHoverBackground:ft.opacity(oo,.4),scrollbarSliderActiveBackground:ft.opacity(oo,.5),overviewRulerBorder:oo,ansi:Kt.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=at(e.foreground,oo),t.background=at(e.background,lc),t.cursor=ft.blend(t.background,at(e.cursor,DC)),t.cursorAccent=ft.blend(t.background,at(e.cursorAccent,jC)),t.selectionBackgroundTransparent=at(e.selectionBackground,Kl),t.selectionBackgroundOpaque=ft.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=at(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ft.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?at(e.selectionForeground,IC):void 0,t.selectionForeground===IC&&(t.selectionForeground=void 0),ft.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ft.opacity(t.selectionBackgroundTransparent,.3)),ft.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ft.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=at(e.scrollbarSliderBackground,ft.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=at(e.scrollbarSliderHoverBackground,ft.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=at(e.scrollbarSliderActiveBackground,ft.opacity(t.foreground,.5)),t.overviewRulerBorder=at(e.overviewRulerBorder,Pie),t.ansi=Kt.slice(),t.ansi[0]=at(e.black,Kt[0]),t.ansi[1]=at(e.red,Kt[1]),t.ansi[2]=at(e.green,Kt[2]),t.ansi[3]=at(e.yellow,Kt[3]),t.ansi[4]=at(e.blue,Kt[4]),t.ansi[5]=at(e.magenta,Kt[5]),t.ansi[6]=at(e.cyan,Kt[6]),t.ansi[7]=at(e.white,Kt[7]),t.ansi[8]=at(e.brightBlack,Kt[8]),t.ansi[9]=at(e.brightRed,Kt[9]),t.ansi[10]=at(e.brightGreen,Kt[10]),t.ansi[11]=at(e.brightYellow,Kt[11]),t.ansi[12]=at(e.brightBlue,Kt[12]),t.ansi[13]=at(e.brightMagenta,Kt[13]),t.ansi[14]=at(e.brightCyan,Kt[14]),t.ansi[15]=at(e.brightWhite,Kt[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]=at(e.extendedAnsi[r],Kt[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()}}};v_=Mt([le(0,$n)],v_);function at(e,t){if(e!==void 0)try{return xt.toColor(e)}catch{}return t}var Rie=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)}},Mie=class{constructor(){this._services=new Rie,this._services.set(o1,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=Cne(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)}},Aie={trace:0,debug:1,info:2,warn:3,error:4,off:5},Lie="xterm.js: ",__=class extends $e{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=Aie[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?"":Lie)+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)}};__=Mt([le(0,$n)],__);var OC=class extends $e{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new te),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new te),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new te),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let r=e;r<this._length-t;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+n.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<n.length;r++)this._array[this._getCyclicIndex(e+r)]=n[r];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let r=this._length+n.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let i=t-1;i>=0;i--)this.set(e+i+n,this.get(e+i));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Be=3,zt=Object.freeze(new Lu),jd=0,fg=2,cc=class R5{constructor(t,n,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Be);let i=n||Er.fromCharData([0,XA,1,0]);for(let s=0;s<t;++s)this.setCell(s,i);this.length=t}get(t){let n=this._data[t*Be+0],r=n&2097151;return[this._data[t*Be+1],n&2097152?this._combined[t]:r?ms(r):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,n){this._data[t*Be+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*Be+0]=t|2097152|n[2]<<22):this._data[t*Be+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*Be+0]>>22}hasWidth(t){return this._data[t*Be+0]&12582912}getFg(t){return this._data[t*Be+1]}getBg(t){return this._data[t*Be+2]}hasContent(t){return this._data[t*Be+0]&4194303}getCodePoint(t){let n=this._data[t*Be+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*Be+0]&2097152}getString(t){let n=this._data[t*Be+0];return n&2097152?this._combined[t]:n&2097151?ms(n&2097151):""}isProtected(t){return this._data[t*Be+2]&536870912}loadCell(t,n){return jd=t*Be,n.content=this._data[jd+0],n.fg=this._data[jd+1],n.bg=this._data[jd+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*Be+0]=n.content,this._data[t*Be+1]=n.fg,this._data[t*Be+2]=n.bg}setCellFromCodepoint(t,n,r,i){i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*Be+0]=n|r<<22,this._data[t*Be+1]=i.fg,this._data[t*Be+2]=i.bg}addCodepointToCell(t,n,r){let i=this._data[t*Be+0];i&2097152?this._combined[t]+=ms(n):i&2097151?(this._combined[t]=ms(i&2097151)+ms(n),i&=-2097152,i|=2097152):i=n|1<<22,r&&(i&=-12582913,i|=r<<22),this._data[t*Be+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 Er;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 Er;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*fg<this._data.buffer.byteLength;let r=t*Be;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*fg<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*fg<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 R5(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*Be+0]&4194303)return t+(this._data[t*Be+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Be+0]&4194303||this._data[t*Be+2]&50331648)return t+(this._data[t*Be+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<Be;c++)this._data[(r+l)*Be+c]=o[(n+l)*Be+c];o[(n+l)*Be+2]&268435456&&(this._extendedAttrs[r+l]=t._extendedAttrs[n+l])}else for(let l=0;l<i;l++){for(let c=0;c<Be;c++)this._data[(r+l)*Be+c]=o[(n+l)*Be+c];o[(n+l)*Be+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*Be+0],a=o&2097151,l=o&2097152?this._combined[n]:a?ms(a):ws;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 Die(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=du(u,d,t),p=1,m=0;for(;p<u.length;){let w=du(u,p,t),_=w-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===w&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let v=0;for(let w=u.length-1;w>0&&(w>d||u[w].getTrimmedLength()===0);w--)v++;v>0&&(o.push(a+u.length-v),o.push(v)),a+=u.length-1}return o}function jie(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 Oie(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 Bie(e,t,n){let r=[],i=e.map((l,c)=>du(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=du(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 du(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 M5=class A5{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=A5._nextId++,this._onDispose=this.register(new te),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Lo(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};M5._nextId=1;var zie=M5,Zt={},ao=Zt.B;Zt[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Zt.A={"#":"£"};Zt.B=void 0;Zt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Zt.C=Zt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Zt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Zt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Zt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Zt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Zt.E=Zt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Zt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Zt.H=Zt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Zt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var BC=4294967295,zC=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=zt.clone(),this.savedCharset=ao,this.markers=[],this._nullCell=Er.fromCharData([0,XA,1,0]),this._whitespaceCell=Er.fromCharData([0,ws,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Sf,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new OC(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new xf),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new xf),this._whitespaceCell}getBlankLine(e,t){return new cc(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>BC?BC:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=zt);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new OC(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(zt),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let o=0;o<this.lines.length;o++)r+=+this.lines.get(o).resize(e,n);let s=0;if(this._rows<t)for(let o=this._rows;o<t;o++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new cc(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+s+1?(this.ybase--,s++,this.ydisp>0&&this.ydisp--):this.lines.push(new cc(e,n)));else for(let o=this._rows;o>t;o--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let o=this.lines.length-i;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),s&&(this.y+=s),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let s=0;s<this.lines.length;s++)r+=+this.lines.get(s).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=Die(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(zt),n);if(r.length>0){let i=jie(this.lines,r);Oie(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(zt),i=n;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new cc(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(zt),i=[],s=0;for(let o=this.lines.length-1;o>=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let l=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),l.unshift(a);if(!n){let b=this.ybase+this.y;if(b>=o&&b<o+l.length)continue}let c=l[l.length-1].getTrimmedLength(),u=Bie(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 S=this.getBlankLine(zt,!0);p.push(S)}p.length>0&&(i.push({start:o+l.length+s,newLines:p}),s+=p.length),l.push(...p);let m=u.length-1,v=u[m];v===0&&(m--,v=u[m]);let w=l.length-d-1,_=c;for(;w>=0;){let b=Math.min(_,v);if(l[m]===void 0)break;if(l[m].copyCellsFrom(l[w],_-b,v-b,b,!0),v-=b,v===0&&(m--,v=u[m]),_-=b,_===0){w--;let S=Math.max(w,0);_=du(l,S,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 w=d.newLines.length-1;w>=0;w--)this.lines.set(v--,d.newLines[w]);v++,o.push({index:c+1,amount:d.newLines.length}),f+=d.newLines.length,d=i[++u]}else this.lines.set(v,a[c--]);let p=0;for(let v=o.length-1;v>=0;v--)o[v].index+=p,this.lines.onInsertEmitter.fire(o[v]),p+=o[v].amount;let m=Math.max(0,l+s-this.lines.maxLength);m>0&&this.lines.onTrimEmitter.fire(m)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new zie(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)}},$ie=class extends $e{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new te),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new zC(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new zC(!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)}},L5=2,D5=1,x_=class extends $e{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new te),this.onResize=this._onResize.event,this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,L5),this.rows=Math.max(e.rawOptions.rows||0,D5),this.buffers=this._register(new $ie(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))}};x_=Mt([le(0,$n)],x_);var aa={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:wf,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Fie=["normal","bold","100","200","300","400","500","600","700","800","900"],Hie=class extends $e{constructor(e){super(),this._onOptionChange=this._register(new te),this.onOptionChange=this._onOptionChange.event;let t={...aa};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(vt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in aa))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,r)=>{if(!(n in aa))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=aa[e]),!Uie(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=aa[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=Fie.includes(t)?t:aa[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 Uie(e){return e==="block"||e==="underline"||e==="bar"}function uc(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&uc(e[r],t-1);return n}var $C=Object.freeze({insertMode:!1}),FC=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),y_=class extends $e{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new te),this.onData=this._onData.event,this._onUserInput=this._register(new te),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new te),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new te),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=uc($C),this.decPrivateModes=uc(FC)}reset(){this.modes=uc($C),this.decPrivateModes=uc(FC)}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))}};y_=Mt([le(0,zn),le(1,t5),le(2,$n)],y_);var HC={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 pg(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 mg=String.fromCharCode,UC={DEFAULT:e=>{let t=[pg(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${mg(t[0])}${mg(t[1])}${mg(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${pg(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${pg(e,!0)};${e.x};${e.y}${t}`}},b_=class extends $e{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new te),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(HC))this.addProtocol(r,HC[r]);for(let r of Object.keys(UC))this.addEncoding(r,UC[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)}};b_=Mt([le(0,zn),le(1,Go),le(2,$n)],b_);var gg=[[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]],Wie=[[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]],Gt;function Vie(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 qie=class{constructor(){if(this.version="6",!Gt){Gt=new Uint8Array(65536),Gt.fill(1),Gt[0]=0,Gt.fill(0,1,32),Gt.fill(0,127,160),Gt.fill(2,4352,4448),Gt[9001]=2,Gt[9002]=2,Gt.fill(2,11904,42192),Gt[12351]=1,Gt.fill(2,44032,55204),Gt.fill(2,63744,64256),Gt.fill(2,65040,65050),Gt.fill(2,65072,65136),Gt.fill(2,65280,65377),Gt.fill(2,65504,65511);for(let e=0;e<gg.length;++e)Gt.fill(0,gg[e][0],gg[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Gt[e]:Vie(e,Wie)?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=go.extractWidth(t);i===0?r=!1:i>n&&(n=i)}return go.createPropertyValue(0,n,r)}},go=class ph{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new te,this.onChange=this._onChange.event;let t=new qie;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=ph.extractWidth(a);ph.extractShouldJoin(a)&&(l-=ph.extractWidth(r)),n+=l,r=a}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},Kie=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 WC(e){var r;let t=(r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:r.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var Gl=2147483647,Gie=256,j5=class w_{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>Gie)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 w_;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 w_(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let n=0;n<this.length;++n){t.push(this.params[n]);let r=this._subParamsIdx[n]>>8,i=this._subParamsIdx[n]&255;i-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,i))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Gl?Gl:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>Gl?Gl:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-n>0?this._subParams.subarray(n,r):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let r=this._subParamsIdx[n]>>8,i=this._subParamsIdx[n]&255;i-r>0&&(t[n]=this._subParams.slice(r,i))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,i=r[n-1];r[n-1]=~i?Math.min(i*10+t,Gl):t}},Yl=[],Yie=class{constructor(){this._state=0,this._active=Yl,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Yl}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=Yl,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Yl,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",Dp(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let r=e[t++];if(r===59){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+r-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=Yl,this._id=-1,this._state=0}}},Jn=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Dp(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},Xl=[],Xie=class{constructor(){this._handlers=Object.create(null),this._active=Xl,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Xl}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Xl,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Xl,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",Dp(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=Xl,this._ident=0}},dc=new j5;dc.addParam(0);var VC=class{constructor(e){this._handler=e,this._data="",this._params=dc,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():dc,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Dp(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=dc,this._data="",this._hitLimit=!1,n));return this._params=dc,this._data="",this._hitLimit=!1,t}},Qie=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}},xr=160,Zie=function(){let e=new Qie(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(xr,0,2,0),e.add(xr,8,5,8),e.add(xr,6,0,6),e.add(xr,11,0,11),e.add(xr,13,13,13),e}(),Jie=class extends $e{constructor(e=Zie){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 j5,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(vt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Yie),this._dcsParser=this._register(new Xie),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:xr)],i>>4){case 2:for(let f=a+1;;++f){if(f>=t||(r=e[f])<32||r>126&&r<xr){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(r=e[f])<32||r>126&&r<xr){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(r=e[f])<32||r>126&&r<xr){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(r=e[f])<32||r>126&&r<xr){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<xr){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<xr){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}}},ese=/^([\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})$/,tse=/^[\da-f]+$/;function qC(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=ese.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),tse.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 vg(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 nse(e,t=16){let[n,r,i]=e;return`rgb:${vg(n,t)}/${vg(r,t)}/${vg(i,t)}`}var rse={"(":0,")":1,"*":2,"+":3,"-":1,".":2},cs=131072,KC=10;function GC(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 YC=5e3,XC=0,ise=class extends $e{constructor(e,t,n,r,i,s,o,a,l=new Jie){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 Sne,this._utf8Decoder=new kne,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=zt.clone(),this._eraseAttrDataInternal=zt.clone(),this._onRequestBell=this._register(new te),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new te),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new te),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new te),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new te),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new te),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new te),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new te),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new te),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new te),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new te),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new te),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new S_(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,u)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:u.toArray()})}),this._parser.setEscHandlerFallback(c=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(c)})}),this._parser.setExecuteHandlerFallback(c=>{this._logService.debug("Unknown EXECUTE code: ",{code:c})}),this._parser.setOscHandlerFallback((c,u,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:u,data:d})}),this._parser.setDcsHandlerFallback((c,u,d)=>{u==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:u,payload:d})}),this._parser.setPrintHandler((c,u,d)=>this.print(c,u,d)),this._parser.registerCsiHandler({final:"@"},c=>this.insertChars(c)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},c=>this.scrollLeft(c)),this._parser.registerCsiHandler({final:"A"},c=>this.cursorUp(c)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},c=>this.scrollRight(c)),this._parser.registerCsiHandler({final:"B"},c=>this.cursorDown(c)),this._parser.registerCsiHandler({final:"C"},c=>this.cursorForward(c)),this._parser.registerCsiHandler({final:"D"},c=>this.cursorBackward(c)),this._parser.registerCsiHandler({final:"E"},c=>this.cursorNextLine(c)),this._parser.registerCsiHandler({final:"F"},c=>this.cursorPrecedingLine(c)),this._parser.registerCsiHandler({final:"G"},c=>this.cursorCharAbsolute(c)),this._parser.registerCsiHandler({final:"H"},c=>this.cursorPosition(c)),this._parser.registerCsiHandler({final:"I"},c=>this.cursorForwardTab(c)),this._parser.registerCsiHandler({final:"J"},c=>this.eraseInDisplay(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},c=>this.eraseInDisplay(c,!0)),this._parser.registerCsiHandler({final:"K"},c=>this.eraseInLine(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},c=>this.eraseInLine(c,!0)),this._parser.registerCsiHandler({final:"L"},c=>this.insertLines(c)),this._parser.registerCsiHandler({final:"M"},c=>this.deleteLines(c)),this._parser.registerCsiHandler({final:"P"},c=>this.deleteChars(c)),this._parser.registerCsiHandler({final:"S"},c=>this.scrollUp(c)),this._parser.registerCsiHandler({final:"T"},c=>this.scrollDown(c)),this._parser.registerCsiHandler({final:"X"},c=>this.eraseChars(c)),this._parser.registerCsiHandler({final:"Z"},c=>this.cursorBackwardTab(c)),this._parser.registerCsiHandler({final:"`"},c=>this.charPosAbsolute(c)),this._parser.registerCsiHandler({final:"a"},c=>this.hPositionRelative(c)),this._parser.registerCsiHandler({final:"b"},c=>this.repeatPrecedingCharacter(c)),this._parser.registerCsiHandler({final:"c"},c=>this.sendDeviceAttributesPrimary(c)),this._parser.registerCsiHandler({prefix:">",final:"c"},c=>this.sendDeviceAttributesSecondary(c)),this._parser.registerCsiHandler({final:"d"},c=>this.linePosAbsolute(c)),this._parser.registerCsiHandler({final:"e"},c=>this.vPositionRelative(c)),this._parser.registerCsiHandler({final:"f"},c=>this.hVPosition(c)),this._parser.registerCsiHandler({final:"g"},c=>this.tabClear(c)),this._parser.registerCsiHandler({final:"h"},c=>this.setMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"h"},c=>this.setModePrivate(c)),this._parser.registerCsiHandler({final:"l"},c=>this.resetMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"l"},c=>this.resetModePrivate(c)),this._parser.registerCsiHandler({final:"m"},c=>this.charAttributes(c)),this._parser.registerCsiHandler({final:"n"},c=>this.deviceStatus(c)),this._parser.registerCsiHandler({prefix:"?",final:"n"},c=>this.deviceStatusPrivate(c)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},c=>this.softReset(c)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},c=>this.setCursorStyle(c)),this._parser.registerCsiHandler({final:"r"},c=>this.setScrollRegion(c)),this._parser.registerCsiHandler({final:"s"},c=>this.saveCursor(c)),this._parser.registerCsiHandler({final:"t"},c=>this.windowOptions(c)),this._parser.registerCsiHandler({final:"u"},c=>this.restoreCursor(c)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},c=>this.insertColumns(c)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},c=>this.deleteColumns(c)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},c=>this.selectProtected(c)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},c=>this.requestMode(c,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},c=>this.requestMode(c,!1)),this._parser.setExecuteHandler(V.BEL,()=>this.bell()),this._parser.setExecuteHandler(V.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(V.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(V.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(V.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(V.BS,()=>this.backspace()),this._parser.setExecuteHandler(V.HT,()=>this.tab()),this._parser.setExecuteHandler(V.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(V.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(hh.IND,()=>this.index()),this._parser.setExecuteHandler(hh.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(hh.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Jn(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new Jn(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new Jn(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new Jn(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new Jn(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new Jn(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new Jn(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new Jn(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new Jn(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new Jn(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new Jn(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new Jn(c=>this.restoreCursorColor(c))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let c in Zt)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 VC((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"),YC))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${YC} 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>cs&&(s=this._parseStack.position+cs)}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<cs&&(this._parseBuffer=new Uint32Array(Math.min(e.length,cs))),o||this._dirtyRowTracker.clearRange(),e.length>cs)for(let c=s;c<e.length;c+=cs){let u=c+cs<e.length?c+cs: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=go.extractWidth(m);let v=go.extractShouldJoin(m),w=v?go.extractWidth(f):0;if(f=m,o&&this._onA11yChar.fire(ms(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-w>a){if(l){let _=d,x=this._activeBuffer.x-w;for(this._activeBuffer.x=w,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),w>0&&d instanceof cc&&d.copyCellsFrom(_,x,0,w,!1);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-w;--x>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(c&&(d.insertCells(this._activeBuffer.x,i-w,this._activeBuffer.getNullCell(u)),d.getWidth(a-1)===2&&d.setCellFromCodepoint(a-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<a&&n-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>GC(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new VC(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Jn(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(s.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){var r;this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!((r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n))!=null&&r.getTrimmedLength()););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(zt));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=go.extractWidth(t),i=this._activeBuffer.x-r,s=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(s.length*n),a=0;for(let c=0;c<s.length;){let u=s.codePointAt(c)||0;o[a++]=u,c+=u>65535?2:1}let l=a;for(let c=1;c<n;++c)o.copyWithin(l,0,a),l+=a;return this.print(o,0,l),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(V.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(V.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(V.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(V.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(V.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,ao),this._charsetService.setgCharset(1,ao),this._charsetService.setgCharset(2,ao),this._charsetService.setgCharset(3,ao);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(v=>(v[v.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",v[v.SET=1]="SET",v[v.RESET=2]="RESET",v[v.PERMANENTLY_SET=3]="PERMANENTLY_SET",v[v.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:s}=this._coreMouseService,o=this._coreService,{buffers:a,cols:l}=this._bufferService,{active:c,alt:u}=a,d=this._optionsService.rawOptions,f=(v,w)=>(o.triggerDataEvent(`${V.ESC}[${t?"":"?"}${v};${w}$y`),!0),p=v=>v?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?l===80?2:l===132?1:0:0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i==="X10")):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i==="VT200")):m===1002?f(m,p(i==="DRAG")):m===1003?f(m,p(i==="ANY")):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(s==="SGR")):m===1015?f(m,4):m===1016?f(m,p(s==="SGR_PIXELS")):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(c===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=Lu.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,s=0;do{if(r[s+i]=e.params[t+s],e.hasSubParams(t+s)){let o=e.getSubParams(t+s),a=0;do r[1]===5&&(i=1),r[s+a+1+i]=o[a];while(++a<o.length&&a+s+1+i<r.length);break}if(r[1]===5&&s+i>=2||r[1]===2&&s+i>=5)break;r[1]&&(i=1)}while(++s+t<e.length&&s+i<r.length);for(let o=2;o<r.length;++o)r[o]===-1&&(r[o]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return s}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=zt.fg,e.bg=zt.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=16777216|n-90|8):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=16777216|n-100|8):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=zt.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=zt.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=zt.fg&16777215,r.bg&=-67108864,r.bg|=zt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${V.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${V.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${V.ESC}[?${t};${n}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=zt.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!GC(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${V.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>KC&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>KC&&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(QC(s))if(i==="?")t.push({type:0,index:s});else{let o=qC(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=qC(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]);QC(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,ao),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(rse[e[0]],Zt[e[1]]||ao),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=zt.clone(),this._eraseAttrDataInternal=zt.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Er;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=o=>(this._coreService.triggerDataEvent(`${V.ESC}${o}${V.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-(i.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},S_=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&&(XC=e,e=t,t=XC),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};S_=Mt([le(0,zn)],S_);function QC(e){return 0<=e&&e<256}var sse=5e7,ZC=12,ose=50,ase=class extends $e{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new te),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>sse)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>=ZC?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>=ZC)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>ose&&(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()}},k_=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)))}};k_=Mt([le(0,zn)],k_);var JC=!1,lse=class extends $e{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new rl),this._onBinary=this._register(new te),this.onBinary=this._onBinary.event,this._onData=this._register(new te),this.onData=this._onData.event,this._onLineFeed=this._register(new te),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new te),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new te),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new te),this._instantiationService=new Mie,this.optionsService=this._register(new Hie(e)),this._instantiationService.setService($n,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(x_)),this._instantiationService.setService(zn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(__)),this._instantiationService.setService(t5,this._logService),this.coreService=this._register(this._instantiationService.createInstance(y_)),this._instantiationService.setService(Go,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(b_)),this._instantiationService.setService(e5,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(go)),this._instantiationService.setService(Tne,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Kie),this._instantiationService.setService(Nne,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(k_),this._instantiationService.setService(n5,this._oscLinkService),this._inputHandler=this._register(new ise(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(mn.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(mn.forward(this._bufferService.onResize,this._onResize)),this._register(mn.forward(this.coreService.onData,this._onData)),this._register(mn.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new ase((t,n)=>this._inputHandler.parse(t,n))),this._register(mn.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new te),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!JC&&(this._logService.warn("writeSync is unreliable and will be removed soon."),JC=!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,L5),t=Math.max(t,D5),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(WC.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(WC(this._bufferService),!1))),this._windowsWrappingHeuristics.value=vt(()=>{for(let t of e)t.dispose()})}}},cse={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 use(e,t,n,r){var o;let i={type:0,cancel:!1,key:void 0},s=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?i.key=V.ESC+"OA":i.key=V.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?i.key=V.ESC+"OD":i.key=V.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?i.key=V.ESC+"OC":i.key=V.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?i.key=V.ESC+"OB":i.key=V.ESC+"[B");break;case 8:i.key=e.ctrlKey?"\b":V.DEL,e.altKey&&(i.key=V.ESC+i.key);break;case 9:if(e.shiftKey){i.key=V.ESC+"[Z";break}i.key=V.HT,i.cancel=!0;break;case 13:i.key=e.altKey?V.ESC+V.CR:V.CR,i.cancel=!0;break;case 27:i.key=V.ESC,e.altKey&&(i.key=V.ESC+V.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;s?i.key=V.ESC+"[1;"+(s+1)+"D":t?i.key=V.ESC+"OD":i.key=V.ESC+"[D";break;case 39:if(e.metaKey)break;s?i.key=V.ESC+"[1;"+(s+1)+"C":t?i.key=V.ESC+"OC":i.key=V.ESC+"[C";break;case 38:if(e.metaKey)break;s?i.key=V.ESC+"[1;"+(s+1)+"A":t?i.key=V.ESC+"OA":i.key=V.ESC+"[A";break;case 40:if(e.metaKey)break;s?i.key=V.ESC+"[1;"+(s+1)+"B":t?i.key=V.ESC+"OB":i.key=V.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=V.ESC+"[2~");break;case 46:s?i.key=V.ESC+"[3;"+(s+1)+"~":i.key=V.ESC+"[3~";break;case 36:s?i.key=V.ESC+"[1;"+(s+1)+"H":t?i.key=V.ESC+"OH":i.key=V.ESC+"[H";break;case 35:s?i.key=V.ESC+"[1;"+(s+1)+"F":t?i.key=V.ESC+"OF":i.key=V.ESC+"[F";break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=V.ESC+"[5;"+(s+1)+"~":i.key=V.ESC+"[5~";break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=V.ESC+"[6;"+(s+1)+"~":i.key=V.ESC+"[6~";break;case 112:s?i.key=V.ESC+"[1;"+(s+1)+"P":i.key=V.ESC+"OP";break;case 113:s?i.key=V.ESC+"[1;"+(s+1)+"Q":i.key=V.ESC+"OQ";break;case 114:s?i.key=V.ESC+"[1;"+(s+1)+"R":i.key=V.ESC+"OR";break;case 115:s?i.key=V.ESC+"[1;"+(s+1)+"S":i.key=V.ESC+"OS";break;case 116:s?i.key=V.ESC+"[15;"+(s+1)+"~":i.key=V.ESC+"[15~";break;case 117:s?i.key=V.ESC+"[17;"+(s+1)+"~":i.key=V.ESC+"[17~";break;case 118:s?i.key=V.ESC+"[18;"+(s+1)+"~":i.key=V.ESC+"[18~";break;case 119:s?i.key=V.ESC+"[19;"+(s+1)+"~":i.key=V.ESC+"[19~";break;case 120:s?i.key=V.ESC+"[20;"+(s+1)+"~":i.key=V.ESC+"[20~";break;case 121:s?i.key=V.ESC+"[21;"+(s+1)+"~":i.key=V.ESC+"[21~";break;case 122:s?i.key=V.ESC+"[23;"+(s+1)+"~":i.key=V.ESC+"[23~";break;case 123:s?i.key=V.ESC+"[24;"+(s+1)+"~":i.key=V.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=V.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=V.DEL:e.keyCode===219?i.key=V.ESC:e.keyCode===220?i.key=V.FS:e.keyCode===221&&(i.key=V.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let a=(o=cse[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(a)i.key=V.ESC+a;else if(e.keyCode>=65&&e.keyCode<=90){let l=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(l);e.shiftKey&&(c=c.toUpperCase()),i.key=V.ESC+c}else if(e.keyCode===32)i.key=V.ESC+(e.ctrlKey?V.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let l=e.code.slice(3,4);e.shiftKey||(l=l.toLowerCase()),i.key=V.ESC+l,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(i.key=V.US),e.key==="@"&&(i.key=V.NUL));break}return i}var jt=0,dse=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Sf,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Sf,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((i,s)=>this._getKey(i)-this._getKey(s)),t=0,n=0,r=new Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(jt=this._search(t),jt===-1)||this._getKey(this._array[jt])!==t)return!1;do if(this._array[jt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(jt),!0;while(++jt<this._array.length&&this._getKey(this._array[jt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((i,s)=>i-s),t=0,n=new Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(jt=this._search(e),!(jt<0||jt>=this._array.length)&&this._getKey(this._array[jt])===e))do yield this._array[jt];while(++jt<this._array.length&&this._getKey(this._array[jt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(jt=this._search(e),!(jt<0||jt>=this._array.length)&&this._getKey(this._array[jt])===e))do t(this._array[jt]);while(++jt<this._array.length&&this._getKey(this._array[jt])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},_g=0,e2=0,hse=class extends $e{constructor(){super(),this._decorations=new dse(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new te),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new te),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(vt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new fse(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=>{_g=i.options.x??0,e2=_g+(i.options.width??1),e>=_g&&e<e2&&(!n||(i.options.layer??"bottom")===n)&&r(i)})}},fse=class extends As{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new te),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new te),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=xt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=xt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},pse=1e3,mse=class{constructor(e,t=pse){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)}},t2=20,kf=class extends $e{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 mse(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(`
|
|
570
570
|
`))),this._register(this._terminal.onA11yTab(s=>this._handleTab(s))),this._register(this._terminal.onKey(s=>this._handleKey(s.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Ee(i,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(vt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<t2+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
@@ -591,4 +591,4 @@ Minimum version required to store current data is: `+s+`.
|
|
|
591
591
|
|
|
592
592
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
593
593
|
|
|
594
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return g.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Poe="DialogDescriptionWarning",Roe=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${f4(Poe).contentName}}.`;return g.useEffect(()=>{var s;const i=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Moe=e4,Aoe=r4,p4=i4,m4=s4,g4=a4,v4=c4,Loe=d4;const Doe=Moe,joe=Aoe,_4=g.forwardRef(({className:e,...t},n)=>h.jsx(p4,{ref:n,className:ne("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",e),...t}));_4.displayName=p4.displayName;const x4=g.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(joe,{children:[h.jsx(_4,{}),h.jsxs(m4,{ref:r,className:ne("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2","gap-4 rounded-lg border border-border bg-elevated p-6 shadow-lg",e),...n,children:[t,h.jsxs(Loe,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-accent",children:[h.jsx(qr,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));x4.displayName=m4.displayName;const y4=({className:e,...t})=>h.jsx("div",{className:ne("flex flex-col space-y-1.5 text-left",e),...t});y4.displayName="DialogHeader";const b4=g.forwardRef(({className:e,...t},n)=>h.jsx(g4,{ref:n,className:ne("text-lg font-semibold leading-none text-text-100",e),...t}));b4.displayName=g4.displayName;const Ooe=g.forwardRef(({className:e,...t},n)=>h.jsx(v4,{ref:n,className:ne("text-sm text-text-300",e),...t}));Ooe.displayName=v4.displayName;function Boe({persona:e,open:t,onClose:n,onDelete:r,embedded:i,onLoadPersonality:s,onSavePersonality:o,onLoadPersonalityLocal:a,onSavePersonalityLocal:l,hasPersonalityLocal:c=!1,onDirtyChange:u,initialPersonality:d,onShareCapability:f,readOnly:p=!1,larkBot:m}){const[v,w]=g.useState(!1),[_,x]=g.useState(!1),b=v||_,S=Ge.useRef(u);g.useEffect(()=>{S.current=u}),g.useEffect(()=>{var k;(k=S.current)==null||k.call(S,b)},[b]);const C=()=>{b&&!window.confirm("修改未保存,确定关闭?")||n()};return t?h.jsxs(h.Fragment,{children:[!i&&h.jsx("div",{className:"absolute inset-0 z-30 bg-black/30",onClick:C,"aria-hidden":"true"}),h.jsxs("aside",{className:i?"flex h-full w-full flex-col bg-bg-0":"absolute right-0 top-0 z-40 flex h-full w-[420px] flex-col bg-bg-0 border-l border-border shadow-xl","data-testid":"persona-settings-drawer",children:[h.jsxs("header",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h.jsx(aF,{className:"h-4 w-4 text-text-300"}),h.jsx("span",{className:"text-[13px] font-medium text-text-100 truncate",children:"Persona 设置"})]}),h.jsx("button",{type:"button",onClick:C,"aria-label":"关闭",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-text-100",children:h.jsx(qr,{className:"h-4 w-4"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-6 flex flex-col gap-4",children:[h.jsxs("header",{className:"flex items-start justify-between gap-3",children:[h.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h2",{className:"text-lg font-semibold text-text-100 truncate",children:e.label}),e.public?h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-bg-200 px-1.5 py-0.5 text-[10px] text-text-200",children:[h.jsx(N8,{className:"h-3 w-3"})," 公开"]}):h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-error-dim px-1.5 py-0.5 text-[10px] text-error",children:[h.jsx(C8,{className:"h-3 w-3"})," 已关闭"]})]}),h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate","data-testid":"persona-id-subtitle",children:e.personaId})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[f?h.jsxs("button",{type:"button",onClick:f,"aria-label":"分享给他人",title:"分享给他人",className:"inline-flex items-center gap-1 rounded-sm px-2 py-1.5 text-xs text-text-200 hover:bg-bg-200 hover:text-text-100",children:[h.jsx(Jx,{className:"h-3.5 w-3.5"}),"分享"]}):null,r?h.jsx("button",{type:"button",onClick:r,"aria-label":"删除 persona",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-error",children:h.jsx(ey,{className:"h-4 w-4"})}):null]})]}),h.jsx("hr",{className:"border-border"}),m?h.jsxs(h.Fragment,{children:[h.jsx(Foe,{...m}),h.jsx("hr",{className:"border-border"})]}):null,s?h.jsxs(h.Fragment,{children:[h.jsx(l2,{onLoad:s,...o&&!e.personalityManaged?{onSave:o}:{},onDirtyChange:w,initialPersonality:d,readOnly:p||!!e.personalityManaged,title:e.personalityManaged?"内置人格":"人格 (Personality)",hint:e.personalityManaged?p?"这个 persona 自带的人格,随 clawd 版本更新。":"这个 persona 自带的人格,随 clawd 版本更新——在这里改不会保留,要加自己的规则请写下面的「你的补充」。":void 0,testIdPrefix:"persona-personality"}),(e.personalityManaged||c)&&a?h.jsx(l2,{onLoad:a,...l?{onSave:l}:{},onDirtyChange:x,readOnly:p,title:p?"补充设定":"你的补充",hint:p?"这个 persona 的补充设定,由它的主人维护。与内置人格叠加生效。":"写入 <persona-dir>/.clawd/personality.local.md,不会被更新覆盖。与内置人格叠加生效,冲突时以你写的为准;对 owner 和访客会话都生效,要区分对象请在正文里写明。只对新启动的会话生效。",placeholder:"例:回答一律先给结论,再展开。",testIdPrefix:"persona-personality-local"}):null,h.jsx("hr",{className:"border-border"})]}):null,h.jsx(Hoe,{settings:e.sandboxSettings??null}),h.jsx("hr",{className:"border-border"}),h.jsx(Uoe,{skills:e.skills??[]}),h.jsx("hr",{className:"border-border"}),h.jsx(Woe,{plugins:e.plugins??[]})]})]})]}):null}function a2({qrUrl:e,busy:t,onCancel:n,title:r="扫码关联飞书 Bot",hint:i="用手机飞书扫码,按页面提示创建应用。确认后自动完成关联。"}){const[s,o]=g.useState(null);return g.useEffect(()=>{let a=!1;return Bu.toDataURL(e,{width:240,margin:1}).then(l=>{a||o(l)}).catch(()=>{a||o(null)}),()=>{a=!0}},[e]),h.jsx(Doe,{open:!0,onOpenChange:a=>a||n==null?void 0:n(),children:h.jsxs(x4,{className:"max-w-xs","data-testid":"lark-bot-qr-dialog",onInteractOutside:a=>a.preventDefault(),onEscapeKeyDown:a=>a.preventDefault(),children:[h.jsx(y4,{children:h.jsx(b4,{children:r})}),h.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s?h.jsx("img",{src:s,alt:"飞书扫码创建应用二维码",className:"h-60 w-60 rounded bg-white p-2","data-testid":"lark-bot-qr-img"}):h.jsx("div",{className:"flex h-60 w-60 items-center justify-center text-[12px] text-text-400",children:"二维码生成中…"}),h.jsx("span",{className:"text-center text-[12px] text-text-300",children:i}),n?h.jsx("button",{type:"button",disabled:t,onClick:n,className:"rounded border border-border px-3 py-1.5 text-[12px] text-text-300 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-cancel",children:"取消"}):null]})]})})}const zoe={expired:"二维码已过期,请重新扫码。",cancelled:"已取消。",access_denied:"你在飞书上取消了本次授权。",lark_protocol_error:"飞书返回了未预期的响应,请重试。",cloud_unreachable:"云端暂时不可达,请稍后重试。",internal_error:"关联失败。若飞书中已创建应用,可在开发者后台删除后重试,或改用手动绑定填入其凭证。"},$oe=new Set(["expired","access_denied","lark_protocol_error","cloud_unreachable","internal_error"]);function Foe({status:e,onProvision:t,onCancelProvision:n,onBindManual:r,onUnbind:i,onUpgrade:s}){const[o,a]=g.useState(!1),[l,c]=g.useState(null),[u,d]=g.useState(""),[f,p]=g.useState(""),[m,v]=g.useState(null),w=k=>{k&&(a(!0),c(null),k().catch(N=>c(N instanceof Error?N.message:String(N))).finally(()=>a(!1)))},_=()=>{v(null),w(t)},x=!o&&!!u&&!!f,b=()=>{!x||!r||w(()=>r({appId:u,appSecret:f}))},S=Iu(b),C=h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx(up,{className:"h-3.5 w-3.5 text-text-400","aria-hidden":!0}),h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"飞书 Bot"})]});return e?h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[C,e.state==="unbound"||e.state==="provisioning"?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"关联一个飞书 bot 后,这个 persona 就是它:拉进群后群成员 @ 它提问、或直接私聊它, 推理跑在你本机,回复自动发回去。"}),t?h.jsx("button",{type:"button",disabled:o||e.state==="provisioning",onClick:_,className:"self-start rounded border border-border bg-bg-200 px-3 py-1.5 text-[12px] font-medium text-text-100 hover:bg-bg-300 disabled:opacity-50","data-testid":"lark-bot-provision",children:e.state==="provisioning"?"等待扫码…":"扫码关联飞书 Bot"}):null,e.state==="unbound"&&e.errorReason&&!m?h.jsxs("div",{className:"flex flex-col gap-1.5 rounded border border-error bg-error-dim px-2 py-1.5","data-testid":"lark-bot-provision-error",children:[h.jsx("span",{className:"text-[11px] text-error",children:zoe[e.errorReason]}),h.jsxs("div",{className:"flex gap-1.5",children:[$oe.has(e.errorReason)&&t?h.jsx("button",{type:"button",disabled:o,onClick:_,className:"rounded border border-border px-2 py-1 text-[11px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-retry",children:"重新扫码"}):null,h.jsx("button",{type:"button",onClick:()=>v(e.errorReason??null),className:"rounded border border-border px-2 py-1 text-[11px] text-text-300 hover:bg-bg-200","data-testid":"lark-bot-provision-error-dismiss",children:"知道了"})]})]}):null,e.state==="provisioning"&&e.qrUrl?h.jsx(a2,{qrUrl:e.qrUrl,busy:o,onCancel:n?()=>w(n):void 0}):null,r&&e.state==="unbound"?h.jsxs("details",{"data-testid":"lark-bot-manual-details",children:[h.jsx("summary",{className:"cursor-pointer text-[11px] text-text-400 hover:text-text-300",children:"已有飞书应用?手动填入凭证"}),h.jsxs("div",{className:"mt-1.5 flex flex-col gap-1.5","data-testid":"lark-bot-manual-form",children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"先在飞书开放平台(open.feishu.cn)创建企业自建应用并启用机器人能力,再填入凭证:"}),h.jsx("input",{value:u,onChange:k=>d(k.target.value),...S,placeholder:"App ID(cli_ 开头)",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-appid"}),h.jsx("input",{value:f,onChange:k=>p(k.target.value),...S,type:"password",placeholder:"App Secret",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-secret"}),h.jsx("button",{type:"button",disabled:!x,onClick:b,className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-manual-submit",children:o?"绑定中…":"绑定"})]})]}):null]}):null,e.state==="bound"||e.state==="broken"?h.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.state==="bound"&&e.needsUpgrade?h.jsxs("div",{className:"flex flex-col gap-1.5 rounded border border-warning/30 bg-warning-dim px-2 py-1.5","data-testid":"lark-bot-upgrade-notice",children:[h.jsx("span",{className:"text-[11px] text-warning",children:"这个 bot 的权限配置有更新,扫码重新授权后生效。在此之前,新增能力对它不起作用。"}),s?h.jsx("button",{type:"button",disabled:o,onClick:()=>w(s),className:"self-start rounded border border-warning/30 bg-warning/10 px-2 py-1 text-[11px] text-warning hover:bg-warning/20 disabled:opacity-50","data-testid":"lark-bot-upgrade",children:"更新授权"}):null]}):null,e.state==="bound"&&e.upgradeQrUrl?h.jsx(a2,{qrUrl:e.upgradeQrUrl,busy:o,onCancel:n?()=>w(n):void 0,title:"扫码更新授权",hint:"用手机飞书扫码,确认页会列出将要添加的权限。期间 bot 照常服务,不会中断。"}):null,e.state==="broken"?h.jsxs("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-broken",children:["Bot 凭证失效:",e.brokenReason??"未知原因","。请解绑后重新填入有效凭证绑定。"]}):null,h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-200",children:[h.jsx("span",{className:"font-medium text-text-100",children:e.botName??"未命名 bot"}),e.appId?h.jsx("span",{className:"text-[11px] text-text-400",children:e.appId}):null]}),h.jsx("span",{className:"text-[11px] text-text-400",children:"把 bot 拉进任意飞书群,群成员 @ 它即可提问。"}),e.groups.length>0?h.jsx("ul",{className:"flex flex-col gap-0.5","data-testid":"lark-bot-groups",children:e.groups.map(k=>h.jsxs("li",{className:"text-[11px] text-text-300 truncate",children:["· ",k.chatName??k.chatId]},k.chatId))}):h.jsx("span",{className:"text-[11px] text-text-400","data-testid":"lark-bot-groups-empty",children:"还没有服务中的群。"}),i?h.jsx("button",{type:"button",disabled:o,onClick:()=>w(i),className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-error hover:bg-error-dim disabled:opacity-50","data-testid":"lark-bot-unbind",children:"解绑"}):null]}):null,l?h.jsx("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-error",children:l}):null]}):h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[C,h.jsx("span",{className:"text-[11px] text-text-400",children:"状态加载中…"})]})}function Hoe({settings:e}){var t,n,r,i,s,o,a,l,c,u,d,f,p;return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-sandbox-setting-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Sandbox Setting"}),h.jsx("span",{className:"text-[11px] text-text-400",children:"约束此 persona 的沙箱权限(只读,需通过文件修改)。"})]}),e==null?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-sandbox-setting-empty",children:"暂无 sandbox 配置"}):h.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md border border-border bg-bg-100 px-3 py-2",children:[h.jsx(zd,{label:"权限默认模式",value:((t=e.permissions)==null?void 0:t.defaultMode)??"—"}),h.jsx(zd,{label:"沙箱启用",value:Tg((n=e.sandbox)==null?void 0:n.enabled)}),h.jsx(zd,{label:"沙箱内自动放行 Bash",value:Tg((r=e.sandbox)==null?void 0:r.autoAllowBashIfSandboxed)}),h.jsx(zd,{label:"允许非沙箱命令",value:Tg((i=e.sandbox)==null?void 0:i.allowUnsandboxedCommands)}),h.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border pt-1.5",children:[h.jsx(Ql,{label:"沙箱外命令",paths:(s=e.sandbox)==null?void 0:s.excludedCommands}),h.jsx(Ql,{label:"允许读取",paths:(a=(o=e.sandbox)==null?void 0:o.filesystem)==null?void 0:a.allowRead}),h.jsx(Ql,{label:"拒绝读取",paths:(c=(l=e.sandbox)==null?void 0:l.filesystem)==null?void 0:c.denyRead}),h.jsx(Ql,{label:"允许写入",paths:(d=(u=e.sandbox)==null?void 0:u.filesystem)==null?void 0:d.allowWrite}),h.jsx(Ql,{label:"拒绝写入",paths:(p=(f=e.sandbox)==null?void 0:f.filesystem)==null?void 0:p.denyWrite})]})]})]})}function Tg(e){return e===!0?"是":e===!1?"否":"—"}function zd({label:e,value:t}){return h.jsxs("div",{className:"flex items-center justify-between gap-3 text-[12px]",children:[h.jsx("span",{className:"text-text-300",children:e}),h.jsx("span",{className:"font-mono text-text-100",children:t})]})}function Ql({label:e,paths:t}){const n=!t||t.length===0;return h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[11px] text-text-300",children:e}),n?h.jsx("span",{className:"text-[11px] text-text-400",children:"—"}):h.jsx("div",{className:"flex flex-wrap gap-1",children:t.map((r,i)=>h.jsx("span",{className:"rounded-sm border border-border bg-bg-0 px-1.5 py-0.5 font-mono text-[11px] text-text-200",children:r},`${e}-${i}-${r}`))})]})}function Uoe({skills:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-skills-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Persona Skills"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 私有 skills(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/skills/"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-skills-empty",children:"暂无 skills"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsxs("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-skill-row",children:[h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.name}),t.description?h.jsx("span",{className:"text-[12px] text-text-300",children:t.description}):h.jsx("span",{className:"text-[11px] text-text-400 italic",children:"无描述"})]},t.name))})]})}function Woe({plugins:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-plugins-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Enabled Plugins"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 已启用的插件(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/settings.json"})," ","的 ",h.jsx("code",{className:"font-mono",children:"enabledPlugins"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-plugins-empty",children:"暂无启用插件"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsx("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-plugin-row",children:h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.id})},t.id))})]})}function l2({onLoad:e,onSave:t,onDirtyChange:n,initialPersonality:r,readOnly:i=!1,title:s,hint:o,placeholder:a,testIdPrefix:l}){const c=r!==void 0,[u,d]=g.useState(c),[f,p]=g.useState(c?r:""),[m,v]=g.useState(c?r:""),[w,_]=g.useState(null),[x,b]=g.useState(!1),[S,C]=g.useState(null),k=Ge.useRef(e),N=Ge.useRef(t),T=Ge.useRef(n);Ge.useEffect(()=>{k.current=e,N.current=t,T.current=n});const z=Ge.useCallback(()=>{d(!1),_(null),k.current().then(M=>{p(M),v(M),d(!0)}).catch(M=>{_(M instanceof Error?M.message:String(M))})},[]);Ge.useEffect(()=>{c||z()},[c,z]);const P=!i&&u&&m!==f;Ge.useEffect(()=>{i||T.current(P)},[P,i]);const B=()=>{N.current&&(b(!0),C(null),N.current(m).then(()=>{p(m),b(!1)}).catch(M=>{C(M instanceof Error?M.message:String(M)),b(!1)}))},A=()=>{v(f),C(null)},R=Iu(()=>{!P||x||B()},()=>{!P||x||A()});return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":`${l}-section`,children:[h.jsx("span",{className:"text-[12px] font-medium text-text-200",children:s}),w?h.jsxs("div",{"data-testid":`${l}-load-error`,className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error flex items-center justify-between gap-2",children:[h.jsxs("span",{children:["加载失败:",w]}),h.jsx("button",{type:"button",onClick:z,className:"rounded-sm border border-error px-2 py-0.5 text-[11px] hover:bg-error/10",children:"重试"})]}):null,S?h.jsxs("div",{"data-testid":`${l}-save-error`,className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error",children:["保存失败:",S]}):null,h.jsx("textarea",{"data-testid":`${l}-textarea`,value:m,onChange:M=>v(M.target.value),...R,readOnly:i,disabled:!i&&(!u||x),placeholder:u?a??"":"加载中…",rows:8,className:"min-h-[8rem] max-h-[18rem] resize-y rounded-md border border-border bg-bg-100 px-2 py-1.5 font-mono text-[11px] text-text-100 disabled:opacity-60"}),o?h.jsx("p",{className:"text-[10px] text-text-400",children:o}):i?null:h.jsx("p",{className:"text-[10px] text-text-400",children:"写入人格文件。修改只对新启动的会话生效。"}),u&&P?h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:A,disabled:x,className:"rounded-sm border border-border px-2 py-1 text-[12px] text-text-200 hover:bg-bg-200 disabled:opacity-60",children:"放弃"}),h.jsx("button",{type:"button",onClick:B,disabled:x,"data-testid":`${l}-save-btn`,className:"rounded-sm bg-accent-dim px-2 py-1 text-[12px] text-text-100 hover:opacity-90 disabled:opacity-60",children:x?"保存中…":"保存"})]}):null]})}const Voe={state:"unbound",groups:[]};function qoe(e,t){const[n,r]=g.useState(null);g.useEffect(()=>{if(!e)return;let c=!1;r(null);const u=async()=>{try{const p=await e.request("larkBot:status",{personaId:t});c||r(p)}catch{c||r(Voe)}};u();const d=e.on("larkBot:state",p=>{const m=p;if(m.personaId!==t)return;const{personaId:v,...w}=m;r(w)}),f=e.on("daemon:connected",()=>{u()});return()=>{c=!0,d(),f()}},[e,t]);const i=g.useCallback(async()=>{e&&await e.request("larkBot:provision",{personaId:t})},[e,t]),s=g.useCallback(async()=>{e&&await e.request("larkBot:provisionCancel",{personaId:t})},[e,t]),o=g.useCallback(async c=>{e&&await e.request("larkBot:bindManual",{personaId:t,...c})},[e,t]),a=g.useCallback(async()=>{e&&await e.request("larkBot:upgrade",{personaId:t})},[e,t]),l=g.useCallback(async()=>{e&&await e.request("larkBot:unbind",{personaId:t})},[e,t]);return{status:n,provision:i,cancelProvision:s,bindManual:o,unbind:l,upgrade:a}}function Koe(e,t="owner"){var k;const{persona:n}=vI(e),r=k$(e),i=C$(),s=E$(),{httpBaseUrl:o}=cp(),a=Yi(),l=qoe(t==="guest"?null:a,e),{capabilities:c}=g1((n==null?void 0:n.tool)??"claude"),u=g.useMemo(()=>!(n!=null&&n.public)||!o||/^https?:\/\/(127\.0\.0\.1|localhost|0\.0\.0\.0|\[?::1\]?)([:/]|$)/i.test(o)?null:`${o}/s/${e}`,[n==null?void 0:n.public,o,e]),d=g.useCallback((N,T)=>{i(e,T).catch(z=>{Me("persona",`${N} failed`,z)})},[i,e]),f=g.useCallback(N=>d("togglePublic",{public:N}),[d]),p=g.useCallback(async N=>{await i(e,{codexSandbox:{network:N}}),await r.refresh()},[i,e,r]),m=g.useCallback(N=>d("changeTool",{tool:N}),[d]),v=g.useCallback(N=>d("changeModel",{model:N}),[d]),w=g.useCallback(N=>d("changeEffort",{effort:N}),[d]),_=g.useCallback(()=>!n||!confirm(`删除 persona "${n.label}"?`)?!1:(s(e).catch(N=>{Me("persona","delete failed",N)}),!0),[n,s,e]),x=g.useCallback(async()=>r.loaded?r.personality:(await r.refresh()).personality,[r]),b=g.useCallback(async N=>{await i(e,{personality:N}),await r.refresh()},[i,e,r]),S=g.useCallback(async()=>r.loaded?r.personalityLocal:(await r.refresh()).personalityLocal,[r]),C=g.useCallback(async N=>{await i(e,{personalityLocal:N}),await r.refresh()},[i,e,r]);return{persona:n,detail:r,models:(c==null?void 0:c.models)??[],configSchema:(c==null?void 0:c.configSchema)??[],larkBot:l,guestShareUrl:u,changeTool:m,changeModel:v,changeEffort:w,togglePublic:f,guestNetwork:((k=r.codexSandbox)==null?void 0:k.network)??!1,toggleGuestNetwork:p,remove:_,loadPersonality:x,savePersonality:b,loadPersonalityLocal:S,savePersonalityLocal:C}}function Goe({personaId:e,open:t,onClose:n,api:r,embedded:i,onDirtyChange:s,onShareCapability:o,viewerRole:a="owner"}){const l=Koe(e,a),{persona:c,detail:u}=l,d=g.useCallback(()=>{l.remove()&&n()},[l,n]);if(!c)return null;const f=a==="guest";return h.jsx(Boe,{embedded:i,persona:{...c,skills:u.skills,plugins:u.plugins,sandboxSettings:u.sandboxSettings,personalityManaged:u.personalityManaged},open:t,onClose:n,onLoadPersonality:l.loadPersonality,onLoadPersonalityLocal:l.loadPersonalityLocal,hasPersonalityLocal:u.personalityLocal!=="",onDirtyChange:s,readOnly:f,...f?{}:{onTogglePublic:l.togglePublic,guestShareUrl:l.guestShareUrl,onChangeTool:l.changeTool,onChangeModel:l.changeModel,onChangeEffort:l.changeEffort,models:l.models,configSchema:l.configSchema,onDelete:d,onSavePersonality:l.savePersonality,onSavePersonalityLocal:l.savePersonalityLocal,larkBot:{status:l.larkBot.status,onProvision:l.larkBot.provision,onCancelProvision:l.larkBot.cancelProvision,onBindManual:l.larkBot.bindManual,onUnbind:l.larkBot.unbind,onUpgrade:l.larkBot.upgrade},...o?{onShareCapability:o}:{}}})}const Yoe={resolve:()=>{}},Xoe=g.createContext(Yoe);function Qoe(){return g.useContext(Xoe)}const Zoe={...Fs,h1:({node:e,...t})=>h.jsx("h1",{...t,className:"mt-4 mb-3 text-[18px] font-semibold leading-tight text-text-100"}),h2:({node:e,...t})=>h.jsx("h2",{...t,className:"mt-4 mb-2 text-[16px] font-semibold leading-tight text-text-100"}),h3:({node:e,...t})=>h.jsx("h3",{...t,className:"mt-3 mb-2 text-[14px] font-semibold leading-tight text-text-100"}),h4:({node:e,...t})=>h.jsx("h4",{...t,className:"mt-3 mb-1 text-[13px] font-semibold text-text-100"}),h5:({node:e,...t})=>h.jsx("h5",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-100"}),h6:({node:e,...t})=>h.jsx("h6",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-300"}),p:({node:e,...t})=>h.jsx("p",{...t,className:"my-2 leading-relaxed"}),ul:({node:e,...t})=>h.jsx("ul",{...t,className:"my-2 list-disc space-y-1 pl-5"}),ol:({node:e,...t})=>h.jsx("ol",{...t,className:"my-2 list-decimal space-y-1 pl-5"}),li:({node:e,...t})=>h.jsx("li",{...t,className:"leading-relaxed"}),blockquote:({node:e,...t})=>h.jsx("blockquote",{...t,className:"my-2 border-l-2 border-border pl-3 italic text-text-300"}),code:({node:e,className:t,children:n,...r})=>t?h.jsx("code",{...r,className:`${t} font-mono text-[12px]`,children:n}):h.jsx("code",{...r,className:"rounded bg-bg-50 px-1 py-0.5 font-mono text-[12px] text-text-100",children:n}),pre:({node:e,...t})=>h.jsx("pre",{...t,className:"my-2 overflow-auto rounded border border-border bg-bg-0 p-3 text-[12px] font-mono text-text-100"}),hr:({node:e,...t})=>h.jsx("hr",{...t,className:"my-3 border-border"}),table:({node:e,...t})=>h.jsx("table",{...t,className:"my-2 w-full border-collapse text-[12px]"}),thead:({node:e,...t})=>h.jsx("thead",{...t,className:"bg-bg-50"}),th:({node:e,...t})=>h.jsx("th",{...t,className:"border border-border px-2 py-1 text-left font-semibold"}),td:({node:e,...t})=>h.jsx("td",{...t,className:"border border-border px-2 py-1"}),strong:({node:e,...t})=>h.jsx("strong",{...t,className:"font-semibold text-text-100"}),em:({node:e,...t})=>h.jsx("em",{...t,className:"italic"})};function Joe(e){const t=e.split("/");return t[t.length-1]||e}function w4({relPath:e,loadMarkdown:t,headerRight:n,showTitleBar:r=!1}){const[i,s]=g.useState(null),[o,a]=g.useState(null),[l,c]=g.useState(!1);return g.useEffect(()=>{if(!e)return;let u=!1;return c(!0),a(null),s(null),(async()=>{try{const d=await t(e);if(u)return;s(d)}catch(d){if(u)return;a(d.message||String(d))}finally{u||c(!1)}})(),()=>{u=!0}},[e,t]),h.jsxs("div",{className:"flex flex-col h-full",children:[r&&e?h.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[h.jsx("div",{"data-testid":"md-preview-title",className:"truncate text-[13px] font-medium text-text-100",title:e,children:Joe(e)}),h.jsx("div",{className:"flex items-center gap-1",children:n})]}):null,h.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 text-[13px] text-text-100",children:l?h.jsx("div",{"data-testid":"md-preview-loading",className:"text-text-400",children:"Loading…"}):o?h.jsx("div",{"data-testid":"md-preview-error",className:"text-destructive whitespace-pre-wrap",children:o}):i!==null?h.jsx("div",{"data-testid":"md-preview-content",className:"max-w-none",children:h.jsx(tl,{remarkPlugins:[nl],components:Zoe,children:i})}):null})]})}function eae({open:e,onOpenChange:t,relPath:n,loadMarkdown:r,onShare:i}){return e?h.jsx("div",{"data-testid":"md-preview-drawer",className:`${s1} z-50 flex w-1/2 max-w-[900px] flex-col border-l border-border bg-elevated shadow-2xl`,children:h.jsx(w4,{relPath:n,loadMarkdown:r,showTitleBar:!0,headerRight:h.jsxs(h.Fragment,{children:[i?h.jsx("button",{type:"button","data-testid":"md-preview-share","aria-label":"Share rendered preview link",onClick:i,className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(D8,{className:"h-4 w-4"})}):null,h.jsx("button",{type:"button","aria-label":"Close preview",onClick:()=>t(!1),className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(qr,{className:"h-4 w-4"})})]})})}):null}const c2=4;function tae({children:e,onHeightChange:t}){const n=g.useRef(null),[r,i]=g.useState(0);return g.useEffect(()=>{const s=n.current;if(!s)return;const o=()=>i(s.offsetHeight>0?s.offsetHeight+c2*2:0);if(o(),typeof ResizeObserver>"u")return;const a=new ResizeObserver(o);return a.observe(s),()=>a.disconnect()},[]),g.useEffect(()=>{t==null||t(r)},[r,t]),h.jsx("div",{"data-testid":"chat-floating-dock","data-height":r,className:"relative z-20 h-0 shrink-0",children:h.jsx("div",{ref:n,className:"absolute left-4 right-4 flex flex-col items-end gap-1",style:{bottom:c2},children:e})})}const nae=250;function rae(e){if(!e||!Number.isFinite(e))return null;const t=e/1e3;if(t<60)return`${t.toFixed(0)}s`;const n=Math.floor(t/60);return`${n}m${Math.round(t-n*60).toString().padStart(2,"0")}s`}function iae({agents:e}){var a,l,c;const[t,n]=g.useState(!1);if(e.length===0)return null;const r=e.length===1?e[0]:null,i=r?r.description:`${e.length} 个后台任务`,s=r?rae((l=(a=r.progress)==null?void 0:a.stats)==null?void 0:l.durationMs):null,o=r?(c=r.progress)==null?void 0:c.lastToolName:null;return h.jsxs("div",{"data-testid":"running-agents-chip","data-agent-count":e.length,className:"relative",children:[t?h.jsx("div",{"data-testid":"running-agents-popover",className:"absolute bottom-full right-0 z-20 mb-1 w-[min(560px,80vw)]",children:h.jsx("div",{className:"min-w-0 overflow-y-auto rounded-lg border border-bg-200/60 bg-bg-100 px-2 py-1 shadow-lg",style:{maxHeight:nae},children:e.map(u=>h.jsx(FA,{expandable:!1,description:u.description,input:u.input,output:u.output,...u.error!==void 0?{error:u.error}:{},pending:u.pending,notifications:u.notifications,...u.toolResultExtra?{toolResultExtra:u.toolResultExtra}:{},...u.progress?{progress:u.progress}:{}},u.toolUseId))})}):null,h.jsxs("button",{type:"button","data-testid":"running-agents-chip-toggle","aria-expanded":t,onClick:()=>n(u=>!u),className:ne("flex max-w-[min(560px,80vw)] min-w-0 items-center gap-2 rounded-full","border border-bg-200/60 bg-bg-100/95 px-3 py-1 text-[12px] shadow-md backdrop-blur","hover:bg-bg-200/95 transition-colors"),children:[h.jsx(cr,{className:"w-3 h-3 shrink-0 animate-spin text-blue-400"}),h.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-text-200",children:i}),s?h.jsx("span",{className:"shrink-0 tabular-nums text-text-400",children:s}):null,o?h.jsxs("span",{className:"shrink-0 font-mono tabular-nums text-blue-400",children:["now:",o]}):null,h.jsx(yI,{className:ne("w-3.5 h-3.5 shrink-0 text-text-400 transition-transform",t&&"rotate-180")})]})]})}const sae={closeTrailing:!1},oae={closeTrailing:!0};function aae(e){return e?sae:oae}function lae({session:e,api:t,onPromoteQuickAsk:n}){const r=_M(e.sessionId);return h.jsx(S4,{state:r,extras:{session:e,api:t,...n?{onPromoteQuickAsk:n}:{}}})}function cae({headerMeta:e,connState:t,liveWorktreeRoot:n,onOpenConfig:r,variant:i="full",ephemeral:s,onPromote:o,hideHeader:a=!1,flatProcess:l=!1,lines:c,pendingPermissions:u,procAlive:d,rewindableUserMessageIds:f,onPermissionRespond:p,onPermissionInterrupt:m,onRewind:v,onFork:w,onQuickAsk:_,topSlot:x,realtimeQuestionAnswers:b,onSubmitQuestion:S,onCancelQuestion:C,liveQuestionToolUseIds:k,api:N,cwd:T,tool:z,cloudVolume:P,sessionKey:B,onSend:A,awaitingUser:R,queued:M,onDequeue:D,onAbort:$,onNewSession:F,onClearSession:j,configSlot:O,chatRootRef:E,chatBodyRef:H,drawers:q,xtermSlot:L,fileSharingScope:re,onShareFile:se,onOpenInTab:K,onPreviewMarkdown:me,onOpenFilePath:Re,dispatchOrigin:ce}){const[Le,Oe]=g.useState(0),Ae=g.useMemo(()=>i==="full"?Vq(bM(c)):[],[c,i]),_e=g.useMemo(()=>new Set(Ae.map(Qe=>Qe.toolUseId)),[Ae]);return h.jsx(Zee,{children:h.jsxs("div",{ref:E,"data-cc-chat-root":"",className:"flex flex-col h-full bg-bg-100",children:[a?null:h.jsx(ene,{meta:e,...z?{tool:z}:{},...P?{cloudVolume:P}:{},connState:t,variant:i,...n!==void 0?{liveWorktreeRoot:n}:{},...i==="full"&&r?{onOpenConfig:r}:{},...i==="quickask"?{ephemeral:s??!1,...o?{onPromote:o}:{}}:{}}),h.jsx("div",{ref:H,"data-testid":"chat-body",className:"flex-1 overflow-y-auto min-h-0",style:{overflowAnchor:"none",paddingBottom:Le},children:h.jsx(UA,{lines:c,...p?{onPermissionRespond:p}:{},...m&&d?{onPermissionInterrupt:m}:{},topSlot:x,...v?{onRewind:v}:{},rewindableUserMessageIds:f,...w?{onFork:w}:{},..._?{onQuickAsk:_}:{},realtimeQuestionAnswers:b,onSubmitQuestion:S,...C?{onCancelQuestion:C}:{},liveQuestionToolUseIds:k,...re?{fileSharingScope:re}:{},...se?{onShareFile:se}:{},...K?{onOpenInTab:K}:{},...me?{onPreviewMarkdown:me}:{},...Re?{onOpenFilePath:Re}:{},...ce?{dispatchOrigin:ce}:{},...i==="full"&&!l?{turnCollapse:aae(d)}:{},dockedAgentToolUseIds:_e})}),L,h.jsx(tae,{onHeightChange:Oe,children:h.jsx(iae,{agents:Ae})}),e.larkChatName?h.jsx("div",{className:"mx-3 mb-3 rounded-lg border border-border bg-bg-200 px-3 py-2 text-[12px] text-text-400","data-testid":"lark-readonly-notice",children:e.larkChatType==="p2p"?`此会话由与「${e.larkChatName}」的飞书私聊驱动——对方消息触发,这里仅供观察。`:`此会话由飞书群「${e.larkChatName}」驱动——群成员 @ bot 提问触发,这里仅供观察。`}):h.jsx(Zte,{meta:e,...N?{api:N}:{},cwd:T,...z?{tool:z}:{},sessionKey:B,onSend:A,awaitingUser:R,...M?{queued:M}:{},...D?{onDequeue:D}:{},...$?{onAbort:$}:{},...F?{onNewSession:F}:{},...j?{onClearSession:j}:{},...O?{configSlot:O}:{}}),q]})})}function S4({state:e,extras:t,onQuickAskInternal:n,onPreviewMdInternal:r}){const{session:i,api:s,liveGitBranch:o,liveWorktreeRoot:a,cloudVolume:l,onNewSession:c,onTurnEnd:u,onOpenConfig:d,onFork:f,onQuickAsk:p,viewerRole:m,onPromoteQuickAsk:v,configSlot:w,hideHeader:_,flatProcess:x}=t,{capabilities:b}=g1(i.tool||"claude"),S=(b==null?void 0:b.features)??hI(i.tool),[C,k]=g.useState(null),[N,T]=g.useState(null),z=cp(),P=!!s&&z.actionsLevel==="owner"&&S.fileSharing,B=vI(i.ownerPersonaId??null).persona,A=(B==null?void 0:B.label)??null,R=!!A&&!!i.ownerPersonaId,M=Qoe(),D=g.useMemo(()=>({resolve:(ee,we)=>M.resolve(ee,we,i.sessionId),...M.onOpenSession?{onOpenSession:M.onOpenSession}:{}}),[M,i.sessionId]),$=g.useCallback((ee,we)=>{k({kind:ee,text:we}),setTimeout(()=>{k(ke=>(ke==null?void 0:ke.text)===we?null:ke)},2e3)},[]),F=Yi(),j=e$(),O=fM(i.sessionId,i.toolSessionId),{events:E,pendingQuestions:H,clearQuestion:q,markQuestionSubmitted:L,status:re}=O,se=e.historyLoading,K=vM(re);g.useEffect(()=>{Me("chat-panel","sessionStatus",{sessionId:i.sessionId,sessionStatus:re,procAlive:K})},[re,K,i.sessionId]);const me=e.lines,Re=e.pendingPermissions,ce=Re[0]??null,Le=g.useMemo(()=>Uq(E),[E]),[Oe,Ae]=g.useState(null),[_e,Qe]=g.useState(()=>new Set);$q(s,i.sessionId,i.toolSessionId,S.observe);const kt=g.useRef(i.sessionId);g.useEffect(()=>{if(kt.current=i.sessionId,!S.rewind){Ae(null);return}let ee=!1;return Ae(null),(async()=>{try{const we=await s.sessionRewindableMessageIds(i.sessionId);if(ee)return;Ae(new Set(we.userMessageIds))}catch{ee||Ae(null)}})(),()=>{ee=!0}},[s,i.sessionId,S.rewind]);const tt=g.useCallback(()=>{const ee=i.sessionId;s.sessionRewindableMessageIds(ee).then(we=>{kt.current===ee&&Ae(new Set(we.userMessageIds))}).catch(()=>{})},[s,i.sessionId]),At=g.useMemo(()=>{if(Oe!==null){const Ze=new Set(Oe);for(const Gr of _e)Ze.delete(Gr);return Ze}const ee=new Set(["Edit","Write","MultiEdit","NotebookEdit"]),we=new Set;let ke=null;for(const Ze of me)Ze.kind==="user-text"?ke=Ze.uuid??null:ke&&Ze.kind==="tool-call"&&ee.has(Ze.tool)&&!_e.has(ke)&&we.add(ke);return we},[me,_e,Oe]),Jt=g.useRef(u);Jt.current=u,Fq(i.sessionId,i.toolSessionId,()=>{Et(null),Qe(new Set)});const nt=gne({sessionStatus:re}),Ct=g.useRef(null);g.useEffect(()=>{var ke;const ee=Ct.current,we=(ee==null?void 0:ee.sid)===i.sessionId;we&&ee.phase===nt||(Ct.current={sid:i.sessionId,phase:nt},Me("session-phase",nt,{sid:i.sessionId,phase:nt,prev:we?ee.phase:null,desc:mne[nt]}),we&&ee.phase==="turn-running"&&nt!=="turn-running"&&((ke=Jt.current)==null||ke.call(Jt),tt()))},[nt,i.sessionId,tt]);const qe=g.useCallback(async()=>{const ee=await s.sessionInterrupt(i.sessionId).catch(()=>{});return(ee==null?void 0:ee.queued)??[]},[s,i.sessionId]),[ot,Et]=g.useState(null),_n=g.useCallback(ee=>{Et(ee)},[]),[Tn,U]=g.useState(!1),J=g.useCallback(()=>{s.sessionStop(i.sessionId).catch(()=>{}),U(!1)},[s,i.sessionId]);g.useCallback(ee=>{s.pinSession(i.sessionId,ee).catch(we=>{Me("chat-panel","pinSession failed",{err:we==null?void 0:we.message})})},[s,i.sessionId]);const xe=v?"quickask":"full",{container:Ie,onCollapse:Fe,hostExtras:Nt}=ane(),en=g.useRef(0),tn=g.useRef(null);g.useEffect(()=>{const ee=we=>{if(we.key!=="Escape")return;if(!K){en.current=0;return}if(we.isComposing)return;const Ze=we.target;if(Ze&&Ze.closest("[data-cc-chat-root]")!==tn.current)return;const Gr=Date.now();Gr-en.current<2e3?(en.current=0,U(!0)):(en.current=Gr,qe())};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[qe,K]);const nn=g.useRef(null),oe=g.useRef(!0),ye=g.useRef(void 0),rt=g.useRef(0),mt=g.useRef(0),fr=g.useRef(void 0);g.useEffect(()=>{T(null)},[i.sessionId]),g.useEffect(()=>{const ee=nn.current;if(!ee)return;const we=150,ke=Ze=>{Date.now()<mt.current&&(Ze.preventDefault(),mt.current=Date.now()+we)};return ee.addEventListener("wheel",ke,{passive:!1}),()=>ee.removeEventListener("wheel",ke)},[]),g.useEffect(()=>{const ee=nn.current;if(!ee)return;const we=32,ke=()=>{const Ze=ee.scrollHeight-ee.scrollTop-ee.clientHeight;oe.current=Ze<=we};return ee.addEventListener("scroll",ke,{passive:!0}),()=>ee.removeEventListener("scroll",ke)},[]),g.useLayoutEffect(()=>{var $u;const ee=nn.current;if(!ee)return;const we=fr.current!==i.sessionId;we&&(fr.current=i.sessionId,oe.current=!0,ye.current=void 0,rt.current=0,mt.current=0);const ke=ye.current,Ze=($u=me[0])==null?void 0:$u.seq;ye.current=Ze,!we&&ke!==void 0&&Ze!==void 0&&Ze<ke?(ee.scrollTop=ee.scrollHeight-rt.current,mt.current=Date.now()+200):oe.current&&(ee.scrollTop=ee.scrollHeight),rt.current=ee.scrollHeight-ee.scrollTop},[me,ce==null?void 0:ce.requestId,i.sessionId]);const ae=g.useMemo(()=>{const ee={};for(const[we,ke]of Object.entries(H))ke.submittedAnswers&&(ee[we]=ke.submittedAnswers);return ee},[H]),Je=g.useMemo(()=>new Set(Object.keys(H)),[H]),hn=g.useCallback(async(ee,we)=>{try{await s.answerQuestion({sessionId:i.sessionId,toolUseId:ee,answers:we}),L(ee,we)}catch{}},[s,i.sessionId,L]),Ys=g.useCallback(async ee=>{try{await s.cancelQuestion({sessionId:i.sessionId,toolUseId:ee}),q(ee)}catch{}},[s,i.sessionId,q]),Nl=g.useCallback(async(ee,we)=>{var ke;if(ce)try{await((ke=e.respondPermission)==null?void 0:ke.call(e,ce.requestId,ee?"allow":"deny"))}catch{}},[e,ce]),Yo=g.useCallback(async()=>{const ee=i.sessionId;try{await s.sessionStop(ee)}catch{}e.clearSession?await e.clearSession():await s.sessionNew(ee)},[e,s,i.sessionId]),ts=g.useMemo(()=>e.historyError?h.jsxs("div",{className:"flex justify-center py-2 text-[12px] text-text-400","data-testid":"history-error",children:["历史未加载完(",e.historyError,");切走再切回可重试"]}):se&&me.length===0?h.jsx("div",{className:"flex justify-center py-4","data-testid":"history-loading",children:h.jsx(cr,{className:"w-4 h-4 text-text-400 animate-spin"})}):null,[se,me.length,e.historyError]),Xs=e.meta,Tl=h.jsxs(h.Fragment,{children:[i.toolSessionId&&S.subagents?h.jsx(lne,{api:s,cwd:i.cwd,toolSessionId:i.toolSessionId,toolKind:i.tool??"claude"}):null,ot&&S.rewind?h.jsx(une,{open:!0,onOpenChange:ee=>{ee||Et(null)},api:s,sessionId:i.sessionId,userMessageId:ot,lines:me,procAlive:K,onNoChanges:ee=>{Qe(we=>{if(we.has(ee))return we;const ke=new Set(we);return ke.add(ee),ke})}}):null,Tn?h.jsx(uae,{onConfirm:J,onCancel:()=>U(!1)}):null]}),Xo={kind:"session",sessionId:i.sessionId},bi=g.useCallback(async ee=>{if(s)try{await XS(s,F,i.sessionId,ee)}catch(we){const ke=we.message;Me("chat-panel","open-in-tab failed",{err:ke}),$("err",`Open in tab 失败:${ke}`)}},[s,F,i.sessionId,$]),[ns,Il]=g.useState(!1),[Pl,Vt]=g.useState(null),Qs=g.useCallback(ee=>{if(r){r(ee);return}Vt(ee),Il(!0)},[r]),Wp=g.useCallback(ee=>{if(!s)return;const we=async()=>{try{await s.attachmentGroupAdd(i.sessionId,ee)}catch(Ze){Me("chat-panel","file-link groupAdd skipped",{err:Ze.message})}},ke=Ze=>{const Gr=Ze.message;Me("chat-panel","file-link open failed",{err:Gr}),$("err",`打开文件失败:${Gr}`)};if(Lp(ee)){we().then(()=>Qs(ee),ke);return}XS(s,F,i.sessionId,ee,60,we).catch(ke)},[s,F,i.sessionId,Qs,$]),Lt=g.useCallback(async ee=>{if(!s)throw new Error("daemon api not ready");const we=await zy(s,F,i.sessionId,ee,60),ke=await fetch(we);if(!ke.ok)throw new Error(`fetch ${ke.status} ${ke.statusText}`);return await ke.text()},[s,F,i.sessionId]),Dt=g.useCallback(async(ee,we)=>{if(s)try{const{url:ke}=await s.attachmentSignUrl({sessionId:i.sessionId,relPath:ee,...we?{view:we}:{}}),Ze=await Tq(ke);$(Ze?"ok":"err",Ze?"分享链接已复制到剪贴板":"复制失败:请手动复制")}catch(ke){const Ze=ke.message;Me("chat-panel","share-file failed",{err:Ze}),$("err",`生成分享链接失败:${Ze}`)}},[s,i.sessionId,$]),In=g.useCallback(()=>T(null),[]),pr=N==="files"&&P&&s?{title:"Edited Files",onBack:In,content:h.jsx(Pse,{api:s,scope:Xo,sessionId:i.sessionId,onShareFile:Dt,onOpenInTab:bi,onPreviewMarkdown:Qs})}:N==="cron"?{title:`定时任务${Le.length?` (${Le.length})`:""}`,onBack:In,content:h.jsx("div",{className:"p-3",children:h.jsx(pne,{jobs:Le})})}:N==="persona"&&R&&s&&i.ownerPersonaId?{title:`Persona · ${A??""}`,onBack:In,content:h.jsx(Goe,{personaId:i.ownerPersonaId,open:!0,onClose:In,api:s,embedded:!0,...m?{viewerRole:m}:{}},i.ownerPersonaId)}:null,Zs=xe==="full"?h.jsx(sne,{session:i,meta:Xs,...o!==void 0?{liveGitBranch:o}:{},...a!==void 0?{liveWorktreeRoot:a}:{},...R?{personaName:A}:{},...R?{onOpenPersona:()=>T("persona")}:{},...P?{onOpenFiles:()=>T("files")}:{},cronActiveCount:Le.length,onCronClick:()=>T("cron"),onForceStop:()=>U(!0),...m?{viewerRole:m}:{},...b!=null&&b.toolSessionIdLabel?{toolSessionIdLabel:b.toolSessionIdLabel}:{},drill:pr,...Fe?{onCollapse:Fe}:{},...Nt?{title:Nt.title,leadingEntries:Nt.leadingEntries}:{}}):null;return h.jsxs(h.Fragment,{children:[Ie&&Zs?hl.createPortal(Zs,Ie):null,h.jsx(cae,{headerMeta:Xs,connState:e.connState,...a!==void 0?{liveWorktreeRoot:a}:{},...d?{onOpenConfig:d}:{},variant:xe,..._?{hideHeader:_}:{},...x?{flatProcess:x}:{},...xe==="quickask"?{ephemeral:i.ephemeral!==!1,onPromote:()=>void(v==null?void 0:v(i.sessionId))}:{},lines:me,pendingPermissions:Re,procAlive:K,rewindableUserMessageIds:At,onPermissionRespond:Nl,onPermissionInterrupt:qe,onRewind:S.rewind?_n:void 0,...f&&S.fork?{onFork:f}:{},...n&&S.fork?{onQuickAsk:n}:p&&S.fork?{onQuickAsk:p}:{},topSlot:ts,realtimeQuestionAnswers:ae,onSubmitQuestion:hn,onCancelQuestion:Ys,liveQuestionToolUseIds:Je,api:s,cwd:i.cwd,...i.tool?{tool:i.tool}:{},...l?{cloudVolume:l}:{},sessionKey:i.sessionId,onSend:e.sendText,queued:e.queued,onDequeue:e.dequeue,awaitingUser:Re.length>0||Object.values(H).some(ee=>!ee.submittedAnswers),onAbort:qe,...c?{onNewSession:c}:{},onClearSession:Yo,...w?{configSlot:w}:{},chatRootRef:tn,chatBodyRef:nn,drawers:Tl,xtermSlot:j==="tui"&&K&&S.tui?h.jsx(Ise,{sessionId:i.sessionId,client:F},i.sessionId):null,fileSharingScope:Xo,...s?{onShareFile:Dt}:{},...s?{onOpenInTab:bi}:{},...s?{onPreviewMarkdown:Qs}:{},...s?{onOpenFilePath:Wp}:{},dispatchOrigin:D}),s?h.jsx(eae,{open:ns,onOpenChange:Il,relPath:Pl,loadMarkdown:Lt,onShare:Pl?()=>void Dt(Pl,"md-rendered"):void 0}):null,C?h.jsx("div",{"data-testid":"share-toast",role:"status","aria-live":"polite",className:C.kind==="ok"?"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-emerald-500/40 bg-emerald-500/10 px-3 py-2 text-[12px] text-emerald-700 shadow-md dark:text-emerald-300":"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px] text-destructive shadow-md",children:C.text}):null]})}function uae({onConfirm:e,onCancel:t}){return h.jsx("div",{role:"dialog","aria-modal":"true","data-testid":"force-stop-confirm",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:t,children:h.jsxs("div",{className:"max-w-sm w-[92%] rounded-lg border border-red-400/40 bg-bg-0 p-4 shadow-xl",onClick:n=>n.stopPropagation(),children:[h.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[h.jsx(tf,{className:"w-5 h-5 text-red-500 shrink-0 mt-0.5"}),h.jsx("div",{className:"text-[14px] text-text-100",children:"强制停止会话进程?会丢失 initialize / 预热缓存,下一次发送需要重新 spawn。"})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:t,className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),h.jsx("button",{type:"button","data-testid":"force-stop-confirm-ok",onClick:e,className:"h-8 px-3 rounded-md bg-red-500 text-white text-[12px] font-medium hover:bg-red-600 cursor-pointer",children:"强制停止"})]})]})})}function dae(e){return e.split("/").pop()||e}function hae({state:e,api:t,onSwitchTab:n,onCloseQuickAsk:r,onCloseMd:i,loadMarkdown:s,quickAskSession:o,onPromoteQuickAsk:a}){if(!xM(e))return null;const l=[];e.quickAsk&&l.push({id:"quick-ask",label:"问一下",title:"问一下",icon:h.jsx(m0,{className:"w-3.5 h-3.5"})});for(const c of e.mds)l.push({id:{kind:"md",relPath:c},label:dae(c),title:c,icon:h.jsx(mi,{className:"w-3.5 h-3.5"})});return h.jsxs("div",{className:"flex flex-col h-full bg-bg-50/60 border-l border-border-strong",children:[h.jsx(uf,{delayDuration:200,skipDelayDuration:100,children:h.jsx("div",{className:["flex items-stretch h-9 border-b border-text-100/10 shrink-0 overflow-x-auto","[scrollbar-width:none] [-ms-overflow-style:none]","[&::-webkit-scrollbar]:hidden"].join(" "),role:"tablist",children:l.map(c=>{const u=zq(e.active,c.id),d=c.id==="quick-ask"?"quick-ask":`md:${c.id.relPath}`;return h.jsxs(Cp,{children:[h.jsx(Ep,{asChild:!0,children:h.jsxs("div",{role:"tab","aria-selected":u,"data-tab-title":c.title,onClick:()=>n(c.id),className:["group relative flex items-center gap-2 px-3 h-full cursor-pointer select-none","text-[12px] max-w-[180px] shrink-0 transition-colors duration-100",u?"text-text-100":"text-text-400 hover:text-text-100 hover:bg-text-100/[0.04]"].join(" "),children:[c.icon,h.jsx("span",{className:"truncate",children:c.label}),h.jsx("button",{type:"button","aria-label":`关闭 ${c.label}`,className:["ml-1 rounded p-0.5 shrink-0 transition-opacity","hover:bg-text-100/10",u?"opacity-70 hover:opacity-100":"opacity-0 group-hover:opacity-70"].join(" "),onClick:f=>{f.stopPropagation(),c.id==="quick-ask"?r():i(c.id.relPath)},children:h.jsx(qr,{className:"w-3 h-3"})}),u?h.jsx("span",{"aria-hidden":"true",className:"absolute left-2 right-2 -bottom-px h-[2px] rounded-full bg-accent"}):null]})}),h.jsx(Pu,{side:"bottom",align:"start",className:"max-w-sm break-all",children:c.title})]},d)})})}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[e.quickAsk&&o?h.jsx("div",{className:"absolute inset-0",style:{display:e.active==="quick-ask"?"block":"none"},children:h.jsx(lae,{session:o,api:t,...a?{onPromoteQuickAsk:a}:{}})}):null,e.mds.map(c=>{const u=e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===c;return h.jsx("div",{className:"absolute inset-0",style:{display:u?"block":"none"},children:h.jsx(w4,{relPath:c,loadMarkdown:s,showTitleBar:!1})},`md-body:${c}`)})]})]})}function fae(e){const t=e instanceof Error?e.message:String(e);return t.length>200?`${t.slice(0,200)}…`:t}function pae({state:e,extras:t}){const{api:n,session:r}=t,i=Yi(),[s,o]=g.useState(Mq()),[a,l]=g.useState(null),c=r.ownerPersonaId!==qT,u=g.useRef(s);u.current=s;const d=g.useRef(!1),f=g.useCallback(async T=>{const z=u.current.quickAsk;l(null);let P;try{P=await kq(n,r,T)}catch(B){Me("quick-ask","fork failed",B),d.current||l(fae(B));return}if(!P){d.current||l("这条会话还没准备好(没有可派生的对话记录),稍后再试");return}if(d.current){n.sessionDelete(P.sessionId).catch(()=>{});return}Cd(z)&&n.sessionDelete(z.sessionId).catch(()=>{}),o(B=>Aq(B,{sessionId:P.sessionId}))},[n,r]),p=g.useCallback(async T=>{const z=u.current.quickAsk,P=(z==null?void 0:z.sessionId)===T;try{await Cq(n,{sessionId:T,stillEphemeral:P&&Cd(z)})&&o(A=>jq(A))}catch(B){Me("quick-ask","promote failed",B)}},[n]),m=g.useCallback(T=>{o(z=>Lq(z,T))},[]),v=g.useCallback(T=>{o(z=>Bq(z,T))},[]),w=g.useCallback(()=>{const T=u.current.quickAsk;Cd(T)&&n.sessionDelete(T.sessionId).catch(()=>{}),o(z=>Dq(z))},[n]),_=g.useCallback(T=>{o(z=>Oq(z,T))},[]);g.useEffect(()=>()=>{d.current=!0;const T=u.current.quickAsk;Cd(T)&&n.sessionDelete(T.sessionId).catch(()=>{})},[]);const x=Ui("sessions")??[],b=s.quickAsk?x.find(T=>T.sessionId===s.quickAsk.sessionId)??{sessionId:s.quickAsk.sessionId,cwd:r.cwd,tool:r.tool}:null,S=g.useCallback(async T=>{const z=await zy(n,i,r.sessionId,T,60),P=await fetch(z);if(!P.ok)throw new Error(`fetch ${P.status} ${P.statusText}`);return P.text()},[n,i,r.sessionId]),C=h.jsx(S4,{state:e,extras:t,onQuickAskInternal:f,onPreviewMdInternal:m}),{initialSize:k,setSize:N}=Rq("chat-panel-right-slot-width",480);return h.jsxs(Oy,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:[h.jsx(df,{id:"chat",minSize:"400px",children:h.jsxs("div",{className:"relative flex flex-col min-w-0 min-h-0 h-full",children:[C,a?h.jsxs("div",{"data-testid":"quick-ask-error",className:"absolute bottom-24 left-1/2 z-10 -translate-x-1/2 max-w-[90%] rounded-md border border-border bg-bg-200 px-3 py-2 text-[12px] text-text-300 shadow-lg",children:[h.jsxs("span",{className:"mr-2",children:["问一下没能打开:",a]}),h.jsx("button",{type:"button","aria-label":"关闭提示",onClick:()=>l(null),className:"text-text-400 hover:text-text-200 cursor-pointer",children:"✕"})]}):null]})}),xM(s)?h.jsxs(h.Fragment,{children:[h.jsx(hM,{className:"w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),h.jsx(df,{id:"right-slot",defaultSize:`${k}px`,minSize:"360px",maxSize:"800px",onResize:T=>N(T.inPixels),children:h.jsx(hae,{state:s,api:n,onSwitchTab:v,onCloseQuickAsk:w,onCloseMd:_,loadMarkdown:S,quickAskSession:b,...c?{onPromoteQuickAsk:p}:{}})})]}):null]})}function mae({extras:e}){const t=_M(e.session.sessionId);return h.jsx(pae,{state:t,extras:e})}function gae(e,t,n){const r=e?t.find(s=>s.id===e):void 0;if(r!=null&&r.efforts&&r.efforts.length>0)return{options:r.efforts,defaultValue:r.defaultEffort??""};const i=n.find(s=>s.name==="effort");return{options:(i==null?void 0:i.options)??[],defaultValue:typeof(i==null?void 0:i.default)=="string"?i.default:""}}function vae(e,t,n){var l;if(!t)return((l=(e??[]).find(c=>c.id===""))==null?void 0:l.label)??"未指定";const r=t.toLowerCase(),i=[["opus","Opus"],["fable","Fable"],["sonnet","Sonnet"],["haiku","Haiku"]];for(const[c,u]of i){if(!r.includes(c))continue;const d=r.match(new RegExp(`${c}-(\\d+)(?:-(\\d+))?`));return d?d[2]?`${u} ${d[1]}.${d[2]}`:`${u} ${d[1]}`:u}const s=e??[],o=s.find(c=>c.id===t);if(o)return o.label;const a=s.find(c=>c.id&&t.toLowerCase().includes(c.id.toLowerCase()));return a?a.label:t}function _ae(e,t){var m,v,w,_;const{models:n,modes:r,configSchema:i}=t,s=e.resolvedModel??e.model,o=gae(s,n,i),a=o.options,l=a.some(x=>x.value===e.effort)?e.effort:o.defaultValue,c=e.effort===""&&e.resolvedEffort?((m=a.find(x=>x.value===e.resolvedEffort))==null?void 0:m.label)??e.resolvedEffort:((v=a.find(x=>x.value===l))==null?void 0:v.label)??null,u=((w=i.find(x=>x.name==="permissionMode"))==null?void 0:w.default)??"",d=r.some(x=>x.id===e.permissionMode)?e.permissionMode:u,p=d===u?null:((_=r.find(x=>x.id===d))==null?void 0:_.label)??null;return{modelLabel:vae(n,s),effortOptions:a,effortValue:l,effortLabel:c,modeValue:d,modeLabel:p,modeTone:p===null?null:d==="bypassPermissions"?"danger":"info"}}function xae(e){let t;return e.map(n=>{const r=n.group&&n.group!==t?n.group:null;return n.group&&(t=n.group),{...n,groupHeading:r}})}function yae({models:e=[],modes:t=[],configSchema:n=[],model:r,resolvedModel:i,resolvedEffort:s,effort:o,permissionMode:a,onPatch:l}){var p;const c=_ae({model:r,resolvedModel:i,resolvedEffort:s,effort:o,permissionMode:a},{models:e,modes:t,configSchema:n}),u=i??r,d=e.map(m=>{const v=m.id===""&&i?`${m.description?`${m.description};`:""}当前:${i}`:m.description;return{value:m.id,label:m.label,...v?{description:v}:{},...m.group?{group:m.group}:{}}}),f=t.map(m=>({value:m.id,label:m.label,...m.description?{description:m.description}:{}}));return h.jsxs(AR,{children:[h.jsx(LR,{asChild:!0,children:h.jsxs("button",{type:"button","data-testid":"session-config-chip",title:"Model / reasoning effort / permission mode",className:"inline-flex items-center gap-1 h-7 px-2.5 rounded-full text-[11px] text-text-400 transition-colors outline-none cursor-pointer hover:bg-text-100/5 hover:text-text-200 data-[state=open]:bg-text-100/5",children:[h.jsx("span",{className:"truncate max-w-[120px]","data-testid":"session-config-chip-model",children:u||c.modelLabel}),c.effortLabel?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-500",children:"·"}),h.jsx("span",{className:"truncate max-w-[80px]","data-testid":"session-config-chip-effort",children:c.effortLabel})]}):null,c.modeLabel?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-500",children:"·"}),h.jsx("span",{"data-testid":"session-config-chip-mode","data-tone":c.modeTone,className:ne("font-semibold",c.modeTone==="danger"?"text-red-400":"text-blue-400"),children:c.modeLabel})]}):null]})}),h.jsxs(Cy,{side:"top",align:"end",className:"w-[230px]","data-testid":"session-config-menu",children:[h.jsx(Ig,{testid:"session-config-model",label:"Model",current:r,currentLabel:c.modelLabel,options:d,onSelect:m=>l({model:m})}),h.jsx(Ig,{testid:"session-config-effort",label:"Reasoning effort",current:c.effortValue,currentLabel:c.effortLabel??"—",options:c.effortOptions,onSelect:m=>l({effort:m})}),f.length>0?h.jsx(Ig,{testid:"session-config-mode",label:"Permission mode",current:c.modeValue,currentLabel:((p=t.find(m=>m.id===c.modeValue))==null?void 0:p.label)??"—",currentTone:c.modeTone,options:f,onSelect:m=>l({permissionMode:m})}):null]})]})}function Ig({testid:e,label:t,current:n,currentLabel:r,currentTone:i,options:s,onSelect:o}){const a=s.length===0;return h.jsxs(NW,{children:[h.jsxs(DR,{"data-testid":e,disabled:a,className:"gap-2 text-[12px]",children:[h.jsx("span",{className:"flex-1 text-text-200",children:t}),h.jsx("span",{className:ne("truncate max-w-[100px]",i==="danger"?"text-red-400 font-semibold":i==="info"?"text-blue-400 font-semibold":"text-text-400"),children:r}),h.jsx(Bn,{className:"w-3.5 h-3.5 shrink-0 text-text-500"})]}),h.jsx(jR,{className:"w-[220px] max-h-[320px] overflow-y-auto",children:xae(s).map((l,c)=>{const u=l.value===n;return h.jsxs(Ge.Fragment,{children:[l.groupHeading?h.jsxs(h.Fragment,{children:[c>0?h.jsx(Ey,{}):null,h.jsx(OR,{"data-testid":`${e}-group`,children:l.groupHeading})]}):null,h.jsxs(co,{"data-testid":`${e}-option-${l.value||"default"}`,onSelect:()=>o(l.value),className:"items-start gap-2",children:[h.jsxs("span",{className:"flex-1 min-w-0",children:[h.jsx("span",{className:ne("block text-[12px]",u?"text-text-100 font-medium":"text-text-300"),children:l.label}),l.description?h.jsx("span",{className:"block text-[11px] text-text-400 mt-0.5",children:l.description}):null]}),u?h.jsx(bu,{className:"w-3.5 h-3.5 shrink-0 text-accent mt-0.5"}):null]})]},l.value||"default")})})]})}function bae(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitBranch(t);i(l.branch??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{branch:r,loading:s,refresh:()=>void a()}}function wae(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitRoot(t);i(l.gitRoot??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{worktreeRoot:r,loading:s,refresh:()=>void a()}}const Sae=5e3;function kae(e,t,n=0){const[r,i]=g.useState(null);return g.useEffect(()=>{if(!t){i(null);return}let s=!1;const o=async()=>{try{const l=await e.cloudVolumeGet();s||i(l.volume??null)}catch{s||i(null)}},a=n>0?setTimeout(()=>void o(),Sae):null;return a||o(),()=>{s=!0,a&&clearTimeout(a)}},[e,t,n]),{volume:r}}const Cae=90;function Eae(e){return e.sizeBytes>0?Math.min(100,Math.max(0,Math.round(e.usedBytes/e.sizeBytes*100))):0}function u2(e){const t=e/1073741824;return t>=.1?`${t.toFixed(1)} GB`:`${Math.max(1,Math.round(e/1024**2))} MB`}function Nae({volume:e}){if(!e)return null;const t=Eae(e),n=t>=Cae?"warn":"ok",r=new Date(e.measuredAt).toLocaleString(),i=n==="ok"?"上一次任务结束时量的。":"盘快满了:在会话里说「清理一下云盘」,persona 会分析工作区里哪些能删、列给你确认后清掉。";return h.jsxs("span",{"data-testid":"chat-header-cloud-volume","data-tone":n,title:`云盘已用 ${u2(e.usedBytes)} / ${u2(e.sizeBytes)}(${r})。${i}`,className:ne("ml-1.5 inline-flex items-center gap-1.5 px-1.5 py-0.5 rounded text-[11px] tabular-nums",n==="ok"&&"bg-text-100/10 text-text-400",n==="warn"&&"bg-warning-dim text-warning"),children:[h.jsx("span",{className:"relative inline-block w-8 h-1 rounded-full bg-current/20 overflow-hidden","aria-hidden":!0,children:h.jsx("span",{className:"absolute inset-y-0 left-0 rounded-full bg-current",style:{width:`${t}%`}})}),"云盘 ",t,"%"]})}function Tae({api:e,session:t,focused:n,totalPanes:r,onFocus:i,onClose:s,onNewSession:o,onOpenConfig:a,onFork:l,onQuickAsk:c,className:u,viewerRole:d="owner",hideHeader:f}){const{capabilities:p}=g1(t.tool),[m,v]=g.useState(0),{branch:w}=bae(e,t.cwd,m),{worktreeRoot:_}=wae(e,t.cwd,m),x=Bz(t.tool),{volume:b}=kae(e,x,m),S=r>1,C=k=>{e.sessionUpdate(t.sessionId,k).catch(N=>{console.error("[session-config] session:update failed",t.sessionId,N)})};return h.jsxs("div",{className:`group/pane relative flex-1 ${u??"flex"} flex-row min-w-0 min-h-0 overflow-hidden ${S?`rounded-md border transition-colors ${n?"border-accent ring-1 ring-accent":"border-border"}`:""}`,onMouseDown:i,"data-testid":`session-pane-${t.sessionId}`,children:[h.jsx(Oy,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:h.jsx(df,{id:"chat",minSize:"400px",children:h.jsx("div",{className:"flex flex-col min-w-0 min-h-0 h-full",children:h.jsx(Iae,{api:e,session:t,liveGitBranch:w,liveWorktreeRoot:_,...x&&b?{cloudVolume:h.jsx(Nae,{volume:b})}:{},onNewSession:o,onTurnEnd:()=>v(k=>k+1),onOpenConfig:a,onFork:l,onQuickAsk:c,viewerRole:d,hideHeader:f,configSlot:p?h.jsx(yae,{models:p.models,modes:p.permissionModes,configSchema:p.configSchema,model:t.model??"",...t.resolvedModel?{resolvedModel:t.resolvedModel}:{},...t.resolvedEffort?{resolvedEffort:t.resolvedEffort}:{},effort:t.effort??"",permissionMode:t.permissionMode??"",onPatch:C}):null})})})}),S&&h.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),s()},className:"absolute top-1.5 right-1.5 z-10 p-1 rounded-md bg-bg-100/80 backdrop-blur-sm border border-border opacity-0 group-hover/pane:opacity-100 transition-opacity text-text-400 hover:text-text-100 hover:bg-bg-200","aria-label":"close pane","data-testid":`session-pane-close-${t.sessionId}`,children:h.jsx(qr,{className:"w-3.5 h-3.5"})})]})}function Iae({api:e,session:t,liveGitBranch:n,liveWorktreeRoot:r,cloudVolume:i,onNewSession:s,onTurnEnd:o,onOpenConfig:a,onFork:l,onQuickAsk:c,viewerRole:u,configSlot:d,hideHeader:f}){return h.jsx(mae,{extras:{session:t,api:e,...n!==void 0?{liveGitBranch:n}:{},...r!==void 0?{liveWorktreeRoot:r}:{},...i!==void 0?{cloudVolume:i}:{},onNewSession:s,onTurnEnd:o,onOpenConfig:a,...l?{onFork:p=>{l(p)}}:{},...c?{onQuickAsk:p=>{c(p)}}:{},...u?{viewerRole:u}:{},...d?{configSlot:d}:{},...f?{hideHeader:f}:{}}})}function Pae({personas:e,sessions:t,api:n,selfPrincipalId:r,selectedPersonaId:i,selectedSessionId:s,selectedSession:o,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,onCloseSession:f}){return h.jsxs("div",{className:"flex h-screen min-h-0 bg-bg-50","data-testid":"guest-share-page",children:[h.jsx("aside",{className:"w-[280px] shrink-0 overflow-y-auto border-r border-border bg-bg-50",children:h.jsx(mV,{personas:e,sessions:t,activePersonaId:i,activeSessionId:s,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,showCopyResume:!1,treatSessionsAsRoots:!0,...r?{ownerPrincipalId:r}:{},isPersonaExpanded:()=>!0})}),h.jsx("main",{className:"flex-1 min-w-0 min-h-0 flex",children:o?h.jsx(Tae,{api:n,session:o,focused:!0,totalPanes:1,onFocus:()=>{},onClose:f,onNewSession:()=>{},onOpenConfig:()=>{},viewerRole:"guest"}):h.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-xs text-text-400","data-testid":"guest-share-empty",children:"选择左侧 persona 开始对话"})})]})}function Rae(){const e=Yi(),t=g.useMemo(()=>new Gx(e),[e]),n=w$(e),{sessions:r,refresh:i}=S$(n),{personas:s}=gI(),o=I$(),a=g.useMemo(()=>{const S=window.location.pathname.match(/^\/s\/([^/]+)/);return S?decodeURIComponent(S[1]):null},[]),l=g.useMemo(()=>r.filter(S=>!S.ephemeral&&S.larkChatId==null),[r]),c=g.useMemo(()=>a?s.filter(S=>S.personaId===a):s,[s,a]),[u,d]=g.useState(null),[f,p]=g.useState(null),[m,v]=g.useState(null);g.useEffect(()=>{let S=!1;return e.request("whoami",{}).then(C=>{S||d(C.capability.id)}).catch(()=>{}),()=>{S=!0}},[e]),g.useEffect(()=>{a&&p(a)},[a]);const w=g.useCallback(async(S,C)=>{const k=await t.sessionCreate({ownerPersonaId:S,...C.trim()?{label:C.trim()}:{}});await i(),p(S),v(k.sessionId)},[t,i]),_=g.useCallback(async S=>{await t.sessionDelete(S),await i(),v(C=>C===S?null:C)},[t,i]),x=g.useCallback(async(S,C)=>{await t.sessionUpdate(S,{label:C.label}),await i()},[t,i]),b=g.useMemo(()=>l.find(S=>S.sessionId===m)??null,[l,m]);return h.jsx(Yx.Provider,{value:o,children:h.jsx(Pae,{personas:c,sessions:l,api:t,selfPrincipalId:u,selectedPersonaId:f,selectedSessionId:m,selectedSession:b,onSelectPersona:p,onSelectSession:v,onCreateSession:(S,C)=>void w(S,C),onDeleteSession:S=>void _(S),onEditSession:(S,C)=>void x(S,C),onCloseSession:()=>v(null)})})}const d2="https://app.ttcadvisory.com";function Mae({onAuthed:e}){const[t,n]=g.useState(!1),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>()=>{s.current&&window.removeEventListener("message",s.current)},[]);const o=g.useCallback(()=>{s.current&&(window.removeEventListener("message",s.current),s.current=null),n(!0),i(null);const a=window.location.origin,l=`${d2}/auth/authorize?callback_url=${encodeURIComponent(a)}&auto=1`,c=async d=>{if(d.origin!==d2)return;const f=d.data;if((f==null?void 0:f.type)==="AUTH_CANCEL"){u(),n(!1);return}if(!((f==null?void 0:f.type)!=="AUTH_SUCCESS"||!f.token)){u();try{const p=await fetch(`${window.location.origin}/share/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ttcToken:f.token})});if(!p.ok){const v=await p.json().catch(()=>({}));throw new Error(v.code??`exchange failed (${p.status})`)}const m=await p.json();if(!m.visitorToken)throw new Error("no visitorToken in response");e(m.visitorToken)}catch(p){i(p instanceof Error?p.message:String(p)),n(!1)}}},u=()=>{window.removeEventListener("message",c),s.current=null};s.current=d=>void c(d),window.addEventListener("message",s.current),window.open(l,"ttc-login","width=480,height=640")},[e]);return h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 font-sans text-text-100","data-testid":"guest-login",children:h.jsxs("div",{className:"flex w-full max-w-xs flex-col gap-3 rounded-lg border border-border bg-bg-100 px-5 py-6",children:[h.jsx("h1",{className:"text-base font-semibold",children:"登录后进入分享"}),h.jsx("p",{className:"text-[11px] leading-snug text-text-400",children:"使用飞书账号登录,即可在浏览器里与分享给你的 persona 交互,无需安装。"}),r?h.jsxs("p",{className:"text-[11px] leading-snug text-error","data-testid":"guest-login-error",children:["登录失败:",r]}):null,h.jsx("button",{type:"button",disabled:t,onClick:()=>o(),"data-testid":"guest-login-button",className:"w-full rounded border border-border bg-bg-50 px-2 py-1.5 text-xs text-text-200 transition-colors hover:bg-text-100/5 hover:text-text-100 disabled:opacity-50",children:t?"请在弹窗中完成授权…":"飞书登录"})]})})}const P_="clawd-visitor:token";function Aae(e,t){const r=`${e.protocol==="https:"?"wss:":"ws:"}//${e.host}`;return t!=null&&t.devPath?`${r}${t.devPath}`:r}function Lae(){return{async getUrl(e){const t=localStorage.getItem(P_);if(!t)throw new Error("NO_VISITOR_TOKEN");const n=Aae(window.location,{});return await aI(e).upsert({id:"guest",name:"访客",mode:"remote",url:n,token:t}),{url:n}}}}function Dae(e){const t=n=>{document.documentElement.classList.toggle("dark",n==="dark")};return t(e.theme.mode),e.onThemeChange(n=>t(n.mode))}function jae(){const e=Yi(),t=g.useMemo(()=>b$(e),[e]);return h.jsx(n$,{cache:t.cache,children:h.jsx(s$,{children:h.jsx(Rae,{})})})}function Oae({host:e}){const[t]=g.useState(()=>localStorage.getItem(P_)),[n,r]=g.useState(!1),[i,s]=g.useState(null);return g.useEffect(()=>Dae(e),[e]),g.useEffect(()=>{if(!t)return;let o=!1;return Lae().getUrl(e).then(()=>{o||r(!0)}).catch(a=>{o||s(a instanceof Error?a.message:String(a))}),()=>{o=!0}},[e,t]),t?h.jsx(zb,{host:e,children:h.jsx(_w,{children:i?h.jsxs("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-center text-xs text-error","data-testid":"guest-share-connect-error",children:["连接失败:",i]}):n?h.jsx(Jz,{host:e,children:h.jsx(jae,{})}):h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-xs text-text-400",children:"正在连接…"})})}):h.jsx(zb,{host:e,children:h.jsx(_w,{children:h.jsx(Mae,{onAuthed:o=>{localStorage.setItem(P_,o),window.location.reload()}})})})}function Bae({filePath:e,oldString:t,newString:n,content:r}){const i=g.useMemo(()=>r!=null?r.split(/\r?\n/).map(s=>({type:"add",text:s})):zae(t??"",n??""),[t,n,r]);return h.jsxs("div",{"data-testid":"inline-diff",className:"min-w-0 max-w-full rounded-lg border border-bg-300/60 bg-bg-50 overflow-hidden text-[12px] font-mono",children:[h.jsx("div",{className:"flex min-w-0 items-center gap-2 px-3 py-1.5 border-b border-bg-300/40 bg-bg-100/30",children:h.jsx("span",{className:"min-w-0 text-text-400 truncate",title:e,children:e})}),h.jsx("div",{className:"max-h-[320px] max-w-full overflow-auto",children:i.map((s,o)=>h.jsxs("div",{"data-testid":`diff-line-${s.type}`,className:ne("flex min-w-max gap-2 px-3 py-0.5 whitespace-pre",s.type==="add"?"bg-success/10 text-success":s.type==="remove"?"bg-error/10 text-error":"text-text-300"),children:[h.jsx("span",{className:"w-3 shrink-0 select-none opacity-60",children:s.type==="add"?"+":s.type==="remove"?"-":" "}),h.jsx("span",{className:"flex-1",children:s.text||" "})]},o))})]})}function zae(e,t){const n=e.split(/\r?\n/),r=t.split(/\r?\n/),i=n.length,s=r.length,o=Array.from({length:i+1},()=>new Array(s+1).fill(0));for(let u=i-1;u>=0;u--)for(let d=s-1;d>=0;d--)o[u][d]=n[u]===r[d]?o[u+1][d+1]+1:Math.max(o[u+1][d],o[u][d+1]);const a=[];let l=0,c=0;for(;l<i&&c<s;)n[l]===r[c]?(a.push({type:"equal",text:n[l]}),l++,c++):o[l+1][c]>=o[l][c+1]?(a.push({type:"remove",text:n[l]}),l++):(a.push({type:"add",text:r[c]}),c++);for(;l<i;)a.push({type:"remove",text:n[l++]});for(;c<s;)a.push({type:"add",text:r[c++]});return a}function $ae({items:e}){return e.length===0?null:h.jsxs("div",{"data-testid":"todo-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-1.5",children:"Todos"}),h.jsx("ul",{className:"flex flex-col gap-1",children:e.map((t,n)=>{const r=t.status==="in_progress"&&t.activeForm||t.content;return h.jsxs("li",{"data-testid":`todo-item-${t.status}`,className:"flex items-start gap-2",children:[h.jsx(Fae,{status:t.status}),h.jsx("span",{className:ne("flex-1 leading-snug",t.status==="completed"?"text-text-400 line-through":t.status==="in_progress"?"text-text-100 font-medium":"text-text-200"),children:r})]},n)})})]})}function Fae({status:e}){return e==="completed"?h.jsx(Xx,{className:"w-3.5 h-3.5 text-success mt-0.5 shrink-0"}):e==="in_progress"?h.jsx(cr,{className:"w-3.5 h-3.5 text-warning mt-0.5 shrink-0 animate-spin"}):h.jsx(l8,{className:"w-3.5 h-3.5 text-text-400 mt-0.5 shrink-0"})}function Hae(e){const t=e??{};return Array.isArray(t.todos)?t.todos.map(n=>{if(!n||typeof n!="object")return null;const r=n,i=typeof r.content=="string"?r.content:"",s=r.status==="pending"||r.status==="in_progress"||r.status==="completed"?r.status:"pending",o=typeof r.activeForm=="string"?r.activeForm:void 0;return{content:i,status:s,activeForm:o}}).filter(n=>n!==null):[]}function Uae({description:e,prompt:t,subagentType:n}){return h.jsxs("div",{"data-testid":"task-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsxs("div",{className:"flex items-center gap-2 text-text-200 font-medium",children:[h.jsx(up,{className:"w-3.5 h-3.5 text-accent shrink-0"}),h.jsx("span",{className:"truncate",children:e||"subagent task"}),n?h.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded-md text-[10px] font-mono bg-accent/10 text-accent",children:n}):null]}),t?h.jsx("div",{className:"mt-1 text-[12px] text-text-400 leading-snug line-clamp-3",children:t}):null]})}function Wae(e){const t=e??{};return{description:typeof t.description=="string"?t.description:"",prompt:typeof t.prompt=="string"?t.prompt:void 0,subagentType:typeof t.subagent_type=="string"?t.subagent_type:void 0}}const Vae={render:({input:e})=>Ge.createElement($ae,{items:Hae(e)})},qae={render:({input:e})=>{const{description:t,prompt:n,subagentType:r}=Wae(e);return Ge.createElement(Uae,{description:t,prompt:n,subagentType:r})}},k4={render:({input:e,output:t,error:n,pending:r,fileScope:i,onShareFile:s,onOpenInTab:o,onPreviewMarkdown:a})=>{const l=Gae(e),c=l?Ge.createElement(Bae,{filePath:l.filePath,oldString:l.oldString,newString:l.newString,content:l.content}):void 0;return Ge.createElement(LA,{tool:Kae(e),input:e,output:t,error:n,pending:r,expandedBody:c,...i?{fileScope:i}:{},...s?{onShareFile:s}:{},...o?{onOpenInTab:o}:{},...a?{onPreviewMarkdown:a}:{}})}};function Kae(e){const t=e??{};return"content"in t&&t.content!==void 0?"Write":("old_string"in t&&t.old_string!==void 0,"Edit")}function Gae(e){const t=e??{},n=typeof t.file_path=="string"?t.file_path:null;if(!n)return null;const r=typeof t.old_string=="string"?t.old_string:void 0,i=typeof t.new_string=="string"?t.new_string:void 0,s=typeof t.content=="string"?t.content:void 0;return r==null&&i==null&&s==null?null:{filePath:n,oldString:r,newString:i,content:s}}kl.register("claude","TodoWrite",Vae);kl.register("claude","Task",qae);kl.register("claude","Edit",k4);kl.register("claude","Write",k4);const C4=document.getElementById("root");if(!C4)throw new Error("guest-main: #root not found");const Yae=rD({});Pg.createRoot(C4).render(h.jsx(Ge.StrictMode,{children:h.jsx(Oae,{host:Yae})}));
|
|
594
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return g.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Poe="DialogDescriptionWarning",Roe=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${f4(Poe).contentName}}.`;return g.useEffect(()=>{var s;const i=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Moe=e4,Aoe=r4,p4=i4,m4=s4,g4=a4,v4=c4,Loe=d4;const Doe=Moe,joe=Aoe,_4=g.forwardRef(({className:e,...t},n)=>h.jsx(p4,{ref:n,className:ne("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",e),...t}));_4.displayName=p4.displayName;const x4=g.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(joe,{children:[h.jsx(_4,{}),h.jsxs(m4,{ref:r,className:ne("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2","gap-4 rounded-lg border border-border bg-elevated p-6 shadow-lg",e),...n,children:[t,h.jsxs(Loe,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-accent",children:[h.jsx(qr,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));x4.displayName=m4.displayName;const y4=({className:e,...t})=>h.jsx("div",{className:ne("flex flex-col space-y-1.5 text-left",e),...t});y4.displayName="DialogHeader";const b4=g.forwardRef(({className:e,...t},n)=>h.jsx(g4,{ref:n,className:ne("text-lg font-semibold leading-none text-text-100",e),...t}));b4.displayName=g4.displayName;const Ooe=g.forwardRef(({className:e,...t},n)=>h.jsx(v4,{ref:n,className:ne("text-sm text-text-300",e),...t}));Ooe.displayName=v4.displayName;function Boe({persona:e,open:t,onClose:n,onDelete:r,embedded:i,onLoadPersonality:s,onSavePersonality:o,onLoadPersonalityLocal:a,onSavePersonalityLocal:l,hasPersonalityLocal:c=!1,onDirtyChange:u,initialPersonality:d,onShareCapability:f,readOnly:p=!1,larkBot:m}){const[v,w]=g.useState(!1),[_,x]=g.useState(!1),b=v||_,S=Ge.useRef(u);g.useEffect(()=>{S.current=u}),g.useEffect(()=>{var k;(k=S.current)==null||k.call(S,b)},[b]);const C=()=>{b&&!window.confirm("修改未保存,确定关闭?")||n()};return t?h.jsxs(h.Fragment,{children:[!i&&h.jsx("div",{className:"absolute inset-0 z-30 bg-black/30",onClick:C,"aria-hidden":"true"}),h.jsxs("aside",{className:i?"flex h-full w-full flex-col bg-bg-0":"absolute right-0 top-0 z-40 flex h-full w-[420px] flex-col bg-bg-0 border-l border-border shadow-xl","data-testid":"persona-settings-drawer",children:[h.jsxs("header",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h.jsx(aF,{className:"h-4 w-4 text-text-300"}),h.jsx("span",{className:"text-[13px] font-medium text-text-100 truncate",children:"Persona 设置"})]}),h.jsx("button",{type:"button",onClick:C,"aria-label":"关闭",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-text-100",children:h.jsx(qr,{className:"h-4 w-4"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-6 flex flex-col gap-4",children:[h.jsxs("header",{className:"flex items-start justify-between gap-3",children:[h.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h2",{className:"text-lg font-semibold text-text-100 truncate",children:e.label}),e.public?h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-bg-200 px-1.5 py-0.5 text-[10px] text-text-200",children:[h.jsx(N8,{className:"h-3 w-3"})," 公开"]}):h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-error-dim px-1.5 py-0.5 text-[10px] text-error",children:[h.jsx(C8,{className:"h-3 w-3"})," 已关闭"]})]}),h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate","data-testid":"persona-id-subtitle",children:e.personaId})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[f?h.jsxs("button",{type:"button",onClick:f,"aria-label":"分享给他人",title:"分享给他人",className:"inline-flex items-center gap-1 rounded-sm px-2 py-1.5 text-xs text-text-200 hover:bg-bg-200 hover:text-text-100",children:[h.jsx(Jx,{className:"h-3.5 w-3.5"}),"分享"]}):null,r?h.jsx("button",{type:"button",onClick:r,"aria-label":"删除 persona",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-error",children:h.jsx(ey,{className:"h-4 w-4"})}):null]})]}),h.jsx("hr",{className:"border-border"}),m?h.jsxs(h.Fragment,{children:[h.jsx(Foe,{...m}),h.jsx("hr",{className:"border-border"})]}):null,s?h.jsxs(h.Fragment,{children:[h.jsx(l2,{onLoad:s,...o&&!e.personalityManaged?{onSave:o}:{},onDirtyChange:w,initialPersonality:d,readOnly:p||!!e.personalityManaged,title:e.personalityManaged?"内置人格":"人格 (Personality)",hint:e.personalityManaged?p?"这个 persona 自带的人格,随 clawd 版本更新。":"这个 persona 自带的人格,随 clawd 版本更新——在这里改不会保留,要加自己的规则请写下面的「你的补充」。":void 0,testIdPrefix:"persona-personality"}),(e.personalityManaged||c)&&a?h.jsx(l2,{onLoad:a,...l?{onSave:l}:{},onDirtyChange:x,readOnly:p,title:p?"补充设定":"你的补充",hint:p?"这个 persona 的补充设定,由它的主人维护。与内置人格叠加生效。":"写入 <persona-dir>/.clawd/personality.local.md,不会被更新覆盖。与内置人格叠加生效,冲突时以你写的为准;对 owner 和访客会话都生效,要区分对象请在正文里写明。只对新启动的会话生效。",placeholder:"例:回答一律先给结论,再展开。",testIdPrefix:"persona-personality-local"}):null,h.jsx("hr",{className:"border-border"})]}):null,h.jsx(Hoe,{settings:e.sandboxSettings??null}),h.jsx("hr",{className:"border-border"}),h.jsx(Uoe,{skills:e.skills??[]}),h.jsx("hr",{className:"border-border"}),h.jsx(Woe,{plugins:e.plugins??[]})]})]})]}):null}function a2({qrUrl:e,busy:t,onCancel:n,title:r="扫码关联飞书 Bot",hint:i="用手机飞书扫码,按页面提示创建应用。确认后自动完成关联。"}){const[s,o]=g.useState(null);return g.useEffect(()=>{let a=!1;return Bu.toDataURL(e,{width:240,margin:1}).then(l=>{a||o(l)}).catch(()=>{a||o(null)}),()=>{a=!0}},[e]),h.jsx(Doe,{open:!0,onOpenChange:a=>a||n==null?void 0:n(),children:h.jsxs(x4,{className:"max-w-xs","data-testid":"lark-bot-qr-dialog",onInteractOutside:a=>a.preventDefault(),onEscapeKeyDown:a=>a.preventDefault(),children:[h.jsx(y4,{children:h.jsx(b4,{children:r})}),h.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s?h.jsx("img",{src:s,alt:"飞书扫码创建应用二维码",className:"h-60 w-60 rounded bg-white p-2","data-testid":"lark-bot-qr-img"}):h.jsx("div",{className:"flex h-60 w-60 items-center justify-center text-[12px] text-text-400",children:"二维码生成中…"}),h.jsx("span",{className:"text-center text-[12px] text-text-300",children:i}),n?h.jsx("button",{type:"button",disabled:t,onClick:n,className:"rounded border border-border px-3 py-1.5 text-[12px] text-text-300 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-cancel",children:"取消"}):null]})]})})}const zoe={expired:"二维码已过期,请重新扫码。",cancelled:"已取消。",access_denied:"你在飞书上取消了本次授权。",lark_protocol_error:"飞书返回了未预期的响应,请重试。",cloud_unreachable:"云端暂时不可达,请稍后重试。",internal_error:"关联失败。若飞书中已创建应用,可在开发者后台删除后重试,或改用手动绑定填入其凭证。"},$oe=new Set(["expired","access_denied","lark_protocol_error","cloud_unreachable","internal_error"]);function Foe({status:e,onProvision:t,onCancelProvision:n,onBindManual:r,onUnbind:i,onUpgrade:s}){const[o,a]=g.useState(!1),[l,c]=g.useState(null),[u,d]=g.useState(""),[f,p]=g.useState(""),[m,v]=g.useState(null),w=k=>{k&&(a(!0),c(null),k().catch(N=>c(N instanceof Error?N.message:String(N))).finally(()=>a(!1)))},_=()=>{v(null),w(t)},x=!o&&!!u&&!!f,b=()=>{!x||!r||w(()=>r({appId:u,appSecret:f}))},S=Iu(b),C=h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx(up,{className:"h-3.5 w-3.5 text-text-400","aria-hidden":!0}),h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"飞书 Bot"})]});return e?h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[C,e.state==="unbound"||e.state==="provisioning"?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"关联一个飞书 bot 后,这个 persona 就是它:拉进群后群成员 @ 它提问、或直接私聊它, 推理跑在你本机,回复自动发回去。"}),t?h.jsx("button",{type:"button",disabled:o||e.state==="provisioning",onClick:_,className:"self-start rounded border border-border bg-bg-200 px-3 py-1.5 text-[12px] font-medium text-text-100 hover:bg-bg-300 disabled:opacity-50","data-testid":"lark-bot-provision",children:e.state==="provisioning"?"等待扫码…":"扫码关联飞书 Bot"}):null,e.state==="unbound"&&e.errorReason&&!m?h.jsxs("div",{className:"flex flex-col gap-1.5 rounded border border-error bg-error-dim px-2 py-1.5","data-testid":"lark-bot-provision-error",children:[h.jsx("span",{className:"text-[11px] text-error",children:zoe[e.errorReason]}),h.jsxs("div",{className:"flex gap-1.5",children:[$oe.has(e.errorReason)&&t?h.jsx("button",{type:"button",disabled:o,onClick:_,className:"rounded border border-border px-2 py-1 text-[11px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-retry",children:"重新扫码"}):null,h.jsx("button",{type:"button",onClick:()=>v(e.errorReason??null),className:"rounded border border-border px-2 py-1 text-[11px] text-text-300 hover:bg-bg-200","data-testid":"lark-bot-provision-error-dismiss",children:"知道了"})]})]}):null,e.state==="provisioning"&&e.qrUrl?h.jsx(a2,{qrUrl:e.qrUrl,busy:o,onCancel:n?()=>w(n):void 0}):null,r&&e.state==="unbound"?h.jsxs("details",{"data-testid":"lark-bot-manual-details",children:[h.jsx("summary",{className:"cursor-pointer text-[11px] text-text-400 hover:text-text-300",children:"已有飞书应用?手动填入凭证"}),h.jsxs("div",{className:"mt-1.5 flex flex-col gap-1.5","data-testid":"lark-bot-manual-form",children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"先在飞书开放平台(open.feishu.cn)创建企业自建应用并启用机器人能力,再填入凭证:"}),h.jsx("input",{value:u,onChange:k=>d(k.target.value),...S,placeholder:"App ID(cli_ 开头)",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-appid"}),h.jsx("input",{value:f,onChange:k=>p(k.target.value),...S,type:"password",placeholder:"App Secret",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-secret"}),h.jsx("button",{type:"button",disabled:!x,onClick:b,className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-manual-submit",children:o?"绑定中…":"绑定"})]})]}):null]}):null,e.state==="bound"||e.state==="broken"?h.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.state==="bound"&&e.needsUpgrade?h.jsxs("div",{className:"flex flex-col gap-1.5 rounded border border-warning/30 bg-warning-dim px-2 py-1.5","data-testid":"lark-bot-upgrade-notice",children:[h.jsx("span",{className:"text-[11px] text-warning",children:"这个 bot 的权限配置有更新,扫码重新授权后生效。在此之前,新增能力对它不起作用。"}),s?h.jsx("button",{type:"button",disabled:o,onClick:()=>w(s),className:"self-start rounded border border-warning/30 bg-warning/10 px-2 py-1 text-[11px] text-warning hover:bg-warning/20 disabled:opacity-50","data-testid":"lark-bot-upgrade",children:"更新授权"}):null]}):null,e.state==="bound"&&e.upgradeQrUrl?h.jsx(a2,{qrUrl:e.upgradeQrUrl,busy:o,onCancel:n?()=>w(n):void 0,title:"扫码更新授权",hint:"用手机飞书扫码,确认页会列出将要添加的权限。期间 bot 照常服务,不会中断。"}):null,e.state==="broken"?h.jsxs("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-broken",children:["Bot 凭证失效:",e.brokenReason??"未知原因","。请解绑后重新填入有效凭证绑定。"]}):null,h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-200",children:[h.jsx("span",{className:"font-medium text-text-100",children:e.botName??"未命名 bot"}),e.appId?h.jsx("span",{className:"text-[11px] text-text-400",children:e.appId}):null]}),h.jsx("span",{className:"text-[11px] text-text-400",children:"把 bot 拉进任意飞书群,群成员 @ 它即可提问。"}),e.groups.length>0?h.jsx("ul",{className:"flex flex-col gap-0.5","data-testid":"lark-bot-groups",children:e.groups.map(k=>h.jsxs("li",{className:"text-[11px] text-text-300 truncate",children:["· ",k.chatName??k.chatId]},k.chatId))}):h.jsx("span",{className:"text-[11px] text-text-400","data-testid":"lark-bot-groups-empty",children:"还没有服务中的群。"}),i?h.jsx("button",{type:"button",disabled:o,onClick:()=>w(i),className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-error hover:bg-error-dim disabled:opacity-50","data-testid":"lark-bot-unbind",children:"解绑"}):null]}):null,l?h.jsx("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-error",children:l}):null]}):h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[C,h.jsx("span",{className:"text-[11px] text-text-400",children:"状态加载中…"})]})}function Hoe({settings:e}){var t,n,r,i,s,o,a,l,c,u,d,f,p;return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-sandbox-setting-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Sandbox Setting"}),h.jsx("span",{className:"text-[11px] text-text-400",children:"约束此 persona 的沙箱权限(只读,需通过文件修改)。"})]}),e==null?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-sandbox-setting-empty",children:"暂无 sandbox 配置"}):h.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md border border-border bg-bg-100 px-3 py-2",children:[h.jsx(zd,{label:"权限默认模式",value:((t=e.permissions)==null?void 0:t.defaultMode)??"—"}),h.jsx(zd,{label:"沙箱启用",value:Tg((n=e.sandbox)==null?void 0:n.enabled)}),h.jsx(zd,{label:"沙箱内自动放行 Bash",value:Tg((r=e.sandbox)==null?void 0:r.autoAllowBashIfSandboxed)}),h.jsx(zd,{label:"允许非沙箱命令",value:Tg((i=e.sandbox)==null?void 0:i.allowUnsandboxedCommands)}),h.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border pt-1.5",children:[h.jsx(Ql,{label:"沙箱外命令",paths:(s=e.sandbox)==null?void 0:s.excludedCommands}),h.jsx(Ql,{label:"允许读取",paths:(a=(o=e.sandbox)==null?void 0:o.filesystem)==null?void 0:a.allowRead}),h.jsx(Ql,{label:"拒绝读取",paths:(c=(l=e.sandbox)==null?void 0:l.filesystem)==null?void 0:c.denyRead}),h.jsx(Ql,{label:"允许写入",paths:(d=(u=e.sandbox)==null?void 0:u.filesystem)==null?void 0:d.allowWrite}),h.jsx(Ql,{label:"拒绝写入",paths:(p=(f=e.sandbox)==null?void 0:f.filesystem)==null?void 0:p.denyWrite})]})]})]})}function Tg(e){return e===!0?"是":e===!1?"否":"—"}function zd({label:e,value:t}){return h.jsxs("div",{className:"flex items-center justify-between gap-3 text-[12px]",children:[h.jsx("span",{className:"text-text-300",children:e}),h.jsx("span",{className:"font-mono text-text-100",children:t})]})}function Ql({label:e,paths:t}){const n=!t||t.length===0;return h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[11px] text-text-300",children:e}),n?h.jsx("span",{className:"text-[11px] text-text-400",children:"—"}):h.jsx("div",{className:"flex flex-wrap gap-1",children:t.map((r,i)=>h.jsx("span",{className:"rounded-sm border border-border bg-bg-0 px-1.5 py-0.5 font-mono text-[11px] text-text-200",children:r},`${e}-${i}-${r}`))})]})}function Uoe({skills:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-skills-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Persona Skills"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 私有 skills(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/skills/"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-skills-empty",children:"暂无 skills"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsxs("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-skill-row",children:[h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.name}),t.description?h.jsx("span",{className:"text-[12px] text-text-300",children:t.description}):h.jsx("span",{className:"text-[11px] text-text-400 italic",children:"无描述"})]},t.name))})]})}function Woe({plugins:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-plugins-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Enabled Plugins"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 已启用的插件(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/settings.json"})," ","的 ",h.jsx("code",{className:"font-mono",children:"enabledPlugins"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-plugins-empty",children:"暂无启用插件"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsx("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-plugin-row",children:h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.id})},t.id))})]})}function l2({onLoad:e,onSave:t,onDirtyChange:n,initialPersonality:r,readOnly:i=!1,title:s,hint:o,placeholder:a,testIdPrefix:l}){const c=r!==void 0,[u,d]=g.useState(c),[f,p]=g.useState(c?r:""),[m,v]=g.useState(c?r:""),[w,_]=g.useState(null),[x,b]=g.useState(!1),[S,C]=g.useState(null),k=Ge.useRef(e),N=Ge.useRef(t),T=Ge.useRef(n);Ge.useEffect(()=>{k.current=e,N.current=t,T.current=n});const z=Ge.useCallback(()=>{d(!1),_(null),k.current().then(M=>{p(M),v(M),d(!0)}).catch(M=>{_(M instanceof Error?M.message:String(M))})},[]);Ge.useEffect(()=>{c||z()},[c,z]);const P=!i&&u&&m!==f;Ge.useEffect(()=>{i||T.current(P)},[P,i]);const B=()=>{N.current&&(b(!0),C(null),N.current(m).then(()=>{p(m),b(!1)}).catch(M=>{C(M instanceof Error?M.message:String(M)),b(!1)}))},A=()=>{v(f),C(null)},R=Iu(()=>{!P||x||B()},()=>{!P||x||A()});return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":`${l}-section`,children:[h.jsx("span",{className:"text-[12px] font-medium text-text-200",children:s}),w?h.jsxs("div",{"data-testid":`${l}-load-error`,className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error flex items-center justify-between gap-2",children:[h.jsxs("span",{children:["加载失败:",w]}),h.jsx("button",{type:"button",onClick:z,className:"rounded-sm border border-error px-2 py-0.5 text-[11px] hover:bg-error/10",children:"重试"})]}):null,S?h.jsxs("div",{"data-testid":`${l}-save-error`,className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error",children:["保存失败:",S]}):null,h.jsx("textarea",{"data-testid":`${l}-textarea`,value:m,onChange:M=>v(M.target.value),...R,readOnly:i,disabled:!i&&(!u||x),placeholder:u?a??"":"加载中…",rows:8,className:"min-h-[8rem] max-h-[18rem] resize-y rounded-md border border-border bg-bg-100 px-2 py-1.5 font-mono text-[11px] text-text-100 disabled:opacity-60"}),o?h.jsx("p",{className:"text-[10px] text-text-400",children:o}):i?null:h.jsx("p",{className:"text-[10px] text-text-400",children:"写入人格文件。修改只对新启动的会话生效。"}),u&&P?h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:A,disabled:x,className:"rounded-sm border border-border px-2 py-1 text-[12px] text-text-200 hover:bg-bg-200 disabled:opacity-60",children:"放弃"}),h.jsx("button",{type:"button",onClick:B,disabled:x,"data-testid":`${l}-save-btn`,className:"rounded-sm bg-accent-dim px-2 py-1 text-[12px] text-text-100 hover:opacity-90 disabled:opacity-60",children:x?"保存中…":"保存"})]}):null]})}const Voe={state:"unbound",groups:[]};function qoe(e,t){const[n,r]=g.useState(null);g.useEffect(()=>{if(!e)return;let c=!1;r(null);const u=async()=>{try{const p=await e.request("larkBot:status",{personaId:t});c||r(p)}catch{c||r(Voe)}};u();const d=e.on("larkBot:state",p=>{const m=p;if(m.personaId!==t)return;const{personaId:v,...w}=m;r(w)}),f=e.on("daemon:connected",()=>{u()});return()=>{c=!0,d(),f()}},[e,t]);const i=g.useCallback(async()=>{e&&await e.request("larkBot:provision",{personaId:t})},[e,t]),s=g.useCallback(async()=>{e&&await e.request("larkBot:provisionCancel",{personaId:t})},[e,t]),o=g.useCallback(async c=>{e&&await e.request("larkBot:bindManual",{personaId:t,...c})},[e,t]),a=g.useCallback(async()=>{e&&await e.request("larkBot:upgrade",{personaId:t})},[e,t]),l=g.useCallback(async()=>{e&&await e.request("larkBot:unbind",{personaId:t})},[e,t]);return{status:n,provision:i,cancelProvision:s,bindManual:o,unbind:l,upgrade:a}}function Koe(e,t="owner"){var k;const{persona:n}=vI(e),r=k$(e),i=C$(),s=E$(),{httpBaseUrl:o}=cp(),a=Yi(),l=qoe(t==="guest"?null:a,e),{capabilities:c}=g1((n==null?void 0:n.tool)??"claude"),u=g.useMemo(()=>!(n!=null&&n.public)||!o||/^https?:\/\/(127\.0\.0\.1|localhost|0\.0\.0\.0|\[?::1\]?)([:/]|$)/i.test(o)?null:`${o}/s/${e}`,[n==null?void 0:n.public,o,e]),d=g.useCallback((N,T)=>{i(e,T).catch(z=>{Me("persona",`${N} failed`,z)})},[i,e]),f=g.useCallback(N=>d("togglePublic",{public:N}),[d]),p=g.useCallback(async N=>{await i(e,{codexSandbox:{network:N}}),await r.refresh()},[i,e,r]),m=g.useCallback(N=>d("changeTool",{tool:N}),[d]),v=g.useCallback(N=>d("changeModel",{model:N}),[d]),w=g.useCallback(N=>d("changeEffort",{effort:N}),[d]),_=g.useCallback(()=>!n||!confirm(`删除 persona "${n.label}"?`)?!1:(s(e).catch(N=>{Me("persona","delete failed",N)}),!0),[n,s,e]),x=g.useCallback(async()=>r.loaded?r.personality:(await r.refresh()).personality,[r]),b=g.useCallback(async N=>{await i(e,{personality:N}),await r.refresh()},[i,e,r]),S=g.useCallback(async()=>r.loaded?r.personalityLocal:(await r.refresh()).personalityLocal,[r]),C=g.useCallback(async N=>{await i(e,{personalityLocal:N}),await r.refresh()},[i,e,r]);return{persona:n,detail:r,models:(c==null?void 0:c.models)??[],configSchema:(c==null?void 0:c.configSchema)??[],larkBot:l,guestShareUrl:u,changeTool:m,changeModel:v,changeEffort:w,togglePublic:f,guestNetwork:((k=r.codexSandbox)==null?void 0:k.network)??!1,toggleGuestNetwork:p,remove:_,loadPersonality:x,savePersonality:b,loadPersonalityLocal:S,savePersonalityLocal:C}}function Goe({personaId:e,open:t,onClose:n,api:r,embedded:i,onDirtyChange:s,onShareCapability:o,viewerRole:a="owner"}){const l=Koe(e,a),{persona:c,detail:u}=l,d=g.useCallback(()=>{l.remove()&&n()},[l,n]);if(!c)return null;const f=a==="guest";return h.jsx(Boe,{embedded:i,persona:{...c,skills:u.skills,plugins:u.plugins,sandboxSettings:u.sandboxSettings,personalityManaged:u.personalityManaged},open:t,onClose:n,onLoadPersonality:l.loadPersonality,onLoadPersonalityLocal:l.loadPersonalityLocal,hasPersonalityLocal:u.personalityLocal!=="",onDirtyChange:s,readOnly:f,...f?{}:{onTogglePublic:l.togglePublic,guestShareUrl:l.guestShareUrl,onChangeTool:l.changeTool,onChangeModel:l.changeModel,onChangeEffort:l.changeEffort,models:l.models,configSchema:l.configSchema,onDelete:d,onSavePersonality:l.savePersonality,onSavePersonalityLocal:l.savePersonalityLocal,larkBot:{status:l.larkBot.status,onProvision:l.larkBot.provision,onCancelProvision:l.larkBot.cancelProvision,onBindManual:l.larkBot.bindManual,onUnbind:l.larkBot.unbind,onUpgrade:l.larkBot.upgrade},...o?{onShareCapability:o}:{}}})}const Yoe={resolve:()=>{}},Xoe=g.createContext(Yoe);function Qoe(){return g.useContext(Xoe)}const Zoe={...Fs,h1:({node:e,...t})=>h.jsx("h1",{...t,className:"mt-4 mb-3 text-[18px] font-semibold leading-tight text-text-100"}),h2:({node:e,...t})=>h.jsx("h2",{...t,className:"mt-4 mb-2 text-[16px] font-semibold leading-tight text-text-100"}),h3:({node:e,...t})=>h.jsx("h3",{...t,className:"mt-3 mb-2 text-[14px] font-semibold leading-tight text-text-100"}),h4:({node:e,...t})=>h.jsx("h4",{...t,className:"mt-3 mb-1 text-[13px] font-semibold text-text-100"}),h5:({node:e,...t})=>h.jsx("h5",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-100"}),h6:({node:e,...t})=>h.jsx("h6",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-300"}),p:({node:e,...t})=>h.jsx("p",{...t,className:"my-2 leading-relaxed"}),ul:({node:e,...t})=>h.jsx("ul",{...t,className:"my-2 list-disc space-y-1 pl-5"}),ol:({node:e,...t})=>h.jsx("ol",{...t,className:"my-2 list-decimal space-y-1 pl-5"}),li:({node:e,...t})=>h.jsx("li",{...t,className:"leading-relaxed"}),blockquote:({node:e,...t})=>h.jsx("blockquote",{...t,className:"my-2 border-l-2 border-border pl-3 italic text-text-300"}),code:({node:e,className:t,children:n,...r})=>t?h.jsx("code",{...r,className:`${t} font-mono text-[12px]`,children:n}):h.jsx("code",{...r,className:"rounded bg-bg-50 px-1 py-0.5 font-mono text-[12px] text-text-100",children:n}),pre:({node:e,...t})=>h.jsx("pre",{...t,className:"my-2 overflow-auto rounded border border-border bg-bg-0 p-3 text-[12px] font-mono text-text-100"}),hr:({node:e,...t})=>h.jsx("hr",{...t,className:"my-3 border-border"}),table:({node:e,...t})=>h.jsx("table",{...t,className:"my-2 w-full border-collapse text-[12px]"}),thead:({node:e,...t})=>h.jsx("thead",{...t,className:"bg-bg-50"}),th:({node:e,...t})=>h.jsx("th",{...t,className:"border border-border px-2 py-1 text-left font-semibold"}),td:({node:e,...t})=>h.jsx("td",{...t,className:"border border-border px-2 py-1"}),strong:({node:e,...t})=>h.jsx("strong",{...t,className:"font-semibold text-text-100"}),em:({node:e,...t})=>h.jsx("em",{...t,className:"italic"})};function Joe(e){const t=e.split("/");return t[t.length-1]||e}function w4({relPath:e,loadMarkdown:t,headerRight:n,showTitleBar:r=!1}){const[i,s]=g.useState(null),[o,a]=g.useState(null),[l,c]=g.useState(!1);return g.useEffect(()=>{if(!e)return;let u=!1;return c(!0),a(null),s(null),(async()=>{try{const d=await t(e);if(u)return;s(d)}catch(d){if(u)return;a(d.message||String(d))}finally{u||c(!1)}})(),()=>{u=!0}},[e,t]),h.jsxs("div",{className:"flex flex-col h-full",children:[r&&e?h.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[h.jsx("div",{"data-testid":"md-preview-title",className:"truncate text-[13px] font-medium text-text-100",title:e,children:Joe(e)}),h.jsx("div",{className:"flex items-center gap-1",children:n})]}):null,h.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 text-[13px] text-text-100",children:l?h.jsx("div",{"data-testid":"md-preview-loading",className:"text-text-400",children:"Loading…"}):o?h.jsx("div",{"data-testid":"md-preview-error",className:"text-destructive whitespace-pre-wrap",children:o}):i!==null?h.jsx("div",{"data-testid":"md-preview-content",className:"max-w-none",children:h.jsx(tl,{remarkPlugins:[nl],components:Zoe,children:i})}):null})]})}function eae({open:e,onOpenChange:t,relPath:n,loadMarkdown:r,onShare:i}){return e?h.jsx("div",{"data-testid":"md-preview-drawer",className:`${s1} z-50 flex w-1/2 max-w-[900px] flex-col border-l border-border bg-elevated shadow-2xl`,children:h.jsx(w4,{relPath:n,loadMarkdown:r,showTitleBar:!0,headerRight:h.jsxs(h.Fragment,{children:[i?h.jsx("button",{type:"button","data-testid":"md-preview-share","aria-label":"Share rendered preview link",onClick:i,className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(D8,{className:"h-4 w-4"})}):null,h.jsx("button",{type:"button","aria-label":"Close preview",onClick:()=>t(!1),className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(qr,{className:"h-4 w-4"})})]})})}):null}const c2=4;function tae({children:e,onHeightChange:t}){const n=g.useRef(null),[r,i]=g.useState(0);return g.useEffect(()=>{const s=n.current;if(!s)return;const o=()=>i(s.offsetHeight>0?s.offsetHeight+c2*2:0);if(o(),typeof ResizeObserver>"u")return;const a=new ResizeObserver(o);return a.observe(s),()=>a.disconnect()},[]),g.useEffect(()=>{t==null||t(r)},[r,t]),h.jsx("div",{"data-testid":"chat-floating-dock","data-height":r,className:"relative z-20 h-0 shrink-0",children:h.jsx("div",{ref:n,className:"absolute left-4 right-4 flex flex-col items-end gap-1",style:{bottom:c2},children:e})})}const nae=250;function rae(e){if(!e||!Number.isFinite(e))return null;const t=e/1e3;if(t<60)return`${t.toFixed(0)}s`;const n=Math.floor(t/60);return`${n}m${Math.round(t-n*60).toString().padStart(2,"0")}s`}function iae({agents:e}){var a,l,c;const[t,n]=g.useState(!1);if(e.length===0)return null;const r=e.length===1?e[0]:null,i=r?r.description:`${e.length} 个后台任务`,s=r?rae((l=(a=r.progress)==null?void 0:a.stats)==null?void 0:l.durationMs):null,o=r?(c=r.progress)==null?void 0:c.lastToolName:null;return h.jsxs("div",{"data-testid":"running-agents-chip","data-agent-count":e.length,className:"relative",children:[t?h.jsx("div",{"data-testid":"running-agents-popover",className:"absolute bottom-full right-0 z-20 mb-1 w-[min(560px,80vw)]",children:h.jsx("div",{className:"min-w-0 overflow-y-auto rounded-lg border border-bg-200/60 bg-bg-100 px-2 py-1 shadow-lg",style:{maxHeight:nae},children:e.map(u=>h.jsx(FA,{expandable:!1,description:u.description,input:u.input,output:u.output,...u.error!==void 0?{error:u.error}:{},pending:u.pending,notifications:u.notifications,...u.toolResultExtra?{toolResultExtra:u.toolResultExtra}:{},...u.progress?{progress:u.progress}:{}},u.toolUseId))})}):null,h.jsxs("button",{type:"button","data-testid":"running-agents-chip-toggle","aria-expanded":t,onClick:()=>n(u=>!u),className:ne("flex max-w-[min(560px,80vw)] min-w-0 items-center gap-2 rounded-full","border border-bg-200/60 bg-bg-100/95 px-3 py-1 text-[12px] shadow-md backdrop-blur","hover:bg-bg-200/95 transition-colors"),children:[h.jsx(cr,{className:"w-3 h-3 shrink-0 animate-spin text-blue-400"}),h.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-text-200",children:i}),s?h.jsx("span",{className:"shrink-0 tabular-nums text-text-400",children:s}):null,o?h.jsxs("span",{className:"shrink-0 font-mono tabular-nums text-blue-400",children:["now:",o]}):null,h.jsx(yI,{className:ne("w-3.5 h-3.5 shrink-0 text-text-400 transition-transform",t&&"rotate-180")})]})]})}const sae={closeTrailing:!1},oae={closeTrailing:!0};function aae(e){return e?sae:oae}function lae({session:e,api:t,onPromoteQuickAsk:n}){const r=_M(e.sessionId);return h.jsx(S4,{state:r,extras:{session:e,api:t,...n?{onPromoteQuickAsk:n}:{}}})}function cae({headerMeta:e,connState:t,liveWorktreeRoot:n,onOpenConfig:r,variant:i="full",ephemeral:s,onPromote:o,hideHeader:a=!1,flatProcess:l=!1,lines:c,pendingPermissions:u,procAlive:d,rewindableUserMessageIds:f,onPermissionRespond:p,onPermissionInterrupt:m,onRewind:v,onFork:w,onQuickAsk:_,topSlot:x,realtimeQuestionAnswers:b,onSubmitQuestion:S,onCancelQuestion:C,liveQuestionToolUseIds:k,api:N,cwd:T,tool:z,cloudVolume:P,sessionKey:B,onSend:A,awaitingUser:R,queued:M,onDequeue:D,onAbort:$,onNewSession:F,onClearSession:j,configSlot:O,chatRootRef:E,chatBodyRef:H,drawers:q,xtermSlot:L,fileSharingScope:re,onShareFile:se,onOpenInTab:K,onPreviewMarkdown:ge,onOpenFilePath:Re,dispatchOrigin:ce}){const[Le,Oe]=g.useState(0),Ae=g.useMemo(()=>i==="full"?Vq(bM(c)):[],[c,i]),_e=g.useMemo(()=>new Set(Ae.map(Qe=>Qe.toolUseId)),[Ae]);return h.jsx(Zee,{children:h.jsxs("div",{ref:E,"data-cc-chat-root":"",className:"flex flex-col h-full bg-bg-100",children:[a?null:h.jsx(ene,{meta:e,...z?{tool:z}:{},...P?{cloudVolume:P}:{},connState:t,variant:i,...n!==void 0?{liveWorktreeRoot:n}:{},...i==="full"&&r?{onOpenConfig:r}:{},...i==="quickask"?{ephemeral:s??!1,...o?{onPromote:o}:{}}:{}}),h.jsx("div",{ref:H,"data-testid":"chat-body",className:"flex-1 overflow-y-auto min-h-0",style:{overflowAnchor:"none",paddingBottom:Le},children:h.jsx(UA,{lines:c,...p?{onPermissionRespond:p}:{},...m&&d?{onPermissionInterrupt:m}:{},topSlot:x,...v?{onRewind:v}:{},rewindableUserMessageIds:f,...w?{onFork:w}:{},..._?{onQuickAsk:_}:{},realtimeQuestionAnswers:b,onSubmitQuestion:S,...C?{onCancelQuestion:C}:{},liveQuestionToolUseIds:k,...re?{fileSharingScope:re}:{},...se?{onShareFile:se}:{},...K?{onOpenInTab:K}:{},...ge?{onPreviewMarkdown:ge}:{},...Re?{onOpenFilePath:Re}:{},...ce?{dispatchOrigin:ce}:{},...i==="full"&&!l?{turnCollapse:aae(d)}:{},dockedAgentToolUseIds:_e})}),L,h.jsx(tae,{onHeightChange:Oe,children:h.jsx(iae,{agents:Ae})}),e.larkChatName?h.jsx("div",{className:"mx-3 mb-3 rounded-lg border border-border bg-bg-200 px-3 py-2 text-[12px] text-text-400","data-testid":"lark-readonly-notice",children:e.larkChatType==="p2p"?`此会话由与「${e.larkChatName}」的飞书私聊驱动——对方消息触发,这里仅供观察。`:`此会话由飞书群「${e.larkChatName}」驱动——群成员 @ bot 提问触发,这里仅供观察。`}):h.jsx(Zte,{meta:e,...N?{api:N}:{},cwd:T,...z?{tool:z}:{},sessionKey:B,onSend:A,awaitingUser:R,...M?{queued:M}:{},...D?{onDequeue:D}:{},...$?{onAbort:$}:{},...F?{onNewSession:F}:{},...j?{onClearSession:j}:{},...O?{configSlot:O}:{}}),q]})})}function S4({state:e,extras:t,onQuickAskInternal:n,onPreviewMdInternal:r}){const{session:i,api:s,liveGitBranch:o,liveWorktreeRoot:a,cloudVolume:l,onNewSession:c,onTurnEnd:u,onOpenConfig:d,onFork:f,onQuickAsk:p,viewerRole:m,onPromoteQuickAsk:v,configSlot:w,hideHeader:_,flatProcess:x}=t,{capabilities:b}=g1(i.tool||"claude"),S=(b==null?void 0:b.features)??hI(i.tool),[C,k]=g.useState(null),[N,T]=g.useState(null),z=cp(),P=!!s&&z.actionsLevel==="owner"&&S.fileSharing,B=vI(i.ownerPersonaId??null).persona,A=(B==null?void 0:B.label)??null,R=!!A&&!!i.ownerPersonaId,M=Qoe(),D=g.useMemo(()=>({resolve:(ee,we)=>M.resolve(ee,we,i.sessionId),...M.onOpenSession?{onOpenSession:M.onOpenSession}:{}}),[M,i.sessionId]),$=g.useCallback((ee,we)=>{k({kind:ee,text:we}),setTimeout(()=>{k(ke=>(ke==null?void 0:ke.text)===we?null:ke)},2e3)},[]),F=Yi(),j=e$(),O=fM(i.sessionId,i.toolSessionId),{events:E,pendingQuestions:H,clearQuestion:q,markQuestionSubmitted:L,status:re}=O,se=e.historyLoading,K=vM(re);g.useEffect(()=>{Me("chat-panel","sessionStatus",{sessionId:i.sessionId,sessionStatus:re,procAlive:K})},[re,K,i.sessionId]);const ge=e.lines,Re=e.pendingPermissions,ce=Re[0]??null,Le=g.useMemo(()=>Uq(E),[E]),[Oe,Ae]=g.useState(null),[_e,Qe]=g.useState(()=>new Set);$q(s,i.sessionId,i.toolSessionId,S.observe);const kt=g.useRef(i.sessionId);g.useEffect(()=>{if(kt.current=i.sessionId,!S.rewind){Ae(null);return}let ee=!1;return Ae(null),(async()=>{try{const we=await s.sessionRewindableMessageIds(i.sessionId);if(ee)return;Ae(new Set(we.userMessageIds))}catch{ee||Ae(null)}})(),()=>{ee=!0}},[s,i.sessionId,S.rewind]);const tt=g.useCallback(()=>{const ee=i.sessionId;s.sessionRewindableMessageIds(ee).then(we=>{kt.current===ee&&Ae(new Set(we.userMessageIds))}).catch(()=>{})},[s,i.sessionId]),At=g.useMemo(()=>{if(Oe!==null){const Ze=new Set(Oe);for(const Gr of _e)Ze.delete(Gr);return Ze}const ee=new Set(["Edit","Write","MultiEdit","NotebookEdit"]),we=new Set;let ke=null;for(const Ze of ge)Ze.kind==="user-text"?ke=Ze.uuid??null:ke&&Ze.kind==="tool-call"&&ee.has(Ze.tool)&&!_e.has(ke)&&we.add(ke);return we},[ge,_e,Oe]),Jt=g.useRef(u);Jt.current=u,Fq(i.sessionId,i.toolSessionId,()=>{Et(null),Qe(new Set)});const nt=gne({sessionStatus:re}),Ct=g.useRef(null);g.useEffect(()=>{var ke;const ee=Ct.current,we=(ee==null?void 0:ee.sid)===i.sessionId;we&&ee.phase===nt||(Ct.current={sid:i.sessionId,phase:nt},Me("session-phase",nt,{sid:i.sessionId,phase:nt,prev:we?ee.phase:null,desc:mne[nt]}),we&&ee.phase==="turn-running"&&nt!=="turn-running"&&((ke=Jt.current)==null||ke.call(Jt),tt()))},[nt,i.sessionId,tt]);const qe=g.useCallback(async()=>{const ee=await s.sessionInterrupt(i.sessionId).catch(()=>{});return(ee==null?void 0:ee.queued)??[]},[s,i.sessionId]),[ot,Et]=g.useState(null),_n=g.useCallback(ee=>{Et(ee)},[]),[Tn,U]=g.useState(!1),J=g.useCallback(()=>{s.sessionStop(i.sessionId).catch(()=>{}),U(!1)},[s,i.sessionId]);g.useCallback(ee=>{s.pinSession(i.sessionId,ee).catch(we=>{Me("chat-panel","pinSession failed",{err:we==null?void 0:we.message})})},[s,i.sessionId]);const xe=v?"quickask":"full",{container:Ie,onCollapse:Fe,hostExtras:Nt}=ane(),en=g.useRef(0),tn=g.useRef(null);g.useEffect(()=>{const ee=we=>{if(we.key!=="Escape")return;if(!K){en.current=0;return}if(we.isComposing)return;const Ze=we.target;if(Ze&&Ze.closest("[data-cc-chat-root]")!==tn.current)return;const Gr=Date.now();Gr-en.current<2e3?(en.current=0,U(!0)):(en.current=Gr,qe())};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[qe,K]);const nn=g.useRef(null),oe=g.useRef(!0),ye=g.useRef(void 0),rt=g.useRef(0),mt=g.useRef(0),fr=g.useRef(void 0);g.useEffect(()=>{T(null)},[i.sessionId]),g.useEffect(()=>{const ee=nn.current;if(!ee)return;const we=150,ke=Ze=>{Date.now()<mt.current&&(Ze.preventDefault(),mt.current=Date.now()+we)};return ee.addEventListener("wheel",ke,{passive:!1}),()=>ee.removeEventListener("wheel",ke)},[]),g.useEffect(()=>{const ee=nn.current;if(!ee)return;const we=32,ke=()=>{const Ze=ee.scrollHeight-ee.scrollTop-ee.clientHeight;oe.current=Ze<=we};return ee.addEventListener("scroll",ke,{passive:!0}),()=>ee.removeEventListener("scroll",ke)},[]),g.useLayoutEffect(()=>{var $u;const ee=nn.current;if(!ee)return;const we=fr.current!==i.sessionId;we&&(fr.current=i.sessionId,oe.current=!0,ye.current=void 0,rt.current=0,mt.current=0);const ke=ye.current,Ze=($u=ge[0])==null?void 0:$u.seq;ye.current=Ze,!we&&ke!==void 0&&Ze!==void 0&&Ze<ke?(ee.scrollTop=ee.scrollHeight-rt.current,mt.current=Date.now()+200):oe.current&&(ee.scrollTop=ee.scrollHeight),rt.current=ee.scrollHeight-ee.scrollTop},[ge,ce==null?void 0:ce.requestId,i.sessionId]);const ae=g.useMemo(()=>{const ee={};for(const[we,ke]of Object.entries(H))ke.submittedAnswers&&(ee[we]=ke.submittedAnswers);return ee},[H]),Je=g.useMemo(()=>new Set(Object.keys(H)),[H]),hn=g.useCallback(async(ee,we)=>{try{await s.answerQuestion({sessionId:i.sessionId,toolUseId:ee,answers:we}),L(ee,we)}catch{}},[s,i.sessionId,L]),Ys=g.useCallback(async ee=>{try{await s.cancelQuestion({sessionId:i.sessionId,toolUseId:ee}),q(ee)}catch{}},[s,i.sessionId,q]),Nl=g.useCallback(async(ee,we)=>{var ke;if(ce)try{await((ke=e.respondPermission)==null?void 0:ke.call(e,ce.requestId,ee?"allow":"deny"))}catch{}},[e,ce]),Yo=g.useCallback(async()=>{const ee=i.sessionId;try{await s.sessionStop(ee)}catch{}e.clearSession?await e.clearSession():await s.sessionNew(ee)},[e,s,i.sessionId]),ts=g.useMemo(()=>e.historyError?h.jsxs("div",{className:"flex justify-center py-2 text-[12px] text-text-400","data-testid":"history-error",children:["历史未加载完(",e.historyError,");切走再切回可重试"]}):se&&ge.length===0?h.jsx("div",{className:"flex justify-center py-4","data-testid":"history-loading",children:h.jsx(cr,{className:"w-4 h-4 text-text-400 animate-spin"})}):null,[se,ge.length,e.historyError]),Xs=e.meta,Tl=h.jsxs(h.Fragment,{children:[i.toolSessionId&&S.subagents?h.jsx(lne,{api:s,cwd:i.cwd,toolSessionId:i.toolSessionId,toolKind:i.tool??"claude"}):null,ot&&S.rewind?h.jsx(une,{open:!0,onOpenChange:ee=>{ee||Et(null)},api:s,sessionId:i.sessionId,userMessageId:ot,lines:ge,procAlive:K,onNoChanges:ee=>{Qe(we=>{if(we.has(ee))return we;const ke=new Set(we);return ke.add(ee),ke})}}):null,Tn?h.jsx(uae,{onConfirm:J,onCancel:()=>U(!1)}):null]}),Xo={kind:"session",sessionId:i.sessionId},bi=g.useCallback(async ee=>{if(s)try{await XS(s,F,i.sessionId,ee)}catch(we){const ke=we.message;Me("chat-panel","open-in-tab failed",{err:ke}),$("err",`Open in tab 失败:${ke}`)}},[s,F,i.sessionId,$]),[ns,Il]=g.useState(!1),[Pl,Vt]=g.useState(null),Qs=g.useCallback(ee=>{if(r){r(ee);return}Vt(ee),Il(!0)},[r]),Wp=g.useCallback(ee=>{if(!s)return;const we=async()=>{try{await s.attachmentGroupAdd(i.sessionId,ee)}catch(Ze){Me("chat-panel","file-link groupAdd skipped",{err:Ze.message})}},ke=Ze=>{const Gr=Ze.message;Me("chat-panel","file-link open failed",{err:Gr}),$("err",`打开文件失败:${Gr}`)};if(Lp(ee)){we().then(()=>Qs(ee),ke);return}XS(s,F,i.sessionId,ee,60,we).catch(ke)},[s,F,i.sessionId,Qs,$]),Lt=g.useCallback(async ee=>{if(!s)throw new Error("daemon api not ready");const we=await zy(s,F,i.sessionId,ee,60),ke=await fetch(we);if(!ke.ok)throw new Error(`fetch ${ke.status} ${ke.statusText}`);return await ke.text()},[s,F,i.sessionId]),Dt=g.useCallback(async(ee,we)=>{if(s)try{const{url:ke}=await s.attachmentSignUrl({sessionId:i.sessionId,relPath:ee,...we?{view:we}:{}}),Ze=await Tq(ke);$(Ze?"ok":"err",Ze?"分享链接已复制到剪贴板":"复制失败:请手动复制")}catch(ke){const Ze=ke.message;Me("chat-panel","share-file failed",{err:Ze}),$("err",`生成分享链接失败:${Ze}`)}},[s,i.sessionId,$]),In=g.useCallback(()=>T(null),[]),pr=N==="files"&&P&&s?{title:"Edited Files",onBack:In,content:h.jsx(Pse,{api:s,scope:Xo,sessionId:i.sessionId,onShareFile:Dt,onOpenInTab:bi,onPreviewMarkdown:Qs})}:N==="cron"?{title:`定时任务${Le.length?` (${Le.length})`:""}`,onBack:In,content:h.jsx("div",{className:"p-3",children:h.jsx(pne,{jobs:Le})})}:N==="persona"&&R&&s&&i.ownerPersonaId?{title:`Persona · ${A??""}`,onBack:In,content:h.jsx(Goe,{personaId:i.ownerPersonaId,open:!0,onClose:In,api:s,embedded:!0,...m?{viewerRole:m}:{}},i.ownerPersonaId)}:null,Zs=xe==="full"?h.jsx(sne,{session:i,meta:Xs,...o!==void 0?{liveGitBranch:o}:{},...a!==void 0?{liveWorktreeRoot:a}:{},...R?{personaName:A}:{},...R?{onOpenPersona:()=>T("persona")}:{},...P?{onOpenFiles:()=>T("files")}:{},cronActiveCount:Le.length,onCronClick:()=>T("cron"),onForceStop:()=>U(!0),...m?{viewerRole:m}:{},...b!=null&&b.toolSessionIdLabel?{toolSessionIdLabel:b.toolSessionIdLabel}:{},drill:pr,...Fe?{onCollapse:Fe}:{},...Nt?{title:Nt.title,leadingEntries:Nt.leadingEntries}:{}}):null;return h.jsxs(h.Fragment,{children:[Ie&&Zs?hl.createPortal(Zs,Ie):null,h.jsx(cae,{headerMeta:Xs,connState:e.connState,...a!==void 0?{liveWorktreeRoot:a}:{},...d?{onOpenConfig:d}:{},variant:xe,..._?{hideHeader:_}:{},...x?{flatProcess:x}:{},...xe==="quickask"?{ephemeral:i.ephemeral!==!1,onPromote:()=>void(v==null?void 0:v(i.sessionId))}:{},lines:ge,pendingPermissions:Re,procAlive:K,rewindableUserMessageIds:At,onPermissionRespond:Nl,onPermissionInterrupt:qe,onRewind:S.rewind?_n:void 0,...f&&S.fork?{onFork:f}:{},...n&&S.fork?{onQuickAsk:n}:p&&S.fork?{onQuickAsk:p}:{},topSlot:ts,realtimeQuestionAnswers:ae,onSubmitQuestion:hn,onCancelQuestion:Ys,liveQuestionToolUseIds:Je,api:s,cwd:i.cwd,...i.tool?{tool:i.tool}:{},...l?{cloudVolume:l}:{},sessionKey:i.sessionId,onSend:e.sendText,queued:e.queued,onDequeue:e.dequeue,awaitingUser:Re.length>0||Object.values(H).some(ee=>!ee.submittedAnswers),onAbort:qe,...c?{onNewSession:c}:{},onClearSession:Yo,...w?{configSlot:w}:{},chatRootRef:tn,chatBodyRef:nn,drawers:Tl,xtermSlot:j==="tui"&&K&&S.tui?h.jsx(Ise,{sessionId:i.sessionId,client:F},i.sessionId):null,fileSharingScope:Xo,...s?{onShareFile:Dt}:{},...s?{onOpenInTab:bi}:{},...s?{onPreviewMarkdown:Qs}:{},...s?{onOpenFilePath:Wp}:{},dispatchOrigin:D}),s?h.jsx(eae,{open:ns,onOpenChange:Il,relPath:Pl,loadMarkdown:Lt,onShare:Pl?()=>void Dt(Pl,"md-rendered"):void 0}):null,C?h.jsx("div",{"data-testid":"share-toast",role:"status","aria-live":"polite",className:C.kind==="ok"?"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-emerald-500/40 bg-emerald-500/10 px-3 py-2 text-[12px] text-emerald-700 shadow-md dark:text-emerald-300":"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px] text-destructive shadow-md",children:C.text}):null]})}function uae({onConfirm:e,onCancel:t}){return h.jsx("div",{role:"dialog","aria-modal":"true","data-testid":"force-stop-confirm",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:t,children:h.jsxs("div",{className:"max-w-sm w-[92%] rounded-lg border border-red-400/40 bg-bg-0 p-4 shadow-xl",onClick:n=>n.stopPropagation(),children:[h.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[h.jsx(tf,{className:"w-5 h-5 text-red-500 shrink-0 mt-0.5"}),h.jsx("div",{className:"text-[14px] text-text-100",children:"强制停止会话进程?会丢失 initialize / 预热缓存,下一次发送需要重新 spawn。"})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:t,className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),h.jsx("button",{type:"button","data-testid":"force-stop-confirm-ok",onClick:e,className:"h-8 px-3 rounded-md bg-red-500 text-white text-[12px] font-medium hover:bg-red-600 cursor-pointer",children:"强制停止"})]})]})})}function dae(e){return e.split("/").pop()||e}function hae({state:e,api:t,onSwitchTab:n,onCloseQuickAsk:r,onCloseMd:i,loadMarkdown:s,quickAskSession:o,onPromoteQuickAsk:a}){if(!xM(e))return null;const l=[];e.quickAsk&&l.push({id:"quick-ask",label:"问一下",title:"问一下",icon:h.jsx(m0,{className:"w-3.5 h-3.5"})});for(const c of e.mds)l.push({id:{kind:"md",relPath:c},label:dae(c),title:c,icon:h.jsx(mi,{className:"w-3.5 h-3.5"})});return h.jsxs("div",{className:"flex flex-col h-full bg-bg-50/60 border-l border-border-strong",children:[h.jsx(uf,{delayDuration:200,skipDelayDuration:100,children:h.jsx("div",{className:["flex items-stretch h-9 border-b border-text-100/10 shrink-0 overflow-x-auto","[scrollbar-width:none] [-ms-overflow-style:none]","[&::-webkit-scrollbar]:hidden"].join(" "),role:"tablist",children:l.map(c=>{const u=zq(e.active,c.id),d=c.id==="quick-ask"?"quick-ask":`md:${c.id.relPath}`;return h.jsxs(Cp,{children:[h.jsx(Ep,{asChild:!0,children:h.jsxs("div",{role:"tab","aria-selected":u,"data-tab-title":c.title,onClick:()=>n(c.id),className:["group relative flex items-center gap-2 px-3 h-full cursor-pointer select-none","text-[12px] max-w-[180px] shrink-0 transition-colors duration-100",u?"text-text-100":"text-text-400 hover:text-text-100 hover:bg-text-100/[0.04]"].join(" "),children:[c.icon,h.jsx("span",{className:"truncate",children:c.label}),h.jsx("button",{type:"button","aria-label":`关闭 ${c.label}`,className:["ml-1 rounded p-0.5 shrink-0 transition-opacity","hover:bg-text-100/10",u?"opacity-70 hover:opacity-100":"opacity-0 group-hover:opacity-70"].join(" "),onClick:f=>{f.stopPropagation(),c.id==="quick-ask"?r():i(c.id.relPath)},children:h.jsx(qr,{className:"w-3 h-3"})}),u?h.jsx("span",{"aria-hidden":"true",className:"absolute left-2 right-2 -bottom-px h-[2px] rounded-full bg-accent"}):null]})}),h.jsx(Pu,{side:"bottom",align:"start",className:"max-w-sm break-all",children:c.title})]},d)})})}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[e.quickAsk&&o?h.jsx("div",{className:"absolute inset-0",style:{display:e.active==="quick-ask"?"block":"none"},children:h.jsx(lae,{session:o,api:t,...a?{onPromoteQuickAsk:a}:{}})}):null,e.mds.map(c=>{const u=e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===c;return h.jsx("div",{className:"absolute inset-0",style:{display:u?"block":"none"},children:h.jsx(w4,{relPath:c,loadMarkdown:s,showTitleBar:!1})},`md-body:${c}`)})]})]})}function fae(e){const t=e instanceof Error?e.message:String(e);return t.length>200?`${t.slice(0,200)}…`:t}function pae({state:e,extras:t}){const{api:n,session:r}=t,i=Yi(),[s,o]=g.useState(Mq()),[a,l]=g.useState(null),c=r.ownerPersonaId!==qT,u=g.useRef(s);u.current=s;const d=g.useRef(!1),f=g.useCallback(async T=>{const z=u.current.quickAsk;l(null);let P;try{P=await kq(n,r,T)}catch(B){Me("quick-ask","fork failed",B),d.current||l(fae(B));return}if(!P){d.current||l("这条会话还没准备好(没有可派生的对话记录),稍后再试");return}if(d.current){n.sessionDelete(P.sessionId).catch(()=>{});return}Cd(z)&&n.sessionDelete(z.sessionId).catch(()=>{}),o(B=>Aq(B,{sessionId:P.sessionId}))},[n,r]),p=g.useCallback(async T=>{const z=u.current.quickAsk,P=(z==null?void 0:z.sessionId)===T;try{await Cq(n,{sessionId:T,stillEphemeral:P&&Cd(z)})&&o(A=>jq(A))}catch(B){Me("quick-ask","promote failed",B)}},[n]),m=g.useCallback(T=>{o(z=>Lq(z,T))},[]),v=g.useCallback(T=>{o(z=>Bq(z,T))},[]),w=g.useCallback(()=>{const T=u.current.quickAsk;Cd(T)&&n.sessionDelete(T.sessionId).catch(()=>{}),o(z=>Dq(z))},[n]),_=g.useCallback(T=>{o(z=>Oq(z,T))},[]);g.useEffect(()=>()=>{d.current=!0;const T=u.current.quickAsk;Cd(T)&&n.sessionDelete(T.sessionId).catch(()=>{})},[]);const x=Ui("sessions")??[],b=s.quickAsk?x.find(T=>T.sessionId===s.quickAsk.sessionId)??{sessionId:s.quickAsk.sessionId,cwd:r.cwd,tool:r.tool}:null,S=g.useCallback(async T=>{const z=await zy(n,i,r.sessionId,T,60),P=await fetch(z);if(!P.ok)throw new Error(`fetch ${P.status} ${P.statusText}`);return P.text()},[n,i,r.sessionId]),C=h.jsx(S4,{state:e,extras:t,onQuickAskInternal:f,onPreviewMdInternal:m}),{initialSize:k,setSize:N}=Rq("chat-panel-right-slot-width",480);return h.jsxs(Oy,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:[h.jsx(df,{id:"chat",minSize:"400px",children:h.jsxs("div",{className:"relative flex flex-col min-w-0 min-h-0 h-full",children:[C,a?h.jsxs("div",{"data-testid":"quick-ask-error",className:"absolute bottom-24 left-1/2 z-10 -translate-x-1/2 max-w-[90%] rounded-md border border-border bg-bg-200 px-3 py-2 text-[12px] text-text-300 shadow-lg",children:[h.jsxs("span",{className:"mr-2",children:["问一下没能打开:",a]}),h.jsx("button",{type:"button","aria-label":"关闭提示",onClick:()=>l(null),className:"text-text-400 hover:text-text-200 cursor-pointer",children:"✕"})]}):null]})}),xM(s)?h.jsxs(h.Fragment,{children:[h.jsx(hM,{className:"w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),h.jsx(df,{id:"right-slot",defaultSize:`${k}px`,minSize:"360px",maxSize:"800px",onResize:T=>N(T.inPixels),children:h.jsx(hae,{state:s,api:n,onSwitchTab:v,onCloseQuickAsk:w,onCloseMd:_,loadMarkdown:S,quickAskSession:b,...c?{onPromoteQuickAsk:p}:{}})})]}):null]})}function mae({extras:e}){const t=_M(e.session.sessionId);return h.jsx(pae,{state:t,extras:e})}function gae(e,t,n){const r=e?t.find(s=>s.id===e):void 0;if(r!=null&&r.efforts&&r.efforts.length>0)return{options:r.efforts,defaultValue:r.defaultEffort??""};const i=n.find(s=>s.name==="effort");return{options:(i==null?void 0:i.options)??[],defaultValue:typeof(i==null?void 0:i.default)=="string"?i.default:""}}function vae(e,t,n){var l;if(!t)return((l=(e??[]).find(c=>c.id===""))==null?void 0:l.label)??"未指定";const r=t.toLowerCase(),i=[["opus","Opus"],["fable","Fable"],["sonnet","Sonnet"],["haiku","Haiku"]];for(const[c,u]of i){if(!r.includes(c))continue;const d=r.match(new RegExp(`${c}-(\\d+)(?:-(\\d+))?`));return d?d[2]?`${u} ${d[1]}.${d[2]}`:`${u} ${d[1]}`:u}const s=e??[],o=s.find(c=>c.id===t);if(o)return o.label;const a=s.find(c=>c.id&&t.toLowerCase().includes(c.id.toLowerCase()));return a?a.label:t}function _ae(e,t){var m,v,w,_;const{models:n,modes:r,configSchema:i}=t,s=e.resolvedModel??e.model,o=gae(s,n,i),a=o.options,l=a.some(x=>x.value===e.effort)?e.effort:o.defaultValue,c=e.effort===""&&e.resolvedEffort?((m=a.find(x=>x.value===e.resolvedEffort))==null?void 0:m.label)??e.resolvedEffort:((v=a.find(x=>x.value===l))==null?void 0:v.label)??null,u=((w=i.find(x=>x.name==="permissionMode"))==null?void 0:w.default)??"",d=r.some(x=>x.id===e.permissionMode)?e.permissionMode:u,p=d===u?null:((_=r.find(x=>x.id===d))==null?void 0:_.label)??null;return{modelLabel:vae(n,s),effortOptions:a,effortValue:l,effortLabel:c,modeValue:d,modeLabel:p,modeTone:p===null?null:d==="bypassPermissions"?"danger":"info"}}function xae(e){let t;return e.map(n=>{const r=n.group&&n.group!==t?n.group:null;return n.group&&(t=n.group),{...n,groupHeading:r}})}function yae({models:e=[],modes:t=[],configSchema:n=[],model:r,resolvedModel:i,resolvedEffort:s,effort:o,permissionMode:a,onPatch:l}){var p;const c=_ae({model:r,resolvedModel:i,resolvedEffort:s,effort:o,permissionMode:a},{models:e,modes:t,configSchema:n}),u=i??r,d=e.map(m=>{const v=m.id===""&&i?`${m.description?`${m.description};`:""}当前:${i}`:m.description;return{value:m.id,label:m.label,...v?{description:v}:{},...m.group?{group:m.group}:{}}}),f=t.map(m=>({value:m.id,label:m.label,...m.description?{description:m.description}:{}}));return h.jsxs(AR,{children:[h.jsx(LR,{asChild:!0,children:h.jsxs("button",{type:"button","data-testid":"session-config-chip",title:"Model / reasoning effort / permission mode",className:"inline-flex items-center gap-1 h-7 px-2.5 rounded-full text-[11px] text-text-400 transition-colors outline-none cursor-pointer hover:bg-text-100/5 hover:text-text-200 data-[state=open]:bg-text-100/5",children:[h.jsx("span",{className:"truncate max-w-[120px]","data-testid":"session-config-chip-model",children:u||c.modelLabel}),c.effortLabel?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-500",children:"·"}),h.jsx("span",{className:"truncate max-w-[80px]","data-testid":"session-config-chip-effort",children:c.effortLabel})]}):null,c.modeLabel?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-500",children:"·"}),h.jsx("span",{"data-testid":"session-config-chip-mode","data-tone":c.modeTone,className:ne("font-semibold",c.modeTone==="danger"?"text-red-400":"text-blue-400"),children:c.modeLabel})]}):null]})}),h.jsxs(Cy,{side:"top",align:"end",className:"w-[230px]","data-testid":"session-config-menu",children:[h.jsx(Ig,{testid:"session-config-model",label:"Model",current:r,currentLabel:c.modelLabel,options:d,onSelect:m=>l({model:m})}),h.jsx(Ig,{testid:"session-config-effort",label:"Reasoning effort",current:c.effortValue,currentLabel:c.effortLabel??"—",options:c.effortOptions,onSelect:m=>l({effort:m})}),f.length>0?h.jsx(Ig,{testid:"session-config-mode",label:"Permission mode",current:c.modeValue,currentLabel:((p=t.find(m=>m.id===c.modeValue))==null?void 0:p.label)??"—",currentTone:c.modeTone,options:f,onSelect:m=>l({permissionMode:m})}):null]})]})}function Ig({testid:e,label:t,current:n,currentLabel:r,currentTone:i,options:s,onSelect:o}){const a=s.length===0;return h.jsxs(NW,{children:[h.jsxs(DR,{"data-testid":e,disabled:a,className:"gap-2 text-[12px]",children:[h.jsx("span",{className:"flex-1 text-text-200",children:t}),h.jsx("span",{className:ne("truncate max-w-[100px]",i==="danger"?"text-red-400 font-semibold":i==="info"?"text-blue-400 font-semibold":"text-text-400"),children:r}),h.jsx(Bn,{className:"w-3.5 h-3.5 shrink-0 text-text-500"})]}),h.jsx(jR,{className:"w-[220px] max-h-[320px] overflow-y-auto",children:xae(s).map((l,c)=>{const u=l.value===n;return h.jsxs(Ge.Fragment,{children:[l.groupHeading?h.jsxs(h.Fragment,{children:[c>0?h.jsx(Ey,{}):null,h.jsx(OR,{"data-testid":`${e}-group`,children:l.groupHeading})]}):null,h.jsxs(co,{"data-testid":`${e}-option-${l.value||"default"}`,onSelect:()=>o(l.value),className:"items-start gap-2",children:[h.jsxs("span",{className:"flex-1 min-w-0",children:[h.jsx("span",{className:ne("block text-[12px]",u?"text-text-100 font-medium":"text-text-300"),children:l.label}),l.description?h.jsx("span",{className:"block text-[11px] text-text-400 mt-0.5",children:l.description}):null]}),u?h.jsx(bu,{className:"w-3.5 h-3.5 shrink-0 text-accent mt-0.5"}):null]})]},l.value||"default")})})]})}function bae(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitBranch(t);i(l.branch??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{branch:r,loading:s,refresh:()=>void a()}}function wae(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitRoot(t);i(l.gitRoot??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{worktreeRoot:r,loading:s,refresh:()=>void a()}}const Sae=5e3;function kae(e,t,n=0){const[r,i]=g.useState(null);return g.useEffect(()=>{if(!t){i(null);return}let s=!1;const o=async()=>{try{const l=await e.cloudVolumeGet();s||i(l.volume??null)}catch{s||i(null)}},a=n>0?setTimeout(()=>void o(),Sae):null;return a||o(),()=>{s=!0,a&&clearTimeout(a)}},[e,t,n]),{volume:r}}const Cae=90;function Eae(e){return e.sizeBytes>0?Math.min(100,Math.max(0,Math.round(e.usedBytes/e.sizeBytes*100))):0}function u2(e){const t=e/1073741824;return t>=.1?`${t.toFixed(1)} GB`:`${Math.max(1,Math.round(e/1024**2))} MB`}function Nae({volume:e}){if(!e)return null;const t=Eae(e),n=t>=Cae?"warn":"ok",r=new Date(e.measuredAt).toLocaleString(),i=n==="ok"?"上一次任务结束时量的。":"盘快满了:在会话里说「清理一下云盘」,persona 会分析工作区里哪些能删、列给你确认后清掉。";return h.jsxs("span",{"data-testid":"chat-header-cloud-volume","data-tone":n,title:`云盘已用 ${u2(e.usedBytes)} / ${u2(e.sizeBytes)}(${r})。${i}`,className:ne("ml-1.5 inline-flex items-center gap-1.5 px-1.5 py-0.5 rounded text-[11px] tabular-nums",n==="ok"&&"bg-text-100/10 text-text-400",n==="warn"&&"bg-warning-dim text-warning"),children:[h.jsx("span",{className:"relative inline-block w-8 h-1 rounded-full bg-current/20 overflow-hidden","aria-hidden":!0,children:h.jsx("span",{className:"absolute inset-y-0 left-0 rounded-full bg-current",style:{width:`${t}%`}})}),"云盘 ",t,"%"]})}function Tae({api:e,session:t,focused:n,totalPanes:r,onFocus:i,onClose:s,onNewSession:o,onOpenConfig:a,onFork:l,onQuickAsk:c,className:u,viewerRole:d="owner",hideHeader:f}){const{capabilities:p}=g1(t.tool),[m,v]=g.useState(0),{branch:w}=bae(e,t.cwd,m),{worktreeRoot:_}=wae(e,t.cwd,m),x=Bz(t.tool),{volume:b}=kae(e,x,m),S=r>1,C=k=>{e.sessionUpdate(t.sessionId,k).catch(N=>{console.error("[session-config] session:update failed",t.sessionId,N)})};return h.jsxs("div",{className:`group/pane relative flex-1 ${u??"flex"} flex-row min-w-0 min-h-0 overflow-hidden ${S?`rounded-md border transition-colors ${n?"border-accent ring-1 ring-accent":"border-border"}`:""}`,onMouseDown:i,"data-testid":`session-pane-${t.sessionId}`,children:[h.jsx(Oy,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:h.jsx(df,{id:"chat",minSize:"400px",children:h.jsx("div",{className:"flex flex-col min-w-0 min-h-0 h-full",children:h.jsx(Iae,{api:e,session:t,liveGitBranch:w,liveWorktreeRoot:_,...x&&b?{cloudVolume:h.jsx(Nae,{volume:b})}:{},onNewSession:o,onTurnEnd:()=>v(k=>k+1),onOpenConfig:a,onFork:l,onQuickAsk:c,viewerRole:d,hideHeader:f,configSlot:p?h.jsx(yae,{models:p.models,modes:p.permissionModes,configSchema:p.configSchema,model:t.model??"",...t.resolvedModel?{resolvedModel:t.resolvedModel}:{},...t.resolvedEffort?{resolvedEffort:t.resolvedEffort}:{},effort:t.effort??"",permissionMode:t.permissionMode??"",onPatch:C}):null})})})}),S&&h.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),s()},className:"absolute top-1.5 right-1.5 z-10 p-1 rounded-md bg-bg-100/80 backdrop-blur-sm border border-border opacity-0 group-hover/pane:opacity-100 transition-opacity text-text-400 hover:text-text-100 hover:bg-bg-200","aria-label":"close pane","data-testid":`session-pane-close-${t.sessionId}`,children:h.jsx(qr,{className:"w-3.5 h-3.5"})})]})}function Iae({api:e,session:t,liveGitBranch:n,liveWorktreeRoot:r,cloudVolume:i,onNewSession:s,onTurnEnd:o,onOpenConfig:a,onFork:l,onQuickAsk:c,viewerRole:u,configSlot:d,hideHeader:f}){return h.jsx(mae,{extras:{session:t,api:e,...n!==void 0?{liveGitBranch:n}:{},...r!==void 0?{liveWorktreeRoot:r}:{},...i!==void 0?{cloudVolume:i}:{},onNewSession:s,onTurnEnd:o,onOpenConfig:a,...l?{onFork:p=>{l(p)}}:{},...c?{onQuickAsk:p=>{c(p)}}:{},...u?{viewerRole:u}:{},...d?{configSlot:d}:{},...f?{hideHeader:f}:{}}})}function Pae({personas:e,sessions:t,api:n,selfPrincipalId:r,selectedPersonaId:i,selectedSessionId:s,selectedSession:o,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,onCloseSession:f}){return h.jsxs("div",{className:"flex h-screen min-h-0 bg-bg-50","data-testid":"guest-share-page",children:[h.jsx("aside",{className:"w-[280px] shrink-0 overflow-y-auto border-r border-border bg-bg-50",children:h.jsx(mV,{personas:e,sessions:t,activePersonaId:i,activeSessionId:s,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,showCopyResume:!1,treatSessionsAsRoots:!0,...r?{ownerPrincipalId:r}:{},isPersonaExpanded:()=>!0})}),h.jsx("main",{className:"flex-1 min-w-0 min-h-0 flex",children:o?h.jsx(Tae,{api:n,session:o,focused:!0,totalPanes:1,onFocus:()=>{},onClose:f,onNewSession:()=>{},onOpenConfig:()=>{},viewerRole:"guest"}):h.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-xs text-text-400","data-testid":"guest-share-empty",children:"选择左侧 persona 开始对话"})})]})}function Rae(){const e=Yi(),t=g.useMemo(()=>new Gx(e),[e]),n=w$(e),{sessions:r,refresh:i}=S$(n),{personas:s}=gI(),o=I$(),a=g.useMemo(()=>{const S=window.location.pathname.match(/^\/s\/([^/]+)/);return S?decodeURIComponent(S[1]):null},[]),l=g.useMemo(()=>r.filter(S=>!S.ephemeral&&S.larkChatId==null),[r]),c=g.useMemo(()=>a?s.filter(S=>S.personaId===a):s,[s,a]),[u,d]=g.useState(null),[f,p]=g.useState(null),[m,v]=g.useState(null);g.useEffect(()=>{let S=!1;return e.request("whoami",{}).then(C=>{S||d(C.capability.id)}).catch(()=>{}),()=>{S=!0}},[e]),g.useEffect(()=>{a&&p(a)},[a]);const w=g.useCallback(async(S,C)=>{const k=await t.sessionCreate({ownerPersonaId:S,...C.trim()?{label:C.trim()}:{}});await i(),p(S),v(k.sessionId)},[t,i]),_=g.useCallback(async S=>{await t.sessionDelete(S),await i(),v(C=>C===S?null:C)},[t,i]),x=g.useCallback(async(S,C)=>{await t.sessionUpdate(S,{label:C.label}),await i()},[t,i]),b=g.useMemo(()=>l.find(S=>S.sessionId===m)??null,[l,m]);return h.jsx(Yx.Provider,{value:o,children:h.jsx(Pae,{personas:c,sessions:l,api:t,selfPrincipalId:u,selectedPersonaId:f,selectedSessionId:m,selectedSession:b,onSelectPersona:p,onSelectSession:v,onCreateSession:(S,C)=>void w(S,C),onDeleteSession:S=>void _(S),onEditSession:(S,C)=>void x(S,C),onCloseSession:()=>v(null)})})}const d2="https://app.ttcadvisory.com";function Mae({onAuthed:e}){const[t,n]=g.useState(!1),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>()=>{s.current&&window.removeEventListener("message",s.current)},[]);const o=g.useCallback(()=>{s.current&&(window.removeEventListener("message",s.current),s.current=null),n(!0),i(null);const a=window.location.origin,l=`${d2}/auth/authorize?callback_url=${encodeURIComponent(a)}&auto=1`,c=async d=>{if(d.origin!==d2)return;const f=d.data;if((f==null?void 0:f.type)==="AUTH_CANCEL"){u(),n(!1);return}if(!((f==null?void 0:f.type)!=="AUTH_SUCCESS"||!f.token)){u();try{const p=await fetch(`${window.location.origin}/share/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ttcToken:f.token})});if(!p.ok){const v=await p.json().catch(()=>({}));throw new Error(v.code??`exchange failed (${p.status})`)}const m=await p.json();if(!m.visitorToken)throw new Error("no visitorToken in response");e(m.visitorToken)}catch(p){i(p instanceof Error?p.message:String(p)),n(!1)}}},u=()=>{window.removeEventListener("message",c),s.current=null};s.current=d=>void c(d),window.addEventListener("message",s.current),window.open(l,"ttc-login","width=480,height=640")},[e]);return h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 font-sans text-text-100","data-testid":"guest-login",children:h.jsxs("div",{className:"flex w-full max-w-xs flex-col gap-3 rounded-lg border border-border bg-bg-100 px-5 py-6",children:[h.jsx("h1",{className:"text-base font-semibold",children:"登录后进入分享"}),h.jsx("p",{className:"text-[11px] leading-snug text-text-400",children:"使用飞书账号登录,即可在浏览器里与分享给你的 persona 交互,无需安装。"}),r?h.jsxs("p",{className:"text-[11px] leading-snug text-error","data-testid":"guest-login-error",children:["登录失败:",r]}):null,h.jsx("button",{type:"button",disabled:t,onClick:()=>o(),"data-testid":"guest-login-button",className:"w-full rounded border border-border bg-bg-50 px-2 py-1.5 text-xs text-text-200 transition-colors hover:bg-text-100/5 hover:text-text-100 disabled:opacity-50",children:t?"请在弹窗中完成授权…":"飞书登录"})]})})}const P_="clawd-visitor:token";function Aae(e,t){const r=`${e.protocol==="https:"?"wss:":"ws:"}//${e.host}`;return t!=null&&t.devPath?`${r}${t.devPath}`:r}function Lae(){return{async getUrl(e){const t=localStorage.getItem(P_);if(!t)throw new Error("NO_VISITOR_TOKEN");const n=Aae(window.location,{});return await aI(e).upsert({id:"guest",name:"访客",mode:"remote",url:n,token:t}),{url:n}}}}function Dae(e){const t=n=>{document.documentElement.classList.toggle("dark",n==="dark")};return t(e.theme.mode),e.onThemeChange(n=>t(n.mode))}function jae(){const e=Yi(),t=g.useMemo(()=>b$(e),[e]);return h.jsx(n$,{cache:t.cache,children:h.jsx(s$,{children:h.jsx(Rae,{})})})}function Oae({host:e}){const[t]=g.useState(()=>localStorage.getItem(P_)),[n,r]=g.useState(!1),[i,s]=g.useState(null);return g.useEffect(()=>Dae(e),[e]),g.useEffect(()=>{if(!t)return;let o=!1;return Lae().getUrl(e).then(()=>{o||r(!0)}).catch(a=>{o||s(a instanceof Error?a.message:String(a))}),()=>{o=!0}},[e,t]),t?h.jsx(zb,{host:e,children:h.jsx(_w,{children:i?h.jsxs("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-center text-xs text-error","data-testid":"guest-share-connect-error",children:["连接失败:",i]}):n?h.jsx(Jz,{host:e,children:h.jsx(jae,{})}):h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-xs text-text-400",children:"正在连接…"})})}):h.jsx(zb,{host:e,children:h.jsx(_w,{children:h.jsx(Mae,{onAuthed:o=>{localStorage.setItem(P_,o),window.location.reload()}})})})}function Bae({filePath:e,oldString:t,newString:n,content:r}){const i=g.useMemo(()=>r!=null?r.split(/\r?\n/).map(s=>({type:"add",text:s})):zae(t??"",n??""),[t,n,r]);return h.jsxs("div",{"data-testid":"inline-diff",className:"min-w-0 max-w-full rounded-lg border border-bg-300/60 bg-bg-50 overflow-hidden text-[12px] font-mono",children:[h.jsx("div",{className:"flex min-w-0 items-center gap-2 px-3 py-1.5 border-b border-bg-300/40 bg-bg-100/30",children:h.jsx("span",{className:"min-w-0 text-text-400 truncate",title:e,children:e})}),h.jsx("div",{className:"max-h-[320px] max-w-full overflow-auto",children:i.map((s,o)=>h.jsxs("div",{"data-testid":`diff-line-${s.type}`,className:ne("flex min-w-max gap-2 px-3 py-0.5 whitespace-pre",s.type==="add"?"bg-success/10 text-success":s.type==="remove"?"bg-error/10 text-error":"text-text-300"),children:[h.jsx("span",{className:"w-3 shrink-0 select-none opacity-60",children:s.type==="add"?"+":s.type==="remove"?"-":" "}),h.jsx("span",{className:"flex-1",children:s.text||" "})]},o))})]})}function zae(e,t){const n=e.split(/\r?\n/),r=t.split(/\r?\n/),i=n.length,s=r.length,o=Array.from({length:i+1},()=>new Array(s+1).fill(0));for(let u=i-1;u>=0;u--)for(let d=s-1;d>=0;d--)o[u][d]=n[u]===r[d]?o[u+1][d+1]+1:Math.max(o[u+1][d],o[u][d+1]);const a=[];let l=0,c=0;for(;l<i&&c<s;)n[l]===r[c]?(a.push({type:"equal",text:n[l]}),l++,c++):o[l+1][c]>=o[l][c+1]?(a.push({type:"remove",text:n[l]}),l++):(a.push({type:"add",text:r[c]}),c++);for(;l<i;)a.push({type:"remove",text:n[l++]});for(;c<s;)a.push({type:"add",text:r[c++]});return a}function $ae({items:e}){return e.length===0?null:h.jsxs("div",{"data-testid":"todo-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-1.5",children:"Todos"}),h.jsx("ul",{className:"flex flex-col gap-1",children:e.map((t,n)=>{const r=t.status==="in_progress"&&t.activeForm||t.content;return h.jsxs("li",{"data-testid":`todo-item-${t.status}`,className:"flex items-start gap-2",children:[h.jsx(Fae,{status:t.status}),h.jsx("span",{className:ne("flex-1 leading-snug",t.status==="completed"?"text-text-400 line-through":t.status==="in_progress"?"text-text-100 font-medium":"text-text-200"),children:r})]},n)})})]})}function Fae({status:e}){return e==="completed"?h.jsx(Xx,{className:"w-3.5 h-3.5 text-success mt-0.5 shrink-0"}):e==="in_progress"?h.jsx(cr,{className:"w-3.5 h-3.5 text-warning mt-0.5 shrink-0 animate-spin"}):h.jsx(l8,{className:"w-3.5 h-3.5 text-text-400 mt-0.5 shrink-0"})}function Hae(e){const t=e??{};return Array.isArray(t.todos)?t.todos.map(n=>{if(!n||typeof n!="object")return null;const r=n,i=typeof r.content=="string"?r.content:"",s=r.status==="pending"||r.status==="in_progress"||r.status==="completed"?r.status:"pending",o=typeof r.activeForm=="string"?r.activeForm:void 0;return{content:i,status:s,activeForm:o}}).filter(n=>n!==null):[]}function Uae({description:e,prompt:t,subagentType:n}){return h.jsxs("div",{"data-testid":"task-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsxs("div",{className:"flex items-center gap-2 text-text-200 font-medium",children:[h.jsx(up,{className:"w-3.5 h-3.5 text-accent shrink-0"}),h.jsx("span",{className:"truncate",children:e||"subagent task"}),n?h.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded-md text-[10px] font-mono bg-accent/10 text-accent",children:n}):null]}),t?h.jsx("div",{className:"mt-1 text-[12px] text-text-400 leading-snug line-clamp-3",children:t}):null]})}function Wae(e){const t=e??{};return{description:typeof t.description=="string"?t.description:"",prompt:typeof t.prompt=="string"?t.prompt:void 0,subagentType:typeof t.subagent_type=="string"?t.subagent_type:void 0}}const Vae={render:({input:e})=>Ge.createElement($ae,{items:Hae(e)})},qae={render:({input:e})=>{const{description:t,prompt:n,subagentType:r}=Wae(e);return Ge.createElement(Uae,{description:t,prompt:n,subagentType:r})}},k4={render:({input:e,output:t,error:n,pending:r,fileScope:i,onShareFile:s,onOpenInTab:o,onPreviewMarkdown:a})=>{const l=Gae(e),c=l?Ge.createElement(Bae,{filePath:l.filePath,oldString:l.oldString,newString:l.newString,content:l.content}):void 0;return Ge.createElement(LA,{tool:Kae(e),input:e,output:t,error:n,pending:r,expandedBody:c,...i?{fileScope:i}:{},...s?{onShareFile:s}:{},...o?{onOpenInTab:o}:{},...a?{onPreviewMarkdown:a}:{}})}};function Kae(e){const t=e??{};return"content"in t&&t.content!==void 0?"Write":("old_string"in t&&t.old_string!==void 0,"Edit")}function Gae(e){const t=e??{},n=typeof t.file_path=="string"?t.file_path:null;if(!n)return null;const r=typeof t.old_string=="string"?t.old_string:void 0,i=typeof t.new_string=="string"?t.new_string:void 0,s=typeof t.content=="string"?t.content:void 0;return r==null&&i==null&&s==null?null:{filePath:n,oldString:r,newString:i,content:s}}kl.register("claude","TodoWrite",Vae);kl.register("claude","Task",qae);kl.register("claude","Edit",k4);kl.register("claude","Write",k4);const C4=document.getElementById("root");if(!C4)throw new Error("guest-main: #root not found");const Yae=rD({});Pg.createRoot(C4).render(h.jsx(Ge.StrictMode,{children:h.jsx(Oae,{host:Yae})}));
|