@clawos-dev/clawd 0.2.642 → 0.2.644
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.
|
@@ -516,7 +516,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
516
516
|
`)},xW=0,la=[];function yW(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState(xW++)[0],s=g.useState(E4)[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=$U([e.lockRef.current],(e.shards||[]).map(ek),!0).filter(Boolean);return v.forEach(function(w){return w.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),v.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(v,w){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var x=jd(v),_=n.current,b="deltaX"in v?v.deltaX:_[0]-x[0],S="deltaY"in v?v.deltaY:_[1]-x[1],C,k=v.target,T=Math.abs(b)>Math.abs(S)?"h":"v";if("touches"in v&&T==="h"&&k.type==="range")return!1;var E=window.getSelection(),j=E&&E.anchorNode,R=j?j===k||j.contains(k):!1;if(R)return!1;var O=ZS(T,k);if(!O)return!0;if(O?C=T:(C=T==="v"?"h":"v",O=ZS(T,k)),!O)return!1;if(!r.current&&"changedTouches"in v&&(b||S)&&(r.current=C),!C)return!0;var P=r.current||C;return mW(P,w,v,P==="h"?b:S)},[]),l=g.useCallback(function(v){var w=v;if(!(!la.length||la[la.length-1]!==s)){var x="deltaY"in w?JS(w):jd(w),_=t.current.filter(function(C){return C.name===w.type&&(C.target===w.target||w.target===C.shadowParent)&&gW(C.delta,x)})[0];if(_&&_.should){w.cancelable&&w.preventDefault();return}if(!_){var b=(o.current.shards||[]).map(ek).filter(Boolean).filter(function(C){return C.contains(w.target)}),S=b.length>0?a(w,b[0]):!o.current.noIsolation;S&&w.cancelable&&w.preventDefault()}}},[]),c=g.useCallback(function(v,w,x,_){var b={name:v,delta:w,target:x,should:_,shadowParent:_W(x)};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(S){return S!==b})},1)},[]),u=g.useCallback(function(v){n.current=jd(v),r.current=void 0},[]),d=g.useCallback(function(v){c(v.type,JS(v),v.target,a(v,e.lockRef.current))},[]),f=g.useCallback(function(v){c(v.type,jd(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return la.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,aa),document.addEventListener("touchmove",l,aa),document.addEventListener("touchstart",u,aa),function(){la=la.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,aa),document.removeEventListener("touchmove",l,aa),document.removeEventListener("touchstart",u,aa)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(s,{styles:vW(i)}):null,p?g.createElement(lW,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function _W(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const bW=YU(C4,yW);var Hy=g.forwardRef(function(e,t){return g.createElement(Fp,ci({},e,{ref:t,sideCar:bW}))});Hy.classNames=Fp.classNames;var Vv=["Enter"," "],wW=["ArrowDown","PageUp","Home"],R4=["ArrowUp","PageDown","End"],SW=[...wW,...R4],kW={ltr:[...Vv,"ArrowRight"],rtl:[...Vv,"ArrowLeft"]},CW={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Bu="Menu",[fu,EW,IW]=z5(Bu),[Go,P4]=Ko(Bu,[IW,$p,g4]),zu=$p(),M4=g4(),[A4,Js]=Go(Bu),[TW,$u]=Go(Bu),L4=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=zu(t),[l,c]=g.useState(null),u=g.useRef(!1),d=_i(s),f=$5(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($y,{...a,children:h.jsx(A4,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(TW,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};L4.displayName=Bu;var NW="MenuAnchor",Uy=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=zu(n);return h.jsx(h4,{...i,...r,ref:t})});Uy.displayName=NW;var Wy="MenuPortal",[RW,j4]=Go(Wy,{forceMount:void 0}),D4=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=Js(Wy,t);return h.jsx(RW,{scope:t,forceMount:n,children:h.jsx(ts,{present:n||s.open,children:h.jsx(Fy,{asChild:!0,container:i,children:r})})})};D4.displayName=Wy;var Tr="MenuContent",[PW,qy]=Go(Tr),O4=g.forwardRef((e,t)=>{const n=j4(Tr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Js(Tr,e.__scopeMenu),o=$u(Tr,e.__scopeMenu);return h.jsx(fu.Provider,{scope:e.__scopeMenu,children:h.jsx(ts,{present:r||s.open,children:h.jsx(fu.Slot,{scope:e.__scopeMenu,children:o.modal?h.jsx(MW,{...i,ref:t}):h.jsx(AW,{...i,ref:t})})})})}),MW=g.forwardRef((e,t)=>{const n=Js(Tr,e.__scopeMenu),r=g.useRef(null),i=Zt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return w4(s)},[]),h.jsx(Vy,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Le(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),AW=g.forwardRef((e,t)=>{const n=Js(Tr,e.__scopeMenu);return h.jsx(Vy,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),LW=du("MenuContent.ScrollLock"),Vy=g.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...v}=e,w=Js(Tr,n),x=$u(Tr,n),_=zu(n),b=M4(n),S=EW(n),[C,k]=g.useState(null),T=g.useRef(null),E=Zt(t,T,w.onContentChange),j=g.useRef(0),R=g.useRef(""),O=g.useRef(0),P=g.useRef(null),A=g.useRef("right"),M=g.useRef(0),L=m?Hy:g.Fragment,$=m?{as:LW,allowPinchZoom:!0}:void 0,F=z=>{var me,Ie;const I=R.current+z,U=S().filter(ce=>!ce.disabled),q=document.activeElement,D=(me=U.find(ce=>ce.ref.current===q))==null?void 0:me.textValue,te=U.map(ce=>ce.textValue),ie=VW(te,I,D),G=(Ie=U.find(ce=>ce.textValue===ie))==null?void 0:Ie.ref.current;(function ce(Me){R.current=Me,window.clearTimeout(j.current),Me!==""&&(j.current=window.setTimeout(()=>ce(""),1e3))})(I),G&&setTimeout(()=>G.focus())};g.useEffect(()=>()=>window.clearTimeout(j.current),[]),U5();const B=g.useCallback(z=>{var U,q;return A.current===((U=P.current)==null?void 0:U.side)&&GW(z,(q=P.current)==null?void 0:q.area)},[]);return h.jsx(PW,{scope:n,searchRef:R,onItemEnter:g.useCallback(z=>{B(z)&&z.preventDefault()},[B]),onItemLeave:g.useCallback(z=>{var I;B(z)||((I=T.current)==null||I.focus(),k(null))},[B]),onTriggerLeave:g.useCallback(z=>{B(z)&&z.preventDefault()},[B]),pointerGraceTimerRef:O,onPointerGraceIntentChange:g.useCallback(z=>{P.current=z},[]),children:h.jsx(L,{...$,children:h.jsx(Py,{asChild:!0,trapped:i,onMountAutoFocus:Le(s,z=>{var I;z.preventDefault(),(I=T.current)==null||I.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:h.jsx(jp,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(jU,{asChild:!0,...b,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:Le(l,z=>{x.isUsingKeyboardRef.current||z.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(f4,{role:"menu","aria-orientation":"vertical","data-state":e3(w.open),"data-radix-menu-content":"",dir:x.dir,..._,...v,ref:E,style:{outline:"none",...v.style},onKeyDown:Le(v.onKeyDown,z=>{const U=z.target.closest("[data-radix-menu-content]")===z.currentTarget,q=z.ctrlKey||z.altKey||z.metaKey,D=z.key.length===1;U&&(z.key==="Tab"&&z.preventDefault(),!q&&D&&F(z.key));const te=T.current;if(z.target!==te||!SW.includes(z.key))return;z.preventDefault();const G=S().filter(me=>!me.disabled).map(me=>me.ref.current);R4.includes(z.key)&&G.reverse(),WW(G)}),onBlur:Le(e.onBlur,z=>{z.currentTarget.contains(z.target)||(window.clearTimeout(j.current),R.current="")}),onPointerMove:Le(e.onPointerMove,pu(z=>{const I=z.target,U=M.current!==z.clientX;if(z.currentTarget.contains(I)&&U){const q=z.clientX>M.current?"right":"left";A.current=q,M.current=z.clientX}}))})})})})})})});O4.displayName=Tr;var jW="MenuGroup",Ky=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(At.div,{role:"group",...r,ref:t})});Ky.displayName=jW;var DW="MenuLabel",B4=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(At.div,{...r,ref:t})});B4.displayName=DW;var Nf="MenuItem",tk="menu.itemSelect",Hp=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=$u(Nf,e.__scopeMenu),a=qy(Nf,e.__scopeMenu),l=Zt(t,s),c=g.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(tk,{bubbles:!0,cancelable:!0});d.addEventListener(tk,p=>r==null?void 0:r(p),{once:!0}),B5(d,f),f.defaultPrevented?c.current=!1:o.onClose()}};return h.jsx(z4,{...i,ref:l,disabled:n,onClick:Le(e.onClick,u),onPointerDown:d=>{var f;(f=e.onPointerDown)==null||f.call(e,d),c.current=!0},onPointerUp:Le(e.onPointerUp,d=>{var f;c.current||(f=d.currentTarget)==null||f.click()}),onKeyDown:Le(e.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||Vv.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});Hp.displayName=Nf;var z4=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=qy(Nf,n),a=M4(n),l=g.useRef(null),c=Zt(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(fu.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:h.jsx(DU,{asChild:!0,...a,focusable:!r,children:h.jsx(At.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:Le(e.onPointerMove,pu(m=>{r?o.onItemLeave(m):(o.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Le(e.onPointerLeave,pu(m=>o.onItemLeave(m))),onFocus:Le(e.onFocus,()=>d(!0)),onBlur:Le(e.onBlur,()=>d(!1))})})})}),OW="MenuCheckboxItem",$4=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return h.jsx(q4,{scope:e.__scopeMenu,checked:n,children:h.jsx(Hp,{role:"menuitemcheckbox","aria-checked":Rf(n)?"mixed":n,...i,ref:t,"data-state":Xy(n),onSelect:Le(i.onSelect,()=>r==null?void 0:r(Rf(n)?!0:!n),{checkForDefaultPrevented:!1})})})});$4.displayName=OW;var F4="MenuRadioGroup",[BW,zW]=Go(F4,{value:void 0,onValueChange:()=>{}}),H4=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=_i(r);return h.jsx(BW,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(Ky,{...i,ref:t})})});H4.displayName=F4;var U4="MenuRadioItem",W4=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=zW(U4,e.__scopeMenu),s=n===i.value;return h.jsx(q4,{scope:e.__scopeMenu,checked:s,children:h.jsx(Hp,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Xy(s),onSelect:Le(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});W4.displayName=U4;var Gy="MenuItemIndicator",[q4,$W]=Go(Gy,{checked:!1}),V4=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=$W(Gy,n);return h.jsx(ts,{present:r||Rf(s.checked)||s.checked===!0,children:h.jsx(At.span,{...i,ref:t,"data-state":Xy(s.checked)})})});V4.displayName=Gy;var FW="MenuSeparator",K4=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(At.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});K4.displayName=FW;var HW="MenuArrow",G4=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=zu(n);return h.jsx(p4,{...i,...r,ref:t})});G4.displayName=HW;var Yy="MenuSub",[UW,Y4]=Go(Yy),X4=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=Js(Yy,t),o=zu(t),[a,l]=g.useState(null),[c,u]=g.useState(null),d=_i(i);return g.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),h.jsx($y,{...o,children:h.jsx(A4,{scope:t,open:r,onOpenChange:d,content:c,onContentChange:u,children:h.jsx(UW,{scope:t,contentId:Fi(),triggerId:Fi(),trigger:a,onTriggerChange:l,children:n})})})};X4.displayName=Yy;var fc="MenuSubTrigger",Q4=g.forwardRef((e,t)=>{const n=Js(fc,e.__scopeMenu),r=$u(fc,e.__scopeMenu),i=Y4(fc,e.__scopeMenu),s=qy(fc,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(Uy,{asChild:!0,...c,children:h.jsx(z4,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":e3(n.open),...e,ref:Lu(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:Le(e.onPointerMove,pu(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:Le(e.onPointerLeave,pu(d=>{var p,m;u();const f=(p=n.content)==null?void 0:p.getBoundingClientRect();if(f){const v=(m=n.content)==null?void 0:m.dataset.side,w=v==="right",x=w?-5:5,_=f[w?"left":"right"],b=f[w?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+x,y:d.clientY},{x:_,y:f.top},{x:b,y:f.top},{x:b,y:f.bottom},{x:_,y:f.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Le(e.onKeyDown,d=>{var p;const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||kW[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});Q4.displayName=fc;var Z4="MenuSubContent",J4=g.forwardRef((e,t)=>{const n=j4(Tr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Js(Tr,e.__scopeMenu),o=$u(Tr,e.__scopeMenu),a=Y4(Z4,e.__scopeMenu),l=g.useRef(null),c=Zt(t,l);return h.jsx(fu.Provider,{scope:e.__scopeMenu,children:h.jsx(ts,{present:r||s.open,children:h.jsx(fu.Slot,{scope:e.__scopeMenu,children:h.jsx(Vy,{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:Le(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Le(e.onEscapeKeyDown,u=>{o.onClose(),u.preventDefault()}),onKeyDown:Le(e.onKeyDown,u=>{var p;const d=u.currentTarget.contains(u.target),f=CW[o.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});J4.displayName=Z4;function e3(e){return e?"open":"closed"}function Rf(e){return e==="indeterminate"}function Xy(e){return Rf(e)?"indeterminate":e?"checked":"unchecked"}function WW(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function qW(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function VW(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=qW(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 KW(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(i=!i)}return i}function GW(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return KW(n,t)}function pu(e){return t=>t.pointerType==="mouse"?e(t):void 0}var YW=L4,XW=Uy,QW=D4,ZW=O4,JW=Ky,eq=B4,tq=Hp,nq=$4,rq=H4,iq=W4,sq=V4,oq=K4,aq=G4,lq=X4,cq=Q4,uq=J4,Up="DropdownMenu",[dq]=Ko(Up,[P4]),Tn=P4(),[hq,t3]=dq(Up),n3=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=Tn(t),c=g.useRef(null),[u,d]=ju({prop:i,defaultProp:s??!1,onChange:o,caller:Up});return h.jsx(hq,{scope:t,triggerId:Fi(),triggerRef:c,contentId:Fi(),open:u,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(YW,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};n3.displayName=Up;var r3="DropdownMenuTrigger",i3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=t3(r3,n),o=Tn(n);return h.jsx(XW,{asChild:!0,...o,children:h.jsx(At.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:Lu(t,s.triggerRef),onPointerDown:Le(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:Le(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});i3.displayName=r3;var fq="DropdownMenuPortal",s3=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Tn(t);return h.jsx(QW,{...r,...n})};s3.displayName=fq;var o3="DropdownMenuContent",a3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=t3(o3,n),s=Tn(n),o=g.useRef(!1);return h.jsx(ZW,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:t,onCloseAutoFocus:Le(e.onCloseAutoFocus,a=>{var l;o.current||(l=i.triggerRef.current)==null||l.focus(),o.current=!1,a.preventDefault()}),onInteractOutside:Le(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)"}})});a3.displayName=o3;var pq="DropdownMenuGroup",mq=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Tn(n);return h.jsx(JW,{...i,...r,ref:t})});mq.displayName=pq;var gq="DropdownMenuLabel",l3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Tn(n);return h.jsx(eq,{...i,...r,ref:t})});l3.displayName=gq;var vq="DropdownMenuItem",c3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Tn(n);return h.jsx(tq,{...i,...r,ref:t})});c3.displayName=vq;var xq="DropdownMenuCheckboxItem",u3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Tn(n);return h.jsx(nq,{...i,...r,ref:t})});u3.displayName=xq;var yq="DropdownMenuRadioGroup",_q=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Tn(n);return h.jsx(rq,{...i,...r,ref:t})});_q.displayName=yq;var bq="DropdownMenuRadioItem",wq=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Tn(n);return h.jsx(iq,{...i,...r,ref:t})});wq.displayName=bq;var Sq="DropdownMenuItemIndicator",d3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Tn(n);return h.jsx(sq,{...i,...r,ref:t})});d3.displayName=Sq;var kq="DropdownMenuSeparator",h3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Tn(n);return h.jsx(oq,{...i,...r,ref:t})});h3.displayName=kq;var Cq="DropdownMenuArrow",Eq=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Tn(n);return h.jsx(aq,{...i,...r,ref:t})});Eq.displayName=Cq;var Iq=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,o=Tn(t),[a,l]=ju({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return h.jsx(lq,{...o,open:a,onOpenChange:l,children:n})},Tq="DropdownMenuSubTrigger",f3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Tn(n);return h.jsx(cq,{...i,...r,ref:t})});f3.displayName=Tq;var Nq="DropdownMenuSubContent",p3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Tn(n);return h.jsx(uq,{...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)"}})});p3.displayName=Nq;var Rq=n3,Pq=i3,m3=s3,g3=a3,v3=l3,x3=c3,y3=u3,Mq=d3,_3=h3,Aq=Iq,b3=f3,w3=p3;const S3=Rq,k3=Pq,Qy=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(m3,{children:h.jsx(g3,{ref:r,sideOffset:t,className:re("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));Qy.displayName=g3.displayName;const Lq=Aq,C3=g.forwardRef(({className:e,...t},n)=>h.jsx(b3,{ref:n,className:re("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100 data-[state=open]:bg-bg-200","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...t}));C3.displayName=b3.displayName;const E3=g.forwardRef(({className:e,...t},n)=>h.jsx(m3,{children:h.jsx(w3,{ref:n,className:re("z-50 min-w-[6rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...t})}));E3.displayName=w3.displayName;const mo=g.forwardRef(({className:e,inset:t,...n},r)=>h.jsx(x3,{ref:r,className:re("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));mo.displayName=x3.displayName;const jq=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>h.jsxs(y3,{ref:i,checked:n,className:re("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-7 pr-2 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[h.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:h.jsx(Mq,{children:h.jsx(Au,{className:"h-3.5 w-3.5"})})}),t]}));jq.displayName=y3.displayName;const Zy=g.forwardRef(({className:e,...t},n)=>h.jsx(_3,{ref:n,className:re("-mx-1 my-1 h-px bg-border",e),...t}));Zy.displayName=_3.displayName;const I3=g.forwardRef(({className:e,...t},n)=>h.jsx(v3,{ref:n,className:re("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));I3.displayName=v3.displayName;function Dq({tool:e,className:t}){const n=NF(e);return h.jsx("span",{"data-testid":n?`session-icon-${e}`:"session-icon-default","aria-label":n?Ny(e):"未知引擎",className:re("w-3.5 h-3.5 shrink-0 inline-flex items-center justify-center",Lp(e),t),children:h.jsx(Ap,{tool:e,className:"w-full h-full"})})}function Oq({sessionId:e,hasUnread:t,running:n=!1,awaitingUser:r=!1,style:i}){return r?h.jsx(Zz,{"data-testid":`awaiting-dot-${e}`,style:i,className:"w-3 h-3 text-warning shrink-0 animate-pulse",strokeWidth:2.25,"aria-label":"awaiting user"}):t?h.jsx("span",{"data-testid":`unread-dot-${e}`,style:i,className:"w-2 h-2 rounded-full bg-error shrink-0","aria-label":"unread"}):n?h.jsx("span",{"data-testid":`running-dot-${e}`,style:i,className:"w-2 h-2 rounded-full bg-success shrink-0 animate-pulse","aria-label":"running"}):null}function T3(e){return e.compositionActive||!!e.nativeIsComposing||e.keyCode===229}function N3(e){return e.key==="Enter"&&!e.shiftKey&&!T3(e)}function Fu(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(N3({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 Bq({open:e,initialLabel:t,placeholder:n,onSubmit:r,onCancel:i,title:s="Edit session",fieldLabel:o="Label",testId:a="session-edit-dialog",requireNonEmpty:l=!1}){const[c,u]=g.useState(t);g.useEffect(()=>{e&&u(t)},[e,t]);const d=c.trim(),f=l&&d==="",p=()=>{f||r({label:d})},m=Fu(p,i);return e?_l.createPortal(h.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-bg-0/40 backdrop-blur-[2px]",onClick:i,"data-testid":`${a}-overlay`,children:h.jsxs("div",{"data-testid":a,className:"w-[420px] max-w-[calc(100vw-32px)] rounded-2xl border border-text-100/[0.12] flex flex-col gap-4 p-5",style:{backgroundColor:"var(--bg-0)",boxShadow:"0 12px 40px rgba(0,0,0,0.04)"},onClick:v=>v.stopPropagation(),children:[h.jsx("div",{className:"text-[15px] font-semibold text-text-100",children:s}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:o}),h.jsx("input",{autoFocus:!0,type:"text",value:c,onChange:v=>u(v.target.value),...m,placeholder:n,"data-testid":`${a}-label`,className:"w-full px-3 py-2 text-[13px] bg-bg-50 border border-bg-300 rounded-lg focus:outline-none focus:border-text-300 transition-colors"})]}),h.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[h.jsx("button",{type:"button",onClick:i,className:"px-4 py-1.5 text-[12px] text-text-300 rounded-lg hover:bg-text-100/5 transition-colors cursor-pointer",children:"Cancel"}),h.jsx("button",{type:"button",onClick:p,disabled:f,"data-testid":`${a}-save`,className:"px-4 py-1.5 text-[12px] font-medium text-bg-0 rounded-lg bg-text-100 hover:bg-text-200 transition-colors cursor-pointer disabled:cursor-not-allowed disabled:opacity-40",children:"Save"})]})]})}),document.body):null}var zq=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),$q="VisuallyHidden",R3=g.forwardRef((e,t)=>h.jsx(At.span,{...e,ref:t,style:{...zq,...e.style}}));R3.displayName=$q;var Fq=R3,[Wp]=Ko("Tooltip",[$p]),qp=$p(),P3="TooltipProvider",Hq=700,Kv="tooltip.open",[Uq,Jy]=Wp(P3),M3=e=>{const{__scopeTooltip:t,delayDuration:n=Hq,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=g.useRef(!0),a=g.useRef(!1),l=g.useRef(0);return g.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),h.jsx(Uq,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:g.useCallback(()=>{window.clearTimeout(l.current),o.current=!1},[]),onClose:g.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:g.useCallback(c=>{a.current=c},[]),disableHoverableContent:i,children:s})};M3.displayName=P3;var mu="Tooltip",[Wq,Vp]=Wp(mu),A3=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=Jy(mu,e.__scopeTooltip),c=qp(t),[u,d]=g.useState(null),f=Fi(),p=g.useRef(0),m=o??l.disableHoverableContent,v=a??l.delayDuration,w=g.useRef(!1),[x,_]=ju({prop:r,defaultProp:i??!1,onChange:T=>{T?(l.onOpen(),document.dispatchEvent(new CustomEvent(Kv))):l.onClose(),s==null||s(T)},caller:mu}),b=g.useMemo(()=>x?w.current?"delayed-open":"instant-open":"closed",[x]),S=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,w.current=!1,_(!0)},[_]),C=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,_(!1)},[_]),k=g.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{w.current=!0,_(!0),p.current=0},v)},[v,_]);return g.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),h.jsx($y,{...c,children:h.jsx(Wq,{scope:t,contentId:f,open:x,stateAttribute:b,trigger:u,onTriggerChange:d,onTriggerEnter:g.useCallback(()=>{l.isOpenDelayedRef.current?k():S()},[l.isOpenDelayedRef,k,S]),onTriggerLeave:g.useCallback(()=>{m?C():(window.clearTimeout(p.current),p.current=0)},[C,m]),onOpen:S,onClose:C,disableHoverableContent:m,children:n})})};A3.displayName=mu;var Gv="TooltipTrigger",L3=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Vp(Gv,n),s=Jy(Gv,n),o=qp(n),a=g.useRef(null),l=Zt(t,a,i.onTriggerChange),c=g.useRef(!1),u=g.useRef(!1),d=g.useCallback(()=>c.current=!1,[]);return g.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),h.jsx(h4,{asChild:!0,...o,children:h.jsx(At.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:Le(e.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:Le(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:Le(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Le(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Le(e.onBlur,i.onClose),onClick:Le(e.onClick,i.onClose)})})});L3.displayName=Gv;var qq="TooltipPortal",[Zce,Vq]=Wp(qq,{forceMount:void 0}),sl="TooltipContent",j3=g.forwardRef((e,t)=>{const n=Vq(sl,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=Vp(sl,e.__scopeTooltip);return h.jsx(ts,{present:r||o.open,children:o.disableHoverableContent?h.jsx(D3,{side:i,...s,ref:t}):h.jsx(Kq,{side:i,...s,ref:t})})}),Kq=g.forwardRef((e,t)=>{const n=Vp(sl,e.__scopeTooltip),r=Jy(sl,e.__scopeTooltip),i=g.useRef(null),s=Zt(t,i),[o,a]=g.useState(null),{trigger:l,onClose:c}=n,u=i.current,{onPointerInTransitChange:d}=r,f=g.useCallback(()=>{a(null),d(!1)},[d]),p=g.useCallback((m,v)=>{const w=m.currentTarget,x={x:m.clientX,y:m.clientY},_=Zq(x,w.getBoundingClientRect()),b=Jq(x,_),S=eV(v.getBoundingClientRect()),C=nV([...b,...S]);a(C),d(!0)},[d]);return g.useEffect(()=>()=>f(),[f]),g.useEffect(()=>{if(l&&u){const m=w=>p(w,u),v=w=>p(w,l);return l.addEventListener("pointerleave",m),u.addEventListener("pointerleave",v),()=>{l.removeEventListener("pointerleave",m),u.removeEventListener("pointerleave",v)}}},[l,u,p,f]),g.useEffect(()=>{if(o){const m=v=>{const w=v.target,x={x:v.clientX,y:v.clientY},_=(l==null?void 0:l.contains(w))||(u==null?void 0:u.contains(w)),b=!tV(x,o);_?f():b&&(f(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[l,u,o,c,f]),h.jsx(D3,{...e,ref:s})}),[Gq,Yq]=Wp(mu,{isInside:!1}),Xq=zF("TooltipContent"),D3=g.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,l=Vp(sl,n),c=qp(n),{onClose:u}=l;return g.useEffect(()=>(document.addEventListener(Kv,u),()=>document.removeEventListener(Kv,u)),[u]),g.useEffect(()=>{if(l.trigger){const d=f=>{const p=f.target;p!=null&&p.contains(l.trigger)&&u()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,u]),h.jsx(jp,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:h.jsxs(f4,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[h.jsx(Xq,{children:r}),h.jsx(Gq,{scope:n,isInside:!0,children:h.jsx(Fq,{id:l.contentId,role:"tooltip",children:i||r})})]})})});j3.displayName=sl;var O3="TooltipArrow",Qq=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=qp(n);return Yq(O3,n).isInside?null:h.jsx(p4,{...i,...r,ref:t})});Qq.displayName=O3;function Zq(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function Jq(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function eV(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function tV(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 nV(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),rV(t)}function rV(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],o=t[t.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var iV=M3,sV=A3,oV=L3,B3=j3;const Pf=iV,Kp=sV,Gp=oV,Hu=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(B3,{ref:r,sideOffset:t,className:re("z-50 overflow-hidden rounded-sm border border-border bg-bg-0 px-2 py-1 text-xs text-text-300 shadow-md",e),...n}));Hu.displayName=B3.displayName;const aV={held:!1,indexBySessionId:new Map},lV=g.createContext(aV);function cV(){return g.useContext(lV)}const uV=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})),dV=[{id:"new-session",combo:{key:"n",mod:!0},label:"新建任务",description:"打开快捷新建弹窗",group:"通用",desktopOnly:!0},{id:"open-search",combo:{key:"k",mod:!0},label:"全局搜索",description:"搜会话内容 / persona / 联系人",group:"通用",desktopOnly:!0},{id:"search-tab-prev",combo:{key:"ArrowLeft",mod:!0},label:"搜索:上一组",description:"搜索浮层里切到左边那个 tab(会话 / persona / 联系人)",group:"通用"},{id:"search-tab-next",combo:{key:"ArrowRight",mod:!0},label:"搜索:下一组",description:"搜索浮层里切到右边那个 tab",group:"通用"},...uV,{id:"archive-session",combo:{key:"Backspace",mod:!0,shift:!0},label:"归档当前会话",description:"归档当前聊天区的会话,Enter 确认 / Esc 取消",group:"会话",desktopOnly:!0},{id:"tab-prev",combo:{key:"ArrowLeft",mod:!0,shift:!0},label:"上一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"tab-next",combo:{key:"ArrowRight",mod:!0,shift:!0},label:"下一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"toggle-hive",combo:{key:"h",mod:!0,shift:!0},label:"Hive 看板",description:"全屏看所有 agent 在干什么;Esc 或点任意行退出",group:"通用"},{id:"send-message",combo:{key:"Enter"},label:"发送消息",description:"在输入框中发送当前内容",group:"输入",displayOnly:!0},{id:"newline",combo:{key:"Enter",shift:!0},label:"换行",description:"在输入框中插入换行",group:"输入",displayOnly:!0},{id:"interrupt",combo:{key:"Escape"},label:"打断回复",description:"打断当前回复;2 秒内按两次停止任务",group:"输入",displayOnly:!0}];dV.filter(e=>!e.displayOnly);function hV(){return/Mac|iP(hone|od|ad)/.test(navigator.platform)}const fV=10,pV=20,mV=16,nk=20,rk=60,gV=4;function Dd({testId:e,label:t,children:n}){return h.jsxs(Kp,{children:[h.jsx(Gp,{asChild:!0,children:h.jsx("span",{"data-testid":e,role:"img","aria-label":t,tabIndex:0,className:"inline-flex shrink-0",children:n})}),h.jsx(Hu,{side:"bottom",children:t})]})}function vV({session:e,active:t,hasUnread:n,running:r=!1,awaitingUser:i=!1,onSelect:s,onEdit:o,onDelete:a,onPin:l,onArchive:c,quickAction:u,depth:d=0,chevron:f,showCopyResume:p=!0,contactDisplayName:m,ownerPrincipalId:v,creatorDisplayName:w,dispatchedFromSessionTitle:x}){const[_,b]=g.useState(!1),S=cV(),C=S.held?S.indexBySessionId.get(e.sessionId):void 0,k=!!e.pinnedAt,T=d===0,E=d===0&&!!c,j=fV+d*pV;let R=null;u==="pin"&&T&&l?R={icon:k?h.jsx(_S,{className:"w-4 h-4"}):h.jsx(bS,{className:"w-4 h-4"}),label:k?"取消置顶":"置顶",run:()=>l(e.sessionId,!k)}:u==="archive"&&E&&c?R={icon:h.jsx(vS,{className:"w-4 h-4"}),label:"归档",run:()=>c(e.sessionId,!0)}:u==="rename"&&o&&(R={icon:h.jsx(Ov,{className:"w-4 h-4"}),label:"重命名",run:()=>b(!0)});const O=g.useCallback(async()=>{const $=D5(e);if($)try{await navigator.clipboard.writeText($)}catch{}},[e]),P=Ry(e),A=e.originOwnerPrincipalId,M=A?`@${m??`…${A.slice(-8)}`}`:null,L=!!(e.ownerPersonaId&&v&&e.creatorPrincipalId&&e.creatorPrincipalId!==v&&!e.larkChatId&&!e.shiftFiredFromSessionId&&!e.dispatchedFromSessionId);return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":`session-item-${e.sessionId}`,onClick:s,style:{paddingLeft:j,display:"grid",gridTemplateColumns:f?`${mV}px ${nk}px 1fr auto ${rk}px`:`${nk}px 1fr auto ${rk}px`,gridTemplateAreas:f?'"chev icon name dot time"':'"icon name dot time"',columnGap:`${gV}px`,alignItems:"center"},className:re("group relative rounded-lg cursor-pointer transition-all duration-150 pr-2.5 py-1.5",t?"bg-accent-dim":"hover:bg-sidebar-hover-bg"),children:[t?h.jsx("span",{"aria-hidden":"true",className:"absolute left-0 top-1/2 -translate-y-1/2 w-[3px] h-7 rounded-r-full bg-accent"}):null,h.jsx("div",{style:{gridArea:"chev"},className:"flex items-center justify-center",children:f??null}),h.jsx("div",{style:{gridArea:"icon"},className:"flex items-center justify-center",children:h.jsx(Dq,{tool:e.tool})}),h.jsxs("div",{style:{gridArea:"name"},className:"flex items-center gap-1 min-w-0",children:[h.jsxs(Pf,{delayDuration:200,skipDelayDuration:100,children:[e.dispatchedFromSessionId?h.jsx(Dd,{testId:`dispatched-icon-${e.sessionId}`,label:`来自【${x??"另一会话"}】dispatch`,children:h.jsx(b$,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.shiftFiredFromSessionId?h.jsx(Dd,{testId:`shift-fired-icon-${e.sessionId}`,label:"定时任务",children:h.jsx(Uz,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.larkChatId?h.jsx(Dd,{testId:`lark-chat-icon-${e.sessionId}`,label:e.larkChatType==="p2p"?"来自飞书DM":"来自飞书群",children:h.jsx(X$,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,L?h.jsx(Dd,{testId:`guest-created-icon-${e.sessionId}`,label:w?`${w}创建`:"其他人创建",children:h.jsx(P7,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null]}),h.jsx("span",{"data-testid":`session-title-${e.sessionId}`,className:re("text-[13px] truncate min-w-0","group-hover:whitespace-normal group-hover:overflow-visible group-hover:break-words",t?"text-text-100 font-medium":"text-text-200"),children:P}),M?h.jsx("span",{"data-testid":`session-mirror-chip-${e.sessionId}`,title:`在 ${M.replace(/^@/,"")} 的设备上`,className:"shrink-0 inline-flex items-center px-1.5 py-0 rounded text-[10px] bg-accent-dim/40 text-accent border border-accent/20 max-w-[120px] truncate",children:M}):null]}),h.jsx(Oq,{sessionId:e.sessionId,hasUnread:n,running:r,awaitingUser:i,style:{gridArea:"dot"}}),C!=null?h.jsx("span",{style:{gridArea:"time"},"data-testid":`session-quick-switch-badge-${e.sessionId}`,className:"text-right shrink-0 transition-opacity duration-150 group-hover:opacity-0",children:h.jsx("span",{className:"inline-flex items-center justify-center h-[18px] px-1.5 rounded-[5px] border border-border bg-bg-200/70 text-[11px] text-text-200 font-medium leading-none",children:hV()?`⌘${C}`:`Ctrl+${C}`})}):h.jsx("span",{style:{gridArea:"time"},className:re("text-[11px] text-text-400/70 text-right shrink-0","transition-opacity duration-150 group-hover:opacity-0"),children:e.updatedAt?RF(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:[R?h.jsx(Pf,{delayDuration:200,skipDelayDuration:100,children:h.jsxs(Kp,{children:[h.jsx(Gp,{asChild:!0,children:h.jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),R.run()},className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":R.label,"data-testid":`quick-action-${u}-${e.sessionId}`,children:R.icon})}),h.jsx(Hu,{side:"bottom",children:R.label})]})}):null,h.jsxs(S3,{modal:!1,children:[h.jsx(k3,{asChild:!0,children:h.jsx("button",{type:"button",onClick:$=>$.stopPropagation(),className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"session actions","data-testid":`session-menu-${e.sessionId}`,children:h.jsx(d5,{className:"w-4 h-4"})})}),h.jsxs(Qy,{align:"end",onClick:$=>$.stopPropagation(),children:[l&&T&&h.jsxs(mo,{onSelect:()=>l(e.sessionId,!k),"data-testid":`session-${k?"unpin":"pin"}-${e.sessionId}`,children:[k?h.jsx(_S,{className:"w-3 h-3 mr-2 text-text-400"}):h.jsx(bS,{className:"w-3 h-3 mr-2 text-text-400"}),k?"Unpin":"Pin"]}),E&&c&&h.jsxs(mo,{onSelect:()=>c(e.sessionId,!0),"data-testid":`session-archive-${e.sessionId}`,children:[h.jsx(vS,{className:"w-3 h-3 mr-2 text-text-400"}),"Archive"]}),o&&h.jsxs(mo,{onSelect:()=>b(!0),"data-testid":`session-rename-${e.sessionId}`,children:[h.jsx(Ov,{className:"w-3 h-3 mr-2 text-text-400"}),"Rename"]}),p&&e.toolSessionId?h.jsxs(mo,{onSelect:()=>void O(),"data-testid":`session-copy-resume-${e.sessionId}`,children:[h.jsx(Sy,{className:"w-3 h-3 mr-2 text-text-400"}),"Copy Resume Command"]}):null,(l||o||p&&e.toolSessionId)&&a&&h.jsx(Zy,{}),a&&h.jsxs(mo,{onSelect:()=>void a(e.sessionId),className:"text-destructive focus:text-destructive focus:bg-destructive/10","data-testid":`session-delete-${e.sessionId}`,children:[h.jsx(Ey,{className:"w-3 h-3 mr-2"}),"Delete"]})]})]})]}):null]}),o?h.jsx(Bq,{open:_,initialLabel:e.label??"",placeholder:e.cwd.split("/").pop()||"",onSubmit:$=>{o(e.sessionId,$),b(!1)},onCancel:()=>b(!1)}):null]})}function e_({node:e,depth:t=0,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:v,getSessionDisplayName:w,parentSession:x}){const _=e.children.length>0,{isCollapsed:b,toggle:S}=Dz(),C=!b(e.session.sessionId),k=g.useCallback(E=>{E.stopPropagation(),S(e.session.sessionId)},[S,e.session.sessionId]),T=_?h.jsx("button",{type:"button",onClick:k,"data-testid":`session-chevron-${e.session.sessionId}`,"aria-label":C?"collapse":"expand","aria-expanded":C,className:"shrink-0 flex items-center justify-center w-4 h-4 text-text-400 hover:text-text-100 cursor-pointer",children:C?h.jsx(Qn,{className:"w-3 h-3"}):h.jsx(zn,{className:"w-3 h-3"})}):null;return h.jsxs("div",{"data-testid":`session-tree-node-${e.session.sessionId}`,children:[h.jsx(vV,{session:e.session,active:n===e.session.sessionId,hasUnread:(r==null?void 0:r.has(e.session.sessionId))??!1,running:(i==null?void 0:i.has(e.session.sessionId))??!1,awaitingUser:(s==null?void 0:s.has(e.session.sessionId))??!1,onSelect:()=>o(e.session.sessionId),onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,showCopyResume:p,ownerPrincipalId:m,creatorDisplayName:e.session.creatorPrincipalId?v==null?void 0:v(e.session.creatorPrincipalId):void 0,dispatchedFromSessionTitle:e.session.dispatchedFromSessionId?(w==null?void 0:w(e.session.dispatchedFromSessionId))??((x==null?void 0:x.sessionId)===e.session.dispatchedFromSessionId?Ry(x):void 0):void 0,depth:t,chevron:T,contactDisplayName:e.session.originOwnerPrincipalId?f==null?void 0:f(e.session.originOwnerPrincipalId):void 0}),_&&C?h.jsx("div",{"data-testid":`session-tree-children-${e.session.sessionId}`,children:e.children.map(E=>h.jsx(e_,{node:E,depth:t+1,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:v,getSessionDisplayName:w,parentSession:e.session},E.session.sessionId))}):null]})}function xV(e){return e.forkedFromSessionId??e.dispatchedFromSessionId??e.shiftFiredFromSessionId}function t_(e,t){return e.updatedAt<t.updatedAt?1:e.updatedAt>t.updatedAt?-1:0}function z3(e){e=e.filter(s=>!s.ephemeral&&s.deployId===void 0&&s.testReleaseId===void 0);const t=new Map;for(const s of e)t.set(s.sessionId,s);const n=new Map,r=[];for(const s of e){const o=xV(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(t_);return{session:s,children:a.map(i)}};return[...r].sort(yV).map(i)}function $3(e){return[...e].sort((t,n)=>t_(t.session,n.session))}function yV(e,t){const n=typeof e.pinnedAt=="number",r=typeof t.pinnedAt=="number";if(n&&r){const i=typeof e.pinSortOrder=="number",s=typeof t.pinSortOrder=="number";return i&&s?e.pinSortOrder-t.pinSortOrder:i?-1:s?1:t.pinnedAt-e.pinnedAt}return n?-1:r?1:t_(e,t)}function _V(e){return e.label?e.label:e.aiLabel?e.aiLabel:e.cwd.split("/").filter(Boolean).pop()??""}function ik(e,t){const n=t.trim().toLowerCase();return n===""?!0:e.toLowerCase().includes(n)}const bV={isCollapsed:()=>!1,toggle:()=>{},prune:()=>{}};function wV({personas:e,activePersonaId:t,onSelectPersona:n,onCreateSession:r,sessions:i,activeSessionId:s,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,isPersonaExpanded:p,onTogglePersonaExpanded:m,onEditSession:v,onPinSession:w,showCopyResume:x,treatSessionsAsRoots:_,searchQuery:b}){const[S,C]=g.useState(null),[k,T]=g.useState(()=>new Set),E=p??(L=>k.has(L)),j=g.useCallback(L=>{if(m){m(L);return}T($=>{const F=new Set($);return F.has(L)?F.delete(L):F.add(L),F})},[m]),R=g.useMemo(()=>i==null?void 0:i.filter(L=>!L.ephemeral),[i]),O=g.useMemo(()=>new Map((R??[]).map(L=>[L.sessionId,Ry(L)])),[R]),P=g.useCallback(L=>f==null?void 0:f.get(L),[f]),A=g.useCallback(L=>O.get(L),[O]);if(e.length===0)return h.jsx(SV,{});const M=(b??"").trim();return M?h.jsx(by.Provider,{value:bV,children:h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(L=>{const $=R?R.filter(I=>I.ownerPersonaId===L.personaId).sort((I,U)=>U.updatedAt>I.updatedAt?1:-1):[],F=ik(L.label,M),B=$.filter(I=>ik(_V(I),M));if(!F&&B.length===0)return null;const z=F?$:B;return h.jsx(sk,{persona:L,active:L.personaId===t,editing:!1,onSelectPersona:n,onSubmitCreateSession:()=>{},onCancelCreateSession:()=>{},personaSessions:z,collapsed:!1,onToggleCollapsed:()=>{},activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:w,showCopyResume:x,treatSessionsAsRoots:_,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:P,getSessionDisplayName:A},L.personaId)})})}):h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(L=>{const $=R?R.filter(F=>F.ownerPersonaId===L.personaId).sort((F,B)=>B.updatedAt>F.updatedAt?1:-1):[];return h.jsx(sk,{persona:L,active:L.personaId===t,editing:L.personaId===S,onSelectPersona:n,onStartCreateSession:r?()=>C(L.personaId):void 0,onSubmitCreateSession:F=>{C(null),r==null||r(L.personaId,F)},onCancelCreateSession:()=>C(null),personaSessions:$,collapsed:!E(L.personaId),onToggleCollapsed:()=>j(L.personaId),activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:w,showCopyResume:x,treatSessionsAsRoots:_,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:P,getSessionDisplayName:A},L.personaId)})})}function SV(){return h.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-text-400",children:"还没有 persona。点上方 Personas 标题右侧 + 创建第一个。"})}function sk({persona:e,active:t,editing:n,onSelectPersona:r,onStartCreateSession:i,onSubmitCreateSession:s,onCancelCreateSession:o,personaSessions:a,collapsed:l,onToggleCollapsed:c,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:w,onPinSession:x,showCopyResume:_,treatSessionsAsRoots:b,ownerPrincipalId:S,creatorDisplayNameByOwnerId:C,getCreatorDisplayName:k,getSessionDisplayName:T}){const E=a.length>0,j=!l,R=g.useMemo(()=>{const A=[],M=new Map;for(const L of a){const $=L.creatorPrincipalId;if(L.larkChatId!=null||!$||S&&$===S){A.push(L);continue}const F=$,B=(C==null?void 0:C.get(F))??`…${F.slice(-8)}`,z=M.get(F);z?z.sessions.push(L):M.set(F,{groupKey:F,displayName:B,sessions:[L]})}return{self:A,byPeer:[...M.values()]}},[a,S,C]),O=R.byPeer.length>0,P=g.useMemo(()=>j&&!O?$3(z3(a)):[],[j,O,a]);return h.jsxs("div",{"data-testid":`persona-node-${e.personaId}`,children:[h.jsxs("div",{className:re("group flex items-center gap-1 px-2 py-1.5 cursor-pointer",t?"bg-accent-dim text-text-100":"hover:bg-bg-200 text-text-200"),onClick:()=>r==null?void 0:r(e.personaId),role:"button",tabIndex:0,children:[E?h.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),c()},"aria-label":j?"collapse":"expand","aria-expanded":j,"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:j?h.jsx(Qn,{className:"h-3 w-3"}):h.jsx(zn,{className:"h-3 w-3"})}):h.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),h.jsx(Ap,{tool:e.tool,className:re("h-3.5 w-3.5 shrink-0",Lp(e.tool))}),h.jsx("span",{className:"flex-1 truncate text-[13px]",children:e.label}),E?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(c7,{className:"h-3.5 w-3.5"})}):null]}),n?h.jsx(kV,{personaId:e.personaId,tool:e.tool,onSubmit:s,onCancel:o}):null,E&&j?h.jsx("div",{"data-testid":`persona-sessions-${e.personaId}`,children:O?h.jsxs(h.Fragment,{children:[R.self.length>0&&h.jsx(ok,{groupKey:`${e.personaId}-self`,label:"我自己",testId:`persona-sessions-${e.personaId}-self`,sessions:R.self,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:w,onPinSession:x,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:T}),R.byPeer.map(A=>h.jsx(ok,{groupKey:`${e.personaId}-peer-${A.groupKey}`,label:A.displayName,testId:`persona-sessions-${e.personaId}-peer-${A.groupKey}`,sessions:A.sessions,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:w,onPinSession:x,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:T},`${e.personaId}-peer-${A.groupKey}`))]}):P.map(A=>h.jsx(e_,{node:A,depth:b?0:1,activeId:u,unreadIds:p,runningIds:f,awaitingIds:d,onSelect:M=>m==null?void 0:m(M),onDelete:v,onEdit:w,onPin:x,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:T},A.session.sessionId))}):null]})}function ok({label:e,testId:t,sessions:n,activeSessionId:r,awaitingIds:i,runningIds:s,unreadIds:o,onSelectSession:a,onDeleteSession:l,onEditSession:c,onPinSession:u,showCopyResume:d,ownerPrincipalId:f,getCreatorDisplayName:p,getSessionDisplayName:m}){const[v,w]=g.useState(!1),x=!v,_=g.useMemo(()=>x?$3(z3(n)):[],[x,n]);return h.jsxs("div",{"data-testid":t,children:[h.jsxs("button",{type:"button",onClick:()=>w(b=>!b),"aria-label":x?"collapse":"expand","aria-expanded":x,"data-testid":`${t}-chevron`,className:"flex items-center gap-1 w-full pl-7 pr-2 py-0.5 text-[11px] text-text-400 hover:text-text-200 transition-colors",children:[x?h.jsx(Qn,{className:"h-3 w-3"}):h.jsx(zn,{className:"h-3 w-3"}),h.jsx(x5,{className:"h-3 w-3","aria-hidden":!0}),h.jsx("span",{className:"truncate",children:e}),h.jsx("span",{className:"ml-auto tabular-nums",children:n.length})]}),x&&h.jsx("div",{children:_.map(b=>h.jsx(e_,{node:b,depth:2,activeId:r,unreadIds:o,runningIds:s,awaitingIds:i,onSelect:S=>a==null?void 0:a(S),onDelete:l,onEdit:c,onPin:u,showCopyResume:d,ownerPrincipalId:f,getCreatorDisplayName:p,getSessionDisplayName:m},b.session.sessionId))})]})}function kV({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=Fu(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(Ap,{tool:t,className:re("h-3 w-3 shrink-0",Lp(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(Au,{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(Xr,{className:"h-3 w-3"})})]})}function CV(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function EV(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),r=parseFloat(n.fontSize);return t*r}function IV(e){return e/100*window.innerHeight}function TV(e){return e/100*window.innerWidth}function NV(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 pc({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=NV(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=EV(t,i);break}case"em":{r=CV(t,i);break}case"vh":{r=IV(i);break}case"vw":{r=TV(i);break}}return r}function Ln(e){return parseFloat(e.toFixed(3))}function ol({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 Yv(e){const{panels:t}=e,n=ol({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=pc({groupSize:n,panelElement:i,styleProp:s.collapsedSize});o=Ln(u/n*100)}let a;if(s.defaultSize!==void 0){const u=pc({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=Ln(u/n*100)}let l=0;if(s.minSize!==void 0){const u=pc({groupSize:n,panelElement:i,styleProp:s.minSize});l=Ln(u/n*100)}let c=100;if(s.maxSize!==void 0){const u=pc({groupSize:n,panelElement:i,styleProp:s.maxSize});c=Ln(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 ct(e,t="Assertion error"){if(!e)throw Error(t)}function Xv(e,t){return Array.from(t).sort(e==="horizontal"?RV:PV)}function RV(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function PV(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function F3(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function H3(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 MV({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}=H3(r,o),c=e==="horizontal"?a:l;c<s&&(s=c,i=o)}return ct(i,"No rect found"),i}let Od;function AV(){return Od===void 0&&(typeof matchMedia=="function"?Od=!!matchMedia("(pointer:coarse)").matches:Od=!1),Od}function U3(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=Xv(n,Array.from(t.children).filter(F3).map(m=>({element:m}))).map(({element:m})=>m),o=[];let a=!1,l=!1,c=-1,u=-1,d=0,f,p=[];{let m=-1;for(const v of s)v.hasAttribute("data-panel")&&(m++,v.hasAttribute("data-disabled")||(d++,c===-1&&(c=m),u=m))}if(d>1){let m=-1;for(const v of s)if(v.hasAttribute("data-panel")){m++;const w=r.find(x=>x.element===v);if(w){if(f){const x=f.element.getBoundingClientRect(),_=v.getBoundingClientRect();let b;if(l){const S=n==="horizontal"?new DOMRect(x.right,x.top,0,x.height):new DOMRect(x.left,x.bottom,x.width,0),C=n==="horizontal"?new DOMRect(_.left,_.top,0,_.height):new DOMRect(_.left,_.top,_.width,0);switch(p.length){case 0:{b=[S,C];break}case 1:{const k=p[0],T=MV({orientation:n,rects:[x,_],targetRect:k.element.getBoundingClientRect()});b=[k,T===x?C:S];break}default:{b=p;break}}}else p.length?b=p:b=[n==="horizontal"?new DOMRect(x.right,_.top,_.left-x.right,_.height):new DOMRect(_.left,x.bottom,_.width,_.top-x.bottom)];for(const S of b){let C="width"in S?S:S.element.getBoundingClientRect();const k=AV()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(C.width<k){const E=k-C.width;C=new DOMRect(C.x-E/2,C.y,C.width+E,C.height)}if(C.height<k){const E=k-C.height;C=new DOMRect(C.x,C.y-E/2,C.width,C.height+E)}const T=m<=c||m>u;!a&&!T&&o.push({group:e,groupSize:ol({group:e}),panels:[f,w],separator:"width"in S?void 0:S,rect:C}),a=!1}}l=!1,f=w,p=[]}}else if(v.hasAttribute("data-separator")){v.ariaDisabled!==null&&(a=!0);const w=i.find(x=>x.element===v);w?p.push(w):(f=void 0,p=[])}else l=!0}return o}var Ss;class W3{constructor(){nb(this,Ss,{})}addListener(t,n){const r=Fl(this,Ss)[t];return r===void 0?Fl(this,Ss)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=Fl(this,Ss)[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(){rb(this,Ss,{})}removeListener(t,n){const r=Fl(this,Ss)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}Ss=new WeakMap;let Fa={cursorFlags:0,state:"inactive"};const n_=new W3;function jo(){return Fa}function LV(e){return n_.addListener("change",e)}function jV(e){const t=Fa,n={...Fa};n.cursorFlags=e,Fa=n,n_.emit("change",{prev:t,next:n})}function Ha(e){const t=Fa;Fa=e,n_.emit("change",{prev:t,next:e})}const DV=e=>e,ug=()=>{},q3=1,V3=2,K3=4,G3=8,ak=3,lk=12;let Bd;function ck(){return Bd===void 0&&(Bd=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(Bd=!0)),Bd}function OV({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case"active":case"hover":t.forEach(s=>{if(!s.mutableState.disableCursor)switch(s.orientation){case"horizontal":{r++;break}case"vertical":{i++;break}}})}if(!(r===0&&i===0)){switch(n){case"active":{if(e&&ck()){const s=(e&q3)!==0,o=(e&V3)!==0,a=(e&K3)!==0,l=(e&G3)!==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 ck()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const uk=new WeakMap;function r_(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=uk.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=jo();switch(r.state){case"active":case"hover":{const i=OV({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(o=>o.group),state:r.state}),s=`*, *:hover {cursor: ${i} !important; }`;if(t===s)return;t=s,i?n.cssRules.length===0?n.insertRule(s):n.replaceSync(s):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}uk.set(e,{prevStyle:t,styleSheet:n})}let di=new Map;const Y3=new W3;function BV(e){di=new Map(di),di.delete(e)}function dk(e,t){for(const[n]of di)if(n.id===e)return n}function Os(e,t){for(const[n,r]of di)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Yo(){return di}function i_(e,t){return Y3.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function Xi(e,t,n){const r=di.get(e);di=new Map(di),di.set(e,t),Y3.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:r,next:t})}function X3(e){const t=jo();let n=!1;switch(t.state){case"active":Ha({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(r_(e),n=!0,t.hitRegions.forEach(r=>{const i=Os(r.group.id,!0);Xi(r.group,i,{isUserInteraction:!0})}))}return n}function hk(e){e.defaultPrevented||X3(e.currentTarget)}function zV(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const o=H3(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 $V(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function FV(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:mk(e),b:mk(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();ct(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:pk(fk(n.a)),b:pk(fk(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 HV=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function UV(e){const t=getComputedStyle(Q3(e)??e).display;return t==="flex"||t==="inline-flex"}function WV(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||UV(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"||HV.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function fk(e){let t=e.length;for(;t--;){const n=e[t];if(ct(n,"Missing node"),WV(n))return n}return null}function pk(e){return e&&Number(getComputedStyle(e).zIndex)||0}function mk(e){const t=[];for(;e;)t.push(e),e=Q3(e);return t}function Q3(e){const{parentNode:t}=e;return $V(t)?t.host:t}function qV(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 VV({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!F3(n)||n.contains(e)||e.contains(n))return!0;if(FV(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(qV(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function s_(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=U3(i),o=zV(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&VV({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function KV(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 kn(e,t,n=0){return Math.abs(Ln(e)-Ln(t))<=n}function ai(e,t){return kn(e,t)?0:e>t?1:-1}function Ra({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(ai(r,l)<0)if(s){const c=(i+l)/2;ai(r,c)<0?r=i:r=l}else r=l;return r=Math.min(a,r),r=Ln(r),r}function gu({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(kn(e,0))return t;const o=s==="imperative-api",a=Object.values(t),l=Object.values(i),c=[...a],[u,d]=r;ct(u!=null,"Invalid first pivot index"),ct(d!=null,"Invalid second pivot index");let f=0;switch(s){case"keyboard":{{const v=e<0?d:u,w=n[v];ct(w,`Panel constraints not found for index ${v}`);const{collapsedSize:x=0,collapsible:_,minSize:b=0}=w;if(_){const S=a[v];if(ct(S!=null,`Previous layout not found for panel index ${v}`),kn(S,x)){const C=b-S;ai(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}{const v=e<0?u:d,w=n[v];ct(w,`No panel constraints found for index ${v}`);const{collapsedSize:x=0,collapsible:_,minSize:b=0}=w;if(_){const S=a[v];if(ct(S!=null,`Previous layout not found for panel index ${v}`),kn(S,b)){const C=S-x;ai(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}break}default:{const v=e<0?d:u,w=n[v];ct(w,`Panel constraints not found for index ${v}`);const x=a[v],{collapsible:_,collapsedSize:b,minSize:S}=w;if(_&&ai(x,S)<0)if(e>0){const C=S-b,k=C/2,T=x+e;ai(T,S)<0&&(e=ai(e,k)<=0?0:C)}else{const C=S-b,k=100-C/2,T=x-e;ai(T,S)<0&&(e=ai(100+e,k)>0?0:-C)}break}}{const v=e<0?1:-1;let w=e<0?d:u,x=0;for(;;){const b=a[w];ct(b!=null,`Previous layout not found for panel index ${w}`);const S=Ra({overrideDisabledPanels:o,panelConstraints:n[w],prevSize:b,size:100})-b;if(x+=S,w+=v,w<0||w>=n.length)break}const _=Math.min(Math.abs(e),Math.abs(x));e=e<0?0-_:_}{let v=e<0?u:d;for(;v>=0&&v<n.length;){const w=Math.abs(e)-Math.abs(f),x=a[v];ct(x!=null,`Previous layout not found for panel index ${v}`);const _=x-w,b=Ra({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:x,size:_});if(!kn(x,b)&&(f+=x-b,c[v]=b,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?v--:v++}}if(KV(l,c))return i;{const v=e<0?d:u,w=a[v];ct(w!=null,`Previous layout not found for panel index ${v}`);const x=w+f,_=Ra({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:w,size:x});if(c[v]=_,!kn(_,x)){let b=x-_,S=e<0?d:u;for(;S>=0&&S<n.length;){const C=c[S];ct(C!=null,`Previous layout not found for panel index ${S}`);const k=C+b,T=Ra({overrideDisabledPanels:o,panelConstraints:n[S],prevSize:C,size:k});if(kn(C,T)||(b-=T-C,c[S]=T),kn(b,0))break;e>0?S--:S++}}}const p=Object.values(c).reduce((v,w)=>w+v,0);if(!kn(p,100,.1))return i;const m=Object.keys(i);return c.reduce((v,w,x)=>(v[m[x]]=w,v),{})}function Do(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||ai(e[n],t[n])!==0)return!1;return!0}function Oo({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(!kn(i,100)&&r.length>0)for(let a=0;a<t.length;a++){const l=r[a];ct(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];ct(l!=null,`No layout data found for index ${a}`);const c=r[a];ct(c!=null,`No layout data found for index ${a}`);const u=Ra({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});c!=u&&(s+=c-u,r[a]=u)}if(!kn(s,0))for(let a=0;a<t.length;a++){const l=r[a];ct(l!=null,`No layout data found for index ${a}`);const c=l+s,u=Ra({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});if(l!==u&&(s-=u-l,r[a]=u,kn(s,0)))break}const o=Object.keys(e);return r.reduce((a,l,c)=>(a[o[c]]=l,a),{})}function Z3({groupId:e,panelId:t}){const n=()=>{const l=Yo();for(const[c,{defaultLayoutDeferred:u,derivedPanelConstraints:d,layout:f,groupSize:p,separatorToPanels:m}]of l)if(c.id===e)return{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:c,groupSize:p,layout:f,separatorToPanels:m};throw Error(`Group ${e} not found`)},r=()=>{const l=n().derivedPanelConstraints.find(c=>c.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const l=n().group.panels.find(c=>c.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const l=n().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:l,panels:c,prevLayout:u,derivedPanelConstraints:d})=>{const f=s(),p=c.findIndex(w=>w.id===t),m=p===0,v=p===c.length-1;if(v&&l<f&&(m||c.slice(0,p).every((w,x)=>{const _=d[x];return(_==null?void 0:_.collapsible)&&kn(_.collapsedSize,u[_.panelId])}))){const w=c.slice(0,p).reduce((x,_)=>x+u[_.id],0);return{...u,[t]:Ln(100-w)}}return gu({delta:v?f-l:l-f,initialLayout:u,panelConstraints:d,pivotIndices:v?[p-1,p]:[p,p+1],prevLayout:u,trigger:"imperative-api"})},a=l=>{const c=s();if(l===c)return;const{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:f,groupSize:p,layout:m,separatorToPanels:v}=n(),w=o({nextSize:l,panels:f.panels,prevLayout:m,derivedPanelConstraints:d}),x=Oo({layout:w,panelConstraints:d});Do(m,x)||Xi(f,{defaultLayoutDeferred:u,derivedPanelConstraints:d,groupSize:p,layout:x,separatorToPanels:v})};return{collapse:()=>{const{collapsible:l,collapsedSize:c}=r(),{mutableValues:u}=i(),d=s();l&&d!==c&&(u.expandToSize=d,a(c))},expand:()=>{const{collapsible:l,collapsedSize:c,minSize:u}=r(),{mutableValues:d}=i(),f=s();if(l&&f===c){let p=d.expandToSize??u;p===0&&(p=1),a(p)}},getSize:()=>{const{group:l}=n(),c=s(),{element:u}=i(),d=l.orientation==="horizontal"?u.offsetWidth:u.offsetHeight;return{asPercentage:c,inPixels:d}},isCollapsed:()=>{const{collapsible:l,collapsedSize:c}=r(),u=s();return l&&kn(c,u)},resize:l=>{const{group:c}=n(),{element:u}=i(),d=ol({group:c}),f=pc({groupSize:d,panelElement:u,styleProp:l}),p=Ln(f/d*100);a(p)}}}function gk(e){if(e.defaultPrevented)return;const t=Yo();s_(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=Z3({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function wh(e){const t=Yo();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 J3({groupId:e}){const t=()=>{const n=Yo();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=Oo({layout:n,panelConstraints:i});return r?a:(Do(a,c)||Xi(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:o,layout:c,separatorToPanels:l}),c)}}}function oo(e,t){const n=wh(e),r=Os(n.id,!0),i=n.separators.find(u=>u.element===e);ct(i,"Matching separator not found");const s=r.separatorToPanels.get(i);ct(s,"Matching panels not found");const o=s.map(u=>n.panels.indexOf(u)),a=J3({groupId:n.id}).getLayout(),l=gu({delta:t,initialLayout:a,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),c=Oo({layout:l,panelConstraints:r.derivedPanelConstraints});Do(a,c)||Xi(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function vk(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=wh(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&oo(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&oo(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&oo(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&oo(t,-5);break}case"End":{e.preventDefault(),oo(t,100);break}case"Enter":{e.preventDefault();const r=wh(t),i=Os(r.id,!0),{derivedPanelConstraints:s,layout:o,separatorToPanels:a}=i,l=r.separators.find(f=>f.element===t);ct(l,"Matching separator not found");const c=a.get(l);ct(c,"Matching panels not found");const u=c[0],d=s.find(f=>f.panelId===u.id);if(ct(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;oo(t,p-f)}break}case"F6":{e.preventDefault();const r=wh(t).separators.map(o=>o.element),i=Array.from(r).findIndex(o=>o===e.currentTarget);ct(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(),oo(t,-100);break}}}function xk(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=Yo(),n=s_(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)}),Ha({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function eR({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:s,prevCursorFlags:o}){let a=0;n.forEach(c=>{const{group:u,groupSize:d}=c,{orientation:f,panels:p}=u,{disableCursor:m}=u.mutableState;let v=0;s?f==="horizontal"?v=(t.clientX-s.x)/d*100:v=(t.clientY-s.y)/d*100:f==="horizontal"?v=t.clientX<0?-100:100:v=t.clientY<0?-100:100;const w=r.get(u),x=i.get(u);if(!w||!x)return;const{defaultLayoutDeferred:_,derivedPanelConstraints:b,groupSize:S,layout:C,separatorToPanels:k}=x;if(b&&C&&k){const T=gu({delta:v,initialLayout:w,panelConstraints:b,pivotIndices:c.panels.map(E=>p.indexOf(E)),prevLayout:C,trigger:"mouse-or-touch"});if(Do(T,C)){if(v!==0&&!m)switch(f){case"horizontal":{a|=v<0?q3:V3;break}case"vertical":{a|=v<0?K3:G3;break}}}else Xi(c.group,{defaultLayoutDeferred:_,derivedPanelConstraints:b,groupSize:S,layout:T,separatorToPanels:k})}});let l=0;t.movementX===0?l|=o&ak:l|=a&ak,t.movementY===0?l|=o&lk:l|=a&lk,jV(l),r_(e)}function yk(e){const t=Yo(),n=jo();switch(n.state){case"active":eR({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function _k(e){var r,i;if(e.defaultPrevented)return;const t=jo(),n=Yo();switch(t.state){case"active":{if(e.buttons===0){Ha({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const o=Os(s.group.id,!0);Xi(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))}eR({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=s_(e,n);s.length===0?t.state!=="inactive"&&Ha({cursorFlags:0,state:"inactive"}):Ha({cursorFlags:0,hitRegions:s,state:"hover"}),r_(e.currentTarget);break}}}function bk(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(jo().state){case"hover":Ha({cursorFlags:0,state:"inactive"})}}function wk(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||X3(e.currentTarget)&&e.preventDefault()}function Sk(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const o=Ln(s.defaultSize);n+=o,r[s.panelId]=o}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=Ln((100-n)/i);for(const o of e)o.defaultSize===void 0&&(r[o.panelId]=s)}return r}function GV(e,t,n){if(!n[0])return;const r=e.panels.find(l=>l.element===t);if(!r||!r.onResize)return;const i=ol({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,a={asPercentage:Ln(s/i*100),inPixels:s};r.mutableValues.prevSize=a,r.onResize(a,r.id,o)}function YV(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 XV({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=Ln(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]=Ln(f/s*c)}else{const d=Ln(c/l.length);for(const f of l)u[f]=d}return u}function QV(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 ca=new Map;function ZV(e){let t=!0;ct(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,s=new n(m=>{for(const v of m){const{borderBoxSize:w,target:x}=v;if(x===e.element){if(t){const _=ol({group:e});if(_===0)return;const b=Os(e.id);if(!b)return;const S=Yv(e),C=b.defaultLayoutDeferred?Sk(S):b.layout,k=XV({group:e,nextGroupSize:_,prevGroupSize:b.groupSize,prevLayout:C}),T=Oo({layout:k,panelConstraints:S});if(!b.defaultLayoutDeferred&&Do(b.layout,T)&&YV(b.derivedPanelConstraints,S)&&b.groupSize===_)return;Xi(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:S,groupSize:_,layout:T,separatorToPanels:b.separatorToPanels})}}else GV(e,x,w)}});s.observe(e.element),e.panels.forEach(m=>{ct(!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=ol({group:e}),a=Yv(e),l=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(QV(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[l]??c??Sk(a),d=Oo({layout:u,panelConstraints:a}),f=e.element.ownerDocument;ca.set(f,(ca.get(f)??0)+1);const p=new Map;return U3(e).forEach(m=>{m.separator&&p.set(m.separator,m.panels)}),Xi(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:a,groupSize:o,layout:d,separatorToPanels:p}),e.separators.forEach(m=>{ct(!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",vk)}),ca.get(f)===1&&(f.addEventListener("contextmenu",hk,!0),f.addEventListener("dblclick",gk,!0),f.addEventListener("pointerdown",xk,!0),f.addEventListener("pointerleave",yk),f.addEventListener("pointermove",_k),f.addEventListener("pointerout",bk),f.addEventListener("pointerup",wk,!0)),function(){t=!1,ca.set(f,Math.max(0,(ca.get(f)??0)-1)),BV(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",vk)}),ca.get(f)||(f.removeEventListener("contextmenu",hk,!0),f.removeEventListener("dblclick",gk,!0),f.removeEventListener("pointerdown",xk,!0),f.removeEventListener("pointerleave",yk),f.removeEventListener("pointermove",_k),f.removeEventListener("pointerout",bk),f.removeEventListener("pointerup",wk,!0)),s.disconnect()}}function JV(){const[e,t]=g.useState({}),n=g.useCallback(()=>t({}),[]);return[e,n]}function o_(e){const t=g.useId();return`${e??t}`}const Xo=typeof window<"u"?g.useLayoutEffect:g.useEffect;function Lc(e){const t=g.useRef(e);return Xo(()=>{t.current=e},[e]),g.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function a_(...e){return Lc(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function l_(e){const t=g.useRef({...e});return Xo(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const tR=g.createContext(null);function eK(e,t){const n=g.useRef({getLayout:()=>({}),setLayout:DV});g.useImperativeHandle(t,()=>n.current,[]),Xo(()=>{Object.assign(n.current,J3({groupId:e}))})}function c_({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=Lc(O=>{Do(m.current.onLayoutChange,O)||(m.current.onLayoutChange=O,l==null||l(O))}),w=Lc((O,P)=>{Do(m.current.onLayoutChanged,O)||(m.current.onLayoutChanged=O,c==null||c(O,{isUserInteraction:P}))}),x=o_(a),_=g.useRef(null),[b,S]=JV(),C=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),k=a_(_,s);eK(x,o);const T=Lc((O,P)=>{const A=jo(),M=dk(O),L=Os(O);if(L){let $=!1;switch(A.state){case"active":{$=A.hitRegions.some(F=>F.group===M);break}}return{flexGrow:L.layout[P]??1,pointerEvents:$?"none":void 0}}if(n!=null&&n[P])return{flexGrow:n==null?void 0:n[P]}}),E=l_({defaultLayout:n,disableCursor:r}),j=g.useMemo(()=>({get disableCursor(){return!!E.disableCursor},getPanelStyles:T,id:x,orientation:u,registerPanel:O=>{const P=C.current;return P.panels=Xv(u,[...P.panels,O]),S(),()=>{P.panels=P.panels.filter(A=>A!==O),S()}},registerSeparator:O=>{const P=C.current;return P.separators=Xv(u,[...P.separators,O]),S(),()=>{P.separators=P.separators.filter(A=>A!==O),S()}},updatePanelProps:(O,{disabled:P})=>{const A=C.current.panels.find($=>$.id===O);A&&(A.panelConstraints.disabled=P);const M=dk(x),L=Os(x);M&&L&&Xi(M,{...L,derivedPanelConstraints:Yv(M)})},updateSeparatorProps:(O,{disabled:P,disableDoubleClick:A})=>{const M=C.current.separators.find(L=>L.id===O);M&&(M.disabled=P,M.disableDoubleClick=A)}}),[T,x,S,u,E]),R=g.useRef(null);return Xo(()=>{const O=_.current;if(O===null)return;const P=C.current;let A;if(E.defaultLayout!==void 0&&Object.keys(E.defaultLayout).length===P.panels.length){A={};for(const I of P.panels){const U=E.defaultLayout[I.id];U!==void 0&&(A[I.id]=U)}}const M={disabled:!!i,element:O,id:x,mutableState:{defaultLayout:A,disableCursor:!!E.disableCursor,expandedPanelSizes:C.current.lastExpandedPanelSizes,layouts:C.current.layouts},orientation:u,panels:P.panels,resizeTargetMinimumSize:P.resizeTargetMinimumSize,separators:P.separators};R.current=M;const L=ZV(M),{defaultLayoutDeferred:$,derivedPanelConstraints:F,layout:B}=Os(M.id,!0);!$&&F.length>0&&(v(B),w(B,!1));const z=i_(x,I=>{const{defaultLayoutDeferred:U,derivedPanelConstraints:q,layout:D}=I.next;if(U||q.length===0)return;const te=M.panels.map(({id:G})=>G).join(",");M.mutableState.layouts[te]=D,q.forEach(G=>{if(G.collapsible){const{layout:me}=I.prev??{};if(me){const Ie=kn(G.collapsedSize,D[G.panelId]),ce=kn(G.collapsedSize,me[G.panelId]);Ie&&!ce&&(M.mutableState.expandedPanelSizes[G.panelId]=me[G.panelId])}}});const ie=jo().state!=="active";v(D),ie&&w(D,I.isUserInteraction)});return()=>{R.current=null,L(),z()}},[i,x,w,v,u,b,E]),g.useEffect(()=>{const O=R.current;O&&(O.mutableState.defaultLayout=n,O.mutableState.disableCursor=!!r)}),h.jsx(tR.Provider,{value:j,children:h.jsx("div",{...p,className:t,"data-group":!0,"data-testid":x,id:x,ref:k,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:u==="horizontal"?"pan-y":"pan-x"},children:e})})}c_.displayName="Group";function u_(){const e=g.useContext(tR);return ct(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function tK(e,t){const{id:n}=u_(),r=g.useRef({collapse:ug,expand:ug,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:ug});g.useImperativeHandle(t,()=>r.current,[]),Xo(()=>{Object.assign(r.current,Z3({groupId:n,panelId:e}))})}function Mf({children:e,className:t,collapsedSize:n="0%",collapsible:r=!1,defaultSize:i,disabled:s,elementRef:o,groupResizeBehavior:a="preserve-relative-size",id:l,maxSize:c="100%",minSize:u="0%",onResize:d,panelRef:f,style:p,...m}){const v=!!l,w=o_(l),x=l_({disabled:s}),_=g.useRef(null),b=a_(_,o),{getPanelStyles:S,id:C,orientation:k,registerPanel:T,updatePanelProps:E}=u_(),j=d!==null,R=Lc((M,L,$)=>{d==null||d(M,l,$)});Xo(()=>{const M=_.current;if(M!==null){const L={element:M,id:w,idIsStable:v,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:j?R:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:r,defaultSize:i,disabled:x.disabled,maxSize:c,minSize:u}};return T(L)}},[a,n,r,i,j,w,v,c,u,R,T,x]),g.useEffect(()=>{E(w,{disabled:s})},[s,w,E]),tK(w,f);const O=()=>{const M=S(C,w);if(M)return JSON.stringify(M)},P=g.useSyncExternalStore(M=>i_(C,M),O,O);let A;return P?A=JSON.parse(P):i!==void 0?A={flexGrow:void 0,flexShrink:void 0,flexBasis:i}:A={flexGrow:1},h.jsx("div",{...m,"data-disabled":s||void 0,"data-panel":!0,"data-testid":w,id:w,ref:b,style:{...nK,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...A},children:h.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...p,touchAction:k==="horizontal"?"pan-y":"pan-x"},children:e})})}Mf.displayName="Panel";const nK={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function rK({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=Oo({layout:gu({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=Oo({layout:gu({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:o}}function nR({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:s,style:o,...a}){const l=o_(s),c=l_({disabled:n,disableDoubleClick:r}),[u,d]=g.useState({}),[f,p]=g.useState("inactive"),[m,v]=g.useState(!1),w=g.useRef(null),x=a_(w,i),{disableCursor:_,id:b,orientation:S,registerSeparator:C,updateSeparatorProps:k}=u_(),T=S==="horizontal"?"vertical":"horizontal";Xo(()=>{const R=w.current;if(R!==null){const O={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:R,id:l},P=C(O),A=LV(L=>{p(L.next.state!=="inactive"&&L.next.hitRegions.some($=>$.separator===O)?L.next.state:"inactive")}),M=i_(b,L=>{const{derivedPanelConstraints:$,layout:F,separatorToPanels:B}=L.next,z=B.get(O);if(z){const I=z[0],U=z.indexOf(I);d(rK({layout:F,panelConstraints:$,panelId:I.id,panelIndex:U}))}});return()=>{A(),M(),P()}}},[b,l,C,c]),g.useEffect(()=>{k(l,{disabled:n,disableDoubleClick:r})},[n,r,l,k]);let E;n&&!_&&(E="not-allowed");let j;if(n)j="disabled";else switch(f){case"active":{j="active";break}default:m?j="focus":j=f}return h.jsx("div",{...a,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":T,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":j,"data-testid":l,id:l,onBlur:()=>v(!1),onFocus:()=>v(!0),ref:x,role:"separator",style:{flexBasis:"auto",cursor:E,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}nR.displayName="Separator";function iK(e){if(!e)return;const t=e.contextUsage,n=e.contextWindowSize;if(!t||!n||n<=0)return;const r=t.inputTokens+(t.cacheReadTokens??0)+(t.cacheCreateTokens??0);if(!(r<=0))return Math.round(r/n*100)}function rR(e,t){const n=Qs(),r=e?`session/${e}`:"",i=Ki(r)??uu,s=g.useCallback(d=>{!e||!r||n.setData(r,f=>r5(f??uu,d,e))},[n,r,e]),o=g.useCallback(()=>{e&&s({type:"session:change",sessionId:e})},[s,e]),a=g.useCallback(d=>{e&&s({type:"permission:clear",sessionId:e,requestId:d})},[s,e]),l=g.useCallback(d=>{e&&s({type:"permission:request",sessionId:e,requestId:d.requestId,tool:d.tool,input:d.input,...d.toolUseId?{toolUseId:d.toolUseId}:{}})},[s,e]),c=g.useCallback(d=>{e&&s({type:"session:question:clear",sessionId:e,toolUseId:d})},[s,e]),u=g.useCallback((d,f)=>{e&&s({type:"session:question:submitted",sessionId:e,toolUseId:d,answers:f})},[s,e]);return{...i,reset:o,clearPermission:a,restorePermission:l,clearQuestion:c,markQuestionSubmitted:u}}function sK(e){return e.kind!=="user-text"?!1:e.meta===void 0||e.meta==="slash-command"||Rp(e.meta)}function oK(e,t={}){let n=0;if(t.implicitCloseOnUserText){for(const r of e)sK(r)&&n++;return n}for(const r of e)r.kind==="turn-end"&&n++;return n}const aK=g.createContext(null);function iR(){return g.useContext(aK)}const lK=50;function cK({api:e,sessionId:t,focused:n=!0,toolSessionId:r,initialTurns:i,implicitCloseOnUserText:s,pageSize:o=lK,enabled:a=!0,refreshVersion:l=0}){const c=iR(),[u,d]=g.useState({messages:[],total:0,loading:!1,error:null}),f=g.useRef(r),p=g.useRef(n),m=g.useRef(null),v=g.useRef(l),w=g.useRef(0),x=g.useRef(!0);return g.useEffect(()=>(x.current=!0,()=>{x.current=!1}),[]),g.useEffect(()=>{const _=f.current;f.current=r;const b=n&&!p.current;if(p.current=n,!a){m.current!==null&&(m.current=null,++w.current,d({messages:[],total:0,loading:!1,error:null}));return}const S=m.current!==t,C=v.current!==l;v.current=l;const k=typeof _=="string"&&_!==r,T=b&&u.error!==null;if(_!==r&&(c==null||c.push({level:"info",msg:"chatflow.history.identity",sessionId:t,meta:{previousToolSessionId:_??null,toolSessionId:r??null,willReload:S||k}})),!S&&!k&&!T&&!C)return;if((S||k)&&d({messages:[],total:0,loading:!1,error:null}),!t){m.current=null;return}m.current=t;const E=++w.current;c==null||c.push({level:"info",msg:"chatflow.history.read.start",sessionId:t,meta:{toolSessionId:r??null,initialTurns:i??null,pageSize:i===void 0?null:o,readSeq:E}}),d(j=>({...j,loading:!0,error:null})),(async()=>{var M;let j=[],R=!1,O,P=i===void 0?{}:{limit:o},A=Number.POSITIVE_INFINITY;for(;;){let L;try{L=await e.historyRead({sessionId:t,...P})}catch(q){if(E!==w.current||!x.current)return;const D=q.message??"history load failed";c==null||c.push({level:"warn",msg:"chatflow.history.read.error",sessionId:t,meta:{readSeq:E,shown:R,errorCode:q&&typeof q=="object"&&"code"in q?String(q.code):null}}),d(te=>({...te,loading:!1,error:D}));return}if(E!==w.current||!x.current)return;c==null||c.push({level:"info",msg:"chatflow.history.read.result",sessionId:t,meta:{readSeq:E,pageMessages:((M=L.messages)==null?void 0:M.length)??0,total:L.total??0,offset:L.offset??null}}),O&&L.snapshotId&&O!==L.snapshotId&&(j=[],R=!1,A=Number.POSITIVE_INFINITY,d({messages:[],total:0,loading:!0,error:null})),O=L.snapshotId,j=[...L.messages??[],...j];const $=L.total??0,F=typeof L.offset=="number"?L.offset:0,B=F>=A,z=F<=0||B;A=F;const I=i!==void 0&&oK(j,{implicitCloseOnUserText:s})>=i;if(R?d({messages:j,total:$,loading:!1,error:null}):(z||I)&&(R=!0,d({messages:j,total:$,loading:!1,error:null})),z)return;const U=Math.max(0,F-o);P={offset:U,limit:F-U,...O?{snapshotId:O}:{}}}})()},[e,t,r,n,o,i,a,l,c]),u}const uK=["TaskCreate","TaskUpdate","TaskList","TaskGet"];function dK(e){return uK.includes(e)}function sR(e){return e==="in_progress"||e==="completed"?e:"pending"}function hK(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:sR(n.status),activeForm:i,description:s}]}function fK(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=sR(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 pK(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=hK(t,i.input);break;case"TaskUpdate":t=fK(t,i.input);break}}return{tasks:t,lastEventIndex:n}}function mK(e){return e==="TodoWrite"}function gK(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 Sh(e,t,n){var o;const r=[],i=new Map;for(let a=0;a<e.length;a++){const l=e[a],c=typeof l.seq=="number"?l.seq:a;switch(l.kind){case"session_init":r.push({kind:"session-init",seq:c,toolSessionId:l.toolSessionId});break;case"text":kk(r,c,"assistant-text",l.text,l.partialId,l.uuid);break;case"thinking":kk(r,c,"assistant-thinking",l.text,l.partialId);break;case"user_text":{l.meta==="task-notification"?r.push({kind:"agent-notification",seq:c,text:l.text,taskId:l.taskId,parentToolUseId:l.parentToolUseId}):l.meta?r.push({kind:"user-meta",seq:c,metaKind:l.meta,text:l.text}):r.push({kind:"user-text",seq:c,text:l.text,uuid:l.uuid,...l.sender&&(l.sender.principal!=="owner"||GN.test(l.text))?{senderDisplayName:l.sender.displayName}:{},senderPrincipal:((o=l.sender)==null?void 0:o.principal)==="guest"?"guest":"owner"});break}case"tool_call":oR(r,c,l.toolUseId,l.tool,l.input,l.toolKind);break;case"tool_result":{const u=i.get(l.toolUseId);if(u!==void 0){if(l.askQuestionAnswers){const f=r[u];f.submittedAnswers=l.askQuestionAnswers}i.delete(l.toolUseId);break}const d={kind:"tool-result",seq:c,toolUseId:l.toolUseId,output:l.output,error:l.error};l.toolResultExtra&&(d.toolResultExtra=l.toolResultExtra),r.push(d);break}case"attachment_memories":r.push({kind:"memory-callout",seq:c,memories:l.memories});break;case"permission_request":{if(!t||l.requestId!==t)break;r.push({kind:"permission-inline",seq:c,requestId:l.requestId,tool:l.tool,input:l.input});break}case"ask_user_question":i.set(l.toolUseId,r.length),r.push({kind:"question-card",seq:c,toolUseId:l.toolUseId,questions:l.questions});break;case"turn_end":{const u={kind:"turn-end",seq:c};l.durationMs!==void 0&&(u.durationMs=l.durationMs),l.reason!==void 0&&(u.reason=l.reason),l.turnId!==void 0&&(u.turnId=l.turnId),r.push(u);break}case"subagent_progress":{const u={kind:"agent-progress",seq:c,toolUseId:l.toolUseId,agentId:l.agentId,status:l.status};l.description&&(u.description=l.description),l.lastToolName&&(u.lastToolName=l.lastToolName),l.prompt&&(u.prompt=l.prompt),l.stats&&(u.stats=l.stats),r.push(u);break}case"error":r.push({kind:"error",seq:c,message:l.message});break}}const s=new Map(e.flatMap((a,l)=>a.turnId?[[a.seq??l,a.turnId]]:[]));for(const a of r){const l=s.get(a.seq);l&&(a.turnId=l)}return r}function oR(e,t,n,r,i,s){if(mK(r)){const o=gK(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(dK(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 kk(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 vK="AskUserQuestion";function d_(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=GN.exec(a.text??""),d=(o=A9.exec(a.text??""))==null?void 0:o[1],f=(u==null?void 0:u[2])??d,p=(u==null?void 0:u[1])==="guest"||d?"guest":"owner";r.push({kind:"user-text",seq:l,text:a.text??"",uuid:a.uuid,...f?{senderDisplayName:f}:{},senderPrincipal:p})}break;case"assistant-text":r.push({kind:"assistant-text",seq:l,text:a.text??"",uuid:a.uuid});break;case"tool_call":{if(a.tool===vK){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}oR(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),typeof a.turnId=="string"&&(u.turnId=a.turnId),r.push(u);break}}}return r}const xK=5e5;function yK(e){const t=xK-e.length;return e.map(n=>({...n,seq:n.seq+t}))}const _r=e=>typeof e=="string"?e:"",Ck=e=>Array.isArray(e)?e.filter(t=>typeof t=="string"):[];function _K(e){var s;if(e.type==="userMessage"){const a=(Array.isArray(e.content)?e.content:[]).map(c=>c.type==="text"?_r(c.text):c.type==="image"?`})`:c.type==="localImage"?`[图片](${_r(c.path)})`:"").filter(Boolean).join(`
|
|
517
517
|
`),l=L9(a);return d_([{kind:"user-text",text:a,uuid:e.id,...l?{meta:l==="task"?"dispatch-task":"dispatch-result"}:{}}],0,"codex")}if(e.type==="agentMessage")return[{kind:"assistant-text",seq:0,text:_r(e.text),uuid:e.id}];if(e.type==="reasoning")return[{kind:"assistant-thinking",seq:0,text:[...Ck(e.summary),...Ck(e.content)].join(`
|
|
518
518
|
`)}];if(e.type==="plan")return[{kind:"assistant-text",seq:0,text:_r(e.text),uuid:e.id}];if(e.type==="hookPrompt"||e.type==="contextCompaction")return[];if(e.type==="subAgentActivity"){const o=_r(e.agentThreadId);return e.kind==="started"?Sh([{kind:"tool_call",tool:"Agent",toolKind:"codex",toolUseId:`codex-agent-${o}`,input:{agentId:o,description:_r(e.agentPath)}}]):e.kind==="completed"||e.kind==="interrupted"?Sh([{kind:"tool_result",toolUseId:`codex-agent-${o}`,output:e.kind==="completed"?"已完成":"已中断"}]):[]}const t=e.type==="mcpToolCall"?`${_r(e.server)}.${_r(e.tool)}`:e.type==="dynamicToolCall"?_r(e.tool):e.type,n=e.type==="commandExecution"?{command:e.command,cwd:e.cwd}:e.type==="fileChange"?{changes:e.changes}:e.arguments??e,r=e.type==="commandExecution"?e.aggregatedOutput:e.type==="fileChange"?(Array.isArray(e.changes)?e.changes:[]).map(o=>_r(o.diff)).join(`
|
|
519
|
-
`):e.result??e.contentItems??e.output??e,i=e.status==="failed"||e.status==="declined"||e.success===!1?_r((s=e.error)==null?void 0:s.message)||"执行失败":e.type==="commandExecution"&&typeof e.exitCode=="number"&&e.exitCode!==0?`exit ${e.exitCode}`:void 0;return Sh([{kind:"tool_call",tool:t,toolKind:"codex",toolUseId:e.id,input:n},{kind:"tool_result",toolUseId:e.id,output:r,...i?{error:i}:{}}])}function bK(e,t,n){const r=new Set,s=(t===void 0?e.items:[...e.items.filter(a=>a.type==="userMessage"&&!t.some(l=>l.id===a.id)),...t,...e.items.filter(a=>a.type!=="userMessage"&&!t.some(l=>l.id===a.id))]).flatMap(a=>r.has(a.id)?[]:(r.add(a.id),_K(a)));let o=!1;for(const a of s)a.kind==="user-text"&&(o&&(a.continuesTurn=!0),o=!0);return e.error&&s.push({kind:"error",seq:0,message:e.error.message}),s.push({kind:"turn-end",seq:0,turnId:e.id,...e.durationMs!==null?{durationMs:e.durationMs}:{},reason:e.status==="interrupted"?"interrupted":"completed"}),s.map((a,l)=>({...a,seq:n+l}))}function wK(e,t){const n=new Set(t.flatMap(s=>s.turnId?[s.turnId]:[])),r=new Set(t.flatMap(s=>"uuid"in s&&s.uuid?[s.uuid]:[]));let i=0;for(let s=0;s<e.length;s++){const o=e[s];if(o.kind==="turn-end"){if(o.turnId&&n.has(o.turnId))return e.slice(0,i);i=s+1}else if("uuid"in o&&o.uuid&&r.has(o.uuid))return e.slice(0,i)}return e}const zd=()=>({turns:[],details:{},nextCursor:null,loading:!1,loadingOlder:!1,error:null});function dg(e,t){if(e.view!==t||!Array.isArray(e.data))throw new Error("历史分页需要更新对端 daemon;未退回全量加载")}function SK(e){const{api:t,sessionId:n,toolSessionId:r,enabled:i,focused:s=!0,refreshVersion:o=0}=e,a=`${i}:${n}:${r??""}`,l=g.useRef(a);l.current=a;const c=g.useRef(0),u=g.useRef(!0),[d,f]=g.useState(zd),p=g.useRef(d);p.current=d;const m=g.useRef(!1),v=g.useRef(new Set),w=g.useRef();g.useEffect(()=>(u.current=!0,()=>{u.current=!1}),[]);const x=g.useCallback(async()=>{if(!i||!r)return;const k=++c.current,T=a;m.current=!1,v.current.clear(),f(E=>({...E,loading:!0,loadingOlder:!1,error:null}));try{const E=await t.historyPage({sessionId:n,view:"turns",limit:10});if(dg(E,"turns"),!u.current||c.current!==k||l.current!==T||E.view!=="turns")return;f({...zd(),turns:[...E.data].reverse(),snapshotId:E.snapshotId,nextCursor:E.nextCursor})}catch(E){if(!u.current||c.current!==k||l.current!==T)return;f(j=>({...j,loading:!1,error:E.message}))}},[t,a,i,r,n]);g.useEffect(()=>{if(!i||!r){c.current++,w.current=void 0,f(zd());return}if(!s)return;const k=w.current;(k==null?void 0:k.identity)===a&&k.version===o&&k.api===t||(((k==null?void 0:k.identity)!==a||k.api!==t)&&f(zd()),w.current={identity:a,version:o,api:t},x())},[t,a,i,r,s,o,x]);const _=g.useCallback(async()=>{const k=p.current;if(!i||k.loading||m.current||!k.nextCursor||!k.snapshotId)return;const T=c.current,E=a;m.current=!0,f(j=>({...j,loadingOlder:!0,error:null}));try{const j=await t.historyPage({sessionId:n,view:"turns",limit:10,cursor:k.nextCursor,snapshotId:k.snapshotId});if(dg(j,"turns"),!u.current||T!==c.current||E!==l.current||j.view!=="turns")return;if(j.snapshotId!==k.snapshotId||j.nextCursor===k.nextCursor)throw new Error("历史分页快照或游标失效,请刷新历史");f(R=>{const O=new Set(R.turns.map(P=>P.id));return{...R,turns:[...j.data.filter(P=>!O.has(P.id)).reverse(),...R.turns],nextCursor:j.nextCursor,loadingOlder:!1}})}catch(j){u.current&&T===c.current&&E===l.current&&f(R=>({...R,loadingOlder:!1,error:j.message}))}finally{T===c.current&&(m.current=!1)}},[t,i,a,n]),b=g.useCallback(async(k,T=!1)=>{const E=p.current,j=E.details[k];if(!i||E.loading||!E.snapshotId||v.current.has(k)||j&&!j.error&&!T||T&&!(j!=null&&j.nextCursor))return;const R=c.current,O=a;v.current.add(k);const P=j??{items:[],loading:!1,error:null,nextCursor:null};f(A=>({...A,details:{...A.details,[k]:{...P,loading:!0,error:null}}}));try{const A=await t.historyPage({sessionId:n,view:"items",turnId:k,limit:50,snapshotId:E.snapshotId,...j!=null&&j.nextCursor?{cursor:j.nextCursor}:{}});if(dg(A,"items"),!u.current||R!==c.current||O!==l.current||A.view!=="items")return;if(A.snapshotId!==E.snapshotId||j!=null&&j.nextCursor&&A.nextCursor===j.nextCursor)throw new Error("轮次详情快照或游标失效,请刷新历史");if(A.data.some($=>$.turnId!==k))throw new Error("轮次详情身份不匹配");const M=new Set(P.items.map($=>$.id)),L=[...P.items,...A.data.map($=>$.item).filter($=>!M.has($.id))];f($=>({...$,details:{...$.details,[k]:{items:L,loading:!1,error:null,nextCursor:A.nextCursor}}}))}catch(A){u.current&&R===c.current&&O===l.current&&f(M=>({...M,details:{...M.details,[k]:{...P,loading:!1,error:A.message}}}))}finally{R===c.current&&v.current.delete(k)}},[t,i,a,n]),S=g.useMemo(()=>d.turns.flatMap((k,T)=>{var E;return bK(k,(E=d.details[k.id])==null?void 0:E.items,(T-d.turns.length)*1e6)}),[d.turns,d.details]),C=g.useMemo(()=>S.map(k=>({kind:k.kind,..."text"in k?{text:k.text}:{},..."uuid"in k?{uuid:k.uuid}:{}})),[S]);return{...d,lines:S,messages:C,total:d.turns.length,loadOlder:_,loadDetails:b,refresh:x}}const kK=/<command-name>([\s\S]*?)<\/command-name>/i,CK=/<command-message>([\s\S]*?)<\/command-message>/i,EK=/<command-args>([\s\S]*?)<\/command-args>/i,IK=/<(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(kK),n=e.match(CK),r=e.match(EK);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(IK,""),i=i.trim(),{commandName:t?t[1].trim():null,commandMessage:n?n[1].trim():null,commandArgs:r?r[1].trim():null,body:i}}function Ek(e){const t=Yp(e);return t.commandName?t.commandArgs?`${t.commandName} ${t.commandArgs}`:t.commandName:e}function Ik(e){return e.kind==="user-text"?!0:e.kind!=="user-meta"?!1:e.metaKind==="slash-command"||Rp(e.metaKind)}function TK(e,t){const n=t.find(Ik);if(!n)return e;const r=Ek(n.text);for(let s=e.length-1;s>=0;s--){const o=e[s];if(Ik(o)&&Ek(o.text)===r)return e.slice(0,s)}const i=e[e.length-1];return i!==void 0&&i.kind!=="turn-end"?[...e,{kind:"turn-end",seq:i.seq+1}]:e}function NK(e){return e==="running"||e==="observing"}function aR(e){return e==="running"||e==="running-idle"||e==="observing"}const RK=1e6,PK=5;function lR(e,t=!0){const n=iR(),r=Ji(),i=g.useMemo(()=>new _y(r),[r]),s=Ki("sessions"),o=g.useMemo(()=>s==null?void 0:s.find(se=>se.sessionId===e),[s,e]),a=o==null?void 0:o.toolSessionId,l=o==null?void 0:o.tool,[c,u]=g.useState(0),[d,f]=g.useState(null),p=Qs(),m=g.useRef(p);m.current=p;const[v,w]=g.useState(null),x=g.useRef(null),_=g.useRef(null);g.useEffect(()=>(f(null),w(null),_.current=null,r.on("session:control",se=>{const We=se;if(!((We==null?void 0:We.sessionId)!==e||We.kind!==QB))if(We.synchronized===!0){const Ce=m.current.read(`session/${e}`);Ce!=null&&Ce.events.length&&w({first:Ce.events[0],count:Ce.events.length,historyBefore:x.current}),f(null),u($e=>$e+1)}else f("断线期间的部分内容未显示,完整内容已保存在云端")})),[r,e]);const b=g.useCallback(()=>{const se=m.current.read(`session/${e}`),We=(se==null?void 0:se.events)??[];let Ce=We.length;for(;Ce>0&&We[Ce-1].kind!=="turn_end";)Ce--;Ce>0&&w({first:We[0],count:Ce,historyBefore:x.current}),_.current={historyBefore:x.current},u($e=>$e+1)},[e]),S=rR(e),{events:C,pendingPermissions:k,queued:T,status:E,clearPermission:j,restorePermission:R}=S,O=az(),P=l==="codex"||l==="codex-cloud",A=cK({api:i,sessionId:e,focused:t,toolSessionId:a,enabled:O!==void 0&&!P,refreshVersion:c,initialTurns:O==="owner"?void 0:PK,implicitCloseOnUserText:l==="codex"}),M=SK({api:i,sessionId:e,focused:t,toolSessionId:a,enabled:O!==void 0&&P,refreshVersion:c}),L=P?M:A,$=g.useMemo(()=>({details:M.details,turnIds:new Set(M.turns.map(se=>se.id)),loadDetails:M.loadDetails}),[M.details,M.turns,M.loadDetails]);x.current=L.messages,g.useEffect(()=>{const se=_.current;!se||L.loading||L.messages===se.historyBefore||(_.current=null,f(null))},[L.messages,L.loading]);const F=g.useMemo(()=>L.messages.filter(se=>!se.isSidechain),[L.messages]),B=g.useMemo(()=>{const se=v;return!se||L.messages===se.historyBefore||L.loading||C[0]!==se.first||C.length<se.count?C:C.slice(se.count)},[C,v,L.messages,L.loading]),z=g.useMemo(()=>P?M.lines:yK(d_(F,0,l)),[F,l,P,M.lines]),I=k[0]??null,U=g.useMemo(()=>Sh(B,(I==null?void 0:I.requestId)??null),[B,I==null?void 0:I.requestId]),q=g.useMemo(()=>P?wK(z,U):TK(z,U),[z,U,P]),D=g.useMemo(()=>U.map((se,We)=>({...se,seq:RK+We})),[U]),te=g.useMemo(()=>[...q,...D],[q,D]),ie=g.useRef(L.messages);g.useEffect(()=>{ie.current!==L.messages&&(ie.current=L.messages,!L.loading&&(n==null||n.push({level:"info",msg:"chatflow.history.display",sessionId:e,meta:{historyMessages:L.messages.length,mainChainMessages:F.length,historyLines:q.length,panelLines:te.length,total:L.total,error:L.error!==null}})))},[L.messages,L.loading,L.total,L.error,F.length,q.length,te.length,n,e]);const G=aR(E),me=NK(E),Ie=(o==null?void 0:o.resolvedModel)??(o==null?void 0:o.model),ce=g.useMemo(()=>({sessionLabel:(o==null?void 0:o.label)||(o==null?void 0:o.aiLabel)||(o==null?void 0:o.larkChatName)||(o==null?void 0:o.larkChatId)||e,sessionId:e,...o!=null&&o.larkChatId?{larkChatName:o.larkChatName??o.larkChatId,larkChatType:o.larkChatType??"group"}:{},...Ie?{model:Ie}:{},...(()=>{const se=o==null?void 0:o.gitBranch;return se?{gitBranch:se}:{}})(),...(()=>{const se=iK(o);return se!==void 0?{contextPct:se}:{}})(),...o!=null&&o.cwd?{cwd:o.cwd}:{},...(()=>{const se=o==null?void 0:o.permissionMode;return se?{permissionMode:se}:{}})(),procAlive:G,streamInProgress:me,pinnedAt:(o==null?void 0:o.pinnedAt)??null}),[o,e,Ie,G,me]),Me=g.useMemo(()=>r.isOpen?E==="error"?{kind:"error",message:"session error"}:{kind:"ready"}:{kind:"closed"},[r.isOpen,E]),Oe=g.useCallback(async(se,We)=>{await i.sessionSend(e,se,We)},[i,e]),je=g.useCallback(async se=>{await i.sessionDequeue(e,se)},[i,e]),ge=g.useCallback(async()=>(await i.sessionInterrupt(e)).queued??[],[i,e]),Qe=g.useCallback(async se=>{if(!(o!=null&&o.cwd)||!a)throw new Error("fork requires sessionFile with cwd + toolSessionId");await i.sessionFork({cwd:o.cwd,toolSessionId:a,messageUuid:se})},[i,o==null?void 0:o.cwd,a]),dt=g.useCallback(async se=>{await i.sessionRewind({sessionId:e,userMessageId:se,dryRun:!1})},[i,e]),nt=g.useCallback(async se=>{await i.sessionUpdate(e,{model:se})},[i,e]),vt=g.useCallback(async()=>{await i.sessionNew(e)},[i,e]),jt=g.useCallback(async(se,We)=>{const Ce=k.find($e=>$e.requestId===se);Ce&&j(se);try{await i.permissionRespond({sessionId:e,permissionRequestId:se,allow:We==="allow"})}catch($e){throw!(($e==null?void 0:$e.message)??"").startsWith("PERMISSION_REQUEST_STALE")&&Ce&&R(Ce),$e}},[i,e,k,j,R]);return g.useMemo(()=>({lines:te,connState:Me,meta:ce,historyLoading:L.loading,historyError:L.error,...P?{codexHistory:$,historyHasMore:M.nextCursor!==null,historyLoadingOlder:M.loadingOlder,loadOlderHistory:M.loadOlder,refreshHistory:M.refresh}:{},historySyncError:d,pendingPermissions:k,queued:T,sendText:Oe,dequeue:je,interrupt:ge,fork:Qe,rewind:dt,switchModel:nt,clearSession:vt,respondPermission:jt,reloadFromCloud:b}),[te,Me,ce,L.loading,L.error,P,$,M.nextCursor,M.loadingOlder,M.loadOlder,M.refresh,d,k,T,Oe,je,ge,Qe,dt,nt,vt,jt,b])}const MK={codex:"on-request",claude:"bypassPermissions",pi:"never"};function AK(e){const t={cwd:e.cwd,permissionMode:e.sourcePermissionMode??MK[e.sourceTool??"claude"]??"bypassPermissions",forkedFromSessionId:e.sourceSessionId};return e.sourceOwnerPersonaId&&(t.ownerPersonaId=e.sourceOwnerPersonaId),e.sourceTool&&(t.tool=e.sourceTool),e.sourceModel&&(t.model=e.sourceModel),e.sourceEffort&&(t.effort=e.sourceEffort),e.sourceProjectPath&&(t.projectPath=e.sourceProjectPath),t}async function LK(e,t,n,r={}){if(!t.toolSessionId)return null;const i=await e.sessionCreate({...AK({cwd:t.cwd,sourceSessionId:t.sessionId,sourcePermissionMode:t.permissionMode,sourceOwnerPersonaId:t.ownerPersonaId,sourceTool:t.tool,sourceModel:t.model,sourceEffort:t.effort,sourceProjectPath:t.projectPath}),...r.ephemeral?{ephemeral:!0}:{}});try{const{forkedToolSessionId:s}=await e.sessionFork({cwd:t.cwd,toolSessionId:t.toolSessionId,...t.tool==="codex"?{sourceSessionId:t.sessionId,turnId:n}:{messageUuid:n},targetCwd:i.cwd});await e.sessionResume(i.sessionId,s)}catch(s){throw e.sessionDelete(i.sessionId).catch(o=>De("quick-ask","fork rollback failed",o)),s}return i}async function jK(e,t,n){return LK(e,t,n,{ephemeral:!0})}function $d(e){return e!=null&&e.ephemeral!==!1}async function DK(e,t){return t.stillEphemeral?(await e.sessionUpdate(t.sessionId,{ephemeral:!1}),!0):!1}function OK(e){try{const t=new URL(e);return t.protocol==="ws:"?t.protocol="http:":t.protocol==="wss:"&&(t.protocol="https:"),`${t.protocol}//${t.host}`}catch{return e}}function BK(e,t){try{const n=new URL(e),r=new URL(t);return n.protocol=r.protocol,n.host=r.host,n.toString()}catch{return e}}async function h_(e,t,n,r,i){const s=await e.attachmentSignUrl({sessionId:n,relPath:r,...i!==void 0?{ttlSeconds:i}:{}});return BK(s.url,OK(t.url))}async function Tk(e,t,n,r,i=60,s){const o=window.open("about:blank","_blank");try{s&&await s();const a=await h_(e,t,n,r,i);o?o.location.href=a:window.open(a,"_blank")}catch(a){throw o&&o.close(),a}}async function zK(e){var t;try{if((t=navigator.clipboard)!=null&&t.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.setAttribute("readonly",""),document.body.appendChild(n),n.select();const r=document.execCommand("copy");return document.body.removeChild(n),r}catch{return!1}}const $K=300;function FK(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function HK(e,t){const n=Y1(),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>{let a=!1;return(async()=>{try{const l=await n.kv.get(e);if(a)return;const c=FK(l);typeof c=="number"&&Number.isFinite(c)&&c>0?i(c):i(t)}catch{a||i(t)}})(),()=>{a=!0}},[n,e,t]);const o=g.useCallback(a=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{s.current=null,n.kv.set(e,a).catch(()=>{})},$K)},[n,e]);return g.useEffect(()=>()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),{initialSize:r??t,setSize:o,loading:r===null}}function UK(){return{quickAsk:null,mds:[],active:null}}function WK(e,t){return{...e,quickAsk:{sessionId:t.sessionId,ephemeral:!0},active:"quick-ask"}}function qK(e,t){const n=e.mds.includes(t);return{...e,mds:n?e.mds:[...e.mds,t],active:{kind:"md",relPath:t}}}function VK(e){if(!e.quickAsk)return e;const t=e.active==="quick-ask",n=e.mds[0],r=t?n?{kind:"md",relPath:n}:null:e.active;return{...e,quickAsk:null,active:r}}function KK(e){return e.quickAsk?{...e,quickAsk:{...e.quickAsk,ephemeral:!1}}:e}function GK(e,t){const n=e.mds.indexOf(t);if(n<0)return e;const r=e.mds.filter(l=>l!==t);if(!(e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===t))return{...e,mds:r};const s=r[n],o=n>0?r[n-1]:void 0;let a=null;return s?a={kind:"md",relPath:s}:o?a={kind:"md",relPath:o}:e.quickAsk&&(a="quick-ask"),{...e,mds:r,active:a}}function YK(e,t){return{...e,active:t}}function XK(e,t){return e===null||t===null||e==="quick-ask"||t==="quick-ask"?e===t:e.relPath===t.relPath}function cR(e){return e.quickAsk!==null||e.mds.length>0}function QK(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 ZK(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 JK=/^Scheduled (?:recurring job|one-shot task) ([0-9a-f]{8}) \(([^)]+)\)/;function eG(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(JK);if(!a)continue;r.set(a[1],{id:a[1],cron:s.cron,prompt:s.prompt,recurring:s.recurring,humanSchedule:a[2],createdAt:s.ts,toolUseId:s.toolUseId});continue}const o=n.get(i.toolUseId);o!==void 0&&(n.delete(i.toolUseId),i.error||r.delete(o))}return Array.from(r.values()).sort((i,s)=>i.createdAt.localeCompare(s.createdAt))}function uR(e){var n;if(e.error)return!1;if(e.pending)return!0;if(e.notifications.length>0)return!1;const t=(n=e.progress)==null?void 0:n.status;return t==="running"?!0:t==="started"?tG(e.input):!1}function tG(e){return!e||typeof e!="object"?!1:e.run_in_background===!0}function nG(e){return e.filter(t=>t.kind==="merged-agent"&&uR(t))}function dR(e){var d;const{tasks:t,lastEventIndex:n}=pK(e);let r=-1;for(let f=e.length-1;f>=0;f--)if(e[f].kind==="todo-checklist"){r=f;break}const i=[],s=new Map,o=new Map,a=new Map,l=new Map,c=new Map,u=(f,p)=>{var _,b,S,C,k,T;const m=i[f],v=c.get(f),w=v!==void 0&&v!==p.toolUseId;if(!w&&(((_=m.progress)==null?void 0:_.status)==="completed"||((b=m.progress)==null?void 0:b.status)==="failed"))return;if(c.set(f,p.toolUseId),l.set(p.agentId,f),w&&(m.pending=!0,(S=m.toolResultExtra)!=null&&S.stats)){const{stats:E,...j}=m.toolResultExtra;m.toolResultExtra=j}const x={agentId:p.agentId,status:p.status};p.description?x.description=p.description:(C=m.progress)!=null&&C.description&&(x.description=m.progress.description),p.lastToolName?x.lastToolName=p.lastToolName:!w&&((k=m.progress)!=null&&k.lastToolName)&&(x.lastToolName=m.progress.lastToolName),p.stats?x.stats=p.stats:!w&&((T=m.progress)!=null&&T.stats)&&(x.stats=m.progress.stats),m.progress=x,(p.status==="completed"||p.status==="failed")&&(m.pending=!1)};for(let f=0;f<e.length;f++){const p=e[f];switch(p.kind){case"tool-call":{const m={kind:"merged-tool",seq:p.seq,tool:p.tool,toolKind:p.toolKind,toolUseId:p.toolUseId,input:p.input,pending:!0};s.set(p.toolUseId,i.length),i.push(m);break}case"tool-result":{const m=s.get(p.toolUseId);if(m!==void 0){const w=i[m];w.output=p.output,w.error=p.error,w.pending=!1,s.delete(p.toolUseId);break}const v=o.get(p.toolUseId);if(v!==void 0){const w=i[v];w.output=p.output,w.error=p.error,w.pending=!1,p.toolResultExtra&&(w.toolResultExtra=p.toolResultExtra),(d=p.toolResultExtra)!=null&&d.agentId&&(l.set(p.toolResultExtra.agentId,v),c.set(v,p.toolUseId));break}break}case"agent-call":{const m={kind:"merged-agent",seq:p.seq,toolUseId:p.toolUseId,description:p.description,input:p.input,pending:!0,notifications:[]},v=i.length;o.set(p.toolUseId,v),i.push(m);const w=a.get(p.toolUseId);w&&(u(v,w),a.delete(p.toolUseId));break}case"agent-progress":{const m=o.get(p.toolUseId)??l.get(p.agentId);if(m!==void 0){u(m,p);break}const v=a.get(p.toolUseId);if((v==null?void 0:v.status)==="completed"||(v==null?void 0:v.status)==="failed")break;a.set(p.toolUseId,p);break}case"agent-notification":{const m=(p.parentToolUseId?o.get(p.parentToolUseId):void 0)??(p.taskId?l.get(p.taskId):void 0);if(m!==void 0){i[m].notifications.push({text:p.text,taskId:p.taskId});break}i.push({kind:"agent-notification",seq:p.seq,text:p.text,taskId:p.taskId,parentToolUseId:p.parentToolUseId});break}case"todo-checklist":{f===r&&p.todos.length>0&&i.push({kind:"todo-checklist",seq:p.seq,toolUseId:p.toolUseId,todos:p.todos});break}case"task-event":{f===n&&t.length>0&&i.push({kind:"plan-card",seq:p.seq,tasks:t});break}default:i.push(p)}}return i}const rG=new Set(["permission-inline","question-card"]);function iG(e){return e.kind==="user-text"?!0:e.kind!=="user-meta"?!1:e.metaKind==="slash-command"||Rp(e.metaKind)}function sG(e){return e.kind==="user-text"&&e.continuesTurn===!0}function oG(e,t={}){const n=[];let r=null;const i=(s,o)=>{r&&(n.push(aG(r,s,o)),r=null)};for(const s of e){if(s.kind==="turn-end"){i(s,!0);continue}if(iG(s)&&(r===null||!sG(s))){i(void 0,!0),r={query:s,body:[]};continue}r===null?r={body:[s]}:r.body.push(s)}return i(void 0,t.closeTrailing===!0),n}function aG(e,t,n){const{query:r,body:i}=e,s=lG(i,t,n),o=cG(i,s),a=dG(i,o),l=r??i[0]??t,c={kind:"turn",seq:l?l.seq:0,status:s,process:a,tail:o};return t!=null&&t.turnId&&(c.turnId=t.turnId),r&&(c.query=r),(t==null?void 0:t.durationMs)!==void 0&&(c.durationMs=t.durationMs),c}function lG(e,t,n){if(!n)return"running";if((t==null?void 0:t.reason)==="interrupted")return"interrupted";const r=Qv(e,i=>i.kind==="error");return r>=0&&!e.slice(r+1).some(s=>s.kind==="assistant-text")?"error":"done"}function cG(e,t){if(t==="running"){const r=[];for(let i=e.length-1;i>=0&&rG.has(e[i].kind);i--)r.unshift(e[i]);return r}const n=t==="error"?Qv(e,r=>r.kind==="error"):Qv(e,r=>r.kind==="assistant-text");return n>=0?[e[n]]:[]}const uG=new Set(["assistant-thinking","user-meta"]);function dG(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(uG.has(o.kind)){r.push(o);continue}s(),r.push(o)}return s(),r}function Qv(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}const hG={Read:["正在读取","已读取"],Bash:["正在运行","已运行"],Grep:["正在搜索","已搜索"],Glob:["正在搜索","已搜索"],Edit:["正在编辑","已编辑"],Write:["正在写入","已写入"],WebFetch:["正在抓取","已抓取"],WebSearch:["正在搜索","已搜索"],Skill:["正在读取","已读取"]};function fG(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 hR(e){const t=hG[e.tool],n=t?e.pending?t[0]:t[1]:e.pending?`正在执行 ${e.tool}`:`已执行 ${e.tool}`,r=fG(e.input);return r?`${n} ${r}`:n}function pG({item:e,renderItemDetail:t}){const[n,r]=g.useState(!1),i=n?Qn:zn,s=n?(t==null?void 0:t(e))??null:null;return h.jsxs("div",{className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>r(o=>!o),"aria-expanded":n,"data-testid":"tool-call-group-row",className:re("flex w-full items-center gap-1.5 text-left cursor-pointer min-w-0 py-0.5 text-[13px] hover:text-text-200",e.error?"text-destructive/80":"text-text-400"),children:[e.pending?h.jsx(dr,{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:hR(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 mG({items:e,renderItemDetail:t}){const[n,r]=g.useState(!1);if(e.length===0)return null;const i=e.some(l=>l.pending),s=i?[...e].reverse().find(l=>l.pending):e[e.length-1],o=!i&&e.length>1?` 等 ${e.length} 项`:"",a=n?Qn:zn;return h.jsxs("div",{"data-testid":"tool-call-group",className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>r(l=>!l),"aria-expanded":n,"data-testid":"tool-call-group-header",className:"flex w-full items-center gap-1.5 text-left cursor-pointer min-w-0 py-0.5 text-[13px] text-text-400 hover:text-text-200",children:[i&&!n?h.jsx(dr,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):h.jsx(a,{className:"w-3.5 h-3.5 shrink-0"}),n?h.jsx("span",{className:"min-w-0 truncate opacity-70",children:i?"正在执行":`${e.length} 项`}):h.jsxs("span",{className:re("truncate min-w-0",i&&"text-text-300"),children:[hR(s),o]})]}),n?h.jsx("div",{className:"mt-0.5 flex flex-col pl-5",children:e.map(l=>h.jsx(pG,{item:l,renderItemDetail:t},l.toolUseId))}):null]})}function gG(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 vG(e,t){const n=t!==void 0?`耗时 ${gG(t)}`:"";switch(e){case"interrupted":return n?`已中断 · ${n}`:"已中断";case"error":return n?`出错 · ${n}`:"出错";default:return n||"已完成"}}function xG({status:e="done",durationMs:t,defaultExpanded:n=!1,onExpandedChange:r,children:i}){const[s,o]=g.useState(n),a=s?Qn:zn;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:()=>{const l=!s;o(l),r==null||r(l)},"aria-expanded":s,"data-testid":"turn-process-block-header",className:re("flex w-full items-center gap-1 text-left cursor-pointer min-w-0 py-0.5 text-[13px]",e!=="done"?"text-destructive/80 hover:text-destructive":"text-text-400 hover:text-text-200"),children:[h.jsx("span",{className:"truncate min-w-0",children:vG(e,t)}),h.jsx(a,{className:"w-3.5 h-3.5 shrink-0"})]}),s?h.jsx("div",{"data-testid":"turn-process-body",className:"mt-2 flex flex-col gap-2 border-l-2 border-border pl-3",children:i}):null]})}const yG=/<(system-reminder|related-dir|clawd-shift-fire)\b[^>]*>[\s\S]*?<\/\1>/gi,_G=/<builder-preview\b[^>]*\/>/gi,bG=/<(clawd-dispatch-task|clawd-dispatch-result)\b[^>]*>([\s\S]*?)<\/\1>/gi,wG=/<\/?(brief|detail|files)>/gi;function fR(e){return e?e.replace(bG,(t,n,r)=>$9(r.replace(wG,"")).trim()).replace(yG,"").replace(_G,"").trim():""}const SG=fR;function kG(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const CG=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,EG=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,IG={};function Nk(e,t){return(IG.jsx?EG:CG).test(e)}const TG=/[ \t\n\f\r]/g;function NG(e){return typeof e=="object"?e.type==="text"?Rk(e.value):!1:Rk(e)}function Rk(e){return e.replace(TG,"")===""}class Uu{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Uu.prototype.normal={};Uu.prototype.property={};Uu.prototype.space=void 0;function pR(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Uu(n,r,t)}function Zv(e){return e.toLowerCase()}class Zn{constructor(t,n){this.attribute=n,this.property=t}}Zn.prototype.attribute="";Zn.prototype.booleanish=!1;Zn.prototype.boolean=!1;Zn.prototype.commaOrSpaceSeparated=!1;Zn.prototype.commaSeparated=!1;Zn.prototype.defined=!1;Zn.prototype.mustUseProperty=!1;Zn.prototype.number=!1;Zn.prototype.overloadedBoolean=!1;Zn.prototype.property="";Zn.prototype.spaceSeparated=!1;Zn.prototype.space=void 0;let RG=0;const Be=Qo(),zt=Qo(),Jv=Qo(),J=Qo(),ht=Qo(),Ua=Qo(),nr=Qo();function Qo(){return 2**++RG}const ex=Object.freeze(Object.defineProperty({__proto__:null,boolean:Be,booleanish:zt,commaOrSpaceSeparated:nr,commaSeparated:Ua,number:J,overloadedBoolean:Jv,spaceSeparated:ht},Symbol.toStringTag,{value:"Module"})),hg=Object.keys(ex);class f_ extends Zn{constructor(t,n,r,i){let s=-1;if(super(t,n),Pk(this,"space",i),typeof r=="number")for(;++s<hg.length;){const o=hg[s];Pk(this,hg[s],(r&ex[o])===ex[o])}}}f_.prototype.defined=!0;function Pk(e,t,n){n&&(e[t]=n)}function Rl(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new f_(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Zv(r)]=r,n[Zv(s.attribute)]=r}return new Uu(t,n,e.space)}const mR=Rl({properties:{ariaActiveDescendant:null,ariaAtomic:zt,ariaAutoComplete:null,ariaBusy:zt,ariaChecked:zt,ariaColCount:J,ariaColIndex:J,ariaColSpan:J,ariaControls:ht,ariaCurrent:null,ariaDescribedBy:ht,ariaDetails:null,ariaDisabled:zt,ariaDropEffect:ht,ariaErrorMessage:null,ariaExpanded:zt,ariaFlowTo:ht,ariaGrabbed:zt,ariaHasPopup:null,ariaHidden:zt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ht,ariaLevel:J,ariaLive:null,ariaModal:zt,ariaMultiLine:zt,ariaMultiSelectable:zt,ariaOrientation:null,ariaOwns:ht,ariaPlaceholder:null,ariaPosInSet:J,ariaPressed:zt,ariaReadOnly:zt,ariaRelevant:null,ariaRequired:zt,ariaRoleDescription:ht,ariaRowCount:J,ariaRowIndex:J,ariaRowSpan:J,ariaSelected:zt,ariaSetSize:J,ariaSort:null,ariaValueMax:J,ariaValueMin:J,ariaValueNow:J,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function gR(e,t){return t in e?e[t]:t}function vR(e,t){return gR(e,t.toLowerCase())}const PG=Rl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ua,acceptCharset:ht,accessKey:ht,action:null,allow:null,allowFullScreen:Be,allowPaymentRequest:Be,allowUserMedia:Be,alt:null,as:null,async:Be,autoCapitalize:null,autoComplete:ht,autoFocus:Be,autoPlay:Be,blocking:ht,capture:null,charSet:null,checked:Be,cite:null,className:ht,cols:J,colSpan:null,content:null,contentEditable:zt,controls:Be,controlsList:ht,coords:J|Ua,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Be,defer:Be,dir:null,dirName:null,disabled:Be,download:Jv,draggable:zt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Be,formTarget:null,headers:ht,height:J,hidden:Jv,high:J,href:null,hrefLang:null,htmlFor:ht,httpEquiv:ht,id:null,imageSizes:null,imageSrcSet:null,inert:Be,inputMode:null,integrity:null,is:null,isMap:Be,itemId:null,itemProp:ht,itemRef:ht,itemScope:Be,itemType:ht,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Be,low:J,manifest:null,max:null,maxLength:J,media:null,method:null,min:null,minLength:J,multiple:Be,muted:Be,name:null,nonce:null,noModule:Be,noValidate:Be,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:Be,optimum:J,pattern:null,ping:ht,placeholder:null,playsInline:Be,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Be,referrerPolicy:null,rel:ht,required:Be,reversed:Be,rows:J,rowSpan:J,sandbox:ht,scope:null,scoped:Be,seamless:Be,selected:Be,shadowRootClonable:Be,shadowRootDelegatesFocus:Be,shadowRootMode:null,shape:null,size:J,sizes:null,slot:null,span:J,spellCheck:zt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:J,step:null,style:null,tabIndex:J,target:null,title:null,translate:null,type:null,typeMustMatch:Be,useMap:null,value:zt,width:J,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ht,axis:null,background:null,bgColor:null,border:J,borderColor:null,bottomMargin:J,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Be,declare:Be,event:null,face:null,frame:null,frameBorder:null,hSpace:J,leftMargin:J,link:null,longDesc:null,lowSrc:null,marginHeight:J,marginWidth:J,noResize:Be,noHref:Be,noShade:Be,noWrap:Be,object:null,profile:null,prompt:null,rev:null,rightMargin:J,rules:null,scheme:null,scrolling:zt,standby:null,summary:null,text:null,topMargin:J,valueType:null,version:null,vAlign:null,vLink:null,vSpace:J,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Be,disableRemotePlayback:Be,prefix:null,property:null,results:J,security:null,unselectable:null},space:"html",transform:vR}),MG=Rl({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:nr,accentHeight:J,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:J,amplitude:J,arabicForm:null,ascent:J,attributeName:null,attributeType:null,azimuth:J,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:J,by:null,calcMode:null,capHeight:J,className:ht,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:J,diffuseConstant:J,direction:null,display:null,dur:null,divisor:J,dominantBaseline:null,download:Be,dx:null,dy:null,edgeMode:null,editable:null,elevation:J,enableBackground:null,end:null,event:null,exponent:J,externalResourcesRequired:null,fill:null,fillOpacity:J,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:Ua,g2:Ua,glyphName:Ua,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:J,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:J,horizOriginX:J,horizOriginY:J,id:null,ideographic:J,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:J,k:J,k1:J,k2:J,k3:J,k4:J,kernelMatrix:nr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:J,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:J,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:J,overlineThickness:J,paintOrder:null,panose1:null,path:null,pathLength:J,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ht,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:J,pointsAtY:J,pointsAtZ:J,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:nr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:nr,rev:nr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:nr,requiredFeatures:nr,requiredFonts:nr,requiredFormats:nr,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:J,specularExponent:J,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:J,strikethroughThickness:J,string:null,stroke:null,strokeDashArray:nr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:J,strokeOpacity:J,strokeWidth:null,style:null,surfaceScale:J,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:nr,tabIndex:J,tableValues:null,target:null,targetX:J,targetY:J,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:nr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:J,underlineThickness:J,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:J,values:null,vAlphabetic:J,vMathematical:J,vectorEffect:null,vHanging:J,vIdeographic:J,version:null,vertAdvY:J,vertOriginX:J,vertOriginY:J,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:J,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:gR}),xR=Rl({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()}}),yR=Rl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:vR}),_R=Rl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),AG={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"},LG=/[A-Z]/g,Mk=/-[a-z]/g,jG=/^data[-\w.:]+$/i;function DG(e,t){const n=Zv(t);let r=t,i=Zn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&jG.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(Mk,BG);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!Mk.test(s)){let o=s.replace(LG,OG);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=f_}return new i(r,t)}function OG(e){return"-"+e.toLowerCase()}function BG(e){return e.charAt(1).toUpperCase()}const zG=pR([mR,PG,xR,yR,_R],"html"),p_=pR([mR,MG,xR,yR,_R],"svg");function $G(e){return e.join(" ").trim()}var m_={},Ak=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,FG=/\n/g,HG=/^\s*/,UG=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,WG=/^:\s*/,qG=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,VG=/^[;\s]*/,KG=/^\s+|\s+$/g,GG=`
|
|
519
|
+
`):e.result??e.contentItems??e.output??e,i=e.status==="failed"||e.status==="declined"||e.success===!1?_r((s=e.error)==null?void 0:s.message)||"执行失败":e.type==="commandExecution"&&typeof e.exitCode=="number"&&e.exitCode!==0?`exit ${e.exitCode}`:void 0;return Sh([{kind:"tool_call",tool:t,toolKind:"codex",toolUseId:e.id,input:n},{kind:"tool_result",toolUseId:e.id,output:r,...i?{error:i}:{}}])}function bK(e,t,n){const r=new Set,s=(t===void 0?e.items:[...e.items.filter(a=>a.type==="userMessage"&&!t.some(l=>l.id===a.id)),...t,...e.items.filter(a=>a.type!=="userMessage"&&!t.some(l=>l.id===a.id))]).flatMap(a=>r.has(a.id)?[]:(r.add(a.id),_K(a)));let o=!1;for(const a of s)a.kind==="user-text"&&(o&&(a.continuesTurn=!0),o=!0);return e.error&&s.push({kind:"error",seq:0,message:e.error.message}),s.push({kind:"turn-end",seq:0,turnId:e.id,...e.durationMs!==null?{durationMs:e.durationMs}:{},reason:e.status==="interrupted"?"interrupted":"completed"}),s.map((a,l)=>({...a,seq:n+l}))}function wK(e,t){const n=new Set(t.flatMap(s=>s.turnId?[s.turnId]:[])),r=new Set(t.flatMap(s=>"uuid"in s&&s.uuid?[s.uuid]:[]));let i=0;for(let s=0;s<e.length;s++){const o=e[s];if(o.kind==="turn-end"){if(o.turnId&&n.has(o.turnId))return e.slice(0,i);i=s+1}else if("uuid"in o&&o.uuid&&r.has(o.uuid))return e.slice(0,i)}return e}const zd=()=>({turns:[],details:{},nextCursor:null,loading:!1,loadingOlder:!1,error:null});function dg(e,t){if(e.view!==t||!Array.isArray(e.data))throw new Error("历史分页需要更新对端 daemon;未退回全量加载")}function SK(e){const{api:t,sessionId:n,toolSessionId:r,enabled:i,focused:s=!0,refreshVersion:o=0}=e,a=`${i}:${n}:${r??""}`,l=g.useRef(a);l.current=a;const c=g.useRef(0),u=g.useRef(!0),[d,f]=g.useState(zd),p=g.useRef(d);p.current=d;const m=g.useRef(!1),v=g.useRef(new Set),w=g.useRef();g.useEffect(()=>(u.current=!0,()=>{u.current=!1}),[]);const x=g.useCallback(async()=>{if(!i||!r)return;const k=++c.current,T=a;m.current=!1,v.current.clear(),f(E=>({...E,loading:!0,loadingOlder:!1,error:null}));try{const E=await t.historyPage({sessionId:n,view:"turns",limit:10});if(dg(E,"turns"),!u.current||c.current!==k||l.current!==T||E.view!=="turns")return;f({...zd(),turns:[...E.data].reverse(),snapshotId:E.snapshotId,nextCursor:E.nextCursor})}catch(E){if(!u.current||c.current!==k||l.current!==T)return;f(j=>({...j,loading:!1,error:E.message}))}},[t,a,i,r,n]);g.useEffect(()=>{if(!i||!r){c.current++,w.current=void 0,f(zd());return}if(!s)return;const k=w.current;(k==null?void 0:k.identity)===a&&k.version===o&&k.api===t||(((k==null?void 0:k.identity)!==a||k.api!==t)&&f(zd()),w.current={identity:a,version:o,api:t},x())},[t,a,i,r,s,o,x]);const _=g.useCallback(async()=>{const k=p.current;if(!i||k.loading||m.current||!k.nextCursor||!k.snapshotId)return;const T=c.current,E=a;m.current=!0,f(j=>({...j,loadingOlder:!0,error:null}));try{const j=await t.historyPage({sessionId:n,view:"turns",limit:10,cursor:k.nextCursor,snapshotId:k.snapshotId});if(dg(j,"turns"),!u.current||T!==c.current||E!==l.current||j.view!=="turns")return;if(j.snapshotId!==k.snapshotId||j.nextCursor===k.nextCursor)throw new Error("历史分页快照或游标失效,请刷新历史");f(R=>{const O=new Set(R.turns.map(P=>P.id));return{...R,turns:[...j.data.filter(P=>!O.has(P.id)).reverse(),...R.turns],nextCursor:j.nextCursor,loadingOlder:!1}})}catch(j){u.current&&T===c.current&&E===l.current&&f(R=>({...R,loadingOlder:!1,error:j.message}))}finally{T===c.current&&(m.current=!1)}},[t,i,a,n]),b=g.useCallback(async(k,T=!1)=>{const E=p.current,j=E.details[k];if(!i||E.loading||!E.snapshotId||v.current.has(k)||j&&!j.error&&!T||T&&!(j!=null&&j.nextCursor))return;const R=c.current,O=a;v.current.add(k);const P=j??{items:[],loading:!1,error:null,nextCursor:null};f(A=>({...A,details:{...A.details,[k]:{...P,loading:!0,error:null}}}));try{const A=await t.historyPage({sessionId:n,view:"items",turnId:k,limit:50,snapshotId:E.snapshotId,...j!=null&&j.nextCursor?{cursor:j.nextCursor}:{}});if(dg(A,"items"),!u.current||R!==c.current||O!==l.current||A.view!=="items")return;if(A.snapshotId!==E.snapshotId||j!=null&&j.nextCursor&&A.nextCursor===j.nextCursor)throw new Error("轮次详情快照或游标失效,请刷新历史");if(A.data.some($=>$.turnId!==k))throw new Error("轮次详情身份不匹配");const M=new Set(P.items.map($=>$.id)),L=[...P.items,...A.data.map($=>$.item).filter($=>!M.has($.id))];f($=>({...$,details:{...$.details,[k]:{items:L,loading:!1,error:null,nextCursor:A.nextCursor}}}))}catch(A){u.current&&R===c.current&&O===l.current&&f(M=>({...M,details:{...M.details,[k]:{...P,loading:!1,error:A.message}}}))}finally{R===c.current&&v.current.delete(k)}},[t,i,a,n]),S=g.useMemo(()=>d.turns.flatMap((k,T)=>{var E;return bK(k,(E=d.details[k.id])==null?void 0:E.items,(T-d.turns.length)*1e6)}),[d.turns,d.details]),C=g.useMemo(()=>S.map(k=>({kind:k.kind,..."text"in k?{text:k.text}:{},..."uuid"in k?{uuid:k.uuid}:{}})),[S]);return{...d,lines:S,messages:C,total:d.turns.length,loadOlder:_,loadDetails:b,refresh:x}}const kK=/<command-name>([\s\S]*?)<\/command-name>/i,CK=/<command-message>([\s\S]*?)<\/command-message>/i,EK=/<command-args>([\s\S]*?)<\/command-args>/i,IK=/<(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(kK),n=e.match(CK),r=e.match(EK);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(IK,""),i=i.trim(),{commandName:t?t[1].trim():null,commandMessage:n?n[1].trim():null,commandArgs:r?r[1].trim():null,body:i}}function Ek(e){const t=Yp(e);return t.commandName?t.commandArgs?`${t.commandName} ${t.commandArgs}`:t.commandName:e}function Ik(e){return e.kind==="user-text"?!0:e.kind!=="user-meta"?!1:e.metaKind==="slash-command"||Rp(e.metaKind)}function TK(e,t){const n=t.find(Ik);if(!n)return e;const r=Ek(n.text);for(let s=e.length-1;s>=0;s--){const o=e[s];if(Ik(o)&&Ek(o.text)===r)return e.slice(0,s)}const i=e[e.length-1];return i!==void 0&&i.kind!=="turn-end"?[...e,{kind:"turn-end",seq:i.seq+1}]:e}function NK(e){return e==="running"||e==="observing"}function aR(e){return e==="running"||e==="running-idle"||e==="observing"}const RK=1e6,PK=5;function lR(e,t=!0){const n=iR(),r=Ji(),i=g.useMemo(()=>new _y(r),[r]),s=Ki("sessions"),o=g.useMemo(()=>s==null?void 0:s.find(se=>se.sessionId===e),[s,e]),a=o==null?void 0:o.toolSessionId,l=o==null?void 0:o.tool,[c,u]=g.useState(0),[d,f]=g.useState(null),p=Qs(),m=g.useRef(p);m.current=p;const[v,w]=g.useState(null),x=g.useRef(null),_=g.useRef(null);g.useEffect(()=>(f(null),w(null),_.current=null,r.on("session:control",se=>{const We=se;if(!((We==null?void 0:We.sessionId)!==e||We.kind!==QB))if(We.synchronized===!0){const Ce=m.current.read(`session/${e}`);Ce!=null&&Ce.events.length&&w({first:Ce.events[0],count:Ce.events.length,historyBefore:x.current}),f(null),u($e=>$e+1)}else f("断线期间的部分内容未显示,完整内容已保存在云端")})),[r,e]);const b=g.useCallback(()=>{const se=m.current.read(`session/${e}`),We=(se==null?void 0:se.events)??[];let Ce=We.length;for(;Ce>0&&We[Ce-1].kind!=="turn_end";)Ce--;Ce>0&&w({first:We[0],count:Ce,historyBefore:x.current}),_.current={historyBefore:x.current},u($e=>$e+1)},[e]),S=rR(e),{events:C,pendingPermissions:k,queued:T,status:E,clearPermission:j,restorePermission:R}=S,O=az(),P=l==="codex",A=cK({api:i,sessionId:e,focused:t,toolSessionId:a,enabled:O!==void 0&&!P,refreshVersion:c,initialTurns:O==="owner"?void 0:PK,implicitCloseOnUserText:l==="codex"}),M=SK({api:i,sessionId:e,focused:t,toolSessionId:a,enabled:O!==void 0&&P,refreshVersion:c}),L=P?M:A,$=g.useMemo(()=>({details:M.details,turnIds:new Set(M.turns.map(se=>se.id)),loadDetails:M.loadDetails}),[M.details,M.turns,M.loadDetails]);x.current=L.messages,g.useEffect(()=>{const se=_.current;!se||L.loading||L.messages===se.historyBefore||(_.current=null,f(null))},[L.messages,L.loading]);const F=g.useMemo(()=>L.messages.filter(se=>!se.isSidechain),[L.messages]),B=g.useMemo(()=>{const se=v;return!se||L.messages===se.historyBefore||L.loading||C[0]!==se.first||C.length<se.count?C:C.slice(se.count)},[C,v,L.messages,L.loading]),z=g.useMemo(()=>P?M.lines:yK(d_(F,0,l)),[F,l,P,M.lines]),I=k[0]??null,U=g.useMemo(()=>Sh(B,(I==null?void 0:I.requestId)??null),[B,I==null?void 0:I.requestId]),q=g.useMemo(()=>P?wK(z,U):TK(z,U),[z,U,P]),D=g.useMemo(()=>U.map((se,We)=>({...se,seq:RK+We})),[U]),te=g.useMemo(()=>[...q,...D],[q,D]),ie=g.useRef(L.messages);g.useEffect(()=>{ie.current!==L.messages&&(ie.current=L.messages,!L.loading&&(n==null||n.push({level:"info",msg:"chatflow.history.display",sessionId:e,meta:{historyMessages:L.messages.length,mainChainMessages:F.length,historyLines:q.length,panelLines:te.length,total:L.total,error:L.error!==null}})))},[L.messages,L.loading,L.total,L.error,F.length,q.length,te.length,n,e]);const G=aR(E),me=NK(E),Ie=(o==null?void 0:o.resolvedModel)??(o==null?void 0:o.model),ce=g.useMemo(()=>({sessionLabel:(o==null?void 0:o.label)||(o==null?void 0:o.aiLabel)||(o==null?void 0:o.larkChatName)||(o==null?void 0:o.larkChatId)||e,sessionId:e,...o!=null&&o.larkChatId?{larkChatName:o.larkChatName??o.larkChatId,larkChatType:o.larkChatType??"group"}:{},...Ie?{model:Ie}:{},...(()=>{const se=o==null?void 0:o.gitBranch;return se?{gitBranch:se}:{}})(),...(()=>{const se=iK(o);return se!==void 0?{contextPct:se}:{}})(),...o!=null&&o.cwd?{cwd:o.cwd}:{},...(()=>{const se=o==null?void 0:o.permissionMode;return se?{permissionMode:se}:{}})(),procAlive:G,streamInProgress:me,pinnedAt:(o==null?void 0:o.pinnedAt)??null}),[o,e,Ie,G,me]),Me=g.useMemo(()=>r.isOpen?E==="error"?{kind:"error",message:"session error"}:{kind:"ready"}:{kind:"closed"},[r.isOpen,E]),Oe=g.useCallback(async(se,We)=>{await i.sessionSend(e,se,We)},[i,e]),je=g.useCallback(async se=>{await i.sessionDequeue(e,se)},[i,e]),ge=g.useCallback(async()=>(await i.sessionInterrupt(e)).queued??[],[i,e]),Qe=g.useCallback(async se=>{if(!(o!=null&&o.cwd)||!a)throw new Error("fork requires sessionFile with cwd + toolSessionId");await i.sessionFork({cwd:o.cwd,toolSessionId:a,messageUuid:se})},[i,o==null?void 0:o.cwd,a]),dt=g.useCallback(async se=>{await i.sessionRewind({sessionId:e,userMessageId:se,dryRun:!1})},[i,e]),nt=g.useCallback(async se=>{await i.sessionUpdate(e,{model:se})},[i,e]),vt=g.useCallback(async()=>{await i.sessionNew(e)},[i,e]),jt=g.useCallback(async(se,We)=>{const Ce=k.find($e=>$e.requestId===se);Ce&&j(se);try{await i.permissionRespond({sessionId:e,permissionRequestId:se,allow:We==="allow"})}catch($e){throw!(($e==null?void 0:$e.message)??"").startsWith("PERMISSION_REQUEST_STALE")&&Ce&&R(Ce),$e}},[i,e,k,j,R]);return g.useMemo(()=>({lines:te,connState:Me,meta:ce,historyLoading:L.loading,historyError:L.error,...P?{codexHistory:$,historyHasMore:M.nextCursor!==null,historyLoadingOlder:M.loadingOlder,loadOlderHistory:M.loadOlder,refreshHistory:M.refresh}:{},historySyncError:d,pendingPermissions:k,queued:T,sendText:Oe,dequeue:je,interrupt:ge,fork:Qe,rewind:dt,switchModel:nt,clearSession:vt,respondPermission:jt,reloadFromCloud:b}),[te,Me,ce,L.loading,L.error,P,$,M.nextCursor,M.loadingOlder,M.loadOlder,M.refresh,d,k,T,Oe,je,ge,Qe,dt,nt,vt,jt,b])}const MK={codex:"on-request",claude:"bypassPermissions",pi:"never"};function AK(e){const t={cwd:e.cwd,permissionMode:e.sourcePermissionMode??MK[e.sourceTool??"claude"]??"bypassPermissions",forkedFromSessionId:e.sourceSessionId};return e.sourceOwnerPersonaId&&(t.ownerPersonaId=e.sourceOwnerPersonaId),e.sourceTool&&(t.tool=e.sourceTool),e.sourceModel&&(t.model=e.sourceModel),e.sourceEffort&&(t.effort=e.sourceEffort),e.sourceProjectPath&&(t.projectPath=e.sourceProjectPath),t}async function LK(e,t,n,r={}){if(!t.toolSessionId)return null;const i=await e.sessionCreate({...AK({cwd:t.cwd,sourceSessionId:t.sessionId,sourcePermissionMode:t.permissionMode,sourceOwnerPersonaId:t.ownerPersonaId,sourceTool:t.tool,sourceModel:t.model,sourceEffort:t.effort,sourceProjectPath:t.projectPath}),...r.ephemeral?{ephemeral:!0}:{}});try{const{forkedToolSessionId:s}=await e.sessionFork({cwd:t.cwd,toolSessionId:t.toolSessionId,...t.tool==="codex"?{sourceSessionId:t.sessionId,turnId:n}:{messageUuid:n},targetCwd:i.cwd});await e.sessionResume(i.sessionId,s)}catch(s){throw e.sessionDelete(i.sessionId).catch(o=>De("quick-ask","fork rollback failed",o)),s}return i}async function jK(e,t,n){return LK(e,t,n,{ephemeral:!0})}function $d(e){return e!=null&&e.ephemeral!==!1}async function DK(e,t){return t.stillEphemeral?(await e.sessionUpdate(t.sessionId,{ephemeral:!1}),!0):!1}function OK(e){try{const t=new URL(e);return t.protocol==="ws:"?t.protocol="http:":t.protocol==="wss:"&&(t.protocol="https:"),`${t.protocol}//${t.host}`}catch{return e}}function BK(e,t){try{const n=new URL(e),r=new URL(t);return n.protocol=r.protocol,n.host=r.host,n.toString()}catch{return e}}async function h_(e,t,n,r,i){const s=await e.attachmentSignUrl({sessionId:n,relPath:r,...i!==void 0?{ttlSeconds:i}:{}});return BK(s.url,OK(t.url))}async function Tk(e,t,n,r,i=60,s){const o=window.open("about:blank","_blank");try{s&&await s();const a=await h_(e,t,n,r,i);o?o.location.href=a:window.open(a,"_blank")}catch(a){throw o&&o.close(),a}}async function zK(e){var t;try{if((t=navigator.clipboard)!=null&&t.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.setAttribute("readonly",""),document.body.appendChild(n),n.select();const r=document.execCommand("copy");return document.body.removeChild(n),r}catch{return!1}}const $K=300;function FK(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function HK(e,t){const n=Y1(),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>{let a=!1;return(async()=>{try{const l=await n.kv.get(e);if(a)return;const c=FK(l);typeof c=="number"&&Number.isFinite(c)&&c>0?i(c):i(t)}catch{a||i(t)}})(),()=>{a=!0}},[n,e,t]);const o=g.useCallback(a=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{s.current=null,n.kv.set(e,a).catch(()=>{})},$K)},[n,e]);return g.useEffect(()=>()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),{initialSize:r??t,setSize:o,loading:r===null}}function UK(){return{quickAsk:null,mds:[],active:null}}function WK(e,t){return{...e,quickAsk:{sessionId:t.sessionId,ephemeral:!0},active:"quick-ask"}}function qK(e,t){const n=e.mds.includes(t);return{...e,mds:n?e.mds:[...e.mds,t],active:{kind:"md",relPath:t}}}function VK(e){if(!e.quickAsk)return e;const t=e.active==="quick-ask",n=e.mds[0],r=t?n?{kind:"md",relPath:n}:null:e.active;return{...e,quickAsk:null,active:r}}function KK(e){return e.quickAsk?{...e,quickAsk:{...e.quickAsk,ephemeral:!1}}:e}function GK(e,t){const n=e.mds.indexOf(t);if(n<0)return e;const r=e.mds.filter(l=>l!==t);if(!(e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===t))return{...e,mds:r};const s=r[n],o=n>0?r[n-1]:void 0;let a=null;return s?a={kind:"md",relPath:s}:o?a={kind:"md",relPath:o}:e.quickAsk&&(a="quick-ask"),{...e,mds:r,active:a}}function YK(e,t){return{...e,active:t}}function XK(e,t){return e===null||t===null||e==="quick-ask"||t==="quick-ask"?e===t:e.relPath===t.relPath}function cR(e){return e.quickAsk!==null||e.mds.length>0}function QK(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 ZK(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 JK=/^Scheduled (?:recurring job|one-shot task) ([0-9a-f]{8}) \(([^)]+)\)/;function eG(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(JK);if(!a)continue;r.set(a[1],{id:a[1],cron:s.cron,prompt:s.prompt,recurring:s.recurring,humanSchedule:a[2],createdAt:s.ts,toolUseId:s.toolUseId});continue}const o=n.get(i.toolUseId);o!==void 0&&(n.delete(i.toolUseId),i.error||r.delete(o))}return Array.from(r.values()).sort((i,s)=>i.createdAt.localeCompare(s.createdAt))}function uR(e){var n;if(e.error)return!1;if(e.pending)return!0;if(e.notifications.length>0)return!1;const t=(n=e.progress)==null?void 0:n.status;return t==="running"?!0:t==="started"?tG(e.input):!1}function tG(e){return!e||typeof e!="object"?!1:e.run_in_background===!0}function nG(e){return e.filter(t=>t.kind==="merged-agent"&&uR(t))}function dR(e){var d;const{tasks:t,lastEventIndex:n}=pK(e);let r=-1;for(let f=e.length-1;f>=0;f--)if(e[f].kind==="todo-checklist"){r=f;break}const i=[],s=new Map,o=new Map,a=new Map,l=new Map,c=new Map,u=(f,p)=>{var _,b,S,C,k,T;const m=i[f],v=c.get(f),w=v!==void 0&&v!==p.toolUseId;if(!w&&(((_=m.progress)==null?void 0:_.status)==="completed"||((b=m.progress)==null?void 0:b.status)==="failed"))return;if(c.set(f,p.toolUseId),l.set(p.agentId,f),w&&(m.pending=!0,(S=m.toolResultExtra)!=null&&S.stats)){const{stats:E,...j}=m.toolResultExtra;m.toolResultExtra=j}const x={agentId:p.agentId,status:p.status};p.description?x.description=p.description:(C=m.progress)!=null&&C.description&&(x.description=m.progress.description),p.lastToolName?x.lastToolName=p.lastToolName:!w&&((k=m.progress)!=null&&k.lastToolName)&&(x.lastToolName=m.progress.lastToolName),p.stats?x.stats=p.stats:!w&&((T=m.progress)!=null&&T.stats)&&(x.stats=m.progress.stats),m.progress=x,(p.status==="completed"||p.status==="failed")&&(m.pending=!1)};for(let f=0;f<e.length;f++){const p=e[f];switch(p.kind){case"tool-call":{const m={kind:"merged-tool",seq:p.seq,tool:p.tool,toolKind:p.toolKind,toolUseId:p.toolUseId,input:p.input,pending:!0};s.set(p.toolUseId,i.length),i.push(m);break}case"tool-result":{const m=s.get(p.toolUseId);if(m!==void 0){const w=i[m];w.output=p.output,w.error=p.error,w.pending=!1,s.delete(p.toolUseId);break}const v=o.get(p.toolUseId);if(v!==void 0){const w=i[v];w.output=p.output,w.error=p.error,w.pending=!1,p.toolResultExtra&&(w.toolResultExtra=p.toolResultExtra),(d=p.toolResultExtra)!=null&&d.agentId&&(l.set(p.toolResultExtra.agentId,v),c.set(v,p.toolUseId));break}break}case"agent-call":{const m={kind:"merged-agent",seq:p.seq,toolUseId:p.toolUseId,description:p.description,input:p.input,pending:!0,notifications:[]},v=i.length;o.set(p.toolUseId,v),i.push(m);const w=a.get(p.toolUseId);w&&(u(v,w),a.delete(p.toolUseId));break}case"agent-progress":{const m=o.get(p.toolUseId)??l.get(p.agentId);if(m!==void 0){u(m,p);break}const v=a.get(p.toolUseId);if((v==null?void 0:v.status)==="completed"||(v==null?void 0:v.status)==="failed")break;a.set(p.toolUseId,p);break}case"agent-notification":{const m=(p.parentToolUseId?o.get(p.parentToolUseId):void 0)??(p.taskId?l.get(p.taskId):void 0);if(m!==void 0){i[m].notifications.push({text:p.text,taskId:p.taskId});break}i.push({kind:"agent-notification",seq:p.seq,text:p.text,taskId:p.taskId,parentToolUseId:p.parentToolUseId});break}case"todo-checklist":{f===r&&p.todos.length>0&&i.push({kind:"todo-checklist",seq:p.seq,toolUseId:p.toolUseId,todos:p.todos});break}case"task-event":{f===n&&t.length>0&&i.push({kind:"plan-card",seq:p.seq,tasks:t});break}default:i.push(p)}}return i}const rG=new Set(["permission-inline","question-card"]);function iG(e){return e.kind==="user-text"?!0:e.kind!=="user-meta"?!1:e.metaKind==="slash-command"||Rp(e.metaKind)}function sG(e){return e.kind==="user-text"&&e.continuesTurn===!0}function oG(e,t={}){const n=[];let r=null;const i=(s,o)=>{r&&(n.push(aG(r,s,o)),r=null)};for(const s of e){if(s.kind==="turn-end"){i(s,!0);continue}if(iG(s)&&(r===null||!sG(s))){i(void 0,!0),r={query:s,body:[]};continue}r===null?r={body:[s]}:r.body.push(s)}return i(void 0,t.closeTrailing===!0),n}function aG(e,t,n){const{query:r,body:i}=e,s=lG(i,t,n),o=cG(i,s),a=dG(i,o),l=r??i[0]??t,c={kind:"turn",seq:l?l.seq:0,status:s,process:a,tail:o};return t!=null&&t.turnId&&(c.turnId=t.turnId),r&&(c.query=r),(t==null?void 0:t.durationMs)!==void 0&&(c.durationMs=t.durationMs),c}function lG(e,t,n){if(!n)return"running";if((t==null?void 0:t.reason)==="interrupted")return"interrupted";const r=Qv(e,i=>i.kind==="error");return r>=0&&!e.slice(r+1).some(s=>s.kind==="assistant-text")?"error":"done"}function cG(e,t){if(t==="running"){const r=[];for(let i=e.length-1;i>=0&&rG.has(e[i].kind);i--)r.unshift(e[i]);return r}const n=t==="error"?Qv(e,r=>r.kind==="error"):Qv(e,r=>r.kind==="assistant-text");return n>=0?[e[n]]:[]}const uG=new Set(["assistant-thinking","user-meta"]);function dG(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(uG.has(o.kind)){r.push(o);continue}s(),r.push(o)}return s(),r}function Qv(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}const hG={Read:["正在读取","已读取"],Bash:["正在运行","已运行"],Grep:["正在搜索","已搜索"],Glob:["正在搜索","已搜索"],Edit:["正在编辑","已编辑"],Write:["正在写入","已写入"],WebFetch:["正在抓取","已抓取"],WebSearch:["正在搜索","已搜索"],Skill:["正在读取","已读取"]};function fG(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 hR(e){const t=hG[e.tool],n=t?e.pending?t[0]:t[1]:e.pending?`正在执行 ${e.tool}`:`已执行 ${e.tool}`,r=fG(e.input);return r?`${n} ${r}`:n}function pG({item:e,renderItemDetail:t}){const[n,r]=g.useState(!1),i=n?Qn:zn,s=n?(t==null?void 0:t(e))??null:null;return h.jsxs("div",{className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>r(o=>!o),"aria-expanded":n,"data-testid":"tool-call-group-row",className:re("flex w-full items-center gap-1.5 text-left cursor-pointer min-w-0 py-0.5 text-[13px] hover:text-text-200",e.error?"text-destructive/80":"text-text-400"),children:[e.pending?h.jsx(dr,{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:hR(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 mG({items:e,renderItemDetail:t}){const[n,r]=g.useState(!1);if(e.length===0)return null;const i=e.some(l=>l.pending),s=i?[...e].reverse().find(l=>l.pending):e[e.length-1],o=!i&&e.length>1?` 等 ${e.length} 项`:"",a=n?Qn:zn;return h.jsxs("div",{"data-testid":"tool-call-group",className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>r(l=>!l),"aria-expanded":n,"data-testid":"tool-call-group-header",className:"flex w-full items-center gap-1.5 text-left cursor-pointer min-w-0 py-0.5 text-[13px] text-text-400 hover:text-text-200",children:[i&&!n?h.jsx(dr,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):h.jsx(a,{className:"w-3.5 h-3.5 shrink-0"}),n?h.jsx("span",{className:"min-w-0 truncate opacity-70",children:i?"正在执行":`${e.length} 项`}):h.jsxs("span",{className:re("truncate min-w-0",i&&"text-text-300"),children:[hR(s),o]})]}),n?h.jsx("div",{className:"mt-0.5 flex flex-col pl-5",children:e.map(l=>h.jsx(pG,{item:l,renderItemDetail:t},l.toolUseId))}):null]})}function gG(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 vG(e,t){const n=t!==void 0?`耗时 ${gG(t)}`:"";switch(e){case"interrupted":return n?`已中断 · ${n}`:"已中断";case"error":return n?`出错 · ${n}`:"出错";default:return n||"已完成"}}function xG({status:e="done",durationMs:t,defaultExpanded:n=!1,onExpandedChange:r,children:i}){const[s,o]=g.useState(n),a=s?Qn:zn;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:()=>{const l=!s;o(l),r==null||r(l)},"aria-expanded":s,"data-testid":"turn-process-block-header",className:re("flex w-full items-center gap-1 text-left cursor-pointer min-w-0 py-0.5 text-[13px]",e!=="done"?"text-destructive/80 hover:text-destructive":"text-text-400 hover:text-text-200"),children:[h.jsx("span",{className:"truncate min-w-0",children:vG(e,t)}),h.jsx(a,{className:"w-3.5 h-3.5 shrink-0"})]}),s?h.jsx("div",{"data-testid":"turn-process-body",className:"mt-2 flex flex-col gap-2 border-l-2 border-border pl-3",children:i}):null]})}const yG=/<(system-reminder|related-dir|clawd-shift-fire)\b[^>]*>[\s\S]*?<\/\1>/gi,_G=/<builder-preview\b[^>]*\/>/gi,bG=/<(clawd-dispatch-task|clawd-dispatch-result)\b[^>]*>([\s\S]*?)<\/\1>/gi,wG=/<\/?(brief|detail|files)>/gi;function fR(e){return e?e.replace(bG,(t,n,r)=>$9(r.replace(wG,"")).trim()).replace(yG,"").replace(_G,"").trim():""}const SG=fR;function kG(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const CG=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,EG=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,IG={};function Nk(e,t){return(IG.jsx?EG:CG).test(e)}const TG=/[ \t\n\f\r]/g;function NG(e){return typeof e=="object"?e.type==="text"?Rk(e.value):!1:Rk(e)}function Rk(e){return e.replace(TG,"")===""}class Uu{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Uu.prototype.normal={};Uu.prototype.property={};Uu.prototype.space=void 0;function pR(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Uu(n,r,t)}function Zv(e){return e.toLowerCase()}class Zn{constructor(t,n){this.attribute=n,this.property=t}}Zn.prototype.attribute="";Zn.prototype.booleanish=!1;Zn.prototype.boolean=!1;Zn.prototype.commaOrSpaceSeparated=!1;Zn.prototype.commaSeparated=!1;Zn.prototype.defined=!1;Zn.prototype.mustUseProperty=!1;Zn.prototype.number=!1;Zn.prototype.overloadedBoolean=!1;Zn.prototype.property="";Zn.prototype.spaceSeparated=!1;Zn.prototype.space=void 0;let RG=0;const Be=Qo(),zt=Qo(),Jv=Qo(),J=Qo(),ht=Qo(),Ua=Qo(),nr=Qo();function Qo(){return 2**++RG}const ex=Object.freeze(Object.defineProperty({__proto__:null,boolean:Be,booleanish:zt,commaOrSpaceSeparated:nr,commaSeparated:Ua,number:J,overloadedBoolean:Jv,spaceSeparated:ht},Symbol.toStringTag,{value:"Module"})),hg=Object.keys(ex);class f_ extends Zn{constructor(t,n,r,i){let s=-1;if(super(t,n),Pk(this,"space",i),typeof r=="number")for(;++s<hg.length;){const o=hg[s];Pk(this,hg[s],(r&ex[o])===ex[o])}}}f_.prototype.defined=!0;function Pk(e,t,n){n&&(e[t]=n)}function Rl(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new f_(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Zv(r)]=r,n[Zv(s.attribute)]=r}return new Uu(t,n,e.space)}const mR=Rl({properties:{ariaActiveDescendant:null,ariaAtomic:zt,ariaAutoComplete:null,ariaBusy:zt,ariaChecked:zt,ariaColCount:J,ariaColIndex:J,ariaColSpan:J,ariaControls:ht,ariaCurrent:null,ariaDescribedBy:ht,ariaDetails:null,ariaDisabled:zt,ariaDropEffect:ht,ariaErrorMessage:null,ariaExpanded:zt,ariaFlowTo:ht,ariaGrabbed:zt,ariaHasPopup:null,ariaHidden:zt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ht,ariaLevel:J,ariaLive:null,ariaModal:zt,ariaMultiLine:zt,ariaMultiSelectable:zt,ariaOrientation:null,ariaOwns:ht,ariaPlaceholder:null,ariaPosInSet:J,ariaPressed:zt,ariaReadOnly:zt,ariaRelevant:null,ariaRequired:zt,ariaRoleDescription:ht,ariaRowCount:J,ariaRowIndex:J,ariaRowSpan:J,ariaSelected:zt,ariaSetSize:J,ariaSort:null,ariaValueMax:J,ariaValueMin:J,ariaValueNow:J,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function gR(e,t){return t in e?e[t]:t}function vR(e,t){return gR(e,t.toLowerCase())}const PG=Rl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ua,acceptCharset:ht,accessKey:ht,action:null,allow:null,allowFullScreen:Be,allowPaymentRequest:Be,allowUserMedia:Be,alt:null,as:null,async:Be,autoCapitalize:null,autoComplete:ht,autoFocus:Be,autoPlay:Be,blocking:ht,capture:null,charSet:null,checked:Be,cite:null,className:ht,cols:J,colSpan:null,content:null,contentEditable:zt,controls:Be,controlsList:ht,coords:J|Ua,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Be,defer:Be,dir:null,dirName:null,disabled:Be,download:Jv,draggable:zt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Be,formTarget:null,headers:ht,height:J,hidden:Jv,high:J,href:null,hrefLang:null,htmlFor:ht,httpEquiv:ht,id:null,imageSizes:null,imageSrcSet:null,inert:Be,inputMode:null,integrity:null,is:null,isMap:Be,itemId:null,itemProp:ht,itemRef:ht,itemScope:Be,itemType:ht,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Be,low:J,manifest:null,max:null,maxLength:J,media:null,method:null,min:null,minLength:J,multiple:Be,muted:Be,name:null,nonce:null,noModule:Be,noValidate:Be,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:Be,optimum:J,pattern:null,ping:ht,placeholder:null,playsInline:Be,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Be,referrerPolicy:null,rel:ht,required:Be,reversed:Be,rows:J,rowSpan:J,sandbox:ht,scope:null,scoped:Be,seamless:Be,selected:Be,shadowRootClonable:Be,shadowRootDelegatesFocus:Be,shadowRootMode:null,shape:null,size:J,sizes:null,slot:null,span:J,spellCheck:zt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:J,step:null,style:null,tabIndex:J,target:null,title:null,translate:null,type:null,typeMustMatch:Be,useMap:null,value:zt,width:J,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ht,axis:null,background:null,bgColor:null,border:J,borderColor:null,bottomMargin:J,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Be,declare:Be,event:null,face:null,frame:null,frameBorder:null,hSpace:J,leftMargin:J,link:null,longDesc:null,lowSrc:null,marginHeight:J,marginWidth:J,noResize:Be,noHref:Be,noShade:Be,noWrap:Be,object:null,profile:null,prompt:null,rev:null,rightMargin:J,rules:null,scheme:null,scrolling:zt,standby:null,summary:null,text:null,topMargin:J,valueType:null,version:null,vAlign:null,vLink:null,vSpace:J,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Be,disableRemotePlayback:Be,prefix:null,property:null,results:J,security:null,unselectable:null},space:"html",transform:vR}),MG=Rl({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:nr,accentHeight:J,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:J,amplitude:J,arabicForm:null,ascent:J,attributeName:null,attributeType:null,azimuth:J,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:J,by:null,calcMode:null,capHeight:J,className:ht,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:J,diffuseConstant:J,direction:null,display:null,dur:null,divisor:J,dominantBaseline:null,download:Be,dx:null,dy:null,edgeMode:null,editable:null,elevation:J,enableBackground:null,end:null,event:null,exponent:J,externalResourcesRequired:null,fill:null,fillOpacity:J,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:Ua,g2:Ua,glyphName:Ua,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:J,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:J,horizOriginX:J,horizOriginY:J,id:null,ideographic:J,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:J,k:J,k1:J,k2:J,k3:J,k4:J,kernelMatrix:nr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:J,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:J,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:J,overlineThickness:J,paintOrder:null,panose1:null,path:null,pathLength:J,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ht,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:J,pointsAtY:J,pointsAtZ:J,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:nr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:nr,rev:nr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:nr,requiredFeatures:nr,requiredFonts:nr,requiredFormats:nr,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:J,specularExponent:J,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:J,strikethroughThickness:J,string:null,stroke:null,strokeDashArray:nr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:J,strokeOpacity:J,strokeWidth:null,style:null,surfaceScale:J,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:nr,tabIndex:J,tableValues:null,target:null,targetX:J,targetY:J,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:nr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:J,underlineThickness:J,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:J,values:null,vAlphabetic:J,vMathematical:J,vectorEffect:null,vHanging:J,vIdeographic:J,version:null,vertAdvY:J,vertOriginX:J,vertOriginY:J,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:J,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:gR}),xR=Rl({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()}}),yR=Rl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:vR}),_R=Rl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),AG={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"},LG=/[A-Z]/g,Mk=/-[a-z]/g,jG=/^data[-\w.:]+$/i;function DG(e,t){const n=Zv(t);let r=t,i=Zn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&jG.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(Mk,BG);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!Mk.test(s)){let o=s.replace(LG,OG);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=f_}return new i(r,t)}function OG(e){return"-"+e.toLowerCase()}function BG(e){return e.charAt(1).toUpperCase()}const zG=pR([mR,PG,xR,yR,_R],"html"),p_=pR([mR,MG,xR,yR,_R],"svg");function $G(e){return e.join(" ").trim()}var m_={},Ak=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,FG=/\n/g,HG=/^\s*/,UG=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,WG=/^:\s*/,qG=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,VG=/^[;\s]*/,KG=/^\s+|\s+$/g,GG=`
|
|
520
520
|
`,Lk="/",jk="*",go="",YG="comment",XG="declaration";function QG(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(FG);v&&(n+=v.length);var w=m.lastIndexOf(GG);r=~w?m.length-w:r+m.length}function s(){var m={line:n,column:r};return function(v){return v.position=new o(m),c(),v}}function o(m){this.start=m,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function a(m){var v=new Error(t.source+":"+n+":"+r+": "+m);if(v.reason=m,v.filename=t.source,v.line=n,v.column=r,v.source=e,!t.silent)throw v}function l(m){var v=m.exec(e);if(v){var w=v[0];return i(w),e=e.slice(w.length),v}}function c(){l(HG)}function u(m){var v;for(m=m||[];v=d();)v!==!1&&m.push(v);return m}function d(){var m=s();if(!(Lk!=e.charAt(0)||jk!=e.charAt(1))){for(var v=2;go!=e.charAt(v)&&(jk!=e.charAt(v)||Lk!=e.charAt(v+1));)++v;if(v+=2,go===e.charAt(v-1))return a("End of comment missing");var w=e.slice(2,v-2);return r+=2,i(w),e=e.slice(v),r+=2,m({type:YG,comment:w})}}function f(){var m=s(),v=l(UG);if(v){if(d(),!l(WG))return a("property missing ':'");var w=l(qG),x=m({type:XG,property:Dk(v[0].replace(Ak,go)),value:w?Dk(w[0].replace(Ak,go)):go});return l(VG),x}}function p(){var m=[];u(m);for(var v;v=f();)v!==!1&&(m.push(v),u(m));return m}return c(),p()}function Dk(e){return e?e.replace(KG,go):go}var ZG=QG,JG=Ah&&Ah.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(m_,"__esModule",{value:!0});m_.default=tY;const eY=JG(ZG);function tY(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,eY.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 Xp={};Object.defineProperty(Xp,"__esModule",{value:!0});Xp.camelCase=void 0;var nY=/^--[a-zA-Z0-9_-]+$/,rY=/-([a-z])/g,iY=/^[^-]+$/,sY=/^-(webkit|moz|ms|o|khtml)-/,oY=/^-(ms)-/,aY=function(e){return!e||iY.test(e)||nY.test(e)},lY=function(e,t){return t.toUpperCase()},Ok=function(e,t){return"".concat(t,"-")},cY=function(e,t){return t===void 0&&(t={}),aY(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(oY,Ok):e=e.replace(sY,Ok),e.replace(rY,lY))};Xp.camelCase=cY;var uY=Ah&&Ah.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},dY=uY(m_),hY=Xp;function tx(e,t){var n={};return!e||typeof e!="string"||(0,dY.default)(e,function(r,i){r&&i&&(n[(0,hY.camelCase)(r,t)]=i)}),n}tx.default=tx;var fY=tx;const pY=ku(fY),bR=wR("end"),g_=wR("start");function wR(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 mY(e){const t=g_(e),n=bR(e);if(t&&n)return{start:t,end:n}}function jc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Bk(e.position):"start"in e||"end"in e?Bk(e):"line"in e||"column"in e?nx(e):""}function nx(e){return zk(e&&e.line)+":"+zk(e&&e.column)}function Bk(e){return nx(e&&e.start)+"-"+nx(e&&e.end)}function zk(e){return e&&typeof e=="number"?e:1}class Nn extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=jc(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Nn.prototype.file="";Nn.prototype.name="";Nn.prototype.reason="";Nn.prototype.message="";Nn.prototype.stack="";Nn.prototype.column=void 0;Nn.prototype.line=void 0;Nn.prototype.ancestors=void 0;Nn.prototype.cause=void 0;Nn.prototype.fatal=void 0;Nn.prototype.place=void 0;Nn.prototype.ruleId=void 0;Nn.prototype.source=void 0;const v_={}.hasOwnProperty,gY=new Map,vY=/[A-Z]/g,xY=new Set(["table","tbody","thead","tfoot","tr"]),yY=new Set(["td","th"]),SR="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function _Y(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=TY(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=IY(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"?p_:zG,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=kR(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function kR(e,t,n){if(t.type==="element")return bY(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return wY(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return kY(e,t,n);if(t.type==="mdxjsEsm")return SY(e,t);if(t.type==="root")return CY(e,t,n);if(t.type==="text")return EY(e,t)}function bY(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=p_,e.schema=i),e.ancestors.push(t);const s=ER(e,t.tagName,!1),o=NY(e,t);let a=y_(e,t);return xY.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!NG(l):!0})),CR(e,o,s,t),x_(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function wY(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)}vu(e,t.position)}function SY(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);vu(e,t.position)}function kY(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=p_,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:ER(e,t.name,!0),o=RY(e,t),a=y_(e,t);return CR(e,o,s,t),x_(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function CY(e,t,n){const r={};return x_(r,y_(e,t)),e.create(t,e.Fragment,r,n)}function EY(e,t){return t.value}function CR(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function x_(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function IY(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 TY(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=g_(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 NY(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&v_.call(t.properties,i)){const s=PY(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&yY.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 RY(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 vu(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 vu(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function y_(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:gY;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=kR(e,s,o);a!==void 0&&n.push(a)}return n}function PY(e,t,n){const r=DG(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?kG(n):$G(n)),r.property==="style"){let i=typeof n=="object"?n:MY(e,String(n));return e.stylePropertyNameCase==="css"&&(i=AY(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?AG[r.property]||r.property:r.attribute,n]}}function MY(e,t){try{return pY(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new Nn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=SR+"#cannot-parse-style-attribute",i}}function ER(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=Nk(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=Nk(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return v_.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);vu(e)}function vu(e,t){const n=new Nn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=SR+"#cannot-handle-mdx-estrees-without-createevaluater",n}function AY(e){const t={};let n;for(n in e)v_.call(e,n)&&(t[LY(n)]=e[n]);return t}function LY(e){let t=e.replace(vY,jY);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function jY(e){return"-"+e.toLowerCase()}const fg={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"]},DY={};function __(e,t){const n=DY,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(OY(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 $k(e.children,t,n)}return Array.isArray(e)?$k(e,t,n):""}function $k(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=IR(e[i],t,n);return r.join("")}function OY(e){return!!(e&&typeof e=="object")}const Fk=document.createElement("i");function b_(e){const t="&"+e+";";Fk.innerHTML=t;const n=Fk.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function yn(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 gn(e,t){return e.length>0?(yn(e,e.length,0,t),e):t}const Hk={}.hasOwnProperty;function TR(e){const t={};let n=-1;for(;++n<e.length;)BY(t,e[n]);return t}function BY(e,t){let n;for(n in t){const i=(Hk.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){Hk.call(i,o)||(i[o]=[]);const a=s[o];zY(i[o],Array.isArray(a)?a:a?[a]:[])}}}function zY(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);yn(e,0,0,r)}function NR(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 Vr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const An=eo(/[A-Za-z]/),En=eo(/[\dA-Za-z]/),$Y=eo(/[#-'*+\--9=?A-Z^-~]/);function Af(e){return e!==null&&(e<32||e===127)}const rx=eo(/\d/),FY=eo(/[\dA-Fa-f]/),HY=eo(/[!-/:-@[-`{-~]/);function ke(e){return e!==null&&e<-2}function ut(e){return e!==null&&(e<0||e===32)}function Ge(e){return e===-2||e===-1||e===32}const Qp=eo(new RegExp("\\p{P}|\\p{S}","u")),Bo=eo(/\s/);function eo(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&&En(e.charCodeAt(n+1))&&En(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 Ze(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return Ge(l)?(e.enter(n),a(l)):t(l)}function a(l){return Ge(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const UY={tokenize:WY};function WY(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"),Ze(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 ke(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const qY={tokenize:VY},Uk={tokenize:KY};function VY(e){const t=this,n=[];let r=0,i,s,o;return a;function a(b){if(r<n.length){const S=n[r];return t.containerState=S[1],e.attempt(S[0].continuation,l,c)(b)}return c(b)}function l(b){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&_();const S=t.events.length;let C=S,k;for(;C--;)if(t.events[C][0]==="exit"&&t.events[C][1].type==="chunkFlow"){k=t.events[C][1].end;break}x(r);let T=S;for(;T<t.events.length;)t.events[T][1].end={...k},T++;return yn(t.events,C+1,0,t.events.slice(S)),t.events.length=T,c(b)}return a(b)}function c(b){if(r===n.length){if(!i)return f(b);if(i.currentConstruct&&i.currentConstruct.concrete)return m(b);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Uk,u,d)(b)}function u(b){return i&&_(),x(r),f(b)}function d(b){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(b)}function f(b){return t.containerState={},e.attempt(Uk,p,m)(b)}function p(b){return r++,n.push([t.currentConstruct,t.containerState]),f(b)}function m(b){if(b===null){i&&_(),x(0),e.consume(b);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),v(b)}function v(b){if(b===null){w(e.exit("chunkFlow"),!0),x(0),e.consume(b);return}return ke(b)?(e.consume(b),w(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(b),v)}function w(b,S){const C=t.sliceStream(b);if(S&&C.push(null),b.previous=s,s&&(s.next=b),s=b,i.defineSkip(b.start),i.write(C),t.parser.lazy[b.start.line]){let k=i.events.length;for(;k--;)if(i.events[k][1].start.offset<o&&(!i.events[k][1].end||i.events[k][1].end.offset>o))return;const T=t.events.length;let E=T,j,R;for(;E--;)if(t.events[E][0]==="exit"&&t.events[E][1].type==="chunkFlow"){if(j){R=t.events[E][1].end;break}j=!0}for(x(r),k=T;k<t.events.length;)t.events[k][1].end={...R},k++;yn(t.events,E+1,0,t.events.slice(T)),t.events.length=k}}function x(b){let S=n.length;for(;S-- >b;){const C=n[S];t.containerState=C[1],C[0].exit.call(t,e)}n.length=b}function _(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function KY(e,t,n){return Ze(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function al(e){if(e===null||ut(e)||Bo(e))return 1;if(Qp(e))return 2}function Ml(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 ix={name:"attention",resolveAll:GY,tokenize:YY};function GY(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};Wk(d,-l),Wk(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=gn(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=gn(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),c=gn(c,Ml(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=gn(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=gn(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):u=0,yn(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 YY(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=al(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=al(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 Wk(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const XY={name:"autolink",tokenize:QY};function QY(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 An(p)?(e.consume(p),o):p===64?n(p):c(p)}function o(p){return p===43||p===45||p===46||En(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||En(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||Af(p)?n(p):(e.consume(p),l)}function c(p){return p===64?(e.consume(p),u):$Y(p)?(e.consume(p),c):n(p)}function u(p){return En(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||En(p))&&r++<63){const m=p===45?f:d;return e.consume(p),m}return n(p)}}const Wu={partial:!0,tokenize:ZY};function ZY(e,t,n){return r;function r(s){return Ge(s)?Ze(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||ke(s)?t(s):n(s)}}const RR={continuation:{tokenize:eX},exit:tX,name:"blockQuote",tokenize:JY};function JY(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 Ge(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function eX(e,t,n){const r=this;return i;function i(o){return Ge(o)?Ze(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(RR,t,n)(o)}}function tX(e){e.exit("blockQuote")}const PR={name:"characterEscape",tokenize:nX};function nX(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 HY(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const MR={name:"characterReference",tokenize:rX};function rX(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=En,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=FY,u):(e.enter("characterReferenceValue"),s=7,o=rx,u(d))}function u(d){if(d===59&&i){const f=e.exit("characterReferenceValue");return o===En&&!b_(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 qk={partial:!0,tokenize:sX},Vk={concrete:!0,name:"codeFenced",tokenize:iX};function iX(e,t,n){const r=this,i={partial:!0,tokenize:C};let s=0,o=0,a;return l;function l(k){return c(k)}function c(k){const T=r.events[r.events.length-1];return s=T&&T[1].type==="linePrefix"?T[2].sliceSerialize(T[1],!0).length:0,a=k,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),u(k)}function u(k){return k===a?(o++,e.consume(k),u):o<3?n(k):(e.exit("codeFencedFenceSequence"),Ge(k)?Ze(e,d,"whitespace")(k):d(k))}function d(k){return k===null||ke(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(qk,v,S)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(k))}function f(k){return k===null||ke(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(k)):Ge(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ze(e,p,"whitespace")(k)):k===96&&k===a?n(k):(e.consume(k),f)}function p(k){return k===null||ke(k)?d(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(k))}function m(k){return k===null||ke(k)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(k)):k===96&&k===a?n(k):(e.consume(k),m)}function v(k){return e.attempt(i,S,w)(k)}function w(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),x}function x(k){return s>0&&Ge(k)?Ze(e,_,"linePrefix",s+1)(k):_(k)}function _(k){return k===null||ke(k)?e.check(qk,v,S)(k):(e.enter("codeFlowValue"),b(k))}function b(k){return k===null||ke(k)?(e.exit("codeFlowValue"),_(k)):(e.consume(k),b)}function S(k){return e.exit("codeFenced"),t(k)}function C(k,T,E){let j=0;return R;function R(L){return k.enter("lineEnding"),k.consume(L),k.exit("lineEnding"),O}function O(L){return k.enter("codeFencedFence"),Ge(L)?Ze(k,P,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):P(L)}function P(L){return L===a?(k.enter("codeFencedFenceSequence"),A(L)):E(L)}function A(L){return L===a?(j++,k.consume(L),A):j>=o?(k.exit("codeFencedFenceSequence"),Ge(L)?Ze(k,M,"whitespace")(L):M(L)):E(L)}function M(L){return L===null||ke(L)?(k.exit("codeFencedFence"),T(L)):E(L)}}}function sX(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 pg={name:"codeIndented",tokenize:aX},oX={partial:!0,tokenize:lX};function aX(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),Ze(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):ke(c)?e.attempt(oX,o,l)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||ke(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),a)}function l(c){return e.exit("codeIndented"),t(c)}}function lX(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):ke(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):Ze(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):ke(o)?i(o):n(o)}}const cX={name:"codeText",previous:dX,resolve:uX,tokenize:hX};function uX(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 dX(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function hX(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)):ke(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||ke(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 fX{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&&Jl(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),Jl(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Jl(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);Jl(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Jl(this.left,n.reverse())}}}function Jl(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 AR(e){const t={};let n=-1,r,i,s,o,a,l,c;const u=new fX(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,pX(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 yn(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function pX(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],c={};let u,d,f=-1,p=n,m=0,v=0;const w=[v];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<a.length;)a[f][0]==="exit"&&a[f-1][0]==="enter"&&a[f][1].type===a[f-1][1].type&&a[f][1].start.line!==a[f][1].end.line&&(v=f+1,w.push(v),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):w.pop(),f=w.length;f--;){const x=a.slice(w[f],w[f+1]),_=s.pop();l.push([_,_+x.length-1]),e.splice(_,2,x)}for(l.reverse(),f=-1;++f<l.length;)c[m+l[f][0]]=m+l[f][1],m+=l[f][1]-l[f][0]-1;return c}const mX={resolve:vX,tokenize:xX},gX={partial:!0,tokenize:yX};function vX(e){return AR(e),e}function xX(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):ke(a)?e.check(gX,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 yX(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Ze(e,s,"linePrefix")}function s(o){if(o===null||ke(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 LR(e,t,n,r,i,s,o,a,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return d;function d(x){return x===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(x),e.exit(s),f):x===null||x===32||x===41||Af(x)?n(x):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),v(x))}function f(x){return x===62?(e.enter(s),e.consume(x),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(x))}function p(x){return x===62?(e.exit("chunkString"),e.exit(a),f(x)):x===null||x===60||ke(x)?n(x):(e.consume(x),x===92?m:p)}function m(x){return x===60||x===62||x===92?(e.consume(x),p):p(x)}function v(x){return!u&&(x===null||x===41||ut(x))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(x)):u<c&&x===40?(e.consume(x),u++,v):x===41?(e.consume(x),u--,v):x===null||x===32||x===40||Af(x)?n(x):(e.consume(x),x===92?w:v)}function w(x){return x===40||x===41||x===92?(e.consume(x),v):v(x)}}function jR(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):ke(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||ke(p)||a++>999?(e.exit("chunkString"),u(p)):(e.consume(p),l||(l=!Ge(p)),p===92?f:d)}function f(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function DR(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):ke(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Ze(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(f))}function u(f){return f===o||f===null||ke(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 Dc(e,t){let n;return r;function r(i){return ke(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Ge(i)?Ze(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const _X={name:"definition",tokenize:wX},bX={partial:!0,tokenize:SX};function wX(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return jR.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=Vr(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 ut(p)?Dc(e,c)(p):c(p)}function c(p){return LR(e,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function u(p){return e.attempt(bX,d,d)(p)}function d(p){return Ge(p)?Ze(e,f,"whitespace")(p):f(p)}function f(p){return p===null||ke(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function SX(e,t,n){return r;function r(a){return ut(a)?Dc(e,i)(a):n(a)}function i(a){return DR(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return Ge(a)?Ze(e,o,"whitespace")(a):o(a)}function o(a){return a===null||ke(a)?t(a):n(a)}}const kX={name:"hardBreakEscape",tokenize:CX};function CX(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return ke(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const EX={name:"headingAtx",resolve:IX,tokenize:TX};function IX(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"},yn(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function TX(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||ut(u)?(e.exit("atxHeadingSequence"),a(u)):n(u)}function a(u){return u===35?(e.enter("atxHeadingSequence"),l(u)):u===null||ke(u)?(e.exit("atxHeading"),t(u)):Ge(u)?Ze(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||ut(u)?(e.exit("atxHeadingText"),a(u)):(e.consume(u),c)}}const NX=["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"],Kk=["pre","script","style","textarea"],RX={concrete:!0,name:"htmlFlow",resolveTo:AX,tokenize:LX},PX={partial:!0,tokenize:DX},MX={partial:!0,tokenize:jX};function AX(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 LX(e,t,n){const r=this;let i,s,o,a,l;return c;function c(D){return u(D)}function u(D){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(D),d}function d(D){return D===33?(e.consume(D),f):D===47?(e.consume(D),s=!0,v):D===63?(e.consume(D),i=3,r.interrupt?t:I):An(D)?(e.consume(D),o=String.fromCharCode(D),w):n(D)}function f(D){return D===45?(e.consume(D),i=2,p):D===91?(e.consume(D),i=5,a=0,m):An(D)?(e.consume(D),i=4,r.interrupt?t:I):n(D)}function p(D){return D===45?(e.consume(D),r.interrupt?t:I):n(D)}function m(D){const te="CDATA[";return D===te.charCodeAt(a++)?(e.consume(D),a===te.length?r.interrupt?t:P:m):n(D)}function v(D){return An(D)?(e.consume(D),o=String.fromCharCode(D),w):n(D)}function w(D){if(D===null||D===47||D===62||ut(D)){const te=D===47,ie=o.toLowerCase();return!te&&!s&&Kk.includes(ie)?(i=1,r.interrupt?t(D):P(D)):NX.includes(o.toLowerCase())?(i=6,te?(e.consume(D),x):r.interrupt?t(D):P(D)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(D):s?_(D):b(D))}return D===45||En(D)?(e.consume(D),o+=String.fromCharCode(D),w):n(D)}function x(D){return D===62?(e.consume(D),r.interrupt?t:P):n(D)}function _(D){return Ge(D)?(e.consume(D),_):R(D)}function b(D){return D===47?(e.consume(D),R):D===58||D===95||An(D)?(e.consume(D),S):Ge(D)?(e.consume(D),b):R(D)}function S(D){return D===45||D===46||D===58||D===95||En(D)?(e.consume(D),S):C(D)}function C(D){return D===61?(e.consume(D),k):Ge(D)?(e.consume(D),C):b(D)}function k(D){return D===null||D===60||D===61||D===62||D===96?n(D):D===34||D===39?(e.consume(D),l=D,T):Ge(D)?(e.consume(D),k):E(D)}function T(D){return D===l?(e.consume(D),l=null,j):D===null||ke(D)?n(D):(e.consume(D),T)}function E(D){return D===null||D===34||D===39||D===47||D===60||D===61||D===62||D===96||ut(D)?C(D):(e.consume(D),E)}function j(D){return D===47||D===62||Ge(D)?b(D):n(D)}function R(D){return D===62?(e.consume(D),O):n(D)}function O(D){return D===null||ke(D)?P(D):Ge(D)?(e.consume(D),O):n(D)}function P(D){return D===45&&i===2?(e.consume(D),$):D===60&&i===1?(e.consume(D),F):D===62&&i===4?(e.consume(D),U):D===63&&i===3?(e.consume(D),I):D===93&&i===5?(e.consume(D),z):ke(D)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(PX,q,A)(D)):D===null||ke(D)?(e.exit("htmlFlowData"),A(D)):(e.consume(D),P)}function A(D){return e.check(MX,M,q)(D)}function M(D){return e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),L}function L(D){return D===null||ke(D)?A(D):(e.enter("htmlFlowData"),P(D))}function $(D){return D===45?(e.consume(D),I):P(D)}function F(D){return D===47?(e.consume(D),o="",B):P(D)}function B(D){if(D===62){const te=o.toLowerCase();return Kk.includes(te)?(e.consume(D),U):P(D)}return An(D)&&o.length<8?(e.consume(D),o+=String.fromCharCode(D),B):P(D)}function z(D){return D===93?(e.consume(D),I):P(D)}function I(D){return D===62?(e.consume(D),U):D===45&&i===2?(e.consume(D),I):P(D)}function U(D){return D===null||ke(D)?(e.exit("htmlFlowData"),q(D)):(e.consume(D),U)}function q(D){return e.exit("htmlFlow"),t(D)}}function jX(e,t,n){const r=this;return i;function i(o){return ke(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 DX(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Wu,t,n)}}const OX={name:"htmlText",tokenize:BX};function BX(e,t,n){const r=this;let i,s,o;return a;function a(I){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(I),l}function l(I){return I===33?(e.consume(I),c):I===47?(e.consume(I),C):I===63?(e.consume(I),b):An(I)?(e.consume(I),E):n(I)}function c(I){return I===45?(e.consume(I),u):I===91?(e.consume(I),s=0,m):An(I)?(e.consume(I),_):n(I)}function u(I){return I===45?(e.consume(I),p):n(I)}function d(I){return I===null?n(I):I===45?(e.consume(I),f):ke(I)?(o=d,F(I)):(e.consume(I),d)}function f(I){return I===45?(e.consume(I),p):d(I)}function p(I){return I===62?$(I):I===45?f(I):d(I)}function m(I){const U="CDATA[";return I===U.charCodeAt(s++)?(e.consume(I),s===U.length?v:m):n(I)}function v(I){return I===null?n(I):I===93?(e.consume(I),w):ke(I)?(o=v,F(I)):(e.consume(I),v)}function w(I){return I===93?(e.consume(I),x):v(I)}function x(I){return I===62?$(I):I===93?(e.consume(I),x):v(I)}function _(I){return I===null||I===62?$(I):ke(I)?(o=_,F(I)):(e.consume(I),_)}function b(I){return I===null?n(I):I===63?(e.consume(I),S):ke(I)?(o=b,F(I)):(e.consume(I),b)}function S(I){return I===62?$(I):b(I)}function C(I){return An(I)?(e.consume(I),k):n(I)}function k(I){return I===45||En(I)?(e.consume(I),k):T(I)}function T(I){return ke(I)?(o=T,F(I)):Ge(I)?(e.consume(I),T):$(I)}function E(I){return I===45||En(I)?(e.consume(I),E):I===47||I===62||ut(I)?j(I):n(I)}function j(I){return I===47?(e.consume(I),$):I===58||I===95||An(I)?(e.consume(I),R):ke(I)?(o=j,F(I)):Ge(I)?(e.consume(I),j):$(I)}function R(I){return I===45||I===46||I===58||I===95||En(I)?(e.consume(I),R):O(I)}function O(I){return I===61?(e.consume(I),P):ke(I)?(o=O,F(I)):Ge(I)?(e.consume(I),O):j(I)}function P(I){return I===null||I===60||I===61||I===62||I===96?n(I):I===34||I===39?(e.consume(I),i=I,A):ke(I)?(o=P,F(I)):Ge(I)?(e.consume(I),P):(e.consume(I),M)}function A(I){return I===i?(e.consume(I),i=void 0,L):I===null?n(I):ke(I)?(o=A,F(I)):(e.consume(I),A)}function M(I){return I===null||I===34||I===39||I===60||I===61||I===96?n(I):I===47||I===62||ut(I)?j(I):(e.consume(I),M)}function L(I){return I===47||I===62||ut(I)?j(I):n(I)}function $(I){return I===62?(e.consume(I),e.exit("htmlTextData"),e.exit("htmlText"),t):n(I)}function F(I){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),B}function B(I){return Ge(I)?Ze(e,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):z(I)}function z(I){return e.enter("htmlTextData"),o(I)}}const w_={name:"labelEnd",resolveAll:HX,resolveTo:UX,tokenize:WX},zX={tokenize:qX},$X={tokenize:VX},FX={tokenize:KX};function HX(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&&yn(e,0,e.length,n),e}function UX(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=gn(a,e.slice(s+1,s+r+3)),a=gn(a,[["enter",u,t]]),a=gn(a,Ml(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=gn(a,[["exit",u,t],e[o-2],e[o-1],["exit",c,t]]),a=gn(a,e.slice(o+1)),a=gn(a,[["exit",l,t]]),yn(e,s,e.length,a),e}function WX(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(Vr(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(zX,u,o?u:d)(f):f===91?e.attempt($X,u,o?c:d)(f):o?u(f):d(f)}function c(f){return e.attempt(FX,u,d)(f)}function u(f){return t(f)}function d(f){return s._balanced=!0,n(f)}}function qX(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 ut(d)?Dc(e,s)(d):s(d)}function s(d){return d===41?u(d):LR(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function o(d){return ut(d)?Dc(e,l)(d):u(d)}function a(d){return n(d)}function l(d){return d===34||d===39||d===40?DR(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):u(d)}function c(d){return ut(d)?Dc(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 VX(e,t,n){const r=this;return i;function i(a){return jR.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Vr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function KX(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 GX={name:"labelStartImage",resolveAll:w_.resolveAll,tokenize:YX};function YX(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 XX={name:"labelStartLink",resolveAll:w_.resolveAll,tokenize:QX};function QX(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 mg={name:"lineEnding",tokenize:ZX};function ZX(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ze(e,t,"linePrefix")}}const kh={name:"thematicBreak",tokenize:JX};function JX(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||ke(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),Ge(c)?Ze(e,a,"whitespace")(c):a(c))}}const qn={continuation:{tokenize:rQ},exit:sQ,name:"list",tokenize:nQ},eQ={partial:!0,tokenize:oQ},tQ={partial:!0,tokenize:iQ};function nQ(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:rx(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(kh,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 rx(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(Wu,r.interrupt?n:u,e.attempt(eQ,f,d))}function u(p){return r.containerState.initialBlankLine=!0,s++,f(p)}function d(p){return Ge(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 rQ(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Wu,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ze(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!Ge(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(tQ,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ze(e,e.attempt(qn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function iQ(e,t,n){const r=this;return Ze(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 sQ(e){e.exit(this.containerState.type)}function oQ(e,t,n){const r=this;return Ze(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!Ge(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const Gk={name:"setextUnderline",resolveTo:aQ,tokenize:lQ};function aQ(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 lQ(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"),Ge(c)?Ze(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||ke(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const cQ={tokenize:uQ};function uQ(e){const t=this,n=e.attempt(Wu,r,e.attempt(this.parser.constructs.flowInitial,i,Ze(e,e.attempt(this.parser.constructs.flow,i,e.attempt(mX,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 dQ={resolveAll:BR()},hQ=OR("string"),fQ=OR("text");function OR(e){return{resolveAll:BR(e==="text"?pQ: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 BR(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 pQ(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 mQ={42:qn,43:qn,45:qn,48:qn,49:qn,50:qn,51:qn,52:qn,53:qn,54:qn,55:qn,56:qn,57:qn,62:RR},gQ={91:_X},vQ={[-2]:pg,[-1]:pg,32:pg},xQ={35:EX,42:kh,45:[Gk,kh],60:RX,61:Gk,95:kh,96:Vk,126:Vk},yQ={38:MR,92:PR},_Q={[-5]:mg,[-4]:mg,[-3]:mg,33:GX,38:MR,42:ix,60:[XY,OX],91:XX,92:[kX,PR],93:w_,95:ix,96:cX},bQ={null:[ix,dQ]},wQ={null:[42,95]},SQ={null:[]},kQ=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:wQ,contentInitial:gQ,disable:SQ,document:mQ,flow:xQ,flowInitial:vQ,insideSpan:bQ,string:yQ,text:_Q},Symbol.toStringTag,{value:"Module"}));function CQ(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],a=[];const l={attempt:T(C),check:T(k),consume:_,enter:b,exit:S,interrupt:T(k,{interrupt:!0})},c={code:null,containerState:{},defineSkip:v,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d};let u=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function d(O){return o=gn(o,O),w(),o[o.length-1]!==null?[]:(E(t,0),c.events=Ml(s,c.events,c),c.events)}function f(O,P){return IQ(p(O),P)}function p(O){return EQ(o,O)}function m(){const{_bufferIndex:O,_index:P,line:A,column:M,offset:L}=r;return{_bufferIndex:O,_index:P,line:A,column:M,offset:L}}function v(O){i[O.line]=O.column,R()}function w(){let O;for(;r._index<o.length;){const P=o[r._index];if(typeof P=="string")for(O=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===O&&r._bufferIndex<P.length;)x(P.charCodeAt(r._bufferIndex));else x(P)}}function x(O){u=u(O)}function _(O){ke(O)?(r.line++,r.column=1,r.offset+=O===-3?2:1,R()):O!==-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=O}function b(O,P){const A=P||{};return A.type=O,A.start=m(),c.events.push(["enter",A,c]),a.push(A),A}function S(O){const P=a.pop();return P.end=m(),c.events.push(["exit",P,c]),P}function C(O,P){E(O,P.from)}function k(O,P){P.restore()}function T(O,P){return A;function A(M,L,$){let F,B,z,I;return Array.isArray(M)?q(M):"tokenize"in M?q([M]):U(M);function U(G){return me;function me(Ie){const ce=Ie!==null&&G[Ie],Me=Ie!==null&&G.null,Oe=[...Array.isArray(ce)?ce:ce?[ce]:[],...Array.isArray(Me)?Me:Me?[Me]:[]];return q(Oe)(Ie)}}function q(G){return F=G,B=0,G.length===0?$:D(G[B])}function D(G){return me;function me(Ie){return I=j(),z=G,G.partial||(c.currentConstruct=G),G.name&&c.parser.constructs.disable.null.includes(G.name)?ie():G.tokenize.call(P?Object.assign(Object.create(c),P):c,l,te,ie)(Ie)}}function te(G){return O(z,I),L}function ie(G){return I.restore(),++B<F.length?D(F[B]):$}}}function E(O,P){O.resolveAll&&!s.includes(O)&&s.push(O),O.resolve&&yn(c.events,P,c.events.length-P,O.resolve(c.events.slice(P),c)),O.resolveTo&&(c.events=O.resolveTo(c.events,c))}function j(){const O=m(),P=c.previous,A=c.currentConstruct,M=c.events.length,L=Array.from(a);return{from:M,restore:$};function $(){r=O,c.previous=P,c.currentConstruct=A,c.events.length=M,a=L,R()}}function R(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function EQ(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 IQ(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=`
|
|
521
521
|
`;break}case-3:{o=`\r
|
|
522
522
|
`;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 TQ(e){const r={constructs:TR([kQ,...(e||{}).extensions||[]]),content:i(UY),defined:[],document:i(qY),flow:i(cQ),lazy:{},string:i(hQ),text:i(fQ)};return r;function i(s){return o;function o(a){return CQ(r,s,a)}}}function NQ(e){for(;!AR(e););return e}const Yk=/[\0\t\n\r]/g;function RQ(){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(Yk.lastIndex=d,c=Yk.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 PQ=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function MQ(e){return e.replace(PQ,AQ)}function AQ(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return NR(n.slice(s?2:1),s?16:10)}return b_(n)||e}const zR={}.hasOwnProperty;function LQ(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),jQ(n)(NQ(TQ(n).document().write(RQ()(e,t,!0))))}function jQ(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(se),autolinkProtocol:j,autolinkEmail:j,atxHeading:s(dt),blockQuote:s(Me),characterEscape:j,characterReference:j,codeFenced:s(Oe),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Oe,o),codeText:s(je,o),codeTextData:j,data:j,codeFlowValue:j,definition:s(ge),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(Qe),hardBreakEscape:s(nt),hardBreakTrailing:s(nt),htmlFlow:s(vt,o),htmlFlowData:j,htmlText:s(vt,o),htmlTextData:j,image:s(jt),label:o,link:s(se),listItem:s(Ce),listItemValue:f,listOrdered:s(We,d),listUnordered:s(We),paragraph:s($e),reference:D,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(dt),strong:s(_t),thematicBreak:s(Rn)},exit:{atxHeading:l(),atxHeadingSequence:C,autolink:l(),autolinkEmail:ce,autolinkProtocol:Ie,blockQuote:l(),characterEscapeValue:R,characterReferenceMarkerHexadecimal:ie,characterReferenceMarkerNumeric:ie,characterReferenceValue:G,characterReference:me,codeFenced:l(w),codeFencedFence:v,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:R,codeIndented:l(x),codeText:l(L),codeTextData:R,data:R,definition:l(),definitionDestinationString:S,definitionLabelString:_,definitionTitleString:b,emphasis:l(),hardBreakEscape:l(P),hardBreakTrailing:l(P),htmlFlow:l(A),htmlFlowData:R,htmlText:l(M),htmlTextData:R,image:l(F),label:z,labelText:B,lineEnding:O,link:l($),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:te,resourceDestinationString:I,resourceTitleString:U,resource:q,setextHeading:l(E),setextHeadingLineSequence:T,setextHeadingText:k,strong:l(),thematicBreak:l()}};$R(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(W){let ee={type:"root",children:[]};const we={stack:[ee],tokenStack:[],config:t,enter:a,exit:c,buffer:o,resume:u,data:n},Ae=[];let qe=-1;for(;++qe<W.length;)if(W[qe][1].type==="listOrdered"||W[qe][1].type==="listUnordered")if(W[qe][0]==="enter")Ae.push(qe);else{const Tt=Ae.pop();qe=i(W,Tt,qe)}for(qe=-1;++qe<W.length;){const Tt=t[W[qe][0]];zR.call(Tt,W[qe][1].type)&&Tt[W[qe][1].type].call(Object.assign({sliceSerialize:W[qe][2].sliceSerialize},we),W[qe][1])}if(we.tokenStack.length>0){const Tt=we.tokenStack[we.tokenStack.length-1];(Tt[1]||Xk).call(we,void 0,Tt[0])}for(ee.position={start:ds(W.length>0?W[0][1].start:{line:1,column:1,offset:0}),end:ds(W.length>0?W[W.length-2][1].end:{line:1,column:1,offset:0})},qe=-1;++qe<t.transforms.length;)ee=t.transforms[qe](ee)||ee;return ee}function i(W,ee,we){let Ae=ee-1,qe=-1,Tt=!1,en,tn,nn,ae;for(;++Ae<=we;){const Se=W[Ae];switch(Se[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Se[0]==="enter"?qe++:qe--,ae=void 0;break}case"lineEndingBlank":{Se[0]==="enter"&&(en&&!ae&&!qe&&!nn&&(nn=Ae),ae=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ae=void 0}if(!qe&&Se[0]==="enter"&&Se[1].type==="listItemPrefix"||qe===-1&&Se[0]==="exit"&&(Se[1].type==="listUnordered"||Se[1].type==="listOrdered")){if(en){let rt=Ae;for(tn=void 0;rt--;){const bt=W[rt];if(bt[1].type==="lineEnding"||bt[1].type==="lineEndingBlank"){if(bt[0]==="exit")continue;tn&&(W[tn][1].type="lineEndingBlank",Tt=!0),bt[1].type="lineEnding",tn=rt}else if(!(bt[1].type==="linePrefix"||bt[1].type==="blockQuotePrefix"||bt[1].type==="blockQuotePrefixWhitespace"||bt[1].type==="blockQuoteMarker"||bt[1].type==="listItemIndent"))break}nn&&(!tn||nn<tn)&&(en._spread=!0),en.end=Object.assign({},tn?W[tn][1].start:Se[1].end),W.splice(tn||Ae,0,["exit",en,Se[2]]),Ae++,we++}if(Se[1].type==="listItemPrefix"){const rt={type:"listItem",_spread:!1,start:Object.assign({},Se[1].start),end:void 0};en=rt,W.splice(Ae,0,["enter",rt,Se[2]]),Ae++,we++,nn=void 0,ae=!0}}}return W[ee][1]._spread=Tt,we}function s(W,ee){return we;function we(Ae){a.call(this,W(Ae),Ae),ee&&ee.call(this,Ae)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(W,ee,we){this.stack[this.stack.length-1].children.push(W),this.stack.push(W),this.tokenStack.push([ee,we||void 0]),W.position={start:ds(ee.start),end:void 0}}function l(W){return ee;function ee(we){W&&W.call(this,we),c.call(this,we)}}function c(W,ee){const we=this.stack.pop(),Ae=this.tokenStack.pop();if(Ae)Ae[0].type!==W.type&&(ee?ee.call(this,W,Ae[0]):(Ae[1]||Xk).call(this,W,Ae[0]));else throw new Error("Cannot close `"+W.type+"` ("+jc({start:W.start,end:W.end})+"): it’s not open");we.position.end=ds(W.end)}function u(){return __(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(W){if(this.data.expectingFirstListItemValue){const ee=this.stack[this.stack.length-2];ee.start=Number.parseInt(this.sliceSerialize(W),10),this.data.expectingFirstListItemValue=void 0}}function p(){const W=this.resume(),ee=this.stack[this.stack.length-1];ee.lang=W}function m(){const W=this.resume(),ee=this.stack[this.stack.length-1];ee.meta=W}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function w(){const W=this.resume(),ee=this.stack[this.stack.length-1];ee.value=W.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){const W=this.resume(),ee=this.stack[this.stack.length-1];ee.value=W.replace(/(\r?\n|\r)$/g,"")}function _(W){const ee=this.resume(),we=this.stack[this.stack.length-1];we.label=ee,we.identifier=Vr(this.sliceSerialize(W)).toLowerCase()}function b(){const W=this.resume(),ee=this.stack[this.stack.length-1];ee.title=W}function S(){const W=this.resume(),ee=this.stack[this.stack.length-1];ee.url=W}function C(W){const ee=this.stack[this.stack.length-1];if(!ee.depth){const we=this.sliceSerialize(W).length;ee.depth=we}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function T(W){const ee=this.stack[this.stack.length-1];ee.depth=this.sliceSerialize(W).codePointAt(0)===61?1:2}function E(){this.data.setextHeadingSlurpLineEnding=void 0}function j(W){const we=this.stack[this.stack.length-1].children;let Ae=we[we.length-1];(!Ae||Ae.type!=="text")&&(Ae=hn(),Ae.position={start:ds(W.start),end:void 0},we.push(Ae)),this.stack.push(Ae)}function R(W){const ee=this.stack.pop();ee.value+=this.sliceSerialize(W),ee.position.end=ds(W.end)}function O(W){const ee=this.stack[this.stack.length-1];if(this.data.atHardBreak){const we=ee.children[ee.children.length-1];we.position.end=ds(W.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ee.type)&&(j.call(this,W),R.call(this,W))}function P(){this.data.atHardBreak=!0}function A(){const W=this.resume(),ee=this.stack[this.stack.length-1];ee.value=W}function M(){const W=this.resume(),ee=this.stack[this.stack.length-1];ee.value=W}function L(){const W=this.resume(),ee=this.stack[this.stack.length-1];ee.value=W}function $(){const W=this.stack[this.stack.length-1];if(this.data.inReference){const ee=this.data.referenceType||"shortcut";W.type+="Reference",W.referenceType=ee,delete W.url,delete W.title}else delete W.identifier,delete W.label;this.data.referenceType=void 0}function F(){const W=this.stack[this.stack.length-1];if(this.data.inReference){const ee=this.data.referenceType||"shortcut";W.type+="Reference",W.referenceType=ee,delete W.url,delete W.title}else delete W.identifier,delete W.label;this.data.referenceType=void 0}function B(W){const ee=this.sliceSerialize(W),we=this.stack[this.stack.length-2];we.label=MQ(ee),we.identifier=Vr(ee).toLowerCase()}function z(){const W=this.stack[this.stack.length-1],ee=this.resume(),we=this.stack[this.stack.length-1];if(this.data.inReference=!0,we.type==="link"){const Ae=W.children;we.children=Ae}else we.alt=ee}function I(){const W=this.resume(),ee=this.stack[this.stack.length-1];ee.url=W}function U(){const W=this.resume(),ee=this.stack[this.stack.length-1];ee.title=W}function q(){this.data.inReference=void 0}function D(){this.data.referenceType="collapsed"}function te(W){const ee=this.resume(),we=this.stack[this.stack.length-1];we.label=ee,we.identifier=Vr(this.sliceSerialize(W)).toLowerCase(),this.data.referenceType="full"}function ie(W){this.data.characterReferenceType=W.type}function G(W){const ee=this.sliceSerialize(W),we=this.data.characterReferenceType;let Ae;we?(Ae=NR(ee,we==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ae=b_(ee);const qe=this.stack[this.stack.length-1];qe.value+=Ae}function me(W){const ee=this.stack.pop();ee.position.end=ds(W.end)}function Ie(W){R.call(this,W);const ee=this.stack[this.stack.length-1];ee.url=this.sliceSerialize(W)}function ce(W){R.call(this,W);const ee=this.stack[this.stack.length-1];ee.url="mailto:"+this.sliceSerialize(W)}function Me(){return{type:"blockquote",children:[]}}function Oe(){return{type:"code",lang:null,meta:null,value:""}}function je(){return{type:"inlineCode",value:""}}function ge(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Qe(){return{type:"emphasis",children:[]}}function dt(){return{type:"heading",depth:0,children:[]}}function nt(){return{type:"break"}}function vt(){return{type:"html",value:""}}function jt(){return{type:"image",title:null,url:"",alt:null}}function se(){return{type:"link",title:null,url:"",children:[]}}function We(W){return{type:"list",ordered:W.type==="listOrdered",start:null,spread:W._spread,children:[]}}function Ce(W){return{type:"listItem",spread:W._spread,checked:null,children:[]}}function $e(){return{type:"paragraph",children:[]}}function _t(){return{type:"strong",children:[]}}function hn(){return{type:"text",value:""}}function Rn(){return{type:"thematicBreak"}}}function ds(e){return{line:e.line,column:e.column,offset:e.offset}}function $R(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?$R(e,r):DQ(e,r)}}function DQ(e,t){let n;for(n in t)if(zR.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 Xk(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+jc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+jc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+jc({start:t.start,end:t.end})+") is still open")}function OQ(e){const t=this;t.parser=n;function n(r){return LQ(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function BQ(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 zQ(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|