@clawos-dev/clawd 0.2.344 → 0.2.346
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/cli.cjs +14 -3
- package/dist/share-md-viewer-error.html +1 -1
- package/dist/share-md-viewer.html +1 -1
- package/dist/share-ui/assets/{guest-CKi1Ff96.js → guest-CuCYJfhF.js} +2 -2
- package/dist/share-ui/assets/{guest-DcTfIUG3.css → guest-D76btdbG.css} +1 -1
- package/dist/share-ui/guest.html +2 -2
- package/package.json +1 -1
|
@@ -472,7 +472,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
472
472
|
`)},Jw=function(){var e=parseInt(document.body.getAttribute(Ca)||"0",10);return isFinite(e)?e:0},e7=function(){g.useEffect(function(){return document.body.setAttribute(Ca,(Jw()+1).toString()),function(){var e=Jw()-1;e<=0?document.body.removeAttribute(Ca):document.body.setAttribute(Ca,e.toString())}},[])},t7=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;e7();var s=g.useMemo(function(){return Q9(i)},[i]);return g.createElement(Z9,{styles:J9(s,!t,i,n?"":"!important")})},f0=!1;if(typeof window<"u")try{var gd=Object.defineProperty({},"passive",{get:function(){return f0=!0,!0}});window.addEventListener("test",gd,gd),window.removeEventListener("test",gd,gd)}catch{f0=!1}var qo=f0?{passive:!1}:!1,n7=function(e){return e.tagName==="TEXTAREA"},XP=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!n7(e)&&n[t]==="visible")},r7=function(e){return XP(e,"overflowY")},i7=function(e){return XP(e,"overflowX")},eS=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=YP(e,r);if(i){var s=QP(e,r),o=s[1],a=s[2];if(o>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},s7=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},o7=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},YP=function(e,t){return e==="v"?r7(t):i7(t)},QP=function(e,t){return e==="v"?s7(t):o7(t)},a7=function(e,t){return e==="h"&&t==="rtl"?-1:1},l7=function(e,t,n,r,i){var s=a7(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=QP(e,a),m=p[0],v=p[1],b=p[2],_=v-b-s*m;(m||_)&&YP(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},vd=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},tS=function(e){return[e.deltaX,e.deltaY]},nS=function(e){return e&&"current"in e?e.current:e},c7=function(e,t){return e[0]===t[0]&&e[1]===t[1]},u7=function(e){return`
|
|
473
473
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
474
474
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
475
|
-
`)},d7=0,Ko=[];function h7(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState(d7++)[0],s=g.useState(GP)[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=A9([e.lockRef.current],(e.shards||[]).map(nS),!0).filter(Boolean);return v.forEach(function(b){return b.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),v.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(v,b){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var _=vd(v),x=n.current,y="deltaX"in v?v.deltaX:x[0]-_[0],w="deltaY"in v?v.deltaY:x[1]-_[1],k,C=v.target,N=Math.abs(y)>Math.abs(w)?"h":"v";if("touches"in v&&N==="h"&&C.type==="range")return!1;var T=window.getSelection(),B=T&&T.anchorNode,P=B?B===C||B.contains(C):!1;if(P)return!1;var A=eS(N,C);if(!A)return!0;if(A?k=N:(k=N==="v"?"h":"v",A=eS(N,C)),!A)return!1;if(!r.current&&"changedTouches"in v&&(y||w)&&(r.current=k),!k)return!0;var I=r.current||k;return l7(I,b,v,I==="h"?y:w)},[]),l=g.useCallback(function(v){var b=v;if(!(!Ko.length||Ko[Ko.length-1]!==s)){var _="deltaY"in b?tS(b):vd(b),x=t.current.filter(function(k){return k.name===b.type&&(k.target===b.target||b.target===k.shadowParent)&&c7(k.delta,_)})[0];if(x&&x.should){b.cancelable&&b.preventDefault();return}if(!x){var y=(o.current.shards||[]).map(nS).filter(Boolean).filter(function(k){return k.contains(b.target)}),w=y.length>0?a(b,y[0]):!o.current.noIsolation;w&&b.cancelable&&b.preventDefault()}}},[]),c=g.useCallback(function(v,b,_,x){var y={name:v,delta:b,target:_,should:x,shadowParent:f7(_)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(w){return w!==y})},1)},[]),u=g.useCallback(function(v){n.current=vd(v),r.current=void 0},[]),d=g.useCallback(function(v){c(v.type,tS(v),v.target,a(v,e.lockRef.current))},[]),f=g.useCallback(function(v){c(v.type,vd(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return Ko.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,qo),document.addEventListener("touchmove",l,qo),document.addEventListener("touchstart",u,qo),function(){Ko=Ko.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,qo),document.removeEventListener("touchmove",l,qo),document.removeEventListener("touchstart",u,qo)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(s,{styles:u7(i)}):null,p?g.createElement(t7,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function f7(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const p7=H9(KP,h7);var Qx=g.forwardRef(function(e,t){return g.createElement(up,Gr({},e,{ref:t,sideCar:p7}))});Qx.classNames=up.classNames;var p0=["Enter"," "],m7=["ArrowDown","PageUp","Home"],ZP=["ArrowUp","PageDown","End"],g7=[...m7,...ZP],v7={ltr:[...p0,"ArrowRight"],rtl:[...p0,"ArrowLeft"]},_7={ltr:["ArrowLeft"],rtl:["ArrowRight"]},bu="Menu",[Yc,x7,y7]=aP(bu),[Lo,JP]=Ao(bu,[y7,cp,BP]),wu=cp(),eI=BP(),[tI,Ds]=Lo(bu),[b7,Su]=Lo(bu),nI=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=wu(t),[l,c]=g.useState(null),u=g.useRef(!1),d=oi(s),f=lP(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(Xx,{...a,children:h.jsx(tI,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(b7,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};nI.displayName=bu;var w7="MenuAnchor",Zx=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=wu(n);return h.jsx(LP,{...i,...r,ref:t})});Zx.displayName=w7;var Jx="MenuPortal",[S7,rI]=Lo(Jx,{forceMount:void 0}),iI=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=Ds(Jx,t);return h.jsx(S7,{scope:t,forceMount:n,children:h.jsx($i,{present:n||s.open,children:h.jsx(Yx,{asChild:!0,container:i,children:r})})})};iI.displayName=Jx;var gr="MenuContent",[k7,ey]=Lo(gr),sI=g.forwardRef((e,t)=>{const n=rI(gr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Ds(gr,e.__scopeMenu),o=Su(gr,e.__scopeMenu);return h.jsx(Yc.Provider,{scope:e.__scopeMenu,children:h.jsx($i,{present:r||s.open,children:h.jsx(Yc.Slot,{scope:e.__scopeMenu,children:o.modal?h.jsx(C7,{...i,ref:t}):h.jsx(E7,{...i,ref:t})})})})}),C7=g.forwardRef((e,t)=>{const n=Ds(gr,e.__scopeMenu),r=g.useRef(null),i=qt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return WP(s)},[]),h.jsx(ty,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),E7=g.forwardRef((e,t)=>{const n=Ds(gr,e.__scopeMenu);return h.jsx(ty,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),N7=Gc("MenuContent.ScrollLock"),ty=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,b=Ds(gr,n),_=Su(gr,n),x=wu(n),y=eI(n),w=x7(n),[k,C]=g.useState(null),N=g.useRef(null),T=qt(t,N,b.onContentChange),B=g.useRef(0),P=g.useRef(""),A=g.useRef(0),I=g.useRef(null),R=g.useRef("right"),j=g.useRef(0),z=m?Qx:g.Fragment,$=m?{as:N7,allowPinchZoom:!0}:void 0,F=O=>{var ye,Fe;const E=P.current+O,H=w().filter(ue=>!ue.disabled),V=document.activeElement,L=(ye=H.find(ue=>ue.ref.current===V))==null?void 0:ye.textValue,ne=H.map(ue=>ue.textValue),ae=z7(ne,E,L),G=(Fe=H.find(ue=>ue.textValue===ae))==null?void 0:Fe.ref.current;(function ue(Ie){P.current=Ie,window.clearTimeout(B.current),Ie!==""&&(B.current=window.setTimeout(()=>ue(""),1e3))})(E),G&&setTimeout(()=>G.focus())};g.useEffect(()=>()=>window.clearTimeout(B.current),[]),dP();const D=g.useCallback(O=>{var H,V;return R.current===((H=I.current)==null?void 0:H.side)&&F7(O,(V=I.current)==null?void 0:V.area)},[]);return h.jsx(k7,{scope:n,searchRef:P,onItemEnter:g.useCallback(O=>{D(O)&&O.preventDefault()},[D]),onItemLeave:g.useCallback(O=>{var E;D(O)||((E=N.current)==null||E.focus(),C(null))},[D]),onTriggerLeave:g.useCallback(O=>{D(O)&&O.preventDefault()},[D]),pointerGraceTimerRef:A,onPointerGraceIntentChange:g.useCallback(O=>{I.current=O},[]),children:h.jsx(z,{...$,children:h.jsx($x,{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(ip,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(T9,{asChild:!0,...y,dir:_.dir,orientation:"vertical",loop:r,currentTabStopId:k,onCurrentTabStopIdChange:C,onEntryFocus:Pe(l,O=>{_.isUsingKeyboardRef.current||O.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(jP,{role:"menu","aria-orientation":"vertical","data-state":wI(b.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,V=O.ctrlKey||O.altKey||O.metaKey,L=O.key.length===1;H&&(O.key==="Tab"&&O.preventDefault(),!V&&L&&F(O.key));const ne=N.current;if(O.target!==ne||!g7.includes(O.key))return;O.preventDefault();const G=w().filter(ye=>!ye.disabled).map(ye=>ye.ref.current);ZP.includes(O.key)&&G.reverse(),O7(G)}),onBlur:Pe(e.onBlur,O=>{O.currentTarget.contains(O.target)||(window.clearTimeout(B.current),P.current="")}),onPointerMove:Pe(e.onPointerMove,Qc(O=>{const E=O.target,H=j.current!==O.clientX;if(O.currentTarget.contains(E)&&H){const V=O.clientX>j.current?"right":"left";R.current=V,j.current=O.clientX}}))})})})})})})});sI.displayName=gr;var T7="MenuGroup",ny=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{role:"group",...r,ref:t})});ny.displayName=T7;var P7="MenuLabel",oI=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{...r,ref:t})});oI.displayName=P7;var Jh="MenuItem",rS="menu.itemSelect",dp=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=Su(Jh,e.__scopeMenu),a=ey(Jh,e.__scopeMenu),l=qt(t,s),c=g.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(rS,{bubbles:!0,cancelable:!0});d.addEventListener(rS,p=>r==null?void 0:r(p),{once:!0}),oP(d,f),f.defaultPrevented?c.current=!1:o.onClose()}};return h.jsx(aI,{...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===" "||p0.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});dp.displayName=Jh;var aI=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=ey(Jh,n),a=eI(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(Yc.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:h.jsx(P9,{asChild:!0,...a,focusable:!r,children:h.jsx(Et.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:Pe(e.onPointerMove,Qc(m=>{r?o.onItemLeave(m):(o.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Pe(e.onPointerLeave,Qc(m=>o.onItemLeave(m))),onFocus:Pe(e.onFocus,()=>d(!0)),onBlur:Pe(e.onBlur,()=>d(!1))})})})}),I7="MenuCheckboxItem",lI=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return h.jsx(fI,{scope:e.__scopeMenu,checked:n,children:h.jsx(dp,{role:"menuitemcheckbox","aria-checked":ef(n)?"mixed":n,...i,ref:t,"data-state":sy(n),onSelect:Pe(i.onSelect,()=>r==null?void 0:r(ef(n)?!0:!n),{checkForDefaultPrevented:!1})})})});lI.displayName=I7;var cI="MenuRadioGroup",[R7,M7]=Lo(cI,{value:void 0,onValueChange:()=>{}}),uI=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=oi(r);return h.jsx(R7,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(ny,{...i,ref:t})})});uI.displayName=cI;var dI="MenuRadioItem",hI=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=M7(dI,e.__scopeMenu),s=n===i.value;return h.jsx(fI,{scope:e.__scopeMenu,checked:s,children:h.jsx(dp,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":sy(s),onSelect:Pe(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});hI.displayName=dI;var ry="MenuItemIndicator",[fI,A7]=Lo(ry,{checked:!1}),pI=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=A7(ry,n);return h.jsx($i,{present:r||ef(s.checked)||s.checked===!0,children:h.jsx(Et.span,{...i,ref:t,"data-state":sy(s.checked)})})});pI.displayName=ry;var L7="MenuSeparator",mI=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});mI.displayName=L7;var j7="MenuArrow",gI=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=wu(n);return h.jsx(DP,{...i,...r,ref:t})});gI.displayName=j7;var iy="MenuSub",[D7,vI]=Lo(iy),_I=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=Ds(iy,t),o=wu(t),[a,l]=g.useState(null),[c,u]=g.useState(null),d=oi(i);return g.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),h.jsx(Xx,{...o,children:h.jsx(tI,{scope:t,open:r,onOpenChange:d,content:c,onContentChange:u,children:h.jsx(D7,{scope:t,contentId:Ti(),triggerId:Ti(),trigger:a,onTriggerChange:l,children:n})})})};_I.displayName=iy;var Gl="MenuSubTrigger",xI=g.forwardRef((e,t)=>{const n=Ds(Gl,e.__scopeMenu),r=Su(Gl,e.__scopeMenu),i=vI(Gl,e.__scopeMenu),s=ey(Gl,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(Zx,{asChild:!0,...c,children:h.jsx(aI,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":wI(n.open),...e,ref:vu(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,Qc(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,Qc(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,b=v==="right",_=b?-5:5,x=f[b?"left":"right"],y=f[b?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+_,y:d.clientY},{x,y:f.top},{x:y,y:f.top},{x:y,y:f.bottom},{x,y:f.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Pe(e.onKeyDown,d=>{var p;const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||v7[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});xI.displayName=Gl;var yI="MenuSubContent",bI=g.forwardRef((e,t)=>{const n=rI(gr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Ds(gr,e.__scopeMenu),o=Su(gr,e.__scopeMenu),a=vI(yI,e.__scopeMenu),l=g.useRef(null),c=qt(t,l);return h.jsx(Yc.Provider,{scope:e.__scopeMenu,children:h.jsx($i,{present:r||s.open,children:h.jsx(Yc.Slot,{scope:e.__scopeMenu,children:h.jsx(ty,{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=_7[o.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});bI.displayName=yI;function wI(e){return e?"open":"closed"}function ef(e){return e==="indeterminate"}function sy(e){return ef(e)?"indeterminate":e?"checked":"unchecked"}function O7(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function B7(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function z7(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=B7(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 $7(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 F7(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return $7(n,t)}function Qc(e){return t=>t.pointerType==="mouse"?e(t):void 0}var H7=nI,U7=Zx,W7=iI,V7=sI,q7=ny,K7=oI,G7=dp,X7=lI,Y7=uI,Q7=hI,Z7=pI,J7=mI,eH=gI,tH=_I,nH=xI,rH=bI,hp="DropdownMenu",[iH]=Ao(hp,[JP]),wn=JP(),[sH,SI]=iH(hp),kI=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=wn(t),c=g.useRef(null),[u,d]=_u({prop:i,defaultProp:s??!1,onChange:o,caller:hp});return h.jsx(sH,{scope:t,triggerId:Ti(),triggerRef:c,contentId:Ti(),open:u,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(H7,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};kI.displayName=hp;var CI="DropdownMenuTrigger",EI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=SI(CI,n),o=wn(n);return h.jsx(U7,{asChild:!0,...o,children:h.jsx(Et.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:vu(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())})})})});EI.displayName=CI;var oH="DropdownMenuPortal",NI=e=>{const{__scopeDropdownMenu:t,...n}=e,r=wn(t);return h.jsx(W7,{...r,...n})};NI.displayName=oH;var TI="DropdownMenuContent",PI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=SI(TI,n),s=wn(n),o=g.useRef(!1);return h.jsx(V7,{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)"}})});PI.displayName=TI;var aH="DropdownMenuGroup",lH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(q7,{...i,...r,ref:t})});lH.displayName=aH;var cH="DropdownMenuLabel",II=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(K7,{...i,...r,ref:t})});II.displayName=cH;var uH="DropdownMenuItem",RI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(G7,{...i,...r,ref:t})});RI.displayName=uH;var dH="DropdownMenuCheckboxItem",MI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(X7,{...i,...r,ref:t})});MI.displayName=dH;var hH="DropdownMenuRadioGroup",fH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(Y7,{...i,...r,ref:t})});fH.displayName=hH;var pH="DropdownMenuRadioItem",mH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(Q7,{...i,...r,ref:t})});mH.displayName=pH;var gH="DropdownMenuItemIndicator",AI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(Z7,{...i,...r,ref:t})});AI.displayName=gH;var vH="DropdownMenuSeparator",LI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(J7,{...i,...r,ref:t})});LI.displayName=vH;var _H="DropdownMenuArrow",xH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(eH,{...i,...r,ref:t})});xH.displayName=_H;var yH=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,o=wn(t),[a,l]=_u({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return h.jsx(tH,{...o,open:a,onOpenChange:l,children:n})},bH="DropdownMenuSubTrigger",jI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(nH,{...i,...r,ref:t})});jI.displayName=bH;var wH="DropdownMenuSubContent",DI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(rH,{...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)"}})});DI.displayName=wH;var SH=kI,kH=EI,OI=NI,BI=PI,zI=II,$I=RI,FI=MI,CH=AI,HI=LI,EH=yH,UI=jI,WI=DI;const oy=SH,ay=kH,fp=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(OI,{children:h.jsx(BI,{ref:r,sideOffset:t,className:fe("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));fp.displayName=BI.displayName;const NH=EH,VI=g.forwardRef(({className:e,...t},n)=>h.jsx(UI,{ref:n,className:fe("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}));VI.displayName=UI.displayName;const qI=g.forwardRef(({className:e,...t},n)=>h.jsx(OI,{children:h.jsx(WI,{ref:n,className:fe("z-50 min-w-[6rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...t})}));qI.displayName=WI.displayName;const yi=g.forwardRef(({className:e,inset:t,...n},r)=>h.jsx($I,{ref:r,className:fe("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}));yi.displayName=$I.displayName;const TH=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>h.jsxs(FI,{ref:i,checked:n,className:fe("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(CH,{children:h.jsx(ul,{className:"h-3.5 w-3.5"})})}),t]}));TH.displayName=FI.displayName;const KI=g.forwardRef(({className:e,...t},n)=>h.jsx(HI,{ref:n,className:fe("-mx-1 my-1 h-px bg-border",e),...t}));KI.displayName=HI.displayName;const PH=g.forwardRef(({className:e,...t},n)=>h.jsx(zI,{ref:n,className:fe("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));PH.displayName=zI.displayName;function IH({tool:e,className:t}){const n=w8(e);return h.jsx("span",{"data-testid":n?`session-icon-${e}`:"session-icon-default","aria-label":n?zx(e):"未知引擎",className:fe("w-3.5 h-3.5 shrink-0 inline-flex items-center justify-center",rp(e),t),children:h.jsx(np,{tool:e,className:"w-full h-full"})})}function GI(e){return e.compositionActive||!!e.nativeIsComposing||e.keyCode===229}function XI(e){return e.key==="Enter"&&!e.shiftKey&&!GI(e)}function ku(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(XI({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 RH({open:e,initialLabel:t,placeholder:n,onSubmit:r,onCancel:i}){const[s,o]=g.useState(t);g.useEffect(()=>{e&&o(t)},[e,t]);const a=ku(()=>r({label:s.trim()}),i);return e?el.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":"session-edit-dialog-overlay",children:h.jsxs("div",{"data-testid":"session-edit-dialog",className:"w-[420px] max-w-[calc(100vw-32px)] rounded-2xl border border-text-100/[0.12] flex flex-col gap-4 p-5",style:{backgroundColor:"var(--bg-0)",boxShadow:"0 12px 40px rgba(0,0,0,0.04)"},onClick:l=>l.stopPropagation(),children:[h.jsx("div",{className:"text-[15px] font-semibold text-text-100",children:"Edit session"}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:"Label"}),h.jsx("input",{autoFocus:!0,type:"text",value:s,onChange:l=>o(l.target.value),...a,placeholder:n,"data-testid":"session-edit-dialog-label",className:"w-full px-3 py-2 text-[13px] bg-bg-50 border border-bg-300 rounded-lg focus:outline-none focus:border-text-300 transition-colors"})]}),h.jsxs("div",{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:()=>r({label:s.trim()}),"data-testid":"session-edit-dialog-save",className:"px-4 py-1.5 text-[12px] font-medium text-bg-0 rounded-lg bg-text-100 hover:bg-text-200 transition-colors cursor-pointer",children:"Save"})]})]})}),document.body):null}const MH={held:!1,indexBySessionId:new Map},AH=g.createContext(MH);function LH(){return g.useContext(AH)}const jH=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})),DH=[{id:"new-session",combo:{key:"n",mod:!0},label:"新建任务",description:"打开快捷新建弹窗",group:"通用",desktopOnly:!0},...jH,{id:"tab-prev",combo:{key:"ArrowLeft",mod:!0,shift:!0},label:"上一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"tab-next",combo:{key:"ArrowRight",mod:!0,shift:!0},label:"下一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"send-message",combo:{key:"Enter"},label:"发送消息",description:"在输入框中发送当前内容",group:"输入",displayOnly:!0},{id:"newline",combo:{key:"Enter",shift:!0},label:"换行",description:"在输入框中插入换行",group:"输入",displayOnly:!0},{id:"interrupt",combo:{key:"Escape"},label:"打断回复",description:"打断当前回复;2 秒内按两次停止任务",group:"输入",displayOnly:!0}];DH.filter(e=>!e.displayOnly);function OH(){return/Mac|iP(hone|od|ad)/.test(navigator.platform)}const BH=10,zH=20,$H=16,FH=20,HH=60,UH=4;function WH({session:e,active:t,hasUnread:n,running:r=!1,awaitingUser:i=!1,onSelect:s,onEdit:o,onDelete:a,onPin:l,onArchive:c,archiveShortcut:u=!1,depth:d=0,chevron:f,showCopyResume:p=!0,contactDisplayName:m}){const[v,b]=g.useState(!1),_=LH(),x=_.held?_.indexBySessionId.get(e.sessionId):void 0,y=!!e.pinnedAt,w=d===0,k=d===0&&!!c,C=BH+d*zH,N=g.useCallback(async()=>{const A=iP(e);if(A)try{await navigator.clipboard.writeText(A)}catch{}},[e]),T=e.appBuilderProject?`[app] ${e.appBuilderProject}`:e.label||e.larkChatName||e.larkChatId||e.cwd.split("/").filter(Boolean).pop()||e.sessionId.slice(0,8),B=e.originOwnerPrincipalId,P=B?`@${m??`…${B.slice(-8)}`}`:null;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":`session-item-${e.sessionId}`,onClick:s,style:{paddingLeft:C,display:"grid",gridTemplateColumns:`${$H}px ${FH}px 1fr auto ${HH}px`,gridTemplateAreas:'"chev icon name dot time"',columnGap:`${UH}px`,alignItems:"center"},className:fe("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(IH,{tool:e.tool})}),h.jsxs("div",{style:{gridArea:"name"},className:"flex items-center gap-1 min-w-0",children:[e.dispatchedFromSessionId?h.jsx(yz,{"data-testid":`dispatched-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"dispatched from another session",children:h.jsx("title",{children:"由另一个 session dispatch 派生"})}):null,e.shiftFiredFromSessionId?h.jsx(GB,{"data-testid":`shift-fired-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"fired by clawd-shift scheduler",children:h.jsx("title",{children:"由 shift 排班到点 fire 派生"})}):null,e.larkChatId?h.jsx(qz,{"data-testid":`lark-chat-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"driven by feishu chat",children:h.jsx("title",{children:e.larkChatType==="p2p"?"飞书私聊会话(对方消息驱动)":"飞书群会话(群成员 @ bot 驱动)"})}):null,h.jsx("span",{"data-testid":`session-title-${e.sessionId}`,className:fe("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:T}),P?h.jsx("span",{"data-testid":`session-mirror-chip-${e.sessionId}`,title:`在 ${P.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:P}):null]}),i?h.jsx(tz,{"data-testid":`awaiting-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-3 h-3 text-warning shrink-0 animate-pulse",strokeWidth:2.25,"aria-label":"awaiting user"}):n?h.jsx("span",{"data-testid":`unread-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-2 h-2 rounded-full bg-error shrink-0","aria-label":"unread"}):r?h.jsx("span",{"data-testid":`running-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-2 h-2 rounded-full bg-success shrink-0 animate-pulse","aria-label":"running"}):null,x!=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:OH()?`⌘${x}`:`Ctrl+${x}`})}):h.jsx("span",{style:{gridArea:"time"},className:fe("text-[11px] text-text-400/70 text-right shrink-0","transition-opacity duration-150 group-hover:opacity-0"),children:e.updatedAt?S8(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:[u&&k&&c?h.jsx("button",{type:"button",title:"归档",onClick:A=>{A.stopPropagation(),c(e.sessionId,!0)},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":"archive session","data-testid":`archive-shortcut-${e.sessionId}`,children:h.jsx(kw,{className:"w-4 h-4"})}):null,h.jsxs(oy,{modal:!1,children:[h.jsx(ay,{asChild:!0,children:h.jsx("button",{type:"button",onClick:A=>A.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(LT,{className:"w-4 h-4"})})}),h.jsxs(fp,{align:"end",onClick:A=>A.stopPropagation(),children:[l&&w&&h.jsxs(yi,{onSelect:()=>l(e.sessionId,!y),"data-testid":`session-${y?"unpin":"pin"}-${e.sessionId}`,children:[y?h.jsx(t$,{className:"w-3 h-3 mr-2 text-text-400"}):h.jsx(r$,{className:"w-3 h-3 mr-2 text-text-400"}),y?"Unpin":"Pin"]}),k&&c&&h.jsxs(yi,{onSelect:()=>c(e.sessionId,!0),"data-testid":`session-archive-${e.sessionId}`,children:[h.jsx(kw,{className:"w-3 h-3 mr-2 text-text-400"}),"Archive"]}),o&&h.jsxs(yi,{onSelect:()=>b(!0),"data-testid":`session-rename-${e.sessionId}`,children:[h.jsx(OT,{className:"w-3 h-3 mr-2 text-text-400"}),"Rename"]}),p&&e.toolSessionId?h.jsxs(yi,{onSelect:()=>void N(),"data-testid":`session-copy-resume-${e.sessionId}`,children:[h.jsx(tp,{className:"w-3 h-3 mr-2 text-text-400"}),"Copy Resume Command"]}):null,(l||o||p&&e.toolSessionId)&&a&&h.jsx(KI,{}),a&&h.jsxs(yi,{onSelect:()=>void a(e.sessionId),className:"text-destructive focus:text-destructive focus:bg-destructive/10","data-testid":`session-delete-${e.sessionId}`,children:[h.jsx(Dx,{className:"w-3 h-3 mr-2"}),"Delete"]})]})]})]}):null]}),o?h.jsx(RH,{open:v,initialLabel:e.label??"",placeholder:e.cwd.split("/").pop()||"",onSubmit:A=>{o(e.sessionId,A),b(!1)},onCancel:()=>b(!1)}):null]})}function ly({node:e,depth:t=0,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,archiveShortcut:d,getContactDisplayName:f,showCopyResume:p}){const m=e.children.length>0,{isCollapsed:v,toggle:b}=FB(),_=!v(e.session.sessionId),x=g.useCallback(w=>{w.stopPropagation(),b(e.session.sessionId)},[b,e.session.sessionId]),y=m?h.jsx("button",{type:"button",onClick:x,"data-testid":`session-chevron-${e.session.sessionId}`,"aria-label":_?"collapse":"expand","aria-expanded":_,className:"shrink-0 flex items-center justify-center w-4 h-4 text-text-400 hover:text-text-100 cursor-pointer",children:_?h.jsx(ir,{className:"w-3 h-3"}):h.jsx(Un,{className:"w-3 h-3"})}):null;return h.jsxs("div",{"data-testid":`session-tree-node-${e.session.sessionId}`,children:[h.jsx(WH,{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,archiveShortcut:d,showCopyResume:p,depth:t,chevron:y,contactDisplayName:e.session.originOwnerPrincipalId?f==null?void 0:f(e.session.originOwnerPrincipalId):void 0}),m&&_?h.jsx("div",{"data-testid":`session-tree-children-${e.session.sessionId}`,children:e.children.map(w=>h.jsx(ly,{node:w,depth:t+1,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,archiveShortcut:d,getContactDisplayName:f,showCopyResume:p},w.session.sessionId))}):null]})}function VH(e){return e.forkedFromSessionId??e.dispatchedFromSessionId??e.shiftFiredFromSessionId}function YI(e){e=e.filter(s=>!s.ephemeral);const t=new Map;for(const s of e)t.set(s.sessionId,s);const n=new Map,r=[];for(const s of e){const o=VH(s);if(o&&t.has(o)){const a=n.get(o)??[];a.push(s),n.set(o,a)}else r.push(s)}const i=s=>{const a=[...n.get(s.sessionId)??[]].sort((l,c)=>l.createdAt<c.createdAt?-1:l.createdAt>c.createdAt?1:0);return{session:s,children:a.map(i)}};return[...r].sort(qH).map(i)}function QI(e){return[...e].sort((t,n)=>t.session.updatedAt<n.session.updatedAt?1:t.session.updatedAt>n.session.updatedAt?-1:0)}function qH(e,t){const n=typeof e.pinnedAt=="number",r=typeof t.pinnedAt=="number";if(n&&r){const i=typeof e.pinSortOrder=="number",s=typeof t.pinSortOrder=="number";return i&&s?e.pinSortOrder-t.pinSortOrder:i?-1:s?1:t.pinnedAt-e.pinnedAt}return n?-1:r||e.updatedAt<t.updatedAt?1:e.updatedAt>t.updatedAt?-1:0}function KH(e){return e.appBuilderProject?`[app] ${e.appBuilderProject}`:e.label?e.label:e.cwd.split("/").filter(Boolean).pop()??""}function iS(e,t){const n=t.trim().toLowerCase();return n===""?!0:e.toLowerCase().includes(n)}const GH={isCollapsed:()=>!1,toggle:()=>{},prune:()=>{}};function XH({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:b,showCopyResume:_,treatSessionsAsRoots:x,searchQuery:y}){const[w,k]=g.useState(null),[C,N]=g.useState(()=>new Set),T=p??(I=>C.has(I)),B=g.useCallback(I=>{if(m){m(I);return}N(R=>{const j=new Set(R);return j.has(I)?j.delete(I):j.add(I),j})},[m]),P=g.useMemo(()=>i==null?void 0:i.filter(I=>!I.ephemeral),[i]);if(e.length===0)return h.jsx(YH,{});const A=(y??"").trim();return A?h.jsx(Ax.Provider,{value:GH,children:h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(I=>{const R=P?P.filter(F=>F.ownerPersonaId===I.personaId).sort((F,D)=>D.updatedAt>F.updatedAt?1:-1):[],j=iS(I.label,A),z=R.filter(F=>iS(KH(F),A));if(!j&&z.length===0)return null;const $=j?R:z;return h.jsx(sS,{persona:I,active:I.personaId===t,editing:!1,onSelectPersona:n,onSubmitCreateSession:()=>{},onCancelCreateSession:()=>{},personaSessions:$,collapsed:!1,onToggleCollapsed:()=>{},activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:b,showCopyResume:_,treatSessionsAsRoots:x,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f},I.personaId)})})}):h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(I=>{const R=P?P.filter(j=>j.ownerPersonaId===I.personaId).sort((j,z)=>z.updatedAt>j.updatedAt?1:-1):[];return h.jsx(sS,{persona:I,active:I.personaId===t,editing:I.personaId===w,onSelectPersona:n,onStartCreateSession:r?()=>k(I.personaId):void 0,onSubmitCreateSession:j=>{k(null),r==null||r(I.personaId,j)},onCancelCreateSession:()=>k(null),personaSessions:R,collapsed:!T(I.personaId),onToggleCollapsed:()=>B(I.personaId),activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:b,showCopyResume:_,treatSessionsAsRoots:x,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f},I.personaId)})})}function YH(){return h.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-text-400",children:"还没有 persona。点上方 Personas 标题右侧 + 创建第一个。"})}function sS({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:b,onPinSession:_,showCopyResume:x,treatSessionsAsRoots:y,ownerPrincipalId:w,creatorDisplayNameByOwnerId:k}){const C=a.length>0,N=!l,T=g.useMemo(()=>{const A=[],I=new Map;for(const R of a){const j=R.creatorPrincipalId;if(R.larkChatId!=null||!j||w&&j===w){A.push(R);continue}const z=j,$=(k==null?void 0:k.get(z))??`…${z.slice(-8)}`,F=I.get(z);F?F.sessions.push(R):I.set(z,{groupKey:z,displayName:$,sessions:[R]})}return{self:A,byPeer:[...I.values()]}},[a,w,k]),B=T.byPeer.length>0,P=g.useMemo(()=>N&&!B?QI(YI(a)):[],[N,B,a]);return h.jsxs("div",{"data-testid":`persona-node-${e.personaId}`,children:[h.jsxs("div",{className:fe("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:[C?h.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),c()},"aria-label":N?"collapse":"expand","aria-expanded":N,"data-testid":`persona-chevron-${e.personaId}`,className:"flex h-4 w-4 shrink-0 items-center justify-center text-text-400 hover:text-text-100",children:N?h.jsx(ir,{className:"h-3 w-3"}):h.jsx(Un,{className:"h-3 w-3"})}):h.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),h.jsx(np,{tool:e.tool,className:fe("h-3.5 w-3.5 shrink-0",rp(e.tool))}),h.jsx("span",{className:"flex-1 truncate text-[13px]",children:e.label}),C?h.jsx("span",{className:"shrink-0 text-[10px] text-text-400 tabular-nums","aria-label":`${a.length} sessions`,children:a.length}):null,i?h.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),i()},"aria-label":"新建会话",title:"新建会话","data-testid":`persona-create-session-${e.personaId}`,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded text-text-400 opacity-0 hover:bg-text-100/10 hover:text-text-100 focus-visible:opacity-100 group-hover:opacity-100",children:h.jsx(a$,{className:"h-3.5 w-3.5"})}):null]}),n?h.jsx(QH,{personaId:e.personaId,tool:e.tool,onSubmit:s,onCancel:o}):null,C&&N?h.jsx("div",{"data-testid":`persona-sessions-${e.personaId}`,children:B?h.jsxs(h.Fragment,{children:[T.self.length>0&&h.jsx(oS,{groupKey:`${e.personaId}-self`,label:"我自己",testId:`persona-sessions-${e.personaId}-self`,sessions:T.self,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:_,showCopyResume:x}),T.byPeer.map(A=>h.jsx(oS,{groupKey:`${e.personaId}-peer-${A.groupKey}`,label:A.displayName,testId:`persona-sessions-${e.personaId}-peer-${A.groupKey}`,sessions:A.sessions,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:_,showCopyResume:x},`${e.personaId}-peer-${A.groupKey}`))]}):P.map(A=>h.jsx(ly,{node:A,depth:y?0:1,activeId:u,unreadIds:p,runningIds:f,awaitingIds:d,onSelect:I=>m==null?void 0:m(I),onDelete:v,onEdit:b,onPin:_,showCopyResume:x},A.session.sessionId))}):null]})}function oS({label:e,testId:t,sessions:n,activeSessionId:r,awaitingIds:i,runningIds:s,unreadIds:o,onSelectSession:a,onDeleteSession:l,onEditSession:c,onPinSession:u,showCopyResume:d}){const[f,p]=g.useState(!1),m=!f,v=g.useMemo(()=>m?QI(YI(n)):[],[m,n]);return h.jsxs("div",{"data-testid":t,children:[h.jsxs("button",{type:"button",onClick:()=>p(b=>!b),"aria-label":m?"collapse":"expand","aria-expanded":m,"data-testid":`${t}-chevron`,className:"flex items-center gap-1 w-full pl-7 pr-2 py-0.5 text-[11px] text-text-400 hover:text-text-200 transition-colors",children:[m?h.jsx(ir,{className:"h-3 w-3"}):h.jsx(Un,{className:"h-3 w-3"}),h.jsx($T,{className:"h-3 w-3","aria-hidden":!0}),h.jsx("span",{className:"truncate",children:e}),h.jsx("span",{className:"ml-auto tabular-nums",children:n.length})]}),m&&h.jsx("div",{children:v.map(b=>h.jsx(ly,{node:b,depth:2,activeId:r,unreadIds:o,runningIds:s,awaitingIds:i,onSelect:_=>a==null?void 0:a(_),onDelete:l,onEdit:c,onPin:u,showCopyResume:d},b.session.sessionId))})]})}function QH({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=ku(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(np,{tool:t,className:fe("h-3 w-3 shrink-0",rp(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(ul,{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(Dr,{className:"h-3 w-3"})})]})}function ZH(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function JH(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),r=parseFloat(n.fontSize);return t*r}function eU(e){return e/100*window.innerHeight}function tU(e){return e/100*window.innerWidth}function nU(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 Xl({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=nU(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=JH(t,i);break}case"em":{r=ZH(t,i);break}case"vh":{r=eU(i);break}case"vw":{r=tU(i);break}}return r}function Nn(e){return parseFloat(e.toFixed(3))}function Ha({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 m0(e){const{panels:t}=e,n=Ha({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=Xl({groupSize:n,panelElement:i,styleProp:s.collapsedSize});o=Nn(u/n*100)}let a;if(s.defaultSize!==void 0){const u=Xl({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=Nn(u/n*100)}let l=0;if(s.minSize!==void 0){const u=Xl({groupSize:n,panelElement:i,styleProp:s.minSize});l=Nn(u/n*100)}let c=100;if(s.maxSize!==void 0){const u=Xl({groupSize:n,panelElement:i,styleProp:s.maxSize});c=Nn(u/n*100)}return{groupResizeBehavior:s.groupResizeBehavior,collapsedSize:o,collapsible:s.collapsible===!0,defaultSize:a,disabled:s.disabled,minSize:l,maxSize:c,panelId:r.id}})}function rt(e,t="Assertion error"){if(!e)throw Error(t)}function g0(e,t){return Array.from(t).sort(e==="horizontal"?rU:iU)}function rU(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function iU(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function ZI(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function JI(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 sU({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}=JI(r,o),c=e==="horizontal"?a:l;c<s&&(s=c,i=o)}return rt(i,"No rect found"),i}let _d;function oU(){return _d===void 0&&(typeof matchMedia=="function"?_d=!!matchMedia("(pointer:coarse)").matches:_d=!1),_d}function eR(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=g0(n,Array.from(t.children).filter(ZI).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 b=r.find(_=>_.element===v);if(b){if(f){const _=f.element.getBoundingClientRect(),x=v.getBoundingClientRect();let y;if(l){const w=n==="horizontal"?new DOMRect(_.right,_.top,0,_.height):new DOMRect(_.left,_.bottom,_.width,0),k=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:{y=[w,k];break}case 1:{const C=p[0],N=sU({orientation:n,rects:[_,x],targetRect:C.element.getBoundingClientRect()});y=[C,N===_?k:w];break}default:{y=p;break}}}else p.length?y=p:y=[n==="horizontal"?new DOMRect(_.right,x.top,x.left-_.right,x.height):new DOMRect(x.left,_.bottom,x.width,x.top-_.bottom)];for(const w of y){let k="width"in w?w:w.element.getBoundingClientRect();const C=oU()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(k.width<C){const T=C-k.width;k=new DOMRect(k.x-T/2,k.y,k.width+T,k.height)}if(k.height<C){const T=C-k.height;k=new DOMRect(k.x,k.y-T/2,k.width,k.height+T)}const N=m<=c||m>u;!a&&!N&&o.push({group:e,groupSize:Ha({group:e}),panels:[f,b],separator:"width"in w?void 0:w,rect:k}),a=!1}}l=!1,f=b,p=[]}}else if(v.hasAttribute("data-separator")){v.ariaDisabled!==null&&(a=!0);const b=i.find(_=>_.element===v);b?p.push(b):(f=void 0,p=[])}else l=!0}return o}var cs;class tR{constructor(){h1(this,cs,{})}addListener(t,n){const r=wl(this,cs)[t];return r===void 0?wl(this,cs)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=wl(this,cs)[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(){f1(this,cs,{})}removeListener(t,n){const r=wl(this,cs)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}cs=new WeakMap;let Ea={cursorFlags:0,state:"inactive"};const cy=new tR;function xo(){return Ea}function aU(e){return cy.addListener("change",e)}function lU(e){const t=Ea,n={...Ea};n.cursorFlags=e,Ea=n,cy.emit("change",{prev:t,next:n})}function Na(e){const t=Ea;Ea=e,cy.emit("change",{prev:t,next:e})}const cU=e=>e,Dm=()=>{},nR=1,rR=2,iR=4,sR=8,aS=3,lS=12;let xd;function cS(){return xd===void 0&&(xd=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(xd=!0)),xd}function uU({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&&cS()){const s=(e&nR)!==0,o=(e&rR)!==0,a=(e&iR)!==0,l=(e&sR)!==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 cS()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const uS=new WeakMap;function uy(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=uS.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=xo();switch(r.state){case"active":case"hover":{const i=uU({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}}uS.set(e,{prevStyle:t,styleSheet:n})}let Yr=new Map;const oR=new tR;function dU(e){Yr=new Map(Yr),Yr.delete(e)}function dS(e,t){for(const[n]of Yr)if(n.id===e)return n}function Ss(e,t){for(const[n,r]of Yr)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function jo(){return Yr}function dy(e,t){return oR.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function Di(e,t,n){const r=Yr.get(e);Yr=new Map(Yr),Yr.set(e,t),oR.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:r,next:t})}function aR(e){const t=xo();let n=!1;switch(t.state){case"active":Na({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(uy(e),n=!0,t.hitRegions.forEach(r=>{const i=Ss(r.group.id,!0);Di(r.group,i,{isUserInteraction:!0})}))}return n}function hS(e){e.defaultPrevented||aR(e.currentTarget)}function hU(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const o=JI(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 fU(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function pU(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:mS(e),b:mS(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();rt(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:pS(fS(n.a)),b:pS(fS(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 mU=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function gU(e){const t=getComputedStyle(lR(e)??e).display;return t==="flex"||t==="inline-flex"}function vU(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||gU(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"||mU.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function fS(e){let t=e.length;for(;t--;){const n=e[t];if(rt(n,"Missing node"),vU(n))return n}return null}function pS(e){return e&&Number(getComputedStyle(e).zIndex)||0}function mS(e){const t=[];for(;e;)t.push(e),e=lR(e);return t}function lR(e){const{parentNode:t}=e;return fU(t)?t.host:t}function _U(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 xU({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!ZI(n)||n.contains(e)||e.contains(n))return!0;if(pU(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(_U(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function hy(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=eR(i),o=hU(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&xU({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function yU(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function _n(e,t,n=0){return Math.abs(Nn(e)-Nn(t))<=n}function qr(e,t){return _n(e,t)?0:e>t?1:-1}function ma({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){const{collapsedSize:i=0,collapsible:s,disabled:o,maxSize:a=100,minSize:l=0}=t;if(o&&!e)return n;if(qr(r,l)<0)if(s){const c=(i+l)/2;qr(r,c)<0?r=i:r=l}else r=l;return r=Math.min(a,r),r=Nn(r),r}function Zc({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(_n(e,0))return t;const o=s==="imperative-api",a=Object.values(t),l=Object.values(i),c=[...a],[u,d]=r;rt(u!=null,"Invalid first pivot index"),rt(d!=null,"Invalid second pivot index");let f=0;switch(s){case"keyboard":{{const v=e<0?d:u,b=n[v];rt(b,`Panel constraints not found for index ${v}`);const{collapsedSize:_=0,collapsible:x,minSize:y=0}=b;if(x){const w=a[v];if(rt(w!=null,`Previous layout not found for panel index ${v}`),_n(w,_)){const k=y-w;qr(k,Math.abs(e))>0&&(e=e<0?0-k:k)}}}{const v=e<0?u:d,b=n[v];rt(b,`No panel constraints found for index ${v}`);const{collapsedSize:_=0,collapsible:x,minSize:y=0}=b;if(x){const w=a[v];if(rt(w!=null,`Previous layout not found for panel index ${v}`),_n(w,y)){const k=w-_;qr(k,Math.abs(e))>0&&(e=e<0?0-k:k)}}}break}default:{const v=e<0?d:u,b=n[v];rt(b,`Panel constraints not found for index ${v}`);const _=a[v],{collapsible:x,collapsedSize:y,minSize:w}=b;if(x&&qr(_,w)<0)if(e>0){const k=w-y,C=k/2,N=_+e;qr(N,w)<0&&(e=qr(e,C)<=0?0:k)}else{const k=w-y,C=100-k/2,N=_-e;qr(N,w)<0&&(e=qr(100+e,C)>0?0:-k)}break}}{const v=e<0?1:-1;let b=e<0?d:u,_=0;for(;;){const y=a[b];rt(y!=null,`Previous layout not found for panel index ${b}`);const w=ma({overrideDisabledPanels:o,panelConstraints:n[b],prevSize:y,size:100})-y;if(_+=w,b+=v,b<0||b>=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 b=Math.abs(e)-Math.abs(f),_=a[v];rt(_!=null,`Previous layout not found for panel index ${v}`);const x=_-b,y=ma({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:_,size:x});if(!_n(_,y)&&(f+=_-y,c[v]=y,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?v--:v++}}if(yU(l,c))return i;{const v=e<0?d:u,b=a[v];rt(b!=null,`Previous layout not found for panel index ${v}`);const _=b+f,x=ma({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:b,size:_});if(c[v]=x,!_n(x,_)){let y=_-x,w=e<0?d:u;for(;w>=0&&w<n.length;){const k=c[w];rt(k!=null,`Previous layout not found for panel index ${w}`);const C=k+y,N=ma({overrideDisabledPanels:o,panelConstraints:n[w],prevSize:k,size:C});if(_n(k,N)||(y-=N-k,c[w]=N),_n(y,0))break;e>0?w--:w++}}}const p=Object.values(c).reduce((v,b)=>b+v,0);if(!_n(p,100,.1))return i;const m=Object.keys(i);return c.reduce((v,b,_)=>(v[m[_]]=b,v),{})}function yo(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||qr(e[n],t[n])!==0)return!1;return!0}function bo({layout:e,panelConstraints:t}){const n=Object.values(e),r=[...n],i=r.reduce((a,l)=>a+l,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(a=>`${a}%`).join(", ")}`);if(!_n(i,100)&&r.length>0)for(let a=0;a<t.length;a++){const l=r[a];rt(l!=null,`No layout data found for index ${a}`);const c=100/i*l;r[a]=c}let s=0;for(let a=0;a<t.length;a++){const l=n[a];rt(l!=null,`No layout data found for index ${a}`);const c=r[a];rt(c!=null,`No layout data found for index ${a}`);const u=ma({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});c!=u&&(s+=c-u,r[a]=u)}if(!_n(s,0))for(let a=0;a<t.length;a++){const l=r[a];rt(l!=null,`No layout data found for index ${a}`);const c=l+s,u=ma({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});if(l!==u&&(s-=u-l,r[a]=u,_n(s,0)))break}const o=Object.keys(e);return r.reduce((a,l,c)=>(a[o[c]]=l,a),{})}function cR({groupId:e,panelId:t}){const n=()=>{const l=jo();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(b=>b.id===t),m=p===0,v=p===c.length-1;if(v&&l<f&&(m||c.slice(0,p).every((b,_)=>{const x=d[_];return(x==null?void 0:x.collapsible)&&_n(x.collapsedSize,u[x.panelId])}))){const b=c.slice(0,p).reduce((_,x)=>_+u[x.id],0);return{...u,[t]:Nn(100-b)}}return Zc({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(),b=o({nextSize:l,panels:f.panels,prevLayout:m,derivedPanelConstraints:d}),_=bo({layout:b,panelConstraints:d});yo(m,_)||Di(f,{defaultLayoutDeferred:u,derivedPanelConstraints:d,groupSize:p,layout:_,separatorToPanels:v})};return{collapse:()=>{const{collapsible:l,collapsedSize:c}=r(),{mutableValues:u}=i(),d=s();l&&d!==c&&(u.expandToSize=d,a(c))},expand:()=>{const{collapsible:l,collapsedSize:c,minSize:u}=r(),{mutableValues:d}=i(),f=s();if(l&&f===c){let p=d.expandToSize??u;p===0&&(p=1),a(p)}},getSize:()=>{const{group:l}=n(),c=s(),{element:u}=i(),d=l.orientation==="horizontal"?u.offsetWidth:u.offsetHeight;return{asPercentage:c,inPixels:d}},isCollapsed:()=>{const{collapsible:l,collapsedSize:c}=r(),u=s();return l&&_n(c,u)},resize:l=>{const{group:c}=n(),{element:u}=i(),d=Ha({group:c}),f=Xl({groupSize:d,panelElement:u,styleProp:l}),p=Nn(f/d*100);a(p)}}}function gS(e){if(e.defaultPrevented)return;const t=jo();hy(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=cR({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function eh(e){const t=jo();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 uR({groupId:e}){const t=()=>{const n=jo();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=bo({layout:n,panelConstraints:i});return r?a:(yo(a,c)||Di(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:o,layout:c,separatorToPanels:l}),c)}}}function Us(e,t){const n=eh(e),r=Ss(n.id,!0),i=n.separators.find(u=>u.element===e);rt(i,"Matching separator not found");const s=r.separatorToPanels.get(i);rt(s,"Matching panels not found");const o=s.map(u=>n.panels.indexOf(u)),a=uR({groupId:n.id}).getLayout(),l=Zc({delta:t,initialLayout:a,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),c=bo({layout:l,panelConstraints:r.derivedPanelConstraints});yo(a,c)||Di(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function vS(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=eh(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Us(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Us(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Us(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Us(t,-5);break}case"End":{e.preventDefault(),Us(t,100);break}case"Enter":{e.preventDefault();const r=eh(t),i=Ss(r.id,!0),{derivedPanelConstraints:s,layout:o,separatorToPanels:a}=i,l=r.separators.find(f=>f.element===t);rt(l,"Matching separator not found");const c=a.get(l);rt(c,"Matching panels not found");const u=c[0],d=s.find(f=>f.panelId===u.id);if(rt(d,"Panel metadata not found"),d.collapsible){const f=o[u.id],p=d.collapsedSize===f?r.mutableState.expandedPanelSizes[u.id]??d.minSize:d.collapsedSize;Us(t,p-f)}break}case"F6":{e.preventDefault();const r=eh(t).separators.map(o=>o.element),i=Array.from(r).findIndex(o=>o===e.currentTarget);rt(i!==null,"Index not found");const s=e.shiftKey?i>0?i-1:r.length-1:i+1<r.length?i+1:0;r[s].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),Us(t,-100);break}}}function _S(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=jo(),n=hy(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)}),Na({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function dR({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 b=r.get(u),_=i.get(u);if(!b||!_)return;const{defaultLayoutDeferred:x,derivedPanelConstraints:y,groupSize:w,layout:k,separatorToPanels:C}=_;if(y&&k&&C){const N=Zc({delta:v,initialLayout:b,panelConstraints:y,pivotIndices:c.panels.map(T=>p.indexOf(T)),prevLayout:k,trigger:"mouse-or-touch"});if(yo(N,k)){if(v!==0&&!m)switch(f){case"horizontal":{a|=v<0?nR:rR;break}case"vertical":{a|=v<0?iR:sR;break}}}else Di(c.group,{defaultLayoutDeferred:x,derivedPanelConstraints:y,groupSize:w,layout:N,separatorToPanels:C})}});let l=0;t.movementX===0?l|=o&aS:l|=a&aS,t.movementY===0?l|=o&lS:l|=a&lS,lU(l),uy(e)}function xS(e){const t=jo(),n=xo();switch(n.state){case"active":dR({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function yS(e){var r,i;if(e.defaultPrevented)return;const t=xo(),n=jo();switch(t.state){case"active":{if(e.buttons===0){Na({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const o=Ss(s.group.id,!0);Di(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))}dR({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=hy(e,n);s.length===0?t.state!=="inactive"&&Na({cursorFlags:0,state:"inactive"}):Na({cursorFlags:0,hitRegions:s,state:"hover"}),uy(e.currentTarget);break}}}function bS(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(xo().state){case"hover":Na({cursorFlags:0,state:"inactive"})}}function wS(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||aR(e.currentTarget)&&e.preventDefault()}function SS(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const o=Nn(s.defaultSize);n+=o,r[s.panelId]=o}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=Nn((100-n)/i);for(const o of e)o.defaultSize===void 0&&(r[o.panelId]=s)}return r}function bU(e,t,n){if(!n[0])return;const r=e.panels.find(l=>l.element===t);if(!r||!r.onResize)return;const i=Ha({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,a={asPercentage:Nn(s/i*100),inPixels:s};r.mutableValues.prevSize=a,r.onResize(a,r.id,o)}function wU(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 SU({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=Nn(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]=Nn(f/s*c)}else{const d=Nn(c/l.length);for(const f of l)u[f]=d}return u}function kU(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 Go=new Map;function CU(e){let t=!0;rt(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,s=new n(m=>{for(const v of m){const{borderBoxSize:b,target:_}=v;if(_===e.element){if(t){const x=Ha({group:e});if(x===0)return;const y=Ss(e.id);if(!y)return;const w=m0(e),k=y.defaultLayoutDeferred?SS(w):y.layout,C=SU({group:e,nextGroupSize:x,prevGroupSize:y.groupSize,prevLayout:k}),N=bo({layout:C,panelConstraints:w});if(!y.defaultLayoutDeferred&&yo(y.layout,N)&&wU(y.derivedPanelConstraints,w)&&y.groupSize===x)return;Di(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:w,groupSize:x,layout:N,separatorToPanels:y.separatorToPanels})}}else bU(e,_,b)}});s.observe(e.element),e.panels.forEach(m=>{rt(!r.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),r.add(m.id),m.onResize&&s.observe(m.element)});const o=Ha({group:e}),a=m0(e),l=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(kU(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[l]??c??SS(a),d=bo({layout:u,panelConstraints:a}),f=e.element.ownerDocument;Go.set(f,(Go.get(f)??0)+1);const p=new Map;return eR(e).forEach(m=>{m.separator&&p.set(m.separator,m.panels)}),Di(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:a,groupSize:o,layout:d,separatorToPanels:p}),e.separators.forEach(m=>{rt(!i.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),i.add(m.id),m.element.addEventListener("keydown",vS)}),Go.get(f)===1&&(f.addEventListener("contextmenu",hS,!0),f.addEventListener("dblclick",gS,!0),f.addEventListener("pointerdown",_S,!0),f.addEventListener("pointerleave",xS),f.addEventListener("pointermove",yS),f.addEventListener("pointerout",bS),f.addEventListener("pointerup",wS,!0)),function(){t=!1,Go.set(f,Math.max(0,(Go.get(f)??0)-1)),dU(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",vS)}),Go.get(f)||(f.removeEventListener("contextmenu",hS,!0),f.removeEventListener("dblclick",gS,!0),f.removeEventListener("pointerdown",_S,!0),f.removeEventListener("pointerleave",xS),f.removeEventListener("pointermove",yS),f.removeEventListener("pointerout",bS),f.removeEventListener("pointerup",wS,!0)),s.disconnect()}}function EU(){const[e,t]=g.useState({}),n=g.useCallback(()=>t({}),[]);return[e,n]}function fy(e){const t=g.useId();return`${e??t}`}const Do=typeof window<"u"?g.useLayoutEffect:g.useEffect;function mc(e){const t=g.useRef(e);return Do(()=>{t.current=e},[e]),g.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function py(...e){return mc(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function my(e){const t=g.useRef({...e});return Do(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const hR=g.createContext(null);function NU(e,t){const n=g.useRef({getLayout:()=>({}),setLayout:cU});g.useImperativeHandle(t,()=>n.current,[]),Do(()=>{Object.assign(n.current,uR({groupId:e}))})}function gy({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=mc(A=>{yo(m.current.onLayoutChange,A)||(m.current.onLayoutChange=A,l==null||l(A))}),b=mc((A,I)=>{yo(m.current.onLayoutChanged,A)||(m.current.onLayoutChanged=A,c==null||c(A,{isUserInteraction:I}))}),_=fy(a),x=g.useRef(null),[y,w]=EU(),k=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),C=py(x,s);NU(_,o);const N=mc((A,I)=>{const R=xo(),j=dS(A),z=Ss(A);if(z){let $=!1;switch(R.state){case"active":{$=R.hitRegions.some(F=>F.group===j);break}}return{flexGrow:z.layout[I]??1,pointerEvents:$?"none":void 0}}if(n!=null&&n[I])return{flexGrow:n==null?void 0:n[I]}}),T=my({defaultLayout:n,disableCursor:r}),B=g.useMemo(()=>({get disableCursor(){return!!T.disableCursor},getPanelStyles:N,id:_,orientation:u,registerPanel:A=>{const I=k.current;return I.panels=g0(u,[...I.panels,A]),w(),()=>{I.panels=I.panels.filter(R=>R!==A),w()}},registerSeparator:A=>{const I=k.current;return I.separators=g0(u,[...I.separators,A]),w(),()=>{I.separators=I.separators.filter(R=>R!==A),w()}},updatePanelProps:(A,{disabled:I})=>{const R=k.current.panels.find($=>$.id===A);R&&(R.panelConstraints.disabled=I);const j=dS(_),z=Ss(_);j&&z&&Di(j,{...z,derivedPanelConstraints:m0(j)})},updateSeparatorProps:(A,{disabled:I,disableDoubleClick:R})=>{const j=k.current.separators.find(z=>z.id===A);j&&(j.disabled=I,j.disableDoubleClick=R)}}),[N,_,w,u,T]),P=g.useRef(null);return Do(()=>{const A=x.current;if(A===null)return;const I=k.current;let R;if(T.defaultLayout!==void 0&&Object.keys(T.defaultLayout).length===I.panels.length){R={};for(const E of I.panels){const H=T.defaultLayout[E.id];H!==void 0&&(R[E.id]=H)}}const j={disabled:!!i,element:A,id:_,mutableState:{defaultLayout:R,disableCursor:!!T.disableCursor,expandedPanelSizes:k.current.lastExpandedPanelSizes,layouts:k.current.layouts},orientation:u,panels:I.panels,resizeTargetMinimumSize:I.resizeTargetMinimumSize,separators:I.separators};P.current=j;const z=CU(j),{defaultLayoutDeferred:$,derivedPanelConstraints:F,layout:D}=Ss(j.id,!0);!$&&F.length>0&&(v(D),b(D,!1));const O=dy(_,E=>{const{defaultLayoutDeferred:H,derivedPanelConstraints:V,layout:L}=E.next;if(H||V.length===0)return;const ne=j.panels.map(({id:G})=>G).join(",");j.mutableState.layouts[ne]=L,V.forEach(G=>{if(G.collapsible){const{layout:ye}=E.prev??{};if(ye){const Fe=_n(G.collapsedSize,L[G.panelId]),ue=_n(G.collapsedSize,ye[G.panelId]);Fe&&!ue&&(j.mutableState.expandedPanelSizes[G.panelId]=ye[G.panelId])}}});const ae=xo().state!=="active";v(L),ae&&b(L,E.isUserInteraction)});return()=>{P.current=null,z(),O()}},[i,_,b,v,u,y,T]),g.useEffect(()=>{const A=P.current;A&&(A.mutableState.defaultLayout=n,A.mutableState.disableCursor=!!r)}),h.jsx(hR.Provider,{value:B,children:h.jsx("div",{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:C,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})})}gy.displayName="Group";function vy(){const e=g.useContext(hR);return rt(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function TU(e,t){const{id:n}=vy(),r=g.useRef({collapse:Dm,expand:Dm,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Dm});g.useImperativeHandle(t,()=>r.current,[]),Do(()=>{Object.assign(r.current,cR({groupId:n,panelId:e}))})}function tf({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,b=fy(l),_=my({disabled:s}),x=g.useRef(null),y=py(x,o),{getPanelStyles:w,id:k,orientation:C,registerPanel:N,updatePanelProps:T}=vy(),B=d!==null,P=mc((j,z,$)=>{d==null||d(j,l,$)});Do(()=>{const j=x.current;if(j!==null){const z={element:j,id:b,idIsStable:v,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:B?P:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:c,minSize:u}};return N(z)}},[a,n,r,i,B,b,v,c,u,P,N,_]),g.useEffect(()=>{T(b,{disabled:s})},[s,b,T]),TU(b,f);const A=()=>{const j=w(k,b);if(j)return JSON.stringify(j)},I=g.useSyncExternalStore(j=>dy(k,j),A,A);let R;return I?R=JSON.parse(I):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":b,id:b,ref:y,style:{...PU,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:C==="horizontal"?"pan-y":"pan-x"},children:e})})}tf.displayName="Panel";const PU={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function IU({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=bo({layout:Zc({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=bo({layout:Zc({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:o}}function fR({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:s,style:o,...a}){const l=fy(s),c=my({disabled:n,disableDoubleClick:r}),[u,d]=g.useState({}),[f,p]=g.useState("inactive"),[m,v]=g.useState(!1),b=g.useRef(null),_=py(b,i),{disableCursor:x,id:y,orientation:w,registerSeparator:k,updateSeparatorProps:C}=vy(),N=w==="horizontal"?"vertical":"horizontal";Do(()=>{const P=b.current;if(P!==null){const A={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:P,id:l},I=k(A),R=aU(z=>{p(z.next.state!=="inactive"&&z.next.hitRegions.some($=>$.separator===A)?z.next.state:"inactive")}),j=dy(y,z=>{const{derivedPanelConstraints:$,layout:F,separatorToPanels:D}=z.next,O=D.get(A);if(O){const E=O[0],H=O.indexOf(E);d(IU({layout:F,panelConstraints:$,panelId:E.id,panelIndex:H}))}});return()=>{R(),j(),I()}}},[y,l,k,c]),g.useEffect(()=>{C(l,{disabled:n,disableDoubleClick:r})},[n,r,l,C]);let T;n&&!x&&(T="not-allowed");let B;if(n)B="disabled";else switch(f){case"active":{B="active";break}default:m?B="focus":B=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":B,"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})}fR.displayName="Separator";function RU(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 MU(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 AU=/^Scheduled (?:recurring job|one-shot task) ([0-9a-f]{8}) \(([^)]+)\)/;function LU(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(AU);if(!a)continue;r.set(a[1],{id:a[1],cron:s.cron,prompt:s.prompt,recurring:s.recurring,humanSchedule:a[2],createdAt:s.ts,toolUseId:s.toolUseId});continue}const o=n.get(i.toolUseId);o!==void 0&&(n.delete(i.toolUseId),i.error||r.delete(o))}return Array.from(r.values()).sort((i,s)=>i.createdAt.localeCompare(s.createdAt))}const jU=["TaskCreate","TaskUpdate","TaskList","TaskGet"];function DU(e){return jU.includes(e)}function pR(e){return e==="in_progress"||e==="completed"?e:"pending"}function OU(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:pR(n.status),activeForm:i,description:s}]}function BU(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=pR(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 zU(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=OU(t,i.input);break;case"TaskUpdate":t=BU(t,i.input);break}}return{tasks:t,lastEventIndex:n}}function $U(e){const{tasks:t,lastEventIndex:n}=zU(e);let r=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind==="todo-checklist"){r=c;break}const i=[],s=new Map,o=new Map,a=new Map,l=(c,u)=>{var f,p,m;const d={agentId:u.agentId,status:u.status};u.description?d.description=u.description:(f=c.progress)!=null&&f.description&&(d.description=c.progress.description),u.lastToolName?d.lastToolName=u.lastToolName:(p=c.progress)!=null&&p.lastToolName&&(d.lastToolName=c.progress.lastToolName),u.stats?d.stats=u.stats:(m=c.progress)!=null&&m.stats&&(d.stats=c.progress.stats),c.progress=d};for(let c=0;c<e.length;c++){const u=e[c];switch(u.kind){case"tool-call":{const d={kind:"merged-tool",seq:u.seq,tool:u.tool,toolKind:u.toolKind,toolUseId:u.toolUseId,input:u.input,pending:!0};s.set(u.toolUseId,i.length),i.push(d);break}case"tool-result":{const d=s.get(u.toolUseId);if(d!==void 0){const p=i[d];p.output=u.output,p.error=u.error,p.pending=!1,s.delete(u.toolUseId);break}const f=o.get(u.toolUseId);if(f!==void 0){const p=i[f];p.output=u.output,p.error=u.error,p.pending=!1,u.toolResultExtra&&(p.toolResultExtra=u.toolResultExtra);break}break}case"agent-call":{const d={kind:"merged-agent",seq:u.seq,toolUseId:u.toolUseId,description:u.description,input:u.input,pending:!0,notifications:[]};o.set(u.toolUseId,i.length),i.push(d);const f=a.get(u.toolUseId);f&&(l(d,f),a.delete(u.toolUseId));break}case"agent-progress":{const d=o.get(u.toolUseId);if(d!==void 0){l(i[d],u);break}a.set(u.toolUseId,u);break}case"agent-notification":{const d=u.parentToolUseId;if(d){const f=o.get(d);if(f!==void 0){i[f].notifications.push({text:u.text,taskId:u.taskId});break}}i.push({kind:"agent-notification",seq:u.seq,text:u.text,taskId:u.taskId,parentToolUseId:u.parentToolUseId});break}case"todo-checklist":{c===r&&u.todos.length>0&&i.push({kind:"todo-checklist",seq:u.seq,toolUseId:u.toolUseId,todos:u.todos});break}case"task-event":{c===n&&t.length>0&&i.push({kind:"plan-card",seq:u.seq,tasks:t});break}default:i.push(u)}}return i}const FU=new Set(["permission-inline","question-card"]);function HU(e){return e.kind==="user-text"?!0:e.kind==="user-meta"&&e.metaKind==="slash-command"}function UU(e,t={}){const n=[];let r=null;const i=(s,o)=>{r&&(n.push(WU(r,s,o)),r=null)};for(const s of e){if(s.kind==="turn-end"){i(s,!0);continue}if(HU(s)&&(r===null||t.implicitCloseOnUserText)){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 WU(e,t,n){const{query:r,body:i}=e,s=VU(i,t,n),o=qU(i,s),a=GU(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 VU(e,t,n){if(!n)return"running";if((t==null?void 0:t.reason)==="interrupted")return"interrupted";const r=v0(e,i=>i.kind==="error");return r>=0&&!e.slice(r+1).some(s=>s.kind==="assistant-text")?"error":"done"}function qU(e,t){if(t==="running"){const i=[];for(let s=e.length-1;s>=0&&FU.has(e[s].kind);s--)i.unshift(e[s]);return i}const n=[];e.forEach((i,s)=>{i.kind==="merged-agent"&&i.pending&&n.push(s)});const r=t==="error"?v0(e,i=>i.kind==="error"):v0(e,i=>i.kind==="assistant-text");return r>=0&&n.push(r),n.sort((i,s)=>i-s).map(i=>e[i])}const KU=new Set(["assistant-thinking","user-meta"]);function GU(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(KU.has(o.kind)){r.push(o);continue}s(),r.push(o)}return s(),r}function v0(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}const XU={Read:["正在读取","已读取"],Bash:["正在运行","已运行"],Grep:["正在搜索","已搜索"],Glob:["正在搜索","已搜索"],Edit:["正在编辑","已编辑"],Write:["正在写入","已写入"],WebFetch:["正在抓取","已抓取"],WebSearch:["正在搜索","已搜索"],Skill:["正在读取","已读取"]};function YU(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 mR(e){const t=XU[e.tool],n=t?e.pending?t[0]:t[1]:e.pending?`正在执行 ${e.tool}`:`已执行 ${e.tool}`,r=YU(e.input);return r?`${n} ${r}`:n}function QU({item:e,renderItemDetail:t}){const[n,r]=g.useState(!1),i=n?ir:Un,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:fe("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(In,{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:mR(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 ZU({items:e,defaultExpanded:t=!1,renderItemDetail:n}){const[r,i]=g.useState(t);if(e.length===0)return null;const s=e.some(c=>c.pending),o=s?[...e].reverse().find(c=>c.pending):e[e.length-1],a=!s&&e.length>1?` 等 ${e.length} 项`:"",l=r?ir:Un;return h.jsxs("div",{"data-testid":"tool-call-group",className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>i(c=>!c),"aria-expanded":r,"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:[s&&!r?h.jsx(In,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):h.jsx(l,{className:"w-3.5 h-3.5 shrink-0"}),r?h.jsx("span",{className:"min-w-0 truncate opacity-70",children:s?"正在执行":`${e.length} 项`}):h.jsxs("span",{className:fe("truncate min-w-0",s&&"text-text-300"),children:[mR(o),a]})]}),r?h.jsx("div",{className:"mt-0.5 flex flex-col pl-5",children:e.map(c=>h.jsx(QU,{item:c,renderItemDetail:n},c.toolUseId))}):null]})}function JU(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 eW(e,t){const n=t!==void 0?`耗时 ${JU(t)}`:"";switch(e){case"interrupted":return n?`已中断 · ${n}`:"已中断";case"error":return n?`出错 · ${n}`:"出错";default:return n||"已完成"}}function tW({status:e="done",durationMs:t,defaultExpanded:n=!1,children:r}){const[i,s]=g.useState(n),o=i?ir:Un;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:fe("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:eW(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 nW=/<(system-reminder|related-dir|clawd-shift-fire)\b[^>]*>[\s\S]*?<\/\1>/gi,rW=/<builder-preview\b[^>]*\/>/gi;function gR(e){return e?e.replace(nW,"").replace(rW,"").trim():""}const iW=gR;function sW(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const oW=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,aW=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,lW={};function kS(e,t){return(lW.jsx?aW:oW).test(e)}const cW=/[ \t\n\f\r]/g;function uW(e){return typeof e=="object"?e.type==="text"?CS(e.value):!1:CS(e)}function CS(e){return e.replace(cW,"")===""}class Cu{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Cu.prototype.normal={};Cu.prototype.property={};Cu.prototype.space=void 0;function vR(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Cu(n,r,t)}function _0(e){return e.toLowerCase()}class Wn{constructor(t,n){this.attribute=n,this.property=t}}Wn.prototype.attribute="";Wn.prototype.booleanish=!1;Wn.prototype.boolean=!1;Wn.prototype.commaOrSpaceSeparated=!1;Wn.prototype.commaSeparated=!1;Wn.prototype.defined=!1;Wn.prototype.mustUseProperty=!1;Wn.prototype.number=!1;Wn.prototype.overloadedBoolean=!1;Wn.prototype.property="";Wn.prototype.spaceSeparated=!1;Wn.prototype.space=void 0;let dW=0;const Me=Oo(),At=Oo(),x0=Oo(),Q=Oo(),at=Oo(),Ta=Oo(),Gn=Oo();function Oo(){return 2**++dW}const y0=Object.freeze(Object.defineProperty({__proto__:null,boolean:Me,booleanish:At,commaOrSpaceSeparated:Gn,commaSeparated:Ta,number:Q,overloadedBoolean:x0,spaceSeparated:at},Symbol.toStringTag,{value:"Module"})),Om=Object.keys(y0);class _y extends Wn{constructor(t,n,r,i){let s=-1;if(super(t,n),ES(this,"space",i),typeof r=="number")for(;++s<Om.length;){const o=Om[s];ES(this,Om[s],(r&y0[o])===y0[o])}}}_y.prototype.defined=!0;function ES(e,t,n){n&&(e[t]=n)}function fl(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[_0(r)]=r,n[_0(s.attribute)]=r}return new Cu(t,n,e.space)}const _R=fl({properties:{ariaActiveDescendant:null,ariaAtomic:At,ariaAutoComplete:null,ariaBusy:At,ariaChecked:At,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:at,ariaCurrent:null,ariaDescribedBy:at,ariaDetails:null,ariaDisabled:At,ariaDropEffect:at,ariaErrorMessage:null,ariaExpanded:At,ariaFlowTo:at,ariaGrabbed:At,ariaHasPopup:null,ariaHidden:At,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:at,ariaLevel:Q,ariaLive:null,ariaModal:At,ariaMultiLine:At,ariaMultiSelectable:At,ariaOrientation:null,ariaOwns:at,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:At,ariaReadOnly:At,ariaRelevant:null,ariaRequired:At,ariaRoleDescription:at,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:At,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 xR(e,t){return t in e?e[t]:t}function yR(e,t){return xR(e,t.toLowerCase())}const hW=fl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ta,acceptCharset:at,accessKey:at,action:null,allow:null,allowFullScreen:Me,allowPaymentRequest:Me,allowUserMedia:Me,alt:null,as:null,async:Me,autoCapitalize:null,autoComplete:at,autoFocus:Me,autoPlay:Me,blocking:at,capture:null,charSet:null,checked:Me,cite:null,className:at,cols:Q,colSpan:null,content:null,contentEditable:At,controls:Me,controlsList:at,coords:Q|Ta,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Me,defer:Me,dir:null,dirName:null,disabled:Me,download:x0,draggable:At,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Me,formTarget:null,headers:at,height:Q,hidden:x0,high:Q,href:null,hrefLang:null,htmlFor:at,httpEquiv:at,id:null,imageSizes:null,imageSrcSet:null,inert:Me,inputMode:null,integrity:null,is:null,isMap:Me,itemId:null,itemProp:at,itemRef:at,itemScope:Me,itemType:at,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Me,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:Me,muted:Me,name:null,nonce:null,noModule:Me,noValidate:Me,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:Me,optimum:Q,pattern:null,ping:at,placeholder:null,playsInline:Me,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Me,referrerPolicy:null,rel:at,required:Me,reversed:Me,rows:Q,rowSpan:Q,sandbox:at,scope:null,scoped:Me,seamless:Me,selected:Me,shadowRootClonable:Me,shadowRootDelegatesFocus:Me,shadowRootMode:null,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:At,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:Me,useMap:null,value:At,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:at,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:Me,declare:Me,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:Me,noHref:Me,noShade:Me,noWrap:Me,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:At,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:Me,disableRemotePlayback:Me,prefix:null,property:null,results:Q,security:null,unselectable:null},space:"html",transform:yR}),fW=fl({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:Gn,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:at,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:Me,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:Ta,g2:Ta,glyphName:Ta,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:Gn,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:at,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Gn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Gn,rev:Gn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Gn,requiredFeatures:Gn,requiredFonts:Gn,requiredFormats:Gn,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:Gn,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:Gn,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:Gn,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:xR}),bR=fl({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),wR=fl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:yR}),SR=fl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),pW={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"},mW=/[A-Z]/g,NS=/-[a-z]/g,gW=/^data[-\w.:]+$/i;function vW(e,t){const n=_0(t);let r=t,i=Wn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&gW.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(NS,xW);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!NS.test(s)){let o=s.replace(mW,_W);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=_y}return new i(r,t)}function _W(e){return"-"+e.toLowerCase()}function xW(e){return e.charAt(1).toUpperCase()}const yW=vR([_R,hW,bR,wR,SR],"html"),xy=vR([_R,fW,bR,wR,SR],"svg");function bW(e){return e.join(" ").trim()}var yy={},TS=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,wW=/\n/g,SW=/^\s*/,kW=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,CW=/^:\s*/,EW=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,NW=/^[;\s]*/,TW=/^\s+|\s+$/g,PW=`
|
|
475
|
+
`)},d7=0,Ko=[];function h7(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState(d7++)[0],s=g.useState(GP)[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=A9([e.lockRef.current],(e.shards||[]).map(nS),!0).filter(Boolean);return v.forEach(function(b){return b.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),v.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(v,b){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var _=vd(v),x=n.current,y="deltaX"in v?v.deltaX:x[0]-_[0],w="deltaY"in v?v.deltaY:x[1]-_[1],k,C=v.target,N=Math.abs(y)>Math.abs(w)?"h":"v";if("touches"in v&&N==="h"&&C.type==="range")return!1;var T=window.getSelection(),B=T&&T.anchorNode,P=B?B===C||B.contains(C):!1;if(P)return!1;var A=eS(N,C);if(!A)return!0;if(A?k=N:(k=N==="v"?"h":"v",A=eS(N,C)),!A)return!1;if(!r.current&&"changedTouches"in v&&(y||w)&&(r.current=k),!k)return!0;var I=r.current||k;return l7(I,b,v,I==="h"?y:w)},[]),l=g.useCallback(function(v){var b=v;if(!(!Ko.length||Ko[Ko.length-1]!==s)){var _="deltaY"in b?tS(b):vd(b),x=t.current.filter(function(k){return k.name===b.type&&(k.target===b.target||b.target===k.shadowParent)&&c7(k.delta,_)})[0];if(x&&x.should){b.cancelable&&b.preventDefault();return}if(!x){var y=(o.current.shards||[]).map(nS).filter(Boolean).filter(function(k){return k.contains(b.target)}),w=y.length>0?a(b,y[0]):!o.current.noIsolation;w&&b.cancelable&&b.preventDefault()}}},[]),c=g.useCallback(function(v,b,_,x){var y={name:v,delta:b,target:_,should:x,shadowParent:f7(_)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(w){return w!==y})},1)},[]),u=g.useCallback(function(v){n.current=vd(v),r.current=void 0},[]),d=g.useCallback(function(v){c(v.type,tS(v),v.target,a(v,e.lockRef.current))},[]),f=g.useCallback(function(v){c(v.type,vd(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return Ko.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,qo),document.addEventListener("touchmove",l,qo),document.addEventListener("touchstart",u,qo),function(){Ko=Ko.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,qo),document.removeEventListener("touchmove",l,qo),document.removeEventListener("touchstart",u,qo)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(s,{styles:u7(i)}):null,p?g.createElement(t7,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function f7(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const p7=H9(KP,h7);var Qx=g.forwardRef(function(e,t){return g.createElement(up,Gr({},e,{ref:t,sideCar:p7}))});Qx.classNames=up.classNames;var p0=["Enter"," "],m7=["ArrowDown","PageUp","Home"],ZP=["ArrowUp","PageDown","End"],g7=[...m7,...ZP],v7={ltr:[...p0,"ArrowRight"],rtl:[...p0,"ArrowLeft"]},_7={ltr:["ArrowLeft"],rtl:["ArrowRight"]},bu="Menu",[Yc,x7,y7]=aP(bu),[Lo,JP]=Ao(bu,[y7,cp,BP]),wu=cp(),eI=BP(),[tI,Ds]=Lo(bu),[b7,Su]=Lo(bu),nI=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=wu(t),[l,c]=g.useState(null),u=g.useRef(!1),d=oi(s),f=lP(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(Xx,{...a,children:h.jsx(tI,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(b7,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};nI.displayName=bu;var w7="MenuAnchor",Zx=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=wu(n);return h.jsx(LP,{...i,...r,ref:t})});Zx.displayName=w7;var Jx="MenuPortal",[S7,rI]=Lo(Jx,{forceMount:void 0}),iI=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=Ds(Jx,t);return h.jsx(S7,{scope:t,forceMount:n,children:h.jsx($i,{present:n||s.open,children:h.jsx(Yx,{asChild:!0,container:i,children:r})})})};iI.displayName=Jx;var gr="MenuContent",[k7,ey]=Lo(gr),sI=g.forwardRef((e,t)=>{const n=rI(gr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Ds(gr,e.__scopeMenu),o=Su(gr,e.__scopeMenu);return h.jsx(Yc.Provider,{scope:e.__scopeMenu,children:h.jsx($i,{present:r||s.open,children:h.jsx(Yc.Slot,{scope:e.__scopeMenu,children:o.modal?h.jsx(C7,{...i,ref:t}):h.jsx(E7,{...i,ref:t})})})})}),C7=g.forwardRef((e,t)=>{const n=Ds(gr,e.__scopeMenu),r=g.useRef(null),i=qt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return WP(s)},[]),h.jsx(ty,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),E7=g.forwardRef((e,t)=>{const n=Ds(gr,e.__scopeMenu);return h.jsx(ty,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),N7=Gc("MenuContent.ScrollLock"),ty=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,b=Ds(gr,n),_=Su(gr,n),x=wu(n),y=eI(n),w=x7(n),[k,C]=g.useState(null),N=g.useRef(null),T=qt(t,N,b.onContentChange),B=g.useRef(0),P=g.useRef(""),A=g.useRef(0),I=g.useRef(null),R=g.useRef("right"),j=g.useRef(0),z=m?Qx:g.Fragment,$=m?{as:N7,allowPinchZoom:!0}:void 0,F=O=>{var ye,Fe;const E=P.current+O,H=w().filter(ue=>!ue.disabled),V=document.activeElement,L=(ye=H.find(ue=>ue.ref.current===V))==null?void 0:ye.textValue,ne=H.map(ue=>ue.textValue),ae=z7(ne,E,L),G=(Fe=H.find(ue=>ue.textValue===ae))==null?void 0:Fe.ref.current;(function ue(Ie){P.current=Ie,window.clearTimeout(B.current),Ie!==""&&(B.current=window.setTimeout(()=>ue(""),1e3))})(E),G&&setTimeout(()=>G.focus())};g.useEffect(()=>()=>window.clearTimeout(B.current),[]),dP();const D=g.useCallback(O=>{var H,V;return R.current===((H=I.current)==null?void 0:H.side)&&F7(O,(V=I.current)==null?void 0:V.area)},[]);return h.jsx(k7,{scope:n,searchRef:P,onItemEnter:g.useCallback(O=>{D(O)&&O.preventDefault()},[D]),onItemLeave:g.useCallback(O=>{var E;D(O)||((E=N.current)==null||E.focus(),C(null))},[D]),onTriggerLeave:g.useCallback(O=>{D(O)&&O.preventDefault()},[D]),pointerGraceTimerRef:A,onPointerGraceIntentChange:g.useCallback(O=>{I.current=O},[]),children:h.jsx(z,{...$,children:h.jsx($x,{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(ip,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(T9,{asChild:!0,...y,dir:_.dir,orientation:"vertical",loop:r,currentTabStopId:k,onCurrentTabStopIdChange:C,onEntryFocus:Pe(l,O=>{_.isUsingKeyboardRef.current||O.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(jP,{role:"menu","aria-orientation":"vertical","data-state":wI(b.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,V=O.ctrlKey||O.altKey||O.metaKey,L=O.key.length===1;H&&(O.key==="Tab"&&O.preventDefault(),!V&&L&&F(O.key));const ne=N.current;if(O.target!==ne||!g7.includes(O.key))return;O.preventDefault();const G=w().filter(ye=>!ye.disabled).map(ye=>ye.ref.current);ZP.includes(O.key)&&G.reverse(),O7(G)}),onBlur:Pe(e.onBlur,O=>{O.currentTarget.contains(O.target)||(window.clearTimeout(B.current),P.current="")}),onPointerMove:Pe(e.onPointerMove,Qc(O=>{const E=O.target,H=j.current!==O.clientX;if(O.currentTarget.contains(E)&&H){const V=O.clientX>j.current?"right":"left";R.current=V,j.current=O.clientX}}))})})})})})})});sI.displayName=gr;var T7="MenuGroup",ny=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{role:"group",...r,ref:t})});ny.displayName=T7;var P7="MenuLabel",oI=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{...r,ref:t})});oI.displayName=P7;var Jh="MenuItem",rS="menu.itemSelect",dp=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=Su(Jh,e.__scopeMenu),a=ey(Jh,e.__scopeMenu),l=qt(t,s),c=g.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(rS,{bubbles:!0,cancelable:!0});d.addEventListener(rS,p=>r==null?void 0:r(p),{once:!0}),oP(d,f),f.defaultPrevented?c.current=!1:o.onClose()}};return h.jsx(aI,{...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===" "||p0.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});dp.displayName=Jh;var aI=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=ey(Jh,n),a=eI(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(Yc.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:h.jsx(P9,{asChild:!0,...a,focusable:!r,children:h.jsx(Et.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:Pe(e.onPointerMove,Qc(m=>{r?o.onItemLeave(m):(o.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Pe(e.onPointerLeave,Qc(m=>o.onItemLeave(m))),onFocus:Pe(e.onFocus,()=>d(!0)),onBlur:Pe(e.onBlur,()=>d(!1))})})})}),I7="MenuCheckboxItem",lI=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return h.jsx(fI,{scope:e.__scopeMenu,checked:n,children:h.jsx(dp,{role:"menuitemcheckbox","aria-checked":ef(n)?"mixed":n,...i,ref:t,"data-state":sy(n),onSelect:Pe(i.onSelect,()=>r==null?void 0:r(ef(n)?!0:!n),{checkForDefaultPrevented:!1})})})});lI.displayName=I7;var cI="MenuRadioGroup",[R7,M7]=Lo(cI,{value:void 0,onValueChange:()=>{}}),uI=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=oi(r);return h.jsx(R7,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(ny,{...i,ref:t})})});uI.displayName=cI;var dI="MenuRadioItem",hI=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=M7(dI,e.__scopeMenu),s=n===i.value;return h.jsx(fI,{scope:e.__scopeMenu,checked:s,children:h.jsx(dp,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":sy(s),onSelect:Pe(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});hI.displayName=dI;var ry="MenuItemIndicator",[fI,A7]=Lo(ry,{checked:!1}),pI=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=A7(ry,n);return h.jsx($i,{present:r||ef(s.checked)||s.checked===!0,children:h.jsx(Et.span,{...i,ref:t,"data-state":sy(s.checked)})})});pI.displayName=ry;var L7="MenuSeparator",mI=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});mI.displayName=L7;var j7="MenuArrow",gI=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=wu(n);return h.jsx(DP,{...i,...r,ref:t})});gI.displayName=j7;var iy="MenuSub",[D7,vI]=Lo(iy),_I=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=Ds(iy,t),o=wu(t),[a,l]=g.useState(null),[c,u]=g.useState(null),d=oi(i);return g.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),h.jsx(Xx,{...o,children:h.jsx(tI,{scope:t,open:r,onOpenChange:d,content:c,onContentChange:u,children:h.jsx(D7,{scope:t,contentId:Ti(),triggerId:Ti(),trigger:a,onTriggerChange:l,children:n})})})};_I.displayName=iy;var Gl="MenuSubTrigger",xI=g.forwardRef((e,t)=>{const n=Ds(Gl,e.__scopeMenu),r=Su(Gl,e.__scopeMenu),i=vI(Gl,e.__scopeMenu),s=ey(Gl,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(Zx,{asChild:!0,...c,children:h.jsx(aI,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":wI(n.open),...e,ref:vu(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,Qc(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,Qc(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,b=v==="right",_=b?-5:5,x=f[b?"left":"right"],y=f[b?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+_,y:d.clientY},{x,y:f.top},{x:y,y:f.top},{x:y,y:f.bottom},{x,y:f.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Pe(e.onKeyDown,d=>{var p;const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||v7[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});xI.displayName=Gl;var yI="MenuSubContent",bI=g.forwardRef((e,t)=>{const n=rI(gr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Ds(gr,e.__scopeMenu),o=Su(gr,e.__scopeMenu),a=vI(yI,e.__scopeMenu),l=g.useRef(null),c=qt(t,l);return h.jsx(Yc.Provider,{scope:e.__scopeMenu,children:h.jsx($i,{present:r||s.open,children:h.jsx(Yc.Slot,{scope:e.__scopeMenu,children:h.jsx(ty,{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=_7[o.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});bI.displayName=yI;function wI(e){return e?"open":"closed"}function ef(e){return e==="indeterminate"}function sy(e){return ef(e)?"indeterminate":e?"checked":"unchecked"}function O7(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function B7(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function z7(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=B7(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 $7(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 F7(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return $7(n,t)}function Qc(e){return t=>t.pointerType==="mouse"?e(t):void 0}var H7=nI,U7=Zx,W7=iI,V7=sI,q7=ny,K7=oI,G7=dp,X7=lI,Y7=uI,Q7=hI,Z7=pI,J7=mI,eH=gI,tH=_I,nH=xI,rH=bI,hp="DropdownMenu",[iH]=Ao(hp,[JP]),wn=JP(),[sH,SI]=iH(hp),kI=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=wn(t),c=g.useRef(null),[u,d]=_u({prop:i,defaultProp:s??!1,onChange:o,caller:hp});return h.jsx(sH,{scope:t,triggerId:Ti(),triggerRef:c,contentId:Ti(),open:u,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(H7,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};kI.displayName=hp;var CI="DropdownMenuTrigger",EI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=SI(CI,n),o=wn(n);return h.jsx(U7,{asChild:!0,...o,children:h.jsx(Et.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:vu(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())})})})});EI.displayName=CI;var oH="DropdownMenuPortal",NI=e=>{const{__scopeDropdownMenu:t,...n}=e,r=wn(t);return h.jsx(W7,{...r,...n})};NI.displayName=oH;var TI="DropdownMenuContent",PI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=SI(TI,n),s=wn(n),o=g.useRef(!1);return h.jsx(V7,{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)"}})});PI.displayName=TI;var aH="DropdownMenuGroup",lH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(q7,{...i,...r,ref:t})});lH.displayName=aH;var cH="DropdownMenuLabel",II=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(K7,{...i,...r,ref:t})});II.displayName=cH;var uH="DropdownMenuItem",RI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(G7,{...i,...r,ref:t})});RI.displayName=uH;var dH="DropdownMenuCheckboxItem",MI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(X7,{...i,...r,ref:t})});MI.displayName=dH;var hH="DropdownMenuRadioGroup",fH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(Y7,{...i,...r,ref:t})});fH.displayName=hH;var pH="DropdownMenuRadioItem",mH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(Q7,{...i,...r,ref:t})});mH.displayName=pH;var gH="DropdownMenuItemIndicator",AI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(Z7,{...i,...r,ref:t})});AI.displayName=gH;var vH="DropdownMenuSeparator",LI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(J7,{...i,...r,ref:t})});LI.displayName=vH;var _H="DropdownMenuArrow",xH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(eH,{...i,...r,ref:t})});xH.displayName=_H;var yH=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,o=wn(t),[a,l]=_u({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return h.jsx(tH,{...o,open:a,onOpenChange:l,children:n})},bH="DropdownMenuSubTrigger",jI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(nH,{...i,...r,ref:t})});jI.displayName=bH;var wH="DropdownMenuSubContent",DI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(rH,{...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)"}})});DI.displayName=wH;var SH=kI,kH=EI,OI=NI,BI=PI,zI=II,$I=RI,FI=MI,CH=AI,HI=LI,EH=yH,UI=jI,WI=DI;const oy=SH,ay=kH,fp=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(OI,{children:h.jsx(BI,{ref:r,sideOffset:t,className:fe("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));fp.displayName=BI.displayName;const NH=EH,VI=g.forwardRef(({className:e,...t},n)=>h.jsx(UI,{ref:n,className:fe("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}));VI.displayName=UI.displayName;const qI=g.forwardRef(({className:e,...t},n)=>h.jsx(OI,{children:h.jsx(WI,{ref:n,className:fe("z-50 min-w-[6rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...t})}));qI.displayName=WI.displayName;const yi=g.forwardRef(({className:e,inset:t,...n},r)=>h.jsx($I,{ref:r,className:fe("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}));yi.displayName=$I.displayName;const TH=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>h.jsxs(FI,{ref:i,checked:n,className:fe("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(CH,{children:h.jsx(ul,{className:"h-3.5 w-3.5"})})}),t]}));TH.displayName=FI.displayName;const KI=g.forwardRef(({className:e,...t},n)=>h.jsx(HI,{ref:n,className:fe("-mx-1 my-1 h-px bg-border",e),...t}));KI.displayName=HI.displayName;const PH=g.forwardRef(({className:e,...t},n)=>h.jsx(zI,{ref:n,className:fe("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));PH.displayName=zI.displayName;function IH({tool:e,className:t}){const n=w8(e);return h.jsx("span",{"data-testid":n?`session-icon-${e}`:"session-icon-default","aria-label":n?zx(e):"未知引擎",className:fe("w-3.5 h-3.5 shrink-0 inline-flex items-center justify-center",rp(e),t),children:h.jsx(np,{tool:e,className:"w-full h-full"})})}function GI(e){return e.compositionActive||!!e.nativeIsComposing||e.keyCode===229}function XI(e){return e.key==="Enter"&&!e.shiftKey&&!GI(e)}function ku(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(XI({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 RH({open:e,initialLabel:t,placeholder:n,onSubmit:r,onCancel:i}){const[s,o]=g.useState(t);g.useEffect(()=>{e&&o(t)},[e,t]);const a=ku(()=>r({label:s.trim()}),i);return e?el.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":"session-edit-dialog-overlay",children:h.jsxs("div",{"data-testid":"session-edit-dialog",className:"w-[420px] max-w-[calc(100vw-32px)] rounded-2xl border border-text-100/[0.12] flex flex-col gap-4 p-5",style:{backgroundColor:"var(--bg-0)",boxShadow:"0 12px 40px rgba(0,0,0,0.04)"},onClick:l=>l.stopPropagation(),children:[h.jsx("div",{className:"text-[15px] font-semibold text-text-100",children:"Edit session"}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:"Label"}),h.jsx("input",{autoFocus:!0,type:"text",value:s,onChange:l=>o(l.target.value),...a,placeholder:n,"data-testid":"session-edit-dialog-label",className:"w-full px-3 py-2 text-[13px] bg-bg-50 border border-bg-300 rounded-lg focus:outline-none focus:border-text-300 transition-colors"})]}),h.jsxs("div",{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:()=>r({label:s.trim()}),"data-testid":"session-edit-dialog-save",className:"px-4 py-1.5 text-[12px] font-medium text-bg-0 rounded-lg bg-text-100 hover:bg-text-200 transition-colors cursor-pointer",children:"Save"})]})]})}),document.body):null}const MH={held:!1,indexBySessionId:new Map},AH=g.createContext(MH);function LH(){return g.useContext(AH)}const jH=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})),DH=[{id:"new-session",combo:{key:"n",mod:!0},label:"新建任务",description:"打开快捷新建弹窗",group:"通用",desktopOnly:!0},...jH,{id:"tab-prev",combo:{key:"ArrowLeft",mod:!0,shift:!0},label:"上一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"tab-next",combo:{key:"ArrowRight",mod:!0,shift:!0},label:"下一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"send-message",combo:{key:"Enter"},label:"发送消息",description:"在输入框中发送当前内容",group:"输入",displayOnly:!0},{id:"newline",combo:{key:"Enter",shift:!0},label:"换行",description:"在输入框中插入换行",group:"输入",displayOnly:!0},{id:"interrupt",combo:{key:"Escape"},label:"打断回复",description:"打断当前回复;2 秒内按两次停止任务",group:"输入",displayOnly:!0}];DH.filter(e=>!e.displayOnly);function OH(){return/Mac|iP(hone|od|ad)/.test(navigator.platform)}const BH=10,zH=20,$H=16,FH=20,HH=60,UH=4;function WH({session:e,active:t,hasUnread:n,running:r=!1,awaitingUser:i=!1,onSelect:s,onEdit:o,onDelete:a,onPin:l,onArchive:c,archiveShortcut:u=!1,depth:d=0,chevron:f,showCopyResume:p=!0,contactDisplayName:m}){const[v,b]=g.useState(!1),_=LH(),x=_.held?_.indexBySessionId.get(e.sessionId):void 0,y=!!e.pinnedAt,w=d===0,k=d===0&&!!c,C=BH+d*zH,N=g.useCallback(async()=>{const A=iP(e);if(A)try{await navigator.clipboard.writeText(A)}catch{}},[e]),T=e.appBuilderProject?`[app] ${e.appBuilderProject}`:e.label||e.larkChatName||e.larkChatId||e.cwd.split("/").filter(Boolean).pop()||e.sessionId.slice(0,8),B=e.originOwnerPrincipalId,P=B?`@${m??`…${B.slice(-8)}`}`:null;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":`session-item-${e.sessionId}`,onClick:s,style:{paddingLeft:C,display:"grid",gridTemplateColumns:`${$H}px ${FH}px 1fr auto ${HH}px`,gridTemplateAreas:'"chev icon name dot time"',columnGap:`${UH}px`,alignItems:"center"},className:fe("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(IH,{tool:e.tool})}),h.jsxs("div",{style:{gridArea:"name"},className:"flex items-center gap-1 min-w-0",children:[e.dispatchedFromSessionId?h.jsx(yz,{"data-testid":`dispatched-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"dispatched from another session",children:h.jsx("title",{children:"由另一个 session dispatch 派生"})}):null,e.shiftFiredFromSessionId?h.jsx(GB,{"data-testid":`shift-fired-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"fired by clawd-shift scheduler",children:h.jsx("title",{children:"由 shift 排班到点 fire 派生"})}):null,e.larkChatId?h.jsx(qz,{"data-testid":`lark-chat-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"driven by feishu chat",children:h.jsx("title",{children:e.larkChatType==="p2p"?"飞书私聊会话(对方消息驱动)":"飞书群会话(群成员 @ bot 驱动)"})}):null,h.jsx("span",{"data-testid":`session-title-${e.sessionId}`,className:fe("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:T}),P?h.jsx("span",{"data-testid":`session-mirror-chip-${e.sessionId}`,title:`在 ${P.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:P}):null]}),i?h.jsx(tz,{"data-testid":`awaiting-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-3 h-3 text-warning shrink-0 animate-pulse",strokeWidth:2.25,"aria-label":"awaiting user"}):n?h.jsx("span",{"data-testid":`unread-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-2 h-2 rounded-full bg-error shrink-0","aria-label":"unread"}):r?h.jsx("span",{"data-testid":`running-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-2 h-2 rounded-full bg-success shrink-0 animate-pulse","aria-label":"running"}):null,x!=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:OH()?`⌘${x}`:`Ctrl+${x}`})}):h.jsx("span",{style:{gridArea:"time"},className:fe("text-[11px] text-text-400/70 text-right shrink-0","transition-opacity duration-150 group-hover:opacity-0"),children:e.updatedAt?S8(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:[u&&k&&c?h.jsx("button",{type:"button",title:"归档",onClick:A=>{A.stopPropagation(),c(e.sessionId,!0)},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":"archive session","data-testid":`archive-shortcut-${e.sessionId}`,children:h.jsx(kw,{className:"w-4 h-4"})}):null,h.jsxs(oy,{modal:!1,children:[h.jsx(ay,{asChild:!0,children:h.jsx("button",{type:"button",onClick:A=>A.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(LT,{className:"w-4 h-4"})})}),h.jsxs(fp,{align:"end",onClick:A=>A.stopPropagation(),children:[l&&w&&h.jsxs(yi,{onSelect:()=>l(e.sessionId,!y),"data-testid":`session-${y?"unpin":"pin"}-${e.sessionId}`,children:[y?h.jsx(t$,{className:"w-3 h-3 mr-2 text-text-400"}):h.jsx(r$,{className:"w-3 h-3 mr-2 text-text-400"}),y?"Unpin":"Pin"]}),k&&c&&h.jsxs(yi,{onSelect:()=>c(e.sessionId,!0),"data-testid":`session-archive-${e.sessionId}`,children:[h.jsx(kw,{className:"w-3 h-3 mr-2 text-text-400"}),"Archive"]}),o&&h.jsxs(yi,{onSelect:()=>b(!0),"data-testid":`session-rename-${e.sessionId}`,children:[h.jsx(OT,{className:"w-3 h-3 mr-2 text-text-400"}),"Rename"]}),p&&e.toolSessionId?h.jsxs(yi,{onSelect:()=>void N(),"data-testid":`session-copy-resume-${e.sessionId}`,children:[h.jsx(tp,{className:"w-3 h-3 mr-2 text-text-400"}),"Copy Resume Command"]}):null,(l||o||p&&e.toolSessionId)&&a&&h.jsx(KI,{}),a&&h.jsxs(yi,{onSelect:()=>void a(e.sessionId),className:"text-destructive focus:text-destructive focus:bg-destructive/10","data-testid":`session-delete-${e.sessionId}`,children:[h.jsx(Dx,{className:"w-3 h-3 mr-2"}),"Delete"]})]})]})]}):null]}),o?h.jsx(RH,{open:v,initialLabel:e.label??"",placeholder:e.cwd.split("/").pop()||"",onSubmit:A=>{o(e.sessionId,A),b(!1)},onCancel:()=>b(!1)}):null]})}function ly({node:e,depth:t=0,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,archiveShortcut:d,getContactDisplayName:f,showCopyResume:p}){const m=e.children.length>0,{isCollapsed:v,toggle:b}=FB(),_=!v(e.session.sessionId),x=g.useCallback(w=>{w.stopPropagation(),b(e.session.sessionId)},[b,e.session.sessionId]),y=m?h.jsx("button",{type:"button",onClick:x,"data-testid":`session-chevron-${e.session.sessionId}`,"aria-label":_?"collapse":"expand","aria-expanded":_,className:"shrink-0 flex items-center justify-center w-4 h-4 text-text-400 hover:text-text-100 cursor-pointer",children:_?h.jsx(ir,{className:"w-3 h-3"}):h.jsx(Un,{className:"w-3 h-3"})}):null;return h.jsxs("div",{"data-testid":`session-tree-node-${e.session.sessionId}`,children:[h.jsx(WH,{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,archiveShortcut:d,showCopyResume:p,depth:t,chevron:y,contactDisplayName:e.session.originOwnerPrincipalId?f==null?void 0:f(e.session.originOwnerPrincipalId):void 0}),m&&_?h.jsx("div",{"data-testid":`session-tree-children-${e.session.sessionId}`,children:e.children.map(w=>h.jsx(ly,{node:w,depth:t+1,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,archiveShortcut:d,getContactDisplayName:f,showCopyResume:p},w.session.sessionId))}):null]})}function VH(e){return e.forkedFromSessionId??e.dispatchedFromSessionId??e.shiftFiredFromSessionId}function YI(e){e=e.filter(s=>!s.ephemeral);const t=new Map;for(const s of e)t.set(s.sessionId,s);const n=new Map,r=[];for(const s of e){const o=VH(s);if(o&&t.has(o)){const a=n.get(o)??[];a.push(s),n.set(o,a)}else r.push(s)}const i=s=>{const a=[...n.get(s.sessionId)??[]].sort((l,c)=>l.createdAt<c.createdAt?-1:l.createdAt>c.createdAt?1:0);return{session:s,children:a.map(i)}};return[...r].sort(qH).map(i)}function QI(e){return[...e].sort((t,n)=>t.session.updatedAt<n.session.updatedAt?1:t.session.updatedAt>n.session.updatedAt?-1:0)}function qH(e,t){const n=typeof e.pinnedAt=="number",r=typeof t.pinnedAt=="number";if(n&&r){const i=typeof e.pinSortOrder=="number",s=typeof t.pinSortOrder=="number";return i&&s?e.pinSortOrder-t.pinSortOrder:i?-1:s?1:t.pinnedAt-e.pinnedAt}return n?-1:r||e.updatedAt<t.updatedAt?1:e.updatedAt>t.updatedAt?-1:0}function KH(e){return e.appBuilderProject?`[app] ${e.appBuilderProject}`:e.label?e.label:e.cwd.split("/").filter(Boolean).pop()??""}function iS(e,t){const n=t.trim().toLowerCase();return n===""?!0:e.toLowerCase().includes(n)}const GH={isCollapsed:()=>!1,toggle:()=>{},prune:()=>{}};function XH({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:b,showCopyResume:_,treatSessionsAsRoots:x,searchQuery:y}){const[w,k]=g.useState(null),[C,N]=g.useState(()=>new Set),T=p??(I=>C.has(I)),B=g.useCallback(I=>{if(m){m(I);return}N(R=>{const j=new Set(R);return j.has(I)?j.delete(I):j.add(I),j})},[m]),P=g.useMemo(()=>i==null?void 0:i.filter(I=>!I.ephemeral),[i]);if(e.length===0)return h.jsx(YH,{});const A=(y??"").trim();return A?h.jsx(Ax.Provider,{value:GH,children:h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(I=>{const R=P?P.filter(F=>F.ownerPersonaId===I.personaId).sort((F,D)=>D.updatedAt>F.updatedAt?1:-1):[],j=iS(I.label,A),z=R.filter(F=>iS(KH(F),A));if(!j&&z.length===0)return null;const $=j?R:z;return h.jsx(sS,{persona:I,active:I.personaId===t,editing:!1,onSelectPersona:n,onSubmitCreateSession:()=>{},onCancelCreateSession:()=>{},personaSessions:$,collapsed:!1,onToggleCollapsed:()=>{},activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:b,showCopyResume:_,treatSessionsAsRoots:x,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f},I.personaId)})})}):h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(I=>{const R=P?P.filter(j=>j.ownerPersonaId===I.personaId).sort((j,z)=>z.updatedAt>j.updatedAt?1:-1):[];return h.jsx(sS,{persona:I,active:I.personaId===t,editing:I.personaId===w,onSelectPersona:n,onStartCreateSession:r?()=>k(I.personaId):void 0,onSubmitCreateSession:j=>{k(null),r==null||r(I.personaId,j)},onCancelCreateSession:()=>k(null),personaSessions:R,collapsed:!T(I.personaId),onToggleCollapsed:()=>B(I.personaId),activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:b,showCopyResume:_,treatSessionsAsRoots:x,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f},I.personaId)})})}function YH(){return h.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-text-400",children:"还没有 persona。点上方 Personas 标题右侧 + 创建第一个。"})}function sS({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:b,onPinSession:_,showCopyResume:x,treatSessionsAsRoots:y,ownerPrincipalId:w,creatorDisplayNameByOwnerId:k}){const C=a.length>0,N=!l,T=g.useMemo(()=>{const A=[],I=new Map;for(const R of a){const j=R.creatorPrincipalId;if(R.larkChatId!=null||!j||w&&j===w){A.push(R);continue}const z=j,$=(k==null?void 0:k.get(z))??`…${z.slice(-8)}`,F=I.get(z);F?F.sessions.push(R):I.set(z,{groupKey:z,displayName:$,sessions:[R]})}return{self:A,byPeer:[...I.values()]}},[a,w,k]),B=T.byPeer.length>0,P=g.useMemo(()=>N&&!B?QI(YI(a)):[],[N,B,a]);return h.jsxs("div",{"data-testid":`persona-node-${e.personaId}`,children:[h.jsxs("div",{className:fe("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:[C?h.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),c()},"aria-label":N?"collapse":"expand","aria-expanded":N,"data-testid":`persona-chevron-${e.personaId}`,className:"flex h-4 w-4 shrink-0 items-center justify-center text-text-400 hover:text-text-100",children:N?h.jsx(ir,{className:"h-3 w-3"}):h.jsx(Un,{className:"h-3 w-3"})}):h.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),h.jsx(np,{tool:e.tool,className:fe("h-3.5 w-3.5 shrink-0",rp(e.tool))}),h.jsx("span",{className:"flex-1 truncate text-[13px]",children:e.label}),C?h.jsx("span",{className:"shrink-0 text-[10px] text-text-400 tabular-nums","aria-label":`${a.length} sessions`,children:a.length}):null,i?h.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),i()},"aria-label":"新建会话",title:"新建会话","data-testid":`persona-create-session-${e.personaId}`,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded text-text-400 opacity-0 hover:bg-text-100/10 hover:text-text-100 focus-visible:opacity-100 group-hover:opacity-100",children:h.jsx(a$,{className:"h-3.5 w-3.5"})}):null]}),n?h.jsx(QH,{personaId:e.personaId,tool:e.tool,onSubmit:s,onCancel:o}):null,C&&N?h.jsx("div",{"data-testid":`persona-sessions-${e.personaId}`,children:B?h.jsxs(h.Fragment,{children:[T.self.length>0&&h.jsx(oS,{groupKey:`${e.personaId}-self`,label:"我自己",testId:`persona-sessions-${e.personaId}-self`,sessions:T.self,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:_,showCopyResume:x}),T.byPeer.map(A=>h.jsx(oS,{groupKey:`${e.personaId}-peer-${A.groupKey}`,label:A.displayName,testId:`persona-sessions-${e.personaId}-peer-${A.groupKey}`,sessions:A.sessions,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:_,showCopyResume:x},`${e.personaId}-peer-${A.groupKey}`))]}):P.map(A=>h.jsx(ly,{node:A,depth:y?0:1,activeId:u,unreadIds:p,runningIds:f,awaitingIds:d,onSelect:I=>m==null?void 0:m(I),onDelete:v,onEdit:b,onPin:_,showCopyResume:x},A.session.sessionId))}):null]})}function oS({label:e,testId:t,sessions:n,activeSessionId:r,awaitingIds:i,runningIds:s,unreadIds:o,onSelectSession:a,onDeleteSession:l,onEditSession:c,onPinSession:u,showCopyResume:d}){const[f,p]=g.useState(!1),m=!f,v=g.useMemo(()=>m?QI(YI(n)):[],[m,n]);return h.jsxs("div",{"data-testid":t,children:[h.jsxs("button",{type:"button",onClick:()=>p(b=>!b),"aria-label":m?"collapse":"expand","aria-expanded":m,"data-testid":`${t}-chevron`,className:"flex items-center gap-1 w-full pl-7 pr-2 py-0.5 text-[11px] text-text-400 hover:text-text-200 transition-colors",children:[m?h.jsx(ir,{className:"h-3 w-3"}):h.jsx(Un,{className:"h-3 w-3"}),h.jsx($T,{className:"h-3 w-3","aria-hidden":!0}),h.jsx("span",{className:"truncate",children:e}),h.jsx("span",{className:"ml-auto tabular-nums",children:n.length})]}),m&&h.jsx("div",{children:v.map(b=>h.jsx(ly,{node:b,depth:2,activeId:r,unreadIds:o,runningIds:s,awaitingIds:i,onSelect:_=>a==null?void 0:a(_),onDelete:l,onEdit:c,onPin:u,showCopyResume:d},b.session.sessionId))})]})}function QH({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=ku(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(np,{tool:t,className:fe("h-3 w-3 shrink-0",rp(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(ul,{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(Dr,{className:"h-3 w-3"})})]})}function ZH(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function JH(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),r=parseFloat(n.fontSize);return t*r}function eU(e){return e/100*window.innerHeight}function tU(e){return e/100*window.innerWidth}function nU(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 Xl({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=nU(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=JH(t,i);break}case"em":{r=ZH(t,i);break}case"vh":{r=eU(i);break}case"vw":{r=tU(i);break}}return r}function Nn(e){return parseFloat(e.toFixed(3))}function Ha({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 m0(e){const{panels:t}=e,n=Ha({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=Xl({groupSize:n,panelElement:i,styleProp:s.collapsedSize});o=Nn(u/n*100)}let a;if(s.defaultSize!==void 0){const u=Xl({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=Nn(u/n*100)}let l=0;if(s.minSize!==void 0){const u=Xl({groupSize:n,panelElement:i,styleProp:s.minSize});l=Nn(u/n*100)}let c=100;if(s.maxSize!==void 0){const u=Xl({groupSize:n,panelElement:i,styleProp:s.maxSize});c=Nn(u/n*100)}return{groupResizeBehavior:s.groupResizeBehavior,collapsedSize:o,collapsible:s.collapsible===!0,defaultSize:a,disabled:s.disabled,minSize:l,maxSize:c,panelId:r.id}})}function rt(e,t="Assertion error"){if(!e)throw Error(t)}function g0(e,t){return Array.from(t).sort(e==="horizontal"?rU:iU)}function rU(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function iU(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function ZI(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function JI(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 sU({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}=JI(r,o),c=e==="horizontal"?a:l;c<s&&(s=c,i=o)}return rt(i,"No rect found"),i}let _d;function oU(){return _d===void 0&&(typeof matchMedia=="function"?_d=!!matchMedia("(pointer:coarse)").matches:_d=!1),_d}function eR(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=g0(n,Array.from(t.children).filter(ZI).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 b=r.find(_=>_.element===v);if(b){if(f){const _=f.element.getBoundingClientRect(),x=v.getBoundingClientRect();let y;if(l){const w=n==="horizontal"?new DOMRect(_.right,_.top,0,_.height):new DOMRect(_.left,_.bottom,_.width,0),k=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:{y=[w,k];break}case 1:{const C=p[0],N=sU({orientation:n,rects:[_,x],targetRect:C.element.getBoundingClientRect()});y=[C,N===_?k:w];break}default:{y=p;break}}}else p.length?y=p:y=[n==="horizontal"?new DOMRect(_.right,x.top,x.left-_.right,x.height):new DOMRect(x.left,_.bottom,x.width,x.top-_.bottom)];for(const w of y){let k="width"in w?w:w.element.getBoundingClientRect();const C=oU()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(k.width<C){const T=C-k.width;k=new DOMRect(k.x-T/2,k.y,k.width+T,k.height)}if(k.height<C){const T=C-k.height;k=new DOMRect(k.x,k.y-T/2,k.width,k.height+T)}const N=m<=c||m>u;!a&&!N&&o.push({group:e,groupSize:Ha({group:e}),panels:[f,b],separator:"width"in w?void 0:w,rect:k}),a=!1}}l=!1,f=b,p=[]}}else if(v.hasAttribute("data-separator")){v.ariaDisabled!==null&&(a=!0);const b=i.find(_=>_.element===v);b?p.push(b):(f=void 0,p=[])}else l=!0}return o}var cs;class tR{constructor(){h1(this,cs,{})}addListener(t,n){const r=wl(this,cs)[t];return r===void 0?wl(this,cs)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=wl(this,cs)[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(){f1(this,cs,{})}removeListener(t,n){const r=wl(this,cs)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}cs=new WeakMap;let Ea={cursorFlags:0,state:"inactive"};const cy=new tR;function xo(){return Ea}function aU(e){return cy.addListener("change",e)}function lU(e){const t=Ea,n={...Ea};n.cursorFlags=e,Ea=n,cy.emit("change",{prev:t,next:n})}function Na(e){const t=Ea;Ea=e,cy.emit("change",{prev:t,next:e})}const cU=e=>e,Dm=()=>{},nR=1,rR=2,iR=4,sR=8,aS=3,lS=12;let xd;function cS(){return xd===void 0&&(xd=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(xd=!0)),xd}function uU({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&&cS()){const s=(e&nR)!==0,o=(e&rR)!==0,a=(e&iR)!==0,l=(e&sR)!==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 cS()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const uS=new WeakMap;function uy(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=uS.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=xo();switch(r.state){case"active":case"hover":{const i=uU({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}}uS.set(e,{prevStyle:t,styleSheet:n})}let Yr=new Map;const oR=new tR;function dU(e){Yr=new Map(Yr),Yr.delete(e)}function dS(e,t){for(const[n]of Yr)if(n.id===e)return n}function Ss(e,t){for(const[n,r]of Yr)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function jo(){return Yr}function dy(e,t){return oR.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function Di(e,t,n){const r=Yr.get(e);Yr=new Map(Yr),Yr.set(e,t),oR.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:r,next:t})}function aR(e){const t=xo();let n=!1;switch(t.state){case"active":Na({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(uy(e),n=!0,t.hitRegions.forEach(r=>{const i=Ss(r.group.id,!0);Di(r.group,i,{isUserInteraction:!0})}))}return n}function hS(e){e.defaultPrevented||aR(e.currentTarget)}function hU(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const o=JI(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 fU(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function pU(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:mS(e),b:mS(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();rt(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:pS(fS(n.a)),b:pS(fS(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 mU=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function gU(e){const t=getComputedStyle(lR(e)??e).display;return t==="flex"||t==="inline-flex"}function vU(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||gU(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"||mU.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function fS(e){let t=e.length;for(;t--;){const n=e[t];if(rt(n,"Missing node"),vU(n))return n}return null}function pS(e){return e&&Number(getComputedStyle(e).zIndex)||0}function mS(e){const t=[];for(;e;)t.push(e),e=lR(e);return t}function lR(e){const{parentNode:t}=e;return fU(t)?t.host:t}function _U(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 xU({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!ZI(n)||n.contains(e)||e.contains(n))return!0;if(pU(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(_U(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function hy(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=eR(i),o=hU(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&xU({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function yU(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function _n(e,t,n=0){return Math.abs(Nn(e)-Nn(t))<=n}function qr(e,t){return _n(e,t)?0:e>t?1:-1}function ma({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){const{collapsedSize:i=0,collapsible:s,disabled:o,maxSize:a=100,minSize:l=0}=t;if(o&&!e)return n;if(qr(r,l)<0)if(s){const c=(i+l)/2;qr(r,c)<0?r=i:r=l}else r=l;return r=Math.min(a,r),r=Nn(r),r}function Zc({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(_n(e,0))return t;const o=s==="imperative-api",a=Object.values(t),l=Object.values(i),c=[...a],[u,d]=r;rt(u!=null,"Invalid first pivot index"),rt(d!=null,"Invalid second pivot index");let f=0;switch(s){case"keyboard":{{const v=e<0?d:u,b=n[v];rt(b,`Panel constraints not found for index ${v}`);const{collapsedSize:_=0,collapsible:x,minSize:y=0}=b;if(x){const w=a[v];if(rt(w!=null,`Previous layout not found for panel index ${v}`),_n(w,_)){const k=y-w;qr(k,Math.abs(e))>0&&(e=e<0?0-k:k)}}}{const v=e<0?u:d,b=n[v];rt(b,`No panel constraints found for index ${v}`);const{collapsedSize:_=0,collapsible:x,minSize:y=0}=b;if(x){const w=a[v];if(rt(w!=null,`Previous layout not found for panel index ${v}`),_n(w,y)){const k=w-_;qr(k,Math.abs(e))>0&&(e=e<0?0-k:k)}}}break}default:{const v=e<0?d:u,b=n[v];rt(b,`Panel constraints not found for index ${v}`);const _=a[v],{collapsible:x,collapsedSize:y,minSize:w}=b;if(x&&qr(_,w)<0)if(e>0){const k=w-y,C=k/2,N=_+e;qr(N,w)<0&&(e=qr(e,C)<=0?0:k)}else{const k=w-y,C=100-k/2,N=_-e;qr(N,w)<0&&(e=qr(100+e,C)>0?0:-k)}break}}{const v=e<0?1:-1;let b=e<0?d:u,_=0;for(;;){const y=a[b];rt(y!=null,`Previous layout not found for panel index ${b}`);const w=ma({overrideDisabledPanels:o,panelConstraints:n[b],prevSize:y,size:100})-y;if(_+=w,b+=v,b<0||b>=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 b=Math.abs(e)-Math.abs(f),_=a[v];rt(_!=null,`Previous layout not found for panel index ${v}`);const x=_-b,y=ma({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:_,size:x});if(!_n(_,y)&&(f+=_-y,c[v]=y,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?v--:v++}}if(yU(l,c))return i;{const v=e<0?d:u,b=a[v];rt(b!=null,`Previous layout not found for panel index ${v}`);const _=b+f,x=ma({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:b,size:_});if(c[v]=x,!_n(x,_)){let y=_-x,w=e<0?d:u;for(;w>=0&&w<n.length;){const k=c[w];rt(k!=null,`Previous layout not found for panel index ${w}`);const C=k+y,N=ma({overrideDisabledPanels:o,panelConstraints:n[w],prevSize:k,size:C});if(_n(k,N)||(y-=N-k,c[w]=N),_n(y,0))break;e>0?w--:w++}}}const p=Object.values(c).reduce((v,b)=>b+v,0);if(!_n(p,100,.1))return i;const m=Object.keys(i);return c.reduce((v,b,_)=>(v[m[_]]=b,v),{})}function yo(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||qr(e[n],t[n])!==0)return!1;return!0}function bo({layout:e,panelConstraints:t}){const n=Object.values(e),r=[...n],i=r.reduce((a,l)=>a+l,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(a=>`${a}%`).join(", ")}`);if(!_n(i,100)&&r.length>0)for(let a=0;a<t.length;a++){const l=r[a];rt(l!=null,`No layout data found for index ${a}`);const c=100/i*l;r[a]=c}let s=0;for(let a=0;a<t.length;a++){const l=n[a];rt(l!=null,`No layout data found for index ${a}`);const c=r[a];rt(c!=null,`No layout data found for index ${a}`);const u=ma({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});c!=u&&(s+=c-u,r[a]=u)}if(!_n(s,0))for(let a=0;a<t.length;a++){const l=r[a];rt(l!=null,`No layout data found for index ${a}`);const c=l+s,u=ma({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});if(l!==u&&(s-=u-l,r[a]=u,_n(s,0)))break}const o=Object.keys(e);return r.reduce((a,l,c)=>(a[o[c]]=l,a),{})}function cR({groupId:e,panelId:t}){const n=()=>{const l=jo();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(b=>b.id===t),m=p===0,v=p===c.length-1;if(v&&l<f&&(m||c.slice(0,p).every((b,_)=>{const x=d[_];return(x==null?void 0:x.collapsible)&&_n(x.collapsedSize,u[x.panelId])}))){const b=c.slice(0,p).reduce((_,x)=>_+u[x.id],0);return{...u,[t]:Nn(100-b)}}return Zc({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(),b=o({nextSize:l,panels:f.panels,prevLayout:m,derivedPanelConstraints:d}),_=bo({layout:b,panelConstraints:d});yo(m,_)||Di(f,{defaultLayoutDeferred:u,derivedPanelConstraints:d,groupSize:p,layout:_,separatorToPanels:v})};return{collapse:()=>{const{collapsible:l,collapsedSize:c}=r(),{mutableValues:u}=i(),d=s();l&&d!==c&&(u.expandToSize=d,a(c))},expand:()=>{const{collapsible:l,collapsedSize:c,minSize:u}=r(),{mutableValues:d}=i(),f=s();if(l&&f===c){let p=d.expandToSize??u;p===0&&(p=1),a(p)}},getSize:()=>{const{group:l}=n(),c=s(),{element:u}=i(),d=l.orientation==="horizontal"?u.offsetWidth:u.offsetHeight;return{asPercentage:c,inPixels:d}},isCollapsed:()=>{const{collapsible:l,collapsedSize:c}=r(),u=s();return l&&_n(c,u)},resize:l=>{const{group:c}=n(),{element:u}=i(),d=Ha({group:c}),f=Xl({groupSize:d,panelElement:u,styleProp:l}),p=Nn(f/d*100);a(p)}}}function gS(e){if(e.defaultPrevented)return;const t=jo();hy(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=cR({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function eh(e){const t=jo();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 uR({groupId:e}){const t=()=>{const n=jo();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=bo({layout:n,panelConstraints:i});return r?a:(yo(a,c)||Di(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:o,layout:c,separatorToPanels:l}),c)}}}function Us(e,t){const n=eh(e),r=Ss(n.id,!0),i=n.separators.find(u=>u.element===e);rt(i,"Matching separator not found");const s=r.separatorToPanels.get(i);rt(s,"Matching panels not found");const o=s.map(u=>n.panels.indexOf(u)),a=uR({groupId:n.id}).getLayout(),l=Zc({delta:t,initialLayout:a,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),c=bo({layout:l,panelConstraints:r.derivedPanelConstraints});yo(a,c)||Di(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function vS(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=eh(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Us(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Us(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Us(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Us(t,-5);break}case"End":{e.preventDefault(),Us(t,100);break}case"Enter":{e.preventDefault();const r=eh(t),i=Ss(r.id,!0),{derivedPanelConstraints:s,layout:o,separatorToPanels:a}=i,l=r.separators.find(f=>f.element===t);rt(l,"Matching separator not found");const c=a.get(l);rt(c,"Matching panels not found");const u=c[0],d=s.find(f=>f.panelId===u.id);if(rt(d,"Panel metadata not found"),d.collapsible){const f=o[u.id],p=d.collapsedSize===f?r.mutableState.expandedPanelSizes[u.id]??d.minSize:d.collapsedSize;Us(t,p-f)}break}case"F6":{e.preventDefault();const r=eh(t).separators.map(o=>o.element),i=Array.from(r).findIndex(o=>o===e.currentTarget);rt(i!==null,"Index not found");const s=e.shiftKey?i>0?i-1:r.length-1:i+1<r.length?i+1:0;r[s].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),Us(t,-100);break}}}function _S(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=jo(),n=hy(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)}),Na({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function dR({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 b=r.get(u),_=i.get(u);if(!b||!_)return;const{defaultLayoutDeferred:x,derivedPanelConstraints:y,groupSize:w,layout:k,separatorToPanels:C}=_;if(y&&k&&C){const N=Zc({delta:v,initialLayout:b,panelConstraints:y,pivotIndices:c.panels.map(T=>p.indexOf(T)),prevLayout:k,trigger:"mouse-or-touch"});if(yo(N,k)){if(v!==0&&!m)switch(f){case"horizontal":{a|=v<0?nR:rR;break}case"vertical":{a|=v<0?iR:sR;break}}}else Di(c.group,{defaultLayoutDeferred:x,derivedPanelConstraints:y,groupSize:w,layout:N,separatorToPanels:C})}});let l=0;t.movementX===0?l|=o&aS:l|=a&aS,t.movementY===0?l|=o&lS:l|=a&lS,lU(l),uy(e)}function xS(e){const t=jo(),n=xo();switch(n.state){case"active":dR({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function yS(e){var r,i;if(e.defaultPrevented)return;const t=xo(),n=jo();switch(t.state){case"active":{if(e.buttons===0){Na({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const o=Ss(s.group.id,!0);Di(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))}dR({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=hy(e,n);s.length===0?t.state!=="inactive"&&Na({cursorFlags:0,state:"inactive"}):Na({cursorFlags:0,hitRegions:s,state:"hover"}),uy(e.currentTarget);break}}}function bS(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(xo().state){case"hover":Na({cursorFlags:0,state:"inactive"})}}function wS(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||aR(e.currentTarget)&&e.preventDefault()}function SS(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const o=Nn(s.defaultSize);n+=o,r[s.panelId]=o}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=Nn((100-n)/i);for(const o of e)o.defaultSize===void 0&&(r[o.panelId]=s)}return r}function bU(e,t,n){if(!n[0])return;const r=e.panels.find(l=>l.element===t);if(!r||!r.onResize)return;const i=Ha({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,a={asPercentage:Nn(s/i*100),inPixels:s};r.mutableValues.prevSize=a,r.onResize(a,r.id,o)}function wU(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 SU({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=Nn(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]=Nn(f/s*c)}else{const d=Nn(c/l.length);for(const f of l)u[f]=d}return u}function kU(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 Go=new Map;function CU(e){let t=!0;rt(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,s=new n(m=>{for(const v of m){const{borderBoxSize:b,target:_}=v;if(_===e.element){if(t){const x=Ha({group:e});if(x===0)return;const y=Ss(e.id);if(!y)return;const w=m0(e),k=y.defaultLayoutDeferred?SS(w):y.layout,C=SU({group:e,nextGroupSize:x,prevGroupSize:y.groupSize,prevLayout:k}),N=bo({layout:C,panelConstraints:w});if(!y.defaultLayoutDeferred&&yo(y.layout,N)&&wU(y.derivedPanelConstraints,w)&&y.groupSize===x)return;Di(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:w,groupSize:x,layout:N,separatorToPanels:y.separatorToPanels})}}else bU(e,_,b)}});s.observe(e.element),e.panels.forEach(m=>{rt(!r.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),r.add(m.id),m.onResize&&s.observe(m.element)});const o=Ha({group:e}),a=m0(e),l=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(kU(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[l]??c??SS(a),d=bo({layout:u,panelConstraints:a}),f=e.element.ownerDocument;Go.set(f,(Go.get(f)??0)+1);const p=new Map;return eR(e).forEach(m=>{m.separator&&p.set(m.separator,m.panels)}),Di(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:a,groupSize:o,layout:d,separatorToPanels:p}),e.separators.forEach(m=>{rt(!i.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),i.add(m.id),m.element.addEventListener("keydown",vS)}),Go.get(f)===1&&(f.addEventListener("contextmenu",hS,!0),f.addEventListener("dblclick",gS,!0),f.addEventListener("pointerdown",_S,!0),f.addEventListener("pointerleave",xS),f.addEventListener("pointermove",yS),f.addEventListener("pointerout",bS),f.addEventListener("pointerup",wS,!0)),function(){t=!1,Go.set(f,Math.max(0,(Go.get(f)??0)-1)),dU(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",vS)}),Go.get(f)||(f.removeEventListener("contextmenu",hS,!0),f.removeEventListener("dblclick",gS,!0),f.removeEventListener("pointerdown",_S,!0),f.removeEventListener("pointerleave",xS),f.removeEventListener("pointermove",yS),f.removeEventListener("pointerout",bS),f.removeEventListener("pointerup",wS,!0)),s.disconnect()}}function EU(){const[e,t]=g.useState({}),n=g.useCallback(()=>t({}),[]);return[e,n]}function fy(e){const t=g.useId();return`${e??t}`}const Do=typeof window<"u"?g.useLayoutEffect:g.useEffect;function mc(e){const t=g.useRef(e);return Do(()=>{t.current=e},[e]),g.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function py(...e){return mc(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function my(e){const t=g.useRef({...e});return Do(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const hR=g.createContext(null);function NU(e,t){const n=g.useRef({getLayout:()=>({}),setLayout:cU});g.useImperativeHandle(t,()=>n.current,[]),Do(()=>{Object.assign(n.current,uR({groupId:e}))})}function gy({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=mc(A=>{yo(m.current.onLayoutChange,A)||(m.current.onLayoutChange=A,l==null||l(A))}),b=mc((A,I)=>{yo(m.current.onLayoutChanged,A)||(m.current.onLayoutChanged=A,c==null||c(A,{isUserInteraction:I}))}),_=fy(a),x=g.useRef(null),[y,w]=EU(),k=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),C=py(x,s);NU(_,o);const N=mc((A,I)=>{const R=xo(),j=dS(A),z=Ss(A);if(z){let $=!1;switch(R.state){case"active":{$=R.hitRegions.some(F=>F.group===j);break}}return{flexGrow:z.layout[I]??1,pointerEvents:$?"none":void 0}}if(n!=null&&n[I])return{flexGrow:n==null?void 0:n[I]}}),T=my({defaultLayout:n,disableCursor:r}),B=g.useMemo(()=>({get disableCursor(){return!!T.disableCursor},getPanelStyles:N,id:_,orientation:u,registerPanel:A=>{const I=k.current;return I.panels=g0(u,[...I.panels,A]),w(),()=>{I.panels=I.panels.filter(R=>R!==A),w()}},registerSeparator:A=>{const I=k.current;return I.separators=g0(u,[...I.separators,A]),w(),()=>{I.separators=I.separators.filter(R=>R!==A),w()}},updatePanelProps:(A,{disabled:I})=>{const R=k.current.panels.find($=>$.id===A);R&&(R.panelConstraints.disabled=I);const j=dS(_),z=Ss(_);j&&z&&Di(j,{...z,derivedPanelConstraints:m0(j)})},updateSeparatorProps:(A,{disabled:I,disableDoubleClick:R})=>{const j=k.current.separators.find(z=>z.id===A);j&&(j.disabled=I,j.disableDoubleClick=R)}}),[N,_,w,u,T]),P=g.useRef(null);return Do(()=>{const A=x.current;if(A===null)return;const I=k.current;let R;if(T.defaultLayout!==void 0&&Object.keys(T.defaultLayout).length===I.panels.length){R={};for(const E of I.panels){const H=T.defaultLayout[E.id];H!==void 0&&(R[E.id]=H)}}const j={disabled:!!i,element:A,id:_,mutableState:{defaultLayout:R,disableCursor:!!T.disableCursor,expandedPanelSizes:k.current.lastExpandedPanelSizes,layouts:k.current.layouts},orientation:u,panels:I.panels,resizeTargetMinimumSize:I.resizeTargetMinimumSize,separators:I.separators};P.current=j;const z=CU(j),{defaultLayoutDeferred:$,derivedPanelConstraints:F,layout:D}=Ss(j.id,!0);!$&&F.length>0&&(v(D),b(D,!1));const O=dy(_,E=>{const{defaultLayoutDeferred:H,derivedPanelConstraints:V,layout:L}=E.next;if(H||V.length===0)return;const ne=j.panels.map(({id:G})=>G).join(",");j.mutableState.layouts[ne]=L,V.forEach(G=>{if(G.collapsible){const{layout:ye}=E.prev??{};if(ye){const Fe=_n(G.collapsedSize,L[G.panelId]),ue=_n(G.collapsedSize,ye[G.panelId]);Fe&&!ue&&(j.mutableState.expandedPanelSizes[G.panelId]=ye[G.panelId])}}});const ae=xo().state!=="active";v(L),ae&&b(L,E.isUserInteraction)});return()=>{P.current=null,z(),O()}},[i,_,b,v,u,y,T]),g.useEffect(()=>{const A=P.current;A&&(A.mutableState.defaultLayout=n,A.mutableState.disableCursor=!!r)}),h.jsx(hR.Provider,{value:B,children:h.jsx("div",{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:C,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})})}gy.displayName="Group";function vy(){const e=g.useContext(hR);return rt(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function TU(e,t){const{id:n}=vy(),r=g.useRef({collapse:Dm,expand:Dm,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Dm});g.useImperativeHandle(t,()=>r.current,[]),Do(()=>{Object.assign(r.current,cR({groupId:n,panelId:e}))})}function tf({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,b=fy(l),_=my({disabled:s}),x=g.useRef(null),y=py(x,o),{getPanelStyles:w,id:k,orientation:C,registerPanel:N,updatePanelProps:T}=vy(),B=d!==null,P=mc((j,z,$)=>{d==null||d(j,l,$)});Do(()=>{const j=x.current;if(j!==null){const z={element:j,id:b,idIsStable:v,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:B?P:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:c,minSize:u}};return N(z)}},[a,n,r,i,B,b,v,c,u,P,N,_]),g.useEffect(()=>{T(b,{disabled:s})},[s,b,T]),TU(b,f);const A=()=>{const j=w(k,b);if(j)return JSON.stringify(j)},I=g.useSyncExternalStore(j=>dy(k,j),A,A);let R;return I?R=JSON.parse(I):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":b,id:b,ref:y,style:{...PU,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:C==="horizontal"?"pan-y":"pan-x"},children:e})})}tf.displayName="Panel";const PU={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function IU({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=bo({layout:Zc({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=bo({layout:Zc({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:o}}function fR({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:s,style:o,...a}){const l=fy(s),c=my({disabled:n,disableDoubleClick:r}),[u,d]=g.useState({}),[f,p]=g.useState("inactive"),[m,v]=g.useState(!1),b=g.useRef(null),_=py(b,i),{disableCursor:x,id:y,orientation:w,registerSeparator:k,updateSeparatorProps:C}=vy(),N=w==="horizontal"?"vertical":"horizontal";Do(()=>{const P=b.current;if(P!==null){const A={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:P,id:l},I=k(A),R=aU(z=>{p(z.next.state!=="inactive"&&z.next.hitRegions.some($=>$.separator===A)?z.next.state:"inactive")}),j=dy(y,z=>{const{derivedPanelConstraints:$,layout:F,separatorToPanels:D}=z.next,O=D.get(A);if(O){const E=O[0],H=O.indexOf(E);d(IU({layout:F,panelConstraints:$,panelId:E.id,panelIndex:H}))}});return()=>{R(),j(),I()}}},[y,l,k,c]),g.useEffect(()=>{C(l,{disabled:n,disableDoubleClick:r})},[n,r,l,C]);let T;n&&!x&&(T="not-allowed");let B;if(n)B="disabled";else switch(f){case"active":{B="active";break}default:m?B="focus":B=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":B,"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})}fR.displayName="Separator";function RU(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 MU(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 AU=/^Scheduled (?:recurring job|one-shot task) ([0-9a-f]{8}) \(([^)]+)\)/;function LU(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(AU);if(!a)continue;r.set(a[1],{id:a[1],cron:s.cron,prompt:s.prompt,recurring:s.recurring,humanSchedule:a[2],createdAt:s.ts,toolUseId:s.toolUseId});continue}const o=n.get(i.toolUseId);o!==void 0&&(n.delete(i.toolUseId),i.error||r.delete(o))}return Array.from(r.values()).sort((i,s)=>i.createdAt.localeCompare(s.createdAt))}const jU=["TaskCreate","TaskUpdate","TaskList","TaskGet"];function DU(e){return jU.includes(e)}function pR(e){return e==="in_progress"||e==="completed"?e:"pending"}function OU(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:pR(n.status),activeForm:i,description:s}]}function BU(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=pR(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 zU(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=OU(t,i.input);break;case"TaskUpdate":t=BU(t,i.input);break}}return{tasks:t,lastEventIndex:n}}function $U(e){const{tasks:t,lastEventIndex:n}=zU(e);let r=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind==="todo-checklist"){r=c;break}const i=[],s=new Map,o=new Map,a=new Map,l=(c,u)=>{var f,p,m;const d={agentId:u.agentId,status:u.status};u.description?d.description=u.description:(f=c.progress)!=null&&f.description&&(d.description=c.progress.description),u.lastToolName?d.lastToolName=u.lastToolName:(p=c.progress)!=null&&p.lastToolName&&(d.lastToolName=c.progress.lastToolName),u.stats?d.stats=u.stats:(m=c.progress)!=null&&m.stats&&(d.stats=c.progress.stats),c.progress=d};for(let c=0;c<e.length;c++){const u=e[c];switch(u.kind){case"tool-call":{const d={kind:"merged-tool",seq:u.seq,tool:u.tool,toolKind:u.toolKind,toolUseId:u.toolUseId,input:u.input,pending:!0};s.set(u.toolUseId,i.length),i.push(d);break}case"tool-result":{const d=s.get(u.toolUseId);if(d!==void 0){const p=i[d];p.output=u.output,p.error=u.error,p.pending=!1,s.delete(u.toolUseId);break}const f=o.get(u.toolUseId);if(f!==void 0){const p=i[f];p.output=u.output,p.error=u.error,p.pending=!1,u.toolResultExtra&&(p.toolResultExtra=u.toolResultExtra);break}break}case"agent-call":{const d={kind:"merged-agent",seq:u.seq,toolUseId:u.toolUseId,description:u.description,input:u.input,pending:!0,notifications:[]};o.set(u.toolUseId,i.length),i.push(d);const f=a.get(u.toolUseId);f&&(l(d,f),a.delete(u.toolUseId));break}case"agent-progress":{const d=o.get(u.toolUseId);if(d!==void 0){l(i[d],u);break}a.set(u.toolUseId,u);break}case"agent-notification":{const d=u.parentToolUseId;if(d){const f=o.get(d);if(f!==void 0){i[f].notifications.push({text:u.text,taskId:u.taskId});break}}i.push({kind:"agent-notification",seq:u.seq,text:u.text,taskId:u.taskId,parentToolUseId:u.parentToolUseId});break}case"todo-checklist":{c===r&&u.todos.length>0&&i.push({kind:"todo-checklist",seq:u.seq,toolUseId:u.toolUseId,todos:u.todos});break}case"task-event":{c===n&&t.length>0&&i.push({kind:"plan-card",seq:u.seq,tasks:t});break}default:i.push(u)}}return i}const FU=new Set(["permission-inline","question-card"]);function HU(e){return e.kind==="user-text"?!0:e.kind==="user-meta"&&e.metaKind==="slash-command"}function UU(e,t={}){const n=[];let r=null,i=-1;for(let o=e.length-1;o>=0;o--)if(e[o].kind==="turn-end"){i=o;break}const s=(o,a)=>{r&&(n.push(WU(r,o,a)),r=null)};for(let o=0;o<e.length;o++){const a=e[o];if(a.kind==="turn-end"){s(a,!0);continue}const l=t.implicitCloseOnUserText||o>i;if(HU(a)&&(r===null||l)){s(void 0,!0),r={query:a,body:[]};continue}r===null?r={body:[a]}:r.body.push(a)}return s(void 0,t.closeTrailing===!0),n}function WU(e,t,n){const{query:r,body:i}=e,s=VU(i,t,n),o=qU(i,s),a=GU(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 VU(e,t,n){if(!n)return"running";if((t==null?void 0:t.reason)==="interrupted")return"interrupted";const r=v0(e,i=>i.kind==="error");return r>=0&&!e.slice(r+1).some(s=>s.kind==="assistant-text")?"error":"done"}function qU(e,t){if(t==="running"){const i=[];for(let s=e.length-1;s>=0&&FU.has(e[s].kind);s--)i.unshift(e[s]);return i}const n=[];e.forEach((i,s)=>{i.kind==="merged-agent"&&i.pending&&n.push(s)});const r=t==="error"?v0(e,i=>i.kind==="error"):v0(e,i=>i.kind==="assistant-text");return r>=0&&n.push(r),n.sort((i,s)=>i-s).map(i=>e[i])}const KU=new Set(["assistant-thinking","user-meta"]);function GU(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(KU.has(o.kind)){r.push(o);continue}s(),r.push(o)}return s(),r}function v0(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}const XU={Read:["正在读取","已读取"],Bash:["正在运行","已运行"],Grep:["正在搜索","已搜索"],Glob:["正在搜索","已搜索"],Edit:["正在编辑","已编辑"],Write:["正在写入","已写入"],WebFetch:["正在抓取","已抓取"],WebSearch:["正在搜索","已搜索"],Skill:["正在读取","已读取"]};function YU(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 mR(e){const t=XU[e.tool],n=t?e.pending?t[0]:t[1]:e.pending?`正在执行 ${e.tool}`:`已执行 ${e.tool}`,r=YU(e.input);return r?`${n} ${r}`:n}function QU({item:e,renderItemDetail:t}){const[n,r]=g.useState(!1),i=n?ir:Un,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:fe("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(In,{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:mR(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 ZU({items:e,defaultExpanded:t=!1,renderItemDetail:n}){const[r,i]=g.useState(t);if(e.length===0)return null;const s=e.some(c=>c.pending),o=s?[...e].reverse().find(c=>c.pending):e[e.length-1],a=!s&&e.length>1?` 等 ${e.length} 项`:"",l=r?ir:Un;return h.jsxs("div",{"data-testid":"tool-call-group",className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>i(c=>!c),"aria-expanded":r,"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:[s&&!r?h.jsx(In,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):h.jsx(l,{className:"w-3.5 h-3.5 shrink-0"}),r?h.jsx("span",{className:"min-w-0 truncate opacity-70",children:s?"正在执行":`${e.length} 项`}):h.jsxs("span",{className:fe("truncate min-w-0",s&&"text-text-300"),children:[mR(o),a]})]}),r?h.jsx("div",{className:"mt-0.5 flex flex-col pl-5",children:e.map(c=>h.jsx(QU,{item:c,renderItemDetail:n},c.toolUseId))}):null]})}function JU(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 eW(e,t){const n=t!==void 0?`耗时 ${JU(t)}`:"";switch(e){case"interrupted":return n?`已中断 · ${n}`:"已中断";case"error":return n?`出错 · ${n}`:"出错";default:return n||"已完成"}}function tW({status:e="done",durationMs:t,defaultExpanded:n=!1,children:r}){const[i,s]=g.useState(n),o=i?ir:Un;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:fe("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:eW(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 nW=/<(system-reminder|related-dir|clawd-shift-fire)\b[^>]*>[\s\S]*?<\/\1>/gi,rW=/<builder-preview\b[^>]*\/>/gi;function gR(e){return e?e.replace(nW,"").replace(rW,"").trim():""}const iW=gR;function sW(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const oW=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,aW=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,lW={};function kS(e,t){return(lW.jsx?aW:oW).test(e)}const cW=/[ \t\n\f\r]/g;function uW(e){return typeof e=="object"?e.type==="text"?CS(e.value):!1:CS(e)}function CS(e){return e.replace(cW,"")===""}class Cu{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Cu.prototype.normal={};Cu.prototype.property={};Cu.prototype.space=void 0;function vR(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Cu(n,r,t)}function _0(e){return e.toLowerCase()}class Wn{constructor(t,n){this.attribute=n,this.property=t}}Wn.prototype.attribute="";Wn.prototype.booleanish=!1;Wn.prototype.boolean=!1;Wn.prototype.commaOrSpaceSeparated=!1;Wn.prototype.commaSeparated=!1;Wn.prototype.defined=!1;Wn.prototype.mustUseProperty=!1;Wn.prototype.number=!1;Wn.prototype.overloadedBoolean=!1;Wn.prototype.property="";Wn.prototype.spaceSeparated=!1;Wn.prototype.space=void 0;let dW=0;const Me=Oo(),At=Oo(),x0=Oo(),Q=Oo(),at=Oo(),Ta=Oo(),Gn=Oo();function Oo(){return 2**++dW}const y0=Object.freeze(Object.defineProperty({__proto__:null,boolean:Me,booleanish:At,commaOrSpaceSeparated:Gn,commaSeparated:Ta,number:Q,overloadedBoolean:x0,spaceSeparated:at},Symbol.toStringTag,{value:"Module"})),Om=Object.keys(y0);class _y extends Wn{constructor(t,n,r,i){let s=-1;if(super(t,n),ES(this,"space",i),typeof r=="number")for(;++s<Om.length;){const o=Om[s];ES(this,Om[s],(r&y0[o])===y0[o])}}}_y.prototype.defined=!0;function ES(e,t,n){n&&(e[t]=n)}function fl(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[_0(r)]=r,n[_0(s.attribute)]=r}return new Cu(t,n,e.space)}const _R=fl({properties:{ariaActiveDescendant:null,ariaAtomic:At,ariaAutoComplete:null,ariaBusy:At,ariaChecked:At,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:at,ariaCurrent:null,ariaDescribedBy:at,ariaDetails:null,ariaDisabled:At,ariaDropEffect:at,ariaErrorMessage:null,ariaExpanded:At,ariaFlowTo:at,ariaGrabbed:At,ariaHasPopup:null,ariaHidden:At,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:at,ariaLevel:Q,ariaLive:null,ariaModal:At,ariaMultiLine:At,ariaMultiSelectable:At,ariaOrientation:null,ariaOwns:at,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:At,ariaReadOnly:At,ariaRelevant:null,ariaRequired:At,ariaRoleDescription:at,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:At,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 xR(e,t){return t in e?e[t]:t}function yR(e,t){return xR(e,t.toLowerCase())}const hW=fl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ta,acceptCharset:at,accessKey:at,action:null,allow:null,allowFullScreen:Me,allowPaymentRequest:Me,allowUserMedia:Me,alt:null,as:null,async:Me,autoCapitalize:null,autoComplete:at,autoFocus:Me,autoPlay:Me,blocking:at,capture:null,charSet:null,checked:Me,cite:null,className:at,cols:Q,colSpan:null,content:null,contentEditable:At,controls:Me,controlsList:at,coords:Q|Ta,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Me,defer:Me,dir:null,dirName:null,disabled:Me,download:x0,draggable:At,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Me,formTarget:null,headers:at,height:Q,hidden:x0,high:Q,href:null,hrefLang:null,htmlFor:at,httpEquiv:at,id:null,imageSizes:null,imageSrcSet:null,inert:Me,inputMode:null,integrity:null,is:null,isMap:Me,itemId:null,itemProp:at,itemRef:at,itemScope:Me,itemType:at,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Me,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:Me,muted:Me,name:null,nonce:null,noModule:Me,noValidate:Me,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:Me,optimum:Q,pattern:null,ping:at,placeholder:null,playsInline:Me,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Me,referrerPolicy:null,rel:at,required:Me,reversed:Me,rows:Q,rowSpan:Q,sandbox:at,scope:null,scoped:Me,seamless:Me,selected:Me,shadowRootClonable:Me,shadowRootDelegatesFocus:Me,shadowRootMode:null,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:At,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:Me,useMap:null,value:At,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:at,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:Me,declare:Me,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:Me,noHref:Me,noShade:Me,noWrap:Me,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:At,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:Me,disableRemotePlayback:Me,prefix:null,property:null,results:Q,security:null,unselectable:null},space:"html",transform:yR}),fW=fl({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:Gn,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:at,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:Me,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:Ta,g2:Ta,glyphName:Ta,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:Gn,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:at,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Gn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Gn,rev:Gn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Gn,requiredFeatures:Gn,requiredFonts:Gn,requiredFormats:Gn,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:Gn,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:Gn,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:Gn,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:xR}),bR=fl({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),wR=fl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:yR}),SR=fl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),pW={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"},mW=/[A-Z]/g,NS=/-[a-z]/g,gW=/^data[-\w.:]+$/i;function vW(e,t){const n=_0(t);let r=t,i=Wn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&gW.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(NS,xW);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!NS.test(s)){let o=s.replace(mW,_W);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=_y}return new i(r,t)}function _W(e){return"-"+e.toLowerCase()}function xW(e){return e.charAt(1).toUpperCase()}const yW=vR([_R,hW,bR,wR,SR],"html"),xy=vR([_R,fW,bR,wR,SR],"svg");function bW(e){return e.join(" ").trim()}var yy={},TS=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,wW=/\n/g,SW=/^\s*/,kW=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,CW=/^:\s*/,EW=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,NW=/^[;\s]*/,TW=/^\s+|\s+$/g,PW=`
|
|
476
476
|
`,PS="/",IS="*",Qs="",IW="comment",RW="declaration";function MW(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(wW);v&&(n+=v.length);var b=m.lastIndexOf(PW);r=~b?m.length-b: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 b=v[0];return i(b),e=e.slice(b.length),v}}function c(){l(SW)}function u(m){var v;for(m=m||[];v=d();)v!==!1&&m.push(v);return m}function d(){var m=s();if(!(PS!=e.charAt(0)||IS!=e.charAt(1))){for(var v=2;Qs!=e.charAt(v)&&(IS!=e.charAt(v)||PS!=e.charAt(v+1));)++v;if(v+=2,Qs===e.charAt(v-1))return a("End of comment missing");var b=e.slice(2,v-2);return r+=2,i(b),e=e.slice(v),r+=2,m({type:IW,comment:b})}}function f(){var m=s(),v=l(kW);if(v){if(d(),!l(CW))return a("property missing ':'");var b=l(EW),_=m({type:RW,property:RS(v[0].replace(TS,Qs)),value:b?RS(b[0].replace(TS,Qs)):Qs});return l(NW),_}}function p(){var m=[];u(m);for(var v;v=f();)v!==!1&&(m.push(v),u(m));return m}return c(),p()}function RS(e){return e?e.replace(TW,Qs):Qs}var AW=MW,LW=ch&&ch.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(yy,"__esModule",{value:!0});yy.default=DW;const jW=LW(AW);function DW(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,jW.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 pp={};Object.defineProperty(pp,"__esModule",{value:!0});pp.camelCase=void 0;var OW=/^--[a-zA-Z0-9_-]+$/,BW=/-([a-z])/g,zW=/^[^-]+$/,$W=/^-(webkit|moz|ms|o|khtml)-/,FW=/^-(ms)-/,HW=function(e){return!e||zW.test(e)||OW.test(e)},UW=function(e,t){return t.toUpperCase()},MS=function(e,t){return"".concat(t,"-")},WW=function(e,t){return t===void 0&&(t={}),HW(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(FW,MS):e=e.replace($W,MS),e.replace(BW,UW))};pp.camelCase=WW;var VW=ch&&ch.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},qW=VW(yy),KW=pp;function b0(e,t){var n={};return!e||typeof e!="string"||(0,qW.default)(e,function(r,i){r&&i&&(n[(0,KW.camelCase)(r,t)]=i)}),n}b0.default=b0;var GW=b0;const XW=lu(GW),kR=CR("end"),by=CR("start");function CR(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function YW(e){const t=by(e),n=kR(e);if(t&&n)return{start:t,end:n}}function gc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?AS(e.position):"start"in e||"end"in e?AS(e):"line"in e||"column"in e?w0(e):""}function w0(e){return LS(e&&e.line)+":"+LS(e&&e.column)}function AS(e){return w0(e&&e.start)+"-"+w0(e&&e.end)}function LS(e){return e&&typeof e=="number"?e:1}class Sn 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=gc(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}}Sn.prototype.file="";Sn.prototype.name="";Sn.prototype.reason="";Sn.prototype.message="";Sn.prototype.stack="";Sn.prototype.column=void 0;Sn.prototype.line=void 0;Sn.prototype.ancestors=void 0;Sn.prototype.cause=void 0;Sn.prototype.fatal=void 0;Sn.prototype.place=void 0;Sn.prototype.ruleId=void 0;Sn.prototype.source=void 0;const wy={}.hasOwnProperty,QW=new Map,ZW=/[A-Z]/g,JW=new Set(["table","tbody","thead","tfoot","tr"]),eV=new Set(["td","th"]),ER="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function tV(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=cV(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=lV(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"?xy:yW,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=NR(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function NR(e,t,n){if(t.type==="element")return nV(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return rV(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return sV(e,t,n);if(t.type==="mdxjsEsm")return iV(e,t);if(t.type==="root")return oV(e,t,n);if(t.type==="text")return aV(e,t)}function nV(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=xy,e.schema=i),e.ancestors.push(t);const s=PR(e,t.tagName,!1),o=uV(e,t);let a=ky(e,t);return JW.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!uW(l):!0})),TR(e,o,s,t),Sy(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function rV(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)}Jc(e,t.position)}function iV(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Jc(e,t.position)}function sV(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=xy,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:PR(e,t.name,!0),o=dV(e,t),a=ky(e,t);return TR(e,o,s,t),Sy(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function oV(e,t,n){const r={};return Sy(r,ky(e,t)),e.create(t,e.Fragment,r,n)}function aV(e,t){return t.value}function TR(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Sy(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function lV(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 cV(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=by(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 uV(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&wy.call(t.properties,i)){const s=hV(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&eV.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 dV(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 Jc(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 Jc(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function ky(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:QW;for(;++r<t.children.length;){const s=t.children[r];let o;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const c=i.get(l)||0;o=l+"-"+c,i.set(l,c+1)}}const a=NR(e,s,o);a!==void 0&&n.push(a)}return n}function hV(e,t,n){const r=vW(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?sW(n):bW(n)),r.property==="style"){let i=typeof n=="object"?n:fV(e,String(n));return e.stylePropertyNameCase==="css"&&(i=pV(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?pW[r.property]||r.property:r.attribute,n]}}function fV(e,t){try{return XW(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new Sn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=ER+"#cannot-parse-style-attribute",i}}function PR(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const a=kS(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=o}else r=kS(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return wy.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);Jc(e)}function Jc(e,t){const n=new Sn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=ER+"#cannot-handle-mdx-estrees-without-createevaluater",n}function pV(e){const t={};let n;for(n in e)wy.call(e,n)&&(t[mV(n)]=e[n]);return t}function mV(e){let t=e.replace(ZW,gV);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function gV(e){return"-"+e.toLowerCase()}const Bm={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"]},vV={};function Cy(e,t){const n=vV,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return IR(e,r,i)}function IR(e,t,n){if(_V(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 jS(e.children,t,n)}return Array.isArray(e)?jS(e,t,n):""}function jS(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=IR(e[i],t,n);return r.join("")}function _V(e){return!!(e&&typeof e=="object")}const DS=document.createElement("i");function Ey(e){const t="&"+e+";";DS.innerHTML=t;const n=DS.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function er(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 fr(e,t){return e.length>0?(er(e,e.length,0,t),e):t}const OS={}.hasOwnProperty;function RR(e){const t={};let n=-1;for(;++n<e.length;)xV(t,e[n]);return t}function xV(e,t){let n;for(n in t){const i=(OS.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){OS.call(i,o)||(i[o]=[]);const a=s[o];yV(i[o],Array.isArray(a)?a:a?[a]:[])}}}function yV(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);er(e,0,0,r)}function MR(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Mr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const En=Os(/[A-Za-z]/),yn=Os(/[\dA-Za-z]/),bV=Os(/[#-'*+\--9=?A-Z^-~]/);function nf(e){return e!==null&&(e<32||e===127)}const S0=Os(/\d/),wV=Os(/[\dA-Fa-f]/),SV=Os(/[!-/:-@[-`{-~]/);function be(e){return e!==null&&e<-2}function ot(e){return e!==null&&(e<0||e===32)}function Ue(e){return e===-2||e===-1||e===32}const mp=Os(new RegExp("\\p{P}|\\p{S}","u")),wo=Os(/\s/);function Os(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function pl(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&yn(e.charCodeAt(n+1))&&yn(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function Ge(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 kV={tokenize:CV};function CV(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"),Ge(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 be(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const EV={tokenize:NV},BS={tokenize:TV};function NV(e){const t=this,n=[];let r=0,i,s,o;return a;function a(y){if(r<n.length){const w=n[r];return t.containerState=w[1],e.attempt(w[0].continuation,l,c)(y)}return c(y)}function l(y){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&x();const w=t.events.length;let k=w,C;for(;k--;)if(t.events[k][0]==="exit"&&t.events[k][1].type==="chunkFlow"){C=t.events[k][1].end;break}_(r);let N=w;for(;N<t.events.length;)t.events[N][1].end={...C},N++;return er(t.events,k+1,0,t.events.slice(w)),t.events.length=N,c(y)}return a(y)}function c(y){if(r===n.length){if(!i)return f(y);if(i.currentConstruct&&i.currentConstruct.concrete)return m(y);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(BS,u,d)(y)}function u(y){return i&&x(),_(r),f(y)}function d(y){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(y)}function f(y){return t.containerState={},e.attempt(BS,p,m)(y)}function p(y){return r++,n.push([t.currentConstruct,t.containerState]),f(y)}function m(y){if(y===null){i&&x(),_(0),e.consume(y);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),v(y)}function v(y){if(y===null){b(e.exit("chunkFlow"),!0),_(0),e.consume(y);return}return be(y)?(e.consume(y),b(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(y),v)}function b(y,w){const k=t.sliceStream(y);if(w&&k.push(null),y.previous=s,s&&(s.next=y),s=y,i.defineSkip(y.start),i.write(k),t.parser.lazy[y.start.line]){let C=i.events.length;for(;C--;)if(i.events[C][1].start.offset<o&&(!i.events[C][1].end||i.events[C][1].end.offset>o))return;const N=t.events.length;let T=N,B,P;for(;T--;)if(t.events[T][0]==="exit"&&t.events[T][1].type==="chunkFlow"){if(B){P=t.events[T][1].end;break}B=!0}for(_(r),C=N;C<t.events.length;)t.events[C][1].end={...P},C++;er(t.events,T+1,0,t.events.slice(N)),t.events.length=C}}function _(y){let w=n.length;for(;w-- >y;){const k=n[w];t.containerState=k[1],k[0].exit.call(t,e)}n.length=y}function x(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function TV(e,t,n){return Ge(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ua(e){if(e===null||ot(e)||wo(e))return 1;if(mp(e))return 2}function gp(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 k0={name:"attention",resolveAll:PV,tokenize:IV};function PV(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};zS(d,-l),zS(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=fr(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=fr(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),c=fr(c,gp(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=fr(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=fr(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):u=0,er(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 IV(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Ua(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=Ua(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 zS(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const RV={name:"autolink",tokenize:MV};function MV(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 En(p)?(e.consume(p),o):p===64?n(p):c(p)}function o(p){return p===43||p===45||p===46||yn(p)?(r=1,a(p)):c(p)}function a(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||yn(p))&&r++<32?(e.consume(p),a):(r=0,c(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||nf(p)?n(p):(e.consume(p),l)}function c(p){return p===64?(e.consume(p),u):bV(p)?(e.consume(p),c):n(p)}function u(p){return yn(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,u):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):f(p)}function f(p){if((p===45||yn(p))&&r++<63){const m=p===45?f:d;return e.consume(p),m}return n(p)}}const Eu={partial:!0,tokenize:AV};function AV(e,t,n){return r;function r(s){return Ue(s)?Ge(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||be(s)?t(s):n(s)}}const AR={continuation:{tokenize:jV},exit:DV,name:"blockQuote",tokenize:LV};function LV(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 jV(e,t,n){const r=this;return i;function i(o){return Ue(o)?Ge(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(AR,t,n)(o)}}function DV(e){e.exit("blockQuote")}const LR={name:"characterEscape",tokenize:OV};function OV(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 SV(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const jR={name:"characterReference",tokenize:BV};function BV(e,t,n){const r=this;let i=0,s,o;return a;function a(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),l}function l(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),s=31,o=yn,u(d))}function c(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=wV,u):(e.enter("characterReferenceValue"),s=7,o=S0,u(d))}function u(d){if(d===59&&i){const f=e.exit("characterReferenceValue");return o===yn&&!Ey(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 $S={partial:!0,tokenize:$V},FS={concrete:!0,name:"codeFenced",tokenize:zV};function zV(e,t,n){const r=this,i={partial:!0,tokenize:k};let s=0,o=0,a;return l;function l(C){return c(C)}function c(C){const N=r.events[r.events.length-1];return s=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[1],!0).length:0,a=C,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),u(C)}function u(C){return C===a?(o++,e.consume(C),u):o<3?n(C):(e.exit("codeFencedFenceSequence"),Ue(C)?Ge(e,d,"whitespace")(C):d(C))}function d(C){return C===null||be(C)?(e.exit("codeFencedFence"),r.interrupt?t(C):e.check($S,v,w)(C)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(C))}function f(C){return C===null||be(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(C)):Ue(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ge(e,p,"whitespace")(C)):C===96&&C===a?n(C):(e.consume(C),f)}function p(C){return C===null||be(C)?d(C):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(C))}function m(C){return C===null||be(C)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(C)):C===96&&C===a?n(C):(e.consume(C),m)}function v(C){return e.attempt(i,w,b)(C)}function b(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),_}function _(C){return s>0&&Ue(C)?Ge(e,x,"linePrefix",s+1)(C):x(C)}function x(C){return C===null||be(C)?e.check($S,v,w)(C):(e.enter("codeFlowValue"),y(C))}function y(C){return C===null||be(C)?(e.exit("codeFlowValue"),x(C)):(e.consume(C),y)}function w(C){return e.exit("codeFenced"),t(C)}function k(C,N,T){let B=0;return P;function P(z){return C.enter("lineEnding"),C.consume(z),C.exit("lineEnding"),A}function A(z){return C.enter("codeFencedFence"),Ue(z)?Ge(C,I,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(z):I(z)}function I(z){return z===a?(C.enter("codeFencedFenceSequence"),R(z)):T(z)}function R(z){return z===a?(B++,C.consume(z),R):B>=o?(C.exit("codeFencedFenceSequence"),Ue(z)?Ge(C,j,"whitespace")(z):j(z)):T(z)}function j(z){return z===null||be(z)?(C.exit("codeFencedFence"),N(z)):T(z)}}}function $V(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 zm={name:"codeIndented",tokenize:HV},FV={partial:!0,tokenize:UV};function HV(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),Ge(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):be(c)?e.attempt(FV,o,l)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||be(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),a)}function l(c){return e.exit("codeIndented"),t(c)}}function UV(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):be(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):Ge(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):be(o)?i(o):n(o)}}const WV={name:"codeText",previous:qV,resolve:VV,tokenize:KV};function VV(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 qV(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function KV(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)):be(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||be(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 GV{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&&Ll(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),Ll(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Ll(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);Ll(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Ll(this.left,n.reverse())}}}function Ll(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 DR(e){const t={};let n=-1,r,i,s,o,a,l,c;const u=new GV(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,XV(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 er(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function XV(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 b=[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,b.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):b.pop(),f=b.length;f--;){const _=a.slice(b[f],b[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 YV={resolve:ZV,tokenize:JV},QV={partial:!0,tokenize:eq};function ZV(e){return DR(e),e}function JV(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):be(a)?e.check(QV,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 eq(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Ge(e,s,"linePrefix")}function s(o){if(o===null||be(o))return n(o);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function OR(e,t,n,r,i,s,o,a,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return d;function d(_){return _===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(_),e.exit(s),f):_===null||_===32||_===41||nf(_)?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||be(_)?n(_):(e.consume(_),_===92?m:p)}function m(_){return _===60||_===62||_===92?(e.consume(_),p):p(_)}function v(_){return!u&&(_===null||_===41||ot(_))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(_)):u<c&&_===40?(e.consume(_),u++,v):_===41?(e.consume(_),u--,v):_===null||_===32||_===40||nf(_)?n(_):(e.consume(_),_===92?b:v)}function b(_){return _===40||_===41||_===92?(e.consume(_),v):v(_)}}function BR(e,t,n,r,i,s){const o=this;let a=0,l;return c;function c(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(s),u}function u(p){return a>999||p===null||p===91||p===93&&!l||p===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(p):p===93?(e.exit(s),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):be(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||be(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 zR(e,t,n,r,i,s){let o;return a;function a(f){return f===34||f===39||f===40?(e.enter(r),e.enter(i),e.consume(f),e.exit(i),o=f===40?41:f,l):n(f)}function l(f){return f===o?(e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):(e.enter(s),c(f))}function c(f){return f===o?(e.exit(s),l(o)):f===null?n(f):be(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Ge(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(f))}function u(f){return f===o||f===null||be(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 vc(e,t){let n;return r;function r(i){return be(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Ue(i)?Ge(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const tq={name:"definition",tokenize:rq},nq={partial:!0,tokenize:iq};function rq(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return BR.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=Mr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return ot(p)?vc(e,c)(p):c(p)}function c(p){return OR(e,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function u(p){return e.attempt(nq,d,d)(p)}function d(p){return Ue(p)?Ge(e,f,"whitespace")(p):f(p)}function f(p){return p===null||be(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function iq(e,t,n){return r;function r(a){return ot(a)?vc(e,i)(a):n(a)}function i(a){return zR(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return Ue(a)?Ge(e,o,"whitespace")(a):o(a)}function o(a){return a===null||be(a)?t(a):n(a)}}const sq={name:"hardBreakEscape",tokenize:oq};function oq(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return be(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const aq={name:"headingAtx",resolve:lq,tokenize:cq};function lq(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"},er(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function cq(e,t,n){let r=0;return i;function i(u){return e.enter("atxHeading"),s(u)}function s(u){return e.enter("atxHeadingSequence"),o(u)}function o(u){return u===35&&r++<6?(e.consume(u),o):u===null||ot(u)?(e.exit("atxHeadingSequence"),a(u)):n(u)}function a(u){return u===35?(e.enter("atxHeadingSequence"),l(u)):u===null||be(u)?(e.exit("atxHeading"),t(u)):Ue(u)?Ge(e,a,"whitespace")(u):(e.enter("atxHeadingText"),c(u))}function l(u){return u===35?(e.consume(u),l):(e.exit("atxHeadingSequence"),a(u))}function c(u){return u===null||u===35||ot(u)?(e.exit("atxHeadingText"),a(u)):(e.consume(u),c)}}const uq=["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"],HS=["pre","script","style","textarea"],dq={concrete:!0,name:"htmlFlow",resolveTo:pq,tokenize:mq},hq={partial:!0,tokenize:vq},fq={partial:!0,tokenize:gq};function pq(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 mq(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):En(L)?(e.consume(L),o=String.fromCharCode(L),b):n(L)}function f(L){return L===45?(e.consume(L),i=2,p):L===91?(e.consume(L),i=5,a=0,m):En(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 ne="CDATA[";return L===ne.charCodeAt(a++)?(e.consume(L),a===ne.length?r.interrupt?t:I:m):n(L)}function v(L){return En(L)?(e.consume(L),o=String.fromCharCode(L),b):n(L)}function b(L){if(L===null||L===47||L===62||ot(L)){const ne=L===47,ae=o.toLowerCase();return!ne&&!s&&HS.includes(ae)?(i=1,r.interrupt?t(L):I(L)):uq.includes(o.toLowerCase())?(i=6,ne?(e.consume(L),_):r.interrupt?t(L):I(L)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(L):s?x(L):y(L))}return L===45||yn(L)?(e.consume(L),o+=String.fromCharCode(L),b):n(L)}function _(L){return L===62?(e.consume(L),r.interrupt?t:I):n(L)}function x(L){return Ue(L)?(e.consume(L),x):P(L)}function y(L){return L===47?(e.consume(L),P):L===58||L===95||En(L)?(e.consume(L),w):Ue(L)?(e.consume(L),y):P(L)}function w(L){return L===45||L===46||L===58||L===95||yn(L)?(e.consume(L),w):k(L)}function k(L){return L===61?(e.consume(L),C):Ue(L)?(e.consume(L),k):y(L)}function C(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),C):T(L)}function N(L){return L===l?(e.consume(L),l=null,B):L===null||be(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||ot(L)?k(L):(e.consume(L),T)}function B(L){return L===47||L===62||Ue(L)?y(L):n(L)}function P(L){return L===62?(e.consume(L),A):n(L)}function A(L){return L===null||be(L)?I(L):Ue(L)?(e.consume(L),A):n(L)}function I(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):be(L)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(hq,V,R)(L)):L===null||be(L)?(e.exit("htmlFlowData"),R(L)):(e.consume(L),I)}function R(L){return e.check(fq,j,V)(L)}function j(L){return e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),z}function z(L){return L===null||be(L)?R(L):(e.enter("htmlFlowData"),I(L))}function $(L){return L===45?(e.consume(L),E):I(L)}function F(L){return L===47?(e.consume(L),o="",D):I(L)}function D(L){if(L===62){const ne=o.toLowerCase();return HS.includes(ne)?(e.consume(L),H):I(L)}return En(L)&&o.length<8?(e.consume(L),o+=String.fromCharCode(L),D):I(L)}function O(L){return L===93?(e.consume(L),E):I(L)}function E(L){return L===62?(e.consume(L),H):L===45&&i===2?(e.consume(L),E):I(L)}function H(L){return L===null||be(L)?(e.exit("htmlFlowData"),V(L)):(e.consume(L),H)}function V(L){return e.exit("htmlFlow"),t(L)}}function gq(e,t,n){const r=this;return i;function i(o){return be(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 vq(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Eu,t,n)}}const _q={name:"htmlText",tokenize:xq};function xq(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),k):E===63?(e.consume(E),y):En(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):En(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):be(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),b):be(E)?(o=v,F(E)):(e.consume(E),v)}function b(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):be(E)?(o=x,F(E)):(e.consume(E),x)}function y(E){return E===null?n(E):E===63?(e.consume(E),w):be(E)?(o=y,F(E)):(e.consume(E),y)}function w(E){return E===62?$(E):y(E)}function k(E){return En(E)?(e.consume(E),C):n(E)}function C(E){return E===45||yn(E)?(e.consume(E),C):N(E)}function N(E){return be(E)?(o=N,F(E)):Ue(E)?(e.consume(E),N):$(E)}function T(E){return E===45||yn(E)?(e.consume(E),T):E===47||E===62||ot(E)?B(E):n(E)}function B(E){return E===47?(e.consume(E),$):E===58||E===95||En(E)?(e.consume(E),P):be(E)?(o=B,F(E)):Ue(E)?(e.consume(E),B):$(E)}function P(E){return E===45||E===46||E===58||E===95||yn(E)?(e.consume(E),P):A(E)}function A(E){return E===61?(e.consume(E),I):be(E)?(o=A,F(E)):Ue(E)?(e.consume(E),A):B(E)}function I(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),i=E,R):be(E)?(o=I,F(E)):Ue(E)?(e.consume(E),I):(e.consume(E),j)}function R(E){return E===i?(e.consume(E),i=void 0,z):E===null?n(E):be(E)?(o=R,F(E)):(e.consume(E),R)}function j(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||ot(E)?B(E):(e.consume(E),j)}function z(E){return E===47||E===62||ot(E)?B(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"),D}function D(E){return Ue(E)?Ge(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 Ny={name:"labelEnd",resolveAll:Sq,resolveTo:kq,tokenize:Cq},yq={tokenize:Eq},bq={tokenize:Nq},wq={tokenize:Tq};function Sq(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&&er(e,0,e.length,n),e}function kq(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=fr(a,e.slice(s+1,s+r+3)),a=fr(a,[["enter",u,t]]),a=fr(a,gp(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=fr(a,[["exit",u,t],e[o-2],e[o-1],["exit",c,t]]),a=fr(a,e.slice(o+1)),a=fr(a,[["exit",l,t]]),er(e,s,e.length,a),e}function Cq(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(Mr(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(yq,u,o?u:d)(f):f===91?e.attempt(bq,u,o?c:d)(f):o?u(f):d(f)}function c(f){return e.attempt(wq,u,d)(f)}function u(f){return t(f)}function d(f){return s._balanced=!0,n(f)}}function Eq(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),i}function i(d){return ot(d)?vc(e,s)(d):s(d)}function s(d){return d===41?u(d):OR(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function o(d){return ot(d)?vc(e,l)(d):u(d)}function a(d){return n(d)}function l(d){return d===34||d===39||d===40?zR(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):u(d)}function c(d){return ot(d)?vc(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 Nq(e,t,n){const r=this;return i;function i(a){return BR.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Mr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function Tq(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 Pq={name:"labelStartImage",resolveAll:Ny.resolveAll,tokenize:Iq};function Iq(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 Rq={name:"labelStartLink",resolveAll:Ny.resolveAll,tokenize:Mq};function Mq(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 $m={name:"lineEnding",tokenize:Aq};function Aq(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ge(e,t,"linePrefix")}}const th={name:"thematicBreak",tokenize:Lq};function Lq(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||be(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),Ue(c)?Ge(e,a,"whitespace")(c):a(c))}}const On={continuation:{tokenize:Bq},exit:$q,name:"list",tokenize:Oq},jq={partial:!0,tokenize:Fq},Dq={partial:!0,tokenize:zq};function Oq(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:S0(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(th,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 S0(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(Eu,r.interrupt?n:u,e.attempt(jq,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 Bq(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Eu,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ge(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(Dq,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ge(e,e.attempt(On,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function zq(e,t,n){const r=this;return Ge(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 $q(e){e.exit(this.containerState.type)}function Fq(e,t,n){const r=this;return Ge(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 US={name:"setextUnderline",resolveTo:Hq,tokenize:Uq};function Hq(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 Uq(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)?Ge(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||be(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const Wq={tokenize:Vq};function Vq(e){const t=this,n=e.attempt(Eu,r,e.attempt(this.parser.constructs.flowInitial,i,Ge(e,e.attempt(this.parser.constructs.flow,i,e.attempt(YV,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 qq={resolveAll:FR()},Kq=$R("string"),Gq=$R("text");function $R(e){return{resolveAll:FR(e==="text"?Xq:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,o,a);return o;function o(u){return c(u)?s(u):a(u)}function a(u){if(u===null){n.consume(u);return}return n.enter("data"),n.consume(u),l}function l(u){return c(u)?(n.exit("data"),s(u)):(n.consume(u),l)}function c(u){if(u===null)return!0;const d=i[u];let f=-1;if(d)for(;++f<d.length;){const p=d[f];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function FR(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function Xq(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 Yq={42:On,43:On,45:On,48:On,49:On,50:On,51:On,52:On,53:On,54:On,55:On,56:On,57:On,62:AR},Qq={91:tq},Zq={[-2]:zm,[-1]:zm,32:zm},Jq={35:aq,42:th,45:[US,th],60:dq,61:US,95:th,96:FS,126:FS},eK={38:jR,92:LR},tK={[-5]:$m,[-4]:$m,[-3]:$m,33:Pq,38:jR,42:k0,60:[RV,_q],91:Rq,92:[sq,LR],93:Ny,95:k0,96:WV},nK={null:[k0,qq]},rK={null:[42,95]},iK={null:[]},sK=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:rK,contentInitial:Qq,disable:iK,document:Yq,flow:Jq,flowInitial:Zq,insideSpan:nK,string:eK,text:tK},Symbol.toStringTag,{value:"Module"}));function oK(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(k),check:N(C),consume:x,enter:y,exit:w,interrupt:N(C,{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(A){return o=fr(o,A),b(),o[o.length-1]!==null?[]:(T(t,0),c.events=gp(s,c.events,c),c.events)}function f(A,I){return lK(p(A),I)}function p(A){return aK(o,A)}function m(){const{_bufferIndex:A,_index:I,line:R,column:j,offset:z}=r;return{_bufferIndex:A,_index:I,line:R,column:j,offset:z}}function v(A){i[A.line]=A.column,P()}function b(){let A;for(;r._index<o.length;){const I=o[r._index];if(typeof I=="string")for(A=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===A&&r._bufferIndex<I.length;)_(I.charCodeAt(r._bufferIndex));else _(I)}}function _(A){u=u(A)}function x(A){be(A)?(r.line++,r.column=1,r.offset+=A===-3?2:1,P()):A!==-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=A}function y(A,I){const R=I||{};return R.type=A,R.start=m(),c.events.push(["enter",R,c]),a.push(R),R}function w(A){const I=a.pop();return I.end=m(),c.events.push(["exit",I,c]),I}function k(A,I){T(A,I.from)}function C(A,I){I.restore()}function N(A,I){return R;function R(j,z,$){let F,D,O,E;return Array.isArray(j)?V(j):"tokenize"in j?V([j]):H(j);function H(G){return ye;function ye(Fe){const ue=Fe!==null&&G[Fe],Ie=Fe!==null&&G.null,Re=[...Array.isArray(ue)?ue:ue?[ue]:[],...Array.isArray(Ie)?Ie:Ie?[Ie]:[]];return V(Re)(Fe)}}function V(G){return F=G,D=0,G.length===0?$:L(G[D])}function L(G){return ye;function ye(Fe){return E=B(),O=G,G.partial||(c.currentConstruct=G),G.name&&c.parser.constructs.disable.null.includes(G.name)?ae():G.tokenize.call(I?Object.assign(Object.create(c),I):c,l,ne,ae)(Fe)}}function ne(G){return A(O,E),z}function ae(G){return E.restore(),++D<F.length?L(F[D]):$}}}function T(A,I){A.resolveAll&&!s.includes(A)&&s.push(A),A.resolve&&er(c.events,I,c.events.length-I,A.resolve(c.events.slice(I),c)),A.resolveTo&&(c.events=A.resolveTo(c.events,c))}function B(){const A=m(),I=c.previous,R=c.currentConstruct,j=c.events.length,z=Array.from(a);return{from:j,restore:$};function $(){r=A,c.previous=I,c.currentConstruct=R,c.events.length=j,a=z,P()}}function P(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function aK(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 lK(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=`
|
|
477
477
|
`;break}case-3:{o=`\r
|
|
478
478
|
`;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 cK(e){const r={constructs:RR([sK,...(e||{}).extensions||[]]),content:i(kV),defined:[],document:i(EV),flow:i(Wq),lazy:{},string:i(Kq),text:i(Gq)};return r;function i(s){return o;function o(a){return oK(r,s,a)}}}function uK(e){for(;!DR(e););return e}const WS=/[\0\t\n\r]/g;function dK(){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(WS.lastIndex=d,c=WS.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 hK=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function fK(e){return e.replace(hK,pK)}function pK(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return MR(n.slice(s?2:1),s?16:10)}return Ey(n)||e}const HR={}.hasOwnProperty;function mK(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),gK(n)(uK(cK(n).document().write(dK()(e,t,!0))))}function gK(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(Mt),autolinkProtocol:B,autolinkEmail:B,atxHeading:s(fn),blockQuote:s(Ie),characterEscape:B,characterReference:B,codeFenced:s(Re),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Re,o),codeText:s(Ke,o),codeTextData:B,data:B,codeFlowValue:B,definition:s(ve),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(ze),hardBreakEscape:s(it),hardBreakTrailing:s(it),htmlFlow:s(Rt,o),htmlFlowData:B,htmlText:s(Rt,o),htmlTextData:B,image:s(Gt),label:o,link:s(Mt),listItem:s(Qe),listItemValue:f,listOrdered:s(bt,d),listUnordered:s(bt),paragraph:s(st),reference:L,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(fn),strong:s(wt),thematicBreak:s(on)},exit:{atxHeading:l(),atxHeadingSequence:k,autolink:l(),autolinkEmail:ue,autolinkProtocol:Fe,blockQuote:l(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:ae,characterReferenceMarkerNumeric:ae,characterReferenceValue:G,characterReference:ye,codeFenced:l(b),codeFencedFence:v,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:P,codeIndented:l(_),codeText:l(z),codeTextData:P,data:P,definition:l(),definitionDestinationString:w,definitionLabelString:x,definitionTitleString:y,emphasis:l(),hardBreakEscape:l(I),hardBreakTrailing:l(I),htmlFlow:l(R),htmlFlowData:P,htmlText:l(j),htmlTextData:P,image:l(F),label:O,labelText:D,lineEnding:A,link:l($),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ne,resourceDestinationString:E,resourceTitleString:H,resource:V,setextHeading:l(T),setextHeadingLineSequence:N,setextHeadingText:C,strong:l(),thematicBreak:l()}};UR(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(U){let Z={type:"root",children:[]};const _e={stack:[Z],tokenStack:[],config:t,enter:a,exit:c,buffer:o,resume:u,data:n},ke=[];let He=-1;for(;++He<U.length;)if(U[He][1].type==="listOrdered"||U[He][1].type==="listUnordered")if(U[He][0]==="enter")ke.push(He);else{const Tt=ke.pop();He=i(U,Tt,He)}for(He=-1;++He<U.length;){const Tt=t[U[He][0]];HR.call(Tt,U[He][1].type)&&Tt[U[He][1].type].call(Object.assign({sliceSerialize:U[He][2].sliceSerialize},_e),U[He][1])}if(_e.tokenStack.length>0){const Tt=_e.tokenStack[_e.tokenStack.length-1];(Tt[1]||VS).call(_e,void 0,Tt[0])}for(Z.position={start:Qi(U.length>0?U[0][1].start:{line:1,column:1,offset:0}),end:Qi(U.length>0?U[U.length-2][1].end:{line:1,column:1,offset:0})},He=-1;++He<t.transforms.length;)Z=t.transforms[He](Z)||Z;return Z}function i(U,Z,_e){let ke=Z-1,He=-1,Tt=!1,Xt,Yt,se,q;for(;++ke<=_e;){const we=U[ke];switch(we[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{we[0]==="enter"?He++:He--,q=void 0;break}case"lineEndingBlank":{we[0]==="enter"&&(Xt&&!q&&!He&&!se&&(se=ke),q=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:q=void 0}if(!He&&we[0]==="enter"&&we[1].type==="listItemPrefix"||He===-1&&we[0]==="exit"&&(we[1].type==="listUnordered"||we[1].type==="listOrdered")){if(Xt){let ht=ke;for(Yt=void 0;ht--;){const an=U[ht];if(an[1].type==="lineEnding"||an[1].type==="lineEndingBlank"){if(an[0]==="exit")continue;Yt&&(U[Yt][1].type="lineEndingBlank",Tt=!0),an[1].type="lineEnding",Yt=ht}else if(!(an[1].type==="linePrefix"||an[1].type==="blockQuotePrefix"||an[1].type==="blockQuotePrefixWhitespace"||an[1].type==="blockQuoteMarker"||an[1].type==="listItemIndent"))break}se&&(!Yt||se<Yt)&&(Xt._spread=!0),Xt.end=Object.assign({},Yt?U[Yt][1].start:we[1].end),U.splice(Yt||ke,0,["exit",Xt,we[2]]),ke++,_e++}if(we[1].type==="listItemPrefix"){const ht={type:"listItem",_spread:!1,start:Object.assign({},we[1].start),end:void 0};Xt=ht,U.splice(ke,0,["enter",ht,we[2]]),ke++,_e++,se=void 0,q=!0}}}return U[Z][1]._spread=Tt,_e}function s(U,Z){return _e;function _e(ke){a.call(this,U(ke),ke),Z&&Z.call(this,ke)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(U,Z,_e){this.stack[this.stack.length-1].children.push(U),this.stack.push(U),this.tokenStack.push([Z,_e||void 0]),U.position={start:Qi(Z.start),end:void 0}}function l(U){return Z;function Z(_e){U&&U.call(this,_e),c.call(this,_e)}}function c(U,Z){const _e=this.stack.pop(),ke=this.tokenStack.pop();if(ke)ke[0].type!==U.type&&(Z?Z.call(this,U,ke[0]):(ke[1]||VS).call(this,U,ke[0]));else throw new Error("Cannot close `"+U.type+"` ("+gc({start:U.start,end:U.end})+"): it’s not open");_e.position.end=Qi(U.end)}function u(){return Cy(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(U){if(this.data.expectingFirstListItemValue){const Z=this.stack[this.stack.length-2];Z.start=Number.parseInt(this.sliceSerialize(U),10),this.data.expectingFirstListItemValue=void 0}}function p(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.lang=U}function m(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.meta=U}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.value=U.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function _(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.value=U.replace(/(\r?\n|\r)$/g,"")}function x(U){const Z=this.resume(),_e=this.stack[this.stack.length-1];_e.label=Z,_e.identifier=Mr(this.sliceSerialize(U)).toLowerCase()}function y(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.title=U}function w(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.url=U}function k(U){const Z=this.stack[this.stack.length-1];if(!Z.depth){const _e=this.sliceSerialize(U).length;Z.depth=_e}}function C(){this.data.setextHeadingSlurpLineEnding=!0}function N(U){const Z=this.stack[this.stack.length-1];Z.depth=this.sliceSerialize(U).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function B(U){const _e=this.stack[this.stack.length-1].children;let ke=_e[_e.length-1];(!ke||ke.type!=="text")&&(ke=pn(),ke.position={start:Qi(U.start),end:void 0},_e.push(ke)),this.stack.push(ke)}function P(U){const Z=this.stack.pop();Z.value+=this.sliceSerialize(U),Z.position.end=Qi(U.end)}function A(U){const Z=this.stack[this.stack.length-1];if(this.data.atHardBreak){const _e=Z.children[Z.children.length-1];_e.position.end=Qi(U.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Z.type)&&(B.call(this,U),P.call(this,U))}function I(){this.data.atHardBreak=!0}function R(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.value=U}function j(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.value=U}function z(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.value=U}function $(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const Z=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=Z,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function F(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const Z=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=Z,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function D(U){const Z=this.sliceSerialize(U),_e=this.stack[this.stack.length-2];_e.label=fK(Z),_e.identifier=Mr(Z).toLowerCase()}function O(){const U=this.stack[this.stack.length-1],Z=this.resume(),_e=this.stack[this.stack.length-1];if(this.data.inReference=!0,_e.type==="link"){const ke=U.children;_e.children=ke}else _e.alt=Z}function E(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.url=U}function H(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.title=U}function V(){this.data.inReference=void 0}function L(){this.data.referenceType="collapsed"}function ne(U){const Z=this.resume(),_e=this.stack[this.stack.length-1];_e.label=Z,_e.identifier=Mr(this.sliceSerialize(U)).toLowerCase(),this.data.referenceType="full"}function ae(U){this.data.characterReferenceType=U.type}function G(U){const Z=this.sliceSerialize(U),_e=this.data.characterReferenceType;let ke;_e?(ke=MR(Z,_e==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ke=Ey(Z);const He=this.stack[this.stack.length-1];He.value+=ke}function ye(U){const Z=this.stack.pop();Z.position.end=Qi(U.end)}function Fe(U){P.call(this,U);const Z=this.stack[this.stack.length-1];Z.url=this.sliceSerialize(U)}function ue(U){P.call(this,U);const Z=this.stack[this.stack.length-1];Z.url="mailto:"+this.sliceSerialize(U)}function Ie(){return{type:"blockquote",children:[]}}function Re(){return{type:"code",lang:null,meta:null,value:""}}function Ke(){return{type:"inlineCode",value:""}}function ve(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ze(){return{type:"emphasis",children:[]}}function fn(){return{type:"heading",depth:0,children:[]}}function it(){return{type:"break"}}function Rt(){return{type:"html",value:""}}function Gt(){return{type:"image",title:null,url:"",alt:null}}function Mt(){return{type:"link",title:null,url:"",children:[]}}function bt(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 st(){return{type:"paragraph",children:[]}}function wt(){return{type:"strong",children:[]}}function pn(){return{type:"text",value:""}}function on(){return{type:"thematicBreak"}}}function Qi(e){return{line:e.line,column:e.column,offset:e.offset}}function UR(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?UR(e,r):vK(e,r)}}function vK(e,t){let n;for(n in t)if(HR.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function VS(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+gc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+gc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+gc({start:t.start,end:t.end})+") is still open")}function _K(e){const t=this;t.parser=n;function n(r){return mK(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function xK(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 yK(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -500,7 +500,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
500
500
|
`))+1))}const o="#".repeat(i),a=n.enter("headingAtx"),l=n.enter("phrasing");s.move(o+" ");let c=n.containerPhrasing(e,{before:"# ",after:`
|
|
501
501
|
`,...s.current()});return/^[\t ]/.test(c)&&(c=tu(c.charCodeAt(0))+c.slice(1)),c=c?o+" "+c:o,n.options.closeAtx&&(c+=" "+o),l(),a(),c}sM.peek=DX;function sM(e){return e.value||""}function DX(){return"<"}oM.peek=OX;function oM(e,t,n,r){const i=Ly(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("image");let a=n.enter("label");const l=n.createTracker(r);let c=l.move("![");return c+=l.move(n.safe(e.alt,{before:c,after:"]",...l.current()})),c+=l.move("]("),a(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(a=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),a(),e.title&&(a=n.enter(`title${s}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),a()),c+=l.move(")"),o(),c}function OX(){return"!"}aM.peek=BX;function aM(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("![");const c=n.safe(e.alt,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),o();const u=n.stack;n.stack=[],o=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return o(),n.stack=u,s(),i==="full"||!c||c!==d?l+=a.move(d+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function BX(){return"!"}lM.peek=zX;function lM(e,t,n){let r=e.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const o=n.unsafe[s],a=n.compilePattern(o);let l;if(o.atBreak)for(;l=a.exec(r);){let c=l.index;r.charCodeAt(c)===10&&r.charCodeAt(c-1)===13&&c--,r=r.slice(0,c)+" "+r.slice(l.index+1)}}return i+r+i}function zX(){return"`"}function cM(e,t){const n=Cy(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}uM.peek=$X;function uM(e,t,n,r){const i=Ly(n),s=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let a,l;if(cM(e,n)){const u=n.stack;n.stack=[],a=n.enter("autolink");let d=o.move("<");return d+=o.move(n.containerPhrasing(e,{before:d,after:">",...o.current()})),d+=o.move(">"),a(),n.stack=u,d}a=n.enter("link"),l=n.enter("label");let c=o.move("[");return c+=o.move(n.containerPhrasing(e,{before:c,after:"](",...o.current()})),c+=o.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),c+=o.move("<"),c+=o.move(n.safe(e.url,{before:c,after:">",...o.current()})),c+=o.move(">")):(l=n.enter("destinationRaw"),c+=o.move(n.safe(e.url,{before:c,after:e.title?" ":")",...o.current()}))),l(),e.title&&(l=n.enter(`title${s}`),c+=o.move(" "+i),c+=o.move(n.safe(e.title,{before:c,after:i,...o.current()})),c+=o.move(i),l()),c+=o.move(")"),a(),c}function $X(e,t,n){return cM(e,n)?"<":"["}dM.peek=FX;function dM(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("[");const c=n.containerPhrasing(e,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),o();const u=n.stack;n.stack=[],o=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return o(),n.stack=u,s(),i==="full"||!c||c!==d?l+=a.move(d+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function FX(){return"["}function jy(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function HX(e){const t=jy(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function UX(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function hM(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function WX(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let o=e.ordered?UX(n):jy(n);const a=e.ordered?o==="."?")":".":HX(n);let l=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){const u=e.children?e.children[0]:void 0;if((o==="*"||o==="-")&&u&&(!u.children||!u.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),hM(n)===o&&u){let d=-1;for(;++d<e.children.length;){const f=e.children[d];if(f&&f.type==="listItem"&&f.children&&f.children[0]&&f.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(o=a),n.bulletCurrent=o;const c=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=s,i(),c}function VX(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function qX(e,t,n,r){const i=VX(n);let s=n.bulletCurrent||jy(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let o=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);const a=n.createTracker(r);a.move(s+" ".repeat(o-s.length)),a.shift(o);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,a.current()),u);return l(),c;function u(d,f,p){return f?(p?"":" ".repeat(o))+d:(p?s:s+" ".repeat(o-s.length))+d}}function KX(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),o=n.containerPhrasing(e,r);return s(),i(),o}const GX=_p(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function XX(e,t,n,r){return(e.children.some(function(o){return GX(o)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function YX(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}fM.peek=QX;function fM(e,t,n,r){const i=YX(n),s=n.enter("strong"),o=n.createTracker(r),a=o.move(i+i);let l=o.move(n.containerPhrasing(e,{after:i,before:a,...o.current()}));const c=l.charCodeAt(0),u=of(r.before.charCodeAt(r.before.length-1),c,i);u.inside&&(l=tu(c)+l.slice(1));const d=l.charCodeAt(l.length-1),f=of(r.after.charCodeAt(0),d,i);f.inside&&(l=l.slice(0,-1)+tu(d));const p=o.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},a+l+p}function QX(e,t,n){return n.options.strong||"*"}function ZX(e,t,n,r){return n.safe(e.value,r)}function JX(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function eY(e,t,n){const r=(hM(n)+(n.options.ruleSpaces?" ":"")).repeat(JX(n));return n.options.ruleSpaces?r.slice(0,-1):r}const pM={blockquote:SX,break:mk,code:PX,definition:RX,emphasis:iM,hardBreak:mk,heading:jX,html:sM,image:oM,imageReference:aM,inlineCode:lM,link:uM,linkReference:dM,list:WX,listItem:qX,paragraph:KX,root:XX,strong:fM,text:ZX,thematicBreak:eY};function tY(){return{enter:{table:nY,tableData:gk,tableHeader:gk,tableRow:iY},exit:{codeText:sY,table:rY,tableData:Qm,tableHeader:Qm,tableRow:Qm}}}function nY(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function rY(e){this.exit(e),this.data.inTable=void 0}function iY(e){this.enter({type:"tableRow",children:[]},e)}function Qm(e){this.exit(e)}function gk(e){this.enter({type:"tableCell",children:[]},e)}function sY(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,oY));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function oY(e,t){return t==="|"?t:e}function aY(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
502
502
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:f,table:o,tableCell:l,tableRow:a}};function o(p,m,v,b){return c(u(p,v,b),p.align)}function a(p,m,v,b){const _=d(p,v,b),x=c([_]);return x.slice(0,x.indexOf(`
|
|
503
|
-
`))}function l(p,m,v,b){const _=v.enter("tableCell"),x=v.enter("phrasing"),y=v.containerPhrasing(p,{...b,before:s,after:s});return x(),_(),y}function c(p,m){return bX(p,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function u(p,m,v){const b=p.children;let _=-1;const x=[],y=m.enter("table");for(;++_<b.length;)x[_]=d(b[_],m,v);return y(),x}function d(p,m,v){const b=p.children;let _=-1;const x=[],y=m.enter("tableRow");for(;++_<b.length;)x[_]=l(b[_],p,m,v);return y(),x}function f(p,m,v){let b=pM.inlineCode(p,m,v);return v.stack.includes("tableCell")&&(b=b.replace(/\|/g,"\\$&")),b}}function lY(){return{exit:{taskListCheckValueChecked:vk,taskListCheckValueUnchecked:vk,paragraph:uY}}}function cY(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:dY}}}function vk(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function uY(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,o;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function dY(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(o);let l=pM.listItem(e,t,n,{...r,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(u){return u+o}}function hY(){return[WG(),dX(),mX(),tY(),lY()]}function fY(e){return{extensions:[VG(),hX(e),gX(),aY(e),cY()]}}const pY={tokenize:yY,partial:!0},mM={tokenize:bY,partial:!0},gM={tokenize:wY,partial:!0},vM={tokenize:SY,partial:!0},mY={tokenize:kY,partial:!0},_M={name:"wwwAutolink",tokenize:_Y,previous:yM},xM={name:"protocolAutolink",tokenize:xY,previous:bM},Fi={name:"emailAutolink",tokenize:vY,previous:wM},di={};function gY(){return{text:di}}let Ws=48;for(;Ws<123;)di[Ws]=Fi,Ws++,Ws===58?Ws=65:Ws===91&&(Ws=97);di[43]=Fi;di[45]=Fi;di[46]=Fi;di[95]=Fi;di[72]=[Fi,xM];di[104]=[Fi,xM];di[87]=[Fi,_M];di[119]=[Fi,_M];function vY(e,t,n){const r=this;let i,s;return o;function o(d){return!P0(d)||!wM.call(r,r.previous)||Dy(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(d))}function a(d){return P0(d)?(e.consume(d),a):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(mY,u,c)(d):d===45||d===95||yn(d)?(s=!0,e.consume(d),l):u(d)}function c(d){return e.consume(d),i=!0,l}function u(d){return s&&i&&En(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function _Y(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!yM.call(r,r.previous)||Dy(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(pY,e.attempt(mM,e.attempt(gM,s),n),n)(o))}function s(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function xY(e,t,n){const r=this;let i="",s=!1;return o;function o(d){return(d===72||d===104)&&bM.call(r,r.previous)&&!Dy(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),e.consume(d),a):n(d)}function a(d){if(En(d)&&i.length<5)return i+=String.fromCodePoint(d),e.consume(d),a;if(d===58){const f=i.toLowerCase();if(f==="http"||f==="https")return e.consume(d),l}return n(d)}function l(d){return d===47?(e.consume(d),s?c:(s=!0,l)):n(d)}function c(d){return d===null||nf(d)||ot(d)||wo(d)||mp(d)?n(d):e.attempt(mM,e.attempt(gM,u),n)(d)}function u(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function yY(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),s):n(o)}function s(o){return o===null?n(o):t(o)}}function bY(e,t,n){let r,i,s;return o;function o(c){return c===46||c===95?e.check(vM,l,a)(c):c===null||ot(c)||wo(c)||c!==45&&mp(c)?l(c):(s=!0,e.consume(c),o)}function a(c){return c===95?r=!0:(i=r,r=void 0),e.consume(c),o}function l(c){return i||r||!s?n(c):t(c)}}function wY(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(vM,t,s)(o):o===null||ot(o)||wo(o)?t(o):(e.consume(o),i)}function s(o){return o===41&&r++,e.consume(o),i}}function SY(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),s):a===93?(e.consume(a),i):a===60||a===null||ot(a)||wo(a)?t(a):n(a)}function i(a){return a===null||a===40||a===91||ot(a)||wo(a)?t(a):r(a)}function s(a){return En(a)?o(a):n(a)}function o(a){return a===59?(e.consume(a),r):En(a)?(e.consume(a),o):n(a)}}function kY(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return yn(s)?n(s):t(s)}}function yM(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||ot(e)}function bM(e){return!En(e)}function wM(e){return!(e===47||P0(e))}function P0(e){return e===43||e===45||e===46||e===95||yn(e)}function Dy(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const CY={tokenize:AY,partial:!0};function EY(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:IY,continuation:{tokenize:RY},exit:MY}},text:{91:{name:"gfmFootnoteCall",tokenize:PY},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:NY,resolveTo:TY}}}}function NY(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);const c=Mr(r.sliceSerialize({start:o.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function TY(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function PY(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(d){if(s>999||d===93&&!o||d===null||d===91||ot(d))return n(d);if(d===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return i.includes(Mr(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return ot(d)||(o=!0),s++,e.consume(d),d===92?u:c}function u(d){return d===91||d===92||d===93?(e.consume(d),s++,c):c(d)}}function IY(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,a;return l;function l(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",u):n(m)}function u(m){if(o>999||m===93&&!a||m===null||m===91||ot(m))return n(m);if(m===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return s=Mr(r.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return ot(m)||(a=!0),o++,e.consume(m),m===92?d:u}function d(m){return m===91||m===92||m===93?(e.consume(m),o++,u):u(m)}function f(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),Ge(e,p,"gfmFootnoteDefinitionWhitespace")):n(m)}function p(m){return t(m)}}function RY(e,t,n){return e.check(Eu,t,e.attempt(CY,t,n))}function MY(e){e.exit("gfmFootnoteDefinition")}function AY(e,t,n){const r=this;return Ge(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(s):n(s)}}function LY(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},d={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},f=[["enter",u,a],["enter",o[c][1],a],["exit",o[c][1],a],["enter",d,a]],p=a.parser.constructs.insideSpan.null;p&&er(f,f.length,0,gp(p,o.slice(c+1,l),a)),er(f,f.length,0,[["exit",d,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",u,a]]),er(o,c-1,l-c+3,f),l=c+f.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function s(o,a,l){const c=this.previous,u=this.events;let d=0;return f;function f(m){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(m):(o.enter("strikethroughSequenceTemporary"),p(m))}function p(m){const v=Ua(c);if(m===126)return d>1?l(m):(o.consume(m),d++,p);if(d<2&&!n)return l(m);const b=o.exit("strikethroughSequenceTemporary"),_=Ua(m);return b._open=!_||_===2&&!!v,b._close=!v||v===2&&!!_,a(m)}}}class jY{constructor(){this.map=[]}add(t,n,r){DY(this,t,n,r)}consume(t){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function DY(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function OY(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function BY(){return{flow:{null:{name:"table",tokenize:zY,resolveAll:$Y}}}}function zY(e,t,n){const r=this;let i=0,s=0,o;return a;function a(P){let A=r.events.length-1;for(;A>-1;){const j=r.events[A][1].type;if(j==="lineEnding"||j==="linePrefix")A--;else break}const I=A>-1?r.events[A][1].type:null,R=I==="tableHead"||I==="tableRow"?C:l;return R===C&&r.parser.lazy[r.now().line]?n(P):R(P)}function l(P){return e.enter("tableHead"),e.enter("tableRow"),c(P)}function c(P){return P===124||(o=!0,s+=1),u(P)}function u(P){return P===null?n(P):be(P)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),p):n(P):Ue(P)?Ge(e,u,"whitespace")(P):(s+=1,o&&(o=!1,i+=1),P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),o=!0,u):(e.enter("data"),d(P)))}function d(P){return P===null||P===124||ot(P)?(e.exit("data"),u(P)):(e.consume(P),P===92?f:d)}function f(P){return P===92||P===124?(e.consume(P),d):d(P)}function p(P){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(P):(e.enter("tableDelimiterRow"),o=!1,Ue(P)?Ge(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):m(P))}function m(P){return P===45||P===58?b(P):P===124?(o=!0,e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),v):k(P)}function v(P){return Ue(P)?Ge(e,b,"whitespace")(P):b(P)}function b(P){return P===58?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),_):P===45?(s+=1,_(P)):P===null||be(P)?w(P):k(P)}function _(P){return P===45?(e.enter("tableDelimiterFiller"),x(P)):k(P)}function x(P){return P===45?(e.consume(P),x):P===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),y):(e.exit("tableDelimiterFiller"),y(P))}function y(P){return Ue(P)?Ge(e,w,"whitespace")(P):w(P)}function w(P){return P===124?m(P):P===null||be(P)?!o||i!==s?k(P):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(P)):k(P)}function k(P){return n(P)}function C(P){return e.enter("tableRow"),N(P)}function N(P){return P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),N):P===null||be(P)?(e.exit("tableRow"),t(P)):Ue(P)?Ge(e,N,"whitespace")(P):(e.enter("data"),T(P))}function T(P){return P===null||P===124||ot(P)?(e.exit("data"),N(P)):(e.consume(P),P===92?B:T)}function B(P){return P===92||P===124?(e.consume(P),T):T(P)}}function $Y(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,c,u,d;const f=new jY;for(;++n<e.length;){const p=e[n],m=p[1];p[0]==="enter"?m.type==="tableHead"?(a=!1,l!==0&&(_k(f,t,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",c,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,d=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,u={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",u,t]])),i=m.type==="tableDelimiterRow"?2:u?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],d=Sd(f,t,s,i,void 0,d),s=[0,0,0,0]),o[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],d=Sd(f,t,s,i,void 0,d)),s=o,o=[s[1],n,0,0])):m.type==="tableHead"?(a=!0,l=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(l=n,s[1]!==0?(o[0]=o[1],d=Sd(f,t,s,i,n,d)):o[1]!==0&&(d=Sd(f,t,o,i,n,d)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&_k(f,t,l,c,u),f.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=OY(t.events,n))}return e}function Sd(e,t,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},ea(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=ea(t.events,n[1]);if(s={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const c=ea(t.events,n[2]),u=ea(t.events,n[3]),d={type:a,start:Object.assign({},c),end:Object.assign({},u)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const f=t.events[n[2]],p=t.events[n[3]];if(f[1].end=Object.assign({},p[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,v=n[3]-n[2]-1;e.add(m,v,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return i!==void 0&&(s.end=Object.assign({},ea(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function _k(e,t,n,r,i){const s=[],o=ea(t.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,t])),r.end=Object.assign({},o),s.push(["exit",r,t]),e.add(n+1,0,s)}function ea(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const FY={name:"tasklistCheck",tokenize:UY};function HY(){return{text:{91:FY}}}function UY(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),s)}function s(l){return ot(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(l)}function a(l){return be(l)?t(l):Ue(l)?e.check({tokenize:WY},t,n)(l):n(l)}}function WY(e,t,n){return Ge(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function VY(e){return RR([gY(),EY(),LY(e),BY(),HY()])}const qY={};function nu(e){const t=this,n=e||qY,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(VY(n)),s.push(hY()),o.push(fY(n))}const KY=/<command-name>([\s\S]*?)<\/command-name>/i,GY=/<command-message>([\s\S]*?)<\/command-message>/i,XY=/<command-args>([\s\S]*?)<\/command-args>/i,YY=/<(local-command-[a-z]+|command-(?:stdout|stderr))>[\s\S]*?<\/\1>/gi;function yp(e){if(!e)return{commandName:null,commandMessage:null,commandArgs:null,body:""};const t=e.match(KY),n=e.match(GY),r=e.match(XY);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(YY,""),i=i.trim(),{commandName:t?t[1].trim():null,commandMessage:n?n[1].trim():null,commandArgs:r?r[1].trim():null,body:i}}function bp(e){if(!e)return!1;const n=e.split("#")[0].split("?")[0].toLowerCase();return n.endsWith(".md")||n.endsWith(".markdown")}function QY(e){if(!e)return null;let t;if(e.startsWith("file://")){const n=e.slice(7);t=n.startsWith("/")?n:`/${n.split("/").slice(1).join("/")}`}else{if(/^[a-z][a-z0-9+.-]*:/i.test(e))return null;if(e.startsWith("/"))t=e;else return null}try{return decodeURIComponent(t)}catch{return t}}const ZY=/\.(png|jpe?g|webp|gif|svg)$/i;function JY(e,t){if((typeof t=="string"?t:null)!==e)return!1;try{const r=new URL(e);return ZY.test(r.pathname)}catch{return!1}}function eQ(e){try{return new URL(e).pathname.split("/").filter(Boolean).pop()??""}catch{return""}}const So={a:({node:e,href:t,children:n,...r})=>typeof t=="string"&&JY(t,n)?h.jsxs("span",{className:"my-1 inline-flex flex-col items-start gap-1 align-top",children:[h.jsx("img",{src:t,alt:eQ(t),className:"max-w-full h-auto rounded border border-border"}),h.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"max-w-full truncate text-[11px] text-text-300 underline decoration-dotted underline-offset-2 hover:text-text-100",children:t})]}):h.jsx("a",{...r,href:t,target:"_blank",rel:"noopener noreferrer",children:n})};function tQ(e){return e.startsWith("file://")?e:JR(e)}function nQ(e){return{...So,a:t=>{const{href:n,children:r}=t,i=typeof n=="string"?QY(n):null;if(i===null){const s=So.a;return h.jsx(s,{...t})}return h.jsx("a",{href:n,"data-testid":"assistant-file-link",title:i,onClick:s=>{s.preventDefault(),e(i)},children:r})}}}function rQ({text:e,forkTarget:t,onOpenFilePath:n}){const{body:r}=yp(e),i=Ze.useMemo(()=>n?nQ(n):So,[n]);return r?h.jsxs("div",{className:"group relative flex min-w-0 max-w-full flex-col items-start","data-testid":"msg-line-assistant-wrapper",children:[h.jsx("div",{"data-testid":"msg-line-assistant",className:"assistant-markdown w-full min-w-0 max-w-full py-1 break-words",children:h.jsx(eu,{remarkPlugins:[nu],components:i,...n?{urlTransform:tQ}:{},children:r})}),t?h.jsxs("div",{className:"mt-1 flex flex-row items-center gap-1 md:absolute md:top-full md:mt-0 md:pt-0.5",children:[t.onFork?h.jsxs("button",{type:"button","data-testid":"assistant-msg-fork","aria-label":"fork from this message",title:"从这条消息派生新 session(截断之后的对话)",onClick:()=>t.onFork(t.messageUuid),className:"inline-flex items-center justify-start gap-1 h-7 w-7 md:h-6 md:w-auto md:px-1.5 rounded-md text-[11px] text-text-400/60 md:text-text-400 hover:bg-text-100/5 hover:text-text-200 md:opacity-0 md:group-hover:opacity-100 md:transition-opacity cursor-pointer",children:[h.jsx(Lx,{className:"w-3 h-3",strokeWidth:2}),h.jsx("span",{className:"hidden md:inline",children:"Fork"})]}):null,t.onQuickAsk?h.jsxs("button",{type:"button","data-testid":"assistant-msg-quick-ask","aria-label":"quick ask from this message",title:"快速问答:从这条消息派生临时会话,关闭即删",onClick:()=>t.onQuickAsk(t.messageUuid),className:"inline-flex items-center justify-start gap-1 h-7 w-7 md:h-6 md:w-auto md:px-1.5 rounded-md text-[11px] text-text-400/60 md:text-text-400 hover:bg-text-100/5 hover:text-text-200 md:opacity-0 md:group-hover:opacity-100 md:transition-opacity cursor-pointer",children:[h.jsx(Hz,{className:"w-3 h-3",strokeWidth:2}),h.jsx("span",{className:"hidden md:inline",children:"问一下"})]}):null]}):null]}):null}function iQ({text:e}){const[t,n]=g.useState(!1);return e?h.jsxs("div",{"data-testid":"msg-line-thinking",className:"text-[12px] text-text-400",children:[h.jsxs("button",{type:"button",onClick:()=>n(r=>!r),className:"flex items-center gap-1 hover:text-text-300 transition-colors cursor-pointer","aria-expanded":t,"data-testid":"msg-line-thinking-toggle",children:[t?h.jsx(ir,{className:"w-3 h-3"}):h.jsx(Un,{className:"w-3 h-3"}),h.jsx("span",{children:"💭 Thinking"})]}),t?h.jsx("div",{className:"ml-4 mt-1 italic text-text-400 whitespace-pre-wrap break-words",children:e}):null]}):null}const sQ=new Set(["Write","Edit","MultiEdit","NotebookEdit"]);function I0(e){return sQ.has(e)}function oQ({tool:e,relPath:t,scope:n,onShareFile:r}){if(!I0(e)||!t||!n||!r)return null;const i=bp(t)?"md-rendered":"raw";return h.jsx("span",{"data-testid":"file-edit-hover-row",className:"inline-flex shrink-0 items-center gap-1",children:h.jsx("span",{role:"button",tabIndex:0,"data-testid":"file-edit-share-btn","aria-label":"Share link",title:"Share link",onClick:s=>{s.stopPropagation(),r(t,i)},onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.stopPropagation(),s.preventDefault(),r(t,i))},className:"inline-flex h-3.5 w-3.5 items-center justify-center text-text-400 hover:text-text-200 cursor-pointer",children:h.jsx(jx,{className:"h-3.5 w-3.5"})})})}function aQ(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.file_path=="string"&&t.file_path||typeof t.notebook_path=="string"&&t.notebook_path||typeof t.path=="string"&&t.path||null||null}function SM(e,t){const[n,r]=g.useState({kind:"idle"});return g.useEffect(()=>{let i=!1,s=null;r({kind:"loading"});const o={};return t&&(o.Authorization=`Bearer ${t}`),fetch(e,{headers:o,credentials:"omit"}).then(async a=>{if(!a.ok)throw new Error(`HTTP ${a.status}`);return a.blob()}).then(a=>{if(i)return;const l=URL.createObjectURL(a);s=l,r({kind:"ready",objectUrl:l})}).catch(a=>{i||r({kind:"error",message:a.message})}),()=>{i=!0,s&&URL.revokeObjectURL(s)}},[e,t]),n}function lQ({url:e,bearerToken:t,alt:n,className:r}){const i=SM(e,t);return h.jsxs("div",{"data-testid":"blob-image","data-state":i.kind,className:fe("relative inline-flex items-center justify-center rounded-md border border-border bg-bg-0",r),children:[i.kind==="loading"?h.jsx("div",{className:"flex h-24 w-32 items-center justify-center",children:h.jsx(In,{className:"h-4 w-4 animate-spin text-text-400"})}):null,i.kind==="error"?h.jsxs("div",{className:"flex h-24 w-32 items-center justify-center gap-1 px-2 text-[11px] text-text-400",children:[h.jsx(Ls,{className:"h-3 w-3"}),h.jsx("span",{title:i.message,children:"加载失败"})]}):null,i.kind==="ready"?h.jsx("img",{src:i.objectUrl,alt:n,className:"block max-h-[180px] max-w-[420px] rounded-md object-contain"}):null]})}function cQ({url:e,bearerToken:t,className:n}){const r=SM(e,t);return h.jsxs("div",{"data-testid":"blob-video","data-state":r.kind,className:fe("relative inline-flex items-center justify-center rounded-md border border-border bg-bg-0",n),children:[r.kind==="loading"?h.jsx(In,{className:"h-4 w-4 animate-spin text-text-400"}):null,r.kind==="error"?h.jsx("span",{className:"px-2 text-[11px] text-text-400",children:"加载失败"}):null,r.kind==="ready"?h.jsx("video",{src:r.objectUrl,controls:!0,className:"block max-h-[240px] max-w-[420px] rounded-md"}):null]})}const uQ=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg"]),dQ=new Set([".mp4",".webm",".mov"]),hQ=new Set([".pdf"]);function fQ(e){const t=e.lastIndexOf("."),n=t>=0?e.slice(t).toLowerCase():"";return uQ.has(n)?"image":dQ.has(n)?"video":hQ.has(n)?"pdf":"binary"}function kM(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function pQ({relPath:e,scope:t,size:n}){const r=Zf();if(r.actionsLevel==="none")return null;const i=vB(r,t,e);if(!i)return null;const s=fQ(e);return s==="image"?h.jsx("div",{"data-testid":"file-edit-inline-preview","data-kind":"image",className:"mt-2",children:h.jsx(lQ,{url:i,bearerToken:r.httpToken,alt:e})}):s==="video"?h.jsx("div",{"data-testid":"file-edit-inline-preview","data-kind":"video",className:"mt-2",children:h.jsx(cQ,{url:i,bearerToken:r.httpToken})}):s==="pdf"?h.jsx(mQ,{relPath:e,url:i,size:n}):typeof n=="number"&&n>=1024*1024?h.jsxs("div",{"data-testid":"file-edit-inline-preview","data-kind":"binary",className:"mt-2 inline-flex items-center gap-1.5 rounded border border-border bg-bg-50 px-2 py-1 text-[11px] text-text-400",children:[h.jsx(Ro,{className:"h-3 w-3"}),h.jsx("span",{className:"font-mono",children:e.split("/").pop()}),h.jsx("span",{children:"·"}),h.jsx("span",{children:kM(n)})]}):null}function mQ({relPath:e,url:t,size:n}){return h.jsxs("a",{"data-testid":"file-edit-inline-preview","data-kind":"pdf",href:t,target:"_blank",rel:"noopener noreferrer",className:"mt-2 inline-flex items-center gap-1.5 rounded border border-border bg-bg-50 px-2 py-1 text-[11px] text-text-300 hover:bg-bg-100",children:[h.jsx(Ro,{className:"h-3 w-3"}),h.jsx("span",{className:"font-mono",children:e.split("/").pop()}),typeof n=="number"?h.jsxs(h.Fragment,{children:[h.jsx("span",{children:"·"}),h.jsx("span",{children:kM(n)})]}):null,h.jsx(qc,{className:"h-3 w-3"})]})}const gQ={Bash:BT,Read:Ro,Edit:OT,Write:Ez,Grep:Ew,Glob:Ew};function vQ(e){return gQ[e]??N$}function _Q(e){if(!e||typeof e!="object")return"";const t=e,n=t.command??t.file_path??t.path??t.pattern??t.query??t.url??t.description;if(typeof n=="string")return n;for(const r of Object.values(t))if(typeof r=="string"&&r)return r;return""}function CM({tool:e,input:t,output:n,error:r,pending:i=!1,expandedBody:s,fileScope:o,onOpenInTab:a,onPreviewMarkdown:l,onShareFile:c}){const[u,d]=g.useState(!1),f=!!r,p=vQ(e),m=_Q(t),v=aQ(t);return h.jsxs("div",{"data-testid":"msg-line-tool","data-tool":e,className:fe("group min-w-0 max-w-full rounded-md border px-3 py-2 text-[13px]",f?"border-destructive/40 bg-destructive/5":"border-border bg-bg-50"),children:[h.jsxs("button",{type:"button",onClick:()=>d(b=>!b),"aria-expanded":u,"data-testid":"msg-line-tool-header",className:"flex w-full items-center gap-2 text-left cursor-pointer min-w-0",children:[f?h.jsx(Ls,{className:"w-4 h-4 text-destructive shrink-0"}):h.jsx(p,{className:fe("w-4 h-4 shrink-0",i?"text-text-400":"text-text-300")}),h.jsx("span",{className:"font-medium text-text-100 shrink-0",children:e}),m?(()=>{if(f||!I0(e)||!v)return null;const _=bp(v)&&l?l:a;return _?h.jsx("span",{role:"button",tabIndex:0,"data-testid":"msg-line-tool-preview","data-clickable":"true",title:m,onClick:x=>{x.stopPropagation(),_(v)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.stopPropagation(),x.preventDefault(),_(v))},className:"text-[12px] text-accent font-mono truncate min-w-0 max-w-full cursor-pointer underline underline-offset-2 hover:opacity-80",children:m}):null})()??h.jsx("span",{"data-testid":"msg-line-tool-preview",className:"text-[12px] text-text-400 font-mono truncate min-w-0 max-w-full",title:m,children:m}):null,h.jsx("span",{"aria-hidden":"true","data-testid":"msg-line-tool-header-spacer",className:"flex-1 min-w-0 self-stretch"}),i?h.jsx(In,{"data-testid":"msg-line-tool-pending",className:"w-3 h-3 text-text-400 animate-spin shrink-0"}):null,!f&&o?h.jsx(oQ,{tool:e,relPath:v,scope:o,...c?{onShareFile:c}:{}}):null]}),u?s!==void 0?h.jsxs("div",{"data-testid":"msg-line-tool-body",className:"mt-2 min-w-0 text-[12px]",children:[s,f?h.jsxs("div",{className:"mt-2",children:[h.jsx("div",{className:"text-destructive mb-0.5",children:"error"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-destructive/40 rounded p-2 overflow-auto text-destructive",children:String(r)})]}):null]}):h.jsxs("div",{"data-testid":"msg-line-tool-body",className:"mt-2 min-w-0 space-y-1 text-[12px]",children:[h.jsxs("div",{children:[h.jsx("div",{className:"text-text-400 mb-0.5",children:"input"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-border rounded p-2 overflow-auto text-text-200",children:JSON.stringify(t,null,2)})]}),n!==void 0?h.jsxs("div",{children:[h.jsx("div",{className:"text-text-400 mb-0.5",children:"output"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-border rounded p-2 overflow-auto text-text-200",children:typeof n=="string"?n:JSON.stringify(n,null,2)})]}):null,f?h.jsxs("div",{children:[h.jsx("div",{className:"text-destructive mb-0.5",children:"error"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-destructive/40 rounded p-2 overflow-auto text-destructive",children:String(r)})]}):null]}):null,!f&&o&&v&&I0(e)?h.jsx(pQ,{relPath:v,scope:o}):null]})}var xQ=Symbol.for("react.lazy"),af=Qa[" use ".trim().toString()];function yQ(e){return typeof e=="object"&&e!==null&&"then"in e}function EM(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===xQ&&"_payload"in e&&yQ(e._payload)}function bQ(e){const t=SQ(e),n=g.forwardRef((r,i)=>{let{children:s,...o}=r;EM(s)&&typeof af=="function"&&(s=af(s._payload));const a=g.Children.toArray(s),l=a.find(CQ);if(l){const c=l.props.children,u=a.map(d=>d===l?g.Children.count(c)>1?g.Children.only(null):g.isValidElement(c)?c.props.children:null:d);return h.jsx(t,{...o,ref:i,children:g.isValidElement(c)?g.cloneElement(c,void 0,u):null})}return h.jsx(t,{...o,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}var wQ=bQ("Slot");function SQ(e){const t=g.forwardRef((n,r)=>{let{children:i,...s}=n;if(EM(i)&&typeof af=="function"&&(i=af(i._payload)),g.isValidElement(i)){const o=NQ(i),a=EQ(s,i.props);return i.type!==g.Fragment&&(a.ref=r?vu(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 kQ=Symbol("radix.slottable");function CQ(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===kQ}function EQ(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 NQ(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const xk=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,yk=HT,TQ=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return yk(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:s}=t,o=Object.keys(i).map(c=>{const u=n==null?void 0:n[c],d=s==null?void 0:s[c];if(u===null)return null;const f=xk(u)||xk(d);return i[c][f]}),a=n&&Object.entries(n).reduce((c,u)=>{let[d,f]=u;return f===void 0||(c[d]=f),c},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((c,u)=>{let{class:d,className:f,...p}=u;return Object.entries(p).every(m=>{let[v,b]=m;return Array.isArray(b)?b.includes({...s,...a}[v]):{...s,...a}[v]===b})?[...c,d,f]:c},[]);return yk(e,o,l,n==null?void 0:n.class,n==null?void 0:n.className)},PQ=TQ("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-accent text-accent-contrast hover:bg-accent-hover",destructive:"bg-destructive text-white hover:bg-destructive-hover",outline:"border border-border bg-transparent text-text-100 hover:bg-bg-200",ghost:"bg-transparent text-text-200 hover:bg-bg-200 hover:text-text-100"},size:{sm:"h-8 px-3 text-xs",md:"h-9 px-4",lg:"h-11 px-6 text-base"}},defaultVariants:{variant:"default",size:"md"}}),ni=g.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...i},s)=>{const o=r?wQ:"button";return h.jsx(o,{ref:s,className:fe(PQ({variant:t,size:n}),e),...i})});ni.displayName="Button";function IQ({tool:e,input:t,onRespond:n,onInterrupt:r}){return h.jsxs("div",{"data-testid":"msg-line-permission",className:"min-w-0 max-w-full rounded-md border border-warning/40 bg-warning-dim/60 px-3 py-2.5 text-[13px]",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 mb-1.5",children:[h.jsx(m$,{className:"w-4 h-4 text-warning shrink-0"}),h.jsxs("span",{className:"min-w-0 font-medium text-text-100 truncate",children:["权限请求:",e]}),r?h.jsx("button",{type:"button",onClick:r,"data-testid":"msg-line-permission-interrupt","aria-label":"interrupt current turn",title:"中断当前轮次(不杀进程)",className:"ml-auto h-6 w-6 rounded-md flex items-center justify-center text-text-400 hover:bg-text-100/10 hover:text-text-200 transition-colors cursor-pointer",children:h.jsx(DT,{className:"w-3.5 h-3.5",strokeWidth:2})}):null]}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-border rounded p-2 mb-2 max-h-[140px] overflow-auto text-[12px] text-text-200",children:JSON.stringify(t,null,2)}),h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsx(ni,{size:"sm",variant:"default",onClick:()=>n(!0,!1),"data-testid":"msg-line-permission-allow",children:"Allow"}),h.jsx(ni,{size:"sm",variant:"outline",onClick:()=>n(!0,!0),"data-testid":"msg-line-permission-allow-always",children:"Allow Always"}),h.jsx(ni,{size:"sm",variant:"destructive",onClick:()=>n(!1,!1),"data-testid":"msg-line-permission-deny",children:"Deny"})]})]})}function RQ({message:e}){return h.jsxs("div",{"data-testid":"msg-line-error",className:"flex min-w-0 max-w-full items-start gap-2 text-destructive text-[13px] rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2",children:[h.jsx(Kc,{className:"w-4 h-4 shrink-0 mt-0.5"}),h.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:e})]})}const bk=/\[attachment:(image|file):([^\]]+)\]/g;function MQ(e){const t=[];let n;for(;(n=bk.exec(e))!==null;){const i=n[2],s=decodeURIComponent(i.split("/").pop()??"file");t.push({type:n[1],url:i,fileName:s})}const r=e.replace(bk,"").trim();return{attachments:t,text:r}}function AQ(e,t){const n=t.filter(i=>i.status==="done"&&i.url);return n.length===0?e:n.map(i=>`[attachment:${i.mimeType.startsWith("image/")?"image":"file"}:${i.url}]`).join(`
|
|
503
|
+
`))}function l(p,m,v,b){const _=v.enter("tableCell"),x=v.enter("phrasing"),y=v.containerPhrasing(p,{...b,before:s,after:s});return x(),_(),y}function c(p,m){return bX(p,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function u(p,m,v){const b=p.children;let _=-1;const x=[],y=m.enter("table");for(;++_<b.length;)x[_]=d(b[_],m,v);return y(),x}function d(p,m,v){const b=p.children;let _=-1;const x=[],y=m.enter("tableRow");for(;++_<b.length;)x[_]=l(b[_],p,m,v);return y(),x}function f(p,m,v){let b=pM.inlineCode(p,m,v);return v.stack.includes("tableCell")&&(b=b.replace(/\|/g,"\\$&")),b}}function lY(){return{exit:{taskListCheckValueChecked:vk,taskListCheckValueUnchecked:vk,paragraph:uY}}}function cY(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:dY}}}function vk(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function uY(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,o;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function dY(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(o);let l=pM.listItem(e,t,n,{...r,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(u){return u+o}}function hY(){return[WG(),dX(),mX(),tY(),lY()]}function fY(e){return{extensions:[VG(),hX(e),gX(),aY(e),cY()]}}const pY={tokenize:yY,partial:!0},mM={tokenize:bY,partial:!0},gM={tokenize:wY,partial:!0},vM={tokenize:SY,partial:!0},mY={tokenize:kY,partial:!0},_M={name:"wwwAutolink",tokenize:_Y,previous:yM},xM={name:"protocolAutolink",tokenize:xY,previous:bM},Fi={name:"emailAutolink",tokenize:vY,previous:wM},di={};function gY(){return{text:di}}let Ws=48;for(;Ws<123;)di[Ws]=Fi,Ws++,Ws===58?Ws=65:Ws===91&&(Ws=97);di[43]=Fi;di[45]=Fi;di[46]=Fi;di[95]=Fi;di[72]=[Fi,xM];di[104]=[Fi,xM];di[87]=[Fi,_M];di[119]=[Fi,_M];function vY(e,t,n){const r=this;let i,s;return o;function o(d){return!P0(d)||!wM.call(r,r.previous)||Dy(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(d))}function a(d){return P0(d)?(e.consume(d),a):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(mY,u,c)(d):d===45||d===95||yn(d)?(s=!0,e.consume(d),l):u(d)}function c(d){return e.consume(d),i=!0,l}function u(d){return s&&i&&En(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function _Y(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!yM.call(r,r.previous)||Dy(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(pY,e.attempt(mM,e.attempt(gM,s),n),n)(o))}function s(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function xY(e,t,n){const r=this;let i="",s=!1;return o;function o(d){return(d===72||d===104)&&bM.call(r,r.previous)&&!Dy(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),e.consume(d),a):n(d)}function a(d){if(En(d)&&i.length<5)return i+=String.fromCodePoint(d),e.consume(d),a;if(d===58){const f=i.toLowerCase();if(f==="http"||f==="https")return e.consume(d),l}return n(d)}function l(d){return d===47?(e.consume(d),s?c:(s=!0,l)):n(d)}function c(d){return d===null||nf(d)||ot(d)||wo(d)||mp(d)?n(d):e.attempt(mM,e.attempt(gM,u),n)(d)}function u(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function yY(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),s):n(o)}function s(o){return o===null?n(o):t(o)}}function bY(e,t,n){let r,i,s;return o;function o(c){return c===46||c===95?e.check(vM,l,a)(c):c===null||ot(c)||wo(c)||c!==45&&mp(c)?l(c):(s=!0,e.consume(c),o)}function a(c){return c===95?r=!0:(i=r,r=void 0),e.consume(c),o}function l(c){return i||r||!s?n(c):t(c)}}function wY(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(vM,t,s)(o):o===null||ot(o)||wo(o)?t(o):(e.consume(o),i)}function s(o){return o===41&&r++,e.consume(o),i}}function SY(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),s):a===93?(e.consume(a),i):a===60||a===null||ot(a)||wo(a)?t(a):n(a)}function i(a){return a===null||a===40||a===91||ot(a)||wo(a)?t(a):r(a)}function s(a){return En(a)?o(a):n(a)}function o(a){return a===59?(e.consume(a),r):En(a)?(e.consume(a),o):n(a)}}function kY(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return yn(s)?n(s):t(s)}}function yM(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||ot(e)}function bM(e){return!En(e)}function wM(e){return!(e===47||P0(e))}function P0(e){return e===43||e===45||e===46||e===95||yn(e)}function Dy(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const CY={tokenize:AY,partial:!0};function EY(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:IY,continuation:{tokenize:RY},exit:MY}},text:{91:{name:"gfmFootnoteCall",tokenize:PY},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:NY,resolveTo:TY}}}}function NY(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);const c=Mr(r.sliceSerialize({start:o.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function TY(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function PY(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(d){if(s>999||d===93&&!o||d===null||d===91||ot(d))return n(d);if(d===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return i.includes(Mr(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return ot(d)||(o=!0),s++,e.consume(d),d===92?u:c}function u(d){return d===91||d===92||d===93?(e.consume(d),s++,c):c(d)}}function IY(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,a;return l;function l(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",u):n(m)}function u(m){if(o>999||m===93&&!a||m===null||m===91||ot(m))return n(m);if(m===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return s=Mr(r.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return ot(m)||(a=!0),o++,e.consume(m),m===92?d:u}function d(m){return m===91||m===92||m===93?(e.consume(m),o++,u):u(m)}function f(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),Ge(e,p,"gfmFootnoteDefinitionWhitespace")):n(m)}function p(m){return t(m)}}function RY(e,t,n){return e.check(Eu,t,e.attempt(CY,t,n))}function MY(e){e.exit("gfmFootnoteDefinition")}function AY(e,t,n){const r=this;return Ge(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(s):n(s)}}function LY(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},d={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},f=[["enter",u,a],["enter",o[c][1],a],["exit",o[c][1],a],["enter",d,a]],p=a.parser.constructs.insideSpan.null;p&&er(f,f.length,0,gp(p,o.slice(c+1,l),a)),er(f,f.length,0,[["exit",d,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",u,a]]),er(o,c-1,l-c+3,f),l=c+f.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function s(o,a,l){const c=this.previous,u=this.events;let d=0;return f;function f(m){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(m):(o.enter("strikethroughSequenceTemporary"),p(m))}function p(m){const v=Ua(c);if(m===126)return d>1?l(m):(o.consume(m),d++,p);if(d<2&&!n)return l(m);const b=o.exit("strikethroughSequenceTemporary"),_=Ua(m);return b._open=!_||_===2&&!!v,b._close=!v||v===2&&!!_,a(m)}}}class jY{constructor(){this.map=[]}add(t,n,r){DY(this,t,n,r)}consume(t){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function DY(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function OY(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function BY(){return{flow:{null:{name:"table",tokenize:zY,resolveAll:$Y}}}}function zY(e,t,n){const r=this;let i=0,s=0,o;return a;function a(P){let A=r.events.length-1;for(;A>-1;){const j=r.events[A][1].type;if(j==="lineEnding"||j==="linePrefix")A--;else break}const I=A>-1?r.events[A][1].type:null,R=I==="tableHead"||I==="tableRow"?C:l;return R===C&&r.parser.lazy[r.now().line]?n(P):R(P)}function l(P){return e.enter("tableHead"),e.enter("tableRow"),c(P)}function c(P){return P===124||(o=!0,s+=1),u(P)}function u(P){return P===null?n(P):be(P)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),p):n(P):Ue(P)?Ge(e,u,"whitespace")(P):(s+=1,o&&(o=!1,i+=1),P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),o=!0,u):(e.enter("data"),d(P)))}function d(P){return P===null||P===124||ot(P)?(e.exit("data"),u(P)):(e.consume(P),P===92?f:d)}function f(P){return P===92||P===124?(e.consume(P),d):d(P)}function p(P){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(P):(e.enter("tableDelimiterRow"),o=!1,Ue(P)?Ge(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):m(P))}function m(P){return P===45||P===58?b(P):P===124?(o=!0,e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),v):k(P)}function v(P){return Ue(P)?Ge(e,b,"whitespace")(P):b(P)}function b(P){return P===58?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),_):P===45?(s+=1,_(P)):P===null||be(P)?w(P):k(P)}function _(P){return P===45?(e.enter("tableDelimiterFiller"),x(P)):k(P)}function x(P){return P===45?(e.consume(P),x):P===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),y):(e.exit("tableDelimiterFiller"),y(P))}function y(P){return Ue(P)?Ge(e,w,"whitespace")(P):w(P)}function w(P){return P===124?m(P):P===null||be(P)?!o||i!==s?k(P):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(P)):k(P)}function k(P){return n(P)}function C(P){return e.enter("tableRow"),N(P)}function N(P){return P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),N):P===null||be(P)?(e.exit("tableRow"),t(P)):Ue(P)?Ge(e,N,"whitespace")(P):(e.enter("data"),T(P))}function T(P){return P===null||P===124||ot(P)?(e.exit("data"),N(P)):(e.consume(P),P===92?B:T)}function B(P){return P===92||P===124?(e.consume(P),T):T(P)}}function $Y(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,c,u,d;const f=new jY;for(;++n<e.length;){const p=e[n],m=p[1];p[0]==="enter"?m.type==="tableHead"?(a=!1,l!==0&&(_k(f,t,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",c,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,d=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,u={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",u,t]])),i=m.type==="tableDelimiterRow"?2:u?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],d=Sd(f,t,s,i,void 0,d),s=[0,0,0,0]),o[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],d=Sd(f,t,s,i,void 0,d)),s=o,o=[s[1],n,0,0])):m.type==="tableHead"?(a=!0,l=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(l=n,s[1]!==0?(o[0]=o[1],d=Sd(f,t,s,i,n,d)):o[1]!==0&&(d=Sd(f,t,o,i,n,d)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&_k(f,t,l,c,u),f.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=OY(t.events,n))}return e}function Sd(e,t,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},ea(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=ea(t.events,n[1]);if(s={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const c=ea(t.events,n[2]),u=ea(t.events,n[3]),d={type:a,start:Object.assign({},c),end:Object.assign({},u)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const f=t.events[n[2]],p=t.events[n[3]];if(f[1].end=Object.assign({},p[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,v=n[3]-n[2]-1;e.add(m,v,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return i!==void 0&&(s.end=Object.assign({},ea(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function _k(e,t,n,r,i){const s=[],o=ea(t.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,t])),r.end=Object.assign({},o),s.push(["exit",r,t]),e.add(n+1,0,s)}function ea(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const FY={name:"tasklistCheck",tokenize:UY};function HY(){return{text:{91:FY}}}function UY(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),s)}function s(l){return ot(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(l)}function a(l){return be(l)?t(l):Ue(l)?e.check({tokenize:WY},t,n)(l):n(l)}}function WY(e,t,n){return Ge(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function VY(e){return RR([gY(),EY(),LY(e),BY(),HY()])}const qY={};function nu(e){const t=this,n=e||qY,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(VY(n)),s.push(hY()),o.push(fY(n))}const KY=/<command-name>([\s\S]*?)<\/command-name>/i,GY=/<command-message>([\s\S]*?)<\/command-message>/i,XY=/<command-args>([\s\S]*?)<\/command-args>/i,YY=/<(local-command-[a-z]+|command-(?:stdout|stderr))>[\s\S]*?<\/\1>/gi;function yp(e){if(!e)return{commandName:null,commandMessage:null,commandArgs:null,body:""};const t=e.match(KY),n=e.match(GY),r=e.match(XY);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(YY,""),i=i.trim(),{commandName:t?t[1].trim():null,commandMessage:n?n[1].trim():null,commandArgs:r?r[1].trim():null,body:i}}function bp(e){if(!e)return!1;const n=e.split("#")[0].split("?")[0].toLowerCase();return n.endsWith(".md")||n.endsWith(".markdown")}function QY(e){if(!e)return null;let t;if(e.startsWith("file://")){const n=e.slice(7);t=n.startsWith("/")?n:`/${n.split("/").slice(1).join("/")}`}else{if(/^[a-z][a-z0-9+.-]*:/i.test(e))return null;if(e.startsWith("/"))t=e;else return null}try{return decodeURIComponent(t)}catch{return t}}const ZY=/\.(png|jpe?g|webp|gif|svg)$/i;function JY(e,t){if((typeof t=="string"?t:null)!==e)return!1;try{const r=new URL(e);return ZY.test(r.pathname)}catch{return!1}}function eQ(e){try{return new URL(e).pathname.split("/").filter(Boolean).pop()??""}catch{return""}}const So={a:({node:e,href:t,children:n,...r})=>typeof t=="string"&&JY(t,n)?h.jsxs("span",{className:"my-1 inline-flex flex-col items-start gap-1 align-top",children:[h.jsx("img",{src:t,alt:eQ(t),className:"max-w-full h-auto rounded border border-border"}),h.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"max-w-full truncate text-[11px] text-text-300 underline decoration-dotted underline-offset-2 hover:text-text-100",children:t})]}):h.jsx("a",{...r,href:t,target:"_blank",rel:"noopener noreferrer",children:n})};function tQ(e){return e.startsWith("file://")?e:JR(e)}function nQ(e){return{...So,a:t=>{const{href:n,children:r}=t,i=typeof n=="string"?QY(n):null;if(i===null){const s=So.a;return h.jsx(s,{...t})}return h.jsx("a",{href:n,"data-testid":"assistant-file-link",title:i,onClick:s=>{s.preventDefault(),e(i)},children:r})}}}function rQ({text:e,forkTarget:t,onOpenFilePath:n}){const{body:r}=yp(e),i=Ze.useMemo(()=>n?nQ(n):So,[n]);return r?h.jsxs("div",{className:"group relative flex min-w-0 max-w-full flex-col items-start","data-testid":"msg-line-assistant-wrapper",children:[h.jsx("div",{"data-testid":"msg-line-assistant",className:"assistant-markdown w-full min-w-0 max-w-full py-1 break-words",children:h.jsx(eu,{remarkPlugins:[nu],components:i,...n?{urlTransform:tQ}:{},children:r})}),t?h.jsxs("div",{className:"mt-1 flex flex-row items-center gap-1 md:absolute md:top-full md:mt-0 md:pt-0.5 md:z-10 md:rounded-md md:pointer-events-none md:group-hover:pointer-events-auto md:group-hover:bg-bg-100",children:[t.onFork?h.jsxs("button",{type:"button","data-testid":"assistant-msg-fork","aria-label":"fork from this message",title:"从这条消息派生新 session(截断之后的对话)",onClick:()=>t.onFork(t.messageUuid),className:"inline-flex items-center justify-start gap-1 h-7 w-7 md:h-6 md:w-auto md:px-1.5 rounded-md text-[11px] text-text-400/60 md:text-text-400 hover:bg-text-100/5 hover:text-text-200 md:opacity-0 md:group-hover:opacity-100 md:transition-opacity cursor-pointer",children:[h.jsx(Lx,{className:"w-3 h-3",strokeWidth:2}),h.jsx("span",{className:"hidden md:inline",children:"Fork"})]}):null,t.onQuickAsk?h.jsxs("button",{type:"button","data-testid":"assistant-msg-quick-ask","aria-label":"quick ask from this message",title:"快速问答:从这条消息派生临时会话,关闭即删",onClick:()=>t.onQuickAsk(t.messageUuid),className:"inline-flex items-center justify-start gap-1 h-7 w-7 md:h-6 md:w-auto md:px-1.5 rounded-md text-[11px] text-text-400/60 md:text-text-400 hover:bg-text-100/5 hover:text-text-200 md:opacity-0 md:group-hover:opacity-100 md:transition-opacity cursor-pointer",children:[h.jsx(Hz,{className:"w-3 h-3",strokeWidth:2}),h.jsx("span",{className:"hidden md:inline",children:"问一下"})]}):null]}):null]}):null}function iQ({text:e}){const[t,n]=g.useState(!1);return e?h.jsxs("div",{"data-testid":"msg-line-thinking",className:"text-[12px] text-text-400",children:[h.jsxs("button",{type:"button",onClick:()=>n(r=>!r),className:"flex items-center gap-1 hover:text-text-300 transition-colors cursor-pointer","aria-expanded":t,"data-testid":"msg-line-thinking-toggle",children:[t?h.jsx(ir,{className:"w-3 h-3"}):h.jsx(Un,{className:"w-3 h-3"}),h.jsx("span",{children:"💭 Thinking"})]}),t?h.jsx("div",{className:"ml-4 mt-1 italic text-text-400 whitespace-pre-wrap break-words",children:e}):null]}):null}const sQ=new Set(["Write","Edit","MultiEdit","NotebookEdit"]);function I0(e){return sQ.has(e)}function oQ({tool:e,relPath:t,scope:n,onShareFile:r}){if(!I0(e)||!t||!n||!r)return null;const i=bp(t)?"md-rendered":"raw";return h.jsx("span",{"data-testid":"file-edit-hover-row",className:"inline-flex shrink-0 items-center gap-1",children:h.jsx("span",{role:"button",tabIndex:0,"data-testid":"file-edit-share-btn","aria-label":"Share link",title:"Share link",onClick:s=>{s.stopPropagation(),r(t,i)},onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.stopPropagation(),s.preventDefault(),r(t,i))},className:"inline-flex h-3.5 w-3.5 items-center justify-center text-text-400 hover:text-text-200 cursor-pointer",children:h.jsx(jx,{className:"h-3.5 w-3.5"})})})}function aQ(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.file_path=="string"&&t.file_path||typeof t.notebook_path=="string"&&t.notebook_path||typeof t.path=="string"&&t.path||null||null}function SM(e,t){const[n,r]=g.useState({kind:"idle"});return g.useEffect(()=>{let i=!1,s=null;r({kind:"loading"});const o={};return t&&(o.Authorization=`Bearer ${t}`),fetch(e,{headers:o,credentials:"omit"}).then(async a=>{if(!a.ok)throw new Error(`HTTP ${a.status}`);return a.blob()}).then(a=>{if(i)return;const l=URL.createObjectURL(a);s=l,r({kind:"ready",objectUrl:l})}).catch(a=>{i||r({kind:"error",message:a.message})}),()=>{i=!0,s&&URL.revokeObjectURL(s)}},[e,t]),n}function lQ({url:e,bearerToken:t,alt:n,className:r}){const i=SM(e,t);return h.jsxs("div",{"data-testid":"blob-image","data-state":i.kind,className:fe("relative inline-flex items-center justify-center rounded-md border border-border bg-bg-0",r),children:[i.kind==="loading"?h.jsx("div",{className:"flex h-24 w-32 items-center justify-center",children:h.jsx(In,{className:"h-4 w-4 animate-spin text-text-400"})}):null,i.kind==="error"?h.jsxs("div",{className:"flex h-24 w-32 items-center justify-center gap-1 px-2 text-[11px] text-text-400",children:[h.jsx(Ls,{className:"h-3 w-3"}),h.jsx("span",{title:i.message,children:"加载失败"})]}):null,i.kind==="ready"?h.jsx("img",{src:i.objectUrl,alt:n,className:"block max-h-[180px] max-w-[420px] rounded-md object-contain"}):null]})}function cQ({url:e,bearerToken:t,className:n}){const r=SM(e,t);return h.jsxs("div",{"data-testid":"blob-video","data-state":r.kind,className:fe("relative inline-flex items-center justify-center rounded-md border border-border bg-bg-0",n),children:[r.kind==="loading"?h.jsx(In,{className:"h-4 w-4 animate-spin text-text-400"}):null,r.kind==="error"?h.jsx("span",{className:"px-2 text-[11px] text-text-400",children:"加载失败"}):null,r.kind==="ready"?h.jsx("video",{src:r.objectUrl,controls:!0,className:"block max-h-[240px] max-w-[420px] rounded-md"}):null]})}const uQ=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg"]),dQ=new Set([".mp4",".webm",".mov"]),hQ=new Set([".pdf"]);function fQ(e){const t=e.lastIndexOf("."),n=t>=0?e.slice(t).toLowerCase():"";return uQ.has(n)?"image":dQ.has(n)?"video":hQ.has(n)?"pdf":"binary"}function kM(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function pQ({relPath:e,scope:t,size:n}){const r=Zf();if(r.actionsLevel==="none")return null;const i=vB(r,t,e);if(!i)return null;const s=fQ(e);return s==="image"?h.jsx("div",{"data-testid":"file-edit-inline-preview","data-kind":"image",className:"mt-2",children:h.jsx(lQ,{url:i,bearerToken:r.httpToken,alt:e})}):s==="video"?h.jsx("div",{"data-testid":"file-edit-inline-preview","data-kind":"video",className:"mt-2",children:h.jsx(cQ,{url:i,bearerToken:r.httpToken})}):s==="pdf"?h.jsx(mQ,{relPath:e,url:i,size:n}):typeof n=="number"&&n>=1024*1024?h.jsxs("div",{"data-testid":"file-edit-inline-preview","data-kind":"binary",className:"mt-2 inline-flex items-center gap-1.5 rounded border border-border bg-bg-50 px-2 py-1 text-[11px] text-text-400",children:[h.jsx(Ro,{className:"h-3 w-3"}),h.jsx("span",{className:"font-mono",children:e.split("/").pop()}),h.jsx("span",{children:"·"}),h.jsx("span",{children:kM(n)})]}):null}function mQ({relPath:e,url:t,size:n}){return h.jsxs("a",{"data-testid":"file-edit-inline-preview","data-kind":"pdf",href:t,target:"_blank",rel:"noopener noreferrer",className:"mt-2 inline-flex items-center gap-1.5 rounded border border-border bg-bg-50 px-2 py-1 text-[11px] text-text-300 hover:bg-bg-100",children:[h.jsx(Ro,{className:"h-3 w-3"}),h.jsx("span",{className:"font-mono",children:e.split("/").pop()}),typeof n=="number"?h.jsxs(h.Fragment,{children:[h.jsx("span",{children:"·"}),h.jsx("span",{children:kM(n)})]}):null,h.jsx(qc,{className:"h-3 w-3"})]})}const gQ={Bash:BT,Read:Ro,Edit:OT,Write:Ez,Grep:Ew,Glob:Ew};function vQ(e){return gQ[e]??N$}function _Q(e){if(!e||typeof e!="object")return"";const t=e,n=t.command??t.file_path??t.path??t.pattern??t.query??t.url??t.description;if(typeof n=="string")return n;for(const r of Object.values(t))if(typeof r=="string"&&r)return r;return""}function CM({tool:e,input:t,output:n,error:r,pending:i=!1,expandedBody:s,fileScope:o,onOpenInTab:a,onPreviewMarkdown:l,onShareFile:c}){const[u,d]=g.useState(!1),f=!!r,p=vQ(e),m=_Q(t),v=aQ(t);return h.jsxs("div",{"data-testid":"msg-line-tool","data-tool":e,className:fe("group min-w-0 max-w-full rounded-md border px-3 py-2 text-[13px]",f?"border-destructive/40 bg-destructive/5":"border-border bg-bg-50"),children:[h.jsxs("button",{type:"button",onClick:()=>d(b=>!b),"aria-expanded":u,"data-testid":"msg-line-tool-header",className:"flex w-full items-center gap-2 text-left cursor-pointer min-w-0",children:[f?h.jsx(Ls,{className:"w-4 h-4 text-destructive shrink-0"}):h.jsx(p,{className:fe("w-4 h-4 shrink-0",i?"text-text-400":"text-text-300")}),h.jsx("span",{className:"font-medium text-text-100 shrink-0",children:e}),m?(()=>{if(f||!I0(e)||!v)return null;const _=bp(v)&&l?l:a;return _?h.jsx("span",{role:"button",tabIndex:0,"data-testid":"msg-line-tool-preview","data-clickable":"true",title:m,onClick:x=>{x.stopPropagation(),_(v)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.stopPropagation(),x.preventDefault(),_(v))},className:"text-[12px] text-accent font-mono truncate min-w-0 max-w-full cursor-pointer underline underline-offset-2 hover:opacity-80",children:m}):null})()??h.jsx("span",{"data-testid":"msg-line-tool-preview",className:"text-[12px] text-text-400 font-mono truncate min-w-0 max-w-full",title:m,children:m}):null,h.jsx("span",{"aria-hidden":"true","data-testid":"msg-line-tool-header-spacer",className:"flex-1 min-w-0 self-stretch"}),i?h.jsx(In,{"data-testid":"msg-line-tool-pending",className:"w-3 h-3 text-text-400 animate-spin shrink-0"}):null,!f&&o?h.jsx(oQ,{tool:e,relPath:v,scope:o,...c?{onShareFile:c}:{}}):null]}),u?s!==void 0?h.jsxs("div",{"data-testid":"msg-line-tool-body",className:"mt-2 min-w-0 text-[12px]",children:[s,f?h.jsxs("div",{className:"mt-2",children:[h.jsx("div",{className:"text-destructive mb-0.5",children:"error"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-destructive/40 rounded p-2 overflow-auto text-destructive",children:String(r)})]}):null]}):h.jsxs("div",{"data-testid":"msg-line-tool-body",className:"mt-2 min-w-0 space-y-1 text-[12px]",children:[h.jsxs("div",{children:[h.jsx("div",{className:"text-text-400 mb-0.5",children:"input"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-border rounded p-2 overflow-auto text-text-200",children:JSON.stringify(t,null,2)})]}),n!==void 0?h.jsxs("div",{children:[h.jsx("div",{className:"text-text-400 mb-0.5",children:"output"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-border rounded p-2 overflow-auto text-text-200",children:typeof n=="string"?n:JSON.stringify(n,null,2)})]}):null,f?h.jsxs("div",{children:[h.jsx("div",{className:"text-destructive mb-0.5",children:"error"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-destructive/40 rounded p-2 overflow-auto text-destructive",children:String(r)})]}):null]}):null,!f&&o&&v&&I0(e)?h.jsx(pQ,{relPath:v,scope:o}):null]})}var xQ=Symbol.for("react.lazy"),af=Qa[" use ".trim().toString()];function yQ(e){return typeof e=="object"&&e!==null&&"then"in e}function EM(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===xQ&&"_payload"in e&&yQ(e._payload)}function bQ(e){const t=SQ(e),n=g.forwardRef((r,i)=>{let{children:s,...o}=r;EM(s)&&typeof af=="function"&&(s=af(s._payload));const a=g.Children.toArray(s),l=a.find(CQ);if(l){const c=l.props.children,u=a.map(d=>d===l?g.Children.count(c)>1?g.Children.only(null):g.isValidElement(c)?c.props.children:null:d);return h.jsx(t,{...o,ref:i,children:g.isValidElement(c)?g.cloneElement(c,void 0,u):null})}return h.jsx(t,{...o,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}var wQ=bQ("Slot");function SQ(e){const t=g.forwardRef((n,r)=>{let{children:i,...s}=n;if(EM(i)&&typeof af=="function"&&(i=af(i._payload)),g.isValidElement(i)){const o=NQ(i),a=EQ(s,i.props);return i.type!==g.Fragment&&(a.ref=r?vu(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 kQ=Symbol("radix.slottable");function CQ(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===kQ}function EQ(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 NQ(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const xk=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,yk=HT,TQ=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return yk(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:s}=t,o=Object.keys(i).map(c=>{const u=n==null?void 0:n[c],d=s==null?void 0:s[c];if(u===null)return null;const f=xk(u)||xk(d);return i[c][f]}),a=n&&Object.entries(n).reduce((c,u)=>{let[d,f]=u;return f===void 0||(c[d]=f),c},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((c,u)=>{let{class:d,className:f,...p}=u;return Object.entries(p).every(m=>{let[v,b]=m;return Array.isArray(b)?b.includes({...s,...a}[v]):{...s,...a}[v]===b})?[...c,d,f]:c},[]);return yk(e,o,l,n==null?void 0:n.class,n==null?void 0:n.className)},PQ=TQ("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-accent text-accent-contrast hover:bg-accent-hover",destructive:"bg-destructive text-white hover:bg-destructive-hover",outline:"border border-border bg-transparent text-text-100 hover:bg-bg-200",ghost:"bg-transparent text-text-200 hover:bg-bg-200 hover:text-text-100"},size:{sm:"h-8 px-3 text-xs",md:"h-9 px-4",lg:"h-11 px-6 text-base"}},defaultVariants:{variant:"default",size:"md"}}),ni=g.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...i},s)=>{const o=r?wQ:"button";return h.jsx(o,{ref:s,className:fe(PQ({variant:t,size:n}),e),...i})});ni.displayName="Button";function IQ({tool:e,input:t,onRespond:n,onInterrupt:r}){return h.jsxs("div",{"data-testid":"msg-line-permission",className:"min-w-0 max-w-full rounded-md border border-warning/40 bg-warning-dim/60 px-3 py-2.5 text-[13px]",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 mb-1.5",children:[h.jsx(m$,{className:"w-4 h-4 text-warning shrink-0"}),h.jsxs("span",{className:"min-w-0 font-medium text-text-100 truncate",children:["权限请求:",e]}),r?h.jsx("button",{type:"button",onClick:r,"data-testid":"msg-line-permission-interrupt","aria-label":"interrupt current turn",title:"中断当前轮次(不杀进程)",className:"ml-auto h-6 w-6 rounded-md flex items-center justify-center text-text-400 hover:bg-text-100/10 hover:text-text-200 transition-colors cursor-pointer",children:h.jsx(DT,{className:"w-3.5 h-3.5",strokeWidth:2})}):null]}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-border rounded p-2 mb-2 max-h-[140px] overflow-auto text-[12px] text-text-200",children:JSON.stringify(t,null,2)}),h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsx(ni,{size:"sm",variant:"default",onClick:()=>n(!0,!1),"data-testid":"msg-line-permission-allow",children:"Allow"}),h.jsx(ni,{size:"sm",variant:"outline",onClick:()=>n(!0,!0),"data-testid":"msg-line-permission-allow-always",children:"Allow Always"}),h.jsx(ni,{size:"sm",variant:"destructive",onClick:()=>n(!1,!1),"data-testid":"msg-line-permission-deny",children:"Deny"})]})]})}function RQ({message:e}){return h.jsxs("div",{"data-testid":"msg-line-error",className:"flex min-w-0 max-w-full items-start gap-2 text-destructive text-[13px] rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2",children:[h.jsx(Kc,{className:"w-4 h-4 shrink-0 mt-0.5"}),h.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:e})]})}const bk=/\[attachment:(image|file):([^\]]+)\]/g;function MQ(e){const t=[];let n;for(;(n=bk.exec(e))!==null;){const i=n[2],s=decodeURIComponent(i.split("/").pop()??"file");t.push({type:n[1],url:i,fileName:s})}const r=e.replace(bk,"").trim();return{attachments:t,text:r}}function AQ(e,t){const n=t.filter(i=>i.status==="done"&&i.url);return n.length===0?e:n.map(i=>`[attachment:${i.mimeType.startsWith("image/")?"image":"file"}:${i.url}]`).join(`
|
|
504
504
|
`)+`
|
|
505
505
|
`+e}const LQ=/\[skill:(.+?):(\/[^\]]+)\]/g;function jQ(e){const t=[],n=e.replace(LQ,(r,i)=>(t.push(i),""));return{skills:t,text:t.length>0?n.trim():e}}function DQ({text:e,senderDisplayName:t,rewindTarget:n}){const r=gR(e),{attachments:i,text:s}=MQ(r),{skills:o,text:a}=jQ(s),{commandName:l,body:c}=yp(a),u=c.length>0;return u||i.length>0||!!l||o.length>0?(l||o.length>0)&&!u&&i.length===0?h.jsxs("div",{className:"flex min-w-0 max-w-full justify-end gap-1.5 py-2 mt-2","data-testid":"msg-line-user",children:[o.map((f,p)=>h.jsxs("span",{"data-testid":"user-skill-chip",className:"inline-flex items-center rounded-md bg-bg-200/60 px-2 py-0.5 text-[11px] font-mono text-text-300",children:["/",f]},`${f}-${p}`)),l?h.jsx("span",{className:"inline-flex items-center rounded-md bg-bg-200/60 px-2 py-0.5 text-[11px] font-mono text-text-300",children:l}):null]}):h.jsxs("div",{className:"group flex min-w-0 max-w-full flex-col items-end py-2 mt-2","data-testid":"msg-line-user",children:[h.jsxs("div",{className:"min-w-0 max-w-[85%] rounded-2xl rounded-br-sm bg-accent px-3.5 py-2 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:[i.length>0?h.jsx(OQ,{attachments:i}):null,o.length>0?h.jsx("div",{className:fe("flex flex-wrap gap-1.5",(u||l)&&"mb-1.5"),children:o.map((f,p)=>h.jsxs("span",{"data-testid":"user-skill-chip",className:"inline-flex items-center rounded-md bg-white/15 px-2 py-0.5 text-[11px] font-mono text-white/90",children:["/",f]},`${f}-${p}`))}):null,l?h.jsx("div",{className:fe("flex",u&&"mb-1.5"),children:h.jsx("span",{"data-testid":"user-command-chip",className:"inline-flex items-center rounded-md bg-white/15 px-2 py-0.5 text-[11px] font-mono text-white/90",children:l})}):null,u?h.jsx("div",{className:"text-[14px] text-white font-medium leading-relaxed",children:c}):null]}),t?h.jsx("div",{"data-testid":"user-msg-sender-label",className:"mt-1 text-[11px] text-text-400",children:t}):null,n?h.jsxs("button",{type:"button","data-testid":"user-msg-rewind","aria-label":"rewind to this message",title:"回退到这条消息(会撤销之后 CC 的文件编辑)",onClick:()=>n.onRewind(n.userMessageId),className:"mt-1 inline-flex items-center gap-1 h-6 px-1.5 rounded-md text-[11px] text-text-400 hover:bg-text-100/5 hover:text-text-200 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:[h.jsx(zT,{className:"w-3 h-3",strokeWidth:2}),h.jsx("span",{children:"Rewind"})]}):null]}):null}function OQ({attachments:e}){return h.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5","data-testid":"user-attachment-row",children:e.map(t=>h.jsx(BQ,{attachment:t},t.url))})}function BQ({attachment:e}){return e.type==="image"?h.jsx("img",{src:e.url,alt:e.fileName,"data-testid":"user-attachment-image",className:"h-16 w-16 rounded object-cover shrink-0 border border-bg-300/50"}):h.jsxs("div",{"data-testid":"user-attachment-file",className:"flex items-center gap-1.5 rounded-md border border-bg-300 bg-bg-100/60 px-2 py-1 text-[12px] text-text-200",children:[h.jsx(Ro,{className:"h-3.5 w-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"max-w-[140px] truncate",children:e.fileName})]})}const zQ={"task-notification":"子任务通知","slash-command":"斜杠命令","local-command":"本地命令输出","system-reminder":"系统提醒","skill-hint":"Skill 注入","meta-text":"系统消息","attachment-skills":"技能列表","attachment-deferred-tools":"Deferred 工具变更"},$Q={"task-notification":Cw,"slash-command":_$,"local-command":BT,"system-reminder":Cw,"skill-hint":o0,"meta-text":jT,"attachment-skills":o0,"attachment-deferred-tools":s$};function FQ({metaKind:e,text:t}){const[n,r]=g.useState(!1),i=$Q[e];if(e==="slash-command"){const{commandName:o,commandMessage:a,commandArgs:l,body:c}=yp(t),u=o??(a?`/${a}`:null),d=!!(l&&l.length>0),f=c.length>0;return!u&&!d&&!f?null:h.jsxs("div",{"data-testid":"msg-line-user-meta","data-meta-kind":e,className:"flex min-w-0 max-w-full flex-col items-end gap-0.5 py-1",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 max-w-full",children:[u?h.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-md bg-bg-200/60 px-2 py-0.5 text-[11px] font-mono text-text-300 shrink-0",children:[h.jsx(i,{className:"w-3 h-3 opacity-70"}),u]}):null,d?h.jsx("span",{"data-testid":"user-meta-command-args",className:"min-w-0 text-[12px] text-text-200 whitespace-pre-wrap break-words max-w-[70ch] [overflow-wrap:anywhere]",children:l}):null]}),f?h.jsx("span",{className:"ml-2 max-w-[60%] truncate text-[11px] text-text-400",children:c}):null]})}const s=t.replace(/\s+/g," ").trim().slice(0,80);return h.jsxs("div",{"data-testid":"msg-line-user-meta","data-meta-kind":e,className:"flex min-w-0 max-w-full flex-col items-start gap-1 py-1",children:[h.jsxs("button",{type:"button","aria-expanded":n,onClick:()=>r(o=>!o),className:fe("group inline-flex items-center gap-1.5 rounded-md border border-bg-200/60 bg-bg-100/40","px-2 py-1 text-[11px] text-text-400 hover:bg-bg-200/40 transition-colors max-w-full"),children:[h.jsx(i,{className:"w-3 h-3 opacity-70 shrink-0"}),h.jsx("span",{className:"font-medium shrink-0",children:zQ[e]}),h.jsx("span",{className:"truncate text-text-400/80 max-w-[60ch]",children:s}),n?h.jsx(ir,{className:"w-3 h-3 opacity-60 shrink-0"}):h.jsx(Un,{className:"w-3 h-3 opacity-60 shrink-0"})]}),n?h.jsx("pre",{"data-testid":"user-meta-body",className:"w-full max-w-full whitespace-pre-wrap break-words text-[11px] text-text-400 bg-bg-50/60 rounded-md p-2 border border-bg-200/60 [overflow-wrap:anywhere]",children:t}):null]})}function HQ({text:e,metaSource:t}){return t==="owner"?h.jsx("div",{className:"flex min-w-0 max-w-full flex-col items-start py-1.5","data-testid":"msg-line-owner-meta",children:h.jsxs("div",{className:fe("inline-flex min-w-0 max-w-[85%] items-start gap-2 rounded-md","border-l-[3px] border-accent bg-accent-dim px-3 py-2"),children:[h.jsx(Wz,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-accent","aria-label":"补充信息"}),h.jsx("span",{className:"min-w-0 text-[12px] leading-relaxed text-text-100 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:e})]})}):h.jsxs("div",{className:"flex min-w-0 max-w-full items-start gap-1.5 py-1 text-[11px] text-text-400","data-testid":"msg-line-cc-meta",children:[h.jsx(jT,{className:"mt-0.5 h-3 w-3 shrink-0"}),h.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:e})]})}function zr(e,t){const r=new RegExp(`<${t}\\b[^>]*>([\\s\\S]*?)</${t}>`,"i").exec(e);if(!r)return;const i=r[1].trim();return i||void 0}function Zm(e,t){const r=new RegExp(`${t}\\s*=\\s*"([^"]+)"`,"i").exec(e);if(!r)return;const i=Number(r[1]);return Number.isFinite(i)?i:void 0}function NM(e){var i,s,o;const t={};if(!e)return t;t.taskId=zr(e,"task-id"),t.toolUseId=zr(e,"tool-use-id"),t.outputFile=zr(e,"output-file"),t.status=zr(e,"status"),t.summary=zr(e,"summary"),t.result=zr(e,"result");const n=zr(e,"usage");if(n){const a=(i=/<total_tokens>\s*(\d+)\s*<\/total_tokens>/i.exec(n))==null?void 0:i[1],l=(s=/<tool_uses>\s*(\d+)\s*<\/tool_uses>/i.exec(n))==null?void 0:s[1],c=(o=/<duration_ms>\s*(\d+)\s*<\/duration_ms>/i.exec(n))==null?void 0:o[1];a&&(t.totalTokens=Number(a)),l&&(t.toolUses=Number(l)),c&&(t.durationMs=Number(c))}const r=zr(e,"worktree");if(r)t.worktreePath=zr(r,"worktreePath"),t.worktreeBranch=zr(r,"worktreeBranch");else{const a=/<worktree\b([^>]*)\/>/i.exec(e);if(a){const l=a[1],c=/worktreePath\s*=\s*"([^"]+)"/i.exec(l),u=/worktreeBranch\s*=\s*"([^"]+)"/i.exec(l);c&&(t.worktreePath=c[1]),u&&(t.worktreeBranch=u[1])}}if(t.totalTokens===void 0&&t.toolUses===void 0&&t.durationMs===void 0){const a=Zm(e,"total_tokens"),l=Zm(e,"tool_uses"),c=Zm(e,"duration_ms");a!==void 0&&(t.totalTokens=a),l!==void 0&&(t.toolUses=l),c!==void 0&&(t.durationMs=c)}return t}function UQ(e){if(!e||!Number.isFinite(e))return null;if(e<1e3)return`${e}ms`;const t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;const n=Math.floor(t/60),r=Math.round(t-n*60);return`${n}m${r.toString().padStart(2,"0")}s`}function WQ({text:e,taskId:t,parentToolUseId:n}){const r=g.useMemo(()=>NM(e),[e]),[i,s]=g.useState(!1),o=t??r.taskId,a=n??r.toolUseId,l=r.status==="failed"?h.jsx(Ls,{className:"w-3.5 h-3.5 text-error"}):r.status==="completed"?h.jsx(ep,{className:"w-3.5 h-3.5 text-success"}):h.jsx(Jf,{className:"w-3.5 h-3.5 text-text-400"}),c=r.status??"unknown",u=UQ(r.durationMs);return h.jsxs("div",{"data-testid":"msg-line-agent-notification","data-task-id":o??"","data-parent-tool-use-id":a??"",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/40",children:[h.jsxs("button",{type:"button","aria-expanded":i,onClick:()=>s(d=>!d),className:fe("flex w-full min-w-0 items-start gap-2 px-2.5 py-1.5 text-left text-[12px]","hover:bg-bg-200/40 rounded-md transition-colors"),children:[h.jsx("span",{className:"mt-[2px] shrink-0",children:l}),h.jsxs("span",{className:"flex-1 min-w-0",children:[h.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[h.jsx("span",{className:"font-medium text-text-200",children:"子任务"}),h.jsx("span",{className:"text-text-400 text-[11px] font-mono",children:o?o.slice(0,12):"未知"}),h.jsx("span",{className:"text-text-400 text-[11px] uppercase tracking-wide",children:c}),u?h.jsxs("span",{className:"text-text-400 text-[11px] tabular-nums",children:["· ",u]}):null,r.totalTokens?h.jsxs("span",{className:"text-text-400 text-[11px] tabular-nums",children:["· ",r.totalTokens," tok"]}):null,r.toolUses?h.jsxs("span",{className:"text-text-400 text-[11px] tabular-nums",children:["· ",r.toolUses," tools"]}):null]}),r.summary?h.jsx("span",{className:"block truncate text-text-300 text-[12px] mt-0.5",children:r.summary}):null]}),i?h.jsx(ir,{className:"w-3.5 h-3.5 mt-[3px] text-text-400 shrink-0"}):h.jsx(Un,{className:"w-3.5 h-3.5 mt-[3px] text-text-400 shrink-0"})]}),i?h.jsxs("div",{"data-testid":"agent-notification-body",className:"min-w-0 border-t border-bg-200/60 px-3 py-2 text-[12px] text-text-300 space-y-2",children:[r.worktreePath||r.worktreeBranch?h.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-400",children:[h.jsx(Lx,{className:"w-3 h-3"}),r.worktreeBranch?h.jsx("span",{className:"font-mono",children:r.worktreeBranch}):null,r.worktreePath?h.jsx("span",{className:"truncate font-mono",children:r.worktreePath}):null]}):null,r.outputFile?h.jsxs("div",{className:"text-[11px] text-text-400",children:[h.jsx("span",{children:"输出文件:"}),h.jsx("span",{className:"font-mono",children:r.outputFile})]}):null,a?h.jsxs("div",{className:"text-[11px] text-text-400",children:[h.jsx("span",{children:"父工具调用:"}),h.jsx("span",{className:"font-mono",children:a})]}):null,r.result?h.jsx("div",{"data-testid":"agent-notification-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(eu,{remarkPlugins:[nu],components:So,children:r.result})}):h.jsx("div",{className:"text-[11px] text-text-400 italic",children:"无详细结果"})]}):null]})}const TM=g.createContext(null);function VQ({children:e}){const[t,n]=g.useState({agentId:null}),r=g.useCallback((o,a)=>{n({agentId:o,agentType:a})},[]),i=g.useCallback(()=>{n(o=>({agentId:null,agentType:o.agentType}))},[]),s=g.useMemo(()=>({state:t,open:r,close:i}),[t,r,i]);return h.jsx(TM.Provider,{value:s,children:e})}function PM(){return g.useContext(TM)}function qQ(e){if(e==null)return null;if(typeof e=="string")return e;if(Array.isArray(e)){const t=[];for(const n of e)if(n&&typeof n=="object"){const r=n;r.type==="text"&&typeof r.text=="string"&&t.push(r.text)}else typeof n=="string"&&t.push(n);return t.length?t.join(`
|
|
506
506
|
`):null}if(typeof e=="object"){const t=e;if(typeof t.text=="string")return t.text}return null}function wk(e){if(!e||!Number.isFinite(e))return null;if(e<1e3)return`${e}ms`;const t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;const n=Math.floor(t/60),r=Math.round(t-n*60);return`${n}m${r.toString().padStart(2,"0")}s`}function KQ(e){return!e||!Number.isFinite(e)?null:e<1e3?`${e} tok`:e<1e4?`${(e/1e3).toFixed(1)}k tok`:`${Math.round(e/1e3)}k tok`}const GQ={readCount:"read",searchCount:"search",bashCount:"bash",editFileCount:"edit",linesAdded:"+lines",linesRemoved:"-lines",otherToolCount:"other"};function XQ(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e)){if(!r||r<=0)continue;const i=GQ[n]??n;t.push(`${i}:${r}`)}return t}function YQ({description:e,input:t,output:n,error:r,pending:i,notifications:s,toolResultExtra:o,progress:a}){const[l,c]=g.useState(!1),u=PM(),d=g.useMemo(()=>{if(!t||typeof t!="object")return null;const T=t;return typeof T.prompt=="string"?T.prompt:null},[t]),f=(o==null?void 0:o.prompt)??d,p=g.useMemo(()=>qQ(n),[n]),m=o==null?void 0:o.stats,v=a==null?void 0:a.stats,b=wk((m==null?void 0:m.durationMs)??(v==null?void 0:v.durationMs)),_=KQ((m==null?void 0:m.tokens)??(v==null?void 0:v.tokens)),x=XQ(m==null?void 0:m.toolStats),y=i&&(a!=null&&a.lastToolName)?`now:${a.lastToolName}`:null,w=!!(o!=null&&o.agentType||b||_||x.length>0||y),k=(o==null?void 0:o.agentId)??(a==null?void 0:a.agentId),C=g.useMemo(()=>s.map(T=>({taskId:T.taskId,text:T.text,parsed:NM(T.text)})),[s]),N=r?h.jsx(Ls,{className:"w-3.5 h-3.5 text-error"}):i?h.jsx(In,{className:"w-3.5 h-3.5 text-blue-400 animate-spin"}):h.jsx(ep,{className:"w-3.5 h-3.5 text-green-500"});return h.jsxs("div",{"data-testid":"msg-line-agent-call","data-pending":i?"true":"false","data-has-error":r?"true":"false","data-notification-count":s.length,"data-has-stats":w?"true":"false","data-agent-id":k??"",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/30",children:[h.jsxs("button",{type:"button","aria-expanded":l,onClick:()=>c(T=>!T),className:fe("flex w-full min-w-0 items-center gap-2 px-2.5 py-1.5 text-left text-[13px]","hover:bg-bg-200/40 rounded-md transition-colors"),children:[h.jsx("span",{className:"w-5 h-5 flex items-center justify-center text-[10px] rounded bg-violet-500/10 text-violet-500 shrink-0","aria-hidden":!0,children:h.jsx(I$,{className:"w-3 h-3"})}),h.jsx("span",{className:"shrink-0",children:N}),h.jsx("span",{className:"flex-1 min-w-0 truncate font-medium text-text-200",children:e}),w?null:s.length>0?h.jsxs("span",{className:"text-[11px] text-text-400 tabular-nums shrink-0",children:[s.length," 次通知"]}):null,k&&(u!=null&&u.open)?h.jsx("span",{role:"button",tabIndex:0,"data-testid":"open-subagent-btn-header","data-agent-id":k,"aria-label":"打开子 agent 对话",onClick:T=>{T.stopPropagation(),u.open(k,o==null?void 0:o.agentType)},onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.stopPropagation(),T.preventDefault(),u.open(k,o==null?void 0:o.agentType))},className:"shrink-0 inline-flex items-center justify-center w-3.5 h-3.5 text-text-400 hover:text-text-200",children:h.jsx(qc,{className:"w-3.5 h-3.5"})}):null,l?h.jsx(ir,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(Un,{className:"w-3.5 h-3.5 text-text-400 shrink-0"})]}),i&&(a!=null&&a.description)?h.jsx("div",{"data-testid":"agent-call-progress-desc",className:"px-3 pt-0 pb-1 text-[12px] text-text-300 truncate",children:a.description}):null,w?h.jsxs("div",{"data-testid":"agent-call-stats",className:"flex items-center gap-1.5 flex-wrap px-3 pb-1.5 pt-0 text-[11px] text-text-400",children:[o!=null&&o.agentType?h.jsx("span",{"data-testid":"agent-call-stats-type",className:"inline-flex items-center rounded-sm bg-violet-500/10 px-1.5 py-0.5 text-violet-400 font-medium",children:o.agentType}):null,b?h.jsx("span",{className:"tabular-nums",children:b}):null,_?h.jsx("span",{className:"tabular-nums",children:_}):null,y?h.jsx("span",{"data-testid":"agent-call-stats-now",className:"font-mono tabular-nums text-blue-400",children:y}):null,x.map(T=>h.jsx("span",{className:"font-mono tabular-nums text-text-400/80",children:T},T)),s.length>0?h.jsxs("span",{className:"tabular-nums text-text-400/70",children:["· ",s.length," 次通知"]}):null]}):null,l?h.jsxs("div",{"data-testid":"agent-call-body",className:"min-w-0 border-t border-bg-200/60 px-3 py-2 space-y-3",children:[r?h.jsx("div",{className:"text-[12px] text-error whitespace-pre-wrap",children:r}):null,C.map((T,B)=>{const P=T.parsed,A=wk(P.durationMs);return h.jsxs("div",{"data-testid":"agent-call-notification","data-task-id":T.taskId??"",className:"min-w-0 rounded-md border border-bg-200/60 bg-bg-0/40 p-2 space-y-1.5",children:[h.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-400 flex-wrap",children:[h.jsx("span",{className:"font-mono",children:(T.taskId??P.taskId??"未知").slice(0,12)}),h.jsx("span",{className:"uppercase tracking-wide",children:P.status??"unknown"}),A?h.jsxs("span",{className:"tabular-nums",children:["· ",A]}):null,P.totalTokens?h.jsxs("span",{className:"tabular-nums",children:["· ",P.totalTokens," tok"]}):null,P.toolUses?h.jsxs("span",{className:"tabular-nums",children:["· ",P.toolUses," tools"]}):null,P.worktreeBranch?h.jsxs("span",{className:"font-mono",children:["· ",P.worktreeBranch]}):null]}),P.summary?h.jsx("div",{className:"text-[12px] text-text-300",children:P.summary}):null,P.result?h.jsx("div",{"data-testid":"agent-call-notification-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(eu,{remarkPlugins:[nu],components:So,children:P.result})}):null]},`${T.taskId??"n"}-${B}`)}),f?h.jsxs("div",{"data-testid":"agent-call-prompt-block",className:"min-w-0 space-y-1",children:[h.jsx("div",{className:"text-[11px] text-text-400 font-medium",children:"任务指令"}),h.jsx("pre",{"data-testid":"agent-call-prompt",className:"max-w-full whitespace-pre-wrap break-words text-[11px] text-text-300 bg-bg-50/60 rounded p-2 border border-bg-200/60 max-h-64 overflow-auto [overflow-wrap:anywhere]",children:f})]}):null,p?h.jsxs("div",{"data-testid":"agent-call-result-block",className:"min-w-0 space-y-1",children:[h.jsx("div",{className:"text-[11px] text-text-400 font-medium",children:"子 agent 报告"}),h.jsx("div",{"data-testid":"agent-call-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(eu,{remarkPlugins:[nu],components:So,children:p})})]}):null,!p&&C.length===0&&!r&&!f?h.jsx("div",{className:"text-[11px] text-text-400 italic",children:"无详细信息"}):null,k&&(u!=null&&u.open)?h.jsx("div",{className:"flex justify-end",children:h.jsxs("button",{type:"button","data-testid":"open-subagent-btn","data-agent-id":k,onClick:()=>u.open(k,o==null?void 0:o.agentType),className:fe("inline-flex items-center gap-1 rounded-md border border-bg-200/60","bg-bg-100/40 hover:bg-bg-200/40 transition-colors","px-2 py-1 text-[11px] text-text-300"),children:[h.jsx(qc,{className:"w-3 h-3"}),h.jsx("span",{children:"打开子 agent 对话"})]})}):null]}):null]})}function IM({title:e,items:t,live:n,progressColor:r="bg-green-500",listKind:i,children:s}){const[o,a]=g.useState(!!n),l=t.length,c=t.filter(d=>d.status==="completed").length,u=l>0?Math.round(c/l*100):0;return h.jsxs("div",{"data-testid":"msg-line-checklist","data-list-kind":i,className:"min-w-0 max-w-full py-1",children:[h.jsxs("button",{type:"button",onClick:()=>a(d=>!d),"aria-expanded":o,className:"flex items-center gap-2.5 w-full text-left rounded-md px-1.5 py-1 hover:bg-text-100/5 cursor-pointer",children:[o?h.jsx(ir,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(Un,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"text-[13px] font-medium text-text-200",children:e}),h.jsxs("span",{className:"text-[11px] text-text-400 tabular-nums",children:[c,"/",l]}),h.jsx("div",{className:"flex-1 max-w-[120px] h-1.5 rounded-full bg-text-100/10 overflow-hidden",children:h.jsx("div",{className:fe("h-full rounded-full transition-all duration-300",r),style:{width:`${u}%`}})})]}),o?h.jsxs("div",{"data-testid":"checklist-body",className:"ml-6 mt-0.5",children:[h.jsx("div",{className:"space-y-px",children:t.map((d,f)=>h.jsxs("div",{className:"flex min-w-0 items-start gap-2 py-0.5 px-1",children:[h.jsx("span",{className:"w-4 h-4 mt-0.5 flex items-center justify-center shrink-0",children:d.status==="completed"?h.jsx(ul,{className:"w-3.5 h-3.5 text-green-500"}):d.status==="in_progress"&&n?h.jsx(In,{className:"w-3.5 h-3.5 text-blue-400 animate-spin"}):h.jsx("span",{className:"w-2 h-2 rounded-full border border-text-400/40"})}),h.jsx("span",{className:fe("min-w-0 text-[13px] leading-snug break-words [overflow-wrap:anywhere]",d.status==="completed"?"text-text-400 line-through":"text-text-200"),children:d.status==="in_progress"&&d.activeForm?d.activeForm:d.content})]},`${f}-${d.content}`))}),s]}):null]})}function QQ({todos:e,live:t}){return h.jsx(IM,{title:"Tasks",items:e,live:t,progressColor:"bg-green-500",listKind:"todo"})}function ZQ({tasks:e,live:t}){return h.jsx(IM,{title:"Plan",items:e,live:t,progressColor:"bg-blue-500",listKind:"plan"})}function JQ(e){if(!e||!Number.isFinite(e))return null;const t=Date.now()-e;if(t<0)return null;const n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);if(i<24)return`${i}h ago`;const s=Math.floor(i/24);if(s<7)return`${s}d ago`;const o=Math.floor(s/7);return o<5?`${o}w ago`:new Date(e).toISOString().slice(0,10)}function eZ(e){return(e.split("/").pop()??e)||e}function tZ({memories:e}){return!e||e.length===0?null:h.jsxs("div",{"data-testid":"memory-callout",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/30",children:[h.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5 text-[12px] text-text-300 border-b border-bg-200/60",children:[h.jsx(iz,{className:"w-3.5 h-3.5 text-amber-500 shrink-0"}),h.jsx("span",{className:"font-medium",children:"项目记忆"}),h.jsxs("span",{className:"text-text-400 tabular-nums",children:["· ",e.length]})]}),h.jsx("ul",{className:"divide-y divide-bg-200/40",children:e.map(t=>h.jsx(nZ,{memory:t},t.path))})]})}function nZ({memory:e}){const[t,n]=g.useState(!1),r=JQ(e.mtimeMs),i=e.content.replace(/\s+/g," ").trim().slice(0,80);return h.jsxs("li",{className:"px-2.5 py-1.5",children:[h.jsxs("button",{type:"button","aria-expanded":t,onClick:()=>n(s=>!s),className:fe("flex w-full items-center gap-1.5 text-left text-[12px]","hover:bg-bg-200/30 rounded-sm py-0.5"),children:[t?h.jsx(ir,{className:"w-3 h-3 text-text-400 shrink-0"}):h.jsx(Un,{className:"w-3 h-3 text-text-400 shrink-0"}),h.jsx("span",{className:"font-mono text-text-300 shrink-0 max-w-[20ch] truncate",title:e.path,children:eZ(e.path)}),h.jsx("span",{className:"flex-1 min-w-0 truncate text-text-400/80",children:i}),r?h.jsx("span",{className:"shrink-0 text-[11px] text-text-400 tabular-nums",children:r}):null]}),t?h.jsx("pre",{"data-testid":"memory-callout-body",className:"mt-1 max-w-full whitespace-pre-wrap break-words text-[12px] text-text-300 bg-bg-50/60 rounded-md p-2 border border-bg-200/60 [overflow-wrap:anywhere]",children:e.content}):null]})}function rZ({toolUseId:e,questions:t,onSubmit:n,onCancel:r,submittedAnswers:i}){const[s,o]=g.useState({}),[a,l]=g.useState({}),[c,u]=g.useState({}),[d,f]=g.useState(!1),[p,m]=g.useState(!1),v=i!==void 0&&Object.keys(i).length>0,b=v||p,_=!n&&!v,x=(C,N)=>{const T={labels:new Set,freeText:""};if(!v||!i)return T;const B=i[C];if(typeof B!="string")return T;const P=B.split(",").map(j=>j.trim()).filter(Boolean),A=new Set(N.map(j=>j.label)),I=new Set,R=[];for(const j of P)A.has(j)?I.add(j):R.push(j);return{labels:I,freeText:R.join(", ")}},y=g.useMemo(()=>t.every(C=>{if((c[C.question]??"").trim().length>0)return!0;if(C.multiSelect){const T=a[C.question];return!!(T&&T.size>0)}return typeof s[C.question]=="string"&&s[C.question].length>0}),[t,s,a,c]),w=async()=>{if(!y||d||b||_||!n)return;const C={};for(const N of t){const T=(c[N.question]??"").trim();if(N.multiSelect){const B=a[N.question],P=B?N.options.filter(A=>B.has(A.label)).map(A=>A.label):[];if(T.length>0&&P.push(T),P.length===0)continue;C[N.question]=P.join(", ")}else if(T.length>0)C[N.question]=T;else{const B=s[N.question];typeof B=="string"&&(C[N.question]=B)}}f(!0);try{await n(C),m(!0)}finally{f(!1)}},k=ku(()=>{w()});return h.jsxs("div",{"data-testid":"msg-line-question","data-tool-use-id":e,className:"min-w-0 max-w-full rounded-md border border-accent/40 bg-accent/5 px-3 py-2.5 text-[13px]",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 mb-2",children:[h.jsx(pz,{className:"w-4 h-4 text-accent shrink-0"}),h.jsx("span",{className:"min-w-0 font-medium text-text-100",children:"需要你的回答 / Need your answer"}),t.length>1?h.jsxs("span",{className:"ml-auto text-[12px] text-text-400","data-testid":"msg-line-question-count",children:[t.length," 个问题"]}):null]}),h.jsx("div",{className:"flex flex-col gap-3 mb-3",children:t.map((C,N)=>{const T=`q-${N}`,B=`${e}-${N}`,P=x(C.question,C.options),A=b||_,I=c[C.question]??"",R=v?P.freeText:p?(c[C.question]??"").trim():"";return h.jsxs("div",{"data-testid":"msg-line-question-item",children:[C.question?h.jsx("div",{className:"text-text-200 mb-1.5",children:C.question}):null,h.jsx("div",{className:"flex flex-col gap-1",children:C.options.map((j,z)=>{var D;const $=`${T}-${z}`,F=v?P.labels.has(j.label):C.multiSelect?!!((D=a[C.question])!=null&&D.has(j.label)):s[C.question]===j.label;return h.jsxs("label",{className:"flex min-w-0 items-start gap-2 cursor-pointer select-none py-1 px-2 rounded hover:bg-bg-100",children:[h.jsx("input",{type:C.multiSelect?"checkbox":"radio",name:B,value:j.label,checked:F,disabled:b||_,onChange:()=>{b||_||(C.multiSelect?l(O=>{const E=new Set(O[C.question]??[]);return E.has(j.label)?E.delete(j.label):E.add(j.label),{...O,[C.question]:E}}):o(O=>({...O,[C.question]:j.label})))},className:"mt-0.5","data-testid":"msg-line-question-option"}),h.jsxs("span",{className:"flex min-w-0 flex-col",children:[h.jsx("span",{className:"text-text-100 [overflow-wrap:anywhere]",children:j.label}),j.description?h.jsx("span",{className:"text-[12px] text-text-400 [overflow-wrap:anywhere]",children:j.description}):null]})]},$)})}),A?R.length>0?h.jsx("div",{className:"mt-2 rounded-lg border border-accent/15 bg-bg-100/60 px-3 py-2 text-[13px] leading-relaxed text-text-200 [overflow-wrap:anywhere]","data-testid":"msg-line-question-freetext-result",children:R}):null:h.jsx("textarea",{rows:3,value:I,placeholder:"或自行输入回答...",onChange:j=>{const z=j.target.value;u($=>({...$,[C.question]:z}))},...k,className:"mt-2 w-full resize-y rounded-lg border border-accent/20 bg-bg-000/60 px-3 py-2 text-[13px] leading-relaxed text-text-100 placeholder:text-text-400 outline-none transition-colors focus:border-accent/60 focus:bg-bg-000","data-testid":"msg-line-question-freetext"})]},T)})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(ni,{size:"sm",variant:"default",onClick:()=>void w(),disabled:!y||d||b||_,"data-testid":"msg-line-question-submit",children:b?"已提交 / Submitted":_?"已结束 / Ended":"提交 / Submit"}),r&&!b&&!_?h.jsx(ni,{size:"sm",variant:"ghost",onClick:()=>void r(),disabled:d,"data-testid":"msg-line-question-cancel",children:"跳过 / Skip"}):null]})]})}function iZ({toolUseId:e,questions:t,historicalAnswers:n,realtimeAnswers:r,onSubmit:i,onCancel:s}){const o=r??n,a=g.useCallback(async c=>{i&&await i(e,c)},[i,e]),l=g.useCallback(async()=>{s&&await s(e)},[s,e]);return h.jsx(rZ,{toolUseId:e,questions:t,onSubmit:i?a:void 0,...s?{onCancel:l}:{},submittedAnswers:o})}function sZ(){const e=new Map,t=(n,r)=>`${n}::${r}`;return{register(n,r,i){e.set(t(n,r),i)},resolve(n,r){return n?e.get(t(n,r))??null:null},reset(){e.clear()}}}const ml=sZ();function RM({lines:e,onPermissionRespond:t,onPermissionInterrupt:n,topSlot:r,onRewind:i,rewindableUserMessageIds:s,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v,onOpenFilePath:b,turnCollapse:_}){const x=g.useMemo(()=>$U(e),[e]),y=g.useMemo(()=>_?UU(x,_):null,[x,_]),w={onRewind:i,rewindableUserMessageIds:s,onPermissionRespond:t,onPermissionInterrupt:n,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v,onOpenFilePath:b};return h.jsxs("div",{"data-testid":"message-list",className:"flex w-full min-w-0 max-w-full flex-col gap-2 px-4 py-3",children:[r,y!==null?y.map(k=>oZ(k,w)):x.map(k=>lf(k,w))]})}function oZ(e,t){const n=`turn-${e.seq}`,r=e.query?lf(e.query,t):null,i=e.process.map(o=>aZ(o,t)),s=e.tail.map(o=>lf(o,t));return e.status==="running"?h.jsxs(Ze.Fragment,{children:[r,i,s]},n):h.jsxs(Ze.Fragment,{children:[r,h.jsx(tW,{status:e.status,...e.durationMs!==void 0?{durationMs:e.durationMs}:{},children:i}),s]},n)}function aZ(e,t){return e.kind==="tool-group"?h.jsx(ZU,{items:e.items,renderItemDetail:n=>lZ(n,t)},`tool-group-${e.seq}`):lf(e,t)}function lZ(e,t){const n=ml.resolve(e.toolKind,e.tool);return n?n.render({input:e.input,output:e.output,error:e.error,pending:e.pending,toolUseId:e.toolUseId,...t.fileSharingScope?{fileScope:t.fileSharingScope}:{},...t.onShareFile?{onShareFile:t.onShareFile}:{},...t.onOpenInTab?{onOpenInTab:t.onOpenInTab}:{},...t.onPreviewMarkdown?{onPreviewMarkdown:t.onPreviewMarkdown}:{}}):null}function lf(e,t){const{onRewind:n,rewindableUserMessageIds:r,onPermissionRespond:i,onPermissionInterrupt:s,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v,onOpenFilePath:b}=t,_=`${e.kind}-${e.seq}`;switch(e.kind){case"session-init":return null;case"user-text":{const x=typeof e.uuid=="string"?e.uuid:void 0,y=!!(n&&x&&(!r||r.has(x)));return h.jsx(DQ,{text:e.text,senderDisplayName:e.senderDisplayName,rewindTarget:y&&x&&n?{userMessageId:x,onRewind:n}:void 0},_)}case"user-meta":return h.jsx(FQ,{metaKind:e.metaKind,text:e.text},_);case"meta-text":return h.jsx(HQ,{text:e.text,metaSource:e.metaSource},_);case"agent-notification":return h.jsx(WQ,{text:e.text,taskId:e.taskId,parentToolUseId:e.parentToolUseId},_);case"assistant-text":{const x=typeof e.uuid=="string"?e.uuid:void 0,y=x&&(o||a)?{messageUuid:x,onFork:o,onQuickAsk:a}:void 0;return h.jsx(rQ,{text:iW(e.text),forkTarget:y,...b?{onOpenFilePath:b}:{}},_)}case"assistant-thinking":return h.jsx(iQ,{text:e.text},_);case"permission-inline":return h.jsx(IQ,{tool:e.tool,input:e.input,onRespond:i??(()=>{}),onInterrupt:s},_);case"error":return h.jsx(RQ,{message:e.message},_);case"turn-end":return null;case"merged-tool":return cZ(e,_,{fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v});case"merged-agent":return h.jsx(YQ,{description:e.description,input:e.input,output:e.output,error:e.error,pending:e.pending,notifications:e.notifications,toolResultExtra:e.toolResultExtra,progress:e.progress},_);case"plan-card":return h.jsx(ZQ,{tasks:e.tasks},_);case"todo-checklist":return h.jsx(QQ,{todos:e.todos},_);case"memory-callout":return h.jsx(tZ,{memories:e.memories},_);case"question-card":{const x=d===void 0||d.has(e.toolUseId);return h.jsx(iZ,{toolUseId:e.toolUseId,questions:e.questions,historicalAnswers:e.submittedAnswers,realtimeAnswers:l==null?void 0:l[e.toolUseId],onSubmit:x?c:void 0,...x&&u?{onCancel:u}:{}},_)}default:return null}}function cZ(e,t,n){const r=ml.resolve(e.toolKind,e.tool),i=r?r.render({input:e.input,output:e.output,error:e.error,pending:e.pending,toolUseId:e.toolUseId,...n.fileSharingScope?{fileScope:n.fileSharingScope}:{},...n.onShareFile?{onShareFile:n.onShareFile}:{},...n.onOpenInTab?{onOpenInTab:n.onOpenInTab}:{},...n.onPreviewMarkdown?{onPreviewMarkdown:n.onPreviewMarkdown}:{}}):null;return h.jsx(Ze.Fragment,{children:i??h.jsx(CM,{tool:e.tool,input:e.input,output:e.output,error:e.error,pending:e.pending,...n.fileSharingScope?{fileScope:n.fileSharingScope}:{},...n.onShareFile?{onShareFile:n.onShareFile}:{},...n.onOpenInTab?{onOpenInTab:n.onOpenInTab}:{},...n.onPreviewMarkdown?{onPreviewMarkdown:n.onPreviewMarkdown}:{}})},t)}const uZ={builtin:"Commands",global:"Global",project:"Project",plugin:"Plugin"},Sk={builtin:0,global:1,project:2,plugin:3};function dZ({query:e,skills:t,activeIndex:n,onActiveIndexChange:r,onSelect:i,onEmpty:s}){const o=g.useRef(null),a=g.useMemo(()=>MM(t,e),[t,e]),l=g.useMemo(()=>{const c=new Set;let u=null;for(let d=0;d<a.length;d++)a[d].source!==u&&(c.add(d),u=a[d].source);return c},[a]);return g.useEffect(()=>{a.length===0&&(s==null||s())},[a.length,s]),g.useEffect(()=>{var c;try{(c=o.current)==null||c.scrollIntoView({block:"nearest"})}catch{}},[n]),a.length===0?null:h.jsx("div",{"data-testid":"cc-skill-selector",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 max-h-[320px] overflow-y-auto rounded-2xl border border-bg-300 bg-bg-50 shadow-lg",children:a.map((c,u)=>{const d=u===n,f=l.has(u);return h.jsxs(Ze.Fragment,{children:[f?h.jsx("div",{className:"sticky top-0 z-10 bg-bg-50/95 backdrop-blur-sm px-4 py-2 text-[10px] font-semibold uppercase tracking-wider text-text-400/70 border-b border-bg-200/60",children:uZ[c.source]}):null,h.jsxs("div",{ref:d?o:void 0,"data-testid":`cc-skill-item-${c.name}`,onMouseEnter:()=>r(u),onClick:()=>i(c),className:fe("flex items-center gap-2.5 px-4 py-2 cursor-pointer transition-colors duration-75",d?"bg-[var(--text-100-dim)]":"hover:bg-bg-100/60"),children:[h.jsxs("code",{className:"text-[12px] font-mono font-semibold text-text-100 shrink-0",children:["/",c.name]}),c.description?h.jsx("span",{className:"text-[11px] text-text-300 truncate ml-auto",children:c.description}):null]})]},`${c.source}/${c.name}`)})})}function MM(e,t){const n=t.trim().toLowerCase(),r=n?e.filter(i=>i.name.toLowerCase().includes(n)||(i.description??"").toLowerCase().includes(n)):e.slice();return r.sort((i,s)=>(Sk[i.source]??9)-(Sk[s.source]??9)),r.slice(0,30)}const hZ=g.createContext(null);function fZ(){return g.useContext(hZ)}const pZ={builtin:"Built-in",global:"Global",project:"Project",policy:"Policy",plugin:"Plugin",persona:"My personas",contact:"People","remote-persona":"Remote personas"},kk={builtin:0,global:1,project:2,policy:3,plugin:4,persona:5,contact:6,"remote-persona":7};function cf(e){switch(e.kind){case"persona":return"persona";case"contact":return"contact";case"remote-persona":return"remote-persona";case"cc-agent":return e.agent.source}}function mZ(e){switch(e.kind){case"persona":return`persona/${e.persona.personaId}`;case"contact":return`contact/${e.contact.deviceId}`;case"remote-persona":return`remote/${e.deviceId}/${e.persona.personaId}`;case"cc-agent":return`${e.agent.source}/${e.agent.name}`}}function gZ(e){switch(e.kind){case"persona":return`${e.persona.personaId} ${e.persona.label}`.toLowerCase();case"contact":return`${e.contact.displayName} ${e.contact.deviceId}`.toLowerCase();case"remote-persona":return`${e.persona.personaId} ${e.persona.label}`.toLowerCase();case"cc-agent":{const t=e.agent;return`${t.name} ${t.description??""} ${t.whenToUse??""}`.toLowerCase()}}}function vZ(e){switch(e.kind){case"persona":return{displayName:`@persona/${e.persona.personaId}`,description:e.persona.label,testid:`cc-agent-item-persona-${e.persona.personaId}`};case"contact":return{displayName:`@${e.contact.displayName}`,description:e.contact.deviceId,testid:`cc-agent-item-contact-${e.contact.deviceId}`};case"remote-persona":return{displayName:`@persona/${e.persona.personaId}`,description:e.persona.label,testid:`cc-agent-item-remote-${e.deviceId}-${e.persona.personaId}`};case"cc-agent":return{displayName:`@${e.agent.name}`,description:e.agent.description,whenToUse:e.agent.whenToUse,plugin:e.agent.plugin,testid:`cc-agent-item-${e.agent.name}`}}}function AM(e,t){const n=t.trim().toLowerCase(),r=n?e.filter(i=>gZ(i).includes(n)):e.slice();return r.sort((i,s)=>(kk[cf(i)]??9)-(kk[cf(s)]??9)),r.slice(0,30)}function Ck({query:e,entries:t,activeIndex:n,onActiveIndexChange:r,onSelect:i,onEmpty:s}){const o=g.useRef(null),a=g.useMemo(()=>AM(t,e),[t,e]),l=g.useMemo(()=>{const c=new Set;let u=null;for(let d=0;d<a.length;d++){const f=cf(a[d]);f!==u&&(c.add(d),u=f)}return c},[a]);return g.useEffect(()=>{a.length===0&&(s==null||s())},[a.length,s]),g.useEffect(()=>{var c;try{(c=o.current)==null||c.scrollIntoView({block:"nearest"})}catch{}},[n]),a.length===0?null:h.jsx("div",{"data-testid":"cc-agent-selector",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 max-h-[320px] overflow-y-auto rounded-2xl border border-bg-300 bg-bg-50 shadow-lg",children:a.map((c,u)=>{const d=u===n,f=l.has(u),p=cf(c),m=vZ(c);return h.jsxs(Ze.Fragment,{children:[f?h.jsx("div",{"data-testid":`cc-agent-group-header-${p}`,"data-source":p,className:"sticky top-0 z-10 bg-bg-50/95 backdrop-blur-sm px-4 py-2 text-[10px] font-semibold uppercase tracking-wider text-text-400/70 border-b border-bg-200/60",children:pZ[p]}):null,h.jsxs("div",{ref:d?o:void 0,"data-testid":m.testid,onMouseEnter:()=>r(u),onClick:()=>i(c),className:fe("flex items-center gap-2.5 px-4 py-2 cursor-pointer transition-colors duration-75",d?"bg-[var(--text-100-dim)]":"hover:bg-bg-100/60"),children:[h.jsx("code",{className:"text-[12px] font-mono font-semibold text-text-100 shrink-0",children:m.displayName}),m.description?h.jsx("span",{className:"text-[11px] text-text-300 truncate ml-2",children:m.description}):null,m.whenToUse?h.jsx("span",{className:"text-[10px] text-text-400/70 italic truncate ml-auto",children:m.whenToUse}):null,m.plugin?h.jsx("span",{className:"text-[10px] text-text-400/70 ml-2 shrink-0",children:m.plugin}):null]})]},mZ(c))})})}function _Z({attachment:e,onRemove:t,onOpenPreview:n}){const r=e.mimeType.startsWith("image/"),i=e.status==="error",s=e.status==="uploading",o=r&&e.status==="done"&&!!e.previewUrl&&!!n;return h.jsxs("div",{"data-testid":`attachment-pill-${e.id}`,className:fe("group relative flex items-center gap-1.5 rounded-lg border px-2 py-1.5 text-[12px] transition-colors",i?"border-red-400/40 bg-red-500/5":"border-bg-300 bg-bg-100"),children:[r&&e.previewUrl?h.jsxs("div",{className:"relative h-7 w-7 shrink-0",children:[h.jsx("img",{src:e.previewUrl,alt:e.fileName,onClick:o?n:void 0,"data-testid":`attachment-thumb-${e.id}`,className:fe("h-7 w-7 rounded object-cover",o&&"cursor-pointer hover:opacity-80",s&&"opacity-40")}),s?h.jsx(In,{"data-testid":`attachment-spinner-${e.id}`,className:"absolute inset-0 m-auto h-3.5 w-3.5 animate-spin text-text-200"}):null]}):h.jsx("div",{className:"relative flex h-7 w-7 items-center justify-center rounded bg-text-100/5 shrink-0",children:s?h.jsx(In,{"data-testid":`attachment-spinner-${e.id}`,className:"h-3.5 w-3.5 animate-spin text-text-400"}):h.jsx(Ro,{className:"h-3.5 w-3.5 text-text-400"})}),h.jsx("span",{className:fe("max-w-[120px] truncate text-text-200",s&&"text-text-400"),title:e.error??e.fileName,children:e.fileName}),i?h.jsx(Ls,{className:"h-3 w-3 text-red-400 shrink-0"}):null,h.jsx("button",{type:"button",onClick:t,"data-testid":`attachment-remove-${e.id}`,className:"flex h-4 w-4 items-center justify-center rounded-full text-text-400 hover:text-text-100 hover:bg-text-100/10 transition-colors cursor-pointer shrink-0","aria-label":"remove",children:h.jsx(Dr,{className:"h-3 w-3"})})]})}function xZ({attachments:e,onRemove:t,onOpenPreview:n}){return e.length===0?null:h.jsx("div",{"data-testid":"attachment-row",className:"flex flex-wrap gap-1.5 mb-2 px-1",children:e.map(r=>h.jsx(_Z,{attachment:r,onRemove:()=>t(r.id),onOpenPreview:n?()=>n(r):void 0},r.id))})}class Yl extends Error{constructor(t,n,r){super(n),this.code=t,this.status=r,this.name="UploadAttachmentError"}}async function yZ(e){if(!e.httpBaseUrl)throw new Yl("TUNNEL_NOT_READY","daemon httpBaseUrl unavailable");if(!e.httpToken)throw new Yl("NO_AUTH","daemon httpToken unavailable");const t=new URLSearchParams({sessionId:e.sessionId,fileName:e.file.name,mimeType:e.file.type||"application/octet-stream"}),n=`${e.httpBaseUrl.replace(/\/$/,"")}/attachments/upload?${t.toString()}`;let r;try{r=await fetch(n,{method:"POST",headers:{Authorization:`Bearer ${e.httpToken}`,"Content-Type":e.file.type||"application/octet-stream"},body:e.file})}catch(i){throw new Yl("NETWORK_ERROR",i.message)}if(!r.ok){let i="UPLOAD_FAILED",s=`HTTP ${r.status}`;try{const o=await r.json();o.code&&(i=o.code),o.message&&(s=o.message)}catch{}throw new Yl(i,s,r.status)}return await r.json()}const Ek=25*1024*1024,bZ="image/*,.txt,.md,.markdown,.csv,.json,.log,.yaml,.yml,.html,.xml,.pdf",wZ=["image/","text/"],SZ=new Set(["application/json","application/xml","application/x-yaml","application/yaml","application/pdf"]),kZ=new Set(["txt","md","markdown","csv","json","log","yaml","yml","html","xml","pdf"]);function CZ(e){var r;const t=(e.type||"").toLowerCase();if(t&&wZ.some(i=>t.startsWith(i))||t&&SZ.has(t))return!0;const n=((r=e.name.split(".").pop())==null?void 0:r.toLowerCase())??"";return n.length>0&&kZ.has(n)}let EZ=0;const NZ=()=>`att-${++EZ}-${Date.now()}`;function TZ(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(typeof r.result=="string"?r.result:""),r.onerror=()=>n(r.error??new Error("read failed")),r.readAsDataURL(e)})}function PZ(e){const[t,n]=g.useState(e.initial??[]),r=g.useCallback(async o=>{const a=Array.from(o);if(a.length===0)return;const l=[],c=[],u=[];for(const d of a){const f={id:NZ(),fileName:d.name,mimeType:d.type||"application/octet-stream"};if(!CZ(d)){c.push({...f,url:null,status:"error",error:"不支持的文件类型"});continue}if(d.size>Ek){c.push({...f,url:null,status:"error",error:`超过 ${Math.round(Ek/1024/1024)}MB 上限`});continue}if(e.sessionId==null){u.push({id:f.id,file:d,mimeType:f.mimeType}),c.push({...f,url:null,status:"uploading"});continue}const p=f.mimeType.startsWith("image/")?URL.createObjectURL(d):void 0;c.push({...f,url:null,status:"uploading",...p?{previewUrl:p}:{}}),l.push({id:f.id,file:d})}n(d=>[...d,...c]);for(const d of u)try{const f=await TZ(d.file);n(p=>p.map(m=>m.id===d.id?{...m,url:f,status:"done",...d.mimeType.startsWith("image/")?{previewUrl:f}:{}}:m))}catch(f){n(p=>p.map(m=>m.id===d.id?{...m,status:"error",error:f.message??"read failed"}:m))}l.length!==0&&await Promise.all(l.map(async d=>{try{const f=await yZ({httpBaseUrl:e.httpBaseUrl,httpToken:e.httpToken,sessionId:e.sessionId,file:d.file});n(p=>p.map(m=>m.id===d.id?{...m,url:f.url,status:"done"}:m))}catch(f){const p=f instanceof Yl?f.code:"UPLOAD_FAILED",m=f.message??"upload failed";n(v=>v.map(b=>b.id===d.id?{...b,status:"error",error:`${p}: ${m}`}:b))}}))},[e.sessionId,e.httpBaseUrl,e.httpToken]),i=g.useCallback(o=>{n(a=>a.filter(l=>l.id!==o))},[]),s=g.useCallback(()=>{n([])},[]);return{attachments:t,setAttachments:n,addFiles:r,removeAttachment:i,clearAttachments:s}}const R0=new Map,IZ=[];function Nk(e){if(e)return R0.get(e)}function Tk(e,t){e&&(t.draft.length===0&&t.attachments.length===0?R0.delete(e):R0.set(e,t))}function RZ(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 MZ({api:e,cwd:t,sessionKey:n,onSend:r,disabled:i,onNewSession:s,onClearSession:o,tool:a,spawnableContacts:l=IZ,ensureRemotePersonas:c,remotePersonasByDeviceId:u}){const d=Nk(n),[f,p]=g.useState((d==null?void 0:d.draft)??""),[m,v]=g.useState(!1),b=g.useRef(null),_=g.useRef(!1),x=g.useCallback(()=>{_.current=!0},[]),y=g.useCallback(()=>{_.current=!1},[]),w=Zf(),{attachments:k,setAttachments:C,addFiles:N,removeAttachment:T,clearAttachments:B}=PZ({httpBaseUrl:w.httpBaseUrl,httpToken:w.httpToken,sessionId:n,initial:(d==null?void 0:d.attachments)??[]}),[P,A]=g.useState([]),[I,R]=g.useState(!1),[j,z]=g.useState(0),[$,F]=g.useState(!1),[D,O]=g.useState([]),[E,H]=g.useState(!1),[V,L]=g.useState(0),[ne,ae]=g.useState(!1),[G,ye]=g.useState([]),[Fe,ue]=g.useState(!1),[Ie,Re]=g.useState(null),[Ke,ve]=g.useState(!1),ze=g.useRef(null),fn=g.useMemo(()=>{const se=[];return s&&se.push({name:"new",source:"builtin",description:"在当前目录下新建会话"}),o&&n&&se.push({name:"clear",source:"builtin",description:"清除当前会话"}),se},[s,o,n]),it=g.useMemo(()=>[...fn,...P],[fn,P]),Rt=g.useMemo(()=>{const se=f.match(/^\/(\S*)$/);return se?se[1]:null},[f]),Gt=Rt!==null&&!$,Mt=g.useMemo(()=>Rt!==null?MM(it,Rt):[],[it,Rt]),bt=g.useMemo(()=>{const se=f.match(/^@(\S*)$/);return se?se[1]:null},[f]),Qe=bt!==null&&!ne,st=g.useMemo(()=>Ie?((u==null?void 0:u.get(Ie.deviceId))??[]).map(q=>({kind:"remote-persona",persona:q,deviceId:Ie.deviceId})):[...D.map(se=>({kind:"cc-agent",agent:se})),...G.map(se=>({kind:"persona",persona:se})),...l.map(se=>({kind:"contact",contact:se}))],[Ie,u,D,G,l]),wt=g.useMemo(()=>bt!==null?AM(st,bt):[],[st,bt]),pn=g.useRef(f);g.useEffect(()=>{f!==pn.current&&(F(!1),ae(!1),pn.current=f)},[f]);const on=g.useCallback(()=>{F(!0)},[]),U=g.useCallback(()=>{ae(!0)},[]),Z=g.useRef(f),_e=g.useRef(k);g.useEffect(()=>{Z.current=f},[f]),g.useEffect(()=>{_e.current=k},[k]);const ke=g.useRef(n);g.useEffect(()=>{const se=ke.current;if(se===n)return;Tk(se,{draft:Z.current,attachments:_e.current});const q=Nk(n);p((q==null?void 0:q.draft)??""),C((q==null?void 0:q.attachments)??[]),z(0),L(0),F(!1),ae(!1),Re(null),ze.current=null,ve(!1),queueMicrotask(()=>{q!=null&&q.draft?LM(b.current):Yo(b.current)}),ke.current=n},[n,C]),g.useEffect(()=>()=>{Tk(ke.current,{draft:Z.current,attachments:_e.current})},[]),g.useEffect(()=>{z(0)},[Rt]),g.useEffect(()=>{L(0)},[bt]),g.useEffect(()=>{bt===null&&Ie&&(Re(null),ze.current=null,ve(!1))},[bt,Ie]),g.useEffect(()=>{if(!Gt||I)return;if(!e){R(!0);return}let se=!1;return(async()=>{try{const q=await e.skillsList(t,a);se||(A(q.skills??[]),R(!0))}catch{se||R(!0)}})(),()=>{se=!0}},[Gt,I,e,t,a]),g.useEffect(()=>{if(!Qe||E)return;if(!e){H(!0);return}let se=!1;return(async()=>{try{const q=await e.agentsList(t,a);se||(O(q.agents??[]),H(!0))}catch{se||H(!0)}})(),()=>{se=!0}},[Qe,E,e,t,a]),g.useEffect(()=>{if(!Qe||Fe)return;if(!e){ue(!0);return}let se=!1;return(async()=>{try{const q=await e.personaList();se||(ye((q.personas??[]).map(we=>({personaId:we.personaId,label:we.label}))),ue(!0))}catch{se||ue(!0)}})(),()=>{se=!0}},[Qe,Fe,e]);const He=g.useCallback(se=>{switch(se.kind){case"persona":p(`@persona/${se.persona.personaId} `);break;case"cc-agent":p(`@"${se.agent.name} (agent)" `);break;case"contact":{const q=se.contact.deviceId;Re({deviceId:q,displayName:se.contact.displayName}),ze.current=q,ve(!0),Promise.resolve(c==null?void 0:c(q)).finally(()=>{ze.current===q&&ve(!1)}),p("@"),ae(!1),setTimeout(()=>{var we;return(we=b.current)==null?void 0:we.focus()},0);return}case"remote-persona":p(`@persona/${se.persona.personaId}@${se.deviceId} `),Re(null);break}ae(!1),setTimeout(()=>{var q;return(q=b.current)==null?void 0:q.focus()},0)},[c]),Tt=g.useCallback(()=>{Re(null),ze.current=null,ve(!1),p("@"),setTimeout(()=>{var se;return(se=b.current)==null?void 0:se.focus()},0)},[]),Xt=g.useCallback(se=>{if(se.source==="builtin"&&se.name==="new"&&s){p(""),B(),Yo(b.current),s(t);return}if(se.source==="builtin"&&se.name==="clear"&&o){p(""),B(),Yo(b.current),o();return}p(`/${se.name} `),setTimeout(()=>{var q;return(q=b.current)==null?void 0:q.focus()},0)},[s,t,B,o]),Yt=g.useCallback(async()=>{const se=f.trim(),q=k.filter(we=>we.status==="done");if(!(!se&&q.length===0)&&!(m||i)){if(se==="/new"&&s){v(!0);try{await s(t),p(""),B(),Yo(b.current)}finally{v(!1)}return}if(se==="/clear"&&o){v(!0);try{await o(),p(""),B(),Yo(b.current)}finally{v(!1)}return}v(!0);try{const we=a==="codex"?RZ(se,P):se,ht=AQ(we,k);await r(ht),p(""),B(),Yo(b.current)}finally{v(!1)}}},[f,k,m,i,r,s,t,B,o,a,P]);return{draft:f,setDraft:p,sending:m,textareaRef:b,isComposingRef:_,onCompositionStart:x,onCompositionEnd:y,attachments:k,addFiles:N,removeAttachment:T,skillSelectorVisible:Gt,filteredSkills:Mt,slashQuery:Rt??"",activeSkillIdx:j,setActiveSkillIdx:z,selectSkill:Xt,dismissSkillSelector:on,agentSelectorVisible:Qe,filteredAgents:wt,mentionQuery:bt,activeAgentIdx:V,setActiveAgentIdx:L,selectAgent:He,dismissAgentSelector:U,drilldown:Ie,drilldownLoading:Ke,exitDrilldown:Tt,doSend:Yt}}const AZ=120;function LM(e){e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,AZ)}px`)}function Yo(e){e&&(e.style.height="auto")}const LZ={spawnableContacts:[],ensureRemotePersonas:()=>Promise.resolve(),remotePersonasByDeviceId:new Map},jZ=g.createContext(LZ);function DZ(){return g.useContext(jZ)}function OZ({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{Pk(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(tp,{className:"h-3 w-3"}),r?"Copied":"Copy"]}),h.jsxs("button",{type:"button",onClick:()=>Pk(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(wz,{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(Dr,{className:"h-3 w-3"})})]})]})})}function Pk(e,t){const n=document.createElement("a");n.href=e,n.download=t||"image",n.click()}const Ik=1e3,BZ=5e3;function kd(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 zZ({meta:e,api:t,cwd:n,tool:r,onSend:i,sessionKey:s,disabled:o=!1,placeholder:a,className:l,awaitingUser:c=!1,onAbort:u,onNewSession:d,onClearSession:f,configSlot:p,aboveSlot:m}){const v=(e==null?void 0:e.streamInProgress)??!1,b=(e==null?void 0:e.contextPct)??null,_=b==null?"":b>=80?"text-red-400":b>=50?"text-amber-400":"text-text-500",x=g.useRef(null),y=DZ(),w=MZ({...t?{api:t}:{},cwd:n,...r?{tool:r}:{},sessionKey:s,onSend:i,disabled:o,...d?{onNewSession:d}:{},...f?{onClearSession:f}:{},spawnableContacts:y.spawnableContacts,ensureRemotePersonas:y.ensureRemotePersonas,remotePersonasByDeviceId:y.remotePersonasByDeviceId}),{draft:k,setDraft:C,sending:N,textareaRef:T,attachments:B,addFiles:P,removeAttachment:A,skillSelectorVisible:I,filteredSkills:R,slashQuery:j,activeSkillIdx:z,setActiveSkillIdx:$,selectSkill:F,dismissSkillSelector:D,agentSelectorVisible:O,filteredAgents:E,mentionQuery:H,activeAgentIdx:V,setActiveAgentIdx:L,selectAgent:ne,dismissAgentSelector:ae,drilldown:G,drilldownLoading:ye,exitDrilldown:Fe,doSend:ue}=w,Ie=fZ();g.useEffect(()=>{if(!Ie||Ie.signal===0||s===null||Ie.sessionId!==s)return;const{signal:q}=Ie;console.log("[chat-focus] 收到聚焦信号",{sessionKey:s,signal:q,delayMs:Ik,activeElement:kd(document.activeElement)});let we=null,ht=null,an=null;const _l=setTimeout(()=>{if(we=T.current,!we){console.warn("[chat-focus] textarea 已不在,放弃聚焦",{sessionKey:s,signal:q});return}we.focus(),console.log("[chat-focus] focus() 已执行",{sessionKey:s,signal:q,landed:document.activeElement===we,activeElement:kd(document.activeElement)}),ht=xl=>{const zo=kd(xl.relatedTarget);setTimeout(()=>{console.warn("[chat-focus] STOLEN 输入框失焦",{sessionKey:s,signal:q,relatedTarget:zo,activeElementAfterTick:kd(document.activeElement)})},0)},we.addEventListener("blur",ht,{once:!0}),an=setTimeout(()=>{we&&ht&&we.removeEventListener("blur",ht)},BZ)},Ik);return()=>{clearTimeout(_l),an&&clearTimeout(an),we&&ht&&we.removeEventListener("blur",ht)}},[Ie==null?void 0:Ie.signal]);const Re=!!t,Ke=N||o||v,ze=(k.trim().length>0||B.some(q=>q.status==="done"))&&!o&&!N&&!c,fn=a??(c?"Answer the question above first...":Ke?"Queue a message...":`Message ${zx(r)}...`),it=g.useRef(!1),Rt=g.useCallback(()=>{it.current=!0},[]),Gt=g.useCallback(()=>{it.current=!1},[]),Mt=g.useCallback(q=>{if(I&&R.length>0){if(q.key==="ArrowDown")return q.preventDefault(),$(z>=R.length-1?0:z+1),!0;if(q.key==="ArrowUp")return q.preventDefault(),$(z<=0?R.length-1:z-1),!0;if(q.key==="Tab"||q.key==="Enter"&&!q.shiftKey){q.preventDefault();const we=R[z];return we&&F(we),!0}if(q.key==="Escape")return q.preventDefault(),D(),!0}return!1},[I,R,z,$,F,D]),bt=g.useCallback(q=>{if(O&&E.length>0){if(q.key==="ArrowDown")return q.preventDefault(),L(V>=E.length-1?0:V+1),!0;if(q.key==="ArrowUp")return q.preventDefault(),L(V<=0?E.length-1:V-1),!0;if(q.key==="Tab"||q.key==="Enter"&&!q.shiftKey){q.preventDefault();const we=E[V];return we&&ne(we),!0}if(q.key==="Escape")return q.preventDefault(),G?Fe():ae(),!0}return!1},[O,E,V,L,ne,ae,G,Fe]),Qe=g.useCallback(q=>{const we=q.nativeEvent;q.key==="Enter"&&GI({compositionActive:it.current,nativeIsComposing:we.isComposing,keyCode:we.keyCode})||Mt(q)||bt(q)||XI({key:q.key,shiftKey:q.shiftKey,compositionActive:it.current,nativeIsComposing:we.isComposing,keyCode:we.keyCode})&&(q.preventDefault(),ze&&ue())},[Mt,bt,ze,ue]),st=g.useCallback(q=>{C(q.target.value),LM(q.target)},[C]),wt=g.useCallback(q=>{q.target.files&&P(q.target.files),q.target.value=""},[P]),pn=g.useCallback(q=>{if(!Re)return;const we=Array.from(q.clipboardData.items).map(ht=>ht.getAsFile()).filter(ht=>!!(ht&&ht.type.startsWith("image/")));we.length!==0&&(q.preventDefault(),P(we))},[P,Re]),[on,U]=g.useState(null),Z=g.useCallback(q=>{q.previewUrl&&U({url:q.previewUrl,name:q.fileName})},[]),[_e,ke]=g.useState(!1),He=g.useCallback(q=>{Re&&(q.preventDefault(),ke(!0))},[Re]),Tt=g.useCallback(()=>ke(!1),[]),Xt=g.useCallback(q=>{Re&&(q.preventDefault(),ke(!1),q.dataTransfer.files.length>0&&P(q.dataTransfer.files))},[P,Re]),Yt=v&&!c&&typeof u=="function",se=o||c;return h.jsxs("div",{"data-testid":"chat-input",className:fe("shrink-0 border-t border-bg-300/20 px-4 py-3",l),onDragOver:He,onDragLeave:Tt,onDrop:Xt,children:[h.jsxs("div",{className:"max-w-3xl mx-auto relative",children:[Re?h.jsx("input",{ref:x,type:"file",multiple:!0,accept:bZ,hidden:!0,onChange:wt,"data-testid":"chat-input-file"}):null,h.jsxs("div",{"data-testid":"chat-input-bare",className:fe("flex flex-col gap-2"),children:[c||N||v?h.jsxs("div",{"data-testid":"chat-input-status-bar",className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsxs("div",{className:"flex gap-1",children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"0ms"}}),h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"150ms"}}),h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"300ms"}})]}),h.jsx("span",{children:c?"Waiting for your answer":`${r==="codex"?"Codex":"Claude"} is working`})]}):null,I?h.jsx(dZ,{query:j,skills:R,activeIndex:z,onActiveIndexChange:$,onSelect:F}):null,O?G?!y.remotePersonasByDeviceId.has(G.deviceId)&&ye?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:`正在加载 @${G.displayName} 的 persona…`}):E.length>0?h.jsx(Ck,{query:H??"",entries:E,activeIndex:V,onActiveIndexChange:L,onSelect:ne}):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:`@${G.displayName} 暂无可派活的 persona(可能离线或未公开)`}):h.jsx(Ck,{query:H??"",entries:E,activeIndex:V,onActiveIndexChange:L,onSelect:ne}):null,B.length>0?h.jsx(xZ,{attachments:B,onRemove:A,onOpenPreview:Z}):null,m?h.jsx("div",{"data-testid":"chat-input-above-slot",className:"mx-2 -mb-3 rounded-t-xl border border-b-0 border-border bg-bg-0 px-3 pt-2 pb-4",children:m}):null,h.jsxs("div",{"data-testid":"bare-chat-input-frame",className:fe("relative flex flex-col gap-1 rounded-xl border border-border bg-bg-0 px-3 py-2 transition-colors duration-200",se?"opacity-60":null,_e?"border-accent/60 bg-accent/5":null),children:[h.jsx("textarea",{ref:T,"data-testid":"chat-input-textarea",value:k,onChange:st,onKeyDown:Qe,onCompositionStart:Rt,onCompositionEnd:Gt,onPaste:pn,placeholder:fn,disabled:se,readOnly:se,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:[Re?h.jsx("button",{type:"button",onClick:()=>{var q;return(q=x.current)==null?void 0:q.click()},disabled:Ke,"data-testid":"chat-input-attach","aria-label":"attach files",className:fe("flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors",Ke?"cursor-default text-text-400/50":"cursor-pointer text-text-400 hover:bg-text-100/5 hover:text-text-200"),children:h.jsx(Qz,{className:"h-4 w-4"})}):null,h.jsx("div",{className:"flex-1 min-w-0"}),b!=null?h.jsxs("span",{"data-testid":"chat-input-ctx",className:fe("shrink-0 text-[11px] tabular-nums",_),children:["ctx:",b,"%"]}):null,p,Yt?h.jsx("button",{type:"button",onClick:u,"data-testid":"chat-input-abort","aria-label":"interrupt",title:"中断当前轮次(不杀进程)",className:"h-8 w-8 rounded-full flex items-center justify-center border border-text-400/40 text-text-400 hover:bg-text-100/5 hover:text-text-100 transition-colors cursor-pointer",children:h.jsx(DT,{className:"w-3.5 h-3.5",strokeWidth:2.5})}):null,h.jsx("button",{type:"button",onClick:()=>{ze&&ue()},disabled:!ze,"data-testid":"chat-input-send","aria-label":"send",className:fe("h-8 w-8 rounded-full flex items-center justify-center transition-colors",ze?"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(JB,{className:"w-4 h-4",strokeWidth:2.5})})]})]})]})]}),on?h.jsx(OZ,{url:on.url,fileName:on.name,onClose:()=>U(null)}):null]})}function $Z(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function FZ({meta:e,tool:t,connState:n,variant:r="full",onOpenConfig:i,liveWorktreeRoot:s,ephemeral:o=!1,onPromote:a,className:l}){const c=s??e.cwd??"",d=!!e.sessionLabel&&e.sessionLabel!==e.sessionId?e.sessionLabel:$Z(c),f=c;return r==="quickask"?h.jsxs("div",{"data-testid":"chat-header","data-variant":"quickask",className:fe("flex items-center shrink-0 px-3 py-2 gap-2",l),children:[a?h.jsx("button",{type:"button","data-testid":"chat-header-promote","data-promoted":o?"false":"true",disabled:!o,onClick:a,title:o?"保留为正式会话":"已保留为正式会话",className:fe("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(oz,{className:fe("w-3.5 h-3.5",!o&&"fill-current")})}):null,h.jsx("span",{className:"font-semibold text-text-100 truncate text-[13px]","data-testid":"chat-header-worktree",title:f,children:d})]}):h.jsxs("div",{"data-testid":"chat-header","data-variant":"full",className:fe("relative flex items-center shrink-0 px-4 pr-[4.5rem] md:pr-4 py-2.5",l),children:[h.jsx("span",{className:"font-semibold text-text-100 truncate text-[13px]","data-testid":"chat-header-worktree",title:f,children:d}),h.jsx("div",{className:"absolute right-4 top-1/2 -translate-y-1/2 z-10 flex items-center gap-1",children:i?h.jsx("button",{type:"button","aria-label":"Session settings","data-testid":"chat-header-settings-mobile",onClick:i,title:"Session settings",className:"flex md:hidden h-7 w-7 items-center justify-center rounded-md bg-transparent text-text-300 transition-colors duration-150 hover:bg-bg-200 hover:text-text-100 cursor-pointer outline-none",children:h.jsx(LT,{className:"w-4 h-4"})}):null})]})}let HZ=null;function UZ(){return HZ}function Ql({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 Rk({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(Ql,{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(ul,{className:"w-3 h-3 shrink-0 text-accent"}):h.jsx(tp,{className:"w-3 h-3 shrink-0 text-text-400 opacity-0 group-hover:opacity-100 transition-opacity"})]})})}function Jm({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 hover:bg-text-100/5 cursor-pointer text-left",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]})}function WZ({session:e,meta:t,liveGitBranch:n,liveWorktreeRoot:r,personaName:i,onOpenPersona:s,onOpenFiles:o,cronActiveCount:a,onCronClick:l,onForceStop:c,viewerRole:u="owner",toolSessionIdLabel:d="tool session id",drill:f=null,onCollapse:p}){const m=n!==void 0?n:t.gitBranch??null,v=t.procAlive??!1,b=iP(e),_=b!=null&&e.originOwnerPrincipalId==null&&u!=="guest",[x,y]=g.useState(null),w=g.useRef(null);g.useEffect(()=>()=>{w.current&&clearTimeout(w.current)},[]);const k=async()=>{if(!_)return;const C=UZ();let N;try{C||(await navigator.clipboard.writeText(b),N="命令已复制")}catch{N="操作失败"}y(N),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>y(null),2500)};return h.jsxs("div",{"data-testid":"session-info-panel",className:"h-full min-w-0 border-l border-border bg-bg-100 flex flex-col",children:[h.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b border-border shrink-0",children:[f?h.jsx("button",{type:"button","data-testid":"session-info-back",onClick:f.onBack,"aria-label":"返回会话信息",className:"p-1 -ml-1 rounded text-text-400 hover:text-text-100 hover:bg-text-100/10",children:h.jsx(QB,{className:"w-4 h-4"})}):p?h.jsx("button",{type:"button","data-testid":"session-info-collapse",onClick:p,"aria-label":"collapse session info",title:"收起会话信息",className:"p-1 -ml-1 rounded text-text-400 hover:text-text-100 hover:bg-text-100/10",children:h.jsx(Sm,{className:"w-4 h-4"})}):h.jsx(Sm,{className:"w-4 h-4 text-text-300"}),h.jsx("span",{className:"flex-1 text-[13px] font-medium text-text-100 truncate",children:f?f.title:"会话信息"}),f&&p?h.jsx("button",{type:"button","data-testid":"session-info-collapse",onClick:p,"aria-label":"collapse session info",title:"收起会话信息",className:"p-1 rounded text-text-400 hover:text-text-100 hover:bg-text-100/10",children:h.jsx(Sm,{className:"w-4 h-4"})}):null]}),f?h.jsx("div",{"data-testid":"session-info-drill",className:"flex-1 min-h-0 overflow-y-auto",children:f.content}):h.jsxs("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:[m?h.jsx(Ql,{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(Lx,{className:"w-3 h-3 shrink-0 text-text-400"}),h.jsx("span",{className:"truncate",children:m})]})}):null,i&&s?h.jsx(Ql,{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($T,{className:"w-3 h-3"}),h.jsx("span",{className:"truncate",children:i})]})}):null,h.jsx(Ql,{label:"引擎",children:h.jsxs("span",{className:"inline-flex items-center gap-1.5","data-testid":"session-info-engine",children:[h.jsx(np,{tool:e.tool,className:fe("w-3.5 h-3.5 shrink-0",rp(e.tool))}),h.jsxs("span",{className:"truncate",children:[zx(e.tool),t.model?` · ${t.model}`:""]})]})}),h.jsx(Ql,{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(Rk,{label:"session id",value:e.sessionId,testid:"session-info-session-id"}),e.toolSessionId?h.jsx(Rk,{label:`${e.tool||"claude"} id`,labelTitle:d,value:e.toolSessionId,testid:"session-info-tool-session-id"}):null,h.jsx("div",{className:"my-2 border-t border-border"}),o?h.jsx(Jm,{icon:h.jsx(Pz,{className:"w-3.5 h-3.5"}),label:"Edited Files",onClick:o,testid:"session-info-files"}):null,a&&a>0&&l?h.jsx(Jm,{icon:h.jsx(vz,{className:"w-3.5 h-3.5"}),label:"定时任务",meta:String(a),onClick:l,testid:"session-info-cron"}):null,_?h.jsx(Jm,{icon:h.jsx(y$,{className:"w-3.5 h-3.5"}),label:"终端",meta:x,onClick:()=>void k(),testid:"session-info-terminal"}):null]}),v&&c?h.jsx("div",{className:"shrink-0 border-t border-border px-3 py-2.5",children:h.jsxs("button",{type:"button","data-testid":"session-info-force-stop",onClick:c,title:e.tool==="codex"?"强制停止 Codex 进程":"强制停止 Claude Code 进程(会丢失 initialize / 预热缓存)",className:"inline-flex items-center gap-1.5 h-6 px-2.5 rounded-md text-text-400 hover:bg-red-500/10 hover:text-red-400 transition-colors text-[12px] cursor-pointer",children:[h.jsx(Gz,{className:"w-3.5 h-3.5"}),h.jsx("span",{children:"强制停止"})]})}):null]})}const VZ=g.createContext({container:null});function qZ(){return g.useContext(VZ)}function KZ(e){return e==="TodoWrite"}function GZ(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 XZ(e,t,n){const r=[],i=new Map;for(let s=0;s<e.length;s++){const o=e[s],a=typeof o.seq=="number"?o.seq:s;switch(o.kind){case"session_init":r.push({kind:"session-init",seq:a,toolSessionId:o.toolSessionId});break;case"text":Mk(r,a,"assistant-text",o.text,o.partialId,o.uuid);break;case"thinking":Mk(r,a,"assistant-thinking",o.text,o.partialId);break;case"user_text":{o.meta==="task-notification"?r.push({kind:"agent-notification",seq:a,text:o.text,taskId:o.taskId,parentToolUseId:o.parentToolUseId}):o.meta?r.push({kind:"user-meta",seq:a,metaKind:o.meta,text:o.text}):r.push({kind:"user-text",seq:a,text:o.text,uuid:o.uuid,...o.sender&&o.sender.principal!=="owner"?{senderDisplayName:o.sender.displayName}:{}});break}case"tool_call":jM(r,a,o.toolUseId,o.tool,o.input,o.toolKind);break;case"tool_result":{const l=i.get(o.toolUseId);if(l!==void 0){if(o.askQuestionAnswers){const u=r[l];u.submittedAnswers=o.askQuestionAnswers}i.delete(o.toolUseId);break}const c={kind:"tool-result",seq:a,toolUseId:o.toolUseId,output:o.output,error:o.error};o.toolResultExtra&&(c.toolResultExtra=o.toolResultExtra),r.push(c);break}case"attachment_memories":r.push({kind:"memory-callout",seq:a,memories:o.memories});break;case"permission_request":{if(!t||o.requestId!==t)break;r.push({kind:"permission-inline",seq:a,requestId:o.requestId,tool:o.tool,input:o.input});break}case"ask_user_question":i.set(o.toolUseId,r.length),r.push({kind:"question-card",seq:a,toolUseId:o.toolUseId,questions:o.questions});break;case"turn_end":{const l={kind:"turn-end",seq:a};o.durationMs!==void 0&&(l.durationMs=o.durationMs),o.reason!==void 0&&(l.reason=o.reason),r.push(l);break}case"subagent_progress":{const l={kind:"agent-progress",seq:a,toolUseId:o.toolUseId,agentId:o.agentId,status:o.status};o.description&&(l.description=o.description),o.lastToolName&&(l.lastToolName=o.lastToolName),o.prompt&&(l.prompt=o.prompt),o.stats&&(l.stats=o.stats),r.push(l);break}case"error":r.push({kind:"error",seq:a,message:o.message});break}}return r}function jM(e,t,n,r,i,s){if(KZ(r)){const o=GZ(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(DU(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 Mk(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 YZ="AskUserQuestion";function DM(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=(o=X6.exec(a.text??""))==null?void 0:o[1];r.push({kind:"user-text",seq:l,text:a.text??"",uuid:a.uuid,...u?{senderDisplayName:u}:{}})}break;case"assistant-text":r.push({kind:"assistant-text",seq:l,text:a.text??"",uuid:a.uuid});break;case"tool_call":{if(a.tool===YZ){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}jM(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 QZ=5e5;function ZZ(e){const t=QZ-e.length;return e.map(n=>({...n,seq:n.seq+t}))}function JZ({api:e,cwd:t,toolSessionId:n}){const r=PM(),i=(r==null?void 0:r.state.agentId)??null,s=r==null?void 0:r.state.agentType,[o,a]=g.useState([]),[l,c]=g.useState(!1),[u,d]=g.useState(null);g.useEffect(()=>{if(!i)return;let p=!1;return c(!0),d(null),a([]),e.historySubagentRead({cwd:t,toolSessionId:n,subagentId:i}).then(m=>{p||a(m.messages??[])}).catch(m=>{p||d(m instanceof Error?m.message:String(m))}).finally(()=>{p||c(!1)}),()=>{p=!0}},[i,t,n,e]);const f=g.useMemo(()=>o.length>0?DM(o,0,"claude"):[],[o]);return!r||!i?null:h.jsxs("div",{"data-testid":"subagent-drawer","data-agent-id":i,className:fe("fixed inset-y-0 right-0 z-50 w-[min(560px,92vw)]","flex flex-col border-l border-bg-200/60 bg-bg-50 shadow-xl"),style:{paddingTop:"env(safe-area-inset-top)"},children:[h.jsxs("div",{className:"flex flex-col gap-0.5 px-3 py-2 border-b border-bg-200/60",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s?h.jsx("span",{className:"inline-flex items-center rounded-sm bg-violet-500/10 px-1.5 py-0.5 text-[11px] text-violet-400 font-medium",children:s}):null,h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate",title:i,children:i})]}),h.jsx("button",{type:"button","aria-label":"关闭",onClick:()=>r.close(),className:"p-1 rounded hover:bg-bg-200/50 text-text-400 hover:text-text-200",children:h.jsx(Dr,{className:"w-4 h-4"})})]}),!l&&!u&&o.length>0?h.jsxs("div",{className:"text-[11px] text-text-400",children:[o.length," 条消息 · 首条为主会话派发的任务指令"]}):null]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden px-3 py-2",children:l?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(In,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"加载中…"})]}):u?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-error",children:[h.jsx(Ls,{className:"w-3.5 h-3.5"}),h.jsx("span",{children:u})]}):f.length===0?h.jsx("div",{className:"text-[12px] text-text-400 italic",children:"无消息"}):h.jsx(RM,{lines:f})})]})}function Ak(e,t){let n=0;for(const r of e.lines)r.startsWith(t)&&n++;return n}function eJ(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+=Ak(m,"+"),p.deletions+=Ak(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 tJ({open:e,onOpenChange:t,api:n,sessionId:r,userMessageId:i,lines:s,procAlive:o,onApplied:a,onNoChanges:l}){const c=g.useMemo(()=>eJ(s,i),[s,i]),[u,d]=g.useState(null),[f,p]=g.useState(!1),[m,v]=g.useState(!1),[b,_]=g.useState(null);g.useEffect(()=>{if(!e)return;let C=!1;return p(!0),d(null),(async()=>{try{const N=await n.sessionRewindDiff({sessionId:r,userMessageId:i});C||(d(N),!N.canRewind&&!N.error&&N.files.length===0&&(l==null||l(i)))}catch{C||d(null)}finally{C||p(!1)}})(),()=>{C=!0}},[e,n,r,i]);const x=g.useMemo(()=>{if(u){const C=!u.canRewind&&!u.error&&u.files.length===0;if(u.canRewind||C)return{source:"rpc",anchorFound:!0,files:u.files.map(N=>({filePath:N.filePath,hunks:N.hunks,insertions:N.insertions,deletions:N.deletions})),totalInsertions:u.totalInsertions,totalDeletions:u.totalDeletions}}return{source:"local",anchorFound:c.anchorFound,files:c.files,totalInsertions:c.totalInsertions,totalDeletions:c.totalDeletions,rpcError:u==null?void 0:u.error}},[u,c]),y=g.useCallback(async()=>{v(!0),_(null);try{const C=await n.sessionRewind({sessionId:r,userMessageId:i,dryRun:!1});if(!C.canRewind){_(C.error??"回退失败");return}a==null||a(),t(!1)}catch(C){_(C.message||"回退失败")}finally{v(!1)}},[n,r,i,a,t]);if(!e)return null;const w=x.files.length>0,k=!f&&!m&&x.anchorFound&&w&&!b;return h.jsxs("div",{"data-testid":"rewind-preview-drawer",className:"fixed right-0 top-0 bottom-0 z-40 flex flex-col border-l border-bg-300/40 bg-bg-0 shadow-xl",style:{width:480,minWidth:480},children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bg-300/30 shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(zT,{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(Dr,{className:"w-4 h-4"})})]}),b?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(Kc,{className:"w-4 h-4 shrink-0 mt-0.5"}),h.jsx("span",{children:b})]}):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(In,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"正在读取快照…"})]}):x.anchorFound?w?h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":"rewind-summary",className:"rounded-md border border-bg-300 bg-bg-100/40 px-3 py-2 text-[12px] text-text-200",children:[h.jsxs("div",{children:["将回退 ",h.jsx("span",{className:"font-semibold text-text-100",children:x.files.length})," ","个文件,",h.jsxs("span",{className:"text-green-500 font-mono",children:["+",x.totalInsertions]})," / ",h.jsxs("span",{className:"text-red-400 font-mono",children:["-",x.totalDeletions]})]}),x.source==="local"?h.jsx("div",{"data-testid":"rewind-source-hint",className:"mt-1 text-text-400 text-[11px]",children:"基于对话里 tool_result 估算(未读到 CC 快照,数字可能与实际磁盘略有差异)"}):null]}),x.files.map(C=>h.jsx(rJ,{file:C},C.filePath))]}):h.jsxs("div",{"data-testid":"rewind-no-changes",className:"rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300 space-y-1",children:[h.jsx("div",{children:"磁盘上的文件已经和这个时刻的快照完全一致——没有需要回退的改动。"}),h.jsx("div",{className:"text-text-400 text-[11px]",children:"可能这条消息之后 Claude 没落盘编辑,或之前已经 rewind 过了。"})]}):h.jsx("div",{"data-testid":"rewind-no-anchor",className:"rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300",children:"未能在当前消息流中找到对应的用户消息(可能已被历史裁剪)。"})}),h.jsxs("div",{className:"flex flex-col gap-2 px-4 py-3 border-t border-bg-300/30 shrink-0",children:[w&&x.anchorFound&&!o?h.jsxs("div",{"data-testid":"rewind-needs-cc",className:"flex items-start gap-2 rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300",children:[h.jsx(Kc,{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:!k,onClick:()=>void y(),"data-testid":"rewind-apply",className:fe("h-8 px-3 rounded-md text-[12px] font-medium transition-colors",k?"bg-accent text-white hover:bg-accent-hover cursor-pointer":"bg-bg-200 text-text-400 cursor-not-allowed"),children:m?"回退中…":"确认回退"})]})]})]})}function nJ(e){return e.replace(/^\/Users\/[^/]+/,"~")}function rJ({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(ir,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(Un,{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:nJ(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(iJ,{hunk:r},`${r.oldStart}-${r.oldLines}-${r.newStart}-${r.newLines}`))}):null]})}function iJ({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:fe("px-3 whitespace-pre",s),children:n.length>0?n:" "},r)})]})}function sJ({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 oJ={idle:"还没启动","turn-running":"正在 run 中","turn-idle":"进程活着,等输入",exited:"进程已退出",crashed:"启动失败 / 异常退出"};function aJ({sessionStatus:e}){switch(e){case"idle":return"idle";case"running":return"turn-running";case"running-idle":return"turn-idle";case"observing":return"turn-running";case"stopped":return"exited";case"error":return"crashed"}}function lJ(e){return e==="running"||e==="observing"}function OM(e){return e==="running"||e==="running-idle"||e==="observing"}/**
|