@vantaloom/runtime-darwin-arm64 0.12.34 → 0.12.35

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.
@@ -63,4 +63,4 @@ ${function(e,t=60){if(0===e.length)return"(空表)";let n=Array.from(e.reduc
63
63
  border-radius: 9999px;
64
64
  background-clip: content-box;
65
65
  }
66
- </style>`,/<\/head>/i.test(t)?t.replace(/<\/head>/i,`${n}</head>`):`${n}${t}`},[r,t]);return(0,eb.jsx)("iframe",{title:e,sandbox:"allow-scripts",srcDoc:a,className:(0,ez.cn)("size-full border-0 bg-background",n)})}function XT({file:e,value:t,labels:n}){let r=ew.useMemo(()=>{let n=e.bytes??(t?new TextEncoder().encode(t):[]),r=Math.min(n.length,4096),a=[];for(let e=0;e<r;e+=16){let t=Array.from({length:Math.min(16,r-e)},(t,r)=>n[e+r]??0);a.push({offset:e.toString(16).padStart(8,"0"),hex:t.map(e=>e.toString(16).padStart(2,"0")).join(" "),ascii:t.map(e=>e>=32&&e<=126?String.fromCharCode(e):".").join("")})}return a},[e.bytes,t]);return 0===r.length?(0,eb.jsx)("div",{className:"ui-text-body grid size-full place-items-center p-6 text-center text-muted-foreground",children:n.noContent}):(0,eb.jsx)("div",{className:"size-full overflow-auto bg-background p-3 ui-text-code",children:(0,eb.jsx)("div",{className:"grid min-w-max grid-cols-[5.5rem_30rem_1fr] gap-x-4",children:r.map(e=>(0,eb.jsxs)(ew.Fragment,{children:[(0,eb.jsx)("span",{className:"text-muted-foreground",children:e.offset}),(0,eb.jsx)("span",{className:"font-mono text-foreground",children:e.hex}),(0,eb.jsx)("span",{className:"font-mono text-muted-foreground",children:e.ascii})]},e.offset))})})}function XR({file:e,labels:t,onApprove:n}){return(0,eb.jsx)("div",{className:"grid size-full place-items-center bg-muted/20 p-6",children:(0,eb.jsxs)("div",{className:"grid max-w-md justify-items-center gap-3 text-center",children:[(0,eb.jsx)("div",{className:"grid size-10 place-items-center rounded-full border bg-background text-muted-foreground",children:(0,eb.jsx)(Xx,{className:"size-4"})}),(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsx)("h3",{className:"ui-text-body font-medium text-foreground",children:t.binaryTitle}),(0,eb.jsx)("p",{className:"ui-text-body text-muted-foreground",children:t.binaryDescription})]}),(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[XM(e.size)&&(0,eb.jsx)(Vp,{variant:"outline",children:XM(e.size)}),(0,eb.jsx)(eO.Button,{type:"button",size:"sm",variant:"outline",onClick:n,children:t.renderAnyway})]})]})})}function XD({labels:e}){return(0,eb.jsx)("div",{className:"ui-text-body grid size-full place-items-center p-6 text-center text-muted-foreground",children:e.unsupportedPreview})}function X_({file:e,value:t,labels:n,renderPreview:r,className:a}){let i=XS(e),o=e.src?e.src:t&&"svg"===XS(e)?`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`:void 0,l=r?.(e,t);return void 0!==l?(0,eb.jsx)("div",{"data-slot":"file-tab-custom-preview",className:(0,ez.cn)("size-full",a),children:l}):"html"===i||"richtext"===i?(0,eb.jsx)(XA,{title:e.name,value:e.previewContent??t,className:a}):"markdown"===i?(0,eb.jsx)("div",{"data-slot":"file-tab-markdown-preview",className:(0,ez.cn)("size-full overflow-auto bg-background",a),children:(0,eb.jsx)(Xz,{value:t})}):"svg"===i&&o?(0,eb.jsx)("div",{"data-slot":"file-tab-svg-preview",className:(0,ez.cn)("grid size-full place-items-center overflow-auto bg-muted/20 p-6",a),children:(0,eb.jsx)("img",{src:o,alt:e.name,className:"max-h-full max-w-full rounded-lg border bg-background p-4"})}):"image"===i&&o?(0,eb.jsx)("div",{"data-slot":"file-tab-image-preview",className:(0,ez.cn)("grid size-full place-items-center overflow-auto bg-muted/20 p-6",a),children:(0,eb.jsx)("img",{src:o,alt:e.name,className:"max-h-full max-w-full rounded-md"})}):"video"===i&&o?(0,eb.jsx)("div",{"data-slot":"file-tab-video-preview",className:(0,ez.cn)("grid size-full place-items-center bg-muted/20 p-6",a),children:(0,eb.jsx)("video",{src:o,controls:!0,preload:"none",className:"max-h-full max-w-full rounded-md border bg-background"})}):(0,eb.jsx)(XD,{labels:n})}function XL({open:e,labels:t,currentView:n,currentMode:r,saving:a,modified:i,canSwitchView:o,canSwitchMode:l,canSave:s,canOpenHistory:c,onOpenChange:d,onToggleView:u,onToggleMode:f,onSave:m,onHistory:h}){let p=[o?{key:"view",label:"code"===n?t.preview:t.code,onClick:u,icon:"code"===n?(0,eb.jsx)(qR,{className:"size-4"}):(0,eb.jsx)(uW,{className:"size-4"})}:void 0,l?{key:"mode",label:"review"===r?t.edit:t.review,onClick:f,icon:"review"===r?(0,eb.jsx)(Xv,{className:"size-4"}):(0,eb.jsx)(eN,{className:"size-4"})}:void 0,s?{key:"save",label:a?t.saving:t.save,onClick:m,disabled:a||!i,icon:(0,eb.jsx)(Xj,{className:"size-4"})}:void 0,c?{key:"history",label:t.history,onClick:h,icon:(0,eb.jsx)(Xb,{className:"size-4"})}:void 0].filter(e=>void 0!==e);return 0===p.length?null:(0,eb.jsx)("div",{"data-slot":"file-tab-floating-actions",className:"absolute right-3 bottom-3 z-20",children:(0,eb.jsxs)("div",{className:"relative size-8",children:[p.map((t,n)=>(0,eb.jsx)(eO.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.label,disabled:t.disabled,onClick:()=>{t.disabled||t.onClick()},className:(0,ez.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[opacity,transform] duration-150 ease-out",e?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0",t.disabled&&"opacity-45"),style:{transform:e?`translateY(-${(n+1)*42}px)`:void 0},children:t.icon},t.key)),(0,eb.jsx)(eO.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.actions,"aria-expanded":e,onClick:()=>d(!e),className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,eb.jsx)(lG,{className:(0,ez.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}function X$({file:e,value:t,defaultValue:n,onValueChange:r,mode:a,defaultMode:i="review",onModeChange:o,view:l,defaultView:s="code",onViewChange:c,modified:d=!1,onSave:u,onSaveError:f,largeBinaryThreshold:m=2097152,showHeader:h=!0,wrapLines:p=!1,renderPreview:g,onHistory:x,labels:v,className:b,editorClassName:y,previewClassName:w,headerClassName:j,...k}){var N;let S,C,M=ew.useMemo(()=>({...Xk,...v}),[v]),[E,I]=ew.useState(n??e.content??""),[P,O]=ew.useState(i),[z,A]=ew.useState(s),[T,R]=ew.useState(!1),[D,_]=ew.useState(!1),[L,$]=ew.useState(!1),F=ew.useRef(null),B=t??E,V=a??P,H=(N=l??z,(S=XE(e)).includes(N)?N:S[0]),U=XS(e),q=XE(e).length>1,W=!e.readOnly&&["text","code","html","markdown","richtext","svg"].includes(XS(e)),K=!!u&&W&&"code"===H&&(d||L),G="review"===V||!0===e.readOnly,X="binary"===(C=XS(e))||"image"!==C&&"video"!==C&&!!(e.size&&e.size>m&&!e.content),Y=(e.path??e.name).split(/[\\/]+/).filter(Boolean),Z=XM(e.size??B.length);async function J(){if(u&&!L){$(!0);try{await u(B),_(!1)}catch(e){f?.(e)}finally{$(!1)}}}return ew.useEffect(()=>{void 0===t&&I(n??e.content??""),R(!1),_(!1)},[n,e,t]),ew.useEffect(()=>{if(D)return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e);function e(e){let t=e.target;t instanceof Node&&F.current?.contains(t)||_(!1)}},[D]),(0,eb.jsxs)("div",{ref:F,"data-slot":"file-tab-viewer","data-mode":V,"data-view":H,className:(0,ez.cn)("vtl-surface-panel relative grid min-h-0 overflow-hidden rounded-[var(--surface-panel-radius)] border",h?"grid-rows-[auto_minmax(0,1fr)]":"grid-rows-[minmax(0,1fr)]",b),...k,children:[h&&(0,eb.jsxs)("div",{"data-slot":"file-tab-viewer-header",className:(0,ez.cn)("flex min-w-0 items-center gap-2 border-b bg-muted/35 px-3 py-2",j),children:[(0,eb.jsx)("span",{className:"grid size-5 shrink-0 place-items-center rounded-md border bg-background text-muted-foreground",children:"image"===U?(0,eb.jsx)(Xy,{className:"size-3.5"}):"video"===U?(0,eb.jsx)(Xw,{className:"size-3.5"}):"binary"===U?(0,eb.jsx)(Xx,{className:"size-3.5"}):(0,eb.jsx)(b2,{className:"size-3.5"})}),(0,eb.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 ui-text-kbd",children:Y.map((e,t)=>(0,eb.jsxs)(ew.Fragment,{children:[t>0&&(0,eb.jsx)("span",{className:"text-muted-foreground",children:M.pathSeparator}),(0,eb.jsx)("span",{className:(0,ez.cn)("truncate",t===Y.length-1?"font-medium text-foreground":"text-muted-foreground"),children:e})]},`${e}-${t}`))}),(0,eb.jsxs)("div",{className:"hidden shrink-0 items-center gap-1.5 sm:flex",children:[Z&&(0,eb.jsx)(Vp,{variant:"outline",children:Z}),W&&"code"===H&&(G?(0,eb.jsxs)(Vp,{variant:"secondary",children:[(0,eb.jsx)(lq,{className:"size-3"}),M.review]}):(0,eb.jsxs)(Vp,{variant:"outline",children:[(0,eb.jsx)(Xv,{className:"size-3"}),M.edit]}))]})]}),(0,eb.jsx)("div",{"data-slot":"file-tab-viewer-body",className:"min-h-0 overflow-hidden",children:X&&!T?(0,eb.jsx)(XR,{file:e,labels:M,onApprove:()=>R(!0)}):"preview"===H?(0,eb.jsx)(X_,{file:e,value:B,labels:M,renderPreview:g,className:w}):"hex"===H?(0,eb.jsx)(XT,{file:e,value:B,labels:M}):(0,eb.jsx)(XO,{file:e,value:B,readOnly:G,onValueChange:function(e){void 0===t&&I(e),r?.(e)},wrapLines:p,className:y})}),(0,eb.jsx)(XL,{open:D,labels:M,currentView:H,currentMode:V,saving:L,modified:d,canSwitchView:q,canSwitchMode:W&&"code"===H,canSave:K,canOpenHistory:!!(x&&e.path),onOpenChange:_,onToggleView:function(){var e;e="code"===H?"preview":"code",void 0===l&&A(e),c?.(e)},onToggleMode:function(){var e;e="review"===V?"edit":"review",void 0===a&&O(e),o?.(e)},onSave:J,onHistory:()=>{_(!1),x?.(e)}})]})}function XF(e,t){return e[Math.max(0,t-1)]?.id??e[0]?.id}function XB(e){return"string"==typeof e||"number"==typeof e?String(e):void 0}function XV(e,t,n){let r=[...e],a=r[t],i=r[n];return a&&i&&(r[t]=i,r[n]=a),r}function XH({tabs:e,defaultTabs:t=[],activeTabId:n,defaultActiveTabId:r,onActiveTabChange:a,onTabsChange:i,onCreateTab:o,onCloseTab:l,onTabReorder:s,onTabDetach:c,onExternalTabDrop:d,createActions:u=[],tabActions:f=[],reorderable:m=!0,detachable:h=!1,externalDropTypes:p=[],createLabel:g="New tab",moreLabel:x="More tab actions",closeLabel:v="Close tab",scrollLeftLabel:b="Scroll tabs left",scrollRightLabel:y="Scroll tabs right",tabListLabel:w="Open tabs",emptyContent:j,renderContent:k,showContent:N=!0,className:S,tabListClassName:C,contentClassName:M}){let[E,I]=ew.useState(t),P=ew.useRef(null),O=ew.useRef(null),[z,A]=ew.useState(),[T,R]=ew.useState(void 0),D=ew.useRef(void 0),[_,L]=ew.useState(void 0),[$,F]=ew.useState(!1),B=ew.useRef(void 0),V=ew.useRef(void 0),H=ew.useRef(!1),[U,q]=ew.useState(!1),[W,K]=ew.useState(!1),[G,X]=ew.useState(),Y=e??E,Z=Y.find(e=>!e.disabled),[J,Q]=ew.useState(r??Z?.id),ee=n??J,et=Y.find(e=>e.id===ee&&!e.disabled)??Z;ew.useEffect(()=>{!et&&Z&&void 0===n&&Q(Z.id)},[et,n,Z]);let en=ew.useCallback(t=>{void 0===e&&I(t),i?.(t)},[i,e]),er=ew.useCallback(e=>{D.current=e,R(e)},[]),ea=ew.useCallback(()=>{let e=O.current,t=new Map;if(!e)return t;for(let n of e.querySelectorAll("[data-tab-id]")){let e=n.getBoundingClientRect(),r=n.dataset.tabId;r&&t.set(r,{left:e.left,top:e.top})}return t},[]),ei=ew.useCallback((e,t=!0)=>{t&&(V.current=ea()),B.current=e,L(e)},[ea]),eo=ew.useCallback(()=>{let e=O.current;if(!e){q(!1),K(!1);return}let t=e.scrollWidth-e.clientWidth;q(e.scrollLeft>1),K(e.scrollLeft<t-1)},[]);function el(e){let t=O.current;if(!t)return;let n=Math.max(.7*t.clientWidth,160);t.scrollLeft+="left"===e?-n:n,window.requestAnimationFrame(eo)}ew.useEffect(()=>{F(!0)},[]),ew.useEffect(()=>{eo();let e=O.current;if(!e)return;let t=new ResizeObserver(eo);return t.observe(e),window.addEventListener("resize",eo),()=>{t.disconnect(),window.removeEventListener("resize",eo)}},[Y.length,eo]),ew.useLayoutEffect(()=>{let e=V.current,t=O.current;if(e&&t)for(let n of(V.current=void 0,t.querySelectorAll("[data-tab-id]"))){let t=n.dataset.tabId;if(!t)continue;let r=e.get(t);if(!r)continue;let a=n.getBoundingClientRect(),i=r.left-a.left,o=r.top-a.top;1>Math.abs(i)&&1>Math.abs(o)||n.animate([{transform:`translate(${i}px, ${o}px)`},{transform:"translate(0, 0)"}],{duration:150,easing:"cubic-bezier(0.2, 0, 0, 1)"})}},[_]);let es=ew.useCallback(e=>{let t=O.current;if(t)return Array.from(t.querySelectorAll("[data-tab-id]")).find(t=>t.dataset.tabId===e)},[]),ec=ew.useCallback((e,t)=>{let n=B.current??Y,r=n.findIndex(t=>t.id===e.tabId);if(-1===r)return;let a=t-e.offsetX,i=a+e.width,o=t>=e.currentX,l=n[r+1],s=n[r-1];if(o&&l&&!l.disabled){let e=es(l.id),t=e?.getBoundingClientRect();t&&i>=t.left+.7*t.width&&ei(XV(n,r,r+1));return}if(!o&&s&&!s.disabled){let e=es(s.id),t=e?.getBoundingClientRect();t&&a<=t.right-.7*t.width&&ei(XV(n,r,r-1))}},[es,Y,ei]);function ed(e){if(!d||0===p.length)return!1;let t=Array.from(e.dataTransfer.types);return p.some(e=>t.includes(e))}function eu(e){let t=O.current;if(!t)return{index:Y.length,left:0};let n=t.getBoundingClientRect(),r=Array.from(t.querySelectorAll("[data-tab-id]"));if(0===r.length)return{index:0,left:t.scrollLeft+8};for(let[a,i]of r.entries()){let r=i.getBoundingClientRect();if(e.clientX<r.left+r.width/2)return{index:a,left:r.left-n.left+t.scrollLeft}}let a=r[r.length-1].getBoundingClientRect();return{index:r.length,left:a.right-n.left+t.scrollLeft}}ew.useEffect(()=>{if(T)return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t,{once:!0}),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t)};function e(e){let t=D.current;if(!t)return;let n=e.clientX-t.startX,r=e.clientY-t.startY,a=t.dragging||Math.abs(n)>4||Math.abs(r)>4;a&&(e.preventDefault(),ec(t,e.clientX)),er({...t,currentX:e.clientX,currentY:e.clientY,dragging:a})}function t(e){let t=D.current;if(t?.dragging){e.preventDefault(),H.current=!0;let r=Y.find(e=>e.id===t.tabId),i=P.current?.getBoundingClientRect(),o=!!i&&(e.clientX<i.left||e.clientX>i.right||e.clientY<i.top||e.clientY>i.bottom);if(h&&c&&r&&o&&function(e,t){if(e.pinned)return!1;let r=Y.findIndex(t=>t.id===e.id);if(c?.(e,{tabs:Y,clientX:t.clientX,clientY:t.clientY,nativeEvent:t})===!1)return!1;let i=Y.filter(t=>t.id!==e.id);if(en(i),e.id===ee){let e=XF(i,r);void 0===n&&Q(e),e&&a?.(e)}return!0}(r,e)){A(void 0),er(void 0),ei(void 0,!1);return}let l=B.current;l&&!(l.length===Y.length&&l.every((e,t)=>e.id===Y[t]?.id))&&(en(l),s?.(l))}A(void 0),er(void 0),ei(void 0,!1)}});let ef=et&&(k?.(et)??et.content??(0,eb.jsx)("div",{className:"grid min-h-44 place-items-center bg-muted/30 p-6 text-center text-muted-foreground",children:et.title})),em=T?.dragging&&_?_:Y,eh=T?.dragging?Y.find(e=>e.id===T.tabId):void 0,ep=T?.dragging&&eh&&$?(0,ix.createPortal)((0,eb.jsxs)("div",{"data-slot":"multi-tab-drag-preview","aria-hidden":"true",className:"pointer-events-none fixed z-[100] flex h-9 min-w-0 items-center gap-1 rounded-t-lg border border-border bg-background px-2.5 text-foreground shadow-lg",style:{left:T.currentX-T.offsetX,top:T.top,width:T.width},children:[eh.icon&&(0,eb.jsx)("span",{className:"grid size-4 shrink-0 place-items-center text-muted-foreground [&_svg]:size-3.5",children:eh.icon}),(0,eb.jsx)("span",{className:"truncate ui-text-control font-medium",children:eh.title}),eh.modified&&(0,eb.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-foreground/70"})]}),document.body):null;return(0,eb.jsxs)("div",{ref:P,"data-slot":"multi-tab-system",className:(0,ez.cn)("vtl-surface-panel grid min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden rounded-[var(--surface-panel-radius)] border",S),children:[(0,eb.jsxs)("div",{className:"relative flex min-w-0 shrink-0 items-end gap-1 border-b bg-muted/35 px-1.5 pt-1.5",children:[U&&(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":b,onClick:()=>el("left"),className:"mb-1 shrink-0",children:(0,eb.jsx)(h8,{})}),(0,eb.jsxs)("div",{ref:O,role:"tablist","aria-label":w,"data-slot":"multi-tab-list",className:(0,ez.cn)("relative flex min-w-0 flex-1 items-end overflow-x-auto [scrollbar-width:none] data-[overflow=both]:[mask-image:linear-gradient(90deg,transparent,black_24px,black_calc(100%-24px),transparent)] data-[overflow=left]:[mask-image:linear-gradient(90deg,transparent,black_24px)] data-[overflow=right]:[mask-image:linear-gradient(90deg,black_calc(100%-24px),transparent)] [&::-webkit-scrollbar]:hidden",C),"data-overflow":U&&W?"both":U?"left":W?"right":void 0,onScroll:eo,onDragOver:function(e){ed(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move",X(eu(e)))},onDragLeave:function(e){if(!ed(e))return;let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||X(void 0)},onDrop:function(e){if(!ed(e))return;e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move";let t=eu(e);X(void 0),d?.({tabs:Y,insertIndex:t.index,nativeEvent:e})},children:[em.map((e,t)=>{let r=e.id===et?.id,i=em[t+1],o=T?.dragging&&z===e.id,s=!r&&!o&&void 0!==i&&i.id!==et?.id&&i.id!==z;return(0,eb.jsxs)(ew.Fragment,{children:[(0,eb.jsxs)("div",{onPointerDown:t=>(function(e,t){if(!m||e.disabled||0!==t.button)return;let n=t.currentTarget.getBoundingClientRect();A(e.id),ei(Y,!1),er({tabId:e.id,startX:t.clientX,startY:t.clientY,offsetX:t.clientX-n.left,top:n.top,width:n.width,currentX:t.clientX,currentY:t.clientY,dragging:!1})})(e,t),"data-slot":"multi-tab","data-tab-id":e.id,"data-state":r?"active":"inactive","data-dragging":z===e.id?"true":void 0,"data-modified":e.modified?"true":void 0,className:(0,ez.cn)("group/tab relative flex h-9 min-w-0 max-w-52 shrink-0 items-center gap-1 rounded-t-lg border border-b-0 px-2.5 transition-[border-color,background-color,color,box-shadow,outline-color] duration-150 ease-out",m&&!e.disabled&&"cursor-grab active:cursor-grabbing",r?"border-border bg-background text-foreground shadow-[0_-1px_0_var(--background)_inset]":"border-transparent bg-transparent text-muted-foreground hover:bg-background/70 hover:text-foreground",o&&"border-dashed border-border bg-muted/45 text-transparent shadow-none outline outline-1 outline-ring/30 [&_*]:opacity-0",e.disabled&&"pointer-events-none opacity-50"),children:[(0,eb.jsx)("button",{type:"button",role:"tab","aria-label":XB(e.title),"aria-selected":r,disabled:e.disabled,onClick:t=>{var r;let i;if(H.current){H.current=!1,t.preventDefault();return}r=e.id,(i=Y.find(e=>e.id===r))&&!i.disabled&&(void 0===n&&Q(r),a?.(r))},className:"absolute inset-0 rounded-t-lg outline-none focus-visible:ring-2 focus-visible:ring-ring/50"}),(0,eb.jsxs)("div",{"aria-hidden":"true",className:"pointer-events-none relative z-10 flex min-w-0 flex-1 items-center gap-1.5",children:[e.icon&&(0,eb.jsx)("span",{className:"grid size-4 shrink-0 place-items-center text-muted-foreground [&_svg]:size-3.5",children:e.icon}),(0,eb.jsx)("span",{className:"truncate ui-text-control font-medium",children:e.title}),e.meta&&(0,eb.jsx)("span",{className:"shrink-0 ui-text-kbd text-muted-foreground",children:e.meta}),e.modified&&(0,eb.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-foreground/70"})]}),!e.pinned&&(0,eb.jsx)("button",{type:"button",draggable:!1,onPointerDown:e=>e.stopPropagation(),"aria-label":e.closeLabel??(XB(e.title)?`${v}: ${XB(e.title)}`:v),onClick:()=>(function(e){if(e.pinned)return;let t=Y.findIndex(t=>t.id===e.id),r=Y.filter(t=>t.id!==e.id);if(en(r),l?.(e),e.id===ee){let e=XF(r,t);void 0===n&&Q(e),e&&a?.(e)}})(e),className:(0,ez.cn)("relative z-20 grid size-5 shrink-0 place-items-center rounded-md text-muted-foreground opacity-0 transition-all hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none group-hover/tab:opacity-100",r&&"opacity-100"),children:(0,eb.jsx)(fV.XIcon,{className:"size-3.5"})})]}),s&&(0,eb.jsx)("span",{"aria-hidden":"true",className:"mb-2 h-4 w-px shrink-0 bg-border/80"})]},e.id)}),G?(0,eb.jsxs)("span",{"data-slot":"multi-tab-external-insert","aria-hidden":"true",className:"pointer-events-none absolute top-2 bottom-1 z-30 flex w-0 -translate-x-1/2 items-center justify-center",style:{left:G.left},children:[(0,eb.jsx)("span",{className:"h-full w-px rounded-full bg-foreground/80"}),(0,eb.jsx)("span",{className:"absolute top-0 size-1.5 rounded-full bg-foreground"})]}):null]}),(0,eb.jsxs)("div",{className:"mb-1 flex shrink-0 items-center gap-1",children:[W&&(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":y,onClick:()=>el("right"),children:(0,eb.jsx)(h7,{})}),u.length>0?(0,eb.jsxs)(wA,{children:[(0,eb.jsx)(wR,{asChild:!0,children:(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":g,children:(0,eb.jsx)(lY,{})})}),(0,eb.jsx)(wG,{align:"end",className:"w-52",children:u.map((e,t)=>(0,eb.jsxs)(ew.Fragment,{children:[e.separatorBefore&&(0,eb.jsx)(wJ,{}),(0,eb.jsxs)(wX,{disabled:e.disabled,onSelect:e.onSelect,children:[e.icon,e.label,e.shortcut&&(0,eb.jsx)(wQ,{children:e.shortcut})]})]},t))})]}):(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":g,onClick:function(){let e=o?.();e&&(en([...Y,e]),e.disabled||(void 0===n&&Q(e.id),a?.(e.id)))},children:(0,eb.jsx)(lY,{})}),f.length>0&&(0,eb.jsxs)(wA,{children:[(0,eb.jsx)(wR,{asChild:!0,children:(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":x,children:(0,eb.jsx)(lG,{})})}),(0,eb.jsx)(wG,{align:"end",className:"w-52",children:f.map((e,t)=>(0,eb.jsxs)(ew.Fragment,{children:[e.separatorBefore&&(0,eb.jsx)(wJ,{}),(0,eb.jsxs)(wX,{disabled:e.disabled,onSelect:e.onSelect,children:[e.icon,e.label,e.shortcut&&(0,eb.jsx)(wQ,{children:e.shortcut})]})]},t))})]})]})]}),ep,N&&(0,eb.jsx)("div",{"data-slot":"multi-tab-content",className:(0,ez.cn)("min-h-0 overflow-hidden",M),children:ef??j??(0,eb.jsx)("div",{"aria-hidden":"true",className:"min-h-44 rounded-lg border border-dashed bg-muted/30"})})]})}let XU=(0,ek.default)("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),Xq=(0,ek.default)("repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);var XW="Tabs",[XK,XG]=cC(XW,[hj]),XX=hj(),[XY,XZ]=XK(XW),XJ=ew.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:l,activationMode:s="automatic",...c}=e,d=hh(l),[u,f]=cT({prop:r,onChange:a,defaultProp:i??"",caller:XW});return(0,eb.jsx)(XY,{scope:n,baseId:cz(),value:u,onValueChange:f,orientation:o,dir:d,activationMode:s,children:(0,eb.jsx)(cL.div,{dir:d,"data-orientation":o,...c,ref:t})})});XJ.displayName=XW;var XQ="TabsList",X0=ew.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...a}=e,i=XZ(XQ,n),o=XX(n);return(0,eb.jsx)(hS,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:r,children:(0,eb.jsx)(cL.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:t})})});X0.displayName=XQ;var X1="TabsTrigger",X2=ew.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:a=!1,...i}=e,o=XZ(X1,n),l=XX(n),s=X3(o.baseId,r),c=X6(o.baseId,r),d=r===o.value;return(0,eb.jsx)(hE,{asChild:!0,...l,focusable:!a,active:d,children:(0,eb.jsx)(cL.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":c,"data-state":d?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:s,...i,ref:t,onMouseDown:cE(e.onMouseDown,e=>{a||0!==e.button||!1!==e.ctrlKey?e.preventDefault():o.onValueChange(r)}),onKeyDown:cE(e.onKeyDown,e=>{[" ","Enter"].includes(e.key)&&o.onValueChange(r)}),onFocus:cE(e.onFocus,()=>{let e="manual"!==o.activationMode;d||a||!e||o.onValueChange(r)})})})});X2.displayName=X1;var X5="TabsContent",X4=ew.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:a,children:i,...o}=e,l=XZ(X5,n),s=X3(l.baseId,r),c=X6(l.baseId,r),d=r===l.value,u=ew.useRef(d);return ew.useEffect(()=>{let e=requestAnimationFrame(()=>u.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,eb.jsx)(c2,{present:a||d,children:({present:n})=>(0,eb.jsx)(cL.div,{"data-state":d?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":s,hidden:!n,id:c,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:u.current?"0s":void 0},children:n&&i})})});function X3(e,t){return`${e}-trigger-${t}`}function X6(e,t){return`${e}-content-${t}`}function X8({className:e,children:t,...n}){let r=ew.useRef(null),{thumb:a,ready:i}=function(e){let[t,n]=ew.useState(null),[r,a]=ew.useState(!1),i=ew.useCallback(()=>{let t=e.current;if(!t)return;let r=t.querySelector('[data-state="active"]');r?n({left:r.offsetLeft,top:r.offsetTop,width:r.offsetWidth,height:r.offsetHeight}):n(null)},[e]);return ew.useEffect(()=>{let t=e.current;if(!t)return;i();let n=new MutationObserver(i);n.observe(t,{attributes:!0,attributeFilter:["data-state"],subtree:!0,childList:!0});let r=null;if("u">typeof ResizeObserver)for(let e of((r=new ResizeObserver(i)).observe(t),Array.from(t.children)))r.observe(e);let o=()=>i();window.addEventListener("resize",o);let l=window.requestAnimationFrame(()=>a(!0));return()=>{n.disconnect(),r?.disconnect(),window.removeEventListener("resize",o),window.cancelAnimationFrame(l)}},[i,e]),{thumb:t,ready:r}}(r);return(0,eb.jsxs)(X0,{ref:r,"data-slot":"tabs-list",className:(0,ez.cn)("relative inline-flex h-8 items-center justify-center gap-0.5 rounded-lg bg-muted p-1 text-muted-foreground",e),...n,children:[a?(0,eb.jsx)("span",{"aria-hidden":!0,"data-slot":"tabs-thumb",className:(0,ez.cn)("pointer-events-none absolute top-0 left-0 z-0 rounded-md bg-background shadow-xs",i&&"transition-[transform,width,height] duration-200 ease-out"),style:{transform:`translate(${a.left}px, ${a.top}px)`,width:a.width,height:a.height}}):null,t]})}function X7({className:e,...t}){return(0,eb.jsx)(X2,{"data-slot":"tabs-trigger",className:(0,ez.cn)("relative z-10 inline-flex h-6 shrink-0 items-center justify-center gap-1.5 rounded-md px-2.5 text-sm font-medium whitespace-nowrap transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:text-foreground [&_svg]:pointer-events-none [&_svg]:size-3.5 [&_svg]:shrink-0",e),...t})}function X9({className:e,...t}){return(0,eb.jsx)(X4,{"data-slot":"tabs-content",className:(0,ez.cn)("mt-3 outline-none focus-visible:ring-2 focus-visible:ring-ring/50 animate-in fade-in-0 duration-150",e),...t})}function Ye(e){let{models:t,loading:n}=e,[r,a]=ew.useState(""),i=ew.useMemo(()=>"multi"===e.mode?e.value:e.value?[e.value]:[],[e]),o=ew.useMemo(()=>new Set(i),[i]),l="multi"===e.mode?e.primaryModelId:void 0,s=null===l?void 0:l&&o.has(l)?l:void 0===l?i[0]:void 0,c=ew.useMemo(()=>t.filter(e=>!1!==e.available),[t]),d=ew.useMemo(()=>{let e=new Map;for(let t of c){let n=t.providerName?.trim()||"其他",r=e.get(n);r?r.push(t):e.set(n,[t])}return Array.from(e.entries()).map(([e,t])=>({provider:e,models:t}))},[c]),u=ew.useMemo(()=>{let e=r.trim().toLowerCase();return e?d.map(t=>({provider:t.provider,models:t.models.filter(n=>n.label.toLowerCase().includes(e)||t.provider.toLowerCase().includes(e))})).filter(e=>e.models.length>0):d},[d,r]),f=ew.useMemo(()=>new Set(c.map(e=>e.value)),[c]),m=ew.useMemo(()=>new Map(t.map(e=>[e.value,e])),[t]),h=ew.useMemo(()=>"multi"!==e.mode?[]:i.filter(e=>!f.has(e)).map(e=>{let t=m.get(e);return{id:e,label:t?.label??e,provider:t?.providerName?.trim()||""}}),[e.mode,i,f,m]),p=ew.useMemo(()=>{let e=r.trim().toLowerCase();return e?h.filter(t=>t.id.toLowerCase().includes(e)||t.label.toLowerCase().includes(e)||t.provider.toLowerCase().includes(e)):h},[h,r]),g=ew.useCallback(t=>{"single"===e.mode?e.onChange(e.value===t?"":t):e.onChange(o.has(t)?e.value.filter(e=>e!==t):[...e.value,t])},[e,o]),x=ew.useCallback(t=>{if("multi"!==e.mode)return;let n=t.map(e=>e.value);if(n.every(e=>o.has(e))){let t=new Set(n);e.onChange(e.value.filter(e=>!t.has(e)))}else{let t=n.filter(e=>!o.has(e));e.onChange([...e.value,...t])}},[e,o]),v="single"===e.mode?e.clearLabel??"无 / 默认":"";return(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsxs)("div",{className:"relative",children:[(0,eb.jsx)(vu,{className:"pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),(0,eb.jsx)(eA,{value:r,onChange:e=>a(e.target.value),placeholder:"搜索模型或渠道...",className:"h-8 pl-8"})]}),(0,eb.jsxs)("div",{className:"grid max-h-[min(22rem,50svh)] gap-3 overflow-auto rounded-lg border bg-card/40 p-2",children:["single"===e.mode?(0,eb.jsxs)("div",{role:"button",tabIndex:0,"aria-pressed":""===e.value,onClick:()=>e.onChange(""),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),e.onChange(""))},className:(0,ez.cn)("flex cursor-pointer items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-sm outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring/50",""===e.value?"bg-primary/10 text-foreground":"hover:bg-muted"),children:[(0,eb.jsx)(vM,{checked:""===e.value,tabIndex:-1,className:"pointer-events-none"}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:v})]}):null,n&&0===t.length?(0,eb.jsx)("p",{className:"px-2 py-6 text-center text-xs text-muted-foreground",children:"读取模型中…"}):0===u.length&&0===p.length?(0,eb.jsx)("p",{className:"px-2 py-6 text-center text-xs text-muted-foreground",children:0===t.length?e.emptyHint??"没有可用模型":"没有匹配的模型"}):(0,eb.jsxs)(eb.Fragment,{children:[u.map(t=>{let n=t.models.map(e=>e.value),r=n.filter(e=>o.has(e)).length,a=r===n.length;return(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2 px-1",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,eb.jsx)("span",{className:"truncate text-xs font-semibold text-foreground",children:t.provider}),(0,eb.jsxs)("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:[r,"/",n.length]})]}),"multi"===e.mode?(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"sm",className:"h-6 shrink-0 px-2 text-xs",onClick:()=>x(t.models),children:a?"取消全选":"全选"}):null]}),(0,eb.jsx)("div",{className:"grid gap-0.5",children:t.models.map(t=>{let n=o.has(t.value),r="multi"===e.mode&&t.value===s;return(0,eb.jsxs)("div",{role:"button",tabIndex:0,"aria-pressed":n,onClick:()=>g(t.value),onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),g(t.value))},className:(0,ez.cn)("flex cursor-pointer items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-sm outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring/50",n?"bg-primary/10 text-foreground":"hover:bg-muted"),children:[(0,eb.jsx)(vM,{checked:n,tabIndex:-1,className:"pointer-events-none"}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t.label}),r?(0,eb.jsx)("span",{className:"shrink-0 rounded bg-primary/15 px-1.5 py-0.5 text-[10px] font-medium text-primary",children:"主"}):null]},t.value)})})]},t.provider)}),p.length>0?(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 px-1",children:[(0,eb.jsx)("span",{className:"truncate text-xs font-semibold text-muted-foreground",children:"已禁用 / 不可用"}),(0,eb.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:p.length})]}),(0,eb.jsx)("div",{className:"grid gap-0.5",children:p.map(e=>(0,eb.jsxs)("div",{role:"button",tabIndex:0,"aria-pressed":!0,title:"该模型所属渠道已禁用或不可用,点击可移除",onClick:()=>g(e.id),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),g(e.id))},className:(0,ez.cn)("flex cursor-pointer items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-sm opacity-60 outline-none transition-colors hover:bg-muted hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/50"),children:[(0,eb.jsx)(vM,{checked:!0,tabIndex:-1,className:"pointer-events-none"}),(0,eb.jsxs)("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:[e.label,e.provider?(0,eb.jsxs)("span",{className:"ml-1.5 text-[11px] text-muted-foreground/70",children:["· ",e.provider]}):null]}),(0,eb.jsx)("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:"不可用"})]},e.id))})]}):null]})]})]})}function Yt({status:e}){return"done"===e?(0,eb.jsx)(h6,{className:"size-3.5 shrink-0 text-emerald-500"}):"in_progress"===e?(0,eb.jsx)(HE,{className:"size-3.5 shrink-0 text-amber-500"}):"blocked"===e||"skipped"===e?(0,eb.jsx)(XU,{className:"size-3.5 shrink-0 text-rose-500"}):(0,eb.jsx)(wk,{className:"size-3.5 shrink-0 text-muted-foreground/50"})}function Yn({done:e,total:t}){let n=t>0?Math.round(e/t*100):0;return(0,eb.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,eb.jsx)("div",{className:"h-1.5 w-16 overflow-hidden rounded-full bg-muted",children:(0,eb.jsx)("div",{className:"h-full rounded-full bg-foreground transition-all",style:{width:`${n}%`}})}),(0,eb.jsxs)("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground",children:[e,"/",t]})]})}X4.displayName=X5;let Yr={main:"主",subagent:"子"};function Ya({node:e,onSet:t}){let{models:n,loading:r}=vH(),[a,i]=ew.useState(!1),o=e.orchestration?.modelRef??"",l=o&&n.length>0?n.find(e=>e.value===o)?.label??o:"";return(0,eb.jsxs)(bC,{open:a,onOpenChange:i,children:[(0,eb.jsx)(bP,{asChild:!0,children:(0,eb.jsx)("button",{type:"button",className:(0,ez.cn)("shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium transition-colors",o?"bg-sky-teal/15 text-sky-teal hover:bg-sky-teal/25":"bg-muted text-muted-foreground hover:bg-muted/70"),title:o?`已指定模型:${l}`:"为该子代理节点指定模型",onClick:e=>e.stopPropagation(),children:o?`模型\xb7${l}`:"模型"})}),(0,eb.jsx)(bH,{align:"end",className:"w-72 p-2",onClick:e=>e.stopPropagation(),children:(0,eb.jsx)(Ye,{mode:"single",models:n,loading:r,value:o,onChange:n=>{t(e.id,n),i(!1)},clearLabel:"默认(由 agent 自行指定)"})})]})}function Yi({node:e,depth:t,activeId:n,onSetNodeModel:r}){let a=function e(t){if(!t.children||0===t.children.length)return"task"!==t.kind&&"subplan"!==t.kind?{done:0,total:0}:{done:+("done"===t.status),total:1};let n=0,r=0;for(let a of t.children){let t=e(a);n+=t.done,r+=t.total}return{done:n,total:r}}(e),i="phase"===e.kind,o=e.orchestration,l=void 0!==n&&e.id===n,s=o?.executor==="subagent";return(0,eb.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,eb.jsxs)("div",{className:(0,ez.cn)("flex items-center gap-2 rounded-md px-1.5 py-1",l&&"bg-sky-teal/10 ring-1 ring-sky-teal/30"),style:{marginLeft:12*t},children:[(0,eb.jsx)(Yt,{status:e.status}),(0,eb.jsx)("span",{className:(0,ez.cn)("min-w-0 flex-1 truncate text-[13px]","done"===e.status&&"text-muted-foreground line-through",l&&"font-medium text-foreground"),title:e.detail||e.title,children:e.title}),i&&o?(0,eb.jsxs)("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:[Yr[o.executor]??o.executor,o.subagentType?`:${o.subagentType}`:""]}):null,s&&r?(0,eb.jsx)(Ya,{node:e,onSet:r}):null,i&&a.total>0?(0,eb.jsx)(Yn,{done:a.done,total:a.total}):null]}),e.children?.map(e=>(0,eb.jsx)(Yi,{node:e,depth:t+1,activeId:n,onSetNodeModel:r},e.id))]})}function Yo({conversationId:e,ownerMachineId:t}){let[n,r]=ew.useState(null),[a,i]=ew.useState(""),[o,l]=ew.useState(!1),[s,c]=ew.useState(!1),[d,u]=ew.useState(!1),[f,m]=ew.useState(!1),h=ew.useRef(void 0);ew.useEffect(()=>()=>{h.current&&window.clearTimeout(h.current)},[]);let p=ew.useCallback(async()=>{if(a.trim())try{await navigator.clipboard.writeText(a),m(!0),h.current&&window.clearTimeout(h.current),h.current=window.setTimeout(()=>m(!1),1600)}catch{}},[a]),g=ew.useCallback((n,a)=>{e&&(r(e=>{if(!e?.tree)return e;let t=e=>e.id===n&&e.orchestration?{...e,orchestration:{...e.orchestration,modelRef:a}}:e.children?{...e,children:e.children.map(t)}:e;return{...e,tree:t(e.tree)}}),cf(e,{nodeId:n,modelRef:a},t))},[e,t]);ew.useEffect(()=>{if(l(!1),!e)return;let n=!0;return(async()=>{try{let r=await sD(e,t);n&&l(r.conversation.loopMode??!1)}catch{}})(),()=>{n=!1}},[e,t]);let x=ew.useCallback(async n=>{if(e){c(!0),l(n);try{let r=await cs(e,n,t);l(r.conversation.loopMode??n)}catch{l(!n)}finally{c(!1)}}},[e,t]),v=ew.useCallback(()=>{o?x(!1):u(!0)},[o,x]);ew.useEffect(()=>{if(r(null),i(""),!e)return;let n=!0,a=0,o=async()=>{let o=a+=1,l=await sF(e,t);n&&o===a&&(r(l.planState),void 0!==l.planDoc&&i(l.planDoc))};o();let l=window.setInterval(o,1200);return()=>{n=!1,window.clearInterval(l)}},[e,t]);let b=n?.activePath?.length?n.activePath[n.activePath.length-1]:void 0;return(0,eb.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col rounded-[inherit] bg-background",children:[(0,eb.jsxs)(XJ,{defaultValue:"doc",className:"flex min-h-0 flex-1 flex-col gap-0",children:[(0,eb.jsxs)("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b px-2 py-1.5",children:[(0,eb.jsxs)(X8,{children:[(0,eb.jsx)(X7,{value:"doc",children:"计划文档"}),(0,eb.jsx)(X7,{value:"tree",children:"执行树"})]}),(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",variant:o?"default":"outline",disabled:!e||s,onClick:v,className:"h-7 shrink-0 gap-1.5 px-2 text-xs",title:o?"循环模式开启中:会话每轮结束后会自动续跑,直到执行树没有剩余可完成的任务。点击关闭。":"开启循环模式:会话每轮结束后自动续跑,持续完成执行树中的剩余任务",children:[(0,eb.jsx)(Xq,{className:"size-3.5"}),"循环模式",o?"·开":""]})]}),(0,eb.jsxs)(X9,{value:"doc",className:"relative min-h-0 min-w-0 flex-1",children:[a.trim()?(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",variant:"outline",onClick:()=>void p(),className:"absolute right-3 top-2 z-10 h-7 gap-1.5 px-2 text-xs",title:"复制计划文档原文",children:[f?(0,eb.jsx)(h6,{className:"size-3.5 text-emerald-500"}):(0,eb.jsx)(lV,{className:"size-3.5"}),f?"已复制":"复制"]}):null,(0,eb.jsx)(jP,{className:"h-full w-full min-w-0",viewportClassName:"vtl-doc-viewport",children:(0,eb.jsx)("div",{className:"min-w-0 px-4 py-3 text-sm break-words [overflow-wrap:anywhere] select-text",children:a.trim()?(0,eb.jsx)(H1,{content:a}):(0,eb.jsx)("p",{className:"text-muted-foreground/70",children:"尚无可读计划文档。"})})})]}),(0,eb.jsx)(X9,{value:"tree",className:"min-h-0 min-w-0 flex-1",children:(0,eb.jsx)(jP,{className:"h-full w-full min-w-0",children:(0,eb.jsx)("div",{className:"min-w-0 px-2 py-2",children:n?.tree?(0,eb.jsx)(Yi,{node:n.tree,depth:0,activeId:b,onSetNodeModel:g}):(0,eb.jsx)("p",{className:"px-2 py-1 text-sm text-muted-foreground/70",children:"计划尚未编译成执行树。"})})})})]}),(0,eb.jsx)(ux,{open:d,onOpenChange:u,children:(0,eb.jsxs)(uR,{children:[(0,eb.jsxs)(uD,{children:[(0,eb.jsx)(uL,{children:"开启循环模式?"}),(0,eb.jsx)(u$,{asChild:!0,children:(0,eb.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,eb.jsx)("p",{children:"开启后,每当 agent 完成一轮工作(运行自然结束)时,系统会自动注入「继续」消息, 让它继续完成执行树中剩余未完成的任务——这一切在后端进行,即使你关闭页面也会持续。"}),(0,eb.jsx)("p",{children:"循环只有在以下情况才会停止:执行树中没有剩余的「待完成(待办/进行中)」任务、 你关闭循环模式、达到安全上限(最多自动续跑 25 次)、存在等待外部事件的 hook, 或本轮运行出错/被你中止。无法完成的任务请让 agent 标记为「阻塞」。"})]})})]}),(0,eb.jsxs)(u_,{children:[(0,eb.jsx)(uB,{children:"取消"}),(0,eb.jsx)(uF,{onClick:()=>void x(!0),children:"开启"})]})]})})]})}function Yl({conversationId:e,ownerMachineId:t,initialPath:n}){let[r,a]=ew.useState([]),[i,o]=ew.useState(n),[l,s]=ew.useState("");return ew.useEffect(()=>{if(!e)return;let n=!0,r=async()=>{let r=await sV(e,t);if(!n)return;let i=r.filter(e=>e.startsWith("plan/specs/"));a(i),o(e=>e??i[0])};r();let i=window.setInterval(r,1200);return()=>{n=!1,window.clearInterval(i)}},[e,t]),ew.useEffect(()=>{if(!e||!i)return void s("");let n=!0,r=async()=>{try{let r=await sB(e,i,t);n&&s(r.content)}catch{n&&s("")}};r();let a=window.setInterval(r,1200);return()=>{n=!1,window.clearInterval(a)}},[e,t,i]),(0,eb.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col rounded-[inherit] bg-background",children:[(0,eb.jsx)("div",{className:"flex shrink-0 flex-wrap gap-1 border-b px-2 py-1.5",children:0===r.length?(0,eb.jsx)("span",{className:"px-1 py-1 text-xs text-muted-foreground/70",children:"尚无规范文档"}):r.map(e=>(0,eb.jsxs)("button",{type:"button",className:(0,ez.cn)("flex items-center gap-1.5 rounded-md px-2 py-1 text-xs transition-colors",e===i?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted/60"),onClick:()=>o(e),children:[(0,eb.jsx)(uX,{className:"size-3.5"}),e.split("/").pop()??e]},e))}),(0,eb.jsx)(jP,{className:"min-h-0 w-full min-w-0 flex-1",viewportClassName:"vtl-doc-viewport",children:(0,eb.jsx)("div",{className:"min-w-0 px-4 py-3 text-sm break-words [overflow-wrap:anywhere]",children:l.trim()?(0,eb.jsx)(H1,{content:l}):(0,eb.jsx)("p",{className:"text-muted-foreground/70",children:i?"(空文档)":"选择左上方的规范文档查看。"})})})]})}var Ys=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let n=(0,lQ.createSlot)(`Primitive.${t}`),r=ew.forwardRef((e,r)=>{let{asChild:a,...i}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,eb.jsx)(a?n:t,{...i,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),Yc=ew.forwardRef((e,t)=>(0,eb.jsx)(Ys.label,{...e,ref:t,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));function Yd({className:e,...t}){return(0,eb.jsx)(Yc,{"data-slot":"label",className:(0,ez.cn)("flex w-fit items-center gap-2 text-sm font-medium leading-snug peer-disabled:cursor-not-allowed peer-disabled:opacity-50 group-data-[disabled=true]/field:opacity-50",e),...t})}function Yu({url:e}){let[t,n]=ew.useState(!1),r=ew.useCallback(async()=>{try{await navigator.clipboard.writeText(e),n(!0),window.setTimeout(()=>n(!1),1500)}catch{}},[e]);return(0,eb.jsxs)("button",{type:"button",onClick:r,title:e,className:"flex min-w-0 items-center gap-1 rounded border bg-muted/40 px-1.5 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[t?(0,eb.jsx)(h6,{className:"size-3 shrink-0 text-emerald-500"}):(0,eb.jsx)(lV,{className:"size-3 shrink-0"}),(0,eb.jsx)("span",{className:"truncate font-mono",children:e})]})}function Yf({conversationId:e,ownerMachineId:t}){let[n,r]=ew.useState(void 0),[a,i]=ew.useState(void 0),[o,l]=ew.useState(!1),s=ew.useCallback(async()=>{if(!e)return;let n=await s1(e,t);return r(n),n},[e,t]);ew.useEffect(()=>{if(!e)return void r(void 0);let n=!0,a=async()=>{let a=await s1(e,t);n&&r(a)};a();let i=window.setInterval(a,2e3);return()=>{n=!1,window.clearInterval(i)}},[e,t]);let c=ew.useCallback(async n=>{if(e){i(n);try{let a=await s4(e,n,t);r(e=>(e??[]).map(e=>e.id===n?a:e))}catch{await s()}finally{i(void 0)}}},[e,t,s]),d=ew.useCallback(async n=>{if(e){i(n);try{await s5(e,n,t),r(e=>(e??[]).filter(e=>e.id!==n))}catch{await s()}finally{i(void 0)}}},[e,t,s]),u=ew.useCallback(async n=>{if(!e)return;let a=await s2(e,n,t);r(e=>[...e??[],a])},[e,t]),f=n??[],m=f.filter(e=>e.enabled&&!e.disabled).length;return(0,eb.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col rounded-[inherit] bg-background",children:[(0,eb.jsxs)("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b px-3 py-2",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,eb.jsx)("span",{className:"text-[13px] font-medium text-foreground",children:"Hook"}),(0,eb.jsxs)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[m,"/",f.length," 启用"]})]}),e?(0,eb.jsx)("div",{className:"flex shrink-0 items-center gap-1",children:(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",variant:"outline",className:"h-9 px-2 text-xs md:h-7",onClick:()=>l(!0),children:[(0,eb.jsx)(lY,{className:"size-3.5"}),"新建"]})}):null]}),(0,eb.jsx)(jP,{className:"min-h-0 flex-1",children:(0,eb.jsx)("div",{className:"px-2 py-2",children:0===f.length?(0,eb.jsx)("p",{className:"px-2 py-1 text-sm text-muted-foreground/70",children:"暂无 hook"}):(0,eb.jsx)("ul",{className:"flex flex-col gap-1.5",children:f.map(e=>{let t=e.enabled&&!e.disabled,n="webhook"===e.trigger.source?e.fireUrl:void 0;return(0,eb.jsxs)("li",{className:(0,ez.cn)("flex flex-col gap-1 rounded-md border px-2.5 py-2",!t&&"opacity-60"),children:[(0,eb.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,eb.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eb.jsx)("span",{className:"block truncate text-[13px] font-medium leading-5 text-foreground",title:e.name||e.id,children:e.name||e.id}),(0,eb.jsx)("span",{className:"block truncate text-[11px] text-muted-foreground/70",children:e.id})]}),(0,eb.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[(0,eb.jsx)(bG,{checked:t,disabled:a===e.id,onCheckedChange:()=>void c(e.id),"aria-label":"启用/停用 hook"}),(0,eb.jsx)("button",{type:"button",disabled:a===e.id,onClick:()=>void d(e.id),"aria-label":"删除 hook",title:"删除 hook",className:"grid size-6 place-items-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-destructive disabled:opacity-50 [&_svg]:size-3.5",children:(0,eb.jsx)(yn,{})})]})]}),(0,eb.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[12px] leading-5",children:[(0,eb.jsx)("span",{className:"text-foreground",children:function(e){switch(e.source){case"timer":if(e.cron)return`⏱ cron: ${e.cron}`;if(e.intervalSec&&e.intervalSec>0)return`⏱ 每 ${e.intervalSec}s`;if(e.delaySec&&e.delaySec>0)return`⏱ ${e.delaySec}s 后`;return"⏱ 定时";case"process_exit":{let t=e.terminalSessionId||e.backgroundCmdId?`: ${e.terminalSessionId||e.backgroundCmdId}`:"";return`⛔ 进程退出${t}`}case"webhook":return"🔌 webhook";case"file":return`📁 文件变化${e.path?`: ${e.path}`:""}`;case"shell_poll":return`🐚 shell${e.command?`: ${e.command}`:""}`;case"lifecycle":return`🔁 生命周期${e.event?`: ${e.event}`:""}`;default:return e.source}}(e.trigger)}),(0,eb.jsx)("span",{className:"text-muted-foreground/50",children:"→"}),(0,eb.jsx)("span",{className:"text-muted-foreground",children:function(e){switch(e.type){case"resume_conversation":return"唤醒本会话";case"run_command":return`运行命令${e.command?`: ${e.command}`:""}`;case"start_conversation":return"新建会话";default:return e.type}}(e.action)})]}),(0,eb.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 text-[11px] text-muted-foreground",children:[(0,eb.jsxs)("span",{className:"tabular-nums",children:["已触发 ",e.fireCount," 次"]}),(0,eb.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,eb.jsx)("span",{children:function(e){if(!e)return"从未触发";let t=Date.parse(e);if(!Number.isFinite(t))return e;let n=Math.max(0,Math.floor((Date.now()-t)/1e3));return n<60?"刚刚触发":n<3600?`${Math.floor(n/60)} 分钟前触发`:n<86400?`${Math.floor(n/3600)} 小时前触发`:new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(t)}(e.lastFiredAt)}),e.once?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,eb.jsx)("span",{children:"仅一次"})]}):e.maxFires&&e.maxFires>0?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,eb.jsxs)("span",{children:["上限 ",e.maxFires]})]}):null]}),n?(0,eb.jsx)("div",{className:"mt-0.5",children:(0,eb.jsx)(Yu,{url:n})}):null]},e.id)})})})}),e?(0,eb.jsx)(Yp,{open:o,onOpenChange:l,onCreate:u}):null]})}Yc.displayName="Label";let Ym=[{value:"timer",label:"定时(timer)"},{value:"webhook",label:"Webhook"},{value:"process_exit",label:"进程退出"},{value:"file",label:"文件变化"},{value:"shell_poll",label:"Shell 轮询"},{value:"lifecycle",label:"生命周期"}],Yh=[{value:"resume_conversation",label:"唤醒本会话"},{value:"run_command",label:"运行命令"},{value:"start_conversation",label:"新建会话"}];function Yp({open:e,onOpenChange:t,onCreate:n}){let[r,a]=ew.useState(""),[i,o]=ew.useState("timer"),[l,s]=ew.useState("60"),[c,d]=ew.useState(""),[u,f]=ew.useState(""),[m,h]=ew.useState(""),[p,g]=ew.useState("resume_conversation"),[x,v]=ew.useState(""),[b,y]=ew.useState(""),[w,j]=ew.useState(!1),[k,N]=ew.useState(!1),[S,C]=ew.useState(""),M=sv();async function E(){N(!0),C("");try{let e={source:i};"timer"===i?c.trim()?e.cron=c.trim():e.delaySec=Math.max(0,Number(l)||0):"file"===i?e.path=u.trim():"shell_poll"===i&&(e.command=m.trim());let a={type:p};"run_command"===p?a.command=b.trim():("resume_conversation"===p||"start_conversation"===p)&&x.trim()&&(a.prompt=x.trim()),await n({name:r.trim()||void 0,trigger:e,action:a,once:w}),t(!1)}catch(e){C(e instanceof Error?e.message:"创建 hook 失败")}finally{N(!1)}}return ew.useEffect(()=>{e&&(a(""),o("timer"),s("60"),d(""),f(""),h(""),g("resume_conversation"),v(""),y(""),j(!1),C(""))},[e]),(0,eb.jsx)(dX,{open:e,onOpenChange:t,children:(0,eb.jsxs)(fU,{className:(0,ez.cn)(M?"inset-0 flex h-svh w-full max-w-none translate-x-0 translate-y-0 flex-col rounded-none border-0":"max-w-md"),children:[(0,eb.jsx)(fq,{children:(0,eb.jsx)(fK,{children:"新建 Hook"})}),(0,eb.jsxs)("div",{className:(0,ez.cn)("grid gap-3",M&&"min-h-0 flex-1 overflow-y-auto"),children:[(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"名称(可选)"}),(0,eb.jsx)(eA,{value:r,onChange:e=>a(e.currentTarget.value),placeholder:"例如 编译完成后继续"})]}),(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"触发源"}),(0,eb.jsxs)(gU,{value:i,onValueChange:e=>o(e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:Ym.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})]}),"timer"===i?(0,eb.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"延迟(秒)"}),(0,eb.jsx)(eA,{type:"number",min:0,value:l,onChange:e=>s(e.currentTarget.value),disabled:!!c.trim()})]}),(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"或 cron"}),(0,eb.jsx)(eA,{value:c,onChange:e=>d(e.currentTarget.value),placeholder:"*/5 * * * *"})]})]}):null,"file"===i?(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"监视路径"}),(0,eb.jsx)(eA,{value:u,onChange:e=>f(e.currentTarget.value),placeholder:"例如 ./dist"})]}):null,"shell_poll"===i?(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"轮询命令"}),(0,eb.jsx)(eA,{value:m,onChange:e=>h(e.currentTarget.value),placeholder:"例如 test -f /tmp/done"})]}):null,(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"动作"}),(0,eb.jsxs)(gU,{value:p,onValueChange:e=>g(e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:Yh.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})]}),"run_command"===p?(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"命令"}),(0,eb.jsx)(eA,{value:b,onChange:e=>y(e.currentTarget.value),placeholder:"例如 npm run build"})]}):(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"提示词(可选)"}),(0,eb.jsx)(eA,{value:x,onChange:e=>v(e.currentTarget.value),placeholder:"触发时注入的提示词"})]}),(0,eb.jsxs)("label",{className:"flex items-center justify-between gap-2 text-sm",children:[(0,eb.jsx)("span",{children:"仅触发一次"}),(0,eb.jsx)(bG,{checked:w,onCheckedChange:j})]}),S?(0,eb.jsx)("p",{className:"text-xs text-destructive",children:S}):null]}),(0,eb.jsxs)(fW,{children:[(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:k,children:"取消"}),(0,eb.jsx)(eO.Button,{type:"button",onClick:()=>void E(),disabled:k,children:k?"创建中":"创建"})]})]})})}let Yg=(0,ek.default)("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);function Yx({conversationId:e,ownerMachineId:t,nodeId:n,binding:r,onBind:a}){let i=r?.childId,o=r?.role??"main",[l,s]=ew.useState(void 0),[c,d]=ew.useState([]),[u,f]=ew.useState(!1),[m,h]=ew.useState(!1),[p,g]=ew.useState([]),[x,v]=ew.useState(""),{models:b}=vH(),y=x||b[0]?.value||"",w=!!(i&&i===l),j=ew.useRef({isTemp:!1});ew.useEffect(()=>{j.current={mainId:e,machineId:t,childId:i,isTemp:"temp"===o&&!!i&&i!==l}},[e,t,i,o,l]),ew.useEffect(()=>{if(!e){s(void 0),d([]),f(!1);return}let n=!0;return(async()=>{try{let r=await sD(e,t);if(!n)return;v(r.conversation.settings?.mainModels?.[0]??""),s(r.conversation.sideQueryConvId||void 0)}catch{}})(),()=>{n=!1}},[e,t]),ew.useEffect(()=>{"main"===o&&!i&&l&&e&&a?.({childId:l,role:"main"})},[o,i,l,e,a]),ew.useEffect(()=>{let e;if(!i){d([]),f(!1);return}let n=!0,r=async()=>{if(n)try{let a=await sD(i,t);if(!n)return;let o=a.conversation.running??!1;d(a.events),f(o),e=window.setTimeout(r,o?1200:5e3)}catch{if(!n)return;try{let e=await s_(i,{limit:400},t);n&&e.events.length&&d(e.events)}catch{}n&&(e=window.setTimeout(r,5e3))}};return r(),()=>{n=!1,void 0!==e&&window.clearTimeout(e)}},[i,t]),ew.useEffect(()=>()=>{let{mainId:e,machineId:t,childId:n,isTemp:r}=j.current;r&&e&&n&&cp(e,n,t).catch(()=>{})},[]);let k=ew.useCallback((n,r=[])=>{let l=n.trim();if(!e||!l&&0===r.length||m)return;h(!0),f(!0);let c=r.map(e=>"image"===e.kind?{kind:"image",name:e.name,mimeType:e.mimeType,data:e.dataUrl?.split(",")[1]??""}:{kind:"card"===e.kind?"card":"file",name:e.name,mimeType:e.mimeType,text:e.text??"",..."card"===e.kind?{cardKind:e.cardKind}:{}}).filter(e=>"image"===e.kind?""!==e.data:(e.text??"")!==""),d="temp"===o&&!i;(async()=>{try{let{sideQueryConvId:n}=await cm(e,l,t,y||void 0,{...i?{childId:i}:d?{kind:"temp"}:{kind:"main"},...c.length>0?{attachments:c}:{}});g([]),n&&(d||i||s(e=>e??n),a?.({childId:n,role:d?"temp":o}))}catch{f(!1)}finally{h(!1)}})()},[e,t,y,m,o,i,a]),N=ew.useCallback(()=>{e&&i&&!w&&(async()=>{try{let{sideQueryConvId:n}=await ch(e,i,t);s(n||i),a?.({childId:i,role:"main"})}catch{}})()},[e,i,w,t,a]),S=ew.useCallback(()=>{"temp"===o&&i&&i!==l&&e&&i&&cp(e,i,t).catch(()=>{}),d([]),f(!1),a?.({role:"temp"})},[o,i,l,e,t,a]),C=ew.useCallback(()=>{a?.({childId:l,role:"main"})},[l,a]),M=!!e,E=!!l,I=!i&&0===c.length;return(0,eb.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col rounded-[inherit] bg-background",children:[(0,eb.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5 border-b px-3 py-2",children:[(0,eb.jsx)(uJ,{className:"size-3.5 text-muted-foreground"}),(0,eb.jsx)("span",{className:"text-[13px] font-medium text-foreground",children:w?"主旁问":"temp"===o?"临时旁问":"旁问"}),M&&i?(0,eb.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[w?(0,eb.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground",children:[(0,eb.jsx)(Yg,{className:"size-3 fill-current"}),"主旁问"]}):(0,eb.jsxs)(eO.Button,{type:"button",variant:"ghost",size:"sm",className:"h-6 gap-1 px-2 text-[11px]",onClick:N,title:"固定为主旁问",children:[(0,eb.jsx)(Yg,{className:"size-3"}),"固定为主旁问"]}),(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon",className:"size-6",onClick:S,title:"新建临时旁问",children:(0,eb.jsx)(lY,{className:"size-3.5"})})]}):(0,eb.jsx)("span",{className:"ml-auto text-[11px] text-muted-foreground",children:"只读 · 不影响主对话"})]}),(0,eb.jsxs)("div",{className:"relative min-h-0 flex-1",children:[(0,eb.jsx)(UL,{className:"size-full min-h-0",composerClassName:"max-w-[42rem]",events:c,running:u||m,disabled:!M,hideComposerOptions:!0,attachments:p,onAttachmentsChange:g,onCardDrop:qg,onSubmit:e=>k(e.value,e.attachments??[])}),I?(0,eb.jsx)("div",{className:"absolute inset-x-0 top-0 bottom-28 grid place-items-center px-6",children:(0,eb.jsxs)("div",{className:"max-w-xs text-center",children:[(0,eb.jsx)(uJ,{className:"mx-auto mb-2 size-7 text-muted-foreground/50"}),M?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:"问点什么?旁问不会影响主对话。"}),(0,eb.jsxs)("div",{className:"flex flex-col items-stretch gap-2",children:[(0,eb.jsxs)(eO.Button,{type:"button",variant:E?"outline":"default",size:"sm",className:(0,ez.cn)("gap-1.5","main"===o&&"ring-1 ring-ring"),onClick:C,children:[(0,eb.jsx)(Yg,{className:"size-3.5"}),E?"继续主旁问":"开始旁问"]}),(0,eb.jsxs)(eO.Button,{type:"button",variant:"outline",size:"sm",className:(0,ez.cn)("gap-1.5","temp"===o&&"ring-1 ring-ring"),onClick:S,children:[(0,eb.jsx)(lY,{className:"size-3.5"}),"新建临时旁问"]})]})]}):(0,eb.jsx)("p",{className:"text-sm text-muted-foreground",children:"选择一个对话后即可在此发起旁问。"})]})}):null]})]})}let Yv=(0,ek.default)("coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]),Yb=(0,ek.default)("file-pen-line",[["path",{d:"m18.226 5.226-2.52-2.52A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-.351",key:"1k2beg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]),Yy=(0,ek.default)("loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]),Yw=(0,ek.default)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function Yj(e,t){return e?(0,eT.localAPIURL)(`/v1/remote/${e}${t}`):(0,eT.localAPIURL)(t)}async function Yk(e,t){let{signal:n,timeoutMs:r=8e3}=t??{},a=new AbortController,i=r>0?setTimeout(()=>a.abort(),r):void 0;n&&n.addEventListener("abort",()=>a.abort(),{once:!0});try{let t=await fetch(Yj(e,"/v1/extensions"),{cache:"no-store",signal:a.signal});if(!t.ok)throw Error(`Extensions API error: ${t.status}`);return await t.json()}finally{i&&clearTimeout(i)}}async function YN(e,t,n){let r=await fetch(Yj(e,t),{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json"},body:void 0===n?void 0:JSON.stringify(n)});if(!r.ok)throw Error(`Extensions API error: ${r.status}`);let a=await r.text();return a?JSON.parse(a):{}}async function YS(e,t){return YN(e,"/v1/extensions/browser/install",{variant:t})}async function YC(e,t){return YN(e,"/v1/extensions/browser/update",t?{variant:t}:{})}async function YM(e){return YN(e,"/v1/extensions/browser/uninstall")}async function YE(e,t){return YN(e,"/v1/extensions/browser/enable",{enabled:t})}async function YI(e,t){let{timeoutMs:n=6e3}=t??{},r=new AbortController,a=n>0?setTimeout(()=>r.abort(),n):void 0;try{let t=await fetch(Yj(e,"/v1/browser/info"),{cache:"no-store",signal:r.signal});if(!t.ok)return null;let n=await t.text(),a=n?JSON.parse(n):{};return{running:!!a.running,monitoring:!!a.monitoring}}catch{return null}finally{a&&clearTimeout(a)}}async function YP(e,t){return{monitoring:!!(await YN(e,"/v1/browser/monitor",{enabled:t})).monitoring}}let YO={drafting:"撰写计划",awaiting_approval:"等待批准",executing:"执行中",compacting:"压缩上下文",done:"已完成"};function Yz(e){if(!e.children||0===e.children.length)return"task"!==e.kind&&"subplan"!==e.kind?{done:0,total:0}:{done:+("done"===e.status),total:1};let t=0,n=0;for(let r of e.children){let e=Yz(r);t+=e.done,n+=e.total}return{done:t,total:n}}function YA(e,t){if(e){if(e.id===t)return e;for(let n of e.children??[]){let e=YA(n,t);if(e)return e}}}function YT({done:e,total:t}){let n=t>0?Math.round(e/t*100):0;return(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-muted",children:(0,eb.jsx)("div",{className:"h-full rounded-full bg-foreground transition-all",style:{width:`${n}%`}})}),(0,eb.jsxs)("span",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground",children:[e,"/",t]})]})}function YR({state:e}){let{phase:t,task:n}=function(e){let t,n=e.activePath??[];if(!e.tree||0===n.length)return{};for(let r of n){let n=YA(e.tree,r);n&&"phase"===n.kind&&(t=n)}let r=n[n.length-1];return{phase:t,task:r?YA(e.tree,r):void 0}}(e),r=e.tree?Yz(e.tree):{done:0,total:0},a=t?Yz(t):void 0,i=r.total>0?Math.round(r.done/r.total*100):0,o=n?.status==="in_progress";return(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(YD,{icon:(0,eb.jsx)(uZ,{}),label:"任务进度"}),(0,eb.jsxs)("div",{className:"flex flex-col gap-2 px-3 pb-2 text-[13px]",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)("span",{className:"text-muted-foreground",children:"当前阶段"}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium",children:t?.title??YO[e.phase]??e.phase??"—"})]}),a&&a.total>0?(0,eb.jsx)(YT,{done:a.done,total:a.total}):null,n?(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[o?(0,eb.jsx)(Yy,{className:"size-3.5 shrink-0 animate-spin text-amber-500"}):"done"===n.status?(0,eb.jsx)(h6,{className:"size-3.5 shrink-0 text-emerald-500"}):null,(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",title:n.detail||n.title,children:n.title})]}):null,(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)("span",{className:"text-muted-foreground",children:"总体进度"}),(0,eb.jsxs)("span",{className:"ml-auto font-medium tabular-nums",children:[i,"%"]})]}),(0,eb.jsx)("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-muted",children:(0,eb.jsx)("div",{className:"h-full rounded-full bg-foreground transition-all",style:{width:`${i}%`}})})]}),(0,eb.jsx)("div",{className:"mx-3 border-t border-border/60"})]})}function YD({icon:e,label:t}){return(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 px-3 pt-3 pb-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/70 [&_svg]:size-3.5",children:[e,(0,eb.jsx)("span",{children:t})]})}function Y_(){let[e,t]=ew.useState("loading"),[n,r]=ew.useState(!1),a=ew.useCallback(async e=>{try{let n=(await Yk(void 0,{signal:e,timeoutMs:6e3})).extensions.find(e=>"browser"===e.id);n&&n.installed?n.running?t("running"):t(e=>"starting"===e?"starting":"stopped"):t("missing")}catch{t("missing")}},[]);ew.useEffect(()=>{let e=!0,t=new AbortController,n=()=>{e&&a(t.signal)};n();let r=window.setInterval(n,1e4);return()=>{e=!1,t.abort(),window.clearInterval(r)}},[a]);let i=ew.useCallback(async()=>{if(!n){r(!0),t("starting");try{await YE(void 0,!0);let e=Date.now()+3e4;for(;Date.now()<e;){await new Promise(e=>setTimeout(e,1500));try{let e=await Yk(void 0,{timeoutMs:6e3});if(e.extensions.find(e=>"browser"===e.id)?.running)return void t("running")}catch{}}}catch{}finally{r(!1),await a()}}},[n,a]);return(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)(qz,{className:"size-4 shrink-0 text-muted-foreground"}),(0,eb.jsx)("span",{className:"text-muted-foreground",children:"浏览器"}),"running"===e?(0,eb.jsx)(YL,{online:!0}):"starting"===e?(0,eb.jsx)(Yy,{className:"size-3.5 shrink-0 animate-spin text-amber-500"}):(0,eb.jsx)(YL,{online:!1}),(0,eb.jsx)("span",{className:"truncate font-medium",children:"running"===e?"运行中":"starting"===e?"启动中":"stopped"===e?"已停止":"missing"===e?"未安装":"—"}),(0,eb.jsx)("span",{className:"ml-auto shrink-0",children:"stopped"===e?(0,eb.jsxs)("button",{type:"button",onClick:()=>void i(),className:"inline-flex items-center gap-1 rounded-md border border-border/70 px-1.5 py-0.5 text-[11px] font-medium text-foreground transition-colors hover:bg-muted",children:[(0,eb.jsx)(HE,{className:"size-3"}),"启动"]}):"running"===e?(0,eb.jsx)("span",{className:"text-[11px] text-muted-foreground/70",title:"在画布的「浏览器」节点中实时查看 Agent 的浏览器操作",children:"画布查看"}):null})]})}function YL({online:e}){return(0,eb.jsx)("span",{"aria-hidden":!0,className:(0,ez.cn)("inline-block size-2 shrink-0 rounded-full",e?"bg-emerald-500":"bg-muted-foreground/40")})}function Y$({conversationId:e,ownerMachineId:t}){let[n,r]=ew.useState(null),[a,i]=ew.useState([]),[o,l]=ew.useState([]),{machines:s}=vd();ew.useEffect(()=>{if(!e)return;let n=!0,a=async()=>{try{let[a,o,s]=await Promise.all([sD(e,t),sL(e,t).catch(()=>[]),s$(e,t).catch(()=>[])]);if(!n)return;r(a),i(o),l(s)}catch{}};a();let o=window.setInterval(a,1200);return()=>{n=!1,window.clearInterval(o)}},[e,t]);let c=ew.useMemo(()=>new Map(s.map(e=>[e.id,e])),[s]),d=e=>"local"===e||c.get(e)?.status==="online",u=e=>"local"===e?c.get("local")?.name??"本地":c.get(e)?.name??e,f=t??n?.conversation.ownerMachineId??"local",m=(n?.conversation.settings?.hosts??[]).filter(Boolean),h=n?.conversation.runUsage,p=n?.conversation.status==="working",g=(h?.cachedInputTokens??0)+(h?.cacheCreationInputTokens??0),{additions:x,deletions:v}=function(e){let t=-1;for(let n=e.length-1;n>=0;n-=1)if(e[n]?.kind==="user"){t=n;break}let n=0,r=0;for(let a=Math.max(0,t);a<e.length;a+=1){let t=e[a],i=t?.additions??t?.meta?.additions,o=t?.deletions??t?.meta?.deletions;"number"==typeof i&&(n+=i),"number"==typeof o&&(r+=o)}return{additions:n,deletions:r}}(n?.events??[]),b=function(e){let t=-1;for(let n=e.length-1;n>=0;n-=1)if(e[n]?.kind==="user"){t=n;break}let n=new Set;for(let r=Math.max(0,t);r<e.length;r+=1){let t=e[r];if(t?.kind==="subagent"&&Array.isArray(t.subagents))for(let e of t.subagents)e?.id&&n.add(e.id)}return n}(n?.events??[]),y=function e(t,n=0,r=[]){for(let a of t)r.push({node:a,depth:n}),a.children&&a.children.length>0&&e(a.children,n+1,r);return r}(a.filter(e=>b.has(e.id))),w=n?.conversation.planState;return(0,eb.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col overflow-auto rounded-[inherit] bg-background text-sm",children:[(0,eb.jsx)(YD,{icon:(0,eb.jsx)(uV,{}),label:"环境信息"}),(0,eb.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 pb-2 text-[13px]",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-foreground/90",children:[(0,eb.jsx)(eP,{className:"size-4 shrink-0 text-muted-foreground"}),(0,eb.jsx)("span",{className:"text-muted-foreground",children:"运行于"}),(0,eb.jsx)(YL,{online:d(f)}),(0,eb.jsx)("span",{className:"truncate font-medium",children:u(f)})]}),(0,eb.jsxs)("div",{className:"flex items-start gap-2",children:[(0,eb.jsx)(Yw,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),(0,eb.jsx)("span",{className:"mt-0.5 shrink-0 text-muted-foreground",children:"可访问"}),(0,eb.jsx)("div",{className:"flex min-w-0 flex-wrap gap-x-3 gap-y-1",children:0===m.length?(0,eb.jsx)("span",{className:"text-muted-foreground/70",children:"—"}):m.map(e=>(0,eb.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,eb.jsx)(YL,{online:d(e)}),(0,eb.jsx)("span",{className:"truncate",children:u(e)})]},e))})]}),(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)(Yb,{className:"size-4 shrink-0 text-muted-foreground"}),(0,eb.jsx)("span",{className:"text-muted-foreground",children:"本轮变更"}),(0,eb.jsxs)("span",{className:"font-medium text-emerald-600 dark:text-emerald-400",children:["+",x]}),(0,eb.jsxs)("span",{className:"font-medium text-rose-600 dark:text-rose-400",children:["-",v]}),(0,eb.jsx)("span",{className:"text-muted-foreground/60",children:"行"})]}),(0,eb.jsx)(Y_,{})]}),(0,eb.jsx)("div",{className:"mx-3 border-t border-border/60"}),w?(0,eb.jsx)(YR,{state:w}):null,(0,eb.jsx)(YD,{icon:(0,eb.jsx)(uH,{}),label:"子智能体"}),(0,eb.jsx)("div",{className:"flex max-h-44 flex-col gap-1 overflow-y-auto px-3 pb-2 text-[13px]",children:0===y.length?(0,eb.jsx)("span",{className:"text-muted-foreground/70",children:"本轮未释放子智能体"}):y.map(({node:e,depth:t})=>{let n="failed"===e.status;return(0,eb.jsxs)("div",{className:"flex items-center gap-2",style:{paddingLeft:12*t},children:[e.running?(0,eb.jsx)(Yy,{className:"size-3.5 shrink-0 animate-spin text-amber-500"}):n?(0,eb.jsx)(fV.XIcon,{className:"size-3.5 shrink-0 text-rose-500"}):(0,eb.jsx)(h6,{className:"size-3.5 shrink-0 text-emerald-500"}),(0,eb.jsx)("span",{className:"truncate",children:e.subagentName||e.title||e.subagentType||"子智能体"}),(0,eb.jsx)("span",{className:"ml-auto shrink-0 text-[11px] text-muted-foreground/70",children:e.running?"运行中":n?"失败":"已完成"})]},e.id)})}),(0,eb.jsx)("div",{className:"mx-3 border-t border-border/60"}),(0,eb.jsx)(YD,{icon:(0,eb.jsx)(u0,{}),label:"后台任务"}),(0,eb.jsx)("div",{className:"flex max-h-44 flex-col gap-1 overflow-y-auto px-3 pb-2 text-[13px]",children:0===o.length?(0,eb.jsx)("span",{className:"text-muted-foreground/70",children:"本轮无后台任务"}):o.map(e=>{let t="failed"===e.status||"timeout"===e.status,n="unknown"===e.status;return(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[e.running?(0,eb.jsx)(Yy,{className:"size-3.5 shrink-0 animate-spin text-amber-500"}):n?(0,eb.jsx)(m0,{className:"size-3.5 shrink-0 text-amber-500"}):t?(0,eb.jsx)(fV.XIcon,{className:"size-3.5 shrink-0 text-rose-500"}):(0,eb.jsx)(h6,{className:"size-3.5 shrink-0 text-emerald-500"}),(0,eb.jsx)("span",{className:"truncate font-mono text-[12px]",title:e.command,children:e.command||"(命令)"}),e.orphaned?(0,eb.jsx)("span",{className:"shrink-0 rounded bg-amber-500/15 px-1 text-[10px] font-medium text-amber-600 dark:text-amber-400",title:"该后台进程脱离了本轮但仍在运行",children:"脱离"}):null,(0,eb.jsx)("span",{className:"ml-auto shrink-0 text-[11px] text-muted-foreground/70",children:e.running?"运行中":n?"状态未知":t?"timeout"===e.status?"超时":"失败":"已完成"})]},e.id)})}),(0,eb.jsx)("div",{className:"mx-3 border-t border-border/60"}),(0,eb.jsx)(YD,{icon:(0,eb.jsx)(Yv,{}),label:p?"本轮消耗":"消耗额度"}),(0,eb.jsx)("div",{className:"grid grid-cols-3 gap-2 px-3 pb-3",children:[{label:"输入",value:h?.inputTokens},{label:"输出",value:h?.outputTokens},{label:"缓存",value:g}].map(e=>{let t;return(0,eb.jsxs)("div",{className:"rounded-lg border border-border/60 bg-muted/30 px-2 py-1.5",children:[(0,eb.jsx)("div",{className:"text-[11px] text-muted-foreground",children:e.label}),(0,eb.jsx)("div",{className:"font-mono text-sm font-medium tabular-nums",children:h?(t=e.value??0)>=1e6?`${(t/1e6).toFixed(2)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t):"—"})]},e.label)})})]})}function YF({done:e,total:t}){let n=t>0?Math.round(e/t*100):0;return(0,eb.jsx)("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-muted",children:(0,eb.jsx)("div",{className:"h-full rounded-full bg-foreground transition-all",style:{width:`${n}%`}})})}function YB({conversationId:e,ownerMachineId:t}){let[n,r]=ew.useState(void 0);ew.useEffect(()=>{if(r(void 0),!e)return;let n=!0,a=0,i=async()=>{let i=a+=1;try{let o=await s_(e,{limit:400},t);if(!n||i!==a)return;r(function(e){for(let t=e.length-1;t>=0;t-=1){let n=e[t];if(n&&"task"===n.kind&&Array.isArray(n.tasks))return n.tasks}}(o.events)??[])}catch{}};i();let o=window.setInterval(i,1200);return()=>{n=!1,window.clearInterval(o)}},[e,t]);let a=n??[],i=a.length,o=a.filter(e=>"done"===e.status).length;return(0,eb.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col rounded-[inherit] bg-background",children:[(0,eb.jsxs)("div",{className:"shrink-0 space-y-1.5 border-b px-3 py-2",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)("span",{className:"text-[13px] font-medium text-foreground",children:"任务"}),(0,eb.jsxs)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[o,"/",i]})]}),(0,eb.jsx)(YF,{done:o,total:i})]}),(0,eb.jsx)(jP,{className:"min-h-0 flex-1",children:(0,eb.jsx)("div",{className:"px-2 py-2",children:0===i?(0,eb.jsx)("p",{className:"px-2 py-1 text-sm text-muted-foreground/70",children:"暂无任务"}):(0,eb.jsx)("ul",{className:"flex flex-col gap-0.5",children:a.map(e=>{let{glyph:t,className:n}=function(e){switch(e){case"done":return{glyph:"✓",className:"text-emerald-500"};case"in_progress":return{glyph:"▸",className:"text-amber-500"};case"cancelled":return{glyph:"✕",className:"text-rose-500"};default:return{glyph:"○",className:"text-muted-foreground/50"}}}(e.status),r="done"===e.status;return(0,eb.jsxs)("li",{className:"flex items-start gap-2 rounded-md px-1.5 py-1",children:[(0,eb.jsx)("span",{className:(0,ez.cn)("mt-px shrink-0 text-[13px] leading-5",n),"aria-hidden":!0,children:t}),(0,eb.jsx)("span",{className:(0,ez.cn)("min-w-0 flex-1 text-[13px] leading-5",r&&"text-muted-foreground line-through"),title:e.detail||e.title,children:e.title})]},e.id)})})})})]})}var YV=e.i(78737);let YH=(0,ek.default)("earth",[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),YU=(0,ek.default)("smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]),Yq=(0,ek.default)("tablet",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]]),YW=[{id:"phone",label:"Phone",width:390,userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.1"},{id:"tablet",label:"Tablet",width:820,userAgent:"Mozilla/5.0 (iPad; CPU OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.1"},{id:"desktop",label:"Desktop",width:1200,userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 15_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"}],YK=[{id:"adaptive",label:"自适应",adaptive:!0},{id:"16:9",label:"16:9",value:16/9},{id:"4:3",label:"4:3",value:4/3},{id:"3:2",label:"3:2",value:1.5},{id:"1:1",label:"1:1",value:1},{id:"9:16",label:"9:16",value:9/16}],YG={urlLabel:"URL",urlPlaceholder:"https://example.com",navigate:"Navigate",actions:"Browser view options",devices:"User agent",ratios:"Viewport ratio",back:"Back",forward:"Forward",reload:"Reload preview",previewTitle:"Browser preview"};function YX(e,t,n){return e.find(e=>e.id===t)??n}function YY({id:e}){return"phone"===e?(0,eb.jsx)(YU,{className:"size-4"}):"tablet"===e?(0,eb.jsx)(Yq,{className:"size-4"}):(0,eb.jsx)(eP,{className:"size-4"})}function YZ({url:e,defaultUrl:t="https://vantaloom.local/workspace",onUrlChange:n,onNavigate:r,onBack:a,onForward:i,device:o,defaultDevice:l="desktop",onDeviceChange:s,ratio:c,defaultRatio:d="adaptive",onRatioChange:u,devices:f=YW,ratios:m=YK,srcDoc:h,renderPreview:p,showHeader:g=!0,labels:x,className:v,headerClassName:b,previewClassName:y,...w}){let j=ew.useMemo(()=>({...YG,...x}),[x]),[k,N]=ew.useState(t),[S,C]=ew.useState(e??t),[M,E]=ew.useState(()=>[e??t]),[I,P]=ew.useState(0),[O,z]=ew.useState(l),[A,T]=ew.useState(d),[R,D]=ew.useState(!1),[_,L]=ew.useState(0),$=ew.useRef(null),F=ew.useId(),[B,V]=function(){let e=ew.useRef(null),[t,n]=ew.useState({width:0,height:0});return ew.useEffect(()=>{let t=e.current;if(!t)return;function r(e){t&&n(e??{width:t.clientWidth,height:t.clientHeight})}r();let a=new ResizeObserver(e=>{let t=e[0];t?r({width:t.contentRect.width,height:t.contentRect.height}):r()});return a.observe(t),()=>a.disconnect()},[]),[e,t]}(),H=e??k,U=YX(f,o??O,f[0]??YW[0]),q=YX(m,c??A,m[0]??YK[0]),W=V.width>0&&V.height>0,K=q.adaptive||"adaptive"===q.id,G=q.value??16/9,X=K&&V.width||U.width,Y=K?V.height||U.width/G:X/G,Z=(W?V.width/V.height:1)<=G,J=Math.max(1,Math.round(W?K||Z?V.width:V.height*G:X)),Q=Math.max(1,Math.round(W?K?V.height:Z?V.width/G:V.height:Y)),ee=J/X,et=ew.useMemo(()=>({url:H,device:U,ratio:q,viewport:{width:J,height:Q,scale:ee}}),[U,q,H,ee,Q,J]);function en(t,a={history:"push"}){void 0===e&&N(t),"none"!==a.history&&E(e=>{let n=e.slice(0,I+1);return n[n.length-1]===t?n:(P(n.length),[...n,t])}),n?.(t),r?.(t)}return ew.useEffect(()=>{C(e??k)},[k,e]),ew.useEffect(()=>{if(R)return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e);function e(e){let t=e.target;t instanceof Node&&$.current?.contains(t)||D(!1)}},[R]),(0,eb.jsxs)("div",{ref:$,"data-slot":"browser-tab-viewer","data-device":U.id,"data-ratio":q.id,className:(0,ez.cn)("vtl-surface-panel relative grid min-h-0 overflow-hidden rounded-[var(--surface-panel-radius)] border",g?"grid-rows-[auto_minmax(0,1fr)]":"grid-rows-[minmax(0,1fr)]",v),...w,children:[g&&(0,eb.jsxs)("div",{"data-slot":"browser-tab-viewer-header",className:(0,ez.cn)("flex min-w-0 items-center gap-2 border-b bg-muted/35 px-3 py-2",b),children:[(0,eb.jsx)("span",{className:"grid size-5 shrink-0 place-items-center rounded-md border bg-background text-muted-foreground",children:(0,eb.jsx)(YH,{className:"size-3.5"})}),(0,eb.jsxs)("form",{onSubmit:function(e){let t;e.preventDefault();let n=(t=S.trim())?/^[a-z][a-z\d+\-.]*:\/\//i.test(t)?t:/^(localhost|127\.0\.0\.1|\[::1\])(?::\d+)?(?:\/|$)/i.test(t)?`http://${t}`:`https://${t}`:"";C(n),en(n)},className:"min-w-0 flex-1",children:[(0,eb.jsx)("label",{className:"sr-only",htmlFor:F,children:j.urlLabel}),(0,eb.jsx)(eA,{id:F,value:S,onChange:e=>C(e.target.value),placeholder:j.urlPlaceholder,className:"h-5 rounded-md border bg-background px-2 shadow-none ui-text-kbd",spellCheck:!1})]}),(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j.back,disabled:I<=0,onClick:function(){if(I<=0)return;let e=I-1,t=M[e];t&&(P(e),C(t),en(t,{history:"none"}),a?.(t))},className:"size-5 rounded-md",children:(0,eb.jsx)(YV.ArrowLeftIcon,{className:"size-3.5"})}),(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j.forward,disabled:I>=M.length-1,onClick:function(){if(I>=M.length-1)return;let e=I+1,t=M[e];t&&(P(e),C(t),en(t,{history:"none"}),i?.(t))},className:"size-5 rounded-md",children:(0,eb.jsx)(ej.ArrowRightIcon,{className:"size-3.5"})}),(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j.reload,onClick:()=>L(e=>e+1),className:"size-5 rounded-md",children:(0,eb.jsx)(yt,{className:"size-3.5"})})]}),(0,eb.jsx)("div",{ref:B,"data-slot":"browser-tab-viewer-stage",className:(0,ez.cn)("grid min-h-0 place-items-center overflow-hidden bg-muted/20",y),children:(0,eb.jsx)("div",{"data-slot":"browser-tab-viewer-viewport",className:"overflow-hidden rounded-lg border bg-background shadow-sm",style:{width:J,height:Q},children:p?p(et):(0,eb.jsx)("iframe",{title:j.previewTitle,src:h?void 0:H,srcDoc:h,sandbox:"allow-forms allow-modals allow-popups allow-same-origin allow-scripts",className:"size-full border-0 bg-background"},`${_}-${H}-${U.id}-${q.id}`)})}),(0,eb.jsxs)("div",{"data-slot":"browser-tab-floating-actions",className:"absolute right-3 bottom-3 z-20",children:[(0,eb.jsxs)("div",{className:(0,ez.cn)("vtl-surface-popover absolute right-0 bottom-10 grid w-56 gap-3 rounded-[var(--surface-popover-radius)] border p-3 transition-[opacity,transform] duration-150",R?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0"),children:[(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)("div",{className:"text-muted-foreground ui-text-kbd",children:j.devices}),(0,eb.jsx)("div",{className:"flex gap-1.5",children:f.map(e=>(0,eb.jsx)(eO.Button,{type:"button",variant:U.id===e.id?"default":"outline",size:"icon-sm","aria-label":e.label,title:e.label,className:"rounded-full",onClick:()=>{let t;return t=YX(f,e.id,U),void(void 0===o&&z(t.id),s?.(t.id,t))},children:(0,eb.jsx)(YY,{id:e.id})},e.id))})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)("div",{className:"text-muted-foreground ui-text-kbd",children:j.ratios}),(0,eb.jsx)("div",{className:"flex flex-wrap gap-1.5",children:m.map(e=>(0,eb.jsx)(eO.Button,{type:"button",variant:q.id===e.id?"default":"outline",size:"xs",className:"h-7 rounded-full px-2.5 ui-text-kbd",onClick:()=>{let t;return t=YX(m,e.id,q),void(void 0===c&&T(t.id),u?.(t.id,t))},children:e.label},e.id))})]})]}),(0,eb.jsx)(eO.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":j.actions,"aria-expanded":R,onClick:()=>D(e=>!e),className:"rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,eb.jsx)(lG,{className:(0,ez.cn)("size-4 transition-transform",R&&"rotate-90")})})]})]})}let YJ=(0,ek.default)("monitor-off",[["path",{d:"M17 17H4a2 2 0 0 1-2-2V5c0-1.5 1-2 1-2",key:"k0q8oc"}],["path",{d:"M22 15V5a2 2 0 0 0-2-2H9",key:"cp1ac0"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),YQ=(0,ek.default)("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);function Y0({frame:e,cursor:t,connection:n,takeover:r,onTakeoverChange:a,onInput:i,onReconnect:o,machines:l,selectedMachineId:s,onSelectMachine:c,onStartBrowser:d,starting:u,monitoring:f,onMonitoringChange:m,className:h}){let p=ew.useRef(null),g=ew.useRef(null),x=ew.useRef(null),v=ew.useRef(t??null),b=ew.useRef(0),y=ew.useRef(!1),[w,j]=ew.useState(!1),k=ew.useCallback(()=>{let e=p.current,t=x.current;if(!e||!t)return;let n=e.getContext("2d");if(!n)return;n.drawImage(t,0,0,e.width,e.height);let r=v.current;if(!r)return;let a=Math.max(9,e.width/110);n.save(),n.beginPath(),n.arc(r.x,r.y,a,0,2*Math.PI),n.fillStyle="rgba(255,45,85,0.35)",n.fill(),n.lineWidth=Math.max(2,a/4),n.strokeStyle="rgba(255,255,255,0.95)",n.stroke(),n.beginPath(),n.arc(r.x,r.y,Math.max(2.5,.32*a),0,2*Math.PI),n.fillStyle="rgba(255,45,85,0.95)",n.fill(),n.restore()},[]);function N(t){let n=p.current;if(!n)return null;let r=n.getBoundingClientRect();if(0===r.width||0===r.height)return null;let a=(e?.width||n.width)/r.width,i=(e?.height||n.height)/r.height;return{x:Math.round((t.clientX-r.left)*a),y:Math.round((t.clientY-r.top)*i)}}function S(e,t){r&&i&&(e.preventDefault(),i({kind:"key",type:t,key:e.key}),"keyDown"===t&&1===e.key.length&&i({kind:"key",type:"char",key:e.key,text:e.key}))}ew.useEffect(()=>{let t=p.current;if(!t||!e?.b64)return;let n=new Image;return g.current=n,n.onload=()=>{if(g.current!==n)return;let r=e.width||n.naturalWidth,a=e.height||n.naturalHeight;t.width!==r&&(t.width=r),t.height!==a&&(t.height=a),x.current=n,k()},n.src=`data:image/jpeg;base64,${e.b64}`,()=>{n.onload=null,g.current===n&&(g.current=null)}},[e,k]),ew.useEffect(()=>{v.current=t??null,k()},[t,k]);let C="streaming"===n||!!e;return(0,eb.jsxs)("div",{className:(0,ez.cn)("vtl-surface-panel relative flex size-full min-h-0 flex-col overflow-hidden",h),"data-slot":"live-browser-view",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-2 border-b bg-muted/35 px-3 py-2",children:[(0,eb.jsx)("span",{className:"text-muted-foreground ui-text-kbd shrink-0",children:"浏览器"}),(0,eb.jsx)("div",{className:"min-w-0 flex-1",children:l.length>0?(0,eb.jsx)("select",{value:s??"",onChange:e=>c?.(e.target.value),className:"h-6 w-full max-w-[16rem] truncate rounded-md border bg-background px-2 ui-text-kbd",children:l.map(e=>(0,eb.jsxs)("option",{value:e.id,disabled:!e.running,children:[e.label,e.running?"":"(未运行)"]},e.id))}):(0,eb.jsx)("span",{className:"text-muted-foreground ui-text-kbd",children:"无可用浏览器"})}),m?(0,eb.jsxs)(eO.Button,{type:"button",size:"xs",variant:f?"default":"outline",className:"h-6 gap-1 rounded-md px-2 ui-text-kbd","aria-pressed":!!f,onClick:()=>m(!f),title:f?"浏览器监视:开启(有头实时画面,会打开一个真实浏览器窗口)。点击关闭后仅在 agent 每次操作后显示一帧。":"浏览器监视:关闭(仅在 agent 每次操作后显示一帧)。点击开启有头实时画面,会打开一个真实浏览器窗口。",children:[f?(0,eb.jsx)(eP,{className:"size-3.5"}):(0,eb.jsx)(YJ,{className:"size-3.5"}),"监视"]}):null,(0,eb.jsxs)(eO.Button,{type:"button",size:"xs",variant:r?"default":"outline",className:"h-6 gap-1 rounded-md px-2 ui-text-kbd","aria-pressed":r,onClick:()=>a(!r),disabled:"streaming"!==n,title:r?"切换到观看模式":"接管:在画面里直接操作",children:[r?(0,eb.jsx)(lU,{className:"size-3.5"}):(0,eb.jsx)(lX,{className:"size-3.5"}),r?"接管中":"观看"]}),"error"===n&&o?(0,eb.jsx)(eO.Button,{type:"button",size:"icon-xs",variant:"ghost",className:"size-6 rounded-md","aria-label":"重新连接",onClick:o,children:(0,eb.jsx)(YQ,{className:"size-3.5"})}):null]}),(0,eb.jsxs)("div",{className:"relative grid min-h-0 flex-1 place-items-center overflow-hidden bg-black/85",children:[C?(0,eb.jsx)("canvas",{ref:p,tabIndex:r?0:-1,onPointerDown:function(e){if(!r||!i)return;let t=N(e);t&&(y.current=!0,e.currentTarget.setPointerCapture(e.pointerId),p.current?.focus(),i({kind:"mouse",type:"mousePressed",button:"left",...t}))},onPointerUp:function(e){if(!r||!i)return;let t=N(e);y.current=!1;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}t&&i({kind:"mouse",type:"mouseReleased",button:"left",...t})},onPointerMove:function(e){if(!r||!i)return;let t=performance.now();if(t-b.current<33)return;b.current=t;let n=N(e);n&&i({kind:"mouse",type:"mouseMoved",button:y.current?"left":"none",...n})},onKeyDown:e=>S(e,"keyDown"),onKeyUp:e=>S(e,"keyUp"),onFocus:()=>j(!0),onBlur:()=>j(!1),className:(0,ez.cn)("max-h-full max-w-full object-contain outline-none",r?"cursor-crosshair":"cursor-default")}):(0,eb.jsx)("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:"connecting"===n?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(eM,{className:"size-5 animate-spin"}),(0,eb.jsx)("span",{children:"正在连接浏览器…"})]}):"error"===n?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(YJ,{className:"size-5"}),(0,eb.jsx)("span",{children:"连接浏览器失败"}),o?(0,eb.jsx)(eO.Button,{type:"button",size:"xs",variant:"outline",onClick:o,children:"重试"}):null]}):u?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(eM,{className:"size-5 animate-spin"}),(0,eb.jsx)("span",{children:"正在启动浏览器…"})]}):0===l.length?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(YJ,{className:"size-5"}),(0,eb.jsx)("span",{children:"未安装浏览器"}),(0,eb.jsx)("span",{className:"text-xs text-muted-foreground/70",children:"请在「官方扩展」页面安装 Vantaloom 浏览器"})]}):d?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(YJ,{className:"size-5"}),(0,eb.jsx)("span",{children:"浏览器已停止"}),(0,eb.jsxs)(eO.Button,{type:"button",size:"xs",variant:"outline",className:"gap-1",onClick:d,children:[(0,eb.jsx)(HE,{className:"size-3.5"}),"启动浏览器"]})]}):!f&&m?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(YJ,{className:"size-5"}),(0,eb.jsx)("span",{children:"等待 agent 操作后显示画面"}),(0,eb.jsxs)(eO.Button,{type:"button",size:"xs",variant:"outline",className:"gap-1",onClick:()=>m(!0),children:[(0,eb.jsx)(eP,{className:"size-3.5"}),"开启浏览器监视以查看实时画面"]})]}):(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(YJ,{className:"size-5"}),(0,eb.jsx)("span",{children:"浏览器未运行"})]})}),r&&C?(0,eb.jsxs)("div",{className:"pointer-events-none absolute inset-0",children:[(0,eb.jsx)("div",{className:(0,ez.cn)("absolute inset-0 rounded-sm ring-2 ring-inset transition-colors",w?"ring-hot-pink":"ring-hot-pink/50")}),(0,eb.jsxs)("span",{className:"absolute left-2 top-2 rounded bg-hot-pink/90 px-1.5 py-0.5 text-[10px] font-medium text-white",children:["接管中",w?"":"(点击画面以捕获键盘)"]})]}):null]})]})}function Y1(e,t){return e?(0,eT.localAPIURL)(`/v1/remote/${e}/browser${t}`):(0,eT.localAPIURL)(`/v1/browser${t}`)}async function Y2(e,t){try{await fetch(Y1(e,"/input"),{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch{}}function Y5({active:e=!0,className:t}){let[n,r]=ew.useState(0),a=function(e,t){let{machines:n}=vd(),[r,a]=ew.useState([]);return ew.useEffect(()=>{if(!e)return;let t=!1;async function r(e,t,n){try{let r=(await Yk(t,{timeoutMs:6e3})).extensions.find(e=>"browser"===e.id);if(!r||!r.installed)return null;return{id:e,machineId:t,label:n,installed:r.installed,running:r.running}}catch{return null}}async function i(){let e=[{id:"",machineId:void 0,label:"本机"}];for(let t of n)t.isLocal||"online"===t.status&&e.push({id:t.id,machineId:t.id,label:t.name||t.id});let i=await Promise.all(e.map(e=>r(e.id,e.machineId,e.label)));t||a(i.filter(e=>null!==e))}i();let o=window.setInterval(i,1e4);return()=>{t=!0,window.clearInterval(o)}},[e,n,t]),r}(e,n),[i,o]=ew.useState(""),[l,s]=ew.useState(!1),[c,d]=ew.useState(!1),[u,f]=ew.useState(!1);ew.useEffect(()=>{0===a.length||a.some(e=>e.id===i)||o((a.find(e=>e.running)??a[0]).id)},[a,i]);let m=a.find(e=>e.id===i),h=!!m?.running;ew.useEffect(()=>{!h&&l&&s(!1)},[h,l]);let{frame:p,cursor:g,connection:x,reconnect:v}=function(e){let{machineId:t,enabled:n}=e,[r,a]=ew.useState(null),[i,o]=ew.useState(null),[l,s]=ew.useState("idle"),[c,d]=ew.useState(0),u=ew.useCallback(()=>{d(e=>e+1)},[]);return ew.useEffect(()=>{let e;if(!n){s("idle"),a(null),o(null);return}let r=!1,i=new AbortController;async function l(){s("connecting");try{let e=await fetch(Y1(t,"/screencast"),{cache:"no-store",headers:{Accept:"text/event-stream"},signal:i.signal});if(r)return;if(404===e.status||409===e.status){s("no-browser"),c();return}if(!e.ok||!e.body){s("error"),c();return}let n=e.body.getReader(),l=new TextDecoder,d="";for(s("streaming");;){let{value:e,done:t}=await n.read();if(r||t)break;let i=(d+=l.decode(e,{stream:!0})).indexOf("\n\n");for(;-1!==i;){let e=d.slice(0,i);d=d.slice(i+2),function(e){let t=e.split("\n").filter(e=>e.startsWith("data:")).map(e=>e.slice(5).trimStart());if(0===t.length)return;let n=t.join("\n");if(n&&"[DONE]"!==n)try{let e=JSON.parse(n);"frame"===e.type&&e.b64?a({b64:e.b64,width:e.meta?.width??0,height:e.meta?.height??0}):"cursor"===e.type&&"number"==typeof e.x&&"number"==typeof e.y&&o({x:e.x,y:e.y})}catch{}}(e),i=d.indexOf("\n\n")}}r||(s("connecting"),c())}catch{if(r||i.signal.aborted)return;s("error"),c()}}function c(){r||(e=setTimeout(()=>{r||l()},1500))}return l(),()=>{r=!0,i.abort(),e&&clearTimeout(e)}},[t,n,c]),{frame:r,cursor:i,connection:l,reconnect:u}}({machineId:m?.machineId,enabled:e&&h});ew.useEffect(()=>{if(!e||!h)return void f(!1);let t=!1;return YI(m?.machineId).then(e=>{!t&&e&&f(e.monitoring)}),()=>{t=!0}},[e,h,m?.machineId]);let b=ew.useCallback(e=>{YP(m?.machineId,e).then(e=>{f(e.monitoring),v()}).catch(()=>{})},[m,v]),y=a.map(e=>({id:e.id,machineId:e.machineId,label:e.label,running:e.running})),w=ew.useCallback(e=>{Y2(m?.machineId,e)},[m?.machineId]),j=ew.useCallback(async()=>{if(!c){d(!0);try{await YE(m?.machineId,!0);let e=Date.now()+3e4;for(;Date.now()<e;){await new Promise(e=>setTimeout(e,1500));try{let e=await Yk(m?.machineId,{timeoutMs:6e3});if(e.extensions.find(e=>"browser"===e.id)?.running)break}catch{}}}catch{}finally{d(!1),r(e=>e+1)}}},[m,c]);return(0,eb.jsx)(Y0,{cursor:g,className:t,frame:p,connection:h?x:"no-browser",takeover:l,onTakeoverChange:s,onInput:w,onReconnect:v,machines:y,selectedMachineId:i,onSelectMachine:o,onStartBrowser:m&&!h?()=>void j():void 0,starting:c,monitoring:u,onMonitoringChange:h?b:void 0})}function Y4({defaultUrl:e,className:t}){let{machines:n}=vd(),[r,a]=ew.useState(!1);return(ew.useEffect(()=>{let e=!1;async function t(){let t=[void 0];for(let e of n)e.isLocal||"online"===e.status&&t.push(e.id);let r=await Promise.all(t.map(async e=>{try{let t=await Yk(e,{timeoutMs:6e3});return!!t.extensions.find(e=>"browser"===e.id)?.running}catch{return!1}}));e||a(r.some(Boolean))}t();let r=window.setInterval(t,12e3);return()=>{e=!0,window.clearInterval(r)}},[n]),r)?(0,eb.jsx)(Y5,{active:!0,className:t}):(0,eb.jsx)(YZ,{className:t,defaultUrl:e})}let Y3=[{policyNumber:3,name:"Allow HTTP Traffic",sourceZone:"Trust",sourceIPs:["192.168.1.0/24","10.0.0.0/8"],destinationZone:"Trust",destinationIPs:["192.168.2.0/24"],tags:["Web Access","Internal"],action:"allow",description:"Permits HTTP traffic from internal network"},{policyNumber:5,name:"Block Suspicious IPs",sourceZone:"Untrust",sourceIPs:["203.0.113.0/24","198.51.100.0/24"],destinationZone:"Trust",destinationIPs:["Any"],tags:["Blocking","Security"],action:"deny",description:"Blocks known malicious IP ranges"},{policyNumber:9,name:"SSH Access Control",sourceZone:"Trust",sourceIPs:["172.16.0.0/12"],destinationZone:"Trust",destinationIPs:["10.50.0.0/16"],tags:["Admin Access","VPN"],action:"allow",description:"Restricted SSH access for admin network"},{policyNumber:12,name:"Database Port Protection",sourceZone:"Untrust",sourceIPs:["0.0.0.0/0"],destinationZone:"Trust",destinationIPs:["10.100.0.0/24"],tags:["Blocking","Database"],action:"deny",description:"Blocks external access to database ports"},{policyNumber:15,name:"API Gateway Access",sourceZone:"Trust",sourceIPs:["192.168.100.0/24","192.168.101.0/24"],destinationZone:"Trust",destinationIPs:["10.200.0.5"],tags:["API","VDI Env"],action:"allow",description:"Allows traffic to API gateway from specific subnets"},{policyNumber:18,name:"Drop Legacy SMB",sourceZone:"Trust",sourceIPs:["Any"],destinationZone:"Trust",destinationIPs:["10.20.0.0/16"],tags:["Legacy","Internal"],action:"drop",description:"Drops SMBv1 probes across workstation networks"},{policyNumber:22,name:"Agent Runtime Mesh",sourceZone:"Trust",sourceIPs:["10.10.4.0/24"],destinationZone:"Trust",destinationIPs:["10.10.8.0/24","10.10.12.0/24"],tags:["Agent","Runtime"],action:"allow",description:"Allows managed agent runtime channels between worker pools"},{policyNumber:27,name:"Block Public Admin Ports",sourceZone:"Untrust",sourceIPs:["0.0.0.0/0"],destinationZone:"Trust",destinationIPs:["Any"],tags:["Blocking","Admin Access"],action:"deny",description:"Denies public access to SSH, RDP, and database admin ports"},{policyNumber:31,name:"Build Cache Access",sourceZone:"Trust",sourceIPs:["10.30.0.0/16"],destinationZone:"Trust",destinationIPs:["10.60.12.20"],tags:["Build","Internal"],action:"allow",description:"Allows build workers to reach shared cache storage"},{policyNumber:36,name:"Relay Egress",sourceZone:"Trust",sourceIPs:["10.40.0.0/16"],destinationZone:"Untrust",destinationIPs:["198.18.0.0/15"],tags:["Relay","Agent"],action:"allow",description:"Permits relay service egress to managed edge addresses"},{policyNumber:41,name:"Quarantine Subnet",sourceZone:"Quarantine",sourceIPs:["10.250.0.0/24"],destinationZone:"Trust",destinationIPs:["Any"],tags:["Security","Blocking"],action:"deny",description:"Blocks quarantined hosts from internal services"},{policyNumber:48,name:"Observability Intake",sourceZone:"Trust",sourceIPs:["10.0.0.0/8"],destinationZone:"Trust",destinationIPs:["10.80.4.10"],tags:["Telemetry","Internal"],action:"allow",description:"Allows metrics and logs to the observability intake"}],Y6=Array.from(new Set(Y3.flatMap(e=>e.tags))).sort(),Y8=[["10.10.4.0/24","Agent workers","Trust","18"],["10.20.0.0/16","Workstations","Trust","41"],["10.250.0.0/24","Quarantine","Quarantine","03"],["198.18.0.0/15","Relay edge","Untrust","12"]],Y7=[["Database Port Protection","2026-06-12","Security"],["Relay Egress","2026-06-28","Network"],["Build Cache Access","2026-07-04","Build"],["Observability Intake","2026-07-18","Ops"]];function Y9({className:e,...t}){return(0,eb.jsx)("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:(0,ez.cn)("mx-auto flex w-full justify-center",e),...t})}function Ze({className:e,...t}){return(0,eb.jsx)("ul",{"data-slot":"pagination-content",className:(0,ez.cn)("flex flex-row items-center gap-1",e),...t})}function Zt({...e}){return(0,eb.jsx)("li",{"data-slot":"pagination-item",...e})}function Zn({className:e,isActive:t,size:n="icon",...r}){return(0,eb.jsx)("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:(0,ez.cn)((0,eO.buttonVariants)({variant:t?"outline":"ghost",size:n}),e),...r})}function Zr({className:e,previousLabel:t="Previous",...n}){return(0,eb.jsxs)(Zn,{"aria-label":t,size:"default",className:(0,ez.cn)("gap-1 px-2.5 sm:pl-2",e),...n,children:[(0,eb.jsx)(h8,{}),(0,eb.jsx)("span",{className:"hidden sm:block",children:t})]})}function Za({className:e,nextLabel:t="Next",...n}){return(0,eb.jsxs)(Zn,{"aria-label":t,size:"default",className:(0,ez.cn)("gap-1 px-2.5 sm:pr-2",e),...n,children:[(0,eb.jsx)("span",{className:"hidden sm:block",children:t}),(0,eb.jsx)(h7,{})]})}function Zi({className:e,moreLabel:t="More pages",...n}){return(0,eb.jsxs)("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:(0,ez.cn)("flex size-8 items-center justify-center",e),...n,children:[(0,eb.jsx)(lG,{className:"size-4"}),(0,eb.jsx)("span",{className:"sr-only",children:t})]})}function Zo({title:e}){return(0,eb.jsx)("h2",{className:"h-7 text-sm font-semibold tracking-normal",children:e})}function Zl(){let[e,t]=ew.useState(""),[n,r]=ew.useState("all"),[a,i]=ew.useState({allow:!1,drop:!1,deny:!1}),[o,l]=ew.useState(1),s=ew.useMemo(()=>["allow","drop","deny"].filter(e=>a[e]),[a]),c=ew.useMemo(()=>[{id:"policyNumber",header:"策略 #",accessorKey:"policyNumber",align:"right",width:84},{id:"name",header:"名称",accessorKey:"name",width:180,className:"font-medium"},{id:"sourceZone",header:"源区域",accessorKey:"sourceZone",width:112,cell:({row:e})=>(0,eb.jsx)(Zd,{zone:e.sourceZone})},{id:"sourceIPs",header:"源 IP",accessorKey:"sourceIPs",width:250,cell:({row:e})=>(0,eb.jsx)(Zc,{items:e.sourceIPs,variant:"outline"}),copyValue:({row:e})=>e.sourceIPs.join(", ")},{id:"destinationZone",header:"目标区域",accessorKey:"destinationZone",width:112,cell:({row:e})=>(0,eb.jsx)(Zd,{zone:e.destinationZone})},{id:"destinationIPs",header:"目标 IP",accessorKey:"destinationIPs",width:250,cell:({row:e})=>(0,eb.jsx)(Zc,{items:e.destinationIPs,variant:"outline"}),copyValue:({row:e})=>e.destinationIPs.join(", ")},{id:"tags",header:"标签",accessorKey:"tags",width:220,cell:({row:e})=>(0,eb.jsx)(Zc,{items:e.tags,variant:"secondary"}),copyValue:({row:e})=>e.tags.join(", ")},{id:"action",header:"动作",accessorKey:"action",width:96,cell:({row:e})=>(0,eb.jsx)(Zu,{action:e.action})}],[]),d=ew.useMemo(()=>{let t=e.trim().toLowerCase();return Y3.filter(e=>{let r=0===t.length||e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.sourceIPs.some(e=>e.toLowerCase().includes(t))||e.destinationIPs.some(e=>e.toLowerCase().includes(t)),i="all"===n||e.tags.includes(n),o=!(a.allow||a.drop||a.deny)||a.allow&&"allow"===e.action||a.drop&&"drop"===e.action||a.deny&&"deny"===e.action;return r&&i&&o})},[a,e,n]),u=Math.max(1,Math.ceil(d.length/8)),f=Math.min(o,u),m=d.slice((f-1)*8,8*f);return ew.useEffect(()=>{l(1)},[a,e,n]),(0,eb.jsxs)("div",{className:"flex h-full min-h-0 flex-col p-3",children:[(0,eb.jsxs)("div",{className:"mb-3 flex shrink-0 items-center justify-between gap-3",children:[(0,eb.jsx)(Zo,{title:"防火墙策略"}),(0,eb.jsxs)(eO.Button,{size:"sm",children:[(0,eb.jsx)(lY,{className:"size-4"}),"新增策略"]})]}),(0,eb.jsxs)("div",{className:"mb-3 grid shrink-0 grid-cols-1 items-end gap-3 sm:grid-cols-[minmax(12rem,1fr)_10rem_auto]",children:[(0,eb.jsxs)("label",{className:"grid gap-1",children:[(0,eb.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:"搜索"}),(0,eb.jsxs)("span",{className:"relative",children:[(0,eb.jsx)(vu,{className:"pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground"}),(0,eb.jsx)(eA,{value:e,onChange:e=>t(e.target.value),placeholder:"搜索策略...",className:"pl-8"})]})]}),(0,eb.jsxs)("label",{className:"grid gap-1",children:[(0,eb.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:"标签"}),(0,eb.jsxs)(gU,{value:n,onValueChange:r,children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{placeholder:"全部标签"})}),(0,eb.jsxs)(xS,{children:[(0,eb.jsx)(xC,{value:"all",children:"全部标签"}),Y6.map(e=>(0,eb.jsx)(xC,{value:e,children:e},e))]})]})]}),(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:"动作"}),(0,eb.jsxs)(hY,{type:"multiple",variant:"outline",value:s,onValueChange:function(e){e.includes("clear")?(t(""),r("all"),i({allow:!1,drop:!1,deny:!1}),l(1)):i({allow:e.includes("allow"),drop:e.includes("drop"),deny:e.includes("deny")})},children:[(0,eb.jsx)(hZ,{value:"allow",children:"允许"}),(0,eb.jsx)(hZ,{value:"drop",children:"丢弃"}),(0,eb.jsx)(hZ,{value:"deny",children:"拒绝"}),(0,eb.jsx)(hZ,{value:"clear",children:"全部"})]})]})]}),(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-x-auto",children:(0,eb.jsx)(WA,{rows:m,columns:c,rowId:"policyNumber",showHeader:!1,showToolbar:!1,rowHeight:40,className:"h-full min-h-0 rounded-lg shadow-none",labels:{noRows:"没有匹配的策略。",selectAllRows:"选择当前页策略",selectRow:e=>`选择第 ${e+1} 条策略`,resizeColumn:"调整列宽",sortAsc:"升序",sortDesc:"降序",sortClear:"取消排序",copyCell:"复制单元格",copied:"已复制"}})}),(0,eb.jsx)(Zs,{page:f,totalPages:u,onPageChange:function(e){l(Math.min(u,Math.max(1,e)))}})]})}function Zs({page:e,totalPages:t,onPageChange:n}){let r=ew.useMemo(()=>t<=3?Array.from({length:t},(e,t)=>t+1):e<=2?[1,2,3]:e>=t-1?[t-2,t-1,t]:[e-1,e,e+1],[e,t]),a=r[0]??1,i=r[r.length-1]??t;function o(e,t){e.preventDefault(),n(t)}return(0,eb.jsx)(Y9,{className:"mt-3 shrink-0",children:(0,eb.jsxs)(Ze,{className:"gap-1 sm:gap-2",children:[(0,eb.jsx)(Zt,{children:(0,eb.jsx)(Zr,{href:"#",previousLabel:"上一页","aria-disabled":1===e,className:(0,ez.cn)(1===e&&"pointer-events-none opacity-40"),onClick:t=>o(t,e-1)})}),a>1?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(Zt,{children:(0,eb.jsx)(Zn,{href:"#",size:"icon",onClick:e=>o(e,1),children:"1"})}),a>2?(0,eb.jsx)(Zt,{children:(0,eb.jsx)(Zi,{moreLabel:"更多页"})}):null]}):null,r.map(t=>(0,eb.jsx)(Zt,{children:(0,eb.jsx)(Zn,{href:"#",size:"icon",isActive:e===t,onClick:e=>o(e,t),children:t})},t)),i<t?(0,eb.jsxs)(eb.Fragment,{children:[i<t-1?(0,eb.jsx)(Zt,{children:(0,eb.jsx)(Zi,{moreLabel:"更多页"})}):null,(0,eb.jsx)(Zt,{children:(0,eb.jsx)(Zn,{href:"#",size:"icon",onClick:e=>o(e,t),children:t})})]}):null,(0,eb.jsx)(Zt,{children:(0,eb.jsx)(Za,{href:"#",nextLabel:"下一页","aria-disabled":e===t,className:(0,ez.cn)(e===t&&"pointer-events-none opacity-40"),onClick:t=>o(t,e+1)})})]})})}function Zc({items:e,variant:t}){return(0,eb.jsx)("div",{className:"flex min-w-48 flex-wrap gap-1",children:e.map(e=>(0,eb.jsx)(Vp,{variant:t,children:e},e))})}function Zd({zone:e}){return(0,eb.jsx)(Vp,{variant:"Trust"===e?"secondary":"outline",children:e})}function Zu({action:e}){return(0,eb.jsx)(Vp,{variant:"allow"===e?"default":"destructive",children:{allow:"允许",drop:"丢弃",deny:"拒绝"}[e]})}function Zf({className:e,...t}){return(0,eb.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:(0,eb.jsx)("table",{"data-slot":"table",className:(0,ez.cn)("w-full caption-bottom text-sm",e),...t})})}function Zm({className:e,...t}){return(0,eb.jsx)("thead",{"data-slot":"table-header",className:(0,ez.cn)("[&_tr]:border-b",e),...t})}function Zh({className:e,...t}){return(0,eb.jsx)("tbody",{"data-slot":"table-body",className:(0,ez.cn)("[&_tr:last-child]:border-0",e),...t})}function Zp({className:e,...t}){return(0,eb.jsx)("tr",{"data-slot":"table-row",className:(0,ez.cn)("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",e),...t})}function Zg({className:e,...t}){return(0,eb.jsx)("th",{"data-slot":"table-head",className:(0,ez.cn)("h-9 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-0.5",e),...t})}function Zx({className:e,...t}){return(0,eb.jsx)("td",{"data-slot":"table-cell",className:(0,ez.cn)("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-0.5",e),...t})}function Zv({title:e}){return(0,eb.jsx)("h2",{className:"h-7 text-sm font-semibold tracking-normal",children:e})}function Zb({title:e,headers:t,rows:n}){return(0,eb.jsxs)("div",{className:"flex h-full min-h-0 flex-col p-3",children:[(0,eb.jsx)(Zv,{title:e}),(0,eb.jsx)("div",{className:"mt-3 min-h-0 flex-1 overflow-auto",children:(0,eb.jsxs)(Zf,{children:[(0,eb.jsx)(Zm,{children:(0,eb.jsx)(Zp,{children:t.map(e=>(0,eb.jsx)(Zg,{children:e},e))})}),(0,eb.jsx)(Zh,{children:n.map(e=>(0,eb.jsx)(Zp,{children:e.map((e,t)=>(0,eb.jsx)(Zx,{className:0===t?"font-medium":"text-muted-foreground",children:e},`${e}-${t}`))},e.join("-")))})]})})]})}function Zy(){return(0,eb.jsxs)("div",{className:"grid h-full min-h-0 content-start gap-3 p-3",children:[(0,eb.jsx)(Zv,{title:"策略申请"}),(0,eb.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,eb.jsx)(eA,{placeholder:"策略名称"}),(0,eb.jsx)(eA,{placeholder:"负责人"}),(0,eb.jsx)(eA,{placeholder:"源 CIDR"}),(0,eb.jsx)(eA,{placeholder:"目标 CIDR"})]}),(0,eb.jsx)("textarea",{placeholder:"用途",className:"min-h-32 resize-none rounded-lg border border-input bg-transparent px-2.5 py-2 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50"}),(0,eb.jsx)("div",{children:(0,eb.jsxs)(eO.Button,{size:"sm",children:[(0,eb.jsx)(lY,{className:"size-4"}),"提交申请"]})})]})}function Zw(){return(0,eb.jsxs)(XJ,{defaultValue:"policies",className:"vtl-firewall-workspace flex h-full min-h-0 flex-col",children:[(0,eb.jsx)("div",{className:"shrink-0 overflow-x-auto px-3 pt-3 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:(0,eb.jsxs)(X8,{className:"h-8 w-max min-w-full",children:[(0,eb.jsx)(X7,{value:"policies",children:"防火墙策略"}),(0,eb.jsx)(X7,{value:"ip-addresses",children:"IP 地址"}),(0,eb.jsx)(X7,{value:"renewals",children:"续期"}),(0,eb.jsx)(X7,{value:"policy-request",children:"策略申请"}),(0,eb.jsx)(X7,{value:"user-settings",children:"用户设置"})]})}),(0,eb.jsx)(X9,{value:"policies",className:"mt-3 min-h-0 flex-1 border-t",children:(0,eb.jsx)(Zl,{})}),(0,eb.jsx)(X9,{value:"ip-addresses",className:"mt-3 min-h-0 flex-1 border-t",children:(0,eb.jsx)(Zb,{title:"IP 地址",headers:["地址","名称","区域","策略"],rows:Y8})}),(0,eb.jsx)(X9,{value:"renewals",className:"mt-3 min-h-0 flex-1 border-t",children:(0,eb.jsx)(Zb,{title:"续期",headers:["策略","续期时间","负责人"],rows:Y7})}),(0,eb.jsx)(X9,{value:"policy-request",className:"mt-3 min-h-0 flex-1 border-t",children:(0,eb.jsx)(Zy,{})}),(0,eb.jsx)(X9,{value:"user-settings",className:"mt-3 min-h-0 flex-1 border-t",children:(0,eb.jsx)(Zb,{title:"用户设置",headers:["设置","值"],rows:[["默认区域","Trust"],["审核提醒","14 天"],["申请审批","安全负责人"],["策略导出","已开启"]]})})]})}function Zj(e){return e.map(e=>{var t;return{id:e.id,name:e.name,path:e.path,kind:"folder"===(t=e.kind)?"folder":"image"===t?"image":"archive"===t?"archive":"text"===t?"text":"code"===t?"code":"executable"===t?"config":"unknown",hasChildren:"folder"===e.kind,readonly:e.readonly,disabled:e.disabled}})}async function Zk(e,t){let n=t.machineId||"local";return Zj((await fc(n,e.path)).items)}function ZN({className:e,onOpenFile:t}){let[n,r]=ew.useState([]),[a,i]=ew.useState(!1),[o,l]=ew.useState(0),s=ew.useCallback(async()=>{i(!0);try{let e=await fs();r(e.roots.map(e=>({id:e.id,machineId:e.machineId,name:e.name,path:e.path,platform:e.platform,children:Zj(e.children)}))),l(e=>e+1)}catch{r([]),l(e=>e+1)}finally{i(!1)}},[]);return ew.useEffect(()=>{s()},[s]),ew.useEffect(()=>{function e(){s()}return window.addEventListener("vantaloom:file-system-changed",e),()=>window.removeEventListener("vantaloom:file-system-changed",e)},[s]),(0,eb.jsx)(U2,{className:e,compact:!0,openFilesOnSingleClick:!1,allowCreateFile:!1,allowCreateFolder:!1,allowRename:!1,allowDelete:!1,allowDragAndDrop:!1,allowBoxSelect:!1,defaultRoots:n,defaultExpandedIds:n.map(e=>e.id),loadingIds:a?n.map(e=>e.id):[],labels:{title:"Explorer",refresh:"刷新",collapseAll:"折叠",empty:"没有文件",noResults:"没有匹配文件",loading:"读取中..."},onLoadChildren:Zk,onOpenNode:(e,n)=>{"folder"!==e.kind&&t?.({machineId:n.machineId||"local",path:e.path})},onRefresh:()=>{s()}},o)}function ZS({open:e,onOpenChange:t,onSelectFile:n}){return(0,eb.jsx)(dX,{open:e,onOpenChange:t,children:(0,eb.jsxs)(fU,{className:"h-[min(42rem,calc(100svh-2rem))] max-w-2xl gap-0 overflow-hidden p-0",children:[(0,eb.jsx)(fK,{className:"sr-only",children:"选择文件"}),(0,eb.jsx)(fG,{className:"sr-only",children:"选择本机可访问文件。"}),(0,eb.jsx)(ZN,{className:"size-full max-w-none rounded-none border-0",onOpenFile:e=>{n(e),t(!1)}})]})})}function ZC(){let e=ew.useRef(null),[t,n]=ew.useState({width:0,height:0});return ew.useLayoutEffect(()=>{let t=e.current;if(!t)return;function r(){let e=t.getBoundingClientRect();n({width:e.width,height:e.height})}r();let a=new ResizeObserver(r);return a.observe(t),()=>a.disconnect()},[]),[e,t]}let ZM=(0,ek.default)("shield-off",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]);function ZE({open:e,placement:t="viewport",movePermissionGranted:n,onOpenChange:r,onAdd:a,onMovePermissionGrantedChange:i}){let o=[{key:"move-permission",label:n?"取消放行权限":"放行权限",icon:n?(0,eb.jsx)(kB,{className:"size-4"}):(0,eb.jsx)(ZM,{className:"size-4"}),pressed:n,onClick:()=>i(!n)},{key:"add",label:"新建文件窗口",icon:(0,eb.jsx)(lY,{className:"size-4"}),pressed:void 0,onClick:a}];return(0,eb.jsx)("div",{className:(0,ez.cn)("right-5 z-50","viewport"===t?"fixed bottom-5 max-md:bottom-20":"absolute bottom-5"),children:(0,eb.jsxs)("div",{className:"relative size-8",children:[o.map((t,n)=>(0,eb.jsx)(eO.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.label,"aria-pressed":t.pressed,title:t.label,onClick:t.onClick,className:(0,ez.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[opacity,transform] duration-150 ease-out",e?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0",t.pressed&&"border-foreground bg-foreground text-background hover:bg-foreground/90 hover:text-background"),style:{transform:e?`translateY(-${(n+1)*42}px)`:void 0},children:t.icon},t.key)),(0,eb.jsx)(eO.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":"文件窗口操作","aria-expanded":e,onClick:()=>r(!e),className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,eb.jsx)(lG,{className:(0,ez.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}let ZI=[];function ZP(e,t){return`${e} / ${t.replace(/\\/g," / ").replace(/\//g," / ")}`}function ZO(e,t){for(let n of e){if(n.id===t)return n;let e=n.children?ZO(n.children,t):void 0;if(e)return e}}function Zz(e,t){return e.replace(/\\/g,"/").toLowerCase()===t.replace(/\\/g,"/").toLowerCase()}function ZA(e,t){let n=e.replace(/\\/g,"/").replace(/\/+/g,"/");return"windows"===t?n.toLowerCase():n}function ZT(e){return e.map(e=>({...e,children:e.children?ZT(e.children):void 0}))}let ZR=(0,ek.default)("move-right",[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]]),ZD=(0,ek.default)("octagon-alert",[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]]),Z_=(0,ek.default)("clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]),ZL={title:"Clipboard",empty:"No clips",dragHandle:"Drag clip"};function Z$({items:e,expanded:t,defaultExpanded:n=!1,expansionDirection:r="down-left",title:a,labels:i,maxCollapsedItems:o=10,maxExpandedHeight:l=360,acceptExternalDrops:s=!1,removeOnExternalDrop:c=!1,className:d,onExpandedChange:u,onItemDragStart:f,onItemDragEnd:m,onItemDuplicate:h,onItemsRemove:p,onItemsReorder:g,onExternalDrop:x,onMouseEnter:v,onMouseLeave:b,...y}){let w={...ZL,...i},[j,k]=ew.useState(n),[N,S]=ew.useState(),[C,M]=ew.useState(),[E,I]=ew.useState(n),[P,O]=ew.useState(),[z,A]=ew.useState({canScrollDown:!1,canScrollUp:!1}),[T,R]=ew.useState(!1),[D,_]=ew.useState(!1),L=ew.useRef(0),$=ew.useRef(void 0),F=ew.useRef(!1),B=ew.useRef(null),V=ew.useRef(null),H=void 0!==t,U=(H?t:j)||void 0!==N,q=Math.min(o,10),W=U?e:e.slice(0,q),K=E?C:void 0,G=44*W.length+18,X=Math.min(G,l),Y=U&&G>X,Z=0===e.length?"h-24":U?`${X}px`:"h-28",J=U&&Y?14:0;ew.useEffect(()=>{if(!U){I(!1),A({canScrollDown:!1,canScrollUp:!1});return}I(!1),window.requestAnimationFrame(()=>{V.current&&(V.current.scrollTop=0)}),A({canScrollUp:!1,canScrollDown:G>X});let e=window.setTimeout(()=>{I(!0)},260);return()=>window.clearTimeout(e)},[G,X,U]),ew.useEffect(()=>()=>{void 0!==$.current&&window.clearTimeout($.current)},[]);let Q=ew.useCallback(e=>{H||k(e),u?.(e)},[H,u]);function ee(e,t=0){let n=e.currentTarget.getBoundingClientRect();return e.clientX>=n.left-t&&e.clientX<=n.right+t&&e.clientY>=n.top-t&&e.clientY<=n.bottom+t}function et(e){if(!U||!V.current)return 0;let t=Array.from(V.current.querySelectorAll('[data-slot="clipboard-stack-card"]'));if(0===t.length)return 0;for(let[n,r]of t.entries()){let t=r.getBoundingClientRect();if(e.clientY<t.top+t.height/2)return n}return t.length}function en(e){return void 0!==N||Array.from(e.dataTransfer.types).includes("application/vnd.vantaloom.clip-id")}return ew.useEffect(()=>{if(0===e.length||U)return;let t=window.requestAnimationFrame(()=>{B.current?.matches(":hover")&&(void 0!==$.current&&(window.clearTimeout($.current),$.current=void 0),R(!1),Q(!0))});return()=>window.cancelAnimationFrame(t)},[e.length,Q,U]),ew.useEffect(()=>{if(!U||!Y||!K||!V.current)return;let e=W.findIndex(e=>e.id===K);if(e<0)return;let t=V.current,n=44*e-8,r=44*e+(W[e]?.expandedHeight??220)+12,a=t.scrollTop,i=a+t.clientHeight;n<a?t.scrollTo({top:Math.max(0,n),behavior:"smooth"}):r>i&&t.scrollTo({top:r-t.clientHeight,behavior:"smooth"})},[K,Y,W,U]),(0,eb.jsxs)("div",{ref:B,"data-slot":"clipboard-stack","data-expanded":U,"data-closing":T,"data-external-dragging":D,"data-expansion-direction":r,className:(0,ez.cn)("group/clipboard relative w-80 max-w-full overflow-visible py-2",d),onMouseEnter:function(e){v?.(e),ee(e)&&(void 0!==$.current&&(window.clearTimeout($.current),$.current=void 0),R(!1),Q(!0))},onMouseMove:function(e){if(!U){ee(e,12)&&(void 0!==$.current&&(window.clearTimeout($.current),$.current=void 0),R(!1),Q(!0));return}!U||N||ee(e,12)||(M(void 0),O(void 0),Q(!1),R(!0),void 0!==$.current&&window.clearTimeout($.current),$.current=window.setTimeout(()=>{R(!1),$.current=void 0},320))},onMouseLeave:function(e){b?.(e),N||(M(void 0),O(void 0),R(!0),Q(!1),void 0!==$.current&&window.clearTimeout($.current),$.current=window.setTimeout(()=>{R(!1),$.current=void 0},320))},onDragEnter:function(e){!s||en(e)||(L.current+=1,_(!0),R(!1))},onDragLeave:function(e){!s||en(e)||(L.current=Math.max(0,L.current-1),0===L.current&&(_(!1),O(void 0)))},onDragOver:function(e){!s||en(e)||(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="copy",_(!0),U?O(et(e)):O(0))},onDrop:function(t){if(!s||en(t))return;t.preventDefault(),t.stopPropagation();let n=P??et(t);L.current=0,_(!1),O(void 0),x?.({insertIndex:n,items:e,nativeEvent:t})},...y,children:[(0,eb.jsxs)("div",{"data-slot":"clipboard-stack-header",className:(0,ez.cn)("mb-2 flex h-8 items-center gap-2 px-1 text-sm font-medium text-foreground transition-[opacity,transform] duration-200","down-left"===r&&"justify-end",U?"opacity-100":"translate-y-1 opacity-0"),children:[(0,eb.jsx)("span",{className:"inline-flex size-6 items-center justify-center rounded-lg border bg-background text-muted-foreground",children:(0,eb.jsx)(Z_,{className:"size-3.5"})}),(0,eb.jsx)("span",{children:a??w.title}),(0,eb.jsx)("span",{className:"ml-auto tabular-nums text-muted-foreground",children:e.length})]}),(0,eb.jsxs)("div",{"data-slot":"clipboard-stack-list",className:(0,ez.cn)("relative transition-[height] duration-300 ease-[cubic-bezier(.2,.8,.2,1)]"),style:{height:Z},children:[e.length>0&&"down-left"===r?(0,eb.jsx)("span",{"data-slot":"clipboard-stack-pivot","aria-hidden":"true",className:(0,ez.cn)("pointer-events-none absolute top-3 right-[34px] z-50 size-2.5 rounded-full bg-foreground shadow-sm transition-[opacity,transform] duration-200 dark:bg-background",U?"scale-75 opacity-0":"opacity-100")}):null,s&&D?(0,eb.jsxs)("span",{"data-slot":"clipboard-stack-external-ghost","aria-hidden":"true",className:(0,ez.cn)("pointer-events-none absolute right-0 z-[70] h-14 w-[88%] rounded-xl border bg-background shadow-md shadow-black/10","clipboard-stack-external-ghost"),children:[(0,eb.jsx)("span",{className:"absolute top-3 right-[34px] size-2 rounded-full bg-foreground dark:bg-background"}),(0,eb.jsx)("span",{className:"absolute top-4 left-3 h-2 w-24 rounded-full bg-foreground/18"}),(0,eb.jsx)("span",{className:"absolute top-8 left-3 h-1.5 w-14 rounded-full bg-foreground/10"})]}):null,0===e.length?(0,eb.jsx)("div",{className:"flex h-24 items-center justify-center rounded-xl border border-dashed bg-muted/35 text-sm text-muted-foreground",children:w.empty}):(0,eb.jsxs)("div",{"data-slot":"clipboard-stack-scroll-frame",className:"relative h-full",children:[(0,eb.jsx)("div",{"data-slot":"clipboard-stack-scroll",ref:V,className:(0,ez.cn)("relative h-full overflow-x-visible",U&&Y?"clipboard-stack-scrollbar-hidden overflow-y-auto pt-2 pr-1 pb-3":"overflow-visible"),onScroll:e=>{let t=e.currentTarget;A({canScrollUp:t.scrollTop>1,canScrollDown:t.scrollTop+t.clientHeight<t.scrollHeight-1})},onDragOver:function(e){U&&N&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move")},onDrop:function(t){if(!U||!N||void 0===P)return;t.preventDefault(),t.stopPropagation(),F.current=!0;let n=e.findIndex(e=>e.id===N),r=e[n];if(n<0||!r)return;let a=e.filter(e=>e.id!==N),i=Math.max(0,Math.min(P>n?P-1:P,a.length));a.splice(i,0,r),O(void 0),M(void 0),i!==n&&g?.(a,{item:r,fromIndex:n,toIndex:i,items:a})},children:(0,eb.jsxs)("div",{"data-slot":"clipboard-stack-scroll-content",className:"relative",style:{width:U&&Y?`calc(100% - ${J}px)`:void 0,marginLeft:U&&Y?`${J}px`:void 0,height:U&&Y?G+28:U?G:"100%"},children:[void 0!==P?(0,eb.jsxs)("span",{"data-slot":"clipboard-stack-insert-line","aria-hidden":"true",className:"pointer-events-none absolute right-0 left-0 z-[80] flex items-center",style:{top:44*P-2},children:[(0,eb.jsx)("span",{className:"h-px flex-1 bg-foreground/70"}),(0,eb.jsx)("span",{className:"mx-1 size-1.5 rounded-full bg-foreground"}),(0,eb.jsx)("span",{className:"h-px flex-1 bg-foreground/70"})]}):null,W.map((t,n)=>(0,eb.jsx)(ZF,{item:t,index:n,count:W.length,expanded:U,active:U&&t.id===K,top:U?44*n:void 0,expansionDirection:r,labels:w,onHover:()=>M(t.id),onDuplicate:()=>{let n=e.findIndex(e=>e.id===t.id);n<0||h?.(e,{item:t,index:n,items:e})},onDragOver:e=>{if(U&&N&&N!==t.id){let t=e.currentTarget.getBoundingClientRect();O(e.clientY<t.top+t.height/2?n:n+1)}},onDragStart:e=>{S(e.item.id),M(void 0),F.current=!1,f?.(e)},onDragEnd:t=>{let n=t.nativeEvent.dataTransfer.dropEffect,r=t.item.id,a=e.findIndex(e=>e.id===r),i=c&&!F.current&&"none"!==n&&a>=0;if(S(void 0),O(void 0),M(void 0),F.current?F.current=!1:Q(!1),i){let n=e.filter(e=>e.id!==r);p?.(n,{item:t.item,index:a,items:n})}m?.(t)}},t.id))]})}),Y&&z.canScrollUp?(0,eb.jsx)("span",{"data-slot":"clipboard-stack-scroll-mask-top","aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 top-0 z-[90] h-8 bg-gradient-to-b from-background to-transparent"}):null,Y&&z.canScrollDown?(0,eb.jsx)("span",{"data-slot":"clipboard-stack-scroll-mask-bottom","aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 bottom-0 z-[90] h-8 bg-gradient-to-t from-background to-transparent"}):null]})]})]})}function ZF({item:e,index:t,count:n,expanded:r,active:a,top:i,expansionDirection:o,labels:l,onHover:s,onDuplicate:c,onDragOver:d,onDragStart:u,onDragEnd:f}){let m=Math.min(t,9),h="down-left"===o?-(4.5*m):[-4,2,-1,4][m]??0,p=r?a?n+20:n-t:n+t;return(0,eb.jsx)("article",{"data-slot":"clipboard-stack-card",draggable:!e.disabled,"aria-disabled":e.disabled,className:(0,ez.cn)("absolute right-0 min-h-16 w-full cursor-grab select-none rounded-xl border bg-background p-2.5 text-foreground shadow-sm shadow-black/5 outline-none transition-[top,transform,opacity,box-shadow,border-color] duration-300 ease-[cubic-bezier(.2,.8,.2,1)] active:cursor-grabbing","hover:border-foreground/35 hover:shadow-md hover:shadow-black/10 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/40",r&&"min-h-0 overflow-hidden py-2 transition-[top,transform,max-height,opacity,box-shadow,border-color] duration-300",r&&!a&&"max-h-11",e.disabled&&"cursor-not-allowed opacity-50"),style:{top:r?i??44*t:"down-left"===o?0:9*m,zIndex:p,maxHeight:r&&a?e.expandedHeight??220:void 0,transformOrigin:"down-left"===o?"calc(100% - 34px) 14px":"100% 0",transform:r?a?"translate3d(-10px, -6px, 0) rotate(0deg)":"translate3d(0, 0, 0) rotate(0deg)":`translate3d(${"down-left"===o?0:4*m}px, 0, 0) rotate(${h}deg)`},tabIndex:e.disabled?-1:0,onMouseDown:function(t){1!==t.button||e.disabled||t.preventDefault()},onMouseEnter:s,onFocus:s,onAuxClick:function(t){1!==t.button||e.disabled||(t.preventDefault(),c?.())},onDragOver:d,onDragStart:function(t){for(let[n,r]of(t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setData("text/plain",e.title),t.dataTransfer.setData("application/vnd.vantaloom.clip-id",e.id),Object.entries(e.dragData??{})))t.dataTransfer.setData(n,r);u?.({item:e,nativeEvent:t})},onDragEnd:function(t){f?.({item:e,nativeEvent:t})},children:(0,eb.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[(0,eb.jsx)("div",{"data-slot":"clipboard-stack-card-media",className:"flex size-8 shrink-0 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:e.icon??(0,eb.jsx)(Z_,{className:"size-4"})}),(0,eb.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,eb.jsx)("p",{className:"truncate text-sm font-medium",children:e.title}),e.meta?(0,eb.jsx)("span",{className:"ml-auto shrink-0 text-xs tabular-nums text-muted-foreground",children:e.meta}):null]}),e.description?(0,eb.jsx)("p",{className:(0,ez.cn)("mt-0.5 text-xs leading-5 text-muted-foreground transition-[max-height,opacity,transform] duration-200",a?"max-h-40 translate-y-0 opacity-100":"max-h-0 -translate-y-1 overflow-hidden opacity-0"),children:e.description}):null,e.content?(0,eb.jsx)("div",{className:(0,ez.cn)("mt-2 text-xs text-muted-foreground transition-[max-height,opacity,transform] duration-200",a?"max-h-80 translate-y-0 opacity-100":"max-h-0 -translate-y-1 overflow-hidden opacity-0"),children:e.content}):null]}),(0,eb.jsx)("span",{"aria-label":l.dragHandle,className:"mt-1 inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground",children:(0,eb.jsx)(fX,{className:"size-3.5"})})]})})}function ZB({transfers:e}){let t=e.slice(0,10);if(0===t.length)return null;let n=t.map(e=>{var t,n,r;let a,i,o;return{id:e.id,title:(a="copy"===(t=e).mode?"复制":"移动",i=t.sources.length,o=t.sources[0],`${a} ${i>1?`${i} 项`:ZH(o?.path??"")}`),description:(n=e).message?n.message:`${n.sources[0]?.machineId??"local"} -> ${n.target.machineId}`,meta:function(e){switch(e.status){case"completed":return"完成";case"failed":return"失败";case"queued":return"排队";default:return`${Math.round(e.progress?.percent??0)}%`}}(e),icon:"completed"===(r=e).status?(0,eb.jsx)(eI,{className:"size-4"}):"failed"===r.status?(0,eb.jsx)(ZD,{className:"size-4"}):"running"===r.status?(0,eb.jsx)(eM,{className:"size-4 animate-spin"}):"copy"===r.mode?(0,eb.jsx)(lV,{className:"size-4"}):(0,eb.jsx)(ZR,{className:"size-4"}),expandedHeight:132,content:(0,eb.jsx)(ZV,{transfer:e})}});return(0,eb.jsx)("div",{className:"pointer-events-auto fixed top-4 right-4 z-50 w-80 max-w-[calc(100vw-2rem)] max-md:left-4 max-md:right-auto max-md:w-auto max-md:max-w-[16rem]",children:(0,eb.jsx)(Z$,{items:n,title:"传输",labels:{empty:"暂无传输",dragHandle:"传输任务"},expansionDirection:"down-left",maxExpandedHeight:420})})}function ZV({transfer:e}){let t=Math.max(0,Math.min(100,e.progress?.percent??0));return(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)("div",{className:"h-1.5 overflow-hidden rounded-full bg-border",children:(0,eb.jsx)("div",{className:"h-full rounded-full bg-foreground transition-[width] duration-300",style:{width:`${t}%`}})}),(0,eb.jsxs)("div",{className:"grid gap-1 tabular-nums",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[(0,eb.jsx)("span",{className:"truncate",children:ZH(e.target.path)}),(0,eb.jsxs)("span",{children:[Math.round(t),"%"]})]}),(0,eb.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-2 text-muted-foreground",children:[(0,eb.jsxs)("span",{className:"truncate",children:[ZU(e.progress.bytesDone)," /"," ",ZU(e.progress.bytesTotal)]}),(0,eb.jsxs)("span",{children:[e.progress.entriesDone,"/",e.progress.entriesTotal]})]}),e.progress.currentPath?(0,eb.jsx)("div",{className:"truncate text-muted-foreground",children:ZH(e.progress.currentPath)}):null]})]})}function ZH(e){return e.split(/[\\/]+/).filter(Boolean).at(-1)??e}function ZU(e){if(!e)return"0 B";let t=["B","KB","MB","GB","TB"],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n>=10||0===r?Math.round(n):n.toFixed(1)} ${t[r]}`}let Zq=(0,ek.default)("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);function ZW({windowLayout:e,roots:t,active:n,zIndex:r,boardSize:a,onActivate:i,onClose:o,onMinimize:l,onWindowChange:s,onNavigate:c,onRootsChange:d,onCreateFolder:u,onRenameItem:f,onDeleteItems:m,onMoveItems:h}){return(0,eb.jsxs)("section",{className:(0,ez.cn)("absolute overflow-hidden rounded-xl border bg-card shadow-lg transition-[box-shadow,border-color] duration-150","vtl-file-manager-window",n&&"border-foreground shadow-xl"),style:{left:e.x,top:e.y,width:e.w,height:e.h,zIndex:r},onPointerDown:i,children:[(0,eb.jsxs)("div",{className:"grid h-9 cursor-grab grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 border-b bg-muted/35 px-2 active:cursor-grabbing",onPointerDown:function(t){t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),i();let n=t.clientX,r=t.clientY;function a(t){let a=Math.max(0,e.x+t.clientX-n),i=Math.max(0,e.y+t.clientY-r);s({...e,x:a,y:i})}window.addEventListener("pointermove",a),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",e)})},children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1",children:[(0,eb.jsx)(eO.Button,{type:"button",size:"icon-sm",variant:"ghost","aria-label":"关闭窗口",onPointerDown:e=>e.stopPropagation(),onClick:o,children:(0,eb.jsx)(fV.XIcon,{})}),(0,eb.jsx)(eO.Button,{type:"button",size:"icon-sm",variant:"ghost","aria-label":"缩小到剪切板",onPointerDown:e=>e.stopPropagation(),onClick:l,children:(0,eb.jsx)(Zq,{})})]}),(0,eb.jsx)("div",{className:"truncate text-center ui-text-control",children:e.title}),(0,eb.jsx)("div",{className:"w-14"})]}),(0,eb.jsx)(jU,{roots:t,variant:"full",currentRootId:e.rootId,currentPath:e.path,draggableItems:!0,onNavigate:c,onRootsChange:e=>d(e),onCreateFolder:u,onRenameItem:f,onDeleteItems:m,onItemDrop:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>h({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r}),labels:{title:"文件管理",search:"搜索文件",newFolder:"新建",upload:"上传",refresh:"刷新",sort:"排序",view:"视图"},className:"vtl-file-window-explorer min-h-0 rounded-none border-0 shadow-none",contentClassName:"min-h-0",style:{height:"calc(100% - 2.25rem)",minHeight:0}}),(0,eb.jsx)("button",{type:"button","aria-label":"调整窗口大小",className:"absolute right-0 bottom-0 size-5 cursor-nwse-resize rounded-tl-md border-t border-l bg-background/80",onPointerDown:function(t){t.preventDefault(),t.stopPropagation(),t.currentTarget.setPointerCapture(t.pointerId),i();let n=t.clientX,r=t.clientY;function o(t){let i=Math.max(420,Math.min(Math.max(420,a.width-e.x),e.w+t.clientX-n)),o=Math.max(320,e.h+t.clientY-r);s({...e,w:i,h:o})}window.addEventListener("pointermove",o),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",e)})}})]})}function ZK({clipboardItems:e=[],onClipboardItemsChange:t,className:n,minBoardHeight:r=520,actionsPlacement:a="container"}){let[i,o]=ZC(),[l,s]=ew.useState([]),[c,d]=ew.useState(ZI),[u,f]=ew.useState(ZI[0]?.id),[m,h]=ew.useState([]),[p,g]=ew.useState(!1),[x,v]=ew.useState(!1),[b,y]=ew.useState(),w=ew.useRef(ZI.length),j=ew.useRef(!1),k=ew.useRef(new Set),N=ew.useCallback(async(e,t,n)=>{let r=await fc(e,n);s(n=>{var a;return a={...r,root:{...r.root,id:t,machineId:e}},n.map(e=>e.id!==a.root.id?e:Zz(e.path,a.path)?{...e,children:ZT(a.items)}:{...e,children:function(e,t,n,r,a){let i=function(e,t,n){let r=ZA(e,n),a=ZA(t,n);if(r===a)return[];let i=r.endsWith("/")?r:`${r}/`;return a.startsWith(i)?a.slice(i.length).split("/").filter(Boolean):[]}(t,n,r);if(0===i.length)return ZT(a);let o="windows"===r?"\\":"/";return function e(t,n,r){let l=i[r];if(!l)return ZT(a);let s=n===o?`${o}${l}`:`${n.replace(/[\\/]+$/,"")}${o}${l}`,c=t.findIndex(e=>Zz(e.path,s)),d=t[c],u={...d??{id:`synthetic-${s}`,name:l,kind:"folder",path:s,children:[]},kind:"folder",children:e(d?.children??[],s,r+1)};if(c<0)return[...t,u];let f=[...t];return f[c]=u,f}(e,t,0)}(e.children,e.path,a.path,e.platform,a.items)})})},[]),S=ew.useCallback(async()=>{let e=ZY((await fg()).transfers);return h(e),e},[]),C=ew.useCallback(e=>{h(t=>ZY([e,...t.filter(t=>t.id!==e.id)]))},[]),M=ew.useCallback(e=>{fp({mode:"move",sources:e.sources.map(e=>({machineId:e.machineId,path:e.path})),target:{machineId:e.target.machineId,path:e.target.path}}).then(C).catch(()=>{})},[C]),E=ew.useCallback(()=>{for(let e of c)N(e.machineId,e.rootId,e.path)},[N,c]);function I(e,t){d(n=>n.map(n=>n.id===e?t(n):n))}function P(e){let t=l[0];if(!t&&!e?.rootId)return;w.current+=1;let n=`files-window-${w.current}`,r=i.current?.getBoundingClientRect(),a=r?.width??o.width,s=r?.height??o.height,c=e?.w??680,u=e?.h??460,m=Math.max(0,(a-c)/2),h=Math.max(0,(s-u)/2),p={id:n,title:e?.title??ZP(t?.name??"local",t?.path??""),machineId:e?.machineId??t?.machineId??"local",rootId:e?.rootId??t?.id??"local",path:e?.path??t?.path??"",x:e?.x??m+12*w.current,y:e?.y??h+12*w.current,w:c,h:u};d(e=>[...e,p]),f(n),N(p.machineId,p.rootId,p.path)}ew.useEffect(()=>{let e=!0;return(async function(){let t=await fs();if(e&&(s(t.roots),!j.current&&t.roots[0])){j.current=!0;let e=function(e,t=0){return{id:`files-${e.id.replace(/[^a-z0-9_-]/gi,"-")}-${t}`,title:ZP(e.name,e.path),machineId:e.machineId,rootId:e.id,path:e.path,x:28+24*t,y:28+24*t,w:720,h:480}}(t.roots[0]);d([e]),f(e.id),N(e.machineId,e.rootId,e.path)}})().catch(()=>{}),S().catch(()=>{}),()=>{e=!1}},[N,S]),ew.useEffect(()=>{if(!m.some(e=>"pending"===e.status||"running"===e.status||"queued"===e.status))return;let e=window.setInterval(async()=>{let e=(await S().catch(()=>m)).filter(e=>"completed"===e.status&&!k.current.has(e.id));if(e.length>0){for(let t of e)k.current.add(t.id);E()}},1e3);return()=>window.clearInterval(e)},[E,S,m]);let O=sv(),z=c.find(e=>e.id===u);function A(e){return{onNavigate:({rootId:t,path:n})=>{let r=l.find(e=>e.id===t),a=r?.machineId??e.machineId;I(e.id,e=>({...e,machineId:a,rootId:t,path:n,title:ZP(r?.name??a,n)})),N(a,t,n)},onRootsChange:s,onCreateFolder:(t,n)=>{ff({machineId:e.machineId,path:t.path,name:n}).then(()=>N(e.machineId,e.rootId,e.path)).catch(()=>{})},onRenameItem:(t,n)=>{fm({machineId:e.machineId,path:t.path,name:n}).then(()=>N(e.machineId,e.rootId,e.path)).catch(()=>{})},onDeleteItems:t=>{fh({machineId:e.machineId,paths:t.map(e=>e.path)}).then(()=>N(e.machineId,e.rootId,e.path)).catch(()=>{})},onMoveItems:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>{let a=l.find(t=>t.id===e);if(!a)return;let i=t.flatMap(e=>{let t=ZO(a.children,e);return t?[{machineId:a.machineId,path:t.path,name:t.name}]:[]});if(0===i.length)return;let o={sources:i,target:{machineId:n.machineId,path:r.path,name:r.name}};x?M(o):y(o)}}}return O?(0,eb.jsxs)("div",{className:(0,ez.cn)("flex h-full min-h-0 w-full flex-col",n),children:[c.length>1?(0,eb.jsx)("div",{className:"flex shrink-0 items-center gap-1 overflow-x-auto border-b px-2 py-1.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:c.map(e=>(0,eb.jsx)("button",{type:"button",className:(0,ez.cn)("shrink-0 rounded-md px-2.5 py-1 text-xs transition-colors",e.id===u?"bg-foreground text-background":"text-muted-foreground hover:bg-muted"),onClick:()=>f(e.id),children:e.title},e.id))}):null,(0,eb.jsx)("div",{className:"min-h-0 flex-1",children:z?(0,eb.jsx)(ZG,{windowLayout:z,roots:l,...A(z)}):(0,eb.jsx)("div",{className:"grid h-full place-items-center text-sm text-muted-foreground",children:"暂无打开的文件窗口"})}),(0,eb.jsx)(ZB,{transfers:m}),(0,eb.jsx)(ZE,{open:p,placement:a,movePermissionGranted:x,onOpenChange:g,onMovePermissionGrantedChange:v,onAdd:()=>{g(!1),P()}}),(0,eb.jsx)(ZX,{move:b,onCancel:()=>y(void 0),onConfirm:e=>{y(void 0),M(e)}})]}):(0,eb.jsxs)("div",{ref:i,className:(0,ez.cn)("relative h-full min-h-0 w-full overflow-hidden rounded-[inherit]",n),onDragOver:e=>{Array.from(e.dataTransfer.types).includes("application/vnd.vantaloom.file-window")&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},onDrop:function(e){let t=e.dataTransfer.getData("application/vnd.vantaloom.file-window");if(t)try{let n=JSON.parse(t),r=i.current?.getBoundingClientRect();e.preventDefault(),e.stopPropagation(),P({...n,x:r?e.clientX-r.left-160:n.x,y:r?e.clientY-r.top-24:n.y})}catch{return}},children:[(0,eb.jsx)("div",{className:"relative h-full min-h-0",style:{minHeight:Math.max(r,o.height-48)},children:c.map((n,r)=>(0,eb.jsx)(ZW,{windowLayout:n,roots:l,active:u===n.id,zIndex:20+r+20*(u===n.id),boardSize:o,onActivate:()=>f(n.id),onClose:()=>d(e=>e.filter(e=>e.id!==n.id)),onMinimize:()=>{t?.([{id:`clip-${n.id}`,title:n.title,description:"文件管理窗口",meta:`${Math.round(n.w)}x${Math.round(n.h)}`,payloads:{"application/vnd.vantaloom.file-window":{...n}},dragData:{"application/vnd.vantaloom.clip-kind":"file-window","application/vnd.vantaloom.file-window":JSON.stringify(n)}},...e.filter(e=>e.id!==`clip-${n.id}`)]),d(e=>e.filter(e=>e.id!==n.id))},onWindowChange:e=>I(n.id,()=>e),...A(n),onNavigate:({rootId:e,path:t})=>{let r=l.find(t=>t.id===e),a=r?.machineId??n.machineId;I(n.id,n=>({...n,machineId:a,rootId:e,path:t,title:ZP(r?.name??a,t)})),N(a,e,t)},onRootsChange:s,onCreateFolder:(e,t)=>{ff({machineId:n.machineId,path:e.path,name:t}).then(()=>N(n.machineId,n.rootId,n.path)).catch(()=>{})},onRenameItem:(e,t)=>{fm({machineId:n.machineId,path:e.path,name:t}).then(()=>N(n.machineId,n.rootId,n.path)).catch(()=>{})},onDeleteItems:e=>{fh({machineId:n.machineId,paths:e.map(e=>e.path)}).then(()=>N(n.machineId,n.rootId,n.path)).catch(()=>{})},onMoveItems:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>{let a=l.find(t=>t.id===e);if(!a)return;let i=t.flatMap(e=>{let t=ZO(a.children,e);return t?[{machineId:a.machineId,path:t.path,name:t.name}]:[]});if(0===i.length)return;let o={sources:i,target:{machineId:n.machineId,path:r.path,name:r.name}};x?M(o):y(o)}},n.id))}),(0,eb.jsx)(ZB,{transfers:m}),(0,eb.jsx)(ZE,{open:p,placement:a,movePermissionGranted:x,onOpenChange:g,onMovePermissionGrantedChange:v,onAdd:()=>{g(!1),P()}}),(0,eb.jsx)(ZX,{move:b,onCancel:()=>y(void 0),onConfirm:e=>{y(void 0),M(e)}})]})}function ZG({windowLayout:e,roots:t,onNavigate:n,onRootsChange:r,onCreateFolder:a,onRenameItem:i,onDeleteItems:o,onMoveItems:l}){return(0,eb.jsx)(jU,{roots:t,variant:"full",currentRootId:e.rootId,currentPath:e.path,onNavigate:n,onRootsChange:e=>r(e),onCreateFolder:a,onRenameItem:i,onDeleteItems:o,onItemDrop:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>l({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r}),labels:{title:"文件管理",search:"搜索文件",newFolder:"新建",upload:"上传",refresh:"刷新",sort:"排序",view:"视图"},className:"h-full min-h-0 rounded-none border-0 shadow-none",contentClassName:"min-h-0"})}function ZX({move:e,onCancel:t,onConfirm:n}){var r;let a=e?.sources??[],i=Math.max(0,a.length-4);return(0,eb.jsx)(ux,{open:void 0!==e,onOpenChange:e=>{e||t()},children:(0,eb.jsxs)(uR,{children:[(0,eb.jsxs)(uD,{children:[(0,eb.jsx)(uL,{children:"确认移动"}),(0,eb.jsx)(u$,{children:e?`将 ${1===(r=a).length?r[0]?ZZ(r[0]):"0 项":`${r.length} 项`} 移动到 ${ZZ(e.target)}`:""})]}),e?(0,eb.jsxs)("div",{className:"grid gap-2 rounded-lg border bg-muted/20 p-3 ui-text-body",children:[(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsx)("span",{className:"text-muted-foreground ui-text-kbd",children:"移动内容"}),(0,eb.jsxs)("div",{className:"grid gap-1",children:[a.slice(0,4).map(e=>(0,eb.jsx)("span",{className:"truncate",children:ZZ(e)},`${e.machineId}:${e.path}`)),i>0?(0,eb.jsxs)("span",{className:"text-muted-foreground",children:["另有 ",i," 项"]}):null]})]}),(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsx)("span",{className:"text-muted-foreground ui-text-kbd",children:"目标位置"}),(0,eb.jsx)("span",{className:"truncate",children:ZZ(e.target)})]})]}):null,(0,eb.jsxs)(u_,{children:[(0,eb.jsx)(uB,{children:"取消"}),(0,eb.jsx)(uF,{onClick:()=>{e&&n(e)},children:"确认移动"})]})]})})}function ZY(e){return e.slice(0,10)}function ZZ(e){let t=e.path.replace(/\\/g,"/");return`${e.machineId} / ${e.name||t}`}function ZJ({className:e}){return(0,eb.jsx)(ZK,{className:(0,ez.cn)("h-full min-h-0 w-full rounded-[inherit] border-0 shadow-none",e),minBoardHeight:360,actionsPlacement:"container"})}var ZQ=ew;function Z0(){return(Z0=Object.assign.bind()).apply(null,arguments)}var Z1=e=>{var{cx:t,cy:n,r,className:a}=e,i=(0,kq.clsx)("recharts-dot",a);return Nj(t)&&Nj(n)&&Nj(r)?ew.createElement("circle",Z0({},AK(e),Tv(e),{className:i,cx:t,cy:n,r:r})):null},Z2=["points"];function Z5(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z4(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Z5(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Z5(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Z3(){return(Z3=Object.assign.bind()).apply(null,arguments)}function Z6(e){var{option:t,dotProps:n,className:r}=e;if((0,ew.isValidElement)(t))return(0,ew.cloneElement)(t,n);if("function"==typeof t)return t(n);var a=(0,kq.clsx)(r,"boolean"!=typeof t?t.className:""),i=null!=n?n:{},{points:o}=i,l=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(i,Z2);return ew.createElement(Z1,Z3({},l,{className:a}))}function Z8(e){var{points:t,dot:n,className:r,dotClassName:a,dataKey:i,baseProps:o,needClip:l,clipPathId:s,zIndex:c=M2.scatter}=e;if(null==t||!n&&1!==t.length)return null;var d=Ro(n),u=null==n?null:(0,ew.isValidElement)(n)?AX(n.props):"object"!=typeof n||Array.isArray(n)?null:AX(n),f=t.map((e,r)=>{var l,s,c=Z4(Z4(Z4({r:3},o),u),{},{index:r,cx:null!=(l=e.x)?l:void 0,cy:null!=(s=e.y)?s:void 0,dataKey:i,value:e.value,payload:e.payload,points:t});return ew.createElement(Z6,{key:"dot-".concat(r),option:n,dotProps:c,className:a})}),m={};return l&&null!=s&&(m.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(s,")")),ew.createElement(LX,{zIndex:c},ew.createElement(AJ,Z3({className:r},m),f))}function Z7(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z9(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Z7(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Z7(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Je=e=>{var t,{point:n,childIndex:r,mainColor:a,activeDot:i,dataKey:o,clipPath:l}=e;if(!1===i||null==n.x||null==n.y)return null;var s=Z9(Z9(Z9({},{index:r,dataKey:o,cx:n.x,cy:n.y,r:4,fill:null!=a?a:"none",strokeWidth:2,stroke:"#fff",payload:n.payload,value:n.value}),AG(i)),Tv(i));return t=(0,ew.isValidElement)(i)?(0,ew.cloneElement)(i,s):"function"==typeof i?i(s):ew.createElement(Z1,s),ew.createElement(AJ,{className:"recharts-active-dot",clipPath:l},t)};function Jt(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:a,clipPath:i,zIndex:o=M2.activeDot}=e,l=Sl(Li),s=Sl(Lh);if(null==t||null==s)return null;var c=t.find(e=>s.includes(e.payload));return null==c?null:ew.createElement(LX,{zIndex:o},ew.createElement(Je,{point:c,childIndex:Number(l),mainColor:n,dataKey:a,activeDot:r,clipPath:i}))}function Jn(e,t){var n,r,a=Sl(t=>OU(t,e)),i=Sl(e=>OK(e,t)),o=null!=(n=null==a?void 0:a.allowDataOverflow)?n:OV.allowDataOverflow,l=null!=(r=null==i?void 0:i.allowDataOverflow)?r:Oq.allowDataOverflow;return{needClip:o||l,needClipX:o,needClipY:l}}function Jr(e){var{xAxisId:t,yAxisId:n,clipPathId:r}=e,a=Sl(B9),{needClipX:i,needClipY:o,needClip:l}=Jn(t,n);if(!l||!a)return null;var{x:s,y:c,width:d,height:u}=a;return ew.createElement("clipPath",{id:"clipPath-".concat(r)},ew.createElement("rect",{x:i?s:s-d/2,y:o?c:c-u/2,width:i?d:2*d,height:o?u:2*u}))}function Ja(e,t){var n,r;return null!=(n=null==(r=e.graphicalItems.cartesianItems.find(e=>e.id===t))?void 0:r.xAxisId)?n:0}function Ji(e,t){var n,r;return null!=(n=null==(r=e.graphicalItems.cartesianItems.find(e=>e.id===t))?void 0:r.yAxisId)?n:0}var Jo=(e,t,n)=>Av(e,"xAxis",Ja(e,t),n),Jl=(e,t,n)=>Ax(e,"xAxis",Ja(e,t),n),Js=(e,t,n)=>Av(e,"yAxis",Ji(e,t),n),Jc=(e,t,n)=>Ax(e,"yAxis",Ji(e,t),n),Jd=k9([MM,Jo,Js,Jl,Jc],(e,t,n,r,a)=>N$(e,"xAxis")?NG(t,r,!1):NG(n,a,!1)),Ju=k9([O0,(e,t)=>t],(e,t)=>e.filter(e=>"area"===e.type).find(e=>e.id===t)),Jf=e=>N$(MM(e),"xAxis")?"yAxis":"xAxis",Jm=k9([Ju,(e,t,n)=>zp(e,Jf(e),"yAxis"===Jf(e)?Ji(e,t):Ja(e,t),n)],(e,t)=>{if(null!=e&&null!=t){var n,{stackId:r}=e,a=Ef(e);if(null!=r&&null!=a){var i=null==(n=t[r])?void 0:n.stackedData,o=null==i?void 0:i.find(e=>e.key===a);if(null!=o)return o.map(e=>[e[0],e[1]])}}}),Jh=k9([MM,Jo,Js,Jl,Jc,Jm,Na,Jd,Ju,e=>e.rootProps.baseValue],(e,t,n,r,a,i,o,l,s,c)=>{var d,{chartData:u,dataStartIndex:f,dataEndIndex:m}=o;if(null!=s&&("horizontal"===e||"vertical"===e)&&null!=t&&null!=n&&null!=r&&null!=a&&0!==r.length&&0!==a.length&&null!=l){var{data:h}=s;if(null!=(d=h&&h.length>0?h:null==u?void 0:u.slice(f,m+1)))return function(e){var t,{areaSettings:{connectNulls:n,baseValue:r,dataKey:a},stackedData:i,layout:o,chartBaseValue:l,xAxis:s,yAxis:c,displayedData:d,dataStartIndex:u,xAxisTicks:f,yAxisTicks:m,bandSize:h}=e,p=i&&i.length,g=((e,t,n,r,a)=>{var i=null!=n?n:t;if(Nj(i))return i;var o="horizontal"===e?a:r,l=o.scale.domain();if("number"===o.type){var s=Math.max(l[0],l[1]),c=Math.min(l[0],l[1]);return"dataMin"===i?c:"dataMax"===i||s<0?s:Math.max(Math.min(l[0],l[1]),0)}return"dataMin"===i?l[0]:"dataMax"===i?l[1]:l[0]})(o,l,r,s,c),x="horizontal"===o,v=!1,b=d.map((e,t)=>{if(p)d=i[u+t];else{var r,o,l,d,b,y=NL(e,a);Array.isArray(y)?(d=y,v=!0):d=[g,y]}var w=null!=(r=null==(o=d)?void 0:o[1])?r:null,j=null==w||p&&!n&&null==NL(e,a);return x?{x:NU({axis:s,ticks:f,bandSize:h,entry:e,index:t}),y:j?null:null!=(b=c.scale.map(w))?b:null,value:d,payload:e}:{x:j?null:null!=(l=s.scale.map(w))?l:null,y:NU({axis:c,ticks:m,bandSize:h,entry:e,index:t}),value:d,payload:e}});return t=p||v?b.map(e=>{var t,n,r=Array.isArray(e.value)?e.value[0]:null;return x?{x:e.x,y:null!=r&&null!=e.y&&null!=(n=c.scale.map(r))?n:null,payload:e.payload}:{x:null!=r&&null!=(t=s.scale.map(r))?t:null,y:e.y,payload:e.payload}}):x?c.scale.map(g):s.scale.map(g),{points:b,baseLine:null!=t?t:0,isRange:v}}({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:a,dataStartIndex:f,areaSettings:s,stackedData:i,displayedData:d,chartBaseValue:c,bandSize:l})}});function Jp(e){var t=AG(e);if(null!=t){var{r:n,strokeWidth:r}=t,a=Number(n),i=Number(r);return(Number.isNaN(a)||a<0)&&(a=3),(Number.isNaN(i)||i<0)&&(i=2),{r:a,strokeWidth:i}}return{r:3,strokeWidth:2}}var Jg=["id"],Jx=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Jv(){return(Jv=Object.assign.bind()).apply(null,arguments)}function Jb(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function Jy(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Jw(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Jy(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Jy(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Jj(e,t){return e&&"none"!==e?e:t}var Jk=ZQ.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:a,fill:i,name:o,hide:l,unit:s,tooltipType:c,id:d}=e,u={dataDefinedOnItem:n,getPosition:Nz,settings:{stroke:r,strokeWidth:a,fill:i,dataKey:t,nameKey:void 0,name:NY(o,t),hide:l,type:c,color:Jj(r,i),unit:s,graphicalItemId:d}};return ZQ.createElement(_u,{tooltipEntrySettings:u})});function JN(e){var{clipPathId:t,points:n,props:r}=e,{needClip:a,dot:i,dataKey:o}=r,l=AK(r);return ZQ.createElement(Z8,{points:n,dot:i,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:a,clipPathId:t})}function JS(e){var{showLabels:t,children:n,points:r}=e,a=r.map(e=>{var t,n,r={x:null!=(t=e.x)?t:0,y:null!=(n=e.y)?n:0,width:0,lowerWidth:0,upperWidth:0,height:0};return Jw(Jw({},r),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:r,fill:void 0})});return ZQ.createElement($c,{value:t?a:void 0},n)}function JC(e){var{points:t,baseLine:n,needClip:r,clipPathId:a,props:i}=e,{layout:o,type:l,stroke:s,connectNulls:c,isRange:d}=i,{id:u}=i,f=Jb(i,Jg),m=AK(f),h=AX(f);return ZQ.createElement(ZQ.Fragment,null,(null==t?void 0:t.length)>1&&ZQ.createElement(AJ,{clipPath:r?"url(#clipPath-".concat(a,")"):void 0},ZQ.createElement(TE,Jv({},h,{id:u,points:t,connectNulls:c,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),"none"!==s&&ZQ.createElement(TE,Jv({},m,{className:"recharts-area-curve",layout:o,type:l,connectNulls:c,fill:"none",points:t})),"none"!==s&&d&&Array.isArray(n)&&ZQ.createElement(TE,Jv({},m,{className:"recharts-area-curve",layout:o,type:l,connectNulls:c,fill:"none",points:n}))),ZQ.createElement(JN,{points:t,props:f,clipPathId:a}))}function JM(e){var t,n,{alpha:r,baseLine:a,points:i,strokeWidth:o}=e,l=null==(t=i[0])?void 0:t.y,s=null==(n=i[i.length-1])?void 0:n.y;if(!NT(l)||!NT(s))return null;var c=r*Math.abs(l-s),d=Math.max(...i.map(e=>e.x||0));return(Nj(a)?d=Math.max(a,d):a&&Array.isArray(a)&&a.length&&(d=Math.max(...a.map(e=>e.x||0),d)),Nj(d))?ZQ.createElement("rect",{x:0,y:l<s?l:l-c,width:d+(o?parseInt("".concat(o),10):1),height:Math.floor(c)}):null}function JE(e){var t,n,{alpha:r,baseLine:a,points:i,strokeWidth:o}=e,l=null==(t=i[0])?void 0:t.x,s=null==(n=i[i.length-1])?void 0:n.x;if(!NT(l)||!NT(s))return null;var c=r*Math.abs(l-s),d=Math.max(...i.map(e=>e.y||0));return(Nj(a)?d=Math.max(a,d):a&&Array.isArray(a)&&a.length&&(d=Math.max(...a.map(e=>e.y||0),d)),Nj(d))?ZQ.createElement("rect",{x:l<s?l:l-c,y:0,width:c,height:Math.floor(d+(o?parseInt("".concat(o),10):1))}):null}function JI(e){var{alpha:t,layout:n,points:r,baseLine:a,strokeWidth:i}=e;return"vertical"===n?ZQ.createElement(JM,{alpha:t,points:r,baseLine:a,strokeWidth:i}):ZQ.createElement(JE,{alpha:t,points:r,baseLine:a,strokeWidth:i})}function JP(e){var{needClip:t,clipPathId:n,props:r,previousPointsRef:a,previousBaselineRef:i}=e,{points:o,baseLine:l,isAnimationActive:s,animationBegin:c,animationDuration:d,animationEasing:u,onAnimationStart:f,onAnimationEnd:m}=r,h=RP((0,ZQ.useMemo)(()=>({points:o,baseLine:l}),[o,l]),"recharts-area-"),p=ME(),[g,x]=(0,ZQ.useState)(!1),v=(0,ZQ.useCallback)(()=>{"function"==typeof m&&m(),x(!1)},[m]),b=(0,ZQ.useCallback)(()=>{"function"==typeof f&&f(),x(!0)},[f]);if(null==p)return null;var y=a.current,w=i.current;return ZQ.createElement(JS,{showLabels:!g,points:o},r.children,ZQ.createElement(RI,{animationId:h,begin:c,duration:d,isActive:s,easing:u,onAnimationEnd:v,onAnimationStart:b,key:h},e=>{if(y){var c,d=y.length/o.length,u=1===e?o:o.map((t,n)=>{var r=Math.floor(n*d);if(y[r]){var a=y[r];return Jw(Jw({},t),{},{x:NE(a.x,t.x,e),y:NE(a.y,t.y,e)})}return t});if(Nj(l))c=NE(w,l,e);else c=null==l||Ny(l)?NE(w,0,e):l.map((t,n)=>{var r=Math.floor(n*d);if(Array.isArray(w)&&w[r]){var a=w[r];return Jw(Jw({},t),{},{x:NE(a.x,t.x,e),y:NE(a.y,t.y,e)})}return t});return e>0&&(a.current=u,i.current=c),ZQ.createElement(JC,{points:u,baseLine:c,needClip:t,clipPathId:n,props:r})}return e>0&&(a.current=o,i.current=l),ZQ.createElement(AJ,null,s&&ZQ.createElement("defs",null,ZQ.createElement("clipPath",{id:"animationClipPath-".concat(n)},ZQ.createElement(JI,{alpha:e,points:o,baseLine:l,layout:p,strokeWidth:r.strokeWidth}))),ZQ.createElement(AJ,{clipPath:"url(#animationClipPath-".concat(n,")")},ZQ.createElement(JC,{points:o,baseLine:l,needClip:t,clipPathId:n,props:r})))}),ZQ.createElement($m,{label:r.label}))}function JO(e){var{needClip:t,clipPathId:n,props:r}=e,a=(0,ZQ.useRef)(null),i=(0,ZQ.useRef)();return ZQ.createElement(JP,{needClip:t,clipPathId:n,props:r,previousPointsRef:a,previousBaselineRef:i})}class Jz extends ZQ.PureComponent{render(){var{hide:e,dot:t,points:n,className:r,top:a,left:i,needClip:o,xAxisId:l,yAxisId:s,width:c,height:d,id:u,baseLine:f,zIndex:m}=this.props;if(e)return null;var h=(0,kq.clsx)("recharts-area",r),{r:p,strokeWidth:g}=Jp(t),x=Ro(t),v=2*p+g,b=o?"url(#clipPath-".concat(x?"":"dots-").concat(u,")"):void 0;return ZQ.createElement(LX,{zIndex:m},ZQ.createElement(AJ,{className:h},o&&ZQ.createElement("defs",null,ZQ.createElement(Jr,{clipPathId:u,xAxisId:l,yAxisId:s}),!x&&ZQ.createElement("clipPath",{id:"clipPath-dots-".concat(u)},ZQ.createElement("rect",{x:i-v/2,y:a-v/2,width:c+v,height:d+v}))),ZQ.createElement(JO,{needClip:o,clipPathId:u,props:this.props})),ZQ.createElement(Jt,{points:n,mainColor:Jj(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:b}),this.props.isRange&&Array.isArray(f)&&ZQ.createElement(Jt,{points:f,mainColor:Jj(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:b}))}}var JA={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:.6,hide:!1,isAnimationActive:"auto",legendType:"line",stroke:"#3182bd",strokeWidth:1,type:"linear",label:!1,xAxisId:0,yAxisId:0,zIndex:M2.area};function JT(e){var t,{activeDot:n,animationBegin:r,animationDuration:a,animationEasing:i,connectNulls:o,dot:l,fill:s,fillOpacity:c,hide:d,isAnimationActive:u,legendType:f,stroke:m,xAxisId:h,yAxisId:p}=e,g=Jb(e,Jx),x=Sl(MM),v=Sl(MK),{needClip:b}=Jn(h,p),y=Mn(),{points:w,isRange:j,baseLine:k}=null!=(t=Sl(t=>Jh(t,e.id,y)))?t:{},N=Sl(B9);if("horizontal"!==x&&"vertical"!==x||null==N||"AreaChart"!==v&&"ComposedChart"!==v)return null;var{height:S,width:C,x:M,y:E}=N;return w&&w.length?ZQ.createElement(Jz,Jv({},g,{activeDot:n,animationBegin:r,animationDuration:a,animationEasing:i,baseLine:k,connectNulls:o,dot:l,fill:s,fillOpacity:c,height:S,hide:d,layout:x,isAnimationActive:u,isRange:j,legendType:f,needClip:b,points:w,stroke:m,width:C,left:M,top:E,xAxisId:h,yAxisId:p})):null}var JR=ZQ.memo(function(e){var t=TG(e,JA),n=Mn();return ZQ.createElement(LC,{id:t.id,type:"area"},e=>ZQ.createElement(ZQ.Fragment,null,ZQ.createElement(Lj,{legendPayload:(e=>{var{dataKey:t,name:n,stroke:r,fill:a,legendType:i,hide:o}=e;return[{inactive:o,dataKey:t,type:i,color:Jj(r,a),value:NY(n,t),payload:e}]})(t)}),ZQ.createElement(Jk,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),ZQ.createElement(LR,{type:"area",id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:NH(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),ZQ.createElement(JT,Jv({},t,{id:e}))))},BM);function JD(){return(JD=Object.assign.bind()).apply(null,arguments)}function J_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}JR.displayName="Area";var JL=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?J_(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):J_(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:{top:5,right:5,bottom:5,left:5},responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},Bp),J$=(0,ew.forwardRef)(function(e,t){var n,r=TG(e.categoricalChartProps,JL),{chartName:a,defaultTooltipEventType:i,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,categoricalChartProps:s}=e;return ew.createElement(BN,{preloadedState:{options:{chartName:a,defaultTooltipEventType:i,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,eventEmitter:void 0}},reduxStoreName:null!=(n=s.id)?n:a},ew.createElement(BS,{chartData:s.data}),ew.createElement(BE,{layout:r.layout,margin:r.margin}),ew.createElement(BP,{throttleDelay:r.throttleDelay,throttledEvents:r.throttledEvents}),ew.createElement(BI,{baseValue:r.baseValue,accessibilityLayer:r.accessibilityLayer,barCategoryGap:r.barCategoryGap,maxBarSize:r.maxBarSize,stackOffset:r.stackOffset,barGap:r.barGap,barSize:r.barSize,syncId:r.syncId,syncMethod:r.syncMethod,className:r.className,reverseStackOrder:r.reverseStackOrder}),ew.createElement(Vr,JD({},r,{ref:t})))}),JF=["axis"],JB=(0,ew.forwardRef)((e,t)=>ew.createElement(J$,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:JF,tooltipPayloadSearcher:$A,categoricalChartProps:e,ref:t})),JV=function(e){var{width:t,height:n}=e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(r%180+180)%180*Math.PI/180,i=Math.atan(n/t);return Math.abs(a>i&&a<Math.PI-i?n/Math.sin(a):t/Math.cos(a))};function JH(e,t){if(t<1)return[];if(1===t)return e;for(var n=[],r=0;r<e.length;r+=t){var a=e[r];void 0!==a&&n.push(a)}return n}function JU(e,t,n,r,a){if(e*t<e*r||e*t>e*a)return!1;var i=n();return e*(t-e*i/2-r)>=0&&e*(t+e*i/2-a)<=0}function Jq(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function JW(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Jq(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Jq(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function JK(e,t,n){var r,{tick:a,ticks:i,viewBox:o,minTickGap:l,orientation:s,interval:c,tickFormatter:d,unit:u,angle:f}=e;if(!i||!i.length||!a)return[];if(Nj(c)||TI.isSsr)return null!=(r=JH(i,(Nj(c)?c:0)+1))?r:[];var m="top"===s||"bottom"===s?"width":"height",h=u&&"width"===m?TD(u,{fontSize:t,letterSpacing:n}):{width:0,height:0},p=(e,r)=>{var a,i="function"==typeof d?d(e.value,r):e.value;return"width"===m?(a=TD(i,{fontSize:t,letterSpacing:n}),JV({width:a.width+h.width,height:a.height+h.height},f)):TD(i,{fontSize:t,letterSpacing:n})[m]},g=i[0],x=i[1],v=i.length>=2&&null!=g&&null!=x?Nb(x.coordinate-g.coordinate):1,b=function(e,t,n){var r="width"===n,{x:a,y:i,width:o,height:l}=e;return 1===t?{start:r?a:i,end:r?a+o:i+l}:{start:r?a+o:i+l,end:r?a:i}}(o,v,m);return"equidistantPreserveStart"===c?function(e,t,n,r,a){for(var i,o=(r||[]).slice(),{start:l,end:s}=t,c=0,d=1,u=l;d<=o.length;)if(i=function(){var t,i=null==r?void 0:r[c];if(void 0===i)return{v:JH(r,d)};var o=c,f=()=>(void 0===t&&(t=n(i,o)),t),m=i.coordinate,h=0===c||JU(e,m,f,u,s);h||(c=0,u=l,d+=1),h&&(u=m+e*(f()/2+a),c+=d)}())return i.v;return[]}(v,b,p,i,l):"equidistantPreserveEnd"===c?function(e,t,n,r,a){var i=(r||[]).slice().length;if(0===i)return[];for(var{start:o,end:l}=t,s=1;s<=i;s++){for(var c,d=(i-1)%s,u=o,f=!0,m=d;m<i&&(0===(c=function(){var t,i=r[m];if(null==i)return 0;var o=m,s=()=>(void 0===t&&(t=n(i,o)),t),c=i.coordinate,h=m===d||JU(e,c,s,u,l);if(!h)return f=!1,1;h&&(u=c+e*(s()/2+a))}())||1!==c);m+=s);if(f){for(var h=[],p=d;p<i;p+=s){var g=r[p];null!=g&&h.push(g)}return h}}return[]}(v,b,p,i,l):("preserveStart"===c||"preserveStartEnd"===c?function(e,t,n,r,a,i){var o=(r||[]).slice(),l=o.length,{start:s,end:c}=t;if(i){var d=r[l-1];if(null!=d){var u=n(d,l-1),f=e*(d.coordinate+e*u/2-c);o[l-1]=d=JW(JW({},d),{},{tickCoord:f>0?d.coordinate-f*e:d.coordinate}),null!=d.tickCoord&&JU(e,d.tickCoord,()=>u,s,c)&&(c=d.tickCoord-e*(u/2+a),o[l-1]=JW(JW({},d),{},{isShow:!0}))}}for(var m=i?l-1:l,h=function(t){var r,i=o[t];if(null==i)return 1;var l=i,d=()=>(void 0===r&&(r=n(i,t)),r);if(0===t){var u=e*(l.coordinate-e*d()/2-s);o[t]=l=JW(JW({},l),{},{tickCoord:u<0?l.coordinate-u*e:l.coordinate})}else o[t]=l=JW(JW({},l),{},{tickCoord:l.coordinate});null!=l.tickCoord&&JU(e,l.tickCoord,d,s,c)&&(s=l.tickCoord+e*(d()/2+a),o[t]=JW(JW({},l),{},{isShow:!0}))},p=0;p<m;p++)if(h(p))continue;return o}(v,b,p,i,l,"preserveStartEnd"===c):function(e,t,n,r,a){for(var i=(r||[]).slice(),o=i.length,{start:l}=t,{end:s}=t,c=function(t){var r,c=i[t];if(null==c)return 1;var d=c,u=()=>(void 0===r&&(r=n(c,t)),r);if(t===o-1){var f=e*(d.coordinate+e*u()/2-s);i[t]=d=JW(JW({},d),{},{tickCoord:f>0?d.coordinate-f*e:d.coordinate})}else i[t]=d=JW(JW({},d),{},{tickCoord:d.coordinate});null!=d.tickCoord&&JU(e,d.tickCoord,u,l,s)&&(s=d.tickCoord-e*(u()/2+a),i[t]=JW(JW({},d),{},{isShow:!0}))},d=o-1;d>=0;d--)if(c(d))continue;return i}(v,b,p,i,l)).filter(e=>e.isShow)}var JG=["axisLine","width","height","className","hide","ticks","axisType","axisId"];function JX(){return(JX=Object.assign.bind()).apply(null,arguments)}function JY(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function JZ(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?JY(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):JY(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var JJ={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd",zIndex:M2.axis};function JQ(e){var{x:t,y:n,width:r,height:a,orientation:i,mirror:o,axisLine:l,otherSvgProps:s}=e;if(!l)return null;var c=JZ(JZ(JZ({},s),AK(l)),{},{fill:"none"});if("top"===i||"bottom"===i){var d=+("top"===i&&!o||"bottom"===i&&o);c=JZ(JZ({},c),{},{x1:t,y1:n+d*a,x2:t+r,y2:n+d*a})}else{var u=+("left"===i&&!o||"right"===i&&o);c=JZ(JZ({},c),{},{x1:t+u*r,y1:n,x2:t+u*r,y2:n+a})}return ew.createElement("line",JX({},c,{className:(0,kq.clsx)("recharts-cartesian-axis-line",(0,kU.default)(l,"className"))}))}function J0(e){var t,{option:n,tickProps:r,value:a}=e,i=(0,kq.clsx)(r.className,"recharts-cartesian-axis-tick-value");if(ew.isValidElement(n))t=ew.cloneElement(n,JZ(JZ({},r),{},{className:i}));else if("function"==typeof n)t=n(JZ(JZ({},r),{},{className:i}));else{var o="recharts-cartesian-axis-tick-value";"boolean"!=typeof n&&(o=(0,kq.clsx)(o,$h(n))),t=ew.createElement(T7,JX({},r,{className:o}),a)}return t}function J1(e){var{ticks:t,axisType:n,axisId:r}=e,a=Sr();return(0,ew.useEffect)(()=>null==r||null==n?Nz:(a(By({ticks:t.map(e=>({value:e.value,coordinate:e.coordinate,offset:e.offset,index:e.index})),axisId:r,axisType:n})),()=>{a(Bw({axisId:r,axisType:n}))}),[a,t,r,n]),null}var J2=(0,ew.forwardRef)((e,t)=>{var{ticks:n=[],tick:r,tickLine:a,stroke:i,tickFormatter:o,unit:l,padding:s,tickTextProps:c,orientation:d,mirror:u,x:f,y:m,width:h,height:p,tickSize:g,tickMargin:x,fontSize:v,letterSpacing:b,getTicksConfig:y,events:w,axisType:j,axisId:k}=e,N=JK(JZ(JZ({},y),{},{ticks:n}),v,b),S=AK(y),C=AG(r),M=T1(S.textAnchor)?S.textAnchor:function(e,t){switch(e){case"left":return t?"start":"end";case"right":return t?"end":"start";default:return"middle"}}(d,u),E=function(e,t){switch(e){case"left":case"right":return"middle";case"top":return t?"start":"end";default:return t?"end":"start"}}(d,u),I={};"object"==typeof a&&(I=a);var P=JZ(JZ({},S),{},{fill:"none"},I),O=N.map(e=>JZ({entry:e},function(e,t,n,r,a,i,o,l,s){var c,d,u,f,m,h,p=l?-1:1,g=e.tickSize||o,x=Nj(e.tickCoord)?e.tickCoord:e.coordinate;switch(i){case"top":c=d=e.coordinate,h=(u=(f=n+!l*a)-p*g)-p*s,m=x;break;case"left":u=f=e.coordinate,m=(c=(d=t+!l*r)-p*g)-p*s,h=x;break;case"right":u=f=e.coordinate,m=(c=(d=t+l*r)+p*g)+p*s,h=x;break;default:c=d=e.coordinate,h=(u=(f=n+l*a)+p*g)+p*s,m=x}return{line:{x1:c,y1:u,x2:d,y2:f},tick:{x:m,y:h}}}(e,f,m,h,p,d,g,u,x))),z=O.map(e=>{var{entry:t,line:n}=e;return ew.createElement(AJ,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(t.value,"-").concat(t.coordinate,"-").concat(t.tickCoord)},a&&ew.createElement("line",JX({},P,n,{className:(0,kq.clsx)("recharts-cartesian-axis-tick-line",(0,kU.default)(a,"className"))})))}),A=O.map((e,t)=>{var n,a,{entry:d,tick:u}=e,f=JZ(JZ(JZ(JZ({verticalAnchor:E},S),{},{textAnchor:M,stroke:"none",fill:i},u),{},{index:t,payload:d,visibleTicksCount:N.length,tickFormatter:o,padding:s},c),{},{angle:null!=(n=null!=(a=null==c?void 0:c.angle)?a:S.angle)?n:0}),m=JZ(JZ({},f),C);return ew.createElement(AJ,JX({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(d.value,"-").concat(d.coordinate,"-").concat(d.tickCoord)},Tb(w,d,t)),r&&ew.createElement(J0,{option:r,tickProps:m,value:"".concat("function"==typeof o?o(d.value,t):d.value).concat(l||"")}))});return ew.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(j,"-ticks")},ew.createElement(J1,{ticks:N,axisId:k,axisType:j}),A.length>0&&ew.createElement(LX,{zIndex:M2.label},ew.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(j,"-tick-labels"),ref:t},A)),z.length>0&&ew.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(j,"-tick-lines")},z))}),J5=(0,ew.forwardRef)((e,t)=>{var{axisLine:n,width:r,height:a,className:i,hide:o,ticks:l,axisType:s,axisId:c}=e,d=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(e,JG),[u,f]=(0,ew.useState)(""),[m,h]=(0,ew.useState)(""),p=(0,ew.useRef)(null);(0,ew.useImperativeHandle)(t,()=>({getCalculatedWidth:()=>{var t;return(e=>{var{ticks:t,label:n,labelGapWithTick:r=5,tickSize:a=0,tickMargin:i=0}=e,o=0;if(t){Array.from(t).forEach(e=>{if(e){var t=e.getBoundingClientRect();t.width>o&&(o=t.width)}});var l=n?n.getBoundingClientRect().width:0;return Math.round(o+(a+i)+l+(n?r:0))}return 0})({ticks:p.current,label:null==(t=e.labelRef)?void 0:t.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}}));var g=(0,ew.useCallback)(e=>{if(e){var t=e.getElementsByClassName("recharts-cartesian-axis-tick-value");p.current=t;var n=t[0];if(n){var r=window.getComputedStyle(n),a=r.fontSize,i=r.letterSpacing;(a!==u||i!==m)&&(f(a),h(i))}}},[u,m]);return o||null!=r&&r<=0||null!=a&&a<=0?null:ew.createElement(LX,{zIndex:e.zIndex},ew.createElement(AJ,{className:(0,kq.clsx)("recharts-cartesian-axis",i)},ew.createElement(JQ,{x:e.x,y:e.y,width:r,height:a,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:AK(e)}),ew.createElement(J2,{ref:g,axisType:s,events:d,fontSize:u,getTicksConfig:e,height:e.height,letterSpacing:m,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:l,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:c}),ew.createElement(L3,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},ew.createElement($n,{label:e.label,labelRef:e.labelRef}),e.children)))}),J4=ew.forwardRef((e,t)=>{var n=TG(e,JJ);return ew.createElement(J5,JX({},n,{ref:t}))});J4.displayName="CartesianAxis";var J3=["x1","y1","x2","y2","key"],J6=["offset"],J8=["xAxisId","yAxisId"],J7=["xAxisId","yAxisId"];function J9(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Qe(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?J9(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):J9(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Qt(){return(Qt=Object.assign.bind()).apply(null,arguments)}function Qn(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var Qr=e=>{var{fill:t}=e;if(!t||"none"===t)return null;var{fillOpacity:n,x:r,y:a,width:i,height:o,ry:l}=e;return ew.createElement("rect",{x:r,y:a,ry:l,width:i,height:o,stroke:"none",fill:t,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function Qa(e){var{option:t,lineItemProps:n}=e;if(ew.isValidElement(t))r=ew.cloneElement(t,n);else if("function"==typeof t)r=t(n);else{var r,a,{x1:i,y1:o,x2:l,y2:s,key:c}=n,d=null!=(a=AK(Qn(n,J3)))?a:{},{offset:u}=d,f=Qn(d,J6);r=ew.createElement("line",Qt({},f,{x1:i,y1:o,x2:l,y2:s,fill:"none",key:c}))}return r}function Qi(e){var{x:t,width:n,horizontal:r=!0,horizontalPoints:a}=e;if(!r||!a||!a.length)return null;var{xAxisId:i,yAxisId:o}=e,l=Qn(e,J8),s=a.map((e,a)=>{var i=Qe(Qe({},l),{},{x1:t,y1:e,x2:t+n,y2:e,key:"line-".concat(a),index:a});return ew.createElement(Qa,{key:"line-".concat(a),option:r,lineItemProps:i})});return ew.createElement("g",{className:"recharts-cartesian-grid-horizontal"},s)}function Qo(e){var{y:t,height:n,vertical:r=!0,verticalPoints:a}=e;if(!r||!a||!a.length)return null;var{xAxisId:i,yAxisId:o}=e,l=Qn(e,J7),s=a.map((e,a)=>{var i=Qe(Qe({},l),{},{x1:e,y1:t,x2:e,y2:t+n,key:"line-".concat(a),index:a});return ew.createElement(Qa,{option:r,lineItemProps:i,key:"line-".concat(a)})});return ew.createElement("g",{className:"recharts-cartesian-grid-vertical"},s)}function Ql(e){var{horizontalFill:t,fillOpacity:n,x:r,y:a,width:i,height:o,horizontalPoints:l,horizontal:s=!0}=e;if(!s||!t||!t.length||null==l)return null;var c=l.map(e=>Math.round(e+a-a)).sort((e,t)=>e-t);a!==c[0]&&c.unshift(0);var d=c.map((e,l)=>{var s=c[l+1],d=null==s?a+o-e:s-e;if(d<=0)return null;var u=l%t.length;return ew.createElement("rect",{key:"react-".concat(l),y:e,x:r,height:d,width:i,stroke:"none",fill:t[u],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return ew.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function Qs(e){var{vertical:t=!0,verticalFill:n,fillOpacity:r,x:a,y:i,width:o,height:l,verticalPoints:s}=e;if(!t||!n||!n.length)return null;var c=s.map(e=>Math.round(e+a-a)).sort((e,t)=>e-t);a!==c[0]&&c.unshift(0);var d=c.map((e,t)=>{var s=c[t+1],d=null==s?a+o-e:s-e;if(d<=0)return null;var u=t%n.length;return ew.createElement("rect",{key:"react-".concat(t),x:e,y:i,width:d,height:l,stroke:"none",fill:n[u],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return ew.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var Qc=(e,t)=>{var{xAxis:n,width:r,height:a,offset:i}=e;return NF(JK(Qe(Qe(Qe({},JJ),n),{},{ticks:NB(n,!0),viewBox:{x:0,y:0,width:r,height:a}})),i.left,i.left+i.width,t)},Qd=(e,t)=>{var{yAxis:n,width:r,height:a,offset:i}=e;return NF(JK(Qe(Qe(Qe({},JJ),n),{},{ticks:NB(n,!0),viewBox:{x:0,y:0,width:r,height:a}})),i.top,i.top+i.height,t)},Qu={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:M2.grid};function Qf(e){var t=Sl(NZ),n=Sl(NJ),r=MC(),a=Qe(Qe({},TG(e,Qu)),{},{x:Nj(e.x)?e.x:r.left,y:Nj(e.y)?e.y:r.top,width:Nj(e.width)?e.width:r.width,height:Nj(e.height)?e.height:r.height}),{xAxisId:i,yAxisId:o,x:l,y:s,width:c,height:d,syncWithTicks:u,horizontalValues:f,verticalValues:m}=a,h=Mn(),p=Sl(e=>Ap(e,"xAxis",i,h)),g=Sl(e=>Ap(e,"yAxis",o,h));if(!NR(c)||!NR(d)||!Nj(l)||!Nj(s))return null;var x=a.verticalCoordinatesGenerator||Qc,v=a.horizontalCoordinatesGenerator||Qd,{horizontalPoints:b,verticalPoints:y}=a;if((!b||!b.length)&&"function"==typeof v){var w=f&&f.length,j=v({yAxis:g?Qe(Qe({},g),{},{ticks:w?f:g.ticks}):void 0,width:null!=t?t:c,height:null!=n?n:d,offset:r},!!w||u);Mo(Array.isArray(j),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof j,"]")),Array.isArray(j)&&(b=j)}if((!y||!y.length)&&"function"==typeof x){var k=m&&m.length,N=x({xAxis:p?Qe(Qe({},p),{},{ticks:k?m:p.ticks}):void 0,width:null!=t?t:c,height:null!=n?n:d,offset:r},!!k||u);Mo(Array.isArray(N),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof N,"]")),Array.isArray(N)&&(y=N)}return ew.createElement(LX,{zIndex:a.zIndex},ew.createElement("g",{className:"recharts-cartesian-grid"},ew.createElement(Qr,{fill:a.fill,fillOpacity:a.fillOpacity,x:a.x,y:a.y,width:a.width,height:a.height,ry:a.ry}),ew.createElement(Ql,Qt({},a,{horizontalPoints:b})),ew.createElement(Qs,Qt({},a,{verticalPoints:y})),ew.createElement(Qi,Qt({},a,{offset:r,horizontalPoints:b,xAxis:p,yAxis:g})),ew.createElement(Qo,Qt({},a,{offset:r,verticalPoints:y,xAxis:p,yAxis:g}))))}Qf.displayName="CartesianGrid";var Qm=["domain","range"],Qh=["domain","range"];function Qp(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function Qg(e,t){return e===t||!!(Array.isArray(e)&&2===e.length&&Array.isArray(t))&&2===t.length&&e[0]===t[0]&&e[1]===t[1]}function Qx(e,t){if(e===t)return!0;var{domain:n,range:r}=e,a=Qp(e,Qm),{domain:i,range:o}=t,l=Qp(t,Qh);return!!Qg(n,i)&&!!Qg(r,o)&&BM(a,l)}var Qv=["type"],Qb=["dangerouslySetInnerHTML","ticks","scale"],Qy=["id","scale"];function Qw(){return(Qw=Object.assign.bind()).apply(null,arguments)}function Qj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Qk(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Qj(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qj(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function QN(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function QS(e){var t=Sr(),n=(0,ew.useRef)(null),r=ME(),{type:a}=e,i=QN(e,Qv),o=M6(r,"xAxis",a),l=(0,ew.useMemo)(()=>{if(null!=o)return Qk(Qk({},i),{},{type:o})},[i,o]);return(0,ew.useLayoutEffect)(()=>{null!=l&&(null===n.current?t(Fx(l)):n.current!==l&&t(Fv({prev:n.current,next:l})),n.current=l)},[l,t]),(0,ew.useLayoutEffect)(()=>()=>{n.current&&(t(Fb(n.current)),n.current=null)},[t]),null}var QC=e=>{var{xAxisId:t,className:n}=e,r=Sl(N9),a=Mn(),i="xAxis",o=Sl(e=>Ag(e,i,t,a)),l=Sl(e=>Ao(e,t)),s=Sl(e=>Ac(e,t)),c=Sl(e=>OH(e,t));if(null==l||null==s||null==c)return null;var{dangerouslySetInnerHTML:d,ticks:u,scale:f}=e,m=QN(e,Qb),{id:h,scale:p}=c,g=QN(c,Qy);return ew.createElement(J4,Qw({},m,g,{x:s.x,y:s.y,width:l.width,height:l.height,className:(0,kq.clsx)("recharts-".concat(i," ").concat(i),n),viewBox:r,ticks:o,axisType:i,axisId:t}))},QM={allowDataOverflow:OV.allowDataOverflow,allowDecimals:OV.allowDecimals,allowDuplicatedCategory:OV.allowDuplicatedCategory,angle:OV.angle,axisLine:JJ.axisLine,height:OV.height,hide:!1,includeHidden:OV.includeHidden,interval:OV.interval,label:!1,minTickGap:OV.minTickGap,mirror:OV.mirror,orientation:OV.orientation,padding:OV.padding,reversed:OV.reversed,scale:OV.scale,tick:OV.tick,tickCount:OV.tickCount,tickLine:JJ.tickLine,tickSize:JJ.tickSize,type:OV.type,niceTicks:OV.niceTicks,xAxisId:0},QE=ew.memo(e=>{var t=TG(e,QM);return ew.createElement(ew.Fragment,null,ew.createElement(QS,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),ew.createElement(QC,t))},Qx);QE.displayName="XAxis";var QI=["type"],QP=["dangerouslySetInnerHTML","ticks","scale"],QO=["id","scale"];function Qz(){return(Qz=Object.assign.bind()).apply(null,arguments)}function QA(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function QT(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?QA(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):QA(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function QR(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function QD(e){var t=Sr(),n=(0,ew.useRef)(null),r=ME(),{type:a}=e,i=QR(e,QI),o=M6(r,"yAxis",a),l=(0,ew.useMemo)(()=>{if(null!=o)return QT(QT({},i),{},{type:o})},[o,i]);return(0,ew.useLayoutEffect)(()=>{null!=l&&(null===n.current?t(Fy(l)):n.current!==l&&t(Fw({prev:n.current,next:l})),n.current=l)},[l,t]),(0,ew.useLayoutEffect)(()=>()=>{n.current&&(t(Fj(n.current)),n.current=null)},[t]),null}function Q_(e){var{yAxisId:t,className:n,width:r,label:a}=e,i=(0,ew.useRef)(null),o=(0,ew.useRef)(null),l=Sl(N9),s=Mn(),c=Sr(),d="yAxis",u=Sl(e=>Au(e,t)),f=Sl(e=>Ad(e,t)),m=Sl(e=>Ag(e,d,t,s)),h=Sl(e=>OW(e,t));if((0,ew.useLayoutEffect)(()=>{if(!("auto"!==r||!u||L7(a)||(0,ew.isValidElement)(a))&&null!=h){var e=i.current;if(e){var n=e.getCalculatedWidth();Math.round(u.width)!==Math.round(n)&&c(FC({id:t,width:n}))}}},[m,u,c,a,t,r,h]),null==u||null==f||null==h)return null;var{dangerouslySetInnerHTML:p,ticks:g,scale:x}=e,v=QR(e,QP),{id:b,scale:y}=h,w=QR(h,QO);return ew.createElement(J4,Qz({},v,w,{ref:i,labelRef:o,x:f.x,y:f.y,tickTextProps:"auto"===r?{width:void 0}:{width:r},width:u.width,height:u.height,className:(0,kq.clsx)("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:m,axisType:d,axisId:t}))}var QL={allowDataOverflow:Oq.allowDataOverflow,allowDecimals:Oq.allowDecimals,allowDuplicatedCategory:Oq.allowDuplicatedCategory,angle:Oq.angle,axisLine:JJ.axisLine,hide:!1,includeHidden:Oq.includeHidden,interval:Oq.interval,label:!1,minTickGap:Oq.minTickGap,mirror:Oq.mirror,orientation:Oq.orientation,padding:Oq.padding,reversed:Oq.reversed,scale:Oq.scale,tick:Oq.tick,tickCount:Oq.tickCount,tickLine:JJ.tickLine,tickSize:JJ.tickSize,type:Oq.type,niceTicks:Oq.niceTicks,width:Oq.width,yAxisId:0},Q$=ew.memo(e=>{var t=TG(e,QL);return ew.createElement(ew.Fragment,null,ew.createElement(QD,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter,niceTicks:t.niceTicks}),ew.createElement(Q_,t))},Qx);function QF({machines:e,defaultMachineId:t,className:n,...r}){let[a,i]=ew.useState(t??e[0]?.id),o=e.find(e=>e.id===a)??e[0],[l,s]=ew.useState({});if(!o)return null;let c=l[o.id]??o.selectedMetricId??o.metrics[0]?.id,d=o.metrics.find(e=>e.id===c)??o.metrics[0];return(0,eb.jsxs)("div",{className:(0,ez.cn)("vtl-surface-card flex h-full min-h-0 flex-col rounded-[var(--surface-card-radius)] border","vtl-performance-monitor",n),...r,children:[(0,eb.jsx)(XJ,{value:o.id,onValueChange:i,className:"shrink-0 px-3 pt-3",children:(0,eb.jsx)(X8,{className:"h-8",children:e.map(e=>(0,eb.jsx)(X7,{value:e.id,children:e.name},e.id))})}),(0,eb.jsxs)("div",{className:"mt-3 grid min-h-0 flex-1 grid-cols-[14rem_minmax(0,1fr)] border-t",children:[(0,eb.jsx)("div",{className:"min-h-0 overflow-auto border-r p-2",children:o.metrics.map(e=>(0,eb.jsxs)("button",{type:"button",onClick:()=>s(t=>({...t,[o.id]:e.id})),className:(0,ez.cn)("grid w-full grid-cols-[3.75rem_minmax(0,1fr)] gap-3 px-2 py-2 text-left transition-colors",e.id===c&&"bg-muted"),children:[(0,eb.jsx)(QW,{data:e.data,color:e.color}),(0,eb.jsxs)("span",{className:"min-w-0",children:[(0,eb.jsx)("span",{className:"block truncate text-base leading-tight",children:e.label}),(0,eb.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.value}),e.detail?(0,eb.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.detail}):null]})]},e.id))}),(0,eb.jsxs)("div",{className:"min-h-0 overflow-auto p-5",children:[(0,eb.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-start gap-5",children:[(0,eb.jsxs)("div",{children:[(0,eb.jsx)("h2",{className:"text-4xl leading-none font-semibold tracking-normal",children:d?.title}),d?.subtitle?(0,eb.jsx)("p",{className:"mt-1 text-base text-muted-foreground",children:d.subtitle}):null]}),(0,eb.jsx)("div",{className:"text-right text-sm text-muted-foreground",children:d?.detail})]}),d?(0,eb.jsx)(QB,{metric:d}):null]})]})]})}function QB({metric:e}){return"cpu"===e.kind?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(QV,{panel:{id:"cpu",title:"% 利用率",value:"100%",data:e.data,span:"full"},size:"large"}),(0,eb.jsx)(QH,{}),(0,eb.jsx)(Qq,{details:e.details,columns:4})]}):"memory"===e.kind?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(QV,{panel:{id:"memory",title:"内存使用量",value:e.detail,data:e.data,span:"full"},size:"large"}),(0,eb.jsx)(QH,{}),(0,eb.jsx)(QU,{segments:e.composition}),(0,eb.jsx)(Qq,{details:e.details,columns:3})]}):"disk"===e.kind?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(QV,{panel:{id:"disk-active",title:"活动时间",value:"100%",data:e.data,span:"full"},size:"large"}),(0,eb.jsx)(QH,{}),(0,eb.jsx)(QV,{panel:{id:"disk-rate",title:"磁盘传输速率",value:"500 KB/秒",data:e.panels?.[0]?.data??e.data,span:"full"},size:"short"}),(0,eb.jsx)(QH,{}),(0,eb.jsx)(Qq,{details:e.details,columns:4})]}):"network"===e.kind?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(QV,{panel:{id:"network",title:"吞吐量",value:"100 Kbps",data:e.data,span:"full",color:"danger"},size:"tall"}),(0,eb.jsx)(QH,{}),(0,eb.jsx)(Qq,{details:e.details,columns:2})]}):(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("div",{className:"mt-5 grid grid-cols-2 gap-3",children:(e.panels??[]).map(e=>(0,eb.jsx)(QV,{panel:e},e.id))}),(0,eb.jsx)(Qq,{details:e.details,columns:3})]})}function QV({panel:e,size:t="normal"}){let n={short:"h-[4rem]",normal:"full"===e.span?"h-20":"h-24",large:"h-[17.5rem]",tall:"h-[21.5rem]"}[t];return(0,eb.jsxs)("div",{className:(0,ez.cn)("mt-5","full"===e.span&&"col-span-2"),children:[(0,eb.jsxs)("div",{className:"mb-1 flex items-center justify-between text-sm",children:[(0,eb.jsx)("span",{className:"text-muted-foreground",children:e.title}),e.value?(0,eb.jsx)("span",{className:"text-muted-foreground tabular-nums",children:e.value}):null]}),(0,eb.jsx)(QK,{data:e.data,color:e.color,className:(0,ez.cn)("w-full",n)})]})}function QH(){return(0,eb.jsxs)("div",{className:"mt-1 flex justify-between text-xs text-muted-foreground",children:[(0,eb.jsx)("span",{children:"60 秒"}),(0,eb.jsx)("span",{children:"0"})]})}function QU({segments:e}){let t=e&&e.length>0?e:[{label:"used",value:64},{label:"available",value:36}];return(0,eb.jsxs)("div",{className:"mt-5",children:[(0,eb.jsx)("div",{className:"mb-1 text-sm text-muted-foreground",children:"内存组合"}),(0,eb.jsx)("div",{className:"flex h-[3.25rem] w-full overflow-hidden border border-primary/75 bg-background",children:t.map((e,n)=>(0,eb.jsx)("div",{className:(0,ez.cn)("h-full border-r border-primary/75 last:border-r-0",0===n?"bg-primary/20":n===t.length-1?"bg-background":"bg-primary/8"),style:{width:`${Math.max(0,e.value)}%`}},`${e.label}-${n}`))})]})}function Qq({details:e,columns:t}){return e?.length?(0,eb.jsx)("div",{className:(0,ez.cn)("mt-5 grid gap-x-10 gap-y-4",2===t&&"grid-cols-2",3===t&&"grid-cols-3",4===t&&"grid-cols-4"),children:e.map(([e,t])=>(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("div",{className:"text-xs text-muted-foreground",children:e}),(0,eb.jsx)("div",{className:"truncate text-2xl leading-tight tabular-nums",children:t})]},e))}):null}function QW({data:e,color:t}){return(0,eb.jsx)(QK,{data:e,color:t,className:"h-10 w-full",strokeWidth:1.4,compact:!0})}function QK({data:e,color:t="default",className:n,strokeWidth:r=1.6,compact:a=!1}){let i=ew.useMemo(()=>(e.length>1?e:[0,0]).map((e,t)=>({index:t,value:Math.max(0,Math.min(100,e))})),[e]),o=ew.useMemo(()=>({value:{label:"Value",color:"danger"===t?"var(--destructive)":"var(--foreground)"}}),[t]);return(0,eb.jsx)(Hl,{config:o,className:(0,ez.cn)("aspect-auto border bg-background text-muted-foreground",n),initialDimension:{width:a?96:640,height:a?40:220},children:(0,eb.jsxs)(JB,{data:i,margin:{top:a?2:6,right:0,bottom:0,left:0},children:[a?null:(0,eb.jsx)(Qf,{strokeDasharray:"0",stroke:"var(--border)",strokeOpacity:.7}),(0,eb.jsx)(QE,{dataKey:"index",hide:!0,domain:["dataMin","dataMax"]}),(0,eb.jsx)(Q$,{hide:!0,domain:[0,100]}),a?null:(0,eb.jsx)(VZ,{cursor:!1,content:(0,eb.jsx)(Hc,{hideLabel:!0,indicator:"line"})}),(0,eb.jsx)(JR,{dataKey:"value",type:"monotone",fill:"var(--color-value)",fillOpacity:"danger"===t?.16:.12,stroke:"var(--color-value)",strokeWidth:r,isAnimationActive:!1,dot:!1,activeDot:!1})]})})}Q$.displayName="YAxis";let QG=(0,ek.default)("badge-alert",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),QX=(0,ek.default)("circle-pause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]),QY={name:"名称",cpu:"CPU",memoryMb:"内存",diskMbps:"磁盘",networkMbps:"网络"};function QZ({machines:e,defaultMachineId:t,className:n,...r}){let[a,i]=ew.useState(t??e[0]?.id),[o,l]=ew.useState("cpu"),[s,c]=ew.useState("desc"),[d,u]=ew.useState({}),f=e.find(e=>e.id===a)??e[0],m=ew.useMemo(()=>{if(!f)return[];let e=[...function(e){let t=new Map,n=new Map;for(let t of e)void 0!==t.pid&&n.set(t.pid,t);for(let a of e){var r;let e=function e(t,n,r=new Set){void 0!==t.pid&&r.add(t.pid);let a=void 0!==t.parentPid?n.get(t.parentPid):void 0;return!a||void 0===a.pid||r.has(a.pid)||["bash","containerd","dockerd","explorer","init","kernel_task","launchd","services","sh","smss","svchost","system","systemd","wininit","winlogon","zsh"].includes(Q5(a))?t:e(a,n,r)}(a,n),i=Q5(e),o=t.get(i)??{kind:"group",id:i,name:(r=e,r.appName?.trim()||r.name.trim().replace(/\.(exe|com)$/i,"")||r.id),children:[],status:[],cpu:0,memoryMb:0,diskMbps:0,networkMbps:0};o.children.push(a),o.cpu+=a.cpu,o.memoryMb+=a.memoryMb,o.diskMbps+=a.diskMbps,o.networkMbps+=a.networkMbps,o.status=function(e,t){let n=new Set(e??[]);for(let e of t??[])n.add(e);return Array.from(n)}(o.status,a.status),t.set(i,o)}return Array.from(t.values()).map(e=>({...e,cpu:Q3(Math.min(100,e.cpu)),memoryMb:Q3(e.memoryMb),diskMbps:Q3(e.diskMbps),networkMbps:Q3(e.networkMbps)}))}(f.processes)].sort((e,t)=>Q4(e,t,o,s)),t=[];for(let n of e){if(n.children.length<=1){let e=n.children[0];e&&t.push(Q2(e,0));continue}if(t.push(n),d[n.id])for(let e of[...n.children].sort((e,t)=>Q4(e,t,o,s)))t.push(Q2(e,1))}return t},[f,d,s,o]),h=ew.useMemo(()=>m.map(e=>({memoryMb:e.memoryMb,diskMbps:e.diskMbps,networkMbps:e.networkMbps})),[m]);function p(e){e===o?c(e=>"asc"===e?"desc":"asc"):(l(e),c("name"===e?"asc":"desc"))}return f?(0,eb.jsxs)("div",{className:(0,ez.cn)("vtl-surface-card flex h-full min-h-0 flex-col rounded-[var(--surface-card-radius)] border","vtl-process-monitor",n),...r,children:[(0,eb.jsx)(XJ,{value:f.id,onValueChange:i,className:"shrink-0 px-3 pt-3",children:(0,eb.jsx)(X8,{className:"h-8",children:e.map(e=>(0,eb.jsx)(X7,{value:e.id,children:e.name},e.id))})}),(0,eb.jsxs)("div",{className:"mt-3 grid h-14 shrink-0 grid-cols-[minmax(12rem,1fr)_6.25rem_repeat(4,minmax(5rem,7rem))] border-y text-sm",children:[(0,eb.jsxs)("button",{type:"button",onClick:()=>p("name"),className:"flex items-end px-3 pb-2 text-left text-muted-foreground",children:["名称",(0,eb.jsx)(QJ,{active:"name"===o,direction:s})]}),(0,eb.jsx)("div",{className:"flex items-end px-3 pb-2 text-muted-foreground",children:"状态"}),["cpu","memoryMb","diskMbps","networkMbps"].map(e=>{var t,n;return(0,eb.jsxs)("button",{type:"button",onClick:()=>p(e),className:"grid content-end border-l px-3 pb-2 text-right",children:[(0,eb.jsx)("span",{className:"text-lg leading-none text-foreground",children:(t=f.totals,"cpu"===(n=e)?`${Math.round(t.cpu)}%`:"memoryMb"===n?`${Math.round(t.memory)}%`:"diskMbps"===n?`${Math.round(t.disk)}%`:"networkMbps"===n?`${Math.round(t.network)}%`:"")}),(0,eb.jsxs)("span",{className:"mt-1 text-xs text-muted-foreground",children:[QY[e],(0,eb.jsx)(QJ,{active:o===e,direction:s,className:"ml-1 inline-flex"})]})]},e)})]}),(0,eb.jsx)("div",{className:"vtl-scrollbar-hidden min-h-0 flex-1 overflow-auto",children:m.map(e=>{var t;return(0,eb.jsxs)("div",{className:(0,ez.cn)("grid min-h-9 grid-cols-[minmax(12rem,1fr)_6.25rem_repeat(4,minmax(5rem,7rem))] items-center text-sm","group"===e.kind&&"bg-muted/35"),children:[(0,eb.jsx)(QQ,{row:e,expanded:"group"===e.kind&&!!d[e.id],onToggle:()=>{"group"===e.kind&&u(t=>({...t,[e.id]:!t[e.id]}))}}),(0,eb.jsx)(Q0,{platform:f.platform,status:e.status}),(0,eb.jsx)(Q1,{value:e.cpu,max:100,label:`${e.cpu.toFixed(1)}%`}),(0,eb.jsx)(Q1,{value:e.memoryMb,max:Q6(h,"memoryMb"),label:(t=e.memoryMb)>=1024?`${Q8(t/1024)} GB`:`${Q8(t)} MB`}),(0,eb.jsx)(Q1,{value:e.diskMbps,max:Math.max(1,Q6(h,"diskMbps")),label:`${Q8(e.diskMbps)} MB/秒`}),(0,eb.jsx)(Q1,{value:e.networkMbps,max:Math.max(1,Q6(h,"networkMbps")),label:`${Q8(e.networkMbps)} Mbps`})]},`${e.kind}-${e.id}`)})})]}):null}function QJ({active:e,direction:t,className:n}){return e?(0,eb.jsx)("asc"===t?k_:kD,{className:(0,ez.cn)("ml-1 size-3",n)}):null}function QQ({row:e,expanded:t,onToggle:n}){if("group"===e.kind){let r=t?pt:h7;return(0,eb.jsxs)("button",{type:"button","aria-expanded":t,onClick:n,className:"flex h-full min-w-0 items-center gap-2 px-3 text-left outline-none transition-colors hover:bg-muted/55 focus-visible:ring-[3px] focus-visible:ring-ring/20",children:[(0,eb.jsx)(r,{className:"size-4 shrink-0 text-muted-foreground"}),(0,eb.jsx)("span",{className:"size-2 rounded-sm bg-foreground/65"}),(0,eb.jsxs)("span",{className:"min-w-0 truncate font-medium",children:[e.name," (",e.children.length,")"]})]})}return(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-2 px-3",style:{paddingLeft:e.depth>0?34:void 0},children:[e.depth>0?(0,eb.jsx)("span",{className:"size-1.5 rounded-full bg-muted-foreground/70"}):(0,eb.jsx)("span",{className:"size-1.5 rounded-full bg-foreground/65"}),(0,eb.jsx)("span",{className:(0,ez.cn)("truncate",0===e.depth&&"font-medium"),children:e.name}),e.process.pid?(0,eb.jsx)("span",{className:"shrink-0 ui-text-kbd text-muted-foreground",children:e.process.pid}):null]})}function Q0({platform:e,status:t}){return t?.length?(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 px-3 text-muted-foreground",children:[t.includes("suspended")?(0,eb.jsx)(QX,{"aria-label":"linux"===e?"挂起进程":"挂起",className:"size-4"}):null,t.includes("auto-restart")?(0,eb.jsx)(lZ,{"aria-label":"linux"===e?"自动重启进程":"自动重启",className:"size-4"}):null,t.includes("running")?(0,eb.jsx)(QG,{"aria-label":"运行",className:"size-4 text-primary"}):null]}):(0,eb.jsx)("div",{className:"px-3"})}function Q1({value:e,max:t,label:n}){let r=Math.min(1,Math.max(0,e/Math.max(1,t))),a=r>.78,i=a?`color-mix(in oklch, var(--destructive) ${Math.round(18+42*r)}%, var(--background))`:`color-mix(in oklch, var(--foreground) ${Math.round(5+20*r)}%, var(--background))`;return(0,eb.jsx)("div",{className:"vtl-process-heat-cell h-full border-l px-3 text-right tabular-nums","data-hot":a?"":void 0,style:{background:i},children:(0,eb.jsx)("span",{className:(0,ez.cn)("leading-9",a&&"text-destructive"),children:n})})}function Q2(e,t){return{kind:"process",id:e.id,process:e,depth:t,name:e.appName&&0===t?e.appName:e.name,status:e.status,cpu:e.cpu,memoryMb:e.memoryMb,diskMbps:e.diskMbps,networkMbps:e.networkMbps}}function Q5(e){return e.appId?.trim().toLowerCase()||e.appName?.trim().toLowerCase()||e.name.trim().toLowerCase().replace(/\.(exe|com)$/i,"")||e.id}function Q4(e,t,n,r){let a="asc"===r?1:-1;return"name"===n?e.name.localeCompare(t.name)*a:(e[n]-t[n])*a}function Q3(e){return Math.round(10*e)/10}function Q6(e,t){return e.reduce((e,n)=>Math.max(e,n[t]),0)}function Q8(e){return new Intl.NumberFormat("zh-CN",{maximumFractionDigits:+(e<10)}).format(e)}function Q7({className:e}){let t=eee("/api/local/machines/processes"),n=eet("/machines/processes"),r=ew.useMemo(()=>[...t,...n],[t,n]);return(0,eb.jsx)(QZ,{machines:r,className:(0,ez.cn)("h-full min-h-0 w-full",e)})}function Q9({className:e}){let t=eee("/api/local/machines/performance"),n=eet("/machines/performance"),r=ew.useMemo(()=>[...t,...n],[t,n]);return(0,eb.jsx)(QF,{machines:r,className:(0,ez.cn)("h-full min-h-0 w-full",e)})}function eee(e){let[t,n]=ew.useState([]);return ew.useEffect(()=>{let t=!0,r=!1;async function a(){if(!r){r=!0;try{let r=await fetch((0,eT.localAPIURL)(e),{cache:"no-store"});if(!r.ok)return;let a=await r.json();t&&n(a.machines)}catch{t&&n([])}finally{r=!1}}}a();let i=window.setInterval(a,2e3);return()=>{t=!1,window.clearInterval(i)}},[e]),t}function eet(e){let{machines:t}=vd(),[n,r]=ew.useState([]),a=ew.useMemo(()=>t.filter(e=>!e.isLocal&&"online"===e.status).map(e=>e.id),[t]);return ew.useEffect(()=>{if(0===a.length)return void r([]);let t=!0,n=!1;async function i(){if(!n){n=!0;try{let n=await Promise.all(a.map(async t=>{try{return(await sk(t,e)).machines??[]}catch{return[]}}));t&&r(n.flat())}finally{n=!1}}}i();let o=window.setInterval(i,5e3);return()=>{t=!1,window.clearInterval(o)}},[a,e]),n}let een=(0,ek.default)("circle-play",[["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),eer=(0,ek.default)("radio",[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]),eea={loading:"Starting terminal...",newTerminal:"New terminal",closeTerminal:e=>`Close ${e}`,terminalList:"Terminal sessions",status:{idle:"Idle",running:"Running",success:"Succeeded",error:"Failed"}},eei=[{id:"powershell",title:"PowerShell",shell:"PowerShell",cwd:"D:\\Projects\\Vantaloom-ui",status:"idle",initialOutput:"PowerShell 7.6.1\r\nPS D:\\Projects\\Vantaloom-ui> "}];function eeo(e,t,n){return e.getPropertyValue(t).trim()||n}function eel(e,t=!1){let n=getComputedStyle(e),r=eeo(n,"--foreground","#18181b"),a=eeo(n,"--terminal-background",eeo(n,"--background","#ffffff")),i="transparent"===a?eeo(n,"--background","#ffffff"):a,o=eeo(n,"--muted-foreground","#71717a"),l=eeo(n,"--border","#e4e4e7"),s=eeo(n,"--selection","#18181b");return{background:a,foreground:r,cursor:t?"transparent":r,cursorAccent:t?"transparent":i,selectionBackground:`color-mix(in oklch, ${s} 18%, transparent)`,selectionForeground:eeo(n,"--selection-foreground","#ffffff"),scrollbarSliderBackground:`color-mix(in oklch, ${l} 78%, transparent)`,scrollbarSliderHoverBackground:l,black:r,red:eeo(n,"--terminal-red","#bf616a"),green:eeo(n,"--terminal-green","#5e8c61"),yellow:eeo(n,"--terminal-yellow","#b06f3c"),blue:eeo(n,"--terminal-blue","#5e81ac"),magenta:eeo(n,"--terminal-magenta","#b48ead"),cyan:eeo(n,"--terminal-cyan","#4c8da8"),white:a,brightBlack:o,brightRed:eeo(n,"--terminal-bright-red","#d06f79"),brightGreen:eeo(n,"--terminal-bright-green","#6b9a70"),brightYellow:eeo(n,"--terminal-bright-yellow","#c2824b"),brightBlue:eeo(n,"--terminal-bright-blue","#6f91ba"),brightMagenta:eeo(n,"--terminal-bright-magenta","#c19ac0"),brightCyan:eeo(n,"--terminal-bright-cyan","#5aa0b8"),brightWhite:r}}function ees(e){return void 0===e?[]:Array.isArray(e)?e:[e]}function eec({initialOutput:t,data:n,dataKey:r,options:a,readOnly:i=!1,autoFocus:o=!1,localEcho:l=!1,onData:s,onResize:c,onReady:d,labels:u,className:f,terminalClassName:m,...h}){let p=ew.useMemo(()=>({loading:eea.loading,...u}),[u]),g=ew.useRef(null),x=ew.useRef(null),v=ew.useRef(void 0),b=ew.useRef(s),y=ew.useRef(c),w=ew.useRef(d),j=ew.useRef(a),k=ew.useRef(i),N=ew.useRef(l),S=ew.useRef(!1),C=ew.useRef(void 0),M=ew.useRef(!1),[E,I]=ew.useState(!1);return ew.useEffect(()=>{b.current=s,y.current=c,w.current=d,j.current=a,k.current=i,N.current=l},[l,s,d,c,a,i]),ew.useEffect(()=>{let n,r=!1,a=[];!async function(){var i;let l,s,c,d,u;if(!g.current||M.current)return;M.current=!0;let[{Terminal:f},{FitAddon:m},{SearchAddon:h},{WebLinksAddon:p}]=await Promise.all([e.A(93626),e.A(16118),e.A(24306),e.A(46866)]);if(r||!g.current)return;let C=new f({convertEol:!1,cursorBlink:!0,cursorStyle:"block",drawBoldTextInBrightColors:!1,fontFamily:(l=getComputedStyle(i=g.current),u=(c=eeo(l,"--font-family-mono",s='"Cascadia Mono", "Cascadia Code", Consolas, "SFMono-Regular", "Liberation Mono", monospace'),d=getComputedStyle(i),c.replace(/var\((--[a-zA-Z0-9-_]+)(?:,[^)]+)?\)/g,(e,t)=>d.getPropertyValue(t).trim()||"")).trim(),`"Cascadia Mono", "Cascadia Code", Consolas, ${u||s}`),fontSize:13,letterSpacing:0,lineHeight:1.25,macOptionIsMeta:!0,minimumContrastRatio:4.5,scrollback:5e3,theme:eel(g.current),...j.current,allowTransparency:!0}),E=new m,P=new h,O=new p;function z(){try{E.fit(),y.current?.({cols:C.cols,rows:C.rows})}catch{}}for(let e of(C.loadAddon(E),C.loadAddon(P),C.loadAddon(O),C.open(g.current),x.current=C,v.current=E,I(!0),requestAnimationFrame(z),(n=new ResizeObserver(z)).observe(g.current),a.push(C.onData(e=>{k.current||(N.current&&("\r"===e?C.write("\r\n"):""===e?C.write("\b \b"):C.write(e)),b.current?.(e))})),ees(t)))C.write(e);w.current?.({terminal:C,fitAddon:E,searchAddon:P,webLinksAddon:O,fit:z,focus:()=>C.focus(),clear:()=>C.clear(),setCursorSuppressed:function(e){let t=g.current;t&&(S.current=e,t.toggleAttribute("data-vtl-terminal-cursor-suppressed",e),C.options.theme=eel(t,e))},write:(e,t)=>C.write(e,t),writeln:e=>C.writeln(e)}),o&&C.focus()}();let i=new MutationObserver(()=>{let e=x.current,t=g.current;e&&t&&(e.options.theme=eel(t,S.current))});return i.observe(document.documentElement,{attributeFilter:["class","style"],attributes:!0}),()=>{for(let e of(r=!0,i.disconnect(),n?.disconnect(),a))e.dispose();x.current?.dispose(),x.current=null,v.current=void 0,S.current=!1,M.current=!1,I(!1)}},[o,t]),ew.useEffect(()=>{let e=x.current;if(e&&C.current!==r)for(let t of(C.current=r,ees(n)))e.write(t)},[n,r]),(0,eb.jsxs)("div",{"data-slot":"terminal-tab-surface",className:(0,ez.cn)("relative size-full min-h-0 overflow-hidden bg-background text-foreground",f),...h,children:[(0,eb.jsx)("div",{ref:g,className:(0,ez.cn)("vtl-terminal-xterm size-full overflow-hidden p-1.5 font-mono","[&_.xterm]:h-full [&_.xterm]:p-0 [&_.xterm-viewport]:!bg-transparent","[&_.xterm-screen]:!bg-transparent [&_.xterm-helper-textarea]:!outline-none","[&[data-vtl-terminal-cursor-suppressed]_.xterm-cursor]:!opacity-0","[&_.xterm-viewport::-webkit-scrollbar]:w-2.5 [&_.xterm-viewport::-webkit-scrollbar-track]:bg-transparent","[&_.xterm-viewport::-webkit-scrollbar-thumb]:rounded-full [&_.xterm-viewport::-webkit-scrollbar-thumb]:border-[3px]","[&_.xterm-viewport::-webkit-scrollbar-thumb]:border-transparent [&_.xterm-viewport::-webkit-scrollbar-thumb]:bg-border [&_.xterm-viewport::-webkit-scrollbar-thumb]:bg-clip-content",m)}),!E&&(0,eb.jsx)("div",{className:"pointer-events-none absolute inset-0 grid place-items-center text-muted-foreground ui-text-code",children:p.loading})]})}function eed({status:e="idle"}){return"running"===e?(0,eb.jsx)(een,{className:"size-3.5 text-foreground"}):"success"===e?(0,eb.jsx)(eI,{className:"size-3.5 text-foreground"}):"error"===e?(0,eb.jsx)(eE,{className:"size-3.5 text-destructive"}):(0,eb.jsx)(wk,{className:"size-3.5 text-muted-foreground"})}function eeu({session:e}){return e.aiControlled?(0,eb.jsx)(eer,{className:"size-3.5 text-destructive"}):(0,eb.jsx)(eed,{status:e.status})}function eef({sessions:e,defaultSessions:t=eei,activeSessionId:n,defaultActiveSessionId:r,onActiveSessionChange:a,onSessionsChange:i,onCreateSession:o,onCloseSession:l,onSessionData:s,onSessionResize:c,onSessionReady:d,showTabs:u=!0,allowCreateSession:f=!0,readOnly:m=!1,localEcho:h=!1,terminalOptions:p,labels:g,className:x,tabListClassName:v,terminalClassName:b,...y}){let w=ew.useMemo(()=>({...eea,...g,status:{...eea.status,...g?.status}}),[g]),[j,k]=ew.useState(t),N=e??j,S=N[0],[C,M]=ew.useState(r??S?.id),E=n??(N.some(e=>e.id===C)?C:S?.id),I=N.find(e=>e.id===E)??S;function P(t){void 0===e&&k(t),i?.(t)}function O(e){e.disabled||(void 0===n&&M(e.id),a?.(e.id,e))}return(0,eb.jsxs)("div",{"data-slot":"terminal-tab-group",className:(0,ez.cn)("vtl-surface-panel grid min-h-0 overflow-hidden rounded-[var(--surface-panel-radius)] border",u?"grid-rows-[auto_minmax(0,1fr)]":"grid-rows-[minmax(0,1fr)]",x),...y,children:[u&&(0,eb.jsxs)("div",{"data-slot":"terminal-tab-list",role:"tablist","aria-label":w.terminalList,className:(0,ez.cn)("flex min-w-0 items-center gap-1 border-b bg-muted/35 px-2 py-1.5",v),children:[(0,eb.jsx)(u0,{className:"ml-1 size-4 shrink-0 text-muted-foreground"}),(0,eb.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:N.map(e=>{let t=e.id===I?.id;return(0,eb.jsxs)("div",{className:(0,ez.cn)("group flex h-7 min-w-0 shrink-0 items-center rounded-md border border-transparent ui-text-control","transition-colors hover:bg-background/80",t?"bg-background text-foreground shadow-xs":"text-muted-foreground",e.disabled&&"pointer-events-none opacity-50"),children:[(0,eb.jsxs)("button",{type:"button",role:"tab","aria-selected":t,"aria-controls":`terminal-panel-${e.id}`,disabled:e.disabled,onClick:()=>O(e),className:"flex h-full min-w-0 items-center gap-1.5 rounded-md px-2 text-left outline-none focus-visible:ring-[3px] focus-visible:ring-ring/20",children:[(0,eb.jsx)(eeu,{session:e}),(0,eb.jsx)("span",{className:"max-w-36 truncate",children:e.title}),e.shell&&(0,eb.jsx)("span",{className:"hidden text-muted-foreground ui-text-kbd sm:inline",children:e.shell})]}),e.closable&&(0,eb.jsx)("button",{type:"button","aria-label":w.closeTerminal(e.title),onClick:t=>{t.stopPropagation();l?.(e.id,e);let n=N.filter(t=>t.id!==e.id);if(P(n),e.id===E){let e=n.at(-1);e&&O(e)}},className:"mr-1 grid size-4 place-items-center rounded-sm text-muted-foreground opacity-0 outline-none transition-opacity hover:bg-muted hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/20 group-hover:opacity-100",children:(0,eb.jsx)(fV.XIcon,{className:"size-3"})})]},e.id)})}),f&&(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":w.newTerminal,onClick:function(){let e=o?.()??{id:`terminal-${Date.now()}`,title:`Terminal ${N.length+1}`,status:"idle",initialOutput:"",closable:!0};P([...N,e]),O(e)},className:"size-7 shrink-0",children:(0,eb.jsx)(lY,{className:"size-3.5"})})]}),(0,eb.jsx)("div",{"data-slot":"terminal-tab-panels",className:"relative min-h-0 overflow-hidden",children:N.map(e=>{let t=e.id===I?.id;return(0,eb.jsx)(eem,{session:e,selected:t,terminalOptions:p,readOnly:m,localEcho:h,onSessionData:s,onSessionResize:c,onSessionReady:d,labels:w,terminalClassName:b},e.id)})})]})}function eem({session:e,selected:t,terminalOptions:n,readOnly:r,localEcho:a,onSessionData:i,onSessionResize:o,onSessionReady:l,labels:s,terminalClassName:c}){let d=ew.useRef(null),u=ew.useRef(t);return ew.useEffect(()=>{if(t&&!u.current&&d.current){let e=d.current;requestAnimationFrame(()=>{e&&(e.fit(),e.terminal.refresh(0,e.terminal.rows-1),e.terminal.focus())})}u.current=t},[t]),(0,eb.jsx)("div",{id:`terminal-panel-${e.id}`,role:"tabpanel","aria-hidden":!t,"data-active":t,className:"absolute inset-0 min-h-0",style:{display:t?"block":"none"},children:(0,eb.jsx)(eec,{initialOutput:e.initialOutput,options:{...n,...e.options},readOnly:r||e.disabled,localEcho:a,autoFocus:t,onData:t=>i?.(e.id,t),onResize:t=>o?.(e.id,t),onReady:t=>{d.current=t,l?.(e.id,t)},labels:s,terminalClassName:c})})}function eeh({className:e,scopeId:t,state:n,onStateChange:r}){let[a,i]=ew.useState([]),[o,l]=ew.useState([]),[s,c]=ew.useState(),[d,u]=ew.useState("local"),[f,m]=ew.useState(),[h,p]=ew.useState(!1),[g,x]=ew.useState(!1),v=ew.useRef(new Map),b=ew.useRef(new Map),y=ew.useRef(new Map),w=ew.useRef(new Map),j=ew.useRef(new Map),k=ew.useRef(new Map),N=ew.useRef(new Map),S=ew.useRef(new Map),C=ew.useRef(!1),M=ew.useRef(n?.autoStart===!1),E=ew.useRef(n),I=ew.useRef(r),P=Array.isArray(n?.sessionIds)?n.sessionIds.join("\0"):"__all__",O=t?.trim()||void 0,z=O??"__unscoped__";ew.useEffect(()=>{E.current=n},[n]),ew.useEffect(()=>{I.current=r},[r]);let A=a.find(e=>e.id===d)??a[0],T=A?.shells?.find(e=>e.id===f)??A?.shells?.[0],R=ew.useMemo(()=>o.map(e=>e.id),[o]),D=ew.useMemo(()=>o.filter(e=>e.aiControlled).map(e=>e.id),[o]),_=R.join("\0"),L=D.join("\0"),$=ew.useCallback((e,t)=>{let n=b.current.get(e);if(t){let t=j.current.get(e);void 0!==t&&(window.clearTimeout(t),j.current.delete(e))}n?.setCursorSuppressed(t)},[]),F=ew.useCallback(e=>{let t=j.current.get(e);void 0!==t&&window.clearTimeout(t);let n=window.setTimeout(()=>{j.current.delete(e),$(e,!1)},90);j.current.set(e,n)},[$]),B=ew.useCallback(e=>{let t=w.current.get(e),n=b.current.get(e);if(!t||!n||t.writing)return;if(!t.buffer){w.current.delete(e),F(e);return}void 0!==t.drainTimer&&(window.clearTimeout(t.drainTimer),t.drainTimer=void 0);let r=t.buffer.slice(0,65536);t.buffer=t.buffer.slice(r.length),t.writing=!0,$(e,!0);try{n.write(r,()=>{(t.writing=!1,b.current.has(e))?t.buffer?t.drainTimer=window.setTimeout(()=>B(e),0):(w.current.delete(e),F(e)):w.current.delete(e)})}catch{t.writing=!1,w.current.delete(e),F(e)}},[F,$]),V=ew.useCallback((e,t)=>{if(!t)return;if(!b.current.get(e))return void y.current.set(e,`${y.current.get(e)??""}${t}`);let n=w.current.get(e);(n||(n={buffer:"",writing:!1},w.current.set(e,n)),n.buffer+=t,$(e,!0),n.buffer.length>=65536)?B(e):n.writing||void 0!==n.drainTimer||(n.drainTimer=window.setTimeout(()=>B(e),8))},[B,$]),H=ew.useCallback((e,t)=>{(k.current.set(e,t.sequence),"output"===t.type&&t.data)?V(e,t.data):"status"===t.type&&t.status&&l(n=>n.map(n=>n.id===e?{...n,status:t.status??n.status,updatedAt:t.createdAt}:n))},[V]),U=ew.useCallback(e=>{if(v.current.has(e))return;let t=new EventSource(function(e,t=0){let n=new URLSearchParams;t>0&&n.set("after",String(t));let r=n.toString();return(0,eT.localAPIURL)(`/api/local/terminals/sessions/${encodeURIComponent(e)}/events${r?`?${r}`:""}`)}(e,k.current.get(e)??0));t.onmessage=t=>{try{H(e,JSON.parse(t.data))}catch{return}},v.current.set(e,t)},[H]),q=ew.useCallback(async()=>{if(A&&!h){M.current=!1,p(!0);try{let e=await f_({machineId:A.id,scopeId:O,shell:T?.id,cwd:A.defaultCwd,cols:100,rows:30});l(t=>t.some(t=>t.id===e.id)?t:[...t,e]),c(e.id),U(e.id)}catch{return}finally{p(!1)}}},[h,U,A,T,O]);function W(e){let t=N.current.get(e);return t||(t={buffer:"",inFlight:!1},N.current.set(e,t)),t}return ew.useEffect(()=>{let e=!0;return x(!1),async function(){try{let t=E.current,n=t?.sessionIds,r=Array.isArray(n)?new Set(n):void 0,[a,o]=await Promise.all([fR(),fD(O)]);if(!e)return;let s=r?o.sessions.filter(e=>r.has(e.id)):o.sessions;C.current=!1,M.current=t?.autoStart===!1,i(a.machines),l(s),c(e=>{let n=t?.activeSessionId??e;return n&&s.some(e=>e.id===n)?n:s[0]?.id});let d=a.machines[0];if(d){let e=a.machines.find(e=>e.id===t?.selectedMachineId)??d;u(e.id),m(n=>t?.selectedShellId&&e.shells?.some(e=>e.id===t.selectedShellId)?t.selectedShellId:n&&e.shells?.some(e=>e.id===n)?n:e.shells?.[0]?.id)}}finally{e&&x(!0)}}(),()=>{e=!1}},[P,O,z]),ew.useEffect(()=>{g&&I.current?.({sessionIds:R,activeSessionId:s,selectedMachineId:d,selectedShellId:f,autoStart:!M.current,aiControlledSessionIds:D})},[s,D,L,g,d,f,R,_]),ew.useEffect(()=>{let e=new Set(R);for(let e of o)U(e.id);for(let[t,n]of v.current)e.has(t)||(n.close(),v.current.delete(t))},[U,R,o]),ew.useEffect(()=>{!g||C.current||M.current||o.length>0||0===a.length||(C.current=!0,q())},[q,g,a.length,o.length]),ew.useEffect(()=>()=>{for(let e of v.current.values())e.close();for(let e of N.current.values())void 0!==e.timer&&window.clearTimeout(e.timer);for(let e of w.current.values())void 0!==e.drainTimer&&window.clearTimeout(e.drainTimer);for(let[e,t]of j.current)window.clearTimeout(t),$(e,!1);N.current.clear(),w.current.clear(),j.current.clear()},[$]),(0,eb.jsxs)("div",{className:(0,ez.cn)("grid h-full min-h-0 w-full grid-rows-[auto_minmax(0,1fr)] overflow-hidden rounded-[inherit] border bg-card",e),children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5 border-b bg-muted/35 px-2 py-1.5",children:[(0,eb.jsxs)(gU,{value:A?.id,onValueChange:e=>{u(e);let t=a.find(t=>t.id===e);m(t?.shells?.[0]?.id)},children:[(0,eb.jsxs)(xj,{size:"sm",className:"max-w-44",children:[(0,eb.jsx)(b7,{className:"size-3.5"}),(0,eb.jsx)(gG,{placeholder:"机器"})]}),(0,eb.jsx)(xS,{align:"start",children:a.filter(e=>"online"===e.status).map(e=>(0,eb.jsx)(xC,{value:e.id,children:e.name},e.id))})]}),(0,eb.jsxs)(gU,{value:T?.id,onValueChange:m,children:[(0,eb.jsx)(xj,{size:"sm",className:"max-w-44",children:(0,eb.jsx)(gG,{placeholder:"Shell"})}),(0,eb.jsx)(xS,{align:"start",children:A?.shells?.map(e=>(0,eb.jsx)(xC,{value:e.id,children:e.name},e.id))})]}),(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"新建终端",disabled:!A||h,onClick:()=>void q(),className:"ml-auto",children:(0,eb.jsx)(lY,{className:"size-4"})})]}),(0,eb.jsx)(eef,{sessions:o.map(eep),activeSessionId:s,allowCreateSession:!1,localEcho:!1,labels:{loading:"启动终端...",terminalList:"终端会话",closeTerminal:e=>`关闭 ${e}`},onActiveSessionChange:e=>c(e),onCloseSession:e=>{let t,n,r;return v.current.get(e)?.close(),v.current.delete(e),b.current.delete(e),y.current.delete(e),t=w.current.get(e),t?.drainTimer!==void 0&&window.clearTimeout(t.drainTimer),w.current.delete(e),k.current.delete(e),void 0!==(n=j.current.get(e))&&(window.clearTimeout(n),j.current.delete(e)),r=N.current.get(e),void(r?.timer!==void 0&&window.clearTimeout(r.timer),N.current.delete(e),S.current.delete(e),l(t=>{let n=t.filter(t=>t.id!==e);return 0===n.length&&(M.current=!0),c(t=>t&&t!==e&&n.some(e=>e.id===t)?t:n[0]?.id),n}),fL(e).catch(()=>{}))},onSessionData:function(e,t){let n=W(e);n.buffer+=t,function e(t){let n=W(t);n.inFlight||void 0!==n.timer||(n.timer=window.setTimeout(()=>{n.timer=void 0,function(t){let n=N.current.get(t);if(!n||n.inFlight)return;let r=n.buffer;if(n.buffer="",!r){void 0===n.timer&&N.current.delete(t);return}n.inFlight=!0,f$(t,r).catch(()=>{}).finally(()=>{let n=N.current.get(t);n&&(n.inFlight=!1,n.buffer?e(t):void 0===n.timer&&N.current.delete(t))})}(t)},6))}(e)},onSessionResize:function(e,t){let n=`${t.cols}x${t.rows}`;S.current.get(e)!==n&&(S.current.set(e,n),fF(e,t).then(e=>{l(t=>t.map(t=>t.id===e.id?{...t,...e}:t))}).catch(()=>{}))},onSessionReady:function(e,t){b.current.set(e,t);let n=y.current.get(e);n&&(y.current.delete(e),V(e,n))},className:"min-h-0 rounded-none border-0"})]})}function eep(e){return{id:e.id,title:e.title,shell:e.ordinal?`T${e.ordinal}`:"",cwd:e.cwd,status:function(e){switch(e){case"running":return"running";case"exited":case"closed":return"success";case"failed":return"error";default:return"idle"}}(e.status),closable:!0,initialOutput:"",aiControlled:e.aiControlled,controller:e.controller}}function eeg(e,t={}){let n="h-full min-h-0 w-full overflow-hidden rounded-[inherit]";switch(e.kind){case"file-tab-viewer":{let r=fi("file-tab-viewer"),a=e.file;if(!a&&t.onRequestFileTab)return(0,eb.jsx)(qs,{className:n,onChooseFile:t.onRequestFileTab});return(0,eb.jsx)(X$,{className:`${n} border-0`,file:a??r.file,value:e.defaultValue??r.defaultValue??"",defaultValue:e.defaultValue??r.defaultValue,view:e.defaultView,mode:e.defaultMode,modified:e.modified,onValueChange:n=>t.onTabChange?.({...e,defaultValue:n,modified:!0}),onViewChange:n=>t.onTabChange?.({...e,defaultView:n}),onModeChange:n=>t.onTabChange?.({...e,defaultMode:n}),onSave:t.onSaveFileTab?n=>t.onSaveFileTab?.(e,n):void 0,onHistory:()=>t.onOpenFileHistory?.(e),labels:{review:"审阅",edit:"编辑",view:"视图",code:"代码",preview:"预览",hex:"十六进制",actions:"文件菜单",save:"保存",saving:"保存中",history:"历史版本"}})}case"browser-tab-viewer":return(0,eb.jsx)(Y4,{className:`${n} border-0`,defaultUrl:e.defaultUrl??fi("browser-tab-viewer").defaultUrl});case"diff-tab-viewer":{let t=fi("diff-tab-viewer");return(0,eb.jsx)(WU,{className:`${n} border-0`,file:e.file??t.file,diff:e.diff??t.diff??""})}case"data-table-tab-viewer":{let r=fi("data-table-tab-viewer"),a=e.file;if(!a&&t.onRequestFileTab)return(0,eb.jsx)(qs,{className:n,onChooseFile:t.onRequestFileTab});return(0,eb.jsx)(WA,{className:`${n} border-0`,file:{name:a?.name??r.file?.name??"data",path:a?.path??r.file?.path,type:eex(e)},source:void 0!==e.defaultValue?{type:eex(e),content:e.defaultValue}:void 0,data:e.tableData??r.tableData??[]})}case"terminal-tab-group":return(0,eb.jsx)(eeh,{className:`${n} border-0`,scopeId:t.terminalScopeId,state:e.terminal??t.terminalState,onStateChange:t.onTerminalStateChange})}}function eex(e){return`${e.file?.mimeType??""} ${e.file?.path??e.file?.name??""}`.toLowerCase().includes("json")?"json":"csv"}function eev(e,t={}){let n="h-full min-h-0 w-full overflow-hidden rounded-[inherit]";switch(e){case"multi-tab-system":{let e=t.nodeId,r=void 0!==t.tabs?t.tabs:[];return(0,eb.jsx)(XH,{className:n,contentClassName:"min-h-0",tabs:r.map(n=>({id:n.id,title:n.title,meta:n.meta,modified:n.modified,icon:fa(n.kind),content:eeg(n,{terminalScopeId:e?`${t.terminalScopeId??`canvas:node:${e}`}:tab:${n.id}`:t.terminalScopeId,terminalState:n.terminal,onTerminalStateChange:r=>e?t.onTabChange?.(e,{...n,terminal:r}):void 0,onRequestFileTab:()=>t.onRequestFileTab?.({nodeId:e,insertIndex:r.length}),onTabChange:n=>{e&&t.onTabChange?.(e,n)},onSaveFileTab:(n,r)=>e?t.onSaveFileTab?.(e,n,r):void 0,onOpenFileHistory:n=>e?t.onOpenFileHistory?.(e,n):void 0})})),activeTabId:t.activeTabId,detachable:!0,externalDropTypes:[qd],createLabel:"打开文件",emptyContent:(0,eb.jsx)(qs,{onChooseFile:()=>t.onRequestFileTab?.({nodeId:e,insertIndex:r.length})}),onCreateTab:()=>{t.onRequestFileTab?.({nodeId:e,insertIndex:r.length})},onActiveTabChange:n=>{e&&t.onActiveTabChange?.(e,n)},onTabsChange:n=>{if(!e)return;let a=n.map(e=>r.find(t=>t.id===e.id)).filter(e=>!!e);t.onTabsChange?.(e,a)},onTabDetach:(n,a)=>{if(!e)return!1;let i=r.find(e=>e.id===n.id);return!!i&&t.onTabDetach?.(e,i,{clientX:a.clientX,clientY:a.clientY})},onExternalTabDrop:({insertIndex:n,nativeEvent:r})=>{e&&t.onExternalTabDrop?.(e,n,r)}})}case"file-tree-panel":if(t.workspaceFolders)return(0,eb.jsx)(qo,{folders:t.workspaceFolders,className:`${n} max-w-none`,onOpenFile:t.onOpenWorkspaceFile});return(0,eb.jsx)(ZN,{className:`${n} max-w-none`,onOpenFile:t.onOpenWorkspaceFile});case"process-management":return(0,eb.jsx)(Q7,{className:`${n} rounded-[inherit] border-0`});case"machine-performance":return(0,eb.jsx)(Q9,{className:`${n} rounded-[inherit] border-0`});case"firewall-policy-workspace":return(0,eb.jsx)("div",{className:`${n} bg-card`,children:(0,eb.jsx)(Zw,{})});case"machine-file-management":return(0,eb.jsx)(ZJ,{className:`${n} bg-card`});case"agent-conversation-panel":return(0,eb.jsx)(UL,{className:`${n} vtl-canvas-agent-conversation-node`,composerClassName:"max-w-[42rem]"});case"status-monitor":return(0,eb.jsx)(Y$,{conversationId:t.conversationId,ownerMachineId:t.ownerMachineId});case"plan-doc-viewer":return(0,eb.jsx)(Yo,{conversationId:t.conversationId,ownerMachineId:t.ownerMachineId});case"spec-doc-viewer":return(0,eb.jsx)(Yl,{conversationId:t.conversationId,ownerMachineId:t.ownerMachineId});case"tasks-pane":return(0,eb.jsx)(YB,{conversationId:t.conversationId,ownerMachineId:t.ownerMachineId});case"hooks-pane":return(0,eb.jsx)(Yf,{conversationId:t.conversationId,ownerMachineId:t.ownerMachineId});case"sidequery-pane":return(0,eb.jsx)(Yx,{conversationId:t.conversationId,ownerMachineId:t.ownerMachineId,nodeId:t.nodeId,binding:t.sideQueryBinding,onBind:e=>t.nodeId&&t.onSideQueryBind?.(t.nodeId,e)});case"file-tab-viewer":case"browser-tab-viewer":case"diff-tab-viewer":case"data-table-tab-viewer":case"terminal-tab-group":return eeg(t.tab??fi(e,`${e}-tab`),{terminalState:t.terminalState,terminalScopeId:t.terminalScopeId,onTerminalStateChange:t.onTerminalStateChange,onRequestFileTab:()=>t.onRequestFileTab?.({nodeId:t.nodeId}),onTabChange:e=>{t.nodeId&&t.onTabChange?.(t.nodeId,e)},onSaveFileTab:(e,n)=>t.nodeId?t.onSaveFileTab?.(t.nodeId,e,n):void 0,onOpenFileHistory:e=>t.nodeId?t.onOpenFileHistory?.(t.nodeId,e):void 0})}}function eeb({kind:e,...t}){return eev(e,t)}function eey(e){let t=Number.isFinite(e)?Math.max(0,e):0;return t>=1e6?`${(t/1e6).toFixed(t>=1e7?0:1)}M`:t>=1e3?`${Math.round(t/1e3)}K`:t.toLocaleString()}function eew({data:e,className:t}){let n=Math.max(0,e.used),r=Math.max(0,e.total),a=r>0?Math.min(100,Math.round(n/r*100)):0,i=e.categories.filter(e=>e.estTokens>0);return(0,eb.jsxs)("div",{className:(0,ez.cn)("flex size-full min-h-0 flex-col gap-3 overflow-hidden bg-card p-3",t),children:[(0,eb.jsxs)("div",{className:"shrink-0 space-y-1.5",children:[(0,eb.jsxs)("div",{className:"flex items-baseline justify-between text-xs",children:[(0,eb.jsx)("span",{className:"font-medium text-foreground",children:"上下文占用"}),(0,eb.jsxs)("span",{className:"text-muted-foreground",children:[eey(n)," / ",eey(r)," · ",a,"%"]})]}),(0,eb.jsx)("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:(0,eb.jsx)("div",{className:"h-full rounded-full bg-foreground transition-[width]",style:{width:`${a}%`}})}),(0,eb.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"下方明细为按字符数估算(估算),非精确 token 统计。"})]}),i.length>0?(0,eb.jsx)("div",{className:"shrink-0 space-y-1",children:i.map(e=>(0,eb.jsxs)("div",{className:"flex items-center justify-between rounded-md bg-muted/40 px-2 py-1 text-xs",children:[(0,eb.jsx)("span",{className:"text-muted-foreground",children:e.label}),(0,eb.jsxs)("span",{className:"font-medium tabular-nums",children:["约 ",eey(e.estTokens),(0,eb.jsx)("span",{className:"ml-1 text-[10px] text-muted-foreground",children:"估算"})]})]},e.key))}):null,(0,eb.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,eb.jsxs)("div",{className:"flex shrink-0 items-baseline justify-between pb-1 text-xs",children:[(0,eb.jsx)("span",{className:"font-medium text-foreground",children:"上下文中的文件"}),(0,eb.jsxs)("span",{className:"text-muted-foreground",children:[e.files.length," 个"]})]}),(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto rounded-md border",children:0===e.files.length?(0,eb.jsx)("div",{className:"grid h-full place-items-center p-4 text-center text-xs text-muted-foreground",children:"本轮暂无被读取/检索的文件进入上下文。"}):(0,eb.jsx)("ul",{className:"divide-y",children:e.files.map(e=>{let t,n;return(0,eb.jsxs)("li",{className:"flex items-center gap-2 px-2 py-1.5 text-xs",title:e.path,children:[(0,eb.jsx)(uX,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,eb.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eb.jsx)("div",{className:"truncate font-medium text-foreground",children:(t=e.path.replace(/[\\/]+$/,""),n=/([^\\/]+)$/.exec(t),n?.[1]??t)}),(0,eb.jsx)("div",{className:"truncate text-[11px] text-muted-foreground",children:e.path})]}),(0,eb.jsxs)("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:["约 ",eey(e.estTokens),(0,eb.jsx)("span",{className:"ml-1 text-[10px]",children:"估算"})]})]},`${e.machineId??"local"}:${e.path}`)})})})]})]})}let eej="application/vnd.vantaloom.agent-pane-shredder",eek="application/vnd.vantaloom.agent-pane-cutter";function eeN({content:e}){return kA(e)?(0,eb.jsx)("button",{type:"button",draggable:!0,"aria-label":"拖拽到对话框作为附件",title:"拖拽到对话框作为附件",onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),onDragStart:t=>{t.stopPropagation(),t.dataTransfer.setData(qf,qh({kind:e.kind,title:e.title,tab:e.tab})),t.dataTransfer.effectAllowed="copy"},className:"grid size-5 shrink-0 cursor-grab place-items-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground active:cursor-grabbing [&_svg]:size-3.5",children:(0,eb.jsx)(kF,{})}):null}function eeS(e,t){return(e?.activeSessionId??"")===(t.activeSessionId??"")&&(e?.selectedMachineId??"")===(t.selectedMachineId??"")&&(e?.selectedShellId??"")===(t.selectedShellId??"")&&(e?.autoStart??!0)===(t.autoStart??!0)&&(e?.sessionIds??[]).join("\0")===t.sessionIds.join("\0")&&(e?.aiControlledSessionIds??[]).join("\0")===(t.aiControlledSessionIds??[]).join("\0")}let eeC=[{id:"quad",label:"四分",slots:4,icon:(0,eb.jsx)(b8,{})},{id:"vertical-split",label:"上下二分",slots:2,icon:(0,eb.jsx)(qR,{})},{id:"horizontal-split",label:"左右二分",slots:2,icon:(0,eb.jsx)(qE,{})},{id:"left-two-right-one",label:"左二右一",slots:3,icon:(0,eb.jsx)(cy,{})},{id:"left-one-right-two",label:"左一右二",slots:3,icon:(0,eb.jsx)(cj,{})},{id:"top-two-bottom-one",label:"上二下一",slots:3,icon:(0,eb.jsx)(qR,{})},{id:"top-one-bottom-two",label:"上一下二",slots:3,icon:(0,eb.jsx)(qT,{})},{id:"single",label:"整窗口",slots:1,icon:(0,eb.jsx)(qA,{})}];function eeM(e,t,n=[50,50]){let r=e?.[t],a=r?.[0],i=r?.[1];return["number"==typeof a&&a>0?a:n[0],"number"==typeof i&&i>0?i:n[1]]}function eeE(e,t){return{[e[0]]:t[0],[e[1]]:t[1]}}function eeI(e,t){return[e[t[0]]??50,e[t[1]]??50]}function eeP({mode:e,sizes:t,onSizeGroupChange:n,children:r}){if("single"===e)return(0,eb.jsx)("div",{className:"size-full min-h-0",children:r[0]});if("horizontal-split"===e){let e=eeM(t,"outer"),a=["pane-0","pane-1"];return(0,eb.jsxs)(mX,{direction:"horizontal",defaultLayout:eeE(a,e),onLayoutChanged:e=>n?.("outer",eeI(e,a)),children:[(0,eb.jsx)(mY,{id:a[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:a[1],defaultSize:e[1],minSize:24,children:r[1]})]})}if("vertical-split"===e){let e=eeM(t,"outer"),a=["pane-0","pane-1"];return(0,eb.jsxs)(mX,{direction:"vertical",defaultLayout:eeE(a,e),onLayoutChanged:e=>n?.("outer",eeI(e,a)),children:[(0,eb.jsx)(mY,{id:a[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:a[1],defaultSize:e[1],minSize:24,children:r[1]})]})}if("left-two-right-one"===e){let e=eeM(t,"outer",[58,42]),a=eeM(t,"left"),i=["left","right"],o=["pane-0","pane-1"];return(0,eb.jsxs)(mX,{direction:"horizontal",defaultLayout:eeE(i,e),onLayoutChanged:e=>n?.("outer",eeI(e,i)),children:[(0,eb.jsx)(mY,{id:i[0],defaultSize:e[0],minSize:24,children:(0,eb.jsxs)(mX,{direction:"vertical",defaultLayout:eeE(o,a),onLayoutChanged:e=>n?.("left",eeI(e,o)),children:[(0,eb.jsx)(mY,{id:o[0],defaultSize:a[0],minSize:20,children:r[0]}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:o[1],defaultSize:a[1],minSize:20,children:r[1]})]})}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:i[1],defaultSize:e[1],minSize:24,children:r[2]})]})}if("left-one-right-two"===e){let e=eeM(t,"outer",[42,58]),a=eeM(t,"right"),i=["left","right"],o=["pane-1","pane-2"];return(0,eb.jsxs)(mX,{direction:"horizontal",defaultLayout:eeE(i,e),onLayoutChanged:e=>n?.("outer",eeI(e,i)),children:[(0,eb.jsx)(mY,{id:i[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:i[1],defaultSize:e[1],minSize:24,children:(0,eb.jsxs)(mX,{direction:"vertical",defaultLayout:eeE(o,a),onLayoutChanged:e=>n?.("right",eeI(e,o)),children:[(0,eb.jsx)(mY,{id:o[0],defaultSize:a[0],minSize:20,children:r[1]}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:o[1],defaultSize:a[1],minSize:20,children:r[2]})]})})]})}if("top-two-bottom-one"===e){let e=eeM(t,"outer",[58,42]),a=eeM(t,"top"),i=["top","bottom"],o=["pane-0","pane-1"];return(0,eb.jsxs)(mX,{direction:"vertical",defaultLayout:eeE(i,e),onLayoutChanged:e=>n?.("outer",eeI(e,i)),children:[(0,eb.jsx)(mY,{id:i[0],defaultSize:e[0],minSize:24,children:(0,eb.jsxs)(mX,{direction:"horizontal",defaultLayout:eeE(o,a),onLayoutChanged:e=>n?.("top",eeI(e,o)),children:[(0,eb.jsx)(mY,{id:o[0],defaultSize:a[0],minSize:24,children:r[0]}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:o[1],defaultSize:a[1],minSize:24,children:r[1]})]})}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:i[1],defaultSize:e[1],minSize:24,children:r[2]})]})}if("top-one-bottom-two"===e){let e=eeM(t,"outer",[42,58]),a=eeM(t,"bottom"),i=["top","bottom"],o=["pane-1","pane-2"];return(0,eb.jsxs)(mX,{direction:"vertical",defaultLayout:eeE(i,e),onLayoutChanged:e=>n?.("outer",eeI(e,i)),children:[(0,eb.jsx)(mY,{id:i[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:i[1],defaultSize:e[1],minSize:24,children:(0,eb.jsxs)(mX,{direction:"horizontal",defaultLayout:eeE(o,a),onLayoutChanged:e=>n?.("bottom",eeI(e,o)),children:[(0,eb.jsx)(mY,{id:o[0],defaultSize:a[0],minSize:24,children:r[1]}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:o[1],defaultSize:a[1],minSize:24,children:r[2]})]})})]})}let a=eeM(t,"outer"),i=eeM(t,"left"),o=eeM(t,"right"),l=["left","right"],s=["pane-0","pane-2"],c=["pane-1","pane-3"];return(0,eb.jsxs)(mX,{direction:"horizontal",defaultLayout:eeE(l,a),onLayoutChanged:e=>n?.("outer",eeI(e,l)),children:[(0,eb.jsx)(mY,{id:l[0],defaultSize:a[0],minSize:24,children:(0,eb.jsxs)(mX,{direction:"vertical",defaultLayout:eeE(s,i),onLayoutChanged:e=>n?.("left",eeI(e,s)),children:[(0,eb.jsx)(mY,{id:s[0],defaultSize:i[0],minSize:20,children:r[0]}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:s[1],defaultSize:i[1],minSize:20,children:r[2]})]})}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:l[1],defaultSize:a[1],minSize:24,children:(0,eb.jsxs)(mX,{direction:"vertical",defaultLayout:eeE(c,o),onLayoutChanged:e=>n?.("right",eeI(e,c)),children:[(0,eb.jsx)(mY,{id:c[0],defaultSize:o[0],minSize:20,children:r[1]}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:c[1],defaultSize:o[1],minSize:20,children:r[3]})]})})]})}function eeO({conversationId:e,ownerMachineId:t,index:n,content:r,clipboardItems:a,clipboardDraggingId:i,onAdd:o,onPanelDrop:l,onContentChange:s,onClear:c,onCut:d,workspaceFolders:u,onRequestFileTab:f,onOpenWorkspaceFile:m,onSaveFileTab:h,onOpenFileHistory:p}){let[g,x]=ew.useState();return(0,eb.jsx)("div",{"data-agent-pane":n,className:(0,ez.cn)("relative size-full min-h-0 min-w-0 overflow-hidden",r?.kind!=="subagent-conversation-panel"&&"bg-background","vtl-agent-workspace-pane",r?.kind==="subagent-conversation-panel"&&"vtl-agent-workspace-conversation-pane bg-transparent","panel"===g&&"ring-2 ring-foreground/60 ring-inset","shredder"===g&&"ring-2 ring-destructive/70 ring-inset","cutter"===g&&"ring-2 ring-amber-500/70 ring-inset"),onDragOver:e=>{let t=Array.from(e.dataTransfer.types);if(t.includes(eek)){e.preventDefault(),e.dataTransfer.dropEffect="move",x("cutter");return}if(t.includes(eej)){e.preventDefault(),e.dataTransfer.dropEffect="move",x("shredder");return}t.includes(kT)&&(e.preventDefault(),e.dataTransfer.dropEffect="move",x("panel"))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||x(void 0)},onDrop:e=>{if(Array.from(e.dataTransfer.types).includes(eek)){e.preventDefault(),e.stopPropagation(),x(void 0),d(n);return}if(Array.from(e.dataTransfer.types).includes(eej)){e.preventDefault(),e.stopPropagation(),x(void 0),c(n);return}let t=function(e){let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id"),n=a.find(e=>e.id===t),r=n?n.payloads?.[kT]:void 0;if(n&&r)return{item:n,content:r.content};let i=e.dataTransfer.getData(kT);if(i)try{let e=JSON.parse(i);return n&&e.content?{item:n,content:e.content}:void 0}catch{return}}(e);t&&(e.preventDefault(),e.stopPropagation(),x(void 0),l(n,t.item,t.content))},children:r?(0,eb.jsx)("div",{className:(0,ez.cn)("size-full min-h-0 min-w-0 overflow-hidden rounded-none","vtl-agent-pane-content","subagent-conversation-panel"===r.kind&&"vtl-agent-pane-conversation-content",i&&"pointer-events-none"),children:kA(r)?eev(r.kind,{tab:r.tab,conversationId:e,ownerMachineId:t,terminalScopeId:e?`agent:${e}:pane:${r.id}`:void 0,terminalState:r.terminal,onTerminalStateChange:e=>{eeS(r.terminal,e)||s(n,{...r,terminal:e})},workspaceFolders:u,nodeId:r.id,tabs:r.tabs,activeTabId:r.activeTabId,sideQueryBinding:r.sideQuery,onSideQueryBind:(e,t)=>s(n,{...r,sideQuery:t}),onRequestFileTab:({insertIndex:e})=>f?.(n,e),onOpenWorkspaceFile:m,onTabsChange:(e,t)=>{s(n,{...r,tabs:t,activeTabId:t.some(e=>e.id===r.activeTabId)?r.activeTabId:t[0]?.id})},onTabChange:(e,t)=>{"multi-tab-system"===r.kind?s(n,{...r,tabs:(r.tabs??[]).map(e=>e.id===t.id?t:e),activeTabId:t.id}):s(n,{...r,title:t.title,tab:t})},onSaveFileTab:(e,t,r)=>h?.(n,t,r),onOpenFileHistory:(e,t)=>p?.(n,t),onActiveTabChange:(e,t)=>{s(n,{...r,activeTabId:t})}}):"context-breakdown"===r.kind?(0,eb.jsx)(eew,{data:r.data}):(0,eb.jsx)(UL,{className:"size-full min-h-0",composerClassName:"max-w-[42.5rem]",initialEvents:r.events},r.id)},r.id):(0,eb.jsx)("div",{className:"vtl-agent-pane-empty grid size-full place-items-center p-4",children:(0,eb.jsxs)(eO.Button,{type:"button",variant:"outline",size:"sm",className:"rounded-full bg-background/90",onClick:o,"data-tour":"pane-add",children:[(0,eb.jsx)(lY,{className:"size-4"}),"添加"]})})})}function eez({open:e,onOpenChange:t,onAdd:n}){let r=eeT.map(e=>kO(e.kind)).filter(e=>!!e);return(0,eb.jsx)(bm,{open:e,onOpenChange:t,title:"添加工作区组件",description:"选择一个组件填入当前窗口。",className:"top-1/2 max-w-xl -translate-y-1/2",children:(0,eb.jsxs)(bf,{loop:!0,children:[(0,eb.jsx)(bh,{placeholder:"搜索组件..."}),(0,eb.jsxs)(bp,{children:[(0,eb.jsx)(bg,{children:"没有匹配组件。"}),(0,eb.jsx)(bx,{heading:"可放入窗口",children:r.map(e=>(0,eb.jsxs)(bv,{"data-tour":`pane-template-${e.id}`,value:`${e.title} ${e.description} ${e.keywords}`,onSelect:()=>n(e.id),children:[(0,eb.jsx)("span",{className:"grid size-8 shrink-0 place-items-center rounded-lg border bg-background text-muted-foreground",children:e.icon}),(0,eb.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,eb.jsx)("span",{className:"block truncate text-sm font-medium",children:e.title}),(0,eb.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,eb.jsx)(bb,{children:"添加"})]},e.id))})]})]})})}function eeA({content:e,index:t,conversationId:n,ownerMachineId:r,workspaceFolders:a,onContentChange:i,onOpenWorkspaceFile:o,onSaveFileTab:l,onOpenFileHistory:s,onRequestFileTab:c}){return"context-breakdown"===e.kind?(0,eb.jsx)(eew,{data:e.data}):kA(e)?eev(e.kind,{tab:e.tab,conversationId:n,ownerMachineId:r,terminalScopeId:n?`agent:${n}:pane:${e.id}`:void 0,terminalState:e.terminal,onTerminalStateChange:n=>{eeS(e.terminal,n)||i(t,{...e,terminal:n})},workspaceFolders:a,nodeId:e.id,tabs:e.tabs,activeTabId:e.activeTabId,sideQueryBinding:e.sideQuery,onSideQueryBind:(n,r)=>i(t,{...e,sideQuery:r}),onRequestFileTab:({insertIndex:e})=>c?.(t,e),onOpenWorkspaceFile:o,onTabsChange:(n,r)=>{i(t,{...e,tabs:r,activeTabId:r.some(t=>t.id===e.activeTabId)?e.activeTabId:r[0]?.id})},onTabChange:(n,r)=>{"multi-tab-system"===e.kind?i(t,{...e,tabs:(e.tabs??[]).map(e=>e.id===r.id?r:e),activeTabId:r.id}):i(t,{...e,title:r.title,tab:r})},onSaveFileTab:(e,n,r)=>l?.(t,n,r),onOpenFileHistory:(e,n)=>s?.(t,n),onActiveTabChange:(n,r)=>{i(t,{...e,activeTabId:r})}}):(0,eb.jsx)(UL,{className:"size-full min-h-0",composerClassName:"max-w-[42.5rem]",initialEvents:e.events},e.id)}let eeT=[{kind:"status-monitor",label:"状态监控",icon:(0,eb.jsx)(uV,{})},{kind:"sidequery-pane",label:"旁问",icon:(0,eb.jsx)(uJ,{})},{kind:"hooks-pane",label:"Hook",icon:(0,eb.jsx)(u2,{})},{kind:"plan-doc-viewer",label:"计划文档",icon:(0,eb.jsx)(uq,{})},{kind:"spec-doc-viewer",label:"规范文档",icon:(0,eb.jsx)(qP,{})},{kind:"browser-tab-viewer",label:"预览窗口",icon:(0,eb.jsx)(qz,{})},{kind:"diff-tab-viewer",label:"Diff 栏",icon:(0,eb.jsx)(qI,{})},{kind:"terminal-tab-group",label:"终端窗口",icon:(0,eb.jsx)(u0,{})},{kind:"file-tree-panel",label:"文件树",icon:(0,eb.jsx)(qO,{})},{kind:"file-tab-viewer",label:"文件窗口",icon:(0,eb.jsx)(uX,{})}];function eeR(e,t,n){return Math.min(n,Math.max(t,e))}function eeD({onAddCard:e,align:t="end"}){return(0,eb.jsxs)(wA,{children:[(0,eb.jsx)(wR,{asChild:!0,children:(0,eb.jsxs)(eO.Button,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",children:[(0,eb.jsx)(lY,{className:"size-4"}),"添加窗口",(0,eb.jsx)(pt,{className:"size-3.5 text-muted-foreground"})]})}),(0,eb.jsx)(wG,{align:t,sideOffset:6,className:"min-w-40",children:eeT.map(t=>(0,eb.jsxs)(wX,{onSelect:()=>e(t.kind),children:[t.icon,(0,eb.jsx)("span",{className:"flex-1",children:t.label})]},t.kind))})]})}function ee_({conversationId:e,ownerMachineId:t,panes:n,agentSide:r,columns:a,heights:i,onColumnsChange:o,onHeightsChange:l,onAddCard:s,onContentChange:c,onClear:d,workspaceFolders:u,onOpenWorkspaceFile:f,onSaveFileTab:m,onOpenFileHistory:h,onRequestFileTab:p}){let g=n.map((e,t)=>({content:e,index:t})).filter(e=>!!e.content),x=new Map(g.map(e=>[e.content.id,e])),v=g.map(e=>e.content.id).join("|"),b="left"===r,y=ew.useRef(0);0===y.current&&a.length>0&&(y.current=a.reduce((e,t)=>{let n=/^col-(\d+)/.exec(t.key);return n?Math.max(e,Number(n[1])):e},0));let w=ew.useCallback(()=>`col-${y.current+=1}`,[]),j=e=>o("function"==typeof e?e(a):e),k=e=>l("function"==typeof e?e(i):e),[N,S]=ew.useState(null),[C,M]=ew.useState(null),[E,I]=ew.useState(null),P=ew.useRef(null),O=ew.useRef(null),z=ew.useRef(null),A=ew.useRef(null);ew.useEffect(()=>{let e={};j(t=>{let n=new Set(g.map(e=>e.content.id)),r=t.map(e=>({...e,cardIds:e.cardIds.filter(e=>n.has(e))})).filter(e=>e.cardIds.length>0),a=new Set(r.flatMap(e=>e.cardIds)),o=g.map(e=>e.content.id).filter(e=>!a.has(e));if(o.length>0){r=r.map(e=>({...e,cardIds:[...e.cardIds]}));let t=P.current?.clientHeight??0,n=t=>t.cardIds.reduce((t,n,r)=>t+(e[n]??i[n]??320)+12*(r>0),0);for(let a of o){let i=!1;if(t>0)for(let o of r){let r=12*(o.cardIds.length>0),l=t-n(o)-r;if(l>=320){o.cardIds.push(a),i=!0;break}if(l>=140){o.cardIds.push(a),e[a]=Math.floor(l),i=!0;break}}i||(0===r.length||t>0?r.push({key:w(),width:360,cardIds:[a]}):r[0].cardIds.push(a))}}return!function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],a=t[n];if(!r||!a||r.key!==a.key||r.width!==a.width||r.cardIds.length!==a.cardIds.length)return!1;for(let e=0;e<r.cardIds.length;e+=1)if(r.cardIds[e]!==a.cardIds[e])return!1}return!0}(t,r)?r:t}),Object.keys(e).length>0&&k(t=>({...t,...e}))},[v,w]);let T=e=>i[e]??320;ew.useEffect(()=>{if(!N)return;let e=e=>{O.current?function(e,t){let n=P.current,r=O.current;if(!n||!r)return;let a=Array.from(n.querySelectorAll("[data-card-id]")),i=null,o=null,l=1/0;for(let n of a){let a=n.dataset.cardId;if(!a||a===r)continue;let s=n.getBoundingClientRect(),c=Math.max(s.left-e,0,e-s.right),d=Math.max(s.top-t,0,t-s.bottom),u=c*c+d*d;u<l&&(l=u,i=a,o=s)}if(!i||!o){z.current=null,I(null);return}let s=e-o.left,c=o.right-e,d=t-o.top,u=o.bottom-t,f=Math.min(s,c,d,u),m=f===d?"top":f===u?"bottom":f===s?"left":"right";z.current={id:i,edge:m};let h=n.getBoundingClientRect();I(function(e,t){switch(t){case"top":return{left:e.left,top:e.top-6-2,width:e.width,height:4};case"bottom":return{left:e.left,top:e.top+e.height+6-2,width:e.width,height:4};case"left":return{left:e.left-6-2,top:e.top,width:4,height:e.height};case"right":return{left:e.left+e.width+6-2,top:e.top,width:4,height:e.height}}}({left:o.left-h.left,top:o.top-h.top,width:o.width,height:o.height},m))}(e.clientX,e.clientY):A.current&&function(e,t){let n=A.current;if(!n)return;if("width"===n.kind){let t=eeR(n.startWidth+(e-n.startX)*n.factor,240,760);j(e=>e.map(e=>e.key===n.columnKey?{...e,width:t}:e));return}if("growHeight"===n.kind){let e=Math.max(140,n.h0+(t-n.startY));k(t=>({...t,[n.cardId]:e}));return}let r=n.hA+n.hB,a=eeR(n.hA+(t-n.startY),140,r-140);k(e=>({...e,[n.aboveId]:a,[n.belowId]:r-a}))}(e.clientX,e.clientY)},t=()=>(function(){let e=O.current;if(e){var t,n;let r=z.current;O.current=null,z.current=null,M(null),I(null),S(null),r&&(t=r.id,n=r.edge,e&&e!==t&&j(r=>{let a=r.map(e=>({...e,cardIds:[...e.cardIds]}));for(let t of a){let n=t.cardIds.indexOf(e);n>=0&&t.cardIds.splice(n,1)}let i=-1,o=-1;a.forEach((e,n)=>{let r=e.cardIds.indexOf(t);r>=0&&(i=n,o=r)});let l=a[i];if(!l)return r;if("top"===n||"bottom"===n)l.cardIds.splice("top"===n?o:o+1,0,e);else{let t=(b?"right"===n:"left"===n)?i:i+1;a.splice(t,0,{key:w(),width:a[i]?.width??360,cardIds:[e]})}return a.filter(e=>e.cardIds.length>0)}));return}A.current&&(A.current=null,S(null))})();return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),window.addEventListener("pointercancel",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t),window.removeEventListener("pointercancel",t)}},[N]);let R=a.map((e,t)=>({column:e,realIndex:t}));b&&R.reverse();let D=(0,eb.jsx)("div",{className:(0,ez.cn)("flex shrink-0 px-3 py-2",b?"justify-end":"justify-start"),children:(0,eb.jsx)(eeD,{onAddCard:s,align:b?"end":"start"})});return 0===g.length?null:(0,eb.jsxs)("div",{className:"relative flex h-full min-h-0 flex-col",children:[D,(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-auto px-3 pb-3",children:(0,eb.jsxs)("div",{ref:P,className:"relative flex min-h-full items-start gap-3",children:[R.map(({column:n})=>{let r=[],i=0;for(let e=0;e<n.cardIds.length;e+=1)i+=T(n.cardIds[e]),e<n.cardIds.length-1&&(r.push(i+6),i+=12);let o=i,l=n.cardIds[n.cardIds.length-1],s=1===n.cardIds.length&&x.get(n.cardIds[0])?.content.kind==="status-monitor";return(0,eb.jsxs)("div",{className:(0,ez.cn)("relative flex shrink-0 flex-col gap-3",s&&"h-full"),style:{width:n.width},children:[n.cardIds.map(n=>{let r=x.get(n);if(!r)return null;let{content:a,index:i}=r;return(0,eb.jsxs)("div",{"data-card-id":a.id,style:s?void 0:{height:T(a.id)},className:(0,ez.cn)("group/card relative flex w-full flex-col overflow-hidden rounded-xl border border-border bg-background shadow-sm",s?"min-h-0 flex-1":"shrink-0",C===a.id?"opacity-40":"opacity-100"),children:[(0,eb.jsxs)("div",{onPointerDown:e=>{var t;return t=a.id,void(0===e.button&&(e.preventDefault(),e.stopPropagation(),O.current=t,z.current=null,M(t),I(null),S("drag")))},className:"flex shrink-0 cursor-grab touch-none select-none items-center justify-between gap-2 border-b border-border/60 px-2.5 py-1.5 active:cursor-grabbing",children:[(0,eb.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[(0,eb.jsx)(fX,{className:"size-3.5 shrink-0 text-muted-foreground/60"}),(0,eb.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:a.title})]}),(0,eb.jsxs)("span",{className:"flex shrink-0 items-center gap-1",children:[(0,eb.jsx)(eeN,{content:a}),(0,eb.jsx)("button",{type:"button",onPointerDown:e=>e.stopPropagation(),onClick:()=>d(i),"aria-label":"关闭窗口",title:"关闭窗口",className:"grid size-5 shrink-0 place-items-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-3.5",children:(0,eb.jsx)(fV.XIcon,{})})]})]}),(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden",children:(0,eb.jsx)(eeA,{content:a,index:i,conversationId:e,ownerMachineId:t,workspaceFolders:u,onContentChange:c,onOpenWorkspaceFile:f,onSaveFileTab:m,onOpenFileHistory:h,onRequestFileTab:p})})]},a.id)}),n.cardIds.slice(0,-1).map((e,t)=>(0,eb.jsx)("div",{"aria-hidden":!0,onPointerDown:r=>{var a;return a=n.cardIds[t+1],void(0===r.button&&(r.preventDefault(),r.stopPropagation(),A.current={kind:"height",aboveId:e,belowId:a,startY:r.clientY,hA:T(e),hB:T(a)},S("resize")))},style:{top:r[t]??0},className:"group/hbar absolute inset-x-0 z-10 flex h-3 -translate-y-1/2 cursor-ns-resize items-center justify-center",children:(0,eb.jsx)("span",{className:"h-1 w-12 rounded-full bg-muted-foreground/40 opacity-0 transition-opacity group-hover/hbar:opacity-100"})},`hbar-${e}`)),l&&!s?(0,eb.jsx)("div",{"aria-hidden":!0,onPointerDown:e=>{0===e.button&&(e.preventDefault(),e.stopPropagation(),A.current={kind:"growHeight",cardId:l,startY:e.clientY,h0:T(l)},S("resize"))},style:{top:o+6},className:"group/hbar absolute inset-x-0 z-10 flex h-3 -translate-y-1/2 cursor-ns-resize items-center justify-center",children:(0,eb.jsx)("span",{className:"h-1 w-12 rounded-full bg-muted-foreground/40 opacity-0 transition-opacity group-hover/hbar:opacity-100"})}):null,(0,eb.jsx)("div",{"aria-hidden":!0,onPointerDown:e=>(function(e,t){if(0!==t.button)return;t.preventDefault(),t.stopPropagation();let n=a.find(t=>t.key===e)?.width??360;A.current={kind:"width",columnKey:e,startX:t.clientX,startWidth:n,factor:b?-1:1},S("resize")})(n.key,e),style:b?{left:-6}:{right:-6},className:(0,ez.cn)("group/wbar absolute inset-y-0 z-10 flex w-3 cursor-ew-resize items-center justify-center",b?"-translate-x-1/2":"translate-x-1/2"),children:(0,eb.jsx)("span",{className:"h-12 w-1 rounded-full bg-muted-foreground/40 opacity-0 transition-opacity group-hover/wbar:opacity-100"})})]},n.key)}),E?(0,eb.jsx)("div",{"aria-hidden":!0,className:"pointer-events-none absolute z-40 rounded-full bg-muted-foreground/70",style:{left:E.left,top:E.top,width:E.width,height:E.height}}):null]})}),N?(0,eb.jsx)("div",{"aria-hidden":!0,className:"absolute inset-0 z-50",style:{cursor:"drag"===N?"grabbing":A.current?.kind==="width"?"ew-resize":"ns-resize"}}):null]})}let eeL="vtl:workspace-layout-mode",ee$="vtl:workspace-agent-side",eeF="vtl:workspace-layout-changed",eeB={mode:"pane",agentSide:"left"};function eeV(){let e=eeB.mode,t=eeB.agentSide;try{let n=window.localStorage.getItem(eeL);("pane"===n||"card"===n||"control-room"===n)&&(e=n);let r=window.localStorage.getItem(ee$);("left"===r||"right"===r)&&(t=r)}catch{}return{mode:e,agentSide:t}}function eeH(e){try{e.mode&&window.localStorage.setItem(eeL,e.mode),e.agentSide&&window.localStorage.setItem(ee$,e.agentSide)}catch{}window.dispatchEvent(new CustomEvent(eeF))}function eeU({stack:e,rootTitle:t,rootOwnerMachineId:n,onNavigateRoot:r,onNavigateIndex:a,onOpenSubagent:i}){let o=e[e.length-1],[l,s]=ew.useState(null);ew.useEffect(()=>{let e;if(!o)return;let t=!1;async function r(){try{let a=await sD(o.id,n);if(t)return;s(a);let i="working"===a.conversation.status||!!a.conversation.running;e=window.setTimeout(r,i?900:5e3)}catch{if(t)return;e=window.setTimeout(r,3e3)}}return s(null),r(),()=>{t=!0,e&&window.clearTimeout(e)}},[o,n]);let[c,d]=ew.useState(!1),u=ew.useRef(!1),f=o?.id,m=l?.conversation.status??"working",h="working"===m||!!l?.conversation.running;ew.useEffect(()=>{d(!1),u.current=!1},[f]);let p=ew.useCallback(e=>{let t=0===e.trim().length;f&&(t||u.current||!h?t&&u.current&&(u.current=!1,cu(f,n)):(u.current=!0,cd(f,n)))},[f,n,h]),g=ew.useCallback(async e=>{let t=e.trim();if(f&&t&&!c){d(!0);try{await cc(f,t,n),u.current=!1}catch{}finally{d(!1)}}},[f,n,c]);return o?(0,eb.jsxs)("div",{className:"absolute inset-0 z-30 flex flex-col bg-background",children:[(0,eb.jsxs)("div",{className:"flex h-9 shrink-0 items-center gap-1 overflow-x-auto border-b px-2 text-xs",children:[(0,eb.jsx)("button",{type:"button",className:"shrink-0 rounded px-1.5 py-0.5 text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",onClick:r,children:t||"主对话"}),e.map((t,n)=>{let r=Uh(t.subagentType),i=n===e.length-1,o=r.Icon;return(0,eb.jsxs)(ew.Fragment,{children:[(0,eb.jsx)(h7,{className:"size-3 shrink-0 text-muted-foreground/60"}),(0,eb.jsxs)("button",{type:"button",className:(0,ez.cn)("flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 transition-colors hover:bg-accent/50",i?"font-medium text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>a(n),children:[(0,eb.jsx)(o,{className:(0,ez.cn)("size-3",r.color)}),(0,eb.jsx)("span",{className:"max-w-[10rem] truncate",children:t.name||`${r.label}子代理`})]})]},t.id)}),(0,eb.jsx)("span",{className:"ml-auto shrink-0 pl-2",children:h?(0,eb.jsxs)("span",{className:"flex items-center gap-1 text-muted-foreground",children:[(0,eb.jsx)(eM,{className:"size-3 animate-spin"}),"运行中"]}):"paused"===m?(0,eb.jsxs)("span",{className:"flex items-center gap-1 text-destructive",children:[(0,eb.jsx)(m0,{className:"size-3"}),"已暂停"]}):(0,eb.jsxs)("span",{className:"flex items-center gap-1 text-emerald-600 dark:text-emerald-500",children:[(0,eb.jsx)(eI,{className:"size-3"}),"完成"]})})]}),(0,eb.jsxs)("div",{className:"relative min-h-0 flex-1",children:[(0,eb.jsx)(UL,{className:"size-full min-h-0",composerClassName:"max-w-[42.5rem]",composerPlaceholder:h?"向该子代理插话(开始输入会暂停它)…":"向该子代理插话…",events:l?.events??[],running:h||c,disabled:!f,hideComposerOptions:!0,onOpenSubagent:e=>i(e),onComposerValueChange:p,onSubmit:e=>void g(e.value)}),l?null:(0,eb.jsx)("div",{className:"absolute inset-0 grid place-items-center bg-background text-sm text-muted-foreground",children:(0,eb.jsxs)("span",{className:"flex items-center gap-2",children:[(0,eb.jsx)(eM,{className:"size-4 animate-spin"}),"正在打开子代理对话…"]})})]})]}):null}let eeq=[],eeW="vantaloom:file-system-changed",eeK=[{id:"",label:"默认"},{id:"low",label:"低"},{id:"medium",label:"中"},{id:"high",label:"高"},{id:"xhigh",label:"极高"}];function eeG(e,t){let n;if(0===t.length)return e;let r=new Map;for(let t=0;t<e.length;t+=1){let n=e[t]?.id;n&&r.set(n,t)}for(let a of t){let t=a?.id,i=t?r.get(t):void 0;if(void 0!==i){if(e[i]===a)continue;n||(n=e.slice()),n[i]=a}else n||(n=e.slice()),t&&r.set(t,n.length),n.push(a)}return n??e}function eeX(e,t){if(0===e.length)return t;let n=new Set;for(let e of t)e?.id&&n.add(e.id);let r=e.filter(e=>e?.id&&!n.has(e.id));return 0===r.length?t:[...r,...t]}function eeY(e){var t;let n=(t=e?.layoutMode,eeC.some(e=>e.id===t)?t:"quad"),r="right"===e?.agentPosition?"right":"left",a=function(e){if(!e||"object"!=typeof e||Array.isArray(e))return{};let t=e.shell&&"object"==typeof e.shell&&!Array.isArray(e.shell)?e.shell:void 0,n={};for(let e of["agent","panes"]){let r=t?.[e];"number"==typeof r&&Number.isFinite(r)&&r>0&&(n[e]=r)}return{...Object.keys(n).length?{shell:n}:{},outer:eeZ(e.outer),left:eeZ(e.left),right:eeZ(e.right),top:eeZ(e.top),bottom:eeZ(e.bottom)}}(e?.sizes),i=Array.from({length:Math.max(4,eeC.find(e=>e.id===n)?.slots??4)},()=>void 0);for(let[t,n]of(e?.panes??[]).entries()){let e=Number.isInteger(n.slot)?n.slot:t;e<0||e>=i.length||(i[e]=function(e,t){var n,r;let a=e.paneId||`${e.kind}-${t+1}`,i=!(n=e.props)||"object"!=typeof n||Array.isArray(n)?{}:n;if("subagent-conversation-panel"===e.kind)return{id:a,kind:"subagent-conversation-panel",title:ee0(i.title)??"Subagent",subagentId:ee0(i.subagentId)??a,events:Array.isArray(i.events)?i.events:[]};if(!kO(e.kind))return;let o=i.tab&&"object"==typeof i.tab?i.tab:void 0,l=Array.isArray(i.tabs)?i.tabs.filter(e=>fr(e?.kind)):void 0,s=kO(e.kind);return{id:a,kind:e.kind,title:ee0(i.title)??o?.title??s?.title??"组件",tab:o,tabs:l,activeTabId:ee0(i.activeTabId),terminal:"terminal-tab-group"===e.kind?!(r=i.terminal)||"object"!=typeof r||Array.isArray(r)?{sessionIds:[]}:{sessionIds:Array.isArray(r.sessionIds)?r.sessionIds.filter(e=>"string"==typeof e):[],activeSessionId:ee0(r.activeSessionId),selectedMachineId:ee0(r.selectedMachineId),selectedShellId:ee0(r.selectedShellId),autoStart:"boolean"==typeof r.autoStart?r.autoStart:void 0,aiControlledSessionIds:Array.isArray(r.aiControlledSessionIds)?r.aiControlledSessionIds.filter(e=>"string"==typeof e):void 0}:void 0}}(n,t))}return{layoutMode:n,agentPosition:r,layoutSizes:a,panes:i,cardColumns:Array.isArray(e?.cardLayout?.columns)?e.cardLayout.columns.filter(e=>e&&"string"==typeof e.key&&Array.isArray(e.cardIds)).map(e=>({key:e.key,width:"number"==typeof e.width&&e.width>0?e.width:360,cardIds:e.cardIds.filter(e=>"string"==typeof e)})):[],cardHeights:e?.cardLayout?.heights&&"object"==typeof e.cardLayout.heights?e.cardLayout.heights:{}}}function eeZ(e){if(!Array.isArray(e))return;let t=e.filter(e=>"number"==typeof e&&Number.isFinite(e)&&e>0);return t.length?t:void 0}function eeJ(e){return e.filter(e=>"number"==typeof e&&Number.isFinite(e)&&e>0)}function eeQ(e){return e>0?Math.max(1,Math.round(e/4)):0}function ee0(e){return"string"==typeof e&&e.trim()?e:void 0}function ee1(e){let t=e?.id.match(/-(\d+)$/);return t?Number(t[1]):0}function ee2(e){return e.reduce((e,t)=>Math.max(e,ee1(t)),0)}let ee5="vtl:composer-model:",ee4="vtl:composer-effort:";function ee3(e,t){if(!t)return"";try{return window.localStorage.getItem(e+t)??""}catch{return""}}function ee6(e,t,n){if(t)try{window.localStorage.setItem(e+t,n)}catch{}}function ee8({conversation:e,clipboardItems:t,clipboardDraggingId:n,onClipboardItemsChange:r,onClipboardDraggingChange:a,onOverlayOpenChange:i,onConversationCreated:o,onCancelDraft:l,subagentStack:s=[],onSubagentStackChange:c,subagentTree:d=[],mobileView:u="conversation",onMobilePaneCountChange:f}){let m=sv(),h=ew.useRef(null),p=ew.useRef(void 0),g=eeY(e?.panes),[x,v]=ew.useState(g.layoutMode),[b,y]=ew.useState(g.agentPosition),w=function(){let[e,t]=ew.useState(eeB);return ew.useEffect(()=>{t(eeV());let e=()=>t(eeV());return window.addEventListener(eeF,e),window.addEventListener("storage",e),()=>{window.removeEventListener(eeF,e),window.removeEventListener("storage",e)}},[]),e}(),j="card"===w.mode,[k,N]=ew.useState(!1),[S,C]=ew.useState(!1);ew.useEffect(()=>{try{C("1"===window.localStorage.getItem("vtl:agent-panes-collapsed"))}catch{}},[]);let M=ew.useCallback(()=>{C(e=>{let t=!e;try{window.localStorage.setItem("vtl:agent-panes-collapsed",t?"1":"0")}catch{}return t})},[]),[E,I]=ew.useState(g.layoutSizes),[P,O]=ew.useState(()=>g.panes),[z,A]=ew.useState(()=>g.cardColumns),[T,R]=ew.useState(()=>g.cardHeights),[D,_]=ew.useState(()=>e?.events??[]),[L,$]=ew.useState(()=>e?.eventsStart??0),[F,B]=ew.useState(()=>e?.eventsTotal??e?.events?.length??0),[V,H]=ew.useState(!1),U=L>0,[q,W]=ew.useState(null),[K,G]=ew.useState(()=>e?.conversation.planState!=null),[X,Y]=ew.useState(new Set),[Z,J]=ew.useState(void 0),[Q,ee]=ew.useState(()=>qN(e?.conversation.id)),et=ew.useCallback(t=>{ee(t),function(e,t){if(e)try{if(!t)return void window.localStorage.removeItem(qk(e));window.localStorage.setItem(qk(e),t.slice(0,1e5))}catch{}}(e?.conversation.id,t)},[e?.conversation.id]),[en,er]=ew.useState(()=>qC(e?.conversation.id)),[ea,ei]=ew.useState([]),[eo,el]=ew.useState(void 0),[es,ec]=ew.useState(!1),[ed,eu]=ew.useState(!1),[ef,em]=ew.useState(!1),[eh,ep]=ew.useState(()=>new Set),[eg,ex]=ew.useState(void 0),[ev,ey]=ew.useState(""),[ej,ek]=ew.useState(!1),[eN,eS]=ew.useState(void 0),[eC,eM]=ew.useState(""),[eE,eI]=ew.useState(e?.conversation.status==="working"),[eP,eA]=ew.useState(e?.conversation.status??"idle"),[eR,eD]=ew.useState(e?.conversation.awaitingTakeover??!1),[e_,eL]=ew.useState(!1),[e$,eF]=ew.useState(e?.conversation.settings?.permissionMode??"acceptEdits"),[eB,eV]=ew.useState(e?.conversation.settings?.reasoningEffort??""),[eH,eU]=ew.useState([]),[eq,eW]=ew.useState(e?.conversation.tokens??0),[eK,eG]=ew.useState(e?.conversation.runUsage),[eX,eY]=ew.useState(e?.conversation.contextTokens??0),[eZ,eJ]=ew.useState(!1),eQ=ew.useRef(eP),e0=ew.useRef(!1),[e1,e2]=ew.useState(),[e5,e4]=ew.useState(),[e3,e6]=ew.useState(),e8=ew.useRef(ee2(g.panes)),e7=ew.useRef(0),e9=ew.useRef(""),te=ew.useRef(void 0),tt=eeC.find(e=>e.id===x)?.slots??4,tn=e?.conversation.settings.folders??eeq,{models:tr}=vH(),ta=ew.useMemo(()=>{let t=e?.conversation.settings.mainModels??[];if(!t.length)return[];let n=new Map(tr.map(e=>[e.value,e]));return t.map(e=>{let t=n.get(e);return t?!1===t.available?{id:e,label:t.label,disabled:!0}:{id:e,label:t.label}:{id:e,label:e,disabled:!0}})},[tr,e?.conversation.settings.mainModels]),ti=ew.useMemo(()=>ta.filter(e=>!e.disabled),[ta]),to=kt(e?.conversation.settings.engine),tl=ew.useMemo(()=>{if(to){let t=e?.conversation.settings.ccModel;return[{id:t&&""!==t?t:"__cc_model__",label:kn(t),disabled:!0}]}return ta},[to,e?.conversation.settings.ccModel,ta]),td=!to&&0===ti.length,[tu,tf]=ew.useState(!1),tm=eE||"working"===eP||tu;e0.current=tm;let th=ew.useCallback(async t=>{if(!e||eZ)return;let n=e.conversation.id,r=e.conversation.ownerMachineId;if(to){if(tm)return void await cc(n,"请执行 /compact 压缩上下文。",r);eI(!0),eA("working");try{let e=await s3(n,{message:"/compact",modelRef:"",mode:"agent"},r);eA(e.conversation.status)}catch(e){eI(!1),eA("idle"),hn.error(e instanceof Error?e.message:"压缩请求失败")}return}if(tm)return void await cc(n,"precise"===t?"请在完成当前小任务后进行精确压缩(去除冗余文件读取和旧工具输出)。":"请在完成当前小任务后进行极致压缩(AI摘要),以便继续工作。",r);eJ(!0);try{let e=await cg(n,t,void 0,r),a=await sD(n,r);a&&(_(a.events),$(a.eventsStart??0),B(a.eventsTotal??a.events.length),eW(a.conversation.tokens??0),eG(a.conversation.runUsage),eY(a.conversation.contextTokens??0));let i=Math.max(0,Math.round((e?.tokensSaved??0)/1e3));hn.success(i>0?`${"extreme"===t?"极致":"精确"}压缩完成 \xb7 节省约 ${i}K tokens`:`${"extreme"===t?"极致":"精确"}压缩完成`)}catch(e){hn.error(e instanceof Error?e.message:"压缩失败")}finally{eJ(!1)}},[e,eZ,tm,to]),tp=ew.useMemo(()=>{if(!e)return;let t=tr.find(e=>e.value===eC),n=t?.contextLength,r=null==n||!Number.isFinite(n)||n<=0?2e5:Math.min(2e7,n<=1e4?Math.round(1e3*n):Math.round(n)),a=eX>0?eX:e.conversation.contextTokens??0;return{used:a,total:r,toolCalls:a,userMessages:0,other:void 0,onCompressPrecise:()=>th("precise"),onCompressExtreme:()=>th("extreme"),compressing:eZ,onExpand:()=>te.current?.()}},[e,tr,eC,eX,th,eZ]),tg=ew.useMemo(()=>{let t=e?.conversation.rounds;if(t?.length)return t;let n=[];for(let e of D){if("user"!==e.kind)continue;let t=n.length,r=(e.title??"").replace(/\s+/g," ").trim(),a=(r?r.slice(0,28):"")||`第 ${t+1} 轮`;n.push({runId:e.id,index:t,anchorEventId:e.id,title:a,summary:a,createdAt:""})}return n},[e?.conversation.rounds,D]),tx=ew.useCallback(async t=>{let n=e?.conversation.id,r=t.anchorEventId??D.find(e=>e.id.startsWith(`${t.runId}-`))?.id??D.find(e=>e.id===t.runId)?.id;if(r){if(D.some(e=>e.id===r))return void h.current?.scrollToEvent(r);if(n&&L>0)try{let t=await s_(n,{fromEventId:r,end:L},e?.conversation.ownerMachineId);t.events.length>0&&(_(e=>eeX(t.events,e)),$(t.start),t.total>0&&B(t.total))}catch{}window.setTimeout(()=>{h.current?.scrollToEvent(r)},60)}},[e?.conversation.id,e?.conversation.ownerMachineId,D,L]),tv=ew.useCallback(t=>{let n;if(t&&function(e,t){if(e)try{if(!t)return void window.localStorage.removeItem(qM(e));window.localStorage.setItem(qM(e),t)}catch{}}(e?.conversation.id,t),!t)return void J(void 0);let r=D.findIndex(e=>e.id===t);if(r>=0)for(let e of tg){let t=e.anchorEventId??e.runId,a=D.findIndex(e=>e.id===t);a>=0&&a<=r&&(n=e.runId)}n||(n=tg.find(e=>t===e.runId||t.startsWith(`${e.runId}-`))?.runId),J(n)},[e?.conversation.id,D,tg]),tb=ew.useCallback(async e=>{if("file-tab-viewer"!==e.kind||e.modified||e.file?.readOnly)return e;try{var t,n;let r=await fS(e);return(t=e,n=r,t.defaultValue!==n.defaultValue||t.title!==n.title||t.file?.size!==n.file?.size||t.file?.mimeType!==n.file?.mimeType||t.file?.previewContent!==n.file?.previewContent||t.file?.src!==n.file?.src||t.file?.truncated!==n.file?.truncated)?r:e}catch{return e}},[]),ty=ew.useCallback(async e=>{if(!e||!kA(e))return e;if("multi-tab-system"===e.kind){var t,n;let r=e.tabs??[],a=await Promise.all(r.map(tb));return(t=r,n=a,t.length!==n.length||t.some((e,t)=>e!==n[t]))?{...e,tabs:a}:e}if("file-tab-viewer"===e.kind&&e.tab){let t=await tb(e.tab);return t!==e.tab?{...e,title:t.title,tab:t}:e}return e},[tb]),tw=ew.useCallback(async()=>{var e,t;let n=await Promise.all(P.map(async e=>ty(e)));e=P,t=n,(e.length!==t.length||e.some((e,n)=>e!==t[n]))&&O(n)},[P,ty]);ew.useEffect(()=>{i?.(void 0!==e1||void 0!==e5||void 0!==e3)},[e5,e3,i,e1]);let tj=ew.useRef(void 0);ew.useEffect(()=>{let t=e?.conversation.id,n=e?.events??[];if(tj.current!==t){tj.current=t,_(n),$(e?.eventsStart??0),B(e?.eventsTotal??n.length);return}_(e=>eeG(e,n))},[e?.conversation.id,e?.events]);let tk=ew.useCallback(async()=>{let t=e?.conversation.id;if(t&&!(L<=0)&&!V){H(!0);try{let n=await s_(t,{end:L,limit:200},e?.conversation.ownerMachineId);n.events.length>0&&_(e=>eeX(n.events,e)),$(e=>n.events.length>0?n.start:Math.max(0,e-200)),n.total>0&&B(n.total)}finally{H(!1)}}},[e?.conversation.id,e?.conversation.ownerMachineId,L,V]);ew.useEffect(()=>{let t=e?.conversation.id;if(!t||0===D.length||p.current===t)return;p.current=t;let n=function(e){if(e)try{return window.localStorage.getItem(qM(e))??void 0}catch{return}}(t),r=D[D.length-1]?.id;if(!n||n===r||!D.some(e=>e.id===n))return;let a=window.setTimeout(()=>{h.current?.scrollToEvent(n)},80);return()=>window.clearTimeout(a)},[e?.conversation.id,D.length]),ew.useEffect(()=>{ee(qN(e?.conversation.id)),er(qC(e?.conversation.id)),ei([]),el(void 0),Y(new Set)},[e?.conversation.id]),ew.useEffect(()=>{eI(e?.conversation.status==="working"),eA(e?.conversation.status??"idle")},[e?.conversation.id,e?.conversation.status]),ew.useEffect(()=>{eD(e?.conversation.awaitingTakeover??!1)},[e?.conversation.id,e?.conversation.awaitingTakeover]);let tN=ew.useRef(void 0);ew.useEffect(()=>{let t=e?.conversation.id,n=e?.conversation.planState!=null;if(tN.current!==t){tN.current=t,G(n);return}n&&G(!0)},[e?.conversation.id,e?.conversation.planState]),ew.useEffect(()=>{eW(e?.conversation.tokens??0),eG(e?.conversation.runUsage),eY(e?.conversation.contextTokens??0)},[e?.conversation.id,e?.conversation.tokens,e?.conversation.runUsage,e?.conversation.contextTokens]),ew.useEffect(()=>{eF(e?.conversation.settings?.permissionMode??"acceptEdits")},[e?.conversation.id,e?.conversation.settings?.permissionMode]);let tS=ew.useRef(void 0);ew.useEffect(()=>{let t=e?.conversation.id;if(tS.current===t)return;if(tS.current=t,!t)return void eV("");let n=ee4+t;(()=>{try{return null!==window.localStorage.getItem(n)}catch{return!1}})()?eV(ee3(ee4,t)):eV(e?.conversation.settings?.reasoningEffort??"")},[e?.conversation.id,e?.conversation.settings?.reasoningEffort]);let tC=e?.conversation.lastModelRef??"",tM=ew.useRef(void 0);function tE(t){eM(t),ee6(ee5,e?.conversation.id,t)}function tI(t){eV(t);let n=e?.conversation.id;ee6(ee4,n,t),n&&nv({reasoningEffort:t})}function tP(e){if(!e.length)return;let t=e.map(kR);r(e=>[...t,...e.filter(e=>!t.some(t=>t.id===e.id))])}function tO(e,t,n){if(!e||!kA(e))return e;if("multi-tab-system"===e.kind){var r;let a,i;return{...e,tabs:(r=e.tabs??[],a=r.filter(e=>e.id!==t.id),i=void 0===n?a.length:Math.min(Math.max(n,0),a.length),a.splice(i,0,t),a),activeTabId:t.id}}return"file-tab-viewer"===e.kind?{...e,title:t.title,tab:t}:e}function tz(e,t){return e&&kA(e)?"multi-tab-system"===e.kind?{...e,tabs:(e.tabs??[]).map(e=>e.id===t.id?t:e),activeTabId:t.id}:"file-tab-viewer"===e.kind?{...e,title:t.title,tab:t}:e:e}function tA(e){O(t=>{let n=t.findIndex(e=>void 0===e);return n>=0?t.map((t,r)=>r===n?e:t):[...t,e]})}function tT(e){e8.current+=1;let t=kz(e,`${e}-${e8.current}`);if("browser-tab-viewer"===e&&t.tab){let e=t.tab;(0,eT.fetchLocalDevServers)().then(n=>{tA(n.length>0?{...t,tab:{...e,defaultUrl:n[0]}}:t)});return}tA(t)}ew.useEffect(()=>{let t=e?.conversation.id,n=e=>!!e&&ti.some(t=>t.id===e),r=ti[0]?.id??"",a=tM.current!==t,i=a?ee3(ee5,t):"",o=n(i)?i:n(tC)?tC:r;tM.current=t,eM(e=>a?o:n(e)?e:o)},[e?.conversation.id,ti,tC]),ew.useEffect(()=>{let t=eeY(e?.panes);v(t.layoutMode),y(t.agentPosition),I(t.layoutSizes),O(t.panes),A(t.cardColumns),R(t.cardHeights),e8.current=ee2(t.panes)},[e?.conversation.id,e?.panes]),ew.useEffect(()=>{let t,n=e?.conversation.id,r=e?.conversation.ownerMachineId;if(!n)return;let a=!1,i=e=>{_(t=>eeG(t,e.events)),eA(e.conversation.status),eW(e.conversation.tokens??0),eG(e.conversation.runUsage),eY(e.conversation.contextTokens??0),eD(e.conversation.awaitingTakeover??!1),null!=e.conversation.planState&&G(!0)},o=e=>{void 0===t&&(t=window.setInterval(async()=>{try{let e=await sD(n,r);if(a)return;i(e),eI("working"===e.conversation.status)}catch{return}},e))};if(r&&"local"!==r)return o(1500),()=>{a=!0,void 0!==t&&window.clearInterval(t)};let l=e?.conversation.lastSeq??0,s=new EventSource((0,eT.localAPIURL)(`/api/local/agent/conversations/${encodeURIComponent(n)}/events/stream?after=${l}`));return s.addEventListener("detail",e=>{try{let t=cx(JSON.parse(e.data));i(t),eI("working"===t.conversation.status)}catch{return}}),s.onerror=()=>{s.close(),o(350)},()=>{a=!0,s.close(),void 0!==t&&window.clearInterval(t)}},[e?.conversation.id,e?.conversation.ownerMachineId]),ew.useEffect(()=>{if(!e?.conversation.id)return;let t=window.setInterval(()=>{tw()},15e3);return()=>window.clearInterval(t)},[e?.conversation.id,tw]),ew.useEffect(()=>{let t=e?.conversation.id,n=e?.conversation.ownerMachineId;if(!t)return;let r=!1;sK(t,n);let a=window.setInterval(()=>{r||sK(t,n)},3e4);return()=>{r=!0,window.clearInterval(a),sG(t,n)}},[e?.conversation.id,e?.conversation.ownerMachineId]),ew.useEffect(()=>{let e=D.filter(e=>"change"===e.kind).map(e=>`${e.id}:${e.status??""}:${e.isStreaming?"1":"0"}`).join("|");e&&e!==e9.current&&(e9.current=e,window.dispatchEvent(new CustomEvent(eeW)),tw())},[D,tw]),ew.useEffect(()=>{let t=e?.conversation.id;if(!t)return;let n=window.setTimeout(()=>{var n;let r;s0(t,(n={columns:z,heights:T},r=[],P.forEach((e,t)=>{e&&(kA(e)?r.push({paneId:e.id,slot:t,kind:e.kind,machineId:e.terminal?.selectedMachineId,resourceId:e.terminal?.activeSessionId,props:{title:e.title,tab:e.tab,tabs:e.tabs,activeTabId:e.activeTabId,terminal:e.terminal}}):"context-breakdown"!==e.kind&&r.push({paneId:e.id,slot:t,kind:e.kind,props:{title:e.title,subagentId:e.subagentId,events:e.events}}))}),{layoutMode:x,agentPosition:b,sizes:E,cardLayout:n,panes:r}),e?.conversation.ownerMachineId)},300);return()=>window.clearTimeout(n)},[b,z,T,e?.conversation.id,x,E,P]);let tR=ew.useCallback(e=>{O(t=>{let n=t.findIndex(e=>e?.kind==="browser-tab-viewer");if(n>=0){let r=t[n];return r&&kA(r)&&r.tab&&(!r.tab.defaultUrl||r.tab.defaultUrl.startsWith("https://vantaloom.local"))?t.map((t,a)=>a===n&&r.tab?{...r,tab:{...r.tab,defaultUrl:e}}:t):t}e8.current+=1;let r=kz("browser-tab-viewer",`browser-tab-viewer-${e8.current}`),a=void 0!==r.tab?{...r,tab:{...r.tab,defaultUrl:e}}:r,i=t.findIndex(e=>void 0===e);return i>=0?t.map((e,t)=>t===i?a:e):j?[...t,a]:t})},[j]),tD=ew.useRef(!1);function t_(e){O(t=>{if(t.findIndex(t=>t?.kind===e)>=0)return t;e8.current+=1;let n=kz(e,`${e}-${e8.current}`),r=t.findIndex(e=>void 0===e);return r>=0?t.map((e,t)=>t===r?n:e):j?[...t,n]:t})}ew.useEffect(()=>{let t,n=e?.conversation.id,r=e?.conversation.ownerMachineId;if(!n||r&&"local"!==r)return;tD.current=!1;let a=!1,i=()=>{void 0!==t&&(window.clearInterval(t),t=void 0)},o=async()=>{if(a||tD.current)return void i();try{let e=(await (0,eT.fetchLocalDevServers)())[0];if(a||tD.current||!e){tD.current&&i();return}tD.current=!0,tR(e),i()}catch{}};return o(),tD.current||(t=window.setInterval(o,3e3)),()=>{a=!0,i()}},[e?.conversation.id,e?.conversation.ownerMachineId,tR]);let tL=ew.useCallback((e,t)=>{O(n=>{if(n.some(n=>void 0!==n&&kA(n)&&(n.id===t||(n.terminal?.sessionIds??[]).includes(e.id))))return n;let r={...kz("terminal-tab-group",t),terminal:{sessionIds:[e.id],activeSessionId:e.id,autoStart:!1,aiControlledSessionIds:[e.id],selectedMachineId:e.machineId}},a=n.findIndex(e=>void 0===e);return a>=0?n.map((e,t)=>t===a?r:e):j?[...n,r]:n})},[j]),t$=ew.useRef(new Set),[tF,tB]=ew.useState(0);ew.useEffect(()=>{tm&&tB(e=>e+1)},[tm]),ew.useEffect(()=>{let t,n=e?.conversation.id,r=e?.conversation.ownerMachineId;if(!n||r&&"local"!==r)return;t$.current=new Set;let a=`agent:${n}:pane:`,i=!1,o=async()=>{if(!i){try{let{sessions:e}=await fD();if(i)return;for(let t of e){if(!0!==t.aiControlled||"agent"!==t.controller||!t.scopeId||!t.scopeId.startsWith(a)||t$.current.has(t.id))continue;let e=t.scopeId.slice(a.length);e&&(t$.current.add(t.id),tL(t,e))}}catch{}i||(t=window.setTimeout(o,e0.current?4e3:3e4))}};return o(),()=>{i=!0,void 0!==t&&window.clearTimeout(t)}},[e?.conversation.id,e?.conversation.ownerMachineId,tL,tF]);let tV=ew.useCallback(()=>{t_("plan-doc-viewer")},[j]),tH=ew.useCallback(()=>{t_("spec-doc-viewer")},[j]),tU=ew.useCallback(()=>{t_("tasks-pane")},[j]),tq=P.some(e=>e?.kind==="plan-doc-viewer"||e?.kind==="spec-doc-viewer");ew.useEffect(()=>{let t=e?.conversation.id;if(W(null),!t||!K&&!tq)return;let n=e?.conversation.ownerMachineId,r=!0,a=async()=>{let e=await sF(t,n);r&&W(e.planState)};a();let i=window.setInterval(a,1500);return()=>{r=!1,window.clearInterval(i)}},[e?.conversation.id,e?.conversation.ownerMachineId,K,tq]);let tW=q??e?.conversation.planState??null,tK=ew.useRef(void 0);ew.useEffect(()=>{let e=tW?.approvals?.find(e=>!e.decision);e&&tK.current!==e.id&&(tK.current=e.id,tV())},[tW,tV]);let tG=ew.useRef(void 0);function tX(e,t){O(n=>{let r=n.findIndex(t=>t?.kind===e);if(r>=0)return n.map((n,a)=>a===r&&n?{id:n.id,kind:e,title:t.title,tab:t}:n);e8.current+=1;let a={id:`${e}-${e8.current}`,kind:e,title:t.title,tab:t},i=n.findIndex(e=>void 0===e);return i>=0?n.map((e,t)=>t===i?a:e):[...n,a]})}async function tY(e,t,n){let r;try{r=await fk(e)}catch(t){if(j){let n,r,a;return void tX("file-tab-viewer",(n=qn(e.path),r=t instanceof Error?t.message:String(t??""),a=[`// 无法加载文件预览`,`// 路径:${e.path}`,e.machineId&&"local"!==e.machineId?`// 机器:${e.machineId}`:"",r?`// 原因:${r}`:"","","// 文件可能已被移动/删除,或路径无法解析。","// 重新点击对话中的该文件可重试加载。"].filter(Boolean).join("\n"),{id:`file-error-${e.machineId??"local"}-${encodeURIComponent(e.path).replace(/[^a-z0-9_-]/gi,"-").slice(0,96)}-${Date.now()}`,kind:"file-tab-viewer",title:n,file:{name:n,path:e.path,machineId:e.machineId,kind:"code",readOnly:!0},defaultValue:a,defaultView:"code",defaultMode:"review"}))}hn.error("文件预览打开失败");return}j?tX("file-tab-viewer",r):O(e=>e.map((e,a)=>a===t?tO(e,r,n):e))}function tZ(e){if(j)return void tY(e,-1);let t=P.slice(0,tt).findIndex(e=>e?.kind==="multi-tab-system");t<0?hn.warning("请先放入一个多标签页组件"):tY(e,t)}function tJ(t){let n=t.path?.trim()||t.name.trim();("diff"===t.kind||"diff"===t.meta)&&t.diff?function(e){let t=e.path?.trim()||e.name.trim(),n={id:function(e,t){let n=0x811c9dc5;for(let e=0;e<t.length;e+=1)n^=t.charCodeAt(e),n=Math.imul(n,0x1000193);return`${e}-${(n>>>0).toString(36)}`}("diff",`${e.mutationId??""}|${e.machineId??"local"}|${t}|${e.diff??""}`),kind:"diff-tab-viewer",title:`Diff ${e.name}`,file:{name:e.name,path:t,machineId:e.machineId??"local",kind:"code"},diff:e.diff};if(j)return tX("diff-tab-viewer",n);let r=P.slice(0,tt).findIndex(e=>e?.kind==="multi-tab-system");r<0?hn.warning("请先放入一个多标签页组件"):O(e=>e.map((e,t)=>t===r?tO(e,n):e))}(t):!n||t.meta?.toLowerCase().startsWith("depth")||tZ(function(e,t){var n,r,a;let i,o,l,s=e.path.trim(),c=t.ownerMachineId||"local";if(/^vantaloom:\/\//i.test(s)){let e=qt(s);return{machineId:e.machineId,path:e.path}}let d=e.machineId||c;if(n=s,/^[A-Za-z]:[\\/]/.test(n)||n.startsWith("/")||n.startsWith("\\\\"))return{machineId:d,path:s};let u=(t.workspaceFolders??[]).map(qt).filter(e=>e.path),f=u.find(e=>e.machineId===d)??u[0];return f?{machineId:f.machineId||d,path:(r=f.path,a=s,i=r.includes("\\")&&!r.includes("/")?"\\":"/",o=r.replace(/[\\/]+$/,""),l=a.replace(/^[\\/]+/,""),`${o}${i}${l}`)}:{machineId:d,path:s}}({machineId:t.machineId,path:n},{workspaceFolders:tn,ownerMachineId:e?.conversation.ownerMachineId}))}ew.useEffect(()=>{let t=e?.conversation.id;!t||tG.current===t||D.some(e=>"task"===e.kind)&&(tG.current=t,tU())},[e?.conversation.id,D,tU]),te.current=function(){let t=function(e,t,n,r){let a=new Map,i=0,o=0,l=0;for(let t of e){for(let e of t.files??[]){var s;let n=(e.path??e.name??"").trim();if(!n||t.actionLabel?.trim()==="探索"||e.meta?.toLowerCase().startsWith("depth")||/[\\/]$/.test(n))continue;let i=e.machineId??r??"local",o=`${i}:${n}`,l=((s=t.detail)?Math.max(1,Math.round(s.length/4)):0)||256,c=a.get(o);c?c.estTokens=Math.max(c.estTokens,l):a.set(o,{path:n,machineId:i,estTokens:l})}"memory"===t.kind?i+=(t.detail??t.title??"").length:"skill"===t.kind?o+=(t.detail??t.title??"").length:("tool"===t.kind||"verify"===t.kind||t.shellMeta)&&(l+=(t.detail??"").length)}let c=[{key:"system",label:"系统提示词",estTokens:1500},{key:"memory",label:"记忆",estTokens:eeQ(i)},{key:"skill",label:"技能",estTokens:eeQ(o)},{key:"terminal",label:"terminal 工具返回内容",estTokens:eeQ(l)}];return{used:t,total:n,files:Array.from(a.values()),categories:c}}(D,tp?.used??0,tp?.total??0,e?.conversation.ownerMachineId);O(e=>{let n=e.findIndex(e=>e?.kind==="context-breakdown");if(n>=0)return e.map((e,r)=>r===n&&e?{id:e.id,kind:"context-breakdown",title:"上下文明细",data:t}:e);e8.current+=1;let r={id:`context-breakdown-${e8.current}`,kind:"context-breakdown",title:"上下文明细",data:t},a=e.findIndex(e=>void 0===e);return a>=0?e.map((e,t)=>t===a?r:e):[...e,r]})};let tQ=e?.conversation.ownerMachineId??"local",t0=ew.useMemo(()=>{let e=e=>/^https?:\/\//i.test(e)||e.startsWith("data:"),t=async e=>{let{target:t,kind:n,label:r}=e;try{if("url"===n)return void window.open(t,"_blank","noopener,noreferrer");if("local-file"===n){let e=await fetch((0,eT.localAPIURL)(`/v1/files/reveal?path=${encodeURIComponent(t)}`),{cache:"no-store"});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error??`reveal failed: ${e.status}`)}return}let e=await fd(tQ,t);if("utf-8"===e.encoding&&"folder"!==e.kind&&!e.truncated)return void tZ({machineId:tQ,path:t});let a=(0,eT.localAPIURL)(`/v1/remote/${encodeURIComponent(tQ)}/files/raw?path=${encodeURIComponent(t)}`);await h1({url:a,label:r}),hn.success(`已开始下载「${r}」,可在 系统设置 → 下载 查看进度`)}catch(e){hn.error(`打开交付物失败:${e instanceof Error?e.message:String(e)}`)}};return{resolveImageSrc:t=>{if(e(t))return t;let n=`path=${encodeURIComponent(t)}`;return"local"===tQ?(0,eT.localAPIURL)(`/v1/files/raw?${n}`):(0,eT.localAPIURL)(`/v1/remote/${encodeURIComponent(tQ)}/files/raw?${n}`)},classify:t=>e(t)?"url":"local"===tQ?"local-file":"remote-file",onOpen:e=>void t(e)}},[tQ]);async function t1(e,t,n){let r=t.file?.path,a=t.file?.machineId??"local";if(!r)throw hn.error("文件路径不可用"),Error("file path is unavailable");try{let i=await fu({machineId:a,path:r,content:n}),o={...await fN(i,{id:t.id,title:t.title,defaultView:t.defaultView,defaultMode:t.defaultMode}),modified:!1};O(t=>t.map((t,n)=>n===e?tz(t,o):t)),window.dispatchEvent(new CustomEvent(eeW)),hn.success("文件已保存")}catch(e){throw hn.error("文件保存失败"),e}}async function t2(t){let n=e?.conversation.id,r=e3?.tab.file?.path,a=e3?.tab.file?.machineId??"local";if(e3&&n&&r)try{let i=await cr(n,{machineId:a,path:r,mutationId:t.mutationId,state:t.state},e?.conversation.ownerMachineId),o=await fN(i,{id:e3.tab.id,title:`${i.name} @ ${ee9(t.mutationId)} ${"before"===t.state?"before":"after"}`,readOnly:!0,defaultView:e3.tab.defaultView,defaultMode:"review"});O(e=>e.map((e,t)=>t===e3.paneIndex?tz(e,o):e)),e6(void 0)}catch{hn.error("历史版本打开失败")}}function t5(e,t,n){let i=P[e];e8.current=Math.max(e8.current,ee1(n)),O(t=>t.map((t,r)=>r===e?n:t)),r(e=>{let n=e.filter(e=>e.id!==t.id);if(!i)return n;let r=kR(i);return[r,...n.filter(e=>e.id!==r.id)]}),a?.(void 0)}function t4(e,t){O(n=>n.map((n,r)=>r===e?t:n))}function t3(t){return{id:t.id,ownerMachineId:t.ownerMachineId??e?.conversation.ownerMachineId,name:t.name,subagentType:t.subagentType}}function t6(e){var t=P[e];if(t&&kA(t)&&"terminal-tab-group"===t.kind)for(let e of t.terminal?.sessionIds??[])fL(e).catch(()=>{});O(t=>t.map((t,n)=>n===e?void 0:t))}function t8(e){let t=P[e];t&&tP([t]),O(t=>t.map((t,n)=>n===e?void 0:t))}async function t7(t,n="chat",r=[]){let a=e?.conversation.id,i=to?"":eC||ti[0]?.id||"";if(!a||(!to&&i&&ee6(ee5,a,i),ee6(ee4,a,eB),t.trim()&&er(function(e,t){let n=t.trim();if(!n)return qC(e);let r=n.slice(0,1e5),a=qC(e);if(a[a.length-1]===r)return a;let i=[...a,r].slice(-100);if(e&&1)try{window.localStorage.setItem(qS(e),JSON.stringify(i))}catch{}return i}(a,t)),eE||"working"===eP))return;if(!to&&!i)return void hn.error("请先在代理模型配置里选择模型");Y(function e(t,n=new Set){for(let r of t)n.add(r.id),e(r.children??[],n);return n}(d));let o=r.map(e=>"image"===e.kind?{kind:"image",name:e.name,mimeType:e.mimeType,data:e.dataUrl?.split(",")[1]??""}:"card"===e.kind?{kind:"card",name:e.name,mimeType:e.mimeType,text:e.text??"",cardKind:e.cardKind}:{kind:"file",name:e.name,mimeType:e.mimeType,text:e.text??""}).filter(e=>"image"===e.kind?(e.data??"")!=="":(e.text??"")!=="");eI(!0),eA("working");try{let r=await s3(a,{message:t,modelRef:i,mode:n,effort:eB||void 0,attachments:o.length>0?o:void 0},e?.conversation.ownerMachineId);eA(r.conversation.status)}catch(e){eI(!1),eA("idle"),hn.error(e instanceof Error?e.message:"对话请求失败")}}async function t9(t){let n=e?.conversation.id,r="string"==typeof t.modelRef?t.modelRef.trim():"",a=to?"":r||eC||ti[0]?.id||"",i="agent"===t.mode?"agent":"chat";if(n){if(!to&&!a)return void hn.error("请先在代理模型配置里选择模型");eI(!0),eA("working"),_(e=>e.map(e=>e.id===t.id?{...e,status:"retried"}:e));try{let r=await s6(n,{modelRef:a,mode:i,effort:eB||void 0,retryEventId:t.id},e?.conversation.ownerMachineId);eA(r.conversation.status)}catch(e){_(e=>e.map(e=>e.id===t.id?t:e)),eI(!1),eA("idle"),hn.error(e instanceof Error?e.message:"对话重试失败")}}}function ne(e){tm?hn.error("对话正在运行,请先停止后再回退"):el(e)}async function nt(){let t=e?.conversation.id;if(t&&!e_){eL(!0);try{let n=await cl(t,e?.conversation.ownerMachineId);eD(n.conversation.awaitingTakeover??!1)}catch(e){hn.error(e instanceof Error?e.message:"接管失败")}finally{eL(!1)}}}async function nn(){let t=e?.conversation.id;if(!eo||!t)return void el(void 0);ec(!0);try{let n=await s8(t,eo.id,e?.conversation.ownerMachineId);_(n.detail.events),$(0),B(n.detail.events.length),eA(n.detail.conversation.status),eI(!1),et(n.prompt),c?.([]);let r=[];n.revertedFiles>0&&r.push(`恢复 ${n.revertedFiles} 个文件`),n.deletedFiles>0&&r.push(`删除 ${n.deletedFiles} 个新增文件`),n.archivedSubagents>0&&r.push(`归档 ${n.archivedSubagents} 个子代理`),hn.success(r.length?`已回退:${r.join(",")}`:"已回退到此处"),n.skippedRemote&&n.skippedRemote.length>0&&hn.warning(`${n.skippedRemote.length} 个远程文件未自动回退,请在对应机器手动处理`)}catch(e){hn.error(e instanceof Error?e.message:"回退失败")}finally{ec(!1),el(void 0)}}async function nr(t){let n=e?.conversation.id;if(n&&!ed){eu(!0);try{let r=await ct(n,t.id,e?.conversation.ownerMachineId);o?.(r),hn.success("已创建分支对话")}catch(e){hn.error(e instanceof Error?e.message:"创建分支失败")}finally{eu(!1)}}}function na(e){_(e.events),$(0),B(e.events.length),eA(e.conversation.status)}function ni(){tm?hn.error("对话正在运行,请先停止后再编辑上下文"):em(!0)}function no(){em(!1),ep(new Set),ex(void 0),ey("")}function nl(e){ep(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function ns(e,t){let n=D.findIndex(t=>t.id===e),r=D.findIndex(e=>e.id===t);if(n<0||r<0)return;let a=Math.min(n,r),i=Math.max(n,r);ep(e=>{let t=new Set(e);for(let e=a;e<=i;e++){let n=D[e];n&&"user"!==n.kind&&t.add(n.id)}return t})}function nc(e){tm?hn.error("对话正在运行,请先停止后再删除"):0!==e.length&&eS(e)}async function nd(){let t=e?.conversation.id;if(!eN||0===eN.length||!t)return void eS(void 0);ek(!0);try{let n=await s7(t,eN,e?.conversation.ownerMachineId);na(n.detail),ep(new Set),hn.success(`已从上下文删除 ${n.deletedEvents||eN.length} 条`)}catch(e){hn.error(e instanceof Error?e.message:"删除失败")}finally{ek(!1),eS(void 0)}}function nu(e,t){ex(e),ey(t)}async function nf(){let t=e?.conversation.id;if(!eg||!t)return void ex(void 0);ek(!0);try{let n=await s9(t,eg,ev,e?.conversation.ownerMachineId);na(n.detail),ex(void 0),ey(""),hn.success("已更新消息")}catch(e){hn.error(e instanceof Error?e.message:"保存失败")}finally{ek(!1)}}function nm(){ex(void 0),ey("")}async function nh(t,n){let r=e?.conversation.id;if(r){ek(!0);try{let a=await ce(r,[t],n,e?.conversation.ownerMachineId);na(a.detail)}catch(e){hn.error(e instanceof Error?e.message:n?"还原失败":"翻译失败")}finally{ek(!1)}}}let np=ew.useMemo(()=>{if(!to)return{mode:ef,selectedIds:eh,onToggleSelect:nl,onRangeSelect:ns,onEnterMode:ni,onExitMode:no,onDeleteOne:e=>nc([e]),editingId:eg,editDraft:ev,onStartEdit:nu,onEditDraftChange:ey,onSaveEdit:()=>void nf(),onCancelEdit:nm,onTranslate:e=>void nh(e,!1),onRestore:e=>void nh(e,!0)}},[to,ef,eh,eg,ev]),ng=e&&eR?(0,eb.jsxs)("div",{className:"vtl-agent-composer-overlay mb-[-1px] flex flex-wrap items-center gap-2 rounded-t-xl border border-b-0 border-border bg-background px-3 py-2 text-sm",children:[(0,eb.jsx)("span",{className:"min-w-0 flex-1 text-muted-foreground",children:"这个对话由任务分发代理管理,已锁定输入"}),(0,eb.jsx)(eO.Button,{type:"button",size:"sm",className:"w-full sm:w-auto",disabled:e_,onClick:()=>void nt(),children:"接管"})]}):null,nx=np&&eg?(0,eb.jsxs)("div",{className:"vtl-agent-composer-overlay mb-[-1px] flex items-center justify-end gap-2 rounded-t-xl border border-b-0 border-border bg-background px-3 py-2 text-sm",children:[(0,eb.jsx)("span",{className:"mr-auto text-muted-foreground",children:"编辑消息"}),(0,eb.jsx)(eO.Button,{type:"button",size:"sm",variant:"ghost",disabled:ej,onClick:nm,children:"取消"}),(0,eb.jsx)(eO.Button,{type:"button",size:"sm",disabled:ej,onClick:()=>void nf(),children:"保存"})]}):np&&ef?(0,eb.jsxs)("div",{className:"vtl-agent-composer-overlay mb-[-1px] flex items-center justify-end gap-2 rounded-t-xl border border-b-0 border-border bg-background px-3 py-2 text-sm",children:[(0,eb.jsx)("span",{className:"mr-auto text-muted-foreground",children:"编辑上下文"}),(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",variant:"destructive",disabled:ej||0===eh.size,onClick:()=>nc([...eh]),children:["删除选中 (",eh.size,")"]}),(0,eb.jsx)(eO.Button,{type:"button",size:"sm",variant:"ghost",onClick:no,children:"退出编辑"})]}):void 0;async function nv(t){let n=e?.conversation.id;if(n)try{let r=e?.conversation.settings??{};await sY(n,{settings:{...r,...t}},e?.conversation.ownerMachineId)}catch(e){hn.error(e instanceof Error?e.message:"设置更新失败")}}async function nb(t,n){let r=e?.conversation.id;if(r)try{await ca(r,t,n,void 0,e?.conversation.ownerMachineId)}catch(e){hn.error(e instanceof Error?e.message:"审批操作失败")}}async function ny(t){let n=e?.conversation.id;return n?ci(n,t,e?.conversation.ownerMachineId):{state:"error",explanation:""}}async function nw(){let t=e?.conversation.id;if(t){tf(!0);try{await co(t,e?.conversation.ownerMachineId)}catch{}}}function nj(){t7("继续","agent")}async function nk(t){let n=e?.conversation.id;if(!n)return;let r=eH.find(e=>e.id===t);if(!r)return;let a="string"==typeof r.content?r.content:String(r.content??"");if(a.trim()){eU(e=>e.filter(e=>e.id!==t));try{await cc(n,a.trim(),e?.conversation.ownerMachineId)}catch{}}}ew.useEffect(()=>{"idle"===eP&&tu&&tf(!1)},[eP,tu]),ew.useEffect(()=>{let e=eQ.current;if(eQ.current=eP,"working"===e&&"idle"===eP&&eH.length>0){let e=eH[0];if(e){eU(eH.slice(1));let t="string"==typeof e.content?e.content:String(e.content??"");t.trim()&&t7(t.trim(),"agent")}}},[eP]);let nN=Array.from({length:tt},(r,a)=>(0,eb.jsx)(eeO,{conversationId:e?.conversation.id,ownerMachineId:e?.conversation.ownerMachineId,index:a,content:P[a],clipboardItems:t,clipboardDraggingId:n,onAdd:()=>e2(a),onPanelDrop:t5,onContentChange:t4,onClear:t6,onCut:t8,workspaceFolders:tn,onRequestFileTab:(e,t)=>e4({paneIndex:e,insertIndex:t}),onOpenWorkspaceFile:tZ,onSaveFileTab:t1,onOpenFileHistory:(e,t)=>e6({paneIndex:e,tab:t})},a)),nS=P.slice(0,tt).some(e=>e?.kind==="subagent-conversation-panel"),nC=E.shell?.agent??42,nM=E.shell?.panes??58,nE=w.agentSide,nI="control-room"===w.mode||k,nP=(0,eb.jsxs)(hY,{type:"single",value:nI?"hidden":nE,variant:"outline",size:"sm","data-tour":"control-room-toggle","aria-label":"Agent 面板位置",onValueChange:e=>{"left"===e||"right"===e?(N(!1),y(e),eeH({mode:j?"card":"pane",agentSide:e})):"hidden"===e&&(N(!0),eeH({mode:"control-room"}))},children:[(0,eb.jsx)(hZ,{value:"left","aria-label":"Agent 在左",title:"Agent 在左",className:"h-7 w-9 px-0 [&_svg]:size-4",children:(0,eb.jsx)(cy,{})}),(0,eb.jsx)(hZ,{value:"hidden","aria-label":"隐藏面板,居中对话",title:"隐藏面板,居中对话",className:"h-7 w-9 px-0 [&_svg]:size-4",children:(0,eb.jsx)(cN,{})}),(0,eb.jsx)(hZ,{value:"right","aria-label":"Agent 在右",title:"Agent 在右",className:"h-7 w-9 px-0 [&_svg]:size-4",children:(0,eb.jsx)(cj,{})})]}),nO=(0,eb.jsxs)("div",{className:"relative flex size-full min-h-0 min-w-0 flex-col",children:[e?(0,eb.jsx)(UF,{ownerMachineId:e.conversation.ownerMachineId,title:e.conversation.title,className:"pr-12"}):null,e?(0,eb.jsx)("div",{className:"pointer-events-none absolute left-1 top-9 z-30 flex justify-start pt-1.5",children:(0,eb.jsx)("div",{className:"pointer-events-auto",children:(0,eb.jsx)(UB,{rounds:tg,onJumpToRound:tx,activeRunId:Z})})}):null,(0,eb.jsx)("div",{className:"min-h-0 flex-1 pl-10",children:(0,eb.jsx)(UL,{ref:h,events:e?D:void 0,hasEarlier:e?U:void 0,loadingEarlier:e?V:void 0,onLoadEarlier:e?tk:void 0,models:e?tl:void 0,modelId:to?tl[0]?.id:eC,permissionModeId:e$,onPermissionModeChange:t=>{eF(t),e?.conversation.id&&nv({permissionMode:t})},running:tm,disabled:!!e&&(td||eR),onModelChange:tE,effortOptions:e?eeK:void 0,selectedEffort:eB,onEffortChange:tI,onSubmit:e?e=>{t7(e.value,"agent",e.attachments??[])}:void 0,onStop:nw,onOpenFile:tJ,deliverable:t0,onOpenSubagent:function(e){e.id&&c?.([t3(e)])},onOpenPlan:tV,onOpenSpec:()=>tH(),onOpenTasks:tU,planPromptBar:ng||(e?(0,eb.jsx)(qv,{conversationId:e.conversation.id,ownerMachineId:e.conversation.ownerMachineId,planState:tW,modelRef:eC||ti[0]?.id||"",onOpenPlan:tV,onResolved:()=>{let t=e?.conversation.id;t&&sF(t,e?.conversation.ownerMachineId).then(e=>W(e.planState))}}):void 0),onRetry:t9,onApprovalDecision:nb,onFetchExplanation:ny,onContinue:nj,onRecallUserMessage:ne,onBranchAssistantMessage:nr,contextEdit:np,contextEditBar:ng?void 0:nx,onActiveEventChange:tv,composerValue:Q,onComposerValueChange:et,promptHistory:en,attachments:ea,onAttachmentsChange:ei,onCardDrop:qg,queuedMessages:eH,onQueuedMessagesChange:eU,onNudge:nk,contextUsage:tp})}),s.length>0&&e?(0,eb.jsx)(eeU,{stack:s,rootTitle:e.conversation.title,rootOwnerMachineId:e.conversation.ownerMachineId,onNavigateRoot:()=>c?.([]),onNavigateIndex:e=>c?.(s.slice(0,e+1)),onOpenSubagent:function(e){e.id&&c?.([...s,t3(e)])}}):null]}),nz=(0,eb.jsx)(mY,{id:"agent",defaultSize:nC,minSize:28,children:nO},"agent-conversation"),nA=(0,eb.jsx)(mY,{id:"panes",defaultSize:nM,minSize:32,children:(0,eb.jsxs)("section",{className:"vtl-agent-workspace-panel flex size-full min-h-0 min-w-0 flex-col bg-transparent","data-has-conversation-pane":nS?"true":void 0,children:[(0,eb.jsx)("div",{className:"flex h-11 shrink-0 items-center border-b px-3","data-tour":"pane-toolbar",children:(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,eb.jsx)(hY,{type:"single",value:x,variant:"outline",size:"sm","aria-label":"布局排版",onValueChange:e=>{let t,n;e&&(t=eeC.find(t=>t.id===e)?.slots??4,(n=P.slice(t).filter(e=>!!e)).length&&tP(n),O(Array.from({length:Math.max(4,t)},(e,n)=>n<t?P[n]:void 0)),v(e))},children:eeC.map(e=>(0,eb.jsx)(hZ,{value:e.id,"aria-label":e.label,title:e.label,className:"h-7 w-10 px-0 [&_svg]:size-4",children:e.icon},e.id))}),nP,(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-sm",draggable:!0,"aria-label":"剪切窗口内容",title:"拖拽到窗口以剪切到剪切板",className:"h-7 w-10 cursor-grab rounded-md text-muted-foreground active:cursor-grabbing [&_svg]:size-4",onDragStart:e=>{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData(eek,"cut")},children:(0,eb.jsx)(lJ,{})}),(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-sm",draggable:!0,"aria-label":"粉碎窗口内容",title:"拖拽到窗口以清空",className:"h-7 w-10 cursor-grab rounded-md text-muted-foreground active:cursor-grabbing [&_svg]:size-4",onDragStart:e=>{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData(eej,"clear")},children:(0,eb.jsx)(cS,{})})]})}),(0,eb.jsx)("div",{className:"min-h-0 flex-1",children:(0,eb.jsx)(eeP,{mode:x,sizes:E,onSizeGroupChange:function(e,t){let n=eeJ(t);I(t=>{var r;return(r=t[e],(r?.length??0)===(n?.length??0)&&(r??[]).every((e,t)=>.01>Math.abs(e-(n?.[t]??0))))?t:{...t,[e]:n}})},children:nN},`${e?.conversation.id??"empty"}-${x}`)})]})},"agent-panes"),nT=(0,eb.jsx)(ee_,{conversationId:e?.conversation.id,ownerMachineId:e?.conversation.ownerMachineId,panes:P,agentSide:nE,columns:z,heights:T,onColumnsChange:A,onHeightsChange:R,onAddCard:tT,onContentChange:t4,onClear:t6,workspaceFolders:tn,onOpenWorkspaceFile:tZ,onSaveFileTab:t1,onOpenFileHistory:(e,t)=>e6({paneIndex:e,tab:t}),onRequestFileTab:(e,t)=>e4({paneIndex:e,insertIndex:t})}),nR=(0,eb.jsx)("div",{className:(0,ez.cn)("absolute inset-y-0 z-30 flex w-9 items-center","left"===nE?"right-0 justify-end pr-1":"left-0 justify-start pl-1"),children:(0,eb.jsx)("button",{type:"button",onClick:M,"aria-label":S?"展开工作区":"收起工作区",title:S?"展开工作区":"收起工作区",className:"grid size-7 place-items-center rounded-md border bg-background/85 text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-opacity hover:bg-muted hover:text-foreground focus-visible:opacity-100 group-hover/panes:opacity-100 [&_svg]:size-4",children:"left"===nE?S?(0,eb.jsx)(ck,{}):(0,eb.jsx)(cw,{}):S?(0,eb.jsx)(tc,{}):(0,eb.jsx)(ts,{})})}),nD=(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(eez,{open:void 0!==e1,onOpenChange:e=>{e||e2(void 0)},onAdd:function(e){if(void 0===e1)return;e8.current+=1;let t=kz(e,`${e}-${e8.current}`),n=P[e1];n&&tP([n]),O(e=>e.map((e,n)=>n===e1?t:e)),e2(void 0)}}),(0,eb.jsx)(ql,{open:void 0!==e5,folders:tn,onOpenChange:e=>{e||e4(void 0)},onSelectFile:e=>{e5&&tY(e,e5.paneIndex,e5.insertIndex),e4(void 0)}}),(0,eb.jsx)(ee7,{open:void 0!==e3,conversationId:e?.conversation.id,ownerMachineId:e?.conversation.ownerMachineId,tab:e3?.tab,onOpenChange:e=>{e||e6(void 0)},onSelectVersion:e=>{t2(e)}}),(0,eb.jsx)(ux,{open:void 0!==eo,onOpenChange:e=>{e||es||el(void 0)},children:(0,eb.jsxs)(uR,{children:[(0,eb.jsxs)(uD,{children:[(0,eb.jsx)(uL,{children:"回退对话到此处?"}),(0,eb.jsx)(u$,{children:"此操作会归档此处之后的所有对话记录,并把这期间(含子代理)对文件的修改全部还原到当前这条消息发送前的状态。该用户消息会回到输入框。回退无法撤销。"})]}),(0,eb.jsxs)(u_,{children:[(0,eb.jsx)(uB,{disabled:es,children:"取消"}),(0,eb.jsx)(uF,{variant:"destructive",disabled:es,onClick:e=>{e.preventDefault(),nn()},children:es?"回退中…":"确认回退"})]})]})}),(0,eb.jsx)(ux,{open:void 0!==eN,onOpenChange:e=>{e||ej||eS(void 0)},children:(0,eb.jsxs)(uR,{children:[(0,eb.jsxs)(uD,{children:[(0,eb.jsx)(uL,{children:"从上下文中删除?"}),(0,eb.jsx)(u$,{children:`确认从上下文中删除选中的 ${eN?.length??0} 条?此操作会同时从智能体的实际上下文中移除(不影响磁盘文件)。`})]}),(0,eb.jsxs)(u_,{children:[(0,eb.jsx)(uB,{disabled:ej,children:"取消"}),(0,eb.jsx)(uF,{variant:"destructive",disabled:ej,onClick:e=>{e.preventDefault(),nd()},children:ej?"删除中…":"确认删除"})]})]})})]});return e?m?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(kE,{view:u,onPaneCountChange:f,conversationPanel:(0,eb.jsx)(UL,{flowContentClassName:"pl-10",events:e?D:void 0,hasEarlier:e?U:void 0,loadingEarlier:e?V:void 0,onLoadEarlier:e?tk:void 0,models:e?tl:void 0,modelId:to?tl[0]?.id:eC,permissionModeId:e$,onPermissionModeChange:t=>{eF(t),e?.conversation.id&&nv({permissionMode:t})},running:tm,disabled:!!e&&(td||eR),onModelChange:tE,effortOptions:e?eeK:void 0,selectedEffort:eB,onEffortChange:tI,onSubmit:e?e=>{t7(e.value,"agent",e.attachments??[])}:void 0,onStop:nw,onOpenFile:tJ,deliverable:t0,onOpenSubagent:function(e){var t;let n=P.slice(0,tt),r=n.findIndex(e=>!e),a=n.findIndex(e=>e?.kind==="subagent-conversation-panel"),i=r>=0?r:a;if(i<0)return void hn.warning("请释放一个窗口再选中浏览");e7.current+=1;let o={id:t=`subagent-${e.id}-${e7.current}`,kind:"subagent-conversation-panel",title:e.title,subagentId:e.id,events:e.events?.length?e.events:[{id:`${t}-status`,kind:"done",title:e.detail??e.status??e.activity??e.title}]};O(e=>e.map((e,t)=>t===i?o:e))},onRetry:t9,onApprovalDecision:nb,onFetchExplanation:ny,onContinue:nj,onRecallUserMessage:ne,onBranchAssistantMessage:nr,contextEdit:np,planPromptBar:ng??void 0,contextEditBar:ng?void 0:nx,onActiveEventChange:tv,composerValue:Q,onComposerValueChange:et,promptHistory:en,attachments:ea,onAttachmentsChange:ei,onCardDrop:qg,queuedMessages:eH,onQueuedMessagesChange:eU,onNudge:nk,contextUsage:tp}),paneElements:nN,panes:P,activeSlotCount:tt,onOpenPalette:e2,timeline:(0,eb.jsx)(UB,{rounds:tg,onJumpToRound:tx,activeRunId:Z})}),nD,(0,eb.jsx)(hs,{position:"top-center"})]}):(0,eb.jsxs)("div",{className:"vtl-app-background vtl-agent-conversation-workspace relative h-full min-h-0",children:[nI?(0,eb.jsxs)("div",{className:"relative flex h-full min-h-0",children:[(0,eb.jsx)("div",{className:"pointer-events-none absolute inset-0 -z-10 opacity-0","aria-hidden":!0,children:(0,eb.jsx)(mX,{direction:"horizontal",children:nA})}),(0,eb.jsxs)("div",{className:"relative flex h-full min-h-0 min-w-0 basis-[58%] shrink-0 flex-col",children:[(0,eb.jsx)(mX,{direction:"horizontal",children:nz}),(0,eb.jsx)("div",{className:"absolute right-3 top-1.5 z-20",children:nP})]}),(0,eb.jsx)("div",{className:"relative min-h-0 min-w-0 flex-1",children:(0,eb.jsx)(qj,{conversationTitle:e.conversation.title,rootEvents:D,rootOwnerMachineId:e.conversation.ownerMachineId,running:tm,subagentTree:d,baselineSubagentIds:X,activeSubagentPath:s,onSelectMain:()=>c?.([]),onSelectSubagent:e=>c?.([e])})})]}):j&&!P.some(Boolean)?(0,eb.jsxs)("div",{className:"relative flex h-full min-h-0",children:[(0,eb.jsx)("div",{className:"relative flex h-full min-h-0 min-w-0 flex-1 flex-col",children:nO}),(0,eb.jsx)("div",{className:(0,ez.cn)("absolute top-2 z-20 flex items-center gap-2","left"===nE?"right-3":"left-3"),children:(0,eb.jsx)(eeD,{onAddCard:tT,align:"left"===nE?"end":"start"})})]}):j?(0,eb.jsx)("div",{className:"flex h-full min-h-0 overflow-x-auto",children:"left"===nE?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("div",{className:"relative flex h-full min-h-0 min-w-[20rem] flex-1 flex-col",children:nO}),(0,eb.jsx)("div",{className:"flex h-full min-h-0 shrink-0 flex-col",children:nT})]}):(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("div",{className:"flex h-full min-h-0 shrink-0 flex-col",children:nT}),(0,eb.jsx)("div",{className:"relative flex h-full min-h-0 min-w-[20rem] flex-1 flex-col",children:nO})]})}):S?(0,eb.jsxs)("div",{className:"group/panes relative flex h-full min-h-0",children:[(0,eb.jsx)("div",{className:"pointer-events-none absolute inset-0 -z-10 opacity-0","aria-hidden":!0,children:(0,eb.jsx)(mX,{direction:"horizontal",children:nA})}),(0,eb.jsx)("div",{className:"relative flex h-full min-h-0 min-w-0 flex-1 flex-col",children:nO}),nR]}):(0,eb.jsxs)("div",{className:"group/panes relative flex h-full min-h-0",children:[(0,eb.jsxs)(mX,{direction:"horizontal",defaultLayout:{agent:nC,panes:nM},onLayoutChanged:e=>{let t=e.agent??nC,n=e.panes??nM;!function(e){let t=eeJ(e),n=t[0],r=t[1];if(void 0===n||void 0===r)return;let a="left"===b?{agent:n,panes:r}:{agent:r,panes:n};I(e=>{let t=e.shell?.agent,n=e.shell?.panes;return .01>Math.abs((t??0)-a.agent)&&.01>Math.abs((n??0)-a.panes)?e:{...e,shell:{...e.shell,...a}}})}("left"===nE?[t,n]:[n,t])},children:["left"===nE?nz:nA,(0,eb.jsx)(mZ,{withHandle:!0}),"left"===nE?nA:nz]},`${e?.conversation.id??"empty"}-${nE}`),nR]}),nD,(0,eb.jsx)(hs,{position:"top-right"})]}):(0,eb.jsx)(kk,{onCreated:e=>o?.(e),onCancel:l})}function ee7({open:e,conversationId:t,ownerMachineId:n,tab:r,onOpenChange:a,onSelectVersion:i}){let[o,l]=ew.useState([]),[s,c]=ew.useState(!1),d=r?.file?.path,u=r?.file?.machineId??"local";return ew.useEffect(()=>{if(!e||!t||!d)return void l([]);let r=!1;return c(!0),cn(t,{machineId:u,path:d},n).then(e=>{r||l(e.versions)}).catch(()=>{r||l([])}).finally(()=>{r||c(!1)}),()=>{r=!0}},[t,n,u,e,d]),(0,eb.jsx)(dX,{open:e,onOpenChange:a,children:(0,eb.jsxs)(fU,{className:"max-w-xl gap-0 overflow-hidden p-0",children:[(0,eb.jsx)(fK,{className:"sr-only",children:"历史版本"}),(0,eb.jsx)(fG,{className:"sr-only",children:"浏览当前文件在此 Agent 会话中的修改历史。"}),(0,eb.jsxs)("div",{className:"border-b px-4 py-3",children:[(0,eb.jsx)("div",{className:"truncate text-sm font-medium",children:r?.file?.name??r?.title??"文件"}),d?(0,eb.jsxs)("div",{className:"mt-0.5 truncate ui-text-kbd text-muted-foreground",children:[u,":",d]}):null]}),(0,eb.jsx)("div",{className:"max-h-[28rem] overflow-auto p-2",children:s?(0,eb.jsx)("div",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:"正在读取历史版本"}):0===o.length?(0,eb.jsx)("div",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:"还没有记录到这个文件的修改历史"}):(0,eb.jsx)("div",{className:"grid gap-1",children:o.map(e=>{var t;let n;return(0,eb.jsxs)("button",{type:"button",className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-3 rounded-md px-3 py-2 text-left transition-colors hover:bg-muted/70",onClick:()=>i(e),children:[(0,eb.jsxs)("span",{className:"min-w-0",children:[(0,eb.jsxs)("span",{className:"block truncate text-sm font-medium",children:[ee9(e.mutationId)," ·"," ","before"===e.state?"修改前":"修改后"]}),(0,eb.jsx)("span",{className:"mt-0.5 block truncate ui-text-kbd text-muted-foreground",children:Number.isFinite(n=Date.parse(t=e.createdAt))?new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(n):t})]}),(0,eb.jsxs)("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,eb.jsxs)("b",{className:"font-medium text-emerald-600",children:["+",e.additions??0]}),(0,eb.jsxs)("b",{className:"font-medium text-rose-600",children:["-",e.deletions??0]})]})]},e.id)})})})]})})}function ee9(e){return e.replace(/^mut-/,"").slice(0,16)}function ete({className:e,orientation:t="horizontal",...n}){return(0,eb.jsx)("div",{role:"separator","aria-orientation":t,"data-slot":"separator","data-orientation":t,className:(0,ez.cn)("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",e),...n})}let ett=(0,l0.cva)("group/item flex w-full flex-wrap items-center rounded-lg border text-sm transition-colors duration-100 outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 [a]:transition-colors [a]:hover:bg-muted",{variants:{variant:{default:"border-transparent",outline:"border-border",muted:"border-transparent bg-muted/50"},size:{default:"gap-2.5 px-3 py-2.5",sm:"gap-2.5 px-3 py-2.5",xs:"gap-2 px-2.5 py-2"}},defaultVariants:{variant:"default",size:"default"}});function etn({className:e,variant:t="default",size:n="default",asChild:r=!1,...a}){let i=r?lQ.Slot:"div";return(0,eb.jsx)(i,{"data-slot":"item","data-variant":t,"data-size":n,className:(0,ez.cn)(ett({variant:t,size:n,className:e})),...a})}let etr=(0,l0.cva)("flex shrink-0 items-center justify-center gap-2 [&_svg]:pointer-events-none",{variants:{variant:{default:"bg-transparent",icon:"[&_svg:not([class*='size-'])]:size-4",marker:"size-8 rounded-md border bg-background ui-text-kbd font-medium text-muted-foreground [&_svg:not([class*='size-'])]:size-4",image:"size-10 overflow-hidden rounded-sm group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 [&_img]:size-full [&_img]:object-cover"},align:{auto:"group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start",start:"translate-y-0.5 self-start",center:"self-center"}},defaultVariants:{variant:"default",align:"auto"}});function eta({className:e,variant:t="default",align:n="auto",...r}){return(0,eb.jsx)("div",{"data-slot":"item-media","data-variant":t,"data-align":n,className:(0,ez.cn)(etr({variant:t,align:n,className:e})),...r})}function eti({className:e,align:t,...n}){return(0,eb.jsx)("div",{"data-slot":"item-content","data-align":t,className:(0,ez.cn)("flex flex-1 flex-col gap-1 group-data-[size=xs]/item:gap-0 [&+[data-slot=item-content]]:flex-none","start"===t&&"self-start","center"===t&&"self-center",e),...n})}function eto({className:e,...t}){return(0,eb.jsx)("div",{"data-slot":"item-title",className:(0,ez.cn)("line-clamp-1 flex w-fit items-center gap-2 text-sm leading-snug font-medium underline-offset-4",e),...t})}function etl({className:e,...t}){return(0,eb.jsx)("p",{"data-slot":"item-description",className:(0,ez.cn)("line-clamp-2 text-left text-sm leading-normal font-normal text-muted-foreground group-data-[size=xs]/item:text-xs [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",e),...t})}function ets({className:e,...t}){return(0,eb.jsx)("div",{"data-slot":"item-actions",className:(0,ez.cn)("flex items-center gap-2",e),...t})}let etc={back:"Back",search:"Search settings...",welcomeTitle:"Settings",welcomeDescription:"Search or choose a setting to continue.",recommendations:"Recommended",noResults:"No settings found."},etd=ew.createContext(null);function etu({value:e,children:t}){return(0,eb.jsx)(etd.Provider,{value:e,children:t})}function etf(e){return"string"==typeof e||"number"==typeof e?String(e):""}function etm({sections:e,recommendations:t,sectionId:n,defaultSectionId:r,childId:a,defaultChildId:i,onSelectionChange:o,labels:l,welcomeContent:s,className:c,sidebarClassName:d,contentClassName:u}){let f={...etc,...l},m=sv(),h=ew.useContext(etd),[p,g]=ew.useState(r),[x,v]=ew.useState(i),[b,y]=ew.useState("list"),w=n??p,j=a??x,k=e.find(e=>e.id===w),N=k?.children?.find(e=>e.id===j),S=!!k?.children?.length,C=m&&"detail"===b,M=ew.useMemo(()=>e.flatMap(e=>[{value:e.id,label:e.title,description:e.description,icon:e.icon,searchValue:[etf(e.title),etf(e.description),...e.keywords??[]].join(" "),keywords:e.keywords},...(e.children??[]).map(t=>({value:`${e.id}/${t.id}`,label:t.title,description:e.title,icon:t.icon??e.icon,disabled:t.disabled,searchValue:[etf(t.title),etf(t.description),etf(e.title),...t.keywords??[]].join(" "),keywords:[etf(e.title),...t.keywords??[]]}))]),[e]),E=t??e.flatMap(e=>(e.children??[]).slice(0,2).map(t=>({id:`${e.id}-${t.id}`,title:t.title,description:e.title,icon:t.icon,sectionId:e.id,childId:t.id})));function I(t,r){let i=e.find(e=>e.id===t),l=void 0!==r,s=!!i?.children?.length;void 0===t?y("list"):l||!s?y("detail"):y("list");let c=i?.children?.[0];void 0!==t&&!l&&c&&(r=c.id),void 0===n&&g(t),void 0===a&&v(r),o?.({sectionId:t,childId:r})}let P=N?.content??k?.content??s??(0,eb.jsxs)("div",{className:"mx-auto flex min-h-[22rem] w-full max-w-2xl flex-col justify-center gap-5 py-12",children:[(0,eb.jsxs)("div",{className:"space-y-2",children:[(0,eb.jsx)("h3",{className:"text-xl font-semibold tracking-normal",children:f.welcomeTitle}),(0,eb.jsx)("p",{className:"max-w-xl text-sm text-muted-foreground",children:f.welcomeDescription})]}),(0,eb.jsx)(etp,{labels:f,options:M,onSelect:(e,t)=>I(e,t)}),E.length>0&&(0,eb.jsxs)("section",{className:"space-y-2",children:[(0,eb.jsx)("div",{className:"ui-text-kbd font-medium text-muted-foreground",children:f.recommendations}),(0,eb.jsx)("div",{className:"grid gap-2 sm:grid-cols-2",children:E.map(e=>(0,eb.jsx)(etn,{asChild:!0,variant:"outline",size:"xs",className:"min-h-14 flex-nowrap bg-card text-left hover:bg-muted/60",children:(0,eb.jsxs)("button",{type:"button",onClick:()=>I(e.sectionId,e.childId),children:[e.icon&&(0,eb.jsx)(eta,{variant:"marker",align:"center",children:e.icon}),(0,eb.jsxs)(eti,{className:"min-w-0 gap-0.5",children:[(0,eb.jsx)(eto,{className:"max-w-full truncate",children:e.title}),e.description&&(0,eb.jsx)(etl,{className:"line-clamp-1",children:e.description})]}),(0,eb.jsx)(ets,{className:"ml-auto",children:(0,eb.jsx)(h7,{className:"size-4 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/item:opacity-100"})})]})},e.id))})]})]});return(0,eb.jsxs)("div",{"data-slot":"settings-menu-panel",className:(0,ez.cn)("vtl-surface-panel grid min-h-[34rem] overflow-hidden rounded-[var(--surface-panel-radius)] border md:grid-cols-[15rem_minmax(0,1fr)]",c),children:[m&&C?null:(0,eb.jsx)("aside",{"data-slot":"settings-menu-sidebar",className:(0,ez.cn)("min-h-0 border-b bg-muted/20 md:border-r md:border-b-0",d),children:(0,eb.jsx)(jP,{className:"h-full",children:(0,eb.jsx)("div",{className:"space-y-1 p-2",children:S?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsxs)(eO.Button,{type:"button",variant:"ghost",className:"mb-1 h-auto min-h-9 w-full justify-start px-2.5 py-1.5 text-left",onClick:()=>I(void 0,void 0),children:[(0,eb.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center [&_svg]:size-4",children:(0,eb.jsx)(YV.ArrowLeftIcon,{})}),(0,eb.jsx)("span",{className:"min-w-0 truncate",children:f.back})]}),(k?.children??[]).map(e=>(0,eb.jsx)(eth,{title:e.title,icon:e.icon,badge:e.badge,active:e.id===j,disabled:e.disabled,onClick:()=>I(k?.id,e.id)},e.id))]}):(0,eb.jsxs)(eb.Fragment,{children:[m&&h?(0,eb.jsxs)(eO.Button,{type:"button",variant:"ghost",className:"mb-1 h-auto min-h-9 w-full justify-start px-2.5 py-1.5 text-left md:hidden",onClick:()=>h(),children:[(0,eb.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center [&_svg]:size-4",children:(0,eb.jsx)(YV.ArrowLeftIcon,{})}),(0,eb.jsx)("span",{className:"min-w-0 truncate",children:f.back})]}):null,e.map(e=>(0,eb.jsx)(eth,{title:e.title,icon:e.icon,badge:e.badge,active:e.id===w,disabled:e.disabled,onClick:()=>I(e.id,void 0)},e.id))]})})})}),!m||C?(0,eb.jsxs)("main",{"data-slot":"settings-menu-content",className:(0,ez.cn)("min-w-0 bg-[var(--surface-panel)] p-4 md:p-5 animate-in fade-in-0 slide-in-from-right-1 duration-150",u),children:[C?(0,eb.jsxs)(eO.Button,{type:"button",variant:"ghost",className:"mb-3 h-auto min-h-9 justify-start px-2.5 py-1.5 text-left md:hidden",onClick:()=>y("list"),children:[(0,eb.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center [&_svg]:size-4",children:(0,eb.jsx)(YV.ArrowLeftIcon,{})}),(0,eb.jsx)("span",{className:"min-w-0 truncate",children:f.back})]}):null,k?(0,eb.jsx)("div",{className:"mb-4 flex min-h-8 items-center justify-between gap-4",children:(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("h2",{className:"truncate text-lg font-semibold tracking-normal",children:N?.title??k.title}),(N?.description??k.description)&&(0,eb.jsx)("p",{className:"truncate text-sm text-muted-foreground",children:N?.description??k.description})]})}):null,P]},`${w??""}/${j??""}`):null]})}function eth({title:e,icon:t,badge:n,active:r,disabled:a,onClick:i}){return(0,eb.jsxs)(eO.Button,{type:"button",variant:"ghost",disabled:a,onClick:i,className:(0,ez.cn)("h-auto min-h-9 w-full justify-start px-2.5 py-1.5 text-left font-medium",r?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/70 hover:text-foreground"),children:[t&&(0,eb.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center [&_svg]:size-4",children:t}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium",children:e}),n&&(0,eb.jsx)(Vp,{variant:"outline",className:"h-5 shrink-0 px-1.5 ui-text-kbd",children:n}),(0,eb.jsx)(h7,{className:"size-3.5 shrink-0 text-muted-foreground/60"})]})}function etp({labels:e,options:t,onSelect:n}){return(0,eb.jsx)(bU,{options:t,placeholder:e.search,emptyText:e.noResults,className:"w-full",contentClassName:"rounded-lg",onValueChange:e=>{let[t,r]=e.split("/");t&&n(t,r)},renderOption:e=>(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground [&_svg]:size-4",children:e.icon??(0,eb.jsx)(vu,{})}),(0,eb.jsxs)("span",{className:"grid min-w-0 flex-1 gap-0.5",children:[(0,eb.jsx)("span",{className:"truncate",children:e.label}),e.description&&(0,eb.jsx)("span",{className:"truncate text-sm text-muted-foreground",children:e.description})]})]})})}let etg=(0,ek.default)("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]),etx=(0,ek.default)("webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]),etv=(0,ek.default)("package-plus",[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M19 13v6",key:"85cyf1"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);function etb({card:e}){return(0,eb.jsxs)("div",{className:(0,ez.cn)("flex flex-col gap-2 rounded-lg border bg-card p-3",e.shadowed&&"opacity-55"),children:[(0,eb.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("div",{className:"truncate text-sm font-medium",title:e.name,children:e.name}),e.description?(0,eb.jsx)("p",{className:"mt-0.5 line-clamp-2 text-xs text-muted-foreground",children:e.description}):null]}),e.badges&&e.badges.length>0?(0,eb.jsx)("div",{className:"flex shrink-0 flex-col items-end gap-1",children:e.badges.map((e,t)=>(0,eb.jsx)(Vp,{variant:e.variant??"secondary",className:(0,ez.cn)("text-[10px]",e.className),children:e.label},`${e.label}-${t}`))}):null]}),e.detail?(0,eb.jsx)("div",{className:"text-[11px] text-muted-foreground/80",children:e.detail}):null,e.actions?(0,eb.jsx)("div",{className:"mt-auto flex flex-wrap gap-1.5",children:e.actions}):null]})}function ety({title:e,count:t,onRefresh:n,onCreate:r,createLabel:a,headerExtra:i}){return(0,eb.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-baseline gap-2",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold text-foreground",children:e}),void 0!==t?(0,eb.jsx)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:t}):null]}),(0,eb.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[i,r?(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",variant:"outline",className:"h-8",onClick:r,children:[(0,eb.jsx)(lY,{className:"size-4"}),a??"新建"]}):null,n?(0,eb.jsx)(eO.Button,{type:"button",size:"sm",variant:"ghost",className:"h-8",onClick:n,"aria-label":"刷新",children:(0,eb.jsx)(yt,{className:"size-4"})}):null]})]})}function etw({title:e,description:t,cards:n,loading:r,error:a,emptyHint:i,onRefresh:o,onCreate:l,createLabel:s,banner:c,headerExtra:d}){return(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsx)(ety,{title:e,count:n.length,onRefresh:o,onCreate:l,createLabel:s,headerExtra:d}),t?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:t}):null,c,a?(0,eb.jsx)("p",{className:"text-sm text-destructive",children:a}):null,r?(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取…"}):0===n.length?(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:i??"暂无内容。"}):(0,eb.jsx)("div",{className:"grid gap-2 sm:grid-cols-2",children:n.map(e=>(0,eb.jsx)(etb,{card:e},e.key))})]})}function etj({children:e,onClick:t,disabled:n,variant:r="outline",destructive:a}){return(0,eb.jsx)(eO.Button,{type:"button",size:"sm",variant:r,className:(0,ez.cn)("h-7 px-2 text-xs",a&&"text-destructive hover:text-destructive"),onClick:t,disabled:n,children:e})}async function etk(e){let t=await etS(`/api/local/projects/${encodeURIComponent(e)}/file-hooks`);return{folder:t.folder??"",hooks:t.hooks??[]}}async function etN(e,t){let n=await etS(`/api/local/projects/${encodeURIComponent(e)}/file-hooks`,{method:"PUT",body:JSON.stringify({hooks:t})});return{folder:n.folder??"",hooks:n.hooks??t}}async function etS(e,t){let n=await fetch((0,eT.localAPIURL)(e),{cache:"no-store",...t,headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error("string"==typeof r?.error?r.error:"接口调用失败");return r}function etC(e){let t=new URLSearchParams;e?.conversationId&&t.set("conversationId",e.conversationId),e?.workspace&&t.set("workspace",e.workspace);let n=t.toString();return n?`?${n}`:""}async function etM(e){return(await etR(`/api/local/skills${etC(e)}`)).skills??[]}async function etE(e,t){return etR(`/api/local/skills/${encodeURIComponent(e)}${etC(t)}`)}async function etI(e){await etR(`/api/local/skills/${encodeURIComponent(e)}`,{method:"DELETE"})}async function etP(e,t){return etR("/api/local/skills/install",{method:"POST",body:JSON.stringify({name:e,...t})})}async function etO(e){let t=new URLSearchParams;e?.scope&&t.set("scope",e.scope),e?.conversationId&&t.set("conversationId",e.conversationId),e?.workspace&&t.set("workspace",e.workspace);let n=t.toString();return(await etR(`/api/local/memory${n?`?${n}`:""}`)).memories??[]}async function etz(e,t,n){return etR(`/api/local/memory/${encodeURIComponent(e)}/${encodeURIComponent(t)}${etC(n)}`)}async function etA(e){return etR("/api/local/memory",{method:"POST",body:JSON.stringify(e)})}async function etT(e,t,n){await etR(`/api/local/memory/${encodeURIComponent(e)}/${encodeURIComponent(t)}${etC(n)}`,{method:"DELETE"})}async function etR(e,t){let n=await fetch((0,eT.localAPIURL)(e),{cache:"no-store",...t,headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error("string"==typeof r?.error?r.error:"skill/memory api failed");return r}function etD({scope:e,workspaceFolder:t,conversationId:n}){let[r,a]=ew.useState([]),[i,o]=ew.useState(!0),[l,s]=ew.useState(""),[c,d]=ew.useState(""),[u,f]=ew.useState(null),[m,h]=ew.useState(!1),p=ew.useMemo(()=>({conversationId:n,workspace:t}),[n,t]),g="global"!==e&&!!(n||t),x=ew.useCallback(async()=>{o(!0),s("");try{a(await etM(p))}catch(e){s(e instanceof Error?e.message:"读取技能失败")}finally{o(!1)}},[p]);async function v(e){h(!0);try{f(await etE(e.name,p))}catch(e){s(e instanceof Error?e.message:"读取技能正文失败")}finally{h(!1)}}async function b(e){d(e.name),s("");try{await etI(e.name),await x()}catch(e){s(e instanceof Error?e.message:"删除失败")}finally{d("")}}async function y(e){if(g){d(e.name),s("");try{await etP(e.name,p),await x()}catch(e){s(e instanceof Error?e.message:"装入工作区失败")}finally{d("")}}}ew.useEffect(()=>{x()},[x]);let w=ew.useMemo(()=>new Set(r.filter(e=>"workspace"===e.scope).map(e=>e.name)),[r]),j="conversation"===e?"对话级":"项目级",k=r.map(t=>{let n="workspace"===t.scope,r="global"!==e&&!n,a=r&&w.has(t.name),i=[];"global"===e?i.push({label:"系统",variant:"default"}):n?i.push({label:j,variant:"default"}):i.push({label:"系统",variant:"secondary"}),a&&i.push({label:"被本级覆盖",variant:"outline",className:"text-amber-600"});let o=function(e){switch(e){case"claude":return{label:"Claude",variant:"outline"};case"codex":case"agents":return{label:"Codex",variant:"outline"};default:return null}}(t.origin);o&&i.push(o),t.source&&i.push({label:t.source,variant:"outline"});let l=(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsxs)(etj,{onClick:()=>void v(t),disabled:m,children:[(0,eb.jsx)(uX,{className:"size-3.5"}),"查看"]}),g&&!n?(0,eb.jsxs)(etj,{onClick:()=>void y(t),disabled:c===t.name,children:[(0,eb.jsx)(etv,{className:"size-3.5"}),"project"===e?"装配到工程":"装入工作区"]}):null,"global"===e?(0,eb.jsxs)(etj,{variant:"ghost",destructive:!0,onClick:()=>void b(t),disabled:c===t.name,children:[(0,eb.jsx)(yn,{className:"size-3.5"}),"删除"]}):null]});return{key:`${t.scope}-${t.name}`,name:t.name,description:t.description,badges:i,inherited:r,shadowed:a,actions:r?(0,eb.jsxs)(etj,{onClick:()=>void v(t),disabled:m,children:[(0,eb.jsx)(uX,{className:"size-3.5"}),"查看"]}):l}});return(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(etw,{title:"技能",description:"global"===e?"系统级技能库,可查看正文、删除。装配到具体工程 / 对话请在对应设置内操作。":`${j}技能(可装配 / 删除)+ 继承的系统级技能(只读,到系统设置编辑)。`,cards:k,loading:i,error:l,emptyHint:"尚无可用技能。可让 agent 把当前流程保存为技能。",onRefresh:()=>void x(),banner:"global"===e||g?"global"!==e?(0,eb.jsx)("p",{className:"rounded-lg border border-dashed px-3 py-2.5 text-xs leading-relaxed text-muted-foreground",children:"以下技能来自工作区文件夹的 .vantaloom / .claude / .codex / .agents 目录,自动扫描并启用,无需手动导入。"}):null:(0,eb.jsx)("p",{className:"rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs leading-relaxed text-amber-700 dark:text-amber-300",children:"尚未设置工作区文件夹,仅能浏览系统级技能。请先在「工作区文件夹」中添加目录,再装配本级技能。"})}),(0,eb.jsx)(dX,{open:!!u,onOpenChange:e=>!e&&f(null),children:(0,eb.jsxs)(fU,{className:"max-h-[85vh] max-w-2xl",children:[(0,eb.jsxs)(fq,{children:[(0,eb.jsx)(fK,{children:u?.name}),(0,eb.jsx)(fG,{children:u?.description})]}),u?.whenToUse?(0,eb.jsxs)("p",{className:"text-xs text-muted-foreground",children:["何时使用:",u.whenToUse]}):null,(0,eb.jsx)(jP,{className:"max-h-[60vh] rounded-md border bg-muted/40",children:(0,eb.jsx)("pre",{className:"whitespace-pre-wrap break-words p-3 text-xs leading-relaxed",children:u?.body||"(无正文)"})})]})})]})}let et_=[{value:"code-style",label:"代码风格"},{value:"pattern",label:"模式"},{value:"spec",label:"规范"},{value:"preference",label:"偏好"},{value:"reference",label:"参考"}];function etL({scope:e,workspaceFolder:t,conversationId:n}){let[r,a]=ew.useState([]),[i,o]=ew.useState(!0),[l,s]=ew.useState(""),[c,d]=ew.useState(""),[u,f]=ew.useState(null),[m,h]=ew.useState(!1),p=ew.useMemo(()=>({conversationId:n,workspace:t}),[n,t]),g="global"===e?"系统":"project"===e?"项目级":"对话级",x=ew.useCallback(async()=>{o(!0),s("");try{a(await etO(p))}catch(e){s(e instanceof Error?e.message:"读取记忆失败")}finally{o(!1)}},[p]);async function v(e){d(e.name);try{let t=await etz(e.scope,e.name,p);f({editing:!0,scope:t.scope,name:t.name,description:t.description,type:t.type,body:t.body})}catch(e){s(e instanceof Error?e.message:"读取记忆正文失败")}finally{d("")}}async function b(){if(u&&u.name.trim()){h(!0),s("");try{await etA({scope:u.scope,name:u.name.trim(),description:u.description.trim(),type:u.type,body:u.body,conversationId:n,workspace:t}),f(null),await x()}catch(e){s(e instanceof Error?e.message:"保存记忆失败")}finally{h(!1)}}}async function y(e){d(e.name),s("");try{await etT(e.scope,e.name,p),await x()}catch(e){s(e instanceof Error?e.message:"删除记忆失败")}finally{d("")}}ew.useEffect(()=>{x()},[x]);let w=r.map(t=>{var n;let r="global"!==e&&"global"===t.scope,a=[{label:(n=t.type,et_.find(e=>e.value===n)?.label??n),variant:"secondary"}];return"global"===t.scope?a.unshift({label:"系统",variant:"global"===e?"default":"secondary"}):"project"===t.scope?a.unshift({label:"项目级",variant:"default"}):a.unshift({label:"对话级",variant:"default"}),{key:`${t.scope}-${t.name}`,name:t.name,description:t.description||"(无描述)",badges:a,inherited:r,detail:t.paths&&t.paths.length>0?(0,eb.jsx)("span",{className:"line-clamp-1",children:t.paths.join(",")}):null,actions:r?null:(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(etj,{onClick:()=>void v(t),disabled:c===t.name,children:"查看 / 编辑"}),(0,eb.jsxs)(etj,{variant:"ghost",destructive:!0,onClick:()=>void y(t),disabled:c===t.name,children:[(0,eb.jsx)(yn,{className:"size-3.5"}),"删除"]})]})}});return(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(etw,{title:"记忆",description:"global"===e?"浏览、新增、编辑与删除系统级记忆。":`${g}记忆(可编辑)+ 继承的系统级记忆(只读)。系统级与本级记忆并存注入,不互相覆盖。`,cards:w,loading:i,error:l,emptyHint:`暂无记忆。`,onRefresh:()=>void x(),onCreate:function(){f({editing:!1,scope:e,name:"",description:"",type:"pattern",body:""})},createLabel:`新增${"系统"===g?"":g}记忆`}),(0,eb.jsx)(dX,{open:!!u,onOpenChange:e=>!e&&f(null),children:(0,eb.jsxs)(fU,{className:"max-h-[85vh] max-w-2xl",children:[(0,eb.jsx)(fq,{children:(0,eb.jsx)(fK,{children:u?.editing?"编辑记忆":"新增记忆"})}),u?(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"名称 (slug)"}),(0,eb.jsx)(eA,{value:u.name,disabled:u.editing,onChange:e=>f({...u,name:e.currentTarget.value}),placeholder:"例如 api-error-handling"})]}),(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"描述"}),(0,eb.jsx)(eA,{value:u.description,onChange:e=>f({...u,description:e.currentTarget.value}),placeholder:"一行用于相关性匹配的描述"})]}),(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"类型"}),(0,eb.jsxs)(gU,{value:u.type,onValueChange:e=>f({...u,type:e}),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:et_.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})]}),(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"正文"}),(0,eb.jsx)(w2,{value:u.body,onChange:e=>f({...u,body:e.currentTarget.value}),rows:10,className:"resize-none text-sm",placeholder:"记忆正文(Markdown)"})]})]}):null,(0,eb.jsxs)(fW,{children:[(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",onClick:()=>f(null),disabled:m,children:"取消"}),(0,eb.jsxs)(eO.Button,{type:"button",onClick:()=>void b(),disabled:m||!u?.name.trim(),children:[(0,eb.jsx)(Xj,{className:"size-4"}),m?"保存中":"保存"]})]})]})})]})}function et$({scope:e,conversationId:t,workspaceFolder:n}){return"global"===e?(0,eb.jsx)(etF,{}):(0,eb.jsx)(etB,{scope:e,conversationId:t,workspaceFolder:n})}function etF(){let[e,t]=ew.useState(""),[n,r]=ew.useState(!0),[a,i]=ew.useState(!1),[o,l]=ew.useState(null),[s,c]=ew.useState(""),d=ew.useRef(""),u=ew.useCallback(async()=>{r(!0),c("");try{let e=await kl(),n=e.systemPrompt?.userPrompt??"";d.current=n,t(n)}catch(e){c(e instanceof Error?e.message:"加载失败")}finally{r(!1)}},[]);async function f(){if(!a){i(!0),c(""),l(null);try{await ks({systemPrompt:{userPrompt:e}}),d.current=e,l(Date.now())}catch(e){c(e instanceof Error?e.message:"保存失败")}finally{i(!1)}}}return ew.useEffect(()=>{u()},[u]),(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsx)(ety,{title:"规则(系统提示词)",onRefresh:()=>void u()}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"兜底系统提示词(SystemPrompt):仅对 vantaloom 引擎对话生效。当某对话未检测到任何项目文档(CLAUDE.md / AGENTS.md / vantaloom.md),也未单独设置时,使用这里的内容作为兜底。"}),s?(0,eb.jsx)("p",{className:"text-sm text-destructive",children:s}):null,(0,eb.jsxs)("div",{className:"grid gap-2 rounded-lg border bg-card p-3",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,eb.jsx)(Vp,{className:"text-[10px]",children:"系统"}),(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",onClick:()=>void f(),disabled:a||n,children:[(0,eb.jsx)(Xj,{className:"size-4"}),a?"保存中":"保存"]})]}),(0,eb.jsx)(w2,{value:e,onChange:e=>{t(e.currentTarget.value),l(null)},placeholder:"例如:始终用中文回复;提交前先跑测试;优先复用现有代码……",rows:8,className:"resize-y text-sm"}),o?(0,eb.jsx)("span",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"已保存"}):null]})]})}function etB({scope:e,conversationId:t,workspaceFolder:n}){let[r,a]=ew.useState([]),[i,o]=ew.useState({}),[l,s]=ew.useState(""),[c,d]=ew.useState(!0),[u,f]=ew.useState(null),[m,h]=ew.useState(""),p="conversation"===e?"对话级":"项目级",g=ew.useCallback(async()=>{d(!0),h("");try{let r=(await kr("conversation"===e?t:void 0,"project"===e?n:void 0)).folders??[];a(r),o(Object.fromEntries(r.map(e=>[e.path,e.vantaloom])));try{let e=await kl();s(e.systemPrompt?.userPrompt??"")}catch{s("")}}catch(e){h(e instanceof Error?e.message:"加载失败")}finally{d(!1)}},[e,t,n]);async function x(r){if(!u){f(r),h("");try{await ka(r,i[r]??"","conversation"===e?t:void 0,"project"===e?n:void 0),await g()}catch(e){h(e instanceof Error?e.message:"保存失败")}finally{f(null)}}}ew.useEffect(()=>{g()},[g]);let v=r.some(e=>(i[e.path]??e.vantaloom)?.trim());return(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsx)(ety,{title:"规则(系统提示词)",onRefresh:()=>void g()}),(0,eb.jsxs)("p",{className:"text-xs text-muted-foreground",children:[p,"规则写入各工作区文件夹的 vantaloom.md,作为系统提示词注入。本级规则会完全覆盖系统兜底提示词。"]}),m?(0,eb.jsx)("p",{className:"text-sm text-destructive",children:m}):null,c||0!==r.length?r.map(e=>{let t=e.docs??[];return(0,eb.jsxs)("div",{className:"grid gap-2 rounded-lg border bg-card p-3",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,eb.jsx)(Vp,{className:"shrink-0 text-[10px]",children:p}),(0,eb.jsx)("span",{className:"truncate text-sm font-medium",title:e.path,children:e.path})]}),(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",onClick:()=>void x(e.path),disabled:u===e.path,children:[(0,eb.jsx)(Xj,{className:"size-4"}),u===e.path?"保存中":"保存到 vantaloom.md"]})]}),t.length>0?(0,eb.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:"用作模板:"}),t.map(t=>(0,eb.jsx)(eO.Button,{type:"button",size:"sm",variant:"ghost",className:"h-7 px-2 text-xs",onClick:()=>o(n=>({...n,[e.path]:t.content})),children:t.name},t.name))]}):(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"未检测到 agent.md / claude.md,可直接编写。"}),(0,eb.jsx)(w2,{value:i[e.path]??"",onChange:t=>o(n=>({...n,[e.path]:t.currentTarget.value})),placeholder:"该级别的系统提示词 / 规范,将写入 vantaloom.md",rows:8,className:"resize-y font-mono text-xs"})]},e.path)}):(0,eb.jsx)("p",{className:"rounded-md border border-dashed px-3 py-4 text-xs text-muted-foreground",children:"还没有可用的工作区文件夹。先在「工作区文件夹」里添加一个本机文件夹。"}),l.trim()?(0,eb.jsxs)("div",{className:`grid gap-2 rounded-lg border bg-card p-3 ${v?"opacity-55":""}`,children:[(0,eb.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,eb.jsx)(Vp,{variant:"secondary",className:"text-[10px]",children:"系统"}),v?(0,eb.jsx)(Vp,{variant:"outline",className:"text-[10px] text-amber-600",children:"未生效(已被本级覆盖)"}):null,(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:"兜底系统提示词(到系统设置编辑)"})]}),(0,eb.jsx)("pre",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap break-words rounded-md border bg-muted/40 p-2 text-xs leading-relaxed text-muted-foreground",children:l})]}):null]})}function etV({scope:e,projectId:t,conversationId:n}){return"conversation"===e&&n?(0,eb.jsx)(etW,{conversationId:n}):"project"===e&&t?(0,eb.jsx)(etK,{projectId:t}):(0,eb.jsx)("p",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"Hook 仅作用于具体的工程或对话。请在工程设置或对话设置中管理 Hook。"})}let etH=[{value:"timer",label:"定时(timer)"},{value:"webhook",label:"Webhook"},{value:"process_exit",label:"进程退出"},{value:"file",label:"文件变化"},{value:"shell_poll",label:"Shell 轮询"},{value:"lifecycle",label:"生命周期"}],etU=[{value:"resume_conversation",label:"唤醒本会话"},{value:"run_command",label:"运行命令"},{value:"start_conversation",label:"新建会话"}];function etq({hook:e,busy:t,onToggle:n,onDelete:r}){let a=e.enabled&&!("disabled"in e&&e.disabled);return(0,eb.jsxs)("div",{className:`flex flex-col gap-1.5 rounded-lg border bg-card p-3 ${a?"":"opacity-60"}`,children:[(0,eb.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,eb.jsx)("div",{className:"min-w-0 flex-1",children:(0,eb.jsx)("span",{className:"block truncate text-sm font-medium leading-5",title:e.name||e.id,children:e.name||e.id||"未命名 Hook"})}),(0,eb.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[n?(0,eb.jsx)(bG,{checked:a,disabled:t,onCheckedChange:()=>n(),"aria-label":"启用/停用 hook"}):null,r?(0,eb.jsx)("button",{type:"button",disabled:t,onClick:()=>r(),"aria-label":"删除 hook",title:"删除 hook",className:"grid size-6 place-items-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-destructive disabled:opacity-50 [&_svg]:size-3.5",children:(0,eb.jsx)(yn,{})}):null]})]}),(0,eb.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[12px] leading-5",children:[(0,eb.jsx)("span",{className:"text-foreground",children:function(e){switch(e.source){case"timer":if(e.cron)return`⏱ cron: ${e.cron}`;if(e.intervalSec&&e.intervalSec>0)return`⏱ 每 ${e.intervalSec}s`;if(e.delaySec&&e.delaySec>0)return`⏱ ${e.delaySec}s 后`;return"⏱ 定时";case"process_exit":return"⛔ 进程退出";case"webhook":return"🔌 webhook";case"file":return`📁 文件变化${e.path?`: ${e.path}`:""}`;case"shell_poll":return`🐚 shell${e.command?`: ${e.command}`:""}`;case"lifecycle":return`🔁 生命周期${e.event?`: ${e.event}`:""}`;default:return e.source}}(e.trigger)}),(0,eb.jsx)("span",{className:"text-muted-foreground/50",children:"→"}),(0,eb.jsx)("span",{className:"text-muted-foreground",children:function(e){switch(e.type){case"resume_conversation":return"唤醒本会话";case"run_command":return`运行命令${e.command?`: ${e.command}`:""}`;case"start_conversation":return"新建会话";default:return e.type}}(e.action)})]})]})}function etW({conversationId:e}){let[t,n]=ew.useState([]),[r,a]=ew.useState(void 0),[i,o]=ew.useState(!1),l=ew.useCallback(async()=>{n(await s1(e))},[e]);async function s(t){a(t);try{let r=await s4(e,t);n(e=>e.map(e=>e.id===t?r:e))}catch{await l()}finally{a(void 0)}}async function c(t){a(t);try{await s5(e,t),n(e=>e.filter(e=>e.id!==t))}catch{await l()}finally{a(void 0)}}async function d(t){let r=await s2(e,t);n(e=>[...e,r])}return ew.useEffect(()=>{let t=!0,r=async()=>{let r=await s1(e);t&&n(r)};r();let a=window.setInterval(r,2e3);return()=>{t=!1,window.clearInterval(a)}},[e]),(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-baseline gap-2",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold text-foreground",children:"Hook"}),(0,eb.jsxs)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[t.filter(e=>e.enabled&&!e.disabled).length,"/",t.length," 启用"]})]}),(0,eb.jsx)("div",{className:"flex shrink-0 items-center gap-1.5",children:(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",variant:"outline",className:"h-8",onClick:()=>o(!0),children:[(0,eb.jsx)(lY,{className:"size-4"}),"新建"]})})]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"本对话的 Hook:外部事件触发后唤醒 / 运行命令 / 新建会话。"}),0===t.length?(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"暂无 hook"}):(0,eb.jsx)("div",{className:"grid gap-2 sm:grid-cols-2",children:t.map(e=>(0,eb.jsx)(etq,{hook:e,busy:r===e.id,onToggle:()=>void s(e.id),onDelete:()=>void c(e.id)},e.id))}),(0,eb.jsx)(etG,{open:i,onOpenChange:o,onCreate:d})]})}function etK({projectId:e}){let[t,n]=ew.useState(""),[r,a]=ew.useState([]),[i,o]=ew.useState(!0),[l,s]=ew.useState(!1),[c,d]=ew.useState(""),[u,f]=ew.useState(!1),[m,h]=ew.useState(!1),[p,g]=ew.useState("[]"),x=ew.useCallback(async()=>{o(!0),d("");try{let t=await etk(e);n(t.folder),a(t.hooks??[])}catch(e){d(e instanceof Error?e.message:"读取工程 Hook 失败")}finally{o(!1)}},[e]);ew.useEffect(()=>{x()},[x]);let v=ew.useCallback(async t=>{s(!0),d("");try{let r=await etN(e,t);n(r.folder),a(r.hooks??t)}catch(e){d(e instanceof Error?e.message:"保存失败"),await x()}finally{s(!1)}},[e,x]);async function b(e){let t=[...r,{...e,enabled:!0}];a(t),await v(t)}async function y(){try{let e=JSON.parse(p);if(!Array.isArray(e))throw Error("内容必须是 Hook 数组(JSON array)");await v(e),h(!1)}catch(e){d(e instanceof Error?e.message:"JSON 无效")}}return(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-baseline gap-2",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold text-foreground",children:"Hook"}),(0,eb.jsxs)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[r.filter(e=>e.enabled??!0).length,"/",r.length," 启用"]})]}),(0,eb.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[(0,eb.jsx)(eO.Button,{type:"button",size:"sm",variant:"ghost",className:"h-8 text-xs",onClick:function(){g(JSON.stringify(r,null,2)),h(!0)},disabled:i,children:"编辑 JSON"}),(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",variant:"outline",className:"h-8",onClick:()=>f(!0),disabled:l,children:[(0,eb.jsx)(lY,{className:"size-4"}),"新建"]})]})]}),(0,eb.jsxs)("p",{className:"text-xs text-muted-foreground",children:["工程 Hook 写入 ",(0,eb.jsx)("code",{className:"font-mono",children:".vantaloom/hooks.json"}),",对本工程的",(0,eb.jsx)("strong",{children:"所有对话"}),"生效。",t?(0,eb.jsxs)("span",{className:"ml-1 break-all text-muted-foreground/70",children:["(",t,")"]}):null]}),c?(0,eb.jsx)("p",{className:"text-sm text-destructive",children:c}):null,i?(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取工程 Hook"}):0===r.length?(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"暂无 hook"}):(0,eb.jsx)("div",{className:"grid gap-2 sm:grid-cols-2",children:r.map((e,t)=>(0,eb.jsx)(etq,{hook:e,busy:l,onToggle:()=>{let e;a(e=r.map((e,n)=>n===t?{...e,enabled:!(e.enabled??!0)}:e)),v(e)},onDelete:()=>{let e;a(e=r.filter((e,n)=>n!==t)),v(e)}},e.id||t))}),(0,eb.jsx)(etG,{open:u,onOpenChange:f,onCreate:b}),(0,eb.jsx)(dX,{open:m,onOpenChange:h,children:(0,eb.jsxs)(fU,{className:"max-w-2xl",children:[(0,eb.jsxs)(fq,{children:[(0,eb.jsx)(fK,{children:"编辑工程 Hook(JSON)"}),(0,eb.jsx)(fG,{children:"直接编辑 .vantaloom/hooks.json 的 Hook 数组。"})]}),(0,eb.jsx)(w2,{value:p,onChange:e=>g(e.currentTarget.value),rows:16,className:"resize-y font-mono text-xs",spellCheck:!1}),(0,eb.jsxs)(fW,{children:[(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",onClick:()=>h(!1),children:"取消"}),(0,eb.jsxs)(eO.Button,{type:"button",onClick:()=>void y(),disabled:l,children:[(0,eb.jsx)(Xj,{className:"size-4"}),"保存"]})]})]})})]})}function etG({open:e,onOpenChange:t,onCreate:n}){let[r,a]=ew.useState(""),[i,o]=ew.useState("timer"),[l,s]=ew.useState("60"),[c,d]=ew.useState(""),[u,f]=ew.useState(""),[m,h]=ew.useState(""),[p,g]=ew.useState("resume_conversation"),[x,v]=ew.useState(""),[b,y]=ew.useState(""),[w,j]=ew.useState(!1),[k,N]=ew.useState(!1),[S,C]=ew.useState("");async function M(){N(!0),C("");try{let e={source:i};"timer"===i?c.trim()?e.cron=c.trim():e.delaySec=Math.max(0,Number(l)||0):"file"===i?e.path=u.trim():"shell_poll"===i&&(e.command=m.trim());let a={type:p};"run_command"===p?a.command=b.trim():x.trim()&&(a.prompt=x.trim()),await n({name:r.trim()||void 0,trigger:e,action:a,once:w}),t(!1)}catch(e){C(e instanceof Error?e.message:"创建 hook 失败")}finally{N(!1)}}return ew.useEffect(()=>{e&&(a(""),o("timer"),s("60"),d(""),f(""),h(""),g("resume_conversation"),v(""),y(""),j(!1),C(""))},[e]),(0,eb.jsx)(dX,{open:e,onOpenChange:t,children:(0,eb.jsxs)(fU,{className:"max-w-md",children:[(0,eb.jsx)(fq,{children:(0,eb.jsx)(fK,{children:"新建 Hook"})}),(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"名称(可选)"}),(0,eb.jsx)(eA,{value:r,onChange:e=>a(e.currentTarget.value),placeholder:"例如 编译完成后继续"})]}),(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"触发源"}),(0,eb.jsxs)(gU,{value:i,onValueChange:e=>o(e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:etH.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})]}),"timer"===i?(0,eb.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"延迟(秒)"}),(0,eb.jsx)(eA,{type:"number",min:0,value:l,onChange:e=>s(e.currentTarget.value),disabled:!!c.trim()})]}),(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"或 cron"}),(0,eb.jsx)(eA,{value:c,onChange:e=>d(e.currentTarget.value),placeholder:"*/5 * * * *"})]})]}):null,"file"===i?(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"监视路径"}),(0,eb.jsx)(eA,{value:u,onChange:e=>f(e.currentTarget.value),placeholder:"例如 ./dist"})]}):null,"shell_poll"===i?(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"轮询命令"}),(0,eb.jsx)(eA,{value:m,onChange:e=>h(e.currentTarget.value),placeholder:"例如 test -f /tmp/done"})]}):null,(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"动作"}),(0,eb.jsxs)(gU,{value:p,onValueChange:e=>g(e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:etU.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})]}),"run_command"===p?(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"命令"}),(0,eb.jsx)(eA,{value:b,onChange:e=>y(e.currentTarget.value),placeholder:"例如 npm run build"})]}):(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"提示词(可选)"}),(0,eb.jsx)(eA,{value:x,onChange:e=>v(e.currentTarget.value),placeholder:"触发时注入的提示词"})]}),(0,eb.jsxs)("label",{className:"flex items-center justify-between gap-2 text-sm",children:[(0,eb.jsx)("span",{children:"仅触发一次"}),(0,eb.jsx)(bG,{checked:w,onCheckedChange:j})]}),S?(0,eb.jsx)("p",{className:"text-xs text-destructive",children:S}):null]}),(0,eb.jsxs)(fW,{children:[(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:k,children:"取消"}),(0,eb.jsx)(eO.Button,{type:"button",onClick:()=>void M(),disabled:k,children:k?"创建中":"创建"})]})]})})}let etX=(0,l0.cva)("vtl-surface-card relative w-full rounded-[var(--surface-card-radius)] border px-4 py-3 text-sm [&>svg]:absolute [&>svg]:top-3.5 [&>svg]:left-4 [&>svg~*]:pl-7",{variants:{variant:{default:"border-border",muted:"border-border bg-muted/40",destructive:"border-destructive/35 bg-destructive/10 text-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}});function etY({className:e,variant:t,...n}){return(0,eb.jsx)("div",{role:"alert","data-slot":"alert",className:(0,ez.cn)(etX({variant:t}),e),...n})}function etZ({className:e,...t}){return(0,eb.jsx)("div",{"data-slot":"alert-title",className:(0,ez.cn)("mb-1 leading-none font-medium",e),...t})}function etJ({className:e,...t}){return(0,eb.jsx)("div",{"data-slot":"alert-description",className:(0,ez.cn)("text-muted-foreground [&_p]:leading-relaxed",e),...t})}var etQ=["PageUp","PageDown"],et0=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],et1={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},et2="Slider",[et5,et4,et3]=hc(et2),[et6,et8]=cC(et2,[et3]),[et7,et9]=et6(et2),ene=ew.forwardRef((e,t)=>{let{name:n,min:r=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:l=!1,minStepsBetweenThumbs:s=0,defaultValue:c=[r],value:d,onValueChange:u=()=>{},onValueCommit:f=()=>{},inverted:m=!1,form:h,...p}=e,g=ew.useRef(new Set),x=ew.useRef(0),v="horizontal"===o,[b=[],y]=cT({prop:d,defaultProp:c,onChange:e=>{let t=[...g.current];t[x.current]?.focus(),u(e)}}),w=ew.useRef(b);function j(e,t,{commit:n}={commit:!1}){let o,l=(String(i).split(".")[1]||"").length,c=pn(Math.round((Math.round((e-r)/i)*i+r)*(o=Math.pow(10,l)))/o,[r,a]);y((e=[])=>{let r=function(e=[],t,n){let r=[...e];return r[n]=t,r.sort((e,t)=>e-t)}(e,c,t);if(!function(e,t){if(t>0)return Math.min(...e.slice(0,-1).map((t,n)=>e[n+1]-t))>=t;return!0}(r,s*i))return e;{x.current=r.indexOf(c);let t=String(r)!==String(e);return t&&n&&f(r),t?r:e}})}return(0,eb.jsx)(et7,{scope:e.__scopeSlider,name:n,disabled:l,min:r,max:a,valueIndexToChangeRef:x,thumbs:g.current,values:b,orientation:o,form:h,children:(0,eb.jsx)(et5.Provider,{scope:e.__scopeSlider,children:(0,eb.jsx)(et5.Slot,{scope:e.__scopeSlider,children:(0,eb.jsx)(v?enr:ena,{"aria-disabled":l,"data-disabled":l?"":void 0,...p,ref:t,onPointerDown:cE(p.onPointerDown,()=>{l||(w.current=b)}),min:r,max:a,inverted:m,onSlideStart:l?void 0:function(e){let t=function(e,t){if(1===e.length)return 0;let n=e.map(e=>Math.abs(e-t)),r=Math.min(...n);return n.indexOf(r)}(b,e);j(e,t)},onSlideMove:l?void 0:function(e){j(e,x.current)},onSlideEnd:l?void 0:function(){let e=w.current[x.current];b[x.current]!==e&&f(b)},onHomeKeyDown:()=>!l&&j(r,0,{commit:!0}),onEndKeyDown:()=>!l&&j(a,b.length-1,{commit:!0}),onStepKeyDown:({event:e,direction:t})=>{if(!l){let n=etQ.includes(e.key)||e.shiftKey&&et0.includes(e.key),r=x.current;j(b[r]+i*(n?10:1)*t,r,{commit:!0})}}})})})})});ene.displayName=et2;var[ent,enn]=et6(et2,{startEdge:"left",endEdge:"right",size:"width",direction:1}),enr=ew.forwardRef((e,t)=>{let{min:n,max:r,dir:a,inverted:i,onSlideStart:o,onSlideMove:l,onSlideEnd:s,onStepKeyDown:c,...d}=e,[u,f]=ew.useState(null),m=(0,cM.useComposedRefs)(t,e=>f(e)),h=ew.useRef(void 0),p=hh(a),g="ltr"===p,x=g&&!i||!g&&i;function v(e){let t=h.current||u.getBoundingClientRect(),a=enp([0,t.width],x?[n,r]:[r,n]);return h.current=t,a(e-t.left)}return(0,eb.jsx)(ent,{scope:e.__scopeSlider,startEdge:x?"left":"right",endEdge:x?"right":"left",direction:x?1:-1,size:"width",children:(0,eb.jsx)(eni,{dir:p,"data-orientation":"horizontal",...d,ref:m,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:e=>{let t=v(e.clientX);o?.(t)},onSlideMove:e=>{let t=v(e.clientX);l?.(t)},onSlideEnd:()=>{h.current=void 0,s?.()},onStepKeyDown:e=>{let t=et1[x?"from-left":"from-right"].includes(e.key);c?.({event:e,direction:t?-1:1})}})})}),ena=ew.forwardRef((e,t)=>{let{min:n,max:r,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:l,onStepKeyDown:s,...c}=e,d=ew.useRef(null),u=(0,cM.useComposedRefs)(t,d),f=ew.useRef(void 0),m=!a;function h(e){let t=f.current||d.current.getBoundingClientRect(),a=enp([0,t.height],m?[r,n]:[n,r]);return f.current=t,a(e-t.top)}return(0,eb.jsx)(ent,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:(0,eb.jsx)(eni,{"data-orientation":"vertical",...c,ref:u,style:{...c.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:e=>{let t=h(e.clientY);i?.(t)},onSlideMove:e=>{let t=h(e.clientY);o?.(t)},onSlideEnd:()=>{f.current=void 0,l?.()},onStepKeyDown:e=>{let t=et1[m?"from-bottom":"from-top"].includes(e.key);s?.({event:e,direction:t?-1:1})}})})}),eni=ew.forwardRef((e,t)=>{let{__scopeSlider:n,onSlideStart:r,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:l,onStepKeyDown:s,...c}=e,d=et9(et2,n);return(0,eb.jsx)(cL.span,{...c,ref:t,onKeyDown:cE(e.onKeyDown,e=>{"Home"===e.key?(o(e),e.preventDefault()):"End"===e.key?(l(e),e.preventDefault()):etQ.concat(et0).includes(e.key)&&(s(e),e.preventDefault())}),onPointerDown:cE(e.onPointerDown,e=>{let t=e.target;t.setPointerCapture(e.pointerId),e.preventDefault(),d.thumbs.has(t)?t.focus():r(e)}),onPointerMove:cE(e.onPointerMove,e=>{e.target.hasPointerCapture(e.pointerId)&&a(e)}),onPointerUp:cE(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&(t.releasePointerCapture(e.pointerId),i(e))})})}),eno="SliderTrack",enl=ew.forwardRef((e,t)=>{let{__scopeSlider:n,...r}=e,a=et9(eno,n);return(0,eb.jsx)(cL.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:t})});enl.displayName=eno;var ens="SliderRange",enc=ew.forwardRef((e,t)=>{let{__scopeSlider:n,...r}=e,a=et9(ens,n),i=enn(ens,n),o=ew.useRef(null),l=(0,cM.useComposedRefs)(t,o),s=a.values.length,c=a.values.map(e=>enh(e,a.min,a.max)),d=s>1?Math.min(...c):0,u=100-Math.max(...c);return(0,eb.jsx)(cL.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:l,style:{...e.style,[i.startEdge]:d+"%",[i.endEdge]:u+"%"}})});enc.displayName=ens;var end="SliderThumb",enu=ew.forwardRef((e,t)=>{let n=et4(e.__scopeSlider),[r,a]=ew.useState(null),i=(0,cM.useComposedRefs)(t,e=>a(e)),o=ew.useMemo(()=>r?n().findIndex(e=>e.ref.current===r):-1,[n,r]);return(0,eb.jsx)(enf,{...e,ref:i,index:o})}),enf=ew.forwardRef((e,t)=>{var n,r,a,i,o;let l,s,{__scopeSlider:c,index:d,name:u,...f}=e,m=et9(end,c),h=enn(end,c),[p,g]=ew.useState(null),x=(0,cM.useComposedRefs)(t,e=>g(e)),v=!p||m.form||!!p.closest("form"),b=gd(p),y=m.values[d],w=void 0===y?0:enh(y,m.min,m.max),j=(n=d,(r=m.values.length)>2?`Value ${n+1} of ${r}`:2===r?["Minimum","Maximum"][n]:void 0),k=b?.[h.size],N=k?(a=k,i=w,o=h.direction,s=enp([0,50],[0,l=a/2]),(l-s(i)*o)*o):0;return ew.useEffect(()=>{if(p)return m.thumbs.add(p),()=>{m.thumbs.delete(p)}},[p,m.thumbs]),(0,eb.jsxs)("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[h.startEdge]:`calc(${w}% + ${N}px)`},children:[(0,eb.jsx)(et5.ItemSlot,{scope:e.__scopeSlider,children:(0,eb.jsx)(cL.span,{role:"slider","aria-label":e["aria-label"]||j,"aria-valuemin":m.min,"aria-valuenow":y,"aria-valuemax":m.max,"aria-orientation":m.orientation,"data-orientation":m.orientation,"data-disabled":m.disabled?"":void 0,tabIndex:m.disabled?void 0:0,...f,ref:x,style:void 0===y?{display:"none"}:e.style,onFocus:cE(e.onFocus,()=>{m.valueIndexToChangeRef.current=d})})}),v&&(0,eb.jsx)(enm,{name:u??(m.name?m.name+(m.values.length>1?"[]":""):void 0),form:m.form,value:y},d)]})});enu.displayName=end;var enm=ew.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{let a=ew.useRef(null),i=(0,cM.useComposedRefs)(a,r),o=gI(t);return ew.useEffect(()=>{let e=a.current;if(!e)return;let n=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set;if(o!==t&&n){let r=new Event("input",{bubbles:!0});n.call(e,t),e.dispatchEvent(r)}},[o,t]),(0,eb.jsx)(cL.input,{style:{display:"none"},...n,ref:i,defaultValue:t})});function enh(e,t,n){return pn(100/(n-t)*(e-t),[0,100])}function enp(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function eng(e){return Array.isArray(e)?e:"number"==typeof e?[e]:void 0}function enx({className:e,defaultValue:t,value:n,min:r=0,max:a=100,...i}){let o=ew.useMemo(()=>eng(n)??eng(t)??[r,a],[t,a,r,n]);return(0,eb.jsxs)(ene,{"data-slot":"slider",defaultValue:eng(t),value:eng(n),min:r,max:a,className:(0,ez.cn)("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-40 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",e),...i,children:[(0,eb.jsx)(enl,{"data-slot":"slider-track",className:"relative grow overflow-hidden rounded-full bg-muted data-[orientation=horizontal]:h-1 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1",children:(0,eb.jsx)(enc,{"data-slot":"slider-range",className:"absolute bg-primary data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"})}),o.map((e,t)=>(0,eb.jsx)(enu,{"data-slot":"slider-thumb",className:"relative block size-3 shrink-0 rounded-full border border-ring bg-white shadow-sm transition-[color,box-shadow] select-none after:absolute after:-inset-2 hover:ring-3 hover:ring-ring/50 focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-hidden active:ring-3 active:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 dark:bg-primary-foreground"},t))]})}function env({dirty:e,saving:t,onSave:n,onReset:r,savedAt:a,error:i,validationMessage:o}){let l=e||!!i||!!a;return(0,eb.jsx)("div",{className:"pointer-events-none sticky inset-x-0 bottom-4 z-10 mt-2 flex justify-center",children:(0,eb.jsxs)("div",{className:(0,ez.cn)("pointer-events-auto flex items-center gap-3 rounded-full border border-border bg-card/95 px-4 py-2 shadow-lg backdrop-blur transition-opacity",l?"opacity-100":"pointer-events-none opacity-0"),children:[i?(0,eb.jsx)("span",{className:"text-xs text-hot-pink",children:i}):o?(0,eb.jsx)("span",{className:"text-xs text-amber-500",children:o}):e?(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:"有未保存的更改"}):a?(0,eb.jsxs)("span",{className:"flex items-center gap-1 text-xs text-emerald-600 dark:text-emerald-400 [&_svg]:size-3.5",children:[(0,eb.jsx)(h6,{}),"已保存"]}):null,e&&r?(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"sm",disabled:t,onClick:r,children:"撤销"}):null,(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",disabled:!e||t||!!o,onClick:n,children:[t?(0,eb.jsx)(eM,{className:"size-4 animate-spin"}):(0,eb.jsx)(h6,{className:"size-4"}),"保存"]})]})})}function enb(e){return{enable:e.memory?.enable??!0,injectBudgetTokens:e.memory?.injectBudgetTokens||2e3,autoCapture:e.memory?.autoCapture??!0}}function eny(){let[e,t]=ew.useState(null),[n,r]=ew.useState(!0),[a,i]=ew.useState(!1),[o,l]=ew.useState(""),[s,c]=ew.useState(!1),[d,u]=ew.useState(null),f=ew.useRef(null);function m(e){t(t=>t?{...t,...e}:t),c(!0),u(null)}async function h(){if(e&&!a){i(!0),l("");try{let n=await ks({memory:e});f.current=n,t(enb(n)),c(!1),u(Date.now())}catch(e){l(e instanceof Error?e.message:"保存失败")}finally{i(!1)}}}return ew.useEffect(()=>{!async function(){try{let e=await kl();f.current=e,t(enb(e))}catch(e){l(e instanceof Error?e.message:"读取记忆配置失败")}finally{r(!1)}}()},[]),n?(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取记忆配置"}):e?(0,eb.jsxs)("div",{className:"grid gap-6 pb-20",children:[o?(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"错误"}),(0,eb.jsx)(etJ,{children:o})]}):null,(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"总开关"}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"启用记忆系统"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"开启后,每次运行会按相关性把记忆正文自动注入系统提示词(类似 CLAUDE.md 自动加载)。"})]}),(0,eb.jsx)(bG,{checked:e.enable,onCheckedChange:e=>m({enable:e})})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"记忆注入 token 预算"}),(0,eb.jsx)("span",{className:"text-sm tabular-nums text-muted-foreground",children:e.injectBudgetTokens})]}),(0,eb.jsx)(enx,{value:[e.injectBudgetTokens],onValueChange:([e])=>m({injectBudgetTokens:e}),min:200,max:8e3,step:100}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"每次运行自动注入的相关记忆正文上限。超出按相关性截断。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"自动捕获记忆"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"在压缩边界 / 计划检查点复用已有摘要,低频派生并去重写入对话记忆(不额外发模型请求)。"})]}),(0,eb.jsx)(bG,{checked:e.autoCapture,onCheckedChange:e=>m({autoCapture:e})})]})]}),(0,eb.jsx)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:(0,eb.jsx)(etL,{scope:"global"})}),(0,eb.jsx)(env,{dirty:s,saving:a,savedAt:d,onSave:()=>void h(),onReset:function(){f.current&&(t(enb(f.current)),c(!1),l(""))}})]}):(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"读取失败"}),(0,eb.jsx)(etJ,{children:o||"无法加载记忆配置"})]})}function enw(e){return{enable:e.skills?.enable??!0,listingBudgetTokens:e.skills?.listingBudgetTokens||1500}}function enj(){let[e,t]=ew.useState(null),[n,r]=ew.useState(!0),[a,i]=ew.useState(!1),[o,l]=ew.useState(""),[s,c]=ew.useState(!1),[d,u]=ew.useState(null),f=ew.useRef(null);function m(e){t(t=>t?{...t,...e}:t),c(!0),u(null)}async function h(){if(e&&!a){i(!0),l("");try{let n=await ks({skills:e});f.current=n,t(enw(n)),c(!1),u(Date.now())}catch(e){l(e instanceof Error?e.message:"保存失败")}finally{i(!1)}}}return ew.useEffect(()=>{!async function(){try{let e=await kl();f.current=e,t(enw(e))}catch(e){l(e instanceof Error?e.message:"读取技能配置失败")}finally{r(!1)}}()},[]),n?(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取技能配置"}):e?(0,eb.jsxs)("div",{className:"grid gap-6 pb-20",children:[o?(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"错误"}),(0,eb.jsx)(etJ,{children:o})]}):null,(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"总开关"}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"启用技能系统"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"开启后,agent 系统提示词会按相关性动态列出可用技能(仅名称+描述),并可懒加载技能正文。"})]}),(0,eb.jsx)(bG,{checked:e.enable,onCheckedChange:e=>m({enable:e})})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"技能清单 token 预算"}),(0,eb.jsx)("span",{className:"text-sm tabular-nums text-muted-foreground",children:e.listingBudgetTokens})]}),(0,eb.jsx)(enx,{value:[e.listingBudgetTokens],onValueChange:([e])=>m({listingBudgetTokens:e}),min:200,max:6e3,step:100}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"每次运行注入到系统提示词的技能清单上限(只计名称+描述+何时使用)。超出按相关性截断。"})]})]}),(0,eb.jsx)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:(0,eb.jsx)(etD,{scope:"global"})}),(0,eb.jsx)(env,{dirty:s,saving:a,savedAt:d,onSave:()=>void h(),onReset:function(){f.current&&(t(enw(f.current)),c(!1),l(""))}})]}):(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"读取失败"}),(0,eb.jsx)(etJ,{children:o||"无法加载技能配置"})]})}enm.displayName="RadioBubbleInput";let enk={skills:"技能",memory:"记忆",hooks:"Hooks",rules:"规则"},enN={skills:(0,eb.jsx)(kV,{}),memory:(0,eb.jsx)(etg,{}),hooks:(0,eb.jsx)(etx,{}),rules:(0,eb.jsx)(uX,{})};function enS(e,t={}){let{projectId:n,conversationId:r,workspaceFolder:a}=t;return("global"===e?["skills","memory","rules"]:["skills","memory","hooks","rules"]).map(t=>({id:t,title:enk[t],icon:enN[t],content:(t=>{switch(t){case"skills":return(0,eb.jsx)(etD,{scope:e,workspaceFolder:a,conversationId:r});case"memory":return(0,eb.jsx)(etL,{scope:e,workspaceFolder:a,conversationId:r});case"hooks":return(0,eb.jsx)(etV,{scope:e,projectId:n,conversationId:r});case"rules":return(0,eb.jsx)(et$,{scope:e,conversationId:r,workspaceFolder:a})}})(t)}))}function enC({scope:e,projectId:t,conversationId:n,workspaceFolder:r}){return"global"===e?(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsx)("header",{className:"flex items-center justify-between gap-3 border-b px-4 py-3",children:(0,eb.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(kV,{}),"扩展 / 资产"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:"扩展 / 资产"})]})}),(0,eb.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,eb.jsx)(etm,{sections:[{id:"skills",title:enk.skills,icon:enN.skills,content:(0,eb.jsx)(enj,{})},{id:"memory",title:enk.memory,icon:enN.memory,content:(0,eb.jsx)(eny,{})},{id:"rules",title:enk.rules,icon:enN.rules,content:(0,eb.jsx)(et$,{scope:"global"})}],defaultSectionId:"skills",labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto"})})]}):null}function enM({skillPolicy:e,memoryPolicy:t,onSkillPolicyChange:n,onMemoryPolicyChange:r}){return(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"本对话策略"}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"技能"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"关闭后,本对话的 agent 不会获得技能工具,系统提示词也不再列出可用技能。"})]}),(0,eb.jsx)(bG,{checked:"off"!==(e||"on"),onCheckedChange:e=>n(e?"on":"off")})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"记忆"}),(0,eb.jsxs)(gU,{value:t||"on",onValueChange:r,children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsxs)(xS,{children:[(0,eb.jsx)(xC,{value:"on",children:"开启(注入 + 可读写)"}),(0,eb.jsx)(xC,{value:"readonly",children:"只读(注入 + 仅可读,禁止写入/删除)"}),(0,eb.jsx)(xC,{value:"off",children:"关闭(不注入、不提供工具)"})]})]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"控制本对话的记忆工具与 <memory> 自动注入。"})]})]})}let enE=[{id:"models",label:"模型"},{id:"tools",label:"工具权限"},{id:"commands",label:"禁止命令"},{id:"folders",label:"工作区文件夹"},{id:"assets",label:"扩展"},{id:"hosts",label:"可访问主机"}];function enI({conversation:e,mainModels:t,ccModel:n="",sessionSettings:r,onMainModelsChange:a,onCcModelChange:i,onSessionSettingsChange:o,onSkillPolicyChange:l,onMemoryPolicyChange:s,onClose:c,onEnterConversation:d}){let[u,f]=ew.useState("models"),m=kt(e.settings.engine),h={models:(0,eb.jsxs)("div",{className:"grid gap-4",children:[(0,eb.jsxs)("div",{className:"grid grid-cols-[5rem_minmax(0,1fr)] items-center gap-3 rounded-lg border bg-card px-3 py-2.5",children:[(0,eb.jsx)("span",{className:"text-sm text-muted-foreground",children:"运行引擎"}),(0,eb.jsx)("span",{className:"truncate text-sm font-medium text-foreground",children:function(e){switch(e){case"claude-code":return"Claude Code";case"reclaude":return"reclaude";default:return"Vantaloom"}}(e.settings.engine)})]}),m?(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsx)("label",{htmlFor:"conversation-cc-model",className:"text-base font-semibold tracking-normal text-foreground",children:"Claude Code 模型"}),(0,eb.jsxs)(gU,{value:""===n?j9:n,onValueChange:e=>i?.(e===j9?"":e),children:[(0,eb.jsx)(xj,{id:"conversation-cc-model",className:"w-full",children:(0,eb.jsx)(gG,{placeholder:"选择 Claude Code 模型"})}),(0,eb.jsx)(xS,{children:ke.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"模型由 Claude Code 提供,不走 Vantaloom 模型路由。"})]}):(0,eb.jsx)(vU,{conversation:e,mainModels:t,onMainModelsChange:a})]}),tools:(0,eb.jsx)(j0,{value:r.allowedTools,onChange:e=>o({...r,allowedTools:e,deniedTools:[]})}),commands:(0,eb.jsx)(j1,{value:r.blockedCommands,onChange:e=>o({...r,blockedCommands:e})}),folders:(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsx)(j2,{title:"可访问的工作区文件夹",value:r.folders,onValueChange:e=>o({...r,folders:m?e.slice(-1):e})}),m?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"Claude Code 仅支持单个工作目录(作为会话的工作根目录)。"}):null]}),hosts:(0,eb.jsx)(j7,{value:r.hosts,onValueChange:e=>o({...r,hosts:e}),disabled:m,hint:m?"Claude Code 的工具锁定在所选 owner 机器本地,可访问主机已锁定。":void 0})},p=enE.filter(e=>"assets"!==e.id||!m).map(t=>"assets"===t.id?{id:t.id,title:t.label,children:[{id:"policy",title:"策略",content:(0,eb.jsx)("div",{className:"w-full",children:(0,eb.jsx)(enM,{skillPolicy:e.settings.skillPolicy,memoryPolicy:e.settings.memoryPolicy,onSkillPolicyChange:e=>l?.(e),onMemoryPolicyChange:e=>s?.(e)})})},...enS("conversation",{conversationId:e.id,workspaceFolder:e.settings.folders?.[0]}).map(e=>({...e,content:(0,eb.jsx)("div",{className:"w-full",children:e.content})}))]}:{id:t.id,title:t.label,content:(0,eb.jsx)("div",{className:"w-full",children:h[t.id]})});return(0,eb.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex items-center gap-2 border-b px-3 py-2.5",children:[(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon","aria-label":"关闭设置",onClick:c,className:"shrink-0",children:(0,eb.jsx)(fV.XIcon,{className:"size-5"})}),(0,eb.jsxs)("button",{type:"button",className:"min-w-0 flex-1 rounded-lg px-2 py-1 text-left transition-colors hover:bg-muted/60",title:"返回该对话",onClick:()=>d?.(e),children:[(0,eb.jsxs)("div",{className:"text-[11px] text-muted-foreground",children:[e.agent," · 会话设置"]}),(0,eb.jsx)("div",{className:"truncate text-sm font-semibold",children:e.title})]})]}),(0,eb.jsx)(etm,{sections:p,sectionId:u,onSelectionChange:({sectionId:e})=>f(e),defaultSectionId:p[0]?.id,labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",contentClassName:"overflow-y-auto pb-[max(1.25rem,env(safe-area-inset-bottom))]"})]})}function enP({conversationId:e,ownerMachineId:t,open:n,onOpenChange:r,onEnterConversation:a}){let[i,o]=ew.useState(),[l,s]=ew.useState(),[c,d]=ew.useState([]),[u,f]=ew.useState(""),[m,h]=ew.useState({folders:[],blockedCommands:[],allowedTools:[],deniedTools:[],plugins:[],hosts:[]});async function p(e){if(!i)return;let n=e.session??m,r=e.mainModels??c,a=e.ccModel??u,l={subagents:i.settings.subagents??[],mainModels:r,folders:n.folders,blockedCommands:n.blockedCommands,allowedTools:n.allowedTools,deniedTools:n.deniedTools,plugins:n.plugins,hosts:n.hosts,permissionMode:n.permissionMode??i.settings.permissionMode,engine:i.settings.engine,ccModel:i.settings.engine?a:void 0,skillPolicy:e.skillPolicy??i.settings.skillPolicy,memoryPolicy:e.memoryPolicy??i.settings.memoryPolicy};try{let e=await sY(i.id,{settings:l},t);o(e.conversation)}catch{}}function g(){o(void 0),s(void 0),r(!1)}return(ew.useEffect(()=>{if(!n||!e)return;let r=!0;return async function(){try{let n=await sD(e,t);if(!r)return;let a=n.conversation;o(a),s(n.conversation.projectId?.trim()||void 0),d(a.settings.mainModels),f(a.settings.ccModel??""),h({folders:a.settings.folders,blockedCommands:a.settings.blockedCommands,allowedTools:a.settings.allowedTools,deniedTools:a.settings.deniedTools,plugins:a.settings.plugins,hosts:a.settings.hosts})}catch{}}(),()=>{r=!1}},[e,n,t]),n&&i)?l?(0,eb.jsx)(enO,{conversation:i,onClose:g,onEnterConversation:()=>{g(),a?.(i.id,t)}}):(0,eb.jsx)(enI,{conversation:i,mainModels:c,ccModel:u,sessionSettings:m,onMainModelsChange:e=>{d(e),p({mainModels:e})},onCcModelChange:e=>{f(e),p({ccModel:e})},onSessionSettingsChange:e=>{h(e),p({session:e})},onSkillPolicyChange:e=>{o(t=>t?{...t,settings:{...t.settings,skillPolicy:e}}:t),p({skillPolicy:e})},onMemoryPolicyChange:e=>{o(t=>t?{...t,settings:{...t.settings,memoryPolicy:e}}:t),p({memoryPolicy:e})},onClose:g,onEnterConversation:e=>{g(),a?.(e.id,t)}}):null}function enO({conversation:e,onClose:t,onEnterConversation:n}){return(0,eb.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex items-center gap-2 border-b px-3 py-2.5",children:[(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon","aria-label":"关闭设置",onClick:t,className:"shrink-0",children:(0,eb.jsx)(fV.XIcon,{className:"size-5"})}),(0,eb.jsxs)("button",{type:"button",className:"min-w-0 flex-1 rounded-lg px-2 py-1 text-left transition-colors hover:bg-muted/60",title:"返回该对话",onClick:n,children:[(0,eb.jsxs)("div",{className:"text-[11px] text-muted-foreground",children:[e.agent," · 会话设置"]}),(0,eb.jsx)("div",{className:"truncate text-sm font-semibold",children:e.title})]})]}),(0,eb.jsx)("div",{className:"flex flex-1 items-center justify-center p-6",children:(0,eb.jsxs)("div",{className:"flex max-w-md flex-col items-center gap-3 rounded-xl border border-border bg-card px-6 py-8 text-center shadow-sm",children:[(0,eb.jsx)("div",{className:"flex size-12 items-center justify-center rounded-full bg-muted text-muted-foreground",children:(0,eb.jsx)(lq,{className:"size-6"})}),(0,eb.jsx)("h2",{className:"text-base font-semibold",children:"由所属工程统一管理"}),(0,eb.jsx)("p",{className:"text-sm leading-relaxed text-muted-foreground",children:"此对话由所属工程统一管理,请前往工程设置修改。"})]})})]})}let enz=[{value:"reclaude",label:"reclaude(RC)"},{value:"claude-code",label:"Claude Code(CC)"}];function enA({open:e,onOpenChange:t,ownerMachineId:n,onEnterConversation:r}){let[a,i]=ew.useState([]),[o,l]=ew.useState(!1),[s,c]=ew.useState(""),[d,u]=ew.useState("reclaude"),[f,m]=ew.useState(""),[h,p]=ew.useState(!1),[g,x]=ew.useState(""),v=sv();ew.useEffect(()=>{if(!e)return;c(""),u("reclaude"),m(""),x("");let t=!0;return l(!0),async function(){let e=await sI(n);t&&(i(e),l(!1))}(),()=>{t=!1}},[e,n]);let b=ew.useMemo(()=>a.find(e=>e.sessionId===s),[a,s]);async function y(){if(b&&!h){p(!0),x("");try{let e=await sP({sessionId:b.sessionId,cwd:b.cwd,title:b.title,engine:d,ccModel:f,projectId:""},n);t(!1),r?.(e.conversation.id,n)}catch(e){x(e instanceof Error?e.message:"导入失败,请稍后重试。")}finally{p(!1)}}}return(0,eb.jsx)(dX,{open:e,onOpenChange:t,children:(0,eb.jsxs)(fU,{className:(0,ez.cn)("flex flex-col gap-4",v?"inset-0 h-svh w-full max-w-none translate-x-0 translate-y-0 rounded-none border-0":"max-h-[85vh] max-w-xl"),children:[(0,eb.jsxs)(fq,{children:[(0,eb.jsx)(fK,{children:"导入 Claude 会话"}),(0,eb.jsx)(fG,{children:"从本机已有的 Claude Code 会话创建对话。继续对话将接续原会话的上下文。"})]}),(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto vtl-scrollbar-hidden",children:o?(0,eb.jsxs)("div",{className:"flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground",children:[(0,eb.jsx)(eM,{className:"size-4 animate-spin"}),"正在扫描本机 Claude 会话…"]}):0===a.length?(0,eb.jsx)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:"未发现本机 Claude 会话"}):(0,eb.jsx)("div",{className:"space-y-1",children:a.map(e=>{let t=e.sessionId===s,n=function(e){let t=Date.parse(e);if(!Number.isFinite(t))return"";let n=Math.max(0,Math.floor((Date.now()-t)/1e3));if(n<60)return"刚刚";let r=Math.floor(n/60);if(r<60)return`${r} 分钟前`;let a=Math.floor(r/60);if(a<24)return`${a} 小时前`;let i=Math.floor(a/24);return 1===i?"昨天":i<7?`${i} 天前`:new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric"}).format(t)}(e.lastActivityAt);return(0,eb.jsxs)("button",{type:"button",onClick:()=>c(e.sessionId),className:(0,ez.cn)("w-full rounded-lg border px-3 py-2.5 text-left transition-colors",t?"border-primary bg-primary/5":"border-border hover:bg-muted/60"),children:[(0,eb.jsx)("div",{className:"truncate text-sm font-semibold text-foreground",children:e.title||"未命名会话"}),(0,eb.jsxs)("div",{className:"mt-0.5 flex items-center gap-1 text-xs text-muted-foreground",children:[(0,eb.jsx)(b3,{className:"size-3 shrink-0"}),(0,eb.jsx)("span",{className:"truncate",children:e.cwd})]}),(0,eb.jsxs)("div",{className:"mt-1 flex items-center gap-2 text-[11px] text-muted-foreground/80",children:[n?(0,eb.jsx)("span",{children:n}):null,n?(0,eb.jsx)("span",{children:"·"}):null,(0,eb.jsxs)("span",{children:[e.messageCount," 条消息"]})]})]},e.sessionId)})})}),b?(0,eb.jsxs)("div",{className:"grid gap-3 border-t pt-4",children:[(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"引擎"}),(0,eb.jsxs)(gU,{value:d,onValueChange:e=>u(e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{placeholder:"选择运行引擎"})}),(0,eb.jsx)(xS,{children:enz.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})]}),(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"CC 模型"}),(0,eb.jsxs)(gU,{value:""===f?j9:f,onValueChange:e=>m(e===j9?"":e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{placeholder:"选择 Claude Code 模型"})}),(0,eb.jsx)(xS,{children:ke.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground/80",children:"其余设置(工作目录等)将按所选会话自动导入。"})]}):null,g?(0,eb.jsx)("p",{className:"text-sm text-destructive",children:g}):null,(0,eb.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:h,children:"取消"}),(0,eb.jsx)(eO.Button,{type:"button",onClick:()=>void y(),disabled:!b||h,children:h?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(eM,{className:"size-4 animate-spin"}),"导入中…"]}):"导入并打开"})]})]})})}function enT(e){return!e||"local"===e}async function enR(e,t){return en$(await enF(t,`/${encodeURIComponent(e)}`),t)}async function enD(e,t){return en$(await enF(t,"",{method:"POST",body:JSON.stringify({title:e.title,nodes:e.nodes.map(fo),edges:e.edges.map(fl)})}),t)}async function en_(e,t,n){return en$(await enF(n,`/${encodeURIComponent(e)}/save`,{method:"PUT",body:JSON.stringify({nodes:t.nodes.map(fo),edges:t.edges.map(fl),nodeIds:t.nodeIds})}),n)}async function enL(e,t){return en$(await enF(t,`/${encodeURIComponent(e)}/open`,{method:"POST"}),t)}function en$(e,t){var n,r;let a;return{canvas:(n=e.canvas,a=enT(r=t)?n.ownerMachineId??"local":r,{id:n.id,title:n.title||"新画布",ownerMachineId:a,nodeCount:n.nodeCount??0,running:n.running??!1,createdAt:n.createdAt,updatedAt:n.updatedAt,lastOpenedAt:n.lastOpenedAt}),nodes:e.nodes??[],edges:e.edges??[]}}async function enF(e,t,n,r){let a=await fetch((0,eT.localAPIURL)(enT(e)?`/api/local/canvas${t}`:`/v1/remote/${e}/canvas${t}`),{cache:"no-store",...n,headers:{...n?.body?{"Content-Type":"application/json"}:{},...n?.headers}});if(r?.allowNotFound&&404===a.status)return;let i=await a.json().catch(()=>({}));if(!a.ok)throw Error("string"==typeof i?.error?i.error:"canvas api failed");return i}let enB=(0,ek.default)("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]),enV=(0,ek.default)("lock-keyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]),enH=(0,ek.default)("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),enU=(0,ek.default)("plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]),enq=(0,ek.default)("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),enW=(0,ek.default)("sliders-horizontal",[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]),enK={done:"Done",current:"Current",queued:"Queued",blocked:"Blocked"};function enG(e,t,n){return Math.min(Math.max(e,t),n)}function enX({items:e,currentId:t,labels:n,scrollCurrentIntoView:r=!0,className:a,viewportClassName:i,itemClassName:o,extendLineToViewport:l=!1,...s}){let c={...enK,...n},d=ew.useRef(null),u=ew.useRef(null),f=ew.useRef(null),m=ew.useRef(0),h=ew.useRef(void 0),[p,g]=ew.useState(0),x=t??e.find(e=>"current"===e.status)?.id,v=ew.useCallback(()=>{void 0!==h.current&&(cancelAnimationFrame(h.current),h.current=void 0)},[]),b=ew.useCallback((e,t=340)=>{let n=d.current,r=u.current;if(!n||!r)return;v();let a=Math.max(0,n.scrollHeight-n.clientHeight),i=n.scrollTop,o=enG(e,0,a),l=performance.now();m.current=o;let s=e=>{let r=enG((e-l)/t,0,1);if(n.scrollTop=i+(o-i)*(1-Math.pow(1-r,3)),r<1){h.current=requestAnimationFrame(s);return}n.scrollTop=o,h.current=void 0};h.current=requestAnimationFrame(s)},[v]),y=ew.useCallback(e=>{let t=d.current,n=u.current;if(!t||!n)return;let r=Math.max(0,t.scrollHeight-t.clientHeight);if(r<=0)return;e.preventDefault();let a=void 0===h.current?t.scrollTop:m.current,i=1===e.deltaMode?32*e.deltaY:2===e.deltaMode?e.deltaY*e.currentTarget.clientHeight:e.deltaY,o=Math.sign(i);if(0===o)return;let l=Array.from(n.querySelectorAll("[data-slot='roadmap-item']")).map(e=>e.offsetTop),s=enG(Math.ceil(Math.abs(i)/160),1,3),c=a;for(let e=0;e<s;e+=1)c=function(e,t,n,r){if(0===e.length)return t;if(n>0)return e.find(e=>e>t+1)??r;for(let n=e.length-1;n>=0;n-=1){let r=e[n];if(void 0!==r&&r<t-1)return r}return 0}(l,c,o,r);b(c)},[b]);return ew.useLayoutEffect(()=>{if(!r)return;let e=d.current,t=u.current,n=f.current;if(!e||!t||!n)return void g(0);let a=n.offsetTop,i=t.scrollHeight-p,o=Math.max(0,e.clientHeight-(i-a));g(e=>Math.abs(e-o)>.5?o:e),requestAnimationFrame(()=>{e.scrollTop=a,m.current=a})},[p,e,x,r]),ew.useEffect(()=>v,[v]),(0,eb.jsx)("div",{"data-slot":"roadmap",className:(0,ez.cn)("min-w-0 text-foreground",a),...s,children:(0,eb.jsx)("div",{"data-slot":"roadmap-viewport",ref:d,onWheel:y,className:(0,ez.cn)("max-h-72 overflow-y-auto overscroll-contain pr-2",i),children:(0,eb.jsxs)("div",{ref:u,className:(0,ez.cn)("relative",l&&"min-h-full"),children:[(0,eb.jsx)("span",{"aria-hidden":"true",className:"absolute top-0 bottom-0 left-[0.3125rem] w-px bg-border"}),e.map(e=>{let t=e.id===x?"current":e.status??"queued";return(0,eb.jsxs)("div",{ref:"current"===t?f:void 0,"data-slot":"roadmap-item","data-status":t,"aria-label":c[t],className:(0,ez.cn)("relative grid grid-cols-[1.5rem_minmax(0,1fr)_auto] items-start gap-2 py-2.5",o),children:[(0,eb.jsx)("span",{"aria-hidden":"true","data-slot":"roadmap-marker",className:(0,ez.cn)("relative z-10 mt-1 size-2.5 rounded-full border bg-background","done"===t&&"border-muted-foreground bg-muted-foreground","current"===t&&"border-primary bg-primary","queued"===t&&"border-border","blocked"===t&&"border-destructive bg-destructive")}),(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("div",{"data-slot":"roadmap-title",className:(0,ez.cn)("text-sm leading-5","queued"===t&&"text-muted-foreground","blocked"===t&&"text-destructive"),children:e.title}),e.description?(0,eb.jsx)("div",{"data-slot":"roadmap-description",className:"mt-0.5 text-xs leading-5 text-muted-foreground",children:e.description}):null]}),e.meta?(0,eb.jsx)("div",{"data-slot":"roadmap-meta",className:"pt-0.5 text-right ui-text-kbd text-muted-foreground",children:e.meta}):null]},e.id)}),p>0?(0,eb.jsx)("div",{"aria-hidden":"true","data-slot":"roadmap-bottom-spacer",style:{height:p}}):null]})})})}let enY="/themes/jelly/bg1.png",enZ="/themes/jelly/bg2.png",enJ="/themes/jelly/bg3.png",enQ="/themes/jelly/bg4.png";function en0({image:e,position:t="center",opacity:n=.72,blur:r="10px"}){return{"--vtl-jelly-card-image":`url("${e}")`,"--vtl-jelly-card-position":t,"--vtl-jelly-card-opacity":String(n),"--vtl-jelly-card-blur":r}}function en1({title:e}){return(0,eb.jsx)("h2",{className:"h-7 text-sm font-semibold tracking-normal",children:e})}let en2={product:"Vantaloom",overview:"运维总览",subtitle:"本机服务、工作组机器和 Agent 运行状态。",workgroup:"工作组",health:"系统健康",cost:"今日消耗",activeRuns:"运行中",queue:"排队任务",machineStatus:"机器状态",resourceTrend:"资源趋势",runMix:"运行构成",schedule:"日程提醒",incidents:"关注事项",online:"在线",local:"本机",p2p:"P2P",direct:"直连",sleeping:"休眠",memory:"内存",cpu:"CPU",gpu:"GPU",disk:"磁盘",theme:"主题"},en5={search:"搜索控制台...",dashboard:"仪表盘",canvas:"工程",machines:"机器",schedules:"日程",settings:"设置",overview:"总览",runs:"运行",telemetry:"遥测",canvasRecent:"打开最近工程",canvasNew:"新建工程",canvasAll:"浏览所有画布",projectCanvas:"画布",projectKanban:"看板",projectSettings:"工程设置",projectNewConversation:"新建对话",projectEmpty:"暂无工程",conversationRecent:"打开最近对话",conversationNew:"新建 Agent 对话",conversationAll:"浏览所有对话",fleet:"机器组",access:"访问控制",calendar:"计划任务",billing:"用量与账单"};en2.local,en2.direct,en2.online,en2.p2p,en2.online,en2.direct,en2.sleeping,en2.cpu,en2.memory,en2.activeRuns;function en4(e){return e.reduce((e,t)=>Math.max(e,t.y+t.h),0)}function en3({children:e}){return(0,eb.jsx)("section",{className:"vtl-app-background flex h-full min-h-0 flex-col pb-14 md:pb-0 text-foreground",children:(0,eb.jsx)(jP,{className:"min-h-0 flex-1",children:e})})}function en6(e){return Math.max(0,...e.map(e=>e.y+e.h))}function en8(e,t,n){return t.some(t=>t.id!==n&&e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y)}function en7(e){let t=Math.max(2,Math.min(12,e.w)),n=Math.max(1,e.h),r=Math.max(0,Math.min(12-t,e.x)),a=Math.max(0,e.y);return{...e,x:r,y:a,w:t,h:n}}function en9(e,t,n,r,a){for(let i=0;i<en6(e)+8;i+=1)for(let o=0;o<=12-r;o+=1){let l={id:t,kind:n,x:o,y:i,w:r,h:a};if(!en8(l,e))return l}return{id:t,kind:n,x:0,y:en6(e)+2,w:r,h:a}}function ere(e){return{...e.defaultConfig}}function ert(e){return e.payloads?.[qf]}function ern({open:e,definitions:t,title:n="添加卡片",description:r="搜索并选择要添加到当前页面的卡片。",groupTitle:a="可添加卡片",onOpenChange:i,onAdd:o}){return(0,eb.jsx)(bm,{open:e,onOpenChange:i,title:n,description:r,className:"top-1/2 max-w-xl -translate-y-1/2",children:(0,eb.jsxs)(bf,{loop:!0,children:[(0,eb.jsx)(bh,{placeholder:"搜索可添加卡片..."}),(0,eb.jsxs)(bp,{className:"max-h-[420px]",children:[(0,eb.jsx)(bg,{children:"没有找到可添加的卡片。"}),(0,eb.jsx)(bx,{heading:a,children:t.map(e=>(0,eb.jsxs)(bv,{value:`${e.title} ${e.description}`,keywords:[e.id,e.defaultConfig.dataSource,e.defaultConfig.title],onSelect:()=>o(e.id),className:"min-h-14 items-start py-2",children:[(0,eb.jsx)("span",{className:"mt-0.5 grid size-8 shrink-0 place-items-center rounded-md border bg-background text-muted-foreground",children:e.icon}),(0,eb.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,eb.jsx)("span",{className:"block truncate font-medium",children:e.title}),(0,eb.jsx)("span",{className:"mt-0.5 block truncate ui-text-kbd text-muted-foreground",children:e.description})]}),(0,eb.jsxs)(bb,{children:[e.defaultSize.w,"x",e.defaultSize.h]})]},e.id))})]})]})})}function err({open:e,dragMode:t,label:n="页面卡片操作",onOpenChange:r,onAdd:a,onDragModeChange:i}){let o=[{key:"add",label:"添加卡片",icon:(0,eb.jsx)(lY,{className:"size-4"}),onClick:a,pressed:!1},{key:"drag",label:"拖拽排版",icon:(0,eb.jsx)(lU,{className:"size-4"}),onClick:()=>i(!t),pressed:t}];return(0,eb.jsx)("div",{className:"fixed right-5 bottom-5 z-30",children:(0,eb.jsxs)("div",{className:"relative size-8",children:[o.map((t,n)=>(0,eb.jsx)(eO.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.label,"aria-pressed":t.pressed,onClick:t.onClick,className:(0,ez.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[opacity,transform] duration-150 ease-out",t.pressed&&"border-foreground bg-foreground text-background shadow-lg ring-1 ring-background/50 hover:bg-foreground hover:text-background dark:bg-primary dark:text-primary-foreground dark:hover:bg-primary",e?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0"),style:{transform:e?`translateY(-${(n+1)*42}px)`:void 0},children:t.icon},t.key)),(0,eb.jsx)(eO.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":n,"aria-expanded":e,onClick:()=>r(!e),className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,eb.jsx)(lG,{className:(0,ez.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}let era=(0,ek.default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);function eri({layout:e,layouts:t,cellSize:n,cellHeight:r,dragMode:a,selected:i,resizing:o,onSelect:l,onMove:s,onCut:c,onCopy:d,onSettingsOpen:u,onResizeStart:f,onResizeEnd:m,children:h}){let[p,g]=ew.useState(!1),x=r??n,v=e.x*(n+12),b=e.y*(x+12),y=e.w*n+(e.w-1)*12,w=e.h*x+(e.h-1)*12;return(0,eb.jsxs)("div",{"data-editable-card":e.id,className:(0,ez.cn)("absolute rounded-lg p-1 transition-[left,top,width,height,box-shadow] duration-200 ease-out",a&&"cursor-grab active:cursor-grabbing",p&&"duration-150",i&&!o&&"z-20 shadow-sm",o&&"z-30 transition-none"),style:{left:v,top:b,width:y,height:w},onPointerDown:function(r){if(!a||o)return;let i=r.target;if(i instanceof HTMLElement&&i.closest("[data-editable-card-action]"))return;r.preventDefault(),r.currentTarget.setPointerCapture(r.pointerId),l();let c=r.clientX,d=r.clientY;function u(r){let a=en7({...e,x:e.x+Math.round((r.clientX-c)/(n+12)),y:e.y+Math.round((r.clientY-d)/(n+12))});en8(a,t,e.id)||s(a)}g(!0),window.addEventListener("pointermove",u),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",e),g(!1)})},onClick:()=>{a&&l()},children:[(0,eb.jsx)("div",{className:(0,ez.cn)("size-full",a&&"pointer-events-none"),children:h}),i&&a&&!o?(0,eb.jsx)("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-1 rounded-lg border-2 border-foreground"}):null,i&&a&&!o?(0,eb.jsx)(ero,{onSettingsOpen:u,onCut:c,onCopy:d,onResizeStart:f}):null,o?(0,eb.jsx)(erl,{layout:e,layouts:t,cellSize:n,onResize:s,onResizeEnd:m}):null]})}function ero({onSettingsOpen:e,onCut:t,onCopy:n,onResizeStart:r}){return(0,eb.jsx)(l2,{"data-editable-card-action":!0,placement:"inline",size:"sm","aria-label":"卡片操作",className:"!absolute top-full left-1/2 z-40 mt-2 -translate-x-1/2 rounded-lg bg-popover/95 p-1 shadow-md",onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:(0,eb.jsxs)(l5,{children:[(0,eb.jsx)(l4,{type:"button","aria-label":"调整大小",onClick:r,children:(0,eb.jsx)(lK,{className:"size-4"})}),(0,eb.jsx)(l4,{type:"button","aria-label":"卡片设置",onPointerDown:t=>{t.preventDefault(),t.stopPropagation(),e()},onClick:e=>e.stopPropagation(),children:(0,eb.jsx)(era,{className:"size-4"})}),(0,eb.jsx)(l4,{type:"button","aria-label":"复制",onClick:n,children:(0,eb.jsx)(lV,{className:"size-4"})}),(0,eb.jsx)(l4,{type:"button","aria-label":"剪切",onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),t()},onClick:e=>e.stopPropagation(),children:(0,eb.jsx)(lJ,{className:"size-4"})})]})})}function erl({layout:e,layouts:t,cellSize:n,onResize:r,onResizeEnd:a}){return(0,eb.jsx)("div",{"data-editable-card-action":!0,className:"pointer-events-none absolute inset-1 z-40 border-2 border-foreground",children:[{id:"top-left",className:"top-0 left-0 -translate-x-1/2 -translate-y-1/2 cursor-nwse-resize"},{id:"top",className:"top-0 left-1/2 -translate-x-1/2 -translate-y-1/2 cursor-ns-resize"},{id:"top-right",className:"top-0 right-0 translate-x-1/2 -translate-y-1/2 cursor-nesw-resize"},{id:"right",className:"top-1/2 right-0 translate-x-1/2 -translate-y-1/2 cursor-ew-resize"},{id:"bottom-right",className:"right-0 bottom-0 translate-x-1/2 translate-y-1/2 cursor-nwse-resize"},{id:"bottom",className:"bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2 cursor-ns-resize"},{id:"bottom-left",className:"bottom-0 left-0 -translate-x-1/2 translate-y-1/2 cursor-nesw-resize"},{id:"left",className:"top-1/2 left-0 -translate-x-1/2 -translate-y-1/2 cursor-ew-resize"}].map(i=>(0,eb.jsx)("button",{type:"button","aria-label":`调整 ${i.id}`,className:(0,ez.cn)("pointer-events-auto absolute size-2.5 border border-foreground bg-background shadow-sm",i.className),onPointerDown:o=>(function(i,o){i.preventDefault(),i.stopPropagation(),i.currentTarget.setPointerCapture(i.pointerId);let l=i.clientX,s=i.clientY;function c(a){let i=Math.round((a.clientX-l)/(n+12)),c=Math.round((a.clientY-s)/(n+12)),d={...e};o.includes("right")&&(d.w=e.w+i),o.includes("bottom")&&(d.h=e.h+c),o.includes("left")&&(d.x=e.x+i,d.w=e.w-i),o.includes("top")&&(d.y=e.y+c,d.h=e.h-c),en8(d=en7(d),t,e.id)||r(d)}window.addEventListener("pointermove",c),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",e),a()})})(o,i.id)},i.id))})}function ers({className:e,...t}){return(0,eb.jsx)(d5,{"data-slot":"sheet-overlay",className:(0,ez.cn)("vtl-overlay fixed inset-0 z-50 animate-in fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0",e),...t})}function erc({className:e,children:t,side:n="right",showCloseButton:r=!0,...a}){return(0,eb.jsxs)(d1,{children:[(0,eb.jsx)(ers,{}),(0,eb.jsxs)(d8,{"data-slot":"sheet-content","data-side":n,className:(0,ez.cn)("vtl-surface-modal fixed z-50 flex flex-col gap-4 border transition ease-in-out outline-none data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:animate-in data-[state=open]:duration-300","right"===n&&"inset-y-0 right-0 h-full w-3/4 border-r-0 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm","left"===n&&"inset-y-0 left-0 h-full w-3/4 border-l-0 data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm","top"===n&&"inset-x-0 top-0 h-auto border-t-0 data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top","bottom"===n&&"inset-x-0 bottom-0 h-auto border-b-0 data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",e),...a,children:[t,r&&(0,eb.jsxs)(uo,{className:"absolute top-3 right-3 inline-flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none disabled:pointer-events-none",children:[(0,eb.jsx)(fV.XIcon,{className:"size-4"}),(0,eb.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function erd({className:e,...t}){return(0,eb.jsx)("div",{"data-slot":"sheet-header",className:(0,ez.cn)("grid gap-1.5 p-4 text-left",e),...t})}function eru({className:e,...t}){return(0,eb.jsx)(un,{"data-slot":"sheet-title",className:(0,ez.cn)("text-base leading-none font-semibold text-foreground",e),...t})}function erf({className:e,...t}){return(0,eb.jsx)(ua,{"data-slot":"sheet-description",className:(0,ez.cn)("text-sm text-muted-foreground",e),...t})}function erm({open:e,layout:t,definition:n,config:r,cellSize:a,onOpenChange:i,onConfigChange:o}){let l=t&&a>0?t.w*a+(t.w-1)*12:320,s=t&&a>0?t.h*a+(t.h-1)*12:180;return(0,eb.jsx)(dX,{open:e,onOpenChange:i,children:(0,eb.jsx)(erc,{side:"right",className:"w-screen gap-0 border-0 bg-transparent p-0 shadow-none sm:max-w-none",children:t&&n&&r?(0,eb.jsxs)("div",{className:"grid h-full min-w-0 grid-cols-1 lg:grid-cols-[minmax(0,1fr)_24rem]",children:[(0,eb.jsx)(erh,{width:l,height:s,className:"hidden lg:grid",children:n.render(r)}),(0,eb.jsxs)("div",{className:"animate-in slide-in-from-right-4 flex h-full w-full flex-col border-y-0 border-r-0 bg-background text-foreground shadow-lg duration-300",children:[(0,eb.jsxs)(erd,{className:"border-b",children:[(0,eb.jsx)(eru,{children:"卡片设置"}),(0,eb.jsxs)(erf,{children:[n.title," · ",t.w,"x",t.h]})]}),(0,eb.jsxs)("div",{className:"grid flex-1 content-start gap-4 overflow-y-auto p-4",children:[(0,eb.jsxs)("label",{className:"grid gap-1.5",children:[(0,eb.jsx)("span",{className:"ui-text-control font-medium",children:"显示标题"}),(0,eb.jsx)(eA,{value:r.title,onChange:e=>o({title:e.currentTarget.value})})]}),(0,eb.jsxs)("label",{className:"grid gap-1.5",children:[(0,eb.jsx)("span",{className:"ui-text-control font-medium",children:"数据来源"}),(0,eb.jsx)(eA,{value:r.dataSource,onChange:e=>o({dataSource:e.currentTarget.value})})]}),(0,eb.jsxs)("label",{className:"grid gap-1.5",children:[(0,eb.jsx)("span",{className:"ui-text-control font-medium",children:"刷新间隔"}),(0,eb.jsx)(eA,{value:r.refreshRate,onChange:e=>o({refreshRate:e.currentTarget.value})})]}),(0,eb.jsxs)("label",{className:"grid gap-1.5",children:[(0,eb.jsx)("span",{className:"ui-text-control font-medium",children:"备注"}),(0,eb.jsx)("textarea",{value:r.note,rows:4,className:"min-h-24 resize-none rounded-lg border border-input bg-transparent px-2.5 py-2 ui-text-control transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50",onChange:e=>o({note:e.currentTarget.value})})]}),(0,eb.jsxs)("div",{className:"rounded-lg border bg-muted/20 p-3",children:[(0,eb.jsx)("div",{className:"ui-text-control font-medium",children:"当前绑定"}),(0,eb.jsxs)("div",{className:"mt-2 grid gap-1 ui-text-kbd text-muted-foreground",children:[(0,eb.jsxs)("span",{children:["类型:",n.id]}),(0,eb.jsxs)("span",{children:["来源:",r.dataSource]}),(0,eb.jsxs)("span",{children:["刷新:",r.refreshRate]})]})]})]})]})]}):null})})}function erh({width:e,height:t,className:n,children:r}){let[a,i]=ZC(),o=i.width>0&&i.height>0?Math.min(1,(i.width-32)/e,(i.height-32)/t):1;return(0,eb.jsx)("div",{ref:a,className:(0,ez.cn)("min-h-0 min-w-0 place-items-center overflow-hidden p-4",n),children:(0,eb.jsx)("div",{className:"animate-in fade-in-0 zoom-in-95 origin-center rounded-lg duration-300",style:{width:e,height:t,transform:`scale(${Math.max(.1,o)})`},children:r})})}function erp({boardId:e,definitions:t,initialLayouts:n,clipboardItems:r=[],minRows:a=9,className:i,actionLabel:o,paletteGroupTitle:l,onClipboardItemsChange:s,onOverlayOpenChange:c}){var d;let[u,f]=ew.useState(!1),[m,h]=ew.useState(!1),[p,g]=ew.useState(!1),[x,v]=ew.useState(()=>n),[b,y]=ew.useState({}),[w,j]=ew.useState(),[k,N]=ew.useState(),[S,C]=ew.useState(),M=ew.useRef(0),E=ew.useRef(0),[I,P]=ZC(),O=P.width>0?(d=P.width)<480?2:d<768?4:12:12,z=function(e,t){if(t>=12)return e;let n=[...e].sort((e,t)=>e.y!==t.y?e.y-t.y:e.x-t.x),r=[];for(let e of n){let n=Math.max(2,Math.min(t,Math.round(e.w*t/12))),a=e.h,i=!1;for(let o=0;o<en4(r)+8&&!i;o+=1)for(let l=0;l<=t-n&&!i;l+=1){let t={...e,x:l,y:o,w:n,h:a};!function(e,t){return t.some(t=>e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y)}(t,r)&&(r.push(t),i=!0)}i||r.push({...e,x:0,y:en4(r),w:n,h:a})}return r}(x,O),A=P.width>0?(P.width-12*(O-1))/O:96,T=O<12?72:A,R=Math.max(a,en6(z)+2),D=R*T+(R-1)*12,_=ew.useMemo(()=>new Map(t.map(e=>[e.id,e])),[t]);function L(e){let t=_.get(e.kind);return b[e.id]??(t?ere(t):void 0)}function $(e){v(t=>{let n=en7(e);return en8(n,t,n.id)?t:t.map(e=>e.id===n.id?n:e)})}function F(e){let t=_.get(e);if(!t)return;E.current+=1;let n=`${e}-added-${E.current}`,r=en9(x,n,e,t.defaultSize.w,t.defaultSize.h);v(e=>[...e,r]),y(e=>({...e,[n]:ere(t)})),j(n),N(void 0),h(!1)}function B(e,t){let n=x.find(t=>t.id===e),r=n?_.get(n.kind):void 0;n&&r&&y(n=>({...n,[e]:{...n[e]??ere(r),...t}}))}ew.useEffect(()=>{c?.(m||!!S)},[m,c,S]),ew.useEffect(()=>()=>c?.(!1),[c]),ew.useEffect(()=>{p||(j(void 0),N(void 0))},[p]),ew.useEffect(()=>{if(k)return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e);function e(e){let t=e.target;t instanceof HTMLElement&&t.closest("[data-editable-card-action]")||(j(k),N(void 0))}},[k]);let V=O<12,H=S?x.find(e=>e.id===S):void 0,U=H?_.get(H.kind):void 0,q=H?L(H):void 0;if(V){let n=[...z].sort((e,t)=>e.y-t.y||e.x-t.x),r=Object.fromEntries(x.map(e=>[e.id,e.w]));return(0,eb.jsxs)(en3,{children:[(0,eb.jsx)("div",{ref:I,"data-editable-card-board":e,className:(0,ez.cn)("mx-auto max-w-7xl p-3",i),children:(0,eb.jsx)("div",{className:"grid grid-cols-2 gap-3",children:n.map(e=>{let t=_.get(e.kind);if(!t)return null;let n=L(e);if(!n)return null;let a=(r[e.id]??e.w)>6;return(0,eb.jsx)("div",{className:(0,ez.cn)("min-w-0 overflow-hidden rounded-lg",a&&"col-span-2"),style:{minHeight:a?200:120},children:t.render(n)},e.id)})})}),(0,eb.jsx)(err,{open:u,dragMode:!1,label:o,onOpenChange:f,onAdd:()=>{f(!1),h(!0)},onDragModeChange:g}),(0,eb.jsx)(ern,{open:m,definitions:t,groupTitle:l,onOpenChange:h,onAdd:F}),(0,eb.jsx)(erm,{open:!!(H&&U&&q),layout:H,definition:U,config:q,cellSize:A,onOpenChange:e=>{e||C(void 0)},onConfigChange:e=>{H&&B(H.id,e)}})]})}return(0,eb.jsxs)(en3,{children:[(0,eb.jsx)("div",{ref:I,"data-editable-card-board":e,className:(0,ez.cn)("relative mx-auto max-w-7xl p-4 lg:p-6",p&&"select-none",i),style:{minHeight:D+48},onDragOver:e=>{Array.from(e.dataTransfer.types).includes(qf)&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},onDrop:function(e){let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id");if(!t)return;let n=r.find(e=>e.id===t),a=n&&ert(n);if(!n||!a||!_.has(a.kind))return;e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move";let i=I.current,o=i?.getBoundingClientRect();!function(e,t){let n=ert(e);if(!n||!_.has(n.kind))return;E.current+=1;let r=`${n.kind}-clip-${E.current}`,a=en7({id:r,kind:n.kind,x:t?.x??0,y:t?.y??en6(x),w:n.w,h:n.h}),i=t&&!en8(a,x)?a:en9(x,r,n.kind,n.w,n.h);v(e=>[...e,i]),y(e=>({...e,[r]:{...n.config}})),j(r),N(void 0)}(n,{x:o&&A>0?Math.round((e.clientX-o.left-24)/(A+12)):0,y:o&&A>0?Math.round((e.clientY-o.top-24)/(A+12)):en6(x)})},onPointerDown:e=>{e.target===e.currentTarget&&(j(void 0),p||N(void 0))},children:(0,eb.jsx)("div",{className:"relative",style:{height:D},children:z.map(t=>{let n=_.get(t.kind);if(!n)return null;let r=L(t);return r?(0,eb.jsx)(eri,{layout:t,layouts:z,cellSize:A,cellHeight:T,dragMode:p,selected:w===t.id,resizing:k===t.id,onSelect:()=>{p&&j(t.id)},onMove:$,onCut:()=>(function(t){let n=x.find(e=>e.id===t),r=n?_.get(n.kind):void 0,a=n?L(n):void 0;if(!n||!r||!a)return;let i=function({boardId:e,layout:t,definition:n,config:r}){let a={boardId:e,kind:t.kind,w:t.w,h:t.h,config:{...r}};return{id:`clip-${e}-${t.id}`,title:r.title||n.title,description:n.description,meta:`${t.w}x${t.h}`,icon:n.icon,dragData:{"application/vnd.vantaloom.clip-kind":"workspace-card","application/vnd.vantaloom.workspace-card-board":e,"application/vnd.vantaloom.workspace-card-kind":t.kind,"application/vnd.vantaloom.workspace-card-width":String(t.w),"application/vnd.vantaloom.workspace-card-height":String(t.h),"application/vnd.vantaloom.workspace-card-config":JSON.stringify(r),[qf]:JSON.stringify(a)},payloads:{[qf]:a}}}({boardId:e,layout:n,definition:r,config:a});s?.(e=>[i,...e.filter(e=>e.id!==i.id)]),v(e=>e.filter(e=>e.id!==t)),y(e=>{let n={...e};return delete n[t],n}),j(void 0),N(void 0),C(e=>e===t?void 0:e)})(t.id),onCopy:()=>(function(e){let t=x.find(t=>t.id===e),n=t?_.get(t.kind):void 0;if(!t||!n)return;M.current+=1;let r=`${e}-copy-${M.current}`,a=en9(x,r,t.kind,t.w,t.h);v(e=>[...e,a]),y(t=>({...t,[r]:t[e]??ere(n)})),j(r)})(t.id),onSettingsOpen:()=>C(t.id),onResizeStart:()=>{j(void 0),N(t.id)},onResizeEnd:()=>{j(t.id),N(void 0)},children:n.render(r)},t.id):null})})}),(0,eb.jsx)(err,{open:u,dragMode:p,label:o,onOpenChange:f,onAdd:()=>{f(!1),h(!0)},onDragModeChange:g}),(0,eb.jsx)(ern,{open:m,definitions:t,groupTitle:l,onOpenChange:h,onAdd:F}),(0,eb.jsx)(erm,{open:!!(H&&U&&q),layout:H,definition:U,config:q,cellSize:A,onOpenChange:e=>{e||C(void 0)},onConfigChange:e=>{H&&B(H.id,e)}})]})}function erg({parts:e}){return(0,eb.jsx)(eb.Fragment,{children:e.map((e,t)=>(0,eb.jsx)("span",{className:e.small?"text-[0.55em]":void 0,children:e.text},`${e.text}-${t}`))})}function erx({value:e,minSize:t=24,maxSize:n=180,className:r,...a}){let i=ew.useRef(null),o=ew.useRef(null),[l,s]=ew.useState(t),c=function(e){let t=e.trim();if(/^[$¥€]\s*\d/.test(t))return[{text:t.replace(/^[$¥€]\s*/,""),small:!1},{text:t[0]??"",small:!0}];let n=t.match(/^(.+?)\s*\/\s*(.+)$/);if(n)return[{text:n[1]??"",small:!1},{text:"/",small:!0},{text:n[2]??"",small:!1}];let r=t.match(/^(.+?)([%a-zA-Z$¥€]+)$/);return r?[{text:r[1]??t,small:!1},{text:r[2]??"",small:!0}]:[{text:t,small:!1}]}(e);return ew.useLayoutEffect(()=>{let e=i.current,r=o.current;if(!e||!r)return;function a(e,r){let a=e.clientWidth,i=e.clientHeight;if(a<=0||i<=0)return;let o=t,l=n,c=t;for(;o<=l;){let e=Math.floor((o+l)/2);r.style.fontSize=`${e}px`,r.getBoundingClientRect().width<=a&&r.getBoundingClientRect().height<=i?(c=e,o=e+1):l=e-1}s(c)}a(e,r);let l=new ResizeObserver(()=>a(e,r));return l.observe(e),()=>l.disconnect()},[n,t,e]),(0,eb.jsxs)("div",{ref:i,className:(0,ez.cn)("relative min-h-0 min-w-0 overflow-hidden",r),...a,children:[(0,eb.jsx)("span",{ref:o,"aria-hidden":"true",className:"pointer-events-none invisible absolute right-0 bottom-0 flex items-baseline whitespace-nowrap font-semibold leading-none tracking-normal",children:(0,eb.jsx)(erg,{parts:c})}),(0,eb.jsx)("span",{className:"absolute right-0 bottom-0 flex max-w-full items-baseline whitespace-nowrap font-semibold leading-none tracking-normal text-foreground",style:{fontSize:l},children:(0,eb.jsx)(erg,{parts:c})})]})}function erv(e){return/^\d+$/.test(e)&&1===e.length?`0${e}`:/^\d+(?:\.\d+)?%$/.test(e)?`${Number.parseFloat(e).toFixed(1)}%`:e}function erb({label:e,value:t,minSize:n=42,maxSize:r=180,valueClassName:a="absolute right-0 bottom-0 h-2/3 w-full"}){return(0,eb.jsxs)("div",{className:"relative h-full min-h-0",children:[(0,eb.jsx)("div",{className:"text-xl font-semibold tracking-normal",children:e}),(0,eb.jsx)(erx,{value:erv(t),minSize:n,maxSize:r,className:a})]})}function ery(e){return Math.max(0,Math.min(100,Math.round(e)))}function erw({className:e,value:t=0,...n}){let r=ery(t);return(0,eb.jsx)("div",{"data-slot":"progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r,className:(0,ez.cn)("relative h-1.5 w-full overflow-hidden rounded-full bg-muted",e),...n,children:(0,eb.jsx)("div",{"data-slot":"progress-indicator",className:"h-full rounded-full bg-primary transition-all",style:{width:`${r}%`}})})}function erj({className:e,value:t=0,label:n,showValue:r=!0,...a}){let i=ery(t),o=2*Math.PI*39;return(0,eb.jsxs)("div",{"data-slot":"progress-ring","aria-label":n?`${n} ${i}%`:`${i}%`,role:"img",className:(0,ez.cn)("relative grid size-24 place-items-center",e),...a,children:[(0,eb.jsxs)("svg",{"aria-hidden":"true","data-slot":"progress-ring-svg",viewBox:"0 0 100 100",className:"absolute inset-0 size-full overflow-visible",children:[(0,eb.jsx)("circle",{cx:"50",cy:"50",r:39,fill:"none",stroke:"var(--muted)",strokeWidth:12}),i>0&&(0,eb.jsx)("circle",{cx:"50",cy:"50",r:39,fill:"none",stroke:"var(--primary)",strokeDasharray:o,strokeDashoffset:o-i/100*o,strokeLinecap:"round",strokeWidth:12,className:"origin-center -rotate-90 transition-all"})]}),(0,eb.jsx)("div",{"data-slot":"progress-ring-center",className:"relative z-10 grid size-16 place-items-center rounded-full bg-card",children:r&&(0,eb.jsxs)("span",{className:"ui-text-control font-medium tabular-nums",children:[i,"%"]})})]})}(0,ek.default)("timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);let erk=(0,ek.default)("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);function erN({canvases:e,mode:t="active",scrollable:n=!1,onSelect:r}){let a=ew.useMemo(()=>e.map(e=>{var n;return{id:e.id,status:"live"===(n=e).status?"current":"review"===n.status?"blocked":"done",title:(0,eb.jsx)(erS,{canvas:e,mode:t,onClick:()=>r(e)})}}),[e,t,r]);return(0,eb.jsx)(enX,{items:a,scrollCurrentIntoView:!1,className:(0,ez.cn)("mt-2",n&&"min-h-0 flex-1"),viewportClassName:(0,ez.cn)("max-h-none pr-0",n?"h-full overflow-y-auto":"overflow-visible"),itemClassName:"py-2"})}function erS({canvas:e,onClick:t,mode:n}){return(0,eb.jsxs)("button",{type:"button",className:(0,ez.cn)("grid w-full items-center gap-4 rounded-lg px-2 py-0 text-left transition-colors hover:bg-muted/50","active"===n?"grid-cols-[minmax(0,1fr)_8rem_1.75rem]":"grid-cols-[minmax(0,1fr)_7rem_7rem_8rem]"),onClick:t,children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("div",{className:"truncate text-sm font-medium",children:e.title}),(0,eb.jsx)("div",{className:"truncate text-xs text-muted-foreground",children:"active"===n?e.purpose:`${e.nodes} nodes`})]}),"active"===n?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(erw,{value:e.progress,className:"h-1.5"}),(0,eb.jsx)("span",{"aria-label":e.progress>=100?"Canvas complete":"Canvas incomplete",className:(0,ez.cn)("size-2.5 rounded-full",e.progress>=100?"bg-primary":"bg-border")})]}):(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(erC,{icon:(0,eb.jsx)(HM,{}),value:`${e.snapshots}`}),(0,eb.jsx)(erC,{icon:(0,eb.jsx)(erk,{}),value:e.runtime}),(0,eb.jsx)("div",{className:"text-right ui-text-kbd text-muted-foreground",children:e.lastOpened})]})]})}function erC({icon:e,value:t}){return(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,eb.jsx)("span",{className:"[&_svg]:size-3.5",children:e}),(0,eb.jsx)("span",{className:"tabular-nums",children:t})]})}let erM=(0,ek.default)("memory-stick",[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]]),erE=(0,ek.default)("radio-tower",[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]]),erI=(0,ek.default)("gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);var erP=ew;function erO(){return(erO=Object.assign.bind()).apply(null,arguments)}function erz(e){return ew.createElement(Dg,erO({shapeType:"rectangle",activeClassName:"recharts-active-bar",inActiveClassName:"recharts-inactive-bar"},e))}var erA=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(n,r)=>{if(Nj(e))return e;var a=Nj(n)||null==n;return a?e(n,r):(a||function(e,t){if(!e)throw Error("Invariant failed")}(!1,"minPointSize callback function received a value with type of ".concat(typeof n,". Currently only numbers or null/undefined are supported.")),t)}},erT=["children"],erR=(0,ew.createContext)({data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0});function erD(e){var{children:t}=e,n=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(e,erT);return ew.createElement(erR.Provider,{value:n},t)}var er_=(e,t,n)=>{var r=null!=n?n:e;if(null!=r)return NC(r,t,0)};function erL(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function er$(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?erL(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):erL(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var erF=k9([O0,(e,t)=>t],(e,t)=>e.filter(e=>"bar"===e.type).find(e=>e.id===t)),erB=k9([erF],e=>null==e?void 0:e.maxBarSize),erV=k9([MM,O0,Ja,Ji,(e,t,n)=>n],(e,t,n,r,a)=>t.filter(t=>"horizontal"===e?t.xAxisId===n:t.yAxisId===r).filter(e=>e.isPanorama===a).filter(e=>!1===e.hide).filter(e=>"bar"===e.type)),erH=k9([erV,e=>e.rootProps.barSize,(e,t)=>{var n=MM(e),r=Ja(e,t),a=Ji(e,t);if(null!=r&&null!=a)return"horizontal"===n?Af(e,"xAxis",r):Af(e,"yAxis",a)}],(e,t,n)=>{var r=e.filter(Eh),a=e.filter(e=>null==e.stackId);return[...Object.entries(r.reduce((e,t)=>{var n=e[t.stackId];return null==n&&(n=[]),n.push(t),e[t.stackId]=n,e},{})).map(e=>{var r,[a,i]=e;return{stackId:a,dataKeys:i.map(e=>e.dataKey),barSize:er_(t,n,null==(r=i[0])?void 0:r.barSize)}}),...a.map(e=>({stackId:void 0,dataKeys:[e.dataKey].filter(e=>null!=e),barSize:er_(t,n,e.barSize)}))]}),erU=(e,t,n)=>{var r,a,i=MM(e),o=Ja(e,t),l=Ji(e,t);if(null!=o&&null!=l)return"horizontal"===i?(r=Av(e,"xAxis",o,n),a=Ax(e,"xAxis",o,n)):(r=Av(e,"yAxis",l,n),a=Ax(e,"yAxis",l,n)),NG(r,a)},erq=k9([erH,MH,e=>e.rootProps.barGap,MU,(e,t,n)=>{var r,a,i,o,l=erF(e,t);if(null==l)return 0;var s=Ja(e,t),c=Ji(e,t);if(null==s||null==c)return 0;var d=MM(e),u=MH(e),{maxBarSize:f}=l;return"horizontal"===d?(i=Av(e,"xAxis",s,n),o=Ax(e,"xAxis",s,n)):(i=Av(e,"yAxis",c,n),o=Ax(e,"yAxis",c,n)),null!=(r=null!=(a=NG(i,o,!0))?a:null==f?u:f)?r:0},erU,erB],(e,t,n,r,a,i,o)=>{var l=function(e,t,n,r,a){var i,o,l=r.length;if(!(l<1)){var s=NC(e,n,0,!0),c=[];if(NT(null==(i=r[0])?void 0:i.barSize)){var d=!1,u=n/l,f=r.reduce((e,t)=>e+(t.barSize||0),0);(f+=(l-1)*s)>=n&&(f-=(l-1)*s,s=0),f>=n&&u>0&&(d=!0,u*=.9,f=l*u);var m={offset:((n-f)/2|0)-s,size:0};o=r.reduce((e,t)=>{var n,r={stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:m.offset+m.size+s,size:d?u:null!=(n=t.barSize)?n:0}},a=[...e,r];return m=r.position,a},c)}else{var h=NC(t,n,0,!0);n-2*h-(l-1)*s<=0&&(s=0);var p=(n-2*h-(l-1)*s)/l;p>1&&(p>>=0);var g=NT(a)?Math.min(p,a):p;o=r.reduce((e,t,n)=>[...e,{stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:h+(p+s)*n+(p-g)/2,size:g}}],c)}return o}}(n,r,a!==i?a:i,e,null==o?t:o);return a!==i&&null!=l&&(l=l.map(e=>er$(er$({},e),{},{position:er$(er$({},e.position),{},{offset:e.position.offset-a/2})}))),l}),erW=k9([erq,erF],(e,t)=>{if(null!=e&&null!=t){var n=e.find(e=>e.stackId===t.stackId&&null!=t.dataKey&&e.dataKeys.includes(t.dataKey));if(null!=n)return n.position}}),erK=k9([(e,t,n)=>{var r=MM(e),a=Ja(e,t),i=Ji(e,t);if(null!=a&&null!=i)return"horizontal"===r?zp(e,"yAxis",i,n):zp(e,"xAxis",a,n)},erF],(e,t)=>{var n=Ef(t);if(!e||null==n||null==t)return;var{stackId:r}=t;if(null!=r){var a=e[r];if(a){var{stackedData:i}=a;if(i)return i.find(e=>e.key===n)}}}),erG=k9([N8,N9,(e,t,n)=>{var r=Ja(e,t);if(null!=r)return Av(e,"xAxis",r,n)},(e,t,n)=>{var r=Ji(e,t);if(null!=r)return Av(e,"yAxis",r,n)},(e,t,n)=>{var r=Ja(e,t);if(null!=r)return Ax(e,"xAxis",r,n)},(e,t,n)=>{var r=Ji(e,t);if(null!=r)return Ax(e,"yAxis",r,n)},erW,MM,Na,erU,erK,erF,(e,t,n,r)=>r],(e,t,n,r,a,i,o,l,s,c,d,u,f)=>{var m,{chartData:h,dataStartIndex:p,dataEndIndex:g}=s;if(null!=u&&null!=o&&null!=t&&("horizontal"===l||"vertical"===l)&&null!=n&&null!=r&&null!=a&&null!=i&&null!=c){var{data:x}=u;if(null!=(m=null!=x&&x.length>0?x:null==h?void 0:h.slice(p,g+1)))return function(e){var{layout:t,barSettings:{dataKey:n,minPointSize:r,hasCustomShape:a},pos:i,bandSize:o,xAxis:l,yAxis:s,xAxisTicks:c,yAxisTicks:d,stackedData:u,displayedData:f,offset:m,cells:h,parentViewBox:p,dataStartIndex:g}=e,x="horizontal"===t?s:l,v=u?x.scale.domain():null,b=(e=>{var{numericAxis:t}=e,n=t.scale.domain();if("number"===t.type){var r=Math.min(n[0],n[1]),a=Math.max(n[0],n[1]);return r<=0&&a>=0?0:a<0?a:r}return n[0]})({numericAxis:x}),y=x.scale.map(b);return f.map((e,f)=>{if(u){var x=u[f+g];if(null==x)return null;j=((e,t)=>{if(!t||2!==t.length||!Nj(t[0])||!Nj(t[1]))return e;var n=Math.min(t[0],t[1]),r=Math.max(t[0],t[1]),a=[e[0],e[1]];return(!Nj(e[0])||e[0]<n)&&(a[0]=n),(!Nj(e[1])||e[1]>r)&&(a[1]=r),a[0]>r&&(a[0]=r),a[1]<n&&(a[1]=n),a})(x,v)}else Array.isArray(j=NL(e,n))||(j=[b,j]);var w=erA(r,0)(j[1],f);if("horizontal"===t){var j,k,N,S,C,M,E,I=s.scale.map(j[0]),P=s.scale.map(j[1]);if(null==I||null==P)return null;k=Nq({axis:l,ticks:c,bandSize:o,offset:i.offset,entry:e,index:f}),N=null!=(E=null!=P?P:I)?E:void 0,S=i.size;var O=I-P;if(C=Ny(O)?0:O,M={x:k,y:m.top,width:S,height:m.height},Math.abs(w)>0&&Math.abs(C)<Math.abs(w)){var z=Nb(C||w)*(Math.abs(w)-Math.abs(C));N-=z,C+=z}}else{var A=l.scale.map(j[0]),T=l.scale.map(j[1]);if(null==A||null==T)return null;if(k=A,N=Nq({axis:s,ticks:d,bandSize:o,offset:i.offset,entry:e,index:f}),S=T-A,C=i.size,M={x:m.left,y:N,width:m.width,height:C},Math.abs(w)>0&&Math.abs(S)<Math.abs(w)){var R=Nb(S||w)*(Math.abs(w)-Math.abs(S));S+=R}}return null!=k&&null!=N&&null!=S&&null!=C&&(a||0!==S&&0!==C)?eat(eat({},e),{},{stackedBarStart:y,x:k,y:N,width:S,height:C,value:u?j:j[1],payload:e,background:M,tooltipPosition:{x:k+S/2,y:N+C/2},parentViewBox:p,originalDataIndex:f},h&&h[f]&&h[f].props):null}).filter(Boolean)}({layout:l,barSettings:u,pos:o,parentViewBox:t,bandSize:c,xAxis:n,yAxis:r,xAxisTicks:a,yAxisTicks:i,stackedData:d,displayedData:m,offset:e,cells:f,dataStartIndex:p})}}),erX=(e,t)=>t,erY=(e,t,n)=>n,erZ=k9([erX,O0,erY],(e,t,n)=>t.filter(e=>"bar"===e.type).filter(t=>t.stackId===e).filter(e=>e.isPanorama===n).filter(e=>!e.hide)),erJ=k9([erZ],e=>e.map(e=>e.id)),erQ=k9([e=>e,erX,erY],(e,t,n)=>{var r=erJ(e,t,n),a=[];return r.forEach(t=>{var r=erG(e,t,n,void 0);null==r||r.forEach(e=>{var t=e.originalDataIndex;a[t]=((e,t)=>{if(!e)return t;if(!t)return e;var n=Math.min(e.x,e.x+e.width,t.x,t.x+t.width),r=Math.min(e.y,e.y+e.height,t.y,t.y+t.height);return{x:n,y:r,width:Math.max(e.x,e.x+e.width,t.x,t.x+t.width)-n,height:Math.max(e.y,e.y+e.height,t.y,t.y+t.height)-r}})(a[t],e)})}),a}),er0=["index"];function er1(){return(er1=Object.assign.bind()).apply(null,arguments)}var er2=(0,ew.createContext)(void 0),er5=(e,t)=>"recharts-bar-stack-clip-path-".concat(e,"-").concat(t),er4=e=>{var{index:t}=e,n=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(e,er0),r=(e=>{var t=(0,ew.useContext)(er2);if(null!=t){var{stackId:n}=t;return"url(#".concat(er5(n,e),")")}})(t);return ew.createElement(AJ,er1({className:"recharts-bar-stack-layer",clipPath:r},n))},er3=["onMouseEnter","onMouseLeave","onClick"],er6=["value","background","tooltipPosition"],er8=["id"],er7=["onMouseEnter","onClick","onMouseLeave"];function er9(){return(er9=Object.assign.bind()).apply(null,arguments)}function eae(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function eat(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?eae(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):eae(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ean(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var ear=erP.memo(e=>{var{dataKey:t,stroke:n,strokeWidth:r,fill:a,name:i,hide:o,unit:l,tooltipType:s,id:c}=e,d={dataDefinedOnItem:void 0,getPosition:Nz,settings:{stroke:n,strokeWidth:r,fill:a,dataKey:t,nameKey:void 0,name:NY(i,t),hide:o,type:s,color:a,unit:l,graphicalItemId:c}};return erP.createElement(_u,{tooltipEntrySettings:d})});function eaa(e){var t,n=Sl(Li),{data:r,dataKey:a,background:i,allOtherBarProps:o}=e,{onMouseEnter:l,onMouseLeave:s,onClick:c}=o,d=ean(o,er3),u=_s(l,a,o.id),f=_c(s),m=_d(c,a,o.id);if(!i||null==r)return null;var h=AG(i);return erP.createElement(LX,{zIndex:(t=M2.barBackground,i&&"object"==typeof i&&"zIndex"in i&&"number"==typeof i.zIndex&&NT(i.zIndex)?i.zIndex:t)},r.map((e,t)=>{var{value:r,background:o,tooltipPosition:l}=e,s=ean(e,er6);if(!o)return null;var c=u(e,t),p=f(e,t),g=m(e,t),x=eat(eat(eat(eat(eat({option:i,isActive:String(t)===n},s),{},{fill:"#eee"},o),h),Tb(d,e,t)),{},{onMouseEnter:c,onMouseLeave:p,onClick:g,dataKey:a,index:t,className:"recharts-bar-background-rectangle"});return erP.createElement(erz,er9({key:"background-bar-".concat(t)},x))}))}function eai(e){var{showLabels:t,children:n,rects:r}=e,a=null==r?void 0:r.map(e=>{var t={x:e.x,y:e.y,width:e.width,lowerWidth:e.width,upperWidth:e.width,height:e.height};return eat(eat({},t),{},{value:e.value,payload:e.payload,parentViewBox:e.parentViewBox,viewBox:t,fill:e.fill})});return erP.createElement($c,{value:t?a:void 0},n)}function eao(e){var t,{shape:n,activeBar:r,baseProps:a,entry:i,index:o,dataKey:l}=e,s=Sl(Li),c=Sl(Ll),d=r&&String(i.originalDataIndex)===s&&(null==c||l===c),[u,f]=(0,erP.useState)(!1),[m,h]=(0,erP.useState)(!1);(0,erP.useEffect)(()=>{var e;return d?(f(!0),e=requestAnimationFrame(()=>{h(!0)})):h(!1),()=>{cancelAnimationFrame(e)}},[d]);var p=(0,erP.useCallback)(()=>{d||f(!1)},[d]),g=d&&m,x=d||u;t=d?!0===r?n:r:n;var v=erP.createElement(erz,er9({},a,{name:String(a.name)},i,{isActive:g,option:t,index:o,dataKey:l,onTransitionEnd:p}));return x?erP.createElement(LX,{zIndex:M2.activeBar},erP.createElement(er4,{index:i.originalDataIndex},v)):v}function eal(e){var{shape:t,baseProps:n,entry:r,index:a,dataKey:i}=e;return erP.createElement(erz,er9({},n,{name:String(n.name)},r,{isActive:!1,option:t,index:a,dataKey:i}))}function eas(e){var t,{data:n,props:r}=e,a=null!=(t=AK(r))?t:{},{id:i}=a,o=ean(a,er8),{shape:l,dataKey:s,activeBar:c}=r,{onMouseEnter:d,onClick:u,onMouseLeave:f}=r,m=ean(r,er7),h=_s(d,s,i),p=_c(f),g=_d(u,s,i);return n?erP.createElement(erP.Fragment,null,n.map((e,t)=>erP.createElement(er4,er9({index:e.originalDataIndex,key:"rectangle-".concat(null==e?void 0:e.x,"-").concat(null==e?void 0:e.y,"-").concat(null==e?void 0:e.value,"-").concat(t),className:"recharts-bar-rectangle"},Tb(m,e,t),{onMouseEnter:h(e,t),onMouseLeave:p(e,t),onClick:g(e,t)}),c?erP.createElement(eao,{shape:l,activeBar:c,baseProps:o,entry:e,index:t,dataKey:s}):erP.createElement(eal,{shape:l,baseProps:o,entry:e,index:t,dataKey:s})))):null}function eac(e){var{props:t,previousRectanglesRef:n}=e,{data:r,layout:a,isAnimationActive:i,animationBegin:o,animationDuration:l,animationEasing:s,onAnimationEnd:c,onAnimationStart:d}=t,u=n.current,f=RP(t,"recharts-bar-"),[m,h]=(0,erP.useState)(!1),p=(0,erP.useCallback)(()=>{"function"==typeof c&&c(),h(!1)},[c]),g=(0,erP.useCallback)(()=>{"function"==typeof d&&d(),h(!0)},[d]);return erP.createElement(eai,{showLabels:!m,rects:r},erP.createElement(RI,{animationId:f,begin:o,duration:l,isActive:i,easing:s,onAnimationEnd:p,onAnimationStart:g,key:f},e=>{var i=1===e?r:null==r?void 0:r.map((t,n)=>{var r=u&&u[n];if(r)return eat(eat({},t),{},{x:NE(r.x,t.x,e),y:NE(r.y,t.y,e),width:NE(r.width,t.width,e),height:NE(r.height,t.height,e)});if("horizontal"===a){var i=NE(0,t.height,e),o=NE(t.stackedBarStart,t.y,e);return eat(eat({},t),{},{y:o,height:i})}var l=NE(0,t.width,e),s=NE(t.stackedBarStart,t.x,e);return eat(eat({},t),{},{width:l,x:s})});return(e>0&&(n.current=null!=i?i:null),null==i)?null:erP.createElement(AJ,null,erP.createElement(eas,{props:t,data:i}))}),erP.createElement($m,{label:t.label}),t.children)}function ead(e){var t=(0,erP.useRef)(null);return erP.createElement(eac,{previousRectanglesRef:t,props:e})}var eau=(e,t)=>{var n=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:n,errorVal:NL(e,t)}};class eaf extends erP.PureComponent{render(){var{hide:e,data:t,dataKey:n,className:r,xAxisId:a,yAxisId:i,needClip:o,background:l,id:s}=this.props;if(e||null==t)return null;var c=(0,kq.clsx)("recharts-bar",r);return erP.createElement(AJ,{className:c,id:s},o&&erP.createElement("defs",null,erP.createElement(Jr,{clipPathId:s,xAxisId:a,yAxisId:i})),erP.createElement(AJ,{className:"recharts-bar-rectangles",clipPath:o?"url(#clipPath-".concat(s,")"):void 0},erP.createElement(eaa,{data:t,dataKey:n,background:l,allOtherBarProps:this.props}),erP.createElement(ead,this.props)))}}var eam={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:0,xAxisId:0,yAxisId:0,zIndex:M2.bar};function eah(e){var t,{xAxisId:n,yAxisId:r,hide:a,legendType:i,minPointSize:o,activeBar:l,animationBegin:s,animationDuration:c,animationEasing:d,isAnimationActive:u}=e,{needClip:f}=Jn(n,r),m=Sl(MM),h=Mn(),p=Ri(e.children,T9),g=Sl(t=>erG(t,e.id,h,p));if("vertical"!==m&&"horizontal"!==m)return null;var x=null==g?void 0:g[0];return t=null==x||null==x.height||null==x.width?0:"vertical"===m?x.height/2:x.width/2,erP.createElement(erD,{xAxisId:n,yAxisId:r,data:g,dataPointFormatter:eau,errorBarOffset:t},erP.createElement(eaf,er9({},e,{layout:m,needClip:f,data:g,xAxisId:n,yAxisId:r,hide:a,legendType:i,minPointSize:o,activeBar:l,animationBegin:s,animationDuration:c,animationEasing:d,isAnimationActive:u})))}erP.memo(function(e){var t,n,r=TG(e,eam),a=(t=r.stackId,null!=(n=(0,ew.useContext)(er2))?n.stackId:null!=t?NH(t):void 0),i=Mn();return erP.createElement(LC,{id:r.id,type:"bar"},e=>erP.createElement(erP.Fragment,null,erP.createElement(Lj,{legendPayload:(e=>{var{dataKey:t,name:n,fill:r,legendType:a,hide:i}=e;return[{inactive:i,dataKey:t,type:a,color:r,value:NY(n,t),payload:e}]})(r)}),erP.createElement(ear,{dataKey:r.dataKey,stroke:r.stroke,strokeWidth:r.strokeWidth,fill:r.fill,name:r.name,hide:r.hide,unit:r.unit,tooltipType:r.tooltipType,id:e}),erP.createElement(LR,{type:"bar",id:e,data:void 0,xAxisId:r.xAxisId,yAxisId:r.yAxisId,zAxisId:0,dataKey:r.dataKey,stackId:a,hide:r.hide,barSize:r.barSize,minPointSize:r.minPointSize,maxBarSize:r.maxBarSize,isPanorama:i,hasCustomShape:null!=r.shape}),erP.createElement(LX,{zIndex:r.zIndex},erP.createElement(eah,er9({},r,{id:e})))))},BM).displayName="Bar";let eap=(0,ek.default)("bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]);function eag({label:e,description:t,value:n}){return(0,eb.jsxs)("div",{className:"relative h-full min-h-0",children:[(0,eb.jsxs)("div",{children:[(0,eb.jsx)("div",{className:"text-xl font-semibold tracking-normal",children:e}),(0,eb.jsx)("div",{className:"mt-1 text-sm leading-5 text-muted-foreground",children:t})]}),(0,eb.jsx)(erx,{value:erv(n),minSize:48,maxSize:220,className:"absolute right-0 bottom-0 h-2/3 w-full"})]})}(0,ek.default)("calendar-clock",[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);var eax=ew,eav=(e,t,n,r)=>Av(e,"xAxis",t,r),eab=(e,t,n,r)=>Ax(e,"xAxis",t,r),eay=(e,t,n,r)=>Av(e,"yAxis",n,r),eaw=(e,t,n,r)=>Ax(e,"yAxis",n,r),eaj=k9([MM,eav,eay,eab,eaw],(e,t,n,r,a)=>N$(e,"xAxis")?NG(t,r,!1):NG(n,a,!1));function eak(e){return"line"===e.type}var eaN=k9([O0,(e,t,n,r,a)=>a],(e,t)=>e.filter(eak).find(e=>e.id===t)),eaS=k9([MM,eav,eay,eab,eaw,eaN,eaj,Nr],(e,t,n,r,a,i,o,l)=>{var s,{chartData:c,dataStartIndex:d,dataEndIndex:u}=l;if(null!=i&&null!=t&&null!=n&&null!=r&&null!=a&&0!==r.length&&0!==a.length&&null!=o&&("horizontal"===e||"vertical"===e)){var{dataKey:f,data:m}=i;if(null!=(s=null!=m&&m.length>0?m:null==c?void 0:c.slice(d,u+1)))return function(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:a,yAxisTicks:i,dataKey:o,bandSize:l,displayedData:s}=e;return s.map((e,s)=>{var c=NL(e,o);if("horizontal"===t){var d=NU({axis:n,ticks:a,bandSize:l,entry:e,index:s}),u=null==c?null:r.scale.map(c);return{x:d,y:null!=u?u:null,value:c,payload:e}}var f=null==c?null:n.scale.map(c),m=NU({axis:r,ticks:i,bandSize:l,entry:e,index:s});return null==f||null==m?null:{x:f,y:m,value:c,payload:e}}).filter(Boolean)}({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:a,dataKey:f,bandSize:o,displayedData:s})}}),eaC=["id"],eaM=["type","layout","connectNulls","needClip","shape"],eaE=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function eaI(){return(eaI=Object.assign.bind()).apply(null,arguments)}function eaP(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function eaO(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?eaP(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):eaP(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function eaz(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var eaA=eax.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:a,fill:i,name:o,hide:l,unit:s,tooltipType:c,id:d}=e,u={dataDefinedOnItem:n,getPosition:Nz,settings:{stroke:r,strokeWidth:a,fill:i,dataKey:t,nameKey:void 0,name:NY(o,t),hide:l,type:c,color:r,unit:s,graphicalItemId:d}};return eax.createElement(_u,{tooltipEntrySettings:u})}),eaT=(e,t)=>"".concat(t,"px ").concat(e,"px");function eaR(e){var{clipPathId:t,points:n,props:r}=e,{dot:a,dataKey:i,needClip:o}=r,{id:l}=r,s=AK(eaz(r,eaC));return eax.createElement(Z8,{points:n,dot:a,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:i,baseProps:s,needClip:o,clipPathId:t})}function eaD(e){var{showLabels:t,children:n,points:r}=e,a=(0,eax.useMemo)(()=>null==r?void 0:r.map(e=>{var t,n,r={x:null!=(t=e.x)?t:0,y:null!=(n=e.y)?n:0,width:0,lowerWidth:0,upperWidth:0,height:0};return eaO(eaO({},r),{},{value:e.value,payload:e.payload,viewBox:r,parentViewBox:void 0,fill:void 0})}),[r]);return eax.createElement($c,{value:t?a:void 0},n)}function ea_(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:a,props:i}=e,{type:o,layout:l,connectNulls:s,needClip:c,shape:d}=i,u=eaO(eaO({},AX(eaz(i,eaM))),{},{fill:"none",className:"recharts-line-curve",clipPath:c?"url(#clipPath-".concat(t,")"):void 0,points:r,type:o,layout:l,connectNulls:s,strokeDasharray:null!=a?a:i.strokeDasharray});return eax.createElement(eax.Fragment,null,(null==r?void 0:r.length)>1&&eax.createElement(Dg,eaI({shapeType:"curve",option:d},u,{pathRef:n})),eax.createElement(eaR,{points:r,clipPathId:t,props:i}))}function eaL(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:a,longestAnimatedLengthRef:i}=e,{points:o,strokeDasharray:l,isAnimationActive:s,animationBegin:c,animationDuration:d,animationEasing:u,animateNewValues:f,width:m,height:h,onAnimationEnd:p,onAnimationStart:g}=n,x=a.current,v=RP(o,"recharts-line-"),b=(0,eax.useRef)(v),[y,w]=(0,eax.useState)(!1),j=(0,eax.useCallback)(()=>{"function"==typeof p&&p(),w(!1)},[p]),k=(0,eax.useCallback)(()=>{"function"==typeof g&&g(),w(!0)},[g]),N=function(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch(e){return 0}}(r.current),S=(0,eax.useRef)(0);b.current!==v&&(S.current=i.current,b.current=v);var C=S.current;return eax.createElement(eaD,{points:o,showLabels:!y},n.children,eax.createElement(RI,{animationId:v,begin:c,duration:d,isActive:s,easing:u,onAnimationEnd:j,onAnimationStart:k,key:v},e=>{var c,d=Math.min(NE(C,N+C,e),N);if(c=s?l?((e,t,n)=>{var r=n.reduce((e,t)=>e+t,0);if(!r)return eaT(t,e);for(var a=Math.floor(e/r),i=e%r,o=[],l=0,s=0;l<n.length;s+=null!=(c=n[l])?c:0,++l){var c,d=n[l];if(null!=d&&s+d>i){o=[...n.slice(0,l),i-s];break}}var u=o.length%2==0?[0,t]:[t];return[...function(e,t){for(var n=e.length%2!=0?[...e,0]:e,r=[],a=0;a<t;++a)r.push(...n);return r}(n,a),...o,...u].map(e=>"".concat(e,"px")).join(", ")})(d,N,"".concat(l).split(/[,\s]+/gim).map(e=>parseFloat(e))):eaT(N,d):null==l?void 0:String(l),e>0&&N>0&&(a.current=o,i.current=Math.max(i.current,d)),x){var u=x.length/o.length,p=1===e?o:o.map((t,n)=>{var r=Math.floor(n*u);if(x[r]){var a=x[r];return eaO(eaO({},t),{},{x:NE(a.x,t.x,e),y:NE(a.y,t.y,e)})}return f?eaO(eaO({},t),{},{x:NE(2*m,t.x,e),y:NE(h/2,t.y,e)}):eaO(eaO({},t),{},{x:t.x,y:t.y})});return a.current=p,eax.createElement(ea_,{props:n,points:p,clipPathId:t,pathRef:r,strokeDasharray:c})}return eax.createElement(ea_,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:c})}),eax.createElement($m,{label:n.label}))}function ea$(e){var{clipPathId:t,props:n}=e,r=(0,eax.useRef)(null),a=(0,eax.useRef)(0),i=(0,eax.useRef)(null);return eax.createElement(eaL,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:a,pathRef:i})}var eaF=(e,t)=>{var n,r;return{x:null!=(n=e.x)?n:void 0,y:null!=(r=e.y)?r:void 0,value:e.value,errorVal:NL(e.payload,t)}};class eaB extends eax.Component{render(){var{hide:e,dot:t,points:n,className:r,xAxisId:a,yAxisId:i,top:o,left:l,width:s,height:c,id:d,needClip:u,zIndex:f}=this.props;if(e)return null;var m=(0,kq.clsx)("recharts-line",r),{r:h,strokeWidth:p}=Jp(t),g=Ro(t),x=2*h+p,v=u?"url(#clipPath-".concat(g?"":"dots-").concat(d,")"):void 0;return eax.createElement(LX,{zIndex:f},eax.createElement(AJ,{className:m},u&&eax.createElement("defs",null,eax.createElement(Jr,{clipPathId:d,xAxisId:a,yAxisId:i}),!g&&eax.createElement("clipPath",{id:"clipPath-dots-".concat(d)},eax.createElement("rect",{x:l-x/2,y:o-x/2,width:s+x,height:c+x}))),eax.createElement(erD,{xAxisId:a,yAxisId:i,data:n,dataPointFormatter:eaF,errorBarOffset:0},eax.createElement(ea$,{props:this.props,clipPathId:d}))),eax.createElement(Jt,{activeDot:this.props.activeDot,points:n,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:v}))}}var eaV={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!0,fill:"#fff",hide:!1,isAnimationActive:"auto",label:!1,legendType:"line",stroke:"#3182bd",strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:M2.line,type:"linear"};function eaH(e){var t=TG(e,eaV),{activeDot:n,animateNewValues:r,animationBegin:a,animationDuration:i,animationEasing:o,connectNulls:l,dot:s,hide:c,isAnimationActive:d,label:u,legendType:f,xAxisId:m,yAxisId:h,id:p}=t,g=eaz(t,eaE),{needClip:x}=Jn(m,h),v=Sl(B9),b=Sl(MM),y=Mn(),w=Sl(e=>eaS(e,m,h,y,p));if("horizontal"!==b&&"vertical"!==b||null==w||null==v)return null;var{height:j,width:k,x:N,y:S}=v;return eax.createElement(eaB,eaI({},g,{id:p,connectNulls:l,dot:s,activeDot:n,animateNewValues:r,animationBegin:a,animationDuration:i,animationEasing:o,isAnimationActive:d,hide:c,label:u,legendType:f,xAxisId:m,yAxisId:h,points:w,layout:b,height:j,width:k,left:N,top:S,needClip:x}))}var eaU=eax.memo(function(e){var t=TG(e,eaV),n=Mn();return eax.createElement(LC,{id:t.id,type:"line"},e=>eax.createElement(eax.Fragment,null,eax.createElement(Lj,{legendPayload:(e=>{var{dataKey:t,name:n,stroke:r,legendType:a,hide:i}=e;return[{inactive:i,dataKey:t,type:a,color:r,value:NY(n,t),payload:e}]})(t)}),eax.createElement(eaA,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),eax.createElement(LR,{type:"line",id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),eax.createElement(eaH,eaI({},t,{id:e}))))},BM);eaU.displayName="Line";var eaq=["axis"],eaW=(0,ew.forwardRef)((e,t)=>ew.createElement(J$,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:eaq,tooltipPayloadSearcher:$A,categoricalChartProps:e,ref:t}));function eaK({title:e,count:t}){return(0,eb.jsxs)("div",{className:"flex h-7 shrink-0 items-center justify-between",children:[(0,eb.jsx)("h2",{className:"text-sm font-semibold tracking-normal",children:e}),(0,eb.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:t})]})}function eaG({items:e}){return(0,eb.jsx)("div",{className:"mt-2 grid",children:e.map((e,t)=>(0,eb.jsxs)("div",{className:(0,ez.cn)("px-2 py-2",t>0&&"border-t"),children:[(0,eb.jsx)("div",{className:"truncate text-sm font-medium",children:e.title}),(0,eb.jsx)("div",{className:(0,ez.cn)("mt-1 truncate ui-text-kbd text-muted-foreground","warning"===e.tone&&"text-destructive"),children:e.meta})]},e.id))})}function eaX({items:e}){let t=ew.useMemo(()=>e.map(([e,t,n,r])=>({id:`${e}-${n}`,status:"完成"===r?"done":"运行中"===r?"current":"失败"===r?"blocked":"queued",title:(0,eb.jsxs)("div",{className:"grid w-full grid-cols-[3.25rem_8rem_minmax(0,1fr)_4rem] items-center gap-3",children:[(0,eb.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:e}),(0,eb.jsx)("span",{className:"truncate ui-text-kbd text-muted-foreground",children:t}),(0,eb.jsx)("span",{className:"truncate",children:n}),(0,eb.jsx)("span",{className:"text-right ui-text-kbd text-muted-foreground",children:r})]})})),[e]);return(0,eb.jsx)(enX,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-1.5"})}function eaY({items:e}){let t=ew.useMemo(()=>e.map(e=>{var t;return{id:e.id,status:"running"===(t=e.state)?"current":"blocked"===t||"failed"===t?"blocked":"queued",title:(0,eb.jsx)(eaZ,{item:e})}}),[e]);return(0,eb.jsx)(enX,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-2"})}function eaZ({item:e}){return(0,eb.jsxs)("div",{className:"grid w-full grid-cols-[minmax(0,1fr)_7.5rem_5rem] items-center gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("div",{className:"truncate text-sm font-medium",children:e.title}),(0,eb.jsxs)("div",{className:"mt-1 truncate ui-text-kbd text-muted-foreground",children:[e.machine," · ",e.agent," · ",e.started]})]}),(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsx)(erw,{value:e.progress,className:"h-1.5"}),(0,eb.jsx)("div",{className:"ui-text-kbd text-muted-foreground",children:e.runtime})]}),(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsx)(erw,{value:e.load,className:"h-1.5"}),(0,eb.jsx)("div",{className:"text-right ui-text-kbd text-muted-foreground",children:"load"})]})]})}function eaJ({workers:e}){return(0,eb.jsx)("div",{className:"mt-2 grid min-h-0 flex-1 content-start overflow-hidden",children:e.map((e,t)=>(0,eb.jsx)(eaQ,{worker:e,divided:t>0},e.id))})}function eaQ({worker:e,divided:t}){return(0,eb.jsxs)("div",{className:(0,ez.cn)("grid min-h-24 grid-cols-[minmax(0,1fr)_2.5rem_auto] items-center gap-4 px-2 py-2",t&&"border-t"),children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("div",{className:"truncate text-lg font-semibold tracking-normal",children:e.machine}),(0,eb.jsx)("div",{className:"mt-0.5 truncate ui-text-kbd text-muted-foreground",children:e.role})]}),(0,eb.jsxs)("div",{className:"text-right text-sm font-medium tabular-nums",children:[e.active,"/",e.capacity]}),(0,eb.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,eb.jsx)(ea0,{label:"CPU",value:e.cpu}),(0,eb.jsx)(ea0,{label:"MEM",value:e.memory})]})]})}function ea0({label:e,value:t}){return(0,eb.jsxs)("div",{className:"grid justify-items-center gap-1",children:[(0,eb.jsx)(erj,{value:t,label:e,className:"size-16 [&_[data-slot=progress-ring-center]]:size-10 [&_[data-slot=progress-ring-center]]:bg-background [&_[data-slot=progress-ring-center]_span]:text-xs"}),(0,eb.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:e})]})}function ea1({events:e}){let t=ew.useMemo(()=>e.map(([e,t],n)=>({id:`${e}-${t}`,status:0===n?"current":"done",title:(0,eb.jsxs)("div",{className:"grid w-full grid-cols-[3.25rem_minmax(0,1fr)] items-center gap-2",children:[(0,eb.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:e}),(0,eb.jsx)("span",{className:"truncate",children:t})]})})),[e]);return(0,eb.jsx)(enX,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-1.5"})}function ea2({machines:e}){return(0,eb.jsx)("div",{className:"mt-2 grid min-h-0 flex-1 content-start overflow-hidden",children:e.map((e,t)=>(0,eb.jsx)(ea5,{machine:e,divided:t>0},e.id))})}function ea5({machine:e,divided:t}){return(0,eb.jsxs)("div",{className:(0,ez.cn)("grid min-h-20 grid-cols-[minmax(0,1fr)_minmax(0,1.45fr)] items-center gap-4 px-2 py-2",t&&"border-t"),children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)(ea3,{status:e.status}),(0,eb.jsx)("span",{className:"truncate text-sm font-medium",children:e.name})]}),(0,eb.jsxs)("div",{className:"mt-1 truncate ui-text-kbd text-muted-foreground",children:[e.os," · ",e.link," · heartbeat ",e.heartbeat]})]}),(0,eb.jsxs)("div",{className:"grid gap-2 sm:grid-cols-4",children:[(0,eb.jsx)(ea4,{icon:(0,eb.jsx)(uK,{}),label:"CPU",value:e.cpu}),(0,eb.jsx)(ea4,{icon:(0,eb.jsx)(erM,{}),label:"MEM",value:e.memory}),(0,eb.jsx)(ea4,{icon:(0,eb.jsx)(uG,{}),label:"DISK",value:e.disk}),(0,eb.jsx)(ea4,{icon:(0,eb.jsx)(erE,{}),label:"NET",value:e.network})]})]})}function ea4({icon:e,label:t,value:n}){return(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsxs)("div",{className:"flex justify-between gap-1 ui-text-kbd text-muted-foreground",children:[(0,eb.jsxs)("span",{className:"flex items-center gap-1 [&_svg]:size-3",children:[e,t]}),(0,eb.jsxs)("span",{children:[n,"%"]})]}),(0,eb.jsx)(erw,{value:n,className:"h-1.5"})]})}function ea3({status:e}){return(0,eb.jsx)("span",{className:(0,ez.cn)("size-2 rounded-full bg-border","online"===e&&"bg-primary")})}function ea6({links:e}){let t=ew.useMemo(()=>e.map(([e,t,n,r,a])=>({id:`${e}-${t}`,status:"Relay fallback"===n?"blocked":"current",title:(0,eb.jsxs)("div",{className:"grid w-full grid-cols-[minmax(0,1fr)_5rem_4rem_3.5rem] items-center gap-3",children:[(0,eb.jsxs)("span",{className:"truncate",children:[e," / ",t]}),(0,eb.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:n}),(0,eb.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:r}),(0,eb.jsx)("span",{className:"text-right ui-text-kbd text-muted-foreground",children:a})]})})),[e]);return(0,eb.jsx)(enX,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-2"})}function ea8({config:e,data:t}){return(0,eb.jsx)(Hl,{config:e,className:"mt-2 min-h-0 flex-1",children:(0,eb.jsxs)(JB,{data:t,margin:{left:8,right:8},children:[(0,eb.jsx)(Qf,{vertical:!1}),(0,eb.jsx)(QE,{dataKey:"time",tickLine:!1,axisLine:!1,tickMargin:8}),(0,eb.jsx)(VZ,{content:(0,eb.jsx)(Hc,{indicator:"line"})}),(0,eb.jsx)(JR,{dataKey:"cpu",type:"monotone",fill:"var(--color-cpu)",fillOpacity:.11,stroke:"var(--color-cpu)",strokeWidth:2}),(0,eb.jsx)(JR,{dataKey:"memory",type:"monotone",fill:"var(--color-memory)",fillOpacity:.1,stroke:"var(--color-memory)",strokeWidth:2}),(0,eb.jsx)(JR,{dataKey:"network",type:"monotone",fill:"var(--color-network)",fillOpacity:.08,stroke:"var(--color-network)",strokeWidth:2})]})})}function ea7({services:e}){let[t,n]=ZC(),r=Math.max(1,Math.floor((Math.max(0,n.width-192-64-32)+5)/12)),a=Math.max(48,n.height>0?Math.floor((n.height-0*Math.max(0,e.length-1))/e.length):48),i=Math.max(28,a-22);return(0,eb.jsx)("div",{ref:t,className:"mt-2 min-h-0 flex-1",children:e.map((e,t)=>(0,eb.jsx)(ea9,{service:e,divided:t>0,rowHeight:a,sampleCount:r,sampleHeight:i},e.id))})}function ea9({service:e,divided:t,rowHeight:n,sampleCount:r,sampleHeight:a}){let i=ew.useMemo(()=>{var t,n;return t=e.samples,n=r,t.length>=n?t.slice(t.length-n):Array.from({length:n},(e,n)=>{let r=n%t.length;return t[r]??0})},[r,e.samples]);return(0,eb.jsxs)("div",{className:(0,ez.cn)("grid grid-cols-[12rem_minmax(0,1fr)_4rem] items-center gap-4 px-2",t&&"border-t"),style:{height:n},children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("div",{className:"truncate text-sm font-medium",children:e.name}),(0,eb.jsx)("div",{className:(0,ez.cn)("mt-0.5 truncate ui-text-kbd text-muted-foreground","告警"===e.state&&"text-destructive"),children:e.state})]}),(0,eb.jsx)("div",{"aria-label":`${e.name} 30 minute stability samples`,className:"flex min-w-0 items-center overflow-hidden",style:{gap:5},children:i.map((t,n)=>{var r;return(0,eb.jsx)("span",{className:(0,ez.cn)("shrink-0 rounded-[2px]",(r=t)<60?"bg-destructive":r<72?"bg-destructive/55":r<84?"bg-primary/35":r<92?"bg-primary/60":"bg-primary"),style:{width:7,height:a},title:`${t}%`},`${e.id}-${n}`)})}),(0,eb.jsxs)("div",{className:"text-right text-sm font-medium tabular-nums",children:[e.samples.at(-1),"%"]})]})}let eie=[{id:"canvas-vantaloom-base",title:"Vantaloom 基座设计",status:"live",purpose:"承载多标签系统、文件树、终端和 Agent 会话节点。",nodes:18,agents:3,progress:64,health:91,runtime:"3h 12m",tokenUsage:62e4,lastOpened:"刚刚",snapshots:14,unsavedChanges:3,roadmap:[{title:"接入节点模板选择",state:"done"},{title:"处理节点吸附与连线遮挡",state:"done"},{title:"合并多标签页拖拽",state:"running"},{title:"沉淀真实项目模板",state:"queued"}],settings:{nodeTemplates:["多标签页系统","文件管理树","终端标签组","Agent 对话"],defaultLayout:["默认缩放 0.72","节点内容 2x","定位点 24px"],folders:["D:/Projects/Vantaloom-ui","D:/Projects/Vantaloom-ui/apps"],sharing:["工作组管理员可编辑","成员可审阅","访客不可访问"],autosave:["每 45 秒保存","节点拖拽结束保存","切换工作区保存"],snapshots:["保留最近 30 个","发布前创建检查点"],hosts:["Studio-PC","Linux-runner-02"],plugins:["Browser","Git checkpoint"]}},{id:"canvas-agent-lab",title:"Agent 编排实验",status:"live",purpose:"验证多 Agent 对话、工具窗口和剪切板在画布中的协同。",nodes:11,agents:4,progress:41,health:78,runtime:"1h 36m",tokenUsage:308e3,lastOpened:"8 分钟前",snapshots:9,unsavedChanges:1,roadmap:[{title:"四分工作区布局",state:"done"},{title:"面板替换进剪切板",state:"done"},{title:"会话浏览页",state:"running"},{title:"会话节点化",state:"queued"}],settings:{nodeTemplates:["Agent 对话","数据表标签","浏览器标签"],defaultLayout:["默认双栏","右侧可调整","剪切板常驻"],folders:["D:/Projects/Vantaloom-ui/apps/vantaloom"],sharing:["仅本机管理员可编辑"],autosave:["每 60 秒保存"],snapshots:["保留最近 12 个"],hosts:["Studio-PC"],plugins:["Browser"]}},{id:"canvas-release-map",title:"发布路线图",status:"review",purpose:"梳理组件库、主应用和文档的发布前检查。",nodes:9,agents:1,progress:83,health:86,runtime:"42m",tokenUsage:144e3,lastOpened:"今天 15:02",snapshots:7,unsavedChanges:0,roadmap:[{title:"组件清单",state:"done"},{title:"风险列表",state:"done"},{title:"最终检查",state:"running"}],settings:{nodeTemplates:["Diff 标签","数据表标签","文件预览标签"],defaultLayout:["审阅模式默认开启"],folders:["D:/Projects/Vantaloom-ui/docs"],sharing:["工作组可审阅"],autosave:["手动保存"],snapshots:["里程碑保留"],hosts:["Studio-PC"],plugins:[]}},{id:"canvas-browser-matrix",title:"浏览器预览矩阵",status:"idle",purpose:"检查不同 UA、比例和内嵌预览模式的表现。",nodes:6,agents:0,progress:100,health:94,runtime:"28m",tokenUsage:78e3,lastOpened:"昨天 18:44",snapshots:5,unsavedChanges:0,roadmap:[{title:"自适应模式",state:"done"},{title:"长宽比菜单",state:"done"},{title:"导航按钮",state:"done"}],settings:{nodeTemplates:["浏览器标签","多标签页系统"],defaultLayout:["自适应预览"],folders:["D:/Projects/Vantaloom-ui/packages/ui"],sharing:["仅自己"],autosave:["关闭"],snapshots:["保留最近 5 个"],hosts:["Studio-PC"],plugins:["Browser"]}},{id:"canvas-ops-topology",title:"工作组拓扑",status:"idle",purpose:"记录机器、服务和工作组连接关系。",nodes:15,agents:0,progress:100,health:89,runtime:"1h 04m",tokenUsage:92e3,lastOpened:"周四 11:30",snapshots:11,unsavedChanges:0,roadmap:[{title:"机器节点整理",state:"done"},{title:"连接策略标注",state:"done"},{title:"访问权限检查",state:"done"}],settings:{nodeTemplates:["数据表标签","浏览器标签","终端标签组"],defaultLayout:["视口吸附开启","节点吸附开启"],folders:["D:/Projects/Vantaloom-ui/ops"],sharing:["管理员可编辑","成员可查看"],autosave:["每 2 分钟保存"],snapshots:["每日保留"],hosts:["Studio-PC","Linux-runner-02","MacBook-build"],plugins:[]}}];function eit(e,t,n,r,a,i,o){return{id:e,title:t,status:"idle",purpose:n,nodes:r,agents:0,progress:100,health:90,runtime:a,tokenUsage:i,lastOpened:o,snapshots:Math.max(3,Math.round(r/2)),unsavedChanges:0,roadmap:[{title:"整理节点结构",state:"done"},{title:"检查连接关系",state:"done"},{title:"保存最终快照",state:"done"}],settings:{nodeTemplates:["多标签页系统","文件预览标签"],defaultLayout:["默认缩放 0.72","节点吸附开启"],folders:["D:/Projects/Vantaloom-ui"],sharing:["仅自己"],autosave:["关闭"],snapshots:["保留最近 5 个"],hosts:["Studio-PC"],plugins:[]}}}eie.push(eit("canvas-terminal-layout","终端工作台草图","记录终端标签组、日志表和命令区的组合方式。",7,"36m",84e3,"昨天 15:21"),eit("canvas-file-review","文件审阅流程","沉淀文件树、diff 预览和文件标签之间的拖拽关系。",12,"58m",126e3,"周五 20:10"),eit("canvas-settings-ia","设置导航结构","整理设置菜单面板的主菜单、子菜单和搜索入口。",8,"24m",61e3,"周五 16:42"),eit("canvas-auth-access","本机账户接入","记录本机用户、工作组加入和可用机器列表关系。",10,"47m",112e3,"周四 22:05"),eit("canvas-data-ops","运维数据面板","对齐数据表标签、机器状态卡片和运行记录列表。",14,"1h 18m",172e3,"周三 19:48"));let ein=eie.filter(e=>"idle"!==e.status),eir=eie.filter(e=>"idle"===e.status);function eia(e,t,n=""){return{title:e,dataSource:t,refreshRate:"30s",note:n}}function eii(e,t){return(0,eb.jsx)("section",{className:(0,ez.cn)("size-full rounded-xl border bg-card p-5","vtl-jelly-image-card vtl-jelly-image-card-shadowless"),style:en0({image:t,opacity:.88,blur:"0px"}),children:e})}let eio=[{id:"metric-active",kind:"metric-active",x:0,y:0,w:3,h:3},{id:"metric-nodes",kind:"metric-nodes",x:3,y:0,w:3,h:3},{id:"metric-unsaved",kind:"metric-unsaved",x:6,y:0,w:3,h:3},{id:"metric-snapshots",kind:"metric-snapshots",x:9,y:0,w:3,h:3},{id:"active",kind:"active",x:0,y:3,w:12,h:3},{id:"recent",kind:"recent",x:0,y:6,w:12,h:Math.max(3,Math.ceil(.75*eir.length)+1)}];function eil({open:e,title:t,description:n,eyebrow:r,panels:a,defaultPanelId:i="overview",onOpenChange:o}){let l=sv(),[s,c]=ew.useState(i),d=a.find(e=>e.id===s)??a[0];return ew.useEffect(()=>{e&&c(i)},[i,e]),(0,eb.jsx)(dX,{open:e,onOpenChange:o,children:(0,eb.jsxs)(fU,{hideClose:!0,className:(0,ez.cn)("gap-0 overflow-hidden p-0",l?"inset-0 h-svh w-full max-w-none translate-x-0 translate-y-0 rounded-none border-0":"h-[min(44rem,calc(100svh-2rem))] max-w-5xl"),children:[(0,eb.jsx)(fK,{className:"sr-only",children:t}),(0,eb.jsxs)(fG,{className:"sr-only",children:[r?(0,eb.jsxs)(eb.Fragment,{children:[r,". "]}):null,n??t]}),l?(0,eb.jsxs)("div",{className:"flex h-full flex-col",children:[(0,eb.jsxs)("header",{className:"flex shrink-0 items-center gap-3 border-b px-4 py-3",children:[(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"关闭",onClick:()=>o(!1),children:(0,eb.jsx)(fV.XIcon,{className:"size-4"})}),(0,eb.jsxs)("div",{className:"min-w-0 flex-1",children:[r?(0,eb.jsx)("div",{className:"truncate text-xs text-muted-foreground",children:r}):null,(0,eb.jsx)("div",{className:"truncate text-sm font-semibold",children:t})]})]}),(0,eb.jsx)("nav",{className:"shrink-0 overflow-x-auto border-b [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:(0,eb.jsx)("div",{className:"flex gap-1.5 px-4 py-2",children:a.map(e=>(0,eb.jsxs)("button",{type:"button",className:(0,ez.cn)("inline-flex shrink-0 items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium transition-colors",d?.id===e.id?"bg-foreground text-background":"bg-muted text-muted-foreground"),onClick:()=>c(e.id),children:[e.icon?(0,eb.jsx)("span",{className:"[&_svg]:size-3.5",children:e.icon}):null,(0,eb.jsx)("span",{children:e.label}),e.badge?(0,eb.jsx)(Vp,{variant:"outline",className:"h-4 px-1 ui-text-kbd",children:e.badge}):null]},e.id))})}),(0,eb.jsx)(jP,{className:"min-h-0 flex-1",children:(0,eb.jsx)("div",{className:"p-4",children:d?.content})})]}):(0,eb.jsxs)("div",{className:"grid size-full min-h-0 grid-cols-[15rem_minmax(0,1fr)]",children:[(0,eb.jsx)("aside",{"data-slot":"resource-management-dialog-sidebar",className:"min-h-0 border-r bg-muted/20",children:(0,eb.jsx)(jP,{className:"h-full",children:(0,eb.jsx)("div",{className:"space-y-1 p-2",children:a.map(e=>(0,eb.jsxs)(eO.Button,{"data-slot":"resource-management-dialog-nav-item",type:"button",variant:"ghost",className:(0,ez.cn)("h-9 w-full justify-start px-2.5 text-left font-medium",d?.id===e.id?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/70 hover:text-foreground"),onClick:()=>c(e.id),children:[e.icon?(0,eb.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center [&_svg]:size-4",children:e.icon}):null,(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.label}),e.badge?(0,eb.jsx)(Vp,{variant:"outline",className:"h-5 px-1.5 ui-text-kbd",children:e.badge}):null]},e.id))})})}),(0,eb.jsx)(jP,{className:"min-h-0 bg-background",children:(0,eb.jsx)("div",{className:"p-5 pr-9",children:d?.content})})]})]})})}function eis({clipboardItems:e=[],onClipboardItemsChange:t,onOverlayOpenChange:n}){let[r,a]=ew.useState(),i=ew.useMemo(()=>(function({onSelect:e}){return[{id:"metric-active",title:"活跃画布",description:"当前正在编辑的画布数量。",icon:(0,eb.jsx)(u1,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:eia("活跃画布","画布列表"),render:e=>eii((0,eb.jsx)(eag,{label:e.title,description:"当前正在编辑的画布数量",value:String(ein.length)}),enY)},{id:"metric-nodes",title:"运行节点",description:"所有活跃画布内的节点。",icon:(0,eb.jsx)(HM,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:eia("运行节点","画布节点"),render:e=>eii((0,eb.jsx)(eag,{label:e.title,description:"所有活跃画布内的节点",value:"38"}),enZ)},{id:"metric-unsaved",title:"未保存",description:"等待写入的画布变更。",icon:(0,eb.jsx)(kV,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:eia("未保存","画布保存状态"),render:e=>eii((0,eb.jsx)(eag,{label:e.title,description:"等待写入的画布变更",value:"4"}),enJ)},{id:"metric-snapshots",title:"快照",description:"可回退的历史存档。",icon:(0,eb.jsx)(Xb,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:eia("快照","画布快照"),render:e=>eii((0,eb.jsx)(eag,{label:e.title,description:"可回退的历史存档",value:"46"}),enQ)},{id:"active",title:"正在使用的画布",description:"活跃画布 Roadmap。",icon:(0,eb.jsx)(u1,{className:"size-4"}),defaultSize:{w:12,h:3},defaultConfig:eia("正在使用的画布","画布列表"),render:t=>(0,eb.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,eb.jsx)(eaK,{title:t.title,count:ein.length}),(0,eb.jsx)(erN,{canvases:ein,scrollable:!0,onSelect:e})]})},{id:"recent",title:"最近画布",description:"最近打开的画布。",icon:(0,eb.jsx)(h9,{className:"size-4"}),defaultSize:{w:12,h:Math.max(3,Math.ceil(.75*eir.length)+1)},defaultConfig:eia("最近画布","画布列表"),render:t=>(0,eb.jsxs)("section",{className:"flex size-full flex-col",children:[(0,eb.jsx)(eaK,{title:t.title,count:eir.length}),(0,eb.jsx)(erN,{canvases:eir,mode:"archive",onSelect:e})]})}]})({onSelect:a}),[]);return(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(erp,{boardId:"canvas-library",definitions:i,initialLayouts:eio,clipboardItems:e,actionLabel:"画布库页面卡片操作",paletteGroupTitle:"画布库页面卡片",onClipboardItemsChange:t,onOverlayOpenChange:n}),(0,eb.jsx)(eid,{canvas:r,onOpenChange:e=>{e||a(void 0)}})]})}function eic({icon:e,value:t}){return(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,eb.jsx)("span",{className:"[&_svg]:size-3.5",children:e}),(0,eb.jsx)("span",{className:"tabular-nums",children:t})]})}function eid({canvas:e,onOpenChange:t}){return e?(0,eb.jsx)(eil,{open:!!e,onOpenChange:t,title:e.title,eyebrow:"画布管理",description:e.purpose,panels:[{id:"overview",label:"首页",icon:(0,eb.jsx)(HE,{}),content:(0,eb.jsx)(eiu,{canvas:e})},{id:"templates",label:"节点模板",icon:(0,eb.jsx)(enB,{}),badge:e.settings.nodeTemplates.length,content:(0,eb.jsx)(eim,{title:"可用节点模板",items:e.settings.nodeTemplates})},{id:"layout",label:"默认布局",icon:(0,eb.jsx)(enW,{}),content:(0,eb.jsx)(eim,{title:"默认布局参数",items:e.settings.defaultLayout})},{id:"folders",label:"工作区绑定",icon:(0,eb.jsx)(h9,{}),content:(0,eb.jsx)(eim,{title:"绑定的工作区文件夹",items:e.settings.folders})},{id:"sharing",label:"共享权限",icon:(0,eb.jsx)(enq,{}),content:(0,eb.jsx)(eim,{title:"共享与权限",items:e.settings.sharing})},{id:"autosave",label:"自动保存",icon:(0,eb.jsx)(Xj,{}),content:(0,eb.jsx)(eim,{title:"自动保存策略",items:e.settings.autosave})},{id:"snapshots",label:"快照和版本",icon:(0,eb.jsx)(Xb,{}),content:(0,eb.jsx)(eim,{title:"快照和版本策略",items:e.settings.snapshots})},{id:"hosts",label:"可访问主机",icon:(0,eb.jsx)(enH,{}),content:(0,eb.jsx)(eim,{title:"可访问主机",items:e.settings.hosts})},{id:"plugins",label:"插件",icon:(0,eb.jsx)(enU,{}),content:(0,eb.jsx)(eim,{title:"画布插件",items:e.settings.plugins,empty:"未加载插件"})}]}):null}function eiu({canvas:e}){return(0,eb.jsxs)("div",{className:"grid gap-5",children:[(0,eb.jsxs)("button",{type:"button",className:"group relative grid min-h-72 rounded-[2rem] border bg-card p-7 text-left transition-colors hover:bg-muted/35",children:[(0,eb.jsxs)("div",{className:"grid gap-5",children:[(0,eb.jsxs)("div",{className:"max-w-2xl",children:[(0,eb.jsx)("h3",{className:"text-3xl font-semibold tracking-normal",children:e.title}),(0,eb.jsx)("p",{className:"mt-4 text-sm leading-6 text-muted-foreground",children:e.purpose})]}),(0,eb.jsxs)("div",{className:"grid max-w-56 gap-2",children:[(0,eb.jsx)(eif,{label:"Nodes",value:`${e.nodes}`}),(0,eb.jsx)(eif,{label:"Agent",value:`${e.agents}`}),(0,eb.jsx)(eif,{label:"Snapshots",value:`${e.snapshots}`})]})]}),(0,eb.jsx)("span",{className:"absolute right-7 bottom-7 text-sm font-medium text-foreground transition-opacity group-hover:opacity-70",children:"进入"})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)("span",{className:"text-sm font-medium",children:"Roadmap"}),(0,eb.jsx)(eic,{icon:(0,eb.jsx)(HM,{}),value:e.runtime})]}),(0,eb.jsx)(enX,{items:e.roadmap.map(e=>({id:e.title,title:e.title,status:"running"===e.state?"current":"done"===e.state?"done":"queued"})),viewportClassName:"max-h-64"})]})]})}function eif({label:e,value:t}){return(0,eb.jsxs)("span",{className:"grid min-w-0 gap-0.5 py-0.5",children:[(0,eb.jsx)("span",{className:"truncate ui-text-kbd text-muted-foreground",children:e}),(0,eb.jsx)("span",{className:"min-w-0 truncate text-sm font-semibold tracking-normal",children:t})]})}function eim({title:e,items:t,empty:n="暂无内容"}){return(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:e}),(0,eb.jsx)("div",{className:"overflow-hidden rounded-xl border bg-card",children:t.length>0?t.map((e,t)=>(0,eb.jsxs)("div",{className:(0,ez.cn)("flex min-h-10 items-center gap-2 px-3 text-sm",t>0&&"border-t"),children:[(0,eb.jsx)(enV,{className:"size-4 text-muted-foreground"}),(0,eb.jsx)("span",{className:"min-w-0 truncate",children:e})]},e)):(0,eb.jsx)("div",{className:"px-3 py-6 text-sm text-muted-foreground",children:n})})]})}function eih({open:e,onOpenChange:t,onAdd:n}){return(0,eb.jsx)(bm,{open:e,onOpenChange:t,title:"添加节点",description:"搜索并选择要放入画布的可用节点。",className:"top-1/2 max-w-xl -translate-y-1/2",children:(0,eb.jsxs)(bf,{loop:!0,children:[(0,eb.jsx)(bh,{placeholder:"搜索节点..."}),(0,eb.jsxs)(bp,{children:[(0,eb.jsx)(bg,{children:"没有匹配节点。"}),(0,eb.jsx)(bx,{heading:"可用节点",children:fe.map(e=>(0,eb.jsxs)(bv,{value:`${e.title} ${e.description} ${e.keywords}`,onSelect:()=>n(e),children:[(0,eb.jsx)("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg border bg-background text-muted-foreground",children:e.icon}),(0,eb.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,eb.jsx)("span",{className:"block truncate text-sm font-medium",children:e.title}),(0,eb.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,eb.jsxs)(bb,{children:[e.size.width,"x",e.size.height]})]},e.id))})]})]})})}function eip({node:e}){return(0,eb.jsx)("button",{type:"button",draggable:!0,"aria-label":"拖拽到对话框作为附件",title:"拖拽到对话框作为附件",onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),onDragStart:t=>{t.stopPropagation(),t.dataTransfer.setData(qf,qh(e)),t.dataTransfer.effectAllowed="copy"},className:"nodrag nopan pointer-events-auto absolute right-1.5 top-1.5 z-10 grid size-6 cursor-grab place-items-center rounded-md border border-border bg-background/85 text-muted-foreground shadow-sm transition-colors hover:bg-muted hover:text-foreground active:cursor-grabbing [&_svg]:size-3.5",children:(0,eb.jsx)(kF,{})})}function eig({nodes:e,edges:t,selectedNodeId:n,clipboardItems:r,onNodesChange:a,onEdgesChange:i,onNodesSet:o,onEdgesSet:l,onSelectedNodeChange:s,onClipboardItemsChange:c}){let d=ew.useRef(null),{addPaletteOpen:u,addTemplateNode:f,handleAddPaletteOpenChange:m,handleCanvasAction:h,handleCanvasDragOver:p,handleCanvasDrop:g,handleNodeCanvasConnect:x,handleNodeCanvasEdgeAction:v,handleNodeCanvasNodeAction:b,filePickerDialog:y,renderedCanvasNodes:w}=function({workspaceRef:e,nodes:t,clipboardItems:n,onNodesSet:r,onEdgesSet:a,onSelectedNodeChange:i,onClipboardItemsChange:o}){let l=ew.useRef(0),s=ew.useRef(0),[c,d]=ew.useState(!1),[u,f]=ew.useState(),[m,h]=ew.useState(),p=ew.useCallback((t,n)=>{let r,a,i,o,l,s,c,d;return r=e.current,a=r?.querySelector(".react-flow__viewport"),i=r?.getBoundingClientRect(),l="none"!==(o=a?getComputedStyle(a).transform:"none")?new DOMMatrixReadOnly(o):void 0,s=l?.a&&Number.isFinite(l.a)?l.a:1,c=l?.e??0,d=l?.f??0,{x:(t-(i?.left??0)-c)/s,y:(n-(i?.top??0)-d)/s}},[e]),g=ew.useCallback((e,t)=>{r(n=>n.map(n=>{let r,a;return n.id===e?(a="string"==typeof(r=n.data??{}).activeTabId&&t.some(e=>e.id===r.activeTabId)?r.activeTabId:t[0]?.id,{...n,data:{...r,tabs:t,activeTabId:a}}):n}))},[r]),x=ew.useCallback((e,t)=>{r(n=>n.map(n=>n.id===e?{...n,data:{...n.data??{},activeTabId:t}}:n))},[r]),v=ew.useCallback((e,t)=>{r(n=>n.map(n=>n.id===e?function(e,t){let n=e.data??{};if("multi-tab-system"===n.kind){let r=Array.isArray(n.tabs)?n.tabs:[];return{...e,data:{...n,tabs:r.map(e=>e.id===t.id?t:e),activeTabId:t.id}}}return fr(n.kind)?{...e,data:{...n,tab:t}}:e}(n,t):n))},[r]),b=ew.useCallback((e,t)=>{r(n=>n.map(n=>n.id===e?{...n,data:{...n.data??{},terminal:t}}:n))},[r]),y=ew.useCallback((e,t)=>{r(n=>n.map(n=>n.id===e?{...n,data:{...n.data??{},sideQuery:t}}:n))},[r]),w=ew.useCallback((e,t)=>{var n;let a=(n=e.kind,fe.find(e=>e.id===n)?.size??u3({width:480,height:320}));s.current+=1;let o=`${e.kind}-detached-${s.current}`;r(n=>[...n,function({tab:e,nodeId:t,center:n,size:r}){return{id:t,type:"blank",position:u7(n,r),data:{contentScale:2,kind:e.kind,tab:{...e,id:`${t}-tab`}},width:r.width,height:r.height,style:u6(r)}}({tab:e,nodeId:o,center:t,size:a})]),i(o)},[r,i]),j=ew.useCallback(async(e,n)=>{try{let a,i=n?.nodeId?t.find(e=>e.id===n.nodeId):void 0,o=i?(i.data??{}).kind:void 0,l="data-table-tab-viewer"===o?await fC(e):await fk(e),s=void 0!==i&&(a=i.data??{},"multi-tab-system"===a.kind||"file-tab-viewer"===a.kind||"data-table-tab-viewer"===a.kind);n?.nodeId&&s&&r(e=>e.map(e=>e.id===n.nodeId?function(e,t,n){let r=e.data??{};if("multi-tab-system"===r.kind){let a,i,o=Array.isArray(r.tabs)?r.tabs:[];return{...e,data:{...r,tabs:(a=o.filter(e=>e.id!==t.id),i=void 0===n?a.length:Math.min(Math.max(n,0),a.length),a.splice(i,0,t),a),activeTabId:t.id}}}return"file-tab-viewer"===r.kind||"data-table-tab-viewer"===r.kind&&"data-table-tab-viewer"===t.kind?{...e,data:{...r,tab:t}}:e}(e,l,n.insertIndex):e)),n?.nodeId&&s||w(l,u??{x:496,y:336})}catch{hn.error("文件预览打开失败")}},[w,t,r,u]),k=ew.useCallback(e=>{let n=t.find(e=>"multi-tab-system"===(e.data??{}).kind);j(e,n?{nodeId:n.id}:void 0)},[t,j]),N=ew.useCallback(async(e,t,n)=>{let r=t.file?.path,a=t.file?.machineId??"local";if(!r)throw hn.error("文件路径不可用"),Error("file path is unavailable");try{let i=await fu({machineId:a,path:r,content:n}),o={...t,title:i.name,modified:!1,defaultValue:"utf-8"===i.encoding?i.content:n,file:{...t.file,name:i.name,path:i.path,machineId:i.machine.id,mimeType:i.mimeType,kind:t.file?.kind,size:i.size,truncated:i.truncated}};v(e,o),hn.success("文件已保存")}catch(e){throw hn.error("文件保存失败"),e}},[v]),S=ew.useCallback((e,t,n)=>{w(t,p(n.clientX,n.clientY))},[w,p]),C=ew.useCallback(e=>{let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id"),r=n.find(e=>e.id===t),a=r?r.payloads?.[qd]:void 0;if(a)return a;let i=e.dataTransfer.getData(qd);if(i)try{return JSON.parse(i)}catch{return}},[n]),M=ew.useCallback((e,t,n)=>{r(r=>r.map(r=>r.id!==e?r:function(e,t,n){let r=e.data??{},a=Array.isArray(r.tabs)?r.tabs:[],i=new Set(a.map(e=>e.id)),o=n.tab.id,l=2;for(;i.has(o);)o=`${n.tab.id}-${l}`,l+=1;let s=[...a];return s.splice(Math.max(0,Math.min(t,s.length)),0,{...n.tab,id:o}),{...e,data:{...r,tabs:s,activeTabId:o}}}(r,t,n)))},[r]),E=ew.useCallback((e,t,n)=>{let r=C(n);r&&M(e,t,r)},[C,M]),I=ew.useCallback(e=>(function(e,t){for(let n of[...e].reverse()){if("multi-tab-system"!==(n.data??{}).kind)continue;let e=function(e){let t="number"==typeof e.width?e.width:"number"==typeof e.style?.width?e.style.width:"string"==typeof e.style?.width?Number.parseFloat(e.style.width):192,n="number"==typeof e.height?e.height:"number"==typeof e.style?.height?e.style.height:"string"==typeof e.style?.height?Number.parseFloat(e.style.height):112;return{width:Number.isFinite(t)?t:192,height:Number.isFinite(n)?n:112}}(n),r=t.x>=n.position.x&&t.x<=n.position.x+e.width,a=t.y>=n.position.y&&t.y<=n.position.y+e.height;if(r&&a)return n}})(t,e),[t]),P=ew.useCallback((t,n,r)=>(function(e,t,n,r){let a=Array.from(e.current?.querySelectorAll(".react-flow__node")??[]).find(e=>e.getAttribute("data-id")===t),i=a?.querySelector('[data-slot="multi-tab-list"]');if(!i)return r;let o=Array.from(i.querySelectorAll("[data-tab-id]"));for(let[e,t]of o.entries()){let r=t.getBoundingClientRect();if(n<r.left+r.width/2)return e}return o.length})(e,t,n,r),[e]),O=function({nodes:e,onTabsChange:t,onActiveTabChange:n,onRequestFileTab:r,onOpenWorkspaceFile:a,onTabChange:i,onSaveFileTab:o,onTerminalStateChange:l,onSideQueryBind:s,onTabDetach:c,onExternalTabDrop:d}){return ew.useMemo(()=>e.map(e=>{let u=e.data??{},f=(e.data??{}).kind;return f?{...e,data:{...u,content:(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(eip,{node:e}),(0,eb.jsx)(eeb,{kind:f,nodeId:e.id,tab:u.tab,tabs:u.tabs,activeTabId:u.activeTabId,terminalScopeId:`canvas:node:${e.id}`,terminalState:u.terminal,onTerminalStateChange:t=>l(e.id,t),sideQueryBinding:u.sideQuery,onSideQueryBind:s,onRequestFileTab:r,onOpenWorkspaceFile:a,onTabsChange:t,onTabChange:i,onSaveFileTab:o,onActiveTabChange:n,onTabDetach:c,onExternalTabDrop:d})]})}}:e}),[e,n,d,a,r,o,s,i,c,l,t])}({nodes:t,onTabsChange:g,onActiveTabChange:x,onRequestFileTab:h,onOpenWorkspaceFile:k,onTabChange:v,onSaveFileTab:N,onTerminalStateChange:b,onSideQueryBind:y,onTabDetach:S,onExternalTabDrop:E}),z=ew.useCallback(e=>{s.current+=1;let n=`${e.id}-${t.length+s.current}`;r(t=>[...t,function({template:e,nodeId:t,center:n}){let r={contentScale:2,kind:e.id};return"multi-tab-system"===e.id?r.tabs=[]:fr(e.id)&&(r.tab=fi(e.id,`${t}-tab`)),{id:t,type:"blank",position:u7(n,e.size),data:r,width:e.size.width,height:e.size.height,style:u6(e.size)}}({template:e,nodeId:n,center:u??{x:496,y:336}})]),i(void 0),d(!1),f(void 0)},[t.length,r,i,u]),A=ew.useCallback(e=>{let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id");if(!t)return;let a=n.find(e=>e.id===t),o=p(e.clientX,e.clientY),s=C(e),c=s?I(o):void 0;if(s&&c){e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move";let t=c.data??{},n=Array.isArray(t.tabs)?t.tabs:[],r=P(c.id,e.clientX,n.length);M(c.id,r,s),i(void 0);return}let d=a?a.payloads?.[qc]:void 0;if(!a||!d)return;e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move",l.current+=1;let u=`${d.node.id}-drop-${l.current}`;r(e=>[...e,function({source:e,nodeId:t,center:n}){let r={width:e.width??192,height:e.height??112};return{...e,id:t,position:u7(n,r),style:e.style??u6(r),selected:!1,data:{...e.data??{},resizing:!1}}}({source:d.node,nodeId:u,center:o})]),i(u)},[n,I,C,p,P,M,r,i]),T=ew.useCallback(e=>{Array.from(e.dataTransfer.types).some(e=>[qc,qd].includes(e))&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},[]),R=ew.useCallback((e,{flowPosition:t})=>{"add"===e&&(f(t),d(!0))},[]),D=ew.useCallback(e=>{a(t=>{if(t.find(t=>t.source===e.source&&t.target===e.target))return t;let n=t.find(t=>t.source===e.target&&t.target===e.source);return n?t.map(e=>e.id===n.id?{...e,data:{...e.data??{},bidirectional:!0}}:e):[...t,{id:`edge-${e.source}-${e.target}-${t.length+1}`,type:"connection",source:e.source,target:e.target,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle,data:{anchors:[]}}]})},[a]),_=ew.useCallback((e,t,n)=>{"cut-edge"===e?a(e=>e.filter(e=>e.id!==t)):a(r=>r.map(r=>{if(r.id!==t)return r;let a=[...r.data?.anchors??[]];return"add-anchor"===e&&n.anchor&&a.splice(n.anchorIndex??a.length,0,n.anchor),"move-anchor"===e&&n.anchor&&void 0!==n.anchorIndex&&(a[n.anchorIndex]=n.anchor),"delete-anchor"===e&&void 0!==n.anchorIndex&&a.splice(n.anchorIndex,1),{...r,data:{...r.data??{},anchors:a}}}))},[a]),L=ew.useCallback((e,n,{snappedPosition:l})=>{if("copy"===e)return void r(e=>{let t=e.find(e=>e.id===n);if(!t)return e;let r=`${t.id}-copy-${e.length+1}`;return i(r),[...e,{...t,id:r,position:l,selected:!1,data:{...t.data??{},resizing:!1}}]});if("cut"===e){let e,l,s,c,d,u=t.find(e=>e.id===n);if(!u)return;let f=(s=(l=function(e){let t=e.data??{},n=t.tab;if(n?.id&&fr(n.kind))return n;let r=t.kind;if(fr(r))return fi(r,e.id)}(e=fo(u)))?{tab:l,sourceNodeId:u.id}:void 0,c={[qc]:{node:e}},d={"application/vnd.vantaloom.clip-kind":l?"canvas-tab":"canvas-node",[qc]:u.id},s&&(c[qd]=s,d[qd]=JSON.stringify(s)),{id:`clip-${u.id}`,title:l?.title??"画布节点",description:l?"来自画布的独立标签页。":"来自节点画布的空白节点。",meta:`${Math.round(u.width??192)}x${Math.round(u.height??112)}`,icon:l?fa(l.kind):(0,eb.jsx)(uU,{className:"size-4"}),dragData:d,payloads:c});o(e=>[f,...e.filter(e=>e.id!==f.id)]),r(e=>e.filter(e=>e.id!==n)),a(e=>e.filter(e=>e.source!==n&&e.target!==n)),i(void 0)}},[t,o,a,r,i]);return{addPaletteOpen:c,addTemplateNode:z,filePickerDialog:(0,eb.jsx)(ZS,{open:void 0!==m,onOpenChange:e=>{e||h(void 0)},onSelectFile:e=>{h(void 0),j(e,m)}}),handleAddPaletteOpenChange:function(e){d(e),e||f(void 0)},handleCanvasAction:R,handleCanvasDragOver:T,handleCanvasDrop:A,handleNodeCanvasConnect:D,handleNodeCanvasEdgeAction:_,handleNodeCanvasNodeAction:L,renderedCanvasNodes:O}}({workspaceRef:d,nodes:e,clipboardItems:r,onNodesChange:a,onEdgesChange:i,onNodesSet:o,onEdgesSet:l,onSelectedNodeChange:s,onClipboardItemsChange:c});return(0,eb.jsxs)("div",{ref:d,className:"vtl-app-background vtl-canvas-workspace relative h-full w-full overflow-hidden",onDragOver:p,onDrop:g,children:[(0,eb.jsx)(sx,{"aria-label":"新建画布",className:"h-full min-h-0 rounded-none border-0",viewportClassName:"h-full",nodes:w,edges:t,nodeTypes:u5,edgeTypes:u4,onNodesChange:a,onEdgesChange:i,selectedNodeId:n,onSelectedNodeChange:s,defaultViewport:{x:0,y:0,zoom:.5},labels:{actions:"画布操作",add:"添加节点",select:"普通鼠标",connect:"连接工具",cut:"剪刀工具",drag:"拖拽工具",modeTools:"模式工具",resetZoom:"重置缩放",viewportTools:"视口工具",lockViewport:"锁定视口",visualSnap:"视觉吸附",nodeSnap:"节点吸附",snapTools:"吸附工具",nodeActions:"节点操作",resizeNode:"调整大小",copyNode:"复制节点",cutNode:"剪切节点"},onCanvasAction:h,onNodeCanvasConnect:x,onNodeCanvasEdgeAction:v,onNodeCanvasNodeAction:b}),(0,eb.jsx)(eih,{open:u,onOpenChange:m,onAdd:f}),y,(0,eb.jsx)(hs,{position:"top-right"})]})}vn.length;let eix="vantaloom:projects-changed";async function eiv(){return(await eiM("/api/local/projects")).projects??[]}async function eib(e){return eiM(`/api/local/projects/${encodeURIComponent(e)}`)}async function eiy(e){return eiM("/api/local/projects",{method:"POST",body:JSON.stringify(e)})}async function eiw(e,t){return eiM(`/api/local/projects/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}async function eij(e){return eiM(`/api/local/projects/${encodeURIComponent(e)}/budget`)}async function eik(e){return eiM(`/api/local/projects/${encodeURIComponent(e)}/codestats`)}async function eiN(e){return eiM(`/api/local/projects/${encodeURIComponent(e)}/gitgraph`)}async function eiS(e,t){return((await eiM(`/api/local/projects/${encodeURIComponent(e)}/conversations${t?"?includeArchived=true":""}`)).conversations??[]).map(e=>cv(e,void 0))}async function eiC(e,t){return cv((await eiM("/api/local/agent/conversations",{method:"POST",body:JSON.stringify({projectId:e,title:t?.title??"新对话",goal:t?.goal??""})})).conversation,void 0)}async function eiM(e,t){let n=await fetch((0,eT.localAPIURL)(e),{cache:"no-store",...t,headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error("string"==typeof r?.error?r.error:"project api failed");return r}let eiE=(0,ek.default)("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]),eiI=["运行环境","工作目录与预算","模型","编排与风控","确认创建"],eiP=[{value:"vantaloom",label:"Vantaloom(原生)"},{value:"claude-code",label:"Claude Code"},{value:"reclaude",label:"reclaude"}],eiO=[{value:"auto",label:"自动(auto)",desc:"不门控,自动放行所有工具调用。"},{value:"acceptEdits",label:"接受编辑(acceptEdits)",desc:"编辑自动放行,命令等高风险调用需审批。默认。"},{value:"ask",label:"逐项审批(ask)",desc:"所有非内联工具调用都需审批。"}],eiz=[{value:"off",label:"关闭(off)",desc:"auto 模式,不门控任何工具调用(仅硬危险命令仍被直接拒绝)。"},{value:"loose",label:"宽松(loose)",desc:"auto 模式 + 危险反思仅对高危调用介入。"},{value:"standard",label:"标准(standard)",desc:"acceptEdits 模式 + 危险反思对「风险及以上」介入。默认。"},{value:"strict",label:"严格(strict)",desc:"ask 模式 + 危险反思对全部工具调用介入。"},{value:"paranoid",label:"偏执(paranoid)",desc:"ask 模式 + 危险反思全覆盖,且发布类命令(publish/deploy/update)强制上卡。"}],eiA=[{value:"queue-park",label:"排队驻留(queue-park)",desc:"门触发时入卡并驻留,agent 继续做别的事,等你回来处理。默认。"},{value:"auto-reject-5m",label:"5 分钟自动拒(auto-reject-5m)",desc:"旧行为:无人处理时 5 分钟后自动拒绝该调用。"},{value:"auto-approve",label:"自动通过(auto-approve)",desc:"无人处理时自动放行(仅硬危险命令仍被拒)。谨慎使用。"}],eiT=[{value:"high-only",label:"仅高危(high-only)"},{value:"risky+",label:"风险及以上(risky+)"},{value:"all",label:"全部(all)"}],eiR=[{value:"wake-singleton",label:"唤醒单例(wake-singleton)"},{value:"spawn-per-card",label:"每卡派生(spawn-per-card)"}];function eiD({onCreated:e,onCancel:t}){let{machines:n}=vd(),{models:r}=vH(),[a,i]=ew.useState("local"),{engines:o}=kb(a),l=ew.useCallback(e=>"vantaloom"===e||(o.find(t=>t.engine===e)?.available??!1),[o]),s=ew.useCallback(e=>o.find(t=>t.engine===e)?.reason,[o]),[c,d]=ew.useState(0),[u,f]=ew.useState("vantaloom"),[m,h]=ew.useState(""),[p,g]=ew.useState("acceptEdits"),[x,v]=ew.useState(["local"]),[b,y]=ew.useState(""),[w,j]=ew.useState(""),[k,N]=ew.useState([]),[S,C]=ew.useState(""),[M,E]=ew.useState([]),[I,P]=ew.useState(""),[O,z]=ew.useState(""),[A,T]=ew.useState("standard"),[R,D]=ew.useState("queue-park"),[_,L]=ew.useState(!1),[$,F]=ew.useState("risky+"),[B,V]=ew.useState(!1),[H,U]=ew.useState("wake-singleton"),[q,W]=ew.useState(!1),[K,G]=ew.useState(""),X=kt(u);ew.useEffect(()=>{"vantaloom"===u||l(u)||f("vantaloom")},[u,l]),ew.useEffect(()=>{X&&(v(e=>1===e.length&&"local"===e[0]?e:["local"]),N(e=>e.length<=1?e:e.slice(-1)))},[X]);let Y="local"===a?"本机":n.find(e=>e.id===a)?.name??a,Z=b.trim().length>0,J=ew.useCallback(async()=>{if(!q){if(!b.trim()){d(1),G("工程名称不能为空");return}W(!0),G("");try{let t={maxPeers:ei_(I,1,16),maxSpawnDepth:ei_(O,1,5),hitlStrictness:A,awayMode:R,dangerAgent:{enabled:_,severity:_?$:"",modelRef:""},reviewerAgent:{enabled:B,mode:B?H:"",modelRef:""}},n=await eiy({title:b.trim(),summary:w.trim()||void 0,ownerMachineId:a,settingsTemplate:{subagents:[],mainModels:X?[]:M,folders:k,blockedCommands:[],allowedTools:[],deniedTools:[],plugins:[],hosts:X?["local"]:x,permissionMode:p,engine:u,ccModel:X?m:void 0},policy:t,budgetTokens:ei_(S,0,Number.MAX_SAFE_INTEGER)});e(n.id)}catch(e){G(e instanceof Error?e.message:"工程创建失败")}finally{W(!1)}}},[R,S,m,q,_,$,u,k,A,x,X,M,I,O,e,a,p,B,H,w,b]),Q=c===eiI.length-1;return(0,eb.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col",children:[(0,eb.jsx)("header",{className:"shrink-0 px-6 pt-8 pb-6",children:(0,eb.jsx)("ol",{className:"mx-auto flex max-w-2xl items-center",children:eiI.map((e,t)=>{let n=t<c,r=t===c;return(0,eb.jsxs)("li",{className:"flex min-w-0 flex-1 items-center last:flex-none",children:[(0,eb.jsxs)("button",{type:"button","aria-current":r?"step":void 0,"aria-label":`第 ${t+1} 步:${e}`,onClick:()=>{t<=c&&d(t)},className:"group flex shrink-0 items-center gap-2 outline-none",children:[(0,eb.jsx)("span",{className:(0,ez.cn)("inline-flex size-8 shrink-0 items-center justify-center rounded-full border text-sm font-medium transition-colors",n?"border-primary bg-primary text-primary-foreground":r?"border-primary text-primary ring-2 ring-primary/30":"border-border bg-background text-muted-foreground"),children:n?(0,eb.jsx)(h6,{className:"size-4"}):t+1}),(0,eb.jsx)("span",{className:(0,ez.cn)("hidden truncate text-sm font-medium transition-colors sm:inline",r?"text-foreground":n?"text-foreground/80":"text-muted-foreground"),children:e})]}),t<eiI.length-1?(0,eb.jsx)("span",{"aria-hidden":"true",className:(0,ez.cn)("mx-3 h-px min-w-6 flex-1 transition-colors",t<c?"bg-primary":"bg-border")}):null]},e)})})}),(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-6",children:(0,eb.jsxs)("div",{className:"mx-auto w-full max-w-2xl",children:[0===c?(0,eb.jsxs)("div",{className:"grid gap-6",children:[(0,eb.jsx)(eiF,{value:a,onChange:i,machines:n}),(0,eb.jsxs)(ei$,{label:"运行引擎(engine)",children:[(0,eb.jsxs)(gU,{value:u,onValueChange:e=>f(e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{placeholder:"选择运行引擎"})}),(0,eb.jsx)(xS,{children:eiP.map(e=>{let t=l(e.value);return(0,eb.jsxs)(xC,{value:e.value,disabled:!t,children:[e.label,t?"":"(不可用)"]},e.value)})})]}),s(u)?(0,eb.jsx)("p",{className:"mt-1.5 text-xs text-muted-foreground",children:s(u)}):null,X?(0,eb.jsx)("p",{className:"mt-1.5 text-xs text-muted-foreground",children:"Claude Code(含 reclaude)运行在所选 owner 机器上;其工具锁定在该机本地。"}):null]}),X?(0,eb.jsxs)(ei$,{label:"Claude Code 模型(ccModel)",children:[(0,eb.jsxs)(gU,{value:""===m?j9:m,onValueChange:e=>h(e===j9?"":e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{placeholder:"选择 Claude Code 模型"})}),(0,eb.jsx)(xS,{children:ke.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]}),(0,eb.jsx)("p",{className:"mt-1.5 text-xs text-muted-foreground",children:"模型由 Claude Code 提供,不走 Vantaloom 模型路由。"})]}):null,(0,eb.jsxs)(ei$,{label:"权限模式(permissionMode)",hint:"新对话默认的工具调用门控强度。与下一步的 HITL 严格度独立设置。",children:[(0,eb.jsxs)(gU,{value:p,onValueChange:g,children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:eiO.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]}),(0,eb.jsx)("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:eiO.find(e=>e.value===p)?.desc})]}),(0,eb.jsx)(j7,{value:x,onValueChange:v,disabled:X,hint:X?"Claude Code 的工具锁定在所选 owner 机器本地,可访问主机已锁定。":void 0})]}):null,1===c?(0,eb.jsxs)("div",{className:"grid gap-6",children:[(0,eb.jsxs)(ei$,{label:"工程名称(必填)",children:[(0,eb.jsx)(eA,{value:b,placeholder:"新工程",onChange:e=>{y(e.currentTarget.value),K&&G("")}}),Z?null:(0,eb.jsx)("p",{className:"mt-1.5 text-xs text-amber-500",children:"工程名称不能为空。"})]}),(0,eb.jsx)(ei$,{label:"摘要(可选)",hint:"一句话描述这个工程的目标。",children:(0,eb.jsx)(w2,{value:w,onChange:e=>j(e.currentTarget.value),placeholder:"暂无工程摘要",rows:3})}),(0,eb.jsx)(j2,{title:"可访问的工作目录",value:k,onValueChange:e=>N(X?e.slice(-1):e)}),X?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"Claude Code 仅支持单个工作目录(作为会话的工作根目录)。"}):null,(0,eb.jsx)(ei$,{label:"预算上限(budgetTokens,可选)",hint:"工程累计 token 上限。留空 / 0 = 沿用全局默认(当前 5,000,000)。",children:(0,eb.jsx)(eA,{type:"number",min:0,step:1e5,value:S,onChange:e=>C(e.currentTarget.value),placeholder:"0 = 全局默认",className:"w-52"})})]}):null,2===c?X?(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsx)("span",{className:"text-base font-semibold tracking-normal text-foreground",children:"Claude Code 模型"}),(0,eb.jsxs)(gU,{value:""===m?j9:m,onValueChange:e=>h(e===j9?"":e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{placeholder:"选择 Claude Code 模型"})}),(0,eb.jsx)(xS,{children:ke.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"模型由 Claude Code 提供,不走 Vantaloom 模型路由。"})]}):(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsx)("span",{className:"text-base font-semibold tracking-normal text-foreground",children:"可用模型"}),(0,eb.jsxs)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:["选择本工程新建对话默认可用的模型(mainModels)。第一个为主模型。",(0,eb.jsxs)("span",{className:"text-amber-600 dark:text-amber-400",children:[" ","未选择任何模型时,工程内新建的对话将无模型可用、无法运行。"]})]})]}),(0,eb.jsx)(vU,{mainModels:M,onMainModelsChange:E})]}):null,3===c?(0,eb.jsxs)("div",{className:"grid gap-6",children:[(0,eb.jsx)(ei$,{label:"同伴并发上限(maxPeers,可选)",hint:`后台同时存在的同伴会话上限。留空 = 默认 8,范围 1–16。`,children:(0,eb.jsx)(eA,{type:"number",min:1,max:16,value:I,onChange:e=>P(e.currentTarget.value),placeholder:`默认 8`,className:"w-40"})}),(0,eb.jsx)(ei$,{label:"派生深度上限(maxSpawnDepth,可选)",hint:`同伴再派生同伴的最大层数。留空 = 默认 3,范围 1–5。`,children:(0,eb.jsx)(eA,{type:"number",min:1,max:5,value:O,onChange:e=>z(e.currentTarget.value),placeholder:`默认 3`,className:"w-40"})}),(0,eb.jsxs)(ei$,{label:"HITL 严格度(hitlStrictness)",children:[(0,eb.jsxs)(gU,{value:A,onValueChange:e=>T(e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:eiz.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]}),(0,eb.jsx)("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:eiz.find(e=>e.value===A)?.desc})]}),(0,eb.jsxs)(ei$,{label:"离开模式(awayMode)",hint:"无人值守时审批门的行为。",children:[(0,eb.jsxs)(gU,{value:R,onValueChange:e=>D(e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:eiA.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]}),(0,eb.jsx)("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:eiA.find(e=>e.value===R)?.desc})]}),(0,eb.jsxs)("div",{className:"rounded-lg border border-border bg-muted/30 p-3",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground [&_svg]:size-4 [&_svg]:text-amber-500",children:[(0,eb.jsx)(m0,{}),"危险反思智能体"]}),(0,eb.jsx)(bG,{checked:_,onCheckedChange:L})]}),(0,eb.jsxs)("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:["开启后,风险调用会先经一个模型「反思」判定(通过 / 拒绝 / 升级人工),再到人工审批门。",(0,eb.jsxs)("span",{className:"text-amber-600 dark:text-amber-400",children:[" ","会占用一个同伴槽位并消耗预算。"]})]}),_?(0,eb.jsx)("div",{className:"mt-3",children:(0,eb.jsx)(ei$,{label:"触发档位(severity)",children:(0,eb.jsxs)(gU,{value:$,onValueChange:e=>F(e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:eiT.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})})}):null]}),(0,eb.jsxs)("div",{className:"rounded-lg border border-border bg-muted/30 p-3",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground [&_svg]:size-4 [&_svg]:text-sky-teal",children:[(0,eb.jsx)(uH,{}),"评审智能体"]}),(0,eb.jsx)(bG,{checked:B,onCheckedChange:V})]}),(0,eb.jsxs)("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:["开启后,卡片进入「评审」状态会唤醒 / 派生一个评审智能体复核。",(0,eb.jsxs)("span",{className:"text-sky-700 dark:text-sky-400",children:[" ","会占用一个同伴槽位并消耗预算。"]})]}),B?(0,eb.jsx)("div",{className:"mt-3",children:(0,eb.jsx)(ei$,{label:"模式(mode)",hint:"单例唤醒省槽位;每卡派生会迅速消耗同伴槽位。",children:(0,eb.jsxs)(gU,{value:H,onValueChange:e=>U(e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:eiR.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})})}):null]})]}):null,4===c?(0,eb.jsxs)("div",{className:"grid gap-4",children:[(0,eb.jsxs)("div",{className:"grid gap-3 rounded-xl border bg-card p-5",children:[(0,eb.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"配置摘要"}),(0,eb.jsxs)("div",{className:"grid gap-2.5",children:[(0,eb.jsx)(eiL,{icon:(0,eb.jsx)(h9,{}),label:"工程名称",value:b.trim()||"(未填写)"}),(0,eb.jsx)(eiL,{icon:(0,eb.jsx)(eP,{}),label:"运行环境",value:Y}),(0,eb.jsx)(eiL,{icon:(0,eb.jsx)(uK,{}),label:"运行引擎",value:eiP.find(e=>e.value===u)?.label??u}),(0,eb.jsx)(eiL,{icon:(0,eb.jsx)(h3,{}),label:"模型",value:X?kn(m):M.length>0?M.map(e=>r.find(t=>t.value===e)?.label??e).join("、"):"未选择(工程内新建对话将无模型可用)"}),(0,eb.jsx)(eiL,{icon:(0,eb.jsx)(eiE,{}),label:"权限 / HITL",value:`${eiO.find(e=>e.value===p)?.label??p} \xb7 ${eiz.find(e=>e.value===A)?.label??A}`}),(0,eb.jsx)(eiL,{icon:(0,eb.jsx)(enH,{}),label:"编排上限",value:`同伴 ${I.trim()||`默认8`} \xb7 深度 ${O.trim()||`默认3`}`}),(0,eb.jsx)(eiL,{icon:(0,eb.jsx)(Yv,{}),label:"预算上限",value:S.trim()&&Number(S.trim())>0?`${Number(S.trim()).toLocaleString("en-US")} tokens`:"全局默认"}),(0,eb.jsx)(eiL,{icon:(0,eb.jsx)(h9,{}),label:"工作目录",value:k.length>0?`${k.length} 个目录`:"未选择(可稍后在工程设置中配置)"}),(0,eb.jsx)(eiL,{icon:(0,eb.jsx)(uH,{}),label:"监督智能体",value:[_?"危险反思":null,B?"评审":null].filter(Boolean).join(" · ")||"未启用"})]})]}),K?(0,eb.jsx)("div",{className:"text-sm text-destructive",children:K}):null]}):null]})}),(0,eb.jsx)("footer",{className:"flex shrink-0 items-center justify-between px-6 pb-8",children:(0,eb.jsxs)("div",{className:"mx-auto flex w-full max-w-2xl items-center justify-between",children:[(0,eb.jsxs)(eO.Button,{type:"button",variant:"ghost",disabled:q,onClick:()=>{0===c?t?.():d(e=>Math.max(0,e-1))},children:[(0,eb.jsx)(h8,{className:"size-4"}),0===c?"取消":"上一步"]}),Q?(0,eb.jsxs)(eO.Button,{type:"button",disabled:q||!Z,onClick:()=>void J(),children:[(0,eb.jsx)(pe,{className:"size-4"}),q?"创建中…":"创建"]}):(0,eb.jsxs)(eO.Button,{type:"button",disabled:1===c&&!Z,onClick:()=>d(e=>Math.min(eiI.length-1,e+1)),children:["下一步",(0,eb.jsx)(h7,{className:"size-4"})]})]})})]})}function ei_(e,t,n){let r=e.trim();if(""===r)return 0;let a=Math.floor(Number(r));return!Number.isFinite(a)||a<=0?0:Math.min(n,Math.max(t,a))}function eiL({icon:e,label:t,value:n}){return(0,eb.jsxs)("div",{className:"grid grid-cols-[auto_5rem_minmax(0,1fr)] items-center gap-3",children:[(0,eb.jsx)("span",{className:"inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground [&_svg]:size-4",children:e}),(0,eb.jsx)("span",{className:"text-sm text-muted-foreground",children:t}),(0,eb.jsx)("span",{className:"min-w-0 truncate text-sm font-medium text-foreground",children:n})]})}function ei$({label:e,hint:t,children:n}){return(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)("span",{className:"text-sm font-medium text-foreground",children:e}),n,t?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground/80",children:t}):null]})}function eiF({value:e,onChange:t,machines:n}){let r=ew.useMemo(()=>{let e=[],t=!1;for(let r of n)if(r.isLocal)t=!0,e.unshift({id:"local",name:"本机",online:!0,reachable:!0});else{let t="online"===r.status;e.push({id:r.id,name:r.name,online:t,reachable:r.reachable??t})}return t||e.unshift({id:"local",name:"本机",online:!0,reachable:!0}),e},[n]);return(0,eb.jsx)(ei$,{label:"工程运行位置",hint:"选择该工程的运行时实际运行在工作组里的哪台机器(默认本机)。",children:(0,eb.jsxs)(gU,{value:e,onValueChange:t,children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{placeholder:"选择运行位置"})}),(0,eb.jsx)(xS,{children:r.map(e=>{let t=e.reachable?"":e.online?"(在线·不可达)":"(离线)";return(0,eb.jsxs)(xC,{value:e.id,disabled:!e.reachable,children:[e.name,t]},e.id)})})]})})}let eiB=[{value:"off",label:"关闭(off)",desc:"auto 模式,不门控任何工具调用(仅硬危险命令仍被直接拒绝)。"},{value:"loose",label:"宽松(loose)",desc:"auto 模式 + 危险反思仅对高危调用介入。"},{value:"standard",label:"标准(standard)",desc:"acceptEdits 模式 + 危险反思对「风险及以上」介入。默认。"},{value:"strict",label:"严格(strict)",desc:"ask 模式 + 危险反思对全部工具调用介入。"},{value:"paranoid",label:"偏执(paranoid)",desc:"ask 模式 + 危险反思全覆盖,且发布类命令(publish/deploy/update)强制上卡。"}],eiV=[{value:"queue-park",label:"排队驻留(queue-park)",desc:"门触发时入卡并驻留,agent 继续做别的事,等你回来处理。默认。"},{value:"auto-reject-5m",label:"5 分钟自动拒(auto-reject-5m)",desc:"旧行为:无人处理时 5 分钟后自动拒绝该调用。"},{value:"auto-approve",label:"自动通过(auto-approve)",desc:"无人处理时自动放行(仅硬危险命令仍被拒)。谨慎使用。"}],eiH=[{value:"high-only",label:"仅高危(high-only)"},{value:"risky+",label:"风险及以上(risky+)"},{value:"all",label:"全部(all)"}],eiU=[{value:"wake-singleton",label:"唤醒单例(wake-singleton)"},{value:"spawn-per-card",label:"每卡派生(spawn-per-card)"}],eiq=[{value:"vantaloom",label:"Vantaloom(原生)"},{value:"claude-code",label:"Claude Code"},{value:"reclaude",label:"reclaude"}],eiW=[{value:"auto",label:"自动(auto)",desc:"不门控,自动放行所有工具调用。"},{value:"acceptEdits",label:"接受编辑(acceptEdits)",desc:"编辑自动放行,命令等高风险调用需审批。"},{value:"ask",label:"逐项审批(ask)",desc:"所有非内联工具调用都需审批。"}],eiK=[{value:"basic",label:"基本",icon:(0,eb.jsx)(era,{})},{value:"models",label:"模型",icon:(0,eb.jsx)(h3,{})},{value:"tools",label:"工具权限",icon:(0,eb.jsx)(enW,{})},{value:"commands",label:"禁止命令",icon:(0,eb.jsx)(u0,{})},{value:"folders",label:"工作区文件夹",icon:(0,eb.jsx)(b3,{})},{value:"hosts",label:"可访问主机",icon:(0,eb.jsx)(Yw,{})},{value:"engine",label:"引擎",icon:(0,eb.jsx)(enW,{})},{value:"assets",label:"扩展",icon:(0,eb.jsx)(kV,{})},{value:"orchestration",label:"编排与预算",icon:(0,eb.jsx)(enH,{})},{value:"hitl",label:"HITL 风控",icon:(0,eb.jsx)(eiE,{})}];function eiG({projectId:e,onClose:t}){let[n,r]=ew.useState(),[a,i]=ew.useState(!0),[o,l]=ew.useState(),[s,c]=ew.useState(null),[d,u]=ew.useState(!1),[f,m]=ew.useState(),[h,p]=ew.useState(),[g,x]=ew.useState("basic"),{models:v,loading:b}=vH(),y=ew.useCallback(async()=>{i(!0),l(void 0);try{let t=await eib(e);r(t),c(eiY(t))}catch(e){l(e instanceof Error?e.message:"工程加载失败")}finally{i(!1)}},[e]);ew.useEffect(()=>{y()},[y]);let w=ew.useMemo(()=>{var e,t;let r;return!!n&&!!s&&(e=s,t=eiY(n),r=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),!(e.title===t.title&&e.summary===t.summary&&e.maxPeers===t.maxPeers&&e.maxSpawnDepth===t.maxSpawnDepth&&e.budgetTokens===t.budgetTokens&&e.budgetSoftPct===t.budgetSoftPct&&e.budgetHardPct===t.budgetHardPct&&e.approvalParkTtlSeconds===t.approvalParkTtlSeconds&&e.hitlStrictness===t.hitlStrictness&&e.awayMode===t.awayMode&&e.dangerEnabled===t.dangerEnabled&&e.dangerSeverity===t.dangerSeverity&&e.dangerModelRef===t.dangerModelRef&&e.reviewerEnabled===t.reviewerEnabled&&e.reviewerMode===t.reviewerMode&&e.reviewerModelRef===t.reviewerModelRef&&e.engine===t.engine&&e.permissionMode===t.permissionMode&&e.ccModel===t.ccModel&&r(e.allowedTools,t.allowedTools)&&r(e.blockedCommands,t.blockedCommands)&&r(e.mainModels,t.mainModels)&&r(e.folders,t.folders)&&r(e.hosts,t.hosts)))},[n,s]),j=s?eiJ(s):void 0;async function k(){if(!s||!n)return;let t=eiJ(s);if(t)return void m(t);u(!0),m(void 0);try{var a;let t,n,i,o=await eiw(e,(a=s,t={maxPeers:eiZ(a.maxPeers,1,16),maxSpawnDepth:eiZ(a.maxSpawnDepth,1,5),budgetSoftPct:eiZ(a.budgetSoftPct,1,100),budgetHardPct:eiZ(a.budgetHardPct,1,200),approvalParkTtlSeconds:Math.max(0,Math.floor(Number(a.approvalParkTtlSeconds.trim()||"0"))||0),hitlStrictness:a.hitlStrictness||"",awayMode:a.awayMode||"",dangerAgent:{enabled:a.dangerEnabled,severity:a.dangerSeverity||"",modelRef:a.dangerModelRef.trim()},reviewerAgent:{enabled:a.reviewerEnabled,mode:a.reviewerMode||"",modelRef:a.reviewerModelRef.trim()}},n=kt(a.engine),i={...a.baseSettings,blockedCommands:a.blockedCommands,allowedTools:a.allowedTools,permissionMode:a.permissionMode,engine:a.engine,mainModels:n?[]:a.mainModels,ccModel:n?a.ccModel:void 0,folders:n?a.folders.slice(-1):a.folders,hosts:a.hosts},{title:a.title.trim(),summary:a.summary.trim(),budgetTokens:eiZ(a.budgetTokens,0,Number.MAX_SAFE_INTEGER),policy:t,settingsTemplate:i}));r(o),c(eiY(o)),p(Date.now())}catch(e){m(e instanceof Error?e.message:"保存失败")}finally{u(!1)}}function N(e){c(t=>t?{...t,...e}:t),p(void 0)}if(a&&!s)return(0,eb.jsx)("div",{className:"vtl-app-background flex h-full w-full items-center justify-center text-muted-foreground",children:(0,eb.jsx)(eM,{className:"size-6 animate-spin"})});if(o&&!s)return(0,eb.jsxs)("div",{className:"vtl-app-background flex h-full w-full flex-col items-center justify-center gap-3 px-6 py-16 text-center",children:[(0,eb.jsx)(m0,{className:"size-8 text-hot-pink"}),(0,eb.jsx)("p",{className:"text-sm text-muted-foreground",children:o}),(0,eb.jsx)(eO.Button,{type:"button",variant:"outline",onClick:()=>void y(),children:"重试"})]});if(!s)return null;let S={basic:(0,eb.jsx)("div",{className:"flex w-full flex-col gap-6",children:(0,eb.jsxs)(eiQ,{icon:(0,eb.jsx)(era,{className:"size-4"}),title:"基本",desc:"工程名称与摘要。",children:[(0,eb.jsx)(ei0,{label:"名称",children:(0,eb.jsx)(eA,{value:s.title,onChange:e=>N({title:e.target.value}),placeholder:"工程名称"})}),(0,eb.jsx)(ei0,{label:"摘要",hint:"一句话描述这个工程的目标(可选)。",children:(0,eb.jsx)(w2,{value:s.summary,onChange:e=>N({summary:e.target.value}),placeholder:"暂无工程摘要",rows:3})})]})}),models:(0,eb.jsx)("div",{className:"flex w-full flex-col gap-6",children:(0,eb.jsxs)(eiQ,{icon:(0,eb.jsx)(h3,{className:"size-4"}),title:"模型",desc:"本工程新建对话默认可用的模型(mainModels)。与对话设置使用同一选择器。",children:[(0,eb.jsxs)("div",{className:"flex items-start gap-2 rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs leading-relaxed text-amber-700 dark:text-amber-300 [&_svg]:mt-0.5 [&_svg]:size-4 [&_svg]:shrink-0",children:[(0,eb.jsx)(m0,{}),(0,eb.jsxs)("span",{children:[(0,eb.jsx)("strong",{children:"关键:"}),"未选择任何模型时,本工程内新建的对话将无模型可用、无法运行。请至少选择一个模型。"]})]}),kt(s.engine)?(0,eb.jsx)(ei0,{label:"Claude Code 模型(ccModel)",hint:"当前引擎为 Claude Code,模型由其提供,不走 Vantaloom 模型路由。",icon:(0,eb.jsx)(h3,{className:"size-4"}),children:(0,eb.jsxs)(gU,{value:""===s.ccModel?j9:s.ccModel,onValueChange:e=>N({ccModel:e===j9?"":e}),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{placeholder:"选择 Claude Code 模型"})}),(0,eb.jsx)(xS,{children:ke.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})}):(0,eb.jsx)(vU,{mainModels:s.mainModels,onMainModelsChange:e=>N({mainModels:e})})]})}),tools:(0,eb.jsx)("div",{className:"flex w-full flex-col gap-4",children:(0,eb.jsx)(j0,{value:s.allowedTools,onChange:e=>N({allowedTools:e})})}),commands:(0,eb.jsx)("div",{className:"flex w-full flex-col gap-4",children:(0,eb.jsx)(j1,{value:s.blockedCommands,onChange:e=>N({blockedCommands:e})})}),folders:(0,eb.jsxs)("div",{className:"flex w-full flex-col gap-3",children:[0===s.folders.length?(0,eb.jsxs)("div",{className:"flex items-start gap-2 rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs leading-relaxed text-amber-700 dark:text-amber-300 [&_svg]:mt-0.5 [&_svg]:size-4 [&_svg]:shrink-0",children:[(0,eb.jsx)(m0,{}),(0,eb.jsxs)("span",{children:[(0,eb.jsx)("strong",{children:"关键:"}),"未配置工作区文件夹时,本工程内新建的对话",(0,eb.jsx)("strong",{children:"没有任何工作目录"}),",智能体将无处读写文件。请至少添加一个文件夹。"]})]}):null,(0,eb.jsx)(j2,{title:"可访问的工作区文件夹",value:s.folders,onValueChange:e=>N({folders:kt(s.engine)?e.slice(-1):e})}),kt(s.engine)?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"Claude Code 仅支持单个工作目录(作为会话的工作根目录)。"}):null]}),hosts:(0,eb.jsx)("div",{className:"flex w-full flex-col gap-4",children:(0,eb.jsx)(j7,{value:s.hosts,onValueChange:e=>N({hosts:e}),disabled:kt(s.engine),hint:kt(s.engine)?"Claude Code 的工具锁定在所选 owner 机器本地,可访问主机已锁定。":void 0})}),engine:(0,eb.jsx)("div",{className:"flex w-full flex-col gap-6",children:(0,eb.jsxs)(eiQ,{icon:(0,eb.jsx)(enW,{className:"size-4"}),title:"引擎",desc:"新对话的默认引擎与权限模式。",children:[(0,eb.jsx)(ei0,{label:"引擎(engine)",children:(0,eb.jsxs)(gU,{value:s.engine,onValueChange:e=>N({engine:e}),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:eiq.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})}),(0,eb.jsxs)(ei0,{label:"权限模式(permissionMode)",children:[(0,eb.jsxs)(gU,{value:s.permissionMode,onValueChange:e=>N({permissionMode:e}),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:eiW.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]}),(0,eb.jsx)("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:eiW.find(e=>e.value===s.permissionMode)?.desc})]})]})}),orchestration:(0,eb.jsxs)("div",{className:"flex w-full flex-col gap-6",children:[(0,eb.jsxs)(eiQ,{icon:(0,eb.jsx)(enH,{className:"size-4"}),title:"编排上限",desc:"限制同伴并发数与派生深度,避免后台 peer 失控扩散。0 / 留空 = 全局默认。",children:[(0,eb.jsx)(ei0,{label:"同伴并发上限(maxPeers)",hint:`后台同时存在的同伴会话上限。默认 8,范围 1–16。`,children:(0,eb.jsx)(eA,{type:"number",min:1,max:16,value:s.maxPeers,onChange:e=>N({maxPeers:e.target.value}),placeholder:`默认 8`,className:"w-40"})}),(0,eb.jsx)(ei0,{label:"派生深度上限(maxSpawnDepth)",hint:`同伴再派生同伴的最大层数。默认 3,范围 1–5。`,children:(0,eb.jsx)(eA,{type:"number",min:1,max:5,value:s.maxSpawnDepth,onChange:e=>N({maxSpawnDepth:e.target.value}),placeholder:`默认 3`,className:"w-40"})})]}),(0,eb.jsxs)(eiQ,{icon:(0,eb.jsx)(Yv,{className:"size-4"}),title:"预算",desc:"工程级 token 预算上限与软 / 硬阈值。与概览页的预算条共用同一更新逻辑——0 = 全局默认。",children:[(0,eb.jsx)(ei0,{label:"预算上限(budgetTokens)",hint:"工程累计 token 上限。0 = 恢复全局默认(当前 5,000,000)。",children:(0,eb.jsx)(eA,{type:"number",min:0,step:1e5,value:s.budgetTokens,onChange:e=>N({budgetTokens:e.target.value}),placeholder:"0 = 全局默认",className:"w-52"})}),(0,eb.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,eb.jsx)(ei0,{label:"软阈值 %(budgetSoftPct)",hint:`接近上限时提示。默认 80%。0 = 默认。`,children:(0,eb.jsx)(eA,{type:"number",min:0,max:100,value:s.budgetSoftPct,onChange:e=>N({budgetSoftPct:e.target.value}),placeholder:`默认 80`,className:"w-32"})}),(0,eb.jsx)(ei0,{label:"硬阈值 %(budgetHardPct)",hint:`达到后阻止新增 peer。默认 100%。0 = 默认。`,children:(0,eb.jsx)(eA,{type:"number",min:0,max:200,value:s.budgetHardPct,onChange:e=>N({budgetHardPct:e.target.value}),placeholder:`默认 100`,className:"w-32"})})]})]})]}),hitl:(0,eb.jsx)("div",{className:"flex w-full flex-col gap-6",children:(0,eb.jsxs)(eiQ,{icon:(0,eb.jsx)(eiE,{className:"size-4"}),title:"HITL 风控",desc:"人类在环(Human-in-the-loop)的严格度、离开模式与监督智能体。",children:[(0,eb.jsxs)(ei0,{label:"严格度(hitlStrictness)",children:[(0,eb.jsxs)(gU,{value:s.hitlStrictness||"standard",onValueChange:e=>N({hitlStrictness:e}),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:eiB.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]}),(0,eb.jsx)("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:eiB.find(e=>e.value===(s.hitlStrictness||"standard"))?.desc})]}),(0,eb.jsxs)(ei0,{label:"离开模式(awayMode)",hint:"无人值守时审批门的行为。",children:[(0,eb.jsxs)(gU,{value:s.awayMode||"queue-park",onValueChange:e=>N({awayMode:e}),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:eiV.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]}),(0,eb.jsx)("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:eiV.find(e=>e.value===(s.awayMode||"queue-park"))?.desc})]}),(0,eb.jsx)(ei0,{label:"驻留 TTL(秒,approvalParkTtlSeconds)",hint:"排队驻留下审批卡的存活秒数。0 = 无限驻留(直到你处理)。",children:(0,eb.jsx)(eA,{type:"number",min:0,value:s.approvalParkTtlSeconds,onChange:e=>N({approvalParkTtlSeconds:e.target.value}),placeholder:"0 = 无限驻留",className:"w-40"})}),(0,eb.jsxs)("div",{className:"rounded-lg border border-border bg-muted/30 p-3",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground [&_svg]:size-4 [&_svg]:text-amber-500",children:[(0,eb.jsx)(m0,{}),"危险反思智能体"]}),(0,eb.jsx)(bG,{checked:s.dangerEnabled,onCheckedChange:e=>N({dangerEnabled:e})})]}),(0,eb.jsxs)("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:["开启后,风险调用会先经一个模型「反思」判定(通过 / 拒绝 / 升级人工),再到人工审批门。",(0,eb.jsxs)("span",{className:"text-amber-600 dark:text-amber-400",children:[" ","会占用一个同伴槽位并消耗预算。"]})]}),s.dangerEnabled?(0,eb.jsxs)("div",{className:"mt-3 grid gap-3",children:[(0,eb.jsx)(ei0,{label:"触发档位(severity)",children:(0,eb.jsxs)(gU,{value:s.dangerSeverity||"risky+",onValueChange:e=>N({dangerSeverity:e}),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:eiH.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})}),(0,eb.jsx)(ei0,{label:"模型(modelRef,可选)",hint:"留空使用工程 / 全局默认模型。",children:(0,eb.jsx)(Ye,{mode:"single",models:v,loading:b,value:s.dangerModelRef,onChange:e=>N({dangerModelRef:e}),clearLabel:"默认(自动选择)",emptyHint:"尚未配置可用模型。请先在「模型路由」中配置渠道与模型。"})})]}):null]}),(0,eb.jsxs)("div",{className:"rounded-lg border border-border bg-muted/30 p-3",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground [&_svg]:size-4 [&_svg]:text-sky-teal",children:[(0,eb.jsx)(uH,{}),"评审智能体"]}),(0,eb.jsx)(bG,{checked:s.reviewerEnabled,onCheckedChange:e=>N({reviewerEnabled:e})})]}),(0,eb.jsxs)("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:["开启后,卡片进入「评审」状态会唤醒 / 派生一个评审智能体复核。",(0,eb.jsxs)("span",{className:"text-sky-700 dark:text-sky-400",children:[" ","会占用一个同伴槽位并消耗预算。"]})]}),s.reviewerEnabled?(0,eb.jsxs)("div",{className:"mt-3 grid gap-3",children:[(0,eb.jsx)(ei0,{label:"模式(mode)",hint:"单例唤醒省槽位;每卡派生会迅速消耗同伴槽位。",children:(0,eb.jsxs)(gU,{value:s.reviewerMode||"wake-singleton",onValueChange:e=>N({reviewerMode:e}),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:eiU.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})}),(0,eb.jsx)(ei0,{label:"模型(modelRef,可选)",hint:"留空使用工程 / 全局默认模型。",children:(0,eb.jsx)(Ye,{mode:"single",models:v,loading:b,value:s.reviewerModelRef,onChange:e=>N({reviewerModelRef:e}),clearLabel:"默认(自动选择)",emptyHint:"尚未配置可用模型。请先在「模型路由」中配置渠道与模型。"})})]}):null]})]})})},C=eiK.map(t=>"assets"===t.value?{id:t.value,title:t.label,icon:t.icon,children:enS("project",{projectId:e,workspaceFolder:s.folders[0]})}:{id:t.value,title:t.label,icon:t.icon,content:S[t.value]});return(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex items-center gap-2 border-b px-3 py-2.5",children:[(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon","aria-label":"关闭设置",onClick:()=>t?.(),className:"shrink-0",children:(0,eb.jsx)(fV.XIcon,{className:"size-5"})}),(0,eb.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(era,{}),"工程设置"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:n?.title??"工程"})]})]}),(0,eb.jsx)(etm,{sections:C,sectionId:g,onSelectionChange:({sectionId:e})=>x(e),defaultSectionId:"basic",labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto pb-28"}),(0,eb.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-10 flex justify-center px-6 pb-4",children:(0,eb.jsxs)("div",{className:(0,ez.cn)("pointer-events-auto flex items-center gap-3 rounded-full border border-border bg-card/95 px-4 py-2 shadow-lg backdrop-blur transition-opacity",w||f||h?"opacity-100":"pointer-events-none opacity-0"),children:[f?(0,eb.jsx)("span",{className:"text-xs text-hot-pink",children:f}):j?(0,eb.jsx)("span",{className:"text-xs text-amber-500",children:j}):w?(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:"有未保存的更改"}):h?(0,eb.jsxs)("span",{className:"flex items-center gap-1 text-xs text-emerald-600 dark:text-emerald-400 [&_svg]:size-3.5",children:[(0,eb.jsx)(h6,{}),"已保存"]}):null,w?(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"sm",disabled:d,onClick:()=>n&&c(eiY(n)),children:"撤销"}):null,(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",disabled:!w||d||!!j,onClick:()=>void k(),children:[d?(0,eb.jsx)(eM,{className:"size-4 animate-spin"}):(0,eb.jsx)(h6,{className:"size-4"}),"保存"]})]})})]})}function eiX(e){return e&&e>0?String(e):""}function eiY(e){let t=e.policy??{},n=t.dangerAgent??{},r=t.reviewerAgent??{},a=e.settingsTemplate;return{title:e.title??"",summary:e.summary??"",maxPeers:eiX(t.maxPeers),maxSpawnDepth:eiX(t.maxSpawnDepth),budgetTokens:eiX(e.budgetTokens),budgetSoftPct:eiX(t.budgetSoftPct),budgetHardPct:eiX(t.budgetHardPct),approvalParkTtlSeconds:eiX(t.approvalParkTtlSeconds),hitlStrictness:t.hitlStrictness??"",awayMode:t.awayMode??"",dangerEnabled:n.enabled??!1,dangerSeverity:n.severity??"",dangerModelRef:n.modelRef??"",reviewerEnabled:r.enabled??!1,reviewerMode:r.mode??"",reviewerModelRef:r.modelRef??"",engine:a.engine??"vantaloom",permissionMode:a.permissionMode??"acceptEdits",allowedTools:a.allowedTools??[],blockedCommands:a.blockedCommands??[],mainModels:a.mainModels??[],ccModel:a.ccModel??"",folders:a.folders??[],hosts:a.hosts??[],baseSettings:a}}function eiZ(e,t,n){let r=e.trim();if(""===r)return 0;let a=Math.floor(Number(r));return!Number.isFinite(a)||a<=0?0:Math.min(n,Math.max(t,a))}function eiJ(e){if(!e.title.trim())return"工程名称不能为空";for(let[t,n]of[[e.maxPeers,"同伴并发上限"],[e.maxSpawnDepth,"派生深度上限"],[e.budgetTokens,"预算上限"],[e.budgetSoftPct,"软阈值"],[e.budgetHardPct,"硬阈值"],[e.approvalParkTtlSeconds,"驻留 TTL"]]){let e=t.trim();if(""===e)continue;let r=Number(e);if(!Number.isFinite(r)||r<0)return`${n}需为 ≥ 0 的整数`}}function eiQ({icon:e,title:t,desc:n,children:r}){return(0,eb.jsxs)("section",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-5 shadow-sm",children:[(0,eb.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-foreground [&_svg]:text-muted-foreground",children:[e,(0,eb.jsx)("h2",{className:"text-base font-semibold",children:t})]}),n?(0,eb.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:n}):null]}),(0,eb.jsx)("div",{className:"flex flex-col gap-4",children:r})]})}function ei0({label:e,hint:t,icon:n,children:r}){return(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsxs)("span",{className:"flex items-center gap-1.5 text-sm font-medium text-foreground [&_svg]:text-muted-foreground",children:[n,e]}),r,t?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground/80",children:t}):null]})}let ei1=(0,ek.default)("kanban",[["path",{d:"M5 3v14",key:"9nsxs2"}],["path",{d:"M12 3v8",key:"1h2ygw"}],["path",{d:"M19 3v18",key:"1sk56x"}]]);function ei2({className:e,size:t="default",...n}){return(0,eb.jsxs)("div",{className:"group/native-select relative w-fit has-[select:disabled]:opacity-50","data-slot":"native-select-wrapper",children:[(0,eb.jsx)("select",{"data-slot":"native-select","data-size":t,className:(0,ez.cn)("h-8 w-full min-w-0 appearance-none rounded-lg border border-input bg-background px-2.5 py-1.5 pr-8 ui-text-control shadow-xs outline-none transition-[color,box-shadow] selection:bg-primary selection:text-primary-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[size=sm]:h-7 data-[size=sm]:py-1 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40",e),...n}),(0,eb.jsx)(pt,{className:"pointer-events-none absolute right-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground opacity-60","aria-hidden":"true","data-slot":"native-select-icon"})]})}function ei5({className:e,...t}){return(0,eb.jsx)("option",{"data-slot":"native-select-option",className:(0,ez.cn)("bg-[Canvas] text-[CanvasText]",e),...t})}function ei4(){return{kind:"human",id:"local",displayName:"我"}}async function ei3(e,t){let n=t?`?status=${encodeURIComponent(t)}`:"";return(await eou(`/api/local/projects/${encodeURIComponent(e)}/issues${n}`)).issues??[]}async function ei6(e){return eou(`/api/local/issues/${encodeURIComponent(e)}`)}async function ei8(e,t){return eou(`/api/local/projects/${encodeURIComponent(e)}/issues`,{method:"POST",body:JSON.stringify(t)})}async function ei7(e,t){return eou(`/api/local/issues/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}async function ei9(e){await eou(`/api/local/issues/${encodeURIComponent(e)}`,{method:"DELETE"})}async function eoe(e,t){return eou(`/api/local/issues/${encodeURIComponent(e)}/claim`,{method:"POST",body:JSON.stringify({assignee:t})})}async function eot(e,t,n=ei4()){return eou(`/api/local/issues/${encodeURIComponent(e)}/comments`,{method:"POST",body:JSON.stringify({actor:n,body:t})})}async function eon(e){return(await eou(`/api/local/issues/${encodeURIComponent(e)}/events`)).events??[]}async function eor(e){return(await eou(`/api/local/projects/${encodeURIComponent(e)}/links`)).links??[]}async function eoa(e,t,n,r){return eou(`/api/local/projects/${encodeURIComponent(e)}/links`,{method:"POST",body:JSON.stringify({fromIssueId:t,toIssueId:n,kind:r})})}async function eoi(e){await eou(`/api/local/links/${encodeURIComponent(e)}`,{method:"DELETE"})}let eoo=new Map,eol=new Map;async function eos(e){let t=Date.now(),n=eoo.get(e);if(n&&t-n.at<2500)return n.value;let r=eol.get(e);if(r)return r;let a=(async()=>{try{let t=(await eou(`/api/local/projects/${encodeURIComponent(e)}/approvals`)).approvals??[];return eoo.set(e,{value:t,at:Date.now()}),t}finally{eol.delete(e)}})();return eol.set(e,a),a}async function eoc(e,t,n,r){await eou(`/api/local/agent/conversations/${encodeURIComponent(e)}/approvals/${encodeURIComponent(t)}`,{method:"POST",body:JSON.stringify(null!=r&&""!==r?{decision:n,feedback:r}:{decision:n})})}class eod extends Error{status;constructor(e,t){super(e),this.name="KanbanAPIError",this.status=t}}async function eou(e,t){let n=await fetch((0,eT.localAPIURL)(e),{cache:"no-store",...t,headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok)throw new eod("string"==typeof r?.error?r.error:"kanban api failed",n.status);return r}let eof=[{status:"backlog",label:"待办池",dot:"bg-ash-gray",chip:"bg-muted text-muted-foreground"},{status:"todo",label:"待领取",dot:"bg-sky-teal",chip:"bg-sky-teal/15 text-sky-teal"},{status:"in_progress",label:"进行中",dot:"bg-vivid-violet",chip:"bg-vivid-violet/15 text-vivid-violet"},{status:"blocked",label:"受阻",dot:"bg-hot-pink",chip:"bg-hot-pink/15 text-hot-pink"},{status:"review",label:"待审核",dot:"bg-amber-500",chip:"bg-amber-500/15 text-amber-600 dark:text-amber-400"},{status:"done",label:"已完成",dot:"bg-emerald-500",chip:"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400"}],eom={status:"cancelled",label:"已取消",dot:"bg-ash-gray",chip:"bg-muted text-muted-foreground"},eoh=[...eof,eom],eop={bug:"缺陷",feature:"功能",task:"任务",chore:"杂务",question:"疑问"},eog=["task","feature","bug","chore","question"],eox={bug:"bg-hot-pink/15 text-hot-pink",feature:"bg-sky-teal/15 text-sky-teal",task:"bg-vivid-violet/15 text-vivid-violet",chore:"bg-muted text-muted-foreground",question:"bg-amber-500/15 text-amber-600 dark:text-amber-400"},eov={low:"低",normal:"普通",high:"高",urgent:"紧急"},eob=["low","normal","high","urgent"],eoy={low:"bg-muted text-muted-foreground",normal:"bg-muted text-muted-foreground",high:"bg-amber-500/15 text-amber-600 dark:text-amber-400",urgent:"bg-hot-pink/15 text-hot-pink"},eow={depends_on:"依赖",blocks:"阻塞",parent:"父级",relates_to:"关联"},eoj=["depends_on","blocks","parent","relates_to"],eok={depends_on:{stroke:"#f59e0b",chip:"bg-amber-500/15 text-amber-600 dark:text-amber-400"},blocks:{stroke:"#ec4899",chip:"bg-hot-pink/15 text-hot-pink"},parent:{stroke:"#8b5cf6",chip:"bg-vivid-violet/15 text-vivid-violet"},relates_to:{stroke:"#14b8a6",chip:"bg-sky-teal/15 text-sky-teal"}},eoN={created:"创建",comment:"评论",status_change:"状态变更",claim:"认领",progress:"进度",schedule:"排期"};function eoS(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}let eoC={safe:"安全",normal:"普通",risky:"有风险",dangerous:"危险"},eoM={safe:"bg-sky-teal/15 text-sky-teal",normal:"bg-muted text-muted-foreground",risky:"bg-amber-500/15 text-amber-600 dark:text-amber-400",dangerous:"bg-hot-pink/15 text-hot-pink"},eoE=(0,ek.default)("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]),eoI=(0,ek.default)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);function eoP({issueId:e,projectId:t,open:n,onClose:r,onChange:a,onDeleted:i}){let[o,l]=ew.useState(null),[s,c]=ew.useState([]),[d,u]=ew.useState([]),[f,m]=ew.useState([]),[h,p]=ew.useState(!1),[g,x]=ew.useState(!1),[v,b]=ew.useState(""),[y,w]=ew.useState(""),j=sv(),k=ew.useCallback(async()=>{if(e){p(!0);try{let[n,r,a,i]=await Promise.all([ei6(e),eon(e).catch(()=>[]),eor(t).catch(()=>[]),ei3(t).catch(()=>[])]);l(n),c(r),u(a),m(i)}catch(e){hn.error(e instanceof Error?e.message:"加载 issue 失败")}finally{p(!1)}}},[e,t]);ew.useEffect(()=>{n&&e&&k(),n||(l(null),c([]),u([]),m([]),b(""),w(""))},[n,e,k]);let N=ew.useCallback(async()=>{u(await eor(t).catch(()=>d)),o&&a?.(o)},[t,d,o,a]);async function S(e,n){if(o){x(!0);try{await eoa(t,o.id,e,n),await N()}catch(e){hn.error(e instanceof Error?e.message:"添加关联失败")}finally{x(!1)}}}async function C(e){x(!0);try{await eoi(e),await N()}catch(e){hn.error(e instanceof Error?e.message:"删除关联失败")}finally{x(!1)}}let M=ew.useCallback(async e=>{if(o){x(!0);try{let t=await ei7(o.id,e);l(t),a?.(t);let n=await eon(o.id).catch(()=>s);c(n)}catch(e){hn.error(e instanceof Error?e.message:"更新失败")}finally{x(!1)}}},[o,a,s]);async function E(){if(o){x(!0);try{let e=await eoe(o.id,ei4());l(e),a?.(e);let t=await eon(o.id).catch(()=>s);c(t),hn.success("认领成功")}catch(e){e instanceof eod&&409===e.status?(hn.error("认领失败:该 issue 已被他人认领"),k()):hn.error(e instanceof Error?e.message:"认领失败")}finally{x(!1)}}}async function I(){if(o&&v.trim()){x(!0);try{await eot(o.id,v.trim()),b("");let e=await eon(o.id).catch(()=>s);c(e),a?.(o)}catch(e){hn.error(e instanceof Error?e.message:"评论失败")}finally{x(!1)}}}async function P(){if(o&&window.confirm(`确定删除 #${o.number} ${o.title}?`)){x(!0);try{await ei9(o.id),i?.(o.id),r()}catch(e){hn.error(e instanceof Error?e.message:"删除失败")}finally{x(!1)}}}let O=o?.progress??{percent:0,checklist:[]};function z(e){return 0===e.length?O.percent:Math.round(e.filter(e=>e.done).length/e.length*100)}async function A(e){let t=O.checklist.map((t,n)=>n===e?{...t,done:!t.done}:t);await M({progress:{percent:z(t),checklist:t}})}async function T(e){let t=e.trim();if(!t)return;let n=[...O.checklist,{text:t,done:!1}];await M({progress:{percent:z(n),checklist:n}})}async function R(e){let t=O.checklist.filter((t,n)=>n!==e);await M({progress:{percent:z(t),checklist:t}})}let D=ew.useMemo(()=>{if(!o)return[];let e=new Map(f.map(e=>[e.id,e]));return d.filter(e=>e.fromIssueId===o.id||e.toIssueId===o.id).map(t=>{let n=t.fromIssueId===o.id,r=n?t.toIssueId:t.fromIssueId;return{link:t,outgoing:n,other:e.get(r)??null,otherId:r}})},[d,o,f]);return(0,eb.jsx)(dX,{open:n,onOpenChange:e=>e?void 0:r(),children:(0,eb.jsxs)(fU,{className:(0,ez.cn)("gap-0 overflow-hidden p-0",j?"inset-0 h-svh w-full max-w-none translate-x-0 translate-y-0 rounded-none border-0":"max-h-[88vh] w-[calc(100%-2rem)] max-w-3xl sm:max-w-3xl"),children:[(0,eb.jsx)(fK,{className:"sr-only",children:o?`#${o.number} ${o.title}`:"issue 详情"}),(0,eb.jsx)(fG,{className:"sr-only",children:"查看并编辑该 issue 的状态、负责人、进度、关联与活动。"}),!o||h?(0,eb.jsx)("div",{className:"flex h-64 items-center justify-center",children:(0,eb.jsx)(eM,{className:"size-6 animate-spin text-muted-foreground"})}):(0,eb.jsxs)("div",{className:(0,ez.cn)("flex flex-col",j?"h-svh":"max-h-[88vh]"),children:[(0,eb.jsxs)("div",{className:"flex items-start gap-3 border-b border-border px-5 py-4 pr-12",children:[(0,eb.jsxs)("span",{className:"mt-0.5 shrink-0 rounded-md bg-muted px-2 py-0.5 font-mono text-xs text-muted-foreground",children:["#",o.number]}),(0,eb.jsx)("h2",{className:"min-w-0 flex-1 break-words text-base font-semibold",children:o.title})]}),(0,eb.jsxs)("div",{className:"grid flex-1 grid-cols-1 gap-0 overflow-y-auto md:grid-cols-[1fr_300px]",children:[(0,eb.jsxs)("div",{className:"flex flex-col gap-5 px-5 py-4",children:[(0,eb.jsx)(eoO,{label:"标题",children:(0,eb.jsx)(eA,{defaultValue:o.title,onBlur:e=>{let t=e.target.value.trim();t&&t!==o.title&&M({title:t})}})}),(0,eb.jsx)(eoO,{label:"描述",children:(0,eb.jsx)(w2,{defaultValue:o.body,rows:4,placeholder:"补充描述…",onBlur:e=>{e.target.value!==o.body&&M({body:e.target.value})}})}),(0,eb.jsx)(eoO,{label:`进度 \xb7 ${O.percent}%`,children:(0,eb.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,eb.jsx)(erw,{value:O.percent,className:"h-2"}),(0,eb.jsx)("div",{className:"flex flex-col gap-1.5",children:O.checklist.map((e,t)=>(0,eb.jsxs)("div",{className:"group flex items-center gap-2 text-sm",children:[(0,eb.jsx)(vM,{checked:e.done,onCheckedChange:()=>void A(t)}),(0,eb.jsx)("span",{className:(0,ez.cn)("min-w-0 flex-1 break-words",e.done&&"text-muted-foreground line-through"),children:e.text}),(0,eb.jsx)("button",{type:"button",onClick:()=>void R(t),className:"shrink-0 text-muted-foreground opacity-0 transition hover:text-hot-pink group-hover:opacity-100",children:(0,eb.jsx)(fV.XIcon,{className:"size-3.5"})})]},t))}),(0,eb.jsx)(eoz,{onAdd:e=>void T(e)})]})}),(0,eb.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,eb.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"活动"}),(0,eb.jsx)("div",{className:"flex flex-col gap-3",children:0===s.length?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground/60",children:"暂无活动"}):s.map(e=>{let t=e.actor?.kind==="human"?"human":"agent",n=e.actor?.displayName??"系统";return(0,eb.jsxs)("div",{className:"flex gap-2.5",children:[(0,eb.jsx)(eoT,{kind:t,small:!0}),(0,eb.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eb.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[(0,eb.jsx)("span",{className:"font-medium text-foreground",children:n}),(0,eb.jsx)("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:eoN[e.kind]??e.kind}),(0,eb.jsx)("span",{className:"text-muted-foreground/60",children:eoS(e.createdAt)})]}),e.body?(0,eb.jsx)("p",{className:"mt-0.5 whitespace-pre-wrap break-words text-sm text-secondary-foreground",children:e.body}):null]})]},e.id)})}),(0,eb.jsxs)("div",{className:"mt-1 flex items-end gap-2",children:[(0,eb.jsx)(w2,{value:v,onChange:e=>b(e.target.value),rows:2,placeholder:"写评论…",className:"min-h-9"}),(0,eb.jsx)(eO.Button,{size:"sm",disabled:!v.trim()||g,onClick:()=>void I(),children:(0,eb.jsx)(eoI,{className:"size-4"})})]})]})]}),(0,eb.jsxs)("div",{className:"flex flex-col gap-4 border-t border-border px-5 py-4 md:border-l md:border-t-0",children:[(0,eb.jsx)(eoO,{label:"状态",children:(0,eb.jsx)(ei2,{className:"w-full",value:o.status,onChange:e=>void M({status:e.target.value}),children:eoh.map(e=>(0,eb.jsx)(ei5,{value:e.status,children:e.label},e.status))})}),(0,eb.jsx)(eoO,{label:"优先级",children:(0,eb.jsx)(ei2,{className:"w-full",value:o.priority,onChange:e=>void M({priority:e.target.value}),children:eob.map(e=>(0,eb.jsx)(ei5,{value:e,children:eov[e]},e))})}),(0,eb.jsx)(eoO,{label:"类型",children:(0,eb.jsx)(ei2,{className:"w-full",value:o.type,onChange:e=>void M({type:e.target.value}),children:eog.map(e=>(0,eb.jsx)(ei5,{value:e,children:eop[e]},e))})}),(0,eb.jsx)(eoO,{label:"负责人",children:o.assignee?(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-lg border border-border px-2.5 py-1.5",children:[(0,eb.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5 text-sm",children:[(0,eb.jsx)(eoT,{kind:o.assignee.kind,small:!0}),(0,eb.jsx)("span",{className:"truncate",children:o.assignee.displayName})]}),(0,eb.jsx)("button",{type:"button",className:"shrink-0 text-xs text-muted-foreground hover:text-hot-pink",onClick:()=>void M({assignee:null}),children:"取消"})]}):(0,eb.jsxs)(eO.Button,{variant:"outline",size:"sm",className:"w-full",disabled:g,onClick:()=>void E(),children:[(0,eb.jsx)(lU,{className:"size-4"})," 认领"]})}),(0,eb.jsx)(eoO,{label:"标签",children:(0,eb.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,eb.jsx)("div",{className:"flex flex-wrap gap-1.5",children:0===o.labels.length?(0,eb.jsx)("span",{className:"text-xs text-muted-foreground/60",children:"暂无标签"}):o.labels.map(e=>(0,eb.jsxs)("span",{className:"group inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs text-muted-foreground",children:[e,(0,eb.jsx)("button",{type:"button",onClick:()=>void M({labels:o.labels.filter(t=>t!==e)}),className:"text-muted-foreground/60 hover:text-hot-pink",children:(0,eb.jsx)(fV.XIcon,{className:"size-3"})})]},e))}),(0,eb.jsxs)("form",{className:"flex gap-1.5",onSubmit:e=>{e.preventDefault();let t=y.trim();t&&!o.labels.includes(t)&&M({labels:[...o.labels,t]}),w("")},children:[(0,eb.jsx)(eA,{value:y,onChange:e=>w(e.target.value),placeholder:"新标签",className:"h-8"}),(0,eb.jsx)(eO.Button,{type:"submit",size:"sm",variant:"outline",children:(0,eb.jsx)(lY,{className:"size-4"})})]})]})}),(0,eb.jsx)(eoO,{label:"关联 issue",children:(0,eb.jsxs)("div",{className:"flex flex-col gap-2",children:[0===D.length?(0,eb.jsx)("span",{className:"text-xs text-muted-foreground/60",children:"暂无关联"}):(0,eb.jsx)("div",{className:"flex flex-col gap-1",children:D.map(({link:e,outgoing:t,other:n,otherId:r})=>{let a=eok[e.kind];return(0,eb.jsxs)("div",{className:"group flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs",children:[(0,eb.jsx)(eoE,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,eb.jsxs)("span",{className:(0,ez.cn)("shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",a.chip),children:[t?"":"被",eow[e.kind]]}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate text-secondary-foreground",children:n?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsxs)("span",{className:"font-mono text-muted-foreground",children:["#",n.number]})," ",n.title]}):(0,eb.jsx)("span",{className:"font-mono text-muted-foreground/60",children:r.slice(0,8)})}),(0,eb.jsx)("button",{type:"button",disabled:g,onClick:()=>void C(e.id),title:"删除关联",className:"shrink-0 text-muted-foreground opacity-0 transition hover:text-hot-pink group-hover:opacity-100 disabled:opacity-30",children:(0,eb.jsx)(fV.XIcon,{className:"size-3.5"})})]},e.id)})}),(0,eb.jsx)(eoA,{currentIssueId:o.id,candidates:f,existingLinks:d,disabled:g,onAdd:S})]})}),(0,eb.jsxs)("div",{className:"mt-auto flex flex-col gap-1 pt-2 text-xs text-muted-foreground/70",children:[(0,eb.jsxs)("span",{children:["创建于 ",eoS(o.createdAt)]}),(0,eb.jsxs)("span",{children:["更新于 ",eoS(o.updatedAt)]})]}),(0,eb.jsxs)(eO.Button,{variant:"ghost",size:"sm",className:"text-hot-pink hover:bg-hot-pink/10 hover:text-hot-pink",disabled:g,onClick:()=>void P(),children:[(0,eb.jsx)(yn,{className:"size-4"})," 删除 issue"]})]})]})]})]})})}function eoO({label:e,children:t}){return(0,eb.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,eb.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:e}),t]})}function eoz({onAdd:e}){let[t,n]=ew.useState("");return(0,eb.jsxs)("form",{className:"flex gap-1.5",onSubmit:r=>{r.preventDefault(),e(t),n("")},children:[(0,eb.jsx)(eA,{value:t,onChange:e=>n(e.target.value),placeholder:"新增清单项",className:"h-8"}),(0,eb.jsx)(eO.Button,{type:"submit",size:"sm",variant:"outline",children:(0,eb.jsx)(lY,{className:"size-4"})})]})}function eoA({currentIssueId:e,candidates:t,existingLinks:n,disabled:r,onAdd:a}){let[i,o]=ew.useState(!1),[l,s]=ew.useState(""),[c,d]=ew.useState("depends_on"),u=ew.useMemo(()=>{let t=new Set;for(let r of n)r.fromIssueId===e&&t.add(r.toIssueId),r.toIssueId===e&&t.add(r.fromIssueId);return t},[n,e]),f=ew.useMemo(()=>{let n=l.trim().toLowerCase();return t.filter(t=>t.id!==e&&!u.has(t.id)).filter(e=>!n||e.title.toLowerCase().includes(n)||`#${e.number}`.includes(n)||String(e.number).includes(n)).slice(0,8)},[t,e,u,l]);return i?(0,eb.jsxs)("div",{className:"flex flex-col gap-1.5 rounded-lg border border-vivid-violet/40 bg-card p-2",children:[(0,eb.jsx)(ei2,{size:"sm",className:"w-full",value:c,onChange:e=>d(e.target.value),children:eoj.map(e=>(0,eb.jsx)(ei5,{value:e,children:eow[e]},e))}),(0,eb.jsx)(eA,{autoFocus:!0,value:l,onChange:e=>s(e.target.value),placeholder:"搜索 issue(编号 / 标题)",className:"h-8"}),(0,eb.jsx)("div",{className:"flex max-h-40 flex-col gap-0.5 overflow-y-auto",children:0===f.length?(0,eb.jsx)("span",{className:"px-1 py-1.5 text-xs text-muted-foreground/60",children:"无可关联的 issue"}):f.map(e=>(0,eb.jsxs)("button",{type:"button",disabled:r,onClick:async()=>{await a(e.id,c),o(!1),s("")},className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-left text-xs transition hover:bg-muted disabled:opacity-50",children:[(0,eb.jsxs)("span",{className:"shrink-0 font-mono text-muted-foreground",children:["#",e.number]}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate text-secondary-foreground",children:e.title})]},e.id))}),(0,eb.jsx)("div",{className:"flex justify-end",children:(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>{o(!1),s("")},children:"取消"})})]}):(0,eb.jsxs)(eO.Button,{variant:"outline",size:"sm",className:"w-full",disabled:r,onClick:()=>o(!0),children:[(0,eb.jsx)(lY,{className:"size-4"})," 添加关联"]})}function eoT({kind:e,small:t}){let n=t?"size-3":"size-3.5";return(0,eb.jsx)("span",{className:(0,ez.cn)("inline-flex shrink-0 items-center justify-center rounded-full",t?"size-5":"size-6","agent"===e?"bg-vivid-violet/15 text-vivid-violet":"bg-sky-teal/15 text-sky-teal"),title:"agent"===e?"Agent":"人类",children:"agent"===e?(0,eb.jsx)(uH,{className:n}):(0,eb.jsx)(HP,{className:n})})}let eoR=["backlog","todo","in_progress","blocked","review","done","cancelled"],eoD={backlog:{border:"border-ash-gray/50",dot:"bg-ash-gray"},todo:{border:"border-sky-teal/50",dot:"bg-sky-teal"},in_progress:{border:"border-vivid-violet/50",dot:"bg-vivid-violet"},blocked:{border:"border-hot-pink/50",dot:"bg-hot-pink"},review:{border:"border-amber-500/50",dot:"bg-amber-500"},done:{border:"border-emerald-500/50",dot:"bg-emerald-500"},cancelled:{border:"border-ash-gray/40",dot:"bg-ash-gray"}};function eo_({issues:e,links:t,loading:n,onOpenIssue:r}){let{placed:a,byId:i,width:o,height:l}=ew.useMemo(()=>{let t=new Map;for(let n of e){let e=t.get(n.status)??[];e.push(n),t.set(n.status,e)}for(let e of t.values())e.sort((e,t)=>e.sortOrder!==t.sortOrder?e.sortOrder-t.sortOrder:e.createdAt.localeCompare(t.createdAt));let n=eoR.filter(e=>(t.get(e)?.length??0)>0),r=[],a=0;n.forEach((e,n)=>{let i=t.get(e)??[];a=Math.max(a,i.length),i.forEach((e,t)=>{r.push({issue:e,x:32+280*n,y:32+84*t})})});let i=new Map(r.map(e=>[e.issue.id,e]));return{placed:r,byId:i,width:n.length>0?64+184*n.length+(n.length-1)*96:64,height:Math.max(64+56*a+28*Math.max(0,a-1),120)}},[e]),s=ew.useMemo(()=>t.map(e=>{let t=i.get(e.fromIssueId),n=i.get(e.toIssueId);return t&&n?{link:e,from:t,to:n}:null}).filter(e=>!!e),[t,i]);if(n)return(0,eb.jsx)("div",{className:"flex flex-1 items-center justify-center",children:(0,eb.jsx)(eM,{className:"size-6 animate-spin text-muted-foreground"})});if(0===e.length)return(0,eb.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 text-sm text-muted-foreground/70",children:[(0,eb.jsx)(enH,{className:"size-6"}),"暂无 issue,先在看板中创建"]});let c=s.length>0;return(0,eb.jsxs)("div",{className:"flex flex-1 flex-col overflow-hidden",children:[c?(0,eb.jsx)("div",{className:"mx-5 mb-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground",children:["depends_on","blocks","parent","relates_to"].map(e=>(0,eb.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,eb.jsx)("span",{className:"inline-block h-0.5 w-4 rounded-full",style:{backgroundColor:eok[e].stroke}}),eow[e]]},e))}):(0,eb.jsxs)("div",{className:"mx-5 mb-2 flex items-center gap-2 rounded-lg border border-dashed border-border bg-muted/30 px-3 py-2 text-xs text-muted-foreground",children:[(0,eb.jsx)(enH,{className:"size-3.5 shrink-0"}),"还没有任何依赖关系。在某张卡片详情的「关联 issue」中添加依赖 / 阻塞 / 父级,即可在此看到请求图谱。"]}),(0,eb.jsx)("div",{className:"flex-1 overflow-auto px-5 pb-4",children:(0,eb.jsxs)("div",{className:"relative",style:{width:o,height:l},children:[(0,eb.jsxs)("svg",{className:"pointer-events-none absolute inset-0",width:o,height:l,children:[(0,eb.jsx)("defs",{children:["depends_on","blocks","parent","relates_to"].map(e=>(0,eb.jsx)("marker",{id:`arrow-${e}`,viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto-start-reverse",children:(0,eb.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:eok[e].stroke})},e))}),s.map(({link:e,from:t,to:n})=>{let r=eoL(t,n),a=eoL(n,t),i=eok[e.kind].stroke,o=(r.x+a.x)/2,l=(r.y+a.y)/2;return(0,eb.jsxs)("g",{children:[(0,eb.jsx)("line",{x1:r.x,y1:r.y,x2:a.x,y2:a.y,stroke:i,strokeWidth:1.75,markerEnd:`url(#arrow-${e.kind})`}),(0,eb.jsx)("text",{x:o,y:l-4,textAnchor:"middle",className:"fill-muted-foreground",style:{fontSize:10},children:eow[e.kind]})]},e.id)})]}),a.map(({issue:e,x:t,y:n})=>{var a;let i=eoD[e.status];return(0,eb.jsxs)("button",{type:"button",onClick:()=>r(e.id),style:{left:t,top:n,width:184,height:56},className:(0,ez.cn)("absolute flex flex-col justify-center gap-0.5 rounded-lg border bg-card px-2.5 py-1.5 text-left shadow-sm transition hover:border-vivid-violet hover:shadow-md",i.border),title:`#${e.number} ${e.title}`,children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,eb.jsx)("span",{className:(0,ez.cn)("size-2 shrink-0 rounded-full",i.dot)}),(0,eb.jsxs)("span",{className:"font-mono text-[11px] text-muted-foreground",children:["#",e.number]}),(0,eb.jsx)("span",{className:"ml-auto truncate text-[10px] text-muted-foreground/70",children:(a=e.status,eoh.find(e=>e.status===a)??{status:a,label:a,dot:"bg-ash-gray",chip:"bg-muted text-muted-foreground"}).label})]}),(0,eb.jsx)("span",{className:"truncate text-xs font-medium text-foreground",children:e.title})]},e.id)})]})})]})}function eoL(e,t){let n=e.x+92,r=e.y+28,a=t.x+92,i=t.y+28,o=a-n,l=i-r;if(0===o&&0===l)return{x:n,y:r};let s=Math.min(0!==o?92/Math.abs(o):1/0,0!==l?28/Math.abs(l):1/0);return{x:n+o*s,y:r+l*s}}async function eo$(e){let t=await fetch((0,eT.localAPIURL)(`/api/local/projects/${encodeURIComponent(e)}/dispatcher`),{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json"}}),n=await t.json().catch(()=>({}));if(!t.ok)throw Error("string"==typeof n?.error?n.error:"dispatcher api failed");let r=cx(n);return{conversationId:r.conversation.id,ownerMachineId:r.conversation.ownerMachineId,events:r.events,running:r.conversation.running??!1,modelRef:r.conversation.settings?.mainModels?.[0]??"",mainModels:r.conversation.settings?.mainModels??[]}}function eoF({projectId:e}){let[t,n]=ew.useState(void 0),[r,a]=ew.useState(void 0),[i,o]=ew.useState(""),[l,s]=ew.useState([]),[c,d]=ew.useState([]),[u,f]=ew.useState(!1),[m,h]=ew.useState(!1);ew.useEffect(()=>{let t=!0;return n(void 0),d([]),f(!1),s([]),(async()=>{try{let r=await eo$(e);if(!t)return;n(r.conversationId),a(r.ownerMachineId),o(r.modelRef),s(r.mainModels),d(r.events),f(r.running)}catch{}})(),()=>{t=!1}},[e]),ew.useEffect(()=>{let e;if(!t)return;let n=!0,a=async()=>{if(n)try{let i=await sD(t,r);if(!n)return;let o=i.conversation.running??!1;d(i.events),f(o),s(i.conversation.settings?.mainModels??[]),e=window.setTimeout(a,o?1200:5e3)}catch{if(!n)return;try{let e=await s_(t,{limit:400},r);n&&e.events.length&&d(e.events)}catch{}n&&(e=window.setTimeout(a,5e3))}};return a(),()=>{n=!1,void 0!==e&&window.clearTimeout(e)}},[t,r]);let p=ew.useCallback(e=>{let n=e.trim();t&&n&&!m&&(h(!0),f(!0),(async()=>{try{await s3(t,{message:n,modelRef:i,mode:"agent"},r)}catch{f(!1)}finally{h(!1)}})())},[t,r,i,m]),g=ew.useMemo(()=>{if(u||m||0===c.length)return;let e=c[c.length-1];return e&&"ask"===e.kind?e:void 0},[c,u,m]),{models:x}=vH(),v=ew.useMemo(()=>l.length?x.filter(e=>l.includes(e.value)).map(e=>({id:e.value,label:e.label})):[],[x,l]),b=0===c.length;return(0,eb.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col rounded-[inherit] bg-background",children:[(0,eb.jsxs)("div",{className:"flex shrink-0 flex-col gap-0.5 border-b px-4 py-2.5",children:[(0,eb.jsx)("span",{className:"text-[13px] font-medium text-foreground",children:"任务分发"}),(0,eb.jsx)("span",{className:"text-[11px] text-muted-foreground",children:"把需求转成任务并派发执行"})]}),(0,eb.jsxs)("div",{className:"relative min-h-0 flex-1",children:[(0,eb.jsx)(UL,{className:"size-full min-h-0",composerClassName:"max-w-[42rem]",events:c,running:u||m,disabled:!t,models:v,modelId:i,onModelChange:e=>o(e),hidePermissionMode:!0,onSubmit:e=>p(e.value),planPromptBar:g?(0,eb.jsx)(eoB,{ask:g,onAnswer:p}):void 0}),b?(0,eb.jsx)("div",{className:"pointer-events-none absolute inset-x-0 top-0 bottom-28 grid place-items-center px-6",children:(0,eb.jsx)("div",{className:"max-w-xs text-center",children:(0,eb.jsx)("p",{className:"text-sm text-muted-foreground",children:"把你对这个工程的需求告诉我,我会拆成任务并派发给执行会话。"})})}):null]})]})}function eoB({ask:e,onAnswer:t}){let n=(e.detail?.trim()||e.title?.trim())??"",r=e.askOptions??[],a=e.askAllowMultiple??!1,i=e.askAllowCustom??!1,[o,l]=ew.useState([]);return ew.useEffect(()=>{l([])},[e.id]),(0,eb.jsxs)("div",{className:"vtl-agent-composer-prompt-bar mb-[-1px] rounded-t-xl border border-b-0 bg-popover px-3 pt-2.5 pb-3 shadow-sm",children:[(0,eb.jsx)("p",{className:"mb-2 text-[13px] font-medium text-foreground",children:n}),r.length>0?(0,eb.jsx)("div",{className:"flex flex-wrap gap-1.5",children:r.map(e=>{let n=a&&o.includes(e);return(0,eb.jsx)(eO.Button,{type:"button",size:"sm",variant:n?"default":"outline",className:(0,ez.cn)("h-auto max-w-full justify-start whitespace-normal py-1.5 text-left text-xs","w-full sm:w-auto"),onClick:()=>a?void l(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]):t(e),children:e},e)})}):null,a?(0,eb.jsx)("div",{className:"mt-2 flex justify-end",children:(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",disabled:0===o.length,onClick:()=>t(o.join("、")),children:[(0,eb.jsx)(eoI,{className:"mr-1.5 size-3"}),"提交所选"]})}):null,i?(0,eb.jsx)("p",{className:"mt-2 text-[11px] text-muted-foreground",children:"或在下方输入框自行回答"}):null]})}let eoV="application/x-vantaloom-issue";function eoH({projectId:e}){let[t,n]=ew.useState([]),[r,a]=ew.useState([]),[i,o]=ew.useState([]),[l,s]=ew.useState("board"),[c,d]=ew.useState(!1),[u,f]=ew.useState(!1),m=sv(),[h,p]=ew.useState(!0),[g,x]=ew.useState(!1),[v,b]=ew.useState(null),[y,w]=ew.useState(null),[j,k]=ew.useState(null),[N,S]=ew.useState(null),[C,M]=ew.useState(!1),[E,I]=ew.useState(null),P=ew.useCallback(async t=>{t?.silent||x(!0);try{let[t,r,i]=await Promise.all([ei3(e),eor(e).catch(()=>[]),eos(e).catch(()=>[])]);n(t),a(r),o(i),b(null)}catch(e){b(e instanceof Error?e.message:"加载看板失败")}finally{p(!1),x(!1)}},[e]);ew.useEffect(()=>{p(!0),P({silent:!0});let e=setInterval(()=>void P({silent:!0}),1e4),t=()=>void P({silent:!0});return window.addEventListener("focus",t),()=>{clearInterval(e),window.removeEventListener("focus",t)}},[P]);let O=ew.useMemo(()=>{let e={};for(let t of[...eof,eom])e[t.status]=[];for(let n of t)(e[n.status]??=[]).push(n);for(let t of Object.values(e))t.sort((e,t)=>e.sortOrder!==t.sortOrder?e.sortOrder-t.sortOrder:e.createdAt.localeCompare(t.createdAt));return e},[t]);async function z(e,r,a){let i,o,l=t.find(t=>t.id===e);if(!l)return;let s=(O[r]??[]).filter(t=>t.id!==e);if(a){let e=s.findIndex(e=>e.id===a);e>=0&&(o=s[e]?.sortOrder,i=e>0?s[e-1]?.sortOrder:void 0)}if(void 0===i&&void 0===o){let e=s[s.length-1];i=e?.sortOrder}let c=void 0!==i&&void 0!==o?(i+o)/2:void 0!==i?i+1e3:void 0!==o?o-1e3:1e3;if(l.status!==r||l.sortOrder!==c){w(null),n(t=>t.map(t=>t.id===e?{...t,status:r,sortOrder:c}:t));try{await ei7(e,{status:r,sortOrder:c})}catch(e){n(t),w(e instanceof Error?`移动失败:${e.message}`:"移动失败,已撤销")}}}function A(e,t,n){e.preventDefault(),e.stopPropagation(),k(null);let r=e.dataTransfer.getData(eoV)||e.dataTransfer.getData("text/plain");r&&z(r,t,n)}async function T(e,t,n){w(null);try{await eoc(e.conversationId,e.approvalId,t,n)}catch(e){e instanceof eod&&404===e.status||w(e instanceof Error?`${"approve"===t?"通过":"拒绝"}失败:${e.message}`:"操作失败")}o(t=>t.filter(t=>t.approvalId!==e.approvalId)),P({silent:!0})}let R=C?[...eof,eom]:eof;return(0,eb.jsxs)(en3,{children:[(0,eb.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,eb.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 px-5 py-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:["board"===l?(0,eb.jsx)(ei1,{className:"size-4 text-muted-foreground"}):(0,eb.jsx)(enH,{className:"size-4 text-muted-foreground"}),(0,eb.jsx)("h1",{className:"text-sm font-semibold text-foreground",children:"board"===l?"看板":"图谱"}),(0,eb.jsxs)("span",{className:"text-xs text-muted-foreground",children:[t.length," 个 issue"]})]}),(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[y?(0,eb.jsxs)("span",{className:"flex items-center gap-1 text-xs text-hot-pink",children:[(0,eb.jsx)(eE,{className:"size-3.5"}),y]}):null,(0,eb.jsxs)("div",{className:"flex items-center rounded-lg border border-border p-0.5",children:[(0,eb.jsxs)("button",{type:"button",onClick:()=>s("board"),className:(0,ez.cn)("flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition","board"===l?"bg-vivid-violet/15 text-vivid-violet":"text-muted-foreground hover:text-foreground"),children:[(0,eb.jsx)(ei1,{className:"size-3.5"}),"看板"]}),(0,eb.jsxs)("button",{type:"button",onClick:()=>s("graph"),className:(0,ez.cn)("flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition","graph"===l?"bg-vivid-violet/15 text-vivid-violet":"text-muted-foreground hover:text-foreground"),children:[(0,eb.jsx)(enH,{className:"size-3.5"}),"图谱"]})]}),"board"===l?(0,eb.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 text-xs text-muted-foreground",children:[(0,eb.jsx)("input",{type:"checkbox",checked:C,onChange:e=>M(e.target.checked),className:"size-3.5 accent-vivid-violet"}),"显示已取消"]}):null,(0,eb.jsxs)(eO.Button,{variant:"outline",size:"sm",onClick:()=>void P(),disabled:g,children:[(0,eb.jsx)(yt,{className:(0,ez.cn)("size-4",g&&"animate-spin")}),"刷新"]}),(0,eb.jsxs)(eO.Button,{variant:"outline",size:"sm",onClick:()=>{f(!0),d(!0)},children:[(0,eb.jsx)(kM,{className:"size-4"}),"任务分发"]})]})]}),i.length>0?(0,eb.jsx)(eoU,{approvals:i,onResolve:T}):null,h?(0,eb.jsx)("div",{className:"flex flex-1 items-center justify-center",children:(0,eb.jsx)(eM,{className:"size-6 animate-spin text-muted-foreground"})}):v?(0,eb.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 text-sm text-hot-pink",children:[(0,eb.jsx)(eE,{className:"size-5"}),v,(0,eb.jsx)(eO.Button,{variant:"outline",size:"sm",onClick:()=>void P(),children:"重试"})]}):"graph"===l?(0,eb.jsx)(eo_,{issues:t,links:r,onOpenIssue:e=>S(e)}):(0,eb.jsx)("div",{className:(0,ez.cn)("grid flex-1 content-start gap-x-3 gap-y-5 overflow-y-auto px-5 pb-4","grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-6"),children:R.map(t=>{let r=O[t.status]??[],a=j===t.status,i=E===t.status;return(0,eb.jsxs)("section",{onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",j!==t.status&&k(t.status)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||k(e=>e===t.status?null:e)},onDrop:e=>A(e,t.status),className:"flex min-w-0 flex-col gap-2",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2 px-1",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,eb.jsx)("span",{className:(0,ez.cn)("size-2 shrink-0 rounded-full",t.dot)}),(0,eb.jsx)("span",{className:"truncate text-sm font-medium text-foreground",children:t.label}),(0,eb.jsx)("span",{className:(0,ez.cn)("shrink-0 rounded-full px-1.5 py-0.5 text-[11px] font-medium",t.chip),children:r.length})]}),(0,eb.jsx)("button",{type:"button",title:"新建 issue",onClick:()=>I(e=>e===t.status?null:t.status),className:"flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-muted hover:text-foreground",children:(0,eb.jsx)(lY,{className:"size-4"})})]}),(0,eb.jsxs)("div",{className:(0,ez.cn)("flex min-h-[5rem] flex-col divide-y divide-border overflow-hidden rounded-lg border bg-card transition-colors",a?"border-vivid-violet ring-1 ring-vivid-violet/40":"border-border"),children:[i?(0,eb.jsx)(eoK,{onCancel:()=>I(null),onCreate:async r=>{try{let a=await ei8(e,{...r}),i="backlog"===t.status?a:await ei7(a.id,{status:t.status}).catch(()=>a);n(e=>[...e,i]),I(null)}catch(e){w(e instanceof Error?`新建失败:${e.message}`:"新建失败")}}}):null,0!==r.length||i?r.map(e=>(0,eb.jsx)(eoW,{issue:e,onOpen:()=>S(e.id),onDropBefore:n=>A(n,t.status,e.id)},e.id)):(0,eb.jsx)("div",{className:"flex flex-1 items-center justify-center px-3 py-8 text-xs text-muted-foreground/60",children:a?"松开以移动到此状态":"暂无 issue"})]})]},t.status)})})]}),(0,eb.jsx)(eoP,{issueId:N,projectId:e,open:null!==N,onClose:()=>S(null),onChange:t=>{n(e=>e.map(e=>e.id===t.id?t:e)),eor(e).then(e=>a(e)).catch(()=>{})},onDeleted:e=>n(t=>t.filter(t=>t.id!==e))}),(0,eb.jsx)(dX,{open:c,onOpenChange:d,children:(0,eb.jsxs)(erc,{side:m?"bottom":"right",className:(0,ez.cn)("w-full gap-0 p-0",m?"h-[95svh]":"sm:max-w-md md:max-w-lg lg:max-w-xl"),children:[(0,eb.jsx)(erd,{className:"border-b",children:(0,eb.jsx)(eru,{children:"任务分发"})}),(0,eb.jsx)("div",{className:"min-h-0 flex-1",children:u?(0,eb.jsx)(eoF,{projectId:e}):null})]})})]})}function eoU({approvals:e,onResolve:t}){return(0,eb.jsxs)("section",{className:"mx-5 mb-3 flex flex-col gap-2 rounded-xl border border-amber-500/40 bg-amber-500/5 p-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)(eiE,{className:"size-4 text-amber-600 dark:text-amber-400"}),(0,eb.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"待审批"}),(0,eb.jsx)("span",{className:"rounded-full bg-amber-500/15 px-1.5 py-0.5 text-[11px] font-medium text-amber-600 dark:text-amber-400",children:e.length}),(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:"同伴会话有待你确认的工具调用"})]}),(0,eb.jsx)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:e.map(e=>(0,eb.jsx)(eoq,{approval:e,onResolve:t},e.approvalId))})]})}function eoq({approval:e,onResolve:t}){let[n,r]=ew.useState(null),[a,i]=ew.useState(!1),[o,l]=ew.useState("");async function s(n,a){r(n);try{await t(e,n,a)}finally{r(null)}}let c=e.riskFactors??[];return(0,eb.jsxs)("article",{className:"flex flex-col gap-2 rounded-lg border border-border bg-card p-2.5 shadow-sm",children:[(0,eb.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,eb.jsx)("span",{className:"break-words font-mono text-[13px] font-medium text-foreground",children:e.toolName}),(0,eb.jsx)("span",{className:(0,ez.cn)("shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",eoM[e.classification]),children:eoC[e.classification]})]}),e.title?(0,eb.jsx)("p",{className:"break-words text-[13px] text-foreground",children:e.title}):null,e.reason?(0,eb.jsx)("p",{className:"break-words text-xs text-muted-foreground",children:e.reason}):null,c.length>0?(0,eb.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,eb.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground/70",children:"风险"}),(0,eb.jsx)("ul",{className:"flex flex-wrap gap-1",children:c.map((e,t)=>(0,eb.jsx)("li",{className:"rounded-full bg-hot-pink/10 px-1.5 py-0.5 text-[10px] text-hot-pink",children:e},`${e}-${t}`))})]}):null,(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground/70",children:[(0,eb.jsx)(kM,{className:"size-3 shrink-0"}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",title:e.conversationTitle,children:e.conversationTitle||"(未命名会话)"}),(0,eb.jsx)("span",{className:"shrink-0","aria-hidden":!0,children:"·"}),(0,eb.jsx)("span",{className:"shrink-0",children:eoS(e.createdAt)})]}),a?(0,eb.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,eb.jsx)(eA,{autoFocus:!0,value:o,onChange:e=>l(e.target.value),placeholder:"拒绝理由(可选)",className:"h-8",onKeyDown:e=>{"Enter"===e.key&&s("reject",o.trim()),"Escape"===e.key&&(i(!1),l(""))}}),(0,eb.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"sm",disabled:null!==n,onClick:()=>{i(!1),l("")},children:"取消"}),(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",variant:"destructive",disabled:null!==n,onClick:()=>void s("reject",o.trim()),children:["reject"===n?(0,eb.jsx)(eM,{className:"size-4 animate-spin"}):(0,eb.jsx)(fV.XIcon,{className:"size-4"}),"确认拒绝"]})]})]}):(0,eb.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,eb.jsxs)(eO.Button,{type:"button",variant:"outline",size:"sm",disabled:null!==n,onClick:()=>i(!0),children:[(0,eb.jsx)(fV.XIcon,{className:"size-4"}),"拒绝"]}),(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",disabled:null!==n,onClick:()=>void s("approve"),children:["approve"===n?(0,eb.jsx)(eM,{className:"size-4 animate-spin"}):(0,eb.jsx)(h6,{className:"size-4"}),"通过"]})]})]})}function eoW({issue:e,onOpen:t,onDropBefore:n}){let r=e.progress,a=r?.checklist.length??0,i=r?.checklist.filter(e=>e.done).length??0;return(0,eb.jsxs)("article",{draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed="move",t.dataTransfer.setData(eoV,e.id),t.dataTransfer.setData("text/plain",e.id)},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="move"},onDrop:n,onClick:t,className:"group cursor-pointer px-3 py-2.5 transition-colors hover:bg-muted/50 active:cursor-grabbing",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsxs)("span",{className:"shrink-0 font-mono text-[11px] text-muted-foreground",children:["#",e.number]}),(0,eb.jsx)("span",{className:(0,ez.cn)("shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",eox[e.type]),children:eop[e.type]}),"low"!==e.priority&&"normal"!==e.priority?(0,eb.jsx)("span",{className:(0,ez.cn)("shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",eoy[e.priority]),children:eov[e.priority]}):null,(0,eb.jsx)("span",{className:"ml-auto flex min-w-0 shrink items-center justify-end gap-1 text-[11px] text-muted-foreground",children:e.assignee?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(eoT,{kind:e.assignee.kind,small:!0}),(0,eb.jsx)("span",{className:"truncate",children:e.assignee.displayName})]}):(0,eb.jsx)("span",{className:"text-muted-foreground/50",children:"未认领"})})]}),(0,eb.jsx)("h3",{className:"mt-1 break-words text-sm font-medium leading-snug text-foreground",children:e.title}),e.labels.length>0?(0,eb.jsx)("div",{className:"mt-1.5 flex flex-wrap gap-1",children:e.labels.slice(0,4).map(e=>(0,eb.jsx)("span",{className:"rounded-full bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:e},e))}):null,r&&(r.percent>0||a>0)?(0,eb.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,eb.jsx)("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-muted",children:(0,eb.jsx)("div",{className:"h-full rounded-full bg-vivid-violet transition-all",style:{width:`${Math.max(0,Math.min(100,r.percent))}%`}})}),(0,eb.jsx)("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:a>0?`${i}/${a}`:`${r.percent}%`})]}):null]})}function eoK({onCreate:e,onCancel:t}){let[n,r]=ew.useState(""),[a,i]=ew.useState("task"),[o,l]=ew.useState("normal"),[s,c]=ew.useState(!1);return(0,eb.jsxs)("form",{className:"flex flex-col gap-2 rounded-lg border border-vivid-violet/40 bg-card p-2.5",onSubmit:async t=>{t.preventDefault(),n.trim()&&(c(!0),await e({title:n.trim(),type:a,priority:o}),c(!1))},children:[(0,eb.jsx)(eA,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),placeholder:"issue 标题",className:"h-8"}),(0,eb.jsxs)("div",{className:"flex gap-1.5",children:[(0,eb.jsx)(ei2,{size:"sm",className:"flex-1",value:a,onChange:e=>i(e.target.value),children:eog.map(e=>(0,eb.jsx)(ei5,{value:e,children:eop[e]},e))}),(0,eb.jsx)(ei2,{size:"sm",className:"flex-1",value:o,onChange:e=>l(e.target.value),children:eob.map(e=>(0,eb.jsx)(ei5,{value:e,children:eov[e]},e))})]}),(0,eb.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"sm",onClick:t,children:"取消"}),(0,eb.jsx)(eO.Button,{type:"submit",size:"sm",disabled:!n.trim()||s,children:s?(0,eb.jsx)(eM,{className:"size-4 animate-spin"}):"新建"})]})]})}let eoG=(0,ek.default)("archive-restore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]),eoX=(0,ek.default)("file-code-corner",[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]]),eoY=(0,ek.default)("git-merge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);function eoZ({projectId:e,onOpenSettings:t,onOpenConversation:n}){let[r,a]=ew.useState(),[i,o]=ew.useState({sessionCount:0,runningCount:0,tokenTotal:0,issueCount:0,openIssueCount:0,pendingApprovalCount:0}),[l,s]=ew.useState(!0),[c,d]=ew.useState([]),[u,f]=ew.useState([]),[m,h]=ew.useState(),[p,g]=ew.useState(),[x,v]=ew.useState(),[b,y]=ew.useState(!0),w=ew.useCallback(async()=>{y(!0);let[t,n]=await Promise.all([eik(e).catch(()=>void 0),eiN(e).catch(()=>void 0)]);t&&g(t),n&&v(n),y(!1)},[e]);return ew.useEffect(()=>{let e=!0;return g(void 0),v(void 0),w().finally(()=>{if(!e)return}),()=>{e=!1}},[w]),ew.useEffect(()=>{let t=!0;async function n(){try{let n,r=await eib(e);if(!t)return;a(r);let i=await eiS(e).catch(()=>[]);if(!t)return;d(i);let l=await ei3(e).catch(()=>[]);if(!t)return;f(l);let s=await eos(e).catch(()=>[]);if(!t)return;let c=await eij(e).catch(()=>void 0);if(!t)return;c&&h(c);let u=l.filter(e=>"done"!==e.status&&"cancelled"!==e.status).length;if(r.canvasId)try{n=(await enR(r.canvasId)).nodes.length}catch{n=void 0}if(!t)return;o({sessionCount:i.length,runningCount:i.filter(e=>!0===e.running).length,tokenTotal:i.reduce((e,t)=>e+(t.runUsage?.totalTokens??t.tokens??0),0),canvasNodeCount:n,issueCount:l.length,openIssueCount:u,pendingApprovalCount:s.length})}catch{}finally{t&&s(!1)}}s(!0),n();let r=setInterval(()=>void n(),1e4);return()=>{t=!1,clearInterval(r)}},[e]),(0,eb.jsx)(en3,{children:(0,eb.jsxs)("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-6 px-6 py-8",children:[(0,eb.jsxs)("header",{className:"flex flex-col gap-1",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,eb.jsx)(uU,{className:"size-4"}),(0,eb.jsx)("span",{className:"text-[13px]",children:"工程"}),(0,eb.jsx)(eoJ,{count:i.pendingApprovalCount}),t?(0,eb.jsxs)("button",{type:"button",onClick:()=>t(e),title:"工程设置",className:"ml-auto flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(era,{}),"设置"]}):null]}),(0,eb.jsx)("h1",{className:"text-2xl font-semibold text-foreground",children:r?.title??(l?"加载中…":"工程")}),r?.summary?(0,eb.jsx)("p",{className:"max-w-2xl text-sm text-muted-foreground",children:r.summary}):(0,eb.jsx)("p",{className:"text-sm text-muted-foreground/60",children:"暂无工程摘要"})]}),(0,eb.jsxs)("section",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[(0,eb.jsx)(eo5,{icon:(0,eb.jsx)(uH,{className:"size-4"}),label:"Agent 会话",value:i.sessionCount,hint:`${i.runningCount} 个运行中`,loading:l}),(0,eb.jsx)(eo5,{icon:(0,eb.jsx)(ei1,{className:"size-4"}),label:"issue 总数",value:i.issueCount,hint:`${i.openIssueCount} 个进行中`,loading:l}),(0,eb.jsx)(eo5,{icon:(0,eb.jsx)(Yv,{className:"size-4"}),label:"总 token",value:i.tokenTotal,loading:l}),(0,eb.jsx)(eo5,{icon:(0,eb.jsx)(uU,{className:"size-4"}),label:"画布节点",value:i.canvasNodeCount??"—",hint:r?.canvasId?void 0:"未绑定画布",loading:l&&r?.canvasId!==void 0})]}),(0,eb.jsx)(eoQ,{projectId:e,budget:m,loading:l,onUpdated:(e,t)=>{h(e),t&&a(t)}}),(0,eb.jsx)(eo0,{peers:c,issues:u,loading:l}),(0,eb.jsx)(eo1,{projectId:e,onOpenConversation:n}),(0,eb.jsxs)("section",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:[(0,eb.jsx)(eo8,{stats:p,loading:b,onRefresh:()=>void w()}),(0,eb.jsx)(eo7,{graph:x,loading:b,onRefresh:()=>void w()})]})]})})}function eoJ({count:e}){return e<=0?(0,eb.jsx)("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground/60",children:"无待审批"}):(0,eb.jsxs)("span",{className:"flex items-center gap-1 rounded-full bg-amber-500/15 px-2 py-0.5 text-[11px] font-medium text-amber-600 dark:text-amber-400 [&_svg]:size-3",title:"同伴会话有待你确认的工具调用,可在看板顶部处理",children:[(0,eb.jsx)(eiE,{}),"待审批 ",e.toLocaleString("zh-CN")]})}function eoQ({projectId:e,budget:t,loading:n,onUpdated:r}){let[a,i]=ew.useState(!1),[o,l]=ew.useState(""),[s,c]=ew.useState(!1),[d,u]=ew.useState();if(n&&!t)return(0,eb.jsxs)("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-sm",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground [&_svg]:shrink-0",children:[(0,eb.jsx)(erI,{className:"size-4"}),(0,eb.jsx)("span",{className:"text-[13px]",children:"工程预算"})]}),(0,eb.jsx)(eM,{className:"size-5 animate-spin text-muted-foreground"})]});if(!t)return null;let f=Math.max(0,t.pct),m=Math.min(100,f),h=t.hard?"hard":t.soft?"soft":"normal";async function p(){let n=o.trim(),a=Number(n);if(""===n||!Number.isFinite(a)||a<0)return void u("请输入 ≥ 0 的整数(0 表示恢复全局默认)");c(!0),u(void 0);try{let n=Math.floor(a),o=await eiw(e,{budgetTokens:n}),l=await eij(e).catch(()=>void 0);r(l??{...t,budget:n||t.budget},o),i(!1)}catch(e){u(e instanceof Error?e.message:"保存失败")}finally{c(!1)}}return(0,eb.jsxs)("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-sm",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground [&_svg]:shrink-0",children:[(0,eb.jsx)(erI,{className:"size-4"}),(0,eb.jsx)("span",{className:"text-[13px]",children:"工程预算"})]}),(0,eb.jsx)("span",{className:(0,ez.cn)("text-xs font-medium","hard"===h?"text-hot-pink":"soft"===h?"text-amber-500":"text-muted-foreground"),children:"hard"===h?"已用尽":"soft"===h?"接近上限":"正常"})]}),(0,eb.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,eb.jsxs)("span",{className:"text-2xl font-semibold text-foreground",children:[f,"%"]}),(0,eb.jsxs)("span",{className:"text-xs text-muted-foreground/70",children:["已用 ",t.used.toLocaleString("zh-CN")," /"," ",t.budget.toLocaleString("zh-CN")," token"]})]}),(0,eb.jsx)("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:(0,eb.jsx)("div",{className:(0,ez.cn)("h-full rounded-full transition-all","hard"===h?"bg-hot-pink":"soft"===h?"bg-amber-500":"bg-sky-teal"),style:{width:`${m}%`}})}),(0,eb.jsx)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground/70",children:a?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("input",{type:"number",min:0,step:1e5,value:o,autoFocus:!0,disabled:s,onChange:e=>l(e.target.value),onKeyDown:e=>{"Enter"===e.key&&p(),"Escape"===e.key&&(i(!1),u(void 0))},placeholder:"0 = 全局默认",className:"w-40 rounded-md border border-border bg-background px-2 py-1 text-foreground outline-none focus:border-sky-teal"}),(0,eb.jsxs)("button",{type:"button",disabled:s,onClick:()=>void p(),className:"flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1 text-foreground hover:bg-muted [&_svg]:size-3 disabled:opacity-50",children:[s?(0,eb.jsx)(eM,{className:"size-3 animate-spin"}):(0,eb.jsx)(h6,{}),"保存"]}),(0,eb.jsx)("button",{type:"button",disabled:s,onClick:()=>{i(!1),u(void 0)},className:"flex items-center gap-1 rounded-md px-1.5 py-1 hover:bg-muted [&_svg]:size-3 disabled:opacity-50",children:(0,eb.jsx)(fV.XIcon,{})}),d?(0,eb.jsx)("span",{className:"text-hot-pink",children:d}):null]}):(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsxs)("span",{children:["预算上限 ",t.budget.toLocaleString("zh-CN")," token"]}),(0,eb.jsxs)("button",{type:"button",onClick:()=>{l(String(t.budget)),u(void 0),i(!0)},className:"flex items-center gap-1 rounded-md px-1.5 py-1 text-muted-foreground hover:bg-muted hover:text-foreground [&_svg]:size-3",children:[(0,eb.jsx)(UH,{}),"调整"]})]})})]})}function eo0({peers:e,issues:t,loading:n}){let r=ew.useMemo(()=>{let e=new Map,n=e=>"done"===e.status||"cancelled"===e.status;for(let r of t){if(r.assignee?.kind!=="agent")continue;let t=r.assignee.id,a=e.get(t);(!a||n(a)&&!n(r))&&e.set(t,r)}return e},[t]);return n&&0===e.length?null:(0,eb.jsxs)("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-4 shadow-sm",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground [&_svg]:shrink-0",children:[(0,eb.jsx)(uH,{className:"size-4"}),(0,eb.jsx)("span",{className:"text-[13px]",children:"同伴会话"}),(0,eb.jsx)("span",{className:"text-xs text-muted-foreground/60",children:e.length})]}),0===e.length?(0,eb.jsx)("p",{className:"py-1 text-xs text-muted-foreground/60",children:"暂无同伴会话。在工程内的对话里用多代理工具拉起同伴即可在此显示。"}):(0,eb.jsx)("ul",{className:"flex flex-col gap-1",children:e.map(e=>{let t=!0===e.running,n=r.get(e.id),a=function(e){let t=e.settings?.folders?.[0]?.trim();if(!t)return"";let n=t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean);return n[n.length-1]??""}(e);return(0,eb.jsxs)("li",{className:"flex items-center gap-2 rounded-lg px-2 py-1.5 text-[13px] hover:bg-muted/50",children:[(0,eb.jsx)("span",{className:(0,ez.cn)("size-1.5 shrink-0 rounded-full",t?"animate-pulse bg-green-500":"border border-muted-foreground/50 bg-transparent"),"aria-label":t?"运行中":"空闲"}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate text-foreground",children:e.title||"(未命名)"}),n?(0,eb.jsxs)("span",{className:"shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground",title:n.title,children:["#",n.number]}):null,a?(0,eb.jsxs)("span",{className:"flex shrink-0 items-center gap-1 text-[11px] text-muted-foreground/70 [&_svg]:size-3",children:[(0,eb.jsx)(HM,{}),(0,eb.jsx)("span",{className:"max-w-32 truncate",children:a})]}):null,(0,eb.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground/60",children:t?"运行中":"空闲"})]},e.id)})})]})}function eo1({projectId:e,onOpenConversation:t}){let[n,r]=ew.useState([]),[a,i]=ew.useState(),[o,l]=ew.useState(),s=ew.useCallback(async()=>{try{let t=await eiS(e,!0);r(t.filter(e=>!!e.archivedAt))}catch{}},[e]);ew.useEffect(()=>{let t=!0,n=async()=>{try{let n=await eiS(e,!0);t&&r(n.filter(e=>!!e.archivedAt))}catch{}};n();let a=setInterval(()=>void n(),1e4);return()=>{t=!1,clearInterval(a)}},[e]);let c=ew.useCallback(async e=>{i(e.id);try{await sQ(e.id,e.ownerMachineId)}catch{}r(t=>t.filter(t=>t.id!==e.id)),i(void 0),s()},[s]),d=ew.useCallback(async e=>{i(e.id);try{await sZ(e.id,e.ownerMachineId)}catch{}r(t=>t.filter(t=>t.id!==e.id)),i(void 0),l(void 0),s()},[s]);return 0===n.length?null:(0,eb.jsxs)("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-4 shadow-sm",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground [&_svg]:shrink-0",children:[(0,eb.jsx)(bX,{className:"size-4"}),(0,eb.jsx)("span",{className:"text-[13px]",children:"已归档对话"}),(0,eb.jsx)("span",{className:"text-xs text-muted-foreground/60",children:n.length})]}),(0,eb.jsx)("ul",{className:"flex flex-col gap-1",children:n.map(n=>{let r=a===n.id;return(0,eb.jsxs)("li",{className:"group flex items-center gap-2 rounded-lg px-2 py-1.5 text-[13px] hover:bg-muted/50",children:[(0,eb.jsx)("button",{type:"button",disabled:!t,onClick:()=>t?.(e,n.id,n.ownerMachineId),title:n.title||"(未命名)",className:"min-w-0 flex-1 truncate text-left text-foreground disabled:cursor-default",children:n.title||"(未命名)"}),(0,eb.jsxs)("button",{type:"button",disabled:r,onClick:()=>void c(n),title:"取消归档",className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground opacity-0 transition hover:bg-background/70 hover:text-foreground group-hover:opacity-100 disabled:opacity-50 [&_svg]:size-3.5",children:[r?(0,eb.jsx)(eM,{className:"size-3.5 animate-spin"}):(0,eb.jsx)(eoG,{}),"取消归档"]}),(0,eb.jsxs)("button",{type:"button",disabled:r,onClick:()=>l(n.id),title:"删除",className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs text-hot-pink opacity-0 transition hover:bg-hot-pink/10 group-hover:opacity-100 disabled:opacity-50 [&_svg]:size-3.5",children:[(0,eb.jsx)(yn,{}),"删除"]}),o===n.id?(0,eb.jsx)(eo2,{title:n.title||"(未命名)",onCancel:()=>l(void 0),onConfirm:()=>void d(n)}):null]},n.id)})})]})}function eo2({title:e,onCancel:t,onConfirm:n}){return(0,eb.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",role:"dialog","aria-modal":"true",onClick:t,children:(0,eb.jsxs)("div",{className:"flex w-full max-w-sm flex-col gap-4 rounded-xl border border-border bg-card p-5 shadow-lg",onClick:e=>e.stopPropagation(),children:[(0,eb.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,eb.jsx)("h2",{className:"text-base font-semibold text-foreground",children:"删除会话"}),(0,eb.jsxs)("p",{className:"text-sm text-muted-foreground",children:["确认删除「",e,"」?此操作无法撤销。"]})]}),(0,eb.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,eb.jsx)("button",{type:"button",onClick:t,className:"rounded-md border border-border bg-background px-3 py-1.5 text-sm text-foreground hover:bg-muted",children:"取消"}),(0,eb.jsx)("button",{type:"button",onClick:n,className:"rounded-md bg-hot-pink px-3 py-1.5 text-sm font-medium text-white hover:opacity-90",children:"删除"})]})]})})}function eo5({icon:e,label:t,value:n,hint:r,loading:a,muted:i}){return(0,eb.jsxs)("div",{className:(0,ez.cn)("flex flex-col gap-2 rounded-xl border border-border bg-card p-4 shadow-sm",i&&"opacity-70"),children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground [&_svg]:shrink-0",children:[e,(0,eb.jsx)("span",{className:"text-[13px]",children:t})]}),(0,eb.jsx)("div",{className:"text-2xl font-semibold text-foreground",children:a?(0,eb.jsx)(eM,{className:"size-5 animate-spin text-muted-foreground"}):"number"==typeof n?n.toLocaleString("zh-CN"):n}),r?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground/70",children:r}):null]})}function eo4({loading:e,onRefresh:t}){return(0,eb.jsxs)("button",{type:"button",disabled:e,onClick:t,title:"刷新",className:"flex items-center gap-1 rounded-md px-1.5 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-50 [&_svg]:size-3",children:[(0,eb.jsx)(yt,{className:(0,ez.cn)(e&&"animate-spin")}),"刷新"]})}let eo3=["bg-sky-teal","bg-vivid-violet","bg-hot-pink","bg-amber-500","bg-emerald-500","bg-blue-500","bg-orange-500","bg-cyan-500"];function eo6(e,t){return"其他"===t?"bg-ash-gray":eo3[e%eo3.length]??"bg-ash-gray"}function eo8({stats:e,loading:t,onRefresh:n}){let r=!!e&&e.totalFiles>0,a=!!e&&!e.folder.trim();return(0,eb.jsxs)("div",{className:"flex min-h-32 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-sm",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground [&_svg]:shrink-0",children:[(0,eb.jsx)(eoX,{className:"size-4"}),(0,eb.jsx)("span",{className:"text-[13px]",children:"代码行数 · 分语言占比"})]}),(0,eb.jsx)(eo4,{loading:t,onRefresh:n})]}),t&&!e?(0,eb.jsx)("div",{className:"flex flex-1 items-center justify-center py-4",children:(0,eb.jsx)(eM,{className:"size-5 animate-spin text-muted-foreground"})}):r?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,eb.jsx)("span",{className:"text-2xl font-semibold text-foreground",children:e.totalLines.toLocaleString("zh-CN")}),(0,eb.jsxs)("span",{className:"text-xs text-muted-foreground/70",children:["行 · ",e.totalFiles.toLocaleString("zh-CN")," 个文件"]}),e.truncated?(0,eb.jsx)("span",{className:"rounded-full bg-amber-500/10 px-2 py-0.5 text-[11px] text-amber-500",children:"部分统计(已截断)"}):null]}),(0,eb.jsx)("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:e.languages.map((e,t)=>(0,eb.jsx)("div",{className:(0,ez.cn)("h-full",eo6(t,e.language)),style:{width:`${Math.max(e.pct,1)}%`},title:`${e.language} \xb7 ${e.pct}%`},e.language))}),(0,eb.jsx)("ul",{className:"flex flex-col gap-1.5",children:e.languages.slice(0,8).map((e,t)=>(0,eb.jsxs)("li",{className:"flex items-center gap-2 text-[13px]",children:[(0,eb.jsx)("span",{className:(0,ez.cn)("size-2.5 shrink-0 rounded-sm",eo6(t,e.language))}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate text-foreground",children:e.language}),(0,eb.jsxs)("span",{className:"shrink-0 text-xs text-muted-foreground/70",children:[e.lines.toLocaleString("zh-CN")," 行"]}),(0,eb.jsxs)("span",{className:"w-10 shrink-0 text-right text-xs font-medium text-muted-foreground",children:[e.pct,"%"]})]},e.language))})]}):(0,eb.jsx)("div",{className:"flex flex-1 items-center justify-center py-4",children:(0,eb.jsx)("span",{className:"rounded-full border border-border/60 bg-background px-3 py-1 text-xs text-muted-foreground",children:a?"未配置工作目录":"暂无代码统计"})})]})}function eo7({graph:e,loading:t,onRefresh:n}){let r=!!e&&e.commits.length>0,a=!!e&&!e.repoRoot.trim();return(0,eb.jsxs)("div",{className:"flex min-h-32 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-sm",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-muted-foreground [&_svg]:shrink-0",children:[(0,eb.jsx)(HM,{className:"size-4"}),(0,eb.jsx)("span",{className:"text-[13px]",children:"Git 提交图谱"}),e?.branch?(0,eb.jsx)("span",{className:"truncate rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground",children:e.branch}):null]}),(0,eb.jsx)(eo4,{loading:t,onRefresh:n})]}),t&&!e?(0,eb.jsx)("div",{className:"flex flex-1 items-center justify-center py-4",children:(0,eb.jsx)(eM,{className:"size-5 animate-spin text-muted-foreground"})}):r?(0,eb.jsx)("ul",{className:"flex max-h-[420px] flex-col overflow-y-auto pr-1",children:e.commits.map((t,n)=>{let r=n===e.commits.length-1,a=t.parents.length>1,i=t.refs.split(",").map(e=>e.trim().replace(/^HEAD ->\s*/,"").replace(/^tag:\s*/,"")).filter(Boolean);return(0,eb.jsxs)("li",{className:"flex gap-2.5",children:[(0,eb.jsxs)("div",{className:"flex w-3 shrink-0 flex-col items-center",children:[(0,eb.jsx)("span",{className:(0,ez.cn)("mt-1.5 flex size-3 items-center justify-center rounded-full",a?"bg-vivid-violet text-white [&_svg]:size-2":"border-2 border-sky-teal bg-background"),children:a?(0,eb.jsx)(eoY,{}):null}),r?null:(0,eb.jsx)("span",{className:"w-px flex-1 bg-border"})]}),(0,eb.jsxs)("div",{className:"min-w-0 flex-1 pb-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:t.shortSha}),i.map(e=>(0,eb.jsx)("span",{className:"shrink-0 rounded-full bg-sky-teal/10 px-1.5 py-0.5 text-[10px] font-medium text-sky-teal",children:e},e))]}),(0,eb.jsx)("p",{className:"truncate text-[13px] text-foreground",children:t.subject||"(无提交信息)"}),(0,eb.jsxs)("p",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground/70",children:[a?(0,eb.jsx)("span",{className:"text-vivid-violet",children:"合并"}):null,(0,eb.jsx)("span",{className:"truncate",children:t.author}),(0,eb.jsx)("span",{"aria-hidden":!0,children:"·"}),(0,eb.jsx)("span",{className:"shrink-0",children:function(e){let t=Date.parse(e);if(Number.isNaN(t))return e;let n=Date.now()-t;if(n<6e4)return"刚刚";if(n<36e5)return`${Math.floor(n/6e4)} 分钟前`;if(n<864e5)return`${Math.floor(n/36e5)} 小时前`;if(n<6048e5)return`${Math.floor(n/864e5)} 天前`;let r=new Date(t),a=String(r.getMonth()+1).padStart(2,"0"),i=String(r.getDate()).padStart(2,"0");return`${r.getFullYear()}-${a}-${i}`}(t.date)})]})]})]},t.sha)})}):(0,eb.jsx)("div",{className:"flex flex-1 items-center justify-center py-4",children:(0,eb.jsx)("span",{className:"rounded-full border border-border/60 bg-background px-3 py-1 text-xs text-muted-foreground",children:a?"非 Git 仓库":"暂无提交"})})]})}let eo9={delete:"Delete",empty:"Drop here",title:"Trash"};function ele({active:e=!1,items:t=[],labels:n,className:r,onDrop:a,onDelete:i,onItemRestore:o,...l}){let s={...eo9,...n},[c,d]=ew.useState(!1),u=ew.useRef(0),f=e||c||t.length>0;return ew.useEffect(()=>{e||(u.current=0,d(!1))},[e]),(0,eb.jsx)("div",{"data-slot":"trash-drop-zone","data-visible":f,"data-drag-inside":c,className:(0,ez.cn)("fixed top-4 left-1/2 z-50 -translate-x-1/2 transition-[opacity,transform] duration-300 ease-[cubic-bezier(.2,.8,.2,1)]",f?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-5 opacity-0",r),onDragEnter:function(e){e.preventDefault(),u.current+=1,d(!0)},onDragLeave:function(){u.current=Math.max(0,u.current-1),0===u.current&&d(!1)},onDragOver:function(e){e.preventDefault(),e.dataTransfer.dropEffect="move",d(!0)},onDrop:function(e){e.preventDefault(),e.stopPropagation(),u.current=0,d(!1);let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id")||e.dataTransfer.getData("text/plain"),n=e.dataTransfer.getData("text/plain")||t||"Dropped item",r=e.dataTransfer.getData("application/vnd.vantaloom.clip-kind");t&&a?.({id:t,title:n,meta:r,nativeEvent:e})},...l,children:(0,eb.jsx)("div",{className:(0,ez.cn)("min-w-12 overflow-hidden rounded-xl border-2 border-background bg-destructive text-destructive-foreground shadow-lg shadow-black/15 transition-[width,min-height,background-color,border-color,padding,box-shadow] duration-300","dark:border-destructive dark:bg-background dark:text-destructive",c||t.length>0?"w-64 border-dashed bg-destructive/12 p-2 text-destructive dark:bg-destructive/8":"flex size-12 items-center justify-center p-0"),children:c||t.length>0?(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsxs)("div",{className:"flex min-h-14 items-center justify-center gap-2 rounded-lg border border-dashed border-destructive/55 bg-destructive/8 px-3 text-sm font-medium text-destructive",children:[(0,eb.jsx)(yn,{className:"size-4"}),(0,eb.jsx)("span",{children:s.empty})]}),t.length>0?(0,eb.jsx)("div",{className:"grid max-h-36 gap-1 overflow-y-auto pr-1",children:t.map(e=>(0,eb.jsxs)("div",{className:"flex h-8 items-center gap-2 rounded-md border border-destructive/25 bg-background/80 px-2 text-foreground",children:[(0,eb.jsx)("button",{type:"button","aria-label":`Restore ${e.title}`,className:"flex size-5 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive",onClick:()=>o?.(e),children:(0,eb.jsx)(fV.XIcon,{className:"size-3.5"})}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",children:e.title}),e.meta?(0,eb.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:e.meta}):null]},e.id))}):null,t.length>0?(0,eb.jsx)("button",{type:"button",className:"h-8 rounded-md bg-destructive px-3 text-xs font-medium text-destructive-foreground transition-colors hover:bg-destructive/90 dark:border dark:border-destructive dark:bg-background dark:text-destructive dark:hover:bg-destructive/10",onClick:()=>i?.(t),children:s.delete}):null]}):(0,eb.jsx)(yn,{className:"size-5"})})})}function elt({hidden:e,items:t,trashItems:n,trashClipboardItems:r,draggingId:a,onDraggingChange:i,onItemsChange:o,onTrashItemsChange:l,onTrashClipboardItemsChange:s}){let c=ew.useRef(0),[d,u]=ew.useState(!1);return(ew.useEffect(()=>{u(!0)},[]),d)?(0,ix.createPortal)((0,eb.jsxs)("div",{className:(0,ez.cn)("pointer-events-none fixed inset-0 z-40 overflow-visible transition-opacity duration-200",e&&"opacity-0"),children:[(0,eb.jsx)(ele,{active:!e&&void 0!==a,items:e?[]:n,className:(0,ez.cn)(e&&"pointer-events-none"),labels:{delete:"删除",empty:"拖入暂存"},onDrop:({id:e,title:n,meta:r})=>{let a=t.find(t=>t.id===e);a&&(s(t=>({...t,[e]:a})),l(t=>t.some(t=>t.id===e)?t:[...t,{id:e,title:n,meta:r,icon:a.icon}]))},onDelete:e=>{let t=new Set(e.map(e=>e.id));l(e=>e.filter(e=>!t.has(e.id))),s(e=>{let n={...e};for(let e of t)delete n[e];return n})},onItemRestore:e=>{let n=r[e.id];n&&o([n,...t.filter(e=>e.id!==n.id)]),l(t=>t.filter(t=>t.id!==e.id)),s(t=>{let n={...t};return delete n[e.id],n})}}),t.length>0?(0,eb.jsx)("div",{className:(0,ez.cn)("pointer-events-auto absolute top-4 right-4 w-80 max-w-[calc(100vw-2rem)] transition-[opacity,transform] duration-200",e&&"pointer-events-none -translate-y-2 opacity-0"),children:(0,eb.jsx)(Z$,{items:t,title:"剪切板",labels:{empty:"剪切板为空",dragHandle:"拖拽卡片"},expansionDirection:"down-left",removeOnExternalDrop:!0,maxExpandedHeight:420,onItemDuplicate:(e,{item:n,index:r})=>{let a,i,l,s,d;return c.current+=1,a=n.payloads?.[qu],i=n.payloads?{...n.payloads}:void 0,l=n.payloads?.[qf],a&&i&&(i[qu]={...a,config:{...a.config}}),l&&i&&(i[qf]={...l,config:l.config?{...l.config}:l.config}),s={...n,id:`${n.id}-copy-${c.current}`,title:`${n.title} copy`,payloads:i,dragData:{...n.dragData,...a?{"application/vnd.vantaloom.dashboard-widget-config":JSON.stringify(a.config)}:{}}},void((d=[...t]).splice(r+1,0,s),o(d))},onItemsRemove:e=>o(e),onItemsReorder:e=>o(e),onItemDragStart:({item:e})=>i(e.id),onItemDragEnd:()=>i(void 0)})}):null]}),document.body):null}let eln=(0,ek.default)("languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]),elr=(0,ek.default)("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),ela=(0,ek.default)("log-out",[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]),eli=(0,ek.default)("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]),elo=(0,ek.default)("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]),ell=(0,ek.default)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);var els="Collapsible",[elc,eld]=cC(els),[elu,elf]=elc(els),elm=ew.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:a,disabled:i,onOpenChange:o,...l}=e,[s,c]=cT({prop:r,defaultProp:a??!1,onChange:o,caller:els});return(0,eb.jsx)(elu,{scope:n,disabled:i,contentId:cz(),open:s,onOpenToggle:ew.useCallback(()=>c(e=>!e),[c]),children:(0,eb.jsx)(cL.div,{"data-state":elv(s),"data-disabled":i?"":void 0,...l,ref:t})})});elm.displayName=els;var elh="CollapsibleTrigger",elp=ew.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,a=elf(elh,n);return(0,eb.jsx)(cL.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":elv(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...r,ref:t,onClick:cE(e.onClick,a.onOpenToggle)})});elp.displayName=elh;var elg="CollapsibleContent";ew.forwardRef((e,t)=>{let{forceMount:n,...r}=e,a=elf(elg,e.__scopeCollapsible);return(0,eb.jsx)(c2,{present:n||a.open,children:({present:e})=>(0,eb.jsx)(elx,{...r,ref:t,present:e})})}).displayName=elg;var elx=ew.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:a,...i}=e,o=elf(elg,n),[l,s]=ew.useState(r),c=ew.useRef(null),d=(0,cM.useComposedRefs)(t,c),u=ew.useRef(0),f=u.current,m=ew.useRef(0),h=m.current,p=o.open||l,g=ew.useRef(p),x=ew.useRef(void 0);return ew.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),cI(()=>{let e=c.current;if(e){x.current=x.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";let t=e.getBoundingClientRect();u.current=t.height,m.current=t.width,g.current||(e.style.transitionDuration=x.current.transitionDuration,e.style.animationName=x.current.animationName),s(r)}},[o.open,r]),(0,eb.jsx)(cL.div,{"data-state":elv(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!p,...i,ref:d,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":h?`${h}px`:void 0,...e.style},children:p&&a})});function elv(e){return e?"open":"closed"}var elb=e.i(91e3);function ely(e){let t=new Map(e.map(e=>[e.id,e])),n=new Map,r=[];for(let a of e){let e=a.forkOriginId;if(e&&t.has(e)){let t=n.get(e)??[];t.push(a),n.set(e,t)}else r.push(a)}return{byId:t,childrenOf:n,roots:r}}function elw(e){let{childrenOf:t,roots:n}=ely(e),r=[],a=e=>{for(let n of(r.push(e),t.get(e.id)??[]))a(n)};for(let e of n)a(e);return r}function elj(e,t,n,r,a){let i=new Set(e);if("range"===n&&a){let n=r.indexOf(a),o=r.indexOf(t);if(-1!==n&&-1!==o){let[a,l]=n<o?[n,o]:[o,n],s=!e.has(t);for(let e=a;e<=l;e++){let t=r[e];t&&(s?i.add(t):i.delete(t))}return i}}return i.has(t)?i.delete(t):i.add(t),i}function elk(e,t,n=!0){let r=ew.useRef(e);r.current=e;let a=ew.useRef(!1);ew.useEffect(()=>{if(!n)return;let e=!1,i=async()=>{if(!e&&!a.current){a.current=!0;try{await r.current()}finally{a.current=!1}}};i();let o=setInterval(()=>{"visible"===document.visibilityState&&i()},t),l=()=>{"visible"===document.visibilityState&&i()};return document.addEventListener("visibilitychange",l),()=>{e=!0,clearInterval(o),document.removeEventListener("visibilitychange",l)}},[t,n])}let elN={"new-canvas":"canvas","all-canvases":"canvas","open-recent-canvas":"canvas","new-project":"canvas","project-overview":"canvas","project-settings":"canvas","project-conversation":"canvas",kanban:"canvas","new-agent-conversation":"agent","open-recent-conversation":"agent",preferences:"settings","preferences-models":"settings","preferences-agents":"settings","system-general":"settings","network-downloads":"settings","preferences-model-routes":"settings","preferences-model-groups":"settings","preferences-agent-config":"settings","preferences-subagent-config":"settings","preferences-cc-engine-config":"settings","preferences-assets":"settings","preferences-layout":"settings","preferences-official-extensions":"settings","network-topology":"settings","network-settings":"settings","search-settings":"settings","system-downloads":"settings","check-update":"settings","balance-usage":"settings",feedback:"settings",account:"settings"};function elS({navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,activeProjectId:a,onItemSelect:i,onOpenConversation:o,onOpenProjectCanvas:l,onOpenProjectOverview:s,onOpenProjectKanban:c,onOpenProjectSettings:d,onNewProjectConversation:u,onOpenProjectConversation:f,onNewProject:m,onOpenConversationSettings:h,onConversationDeleted:p,onAccountSettings:g,subagentTree:x,activeSubagentPath:v,onOpenSubagent:b,hideCanvas:y,className:w}){let j=elN[n]??(elG.some(e=>e.items.some(e=>e.id===n))?"settings":y?"agent":"canvas"),[k,N]=ew.useState(j);ew.useEffect(()=>{N(j)},[j]);let S=t.find(e=>e.id===k),C=ew.useRef(null),M=ew.useRef(new Map),[E,I]=ew.useState(null),[P,O]=ew.useState(!1),z=ew.useCallback(()=>{let e=C.current,t=M.current.get(k);if(!e||!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();I({left:r.left-n.left,top:r.top-n.top,width:r.width,height:r.height})},[k]);return ew.useEffect(()=>{z();let e=window.requestAnimationFrame(()=>O(!0)),t=C.current,n=null;return t&&"u">typeof ResizeObserver&&(n=new ResizeObserver(z)).observe(t),window.addEventListener("resize",z),()=>{window.cancelAnimationFrame(e),n?.disconnect(),window.removeEventListener("resize",z)}},[z]),(0,eb.jsxs)("aside",{"data-slot":"flat-sidebar",className:(0,ez.cn)("flex h-full w-72 flex-col rounded-xl border border-border bg-sidebar p-3 text-sidebar-foreground shadow-sm",w),children:[(0,eb.jsxs)("nav",{ref:C,className:"relative mb-5 flex gap-1 rounded-lg bg-muted/70 p-1",children:[E?(0,eb.jsx)("span",{"aria-hidden":!0,className:(0,ez.cn)("pointer-events-none absolute top-0 left-0 z-0 rounded-md border border-border/50 bg-background shadow-sm",P&&"transition-[transform,width,height] duration-200 ease-out"),style:{transform:`translate(${E.left}px, ${E.top}px)`,width:E.width,height:E.height}}):null,e.map(e=>{let t=e.id===k;return(0,eb.jsxs)("button",{ref:t=>{t?M.current.set(e.id,t):M.current.delete(e.id)},type:"button",onClick:()=>N(e.id),className:(0,ez.cn)("relative z-10 flex flex-1 items-center justify-center gap-1.5 rounded-md py-1.5 text-[13px] font-medium transition-colors [&_svg]:size-4",t?"text-foreground":"text-muted-foreground hover:bg-background/50 hover:text-foreground"),children:[e.icon,(0,eb.jsx)("span",{className:"truncate",children:e.label})]},e.id)})]}),"canvas"===k?(0,eb.jsx)(elI,{activeProjectId:a,activeConversationId:r,hideCanvas:y,onOpenProjectCanvas:l,onOpenProjectOverview:s,onOpenProjectKanban:c,onOpenProjectSettings:d,onNewProjectConversation:u,onOpenProjectConversation:f,onNewProject:m,onOpenConversation:o,onOpenConversationSettings:h,onConversationDeleted:p,subagentTree:x,activeSubagentPath:v,onOpenSubagent:b}):"agent"===k?(0,eb.jsx)(elT,{activeConversationId:r,onItemSelect:i,onOpenConversation:o,onOpenConversationSettings:h,onConversationDeleted:p,subagentTree:x,activeSubagentPath:v,onOpenSubagent:b}):(0,eb.jsx)(elW,{content:S,activeWorkspace:n,onItemSelect:i}),(0,eb.jsx)(el0,{onItemSelect:i,onAccountSettings:g})]})}let elC=ew.useLayoutEffect;function elM({open:e,className:t,children:n}){let r=ew.useRef(null),[a,i]=ew.useState(e),[o,l]=ew.useState(e?"auto":0),s=ew.useRef(!0);return ew.useEffect(()=>{e&&i(!0)},[e]),elC(()=>{if(s.current){s.current=!1,l(e?"auto":0);return}let t=r.current;if(!t)return;let n=t.scrollHeight;if(e){l(n);let e=window.setTimeout(()=>l("auto"),200);return()=>window.clearTimeout(e)}l(n);let a=window.requestAnimationFrame(()=>l(0));return()=>window.cancelAnimationFrame(a)},[e]),(0,eb.jsx)("div",{"aria-hidden":!e,className:(0,ez.cn)("overflow-hidden transition-[height] ease-out",e?"duration-200":"duration-150",t),style:{height:o},children:(0,eb.jsx)("div",{ref:r,children:a?n:null})})}function elE(e){let[t,n]=ew.useState(0),r=ew.useRef(e);return ew.useEffect(()=>{e&&!r.current&&n(e=>e+1),r.current=e},[e]),t}function elI({activeProjectId:e,activeConversationId:t,hideCanvas:n,onOpenProjectCanvas:r,onOpenProjectOverview:a,onOpenProjectKanban:i,onOpenProjectSettings:o,onNewProjectConversation:l,onOpenProjectConversation:s,onNewProject:c,onOpenConversation:d,onOpenConversationSettings:u,onConversationDeleted:f,subagentTree:m,activeSubagentPath:h,onOpenSubagent:p}){let{projects:g,loading:x,refresh:v}=function(){let[e,t]=ew.useState([]),[n,r]=ew.useState(!0),a=ew.useRef(!0),i=ew.useCallback(async()=>{try{let e=await eiv();if(!a.current)return;let n=[...e].sort((e,t)=>t.updatedAt>e.updatedAt?1:-1);t(n)}catch{}finally{a.current&&r(!1)}},[]);return ew.useEffect(()=>{a.current=!0;let e=()=>void i();return window.addEventListener(eix,e),()=>{a.current=!1,window.removeEventListener(eix,e)}},[i]),elk(i,1e4),{projects:e,loading:n,refresh:()=>void i()}}(),b=x&&0===g.length;return(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("div",{className:"mb-6 space-y-0.5",children:(0,eb.jsx)("div",{className:"vtl-stagger-item",style:{animationDelay:"0ms"},children:(0,eb.jsx)(elZ,{icon:elo,label:en5.canvasNew,onClick:()=>c?.()})})}),(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto vtl-scrollbar-hidden pr-1",children:(0,eb.jsx)("div",{className:"space-y-0.5",children:b?(0,eb.jsx)(elJ,{}):0===g.length?(0,eb.jsx)("p",{className:"px-3 py-1.5 text-[13px] text-muted-foreground/60",children:en5.projectEmpty}):g.map((c,g)=>(0,eb.jsx)("div",{className:"vtl-stagger-item",style:{animationDelay:`${25*Math.min(g+1,12)}ms`},children:(0,eb.jsx)(elP,{project:c,active:c.id===e,activeConversationId:t,hideCanvas:n,onOpenProjectCanvas:r,onOpenProjectOverview:a,onOpenProjectKanban:i,onOpenProjectSettings:o,onNewProjectConversation:l,onOpenProjectConversation:s,onOpenConversation:d,onOpenConversationSettings:u,onConversationDeleted:f,onConversationsChanged:v,subagentTree:m,activeSubagentPath:h,onOpenSubagent:p})},c.id))})})]})}function elP({project:e,active:t,activeConversationId:n,hideCanvas:r,onOpenProjectCanvas:a,onOpenProjectOverview:i,onOpenProjectKanban:o,onOpenProjectSettings:l,onNewProjectConversation:s,onOpenProjectConversation:c,onOpenConversation:d,onOpenConversationSettings:u,onConversationDeleted:f,onConversationsChanged:m,subagentTree:h,activeSubagentPath:p,onOpenSubagent:g}){let[x,v]=ew.useState(t),[b,y]=ew.useState([]),[w,j]=ew.useState(0),k=ew.useCallback(async()=>{try{let t=await eos(e.id);j(t.length)}catch{}},[e.id]),[N,S]=ew.useState(()=>new Set),C=ew.useRef(null),M=N.size>0,E=ew.useCallback(async()=>{try{let t=await eiS(e.id);y(t)}catch{}},[e.id]);elk(E,1e4,x),elk(k,1e4,x);let I=ew.useCallback(async e=>{try{await sZ(e.id,e.ownerMachineId)}catch{}f?.(e.id),y(t=>t.filter(t=>t.id!==e.id)),m?.()},[f,m]),P=ew.useCallback(async e=>{try{await sJ(e.id,e.ownerMachineId)}catch{}y(t=>t.filter(t=>t.id!==e.id)),m?.()},[m]),O=ew.useMemo(()=>elw(b),[b]),z=ew.useMemo(()=>O.map(e=>e.id),[O]),A=ew.useCallback((e,t)=>{S(n=>elj(n,e,t,z,C.current)),C.current=e},[z]),T=ew.useCallback(()=>{S(new Set),C.current=null},[]);ew.useEffect(()=>{S(e=>{if(0===e.size)return e;let t=new Set(b.map(e=>e.id)),n=!1,r=new Set;for(let a of e)t.has(a)?r.add(a):n=!0;return n?r:e})},[b]);let R=ew.useCallback(async()=>{let e=b.filter(e=>N.has(e.id));await Promise.all(e.map(e=>sJ(e.id,e.ownerMachineId).catch(()=>{}))),T(),await E(),m?.()},[b,N,T,E,m]),D=ew.useCallback(async()=>{let e=b.filter(e=>N.has(e.id));for(let t of(await Promise.all(e.map(e=>sZ(e.id,e.ownerMachineId).catch(()=>{}))),e))f?.(t.id);T(),await E(),m?.()},[b,N,T,E,f,m]),_=ew.useCallback(async t=>{try{let n=await ct(t.id,void 0,t.ownerMachineId);c?c(e.id,n.conversation.id,n.conversation.ownerMachineId):d(n.conversation.id,n.conversation.ownerMachineId),m?.()}catch{}},[d,c,e.id,m]),L=ew.useCallback((t,n)=>{c?c(e.id,t,n):d(t,n)},[c,d,e.id]),$=ew.useMemo(()=>(function(e,t){let{childrenOf:n,roots:r}=ely(e),a=new Set((t.activeSubagentPath??[]).map(e=>e.id)),i=t.activeSubagentPath?.[t.activeSubagentPath.length-1]?.id,o=(e,r)=>{let l=e.id!==t.activeConversationId||(t.subagentTree?.length??0)===0?null:(0,eb.jsx)(elD,{nodes:t.subagentTree??[],depth:0,ancestors:[],activeIds:a,activeLeafId:i,onOpen:t.onOpenSubagent});return(0,eb.jsxs)(ew.Fragment,{children:[(0,eb.jsx)(elU,{conversation:e,depth:r,active:e.id===t.activeConversationId,onOpenConversation:t.onOpenConversation,onOpenConversationSettings:t.onOpenConversationSettings,onDelete:t.onDelete,onFork:t.onFork,onArchive:t.onArchive?()=>t.onArchive?.(e):void 0,selectionMode:t.selectionMode,selected:t.selectedIds?.has(e.id),onToggleSelect:t.onToggleSelect?n=>t.onToggleSelect?.(e.id,n):void 0}),l?(0,eb.jsx)("div",{style:r>0?{marginLeft:14*r}:void 0,children:l}):null,(n.get(e.id)??[]).map(e=>o(e,r+1))]},e.id)};return r.map((e,t)=>(0,eb.jsx)("div",{className:"vtl-stagger-item space-y-0.5",style:{animationDelay:`${25*Math.min(t+3,12)}ms`},children:o(e,0)},e.id))})(b,{activeConversationId:n,onOpenConversation:L,onOpenConversationSettings:u,onDelete:I,onFork:_,onArchive:P,selectionMode:M,selectedIds:N,onToggleSelect:A,subagentTree:h,activeSubagentPath:p,onOpenSubagent:g}),[b,n,L,u,I,_,P,M,N,A,h,p,g]),F=elE(x);return(0,eb.jsxs)(elm,{open:x,onOpenChange:v,children:[(0,eb.jsxs)("div",{className:(0,ez.cn)("group flex items-center rounded-lg text-[13px] transition-colors",t?"bg-muted text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground"),children:[(0,eb.jsx)(elp,{asChild:!0,children:(0,eb.jsx)("button",{type:"button","aria-label":x?"收起工程":"展开工程",className:"shrink-0 rounded-md p-1.5 pl-2 text-muted-foreground hover:text-foreground",onClick:e=>e.stopPropagation(),children:(0,eb.jsx)(pt,{className:(0,ez.cn)("size-4 transition-transform",x?"rotate-0":"-rotate-90")})})}),(0,eb.jsxs)("button",{type:"button",title:e.title,onClick:()=>{v(!0),i?.(e.id)},className:"flex min-w-0 flex-1 items-center gap-2 rounded-lg py-2 pr-3 text-left",children:[(0,eb.jsx)(uU,{className:"size-4 shrink-0 text-muted-foreground"}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.title}),w>0?(0,eb.jsx)("span",{title:`${w} 项待审批`,className:"shrink-0 rounded-full bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-amber-600 dark:bg-amber-400/20 dark:text-amber-300",children:w}):null,t&&(0,eb.jsx)(elQ,{active:!0})]})]}),(0,eb.jsx)(elM,{open:x,className:"mt-0.5",children:(0,eb.jsx)("div",{className:"ml-[1.125rem] border-l border-border/60 pl-1.5",children:(0,eb.jsxs)("div",{className:"space-y-0.5",children:[r?null:(0,eb.jsx)("div",{className:"vtl-stagger-item",style:{animationDelay:"0ms"},children:(0,eb.jsx)(elO,{icon:(0,eb.jsx)(uU,{className:"size-4"}),label:en5.projectCanvas,onClick:()=>a?.(e.id,e.canvasId)})}),(0,eb.jsx)("div",{className:"vtl-stagger-item",style:{animationDelay:"25ms"},children:(0,eb.jsx)(elO,{icon:(0,eb.jsx)(elr,{className:"size-4"}),label:en5.projectKanban,onClick:()=>o?.(e.id)})}),M?(0,eb.jsx)(el$,{count:N.size,archived:!1,onArchive:()=>void R(),onDelete:()=>void D(),onCancel:T}):null,$,(0,eb.jsxs)("button",{type:"button",onClick:()=>s?.(e.id),title:en5.projectNewConversation,className:"flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-[13px] text-muted-foreground/80 transition-colors hover:bg-muted hover:text-foreground",children:[(0,eb.jsx)(lY,{className:"size-4 shrink-0"}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",children:en5.projectNewConversation})]})]},F)})})]})}function elO({icon:e,label:t,onClick:n}){return(0,eb.jsxs)("button",{type:"button",onClick:n,className:"flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-[13px] text-foreground/80 transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-muted-foreground",children:[e,(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t})]})}let elz="__all__",elA={status:"all",location:elz,sort:"recent"};function elT({activeConversationId:e,onItemSelect:t,onOpenConversation:n,onOpenConversationSettings:r,onConversationDeleted:a,subagentTree:i,activeSubagentPath:o,onOpenSubagent:l}){let[s,c]=ew.useState(elA),d="archived"===s.status,{recents:u,refresh:f,loading:m,machineNames:h}=function(e){let[t,n]=ew.useState([]),[r,a]=ew.useState(!0),[i,o]=ew.useState({}),l=ew.useRef(!0),s=ew.useCallback(async()=>{try{let{machineNames:t}=await sT({includeArchived:e,onPartial:e=>{l.current&&(n([...e].filter(e=>!e.projectId).sort((e,t)=>t.updatedAt>e.updatedAt?1:-1)),a(!1))}});if(!l.current)return;o(t)}catch{}finally{l.current&&a(!1)}},[e]);return ew.useEffect(()=>(l.current=!0,()=>{l.current=!1}),[]),elk(s,1e4),{recents:t,refresh:()=>void s(),loading:r,machineNames:i}}(d),[p,g]=ew.useState(()=>new Set),x=ew.useRef(null),v=ew.useMemo(()=>{let e=new Set;for(let t of u)e.add(t.ownerMachineId||sC);return Array.from(e)},[u]),b=ew.useCallback(e=>sM(e)?"本机":h[e]??e,[h]),y=ew.useMemo(()=>{let e=u.filter(e=>{let t=!0===e.running,n=!!e.archivedAt;if("archived"===s.status){if(!n)return!1}else if(n)return!1;return("running"!==s.status||!!t)&&("idle"!==s.status||!t)&&(s.location===elz||(e.ownerMachineId||sC)===s.location)});return"name"===s.sort?e.sort((e,t)=>e.title.localeCompare(t.title,"zh-CN",{sensitivity:"base"})):e.sort((e,t)=>t.updatedAt>e.updatedAt?1:-1),e},[u,s]),w=ew.useMemo(()=>y.filter(e=>!0===e.running),[y]),j=ew.useMemo(()=>y.filter(e=>!0!==e.running),[y]),k=s.status!==elA.status||s.location!==elA.location||s.sort!==elA.sort,N=m&&0===u.length,S=ew.useCallback(async e=>{try{await sZ(e.id,e.ownerMachineId)}catch{}a?.(e.id),f()},[a,f]),C=ew.useCallback(async e=>{try{let t=await ct(e.id,void 0,e.ownerMachineId);await f(),n(t.conversation.id,t.conversation.ownerMachineId)}catch{}},[f,n]),M=ew.useCallback(async e=>{try{await sJ(e.id,e.ownerMachineId)}catch{}f()},[f]),E=ew.useCallback(async e=>{try{await sQ(e.id,e.ownerMachineId)}catch{}f()},[f]),I=ew.useMemo(()=>[...elw(w),...elw(j)],[w,j]),P=ew.useMemo(()=>I.map(e=>e.id),[I]),O=ew.useCallback((e,t)=>{g(n=>elj(n,e,t,P,x.current)),x.current=e},[P]),z=ew.useCallback(()=>{g(new Set),x.current=null},[]);ew.useEffect(()=>{g(e=>{if(0===e.size)return e;let t=new Set(I.map(e=>e.id)),n=!1,r=new Set;for(let a of e)t.has(a)?r.add(a):n=!0;return n?r:e})},[I]);let A=ew.useMemo(()=>I.filter(e=>p.has(e.id)),[I,p]),T=ew.useCallback(async()=>{await Promise.all(A.map(e=>(d?sQ(e.id,e.ownerMachineId):sJ(e.id,e.ownerMachineId)).catch(()=>{}))),z(),f()},[A,d,z,f]),R=ew.useCallback(async()=>{for(let e of(await Promise.all(A.map(e=>sZ(e.id,e.ownerMachineId).catch(()=>{}))),A))a?.(e.id);z(),f()},[A,z,f,a]),D=p.size>0,_=ew.useMemo(()=>new Set((o??[]).map(e=>e.id)),[o]),L=o?.[o.length-1]?.id,$=ew.useCallback(t=>t!==e||(i?.length??0)===0?null:(0,eb.jsx)(elD,{nodes:i??[],depth:0,ancestors:[],activeIds:_,activeLeafId:L,onOpen:l}),[e,i,_,L,l]),F=ew.useCallback(t=>{let{childrenOf:a,roots:i}=ely(t),o=(t,i)=>{let l=$(t.id);return(0,eb.jsxs)(ew.Fragment,{children:[(0,eb.jsx)(elU,{conversation:t,depth:i,active:t.id===e,onOpenConversation:n,onOpenConversationSettings:r,onDelete:S,onFork:C,onArchive:t.archivedAt?void 0:()=>M(t),onUnarchive:t.archivedAt?()=>E(t):void 0,selectionMode:D,selected:p.has(t.id),onToggleSelect:e=>O(t.id,e)}),l?(0,eb.jsx)("div",{style:i>0?{marginLeft:14*i}:void 0,children:l}):null,(a.get(t.id)??[]).map(e=>o(e,i+1))]},t.id)};return i.map(e=>o(e,0))},[$,e,n,r,S,C,M,E,D,p,O]),B=ew.useMemo(()=>F(w),[F,w]),V=ew.useMemo(()=>F(j),[F,j]);return(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("div",{className:"vtl-stagger-item mb-6 space-y-0.5",style:{animationDelay:"0ms"},"data-tour":"new-conversation",children:(0,eb.jsxs)(wh,{children:[(0,eb.jsx)(wg,{asChild:!0,children:(0,eb.jsx)(elZ,{icon:tl,label:en5.conversationNew,onClick:()=>t({item:{id:"new-agent-conversation"}})})}),(0,eb.jsx)(wN,{className:"min-w-44",children:(0,eb.jsxs)(wS,{onSelect:()=>t({item:{id:"import-claude-session"}}),children:[(0,eb.jsx)(bJ,{}),(0,eb.jsx)("span",{className:"flex-1",children:"导入 Claude 会话"})]})})]})}),D?(0,eb.jsx)(el$,{count:p.size,archived:d,onArchive:()=>void T(),onDelete:()=>void R(),onCancel:z}):null,(0,eb.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto vtl-scrollbar-hidden pr-1",children:[w.length>0?(0,eb.jsxs)("div",{className:"vtl-stagger-item mb-4",style:{animationDelay:"25ms"},children:[(0,eb.jsxs)("div",{className:"mb-2 flex items-center gap-2 px-3",children:[(0,eb.jsx)("span",{className:"size-1.5 shrink-0 rounded-full bg-green-500"}),(0,eb.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"正在运行"})]}),(0,eb.jsx)("div",{className:"space-y-0.5",children:B})]}):null,(0,eb.jsxs)("div",{className:"vtl-stagger-item mb-2 flex items-center justify-between px-3",style:{animationDelay:"50ms"},children:[(0,eb.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"最近"}),(0,eb.jsx)(elF,{filter:s,onChange:c,active:k,locations:v,locationLabel:b})]}),(0,eb.jsx)("div",{className:"space-y-0.5",children:N?(0,eb.jsx)(elJ,{}):0===j.length?(0,eb.jsx)("p",{className:"px-3 py-1.5 text-[13px] text-muted-foreground/60",children:d?"暂无已归档对话":k?"没有符合筛选条件的对话":"暂无对话"}):V})]})]})}function elR(e,t){return!!(e.running||t.has(e.id))||(e.children??[]).some(e=>elR(e,t))}let elD=ew.memo(function e({nodes:t,depth:n,ancestors:r,activeIds:a,activeLeafId:i,onOpen:o}){let l=t.filter(e=>elR(e,a));return 0===l.length?null:(0,eb.jsx)("div",{className:"space-y-0.5",children:l.map(t=>{let l=Uh(t.subagentType),s=l.Icon,c=[...r,{id:t.id,ownerMachineId:t.ownerMachineId,name:t.subagentName,subagentType:t.subagentType}],d=t.id===i,u=t.children??[],f=u.some(e=>elR(e,a));return(0,eb.jsxs)("div",{children:[(0,eb.jsxs)("button",{type:"button",className:(0,ez.cn)("flex w-full items-center gap-1.5 rounded-md py-1 pr-2 text-left text-xs transition-colors",d?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),style:{paddingLeft:18+14*n},onClick:()=>o?.(c),title:t.subagentName||l.label,children:[(0,eb.jsx)("span",{className:"shrink-0 text-muted-foreground/40",children:"└"}),(0,eb.jsx)(s,{className:(0,ez.cn)("size-3.5 shrink-0",l.color)}),(0,eb.jsx)("span",{className:"truncate",children:t.subagentName||`${l.label}子代理`}),t.running?(0,eb.jsx)(eM,{className:"ml-auto size-3 shrink-0 animate-spin text-muted-foreground"}):null]}),(0,eb.jsx)(elM,{open:f,children:(0,eb.jsx)(e,{nodes:u,depth:n+1,ancestors:c,activeIds:a,activeLeafId:i,onOpen:o})})]},t.id)})})},(e,t)=>e.nodes===t.nodes&&e.activeIds===t.activeIds&&e.activeLeafId===t.activeLeafId&&e.depth===t.depth&&e.ancestors===t.ancestors&&e.onOpen===t.onOpen),el_={all:"全部",running:"运行中",idle:"空闲",archived:"已归档"},elL={recent:"最近活动",name:"名称"};function el$({count:e,archived:t,onArchive:n,onDelete:r,onCancel:a}){let[i,o]=ew.useState(!1);return(0,eb.jsxs)("div",{className:"mb-3 flex items-center gap-1.5 rounded-lg border border-border bg-muted/60 px-2.5 py-1.5 text-[13px]",children:[(0,eb.jsxs)("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:["已选 ",e," 项"]}),(0,eb.jsxs)("button",{type:"button",onClick:n,title:t?"取消归档":"归档",className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-foreground/80 transition-colors hover:bg-background/70 hover:text-foreground [&_svg]:size-3.5",children:[t?(0,eb.jsx)(eoG,{}):(0,eb.jsx)(bX,{}),t?"取消归档":"归档"]}),(0,eb.jsxs)("button",{type:"button",onClick:()=>o(!0),title:"删除",className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-destructive transition-colors hover:bg-destructive/10 [&_svg]:size-3.5",children:[(0,eb.jsx)(yn,{}),"删除"]}),(0,eb.jsx)("button",{type:"button",onClick:a,className:"shrink-0 rounded-md px-2 py-1 text-muted-foreground transition-colors hover:bg-background/70 hover:text-foreground",children:"取消"}),(0,eb.jsx)(ux,{open:i,onOpenChange:o,children:(0,eb.jsxs)(uR,{children:[(0,eb.jsxs)(uD,{children:[(0,eb.jsx)(uL,{children:"删除会话"}),(0,eb.jsxs)(u$,{children:["确认删除选中的 ",e," 个对话?此操作无法撤销。"]})]}),(0,eb.jsxs)(u_,{children:[(0,eb.jsx)(uB,{children:"取消"}),(0,eb.jsx)(uF,{variant:"destructive",onClick:r,children:"删除"})]})]})})]})}function elF({filter:e,onChange:t,active:n,locations:r,locationLabel:a}){let i=sv(),o=e.location===elz?"全部":a(e.location),l=(0,eb.jsxs)("button",{type:"button",title:"筛选","aria-label":"筛选",className:(0,ez.cn)("relative rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground",n&&"text-foreground"),children:[(0,eb.jsx)(enW,{className:"size-4"}),n?(0,eb.jsx)("span",{className:"absolute -right-0.5 -top-0.5 size-2 rounded-full border border-sidebar bg-primary"}):null]});return i?(0,eb.jsxs)(x5,{direction:"bottom",children:[(0,eb.jsx)(dZ,{asChild:!0,children:l}),(0,eb.jsxs)(x3,{children:[(0,eb.jsx)(x6,{children:(0,eb.jsx)(x8,{children:"筛选与排序"})}),(0,eb.jsxs)("div",{className:"max-h-[60vh] overflow-y-auto px-4 pb-6",children:[(0,eb.jsx)(elB,{title:"状态",children:Object.keys(el_).map(n=>(0,eb.jsx)(elV,{label:el_[n],selected:e.status===n,onSelect:()=>t({...e,status:n})},n))}),(0,eb.jsxs)(elB,{title:"运行位置",children:[(0,eb.jsx)(elV,{label:"全部",selected:e.location===elz,onSelect:()=>t({...e,location:elz})}),r.map(n=>(0,eb.jsx)(elV,{label:a(n),selected:e.location===n,onSelect:()=>t({...e,location:n})},n))]}),(0,eb.jsx)(elB,{title:"排序",children:Object.keys(elL).map(n=>(0,eb.jsx)(elV,{label:elL[n],selected:e.sort===n,onSelect:()=>t({...e,sort:n})},n))}),n?(0,eb.jsx)("button",{type:"button",onClick:()=>t(elA),className:"mt-4 flex h-11 w-full items-center justify-center rounded-lg border border-border text-[15px] text-foreground/80 transition-colors hover:bg-muted hover:text-foreground",children:"重置筛选"}):null]})]})]}):(0,eb.jsxs)(wA,{children:[(0,eb.jsx)(wR,{asChild:!0,children:l}),(0,eb.jsxs)(wG,{align:"end",sideOffset:4,className:"min-w-56",children:[(0,eb.jsx)(wZ,{children:"筛选与排序"}),(0,eb.jsxs)(wK,{children:[(0,eb.jsxs)(w0,{children:[(0,eb.jsx)("span",{className:"flex-1",children:"状态"}),(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:el_[e.status]})]}),(0,eb.jsx)(w1,{children:(0,eb.jsxs)(wB,{value:e.status,onValueChange:n=>t({...e,status:n}),children:[(0,eb.jsx)(wY,{value:"all",children:"全部"}),(0,eb.jsx)(wY,{value:"running",children:"运行中"}),(0,eb.jsx)(wY,{value:"idle",children:"空闲"}),(0,eb.jsx)(wY,{value:"archived",children:"已归档"})]})})]}),(0,eb.jsxs)(wK,{children:[(0,eb.jsxs)(w0,{children:[(0,eb.jsx)("span",{className:"flex-1",children:"运行位置"}),(0,eb.jsx)("span",{className:"max-w-24 truncate text-xs text-muted-foreground",children:o})]}),(0,eb.jsx)(w1,{className:"max-h-72 overflow-y-auto",children:(0,eb.jsxs)(wB,{value:e.location,onValueChange:n=>t({...e,location:n}),children:[(0,eb.jsx)(wY,{value:elz,children:"全部"}),r.map(e=>(0,eb.jsx)(wY,{value:e,children:(0,eb.jsx)("span",{className:"truncate",children:a(e)})},e))]})})]}),(0,eb.jsx)(wJ,{}),(0,eb.jsx)(wZ,{children:"排序"}),(0,eb.jsxs)(wB,{value:e.sort,onValueChange:n=>t({...e,sort:n}),children:[(0,eb.jsx)(wY,{value:"recent",children:elL.recent}),(0,eb.jsx)(wY,{value:"name",children:elL.name})]}),n?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(wJ,{}),(0,eb.jsx)(wX,{onSelect:()=>t(elA),children:(0,eb.jsx)("span",{className:"flex-1",children:"重置筛选"})})]}):null]})]})}function elB({title:e,children:t}){return(0,eb.jsxs)("div",{className:"mb-4 last:mb-0",children:[(0,eb.jsx)("p",{className:"mb-1 px-1 text-xs font-medium text-muted-foreground",children:e}),(0,eb.jsx)("div",{className:"space-y-0.5",children:t})]})}function elV({label:e,selected:t,onSelect:n}){return(0,eb.jsxs)("button",{type:"button",role:"radio","aria-checked":t,onClick:n,className:(0,ez.cn)("flex h-11 w-full items-center gap-2 rounded-lg px-3 text-left text-[15px] transition-colors",t?"bg-muted text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground"),children:[(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e}),t?(0,eb.jsx)(h6,{className:"size-4 shrink-0 text-primary"}):null]})}function elH({engine:e}){if("vantaloom"===e)return null;let t="claude-code"===e;return(0,eb.jsxs)("span",{title:t?"Claude Code":"reclaude",className:(0,ez.cn)("relative inline-flex shrink-0 select-none items-center justify-center rounded px-1 py-px text-[9px] font-semibold leading-none tracking-wide",t?"bg-violet-500/15 text-violet-600 dark:bg-violet-400/20 dark:text-violet-300":"bg-sky-500/15 text-sky-600 dark:bg-sky-400/20 dark:text-sky-300"),children:[t?"CC":"RC",!t&&(0,eb.jsx)("span",{className:"absolute -right-0.5 -top-0.5 size-1.5 rounded-full bg-sky-400 dark:bg-sky-300"})]})}let elU=ew.memo(function({conversation:e,active:t,depth:n=0,onOpenConversation:r,onOpenConversationSettings:a,onDelete:i,onFork:o,onArchive:l,onUnarchive:s,selectionMode:c,selected:d,onToggleSelect:u}){let f=!0===e.running,m=e.settings?.engine??"vantaloom",h=!!e.projectId,p="vantaloom"!==m?(0,eb.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden",children:[(0,eb.jsx)(elH,{engine:m}),(0,eb.jsx)("span",{className:"truncate",children:e.title})]}):void 0;return(0,eb.jsx)(elq,{title:f?`${e.title} \xb7 运行中`:e.title,label:e.title,labelNode:p,active:t,running:f,depth:n,onOpen:()=>r(e.id,e.ownerMachineId),onOpenSettings:a&&!h?()=>a(e.id,e.ownerMachineId):void 0,onDelete:i?()=>i(e):void 0,onFork:o?()=>o(e):void 0,onArchive:l,onUnarchive:s,selectionMode:c,selected:d,onToggleSelect:u,deleteLabel:"删除会话"})}),elq=ew.memo(function({title:e,label:t,labelNode:n,active:r,running:a,depth:i=0,onOpen:o,onOpenSettings:l,onDelete:s,onFork:c,onArchive:d,onUnarchive:u,selectionMode:f,selected:m,onToggleSelect:h,deleteLabel:p="删除"}){let[g,x]=ew.useState(!1),v=!!h,b=!!(l||s||c||d||u),y=i>0,w=(0,eb.jsxs)(eb.Fragment,{children:[l?(0,eb.jsxs)(wS,{onSelect:()=>l(),children:[(0,eb.jsx)(era,{}),(0,eb.jsx)("span",{className:"flex-1",children:"打开设置界面"})]}):null,c?(0,eb.jsxs)(wS,{onSelect:()=>c(),children:[(0,eb.jsx)(HM,{}),(0,eb.jsx)("span",{className:"flex-1",children:"分支对话"})]}):null,d?(0,eb.jsxs)(wS,{onSelect:()=>d(),children:[(0,eb.jsx)(bX,{}),(0,eb.jsx)("span",{className:"flex-1",children:"归档"})]}):null,u?(0,eb.jsxs)(wS,{onSelect:()=>u(),children:[(0,eb.jsx)(eoG,{}),(0,eb.jsx)("span",{className:"flex-1",children:"取消归档"})]}):null,s?(0,eb.jsxs)(wS,{variant:"destructive",onSelect:()=>x(!0),children:[(0,eb.jsx)(yn,{}),(0,eb.jsx)("span",{className:"flex-1",children:p})]}):null]}),j=(0,eb.jsxs)("div",{className:(0,ez.cn)("group relative flex items-center rounded-lg text-[13px] transition-colors animate-in fade-in-0 slide-in-from-left-1 duration-200",m?"bg-primary/10 text-foreground":r?"bg-muted text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground"),style:y?{marginLeft:14*i}:void 0,children:[f&&v?(0,eb.jsx)("button",{type:"button","aria-label":m?"取消选择":"选择","aria-pressed":m,onClick:e=>{e.preventDefault(),e.stopPropagation(),h?.(e.shiftKey?"range":"toggle")},className:(0,ez.cn)("ml-2 flex size-4 shrink-0 items-center justify-center rounded border",m?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/50 bg-transparent"),children:m?(0,eb.jsx)(h6,{className:"size-3"}):null}):null,(0,eb.jsxs)("button",{type:"button",title:e,onClick:e=>{if(v&&(f||e.metaKey||e.ctrlKey||e.shiftKey)){e.preventDefault(),h?.(e.shiftKey?"range":"toggle");return}o()},className:"flex min-w-0 flex-1 items-center gap-3 rounded-lg px-3 py-2 text-left",children:[y?(0,eb.jsx)("span",{"aria-hidden":!0,className:"h-4 w-0.5 shrink-0 rounded-full bg-primary/40"}):null,a?(0,eb.jsx)("span",{className:"size-1.5 shrink-0 animate-pulse rounded-full bg-green-500","aria-label":"运行中"}):(0,eb.jsx)(elQ,{active:r}),n??(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t})]}),b&&!f?(0,eb.jsxs)(wA,{children:[(0,eb.jsx)(wR,{asChild:!0,children:(0,eb.jsx)("button",{type:"button","aria-label":"更多操作",className:"mr-1 shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity hover:bg-background/70 hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100 aria-expanded:opacity-100",children:(0,eb.jsx)(lG,{className:"size-4"})})}),(0,eb.jsxs)(wG,{align:"end",sideOffset:4,className:"min-w-44",children:[l?(0,eb.jsxs)(wX,{onSelect:()=>l(),children:[(0,eb.jsx)(era,{}),(0,eb.jsx)("span",{className:"flex-1",children:"打开设置界面"})]}):null,c?(0,eb.jsxs)(wX,{onSelect:()=>c(),children:[(0,eb.jsx)(HM,{}),(0,eb.jsx)("span",{className:"flex-1",children:"分支对话"})]}):null,d?(0,eb.jsxs)(wX,{onSelect:()=>d(),children:[(0,eb.jsx)(bX,{}),(0,eb.jsx)("span",{className:"flex-1",children:"归档"})]}):null,u?(0,eb.jsxs)(wX,{onSelect:()=>u(),children:[(0,eb.jsx)(eoG,{}),(0,eb.jsx)("span",{className:"flex-1",children:"取消归档"})]}):null,s?(0,eb.jsxs)(wX,{variant:"destructive",onSelect:()=>x(!0),children:[(0,eb.jsx)(yn,{}),(0,eb.jsx)("span",{className:"flex-1",children:p})]}):null]})]}):null]});return(0,eb.jsxs)(eb.Fragment,{children:[b?(0,eb.jsxs)(wh,{children:[(0,eb.jsx)(wg,{asChild:!0,children:j}),(0,eb.jsx)(wN,{className:"min-w-44",children:w})]}):j,s?(0,eb.jsx)(ux,{open:g,onOpenChange:x,children:(0,eb.jsxs)(uR,{children:[(0,eb.jsxs)(uD,{children:[(0,eb.jsx)(uL,{children:p}),(0,eb.jsxs)(u$,{children:["确认删除「",t,"」?此操作无法撤销。"]})]}),(0,eb.jsxs)(u_,{children:[(0,eb.jsx)(uB,{children:"取消"}),(0,eb.jsx)(uF,{variant:"destructive",onClick:()=>s(),children:"删除"})]})]})}):null]})});function elW({content:e,activeWorkspace:t,onItemSelect:n}){let r=(e?.sections??[]).flatMap(e=>e.items);return(0,eb.jsx)(jP,{className:"min-h-0 flex-1",viewportClassName:"pr-1",children:(0,eb.jsx)("div",{className:"space-y-0.5",children:r.map(e=>"preferences"===e.id?(0,eb.jsx)(elX,{activeWorkspace:t,onItemSelect:n},e.id):(0,eb.jsx)(elK,{id:e.id,icon:e.icon,label:e.label,active:e.id===t,onItemSelect:n},e.id))})})}function elK({id:e,icon:t,label:n,active:r,onItemSelect:a}){return(0,eb.jsxs)("button",{type:"button",onClick:()=>a({item:{id:e}}),className:(0,ez.cn)("flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",r?"bg-muted text-foreground [&_svg]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&_svg]:text-muted-foreground"),children:[t,(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",children:n}),r&&(0,eb.jsx)(elQ,{active:!0})]})}let elG=[{id:"model",title:"模型设置",icon:(0,eb.jsx)(uK,{}),items:[{id:"preferences-models",label:"模型",icon:(0,eb.jsx)(h3,{})},{id:"preferences-agents",label:"代理",icon:(0,eb.jsx)(uH,{})},{id:"preferences-cc-engine-config",label:"CC 引擎",icon:(0,eb.jsx)(uK,{})}]},{id:"prefs",title:"偏好设置",icon:(0,eb.jsx)(era,{}),items:[{id:"preferences-assets",label:"扩展 / 资产",icon:(0,eb.jsx)(kV,{})},{id:"preferences-layout",label:"布局排版",icon:(0,eb.jsx)(elr,{})},{id:"preferences-official-extensions",label:"官方扩展",icon:(0,eb.jsx)(qz,{})}]},{id:"system",title:"系统设置",icon:(0,eb.jsx)(Yw,{}),items:[{id:"system-general",label:"系统与账户",icon:(0,eb.jsx)(Yw,{})},{id:"network-downloads",label:"网络与下载",icon:(0,eb.jsx)(enH,{})},{id:"search-settings",label:"搜索设置",icon:(0,eb.jsx)(vu,{})}]}];function elX({activeWorkspace:e,onItemSelect:t}){return(0,eb.jsx)(eb.Fragment,{children:elG.map((n,r)=>(0,eb.jsx)("div",{className:"vtl-stagger-item",style:{animationDelay:`${25*Math.min(r,12)}ms`},children:(0,eb.jsx)(elY,{title:n.title,icon:n.icon,items:n.items,activeWorkspace:e,onItemSelect:t})},n.id))})}function elY({title:e,icon:t,items:n,activeWorkspace:r,onItemSelect:a}){let i=n.some(e=>e.id===r),[o,l]=ew.useState(!0),s=elE(o);return(0,eb.jsxs)(elm,{open:o,onOpenChange:l,children:[(0,eb.jsx)(elp,{asChild:!0,children:(0,eb.jsxs)("button",{type:"button",className:(0,ez.cn)("flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",i?"text-foreground [&>svg:first-child]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&>svg:first-child]:text-muted-foreground"),children:[t,(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e}),(0,eb.jsx)(pt,{className:(0,ez.cn)("text-muted-foreground transition-transform",o?"rotate-0":"-rotate-90")})]})}),(0,eb.jsx)(elM,{open:o,className:"mt-0.5",children:(0,eb.jsx)("div",{className:"space-y-0.5",children:n.map((e,t)=>{let n=e.id===r;return(0,eb.jsxs)("button",{type:"button",onClick:()=>a({item:{id:e.id}}),style:{animationDelay:`${25*Math.min(t,12)}ms`},className:(0,ez.cn)("vtl-stagger-item flex w-full items-center gap-3 rounded-lg py-2 pl-9 pr-3 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",n?"bg-muted text-foreground [&_svg]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&_svg]:text-muted-foreground"),children:[e.icon,(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.label}),n&&(0,eb.jsx)(elQ,{active:!0})]},e.id)})},s)})]})}let elZ=ew.forwardRef(function({icon:e,label:t,onClick:n,...r},a){return(0,eb.jsxs)("button",{ref:a,type:"button",onClick:n,className:"flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm text-foreground transition-colors hover:bg-muted",...r,children:[(0,eb.jsx)(e,{className:"size-4 shrink-0 text-muted-foreground"}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t})]})});function elJ(){return(0,eb.jsxs)("div",{className:"flex items-center justify-center gap-2 px-3 py-3 text-[13px] text-muted-foreground/70",role:"status","aria-live":"polite",children:[(0,eb.jsx)(eM,{className:"size-4 animate-spin"}),(0,eb.jsx)("span",{children:"加载中…"})]})}function elQ({active:e}){return(0,eb.jsx)("span",{className:(0,ez.cn)("size-1.5 shrink-0 rounded-full",e?"bg-primary":"border border-muted-foreground/50 bg-transparent")})}function el0({onItemSelect:e,onAccountSettings:t}){let{user:n}=ti(),r=n?.name??en2.product,a=(n?.name??"V").slice(0,1).toUpperCase();return(0,eb.jsx)("div",{className:"mt-auto pt-3",children:(0,eb.jsxs)(wA,{children:[(0,eb.jsx)(wR,{asChild:!0,children:(0,eb.jsxs)("button",{type:"button","data-tour":"account-button",className:"flex w-full items-center justify-between rounded-xl p-2 transition-colors hover:bg-muted",children:[(0,eb.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,eb.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full border border-border/60 bg-muted text-[10px] font-semibold text-foreground",children:a}),(0,eb.jsx)("span",{className:"truncate text-sm text-foreground",children:r})]}),(0,eb.jsx)(h7,{className:"size-4 shrink-0 -rotate-90 text-muted-foreground"})]})}),(0,eb.jsxs)(wG,{side:"top",align:"start",sideOffset:8,className:"w-[var(--radix-dropdown-menu-trigger-width)] min-w-60",children:[n?.email&&(0,eb.jsx)(wZ,{className:"truncate font-normal text-muted-foreground",children:n.email}),(0,eb.jsxs)(wX,{onSelect:()=>e({item:{id:"preferences"}}),children:[(0,eb.jsx)(era,{}),(0,eb.jsx)("span",{className:"flex-1",children:"设置"}),(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:"Ctrl,"})]}),(0,eb.jsxs)(wX,{disabled:!0,children:[(0,eb.jsx)(eln,{}),(0,eb.jsx)("span",{className:"flex-1",children:"语言"}),(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:"中文"})]}),(0,eb.jsxs)(wX,{disabled:!0,children:[(0,eb.jsx)(qx,{}),(0,eb.jsx)("span",{className:"flex-1",children:"获取帮助"})]}),(0,eb.jsx)(wJ,{}),(0,eb.jsxs)(wX,{onSelect:()=>{t?t():e({item:{id:"account"}})},children:[(0,eb.jsx)(Xb,{}),(0,eb.jsx)("span",{className:"flex-1",children:"Hub 账户"})]}),(0,eb.jsx)(el2,{}),n&&(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(wJ,{}),(0,eb.jsx)(el5,{})]})]})]})})}let el1=["light","dark","jelly"];function el2(){let{resolvedTheme:e,setTheme:t}=(0,m1.useTheme)(),[n,r]=ew.useState(elb.defaultAppearanceTheme);ew.useEffect(()=>{let e=window.localStorage.getItem(elb.appearanceThemeStorageKey)??elb.defaultAppearanceTheme;r(e),(0,elb.applyAppearanceTheme)({theme:e})},[]);let a=n===elb.jellyAppearanceTheme?"jelly":"dark"===e?"dark":"light",i=el1[(el1.indexOf(a)+1)%el1.length]??"light";function o(e){r(e),window.localStorage.setItem(elb.appearanceThemeStorageKey,e),(0,elb.applyAppearanceTheme)({theme:e})}let l="dark"===a?eli:ell;return(0,eb.jsxs)(wX,{onSelect:e=>{e.preventDefault(),function(){if("jelly"===i){t("dark"),o(elb.jellyAppearanceTheme);return}o(elb.defaultAppearanceTheme),t(i)}()},children:[(0,eb.jsx)(l,{}),(0,eb.jsx)("span",{className:"flex-1",children:en2.theme}),(0,eb.jsx)("span",{className:"text-xs capitalize text-muted-foreground",children:a})]})}function el5(){let{logout:e}=ti();return(0,eb.jsxs)(wX,{variant:"destructive",onSelect:()=>{e().then(()=>{window.location.reload()})},children:[(0,eb.jsx)(ela,{}),(0,eb.jsx)("span",{className:"flex-1",children:"退出登录"})]})}function el4({navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,activeProjectId:a,onItemSelect:i,onOpenConversation:o,onOpenProjectCanvas:l,onOpenProjectOverview:s,onOpenProjectKanban:c,onOpenProjectSettings:d,onNewProjectConversation:u,onOpenProjectConversation:f,onNewProject:m,onOpenConversationSettings:h,onConversationDeleted:p,onAccountSettings:g,subagentTree:x,activeSubagentPath:v,onOpenSubagent:b,title:y,trailing:w,children:j}){let[k,N]=ew.useState(!1),S=ew.useCallback(()=>N(!1),[]),C=ew.useCallback(e=>{S(),i(e)},[S,i]),M=ew.useCallback((e,t)=>{S(),o(e,t)},[S,o]),E=ew.useCallback(e=>{S(),b?.(e)},[S,b]);return(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(el3,{onMenuClick:()=>N(!0),title:y,trailing:w}),(0,eb.jsx)(x5,{open:k,onOpenChange:N,direction:"left",children:(0,eb.jsxs)(x3,{className:"w-[85vw] max-w-xs",children:[(0,eb.jsx)(x8,{className:"sr-only",children:"导航"}),(0,eb.jsx)(elS,{hideCanvas:!0,navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,activeProjectId:a,onItemSelect:C,onOpenConversation:M,onOpenCanvas:()=>{},onOpenProjectCanvas:(e,t)=>{S(),l?.(e,t)},onOpenProjectOverview:e=>{S(),s?.(e)},onOpenProjectKanban:e=>{S(),c?.(e)},onOpenProjectSettings:e=>{S(),d?.(e)},onNewProjectConversation:e=>{S(),u?.(e)},onOpenProjectConversation:(e,t,n)=>{S(),f?.(e,t,n)},onNewProject:()=>{S(),m?.()},onOpenConversationSettings:(e,t)=>{S(),h?.(e,t)},onConversationDeleted:p,onAccountSettings:()=>{S(),g?.()},subagentTree:x,activeSubagentPath:v,onOpenSubagent:E,className:"h-full w-full rounded-none border-0 p-3 pt-[max(0.75rem,env(safe-area-inset-top))] shadow-none"})]})}),(0,eb.jsx)(etu,{value:()=>N(!0),children:j})]})}function el3({onMenuClick:e,title:t,trailing:n,className:r}){return(0,eb.jsxs)("header",{className:(0,ez.cn)("fixed inset-x-0 top-0 z-40 flex h-12 items-center gap-1 border-b border-border bg-sidebar/95 px-1.5 pt-[env(safe-area-inset-top)] backdrop-blur",r),style:{height:"calc(3rem + env(safe-area-inset-top))"},children:[(0,eb.jsx)("button",{type:"button","aria-label":"展开导航",onClick:e,className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-foreground/80 transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-5",children:(0,eb.jsx)(cy,{})}),t?(0,eb.jsx)("div",{className:"min-w-0 flex-1 truncate text-center text-sm font-medium text-foreground",children:t}):(0,eb.jsx)("div",{className:"min-w-0 flex-1"}),(0,eb.jsx)("div",{className:"flex shrink-0 items-center",children:n})]})}let el6=(0,ek.default)("message-square-text",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]),el8=[{id:"canvas",label:en5.canvas,icon:(0,eb.jsx)(uU,{})},{id:"agent",label:"智能体",icon:(0,eb.jsx)(uH,{})},{id:"settings",label:en5.settings,icon:(0,eb.jsx)(era,{})}],el7=[{id:"canvas",title:en5.canvas,description:"节点画布工作区。",sections:[{id:"canvases",title:en5.canvas,items:[{id:"open-recent-canvas",label:en5.canvasRecent,icon:(0,eb.jsx)(uU,{})},{id:"new-canvas",label:en5.canvasNew,icon:(0,eb.jsx)(lY,{})},{id:"all-canvases",label:en5.canvasAll,icon:(0,eb.jsx)(uG,{})}]}]},{id:"agent",title:"智能体",description:"Agent 对话工作区。",sections:[{id:"conversations",title:"Agent 对话",items:[{id:"open-recent-conversation",label:en5.conversationRecent,icon:(0,eb.jsx)(el6,{})},{id:"new-agent-conversation",label:en5.conversationNew,icon:(0,eb.jsx)(uH,{})}]}]},{id:"settings",title:en5.settings,description:"系统、工作组和用量配置。",sections:[{id:"settings",items:[{id:"preferences",label:"设置",icon:(0,eb.jsx)(era,{})}]}]}],el9=(0,ek.default)("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]),ese=(0,ek.default)("unplug",[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]]),est=(0,ek.default)("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]),esn=(0,ek.default)("wifi-off",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);function esr(){return(0,eb.jsx)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:(0,eb.jsx)(esa,{})})})}function esa(){let{user:e,machine:t,logout:n,unbind:r,refreshUser:a}=ti(),[i,o]=ew.useState(!1),[l,s]=ew.useState(!1),[c,d]=ew.useState(t),[u,f]=ew.useState(!1),[m,h]=ew.useState(""),[p,g]=ew.useState(!1),[x,v]=ew.useState(null);async function b(){o(!0);try{await eY("online");let e=eH();d(e),await a()}catch{}finally{o(!1)}}async function y(){let e=m.trim();if(!e)return void v("名称不能为空");g(!0),v(null);try{let t=await eJ(e);d(e=>e?{...e,name:t}:e),f(!1)}catch(e){v(e instanceof Error?e.message:"重命名失败")}finally{g(!1)}}async function w(){s(!0);try{await r()}catch{s(!1)}}async function j(){await n()}return ew.useEffect(()=>{d(t)},[t]),e?(0,eb.jsxs)("div",{className:"grid gap-6 text-foreground","data-tour":"hub-account",children:[(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"账户信息"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"你的 Vantaloom Hub 账户详情。"}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,eb.jsx)("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-full bg-primary/10",children:(0,eb.jsx)("span",{className:"text-base font-semibold text-primary",children:e.name.charAt(0).toUpperCase()})}),(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("p",{className:"truncate text-sm font-medium",children:e.name}),(0,eb.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:e.email})]})]}),(0,eb.jsxs)(Vp,{variant:"outline",className:"shrink-0",children:[(0,eb.jsx)(kB,{className:"mr-1 size-3"}),"已验证"]})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)("span",{className:"text-sm text-muted-foreground",children:"用户 ID"}),(0,eb.jsxs)("code",{className:"rounded bg-muted px-2 py-0.5 font-mono text-xs",children:[e.id.slice(0,8),"..."]})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)("span",{className:"text-sm text-muted-foreground",children:"注册时间"}),(0,eb.jsx)("span",{className:"text-sm",children:new Date(e.createdAt).toLocaleDateString("zh-CN")})]})]}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"设备绑定"}),(0,eb.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"此设备已自动注册到你的 Hub 账户。"})]}),c?(0,eb.jsxs)(eO.Button,{variant:"outline",size:"sm",className:"shrink-0",onClick:b,disabled:i,children:[i?(0,eb.jsx)(eM,{className:"animate-spin"}):(0,eb.jsx)(yt,{}),i?"刷新中...":"刷新状态"]}):null]}),c?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,eb.jsxs)("div",{className:"min-w-0 flex-1",children:[u?(0,eb.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,eb.jsx)(eA,{value:m,onChange:e=>h(e.target.value),maxLength:64,autoFocus:!0,placeholder:"机器名称",className:"h-8 text-sm",onKeyDown:e=>{"Enter"===e.key&&y(),"Escape"===e.key&&f(!1)}}),(0,eb.jsx)(eO.Button,{size:"icon-sm",variant:"ghost",className:"size-8 shrink-0",onClick:()=>void y(),disabled:p,"aria-label":"保存名称",children:p?(0,eb.jsx)(eM,{className:"animate-spin"}):(0,eb.jsx)(h6,{})}),(0,eb.jsx)(eO.Button,{size:"icon-sm",variant:"ghost",className:"size-8 shrink-0",onClick:()=>f(!1),disabled:p,"aria-label":"取消",children:(0,eb.jsx)(fV.XIcon,{})})]}):(0,eb.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,eb.jsx)("p",{className:"truncate text-sm font-medium",children:c.name}),(0,eb.jsx)("button",{type:"button",onClick:function(){h(c?.name??""),v(null),f(!0)},title:"重命名",className:"shrink-0 rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:(0,eb.jsx)(UH,{className:"size-3.5"})})]}),(0,eb.jsxs)("p",{className:"truncate text-xs text-muted-foreground",children:[c.platform," / ",c.arch]})]}),(0,eb.jsxs)(Vp,{variant:"online"===c.status?"default":"secondary",className:"shrink-0 gap-1",children:["online"===c.status?(0,eb.jsx)(est,{className:"size-3"}):(0,eb.jsx)(esn,{className:"size-3"}),"online"===c.status?"在线":"离线"]})]}),x?(0,eb.jsx)("p",{className:"text-xs text-destructive",children:x}):null,(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)("span",{className:"text-sm text-muted-foreground",children:"设备 ID"}),(0,eb.jsxs)("code",{className:"rounded bg-muted px-2 py-0.5 font-mono text-xs",children:[c.id.slice(0,8),"..."]})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)("span",{className:"text-sm text-muted-foreground",children:"连接方式"}),(0,eb.jsx)("span",{className:"text-sm",children:c.connectivity||"直连"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)("span",{className:"text-sm text-muted-foreground",children:"本机 IP"}),(0,eb.jsx)("code",{className:"rounded bg-muted px-2 py-0.5 font-mono text-xs",children:c.localIp})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)("span",{className:"text-sm text-muted-foreground",children:"最后心跳"}),(0,eb.jsx)("span",{className:"text-sm",children:new Date(c.lastHeartbeat).toLocaleString("zh-CN")})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)("span",{className:"text-sm text-muted-foreground",children:"注册时间"}),(0,eb.jsx)("span",{className:"text-sm",children:new Date(c.createdAt).toLocaleString("zh-CN")})]})]}):(0,eb.jsxs)("div",{className:"flex flex-col items-center gap-3 py-6 text-center",children:[(0,eb.jsx)(esn,{className:"size-8 text-muted-foreground/40"}),(0,eb.jsxs)("div",{children:[(0,eb.jsx)("p",{className:"text-sm font-medium",children:"设备未绑定"}),(0,eb.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"设备注册异常,请尝试重新登录"})]})]})]}),(0,eb.jsx)(esi,{}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"hub-account-danger",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold text-destructive",children:"危险操作"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"以下操作不可逆,请谨慎执行。"}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("p",{className:"text-sm font-medium",children:"解除设备绑定"}),(0,eb.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"将此设备从你的 Hub 账户中移除,并退出登录。设备数据不会受到影响。"})]}),(0,eb.jsxs)(ux,{children:[(0,eb.jsx)(uv,{asChild:!0,children:(0,eb.jsxs)(eO.Button,{variant:"destructive",size:"sm",className:"shrink-0",children:[(0,eb.jsx)(ese,{}),"解除绑定"]})}),(0,eb.jsxs)(uR,{children:[(0,eb.jsxs)(uD,{children:[(0,eb.jsx)(uL,{children:"确认解除设备绑定?"}),(0,eb.jsx)(u$,{children:"此操作将从你的 Hub 账户中移除当前设备,并退出登录。你可以随时重新登录并绑定设备。"})]}),(0,eb.jsxs)(u_,{children:[(0,eb.jsx)(uB,{children:"取消"}),(0,eb.jsx)(uF,{onClick:w,disabled:l,className:"bg-destructive text-white hover:bg-destructive/90",children:l?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(eM,{className:"animate-spin"}),"处理中..."]}):"确认解除"})]})]})]})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("p",{className:"text-sm font-medium",children:"退出登录"}),(0,eb.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"退出当前 Hub 账户但保留设备在云端的注册。下次登录时无需重新绑定。"})]}),(0,eb.jsxs)(eO.Button,{variant:"outline",size:"sm",className:"shrink-0",onClick:j,children:[(0,eb.jsx)(ela,{}),"退出登录"]})]})]})]}):null}function esi(){let[e,t]=ew.useState(""),[n,r]=ew.useState(""),[a,i]=ew.useState(""),[o,l]=ew.useState(!1),[s,c]=ew.useState(null);async function d(){if(c(null),n.length<8)return void c({kind:"err",text:"新密码至少 8 位"});if(n!==a)return void c({kind:"err",text:"两次输入的新密码不一致"});l(!0);try{await eQ(e,n),c({kind:"ok",text:"密码已更新"}),t(""),r(""),i("")}catch(e){c({kind:"err",text:e instanceof Error?e.message:"修改失败,请重试"})}finally{l(!1)}}return(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)(el9,{className:"size-4 text-muted-foreground"}),(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"修改密码"})]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"更改你的 Vantaloom Hub 登录密码。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(eA,{type:"password",placeholder:"当前密码",autoComplete:"current-password",value:e,onChange:e=>t(e.target.value)}),(0,eb.jsx)(eA,{type:"password",placeholder:"新密码(至少 8 位)",autoComplete:"new-password",value:n,onChange:e=>r(e.target.value)}),(0,eb.jsx)(eA,{type:"password",placeholder:"确认新密码",autoComplete:"new-password",value:a,onChange:e=>i(e.target.value)})]}),s?(0,eb.jsx)("p",{className:"ok"===s.kind?"text-xs text-primary":"text-xs text-destructive",children:s.text}):null,(0,eb.jsx)("div",{className:"flex justify-end",children:(0,eb.jsx)(eO.Button,{size:"sm",onClick:d,disabled:o||!e||!n,children:o?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(eM,{className:"animate-spin"}),"保存中..."]}):"更新密码"})})]})}let eso=[1e4,3e4,12e4,3e5,6e5];function esl(e){return{compression:{...e.compression},summary:{...e.summary},approval:{...e.approval},behavior:{maxToolCalls:e.behavior?.maxToolCalls??0,retryCount:e.behavior?.retryCount??0,retryDelaysMs:e.behavior?.retryDelaysMs??[],loopMaxIterations:e.behavior?.loopMaxIterations??25,loopHookWait:e.behavior?.loopHookWait??"defer",loopHookWaitTimeoutSec:e.behavior?.loopHookWaitTimeoutSec??0}}}function ess(e){return(e&&e.length?e:eso).map(e=>Math.round(e/1e3)).join(", ")}function esc(){let[e,t]=ew.useState(null),[n,r]=ew.useState([]),[a,i]=ew.useState(!0),[o,l]=ew.useState(!1),[s,c]=ew.useState(""),[d,u]=ew.useState(!1),[f,m]=ew.useState(null),h=ew.useRef(null),[p,g]=ew.useState(""),[x,v]=ew.useState("context");function b(e,n){t(t=>t?{...t,[e]:{...t[e],...n}}:t),u(!0),m(null)}async function y(){if(e&&!o){l(!0),c("");try{let n=await ks({compression:e.compression,summary:e.summary,approval:e.approval,behavior:e.behavior});h.current=n,t(esl(n)),g(ess(n.behavior?.retryDelaysMs)),u(!1),m(Date.now())}catch(e){c(e instanceof Error?e.message:"Save failed")}finally{l(!1)}}}if(ew.useEffect(()=>{!async function(){try{let[e,n]=await Promise.all([kl(),vE()]);h.current=e,t(esl(e)),g(ess(e.behavior?.retryDelaysMs)),r(n.models)}catch(e){c(e instanceof Error?e.message:"Failed to load config")}finally{i(!1)}}()},[]),a)return(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取代理配置"});if(!e)return(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"读取失败"}),(0,eb.jsx)(etJ,{children:s||"无法加载代理配置"})]});let w=s?(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"错误"}),(0,eb.jsx)(etJ,{children:s})]}):null,j=(0,eb.jsxs)("div",{className:"mx-auto grid w-full max-w-2xl gap-6",children:[(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-compression",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"压缩上下文"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"当对话 token 达到模型上下文窗口的指定百分比时自动压缩。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"自动压缩阈值"}),(0,eb.jsxs)("span",{className:"text-sm tabular-nums text-muted-foreground",children:[e.compression.autoThresholdPercent,"%"]})]}),(0,eb.jsx)(enx,{value:[e.compression.autoThresholdPercent],onValueChange:([e])=>b("compression",{autoThresholdPercent:e}),min:0,max:100,step:5}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"0% 表示禁用自动压缩。建议设为 70%-85%。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"压缩模型"}),(0,eb.jsx)(esd,{models:n,value:e.compression.modelRef,onValueChange:e=>b("compression",{modelRef:e}),placeholder:"使用主模型"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"用于执行上下文压缩的模型。留空则使用当前对话主模型。"})]})]}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-summary",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"对话摘要"}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"对话标题摘要"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"每轮对话结束后自动更新对话标题。"})]}),(0,eb.jsx)(bG,{checked:e.summary.enableTitleSummary,onCheckedChange:e=>b("summary",{enableTitleSummary:e})})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"轮次标题摘要"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"为每轮 agent 操作生成摘要标题。"})]}),(0,eb.jsx)(bG,{checked:e.summary.enableRoundSummary,onCheckedChange:e=>b("summary",{enableRoundSummary:e})})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"摘要模型"}),(0,eb.jsx)(esd,{models:n,value:e.summary.modelRef,onValueChange:e=>b("summary",{modelRef:e}),placeholder:"使用主模型"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"用于生成对话摘要的模型。留空则使用当前对话主模型。"})]})]})]}),k=(0,eb.jsxs)("div",{className:"mx-auto grid w-full max-w-2xl gap-6",children:[(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"自动重试与工具调用上限"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"控制本机(vantaloom)agent 单次运行的工具调用上限,以及请求失败后的自动重试。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"最大工具调用次数"}),(0,eb.jsx)(eA,{type:"number",min:0,value:e.behavior.maxToolCalls,onChange:e=>b("behavior",{maxToolCalls:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"单次运行累计调用工具达到该次数后强制暂停(可点击“继续”恢复)。设为 0 表示不限次(默认)。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"自动重试次数"}),(0,eb.jsx)(eA,{type:"number",min:0,value:e.behavior.retryCount,onChange:e=>b("behavior",{retryCount:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"模型/服务商请求失败时自动重试的次数(仅在尚未产出内容时重试,避免重复输出)。设为 0 表示不重试。"})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"重试间隔梯度(秒)"}),(0,eb.jsx)(eA,{value:p,onChange:e=>{let t=e.currentTarget.value;g(t),b("behavior",{retryDelaysMs:t.split(/[,,\s]+/).map(e=>Number.parseInt(e.trim(),10)).filter(e=>Number.isFinite(e)&&e>0).map(e=>1e3*e)})},placeholder:"10, 30, 120, 300, 600"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"用逗号分隔每次重试的等待秒数(指数级递增),例如 10, 30, 120, 300, 600。超出列表长度时使用最后一项。留空使用内置默认梯度。"})]})]}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"循环模式"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"开启循环模式后,每轮运行结束会自动注入“继续”并续跑,直到执行树中没有未完成(且未阻塞)的任务。以下设置控制其自动续跑的上限与遇到钩子时的处理方式。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"最大循环次数"}),(0,eb.jsx)(eA,{type:"number",min:1,value:e.behavior.loopMaxIterations,onChange:e=>b("behavior",{loopMaxIterations:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"连续自动续跑达到该次数后强制暂停以避免无限计费(发送新消息可继续)。设为 0 表示使用内置默认值(25)。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"钩子处理"}),(0,eb.jsx)(x7,{value:e.behavior.loopHookWait??"defer",onValueChange:e=>b("behavior",{loopHookWait:"wait"===e?"wait":"defer"}),title:"钩子处理",className:"w-full",options:[{value:"defer",label:"有钩子运行时暂停"},{value:"wait",label:"等待钩子完成后继续"}]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"当存在会自动唤醒本对话的钩子(如进程退出、定时器)时:选择“暂停”则交由钩子驱动;选择“等待”则等钩子完成后再继续循环。"})]}),"wait"===e.behavior.loopHookWait?(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"等待超时(秒,0 = 直到无钩子)"}),(0,eb.jsx)(eA,{type:"number",min:0,value:e.behavior.loopHookWaitTimeoutSec??0,onChange:e=>b("behavior",{loopHookWaitTimeoutSec:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"在“等待”模式下,最多等待多少秒后无论钩子是否完成都继续。设为 0 表示一直等到没有钩子在运行(仍受 30 分钟的硬性上限约束)。"})]}):null]})]}),N=(0,eb.jsx)("div",{className:"mx-auto grid w-full max-w-2xl gap-6",children:(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-approval",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"命令审批"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"在 Auto 权限模式下,使用 AI 模型审批 Agent 发起的命令是否可以自动执行。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"审批模型"}),(0,eb.jsx)(esd,{models:n,value:e.approval.modelRef,onValueChange:e=>b("approval",{modelRef:e}),placeholder:"未配置(全部放行)"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"留空表示 Auto 模式下不进行 AI 审批,所有非危险命令自动放行。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"审批提示词"}),(0,eb.jsx)(w2,{value:e.approval.prompt,onChange:e=>b("approval",{prompt:e.currentTarget.value}),placeholder:"可选:给审批模型的额外指导,例如允许哪些操作、拒绝哪些操作",rows:4,className:"resize-none text-sm"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"与系统提示词一起发送给审批模型,帮助它判断命令是否安全。"})]})]})});return(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex flex-col gap-0.5 border-b px-4 py-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(uH,{}),"代理配置"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:"代理配置"})]}),w?(0,eb.jsx)("div",{className:"px-4 pt-4 md:px-5",children:w}):null,(0,eb.jsx)(etm,{sections:[{id:"context",title:"上下文",icon:(0,eb.jsx)(k$,{}),content:j},{id:"behavior",title:"运行行为",icon:(0,eb.jsx)(enW,{}),content:k},{id:"approval",title:"命令审批",icon:(0,eb.jsx)(kB,{}),content:N}],sectionId:x,onSelectionChange:({sectionId:e})=>{e&&v(e)},defaultSectionId:"context",labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto pb-28"}),(0,eb.jsx)(env,{dirty:d,saving:o,savedAt:f,onSave:()=>void y(),onReset:function(){h.current&&(t(esl(h.current)),g(ess(h.current.behavior?.retryDelaysMs)),u(!1),c(""))}})]})}function esd({models:e,value:t,onValueChange:n,placeholder:r}){return(0,eb.jsx)(x7,{value:t||"__none__",onValueChange:e=>n("__none__"===e?"":e),placeholder:r,title:"选择模型",className:"w-full",options:[{value:"__none__",label:r},...e.map(e=>({value:e.id,label:e.label}))]})}let esu=(0,ek.default)("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]),esf=(0,ek.default)("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]),esm=(0,ek.default)("log-in",[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]]),esh=(0,ek.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),esp={vantaloom:"Vantaloom","claude-code":"Claude Code",reclaude:"reclaude"},esg={idle:"","installing-node":"正在安装 Node.js…","installing-bridge":"正在安装 SDK 桥…",done:"安装完成",error:"安装失败"};function esx(e){return{...e.claudeCode??{}}}function esv(e,t){if(e.reclaudeExecutable)return e;let n=t.find(e=>"reclaude"===e.engine);return n?.available&&n.detail?{...e,reclaudeExecutable:n.detail}:e}function esb(){let[e,t]=ew.useState(null),[n,r]=ew.useState([]),[a,i]=ew.useState([]),[o,l]=ew.useState(!0),[s,c]=ew.useState(!1),[d,u]=ew.useState(null),f=ew.useRef(!1),[m,h]=ew.useState(""),[p,g]=ew.useState(!1),[x,v]=ew.useState(null),b=ew.useRef(null),[y,w]=ew.useState(null),[j,k]=ew.useState("idle"),[N,S]=ew.useState(""),[C,M]=ew.useState(""),E=ew.useRef(!1),[I,P]=ew.useState("engines");async function O(){if(!f.current){f.current=!0;try{for(;f.current;){let e;if(await new Promise(e=>setTimeout(e,1500)),!f.current)break;try{e=await kf()}catch{continue}if(u(e.status),!kd(e.status.phase)){if(e.engines){let n=e.engines;r(n),t(e=>{if(!e)return e;let t=esv(e,n);return p||(b.current=t),t})}"error"===e.status.phase&&h(e.status.error||"适配器安装失败");break}}}finally{f.current=!1}}}async function z(){try{let[e,t]=await Promise.all([km(),kc()]);w(e),r(t.engines??[])}catch{}}async function A(){if("starting"!==j&&"awaiting"!==j){k("starting"),M(""),S(""),E.current=!1;try{let{authUrl:e,state:t}=await kh();if(S(e),e)try{window.open(e,"_blank","noopener,noreferrer")}catch{}k("awaiting");let n=Date.now()+6e5;for(;!E.current&&Date.now()<n;){let e;if(await new Promise(e=>setTimeout(e,2e3)),E.current)return;try{e=await kp(t)}catch(e){k("error"),M(e instanceof Error?e.message:"登录失败");return}if("approved"===e.status){k("idle"),await z();return}if("error"===e.status){k("error"),M(e.error||"授权失败");return}}E.current||(k("error"),M("登录超时,请重试"))}catch(e){k("error"),M(e instanceof Error?e.message:"登录失败")}}}async function T(){try{await kg()}catch{}await z()}async function R(){if(!_){h("");try{let e=await ku();e.status&&u(e.status)}catch{}O()}}function D(e){t(t=>t?{...t,...e}:t),g(!0),v(null)}ew.useEffect(()=>{!async function(){try{let[e,n,a,o,l]=await Promise.all([kl(),kc(),vE(),km().catch(()=>null),kf().catch(()=>null)]),s=n.engines??[],c=esv(esx(e),s);b.current=c,t(c),r(s),i(a.models),w(o),l?.status&&(u(l.status),kd(l.status.phase)&&O())}catch(e){h(e instanceof Error?e.message:"Failed to load config")}finally{l(!1)}}()},[]),ew.useEffect(()=>()=>{E.current=!0,f.current=!1},[]);let _=kd(d?.phase),L=e?.adapterArgs?.[0]??"",$=!!(y?.loggedIn||n.find(e=>"reclaude"===e.engine)?.available||e?.reclaudeExecutable);async function F(){if(e&&!s){c(!0),h("");try{let n=await ks({claudeCode:e}),r=esx(n);b.current=r,t(r),g(!1),v(Date.now())}catch(e){h(e instanceof Error?e.message:"Save failed")}finally{c(!1)}}}if(o)return(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取引擎配置"});if(!e)return(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"读取失败"}),(0,eb.jsx)(etJ,{children:m||"无法加载引擎配置"})]});let B=(0,eb.jsxs)("section",{className:"grid w-full gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"检测到的引擎"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"本机当前可用的 Agent 运行引擎。不可用的引擎会说明原因。"})]}),(0,eb.jsxs)(eO.Button,{type:"button",variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void R(),disabled:_,children:[_?(0,eb.jsx)(eM,{className:"size-4 animate-spin"}):(0,eb.jsx)(bJ,{className:"size-4"}),_?esg[d?.phase??"installing-bridge"]||"安装中…":"下载/安装 SDK 桥"]})]}),d&&"idle"!==d.phase?(0,eb.jsxs)("div",{className:"grid gap-1.5 rounded-md border bg-background p-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:[_?(0,eb.jsx)(eM,{className:"size-3.5 animate-spin text-muted-foreground"}):"done"===d.phase?(0,eb.jsx)(eI,{className:"size-3.5 text-emerald-600 dark:text-emerald-400"}):(0,eb.jsx)(esh,{className:"size-3.5 text-destructive"}),(0,eb.jsx)("span",{children:esg[d.phase]||d.phase})]}),d.lines.length>0?(0,eb.jsx)("pre",{className:"max-h-32 overflow-auto rounded bg-muted/50 px-2 py-1.5 text-[11px] leading-relaxed text-muted-foreground",children:d.lines.slice(-12).join("\n")}):null]}):null,(0,eb.jsx)("p",{className:"text-xs text-muted-foreground/80",children:"Claude Code / reclaude 通过内置的 Claude SDK 桥(@anthropic-ai/claude-agent-sdk)运行。 运行时通常已自带它;若显示缺失,点击上方按钮即可在后台静默下载安装,无需手填路径即可使用。"}),(0,eb.jsx)("div",{className:"grid gap-2",children:0===n.length?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"未检测到引擎信息。"}):n.map(e=>(0,eb.jsxs)("div",{className:"grid gap-1 rounded-md border bg-background p-3",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,eb.jsx)("span",{className:"text-sm font-medium",children:esp[e.engine]??e.engine}),(0,eb.jsxs)("span",{className:(0,ez.cn)("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium [&_svg]:size-3",e.available?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"bg-destructive/10 text-destructive"),children:[e.available?(0,eb.jsx)(eI,{}):(0,eb.jsx)(esh,{}),e.available?"可用":"不可用"]})]}),e.reason?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:e.reason}):null,e.detail?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground/80",children:e.detail}):null]},e.engine))})]}),V=(0,eb.jsxs)("section",{className:"grid w-full gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"reclaude 账户"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"在 Vantaloom 内直接登录 reclaude(recode.cat)。登录后 reclaude 引擎无需安装外部 reclaude / Claude Code 即可使用——本机通过内置签名代理访问 reclaude 网关,由 reclaude 托管账号并代理网络。"})]}),y?.loggedIn?(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-md border bg-background p-3",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-sm font-medium",children:[(0,eb.jsx)(eI,{className:"size-4 text-emerald-600 dark:text-emerald-400"}),"已登录"]}),(0,eb.jsxs)("p",{className:"truncate text-xs text-muted-foreground",children:[y.email||"已连接",y.gatewayUrl?` \xb7 ${y.gatewayUrl}`:""]})]}),(0,eb.jsxs)(eO.Button,{type:"button",variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void T(),children:[(0,eb.jsx)(ela,{className:"size-4"}),"注销"]})]}):(0,eb.jsxs)("div",{className:"grid gap-2",children:["awaiting"===j?(0,eb.jsxs)(etY,{children:[(0,eb.jsx)(eM,{className:"animate-spin"}),(0,eb.jsx)(etZ,{children:"等待浏览器授权…"}),(0,eb.jsxs)(etJ,{children:["已打开授权页面,请在浏览器中完成 reclaude 登录授权;完成后这里会自动更新。",N?(0,eb.jsxs)("a",{href:N,target:"_blank",rel:"noopener noreferrer",className:"mt-1 inline-flex items-center gap-1 underline",children:[(0,eb.jsx)(esu,{className:"size-3"}),"重新打开授权页面"]}):null]})]}):null,"error"===j&&C?(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"登录失败"}),(0,eb.jsx)(etJ,{children:C})]}):null,(0,eb.jsx)("div",{className:"flex items-center gap-2",children:"awaiting"===j?(0,eb.jsx)(eO.Button,{type:"button",variant:"outline",size:"sm",onClick:function(){E.current=!0,k("idle")},children:"取消"}):(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",disabled:"starting"===j,onClick:()=>void A(),children:["starting"===j?(0,eb.jsx)(eM,{className:"size-4 animate-spin"}):(0,eb.jsx)(esm,{className:"size-4"}),"starting"===j?"正在发起…":"登录 reclaude"]})})]})]}),H=(0,eb.jsx)("section",{className:"w-full rounded-lg border bg-card p-4",children:(0,eb.jsxs)("div",{className:"grid gap-4 text-foreground",children:[(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"Node 可执行文件"}),(0,eb.jsx)(eA,{value:e.adapterCommand??"",onChange:e=>D({adapterCommand:e.currentTarget.value}),placeholder:"node"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"运行 SDK 桥的 Node 可执行文件。留空则自动发现(或使用 node)。"})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"SDK 桥脚本路径 (…/adapters/claude-sdk-bridge/index.mjs)"}),(0,eb.jsx)(eA,{value:L,onChange:e=>{let t=e.currentTarget.value;D({adapterArgs:t?[t]:[]})},placeholder:"…/adapters/claude-sdk-bridge/index.mjs"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"留空则自动发现(随运行时安装,或环境变量 VANTALOOM_CC_SDK_BRIDGE)。"})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"Git Bash 路径"}),(0,eb.jsx)(eA,{value:e.gitBashPath??"",onChange:e=>D({gitBashPath:e.currentTarget.value}),placeholder:"C:\\\\Program Files\\\\Git\\\\bin\\\\bash.exe"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"Windows 专用,留空自动发现。"})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"reclaude 可执行文件"}),(0,eb.jsx)(eA,{value:e.reclaudeExecutable??"",onChange:e=>D({reclaudeExecutable:e.currentTarget.value}),placeholder:"reclaude"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"仅作回退:未在上方登录 reclaude 时,engine=reclaude 会改用此外部 reclaude 可执行文件作为 claude 启动。已在上方登录则无需填写。自动发现到 reclaude 时会自动填入。"})]})]})}),U=(0,eb.jsx)("section",{className:"w-full rounded-lg border bg-card p-4",children:(0,eb.jsxs)("div",{className:"grid gap-4 text-foreground",children:[$?(0,eb.jsxs)(etY,{children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"已配置 reclaude,自定义接入已停用"}),(0,eb.jsx)(etJ,{children:"reclaude 已托管账号并代理网络,Claude Code 会经由 reclaude 网关访问, 无需再填写 Base URL / API Key / OAuth Token。如需使用自定义接入,请先移除 reclaude 配置。"})]}):null,(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"Base URL"}),(0,eb.jsx)(eA,{autoComplete:"off",disabled:$,value:e.baseUrl??"",onChange:e=>D({baseUrl:e.currentTarget.value}),placeholder:"https://api.anthropic.com(留空使用官方)"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"claude-code 引擎用:自定义 Anthropic 兼容端点(ANTHROPIC_BASE_URL)。 留空使用官方接口。"})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"API Key"}),(0,eb.jsx)(eA,{type:"password",autoComplete:"off",disabled:$,value:e.apiKey??"",onChange:e=>D({apiKey:e.currentTarget.value}),placeholder:"claude-code 引擎用;留空可用 claude /login"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"claude-code 引擎用(ANTHROPIC_API_KEY);配合上方 Base URL 接入中转/自建网关。 留空可使用 claude /login 登录。"})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"OAuth Token"}),(0,eb.jsx)(eA,{type:"password",autoComplete:"off",disabled:$,value:e.oauthToken??"",onChange:e=>D({oauthToken:e.currentTarget.value}),placeholder:"留空使用其它认证方式"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"可选的 OAuth Token,作为 API Key 之外的认证方式。"})]})]})}),q=(0,eb.jsx)("section",{className:"w-full rounded-lg border bg-card p-4",children:(0,eb.jsx)("div",{className:"grid gap-4 text-foreground",children:(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"摘要模型"}),(0,eb.jsx)(esy,{models:a,value:e.summaryModelRef??"",onValueChange:e=>D({summaryModelRef:e}),placeholder:"使用默认"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"CC 会话标题/摘要用的 Vantaloom 模型路由。"})]})})}),W=[{id:"engines",title:"检测到的引擎",icon:(0,eb.jsx)(uK,{}),content:B},{id:"reclaude",title:"reclaude 账户",icon:(0,eb.jsx)(HP,{}),content:V},{id:"adapter",title:"SDK 桥(高级)",icon:(0,eb.jsx)(u0,{}),content:H},{id:"auth",title:"Claude Code 自定义接入",icon:(0,eb.jsx)(esf,{}),content:U},{id:"summary",title:"摘要模型",icon:(0,eb.jsx)(uX,{}),content:q}];return(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex flex-col gap-0.5 border-b px-4 py-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(uK,{}),"CC 引擎"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:"CC 引擎设置"})]}),m?(0,eb.jsx)("div",{className:"px-4 pt-4 md:px-5",children:(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"错误"}),(0,eb.jsx)(etJ,{children:m})]})}):null,(0,eb.jsx)(etm,{sections:W,sectionId:I,onSelectionChange:({sectionId:e})=>e&&P(e),defaultSectionId:"engines",labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto"}),(0,eb.jsx)(env,{dirty:p,saving:s,savedAt:x,onSave:()=>void F(),onReset:function(){b.current&&(t(b.current),g(!1),h(""))}})]})}function esy({models:e,value:t,onValueChange:n,placeholder:r}){return(0,eb.jsx)(x7,{value:t||"__none__",onValueChange:e=>n("__none__"===e?"":e),placeholder:r,title:"选择摘要模型",className:"w-full",options:[{value:"__none__",label:r},...e.map(e=>({value:e.id,label:e.label}))]})}let esw=[{id:"card",label:"卡片布局",description:"圆角卡片自由排布,右上角下拉菜单按需添加单窗口。",icon:(0,eb.jsx)(elr,{})},{id:"pane",label:"分屏布局",description:"传统多窗格 + 顶部分屏预设,可拖拽分割线调整。",icon:(0,eb.jsx)(qE,{})},{id:"control-room",label:"导播台视角",description:"隐藏窗格,右侧以监视器墙并排查看主代理与各子代理。",icon:(0,eb.jsx)(eP,{})}],esj=[{id:"left",label:"Agent 在左",icon:(0,eb.jsx)(cy,{})},{id:"right",label:"Agent 在右",icon:(0,eb.jsx)(cj,{})}];function esk(){let[e,t]=ew.useState("pane"),[n,r]=ew.useState("left");ew.useEffect(()=>{let e=eeV();t(e.mode),r(e.agentSide)},[]);let a=(0,eb.jsxs)("section",{className:"grid w-full gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"布局模式"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"仅电脑端生效。切换 Agent 工作区的窗口布局,设置即时应用到所有会话。"}),(0,eb.jsx)("div",{className:"grid gap-2 sm:grid-cols-3",children:esw.map(n=>{let r=e===n.id;return(0,eb.jsxs)("button",{type:"button",onClick:()=>{var e;t(e=n.id),eeH({mode:e})},className:(0,ez.cn)("flex flex-col gap-2 rounded-lg border p-3 text-left transition-colors [&_svg]:size-5",r?"border-primary bg-primary/5 text-foreground":"border-border bg-background text-muted-foreground hover:bg-muted/60 hover:text-foreground"),"aria-pressed":r,children:[(0,eb.jsx)("span",{className:(0,ez.cn)("grid size-9 place-items-center rounded-md",r?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:n.icon}),(0,eb.jsx)("span",{className:"text-sm font-medium text-foreground",children:n.label}),(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:n.description})]},n.id)})})]}),i=(0,eb.jsxs)("section",{className:"grid w-full gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"Agent 对话位置"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"仅电脑端生效。切换 Agent 对话窗口在工作区中的位置。"}),(0,eb.jsx)("div",{className:"flex flex-wrap gap-2",children:esj.map(e=>{let t=n===e.id;return(0,eb.jsxs)("button",{type:"button",onClick:()=>{var t;r(t=e.id),eeH({agentSide:t})},className:(0,ez.cn)("inline-flex items-center gap-2 rounded-lg border px-3 py-2 text-sm transition-colors [&_svg]:size-4",t?"border-primary bg-primary/5 text-foreground":"border-border bg-background text-muted-foreground hover:bg-muted/60 hover:text-foreground"),"aria-pressed":t,children:[e.icon,e.label]},e.id)})})]});return(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex flex-col gap-0.5 border-b px-4 py-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(elr,{}),"布局排版"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:"布局排版"})]}),(0,eb.jsx)(etm,{sections:[{id:"mode",title:"布局模式",icon:(0,eb.jsx)(elr,{}),content:a},{id:"side",title:"Agent 对话位置",icon:(0,eb.jsx)(cy,{}),content:i}],defaultSectionId:"mode",labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto"})]})}async function esN(){return esM("/api/local/model-groups")}async function esS(e){return esM("/api/local/model-groups",{method:"POST",body:JSON.stringify(e)})}async function esC(e){await esM(`/api/local/model-groups/${encodeURIComponent(e)}`,{method:"DELETE"})}async function esM(e,t){let n=await fetch((0,eT.localAPIURL)(e),{cache:"no-store",...t,headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error("string"==typeof r?.error?r.error:"model group api failed");return r}function esE(e){return{key:e.id,id:e.id,name:e.name,members:e.members.map(e=>({modelRef:e.modelRef,weight:e.weight})),editing:!1}}let esI=0;function esP(e){return JSON.stringify(e.map(e=>({id:e.id??"",name:e.name,members:e.members})))}function esO(){let{models:e,loading:t}=vH(),[n,r]=ew.useState([]),[a,i]=ew.useState([]),[o,l]=ew.useState(!0),[s,c]=ew.useState(""),[d,u]=ew.useState(!1),[f,m]=ew.useState(""),[h,p]=ew.useState(null),g=ew.useMemo(()=>e.filter(e=>!e.value.startsWith("group:")),[e]),x=ew.useMemo(()=>{let e=new Map;for(let t of g)e.set(t.value,t.label);return e},[g]),v=ew.useCallback(async()=>{c("");try{let e=((await esN()).groups??[]).map(esE);r(e),i(e)}catch(e){c(e instanceof Error?e.message:"模型组读取失败")}finally{l(!1)}},[]);ew.useEffect(()=>{v()},[v]);let b=ew.useMemo(()=>esP(n)!==esP(a),[n,a]),y=ew.useMemo(()=>{for(let e of n){if(!e.name.trim())return"每个模型组都需要一个名称";if(0===e.members.length)return"每个模型组至少需要一个成员模型"}},[n]);async function w(e){if(!e.id)return void r(t=>t.filter(t=>t.key!==e.key));m("");try{await esC(e.id),r(t=>t.filter(t=>t.key!==e.key)),i(t=>t.filter(t=>t.id!==e.id))}catch(e){m(e instanceof Error?e.message:"删除失败")}}async function j(){if(!d&&!y){u(!0),m("");try{let e=[];for(let t of n){let n=await esS({id:t.id,name:t.name.trim(),members:t.members});e.push({...esE(n),key:t.key})}r(e),i(e.map(e=>({...e}))),p(Date.now())}catch(e){m(e instanceof Error?e.message:"保存失败")}finally{u(!1)}}}return(0,eb.jsxs)("div",{className:"grid gap-4 pb-20",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsx)("div",{className:"min-w-0",children:(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"把多个模型组合成一个「模型组」,调用时按顺序轮询成员:先尝试第一个,出错按其 重试次数重试;用尽后切到下一个;全部用尽再回到第一个做最后一次尝试,仍失败才报错。 保存后可在任意模型选择处以「模型组:名称」选用。"})}),(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",onClick:function(){r(e=>[{key:(esI+=1,`new-group-${esI}`),name:"",members:[],editing:!0},...e]),p(null)},children:[(0,eb.jsx)(lY,{className:"size-4"}),"添加模型组"]})]}),s?(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"读取失败"}),(0,eb.jsx)(etJ,{children:s})]}):null,o?(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取模型组"}):0===n.length?(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"还没有模型组。点击「添加模型组」创建一个。"}):(0,eb.jsx)("div",{className:"grid gap-3",children:n.map(e=>(0,eb.jsx)(esz,{draft:e,candidates:g,candidatesLoading:t,labelByRef:x,onChange:t=>{var n,a;return n=e.key,a=()=>t,void r(e=>e.map(e=>e.key===n?a(e):e))},onDelete:()=>{w(e)}},e.key))}),(0,eb.jsx)(env,{dirty:b,saving:d,onSave:()=>{j()},onReset:function(){r(a.map(e=>({...e}))),m(""),p(null)},savedAt:h,error:f||void 0,validationMessage:b?y:void 0})]})}function esz({draft:e,candidates:t,candidatesLoading:n,labelByRef:r,onChange:a,onDelete:i}){let[o,l]=ew.useState(null),s=ew.useMemo(()=>e.members.map(e=>e.modelRef),[e.members]),c=ew.useCallback(t=>{let n=new Set(t),r=e.members.filter(e=>n.has(e.modelRef)),i=new Set(r.map(e=>e.modelRef)),o=t.filter(e=>!i.has(e)).map(e=>({modelRef:e,weight:2}));a({...e,members:[...r,...o]})},[e,a]);if(!e.editing){let t=e.members.map(e=>r.get(e.modelRef)??e.modelRef);return(0,eb.jsxs)("section",{className:"grid min-h-16 grid-cols-[minmax(0,1fr)_auto] items-center gap-3 rounded-lg border bg-card px-3 py-2.5",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[(0,eb.jsx)(k$,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,eb.jsx)("span",{className:"truncate text-sm font-medium",children:e.name.trim()||"未命名模型组"}),(0,eb.jsxs)("span",{className:"ui-text-kbd text-muted-foreground",children:[e.members.length," 个成员"]})]}),(0,eb.jsx)("div",{className:"mt-1 truncate text-xs text-muted-foreground",children:t.length>0?t.join(" → "):"未选择成员"})]}),(0,eb.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,eb.jsxs)(eO.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>a({...e,editing:!0}),children:[(0,eb.jsx)(UH,{className:"size-4"}),"编辑"]}),(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-hot-pink",onClick:i,title:"删除模型组",children:(0,eb.jsx)(yn,{className:"size-4"})})]})]})}return(0,eb.jsxs)("div",{className:"grid gap-3 rounded-lg border bg-card/40 p-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)(k$,{className:"size-4 shrink-0 text-muted-foreground"}),(0,eb.jsx)(eA,{value:e.name,onChange:t=>a({...e,name:t.target.value}),placeholder:"模型组名称",className:"h-8 flex-1"}),(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground",onClick:()=>a({...e,editing:!1}),title:"收起",children:(0,eb.jsx)(xw,{className:"size-4"})}),(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-hot-pink",onClick:i,title:"删除模型组",children:(0,eb.jsx)(yn,{className:"size-4"})})]}),(0,eb.jsx)(Ye,{mode:"multi",models:t,loading:n,value:s,onChange:c,emptyHint:"没有可用模型(先在「模型路由」配置渠道)"}),e.members.length>0?(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsx)("p",{className:"px-1 text-[11px] text-muted-foreground",children:"成员顺序与重试次数(拖动调整顺序;重试次数 = 该成员出错时的重试次数)"}),(0,eb.jsx)("div",{className:"grid gap-1",children:e.members.map((t,n)=>(0,eb.jsxs)("div",{draggable:!0,onDragStart:()=>l(n),onDragOver:e=>e.preventDefault(),onDrop:t=>{t.preventDefault(),null!==o&&function(t,n){if(t===n||t<0||n<0)return;let r=[...e.members],i=r[t];i&&(r.splice(t,1),r.splice(n,0,i),a({...e,members:r}))}(o,n),l(null)},onDragEnd:()=>l(null),className:(0,ez.cn)("flex items-center gap-2 rounded-md border bg-background px-2 py-1.5",o===n&&"opacity-50"),children:[(0,eb.jsx)(fX,{className:"size-4 shrink-0 cursor-grab text-muted-foreground"}),(0,eb.jsxs)("span",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground",children:[n+1,"."]}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm",children:r.get(t.modelRef)??t.modelRef}),(0,eb.jsxs)("label",{className:"flex shrink-0 items-center gap-1 text-[11px] text-muted-foreground",children:["重试",(0,eb.jsx)(eA,{type:"number",min:0,value:t.weight,onChange:t=>{var r;return r=Number.parseInt(t.target.value,10)||0,void a({...e,members:e.members.map((e,t)=>t===n?{...e,weight:Math.max(0,r)}:e)})},className:"h-7 w-14 px-2 text-center"})]}),(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0 text-muted-foreground hover:text-hot-pink",onClick:()=>{a({...e,members:e.members.filter((e,t)=>t!==n)})},title:"移除成员",children:(0,eb.jsx)(fV.XIcon,{className:"size-3.5"})})]},t.modelRef))})]}):null]})}let esA=(0,ek.default)("check-check",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]),esT=(0,ek.default)("flask-conical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]),esR=[{value:"openai-v1",label:"OpenAI v1"},{value:"anthropic",label:"Anthropic"},{value:"openai-responses",label:"OpenAI Responses"},{value:"codex",label:"Codex"}];function esD(e){return{id:e.id,providerName:e.providerName,protocol:e.protocol,endpointUrl:e.endpointUrl,apiKey:e.apiKey??"",models:e.models,selectedModelIds:e.selectedModelIds,builtin:e.builtin,enabled:e.enabled??!0,proxyEnabled:e.proxyEnabled??!1,proxyUrl:e.proxyUrl??"",loadingModels:!1,saving:!1,error:e.lastError??"",savedKeyAvailable:!!e.apiKey||!!e.builtin,editing:!1}}function es_(){let[e,t]=ew.useState([]),[n,r]=ew.useState(!0),[a,i]=ew.useState(""),o=ew.useCallback(async()=>{i("");try{let e=await vE();t(e.routes.map(esD))}catch(e){i(e instanceof Error?e.message:"模型路由读取失败")}finally{r(!1)}},[]);function l(e,n){t(t=>t.map((t,r)=>r===e?n(t):t))}async function s(t){let n=e[t];if(n&&!n.saving){l(t,e=>({...e,saving:!0,error:""}));try{let e=await vP({id:n.id,providerName:n.providerName,protocol:n.protocol,endpointUrl:n.endpointUrl,apiKey:n.apiKey,models:n.models,selectedModelIds:n.selectedModelIds,proxyEnabled:n.proxyEnabled,proxyUrl:n.proxyUrl.trim()});l(t,()=>esD(e))}catch(e){l(t,t=>({...t,saving:!1,error:e instanceof Error?e.message:"保存失败"}))}}}async function c(t,n){let r=e[t];if(r&&r.id&&!r.togglingEnabled){l(t,e=>({...e,enabled:n,togglingEnabled:!0}));try{let e=await vA(r.id,n);l(t,t=>({...t,enabled:e.enabled??n,togglingEnabled:!1})),vL=null,v_=!1,vV().catch(()=>{})}catch(e){l(t,t=>({...t,enabled:!n,togglingEnabled:!1,error:e instanceof Error?e.message:"切换失败"}))}}}async function d(n){let r=e[n];if(r&&!r.saving){if(!r.id)return void t(e=>e.filter((e,t)=>t!==n));l(n,e=>({...e,saving:!0,error:""}));try{await vO(r.id),t(e=>e.filter((e,t)=>t!==n))}catch(e){l(n,t=>({...t,saving:!1,error:e instanceof Error?e.message:"删除失败"}))}}}return ew.useEffect(()=>{o()},[o]),ew.useEffect(()=>{let e=!1,n=window.setInterval(()=>{(async()=>{try{let n=await vE();if(e)return;let r=n.routes.find(e=>e.builtin);t(e=>{let t=e.some(e=>e.builtin);return r?t?e.map(e=>e.builtin?{...e,providerName:r.providerName,models:r.models,selectedModelIds:r.selectedModelIds,enabled:e.togglingEnabled?e.enabled:r.enabled??!0,error:r.lastError??""}:e):[esD(r),...e]:t?e.filter(e=>!e.builtin):e})}catch{}})()},3e4);return()=>{e=!0,window.clearInterval(n)}},[]),(0,eb.jsxs)("div",{className:"grid gap-4",children:[(0,eb.jsx)("div",{className:"flex items-center justify-end gap-3",children:(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",onClick:function(){t(e=>[{providerName:"",protocol:"openai-v1",endpointUrl:"",apiKey:"",models:[],selectedModelIds:[],enabled:!0,proxyEnabled:!1,proxyUrl:"",loadingModels:!1,saving:!1,error:"",editing:!0},...e])},"data-tour":"add-model-route",children:[(0,eb.jsx)(lY,{className:"size-4"}),"添加模型路由"]})}),a?(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"读取失败"}),(0,eb.jsx)(etJ,{children:a})]}):null,n?(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取模型路由"}):0===e.length?(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"还没有模型路由。"}):(0,eb.jsx)("div",{className:"grid gap-3",children:e.map((e,t)=>(0,eb.jsx)(es$,{draft:e,onDraftChange:e=>l(t,()=>e),onSave:()=>{s(t)},onDelete:()=>{d(t)},onToggleEnabled:e=>{c(t,e)}},e.id??`draft-${t}`))})]})}function esL({value:e,title:t}){let[n,r]=ew.useState(!1);return(0,eb.jsx)("button",{type:"button",tabIndex:-1,title:t??"复制",disabled:!e,onClick:async()=>{if(e)try{await navigator.clipboard.writeText(e),r(!0),window.setTimeout(()=>r(!1),1200)}catch{}},className:"absolute right-1 top-1/2 flex size-6 -translate-y-1/2 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-40",children:n?(0,eb.jsx)(h6,{className:"size-3.5 text-emerald-500"}):(0,eb.jsx)(lV,{className:"size-3.5"})})}function es$({draft:e,onDraftChange:t,onSave:n,onDelete:r,onToggleEnabled:a}){let i=ew.useRef(e),o=ew.useRef(t),[l,s]=ew.useState({}),[c,d]=ew.useState(""),[u,f]=ew.useState(null),m=ew.useCallback(e=>{f({open:!0,modelId:e,prompt:"hi",stream:!0,running:!1,result:null})},[]),h=ew.useCallback(async(e,t)=>{if(!e)return void s(e=>({...e,[t]:{state:"failed",reason:"请先保存路由后再测试"}}));s(e=>({...e,[t]:{state:"testing"}}));try{let n=await vz({routeId:e,modelId:t});s(e=>({...e,[t]:n.ok?{state:"success"}:{state:"failed",reason:n.error||"测试失败"}}))}catch(e){s(n=>({...n,[t]:{state:"failed",reason:e instanceof Error?e.message:"测试失败"}}))}},[]),p=ew.useCallback(async(e,t)=>{if(f(e=>e?{...e,running:!0,result:null}:e),!e)return void f(e=>e?{...e,running:!1,result:{ok:!1,error:"请先保存路由后再测试"}}:e);let n=Date.now();try{let r=await vz({routeId:e,modelId:t.modelId,prompt:t.prompt,stream:t.stream}),a=r.latencyMs??Date.now()-n;f(e=>e?{...e,running:!1,result:{...r,latencyMs:a}}:e)}catch(e){f(t=>t?{...t,running:!1,result:{ok:!1,error:e instanceof Error?e.message:"测试失败"}}:t)}},[]),g=[e.providerName,e.protocol,e.endpointUrl,e.apiKey||(e.savedKeyAvailable?"saved":"")].join("\n"),x=e.providerName.trim()&&e.endpointUrl.trim()&&e.apiKey.trim(),v=e.providerName.trim()&&e.endpointUrl.trim()&&(e.apiKey.trim()||e.savedKeyAvailable)&&e.selectedModelIds.length>0&&!e.saving;ew.useEffect(()=>{i.current=e,o.current=t},[e,t]);let b=ew.useRef(null),y=ew.useRef(null),w=ew.useCallback(async e=>{let t=i.current;b.current=e,o.current({...t,loadingModels:!0,error:""});try{let e=await vI({providerName:t.providerName,protocol:t.protocol,endpointUrl:t.endpointUrl,apiKey:t.apiKey}),n=t.selectedModelIds.filter(t=>e.models.some(e=>e.id===t));o.current({...i.current,models:e.models,selectedModelIds:n,loadingModels:!1,error:""})}catch(e){o.current({...i.current,loadingModels:!1,error:e instanceof Error?e.message:"模型拉取失败"})}},[]);ew.useEffect(()=>{if((null!==y.current&&(window.clearTimeout(y.current),y.current=null),x)&&g!==b.current)return y.current=window.setTimeout(()=>{y.current=null,w(g)},1300),()=>{null!==y.current&&(window.clearTimeout(y.current),y.current=null)}},[x,g,w]);let j=ew.useCallback(()=>{x&&g!==b.current&&(null!==y.current&&(window.clearTimeout(y.current),y.current=null),w(g))},[x,g,w]);function k(n){t({...e,...n})}let N=e.models.length>0&&e.selectedModelIds.length===e.models.length,S=e.models.length>18,C=c.trim().toLowerCase(),M=C.length>0?e.models.filter(e=>{let t=e.id.toLowerCase(),n=(e.displayName??"").toLowerCase();return t.includes(C)||n.includes(C)}):e.models;if(!e.editing||e.builtin){let t=e.selectedModelIds.map(t=>e.models.find(e=>e.id===t)?.displayName||t).filter(Boolean),n=esR.find(t=>t.value===e.protocol)?.label??e.protocol;return(0,eb.jsxs)("section",{className:(0,ez.cn)("grid min-h-16 grid-cols-[minmax(0,1fr)_auto] items-center gap-3 rounded-lg border bg-card px-3 py-2.5",!e.enabled&&"opacity-60"),children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[e.builtin?(0,eb.jsx)(lq,{className:"size-3.5 shrink-0 text-muted-foreground"}):null,(0,eb.jsx)("span",{className:"truncate text-sm font-medium",children:e.providerName}),e.builtin?(0,eb.jsx)("span",{className:"ui-text-kbd rounded-full bg-muted px-2 py-0.5 text-muted-foreground",children:"官渠"}):null,(0,eb.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:n}),e.enabled?null:(0,eb.jsx)("span",{className:"ui-text-kbd rounded-full bg-destructive/10 px-2 py-0.5 text-destructive",children:"已禁用"})]}),(0,eb.jsx)("div",{className:"mt-1 truncate text-xs text-muted-foreground",children:t.length>0?t.join(", "):"未选择模型"})]}),(0,eb.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[e.id?(0,eb.jsx)(bG,{checked:e.enabled,disabled:e.togglingEnabled,onCheckedChange:e=>a(!0===e),"aria-label":e.enabled?"禁用此路由":"启用此路由",title:e.enabled?"已启用(点击禁用)":"已禁用(点击启用)"}):null,e.builtin?null:(0,eb.jsxs)(eO.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>k({editing:!0}),children:[(0,eb.jsx)(UH,{className:"size-4"}),"编辑"]})]})]})}return(0,eb.jsxs)("section",{className:"grid min-w-0 gap-3 rounded-lg border bg-card p-3","data-tour":"model-route-form",children:[(0,eb.jsxs)("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_11rem]",children:[(0,eb.jsx)(eA,{value:e.providerName,placeholder:"提供商名称",onChange:e=>k({providerName:e.currentTarget.value}),onBlur:j}),(0,eb.jsx)(x7,{value:e.protocol,onValueChange:e=>k({protocol:e}),options:esR,title:"选择协议",className:"w-full"})]}),(0,eb.jsxs)("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_minmax(0,18rem)]",children:[(0,eb.jsxs)("div",{className:"relative",children:[(0,eb.jsx)(eA,{value:e.endpointUrl,placeholder:"API 端点 URL,例如 https://api.openai.com/v1",className:"pr-8",onChange:e=>k({endpointUrl:e.currentTarget.value}),onBlur:j}),(0,eb.jsx)(esL,{value:e.endpointUrl,title:"复制端点 URL"})]}),(0,eb.jsxs)("div",{className:"relative",children:[(0,eb.jsx)(eA,{value:e.apiKey,type:"text",placeholder:"API Key",autoComplete:"off",spellCheck:!1,className:"pr-8 font-mono",onChange:e=>k({apiKey:e.currentTarget.value}),onBlur:j}),(0,eb.jsx)(esL,{value:e.apiKey,title:"复制 API Key"})]})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)("div",{className:"flex items-center justify-between gap-2",children:(0,eb.jsxs)("label",{className:"flex cursor-pointer items-center gap-2 text-sm font-medium",children:[(0,eb.jsx)(bG,{checked:e.proxyEnabled,onCheckedChange:e=>k({proxyEnabled:!0===e}),"aria-label":"启用代理"}),"启用代理"]})}),e.proxyEnabled?(0,eb.jsxs)("div",{className:"relative",children:[(0,eb.jsx)(eA,{value:e.proxyUrl,placeholder:"http://127.0.0.1:7890",autoComplete:"off",spellCheck:!1,className:"pr-8 font-mono",onChange:e=>k({proxyUrl:e.currentTarget.value})}),(0,eb.jsx)(esL,{value:e.proxyUrl,title:"复制代理地址"})]}):null,(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"启用后该渠道的所有模型请求都经此代理。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsxs)("div",{className:"flex min-h-6 items-center justify-between gap-2",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm font-medium",children:[(0,eb.jsx)(h3,{className:"size-4 text-muted-foreground"}),"可用模型",e.models.length>0?(0,eb.jsxs)("span",{className:"text-xs font-normal text-muted-foreground tabular-nums",children:[e.selectedModelIds.length,"/",e.models.length]}):null]}),(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[e.loadingModels?(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:"拉取中"}):null,e.models.length>0?(0,eb.jsxs)(eO.Button,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>k({selectedModelIds:N?[]:e.models.map(e=>e.id)}),children:[(0,eb.jsx)(esA,{className:"size-3.5"}),N?"全不选":"全选"]}):null]})]}),S?(0,eb.jsxs)("div",{className:"relative",children:[(0,eb.jsx)(vu,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),(0,eb.jsx)(eA,{value:c,placeholder:"搜索模型…",autoComplete:"off",spellCheck:!1,className:"h-8 pl-8 pr-8 text-sm",onChange:e=>d(e.currentTarget.value)}),c?(0,eb.jsx)("button",{type:"button",tabIndex:-1,title:"清除",onClick:()=>d(""),className:"absolute right-1 top-1/2 flex size-6 -translate-y-1/2 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:(0,eb.jsx)(fV.XIcon,{className:"size-3.5"})}):null]}):null,e.models.length>0?0===M.length?(0,eb.jsxs)("div",{className:"rounded-md border border-dashed px-3 py-4 text-sm text-muted-foreground",children:["没有匹配「",c,"」的模型。"]}):(0,eb.jsx)("div",{className:"grid max-h-64 gap-1 overflow-auto pr-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:M.map(t=>{let n=e.selectedModelIds.includes(t.id),r=l[t.id]??{state:"idle"};return(0,eb.jsxs)("div",{className:(0,ez.cn)("grid min-h-8 grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-2 rounded-md px-2 text-sm hover:bg-muted/60",n&&"bg-muted/70"),children:[(0,eb.jsxs)("label",{className:"flex min-w-0 cursor-pointer items-center gap-2",children:[(0,eb.jsx)(vM,{checked:n,onCheckedChange:n=>{var r;return r=t.id,void k({selectedModelIds:!0===n?[...e.selectedModelIds,r]:e.selectedModelIds.filter(e=>e!==r)})}}),(0,eb.jsx)("span",{className:"truncate",children:t.displayName||t.id})]}),(0,eb.jsxs)("div",{className:"flex items-center gap-1",children:[(0,eb.jsx)(eA,{type:"number",className:"h-6 w-16 px-1.5 text-center text-xs tabular-nums",value:t.contextLength||200,min:1,max:1e4,onChange:n=>{var r,a;return r=t.id,a=Number.parseInt(n.currentTarget.value,10)||0,void k({models:e.models.map(e=>e.id===r?{...e,contextLength:a>0?a:void 0}:e)})}}),(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:"k"})]}),(0,eb.jsxs)(wh,{children:[(0,eb.jsx)(wg,{asChild:!0,children:(0,eb.jsx)("button",{type:"button",title:"failed"===r.state?`测试失败:${r.reason??""}`:"success"===r.state?"测试通过(右键高级测试)":"测试此模型(右键高级测试)",disabled:"testing"===r.state,onClick:()=>void h(e.id,t.id),className:(0,ez.cn)("flex size-6 shrink-0 items-center justify-center rounded transition-colors hover:bg-muted disabled:opacity-60","success"===r.state&&"text-emerald-500","failed"===r.state&&"text-destructive","idle"===r.state&&"text-muted-foreground","testing"===r.state&&"text-muted-foreground"),children:"testing"===r.state?(0,eb.jsx)(HR,{className:"size-3.5"}):"success"===r.state?(0,eb.jsx)(h6,{className:"size-3.5"}):"failed"===r.state?(0,eb.jsx)(fV.XIcon,{className:"size-3.5"}):(0,eb.jsx)(HE,{className:"size-3.5"})})}),(0,eb.jsx)(wN,{children:(0,eb.jsxs)(wS,{onSelect:()=>m(t.id),children:[(0,eb.jsx)(esT,{className:"size-4"}),"高级测试…"]})})]})]},t.id)})}):(0,eb.jsx)("div",{className:"rounded-md border border-dashed px-3 py-4 text-sm text-muted-foreground",children:"填写端点和密钥后会自动拉取模型。"})]}),e.error?(0,eb.jsxs)(etY,{variant:"destructive",className:"min-w-0 max-w-full overflow-hidden",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"模型路由错误"}),(0,eb.jsx)(etJ,{className:"max-h-32 max-w-full min-w-0 overflow-y-auto whitespace-pre-wrap break-all",children:e.error})]}):null,(0,eb.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,eb.jsxs)(eO.Button,{type:"button",variant:"destructive",onClick:r,disabled:e.saving,children:[(0,eb.jsx)(yn,{className:"size-4"}),"删除"]}),(0,eb.jsx)(eO.Button,{type:"button",onClick:n,disabled:!v,children:e.saving?"保存中":"保存"})]}),(0,eb.jsx)(dX,{open:!!u?.open,onOpenChange:e=>{e||f(null)},children:(0,eb.jsxs)(fU,{className:"max-w-xl",children:[(0,eb.jsxs)(fq,{children:[(0,eb.jsx)(fK,{children:"高级模型测试"}),(0,eb.jsx)(fG,{children:"用自定义提示词向所选模型发起一次真实请求,查看完整回复与延迟。"})]}),u?(0,eb.jsx)(esF,{draft:e,state:u,onChange:e=>f(t=>t?{...t,...e}:t),onRun:()=>void p(e.id,{modelId:u.modelId,prompt:u.prompt,stream:u.stream})}):null]})})]})}function esF({draft:e,state:t,onChange:n,onRun:r}){let[a,i]=ew.useState(!1),o=t.result,l=o?.content??"";return(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsxs)("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_auto] md:items-center",children:[(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"目标模型"}),(0,eb.jsx)(x7,{value:t.modelId,onValueChange:e=>n({modelId:e}),options:e.models.map(e=>({value:e.id,label:e.displayName||e.id})),placeholder:"选择模型",title:"选择模型",className:"w-full"})]}),(0,eb.jsxs)("label",{className:"flex cursor-pointer items-center gap-2 pt-1 text-sm md:pt-5",children:[(0,eb.jsx)(bG,{checked:t.stream,onCheckedChange:e=>n({stream:!0===e}),"aria-label":"流式"}),"流式"]})]}),(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"测试提示词"}),(0,eb.jsx)(w2,{value:t.prompt,rows:3,placeholder:"hi",spellCheck:!1,className:"resize-y font-mono text-sm",onChange:e=>n({prompt:e.currentTarget.value})})]}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,eb.jsx)(eO.Button,{type:"button",size:"sm",onClick:r,disabled:t.running||!t.modelId,children:t.running?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(HR,{className:"size-4"}),"测试中"]}):(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(HE,{className:"size-4"}),"测试"]})}),o&&"number"==typeof o.latencyMs?(0,eb.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums",children:["延迟 ",o.latencyMs," ms"]}):null]}),o&&!o.ok?(0,eb.jsxs)(etY,{variant:"destructive",className:"min-w-0 max-w-full overflow-hidden",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"测试失败"}),(0,eb.jsx)(etJ,{className:"max-h-40 max-w-full min-w-0 overflow-y-auto whitespace-pre-wrap break-all",children:o.error||"未知错误"})]}):null,o&&o.ok?(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"模型回复"}),(0,eb.jsxs)(eO.Button,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",disabled:!l,onClick:async()=>{if(l)try{await navigator.clipboard.writeText(l),i(!0),window.setTimeout(()=>i(!1),1200)}catch{}},children:[a?(0,eb.jsx)(h6,{className:"size-3.5 text-emerald-500"}):(0,eb.jsx)(lV,{className:"size-3.5"}),"复制"]})]}),(0,eb.jsx)("div",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/40 p-2 font-mono text-xs",children:l||"(空回复)"})]}):null]})}async function esB(){return esH("/api/local/subagent-config")}async function esV(e){return esH("/api/local/subagent-config",{method:"PUT",body:JSON.stringify(e)})}async function esH(e,t){let n=await fetch((0,eT.localAPIURL)(e),{cache:"no-store",...t,headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error("string"==typeof r?.error?r.error:"subagent config api failed");return r}function esU(e){return{...e,models:[...e.models??[]]}}function esq(e){return{explore:esU(e.explore),workflow:esU(e.workflow),operator:esU(e.operator),custom:{...e.custom,models:[...e.custom.models??[]]}}}let esW={explore:{title:"探索子代理",icon:(0,eb.jsx)(HC,{className:"size-4"}),tint:"text-sky-600 dark:text-sky-400",description:"只读的代码库探索/调研专家。彻底阅读、搜索代码库,返回带文件路径+行号引用的完整结论,替主 agent 节省上下文。",tools:"仅阅读(vantaloom_read)"},workflow:{title:"工作流子代理",icon:(0,eb.jsx)(u1,{className:"size-4"}),tint:"text-violet-600 dark:text-violet-400",description:"按 workflow-*.yml 严格执行可重复的多步流程,并把其中确定性的步骤自动固化为脚本、给 yml 添加批注。",tools:"阅读 / 编辑 / 终端(vantaloom_read · vantaloom_edit · vantaloom_shell)"},operator:{title:"操作员子代理",icon:(0,eb.jsx)(u0,{className:"size-4"}),tint:"text-pink-600 dark:text-pink-400",description:"专门驱动交互式终端(未来含浏览器)。执行大量终端操作并把结果回报给主 agent。",tools:"阅读 / 终端(vantaloom_read · vantaloom_shell)"}};function esK(){let[e,t]=ew.useState("explore"),[n,r]=ew.useState(null),{models:a,loading:i}=vH(),[o,l]=ew.useState(!0),[s,c]=ew.useState(!1),[d,u]=ew.useState(""),[f,m]=ew.useState(!1),[h,p]=ew.useState(null),g=ew.useRef(null);async function x(){if(n&&!s){c(!0),u("");try{let e=await esV({explore:n.explore,workflow:n.workflow,operator:n.operator,custom:n.custom});g.current=e,r(esq(e)),m(!1),p(Date.now())}catch(e){u(e instanceof Error?e.message:"Save failed")}finally{c(!1)}}}if(ew.useEffect(()=>{!async function(){try{let e=await esB();g.current=e,r(esq(e))}catch(e){u(e instanceof Error?e.message:"Failed to load config")}finally{l(!1)}}()},[]),o)return(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取子代理配置"});if(!n)return(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"读取失败"}),(0,eb.jsx)(etJ,{children:d||"无法加载子代理配置"})]});let v=e=>({id:e,title:esW[e].title,icon:esW[e].icon,content:(0,eb.jsx)("div",{className:"mx-auto w-full max-w-2xl",children:(0,eb.jsx)(esG,{tourId:`subagent-${e}`,meta:esW[e],value:n[e],models:a,modelsLoading:i,onChange:t=>{r(n=>n?{...n,[e]:{...n[e],...t}}:n),m(!0),p(null)}})})});return(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex flex-col gap-0.5 border-b px-4 py-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(uH,{}),"子代理配置"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:"子代理配置"})]}),d?(0,eb.jsx)("div",{className:"px-4 pt-4 md:px-5",children:(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"错误"}),(0,eb.jsx)(etJ,{children:d})]})}):null,(0,eb.jsx)(etm,{sections:[v("explore"),v("workflow"),v("operator"),{id:"custom",title:"自定义子代理",icon:(0,eb.jsx)(uH,{className:"size-4"}),content:(0,eb.jsx)("div",{className:"mx-auto w-full max-w-2xl",children:(0,eb.jsx)(esX,{value:n.custom,models:a,modelsLoading:i,onChange:function(e){r(t=>t?{...t,custom:{...t.custom,...e}}:t),m(!0),p(null)}})})}],sectionId:e,onSelectionChange:({sectionId:e})=>e&&t(e),defaultSectionId:"explore",labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto pb-28"}),(0,eb.jsx)(env,{dirty:f,saving:s,savedAt:h,onSave:()=>void x(),onReset:function(){g.current&&(r(esq(g.current)),m(!1),u(""))}})]})}function esG({meta:e,value:t,models:n,modelsLoading:r,onChange:a,tourId:i}){return(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":i,children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)("span",{className:e.tint,children:e.icon}),(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:e.title})]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:e.description}),(0,eb.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,eb.jsx)("span",{className:"text-foreground/70",children:"可用工具:"}),e.tools,(0,eb.jsx)("span",{className:"ml-1 text-muted-foreground/70",children:"(固定,不可更改)"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"可用模型"}),(0,eb.jsx)(Ye,{mode:"multi",models:n,loading:r,value:t.models??[],onChange:e=>a({models:e})}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"可选多个模型;首个作为默认。开启“允许上级指定模型”后,上级 agent 只能从这里选;留空则继承派发它的上级 agent 当前使用的模型。"})]}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"允许上级指定模型"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"开启后,上级 agent 可在派发时动态指定该子代理使用的模型。"})]}),(0,eb.jsx)(bG,{checked:t.allowCallerModel,onCheckedChange:e=>a({allowCallerModel:e})})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"系统提示词"}),t.promptOverride?(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>a({promptOverride:""}),children:"恢复默认"}):null]}),(0,eb.jsx)(w2,{value:t.promptOverride,onChange:e=>a({promptOverride:e.currentTarget.value}),placeholder:"留空使用内置默认提示词;在此输入将覆盖默认提示词(环境/工具说明仍会自动附加)。",rows:t.promptOverride?10:3,className:"resize-y text-sm"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"覆盖该官方子代理的预设系统提示词。派发时还会自动附加工作区、操作系统与工具使用说明。"})]})]})}function esX({value:e,models:t,modelsLoading:n,onChange:r}){return(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"subagent-custom",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:(0,eb.jsx)(uH,{className:"size-4"})}),(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"自定义子代理"})]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"主 agent 可以自取名字、从下面的模型池中选一个模型来召唤自定义子代理,并可选择是否继承当前对话上下文。自定义子代理拥有完整工具集,还能进一步派发上面三种官方子代理。"}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"可用模型池"}),(0,eb.jsx)(Ye,{mode:"multi",models:t,loading:n,value:e.models??[],onChange:e=>r({models:e})}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"主 agent 召唤自定义子代理时会从这个池中选择一个模型。留空则沿用上级 agent 的模型。"})]})]})}function esY({section:e}={}){return"agent-config"===e||"subagent-config"===e||"cc-engine-config"===e||"assets"===e||"layout"===e?(0,eb.jsx)("div",{className:"h-full min-h-0","data-tour":`preferences-${e}`,children:"agent-config"===e?(0,eb.jsx)(esc,{}):"subagent-config"===e?(0,eb.jsx)(esK,{}):"cc-engine-config"===e?(0,eb.jsx)(esb,{}):"layout"===e?(0,eb.jsx)(esk,{}):(0,eb.jsx)(enC,{scope:"global"})}):(0,eb.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:(0,eb.jsx)("div",{className:"mx-auto w-full max-w-3xl","data-tour":`preferences-${e??"model-routes"}`,children:"model-groups"===e?(0,eb.jsx)(esO,{}):(0,eb.jsx)(es_,{})})})}function esZ(){return(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex flex-col gap-0.5 border-b px-4 py-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(uK,{}),"模型设置"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:"模型设置"})]}),(0,eb.jsx)(etm,{sections:[{id:"routes",title:"模型路由",icon:(0,eb.jsx)(h3,{className:"size-4"}),content:(0,eb.jsx)(es_,{})},{id:"groups",title:"聚合模型",icon:(0,eb.jsx)(k$,{className:"size-4"}),content:(0,eb.jsx)(esO,{})}],defaultSectionId:"routes",labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto"})]})}let esJ=[1e4,3e4,12e4,3e5,6e5];function esQ(e){return{compression:{...e.compression},summary:{...e.summary},approval:{...e.approval},behavior:{maxToolCalls:e.behavior?.maxToolCalls??0,retryCount:e.behavior?.retryCount??0,retryDelaysMs:e.behavior?.retryDelaysMs??[],loopMaxIterations:e.behavior?.loopMaxIterations??25,loopHookWait:e.behavior?.loopHookWait??"defer",loopHookWaitTimeoutSec:e.behavior?.loopHookWaitTimeoutSec??0}}}function es0(e){return(e&&e.length?e:esJ).map(e=>Math.round(e/1e3)).join(", ")}function es1(){let[e,t]=ew.useState("context"),[n,r]=ew.useState(""),[a,i]=ew.useState(!0),[o,l]=ew.useState(!1),[s,c]=ew.useState(null),[d,u]=ew.useState(null),[f,m]=ew.useState(!1),h=ew.useRef(null),[p,g]=ew.useState([]),[x,v]=ew.useState(""),[b,y]=ew.useState(null),[w,j]=ew.useState(!1),k=ew.useRef(null),{models:N,loading:S}=vH();function C(e,t){u(n=>n?{...n,[e]:{...n[e],...t}}:n),m(!0),c(null)}async function M(){if(!o){l(!0),r("");try{if(f&&d){let e=await ks({compression:d.compression,summary:d.summary,approval:d.approval,behavior:d.behavior});h.current=e,u(esQ(e)),v(es0(e.behavior?.retryDelaysMs)),m(!1)}if(w&&b){let e=await esV({explore:b.explore,workflow:b.workflow,operator:b.operator,custom:b.custom});k.current=e,y(esq(e)),j(!1)}c(Date.now())}catch(e){r(e instanceof Error?e.message:"Save failed")}finally{l(!1)}}}if(ew.useEffect(()=>{!async function(){try{let[e,t,n]=await Promise.all([kl(),vE(),esB()]);h.current=e,u(esQ(e)),v(es0(e.behavior?.retryDelaysMs)),g(t.models),k.current=n,y(esq(n))}catch(e){r(e instanceof Error?e.message:"Failed to load config")}finally{i(!1)}}()},[]),a)return(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取代理配置"});if(!d||!b)return(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"读取失败"}),(0,eb.jsx)(etJ,{children:n||"无法加载代理配置"})]});let E=(0,eb.jsxs)("div",{className:"grid w-full gap-6",children:[(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-compression",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"压缩上下文"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"当对话 token 达到模型上下文窗口的指定百分比时自动压缩。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"自动压缩阈值"}),(0,eb.jsxs)("span",{className:"text-sm tabular-nums text-muted-foreground",children:[d.compression.autoThresholdPercent,"%"]})]}),(0,eb.jsx)(enx,{value:[d.compression.autoThresholdPercent],onValueChange:([e])=>C("compression",{autoThresholdPercent:e}),min:0,max:100,step:5}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"0% 表示禁用自动压缩。建议设为 70%-85%。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"压缩模型"}),(0,eb.jsx)(es2,{models:p,value:d.compression.modelRef,onValueChange:e=>C("compression",{modelRef:e}),placeholder:"使用主模型"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"用于执行上下文压缩的模型。留空则使用当前对话主模型。"})]})]}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-summary",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"对话摘要"}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"对话标题摘要"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"每轮对话结束后自动更新对话标题。"})]}),(0,eb.jsx)(bG,{checked:d.summary.enableTitleSummary,onCheckedChange:e=>C("summary",{enableTitleSummary:e})})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"轮次标题摘要"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"为每轮 agent 操作生成摘要标题。"})]}),(0,eb.jsx)(bG,{checked:d.summary.enableRoundSummary,onCheckedChange:e=>C("summary",{enableRoundSummary:e})})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"摘要模型"}),(0,eb.jsx)(es2,{models:p,value:d.summary.modelRef,onValueChange:e=>C("summary",{modelRef:e}),placeholder:"使用主模型"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"用于生成对话摘要的模型。留空则使用当前对话主模型。"})]})]})]}),I=(0,eb.jsxs)("div",{className:"grid w-full gap-6",children:[(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"自动重试与工具调用上限"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"控制本机(vantaloom)agent 单次运行的工具调用上限,以及请求失败后的自动重试。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"最大工具调用次数"}),(0,eb.jsx)(eA,{type:"number",min:0,value:d.behavior.maxToolCalls,onChange:e=>C("behavior",{maxToolCalls:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"单次运行累计调用工具达到该次数后强制暂停(可点击“继续”恢复)。设为 0 表示不限次(默认)。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"自动重试次数"}),(0,eb.jsx)(eA,{type:"number",min:0,value:d.behavior.retryCount,onChange:e=>C("behavior",{retryCount:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"模型/服务商请求失败时自动重试的次数(仅在尚未产出内容时重试,避免重复输出)。设为 0 表示不重试。"})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"重试间隔梯度(秒)"}),(0,eb.jsx)(eA,{value:x,onChange:e=>{let t=e.currentTarget.value;v(t),C("behavior",{retryDelaysMs:t.split(/[,,\s]+/).map(e=>Number.parseInt(e.trim(),10)).filter(e=>Number.isFinite(e)&&e>0).map(e=>1e3*e)})},placeholder:"10, 30, 120, 300, 600"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"用逗号分隔每次重试的等待秒数(指数级递增),例如 10, 30, 120, 300, 600。超出列表长度时使用最后一项。留空使用内置默认梯度。"})]})]}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"循环模式"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"开启循环模式后,每轮运行结束会自动注入“继续”并续跑,直到执行树中没有未完成(且未阻塞)的任务。以下设置控制其自动续跑的上限与遇到钩子时的处理方式。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"最大循环次数"}),(0,eb.jsx)(eA,{type:"number",min:1,value:d.behavior.loopMaxIterations,onChange:e=>C("behavior",{loopMaxIterations:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"连续自动续跑达到该次数后强制暂停以避免无限计费(发送新消息可继续)。设为 0 表示使用内置默认值(25)。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"钩子处理"}),(0,eb.jsx)(x7,{value:d.behavior.loopHookWait??"defer",onValueChange:e=>C("behavior",{loopHookWait:"wait"===e?"wait":"defer"}),title:"钩子处理",className:"w-full",options:[{value:"defer",label:"有钩子运行时暂停"},{value:"wait",label:"等待钩子完成后继续"}]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"当存在会自动唤醒本对话的钩子(如进程退出、定时器)时:选择“暂停”则交由钩子驱动;选择“等待”则等钩子完成后再继续循环。"})]}),"wait"===d.behavior.loopHookWait?(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"等待超时(秒,0 = 直到无钩子)"}),(0,eb.jsx)(eA,{type:"number",min:0,value:d.behavior.loopHookWaitTimeoutSec??0,onChange:e=>C("behavior",{loopHookWaitTimeoutSec:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"在“等待”模式下,最多等待多少秒后无论钩子是否完成都继续。设为 0 表示一直等到没有钩子在运行(仍受 30 分钟的硬性上限约束)。"})]}):null]})]}),P=(0,eb.jsx)("div",{className:"grid w-full gap-6",children:(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-approval",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"命令审批"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"在 Auto 权限模式下,使用 AI 模型审批 Agent 发起的命令是否可以自动执行。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"审批模型"}),(0,eb.jsx)(es2,{models:p,value:d.approval.modelRef,onValueChange:e=>C("approval",{modelRef:e}),placeholder:"未配置(全部放行)"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"留空表示 Auto 模式下不进行 AI 审批,所有非危险命令自动放行。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"审批提示词"}),(0,eb.jsx)(w2,{value:d.approval.prompt,onChange:e=>C("approval",{prompt:e.currentTarget.value}),placeholder:"可选:给审批模型的额外指导,例如允许哪些操作、拒绝哪些操作",rows:4,className:"resize-none text-sm"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"与系统提示词一起发送给审批模型,帮助它判断命令是否安全。"})]})]})}),O=e=>({id:e,title:esW[e].title,icon:esW[e].icon,content:(0,eb.jsx)("div",{className:"w-full",children:(0,eb.jsx)(esG,{tourId:`subagent-${e}`,meta:esW[e],value:b[e],models:N,modelsLoading:S,onChange:t=>{y(n=>n?{...n,[e]:{...n[e],...t}}:n),j(!0),c(null)}})})});return(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex flex-col gap-0.5 border-b px-4 py-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(uH,{}),"代理配置"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:"代理配置"})]}),n?(0,eb.jsx)("div",{className:"px-4 pt-4 md:px-5",children:(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"错误"}),(0,eb.jsx)(etJ,{children:n})]})}):null,(0,eb.jsx)(etm,{sections:[{id:"context",title:"上下文",icon:(0,eb.jsx)(k$,{}),content:E},{id:"behavior",title:"运行行为",icon:(0,eb.jsx)(enW,{}),content:I},{id:"approval",title:"命令审批",icon:(0,eb.jsx)(kB,{}),content:P},O("explore"),O("workflow"),O("operator"),{id:"custom",title:"自定义子代理",icon:(0,eb.jsx)(uH,{className:"size-4"}),content:(0,eb.jsx)("div",{className:"w-full",children:(0,eb.jsx)(esX,{value:b.custom,models:N,modelsLoading:S,onChange:function(e){y(t=>t?{...t,custom:{...t.custom,...e}}:t),j(!0),c(null)}})})}],sectionId:e,onSelectionChange:({sectionId:e})=>{e&&t(e)},defaultSectionId:"context",labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto"}),(0,eb.jsx)(env,{dirty:f||w,saving:o,savedAt:s,onSave:()=>void M(),onReset:function(){h.current&&(u(esQ(h.current)),v(es0(h.current.behavior?.retryDelaysMs))),k.current&&y(esq(k.current)),m(!1),j(!1),r("")}})]})}function es2({models:e,value:t,onValueChange:n,placeholder:r}){return(0,eb.jsx)(x7,{value:t||"__none__",onValueChange:e=>n("__none__"===e?"":e),placeholder:r,title:"选择模型",className:"w-full",options:[{value:"__none__",label:r},...e.map(e=>({value:e.id,label:e.label}))]})}let es5=(0,ek.default)("wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]),es4={totals:{machines:0,online:0,runtime:0,tokens:0},machines:[],topology:{nodes:[],links:[]},pathTotals:{direct:0,p2p:0,relay:0,broken:0},latency:[],candidates:[]},es3={metrics:{online:0,health:0,latency:"local",events:0},machines:[],trend:[],networkLinks:[],events:[],serviceHealth:[]};function es6(e,t){let[n,r]=ew.useState(t);return ew.useEffect(()=>{let n=!0,a=!1;async function i(){if(!a){a=!0;try{let t=await fetch((0,eT.localAPIURL)(e),{cache:"no-store"});if(!t.ok)return;let a=await t.json();n&&r(a)}catch{n&&r(t)}finally{a=!1}}}i();let o=window.setInterval(i,2e3);return()=>{n=!1,window.clearInterval(o)}},[t,e]),n}let es8={online:{label:"在线",dot:"bg-foreground"},warning:{label:"警告",dot:"bg-muted-foreground"},offline:{label:"离线",dot:"bg-destructive"}},es7={direct:{label:"直连",dot:"bg-foreground"},p2p:{label:"P2P",dot:"bg-foreground"},relay:{label:"中继",dot:"bg-muted-foreground"},down:{label:"断开",dot:"bg-destructive"}};function es9(){return(0,eb.jsx)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:(0,eb.jsx)(ece,{})})})}function ece(){let e=es6("/api/local/machines/fleet",es4),{nodes:t,links:n}=e.topology,r=new Map(t.map(e=>[e.id,e.label])),a=e=>r.get(e)??e;return(0,eb.jsxs)("div",{className:"space-y-4 text-foreground",children:[(0,eb.jsxs)("div",{children:[(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"系统中各机器与连接的明细(自动生成)。下表列出每台机器的在线状态,以及机器之间的连接方式与实时延迟。"}),(0,eb.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 text-xs text-muted-foreground",children:[(0,eb.jsxs)("span",{children:["机器 ",e.totals.online,"/",e.totals.machines," 在线"]}),(0,eb.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,eb.jsx)("span",{className:"size-2 rounded-full bg-foreground"}),"直连 ",e.pathTotals.direct]}),(0,eb.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,eb.jsx)("span",{className:"size-2 rounded-full bg-foreground"}),"P2P ",e.pathTotals.p2p]}),(0,eb.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,eb.jsx)("span",{className:"size-2 rounded-full bg-muted-foreground"}),"中继 ",e.pathTotals.relay]}),(0,eb.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,eb.jsx)("span",{className:"size-2 rounded-full bg-destructive"}),"断开 ",e.pathTotals.broken]})]})]}),(0,eb.jsxs)("section",{className:"rounded-xl border bg-card",children:[(0,eb.jsx)("div",{className:"border-b border-border/60 px-3 py-2 text-sm font-medium",children:"机器"}),(0,eb.jsx)("div",{className:"overflow-x-auto",children:(0,eb.jsxs)("table",{className:"w-full min-w-[28rem] border-collapse text-sm",children:[(0,eb.jsx)("thead",{children:(0,eb.jsxs)("tr",{className:"text-left text-xs text-muted-foreground",children:[(0,eb.jsx)("th",{className:"px-3 py-2 font-medium",children:"名称"}),(0,eb.jsx)("th",{className:"px-3 py-2 font-medium",children:"状态"}),(0,eb.jsx)("th",{className:"px-3 py-2 font-medium",children:"详情"})]})}),(0,eb.jsx)("tbody",{children:0===t.length?(0,eb.jsx)("tr",{children:(0,eb.jsx)("td",{colSpan:3,className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"暂未发现机器。登录 Hub 账户并把机器加入同一工作组后,这里会自动列出。"})}):t.map(e=>{let t=es8[e.state??"offline"];return(0,eb.jsxs)("tr",{className:"border-b border-border/60 last:border-b-0",children:[(0,eb.jsx)("td",{className:"px-3 py-2 font-medium",children:e.label}),(0,eb.jsx)("td",{className:"px-3 py-2",children:(0,eb.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,eb.jsx)("span",{className:`size-2 rounded-full ${t.dot}`}),t.label]})}),(0,eb.jsx)("td",{className:"px-3 py-2 text-muted-foreground",children:e.meta??"—"})]},e.id)})})]})})]}),(0,eb.jsxs)("section",{className:"rounded-xl border bg-card",children:[(0,eb.jsx)("div",{className:"border-b border-border/60 px-3 py-2 text-sm font-medium",children:"连接"}),(0,eb.jsx)("div",{className:"overflow-x-auto",children:(0,eb.jsxs)("table",{className:"w-full min-w-[32rem] border-collapse text-sm",children:[(0,eb.jsx)("thead",{children:(0,eb.jsxs)("tr",{className:"text-left text-xs text-muted-foreground",children:[(0,eb.jsx)("th",{className:"px-3 py-2 font-medium",children:"来源"}),(0,eb.jsx)("th",{className:"px-3 py-2 font-medium",children:"目标"}),(0,eb.jsx)("th",{className:"px-3 py-2 font-medium",children:"类型"}),(0,eb.jsx)("th",{className:"px-3 py-2 font-medium",children:"详情 / 延迟"})]})}),(0,eb.jsx)("tbody",{children:0===n.length?(0,eb.jsx)("tr",{children:(0,eb.jsx)("td",{colSpan:4,className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"暂无连接。"})}):n.map(e=>{let t=es7[e.kind??"direct"],n=e.label??e.meta;return(0,eb.jsxs)("tr",{className:"border-b border-border/60 last:border-b-0",children:[(0,eb.jsx)("td",{className:"px-3 py-2",children:a(e.from)}),(0,eb.jsx)("td",{className:"px-3 py-2",children:a(e.to)}),(0,eb.jsx)("td",{className:"px-3 py-2",children:(0,eb.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,eb.jsx)("span",{className:`size-2 rounded-full ${t.dot}`}),t.label]})}),(0,eb.jsx)("td",{className:"px-3 py-2 text-muted-foreground",children:n??"—"})]},e.id)})})]})})]})]})}let ect=(0,ek.default)("gift",[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]]),ecn=(0,ek.default)("trending-up",[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]]),ecr=[{value:"24h",label:"近 24 小时"},{value:"7d",label:"近 7 天"},{value:"30d",label:"近 30 天"}];function eca(){return(0,eb.jsx)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:(0,eb.jsx)(eci,{})})})}function eci(){let{user:e}=ti(),[t,n]=ew.useState(null),[r,a]=ew.useState(!0),[i,o]=ew.useState(null),[l,s]=ew.useState("7d"),[c,d]=ew.useState("all"),[u,f]=ew.useState([]),[m,h]=ew.useState([]),[p,g]=ew.useState(!0),[x,v]=ew.useState(""),[b,y]=ew.useState(!1),[w,j]=ew.useState(null),k=ew.useCallback(async()=>{a(!0),o(null);try{n(await e4())}catch(e){o(e instanceof Error?e.message:"读取余额失败")}finally{a(!1)}},[]);ew.useEffect(()=>{e&&(k(),e8().then(e=>f(e.models)).catch(()=>f([])))},[e,k]),ew.useEffect(()=>{if(!e)return;let t=!1;return g(!0),e3(l,"all"===c?void 0:c).then(e=>{t||h(e.points)}).catch(()=>{t||h([])}).finally(()=>{t||g(!1)}),()=>{t=!0}},[e,l,c]);let N=ew.useMemo(()=>m.reduce((e,t)=>(e.costMicro+=t.costMicro,e.requests+=t.requests,e.totalTokens+=t.totalTokens,e),{costMicro:0,requests:0,totalTokens:0}),[m]),S=ew.useMemo(()=>m.map(e=>{var t;let n;return{label:(t=e.time,n=new Date(t),"24h"===l?n.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit"})),cost:e.costMicro/1e6,requests:e.requests,tokens:e.totalTokens}}),[m,l]);async function C(){let e=x.trim();if(e){y(!0),j(null);try{let t=await e6(e);j({kind:"ok",text:`兑换成功,到账 ${e2(t.valueMicro)}`}),v(""),n(e=>e?{...e,balanceMicro:t.balanceMicro,balanceUsd:t.balanceMicro/1e6}:e)}catch(e){j({kind:"err",text:e instanceof Error?e.message:"兑换失败,请检查兑换码"})}finally{y(!1)}}}return e?(0,eb.jsxs)("div",{className:"grid gap-6 text-foreground",children:[(0,eb.jsx)("div",{className:"min-w-0",children:(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"查看官方渠道的账户余额、调用用量,并使用兑换码充值。"})}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)(es5,{className:"size-4 text-muted-foreground"}),(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"账户余额"})]}),(0,eb.jsxs)(eO.Button,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void k(),disabled:r,children:[r?(0,eb.jsx)(eM,{className:"animate-spin"}):(0,eb.jsx)(yt,{}),"刷新"]})]}),i?(0,eb.jsx)("p",{className:"text-xs text-destructive",children:i}):(0,eb.jsx)("p",{className:"text-3xl font-semibold tracking-tight",children:r&&!t?"—":e2(t?.balanceMicro??0,4)})]}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)(ect,{className:"size-4 text-muted-foreground"}),(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"兑换码充值"})]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"输入兑换码,金额将立即计入账户余额。"}),(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)(eA,{value:x,onChange:e=>v(e.target.value),placeholder:"请输入兑换码",className:"font-mono",onKeyDown:e=>{"Enter"===e.key&&C()}}),(0,eb.jsxs)(eO.Button,{className:"shrink-0",onClick:()=>void C(),disabled:b||!x.trim(),children:[b?(0,eb.jsx)(eM,{className:"animate-spin"}):null,"兑换"]})]}),w?(0,eb.jsx)("p",{className:(0,ez.cn)("text-xs","ok"===w.kind?"text-primary":"text-destructive"),children:w.text}):null]}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)(ecn,{className:"size-4 text-muted-foreground"}),(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"用量趋势"})]}),(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsxs)(gU,{value:c,onValueChange:d,children:[(0,eb.jsx)(xj,{size:"sm",className:"w-44",children:(0,eb.jsx)(gG,{placeholder:"全部模型"})}),(0,eb.jsxs)(xS,{children:[(0,eb.jsx)(xC,{value:"all",children:"全部模型"}),u.map(e=>(0,eb.jsx)(xC,{value:e.id,children:e.displayName||e.id},e.id))]})]}),(0,eb.jsxs)(gU,{value:l,onValueChange:s,children:[(0,eb.jsx)(xj,{size:"sm",className:"w-32",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:ecr.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})]})]}),(0,eb.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,eb.jsx)(eco,{label:"花费",value:e2(N.costMicro,4)}),(0,eb.jsx)(eco,{label:"请求数",value:N.requests.toLocaleString("zh-CN")}),(0,eb.jsx)(eco,{label:"Tokens",value:N.totalTokens.toLocaleString("zh-CN")})]}),(0,eb.jsx)("div",{className:"h-56 w-full",children:p&&0===m.length?(0,eb.jsx)("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:(0,eb.jsx)(eM,{className:"size-5 animate-spin"})}):0===S.length?(0,eb.jsx)("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:"所选区间暂无用量记录"}):(0,eb.jsx)(Mj,{width:"100%",height:"100%",children:(0,eb.jsxs)(JB,{data:S,margin:{top:8,right:8,left:0,bottom:0},children:[(0,eb.jsx)("defs",{children:(0,eb.jsxs)("linearGradient",{id:"usageCost",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,eb.jsx)("stop",{offset:"5%",stopColor:"var(--color-primary)",stopOpacity:.35}),(0,eb.jsx)("stop",{offset:"95%",stopColor:"var(--color-primary)",stopOpacity:0})]})}),(0,eb.jsx)(Qf,{strokeDasharray:"3 3",stroke:"var(--color-border)",vertical:!1}),(0,eb.jsx)(QE,{dataKey:"label",tick:{fontSize:11},stroke:"var(--color-muted-foreground)",tickLine:!1,axisLine:!1}),(0,eb.jsx)(Q$,{tick:{fontSize:11},stroke:"var(--color-muted-foreground)",tickLine:!1,axisLine:!1,width:48,tickFormatter:e=>`$${e.toFixed(2)}`}),(0,eb.jsx)(VZ,{contentStyle:{borderRadius:8,border:"1px solid var(--color-border)",background:"var(--color-popover)",fontSize:12},formatter:e=>[`$${Number(e).toFixed(4)}`,"花费"]}),(0,eb.jsx)(JR,{type:"monotone",dataKey:"cost",stroke:"var(--color-primary)",strokeWidth:2,fill:"url(#usageCost)"})]})})})]})]}):(0,eb.jsxs)("div",{className:"flex flex-col items-center gap-3 rounded-lg border bg-card py-16 text-center text-foreground",children:[(0,eb.jsx)(es5,{className:"size-8 text-muted-foreground/40"}),(0,eb.jsx)("p",{className:"text-sm font-medium",children:"未登录 Hub 账户"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"请先在「系统设置 · Hub 账户」中登录,再查看余额与用量。"})]})}function eco({label:e,value:t}){return(0,eb.jsxs)("div",{className:"rounded-md bg-muted/55 px-3 py-2",children:[(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:e}),(0,eb.jsx)("p",{className:"mt-0.5 truncate text-sm font-semibold",children:t})]})}let ecl=(0,ek.default)("circle-arrow-up",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);function ecs(e,t){if(e.isLocal)return(0,eT.localAPIURL)(t);let n=t.replace(/^\/v1(?=\/)/,"");return(0,eT.localAPIURL)(`/v1/remote/${e.id}${n}`)}async function ecc(e){try{let t=await fetch(`https://registry.npmjs.org/@vantaloom/runtime-${e}`,{headers:{Accept:"application/vnd.npm.install-v1+json"},cache:"no-store"});if(!t.ok)return;let n=await t.json();return n?.["dist-tags"]?.latest}catch{return}}function ecd(){return(0,eb.jsx)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:(0,eb.jsx)(ecu,{})})})}function ecu(){let[e,t]=ew.useState([]),[n,r]=ew.useState(!0),a=ew.useRef(!0),i=ew.useCallback((e,n)=>{t(t=>t.map(t=>t.machine.id===e?{...t,...n}:t))},[]),o=ew.useCallback(async()=>{r(!0);let e=[];try{let t=await fetch((0,eT.localAPIURL)("/v1/remote/machines"),{cache:"no-store"});e=(await t.json()).machines??[]}catch{e=[]}a.current&&(t(e.map(e=>({machine:e,loading:!0}))),r(!1),await Promise.all(e.map(async e=>{if(!e.isLocal&&"online"!==e.status){a.current&&i(e.id,{loading:!1,error:"离线"});return}try{let t,n=await fetch(ecs(e,"/v1/runtime/info"),{cache:"no-store"});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.text();try{t=JSON.parse(r)}catch{throw Error("该机器运行时过旧,不支持版本检测")}let o=await ecc(t.platform);a.current&&i(e.id,{info:t,latest:o,loading:!1})}catch(t){a.current&&i(e.id,{loading:!1,error:t instanceof Error?t.message:"无法获取版本"})}})))},[i]);async function l(e){if(e.info&&!e.updating){i(e.machine.id,{updating:!0});try{await fetch(ecs(e.machine,"/v1/runtime/update"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({version:e.latest})})}catch{}window.setTimeout(()=>{a.current&&o()},25e3)}}return ew.useEffect(()=>(a.current=!0,o(),()=>{a.current=!1}),[o]),(0,eb.jsxs)("div",{className:"flex flex-col gap-5 text-foreground","data-tour":"check-update",children:[(0,eb.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,eb.jsx)("div",{children:(0,eb.jsx)("p",{className:"text-sm text-muted-foreground",children:"工作组内各机器的运行时版本与可用更新。点击「立即更新」可让对应机器自动更新(该机器会短暂重启)。"})}),(0,eb.jsxs)(eO.Button,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void o(),disabled:n,children:[(0,eb.jsx)(yt,{className:(0,ez.cn)("size-4",n&&"animate-spin")}),"刷新"]})]}),n&&0===e.length?(0,eb.jsxs)("div",{className:"flex items-center justify-center gap-2 rounded-xl border bg-card p-8 text-sm text-muted-foreground",children:[(0,eb.jsx)(eM,{className:"size-4 animate-spin"})," 正在获取机器列表…"]}):0===e.length?(0,eb.jsx)("div",{className:"rounded-xl border bg-card p-8 text-center text-sm text-muted-foreground",children:"暂无可用机器。"}):(0,eb.jsx)("div",{className:"flex flex-col gap-2",children:e.map(e=>{let t=!!e.info&&!!e.latest&&e.latest!==e.info.version;return(0,eb.jsxs)("div",{className:"flex items-center gap-4 rounded-xl border bg-card px-4 py-3",children:[(0,eb.jsx)(eP,{className:"size-5 shrink-0 text-muted-foreground"}),(0,eb.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)("span",{className:"truncate text-sm font-medium",children:e.machine.name}),e.machine.isLocal?(0,eb.jsx)("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:"本机"}):null]}),(0,eb.jsx)("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:e.loading?"读取版本中…":e.error?(0,eb.jsx)("span",{className:"text-amber-600",children:e.error}):(0,eb.jsxs)(eb.Fragment,{children:[function(e){switch(e){case"windows":return"Windows";case"darwin":return"macOS";case"linux":return"Linux";case"android":return"Android";default:return e||"未知"}}(e.info?.os??e.machine.platform??"")," · 当前 ",(0,eb.jsx)("span",{className:"font-mono",children:e.info?.version??"?"}),e.latest?(0,eb.jsxs)(eb.Fragment,{children:[" · 最新 ",(0,eb.jsx)("span",{className:"font-mono",children:e.latest})]}):null,e.info?.updatedAt?(0,eb.jsxs)(eb.Fragment,{children:[" · 更新于 ",function(e){if(!e)return"—";let t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t):"—"}(e.info.updatedAt)]}):null]})})]}),e.loading?(0,eb.jsx)(eM,{className:"size-4 animate-spin text-muted-foreground"}):e.updating?(0,eb.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-primary",children:[(0,eb.jsx)(eM,{className:"size-4 animate-spin"})," 更新中…"]}):t?(0,eb.jsxs)(eO.Button,{size:"sm",onClick:()=>void l(e),children:[(0,eb.jsx)(ecl,{className:"size-4"})," 立即更新"]}):e.info?(0,eb.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,eb.jsx)(eI,{className:"size-4 text-emerald-500"})," 已是最新"]}):null]},e.machine.id)})}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"最新版本号来自 npm(@vantaloom/runtime-<平台>)。更新过程中该机器会停止并重启运行时, 若你的手机正连着它会短暂断开,更新完成后重新连接即可。"})]})}let ecf=(0,ek.default)("image-plus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]),ecm=[{value:"bug",label:"功能异常"},{value:"feature",label:"功能建议"},{value:"billing",label:"计费与余额"},{value:"other",label:"其他"}],ech=Object.fromEntries(ecm.map(e=>[e.value,e.label])),ecp={pending:{label:"待审批",variant:"secondary"},preparing:{label:"准备完成",variant:"outline"},done:{label:"已完成",variant:"default"},noplan:{label:"暂时无计划",variant:"secondary"}};function ecg(){return(0,eb.jsx)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:(0,eb.jsx)(ecx,{})})})}function ecx(){let{user:e}=ti(),[t,n]=ew.useState(""),[r,a]=ew.useState("bug"),[i,o]=ew.useState(""),[l,s]=ew.useState([]),[c,d]=ew.useState(!1),[u,f]=ew.useState(null),[m,h]=ew.useState(!1),p=ew.useRef(null),[g,x]=ew.useState([]),[v,b]=ew.useState(!0),[y,w]=ew.useState(null),j=ew.useCallback(async()=>{b(!0);try{let e=await e9();x(e.issues)}catch{x([])}finally{b(!1)}},[]);function k(e){let t=Array.from(e).filter(e=>e.type.startsWith("image/"));f(null),s(e=>{let n=[...e];for(let e of t){if(n.length>=10){f({kind:"err",text:`最多上传 10 张图片`});break}if(e.size>8388608){f({kind:"err",text:`「${e.name}」过大(上限 8MB)`});continue}n.push({id:`${e.name}-${e.size}-${n.length}`,file:e,url:URL.createObjectURL(e)})}return n})}async function N(){if(!t.trim())return void f({kind:"err",text:"请填写标题"});d(!0),f(null);try{let{issue:e}=await e7({title:t.trim(),type:r,content:i.trim()}),c=!1;for(let t of l)try{await te(e.id,t.file)}catch{c=!0}f({kind:"ok",text:c?"反馈已提交,但部分图片上传失败,请在下方列表确认":"反馈已提交,感谢您的反馈!"}),n(""),a("bug"),o(""),l.forEach(e=>URL.revokeObjectURL(e.url)),s([]),j()}catch(e){f({kind:"err",text:e instanceof Error?e.message:"提交失败,请重试"})}finally{d(!1)}}return ew.useEffect(()=>{e&&j()},[e,j]),ew.useEffect(()=>()=>{l.forEach(e=>URL.revokeObjectURL(e.url))},[]),e?(0,eb.jsxs)("div",{className:"grid gap-6 text-foreground",children:[(0,eb.jsx)("div",{className:"min-w-0",children:(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"提交功能异常、建议或计费问题,我们会在看板中跟进处理。"})}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"标题"}),(0,eb.jsx)(eA,{value:t,onChange:e=>n(e.target.value),maxLength:120,placeholder:"简要描述问题"})]}),(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"类型"}),(0,eb.jsxs)(gU,{value:r,onValueChange:a,children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:ecm.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})]}),(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"详细描述"}),(0,eb.jsx)(w2,{value:i,onChange:e=>o(e.target.value),rows:5,placeholder:"详细描述问题的复现步骤、期望行为等",onPaste:e=>{let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith("image/"));t.length>0&&(e.preventDefault(),k(t))}})]}),(0,eb.jsxs)("div",{className:(0,ez.cn)("grid gap-3 rounded-lg border border-dashed p-3 transition-colors",m?"border-primary bg-primary/5":"border-input"),onDragOver:e=>{e.preventDefault(),h(!0)},onDragLeave:()=>h(!1),onDrop:e=>{e.preventDefault(),h(!1),e.dataTransfer.files.length>0&&k(e.dataTransfer.files)},children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,eb.jsxs)("p",{className:"text-xs text-muted-foreground",children:["可拖拽、粘贴或选择图片(最多 ",10," 张,单张 ≤ 8MB)"]}),(0,eb.jsxs)(eO.Button,{type:"button",variant:"outline",size:"sm",className:"shrink-0",onClick:()=>p.current?.click(),children:[(0,eb.jsx)(ecf,{}),"添加图片"]}),(0,eb.jsx)("input",{ref:p,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&k(e.target.files),e.target.value=""}})]}),l.length>0?(0,eb.jsx)("div",{className:"flex flex-wrap gap-2",children:l.map(e=>(0,eb.jsxs)("div",{className:"relative size-16 overflow-hidden rounded-md border",children:[(0,eb.jsx)("img",{src:e.url,alt:e.file.name,className:"size-full object-cover"}),(0,eb.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.id,void s(e=>{let n=e.find(e=>e.id===t);return n&&URL.revokeObjectURL(n.url),e.filter(e=>e.id!==t)})},className:"absolute right-0.5 top-0.5 rounded-full bg-black/55 p-0.5 text-white hover:bg-black/75","aria-label":"移除图片",children:(0,eb.jsx)(fV.XIcon,{className:"size-3"})})]},e.id))}):null]}),u?(0,eb.jsx)("p",{className:(0,ez.cn)("text-xs","ok"===u.kind?"text-primary":"text-destructive"),children:u.text}):null,(0,eb.jsx)("div",{className:"flex justify-end",children:(0,eb.jsxs)(eO.Button,{onClick:()=>void N(),disabled:c||!t.trim(),children:[c?(0,eb.jsx)(eM,{className:"animate-spin"}):(0,eb.jsx)(eoI,{}),"提交反馈"]})})]}),(0,eb.jsxs)("section",{className:"grid gap-3",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"我的反馈"}),v?(0,eb.jsx)("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:(0,eb.jsx)(eM,{className:"size-5 animate-spin"})}):0===g.length?(0,eb.jsx)("p",{className:"rounded-lg border bg-card p-6 text-center text-xs text-muted-foreground",children:"你还没有提交过反馈。"}):g.map(e=>{let t=ecp[e.status]??{label:e.status,variant:"secondary"};return(0,eb.jsxs)("article",{className:"grid gap-2 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,eb.jsx)("p",{className:"min-w-0 flex-1 break-words text-sm font-medium",children:e.title}),(0,eb.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[(0,eb.jsx)(Vp,{variant:"outline",children:ech[e.type]??e.type}),(0,eb.jsx)(Vp,{variant:t.variant,children:t.label})]})]}),e.content?(0,eb.jsx)("p",{className:"whitespace-pre-wrap break-words text-xs text-muted-foreground",children:e.content}):null,e.images.length>0?(0,eb.jsx)("div",{className:"flex flex-wrap gap-2",children:e.images.map(t=>(0,eb.jsx)("button",{type:"button",className:"size-16 overflow-hidden rounded-md border",onClick:()=>w({issueId:e.id,imageId:t.id}),children:(0,eb.jsx)(ecy,{issueId:e.id,imageId:t.id})},t.id))}):null,(0,eb.jsx)("p",{className:"text-[11px] text-muted-foreground",children:new Date(e.createdAt).toLocaleString("zh-CN")})]},e.id)})]}),(0,eb.jsx)(ecv,{}),(0,eb.jsx)(dX,{open:null!==y,onOpenChange:e=>{e||w(null)},children:(0,eb.jsx)(fU,{className:"max-w-3xl",children:y?(0,eb.jsx)(ecw,{issueId:y.issueId,imageId:y.imageId,className:"max-h-[75vh] w-full object-contain"}):null})})]}):(0,eb.jsxs)("div",{className:"grid gap-6 text-foreground",children:[(0,eb.jsx)(ecv,{}),(0,eb.jsxs)("div",{className:"flex flex-col items-center gap-3 rounded-lg border bg-card py-16 text-center",children:[(0,eb.jsx)(kM,{className:"size-8 text-muted-foreground/40"}),(0,eb.jsx)("p",{className:"text-sm font-medium",children:"未登录 Hub 账户"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"请先在「系统设置 · Hub 账户」中登录,再提交问题反馈。"})]})]})}function ecv(){let[e,t]=ew.useState(!1),[n,r]=ew.useState(!0),[a,i]=ew.useState(!1),[o,l]=ew.useState(null);async function s(n){if(!a){t(n),i(!0),l(null);try{let e=await ks({telemetry:{enabled:n}});t(e.telemetry?.enabled??n)}catch(n){t(e),l(n instanceof Error?n.message:"保存失败,请重试")}finally{i(!1)}}}return ew.useEffect(()=>{let e=!1;return async function(){try{let n=await kl();e||t(n.telemetry?.enabled??!1)}catch{}finally{e||r(!1)}}(),()=>{e=!0}},[]),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)(uV,{className:"size-4 text-muted-foreground"}),(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"错误诊断上报"})]}),(0,eb.jsxs)("p",{className:"text-xs text-muted-foreground",children:["默认",(0,eb.jsx)("span",{className:"font-medium text-foreground",children:"关闭"}),"。开启后,",(0,eb.jsx)("span",{className:"font-medium text-foreground",children:"仅当出现网络错误时"}),",应用会把少量非隐私设备信息(系统 / 架构 / 版本 / 代理模式 / 网络开关 等) 与",(0,eb.jsx)("span",{className:"font-medium text-foreground",children:"完整错误文本"}),"上报到 Hub,用于协助排查连接问题。"]}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"允许错误诊断上报"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"关闭时应用不会进行任何遥测网络请求。"})]}),(0,eb.jsx)(bG,{checked:e,disabled:n||a,onCheckedChange:e=>void s(e)})]}),(0,eb.jsx)("div",{className:"rounded-md bg-muted/50 px-3 py-2",children:(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"绝不会上报:API 密钥、代理地址、文件路径、对话内容,以及你的 Hub 身份。"})}),o?(0,eb.jsx)("p",{className:"text-xs text-destructive",children:o}):null]})}function ecb(e,t){let[n,r]=ew.useState(null);return ew.useEffect(()=>{let n=!0,a=null;return tt(e,t).then(e=>{a=e,n?r(e):URL.revokeObjectURL(e)}).catch(()=>{}),()=>{n=!1,a&&URL.revokeObjectURL(a)}},[e,t]),n}function ecy({issueId:e,imageId:t}){let n=ecb(e,t);return n?(0,eb.jsx)("img",{src:n,alt:"",className:"size-full object-cover"}):(0,eb.jsx)("div",{className:"flex size-full items-center justify-center bg-muted"})}function ecw({issueId:e,imageId:t,className:n}){let r=ecb(e,t);return r?(0,eb.jsx)("img",{src:r,alt:"",className:n}):(0,eb.jsx)("div",{className:"flex h-64 items-center justify-center text-muted-foreground",children:(0,eb.jsx)(eM,{className:"size-5 animate-spin"})})}function ecj(){return(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex flex-col gap-0.5 border-b px-4 py-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(Yw,{}),"系统设置"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:"系统设置"})]}),(0,eb.jsx)(etm,{sections:[{id:"topology",title:"组网关系",icon:(0,eb.jsx)(enH,{}),content:(0,eb.jsx)(ece,{})},{id:"update",title:"检查更新",icon:(0,eb.jsx)(yt,{}),content:(0,eb.jsx)(ecu,{})},{id:"account",title:"账户设置",icon:(0,eb.jsx)(eC,{}),content:(0,eb.jsx)(esa,{})},{id:"balance",title:"余额用量",icon:(0,eb.jsx)(es5,{}),content:(0,eb.jsx)(eci,{})},{id:"feedback",title:"问题反馈",icon:(0,eb.jsx)(kM,{}),content:(0,eb.jsx)(ecx,{})}],defaultSectionId:"topology",labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto"})]})}let eck=(0,ek.default)("pause",[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]]);function ecN(e){if(!Number.isFinite(e)||e<0)return"—";if(e<1024)return`${e} B`;let t=["KB","MB","GB","TB"],n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n.toFixed(n>=100?0:1)} ${t[r]}`}function ecS({status:e}){switch(e){case"active":return(0,eb.jsx)(Vp,{variant:"default",children:"下载中"});case"complete":return(0,eb.jsx)(Vp,{className:"border-transparent bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",children:"已完成"});case"error":return(0,eb.jsx)(Vp,{variant:"destructive",children:"失败"});case"paused":return(0,eb.jsx)(Vp,{variant:"secondary",children:"已暂停"});case"canceled":return(0,eb.jsx)(Vp,{variant:"outline",children:"已取消"});default:return(0,eb.jsx)(Vp,{variant:"outline",children:"等待中"})}}let ecC=["complete","error","canceled"];function ecM({download:e}){let{status:t,percent:n,totalBytes:r}=e,a=Math.max(0,Math.min(100,n));return r<0&&"active"===t?(0,eb.jsx)("div",{className:"relative h-1.5 w-full overflow-hidden rounded-full bg-muted",children:(0,eb.jsx)("div",{className:(0,ez.cn)("absolute inset-y-0 w-1/3 rounded-full bg-primary/70","vtl-download-indeterminate")})}):(0,eb.jsx)("div",{className:"relative h-1.5 w-full overflow-hidden rounded-full bg-muted",children:(0,eb.jsx)("div",{className:(0,ez.cn)("h-full rounded-full transition-all","error"===t?"bg-destructive":"complete"===t?"bg-emerald-500":"paused"===t?"bg-muted-foreground/60":"bg-primary","active"===t&&"vtl-download-stripes bg-[length:1rem_1rem]"),style:{width:`${a}%`}})})}function ecE({download:e}){var t,n,r;let a,[i,o]=ew.useState(!1),l=ew.useCallback(async e=>{o(!0);try{await e()}catch{}finally{o(!1)}},[]),{status:s}=e,c="active"===s?!Number.isFinite(t=e.speedBps)||t<=0?"":`${ecN(t)}/s`:"",d="active"===s?function(e){if(!Number.isFinite(e)||e<0)return"";let t=Math.round(e),n=Math.floor(t/3600),r=Math.floor(t%3600/60),a=t%60;return n>0?`${n}:${String(r).padStart(2,"0")}:${String(a).padStart(2,"0")}`:`${String(r).padStart(2,"0")}:${String(a).padStart(2,"0")}`}(e.etaSeconds):"",u=!(e.totalBytes<0&&"active"===s),f="active"===s,m="paused"===s,h="error"===s||"canceled"===s,p="active"===s||"paused"===s||"waiting"===s,g=ecC.includes(s);return(0,eb.jsxs)("div",{className:"grid gap-2 rounded-lg border bg-card p-3",children:[(0,eb.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eb.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,eb.jsx)("span",{className:"truncate text-sm font-medium text-foreground",children:e.label||e.url||e.id}),(0,eb.jsx)(ecS,{status:s}),e.attempt>1&&(0,eb.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:["重试 ",e.attempt]})]}),e.dest&&(0,eb.jsx)("p",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:e.dest})]}),(0,eb.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[i&&(0,eb.jsx)(HR,{className:"size-3.5"}),f&&(0,eb.jsx)(eO.Button,{size:"icon",variant:"ghost",className:"size-7",disabled:i,title:"暂停","aria-label":"暂停",onClick:()=>l(()=>h2(e.id,"pause")),children:(0,eb.jsx)(eck,{className:"size-3.5"})}),m&&(0,eb.jsx)(eO.Button,{size:"icon",variant:"ghost",className:"size-7",disabled:i,title:"继续","aria-label":"继续",onClick:()=>l(()=>h2(e.id,"resume")),children:(0,eb.jsx)(HE,{className:"size-3.5"})}),h&&(0,eb.jsx)(eO.Button,{size:"icon",variant:"ghost",className:"size-7",disabled:i,title:"重试","aria-label":"重试",onClick:()=>l(()=>h2(e.id,"retry")),children:(0,eb.jsx)(yt,{className:"size-3.5"})}),p&&(0,eb.jsx)(eO.Button,{size:"icon",variant:"ghost",className:"size-7",disabled:i,title:"取消","aria-label":"取消",onClick:()=>l(()=>h2(e.id,"cancel")),children:(0,eb.jsx)(fV.XIcon,{className:"size-3.5"})}),g&&(0,eb.jsx)(eO.Button,{size:"icon",variant:"ghost",className:"size-7 text-muted-foreground hover:text-destructive",disabled:i,title:"移除","aria-label":"移除",onClick:()=>l(()=>h2(e.id,"remove")),children:(0,eb.jsx)(yn,{className:"size-3.5"})})]})]}),(0,eb.jsx)(ecM,{download:e}),(0,eb.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[u&&(0,eb.jsxs)("span",{className:"tabular-nums",children:[Math.round(e.percent),"%"]}),(0,eb.jsx)("span",{className:"tabular-nums",children:(n=e.downloadedBytes,r=e.totalBytes,a=ecN(n),r<0?a:`${a} / ${ecN(r)}`)}),c&&(0,eb.jsx)("span",{className:"tabular-nums",children:c}),d&&(0,eb.jsxs)("span",{className:"tabular-nums",children:["剩余 ",d]}),e.connections>0&&(0,eb.jsxs)("span",{className:"tabular-nums",children:[e.connections," 连接"]})]}),"error"===s&&e.error&&(0,eb.jsx)("p",{className:"text-[11px] text-destructive",children:e.error})]})}function ecI(){let[e,t]=ew.useState([]),[n,r]=ew.useState("loading"),[a,i]=ew.useState(0),o=ew.useCallback(()=>{r("loading"),i(e=>e+1)},[]);return(ew.useEffect(()=>{let e,n=!1,a=new AbortController,i=e=>{n||(t(e),r("ready"))};async function o(){try{let e=await hQ({signal:a.signal});if(n)return;t(e.downloads),r("ready")}catch(e){if(n||a.signal.aborted)return;if(e instanceof hJ)return void r("unavailable")}try{await h0(i,{signal:a.signal}),n||l()}catch(e){if(n||a.signal.aborted)return;if(e instanceof hJ)return void r("unavailable");r(e=>"ready"===e?"ready":"error"),l()}}function l(){n||(e=setTimeout(()=>{n||o()},2e3))}return o(),()=>{n=!0,a.abort(),e&&clearTimeout(e)}},[a]),"loading"===n)?(0,eb.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border bg-card p-6 text-sm text-muted-foreground",children:[(0,eb.jsx)(HR,{className:"size-4"}),"正在获取下载状态…"]}):"unavailable"===n||"error"===n?(0,eb.jsxs)("div",{className:"grid gap-3 rounded-lg border border-destructive/30 bg-destructive/5 p-6",children:[(0,eb.jsx)("p",{className:"text-sm text-destructive",children:"无法获取下载状态"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"请确认本机运行时已启动,稍后重试。"}),(0,eb.jsx)("div",{children:(0,eb.jsxs)(eO.Button,{variant:"outline",size:"sm",onClick:o,children:[(0,eb.jsx)(yt,{className:"size-3.5"}),"重试"]})})]}):0===e.length?(0,eb.jsx)("div",{className:"rounded-lg border bg-card p-10 text-center text-sm text-muted-foreground",children:"暂无下载任务"}):(0,eb.jsx)("div",{className:"grid gap-2",children:e.map(e=>(0,eb.jsx)(ecE,{download:e},e.id))})}function ecP({label:e,description:t,value:n,min:r,max:a,onChange:i,disabled:o}){return(0,eb.jsxs)("label",{className:"grid gap-1.5",children:[(0,eb.jsx)("span",{className:"text-xs font-medium text-foreground",children:e}),t&&(0,eb.jsx)("span",{className:"text-[11px] text-muted-foreground",children:t}),(0,eb.jsx)(eA,{type:"number",inputMode:"numeric",min:r,max:a,value:Number.isFinite(n)?n:0,disabled:o,onChange:e=>{let t=Number(e.target.value);if(Number.isNaN(t))return;let n=t;void 0!==r&&(n=Math.max(r,n)),void 0!==a&&(n=Math.min(a,n)),i(n)},className:"max-w-[12rem]"})]})}function ecO(){let[e,t]=ew.useState(null),[n,r]=ew.useState("loading"),[a,i]=ew.useState(!1),[o,l]=ew.useState(!1),[s,c]=ew.useState(null),[d,u]=ew.useState(0),f=ew.useCallback(()=>{r("loading"),u(e=>e+1)},[]);ew.useEffect(()=>{let e=!1,n=new AbortController;return async function(){try{let a=await h5({signal:n.signal});if(e)return;t(a),r("ready")}catch(t){if(e||n.signal.aborted)return;r(t instanceof hJ?"unavailable":"error")}}(),()=>{e=!0,n.abort()}},[d]);let m=ew.useCallback((e,n)=>{t(t=>t?{...t,[e]:n}:t),l(!1)},[]),h=ew.useCallback(async()=>{if(e){i(!0),c(null),l(!1);try{let n=await h4(e);t(n),l(!0)}catch{c("保存失败,请稍后重试。")}finally{i(!1)}}},[e]);return"loading"===n?(0,eb.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border bg-card p-6 text-sm text-muted-foreground",children:[(0,eb.jsx)(HR,{className:"size-4"}),"正在加载下载设置…"]}):"unavailable"!==n&&"error"!==n&&e?(0,eb.jsxs)("section",{className:"grid gap-4 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("label",{className:"grid gap-1.5",children:[(0,eb.jsx)("span",{className:"text-xs font-medium text-foreground",children:"下载目录"}),(0,eb.jsx)("span",{className:"text-[11px] text-muted-foreground",children:"下载文件的默认保存位置。"}),(0,eb.jsx)(eA,{type:"text",value:e.downloadDir,disabled:a,placeholder:"例如 D:\\\\Downloads",onChange:e=>m("downloadDir",e.target.value)})]}),(0,eb.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,eb.jsx)(ecP,{label:"最大同时下载数",description:"同时进行的任务数量上限。",value:e.maxConcurrentDownloads,min:1,max:32,disabled:a,onChange:e=>m("maxConcurrentDownloads",e)}),(0,eb.jsx)(ecP,{label:"单任务最大连接数",description:"单个任务的并发分段连接数(1–16)。",value:e.maxConnectionsPerTask,min:1,max:16,disabled:a,onChange:e=>m("maxConnectionsPerTask",e)}),(0,eb.jsx)(ecP,{label:"失败重试次数",description:"任务失败后的自动重试上限。",value:e.maxRetries,min:0,max:20,disabled:a,onChange:e=>m("maxRetries",e)})]}),(0,eb.jsxs)("label",{className:"grid gap-1.5",children:[(0,eb.jsx)("span",{className:"text-xs font-medium text-foreground",children:"代理"}),(0,eb.jsx)("span",{className:"text-[11px] text-muted-foreground",children:"下载使用的代理地址,留空则不使用代理。"}),(0,eb.jsx)(eA,{type:"text",value:e.proxy,disabled:a,placeholder:"例如 http://127.0.0.1:7890(留空=不使用)",onChange:e=>m("proxy",e.target.value)})]}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-lg border bg-background p-3",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("p",{className:"text-sm font-medium text-foreground",children:"校验文件哈希"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"下载完成后校验文件哈希以确保完整性。"})]}),(0,eb.jsx)(bG,{checked:e.verifyChecksums,disabled:a,onCheckedChange:e=>m("verifyChecksums",e),"aria-label":"校验文件哈希"})]}),(0,eb.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,eb.jsxs)(eO.Button,{size:"sm",disabled:a,onClick:h,children:[a?(0,eb.jsx)(HR,{className:"size-3.5"}):null,a?"正在保存…":"保存设置"]}),o&&!a&&(0,eb.jsx)("span",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"已保存"}),s&&(0,eb.jsx)("span",{className:"text-xs text-destructive",children:s})]})]}):(0,eb.jsxs)("div",{className:"grid gap-3 rounded-lg border border-destructive/30 bg-destructive/5 p-6",children:[(0,eb.jsx)("p",{className:"text-sm text-destructive",children:"无法获取下载设置"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"请确认本机运行时已启动,稍后重试。"}),(0,eb.jsx)("div",{children:(0,eb.jsxs)(eO.Button,{variant:"outline",size:"sm",onClick:f,children:[(0,eb.jsx)(yt,{className:"size-3.5"}),"重试"]})})]})}function ecz(){return(0,eb.jsxs)("div",{className:"grid gap-6","data-tour":"system-downloads",children:[(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsx)("h4",{className:"text-sm font-medium text-foreground",children:"下载任务"}),(0,eb.jsx)(ecI,{})]}),(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsx)("h4",{className:"text-sm font-medium text-foreground",children:"全局设置"}),(0,eb.jsx)(ecO,{})]})]})}function ecA(){return(0,eb.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:(0,eb.jsx)("div",{className:"mx-auto w-full max-w-3xl",children:(0,eb.jsxs)("div",{className:"grid gap-6",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsxs)("h3",{className:"flex items-center gap-2 text-base font-semibold tracking-normal",children:[(0,eb.jsx)(bJ,{className:"size-4"}),"下载"]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"管理本机的下载任务,并配置下载目录、并发与代理等全局选项。"})]}),(0,eb.jsx)(ecz,{})]})})})}let ecT=[{value:"system",label:"跟随系统",help:"读取操作系统的系统代理设置(Windows 注册表 / Clash「系统代理」模式)。注意:macOS / Linux 上没有系统代理读取能力,此项等价于「仅环境变量」。"},{value:"env",label:"仅环境变量",help:"只使用 HTTP_PROXY / HTTPS_PROXY / NO_PROXY 环境变量,忽略系统代理设置。"},{value:"direct",label:"直连",help:"不使用任何代理,直接连接。在「只能走代理」的网络环境下会失败。"},{value:"custom",label:"自定义",help:"手动指定代理地址(见下方)。注意:当前仅支持 http / https 代理(CONNECT 隧道),socks5 代理可能无法生效。"}];function ecR(e){let t=e.network;return{enableUTLS:t?.enableUTLS??!0,enableBrowserHeaders:t?.enableBrowserHeaders??!0,proxyMode:t?.proxyMode??"system",customProxyURL:t?.customProxyURL??"",retryCount:t?.retryCount??3,retryDelaysMs:t?.retryDelaysMs??[],enableFallback:t?.enableFallback??!0,streamIdleTimeoutMs:t?.streamIdleTimeoutMs??0}}function ecD(){let[e,t]=ew.useState(null),[n,r]=ew.useState(!0),[a,i]=ew.useState(!1),[o,l]=ew.useState(""),[s,c]=ew.useState(!1),[d,u]=ew.useState(null),f=ew.useRef(null);function m(e){t(t=>t?{...t,...e}:t),c(!0),u(null)}async function h(){if(e&&!a){i(!0),l("");try{let n=await ks({network:e});f.current=n,t(ecR(n)),c(!1),u(Date.now())}catch(e){l(e instanceof Error?e.message:"Save failed")}finally{i(!1)}}}if(ew.useEffect(()=>{!async function(){try{let e=await kl();f.current=e,t(ecR(e))}catch(e){l(e instanceof Error?e.message:"Failed to load config")}finally{r(!1)}}()},[]),n)return(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取网络设置"});if(!e)return(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"读取失败"}),(0,eb.jsx)(etJ,{children:o||"无法加载网络设置"})]});let p=ecT.find(t=>t.value===e.proxyMode),g=function(e){if(!e)return e;try{let t=new URL(e);return(t.username||t.password)&&(t.username=t.username?"***":"",t.password=t.password?"***":""),t.toString()}catch{return e.replace(/\/\/[^/@]+@/,"//***:***@")}}(e.customProxyURL??"");return(0,eb.jsxs)("div",{className:"grid gap-6 pb-20",children:[o?(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"错误"}),(0,eb.jsx)(etJ,{children:o})]}):null,(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"传输层伪装"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"模拟真实浏览器的 TLS 指纹与请求头,避免被 Cloudflare 等防护按机器人流量重置连接。"}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"启用 uTLS 指纹伪装"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"使用 Chrome 的 TLS ClientHello 指纹(JA3/JA4),绕过基于指纹的连接重置。建议保持开启。"})]}),(0,eb.jsx)(bG,{checked:e.enableUTLS,onCheckedChange:e=>m({enableUTLS:e})})]}),e.enableUTLS?null:(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(m0,{}),(0,eb.jsx)(etZ,{children:"已关闭 uTLS 指纹伪装"}),(0,eb.jsx)(etJ,{children:"关闭后部分 Cloudflare 渠道可能连接被重置(TCP reset / 握手失败)。仅在 uTLS 反而导致连接异常时关闭。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"启用浏览器请求头"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"为出站请求注入 Chrome 的 User-Agent / sec-ch-ua 等请求头,进一步降低被识别为机器人的概率。"})]}),(0,eb.jsx)(bG,{checked:e.enableBrowserHeaders,onCheckedChange:e=>m({enableBrowserHeaders:e})})]})]}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"代理模式"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"控制所有出站请求(模型列表拉取 + 对话流)如何解析代理。换机器表现不一时,通常是这里的问题。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"代理模式"}),(0,eb.jsxs)(gU,{value:e.proxyMode,onValueChange:e=>m({proxyMode:e}),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:ecT.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]}),p?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:p.help}):null]}),"custom"===e.proxyMode?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"自定义代理地址"}),(0,eb.jsx)(eA,{value:e.customProxyURL??"",onChange:e=>m({customProxyURL:e.currentTarget.value}),placeholder:"http://127.0.0.1:7890",spellCheck:!1,autoComplete:"off"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"仅支持 http / https 代理。若填写包含账号密码(user:pass),日志中会被脱敏处理。"}),g&&g!==e.customProxyURL?(0,eb.jsxs)("p",{className:"text-xs text-muted-foreground",children:["脱敏预览:",g]}):null]})]}):null]}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"重试与降级"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"请求因网络抖动(连接重置 / 网关 5xx)失败时的自动恢复策略。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"重试次数"}),(0,eb.jsxs)("span",{className:"text-sm tabular-nums text-muted-foreground",children:[e.retryCount," 次"]})]}),(0,eb.jsx)(enx,{value:[e.retryCount],onValueChange:([e])=>m({retryCount:e}),min:0,max:10,step:1}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"可重试的请求失败后自动重试的次数(仅在尚未产出内容时重试,避免重复输出)。设为 0 表示不重试。默认 3。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"启用降级回退"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"连接失败时自动逐级降级:uTLS → 直连 → 标准 TLS,绕开坏代理 / 回环 / 指纹被重置等问题。关闭后将严格按当前模式连接(便于排查真实错误)。"})]}),(0,eb.jsx)(bG,{checked:e.enableFallback,onCheckedChange:e=>m({enableFallback:e})})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"吐字超时(秒)"}),(0,eb.jsx)(eA,{type:"number",inputMode:"numeric",min:0,step:1,value:e.streamIdleTimeoutMs&&e.streamIdleTimeoutMs>0?Math.round(e.streamIdleTimeoutMs/1e3):0,onChange:e=>{let t=Number(e.currentTarget.value);m({streamIdleTimeoutMs:1e3*(Number.isFinite(t)&&t>0?Math.round(t):0)})},placeholder:"0",spellCheck:!1,autoComplete:"off",className:"w-32"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"上游超过该时间未返回任何内容则判定为错误并重试;0 = 不限制(默认)。常用值如 30 / 60 / 120 秒。"})]})]}),(0,eb.jsx)(env,{dirty:s,saving:a,savedAt:d,onSave:()=>void h(),onReset:function(){f.current&&(t(ecR(f.current)),c(!1),l(""))}})]})}function ec_(){return(0,eb.jsx)(ecD,{})}function ecL(){return(0,eb.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"shrink-0 border-b px-6 py-4",children:[(0,eb.jsx)("h2",{className:"text-base font-semibold tracking-normal",children:"网络设置"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"调整出站请求的传输伪装、代理模式与失败重试,以适配不同网络环境并应对 Cloudflare 连接异常。"})]}),(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-6",children:(0,eb.jsx)("div",{className:"mx-auto max-w-2xl",children:(0,eb.jsx)(ec_,{})})})]})}function ec$(){return(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex flex-col gap-0.5 border-b px-4 py-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(enH,{}),"网络与下载"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:"网络与下载"})]}),(0,eb.jsx)(etm,{sections:[{id:"network",title:"网络设置",icon:(0,eb.jsx)(enH,{}),content:(0,eb.jsx)(ec_,{})},{id:"downloads",title:"下载",icon:(0,eb.jsx)(bJ,{}),content:(0,eb.jsx)(ecz,{})}],defaultSectionId:"network",labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto"})]})}let ecF=(0,ek.default)("list-ordered",[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]]),ecB=[{value:"",label:"不使用(仅搜索引擎兜底)",help:"不接入 AI 搜索渠道,只用下方的搜索引擎兜底抓取。无需任何 Key。"},{value:"hub",label:"官方自带搜索(Hub)",help:"使用 Vantaloom Hub 的官方搜索(Grok 实时联网),无需自备 Key——直接用你的 Hub 登录额度,按次计费。需登录 Hub 账户。"},{value:"tavily",label:"Tavily(国际 · 为 LLM 优化)",help:"专为 AI agent 设计,结果干净、含摘要,免费额度较大。需走代理访问。在 tavily.com 获取 API Key。"},{value:"bocha",label:"博查 Bocha(国内 · 直连免代理)",help:"国产、为大模型设计的搜索 API,人民币计费、国内直连无需翻墙。在 bochaai.com 获取 API Key。"},{value:"brave",label:"Brave Search(国际 · 独立索引)",help:"独立网页索引,隐私友好、价格便宜。需走代理访问。在 brave.com/search/api 获取订阅 Token。"},{value:"serper",label:"Serper(国际 · Google 结果)",help:"Google 搜索结果转 JSON,便宜快速。需走代理访问。在 serper.dev 获取 API Key。"}],ecV=[{value:"bing",label:"Bing(默认,较稳定)"},{value:"duckduckgo",label:"DuckDuckGo"}],ecH=[{value:"auto",label:"自动(先 Jina 后 Firecrawl)",help:"默认。先用 Jina Reader(免费、轻),失败或为空时若配置了 Firecrawl Key 再用 Firecrawl 兜底。"},{value:"jina",label:"仅 Jina Reader",help:"只用 Jina Reader(r.jina.ai)。免费可用、有速率限制;填 Key 可提高限额。"},{value:"firecrawl",label:"仅 Firecrawl",help:"只用 Firecrawl(正文抽取更强),必须配置下方的 Firecrawl API Key。"}];function ecU(e){let t=e.search;return{enable:t?.enable??!0,provider:t?.provider??"",apiKey:t?.apiKey??"",endpoint:t?.endpoint??"",enableEngineFallback:t?.enableEngineFallback??!0,engine:t?.engine??"bing",defaultReader:t?.defaultReader??"auto",jinaApiKey:t?.jinaApiKey??"",firecrawlApiKey:t?.firecrawlApiKey??"",maxResults:t?.maxResults??8,githubToken:t?.githubToken??""}}function ecq({draft:e,update:t,hubUser:n}){let r=ecB.find(t=>t.value===(e.provider??""));return(0,eb.jsxs)("div",{className:"grid gap-6",children:[(0,eb.jsx)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"启用联网搜索工具"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"为智能体提供 联网搜索 + 网页阅读 能力(vantaloom_search),无需启动浏览器。即使不配置任何 Key,也能用下方的搜索引擎兜底 + Jina 阅读开箱即用。"})]}),(0,eb.jsx)(bG,{checked:e.enable,onCheckedChange:e=>t({enable:e})})]})}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"AI 搜索渠道"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"检索层:把关键词转成排序的「标题 / 链接 / 摘要」。配置后质量更好;不配置则只走下方搜索引擎兜底。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"搜索渠道"}),(0,eb.jsx)(x7,{value:e.provider?e.provider:"none",onValueChange:e=>t({provider:"none"===e?"":e}),options:ecB.map(e=>({value:e.value||"none",label:e.label})),title:"选择搜索渠道",className:"w-full"}),r?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:r.help}):null]}),e.provider&&"hub"!==e.provider?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"API Key"}),(0,eb.jsx)(eA,{value:e.apiKey??"",onChange:e=>t({apiKey:e.currentTarget.value}),placeholder:"搜索渠道 API Key",className:"font-mono text-xs",spellCheck:!1,autoComplete:"off"})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"自定义接口地址(可选)"}),(0,eb.jsx)(eA,{value:e.endpoint??"",onChange:e=>t({endpoint:e.currentTarget.value}),placeholder:"留空使用渠道默认地址",className:"font-mono text-xs",spellCheck:!1,autoComplete:"off"})]})]}):null,"hub"===e.provider?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(ete,{}),n?(0,eb.jsxs)("p",{className:"text-xs text-muted-foreground",children:["已登录 Hub(",n.email||n.name,"),将使用官方搜索额度按次计费。无需填写 Key 或接口地址。"]}):(0,eb.jsx)("p",{className:"text-xs text-destructive",children:"尚未登录 Hub。官方搜索需要先在「Hub 账户」设置中登录。"})]}):null]})]})}function ecW({draft:e,update:t}){return(0,eb.jsx)("div",{className:"grid gap-6",children:(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"搜索引擎兜底(无需 Key)"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"未配置 AI 渠道或渠道失败时,自动解析搜索引擎结果页,过滤出条目与网址。请求带浏览器指纹(uTLS + 请求头),降低被拦截概率。"}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"启用搜索引擎兜底"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"关闭后,未配置 AI 渠道时将无法搜索。建议保持开启。"})]}),(0,eb.jsx)(bG,{checked:e.enableEngineFallback,onCheckedChange:e=>t({enableEngineFallback:e})})]}),e.enableEngineFallback?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"兜底搜索引擎"}),(0,eb.jsx)(x7,{value:e.engine??"bing",onValueChange:e=>t({engine:e}),options:ecV,title:"选择兜底搜索引擎",className:"w-full"})]})]}):null]})})}function ecK({draft:e,update:t}){let n=ecH.find(t=>t.value===(e.defaultReader??"auto"));return(0,eb.jsx)("div",{className:"grid gap-6",children:(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"网页阅读"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"阅读层:把网页抽取成干净的正文 Markdown,不启动浏览器。智能体每次调用可自选引擎,下面是它未指定时的默认。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"默认阅读引擎"}),(0,eb.jsx)(x7,{value:e.defaultReader??"auto",onValueChange:e=>t({defaultReader:e}),options:ecH.map(e=>({value:e.value,label:e.label})),title:"选择默认阅读引擎",className:"w-full"}),n?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:n.help}):null]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"Jina Reader API Key(可选)"}),(0,eb.jsx)(eA,{value:e.jinaApiKey??"",onChange:e=>t({jinaApiKey:e.currentTarget.value}),placeholder:"留空也可用(免费有速率限制)",className:"font-mono text-xs",spellCheck:!1,autoComplete:"off"})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"Firecrawl API Key"}),(0,eb.jsx)(eA,{value:e.firecrawlApiKey??"",onChange:e=>t({firecrawlApiKey:e.currentTarget.value}),placeholder:"使用 Firecrawl 阅读时必填",className:"font-mono text-xs",spellCheck:!1,autoComplete:"off"})]})]})})}function ecG({draft:e,update:t}){return(0,eb.jsx)("div",{className:"grid gap-6",children:(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"可信信源(公共 API · 无需 Key)"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"智能体可在搜索时指定来源,直接调用各站点的官方公共 API,结果比通用网页搜索干净得多——已内置启用,无需配置:"}),(0,eb.jsxs)("ul",{className:"ml-4 list-disc space-y-1 text-xs text-muted-foreground",children:[(0,eb.jsxs)("li",{children:[(0,eb.jsx)("span",{className:"font-medium text-foreground",children:"GitHub / Gitee"})," — 按 star 排序搜索开源仓库"]}),(0,eb.jsxs)("li",{children:[(0,eb.jsx)("span",{className:"font-medium text-foreground",children:"维基百科"})," — 词条检索(支持多语言)"]}),(0,eb.jsxs)("li",{children:[(0,eb.jsx)("span",{className:"font-medium text-foreground",children:"Fandom"})," — 游戏 / 动漫 / 影视等粉丝维基"]})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"GitHub Token(可选)"}),(0,eb.jsx)(eA,{value:e.githubToken??"",onChange:e=>t({githubToken:e.currentTarget.value}),placeholder:"留空也可用(匿名限速 10 次/分钟),填入可提高限额",className:"font-mono text-xs",spellCheck:!1,autoComplete:"off"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"仅用于 GitHub 来源的搜索限速提升。在 github.com/settings/tokens 生成(无需任何权限范围即可)。"})]})]})})}function ecX({draft:e,update:t}){return(0,eb.jsx)("div",{className:"grid gap-6",children:(0,eb.jsx)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"默认返回结果数"}),(0,eb.jsxs)("span",{className:"text-sm tabular-nums text-muted-foreground",children:[e.maxResults||8," 条"]})]}),(0,eb.jsx)(enx,{value:[e.maxResults||8],onValueChange:([e])=>t({maxResults:e}),min:1,max:20,step:1}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"每次搜索返回给智能体的结果条数上限(智能体也可在调用时显式指定)。默认 8。"})]})})})}function ecY(){let e,{user:t}=ti(),[n,r]=ew.useState(null),[a,i]=ew.useState(!0),[o,l]=ew.useState(!1),[s,c]=ew.useState(""),[d,u]=ew.useState(!1),[f,m]=ew.useState(null),h=ew.useRef(null);async function p(){if(n&&!o){l(!0),c("");try{let e=await ks({search:n});h.current=e,r(ecU(e)),u(!1),m(Date.now())}catch(e){c(e instanceof Error?e.message:"Save failed")}finally{l(!1)}}}if(ew.useEffect(()=>{!async function(){try{let e=await kl();h.current=e,r(ecU(e))}catch(e){c(e instanceof Error?e.message:"Failed to load config")}finally{i(!1)}}()},[]),a)e=(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取搜索设置"});else if(n){let a={draft:n,update:function(e){r(t=>t?{...t,...e}:t),u(!0),m(null)},hubUser:t};e=(0,eb.jsx)(etm,{sections:[{id:"provider",title:"搜索渠道",icon:(0,eb.jsx)(vu,{}),content:(0,eb.jsx)(ecq,{...a})},{id:"engine",title:"搜索引擎兜底",icon:(0,eb.jsx)(qz,{}),content:(0,eb.jsx)(ecW,{...a})},{id:"reader",title:"网页阅读",icon:(0,eb.jsx)(to,{}),content:(0,eb.jsx)(ecK,{...a})},{id:"sources",title:"可信信源",icon:(0,eb.jsx)(kB,{}),content:(0,eb.jsx)(ecG,{...a})},{id:"limits",title:"结果数量",icon:(0,eb.jsx)(ecF,{}),content:(0,eb.jsx)(ecX,{...a})}],defaultSectionId:"provider",labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto"})}else e=(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"读取失败"}),(0,eb.jsx)(etJ,{children:s||"无法加载搜索设置"})]});return(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex flex-col gap-0.5 border-b px-4 py-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(vu,{}),"搜索设置"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:"搜索设置"})]}),e,(0,eb.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-10 flex justify-center px-6 pb-4",children:(0,eb.jsxs)("div",{className:(0,ez.cn)("pointer-events-auto flex items-center gap-3 rounded-full border border-border bg-card/95 px-4 py-2 shadow-lg backdrop-blur transition-opacity",d||s||f?"opacity-100":"pointer-events-none opacity-0"),children:[s?(0,eb.jsx)("span",{className:"text-xs text-hot-pink",children:s}):d?(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:"有未保存的更改"}):f?(0,eb.jsxs)("span",{className:"flex items-center gap-1 text-xs text-emerald-600 dark:text-emerald-400 [&_svg]:size-3.5",children:[(0,eb.jsx)(h6,{}),"已保存"]}):null,d?(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"sm",disabled:o,onClick:function(){h.current&&(r(ecU(h.current)),u(!1),c(""))},children:"撤销"}):null,(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",disabled:!d||o,onClick:()=>void p(),children:[o?(0,eb.jsx)(eM,{className:"size-4 animate-spin"}):(0,eb.jsx)(h6,{className:"size-4"}),"保存"]})]})})]})}let ecZ=(0,ek.default)("blocks",[["path",{d:"M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2",key:"1ah6g2"}],["rect",{x:"14",y:"2",width:"8",height:"8",rx:"1",key:"88lufb"}]]),ecJ="local",ecQ=[{id:"cloakbrowser",label:"CloakBrowser 默认",description:"源码级反爬的真 Chromium,最适合 agent 在真实站点稳定工作。"},{id:"chrome-for-testing",label:"Chrome for Testing",description:"Google 官方纯净自动化 Chromium,更轻量、自动化友好。"}];function ec0(){let{machines:e}=vd(),t=ew.useMemo(()=>{let t=[],n=!1;for(let r of e)if(r.isLocal)n=!0,t.unshift({id:ecJ,name:"本机",online:!0,reachable:!0,isLocal:!0});else{let e="online"===r.status;t.push({id:r.id,name:r.name,online:e,reachable:r.reachable??e,isLocal:!1})}return n||t.unshift({id:ecJ,name:"本机",online:!0,reachable:!0,isLocal:!0}),t},[e]),[n,r]=ew.useState(ecJ);return ew.useEffect(()=>{t.some(e=>e.id===n)||r(t[0]?.id??ecJ)},[t,n]),(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex flex-col gap-0.5 border-b px-4 py-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(ecZ,{}),"官方扩展"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:"官方扩展"})]}),0===t.length?(0,eb.jsx)("div",{className:"grid min-h-0 flex-1 place-items-center p-6 text-sm text-muted-foreground",children:"暂无可管理的机器。"}):(0,eb.jsx)(etm,{sections:t.map(e=>({id:e.id,title:e.name,icon:(0,eb.jsx)(eP,{}),badge:(0,eb.jsxs)("span",{className:"flex items-center gap-1",children:[(0,eb.jsx)("span",{className:(0,ez.cn)("size-1.5 rounded-full",e.online?"bg-emerald-500":"bg-muted-foreground/40"),"aria-hidden":!0}),e.online?"在线":"离线"]}),content:(0,eb.jsx)(ec1,{machine:e})})),sectionId:n,onSelectionChange:({sectionId:e})=>{e&&r(e)},defaultSectionId:t[0]?.id,labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto pb-28"})]})}function ec1({machine:e}){var t;let n=(t=e?.id??ecJ)===ecJ?void 0:t,r=e?.reachable??!0,[a,i]=ew.useState(null),[o,l]=ew.useState(!0),[s,c]=ew.useState(!1),[d,u]=ew.useState(0),[f,m]=ew.useState(!1),h=ew.useCallback(()=>u(e=>e+1),[]);ew.useEffect(()=>{if(!r){l(!1),c(!0),i(null);return}let e=!0,t=new AbortController;async function a(){try{let r=await Yk(n,{signal:t.signal});if(!e)return;i(r.extensions??[]),c(!1)}catch{if(!e)return;c(!0)}finally{e&&l(!1)}}a();let o=f?window.setInterval(a,3e3):void 0;return()=>{e=!1,t.abort(),o&&window.clearInterval(o)}},[n,r,d,f]);let p=a?.find(e=>"browser"===e.id)??(a?ec2:void 0);return o?(0,eb.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border bg-card p-6 text-sm text-muted-foreground",children:[(0,eb.jsx)(HR,{className:"size-4"}),"正在获取扩展状态…"]}):s||!a?(0,eb.jsxs)("div",{className:"grid gap-3 rounded-lg border border-destructive/30 bg-destructive/5 p-6",children:[(0,eb.jsx)("p",{className:"text-sm text-destructive",children:"无法获取扩展状态"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:r?"请确认该机器的运行时已启动,稍后重试。":"该机器当前不可达(离线或无连接路径)。"}),r&&(0,eb.jsx)("div",{children:(0,eb.jsxs)(eO.Button,{variant:"outline",size:"sm",onClick:h,children:[(0,eb.jsx)(yt,{className:"size-3.5"}),"重试"]})})]}):p?(0,eb.jsx)(ec5,{machineId:n,extension:p,onChanged:h,setPolling:m}):(0,eb.jsx)("div",{className:"rounded-lg border bg-card p-6 text-sm text-muted-foreground",children:"该机器暂无可用的官方扩展。"})}let ec2={id:"browser",name:"Vantaloom 浏览器",installed:!1,enabled:!1,running:!1,variant:"cloakbrowser",version:"",available:["cloakbrowser","chrome-for-testing"]};function ec5({machineId:e,extension:t,onChanged:n,setPolling:r}){var a;let[i,o]=ew.useState(null),[l,s]=ew.useState(null),[c,d]=ew.useState(t.variant??"cloakbrowser");ew.useEffect(()=>{t.installed&&t.variant&&d(t.variant)},[t.installed,t.variant]);let u="install"===i;async function f(e,t,a=!1){o(e),s(null),a&&r(!0);try{await t(),n()}catch{s("操作失败,请稍后重试。")}finally{o(null),a&&r(!1)}}async function m(t){o("enable"),s(null),r(!0);try{await YE(e,t),n();let r=Date.now()+3e4;for(;Date.now()<r;){await new Promise(e=>setTimeout(e,1500));try{let n=(await Yk(e,{timeoutMs:6e3})).extensions.find(e=>"browser"===e.id);if(n&&n.running===t)break}catch{}}n()}catch{s(t?"启动失败,请稍后重试。":"停止失败,请稍后重试。")}finally{o(null),r(!1)}}let h="enable"===i,p=h&&!t.running||t.enabled&&!t.running,g=h&&t.running,x=t.installed?t.running?(0,eb.jsx)(Vp,{variant:"default",children:"运行中"}):p?(0,eb.jsx)(Vp,{variant:"secondary",className:"bg-amber-500/15 text-amber-600 dark:text-amber-400",children:"启动中"}):(0,eb.jsx)(Vp,{variant:"secondary",className:"bg-muted text-muted-foreground",children:"已停止"}):(0,eb.jsx)(Vp,{variant:"outline",children:"未安装"}),v=ecQ.filter(e=>!t.available?.length||t.available.includes(e.id));return(0,eb.jsxs)("section",{className:"grid gap-4 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("div",{className:"flex items-start gap-3",children:[(0,eb.jsx)("span",{className:"grid size-10 shrink-0 place-items-center rounded-md bg-primary/10 text-primary [&_svg]:size-5",children:(0,eb.jsx)(qz,{})}),(0,eb.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eb.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold text-foreground",children:"Vantaloom 浏览器"}),x,t.installed&&t.version&&(0,eb.jsxs)("span",{className:"text-xs text-muted-foreground",children:["v",t.version]})]}),(0,eb.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:"让 Agent 可操作真实浏览器:网站预览直连真实浏览器,可在指定机器上运行并远程观看 Agent 的操作过程。"})]})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"浏览器内核"}),(0,eb.jsx)("div",{className:"grid gap-2 sm:grid-cols-2",children:v.map(e=>{let n=c===e.id,r=t.installed;return(0,eb.jsxs)("button",{type:"button",disabled:r||null!==i,onClick:()=>d(e.id),className:(0,ez.cn)("flex flex-col gap-1 rounded-lg border p-3 text-left transition-colors",n?"border-primary bg-primary/5 text-foreground":"border-border bg-background text-muted-foreground hover:bg-muted/60 hover:text-foreground",(r||null!==i)&&"opacity-60"),"aria-pressed":n,children:[(0,eb.jsx)("span",{className:"text-sm font-medium text-foreground",children:e.label}),(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:e.description})]},e.id)})}),t.installed&&(0,eb.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["已安装的内核为 ",(a=t.variant,ecQ.find(e=>e.id===a)?.label??a),",如需更换请先卸载。"]})]}),(0,eb.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:t.installed?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsxs)(eO.Button,{size:"sm",disabled:null!==i,onClick:()=>m(!t.running),children:[h?(0,eb.jsx)(HR,{className:"size-3.5"}):t.running?(0,eb.jsx)(kH,{className:"size-3.5"}):(0,eb.jsx)(HE,{className:"size-3.5"}),g?"停止中…":p?"启动中…":t.running?"停止浏览器":"启动浏览器"]}),(0,eb.jsxs)(eO.Button,{size:"sm",variant:"outline",disabled:null!==i,onClick:()=>f("update",()=>YC(e),!0),children:["update"===i?(0,eb.jsx)(HR,{className:"size-3.5"}):(0,eb.jsx)(yt,{className:"size-3.5"}),"update"===i?"正在更新…":"更新"]}),(0,eb.jsxs)(eO.Button,{size:"sm",variant:"destructive",disabled:null!==i,onClick:()=>f("uninstall",()=>YM(e)),children:["uninstall"===i?(0,eb.jsx)(HR,{className:"size-3.5"}):(0,eb.jsx)(yn,{className:"size-3.5"}),"卸载"]})]}):(0,eb.jsxs)(eO.Button,{size:"sm",disabled:null!==i,onClick:()=>f("install",()=>YS(e,c),!0),children:[u?(0,eb.jsx)(HR,{className:"size-3.5"}):null,u?"正在安装…":"安装"]})}),t.installed&&(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-lg border bg-background p-3",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("p",{className:"text-sm font-medium text-foreground",children:"在此机器上运行"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"开启后该机器的 Agent 可使用浏览器工具;关闭则停止浏览器与边车进程。"})]}),(0,eb.jsx)(bG,{checked:t.enabled,disabled:null!==i,onCheckedChange:e=>void m(e),"aria-label":"在此机器上运行浏览器扩展"})]}),l&&(0,eb.jsx)("p",{className:"text-xs text-destructive",children:l})]})}let ec4=["light","dark","jelly"],ec3={light:{label:"Light",icon:ell,className:"text-sidebar-foreground/60"},dark:{label:"Dark",icon:eli,className:"text-sidebar-foreground/60"},jelly:{label:"Jelly",icon:function(e){return(0,eb.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[(0,eb.jsx)("path",{d:"M6.5 11.5C6.5 8 8.7 5.5 12 5.5s5.5 2.5 5.5 6v.6c0 .8-.6 1.4-1.4 1.4H7.9c-.8 0-1.4-.6-1.4-1.4v-.6Z"}),(0,eb.jsx)("path",{d:"M7.8 13.5c.4 1 1.1 1.5 2 1.5s1.6-.5 2-1.5c.4 1 1.1 1.5 2 1.5s1.6-.5 2-1.5"}),(0,eb.jsx)("path",{d:"M9 15.5c0 1.4-1.2 1.4-1.2 2.8 0 .7.3 1.2.8 1.7"}),(0,eb.jsx)("path",{d:"M12 15.5c0 1.6-1.4 1.6-1.4 3.2 0 .7.3 1.2.8 1.8"}),(0,eb.jsx)("path",{d:"M15 15.5c0 1.4 1.2 1.4 1.2 2.8 0 .7-.3 1.2-.8 1.7"})]})},className:"text-primary"}};function ec6(){let{resolvedTheme:e,setTheme:t}=(0,m1.useTheme)(),[n,r]=ew.useState(elb.defaultAppearanceTheme);ew.useEffect(()=>{let e=window.localStorage.getItem(elb.appearanceThemeStorageKey)??elb.defaultAppearanceTheme;r(e),(0,elb.applyAppearanceTheme)({theme:e})},[]);let a=n===elb.jellyAppearanceTheme?"jelly":"dark"===e?"dark":"light",i=ec4.indexOf(a),o=ec4[(i+1)%ec4.length]??"light",{icon:l,label:s,className:c}=ec3[a];function d(e){r(e),window.localStorage.setItem(elb.appearanceThemeStorageKey,e),(0,elb.applyAppearanceTheme)({theme:e})}return(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-sm",className:(0,ez.cn)("size-10 hover:bg-muted hover:text-sidebar-foreground",c),"aria-label":`${en2.theme}: ${s}`,title:`${en2.theme}: ${s}`,onClick:function(){if("jelly"===o){t("dark"),d(elb.jellyAppearanceTheme);return}d(elb.defaultAppearanceTheme),t(o)},children:(0,eb.jsx)(l,{})})}let ec8=(0,ek.default)("chart-area",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z",key:"q0gr47"}]]);(0,ek.default)("layout-dashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]),(0,ek.default)("route",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]]);let ec7=[{id:"run-ui-polish",title:"组件库视觉回归检查",machine:"Studio-PC",agent:"UI Polish",state:"running",started:"14:08",runtime:"22m",progress:68,load:54},{id:"run-runner-build",title:"Linux runner 镜像构建",machine:"Linux-runner-02",agent:"Build Agent",state:"running",started:"14:15",runtime:"15m",progress:41,load:86},{id:"run-access-audit",title:"工作组权限审阅",machine:"Studio-PC",agent:"Access Agent",state:"blocked",started:"14:21",runtime:"9m",progress:37,load:18},{id:"run-docs",title:"发布说明摘要",machine:"MacBook-build",agent:"Docs Agent",state:"queued",started:"等待",runtime:"0m",progress:0,load:0},{id:"run-cache-clean",title:"缓存清理策略验证",machine:"Linux-runner-02",agent:"Ops Sentinel",state:"failed",started:"13:54",runtime:"6m",progress:28,load:12}],ec9=[{id:"worker-studio",machine:"Studio-PC",role:"local coordinator",active:3,capacity:6,cpu:42,memory:68},{id:"worker-runner",machine:"Linux-runner-02",role:"gpu worker",active:4,capacity:5,cpu:76,memory:81},{id:"worker-mac",machine:"MacBook-build",role:"build host",active:0,capacity:3,cpu:8,memory:24}],ede=[{id:"confirm-shell",title:"Studio-PC 请求执行发布前文件写入",meta:"UI Polish · apply_patch",tone:"normal"},{id:"confirm-service",title:"Linux-runner-02 请求重启 runner 服务",meta:"Ops Sentinel · Restart-Service",tone:"warning"},{id:"confirm-token",title:"工作组 token 加入新机器",meta:"Access Agent · admin required",tone:"normal"}],edt=[["14:29","Studio-PC","pnpm --filter vantaloom-app lint","完成"],["14:27","Linux-runner-02","docker build agent-runtime","运行中"],["14:22","Studio-PC","apply_patch agent settings","完成"],["14:17","MacBook-build","pnpm typecheck","排队"],["14:03","Linux-runner-02","cache prune dry-run","失败"]],edn={cpu:{label:"CPU",color:"var(--chart-1)"},memory:{label:"Memory",color:"var(--chart-3)"},network:{label:"Network",color:"var(--chart-5)"}};function edr(e,t,n=42,r){return(0,eb.jsx)("section",{className:(0,ez.cn)("size-full rounded-xl border bg-card p-5",r&&"vtl-jelly-image-card",r&&r.includes("/bg")&&"vtl-jelly-image-card-shadowless"),style:r?en0({image:r,opacity:.74,blur:"8px"}):void 0,children:(0,eb.jsx)(erb,{label:e,value:t,minSize:n})})}function eda(e,t,n=""){return{title:e,dataSource:t,refreshRate:"10s",note:n}}let edi={metrics:{online:2,health:88.4,latency:"38ms",events:17},machines:[{id:"studio",name:"Studio-PC",os:"Windows",status:"online",link:"direct",heartbeat:"3s",cpu:42,memory:68,disk:71,network:24},{id:"runner",name:"Linux-runner-02",os:"Linux",status:"online",link:"p2p",heartbeat:"5s",cpu:76,memory:81,disk:62,network:43},{id:"mac",name:"MacBook-build",os:"macOS",status:"sleeping",link:"direct",heartbeat:"2m",cpu:8,memory:24,disk:48,network:6}],trend:[{time:"09:00",cpu:36,memory:54,network:24},{time:"10:00",cpu:48,memory:61,network:29},{time:"11:00",cpu:44,memory:58,network:34},{time:"12:00",cpu:63,memory:72,network:41},{time:"13:00",cpu:58,memory:69,network:37},{time:"14:00",cpu:71,memory:76,network:46}],networkLinks:[["Studio-PC","Linux-runner-02","P2P","38ms","0.3%"],["Studio-PC","MacBook-build","Direct","12ms","0.0%"],["Linux-runner-02","MacBook-build","Relay fallback","84ms","1.1%"]],events:[["14:31","Linux-runner-02 心跳延迟升高"],["14:28","Studio-PC 完成 2 个工具调用"],["14:19","MacBook-build 进入睡眠状态"],["14:12","工作组权限策略同步完成"],["14:04","P2P 链路切换到备用路径"]],serviceHealth:[{id:"local-service",name:"Local service",state:"正常",samples:[96,98,97,95,96,94,97,98,96,95,97,96]},{id:"agent-runtime",name:"Agent runtime",state:"正常",samples:[91,93,94,90,88,92,94,93,91,89,92,94]},{id:"p2p-mesh",name:"P2P mesh",state:"波动",samples:[78,82,76,73,68,71,74,79,83,80,77,72]},{id:"plugin-bridge",name:"Plugin bridge",state:"告警",samples:[88,86,84,82,79,74,63,54,48,52,67,76]}]},edo=[{id:"metric-runs",title:"运行中",description:"当前正在执行的运行数量。",icon:(0,eb.jsx)(u1,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eda("运行中","运行队列"),render:e=>edr(e.title,"07",44,enY)},{id:"metric-queued",title:"排队",description:"等待调度的任务数量。",icon:(0,eb.jsx)(uV,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eda("排队","调度器"),render:e=>edr(e.title,"04",44,enZ)},{id:"metric-blocked",title:"待确认",description:"等待人工确认的任务数量。",icon:(0,eb.jsx)(eiE,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eda("待确认","确认队列"),render:e=>edr(e.title,"03",44,enJ)},{id:"metric-workers",title:"Worker",description:"当前可调度 worker 数量。",icon:(0,eb.jsx)(Yw,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eda("Worker","Agent worker"),render:e=>edr(e.title,"14",44,enQ)},{id:"queue",title:"任务队列",description:"运行队列 Roadmap。",icon:(0,eb.jsx)(uZ,{className:"size-4"}),defaultSize:{w:7,h:5},defaultConfig:eda("任务队列","运行队列"),render:e=>(0,eb.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,eb.jsx)(en1,{title:e.title}),(0,eb.jsx)(eaY,{items:ec7})]})},{id:"workers",title:"Agent worker",description:"各 worker 的负载和容量。",icon:(0,eb.jsx)(Yw,{className:"size-4"}),defaultSize:{w:5,h:5},defaultConfig:eda("Agent worker","Worker 状态"),render:e=>(0,eb.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,eb.jsx)(en1,{title:e.title}),(0,eb.jsx)(eaJ,{workers:ec9})]})},{id:"log",title:"最近执行",description:"最近执行记录 Roadmap。",icon:(0,eb.jsx)(erk,{className:"size-4"}),defaultSize:{w:7,h:4},defaultConfig:eda("最近执行","执行日志"),render:e=>(0,eb.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,eb.jsx)(en1,{title:e.title}),(0,eb.jsx)(eaX,{items:edt})]})},{id:"confirmations",title:"待确认",description:"等待人工确认的事项。",icon:(0,eb.jsx)(eap,{className:"size-4"}),defaultSize:{w:5,h:4},defaultConfig:eda("待确认","确认队列"),render:e=>(0,eb.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,eb.jsx)(en1,{title:e.title}),(0,eb.jsx)(eaG,{items:ede})]})}],edl=[{id:"metric-runs",kind:"metric-runs",x:0,y:0,w:3,h:2},{id:"metric-queued",kind:"metric-queued",x:3,y:0,w:3,h:2},{id:"metric-blocked",kind:"metric-blocked",x:6,y:0,w:3,h:2},{id:"metric-workers",kind:"metric-workers",x:9,y:0,w:3,h:2},{id:"queue",kind:"queue",x:0,y:2,w:7,h:5},{id:"workers",kind:"workers",x:7,y:2,w:5,h:5},{id:"log",kind:"log",x:0,y:7,w:7,h:4},{id:"confirmations",kind:"confirmations",x:7,y:7,w:5,h:4}];function eds(e=edi){return[{id:"metric-online",title:"在线机器",description:"当前在线机器数量。",icon:(0,eb.jsx)(eP,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eda("在线机器","机器心跳"),render:t=>edr(t.title,String(e.metrics.online),44,enY)},{id:"metric-health",title:"健康度",description:"工作组整体健康度。",icon:(0,eb.jsx)(eI,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eda("健康度","服务遥测"),render:t=>edr(t.title,`${e.metrics.health}%`,44,enZ)},{id:"metric-latency",title:"平均延迟",description:"机器连接平均延迟。",icon:(0,eb.jsx)(erE,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eda("平均延迟","网络遥测"),render:t=>edr(t.title,e.metrics.latency,44,enJ)},{id:"metric-events",title:"事件",description:"最近事件数量。",icon:(0,eb.jsx)(eap,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eda("事件","事件流"),render:t=>edr(t.title,String(e.metrics.events),44,enQ)},{id:"machines",title:"机器健康矩阵",description:"各机器资源和心跳状态。",icon:(0,eb.jsx)(eP,{className:"size-4"}),defaultSize:{w:7,h:5},defaultConfig:eda("机器健康矩阵","机器遥测"),render:t=>(0,eb.jsxs)("section",{className:"vtl-jelly-image-card flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",style:en0({image:"/themes/jelly/card1.png",opacity:.88,blur:"10px"}),children:[(0,eb.jsx)(en1,{title:t.title}),(0,eb.jsx)(ea2,{machines:e.machines})]})},{id:"trend",title:"资源趋势",description:"CPU、内存和网络趋势。",icon:(0,eb.jsx)(ec8,{className:"size-4"}),defaultSize:{w:5,h:5},defaultConfig:eda("资源趋势","机器遥测"),render:t=>(0,eb.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,eb.jsx)(en1,{title:t.title}),(0,eb.jsx)(ea8,{config:edn,data:e.trend})]})},{id:"network",title:"网络连接",description:"机器之间连接状态。",icon:(0,eb.jsx)(enH,{className:"size-4"}),defaultSize:{w:6,h:4},defaultConfig:eda("网络连接","网络遥测"),render:t=>(0,eb.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,eb.jsx)(en1,{title:t.title}),(0,eb.jsx)(ea6,{links:e.networkLinks})]})},{id:"events",title:"事件流",description:"最近遥测事件。",icon:(0,eb.jsx)(eap,{className:"size-4"}),defaultSize:{w:6,h:4},defaultConfig:eda("事件流","事件流"),render:t=>(0,eb.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,eb.jsx)(en1,{title:t.title}),(0,eb.jsx)(ea1,{events:e.events})]})},{id:"services",title:"服务健康",description:"服务 30 分钟粒度健康条。",icon:(0,eb.jsx)(Yw,{className:"size-4"}),defaultSize:{w:12,h:3},defaultConfig:eda("服务健康","服务遥测"),render:t=>(0,eb.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,eb.jsx)(en1,{title:t.title}),(0,eb.jsx)(ea7,{services:e.serviceHealth})]})}]}eds();let edc=[{id:"metric-online",kind:"metric-online",x:0,y:0,w:3,h:2},{id:"metric-health",kind:"metric-health",x:3,y:0,w:3,h:2},{id:"metric-latency",kind:"metric-latency",x:6,y:0,w:3,h:2},{id:"metric-events",kind:"metric-events",x:9,y:0,w:3,h:2},{id:"machines",kind:"machines",x:0,y:2,w:7,h:5},{id:"trend",kind:"trend",x:7,y:2,w:5,h:5},{id:"network",kind:"network",x:0,y:7,w:6,h:4},{id:"events",kind:"events",x:6,y:7,w:6,h:4},{id:"services",kind:"services",x:0,y:11,w:12,h:3}],edd={totals:{machines:4,online:2,runtime:3,tokens:7},machines:[{id:"studio",name:"Studio-PC",role:"本机",group:"Core",os:"Windows 11",runtime:"0.16.4",state:"online",tags:["admin","shell","files","scheduler"],agent:"6/8",cpu:42,memory:68,version:"Agent runtime 0.16.4",admin:"Allay"},{id:"runner",name:"Linux-runner-02",role:"GPU worker",group:"Compute",os:"Ubuntu 24.04",runtime:"0.16.3",state:"online",tags:["gpu","agent","files"],agent:"4/6",cpu:76,memory:81,version:"Agent runtime 0.16.3",admin:"Ops"},{id:"mac",name:"MacBook-build",role:"构建机",group:"Build",os:"macOS 15.4",runtime:"0.15.9",state:"sleeping",tags:["build","readonly"],agent:"0/3",cpu:8,memory:24,version:"Agent runtime 0.15.9",admin:"Allay"},{id:"observer",name:"Observer-01",role:"只读观测节点",group:"Edge",os:"Debian 13",runtime:"0.16.2",state:"warning",tags:["readonly","audit"],agent:"1/2",cpu:18,memory:36,version:"Agent runtime 0.16.2",admin:"Security"}],topology:{nodes:[{id:"studio",label:"Studio-PC",meta:"本机",x:50,y:18},{id:"runner",label:"Linux-runner-02",meta:"GPU worker",x:22,y:60},{id:"mac",label:"MacBook-build",meta:"构建机",x:76,y:58,state:"warning"},{id:"observer",label:"Observer-01",meta:"只读观测",x:50,y:82,state:"warning"}],links:[{id:"sr",from:"studio",to:"runner",kind:"p2p",label:"P2P",meta:"38ms / 0.3%"},{id:"sm",from:"studio",to:"mac",kind:"direct",label:"Direct",meta:"12ms / 0%"},{id:"ro",from:"runner",to:"observer",kind:"relay",label:"Relay",meta:"84ms / 1.1%"},{id:"mo",from:"mac",to:"observer",kind:"down",label:"Down",meta:"lost"}]},pathTotals:{direct:1,p2p:1,relay:1,broken:1},latency:[{time:"09:00",p2p:42,direct:12,relay:96},{time:"10:00",p2p:39,direct:12,relay:88},{time:"11:00",p2p:44,direct:14,relay:91},{time:"12:00",p2p:38,direct:12,relay:84},{time:"13:00",p2p:36,direct:11,relay:86},{time:"14:00",p2p:41,direct:13,relay:93}],candidates:[["Studio-PC","Linux-runner-02","P2P","symmetric NAT","38ms","0.3%"],["Studio-PC","MacBook-build","Direct","open port 4178","12ms","0.0%"],["Linux-runner-02","Observer-01","Relay","udp blocked","84ms","1.1%"],["MacBook-build","Observer-01","Interrupted","sleep","-","-"]]};function edu({clipboardItems:e=[],onClipboardItemsChange:t,onOverlayOpenChange:n}){return(0,eb.jsx)(erp,{boardId:"runtime-operations",definitions:edo,initialLayouts:edl,clipboardItems:e,actionLabel:"运行页面卡片操作",paletteGroupTitle:"运行页面卡片",onClipboardItemsChange:t,onOverlayOpenChange:n})}function edf({clipboardItems:e=[],onClipboardItemsChange:t,onOverlayOpenChange:n}){let r=es6("/api/local/machines/telemetry",es3),a=ew.useMemo(()=>eds(r),[r]);return(0,eb.jsx)(erp,{boardId:"telemetry",definitions:a,initialLayouts:edc,clipboardItems:e,actionLabel:"遥测页面卡片操作",paletteGroupTitle:"遥测页面卡片",onClipboardItemsChange:t,onOverlayOpenChange:n})}function edm({className:e,title:t="Vantaloom"}){return(0,eb.jsxs)("svg",{viewBox:"180 350 1130 260",fill:"currentColor",role:"img","aria-label":t,className:(0,ez.cn)("[[data-vtl-theme=jelly]_&]:opacity-70",e),children:[(0,eb.jsx)("path",{d:"m658 393 2 1v47l57 1v1l-12 2-45 5v89l2 14 4 7 6 3h12l8-2-5-10-1-4v-11l3-8 4-6 7-7 14-8 16-6 33-9h3l-1-16-4-8-6-5-10-3h-15l-13 3-16 7-7 5 1-4 8-8 14-8 12-4 7-1h23l16 4 9 6 4 5 4 9 1 5 1 69 2 11 3 5 7 5v1h-28l-6-4-4-11v-7h-2l-2 4-7 8-11 8-10 4-4 1h-21l-9-4-7-5-14 7-7 2h-18l-11-4-6-5-5-10-1-4-1-33v-61l1-4-26 3-9-7-4-3 4-1 34-2v-34l2-5zm107 104-19 6-17 8-10 9-4 8-1 4v11l3 8 8 7 7 2h8l10-3 10-7 6-7 1-2v-44z"}),(0,eb.jsx)("path",{d:"m1147 452h15l11 3 10 9 5 10v3h2l2-5 10-10 12-7 11-3h18l10 3 6 4 7 8 4 12 1 9 1 62 3 12 4 5 3 3h-38l-1-86-2-9-5-7-7-3h-12l-10 3-9 6-7 8-1 88h-26l-1-88-3-9-5-6-6-2h-11l-9 3-9 7-4 6-1 89h-34l6-14 4-19 1-10v-28l-3-19-6-18-4-9h28l3 8 3 13 7-8 8-7 10-5z"}),(0,eb.jsx)("path",{d:"m556 449h19l13 4 10 9 4 9 2 13 1 67 3 10 4 5 5 4h-40l-1-85-3-12-4-6-7-4-3-1h-14l-11 4-10 7-5 8-1 6-1 83h-25l-1-99-2-17 1-1h24l2 6 2 13 9-10 12-8 11-4z"}),(0,eb.jsx)("path",{d:"m409 450h22l16 4 9 6 6 9 3 11 1 71 2 9 3 5 6 4v1h-27l-6-4-3-7-2-9-11 12-13 8-9 3-7 1h-13l-12-3-10-7-6-10-1-4v-13l5-12 4-5 12-9 18-8 35-10 6-2v-14l-3-8-5-5-7-3-4-1h-15l-13 3-20 10 6-9 10-7 13-5zm27 47-23 8-13 7-8 7-5 9-1 4v11l5 10 5 4 8 3h10l11-4 8-6 5-6 1-4v-43z"}),(0,eb.jsx)("path",{d:"m918 450h22l15 3 16 8 12 11 7 8 7 14 3 11v21l-3 12-4 8-5-5-8-17-11-33-7-13-9-10-10-6-7-2h-12l-11 4-8 7-7 10-4 13-1 7v18l3 14 4 10 6 8 9 8 10 4 6 1h9l9-2 7-4 5 1 5 5v2l-10 5-13 3h-22l-15-4-16-8-10-9-6-7-7-14-3-14v-16l3-13 6-12 8-10 12-9 12-5z"}),(0,eb.jsx)("path",{d:"m224 442h17l15 3 10 5 10 9 9 13 14 29 13 28 6 14v2h2l1-5 16-39 17-40 4-8h9l-2 6-18 42-11 26-17 40-9 21-3-1-29-58-10-19-12-23-8-11-9-10-9-7-10-4-5-1h-19l-15 3 4-4 13-6 16-4z"}),(0,eb.jsx)("path",{d:"m1010 450h19l17 4 13 7 12 11 7 11 5 13 2 11v10l-3 16-4 10-9 12-8 7-12 7-13 4-7 1h-25l-16-4-13-7-11-9-7-9-7-14-2-9v-17l3-12 5-10 3-1 7 18 11 33 8 14 8 9 8 5 12 3h8l12-3 10-7 6-8 5-12 2-11v-19l-3-14-5-12-8-10-10-6-7-2h-13l-11 4-6 4-4-2-6-5 3-3 10-5z"}),(0,eb.jsx)("path",{d:"m848 371h1l1 171 2 9 4 6 6 5 19 5 6 2v1h-65l-1-188z"})]})}function edh(e){return()=>new Promise(t=>{e(),window.setTimeout(t,60)})}function edp(e){return"u"<typeof document?null:document.querySelector(e)}function edg(){return null!=edp('[role="menu"]')}function edx(){return null!=edp('[data-tour="init-wizard"]')}function edv(){let e=edp('[data-tour="init-wizard"] [aria-current="step"]'),t=e?.getAttribute("aria-label")?.match(/第\s*(\d+)/);return t?Number(t[1]):0}!function(e=edd){eda("机器","机器组"),eda("在线","机器心跳"),eda("Runtime","Agent runtime"),eda("Token","机器注册"),eda("机器组","机器组"),eda("拓扑图","网络拓扑"),eda("直连","网络拓扑"),eda("P2P","网络拓扑"),eda("Relay","网络拓扑"),eda("中断","网络拓扑"),eda("延迟","网络遥测"),eda("候选路径","网络候选路径")}(),eda("日志与审计","审计事件"),eda("筛选","审计筛选"),eda("拒绝事件","审计事件"),eda("事件趋势","审计事件");var edb=e.i(64990);function edy(){let e=sv(),[t,n]=ew.useState(!1);ew.useEffect(()=>{try{n("1"===window.localStorage.getItem("vtl:sidebar-collapsed"))}catch{}},[]);let r=ew.useCallback(()=>{n(e=>{let t=!e;try{window.localStorage.setItem("vtl:sidebar-collapsed",t?"1":"0")}catch{}return t})},[]),[a,i]=ew.useState("home"),[o,l]=ew.useState(!1),[s,c]=ew.useState(),[d,u]=ew.useState(),[f,m]=ew.useState([]),[h,p]=ew.useState([]),[g,x]=ew.useState("conversation"),[v,b]=ew.useState(0),y=s?.conversation.id,w=s?.conversation.ownerMachineId;ew.useEffect(()=>{m([]),p([]),x("conversation")},[y]),ew.useEffect(()=>{let e;if(!y||"new-agent-conversation"!==a&&"project-conversation"!==a)return void p([]);let t=!1,n=async()=>{let r=await sL(y,w);t||(p(r),e=window.setTimeout(n,!function e(t){return t.some(t=>t.running||e(t.children??[]))}(r)?6e3:2e3))};return n(),()=>{t=!0,e&&window.clearTimeout(e)}},[y,w,a]);let[j,k]=ew.useState();ew.useEffect(()=>{k(void 0)},[a]);let[N,S]=ew.useState(!1),[C,M]=ew.useState(!1),[E,I]=ew.useState([]),[P,O]=ew.useState([]),[z,A]=ew.useState({}),[T,R]=ew.useState(),[D,_]=ew.useState(u9),[L,$]=ew.useState([]),[F,B]=ew.useState(),[V,H]=ew.useState(),[U,q]=ew.useState(),[W,K]=ew.useState(),G=ew.useRef(!1),X=ew.useCallback(e=>{_(t=>iZ(e,t))},[]),Y=ew.useCallback(e=>{$(t=>iZ(e,t))},[]),Z=ew.useCallback(async(e,t)=>{let n="u">typeof performance?performance.now():Date.now();console.debug(`[open] click conversation=${e} owner=${t??"local"}`),u({id:e,ownerMachineId:t}),i("new-agent-conversation");let r=()=>Math.round(("u">typeof performance?performance.now():Date.now())-n);try{let n=await sW(e,t);console.debug(`[open] detail loaded in ${r()}ms (id=${e})`),c(n),u(t=>t?.id===e?void 0:t)}catch(n){if(n instanceof sN){let r=n.openedBy?.displayName||"另一台设备";if(window.confirm(`此对话正在「${r}」上打开,无法同时操作。是否强制接管(对方将被踢出)?`)){try{let n=await sW(e,t,{force:!0});c(n)}finally{u(t=>t?.id===e?void 0:t)}return}u(t=>t?.id===e?void 0:t),s||i("home");return}console.warn(`[open] failed after ${r()}ms (id=${e})`,n),u(t=>t?.id===e?void 0:t),s||i("home")}},[s]),J=ew.useCallback(async(e,t)=>{m([]),await Z(e,t)},[Z]),Q=ew.useCallback(()=>{c(void 0),i("new-agent-conversation")},[]),ee=ew.useCallback(async()=>{let e=await sR();e?await Z(e.conversation.id,e.conversation.ownerMachineId):Q()},[Z,Q]),et=ew.useCallback(async()=>{G.current=!0,_(u9),$([]),i("new-canvas");try{let e=await enD({title:"新画布",nodes:u9,edges:[]});H(e.canvas.id),q("local")}catch{H(void 0),q(void 0),G.current=!1}},[]),en=ew.useCallback(async(e,t)=>{try{await enL(e,t);let n=await enR(e,t);G.current=!0,_(n.nodes),$(n.edges),H(n.canvas.id),q(n.canvas.ownerMachineId),i("new-canvas")}catch{}},[]),er=ew.useCallback(e=>{K(e),i("project-overview")},[]),ea=ew.useCallback(e=>{K(e),i("kanban")},[]),ei=ew.useCallback(e=>{K(e),i("project-settings")},[]),eo=ew.useCallback(async(e,t)=>{K(e);let n=t;if(!n)try{n=(await eib(e)).canvasId}catch{}if(!n)try{n=(await enD({title:"工程画布",nodes:u9,edges:[]})).canvas.id,await eiw(e,{canvasId:n}).catch(()=>{})}catch{return}await en(n)},[en]),el=ew.useCallback(async(e,t,n)=>{K(e),m([]),u({id:t,ownerMachineId:n}),i("project-conversation");try{let e=await sW(t,n);c(e)}catch{}finally{u(e=>e?.id===t?void 0:e)}},[]),es=ew.useCallback(()=>{i("new-project")},[]),ec=ew.useCallback(async e=>{try{let t=await eiC(e);await el(e,t.id,t.ownerMachineId)}catch{}},[el]);ew.useEffect(()=>{if(!V)return;if(G.current){G.current=!1;return}let e=window.setTimeout(()=>{en_(V,{nodes:D,edges:L,nodeIds:D.map(e=>e.id)},U).catch(()=>{})},800);return()=>window.clearTimeout(e)},[D,L,V,U]);let ed=ew.useCallback(({item:t})=>{if(!e||"new-canvas"!==t.id&&"all-canvases"!==t.id&&"open-recent-canvas"!==t.id){if("new-canvas"===t.id)return void et();if("all-canvases"===t.id)return void i("all-canvases");if("new-agent-conversation"===t.id)return void Q();if("import-claude-session"===t.id)return void S(!0);if("open-recent-conversation"===t.id)return void ee();if("runs"===t.id)return void i("runs");if("telemetry"===t.id)return void i("telemetry");("preferences"===t.id||"preferences-models"===t.id||"preferences-agents"===t.id||"system-general"===t.id||"network-downloads"===t.id||"preferences-model-routes"===t.id||"preferences-model-groups"===t.id||"preferences-agent-config"===t.id||"preferences-subagent-config"===t.id||"preferences-cc-engine-config"===t.id||"preferences-assets"===t.id||"preferences-layout"===t.id||"preferences-official-extensions"===t.id||"network-topology"===t.id||"network-settings"===t.id||"search-settings"===t.id||"system-downloads"===t.id||"check-update"===t.id||"account"===t.id||"balance-usage"===t.id||"feedback"===t.id)&&i(t.id)}},[et,e,ee,Q]),{start:eu}=(0,edb.useTour)(),ef=ew.useCallback(()=>{var e;eu((e={select:e=>ed({item:{id:e}}),startNewConversation:Q,goHome:()=>{i("home"),c(void 0)}},{id:"product-tour",steps:[{id:"intro",centered:!0,title:"欢迎使用 Vantaloom 👋",body:(0,eb.jsxs)(eb.Fragment,{children:["这是一份手把手向导,会高亮关键位置并在需要时",(0,eb.jsx)("b",{children:"请你亲自操作"}),"(没做完不会出现「下一步」)。 全程界面都可正常点击;随时按 ",(0,eb.jsx)("kbd",{children:"Esc"})," 或右上角 ✕ 退出。"]})},{id:"theme",before:edh(()=>e.goHome()),target:()=>edp('[role="menu"]')??edp('[data-tour="account-button"]'),gate:edg,gateHint:"点击用户名按钮展开菜单",padding:6,title:"切换主题",body:(0,eb.jsxs)(eb.Fragment,{children:["点击左下角的 ",(0,eb.jsx)("b",{children:"用户名按钮"})," 打开菜单。展开后,里面的 ",(0,eb.jsx)("b",{children:"外观 / 主题"})," 项每点一次就在"," ",(0,eb.jsx)("b",{children:"浅色 → 深色 → 果冻"})," 之间循环。"]})},{id:"model-routes-add",before:edh(()=>e.select("preferences-model-routes")),target:()=>edp('[data-tour="model-route-form"]')??edp('[data-tour="add-model-route"]'),gate:()=>null!=edp('[data-tour="model-route-form"]'),gateHint:"点击「添加模型路由」",title:"配置模型渠道(1/2)",body:(0,eb.jsxs)(eb.Fragment,{children:["进入 ",(0,eb.jsx)("b",{children:"设置 → 模型路由"}),"。请点 ",(0,eb.jsx)("b",{children:"添加模型路由"})," 新增一个第三方渠道(任何 OpenAI / Anthropic 兼容 API 都行)。"]})},{id:"model-routes-fields",before:edh(()=>e.select("preferences-model-routes")),target:'[data-tour="model-route-form"]',waitForTarget:2500,title:"配置模型渠道(2/2)",body:(0,eb.jsxs)(eb.Fragment,{children:["表单各项:",(0,eb.jsx)("b",{children:"提供商名称"})," 仅作标识;",(0,eb.jsx)("b",{children:"协议"})," 选 OpenAI / Anthropic 风格;",(0,eb.jsx)("b",{children:"Endpoint URL"})," 填到 ",(0,eb.jsx)("code",{children:"/v1"})," 这一级;",(0,eb.jsx)("b",{children:"API Key"})," 是密钥;",(0,eb.jsx)("b",{children:"可用模型"})," 勾选启用并可设上下文长度。",(0,eb.jsx)("br",{}),"⚠️ 填完",(0,eb.jsx)("b",{children:"务必点「保存」"}),",否则不生效。"]})},{id:"agent-config-compression",before:edh(()=>e.select("preferences-agent-config")),target:'[data-tour="agent-config-compression"]',title:"代理配置 · 压缩上下文",body:(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("b",{children:"设置 → 代理配置"})," 的第一块:当对话 token 接近模型上下文窗口的设定百分比时,自动用",(0,eb.jsx)("b",{children:"压缩模型"})," 压缩历史。阈值 0% 表示关闭,建议 70%-85%。"]})},{id:"agent-config-summary",before:edh(()=>e.select("preferences-agent-config")),target:'[data-tour="agent-config-summary"]',title:"代理配置 · 对话摘要",body:(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("b",{children:"对话摘要"}),":开启后用",(0,eb.jsx)("b",{children:"摘要模型"}),"自动生成 / 更新对话标题与每轮的轮次标题,方便在侧边栏 与时间轴里快速辨认。"]})},{id:"agent-config-approval",before:edh(()=>e.select("preferences-agent-config")),target:'[data-tour="agent-config-approval"]',title:"代理配置 · 命令审批",body:(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("b",{children:"命令审批"}),":在 Auto 权限模式下,用",(0,eb.jsx)("b",{children:"审批模型"})," + ",(0,eb.jsx)("b",{children:"审批提示词"})," 判断 Agent 发起的命令 是否自动放行。留空则非危险命令全部放行。改完记得 ",(0,eb.jsx)("b",{children:"保存"}),"。"]})},{id:"subagent-explore",before:edh(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-explore"]',title:"子代理 · 探索",body:(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("b",{children:"设置 → 子代理配置"}),"。",(0,eb.jsx)("b",{children:"探索"})," 子代理擅长只读检索代码 / 资料。可单独设它的",(0,eb.jsx)("b",{children:"使用模型"}),"(留空则继承上级)与",(0,eb.jsx)("b",{children:"系统提示词"}),"。"]})},{id:"subagent-workflow",before:edh(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-workflow"]',title:"子代理 · 工作流",body:(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("b",{children:"工作流"})," 子代理负责多步骤任务编排,同样可单独配模型与提示词。"]})},{id:"subagent-operator",before:edh(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-operator"]',title:"子代理 · 操作",body:(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("b",{children:"操作"})," 子代理执行写文件 / 跑命令等动手类任务,工具集固定。"]})},{id:"subagent-custom",before:edh(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-custom"]',title:"子代理 · 自定义",body:(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("b",{children:"自定义子代理"}),":主 Agent 可自取名字、从你设的",(0,eb.jsx)("b",{children:"可用模型池"}),"里挑模型来召唤,拥有完整 工具集,还能再派发上面三种官方子代理。"]})},{id:"check-update",before:edh(()=>e.select("check-update")),target:'[data-tour="check-update"]',title:"检查更新",body:(0,eb.jsxs)(eb.Fragment,{children:["这里查看各机器的运行时版本并 ",(0,eb.jsx)("b",{children:"立即更新"}),"。原理:从 npm 拉取最新运行时包、就地替换二进制与 前端,",(0,eb.jsx)("b",{children:"无需重装"}),";P2P mesh 未变时更新还",(0,eb.jsx)("b",{children:"不需要管理员权限"}),"。"]})},{id:"hub-account",before:edh(()=>e.select("account")),target:'[data-tour="hub-account"]',title:"Hub 账户",body:(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("b",{children:"设置 → Hub 账户"}),"。上方是你的",(0,eb.jsx)("b",{children:"账户信息"}),"与",(0,eb.jsx)("b",{children:"设备绑定"}),"状态——Hub 负责多机互联、组网 下发与云端身份。"]})},{id:"hub-account-danger",before:edh(()=>e.select("account")),target:'[data-tour="hub-account-danger"]',title:"Hub 账户 · 危险操作",body:(0,eb.jsxs)(eb.Fragment,{children:["下方的 ",(0,eb.jsx)("b",{children:"危险操作"})," 区可",(0,eb.jsx)("b",{children:"解除设备绑定"}),"或",(0,eb.jsx)("b",{children:"退出登录"}),"。这些操作不可逆,会把本机移出 账户,请谨慎。"]})},{id:"new-conversation",before:edh(()=>e.goHome()),target:'[data-tour="home-new-conversation"]',gate:edx,gateHint:"点击「新建对话」继续",title:"创建新对话",body:(0,eb.jsxs)(eb.Fragment,{children:["回到主页,请点 ",(0,eb.jsx)("b",{children:"新建对话"})," 进入初始化向导(侧边栏顶部也有同样入口)。"]})},{id:"wizard-1",target:'[data-tour="init-wizard"]',placement:"left",padding:4,waitForTarget:5e3,gate:()=>!edx()||edv()>=2,gateHint:"配好运行环境后点向导的「下一步」",title:"向导 ① 运行环境与引擎",body:(0,eb.jsxs)(eb.Fragment,{children:["先选在",(0,eb.jsx)("b",{children:"哪台机器"}),"上运行;本机运行时还能选 ",(0,eb.jsx)("b",{children:"运行引擎"}),"——",(0,eb.jsx)("b",{children:"Vantaloom"})," / ",(0,eb.jsx)("b",{children:"Claude Code"})," / ",(0,eb.jsx)("b",{children:"reclaude"}),"(Claude Code 仅限本机)。 整个向导区域已高亮,配好后点向导自己的 ",(0,eb.jsx)("b",{children:"下一步"}),"。"]})},{id:"wizard-2",target:'[data-tour="init-wizard"]',placement:"left",padding:4,gate:()=>!edx()||edv()>=3,gateHint:"选好工作目录后点向导的「下一步」",title:"向导 ② 选择工作目录",body:(0,eb.jsxs)(eb.Fragment,{children:["先给对话",(0,eb.jsx)("b",{children:"起个名字"}),",再选 ",(0,eb.jsx)("b",{children:"工作目录"}),"——这是智能体能读写的根目录 (Claude Code 用单个目录作为工作根目录)。选好后点向导的「下一步」。"]})},{id:"wizard-3",target:'[data-tour="init-wizard"]',placement:"left",padding:4,gate:()=>!edx()||edv()>=4,gateHint:"配好模型后点向导的「下一步」",title:"向导 ③ 模型设置",body:(0,eb.jsxs)(eb.Fragment,{children:["选择这段对话使用的",(0,eb.jsx)("b",{children:"模型"}),"——",(0,eb.jsx)("b",{children:"Vantaloom"})," 用你刚配置的模型路由,",(0,eb.jsx)("b",{children:"Claude Code"})," 则由其自身提供模型。选好后点向导的「下一步」。"]})},{id:"wizard-4",target:'[data-tour="init-wizard"]',placement:"left",padding:4,gate:()=>!edx(),gateHint:"点向导的「确认开始」创建对话",title:"向导 ④ 确认开始",body:(0,eb.jsxs)(eb.Fragment,{children:["核对无误后,点向导右下角的 ",(0,eb.jsx)("b",{children:"确认开始"})," 创建对话。创建成功后会自动进入对话界面。"]})},{id:"composer-toolbar",target:'[data-slot="agent-input-composer-toolbar"]',waitForTarget:6e3,title:"输入框下方的按钮",body:(0,eb.jsxs)(eb.Fragment,{children:["输入框下面一排:",(0,eb.jsx)("b",{children:"权限模式"}),"(工具调用是否需审批)、",(0,eb.jsx)("b",{children:"模型选择"}),"、右侧 ",(0,eb.jsx)("b",{children:"发送 / 停止"}),"按钮(运行中变停止),以及 ",(0,eb.jsx)("b",{children:"上下文用量"})," 指示。"]})},{id:"queue-stack",target:'[data-slot="agent-input-composer-textarea"]',waitForTarget:3e3,title:"待发送栈(Tab 键)",body:(0,eb.jsxs)(eb.Fragment,{children:["输入内容后按 ",(0,eb.jsx)("kbd",{children:"Tab"})," 可把它压入",(0,eb.jsx)("b",{children:"待发送栈"}),"而不立即发送,便于排队多条指令。栈里每条都能 点击:用 ",(0,eb.jsx)("b",{children:"引导"})," 在合适时机插入对话,或删除。"]})},{id:"pane-toolbar",target:'[data-tour="pane-toolbar"]',waitForTarget:3e3,title:"工作区顶栏",body:(0,eb.jsxs)(eb.Fragment,{children:["右侧工作区最上面一排:左边 ",(0,eb.jsx)("b",{children:"布局标签"})," 切换分屏预设,中间 ",(0,eb.jsx)("b",{children:"位置切换"})," 控制对话面板在左 / 居中 / 在右。"]})},{id:"pane-split",target:'[aria-label="上下二分"]',waitForTarget:4e3,gate:()=>null!=edp('[aria-label="上下二分"][data-state="active"]'),gateHint:"点「上下二分」分栏",title:"动手 · 上下分栏",body:(0,eb.jsxs)(eb.Fragment,{children:["在布局标签里点 ",(0,eb.jsx)("b",{children:"上下二分"}),"(顶部面板图标),把右侧工作区分成上下两块。"]})},{id:"pane-add-top",target:'[data-tour="pane-add"]',waitForTarget:3e3,gate:()=>null!=edp('[placeholder="搜索组件..."]')||null!=edp('[data-slot="multi-tab-list"]'),gateHint:"点上面板的「添加」",autoAdvance:!0,title:"动手 · 添加上面板组件",body:(0,eb.jsxs)(eb.Fragment,{children:["点",(0,eb.jsx)("b",{children:"上面板"}),"中间的 ",(0,eb.jsx)("b",{children:"添加"})," 按钮,打开组件选择面板。"]})},{id:"pane-pick-multitab",target:'[data-tour="pane-template-multi-tab-system"]',waitForTarget:3e3,gate:()=>null!=edp('[data-slot="multi-tab-list"]'),gateHint:"选择「多标签页系统」",title:"动手 · 选多文件标签组件",body:(0,eb.jsxs)(eb.Fragment,{children:["在弹出面板里找到 ",(0,eb.jsx)("b",{children:"多标签页系统"}),"(即多文件标签组件)并点击添加,它会填入上面板。"]})},{id:"multi-tab",target:'[data-slot="multi-tab-list"]',waitForTarget:3e3,title:"多文件标签组件",body:(0,eb.jsxs)(eb.Fragment,{children:["顶部是",(0,eb.jsx)("b",{children:"多文件标签条"}),":点 ",(0,eb.jsx)("b",{children:"+"})," 新增标签、点标签切换文件、",(0,eb.jsx)("b",{children:"×"})," 关闭。单文件内还能在",(0,eb.jsx)("b",{children:"查看 / 编辑"})," 与 ",(0,eb.jsx)("b",{children:"代码 / 预览 / 十六进制"})," 间切换,编辑后记得保存。"]})},{id:"pane-add-bottom",target:'[data-tour="pane-add"]',waitForTarget:3e3,gate:()=>null!=edp('[placeholder="搜索组件..."]')||null!=edp('[data-slot="terminal-tab-group"]'),gateHint:"点下面板的「添加」",autoAdvance:!0,title:"动手 · 添加下面板组件",body:(0,eb.jsxs)(eb.Fragment,{children:["现在点",(0,eb.jsx)("b",{children:"下面板"}),"的 ",(0,eb.jsx)("b",{children:"添加"})," 按钮,再次打开组件选择面板。"]})},{id:"pane-pick-terminal",target:'[data-tour="pane-template-terminal-tab-group"]',waitForTarget:3e3,gate:()=>null!=edp('[data-slot="terminal-tab-group"]'),gateHint:"选择「终端标签组」",title:"动手 · 选终端",body:(0,eb.jsxs)(eb.Fragment,{children:["在面板里找到 ",(0,eb.jsx)("b",{children:"终端标签组"})," 并点击添加,它会填入下面板。"]})},{id:"terminal",target:'[data-slot="terminal-tab-group"]',waitForTarget:3e3,title:"终端组件",body:(0,eb.jsxs)(eb.Fragment,{children:["终端支持多会话标签:点 ",(0,eb.jsx)("b",{children:"+"})," 新开会话、点标签切换、",(0,eb.jsx)("b",{children:"×"})," 关闭。直接输入命令即可,输出实时回显,与本机真实 shell 一致。"]})},{id:"pane-cut-clear",target:'[aria-label="剪切窗口内容"]',waitForTarget:3e3,title:"剪切与粉碎",body:(0,eb.jsxs)(eb.Fragment,{children:["顶栏的 ",(0,eb.jsx)("b",{children:"剪切"}),"(剪刀)把窗口内容移动到别处;",(0,eb.jsx)("b",{children:"粉碎"}),"(碎纸机)清空该窗口。均对单个 pane 生效。"]})},{id:"control-room",target:'[data-tour="control-room-toggle"]',waitForTarget:3e3,title:"导播台视角",body:(0,eb.jsxs)(eb.Fragment,{children:["点位置切换中间的 ",(0,eb.jsx)("b",{children:"「隐藏面板」"}),"(矩形图标)进入",(0,eb.jsx)("b",{children:"导播台"}),":对话偏左,右侧悬浮显示主 Agent 与各子 Agent 的实时预览小窗,点小窗即可切换主面板。"]})},{id:"outro",centered:!0,title:"完成 🎉",body:(0,eb.jsxs)(eb.Fragment,{children:["你已走过核心功能。随时可从空白页的 ",(0,eb.jsx)("b",{children:"使用教程"})," 重新打开本向导。开始创造吧!"]})}]}))},[ed,Q,eu]),em=ew.useCallback(()=>{i("account")},[]),eh=d?.id??s?.conversation.id,ep=!!d&&s?.conversation.id!==d.id,eg="new-agent-conversation"===a||"project-conversation"===a,ex=(0,eb.jsxs)("section",{className:(0,ez.cn)("relative h-full min-w-0 flex-1 overflow-hidden",e&&"pt-[calc(3rem+env(safe-area-inset-top))]"),children:["runs"===a?(0,eb.jsx)(edu,{clipboardItems:E,onClipboardItemsChange:I,onOverlayOpenChange:M}):"telemetry"===a?(0,eb.jsx)(edf,{clipboardItems:E,onClipboardItemsChange:I,onOverlayOpenChange:M}):"preferences-models"===a?(0,eb.jsx)(esZ,{}):"preferences-agents"===a?(0,eb.jsx)(es1,{}):"system-general"===a?(0,eb.jsx)(ecj,{}):"network-downloads"===a?(0,eb.jsx)(ec$,{}):"preferences-model-routes"===a?(0,eb.jsx)(esY,{section:"model-routes"}):"preferences-model-groups"===a?(0,eb.jsx)(esY,{section:"model-groups"}):"preferences-agent-config"===a?(0,eb.jsx)(esY,{section:"agent-config"}):"preferences-subagent-config"===a?(0,eb.jsx)(esY,{section:"subagent-config"}):"preferences-cc-engine-config"===a?(0,eb.jsx)(esY,{section:"cc-engine-config"}):"preferences-assets"===a?(0,eb.jsx)(esY,{section:"assets"}):"preferences-layout"===a?(0,eb.jsx)(esY,{section:"layout"}):"preferences-official-extensions"===a?(0,eb.jsx)(ec0,{}):"network-topology"===a?(0,eb.jsx)(es9,{}):"network-settings"===a?(0,eb.jsx)(ecL,{}):"search-settings"===a?(0,eb.jsx)(ecY,{}):"system-downloads"===a?(0,eb.jsx)(ecA,{}):"preferences"===a?(0,eb.jsx)(esY,{}):"check-update"===a?(0,eb.jsx)(ecd,{}):"balance-usage"===a?(0,eb.jsx)(eca,{}):"feedback"===a?(0,eb.jsx)(ecg,{}):"account"===a?(0,eb.jsx)(esr,{}):e||"new-canvas"!==a?e||"all-canvases"!==a?"new-project"===a?(0,eb.jsx)(eiD,{onCreated:e=>{window.dispatchEvent(new CustomEvent(eix)),er(e)},onCancel:()=>i("home")}):"project-overview"===a&&W?(0,eb.jsx)(eoZ,{projectId:W,onOpenSettings:ei,onOpenConversation:(e,t)=>{el(W,e,t)}}):"project-settings"===a&&W?(0,eb.jsx)(eiG,{projectId:W,onClose:()=>i("project-overview")}):"kanban"===a&&W?(0,eb.jsx)(eoH,{projectId:W}):("new-agent-conversation"===a||"project-conversation"===a)&&ep?(0,eb.jsxs)("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 text-muted-foreground",children:[(0,eb.jsx)(eM,{className:"size-6 animate-spin"}),(0,eb.jsx)("span",{className:"text-sm",children:"正在打开对话…"})]}):"new-agent-conversation"===a||"project-conversation"===a?(0,eb.jsx)(ee8,{conversation:s,clipboardItems:E,clipboardDraggingId:T,onClipboardItemsChange:I,onClipboardDraggingChange:R,onOverlayOpenChange:l,onConversationCreated:e=>{c(e)},onCancelDraft:()=>i("home"),subagentStack:f,onSubagentStackChange:m,subagentTree:h,mobileView:g,onMobilePaneCountChange:b}):e?(0,eb.jsx)(edj,{activeConversationId:eh,onItemSelect:ed,onOpenConversation:(e,t)=>{J(e,t)},onOpenConversationSettings:(e,t)=>{k({id:e,owner:t})},onConversationDeleted:e=>{k(t=>t?.id===e?void 0:t)}}):(0,eb.jsx)(edw,{onNewConversation:Q,onStartTour:ef}):(0,eb.jsx)(eis,{clipboardItems:E,onClipboardItemsChange:I,onOverlayOpenChange:M}):(0,eb.jsx)(eig,{nodes:D,edges:L,selectedNodeId:F,clipboardItems:E,onNodesChange:X,onEdgesChange:Y,onNodesSet:_,onEdgesSet:$,onSelectedNodeChange:B,onClipboardItemsChange:I}),j?(0,eb.jsx)("div",{className:(0,ez.cn)("absolute inset-0 z-30",e&&"pt-[calc(3rem+env(safe-area-inset-top))]"),children:(0,eb.jsx)(enP,{conversationId:j.id,ownerMachineId:j.owner,open:!0,onOpenChange:e=>{e||k(void 0)},onEnterConversation:(e,t)=>{J(e,t)}})}):null,(0,eb.jsx)(enA,{open:N,onOpenChange:S,onEnterConversation:(e,t)=>{J(e,t)}}),(0,eb.jsx)(elt,{hidden:!!j||(eg?o:C),items:E,trashItems:P,draggingId:T,onDraggingChange:R,onItemsChange:I,onTrashItemsChange:O,onTrashClipboardItemsChange:A,trashClipboardItems:z})]});return(0,eb.jsxs)("main",{className:"vtl-app-background relative flex h-svh overflow-hidden text-foreground select-none [-webkit-touch-callout:none]",children:[e?(0,eb.jsx)(el4,{navItems:el8,contents:el7,activeWorkspace:a,activeConversationId:eh,activeProjectId:W,onItemSelect:ed,onOpenConversation:(e,t)=>{J(e,t)},onOpenProjectCanvas:(e,t)=>{eo(e,t)},onOpenProjectOverview:er,onOpenProjectKanban:ea,onOpenProjectSettings:ei,onNewProjectConversation:e=>{ec(e)},onOpenProjectConversation:(e,t,n)=>{el(e,t,n)},onNewProject:()=>{es()},onOpenConversationSettings:(e,t)=>{k({id:e,owner:t})},onConversationDeleted:e=>{s?.conversation.id===e&&(c(void 0),i("home")),k(t=>t?.id===e?void 0:t)},onAccountSettings:em,subagentTree:h,activeSubagentPath:f,onOpenSubagent:e=>m(e),title:eg&&s?s.conversation.title?.trim()||"新 Agent 对话":en2.product,trailing:eg&&s?(0,eb.jsx)(kI,{view:g,onViewChange:x,paneCount:v}):(0,eb.jsx)(ec6,{}),children:ex}):(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("div",{className:(0,ez.cn)("relative hidden h-svh shrink-0 overflow-hidden p-3 transition-[width,padding] duration-300 ease-out md:block",t?"w-0 p-0":"w-[19.5rem]"),children:(0,eb.jsx)(elS,{navItems:el8,contents:el7,activeWorkspace:a,activeConversationId:eh,activeCanvasId:V,activeProjectId:W,onItemSelect:ed,onOpenConversation:(e,t)=>{J(e,t)},onOpenCanvas:(e,t)=>{en(e,t)},onOpenProjectCanvas:(e,t)=>{eo(e,t)},onOpenProjectOverview:er,onOpenProjectKanban:ea,onOpenProjectSettings:ei,onNewProjectConversation:e=>{ec(e)},onOpenProjectConversation:(e,t,n)=>{el(e,t,n)},onNewProject:()=>{es()},onOpenConversationSettings:(e,t)=>{k({id:e,owner:t})},onConversationDeleted:e=>{s?.conversation.id===e&&(c(void 0),i("home")),k(t=>t?.id===e?void 0:t)},onAccountSettings:em,subagentTree:h,activeSubagentPath:f,onOpenSubagent:e=>m(e)})}),(0,eb.jsx)("div",{className:(0,ez.cn)("group/sb-handle absolute inset-y-0 z-30 hidden w-8 md:block","transition-[left] duration-300 ease-out",t?"left-0":"left-[18.5rem]"),children:(0,eb.jsx)("button",{type:"button",onClick:r,"aria-label":t?"展开侧边栏":"收起侧边栏",title:t?"展开侧边栏":"收起侧边栏",className:"absolute top-1/2 left-0 flex h-14 w-6 -translate-y-1/2 items-center justify-center rounded-r-md border border-l-0 border-border bg-background/85 text-muted-foreground opacity-0 shadow-md backdrop-blur transition-opacity duration-200 hover:text-foreground focus-visible:opacity-100 group-hover/sb-handle:opacity-100",children:t?(0,eb.jsx)(tc,{className:"size-4"}):(0,eb.jsx)(ts,{className:"size-4"})})})]}),e?null:ex]})}function edw({onNewConversation:e,onStartTour:t}){return(0,eb.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col items-center justify-center gap-5 px-6 text-center",children:[(0,eb.jsx)(edm,{className:"h-20 w-auto max-w-[78vw] text-foreground"}),(0,eb.jsx)("p",{className:"max-w-sm text-sm text-muted-foreground",children:"从左侧选择一个会话,或新建对话"}),(0,eb.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[(0,eb.jsxs)(eO.Button,{type:"button",onClick:e,"data-tour":"home-new-conversation",children:[(0,eb.jsx)(tl,{className:"size-4"}),"新建对话"]}),(0,eb.jsxs)(eO.Button,{type:"button",variant:"outline",onClick:t,children:[(0,eb.jsx)(to,{className:"size-4"}),"使用教程"]})]})]})}function edj({activeConversationId:e,onItemSelect:t,onOpenConversation:n,onOpenConversationSettings:r,onConversationDeleted:a}){return(0,eb.jsx)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col px-3 pt-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]",children:(0,eb.jsx)(elT,{activeConversationId:e,onItemSelect:t,onOpenConversation:n,onOpenConversationSettings:r,onConversationDeleted:a})})}function edk(){let{ready:e,user:t,logout:n}=ti();return e?t?(0,eb.jsx)(edy,{}):(0,eb.jsx)(tn,{onComplete:()=>{window.location.reload()}}):(0,eb.jsx)("main",{className:"grid min-h-svh place-items-center bg-background",children:(0,eb.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,eb.jsx)("div",{className:"size-8 animate-spin rounded-full border-2 border-muted-foreground/20 border-t-primary"}),(0,eb.jsx)("span",{className:"text-sm text-muted-foreground",children:"连接中..."})]})})}function edN(){return(0,eb.jsx)(ta,{children:(0,eb.jsx)(edk,{})})}e.s(["default",()=>edN],66204)}]);
66
+ </style>`,/<\/head>/i.test(t)?t.replace(/<\/head>/i,`${n}</head>`):`${n}${t}`},[r,t]);return(0,eb.jsx)("iframe",{title:e,sandbox:"allow-scripts",srcDoc:a,className:(0,ez.cn)("size-full border-0 bg-background",n)})}function XT({file:e,value:t,labels:n}){let r=ew.useMemo(()=>{let n=e.bytes??(t?new TextEncoder().encode(t):[]),r=Math.min(n.length,4096),a=[];for(let e=0;e<r;e+=16){let t=Array.from({length:Math.min(16,r-e)},(t,r)=>n[e+r]??0);a.push({offset:e.toString(16).padStart(8,"0"),hex:t.map(e=>e.toString(16).padStart(2,"0")).join(" "),ascii:t.map(e=>e>=32&&e<=126?String.fromCharCode(e):".").join("")})}return a},[e.bytes,t]);return 0===r.length?(0,eb.jsx)("div",{className:"ui-text-body grid size-full place-items-center p-6 text-center text-muted-foreground",children:n.noContent}):(0,eb.jsx)("div",{className:"size-full overflow-auto bg-background p-3 ui-text-code",children:(0,eb.jsx)("div",{className:"grid min-w-max grid-cols-[5.5rem_30rem_1fr] gap-x-4",children:r.map(e=>(0,eb.jsxs)(ew.Fragment,{children:[(0,eb.jsx)("span",{className:"text-muted-foreground",children:e.offset}),(0,eb.jsx)("span",{className:"font-mono text-foreground",children:e.hex}),(0,eb.jsx)("span",{className:"font-mono text-muted-foreground",children:e.ascii})]},e.offset))})})}function XR({file:e,labels:t,onApprove:n}){return(0,eb.jsx)("div",{className:"grid size-full place-items-center bg-muted/20 p-6",children:(0,eb.jsxs)("div",{className:"grid max-w-md justify-items-center gap-3 text-center",children:[(0,eb.jsx)("div",{className:"grid size-10 place-items-center rounded-full border bg-background text-muted-foreground",children:(0,eb.jsx)(Xx,{className:"size-4"})}),(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsx)("h3",{className:"ui-text-body font-medium text-foreground",children:t.binaryTitle}),(0,eb.jsx)("p",{className:"ui-text-body text-muted-foreground",children:t.binaryDescription})]}),(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[XM(e.size)&&(0,eb.jsx)(Vp,{variant:"outline",children:XM(e.size)}),(0,eb.jsx)(eO.Button,{type:"button",size:"sm",variant:"outline",onClick:n,children:t.renderAnyway})]})]})})}function XD({labels:e}){return(0,eb.jsx)("div",{className:"ui-text-body grid size-full place-items-center p-6 text-center text-muted-foreground",children:e.unsupportedPreview})}function X_({file:e,value:t,labels:n,renderPreview:r,className:a}){let i=XS(e),o=e.src?e.src:t&&"svg"===XS(e)?`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`:void 0,l=r?.(e,t);return void 0!==l?(0,eb.jsx)("div",{"data-slot":"file-tab-custom-preview",className:(0,ez.cn)("size-full",a),children:l}):"html"===i||"richtext"===i?(0,eb.jsx)(XA,{title:e.name,value:e.previewContent??t,className:a}):"markdown"===i?(0,eb.jsx)("div",{"data-slot":"file-tab-markdown-preview",className:(0,ez.cn)("size-full overflow-auto bg-background",a),children:(0,eb.jsx)(Xz,{value:t})}):"svg"===i&&o?(0,eb.jsx)("div",{"data-slot":"file-tab-svg-preview",className:(0,ez.cn)("grid size-full place-items-center overflow-auto bg-muted/20 p-6",a),children:(0,eb.jsx)("img",{src:o,alt:e.name,className:"max-h-full max-w-full rounded-lg border bg-background p-4"})}):"image"===i&&o?(0,eb.jsx)("div",{"data-slot":"file-tab-image-preview",className:(0,ez.cn)("grid size-full place-items-center overflow-auto bg-muted/20 p-6",a),children:(0,eb.jsx)("img",{src:o,alt:e.name,className:"max-h-full max-w-full rounded-md"})}):"video"===i&&o?(0,eb.jsx)("div",{"data-slot":"file-tab-video-preview",className:(0,ez.cn)("grid size-full place-items-center bg-muted/20 p-6",a),children:(0,eb.jsx)("video",{src:o,controls:!0,preload:"none",className:"max-h-full max-w-full rounded-md border bg-background"})}):(0,eb.jsx)(XD,{labels:n})}function XL({open:e,labels:t,currentView:n,currentMode:r,saving:a,modified:i,canSwitchView:o,canSwitchMode:l,canSave:s,canOpenHistory:c,onOpenChange:d,onToggleView:u,onToggleMode:f,onSave:m,onHistory:h}){let p=[o?{key:"view",label:"code"===n?t.preview:t.code,onClick:u,icon:"code"===n?(0,eb.jsx)(qR,{className:"size-4"}):(0,eb.jsx)(uW,{className:"size-4"})}:void 0,l?{key:"mode",label:"review"===r?t.edit:t.review,onClick:f,icon:"review"===r?(0,eb.jsx)(Xv,{className:"size-4"}):(0,eb.jsx)(eN,{className:"size-4"})}:void 0,s?{key:"save",label:a?t.saving:t.save,onClick:m,disabled:a||!i,icon:(0,eb.jsx)(Xj,{className:"size-4"})}:void 0,c?{key:"history",label:t.history,onClick:h,icon:(0,eb.jsx)(Xb,{className:"size-4"})}:void 0].filter(e=>void 0!==e);return 0===p.length?null:(0,eb.jsx)("div",{"data-slot":"file-tab-floating-actions",className:"absolute right-3 bottom-3 z-20",children:(0,eb.jsxs)("div",{className:"relative size-8",children:[p.map((t,n)=>(0,eb.jsx)(eO.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.label,disabled:t.disabled,onClick:()=>{t.disabled||t.onClick()},className:(0,ez.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[opacity,transform] duration-150 ease-out",e?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0",t.disabled&&"opacity-45"),style:{transform:e?`translateY(-${(n+1)*42}px)`:void 0},children:t.icon},t.key)),(0,eb.jsx)(eO.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.actions,"aria-expanded":e,onClick:()=>d(!e),className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,eb.jsx)(lG,{className:(0,ez.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}function X$({file:e,value:t,defaultValue:n,onValueChange:r,mode:a,defaultMode:i="review",onModeChange:o,view:l,defaultView:s="code",onViewChange:c,modified:d=!1,onSave:u,onSaveError:f,largeBinaryThreshold:m=2097152,showHeader:h=!0,wrapLines:p=!1,renderPreview:g,onHistory:x,labels:v,className:b,editorClassName:y,previewClassName:w,headerClassName:j,...k}){var N;let S,C,M=ew.useMemo(()=>({...Xk,...v}),[v]),[E,I]=ew.useState(n??e.content??""),[P,O]=ew.useState(i),[z,A]=ew.useState(s),[T,R]=ew.useState(!1),[D,_]=ew.useState(!1),[L,$]=ew.useState(!1),F=ew.useRef(null),B=t??E,V=a??P,H=(N=l??z,(S=XE(e)).includes(N)?N:S[0]),U=XS(e),q=XE(e).length>1,W=!e.readOnly&&["text","code","html","markdown","richtext","svg"].includes(XS(e)),K=!!u&&W&&"code"===H&&(d||L),G="review"===V||!0===e.readOnly,X="binary"===(C=XS(e))||"image"!==C&&"video"!==C&&!!(e.size&&e.size>m&&!e.content),Y=(e.path??e.name).split(/[\\/]+/).filter(Boolean),Z=XM(e.size??B.length);async function J(){if(u&&!L){$(!0);try{await u(B),_(!1)}catch(e){f?.(e)}finally{$(!1)}}}return ew.useEffect(()=>{void 0===t&&I(n??e.content??""),R(!1),_(!1)},[n,e,t]),ew.useEffect(()=>{if(D)return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e);function e(e){let t=e.target;t instanceof Node&&F.current?.contains(t)||_(!1)}},[D]),(0,eb.jsxs)("div",{ref:F,"data-slot":"file-tab-viewer","data-mode":V,"data-view":H,className:(0,ez.cn)("vtl-surface-panel relative grid min-h-0 overflow-hidden rounded-[var(--surface-panel-radius)] border",h?"grid-rows-[auto_minmax(0,1fr)]":"grid-rows-[minmax(0,1fr)]",b),...k,children:[h&&(0,eb.jsxs)("div",{"data-slot":"file-tab-viewer-header",className:(0,ez.cn)("flex min-w-0 items-center gap-2 border-b bg-muted/35 px-3 py-2",j),children:[(0,eb.jsx)("span",{className:"grid size-5 shrink-0 place-items-center rounded-md border bg-background text-muted-foreground",children:"image"===U?(0,eb.jsx)(Xy,{className:"size-3.5"}):"video"===U?(0,eb.jsx)(Xw,{className:"size-3.5"}):"binary"===U?(0,eb.jsx)(Xx,{className:"size-3.5"}):(0,eb.jsx)(b2,{className:"size-3.5"})}),(0,eb.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 ui-text-kbd",children:Y.map((e,t)=>(0,eb.jsxs)(ew.Fragment,{children:[t>0&&(0,eb.jsx)("span",{className:"text-muted-foreground",children:M.pathSeparator}),(0,eb.jsx)("span",{className:(0,ez.cn)("truncate",t===Y.length-1?"font-medium text-foreground":"text-muted-foreground"),children:e})]},`${e}-${t}`))}),(0,eb.jsxs)("div",{className:"hidden shrink-0 items-center gap-1.5 sm:flex",children:[Z&&(0,eb.jsx)(Vp,{variant:"outline",children:Z}),W&&"code"===H&&(G?(0,eb.jsxs)(Vp,{variant:"secondary",children:[(0,eb.jsx)(lq,{className:"size-3"}),M.review]}):(0,eb.jsxs)(Vp,{variant:"outline",children:[(0,eb.jsx)(Xv,{className:"size-3"}),M.edit]}))]})]}),(0,eb.jsx)("div",{"data-slot":"file-tab-viewer-body",className:"min-h-0 overflow-hidden",children:X&&!T?(0,eb.jsx)(XR,{file:e,labels:M,onApprove:()=>R(!0)}):"preview"===H?(0,eb.jsx)(X_,{file:e,value:B,labels:M,renderPreview:g,className:w}):"hex"===H?(0,eb.jsx)(XT,{file:e,value:B,labels:M}):(0,eb.jsx)(XO,{file:e,value:B,readOnly:G,onValueChange:function(e){void 0===t&&I(e),r?.(e)},wrapLines:p,className:y})}),(0,eb.jsx)(XL,{open:D,labels:M,currentView:H,currentMode:V,saving:L,modified:d,canSwitchView:q,canSwitchMode:W&&"code"===H,canSave:K,canOpenHistory:!!(x&&e.path),onOpenChange:_,onToggleView:function(){var e;e="code"===H?"preview":"code",void 0===l&&A(e),c?.(e)},onToggleMode:function(){var e;e="review"===V?"edit":"review",void 0===a&&O(e),o?.(e)},onSave:J,onHistory:()=>{_(!1),x?.(e)}})]})}function XF(e,t){return e[Math.max(0,t-1)]?.id??e[0]?.id}function XB(e){return"string"==typeof e||"number"==typeof e?String(e):void 0}function XV(e,t,n){let r=[...e],a=r[t],i=r[n];return a&&i&&(r[t]=i,r[n]=a),r}function XH({tabs:e,defaultTabs:t=[],activeTabId:n,defaultActiveTabId:r,onActiveTabChange:a,onTabsChange:i,onCreateTab:o,onCloseTab:l,onTabReorder:s,onTabDetach:c,onExternalTabDrop:d,createActions:u=[],tabActions:f=[],reorderable:m=!0,detachable:h=!1,externalDropTypes:p=[],createLabel:g="New tab",moreLabel:x="More tab actions",closeLabel:v="Close tab",scrollLeftLabel:b="Scroll tabs left",scrollRightLabel:y="Scroll tabs right",tabListLabel:w="Open tabs",emptyContent:j,renderContent:k,showContent:N=!0,className:S,tabListClassName:C,contentClassName:M}){let[E,I]=ew.useState(t),P=ew.useRef(null),O=ew.useRef(null),[z,A]=ew.useState(),[T,R]=ew.useState(void 0),D=ew.useRef(void 0),[_,L]=ew.useState(void 0),[$,F]=ew.useState(!1),B=ew.useRef(void 0),V=ew.useRef(void 0),H=ew.useRef(!1),[U,q]=ew.useState(!1),[W,K]=ew.useState(!1),[G,X]=ew.useState(),Y=e??E,Z=Y.find(e=>!e.disabled),[J,Q]=ew.useState(r??Z?.id),ee=n??J,et=Y.find(e=>e.id===ee&&!e.disabled)??Z;ew.useEffect(()=>{!et&&Z&&void 0===n&&Q(Z.id)},[et,n,Z]);let en=ew.useCallback(t=>{void 0===e&&I(t),i?.(t)},[i,e]),er=ew.useCallback(e=>{D.current=e,R(e)},[]),ea=ew.useCallback(()=>{let e=O.current,t=new Map;if(!e)return t;for(let n of e.querySelectorAll("[data-tab-id]")){let e=n.getBoundingClientRect(),r=n.dataset.tabId;r&&t.set(r,{left:e.left,top:e.top})}return t},[]),ei=ew.useCallback((e,t=!0)=>{t&&(V.current=ea()),B.current=e,L(e)},[ea]),eo=ew.useCallback(()=>{let e=O.current;if(!e){q(!1),K(!1);return}let t=e.scrollWidth-e.clientWidth;q(e.scrollLeft>1),K(e.scrollLeft<t-1)},[]);function el(e){let t=O.current;if(!t)return;let n=Math.max(.7*t.clientWidth,160);t.scrollLeft+="left"===e?-n:n,window.requestAnimationFrame(eo)}ew.useEffect(()=>{F(!0)},[]),ew.useEffect(()=>{eo();let e=O.current;if(!e)return;let t=new ResizeObserver(eo);return t.observe(e),window.addEventListener("resize",eo),()=>{t.disconnect(),window.removeEventListener("resize",eo)}},[Y.length,eo]),ew.useLayoutEffect(()=>{let e=V.current,t=O.current;if(e&&t)for(let n of(V.current=void 0,t.querySelectorAll("[data-tab-id]"))){let t=n.dataset.tabId;if(!t)continue;let r=e.get(t);if(!r)continue;let a=n.getBoundingClientRect(),i=r.left-a.left,o=r.top-a.top;1>Math.abs(i)&&1>Math.abs(o)||n.animate([{transform:`translate(${i}px, ${o}px)`},{transform:"translate(0, 0)"}],{duration:150,easing:"cubic-bezier(0.2, 0, 0, 1)"})}},[_]);let es=ew.useCallback(e=>{let t=O.current;if(t)return Array.from(t.querySelectorAll("[data-tab-id]")).find(t=>t.dataset.tabId===e)},[]),ec=ew.useCallback((e,t)=>{let n=B.current??Y,r=n.findIndex(t=>t.id===e.tabId);if(-1===r)return;let a=t-e.offsetX,i=a+e.width,o=t>=e.currentX,l=n[r+1],s=n[r-1];if(o&&l&&!l.disabled){let e=es(l.id),t=e?.getBoundingClientRect();t&&i>=t.left+.7*t.width&&ei(XV(n,r,r+1));return}if(!o&&s&&!s.disabled){let e=es(s.id),t=e?.getBoundingClientRect();t&&a<=t.right-.7*t.width&&ei(XV(n,r,r-1))}},[es,Y,ei]);function ed(e){if(!d||0===p.length)return!1;let t=Array.from(e.dataTransfer.types);return p.some(e=>t.includes(e))}function eu(e){let t=O.current;if(!t)return{index:Y.length,left:0};let n=t.getBoundingClientRect(),r=Array.from(t.querySelectorAll("[data-tab-id]"));if(0===r.length)return{index:0,left:t.scrollLeft+8};for(let[a,i]of r.entries()){let r=i.getBoundingClientRect();if(e.clientX<r.left+r.width/2)return{index:a,left:r.left-n.left+t.scrollLeft}}let a=r[r.length-1].getBoundingClientRect();return{index:r.length,left:a.right-n.left+t.scrollLeft}}ew.useEffect(()=>{if(T)return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t,{once:!0}),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t)};function e(e){let t=D.current;if(!t)return;let n=e.clientX-t.startX,r=e.clientY-t.startY,a=t.dragging||Math.abs(n)>4||Math.abs(r)>4;a&&(e.preventDefault(),ec(t,e.clientX)),er({...t,currentX:e.clientX,currentY:e.clientY,dragging:a})}function t(e){let t=D.current;if(t?.dragging){e.preventDefault(),H.current=!0;let r=Y.find(e=>e.id===t.tabId),i=P.current?.getBoundingClientRect(),o=!!i&&(e.clientX<i.left||e.clientX>i.right||e.clientY<i.top||e.clientY>i.bottom);if(h&&c&&r&&o&&function(e,t){if(e.pinned)return!1;let r=Y.findIndex(t=>t.id===e.id);if(c?.(e,{tabs:Y,clientX:t.clientX,clientY:t.clientY,nativeEvent:t})===!1)return!1;let i=Y.filter(t=>t.id!==e.id);if(en(i),e.id===ee){let e=XF(i,r);void 0===n&&Q(e),e&&a?.(e)}return!0}(r,e)){A(void 0),er(void 0),ei(void 0,!1);return}let l=B.current;l&&!(l.length===Y.length&&l.every((e,t)=>e.id===Y[t]?.id))&&(en(l),s?.(l))}A(void 0),er(void 0),ei(void 0,!1)}});let ef=et&&(k?.(et)??et.content??(0,eb.jsx)("div",{className:"grid min-h-44 place-items-center bg-muted/30 p-6 text-center text-muted-foreground",children:et.title})),em=T?.dragging&&_?_:Y,eh=T?.dragging?Y.find(e=>e.id===T.tabId):void 0,ep=T?.dragging&&eh&&$?(0,ix.createPortal)((0,eb.jsxs)("div",{"data-slot":"multi-tab-drag-preview","aria-hidden":"true",className:"pointer-events-none fixed z-[100] flex h-9 min-w-0 items-center gap-1 rounded-t-lg border border-border bg-background px-2.5 text-foreground shadow-lg",style:{left:T.currentX-T.offsetX,top:T.top,width:T.width},children:[eh.icon&&(0,eb.jsx)("span",{className:"grid size-4 shrink-0 place-items-center text-muted-foreground [&_svg]:size-3.5",children:eh.icon}),(0,eb.jsx)("span",{className:"truncate ui-text-control font-medium",children:eh.title}),eh.modified&&(0,eb.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-foreground/70"})]}),document.body):null;return(0,eb.jsxs)("div",{ref:P,"data-slot":"multi-tab-system",className:(0,ez.cn)("vtl-surface-panel grid min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden rounded-[var(--surface-panel-radius)] border",S),children:[(0,eb.jsxs)("div",{className:"relative flex min-w-0 shrink-0 items-end gap-1 border-b bg-muted/35 px-1.5 pt-1.5",children:[U&&(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":b,onClick:()=>el("left"),className:"mb-1 shrink-0",children:(0,eb.jsx)(h8,{})}),(0,eb.jsxs)("div",{ref:O,role:"tablist","aria-label":w,"data-slot":"multi-tab-list",className:(0,ez.cn)("relative flex min-w-0 flex-1 items-end overflow-x-auto [scrollbar-width:none] data-[overflow=both]:[mask-image:linear-gradient(90deg,transparent,black_24px,black_calc(100%-24px),transparent)] data-[overflow=left]:[mask-image:linear-gradient(90deg,transparent,black_24px)] data-[overflow=right]:[mask-image:linear-gradient(90deg,black_calc(100%-24px),transparent)] [&::-webkit-scrollbar]:hidden",C),"data-overflow":U&&W?"both":U?"left":W?"right":void 0,onScroll:eo,onDragOver:function(e){ed(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move",X(eu(e)))},onDragLeave:function(e){if(!ed(e))return;let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||X(void 0)},onDrop:function(e){if(!ed(e))return;e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move";let t=eu(e);X(void 0),d?.({tabs:Y,insertIndex:t.index,nativeEvent:e})},children:[em.map((e,t)=>{let r=e.id===et?.id,i=em[t+1],o=T?.dragging&&z===e.id,s=!r&&!o&&void 0!==i&&i.id!==et?.id&&i.id!==z;return(0,eb.jsxs)(ew.Fragment,{children:[(0,eb.jsxs)("div",{onPointerDown:t=>(function(e,t){if(!m||e.disabled||0!==t.button)return;let n=t.currentTarget.getBoundingClientRect();A(e.id),ei(Y,!1),er({tabId:e.id,startX:t.clientX,startY:t.clientY,offsetX:t.clientX-n.left,top:n.top,width:n.width,currentX:t.clientX,currentY:t.clientY,dragging:!1})})(e,t),"data-slot":"multi-tab","data-tab-id":e.id,"data-state":r?"active":"inactive","data-dragging":z===e.id?"true":void 0,"data-modified":e.modified?"true":void 0,className:(0,ez.cn)("group/tab relative flex h-9 min-w-0 max-w-52 shrink-0 items-center gap-1 rounded-t-lg border border-b-0 px-2.5 transition-[border-color,background-color,color,box-shadow,outline-color] duration-150 ease-out",m&&!e.disabled&&"cursor-grab active:cursor-grabbing",r?"border-border bg-background text-foreground shadow-[0_-1px_0_var(--background)_inset]":"border-transparent bg-transparent text-muted-foreground hover:bg-background/70 hover:text-foreground",o&&"border-dashed border-border bg-muted/45 text-transparent shadow-none outline outline-1 outline-ring/30 [&_*]:opacity-0",e.disabled&&"pointer-events-none opacity-50"),children:[(0,eb.jsx)("button",{type:"button",role:"tab","aria-label":XB(e.title),"aria-selected":r,disabled:e.disabled,onClick:t=>{var r;let i;if(H.current){H.current=!1,t.preventDefault();return}r=e.id,(i=Y.find(e=>e.id===r))&&!i.disabled&&(void 0===n&&Q(r),a?.(r))},className:"absolute inset-0 rounded-t-lg outline-none focus-visible:ring-2 focus-visible:ring-ring/50"}),(0,eb.jsxs)("div",{"aria-hidden":"true",className:"pointer-events-none relative z-10 flex min-w-0 flex-1 items-center gap-1.5",children:[e.icon&&(0,eb.jsx)("span",{className:"grid size-4 shrink-0 place-items-center text-muted-foreground [&_svg]:size-3.5",children:e.icon}),(0,eb.jsx)("span",{className:"truncate ui-text-control font-medium",children:e.title}),e.meta&&(0,eb.jsx)("span",{className:"shrink-0 ui-text-kbd text-muted-foreground",children:e.meta}),e.modified&&(0,eb.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-foreground/70"})]}),!e.pinned&&(0,eb.jsx)("button",{type:"button",draggable:!1,onPointerDown:e=>e.stopPropagation(),"aria-label":e.closeLabel??(XB(e.title)?`${v}: ${XB(e.title)}`:v),onClick:()=>(function(e){if(e.pinned)return;let t=Y.findIndex(t=>t.id===e.id),r=Y.filter(t=>t.id!==e.id);if(en(r),l?.(e),e.id===ee){let e=XF(r,t);void 0===n&&Q(e),e&&a?.(e)}})(e),className:(0,ez.cn)("relative z-20 grid size-5 shrink-0 place-items-center rounded-md text-muted-foreground opacity-0 transition-all hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none group-hover/tab:opacity-100",r&&"opacity-100"),children:(0,eb.jsx)(fV.XIcon,{className:"size-3.5"})})]}),s&&(0,eb.jsx)("span",{"aria-hidden":"true",className:"mb-2 h-4 w-px shrink-0 bg-border/80"})]},e.id)}),G?(0,eb.jsxs)("span",{"data-slot":"multi-tab-external-insert","aria-hidden":"true",className:"pointer-events-none absolute top-2 bottom-1 z-30 flex w-0 -translate-x-1/2 items-center justify-center",style:{left:G.left},children:[(0,eb.jsx)("span",{className:"h-full w-px rounded-full bg-foreground/80"}),(0,eb.jsx)("span",{className:"absolute top-0 size-1.5 rounded-full bg-foreground"})]}):null]}),(0,eb.jsxs)("div",{className:"mb-1 flex shrink-0 items-center gap-1",children:[W&&(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":y,onClick:()=>el("right"),children:(0,eb.jsx)(h7,{})}),u.length>0?(0,eb.jsxs)(wA,{children:[(0,eb.jsx)(wR,{asChild:!0,children:(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":g,children:(0,eb.jsx)(lY,{})})}),(0,eb.jsx)(wG,{align:"end",className:"w-52",children:u.map((e,t)=>(0,eb.jsxs)(ew.Fragment,{children:[e.separatorBefore&&(0,eb.jsx)(wJ,{}),(0,eb.jsxs)(wX,{disabled:e.disabled,onSelect:e.onSelect,children:[e.icon,e.label,e.shortcut&&(0,eb.jsx)(wQ,{children:e.shortcut})]})]},t))})]}):(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":g,onClick:function(){let e=o?.();e&&(en([...Y,e]),e.disabled||(void 0===n&&Q(e.id),a?.(e.id)))},children:(0,eb.jsx)(lY,{})}),f.length>0&&(0,eb.jsxs)(wA,{children:[(0,eb.jsx)(wR,{asChild:!0,children:(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":x,children:(0,eb.jsx)(lG,{})})}),(0,eb.jsx)(wG,{align:"end",className:"w-52",children:f.map((e,t)=>(0,eb.jsxs)(ew.Fragment,{children:[e.separatorBefore&&(0,eb.jsx)(wJ,{}),(0,eb.jsxs)(wX,{disabled:e.disabled,onSelect:e.onSelect,children:[e.icon,e.label,e.shortcut&&(0,eb.jsx)(wQ,{children:e.shortcut})]})]},t))})]})]})]}),ep,N&&(0,eb.jsx)("div",{"data-slot":"multi-tab-content",className:(0,ez.cn)("min-h-0 overflow-hidden",M),children:ef??j??(0,eb.jsx)("div",{"aria-hidden":"true",className:"min-h-44 rounded-lg border border-dashed bg-muted/30"})})]})}let XU=(0,ek.default)("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),Xq=(0,ek.default)("repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);var XW="Tabs",[XK,XG]=cC(XW,[hj]),XX=hj(),[XY,XZ]=XK(XW),XJ=ew.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:l,activationMode:s="automatic",...c}=e,d=hh(l),[u,f]=cT({prop:r,onChange:a,defaultProp:i??"",caller:XW});return(0,eb.jsx)(XY,{scope:n,baseId:cz(),value:u,onValueChange:f,orientation:o,dir:d,activationMode:s,children:(0,eb.jsx)(cL.div,{dir:d,"data-orientation":o,...c,ref:t})})});XJ.displayName=XW;var XQ="TabsList",X0=ew.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...a}=e,i=XZ(XQ,n),o=XX(n);return(0,eb.jsx)(hS,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:r,children:(0,eb.jsx)(cL.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:t})})});X0.displayName=XQ;var X1="TabsTrigger",X2=ew.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:a=!1,...i}=e,o=XZ(X1,n),l=XX(n),s=X3(o.baseId,r),c=X6(o.baseId,r),d=r===o.value;return(0,eb.jsx)(hE,{asChild:!0,...l,focusable:!a,active:d,children:(0,eb.jsx)(cL.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":c,"data-state":d?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:s,...i,ref:t,onMouseDown:cE(e.onMouseDown,e=>{a||0!==e.button||!1!==e.ctrlKey?e.preventDefault():o.onValueChange(r)}),onKeyDown:cE(e.onKeyDown,e=>{[" ","Enter"].includes(e.key)&&o.onValueChange(r)}),onFocus:cE(e.onFocus,()=>{let e="manual"!==o.activationMode;d||a||!e||o.onValueChange(r)})})})});X2.displayName=X1;var X5="TabsContent",X4=ew.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:a,children:i,...o}=e,l=XZ(X5,n),s=X3(l.baseId,r),c=X6(l.baseId,r),d=r===l.value,u=ew.useRef(d);return ew.useEffect(()=>{let e=requestAnimationFrame(()=>u.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,eb.jsx)(c2,{present:a||d,children:({present:n})=>(0,eb.jsx)(cL.div,{"data-state":d?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":s,hidden:!n,id:c,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:u.current?"0s":void 0},children:n&&i})})});function X3(e,t){return`${e}-trigger-${t}`}function X6(e,t){return`${e}-content-${t}`}function X8({className:e,children:t,...n}){let r=ew.useRef(null),{thumb:a,ready:i}=function(e){let[t,n]=ew.useState(null),[r,a]=ew.useState(!1),i=ew.useCallback(()=>{let t=e.current;if(!t)return;let r=t.querySelector('[data-state="active"]');r?n({left:r.offsetLeft,top:r.offsetTop,width:r.offsetWidth,height:r.offsetHeight}):n(null)},[e]);return ew.useEffect(()=>{let t=e.current;if(!t)return;i();let n=new MutationObserver(i);n.observe(t,{attributes:!0,attributeFilter:["data-state"],subtree:!0,childList:!0});let r=null;if("u">typeof ResizeObserver)for(let e of((r=new ResizeObserver(i)).observe(t),Array.from(t.children)))r.observe(e);let o=()=>i();window.addEventListener("resize",o);let l=window.requestAnimationFrame(()=>a(!0));return()=>{n.disconnect(),r?.disconnect(),window.removeEventListener("resize",o),window.cancelAnimationFrame(l)}},[i,e]),{thumb:t,ready:r}}(r);return(0,eb.jsxs)(X0,{ref:r,"data-slot":"tabs-list",className:(0,ez.cn)("relative inline-flex h-8 items-center justify-center gap-0.5 rounded-lg bg-muted p-1 text-muted-foreground",e),...n,children:[a?(0,eb.jsx)("span",{"aria-hidden":!0,"data-slot":"tabs-thumb",className:(0,ez.cn)("pointer-events-none absolute top-0 left-0 z-0 rounded-md bg-background shadow-xs",i&&"transition-[transform,width,height] duration-200 ease-out"),style:{transform:`translate(${a.left}px, ${a.top}px)`,width:a.width,height:a.height}}):null,t]})}function X7({className:e,...t}){return(0,eb.jsx)(X2,{"data-slot":"tabs-trigger",className:(0,ez.cn)("relative z-10 inline-flex h-6 shrink-0 items-center justify-center gap-1.5 rounded-md px-2.5 text-sm font-medium whitespace-nowrap transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:text-foreground [&_svg]:pointer-events-none [&_svg]:size-3.5 [&_svg]:shrink-0",e),...t})}function X9({className:e,...t}){return(0,eb.jsx)(X4,{"data-slot":"tabs-content",className:(0,ez.cn)("mt-3 outline-none focus-visible:ring-2 focus-visible:ring-ring/50 animate-in fade-in-0 duration-150",e),...t})}function Ye(e){let{models:t,loading:n}=e,[r,a]=ew.useState(""),i=ew.useMemo(()=>"multi"===e.mode?e.value:e.value?[e.value]:[],[e]),o=ew.useMemo(()=>new Set(i),[i]),l="multi"===e.mode?e.primaryModelId:void 0,s=null===l?void 0:l&&o.has(l)?l:void 0===l?i[0]:void 0,c=ew.useMemo(()=>t.filter(e=>!1!==e.available),[t]),d=ew.useMemo(()=>{let e=new Map;for(let t of c){let n=t.providerName?.trim()||"其他",r=e.get(n);r?r.push(t):e.set(n,[t])}return Array.from(e.entries()).map(([e,t])=>({provider:e,models:t}))},[c]),u=ew.useMemo(()=>{let e=r.trim().toLowerCase();return e?d.map(t=>({provider:t.provider,models:t.models.filter(n=>n.label.toLowerCase().includes(e)||t.provider.toLowerCase().includes(e))})).filter(e=>e.models.length>0):d},[d,r]),f=ew.useMemo(()=>new Set(c.map(e=>e.value)),[c]),m=ew.useMemo(()=>new Map(t.map(e=>[e.value,e])),[t]),h=ew.useMemo(()=>"multi"!==e.mode?[]:i.filter(e=>!f.has(e)).map(e=>{let t=m.get(e);return{id:e,label:t?.label??e,provider:t?.providerName?.trim()||""}}),[e.mode,i,f,m]),p=ew.useMemo(()=>{let e=r.trim().toLowerCase();return e?h.filter(t=>t.id.toLowerCase().includes(e)||t.label.toLowerCase().includes(e)||t.provider.toLowerCase().includes(e)):h},[h,r]),g=ew.useCallback(t=>{"single"===e.mode?e.onChange(e.value===t?"":t):e.onChange(o.has(t)?e.value.filter(e=>e!==t):[...e.value,t])},[e,o]),x=ew.useCallback(t=>{if("multi"!==e.mode)return;let n=t.map(e=>e.value);if(n.every(e=>o.has(e))){let t=new Set(n);e.onChange(e.value.filter(e=>!t.has(e)))}else{let t=n.filter(e=>!o.has(e));e.onChange([...e.value,...t])}},[e,o]),v="single"===e.mode?e.clearLabel??"无 / 默认":"";return(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsxs)("div",{className:"relative",children:[(0,eb.jsx)(vu,{className:"pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),(0,eb.jsx)(eA,{value:r,onChange:e=>a(e.target.value),placeholder:"搜索模型或渠道...",className:"h-8 pl-8"})]}),(0,eb.jsxs)("div",{className:"grid max-h-[min(22rem,50svh)] gap-3 overflow-auto rounded-lg border bg-card/40 p-2",children:["single"===e.mode?(0,eb.jsxs)("div",{role:"button",tabIndex:0,"aria-pressed":""===e.value,onClick:()=>e.onChange(""),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),e.onChange(""))},className:(0,ez.cn)("flex cursor-pointer items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-sm outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring/50",""===e.value?"bg-primary/10 text-foreground":"hover:bg-muted"),children:[(0,eb.jsx)(vM,{checked:""===e.value,tabIndex:-1,className:"pointer-events-none"}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:v})]}):null,n&&0===t.length?(0,eb.jsx)("p",{className:"px-2 py-6 text-center text-xs text-muted-foreground",children:"读取模型中…"}):0===u.length&&0===p.length?(0,eb.jsx)("p",{className:"px-2 py-6 text-center text-xs text-muted-foreground",children:0===t.length?e.emptyHint??"没有可用模型":"没有匹配的模型"}):(0,eb.jsxs)(eb.Fragment,{children:[u.map(t=>{let n=t.models.map(e=>e.value),r=n.filter(e=>o.has(e)).length,a=r===n.length;return(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2 px-1",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,eb.jsx)("span",{className:"truncate text-xs font-semibold text-foreground",children:t.provider}),(0,eb.jsxs)("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:[r,"/",n.length]})]}),"multi"===e.mode?(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"sm",className:"h-6 shrink-0 px-2 text-xs",onClick:()=>x(t.models),children:a?"取消全选":"全选"}):null]}),(0,eb.jsx)("div",{className:"grid gap-0.5",children:t.models.map(t=>{let n=o.has(t.value),r="multi"===e.mode&&t.value===s;return(0,eb.jsxs)("div",{role:"button",tabIndex:0,"aria-pressed":n,onClick:()=>g(t.value),onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),g(t.value))},className:(0,ez.cn)("flex cursor-pointer items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-sm outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring/50",n?"bg-primary/10 text-foreground":"hover:bg-muted"),children:[(0,eb.jsx)(vM,{checked:n,tabIndex:-1,className:"pointer-events-none"}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t.label}),r?(0,eb.jsx)("span",{className:"shrink-0 rounded bg-primary/15 px-1.5 py-0.5 text-[10px] font-medium text-primary",children:"主"}):null]},t.value)})})]},t.provider)}),p.length>0?(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 px-1",children:[(0,eb.jsx)("span",{className:"truncate text-xs font-semibold text-muted-foreground",children:"已禁用 / 不可用"}),(0,eb.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:p.length})]}),(0,eb.jsx)("div",{className:"grid gap-0.5",children:p.map(e=>(0,eb.jsxs)("div",{role:"button",tabIndex:0,"aria-pressed":!0,title:"该模型所属渠道已禁用或不可用,点击可移除",onClick:()=>g(e.id),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),g(e.id))},className:(0,ez.cn)("flex cursor-pointer items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-sm opacity-60 outline-none transition-colors hover:bg-muted hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/50"),children:[(0,eb.jsx)(vM,{checked:!0,tabIndex:-1,className:"pointer-events-none"}),(0,eb.jsxs)("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:[e.label,e.provider?(0,eb.jsxs)("span",{className:"ml-1.5 text-[11px] text-muted-foreground/70",children:["· ",e.provider]}):null]}),(0,eb.jsx)("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:"不可用"})]},e.id))})]}):null]})]})]})}function Yt({status:e}){return"done"===e?(0,eb.jsx)(h6,{className:"size-3.5 shrink-0 text-emerald-500"}):"in_progress"===e?(0,eb.jsx)(HE,{className:"size-3.5 shrink-0 text-amber-500"}):"blocked"===e||"skipped"===e?(0,eb.jsx)(XU,{className:"size-3.5 shrink-0 text-rose-500"}):(0,eb.jsx)(wk,{className:"size-3.5 shrink-0 text-muted-foreground/50"})}function Yn({done:e,total:t}){let n=t>0?Math.round(e/t*100):0;return(0,eb.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,eb.jsx)("div",{className:"h-1.5 w-16 overflow-hidden rounded-full bg-muted",children:(0,eb.jsx)("div",{className:"h-full rounded-full bg-foreground transition-all",style:{width:`${n}%`}})}),(0,eb.jsxs)("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground",children:[e,"/",t]})]})}X4.displayName=X5;let Yr={main:"主",subagent:"子"};function Ya({node:e,onSet:t}){let{models:n,loading:r}=vH(),[a,i]=ew.useState(!1),o=e.orchestration?.modelRef??"",l=o&&n.length>0?n.find(e=>e.value===o)?.label??o:"";return(0,eb.jsxs)(bC,{open:a,onOpenChange:i,children:[(0,eb.jsx)(bP,{asChild:!0,children:(0,eb.jsx)("button",{type:"button",className:(0,ez.cn)("shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium transition-colors",o?"bg-sky-teal/15 text-sky-teal hover:bg-sky-teal/25":"bg-muted text-muted-foreground hover:bg-muted/70"),title:o?`已指定模型:${l}`:"为该子代理节点指定模型",onClick:e=>e.stopPropagation(),children:o?`模型\xb7${l}`:"模型"})}),(0,eb.jsx)(bH,{align:"end",className:"w-72 p-2",onClick:e=>e.stopPropagation(),children:(0,eb.jsx)(Ye,{mode:"single",models:n,loading:r,value:o,onChange:n=>{t(e.id,n),i(!1)},clearLabel:"默认(由 agent 自行指定)"})})]})}function Yi({node:e,depth:t,activeId:n,onSetNodeModel:r}){let a=function e(t){if(!t.children||0===t.children.length)return"task"!==t.kind&&"subplan"!==t.kind?{done:0,total:0}:{done:+("done"===t.status),total:1};let n=0,r=0;for(let a of t.children){let t=e(a);n+=t.done,r+=t.total}return{done:n,total:r}}(e),i="phase"===e.kind,o=e.orchestration,l=void 0!==n&&e.id===n,s=o?.executor==="subagent";return(0,eb.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,eb.jsxs)("div",{className:(0,ez.cn)("flex items-center gap-2 rounded-md px-1.5 py-1",l&&"bg-sky-teal/10 ring-1 ring-sky-teal/30"),style:{marginLeft:12*t},children:[(0,eb.jsx)(Yt,{status:e.status}),(0,eb.jsx)("span",{className:(0,ez.cn)("min-w-0 flex-1 truncate text-[13px]","done"===e.status&&"text-muted-foreground line-through",l&&"font-medium text-foreground"),title:e.detail||e.title,children:e.title}),i&&o?(0,eb.jsxs)("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:[Yr[o.executor]??o.executor,o.subagentType?`:${o.subagentType}`:""]}):null,s&&r?(0,eb.jsx)(Ya,{node:e,onSet:r}):null,i&&a.total>0?(0,eb.jsx)(Yn,{done:a.done,total:a.total}):null]}),e.children?.map(e=>(0,eb.jsx)(Yi,{node:e,depth:t+1,activeId:n,onSetNodeModel:r},e.id))]})}function Yo({conversationId:e,ownerMachineId:t}){let[n,r]=ew.useState(null),[a,i]=ew.useState(""),[o,l]=ew.useState(!1),[s,c]=ew.useState(!1),[d,u]=ew.useState(!1),[f,m]=ew.useState(!1),h=ew.useRef(void 0);ew.useEffect(()=>()=>{h.current&&window.clearTimeout(h.current)},[]);let p=ew.useCallback(async()=>{if(a.trim())try{await navigator.clipboard.writeText(a),m(!0),h.current&&window.clearTimeout(h.current),h.current=window.setTimeout(()=>m(!1),1600)}catch{}},[a]),g=ew.useCallback((n,a)=>{e&&(r(e=>{if(!e?.tree)return e;let t=e=>e.id===n&&e.orchestration?{...e,orchestration:{...e.orchestration,modelRef:a}}:e.children?{...e,children:e.children.map(t)}:e;return{...e,tree:t(e.tree)}}),cf(e,{nodeId:n,modelRef:a},t))},[e,t]);ew.useEffect(()=>{if(l(!1),!e)return;let n=!0;return(async()=>{try{let r=await sD(e,t);n&&l(r.conversation.loopMode??!1)}catch{}})(),()=>{n=!1}},[e,t]);let x=ew.useCallback(async n=>{if(e){c(!0),l(n);try{let r=await cs(e,n,t);l(r.conversation.loopMode??n)}catch{l(!n)}finally{c(!1)}}},[e,t]),v=ew.useCallback(()=>{o?x(!1):u(!0)},[o,x]);ew.useEffect(()=>{if(r(null),i(""),!e)return;let n=!0,a=0,o=async()=>{let o=a+=1,l=await sF(e,t);n&&o===a&&(r(l.planState),void 0!==l.planDoc&&i(l.planDoc))};o();let l=window.setInterval(o,1200);return()=>{n=!1,window.clearInterval(l)}},[e,t]);let b=n?.activePath?.length?n.activePath[n.activePath.length-1]:void 0;return(0,eb.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col rounded-[inherit] bg-background",children:[(0,eb.jsxs)(XJ,{defaultValue:"doc",className:"flex min-h-0 flex-1 flex-col gap-0",children:[(0,eb.jsxs)("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b px-2 py-1.5",children:[(0,eb.jsxs)(X8,{children:[(0,eb.jsx)(X7,{value:"doc",children:"计划文档"}),(0,eb.jsx)(X7,{value:"tree",children:"执行树"})]}),(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",variant:o?"default":"outline",disabled:!e||s,onClick:v,className:"h-7 shrink-0 gap-1.5 px-2 text-xs",title:o?"循环模式开启中:会话每轮结束后会自动续跑,直到执行树没有剩余可完成的任务。点击关闭。":"开启循环模式:会话每轮结束后自动续跑,持续完成执行树中的剩余任务",children:[(0,eb.jsx)(Xq,{className:"size-3.5"}),"循环模式",o?"·开":""]})]}),(0,eb.jsxs)(X9,{value:"doc",className:"relative min-h-0 min-w-0 flex-1",children:[a.trim()?(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",variant:"outline",onClick:()=>void p(),className:"absolute right-3 top-2 z-10 h-7 gap-1.5 px-2 text-xs",title:"复制计划文档原文",children:[f?(0,eb.jsx)(h6,{className:"size-3.5 text-emerald-500"}):(0,eb.jsx)(lV,{className:"size-3.5"}),f?"已复制":"复制"]}):null,(0,eb.jsx)(jP,{className:"h-full w-full min-w-0",viewportClassName:"vtl-doc-viewport",children:(0,eb.jsx)("div",{className:"min-w-0 px-4 py-3 text-sm break-words [overflow-wrap:anywhere] select-text",children:a.trim()?(0,eb.jsx)(H1,{content:a}):(0,eb.jsx)("p",{className:"text-muted-foreground/70",children:"尚无可读计划文档。"})})})]}),(0,eb.jsx)(X9,{value:"tree",className:"min-h-0 min-w-0 flex-1",children:(0,eb.jsx)(jP,{className:"h-full w-full min-w-0",children:(0,eb.jsx)("div",{className:"min-w-0 px-2 py-2",children:n?.tree?(0,eb.jsx)(Yi,{node:n.tree,depth:0,activeId:b,onSetNodeModel:g}):(0,eb.jsx)("p",{className:"px-2 py-1 text-sm text-muted-foreground/70",children:"计划尚未编译成执行树。"})})})})]}),(0,eb.jsx)(ux,{open:d,onOpenChange:u,children:(0,eb.jsxs)(uR,{children:[(0,eb.jsxs)(uD,{children:[(0,eb.jsx)(uL,{children:"开启循环模式?"}),(0,eb.jsx)(u$,{asChild:!0,children:(0,eb.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,eb.jsx)("p",{children:"开启后,每当 agent 完成一轮工作(运行自然结束)时,系统会自动注入「继续」消息, 让它继续完成执行树中剩余未完成的任务——这一切在后端进行,即使你关闭页面也会持续。"}),(0,eb.jsx)("p",{children:"循环只有在以下情况才会停止:执行树中没有剩余的「待完成(待办/进行中)」任务、 你关闭循环模式、达到安全上限(最多自动续跑 25 次)、存在等待外部事件的 hook, 或本轮运行出错/被你中止。无法完成的任务请让 agent 标记为「阻塞」。"})]})})]}),(0,eb.jsxs)(u_,{children:[(0,eb.jsx)(uB,{children:"取消"}),(0,eb.jsx)(uF,{onClick:()=>void x(!0),children:"开启"})]})]})})]})}function Yl({conversationId:e,ownerMachineId:t,initialPath:n}){let[r,a]=ew.useState([]),[i,o]=ew.useState(n),[l,s]=ew.useState("");return ew.useEffect(()=>{if(!e)return;let n=!0,r=async()=>{let r=await sV(e,t);if(!n)return;let i=r.filter(e=>e.startsWith("plan/specs/"));a(i),o(e=>e??i[0])};r();let i=window.setInterval(r,1200);return()=>{n=!1,window.clearInterval(i)}},[e,t]),ew.useEffect(()=>{if(!e||!i)return void s("");let n=!0,r=async()=>{try{let r=await sB(e,i,t);n&&s(r.content)}catch{n&&s("")}};r();let a=window.setInterval(r,1200);return()=>{n=!1,window.clearInterval(a)}},[e,t,i]),(0,eb.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col rounded-[inherit] bg-background",children:[(0,eb.jsx)("div",{className:"flex shrink-0 flex-wrap gap-1 border-b px-2 py-1.5",children:0===r.length?(0,eb.jsx)("span",{className:"px-1 py-1 text-xs text-muted-foreground/70",children:"尚无规范文档"}):r.map(e=>(0,eb.jsxs)("button",{type:"button",className:(0,ez.cn)("flex items-center gap-1.5 rounded-md px-2 py-1 text-xs transition-colors",e===i?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted/60"),onClick:()=>o(e),children:[(0,eb.jsx)(uX,{className:"size-3.5"}),e.split("/").pop()??e]},e))}),(0,eb.jsx)(jP,{className:"min-h-0 w-full min-w-0 flex-1",viewportClassName:"vtl-doc-viewport",children:(0,eb.jsx)("div",{className:"min-w-0 px-4 py-3 text-sm break-words [overflow-wrap:anywhere]",children:l.trim()?(0,eb.jsx)(H1,{content:l}):(0,eb.jsx)("p",{className:"text-muted-foreground/70",children:i?"(空文档)":"选择左上方的规范文档查看。"})})})]})}var Ys=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let n=(0,lQ.createSlot)(`Primitive.${t}`),r=ew.forwardRef((e,r)=>{let{asChild:a,...i}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,eb.jsx)(a?n:t,{...i,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),Yc=ew.forwardRef((e,t)=>(0,eb.jsx)(Ys.label,{...e,ref:t,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));function Yd({className:e,...t}){return(0,eb.jsx)(Yc,{"data-slot":"label",className:(0,ez.cn)("flex w-fit items-center gap-2 text-sm font-medium leading-snug peer-disabled:cursor-not-allowed peer-disabled:opacity-50 group-data-[disabled=true]/field:opacity-50",e),...t})}function Yu({url:e}){let[t,n]=ew.useState(!1),r=ew.useCallback(async()=>{try{await navigator.clipboard.writeText(e),n(!0),window.setTimeout(()=>n(!1),1500)}catch{}},[e]);return(0,eb.jsxs)("button",{type:"button",onClick:r,title:e,className:"flex min-w-0 items-center gap-1 rounded border bg-muted/40 px-1.5 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[t?(0,eb.jsx)(h6,{className:"size-3 shrink-0 text-emerald-500"}):(0,eb.jsx)(lV,{className:"size-3 shrink-0"}),(0,eb.jsx)("span",{className:"truncate font-mono",children:e})]})}function Yf({conversationId:e,ownerMachineId:t}){let[n,r]=ew.useState(void 0),[a,i]=ew.useState(void 0),[o,l]=ew.useState(!1),s=ew.useCallback(async()=>{if(!e)return;let n=await s1(e,t);return r(n),n},[e,t]);ew.useEffect(()=>{if(!e)return void r(void 0);let n=!0,a=async()=>{let a=await s1(e,t);n&&r(a)};a();let i=window.setInterval(a,2e3);return()=>{n=!1,window.clearInterval(i)}},[e,t]);let c=ew.useCallback(async n=>{if(e){i(n);try{let a=await s4(e,n,t);r(e=>(e??[]).map(e=>e.id===n?a:e))}catch{await s()}finally{i(void 0)}}},[e,t,s]),d=ew.useCallback(async n=>{if(e){i(n);try{await s5(e,n,t),r(e=>(e??[]).filter(e=>e.id!==n))}catch{await s()}finally{i(void 0)}}},[e,t,s]),u=ew.useCallback(async n=>{if(!e)return;let a=await s2(e,n,t);r(e=>[...e??[],a])},[e,t]),f=n??[],m=f.filter(e=>e.enabled&&!e.disabled).length;return(0,eb.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col rounded-[inherit] bg-background",children:[(0,eb.jsxs)("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b px-3 py-2",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,eb.jsx)("span",{className:"text-[13px] font-medium text-foreground",children:"Hook"}),(0,eb.jsxs)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[m,"/",f.length," 启用"]})]}),e?(0,eb.jsx)("div",{className:"flex shrink-0 items-center gap-1",children:(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",variant:"outline",className:"h-9 px-2 text-xs md:h-7",onClick:()=>l(!0),children:[(0,eb.jsx)(lY,{className:"size-3.5"}),"新建"]})}):null]}),(0,eb.jsx)(jP,{className:"min-h-0 flex-1",children:(0,eb.jsx)("div",{className:"px-2 py-2",children:0===f.length?(0,eb.jsx)("p",{className:"px-2 py-1 text-sm text-muted-foreground/70",children:"暂无 hook"}):(0,eb.jsx)("ul",{className:"flex flex-col gap-1.5",children:f.map(e=>{let t=e.enabled&&!e.disabled,n="webhook"===e.trigger.source?e.fireUrl:void 0;return(0,eb.jsxs)("li",{className:(0,ez.cn)("flex flex-col gap-1 rounded-md border px-2.5 py-2",!t&&"opacity-60"),children:[(0,eb.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,eb.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eb.jsx)("span",{className:"block truncate text-[13px] font-medium leading-5 text-foreground",title:e.name||e.id,children:e.name||e.id}),(0,eb.jsx)("span",{className:"block truncate text-[11px] text-muted-foreground/70",children:e.id})]}),(0,eb.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[(0,eb.jsx)(bG,{checked:t,disabled:a===e.id,onCheckedChange:()=>void c(e.id),"aria-label":"启用/停用 hook"}),(0,eb.jsx)("button",{type:"button",disabled:a===e.id,onClick:()=>void d(e.id),"aria-label":"删除 hook",title:"删除 hook",className:"grid size-6 place-items-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-destructive disabled:opacity-50 [&_svg]:size-3.5",children:(0,eb.jsx)(yn,{})})]})]}),(0,eb.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[12px] leading-5",children:[(0,eb.jsx)("span",{className:"text-foreground",children:function(e){switch(e.source){case"timer":if(e.cron)return`⏱ cron: ${e.cron}`;if(e.intervalSec&&e.intervalSec>0)return`⏱ 每 ${e.intervalSec}s`;if(e.delaySec&&e.delaySec>0)return`⏱ ${e.delaySec}s 后`;return"⏱ 定时";case"process_exit":{let t=e.terminalSessionId||e.backgroundCmdId?`: ${e.terminalSessionId||e.backgroundCmdId}`:"";return`⛔ 进程退出${t}`}case"webhook":return"🔌 webhook";case"file":return`📁 文件变化${e.path?`: ${e.path}`:""}`;case"shell_poll":return`🐚 shell${e.command?`: ${e.command}`:""}`;case"lifecycle":return`🔁 生命周期${e.event?`: ${e.event}`:""}`;default:return e.source}}(e.trigger)}),(0,eb.jsx)("span",{className:"text-muted-foreground/50",children:"→"}),(0,eb.jsx)("span",{className:"text-muted-foreground",children:function(e){switch(e.type){case"resume_conversation":return"唤醒本会话";case"run_command":return`运行命令${e.command?`: ${e.command}`:""}`;case"start_conversation":return"新建会话";default:return e.type}}(e.action)})]}),(0,eb.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 text-[11px] text-muted-foreground",children:[(0,eb.jsxs)("span",{className:"tabular-nums",children:["已触发 ",e.fireCount," 次"]}),(0,eb.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,eb.jsx)("span",{children:function(e){if(!e)return"从未触发";let t=Date.parse(e);if(!Number.isFinite(t))return e;let n=Math.max(0,Math.floor((Date.now()-t)/1e3));return n<60?"刚刚触发":n<3600?`${Math.floor(n/60)} 分钟前触发`:n<86400?`${Math.floor(n/3600)} 小时前触发`:new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(t)}(e.lastFiredAt)}),e.once?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,eb.jsx)("span",{children:"仅一次"})]}):e.maxFires&&e.maxFires>0?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,eb.jsxs)("span",{children:["上限 ",e.maxFires]})]}):null]}),n?(0,eb.jsx)("div",{className:"mt-0.5",children:(0,eb.jsx)(Yu,{url:n})}):null]},e.id)})})})}),e?(0,eb.jsx)(Yp,{open:o,onOpenChange:l,onCreate:u}):null]})}Yc.displayName="Label";let Ym=[{value:"timer",label:"定时(timer)"},{value:"webhook",label:"Webhook"},{value:"process_exit",label:"进程退出"},{value:"file",label:"文件变化"},{value:"shell_poll",label:"Shell 轮询"},{value:"lifecycle",label:"生命周期"}],Yh=[{value:"resume_conversation",label:"唤醒本会话"},{value:"run_command",label:"运行命令"},{value:"start_conversation",label:"新建会话"}];function Yp({open:e,onOpenChange:t,onCreate:n}){let[r,a]=ew.useState(""),[i,o]=ew.useState("timer"),[l,s]=ew.useState("60"),[c,d]=ew.useState(""),[u,f]=ew.useState(""),[m,h]=ew.useState(""),[p,g]=ew.useState("resume_conversation"),[x,v]=ew.useState(""),[b,y]=ew.useState(""),[w,j]=ew.useState(!1),[k,N]=ew.useState(!1),[S,C]=ew.useState(""),M=sv();async function E(){N(!0),C("");try{let e={source:i};"timer"===i?c.trim()?e.cron=c.trim():e.delaySec=Math.max(0,Number(l)||0):"file"===i?e.path=u.trim():"shell_poll"===i&&(e.command=m.trim());let a={type:p};"run_command"===p?a.command=b.trim():("resume_conversation"===p||"start_conversation"===p)&&x.trim()&&(a.prompt=x.trim()),await n({name:r.trim()||void 0,trigger:e,action:a,once:w}),t(!1)}catch(e){C(e instanceof Error?e.message:"创建 hook 失败")}finally{N(!1)}}return ew.useEffect(()=>{e&&(a(""),o("timer"),s("60"),d(""),f(""),h(""),g("resume_conversation"),v(""),y(""),j(!1),C(""))},[e]),(0,eb.jsx)(dX,{open:e,onOpenChange:t,children:(0,eb.jsxs)(fU,{className:(0,ez.cn)(M?"inset-0 flex h-svh w-full max-w-none translate-x-0 translate-y-0 flex-col rounded-none border-0":"max-w-md"),children:[(0,eb.jsx)(fq,{children:(0,eb.jsx)(fK,{children:"新建 Hook"})}),(0,eb.jsxs)("div",{className:(0,ez.cn)("grid gap-3",M&&"min-h-0 flex-1 overflow-y-auto"),children:[(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"名称(可选)"}),(0,eb.jsx)(eA,{value:r,onChange:e=>a(e.currentTarget.value),placeholder:"例如 编译完成后继续"})]}),(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"触发源"}),(0,eb.jsxs)(gU,{value:i,onValueChange:e=>o(e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:Ym.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})]}),"timer"===i?(0,eb.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"延迟(秒)"}),(0,eb.jsx)(eA,{type:"number",min:0,value:l,onChange:e=>s(e.currentTarget.value),disabled:!!c.trim()})]}),(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"或 cron"}),(0,eb.jsx)(eA,{value:c,onChange:e=>d(e.currentTarget.value),placeholder:"*/5 * * * *"})]})]}):null,"file"===i?(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"监视路径"}),(0,eb.jsx)(eA,{value:u,onChange:e=>f(e.currentTarget.value),placeholder:"例如 ./dist"})]}):null,"shell_poll"===i?(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"轮询命令"}),(0,eb.jsx)(eA,{value:m,onChange:e=>h(e.currentTarget.value),placeholder:"例如 test -f /tmp/done"})]}):null,(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"动作"}),(0,eb.jsxs)(gU,{value:p,onValueChange:e=>g(e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:Yh.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})]}),"run_command"===p?(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"命令"}),(0,eb.jsx)(eA,{value:b,onChange:e=>y(e.currentTarget.value),placeholder:"例如 npm run build"})]}):(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"提示词(可选)"}),(0,eb.jsx)(eA,{value:x,onChange:e=>v(e.currentTarget.value),placeholder:"触发时注入的提示词"})]}),(0,eb.jsxs)("label",{className:"flex items-center justify-between gap-2 text-sm",children:[(0,eb.jsx)("span",{children:"仅触发一次"}),(0,eb.jsx)(bG,{checked:w,onCheckedChange:j})]}),S?(0,eb.jsx)("p",{className:"text-xs text-destructive",children:S}):null]}),(0,eb.jsxs)(fW,{children:[(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:k,children:"取消"}),(0,eb.jsx)(eO.Button,{type:"button",onClick:()=>void E(),disabled:k,children:k?"创建中":"创建"})]})]})})}let Yg=(0,ek.default)("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);function Yx({conversationId:e,ownerMachineId:t,nodeId:n,binding:r,onBind:a}){let i=r?.childId,o=r?.role??"main",[l,s]=ew.useState(void 0),[c,d]=ew.useState([]),[u,f]=ew.useState(!1),[m,h]=ew.useState(!1),[p,g]=ew.useState([]),[x,v]=ew.useState(""),{models:b}=vH(),y=x||b[0]?.value||"",w=!!(i&&i===l),j=ew.useRef({isTemp:!1});ew.useEffect(()=>{j.current={mainId:e,machineId:t,childId:i,isTemp:"temp"===o&&!!i&&i!==l}},[e,t,i,o,l]),ew.useEffect(()=>{if(!e){s(void 0),d([]),f(!1);return}let n=!0;return(async()=>{try{let r=await sD(e,t);if(!n)return;v(r.conversation.settings?.mainModels?.[0]??""),s(r.conversation.sideQueryConvId||void 0)}catch{}})(),()=>{n=!1}},[e,t]),ew.useEffect(()=>{"main"===o&&!i&&l&&e&&a?.({childId:l,role:"main"})},[o,i,l,e,a]),ew.useEffect(()=>{let e;if(!i){d([]),f(!1);return}let n=!0,r=async()=>{if(n)try{let a=await sD(i,t);if(!n)return;let o=a.conversation.running??!1;d(a.events),f(o),e=window.setTimeout(r,o?1200:5e3)}catch{if(!n)return;try{let e=await s_(i,{limit:400},t);n&&e.events.length&&d(e.events)}catch{}n&&(e=window.setTimeout(r,5e3))}};return r(),()=>{n=!1,void 0!==e&&window.clearTimeout(e)}},[i,t]),ew.useEffect(()=>()=>{let{mainId:e,machineId:t,childId:n,isTemp:r}=j.current;r&&e&&n&&cp(e,n,t).catch(()=>{})},[]);let k=ew.useCallback((n,r=[])=>{let l=n.trim();if(!e||!l&&0===r.length||m)return;h(!0),f(!0);let c=r.map(e=>"image"===e.kind?{kind:"image",name:e.name,mimeType:e.mimeType,data:e.dataUrl?.split(",")[1]??""}:{kind:"card"===e.kind?"card":"file",name:e.name,mimeType:e.mimeType,text:e.text??"",..."card"===e.kind?{cardKind:e.cardKind}:{}}).filter(e=>"image"===e.kind?""!==e.data:(e.text??"")!==""),d="temp"===o&&!i;(async()=>{try{let{sideQueryConvId:n}=await cm(e,l,t,y||void 0,{...i?{childId:i}:d?{kind:"temp"}:{kind:"main"},...c.length>0?{attachments:c}:{}});g([]),n&&(d||i||s(e=>e??n),a?.({childId:n,role:d?"temp":o}))}catch{f(!1)}finally{h(!1)}})()},[e,t,y,m,o,i,a]),N=ew.useCallback(()=>{e&&i&&!w&&(async()=>{try{let{sideQueryConvId:n}=await ch(e,i,t);s(n||i),a?.({childId:i,role:"main"})}catch{}})()},[e,i,w,t,a]),S=ew.useCallback(()=>{"temp"===o&&i&&i!==l&&e&&i&&cp(e,i,t).catch(()=>{}),d([]),f(!1),a?.({role:"temp"})},[o,i,l,e,t,a]),C=ew.useCallback(()=>{a?.({childId:l,role:"main"})},[l,a]),M=!!e,E=!!l,I=!i&&0===c.length;return(0,eb.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col rounded-[inherit] bg-background",children:[(0,eb.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5 border-b px-3 py-2",children:[(0,eb.jsx)(uJ,{className:"size-3.5 text-muted-foreground"}),(0,eb.jsx)("span",{className:"text-[13px] font-medium text-foreground",children:w?"主旁问":"temp"===o?"临时旁问":"旁问"}),M&&i?(0,eb.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[w?(0,eb.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground",children:[(0,eb.jsx)(Yg,{className:"size-3 fill-current"}),"主旁问"]}):(0,eb.jsxs)(eO.Button,{type:"button",variant:"ghost",size:"sm",className:"h-6 gap-1 px-2 text-[11px]",onClick:N,title:"固定为主旁问",children:[(0,eb.jsx)(Yg,{className:"size-3"}),"固定为主旁问"]}),(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon",className:"size-6",onClick:S,title:"新建临时旁问",children:(0,eb.jsx)(lY,{className:"size-3.5"})})]}):(0,eb.jsx)("span",{className:"ml-auto text-[11px] text-muted-foreground",children:"只读 · 不影响主对话"})]}),(0,eb.jsxs)("div",{className:"relative min-h-0 flex-1",children:[(0,eb.jsx)(UL,{className:"size-full min-h-0",composerClassName:"max-w-[42rem]",events:c,running:u||m,disabled:!M,hideComposerOptions:!0,attachments:p,onAttachmentsChange:g,onCardDrop:qg,onSubmit:e=>k(e.value,e.attachments??[])}),I?(0,eb.jsx)("div",{className:"absolute inset-x-0 top-0 bottom-28 grid place-items-center px-6",children:(0,eb.jsxs)("div",{className:"max-w-xs text-center",children:[(0,eb.jsx)(uJ,{className:"mx-auto mb-2 size-7 text-muted-foreground/50"}),M?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:"问点什么?旁问不会影响主对话。"}),(0,eb.jsxs)("div",{className:"flex flex-col items-stretch gap-2",children:[(0,eb.jsxs)(eO.Button,{type:"button",variant:E?"outline":"default",size:"sm",className:(0,ez.cn)("gap-1.5","main"===o&&"ring-1 ring-ring"),onClick:C,children:[(0,eb.jsx)(Yg,{className:"size-3.5"}),E?"继续主旁问":"开始旁问"]}),(0,eb.jsxs)(eO.Button,{type:"button",variant:"outline",size:"sm",className:(0,ez.cn)("gap-1.5","temp"===o&&"ring-1 ring-ring"),onClick:S,children:[(0,eb.jsx)(lY,{className:"size-3.5"}),"新建临时旁问"]})]})]}):(0,eb.jsx)("p",{className:"text-sm text-muted-foreground",children:"选择一个对话后即可在此发起旁问。"})]})}):null]})]})}let Yv=(0,ek.default)("coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]),Yb=(0,ek.default)("file-pen-line",[["path",{d:"m18.226 5.226-2.52-2.52A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-.351",key:"1k2beg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]),Yy=(0,ek.default)("loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]),Yw=(0,ek.default)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function Yj(e,t){return e?(0,eT.localAPIURL)(`/v1/remote/${e}${t}`):(0,eT.localAPIURL)(t)}async function Yk(e,t){let{signal:n,timeoutMs:r=8e3}=t??{},a=new AbortController,i=r>0?setTimeout(()=>a.abort(),r):void 0;n&&n.addEventListener("abort",()=>a.abort(),{once:!0});try{let t=await fetch(Yj(e,"/v1/extensions"),{cache:"no-store",signal:a.signal});if(!t.ok)throw Error(`Extensions API error: ${t.status}`);return await t.json()}finally{i&&clearTimeout(i)}}async function YN(e,t,n){let r=await fetch(Yj(e,t),{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json"},body:void 0===n?void 0:JSON.stringify(n)});if(!r.ok)throw Error(`Extensions API error: ${r.status}`);let a=await r.text();return a?JSON.parse(a):{}}async function YS(e,t){return YN(e,"/v1/extensions/browser/install",{variant:t})}async function YC(e,t){return YN(e,"/v1/extensions/browser/update",t?{variant:t}:{})}async function YM(e){return YN(e,"/v1/extensions/browser/uninstall")}async function YE(e,t){return YN(e,"/v1/extensions/browser/enable",{enabled:t})}async function YI(e,t){let{timeoutMs:n=6e3}=t??{},r=new AbortController,a=n>0?setTimeout(()=>r.abort(),n):void 0;try{let t=await fetch(Yj(e,"/v1/browser/info"),{cache:"no-store",signal:r.signal});if(!t.ok)return null;let n=await t.text(),a=n?JSON.parse(n):{};return{running:!!a.running,monitoring:!!a.monitoring}}catch{return null}finally{a&&clearTimeout(a)}}async function YP(e,t){return{monitoring:!!(await YN(e,"/v1/browser/monitor",{enabled:t})).monitoring}}let YO={drafting:"撰写计划",awaiting_approval:"等待批准",executing:"执行中",compacting:"压缩上下文",done:"已完成"};function Yz(e){if(!e.children||0===e.children.length)return"task"!==e.kind&&"subplan"!==e.kind?{done:0,total:0}:{done:+("done"===e.status),total:1};let t=0,n=0;for(let r of e.children){let e=Yz(r);t+=e.done,n+=e.total}return{done:t,total:n}}function YA(e,t){if(e){if(e.id===t)return e;for(let n of e.children??[]){let e=YA(n,t);if(e)return e}}}function YT({done:e,total:t}){let n=t>0?Math.round(e/t*100):0;return(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-muted",children:(0,eb.jsx)("div",{className:"h-full rounded-full bg-foreground transition-all",style:{width:`${n}%`}})}),(0,eb.jsxs)("span",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground",children:[e,"/",t]})]})}function YR({state:e}){let{phase:t,task:n}=function(e){let t,n=e.activePath??[];if(!e.tree||0===n.length)return{};for(let r of n){let n=YA(e.tree,r);n&&"phase"===n.kind&&(t=n)}let r=n[n.length-1];return{phase:t,task:r?YA(e.tree,r):void 0}}(e),r=e.tree?Yz(e.tree):{done:0,total:0},a=t?Yz(t):void 0,i=r.total>0?Math.round(r.done/r.total*100):0,o=n?.status==="in_progress";return(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(YD,{icon:(0,eb.jsx)(uZ,{}),label:"任务进度"}),(0,eb.jsxs)("div",{className:"flex flex-col gap-2 px-3 pb-2 text-[13px]",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)("span",{className:"text-muted-foreground",children:"当前阶段"}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium",children:t?.title??YO[e.phase]??e.phase??"—"})]}),a&&a.total>0?(0,eb.jsx)(YT,{done:a.done,total:a.total}):null,n?(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[o?(0,eb.jsx)(Yy,{className:"size-3.5 shrink-0 animate-spin text-amber-500"}):"done"===n.status?(0,eb.jsx)(h6,{className:"size-3.5 shrink-0 text-emerald-500"}):null,(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",title:n.detail||n.title,children:n.title})]}):null,(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)("span",{className:"text-muted-foreground",children:"总体进度"}),(0,eb.jsxs)("span",{className:"ml-auto font-medium tabular-nums",children:[i,"%"]})]}),(0,eb.jsx)("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-muted",children:(0,eb.jsx)("div",{className:"h-full rounded-full bg-foreground transition-all",style:{width:`${i}%`}})})]}),(0,eb.jsx)("div",{className:"mx-3 border-t border-border/60"})]})}function YD({icon:e,label:t}){return(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 px-3 pt-3 pb-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/70 [&_svg]:size-3.5",children:[e,(0,eb.jsx)("span",{children:t})]})}function Y_(){let[e,t]=ew.useState("loading"),[n,r]=ew.useState(!1),a=ew.useCallback(async e=>{try{let n=(await Yk(void 0,{signal:e,timeoutMs:6e3})).extensions.find(e=>"browser"===e.id);n&&n.installed?n.running?t("running"):t(e=>"starting"===e?"starting":"stopped"):t("missing")}catch{t("missing")}},[]);ew.useEffect(()=>{let e=!0,t=new AbortController,n=()=>{e&&a(t.signal)};n();let r=window.setInterval(n,1e4);return()=>{e=!1,t.abort(),window.clearInterval(r)}},[a]);let i=ew.useCallback(async()=>{if(!n){r(!0),t("starting");try{await YE(void 0,!0);let e=Date.now()+3e4;for(;Date.now()<e;){await new Promise(e=>setTimeout(e,1500));try{let e=await Yk(void 0,{timeoutMs:6e3});if(e.extensions.find(e=>"browser"===e.id)?.running)return void t("running")}catch{}}}catch{}finally{r(!1),await a()}}},[n,a]);return(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)(qz,{className:"size-4 shrink-0 text-muted-foreground"}),(0,eb.jsx)("span",{className:"text-muted-foreground",children:"浏览器"}),"running"===e?(0,eb.jsx)(YL,{online:!0}):"starting"===e?(0,eb.jsx)(Yy,{className:"size-3.5 shrink-0 animate-spin text-amber-500"}):(0,eb.jsx)(YL,{online:!1}),(0,eb.jsx)("span",{className:"truncate font-medium",children:"running"===e?"运行中":"starting"===e?"启动中":"stopped"===e?"已停止":"missing"===e?"未安装":"—"}),(0,eb.jsx)("span",{className:"ml-auto shrink-0",children:"stopped"===e?(0,eb.jsxs)("button",{type:"button",onClick:()=>void i(),className:"inline-flex items-center gap-1 rounded-md border border-border/70 px-1.5 py-0.5 text-[11px] font-medium text-foreground transition-colors hover:bg-muted",children:[(0,eb.jsx)(HE,{className:"size-3"}),"启动"]}):"running"===e?(0,eb.jsx)("span",{className:"text-[11px] text-muted-foreground/70",title:"在画布的「浏览器」节点中实时查看 Agent 的浏览器操作",children:"画布查看"}):null})]})}function YL({online:e}){return(0,eb.jsx)("span",{"aria-hidden":!0,className:(0,ez.cn)("inline-block size-2 shrink-0 rounded-full",e?"bg-emerald-500":"bg-muted-foreground/40")})}function Y$({conversationId:e,ownerMachineId:t}){let[n,r]=ew.useState(null),[a,i]=ew.useState([]),[o,l]=ew.useState([]),{machines:s}=vd();ew.useEffect(()=>{if(!e)return;let n=!0,a=async()=>{try{let[a,o,s]=await Promise.all([sD(e,t),sL(e,t).catch(()=>[]),s$(e,t).catch(()=>[])]);if(!n)return;r(a),i(o),l(s)}catch{}};a();let o=window.setInterval(a,1200);return()=>{n=!1,window.clearInterval(o)}},[e,t]);let c=ew.useMemo(()=>new Map(s.map(e=>[e.id,e])),[s]),d=e=>"local"===e||c.get(e)?.status==="online",u=e=>"local"===e?c.get("local")?.name??"本地":c.get(e)?.name??e,f=t??n?.conversation.ownerMachineId??"local",m=(n?.conversation.settings?.hosts??[]).filter(Boolean),h=n?.conversation.runUsage,p=n?.conversation.status==="working",g=(h?.cachedInputTokens??0)+(h?.cacheCreationInputTokens??0),{additions:x,deletions:v}=function(e){let t=-1;for(let n=e.length-1;n>=0;n-=1)if(e[n]?.kind==="user"){t=n;break}let n=0,r=0;for(let a=Math.max(0,t);a<e.length;a+=1){let t=e[a],i=t?.additions??t?.meta?.additions,o=t?.deletions??t?.meta?.deletions;"number"==typeof i&&(n+=i),"number"==typeof o&&(r+=o)}return{additions:n,deletions:r}}(n?.events??[]),b=function(e){let t=-1;for(let n=e.length-1;n>=0;n-=1)if(e[n]?.kind==="user"){t=n;break}let n=new Set;for(let r=Math.max(0,t);r<e.length;r+=1){let t=e[r];if(t?.kind==="subagent"&&Array.isArray(t.subagents))for(let e of t.subagents)e?.id&&n.add(e.id)}return n}(n?.events??[]),y=function e(t,n=0,r=[]){for(let a of t)r.push({node:a,depth:n}),a.children&&a.children.length>0&&e(a.children,n+1,r);return r}(a.filter(e=>b.has(e.id))),w=n?.conversation.planState;return(0,eb.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col overflow-auto rounded-[inherit] bg-background text-sm",children:[(0,eb.jsx)(YD,{icon:(0,eb.jsx)(uV,{}),label:"环境信息"}),(0,eb.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 pb-2 text-[13px]",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-foreground/90",children:[(0,eb.jsx)(eP,{className:"size-4 shrink-0 text-muted-foreground"}),(0,eb.jsx)("span",{className:"text-muted-foreground",children:"运行于"}),(0,eb.jsx)(YL,{online:d(f)}),(0,eb.jsx)("span",{className:"truncate font-medium",children:u(f)})]}),(0,eb.jsxs)("div",{className:"flex items-start gap-2",children:[(0,eb.jsx)(Yw,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),(0,eb.jsx)("span",{className:"mt-0.5 shrink-0 text-muted-foreground",children:"可访问"}),(0,eb.jsx)("div",{className:"flex min-w-0 flex-wrap gap-x-3 gap-y-1",children:0===m.length?(0,eb.jsx)("span",{className:"text-muted-foreground/70",children:"—"}):m.map(e=>(0,eb.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,eb.jsx)(YL,{online:d(e)}),(0,eb.jsx)("span",{className:"truncate",children:u(e)})]},e))})]}),(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)(Yb,{className:"size-4 shrink-0 text-muted-foreground"}),(0,eb.jsx)("span",{className:"text-muted-foreground",children:"本轮变更"}),(0,eb.jsxs)("span",{className:"font-medium text-emerald-600 dark:text-emerald-400",children:["+",x]}),(0,eb.jsxs)("span",{className:"font-medium text-rose-600 dark:text-rose-400",children:["-",v]}),(0,eb.jsx)("span",{className:"text-muted-foreground/60",children:"行"})]}),(0,eb.jsx)(Y_,{})]}),(0,eb.jsx)("div",{className:"mx-3 border-t border-border/60"}),w?(0,eb.jsx)(YR,{state:w}):null,(0,eb.jsx)(YD,{icon:(0,eb.jsx)(uH,{}),label:"子智能体"}),(0,eb.jsx)("div",{className:"flex max-h-44 flex-col gap-1 overflow-y-auto px-3 pb-2 text-[13px]",children:0===y.length?(0,eb.jsx)("span",{className:"text-muted-foreground/70",children:"本轮未释放子智能体"}):y.map(({node:e,depth:t})=>{let n="failed"===e.status;return(0,eb.jsxs)("div",{className:"flex items-center gap-2",style:{paddingLeft:12*t},children:[e.running?(0,eb.jsx)(Yy,{className:"size-3.5 shrink-0 animate-spin text-amber-500"}):n?(0,eb.jsx)(fV.XIcon,{className:"size-3.5 shrink-0 text-rose-500"}):(0,eb.jsx)(h6,{className:"size-3.5 shrink-0 text-emerald-500"}),(0,eb.jsx)("span",{className:"truncate",children:e.subagentName||e.title||e.subagentType||"子智能体"}),(0,eb.jsx)("span",{className:"ml-auto shrink-0 text-[11px] text-muted-foreground/70",children:e.running?"运行中":n?"失败":"已完成"})]},e.id)})}),(0,eb.jsx)("div",{className:"mx-3 border-t border-border/60"}),(0,eb.jsx)(YD,{icon:(0,eb.jsx)(u0,{}),label:"后台任务"}),(0,eb.jsx)("div",{className:"flex max-h-44 flex-col gap-1 overflow-y-auto px-3 pb-2 text-[13px]",children:0===o.length?(0,eb.jsx)("span",{className:"text-muted-foreground/70",children:"本轮无后台任务"}):o.map(e=>{let t="failed"===e.status||"timeout"===e.status,n="unknown"===e.status;return(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[e.running?(0,eb.jsx)(Yy,{className:"size-3.5 shrink-0 animate-spin text-amber-500"}):n?(0,eb.jsx)(m0,{className:"size-3.5 shrink-0 text-amber-500"}):t?(0,eb.jsx)(fV.XIcon,{className:"size-3.5 shrink-0 text-rose-500"}):(0,eb.jsx)(h6,{className:"size-3.5 shrink-0 text-emerald-500"}),(0,eb.jsx)("span",{className:"truncate font-mono text-[12px]",title:e.command,children:e.command||"(命令)"}),e.orphaned?(0,eb.jsx)("span",{className:"shrink-0 rounded bg-amber-500/15 px-1 text-[10px] font-medium text-amber-600 dark:text-amber-400",title:"该后台进程脱离了本轮但仍在运行",children:"脱离"}):null,(0,eb.jsx)("span",{className:"ml-auto shrink-0 text-[11px] text-muted-foreground/70",children:e.running?"运行中":n?"状态未知":t?"timeout"===e.status?"超时":"失败":"已完成"})]},e.id)})}),(0,eb.jsx)("div",{className:"mx-3 border-t border-border/60"}),(0,eb.jsx)(YD,{icon:(0,eb.jsx)(Yv,{}),label:p?"本轮消耗":"消耗额度"}),(0,eb.jsx)("div",{className:"grid grid-cols-3 gap-2 px-3 pb-3",children:[{label:"输入",value:h?.inputTokens},{label:"输出",value:h?.outputTokens},{label:"缓存",value:g}].map(e=>{let t;return(0,eb.jsxs)("div",{className:"rounded-lg border border-border/60 bg-muted/30 px-2 py-1.5",children:[(0,eb.jsx)("div",{className:"text-[11px] text-muted-foreground",children:e.label}),(0,eb.jsx)("div",{className:"font-mono text-sm font-medium tabular-nums",children:h?(t=e.value??0)>=1e6?`${(t/1e6).toFixed(2)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t):"—"})]},e.label)})})]})}function YF({done:e,total:t}){let n=t>0?Math.round(e/t*100):0;return(0,eb.jsx)("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-muted",children:(0,eb.jsx)("div",{className:"h-full rounded-full bg-foreground transition-all",style:{width:`${n}%`}})})}function YB({conversationId:e,ownerMachineId:t}){let[n,r]=ew.useState(void 0);ew.useEffect(()=>{if(r(void 0),!e)return;let n=!0,a=0,i=async()=>{let i=a+=1;try{let o=await s_(e,{limit:400},t);if(!n||i!==a)return;r(function(e){for(let t=e.length-1;t>=0;t-=1){let n=e[t];if(n&&"task"===n.kind&&Array.isArray(n.tasks))return n.tasks}}(o.events)??[])}catch{}};i();let o=window.setInterval(i,1200);return()=>{n=!1,window.clearInterval(o)}},[e,t]);let a=n??[],i=a.length,o=a.filter(e=>"done"===e.status).length;return(0,eb.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col rounded-[inherit] bg-background",children:[(0,eb.jsxs)("div",{className:"shrink-0 space-y-1.5 border-b px-3 py-2",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)("span",{className:"text-[13px] font-medium text-foreground",children:"任务"}),(0,eb.jsxs)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[o,"/",i]})]}),(0,eb.jsx)(YF,{done:o,total:i})]}),(0,eb.jsx)(jP,{className:"min-h-0 flex-1",children:(0,eb.jsx)("div",{className:"px-2 py-2",children:0===i?(0,eb.jsx)("p",{className:"px-2 py-1 text-sm text-muted-foreground/70",children:"暂无任务"}):(0,eb.jsx)("ul",{className:"flex flex-col gap-0.5",children:a.map(e=>{let{glyph:t,className:n}=function(e){switch(e){case"done":return{glyph:"✓",className:"text-emerald-500"};case"in_progress":return{glyph:"▸",className:"text-amber-500"};case"cancelled":return{glyph:"✕",className:"text-rose-500"};default:return{glyph:"○",className:"text-muted-foreground/50"}}}(e.status),r="done"===e.status;return(0,eb.jsxs)("li",{className:"flex items-start gap-2 rounded-md px-1.5 py-1",children:[(0,eb.jsx)("span",{className:(0,ez.cn)("mt-px shrink-0 text-[13px] leading-5",n),"aria-hidden":!0,children:t}),(0,eb.jsx)("span",{className:(0,ez.cn)("min-w-0 flex-1 text-[13px] leading-5",r&&"text-muted-foreground line-through"),title:e.detail||e.title,children:e.title})]},e.id)})})})})]})}var YV=e.i(78737);let YH=(0,ek.default)("earth",[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),YU=(0,ek.default)("smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]),Yq=(0,ek.default)("tablet",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]]),YW=[{id:"phone",label:"Phone",width:390,userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.1"},{id:"tablet",label:"Tablet",width:820,userAgent:"Mozilla/5.0 (iPad; CPU OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.1"},{id:"desktop",label:"Desktop",width:1200,userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 15_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"}],YK=[{id:"adaptive",label:"自适应",adaptive:!0},{id:"16:9",label:"16:9",value:16/9},{id:"4:3",label:"4:3",value:4/3},{id:"3:2",label:"3:2",value:1.5},{id:"1:1",label:"1:1",value:1},{id:"9:16",label:"9:16",value:9/16}],YG={urlLabel:"URL",urlPlaceholder:"https://example.com",navigate:"Navigate",actions:"Browser view options",devices:"User agent",ratios:"Viewport ratio",back:"Back",forward:"Forward",reload:"Reload preview",previewTitle:"Browser preview"};function YX(e,t,n){return e.find(e=>e.id===t)??n}function YY({id:e}){return"phone"===e?(0,eb.jsx)(YU,{className:"size-4"}):"tablet"===e?(0,eb.jsx)(Yq,{className:"size-4"}):(0,eb.jsx)(eP,{className:"size-4"})}function YZ({url:e,defaultUrl:t="https://vantaloom.local/workspace",onUrlChange:n,onNavigate:r,onBack:a,onForward:i,device:o,defaultDevice:l="desktop",onDeviceChange:s,ratio:c,defaultRatio:d="adaptive",onRatioChange:u,devices:f=YW,ratios:m=YK,srcDoc:h,renderPreview:p,showHeader:g=!0,labels:x,className:v,headerClassName:b,previewClassName:y,...w}){let j=ew.useMemo(()=>({...YG,...x}),[x]),[k,N]=ew.useState(t),[S,C]=ew.useState(e??t),[M,E]=ew.useState(()=>[e??t]),[I,P]=ew.useState(0),[O,z]=ew.useState(l),[A,T]=ew.useState(d),[R,D]=ew.useState(!1),[_,L]=ew.useState(0),$=ew.useRef(null),F=ew.useId(),[B,V]=function(){let e=ew.useRef(null),[t,n]=ew.useState({width:0,height:0});return ew.useEffect(()=>{let t=e.current;if(!t)return;function r(e){t&&n(e??{width:t.clientWidth,height:t.clientHeight})}r();let a=new ResizeObserver(e=>{let t=e[0];t?r({width:t.contentRect.width,height:t.contentRect.height}):r()});return a.observe(t),()=>a.disconnect()},[]),[e,t]}(),H=e??k,U=YX(f,o??O,f[0]??YW[0]),q=YX(m,c??A,m[0]??YK[0]),W=V.width>0&&V.height>0,K=q.adaptive||"adaptive"===q.id,G=q.value??16/9,X=K&&V.width||U.width,Y=K?V.height||U.width/G:X/G,Z=(W?V.width/V.height:1)<=G,J=Math.max(1,Math.round(W?K||Z?V.width:V.height*G:X)),Q=Math.max(1,Math.round(W?K?V.height:Z?V.width/G:V.height:Y)),ee=J/X,et=ew.useMemo(()=>({url:H,device:U,ratio:q,viewport:{width:J,height:Q,scale:ee}}),[U,q,H,ee,Q,J]);function en(t,a={history:"push"}){void 0===e&&N(t),"none"!==a.history&&E(e=>{let n=e.slice(0,I+1);return n[n.length-1]===t?n:(P(n.length),[...n,t])}),n?.(t),r?.(t)}return ew.useEffect(()=>{C(e??k)},[k,e]),ew.useEffect(()=>{if(R)return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e);function e(e){let t=e.target;t instanceof Node&&$.current?.contains(t)||D(!1)}},[R]),(0,eb.jsxs)("div",{ref:$,"data-slot":"browser-tab-viewer","data-device":U.id,"data-ratio":q.id,className:(0,ez.cn)("vtl-surface-panel relative grid min-h-0 overflow-hidden rounded-[var(--surface-panel-radius)] border",g?"grid-rows-[auto_minmax(0,1fr)]":"grid-rows-[minmax(0,1fr)]",v),...w,children:[g&&(0,eb.jsxs)("div",{"data-slot":"browser-tab-viewer-header",className:(0,ez.cn)("flex min-w-0 items-center gap-2 border-b bg-muted/35 px-3 py-2",b),children:[(0,eb.jsx)("span",{className:"grid size-5 shrink-0 place-items-center rounded-md border bg-background text-muted-foreground",children:(0,eb.jsx)(YH,{className:"size-3.5"})}),(0,eb.jsxs)("form",{onSubmit:function(e){let t;e.preventDefault();let n=(t=S.trim())?/^[a-z][a-z\d+\-.]*:\/\//i.test(t)?t:/^(localhost|127\.0\.0\.1|\[::1\])(?::\d+)?(?:\/|$)/i.test(t)?`http://${t}`:`https://${t}`:"";C(n),en(n)},className:"min-w-0 flex-1",children:[(0,eb.jsx)("label",{className:"sr-only",htmlFor:F,children:j.urlLabel}),(0,eb.jsx)(eA,{id:F,value:S,onChange:e=>C(e.target.value),placeholder:j.urlPlaceholder,className:"h-5 rounded-md border bg-background px-2 shadow-none ui-text-kbd",spellCheck:!1})]}),(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j.back,disabled:I<=0,onClick:function(){if(I<=0)return;let e=I-1,t=M[e];t&&(P(e),C(t),en(t,{history:"none"}),a?.(t))},className:"size-5 rounded-md",children:(0,eb.jsx)(YV.ArrowLeftIcon,{className:"size-3.5"})}),(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j.forward,disabled:I>=M.length-1,onClick:function(){if(I>=M.length-1)return;let e=I+1,t=M[e];t&&(P(e),C(t),en(t,{history:"none"}),i?.(t))},className:"size-5 rounded-md",children:(0,eb.jsx)(ej.ArrowRightIcon,{className:"size-3.5"})}),(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j.reload,onClick:()=>L(e=>e+1),className:"size-5 rounded-md",children:(0,eb.jsx)(yt,{className:"size-3.5"})})]}),(0,eb.jsx)("div",{ref:B,"data-slot":"browser-tab-viewer-stage",className:(0,ez.cn)("grid min-h-0 place-items-center overflow-hidden bg-muted/20",y),children:(0,eb.jsx)("div",{"data-slot":"browser-tab-viewer-viewport",className:"overflow-hidden rounded-lg border bg-background shadow-sm",style:{width:J,height:Q},children:p?p(et):(0,eb.jsx)("iframe",{title:j.previewTitle,src:h?void 0:H,srcDoc:h,sandbox:"allow-forms allow-modals allow-popups allow-same-origin allow-scripts",className:"size-full border-0 bg-background"},`${_}-${H}-${U.id}-${q.id}`)})}),(0,eb.jsxs)("div",{"data-slot":"browser-tab-floating-actions",className:"absolute right-3 bottom-3 z-20",children:[(0,eb.jsxs)("div",{className:(0,ez.cn)("vtl-surface-popover absolute right-0 bottom-10 grid w-56 gap-3 rounded-[var(--surface-popover-radius)] border p-3 transition-[opacity,transform] duration-150",R?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0"),children:[(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)("div",{className:"text-muted-foreground ui-text-kbd",children:j.devices}),(0,eb.jsx)("div",{className:"flex gap-1.5",children:f.map(e=>(0,eb.jsx)(eO.Button,{type:"button",variant:U.id===e.id?"default":"outline",size:"icon-sm","aria-label":e.label,title:e.label,className:"rounded-full",onClick:()=>{let t;return t=YX(f,e.id,U),void(void 0===o&&z(t.id),s?.(t.id,t))},children:(0,eb.jsx)(YY,{id:e.id})},e.id))})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)("div",{className:"text-muted-foreground ui-text-kbd",children:j.ratios}),(0,eb.jsx)("div",{className:"flex flex-wrap gap-1.5",children:m.map(e=>(0,eb.jsx)(eO.Button,{type:"button",variant:q.id===e.id?"default":"outline",size:"xs",className:"h-7 rounded-full px-2.5 ui-text-kbd",onClick:()=>{let t;return t=YX(m,e.id,q),void(void 0===c&&T(t.id),u?.(t.id,t))},children:e.label},e.id))})]})]}),(0,eb.jsx)(eO.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":j.actions,"aria-expanded":R,onClick:()=>D(e=>!e),className:"rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,eb.jsx)(lG,{className:(0,ez.cn)("size-4 transition-transform",R&&"rotate-90")})})]})]})}let YJ=(0,ek.default)("monitor-off",[["path",{d:"M17 17H4a2 2 0 0 1-2-2V5c0-1.5 1-2 1-2",key:"k0q8oc"}],["path",{d:"M22 15V5a2 2 0 0 0-2-2H9",key:"cp1ac0"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),YQ=(0,ek.default)("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);function Y0({frame:e,cursor:t,connection:n,takeover:r,onTakeoverChange:a,onInput:i,onReconnect:o,machines:l,selectedMachineId:s,onSelectMachine:c,onStartBrowser:d,starting:u,monitoring:f,onMonitoringChange:m,className:h}){let p=ew.useRef(null),g=ew.useRef(null),x=ew.useRef(null),v=ew.useRef(t??null),b=ew.useRef(0),y=ew.useRef(!1),[w,j]=ew.useState(!1),k=ew.useCallback(()=>{let e=p.current,t=x.current;if(!e||!t)return;let n=e.getContext("2d");if(!n)return;n.drawImage(t,0,0,e.width,e.height);let r=v.current;if(!r)return;let a=Math.max(9,e.width/110);n.save(),n.beginPath(),n.arc(r.x,r.y,a,0,2*Math.PI),n.fillStyle="rgba(255,45,85,0.35)",n.fill(),n.lineWidth=Math.max(2,a/4),n.strokeStyle="rgba(255,255,255,0.95)",n.stroke(),n.beginPath(),n.arc(r.x,r.y,Math.max(2.5,.32*a),0,2*Math.PI),n.fillStyle="rgba(255,45,85,0.95)",n.fill(),n.restore()},[]);function N(t){let n=p.current;if(!n)return null;let r=n.getBoundingClientRect();if(0===r.width||0===r.height)return null;let a=(e?.width||n.width)/r.width,i=(e?.height||n.height)/r.height;return{x:Math.round((t.clientX-r.left)*a),y:Math.round((t.clientY-r.top)*i)}}function S(e,t){r&&i&&(e.preventDefault(),i({kind:"key",type:t,key:e.key}),"keyDown"===t&&1===e.key.length&&i({kind:"key",type:"char",key:e.key,text:e.key}))}ew.useEffect(()=>{let t=p.current;if(!t||!e?.b64)return;let n=new Image;return g.current=n,n.onload=()=>{if(g.current!==n)return;let r=e.width||n.naturalWidth,a=e.height||n.naturalHeight;t.width!==r&&(t.width=r),t.height!==a&&(t.height=a),x.current=n,k()},n.src=`data:image/jpeg;base64,${e.b64}`,()=>{n.onload=null,g.current===n&&(g.current=null)}},[e,k]),ew.useEffect(()=>{v.current=t??null,k()},[t,k]);let C="streaming"===n||!!e;return(0,eb.jsxs)("div",{className:(0,ez.cn)("vtl-surface-panel relative flex size-full min-h-0 flex-col overflow-hidden",h),"data-slot":"live-browser-view",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-2 border-b bg-muted/35 px-3 py-2",children:[(0,eb.jsx)("span",{className:"text-muted-foreground ui-text-kbd shrink-0",children:"浏览器"}),(0,eb.jsx)("div",{className:"min-w-0 flex-1",children:l.length>0?(0,eb.jsx)("select",{value:s??"",onChange:e=>c?.(e.target.value),className:"h-6 w-full max-w-[16rem] truncate rounded-md border bg-background px-2 ui-text-kbd",children:l.map(e=>(0,eb.jsxs)("option",{value:e.id,disabled:!e.running,children:[e.label,e.running?"":"(未运行)"]},e.id))}):(0,eb.jsx)("span",{className:"text-muted-foreground ui-text-kbd",children:"无可用浏览器"})}),m?(0,eb.jsxs)(eO.Button,{type:"button",size:"xs",variant:f?"default":"outline",className:"h-6 gap-1 rounded-md px-2 ui-text-kbd","aria-pressed":!!f,onClick:()=>m(!f),title:f?"浏览器监视:开启(有头实时画面,会打开一个真实浏览器窗口)。点击关闭后仅在 agent 每次操作后显示一帧。":"浏览器监视:关闭(仅在 agent 每次操作后显示一帧)。点击开启有头实时画面,会打开一个真实浏览器窗口。",children:[f?(0,eb.jsx)(eP,{className:"size-3.5"}):(0,eb.jsx)(YJ,{className:"size-3.5"}),"监视"]}):null,(0,eb.jsxs)(eO.Button,{type:"button",size:"xs",variant:r?"default":"outline",className:"h-6 gap-1 rounded-md px-2 ui-text-kbd","aria-pressed":r,onClick:()=>a(!r),disabled:"streaming"!==n,title:r?"切换到观看模式":"接管:在画面里直接操作",children:[r?(0,eb.jsx)(lU,{className:"size-3.5"}):(0,eb.jsx)(lX,{className:"size-3.5"}),r?"接管中":"观看"]}),"error"===n&&o?(0,eb.jsx)(eO.Button,{type:"button",size:"icon-xs",variant:"ghost",className:"size-6 rounded-md","aria-label":"重新连接",onClick:o,children:(0,eb.jsx)(YQ,{className:"size-3.5"})}):null]}),(0,eb.jsxs)("div",{className:"relative grid min-h-0 flex-1 place-items-center overflow-hidden bg-black/85",children:[C?(0,eb.jsx)("canvas",{ref:p,tabIndex:r?0:-1,onPointerDown:function(e){if(!r||!i)return;let t=N(e);t&&(y.current=!0,e.currentTarget.setPointerCapture(e.pointerId),p.current?.focus(),i({kind:"mouse",type:"mousePressed",button:"left",...t}))},onPointerUp:function(e){if(!r||!i)return;let t=N(e);y.current=!1;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}t&&i({kind:"mouse",type:"mouseReleased",button:"left",...t})},onPointerMove:function(e){if(!r||!i)return;let t=performance.now();if(t-b.current<33)return;b.current=t;let n=N(e);n&&i({kind:"mouse",type:"mouseMoved",button:y.current?"left":"none",...n})},onKeyDown:e=>S(e,"keyDown"),onKeyUp:e=>S(e,"keyUp"),onFocus:()=>j(!0),onBlur:()=>j(!1),className:(0,ez.cn)("max-h-full max-w-full object-contain outline-none",r?"cursor-crosshair":"cursor-default")}):(0,eb.jsx)("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:"connecting"===n?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(eM,{className:"size-5 animate-spin"}),(0,eb.jsx)("span",{children:"正在连接浏览器…"})]}):"error"===n?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(YJ,{className:"size-5"}),(0,eb.jsx)("span",{children:"连接浏览器失败"}),o?(0,eb.jsx)(eO.Button,{type:"button",size:"xs",variant:"outline",onClick:o,children:"重试"}):null]}):u?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(eM,{className:"size-5 animate-spin"}),(0,eb.jsx)("span",{children:"正在启动浏览器…"})]}):0===l.length?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(YJ,{className:"size-5"}),(0,eb.jsx)("span",{children:"未安装浏览器"}),(0,eb.jsx)("span",{className:"text-xs text-muted-foreground/70",children:"请在「官方扩展」页面安装 Vantaloom 浏览器"})]}):d?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(YJ,{className:"size-5"}),(0,eb.jsx)("span",{children:"浏览器已停止"}),(0,eb.jsxs)(eO.Button,{type:"button",size:"xs",variant:"outline",className:"gap-1",onClick:d,children:[(0,eb.jsx)(HE,{className:"size-3.5"}),"启动浏览器"]})]}):!f&&m?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(YJ,{className:"size-5"}),(0,eb.jsx)("span",{children:"等待 agent 操作后显示画面"}),(0,eb.jsxs)(eO.Button,{type:"button",size:"xs",variant:"outline",className:"gap-1",onClick:()=>m(!0),children:[(0,eb.jsx)(eP,{className:"size-3.5"}),"开启浏览器监视以查看实时画面"]})]}):(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(YJ,{className:"size-5"}),(0,eb.jsx)("span",{children:"浏览器未运行"})]})}),r&&C?(0,eb.jsxs)("div",{className:"pointer-events-none absolute inset-0",children:[(0,eb.jsx)("div",{className:(0,ez.cn)("absolute inset-0 rounded-sm ring-2 ring-inset transition-colors",w?"ring-hot-pink":"ring-hot-pink/50")}),(0,eb.jsxs)("span",{className:"absolute left-2 top-2 rounded bg-hot-pink/90 px-1.5 py-0.5 text-[10px] font-medium text-white",children:["接管中",w?"":"(点击画面以捕获键盘)"]})]}):null]})]})}function Y1(e,t){return e?(0,eT.localAPIURL)(`/v1/remote/${e}/browser${t}`):(0,eT.localAPIURL)(`/v1/browser${t}`)}async function Y2(e,t){try{await fetch(Y1(e,"/input"),{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch{}}function Y5({active:e=!0,className:t}){let[n,r]=ew.useState(0),a=function(e,t){let{machines:n}=vd(),[r,a]=ew.useState([]);return ew.useEffect(()=>{if(!e)return;let t=!1;async function r(e,t,n){try{let r=(await Yk(t,{timeoutMs:6e3})).extensions.find(e=>"browser"===e.id);if(!r||!r.installed)return null;return{id:e,machineId:t,label:n,installed:r.installed,running:r.running}}catch{return null}}async function i(){let e=[{id:"",machineId:void 0,label:"本机"}];for(let t of n)t.isLocal||"online"===t.status&&e.push({id:t.id,machineId:t.id,label:t.name||t.id});let i=await Promise.all(e.map(e=>r(e.id,e.machineId,e.label)));t||a(i.filter(e=>null!==e))}i();let o=window.setInterval(i,1e4);return()=>{t=!0,window.clearInterval(o)}},[e,n,t]),r}(e,n),[i,o]=ew.useState(""),[l,s]=ew.useState(!1),[c,d]=ew.useState(!1),[u,f]=ew.useState(!1);ew.useEffect(()=>{0===a.length||a.some(e=>e.id===i)||o((a.find(e=>e.running)??a[0]).id)},[a,i]);let m=a.find(e=>e.id===i),h=!!m?.running;ew.useEffect(()=>{!h&&l&&s(!1)},[h,l]);let{frame:p,cursor:g,connection:x,reconnect:v}=function(e){let{machineId:t,enabled:n}=e,[r,a]=ew.useState(null),[i,o]=ew.useState(null),[l,s]=ew.useState("idle"),[c,d]=ew.useState(0),u=ew.useCallback(()=>{d(e=>e+1)},[]);return ew.useEffect(()=>{let e;if(!n){s("idle"),a(null),o(null);return}let r=!1,i=new AbortController;async function l(){s("connecting");try{let e=await fetch(Y1(t,"/screencast"),{cache:"no-store",headers:{Accept:"text/event-stream"},signal:i.signal});if(r)return;if(404===e.status||409===e.status){s("no-browser"),c();return}if(!e.ok||!e.body){s("error"),c();return}let n=e.body.getReader(),l=new TextDecoder,d="";for(s("streaming");;){let{value:e,done:t}=await n.read();if(r||t)break;let i=(d+=l.decode(e,{stream:!0})).indexOf("\n\n");for(;-1!==i;){let e=d.slice(0,i);d=d.slice(i+2),function(e){let t=e.split("\n").filter(e=>e.startsWith("data:")).map(e=>e.slice(5).trimStart());if(0===t.length)return;let n=t.join("\n");if(n&&"[DONE]"!==n)try{let e=JSON.parse(n);"frame"===e.type&&e.b64?a({b64:e.b64,width:e.meta?.width??0,height:e.meta?.height??0}):"cursor"===e.type&&"number"==typeof e.x&&"number"==typeof e.y&&o({x:e.x,y:e.y})}catch{}}(e),i=d.indexOf("\n\n")}}r||(s("connecting"),c())}catch{if(r||i.signal.aborted)return;s("error"),c()}}function c(){r||(e=setTimeout(()=>{r||l()},1500))}return l(),()=>{r=!0,i.abort(),e&&clearTimeout(e)}},[t,n,c]),{frame:r,cursor:i,connection:l,reconnect:u}}({machineId:m?.machineId,enabled:e&&h});ew.useEffect(()=>{if(!e||!h)return void f(!1);let t=!1;return YI(m?.machineId).then(e=>{!t&&e&&f(e.monitoring)}),()=>{t=!0}},[e,h,m?.machineId]);let b=ew.useCallback(e=>{YP(m?.machineId,e).then(e=>{f(e.monitoring),v()}).catch(()=>{})},[m,v]),y=a.map(e=>({id:e.id,machineId:e.machineId,label:e.label,running:e.running})),w=ew.useCallback(e=>{Y2(m?.machineId,e)},[m?.machineId]),j=ew.useCallback(async()=>{if(!c){d(!0);try{await YE(m?.machineId,!0);let e=Date.now()+3e4;for(;Date.now()<e;){await new Promise(e=>setTimeout(e,1500));try{let e=await Yk(m?.machineId,{timeoutMs:6e3});if(e.extensions.find(e=>"browser"===e.id)?.running)break}catch{}}}catch{}finally{d(!1),r(e=>e+1)}}},[m,c]);return(0,eb.jsx)(Y0,{cursor:g,className:t,frame:p,connection:h?x:"no-browser",takeover:l,onTakeoverChange:s,onInput:w,onReconnect:v,machines:y,selectedMachineId:i,onSelectMachine:o,onStartBrowser:m&&!h?()=>void j():void 0,starting:c,monitoring:u,onMonitoringChange:h?b:void 0})}function Y4({defaultUrl:e,className:t}){let{machines:n}=vd(),[r,a]=ew.useState(!1);return(ew.useEffect(()=>{let e=!1;async function t(){let t=[void 0];for(let e of n)e.isLocal||"online"===e.status&&t.push(e.id);let r=await Promise.all(t.map(async e=>{try{let t=await Yk(e,{timeoutMs:6e3});return!!t.extensions.find(e=>"browser"===e.id)?.running}catch{return!1}}));e||a(r.some(Boolean))}t();let r=window.setInterval(t,12e3);return()=>{e=!0,window.clearInterval(r)}},[n]),r)?(0,eb.jsx)(Y5,{active:!0,className:t}):(0,eb.jsx)(YZ,{className:t,defaultUrl:e})}let Y3=[{policyNumber:3,name:"Allow HTTP Traffic",sourceZone:"Trust",sourceIPs:["192.168.1.0/24","10.0.0.0/8"],destinationZone:"Trust",destinationIPs:["192.168.2.0/24"],tags:["Web Access","Internal"],action:"allow",description:"Permits HTTP traffic from internal network"},{policyNumber:5,name:"Block Suspicious IPs",sourceZone:"Untrust",sourceIPs:["203.0.113.0/24","198.51.100.0/24"],destinationZone:"Trust",destinationIPs:["Any"],tags:["Blocking","Security"],action:"deny",description:"Blocks known malicious IP ranges"},{policyNumber:9,name:"SSH Access Control",sourceZone:"Trust",sourceIPs:["172.16.0.0/12"],destinationZone:"Trust",destinationIPs:["10.50.0.0/16"],tags:["Admin Access","VPN"],action:"allow",description:"Restricted SSH access for admin network"},{policyNumber:12,name:"Database Port Protection",sourceZone:"Untrust",sourceIPs:["0.0.0.0/0"],destinationZone:"Trust",destinationIPs:["10.100.0.0/24"],tags:["Blocking","Database"],action:"deny",description:"Blocks external access to database ports"},{policyNumber:15,name:"API Gateway Access",sourceZone:"Trust",sourceIPs:["192.168.100.0/24","192.168.101.0/24"],destinationZone:"Trust",destinationIPs:["10.200.0.5"],tags:["API","VDI Env"],action:"allow",description:"Allows traffic to API gateway from specific subnets"},{policyNumber:18,name:"Drop Legacy SMB",sourceZone:"Trust",sourceIPs:["Any"],destinationZone:"Trust",destinationIPs:["10.20.0.0/16"],tags:["Legacy","Internal"],action:"drop",description:"Drops SMBv1 probes across workstation networks"},{policyNumber:22,name:"Agent Runtime Mesh",sourceZone:"Trust",sourceIPs:["10.10.4.0/24"],destinationZone:"Trust",destinationIPs:["10.10.8.0/24","10.10.12.0/24"],tags:["Agent","Runtime"],action:"allow",description:"Allows managed agent runtime channels between worker pools"},{policyNumber:27,name:"Block Public Admin Ports",sourceZone:"Untrust",sourceIPs:["0.0.0.0/0"],destinationZone:"Trust",destinationIPs:["Any"],tags:["Blocking","Admin Access"],action:"deny",description:"Denies public access to SSH, RDP, and database admin ports"},{policyNumber:31,name:"Build Cache Access",sourceZone:"Trust",sourceIPs:["10.30.0.0/16"],destinationZone:"Trust",destinationIPs:["10.60.12.20"],tags:["Build","Internal"],action:"allow",description:"Allows build workers to reach shared cache storage"},{policyNumber:36,name:"Relay Egress",sourceZone:"Trust",sourceIPs:["10.40.0.0/16"],destinationZone:"Untrust",destinationIPs:["198.18.0.0/15"],tags:["Relay","Agent"],action:"allow",description:"Permits relay service egress to managed edge addresses"},{policyNumber:41,name:"Quarantine Subnet",sourceZone:"Quarantine",sourceIPs:["10.250.0.0/24"],destinationZone:"Trust",destinationIPs:["Any"],tags:["Security","Blocking"],action:"deny",description:"Blocks quarantined hosts from internal services"},{policyNumber:48,name:"Observability Intake",sourceZone:"Trust",sourceIPs:["10.0.0.0/8"],destinationZone:"Trust",destinationIPs:["10.80.4.10"],tags:["Telemetry","Internal"],action:"allow",description:"Allows metrics and logs to the observability intake"}],Y6=Array.from(new Set(Y3.flatMap(e=>e.tags))).sort(),Y8=[["10.10.4.0/24","Agent workers","Trust","18"],["10.20.0.0/16","Workstations","Trust","41"],["10.250.0.0/24","Quarantine","Quarantine","03"],["198.18.0.0/15","Relay edge","Untrust","12"]],Y7=[["Database Port Protection","2026-06-12","Security"],["Relay Egress","2026-06-28","Network"],["Build Cache Access","2026-07-04","Build"],["Observability Intake","2026-07-18","Ops"]];function Y9({className:e,...t}){return(0,eb.jsx)("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:(0,ez.cn)("mx-auto flex w-full justify-center",e),...t})}function Ze({className:e,...t}){return(0,eb.jsx)("ul",{"data-slot":"pagination-content",className:(0,ez.cn)("flex flex-row items-center gap-1",e),...t})}function Zt({...e}){return(0,eb.jsx)("li",{"data-slot":"pagination-item",...e})}function Zn({className:e,isActive:t,size:n="icon",...r}){return(0,eb.jsx)("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:(0,ez.cn)((0,eO.buttonVariants)({variant:t?"outline":"ghost",size:n}),e),...r})}function Zr({className:e,previousLabel:t="Previous",...n}){return(0,eb.jsxs)(Zn,{"aria-label":t,size:"default",className:(0,ez.cn)("gap-1 px-2.5 sm:pl-2",e),...n,children:[(0,eb.jsx)(h8,{}),(0,eb.jsx)("span",{className:"hidden sm:block",children:t})]})}function Za({className:e,nextLabel:t="Next",...n}){return(0,eb.jsxs)(Zn,{"aria-label":t,size:"default",className:(0,ez.cn)("gap-1 px-2.5 sm:pr-2",e),...n,children:[(0,eb.jsx)("span",{className:"hidden sm:block",children:t}),(0,eb.jsx)(h7,{})]})}function Zi({className:e,moreLabel:t="More pages",...n}){return(0,eb.jsxs)("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:(0,ez.cn)("flex size-8 items-center justify-center",e),...n,children:[(0,eb.jsx)(lG,{className:"size-4"}),(0,eb.jsx)("span",{className:"sr-only",children:t})]})}function Zo({title:e}){return(0,eb.jsx)("h2",{className:"h-7 text-sm font-semibold tracking-normal",children:e})}function Zl(){let[e,t]=ew.useState(""),[n,r]=ew.useState("all"),[a,i]=ew.useState({allow:!1,drop:!1,deny:!1}),[o,l]=ew.useState(1),s=ew.useMemo(()=>["allow","drop","deny"].filter(e=>a[e]),[a]),c=ew.useMemo(()=>[{id:"policyNumber",header:"策略 #",accessorKey:"policyNumber",align:"right",width:84},{id:"name",header:"名称",accessorKey:"name",width:180,className:"font-medium"},{id:"sourceZone",header:"源区域",accessorKey:"sourceZone",width:112,cell:({row:e})=>(0,eb.jsx)(Zd,{zone:e.sourceZone})},{id:"sourceIPs",header:"源 IP",accessorKey:"sourceIPs",width:250,cell:({row:e})=>(0,eb.jsx)(Zc,{items:e.sourceIPs,variant:"outline"}),copyValue:({row:e})=>e.sourceIPs.join(", ")},{id:"destinationZone",header:"目标区域",accessorKey:"destinationZone",width:112,cell:({row:e})=>(0,eb.jsx)(Zd,{zone:e.destinationZone})},{id:"destinationIPs",header:"目标 IP",accessorKey:"destinationIPs",width:250,cell:({row:e})=>(0,eb.jsx)(Zc,{items:e.destinationIPs,variant:"outline"}),copyValue:({row:e})=>e.destinationIPs.join(", ")},{id:"tags",header:"标签",accessorKey:"tags",width:220,cell:({row:e})=>(0,eb.jsx)(Zc,{items:e.tags,variant:"secondary"}),copyValue:({row:e})=>e.tags.join(", ")},{id:"action",header:"动作",accessorKey:"action",width:96,cell:({row:e})=>(0,eb.jsx)(Zu,{action:e.action})}],[]),d=ew.useMemo(()=>{let t=e.trim().toLowerCase();return Y3.filter(e=>{let r=0===t.length||e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.sourceIPs.some(e=>e.toLowerCase().includes(t))||e.destinationIPs.some(e=>e.toLowerCase().includes(t)),i="all"===n||e.tags.includes(n),o=!(a.allow||a.drop||a.deny)||a.allow&&"allow"===e.action||a.drop&&"drop"===e.action||a.deny&&"deny"===e.action;return r&&i&&o})},[a,e,n]),u=Math.max(1,Math.ceil(d.length/8)),f=Math.min(o,u),m=d.slice((f-1)*8,8*f);return ew.useEffect(()=>{l(1)},[a,e,n]),(0,eb.jsxs)("div",{className:"flex h-full min-h-0 flex-col p-3",children:[(0,eb.jsxs)("div",{className:"mb-3 flex shrink-0 items-center justify-between gap-3",children:[(0,eb.jsx)(Zo,{title:"防火墙策略"}),(0,eb.jsxs)(eO.Button,{size:"sm",children:[(0,eb.jsx)(lY,{className:"size-4"}),"新增策略"]})]}),(0,eb.jsxs)("div",{className:"mb-3 grid shrink-0 grid-cols-1 items-end gap-3 sm:grid-cols-[minmax(12rem,1fr)_10rem_auto]",children:[(0,eb.jsxs)("label",{className:"grid gap-1",children:[(0,eb.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:"搜索"}),(0,eb.jsxs)("span",{className:"relative",children:[(0,eb.jsx)(vu,{className:"pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground"}),(0,eb.jsx)(eA,{value:e,onChange:e=>t(e.target.value),placeholder:"搜索策略...",className:"pl-8"})]})]}),(0,eb.jsxs)("label",{className:"grid gap-1",children:[(0,eb.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:"标签"}),(0,eb.jsxs)(gU,{value:n,onValueChange:r,children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{placeholder:"全部标签"})}),(0,eb.jsxs)(xS,{children:[(0,eb.jsx)(xC,{value:"all",children:"全部标签"}),Y6.map(e=>(0,eb.jsx)(xC,{value:e,children:e},e))]})]})]}),(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:"动作"}),(0,eb.jsxs)(hY,{type:"multiple",variant:"outline",value:s,onValueChange:function(e){e.includes("clear")?(t(""),r("all"),i({allow:!1,drop:!1,deny:!1}),l(1)):i({allow:e.includes("allow"),drop:e.includes("drop"),deny:e.includes("deny")})},children:[(0,eb.jsx)(hZ,{value:"allow",children:"允许"}),(0,eb.jsx)(hZ,{value:"drop",children:"丢弃"}),(0,eb.jsx)(hZ,{value:"deny",children:"拒绝"}),(0,eb.jsx)(hZ,{value:"clear",children:"全部"})]})]})]}),(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-x-auto",children:(0,eb.jsx)(WA,{rows:m,columns:c,rowId:"policyNumber",showHeader:!1,showToolbar:!1,rowHeight:40,className:"h-full min-h-0 rounded-lg shadow-none",labels:{noRows:"没有匹配的策略。",selectAllRows:"选择当前页策略",selectRow:e=>`选择第 ${e+1} 条策略`,resizeColumn:"调整列宽",sortAsc:"升序",sortDesc:"降序",sortClear:"取消排序",copyCell:"复制单元格",copied:"已复制"}})}),(0,eb.jsx)(Zs,{page:f,totalPages:u,onPageChange:function(e){l(Math.min(u,Math.max(1,e)))}})]})}function Zs({page:e,totalPages:t,onPageChange:n}){let r=ew.useMemo(()=>t<=3?Array.from({length:t},(e,t)=>t+1):e<=2?[1,2,3]:e>=t-1?[t-2,t-1,t]:[e-1,e,e+1],[e,t]),a=r[0]??1,i=r[r.length-1]??t;function o(e,t){e.preventDefault(),n(t)}return(0,eb.jsx)(Y9,{className:"mt-3 shrink-0",children:(0,eb.jsxs)(Ze,{className:"gap-1 sm:gap-2",children:[(0,eb.jsx)(Zt,{children:(0,eb.jsx)(Zr,{href:"#",previousLabel:"上一页","aria-disabled":1===e,className:(0,ez.cn)(1===e&&"pointer-events-none opacity-40"),onClick:t=>o(t,e-1)})}),a>1?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(Zt,{children:(0,eb.jsx)(Zn,{href:"#",size:"icon",onClick:e=>o(e,1),children:"1"})}),a>2?(0,eb.jsx)(Zt,{children:(0,eb.jsx)(Zi,{moreLabel:"更多页"})}):null]}):null,r.map(t=>(0,eb.jsx)(Zt,{children:(0,eb.jsx)(Zn,{href:"#",size:"icon",isActive:e===t,onClick:e=>o(e,t),children:t})},t)),i<t?(0,eb.jsxs)(eb.Fragment,{children:[i<t-1?(0,eb.jsx)(Zt,{children:(0,eb.jsx)(Zi,{moreLabel:"更多页"})}):null,(0,eb.jsx)(Zt,{children:(0,eb.jsx)(Zn,{href:"#",size:"icon",onClick:e=>o(e,t),children:t})})]}):null,(0,eb.jsx)(Zt,{children:(0,eb.jsx)(Za,{href:"#",nextLabel:"下一页","aria-disabled":e===t,className:(0,ez.cn)(e===t&&"pointer-events-none opacity-40"),onClick:t=>o(t,e+1)})})]})})}function Zc({items:e,variant:t}){return(0,eb.jsx)("div",{className:"flex min-w-48 flex-wrap gap-1",children:e.map(e=>(0,eb.jsx)(Vp,{variant:t,children:e},e))})}function Zd({zone:e}){return(0,eb.jsx)(Vp,{variant:"Trust"===e?"secondary":"outline",children:e})}function Zu({action:e}){return(0,eb.jsx)(Vp,{variant:"allow"===e?"default":"destructive",children:{allow:"允许",drop:"丢弃",deny:"拒绝"}[e]})}function Zf({className:e,...t}){return(0,eb.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:(0,eb.jsx)("table",{"data-slot":"table",className:(0,ez.cn)("w-full caption-bottom text-sm",e),...t})})}function Zm({className:e,...t}){return(0,eb.jsx)("thead",{"data-slot":"table-header",className:(0,ez.cn)("[&_tr]:border-b",e),...t})}function Zh({className:e,...t}){return(0,eb.jsx)("tbody",{"data-slot":"table-body",className:(0,ez.cn)("[&_tr:last-child]:border-0",e),...t})}function Zp({className:e,...t}){return(0,eb.jsx)("tr",{"data-slot":"table-row",className:(0,ez.cn)("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",e),...t})}function Zg({className:e,...t}){return(0,eb.jsx)("th",{"data-slot":"table-head",className:(0,ez.cn)("h-9 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-0.5",e),...t})}function Zx({className:e,...t}){return(0,eb.jsx)("td",{"data-slot":"table-cell",className:(0,ez.cn)("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-0.5",e),...t})}function Zv({title:e}){return(0,eb.jsx)("h2",{className:"h-7 text-sm font-semibold tracking-normal",children:e})}function Zb({title:e,headers:t,rows:n}){return(0,eb.jsxs)("div",{className:"flex h-full min-h-0 flex-col p-3",children:[(0,eb.jsx)(Zv,{title:e}),(0,eb.jsx)("div",{className:"mt-3 min-h-0 flex-1 overflow-auto",children:(0,eb.jsxs)(Zf,{children:[(0,eb.jsx)(Zm,{children:(0,eb.jsx)(Zp,{children:t.map(e=>(0,eb.jsx)(Zg,{children:e},e))})}),(0,eb.jsx)(Zh,{children:n.map(e=>(0,eb.jsx)(Zp,{children:e.map((e,t)=>(0,eb.jsx)(Zx,{className:0===t?"font-medium":"text-muted-foreground",children:e},`${e}-${t}`))},e.join("-")))})]})})]})}function Zy(){return(0,eb.jsxs)("div",{className:"grid h-full min-h-0 content-start gap-3 p-3",children:[(0,eb.jsx)(Zv,{title:"策略申请"}),(0,eb.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,eb.jsx)(eA,{placeholder:"策略名称"}),(0,eb.jsx)(eA,{placeholder:"负责人"}),(0,eb.jsx)(eA,{placeholder:"源 CIDR"}),(0,eb.jsx)(eA,{placeholder:"目标 CIDR"})]}),(0,eb.jsx)("textarea",{placeholder:"用途",className:"min-h-32 resize-none rounded-lg border border-input bg-transparent px-2.5 py-2 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50"}),(0,eb.jsx)("div",{children:(0,eb.jsxs)(eO.Button,{size:"sm",children:[(0,eb.jsx)(lY,{className:"size-4"}),"提交申请"]})})]})}function Zw(){return(0,eb.jsxs)(XJ,{defaultValue:"policies",className:"vtl-firewall-workspace flex h-full min-h-0 flex-col",children:[(0,eb.jsx)("div",{className:"shrink-0 overflow-x-auto px-3 pt-3 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:(0,eb.jsxs)(X8,{className:"h-8 w-max min-w-full",children:[(0,eb.jsx)(X7,{value:"policies",children:"防火墙策略"}),(0,eb.jsx)(X7,{value:"ip-addresses",children:"IP 地址"}),(0,eb.jsx)(X7,{value:"renewals",children:"续期"}),(0,eb.jsx)(X7,{value:"policy-request",children:"策略申请"}),(0,eb.jsx)(X7,{value:"user-settings",children:"用户设置"})]})}),(0,eb.jsx)(X9,{value:"policies",className:"mt-3 min-h-0 flex-1 border-t",children:(0,eb.jsx)(Zl,{})}),(0,eb.jsx)(X9,{value:"ip-addresses",className:"mt-3 min-h-0 flex-1 border-t",children:(0,eb.jsx)(Zb,{title:"IP 地址",headers:["地址","名称","区域","策略"],rows:Y8})}),(0,eb.jsx)(X9,{value:"renewals",className:"mt-3 min-h-0 flex-1 border-t",children:(0,eb.jsx)(Zb,{title:"续期",headers:["策略","续期时间","负责人"],rows:Y7})}),(0,eb.jsx)(X9,{value:"policy-request",className:"mt-3 min-h-0 flex-1 border-t",children:(0,eb.jsx)(Zy,{})}),(0,eb.jsx)(X9,{value:"user-settings",className:"mt-3 min-h-0 flex-1 border-t",children:(0,eb.jsx)(Zb,{title:"用户设置",headers:["设置","值"],rows:[["默认区域","Trust"],["审核提醒","14 天"],["申请审批","安全负责人"],["策略导出","已开启"]]})})]})}function Zj(e){return e.map(e=>{var t;return{id:e.id,name:e.name,path:e.path,kind:"folder"===(t=e.kind)?"folder":"image"===t?"image":"archive"===t?"archive":"text"===t?"text":"code"===t?"code":"executable"===t?"config":"unknown",hasChildren:"folder"===e.kind,readonly:e.readonly,disabled:e.disabled}})}async function Zk(e,t){let n=t.machineId||"local";return Zj((await fc(n,e.path)).items)}function ZN({className:e,onOpenFile:t}){let[n,r]=ew.useState([]),[a,i]=ew.useState(!1),[o,l]=ew.useState(0),s=ew.useCallback(async()=>{i(!0);try{let e=await fs();r(e.roots.map(e=>({id:e.id,machineId:e.machineId,name:e.name,path:e.path,platform:e.platform,children:Zj(e.children)}))),l(e=>e+1)}catch{r([]),l(e=>e+1)}finally{i(!1)}},[]);return ew.useEffect(()=>{s()},[s]),ew.useEffect(()=>{function e(){s()}return window.addEventListener("vantaloom:file-system-changed",e),()=>window.removeEventListener("vantaloom:file-system-changed",e)},[s]),(0,eb.jsx)(U2,{className:e,compact:!0,openFilesOnSingleClick:!1,allowCreateFile:!1,allowCreateFolder:!1,allowRename:!1,allowDelete:!1,allowDragAndDrop:!1,allowBoxSelect:!1,defaultRoots:n,defaultExpandedIds:n.map(e=>e.id),loadingIds:a?n.map(e=>e.id):[],labels:{title:"Explorer",refresh:"刷新",collapseAll:"折叠",empty:"没有文件",noResults:"没有匹配文件",loading:"读取中..."},onLoadChildren:Zk,onOpenNode:(e,n)=>{"folder"!==e.kind&&t?.({machineId:n.machineId||"local",path:e.path})},onRefresh:()=>{s()}},o)}function ZS({open:e,onOpenChange:t,onSelectFile:n}){return(0,eb.jsx)(dX,{open:e,onOpenChange:t,children:(0,eb.jsxs)(fU,{className:"h-[min(42rem,calc(100svh-2rem))] max-w-2xl gap-0 overflow-hidden p-0",children:[(0,eb.jsx)(fK,{className:"sr-only",children:"选择文件"}),(0,eb.jsx)(fG,{className:"sr-only",children:"选择本机可访问文件。"}),(0,eb.jsx)(ZN,{className:"size-full max-w-none rounded-none border-0",onOpenFile:e=>{n(e),t(!1)}})]})})}function ZC(){let e=ew.useRef(null),[t,n]=ew.useState({width:0,height:0});return ew.useLayoutEffect(()=>{let t=e.current;if(!t)return;function r(){let e=t.getBoundingClientRect();n({width:e.width,height:e.height})}r();let a=new ResizeObserver(r);return a.observe(t),()=>a.disconnect()},[]),[e,t]}let ZM=(0,ek.default)("shield-off",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]);function ZE({open:e,placement:t="viewport",movePermissionGranted:n,onOpenChange:r,onAdd:a,onMovePermissionGrantedChange:i}){let o=[{key:"move-permission",label:n?"取消放行权限":"放行权限",icon:n?(0,eb.jsx)(kB,{className:"size-4"}):(0,eb.jsx)(ZM,{className:"size-4"}),pressed:n,onClick:()=>i(!n)},{key:"add",label:"新建文件窗口",icon:(0,eb.jsx)(lY,{className:"size-4"}),pressed:void 0,onClick:a}];return(0,eb.jsx)("div",{className:(0,ez.cn)("right-5 z-50","viewport"===t?"fixed bottom-5 max-md:bottom-20":"absolute bottom-5"),children:(0,eb.jsxs)("div",{className:"relative size-8",children:[o.map((t,n)=>(0,eb.jsx)(eO.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.label,"aria-pressed":t.pressed,title:t.label,onClick:t.onClick,className:(0,ez.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[opacity,transform] duration-150 ease-out",e?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0",t.pressed&&"border-foreground bg-foreground text-background hover:bg-foreground/90 hover:text-background"),style:{transform:e?`translateY(-${(n+1)*42}px)`:void 0},children:t.icon},t.key)),(0,eb.jsx)(eO.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":"文件窗口操作","aria-expanded":e,onClick:()=>r(!e),className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,eb.jsx)(lG,{className:(0,ez.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}let ZI=[];function ZP(e,t){return`${e} / ${t.replace(/\\/g," / ").replace(/\//g," / ")}`}function ZO(e,t){for(let n of e){if(n.id===t)return n;let e=n.children?ZO(n.children,t):void 0;if(e)return e}}function Zz(e,t){return e.replace(/\\/g,"/").toLowerCase()===t.replace(/\\/g,"/").toLowerCase()}function ZA(e,t){let n=e.replace(/\\/g,"/").replace(/\/+/g,"/");return"windows"===t?n.toLowerCase():n}function ZT(e){return e.map(e=>({...e,children:e.children?ZT(e.children):void 0}))}let ZR=(0,ek.default)("move-right",[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]]),ZD=(0,ek.default)("octagon-alert",[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]]),Z_=(0,ek.default)("clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]),ZL={title:"Clipboard",empty:"No clips",dragHandle:"Drag clip"};function Z$({items:e,expanded:t,defaultExpanded:n=!1,expansionDirection:r="down-left",title:a,labels:i,maxCollapsedItems:o=10,maxExpandedHeight:l=360,acceptExternalDrops:s=!1,removeOnExternalDrop:c=!1,className:d,onExpandedChange:u,onItemDragStart:f,onItemDragEnd:m,onItemDuplicate:h,onItemsRemove:p,onItemsReorder:g,onExternalDrop:x,onMouseEnter:v,onMouseLeave:b,...y}){let w={...ZL,...i},[j,k]=ew.useState(n),[N,S]=ew.useState(),[C,M]=ew.useState(),[E,I]=ew.useState(n),[P,O]=ew.useState(),[z,A]=ew.useState({canScrollDown:!1,canScrollUp:!1}),[T,R]=ew.useState(!1),[D,_]=ew.useState(!1),L=ew.useRef(0),$=ew.useRef(void 0),F=ew.useRef(!1),B=ew.useRef(null),V=ew.useRef(null),H=void 0!==t,U=(H?t:j)||void 0!==N,q=Math.min(o,10),W=U?e:e.slice(0,q),K=E?C:void 0,G=44*W.length+18,X=Math.min(G,l),Y=U&&G>X,Z=0===e.length?"h-24":U?`${X}px`:"h-28",J=U&&Y?14:0;ew.useEffect(()=>{if(!U){I(!1),A({canScrollDown:!1,canScrollUp:!1});return}I(!1),window.requestAnimationFrame(()=>{V.current&&(V.current.scrollTop=0)}),A({canScrollUp:!1,canScrollDown:G>X});let e=window.setTimeout(()=>{I(!0)},260);return()=>window.clearTimeout(e)},[G,X,U]),ew.useEffect(()=>()=>{void 0!==$.current&&window.clearTimeout($.current)},[]);let Q=ew.useCallback(e=>{H||k(e),u?.(e)},[H,u]);function ee(e,t=0){let n=e.currentTarget.getBoundingClientRect();return e.clientX>=n.left-t&&e.clientX<=n.right+t&&e.clientY>=n.top-t&&e.clientY<=n.bottom+t}function et(e){if(!U||!V.current)return 0;let t=Array.from(V.current.querySelectorAll('[data-slot="clipboard-stack-card"]'));if(0===t.length)return 0;for(let[n,r]of t.entries()){let t=r.getBoundingClientRect();if(e.clientY<t.top+t.height/2)return n}return t.length}function en(e){return void 0!==N||Array.from(e.dataTransfer.types).includes("application/vnd.vantaloom.clip-id")}return ew.useEffect(()=>{if(0===e.length||U)return;let t=window.requestAnimationFrame(()=>{B.current?.matches(":hover")&&(void 0!==$.current&&(window.clearTimeout($.current),$.current=void 0),R(!1),Q(!0))});return()=>window.cancelAnimationFrame(t)},[e.length,Q,U]),ew.useEffect(()=>{if(!U||!Y||!K||!V.current)return;let e=W.findIndex(e=>e.id===K);if(e<0)return;let t=V.current,n=44*e-8,r=44*e+(W[e]?.expandedHeight??220)+12,a=t.scrollTop,i=a+t.clientHeight;n<a?t.scrollTo({top:Math.max(0,n),behavior:"smooth"}):r>i&&t.scrollTo({top:r-t.clientHeight,behavior:"smooth"})},[K,Y,W,U]),(0,eb.jsxs)("div",{ref:B,"data-slot":"clipboard-stack","data-expanded":U,"data-closing":T,"data-external-dragging":D,"data-expansion-direction":r,className:(0,ez.cn)("group/clipboard relative w-80 max-w-full overflow-visible py-2",d),onMouseEnter:function(e){v?.(e),ee(e)&&(void 0!==$.current&&(window.clearTimeout($.current),$.current=void 0),R(!1),Q(!0))},onMouseMove:function(e){if(!U){ee(e,12)&&(void 0!==$.current&&(window.clearTimeout($.current),$.current=void 0),R(!1),Q(!0));return}!U||N||ee(e,12)||(M(void 0),O(void 0),Q(!1),R(!0),void 0!==$.current&&window.clearTimeout($.current),$.current=window.setTimeout(()=>{R(!1),$.current=void 0},320))},onMouseLeave:function(e){b?.(e),N||(M(void 0),O(void 0),R(!0),Q(!1),void 0!==$.current&&window.clearTimeout($.current),$.current=window.setTimeout(()=>{R(!1),$.current=void 0},320))},onDragEnter:function(e){!s||en(e)||(L.current+=1,_(!0),R(!1))},onDragLeave:function(e){!s||en(e)||(L.current=Math.max(0,L.current-1),0===L.current&&(_(!1),O(void 0)))},onDragOver:function(e){!s||en(e)||(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="copy",_(!0),U?O(et(e)):O(0))},onDrop:function(t){if(!s||en(t))return;t.preventDefault(),t.stopPropagation();let n=P??et(t);L.current=0,_(!1),O(void 0),x?.({insertIndex:n,items:e,nativeEvent:t})},...y,children:[(0,eb.jsxs)("div",{"data-slot":"clipboard-stack-header",className:(0,ez.cn)("mb-2 flex h-8 items-center gap-2 px-1 text-sm font-medium text-foreground transition-[opacity,transform] duration-200","down-left"===r&&"justify-end",U?"opacity-100":"translate-y-1 opacity-0"),children:[(0,eb.jsx)("span",{className:"inline-flex size-6 items-center justify-center rounded-lg border bg-background text-muted-foreground",children:(0,eb.jsx)(Z_,{className:"size-3.5"})}),(0,eb.jsx)("span",{children:a??w.title}),(0,eb.jsx)("span",{className:"ml-auto tabular-nums text-muted-foreground",children:e.length})]}),(0,eb.jsxs)("div",{"data-slot":"clipboard-stack-list",className:(0,ez.cn)("relative transition-[height] duration-300 ease-[cubic-bezier(.2,.8,.2,1)]"),style:{height:Z},children:[e.length>0&&"down-left"===r?(0,eb.jsx)("span",{"data-slot":"clipboard-stack-pivot","aria-hidden":"true",className:(0,ez.cn)("pointer-events-none absolute top-3 right-[34px] z-50 size-2.5 rounded-full bg-foreground shadow-sm transition-[opacity,transform] duration-200 dark:bg-background",U?"scale-75 opacity-0":"opacity-100")}):null,s&&D?(0,eb.jsxs)("span",{"data-slot":"clipboard-stack-external-ghost","aria-hidden":"true",className:(0,ez.cn)("pointer-events-none absolute right-0 z-[70] h-14 w-[88%] rounded-xl border bg-background shadow-md shadow-black/10","clipboard-stack-external-ghost"),children:[(0,eb.jsx)("span",{className:"absolute top-3 right-[34px] size-2 rounded-full bg-foreground dark:bg-background"}),(0,eb.jsx)("span",{className:"absolute top-4 left-3 h-2 w-24 rounded-full bg-foreground/18"}),(0,eb.jsx)("span",{className:"absolute top-8 left-3 h-1.5 w-14 rounded-full bg-foreground/10"})]}):null,0===e.length?(0,eb.jsx)("div",{className:"flex h-24 items-center justify-center rounded-xl border border-dashed bg-muted/35 text-sm text-muted-foreground",children:w.empty}):(0,eb.jsxs)("div",{"data-slot":"clipboard-stack-scroll-frame",className:"relative h-full",children:[(0,eb.jsx)("div",{"data-slot":"clipboard-stack-scroll",ref:V,className:(0,ez.cn)("relative h-full overflow-x-visible",U&&Y?"clipboard-stack-scrollbar-hidden overflow-y-auto pt-2 pr-1 pb-3":"overflow-visible"),onScroll:e=>{let t=e.currentTarget;A({canScrollUp:t.scrollTop>1,canScrollDown:t.scrollTop+t.clientHeight<t.scrollHeight-1})},onDragOver:function(e){U&&N&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move")},onDrop:function(t){if(!U||!N||void 0===P)return;t.preventDefault(),t.stopPropagation(),F.current=!0;let n=e.findIndex(e=>e.id===N),r=e[n];if(n<0||!r)return;let a=e.filter(e=>e.id!==N),i=Math.max(0,Math.min(P>n?P-1:P,a.length));a.splice(i,0,r),O(void 0),M(void 0),i!==n&&g?.(a,{item:r,fromIndex:n,toIndex:i,items:a})},children:(0,eb.jsxs)("div",{"data-slot":"clipboard-stack-scroll-content",className:"relative",style:{width:U&&Y?`calc(100% - ${J}px)`:void 0,marginLeft:U&&Y?`${J}px`:void 0,height:U&&Y?G+28:U?G:"100%"},children:[void 0!==P?(0,eb.jsxs)("span",{"data-slot":"clipboard-stack-insert-line","aria-hidden":"true",className:"pointer-events-none absolute right-0 left-0 z-[80] flex items-center",style:{top:44*P-2},children:[(0,eb.jsx)("span",{className:"h-px flex-1 bg-foreground/70"}),(0,eb.jsx)("span",{className:"mx-1 size-1.5 rounded-full bg-foreground"}),(0,eb.jsx)("span",{className:"h-px flex-1 bg-foreground/70"})]}):null,W.map((t,n)=>(0,eb.jsx)(ZF,{item:t,index:n,count:W.length,expanded:U,active:U&&t.id===K,top:U?44*n:void 0,expansionDirection:r,labels:w,onHover:()=>M(t.id),onDuplicate:()=>{let n=e.findIndex(e=>e.id===t.id);n<0||h?.(e,{item:t,index:n,items:e})},onDragOver:e=>{if(U&&N&&N!==t.id){let t=e.currentTarget.getBoundingClientRect();O(e.clientY<t.top+t.height/2?n:n+1)}},onDragStart:e=>{S(e.item.id),M(void 0),F.current=!1,f?.(e)},onDragEnd:t=>{let n=t.nativeEvent.dataTransfer.dropEffect,r=t.item.id,a=e.findIndex(e=>e.id===r),i=c&&!F.current&&"none"!==n&&a>=0;if(S(void 0),O(void 0),M(void 0),F.current?F.current=!1:Q(!1),i){let n=e.filter(e=>e.id!==r);p?.(n,{item:t.item,index:a,items:n})}m?.(t)}},t.id))]})}),Y&&z.canScrollUp?(0,eb.jsx)("span",{"data-slot":"clipboard-stack-scroll-mask-top","aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 top-0 z-[90] h-8 bg-gradient-to-b from-background to-transparent"}):null,Y&&z.canScrollDown?(0,eb.jsx)("span",{"data-slot":"clipboard-stack-scroll-mask-bottom","aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 bottom-0 z-[90] h-8 bg-gradient-to-t from-background to-transparent"}):null]})]})]})}function ZF({item:e,index:t,count:n,expanded:r,active:a,top:i,expansionDirection:o,labels:l,onHover:s,onDuplicate:c,onDragOver:d,onDragStart:u,onDragEnd:f}){let m=Math.min(t,9),h="down-left"===o?-(4.5*m):[-4,2,-1,4][m]??0,p=r?a?n+20:n-t:n+t;return(0,eb.jsx)("article",{"data-slot":"clipboard-stack-card",draggable:!e.disabled,"aria-disabled":e.disabled,className:(0,ez.cn)("absolute right-0 min-h-16 w-full cursor-grab select-none rounded-xl border bg-background p-2.5 text-foreground shadow-sm shadow-black/5 outline-none transition-[top,transform,opacity,box-shadow,border-color] duration-300 ease-[cubic-bezier(.2,.8,.2,1)] active:cursor-grabbing","hover:border-foreground/35 hover:shadow-md hover:shadow-black/10 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/40",r&&"min-h-0 overflow-hidden py-2 transition-[top,transform,max-height,opacity,box-shadow,border-color] duration-300",r&&!a&&"max-h-11",e.disabled&&"cursor-not-allowed opacity-50"),style:{top:r?i??44*t:"down-left"===o?0:9*m,zIndex:p,maxHeight:r&&a?e.expandedHeight??220:void 0,transformOrigin:"down-left"===o?"calc(100% - 34px) 14px":"100% 0",transform:r?a?"translate3d(-10px, -6px, 0) rotate(0deg)":"translate3d(0, 0, 0) rotate(0deg)":`translate3d(${"down-left"===o?0:4*m}px, 0, 0) rotate(${h}deg)`},tabIndex:e.disabled?-1:0,onMouseDown:function(t){1!==t.button||e.disabled||t.preventDefault()},onMouseEnter:s,onFocus:s,onAuxClick:function(t){1!==t.button||e.disabled||(t.preventDefault(),c?.())},onDragOver:d,onDragStart:function(t){for(let[n,r]of(t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setData("text/plain",e.title),t.dataTransfer.setData("application/vnd.vantaloom.clip-id",e.id),Object.entries(e.dragData??{})))t.dataTransfer.setData(n,r);u?.({item:e,nativeEvent:t})},onDragEnd:function(t){f?.({item:e,nativeEvent:t})},children:(0,eb.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[(0,eb.jsx)("div",{"data-slot":"clipboard-stack-card-media",className:"flex size-8 shrink-0 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:e.icon??(0,eb.jsx)(Z_,{className:"size-4"})}),(0,eb.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,eb.jsx)("p",{className:"truncate text-sm font-medium",children:e.title}),e.meta?(0,eb.jsx)("span",{className:"ml-auto shrink-0 text-xs tabular-nums text-muted-foreground",children:e.meta}):null]}),e.description?(0,eb.jsx)("p",{className:(0,ez.cn)("mt-0.5 text-xs leading-5 text-muted-foreground transition-[max-height,opacity,transform] duration-200",a?"max-h-40 translate-y-0 opacity-100":"max-h-0 -translate-y-1 overflow-hidden opacity-0"),children:e.description}):null,e.content?(0,eb.jsx)("div",{className:(0,ez.cn)("mt-2 text-xs text-muted-foreground transition-[max-height,opacity,transform] duration-200",a?"max-h-80 translate-y-0 opacity-100":"max-h-0 -translate-y-1 overflow-hidden opacity-0"),children:e.content}):null]}),(0,eb.jsx)("span",{"aria-label":l.dragHandle,className:"mt-1 inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground",children:(0,eb.jsx)(fX,{className:"size-3.5"})})]})})}function ZB({transfers:e}){let t=e.slice(0,10);if(0===t.length)return null;let n=t.map(e=>{var t,n,r;let a,i,o;return{id:e.id,title:(a="copy"===(t=e).mode?"复制":"移动",i=t.sources.length,o=t.sources[0],`${a} ${i>1?`${i} 项`:ZH(o?.path??"")}`),description:(n=e).message?n.message:`${n.sources[0]?.machineId??"local"} -> ${n.target.machineId}`,meta:function(e){switch(e.status){case"completed":return"完成";case"failed":return"失败";case"queued":return"排队";default:return`${Math.round(e.progress?.percent??0)}%`}}(e),icon:"completed"===(r=e).status?(0,eb.jsx)(eI,{className:"size-4"}):"failed"===r.status?(0,eb.jsx)(ZD,{className:"size-4"}):"running"===r.status?(0,eb.jsx)(eM,{className:"size-4 animate-spin"}):"copy"===r.mode?(0,eb.jsx)(lV,{className:"size-4"}):(0,eb.jsx)(ZR,{className:"size-4"}),expandedHeight:132,content:(0,eb.jsx)(ZV,{transfer:e})}});return(0,eb.jsx)("div",{className:"pointer-events-auto fixed top-4 right-4 z-50 w-80 max-w-[calc(100vw-2rem)] max-md:left-4 max-md:right-auto max-md:w-auto max-md:max-w-[16rem]",children:(0,eb.jsx)(Z$,{items:n,title:"传输",labels:{empty:"暂无传输",dragHandle:"传输任务"},expansionDirection:"down-left",maxExpandedHeight:420})})}function ZV({transfer:e}){let t=Math.max(0,Math.min(100,e.progress?.percent??0));return(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)("div",{className:"h-1.5 overflow-hidden rounded-full bg-border",children:(0,eb.jsx)("div",{className:"h-full rounded-full bg-foreground transition-[width] duration-300",style:{width:`${t}%`}})}),(0,eb.jsxs)("div",{className:"grid gap-1 tabular-nums",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[(0,eb.jsx)("span",{className:"truncate",children:ZH(e.target.path)}),(0,eb.jsxs)("span",{children:[Math.round(t),"%"]})]}),(0,eb.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-2 text-muted-foreground",children:[(0,eb.jsxs)("span",{className:"truncate",children:[ZU(e.progress.bytesDone)," /"," ",ZU(e.progress.bytesTotal)]}),(0,eb.jsxs)("span",{children:[e.progress.entriesDone,"/",e.progress.entriesTotal]})]}),e.progress.currentPath?(0,eb.jsx)("div",{className:"truncate text-muted-foreground",children:ZH(e.progress.currentPath)}):null]})]})}function ZH(e){return e.split(/[\\/]+/).filter(Boolean).at(-1)??e}function ZU(e){if(!e)return"0 B";let t=["B","KB","MB","GB","TB"],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n>=10||0===r?Math.round(n):n.toFixed(1)} ${t[r]}`}let Zq=(0,ek.default)("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);function ZW({windowLayout:e,roots:t,active:n,zIndex:r,boardSize:a,onActivate:i,onClose:o,onMinimize:l,onWindowChange:s,onNavigate:c,onRootsChange:d,onCreateFolder:u,onRenameItem:f,onDeleteItems:m,onMoveItems:h}){return(0,eb.jsxs)("section",{className:(0,ez.cn)("absolute overflow-hidden rounded-xl border bg-card shadow-lg transition-[box-shadow,border-color] duration-150","vtl-file-manager-window",n&&"border-foreground shadow-xl"),style:{left:e.x,top:e.y,width:e.w,height:e.h,zIndex:r},onPointerDown:i,children:[(0,eb.jsxs)("div",{className:"grid h-9 cursor-grab grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 border-b bg-muted/35 px-2 active:cursor-grabbing",onPointerDown:function(t){t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),i();let n=t.clientX,r=t.clientY;function a(t){let a=Math.max(0,e.x+t.clientX-n),i=Math.max(0,e.y+t.clientY-r);s({...e,x:a,y:i})}window.addEventListener("pointermove",a),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",e)})},children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1",children:[(0,eb.jsx)(eO.Button,{type:"button",size:"icon-sm",variant:"ghost","aria-label":"关闭窗口",onPointerDown:e=>e.stopPropagation(),onClick:o,children:(0,eb.jsx)(fV.XIcon,{})}),(0,eb.jsx)(eO.Button,{type:"button",size:"icon-sm",variant:"ghost","aria-label":"缩小到剪切板",onPointerDown:e=>e.stopPropagation(),onClick:l,children:(0,eb.jsx)(Zq,{})})]}),(0,eb.jsx)("div",{className:"truncate text-center ui-text-control",children:e.title}),(0,eb.jsx)("div",{className:"w-14"})]}),(0,eb.jsx)(jU,{roots:t,variant:"full",currentRootId:e.rootId,currentPath:e.path,draggableItems:!0,onNavigate:c,onRootsChange:e=>d(e),onCreateFolder:u,onRenameItem:f,onDeleteItems:m,onItemDrop:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>h({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r}),labels:{title:"文件管理",search:"搜索文件",newFolder:"新建",upload:"上传",refresh:"刷新",sort:"排序",view:"视图"},className:"vtl-file-window-explorer min-h-0 rounded-none border-0 shadow-none",contentClassName:"min-h-0",style:{height:"calc(100% - 2.25rem)",minHeight:0}}),(0,eb.jsx)("button",{type:"button","aria-label":"调整窗口大小",className:"absolute right-0 bottom-0 size-5 cursor-nwse-resize rounded-tl-md border-t border-l bg-background/80",onPointerDown:function(t){t.preventDefault(),t.stopPropagation(),t.currentTarget.setPointerCapture(t.pointerId),i();let n=t.clientX,r=t.clientY;function o(t){let i=Math.max(420,Math.min(Math.max(420,a.width-e.x),e.w+t.clientX-n)),o=Math.max(320,e.h+t.clientY-r);s({...e,w:i,h:o})}window.addEventListener("pointermove",o),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",e)})}})]})}function ZK({clipboardItems:e=[],onClipboardItemsChange:t,className:n,minBoardHeight:r=520,actionsPlacement:a="container"}){let[i,o]=ZC(),[l,s]=ew.useState([]),[c,d]=ew.useState(ZI),[u,f]=ew.useState(ZI[0]?.id),[m,h]=ew.useState([]),[p,g]=ew.useState(!1),[x,v]=ew.useState(!1),[b,y]=ew.useState(),w=ew.useRef(ZI.length),j=ew.useRef(!1),k=ew.useRef(new Set),N=ew.useCallback(async(e,t,n)=>{let r=await fc(e,n);s(n=>{var a;return a={...r,root:{...r.root,id:t,machineId:e}},n.map(e=>e.id!==a.root.id?e:Zz(e.path,a.path)?{...e,children:ZT(a.items)}:{...e,children:function(e,t,n,r,a){let i=function(e,t,n){let r=ZA(e,n),a=ZA(t,n);if(r===a)return[];let i=r.endsWith("/")?r:`${r}/`;return a.startsWith(i)?a.slice(i.length).split("/").filter(Boolean):[]}(t,n,r);if(0===i.length)return ZT(a);let o="windows"===r?"\\":"/";return function e(t,n,r){let l=i[r];if(!l)return ZT(a);let s=n===o?`${o}${l}`:`${n.replace(/[\\/]+$/,"")}${o}${l}`,c=t.findIndex(e=>Zz(e.path,s)),d=t[c],u={...d??{id:`synthetic-${s}`,name:l,kind:"folder",path:s,children:[]},kind:"folder",children:e(d?.children??[],s,r+1)};if(c<0)return[...t,u];let f=[...t];return f[c]=u,f}(e,t,0)}(e.children,e.path,a.path,e.platform,a.items)})})},[]),S=ew.useCallback(async()=>{let e=ZY((await fg()).transfers);return h(e),e},[]),C=ew.useCallback(e=>{h(t=>ZY([e,...t.filter(t=>t.id!==e.id)]))},[]),M=ew.useCallback(e=>{fp({mode:"move",sources:e.sources.map(e=>({machineId:e.machineId,path:e.path})),target:{machineId:e.target.machineId,path:e.target.path}}).then(C).catch(()=>{})},[C]),E=ew.useCallback(()=>{for(let e of c)N(e.machineId,e.rootId,e.path)},[N,c]);function I(e,t){d(n=>n.map(n=>n.id===e?t(n):n))}function P(e){let t=l[0];if(!t&&!e?.rootId)return;w.current+=1;let n=`files-window-${w.current}`,r=i.current?.getBoundingClientRect(),a=r?.width??o.width,s=r?.height??o.height,c=e?.w??680,u=e?.h??460,m=Math.max(0,(a-c)/2),h=Math.max(0,(s-u)/2),p={id:n,title:e?.title??ZP(t?.name??"local",t?.path??""),machineId:e?.machineId??t?.machineId??"local",rootId:e?.rootId??t?.id??"local",path:e?.path??t?.path??"",x:e?.x??m+12*w.current,y:e?.y??h+12*w.current,w:c,h:u};d(e=>[...e,p]),f(n),N(p.machineId,p.rootId,p.path)}ew.useEffect(()=>{let e=!0;return(async function(){let t=await fs();if(e&&(s(t.roots),!j.current&&t.roots[0])){j.current=!0;let e=function(e,t=0){return{id:`files-${e.id.replace(/[^a-z0-9_-]/gi,"-")}-${t}`,title:ZP(e.name,e.path),machineId:e.machineId,rootId:e.id,path:e.path,x:28+24*t,y:28+24*t,w:720,h:480}}(t.roots[0]);d([e]),f(e.id),N(e.machineId,e.rootId,e.path)}})().catch(()=>{}),S().catch(()=>{}),()=>{e=!1}},[N,S]),ew.useEffect(()=>{if(!m.some(e=>"pending"===e.status||"running"===e.status||"queued"===e.status))return;let e=window.setInterval(async()=>{let e=(await S().catch(()=>m)).filter(e=>"completed"===e.status&&!k.current.has(e.id));if(e.length>0){for(let t of e)k.current.add(t.id);E()}},1e3);return()=>window.clearInterval(e)},[E,S,m]);let O=sv(),z=c.find(e=>e.id===u);function A(e){return{onNavigate:({rootId:t,path:n})=>{let r=l.find(e=>e.id===t),a=r?.machineId??e.machineId;I(e.id,e=>({...e,machineId:a,rootId:t,path:n,title:ZP(r?.name??a,n)})),N(a,t,n)},onRootsChange:s,onCreateFolder:(t,n)=>{ff({machineId:e.machineId,path:t.path,name:n}).then(()=>N(e.machineId,e.rootId,e.path)).catch(()=>{})},onRenameItem:(t,n)=>{fm({machineId:e.machineId,path:t.path,name:n}).then(()=>N(e.machineId,e.rootId,e.path)).catch(()=>{})},onDeleteItems:t=>{fh({machineId:e.machineId,paths:t.map(e=>e.path)}).then(()=>N(e.machineId,e.rootId,e.path)).catch(()=>{})},onMoveItems:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>{let a=l.find(t=>t.id===e);if(!a)return;let i=t.flatMap(e=>{let t=ZO(a.children,e);return t?[{machineId:a.machineId,path:t.path,name:t.name}]:[]});if(0===i.length)return;let o={sources:i,target:{machineId:n.machineId,path:r.path,name:r.name}};x?M(o):y(o)}}}return O?(0,eb.jsxs)("div",{className:(0,ez.cn)("flex h-full min-h-0 w-full flex-col",n),children:[c.length>1?(0,eb.jsx)("div",{className:"flex shrink-0 items-center gap-1 overflow-x-auto border-b px-2 py-1.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:c.map(e=>(0,eb.jsx)("button",{type:"button",className:(0,ez.cn)("shrink-0 rounded-md px-2.5 py-1 text-xs transition-colors",e.id===u?"bg-foreground text-background":"text-muted-foreground hover:bg-muted"),onClick:()=>f(e.id),children:e.title},e.id))}):null,(0,eb.jsx)("div",{className:"min-h-0 flex-1",children:z?(0,eb.jsx)(ZG,{windowLayout:z,roots:l,...A(z)}):(0,eb.jsx)("div",{className:"grid h-full place-items-center text-sm text-muted-foreground",children:"暂无打开的文件窗口"})}),(0,eb.jsx)(ZB,{transfers:m}),(0,eb.jsx)(ZE,{open:p,placement:a,movePermissionGranted:x,onOpenChange:g,onMovePermissionGrantedChange:v,onAdd:()=>{g(!1),P()}}),(0,eb.jsx)(ZX,{move:b,onCancel:()=>y(void 0),onConfirm:e=>{y(void 0),M(e)}})]}):(0,eb.jsxs)("div",{ref:i,className:(0,ez.cn)("relative h-full min-h-0 w-full overflow-hidden rounded-[inherit]",n),onDragOver:e=>{Array.from(e.dataTransfer.types).includes("application/vnd.vantaloom.file-window")&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},onDrop:function(e){let t=e.dataTransfer.getData("application/vnd.vantaloom.file-window");if(t)try{let n=JSON.parse(t),r=i.current?.getBoundingClientRect();e.preventDefault(),e.stopPropagation(),P({...n,x:r?e.clientX-r.left-160:n.x,y:r?e.clientY-r.top-24:n.y})}catch{return}},children:[(0,eb.jsx)("div",{className:"relative h-full min-h-0",style:{minHeight:Math.max(r,o.height-48)},children:c.map((n,r)=>(0,eb.jsx)(ZW,{windowLayout:n,roots:l,active:u===n.id,zIndex:20+r+20*(u===n.id),boardSize:o,onActivate:()=>f(n.id),onClose:()=>d(e=>e.filter(e=>e.id!==n.id)),onMinimize:()=>{t?.([{id:`clip-${n.id}`,title:n.title,description:"文件管理窗口",meta:`${Math.round(n.w)}x${Math.round(n.h)}`,payloads:{"application/vnd.vantaloom.file-window":{...n}},dragData:{"application/vnd.vantaloom.clip-kind":"file-window","application/vnd.vantaloom.file-window":JSON.stringify(n)}},...e.filter(e=>e.id!==`clip-${n.id}`)]),d(e=>e.filter(e=>e.id!==n.id))},onWindowChange:e=>I(n.id,()=>e),...A(n),onNavigate:({rootId:e,path:t})=>{let r=l.find(t=>t.id===e),a=r?.machineId??n.machineId;I(n.id,n=>({...n,machineId:a,rootId:e,path:t,title:ZP(r?.name??a,t)})),N(a,e,t)},onRootsChange:s,onCreateFolder:(e,t)=>{ff({machineId:n.machineId,path:e.path,name:t}).then(()=>N(n.machineId,n.rootId,n.path)).catch(()=>{})},onRenameItem:(e,t)=>{fm({machineId:n.machineId,path:e.path,name:t}).then(()=>N(n.machineId,n.rootId,n.path)).catch(()=>{})},onDeleteItems:e=>{fh({machineId:n.machineId,paths:e.map(e=>e.path)}).then(()=>N(n.machineId,n.rootId,n.path)).catch(()=>{})},onMoveItems:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>{let a=l.find(t=>t.id===e);if(!a)return;let i=t.flatMap(e=>{let t=ZO(a.children,e);return t?[{machineId:a.machineId,path:t.path,name:t.name}]:[]});if(0===i.length)return;let o={sources:i,target:{machineId:n.machineId,path:r.path,name:r.name}};x?M(o):y(o)}},n.id))}),(0,eb.jsx)(ZB,{transfers:m}),(0,eb.jsx)(ZE,{open:p,placement:a,movePermissionGranted:x,onOpenChange:g,onMovePermissionGrantedChange:v,onAdd:()=>{g(!1),P()}}),(0,eb.jsx)(ZX,{move:b,onCancel:()=>y(void 0),onConfirm:e=>{y(void 0),M(e)}})]})}function ZG({windowLayout:e,roots:t,onNavigate:n,onRootsChange:r,onCreateFolder:a,onRenameItem:i,onDeleteItems:o,onMoveItems:l}){return(0,eb.jsx)(jU,{roots:t,variant:"full",currentRootId:e.rootId,currentPath:e.path,onNavigate:n,onRootsChange:e=>r(e),onCreateFolder:a,onRenameItem:i,onDeleteItems:o,onItemDrop:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>l({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r}),labels:{title:"文件管理",search:"搜索文件",newFolder:"新建",upload:"上传",refresh:"刷新",sort:"排序",view:"视图"},className:"h-full min-h-0 rounded-none border-0 shadow-none",contentClassName:"min-h-0"})}function ZX({move:e,onCancel:t,onConfirm:n}){var r;let a=e?.sources??[],i=Math.max(0,a.length-4);return(0,eb.jsx)(ux,{open:void 0!==e,onOpenChange:e=>{e||t()},children:(0,eb.jsxs)(uR,{children:[(0,eb.jsxs)(uD,{children:[(0,eb.jsx)(uL,{children:"确认移动"}),(0,eb.jsx)(u$,{children:e?`将 ${1===(r=a).length?r[0]?ZZ(r[0]):"0 项":`${r.length} 项`} 移动到 ${ZZ(e.target)}`:""})]}),e?(0,eb.jsxs)("div",{className:"grid gap-2 rounded-lg border bg-muted/20 p-3 ui-text-body",children:[(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsx)("span",{className:"text-muted-foreground ui-text-kbd",children:"移动内容"}),(0,eb.jsxs)("div",{className:"grid gap-1",children:[a.slice(0,4).map(e=>(0,eb.jsx)("span",{className:"truncate",children:ZZ(e)},`${e.machineId}:${e.path}`)),i>0?(0,eb.jsxs)("span",{className:"text-muted-foreground",children:["另有 ",i," 项"]}):null]})]}),(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsx)("span",{className:"text-muted-foreground ui-text-kbd",children:"目标位置"}),(0,eb.jsx)("span",{className:"truncate",children:ZZ(e.target)})]})]}):null,(0,eb.jsxs)(u_,{children:[(0,eb.jsx)(uB,{children:"取消"}),(0,eb.jsx)(uF,{onClick:()=>{e&&n(e)},children:"确认移动"})]})]})})}function ZY(e){return e.slice(0,10)}function ZZ(e){let t=e.path.replace(/\\/g,"/");return`${e.machineId} / ${e.name||t}`}function ZJ({className:e}){return(0,eb.jsx)(ZK,{className:(0,ez.cn)("h-full min-h-0 w-full rounded-[inherit] border-0 shadow-none",e),minBoardHeight:360,actionsPlacement:"container"})}var ZQ=ew;function Z0(){return(Z0=Object.assign.bind()).apply(null,arguments)}var Z1=e=>{var{cx:t,cy:n,r,className:a}=e,i=(0,kq.clsx)("recharts-dot",a);return Nj(t)&&Nj(n)&&Nj(r)?ew.createElement("circle",Z0({},AK(e),Tv(e),{className:i,cx:t,cy:n,r:r})):null},Z2=["points"];function Z5(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z4(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Z5(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Z5(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Z3(){return(Z3=Object.assign.bind()).apply(null,arguments)}function Z6(e){var{option:t,dotProps:n,className:r}=e;if((0,ew.isValidElement)(t))return(0,ew.cloneElement)(t,n);if("function"==typeof t)return t(n);var a=(0,kq.clsx)(r,"boolean"!=typeof t?t.className:""),i=null!=n?n:{},{points:o}=i,l=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(i,Z2);return ew.createElement(Z1,Z3({},l,{className:a}))}function Z8(e){var{points:t,dot:n,className:r,dotClassName:a,dataKey:i,baseProps:o,needClip:l,clipPathId:s,zIndex:c=M2.scatter}=e;if(null==t||!n&&1!==t.length)return null;var d=Ro(n),u=null==n?null:(0,ew.isValidElement)(n)?AX(n.props):"object"!=typeof n||Array.isArray(n)?null:AX(n),f=t.map((e,r)=>{var l,s,c=Z4(Z4(Z4({r:3},o),u),{},{index:r,cx:null!=(l=e.x)?l:void 0,cy:null!=(s=e.y)?s:void 0,dataKey:i,value:e.value,payload:e.payload,points:t});return ew.createElement(Z6,{key:"dot-".concat(r),option:n,dotProps:c,className:a})}),m={};return l&&null!=s&&(m.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(s,")")),ew.createElement(LX,{zIndex:c},ew.createElement(AJ,Z3({className:r},m),f))}function Z7(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z9(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Z7(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Z7(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Je=e=>{var t,{point:n,childIndex:r,mainColor:a,activeDot:i,dataKey:o,clipPath:l}=e;if(!1===i||null==n.x||null==n.y)return null;var s=Z9(Z9(Z9({},{index:r,dataKey:o,cx:n.x,cy:n.y,r:4,fill:null!=a?a:"none",strokeWidth:2,stroke:"#fff",payload:n.payload,value:n.value}),AG(i)),Tv(i));return t=(0,ew.isValidElement)(i)?(0,ew.cloneElement)(i,s):"function"==typeof i?i(s):ew.createElement(Z1,s),ew.createElement(AJ,{className:"recharts-active-dot",clipPath:l},t)};function Jt(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:a,clipPath:i,zIndex:o=M2.activeDot}=e,l=Sl(Li),s=Sl(Lh);if(null==t||null==s)return null;var c=t.find(e=>s.includes(e.payload));return null==c?null:ew.createElement(LX,{zIndex:o},ew.createElement(Je,{point:c,childIndex:Number(l),mainColor:n,dataKey:a,activeDot:r,clipPath:i}))}function Jn(e,t){var n,r,a=Sl(t=>OU(t,e)),i=Sl(e=>OK(e,t)),o=null!=(n=null==a?void 0:a.allowDataOverflow)?n:OV.allowDataOverflow,l=null!=(r=null==i?void 0:i.allowDataOverflow)?r:Oq.allowDataOverflow;return{needClip:o||l,needClipX:o,needClipY:l}}function Jr(e){var{xAxisId:t,yAxisId:n,clipPathId:r}=e,a=Sl(B9),{needClipX:i,needClipY:o,needClip:l}=Jn(t,n);if(!l||!a)return null;var{x:s,y:c,width:d,height:u}=a;return ew.createElement("clipPath",{id:"clipPath-".concat(r)},ew.createElement("rect",{x:i?s:s-d/2,y:o?c:c-u/2,width:i?d:2*d,height:o?u:2*u}))}function Ja(e,t){var n,r;return null!=(n=null==(r=e.graphicalItems.cartesianItems.find(e=>e.id===t))?void 0:r.xAxisId)?n:0}function Ji(e,t){var n,r;return null!=(n=null==(r=e.graphicalItems.cartesianItems.find(e=>e.id===t))?void 0:r.yAxisId)?n:0}var Jo=(e,t,n)=>Av(e,"xAxis",Ja(e,t),n),Jl=(e,t,n)=>Ax(e,"xAxis",Ja(e,t),n),Js=(e,t,n)=>Av(e,"yAxis",Ji(e,t),n),Jc=(e,t,n)=>Ax(e,"yAxis",Ji(e,t),n),Jd=k9([MM,Jo,Js,Jl,Jc],(e,t,n,r,a)=>N$(e,"xAxis")?NG(t,r,!1):NG(n,a,!1)),Ju=k9([O0,(e,t)=>t],(e,t)=>e.filter(e=>"area"===e.type).find(e=>e.id===t)),Jf=e=>N$(MM(e),"xAxis")?"yAxis":"xAxis",Jm=k9([Ju,(e,t,n)=>zp(e,Jf(e),"yAxis"===Jf(e)?Ji(e,t):Ja(e,t),n)],(e,t)=>{if(null!=e&&null!=t){var n,{stackId:r}=e,a=Ef(e);if(null!=r&&null!=a){var i=null==(n=t[r])?void 0:n.stackedData,o=null==i?void 0:i.find(e=>e.key===a);if(null!=o)return o.map(e=>[e[0],e[1]])}}}),Jh=k9([MM,Jo,Js,Jl,Jc,Jm,Na,Jd,Ju,e=>e.rootProps.baseValue],(e,t,n,r,a,i,o,l,s,c)=>{var d,{chartData:u,dataStartIndex:f,dataEndIndex:m}=o;if(null!=s&&("horizontal"===e||"vertical"===e)&&null!=t&&null!=n&&null!=r&&null!=a&&0!==r.length&&0!==a.length&&null!=l){var{data:h}=s;if(null!=(d=h&&h.length>0?h:null==u?void 0:u.slice(f,m+1)))return function(e){var t,{areaSettings:{connectNulls:n,baseValue:r,dataKey:a},stackedData:i,layout:o,chartBaseValue:l,xAxis:s,yAxis:c,displayedData:d,dataStartIndex:u,xAxisTicks:f,yAxisTicks:m,bandSize:h}=e,p=i&&i.length,g=((e,t,n,r,a)=>{var i=null!=n?n:t;if(Nj(i))return i;var o="horizontal"===e?a:r,l=o.scale.domain();if("number"===o.type){var s=Math.max(l[0],l[1]),c=Math.min(l[0],l[1]);return"dataMin"===i?c:"dataMax"===i||s<0?s:Math.max(Math.min(l[0],l[1]),0)}return"dataMin"===i?l[0]:"dataMax"===i?l[1]:l[0]})(o,l,r,s,c),x="horizontal"===o,v=!1,b=d.map((e,t)=>{if(p)d=i[u+t];else{var r,o,l,d,b,y=NL(e,a);Array.isArray(y)?(d=y,v=!0):d=[g,y]}var w=null!=(r=null==(o=d)?void 0:o[1])?r:null,j=null==w||p&&!n&&null==NL(e,a);return x?{x:NU({axis:s,ticks:f,bandSize:h,entry:e,index:t}),y:j?null:null!=(b=c.scale.map(w))?b:null,value:d,payload:e}:{x:j?null:null!=(l=s.scale.map(w))?l:null,y:NU({axis:c,ticks:m,bandSize:h,entry:e,index:t}),value:d,payload:e}});return t=p||v?b.map(e=>{var t,n,r=Array.isArray(e.value)?e.value[0]:null;return x?{x:e.x,y:null!=r&&null!=e.y&&null!=(n=c.scale.map(r))?n:null,payload:e.payload}:{x:null!=r&&null!=(t=s.scale.map(r))?t:null,y:e.y,payload:e.payload}}):x?c.scale.map(g):s.scale.map(g),{points:b,baseLine:null!=t?t:0,isRange:v}}({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:a,dataStartIndex:f,areaSettings:s,stackedData:i,displayedData:d,chartBaseValue:c,bandSize:l})}});function Jp(e){var t=AG(e);if(null!=t){var{r:n,strokeWidth:r}=t,a=Number(n),i=Number(r);return(Number.isNaN(a)||a<0)&&(a=3),(Number.isNaN(i)||i<0)&&(i=2),{r:a,strokeWidth:i}}return{r:3,strokeWidth:2}}var Jg=["id"],Jx=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Jv(){return(Jv=Object.assign.bind()).apply(null,arguments)}function Jb(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function Jy(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Jw(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Jy(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Jy(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Jj(e,t){return e&&"none"!==e?e:t}var Jk=ZQ.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:a,fill:i,name:o,hide:l,unit:s,tooltipType:c,id:d}=e,u={dataDefinedOnItem:n,getPosition:Nz,settings:{stroke:r,strokeWidth:a,fill:i,dataKey:t,nameKey:void 0,name:NY(o,t),hide:l,type:c,color:Jj(r,i),unit:s,graphicalItemId:d}};return ZQ.createElement(_u,{tooltipEntrySettings:u})});function JN(e){var{clipPathId:t,points:n,props:r}=e,{needClip:a,dot:i,dataKey:o}=r,l=AK(r);return ZQ.createElement(Z8,{points:n,dot:i,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:a,clipPathId:t})}function JS(e){var{showLabels:t,children:n,points:r}=e,a=r.map(e=>{var t,n,r={x:null!=(t=e.x)?t:0,y:null!=(n=e.y)?n:0,width:0,lowerWidth:0,upperWidth:0,height:0};return Jw(Jw({},r),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:r,fill:void 0})});return ZQ.createElement($c,{value:t?a:void 0},n)}function JC(e){var{points:t,baseLine:n,needClip:r,clipPathId:a,props:i}=e,{layout:o,type:l,stroke:s,connectNulls:c,isRange:d}=i,{id:u}=i,f=Jb(i,Jg),m=AK(f),h=AX(f);return ZQ.createElement(ZQ.Fragment,null,(null==t?void 0:t.length)>1&&ZQ.createElement(AJ,{clipPath:r?"url(#clipPath-".concat(a,")"):void 0},ZQ.createElement(TE,Jv({},h,{id:u,points:t,connectNulls:c,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),"none"!==s&&ZQ.createElement(TE,Jv({},m,{className:"recharts-area-curve",layout:o,type:l,connectNulls:c,fill:"none",points:t})),"none"!==s&&d&&Array.isArray(n)&&ZQ.createElement(TE,Jv({},m,{className:"recharts-area-curve",layout:o,type:l,connectNulls:c,fill:"none",points:n}))),ZQ.createElement(JN,{points:t,props:f,clipPathId:a}))}function JM(e){var t,n,{alpha:r,baseLine:a,points:i,strokeWidth:o}=e,l=null==(t=i[0])?void 0:t.y,s=null==(n=i[i.length-1])?void 0:n.y;if(!NT(l)||!NT(s))return null;var c=r*Math.abs(l-s),d=Math.max(...i.map(e=>e.x||0));return(Nj(a)?d=Math.max(a,d):a&&Array.isArray(a)&&a.length&&(d=Math.max(...a.map(e=>e.x||0),d)),Nj(d))?ZQ.createElement("rect",{x:0,y:l<s?l:l-c,width:d+(o?parseInt("".concat(o),10):1),height:Math.floor(c)}):null}function JE(e){var t,n,{alpha:r,baseLine:a,points:i,strokeWidth:o}=e,l=null==(t=i[0])?void 0:t.x,s=null==(n=i[i.length-1])?void 0:n.x;if(!NT(l)||!NT(s))return null;var c=r*Math.abs(l-s),d=Math.max(...i.map(e=>e.y||0));return(Nj(a)?d=Math.max(a,d):a&&Array.isArray(a)&&a.length&&(d=Math.max(...a.map(e=>e.y||0),d)),Nj(d))?ZQ.createElement("rect",{x:l<s?l:l-c,y:0,width:c,height:Math.floor(d+(o?parseInt("".concat(o),10):1))}):null}function JI(e){var{alpha:t,layout:n,points:r,baseLine:a,strokeWidth:i}=e;return"vertical"===n?ZQ.createElement(JM,{alpha:t,points:r,baseLine:a,strokeWidth:i}):ZQ.createElement(JE,{alpha:t,points:r,baseLine:a,strokeWidth:i})}function JP(e){var{needClip:t,clipPathId:n,props:r,previousPointsRef:a,previousBaselineRef:i}=e,{points:o,baseLine:l,isAnimationActive:s,animationBegin:c,animationDuration:d,animationEasing:u,onAnimationStart:f,onAnimationEnd:m}=r,h=RP((0,ZQ.useMemo)(()=>({points:o,baseLine:l}),[o,l]),"recharts-area-"),p=ME(),[g,x]=(0,ZQ.useState)(!1),v=(0,ZQ.useCallback)(()=>{"function"==typeof m&&m(),x(!1)},[m]),b=(0,ZQ.useCallback)(()=>{"function"==typeof f&&f(),x(!0)},[f]);if(null==p)return null;var y=a.current,w=i.current;return ZQ.createElement(JS,{showLabels:!g,points:o},r.children,ZQ.createElement(RI,{animationId:h,begin:c,duration:d,isActive:s,easing:u,onAnimationEnd:v,onAnimationStart:b,key:h},e=>{if(y){var c,d=y.length/o.length,u=1===e?o:o.map((t,n)=>{var r=Math.floor(n*d);if(y[r]){var a=y[r];return Jw(Jw({},t),{},{x:NE(a.x,t.x,e),y:NE(a.y,t.y,e)})}return t});if(Nj(l))c=NE(w,l,e);else c=null==l||Ny(l)?NE(w,0,e):l.map((t,n)=>{var r=Math.floor(n*d);if(Array.isArray(w)&&w[r]){var a=w[r];return Jw(Jw({},t),{},{x:NE(a.x,t.x,e),y:NE(a.y,t.y,e)})}return t});return e>0&&(a.current=u,i.current=c),ZQ.createElement(JC,{points:u,baseLine:c,needClip:t,clipPathId:n,props:r})}return e>0&&(a.current=o,i.current=l),ZQ.createElement(AJ,null,s&&ZQ.createElement("defs",null,ZQ.createElement("clipPath",{id:"animationClipPath-".concat(n)},ZQ.createElement(JI,{alpha:e,points:o,baseLine:l,layout:p,strokeWidth:r.strokeWidth}))),ZQ.createElement(AJ,{clipPath:"url(#animationClipPath-".concat(n,")")},ZQ.createElement(JC,{points:o,baseLine:l,needClip:t,clipPathId:n,props:r})))}),ZQ.createElement($m,{label:r.label}))}function JO(e){var{needClip:t,clipPathId:n,props:r}=e,a=(0,ZQ.useRef)(null),i=(0,ZQ.useRef)();return ZQ.createElement(JP,{needClip:t,clipPathId:n,props:r,previousPointsRef:a,previousBaselineRef:i})}class Jz extends ZQ.PureComponent{render(){var{hide:e,dot:t,points:n,className:r,top:a,left:i,needClip:o,xAxisId:l,yAxisId:s,width:c,height:d,id:u,baseLine:f,zIndex:m}=this.props;if(e)return null;var h=(0,kq.clsx)("recharts-area",r),{r:p,strokeWidth:g}=Jp(t),x=Ro(t),v=2*p+g,b=o?"url(#clipPath-".concat(x?"":"dots-").concat(u,")"):void 0;return ZQ.createElement(LX,{zIndex:m},ZQ.createElement(AJ,{className:h},o&&ZQ.createElement("defs",null,ZQ.createElement(Jr,{clipPathId:u,xAxisId:l,yAxisId:s}),!x&&ZQ.createElement("clipPath",{id:"clipPath-dots-".concat(u)},ZQ.createElement("rect",{x:i-v/2,y:a-v/2,width:c+v,height:d+v}))),ZQ.createElement(JO,{needClip:o,clipPathId:u,props:this.props})),ZQ.createElement(Jt,{points:n,mainColor:Jj(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:b}),this.props.isRange&&Array.isArray(f)&&ZQ.createElement(Jt,{points:f,mainColor:Jj(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:b}))}}var JA={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:.6,hide:!1,isAnimationActive:"auto",legendType:"line",stroke:"#3182bd",strokeWidth:1,type:"linear",label:!1,xAxisId:0,yAxisId:0,zIndex:M2.area};function JT(e){var t,{activeDot:n,animationBegin:r,animationDuration:a,animationEasing:i,connectNulls:o,dot:l,fill:s,fillOpacity:c,hide:d,isAnimationActive:u,legendType:f,stroke:m,xAxisId:h,yAxisId:p}=e,g=Jb(e,Jx),x=Sl(MM),v=Sl(MK),{needClip:b}=Jn(h,p),y=Mn(),{points:w,isRange:j,baseLine:k}=null!=(t=Sl(t=>Jh(t,e.id,y)))?t:{},N=Sl(B9);if("horizontal"!==x&&"vertical"!==x||null==N||"AreaChart"!==v&&"ComposedChart"!==v)return null;var{height:S,width:C,x:M,y:E}=N;return w&&w.length?ZQ.createElement(Jz,Jv({},g,{activeDot:n,animationBegin:r,animationDuration:a,animationEasing:i,baseLine:k,connectNulls:o,dot:l,fill:s,fillOpacity:c,height:S,hide:d,layout:x,isAnimationActive:u,isRange:j,legendType:f,needClip:b,points:w,stroke:m,width:C,left:M,top:E,xAxisId:h,yAxisId:p})):null}var JR=ZQ.memo(function(e){var t=TG(e,JA),n=Mn();return ZQ.createElement(LC,{id:t.id,type:"area"},e=>ZQ.createElement(ZQ.Fragment,null,ZQ.createElement(Lj,{legendPayload:(e=>{var{dataKey:t,name:n,stroke:r,fill:a,legendType:i,hide:o}=e;return[{inactive:o,dataKey:t,type:i,color:Jj(r,a),value:NY(n,t),payload:e}]})(t)}),ZQ.createElement(Jk,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),ZQ.createElement(LR,{type:"area",id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:NH(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),ZQ.createElement(JT,Jv({},t,{id:e}))))},BM);function JD(){return(JD=Object.assign.bind()).apply(null,arguments)}function J_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}JR.displayName="Area";var JL=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?J_(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):J_(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:{top:5,right:5,bottom:5,left:5},responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},Bp),J$=(0,ew.forwardRef)(function(e,t){var n,r=TG(e.categoricalChartProps,JL),{chartName:a,defaultTooltipEventType:i,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,categoricalChartProps:s}=e;return ew.createElement(BN,{preloadedState:{options:{chartName:a,defaultTooltipEventType:i,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,eventEmitter:void 0}},reduxStoreName:null!=(n=s.id)?n:a},ew.createElement(BS,{chartData:s.data}),ew.createElement(BE,{layout:r.layout,margin:r.margin}),ew.createElement(BP,{throttleDelay:r.throttleDelay,throttledEvents:r.throttledEvents}),ew.createElement(BI,{baseValue:r.baseValue,accessibilityLayer:r.accessibilityLayer,barCategoryGap:r.barCategoryGap,maxBarSize:r.maxBarSize,stackOffset:r.stackOffset,barGap:r.barGap,barSize:r.barSize,syncId:r.syncId,syncMethod:r.syncMethod,className:r.className,reverseStackOrder:r.reverseStackOrder}),ew.createElement(Vr,JD({},r,{ref:t})))}),JF=["axis"],JB=(0,ew.forwardRef)((e,t)=>ew.createElement(J$,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:JF,tooltipPayloadSearcher:$A,categoricalChartProps:e,ref:t})),JV=function(e){var{width:t,height:n}=e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(r%180+180)%180*Math.PI/180,i=Math.atan(n/t);return Math.abs(a>i&&a<Math.PI-i?n/Math.sin(a):t/Math.cos(a))};function JH(e,t){if(t<1)return[];if(1===t)return e;for(var n=[],r=0;r<e.length;r+=t){var a=e[r];void 0!==a&&n.push(a)}return n}function JU(e,t,n,r,a){if(e*t<e*r||e*t>e*a)return!1;var i=n();return e*(t-e*i/2-r)>=0&&e*(t+e*i/2-a)<=0}function Jq(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function JW(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Jq(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Jq(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function JK(e,t,n){var r,{tick:a,ticks:i,viewBox:o,minTickGap:l,orientation:s,interval:c,tickFormatter:d,unit:u,angle:f}=e;if(!i||!i.length||!a)return[];if(Nj(c)||TI.isSsr)return null!=(r=JH(i,(Nj(c)?c:0)+1))?r:[];var m="top"===s||"bottom"===s?"width":"height",h=u&&"width"===m?TD(u,{fontSize:t,letterSpacing:n}):{width:0,height:0},p=(e,r)=>{var a,i="function"==typeof d?d(e.value,r):e.value;return"width"===m?(a=TD(i,{fontSize:t,letterSpacing:n}),JV({width:a.width+h.width,height:a.height+h.height},f)):TD(i,{fontSize:t,letterSpacing:n})[m]},g=i[0],x=i[1],v=i.length>=2&&null!=g&&null!=x?Nb(x.coordinate-g.coordinate):1,b=function(e,t,n){var r="width"===n,{x:a,y:i,width:o,height:l}=e;return 1===t?{start:r?a:i,end:r?a+o:i+l}:{start:r?a+o:i+l,end:r?a:i}}(o,v,m);return"equidistantPreserveStart"===c?function(e,t,n,r,a){for(var i,o=(r||[]).slice(),{start:l,end:s}=t,c=0,d=1,u=l;d<=o.length;)if(i=function(){var t,i=null==r?void 0:r[c];if(void 0===i)return{v:JH(r,d)};var o=c,f=()=>(void 0===t&&(t=n(i,o)),t),m=i.coordinate,h=0===c||JU(e,m,f,u,s);h||(c=0,u=l,d+=1),h&&(u=m+e*(f()/2+a),c+=d)}())return i.v;return[]}(v,b,p,i,l):"equidistantPreserveEnd"===c?function(e,t,n,r,a){var i=(r||[]).slice().length;if(0===i)return[];for(var{start:o,end:l}=t,s=1;s<=i;s++){for(var c,d=(i-1)%s,u=o,f=!0,m=d;m<i&&(0===(c=function(){var t,i=r[m];if(null==i)return 0;var o=m,s=()=>(void 0===t&&(t=n(i,o)),t),c=i.coordinate,h=m===d||JU(e,c,s,u,l);if(!h)return f=!1,1;h&&(u=c+e*(s()/2+a))}())||1!==c);m+=s);if(f){for(var h=[],p=d;p<i;p+=s){var g=r[p];null!=g&&h.push(g)}return h}}return[]}(v,b,p,i,l):("preserveStart"===c||"preserveStartEnd"===c?function(e,t,n,r,a,i){var o=(r||[]).slice(),l=o.length,{start:s,end:c}=t;if(i){var d=r[l-1];if(null!=d){var u=n(d,l-1),f=e*(d.coordinate+e*u/2-c);o[l-1]=d=JW(JW({},d),{},{tickCoord:f>0?d.coordinate-f*e:d.coordinate}),null!=d.tickCoord&&JU(e,d.tickCoord,()=>u,s,c)&&(c=d.tickCoord-e*(u/2+a),o[l-1]=JW(JW({},d),{},{isShow:!0}))}}for(var m=i?l-1:l,h=function(t){var r,i=o[t];if(null==i)return 1;var l=i,d=()=>(void 0===r&&(r=n(i,t)),r);if(0===t){var u=e*(l.coordinate-e*d()/2-s);o[t]=l=JW(JW({},l),{},{tickCoord:u<0?l.coordinate-u*e:l.coordinate})}else o[t]=l=JW(JW({},l),{},{tickCoord:l.coordinate});null!=l.tickCoord&&JU(e,l.tickCoord,d,s,c)&&(s=l.tickCoord+e*(d()/2+a),o[t]=JW(JW({},l),{},{isShow:!0}))},p=0;p<m;p++)if(h(p))continue;return o}(v,b,p,i,l,"preserveStartEnd"===c):function(e,t,n,r,a){for(var i=(r||[]).slice(),o=i.length,{start:l}=t,{end:s}=t,c=function(t){var r,c=i[t];if(null==c)return 1;var d=c,u=()=>(void 0===r&&(r=n(c,t)),r);if(t===o-1){var f=e*(d.coordinate+e*u()/2-s);i[t]=d=JW(JW({},d),{},{tickCoord:f>0?d.coordinate-f*e:d.coordinate})}else i[t]=d=JW(JW({},d),{},{tickCoord:d.coordinate});null!=d.tickCoord&&JU(e,d.tickCoord,u,l,s)&&(s=d.tickCoord-e*(u()/2+a),i[t]=JW(JW({},d),{},{isShow:!0}))},d=o-1;d>=0;d--)if(c(d))continue;return i}(v,b,p,i,l)).filter(e=>e.isShow)}var JG=["axisLine","width","height","className","hide","ticks","axisType","axisId"];function JX(){return(JX=Object.assign.bind()).apply(null,arguments)}function JY(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function JZ(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?JY(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):JY(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var JJ={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd",zIndex:M2.axis};function JQ(e){var{x:t,y:n,width:r,height:a,orientation:i,mirror:o,axisLine:l,otherSvgProps:s}=e;if(!l)return null;var c=JZ(JZ(JZ({},s),AK(l)),{},{fill:"none"});if("top"===i||"bottom"===i){var d=+("top"===i&&!o||"bottom"===i&&o);c=JZ(JZ({},c),{},{x1:t,y1:n+d*a,x2:t+r,y2:n+d*a})}else{var u=+("left"===i&&!o||"right"===i&&o);c=JZ(JZ({},c),{},{x1:t+u*r,y1:n,x2:t+u*r,y2:n+a})}return ew.createElement("line",JX({},c,{className:(0,kq.clsx)("recharts-cartesian-axis-line",(0,kU.default)(l,"className"))}))}function J0(e){var t,{option:n,tickProps:r,value:a}=e,i=(0,kq.clsx)(r.className,"recharts-cartesian-axis-tick-value");if(ew.isValidElement(n))t=ew.cloneElement(n,JZ(JZ({},r),{},{className:i}));else if("function"==typeof n)t=n(JZ(JZ({},r),{},{className:i}));else{var o="recharts-cartesian-axis-tick-value";"boolean"!=typeof n&&(o=(0,kq.clsx)(o,$h(n))),t=ew.createElement(T7,JX({},r,{className:o}),a)}return t}function J1(e){var{ticks:t,axisType:n,axisId:r}=e,a=Sr();return(0,ew.useEffect)(()=>null==r||null==n?Nz:(a(By({ticks:t.map(e=>({value:e.value,coordinate:e.coordinate,offset:e.offset,index:e.index})),axisId:r,axisType:n})),()=>{a(Bw({axisId:r,axisType:n}))}),[a,t,r,n]),null}var J2=(0,ew.forwardRef)((e,t)=>{var{ticks:n=[],tick:r,tickLine:a,stroke:i,tickFormatter:o,unit:l,padding:s,tickTextProps:c,orientation:d,mirror:u,x:f,y:m,width:h,height:p,tickSize:g,tickMargin:x,fontSize:v,letterSpacing:b,getTicksConfig:y,events:w,axisType:j,axisId:k}=e,N=JK(JZ(JZ({},y),{},{ticks:n}),v,b),S=AK(y),C=AG(r),M=T1(S.textAnchor)?S.textAnchor:function(e,t){switch(e){case"left":return t?"start":"end";case"right":return t?"end":"start";default:return"middle"}}(d,u),E=function(e,t){switch(e){case"left":case"right":return"middle";case"top":return t?"start":"end";default:return t?"end":"start"}}(d,u),I={};"object"==typeof a&&(I=a);var P=JZ(JZ({},S),{},{fill:"none"},I),O=N.map(e=>JZ({entry:e},function(e,t,n,r,a,i,o,l,s){var c,d,u,f,m,h,p=l?-1:1,g=e.tickSize||o,x=Nj(e.tickCoord)?e.tickCoord:e.coordinate;switch(i){case"top":c=d=e.coordinate,h=(u=(f=n+!l*a)-p*g)-p*s,m=x;break;case"left":u=f=e.coordinate,m=(c=(d=t+!l*r)-p*g)-p*s,h=x;break;case"right":u=f=e.coordinate,m=(c=(d=t+l*r)+p*g)+p*s,h=x;break;default:c=d=e.coordinate,h=(u=(f=n+l*a)+p*g)+p*s,m=x}return{line:{x1:c,y1:u,x2:d,y2:f},tick:{x:m,y:h}}}(e,f,m,h,p,d,g,u,x))),z=O.map(e=>{var{entry:t,line:n}=e;return ew.createElement(AJ,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(t.value,"-").concat(t.coordinate,"-").concat(t.tickCoord)},a&&ew.createElement("line",JX({},P,n,{className:(0,kq.clsx)("recharts-cartesian-axis-tick-line",(0,kU.default)(a,"className"))})))}),A=O.map((e,t)=>{var n,a,{entry:d,tick:u}=e,f=JZ(JZ(JZ(JZ({verticalAnchor:E},S),{},{textAnchor:M,stroke:"none",fill:i},u),{},{index:t,payload:d,visibleTicksCount:N.length,tickFormatter:o,padding:s},c),{},{angle:null!=(n=null!=(a=null==c?void 0:c.angle)?a:S.angle)?n:0}),m=JZ(JZ({},f),C);return ew.createElement(AJ,JX({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(d.value,"-").concat(d.coordinate,"-").concat(d.tickCoord)},Tb(w,d,t)),r&&ew.createElement(J0,{option:r,tickProps:m,value:"".concat("function"==typeof o?o(d.value,t):d.value).concat(l||"")}))});return ew.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(j,"-ticks")},ew.createElement(J1,{ticks:N,axisId:k,axisType:j}),A.length>0&&ew.createElement(LX,{zIndex:M2.label},ew.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(j,"-tick-labels"),ref:t},A)),z.length>0&&ew.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(j,"-tick-lines")},z))}),J5=(0,ew.forwardRef)((e,t)=>{var{axisLine:n,width:r,height:a,className:i,hide:o,ticks:l,axisType:s,axisId:c}=e,d=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(e,JG),[u,f]=(0,ew.useState)(""),[m,h]=(0,ew.useState)(""),p=(0,ew.useRef)(null);(0,ew.useImperativeHandle)(t,()=>({getCalculatedWidth:()=>{var t;return(e=>{var{ticks:t,label:n,labelGapWithTick:r=5,tickSize:a=0,tickMargin:i=0}=e,o=0;if(t){Array.from(t).forEach(e=>{if(e){var t=e.getBoundingClientRect();t.width>o&&(o=t.width)}});var l=n?n.getBoundingClientRect().width:0;return Math.round(o+(a+i)+l+(n?r:0))}return 0})({ticks:p.current,label:null==(t=e.labelRef)?void 0:t.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}}));var g=(0,ew.useCallback)(e=>{if(e){var t=e.getElementsByClassName("recharts-cartesian-axis-tick-value");p.current=t;var n=t[0];if(n){var r=window.getComputedStyle(n),a=r.fontSize,i=r.letterSpacing;(a!==u||i!==m)&&(f(a),h(i))}}},[u,m]);return o||null!=r&&r<=0||null!=a&&a<=0?null:ew.createElement(LX,{zIndex:e.zIndex},ew.createElement(AJ,{className:(0,kq.clsx)("recharts-cartesian-axis",i)},ew.createElement(JQ,{x:e.x,y:e.y,width:r,height:a,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:AK(e)}),ew.createElement(J2,{ref:g,axisType:s,events:d,fontSize:u,getTicksConfig:e,height:e.height,letterSpacing:m,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:l,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:c}),ew.createElement(L3,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},ew.createElement($n,{label:e.label,labelRef:e.labelRef}),e.children)))}),J4=ew.forwardRef((e,t)=>{var n=TG(e,JJ);return ew.createElement(J5,JX({},n,{ref:t}))});J4.displayName="CartesianAxis";var J3=["x1","y1","x2","y2","key"],J6=["offset"],J8=["xAxisId","yAxisId"],J7=["xAxisId","yAxisId"];function J9(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Qe(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?J9(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):J9(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Qt(){return(Qt=Object.assign.bind()).apply(null,arguments)}function Qn(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var Qr=e=>{var{fill:t}=e;if(!t||"none"===t)return null;var{fillOpacity:n,x:r,y:a,width:i,height:o,ry:l}=e;return ew.createElement("rect",{x:r,y:a,ry:l,width:i,height:o,stroke:"none",fill:t,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function Qa(e){var{option:t,lineItemProps:n}=e;if(ew.isValidElement(t))r=ew.cloneElement(t,n);else if("function"==typeof t)r=t(n);else{var r,a,{x1:i,y1:o,x2:l,y2:s,key:c}=n,d=null!=(a=AK(Qn(n,J3)))?a:{},{offset:u}=d,f=Qn(d,J6);r=ew.createElement("line",Qt({},f,{x1:i,y1:o,x2:l,y2:s,fill:"none",key:c}))}return r}function Qi(e){var{x:t,width:n,horizontal:r=!0,horizontalPoints:a}=e;if(!r||!a||!a.length)return null;var{xAxisId:i,yAxisId:o}=e,l=Qn(e,J8),s=a.map((e,a)=>{var i=Qe(Qe({},l),{},{x1:t,y1:e,x2:t+n,y2:e,key:"line-".concat(a),index:a});return ew.createElement(Qa,{key:"line-".concat(a),option:r,lineItemProps:i})});return ew.createElement("g",{className:"recharts-cartesian-grid-horizontal"},s)}function Qo(e){var{y:t,height:n,vertical:r=!0,verticalPoints:a}=e;if(!r||!a||!a.length)return null;var{xAxisId:i,yAxisId:o}=e,l=Qn(e,J7),s=a.map((e,a)=>{var i=Qe(Qe({},l),{},{x1:e,y1:t,x2:e,y2:t+n,key:"line-".concat(a),index:a});return ew.createElement(Qa,{option:r,lineItemProps:i,key:"line-".concat(a)})});return ew.createElement("g",{className:"recharts-cartesian-grid-vertical"},s)}function Ql(e){var{horizontalFill:t,fillOpacity:n,x:r,y:a,width:i,height:o,horizontalPoints:l,horizontal:s=!0}=e;if(!s||!t||!t.length||null==l)return null;var c=l.map(e=>Math.round(e+a-a)).sort((e,t)=>e-t);a!==c[0]&&c.unshift(0);var d=c.map((e,l)=>{var s=c[l+1],d=null==s?a+o-e:s-e;if(d<=0)return null;var u=l%t.length;return ew.createElement("rect",{key:"react-".concat(l),y:e,x:r,height:d,width:i,stroke:"none",fill:t[u],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return ew.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function Qs(e){var{vertical:t=!0,verticalFill:n,fillOpacity:r,x:a,y:i,width:o,height:l,verticalPoints:s}=e;if(!t||!n||!n.length)return null;var c=s.map(e=>Math.round(e+a-a)).sort((e,t)=>e-t);a!==c[0]&&c.unshift(0);var d=c.map((e,t)=>{var s=c[t+1],d=null==s?a+o-e:s-e;if(d<=0)return null;var u=t%n.length;return ew.createElement("rect",{key:"react-".concat(t),x:e,y:i,width:d,height:l,stroke:"none",fill:n[u],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return ew.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var Qc=(e,t)=>{var{xAxis:n,width:r,height:a,offset:i}=e;return NF(JK(Qe(Qe(Qe({},JJ),n),{},{ticks:NB(n,!0),viewBox:{x:0,y:0,width:r,height:a}})),i.left,i.left+i.width,t)},Qd=(e,t)=>{var{yAxis:n,width:r,height:a,offset:i}=e;return NF(JK(Qe(Qe(Qe({},JJ),n),{},{ticks:NB(n,!0),viewBox:{x:0,y:0,width:r,height:a}})),i.top,i.top+i.height,t)},Qu={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:M2.grid};function Qf(e){var t=Sl(NZ),n=Sl(NJ),r=MC(),a=Qe(Qe({},TG(e,Qu)),{},{x:Nj(e.x)?e.x:r.left,y:Nj(e.y)?e.y:r.top,width:Nj(e.width)?e.width:r.width,height:Nj(e.height)?e.height:r.height}),{xAxisId:i,yAxisId:o,x:l,y:s,width:c,height:d,syncWithTicks:u,horizontalValues:f,verticalValues:m}=a,h=Mn(),p=Sl(e=>Ap(e,"xAxis",i,h)),g=Sl(e=>Ap(e,"yAxis",o,h));if(!NR(c)||!NR(d)||!Nj(l)||!Nj(s))return null;var x=a.verticalCoordinatesGenerator||Qc,v=a.horizontalCoordinatesGenerator||Qd,{horizontalPoints:b,verticalPoints:y}=a;if((!b||!b.length)&&"function"==typeof v){var w=f&&f.length,j=v({yAxis:g?Qe(Qe({},g),{},{ticks:w?f:g.ticks}):void 0,width:null!=t?t:c,height:null!=n?n:d,offset:r},!!w||u);Mo(Array.isArray(j),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof j,"]")),Array.isArray(j)&&(b=j)}if((!y||!y.length)&&"function"==typeof x){var k=m&&m.length,N=x({xAxis:p?Qe(Qe({},p),{},{ticks:k?m:p.ticks}):void 0,width:null!=t?t:c,height:null!=n?n:d,offset:r},!!k||u);Mo(Array.isArray(N),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof N,"]")),Array.isArray(N)&&(y=N)}return ew.createElement(LX,{zIndex:a.zIndex},ew.createElement("g",{className:"recharts-cartesian-grid"},ew.createElement(Qr,{fill:a.fill,fillOpacity:a.fillOpacity,x:a.x,y:a.y,width:a.width,height:a.height,ry:a.ry}),ew.createElement(Ql,Qt({},a,{horizontalPoints:b})),ew.createElement(Qs,Qt({},a,{verticalPoints:y})),ew.createElement(Qi,Qt({},a,{offset:r,horizontalPoints:b,xAxis:p,yAxis:g})),ew.createElement(Qo,Qt({},a,{offset:r,verticalPoints:y,xAxis:p,yAxis:g}))))}Qf.displayName="CartesianGrid";var Qm=["domain","range"],Qh=["domain","range"];function Qp(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function Qg(e,t){return e===t||!!(Array.isArray(e)&&2===e.length&&Array.isArray(t))&&2===t.length&&e[0]===t[0]&&e[1]===t[1]}function Qx(e,t){if(e===t)return!0;var{domain:n,range:r}=e,a=Qp(e,Qm),{domain:i,range:o}=t,l=Qp(t,Qh);return!!Qg(n,i)&&!!Qg(r,o)&&BM(a,l)}var Qv=["type"],Qb=["dangerouslySetInnerHTML","ticks","scale"],Qy=["id","scale"];function Qw(){return(Qw=Object.assign.bind()).apply(null,arguments)}function Qj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Qk(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Qj(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qj(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function QN(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function QS(e){var t=Sr(),n=(0,ew.useRef)(null),r=ME(),{type:a}=e,i=QN(e,Qv),o=M6(r,"xAxis",a),l=(0,ew.useMemo)(()=>{if(null!=o)return Qk(Qk({},i),{},{type:o})},[i,o]);return(0,ew.useLayoutEffect)(()=>{null!=l&&(null===n.current?t(Fx(l)):n.current!==l&&t(Fv({prev:n.current,next:l})),n.current=l)},[l,t]),(0,ew.useLayoutEffect)(()=>()=>{n.current&&(t(Fb(n.current)),n.current=null)},[t]),null}var QC=e=>{var{xAxisId:t,className:n}=e,r=Sl(N9),a=Mn(),i="xAxis",o=Sl(e=>Ag(e,i,t,a)),l=Sl(e=>Ao(e,t)),s=Sl(e=>Ac(e,t)),c=Sl(e=>OH(e,t));if(null==l||null==s||null==c)return null;var{dangerouslySetInnerHTML:d,ticks:u,scale:f}=e,m=QN(e,Qb),{id:h,scale:p}=c,g=QN(c,Qy);return ew.createElement(J4,Qw({},m,g,{x:s.x,y:s.y,width:l.width,height:l.height,className:(0,kq.clsx)("recharts-".concat(i," ").concat(i),n),viewBox:r,ticks:o,axisType:i,axisId:t}))},QM={allowDataOverflow:OV.allowDataOverflow,allowDecimals:OV.allowDecimals,allowDuplicatedCategory:OV.allowDuplicatedCategory,angle:OV.angle,axisLine:JJ.axisLine,height:OV.height,hide:!1,includeHidden:OV.includeHidden,interval:OV.interval,label:!1,minTickGap:OV.minTickGap,mirror:OV.mirror,orientation:OV.orientation,padding:OV.padding,reversed:OV.reversed,scale:OV.scale,tick:OV.tick,tickCount:OV.tickCount,tickLine:JJ.tickLine,tickSize:JJ.tickSize,type:OV.type,niceTicks:OV.niceTicks,xAxisId:0},QE=ew.memo(e=>{var t=TG(e,QM);return ew.createElement(ew.Fragment,null,ew.createElement(QS,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),ew.createElement(QC,t))},Qx);QE.displayName="XAxis";var QI=["type"],QP=["dangerouslySetInnerHTML","ticks","scale"],QO=["id","scale"];function Qz(){return(Qz=Object.assign.bind()).apply(null,arguments)}function QA(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function QT(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?QA(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):QA(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function QR(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function QD(e){var t=Sr(),n=(0,ew.useRef)(null),r=ME(),{type:a}=e,i=QR(e,QI),o=M6(r,"yAxis",a),l=(0,ew.useMemo)(()=>{if(null!=o)return QT(QT({},i),{},{type:o})},[o,i]);return(0,ew.useLayoutEffect)(()=>{null!=l&&(null===n.current?t(Fy(l)):n.current!==l&&t(Fw({prev:n.current,next:l})),n.current=l)},[l,t]),(0,ew.useLayoutEffect)(()=>()=>{n.current&&(t(Fj(n.current)),n.current=null)},[t]),null}function Q_(e){var{yAxisId:t,className:n,width:r,label:a}=e,i=(0,ew.useRef)(null),o=(0,ew.useRef)(null),l=Sl(N9),s=Mn(),c=Sr(),d="yAxis",u=Sl(e=>Au(e,t)),f=Sl(e=>Ad(e,t)),m=Sl(e=>Ag(e,d,t,s)),h=Sl(e=>OW(e,t));if((0,ew.useLayoutEffect)(()=>{if(!("auto"!==r||!u||L7(a)||(0,ew.isValidElement)(a))&&null!=h){var e=i.current;if(e){var n=e.getCalculatedWidth();Math.round(u.width)!==Math.round(n)&&c(FC({id:t,width:n}))}}},[m,u,c,a,t,r,h]),null==u||null==f||null==h)return null;var{dangerouslySetInnerHTML:p,ticks:g,scale:x}=e,v=QR(e,QP),{id:b,scale:y}=h,w=QR(h,QO);return ew.createElement(J4,Qz({},v,w,{ref:i,labelRef:o,x:f.x,y:f.y,tickTextProps:"auto"===r?{width:void 0}:{width:r},width:u.width,height:u.height,className:(0,kq.clsx)("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:m,axisType:d,axisId:t}))}var QL={allowDataOverflow:Oq.allowDataOverflow,allowDecimals:Oq.allowDecimals,allowDuplicatedCategory:Oq.allowDuplicatedCategory,angle:Oq.angle,axisLine:JJ.axisLine,hide:!1,includeHidden:Oq.includeHidden,interval:Oq.interval,label:!1,minTickGap:Oq.minTickGap,mirror:Oq.mirror,orientation:Oq.orientation,padding:Oq.padding,reversed:Oq.reversed,scale:Oq.scale,tick:Oq.tick,tickCount:Oq.tickCount,tickLine:JJ.tickLine,tickSize:JJ.tickSize,type:Oq.type,niceTicks:Oq.niceTicks,width:Oq.width,yAxisId:0},Q$=ew.memo(e=>{var t=TG(e,QL);return ew.createElement(ew.Fragment,null,ew.createElement(QD,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter,niceTicks:t.niceTicks}),ew.createElement(Q_,t))},Qx);function QF({machines:e,defaultMachineId:t,className:n,...r}){let[a,i]=ew.useState(t??e[0]?.id),o=e.find(e=>e.id===a)??e[0],[l,s]=ew.useState({});if(!o)return null;let c=l[o.id]??o.selectedMetricId??o.metrics[0]?.id,d=o.metrics.find(e=>e.id===c)??o.metrics[0];return(0,eb.jsxs)("div",{className:(0,ez.cn)("vtl-surface-card flex h-full min-h-0 flex-col rounded-[var(--surface-card-radius)] border","vtl-performance-monitor",n),...r,children:[(0,eb.jsx)(XJ,{value:o.id,onValueChange:i,className:"shrink-0 px-3 pt-3",children:(0,eb.jsx)(X8,{className:"h-8",children:e.map(e=>(0,eb.jsx)(X7,{value:e.id,children:e.name},e.id))})}),(0,eb.jsxs)("div",{className:"mt-3 grid min-h-0 flex-1 grid-cols-[14rem_minmax(0,1fr)] border-t",children:[(0,eb.jsx)("div",{className:"min-h-0 overflow-auto border-r p-2",children:o.metrics.map(e=>(0,eb.jsxs)("button",{type:"button",onClick:()=>s(t=>({...t,[o.id]:e.id})),className:(0,ez.cn)("grid w-full grid-cols-[3.75rem_minmax(0,1fr)] gap-3 px-2 py-2 text-left transition-colors",e.id===c&&"bg-muted"),children:[(0,eb.jsx)(QW,{data:e.data,color:e.color}),(0,eb.jsxs)("span",{className:"min-w-0",children:[(0,eb.jsx)("span",{className:"block truncate text-base leading-tight",children:e.label}),(0,eb.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.value}),e.detail?(0,eb.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.detail}):null]})]},e.id))}),(0,eb.jsxs)("div",{className:"min-h-0 overflow-auto p-5",children:[(0,eb.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-start gap-5",children:[(0,eb.jsxs)("div",{children:[(0,eb.jsx)("h2",{className:"text-4xl leading-none font-semibold tracking-normal",children:d?.title}),d?.subtitle?(0,eb.jsx)("p",{className:"mt-1 text-base text-muted-foreground",children:d.subtitle}):null]}),(0,eb.jsx)("div",{className:"text-right text-sm text-muted-foreground",children:d?.detail})]}),d?(0,eb.jsx)(QB,{metric:d}):null]})]})]})}function QB({metric:e}){return"cpu"===e.kind?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(QV,{panel:{id:"cpu",title:"% 利用率",value:"100%",data:e.data,span:"full"},size:"large"}),(0,eb.jsx)(QH,{}),(0,eb.jsx)(Qq,{details:e.details,columns:4})]}):"memory"===e.kind?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(QV,{panel:{id:"memory",title:"内存使用量",value:e.detail,data:e.data,span:"full"},size:"large"}),(0,eb.jsx)(QH,{}),(0,eb.jsx)(QU,{segments:e.composition}),(0,eb.jsx)(Qq,{details:e.details,columns:3})]}):"disk"===e.kind?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(QV,{panel:{id:"disk-active",title:"活动时间",value:"100%",data:e.data,span:"full"},size:"large"}),(0,eb.jsx)(QH,{}),(0,eb.jsx)(QV,{panel:{id:"disk-rate",title:"磁盘传输速率",value:"500 KB/秒",data:e.panels?.[0]?.data??e.data,span:"full"},size:"short"}),(0,eb.jsx)(QH,{}),(0,eb.jsx)(Qq,{details:e.details,columns:4})]}):"network"===e.kind?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(QV,{panel:{id:"network",title:"吞吐量",value:"100 Kbps",data:e.data,span:"full",color:"danger"},size:"tall"}),(0,eb.jsx)(QH,{}),(0,eb.jsx)(Qq,{details:e.details,columns:2})]}):(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("div",{className:"mt-5 grid grid-cols-2 gap-3",children:(e.panels??[]).map(e=>(0,eb.jsx)(QV,{panel:e},e.id))}),(0,eb.jsx)(Qq,{details:e.details,columns:3})]})}function QV({panel:e,size:t="normal"}){let n={short:"h-[4rem]",normal:"full"===e.span?"h-20":"h-24",large:"h-[17.5rem]",tall:"h-[21.5rem]"}[t];return(0,eb.jsxs)("div",{className:(0,ez.cn)("mt-5","full"===e.span&&"col-span-2"),children:[(0,eb.jsxs)("div",{className:"mb-1 flex items-center justify-between text-sm",children:[(0,eb.jsx)("span",{className:"text-muted-foreground",children:e.title}),e.value?(0,eb.jsx)("span",{className:"text-muted-foreground tabular-nums",children:e.value}):null]}),(0,eb.jsx)(QK,{data:e.data,color:e.color,className:(0,ez.cn)("w-full",n)})]})}function QH(){return(0,eb.jsxs)("div",{className:"mt-1 flex justify-between text-xs text-muted-foreground",children:[(0,eb.jsx)("span",{children:"60 秒"}),(0,eb.jsx)("span",{children:"0"})]})}function QU({segments:e}){let t=e&&e.length>0?e:[{label:"used",value:64},{label:"available",value:36}];return(0,eb.jsxs)("div",{className:"mt-5",children:[(0,eb.jsx)("div",{className:"mb-1 text-sm text-muted-foreground",children:"内存组合"}),(0,eb.jsx)("div",{className:"flex h-[3.25rem] w-full overflow-hidden border border-primary/75 bg-background",children:t.map((e,n)=>(0,eb.jsx)("div",{className:(0,ez.cn)("h-full border-r border-primary/75 last:border-r-0",0===n?"bg-primary/20":n===t.length-1?"bg-background":"bg-primary/8"),style:{width:`${Math.max(0,e.value)}%`}},`${e.label}-${n}`))})]})}function Qq({details:e,columns:t}){return e?.length?(0,eb.jsx)("div",{className:(0,ez.cn)("mt-5 grid gap-x-10 gap-y-4",2===t&&"grid-cols-2",3===t&&"grid-cols-3",4===t&&"grid-cols-4"),children:e.map(([e,t])=>(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("div",{className:"text-xs text-muted-foreground",children:e}),(0,eb.jsx)("div",{className:"truncate text-2xl leading-tight tabular-nums",children:t})]},e))}):null}function QW({data:e,color:t}){return(0,eb.jsx)(QK,{data:e,color:t,className:"h-10 w-full",strokeWidth:1.4,compact:!0})}function QK({data:e,color:t="default",className:n,strokeWidth:r=1.6,compact:a=!1}){let i=ew.useMemo(()=>(e.length>1?e:[0,0]).map((e,t)=>({index:t,value:Math.max(0,Math.min(100,e))})),[e]),o=ew.useMemo(()=>({value:{label:"Value",color:"danger"===t?"var(--destructive)":"var(--foreground)"}}),[t]);return(0,eb.jsx)(Hl,{config:o,className:(0,ez.cn)("aspect-auto border bg-background text-muted-foreground",n),initialDimension:{width:a?96:640,height:a?40:220},children:(0,eb.jsxs)(JB,{data:i,margin:{top:a?2:6,right:0,bottom:0,left:0},children:[a?null:(0,eb.jsx)(Qf,{strokeDasharray:"0",stroke:"var(--border)",strokeOpacity:.7}),(0,eb.jsx)(QE,{dataKey:"index",hide:!0,domain:["dataMin","dataMax"]}),(0,eb.jsx)(Q$,{hide:!0,domain:[0,100]}),a?null:(0,eb.jsx)(VZ,{cursor:!1,content:(0,eb.jsx)(Hc,{hideLabel:!0,indicator:"line"})}),(0,eb.jsx)(JR,{dataKey:"value",type:"monotone",fill:"var(--color-value)",fillOpacity:"danger"===t?.16:.12,stroke:"var(--color-value)",strokeWidth:r,isAnimationActive:!1,dot:!1,activeDot:!1})]})})}Q$.displayName="YAxis";let QG=(0,ek.default)("badge-alert",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),QX=(0,ek.default)("circle-pause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]),QY={name:"名称",cpu:"CPU",memoryMb:"内存",diskMbps:"磁盘",networkMbps:"网络"};function QZ({machines:e,defaultMachineId:t,className:n,...r}){let[a,i]=ew.useState(t??e[0]?.id),[o,l]=ew.useState("cpu"),[s,c]=ew.useState("desc"),[d,u]=ew.useState({}),f=e.find(e=>e.id===a)??e[0],m=ew.useMemo(()=>{if(!f)return[];let e=[...function(e){let t=new Map,n=new Map;for(let t of e)void 0!==t.pid&&n.set(t.pid,t);for(let a of e){var r;let e=function e(t,n,r=new Set){void 0!==t.pid&&r.add(t.pid);let a=void 0!==t.parentPid?n.get(t.parentPid):void 0;return!a||void 0===a.pid||r.has(a.pid)||["bash","containerd","dockerd","explorer","init","kernel_task","launchd","services","sh","smss","svchost","system","systemd","wininit","winlogon","zsh"].includes(Q5(a))?t:e(a,n,r)}(a,n),i=Q5(e),o=t.get(i)??{kind:"group",id:i,name:(r=e,r.appName?.trim()||r.name.trim().replace(/\.(exe|com)$/i,"")||r.id),children:[],status:[],cpu:0,memoryMb:0,diskMbps:0,networkMbps:0};o.children.push(a),o.cpu+=a.cpu,o.memoryMb+=a.memoryMb,o.diskMbps+=a.diskMbps,o.networkMbps+=a.networkMbps,o.status=function(e,t){let n=new Set(e??[]);for(let e of t??[])n.add(e);return Array.from(n)}(o.status,a.status),t.set(i,o)}return Array.from(t.values()).map(e=>({...e,cpu:Q3(Math.min(100,e.cpu)),memoryMb:Q3(e.memoryMb),diskMbps:Q3(e.diskMbps),networkMbps:Q3(e.networkMbps)}))}(f.processes)].sort((e,t)=>Q4(e,t,o,s)),t=[];for(let n of e){if(n.children.length<=1){let e=n.children[0];e&&t.push(Q2(e,0));continue}if(t.push(n),d[n.id])for(let e of[...n.children].sort((e,t)=>Q4(e,t,o,s)))t.push(Q2(e,1))}return t},[f,d,s,o]),h=ew.useMemo(()=>m.map(e=>({memoryMb:e.memoryMb,diskMbps:e.diskMbps,networkMbps:e.networkMbps})),[m]);function p(e){e===o?c(e=>"asc"===e?"desc":"asc"):(l(e),c("name"===e?"asc":"desc"))}return f?(0,eb.jsxs)("div",{className:(0,ez.cn)("vtl-surface-card flex h-full min-h-0 flex-col rounded-[var(--surface-card-radius)] border","vtl-process-monitor",n),...r,children:[(0,eb.jsx)(XJ,{value:f.id,onValueChange:i,className:"shrink-0 px-3 pt-3",children:(0,eb.jsx)(X8,{className:"h-8",children:e.map(e=>(0,eb.jsx)(X7,{value:e.id,children:e.name},e.id))})}),(0,eb.jsxs)("div",{className:"mt-3 grid h-14 shrink-0 grid-cols-[minmax(12rem,1fr)_6.25rem_repeat(4,minmax(5rem,7rem))] border-y text-sm",children:[(0,eb.jsxs)("button",{type:"button",onClick:()=>p("name"),className:"flex items-end px-3 pb-2 text-left text-muted-foreground",children:["名称",(0,eb.jsx)(QJ,{active:"name"===o,direction:s})]}),(0,eb.jsx)("div",{className:"flex items-end px-3 pb-2 text-muted-foreground",children:"状态"}),["cpu","memoryMb","diskMbps","networkMbps"].map(e=>{var t,n;return(0,eb.jsxs)("button",{type:"button",onClick:()=>p(e),className:"grid content-end border-l px-3 pb-2 text-right",children:[(0,eb.jsx)("span",{className:"text-lg leading-none text-foreground",children:(t=f.totals,"cpu"===(n=e)?`${Math.round(t.cpu)}%`:"memoryMb"===n?`${Math.round(t.memory)}%`:"diskMbps"===n?`${Math.round(t.disk)}%`:"networkMbps"===n?`${Math.round(t.network)}%`:"")}),(0,eb.jsxs)("span",{className:"mt-1 text-xs text-muted-foreground",children:[QY[e],(0,eb.jsx)(QJ,{active:o===e,direction:s,className:"ml-1 inline-flex"})]})]},e)})]}),(0,eb.jsx)("div",{className:"vtl-scrollbar-hidden min-h-0 flex-1 overflow-auto",children:m.map(e=>{var t;return(0,eb.jsxs)("div",{className:(0,ez.cn)("grid min-h-9 grid-cols-[minmax(12rem,1fr)_6.25rem_repeat(4,minmax(5rem,7rem))] items-center text-sm","group"===e.kind&&"bg-muted/35"),children:[(0,eb.jsx)(QQ,{row:e,expanded:"group"===e.kind&&!!d[e.id],onToggle:()=>{"group"===e.kind&&u(t=>({...t,[e.id]:!t[e.id]}))}}),(0,eb.jsx)(Q0,{platform:f.platform,status:e.status}),(0,eb.jsx)(Q1,{value:e.cpu,max:100,label:`${e.cpu.toFixed(1)}%`}),(0,eb.jsx)(Q1,{value:e.memoryMb,max:Q6(h,"memoryMb"),label:(t=e.memoryMb)>=1024?`${Q8(t/1024)} GB`:`${Q8(t)} MB`}),(0,eb.jsx)(Q1,{value:e.diskMbps,max:Math.max(1,Q6(h,"diskMbps")),label:`${Q8(e.diskMbps)} MB/秒`}),(0,eb.jsx)(Q1,{value:e.networkMbps,max:Math.max(1,Q6(h,"networkMbps")),label:`${Q8(e.networkMbps)} Mbps`})]},`${e.kind}-${e.id}`)})})]}):null}function QJ({active:e,direction:t,className:n}){return e?(0,eb.jsx)("asc"===t?k_:kD,{className:(0,ez.cn)("ml-1 size-3",n)}):null}function QQ({row:e,expanded:t,onToggle:n}){if("group"===e.kind){let r=t?pt:h7;return(0,eb.jsxs)("button",{type:"button","aria-expanded":t,onClick:n,className:"flex h-full min-w-0 items-center gap-2 px-3 text-left outline-none transition-colors hover:bg-muted/55 focus-visible:ring-[3px] focus-visible:ring-ring/20",children:[(0,eb.jsx)(r,{className:"size-4 shrink-0 text-muted-foreground"}),(0,eb.jsx)("span",{className:"size-2 rounded-sm bg-foreground/65"}),(0,eb.jsxs)("span",{className:"min-w-0 truncate font-medium",children:[e.name," (",e.children.length,")"]})]})}return(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-2 px-3",style:{paddingLeft:e.depth>0?34:void 0},children:[e.depth>0?(0,eb.jsx)("span",{className:"size-1.5 rounded-full bg-muted-foreground/70"}):(0,eb.jsx)("span",{className:"size-1.5 rounded-full bg-foreground/65"}),(0,eb.jsx)("span",{className:(0,ez.cn)("truncate",0===e.depth&&"font-medium"),children:e.name}),e.process.pid?(0,eb.jsx)("span",{className:"shrink-0 ui-text-kbd text-muted-foreground",children:e.process.pid}):null]})}function Q0({platform:e,status:t}){return t?.length?(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 px-3 text-muted-foreground",children:[t.includes("suspended")?(0,eb.jsx)(QX,{"aria-label":"linux"===e?"挂起进程":"挂起",className:"size-4"}):null,t.includes("auto-restart")?(0,eb.jsx)(lZ,{"aria-label":"linux"===e?"自动重启进程":"自动重启",className:"size-4"}):null,t.includes("running")?(0,eb.jsx)(QG,{"aria-label":"运行",className:"size-4 text-primary"}):null]}):(0,eb.jsx)("div",{className:"px-3"})}function Q1({value:e,max:t,label:n}){let r=Math.min(1,Math.max(0,e/Math.max(1,t))),a=r>.78,i=a?`color-mix(in oklch, var(--destructive) ${Math.round(18+42*r)}%, var(--background))`:`color-mix(in oklch, var(--foreground) ${Math.round(5+20*r)}%, var(--background))`;return(0,eb.jsx)("div",{className:"vtl-process-heat-cell h-full border-l px-3 text-right tabular-nums","data-hot":a?"":void 0,style:{background:i},children:(0,eb.jsx)("span",{className:(0,ez.cn)("leading-9",a&&"text-destructive"),children:n})})}function Q2(e,t){return{kind:"process",id:e.id,process:e,depth:t,name:e.appName&&0===t?e.appName:e.name,status:e.status,cpu:e.cpu,memoryMb:e.memoryMb,diskMbps:e.diskMbps,networkMbps:e.networkMbps}}function Q5(e){return e.appId?.trim().toLowerCase()||e.appName?.trim().toLowerCase()||e.name.trim().toLowerCase().replace(/\.(exe|com)$/i,"")||e.id}function Q4(e,t,n,r){let a="asc"===r?1:-1;return"name"===n?e.name.localeCompare(t.name)*a:(e[n]-t[n])*a}function Q3(e){return Math.round(10*e)/10}function Q6(e,t){return e.reduce((e,n)=>Math.max(e,n[t]),0)}function Q8(e){return new Intl.NumberFormat("zh-CN",{maximumFractionDigits:+(e<10)}).format(e)}function Q7({className:e}){let t=eee("/api/local/machines/processes"),n=eet("/machines/processes"),r=ew.useMemo(()=>[...t,...n],[t,n]);return(0,eb.jsx)(QZ,{machines:r,className:(0,ez.cn)("h-full min-h-0 w-full",e)})}function Q9({className:e}){let t=eee("/api/local/machines/performance"),n=eet("/machines/performance"),r=ew.useMemo(()=>[...t,...n],[t,n]);return(0,eb.jsx)(QF,{machines:r,className:(0,ez.cn)("h-full min-h-0 w-full",e)})}function eee(e){let[t,n]=ew.useState([]);return ew.useEffect(()=>{let t=!0,r=!1;async function a(){if(!r){r=!0;try{let r=await fetch((0,eT.localAPIURL)(e),{cache:"no-store"});if(!r.ok)return;let a=await r.json();t&&n(a.machines)}catch{t&&n([])}finally{r=!1}}}a();let i=window.setInterval(a,2e3);return()=>{t=!1,window.clearInterval(i)}},[e]),t}function eet(e){let{machines:t}=vd(),[n,r]=ew.useState([]),a=ew.useMemo(()=>t.filter(e=>!e.isLocal&&"online"===e.status).map(e=>e.id),[t]);return ew.useEffect(()=>{if(0===a.length)return void r([]);let t=!0,n=!1;async function i(){if(!n){n=!0;try{let n=await Promise.all(a.map(async t=>{try{return(await sk(t,e)).machines??[]}catch{return[]}}));t&&r(n.flat())}finally{n=!1}}}i();let o=window.setInterval(i,5e3);return()=>{t=!1,window.clearInterval(o)}},[a,e]),n}let een=(0,ek.default)("circle-play",[["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),eer=(0,ek.default)("radio",[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]),eea={loading:"Starting terminal...",newTerminal:"New terminal",closeTerminal:e=>`Close ${e}`,terminalList:"Terminal sessions",status:{idle:"Idle",running:"Running",success:"Succeeded",error:"Failed"}},eei=[{id:"powershell",title:"PowerShell",shell:"PowerShell",cwd:"D:\\Projects\\Vantaloom-ui",status:"idle",initialOutput:"PowerShell 7.6.1\r\nPS D:\\Projects\\Vantaloom-ui> "}];function eeo(e,t,n){return e.getPropertyValue(t).trim()||n}function eel(e,t=!1){let n=getComputedStyle(e),r=eeo(n,"--foreground","#18181b"),a=eeo(n,"--terminal-background",eeo(n,"--background","#ffffff")),i="transparent"===a?eeo(n,"--background","#ffffff"):a,o=eeo(n,"--muted-foreground","#71717a"),l=eeo(n,"--border","#e4e4e7"),s=eeo(n,"--selection","#18181b");return{background:a,foreground:r,cursor:t?"transparent":r,cursorAccent:t?"transparent":i,selectionBackground:`color-mix(in oklch, ${s} 18%, transparent)`,selectionForeground:eeo(n,"--selection-foreground","#ffffff"),scrollbarSliderBackground:`color-mix(in oklch, ${l} 78%, transparent)`,scrollbarSliderHoverBackground:l,black:r,red:eeo(n,"--terminal-red","#bf616a"),green:eeo(n,"--terminal-green","#5e8c61"),yellow:eeo(n,"--terminal-yellow","#b06f3c"),blue:eeo(n,"--terminal-blue","#5e81ac"),magenta:eeo(n,"--terminal-magenta","#b48ead"),cyan:eeo(n,"--terminal-cyan","#4c8da8"),white:a,brightBlack:o,brightRed:eeo(n,"--terminal-bright-red","#d06f79"),brightGreen:eeo(n,"--terminal-bright-green","#6b9a70"),brightYellow:eeo(n,"--terminal-bright-yellow","#c2824b"),brightBlue:eeo(n,"--terminal-bright-blue","#6f91ba"),brightMagenta:eeo(n,"--terminal-bright-magenta","#c19ac0"),brightCyan:eeo(n,"--terminal-bright-cyan","#5aa0b8"),brightWhite:r}}function ees(e){return void 0===e?[]:Array.isArray(e)?e:[e]}function eec({initialOutput:t,data:n,dataKey:r,options:a,readOnly:i=!1,autoFocus:o=!1,localEcho:l=!1,onData:s,onResize:c,onReady:d,labels:u,className:f,terminalClassName:m,...h}){let p=ew.useMemo(()=>({loading:eea.loading,...u}),[u]),g=ew.useRef(null),x=ew.useRef(null),v=ew.useRef(void 0),b=ew.useRef(s),y=ew.useRef(c),w=ew.useRef(d),j=ew.useRef(a),k=ew.useRef(i),N=ew.useRef(l),S=ew.useRef(!1),C=ew.useRef(void 0),M=ew.useRef(!1),[E,I]=ew.useState(!1);return ew.useEffect(()=>{b.current=s,y.current=c,w.current=d,j.current=a,k.current=i,N.current=l},[l,s,d,c,a,i]),ew.useEffect(()=>{let n,r=!1,a=[];!async function(){var i;let l,s,c,d,u;if(!g.current||M.current)return;M.current=!0;let[{Terminal:f},{FitAddon:m},{SearchAddon:h},{WebLinksAddon:p}]=await Promise.all([e.A(93626),e.A(16118),e.A(24306),e.A(46866)]);if(r||!g.current)return;let C=new f({convertEol:!1,cursorBlink:!0,cursorStyle:"block",drawBoldTextInBrightColors:!1,fontFamily:(l=getComputedStyle(i=g.current),u=(c=eeo(l,"--font-family-mono",s='"Cascadia Mono", "Cascadia Code", Consolas, "SFMono-Regular", "Liberation Mono", monospace'),d=getComputedStyle(i),c.replace(/var\((--[a-zA-Z0-9-_]+)(?:,[^)]+)?\)/g,(e,t)=>d.getPropertyValue(t).trim()||"")).trim(),`"Cascadia Mono", "Cascadia Code", Consolas, ${u||s}`),fontSize:13,letterSpacing:0,lineHeight:1.25,macOptionIsMeta:!0,minimumContrastRatio:4.5,scrollback:5e3,theme:eel(g.current),...j.current,allowTransparency:!0}),E=new m,P=new h,O=new p;function z(){try{E.fit(),y.current?.({cols:C.cols,rows:C.rows})}catch{}}for(let e of(C.loadAddon(E),C.loadAddon(P),C.loadAddon(O),C.open(g.current),x.current=C,v.current=E,I(!0),requestAnimationFrame(z),(n=new ResizeObserver(z)).observe(g.current),a.push(C.onData(e=>{k.current||(N.current&&("\r"===e?C.write("\r\n"):""===e?C.write("\b \b"):C.write(e)),b.current?.(e))})),ees(t)))C.write(e);w.current?.({terminal:C,fitAddon:E,searchAddon:P,webLinksAddon:O,fit:z,focus:()=>C.focus(),clear:()=>C.clear(),setCursorSuppressed:function(e){let t=g.current;t&&(S.current=e,t.toggleAttribute("data-vtl-terminal-cursor-suppressed",e),C.options.theme=eel(t,e))},write:(e,t)=>C.write(e,t),writeln:e=>C.writeln(e)}),o&&C.focus()}();let i=new MutationObserver(()=>{let e=x.current,t=g.current;e&&t&&(e.options.theme=eel(t,S.current))});return i.observe(document.documentElement,{attributeFilter:["class","style"],attributes:!0}),()=>{for(let e of(r=!0,i.disconnect(),n?.disconnect(),a))e.dispose();x.current?.dispose(),x.current=null,v.current=void 0,S.current=!1,M.current=!1,I(!1)}},[o,t]),ew.useEffect(()=>{let e=x.current;if(e&&C.current!==r)for(let t of(C.current=r,ees(n)))e.write(t)},[n,r]),(0,eb.jsxs)("div",{"data-slot":"terminal-tab-surface",className:(0,ez.cn)("relative size-full min-h-0 overflow-hidden bg-background text-foreground",f),...h,children:[(0,eb.jsx)("div",{ref:g,className:(0,ez.cn)("vtl-terminal-xterm size-full overflow-hidden p-1.5 font-mono","[&_.xterm]:h-full [&_.xterm]:p-0 [&_.xterm-viewport]:!bg-transparent","[&_.xterm-screen]:!bg-transparent [&_.xterm-helper-textarea]:!outline-none","[&[data-vtl-terminal-cursor-suppressed]_.xterm-cursor]:!opacity-0","[&_.xterm-viewport::-webkit-scrollbar]:w-2.5 [&_.xterm-viewport::-webkit-scrollbar-track]:bg-transparent","[&_.xterm-viewport::-webkit-scrollbar-thumb]:rounded-full [&_.xterm-viewport::-webkit-scrollbar-thumb]:border-[3px]","[&_.xterm-viewport::-webkit-scrollbar-thumb]:border-transparent [&_.xterm-viewport::-webkit-scrollbar-thumb]:bg-border [&_.xterm-viewport::-webkit-scrollbar-thumb]:bg-clip-content",m)}),!E&&(0,eb.jsx)("div",{className:"pointer-events-none absolute inset-0 grid place-items-center text-muted-foreground ui-text-code",children:p.loading})]})}function eed({status:e="idle"}){return"running"===e?(0,eb.jsx)(een,{className:"size-3.5 text-foreground"}):"success"===e?(0,eb.jsx)(eI,{className:"size-3.5 text-foreground"}):"error"===e?(0,eb.jsx)(eE,{className:"size-3.5 text-destructive"}):(0,eb.jsx)(wk,{className:"size-3.5 text-muted-foreground"})}function eeu({session:e}){return e.aiControlled?(0,eb.jsx)(eer,{className:"size-3.5 text-destructive"}):(0,eb.jsx)(eed,{status:e.status})}function eef({sessions:e,defaultSessions:t=eei,activeSessionId:n,defaultActiveSessionId:r,onActiveSessionChange:a,onSessionsChange:i,onCreateSession:o,onCloseSession:l,onSessionData:s,onSessionResize:c,onSessionReady:d,showTabs:u=!0,allowCreateSession:f=!0,readOnly:m=!1,localEcho:h=!1,terminalOptions:p,labels:g,className:x,tabListClassName:v,terminalClassName:b,...y}){let w=ew.useMemo(()=>({...eea,...g,status:{...eea.status,...g?.status}}),[g]),[j,k]=ew.useState(t),N=e??j,S=N[0],[C,M]=ew.useState(r??S?.id),E=n??(N.some(e=>e.id===C)?C:S?.id),I=N.find(e=>e.id===E)??S;function P(t){void 0===e&&k(t),i?.(t)}function O(e){e.disabled||(void 0===n&&M(e.id),a?.(e.id,e))}return(0,eb.jsxs)("div",{"data-slot":"terminal-tab-group",className:(0,ez.cn)("vtl-surface-panel grid min-h-0 overflow-hidden rounded-[var(--surface-panel-radius)] border",u?"grid-rows-[auto_minmax(0,1fr)]":"grid-rows-[minmax(0,1fr)]",x),...y,children:[u&&(0,eb.jsxs)("div",{"data-slot":"terminal-tab-list",role:"tablist","aria-label":w.terminalList,className:(0,ez.cn)("flex min-w-0 items-center gap-1 border-b bg-muted/35 px-2 py-1.5",v),children:[(0,eb.jsx)(u0,{className:"ml-1 size-4 shrink-0 text-muted-foreground"}),(0,eb.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:N.map(e=>{let t=e.id===I?.id;return(0,eb.jsxs)("div",{className:(0,ez.cn)("group flex h-7 min-w-0 shrink-0 items-center rounded-md border border-transparent ui-text-control","transition-colors hover:bg-background/80",t?"bg-background text-foreground shadow-xs":"text-muted-foreground",e.disabled&&"pointer-events-none opacity-50"),children:[(0,eb.jsxs)("button",{type:"button",role:"tab","aria-selected":t,"aria-controls":`terminal-panel-${e.id}`,disabled:e.disabled,onClick:()=>O(e),className:"flex h-full min-w-0 items-center gap-1.5 rounded-md px-2 text-left outline-none focus-visible:ring-[3px] focus-visible:ring-ring/20",children:[(0,eb.jsx)(eeu,{session:e}),(0,eb.jsx)("span",{className:"max-w-36 truncate",children:e.title}),e.shell&&(0,eb.jsx)("span",{className:"hidden text-muted-foreground ui-text-kbd sm:inline",children:e.shell})]}),e.closable&&(0,eb.jsx)("button",{type:"button","aria-label":w.closeTerminal(e.title),onClick:t=>{t.stopPropagation();l?.(e.id,e);let n=N.filter(t=>t.id!==e.id);if(P(n),e.id===E){let e=n.at(-1);e&&O(e)}},className:"mr-1 grid size-4 place-items-center rounded-sm text-muted-foreground opacity-0 outline-none transition-opacity hover:bg-muted hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/20 group-hover:opacity-100",children:(0,eb.jsx)(fV.XIcon,{className:"size-3"})})]},e.id)})}),f&&(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":w.newTerminal,onClick:function(){let e=o?.()??{id:`terminal-${Date.now()}`,title:`Terminal ${N.length+1}`,status:"idle",initialOutput:"",closable:!0};P([...N,e]),O(e)},className:"size-7 shrink-0",children:(0,eb.jsx)(lY,{className:"size-3.5"})})]}),(0,eb.jsx)("div",{"data-slot":"terminal-tab-panels",className:"relative min-h-0 overflow-hidden",children:N.map(e=>{let t=e.id===I?.id;return(0,eb.jsx)(eem,{session:e,selected:t,terminalOptions:p,readOnly:m,localEcho:h,onSessionData:s,onSessionResize:c,onSessionReady:d,labels:w,terminalClassName:b},e.id)})})]})}function eem({session:e,selected:t,terminalOptions:n,readOnly:r,localEcho:a,onSessionData:i,onSessionResize:o,onSessionReady:l,labels:s,terminalClassName:c}){let d=ew.useRef(null),u=ew.useRef(t);return ew.useEffect(()=>{if(t&&!u.current&&d.current){let e=d.current;requestAnimationFrame(()=>{e&&(e.fit(),e.terminal.refresh(0,e.terminal.rows-1),e.terminal.focus())})}u.current=t},[t]),(0,eb.jsx)("div",{id:`terminal-panel-${e.id}`,role:"tabpanel","aria-hidden":!t,"data-active":t,className:"absolute inset-0 min-h-0",style:{display:t?"block":"none"},children:(0,eb.jsx)(eec,{initialOutput:e.initialOutput,options:{...n,...e.options},readOnly:r||e.disabled,localEcho:a,autoFocus:t,onData:t=>i?.(e.id,t),onResize:t=>o?.(e.id,t),onReady:t=>{d.current=t,l?.(e.id,t)},labels:s,terminalClassName:c})})}function eeh({className:e,scopeId:t,state:n,onStateChange:r}){let[a,i]=ew.useState([]),[o,l]=ew.useState([]),[s,c]=ew.useState(),[d,u]=ew.useState("local"),[f,m]=ew.useState(),[h,p]=ew.useState(!1),[g,x]=ew.useState(!1),v=ew.useRef(new Map),b=ew.useRef(new Map),y=ew.useRef(new Map),w=ew.useRef(new Map),j=ew.useRef(new Map),k=ew.useRef(new Map),N=ew.useRef(new Map),S=ew.useRef(new Map),C=ew.useRef(!1),M=ew.useRef(n?.autoStart===!1),E=ew.useRef(n),I=ew.useRef(r),P=Array.isArray(n?.sessionIds)?n.sessionIds.join("\0"):"__all__",O=t?.trim()||void 0,z=O??"__unscoped__";ew.useEffect(()=>{E.current=n},[n]),ew.useEffect(()=>{I.current=r},[r]);let A=a.find(e=>e.id===d)??a[0],T=A?.shells?.find(e=>e.id===f)??A?.shells?.[0],R=ew.useMemo(()=>o.map(e=>e.id),[o]),D=ew.useMemo(()=>o.filter(e=>e.aiControlled).map(e=>e.id),[o]),_=R.join("\0"),L=D.join("\0"),$=ew.useCallback((e,t)=>{let n=b.current.get(e);if(t){let t=j.current.get(e);void 0!==t&&(window.clearTimeout(t),j.current.delete(e))}n?.setCursorSuppressed(t)},[]),F=ew.useCallback(e=>{let t=j.current.get(e);void 0!==t&&window.clearTimeout(t);let n=window.setTimeout(()=>{j.current.delete(e),$(e,!1)},90);j.current.set(e,n)},[$]),B=ew.useCallback(e=>{let t=w.current.get(e),n=b.current.get(e);if(!t||!n||t.writing)return;if(!t.buffer){w.current.delete(e),F(e);return}void 0!==t.drainTimer&&(window.clearTimeout(t.drainTimer),t.drainTimer=void 0);let r=t.buffer.slice(0,65536);t.buffer=t.buffer.slice(r.length),t.writing=!0,$(e,!0);try{n.write(r,()=>{(t.writing=!1,b.current.has(e))?t.buffer?t.drainTimer=window.setTimeout(()=>B(e),0):(w.current.delete(e),F(e)):w.current.delete(e)})}catch{t.writing=!1,w.current.delete(e),F(e)}},[F,$]),V=ew.useCallback((e,t)=>{if(!t)return;if(!b.current.get(e))return void y.current.set(e,`${y.current.get(e)??""}${t}`);let n=w.current.get(e);(n||(n={buffer:"",writing:!1},w.current.set(e,n)),n.buffer+=t,$(e,!0),n.buffer.length>=65536)?B(e):n.writing||void 0!==n.drainTimer||(n.drainTimer=window.setTimeout(()=>B(e),8))},[B,$]),H=ew.useCallback((e,t)=>{(k.current.set(e,t.sequence),"output"===t.type&&t.data)?V(e,t.data):"status"===t.type&&t.status&&l(n=>n.map(n=>n.id===e?{...n,status:t.status??n.status,updatedAt:t.createdAt}:n))},[V]),U=ew.useCallback(e=>{if(v.current.has(e))return;let t=new EventSource(function(e,t=0){let n=new URLSearchParams;t>0&&n.set("after",String(t));let r=n.toString();return(0,eT.localAPIURL)(`/api/local/terminals/sessions/${encodeURIComponent(e)}/events${r?`?${r}`:""}`)}(e,k.current.get(e)??0));t.onmessage=t=>{try{H(e,JSON.parse(t.data))}catch{return}},v.current.set(e,t)},[H]),q=ew.useCallback(async()=>{if(A&&!h){M.current=!1,p(!0);try{let e=await f_({machineId:A.id,scopeId:O,shell:T?.id,cwd:A.defaultCwd,cols:100,rows:30});l(t=>t.some(t=>t.id===e.id)?t:[...t,e]),c(e.id),U(e.id)}catch{return}finally{p(!1)}}},[h,U,A,T,O]);function W(e){let t=N.current.get(e);return t||(t={buffer:"",inFlight:!1},N.current.set(e,t)),t}return ew.useEffect(()=>{let e=!0;return x(!1),async function(){try{let t=E.current,n=t?.sessionIds,r=Array.isArray(n)?new Set(n):void 0,[a,o]=await Promise.all([fR(),fD(O)]);if(!e)return;let s=r?o.sessions.filter(e=>r.has(e.id)):o.sessions;C.current=!1,M.current=t?.autoStart===!1,i(a.machines),l(s),c(e=>{let n=t?.activeSessionId??e;return n&&s.some(e=>e.id===n)?n:s[0]?.id});let d=a.machines[0];if(d){let e=a.machines.find(e=>e.id===t?.selectedMachineId)??d;u(e.id),m(n=>t?.selectedShellId&&e.shells?.some(e=>e.id===t.selectedShellId)?t.selectedShellId:n&&e.shells?.some(e=>e.id===n)?n:e.shells?.[0]?.id)}}finally{e&&x(!0)}}(),()=>{e=!1}},[P,O,z]),ew.useEffect(()=>{g&&I.current?.({sessionIds:R,activeSessionId:s,selectedMachineId:d,selectedShellId:f,autoStart:!M.current,aiControlledSessionIds:D})},[s,D,L,g,d,f,R,_]),ew.useEffect(()=>{let e=new Set(R);for(let e of o)U(e.id);for(let[t,n]of v.current)e.has(t)||(n.close(),v.current.delete(t))},[U,R,o]),ew.useEffect(()=>{!g||C.current||M.current||o.length>0||0===a.length||(C.current=!0,q())},[q,g,a.length,o.length]),ew.useEffect(()=>()=>{for(let e of v.current.values())e.close();for(let e of N.current.values())void 0!==e.timer&&window.clearTimeout(e.timer);for(let e of w.current.values())void 0!==e.drainTimer&&window.clearTimeout(e.drainTimer);for(let[e,t]of j.current)window.clearTimeout(t),$(e,!1);N.current.clear(),w.current.clear(),j.current.clear()},[$]),(0,eb.jsxs)("div",{className:(0,ez.cn)("grid h-full min-h-0 w-full grid-rows-[auto_minmax(0,1fr)] overflow-hidden rounded-[inherit] border bg-card",e),children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5 border-b bg-muted/35 px-2 py-1.5",children:[(0,eb.jsxs)(gU,{value:A?.id,onValueChange:e=>{u(e);let t=a.find(t=>t.id===e);m(t?.shells?.[0]?.id)},children:[(0,eb.jsxs)(xj,{size:"sm",className:"max-w-44",children:[(0,eb.jsx)(b7,{className:"size-3.5"}),(0,eb.jsx)(gG,{placeholder:"机器"})]}),(0,eb.jsx)(xS,{align:"start",children:a.filter(e=>"online"===e.status).map(e=>(0,eb.jsx)(xC,{value:e.id,children:e.name},e.id))})]}),(0,eb.jsxs)(gU,{value:T?.id,onValueChange:m,children:[(0,eb.jsx)(xj,{size:"sm",className:"max-w-44",children:(0,eb.jsx)(gG,{placeholder:"Shell"})}),(0,eb.jsx)(xS,{align:"start",children:A?.shells?.map(e=>(0,eb.jsx)(xC,{value:e.id,children:e.name},e.id))})]}),(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"新建终端",disabled:!A||h,onClick:()=>void q(),className:"ml-auto",children:(0,eb.jsx)(lY,{className:"size-4"})})]}),(0,eb.jsx)(eef,{sessions:o.map(eep),activeSessionId:s,allowCreateSession:!1,localEcho:!1,labels:{loading:"启动终端...",terminalList:"终端会话",closeTerminal:e=>`关闭 ${e}`},onActiveSessionChange:e=>c(e),onCloseSession:e=>{let t,n,r;return v.current.get(e)?.close(),v.current.delete(e),b.current.delete(e),y.current.delete(e),t=w.current.get(e),t?.drainTimer!==void 0&&window.clearTimeout(t.drainTimer),w.current.delete(e),k.current.delete(e),void 0!==(n=j.current.get(e))&&(window.clearTimeout(n),j.current.delete(e)),r=N.current.get(e),void(r?.timer!==void 0&&window.clearTimeout(r.timer),N.current.delete(e),S.current.delete(e),l(t=>{let n=t.filter(t=>t.id!==e);return 0===n.length&&(M.current=!0),c(t=>t&&t!==e&&n.some(e=>e.id===t)?t:n[0]?.id),n}),fL(e).catch(()=>{}))},onSessionData:function(e,t){let n=W(e);n.buffer+=t,function e(t){let n=W(t);n.inFlight||void 0!==n.timer||(n.timer=window.setTimeout(()=>{n.timer=void 0,function(t){let n=N.current.get(t);if(!n||n.inFlight)return;let r=n.buffer;if(n.buffer="",!r){void 0===n.timer&&N.current.delete(t);return}n.inFlight=!0,f$(t,r).catch(()=>{}).finally(()=>{let n=N.current.get(t);n&&(n.inFlight=!1,n.buffer?e(t):void 0===n.timer&&N.current.delete(t))})}(t)},6))}(e)},onSessionResize:function(e,t){let n=`${t.cols}x${t.rows}`;S.current.get(e)!==n&&(S.current.set(e,n),fF(e,t).then(e=>{l(t=>t.map(t=>t.id===e.id?{...t,...e}:t))}).catch(()=>{}))},onSessionReady:function(e,t){b.current.set(e,t);let n=y.current.get(e);n&&(y.current.delete(e),V(e,n))},className:"min-h-0 rounded-none border-0"})]})}function eep(e){return{id:e.id,title:e.title,shell:e.ordinal?`T${e.ordinal}`:"",cwd:e.cwd,status:function(e){switch(e){case"running":return"running";case"exited":case"closed":return"success";case"failed":return"error";default:return"idle"}}(e.status),closable:!0,initialOutput:"",aiControlled:e.aiControlled,controller:e.controller}}function eeg(e,t={}){let n="h-full min-h-0 w-full overflow-hidden rounded-[inherit]";switch(e.kind){case"file-tab-viewer":{let r=fi("file-tab-viewer"),a=e.file;if(!a&&t.onRequestFileTab)return(0,eb.jsx)(qs,{className:n,onChooseFile:t.onRequestFileTab});return(0,eb.jsx)(X$,{className:`${n} border-0`,file:a??r.file,value:e.defaultValue??r.defaultValue??"",defaultValue:e.defaultValue??r.defaultValue,view:e.defaultView,mode:e.defaultMode,modified:e.modified,onValueChange:n=>t.onTabChange?.({...e,defaultValue:n,modified:!0}),onViewChange:n=>t.onTabChange?.({...e,defaultView:n}),onModeChange:n=>t.onTabChange?.({...e,defaultMode:n}),onSave:t.onSaveFileTab?n=>t.onSaveFileTab?.(e,n):void 0,onHistory:()=>t.onOpenFileHistory?.(e),labels:{review:"审阅",edit:"编辑",view:"视图",code:"代码",preview:"预览",hex:"十六进制",actions:"文件菜单",save:"保存",saving:"保存中",history:"历史版本"}})}case"browser-tab-viewer":return(0,eb.jsx)(Y4,{className:`${n} border-0`,defaultUrl:e.defaultUrl??fi("browser-tab-viewer").defaultUrl});case"diff-tab-viewer":{let t=fi("diff-tab-viewer");return(0,eb.jsx)(WU,{className:`${n} border-0`,file:e.file??t.file,diff:e.diff??t.diff??""})}case"data-table-tab-viewer":{let r=fi("data-table-tab-viewer"),a=e.file;if(!a&&t.onRequestFileTab)return(0,eb.jsx)(qs,{className:n,onChooseFile:t.onRequestFileTab});return(0,eb.jsx)(WA,{className:`${n} border-0`,file:{name:a?.name??r.file?.name??"data",path:a?.path??r.file?.path,type:eex(e)},source:void 0!==e.defaultValue?{type:eex(e),content:e.defaultValue}:void 0,data:e.tableData??r.tableData??[]})}case"terminal-tab-group":return(0,eb.jsx)(eeh,{className:`${n} border-0`,scopeId:t.terminalScopeId,state:e.terminal??t.terminalState,onStateChange:t.onTerminalStateChange})}}function eex(e){return`${e.file?.mimeType??""} ${e.file?.path??e.file?.name??""}`.toLowerCase().includes("json")?"json":"csv"}function eev(e,t={}){let n="h-full min-h-0 w-full overflow-hidden rounded-[inherit]";switch(e){case"multi-tab-system":{let e=t.nodeId,r=void 0!==t.tabs?t.tabs:[];return(0,eb.jsx)(XH,{className:n,contentClassName:"min-h-0",tabs:r.map(n=>({id:n.id,title:n.title,meta:n.meta,modified:n.modified,icon:fa(n.kind),content:eeg(n,{terminalScopeId:e?`${t.terminalScopeId??`canvas:node:${e}`}:tab:${n.id}`:t.terminalScopeId,terminalState:n.terminal,onTerminalStateChange:r=>e?t.onTabChange?.(e,{...n,terminal:r}):void 0,onRequestFileTab:()=>t.onRequestFileTab?.({nodeId:e,insertIndex:r.length}),onTabChange:n=>{e&&t.onTabChange?.(e,n)},onSaveFileTab:(n,r)=>e?t.onSaveFileTab?.(e,n,r):void 0,onOpenFileHistory:n=>e?t.onOpenFileHistory?.(e,n):void 0})})),activeTabId:t.activeTabId,detachable:!0,externalDropTypes:[qd],createLabel:"打开文件",emptyContent:(0,eb.jsx)(qs,{onChooseFile:()=>t.onRequestFileTab?.({nodeId:e,insertIndex:r.length})}),onCreateTab:()=>{t.onRequestFileTab?.({nodeId:e,insertIndex:r.length})},onActiveTabChange:n=>{e&&t.onActiveTabChange?.(e,n)},onTabsChange:n=>{if(!e)return;let a=n.map(e=>r.find(t=>t.id===e.id)).filter(e=>!!e);t.onTabsChange?.(e,a)},onTabDetach:(n,a)=>{if(!e)return!1;let i=r.find(e=>e.id===n.id);return!!i&&t.onTabDetach?.(e,i,{clientX:a.clientX,clientY:a.clientY})},onExternalTabDrop:({insertIndex:n,nativeEvent:r})=>{e&&t.onExternalTabDrop?.(e,n,r)}})}case"file-tree-panel":if(t.workspaceFolders)return(0,eb.jsx)(qo,{folders:t.workspaceFolders,className:`${n} max-w-none`,onOpenFile:t.onOpenWorkspaceFile});return(0,eb.jsx)(ZN,{className:`${n} max-w-none`,onOpenFile:t.onOpenWorkspaceFile});case"process-management":return(0,eb.jsx)(Q7,{className:`${n} rounded-[inherit] border-0`});case"machine-performance":return(0,eb.jsx)(Q9,{className:`${n} rounded-[inherit] border-0`});case"firewall-policy-workspace":return(0,eb.jsx)("div",{className:`${n} bg-card`,children:(0,eb.jsx)(Zw,{})});case"machine-file-management":return(0,eb.jsx)(ZJ,{className:`${n} bg-card`});case"agent-conversation-panel":return(0,eb.jsx)(UL,{className:`${n} vtl-canvas-agent-conversation-node`,composerClassName:"max-w-[42rem]"});case"status-monitor":return(0,eb.jsx)(Y$,{conversationId:t.conversationId,ownerMachineId:t.ownerMachineId});case"plan-doc-viewer":return(0,eb.jsx)(Yo,{conversationId:t.conversationId,ownerMachineId:t.ownerMachineId});case"spec-doc-viewer":return(0,eb.jsx)(Yl,{conversationId:t.conversationId,ownerMachineId:t.ownerMachineId});case"tasks-pane":return(0,eb.jsx)(YB,{conversationId:t.conversationId,ownerMachineId:t.ownerMachineId});case"hooks-pane":return(0,eb.jsx)(Yf,{conversationId:t.conversationId,ownerMachineId:t.ownerMachineId});case"sidequery-pane":return(0,eb.jsx)(Yx,{conversationId:t.conversationId,ownerMachineId:t.ownerMachineId,nodeId:t.nodeId,binding:t.sideQueryBinding,onBind:e=>t.nodeId&&t.onSideQueryBind?.(t.nodeId,e)});case"file-tab-viewer":case"browser-tab-viewer":case"diff-tab-viewer":case"data-table-tab-viewer":case"terminal-tab-group":return eeg(t.tab??fi(e,`${e}-tab`),{terminalState:t.terminalState,terminalScopeId:t.terminalScopeId,onTerminalStateChange:t.onTerminalStateChange,onRequestFileTab:()=>t.onRequestFileTab?.({nodeId:t.nodeId}),onTabChange:e=>{t.nodeId&&t.onTabChange?.(t.nodeId,e)},onSaveFileTab:(e,n)=>t.nodeId?t.onSaveFileTab?.(t.nodeId,e,n):void 0,onOpenFileHistory:e=>t.nodeId?t.onOpenFileHistory?.(t.nodeId,e):void 0})}}function eeb({kind:e,...t}){return eev(e,t)}function eey(e){let t=Number.isFinite(e)?Math.max(0,e):0;return t>=1e6?`${(t/1e6).toFixed(t>=1e7?0:1)}M`:t>=1e3?`${Math.round(t/1e3)}K`:t.toLocaleString()}function eew({data:e,className:t}){let n=Math.max(0,e.used),r=Math.max(0,e.total),a=r>0?Math.min(100,Math.round(n/r*100)):0,i=e.categories.filter(e=>e.estTokens>0);return(0,eb.jsxs)("div",{className:(0,ez.cn)("flex size-full min-h-0 flex-col gap-3 overflow-hidden bg-card p-3",t),children:[(0,eb.jsxs)("div",{className:"shrink-0 space-y-1.5",children:[(0,eb.jsxs)("div",{className:"flex items-baseline justify-between text-xs",children:[(0,eb.jsx)("span",{className:"font-medium text-foreground",children:"上下文占用"}),(0,eb.jsxs)("span",{className:"text-muted-foreground",children:[eey(n)," / ",eey(r)," · ",a,"%"]})]}),(0,eb.jsx)("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:(0,eb.jsx)("div",{className:"h-full rounded-full bg-foreground transition-[width]",style:{width:`${a}%`}})}),(0,eb.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"下方明细为按字符数估算(估算),非精确 token 统计。"})]}),i.length>0?(0,eb.jsx)("div",{className:"shrink-0 space-y-1",children:i.map(e=>(0,eb.jsxs)("div",{className:"flex items-center justify-between rounded-md bg-muted/40 px-2 py-1 text-xs",children:[(0,eb.jsx)("span",{className:"text-muted-foreground",children:e.label}),(0,eb.jsxs)("span",{className:"font-medium tabular-nums",children:["约 ",eey(e.estTokens),(0,eb.jsx)("span",{className:"ml-1 text-[10px] text-muted-foreground",children:"估算"})]})]},e.key))}):null,(0,eb.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,eb.jsxs)("div",{className:"flex shrink-0 items-baseline justify-between pb-1 text-xs",children:[(0,eb.jsx)("span",{className:"font-medium text-foreground",children:"上下文中的文件"}),(0,eb.jsxs)("span",{className:"text-muted-foreground",children:[e.files.length," 个"]})]}),(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto rounded-md border",children:0===e.files.length?(0,eb.jsx)("div",{className:"grid h-full place-items-center p-4 text-center text-xs text-muted-foreground",children:"本轮暂无被读取/检索的文件进入上下文。"}):(0,eb.jsx)("ul",{className:"divide-y",children:e.files.map(e=>{let t,n;return(0,eb.jsxs)("li",{className:"flex items-center gap-2 px-2 py-1.5 text-xs",title:e.path,children:[(0,eb.jsx)(uX,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,eb.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eb.jsx)("div",{className:"truncate font-medium text-foreground",children:(t=e.path.replace(/[\\/]+$/,""),n=/([^\\/]+)$/.exec(t),n?.[1]??t)}),(0,eb.jsx)("div",{className:"truncate text-[11px] text-muted-foreground",children:e.path})]}),(0,eb.jsxs)("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:["约 ",eey(e.estTokens),(0,eb.jsx)("span",{className:"ml-1 text-[10px]",children:"估算"})]})]},`${e.machineId??"local"}:${e.path}`)})})})]})]})}let eej="application/vnd.vantaloom.agent-pane-shredder",eek="application/vnd.vantaloom.agent-pane-cutter";function eeN({content:e}){return kA(e)?(0,eb.jsx)("button",{type:"button",draggable:!0,"aria-label":"拖拽到对话框作为附件",title:"拖拽到对话框作为附件",onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),onDragStart:t=>{t.stopPropagation(),t.dataTransfer.setData(qf,qh({kind:e.kind,title:e.title,tab:e.tab})),t.dataTransfer.effectAllowed="copy"},className:"grid size-5 shrink-0 cursor-grab place-items-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground active:cursor-grabbing [&_svg]:size-3.5",children:(0,eb.jsx)(kF,{})}):null}function eeS(e,t){return(e?.activeSessionId??"")===(t.activeSessionId??"")&&(e?.selectedMachineId??"")===(t.selectedMachineId??"")&&(e?.selectedShellId??"")===(t.selectedShellId??"")&&(e?.autoStart??!0)===(t.autoStart??!0)&&(e?.sessionIds??[]).join("\0")===t.sessionIds.join("\0")&&(e?.aiControlledSessionIds??[]).join("\0")===(t.aiControlledSessionIds??[]).join("\0")}let eeC=[{id:"quad",label:"四分",slots:4,icon:(0,eb.jsx)(b8,{})},{id:"vertical-split",label:"上下二分",slots:2,icon:(0,eb.jsx)(qR,{})},{id:"horizontal-split",label:"左右二分",slots:2,icon:(0,eb.jsx)(qE,{})},{id:"left-two-right-one",label:"左二右一",slots:3,icon:(0,eb.jsx)(cy,{})},{id:"left-one-right-two",label:"左一右二",slots:3,icon:(0,eb.jsx)(cj,{})},{id:"top-two-bottom-one",label:"上二下一",slots:3,icon:(0,eb.jsx)(qR,{})},{id:"top-one-bottom-two",label:"上一下二",slots:3,icon:(0,eb.jsx)(qT,{})},{id:"single",label:"整窗口",slots:1,icon:(0,eb.jsx)(qA,{})}];function eeM(e,t,n=[50,50]){let r=e?.[t],a=r?.[0],i=r?.[1];return["number"==typeof a&&a>0?a:n[0],"number"==typeof i&&i>0?i:n[1]]}function eeE(e,t){return{[e[0]]:t[0],[e[1]]:t[1]}}function eeI(e,t){return[e[t[0]]??50,e[t[1]]??50]}function eeP({mode:e,sizes:t,onSizeGroupChange:n,children:r}){if("single"===e)return(0,eb.jsx)("div",{className:"size-full min-h-0",children:r[0]});if("horizontal-split"===e){let e=eeM(t,"outer"),a=["pane-0","pane-1"];return(0,eb.jsxs)(mX,{direction:"horizontal",defaultLayout:eeE(a,e),onLayoutChanged:e=>n?.("outer",eeI(e,a)),children:[(0,eb.jsx)(mY,{id:a[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:a[1],defaultSize:e[1],minSize:24,children:r[1]})]})}if("vertical-split"===e){let e=eeM(t,"outer"),a=["pane-0","pane-1"];return(0,eb.jsxs)(mX,{direction:"vertical",defaultLayout:eeE(a,e),onLayoutChanged:e=>n?.("outer",eeI(e,a)),children:[(0,eb.jsx)(mY,{id:a[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:a[1],defaultSize:e[1],minSize:24,children:r[1]})]})}if("left-two-right-one"===e){let e=eeM(t,"outer",[58,42]),a=eeM(t,"left"),i=["left","right"],o=["pane-0","pane-1"];return(0,eb.jsxs)(mX,{direction:"horizontal",defaultLayout:eeE(i,e),onLayoutChanged:e=>n?.("outer",eeI(e,i)),children:[(0,eb.jsx)(mY,{id:i[0],defaultSize:e[0],minSize:24,children:(0,eb.jsxs)(mX,{direction:"vertical",defaultLayout:eeE(o,a),onLayoutChanged:e=>n?.("left",eeI(e,o)),children:[(0,eb.jsx)(mY,{id:o[0],defaultSize:a[0],minSize:20,children:r[0]}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:o[1],defaultSize:a[1],minSize:20,children:r[1]})]})}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:i[1],defaultSize:e[1],minSize:24,children:r[2]})]})}if("left-one-right-two"===e){let e=eeM(t,"outer",[42,58]),a=eeM(t,"right"),i=["left","right"],o=["pane-1","pane-2"];return(0,eb.jsxs)(mX,{direction:"horizontal",defaultLayout:eeE(i,e),onLayoutChanged:e=>n?.("outer",eeI(e,i)),children:[(0,eb.jsx)(mY,{id:i[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:i[1],defaultSize:e[1],minSize:24,children:(0,eb.jsxs)(mX,{direction:"vertical",defaultLayout:eeE(o,a),onLayoutChanged:e=>n?.("right",eeI(e,o)),children:[(0,eb.jsx)(mY,{id:o[0],defaultSize:a[0],minSize:20,children:r[1]}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:o[1],defaultSize:a[1],minSize:20,children:r[2]})]})})]})}if("top-two-bottom-one"===e){let e=eeM(t,"outer",[58,42]),a=eeM(t,"top"),i=["top","bottom"],o=["pane-0","pane-1"];return(0,eb.jsxs)(mX,{direction:"vertical",defaultLayout:eeE(i,e),onLayoutChanged:e=>n?.("outer",eeI(e,i)),children:[(0,eb.jsx)(mY,{id:i[0],defaultSize:e[0],minSize:24,children:(0,eb.jsxs)(mX,{direction:"horizontal",defaultLayout:eeE(o,a),onLayoutChanged:e=>n?.("top",eeI(e,o)),children:[(0,eb.jsx)(mY,{id:o[0],defaultSize:a[0],minSize:24,children:r[0]}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:o[1],defaultSize:a[1],minSize:24,children:r[1]})]})}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:i[1],defaultSize:e[1],minSize:24,children:r[2]})]})}if("top-one-bottom-two"===e){let e=eeM(t,"outer",[42,58]),a=eeM(t,"bottom"),i=["top","bottom"],o=["pane-1","pane-2"];return(0,eb.jsxs)(mX,{direction:"vertical",defaultLayout:eeE(i,e),onLayoutChanged:e=>n?.("outer",eeI(e,i)),children:[(0,eb.jsx)(mY,{id:i[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:i[1],defaultSize:e[1],minSize:24,children:(0,eb.jsxs)(mX,{direction:"horizontal",defaultLayout:eeE(o,a),onLayoutChanged:e=>n?.("bottom",eeI(e,o)),children:[(0,eb.jsx)(mY,{id:o[0],defaultSize:a[0],minSize:24,children:r[1]}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:o[1],defaultSize:a[1],minSize:24,children:r[2]})]})})]})}let a=eeM(t,"outer"),i=eeM(t,"left"),o=eeM(t,"right"),l=["left","right"],s=["pane-0","pane-2"],c=["pane-1","pane-3"];return(0,eb.jsxs)(mX,{direction:"horizontal",defaultLayout:eeE(l,a),onLayoutChanged:e=>n?.("outer",eeI(e,l)),children:[(0,eb.jsx)(mY,{id:l[0],defaultSize:a[0],minSize:24,children:(0,eb.jsxs)(mX,{direction:"vertical",defaultLayout:eeE(s,i),onLayoutChanged:e=>n?.("left",eeI(e,s)),children:[(0,eb.jsx)(mY,{id:s[0],defaultSize:i[0],minSize:20,children:r[0]}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:s[1],defaultSize:i[1],minSize:20,children:r[2]})]})}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:l[1],defaultSize:a[1],minSize:24,children:(0,eb.jsxs)(mX,{direction:"vertical",defaultLayout:eeE(c,o),onLayoutChanged:e=>n?.("right",eeI(e,c)),children:[(0,eb.jsx)(mY,{id:c[0],defaultSize:o[0],minSize:20,children:r[1]}),(0,eb.jsx)(mZ,{withHandle:!0}),(0,eb.jsx)(mY,{id:c[1],defaultSize:o[1],minSize:20,children:r[3]})]})})]})}function eeO({conversationId:e,ownerMachineId:t,index:n,content:r,clipboardItems:a,clipboardDraggingId:i,onAdd:o,onPanelDrop:l,onContentChange:s,onClear:c,onCut:d,workspaceFolders:u,onRequestFileTab:f,onOpenWorkspaceFile:m,onSaveFileTab:h,onOpenFileHistory:p}){let[g,x]=ew.useState();return(0,eb.jsx)("div",{"data-agent-pane":n,className:(0,ez.cn)("relative size-full min-h-0 min-w-0 overflow-hidden",r?.kind!=="subagent-conversation-panel"&&"bg-background","vtl-agent-workspace-pane",r?.kind==="subagent-conversation-panel"&&"vtl-agent-workspace-conversation-pane bg-transparent","panel"===g&&"ring-2 ring-foreground/60 ring-inset","shredder"===g&&"ring-2 ring-destructive/70 ring-inset","cutter"===g&&"ring-2 ring-amber-500/70 ring-inset"),onDragOver:e=>{let t=Array.from(e.dataTransfer.types);if(t.includes(eek)){e.preventDefault(),e.dataTransfer.dropEffect="move",x("cutter");return}if(t.includes(eej)){e.preventDefault(),e.dataTransfer.dropEffect="move",x("shredder");return}t.includes(kT)&&(e.preventDefault(),e.dataTransfer.dropEffect="move",x("panel"))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||x(void 0)},onDrop:e=>{if(Array.from(e.dataTransfer.types).includes(eek)){e.preventDefault(),e.stopPropagation(),x(void 0),d(n);return}if(Array.from(e.dataTransfer.types).includes(eej)){e.preventDefault(),e.stopPropagation(),x(void 0),c(n);return}let t=function(e){let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id"),n=a.find(e=>e.id===t),r=n?n.payloads?.[kT]:void 0;if(n&&r)return{item:n,content:r.content};let i=e.dataTransfer.getData(kT);if(i)try{let e=JSON.parse(i);return n&&e.content?{item:n,content:e.content}:void 0}catch{return}}(e);t&&(e.preventDefault(),e.stopPropagation(),x(void 0),l(n,t.item,t.content))},children:r?(0,eb.jsx)("div",{className:(0,ez.cn)("size-full min-h-0 min-w-0 overflow-hidden rounded-none","vtl-agent-pane-content","subagent-conversation-panel"===r.kind&&"vtl-agent-pane-conversation-content",i&&"pointer-events-none"),children:kA(r)?eev(r.kind,{tab:r.tab,conversationId:e,ownerMachineId:t,terminalScopeId:e?`agent:${e}:pane:${r.id}`:void 0,terminalState:r.terminal,onTerminalStateChange:e=>{eeS(r.terminal,e)||s(n,{...r,terminal:e})},workspaceFolders:u,nodeId:r.id,tabs:r.tabs,activeTabId:r.activeTabId,sideQueryBinding:r.sideQuery,onSideQueryBind:(e,t)=>s(n,{...r,sideQuery:t}),onRequestFileTab:({insertIndex:e})=>f?.(n,e),onOpenWorkspaceFile:m,onTabsChange:(e,t)=>{s(n,{...r,tabs:t,activeTabId:t.some(e=>e.id===r.activeTabId)?r.activeTabId:t[0]?.id})},onTabChange:(e,t)=>{"multi-tab-system"===r.kind?s(n,{...r,tabs:(r.tabs??[]).map(e=>e.id===t.id?t:e),activeTabId:t.id}):s(n,{...r,title:t.title,tab:t})},onSaveFileTab:(e,t,r)=>h?.(n,t,r),onOpenFileHistory:(e,t)=>p?.(n,t),onActiveTabChange:(e,t)=>{s(n,{...r,activeTabId:t})}}):"context-breakdown"===r.kind?(0,eb.jsx)(eew,{data:r.data}):(0,eb.jsx)(UL,{className:"size-full min-h-0",composerClassName:"max-w-[42.5rem]",initialEvents:r.events},r.id)},r.id):(0,eb.jsx)("div",{className:"vtl-agent-pane-empty grid size-full place-items-center p-4",children:(0,eb.jsxs)(eO.Button,{type:"button",variant:"outline",size:"sm",className:"rounded-full bg-background/90",onClick:o,"data-tour":"pane-add",children:[(0,eb.jsx)(lY,{className:"size-4"}),"添加"]})})})}function eez({open:e,onOpenChange:t,onAdd:n}){let r=eeT.map(e=>kO(e.kind)).filter(e=>!!e);return(0,eb.jsx)(bm,{open:e,onOpenChange:t,title:"添加工作区组件",description:"选择一个组件填入当前窗口。",className:"top-1/2 max-w-xl -translate-y-1/2",children:(0,eb.jsxs)(bf,{loop:!0,children:[(0,eb.jsx)(bh,{placeholder:"搜索组件..."}),(0,eb.jsxs)(bp,{children:[(0,eb.jsx)(bg,{children:"没有匹配组件。"}),(0,eb.jsx)(bx,{heading:"可放入窗口",children:r.map(e=>(0,eb.jsxs)(bv,{"data-tour":`pane-template-${e.id}`,value:`${e.title} ${e.description} ${e.keywords}`,onSelect:()=>n(e.id),children:[(0,eb.jsx)("span",{className:"grid size-8 shrink-0 place-items-center rounded-lg border bg-background text-muted-foreground",children:e.icon}),(0,eb.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,eb.jsx)("span",{className:"block truncate text-sm font-medium",children:e.title}),(0,eb.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,eb.jsx)(bb,{children:"添加"})]},e.id))})]})]})})}function eeA({content:e,index:t,conversationId:n,ownerMachineId:r,workspaceFolders:a,onContentChange:i,onOpenWorkspaceFile:o,onSaveFileTab:l,onOpenFileHistory:s,onRequestFileTab:c}){return"context-breakdown"===e.kind?(0,eb.jsx)(eew,{data:e.data}):kA(e)?eev(e.kind,{tab:e.tab,conversationId:n,ownerMachineId:r,terminalScopeId:n?`agent:${n}:pane:${e.id}`:void 0,terminalState:e.terminal,onTerminalStateChange:n=>{eeS(e.terminal,n)||i(t,{...e,terminal:n})},workspaceFolders:a,nodeId:e.id,tabs:e.tabs,activeTabId:e.activeTabId,sideQueryBinding:e.sideQuery,onSideQueryBind:(n,r)=>i(t,{...e,sideQuery:r}),onRequestFileTab:({insertIndex:e})=>c?.(t,e),onOpenWorkspaceFile:o,onTabsChange:(n,r)=>{i(t,{...e,tabs:r,activeTabId:r.some(t=>t.id===e.activeTabId)?e.activeTabId:r[0]?.id})},onTabChange:(n,r)=>{"multi-tab-system"===e.kind?i(t,{...e,tabs:(e.tabs??[]).map(e=>e.id===r.id?r:e),activeTabId:r.id}):i(t,{...e,title:r.title,tab:r})},onSaveFileTab:(e,n,r)=>l?.(t,n,r),onOpenFileHistory:(e,n)=>s?.(t,n),onActiveTabChange:(n,r)=>{i(t,{...e,activeTabId:r})}}):(0,eb.jsx)(UL,{className:"size-full min-h-0",composerClassName:"max-w-[42.5rem]",initialEvents:e.events},e.id)}let eeT=[{kind:"status-monitor",label:"状态监控",icon:(0,eb.jsx)(uV,{})},{kind:"sidequery-pane",label:"旁问",icon:(0,eb.jsx)(uJ,{})},{kind:"hooks-pane",label:"Hook",icon:(0,eb.jsx)(u2,{})},{kind:"plan-doc-viewer",label:"计划文档",icon:(0,eb.jsx)(uq,{})},{kind:"spec-doc-viewer",label:"规范文档",icon:(0,eb.jsx)(qP,{})},{kind:"browser-tab-viewer",label:"预览窗口",icon:(0,eb.jsx)(qz,{})},{kind:"diff-tab-viewer",label:"Diff 栏",icon:(0,eb.jsx)(qI,{})},{kind:"terminal-tab-group",label:"终端窗口",icon:(0,eb.jsx)(u0,{})},{kind:"file-tree-panel",label:"文件树",icon:(0,eb.jsx)(qO,{})},{kind:"file-tab-viewer",label:"文件窗口",icon:(0,eb.jsx)(uX,{})}];function eeR(e,t,n){return Math.min(n,Math.max(t,e))}function eeD({onAddCard:e,align:t="end"}){return(0,eb.jsxs)(wA,{children:[(0,eb.jsx)(wR,{asChild:!0,children:(0,eb.jsxs)(eO.Button,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",children:[(0,eb.jsx)(lY,{className:"size-4"}),"添加窗口",(0,eb.jsx)(pt,{className:"size-3.5 text-muted-foreground"})]})}),(0,eb.jsx)(wG,{align:t,sideOffset:6,className:"min-w-40",children:eeT.map(t=>(0,eb.jsxs)(wX,{onSelect:()=>e(t.kind),children:[t.icon,(0,eb.jsx)("span",{className:"flex-1",children:t.label})]},t.kind))})]})}function ee_({conversationId:e,ownerMachineId:t,panes:n,agentSide:r,columns:a,heights:i,onColumnsChange:o,onHeightsChange:l,onAddCard:s,onContentChange:c,onClear:d,workspaceFolders:u,onOpenWorkspaceFile:f,onSaveFileTab:m,onOpenFileHistory:h,onRequestFileTab:p}){let g=n.map((e,t)=>({content:e,index:t})).filter(e=>!!e.content),x=new Map(g.map(e=>[e.content.id,e])),v=g.map(e=>e.content.id).join("|"),b="left"===r,y=ew.useRef(0);0===y.current&&a.length>0&&(y.current=a.reduce((e,t)=>{let n=/^col-(\d+)/.exec(t.key);return n?Math.max(e,Number(n[1])):e},0));let w=ew.useCallback(()=>`col-${y.current+=1}`,[]),j=e=>o("function"==typeof e?e(a):e),k=e=>l("function"==typeof e?e(i):e),[N,S]=ew.useState(null),[C,M]=ew.useState(null),[E,I]=ew.useState(null),P=ew.useRef(null),O=ew.useRef(null),z=ew.useRef(null),A=ew.useRef(null);ew.useEffect(()=>{let e={};j(t=>{let n=new Set(g.map(e=>e.content.id)),r=t.map(e=>({...e,cardIds:e.cardIds.filter(e=>n.has(e))})).filter(e=>e.cardIds.length>0),a=new Set(r.flatMap(e=>e.cardIds)),o=g.map(e=>e.content.id).filter(e=>!a.has(e));if(o.length>0){r=r.map(e=>({...e,cardIds:[...e.cardIds]}));let t=P.current?.clientHeight??0,n=t=>t.cardIds.reduce((t,n,r)=>t+(e[n]??i[n]??320)+12*(r>0),0);for(let a of o){let i=!1;if(t>0)for(let o of r){let r=12*(o.cardIds.length>0),l=t-n(o)-r;if(l>=320){o.cardIds.push(a),i=!0;break}if(l>=140){o.cardIds.push(a),e[a]=Math.floor(l),i=!0;break}}i||(0===r.length||t>0?r.push({key:w(),width:360,cardIds:[a]}):r[0].cardIds.push(a))}}return!function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],a=t[n];if(!r||!a||r.key!==a.key||r.width!==a.width||r.cardIds.length!==a.cardIds.length)return!1;for(let e=0;e<r.cardIds.length;e+=1)if(r.cardIds[e]!==a.cardIds[e])return!1}return!0}(t,r)?r:t}),Object.keys(e).length>0&&k(t=>({...t,...e}))},[v,w]);let T=e=>i[e]??320;ew.useEffect(()=>{if(!N)return;let e=e=>{O.current?function(e,t){let n=P.current,r=O.current;if(!n||!r)return;let a=Array.from(n.querySelectorAll("[data-card-id]")),i=null,o=null,l=1/0;for(let n of a){let a=n.dataset.cardId;if(!a||a===r)continue;let s=n.getBoundingClientRect(),c=Math.max(s.left-e,0,e-s.right),d=Math.max(s.top-t,0,t-s.bottom),u=c*c+d*d;u<l&&(l=u,i=a,o=s)}if(!i||!o){z.current=null,I(null);return}let s=e-o.left,c=o.right-e,d=t-o.top,u=o.bottom-t,f=Math.min(s,c,d,u),m=f===d?"top":f===u?"bottom":f===s?"left":"right";z.current={id:i,edge:m};let h=n.getBoundingClientRect();I(function(e,t){switch(t){case"top":return{left:e.left,top:e.top-6-2,width:e.width,height:4};case"bottom":return{left:e.left,top:e.top+e.height+6-2,width:e.width,height:4};case"left":return{left:e.left-6-2,top:e.top,width:4,height:e.height};case"right":return{left:e.left+e.width+6-2,top:e.top,width:4,height:e.height}}}({left:o.left-h.left,top:o.top-h.top,width:o.width,height:o.height},m))}(e.clientX,e.clientY):A.current&&function(e,t){let n=A.current;if(!n)return;if("width"===n.kind){let t=eeR(n.startWidth+(e-n.startX)*n.factor,240,760);j(e=>e.map(e=>e.key===n.columnKey?{...e,width:t}:e));return}if("growHeight"===n.kind){let e=Math.max(140,n.h0+(t-n.startY));k(t=>({...t,[n.cardId]:e}));return}let r=n.hA+n.hB,a=eeR(n.hA+(t-n.startY),140,r-140);k(e=>({...e,[n.aboveId]:a,[n.belowId]:r-a}))}(e.clientX,e.clientY)},t=()=>(function(){let e=O.current;if(e){var t,n;let r=z.current;O.current=null,z.current=null,M(null),I(null),S(null),r&&(t=r.id,n=r.edge,e&&e!==t&&j(r=>{let a=r.map(e=>({...e,cardIds:[...e.cardIds]}));for(let t of a){let n=t.cardIds.indexOf(e);n>=0&&t.cardIds.splice(n,1)}let i=-1,o=-1;a.forEach((e,n)=>{let r=e.cardIds.indexOf(t);r>=0&&(i=n,o=r)});let l=a[i];if(!l)return r;if("top"===n||"bottom"===n)l.cardIds.splice("top"===n?o:o+1,0,e);else{let t=(b?"right"===n:"left"===n)?i:i+1;a.splice(t,0,{key:w(),width:a[i]?.width??360,cardIds:[e]})}return a.filter(e=>e.cardIds.length>0)}));return}A.current&&(A.current=null,S(null))})();return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),window.addEventListener("pointercancel",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t),window.removeEventListener("pointercancel",t)}},[N]);let R=a.map((e,t)=>({column:e,realIndex:t}));b&&R.reverse();let D=(0,eb.jsx)("div",{className:(0,ez.cn)("flex shrink-0 px-3 py-2",b?"justify-end":"justify-start"),children:(0,eb.jsx)(eeD,{onAddCard:s,align:b?"end":"start"})});return 0===g.length?null:(0,eb.jsxs)("div",{className:"relative flex h-full min-h-0 flex-col",children:[D,(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-auto px-3 pb-3",children:(0,eb.jsxs)("div",{ref:P,className:"relative flex min-h-full items-start gap-3",children:[R.map(({column:n})=>{let r=[],i=0;for(let e=0;e<n.cardIds.length;e+=1)i+=T(n.cardIds[e]),e<n.cardIds.length-1&&(r.push(i+6),i+=12);let o=i,l=n.cardIds[n.cardIds.length-1],s=1===n.cardIds.length&&x.get(n.cardIds[0])?.content.kind==="status-monitor";return(0,eb.jsxs)("div",{className:(0,ez.cn)("relative flex shrink-0 flex-col gap-3",s&&"h-full"),style:{width:n.width},children:[n.cardIds.map(n=>{let r=x.get(n);if(!r)return null;let{content:a,index:i}=r;return(0,eb.jsxs)("div",{"data-card-id":a.id,style:s?void 0:{height:T(a.id)},className:(0,ez.cn)("group/card relative flex w-full flex-col overflow-hidden rounded-xl border border-border bg-background shadow-sm",s?"min-h-0 flex-1":"shrink-0",C===a.id?"opacity-40":"opacity-100"),children:[(0,eb.jsxs)("div",{onPointerDown:e=>{var t;return t=a.id,void(0===e.button&&(e.preventDefault(),e.stopPropagation(),O.current=t,z.current=null,M(t),I(null),S("drag")))},className:"flex shrink-0 cursor-grab touch-none select-none items-center justify-between gap-2 border-b border-border/60 px-2.5 py-1.5 active:cursor-grabbing",children:[(0,eb.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[(0,eb.jsx)(fX,{className:"size-3.5 shrink-0 text-muted-foreground/60"}),(0,eb.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:a.title})]}),(0,eb.jsxs)("span",{className:"flex shrink-0 items-center gap-1",children:[(0,eb.jsx)(eeN,{content:a}),(0,eb.jsx)("button",{type:"button",onPointerDown:e=>e.stopPropagation(),onClick:()=>d(i),"aria-label":"关闭窗口",title:"关闭窗口",className:"grid size-5 shrink-0 place-items-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-3.5",children:(0,eb.jsx)(fV.XIcon,{})})]})]}),(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden",children:(0,eb.jsx)(eeA,{content:a,index:i,conversationId:e,ownerMachineId:t,workspaceFolders:u,onContentChange:c,onOpenWorkspaceFile:f,onSaveFileTab:m,onOpenFileHistory:h,onRequestFileTab:p})})]},a.id)}),n.cardIds.slice(0,-1).map((e,t)=>(0,eb.jsx)("div",{"aria-hidden":!0,onPointerDown:r=>{var a;return a=n.cardIds[t+1],void(0===r.button&&(r.preventDefault(),r.stopPropagation(),A.current={kind:"height",aboveId:e,belowId:a,startY:r.clientY,hA:T(e),hB:T(a)},S("resize")))},style:{top:r[t]??0},className:"group/hbar absolute inset-x-0 z-10 flex h-3 -translate-y-1/2 cursor-ns-resize items-center justify-center",children:(0,eb.jsx)("span",{className:"h-1 w-12 rounded-full bg-muted-foreground/40 opacity-0 transition-opacity group-hover/hbar:opacity-100"})},`hbar-${e}`)),l&&!s?(0,eb.jsx)("div",{"aria-hidden":!0,onPointerDown:e=>{0===e.button&&(e.preventDefault(),e.stopPropagation(),A.current={kind:"growHeight",cardId:l,startY:e.clientY,h0:T(l)},S("resize"))},style:{top:o+6},className:"group/hbar absolute inset-x-0 z-10 flex h-3 -translate-y-1/2 cursor-ns-resize items-center justify-center",children:(0,eb.jsx)("span",{className:"h-1 w-12 rounded-full bg-muted-foreground/40 opacity-0 transition-opacity group-hover/hbar:opacity-100"})}):null,(0,eb.jsx)("div",{"aria-hidden":!0,onPointerDown:e=>(function(e,t){if(0!==t.button)return;t.preventDefault(),t.stopPropagation();let n=a.find(t=>t.key===e)?.width??360;A.current={kind:"width",columnKey:e,startX:t.clientX,startWidth:n,factor:b?-1:1},S("resize")})(n.key,e),style:b?{left:-6}:{right:-6},className:(0,ez.cn)("group/wbar absolute inset-y-0 z-10 flex w-3 cursor-ew-resize items-center justify-center",b?"-translate-x-1/2":"translate-x-1/2"),children:(0,eb.jsx)("span",{className:"h-12 w-1 rounded-full bg-muted-foreground/40 opacity-0 transition-opacity group-hover/wbar:opacity-100"})})]},n.key)}),E?(0,eb.jsx)("div",{"aria-hidden":!0,className:"pointer-events-none absolute z-40 rounded-full bg-muted-foreground/70",style:{left:E.left,top:E.top,width:E.width,height:E.height}}):null]})}),N?(0,eb.jsx)("div",{"aria-hidden":!0,className:"absolute inset-0 z-50",style:{cursor:"drag"===N?"grabbing":A.current?.kind==="width"?"ew-resize":"ns-resize"}}):null]})}let eeL="vtl:workspace-layout-mode",ee$="vtl:workspace-agent-side",eeF="vtl:workspace-layout-changed",eeB={mode:"pane",agentSide:"left"};function eeV(){let e=eeB.mode,t=eeB.agentSide;try{let n=window.localStorage.getItem(eeL);("pane"===n||"card"===n||"control-room"===n)&&(e=n);let r=window.localStorage.getItem(ee$);("left"===r||"right"===r)&&(t=r)}catch{}return{mode:e,agentSide:t}}function eeH(e){try{e.mode&&window.localStorage.setItem(eeL,e.mode),e.agentSide&&window.localStorage.setItem(ee$,e.agentSide)}catch{}window.dispatchEvent(new CustomEvent(eeF))}function eeU({stack:e,rootTitle:t,rootOwnerMachineId:n,onNavigateRoot:r,onNavigateIndex:a,onOpenSubagent:i}){let o=e[e.length-1],[l,s]=ew.useState(null);ew.useEffect(()=>{let e;if(!o)return;let t=!1;async function r(){try{let a=await sD(o.id,n);if(t)return;s(a);let i="working"===a.conversation.status||!!a.conversation.running;e=window.setTimeout(r,i?900:5e3)}catch{if(t)return;e=window.setTimeout(r,3e3)}}return s(null),r(),()=>{t=!0,e&&window.clearTimeout(e)}},[o,n]);let[c,d]=ew.useState(!1),u=ew.useRef(!1),f=o?.id,m=l?.conversation.status??"working",h="working"===m||!!l?.conversation.running;ew.useEffect(()=>{d(!1),u.current=!1},[f]);let p=ew.useCallback(e=>{let t=0===e.trim().length;f&&(t||u.current||!h?t&&u.current&&(u.current=!1,cu(f,n)):(u.current=!0,cd(f,n)))},[f,n,h]),g=ew.useCallback(async e=>{let t=e.trim();if(f&&t&&!c){d(!0);try{await cc(f,t,n),u.current=!1}catch{}finally{d(!1)}}},[f,n,c]);return o?(0,eb.jsxs)("div",{className:"absolute inset-0 z-30 flex flex-col bg-background",children:[(0,eb.jsxs)("div",{className:"flex h-9 shrink-0 items-center gap-1 overflow-x-auto border-b px-2 text-xs",children:[(0,eb.jsx)("button",{type:"button",className:"shrink-0 rounded px-1.5 py-0.5 text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",onClick:r,children:t||"主对话"}),e.map((t,n)=>{let r=Uh(t.subagentType),i=n===e.length-1,o=r.Icon;return(0,eb.jsxs)(ew.Fragment,{children:[(0,eb.jsx)(h7,{className:"size-3 shrink-0 text-muted-foreground/60"}),(0,eb.jsxs)("button",{type:"button",className:(0,ez.cn)("flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 transition-colors hover:bg-accent/50",i?"font-medium text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>a(n),children:[(0,eb.jsx)(o,{className:(0,ez.cn)("size-3",r.color)}),(0,eb.jsx)("span",{className:"max-w-[10rem] truncate",children:t.name||`${r.label}子代理`})]})]},t.id)}),(0,eb.jsx)("span",{className:"ml-auto shrink-0 pl-2",children:h?(0,eb.jsxs)("span",{className:"flex items-center gap-1 text-muted-foreground",children:[(0,eb.jsx)(eM,{className:"size-3 animate-spin"}),"运行中"]}):"paused"===m?(0,eb.jsxs)("span",{className:"flex items-center gap-1 text-destructive",children:[(0,eb.jsx)(m0,{className:"size-3"}),"已暂停"]}):(0,eb.jsxs)("span",{className:"flex items-center gap-1 text-emerald-600 dark:text-emerald-500",children:[(0,eb.jsx)(eI,{className:"size-3"}),"完成"]})})]}),(0,eb.jsxs)("div",{className:"relative min-h-0 flex-1",children:[(0,eb.jsx)(UL,{className:"size-full min-h-0",composerClassName:"max-w-[42.5rem]",composerPlaceholder:h?"向该子代理插话(开始输入会暂停它)…":"向该子代理插话…",events:l?.events??[],running:h||c,disabled:!f,hideComposerOptions:!0,onOpenSubagent:e=>i(e),onComposerValueChange:p,onSubmit:e=>void g(e.value)}),l?null:(0,eb.jsx)("div",{className:"absolute inset-0 grid place-items-center bg-background text-sm text-muted-foreground",children:(0,eb.jsxs)("span",{className:"flex items-center gap-2",children:[(0,eb.jsx)(eM,{className:"size-4 animate-spin"}),"正在打开子代理对话…"]})})]})]}):null}let eeq=[],eeW="vantaloom:file-system-changed",eeK=[{id:"",label:"默认"},{id:"low",label:"低"},{id:"medium",label:"中"},{id:"high",label:"高"},{id:"xhigh",label:"极高"}];function eeG(e,t){let n;if(0===t.length)return e;let r=new Map;for(let t=0;t<e.length;t+=1){let n=e[t]?.id;n&&r.set(n,t)}for(let a of t){let t=a?.id,i=t?r.get(t):void 0;if(void 0!==i){if(e[i]===a)continue;n||(n=e.slice()),n[i]=a}else n||(n=e.slice()),t&&r.set(t,n.length),n.push(a)}return n??e}function eeX(e,t){if(0===e.length)return t;let n=new Set;for(let e of t)e?.id&&n.add(e.id);let r=e.filter(e=>e?.id&&!n.has(e.id));return 0===r.length?t:[...r,...t]}function eeY(e){var t;let n=(t=e?.layoutMode,eeC.some(e=>e.id===t)?t:"quad"),r="right"===e?.agentPosition?"right":"left",a=function(e){if(!e||"object"!=typeof e||Array.isArray(e))return{};let t=e.shell&&"object"==typeof e.shell&&!Array.isArray(e.shell)?e.shell:void 0,n={};for(let e of["agent","panes"]){let r=t?.[e];"number"==typeof r&&Number.isFinite(r)&&r>0&&(n[e]=r)}return{...Object.keys(n).length?{shell:n}:{},outer:eeZ(e.outer),left:eeZ(e.left),right:eeZ(e.right),top:eeZ(e.top),bottom:eeZ(e.bottom)}}(e?.sizes),i=Array.from({length:Math.max(4,eeC.find(e=>e.id===n)?.slots??4)},()=>void 0);for(let[t,n]of(e?.panes??[]).entries()){let e=Number.isInteger(n.slot)?n.slot:t;e<0||e>=i.length||(i[e]=function(e,t){var n,r;let a=e.paneId||`${e.kind}-${t+1}`,i=!(n=e.props)||"object"!=typeof n||Array.isArray(n)?{}:n;if("subagent-conversation-panel"===e.kind)return{id:a,kind:"subagent-conversation-panel",title:ee0(i.title)??"Subagent",subagentId:ee0(i.subagentId)??a,events:Array.isArray(i.events)?i.events:[]};if(!kO(e.kind))return;let o=i.tab&&"object"==typeof i.tab?i.tab:void 0,l=Array.isArray(i.tabs)?i.tabs.filter(e=>fr(e?.kind)):void 0,s=kO(e.kind);return{id:a,kind:e.kind,title:ee0(i.title)??o?.title??s?.title??"组件",tab:o,tabs:l,activeTabId:ee0(i.activeTabId),terminal:"terminal-tab-group"===e.kind?!(r=i.terminal)||"object"!=typeof r||Array.isArray(r)?{sessionIds:[]}:{sessionIds:Array.isArray(r.sessionIds)?r.sessionIds.filter(e=>"string"==typeof e):[],activeSessionId:ee0(r.activeSessionId),selectedMachineId:ee0(r.selectedMachineId),selectedShellId:ee0(r.selectedShellId),autoStart:"boolean"==typeof r.autoStart?r.autoStart:void 0,aiControlledSessionIds:Array.isArray(r.aiControlledSessionIds)?r.aiControlledSessionIds.filter(e=>"string"==typeof e):void 0}:void 0}}(n,t))}return{layoutMode:n,agentPosition:r,layoutSizes:a,panes:i,cardColumns:Array.isArray(e?.cardLayout?.columns)?e.cardLayout.columns.filter(e=>e&&"string"==typeof e.key&&Array.isArray(e.cardIds)).map(e=>({key:e.key,width:"number"==typeof e.width&&e.width>0?e.width:360,cardIds:e.cardIds.filter(e=>"string"==typeof e)})):[],cardHeights:e?.cardLayout?.heights&&"object"==typeof e.cardLayout.heights?e.cardLayout.heights:{}}}function eeZ(e){if(!Array.isArray(e))return;let t=e.filter(e=>"number"==typeof e&&Number.isFinite(e)&&e>0);return t.length?t:void 0}function eeJ(e){return e.filter(e=>"number"==typeof e&&Number.isFinite(e)&&e>0)}function eeQ(e){return e>0?Math.max(1,Math.round(e/4)):0}function ee0(e){return"string"==typeof e&&e.trim()?e:void 0}function ee1(e){let t=e?.id.match(/-(\d+)$/);return t?Number(t[1]):0}function ee2(e){return e.reduce((e,t)=>Math.max(e,ee1(t)),0)}let ee5="vtl:composer-model:",ee4="vtl:composer-effort:";function ee3(e,t){if(!t)return"";try{return window.localStorage.getItem(e+t)??""}catch{return""}}function ee6(e,t,n){if(t)try{window.localStorage.setItem(e+t,n)}catch{}}function ee8({conversation:e,clipboardItems:t,clipboardDraggingId:n,onClipboardItemsChange:r,onClipboardDraggingChange:a,onOverlayOpenChange:i,onConversationCreated:o,onCancelDraft:l,subagentStack:s=[],onSubagentStackChange:c,subagentTree:d=[],mobileView:u="conversation",onMobilePaneCountChange:f}){let m=sv(),h=ew.useRef(null),p=ew.useRef(void 0),g=eeY(e?.panes),[x,v]=ew.useState(g.layoutMode),[b,y]=ew.useState(g.agentPosition),w=function(){let[e,t]=ew.useState(eeB);return ew.useEffect(()=>{t(eeV());let e=()=>t(eeV());return window.addEventListener(eeF,e),window.addEventListener("storage",e),()=>{window.removeEventListener(eeF,e),window.removeEventListener("storage",e)}},[]),e}(),j="card"===w.mode,[k,N]=ew.useState(!1),[S,C]=ew.useState(!1);ew.useEffect(()=>{try{C("1"===window.localStorage.getItem("vtl:agent-panes-collapsed"))}catch{}},[]);let M=ew.useCallback(()=>{C(e=>{let t=!e;try{window.localStorage.setItem("vtl:agent-panes-collapsed",t?"1":"0")}catch{}return t})},[]),[E,I]=ew.useState(g.layoutSizes),[P,O]=ew.useState(()=>g.panes),[z,A]=ew.useState(()=>g.cardColumns),[T,R]=ew.useState(()=>g.cardHeights),[D,_]=ew.useState(()=>e?.events??[]),[L,$]=ew.useState(()=>e?.eventsStart??0),[F,B]=ew.useState(()=>e?.eventsTotal??e?.events?.length??0),[V,H]=ew.useState(!1),U=L>0,[q,W]=ew.useState(null),[K,G]=ew.useState(()=>e?.conversation.planState!=null),[X,Y]=ew.useState(new Set),[Z,J]=ew.useState(void 0),[Q,ee]=ew.useState(()=>qN(e?.conversation.id)),et=ew.useCallback(t=>{ee(t),function(e,t){if(e)try{if(!t)return void window.localStorage.removeItem(qk(e));window.localStorage.setItem(qk(e),t.slice(0,1e5))}catch{}}(e?.conversation.id,t)},[e?.conversation.id]),[en,er]=ew.useState(()=>qC(e?.conversation.id)),[ea,ei]=ew.useState([]),[eo,el]=ew.useState(void 0),[es,ec]=ew.useState(!1),[ed,eu]=ew.useState(!1),[ef,em]=ew.useState(!1),[eh,ep]=ew.useState(()=>new Set),[eg,ex]=ew.useState(void 0),[ev,ey]=ew.useState(""),[ej,ek]=ew.useState(!1),[eN,eS]=ew.useState(void 0),[eC,eM]=ew.useState(""),[eE,eI]=ew.useState(e?.conversation.status==="working"),[eP,eA]=ew.useState(e?.conversation.status??"idle"),[eR,eD]=ew.useState(e?.conversation.awaitingTakeover??!1),[e_,eL]=ew.useState(!1),[e$,eF]=ew.useState(e?.conversation.settings?.permissionMode??"acceptEdits"),[eB,eV]=ew.useState(e?.conversation.settings?.reasoningEffort??""),[eH,eU]=ew.useState([]),[eq,eW]=ew.useState(e?.conversation.tokens??0),[eK,eG]=ew.useState(e?.conversation.runUsage),[eX,eY]=ew.useState(e?.conversation.contextTokens??0),[eZ,eJ]=ew.useState(!1),eQ=ew.useRef(eP),e0=ew.useRef(!1),[e1,e2]=ew.useState(),[e5,e4]=ew.useState(),[e3,e6]=ew.useState(),e8=ew.useRef(ee2(g.panes)),e7=ew.useRef(0),e9=ew.useRef(""),te=ew.useRef(void 0),tt=eeC.find(e=>e.id===x)?.slots??4,tn=e?.conversation.settings.folders??eeq,{models:tr}=vH(),ta=ew.useMemo(()=>{let t=e?.conversation.settings.mainModels??[];if(!t.length)return[];let n=new Map(tr.map(e=>[e.value,e]));return t.map(e=>{let t=n.get(e);return t?!1===t.available?{id:e,label:t.label,disabled:!0}:{id:e,label:t.label}:{id:e,label:e,disabled:!0}})},[tr,e?.conversation.settings.mainModels]),ti=ew.useMemo(()=>ta.filter(e=>!e.disabled),[ta]),to=kt(e?.conversation.settings.engine),tl=ew.useMemo(()=>{if(to){let t=e?.conversation.settings.ccModel;return[{id:t&&""!==t?t:"__cc_model__",label:kn(t),disabled:!0}]}return ta},[to,e?.conversation.settings.ccModel,ta]),td=!to&&0===ti.length,[tu,tf]=ew.useState(!1),tm=eE||"working"===eP||tu;e0.current=tm;let th=ew.useCallback(async t=>{if(!e||eZ)return;let n=e.conversation.id,r=e.conversation.ownerMachineId;if(to){if(tm)return void await cc(n,"请执行 /compact 压缩上下文。",r);eI(!0),eA("working");try{let e=await s3(n,{message:"/compact",modelRef:"",mode:"agent"},r);eA(e.conversation.status)}catch(e){eI(!1),eA("idle"),hn.error(e instanceof Error?e.message:"压缩请求失败")}return}if(tm)return void await cc(n,"precise"===t?"请在完成当前小任务后进行精确压缩(去除冗余文件读取和旧工具输出)。":"请在完成当前小任务后进行极致压缩(AI摘要),以便继续工作。",r);eJ(!0);try{let e=await cg(n,t,void 0,r),a=await sD(n,r);a&&(_(a.events),$(a.eventsStart??0),B(a.eventsTotal??a.events.length),eW(a.conversation.tokens??0),eG(a.conversation.runUsage),eY(a.conversation.contextTokens??0));let i=Math.max(0,Math.round((e?.tokensSaved??0)/1e3));hn.success(i>0?`${"extreme"===t?"极致":"精确"}压缩完成 \xb7 节省约 ${i}K tokens`:`${"extreme"===t?"极致":"精确"}压缩完成`)}catch(e){hn.error(e instanceof Error?e.message:"压缩失败")}finally{eJ(!1)}},[e,eZ,tm,to]),tp=ew.useMemo(()=>{if(!e)return;let t=tr.find(e=>e.value===eC),n=t?.contextLength,r=null==n||!Number.isFinite(n)||n<=0?2e5:Math.min(2e7,n<=1e4?Math.round(1e3*n):Math.round(n)),a=eX>0?eX:e.conversation.contextTokens??0;return{used:a,total:r,toolCalls:a,userMessages:0,other:void 0,onCompressPrecise:()=>th("precise"),onCompressExtreme:()=>th("extreme"),compressing:eZ,onExpand:()=>te.current?.()}},[e,tr,eC,eX,th,eZ]),tg=ew.useMemo(()=>{let t=e?.conversation.rounds;if(t?.length)return t;let n=[];for(let e of D){if("user"!==e.kind)continue;let t=n.length,r=(e.title??"").replace(/\s+/g," ").trim(),a=(r?r.slice(0,28):"")||`第 ${t+1} 轮`;n.push({runId:e.id,index:t,anchorEventId:e.id,title:a,summary:a,createdAt:""})}return n},[e?.conversation.rounds,D]),tx=ew.useCallback(async t=>{let n=e?.conversation.id,r=t.anchorEventId??D.find(e=>e.id.startsWith(`${t.runId}-`))?.id??D.find(e=>e.id===t.runId)?.id;if(r){if(D.some(e=>e.id===r))return void h.current?.scrollToEvent(r);if(n&&L>0)try{let t=await s_(n,{fromEventId:r,end:L},e?.conversation.ownerMachineId);t.events.length>0&&(_(e=>eeX(t.events,e)),$(t.start),t.total>0&&B(t.total))}catch{}window.setTimeout(()=>{h.current?.scrollToEvent(r)},60)}},[e?.conversation.id,e?.conversation.ownerMachineId,D,L]),tv=ew.useCallback(t=>{let n;if(t&&function(e,t){if(e)try{if(!t)return void window.localStorage.removeItem(qM(e));window.localStorage.setItem(qM(e),t)}catch{}}(e?.conversation.id,t),!t)return void J(void 0);let r=D.findIndex(e=>e.id===t);if(r>=0)for(let e of tg){let t=e.anchorEventId??e.runId,a=D.findIndex(e=>e.id===t);a>=0&&a<=r&&(n=e.runId)}n||(n=tg.find(e=>t===e.runId||t.startsWith(`${e.runId}-`))?.runId),J(n)},[e?.conversation.id,D,tg]),tb=ew.useCallback(async e=>{if("file-tab-viewer"!==e.kind||e.modified||e.file?.readOnly)return e;try{var t,n;let r=await fS(e);return(t=e,n=r,t.defaultValue!==n.defaultValue||t.title!==n.title||t.file?.size!==n.file?.size||t.file?.mimeType!==n.file?.mimeType||t.file?.previewContent!==n.file?.previewContent||t.file?.src!==n.file?.src||t.file?.truncated!==n.file?.truncated)?r:e}catch{return e}},[]),ty=ew.useCallback(async e=>{if(!e||!kA(e))return e;if("multi-tab-system"===e.kind){var t,n;let r=e.tabs??[],a=await Promise.all(r.map(tb));return(t=r,n=a,t.length!==n.length||t.some((e,t)=>e!==n[t]))?{...e,tabs:a}:e}if("file-tab-viewer"===e.kind&&e.tab){let t=await tb(e.tab);return t!==e.tab?{...e,title:t.title,tab:t}:e}return e},[tb]),tw=ew.useCallback(async()=>{var e,t;let n=await Promise.all(P.map(async e=>ty(e)));e=P,t=n,(e.length!==t.length||e.some((e,n)=>e!==t[n]))&&O(n)},[P,ty]);ew.useEffect(()=>{i?.(void 0!==e1||void 0!==e5||void 0!==e3)},[e5,e3,i,e1]);let tj=ew.useRef(void 0);ew.useEffect(()=>{let t=e?.conversation.id,n=e?.events??[];if(tj.current!==t){tj.current=t,_(n),$(e?.eventsStart??0),B(e?.eventsTotal??n.length);return}_(e=>eeG(e,n))},[e?.conversation.id,e?.events]);let tk=ew.useCallback(async()=>{let t=e?.conversation.id;if(t&&!(L<=0)&&!V){H(!0);try{let n=await s_(t,{end:L,limit:200},e?.conversation.ownerMachineId);n.events.length>0&&_(e=>eeX(n.events,e)),$(e=>n.events.length>0?n.start:Math.max(0,e-200)),n.total>0&&B(n.total)}finally{H(!1)}}},[e?.conversation.id,e?.conversation.ownerMachineId,L,V]);ew.useEffect(()=>{let t=e?.conversation.id;if(!t||0===D.length||p.current===t)return;p.current=t;let n=function(e){if(e)try{return window.localStorage.getItem(qM(e))??void 0}catch{return}}(t),r=D[D.length-1]?.id;if(!n||n===r||!D.some(e=>e.id===n))return;let a=window.setTimeout(()=>{h.current?.scrollToEvent(n)},80);return()=>window.clearTimeout(a)},[e?.conversation.id,D.length]),ew.useEffect(()=>{ee(qN(e?.conversation.id)),er(qC(e?.conversation.id)),ei([]),el(void 0),Y(new Set)},[e?.conversation.id]),ew.useEffect(()=>{eI(e?.conversation.status==="working"),eA(e?.conversation.status??"idle")},[e?.conversation.id,e?.conversation.status]),ew.useEffect(()=>{eD(e?.conversation.awaitingTakeover??!1)},[e?.conversation.id,e?.conversation.awaitingTakeover]);let tN=ew.useRef(void 0);ew.useEffect(()=>{let t=e?.conversation.id,n=e?.conversation.planState!=null;if(tN.current!==t){tN.current=t,G(n);return}n&&G(!0)},[e?.conversation.id,e?.conversation.planState]),ew.useEffect(()=>{eW(e?.conversation.tokens??0),eG(e?.conversation.runUsage),eY(e?.conversation.contextTokens??0)},[e?.conversation.id,e?.conversation.tokens,e?.conversation.runUsage,e?.conversation.contextTokens]),ew.useEffect(()=>{eF(e?.conversation.settings?.permissionMode??"acceptEdits")},[e?.conversation.id,e?.conversation.settings?.permissionMode]);let tS=ew.useRef(void 0);ew.useEffect(()=>{let t=e?.conversation.id;if(tS.current===t)return;if(tS.current=t,!t)return void eV("");let n=ee4+t;(()=>{try{return null!==window.localStorage.getItem(n)}catch{return!1}})()?eV(ee3(ee4,t)):eV(e?.conversation.settings?.reasoningEffort??"")},[e?.conversation.id,e?.conversation.settings?.reasoningEffort]);let tC=e?.conversation.lastModelRef??"",tM=ew.useRef(void 0);function tE(t){eM(t),ee6(ee5,e?.conversation.id,t)}function tI(t){eV(t);let n=e?.conversation.id;ee6(ee4,n,t),n&&nv({reasoningEffort:t})}function tP(e){if(!e.length)return;let t=e.map(kR);r(e=>[...t,...e.filter(e=>!t.some(t=>t.id===e.id))])}function tO(e,t,n){if(!e||!kA(e))return e;if("multi-tab-system"===e.kind){var r;let a,i;return{...e,tabs:(r=e.tabs??[],a=r.filter(e=>e.id!==t.id),i=void 0===n?a.length:Math.min(Math.max(n,0),a.length),a.splice(i,0,t),a),activeTabId:t.id}}return"file-tab-viewer"===e.kind?{...e,title:t.title,tab:t}:e}function tz(e,t){return e&&kA(e)?"multi-tab-system"===e.kind?{...e,tabs:(e.tabs??[]).map(e=>e.id===t.id?t:e),activeTabId:t.id}:"file-tab-viewer"===e.kind?{...e,title:t.title,tab:t}:e:e}function tA(e){O(t=>{let n=t.findIndex(e=>void 0===e);return n>=0?t.map((t,r)=>r===n?e:t):[...t,e]})}function tT(e){e8.current+=1;let t=kz(e,`${e}-${e8.current}`);if("browser-tab-viewer"===e&&t.tab){let e=t.tab;(0,eT.fetchLocalDevServers)().then(n=>{tA(n.length>0?{...t,tab:{...e,defaultUrl:n[0]}}:t)});return}tA(t)}ew.useEffect(()=>{let t=e?.conversation.id,n=e=>!!e&&ti.some(t=>t.id===e),r=ti[0]?.id??"",a=tM.current!==t,i=a?ee3(ee5,t):"",o=n(i)?i:n(tC)?tC:r;tM.current=t,eM(e=>a?o:n(e)?e:o)},[e?.conversation.id,ti,tC]),ew.useEffect(()=>{let t=eeY(e?.panes);v(t.layoutMode),y(t.agentPosition),I(t.layoutSizes),O(t.panes),A(t.cardColumns),R(t.cardHeights),e8.current=ee2(t.panes)},[e?.conversation.id,e?.panes]),ew.useEffect(()=>{let t,n=e?.conversation.id,r=e?.conversation.ownerMachineId;if(!n)return;let a=!1,i=e=>{_(t=>eeG(t,e.events)),eA(e.conversation.status),eW(e.conversation.tokens??0),eG(e.conversation.runUsage),eY(e.conversation.contextTokens??0),eD(e.conversation.awaitingTakeover??!1),null!=e.conversation.planState&&G(!0)},o=e=>{void 0===t&&(t=window.setInterval(async()=>{try{let e=await sD(n,r);if(a)return;i(e),eI("working"===e.conversation.status)}catch{return}},e))};if(r&&"local"!==r)return o(1500),()=>{a=!0,void 0!==t&&window.clearInterval(t)};let l=e?.conversation.lastSeq??0,s=new EventSource((0,eT.localAPIURL)(`/api/local/agent/conversations/${encodeURIComponent(n)}/events/stream?after=${l}`));return s.addEventListener("detail",e=>{try{let t=cx(JSON.parse(e.data));i(t),eI("working"===t.conversation.status)}catch{return}}),s.onerror=()=>{s.close(),o(350)},()=>{a=!0,s.close(),void 0!==t&&window.clearInterval(t)}},[e?.conversation.id,e?.conversation.ownerMachineId]),ew.useEffect(()=>{if(!e?.conversation.id)return;let t=window.setInterval(()=>{tw()},15e3);return()=>window.clearInterval(t)},[e?.conversation.id,tw]),ew.useEffect(()=>{let t=e?.conversation.id,n=e?.conversation.ownerMachineId;if(!t)return;let r=!1;sK(t,n);let a=window.setInterval(()=>{r||sK(t,n)},3e4);return()=>{r=!0,window.clearInterval(a),sG(t,n)}},[e?.conversation.id,e?.conversation.ownerMachineId]),ew.useEffect(()=>{let e=D.filter(e=>"change"===e.kind).map(e=>`${e.id}:${e.status??""}:${e.isStreaming?"1":"0"}`).join("|");e&&e!==e9.current&&(e9.current=e,window.dispatchEvent(new CustomEvent(eeW)),tw())},[D,tw]),ew.useEffect(()=>{let t=e?.conversation.id;if(!t)return;let n=window.setTimeout(()=>{var n;let r;s0(t,(n={columns:z,heights:T},r=[],P.forEach((e,t)=>{e&&(kA(e)?r.push({paneId:e.id,slot:t,kind:e.kind,machineId:e.terminal?.selectedMachineId,resourceId:e.terminal?.activeSessionId,props:{title:e.title,tab:e.tab,tabs:e.tabs,activeTabId:e.activeTabId,terminal:e.terminal}}):"context-breakdown"!==e.kind&&r.push({paneId:e.id,slot:t,kind:e.kind,props:{title:e.title,subagentId:e.subagentId,events:e.events}}))}),{layoutMode:x,agentPosition:b,sizes:E,cardLayout:n,panes:r}),e?.conversation.ownerMachineId)},300);return()=>window.clearTimeout(n)},[b,z,T,e?.conversation.id,x,E,P]);let tR=ew.useCallback(e=>{O(t=>{let n=t.findIndex(e=>e?.kind==="browser-tab-viewer");if(n>=0){let r=t[n];return r&&kA(r)&&r.tab&&(!r.tab.defaultUrl||r.tab.defaultUrl.startsWith("https://vantaloom.local"))?t.map((t,a)=>a===n&&r.tab?{...r,tab:{...r.tab,defaultUrl:e}}:t):t}e8.current+=1;let r=kz("browser-tab-viewer",`browser-tab-viewer-${e8.current}`),a=void 0!==r.tab?{...r,tab:{...r.tab,defaultUrl:e}}:r,i=t.findIndex(e=>void 0===e);return i>=0?t.map((e,t)=>t===i?a:e):j?[...t,a]:t})},[j]),tD=ew.useRef(!1);function t_(e){O(t=>{if(t.findIndex(t=>t?.kind===e)>=0)return t;e8.current+=1;let n=kz(e,`${e}-${e8.current}`),r=t.findIndex(e=>void 0===e);return r>=0?t.map((e,t)=>t===r?n:e):j?[...t,n]:t})}ew.useEffect(()=>{let t,n=e?.conversation.id,r=e?.conversation.ownerMachineId;if(!n||r&&"local"!==r)return;tD.current=!1;let a=!1,i=()=>{void 0!==t&&(window.clearInterval(t),t=void 0)},o=async()=>{if(a||tD.current)return void i();try{let e=(await (0,eT.fetchLocalDevServers)())[0];if(a||tD.current||!e){tD.current&&i();return}tD.current=!0,tR(e),i()}catch{}};return o(),tD.current||(t=window.setInterval(o,3e3)),()=>{a=!0,i()}},[e?.conversation.id,e?.conversation.ownerMachineId,tR]);let tL=ew.useCallback((e,t)=>{O(n=>{if(n.some(n=>void 0!==n&&kA(n)&&(n.id===t||(n.terminal?.sessionIds??[]).includes(e.id))))return n;let r={...kz("terminal-tab-group",t),terminal:{sessionIds:[e.id],activeSessionId:e.id,autoStart:!1,aiControlledSessionIds:[e.id],selectedMachineId:e.machineId}},a=n.findIndex(e=>void 0===e);return a>=0?n.map((e,t)=>t===a?r:e):j?[...n,r]:n})},[j]),t$=ew.useRef(new Set),[tF,tB]=ew.useState(0);ew.useEffect(()=>{tm&&tB(e=>e+1)},[tm]),ew.useEffect(()=>{let t,n=e?.conversation.id,r=e?.conversation.ownerMachineId;if(!n||r&&"local"!==r)return;t$.current=new Set;let a=`agent:${n}:pane:`,i=!1,o=async()=>{if(!i){try{let{sessions:e}=await fD();if(i)return;for(let t of e){if(!0!==t.aiControlled||"agent"!==t.controller||!t.scopeId||!t.scopeId.startsWith(a)||t$.current.has(t.id))continue;let e=t.scopeId.slice(a.length);e&&(t$.current.add(t.id),tL(t,e))}}catch{}i||(t=window.setTimeout(o,e0.current?4e3:3e4))}};return o(),()=>{i=!0,void 0!==t&&window.clearTimeout(t)}},[e?.conversation.id,e?.conversation.ownerMachineId,tL,tF]);let tV=ew.useCallback(()=>{t_("plan-doc-viewer")},[j]),tH=ew.useCallback(()=>{t_("spec-doc-viewer")},[j]),tU=ew.useCallback(()=>{t_("tasks-pane")},[j]),tq=P.some(e=>e?.kind==="plan-doc-viewer"||e?.kind==="spec-doc-viewer");ew.useEffect(()=>{let t=e?.conversation.id;if(W(null),!t||!K&&!tq)return;let n=e?.conversation.ownerMachineId,r=!0,a=async()=>{let e=await sF(t,n);r&&W(e.planState)};a();let i=window.setInterval(a,1500);return()=>{r=!1,window.clearInterval(i)}},[e?.conversation.id,e?.conversation.ownerMachineId,K,tq]);let tW=q??e?.conversation.planState??null,tK=ew.useRef(void 0);ew.useEffect(()=>{let e=tW?.approvals?.find(e=>!e.decision);e&&tK.current!==e.id&&(tK.current=e.id,tV())},[tW,tV]);let tG=ew.useRef(void 0);function tX(e,t){O(n=>{let r=n.findIndex(t=>t?.kind===e);if(r>=0)return n.map((n,a)=>a===r&&n?{id:n.id,kind:e,title:t.title,tab:t}:n);e8.current+=1;let a={id:`${e}-${e8.current}`,kind:e,title:t.title,tab:t},i=n.findIndex(e=>void 0===e);return i>=0?n.map((e,t)=>t===i?a:e):[...n,a]})}async function tY(e,t,n){let r;try{r=await fk(e)}catch(t){if(j){let n,r,a;return void tX("file-tab-viewer",(n=qn(e.path),r=t instanceof Error?t.message:String(t??""),a=[`// 无法加载文件预览`,`// 路径:${e.path}`,e.machineId&&"local"!==e.machineId?`// 机器:${e.machineId}`:"",r?`// 原因:${r}`:"","","// 文件可能已被移动/删除,或路径无法解析。","// 重新点击对话中的该文件可重试加载。"].filter(Boolean).join("\n"),{id:`file-error-${e.machineId??"local"}-${encodeURIComponent(e.path).replace(/[^a-z0-9_-]/gi,"-").slice(0,96)}-${Date.now()}`,kind:"file-tab-viewer",title:n,file:{name:n,path:e.path,machineId:e.machineId,kind:"code",readOnly:!0},defaultValue:a,defaultView:"code",defaultMode:"review"}))}hn.error("文件预览打开失败");return}j?tX("file-tab-viewer",r):O(e=>e.map((e,a)=>a===t?tO(e,r,n):e))}function tZ(e){if(j)return void tY(e,-1);let t=P.slice(0,tt).findIndex(e=>e?.kind==="multi-tab-system");t<0?hn.warning("请先放入一个多标签页组件"):tY(e,t)}function tJ(t){let n=t.path?.trim()||t.name.trim();("diff"===t.kind||"diff"===t.meta)&&t.diff?function(e){let t=e.path?.trim()||e.name.trim(),n={id:function(e,t){let n=0x811c9dc5;for(let e=0;e<t.length;e+=1)n^=t.charCodeAt(e),n=Math.imul(n,0x1000193);return`${e}-${(n>>>0).toString(36)}`}("diff",`${e.mutationId??""}|${e.machineId??"local"}|${t}|${e.diff??""}`),kind:"diff-tab-viewer",title:`Diff ${e.name}`,file:{name:e.name,path:t,machineId:e.machineId??"local",kind:"code"},diff:e.diff};if(j)return tX("diff-tab-viewer",n);let r=P.slice(0,tt).findIndex(e=>e?.kind==="multi-tab-system");r<0?hn.warning("请先放入一个多标签页组件"):O(e=>e.map((e,t)=>t===r?tO(e,n):e))}(t):!n||t.meta?.toLowerCase().startsWith("depth")||tZ(function(e,t){var n,r,a;let i,o,l,s=e.path.trim(),c=t.ownerMachineId||"local";if(/^vantaloom:\/\//i.test(s)){let e=qt(s);return{machineId:e.machineId,path:e.path}}let d=e.machineId||c;if(n=s,/^[A-Za-z]:[\\/]/.test(n)||n.startsWith("/")||n.startsWith("\\\\"))return{machineId:d,path:s};let u=(t.workspaceFolders??[]).map(qt).filter(e=>e.path),f=u.find(e=>e.machineId===d)??u[0];return f?{machineId:f.machineId||d,path:(r=f.path,a=s,i=r.includes("\\")&&!r.includes("/")?"\\":"/",o=r.replace(/[\\/]+$/,""),l=a.replace(/^[\\/]+/,""),`${o}${i}${l}`)}:{machineId:d,path:s}}({machineId:t.machineId,path:n},{workspaceFolders:tn,ownerMachineId:e?.conversation.ownerMachineId}))}ew.useEffect(()=>{let t=e?.conversation.id;!t||tG.current===t||D.some(e=>"task"===e.kind)&&(tG.current=t,tU())},[e?.conversation.id,D,tU]),te.current=function(){let t=function(e,t,n,r){let a=new Map,i=0,o=0,l=0;for(let t of e){for(let e of t.files??[]){var s;let n=(e.path??e.name??"").trim();if(!n||t.actionLabel?.trim()==="探索"||e.meta?.toLowerCase().startsWith("depth")||/[\\/]$/.test(n))continue;let i=e.machineId??r??"local",o=`${i}:${n}`,l=((s=t.detail)?Math.max(1,Math.round(s.length/4)):0)||256,c=a.get(o);c?c.estTokens=Math.max(c.estTokens,l):a.set(o,{path:n,machineId:i,estTokens:l})}"memory"===t.kind?i+=(t.detail??t.title??"").length:"skill"===t.kind?o+=(t.detail??t.title??"").length:("tool"===t.kind||"verify"===t.kind||t.shellMeta)&&(l+=(t.detail??"").length)}let c=[{key:"system",label:"系统提示词",estTokens:1500},{key:"memory",label:"记忆",estTokens:eeQ(i)},{key:"skill",label:"技能",estTokens:eeQ(o)},{key:"terminal",label:"terminal 工具返回内容",estTokens:eeQ(l)}];return{used:t,total:n,files:Array.from(a.values()),categories:c}}(D,tp?.used??0,tp?.total??0,e?.conversation.ownerMachineId);O(e=>{let n=e.findIndex(e=>e?.kind==="context-breakdown");if(n>=0)return e.map((e,r)=>r===n&&e?{id:e.id,kind:"context-breakdown",title:"上下文明细",data:t}:e);e8.current+=1;let r={id:`context-breakdown-${e8.current}`,kind:"context-breakdown",title:"上下文明细",data:t},a=e.findIndex(e=>void 0===e);return a>=0?e.map((e,t)=>t===a?r:e):[...e,r]})};let tQ=e?.conversation.ownerMachineId??"local",t0=ew.useMemo(()=>{let e=e=>/^https?:\/\//i.test(e)||e.startsWith("data:"),t=async e=>{let{target:t,kind:n,label:r}=e;try{if("url"===n)return void window.open(t,"_blank","noopener,noreferrer");if("local-file"===n){let e=await fetch((0,eT.localAPIURL)(`/v1/files/reveal?path=${encodeURIComponent(t)}`),{cache:"no-store"});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error??`reveal failed: ${e.status}`)}return}let e=await fd(tQ,t);if("utf-8"===e.encoding&&"folder"!==e.kind&&!e.truncated)return void tZ({machineId:tQ,path:t});let a=(0,eT.localAPIURL)(`/v1/remote/${encodeURIComponent(tQ)}/files/raw?path=${encodeURIComponent(t)}`);await h1({url:a,label:r}),hn.success(`已开始下载「${r}」,可在 系统设置 → 下载 查看进度`)}catch(e){hn.error(`打开交付物失败:${e instanceof Error?e.message:String(e)}`)}};return{resolveImageSrc:t=>{if(e(t))return t;let n=`path=${encodeURIComponent(t)}`;return"local"===tQ?(0,eT.localAPIURL)(`/v1/files/raw?${n}`):(0,eT.localAPIURL)(`/v1/remote/${encodeURIComponent(tQ)}/files/raw?${n}`)},classify:t=>e(t)?"url":"local"===tQ?"local-file":"remote-file",onOpen:e=>void t(e)}},[tQ]);async function t1(e,t,n){let r=t.file?.path,a=t.file?.machineId??"local";if(!r)throw hn.error("文件路径不可用"),Error("file path is unavailable");try{let i=await fu({machineId:a,path:r,content:n}),o={...await fN(i,{id:t.id,title:t.title,defaultView:t.defaultView,defaultMode:t.defaultMode}),modified:!1};O(t=>t.map((t,n)=>n===e?tz(t,o):t)),window.dispatchEvent(new CustomEvent(eeW)),hn.success("文件已保存")}catch(e){throw hn.error("文件保存失败"),e}}async function t2(t){let n=e?.conversation.id,r=e3?.tab.file?.path,a=e3?.tab.file?.machineId??"local";if(e3&&n&&r)try{let i=await cr(n,{machineId:a,path:r,mutationId:t.mutationId,state:t.state},e?.conversation.ownerMachineId),o=await fN(i,{id:e3.tab.id,title:`${i.name} @ ${ee9(t.mutationId)} ${"before"===t.state?"before":"after"}`,readOnly:!0,defaultView:e3.tab.defaultView,defaultMode:"review"});O(e=>e.map((e,t)=>t===e3.paneIndex?tz(e,o):e)),e6(void 0)}catch{hn.error("历史版本打开失败")}}function t5(e,t,n){let i=P[e];e8.current=Math.max(e8.current,ee1(n)),O(t=>t.map((t,r)=>r===e?n:t)),r(e=>{let n=e.filter(e=>e.id!==t.id);if(!i)return n;let r=kR(i);return[r,...n.filter(e=>e.id!==r.id)]}),a?.(void 0)}function t4(e,t){O(n=>n.map((n,r)=>r===e?t:n))}function t3(t){return{id:t.id,ownerMachineId:t.ownerMachineId??e?.conversation.ownerMachineId,name:t.name,subagentType:t.subagentType}}function t6(e){var t=P[e];if(t&&kA(t)&&"terminal-tab-group"===t.kind)for(let e of t.terminal?.sessionIds??[])fL(e).catch(()=>{});O(t=>t.map((t,n)=>n===e?void 0:t))}function t8(e){let t=P[e];t&&tP([t]),O(t=>t.map((t,n)=>n===e?void 0:t))}async function t7(t,n="chat",r=[]){let a=e?.conversation.id,i=to?"":eC||ti[0]?.id||"";if(!a||(!to&&i&&ee6(ee5,a,i),ee6(ee4,a,eB),t.trim()&&er(function(e,t){let n=t.trim();if(!n)return qC(e);let r=n.slice(0,1e5),a=qC(e);if(a[a.length-1]===r)return a;let i=[...a,r].slice(-100);if(e&&1)try{window.localStorage.setItem(qS(e),JSON.stringify(i))}catch{}return i}(a,t)),eE||"working"===eP))return;if(!to&&!i)return void hn.error("请先在代理模型配置里选择模型");Y(function e(t,n=new Set){for(let r of t)n.add(r.id),e(r.children??[],n);return n}(d));let o=r.map(e=>"image"===e.kind?{kind:"image",name:e.name,mimeType:e.mimeType,data:e.dataUrl?.split(",")[1]??""}:"card"===e.kind?{kind:"card",name:e.name,mimeType:e.mimeType,text:e.text??"",cardKind:e.cardKind}:{kind:"file",name:e.name,mimeType:e.mimeType,text:e.text??""}).filter(e=>"image"===e.kind?(e.data??"")!=="":(e.text??"")!=="");eI(!0),eA("working");try{let r=await s3(a,{message:t,modelRef:i,mode:n,effort:eB||void 0,attachments:o.length>0?o:void 0},e?.conversation.ownerMachineId);eA(r.conversation.status)}catch(e){eI(!1),eA("idle"),hn.error(e instanceof Error?e.message:"对话请求失败")}}async function t9(t){let n=e?.conversation.id,r="string"==typeof t.modelRef?t.modelRef.trim():"",a=to?"":r||eC||ti[0]?.id||"",i="agent"===t.mode?"agent":"chat";if(n){if(!to&&!a)return void hn.error("请先在代理模型配置里选择模型");eI(!0),eA("working"),_(e=>e.map(e=>e.id===t.id?{...e,status:"retried"}:e));try{let r=await s6(n,{modelRef:a,mode:i,effort:eB||void 0,retryEventId:t.id},e?.conversation.ownerMachineId);eA(r.conversation.status)}catch(e){_(e=>e.map(e=>e.id===t.id?t:e)),eI(!1),eA("idle"),hn.error(e instanceof Error?e.message:"对话重试失败")}}}function ne(e){tm?hn.error("对话正在运行,请先停止后再回退"):el(e)}async function nt(){let t=e?.conversation.id;if(t&&!e_){eL(!0);try{let n=await cl(t,e?.conversation.ownerMachineId);eD(n.conversation.awaitingTakeover??!1)}catch(e){hn.error(e instanceof Error?e.message:"接管失败")}finally{eL(!1)}}}async function nn(){let t=e?.conversation.id;if(!eo||!t)return void el(void 0);ec(!0);try{let n=await s8(t,eo.id,e?.conversation.ownerMachineId);_(n.detail.events),$(0),B(n.detail.events.length),eA(n.detail.conversation.status),eI(!1),et(n.prompt),c?.([]);let r=[];n.revertedFiles>0&&r.push(`恢复 ${n.revertedFiles} 个文件`),n.deletedFiles>0&&r.push(`删除 ${n.deletedFiles} 个新增文件`),n.archivedSubagents>0&&r.push(`归档 ${n.archivedSubagents} 个子代理`),hn.success(r.length?`已回退:${r.join(",")}`:"已回退到此处"),n.skippedRemote&&n.skippedRemote.length>0&&hn.warning(`${n.skippedRemote.length} 个远程文件未自动回退,请在对应机器手动处理`)}catch(e){hn.error(e instanceof Error?e.message:"回退失败")}finally{ec(!1),el(void 0)}}async function nr(t){let n=e?.conversation.id;if(n&&!ed){eu(!0);try{let r=await ct(n,t.id,e?.conversation.ownerMachineId);o?.(r),hn.success("已创建分支对话")}catch(e){hn.error(e instanceof Error?e.message:"创建分支失败")}finally{eu(!1)}}}function na(e){_(e.events),$(0),B(e.events.length),eA(e.conversation.status)}function ni(){tm?hn.error("对话正在运行,请先停止后再编辑上下文"):em(!0)}function no(){em(!1),ep(new Set),ex(void 0),ey("")}function nl(e){ep(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function ns(e,t){let n=D.findIndex(t=>t.id===e),r=D.findIndex(e=>e.id===t);if(n<0||r<0)return;let a=Math.min(n,r),i=Math.max(n,r);ep(e=>{let t=new Set(e);for(let e=a;e<=i;e++){let n=D[e];n&&"user"!==n.kind&&t.add(n.id)}return t})}function nc(e){tm?hn.error("对话正在运行,请先停止后再删除"):0!==e.length&&eS(e)}async function nd(){let t=e?.conversation.id;if(!eN||0===eN.length||!t)return void eS(void 0);ek(!0);try{let n=await s7(t,eN,e?.conversation.ownerMachineId);na(n.detail),ep(new Set),hn.success(`已从上下文删除 ${n.deletedEvents||eN.length} 条`)}catch(e){hn.error(e instanceof Error?e.message:"删除失败")}finally{ek(!1),eS(void 0)}}function nu(e,t){ex(e),ey(t)}async function nf(){let t=e?.conversation.id;if(!eg||!t)return void ex(void 0);ek(!0);try{let n=await s9(t,eg,ev,e?.conversation.ownerMachineId);na(n.detail),ex(void 0),ey(""),hn.success("已更新消息")}catch(e){hn.error(e instanceof Error?e.message:"保存失败")}finally{ek(!1)}}function nm(){ex(void 0),ey("")}async function nh(t,n){let r=e?.conversation.id;if(r){ek(!0);try{let a=await ce(r,[t],n,e?.conversation.ownerMachineId);na(a.detail)}catch(e){hn.error(e instanceof Error?e.message:n?"还原失败":"翻译失败")}finally{ek(!1)}}}let np=ew.useMemo(()=>{if(!to)return{mode:ef,selectedIds:eh,onToggleSelect:nl,onRangeSelect:ns,onEnterMode:ni,onExitMode:no,onDeleteOne:e=>nc([e]),editingId:eg,editDraft:ev,onStartEdit:nu,onEditDraftChange:ey,onSaveEdit:()=>void nf(),onCancelEdit:nm,onTranslate:e=>void nh(e,!1),onRestore:e=>void nh(e,!0)}},[to,ef,eh,eg,ev]),ng=e&&eR?(0,eb.jsxs)("div",{className:"vtl-agent-composer-overlay mb-[-1px] flex flex-wrap items-center gap-2 rounded-t-xl border border-b-0 border-border bg-background px-3 py-2 text-sm",children:[(0,eb.jsx)("span",{className:"min-w-0 flex-1 text-muted-foreground",children:"这个对话由任务分发代理管理,已锁定输入"}),(0,eb.jsx)(eO.Button,{type:"button",size:"sm",className:"w-full sm:w-auto",disabled:e_,onClick:()=>void nt(),children:"接管"})]}):null,nx=np&&eg?(0,eb.jsxs)("div",{className:"vtl-agent-composer-overlay mb-[-1px] flex items-center justify-end gap-2 rounded-t-xl border border-b-0 border-border bg-background px-3 py-2 text-sm",children:[(0,eb.jsx)("span",{className:"mr-auto text-muted-foreground",children:"编辑消息"}),(0,eb.jsx)(eO.Button,{type:"button",size:"sm",variant:"ghost",disabled:ej,onClick:nm,children:"取消"}),(0,eb.jsx)(eO.Button,{type:"button",size:"sm",disabled:ej,onClick:()=>void nf(),children:"保存"})]}):np&&ef?(0,eb.jsxs)("div",{className:"vtl-agent-composer-overlay mb-[-1px] flex items-center justify-end gap-2 rounded-t-xl border border-b-0 border-border bg-background px-3 py-2 text-sm",children:[(0,eb.jsx)("span",{className:"mr-auto text-muted-foreground",children:"编辑上下文"}),(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",variant:"destructive",disabled:ej||0===eh.size,onClick:()=>nc([...eh]),children:["删除选中 (",eh.size,")"]}),(0,eb.jsx)(eO.Button,{type:"button",size:"sm",variant:"ghost",onClick:no,children:"退出编辑"})]}):void 0;async function nv(t){let n=e?.conversation.id;if(n)try{let r=e?.conversation.settings??{};await sY(n,{settings:{...r,...t}},e?.conversation.ownerMachineId)}catch(e){hn.error(e instanceof Error?e.message:"设置更新失败")}}async function nb(t,n){let r=e?.conversation.id;if(r)try{await ca(r,t,n,void 0,e?.conversation.ownerMachineId)}catch(e){hn.error(e instanceof Error?e.message:"审批操作失败")}}async function ny(t){let n=e?.conversation.id;return n?ci(n,t,e?.conversation.ownerMachineId):{state:"error",explanation:""}}async function nw(){let t=e?.conversation.id;if(t){tf(!0);try{await co(t,e?.conversation.ownerMachineId)}catch{}}}function nj(){t7("继续","agent")}async function nk(t){let n=e?.conversation.id;if(!n)return;let r=eH.find(e=>e.id===t);if(!r)return;let a="string"==typeof r.content?r.content:String(r.content??"");if(a.trim()){eU(e=>e.filter(e=>e.id!==t));try{await cc(n,a.trim(),e?.conversation.ownerMachineId)}catch{}}}ew.useEffect(()=>{"idle"===eP&&tu&&tf(!1)},[eP,tu]),ew.useEffect(()=>{let e=eQ.current;if(eQ.current=eP,"working"===e&&"idle"===eP&&eH.length>0){let e=eH[0];if(e){eU(eH.slice(1));let t="string"==typeof e.content?e.content:String(e.content??"");t.trim()&&t7(t.trim(),"agent")}}},[eP]);let nN=Array.from({length:tt},(r,a)=>(0,eb.jsx)(eeO,{conversationId:e?.conversation.id,ownerMachineId:e?.conversation.ownerMachineId,index:a,content:P[a],clipboardItems:t,clipboardDraggingId:n,onAdd:()=>e2(a),onPanelDrop:t5,onContentChange:t4,onClear:t6,onCut:t8,workspaceFolders:tn,onRequestFileTab:(e,t)=>e4({paneIndex:e,insertIndex:t}),onOpenWorkspaceFile:tZ,onSaveFileTab:t1,onOpenFileHistory:(e,t)=>e6({paneIndex:e,tab:t})},a)),nS=P.slice(0,tt).some(e=>e?.kind==="subagent-conversation-panel"),nC=E.shell?.agent??42,nM=E.shell?.panes??58,nE=w.agentSide,nI="control-room"===w.mode||k,nP=(0,eb.jsxs)(hY,{type:"single",value:nI?"hidden":nE,variant:"outline",size:"sm","data-tour":"control-room-toggle","aria-label":"Agent 面板位置",onValueChange:e=>{"left"===e||"right"===e?(N(!1),y(e),eeH({mode:j?"card":"pane",agentSide:e})):"hidden"===e&&(N(!0),eeH({mode:"control-room"}))},children:[(0,eb.jsx)(hZ,{value:"left","aria-label":"Agent 在左",title:"Agent 在左",className:"h-7 w-9 px-0 [&_svg]:size-4",children:(0,eb.jsx)(cy,{})}),(0,eb.jsx)(hZ,{value:"hidden","aria-label":"隐藏面板,居中对话",title:"隐藏面板,居中对话",className:"h-7 w-9 px-0 [&_svg]:size-4",children:(0,eb.jsx)(cN,{})}),(0,eb.jsx)(hZ,{value:"right","aria-label":"Agent 在右",title:"Agent 在右",className:"h-7 w-9 px-0 [&_svg]:size-4",children:(0,eb.jsx)(cj,{})})]}),nO=(0,eb.jsxs)("div",{className:"relative flex size-full min-h-0 min-w-0 flex-col",children:[e?(0,eb.jsx)(UF,{ownerMachineId:e.conversation.ownerMachineId,title:e.conversation.title,className:"pr-12"}):null,e?(0,eb.jsx)("div",{className:"pointer-events-none absolute left-1 top-9 z-30 flex justify-start pt-1.5",children:(0,eb.jsx)("div",{className:"pointer-events-auto",children:(0,eb.jsx)(UB,{rounds:tg,onJumpToRound:tx,activeRunId:Z})})}):null,(0,eb.jsx)("div",{className:"min-h-0 flex-1 pl-10",children:(0,eb.jsx)(UL,{ref:h,events:e?D:void 0,hasEarlier:e?U:void 0,loadingEarlier:e?V:void 0,onLoadEarlier:e?tk:void 0,models:e?tl:void 0,modelId:to?tl[0]?.id:eC,permissionModeId:e$,onPermissionModeChange:t=>{eF(t),e?.conversation.id&&nv({permissionMode:t})},running:tm,disabled:!!e&&(td||eR),onModelChange:tE,effortOptions:e?eeK:void 0,selectedEffort:eB,onEffortChange:tI,onSubmit:e?e=>{t7(e.value,"agent",e.attachments??[])}:void 0,onStop:nw,onOpenFile:tJ,deliverable:t0,onOpenSubagent:function(e){e.id&&c?.([t3(e)])},onOpenPlan:tV,onOpenSpec:()=>tH(),onOpenTasks:tU,planPromptBar:ng||(e?(0,eb.jsx)(qv,{conversationId:e.conversation.id,ownerMachineId:e.conversation.ownerMachineId,planState:tW,modelRef:eC||ti[0]?.id||"",onOpenPlan:tV,onResolved:()=>{let t=e?.conversation.id;t&&sF(t,e?.conversation.ownerMachineId).then(e=>W(e.planState))}}):void 0),onRetry:t9,onApprovalDecision:nb,onFetchExplanation:ny,onContinue:nj,onRecallUserMessage:ne,onBranchAssistantMessage:nr,contextEdit:np,contextEditBar:ng?void 0:nx,onActiveEventChange:tv,composerValue:Q,onComposerValueChange:et,promptHistory:en,attachments:ea,onAttachmentsChange:ei,onCardDrop:qg,queuedMessages:eH,onQueuedMessagesChange:eU,onNudge:nk,contextUsage:tp})}),s.length>0&&e?(0,eb.jsx)(eeU,{stack:s,rootTitle:e.conversation.title,rootOwnerMachineId:e.conversation.ownerMachineId,onNavigateRoot:()=>c?.([]),onNavigateIndex:e=>c?.(s.slice(0,e+1)),onOpenSubagent:function(e){e.id&&c?.([...s,t3(e)])}}):null]}),nz=(0,eb.jsx)(mY,{id:"agent",defaultSize:nC,minSize:28,children:nO},"agent-conversation"),nA=(0,eb.jsx)(mY,{id:"panes",defaultSize:nM,minSize:32,children:(0,eb.jsxs)("section",{className:"vtl-agent-workspace-panel flex size-full min-h-0 min-w-0 flex-col bg-transparent","data-has-conversation-pane":nS?"true":void 0,children:[(0,eb.jsx)("div",{className:"flex h-11 shrink-0 items-center border-b px-3","data-tour":"pane-toolbar",children:(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,eb.jsx)(hY,{type:"single",value:x,variant:"outline",size:"sm","aria-label":"布局排版",onValueChange:e=>{let t,n;e&&(t=eeC.find(t=>t.id===e)?.slots??4,(n=P.slice(t).filter(e=>!!e)).length&&tP(n),O(Array.from({length:Math.max(4,t)},(e,n)=>n<t?P[n]:void 0)),v(e))},children:eeC.map(e=>(0,eb.jsx)(hZ,{value:e.id,"aria-label":e.label,title:e.label,className:"h-7 w-10 px-0 [&_svg]:size-4",children:e.icon},e.id))}),nP,(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-sm",draggable:!0,"aria-label":"剪切窗口内容",title:"拖拽到窗口以剪切到剪切板",className:"h-7 w-10 cursor-grab rounded-md text-muted-foreground active:cursor-grabbing [&_svg]:size-4",onDragStart:e=>{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData(eek,"cut")},children:(0,eb.jsx)(lJ,{})}),(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-sm",draggable:!0,"aria-label":"粉碎窗口内容",title:"拖拽到窗口以清空",className:"h-7 w-10 cursor-grab rounded-md text-muted-foreground active:cursor-grabbing [&_svg]:size-4",onDragStart:e=>{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData(eej,"clear")},children:(0,eb.jsx)(cS,{})})]})}),(0,eb.jsx)("div",{className:"min-h-0 flex-1",children:(0,eb.jsx)(eeP,{mode:x,sizes:E,onSizeGroupChange:function(e,t){let n=eeJ(t);I(t=>{var r;return(r=t[e],(r?.length??0)===(n?.length??0)&&(r??[]).every((e,t)=>.01>Math.abs(e-(n?.[t]??0))))?t:{...t,[e]:n}})},children:nN},`${e?.conversation.id??"empty"}-${x}`)})]})},"agent-panes"),nT=(0,eb.jsx)(ee_,{conversationId:e?.conversation.id,ownerMachineId:e?.conversation.ownerMachineId,panes:P,agentSide:nE,columns:z,heights:T,onColumnsChange:A,onHeightsChange:R,onAddCard:tT,onContentChange:t4,onClear:t6,workspaceFolders:tn,onOpenWorkspaceFile:tZ,onSaveFileTab:t1,onOpenFileHistory:(e,t)=>e6({paneIndex:e,tab:t}),onRequestFileTab:(e,t)=>e4({paneIndex:e,insertIndex:t})}),nR=(0,eb.jsx)("div",{className:(0,ez.cn)("absolute inset-y-0 z-30 flex w-9 items-center","left"===nE?"right-0 justify-end pr-1":"left-0 justify-start pl-1"),children:(0,eb.jsx)("button",{type:"button",onClick:M,"aria-label":S?"展开工作区":"收起工作区",title:S?"展开工作区":"收起工作区",className:"grid size-7 place-items-center rounded-md border bg-background/85 text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-opacity hover:bg-muted hover:text-foreground focus-visible:opacity-100 group-hover/panes:opacity-100 [&_svg]:size-4",children:"left"===nE?S?(0,eb.jsx)(ck,{}):(0,eb.jsx)(cw,{}):S?(0,eb.jsx)(tc,{}):(0,eb.jsx)(ts,{})})}),nD=(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(eez,{open:void 0!==e1,onOpenChange:e=>{e||e2(void 0)},onAdd:function(e){if(void 0===e1)return;e8.current+=1;let t=kz(e,`${e}-${e8.current}`),n=P[e1];n&&tP([n]),O(e=>e.map((e,n)=>n===e1?t:e)),e2(void 0)}}),(0,eb.jsx)(ql,{open:void 0!==e5,folders:tn,onOpenChange:e=>{e||e4(void 0)},onSelectFile:e=>{e5&&tY(e,e5.paneIndex,e5.insertIndex),e4(void 0)}}),(0,eb.jsx)(ee7,{open:void 0!==e3,conversationId:e?.conversation.id,ownerMachineId:e?.conversation.ownerMachineId,tab:e3?.tab,onOpenChange:e=>{e||e6(void 0)},onSelectVersion:e=>{t2(e)}}),(0,eb.jsx)(ux,{open:void 0!==eo,onOpenChange:e=>{e||es||el(void 0)},children:(0,eb.jsxs)(uR,{children:[(0,eb.jsxs)(uD,{children:[(0,eb.jsx)(uL,{children:"回退对话到此处?"}),(0,eb.jsx)(u$,{children:"此操作会归档此处之后的所有对话记录,并把这期间(含子代理)对文件的修改全部还原到当前这条消息发送前的状态。该用户消息会回到输入框。回退无法撤销。"})]}),(0,eb.jsxs)(u_,{children:[(0,eb.jsx)(uB,{disabled:es,children:"取消"}),(0,eb.jsx)(uF,{variant:"destructive",disabled:es,onClick:e=>{e.preventDefault(),nn()},children:es?"回退中…":"确认回退"})]})]})}),(0,eb.jsx)(ux,{open:void 0!==eN,onOpenChange:e=>{e||ej||eS(void 0)},children:(0,eb.jsxs)(uR,{children:[(0,eb.jsxs)(uD,{children:[(0,eb.jsx)(uL,{children:"从上下文中删除?"}),(0,eb.jsx)(u$,{children:`确认从上下文中删除选中的 ${eN?.length??0} 条?此操作会同时从智能体的实际上下文中移除(不影响磁盘文件)。`})]}),(0,eb.jsxs)(u_,{children:[(0,eb.jsx)(uB,{disabled:ej,children:"取消"}),(0,eb.jsx)(uF,{variant:"destructive",disabled:ej,onClick:e=>{e.preventDefault(),nd()},children:ej?"删除中…":"确认删除"})]})]})})]});return e?m?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(kE,{view:u,onPaneCountChange:f,conversationPanel:(0,eb.jsx)(UL,{flowContentClassName:"pl-10",events:e?D:void 0,hasEarlier:e?U:void 0,loadingEarlier:e?V:void 0,onLoadEarlier:e?tk:void 0,models:e?tl:void 0,modelId:to?tl[0]?.id:eC,permissionModeId:e$,onPermissionModeChange:t=>{eF(t),e?.conversation.id&&nv({permissionMode:t})},running:tm,disabled:!!e&&(td||eR),onModelChange:tE,effortOptions:e?eeK:void 0,selectedEffort:eB,onEffortChange:tI,onSubmit:e?e=>{t7(e.value,"agent",e.attachments??[])}:void 0,onStop:nw,onOpenFile:tJ,deliverable:t0,onOpenSubagent:function(e){var t;let n=P.slice(0,tt),r=n.findIndex(e=>!e),a=n.findIndex(e=>e?.kind==="subagent-conversation-panel"),i=r>=0?r:a;if(i<0)return void hn.warning("请释放一个窗口再选中浏览");e7.current+=1;let o={id:t=`subagent-${e.id}-${e7.current}`,kind:"subagent-conversation-panel",title:e.title,subagentId:e.id,events:e.events?.length?e.events:[{id:`${t}-status`,kind:"done",title:e.detail??e.status??e.activity??e.title}]};O(e=>e.map((e,t)=>t===i?o:e))},onRetry:t9,onApprovalDecision:nb,onFetchExplanation:ny,onContinue:nj,onRecallUserMessage:ne,onBranchAssistantMessage:nr,contextEdit:np,planPromptBar:ng??void 0,contextEditBar:ng?void 0:nx,onActiveEventChange:tv,composerValue:Q,onComposerValueChange:et,promptHistory:en,attachments:ea,onAttachmentsChange:ei,onCardDrop:qg,queuedMessages:eH,onQueuedMessagesChange:eU,onNudge:nk,contextUsage:tp}),paneElements:nN,panes:P,activeSlotCount:tt,onOpenPalette:e2,timeline:(0,eb.jsx)(UB,{rounds:tg,onJumpToRound:tx,activeRunId:Z})}),nD,(0,eb.jsx)(hs,{position:"top-center"})]}):(0,eb.jsxs)("div",{className:"vtl-app-background vtl-agent-conversation-workspace relative h-full min-h-0",children:[nI?(0,eb.jsxs)("div",{className:"relative flex h-full min-h-0",children:[(0,eb.jsx)("div",{className:"pointer-events-none absolute inset-0 -z-10 opacity-0","aria-hidden":!0,children:(0,eb.jsx)(mX,{direction:"horizontal",children:nA})}),(0,eb.jsxs)("div",{className:"relative flex h-full min-h-0 min-w-0 basis-[58%] shrink-0 flex-col",children:[(0,eb.jsx)(mX,{direction:"horizontal",children:nz}),(0,eb.jsx)("div",{className:"absolute right-3 top-1.5 z-20",children:nP})]}),(0,eb.jsx)("div",{className:"relative min-h-0 min-w-0 flex-1",children:(0,eb.jsx)(qj,{conversationTitle:e.conversation.title,rootEvents:D,rootOwnerMachineId:e.conversation.ownerMachineId,running:tm,subagentTree:d,baselineSubagentIds:X,activeSubagentPath:s,onSelectMain:()=>c?.([]),onSelectSubagent:e=>c?.([e])})})]}):j&&!P.some(Boolean)?(0,eb.jsxs)("div",{className:"relative flex h-full min-h-0",children:[(0,eb.jsx)("div",{className:"relative flex h-full min-h-0 min-w-0 flex-1 flex-col",children:nO}),(0,eb.jsx)("div",{className:(0,ez.cn)("absolute top-2 z-20 flex items-center gap-2","left"===nE?"right-3":"left-3"),children:(0,eb.jsx)(eeD,{onAddCard:tT,align:"left"===nE?"end":"start"})})]}):j?(0,eb.jsx)("div",{className:"flex h-full min-h-0 overflow-x-auto",children:"left"===nE?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("div",{className:"relative flex h-full min-h-0 min-w-[20rem] flex-1 flex-col",children:nO}),(0,eb.jsx)("div",{className:"flex h-full min-h-0 shrink-0 flex-col",children:nT})]}):(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("div",{className:"flex h-full min-h-0 shrink-0 flex-col",children:nT}),(0,eb.jsx)("div",{className:"relative flex h-full min-h-0 min-w-[20rem] flex-1 flex-col",children:nO})]})}):S?(0,eb.jsxs)("div",{className:"group/panes relative flex h-full min-h-0",children:[(0,eb.jsx)("div",{className:"pointer-events-none absolute inset-0 -z-10 opacity-0","aria-hidden":!0,children:(0,eb.jsx)(mX,{direction:"horizontal",children:nA})}),(0,eb.jsx)("div",{className:"relative flex h-full min-h-0 min-w-0 flex-1 flex-col",children:nO}),nR]}):(0,eb.jsxs)("div",{className:"group/panes relative flex h-full min-h-0",children:[(0,eb.jsxs)(mX,{direction:"horizontal",defaultLayout:{agent:nC,panes:nM},onLayoutChanged:e=>{let t=e.agent??nC,n=e.panes??nM;!function(e){let t=eeJ(e),n=t[0],r=t[1];if(void 0===n||void 0===r)return;let a="left"===b?{agent:n,panes:r}:{agent:r,panes:n};I(e=>{let t=e.shell?.agent,n=e.shell?.panes;return .01>Math.abs((t??0)-a.agent)&&.01>Math.abs((n??0)-a.panes)?e:{...e,shell:{...e.shell,...a}}})}("left"===nE?[t,n]:[n,t])},children:["left"===nE?nz:nA,(0,eb.jsx)(mZ,{withHandle:!0}),"left"===nE?nA:nz]},`${e?.conversation.id??"empty"}-${nE}`),nR]}),nD,(0,eb.jsx)(hs,{position:"top-right"})]}):(0,eb.jsx)(kk,{onCreated:e=>o?.(e),onCancel:l})}function ee7({open:e,conversationId:t,ownerMachineId:n,tab:r,onOpenChange:a,onSelectVersion:i}){let[o,l]=ew.useState([]),[s,c]=ew.useState(!1),d=r?.file?.path,u=r?.file?.machineId??"local";return ew.useEffect(()=>{if(!e||!t||!d)return void l([]);let r=!1;return c(!0),cn(t,{machineId:u,path:d},n).then(e=>{r||l(e.versions)}).catch(()=>{r||l([])}).finally(()=>{r||c(!1)}),()=>{r=!0}},[t,n,u,e,d]),(0,eb.jsx)(dX,{open:e,onOpenChange:a,children:(0,eb.jsxs)(fU,{className:"max-w-xl gap-0 overflow-hidden p-0",children:[(0,eb.jsx)(fK,{className:"sr-only",children:"历史版本"}),(0,eb.jsx)(fG,{className:"sr-only",children:"浏览当前文件在此 Agent 会话中的修改历史。"}),(0,eb.jsxs)("div",{className:"border-b px-4 py-3",children:[(0,eb.jsx)("div",{className:"truncate text-sm font-medium",children:r?.file?.name??r?.title??"文件"}),d?(0,eb.jsxs)("div",{className:"mt-0.5 truncate ui-text-kbd text-muted-foreground",children:[u,":",d]}):null]}),(0,eb.jsx)("div",{className:"max-h-[28rem] overflow-auto p-2",children:s?(0,eb.jsx)("div",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:"正在读取历史版本"}):0===o.length?(0,eb.jsx)("div",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:"还没有记录到这个文件的修改历史"}):(0,eb.jsx)("div",{className:"grid gap-1",children:o.map(e=>{var t;let n;return(0,eb.jsxs)("button",{type:"button",className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-3 rounded-md px-3 py-2 text-left transition-colors hover:bg-muted/70",onClick:()=>i(e),children:[(0,eb.jsxs)("span",{className:"min-w-0",children:[(0,eb.jsxs)("span",{className:"block truncate text-sm font-medium",children:[ee9(e.mutationId)," ·"," ","before"===e.state?"修改前":"修改后"]}),(0,eb.jsx)("span",{className:"mt-0.5 block truncate ui-text-kbd text-muted-foreground",children:Number.isFinite(n=Date.parse(t=e.createdAt))?new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(n):t})]}),(0,eb.jsxs)("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,eb.jsxs)("b",{className:"font-medium text-emerald-600",children:["+",e.additions??0]}),(0,eb.jsxs)("b",{className:"font-medium text-rose-600",children:["-",e.deletions??0]})]})]},e.id)})})})]})})}function ee9(e){return e.replace(/^mut-/,"").slice(0,16)}function ete({className:e,orientation:t="horizontal",...n}){return(0,eb.jsx)("div",{role:"separator","aria-orientation":t,"data-slot":"separator","data-orientation":t,className:(0,ez.cn)("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",e),...n})}let ett=(0,l0.cva)("group/item flex w-full flex-wrap items-center rounded-lg border text-sm transition-colors duration-100 outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 [a]:transition-colors [a]:hover:bg-muted",{variants:{variant:{default:"border-transparent",outline:"border-border",muted:"border-transparent bg-muted/50"},size:{default:"gap-2.5 px-3 py-2.5",sm:"gap-2.5 px-3 py-2.5",xs:"gap-2 px-2.5 py-2"}},defaultVariants:{variant:"default",size:"default"}});function etn({className:e,variant:t="default",size:n="default",asChild:r=!1,...a}){let i=r?lQ.Slot:"div";return(0,eb.jsx)(i,{"data-slot":"item","data-variant":t,"data-size":n,className:(0,ez.cn)(ett({variant:t,size:n,className:e})),...a})}let etr=(0,l0.cva)("flex shrink-0 items-center justify-center gap-2 [&_svg]:pointer-events-none",{variants:{variant:{default:"bg-transparent",icon:"[&_svg:not([class*='size-'])]:size-4",marker:"size-8 rounded-md border bg-background ui-text-kbd font-medium text-muted-foreground [&_svg:not([class*='size-'])]:size-4",image:"size-10 overflow-hidden rounded-sm group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 [&_img]:size-full [&_img]:object-cover"},align:{auto:"group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start",start:"translate-y-0.5 self-start",center:"self-center"}},defaultVariants:{variant:"default",align:"auto"}});function eta({className:e,variant:t="default",align:n="auto",...r}){return(0,eb.jsx)("div",{"data-slot":"item-media","data-variant":t,"data-align":n,className:(0,ez.cn)(etr({variant:t,align:n,className:e})),...r})}function eti({className:e,align:t,...n}){return(0,eb.jsx)("div",{"data-slot":"item-content","data-align":t,className:(0,ez.cn)("flex flex-1 flex-col gap-1 group-data-[size=xs]/item:gap-0 [&+[data-slot=item-content]]:flex-none","start"===t&&"self-start","center"===t&&"self-center",e),...n})}function eto({className:e,...t}){return(0,eb.jsx)("div",{"data-slot":"item-title",className:(0,ez.cn)("line-clamp-1 flex w-fit items-center gap-2 text-sm leading-snug font-medium underline-offset-4",e),...t})}function etl({className:e,...t}){return(0,eb.jsx)("p",{"data-slot":"item-description",className:(0,ez.cn)("line-clamp-2 text-left text-sm leading-normal font-normal text-muted-foreground group-data-[size=xs]/item:text-xs [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",e),...t})}function ets({className:e,...t}){return(0,eb.jsx)("div",{"data-slot":"item-actions",className:(0,ez.cn)("flex items-center gap-2",e),...t})}let etc={back:"Back",search:"Search settings...",welcomeTitle:"Settings",welcomeDescription:"Search or choose a setting to continue.",recommendations:"Recommended",noResults:"No settings found."},etd=ew.createContext(null);function etu({value:e,children:t}){return(0,eb.jsx)(etd.Provider,{value:e,children:t})}function etf(e){return"string"==typeof e||"number"==typeof e?String(e):""}function etm({sections:e,recommendations:t,sectionId:n,defaultSectionId:r,childId:a,defaultChildId:i,onSelectionChange:o,labels:l,welcomeContent:s,className:c,sidebarClassName:d,contentClassName:u}){let f={...etc,...l},m=sv(),h=ew.useContext(etd),[p,g]=ew.useState(r),[x,v]=ew.useState(i),[b,y]=ew.useState("list"),w=n??p,j=a??x,k=e.find(e=>e.id===w),N=k?.children?.find(e=>e.id===j),S=!!k?.children?.length,C=m&&"detail"===b,M=ew.useMemo(()=>e.flatMap(e=>[{value:e.id,label:e.title,description:e.description,icon:e.icon,searchValue:[etf(e.title),etf(e.description),...e.keywords??[]].join(" "),keywords:e.keywords},...(e.children??[]).map(t=>({value:`${e.id}/${t.id}`,label:t.title,description:e.title,icon:t.icon??e.icon,disabled:t.disabled,searchValue:[etf(t.title),etf(t.description),etf(e.title),...t.keywords??[]].join(" "),keywords:[etf(e.title),...t.keywords??[]]}))]),[e]),E=t??e.flatMap(e=>(e.children??[]).slice(0,2).map(t=>({id:`${e.id}-${t.id}`,title:t.title,description:e.title,icon:t.icon,sectionId:e.id,childId:t.id})));function I(t,r){let i=e.find(e=>e.id===t),l=void 0!==r,s=!!i?.children?.length;void 0===t?y("list"):l||!s?y("detail"):y("list");let c=i?.children?.[0];void 0!==t&&!l&&c&&(r=c.id),void 0===n&&g(t),void 0===a&&v(r),o?.({sectionId:t,childId:r})}let P=N?.content??k?.content??s??(0,eb.jsxs)("div",{className:"mx-auto flex min-h-[22rem] w-full max-w-2xl flex-col justify-center gap-5 py-12",children:[(0,eb.jsxs)("div",{className:"space-y-2",children:[(0,eb.jsx)("h3",{className:"text-xl font-semibold tracking-normal",children:f.welcomeTitle}),(0,eb.jsx)("p",{className:"max-w-xl text-sm text-muted-foreground",children:f.welcomeDescription})]}),(0,eb.jsx)(etp,{labels:f,options:M,onSelect:(e,t)=>I(e,t)}),E.length>0&&(0,eb.jsxs)("section",{className:"space-y-2",children:[(0,eb.jsx)("div",{className:"ui-text-kbd font-medium text-muted-foreground",children:f.recommendations}),(0,eb.jsx)("div",{className:"grid gap-2 sm:grid-cols-2",children:E.map(e=>(0,eb.jsx)(etn,{asChild:!0,variant:"outline",size:"xs",className:"min-h-14 flex-nowrap bg-card text-left hover:bg-muted/60",children:(0,eb.jsxs)("button",{type:"button",onClick:()=>I(e.sectionId,e.childId),children:[e.icon&&(0,eb.jsx)(eta,{variant:"marker",align:"center",children:e.icon}),(0,eb.jsxs)(eti,{className:"min-w-0 gap-0.5",children:[(0,eb.jsx)(eto,{className:"max-w-full truncate",children:e.title}),e.description&&(0,eb.jsx)(etl,{className:"line-clamp-1",children:e.description})]}),(0,eb.jsx)(ets,{className:"ml-auto",children:(0,eb.jsx)(h7,{className:"size-4 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/item:opacity-100"})})]})},e.id))})]})]});return(0,eb.jsxs)("div",{"data-slot":"settings-menu-panel",className:(0,ez.cn)("vtl-surface-panel grid min-h-[34rem] overflow-hidden rounded-[var(--surface-panel-radius)] border md:grid-cols-[15rem_minmax(0,1fr)]",c),children:[m&&C?null:(0,eb.jsx)("aside",{"data-slot":"settings-menu-sidebar",className:(0,ez.cn)("min-h-0 border-b bg-muted/20 md:border-r md:border-b-0",d),children:(0,eb.jsx)(jP,{className:"h-full",children:(0,eb.jsx)("div",{className:"space-y-1 p-2",children:S?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsxs)(eO.Button,{type:"button",variant:"ghost",className:"mb-1 h-auto min-h-9 w-full justify-start px-2.5 py-1.5 text-left",onClick:()=>I(void 0,void 0),children:[(0,eb.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center [&_svg]:size-4",children:(0,eb.jsx)(YV.ArrowLeftIcon,{})}),(0,eb.jsx)("span",{className:"min-w-0 truncate",children:f.back})]}),(k?.children??[]).map(e=>(0,eb.jsx)(eth,{title:e.title,icon:e.icon,badge:e.badge,active:e.id===j,disabled:e.disabled,onClick:()=>I(k?.id,e.id)},e.id))]}):(0,eb.jsxs)(eb.Fragment,{children:[m&&h?(0,eb.jsxs)(eO.Button,{type:"button",variant:"ghost",className:"mb-1 h-auto min-h-9 w-full justify-start px-2.5 py-1.5 text-left md:hidden",onClick:()=>h(),children:[(0,eb.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center [&_svg]:size-4",children:(0,eb.jsx)(YV.ArrowLeftIcon,{})}),(0,eb.jsx)("span",{className:"min-w-0 truncate",children:f.back})]}):null,e.map(e=>(0,eb.jsx)(eth,{title:e.title,icon:e.icon,badge:e.badge,active:e.id===w,disabled:e.disabled,onClick:()=>I(e.id,void 0)},e.id))]})})})}),!m||C?(0,eb.jsxs)("main",{"data-slot":"settings-menu-content",className:(0,ez.cn)("min-w-0 bg-[var(--surface-panel)] p-4 md:p-5 animate-in fade-in-0 slide-in-from-right-1 duration-150",u),children:[C?(0,eb.jsxs)(eO.Button,{type:"button",variant:"ghost",className:"mb-3 h-auto min-h-9 justify-start px-2.5 py-1.5 text-left md:hidden",onClick:()=>y("list"),children:[(0,eb.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center [&_svg]:size-4",children:(0,eb.jsx)(YV.ArrowLeftIcon,{})}),(0,eb.jsx)("span",{className:"min-w-0 truncate",children:f.back})]}):null,k?(0,eb.jsx)("div",{className:"mb-4 flex min-h-8 items-center justify-between gap-4",children:(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("h2",{className:"truncate text-lg font-semibold tracking-normal",children:N?.title??k.title}),(N?.description??k.description)&&(0,eb.jsx)("p",{className:"truncate text-sm text-muted-foreground",children:N?.description??k.description})]})}):null,P]},`${w??""}/${j??""}`):null]})}function eth({title:e,icon:t,badge:n,active:r,disabled:a,onClick:i}){return(0,eb.jsxs)(eO.Button,{type:"button",variant:"ghost",disabled:a,onClick:i,className:(0,ez.cn)("h-auto min-h-9 w-full justify-start px-2.5 py-1.5 text-left font-medium",r?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/70 hover:text-foreground"),children:[t&&(0,eb.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center [&_svg]:size-4",children:t}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium",children:e}),n&&(0,eb.jsx)(Vp,{variant:"outline",className:"h-5 shrink-0 px-1.5 ui-text-kbd",children:n}),(0,eb.jsx)(h7,{className:"size-3.5 shrink-0 text-muted-foreground/60"})]})}function etp({labels:e,options:t,onSelect:n}){return(0,eb.jsx)(bU,{options:t,placeholder:e.search,emptyText:e.noResults,className:"w-full",contentClassName:"rounded-lg",onValueChange:e=>{let[t,r]=e.split("/");t&&n(t,r)},renderOption:e=>(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground [&_svg]:size-4",children:e.icon??(0,eb.jsx)(vu,{})}),(0,eb.jsxs)("span",{className:"grid min-w-0 flex-1 gap-0.5",children:[(0,eb.jsx)("span",{className:"truncate",children:e.label}),e.description&&(0,eb.jsx)("span",{className:"truncate text-sm text-muted-foreground",children:e.description})]})]})})}let etg=(0,ek.default)("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]),etx=(0,ek.default)("webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]),etv=(0,ek.default)("package-plus",[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M19 13v6",key:"85cyf1"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);function etb({card:e}){return(0,eb.jsxs)("div",{className:(0,ez.cn)("flex flex-col gap-2 rounded-lg border bg-card p-3",e.shadowed&&"opacity-55"),children:[(0,eb.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("div",{className:"truncate text-sm font-medium",title:e.name,children:e.name}),e.description?(0,eb.jsx)("p",{className:"mt-0.5 line-clamp-2 text-xs text-muted-foreground",children:e.description}):null]}),e.badges&&e.badges.length>0?(0,eb.jsx)("div",{className:"flex shrink-0 flex-col items-end gap-1",children:e.badges.map((e,t)=>(0,eb.jsx)(Vp,{variant:e.variant??"secondary",className:(0,ez.cn)("text-[10px]",e.className),children:e.label},`${e.label}-${t}`))}):null]}),e.detail?(0,eb.jsx)("div",{className:"text-[11px] text-muted-foreground/80",children:e.detail}):null,e.actions?(0,eb.jsx)("div",{className:"mt-auto flex flex-wrap gap-1.5",children:e.actions}):null]})}function ety({title:e,count:t,onRefresh:n,onCreate:r,createLabel:a,headerExtra:i}){return(0,eb.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-baseline gap-2",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold text-foreground",children:e}),void 0!==t?(0,eb.jsx)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:t}):null]}),(0,eb.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[i,r?(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",variant:"outline",className:"h-8",onClick:r,children:[(0,eb.jsx)(lY,{className:"size-4"}),a??"新建"]}):null,n?(0,eb.jsx)(eO.Button,{type:"button",size:"sm",variant:"ghost",className:"h-8",onClick:n,"aria-label":"刷新",children:(0,eb.jsx)(yt,{className:"size-4"})}):null]})]})}function etw({title:e,description:t,cards:n,loading:r,error:a,emptyHint:i,onRefresh:o,onCreate:l,createLabel:s,banner:c,headerExtra:d}){return(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsx)(ety,{title:e,count:n.length,onRefresh:o,onCreate:l,createLabel:s,headerExtra:d}),t?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:t}):null,c,a?(0,eb.jsx)("p",{className:"text-sm text-destructive",children:a}):null,r?(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取…"}):0===n.length?(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:i??"暂无内容。"}):(0,eb.jsx)("div",{className:"grid gap-2 sm:grid-cols-2",children:n.map(e=>(0,eb.jsx)(etb,{card:e},e.key))})]})}function etj({children:e,onClick:t,disabled:n,variant:r="outline",destructive:a}){return(0,eb.jsx)(eO.Button,{type:"button",size:"sm",variant:r,className:(0,ez.cn)("h-7 px-2 text-xs",a&&"text-destructive hover:text-destructive"),onClick:t,disabled:n,children:e})}async function etk(e){let t=await etS(`/api/local/projects/${encodeURIComponent(e)}/file-hooks`);return{folder:t.folder??"",hooks:t.hooks??[]}}async function etN(e,t){let n=await etS(`/api/local/projects/${encodeURIComponent(e)}/file-hooks`,{method:"PUT",body:JSON.stringify({hooks:t})});return{folder:n.folder??"",hooks:n.hooks??t}}async function etS(e,t){let n=await fetch((0,eT.localAPIURL)(e),{cache:"no-store",...t,headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error("string"==typeof r?.error?r.error:"接口调用失败");return r}function etC(e){let t=new URLSearchParams;e?.conversationId&&t.set("conversationId",e.conversationId),e?.workspace&&t.set("workspace",e.workspace);let n=t.toString();return n?`?${n}`:""}async function etM(e){return(await etR(`/api/local/skills${etC(e)}`)).skills??[]}async function etE(e,t){return etR(`/api/local/skills/${encodeURIComponent(e)}${etC(t)}`)}async function etI(e){await etR(`/api/local/skills/${encodeURIComponent(e)}`,{method:"DELETE"})}async function etP(e,t){return etR("/api/local/skills/install",{method:"POST",body:JSON.stringify({name:e,...t})})}async function etO(e){let t=new URLSearchParams;e?.scope&&t.set("scope",e.scope),e?.conversationId&&t.set("conversationId",e.conversationId),e?.workspace&&t.set("workspace",e.workspace);let n=t.toString();return(await etR(`/api/local/memory${n?`?${n}`:""}`)).memories??[]}async function etz(e,t,n){return etR(`/api/local/memory/${encodeURIComponent(e)}/${encodeURIComponent(t)}${etC(n)}`)}async function etA(e){return etR("/api/local/memory",{method:"POST",body:JSON.stringify(e)})}async function etT(e,t,n){await etR(`/api/local/memory/${encodeURIComponent(e)}/${encodeURIComponent(t)}${etC(n)}`,{method:"DELETE"})}async function etR(e,t){let n=await fetch((0,eT.localAPIURL)(e),{cache:"no-store",...t,headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error("string"==typeof r?.error?r.error:"skill/memory api failed");return r}function etD({scope:e,workspaceFolder:t,conversationId:n}){let[r,a]=ew.useState([]),[i,o]=ew.useState(!0),[l,s]=ew.useState(""),[c,d]=ew.useState(""),[u,f]=ew.useState(null),[m,h]=ew.useState(!1),p=ew.useMemo(()=>({conversationId:n,workspace:t}),[n,t]),g="global"!==e&&!!(n||t),x=ew.useCallback(async()=>{o(!0),s("");try{a(await etM(p))}catch(e){s(e instanceof Error?e.message:"读取技能失败")}finally{o(!1)}},[p]);async function v(e){h(!0);try{f(await etE(e.name,p))}catch(e){s(e instanceof Error?e.message:"读取技能正文失败")}finally{h(!1)}}async function b(e){d(e.name),s("");try{await etI(e.name),await x()}catch(e){s(e instanceof Error?e.message:"删除失败")}finally{d("")}}async function y(e){if(g){d(e.name),s("");try{await etP(e.name,p),await x()}catch(e){s(e instanceof Error?e.message:"装入工作区失败")}finally{d("")}}}ew.useEffect(()=>{x()},[x]);let w=ew.useMemo(()=>new Set(r.filter(e=>"workspace"===e.scope).map(e=>e.name)),[r]),j="conversation"===e?"对话级":"项目级",k=r.map(t=>{let n="workspace"===t.scope,r="global"!==e&&!n,a=r&&w.has(t.name),i=[];"global"===e?i.push({label:"系统",variant:"default"}):n?i.push({label:j,variant:"default"}):i.push({label:"系统",variant:"secondary"}),a&&i.push({label:"被本级覆盖",variant:"outline",className:"text-amber-600"});let o=function(e){switch(e){case"claude":return{label:"Claude",variant:"outline"};case"codex":case"agents":return{label:"Codex",variant:"outline"};default:return null}}(t.origin);o&&i.push(o),t.source&&i.push({label:t.source,variant:"outline"});let l=(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsxs)(etj,{onClick:()=>void v(t),disabled:m,children:[(0,eb.jsx)(uX,{className:"size-3.5"}),"查看"]}),g&&!n?(0,eb.jsxs)(etj,{onClick:()=>void y(t),disabled:c===t.name,children:[(0,eb.jsx)(etv,{className:"size-3.5"}),"project"===e?"装配到工程":"装入工作区"]}):null,"global"===e&&"global"===t.origin?(0,eb.jsxs)(etj,{variant:"ghost",destructive:!0,onClick:()=>void b(t),disabled:c===t.name,children:[(0,eb.jsx)(yn,{className:"size-3.5"}),"删除"]}):null]});return{key:`${t.scope}-${t.name}`,name:t.name,description:t.description,badges:i,inherited:r,shadowed:a,actions:r?(0,eb.jsxs)(etj,{onClick:()=>void v(t),disabled:m,children:[(0,eb.jsx)(uX,{className:"size-3.5"}),"查看"]}):l}});return(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(etw,{title:"技能",description:"global"===e?"系统级技能:Vantaloom 库 + 自动扫描的 Claude(~/.claude/skills) / Codex(~/.codex/skills、~/.agents/skills) 主目录技能。带来源徽章;CC/Codex 技能只读(在其自身目录维护)。":`${j}技能(可装配 / 删除)+ 继承的系统级技能(只读,到系统设置编辑)。`,cards:k,loading:i,error:l,emptyHint:"尚无可用技能。可让 agent 把当前流程保存为技能。",onRefresh:()=>void x(),banner:"global"===e||g?"global"!==e?(0,eb.jsx)("p",{className:"rounded-lg border border-dashed px-3 py-2.5 text-xs leading-relaxed text-muted-foreground",children:"以下技能来自工作区文件夹的 .vantaloom / .claude / .codex / .agents 目录,自动扫描并启用,无需手动导入。"}):null:(0,eb.jsx)("p",{className:"rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs leading-relaxed text-amber-700 dark:text-amber-300",children:"尚未设置工作区文件夹,仅能浏览系统级技能。请先在「工作区文件夹」中添加目录,再装配本级技能。"})}),(0,eb.jsx)(dX,{open:!!u,onOpenChange:e=>!e&&f(null),children:(0,eb.jsxs)(fU,{className:"max-h-[85vh] max-w-2xl",children:[(0,eb.jsxs)(fq,{children:[(0,eb.jsx)(fK,{children:u?.name}),(0,eb.jsx)(fG,{children:u?.description})]}),u?.whenToUse?(0,eb.jsxs)("p",{className:"text-xs text-muted-foreground",children:["何时使用:",u.whenToUse]}):null,(0,eb.jsx)(jP,{className:"max-h-[60vh] rounded-md border bg-muted/40",children:(0,eb.jsx)("pre",{className:"whitespace-pre-wrap break-words p-3 text-xs leading-relaxed",children:u?.body||"(无正文)"})})]})})]})}let et_=[{value:"code-style",label:"代码风格"},{value:"pattern",label:"模式"},{value:"spec",label:"规范"},{value:"preference",label:"偏好"},{value:"reference",label:"参考"}];function etL({scope:e,workspaceFolder:t,conversationId:n}){let[r,a]=ew.useState([]),[i,o]=ew.useState(!0),[l,s]=ew.useState(""),[c,d]=ew.useState(""),[u,f]=ew.useState(null),[m,h]=ew.useState(!1),p=ew.useMemo(()=>({conversationId:n,workspace:t}),[n,t]),g="global"===e?"系统":"project"===e?"项目级":"对话级",x=ew.useCallback(async()=>{o(!0),s("");try{a(await etO(p))}catch(e){s(e instanceof Error?e.message:"读取记忆失败")}finally{o(!1)}},[p]);async function v(e){d(e.name);try{let t=await etz(e.scope,e.name,p);f({editing:!0,scope:t.scope,name:t.name,description:t.description,type:t.type,body:t.body})}catch(e){s(e instanceof Error?e.message:"读取记忆正文失败")}finally{d("")}}async function b(){if(u&&u.name.trim()){h(!0),s("");try{await etA({scope:u.scope,name:u.name.trim(),description:u.description.trim(),type:u.type,body:u.body,conversationId:n,workspace:t}),f(null),await x()}catch(e){s(e instanceof Error?e.message:"保存记忆失败")}finally{h(!1)}}}async function y(e){d(e.name),s("");try{await etT(e.scope,e.name,p),await x()}catch(e){s(e instanceof Error?e.message:"删除记忆失败")}finally{d("")}}ew.useEffect(()=>{x()},[x]);let w=r.map(t=>{var n;let r="global"!==e&&"global"===t.scope,a=[{label:(n=t.type,et_.find(e=>e.value===n)?.label??n),variant:"secondary"}];return"global"===t.scope?a.unshift({label:"系统",variant:"global"===e?"default":"secondary"}):"project"===t.scope?a.unshift({label:"项目级",variant:"default"}):a.unshift({label:"对话级",variant:"default"}),{key:`${t.scope}-${t.name}`,name:t.name,description:t.description||"(无描述)",badges:a,inherited:r,detail:t.paths&&t.paths.length>0?(0,eb.jsx)("span",{className:"line-clamp-1",children:t.paths.join(",")}):null,actions:r?null:(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(etj,{onClick:()=>void v(t),disabled:c===t.name,children:"查看 / 编辑"}),(0,eb.jsxs)(etj,{variant:"ghost",destructive:!0,onClick:()=>void y(t),disabled:c===t.name,children:[(0,eb.jsx)(yn,{className:"size-3.5"}),"删除"]})]})}});return(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(etw,{title:"记忆",description:"global"===e?"浏览、新增、编辑与删除系统级记忆。":`${g}记忆(可编辑)+ 继承的系统级记忆(只读)。系统级与本级记忆并存注入,不互相覆盖。`,cards:w,loading:i,error:l,emptyHint:`暂无记忆。`,onRefresh:()=>void x(),onCreate:function(){f({editing:!1,scope:e,name:"",description:"",type:"pattern",body:""})},createLabel:`新增${"系统"===g?"":g}记忆`}),(0,eb.jsx)(dX,{open:!!u,onOpenChange:e=>!e&&f(null),children:(0,eb.jsxs)(fU,{className:"max-h-[85vh] max-w-2xl",children:[(0,eb.jsx)(fq,{children:(0,eb.jsx)(fK,{children:u?.editing?"编辑记忆":"新增记忆"})}),u?(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"名称 (slug)"}),(0,eb.jsx)(eA,{value:u.name,disabled:u.editing,onChange:e=>f({...u,name:e.currentTarget.value}),placeholder:"例如 api-error-handling"})]}),(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"描述"}),(0,eb.jsx)(eA,{value:u.description,onChange:e=>f({...u,description:e.currentTarget.value}),placeholder:"一行用于相关性匹配的描述"})]}),(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"类型"}),(0,eb.jsxs)(gU,{value:u.type,onValueChange:e=>f({...u,type:e}),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:et_.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})]}),(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"正文"}),(0,eb.jsx)(w2,{value:u.body,onChange:e=>f({...u,body:e.currentTarget.value}),rows:10,className:"resize-none text-sm",placeholder:"记忆正文(Markdown)"})]})]}):null,(0,eb.jsxs)(fW,{children:[(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",onClick:()=>f(null),disabled:m,children:"取消"}),(0,eb.jsxs)(eO.Button,{type:"button",onClick:()=>void b(),disabled:m||!u?.name.trim(),children:[(0,eb.jsx)(Xj,{className:"size-4"}),m?"保存中":"保存"]})]})]})})]})}function et$({scope:e,conversationId:t,workspaceFolder:n}){return"global"===e?(0,eb.jsx)(etF,{}):(0,eb.jsx)(etB,{scope:e,conversationId:t,workspaceFolder:n})}function etF(){let[e,t]=ew.useState(""),[n,r]=ew.useState(!0),[a,i]=ew.useState(!1),[o,l]=ew.useState(null),[s,c]=ew.useState(""),d=ew.useRef(""),u=ew.useCallback(async()=>{r(!0),c("");try{let e=await kl(),n=e.systemPrompt?.userPrompt??"";d.current=n,t(n)}catch(e){c(e instanceof Error?e.message:"加载失败")}finally{r(!1)}},[]);async function f(){if(!a){i(!0),c(""),l(null);try{await ks({systemPrompt:{userPrompt:e}}),d.current=e,l(Date.now())}catch(e){c(e instanceof Error?e.message:"保存失败")}finally{i(!1)}}}return ew.useEffect(()=>{u()},[u]),(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsx)(ety,{title:"规则(系统提示词)",onRefresh:()=>void u()}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"兜底系统提示词(SystemPrompt):仅对 vantaloom 引擎对话生效。当某对话未检测到任何项目文档(CLAUDE.md / AGENTS.md / vantaloom.md),也未单独设置时,使用这里的内容作为兜底。"}),s?(0,eb.jsx)("p",{className:"text-sm text-destructive",children:s}):null,(0,eb.jsxs)("div",{className:"grid gap-2 rounded-lg border bg-card p-3",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,eb.jsx)(Vp,{className:"text-[10px]",children:"系统"}),(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",onClick:()=>void f(),disabled:a||n,children:[(0,eb.jsx)(Xj,{className:"size-4"}),a?"保存中":"保存"]})]}),(0,eb.jsx)(w2,{value:e,onChange:e=>{t(e.currentTarget.value),l(null)},placeholder:"例如:始终用中文回复;提交前先跑测试;优先复用现有代码……",rows:8,className:"resize-y text-sm"}),o?(0,eb.jsx)("span",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"已保存"}):null]})]})}function etB({scope:e,conversationId:t,workspaceFolder:n}){let[r,a]=ew.useState([]),[i,o]=ew.useState({}),[l,s]=ew.useState(""),[c,d]=ew.useState(!0),[u,f]=ew.useState(null),[m,h]=ew.useState(""),p="conversation"===e?"对话级":"项目级",g=ew.useCallback(async()=>{d(!0),h("");try{let r=(await kr("conversation"===e?t:void 0,"project"===e?n:void 0)).folders??[];a(r),o(Object.fromEntries(r.map(e=>[e.path,e.vantaloom])));try{let e=await kl();s(e.systemPrompt?.userPrompt??"")}catch{s("")}}catch(e){h(e instanceof Error?e.message:"加载失败")}finally{d(!1)}},[e,t,n]);async function x(r){if(!u){f(r),h("");try{await ka(r,i[r]??"","conversation"===e?t:void 0,"project"===e?n:void 0),await g()}catch(e){h(e instanceof Error?e.message:"保存失败")}finally{f(null)}}}ew.useEffect(()=>{g()},[g]);let v=r.some(e=>(i[e.path]??e.vantaloom)?.trim());return(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsx)(ety,{title:"规则(系统提示词)",onRefresh:()=>void g()}),(0,eb.jsxs)("p",{className:"text-xs text-muted-foreground",children:[p,"规则写入各工作区文件夹的 vantaloom.md,作为系统提示词注入。本级规则会完全覆盖系统兜底提示词。"]}),m?(0,eb.jsx)("p",{className:"text-sm text-destructive",children:m}):null,c||0!==r.length?r.map(e=>{let t=e.docs??[];return(0,eb.jsxs)("div",{className:"grid gap-2 rounded-lg border bg-card p-3",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,eb.jsx)(Vp,{className:"shrink-0 text-[10px]",children:p}),(0,eb.jsx)("span",{className:"truncate text-sm font-medium",title:e.path,children:e.path})]}),(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",onClick:()=>void x(e.path),disabled:u===e.path,children:[(0,eb.jsx)(Xj,{className:"size-4"}),u===e.path?"保存中":"保存到 vantaloom.md"]})]}),t.length>0?(0,eb.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:"用作模板:"}),t.map(t=>(0,eb.jsx)(eO.Button,{type:"button",size:"sm",variant:"ghost",className:"h-7 px-2 text-xs",onClick:()=>o(n=>({...n,[e.path]:t.content})),children:t.name},t.name))]}):(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"未检测到 agent.md / claude.md,可直接编写。"}),(0,eb.jsx)(w2,{value:i[e.path]??"",onChange:t=>o(n=>({...n,[e.path]:t.currentTarget.value})),placeholder:"该级别的系统提示词 / 规范,将写入 vantaloom.md",rows:8,className:"resize-y font-mono text-xs"})]},e.path)}):(0,eb.jsx)("p",{className:"rounded-md border border-dashed px-3 py-4 text-xs text-muted-foreground",children:"还没有可用的工作区文件夹。先在「工作区文件夹」里添加一个本机文件夹。"}),l.trim()?(0,eb.jsxs)("div",{className:`grid gap-2 rounded-lg border bg-card p-3 ${v?"opacity-55":""}`,children:[(0,eb.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,eb.jsx)(Vp,{variant:"secondary",className:"text-[10px]",children:"系统"}),v?(0,eb.jsx)(Vp,{variant:"outline",className:"text-[10px] text-amber-600",children:"未生效(已被本级覆盖)"}):null,(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:"兜底系统提示词(到系统设置编辑)"})]}),(0,eb.jsx)("pre",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap break-words rounded-md border bg-muted/40 p-2 text-xs leading-relaxed text-muted-foreground",children:l})]}):null]})}function etV({scope:e,projectId:t,conversationId:n}){return"conversation"===e&&n?(0,eb.jsx)(etW,{conversationId:n}):"project"===e&&t?(0,eb.jsx)(etK,{projectId:t}):(0,eb.jsx)("p",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"Hook 仅作用于具体的工程或对话。请在工程设置或对话设置中管理 Hook。"})}let etH=[{value:"timer",label:"定时(timer)"},{value:"webhook",label:"Webhook"},{value:"process_exit",label:"进程退出"},{value:"file",label:"文件变化"},{value:"shell_poll",label:"Shell 轮询"},{value:"lifecycle",label:"生命周期"}],etU=[{value:"resume_conversation",label:"唤醒本会话"},{value:"run_command",label:"运行命令"},{value:"start_conversation",label:"新建会话"}];function etq({hook:e,busy:t,onToggle:n,onDelete:r}){let a=e.enabled&&!("disabled"in e&&e.disabled);return(0,eb.jsxs)("div",{className:`flex flex-col gap-1.5 rounded-lg border bg-card p-3 ${a?"":"opacity-60"}`,children:[(0,eb.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,eb.jsx)("div",{className:"min-w-0 flex-1",children:(0,eb.jsx)("span",{className:"block truncate text-sm font-medium leading-5",title:e.name||e.id,children:e.name||e.id||"未命名 Hook"})}),(0,eb.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[n?(0,eb.jsx)(bG,{checked:a,disabled:t,onCheckedChange:()=>n(),"aria-label":"启用/停用 hook"}):null,r?(0,eb.jsx)("button",{type:"button",disabled:t,onClick:()=>r(),"aria-label":"删除 hook",title:"删除 hook",className:"grid size-6 place-items-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-destructive disabled:opacity-50 [&_svg]:size-3.5",children:(0,eb.jsx)(yn,{})}):null]})]}),(0,eb.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[12px] leading-5",children:[(0,eb.jsx)("span",{className:"text-foreground",children:function(e){switch(e.source){case"timer":if(e.cron)return`⏱ cron: ${e.cron}`;if(e.intervalSec&&e.intervalSec>0)return`⏱ 每 ${e.intervalSec}s`;if(e.delaySec&&e.delaySec>0)return`⏱ ${e.delaySec}s 后`;return"⏱ 定时";case"process_exit":return"⛔ 进程退出";case"webhook":return"🔌 webhook";case"file":return`📁 文件变化${e.path?`: ${e.path}`:""}`;case"shell_poll":return`🐚 shell${e.command?`: ${e.command}`:""}`;case"lifecycle":return`🔁 生命周期${e.event?`: ${e.event}`:""}`;default:return e.source}}(e.trigger)}),(0,eb.jsx)("span",{className:"text-muted-foreground/50",children:"→"}),(0,eb.jsx)("span",{className:"text-muted-foreground",children:function(e){switch(e.type){case"resume_conversation":return"唤醒本会话";case"run_command":return`运行命令${e.command?`: ${e.command}`:""}`;case"start_conversation":return"新建会话";default:return e.type}}(e.action)})]})]})}function etW({conversationId:e}){let[t,n]=ew.useState([]),[r,a]=ew.useState(void 0),[i,o]=ew.useState(!1),l=ew.useCallback(async()=>{n(await s1(e))},[e]);async function s(t){a(t);try{let r=await s4(e,t);n(e=>e.map(e=>e.id===t?r:e))}catch{await l()}finally{a(void 0)}}async function c(t){a(t);try{await s5(e,t),n(e=>e.filter(e=>e.id!==t))}catch{await l()}finally{a(void 0)}}async function d(t){let r=await s2(e,t);n(e=>[...e,r])}return ew.useEffect(()=>{let t=!0,r=async()=>{let r=await s1(e);t&&n(r)};r();let a=window.setInterval(r,2e3);return()=>{t=!1,window.clearInterval(a)}},[e]),(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-baseline gap-2",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold text-foreground",children:"Hook"}),(0,eb.jsxs)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[t.filter(e=>e.enabled&&!e.disabled).length,"/",t.length," 启用"]})]}),(0,eb.jsx)("div",{className:"flex shrink-0 items-center gap-1.5",children:(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",variant:"outline",className:"h-8",onClick:()=>o(!0),children:[(0,eb.jsx)(lY,{className:"size-4"}),"新建"]})})]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"本对话的 Hook:外部事件触发后唤醒 / 运行命令 / 新建会话。"}),0===t.length?(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"暂无 hook"}):(0,eb.jsx)("div",{className:"grid gap-2 sm:grid-cols-2",children:t.map(e=>(0,eb.jsx)(etq,{hook:e,busy:r===e.id,onToggle:()=>void s(e.id),onDelete:()=>void c(e.id)},e.id))}),(0,eb.jsx)(etG,{open:i,onOpenChange:o,onCreate:d})]})}function etK({projectId:e}){let[t,n]=ew.useState(""),[r,a]=ew.useState([]),[i,o]=ew.useState(!0),[l,s]=ew.useState(!1),[c,d]=ew.useState(""),[u,f]=ew.useState(!1),[m,h]=ew.useState(!1),[p,g]=ew.useState("[]"),x=ew.useCallback(async()=>{o(!0),d("");try{let t=await etk(e);n(t.folder),a(t.hooks??[])}catch(e){d(e instanceof Error?e.message:"读取工程 Hook 失败")}finally{o(!1)}},[e]);ew.useEffect(()=>{x()},[x]);let v=ew.useCallback(async t=>{s(!0),d("");try{let r=await etN(e,t);n(r.folder),a(r.hooks??t)}catch(e){d(e instanceof Error?e.message:"保存失败"),await x()}finally{s(!1)}},[e,x]);async function b(e){let t=[...r,{...e,enabled:!0}];a(t),await v(t)}async function y(){try{let e=JSON.parse(p);if(!Array.isArray(e))throw Error("内容必须是 Hook 数组(JSON array)");await v(e),h(!1)}catch(e){d(e instanceof Error?e.message:"JSON 无效")}}return(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-baseline gap-2",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold text-foreground",children:"Hook"}),(0,eb.jsxs)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[r.filter(e=>e.enabled??!0).length,"/",r.length," 启用"]})]}),(0,eb.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[(0,eb.jsx)(eO.Button,{type:"button",size:"sm",variant:"ghost",className:"h-8 text-xs",onClick:function(){g(JSON.stringify(r,null,2)),h(!0)},disabled:i,children:"编辑 JSON"}),(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",variant:"outline",className:"h-8",onClick:()=>f(!0),disabled:l,children:[(0,eb.jsx)(lY,{className:"size-4"}),"新建"]})]})]}),(0,eb.jsxs)("p",{className:"text-xs text-muted-foreground",children:["工程 Hook 写入 ",(0,eb.jsx)("code",{className:"font-mono",children:".vantaloom/hooks.json"}),",对本工程的",(0,eb.jsx)("strong",{children:"所有对话"}),"生效。",t?(0,eb.jsxs)("span",{className:"ml-1 break-all text-muted-foreground/70",children:["(",t,")"]}):null]}),c?(0,eb.jsx)("p",{className:"text-sm text-destructive",children:c}):null,i?(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取工程 Hook"}):0===r.length?(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"暂无 hook"}):(0,eb.jsx)("div",{className:"grid gap-2 sm:grid-cols-2",children:r.map((e,t)=>(0,eb.jsx)(etq,{hook:e,busy:l,onToggle:()=>{let e;a(e=r.map((e,n)=>n===t?{...e,enabled:!(e.enabled??!0)}:e)),v(e)},onDelete:()=>{let e;a(e=r.filter((e,n)=>n!==t)),v(e)}},e.id||t))}),(0,eb.jsx)(etG,{open:u,onOpenChange:f,onCreate:b}),(0,eb.jsx)(dX,{open:m,onOpenChange:h,children:(0,eb.jsxs)(fU,{className:"max-w-2xl",children:[(0,eb.jsxs)(fq,{children:[(0,eb.jsx)(fK,{children:"编辑工程 Hook(JSON)"}),(0,eb.jsx)(fG,{children:"直接编辑 .vantaloom/hooks.json 的 Hook 数组。"})]}),(0,eb.jsx)(w2,{value:p,onChange:e=>g(e.currentTarget.value),rows:16,className:"resize-y font-mono text-xs",spellCheck:!1}),(0,eb.jsxs)(fW,{children:[(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",onClick:()=>h(!1),children:"取消"}),(0,eb.jsxs)(eO.Button,{type:"button",onClick:()=>void y(),disabled:l,children:[(0,eb.jsx)(Xj,{className:"size-4"}),"保存"]})]})]})})]})}function etG({open:e,onOpenChange:t,onCreate:n}){let[r,a]=ew.useState(""),[i,o]=ew.useState("timer"),[l,s]=ew.useState("60"),[c,d]=ew.useState(""),[u,f]=ew.useState(""),[m,h]=ew.useState(""),[p,g]=ew.useState("resume_conversation"),[x,v]=ew.useState(""),[b,y]=ew.useState(""),[w,j]=ew.useState(!1),[k,N]=ew.useState(!1),[S,C]=ew.useState("");async function M(){N(!0),C("");try{let e={source:i};"timer"===i?c.trim()?e.cron=c.trim():e.delaySec=Math.max(0,Number(l)||0):"file"===i?e.path=u.trim():"shell_poll"===i&&(e.command=m.trim());let a={type:p};"run_command"===p?a.command=b.trim():x.trim()&&(a.prompt=x.trim()),await n({name:r.trim()||void 0,trigger:e,action:a,once:w}),t(!1)}catch(e){C(e instanceof Error?e.message:"创建 hook 失败")}finally{N(!1)}}return ew.useEffect(()=>{e&&(a(""),o("timer"),s("60"),d(""),f(""),h(""),g("resume_conversation"),v(""),y(""),j(!1),C(""))},[e]),(0,eb.jsx)(dX,{open:e,onOpenChange:t,children:(0,eb.jsxs)(fU,{className:"max-w-md",children:[(0,eb.jsx)(fq,{children:(0,eb.jsx)(fK,{children:"新建 Hook"})}),(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"名称(可选)"}),(0,eb.jsx)(eA,{value:r,onChange:e=>a(e.currentTarget.value),placeholder:"例如 编译完成后继续"})]}),(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"触发源"}),(0,eb.jsxs)(gU,{value:i,onValueChange:e=>o(e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:etH.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})]}),"timer"===i?(0,eb.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"延迟(秒)"}),(0,eb.jsx)(eA,{type:"number",min:0,value:l,onChange:e=>s(e.currentTarget.value),disabled:!!c.trim()})]}),(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"或 cron"}),(0,eb.jsx)(eA,{value:c,onChange:e=>d(e.currentTarget.value),placeholder:"*/5 * * * *"})]})]}):null,"file"===i?(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"监视路径"}),(0,eb.jsx)(eA,{value:u,onChange:e=>f(e.currentTarget.value),placeholder:"例如 ./dist"})]}):null,"shell_poll"===i?(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"轮询命令"}),(0,eb.jsx)(eA,{value:m,onChange:e=>h(e.currentTarget.value),placeholder:"例如 test -f /tmp/done"})]}):null,(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"动作"}),(0,eb.jsxs)(gU,{value:p,onValueChange:e=>g(e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:etU.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})]}),"run_command"===p?(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"命令"}),(0,eb.jsx)(eA,{value:b,onChange:e=>y(e.currentTarget.value),placeholder:"例如 npm run build"})]}):(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"提示词(可选)"}),(0,eb.jsx)(eA,{value:x,onChange:e=>v(e.currentTarget.value),placeholder:"触发时注入的提示词"})]}),(0,eb.jsxs)("label",{className:"flex items-center justify-between gap-2 text-sm",children:[(0,eb.jsx)("span",{children:"仅触发一次"}),(0,eb.jsx)(bG,{checked:w,onCheckedChange:j})]}),S?(0,eb.jsx)("p",{className:"text-xs text-destructive",children:S}):null]}),(0,eb.jsxs)(fW,{children:[(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:k,children:"取消"}),(0,eb.jsx)(eO.Button,{type:"button",onClick:()=>void M(),disabled:k,children:k?"创建中":"创建"})]})]})})}let etX=(0,l0.cva)("vtl-surface-card relative w-full rounded-[var(--surface-card-radius)] border px-4 py-3 text-sm [&>svg]:absolute [&>svg]:top-3.5 [&>svg]:left-4 [&>svg~*]:pl-7",{variants:{variant:{default:"border-border",muted:"border-border bg-muted/40",destructive:"border-destructive/35 bg-destructive/10 text-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}});function etY({className:e,variant:t,...n}){return(0,eb.jsx)("div",{role:"alert","data-slot":"alert",className:(0,ez.cn)(etX({variant:t}),e),...n})}function etZ({className:e,...t}){return(0,eb.jsx)("div",{"data-slot":"alert-title",className:(0,ez.cn)("mb-1 leading-none font-medium",e),...t})}function etJ({className:e,...t}){return(0,eb.jsx)("div",{"data-slot":"alert-description",className:(0,ez.cn)("text-muted-foreground [&_p]:leading-relaxed",e),...t})}var etQ=["PageUp","PageDown"],et0=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],et1={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},et2="Slider",[et5,et4,et3]=hc(et2),[et6,et8]=cC(et2,[et3]),[et7,et9]=et6(et2),ene=ew.forwardRef((e,t)=>{let{name:n,min:r=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:l=!1,minStepsBetweenThumbs:s=0,defaultValue:c=[r],value:d,onValueChange:u=()=>{},onValueCommit:f=()=>{},inverted:m=!1,form:h,...p}=e,g=ew.useRef(new Set),x=ew.useRef(0),v="horizontal"===o,[b=[],y]=cT({prop:d,defaultProp:c,onChange:e=>{let t=[...g.current];t[x.current]?.focus(),u(e)}}),w=ew.useRef(b);function j(e,t,{commit:n}={commit:!1}){let o,l=(String(i).split(".")[1]||"").length,c=pn(Math.round((Math.round((e-r)/i)*i+r)*(o=Math.pow(10,l)))/o,[r,a]);y((e=[])=>{let r=function(e=[],t,n){let r=[...e];return r[n]=t,r.sort((e,t)=>e-t)}(e,c,t);if(!function(e,t){if(t>0)return Math.min(...e.slice(0,-1).map((t,n)=>e[n+1]-t))>=t;return!0}(r,s*i))return e;{x.current=r.indexOf(c);let t=String(r)!==String(e);return t&&n&&f(r),t?r:e}})}return(0,eb.jsx)(et7,{scope:e.__scopeSlider,name:n,disabled:l,min:r,max:a,valueIndexToChangeRef:x,thumbs:g.current,values:b,orientation:o,form:h,children:(0,eb.jsx)(et5.Provider,{scope:e.__scopeSlider,children:(0,eb.jsx)(et5.Slot,{scope:e.__scopeSlider,children:(0,eb.jsx)(v?enr:ena,{"aria-disabled":l,"data-disabled":l?"":void 0,...p,ref:t,onPointerDown:cE(p.onPointerDown,()=>{l||(w.current=b)}),min:r,max:a,inverted:m,onSlideStart:l?void 0:function(e){let t=function(e,t){if(1===e.length)return 0;let n=e.map(e=>Math.abs(e-t)),r=Math.min(...n);return n.indexOf(r)}(b,e);j(e,t)},onSlideMove:l?void 0:function(e){j(e,x.current)},onSlideEnd:l?void 0:function(){let e=w.current[x.current];b[x.current]!==e&&f(b)},onHomeKeyDown:()=>!l&&j(r,0,{commit:!0}),onEndKeyDown:()=>!l&&j(a,b.length-1,{commit:!0}),onStepKeyDown:({event:e,direction:t})=>{if(!l){let n=etQ.includes(e.key)||e.shiftKey&&et0.includes(e.key),r=x.current;j(b[r]+i*(n?10:1)*t,r,{commit:!0})}}})})})})});ene.displayName=et2;var[ent,enn]=et6(et2,{startEdge:"left",endEdge:"right",size:"width",direction:1}),enr=ew.forwardRef((e,t)=>{let{min:n,max:r,dir:a,inverted:i,onSlideStart:o,onSlideMove:l,onSlideEnd:s,onStepKeyDown:c,...d}=e,[u,f]=ew.useState(null),m=(0,cM.useComposedRefs)(t,e=>f(e)),h=ew.useRef(void 0),p=hh(a),g="ltr"===p,x=g&&!i||!g&&i;function v(e){let t=h.current||u.getBoundingClientRect(),a=enp([0,t.width],x?[n,r]:[r,n]);return h.current=t,a(e-t.left)}return(0,eb.jsx)(ent,{scope:e.__scopeSlider,startEdge:x?"left":"right",endEdge:x?"right":"left",direction:x?1:-1,size:"width",children:(0,eb.jsx)(eni,{dir:p,"data-orientation":"horizontal",...d,ref:m,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:e=>{let t=v(e.clientX);o?.(t)},onSlideMove:e=>{let t=v(e.clientX);l?.(t)},onSlideEnd:()=>{h.current=void 0,s?.()},onStepKeyDown:e=>{let t=et1[x?"from-left":"from-right"].includes(e.key);c?.({event:e,direction:t?-1:1})}})})}),ena=ew.forwardRef((e,t)=>{let{min:n,max:r,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:l,onStepKeyDown:s,...c}=e,d=ew.useRef(null),u=(0,cM.useComposedRefs)(t,d),f=ew.useRef(void 0),m=!a;function h(e){let t=f.current||d.current.getBoundingClientRect(),a=enp([0,t.height],m?[r,n]:[n,r]);return f.current=t,a(e-t.top)}return(0,eb.jsx)(ent,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:(0,eb.jsx)(eni,{"data-orientation":"vertical",...c,ref:u,style:{...c.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:e=>{let t=h(e.clientY);i?.(t)},onSlideMove:e=>{let t=h(e.clientY);o?.(t)},onSlideEnd:()=>{f.current=void 0,l?.()},onStepKeyDown:e=>{let t=et1[m?"from-bottom":"from-top"].includes(e.key);s?.({event:e,direction:t?-1:1})}})})}),eni=ew.forwardRef((e,t)=>{let{__scopeSlider:n,onSlideStart:r,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:l,onStepKeyDown:s,...c}=e,d=et9(et2,n);return(0,eb.jsx)(cL.span,{...c,ref:t,onKeyDown:cE(e.onKeyDown,e=>{"Home"===e.key?(o(e),e.preventDefault()):"End"===e.key?(l(e),e.preventDefault()):etQ.concat(et0).includes(e.key)&&(s(e),e.preventDefault())}),onPointerDown:cE(e.onPointerDown,e=>{let t=e.target;t.setPointerCapture(e.pointerId),e.preventDefault(),d.thumbs.has(t)?t.focus():r(e)}),onPointerMove:cE(e.onPointerMove,e=>{e.target.hasPointerCapture(e.pointerId)&&a(e)}),onPointerUp:cE(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&(t.releasePointerCapture(e.pointerId),i(e))})})}),eno="SliderTrack",enl=ew.forwardRef((e,t)=>{let{__scopeSlider:n,...r}=e,a=et9(eno,n);return(0,eb.jsx)(cL.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:t})});enl.displayName=eno;var ens="SliderRange",enc=ew.forwardRef((e,t)=>{let{__scopeSlider:n,...r}=e,a=et9(ens,n),i=enn(ens,n),o=ew.useRef(null),l=(0,cM.useComposedRefs)(t,o),s=a.values.length,c=a.values.map(e=>enh(e,a.min,a.max)),d=s>1?Math.min(...c):0,u=100-Math.max(...c);return(0,eb.jsx)(cL.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:l,style:{...e.style,[i.startEdge]:d+"%",[i.endEdge]:u+"%"}})});enc.displayName=ens;var end="SliderThumb",enu=ew.forwardRef((e,t)=>{let n=et4(e.__scopeSlider),[r,a]=ew.useState(null),i=(0,cM.useComposedRefs)(t,e=>a(e)),o=ew.useMemo(()=>r?n().findIndex(e=>e.ref.current===r):-1,[n,r]);return(0,eb.jsx)(enf,{...e,ref:i,index:o})}),enf=ew.forwardRef((e,t)=>{var n,r,a,i,o;let l,s,{__scopeSlider:c,index:d,name:u,...f}=e,m=et9(end,c),h=enn(end,c),[p,g]=ew.useState(null),x=(0,cM.useComposedRefs)(t,e=>g(e)),v=!p||m.form||!!p.closest("form"),b=gd(p),y=m.values[d],w=void 0===y?0:enh(y,m.min,m.max),j=(n=d,(r=m.values.length)>2?`Value ${n+1} of ${r}`:2===r?["Minimum","Maximum"][n]:void 0),k=b?.[h.size],N=k?(a=k,i=w,o=h.direction,s=enp([0,50],[0,l=a/2]),(l-s(i)*o)*o):0;return ew.useEffect(()=>{if(p)return m.thumbs.add(p),()=>{m.thumbs.delete(p)}},[p,m.thumbs]),(0,eb.jsxs)("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[h.startEdge]:`calc(${w}% + ${N}px)`},children:[(0,eb.jsx)(et5.ItemSlot,{scope:e.__scopeSlider,children:(0,eb.jsx)(cL.span,{role:"slider","aria-label":e["aria-label"]||j,"aria-valuemin":m.min,"aria-valuenow":y,"aria-valuemax":m.max,"aria-orientation":m.orientation,"data-orientation":m.orientation,"data-disabled":m.disabled?"":void 0,tabIndex:m.disabled?void 0:0,...f,ref:x,style:void 0===y?{display:"none"}:e.style,onFocus:cE(e.onFocus,()=>{m.valueIndexToChangeRef.current=d})})}),v&&(0,eb.jsx)(enm,{name:u??(m.name?m.name+(m.values.length>1?"[]":""):void 0),form:m.form,value:y},d)]})});enu.displayName=end;var enm=ew.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{let a=ew.useRef(null),i=(0,cM.useComposedRefs)(a,r),o=gI(t);return ew.useEffect(()=>{let e=a.current;if(!e)return;let n=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set;if(o!==t&&n){let r=new Event("input",{bubbles:!0});n.call(e,t),e.dispatchEvent(r)}},[o,t]),(0,eb.jsx)(cL.input,{style:{display:"none"},...n,ref:i,defaultValue:t})});function enh(e,t,n){return pn(100/(n-t)*(e-t),[0,100])}function enp(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function eng(e){return Array.isArray(e)?e:"number"==typeof e?[e]:void 0}function enx({className:e,defaultValue:t,value:n,min:r=0,max:a=100,...i}){let o=ew.useMemo(()=>eng(n)??eng(t)??[r,a],[t,a,r,n]);return(0,eb.jsxs)(ene,{"data-slot":"slider",defaultValue:eng(t),value:eng(n),min:r,max:a,className:(0,ez.cn)("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-40 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",e),...i,children:[(0,eb.jsx)(enl,{"data-slot":"slider-track",className:"relative grow overflow-hidden rounded-full bg-muted data-[orientation=horizontal]:h-1 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1",children:(0,eb.jsx)(enc,{"data-slot":"slider-range",className:"absolute bg-primary data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"})}),o.map((e,t)=>(0,eb.jsx)(enu,{"data-slot":"slider-thumb",className:"relative block size-3 shrink-0 rounded-full border border-ring bg-white shadow-sm transition-[color,box-shadow] select-none after:absolute after:-inset-2 hover:ring-3 hover:ring-ring/50 focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-hidden active:ring-3 active:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 dark:bg-primary-foreground"},t))]})}function env({dirty:e,saving:t,onSave:n,onReset:r,savedAt:a,error:i,validationMessage:o}){let l=e||!!i||!!a;return(0,eb.jsx)("div",{className:"pointer-events-none sticky inset-x-0 bottom-4 z-10 mt-2 flex justify-center",children:(0,eb.jsxs)("div",{className:(0,ez.cn)("pointer-events-auto flex items-center gap-3 rounded-full border border-border bg-card/95 px-4 py-2 shadow-lg backdrop-blur transition-opacity",l?"opacity-100":"pointer-events-none opacity-0"),children:[i?(0,eb.jsx)("span",{className:"text-xs text-hot-pink",children:i}):o?(0,eb.jsx)("span",{className:"text-xs text-amber-500",children:o}):e?(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:"有未保存的更改"}):a?(0,eb.jsxs)("span",{className:"flex items-center gap-1 text-xs text-emerald-600 dark:text-emerald-400 [&_svg]:size-3.5",children:[(0,eb.jsx)(h6,{}),"已保存"]}):null,e&&r?(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"sm",disabled:t,onClick:r,children:"撤销"}):null,(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",disabled:!e||t||!!o,onClick:n,children:[t?(0,eb.jsx)(eM,{className:"size-4 animate-spin"}):(0,eb.jsx)(h6,{className:"size-4"}),"保存"]})]})})}function enb(e){return{enable:e.memory?.enable??!0,injectBudgetTokens:e.memory?.injectBudgetTokens||2e3,autoCapture:e.memory?.autoCapture??!0}}function eny(){let[e,t]=ew.useState(null),[n,r]=ew.useState(!0),[a,i]=ew.useState(!1),[o,l]=ew.useState(""),[s,c]=ew.useState(!1),[d,u]=ew.useState(null),f=ew.useRef(null);function m(e){t(t=>t?{...t,...e}:t),c(!0),u(null)}async function h(){if(e&&!a){i(!0),l("");try{let n=await ks({memory:e});f.current=n,t(enb(n)),c(!1),u(Date.now())}catch(e){l(e instanceof Error?e.message:"保存失败")}finally{i(!1)}}}return ew.useEffect(()=>{!async function(){try{let e=await kl();f.current=e,t(enb(e))}catch(e){l(e instanceof Error?e.message:"读取记忆配置失败")}finally{r(!1)}}()},[]),n?(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取记忆配置"}):e?(0,eb.jsxs)("div",{className:"grid gap-6 pb-20",children:[o?(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"错误"}),(0,eb.jsx)(etJ,{children:o})]}):null,(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"总开关"}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"启用记忆系统"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"开启后,每次运行会按相关性把记忆正文自动注入系统提示词(类似 CLAUDE.md 自动加载)。"})]}),(0,eb.jsx)(bG,{checked:e.enable,onCheckedChange:e=>m({enable:e})})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"记忆注入 token 预算"}),(0,eb.jsx)("span",{className:"text-sm tabular-nums text-muted-foreground",children:e.injectBudgetTokens})]}),(0,eb.jsx)(enx,{value:[e.injectBudgetTokens],onValueChange:([e])=>m({injectBudgetTokens:e}),min:200,max:8e3,step:100}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"每次运行自动注入的相关记忆正文上限。超出按相关性截断。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"自动捕获记忆"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"在压缩边界 / 计划检查点复用已有摘要,低频派生并去重写入对话记忆(不额外发模型请求)。"})]}),(0,eb.jsx)(bG,{checked:e.autoCapture,onCheckedChange:e=>m({autoCapture:e})})]})]}),(0,eb.jsx)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:(0,eb.jsx)(etL,{scope:"global"})}),(0,eb.jsx)(env,{dirty:s,saving:a,savedAt:d,onSave:()=>void h(),onReset:function(){f.current&&(t(enb(f.current)),c(!1),l(""))}})]}):(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"读取失败"}),(0,eb.jsx)(etJ,{children:o||"无法加载记忆配置"})]})}function enw(e){return{enable:e.skills?.enable??!0,listingBudgetTokens:e.skills?.listingBudgetTokens||1500}}function enj(){let[e,t]=ew.useState(null),[n,r]=ew.useState(!0),[a,i]=ew.useState(!1),[o,l]=ew.useState(""),[s,c]=ew.useState(!1),[d,u]=ew.useState(null),f=ew.useRef(null);function m(e){t(t=>t?{...t,...e}:t),c(!0),u(null)}async function h(){if(e&&!a){i(!0),l("");try{let n=await ks({skills:e});f.current=n,t(enw(n)),c(!1),u(Date.now())}catch(e){l(e instanceof Error?e.message:"保存失败")}finally{i(!1)}}}return ew.useEffect(()=>{!async function(){try{let e=await kl();f.current=e,t(enw(e))}catch(e){l(e instanceof Error?e.message:"读取技能配置失败")}finally{r(!1)}}()},[]),n?(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取技能配置"}):e?(0,eb.jsxs)("div",{className:"grid gap-6 pb-20",children:[o?(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"错误"}),(0,eb.jsx)(etJ,{children:o})]}):null,(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"总开关"}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"启用技能系统"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"开启后,agent 系统提示词会按相关性动态列出可用技能(仅名称+描述),并可懒加载技能正文。"})]}),(0,eb.jsx)(bG,{checked:e.enable,onCheckedChange:e=>m({enable:e})})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"技能清单 token 预算"}),(0,eb.jsx)("span",{className:"text-sm tabular-nums text-muted-foreground",children:e.listingBudgetTokens})]}),(0,eb.jsx)(enx,{value:[e.listingBudgetTokens],onValueChange:([e])=>m({listingBudgetTokens:e}),min:200,max:6e3,step:100}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"每次运行注入到系统提示词的技能清单上限(只计名称+描述+何时使用)。超出按相关性截断。"})]})]}),(0,eb.jsx)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:(0,eb.jsx)(etD,{scope:"global"})}),(0,eb.jsx)(env,{dirty:s,saving:a,savedAt:d,onSave:()=>void h(),onReset:function(){f.current&&(t(enw(f.current)),c(!1),l(""))}})]}):(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"读取失败"}),(0,eb.jsx)(etJ,{children:o||"无法加载技能配置"})]})}enm.displayName="RadioBubbleInput";let enk={skills:"技能",memory:"记忆",hooks:"Hooks",rules:"规则"},enN={skills:(0,eb.jsx)(kV,{}),memory:(0,eb.jsx)(etg,{}),hooks:(0,eb.jsx)(etx,{}),rules:(0,eb.jsx)(uX,{})};function enS(e,t={}){let{projectId:n,conversationId:r,workspaceFolder:a}=t;return("global"===e?["skills","memory","rules"]:["skills","memory","hooks","rules"]).map(t=>({id:t,title:enk[t],icon:enN[t],content:(t=>{switch(t){case"skills":return(0,eb.jsx)(etD,{scope:e,workspaceFolder:a,conversationId:r});case"memory":return(0,eb.jsx)(etL,{scope:e,workspaceFolder:a,conversationId:r});case"hooks":return(0,eb.jsx)(etV,{scope:e,projectId:n,conversationId:r});case"rules":return(0,eb.jsx)(et$,{scope:e,conversationId:r,workspaceFolder:a})}})(t)}))}function enC({scope:e,projectId:t,conversationId:n,workspaceFolder:r}){return"global"===e?(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsx)("header",{className:"flex items-center justify-between gap-3 border-b px-4 py-3",children:(0,eb.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(kV,{}),"扩展 / 资产"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:"扩展 / 资产"})]})}),(0,eb.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,eb.jsx)(etm,{sections:[{id:"skills",title:enk.skills,icon:enN.skills,content:(0,eb.jsx)(enj,{})},{id:"memory",title:enk.memory,icon:enN.memory,content:(0,eb.jsx)(eny,{})},{id:"rules",title:enk.rules,icon:enN.rules,content:(0,eb.jsx)(et$,{scope:"global"})}],defaultSectionId:"skills",labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto"})})]}):null}function enM({skillPolicy:e,memoryPolicy:t,onSkillPolicyChange:n,onMemoryPolicyChange:r}){return(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"本对话策略"}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"技能"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"关闭后,本对话的 agent 不会获得技能工具,系统提示词也不再列出可用技能。"})]}),(0,eb.jsx)(bG,{checked:"off"!==(e||"on"),onCheckedChange:e=>n(e?"on":"off")})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"记忆"}),(0,eb.jsxs)(gU,{value:t||"on",onValueChange:r,children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsxs)(xS,{children:[(0,eb.jsx)(xC,{value:"on",children:"开启(注入 + 可读写)"}),(0,eb.jsx)(xC,{value:"readonly",children:"只读(注入 + 仅可读,禁止写入/删除)"}),(0,eb.jsx)(xC,{value:"off",children:"关闭(不注入、不提供工具)"})]})]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"控制本对话的记忆工具与 <memory> 自动注入。"})]})]})}let enE=[{id:"models",label:"模型"},{id:"tools",label:"工具权限"},{id:"commands",label:"禁止命令"},{id:"folders",label:"工作区文件夹"},{id:"assets",label:"扩展"},{id:"hosts",label:"可访问主机"}];function enI({conversation:e,mainModels:t,ccModel:n="",sessionSettings:r,onMainModelsChange:a,onCcModelChange:i,onSessionSettingsChange:o,onSkillPolicyChange:l,onMemoryPolicyChange:s,onClose:c,onEnterConversation:d}){let[u,f]=ew.useState("models"),m=kt(e.settings.engine),h={models:(0,eb.jsxs)("div",{className:"grid gap-4",children:[(0,eb.jsxs)("div",{className:"grid grid-cols-[5rem_minmax(0,1fr)] items-center gap-3 rounded-lg border bg-card px-3 py-2.5",children:[(0,eb.jsx)("span",{className:"text-sm text-muted-foreground",children:"运行引擎"}),(0,eb.jsx)("span",{className:"truncate text-sm font-medium text-foreground",children:function(e){switch(e){case"claude-code":return"Claude Code";case"reclaude":return"reclaude";default:return"Vantaloom"}}(e.settings.engine)})]}),m?(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsx)("label",{htmlFor:"conversation-cc-model",className:"text-base font-semibold tracking-normal text-foreground",children:"Claude Code 模型"}),(0,eb.jsxs)(gU,{value:""===n?j9:n,onValueChange:e=>i?.(e===j9?"":e),children:[(0,eb.jsx)(xj,{id:"conversation-cc-model",className:"w-full",children:(0,eb.jsx)(gG,{placeholder:"选择 Claude Code 模型"})}),(0,eb.jsx)(xS,{children:ke.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"模型由 Claude Code 提供,不走 Vantaloom 模型路由。"})]}):(0,eb.jsx)(vU,{conversation:e,mainModels:t,onMainModelsChange:a})]}),tools:(0,eb.jsx)(j0,{value:r.allowedTools,onChange:e=>o({...r,allowedTools:e,deniedTools:[]})}),commands:(0,eb.jsx)(j1,{value:r.blockedCommands,onChange:e=>o({...r,blockedCommands:e})}),folders:(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsx)(j2,{title:"可访问的工作区文件夹",value:r.folders,onValueChange:e=>o({...r,folders:m?e.slice(-1):e})}),m?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"Claude Code 仅支持单个工作目录(作为会话的工作根目录)。"}):null]}),hosts:(0,eb.jsx)(j7,{value:r.hosts,onValueChange:e=>o({...r,hosts:e}),disabled:m,hint:m?"Claude Code 的工具锁定在所选 owner 机器本地,可访问主机已锁定。":void 0})},p=enE.filter(e=>"assets"!==e.id||!m).map(t=>"assets"===t.id?{id:t.id,title:t.label,children:[{id:"policy",title:"策略",content:(0,eb.jsx)("div",{className:"w-full",children:(0,eb.jsx)(enM,{skillPolicy:e.settings.skillPolicy,memoryPolicy:e.settings.memoryPolicy,onSkillPolicyChange:e=>l?.(e),onMemoryPolicyChange:e=>s?.(e)})})},...enS("conversation",{conversationId:e.id,workspaceFolder:e.settings.folders?.[0]}).map(e=>({...e,content:(0,eb.jsx)("div",{className:"w-full",children:e.content})}))]}:{id:t.id,title:t.label,content:(0,eb.jsx)("div",{className:"w-full",children:h[t.id]})});return(0,eb.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex items-center gap-2 border-b px-3 py-2.5",children:[(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon","aria-label":"关闭设置",onClick:c,className:"shrink-0",children:(0,eb.jsx)(fV.XIcon,{className:"size-5"})}),(0,eb.jsxs)("button",{type:"button",className:"min-w-0 flex-1 rounded-lg px-2 py-1 text-left transition-colors hover:bg-muted/60",title:"返回该对话",onClick:()=>d?.(e),children:[(0,eb.jsxs)("div",{className:"text-[11px] text-muted-foreground",children:[e.agent," · 会话设置"]}),(0,eb.jsx)("div",{className:"truncate text-sm font-semibold",children:e.title})]})]}),(0,eb.jsx)(etm,{sections:p,sectionId:u,onSelectionChange:({sectionId:e})=>f(e),defaultSectionId:p[0]?.id,labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",contentClassName:"overflow-y-auto pb-[max(1.25rem,env(safe-area-inset-bottom))]"})]})}function enP({conversationId:e,ownerMachineId:t,open:n,onOpenChange:r,onEnterConversation:a}){let[i,o]=ew.useState(),[l,s]=ew.useState(),[c,d]=ew.useState([]),[u,f]=ew.useState(""),[m,h]=ew.useState({folders:[],blockedCommands:[],allowedTools:[],deniedTools:[],plugins:[],hosts:[]});async function p(e){if(!i)return;let n=e.session??m,r=e.mainModels??c,a=e.ccModel??u,l={subagents:i.settings.subagents??[],mainModels:r,folders:n.folders,blockedCommands:n.blockedCommands,allowedTools:n.allowedTools,deniedTools:n.deniedTools,plugins:n.plugins,hosts:n.hosts,permissionMode:n.permissionMode??i.settings.permissionMode,engine:i.settings.engine,ccModel:i.settings.engine?a:void 0,skillPolicy:e.skillPolicy??i.settings.skillPolicy,memoryPolicy:e.memoryPolicy??i.settings.memoryPolicy};try{let e=await sY(i.id,{settings:l},t);o(e.conversation)}catch{}}function g(){o(void 0),s(void 0),r(!1)}return(ew.useEffect(()=>{if(!n||!e)return;let r=!0;return async function(){try{let n=await sD(e,t);if(!r)return;let a=n.conversation;o(a),s(n.conversation.projectId?.trim()||void 0),d(a.settings.mainModels),f(a.settings.ccModel??""),h({folders:a.settings.folders,blockedCommands:a.settings.blockedCommands,allowedTools:a.settings.allowedTools,deniedTools:a.settings.deniedTools,plugins:a.settings.plugins,hosts:a.settings.hosts})}catch{}}(),()=>{r=!1}},[e,n,t]),n&&i)?l?(0,eb.jsx)(enO,{conversation:i,onClose:g,onEnterConversation:()=>{g(),a?.(i.id,t)}}):(0,eb.jsx)(enI,{conversation:i,mainModels:c,ccModel:u,sessionSettings:m,onMainModelsChange:e=>{d(e),p({mainModels:e})},onCcModelChange:e=>{f(e),p({ccModel:e})},onSessionSettingsChange:e=>{h(e),p({session:e})},onSkillPolicyChange:e=>{o(t=>t?{...t,settings:{...t.settings,skillPolicy:e}}:t),p({skillPolicy:e})},onMemoryPolicyChange:e=>{o(t=>t?{...t,settings:{...t.settings,memoryPolicy:e}}:t),p({memoryPolicy:e})},onClose:g,onEnterConversation:e=>{g(),a?.(e.id,t)}}):null}function enO({conversation:e,onClose:t,onEnterConversation:n}){return(0,eb.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex items-center gap-2 border-b px-3 py-2.5",children:[(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon","aria-label":"关闭设置",onClick:t,className:"shrink-0",children:(0,eb.jsx)(fV.XIcon,{className:"size-5"})}),(0,eb.jsxs)("button",{type:"button",className:"min-w-0 flex-1 rounded-lg px-2 py-1 text-left transition-colors hover:bg-muted/60",title:"返回该对话",onClick:n,children:[(0,eb.jsxs)("div",{className:"text-[11px] text-muted-foreground",children:[e.agent," · 会话设置"]}),(0,eb.jsx)("div",{className:"truncate text-sm font-semibold",children:e.title})]})]}),(0,eb.jsx)("div",{className:"flex flex-1 items-center justify-center p-6",children:(0,eb.jsxs)("div",{className:"flex max-w-md flex-col items-center gap-3 rounded-xl border border-border bg-card px-6 py-8 text-center shadow-sm",children:[(0,eb.jsx)("div",{className:"flex size-12 items-center justify-center rounded-full bg-muted text-muted-foreground",children:(0,eb.jsx)(lq,{className:"size-6"})}),(0,eb.jsx)("h2",{className:"text-base font-semibold",children:"由所属工程统一管理"}),(0,eb.jsx)("p",{className:"text-sm leading-relaxed text-muted-foreground",children:"此对话由所属工程统一管理,请前往工程设置修改。"})]})})]})}let enz=[{value:"reclaude",label:"reclaude(RC)"},{value:"claude-code",label:"Claude Code(CC)"}];function enA({open:e,onOpenChange:t,ownerMachineId:n,onEnterConversation:r}){let[a,i]=ew.useState([]),[o,l]=ew.useState(!1),[s,c]=ew.useState(""),[d,u]=ew.useState("reclaude"),[f,m]=ew.useState(""),[h,p]=ew.useState(!1),[g,x]=ew.useState(""),v=sv();ew.useEffect(()=>{if(!e)return;c(""),u("reclaude"),m(""),x("");let t=!0;return l(!0),async function(){let e=await sI(n);t&&(i(e),l(!1))}(),()=>{t=!1}},[e,n]);let b=ew.useMemo(()=>a.find(e=>e.sessionId===s),[a,s]);async function y(){if(b&&!h){p(!0),x("");try{let e=await sP({sessionId:b.sessionId,cwd:b.cwd,title:b.title,engine:d,ccModel:f,projectId:""},n);t(!1),r?.(e.conversation.id,n)}catch(e){x(e instanceof Error?e.message:"导入失败,请稍后重试。")}finally{p(!1)}}}return(0,eb.jsx)(dX,{open:e,onOpenChange:t,children:(0,eb.jsxs)(fU,{className:(0,ez.cn)("flex flex-col gap-4",v?"inset-0 h-svh w-full max-w-none translate-x-0 translate-y-0 rounded-none border-0":"max-h-[85vh] max-w-xl"),children:[(0,eb.jsxs)(fq,{children:[(0,eb.jsx)(fK,{children:"导入 Claude 会话"}),(0,eb.jsx)(fG,{children:"从本机已有的 Claude Code 会话创建对话。继续对话将接续原会话的上下文。"})]}),(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto vtl-scrollbar-hidden",children:o?(0,eb.jsxs)("div",{className:"flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground",children:[(0,eb.jsx)(eM,{className:"size-4 animate-spin"}),"正在扫描本机 Claude 会话…"]}):0===a.length?(0,eb.jsx)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:"未发现本机 Claude 会话"}):(0,eb.jsx)("div",{className:"space-y-1",children:a.map(e=>{let t=e.sessionId===s,n=function(e){let t=Date.parse(e);if(!Number.isFinite(t))return"";let n=Math.max(0,Math.floor((Date.now()-t)/1e3));if(n<60)return"刚刚";let r=Math.floor(n/60);if(r<60)return`${r} 分钟前`;let a=Math.floor(r/60);if(a<24)return`${a} 小时前`;let i=Math.floor(a/24);return 1===i?"昨天":i<7?`${i} 天前`:new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric"}).format(t)}(e.lastActivityAt);return(0,eb.jsxs)("button",{type:"button",onClick:()=>c(e.sessionId),className:(0,ez.cn)("w-full rounded-lg border px-3 py-2.5 text-left transition-colors",t?"border-primary bg-primary/5":"border-border hover:bg-muted/60"),children:[(0,eb.jsx)("div",{className:"truncate text-sm font-semibold text-foreground",children:e.title||"未命名会话"}),(0,eb.jsxs)("div",{className:"mt-0.5 flex items-center gap-1 text-xs text-muted-foreground",children:[(0,eb.jsx)(b3,{className:"size-3 shrink-0"}),(0,eb.jsx)("span",{className:"truncate",children:e.cwd})]}),(0,eb.jsxs)("div",{className:"mt-1 flex items-center gap-2 text-[11px] text-muted-foreground/80",children:[n?(0,eb.jsx)("span",{children:n}):null,n?(0,eb.jsx)("span",{children:"·"}):null,(0,eb.jsxs)("span",{children:[e.messageCount," 条消息"]})]})]},e.sessionId)})})}),b?(0,eb.jsxs)("div",{className:"grid gap-3 border-t pt-4",children:[(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"引擎"}),(0,eb.jsxs)(gU,{value:d,onValueChange:e=>u(e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{placeholder:"选择运行引擎"})}),(0,eb.jsx)(xS,{children:enz.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})]}),(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"CC 模型"}),(0,eb.jsxs)(gU,{value:""===f?j9:f,onValueChange:e=>m(e===j9?"":e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{placeholder:"选择 Claude Code 模型"})}),(0,eb.jsx)(xS,{children:ke.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground/80",children:"其余设置(工作目录等)将按所选会话自动导入。"})]}):null,g?(0,eb.jsx)("p",{className:"text-sm text-destructive",children:g}):null,(0,eb.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:h,children:"取消"}),(0,eb.jsx)(eO.Button,{type:"button",onClick:()=>void y(),disabled:!b||h,children:h?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(eM,{className:"size-4 animate-spin"}),"导入中…"]}):"导入并打开"})]})]})})}function enT(e){return!e||"local"===e}async function enR(e,t){return en$(await enF(t,`/${encodeURIComponent(e)}`),t)}async function enD(e,t){return en$(await enF(t,"",{method:"POST",body:JSON.stringify({title:e.title,nodes:e.nodes.map(fo),edges:e.edges.map(fl)})}),t)}async function en_(e,t,n){return en$(await enF(n,`/${encodeURIComponent(e)}/save`,{method:"PUT",body:JSON.stringify({nodes:t.nodes.map(fo),edges:t.edges.map(fl),nodeIds:t.nodeIds})}),n)}async function enL(e,t){return en$(await enF(t,`/${encodeURIComponent(e)}/open`,{method:"POST"}),t)}function en$(e,t){var n,r;let a;return{canvas:(n=e.canvas,a=enT(r=t)?n.ownerMachineId??"local":r,{id:n.id,title:n.title||"新画布",ownerMachineId:a,nodeCount:n.nodeCount??0,running:n.running??!1,createdAt:n.createdAt,updatedAt:n.updatedAt,lastOpenedAt:n.lastOpenedAt}),nodes:e.nodes??[],edges:e.edges??[]}}async function enF(e,t,n,r){let a=await fetch((0,eT.localAPIURL)(enT(e)?`/api/local/canvas${t}`:`/v1/remote/${e}/canvas${t}`),{cache:"no-store",...n,headers:{...n?.body?{"Content-Type":"application/json"}:{},...n?.headers}});if(r?.allowNotFound&&404===a.status)return;let i=await a.json().catch(()=>({}));if(!a.ok)throw Error("string"==typeof i?.error?i.error:"canvas api failed");return i}let enB=(0,ek.default)("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]),enV=(0,ek.default)("lock-keyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]),enH=(0,ek.default)("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),enU=(0,ek.default)("plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]),enq=(0,ek.default)("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),enW=(0,ek.default)("sliders-horizontal",[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]),enK={done:"Done",current:"Current",queued:"Queued",blocked:"Blocked"};function enG(e,t,n){return Math.min(Math.max(e,t),n)}function enX({items:e,currentId:t,labels:n,scrollCurrentIntoView:r=!0,className:a,viewportClassName:i,itemClassName:o,extendLineToViewport:l=!1,...s}){let c={...enK,...n},d=ew.useRef(null),u=ew.useRef(null),f=ew.useRef(null),m=ew.useRef(0),h=ew.useRef(void 0),[p,g]=ew.useState(0),x=t??e.find(e=>"current"===e.status)?.id,v=ew.useCallback(()=>{void 0!==h.current&&(cancelAnimationFrame(h.current),h.current=void 0)},[]),b=ew.useCallback((e,t=340)=>{let n=d.current,r=u.current;if(!n||!r)return;v();let a=Math.max(0,n.scrollHeight-n.clientHeight),i=n.scrollTop,o=enG(e,0,a),l=performance.now();m.current=o;let s=e=>{let r=enG((e-l)/t,0,1);if(n.scrollTop=i+(o-i)*(1-Math.pow(1-r,3)),r<1){h.current=requestAnimationFrame(s);return}n.scrollTop=o,h.current=void 0};h.current=requestAnimationFrame(s)},[v]),y=ew.useCallback(e=>{let t=d.current,n=u.current;if(!t||!n)return;let r=Math.max(0,t.scrollHeight-t.clientHeight);if(r<=0)return;e.preventDefault();let a=void 0===h.current?t.scrollTop:m.current,i=1===e.deltaMode?32*e.deltaY:2===e.deltaMode?e.deltaY*e.currentTarget.clientHeight:e.deltaY,o=Math.sign(i);if(0===o)return;let l=Array.from(n.querySelectorAll("[data-slot='roadmap-item']")).map(e=>e.offsetTop),s=enG(Math.ceil(Math.abs(i)/160),1,3),c=a;for(let e=0;e<s;e+=1)c=function(e,t,n,r){if(0===e.length)return t;if(n>0)return e.find(e=>e>t+1)??r;for(let n=e.length-1;n>=0;n-=1){let r=e[n];if(void 0!==r&&r<t-1)return r}return 0}(l,c,o,r);b(c)},[b]);return ew.useLayoutEffect(()=>{if(!r)return;let e=d.current,t=u.current,n=f.current;if(!e||!t||!n)return void g(0);let a=n.offsetTop,i=t.scrollHeight-p,o=Math.max(0,e.clientHeight-(i-a));g(e=>Math.abs(e-o)>.5?o:e),requestAnimationFrame(()=>{e.scrollTop=a,m.current=a})},[p,e,x,r]),ew.useEffect(()=>v,[v]),(0,eb.jsx)("div",{"data-slot":"roadmap",className:(0,ez.cn)("min-w-0 text-foreground",a),...s,children:(0,eb.jsx)("div",{"data-slot":"roadmap-viewport",ref:d,onWheel:y,className:(0,ez.cn)("max-h-72 overflow-y-auto overscroll-contain pr-2",i),children:(0,eb.jsxs)("div",{ref:u,className:(0,ez.cn)("relative",l&&"min-h-full"),children:[(0,eb.jsx)("span",{"aria-hidden":"true",className:"absolute top-0 bottom-0 left-[0.3125rem] w-px bg-border"}),e.map(e=>{let t=e.id===x?"current":e.status??"queued";return(0,eb.jsxs)("div",{ref:"current"===t?f:void 0,"data-slot":"roadmap-item","data-status":t,"aria-label":c[t],className:(0,ez.cn)("relative grid grid-cols-[1.5rem_minmax(0,1fr)_auto] items-start gap-2 py-2.5",o),children:[(0,eb.jsx)("span",{"aria-hidden":"true","data-slot":"roadmap-marker",className:(0,ez.cn)("relative z-10 mt-1 size-2.5 rounded-full border bg-background","done"===t&&"border-muted-foreground bg-muted-foreground","current"===t&&"border-primary bg-primary","queued"===t&&"border-border","blocked"===t&&"border-destructive bg-destructive")}),(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("div",{"data-slot":"roadmap-title",className:(0,ez.cn)("text-sm leading-5","queued"===t&&"text-muted-foreground","blocked"===t&&"text-destructive"),children:e.title}),e.description?(0,eb.jsx)("div",{"data-slot":"roadmap-description",className:"mt-0.5 text-xs leading-5 text-muted-foreground",children:e.description}):null]}),e.meta?(0,eb.jsx)("div",{"data-slot":"roadmap-meta",className:"pt-0.5 text-right ui-text-kbd text-muted-foreground",children:e.meta}):null]},e.id)}),p>0?(0,eb.jsx)("div",{"aria-hidden":"true","data-slot":"roadmap-bottom-spacer",style:{height:p}}):null]})})})}let enY="/themes/jelly/bg1.png",enZ="/themes/jelly/bg2.png",enJ="/themes/jelly/bg3.png",enQ="/themes/jelly/bg4.png";function en0({image:e,position:t="center",opacity:n=.72,blur:r="10px"}){return{"--vtl-jelly-card-image":`url("${e}")`,"--vtl-jelly-card-position":t,"--vtl-jelly-card-opacity":String(n),"--vtl-jelly-card-blur":r}}function en1({title:e}){return(0,eb.jsx)("h2",{className:"h-7 text-sm font-semibold tracking-normal",children:e})}let en2={product:"Vantaloom",overview:"运维总览",subtitle:"本机服务、工作组机器和 Agent 运行状态。",workgroup:"工作组",health:"系统健康",cost:"今日消耗",activeRuns:"运行中",queue:"排队任务",machineStatus:"机器状态",resourceTrend:"资源趋势",runMix:"运行构成",schedule:"日程提醒",incidents:"关注事项",online:"在线",local:"本机",p2p:"P2P",direct:"直连",sleeping:"休眠",memory:"内存",cpu:"CPU",gpu:"GPU",disk:"磁盘",theme:"主题"},en5={search:"搜索控制台...",dashboard:"仪表盘",canvas:"工程",machines:"机器",schedules:"日程",settings:"设置",overview:"总览",runs:"运行",telemetry:"遥测",canvasRecent:"打开最近工程",canvasNew:"新建工程",canvasAll:"浏览所有画布",projectCanvas:"画布",projectKanban:"看板",projectSettings:"工程设置",projectNewConversation:"新建对话",projectEmpty:"暂无工程",conversationRecent:"打开最近对话",conversationNew:"新建 Agent 对话",conversationAll:"浏览所有对话",fleet:"机器组",access:"访问控制",calendar:"计划任务",billing:"用量与账单"};en2.local,en2.direct,en2.online,en2.p2p,en2.online,en2.direct,en2.sleeping,en2.cpu,en2.memory,en2.activeRuns;function en4(e){return e.reduce((e,t)=>Math.max(e,t.y+t.h),0)}function en3({children:e}){return(0,eb.jsx)("section",{className:"vtl-app-background flex h-full min-h-0 flex-col pb-14 md:pb-0 text-foreground",children:(0,eb.jsx)(jP,{className:"min-h-0 flex-1",children:e})})}function en6(e){return Math.max(0,...e.map(e=>e.y+e.h))}function en8(e,t,n){return t.some(t=>t.id!==n&&e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y)}function en7(e){let t=Math.max(2,Math.min(12,e.w)),n=Math.max(1,e.h),r=Math.max(0,Math.min(12-t,e.x)),a=Math.max(0,e.y);return{...e,x:r,y:a,w:t,h:n}}function en9(e,t,n,r,a){for(let i=0;i<en6(e)+8;i+=1)for(let o=0;o<=12-r;o+=1){let l={id:t,kind:n,x:o,y:i,w:r,h:a};if(!en8(l,e))return l}return{id:t,kind:n,x:0,y:en6(e)+2,w:r,h:a}}function ere(e){return{...e.defaultConfig}}function ert(e){return e.payloads?.[qf]}function ern({open:e,definitions:t,title:n="添加卡片",description:r="搜索并选择要添加到当前页面的卡片。",groupTitle:a="可添加卡片",onOpenChange:i,onAdd:o}){return(0,eb.jsx)(bm,{open:e,onOpenChange:i,title:n,description:r,className:"top-1/2 max-w-xl -translate-y-1/2",children:(0,eb.jsxs)(bf,{loop:!0,children:[(0,eb.jsx)(bh,{placeholder:"搜索可添加卡片..."}),(0,eb.jsxs)(bp,{className:"max-h-[420px]",children:[(0,eb.jsx)(bg,{children:"没有找到可添加的卡片。"}),(0,eb.jsx)(bx,{heading:a,children:t.map(e=>(0,eb.jsxs)(bv,{value:`${e.title} ${e.description}`,keywords:[e.id,e.defaultConfig.dataSource,e.defaultConfig.title],onSelect:()=>o(e.id),className:"min-h-14 items-start py-2",children:[(0,eb.jsx)("span",{className:"mt-0.5 grid size-8 shrink-0 place-items-center rounded-md border bg-background text-muted-foreground",children:e.icon}),(0,eb.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,eb.jsx)("span",{className:"block truncate font-medium",children:e.title}),(0,eb.jsx)("span",{className:"mt-0.5 block truncate ui-text-kbd text-muted-foreground",children:e.description})]}),(0,eb.jsxs)(bb,{children:[e.defaultSize.w,"x",e.defaultSize.h]})]},e.id))})]})]})})}function err({open:e,dragMode:t,label:n="页面卡片操作",onOpenChange:r,onAdd:a,onDragModeChange:i}){let o=[{key:"add",label:"添加卡片",icon:(0,eb.jsx)(lY,{className:"size-4"}),onClick:a,pressed:!1},{key:"drag",label:"拖拽排版",icon:(0,eb.jsx)(lU,{className:"size-4"}),onClick:()=>i(!t),pressed:t}];return(0,eb.jsx)("div",{className:"fixed right-5 bottom-5 z-30",children:(0,eb.jsxs)("div",{className:"relative size-8",children:[o.map((t,n)=>(0,eb.jsx)(eO.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.label,"aria-pressed":t.pressed,onClick:t.onClick,className:(0,ez.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[opacity,transform] duration-150 ease-out",t.pressed&&"border-foreground bg-foreground text-background shadow-lg ring-1 ring-background/50 hover:bg-foreground hover:text-background dark:bg-primary dark:text-primary-foreground dark:hover:bg-primary",e?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0"),style:{transform:e?`translateY(-${(n+1)*42}px)`:void 0},children:t.icon},t.key)),(0,eb.jsx)(eO.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":n,"aria-expanded":e,onClick:()=>r(!e),className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,eb.jsx)(lG,{className:(0,ez.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}let era=(0,ek.default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);function eri({layout:e,layouts:t,cellSize:n,cellHeight:r,dragMode:a,selected:i,resizing:o,onSelect:l,onMove:s,onCut:c,onCopy:d,onSettingsOpen:u,onResizeStart:f,onResizeEnd:m,children:h}){let[p,g]=ew.useState(!1),x=r??n,v=e.x*(n+12),b=e.y*(x+12),y=e.w*n+(e.w-1)*12,w=e.h*x+(e.h-1)*12;return(0,eb.jsxs)("div",{"data-editable-card":e.id,className:(0,ez.cn)("absolute rounded-lg p-1 transition-[left,top,width,height,box-shadow] duration-200 ease-out",a&&"cursor-grab active:cursor-grabbing",p&&"duration-150",i&&!o&&"z-20 shadow-sm",o&&"z-30 transition-none"),style:{left:v,top:b,width:y,height:w},onPointerDown:function(r){if(!a||o)return;let i=r.target;if(i instanceof HTMLElement&&i.closest("[data-editable-card-action]"))return;r.preventDefault(),r.currentTarget.setPointerCapture(r.pointerId),l();let c=r.clientX,d=r.clientY;function u(r){let a=en7({...e,x:e.x+Math.round((r.clientX-c)/(n+12)),y:e.y+Math.round((r.clientY-d)/(n+12))});en8(a,t,e.id)||s(a)}g(!0),window.addEventListener("pointermove",u),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",e),g(!1)})},onClick:()=>{a&&l()},children:[(0,eb.jsx)("div",{className:(0,ez.cn)("size-full",a&&"pointer-events-none"),children:h}),i&&a&&!o?(0,eb.jsx)("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-1 rounded-lg border-2 border-foreground"}):null,i&&a&&!o?(0,eb.jsx)(ero,{onSettingsOpen:u,onCut:c,onCopy:d,onResizeStart:f}):null,o?(0,eb.jsx)(erl,{layout:e,layouts:t,cellSize:n,onResize:s,onResizeEnd:m}):null]})}function ero({onSettingsOpen:e,onCut:t,onCopy:n,onResizeStart:r}){return(0,eb.jsx)(l2,{"data-editable-card-action":!0,placement:"inline",size:"sm","aria-label":"卡片操作",className:"!absolute top-full left-1/2 z-40 mt-2 -translate-x-1/2 rounded-lg bg-popover/95 p-1 shadow-md",onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:(0,eb.jsxs)(l5,{children:[(0,eb.jsx)(l4,{type:"button","aria-label":"调整大小",onClick:r,children:(0,eb.jsx)(lK,{className:"size-4"})}),(0,eb.jsx)(l4,{type:"button","aria-label":"卡片设置",onPointerDown:t=>{t.preventDefault(),t.stopPropagation(),e()},onClick:e=>e.stopPropagation(),children:(0,eb.jsx)(era,{className:"size-4"})}),(0,eb.jsx)(l4,{type:"button","aria-label":"复制",onClick:n,children:(0,eb.jsx)(lV,{className:"size-4"})}),(0,eb.jsx)(l4,{type:"button","aria-label":"剪切",onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),t()},onClick:e=>e.stopPropagation(),children:(0,eb.jsx)(lJ,{className:"size-4"})})]})})}function erl({layout:e,layouts:t,cellSize:n,onResize:r,onResizeEnd:a}){return(0,eb.jsx)("div",{"data-editable-card-action":!0,className:"pointer-events-none absolute inset-1 z-40 border-2 border-foreground",children:[{id:"top-left",className:"top-0 left-0 -translate-x-1/2 -translate-y-1/2 cursor-nwse-resize"},{id:"top",className:"top-0 left-1/2 -translate-x-1/2 -translate-y-1/2 cursor-ns-resize"},{id:"top-right",className:"top-0 right-0 translate-x-1/2 -translate-y-1/2 cursor-nesw-resize"},{id:"right",className:"top-1/2 right-0 translate-x-1/2 -translate-y-1/2 cursor-ew-resize"},{id:"bottom-right",className:"right-0 bottom-0 translate-x-1/2 translate-y-1/2 cursor-nwse-resize"},{id:"bottom",className:"bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2 cursor-ns-resize"},{id:"bottom-left",className:"bottom-0 left-0 -translate-x-1/2 translate-y-1/2 cursor-nesw-resize"},{id:"left",className:"top-1/2 left-0 -translate-x-1/2 -translate-y-1/2 cursor-ew-resize"}].map(i=>(0,eb.jsx)("button",{type:"button","aria-label":`调整 ${i.id}`,className:(0,ez.cn)("pointer-events-auto absolute size-2.5 border border-foreground bg-background shadow-sm",i.className),onPointerDown:o=>(function(i,o){i.preventDefault(),i.stopPropagation(),i.currentTarget.setPointerCapture(i.pointerId);let l=i.clientX,s=i.clientY;function c(a){let i=Math.round((a.clientX-l)/(n+12)),c=Math.round((a.clientY-s)/(n+12)),d={...e};o.includes("right")&&(d.w=e.w+i),o.includes("bottom")&&(d.h=e.h+c),o.includes("left")&&(d.x=e.x+i,d.w=e.w-i),o.includes("top")&&(d.y=e.y+c,d.h=e.h-c),en8(d=en7(d),t,e.id)||r(d)}window.addEventListener("pointermove",c),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",e),a()})})(o,i.id)},i.id))})}function ers({className:e,...t}){return(0,eb.jsx)(d5,{"data-slot":"sheet-overlay",className:(0,ez.cn)("vtl-overlay fixed inset-0 z-50 animate-in fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0",e),...t})}function erc({className:e,children:t,side:n="right",showCloseButton:r=!0,...a}){return(0,eb.jsxs)(d1,{children:[(0,eb.jsx)(ers,{}),(0,eb.jsxs)(d8,{"data-slot":"sheet-content","data-side":n,className:(0,ez.cn)("vtl-surface-modal fixed z-50 flex flex-col gap-4 border transition ease-in-out outline-none data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:animate-in data-[state=open]:duration-300","right"===n&&"inset-y-0 right-0 h-full w-3/4 border-r-0 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm","left"===n&&"inset-y-0 left-0 h-full w-3/4 border-l-0 data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm","top"===n&&"inset-x-0 top-0 h-auto border-t-0 data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top","bottom"===n&&"inset-x-0 bottom-0 h-auto border-b-0 data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",e),...a,children:[t,r&&(0,eb.jsxs)(uo,{className:"absolute top-3 right-3 inline-flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none disabled:pointer-events-none",children:[(0,eb.jsx)(fV.XIcon,{className:"size-4"}),(0,eb.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function erd({className:e,...t}){return(0,eb.jsx)("div",{"data-slot":"sheet-header",className:(0,ez.cn)("grid gap-1.5 p-4 text-left",e),...t})}function eru({className:e,...t}){return(0,eb.jsx)(un,{"data-slot":"sheet-title",className:(0,ez.cn)("text-base leading-none font-semibold text-foreground",e),...t})}function erf({className:e,...t}){return(0,eb.jsx)(ua,{"data-slot":"sheet-description",className:(0,ez.cn)("text-sm text-muted-foreground",e),...t})}function erm({open:e,layout:t,definition:n,config:r,cellSize:a,onOpenChange:i,onConfigChange:o}){let l=t&&a>0?t.w*a+(t.w-1)*12:320,s=t&&a>0?t.h*a+(t.h-1)*12:180;return(0,eb.jsx)(dX,{open:e,onOpenChange:i,children:(0,eb.jsx)(erc,{side:"right",className:"w-screen gap-0 border-0 bg-transparent p-0 shadow-none sm:max-w-none",children:t&&n&&r?(0,eb.jsxs)("div",{className:"grid h-full min-w-0 grid-cols-1 lg:grid-cols-[minmax(0,1fr)_24rem]",children:[(0,eb.jsx)(erh,{width:l,height:s,className:"hidden lg:grid",children:n.render(r)}),(0,eb.jsxs)("div",{className:"animate-in slide-in-from-right-4 flex h-full w-full flex-col border-y-0 border-r-0 bg-background text-foreground shadow-lg duration-300",children:[(0,eb.jsxs)(erd,{className:"border-b",children:[(0,eb.jsx)(eru,{children:"卡片设置"}),(0,eb.jsxs)(erf,{children:[n.title," · ",t.w,"x",t.h]})]}),(0,eb.jsxs)("div",{className:"grid flex-1 content-start gap-4 overflow-y-auto p-4",children:[(0,eb.jsxs)("label",{className:"grid gap-1.5",children:[(0,eb.jsx)("span",{className:"ui-text-control font-medium",children:"显示标题"}),(0,eb.jsx)(eA,{value:r.title,onChange:e=>o({title:e.currentTarget.value})})]}),(0,eb.jsxs)("label",{className:"grid gap-1.5",children:[(0,eb.jsx)("span",{className:"ui-text-control font-medium",children:"数据来源"}),(0,eb.jsx)(eA,{value:r.dataSource,onChange:e=>o({dataSource:e.currentTarget.value})})]}),(0,eb.jsxs)("label",{className:"grid gap-1.5",children:[(0,eb.jsx)("span",{className:"ui-text-control font-medium",children:"刷新间隔"}),(0,eb.jsx)(eA,{value:r.refreshRate,onChange:e=>o({refreshRate:e.currentTarget.value})})]}),(0,eb.jsxs)("label",{className:"grid gap-1.5",children:[(0,eb.jsx)("span",{className:"ui-text-control font-medium",children:"备注"}),(0,eb.jsx)("textarea",{value:r.note,rows:4,className:"min-h-24 resize-none rounded-lg border border-input bg-transparent px-2.5 py-2 ui-text-control transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50",onChange:e=>o({note:e.currentTarget.value})})]}),(0,eb.jsxs)("div",{className:"rounded-lg border bg-muted/20 p-3",children:[(0,eb.jsx)("div",{className:"ui-text-control font-medium",children:"当前绑定"}),(0,eb.jsxs)("div",{className:"mt-2 grid gap-1 ui-text-kbd text-muted-foreground",children:[(0,eb.jsxs)("span",{children:["类型:",n.id]}),(0,eb.jsxs)("span",{children:["来源:",r.dataSource]}),(0,eb.jsxs)("span",{children:["刷新:",r.refreshRate]})]})]})]})]})]}):null})})}function erh({width:e,height:t,className:n,children:r}){let[a,i]=ZC(),o=i.width>0&&i.height>0?Math.min(1,(i.width-32)/e,(i.height-32)/t):1;return(0,eb.jsx)("div",{ref:a,className:(0,ez.cn)("min-h-0 min-w-0 place-items-center overflow-hidden p-4",n),children:(0,eb.jsx)("div",{className:"animate-in fade-in-0 zoom-in-95 origin-center rounded-lg duration-300",style:{width:e,height:t,transform:`scale(${Math.max(.1,o)})`},children:r})})}function erp({boardId:e,definitions:t,initialLayouts:n,clipboardItems:r=[],minRows:a=9,className:i,actionLabel:o,paletteGroupTitle:l,onClipboardItemsChange:s,onOverlayOpenChange:c}){var d;let[u,f]=ew.useState(!1),[m,h]=ew.useState(!1),[p,g]=ew.useState(!1),[x,v]=ew.useState(()=>n),[b,y]=ew.useState({}),[w,j]=ew.useState(),[k,N]=ew.useState(),[S,C]=ew.useState(),M=ew.useRef(0),E=ew.useRef(0),[I,P]=ZC(),O=P.width>0?(d=P.width)<480?2:d<768?4:12:12,z=function(e,t){if(t>=12)return e;let n=[...e].sort((e,t)=>e.y!==t.y?e.y-t.y:e.x-t.x),r=[];for(let e of n){let n=Math.max(2,Math.min(t,Math.round(e.w*t/12))),a=e.h,i=!1;for(let o=0;o<en4(r)+8&&!i;o+=1)for(let l=0;l<=t-n&&!i;l+=1){let t={...e,x:l,y:o,w:n,h:a};!function(e,t){return t.some(t=>e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y)}(t,r)&&(r.push(t),i=!0)}i||r.push({...e,x:0,y:en4(r),w:n,h:a})}return r}(x,O),A=P.width>0?(P.width-12*(O-1))/O:96,T=O<12?72:A,R=Math.max(a,en6(z)+2),D=R*T+(R-1)*12,_=ew.useMemo(()=>new Map(t.map(e=>[e.id,e])),[t]);function L(e){let t=_.get(e.kind);return b[e.id]??(t?ere(t):void 0)}function $(e){v(t=>{let n=en7(e);return en8(n,t,n.id)?t:t.map(e=>e.id===n.id?n:e)})}function F(e){let t=_.get(e);if(!t)return;E.current+=1;let n=`${e}-added-${E.current}`,r=en9(x,n,e,t.defaultSize.w,t.defaultSize.h);v(e=>[...e,r]),y(e=>({...e,[n]:ere(t)})),j(n),N(void 0),h(!1)}function B(e,t){let n=x.find(t=>t.id===e),r=n?_.get(n.kind):void 0;n&&r&&y(n=>({...n,[e]:{...n[e]??ere(r),...t}}))}ew.useEffect(()=>{c?.(m||!!S)},[m,c,S]),ew.useEffect(()=>()=>c?.(!1),[c]),ew.useEffect(()=>{p||(j(void 0),N(void 0))},[p]),ew.useEffect(()=>{if(k)return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e);function e(e){let t=e.target;t instanceof HTMLElement&&t.closest("[data-editable-card-action]")||(j(k),N(void 0))}},[k]);let V=O<12,H=S?x.find(e=>e.id===S):void 0,U=H?_.get(H.kind):void 0,q=H?L(H):void 0;if(V){let n=[...z].sort((e,t)=>e.y-t.y||e.x-t.x),r=Object.fromEntries(x.map(e=>[e.id,e.w]));return(0,eb.jsxs)(en3,{children:[(0,eb.jsx)("div",{ref:I,"data-editable-card-board":e,className:(0,ez.cn)("mx-auto max-w-7xl p-3",i),children:(0,eb.jsx)("div",{className:"grid grid-cols-2 gap-3",children:n.map(e=>{let t=_.get(e.kind);if(!t)return null;let n=L(e);if(!n)return null;let a=(r[e.id]??e.w)>6;return(0,eb.jsx)("div",{className:(0,ez.cn)("min-w-0 overflow-hidden rounded-lg",a&&"col-span-2"),style:{minHeight:a?200:120},children:t.render(n)},e.id)})})}),(0,eb.jsx)(err,{open:u,dragMode:!1,label:o,onOpenChange:f,onAdd:()=>{f(!1),h(!0)},onDragModeChange:g}),(0,eb.jsx)(ern,{open:m,definitions:t,groupTitle:l,onOpenChange:h,onAdd:F}),(0,eb.jsx)(erm,{open:!!(H&&U&&q),layout:H,definition:U,config:q,cellSize:A,onOpenChange:e=>{e||C(void 0)},onConfigChange:e=>{H&&B(H.id,e)}})]})}return(0,eb.jsxs)(en3,{children:[(0,eb.jsx)("div",{ref:I,"data-editable-card-board":e,className:(0,ez.cn)("relative mx-auto max-w-7xl p-4 lg:p-6",p&&"select-none",i),style:{minHeight:D+48},onDragOver:e=>{Array.from(e.dataTransfer.types).includes(qf)&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},onDrop:function(e){let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id");if(!t)return;let n=r.find(e=>e.id===t),a=n&&ert(n);if(!n||!a||!_.has(a.kind))return;e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move";let i=I.current,o=i?.getBoundingClientRect();!function(e,t){let n=ert(e);if(!n||!_.has(n.kind))return;E.current+=1;let r=`${n.kind}-clip-${E.current}`,a=en7({id:r,kind:n.kind,x:t?.x??0,y:t?.y??en6(x),w:n.w,h:n.h}),i=t&&!en8(a,x)?a:en9(x,r,n.kind,n.w,n.h);v(e=>[...e,i]),y(e=>({...e,[r]:{...n.config}})),j(r),N(void 0)}(n,{x:o&&A>0?Math.round((e.clientX-o.left-24)/(A+12)):0,y:o&&A>0?Math.round((e.clientY-o.top-24)/(A+12)):en6(x)})},onPointerDown:e=>{e.target===e.currentTarget&&(j(void 0),p||N(void 0))},children:(0,eb.jsx)("div",{className:"relative",style:{height:D},children:z.map(t=>{let n=_.get(t.kind);if(!n)return null;let r=L(t);return r?(0,eb.jsx)(eri,{layout:t,layouts:z,cellSize:A,cellHeight:T,dragMode:p,selected:w===t.id,resizing:k===t.id,onSelect:()=>{p&&j(t.id)},onMove:$,onCut:()=>(function(t){let n=x.find(e=>e.id===t),r=n?_.get(n.kind):void 0,a=n?L(n):void 0;if(!n||!r||!a)return;let i=function({boardId:e,layout:t,definition:n,config:r}){let a={boardId:e,kind:t.kind,w:t.w,h:t.h,config:{...r}};return{id:`clip-${e}-${t.id}`,title:r.title||n.title,description:n.description,meta:`${t.w}x${t.h}`,icon:n.icon,dragData:{"application/vnd.vantaloom.clip-kind":"workspace-card","application/vnd.vantaloom.workspace-card-board":e,"application/vnd.vantaloom.workspace-card-kind":t.kind,"application/vnd.vantaloom.workspace-card-width":String(t.w),"application/vnd.vantaloom.workspace-card-height":String(t.h),"application/vnd.vantaloom.workspace-card-config":JSON.stringify(r),[qf]:JSON.stringify(a)},payloads:{[qf]:a}}}({boardId:e,layout:n,definition:r,config:a});s?.(e=>[i,...e.filter(e=>e.id!==i.id)]),v(e=>e.filter(e=>e.id!==t)),y(e=>{let n={...e};return delete n[t],n}),j(void 0),N(void 0),C(e=>e===t?void 0:e)})(t.id),onCopy:()=>(function(e){let t=x.find(t=>t.id===e),n=t?_.get(t.kind):void 0;if(!t||!n)return;M.current+=1;let r=`${e}-copy-${M.current}`,a=en9(x,r,t.kind,t.w,t.h);v(e=>[...e,a]),y(t=>({...t,[r]:t[e]??ere(n)})),j(r)})(t.id),onSettingsOpen:()=>C(t.id),onResizeStart:()=>{j(void 0),N(t.id)},onResizeEnd:()=>{j(t.id),N(void 0)},children:n.render(r)},t.id):null})})}),(0,eb.jsx)(err,{open:u,dragMode:p,label:o,onOpenChange:f,onAdd:()=>{f(!1),h(!0)},onDragModeChange:g}),(0,eb.jsx)(ern,{open:m,definitions:t,groupTitle:l,onOpenChange:h,onAdd:F}),(0,eb.jsx)(erm,{open:!!(H&&U&&q),layout:H,definition:U,config:q,cellSize:A,onOpenChange:e=>{e||C(void 0)},onConfigChange:e=>{H&&B(H.id,e)}})]})}function erg({parts:e}){return(0,eb.jsx)(eb.Fragment,{children:e.map((e,t)=>(0,eb.jsx)("span",{className:e.small?"text-[0.55em]":void 0,children:e.text},`${e.text}-${t}`))})}function erx({value:e,minSize:t=24,maxSize:n=180,className:r,...a}){let i=ew.useRef(null),o=ew.useRef(null),[l,s]=ew.useState(t),c=function(e){let t=e.trim();if(/^[$¥€]\s*\d/.test(t))return[{text:t.replace(/^[$¥€]\s*/,""),small:!1},{text:t[0]??"",small:!0}];let n=t.match(/^(.+?)\s*\/\s*(.+)$/);if(n)return[{text:n[1]??"",small:!1},{text:"/",small:!0},{text:n[2]??"",small:!1}];let r=t.match(/^(.+?)([%a-zA-Z$¥€]+)$/);return r?[{text:r[1]??t,small:!1},{text:r[2]??"",small:!0}]:[{text:t,small:!1}]}(e);return ew.useLayoutEffect(()=>{let e=i.current,r=o.current;if(!e||!r)return;function a(e,r){let a=e.clientWidth,i=e.clientHeight;if(a<=0||i<=0)return;let o=t,l=n,c=t;for(;o<=l;){let e=Math.floor((o+l)/2);r.style.fontSize=`${e}px`,r.getBoundingClientRect().width<=a&&r.getBoundingClientRect().height<=i?(c=e,o=e+1):l=e-1}s(c)}a(e,r);let l=new ResizeObserver(()=>a(e,r));return l.observe(e),()=>l.disconnect()},[n,t,e]),(0,eb.jsxs)("div",{ref:i,className:(0,ez.cn)("relative min-h-0 min-w-0 overflow-hidden",r),...a,children:[(0,eb.jsx)("span",{ref:o,"aria-hidden":"true",className:"pointer-events-none invisible absolute right-0 bottom-0 flex items-baseline whitespace-nowrap font-semibold leading-none tracking-normal",children:(0,eb.jsx)(erg,{parts:c})}),(0,eb.jsx)("span",{className:"absolute right-0 bottom-0 flex max-w-full items-baseline whitespace-nowrap font-semibold leading-none tracking-normal text-foreground",style:{fontSize:l},children:(0,eb.jsx)(erg,{parts:c})})]})}function erv(e){return/^\d+$/.test(e)&&1===e.length?`0${e}`:/^\d+(?:\.\d+)?%$/.test(e)?`${Number.parseFloat(e).toFixed(1)}%`:e}function erb({label:e,value:t,minSize:n=42,maxSize:r=180,valueClassName:a="absolute right-0 bottom-0 h-2/3 w-full"}){return(0,eb.jsxs)("div",{className:"relative h-full min-h-0",children:[(0,eb.jsx)("div",{className:"text-xl font-semibold tracking-normal",children:e}),(0,eb.jsx)(erx,{value:erv(t),minSize:n,maxSize:r,className:a})]})}function ery(e){return Math.max(0,Math.min(100,Math.round(e)))}function erw({className:e,value:t=0,...n}){let r=ery(t);return(0,eb.jsx)("div",{"data-slot":"progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r,className:(0,ez.cn)("relative h-1.5 w-full overflow-hidden rounded-full bg-muted",e),...n,children:(0,eb.jsx)("div",{"data-slot":"progress-indicator",className:"h-full rounded-full bg-primary transition-all",style:{width:`${r}%`}})})}function erj({className:e,value:t=0,label:n,showValue:r=!0,...a}){let i=ery(t),o=2*Math.PI*39;return(0,eb.jsxs)("div",{"data-slot":"progress-ring","aria-label":n?`${n} ${i}%`:`${i}%`,role:"img",className:(0,ez.cn)("relative grid size-24 place-items-center",e),...a,children:[(0,eb.jsxs)("svg",{"aria-hidden":"true","data-slot":"progress-ring-svg",viewBox:"0 0 100 100",className:"absolute inset-0 size-full overflow-visible",children:[(0,eb.jsx)("circle",{cx:"50",cy:"50",r:39,fill:"none",stroke:"var(--muted)",strokeWidth:12}),i>0&&(0,eb.jsx)("circle",{cx:"50",cy:"50",r:39,fill:"none",stroke:"var(--primary)",strokeDasharray:o,strokeDashoffset:o-i/100*o,strokeLinecap:"round",strokeWidth:12,className:"origin-center -rotate-90 transition-all"})]}),(0,eb.jsx)("div",{"data-slot":"progress-ring-center",className:"relative z-10 grid size-16 place-items-center rounded-full bg-card",children:r&&(0,eb.jsxs)("span",{className:"ui-text-control font-medium tabular-nums",children:[i,"%"]})})]})}(0,ek.default)("timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);let erk=(0,ek.default)("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);function erN({canvases:e,mode:t="active",scrollable:n=!1,onSelect:r}){let a=ew.useMemo(()=>e.map(e=>{var n;return{id:e.id,status:"live"===(n=e).status?"current":"review"===n.status?"blocked":"done",title:(0,eb.jsx)(erS,{canvas:e,mode:t,onClick:()=>r(e)})}}),[e,t,r]);return(0,eb.jsx)(enX,{items:a,scrollCurrentIntoView:!1,className:(0,ez.cn)("mt-2",n&&"min-h-0 flex-1"),viewportClassName:(0,ez.cn)("max-h-none pr-0",n?"h-full overflow-y-auto":"overflow-visible"),itemClassName:"py-2"})}function erS({canvas:e,onClick:t,mode:n}){return(0,eb.jsxs)("button",{type:"button",className:(0,ez.cn)("grid w-full items-center gap-4 rounded-lg px-2 py-0 text-left transition-colors hover:bg-muted/50","active"===n?"grid-cols-[minmax(0,1fr)_8rem_1.75rem]":"grid-cols-[minmax(0,1fr)_7rem_7rem_8rem]"),onClick:t,children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("div",{className:"truncate text-sm font-medium",children:e.title}),(0,eb.jsx)("div",{className:"truncate text-xs text-muted-foreground",children:"active"===n?e.purpose:`${e.nodes} nodes`})]}),"active"===n?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(erw,{value:e.progress,className:"h-1.5"}),(0,eb.jsx)("span",{"aria-label":e.progress>=100?"Canvas complete":"Canvas incomplete",className:(0,ez.cn)("size-2.5 rounded-full",e.progress>=100?"bg-primary":"bg-border")})]}):(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(erC,{icon:(0,eb.jsx)(HM,{}),value:`${e.snapshots}`}),(0,eb.jsx)(erC,{icon:(0,eb.jsx)(erk,{}),value:e.runtime}),(0,eb.jsx)("div",{className:"text-right ui-text-kbd text-muted-foreground",children:e.lastOpened})]})]})}function erC({icon:e,value:t}){return(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,eb.jsx)("span",{className:"[&_svg]:size-3.5",children:e}),(0,eb.jsx)("span",{className:"tabular-nums",children:t})]})}let erM=(0,ek.default)("memory-stick",[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]]),erE=(0,ek.default)("radio-tower",[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]]),erI=(0,ek.default)("gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);var erP=ew;function erO(){return(erO=Object.assign.bind()).apply(null,arguments)}function erz(e){return ew.createElement(Dg,erO({shapeType:"rectangle",activeClassName:"recharts-active-bar",inActiveClassName:"recharts-inactive-bar"},e))}var erA=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(n,r)=>{if(Nj(e))return e;var a=Nj(n)||null==n;return a?e(n,r):(a||function(e,t){if(!e)throw Error("Invariant failed")}(!1,"minPointSize callback function received a value with type of ".concat(typeof n,". Currently only numbers or null/undefined are supported.")),t)}},erT=["children"],erR=(0,ew.createContext)({data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0});function erD(e){var{children:t}=e,n=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(e,erT);return ew.createElement(erR.Provider,{value:n},t)}var er_=(e,t,n)=>{var r=null!=n?n:e;if(null!=r)return NC(r,t,0)};function erL(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function er$(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?erL(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):erL(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var erF=k9([O0,(e,t)=>t],(e,t)=>e.filter(e=>"bar"===e.type).find(e=>e.id===t)),erB=k9([erF],e=>null==e?void 0:e.maxBarSize),erV=k9([MM,O0,Ja,Ji,(e,t,n)=>n],(e,t,n,r,a)=>t.filter(t=>"horizontal"===e?t.xAxisId===n:t.yAxisId===r).filter(e=>e.isPanorama===a).filter(e=>!1===e.hide).filter(e=>"bar"===e.type)),erH=k9([erV,e=>e.rootProps.barSize,(e,t)=>{var n=MM(e),r=Ja(e,t),a=Ji(e,t);if(null!=r&&null!=a)return"horizontal"===n?Af(e,"xAxis",r):Af(e,"yAxis",a)}],(e,t,n)=>{var r=e.filter(Eh),a=e.filter(e=>null==e.stackId);return[...Object.entries(r.reduce((e,t)=>{var n=e[t.stackId];return null==n&&(n=[]),n.push(t),e[t.stackId]=n,e},{})).map(e=>{var r,[a,i]=e;return{stackId:a,dataKeys:i.map(e=>e.dataKey),barSize:er_(t,n,null==(r=i[0])?void 0:r.barSize)}}),...a.map(e=>({stackId:void 0,dataKeys:[e.dataKey].filter(e=>null!=e),barSize:er_(t,n,e.barSize)}))]}),erU=(e,t,n)=>{var r,a,i=MM(e),o=Ja(e,t),l=Ji(e,t);if(null!=o&&null!=l)return"horizontal"===i?(r=Av(e,"xAxis",o,n),a=Ax(e,"xAxis",o,n)):(r=Av(e,"yAxis",l,n),a=Ax(e,"yAxis",l,n)),NG(r,a)},erq=k9([erH,MH,e=>e.rootProps.barGap,MU,(e,t,n)=>{var r,a,i,o,l=erF(e,t);if(null==l)return 0;var s=Ja(e,t),c=Ji(e,t);if(null==s||null==c)return 0;var d=MM(e),u=MH(e),{maxBarSize:f}=l;return"horizontal"===d?(i=Av(e,"xAxis",s,n),o=Ax(e,"xAxis",s,n)):(i=Av(e,"yAxis",c,n),o=Ax(e,"yAxis",c,n)),null!=(r=null!=(a=NG(i,o,!0))?a:null==f?u:f)?r:0},erU,erB],(e,t,n,r,a,i,o)=>{var l=function(e,t,n,r,a){var i,o,l=r.length;if(!(l<1)){var s=NC(e,n,0,!0),c=[];if(NT(null==(i=r[0])?void 0:i.barSize)){var d=!1,u=n/l,f=r.reduce((e,t)=>e+(t.barSize||0),0);(f+=(l-1)*s)>=n&&(f-=(l-1)*s,s=0),f>=n&&u>0&&(d=!0,u*=.9,f=l*u);var m={offset:((n-f)/2|0)-s,size:0};o=r.reduce((e,t)=>{var n,r={stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:m.offset+m.size+s,size:d?u:null!=(n=t.barSize)?n:0}},a=[...e,r];return m=r.position,a},c)}else{var h=NC(t,n,0,!0);n-2*h-(l-1)*s<=0&&(s=0);var p=(n-2*h-(l-1)*s)/l;p>1&&(p>>=0);var g=NT(a)?Math.min(p,a):p;o=r.reduce((e,t,n)=>[...e,{stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:h+(p+s)*n+(p-g)/2,size:g}}],c)}return o}}(n,r,a!==i?a:i,e,null==o?t:o);return a!==i&&null!=l&&(l=l.map(e=>er$(er$({},e),{},{position:er$(er$({},e.position),{},{offset:e.position.offset-a/2})}))),l}),erW=k9([erq,erF],(e,t)=>{if(null!=e&&null!=t){var n=e.find(e=>e.stackId===t.stackId&&null!=t.dataKey&&e.dataKeys.includes(t.dataKey));if(null!=n)return n.position}}),erK=k9([(e,t,n)=>{var r=MM(e),a=Ja(e,t),i=Ji(e,t);if(null!=a&&null!=i)return"horizontal"===r?zp(e,"yAxis",i,n):zp(e,"xAxis",a,n)},erF],(e,t)=>{var n=Ef(t);if(!e||null==n||null==t)return;var{stackId:r}=t;if(null!=r){var a=e[r];if(a){var{stackedData:i}=a;if(i)return i.find(e=>e.key===n)}}}),erG=k9([N8,N9,(e,t,n)=>{var r=Ja(e,t);if(null!=r)return Av(e,"xAxis",r,n)},(e,t,n)=>{var r=Ji(e,t);if(null!=r)return Av(e,"yAxis",r,n)},(e,t,n)=>{var r=Ja(e,t);if(null!=r)return Ax(e,"xAxis",r,n)},(e,t,n)=>{var r=Ji(e,t);if(null!=r)return Ax(e,"yAxis",r,n)},erW,MM,Na,erU,erK,erF,(e,t,n,r)=>r],(e,t,n,r,a,i,o,l,s,c,d,u,f)=>{var m,{chartData:h,dataStartIndex:p,dataEndIndex:g}=s;if(null!=u&&null!=o&&null!=t&&("horizontal"===l||"vertical"===l)&&null!=n&&null!=r&&null!=a&&null!=i&&null!=c){var{data:x}=u;if(null!=(m=null!=x&&x.length>0?x:null==h?void 0:h.slice(p,g+1)))return function(e){var{layout:t,barSettings:{dataKey:n,minPointSize:r,hasCustomShape:a},pos:i,bandSize:o,xAxis:l,yAxis:s,xAxisTicks:c,yAxisTicks:d,stackedData:u,displayedData:f,offset:m,cells:h,parentViewBox:p,dataStartIndex:g}=e,x="horizontal"===t?s:l,v=u?x.scale.domain():null,b=(e=>{var{numericAxis:t}=e,n=t.scale.domain();if("number"===t.type){var r=Math.min(n[0],n[1]),a=Math.max(n[0],n[1]);return r<=0&&a>=0?0:a<0?a:r}return n[0]})({numericAxis:x}),y=x.scale.map(b);return f.map((e,f)=>{if(u){var x=u[f+g];if(null==x)return null;j=((e,t)=>{if(!t||2!==t.length||!Nj(t[0])||!Nj(t[1]))return e;var n=Math.min(t[0],t[1]),r=Math.max(t[0],t[1]),a=[e[0],e[1]];return(!Nj(e[0])||e[0]<n)&&(a[0]=n),(!Nj(e[1])||e[1]>r)&&(a[1]=r),a[0]>r&&(a[0]=r),a[1]<n&&(a[1]=n),a})(x,v)}else Array.isArray(j=NL(e,n))||(j=[b,j]);var w=erA(r,0)(j[1],f);if("horizontal"===t){var j,k,N,S,C,M,E,I=s.scale.map(j[0]),P=s.scale.map(j[1]);if(null==I||null==P)return null;k=Nq({axis:l,ticks:c,bandSize:o,offset:i.offset,entry:e,index:f}),N=null!=(E=null!=P?P:I)?E:void 0,S=i.size;var O=I-P;if(C=Ny(O)?0:O,M={x:k,y:m.top,width:S,height:m.height},Math.abs(w)>0&&Math.abs(C)<Math.abs(w)){var z=Nb(C||w)*(Math.abs(w)-Math.abs(C));N-=z,C+=z}}else{var A=l.scale.map(j[0]),T=l.scale.map(j[1]);if(null==A||null==T)return null;if(k=A,N=Nq({axis:s,ticks:d,bandSize:o,offset:i.offset,entry:e,index:f}),S=T-A,C=i.size,M={x:m.left,y:N,width:m.width,height:C},Math.abs(w)>0&&Math.abs(S)<Math.abs(w)){var R=Nb(S||w)*(Math.abs(w)-Math.abs(S));S+=R}}return null!=k&&null!=N&&null!=S&&null!=C&&(a||0!==S&&0!==C)?eat(eat({},e),{},{stackedBarStart:y,x:k,y:N,width:S,height:C,value:u?j:j[1],payload:e,background:M,tooltipPosition:{x:k+S/2,y:N+C/2},parentViewBox:p,originalDataIndex:f},h&&h[f]&&h[f].props):null}).filter(Boolean)}({layout:l,barSettings:u,pos:o,parentViewBox:t,bandSize:c,xAxis:n,yAxis:r,xAxisTicks:a,yAxisTicks:i,stackedData:d,displayedData:m,offset:e,cells:f,dataStartIndex:p})}}),erX=(e,t)=>t,erY=(e,t,n)=>n,erZ=k9([erX,O0,erY],(e,t,n)=>t.filter(e=>"bar"===e.type).filter(t=>t.stackId===e).filter(e=>e.isPanorama===n).filter(e=>!e.hide)),erJ=k9([erZ],e=>e.map(e=>e.id)),erQ=k9([e=>e,erX,erY],(e,t,n)=>{var r=erJ(e,t,n),a=[];return r.forEach(t=>{var r=erG(e,t,n,void 0);null==r||r.forEach(e=>{var t=e.originalDataIndex;a[t]=((e,t)=>{if(!e)return t;if(!t)return e;var n=Math.min(e.x,e.x+e.width,t.x,t.x+t.width),r=Math.min(e.y,e.y+e.height,t.y,t.y+t.height);return{x:n,y:r,width:Math.max(e.x,e.x+e.width,t.x,t.x+t.width)-n,height:Math.max(e.y,e.y+e.height,t.y,t.y+t.height)-r}})(a[t],e)})}),a}),er0=["index"];function er1(){return(er1=Object.assign.bind()).apply(null,arguments)}var er2=(0,ew.createContext)(void 0),er5=(e,t)=>"recharts-bar-stack-clip-path-".concat(e,"-").concat(t),er4=e=>{var{index:t}=e,n=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(e,er0),r=(e=>{var t=(0,ew.useContext)(er2);if(null!=t){var{stackId:n}=t;return"url(#".concat(er5(n,e),")")}})(t);return ew.createElement(AJ,er1({className:"recharts-bar-stack-layer",clipPath:r},n))},er3=["onMouseEnter","onMouseLeave","onClick"],er6=["value","background","tooltipPosition"],er8=["id"],er7=["onMouseEnter","onClick","onMouseLeave"];function er9(){return(er9=Object.assign.bind()).apply(null,arguments)}function eae(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function eat(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?eae(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):eae(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ean(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var ear=erP.memo(e=>{var{dataKey:t,stroke:n,strokeWidth:r,fill:a,name:i,hide:o,unit:l,tooltipType:s,id:c}=e,d={dataDefinedOnItem:void 0,getPosition:Nz,settings:{stroke:n,strokeWidth:r,fill:a,dataKey:t,nameKey:void 0,name:NY(i,t),hide:o,type:s,color:a,unit:l,graphicalItemId:c}};return erP.createElement(_u,{tooltipEntrySettings:d})});function eaa(e){var t,n=Sl(Li),{data:r,dataKey:a,background:i,allOtherBarProps:o}=e,{onMouseEnter:l,onMouseLeave:s,onClick:c}=o,d=ean(o,er3),u=_s(l,a,o.id),f=_c(s),m=_d(c,a,o.id);if(!i||null==r)return null;var h=AG(i);return erP.createElement(LX,{zIndex:(t=M2.barBackground,i&&"object"==typeof i&&"zIndex"in i&&"number"==typeof i.zIndex&&NT(i.zIndex)?i.zIndex:t)},r.map((e,t)=>{var{value:r,background:o,tooltipPosition:l}=e,s=ean(e,er6);if(!o)return null;var c=u(e,t),p=f(e,t),g=m(e,t),x=eat(eat(eat(eat(eat({option:i,isActive:String(t)===n},s),{},{fill:"#eee"},o),h),Tb(d,e,t)),{},{onMouseEnter:c,onMouseLeave:p,onClick:g,dataKey:a,index:t,className:"recharts-bar-background-rectangle"});return erP.createElement(erz,er9({key:"background-bar-".concat(t)},x))}))}function eai(e){var{showLabels:t,children:n,rects:r}=e,a=null==r?void 0:r.map(e=>{var t={x:e.x,y:e.y,width:e.width,lowerWidth:e.width,upperWidth:e.width,height:e.height};return eat(eat({},t),{},{value:e.value,payload:e.payload,parentViewBox:e.parentViewBox,viewBox:t,fill:e.fill})});return erP.createElement($c,{value:t?a:void 0},n)}function eao(e){var t,{shape:n,activeBar:r,baseProps:a,entry:i,index:o,dataKey:l}=e,s=Sl(Li),c=Sl(Ll),d=r&&String(i.originalDataIndex)===s&&(null==c||l===c),[u,f]=(0,erP.useState)(!1),[m,h]=(0,erP.useState)(!1);(0,erP.useEffect)(()=>{var e;return d?(f(!0),e=requestAnimationFrame(()=>{h(!0)})):h(!1),()=>{cancelAnimationFrame(e)}},[d]);var p=(0,erP.useCallback)(()=>{d||f(!1)},[d]),g=d&&m,x=d||u;t=d?!0===r?n:r:n;var v=erP.createElement(erz,er9({},a,{name:String(a.name)},i,{isActive:g,option:t,index:o,dataKey:l,onTransitionEnd:p}));return x?erP.createElement(LX,{zIndex:M2.activeBar},erP.createElement(er4,{index:i.originalDataIndex},v)):v}function eal(e){var{shape:t,baseProps:n,entry:r,index:a,dataKey:i}=e;return erP.createElement(erz,er9({},n,{name:String(n.name)},r,{isActive:!1,option:t,index:a,dataKey:i}))}function eas(e){var t,{data:n,props:r}=e,a=null!=(t=AK(r))?t:{},{id:i}=a,o=ean(a,er8),{shape:l,dataKey:s,activeBar:c}=r,{onMouseEnter:d,onClick:u,onMouseLeave:f}=r,m=ean(r,er7),h=_s(d,s,i),p=_c(f),g=_d(u,s,i);return n?erP.createElement(erP.Fragment,null,n.map((e,t)=>erP.createElement(er4,er9({index:e.originalDataIndex,key:"rectangle-".concat(null==e?void 0:e.x,"-").concat(null==e?void 0:e.y,"-").concat(null==e?void 0:e.value,"-").concat(t),className:"recharts-bar-rectangle"},Tb(m,e,t),{onMouseEnter:h(e,t),onMouseLeave:p(e,t),onClick:g(e,t)}),c?erP.createElement(eao,{shape:l,activeBar:c,baseProps:o,entry:e,index:t,dataKey:s}):erP.createElement(eal,{shape:l,baseProps:o,entry:e,index:t,dataKey:s})))):null}function eac(e){var{props:t,previousRectanglesRef:n}=e,{data:r,layout:a,isAnimationActive:i,animationBegin:o,animationDuration:l,animationEasing:s,onAnimationEnd:c,onAnimationStart:d}=t,u=n.current,f=RP(t,"recharts-bar-"),[m,h]=(0,erP.useState)(!1),p=(0,erP.useCallback)(()=>{"function"==typeof c&&c(),h(!1)},[c]),g=(0,erP.useCallback)(()=>{"function"==typeof d&&d(),h(!0)},[d]);return erP.createElement(eai,{showLabels:!m,rects:r},erP.createElement(RI,{animationId:f,begin:o,duration:l,isActive:i,easing:s,onAnimationEnd:p,onAnimationStart:g,key:f},e=>{var i=1===e?r:null==r?void 0:r.map((t,n)=>{var r=u&&u[n];if(r)return eat(eat({},t),{},{x:NE(r.x,t.x,e),y:NE(r.y,t.y,e),width:NE(r.width,t.width,e),height:NE(r.height,t.height,e)});if("horizontal"===a){var i=NE(0,t.height,e),o=NE(t.stackedBarStart,t.y,e);return eat(eat({},t),{},{y:o,height:i})}var l=NE(0,t.width,e),s=NE(t.stackedBarStart,t.x,e);return eat(eat({},t),{},{width:l,x:s})});return(e>0&&(n.current=null!=i?i:null),null==i)?null:erP.createElement(AJ,null,erP.createElement(eas,{props:t,data:i}))}),erP.createElement($m,{label:t.label}),t.children)}function ead(e){var t=(0,erP.useRef)(null);return erP.createElement(eac,{previousRectanglesRef:t,props:e})}var eau=(e,t)=>{var n=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:n,errorVal:NL(e,t)}};class eaf extends erP.PureComponent{render(){var{hide:e,data:t,dataKey:n,className:r,xAxisId:a,yAxisId:i,needClip:o,background:l,id:s}=this.props;if(e||null==t)return null;var c=(0,kq.clsx)("recharts-bar",r);return erP.createElement(AJ,{className:c,id:s},o&&erP.createElement("defs",null,erP.createElement(Jr,{clipPathId:s,xAxisId:a,yAxisId:i})),erP.createElement(AJ,{className:"recharts-bar-rectangles",clipPath:o?"url(#clipPath-".concat(s,")"):void 0},erP.createElement(eaa,{data:t,dataKey:n,background:l,allOtherBarProps:this.props}),erP.createElement(ead,this.props)))}}var eam={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:0,xAxisId:0,yAxisId:0,zIndex:M2.bar};function eah(e){var t,{xAxisId:n,yAxisId:r,hide:a,legendType:i,minPointSize:o,activeBar:l,animationBegin:s,animationDuration:c,animationEasing:d,isAnimationActive:u}=e,{needClip:f}=Jn(n,r),m=Sl(MM),h=Mn(),p=Ri(e.children,T9),g=Sl(t=>erG(t,e.id,h,p));if("vertical"!==m&&"horizontal"!==m)return null;var x=null==g?void 0:g[0];return t=null==x||null==x.height||null==x.width?0:"vertical"===m?x.height/2:x.width/2,erP.createElement(erD,{xAxisId:n,yAxisId:r,data:g,dataPointFormatter:eau,errorBarOffset:t},erP.createElement(eaf,er9({},e,{layout:m,needClip:f,data:g,xAxisId:n,yAxisId:r,hide:a,legendType:i,minPointSize:o,activeBar:l,animationBegin:s,animationDuration:c,animationEasing:d,isAnimationActive:u})))}erP.memo(function(e){var t,n,r=TG(e,eam),a=(t=r.stackId,null!=(n=(0,ew.useContext)(er2))?n.stackId:null!=t?NH(t):void 0),i=Mn();return erP.createElement(LC,{id:r.id,type:"bar"},e=>erP.createElement(erP.Fragment,null,erP.createElement(Lj,{legendPayload:(e=>{var{dataKey:t,name:n,fill:r,legendType:a,hide:i}=e;return[{inactive:i,dataKey:t,type:a,color:r,value:NY(n,t),payload:e}]})(r)}),erP.createElement(ear,{dataKey:r.dataKey,stroke:r.stroke,strokeWidth:r.strokeWidth,fill:r.fill,name:r.name,hide:r.hide,unit:r.unit,tooltipType:r.tooltipType,id:e}),erP.createElement(LR,{type:"bar",id:e,data:void 0,xAxisId:r.xAxisId,yAxisId:r.yAxisId,zAxisId:0,dataKey:r.dataKey,stackId:a,hide:r.hide,barSize:r.barSize,minPointSize:r.minPointSize,maxBarSize:r.maxBarSize,isPanorama:i,hasCustomShape:null!=r.shape}),erP.createElement(LX,{zIndex:r.zIndex},erP.createElement(eah,er9({},r,{id:e})))))},BM).displayName="Bar";let eap=(0,ek.default)("bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]);function eag({label:e,description:t,value:n}){return(0,eb.jsxs)("div",{className:"relative h-full min-h-0",children:[(0,eb.jsxs)("div",{children:[(0,eb.jsx)("div",{className:"text-xl font-semibold tracking-normal",children:e}),(0,eb.jsx)("div",{className:"mt-1 text-sm leading-5 text-muted-foreground",children:t})]}),(0,eb.jsx)(erx,{value:erv(n),minSize:48,maxSize:220,className:"absolute right-0 bottom-0 h-2/3 w-full"})]})}(0,ek.default)("calendar-clock",[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);var eax=ew,eav=(e,t,n,r)=>Av(e,"xAxis",t,r),eab=(e,t,n,r)=>Ax(e,"xAxis",t,r),eay=(e,t,n,r)=>Av(e,"yAxis",n,r),eaw=(e,t,n,r)=>Ax(e,"yAxis",n,r),eaj=k9([MM,eav,eay,eab,eaw],(e,t,n,r,a)=>N$(e,"xAxis")?NG(t,r,!1):NG(n,a,!1));function eak(e){return"line"===e.type}var eaN=k9([O0,(e,t,n,r,a)=>a],(e,t)=>e.filter(eak).find(e=>e.id===t)),eaS=k9([MM,eav,eay,eab,eaw,eaN,eaj,Nr],(e,t,n,r,a,i,o,l)=>{var s,{chartData:c,dataStartIndex:d,dataEndIndex:u}=l;if(null!=i&&null!=t&&null!=n&&null!=r&&null!=a&&0!==r.length&&0!==a.length&&null!=o&&("horizontal"===e||"vertical"===e)){var{dataKey:f,data:m}=i;if(null!=(s=null!=m&&m.length>0?m:null==c?void 0:c.slice(d,u+1)))return function(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:a,yAxisTicks:i,dataKey:o,bandSize:l,displayedData:s}=e;return s.map((e,s)=>{var c=NL(e,o);if("horizontal"===t){var d=NU({axis:n,ticks:a,bandSize:l,entry:e,index:s}),u=null==c?null:r.scale.map(c);return{x:d,y:null!=u?u:null,value:c,payload:e}}var f=null==c?null:n.scale.map(c),m=NU({axis:r,ticks:i,bandSize:l,entry:e,index:s});return null==f||null==m?null:{x:f,y:m,value:c,payload:e}}).filter(Boolean)}({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:a,dataKey:f,bandSize:o,displayedData:s})}}),eaC=["id"],eaM=["type","layout","connectNulls","needClip","shape"],eaE=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function eaI(){return(eaI=Object.assign.bind()).apply(null,arguments)}function eaP(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function eaO(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?eaP(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):eaP(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function eaz(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var eaA=eax.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:a,fill:i,name:o,hide:l,unit:s,tooltipType:c,id:d}=e,u={dataDefinedOnItem:n,getPosition:Nz,settings:{stroke:r,strokeWidth:a,fill:i,dataKey:t,nameKey:void 0,name:NY(o,t),hide:l,type:c,color:r,unit:s,graphicalItemId:d}};return eax.createElement(_u,{tooltipEntrySettings:u})}),eaT=(e,t)=>"".concat(t,"px ").concat(e,"px");function eaR(e){var{clipPathId:t,points:n,props:r}=e,{dot:a,dataKey:i,needClip:o}=r,{id:l}=r,s=AK(eaz(r,eaC));return eax.createElement(Z8,{points:n,dot:a,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:i,baseProps:s,needClip:o,clipPathId:t})}function eaD(e){var{showLabels:t,children:n,points:r}=e,a=(0,eax.useMemo)(()=>null==r?void 0:r.map(e=>{var t,n,r={x:null!=(t=e.x)?t:0,y:null!=(n=e.y)?n:0,width:0,lowerWidth:0,upperWidth:0,height:0};return eaO(eaO({},r),{},{value:e.value,payload:e.payload,viewBox:r,parentViewBox:void 0,fill:void 0})}),[r]);return eax.createElement($c,{value:t?a:void 0},n)}function ea_(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:a,props:i}=e,{type:o,layout:l,connectNulls:s,needClip:c,shape:d}=i,u=eaO(eaO({},AX(eaz(i,eaM))),{},{fill:"none",className:"recharts-line-curve",clipPath:c?"url(#clipPath-".concat(t,")"):void 0,points:r,type:o,layout:l,connectNulls:s,strokeDasharray:null!=a?a:i.strokeDasharray});return eax.createElement(eax.Fragment,null,(null==r?void 0:r.length)>1&&eax.createElement(Dg,eaI({shapeType:"curve",option:d},u,{pathRef:n})),eax.createElement(eaR,{points:r,clipPathId:t,props:i}))}function eaL(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:a,longestAnimatedLengthRef:i}=e,{points:o,strokeDasharray:l,isAnimationActive:s,animationBegin:c,animationDuration:d,animationEasing:u,animateNewValues:f,width:m,height:h,onAnimationEnd:p,onAnimationStart:g}=n,x=a.current,v=RP(o,"recharts-line-"),b=(0,eax.useRef)(v),[y,w]=(0,eax.useState)(!1),j=(0,eax.useCallback)(()=>{"function"==typeof p&&p(),w(!1)},[p]),k=(0,eax.useCallback)(()=>{"function"==typeof g&&g(),w(!0)},[g]),N=function(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch(e){return 0}}(r.current),S=(0,eax.useRef)(0);b.current!==v&&(S.current=i.current,b.current=v);var C=S.current;return eax.createElement(eaD,{points:o,showLabels:!y},n.children,eax.createElement(RI,{animationId:v,begin:c,duration:d,isActive:s,easing:u,onAnimationEnd:j,onAnimationStart:k,key:v},e=>{var c,d=Math.min(NE(C,N+C,e),N);if(c=s?l?((e,t,n)=>{var r=n.reduce((e,t)=>e+t,0);if(!r)return eaT(t,e);for(var a=Math.floor(e/r),i=e%r,o=[],l=0,s=0;l<n.length;s+=null!=(c=n[l])?c:0,++l){var c,d=n[l];if(null!=d&&s+d>i){o=[...n.slice(0,l),i-s];break}}var u=o.length%2==0?[0,t]:[t];return[...function(e,t){for(var n=e.length%2!=0?[...e,0]:e,r=[],a=0;a<t;++a)r.push(...n);return r}(n,a),...o,...u].map(e=>"".concat(e,"px")).join(", ")})(d,N,"".concat(l).split(/[,\s]+/gim).map(e=>parseFloat(e))):eaT(N,d):null==l?void 0:String(l),e>0&&N>0&&(a.current=o,i.current=Math.max(i.current,d)),x){var u=x.length/o.length,p=1===e?o:o.map((t,n)=>{var r=Math.floor(n*u);if(x[r]){var a=x[r];return eaO(eaO({},t),{},{x:NE(a.x,t.x,e),y:NE(a.y,t.y,e)})}return f?eaO(eaO({},t),{},{x:NE(2*m,t.x,e),y:NE(h/2,t.y,e)}):eaO(eaO({},t),{},{x:t.x,y:t.y})});return a.current=p,eax.createElement(ea_,{props:n,points:p,clipPathId:t,pathRef:r,strokeDasharray:c})}return eax.createElement(ea_,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:c})}),eax.createElement($m,{label:n.label}))}function ea$(e){var{clipPathId:t,props:n}=e,r=(0,eax.useRef)(null),a=(0,eax.useRef)(0),i=(0,eax.useRef)(null);return eax.createElement(eaL,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:a,pathRef:i})}var eaF=(e,t)=>{var n,r;return{x:null!=(n=e.x)?n:void 0,y:null!=(r=e.y)?r:void 0,value:e.value,errorVal:NL(e.payload,t)}};class eaB extends eax.Component{render(){var{hide:e,dot:t,points:n,className:r,xAxisId:a,yAxisId:i,top:o,left:l,width:s,height:c,id:d,needClip:u,zIndex:f}=this.props;if(e)return null;var m=(0,kq.clsx)("recharts-line",r),{r:h,strokeWidth:p}=Jp(t),g=Ro(t),x=2*h+p,v=u?"url(#clipPath-".concat(g?"":"dots-").concat(d,")"):void 0;return eax.createElement(LX,{zIndex:f},eax.createElement(AJ,{className:m},u&&eax.createElement("defs",null,eax.createElement(Jr,{clipPathId:d,xAxisId:a,yAxisId:i}),!g&&eax.createElement("clipPath",{id:"clipPath-dots-".concat(d)},eax.createElement("rect",{x:l-x/2,y:o-x/2,width:s+x,height:c+x}))),eax.createElement(erD,{xAxisId:a,yAxisId:i,data:n,dataPointFormatter:eaF,errorBarOffset:0},eax.createElement(ea$,{props:this.props,clipPathId:d}))),eax.createElement(Jt,{activeDot:this.props.activeDot,points:n,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:v}))}}var eaV={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!0,fill:"#fff",hide:!1,isAnimationActive:"auto",label:!1,legendType:"line",stroke:"#3182bd",strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:M2.line,type:"linear"};function eaH(e){var t=TG(e,eaV),{activeDot:n,animateNewValues:r,animationBegin:a,animationDuration:i,animationEasing:o,connectNulls:l,dot:s,hide:c,isAnimationActive:d,label:u,legendType:f,xAxisId:m,yAxisId:h,id:p}=t,g=eaz(t,eaE),{needClip:x}=Jn(m,h),v=Sl(B9),b=Sl(MM),y=Mn(),w=Sl(e=>eaS(e,m,h,y,p));if("horizontal"!==b&&"vertical"!==b||null==w||null==v)return null;var{height:j,width:k,x:N,y:S}=v;return eax.createElement(eaB,eaI({},g,{id:p,connectNulls:l,dot:s,activeDot:n,animateNewValues:r,animationBegin:a,animationDuration:i,animationEasing:o,isAnimationActive:d,hide:c,label:u,legendType:f,xAxisId:m,yAxisId:h,points:w,layout:b,height:j,width:k,left:N,top:S,needClip:x}))}var eaU=eax.memo(function(e){var t=TG(e,eaV),n=Mn();return eax.createElement(LC,{id:t.id,type:"line"},e=>eax.createElement(eax.Fragment,null,eax.createElement(Lj,{legendPayload:(e=>{var{dataKey:t,name:n,stroke:r,legendType:a,hide:i}=e;return[{inactive:i,dataKey:t,type:a,color:r,value:NY(n,t),payload:e}]})(t)}),eax.createElement(eaA,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),eax.createElement(LR,{type:"line",id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),eax.createElement(eaH,eaI({},t,{id:e}))))},BM);eaU.displayName="Line";var eaq=["axis"],eaW=(0,ew.forwardRef)((e,t)=>ew.createElement(J$,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:eaq,tooltipPayloadSearcher:$A,categoricalChartProps:e,ref:t}));function eaK({title:e,count:t}){return(0,eb.jsxs)("div",{className:"flex h-7 shrink-0 items-center justify-between",children:[(0,eb.jsx)("h2",{className:"text-sm font-semibold tracking-normal",children:e}),(0,eb.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:t})]})}function eaG({items:e}){return(0,eb.jsx)("div",{className:"mt-2 grid",children:e.map((e,t)=>(0,eb.jsxs)("div",{className:(0,ez.cn)("px-2 py-2",t>0&&"border-t"),children:[(0,eb.jsx)("div",{className:"truncate text-sm font-medium",children:e.title}),(0,eb.jsx)("div",{className:(0,ez.cn)("mt-1 truncate ui-text-kbd text-muted-foreground","warning"===e.tone&&"text-destructive"),children:e.meta})]},e.id))})}function eaX({items:e}){let t=ew.useMemo(()=>e.map(([e,t,n,r])=>({id:`${e}-${n}`,status:"完成"===r?"done":"运行中"===r?"current":"失败"===r?"blocked":"queued",title:(0,eb.jsxs)("div",{className:"grid w-full grid-cols-[3.25rem_8rem_minmax(0,1fr)_4rem] items-center gap-3",children:[(0,eb.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:e}),(0,eb.jsx)("span",{className:"truncate ui-text-kbd text-muted-foreground",children:t}),(0,eb.jsx)("span",{className:"truncate",children:n}),(0,eb.jsx)("span",{className:"text-right ui-text-kbd text-muted-foreground",children:r})]})})),[e]);return(0,eb.jsx)(enX,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-1.5"})}function eaY({items:e}){let t=ew.useMemo(()=>e.map(e=>{var t;return{id:e.id,status:"running"===(t=e.state)?"current":"blocked"===t||"failed"===t?"blocked":"queued",title:(0,eb.jsx)(eaZ,{item:e})}}),[e]);return(0,eb.jsx)(enX,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-2"})}function eaZ({item:e}){return(0,eb.jsxs)("div",{className:"grid w-full grid-cols-[minmax(0,1fr)_7.5rem_5rem] items-center gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("div",{className:"truncate text-sm font-medium",children:e.title}),(0,eb.jsxs)("div",{className:"mt-1 truncate ui-text-kbd text-muted-foreground",children:[e.machine," · ",e.agent," · ",e.started]})]}),(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsx)(erw,{value:e.progress,className:"h-1.5"}),(0,eb.jsx)("div",{className:"ui-text-kbd text-muted-foreground",children:e.runtime})]}),(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsx)(erw,{value:e.load,className:"h-1.5"}),(0,eb.jsx)("div",{className:"text-right ui-text-kbd text-muted-foreground",children:"load"})]})]})}function eaJ({workers:e}){return(0,eb.jsx)("div",{className:"mt-2 grid min-h-0 flex-1 content-start overflow-hidden",children:e.map((e,t)=>(0,eb.jsx)(eaQ,{worker:e,divided:t>0},e.id))})}function eaQ({worker:e,divided:t}){return(0,eb.jsxs)("div",{className:(0,ez.cn)("grid min-h-24 grid-cols-[minmax(0,1fr)_2.5rem_auto] items-center gap-4 px-2 py-2",t&&"border-t"),children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("div",{className:"truncate text-lg font-semibold tracking-normal",children:e.machine}),(0,eb.jsx)("div",{className:"mt-0.5 truncate ui-text-kbd text-muted-foreground",children:e.role})]}),(0,eb.jsxs)("div",{className:"text-right text-sm font-medium tabular-nums",children:[e.active,"/",e.capacity]}),(0,eb.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,eb.jsx)(ea0,{label:"CPU",value:e.cpu}),(0,eb.jsx)(ea0,{label:"MEM",value:e.memory})]})]})}function ea0({label:e,value:t}){return(0,eb.jsxs)("div",{className:"grid justify-items-center gap-1",children:[(0,eb.jsx)(erj,{value:t,label:e,className:"size-16 [&_[data-slot=progress-ring-center]]:size-10 [&_[data-slot=progress-ring-center]]:bg-background [&_[data-slot=progress-ring-center]_span]:text-xs"}),(0,eb.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:e})]})}function ea1({events:e}){let t=ew.useMemo(()=>e.map(([e,t],n)=>({id:`${e}-${t}`,status:0===n?"current":"done",title:(0,eb.jsxs)("div",{className:"grid w-full grid-cols-[3.25rem_minmax(0,1fr)] items-center gap-2",children:[(0,eb.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:e}),(0,eb.jsx)("span",{className:"truncate",children:t})]})})),[e]);return(0,eb.jsx)(enX,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-1.5"})}function ea2({machines:e}){return(0,eb.jsx)("div",{className:"mt-2 grid min-h-0 flex-1 content-start overflow-hidden",children:e.map((e,t)=>(0,eb.jsx)(ea5,{machine:e,divided:t>0},e.id))})}function ea5({machine:e,divided:t}){return(0,eb.jsxs)("div",{className:(0,ez.cn)("grid min-h-20 grid-cols-[minmax(0,1fr)_minmax(0,1.45fr)] items-center gap-4 px-2 py-2",t&&"border-t"),children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)(ea3,{status:e.status}),(0,eb.jsx)("span",{className:"truncate text-sm font-medium",children:e.name})]}),(0,eb.jsxs)("div",{className:"mt-1 truncate ui-text-kbd text-muted-foreground",children:[e.os," · ",e.link," · heartbeat ",e.heartbeat]})]}),(0,eb.jsxs)("div",{className:"grid gap-2 sm:grid-cols-4",children:[(0,eb.jsx)(ea4,{icon:(0,eb.jsx)(uK,{}),label:"CPU",value:e.cpu}),(0,eb.jsx)(ea4,{icon:(0,eb.jsx)(erM,{}),label:"MEM",value:e.memory}),(0,eb.jsx)(ea4,{icon:(0,eb.jsx)(uG,{}),label:"DISK",value:e.disk}),(0,eb.jsx)(ea4,{icon:(0,eb.jsx)(erE,{}),label:"NET",value:e.network})]})]})}function ea4({icon:e,label:t,value:n}){return(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsxs)("div",{className:"flex justify-between gap-1 ui-text-kbd text-muted-foreground",children:[(0,eb.jsxs)("span",{className:"flex items-center gap-1 [&_svg]:size-3",children:[e,t]}),(0,eb.jsxs)("span",{children:[n,"%"]})]}),(0,eb.jsx)(erw,{value:n,className:"h-1.5"})]})}function ea3({status:e}){return(0,eb.jsx)("span",{className:(0,ez.cn)("size-2 rounded-full bg-border","online"===e&&"bg-primary")})}function ea6({links:e}){let t=ew.useMemo(()=>e.map(([e,t,n,r,a])=>({id:`${e}-${t}`,status:"Relay fallback"===n?"blocked":"current",title:(0,eb.jsxs)("div",{className:"grid w-full grid-cols-[minmax(0,1fr)_5rem_4rem_3.5rem] items-center gap-3",children:[(0,eb.jsxs)("span",{className:"truncate",children:[e," / ",t]}),(0,eb.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:n}),(0,eb.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:r}),(0,eb.jsx)("span",{className:"text-right ui-text-kbd text-muted-foreground",children:a})]})})),[e]);return(0,eb.jsx)(enX,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-2"})}function ea8({config:e,data:t}){return(0,eb.jsx)(Hl,{config:e,className:"mt-2 min-h-0 flex-1",children:(0,eb.jsxs)(JB,{data:t,margin:{left:8,right:8},children:[(0,eb.jsx)(Qf,{vertical:!1}),(0,eb.jsx)(QE,{dataKey:"time",tickLine:!1,axisLine:!1,tickMargin:8}),(0,eb.jsx)(VZ,{content:(0,eb.jsx)(Hc,{indicator:"line"})}),(0,eb.jsx)(JR,{dataKey:"cpu",type:"monotone",fill:"var(--color-cpu)",fillOpacity:.11,stroke:"var(--color-cpu)",strokeWidth:2}),(0,eb.jsx)(JR,{dataKey:"memory",type:"monotone",fill:"var(--color-memory)",fillOpacity:.1,stroke:"var(--color-memory)",strokeWidth:2}),(0,eb.jsx)(JR,{dataKey:"network",type:"monotone",fill:"var(--color-network)",fillOpacity:.08,stroke:"var(--color-network)",strokeWidth:2})]})})}function ea7({services:e}){let[t,n]=ZC(),r=Math.max(1,Math.floor((Math.max(0,n.width-192-64-32)+5)/12)),a=Math.max(48,n.height>0?Math.floor((n.height-0*Math.max(0,e.length-1))/e.length):48),i=Math.max(28,a-22);return(0,eb.jsx)("div",{ref:t,className:"mt-2 min-h-0 flex-1",children:e.map((e,t)=>(0,eb.jsx)(ea9,{service:e,divided:t>0,rowHeight:a,sampleCount:r,sampleHeight:i},e.id))})}function ea9({service:e,divided:t,rowHeight:n,sampleCount:r,sampleHeight:a}){let i=ew.useMemo(()=>{var t,n;return t=e.samples,n=r,t.length>=n?t.slice(t.length-n):Array.from({length:n},(e,n)=>{let r=n%t.length;return t[r]??0})},[r,e.samples]);return(0,eb.jsxs)("div",{className:(0,ez.cn)("grid grid-cols-[12rem_minmax(0,1fr)_4rem] items-center gap-4 px-2",t&&"border-t"),style:{height:n},children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("div",{className:"truncate text-sm font-medium",children:e.name}),(0,eb.jsx)("div",{className:(0,ez.cn)("mt-0.5 truncate ui-text-kbd text-muted-foreground","告警"===e.state&&"text-destructive"),children:e.state})]}),(0,eb.jsx)("div",{"aria-label":`${e.name} 30 minute stability samples`,className:"flex min-w-0 items-center overflow-hidden",style:{gap:5},children:i.map((t,n)=>{var r;return(0,eb.jsx)("span",{className:(0,ez.cn)("shrink-0 rounded-[2px]",(r=t)<60?"bg-destructive":r<72?"bg-destructive/55":r<84?"bg-primary/35":r<92?"bg-primary/60":"bg-primary"),style:{width:7,height:a},title:`${t}%`},`${e.id}-${n}`)})}),(0,eb.jsxs)("div",{className:"text-right text-sm font-medium tabular-nums",children:[e.samples.at(-1),"%"]})]})}let eie=[{id:"canvas-vantaloom-base",title:"Vantaloom 基座设计",status:"live",purpose:"承载多标签系统、文件树、终端和 Agent 会话节点。",nodes:18,agents:3,progress:64,health:91,runtime:"3h 12m",tokenUsage:62e4,lastOpened:"刚刚",snapshots:14,unsavedChanges:3,roadmap:[{title:"接入节点模板选择",state:"done"},{title:"处理节点吸附与连线遮挡",state:"done"},{title:"合并多标签页拖拽",state:"running"},{title:"沉淀真实项目模板",state:"queued"}],settings:{nodeTemplates:["多标签页系统","文件管理树","终端标签组","Agent 对话"],defaultLayout:["默认缩放 0.72","节点内容 2x","定位点 24px"],folders:["D:/Projects/Vantaloom-ui","D:/Projects/Vantaloom-ui/apps"],sharing:["工作组管理员可编辑","成员可审阅","访客不可访问"],autosave:["每 45 秒保存","节点拖拽结束保存","切换工作区保存"],snapshots:["保留最近 30 个","发布前创建检查点"],hosts:["Studio-PC","Linux-runner-02"],plugins:["Browser","Git checkpoint"]}},{id:"canvas-agent-lab",title:"Agent 编排实验",status:"live",purpose:"验证多 Agent 对话、工具窗口和剪切板在画布中的协同。",nodes:11,agents:4,progress:41,health:78,runtime:"1h 36m",tokenUsage:308e3,lastOpened:"8 分钟前",snapshots:9,unsavedChanges:1,roadmap:[{title:"四分工作区布局",state:"done"},{title:"面板替换进剪切板",state:"done"},{title:"会话浏览页",state:"running"},{title:"会话节点化",state:"queued"}],settings:{nodeTemplates:["Agent 对话","数据表标签","浏览器标签"],defaultLayout:["默认双栏","右侧可调整","剪切板常驻"],folders:["D:/Projects/Vantaloom-ui/apps/vantaloom"],sharing:["仅本机管理员可编辑"],autosave:["每 60 秒保存"],snapshots:["保留最近 12 个"],hosts:["Studio-PC"],plugins:["Browser"]}},{id:"canvas-release-map",title:"发布路线图",status:"review",purpose:"梳理组件库、主应用和文档的发布前检查。",nodes:9,agents:1,progress:83,health:86,runtime:"42m",tokenUsage:144e3,lastOpened:"今天 15:02",snapshots:7,unsavedChanges:0,roadmap:[{title:"组件清单",state:"done"},{title:"风险列表",state:"done"},{title:"最终检查",state:"running"}],settings:{nodeTemplates:["Diff 标签","数据表标签","文件预览标签"],defaultLayout:["审阅模式默认开启"],folders:["D:/Projects/Vantaloom-ui/docs"],sharing:["工作组可审阅"],autosave:["手动保存"],snapshots:["里程碑保留"],hosts:["Studio-PC"],plugins:[]}},{id:"canvas-browser-matrix",title:"浏览器预览矩阵",status:"idle",purpose:"检查不同 UA、比例和内嵌预览模式的表现。",nodes:6,agents:0,progress:100,health:94,runtime:"28m",tokenUsage:78e3,lastOpened:"昨天 18:44",snapshots:5,unsavedChanges:0,roadmap:[{title:"自适应模式",state:"done"},{title:"长宽比菜单",state:"done"},{title:"导航按钮",state:"done"}],settings:{nodeTemplates:["浏览器标签","多标签页系统"],defaultLayout:["自适应预览"],folders:["D:/Projects/Vantaloom-ui/packages/ui"],sharing:["仅自己"],autosave:["关闭"],snapshots:["保留最近 5 个"],hosts:["Studio-PC"],plugins:["Browser"]}},{id:"canvas-ops-topology",title:"工作组拓扑",status:"idle",purpose:"记录机器、服务和工作组连接关系。",nodes:15,agents:0,progress:100,health:89,runtime:"1h 04m",tokenUsage:92e3,lastOpened:"周四 11:30",snapshots:11,unsavedChanges:0,roadmap:[{title:"机器节点整理",state:"done"},{title:"连接策略标注",state:"done"},{title:"访问权限检查",state:"done"}],settings:{nodeTemplates:["数据表标签","浏览器标签","终端标签组"],defaultLayout:["视口吸附开启","节点吸附开启"],folders:["D:/Projects/Vantaloom-ui/ops"],sharing:["管理员可编辑","成员可查看"],autosave:["每 2 分钟保存"],snapshots:["每日保留"],hosts:["Studio-PC","Linux-runner-02","MacBook-build"],plugins:[]}}];function eit(e,t,n,r,a,i,o){return{id:e,title:t,status:"idle",purpose:n,nodes:r,agents:0,progress:100,health:90,runtime:a,tokenUsage:i,lastOpened:o,snapshots:Math.max(3,Math.round(r/2)),unsavedChanges:0,roadmap:[{title:"整理节点结构",state:"done"},{title:"检查连接关系",state:"done"},{title:"保存最终快照",state:"done"}],settings:{nodeTemplates:["多标签页系统","文件预览标签"],defaultLayout:["默认缩放 0.72","节点吸附开启"],folders:["D:/Projects/Vantaloom-ui"],sharing:["仅自己"],autosave:["关闭"],snapshots:["保留最近 5 个"],hosts:["Studio-PC"],plugins:[]}}}eie.push(eit("canvas-terminal-layout","终端工作台草图","记录终端标签组、日志表和命令区的组合方式。",7,"36m",84e3,"昨天 15:21"),eit("canvas-file-review","文件审阅流程","沉淀文件树、diff 预览和文件标签之间的拖拽关系。",12,"58m",126e3,"周五 20:10"),eit("canvas-settings-ia","设置导航结构","整理设置菜单面板的主菜单、子菜单和搜索入口。",8,"24m",61e3,"周五 16:42"),eit("canvas-auth-access","本机账户接入","记录本机用户、工作组加入和可用机器列表关系。",10,"47m",112e3,"周四 22:05"),eit("canvas-data-ops","运维数据面板","对齐数据表标签、机器状态卡片和运行记录列表。",14,"1h 18m",172e3,"周三 19:48"));let ein=eie.filter(e=>"idle"!==e.status),eir=eie.filter(e=>"idle"===e.status);function eia(e,t,n=""){return{title:e,dataSource:t,refreshRate:"30s",note:n}}function eii(e,t){return(0,eb.jsx)("section",{className:(0,ez.cn)("size-full rounded-xl border bg-card p-5","vtl-jelly-image-card vtl-jelly-image-card-shadowless"),style:en0({image:t,opacity:.88,blur:"0px"}),children:e})}let eio=[{id:"metric-active",kind:"metric-active",x:0,y:0,w:3,h:3},{id:"metric-nodes",kind:"metric-nodes",x:3,y:0,w:3,h:3},{id:"metric-unsaved",kind:"metric-unsaved",x:6,y:0,w:3,h:3},{id:"metric-snapshots",kind:"metric-snapshots",x:9,y:0,w:3,h:3},{id:"active",kind:"active",x:0,y:3,w:12,h:3},{id:"recent",kind:"recent",x:0,y:6,w:12,h:Math.max(3,Math.ceil(.75*eir.length)+1)}];function eil({open:e,title:t,description:n,eyebrow:r,panels:a,defaultPanelId:i="overview",onOpenChange:o}){let l=sv(),[s,c]=ew.useState(i),d=a.find(e=>e.id===s)??a[0];return ew.useEffect(()=>{e&&c(i)},[i,e]),(0,eb.jsx)(dX,{open:e,onOpenChange:o,children:(0,eb.jsxs)(fU,{hideClose:!0,className:(0,ez.cn)("gap-0 overflow-hidden p-0",l?"inset-0 h-svh w-full max-w-none translate-x-0 translate-y-0 rounded-none border-0":"h-[min(44rem,calc(100svh-2rem))] max-w-5xl"),children:[(0,eb.jsx)(fK,{className:"sr-only",children:t}),(0,eb.jsxs)(fG,{className:"sr-only",children:[r?(0,eb.jsxs)(eb.Fragment,{children:[r,". "]}):null,n??t]}),l?(0,eb.jsxs)("div",{className:"flex h-full flex-col",children:[(0,eb.jsxs)("header",{className:"flex shrink-0 items-center gap-3 border-b px-4 py-3",children:[(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"关闭",onClick:()=>o(!1),children:(0,eb.jsx)(fV.XIcon,{className:"size-4"})}),(0,eb.jsxs)("div",{className:"min-w-0 flex-1",children:[r?(0,eb.jsx)("div",{className:"truncate text-xs text-muted-foreground",children:r}):null,(0,eb.jsx)("div",{className:"truncate text-sm font-semibold",children:t})]})]}),(0,eb.jsx)("nav",{className:"shrink-0 overflow-x-auto border-b [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:(0,eb.jsx)("div",{className:"flex gap-1.5 px-4 py-2",children:a.map(e=>(0,eb.jsxs)("button",{type:"button",className:(0,ez.cn)("inline-flex shrink-0 items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium transition-colors",d?.id===e.id?"bg-foreground text-background":"bg-muted text-muted-foreground"),onClick:()=>c(e.id),children:[e.icon?(0,eb.jsx)("span",{className:"[&_svg]:size-3.5",children:e.icon}):null,(0,eb.jsx)("span",{children:e.label}),e.badge?(0,eb.jsx)(Vp,{variant:"outline",className:"h-4 px-1 ui-text-kbd",children:e.badge}):null]},e.id))})}),(0,eb.jsx)(jP,{className:"min-h-0 flex-1",children:(0,eb.jsx)("div",{className:"p-4",children:d?.content})})]}):(0,eb.jsxs)("div",{className:"grid size-full min-h-0 grid-cols-[15rem_minmax(0,1fr)]",children:[(0,eb.jsx)("aside",{"data-slot":"resource-management-dialog-sidebar",className:"min-h-0 border-r bg-muted/20",children:(0,eb.jsx)(jP,{className:"h-full",children:(0,eb.jsx)("div",{className:"space-y-1 p-2",children:a.map(e=>(0,eb.jsxs)(eO.Button,{"data-slot":"resource-management-dialog-nav-item",type:"button",variant:"ghost",className:(0,ez.cn)("h-9 w-full justify-start px-2.5 text-left font-medium",d?.id===e.id?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/70 hover:text-foreground"),onClick:()=>c(e.id),children:[e.icon?(0,eb.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center [&_svg]:size-4",children:e.icon}):null,(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.label}),e.badge?(0,eb.jsx)(Vp,{variant:"outline",className:"h-5 px-1.5 ui-text-kbd",children:e.badge}):null]},e.id))})})}),(0,eb.jsx)(jP,{className:"min-h-0 bg-background",children:(0,eb.jsx)("div",{className:"p-5 pr-9",children:d?.content})})]})]})})}function eis({clipboardItems:e=[],onClipboardItemsChange:t,onOverlayOpenChange:n}){let[r,a]=ew.useState(),i=ew.useMemo(()=>(function({onSelect:e}){return[{id:"metric-active",title:"活跃画布",description:"当前正在编辑的画布数量。",icon:(0,eb.jsx)(u1,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:eia("活跃画布","画布列表"),render:e=>eii((0,eb.jsx)(eag,{label:e.title,description:"当前正在编辑的画布数量",value:String(ein.length)}),enY)},{id:"metric-nodes",title:"运行节点",description:"所有活跃画布内的节点。",icon:(0,eb.jsx)(HM,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:eia("运行节点","画布节点"),render:e=>eii((0,eb.jsx)(eag,{label:e.title,description:"所有活跃画布内的节点",value:"38"}),enZ)},{id:"metric-unsaved",title:"未保存",description:"等待写入的画布变更。",icon:(0,eb.jsx)(kV,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:eia("未保存","画布保存状态"),render:e=>eii((0,eb.jsx)(eag,{label:e.title,description:"等待写入的画布变更",value:"4"}),enJ)},{id:"metric-snapshots",title:"快照",description:"可回退的历史存档。",icon:(0,eb.jsx)(Xb,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:eia("快照","画布快照"),render:e=>eii((0,eb.jsx)(eag,{label:e.title,description:"可回退的历史存档",value:"46"}),enQ)},{id:"active",title:"正在使用的画布",description:"活跃画布 Roadmap。",icon:(0,eb.jsx)(u1,{className:"size-4"}),defaultSize:{w:12,h:3},defaultConfig:eia("正在使用的画布","画布列表"),render:t=>(0,eb.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,eb.jsx)(eaK,{title:t.title,count:ein.length}),(0,eb.jsx)(erN,{canvases:ein,scrollable:!0,onSelect:e})]})},{id:"recent",title:"最近画布",description:"最近打开的画布。",icon:(0,eb.jsx)(h9,{className:"size-4"}),defaultSize:{w:12,h:Math.max(3,Math.ceil(.75*eir.length)+1)},defaultConfig:eia("最近画布","画布列表"),render:t=>(0,eb.jsxs)("section",{className:"flex size-full flex-col",children:[(0,eb.jsx)(eaK,{title:t.title,count:eir.length}),(0,eb.jsx)(erN,{canvases:eir,mode:"archive",onSelect:e})]})}]})({onSelect:a}),[]);return(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(erp,{boardId:"canvas-library",definitions:i,initialLayouts:eio,clipboardItems:e,actionLabel:"画布库页面卡片操作",paletteGroupTitle:"画布库页面卡片",onClipboardItemsChange:t,onOverlayOpenChange:n}),(0,eb.jsx)(eid,{canvas:r,onOpenChange:e=>{e||a(void 0)}})]})}function eic({icon:e,value:t}){return(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,eb.jsx)("span",{className:"[&_svg]:size-3.5",children:e}),(0,eb.jsx)("span",{className:"tabular-nums",children:t})]})}function eid({canvas:e,onOpenChange:t}){return e?(0,eb.jsx)(eil,{open:!!e,onOpenChange:t,title:e.title,eyebrow:"画布管理",description:e.purpose,panels:[{id:"overview",label:"首页",icon:(0,eb.jsx)(HE,{}),content:(0,eb.jsx)(eiu,{canvas:e})},{id:"templates",label:"节点模板",icon:(0,eb.jsx)(enB,{}),badge:e.settings.nodeTemplates.length,content:(0,eb.jsx)(eim,{title:"可用节点模板",items:e.settings.nodeTemplates})},{id:"layout",label:"默认布局",icon:(0,eb.jsx)(enW,{}),content:(0,eb.jsx)(eim,{title:"默认布局参数",items:e.settings.defaultLayout})},{id:"folders",label:"工作区绑定",icon:(0,eb.jsx)(h9,{}),content:(0,eb.jsx)(eim,{title:"绑定的工作区文件夹",items:e.settings.folders})},{id:"sharing",label:"共享权限",icon:(0,eb.jsx)(enq,{}),content:(0,eb.jsx)(eim,{title:"共享与权限",items:e.settings.sharing})},{id:"autosave",label:"自动保存",icon:(0,eb.jsx)(Xj,{}),content:(0,eb.jsx)(eim,{title:"自动保存策略",items:e.settings.autosave})},{id:"snapshots",label:"快照和版本",icon:(0,eb.jsx)(Xb,{}),content:(0,eb.jsx)(eim,{title:"快照和版本策略",items:e.settings.snapshots})},{id:"hosts",label:"可访问主机",icon:(0,eb.jsx)(enH,{}),content:(0,eb.jsx)(eim,{title:"可访问主机",items:e.settings.hosts})},{id:"plugins",label:"插件",icon:(0,eb.jsx)(enU,{}),content:(0,eb.jsx)(eim,{title:"画布插件",items:e.settings.plugins,empty:"未加载插件"})}]}):null}function eiu({canvas:e}){return(0,eb.jsxs)("div",{className:"grid gap-5",children:[(0,eb.jsxs)("button",{type:"button",className:"group relative grid min-h-72 rounded-[2rem] border bg-card p-7 text-left transition-colors hover:bg-muted/35",children:[(0,eb.jsxs)("div",{className:"grid gap-5",children:[(0,eb.jsxs)("div",{className:"max-w-2xl",children:[(0,eb.jsx)("h3",{className:"text-3xl font-semibold tracking-normal",children:e.title}),(0,eb.jsx)("p",{className:"mt-4 text-sm leading-6 text-muted-foreground",children:e.purpose})]}),(0,eb.jsxs)("div",{className:"grid max-w-56 gap-2",children:[(0,eb.jsx)(eif,{label:"Nodes",value:`${e.nodes}`}),(0,eb.jsx)(eif,{label:"Agent",value:`${e.agents}`}),(0,eb.jsx)(eif,{label:"Snapshots",value:`${e.snapshots}`})]})]}),(0,eb.jsx)("span",{className:"absolute right-7 bottom-7 text-sm font-medium text-foreground transition-opacity group-hover:opacity-70",children:"进入"})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)("span",{className:"text-sm font-medium",children:"Roadmap"}),(0,eb.jsx)(eic,{icon:(0,eb.jsx)(HM,{}),value:e.runtime})]}),(0,eb.jsx)(enX,{items:e.roadmap.map(e=>({id:e.title,title:e.title,status:"running"===e.state?"current":"done"===e.state?"done":"queued"})),viewportClassName:"max-h-64"})]})]})}function eif({label:e,value:t}){return(0,eb.jsxs)("span",{className:"grid min-w-0 gap-0.5 py-0.5",children:[(0,eb.jsx)("span",{className:"truncate ui-text-kbd text-muted-foreground",children:e}),(0,eb.jsx)("span",{className:"min-w-0 truncate text-sm font-semibold tracking-normal",children:t})]})}function eim({title:e,items:t,empty:n="暂无内容"}){return(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:e}),(0,eb.jsx)("div",{className:"overflow-hidden rounded-xl border bg-card",children:t.length>0?t.map((e,t)=>(0,eb.jsxs)("div",{className:(0,ez.cn)("flex min-h-10 items-center gap-2 px-3 text-sm",t>0&&"border-t"),children:[(0,eb.jsx)(enV,{className:"size-4 text-muted-foreground"}),(0,eb.jsx)("span",{className:"min-w-0 truncate",children:e})]},e)):(0,eb.jsx)("div",{className:"px-3 py-6 text-sm text-muted-foreground",children:n})})]})}function eih({open:e,onOpenChange:t,onAdd:n}){return(0,eb.jsx)(bm,{open:e,onOpenChange:t,title:"添加节点",description:"搜索并选择要放入画布的可用节点。",className:"top-1/2 max-w-xl -translate-y-1/2",children:(0,eb.jsxs)(bf,{loop:!0,children:[(0,eb.jsx)(bh,{placeholder:"搜索节点..."}),(0,eb.jsxs)(bp,{children:[(0,eb.jsx)(bg,{children:"没有匹配节点。"}),(0,eb.jsx)(bx,{heading:"可用节点",children:fe.map(e=>(0,eb.jsxs)(bv,{value:`${e.title} ${e.description} ${e.keywords}`,onSelect:()=>n(e),children:[(0,eb.jsx)("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg border bg-background text-muted-foreground",children:e.icon}),(0,eb.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,eb.jsx)("span",{className:"block truncate text-sm font-medium",children:e.title}),(0,eb.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,eb.jsxs)(bb,{children:[e.size.width,"x",e.size.height]})]},e.id))})]})]})})}function eip({node:e}){return(0,eb.jsx)("button",{type:"button",draggable:!0,"aria-label":"拖拽到对话框作为附件",title:"拖拽到对话框作为附件",onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),onDragStart:t=>{t.stopPropagation(),t.dataTransfer.setData(qf,qh(e)),t.dataTransfer.effectAllowed="copy"},className:"nodrag nopan pointer-events-auto absolute right-1.5 top-1.5 z-10 grid size-6 cursor-grab place-items-center rounded-md border border-border bg-background/85 text-muted-foreground shadow-sm transition-colors hover:bg-muted hover:text-foreground active:cursor-grabbing [&_svg]:size-3.5",children:(0,eb.jsx)(kF,{})})}function eig({nodes:e,edges:t,selectedNodeId:n,clipboardItems:r,onNodesChange:a,onEdgesChange:i,onNodesSet:o,onEdgesSet:l,onSelectedNodeChange:s,onClipboardItemsChange:c}){let d=ew.useRef(null),{addPaletteOpen:u,addTemplateNode:f,handleAddPaletteOpenChange:m,handleCanvasAction:h,handleCanvasDragOver:p,handleCanvasDrop:g,handleNodeCanvasConnect:x,handleNodeCanvasEdgeAction:v,handleNodeCanvasNodeAction:b,filePickerDialog:y,renderedCanvasNodes:w}=function({workspaceRef:e,nodes:t,clipboardItems:n,onNodesSet:r,onEdgesSet:a,onSelectedNodeChange:i,onClipboardItemsChange:o}){let l=ew.useRef(0),s=ew.useRef(0),[c,d]=ew.useState(!1),[u,f]=ew.useState(),[m,h]=ew.useState(),p=ew.useCallback((t,n)=>{let r,a,i,o,l,s,c,d;return r=e.current,a=r?.querySelector(".react-flow__viewport"),i=r?.getBoundingClientRect(),l="none"!==(o=a?getComputedStyle(a).transform:"none")?new DOMMatrixReadOnly(o):void 0,s=l?.a&&Number.isFinite(l.a)?l.a:1,c=l?.e??0,d=l?.f??0,{x:(t-(i?.left??0)-c)/s,y:(n-(i?.top??0)-d)/s}},[e]),g=ew.useCallback((e,t)=>{r(n=>n.map(n=>{let r,a;return n.id===e?(a="string"==typeof(r=n.data??{}).activeTabId&&t.some(e=>e.id===r.activeTabId)?r.activeTabId:t[0]?.id,{...n,data:{...r,tabs:t,activeTabId:a}}):n}))},[r]),x=ew.useCallback((e,t)=>{r(n=>n.map(n=>n.id===e?{...n,data:{...n.data??{},activeTabId:t}}:n))},[r]),v=ew.useCallback((e,t)=>{r(n=>n.map(n=>n.id===e?function(e,t){let n=e.data??{};if("multi-tab-system"===n.kind){let r=Array.isArray(n.tabs)?n.tabs:[];return{...e,data:{...n,tabs:r.map(e=>e.id===t.id?t:e),activeTabId:t.id}}}return fr(n.kind)?{...e,data:{...n,tab:t}}:e}(n,t):n))},[r]),b=ew.useCallback((e,t)=>{r(n=>n.map(n=>n.id===e?{...n,data:{...n.data??{},terminal:t}}:n))},[r]),y=ew.useCallback((e,t)=>{r(n=>n.map(n=>n.id===e?{...n,data:{...n.data??{},sideQuery:t}}:n))},[r]),w=ew.useCallback((e,t)=>{var n;let a=(n=e.kind,fe.find(e=>e.id===n)?.size??u3({width:480,height:320}));s.current+=1;let o=`${e.kind}-detached-${s.current}`;r(n=>[...n,function({tab:e,nodeId:t,center:n,size:r}){return{id:t,type:"blank",position:u7(n,r),data:{contentScale:2,kind:e.kind,tab:{...e,id:`${t}-tab`}},width:r.width,height:r.height,style:u6(r)}}({tab:e,nodeId:o,center:t,size:a})]),i(o)},[r,i]),j=ew.useCallback(async(e,n)=>{try{let a,i=n?.nodeId?t.find(e=>e.id===n.nodeId):void 0,o=i?(i.data??{}).kind:void 0,l="data-table-tab-viewer"===o?await fC(e):await fk(e),s=void 0!==i&&(a=i.data??{},"multi-tab-system"===a.kind||"file-tab-viewer"===a.kind||"data-table-tab-viewer"===a.kind);n?.nodeId&&s&&r(e=>e.map(e=>e.id===n.nodeId?function(e,t,n){let r=e.data??{};if("multi-tab-system"===r.kind){let a,i,o=Array.isArray(r.tabs)?r.tabs:[];return{...e,data:{...r,tabs:(a=o.filter(e=>e.id!==t.id),i=void 0===n?a.length:Math.min(Math.max(n,0),a.length),a.splice(i,0,t),a),activeTabId:t.id}}}return"file-tab-viewer"===r.kind||"data-table-tab-viewer"===r.kind&&"data-table-tab-viewer"===t.kind?{...e,data:{...r,tab:t}}:e}(e,l,n.insertIndex):e)),n?.nodeId&&s||w(l,u??{x:496,y:336})}catch{hn.error("文件预览打开失败")}},[w,t,r,u]),k=ew.useCallback(e=>{let n=t.find(e=>"multi-tab-system"===(e.data??{}).kind);j(e,n?{nodeId:n.id}:void 0)},[t,j]),N=ew.useCallback(async(e,t,n)=>{let r=t.file?.path,a=t.file?.machineId??"local";if(!r)throw hn.error("文件路径不可用"),Error("file path is unavailable");try{let i=await fu({machineId:a,path:r,content:n}),o={...t,title:i.name,modified:!1,defaultValue:"utf-8"===i.encoding?i.content:n,file:{...t.file,name:i.name,path:i.path,machineId:i.machine.id,mimeType:i.mimeType,kind:t.file?.kind,size:i.size,truncated:i.truncated}};v(e,o),hn.success("文件已保存")}catch(e){throw hn.error("文件保存失败"),e}},[v]),S=ew.useCallback((e,t,n)=>{w(t,p(n.clientX,n.clientY))},[w,p]),C=ew.useCallback(e=>{let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id"),r=n.find(e=>e.id===t),a=r?r.payloads?.[qd]:void 0;if(a)return a;let i=e.dataTransfer.getData(qd);if(i)try{return JSON.parse(i)}catch{return}},[n]),M=ew.useCallback((e,t,n)=>{r(r=>r.map(r=>r.id!==e?r:function(e,t,n){let r=e.data??{},a=Array.isArray(r.tabs)?r.tabs:[],i=new Set(a.map(e=>e.id)),o=n.tab.id,l=2;for(;i.has(o);)o=`${n.tab.id}-${l}`,l+=1;let s=[...a];return s.splice(Math.max(0,Math.min(t,s.length)),0,{...n.tab,id:o}),{...e,data:{...r,tabs:s,activeTabId:o}}}(r,t,n)))},[r]),E=ew.useCallback((e,t,n)=>{let r=C(n);r&&M(e,t,r)},[C,M]),I=ew.useCallback(e=>(function(e,t){for(let n of[...e].reverse()){if("multi-tab-system"!==(n.data??{}).kind)continue;let e=function(e){let t="number"==typeof e.width?e.width:"number"==typeof e.style?.width?e.style.width:"string"==typeof e.style?.width?Number.parseFloat(e.style.width):192,n="number"==typeof e.height?e.height:"number"==typeof e.style?.height?e.style.height:"string"==typeof e.style?.height?Number.parseFloat(e.style.height):112;return{width:Number.isFinite(t)?t:192,height:Number.isFinite(n)?n:112}}(n),r=t.x>=n.position.x&&t.x<=n.position.x+e.width,a=t.y>=n.position.y&&t.y<=n.position.y+e.height;if(r&&a)return n}})(t,e),[t]),P=ew.useCallback((t,n,r)=>(function(e,t,n,r){let a=Array.from(e.current?.querySelectorAll(".react-flow__node")??[]).find(e=>e.getAttribute("data-id")===t),i=a?.querySelector('[data-slot="multi-tab-list"]');if(!i)return r;let o=Array.from(i.querySelectorAll("[data-tab-id]"));for(let[e,t]of o.entries()){let r=t.getBoundingClientRect();if(n<r.left+r.width/2)return e}return o.length})(e,t,n,r),[e]),O=function({nodes:e,onTabsChange:t,onActiveTabChange:n,onRequestFileTab:r,onOpenWorkspaceFile:a,onTabChange:i,onSaveFileTab:o,onTerminalStateChange:l,onSideQueryBind:s,onTabDetach:c,onExternalTabDrop:d}){return ew.useMemo(()=>e.map(e=>{let u=e.data??{},f=(e.data??{}).kind;return f?{...e,data:{...u,content:(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(eip,{node:e}),(0,eb.jsx)(eeb,{kind:f,nodeId:e.id,tab:u.tab,tabs:u.tabs,activeTabId:u.activeTabId,terminalScopeId:`canvas:node:${e.id}`,terminalState:u.terminal,onTerminalStateChange:t=>l(e.id,t),sideQueryBinding:u.sideQuery,onSideQueryBind:s,onRequestFileTab:r,onOpenWorkspaceFile:a,onTabsChange:t,onTabChange:i,onSaveFileTab:o,onActiveTabChange:n,onTabDetach:c,onExternalTabDrop:d})]})}}:e}),[e,n,d,a,r,o,s,i,c,l,t])}({nodes:t,onTabsChange:g,onActiveTabChange:x,onRequestFileTab:h,onOpenWorkspaceFile:k,onTabChange:v,onSaveFileTab:N,onTerminalStateChange:b,onSideQueryBind:y,onTabDetach:S,onExternalTabDrop:E}),z=ew.useCallback(e=>{s.current+=1;let n=`${e.id}-${t.length+s.current}`;r(t=>[...t,function({template:e,nodeId:t,center:n}){let r={contentScale:2,kind:e.id};return"multi-tab-system"===e.id?r.tabs=[]:fr(e.id)&&(r.tab=fi(e.id,`${t}-tab`)),{id:t,type:"blank",position:u7(n,e.size),data:r,width:e.size.width,height:e.size.height,style:u6(e.size)}}({template:e,nodeId:n,center:u??{x:496,y:336}})]),i(void 0),d(!1),f(void 0)},[t.length,r,i,u]),A=ew.useCallback(e=>{let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id");if(!t)return;let a=n.find(e=>e.id===t),o=p(e.clientX,e.clientY),s=C(e),c=s?I(o):void 0;if(s&&c){e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move";let t=c.data??{},n=Array.isArray(t.tabs)?t.tabs:[],r=P(c.id,e.clientX,n.length);M(c.id,r,s),i(void 0);return}let d=a?a.payloads?.[qc]:void 0;if(!a||!d)return;e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move",l.current+=1;let u=`${d.node.id}-drop-${l.current}`;r(e=>[...e,function({source:e,nodeId:t,center:n}){let r={width:e.width??192,height:e.height??112};return{...e,id:t,position:u7(n,r),style:e.style??u6(r),selected:!1,data:{...e.data??{},resizing:!1}}}({source:d.node,nodeId:u,center:o})]),i(u)},[n,I,C,p,P,M,r,i]),T=ew.useCallback(e=>{Array.from(e.dataTransfer.types).some(e=>[qc,qd].includes(e))&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},[]),R=ew.useCallback((e,{flowPosition:t})=>{"add"===e&&(f(t),d(!0))},[]),D=ew.useCallback(e=>{a(t=>{if(t.find(t=>t.source===e.source&&t.target===e.target))return t;let n=t.find(t=>t.source===e.target&&t.target===e.source);return n?t.map(e=>e.id===n.id?{...e,data:{...e.data??{},bidirectional:!0}}:e):[...t,{id:`edge-${e.source}-${e.target}-${t.length+1}`,type:"connection",source:e.source,target:e.target,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle,data:{anchors:[]}}]})},[a]),_=ew.useCallback((e,t,n)=>{"cut-edge"===e?a(e=>e.filter(e=>e.id!==t)):a(r=>r.map(r=>{if(r.id!==t)return r;let a=[...r.data?.anchors??[]];return"add-anchor"===e&&n.anchor&&a.splice(n.anchorIndex??a.length,0,n.anchor),"move-anchor"===e&&n.anchor&&void 0!==n.anchorIndex&&(a[n.anchorIndex]=n.anchor),"delete-anchor"===e&&void 0!==n.anchorIndex&&a.splice(n.anchorIndex,1),{...r,data:{...r.data??{},anchors:a}}}))},[a]),L=ew.useCallback((e,n,{snappedPosition:l})=>{if("copy"===e)return void r(e=>{let t=e.find(e=>e.id===n);if(!t)return e;let r=`${t.id}-copy-${e.length+1}`;return i(r),[...e,{...t,id:r,position:l,selected:!1,data:{...t.data??{},resizing:!1}}]});if("cut"===e){let e,l,s,c,d,u=t.find(e=>e.id===n);if(!u)return;let f=(s=(l=function(e){let t=e.data??{},n=t.tab;if(n?.id&&fr(n.kind))return n;let r=t.kind;if(fr(r))return fi(r,e.id)}(e=fo(u)))?{tab:l,sourceNodeId:u.id}:void 0,c={[qc]:{node:e}},d={"application/vnd.vantaloom.clip-kind":l?"canvas-tab":"canvas-node",[qc]:u.id},s&&(c[qd]=s,d[qd]=JSON.stringify(s)),{id:`clip-${u.id}`,title:l?.title??"画布节点",description:l?"来自画布的独立标签页。":"来自节点画布的空白节点。",meta:`${Math.round(u.width??192)}x${Math.round(u.height??112)}`,icon:l?fa(l.kind):(0,eb.jsx)(uU,{className:"size-4"}),dragData:d,payloads:c});o(e=>[f,...e.filter(e=>e.id!==f.id)]),r(e=>e.filter(e=>e.id!==n)),a(e=>e.filter(e=>e.source!==n&&e.target!==n)),i(void 0)}},[t,o,a,r,i]);return{addPaletteOpen:c,addTemplateNode:z,filePickerDialog:(0,eb.jsx)(ZS,{open:void 0!==m,onOpenChange:e=>{e||h(void 0)},onSelectFile:e=>{h(void 0),j(e,m)}}),handleAddPaletteOpenChange:function(e){d(e),e||f(void 0)},handleCanvasAction:R,handleCanvasDragOver:T,handleCanvasDrop:A,handleNodeCanvasConnect:D,handleNodeCanvasEdgeAction:_,handleNodeCanvasNodeAction:L,renderedCanvasNodes:O}}({workspaceRef:d,nodes:e,clipboardItems:r,onNodesChange:a,onEdgesChange:i,onNodesSet:o,onEdgesSet:l,onSelectedNodeChange:s,onClipboardItemsChange:c});return(0,eb.jsxs)("div",{ref:d,className:"vtl-app-background vtl-canvas-workspace relative h-full w-full overflow-hidden",onDragOver:p,onDrop:g,children:[(0,eb.jsx)(sx,{"aria-label":"新建画布",className:"h-full min-h-0 rounded-none border-0",viewportClassName:"h-full",nodes:w,edges:t,nodeTypes:u5,edgeTypes:u4,onNodesChange:a,onEdgesChange:i,selectedNodeId:n,onSelectedNodeChange:s,defaultViewport:{x:0,y:0,zoom:.5},labels:{actions:"画布操作",add:"添加节点",select:"普通鼠标",connect:"连接工具",cut:"剪刀工具",drag:"拖拽工具",modeTools:"模式工具",resetZoom:"重置缩放",viewportTools:"视口工具",lockViewport:"锁定视口",visualSnap:"视觉吸附",nodeSnap:"节点吸附",snapTools:"吸附工具",nodeActions:"节点操作",resizeNode:"调整大小",copyNode:"复制节点",cutNode:"剪切节点"},onCanvasAction:h,onNodeCanvasConnect:x,onNodeCanvasEdgeAction:v,onNodeCanvasNodeAction:b}),(0,eb.jsx)(eih,{open:u,onOpenChange:m,onAdd:f}),y,(0,eb.jsx)(hs,{position:"top-right"})]})}vn.length;let eix="vantaloom:projects-changed";async function eiv(){return(await eiM("/api/local/projects")).projects??[]}async function eib(e){return eiM(`/api/local/projects/${encodeURIComponent(e)}`)}async function eiy(e){return eiM("/api/local/projects",{method:"POST",body:JSON.stringify(e)})}async function eiw(e,t){return eiM(`/api/local/projects/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}async function eij(e){return eiM(`/api/local/projects/${encodeURIComponent(e)}/budget`)}async function eik(e){return eiM(`/api/local/projects/${encodeURIComponent(e)}/codestats`)}async function eiN(e){return eiM(`/api/local/projects/${encodeURIComponent(e)}/gitgraph`)}async function eiS(e,t){return((await eiM(`/api/local/projects/${encodeURIComponent(e)}/conversations${t?"?includeArchived=true":""}`)).conversations??[]).map(e=>cv(e,void 0))}async function eiC(e,t){return cv((await eiM("/api/local/agent/conversations",{method:"POST",body:JSON.stringify({projectId:e,title:t?.title??"新对话",goal:t?.goal??""})})).conversation,void 0)}async function eiM(e,t){let n=await fetch((0,eT.localAPIURL)(e),{cache:"no-store",...t,headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error("string"==typeof r?.error?r.error:"project api failed");return r}let eiE=(0,ek.default)("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]),eiI=["运行环境","工作目录与预算","模型","编排与风控","确认创建"],eiP=[{value:"vantaloom",label:"Vantaloom(原生)"},{value:"claude-code",label:"Claude Code"},{value:"reclaude",label:"reclaude"}],eiO=[{value:"auto",label:"自动(auto)",desc:"不门控,自动放行所有工具调用。"},{value:"acceptEdits",label:"接受编辑(acceptEdits)",desc:"编辑自动放行,命令等高风险调用需审批。默认。"},{value:"ask",label:"逐项审批(ask)",desc:"所有非内联工具调用都需审批。"}],eiz=[{value:"off",label:"关闭(off)",desc:"auto 模式,不门控任何工具调用(仅硬危险命令仍被直接拒绝)。"},{value:"loose",label:"宽松(loose)",desc:"auto 模式 + 危险反思仅对高危调用介入。"},{value:"standard",label:"标准(standard)",desc:"acceptEdits 模式 + 危险反思对「风险及以上」介入。默认。"},{value:"strict",label:"严格(strict)",desc:"ask 模式 + 危险反思对全部工具调用介入。"},{value:"paranoid",label:"偏执(paranoid)",desc:"ask 模式 + 危险反思全覆盖,且发布类命令(publish/deploy/update)强制上卡。"}],eiA=[{value:"queue-park",label:"排队驻留(queue-park)",desc:"门触发时入卡并驻留,agent 继续做别的事,等你回来处理。默认。"},{value:"auto-reject-5m",label:"5 分钟自动拒(auto-reject-5m)",desc:"旧行为:无人处理时 5 分钟后自动拒绝该调用。"},{value:"auto-approve",label:"自动通过(auto-approve)",desc:"无人处理时自动放行(仅硬危险命令仍被拒)。谨慎使用。"}],eiT=[{value:"high-only",label:"仅高危(high-only)"},{value:"risky+",label:"风险及以上(risky+)"},{value:"all",label:"全部(all)"}],eiR=[{value:"wake-singleton",label:"唤醒单例(wake-singleton)"},{value:"spawn-per-card",label:"每卡派生(spawn-per-card)"}];function eiD({onCreated:e,onCancel:t}){let{machines:n}=vd(),{models:r}=vH(),[a,i]=ew.useState("local"),{engines:o}=kb(a),l=ew.useCallback(e=>"vantaloom"===e||(o.find(t=>t.engine===e)?.available??!1),[o]),s=ew.useCallback(e=>o.find(t=>t.engine===e)?.reason,[o]),[c,d]=ew.useState(0),[u,f]=ew.useState("vantaloom"),[m,h]=ew.useState(""),[p,g]=ew.useState("acceptEdits"),[x,v]=ew.useState(["local"]),[b,y]=ew.useState(""),[w,j]=ew.useState(""),[k,N]=ew.useState([]),[S,C]=ew.useState(""),[M,E]=ew.useState([]),[I,P]=ew.useState(""),[O,z]=ew.useState(""),[A,T]=ew.useState("standard"),[R,D]=ew.useState("queue-park"),[_,L]=ew.useState(!1),[$,F]=ew.useState("risky+"),[B,V]=ew.useState(!1),[H,U]=ew.useState("wake-singleton"),[q,W]=ew.useState(!1),[K,G]=ew.useState(""),X=kt(u);ew.useEffect(()=>{"vantaloom"===u||l(u)||f("vantaloom")},[u,l]),ew.useEffect(()=>{X&&(v(e=>1===e.length&&"local"===e[0]?e:["local"]),N(e=>e.length<=1?e:e.slice(-1)))},[X]);let Y="local"===a?"本机":n.find(e=>e.id===a)?.name??a,Z=b.trim().length>0,J=ew.useCallback(async()=>{if(!q){if(!b.trim()){d(1),G("工程名称不能为空");return}W(!0),G("");try{let t={maxPeers:ei_(I,1,16),maxSpawnDepth:ei_(O,1,5),hitlStrictness:A,awayMode:R,dangerAgent:{enabled:_,severity:_?$:"",modelRef:""},reviewerAgent:{enabled:B,mode:B?H:"",modelRef:""}},n=await eiy({title:b.trim(),summary:w.trim()||void 0,ownerMachineId:a,settingsTemplate:{subagents:[],mainModels:X?[]:M,folders:k,blockedCommands:[],allowedTools:[],deniedTools:[],plugins:[],hosts:X?["local"]:x,permissionMode:p,engine:u,ccModel:X?m:void 0},policy:t,budgetTokens:ei_(S,0,Number.MAX_SAFE_INTEGER)});e(n.id)}catch(e){G(e instanceof Error?e.message:"工程创建失败")}finally{W(!1)}}},[R,S,m,q,_,$,u,k,A,x,X,M,I,O,e,a,p,B,H,w,b]),Q=c===eiI.length-1;return(0,eb.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col",children:[(0,eb.jsx)("header",{className:"shrink-0 px-6 pt-8 pb-6",children:(0,eb.jsx)("ol",{className:"mx-auto flex max-w-2xl items-center",children:eiI.map((e,t)=>{let n=t<c,r=t===c;return(0,eb.jsxs)("li",{className:"flex min-w-0 flex-1 items-center last:flex-none",children:[(0,eb.jsxs)("button",{type:"button","aria-current":r?"step":void 0,"aria-label":`第 ${t+1} 步:${e}`,onClick:()=>{t<=c&&d(t)},className:"group flex shrink-0 items-center gap-2 outline-none",children:[(0,eb.jsx)("span",{className:(0,ez.cn)("inline-flex size-8 shrink-0 items-center justify-center rounded-full border text-sm font-medium transition-colors",n?"border-primary bg-primary text-primary-foreground":r?"border-primary text-primary ring-2 ring-primary/30":"border-border bg-background text-muted-foreground"),children:n?(0,eb.jsx)(h6,{className:"size-4"}):t+1}),(0,eb.jsx)("span",{className:(0,ez.cn)("hidden truncate text-sm font-medium transition-colors sm:inline",r?"text-foreground":n?"text-foreground/80":"text-muted-foreground"),children:e})]}),t<eiI.length-1?(0,eb.jsx)("span",{"aria-hidden":"true",className:(0,ez.cn)("mx-3 h-px min-w-6 flex-1 transition-colors",t<c?"bg-primary":"bg-border")}):null]},e)})})}),(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-6",children:(0,eb.jsxs)("div",{className:"mx-auto w-full max-w-2xl",children:[0===c?(0,eb.jsxs)("div",{className:"grid gap-6",children:[(0,eb.jsx)(eiF,{value:a,onChange:i,machines:n}),(0,eb.jsxs)(ei$,{label:"运行引擎(engine)",children:[(0,eb.jsxs)(gU,{value:u,onValueChange:e=>f(e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{placeholder:"选择运行引擎"})}),(0,eb.jsx)(xS,{children:eiP.map(e=>{let t=l(e.value);return(0,eb.jsxs)(xC,{value:e.value,disabled:!t,children:[e.label,t?"":"(不可用)"]},e.value)})})]}),s(u)?(0,eb.jsx)("p",{className:"mt-1.5 text-xs text-muted-foreground",children:s(u)}):null,X?(0,eb.jsx)("p",{className:"mt-1.5 text-xs text-muted-foreground",children:"Claude Code(含 reclaude)运行在所选 owner 机器上;其工具锁定在该机本地。"}):null]}),X?(0,eb.jsxs)(ei$,{label:"Claude Code 模型(ccModel)",children:[(0,eb.jsxs)(gU,{value:""===m?j9:m,onValueChange:e=>h(e===j9?"":e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{placeholder:"选择 Claude Code 模型"})}),(0,eb.jsx)(xS,{children:ke.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]}),(0,eb.jsx)("p",{className:"mt-1.5 text-xs text-muted-foreground",children:"模型由 Claude Code 提供,不走 Vantaloom 模型路由。"})]}):null,(0,eb.jsxs)(ei$,{label:"权限模式(permissionMode)",hint:"新对话默认的工具调用门控强度。与下一步的 HITL 严格度独立设置。",children:[(0,eb.jsxs)(gU,{value:p,onValueChange:g,children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:eiO.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]}),(0,eb.jsx)("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:eiO.find(e=>e.value===p)?.desc})]}),(0,eb.jsx)(j7,{value:x,onValueChange:v,disabled:X,hint:X?"Claude Code 的工具锁定在所选 owner 机器本地,可访问主机已锁定。":void 0})]}):null,1===c?(0,eb.jsxs)("div",{className:"grid gap-6",children:[(0,eb.jsxs)(ei$,{label:"工程名称(必填)",children:[(0,eb.jsx)(eA,{value:b,placeholder:"新工程",onChange:e=>{y(e.currentTarget.value),K&&G("")}}),Z?null:(0,eb.jsx)("p",{className:"mt-1.5 text-xs text-amber-500",children:"工程名称不能为空。"})]}),(0,eb.jsx)(ei$,{label:"摘要(可选)",hint:"一句话描述这个工程的目标。",children:(0,eb.jsx)(w2,{value:w,onChange:e=>j(e.currentTarget.value),placeholder:"暂无工程摘要",rows:3})}),(0,eb.jsx)(j2,{title:"可访问的工作目录",value:k,onValueChange:e=>N(X?e.slice(-1):e)}),X?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"Claude Code 仅支持单个工作目录(作为会话的工作根目录)。"}):null,(0,eb.jsx)(ei$,{label:"预算上限(budgetTokens,可选)",hint:"工程累计 token 上限。留空 / 0 = 沿用全局默认(当前 5,000,000)。",children:(0,eb.jsx)(eA,{type:"number",min:0,step:1e5,value:S,onChange:e=>C(e.currentTarget.value),placeholder:"0 = 全局默认",className:"w-52"})})]}):null,2===c?X?(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsx)("span",{className:"text-base font-semibold tracking-normal text-foreground",children:"Claude Code 模型"}),(0,eb.jsxs)(gU,{value:""===m?j9:m,onValueChange:e=>h(e===j9?"":e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{placeholder:"选择 Claude Code 模型"})}),(0,eb.jsx)(xS,{children:ke.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"模型由 Claude Code 提供,不走 Vantaloom 模型路由。"})]}):(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsx)("span",{className:"text-base font-semibold tracking-normal text-foreground",children:"可用模型"}),(0,eb.jsxs)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:["选择本工程新建对话默认可用的模型(mainModels)。第一个为主模型。",(0,eb.jsxs)("span",{className:"text-amber-600 dark:text-amber-400",children:[" ","未选择任何模型时,工程内新建的对话将无模型可用、无法运行。"]})]})]}),(0,eb.jsx)(vU,{mainModels:M,onMainModelsChange:E})]}):null,3===c?(0,eb.jsxs)("div",{className:"grid gap-6",children:[(0,eb.jsx)(ei$,{label:"同伴并发上限(maxPeers,可选)",hint:`后台同时存在的同伴会话上限。留空 = 默认 8,范围 1–16。`,children:(0,eb.jsx)(eA,{type:"number",min:1,max:16,value:I,onChange:e=>P(e.currentTarget.value),placeholder:`默认 8`,className:"w-40"})}),(0,eb.jsx)(ei$,{label:"派生深度上限(maxSpawnDepth,可选)",hint:`同伴再派生同伴的最大层数。留空 = 默认 3,范围 1–5。`,children:(0,eb.jsx)(eA,{type:"number",min:1,max:5,value:O,onChange:e=>z(e.currentTarget.value),placeholder:`默认 3`,className:"w-40"})}),(0,eb.jsxs)(ei$,{label:"HITL 严格度(hitlStrictness)",children:[(0,eb.jsxs)(gU,{value:A,onValueChange:e=>T(e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:eiz.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]}),(0,eb.jsx)("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:eiz.find(e=>e.value===A)?.desc})]}),(0,eb.jsxs)(ei$,{label:"离开模式(awayMode)",hint:"无人值守时审批门的行为。",children:[(0,eb.jsxs)(gU,{value:R,onValueChange:e=>D(e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:eiA.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]}),(0,eb.jsx)("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:eiA.find(e=>e.value===R)?.desc})]}),(0,eb.jsxs)("div",{className:"rounded-lg border border-border bg-muted/30 p-3",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground [&_svg]:size-4 [&_svg]:text-amber-500",children:[(0,eb.jsx)(m0,{}),"危险反思智能体"]}),(0,eb.jsx)(bG,{checked:_,onCheckedChange:L})]}),(0,eb.jsxs)("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:["开启后,风险调用会先经一个模型「反思」判定(通过 / 拒绝 / 升级人工),再到人工审批门。",(0,eb.jsxs)("span",{className:"text-amber-600 dark:text-amber-400",children:[" ","会占用一个同伴槽位并消耗预算。"]})]}),_?(0,eb.jsx)("div",{className:"mt-3",children:(0,eb.jsx)(ei$,{label:"触发档位(severity)",children:(0,eb.jsxs)(gU,{value:$,onValueChange:e=>F(e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:eiT.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})})}):null]}),(0,eb.jsxs)("div",{className:"rounded-lg border border-border bg-muted/30 p-3",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground [&_svg]:size-4 [&_svg]:text-sky-teal",children:[(0,eb.jsx)(uH,{}),"评审智能体"]}),(0,eb.jsx)(bG,{checked:B,onCheckedChange:V})]}),(0,eb.jsxs)("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:["开启后,卡片进入「评审」状态会唤醒 / 派生一个评审智能体复核。",(0,eb.jsxs)("span",{className:"text-sky-700 dark:text-sky-400",children:[" ","会占用一个同伴槽位并消耗预算。"]})]}),B?(0,eb.jsx)("div",{className:"mt-3",children:(0,eb.jsx)(ei$,{label:"模式(mode)",hint:"单例唤醒省槽位;每卡派生会迅速消耗同伴槽位。",children:(0,eb.jsxs)(gU,{value:H,onValueChange:e=>U(e),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:eiR.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})})}):null]})]}):null,4===c?(0,eb.jsxs)("div",{className:"grid gap-4",children:[(0,eb.jsxs)("div",{className:"grid gap-3 rounded-xl border bg-card p-5",children:[(0,eb.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"配置摘要"}),(0,eb.jsxs)("div",{className:"grid gap-2.5",children:[(0,eb.jsx)(eiL,{icon:(0,eb.jsx)(h9,{}),label:"工程名称",value:b.trim()||"(未填写)"}),(0,eb.jsx)(eiL,{icon:(0,eb.jsx)(eP,{}),label:"运行环境",value:Y}),(0,eb.jsx)(eiL,{icon:(0,eb.jsx)(uK,{}),label:"运行引擎",value:eiP.find(e=>e.value===u)?.label??u}),(0,eb.jsx)(eiL,{icon:(0,eb.jsx)(h3,{}),label:"模型",value:X?kn(m):M.length>0?M.map(e=>r.find(t=>t.value===e)?.label??e).join("、"):"未选择(工程内新建对话将无模型可用)"}),(0,eb.jsx)(eiL,{icon:(0,eb.jsx)(eiE,{}),label:"权限 / HITL",value:`${eiO.find(e=>e.value===p)?.label??p} \xb7 ${eiz.find(e=>e.value===A)?.label??A}`}),(0,eb.jsx)(eiL,{icon:(0,eb.jsx)(enH,{}),label:"编排上限",value:`同伴 ${I.trim()||`默认8`} \xb7 深度 ${O.trim()||`默认3`}`}),(0,eb.jsx)(eiL,{icon:(0,eb.jsx)(Yv,{}),label:"预算上限",value:S.trim()&&Number(S.trim())>0?`${Number(S.trim()).toLocaleString("en-US")} tokens`:"全局默认"}),(0,eb.jsx)(eiL,{icon:(0,eb.jsx)(h9,{}),label:"工作目录",value:k.length>0?`${k.length} 个目录`:"未选择(可稍后在工程设置中配置)"}),(0,eb.jsx)(eiL,{icon:(0,eb.jsx)(uH,{}),label:"监督智能体",value:[_?"危险反思":null,B?"评审":null].filter(Boolean).join(" · ")||"未启用"})]})]}),K?(0,eb.jsx)("div",{className:"text-sm text-destructive",children:K}):null]}):null]})}),(0,eb.jsx)("footer",{className:"flex shrink-0 items-center justify-between px-6 pb-8",children:(0,eb.jsxs)("div",{className:"mx-auto flex w-full max-w-2xl items-center justify-between",children:[(0,eb.jsxs)(eO.Button,{type:"button",variant:"ghost",disabled:q,onClick:()=>{0===c?t?.():d(e=>Math.max(0,e-1))},children:[(0,eb.jsx)(h8,{className:"size-4"}),0===c?"取消":"上一步"]}),Q?(0,eb.jsxs)(eO.Button,{type:"button",disabled:q||!Z,onClick:()=>void J(),children:[(0,eb.jsx)(pe,{className:"size-4"}),q?"创建中…":"创建"]}):(0,eb.jsxs)(eO.Button,{type:"button",disabled:1===c&&!Z,onClick:()=>d(e=>Math.min(eiI.length-1,e+1)),children:["下一步",(0,eb.jsx)(h7,{className:"size-4"})]})]})})]})}function ei_(e,t,n){let r=e.trim();if(""===r)return 0;let a=Math.floor(Number(r));return!Number.isFinite(a)||a<=0?0:Math.min(n,Math.max(t,a))}function eiL({icon:e,label:t,value:n}){return(0,eb.jsxs)("div",{className:"grid grid-cols-[auto_5rem_minmax(0,1fr)] items-center gap-3",children:[(0,eb.jsx)("span",{className:"inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground [&_svg]:size-4",children:e}),(0,eb.jsx)("span",{className:"text-sm text-muted-foreground",children:t}),(0,eb.jsx)("span",{className:"min-w-0 truncate text-sm font-medium text-foreground",children:n})]})}function ei$({label:e,hint:t,children:n}){return(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)("span",{className:"text-sm font-medium text-foreground",children:e}),n,t?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground/80",children:t}):null]})}function eiF({value:e,onChange:t,machines:n}){let r=ew.useMemo(()=>{let e=[],t=!1;for(let r of n)if(r.isLocal)t=!0,e.unshift({id:"local",name:"本机",online:!0,reachable:!0});else{let t="online"===r.status;e.push({id:r.id,name:r.name,online:t,reachable:r.reachable??t})}return t||e.unshift({id:"local",name:"本机",online:!0,reachable:!0}),e},[n]);return(0,eb.jsx)(ei$,{label:"工程运行位置",hint:"选择该工程的运行时实际运行在工作组里的哪台机器(默认本机)。",children:(0,eb.jsxs)(gU,{value:e,onValueChange:t,children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{placeholder:"选择运行位置"})}),(0,eb.jsx)(xS,{children:r.map(e=>{let t=e.reachable?"":e.online?"(在线·不可达)":"(离线)";return(0,eb.jsxs)(xC,{value:e.id,disabled:!e.reachable,children:[e.name,t]},e.id)})})]})})}let eiB=[{value:"off",label:"关闭(off)",desc:"auto 模式,不门控任何工具调用(仅硬危险命令仍被直接拒绝)。"},{value:"loose",label:"宽松(loose)",desc:"auto 模式 + 危险反思仅对高危调用介入。"},{value:"standard",label:"标准(standard)",desc:"acceptEdits 模式 + 危险反思对「风险及以上」介入。默认。"},{value:"strict",label:"严格(strict)",desc:"ask 模式 + 危险反思对全部工具调用介入。"},{value:"paranoid",label:"偏执(paranoid)",desc:"ask 模式 + 危险反思全覆盖,且发布类命令(publish/deploy/update)强制上卡。"}],eiV=[{value:"queue-park",label:"排队驻留(queue-park)",desc:"门触发时入卡并驻留,agent 继续做别的事,等你回来处理。默认。"},{value:"auto-reject-5m",label:"5 分钟自动拒(auto-reject-5m)",desc:"旧行为:无人处理时 5 分钟后自动拒绝该调用。"},{value:"auto-approve",label:"自动通过(auto-approve)",desc:"无人处理时自动放行(仅硬危险命令仍被拒)。谨慎使用。"}],eiH=[{value:"high-only",label:"仅高危(high-only)"},{value:"risky+",label:"风险及以上(risky+)"},{value:"all",label:"全部(all)"}],eiU=[{value:"wake-singleton",label:"唤醒单例(wake-singleton)"},{value:"spawn-per-card",label:"每卡派生(spawn-per-card)"}],eiq=[{value:"vantaloom",label:"Vantaloom(原生)"},{value:"claude-code",label:"Claude Code"},{value:"reclaude",label:"reclaude"}],eiW=[{value:"auto",label:"自动(auto)",desc:"不门控,自动放行所有工具调用。"},{value:"acceptEdits",label:"接受编辑(acceptEdits)",desc:"编辑自动放行,命令等高风险调用需审批。"},{value:"ask",label:"逐项审批(ask)",desc:"所有非内联工具调用都需审批。"}],eiK=[{value:"basic",label:"基本",icon:(0,eb.jsx)(era,{})},{value:"models",label:"模型",icon:(0,eb.jsx)(h3,{})},{value:"tools",label:"工具权限",icon:(0,eb.jsx)(enW,{})},{value:"commands",label:"禁止命令",icon:(0,eb.jsx)(u0,{})},{value:"folders",label:"工作区文件夹",icon:(0,eb.jsx)(b3,{})},{value:"hosts",label:"可访问主机",icon:(0,eb.jsx)(Yw,{})},{value:"engine",label:"引擎",icon:(0,eb.jsx)(enW,{})},{value:"assets",label:"扩展",icon:(0,eb.jsx)(kV,{})},{value:"orchestration",label:"编排与预算",icon:(0,eb.jsx)(enH,{})},{value:"hitl",label:"HITL 风控",icon:(0,eb.jsx)(eiE,{})}];function eiG({projectId:e,onClose:t}){let[n,r]=ew.useState(),[a,i]=ew.useState(!0),[o,l]=ew.useState(),[s,c]=ew.useState(null),[d,u]=ew.useState(!1),[f,m]=ew.useState(),[h,p]=ew.useState(),[g,x]=ew.useState("basic"),{models:v,loading:b}=vH(),y=ew.useCallback(async()=>{i(!0),l(void 0);try{let t=await eib(e);r(t),c(eiY(t))}catch(e){l(e instanceof Error?e.message:"工程加载失败")}finally{i(!1)}},[e]);ew.useEffect(()=>{y()},[y]);let w=ew.useMemo(()=>{var e,t;let r;return!!n&&!!s&&(e=s,t=eiY(n),r=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),!(e.title===t.title&&e.summary===t.summary&&e.maxPeers===t.maxPeers&&e.maxSpawnDepth===t.maxSpawnDepth&&e.budgetTokens===t.budgetTokens&&e.budgetSoftPct===t.budgetSoftPct&&e.budgetHardPct===t.budgetHardPct&&e.approvalParkTtlSeconds===t.approvalParkTtlSeconds&&e.hitlStrictness===t.hitlStrictness&&e.awayMode===t.awayMode&&e.dangerEnabled===t.dangerEnabled&&e.dangerSeverity===t.dangerSeverity&&e.dangerModelRef===t.dangerModelRef&&e.reviewerEnabled===t.reviewerEnabled&&e.reviewerMode===t.reviewerMode&&e.reviewerModelRef===t.reviewerModelRef&&e.engine===t.engine&&e.permissionMode===t.permissionMode&&e.ccModel===t.ccModel&&r(e.allowedTools,t.allowedTools)&&r(e.blockedCommands,t.blockedCommands)&&r(e.mainModels,t.mainModels)&&r(e.folders,t.folders)&&r(e.hosts,t.hosts)))},[n,s]),j=s?eiJ(s):void 0;async function k(){if(!s||!n)return;let t=eiJ(s);if(t)return void m(t);u(!0),m(void 0);try{var a;let t,n,i,o=await eiw(e,(a=s,t={maxPeers:eiZ(a.maxPeers,1,16),maxSpawnDepth:eiZ(a.maxSpawnDepth,1,5),budgetSoftPct:eiZ(a.budgetSoftPct,1,100),budgetHardPct:eiZ(a.budgetHardPct,1,200),approvalParkTtlSeconds:Math.max(0,Math.floor(Number(a.approvalParkTtlSeconds.trim()||"0"))||0),hitlStrictness:a.hitlStrictness||"",awayMode:a.awayMode||"",dangerAgent:{enabled:a.dangerEnabled,severity:a.dangerSeverity||"",modelRef:a.dangerModelRef.trim()},reviewerAgent:{enabled:a.reviewerEnabled,mode:a.reviewerMode||"",modelRef:a.reviewerModelRef.trim()}},n=kt(a.engine),i={...a.baseSettings,blockedCommands:a.blockedCommands,allowedTools:a.allowedTools,permissionMode:a.permissionMode,engine:a.engine,mainModels:n?[]:a.mainModels,ccModel:n?a.ccModel:void 0,folders:n?a.folders.slice(-1):a.folders,hosts:a.hosts},{title:a.title.trim(),summary:a.summary.trim(),budgetTokens:eiZ(a.budgetTokens,0,Number.MAX_SAFE_INTEGER),policy:t,settingsTemplate:i}));r(o),c(eiY(o)),p(Date.now())}catch(e){m(e instanceof Error?e.message:"保存失败")}finally{u(!1)}}function N(e){c(t=>t?{...t,...e}:t),p(void 0)}if(a&&!s)return(0,eb.jsx)("div",{className:"vtl-app-background flex h-full w-full items-center justify-center text-muted-foreground",children:(0,eb.jsx)(eM,{className:"size-6 animate-spin"})});if(o&&!s)return(0,eb.jsxs)("div",{className:"vtl-app-background flex h-full w-full flex-col items-center justify-center gap-3 px-6 py-16 text-center",children:[(0,eb.jsx)(m0,{className:"size-8 text-hot-pink"}),(0,eb.jsx)("p",{className:"text-sm text-muted-foreground",children:o}),(0,eb.jsx)(eO.Button,{type:"button",variant:"outline",onClick:()=>void y(),children:"重试"})]});if(!s)return null;let S={basic:(0,eb.jsx)("div",{className:"flex w-full flex-col gap-6",children:(0,eb.jsxs)(eiQ,{icon:(0,eb.jsx)(era,{className:"size-4"}),title:"基本",desc:"工程名称与摘要。",children:[(0,eb.jsx)(ei0,{label:"名称",children:(0,eb.jsx)(eA,{value:s.title,onChange:e=>N({title:e.target.value}),placeholder:"工程名称"})}),(0,eb.jsx)(ei0,{label:"摘要",hint:"一句话描述这个工程的目标(可选)。",children:(0,eb.jsx)(w2,{value:s.summary,onChange:e=>N({summary:e.target.value}),placeholder:"暂无工程摘要",rows:3})})]})}),models:(0,eb.jsx)("div",{className:"flex w-full flex-col gap-6",children:(0,eb.jsxs)(eiQ,{icon:(0,eb.jsx)(h3,{className:"size-4"}),title:"模型",desc:"本工程新建对话默认可用的模型(mainModels)。与对话设置使用同一选择器。",children:[(0,eb.jsxs)("div",{className:"flex items-start gap-2 rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs leading-relaxed text-amber-700 dark:text-amber-300 [&_svg]:mt-0.5 [&_svg]:size-4 [&_svg]:shrink-0",children:[(0,eb.jsx)(m0,{}),(0,eb.jsxs)("span",{children:[(0,eb.jsx)("strong",{children:"关键:"}),"未选择任何模型时,本工程内新建的对话将无模型可用、无法运行。请至少选择一个模型。"]})]}),kt(s.engine)?(0,eb.jsx)(ei0,{label:"Claude Code 模型(ccModel)",hint:"当前引擎为 Claude Code,模型由其提供,不走 Vantaloom 模型路由。",icon:(0,eb.jsx)(h3,{className:"size-4"}),children:(0,eb.jsxs)(gU,{value:""===s.ccModel?j9:s.ccModel,onValueChange:e=>N({ccModel:e===j9?"":e}),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{placeholder:"选择 Claude Code 模型"})}),(0,eb.jsx)(xS,{children:ke.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})}):(0,eb.jsx)(vU,{mainModels:s.mainModels,onMainModelsChange:e=>N({mainModels:e})})]})}),tools:(0,eb.jsx)("div",{className:"flex w-full flex-col gap-4",children:(0,eb.jsx)(j0,{value:s.allowedTools,onChange:e=>N({allowedTools:e})})}),commands:(0,eb.jsx)("div",{className:"flex w-full flex-col gap-4",children:(0,eb.jsx)(j1,{value:s.blockedCommands,onChange:e=>N({blockedCommands:e})})}),folders:(0,eb.jsxs)("div",{className:"flex w-full flex-col gap-3",children:[0===s.folders.length?(0,eb.jsxs)("div",{className:"flex items-start gap-2 rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs leading-relaxed text-amber-700 dark:text-amber-300 [&_svg]:mt-0.5 [&_svg]:size-4 [&_svg]:shrink-0",children:[(0,eb.jsx)(m0,{}),(0,eb.jsxs)("span",{children:[(0,eb.jsx)("strong",{children:"关键:"}),"未配置工作区文件夹时,本工程内新建的对话",(0,eb.jsx)("strong",{children:"没有任何工作目录"}),",智能体将无处读写文件。请至少添加一个文件夹。"]})]}):null,(0,eb.jsx)(j2,{title:"可访问的工作区文件夹",value:s.folders,onValueChange:e=>N({folders:kt(s.engine)?e.slice(-1):e})}),kt(s.engine)?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"Claude Code 仅支持单个工作目录(作为会话的工作根目录)。"}):null]}),hosts:(0,eb.jsx)("div",{className:"flex w-full flex-col gap-4",children:(0,eb.jsx)(j7,{value:s.hosts,onValueChange:e=>N({hosts:e}),disabled:kt(s.engine),hint:kt(s.engine)?"Claude Code 的工具锁定在所选 owner 机器本地,可访问主机已锁定。":void 0})}),engine:(0,eb.jsx)("div",{className:"flex w-full flex-col gap-6",children:(0,eb.jsxs)(eiQ,{icon:(0,eb.jsx)(enW,{className:"size-4"}),title:"引擎",desc:"新对话的默认引擎与权限模式。",children:[(0,eb.jsx)(ei0,{label:"引擎(engine)",children:(0,eb.jsxs)(gU,{value:s.engine,onValueChange:e=>N({engine:e}),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:eiq.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})}),(0,eb.jsxs)(ei0,{label:"权限模式(permissionMode)",children:[(0,eb.jsxs)(gU,{value:s.permissionMode,onValueChange:e=>N({permissionMode:e}),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:eiW.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]}),(0,eb.jsx)("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:eiW.find(e=>e.value===s.permissionMode)?.desc})]})]})}),orchestration:(0,eb.jsxs)("div",{className:"flex w-full flex-col gap-6",children:[(0,eb.jsxs)(eiQ,{icon:(0,eb.jsx)(enH,{className:"size-4"}),title:"编排上限",desc:"限制同伴并发数与派生深度,避免后台 peer 失控扩散。0 / 留空 = 全局默认。",children:[(0,eb.jsx)(ei0,{label:"同伴并发上限(maxPeers)",hint:`后台同时存在的同伴会话上限。默认 8,范围 1–16。`,children:(0,eb.jsx)(eA,{type:"number",min:1,max:16,value:s.maxPeers,onChange:e=>N({maxPeers:e.target.value}),placeholder:`默认 8`,className:"w-40"})}),(0,eb.jsx)(ei0,{label:"派生深度上限(maxSpawnDepth)",hint:`同伴再派生同伴的最大层数。默认 3,范围 1–5。`,children:(0,eb.jsx)(eA,{type:"number",min:1,max:5,value:s.maxSpawnDepth,onChange:e=>N({maxSpawnDepth:e.target.value}),placeholder:`默认 3`,className:"w-40"})})]}),(0,eb.jsxs)(eiQ,{icon:(0,eb.jsx)(Yv,{className:"size-4"}),title:"预算",desc:"工程级 token 预算上限与软 / 硬阈值。与概览页的预算条共用同一更新逻辑——0 = 全局默认。",children:[(0,eb.jsx)(ei0,{label:"预算上限(budgetTokens)",hint:"工程累计 token 上限。0 = 恢复全局默认(当前 5,000,000)。",children:(0,eb.jsx)(eA,{type:"number",min:0,step:1e5,value:s.budgetTokens,onChange:e=>N({budgetTokens:e.target.value}),placeholder:"0 = 全局默认",className:"w-52"})}),(0,eb.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,eb.jsx)(ei0,{label:"软阈值 %(budgetSoftPct)",hint:`接近上限时提示。默认 80%。0 = 默认。`,children:(0,eb.jsx)(eA,{type:"number",min:0,max:100,value:s.budgetSoftPct,onChange:e=>N({budgetSoftPct:e.target.value}),placeholder:`默认 80`,className:"w-32"})}),(0,eb.jsx)(ei0,{label:"硬阈值 %(budgetHardPct)",hint:`达到后阻止新增 peer。默认 100%。0 = 默认。`,children:(0,eb.jsx)(eA,{type:"number",min:0,max:200,value:s.budgetHardPct,onChange:e=>N({budgetHardPct:e.target.value}),placeholder:`默认 100`,className:"w-32"})})]})]})]}),hitl:(0,eb.jsx)("div",{className:"flex w-full flex-col gap-6",children:(0,eb.jsxs)(eiQ,{icon:(0,eb.jsx)(eiE,{className:"size-4"}),title:"HITL 风控",desc:"人类在环(Human-in-the-loop)的严格度、离开模式与监督智能体。",children:[(0,eb.jsxs)(ei0,{label:"严格度(hitlStrictness)",children:[(0,eb.jsxs)(gU,{value:s.hitlStrictness||"standard",onValueChange:e=>N({hitlStrictness:e}),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:eiB.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]}),(0,eb.jsx)("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:eiB.find(e=>e.value===(s.hitlStrictness||"standard"))?.desc})]}),(0,eb.jsxs)(ei0,{label:"离开模式(awayMode)",hint:"无人值守时审批门的行为。",children:[(0,eb.jsxs)(gU,{value:s.awayMode||"queue-park",onValueChange:e=>N({awayMode:e}),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:eiV.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]}),(0,eb.jsx)("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:eiV.find(e=>e.value===(s.awayMode||"queue-park"))?.desc})]}),(0,eb.jsx)(ei0,{label:"驻留 TTL(秒,approvalParkTtlSeconds)",hint:"排队驻留下审批卡的存活秒数。0 = 无限驻留(直到你处理)。",children:(0,eb.jsx)(eA,{type:"number",min:0,value:s.approvalParkTtlSeconds,onChange:e=>N({approvalParkTtlSeconds:e.target.value}),placeholder:"0 = 无限驻留",className:"w-40"})}),(0,eb.jsxs)("div",{className:"rounded-lg border border-border bg-muted/30 p-3",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground [&_svg]:size-4 [&_svg]:text-amber-500",children:[(0,eb.jsx)(m0,{}),"危险反思智能体"]}),(0,eb.jsx)(bG,{checked:s.dangerEnabled,onCheckedChange:e=>N({dangerEnabled:e})})]}),(0,eb.jsxs)("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:["开启后,风险调用会先经一个模型「反思」判定(通过 / 拒绝 / 升级人工),再到人工审批门。",(0,eb.jsxs)("span",{className:"text-amber-600 dark:text-amber-400",children:[" ","会占用一个同伴槽位并消耗预算。"]})]}),s.dangerEnabled?(0,eb.jsxs)("div",{className:"mt-3 grid gap-3",children:[(0,eb.jsx)(ei0,{label:"触发档位(severity)",children:(0,eb.jsxs)(gU,{value:s.dangerSeverity||"risky+",onValueChange:e=>N({dangerSeverity:e}),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:eiH.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})}),(0,eb.jsx)(ei0,{label:"模型(modelRef,可选)",hint:"留空使用工程 / 全局默认模型。",children:(0,eb.jsx)(Ye,{mode:"single",models:v,loading:b,value:s.dangerModelRef,onChange:e=>N({dangerModelRef:e}),clearLabel:"默认(自动选择)",emptyHint:"尚未配置可用模型。请先在「模型路由」中配置渠道与模型。"})})]}):null]}),(0,eb.jsxs)("div",{className:"rounded-lg border border-border bg-muted/30 p-3",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground [&_svg]:size-4 [&_svg]:text-sky-teal",children:[(0,eb.jsx)(uH,{}),"评审智能体"]}),(0,eb.jsx)(bG,{checked:s.reviewerEnabled,onCheckedChange:e=>N({reviewerEnabled:e})})]}),(0,eb.jsxs)("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:["开启后,卡片进入「评审」状态会唤醒 / 派生一个评审智能体复核。",(0,eb.jsxs)("span",{className:"text-sky-700 dark:text-sky-400",children:[" ","会占用一个同伴槽位并消耗预算。"]})]}),s.reviewerEnabled?(0,eb.jsxs)("div",{className:"mt-3 grid gap-3",children:[(0,eb.jsx)(ei0,{label:"模式(mode)",hint:"单例唤醒省槽位;每卡派生会迅速消耗同伴槽位。",children:(0,eb.jsxs)(gU,{value:s.reviewerMode||"wake-singleton",onValueChange:e=>N({reviewerMode:e}),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:eiU.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})}),(0,eb.jsx)(ei0,{label:"模型(modelRef,可选)",hint:"留空使用工程 / 全局默认模型。",children:(0,eb.jsx)(Ye,{mode:"single",models:v,loading:b,value:s.reviewerModelRef,onChange:e=>N({reviewerModelRef:e}),clearLabel:"默认(自动选择)",emptyHint:"尚未配置可用模型。请先在「模型路由」中配置渠道与模型。"})})]}):null]})]})})},C=eiK.map(t=>"assets"===t.value?{id:t.value,title:t.label,icon:t.icon,children:enS("project",{projectId:e,workspaceFolder:s.folders[0]})}:{id:t.value,title:t.label,icon:t.icon,content:S[t.value]});return(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex items-center gap-2 border-b px-3 py-2.5",children:[(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon","aria-label":"关闭设置",onClick:()=>t?.(),className:"shrink-0",children:(0,eb.jsx)(fV.XIcon,{className:"size-5"})}),(0,eb.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(era,{}),"工程设置"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:n?.title??"工程"})]})]}),(0,eb.jsx)(etm,{sections:C,sectionId:g,onSelectionChange:({sectionId:e})=>x(e),defaultSectionId:"basic",labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto pb-28"}),(0,eb.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-10 flex justify-center px-6 pb-4",children:(0,eb.jsxs)("div",{className:(0,ez.cn)("pointer-events-auto flex items-center gap-3 rounded-full border border-border bg-card/95 px-4 py-2 shadow-lg backdrop-blur transition-opacity",w||f||h?"opacity-100":"pointer-events-none opacity-0"),children:[f?(0,eb.jsx)("span",{className:"text-xs text-hot-pink",children:f}):j?(0,eb.jsx)("span",{className:"text-xs text-amber-500",children:j}):w?(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:"有未保存的更改"}):h?(0,eb.jsxs)("span",{className:"flex items-center gap-1 text-xs text-emerald-600 dark:text-emerald-400 [&_svg]:size-3.5",children:[(0,eb.jsx)(h6,{}),"已保存"]}):null,w?(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"sm",disabled:d,onClick:()=>n&&c(eiY(n)),children:"撤销"}):null,(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",disabled:!w||d||!!j,onClick:()=>void k(),children:[d?(0,eb.jsx)(eM,{className:"size-4 animate-spin"}):(0,eb.jsx)(h6,{className:"size-4"}),"保存"]})]})})]})}function eiX(e){return e&&e>0?String(e):""}function eiY(e){let t=e.policy??{},n=t.dangerAgent??{},r=t.reviewerAgent??{},a=e.settingsTemplate;return{title:e.title??"",summary:e.summary??"",maxPeers:eiX(t.maxPeers),maxSpawnDepth:eiX(t.maxSpawnDepth),budgetTokens:eiX(e.budgetTokens),budgetSoftPct:eiX(t.budgetSoftPct),budgetHardPct:eiX(t.budgetHardPct),approvalParkTtlSeconds:eiX(t.approvalParkTtlSeconds),hitlStrictness:t.hitlStrictness??"",awayMode:t.awayMode??"",dangerEnabled:n.enabled??!1,dangerSeverity:n.severity??"",dangerModelRef:n.modelRef??"",reviewerEnabled:r.enabled??!1,reviewerMode:r.mode??"",reviewerModelRef:r.modelRef??"",engine:a.engine??"vantaloom",permissionMode:a.permissionMode??"acceptEdits",allowedTools:a.allowedTools??[],blockedCommands:a.blockedCommands??[],mainModels:a.mainModels??[],ccModel:a.ccModel??"",folders:a.folders??[],hosts:a.hosts??[],baseSettings:a}}function eiZ(e,t,n){let r=e.trim();if(""===r)return 0;let a=Math.floor(Number(r));return!Number.isFinite(a)||a<=0?0:Math.min(n,Math.max(t,a))}function eiJ(e){if(!e.title.trim())return"工程名称不能为空";for(let[t,n]of[[e.maxPeers,"同伴并发上限"],[e.maxSpawnDepth,"派生深度上限"],[e.budgetTokens,"预算上限"],[e.budgetSoftPct,"软阈值"],[e.budgetHardPct,"硬阈值"],[e.approvalParkTtlSeconds,"驻留 TTL"]]){let e=t.trim();if(""===e)continue;let r=Number(e);if(!Number.isFinite(r)||r<0)return`${n}需为 ≥ 0 的整数`}}function eiQ({icon:e,title:t,desc:n,children:r}){return(0,eb.jsxs)("section",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-5 shadow-sm",children:[(0,eb.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-foreground [&_svg]:text-muted-foreground",children:[e,(0,eb.jsx)("h2",{className:"text-base font-semibold",children:t})]}),n?(0,eb.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:n}):null]}),(0,eb.jsx)("div",{className:"flex flex-col gap-4",children:r})]})}function ei0({label:e,hint:t,icon:n,children:r}){return(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsxs)("span",{className:"flex items-center gap-1.5 text-sm font-medium text-foreground [&_svg]:text-muted-foreground",children:[n,e]}),r,t?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground/80",children:t}):null]})}let ei1=(0,ek.default)("kanban",[["path",{d:"M5 3v14",key:"9nsxs2"}],["path",{d:"M12 3v8",key:"1h2ygw"}],["path",{d:"M19 3v18",key:"1sk56x"}]]);function ei2({className:e,size:t="default",...n}){return(0,eb.jsxs)("div",{className:"group/native-select relative w-fit has-[select:disabled]:opacity-50","data-slot":"native-select-wrapper",children:[(0,eb.jsx)("select",{"data-slot":"native-select","data-size":t,className:(0,ez.cn)("h-8 w-full min-w-0 appearance-none rounded-lg border border-input bg-background px-2.5 py-1.5 pr-8 ui-text-control shadow-xs outline-none transition-[color,box-shadow] selection:bg-primary selection:text-primary-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[size=sm]:h-7 data-[size=sm]:py-1 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40",e),...n}),(0,eb.jsx)(pt,{className:"pointer-events-none absolute right-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground opacity-60","aria-hidden":"true","data-slot":"native-select-icon"})]})}function ei5({className:e,...t}){return(0,eb.jsx)("option",{"data-slot":"native-select-option",className:(0,ez.cn)("bg-[Canvas] text-[CanvasText]",e),...t})}function ei4(){return{kind:"human",id:"local",displayName:"我"}}async function ei3(e,t){let n=t?`?status=${encodeURIComponent(t)}`:"";return(await eou(`/api/local/projects/${encodeURIComponent(e)}/issues${n}`)).issues??[]}async function ei6(e){return eou(`/api/local/issues/${encodeURIComponent(e)}`)}async function ei8(e,t){return eou(`/api/local/projects/${encodeURIComponent(e)}/issues`,{method:"POST",body:JSON.stringify(t)})}async function ei7(e,t){return eou(`/api/local/issues/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}async function ei9(e){await eou(`/api/local/issues/${encodeURIComponent(e)}`,{method:"DELETE"})}async function eoe(e,t){return eou(`/api/local/issues/${encodeURIComponent(e)}/claim`,{method:"POST",body:JSON.stringify({assignee:t})})}async function eot(e,t,n=ei4()){return eou(`/api/local/issues/${encodeURIComponent(e)}/comments`,{method:"POST",body:JSON.stringify({actor:n,body:t})})}async function eon(e){return(await eou(`/api/local/issues/${encodeURIComponent(e)}/events`)).events??[]}async function eor(e){return(await eou(`/api/local/projects/${encodeURIComponent(e)}/links`)).links??[]}async function eoa(e,t,n,r){return eou(`/api/local/projects/${encodeURIComponent(e)}/links`,{method:"POST",body:JSON.stringify({fromIssueId:t,toIssueId:n,kind:r})})}async function eoi(e){await eou(`/api/local/links/${encodeURIComponent(e)}`,{method:"DELETE"})}let eoo=new Map,eol=new Map;async function eos(e){let t=Date.now(),n=eoo.get(e);if(n&&t-n.at<2500)return n.value;let r=eol.get(e);if(r)return r;let a=(async()=>{try{let t=(await eou(`/api/local/projects/${encodeURIComponent(e)}/approvals`)).approvals??[];return eoo.set(e,{value:t,at:Date.now()}),t}finally{eol.delete(e)}})();return eol.set(e,a),a}async function eoc(e,t,n,r){await eou(`/api/local/agent/conversations/${encodeURIComponent(e)}/approvals/${encodeURIComponent(t)}`,{method:"POST",body:JSON.stringify(null!=r&&""!==r?{decision:n,feedback:r}:{decision:n})})}class eod extends Error{status;constructor(e,t){super(e),this.name="KanbanAPIError",this.status=t}}async function eou(e,t){let n=await fetch((0,eT.localAPIURL)(e),{cache:"no-store",...t,headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok)throw new eod("string"==typeof r?.error?r.error:"kanban api failed",n.status);return r}let eof=[{status:"backlog",label:"待办池",dot:"bg-ash-gray",chip:"bg-muted text-muted-foreground"},{status:"todo",label:"待领取",dot:"bg-sky-teal",chip:"bg-sky-teal/15 text-sky-teal"},{status:"in_progress",label:"进行中",dot:"bg-vivid-violet",chip:"bg-vivid-violet/15 text-vivid-violet"},{status:"blocked",label:"受阻",dot:"bg-hot-pink",chip:"bg-hot-pink/15 text-hot-pink"},{status:"review",label:"待审核",dot:"bg-amber-500",chip:"bg-amber-500/15 text-amber-600 dark:text-amber-400"},{status:"done",label:"已完成",dot:"bg-emerald-500",chip:"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400"}],eom={status:"cancelled",label:"已取消",dot:"bg-ash-gray",chip:"bg-muted text-muted-foreground"},eoh=[...eof,eom],eop={bug:"缺陷",feature:"功能",task:"任务",chore:"杂务",question:"疑问"},eog=["task","feature","bug","chore","question"],eox={bug:"bg-hot-pink/15 text-hot-pink",feature:"bg-sky-teal/15 text-sky-teal",task:"bg-vivid-violet/15 text-vivid-violet",chore:"bg-muted text-muted-foreground",question:"bg-amber-500/15 text-amber-600 dark:text-amber-400"},eov={low:"低",normal:"普通",high:"高",urgent:"紧急"},eob=["low","normal","high","urgent"],eoy={low:"bg-muted text-muted-foreground",normal:"bg-muted text-muted-foreground",high:"bg-amber-500/15 text-amber-600 dark:text-amber-400",urgent:"bg-hot-pink/15 text-hot-pink"},eow={depends_on:"依赖",blocks:"阻塞",parent:"父级",relates_to:"关联"},eoj=["depends_on","blocks","parent","relates_to"],eok={depends_on:{stroke:"#f59e0b",chip:"bg-amber-500/15 text-amber-600 dark:text-amber-400"},blocks:{stroke:"#ec4899",chip:"bg-hot-pink/15 text-hot-pink"},parent:{stroke:"#8b5cf6",chip:"bg-vivid-violet/15 text-vivid-violet"},relates_to:{stroke:"#14b8a6",chip:"bg-sky-teal/15 text-sky-teal"}},eoN={created:"创建",comment:"评论",status_change:"状态变更",claim:"认领",progress:"进度",schedule:"排期"};function eoS(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}let eoC={safe:"安全",normal:"普通",risky:"有风险",dangerous:"危险"},eoM={safe:"bg-sky-teal/15 text-sky-teal",normal:"bg-muted text-muted-foreground",risky:"bg-amber-500/15 text-amber-600 dark:text-amber-400",dangerous:"bg-hot-pink/15 text-hot-pink"},eoE=(0,ek.default)("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]),eoI=(0,ek.default)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);function eoP({issueId:e,projectId:t,open:n,onClose:r,onChange:a,onDeleted:i}){let[o,l]=ew.useState(null),[s,c]=ew.useState([]),[d,u]=ew.useState([]),[f,m]=ew.useState([]),[h,p]=ew.useState(!1),[g,x]=ew.useState(!1),[v,b]=ew.useState(""),[y,w]=ew.useState(""),j=sv(),k=ew.useCallback(async()=>{if(e){p(!0);try{let[n,r,a,i]=await Promise.all([ei6(e),eon(e).catch(()=>[]),eor(t).catch(()=>[]),ei3(t).catch(()=>[])]);l(n),c(r),u(a),m(i)}catch(e){hn.error(e instanceof Error?e.message:"加载 issue 失败")}finally{p(!1)}}},[e,t]);ew.useEffect(()=>{n&&e&&k(),n||(l(null),c([]),u([]),m([]),b(""),w(""))},[n,e,k]);let N=ew.useCallback(async()=>{u(await eor(t).catch(()=>d)),o&&a?.(o)},[t,d,o,a]);async function S(e,n){if(o){x(!0);try{await eoa(t,o.id,e,n),await N()}catch(e){hn.error(e instanceof Error?e.message:"添加关联失败")}finally{x(!1)}}}async function C(e){x(!0);try{await eoi(e),await N()}catch(e){hn.error(e instanceof Error?e.message:"删除关联失败")}finally{x(!1)}}let M=ew.useCallback(async e=>{if(o){x(!0);try{let t=await ei7(o.id,e);l(t),a?.(t);let n=await eon(o.id).catch(()=>s);c(n)}catch(e){hn.error(e instanceof Error?e.message:"更新失败")}finally{x(!1)}}},[o,a,s]);async function E(){if(o){x(!0);try{let e=await eoe(o.id,ei4());l(e),a?.(e);let t=await eon(o.id).catch(()=>s);c(t),hn.success("认领成功")}catch(e){e instanceof eod&&409===e.status?(hn.error("认领失败:该 issue 已被他人认领"),k()):hn.error(e instanceof Error?e.message:"认领失败")}finally{x(!1)}}}async function I(){if(o&&v.trim()){x(!0);try{await eot(o.id,v.trim()),b("");let e=await eon(o.id).catch(()=>s);c(e),a?.(o)}catch(e){hn.error(e instanceof Error?e.message:"评论失败")}finally{x(!1)}}}async function P(){if(o&&window.confirm(`确定删除 #${o.number} ${o.title}?`)){x(!0);try{await ei9(o.id),i?.(o.id),r()}catch(e){hn.error(e instanceof Error?e.message:"删除失败")}finally{x(!1)}}}let O=o?.progress??{percent:0,checklist:[]};function z(e){return 0===e.length?O.percent:Math.round(e.filter(e=>e.done).length/e.length*100)}async function A(e){let t=O.checklist.map((t,n)=>n===e?{...t,done:!t.done}:t);await M({progress:{percent:z(t),checklist:t}})}async function T(e){let t=e.trim();if(!t)return;let n=[...O.checklist,{text:t,done:!1}];await M({progress:{percent:z(n),checklist:n}})}async function R(e){let t=O.checklist.filter((t,n)=>n!==e);await M({progress:{percent:z(t),checklist:t}})}let D=ew.useMemo(()=>{if(!o)return[];let e=new Map(f.map(e=>[e.id,e]));return d.filter(e=>e.fromIssueId===o.id||e.toIssueId===o.id).map(t=>{let n=t.fromIssueId===o.id,r=n?t.toIssueId:t.fromIssueId;return{link:t,outgoing:n,other:e.get(r)??null,otherId:r}})},[d,o,f]);return(0,eb.jsx)(dX,{open:n,onOpenChange:e=>e?void 0:r(),children:(0,eb.jsxs)(fU,{className:(0,ez.cn)("gap-0 overflow-hidden p-0",j?"inset-0 h-svh w-full max-w-none translate-x-0 translate-y-0 rounded-none border-0":"max-h-[88vh] w-[calc(100%-2rem)] max-w-3xl sm:max-w-3xl"),children:[(0,eb.jsx)(fK,{className:"sr-only",children:o?`#${o.number} ${o.title}`:"issue 详情"}),(0,eb.jsx)(fG,{className:"sr-only",children:"查看并编辑该 issue 的状态、负责人、进度、关联与活动。"}),!o||h?(0,eb.jsx)("div",{className:"flex h-64 items-center justify-center",children:(0,eb.jsx)(eM,{className:"size-6 animate-spin text-muted-foreground"})}):(0,eb.jsxs)("div",{className:(0,ez.cn)("flex flex-col",j?"h-svh":"max-h-[88vh]"),children:[(0,eb.jsxs)("div",{className:"flex items-start gap-3 border-b border-border px-5 py-4 pr-12",children:[(0,eb.jsxs)("span",{className:"mt-0.5 shrink-0 rounded-md bg-muted px-2 py-0.5 font-mono text-xs text-muted-foreground",children:["#",o.number]}),(0,eb.jsx)("h2",{className:"min-w-0 flex-1 break-words text-base font-semibold",children:o.title})]}),(0,eb.jsxs)("div",{className:"grid flex-1 grid-cols-1 gap-0 overflow-y-auto md:grid-cols-[1fr_300px]",children:[(0,eb.jsxs)("div",{className:"flex flex-col gap-5 px-5 py-4",children:[(0,eb.jsx)(eoO,{label:"标题",children:(0,eb.jsx)(eA,{defaultValue:o.title,onBlur:e=>{let t=e.target.value.trim();t&&t!==o.title&&M({title:t})}})}),(0,eb.jsx)(eoO,{label:"描述",children:(0,eb.jsx)(w2,{defaultValue:o.body,rows:4,placeholder:"补充描述…",onBlur:e=>{e.target.value!==o.body&&M({body:e.target.value})}})}),(0,eb.jsx)(eoO,{label:`进度 \xb7 ${O.percent}%`,children:(0,eb.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,eb.jsx)(erw,{value:O.percent,className:"h-2"}),(0,eb.jsx)("div",{className:"flex flex-col gap-1.5",children:O.checklist.map((e,t)=>(0,eb.jsxs)("div",{className:"group flex items-center gap-2 text-sm",children:[(0,eb.jsx)(vM,{checked:e.done,onCheckedChange:()=>void A(t)}),(0,eb.jsx)("span",{className:(0,ez.cn)("min-w-0 flex-1 break-words",e.done&&"text-muted-foreground line-through"),children:e.text}),(0,eb.jsx)("button",{type:"button",onClick:()=>void R(t),className:"shrink-0 text-muted-foreground opacity-0 transition hover:text-hot-pink group-hover:opacity-100",children:(0,eb.jsx)(fV.XIcon,{className:"size-3.5"})})]},t))}),(0,eb.jsx)(eoz,{onAdd:e=>void T(e)})]})}),(0,eb.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,eb.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"活动"}),(0,eb.jsx)("div",{className:"flex flex-col gap-3",children:0===s.length?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground/60",children:"暂无活动"}):s.map(e=>{let t=e.actor?.kind==="human"?"human":"agent",n=e.actor?.displayName??"系统";return(0,eb.jsxs)("div",{className:"flex gap-2.5",children:[(0,eb.jsx)(eoT,{kind:t,small:!0}),(0,eb.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eb.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[(0,eb.jsx)("span",{className:"font-medium text-foreground",children:n}),(0,eb.jsx)("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:eoN[e.kind]??e.kind}),(0,eb.jsx)("span",{className:"text-muted-foreground/60",children:eoS(e.createdAt)})]}),e.body?(0,eb.jsx)("p",{className:"mt-0.5 whitespace-pre-wrap break-words text-sm text-secondary-foreground",children:e.body}):null]})]},e.id)})}),(0,eb.jsxs)("div",{className:"mt-1 flex items-end gap-2",children:[(0,eb.jsx)(w2,{value:v,onChange:e=>b(e.target.value),rows:2,placeholder:"写评论…",className:"min-h-9"}),(0,eb.jsx)(eO.Button,{size:"sm",disabled:!v.trim()||g,onClick:()=>void I(),children:(0,eb.jsx)(eoI,{className:"size-4"})})]})]})]}),(0,eb.jsxs)("div",{className:"flex flex-col gap-4 border-t border-border px-5 py-4 md:border-l md:border-t-0",children:[(0,eb.jsx)(eoO,{label:"状态",children:(0,eb.jsx)(ei2,{className:"w-full",value:o.status,onChange:e=>void M({status:e.target.value}),children:eoh.map(e=>(0,eb.jsx)(ei5,{value:e.status,children:e.label},e.status))})}),(0,eb.jsx)(eoO,{label:"优先级",children:(0,eb.jsx)(ei2,{className:"w-full",value:o.priority,onChange:e=>void M({priority:e.target.value}),children:eob.map(e=>(0,eb.jsx)(ei5,{value:e,children:eov[e]},e))})}),(0,eb.jsx)(eoO,{label:"类型",children:(0,eb.jsx)(ei2,{className:"w-full",value:o.type,onChange:e=>void M({type:e.target.value}),children:eog.map(e=>(0,eb.jsx)(ei5,{value:e,children:eop[e]},e))})}),(0,eb.jsx)(eoO,{label:"负责人",children:o.assignee?(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-lg border border-border px-2.5 py-1.5",children:[(0,eb.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5 text-sm",children:[(0,eb.jsx)(eoT,{kind:o.assignee.kind,small:!0}),(0,eb.jsx)("span",{className:"truncate",children:o.assignee.displayName})]}),(0,eb.jsx)("button",{type:"button",className:"shrink-0 text-xs text-muted-foreground hover:text-hot-pink",onClick:()=>void M({assignee:null}),children:"取消"})]}):(0,eb.jsxs)(eO.Button,{variant:"outline",size:"sm",className:"w-full",disabled:g,onClick:()=>void E(),children:[(0,eb.jsx)(lU,{className:"size-4"})," 认领"]})}),(0,eb.jsx)(eoO,{label:"标签",children:(0,eb.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,eb.jsx)("div",{className:"flex flex-wrap gap-1.5",children:0===o.labels.length?(0,eb.jsx)("span",{className:"text-xs text-muted-foreground/60",children:"暂无标签"}):o.labels.map(e=>(0,eb.jsxs)("span",{className:"group inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs text-muted-foreground",children:[e,(0,eb.jsx)("button",{type:"button",onClick:()=>void M({labels:o.labels.filter(t=>t!==e)}),className:"text-muted-foreground/60 hover:text-hot-pink",children:(0,eb.jsx)(fV.XIcon,{className:"size-3"})})]},e))}),(0,eb.jsxs)("form",{className:"flex gap-1.5",onSubmit:e=>{e.preventDefault();let t=y.trim();t&&!o.labels.includes(t)&&M({labels:[...o.labels,t]}),w("")},children:[(0,eb.jsx)(eA,{value:y,onChange:e=>w(e.target.value),placeholder:"新标签",className:"h-8"}),(0,eb.jsx)(eO.Button,{type:"submit",size:"sm",variant:"outline",children:(0,eb.jsx)(lY,{className:"size-4"})})]})]})}),(0,eb.jsx)(eoO,{label:"关联 issue",children:(0,eb.jsxs)("div",{className:"flex flex-col gap-2",children:[0===D.length?(0,eb.jsx)("span",{className:"text-xs text-muted-foreground/60",children:"暂无关联"}):(0,eb.jsx)("div",{className:"flex flex-col gap-1",children:D.map(({link:e,outgoing:t,other:n,otherId:r})=>{let a=eok[e.kind];return(0,eb.jsxs)("div",{className:"group flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs",children:[(0,eb.jsx)(eoE,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,eb.jsxs)("span",{className:(0,ez.cn)("shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",a.chip),children:[t?"":"被",eow[e.kind]]}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate text-secondary-foreground",children:n?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsxs)("span",{className:"font-mono text-muted-foreground",children:["#",n.number]})," ",n.title]}):(0,eb.jsx)("span",{className:"font-mono text-muted-foreground/60",children:r.slice(0,8)})}),(0,eb.jsx)("button",{type:"button",disabled:g,onClick:()=>void C(e.id),title:"删除关联",className:"shrink-0 text-muted-foreground opacity-0 transition hover:text-hot-pink group-hover:opacity-100 disabled:opacity-30",children:(0,eb.jsx)(fV.XIcon,{className:"size-3.5"})})]},e.id)})}),(0,eb.jsx)(eoA,{currentIssueId:o.id,candidates:f,existingLinks:d,disabled:g,onAdd:S})]})}),(0,eb.jsxs)("div",{className:"mt-auto flex flex-col gap-1 pt-2 text-xs text-muted-foreground/70",children:[(0,eb.jsxs)("span",{children:["创建于 ",eoS(o.createdAt)]}),(0,eb.jsxs)("span",{children:["更新于 ",eoS(o.updatedAt)]})]}),(0,eb.jsxs)(eO.Button,{variant:"ghost",size:"sm",className:"text-hot-pink hover:bg-hot-pink/10 hover:text-hot-pink",disabled:g,onClick:()=>void P(),children:[(0,eb.jsx)(yn,{className:"size-4"})," 删除 issue"]})]})]})]})]})})}function eoO({label:e,children:t}){return(0,eb.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,eb.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:e}),t]})}function eoz({onAdd:e}){let[t,n]=ew.useState("");return(0,eb.jsxs)("form",{className:"flex gap-1.5",onSubmit:r=>{r.preventDefault(),e(t),n("")},children:[(0,eb.jsx)(eA,{value:t,onChange:e=>n(e.target.value),placeholder:"新增清单项",className:"h-8"}),(0,eb.jsx)(eO.Button,{type:"submit",size:"sm",variant:"outline",children:(0,eb.jsx)(lY,{className:"size-4"})})]})}function eoA({currentIssueId:e,candidates:t,existingLinks:n,disabled:r,onAdd:a}){let[i,o]=ew.useState(!1),[l,s]=ew.useState(""),[c,d]=ew.useState("depends_on"),u=ew.useMemo(()=>{let t=new Set;for(let r of n)r.fromIssueId===e&&t.add(r.toIssueId),r.toIssueId===e&&t.add(r.fromIssueId);return t},[n,e]),f=ew.useMemo(()=>{let n=l.trim().toLowerCase();return t.filter(t=>t.id!==e&&!u.has(t.id)).filter(e=>!n||e.title.toLowerCase().includes(n)||`#${e.number}`.includes(n)||String(e.number).includes(n)).slice(0,8)},[t,e,u,l]);return i?(0,eb.jsxs)("div",{className:"flex flex-col gap-1.5 rounded-lg border border-vivid-violet/40 bg-card p-2",children:[(0,eb.jsx)(ei2,{size:"sm",className:"w-full",value:c,onChange:e=>d(e.target.value),children:eoj.map(e=>(0,eb.jsx)(ei5,{value:e,children:eow[e]},e))}),(0,eb.jsx)(eA,{autoFocus:!0,value:l,onChange:e=>s(e.target.value),placeholder:"搜索 issue(编号 / 标题)",className:"h-8"}),(0,eb.jsx)("div",{className:"flex max-h-40 flex-col gap-0.5 overflow-y-auto",children:0===f.length?(0,eb.jsx)("span",{className:"px-1 py-1.5 text-xs text-muted-foreground/60",children:"无可关联的 issue"}):f.map(e=>(0,eb.jsxs)("button",{type:"button",disabled:r,onClick:async()=>{await a(e.id,c),o(!1),s("")},className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-left text-xs transition hover:bg-muted disabled:opacity-50",children:[(0,eb.jsxs)("span",{className:"shrink-0 font-mono text-muted-foreground",children:["#",e.number]}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate text-secondary-foreground",children:e.title})]},e.id))}),(0,eb.jsx)("div",{className:"flex justify-end",children:(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>{o(!1),s("")},children:"取消"})})]}):(0,eb.jsxs)(eO.Button,{variant:"outline",size:"sm",className:"w-full",disabled:r,onClick:()=>o(!0),children:[(0,eb.jsx)(lY,{className:"size-4"})," 添加关联"]})}function eoT({kind:e,small:t}){let n=t?"size-3":"size-3.5";return(0,eb.jsx)("span",{className:(0,ez.cn)("inline-flex shrink-0 items-center justify-center rounded-full",t?"size-5":"size-6","agent"===e?"bg-vivid-violet/15 text-vivid-violet":"bg-sky-teal/15 text-sky-teal"),title:"agent"===e?"Agent":"人类",children:"agent"===e?(0,eb.jsx)(uH,{className:n}):(0,eb.jsx)(HP,{className:n})})}let eoR=["backlog","todo","in_progress","blocked","review","done","cancelled"],eoD={backlog:{border:"border-ash-gray/50",dot:"bg-ash-gray"},todo:{border:"border-sky-teal/50",dot:"bg-sky-teal"},in_progress:{border:"border-vivid-violet/50",dot:"bg-vivid-violet"},blocked:{border:"border-hot-pink/50",dot:"bg-hot-pink"},review:{border:"border-amber-500/50",dot:"bg-amber-500"},done:{border:"border-emerald-500/50",dot:"bg-emerald-500"},cancelled:{border:"border-ash-gray/40",dot:"bg-ash-gray"}};function eo_({issues:e,links:t,loading:n,onOpenIssue:r}){let{placed:a,byId:i,width:o,height:l}=ew.useMemo(()=>{let t=new Map;for(let n of e){let e=t.get(n.status)??[];e.push(n),t.set(n.status,e)}for(let e of t.values())e.sort((e,t)=>e.sortOrder!==t.sortOrder?e.sortOrder-t.sortOrder:e.createdAt.localeCompare(t.createdAt));let n=eoR.filter(e=>(t.get(e)?.length??0)>0),r=[],a=0;n.forEach((e,n)=>{let i=t.get(e)??[];a=Math.max(a,i.length),i.forEach((e,t)=>{r.push({issue:e,x:32+280*n,y:32+84*t})})});let i=new Map(r.map(e=>[e.issue.id,e]));return{placed:r,byId:i,width:n.length>0?64+184*n.length+(n.length-1)*96:64,height:Math.max(64+56*a+28*Math.max(0,a-1),120)}},[e]),s=ew.useMemo(()=>t.map(e=>{let t=i.get(e.fromIssueId),n=i.get(e.toIssueId);return t&&n?{link:e,from:t,to:n}:null}).filter(e=>!!e),[t,i]);if(n)return(0,eb.jsx)("div",{className:"flex flex-1 items-center justify-center",children:(0,eb.jsx)(eM,{className:"size-6 animate-spin text-muted-foreground"})});if(0===e.length)return(0,eb.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 text-sm text-muted-foreground/70",children:[(0,eb.jsx)(enH,{className:"size-6"}),"暂无 issue,先在看板中创建"]});let c=s.length>0;return(0,eb.jsxs)("div",{className:"flex flex-1 flex-col overflow-hidden",children:[c?(0,eb.jsx)("div",{className:"mx-5 mb-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground",children:["depends_on","blocks","parent","relates_to"].map(e=>(0,eb.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,eb.jsx)("span",{className:"inline-block h-0.5 w-4 rounded-full",style:{backgroundColor:eok[e].stroke}}),eow[e]]},e))}):(0,eb.jsxs)("div",{className:"mx-5 mb-2 flex items-center gap-2 rounded-lg border border-dashed border-border bg-muted/30 px-3 py-2 text-xs text-muted-foreground",children:[(0,eb.jsx)(enH,{className:"size-3.5 shrink-0"}),"还没有任何依赖关系。在某张卡片详情的「关联 issue」中添加依赖 / 阻塞 / 父级,即可在此看到请求图谱。"]}),(0,eb.jsx)("div",{className:"flex-1 overflow-auto px-5 pb-4",children:(0,eb.jsxs)("div",{className:"relative",style:{width:o,height:l},children:[(0,eb.jsxs)("svg",{className:"pointer-events-none absolute inset-0",width:o,height:l,children:[(0,eb.jsx)("defs",{children:["depends_on","blocks","parent","relates_to"].map(e=>(0,eb.jsx)("marker",{id:`arrow-${e}`,viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto-start-reverse",children:(0,eb.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:eok[e].stroke})},e))}),s.map(({link:e,from:t,to:n})=>{let r=eoL(t,n),a=eoL(n,t),i=eok[e.kind].stroke,o=(r.x+a.x)/2,l=(r.y+a.y)/2;return(0,eb.jsxs)("g",{children:[(0,eb.jsx)("line",{x1:r.x,y1:r.y,x2:a.x,y2:a.y,stroke:i,strokeWidth:1.75,markerEnd:`url(#arrow-${e.kind})`}),(0,eb.jsx)("text",{x:o,y:l-4,textAnchor:"middle",className:"fill-muted-foreground",style:{fontSize:10},children:eow[e.kind]})]},e.id)})]}),a.map(({issue:e,x:t,y:n})=>{var a;let i=eoD[e.status];return(0,eb.jsxs)("button",{type:"button",onClick:()=>r(e.id),style:{left:t,top:n,width:184,height:56},className:(0,ez.cn)("absolute flex flex-col justify-center gap-0.5 rounded-lg border bg-card px-2.5 py-1.5 text-left shadow-sm transition hover:border-vivid-violet hover:shadow-md",i.border),title:`#${e.number} ${e.title}`,children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,eb.jsx)("span",{className:(0,ez.cn)("size-2 shrink-0 rounded-full",i.dot)}),(0,eb.jsxs)("span",{className:"font-mono text-[11px] text-muted-foreground",children:["#",e.number]}),(0,eb.jsx)("span",{className:"ml-auto truncate text-[10px] text-muted-foreground/70",children:(a=e.status,eoh.find(e=>e.status===a)??{status:a,label:a,dot:"bg-ash-gray",chip:"bg-muted text-muted-foreground"}).label})]}),(0,eb.jsx)("span",{className:"truncate text-xs font-medium text-foreground",children:e.title})]},e.id)})]})})]})}function eoL(e,t){let n=e.x+92,r=e.y+28,a=t.x+92,i=t.y+28,o=a-n,l=i-r;if(0===o&&0===l)return{x:n,y:r};let s=Math.min(0!==o?92/Math.abs(o):1/0,0!==l?28/Math.abs(l):1/0);return{x:n+o*s,y:r+l*s}}async function eo$(e){let t=await fetch((0,eT.localAPIURL)(`/api/local/projects/${encodeURIComponent(e)}/dispatcher`),{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json"}}),n=await t.json().catch(()=>({}));if(!t.ok)throw Error("string"==typeof n?.error?n.error:"dispatcher api failed");let r=cx(n);return{conversationId:r.conversation.id,ownerMachineId:r.conversation.ownerMachineId,events:r.events,running:r.conversation.running??!1,modelRef:r.conversation.settings?.mainModels?.[0]??"",mainModels:r.conversation.settings?.mainModels??[]}}function eoF({projectId:e}){let[t,n]=ew.useState(void 0),[r,a]=ew.useState(void 0),[i,o]=ew.useState(""),[l,s]=ew.useState([]),[c,d]=ew.useState([]),[u,f]=ew.useState(!1),[m,h]=ew.useState(!1);ew.useEffect(()=>{let t=!0;return n(void 0),d([]),f(!1),s([]),(async()=>{try{let r=await eo$(e);if(!t)return;n(r.conversationId),a(r.ownerMachineId),o(r.modelRef),s(r.mainModels),d(r.events),f(r.running)}catch{}})(),()=>{t=!1}},[e]),ew.useEffect(()=>{let e;if(!t)return;let n=!0,a=async()=>{if(n)try{let i=await sD(t,r);if(!n)return;let o=i.conversation.running??!1;d(i.events),f(o),s(i.conversation.settings?.mainModels??[]),e=window.setTimeout(a,o?1200:5e3)}catch{if(!n)return;try{let e=await s_(t,{limit:400},r);n&&e.events.length&&d(e.events)}catch{}n&&(e=window.setTimeout(a,5e3))}};return a(),()=>{n=!1,void 0!==e&&window.clearTimeout(e)}},[t,r]);let p=ew.useCallback(e=>{let n=e.trim();t&&n&&!m&&(h(!0),f(!0),(async()=>{try{await s3(t,{message:n,modelRef:i,mode:"agent"},r)}catch{f(!1)}finally{h(!1)}})())},[t,r,i,m]),g=ew.useMemo(()=>{if(u||m||0===c.length)return;let e=c[c.length-1];return e&&"ask"===e.kind?e:void 0},[c,u,m]),{models:x}=vH(),v=ew.useMemo(()=>l.length?x.filter(e=>l.includes(e.value)).map(e=>({id:e.value,label:e.label})):[],[x,l]),b=0===c.length;return(0,eb.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col rounded-[inherit] bg-background",children:[(0,eb.jsxs)("div",{className:"flex shrink-0 flex-col gap-0.5 border-b px-4 py-2.5",children:[(0,eb.jsx)("span",{className:"text-[13px] font-medium text-foreground",children:"任务分发"}),(0,eb.jsx)("span",{className:"text-[11px] text-muted-foreground",children:"把需求转成任务并派发执行"})]}),(0,eb.jsxs)("div",{className:"relative min-h-0 flex-1",children:[(0,eb.jsx)(UL,{className:"size-full min-h-0",composerClassName:"max-w-[42rem]",events:c,running:u||m,disabled:!t,models:v,modelId:i,onModelChange:e=>o(e),hidePermissionMode:!0,onSubmit:e=>p(e.value),planPromptBar:g?(0,eb.jsx)(eoB,{ask:g,onAnswer:p}):void 0}),b?(0,eb.jsx)("div",{className:"pointer-events-none absolute inset-x-0 top-0 bottom-28 grid place-items-center px-6",children:(0,eb.jsx)("div",{className:"max-w-xs text-center",children:(0,eb.jsx)("p",{className:"text-sm text-muted-foreground",children:"把你对这个工程的需求告诉我,我会拆成任务并派发给执行会话。"})})}):null]})]})}function eoB({ask:e,onAnswer:t}){let n=(e.detail?.trim()||e.title?.trim())??"",r=e.askOptions??[],a=e.askAllowMultiple??!1,i=e.askAllowCustom??!1,[o,l]=ew.useState([]);return ew.useEffect(()=>{l([])},[e.id]),(0,eb.jsxs)("div",{className:"vtl-agent-composer-prompt-bar mb-[-1px] rounded-t-xl border border-b-0 bg-popover px-3 pt-2.5 pb-3 shadow-sm",children:[(0,eb.jsx)("p",{className:"mb-2 text-[13px] font-medium text-foreground",children:n}),r.length>0?(0,eb.jsx)("div",{className:"flex flex-wrap gap-1.5",children:r.map(e=>{let n=a&&o.includes(e);return(0,eb.jsx)(eO.Button,{type:"button",size:"sm",variant:n?"default":"outline",className:(0,ez.cn)("h-auto max-w-full justify-start whitespace-normal py-1.5 text-left text-xs","w-full sm:w-auto"),onClick:()=>a?void l(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]):t(e),children:e},e)})}):null,a?(0,eb.jsx)("div",{className:"mt-2 flex justify-end",children:(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",disabled:0===o.length,onClick:()=>t(o.join("、")),children:[(0,eb.jsx)(eoI,{className:"mr-1.5 size-3"}),"提交所选"]})}):null,i?(0,eb.jsx)("p",{className:"mt-2 text-[11px] text-muted-foreground",children:"或在下方输入框自行回答"}):null]})}let eoV="application/x-vantaloom-issue";function eoH({projectId:e}){let[t,n]=ew.useState([]),[r,a]=ew.useState([]),[i,o]=ew.useState([]),[l,s]=ew.useState("board"),[c,d]=ew.useState(!1),[u,f]=ew.useState(!1),m=sv(),[h,p]=ew.useState(!0),[g,x]=ew.useState(!1),[v,b]=ew.useState(null),[y,w]=ew.useState(null),[j,k]=ew.useState(null),[N,S]=ew.useState(null),[C,M]=ew.useState(!1),[E,I]=ew.useState(null),P=ew.useCallback(async t=>{t?.silent||x(!0);try{let[t,r,i]=await Promise.all([ei3(e),eor(e).catch(()=>[]),eos(e).catch(()=>[])]);n(t),a(r),o(i),b(null)}catch(e){b(e instanceof Error?e.message:"加载看板失败")}finally{p(!1),x(!1)}},[e]);ew.useEffect(()=>{p(!0),P({silent:!0});let e=setInterval(()=>void P({silent:!0}),1e4),t=()=>void P({silent:!0});return window.addEventListener("focus",t),()=>{clearInterval(e),window.removeEventListener("focus",t)}},[P]);let O=ew.useMemo(()=>{let e={};for(let t of[...eof,eom])e[t.status]=[];for(let n of t)(e[n.status]??=[]).push(n);for(let t of Object.values(e))t.sort((e,t)=>e.sortOrder!==t.sortOrder?e.sortOrder-t.sortOrder:e.createdAt.localeCompare(t.createdAt));return e},[t]);async function z(e,r,a){let i,o,l=t.find(t=>t.id===e);if(!l)return;let s=(O[r]??[]).filter(t=>t.id!==e);if(a){let e=s.findIndex(e=>e.id===a);e>=0&&(o=s[e]?.sortOrder,i=e>0?s[e-1]?.sortOrder:void 0)}if(void 0===i&&void 0===o){let e=s[s.length-1];i=e?.sortOrder}let c=void 0!==i&&void 0!==o?(i+o)/2:void 0!==i?i+1e3:void 0!==o?o-1e3:1e3;if(l.status!==r||l.sortOrder!==c){w(null),n(t=>t.map(t=>t.id===e?{...t,status:r,sortOrder:c}:t));try{await ei7(e,{status:r,sortOrder:c})}catch(e){n(t),w(e instanceof Error?`移动失败:${e.message}`:"移动失败,已撤销")}}}function A(e,t,n){e.preventDefault(),e.stopPropagation(),k(null);let r=e.dataTransfer.getData(eoV)||e.dataTransfer.getData("text/plain");r&&z(r,t,n)}async function T(e,t,n){w(null);try{await eoc(e.conversationId,e.approvalId,t,n)}catch(e){e instanceof eod&&404===e.status||w(e instanceof Error?`${"approve"===t?"通过":"拒绝"}失败:${e.message}`:"操作失败")}o(t=>t.filter(t=>t.approvalId!==e.approvalId)),P({silent:!0})}let R=C?[...eof,eom]:eof;return(0,eb.jsxs)(en3,{children:[(0,eb.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,eb.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 px-5 py-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:["board"===l?(0,eb.jsx)(ei1,{className:"size-4 text-muted-foreground"}):(0,eb.jsx)(enH,{className:"size-4 text-muted-foreground"}),(0,eb.jsx)("h1",{className:"text-sm font-semibold text-foreground",children:"board"===l?"看板":"图谱"}),(0,eb.jsxs)("span",{className:"text-xs text-muted-foreground",children:[t.length," 个 issue"]})]}),(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[y?(0,eb.jsxs)("span",{className:"flex items-center gap-1 text-xs text-hot-pink",children:[(0,eb.jsx)(eE,{className:"size-3.5"}),y]}):null,(0,eb.jsxs)("div",{className:"flex items-center rounded-lg border border-border p-0.5",children:[(0,eb.jsxs)("button",{type:"button",onClick:()=>s("board"),className:(0,ez.cn)("flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition","board"===l?"bg-vivid-violet/15 text-vivid-violet":"text-muted-foreground hover:text-foreground"),children:[(0,eb.jsx)(ei1,{className:"size-3.5"}),"看板"]}),(0,eb.jsxs)("button",{type:"button",onClick:()=>s("graph"),className:(0,ez.cn)("flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition","graph"===l?"bg-vivid-violet/15 text-vivid-violet":"text-muted-foreground hover:text-foreground"),children:[(0,eb.jsx)(enH,{className:"size-3.5"}),"图谱"]})]}),"board"===l?(0,eb.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 text-xs text-muted-foreground",children:[(0,eb.jsx)("input",{type:"checkbox",checked:C,onChange:e=>M(e.target.checked),className:"size-3.5 accent-vivid-violet"}),"显示已取消"]}):null,(0,eb.jsxs)(eO.Button,{variant:"outline",size:"sm",onClick:()=>void P(),disabled:g,children:[(0,eb.jsx)(yt,{className:(0,ez.cn)("size-4",g&&"animate-spin")}),"刷新"]}),(0,eb.jsxs)(eO.Button,{variant:"outline",size:"sm",onClick:()=>{f(!0),d(!0)},children:[(0,eb.jsx)(kM,{className:"size-4"}),"任务分发"]})]})]}),i.length>0?(0,eb.jsx)(eoU,{approvals:i,onResolve:T}):null,h?(0,eb.jsx)("div",{className:"flex flex-1 items-center justify-center",children:(0,eb.jsx)(eM,{className:"size-6 animate-spin text-muted-foreground"})}):v?(0,eb.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 text-sm text-hot-pink",children:[(0,eb.jsx)(eE,{className:"size-5"}),v,(0,eb.jsx)(eO.Button,{variant:"outline",size:"sm",onClick:()=>void P(),children:"重试"})]}):"graph"===l?(0,eb.jsx)(eo_,{issues:t,links:r,onOpenIssue:e=>S(e)}):(0,eb.jsx)("div",{className:(0,ez.cn)("grid flex-1 content-start gap-x-3 gap-y-5 overflow-y-auto px-5 pb-4","grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-6"),children:R.map(t=>{let r=O[t.status]??[],a=j===t.status,i=E===t.status;return(0,eb.jsxs)("section",{onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",j!==t.status&&k(t.status)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||k(e=>e===t.status?null:e)},onDrop:e=>A(e,t.status),className:"flex min-w-0 flex-col gap-2",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2 px-1",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,eb.jsx)("span",{className:(0,ez.cn)("size-2 shrink-0 rounded-full",t.dot)}),(0,eb.jsx)("span",{className:"truncate text-sm font-medium text-foreground",children:t.label}),(0,eb.jsx)("span",{className:(0,ez.cn)("shrink-0 rounded-full px-1.5 py-0.5 text-[11px] font-medium",t.chip),children:r.length})]}),(0,eb.jsx)("button",{type:"button",title:"新建 issue",onClick:()=>I(e=>e===t.status?null:t.status),className:"flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-muted hover:text-foreground",children:(0,eb.jsx)(lY,{className:"size-4"})})]}),(0,eb.jsxs)("div",{className:(0,ez.cn)("flex min-h-[5rem] flex-col divide-y divide-border overflow-hidden rounded-lg border bg-card transition-colors",a?"border-vivid-violet ring-1 ring-vivid-violet/40":"border-border"),children:[i?(0,eb.jsx)(eoK,{onCancel:()=>I(null),onCreate:async r=>{try{let a=await ei8(e,{...r}),i="backlog"===t.status?a:await ei7(a.id,{status:t.status}).catch(()=>a);n(e=>[...e,i]),I(null)}catch(e){w(e instanceof Error?`新建失败:${e.message}`:"新建失败")}}}):null,0!==r.length||i?r.map(e=>(0,eb.jsx)(eoW,{issue:e,onOpen:()=>S(e.id),onDropBefore:n=>A(n,t.status,e.id)},e.id)):(0,eb.jsx)("div",{className:"flex flex-1 items-center justify-center px-3 py-8 text-xs text-muted-foreground/60",children:a?"松开以移动到此状态":"暂无 issue"})]})]},t.status)})})]}),(0,eb.jsx)(eoP,{issueId:N,projectId:e,open:null!==N,onClose:()=>S(null),onChange:t=>{n(e=>e.map(e=>e.id===t.id?t:e)),eor(e).then(e=>a(e)).catch(()=>{})},onDeleted:e=>n(t=>t.filter(t=>t.id!==e))}),(0,eb.jsx)(dX,{open:c,onOpenChange:d,children:(0,eb.jsxs)(erc,{side:m?"bottom":"right",className:(0,ez.cn)("w-full gap-0 p-0",m?"h-[95svh]":"sm:max-w-md md:max-w-lg lg:max-w-xl"),children:[(0,eb.jsx)(erd,{className:"border-b",children:(0,eb.jsx)(eru,{children:"任务分发"})}),(0,eb.jsx)("div",{className:"min-h-0 flex-1",children:u?(0,eb.jsx)(eoF,{projectId:e}):null})]})})]})}function eoU({approvals:e,onResolve:t}){return(0,eb.jsxs)("section",{className:"mx-5 mb-3 flex flex-col gap-2 rounded-xl border border-amber-500/40 bg-amber-500/5 p-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)(eiE,{className:"size-4 text-amber-600 dark:text-amber-400"}),(0,eb.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"待审批"}),(0,eb.jsx)("span",{className:"rounded-full bg-amber-500/15 px-1.5 py-0.5 text-[11px] font-medium text-amber-600 dark:text-amber-400",children:e.length}),(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:"同伴会话有待你确认的工具调用"})]}),(0,eb.jsx)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:e.map(e=>(0,eb.jsx)(eoq,{approval:e,onResolve:t},e.approvalId))})]})}function eoq({approval:e,onResolve:t}){let[n,r]=ew.useState(null),[a,i]=ew.useState(!1),[o,l]=ew.useState("");async function s(n,a){r(n);try{await t(e,n,a)}finally{r(null)}}let c=e.riskFactors??[];return(0,eb.jsxs)("article",{className:"flex flex-col gap-2 rounded-lg border border-border bg-card p-2.5 shadow-sm",children:[(0,eb.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,eb.jsx)("span",{className:"break-words font-mono text-[13px] font-medium text-foreground",children:e.toolName}),(0,eb.jsx)("span",{className:(0,ez.cn)("shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",eoM[e.classification]),children:eoC[e.classification]})]}),e.title?(0,eb.jsx)("p",{className:"break-words text-[13px] text-foreground",children:e.title}):null,e.reason?(0,eb.jsx)("p",{className:"break-words text-xs text-muted-foreground",children:e.reason}):null,c.length>0?(0,eb.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,eb.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground/70",children:"风险"}),(0,eb.jsx)("ul",{className:"flex flex-wrap gap-1",children:c.map((e,t)=>(0,eb.jsx)("li",{className:"rounded-full bg-hot-pink/10 px-1.5 py-0.5 text-[10px] text-hot-pink",children:e},`${e}-${t}`))})]}):null,(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground/70",children:[(0,eb.jsx)(kM,{className:"size-3 shrink-0"}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",title:e.conversationTitle,children:e.conversationTitle||"(未命名会话)"}),(0,eb.jsx)("span",{className:"shrink-0","aria-hidden":!0,children:"·"}),(0,eb.jsx)("span",{className:"shrink-0",children:eoS(e.createdAt)})]}),a?(0,eb.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,eb.jsx)(eA,{autoFocus:!0,value:o,onChange:e=>l(e.target.value),placeholder:"拒绝理由(可选)",className:"h-8",onKeyDown:e=>{"Enter"===e.key&&s("reject",o.trim()),"Escape"===e.key&&(i(!1),l(""))}}),(0,eb.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"sm",disabled:null!==n,onClick:()=>{i(!1),l("")},children:"取消"}),(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",variant:"destructive",disabled:null!==n,onClick:()=>void s("reject",o.trim()),children:["reject"===n?(0,eb.jsx)(eM,{className:"size-4 animate-spin"}):(0,eb.jsx)(fV.XIcon,{className:"size-4"}),"确认拒绝"]})]})]}):(0,eb.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,eb.jsxs)(eO.Button,{type:"button",variant:"outline",size:"sm",disabled:null!==n,onClick:()=>i(!0),children:[(0,eb.jsx)(fV.XIcon,{className:"size-4"}),"拒绝"]}),(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",disabled:null!==n,onClick:()=>void s("approve"),children:["approve"===n?(0,eb.jsx)(eM,{className:"size-4 animate-spin"}):(0,eb.jsx)(h6,{className:"size-4"}),"通过"]})]})]})}function eoW({issue:e,onOpen:t,onDropBefore:n}){let r=e.progress,a=r?.checklist.length??0,i=r?.checklist.filter(e=>e.done).length??0;return(0,eb.jsxs)("article",{draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed="move",t.dataTransfer.setData(eoV,e.id),t.dataTransfer.setData("text/plain",e.id)},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="move"},onDrop:n,onClick:t,className:"group cursor-pointer px-3 py-2.5 transition-colors hover:bg-muted/50 active:cursor-grabbing",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsxs)("span",{className:"shrink-0 font-mono text-[11px] text-muted-foreground",children:["#",e.number]}),(0,eb.jsx)("span",{className:(0,ez.cn)("shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",eox[e.type]),children:eop[e.type]}),"low"!==e.priority&&"normal"!==e.priority?(0,eb.jsx)("span",{className:(0,ez.cn)("shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",eoy[e.priority]),children:eov[e.priority]}):null,(0,eb.jsx)("span",{className:"ml-auto flex min-w-0 shrink items-center justify-end gap-1 text-[11px] text-muted-foreground",children:e.assignee?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(eoT,{kind:e.assignee.kind,small:!0}),(0,eb.jsx)("span",{className:"truncate",children:e.assignee.displayName})]}):(0,eb.jsx)("span",{className:"text-muted-foreground/50",children:"未认领"})})]}),(0,eb.jsx)("h3",{className:"mt-1 break-words text-sm font-medium leading-snug text-foreground",children:e.title}),e.labels.length>0?(0,eb.jsx)("div",{className:"mt-1.5 flex flex-wrap gap-1",children:e.labels.slice(0,4).map(e=>(0,eb.jsx)("span",{className:"rounded-full bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:e},e))}):null,r&&(r.percent>0||a>0)?(0,eb.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,eb.jsx)("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-muted",children:(0,eb.jsx)("div",{className:"h-full rounded-full bg-vivid-violet transition-all",style:{width:`${Math.max(0,Math.min(100,r.percent))}%`}})}),(0,eb.jsx)("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:a>0?`${i}/${a}`:`${r.percent}%`})]}):null]})}function eoK({onCreate:e,onCancel:t}){let[n,r]=ew.useState(""),[a,i]=ew.useState("task"),[o,l]=ew.useState("normal"),[s,c]=ew.useState(!1);return(0,eb.jsxs)("form",{className:"flex flex-col gap-2 rounded-lg border border-vivid-violet/40 bg-card p-2.5",onSubmit:async t=>{t.preventDefault(),n.trim()&&(c(!0),await e({title:n.trim(),type:a,priority:o}),c(!1))},children:[(0,eb.jsx)(eA,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),placeholder:"issue 标题",className:"h-8"}),(0,eb.jsxs)("div",{className:"flex gap-1.5",children:[(0,eb.jsx)(ei2,{size:"sm",className:"flex-1",value:a,onChange:e=>i(e.target.value),children:eog.map(e=>(0,eb.jsx)(ei5,{value:e,children:eop[e]},e))}),(0,eb.jsx)(ei2,{size:"sm",className:"flex-1",value:o,onChange:e=>l(e.target.value),children:eob.map(e=>(0,eb.jsx)(ei5,{value:e,children:eov[e]},e))})]}),(0,eb.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"sm",onClick:t,children:"取消"}),(0,eb.jsx)(eO.Button,{type:"submit",size:"sm",disabled:!n.trim()||s,children:s?(0,eb.jsx)(eM,{className:"size-4 animate-spin"}):"新建"})]})]})}let eoG=(0,ek.default)("archive-restore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]),eoX=(0,ek.default)("file-code-corner",[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]]),eoY=(0,ek.default)("git-merge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);function eoZ({projectId:e,onOpenSettings:t,onOpenConversation:n}){let[r,a]=ew.useState(),[i,o]=ew.useState({sessionCount:0,runningCount:0,tokenTotal:0,issueCount:0,openIssueCount:0,pendingApprovalCount:0}),[l,s]=ew.useState(!0),[c,d]=ew.useState([]),[u,f]=ew.useState([]),[m,h]=ew.useState(),[p,g]=ew.useState(),[x,v]=ew.useState(),[b,y]=ew.useState(!0),w=ew.useCallback(async()=>{y(!0);let[t,n]=await Promise.all([eik(e).catch(()=>void 0),eiN(e).catch(()=>void 0)]);t&&g(t),n&&v(n),y(!1)},[e]);return ew.useEffect(()=>{let e=!0;return g(void 0),v(void 0),w().finally(()=>{if(!e)return}),()=>{e=!1}},[w]),ew.useEffect(()=>{let t=!0;async function n(){try{let n,r=await eib(e);if(!t)return;a(r);let i=await eiS(e).catch(()=>[]);if(!t)return;d(i);let l=await ei3(e).catch(()=>[]);if(!t)return;f(l);let s=await eos(e).catch(()=>[]);if(!t)return;let c=await eij(e).catch(()=>void 0);if(!t)return;c&&h(c);let u=l.filter(e=>"done"!==e.status&&"cancelled"!==e.status).length;if(r.canvasId)try{n=(await enR(r.canvasId)).nodes.length}catch{n=void 0}if(!t)return;o({sessionCount:i.length,runningCount:i.filter(e=>!0===e.running).length,tokenTotal:i.reduce((e,t)=>e+(t.runUsage?.totalTokens??t.tokens??0),0),canvasNodeCount:n,issueCount:l.length,openIssueCount:u,pendingApprovalCount:s.length})}catch{}finally{t&&s(!1)}}s(!0),n();let r=setInterval(()=>void n(),1e4);return()=>{t=!1,clearInterval(r)}},[e]),(0,eb.jsx)(en3,{children:(0,eb.jsxs)("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-6 px-6 py-8",children:[(0,eb.jsxs)("header",{className:"flex flex-col gap-1",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,eb.jsx)(uU,{className:"size-4"}),(0,eb.jsx)("span",{className:"text-[13px]",children:"工程"}),(0,eb.jsx)(eoJ,{count:i.pendingApprovalCount}),t?(0,eb.jsxs)("button",{type:"button",onClick:()=>t(e),title:"工程设置",className:"ml-auto flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(era,{}),"设置"]}):null]}),(0,eb.jsx)("h1",{className:"text-2xl font-semibold text-foreground",children:r?.title??(l?"加载中…":"工程")}),r?.summary?(0,eb.jsx)("p",{className:"max-w-2xl text-sm text-muted-foreground",children:r.summary}):(0,eb.jsx)("p",{className:"text-sm text-muted-foreground/60",children:"暂无工程摘要"})]}),(0,eb.jsxs)("section",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[(0,eb.jsx)(eo5,{icon:(0,eb.jsx)(uH,{className:"size-4"}),label:"Agent 会话",value:i.sessionCount,hint:`${i.runningCount} 个运行中`,loading:l}),(0,eb.jsx)(eo5,{icon:(0,eb.jsx)(ei1,{className:"size-4"}),label:"issue 总数",value:i.issueCount,hint:`${i.openIssueCount} 个进行中`,loading:l}),(0,eb.jsx)(eo5,{icon:(0,eb.jsx)(Yv,{className:"size-4"}),label:"总 token",value:i.tokenTotal,loading:l}),(0,eb.jsx)(eo5,{icon:(0,eb.jsx)(uU,{className:"size-4"}),label:"画布节点",value:i.canvasNodeCount??"—",hint:r?.canvasId?void 0:"未绑定画布",loading:l&&r?.canvasId!==void 0})]}),(0,eb.jsx)(eoQ,{projectId:e,budget:m,loading:l,onUpdated:(e,t)=>{h(e),t&&a(t)}}),(0,eb.jsx)(eo0,{peers:c,issues:u,loading:l}),(0,eb.jsx)(eo1,{projectId:e,onOpenConversation:n}),(0,eb.jsxs)("section",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:[(0,eb.jsx)(eo8,{stats:p,loading:b,onRefresh:()=>void w()}),(0,eb.jsx)(eo7,{graph:x,loading:b,onRefresh:()=>void w()})]})]})})}function eoJ({count:e}){return e<=0?(0,eb.jsx)("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground/60",children:"无待审批"}):(0,eb.jsxs)("span",{className:"flex items-center gap-1 rounded-full bg-amber-500/15 px-2 py-0.5 text-[11px] font-medium text-amber-600 dark:text-amber-400 [&_svg]:size-3",title:"同伴会话有待你确认的工具调用,可在看板顶部处理",children:[(0,eb.jsx)(eiE,{}),"待审批 ",e.toLocaleString("zh-CN")]})}function eoQ({projectId:e,budget:t,loading:n,onUpdated:r}){let[a,i]=ew.useState(!1),[o,l]=ew.useState(""),[s,c]=ew.useState(!1),[d,u]=ew.useState();if(n&&!t)return(0,eb.jsxs)("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-sm",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground [&_svg]:shrink-0",children:[(0,eb.jsx)(erI,{className:"size-4"}),(0,eb.jsx)("span",{className:"text-[13px]",children:"工程预算"})]}),(0,eb.jsx)(eM,{className:"size-5 animate-spin text-muted-foreground"})]});if(!t)return null;let f=Math.max(0,t.pct),m=Math.min(100,f),h=t.hard?"hard":t.soft?"soft":"normal";async function p(){let n=o.trim(),a=Number(n);if(""===n||!Number.isFinite(a)||a<0)return void u("请输入 ≥ 0 的整数(0 表示恢复全局默认)");c(!0),u(void 0);try{let n=Math.floor(a),o=await eiw(e,{budgetTokens:n}),l=await eij(e).catch(()=>void 0);r(l??{...t,budget:n||t.budget},o),i(!1)}catch(e){u(e instanceof Error?e.message:"保存失败")}finally{c(!1)}}return(0,eb.jsxs)("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-sm",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground [&_svg]:shrink-0",children:[(0,eb.jsx)(erI,{className:"size-4"}),(0,eb.jsx)("span",{className:"text-[13px]",children:"工程预算"})]}),(0,eb.jsx)("span",{className:(0,ez.cn)("text-xs font-medium","hard"===h?"text-hot-pink":"soft"===h?"text-amber-500":"text-muted-foreground"),children:"hard"===h?"已用尽":"soft"===h?"接近上限":"正常"})]}),(0,eb.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,eb.jsxs)("span",{className:"text-2xl font-semibold text-foreground",children:[f,"%"]}),(0,eb.jsxs)("span",{className:"text-xs text-muted-foreground/70",children:["已用 ",t.used.toLocaleString("zh-CN")," /"," ",t.budget.toLocaleString("zh-CN")," token"]})]}),(0,eb.jsx)("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:(0,eb.jsx)("div",{className:(0,ez.cn)("h-full rounded-full transition-all","hard"===h?"bg-hot-pink":"soft"===h?"bg-amber-500":"bg-sky-teal"),style:{width:`${m}%`}})}),(0,eb.jsx)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground/70",children:a?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("input",{type:"number",min:0,step:1e5,value:o,autoFocus:!0,disabled:s,onChange:e=>l(e.target.value),onKeyDown:e=>{"Enter"===e.key&&p(),"Escape"===e.key&&(i(!1),u(void 0))},placeholder:"0 = 全局默认",className:"w-40 rounded-md border border-border bg-background px-2 py-1 text-foreground outline-none focus:border-sky-teal"}),(0,eb.jsxs)("button",{type:"button",disabled:s,onClick:()=>void p(),className:"flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1 text-foreground hover:bg-muted [&_svg]:size-3 disabled:opacity-50",children:[s?(0,eb.jsx)(eM,{className:"size-3 animate-spin"}):(0,eb.jsx)(h6,{}),"保存"]}),(0,eb.jsx)("button",{type:"button",disabled:s,onClick:()=>{i(!1),u(void 0)},className:"flex items-center gap-1 rounded-md px-1.5 py-1 hover:bg-muted [&_svg]:size-3 disabled:opacity-50",children:(0,eb.jsx)(fV.XIcon,{})}),d?(0,eb.jsx)("span",{className:"text-hot-pink",children:d}):null]}):(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsxs)("span",{children:["预算上限 ",t.budget.toLocaleString("zh-CN")," token"]}),(0,eb.jsxs)("button",{type:"button",onClick:()=>{l(String(t.budget)),u(void 0),i(!0)},className:"flex items-center gap-1 rounded-md px-1.5 py-1 text-muted-foreground hover:bg-muted hover:text-foreground [&_svg]:size-3",children:[(0,eb.jsx)(UH,{}),"调整"]})]})})]})}function eo0({peers:e,issues:t,loading:n}){let r=ew.useMemo(()=>{let e=new Map,n=e=>"done"===e.status||"cancelled"===e.status;for(let r of t){if(r.assignee?.kind!=="agent")continue;let t=r.assignee.id,a=e.get(t);(!a||n(a)&&!n(r))&&e.set(t,r)}return e},[t]);return n&&0===e.length?null:(0,eb.jsxs)("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-4 shadow-sm",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground [&_svg]:shrink-0",children:[(0,eb.jsx)(uH,{className:"size-4"}),(0,eb.jsx)("span",{className:"text-[13px]",children:"同伴会话"}),(0,eb.jsx)("span",{className:"text-xs text-muted-foreground/60",children:e.length})]}),0===e.length?(0,eb.jsx)("p",{className:"py-1 text-xs text-muted-foreground/60",children:"暂无同伴会话。在工程内的对话里用多代理工具拉起同伴即可在此显示。"}):(0,eb.jsx)("ul",{className:"flex flex-col gap-1",children:e.map(e=>{let t=!0===e.running,n=r.get(e.id),a=function(e){let t=e.settings?.folders?.[0]?.trim();if(!t)return"";let n=t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean);return n[n.length-1]??""}(e);return(0,eb.jsxs)("li",{className:"flex items-center gap-2 rounded-lg px-2 py-1.5 text-[13px] hover:bg-muted/50",children:[(0,eb.jsx)("span",{className:(0,ez.cn)("size-1.5 shrink-0 rounded-full",t?"animate-pulse bg-green-500":"border border-muted-foreground/50 bg-transparent"),"aria-label":t?"运行中":"空闲"}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate text-foreground",children:e.title||"(未命名)"}),n?(0,eb.jsxs)("span",{className:"shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground",title:n.title,children:["#",n.number]}):null,a?(0,eb.jsxs)("span",{className:"flex shrink-0 items-center gap-1 text-[11px] text-muted-foreground/70 [&_svg]:size-3",children:[(0,eb.jsx)(HM,{}),(0,eb.jsx)("span",{className:"max-w-32 truncate",children:a})]}):null,(0,eb.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground/60",children:t?"运行中":"空闲"})]},e.id)})})]})}function eo1({projectId:e,onOpenConversation:t}){let[n,r]=ew.useState([]),[a,i]=ew.useState(),[o,l]=ew.useState(),s=ew.useCallback(async()=>{try{let t=await eiS(e,!0);r(t.filter(e=>!!e.archivedAt))}catch{}},[e]);ew.useEffect(()=>{let t=!0,n=async()=>{try{let n=await eiS(e,!0);t&&r(n.filter(e=>!!e.archivedAt))}catch{}};n();let a=setInterval(()=>void n(),1e4);return()=>{t=!1,clearInterval(a)}},[e]);let c=ew.useCallback(async e=>{i(e.id);try{await sQ(e.id,e.ownerMachineId)}catch{}r(t=>t.filter(t=>t.id!==e.id)),i(void 0),s()},[s]),d=ew.useCallback(async e=>{i(e.id);try{await sZ(e.id,e.ownerMachineId)}catch{}r(t=>t.filter(t=>t.id!==e.id)),i(void 0),l(void 0),s()},[s]);return 0===n.length?null:(0,eb.jsxs)("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-4 shadow-sm",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground [&_svg]:shrink-0",children:[(0,eb.jsx)(bX,{className:"size-4"}),(0,eb.jsx)("span",{className:"text-[13px]",children:"已归档对话"}),(0,eb.jsx)("span",{className:"text-xs text-muted-foreground/60",children:n.length})]}),(0,eb.jsx)("ul",{className:"flex flex-col gap-1",children:n.map(n=>{let r=a===n.id;return(0,eb.jsxs)("li",{className:"group flex items-center gap-2 rounded-lg px-2 py-1.5 text-[13px] hover:bg-muted/50",children:[(0,eb.jsx)("button",{type:"button",disabled:!t,onClick:()=>t?.(e,n.id,n.ownerMachineId),title:n.title||"(未命名)",className:"min-w-0 flex-1 truncate text-left text-foreground disabled:cursor-default",children:n.title||"(未命名)"}),(0,eb.jsxs)("button",{type:"button",disabled:r,onClick:()=>void c(n),title:"取消归档",className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground opacity-0 transition hover:bg-background/70 hover:text-foreground group-hover:opacity-100 disabled:opacity-50 [&_svg]:size-3.5",children:[r?(0,eb.jsx)(eM,{className:"size-3.5 animate-spin"}):(0,eb.jsx)(eoG,{}),"取消归档"]}),(0,eb.jsxs)("button",{type:"button",disabled:r,onClick:()=>l(n.id),title:"删除",className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs text-hot-pink opacity-0 transition hover:bg-hot-pink/10 group-hover:opacity-100 disabled:opacity-50 [&_svg]:size-3.5",children:[(0,eb.jsx)(yn,{}),"删除"]}),o===n.id?(0,eb.jsx)(eo2,{title:n.title||"(未命名)",onCancel:()=>l(void 0),onConfirm:()=>void d(n)}):null]},n.id)})})]})}function eo2({title:e,onCancel:t,onConfirm:n}){return(0,eb.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",role:"dialog","aria-modal":"true",onClick:t,children:(0,eb.jsxs)("div",{className:"flex w-full max-w-sm flex-col gap-4 rounded-xl border border-border bg-card p-5 shadow-lg",onClick:e=>e.stopPropagation(),children:[(0,eb.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,eb.jsx)("h2",{className:"text-base font-semibold text-foreground",children:"删除会话"}),(0,eb.jsxs)("p",{className:"text-sm text-muted-foreground",children:["确认删除「",e,"」?此操作无法撤销。"]})]}),(0,eb.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,eb.jsx)("button",{type:"button",onClick:t,className:"rounded-md border border-border bg-background px-3 py-1.5 text-sm text-foreground hover:bg-muted",children:"取消"}),(0,eb.jsx)("button",{type:"button",onClick:n,className:"rounded-md bg-hot-pink px-3 py-1.5 text-sm font-medium text-white hover:opacity-90",children:"删除"})]})]})})}function eo5({icon:e,label:t,value:n,hint:r,loading:a,muted:i}){return(0,eb.jsxs)("div",{className:(0,ez.cn)("flex flex-col gap-2 rounded-xl border border-border bg-card p-4 shadow-sm",i&&"opacity-70"),children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground [&_svg]:shrink-0",children:[e,(0,eb.jsx)("span",{className:"text-[13px]",children:t})]}),(0,eb.jsx)("div",{className:"text-2xl font-semibold text-foreground",children:a?(0,eb.jsx)(eM,{className:"size-5 animate-spin text-muted-foreground"}):"number"==typeof n?n.toLocaleString("zh-CN"):n}),r?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground/70",children:r}):null]})}function eo4({loading:e,onRefresh:t}){return(0,eb.jsxs)("button",{type:"button",disabled:e,onClick:t,title:"刷新",className:"flex items-center gap-1 rounded-md px-1.5 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-50 [&_svg]:size-3",children:[(0,eb.jsx)(yt,{className:(0,ez.cn)(e&&"animate-spin")}),"刷新"]})}let eo3=["bg-sky-teal","bg-vivid-violet","bg-hot-pink","bg-amber-500","bg-emerald-500","bg-blue-500","bg-orange-500","bg-cyan-500"];function eo6(e,t){return"其他"===t?"bg-ash-gray":eo3[e%eo3.length]??"bg-ash-gray"}function eo8({stats:e,loading:t,onRefresh:n}){let r=!!e&&e.totalFiles>0,a=!!e&&!e.folder.trim();return(0,eb.jsxs)("div",{className:"flex min-h-32 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-sm",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground [&_svg]:shrink-0",children:[(0,eb.jsx)(eoX,{className:"size-4"}),(0,eb.jsx)("span",{className:"text-[13px]",children:"代码行数 · 分语言占比"})]}),(0,eb.jsx)(eo4,{loading:t,onRefresh:n})]}),t&&!e?(0,eb.jsx)("div",{className:"flex flex-1 items-center justify-center py-4",children:(0,eb.jsx)(eM,{className:"size-5 animate-spin text-muted-foreground"})}):r?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,eb.jsx)("span",{className:"text-2xl font-semibold text-foreground",children:e.totalLines.toLocaleString("zh-CN")}),(0,eb.jsxs)("span",{className:"text-xs text-muted-foreground/70",children:["行 · ",e.totalFiles.toLocaleString("zh-CN")," 个文件"]}),e.truncated?(0,eb.jsx)("span",{className:"rounded-full bg-amber-500/10 px-2 py-0.5 text-[11px] text-amber-500",children:"部分统计(已截断)"}):null]}),(0,eb.jsx)("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:e.languages.map((e,t)=>(0,eb.jsx)("div",{className:(0,ez.cn)("h-full",eo6(t,e.language)),style:{width:`${Math.max(e.pct,1)}%`},title:`${e.language} \xb7 ${e.pct}%`},e.language))}),(0,eb.jsx)("ul",{className:"flex flex-col gap-1.5",children:e.languages.slice(0,8).map((e,t)=>(0,eb.jsxs)("li",{className:"flex items-center gap-2 text-[13px]",children:[(0,eb.jsx)("span",{className:(0,ez.cn)("size-2.5 shrink-0 rounded-sm",eo6(t,e.language))}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate text-foreground",children:e.language}),(0,eb.jsxs)("span",{className:"shrink-0 text-xs text-muted-foreground/70",children:[e.lines.toLocaleString("zh-CN")," 行"]}),(0,eb.jsxs)("span",{className:"w-10 shrink-0 text-right text-xs font-medium text-muted-foreground",children:[e.pct,"%"]})]},e.language))})]}):(0,eb.jsx)("div",{className:"flex flex-1 items-center justify-center py-4",children:(0,eb.jsx)("span",{className:"rounded-full border border-border/60 bg-background px-3 py-1 text-xs text-muted-foreground",children:a?"未配置工作目录":"暂无代码统计"})})]})}function eo7({graph:e,loading:t,onRefresh:n}){let r=!!e&&e.commits.length>0,a=!!e&&!e.repoRoot.trim();return(0,eb.jsxs)("div",{className:"flex min-h-32 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-sm",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-muted-foreground [&_svg]:shrink-0",children:[(0,eb.jsx)(HM,{className:"size-4"}),(0,eb.jsx)("span",{className:"text-[13px]",children:"Git 提交图谱"}),e?.branch?(0,eb.jsx)("span",{className:"truncate rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground",children:e.branch}):null]}),(0,eb.jsx)(eo4,{loading:t,onRefresh:n})]}),t&&!e?(0,eb.jsx)("div",{className:"flex flex-1 items-center justify-center py-4",children:(0,eb.jsx)(eM,{className:"size-5 animate-spin text-muted-foreground"})}):r?(0,eb.jsx)("ul",{className:"flex max-h-[420px] flex-col overflow-y-auto pr-1",children:e.commits.map((t,n)=>{let r=n===e.commits.length-1,a=t.parents.length>1,i=t.refs.split(",").map(e=>e.trim().replace(/^HEAD ->\s*/,"").replace(/^tag:\s*/,"")).filter(Boolean);return(0,eb.jsxs)("li",{className:"flex gap-2.5",children:[(0,eb.jsxs)("div",{className:"flex w-3 shrink-0 flex-col items-center",children:[(0,eb.jsx)("span",{className:(0,ez.cn)("mt-1.5 flex size-3 items-center justify-center rounded-full",a?"bg-vivid-violet text-white [&_svg]:size-2":"border-2 border-sky-teal bg-background"),children:a?(0,eb.jsx)(eoY,{}):null}),r?null:(0,eb.jsx)("span",{className:"w-px flex-1 bg-border"})]}),(0,eb.jsxs)("div",{className:"min-w-0 flex-1 pb-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:t.shortSha}),i.map(e=>(0,eb.jsx)("span",{className:"shrink-0 rounded-full bg-sky-teal/10 px-1.5 py-0.5 text-[10px] font-medium text-sky-teal",children:e},e))]}),(0,eb.jsx)("p",{className:"truncate text-[13px] text-foreground",children:t.subject||"(无提交信息)"}),(0,eb.jsxs)("p",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground/70",children:[a?(0,eb.jsx)("span",{className:"text-vivid-violet",children:"合并"}):null,(0,eb.jsx)("span",{className:"truncate",children:t.author}),(0,eb.jsx)("span",{"aria-hidden":!0,children:"·"}),(0,eb.jsx)("span",{className:"shrink-0",children:function(e){let t=Date.parse(e);if(Number.isNaN(t))return e;let n=Date.now()-t;if(n<6e4)return"刚刚";if(n<36e5)return`${Math.floor(n/6e4)} 分钟前`;if(n<864e5)return`${Math.floor(n/36e5)} 小时前`;if(n<6048e5)return`${Math.floor(n/864e5)} 天前`;let r=new Date(t),a=String(r.getMonth()+1).padStart(2,"0"),i=String(r.getDate()).padStart(2,"0");return`${r.getFullYear()}-${a}-${i}`}(t.date)})]})]})]},t.sha)})}):(0,eb.jsx)("div",{className:"flex flex-1 items-center justify-center py-4",children:(0,eb.jsx)("span",{className:"rounded-full border border-border/60 bg-background px-3 py-1 text-xs text-muted-foreground",children:a?"非 Git 仓库":"暂无提交"})})]})}let eo9={delete:"Delete",empty:"Drop here",title:"Trash"};function ele({active:e=!1,items:t=[],labels:n,className:r,onDrop:a,onDelete:i,onItemRestore:o,...l}){let s={...eo9,...n},[c,d]=ew.useState(!1),u=ew.useRef(0),f=e||c||t.length>0;return ew.useEffect(()=>{e||(u.current=0,d(!1))},[e]),(0,eb.jsx)("div",{"data-slot":"trash-drop-zone","data-visible":f,"data-drag-inside":c,className:(0,ez.cn)("fixed top-4 left-1/2 z-50 -translate-x-1/2 transition-[opacity,transform] duration-300 ease-[cubic-bezier(.2,.8,.2,1)]",f?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-5 opacity-0",r),onDragEnter:function(e){e.preventDefault(),u.current+=1,d(!0)},onDragLeave:function(){u.current=Math.max(0,u.current-1),0===u.current&&d(!1)},onDragOver:function(e){e.preventDefault(),e.dataTransfer.dropEffect="move",d(!0)},onDrop:function(e){e.preventDefault(),e.stopPropagation(),u.current=0,d(!1);let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id")||e.dataTransfer.getData("text/plain"),n=e.dataTransfer.getData("text/plain")||t||"Dropped item",r=e.dataTransfer.getData("application/vnd.vantaloom.clip-kind");t&&a?.({id:t,title:n,meta:r,nativeEvent:e})},...l,children:(0,eb.jsx)("div",{className:(0,ez.cn)("min-w-12 overflow-hidden rounded-xl border-2 border-background bg-destructive text-destructive-foreground shadow-lg shadow-black/15 transition-[width,min-height,background-color,border-color,padding,box-shadow] duration-300","dark:border-destructive dark:bg-background dark:text-destructive",c||t.length>0?"w-64 border-dashed bg-destructive/12 p-2 text-destructive dark:bg-destructive/8":"flex size-12 items-center justify-center p-0"),children:c||t.length>0?(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsxs)("div",{className:"flex min-h-14 items-center justify-center gap-2 rounded-lg border border-dashed border-destructive/55 bg-destructive/8 px-3 text-sm font-medium text-destructive",children:[(0,eb.jsx)(yn,{className:"size-4"}),(0,eb.jsx)("span",{children:s.empty})]}),t.length>0?(0,eb.jsx)("div",{className:"grid max-h-36 gap-1 overflow-y-auto pr-1",children:t.map(e=>(0,eb.jsxs)("div",{className:"flex h-8 items-center gap-2 rounded-md border border-destructive/25 bg-background/80 px-2 text-foreground",children:[(0,eb.jsx)("button",{type:"button","aria-label":`Restore ${e.title}`,className:"flex size-5 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive",onClick:()=>o?.(e),children:(0,eb.jsx)(fV.XIcon,{className:"size-3.5"})}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",children:e.title}),e.meta?(0,eb.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:e.meta}):null]},e.id))}):null,t.length>0?(0,eb.jsx)("button",{type:"button",className:"h-8 rounded-md bg-destructive px-3 text-xs font-medium text-destructive-foreground transition-colors hover:bg-destructive/90 dark:border dark:border-destructive dark:bg-background dark:text-destructive dark:hover:bg-destructive/10",onClick:()=>i?.(t),children:s.delete}):null]}):(0,eb.jsx)(yn,{className:"size-5"})})})}function elt({hidden:e,items:t,trashItems:n,trashClipboardItems:r,draggingId:a,onDraggingChange:i,onItemsChange:o,onTrashItemsChange:l,onTrashClipboardItemsChange:s}){let c=ew.useRef(0),[d,u]=ew.useState(!1);return(ew.useEffect(()=>{u(!0)},[]),d)?(0,ix.createPortal)((0,eb.jsxs)("div",{className:(0,ez.cn)("pointer-events-none fixed inset-0 z-40 overflow-visible transition-opacity duration-200",e&&"opacity-0"),children:[(0,eb.jsx)(ele,{active:!e&&void 0!==a,items:e?[]:n,className:(0,ez.cn)(e&&"pointer-events-none"),labels:{delete:"删除",empty:"拖入暂存"},onDrop:({id:e,title:n,meta:r})=>{let a=t.find(t=>t.id===e);a&&(s(t=>({...t,[e]:a})),l(t=>t.some(t=>t.id===e)?t:[...t,{id:e,title:n,meta:r,icon:a.icon}]))},onDelete:e=>{let t=new Set(e.map(e=>e.id));l(e=>e.filter(e=>!t.has(e.id))),s(e=>{let n={...e};for(let e of t)delete n[e];return n})},onItemRestore:e=>{let n=r[e.id];n&&o([n,...t.filter(e=>e.id!==n.id)]),l(t=>t.filter(t=>t.id!==e.id)),s(t=>{let n={...t};return delete n[e.id],n})}}),t.length>0?(0,eb.jsx)("div",{className:(0,ez.cn)("pointer-events-auto absolute top-4 right-4 w-80 max-w-[calc(100vw-2rem)] transition-[opacity,transform] duration-200",e&&"pointer-events-none -translate-y-2 opacity-0"),children:(0,eb.jsx)(Z$,{items:t,title:"剪切板",labels:{empty:"剪切板为空",dragHandle:"拖拽卡片"},expansionDirection:"down-left",removeOnExternalDrop:!0,maxExpandedHeight:420,onItemDuplicate:(e,{item:n,index:r})=>{let a,i,l,s,d;return c.current+=1,a=n.payloads?.[qu],i=n.payloads?{...n.payloads}:void 0,l=n.payloads?.[qf],a&&i&&(i[qu]={...a,config:{...a.config}}),l&&i&&(i[qf]={...l,config:l.config?{...l.config}:l.config}),s={...n,id:`${n.id}-copy-${c.current}`,title:`${n.title} copy`,payloads:i,dragData:{...n.dragData,...a?{"application/vnd.vantaloom.dashboard-widget-config":JSON.stringify(a.config)}:{}}},void((d=[...t]).splice(r+1,0,s),o(d))},onItemsRemove:e=>o(e),onItemsReorder:e=>o(e),onItemDragStart:({item:e})=>i(e.id),onItemDragEnd:()=>i(void 0)})}):null]}),document.body):null}let eln=(0,ek.default)("languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]),elr=(0,ek.default)("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),ela=(0,ek.default)("log-out",[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]),eli=(0,ek.default)("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]),elo=(0,ek.default)("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]),ell=(0,ek.default)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);var els="Collapsible",[elc,eld]=cC(els),[elu,elf]=elc(els),elm=ew.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:a,disabled:i,onOpenChange:o,...l}=e,[s,c]=cT({prop:r,defaultProp:a??!1,onChange:o,caller:els});return(0,eb.jsx)(elu,{scope:n,disabled:i,contentId:cz(),open:s,onOpenToggle:ew.useCallback(()=>c(e=>!e),[c]),children:(0,eb.jsx)(cL.div,{"data-state":elv(s),"data-disabled":i?"":void 0,...l,ref:t})})});elm.displayName=els;var elh="CollapsibleTrigger",elp=ew.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,a=elf(elh,n);return(0,eb.jsx)(cL.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":elv(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...r,ref:t,onClick:cE(e.onClick,a.onOpenToggle)})});elp.displayName=elh;var elg="CollapsibleContent";ew.forwardRef((e,t)=>{let{forceMount:n,...r}=e,a=elf(elg,e.__scopeCollapsible);return(0,eb.jsx)(c2,{present:n||a.open,children:({present:e})=>(0,eb.jsx)(elx,{...r,ref:t,present:e})})}).displayName=elg;var elx=ew.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:a,...i}=e,o=elf(elg,n),[l,s]=ew.useState(r),c=ew.useRef(null),d=(0,cM.useComposedRefs)(t,c),u=ew.useRef(0),f=u.current,m=ew.useRef(0),h=m.current,p=o.open||l,g=ew.useRef(p),x=ew.useRef(void 0);return ew.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),cI(()=>{let e=c.current;if(e){x.current=x.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";let t=e.getBoundingClientRect();u.current=t.height,m.current=t.width,g.current||(e.style.transitionDuration=x.current.transitionDuration,e.style.animationName=x.current.animationName),s(r)}},[o.open,r]),(0,eb.jsx)(cL.div,{"data-state":elv(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!p,...i,ref:d,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":h?`${h}px`:void 0,...e.style},children:p&&a})});function elv(e){return e?"open":"closed"}var elb=e.i(91e3);function ely(e){let t=new Map(e.map(e=>[e.id,e])),n=new Map,r=[];for(let a of e){let e=a.forkOriginId;if(e&&t.has(e)){let t=n.get(e)??[];t.push(a),n.set(e,t)}else r.push(a)}return{byId:t,childrenOf:n,roots:r}}function elw(e){let{childrenOf:t,roots:n}=ely(e),r=[],a=e=>{for(let n of(r.push(e),t.get(e.id)??[]))a(n)};for(let e of n)a(e);return r}function elj(e,t,n,r,a){let i=new Set(e);if("range"===n&&a){let n=r.indexOf(a),o=r.indexOf(t);if(-1!==n&&-1!==o){let[a,l]=n<o?[n,o]:[o,n],s=!e.has(t);for(let e=a;e<=l;e++){let t=r[e];t&&(s?i.add(t):i.delete(t))}return i}}return i.has(t)?i.delete(t):i.add(t),i}function elk(e,t,n=!0){let r=ew.useRef(e);r.current=e;let a=ew.useRef(!1);ew.useEffect(()=>{if(!n)return;let e=!1,i=async()=>{if(!e&&!a.current){a.current=!0;try{await r.current()}finally{a.current=!1}}};i();let o=setInterval(()=>{"visible"===document.visibilityState&&i()},t),l=()=>{"visible"===document.visibilityState&&i()};return document.addEventListener("visibilitychange",l),()=>{e=!0,clearInterval(o),document.removeEventListener("visibilitychange",l)}},[t,n])}let elN={"new-canvas":"canvas","all-canvases":"canvas","open-recent-canvas":"canvas","new-project":"canvas","project-overview":"canvas","project-settings":"canvas","project-conversation":"canvas",kanban:"canvas","new-agent-conversation":"agent","open-recent-conversation":"agent",preferences:"settings","preferences-models":"settings","preferences-agents":"settings","system-general":"settings","network-downloads":"settings","preferences-model-routes":"settings","preferences-model-groups":"settings","preferences-agent-config":"settings","preferences-subagent-config":"settings","preferences-cc-engine-config":"settings","preferences-assets":"settings","preferences-layout":"settings","preferences-official-extensions":"settings","network-topology":"settings","network-settings":"settings","search-settings":"settings","system-downloads":"settings","check-update":"settings","balance-usage":"settings",feedback:"settings",account:"settings"};function elS({navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,activeProjectId:a,onItemSelect:i,onOpenConversation:o,onOpenProjectCanvas:l,onOpenProjectOverview:s,onOpenProjectKanban:c,onOpenProjectSettings:d,onNewProjectConversation:u,onOpenProjectConversation:f,onNewProject:m,onOpenConversationSettings:h,onConversationDeleted:p,onAccountSettings:g,subagentTree:x,activeSubagentPath:v,onOpenSubagent:b,hideCanvas:y,className:w}){let j=elN[n]??(elG.some(e=>e.items.some(e=>e.id===n))?"settings":y?"agent":"canvas"),[k,N]=ew.useState(j);ew.useEffect(()=>{N(j)},[j]);let S=t.find(e=>e.id===k),C=ew.useRef(null),M=ew.useRef(new Map),[E,I]=ew.useState(null),[P,O]=ew.useState(!1),z=ew.useCallback(()=>{let e=C.current,t=M.current.get(k);if(!e||!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();I({left:r.left-n.left,top:r.top-n.top,width:r.width,height:r.height})},[k]);return ew.useEffect(()=>{z();let e=window.requestAnimationFrame(()=>O(!0)),t=C.current,n=null;return t&&"u">typeof ResizeObserver&&(n=new ResizeObserver(z)).observe(t),window.addEventListener("resize",z),()=>{window.cancelAnimationFrame(e),n?.disconnect(),window.removeEventListener("resize",z)}},[z]),(0,eb.jsxs)("aside",{"data-slot":"flat-sidebar",className:(0,ez.cn)("flex h-full w-72 flex-col rounded-xl border border-border bg-sidebar p-3 text-sidebar-foreground shadow-sm",w),children:[(0,eb.jsxs)("nav",{ref:C,className:"relative mb-5 flex gap-1 rounded-lg bg-muted/70 p-1",children:[E?(0,eb.jsx)("span",{"aria-hidden":!0,className:(0,ez.cn)("pointer-events-none absolute top-0 left-0 z-0 rounded-md border border-border/50 bg-background shadow-sm",P&&"transition-[transform,width,height] duration-200 ease-out"),style:{transform:`translate(${E.left}px, ${E.top}px)`,width:E.width,height:E.height}}):null,e.map(e=>{let t=e.id===k;return(0,eb.jsxs)("button",{ref:t=>{t?M.current.set(e.id,t):M.current.delete(e.id)},type:"button",onClick:()=>N(e.id),className:(0,ez.cn)("relative z-10 flex flex-1 items-center justify-center gap-1.5 rounded-md py-1.5 text-[13px] font-medium transition-colors [&_svg]:size-4",t?"text-foreground":"text-muted-foreground hover:bg-background/50 hover:text-foreground"),children:[e.icon,(0,eb.jsx)("span",{className:"truncate",children:e.label})]},e.id)})]}),"canvas"===k?(0,eb.jsx)(elI,{activeProjectId:a,activeConversationId:r,hideCanvas:y,onOpenProjectCanvas:l,onOpenProjectOverview:s,onOpenProjectKanban:c,onOpenProjectSettings:d,onNewProjectConversation:u,onOpenProjectConversation:f,onNewProject:m,onOpenConversation:o,onOpenConversationSettings:h,onConversationDeleted:p,subagentTree:x,activeSubagentPath:v,onOpenSubagent:b}):"agent"===k?(0,eb.jsx)(elT,{activeConversationId:r,onItemSelect:i,onOpenConversation:o,onOpenConversationSettings:h,onConversationDeleted:p,subagentTree:x,activeSubagentPath:v,onOpenSubagent:b}):(0,eb.jsx)(elW,{content:S,activeWorkspace:n,onItemSelect:i}),(0,eb.jsx)(el0,{onItemSelect:i,onAccountSettings:g})]})}let elC=ew.useLayoutEffect;function elM({open:e,className:t,children:n}){let r=ew.useRef(null),[a,i]=ew.useState(e),[o,l]=ew.useState(e?"auto":0),s=ew.useRef(!0);return ew.useEffect(()=>{e&&i(!0)},[e]),elC(()=>{if(s.current){s.current=!1,l(e?"auto":0);return}let t=r.current;if(!t)return;let n=t.scrollHeight;if(e){l(n);let e=window.setTimeout(()=>l("auto"),200);return()=>window.clearTimeout(e)}l(n);let a=window.requestAnimationFrame(()=>l(0));return()=>window.cancelAnimationFrame(a)},[e]),(0,eb.jsx)("div",{"aria-hidden":!e,className:(0,ez.cn)("overflow-hidden transition-[height] ease-out",e?"duration-200":"duration-150",t),style:{height:o},children:(0,eb.jsx)("div",{ref:r,children:a?n:null})})}function elE(e){let[t,n]=ew.useState(0),r=ew.useRef(e);return ew.useEffect(()=>{e&&!r.current&&n(e=>e+1),r.current=e},[e]),t}function elI({activeProjectId:e,activeConversationId:t,hideCanvas:n,onOpenProjectCanvas:r,onOpenProjectOverview:a,onOpenProjectKanban:i,onOpenProjectSettings:o,onNewProjectConversation:l,onOpenProjectConversation:s,onNewProject:c,onOpenConversation:d,onOpenConversationSettings:u,onConversationDeleted:f,subagentTree:m,activeSubagentPath:h,onOpenSubagent:p}){let{projects:g,loading:x,refresh:v}=function(){let[e,t]=ew.useState([]),[n,r]=ew.useState(!0),a=ew.useRef(!0),i=ew.useCallback(async()=>{try{let e=await eiv();if(!a.current)return;let n=[...e].sort((e,t)=>t.updatedAt>e.updatedAt?1:-1);t(n)}catch{}finally{a.current&&r(!1)}},[]);return ew.useEffect(()=>{a.current=!0;let e=()=>void i();return window.addEventListener(eix,e),()=>{a.current=!1,window.removeEventListener(eix,e)}},[i]),elk(i,1e4),{projects:e,loading:n,refresh:()=>void i()}}(),b=x&&0===g.length;return(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("div",{className:"mb-6 space-y-0.5",children:(0,eb.jsx)("div",{className:"vtl-stagger-item",style:{animationDelay:"0ms"},children:(0,eb.jsx)(elZ,{icon:elo,label:en5.canvasNew,onClick:()=>c?.()})})}),(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto vtl-scrollbar-hidden pr-1",children:(0,eb.jsx)("div",{className:"space-y-0.5",children:b?(0,eb.jsx)(elJ,{}):0===g.length?(0,eb.jsx)("p",{className:"px-3 py-1.5 text-[13px] text-muted-foreground/60",children:en5.projectEmpty}):g.map((c,g)=>(0,eb.jsx)("div",{className:"vtl-stagger-item",style:{animationDelay:`${25*Math.min(g+1,12)}ms`},children:(0,eb.jsx)(elP,{project:c,active:c.id===e,activeConversationId:t,hideCanvas:n,onOpenProjectCanvas:r,onOpenProjectOverview:a,onOpenProjectKanban:i,onOpenProjectSettings:o,onNewProjectConversation:l,onOpenProjectConversation:s,onOpenConversation:d,onOpenConversationSettings:u,onConversationDeleted:f,onConversationsChanged:v,subagentTree:m,activeSubagentPath:h,onOpenSubagent:p})},c.id))})})]})}function elP({project:e,active:t,activeConversationId:n,hideCanvas:r,onOpenProjectCanvas:a,onOpenProjectOverview:i,onOpenProjectKanban:o,onOpenProjectSettings:l,onNewProjectConversation:s,onOpenProjectConversation:c,onOpenConversation:d,onOpenConversationSettings:u,onConversationDeleted:f,onConversationsChanged:m,subagentTree:h,activeSubagentPath:p,onOpenSubagent:g}){let[x,v]=ew.useState(t),[b,y]=ew.useState([]),[w,j]=ew.useState(0),k=ew.useCallback(async()=>{try{let t=await eos(e.id);j(t.length)}catch{}},[e.id]),[N,S]=ew.useState(()=>new Set),C=ew.useRef(null),M=N.size>0,E=ew.useCallback(async()=>{try{let t=await eiS(e.id);y(t)}catch{}},[e.id]);elk(E,1e4,x),elk(k,1e4,x);let I=ew.useCallback(async e=>{try{await sZ(e.id,e.ownerMachineId)}catch{}f?.(e.id),y(t=>t.filter(t=>t.id!==e.id)),m?.()},[f,m]),P=ew.useCallback(async e=>{try{await sJ(e.id,e.ownerMachineId)}catch{}y(t=>t.filter(t=>t.id!==e.id)),m?.()},[m]),O=ew.useMemo(()=>elw(b),[b]),z=ew.useMemo(()=>O.map(e=>e.id),[O]),A=ew.useCallback((e,t)=>{S(n=>elj(n,e,t,z,C.current)),C.current=e},[z]),T=ew.useCallback(()=>{S(new Set),C.current=null},[]);ew.useEffect(()=>{S(e=>{if(0===e.size)return e;let t=new Set(b.map(e=>e.id)),n=!1,r=new Set;for(let a of e)t.has(a)?r.add(a):n=!0;return n?r:e})},[b]);let R=ew.useCallback(async()=>{let e=b.filter(e=>N.has(e.id));await Promise.all(e.map(e=>sJ(e.id,e.ownerMachineId).catch(()=>{}))),T(),await E(),m?.()},[b,N,T,E,m]),D=ew.useCallback(async()=>{let e=b.filter(e=>N.has(e.id));for(let t of(await Promise.all(e.map(e=>sZ(e.id,e.ownerMachineId).catch(()=>{}))),e))f?.(t.id);T(),await E(),m?.()},[b,N,T,E,f,m]),_=ew.useCallback(async t=>{try{let n=await ct(t.id,void 0,t.ownerMachineId);c?c(e.id,n.conversation.id,n.conversation.ownerMachineId):d(n.conversation.id,n.conversation.ownerMachineId),m?.()}catch{}},[d,c,e.id,m]),L=ew.useCallback((t,n)=>{c?c(e.id,t,n):d(t,n)},[c,d,e.id]),$=ew.useMemo(()=>(function(e,t){let{childrenOf:n,roots:r}=ely(e),a=new Set((t.activeSubagentPath??[]).map(e=>e.id)),i=t.activeSubagentPath?.[t.activeSubagentPath.length-1]?.id,o=(e,r)=>{let l=e.id!==t.activeConversationId||(t.subagentTree?.length??0)===0?null:(0,eb.jsx)(elD,{nodes:t.subagentTree??[],depth:0,ancestors:[],activeIds:a,activeLeafId:i,onOpen:t.onOpenSubagent});return(0,eb.jsxs)(ew.Fragment,{children:[(0,eb.jsx)(elU,{conversation:e,depth:r,active:e.id===t.activeConversationId,onOpenConversation:t.onOpenConversation,onOpenConversationSettings:t.onOpenConversationSettings,onDelete:t.onDelete,onFork:t.onFork,onArchive:t.onArchive?()=>t.onArchive?.(e):void 0,selectionMode:t.selectionMode,selected:t.selectedIds?.has(e.id),onToggleSelect:t.onToggleSelect?n=>t.onToggleSelect?.(e.id,n):void 0}),l?(0,eb.jsx)("div",{style:r>0?{marginLeft:14*r}:void 0,children:l}):null,(n.get(e.id)??[]).map(e=>o(e,r+1))]},e.id)};return r.map((e,t)=>(0,eb.jsx)("div",{className:"vtl-stagger-item space-y-0.5",style:{animationDelay:`${25*Math.min(t+3,12)}ms`},children:o(e,0)},e.id))})(b,{activeConversationId:n,onOpenConversation:L,onOpenConversationSettings:u,onDelete:I,onFork:_,onArchive:P,selectionMode:M,selectedIds:N,onToggleSelect:A,subagentTree:h,activeSubagentPath:p,onOpenSubagent:g}),[b,n,L,u,I,_,P,M,N,A,h,p,g]),F=elE(x);return(0,eb.jsxs)(elm,{open:x,onOpenChange:v,children:[(0,eb.jsxs)("div",{className:(0,ez.cn)("group flex items-center rounded-lg text-[13px] transition-colors",t?"bg-muted text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground"),children:[(0,eb.jsx)(elp,{asChild:!0,children:(0,eb.jsx)("button",{type:"button","aria-label":x?"收起工程":"展开工程",className:"shrink-0 rounded-md p-1.5 pl-2 text-muted-foreground hover:text-foreground",onClick:e=>e.stopPropagation(),children:(0,eb.jsx)(pt,{className:(0,ez.cn)("size-4 transition-transform",x?"rotate-0":"-rotate-90")})})}),(0,eb.jsxs)("button",{type:"button",title:e.title,onClick:()=>{v(!0),i?.(e.id)},className:"flex min-w-0 flex-1 items-center gap-2 rounded-lg py-2 pr-3 text-left",children:[(0,eb.jsx)(uU,{className:"size-4 shrink-0 text-muted-foreground"}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.title}),w>0?(0,eb.jsx)("span",{title:`${w} 项待审批`,className:"shrink-0 rounded-full bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-amber-600 dark:bg-amber-400/20 dark:text-amber-300",children:w}):null,t&&(0,eb.jsx)(elQ,{active:!0})]})]}),(0,eb.jsx)(elM,{open:x,className:"mt-0.5",children:(0,eb.jsx)("div",{className:"ml-[1.125rem] border-l border-border/60 pl-1.5",children:(0,eb.jsxs)("div",{className:"space-y-0.5",children:[r?null:(0,eb.jsx)("div",{className:"vtl-stagger-item",style:{animationDelay:"0ms"},children:(0,eb.jsx)(elO,{icon:(0,eb.jsx)(uU,{className:"size-4"}),label:en5.projectCanvas,onClick:()=>a?.(e.id,e.canvasId)})}),(0,eb.jsx)("div",{className:"vtl-stagger-item",style:{animationDelay:"25ms"},children:(0,eb.jsx)(elO,{icon:(0,eb.jsx)(elr,{className:"size-4"}),label:en5.projectKanban,onClick:()=>o?.(e.id)})}),M?(0,eb.jsx)(el$,{count:N.size,archived:!1,onArchive:()=>void R(),onDelete:()=>void D(),onCancel:T}):null,$,(0,eb.jsxs)("button",{type:"button",onClick:()=>s?.(e.id),title:en5.projectNewConversation,className:"flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-[13px] text-muted-foreground/80 transition-colors hover:bg-muted hover:text-foreground",children:[(0,eb.jsx)(lY,{className:"size-4 shrink-0"}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",children:en5.projectNewConversation})]})]},F)})})]})}function elO({icon:e,label:t,onClick:n}){return(0,eb.jsxs)("button",{type:"button",onClick:n,className:"flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-[13px] text-foreground/80 transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-muted-foreground",children:[e,(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t})]})}let elz="__all__",elA={status:"all",location:elz,sort:"recent"};function elT({activeConversationId:e,onItemSelect:t,onOpenConversation:n,onOpenConversationSettings:r,onConversationDeleted:a,subagentTree:i,activeSubagentPath:o,onOpenSubagent:l}){let[s,c]=ew.useState(elA),d="archived"===s.status,{recents:u,refresh:f,loading:m,machineNames:h}=function(e){let[t,n]=ew.useState([]),[r,a]=ew.useState(!0),[i,o]=ew.useState({}),l=ew.useRef(!0),s=ew.useCallback(async()=>{try{let{machineNames:t}=await sT({includeArchived:e,onPartial:e=>{l.current&&(n([...e].filter(e=>!e.projectId).sort((e,t)=>t.updatedAt>e.updatedAt?1:-1)),a(!1))}});if(!l.current)return;o(t)}catch{}finally{l.current&&a(!1)}},[e]);return ew.useEffect(()=>(l.current=!0,()=>{l.current=!1}),[]),elk(s,1e4),{recents:t,refresh:()=>void s(),loading:r,machineNames:i}}(d),[p,g]=ew.useState(()=>new Set),x=ew.useRef(null),v=ew.useMemo(()=>{let e=new Set;for(let t of u)e.add(t.ownerMachineId||sC);return Array.from(e)},[u]),b=ew.useCallback(e=>sM(e)?"本机":h[e]??e,[h]),y=ew.useMemo(()=>{let e=u.filter(e=>{let t=!0===e.running,n=!!e.archivedAt;if("archived"===s.status){if(!n)return!1}else if(n)return!1;return("running"!==s.status||!!t)&&("idle"!==s.status||!t)&&(s.location===elz||(e.ownerMachineId||sC)===s.location)});return"name"===s.sort?e.sort((e,t)=>e.title.localeCompare(t.title,"zh-CN",{sensitivity:"base"})):e.sort((e,t)=>t.updatedAt>e.updatedAt?1:-1),e},[u,s]),w=ew.useMemo(()=>y.filter(e=>!0===e.running),[y]),j=ew.useMemo(()=>y.filter(e=>!0!==e.running),[y]),k=s.status!==elA.status||s.location!==elA.location||s.sort!==elA.sort,N=m&&0===u.length,S=ew.useCallback(async e=>{try{await sZ(e.id,e.ownerMachineId)}catch{}a?.(e.id),f()},[a,f]),C=ew.useCallback(async e=>{try{let t=await ct(e.id,void 0,e.ownerMachineId);await f(),n(t.conversation.id,t.conversation.ownerMachineId)}catch{}},[f,n]),M=ew.useCallback(async e=>{try{await sJ(e.id,e.ownerMachineId)}catch{}f()},[f]),E=ew.useCallback(async e=>{try{await sQ(e.id,e.ownerMachineId)}catch{}f()},[f]),I=ew.useMemo(()=>[...elw(w),...elw(j)],[w,j]),P=ew.useMemo(()=>I.map(e=>e.id),[I]),O=ew.useCallback((e,t)=>{g(n=>elj(n,e,t,P,x.current)),x.current=e},[P]),z=ew.useCallback(()=>{g(new Set),x.current=null},[]);ew.useEffect(()=>{g(e=>{if(0===e.size)return e;let t=new Set(I.map(e=>e.id)),n=!1,r=new Set;for(let a of e)t.has(a)?r.add(a):n=!0;return n?r:e})},[I]);let A=ew.useMemo(()=>I.filter(e=>p.has(e.id)),[I,p]),T=ew.useCallback(async()=>{await Promise.all(A.map(e=>(d?sQ(e.id,e.ownerMachineId):sJ(e.id,e.ownerMachineId)).catch(()=>{}))),z(),f()},[A,d,z,f]),R=ew.useCallback(async()=>{for(let e of(await Promise.all(A.map(e=>sZ(e.id,e.ownerMachineId).catch(()=>{}))),A))a?.(e.id);z(),f()},[A,z,f,a]),D=p.size>0,_=ew.useMemo(()=>new Set((o??[]).map(e=>e.id)),[o]),L=o?.[o.length-1]?.id,$=ew.useCallback(t=>t!==e||(i?.length??0)===0?null:(0,eb.jsx)(elD,{nodes:i??[],depth:0,ancestors:[],activeIds:_,activeLeafId:L,onOpen:l}),[e,i,_,L,l]),F=ew.useCallback(t=>{let{childrenOf:a,roots:i}=ely(t),o=(t,i)=>{let l=$(t.id);return(0,eb.jsxs)(ew.Fragment,{children:[(0,eb.jsx)(elU,{conversation:t,depth:i,active:t.id===e,onOpenConversation:n,onOpenConversationSettings:r,onDelete:S,onFork:C,onArchive:t.archivedAt?void 0:()=>M(t),onUnarchive:t.archivedAt?()=>E(t):void 0,selectionMode:D,selected:p.has(t.id),onToggleSelect:e=>O(t.id,e)}),l?(0,eb.jsx)("div",{style:i>0?{marginLeft:14*i}:void 0,children:l}):null,(a.get(t.id)??[]).map(e=>o(e,i+1))]},t.id)};return i.map(e=>o(e,0))},[$,e,n,r,S,C,M,E,D,p,O]),B=ew.useMemo(()=>F(w),[F,w]),V=ew.useMemo(()=>F(j),[F,j]);return(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("div",{className:"vtl-stagger-item mb-6 space-y-0.5",style:{animationDelay:"0ms"},"data-tour":"new-conversation",children:(0,eb.jsxs)(wh,{children:[(0,eb.jsx)(wg,{asChild:!0,children:(0,eb.jsx)(elZ,{icon:tl,label:en5.conversationNew,onClick:()=>t({item:{id:"new-agent-conversation"}})})}),(0,eb.jsx)(wN,{className:"min-w-44",children:(0,eb.jsxs)(wS,{onSelect:()=>t({item:{id:"import-claude-session"}}),children:[(0,eb.jsx)(bJ,{}),(0,eb.jsx)("span",{className:"flex-1",children:"导入 Claude 会话"})]})})]})}),D?(0,eb.jsx)(el$,{count:p.size,archived:d,onArchive:()=>void T(),onDelete:()=>void R(),onCancel:z}):null,(0,eb.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto vtl-scrollbar-hidden pr-1",children:[w.length>0?(0,eb.jsxs)("div",{className:"vtl-stagger-item mb-4",style:{animationDelay:"25ms"},children:[(0,eb.jsxs)("div",{className:"mb-2 flex items-center gap-2 px-3",children:[(0,eb.jsx)("span",{className:"size-1.5 shrink-0 rounded-full bg-green-500"}),(0,eb.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"正在运行"})]}),(0,eb.jsx)("div",{className:"space-y-0.5",children:B})]}):null,(0,eb.jsxs)("div",{className:"vtl-stagger-item mb-2 flex items-center justify-between px-3",style:{animationDelay:"50ms"},children:[(0,eb.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"最近"}),(0,eb.jsx)(elF,{filter:s,onChange:c,active:k,locations:v,locationLabel:b})]}),(0,eb.jsx)("div",{className:"space-y-0.5",children:N?(0,eb.jsx)(elJ,{}):0===j.length?(0,eb.jsx)("p",{className:"px-3 py-1.5 text-[13px] text-muted-foreground/60",children:d?"暂无已归档对话":k?"没有符合筛选条件的对话":"暂无对话"}):V})]})]})}function elR(e,t){return!!(e.running||t.has(e.id))||(e.children??[]).some(e=>elR(e,t))}let elD=ew.memo(function e({nodes:t,depth:n,ancestors:r,activeIds:a,activeLeafId:i,onOpen:o}){let l=t.filter(e=>elR(e,a));return 0===l.length?null:(0,eb.jsx)("div",{className:"space-y-0.5",children:l.map(t=>{let l=Uh(t.subagentType),s=l.Icon,c=[...r,{id:t.id,ownerMachineId:t.ownerMachineId,name:t.subagentName,subagentType:t.subagentType}],d=t.id===i,u=t.children??[],f=u.some(e=>elR(e,a));return(0,eb.jsxs)("div",{children:[(0,eb.jsxs)("button",{type:"button",className:(0,ez.cn)("flex w-full items-center gap-1.5 rounded-md py-1 pr-2 text-left text-xs transition-colors",d?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),style:{paddingLeft:18+14*n},onClick:()=>o?.(c),title:t.subagentName||l.label,children:[(0,eb.jsx)("span",{className:"shrink-0 text-muted-foreground/40",children:"└"}),(0,eb.jsx)(s,{className:(0,ez.cn)("size-3.5 shrink-0",l.color)}),(0,eb.jsx)("span",{className:"truncate",children:t.subagentName||`${l.label}子代理`}),t.running?(0,eb.jsx)(eM,{className:"ml-auto size-3 shrink-0 animate-spin text-muted-foreground"}):null]}),(0,eb.jsx)(elM,{open:f,children:(0,eb.jsx)(e,{nodes:u,depth:n+1,ancestors:c,activeIds:a,activeLeafId:i,onOpen:o})})]},t.id)})})},(e,t)=>e.nodes===t.nodes&&e.activeIds===t.activeIds&&e.activeLeafId===t.activeLeafId&&e.depth===t.depth&&e.ancestors===t.ancestors&&e.onOpen===t.onOpen),el_={all:"全部",running:"运行中",idle:"空闲",archived:"已归档"},elL={recent:"最近活动",name:"名称"};function el$({count:e,archived:t,onArchive:n,onDelete:r,onCancel:a}){let[i,o]=ew.useState(!1);return(0,eb.jsxs)("div",{className:"mb-3 flex items-center gap-1.5 rounded-lg border border-border bg-muted/60 px-2.5 py-1.5 text-[13px]",children:[(0,eb.jsxs)("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:["已选 ",e," 项"]}),(0,eb.jsxs)("button",{type:"button",onClick:n,title:t?"取消归档":"归档",className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-foreground/80 transition-colors hover:bg-background/70 hover:text-foreground [&_svg]:size-3.5",children:[t?(0,eb.jsx)(eoG,{}):(0,eb.jsx)(bX,{}),t?"取消归档":"归档"]}),(0,eb.jsxs)("button",{type:"button",onClick:()=>o(!0),title:"删除",className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-destructive transition-colors hover:bg-destructive/10 [&_svg]:size-3.5",children:[(0,eb.jsx)(yn,{}),"删除"]}),(0,eb.jsx)("button",{type:"button",onClick:a,className:"shrink-0 rounded-md px-2 py-1 text-muted-foreground transition-colors hover:bg-background/70 hover:text-foreground",children:"取消"}),(0,eb.jsx)(ux,{open:i,onOpenChange:o,children:(0,eb.jsxs)(uR,{children:[(0,eb.jsxs)(uD,{children:[(0,eb.jsx)(uL,{children:"删除会话"}),(0,eb.jsxs)(u$,{children:["确认删除选中的 ",e," 个对话?此操作无法撤销。"]})]}),(0,eb.jsxs)(u_,{children:[(0,eb.jsx)(uB,{children:"取消"}),(0,eb.jsx)(uF,{variant:"destructive",onClick:r,children:"删除"})]})]})})]})}function elF({filter:e,onChange:t,active:n,locations:r,locationLabel:a}){let i=sv(),o=e.location===elz?"全部":a(e.location),l=(0,eb.jsxs)("button",{type:"button",title:"筛选","aria-label":"筛选",className:(0,ez.cn)("relative rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground",n&&"text-foreground"),children:[(0,eb.jsx)(enW,{className:"size-4"}),n?(0,eb.jsx)("span",{className:"absolute -right-0.5 -top-0.5 size-2 rounded-full border border-sidebar bg-primary"}):null]});return i?(0,eb.jsxs)(x5,{direction:"bottom",children:[(0,eb.jsx)(dZ,{asChild:!0,children:l}),(0,eb.jsxs)(x3,{children:[(0,eb.jsx)(x6,{children:(0,eb.jsx)(x8,{children:"筛选与排序"})}),(0,eb.jsxs)("div",{className:"max-h-[60vh] overflow-y-auto px-4 pb-6",children:[(0,eb.jsx)(elB,{title:"状态",children:Object.keys(el_).map(n=>(0,eb.jsx)(elV,{label:el_[n],selected:e.status===n,onSelect:()=>t({...e,status:n})},n))}),(0,eb.jsxs)(elB,{title:"运行位置",children:[(0,eb.jsx)(elV,{label:"全部",selected:e.location===elz,onSelect:()=>t({...e,location:elz})}),r.map(n=>(0,eb.jsx)(elV,{label:a(n),selected:e.location===n,onSelect:()=>t({...e,location:n})},n))]}),(0,eb.jsx)(elB,{title:"排序",children:Object.keys(elL).map(n=>(0,eb.jsx)(elV,{label:elL[n],selected:e.sort===n,onSelect:()=>t({...e,sort:n})},n))}),n?(0,eb.jsx)("button",{type:"button",onClick:()=>t(elA),className:"mt-4 flex h-11 w-full items-center justify-center rounded-lg border border-border text-[15px] text-foreground/80 transition-colors hover:bg-muted hover:text-foreground",children:"重置筛选"}):null]})]})]}):(0,eb.jsxs)(wA,{children:[(0,eb.jsx)(wR,{asChild:!0,children:l}),(0,eb.jsxs)(wG,{align:"end",sideOffset:4,className:"min-w-56",children:[(0,eb.jsx)(wZ,{children:"筛选与排序"}),(0,eb.jsxs)(wK,{children:[(0,eb.jsxs)(w0,{children:[(0,eb.jsx)("span",{className:"flex-1",children:"状态"}),(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:el_[e.status]})]}),(0,eb.jsx)(w1,{children:(0,eb.jsxs)(wB,{value:e.status,onValueChange:n=>t({...e,status:n}),children:[(0,eb.jsx)(wY,{value:"all",children:"全部"}),(0,eb.jsx)(wY,{value:"running",children:"运行中"}),(0,eb.jsx)(wY,{value:"idle",children:"空闲"}),(0,eb.jsx)(wY,{value:"archived",children:"已归档"})]})})]}),(0,eb.jsxs)(wK,{children:[(0,eb.jsxs)(w0,{children:[(0,eb.jsx)("span",{className:"flex-1",children:"运行位置"}),(0,eb.jsx)("span",{className:"max-w-24 truncate text-xs text-muted-foreground",children:o})]}),(0,eb.jsx)(w1,{className:"max-h-72 overflow-y-auto",children:(0,eb.jsxs)(wB,{value:e.location,onValueChange:n=>t({...e,location:n}),children:[(0,eb.jsx)(wY,{value:elz,children:"全部"}),r.map(e=>(0,eb.jsx)(wY,{value:e,children:(0,eb.jsx)("span",{className:"truncate",children:a(e)})},e))]})})]}),(0,eb.jsx)(wJ,{}),(0,eb.jsx)(wZ,{children:"排序"}),(0,eb.jsxs)(wB,{value:e.sort,onValueChange:n=>t({...e,sort:n}),children:[(0,eb.jsx)(wY,{value:"recent",children:elL.recent}),(0,eb.jsx)(wY,{value:"name",children:elL.name})]}),n?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(wJ,{}),(0,eb.jsx)(wX,{onSelect:()=>t(elA),children:(0,eb.jsx)("span",{className:"flex-1",children:"重置筛选"})})]}):null]})]})}function elB({title:e,children:t}){return(0,eb.jsxs)("div",{className:"mb-4 last:mb-0",children:[(0,eb.jsx)("p",{className:"mb-1 px-1 text-xs font-medium text-muted-foreground",children:e}),(0,eb.jsx)("div",{className:"space-y-0.5",children:t})]})}function elV({label:e,selected:t,onSelect:n}){return(0,eb.jsxs)("button",{type:"button",role:"radio","aria-checked":t,onClick:n,className:(0,ez.cn)("flex h-11 w-full items-center gap-2 rounded-lg px-3 text-left text-[15px] transition-colors",t?"bg-muted text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground"),children:[(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e}),t?(0,eb.jsx)(h6,{className:"size-4 shrink-0 text-primary"}):null]})}function elH({engine:e}){if("vantaloom"===e)return null;let t="claude-code"===e;return(0,eb.jsxs)("span",{title:t?"Claude Code":"reclaude",className:(0,ez.cn)("relative inline-flex shrink-0 select-none items-center justify-center rounded px-1 py-px text-[9px] font-semibold leading-none tracking-wide",t?"bg-violet-500/15 text-violet-600 dark:bg-violet-400/20 dark:text-violet-300":"bg-sky-500/15 text-sky-600 dark:bg-sky-400/20 dark:text-sky-300"),children:[t?"CC":"RC",!t&&(0,eb.jsx)("span",{className:"absolute -right-0.5 -top-0.5 size-1.5 rounded-full bg-sky-400 dark:bg-sky-300"})]})}let elU=ew.memo(function({conversation:e,active:t,depth:n=0,onOpenConversation:r,onOpenConversationSettings:a,onDelete:i,onFork:o,onArchive:l,onUnarchive:s,selectionMode:c,selected:d,onToggleSelect:u}){let f=!0===e.running,m=e.settings?.engine??"vantaloom",h=!!e.projectId,p="vantaloom"!==m?(0,eb.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden",children:[(0,eb.jsx)(elH,{engine:m}),(0,eb.jsx)("span",{className:"truncate",children:e.title})]}):void 0;return(0,eb.jsx)(elq,{title:f?`${e.title} \xb7 运行中`:e.title,label:e.title,labelNode:p,active:t,running:f,depth:n,onOpen:()=>r(e.id,e.ownerMachineId),onOpenSettings:a&&!h?()=>a(e.id,e.ownerMachineId):void 0,onDelete:i?()=>i(e):void 0,onFork:o?()=>o(e):void 0,onArchive:l,onUnarchive:s,selectionMode:c,selected:d,onToggleSelect:u,deleteLabel:"删除会话"})}),elq=ew.memo(function({title:e,label:t,labelNode:n,active:r,running:a,depth:i=0,onOpen:o,onOpenSettings:l,onDelete:s,onFork:c,onArchive:d,onUnarchive:u,selectionMode:f,selected:m,onToggleSelect:h,deleteLabel:p="删除"}){let[g,x]=ew.useState(!1),v=!!h,b=!!(l||s||c||d||u),y=i>0,w=(0,eb.jsxs)(eb.Fragment,{children:[l?(0,eb.jsxs)(wS,{onSelect:()=>l(),children:[(0,eb.jsx)(era,{}),(0,eb.jsx)("span",{className:"flex-1",children:"打开设置界面"})]}):null,c?(0,eb.jsxs)(wS,{onSelect:()=>c(),children:[(0,eb.jsx)(HM,{}),(0,eb.jsx)("span",{className:"flex-1",children:"分支对话"})]}):null,d?(0,eb.jsxs)(wS,{onSelect:()=>d(),children:[(0,eb.jsx)(bX,{}),(0,eb.jsx)("span",{className:"flex-1",children:"归档"})]}):null,u?(0,eb.jsxs)(wS,{onSelect:()=>u(),children:[(0,eb.jsx)(eoG,{}),(0,eb.jsx)("span",{className:"flex-1",children:"取消归档"})]}):null,s?(0,eb.jsxs)(wS,{variant:"destructive",onSelect:()=>x(!0),children:[(0,eb.jsx)(yn,{}),(0,eb.jsx)("span",{className:"flex-1",children:p})]}):null]}),j=(0,eb.jsxs)("div",{className:(0,ez.cn)("group relative flex items-center rounded-lg text-[13px] transition-colors animate-in fade-in-0 slide-in-from-left-1 duration-200",m?"bg-primary/10 text-foreground":r?"bg-muted text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground"),style:y?{marginLeft:14*i}:void 0,children:[f&&v?(0,eb.jsx)("button",{type:"button","aria-label":m?"取消选择":"选择","aria-pressed":m,onClick:e=>{e.preventDefault(),e.stopPropagation(),h?.(e.shiftKey?"range":"toggle")},className:(0,ez.cn)("ml-2 flex size-4 shrink-0 items-center justify-center rounded border",m?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/50 bg-transparent"),children:m?(0,eb.jsx)(h6,{className:"size-3"}):null}):null,(0,eb.jsxs)("button",{type:"button",title:e,onClick:e=>{if(v&&(f||e.metaKey||e.ctrlKey||e.shiftKey)){e.preventDefault(),h?.(e.shiftKey?"range":"toggle");return}o()},className:"flex min-w-0 flex-1 items-center gap-3 rounded-lg px-3 py-2 text-left",children:[y?(0,eb.jsx)("span",{"aria-hidden":!0,className:"h-4 w-0.5 shrink-0 rounded-full bg-primary/40"}):null,a?(0,eb.jsx)("span",{className:"size-1.5 shrink-0 animate-pulse rounded-full bg-green-500","aria-label":"运行中"}):(0,eb.jsx)(elQ,{active:r}),n??(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t})]}),b&&!f?(0,eb.jsxs)(wA,{children:[(0,eb.jsx)(wR,{asChild:!0,children:(0,eb.jsx)("button",{type:"button","aria-label":"更多操作",className:"mr-1 shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity hover:bg-background/70 hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100 aria-expanded:opacity-100",children:(0,eb.jsx)(lG,{className:"size-4"})})}),(0,eb.jsxs)(wG,{align:"end",sideOffset:4,className:"min-w-44",children:[l?(0,eb.jsxs)(wX,{onSelect:()=>l(),children:[(0,eb.jsx)(era,{}),(0,eb.jsx)("span",{className:"flex-1",children:"打开设置界面"})]}):null,c?(0,eb.jsxs)(wX,{onSelect:()=>c(),children:[(0,eb.jsx)(HM,{}),(0,eb.jsx)("span",{className:"flex-1",children:"分支对话"})]}):null,d?(0,eb.jsxs)(wX,{onSelect:()=>d(),children:[(0,eb.jsx)(bX,{}),(0,eb.jsx)("span",{className:"flex-1",children:"归档"})]}):null,u?(0,eb.jsxs)(wX,{onSelect:()=>u(),children:[(0,eb.jsx)(eoG,{}),(0,eb.jsx)("span",{className:"flex-1",children:"取消归档"})]}):null,s?(0,eb.jsxs)(wX,{variant:"destructive",onSelect:()=>x(!0),children:[(0,eb.jsx)(yn,{}),(0,eb.jsx)("span",{className:"flex-1",children:p})]}):null]})]}):null]});return(0,eb.jsxs)(eb.Fragment,{children:[b?(0,eb.jsxs)(wh,{children:[(0,eb.jsx)(wg,{asChild:!0,children:j}),(0,eb.jsx)(wN,{className:"min-w-44",children:w})]}):j,s?(0,eb.jsx)(ux,{open:g,onOpenChange:x,children:(0,eb.jsxs)(uR,{children:[(0,eb.jsxs)(uD,{children:[(0,eb.jsx)(uL,{children:p}),(0,eb.jsxs)(u$,{children:["确认删除「",t,"」?此操作无法撤销。"]})]}),(0,eb.jsxs)(u_,{children:[(0,eb.jsx)(uB,{children:"取消"}),(0,eb.jsx)(uF,{variant:"destructive",onClick:()=>s(),children:"删除"})]})]})}):null]})});function elW({content:e,activeWorkspace:t,onItemSelect:n}){let r=(e?.sections??[]).flatMap(e=>e.items);return(0,eb.jsx)(jP,{className:"min-h-0 flex-1",viewportClassName:"pr-1",children:(0,eb.jsx)("div",{className:"space-y-0.5",children:r.map(e=>"preferences"===e.id?(0,eb.jsx)(elX,{activeWorkspace:t,onItemSelect:n},e.id):(0,eb.jsx)(elK,{id:e.id,icon:e.icon,label:e.label,active:e.id===t,onItemSelect:n},e.id))})})}function elK({id:e,icon:t,label:n,active:r,onItemSelect:a}){return(0,eb.jsxs)("button",{type:"button",onClick:()=>a({item:{id:e}}),className:(0,ez.cn)("flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",r?"bg-muted text-foreground [&_svg]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&_svg]:text-muted-foreground"),children:[t,(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",children:n}),r&&(0,eb.jsx)(elQ,{active:!0})]})}let elG=[{id:"model",title:"模型设置",icon:(0,eb.jsx)(uK,{}),items:[{id:"preferences-models",label:"模型",icon:(0,eb.jsx)(h3,{})},{id:"preferences-agents",label:"代理",icon:(0,eb.jsx)(uH,{})},{id:"preferences-cc-engine-config",label:"CC 引擎",icon:(0,eb.jsx)(uK,{})}]},{id:"prefs",title:"偏好设置",icon:(0,eb.jsx)(era,{}),items:[{id:"preferences-assets",label:"扩展 / 资产",icon:(0,eb.jsx)(kV,{})},{id:"preferences-layout",label:"布局排版",icon:(0,eb.jsx)(elr,{})},{id:"preferences-official-extensions",label:"官方扩展",icon:(0,eb.jsx)(qz,{})}]},{id:"system",title:"系统设置",icon:(0,eb.jsx)(Yw,{}),items:[{id:"system-general",label:"系统与账户",icon:(0,eb.jsx)(Yw,{})},{id:"network-downloads",label:"网络与下载",icon:(0,eb.jsx)(enH,{})},{id:"search-settings",label:"搜索设置",icon:(0,eb.jsx)(vu,{})}]}];function elX({activeWorkspace:e,onItemSelect:t}){return(0,eb.jsx)(eb.Fragment,{children:elG.map((n,r)=>(0,eb.jsx)("div",{className:"vtl-stagger-item",style:{animationDelay:`${25*Math.min(r,12)}ms`},children:(0,eb.jsx)(elY,{title:n.title,icon:n.icon,items:n.items,activeWorkspace:e,onItemSelect:t})},n.id))})}function elY({title:e,icon:t,items:n,activeWorkspace:r,onItemSelect:a}){let i=n.some(e=>e.id===r),[o,l]=ew.useState(!0),s=elE(o);return(0,eb.jsxs)(elm,{open:o,onOpenChange:l,children:[(0,eb.jsx)(elp,{asChild:!0,children:(0,eb.jsxs)("button",{type:"button",className:(0,ez.cn)("flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",i?"text-foreground [&>svg:first-child]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&>svg:first-child]:text-muted-foreground"),children:[t,(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e}),(0,eb.jsx)(pt,{className:(0,ez.cn)("text-muted-foreground transition-transform",o?"rotate-0":"-rotate-90")})]})}),(0,eb.jsx)(elM,{open:o,className:"mt-0.5",children:(0,eb.jsx)("div",{className:"space-y-0.5",children:n.map((e,t)=>{let n=e.id===r;return(0,eb.jsxs)("button",{type:"button",onClick:()=>a({item:{id:e.id}}),style:{animationDelay:`${25*Math.min(t,12)}ms`},className:(0,ez.cn)("vtl-stagger-item flex w-full items-center gap-3 rounded-lg py-2 pl-9 pr-3 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",n?"bg-muted text-foreground [&_svg]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&_svg]:text-muted-foreground"),children:[e.icon,(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.label}),n&&(0,eb.jsx)(elQ,{active:!0})]},e.id)})},s)})]})}let elZ=ew.forwardRef(function({icon:e,label:t,onClick:n,...r},a){return(0,eb.jsxs)("button",{ref:a,type:"button",onClick:n,className:"flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm text-foreground transition-colors hover:bg-muted",...r,children:[(0,eb.jsx)(e,{className:"size-4 shrink-0 text-muted-foreground"}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t})]})});function elJ(){return(0,eb.jsxs)("div",{className:"flex items-center justify-center gap-2 px-3 py-3 text-[13px] text-muted-foreground/70",role:"status","aria-live":"polite",children:[(0,eb.jsx)(eM,{className:"size-4 animate-spin"}),(0,eb.jsx)("span",{children:"加载中…"})]})}function elQ({active:e}){return(0,eb.jsx)("span",{className:(0,ez.cn)("size-1.5 shrink-0 rounded-full",e?"bg-primary":"border border-muted-foreground/50 bg-transparent")})}function el0({onItemSelect:e,onAccountSettings:t}){let{user:n}=ti(),r=n?.name??en2.product,a=(n?.name??"V").slice(0,1).toUpperCase();return(0,eb.jsx)("div",{className:"mt-auto pt-3",children:(0,eb.jsxs)(wA,{children:[(0,eb.jsx)(wR,{asChild:!0,children:(0,eb.jsxs)("button",{type:"button","data-tour":"account-button",className:"flex w-full items-center justify-between rounded-xl p-2 transition-colors hover:bg-muted",children:[(0,eb.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,eb.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full border border-border/60 bg-muted text-[10px] font-semibold text-foreground",children:a}),(0,eb.jsx)("span",{className:"truncate text-sm text-foreground",children:r})]}),(0,eb.jsx)(h7,{className:"size-4 shrink-0 -rotate-90 text-muted-foreground"})]})}),(0,eb.jsxs)(wG,{side:"top",align:"start",sideOffset:8,className:"w-[var(--radix-dropdown-menu-trigger-width)] min-w-60",children:[n?.email&&(0,eb.jsx)(wZ,{className:"truncate font-normal text-muted-foreground",children:n.email}),(0,eb.jsxs)(wX,{onSelect:()=>e({item:{id:"preferences"}}),children:[(0,eb.jsx)(era,{}),(0,eb.jsx)("span",{className:"flex-1",children:"设置"}),(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:"Ctrl,"})]}),(0,eb.jsxs)(wX,{disabled:!0,children:[(0,eb.jsx)(eln,{}),(0,eb.jsx)("span",{className:"flex-1",children:"语言"}),(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:"中文"})]}),(0,eb.jsxs)(wX,{disabled:!0,children:[(0,eb.jsx)(qx,{}),(0,eb.jsx)("span",{className:"flex-1",children:"获取帮助"})]}),(0,eb.jsx)(wJ,{}),(0,eb.jsxs)(wX,{onSelect:()=>{t?t():e({item:{id:"account"}})},children:[(0,eb.jsx)(Xb,{}),(0,eb.jsx)("span",{className:"flex-1",children:"Hub 账户"})]}),(0,eb.jsx)(el2,{}),n&&(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(wJ,{}),(0,eb.jsx)(el5,{})]})]})]})})}let el1=["light","dark","jelly"];function el2(){let{resolvedTheme:e,setTheme:t}=(0,m1.useTheme)(),[n,r]=ew.useState(elb.defaultAppearanceTheme);ew.useEffect(()=>{let e=window.localStorage.getItem(elb.appearanceThemeStorageKey)??elb.defaultAppearanceTheme;r(e),(0,elb.applyAppearanceTheme)({theme:e})},[]);let a=n===elb.jellyAppearanceTheme?"jelly":"dark"===e?"dark":"light",i=el1[(el1.indexOf(a)+1)%el1.length]??"light";function o(e){r(e),window.localStorage.setItem(elb.appearanceThemeStorageKey,e),(0,elb.applyAppearanceTheme)({theme:e})}let l="dark"===a?eli:ell;return(0,eb.jsxs)(wX,{onSelect:e=>{e.preventDefault(),function(){if("jelly"===i){t("dark"),o(elb.jellyAppearanceTheme);return}o(elb.defaultAppearanceTheme),t(i)}()},children:[(0,eb.jsx)(l,{}),(0,eb.jsx)("span",{className:"flex-1",children:en2.theme}),(0,eb.jsx)("span",{className:"text-xs capitalize text-muted-foreground",children:a})]})}function el5(){let{logout:e}=ti();return(0,eb.jsxs)(wX,{variant:"destructive",onSelect:()=>{e().then(()=>{window.location.reload()})},children:[(0,eb.jsx)(ela,{}),(0,eb.jsx)("span",{className:"flex-1",children:"退出登录"})]})}function el4({navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,activeProjectId:a,onItemSelect:i,onOpenConversation:o,onOpenProjectCanvas:l,onOpenProjectOverview:s,onOpenProjectKanban:c,onOpenProjectSettings:d,onNewProjectConversation:u,onOpenProjectConversation:f,onNewProject:m,onOpenConversationSettings:h,onConversationDeleted:p,onAccountSettings:g,subagentTree:x,activeSubagentPath:v,onOpenSubagent:b,title:y,trailing:w,children:j}){let[k,N]=ew.useState(!1),S=ew.useCallback(()=>N(!1),[]),C=ew.useCallback(e=>{S(),i(e)},[S,i]),M=ew.useCallback((e,t)=>{S(),o(e,t)},[S,o]),E=ew.useCallback(e=>{S(),b?.(e)},[S,b]);return(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(el3,{onMenuClick:()=>N(!0),title:y,trailing:w}),(0,eb.jsx)(x5,{open:k,onOpenChange:N,direction:"left",children:(0,eb.jsxs)(x3,{className:"w-[85vw] max-w-xs",children:[(0,eb.jsx)(x8,{className:"sr-only",children:"导航"}),(0,eb.jsx)(elS,{hideCanvas:!0,navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,activeProjectId:a,onItemSelect:C,onOpenConversation:M,onOpenCanvas:()=>{},onOpenProjectCanvas:(e,t)=>{S(),l?.(e,t)},onOpenProjectOverview:e=>{S(),s?.(e)},onOpenProjectKanban:e=>{S(),c?.(e)},onOpenProjectSettings:e=>{S(),d?.(e)},onNewProjectConversation:e=>{S(),u?.(e)},onOpenProjectConversation:(e,t,n)=>{S(),f?.(e,t,n)},onNewProject:()=>{S(),m?.()},onOpenConversationSettings:(e,t)=>{S(),h?.(e,t)},onConversationDeleted:p,onAccountSettings:()=>{S(),g?.()},subagentTree:x,activeSubagentPath:v,onOpenSubagent:E,className:"h-full w-full rounded-none border-0 p-3 pt-[max(0.75rem,env(safe-area-inset-top))] shadow-none"})]})}),(0,eb.jsx)(etu,{value:()=>N(!0),children:j})]})}function el3({onMenuClick:e,title:t,trailing:n,className:r}){return(0,eb.jsxs)("header",{className:(0,ez.cn)("fixed inset-x-0 top-0 z-40 flex h-12 items-center gap-1 border-b border-border bg-sidebar/95 px-1.5 pt-[env(safe-area-inset-top)] backdrop-blur",r),style:{height:"calc(3rem + env(safe-area-inset-top))"},children:[(0,eb.jsx)("button",{type:"button","aria-label":"展开导航",onClick:e,className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-foreground/80 transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-5",children:(0,eb.jsx)(cy,{})}),t?(0,eb.jsx)("div",{className:"min-w-0 flex-1 truncate text-center text-sm font-medium text-foreground",children:t}):(0,eb.jsx)("div",{className:"min-w-0 flex-1"}),(0,eb.jsx)("div",{className:"flex shrink-0 items-center",children:n})]})}let el6=(0,ek.default)("message-square-text",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]),el8=[{id:"canvas",label:en5.canvas,icon:(0,eb.jsx)(uU,{})},{id:"agent",label:"智能体",icon:(0,eb.jsx)(uH,{})},{id:"settings",label:en5.settings,icon:(0,eb.jsx)(era,{})}],el7=[{id:"canvas",title:en5.canvas,description:"节点画布工作区。",sections:[{id:"canvases",title:en5.canvas,items:[{id:"open-recent-canvas",label:en5.canvasRecent,icon:(0,eb.jsx)(uU,{})},{id:"new-canvas",label:en5.canvasNew,icon:(0,eb.jsx)(lY,{})},{id:"all-canvases",label:en5.canvasAll,icon:(0,eb.jsx)(uG,{})}]}]},{id:"agent",title:"智能体",description:"Agent 对话工作区。",sections:[{id:"conversations",title:"Agent 对话",items:[{id:"open-recent-conversation",label:en5.conversationRecent,icon:(0,eb.jsx)(el6,{})},{id:"new-agent-conversation",label:en5.conversationNew,icon:(0,eb.jsx)(uH,{})}]}]},{id:"settings",title:en5.settings,description:"系统、工作组和用量配置。",sections:[{id:"settings",items:[{id:"preferences",label:"设置",icon:(0,eb.jsx)(era,{})}]}]}],el9=(0,ek.default)("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]),ese=(0,ek.default)("unplug",[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]]),est=(0,ek.default)("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]),esn=(0,ek.default)("wifi-off",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);function esr(){return(0,eb.jsx)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:(0,eb.jsx)(esa,{})})})}function esa(){let{user:e,machine:t,logout:n,unbind:r,refreshUser:a}=ti(),[i,o]=ew.useState(!1),[l,s]=ew.useState(!1),[c,d]=ew.useState(t),[u,f]=ew.useState(!1),[m,h]=ew.useState(""),[p,g]=ew.useState(!1),[x,v]=ew.useState(null);async function b(){o(!0);try{await eY("online");let e=eH();d(e),await a()}catch{}finally{o(!1)}}async function y(){let e=m.trim();if(!e)return void v("名称不能为空");g(!0),v(null);try{let t=await eJ(e);d(e=>e?{...e,name:t}:e),f(!1)}catch(e){v(e instanceof Error?e.message:"重命名失败")}finally{g(!1)}}async function w(){s(!0);try{await r()}catch{s(!1)}}async function j(){await n()}return ew.useEffect(()=>{d(t)},[t]),e?(0,eb.jsxs)("div",{className:"grid gap-6 text-foreground","data-tour":"hub-account",children:[(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"账户信息"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"你的 Vantaloom Hub 账户详情。"}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,eb.jsx)("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-full bg-primary/10",children:(0,eb.jsx)("span",{className:"text-base font-semibold text-primary",children:e.name.charAt(0).toUpperCase()})}),(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("p",{className:"truncate text-sm font-medium",children:e.name}),(0,eb.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:e.email})]})]}),(0,eb.jsxs)(Vp,{variant:"outline",className:"shrink-0",children:[(0,eb.jsx)(kB,{className:"mr-1 size-3"}),"已验证"]})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)("span",{className:"text-sm text-muted-foreground",children:"用户 ID"}),(0,eb.jsxs)("code",{className:"rounded bg-muted px-2 py-0.5 font-mono text-xs",children:[e.id.slice(0,8),"..."]})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)("span",{className:"text-sm text-muted-foreground",children:"注册时间"}),(0,eb.jsx)("span",{className:"text-sm",children:new Date(e.createdAt).toLocaleDateString("zh-CN")})]})]}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"设备绑定"}),(0,eb.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"此设备已自动注册到你的 Hub 账户。"})]}),c?(0,eb.jsxs)(eO.Button,{variant:"outline",size:"sm",className:"shrink-0",onClick:b,disabled:i,children:[i?(0,eb.jsx)(eM,{className:"animate-spin"}):(0,eb.jsx)(yt,{}),i?"刷新中...":"刷新状态"]}):null]}),c?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,eb.jsxs)("div",{className:"min-w-0 flex-1",children:[u?(0,eb.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,eb.jsx)(eA,{value:m,onChange:e=>h(e.target.value),maxLength:64,autoFocus:!0,placeholder:"机器名称",className:"h-8 text-sm",onKeyDown:e=>{"Enter"===e.key&&y(),"Escape"===e.key&&f(!1)}}),(0,eb.jsx)(eO.Button,{size:"icon-sm",variant:"ghost",className:"size-8 shrink-0",onClick:()=>void y(),disabled:p,"aria-label":"保存名称",children:p?(0,eb.jsx)(eM,{className:"animate-spin"}):(0,eb.jsx)(h6,{})}),(0,eb.jsx)(eO.Button,{size:"icon-sm",variant:"ghost",className:"size-8 shrink-0",onClick:()=>f(!1),disabled:p,"aria-label":"取消",children:(0,eb.jsx)(fV.XIcon,{})})]}):(0,eb.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,eb.jsx)("p",{className:"truncate text-sm font-medium",children:c.name}),(0,eb.jsx)("button",{type:"button",onClick:function(){h(c?.name??""),v(null),f(!0)},title:"重命名",className:"shrink-0 rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:(0,eb.jsx)(UH,{className:"size-3.5"})})]}),(0,eb.jsxs)("p",{className:"truncate text-xs text-muted-foreground",children:[c.platform," / ",c.arch]})]}),(0,eb.jsxs)(Vp,{variant:"online"===c.status?"default":"secondary",className:"shrink-0 gap-1",children:["online"===c.status?(0,eb.jsx)(est,{className:"size-3"}):(0,eb.jsx)(esn,{className:"size-3"}),"online"===c.status?"在线":"离线"]})]}),x?(0,eb.jsx)("p",{className:"text-xs text-destructive",children:x}):null,(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)("span",{className:"text-sm text-muted-foreground",children:"设备 ID"}),(0,eb.jsxs)("code",{className:"rounded bg-muted px-2 py-0.5 font-mono text-xs",children:[c.id.slice(0,8),"..."]})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)("span",{className:"text-sm text-muted-foreground",children:"连接方式"}),(0,eb.jsx)("span",{className:"text-sm",children:c.connectivity||"直连"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)("span",{className:"text-sm text-muted-foreground",children:"本机 IP"}),(0,eb.jsx)("code",{className:"rounded bg-muted px-2 py-0.5 font-mono text-xs",children:c.localIp})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)("span",{className:"text-sm text-muted-foreground",children:"最后心跳"}),(0,eb.jsx)("span",{className:"text-sm",children:new Date(c.lastHeartbeat).toLocaleString("zh-CN")})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)("span",{className:"text-sm text-muted-foreground",children:"注册时间"}),(0,eb.jsx)("span",{className:"text-sm",children:new Date(c.createdAt).toLocaleString("zh-CN")})]})]}):(0,eb.jsxs)("div",{className:"flex flex-col items-center gap-3 py-6 text-center",children:[(0,eb.jsx)(esn,{className:"size-8 text-muted-foreground/40"}),(0,eb.jsxs)("div",{children:[(0,eb.jsx)("p",{className:"text-sm font-medium",children:"设备未绑定"}),(0,eb.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"设备注册异常,请尝试重新登录"})]})]})]}),(0,eb.jsx)(esi,{}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"hub-account-danger",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold text-destructive",children:"危险操作"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"以下操作不可逆,请谨慎执行。"}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("p",{className:"text-sm font-medium",children:"解除设备绑定"}),(0,eb.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"将此设备从你的 Hub 账户中移除,并退出登录。设备数据不会受到影响。"})]}),(0,eb.jsxs)(ux,{children:[(0,eb.jsx)(uv,{asChild:!0,children:(0,eb.jsxs)(eO.Button,{variant:"destructive",size:"sm",className:"shrink-0",children:[(0,eb.jsx)(ese,{}),"解除绑定"]})}),(0,eb.jsxs)(uR,{children:[(0,eb.jsxs)(uD,{children:[(0,eb.jsx)(uL,{children:"确认解除设备绑定?"}),(0,eb.jsx)(u$,{children:"此操作将从你的 Hub 账户中移除当前设备,并退出登录。你可以随时重新登录并绑定设备。"})]}),(0,eb.jsxs)(u_,{children:[(0,eb.jsx)(uB,{children:"取消"}),(0,eb.jsx)(uF,{onClick:w,disabled:l,className:"bg-destructive text-white hover:bg-destructive/90",children:l?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(eM,{className:"animate-spin"}),"处理中..."]}):"确认解除"})]})]})]})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("p",{className:"text-sm font-medium",children:"退出登录"}),(0,eb.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"退出当前 Hub 账户但保留设备在云端的注册。下次登录时无需重新绑定。"})]}),(0,eb.jsxs)(eO.Button,{variant:"outline",size:"sm",className:"shrink-0",onClick:j,children:[(0,eb.jsx)(ela,{}),"退出登录"]})]})]})]}):null}function esi(){let[e,t]=ew.useState(""),[n,r]=ew.useState(""),[a,i]=ew.useState(""),[o,l]=ew.useState(!1),[s,c]=ew.useState(null);async function d(){if(c(null),n.length<8)return void c({kind:"err",text:"新密码至少 8 位"});if(n!==a)return void c({kind:"err",text:"两次输入的新密码不一致"});l(!0);try{await eQ(e,n),c({kind:"ok",text:"密码已更新"}),t(""),r(""),i("")}catch(e){c({kind:"err",text:e instanceof Error?e.message:"修改失败,请重试"})}finally{l(!1)}}return(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)(el9,{className:"size-4 text-muted-foreground"}),(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"修改密码"})]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"更改你的 Vantaloom Hub 登录密码。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(eA,{type:"password",placeholder:"当前密码",autoComplete:"current-password",value:e,onChange:e=>t(e.target.value)}),(0,eb.jsx)(eA,{type:"password",placeholder:"新密码(至少 8 位)",autoComplete:"new-password",value:n,onChange:e=>r(e.target.value)}),(0,eb.jsx)(eA,{type:"password",placeholder:"确认新密码",autoComplete:"new-password",value:a,onChange:e=>i(e.target.value)})]}),s?(0,eb.jsx)("p",{className:"ok"===s.kind?"text-xs text-primary":"text-xs text-destructive",children:s.text}):null,(0,eb.jsx)("div",{className:"flex justify-end",children:(0,eb.jsx)(eO.Button,{size:"sm",onClick:d,disabled:o||!e||!n,children:o?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(eM,{className:"animate-spin"}),"保存中..."]}):"更新密码"})})]})}let eso=[1e4,3e4,12e4,3e5,6e5];function esl(e){return{compression:{...e.compression},summary:{...e.summary},approval:{...e.approval},behavior:{maxToolCalls:e.behavior?.maxToolCalls??0,retryCount:e.behavior?.retryCount??0,retryDelaysMs:e.behavior?.retryDelaysMs??[],loopMaxIterations:e.behavior?.loopMaxIterations??25,loopHookWait:e.behavior?.loopHookWait??"defer",loopHookWaitTimeoutSec:e.behavior?.loopHookWaitTimeoutSec??0}}}function ess(e){return(e&&e.length?e:eso).map(e=>Math.round(e/1e3)).join(", ")}function esc(){let[e,t]=ew.useState(null),[n,r]=ew.useState([]),[a,i]=ew.useState(!0),[o,l]=ew.useState(!1),[s,c]=ew.useState(""),[d,u]=ew.useState(!1),[f,m]=ew.useState(null),h=ew.useRef(null),[p,g]=ew.useState(""),[x,v]=ew.useState("context");function b(e,n){t(t=>t?{...t,[e]:{...t[e],...n}}:t),u(!0),m(null)}async function y(){if(e&&!o){l(!0),c("");try{let n=await ks({compression:e.compression,summary:e.summary,approval:e.approval,behavior:e.behavior});h.current=n,t(esl(n)),g(ess(n.behavior?.retryDelaysMs)),u(!1),m(Date.now())}catch(e){c(e instanceof Error?e.message:"Save failed")}finally{l(!1)}}}if(ew.useEffect(()=>{!async function(){try{let[e,n]=await Promise.all([kl(),vE()]);h.current=e,t(esl(e)),g(ess(e.behavior?.retryDelaysMs)),r(n.models)}catch(e){c(e instanceof Error?e.message:"Failed to load config")}finally{i(!1)}}()},[]),a)return(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取代理配置"});if(!e)return(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"读取失败"}),(0,eb.jsx)(etJ,{children:s||"无法加载代理配置"})]});let w=s?(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"错误"}),(0,eb.jsx)(etJ,{children:s})]}):null,j=(0,eb.jsxs)("div",{className:"mx-auto grid w-full max-w-2xl gap-6",children:[(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-compression",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"压缩上下文"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"当对话 token 达到模型上下文窗口的指定百分比时自动压缩。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"自动压缩阈值"}),(0,eb.jsxs)("span",{className:"text-sm tabular-nums text-muted-foreground",children:[e.compression.autoThresholdPercent,"%"]})]}),(0,eb.jsx)(enx,{value:[e.compression.autoThresholdPercent],onValueChange:([e])=>b("compression",{autoThresholdPercent:e}),min:0,max:100,step:5}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"0% 表示禁用自动压缩。建议设为 70%-85%。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"压缩模型"}),(0,eb.jsx)(esd,{models:n,value:e.compression.modelRef,onValueChange:e=>b("compression",{modelRef:e}),placeholder:"使用主模型"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"用于执行上下文压缩的模型。留空则使用当前对话主模型。"})]})]}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-summary",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"对话摘要"}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"对话标题摘要"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"每轮对话结束后自动更新对话标题。"})]}),(0,eb.jsx)(bG,{checked:e.summary.enableTitleSummary,onCheckedChange:e=>b("summary",{enableTitleSummary:e})})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"轮次标题摘要"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"为每轮 agent 操作生成摘要标题。"})]}),(0,eb.jsx)(bG,{checked:e.summary.enableRoundSummary,onCheckedChange:e=>b("summary",{enableRoundSummary:e})})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"摘要模型"}),(0,eb.jsx)(esd,{models:n,value:e.summary.modelRef,onValueChange:e=>b("summary",{modelRef:e}),placeholder:"使用主模型"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"用于生成对话摘要的模型。留空则使用当前对话主模型。"})]})]})]}),k=(0,eb.jsxs)("div",{className:"mx-auto grid w-full max-w-2xl gap-6",children:[(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"自动重试与工具调用上限"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"控制本机(vantaloom)agent 单次运行的工具调用上限,以及请求失败后的自动重试。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"最大工具调用次数"}),(0,eb.jsx)(eA,{type:"number",min:0,value:e.behavior.maxToolCalls,onChange:e=>b("behavior",{maxToolCalls:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"单次运行累计调用工具达到该次数后强制暂停(可点击“继续”恢复)。设为 0 表示不限次(默认)。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"自动重试次数"}),(0,eb.jsx)(eA,{type:"number",min:0,value:e.behavior.retryCount,onChange:e=>b("behavior",{retryCount:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"模型/服务商请求失败时自动重试的次数(仅在尚未产出内容时重试,避免重复输出)。设为 0 表示不重试。"})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"重试间隔梯度(秒)"}),(0,eb.jsx)(eA,{value:p,onChange:e=>{let t=e.currentTarget.value;g(t),b("behavior",{retryDelaysMs:t.split(/[,,\s]+/).map(e=>Number.parseInt(e.trim(),10)).filter(e=>Number.isFinite(e)&&e>0).map(e=>1e3*e)})},placeholder:"10, 30, 120, 300, 600"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"用逗号分隔每次重试的等待秒数(指数级递增),例如 10, 30, 120, 300, 600。超出列表长度时使用最后一项。留空使用内置默认梯度。"})]})]}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"循环模式"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"开启循环模式后,每轮运行结束会自动注入“继续”并续跑,直到执行树中没有未完成(且未阻塞)的任务。以下设置控制其自动续跑的上限与遇到钩子时的处理方式。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"最大循环次数"}),(0,eb.jsx)(eA,{type:"number",min:1,value:e.behavior.loopMaxIterations,onChange:e=>b("behavior",{loopMaxIterations:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"连续自动续跑达到该次数后强制暂停以避免无限计费(发送新消息可继续)。设为 0 表示使用内置默认值(25)。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"钩子处理"}),(0,eb.jsx)(x7,{value:e.behavior.loopHookWait??"defer",onValueChange:e=>b("behavior",{loopHookWait:"wait"===e?"wait":"defer"}),title:"钩子处理",className:"w-full",options:[{value:"defer",label:"有钩子运行时暂停"},{value:"wait",label:"等待钩子完成后继续"}]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"当存在会自动唤醒本对话的钩子(如进程退出、定时器)时:选择“暂停”则交由钩子驱动;选择“等待”则等钩子完成后再继续循环。"})]}),"wait"===e.behavior.loopHookWait?(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"等待超时(秒,0 = 直到无钩子)"}),(0,eb.jsx)(eA,{type:"number",min:0,value:e.behavior.loopHookWaitTimeoutSec??0,onChange:e=>b("behavior",{loopHookWaitTimeoutSec:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"在“等待”模式下,最多等待多少秒后无论钩子是否完成都继续。设为 0 表示一直等到没有钩子在运行(仍受 30 分钟的硬性上限约束)。"})]}):null]})]}),N=(0,eb.jsx)("div",{className:"mx-auto grid w-full max-w-2xl gap-6",children:(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-approval",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"命令审批"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"在 Auto 权限模式下,使用 AI 模型审批 Agent 发起的命令是否可以自动执行。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"审批模型"}),(0,eb.jsx)(esd,{models:n,value:e.approval.modelRef,onValueChange:e=>b("approval",{modelRef:e}),placeholder:"未配置(全部放行)"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"留空表示 Auto 模式下不进行 AI 审批,所有非危险命令自动放行。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"审批提示词"}),(0,eb.jsx)(w2,{value:e.approval.prompt,onChange:e=>b("approval",{prompt:e.currentTarget.value}),placeholder:"可选:给审批模型的额外指导,例如允许哪些操作、拒绝哪些操作",rows:4,className:"resize-none text-sm"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"与系统提示词一起发送给审批模型,帮助它判断命令是否安全。"})]})]})});return(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex flex-col gap-0.5 border-b px-4 py-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(uH,{}),"代理配置"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:"代理配置"})]}),w?(0,eb.jsx)("div",{className:"px-4 pt-4 md:px-5",children:w}):null,(0,eb.jsx)(etm,{sections:[{id:"context",title:"上下文",icon:(0,eb.jsx)(k$,{}),content:j},{id:"behavior",title:"运行行为",icon:(0,eb.jsx)(enW,{}),content:k},{id:"approval",title:"命令审批",icon:(0,eb.jsx)(kB,{}),content:N}],sectionId:x,onSelectionChange:({sectionId:e})=>{e&&v(e)},defaultSectionId:"context",labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto pb-28"}),(0,eb.jsx)(env,{dirty:d,saving:o,savedAt:f,onSave:()=>void y(),onReset:function(){h.current&&(t(esl(h.current)),g(ess(h.current.behavior?.retryDelaysMs)),u(!1),c(""))}})]})}function esd({models:e,value:t,onValueChange:n,placeholder:r}){return(0,eb.jsx)(x7,{value:t||"__none__",onValueChange:e=>n("__none__"===e?"":e),placeholder:r,title:"选择模型",className:"w-full",options:[{value:"__none__",label:r},...e.map(e=>({value:e.id,label:e.label}))]})}let esu=(0,ek.default)("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]),esf=(0,ek.default)("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]),esm=(0,ek.default)("log-in",[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]]),esh=(0,ek.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),esp={vantaloom:"Vantaloom","claude-code":"Claude Code",reclaude:"reclaude"},esg={idle:"","installing-node":"正在安装 Node.js…","installing-bridge":"正在安装 SDK 桥…",done:"安装完成",error:"安装失败"};function esx(e){return{...e.claudeCode??{}}}function esv(e,t){if(e.reclaudeExecutable)return e;let n=t.find(e=>"reclaude"===e.engine);return n?.available&&n.detail?{...e,reclaudeExecutable:n.detail}:e}function esb(){let[e,t]=ew.useState(null),[n,r]=ew.useState([]),[a,i]=ew.useState([]),[o,l]=ew.useState(!0),[s,c]=ew.useState(!1),[d,u]=ew.useState(null),f=ew.useRef(!1),[m,h]=ew.useState(""),[p,g]=ew.useState(!1),[x,v]=ew.useState(null),b=ew.useRef(null),[y,w]=ew.useState(null),[j,k]=ew.useState("idle"),[N,S]=ew.useState(""),[C,M]=ew.useState(""),E=ew.useRef(!1),[I,P]=ew.useState("engines");async function O(){if(!f.current){f.current=!0;try{for(;f.current;){let e;if(await new Promise(e=>setTimeout(e,1500)),!f.current)break;try{e=await kf()}catch{continue}if(u(e.status),!kd(e.status.phase)){if(e.engines){let n=e.engines;r(n),t(e=>{if(!e)return e;let t=esv(e,n);return p||(b.current=t),t})}"error"===e.status.phase&&h(e.status.error||"适配器安装失败");break}}}finally{f.current=!1}}}async function z(){try{let[e,t]=await Promise.all([km(),kc()]);w(e),r(t.engines??[])}catch{}}async function A(){if("starting"!==j&&"awaiting"!==j){k("starting"),M(""),S(""),E.current=!1;try{let{authUrl:e,state:t}=await kh();if(S(e),e)try{window.open(e,"_blank","noopener,noreferrer")}catch{}k("awaiting");let n=Date.now()+6e5;for(;!E.current&&Date.now()<n;){let e;if(await new Promise(e=>setTimeout(e,2e3)),E.current)return;try{e=await kp(t)}catch(e){k("error"),M(e instanceof Error?e.message:"登录失败");return}if("approved"===e.status){k("idle"),await z();return}if("error"===e.status){k("error"),M(e.error||"授权失败");return}}E.current||(k("error"),M("登录超时,请重试"))}catch(e){k("error"),M(e instanceof Error?e.message:"登录失败")}}}async function T(){try{await kg()}catch{}await z()}async function R(){if(!_){h("");try{let e=await ku();e.status&&u(e.status)}catch{}O()}}function D(e){t(t=>t?{...t,...e}:t),g(!0),v(null)}ew.useEffect(()=>{!async function(){try{let[e,n,a,o,l]=await Promise.all([kl(),kc(),vE(),km().catch(()=>null),kf().catch(()=>null)]),s=n.engines??[],c=esv(esx(e),s);b.current=c,t(c),r(s),i(a.models),w(o),l?.status&&(u(l.status),kd(l.status.phase)&&O())}catch(e){h(e instanceof Error?e.message:"Failed to load config")}finally{l(!1)}}()},[]),ew.useEffect(()=>()=>{E.current=!0,f.current=!1},[]);let _=kd(d?.phase),L=e?.adapterArgs?.[0]??"",$=!!(y?.loggedIn||n.find(e=>"reclaude"===e.engine)?.available||e?.reclaudeExecutable);async function F(){if(e&&!s){c(!0),h("");try{let n=await ks({claudeCode:e}),r=esx(n);b.current=r,t(r),g(!1),v(Date.now())}catch(e){h(e instanceof Error?e.message:"Save failed")}finally{c(!1)}}}if(o)return(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取引擎配置"});if(!e)return(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"读取失败"}),(0,eb.jsx)(etJ,{children:m||"无法加载引擎配置"})]});let B=(0,eb.jsxs)("section",{className:"grid w-full gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"检测到的引擎"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"本机当前可用的 Agent 运行引擎。不可用的引擎会说明原因。"})]}),(0,eb.jsxs)(eO.Button,{type:"button",variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void R(),disabled:_,children:[_?(0,eb.jsx)(eM,{className:"size-4 animate-spin"}):(0,eb.jsx)(bJ,{className:"size-4"}),_?esg[d?.phase??"installing-bridge"]||"安装中…":"下载/安装 SDK 桥"]})]}),d&&"idle"!==d.phase?(0,eb.jsxs)("div",{className:"grid gap-1.5 rounded-md border bg-background p-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:[_?(0,eb.jsx)(eM,{className:"size-3.5 animate-spin text-muted-foreground"}):"done"===d.phase?(0,eb.jsx)(eI,{className:"size-3.5 text-emerald-600 dark:text-emerald-400"}):(0,eb.jsx)(esh,{className:"size-3.5 text-destructive"}),(0,eb.jsx)("span",{children:esg[d.phase]||d.phase})]}),d.lines.length>0?(0,eb.jsx)("pre",{className:"max-h-32 overflow-auto rounded bg-muted/50 px-2 py-1.5 text-[11px] leading-relaxed text-muted-foreground",children:d.lines.slice(-12).join("\n")}):null]}):null,(0,eb.jsx)("p",{className:"text-xs text-muted-foreground/80",children:"Claude Code / reclaude 通过内置的 Claude SDK 桥(@anthropic-ai/claude-agent-sdk)运行。 运行时通常已自带它;若显示缺失,点击上方按钮即可在后台静默下载安装,无需手填路径即可使用。"}),(0,eb.jsx)("div",{className:"grid gap-2",children:0===n.length?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"未检测到引擎信息。"}):n.map(e=>(0,eb.jsxs)("div",{className:"grid gap-1 rounded-md border bg-background p-3",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,eb.jsx)("span",{className:"text-sm font-medium",children:esp[e.engine]??e.engine}),(0,eb.jsxs)("span",{className:(0,ez.cn)("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium [&_svg]:size-3",e.available?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"bg-destructive/10 text-destructive"),children:[e.available?(0,eb.jsx)(eI,{}):(0,eb.jsx)(esh,{}),e.available?"可用":"不可用"]})]}),e.reason?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:e.reason}):null,e.detail?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground/80",children:e.detail}):null]},e.engine))})]}),V=(0,eb.jsxs)("section",{className:"grid w-full gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"reclaude 账户"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"在 Vantaloom 内直接登录 reclaude(recode.cat)。登录后 reclaude 引擎无需安装外部 reclaude / Claude Code 即可使用——本机通过内置签名代理访问 reclaude 网关,由 reclaude 托管账号并代理网络。"})]}),y?.loggedIn?(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-md border bg-background p-3",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-sm font-medium",children:[(0,eb.jsx)(eI,{className:"size-4 text-emerald-600 dark:text-emerald-400"}),"已登录"]}),(0,eb.jsxs)("p",{className:"truncate text-xs text-muted-foreground",children:[y.email||"已连接",y.gatewayUrl?` \xb7 ${y.gatewayUrl}`:""]})]}),(0,eb.jsxs)(eO.Button,{type:"button",variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void T(),children:[(0,eb.jsx)(ela,{className:"size-4"}),"注销"]})]}):(0,eb.jsxs)("div",{className:"grid gap-2",children:["awaiting"===j?(0,eb.jsxs)(etY,{children:[(0,eb.jsx)(eM,{className:"animate-spin"}),(0,eb.jsx)(etZ,{children:"等待浏览器授权…"}),(0,eb.jsxs)(etJ,{children:["已打开授权页面,请在浏览器中完成 reclaude 登录授权;完成后这里会自动更新。",N?(0,eb.jsxs)("a",{href:N,target:"_blank",rel:"noopener noreferrer",className:"mt-1 inline-flex items-center gap-1 underline",children:[(0,eb.jsx)(esu,{className:"size-3"}),"重新打开授权页面"]}):null]})]}):null,"error"===j&&C?(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"登录失败"}),(0,eb.jsx)(etJ,{children:C})]}):null,(0,eb.jsx)("div",{className:"flex items-center gap-2",children:"awaiting"===j?(0,eb.jsx)(eO.Button,{type:"button",variant:"outline",size:"sm",onClick:function(){E.current=!0,k("idle")},children:"取消"}):(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",disabled:"starting"===j,onClick:()=>void A(),children:["starting"===j?(0,eb.jsx)(eM,{className:"size-4 animate-spin"}):(0,eb.jsx)(esm,{className:"size-4"}),"starting"===j?"正在发起…":"登录 reclaude"]})})]})]}),H=(0,eb.jsx)("section",{className:"w-full rounded-lg border bg-card p-4",children:(0,eb.jsxs)("div",{className:"grid gap-4 text-foreground",children:[(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"Node 可执行文件"}),(0,eb.jsx)(eA,{value:e.adapterCommand??"",onChange:e=>D({adapterCommand:e.currentTarget.value}),placeholder:"node"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"运行 SDK 桥的 Node 可执行文件。留空则自动发现(或使用 node)。"})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"SDK 桥脚本路径 (…/adapters/claude-sdk-bridge/index.mjs)"}),(0,eb.jsx)(eA,{value:L,onChange:e=>{let t=e.currentTarget.value;D({adapterArgs:t?[t]:[]})},placeholder:"…/adapters/claude-sdk-bridge/index.mjs"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"留空则自动发现(随运行时安装,或环境变量 VANTALOOM_CC_SDK_BRIDGE)。"})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"Git Bash 路径"}),(0,eb.jsx)(eA,{value:e.gitBashPath??"",onChange:e=>D({gitBashPath:e.currentTarget.value}),placeholder:"C:\\\\Program Files\\\\Git\\\\bin\\\\bash.exe"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"Windows 专用,留空自动发现。"})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"reclaude 可执行文件"}),(0,eb.jsx)(eA,{value:e.reclaudeExecutable??"",onChange:e=>D({reclaudeExecutable:e.currentTarget.value}),placeholder:"reclaude"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"仅作回退:未在上方登录 reclaude 时,engine=reclaude 会改用此外部 reclaude 可执行文件作为 claude 启动。已在上方登录则无需填写。自动发现到 reclaude 时会自动填入。"})]})]})}),U=(0,eb.jsx)("section",{className:"w-full rounded-lg border bg-card p-4",children:(0,eb.jsxs)("div",{className:"grid gap-4 text-foreground",children:[$?(0,eb.jsxs)(etY,{children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"已配置 reclaude,自定义接入已停用"}),(0,eb.jsx)(etJ,{children:"reclaude 已托管账号并代理网络,Claude Code 会经由 reclaude 网关访问, 无需再填写 Base URL / API Key / OAuth Token。如需使用自定义接入,请先移除 reclaude 配置。"})]}):null,(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"Base URL"}),(0,eb.jsx)(eA,{autoComplete:"off",disabled:$,value:e.baseUrl??"",onChange:e=>D({baseUrl:e.currentTarget.value}),placeholder:"https://api.anthropic.com(留空使用官方)"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"claude-code 引擎用:自定义 Anthropic 兼容端点(ANTHROPIC_BASE_URL)。 留空使用官方接口。"})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"API Key"}),(0,eb.jsx)(eA,{type:"password",autoComplete:"off",disabled:$,value:e.apiKey??"",onChange:e=>D({apiKey:e.currentTarget.value}),placeholder:"claude-code 引擎用;留空可用 claude /login"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"claude-code 引擎用(ANTHROPIC_API_KEY);配合上方 Base URL 接入中转/自建网关。 留空可使用 claude /login 登录。"})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"OAuth Token"}),(0,eb.jsx)(eA,{type:"password",autoComplete:"off",disabled:$,value:e.oauthToken??"",onChange:e=>D({oauthToken:e.currentTarget.value}),placeholder:"留空使用其它认证方式"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"可选的 OAuth Token,作为 API Key 之外的认证方式。"})]})]})}),q=(0,eb.jsx)("section",{className:"w-full rounded-lg border bg-card p-4",children:(0,eb.jsx)("div",{className:"grid gap-4 text-foreground",children:(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"摘要模型"}),(0,eb.jsx)(esy,{models:a,value:e.summaryModelRef??"",onValueChange:e=>D({summaryModelRef:e}),placeholder:"使用默认"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"CC 会话标题/摘要用的 Vantaloom 模型路由。"})]})})}),W=[{id:"engines",title:"检测到的引擎",icon:(0,eb.jsx)(uK,{}),content:B},{id:"reclaude",title:"reclaude 账户",icon:(0,eb.jsx)(HP,{}),content:V},{id:"adapter",title:"SDK 桥(高级)",icon:(0,eb.jsx)(u0,{}),content:H},{id:"auth",title:"Claude Code 自定义接入",icon:(0,eb.jsx)(esf,{}),content:U},{id:"summary",title:"摘要模型",icon:(0,eb.jsx)(uX,{}),content:q}];return(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex flex-col gap-0.5 border-b px-4 py-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(uK,{}),"CC 引擎"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:"CC 引擎设置"})]}),m?(0,eb.jsx)("div",{className:"px-4 pt-4 md:px-5",children:(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"错误"}),(0,eb.jsx)(etJ,{children:m})]})}):null,(0,eb.jsx)(etm,{sections:W,sectionId:I,onSelectionChange:({sectionId:e})=>e&&P(e),defaultSectionId:"engines",labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto"}),(0,eb.jsx)(env,{dirty:p,saving:s,savedAt:x,onSave:()=>void F(),onReset:function(){b.current&&(t(b.current),g(!1),h(""))}})]})}function esy({models:e,value:t,onValueChange:n,placeholder:r}){return(0,eb.jsx)(x7,{value:t||"__none__",onValueChange:e=>n("__none__"===e?"":e),placeholder:r,title:"选择摘要模型",className:"w-full",options:[{value:"__none__",label:r},...e.map(e=>({value:e.id,label:e.label}))]})}let esw=[{id:"card",label:"卡片布局",description:"圆角卡片自由排布,右上角下拉菜单按需添加单窗口。",icon:(0,eb.jsx)(elr,{})},{id:"pane",label:"分屏布局",description:"传统多窗格 + 顶部分屏预设,可拖拽分割线调整。",icon:(0,eb.jsx)(qE,{})},{id:"control-room",label:"导播台视角",description:"隐藏窗格,右侧以监视器墙并排查看主代理与各子代理。",icon:(0,eb.jsx)(eP,{})}],esj=[{id:"left",label:"Agent 在左",icon:(0,eb.jsx)(cy,{})},{id:"right",label:"Agent 在右",icon:(0,eb.jsx)(cj,{})}];function esk(){let[e,t]=ew.useState("pane"),[n,r]=ew.useState("left");ew.useEffect(()=>{let e=eeV();t(e.mode),r(e.agentSide)},[]);let a=(0,eb.jsxs)("section",{className:"grid w-full gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"布局模式"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"仅电脑端生效。切换 Agent 工作区的窗口布局,设置即时应用到所有会话。"}),(0,eb.jsx)("div",{className:"grid gap-2 sm:grid-cols-3",children:esw.map(n=>{let r=e===n.id;return(0,eb.jsxs)("button",{type:"button",onClick:()=>{var e;t(e=n.id),eeH({mode:e})},className:(0,ez.cn)("flex flex-col gap-2 rounded-lg border p-3 text-left transition-colors [&_svg]:size-5",r?"border-primary bg-primary/5 text-foreground":"border-border bg-background text-muted-foreground hover:bg-muted/60 hover:text-foreground"),"aria-pressed":r,children:[(0,eb.jsx)("span",{className:(0,ez.cn)("grid size-9 place-items-center rounded-md",r?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:n.icon}),(0,eb.jsx)("span",{className:"text-sm font-medium text-foreground",children:n.label}),(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:n.description})]},n.id)})})]}),i=(0,eb.jsxs)("section",{className:"grid w-full gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"Agent 对话位置"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"仅电脑端生效。切换 Agent 对话窗口在工作区中的位置。"}),(0,eb.jsx)("div",{className:"flex flex-wrap gap-2",children:esj.map(e=>{let t=n===e.id;return(0,eb.jsxs)("button",{type:"button",onClick:()=>{var t;r(t=e.id),eeH({agentSide:t})},className:(0,ez.cn)("inline-flex items-center gap-2 rounded-lg border px-3 py-2 text-sm transition-colors [&_svg]:size-4",t?"border-primary bg-primary/5 text-foreground":"border-border bg-background text-muted-foreground hover:bg-muted/60 hover:text-foreground"),"aria-pressed":t,children:[e.icon,e.label]},e.id)})})]});return(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex flex-col gap-0.5 border-b px-4 py-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(elr,{}),"布局排版"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:"布局排版"})]}),(0,eb.jsx)(etm,{sections:[{id:"mode",title:"布局模式",icon:(0,eb.jsx)(elr,{}),content:a},{id:"side",title:"Agent 对话位置",icon:(0,eb.jsx)(cy,{}),content:i}],defaultSectionId:"mode",labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto"})]})}async function esN(){return esM("/api/local/model-groups")}async function esS(e){return esM("/api/local/model-groups",{method:"POST",body:JSON.stringify(e)})}async function esC(e){await esM(`/api/local/model-groups/${encodeURIComponent(e)}`,{method:"DELETE"})}async function esM(e,t){let n=await fetch((0,eT.localAPIURL)(e),{cache:"no-store",...t,headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error("string"==typeof r?.error?r.error:"model group api failed");return r}function esE(e){return{key:e.id,id:e.id,name:e.name,members:e.members.map(e=>({modelRef:e.modelRef,weight:e.weight})),editing:!1}}let esI=0;function esP(e){return JSON.stringify(e.map(e=>({id:e.id??"",name:e.name,members:e.members})))}function esO(){let{models:e,loading:t}=vH(),[n,r]=ew.useState([]),[a,i]=ew.useState([]),[o,l]=ew.useState(!0),[s,c]=ew.useState(""),[d,u]=ew.useState(!1),[f,m]=ew.useState(""),[h,p]=ew.useState(null),g=ew.useMemo(()=>e.filter(e=>!e.value.startsWith("group:")),[e]),x=ew.useMemo(()=>{let e=new Map;for(let t of g)e.set(t.value,t.label);return e},[g]),v=ew.useCallback(async()=>{c("");try{let e=((await esN()).groups??[]).map(esE);r(e),i(e)}catch(e){c(e instanceof Error?e.message:"模型组读取失败")}finally{l(!1)}},[]);ew.useEffect(()=>{v()},[v]);let b=ew.useMemo(()=>esP(n)!==esP(a),[n,a]),y=ew.useMemo(()=>{for(let e of n){if(!e.name.trim())return"每个模型组都需要一个名称";if(0===e.members.length)return"每个模型组至少需要一个成员模型"}},[n]);async function w(e){if(!e.id)return void r(t=>t.filter(t=>t.key!==e.key));m("");try{await esC(e.id),r(t=>t.filter(t=>t.key!==e.key)),i(t=>t.filter(t=>t.id!==e.id))}catch(e){m(e instanceof Error?e.message:"删除失败")}}async function j(){if(!d&&!y){u(!0),m("");try{let e=[];for(let t of n){let n=await esS({id:t.id,name:t.name.trim(),members:t.members});e.push({...esE(n),key:t.key})}r(e),i(e.map(e=>({...e}))),p(Date.now())}catch(e){m(e instanceof Error?e.message:"保存失败")}finally{u(!1)}}}return(0,eb.jsxs)("div",{className:"grid gap-4 pb-20",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsx)("div",{className:"min-w-0",children:(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"把多个模型组合成一个「模型组」,调用时按顺序轮询成员:先尝试第一个,出错按其 重试次数重试;用尽后切到下一个;全部用尽再回到第一个做最后一次尝试,仍失败才报错。 保存后可在任意模型选择处以「模型组:名称」选用。"})}),(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",onClick:function(){r(e=>[{key:(esI+=1,`new-group-${esI}`),name:"",members:[],editing:!0},...e]),p(null)},children:[(0,eb.jsx)(lY,{className:"size-4"}),"添加模型组"]})]}),s?(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"读取失败"}),(0,eb.jsx)(etJ,{children:s})]}):null,o?(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取模型组"}):0===n.length?(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"还没有模型组。点击「添加模型组」创建一个。"}):(0,eb.jsx)("div",{className:"grid gap-3",children:n.map(e=>(0,eb.jsx)(esz,{draft:e,candidates:g,candidatesLoading:t,labelByRef:x,onChange:t=>{var n,a;return n=e.key,a=()=>t,void r(e=>e.map(e=>e.key===n?a(e):e))},onDelete:()=>{w(e)}},e.key))}),(0,eb.jsx)(env,{dirty:b,saving:d,onSave:()=>{j()},onReset:function(){r(a.map(e=>({...e}))),m(""),p(null)},savedAt:h,error:f||void 0,validationMessage:b?y:void 0})]})}function esz({draft:e,candidates:t,candidatesLoading:n,labelByRef:r,onChange:a,onDelete:i}){let[o,l]=ew.useState(null),s=ew.useMemo(()=>e.members.map(e=>e.modelRef),[e.members]),c=ew.useCallback(t=>{let n=new Set(t),r=e.members.filter(e=>n.has(e.modelRef)),i=new Set(r.map(e=>e.modelRef)),o=t.filter(e=>!i.has(e)).map(e=>({modelRef:e,weight:2}));a({...e,members:[...r,...o]})},[e,a]);if(!e.editing){let t=e.members.map(e=>r.get(e.modelRef)??e.modelRef);return(0,eb.jsxs)("section",{className:"grid min-h-16 grid-cols-[minmax(0,1fr)_auto] items-center gap-3 rounded-lg border bg-card px-3 py-2.5",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[(0,eb.jsx)(k$,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,eb.jsx)("span",{className:"truncate text-sm font-medium",children:e.name.trim()||"未命名模型组"}),(0,eb.jsxs)("span",{className:"ui-text-kbd text-muted-foreground",children:[e.members.length," 个成员"]})]}),(0,eb.jsx)("div",{className:"mt-1 truncate text-xs text-muted-foreground",children:t.length>0?t.join(" → "):"未选择成员"})]}),(0,eb.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,eb.jsxs)(eO.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>a({...e,editing:!0}),children:[(0,eb.jsx)(UH,{className:"size-4"}),"编辑"]}),(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-hot-pink",onClick:i,title:"删除模型组",children:(0,eb.jsx)(yn,{className:"size-4"})})]})]})}return(0,eb.jsxs)("div",{className:"grid gap-3 rounded-lg border bg-card/40 p-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)(k$,{className:"size-4 shrink-0 text-muted-foreground"}),(0,eb.jsx)(eA,{value:e.name,onChange:t=>a({...e,name:t.target.value}),placeholder:"模型组名称",className:"h-8 flex-1"}),(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground",onClick:()=>a({...e,editing:!1}),title:"收起",children:(0,eb.jsx)(xw,{className:"size-4"})}),(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-hot-pink",onClick:i,title:"删除模型组",children:(0,eb.jsx)(yn,{className:"size-4"})})]}),(0,eb.jsx)(Ye,{mode:"multi",models:t,loading:n,value:s,onChange:c,emptyHint:"没有可用模型(先在「模型路由」配置渠道)"}),e.members.length>0?(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsx)("p",{className:"px-1 text-[11px] text-muted-foreground",children:"成员顺序与重试次数(拖动调整顺序;重试次数 = 该成员出错时的重试次数)"}),(0,eb.jsx)("div",{className:"grid gap-1",children:e.members.map((t,n)=>(0,eb.jsxs)("div",{draggable:!0,onDragStart:()=>l(n),onDragOver:e=>e.preventDefault(),onDrop:t=>{t.preventDefault(),null!==o&&function(t,n){if(t===n||t<0||n<0)return;let r=[...e.members],i=r[t];i&&(r.splice(t,1),r.splice(n,0,i),a({...e,members:r}))}(o,n),l(null)},onDragEnd:()=>l(null),className:(0,ez.cn)("flex items-center gap-2 rounded-md border bg-background px-2 py-1.5",o===n&&"opacity-50"),children:[(0,eb.jsx)(fX,{className:"size-4 shrink-0 cursor-grab text-muted-foreground"}),(0,eb.jsxs)("span",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground",children:[n+1,"."]}),(0,eb.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm",children:r.get(t.modelRef)??t.modelRef}),(0,eb.jsxs)("label",{className:"flex shrink-0 items-center gap-1 text-[11px] text-muted-foreground",children:["重试",(0,eb.jsx)(eA,{type:"number",min:0,value:t.weight,onChange:t=>{var r;return r=Number.parseInt(t.target.value,10)||0,void a({...e,members:e.members.map((e,t)=>t===n?{...e,weight:Math.max(0,r)}:e)})},className:"h-7 w-14 px-2 text-center"})]}),(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0 text-muted-foreground hover:text-hot-pink",onClick:()=>{a({...e,members:e.members.filter((e,t)=>t!==n)})},title:"移除成员",children:(0,eb.jsx)(fV.XIcon,{className:"size-3.5"})})]},t.modelRef))})]}):null]})}let esA=(0,ek.default)("check-check",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]),esT=(0,ek.default)("flask-conical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]),esR=[{value:"openai-v1",label:"OpenAI v1"},{value:"anthropic",label:"Anthropic"},{value:"openai-responses",label:"OpenAI Responses"},{value:"codex",label:"Codex"}];function esD(e){return{id:e.id,providerName:e.providerName,protocol:e.protocol,endpointUrl:e.endpointUrl,apiKey:e.apiKey??"",models:e.models,selectedModelIds:e.selectedModelIds,builtin:e.builtin,enabled:e.enabled??!0,proxyEnabled:e.proxyEnabled??!1,proxyUrl:e.proxyUrl??"",loadingModels:!1,saving:!1,error:e.lastError??"",savedKeyAvailable:!!e.apiKey||!!e.builtin,editing:!1}}function es_(){let[e,t]=ew.useState([]),[n,r]=ew.useState(!0),[a,i]=ew.useState(""),o=ew.useCallback(async()=>{i("");try{let e=await vE();t(e.routes.map(esD))}catch(e){i(e instanceof Error?e.message:"模型路由读取失败")}finally{r(!1)}},[]);function l(e,n){t(t=>t.map((t,r)=>r===e?n(t):t))}async function s(t){let n=e[t];if(n&&!n.saving){l(t,e=>({...e,saving:!0,error:""}));try{let e=await vP({id:n.id,providerName:n.providerName,protocol:n.protocol,endpointUrl:n.endpointUrl,apiKey:n.apiKey,models:n.models,selectedModelIds:n.selectedModelIds,proxyEnabled:n.proxyEnabled,proxyUrl:n.proxyUrl.trim()});l(t,()=>esD(e))}catch(e){l(t,t=>({...t,saving:!1,error:e instanceof Error?e.message:"保存失败"}))}}}async function c(t,n){let r=e[t];if(r&&r.id&&!r.togglingEnabled){l(t,e=>({...e,enabled:n,togglingEnabled:!0}));try{let e=await vA(r.id,n);l(t,t=>({...t,enabled:e.enabled??n,togglingEnabled:!1})),vL=null,v_=!1,vV().catch(()=>{})}catch(e){l(t,t=>({...t,enabled:!n,togglingEnabled:!1,error:e instanceof Error?e.message:"切换失败"}))}}}async function d(n){let r=e[n];if(r&&!r.saving){if(!r.id)return void t(e=>e.filter((e,t)=>t!==n));l(n,e=>({...e,saving:!0,error:""}));try{await vO(r.id),t(e=>e.filter((e,t)=>t!==n))}catch(e){l(n,t=>({...t,saving:!1,error:e instanceof Error?e.message:"删除失败"}))}}}return ew.useEffect(()=>{o()},[o]),ew.useEffect(()=>{let e=!1,n=window.setInterval(()=>{(async()=>{try{let n=await vE();if(e)return;let r=n.routes.find(e=>e.builtin);t(e=>{let t=e.some(e=>e.builtin);return r?t?e.map(e=>e.builtin?{...e,providerName:r.providerName,models:r.models,selectedModelIds:r.selectedModelIds,enabled:e.togglingEnabled?e.enabled:r.enabled??!0,error:r.lastError??""}:e):[esD(r),...e]:t?e.filter(e=>!e.builtin):e})}catch{}})()},3e4);return()=>{e=!0,window.clearInterval(n)}},[]),(0,eb.jsxs)("div",{className:"grid gap-4",children:[(0,eb.jsx)("div",{className:"flex items-center justify-end gap-3",children:(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",onClick:function(){t(e=>[{providerName:"",protocol:"openai-v1",endpointUrl:"",apiKey:"",models:[],selectedModelIds:[],enabled:!0,proxyEnabled:!1,proxyUrl:"",loadingModels:!1,saving:!1,error:"",editing:!0},...e])},"data-tour":"add-model-route",children:[(0,eb.jsx)(lY,{className:"size-4"}),"添加模型路由"]})}),a?(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"读取失败"}),(0,eb.jsx)(etJ,{children:a})]}):null,n?(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取模型路由"}):0===e.length?(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"还没有模型路由。"}):(0,eb.jsx)("div",{className:"grid gap-3",children:e.map((e,t)=>(0,eb.jsx)(es$,{draft:e,onDraftChange:e=>l(t,()=>e),onSave:()=>{s(t)},onDelete:()=>{d(t)},onToggleEnabled:e=>{c(t,e)}},e.id??`draft-${t}`))})]})}function esL({value:e,title:t}){let[n,r]=ew.useState(!1);return(0,eb.jsx)("button",{type:"button",tabIndex:-1,title:t??"复制",disabled:!e,onClick:async()=>{if(e)try{await navigator.clipboard.writeText(e),r(!0),window.setTimeout(()=>r(!1),1200)}catch{}},className:"absolute right-1 top-1/2 flex size-6 -translate-y-1/2 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-40",children:n?(0,eb.jsx)(h6,{className:"size-3.5 text-emerald-500"}):(0,eb.jsx)(lV,{className:"size-3.5"})})}function es$({draft:e,onDraftChange:t,onSave:n,onDelete:r,onToggleEnabled:a}){let i=ew.useRef(e),o=ew.useRef(t),[l,s]=ew.useState({}),[c,d]=ew.useState(""),[u,f]=ew.useState(null),m=ew.useCallback(e=>{f({open:!0,modelId:e,prompt:"hi",stream:!0,running:!1,result:null})},[]),h=ew.useCallback(async(e,t)=>{if(!e)return void s(e=>({...e,[t]:{state:"failed",reason:"请先保存路由后再测试"}}));s(e=>({...e,[t]:{state:"testing"}}));try{let n=await vz({routeId:e,modelId:t});s(e=>({...e,[t]:n.ok?{state:"success"}:{state:"failed",reason:n.error||"测试失败"}}))}catch(e){s(n=>({...n,[t]:{state:"failed",reason:e instanceof Error?e.message:"测试失败"}}))}},[]),p=ew.useCallback(async(e,t)=>{if(f(e=>e?{...e,running:!0,result:null}:e),!e)return void f(e=>e?{...e,running:!1,result:{ok:!1,error:"请先保存路由后再测试"}}:e);let n=Date.now();try{let r=await vz({routeId:e,modelId:t.modelId,prompt:t.prompt,stream:t.stream}),a=r.latencyMs??Date.now()-n;f(e=>e?{...e,running:!1,result:{...r,latencyMs:a}}:e)}catch(e){f(t=>t?{...t,running:!1,result:{ok:!1,error:e instanceof Error?e.message:"测试失败"}}:t)}},[]),g=[e.providerName,e.protocol,e.endpointUrl,e.apiKey||(e.savedKeyAvailable?"saved":"")].join("\n"),x=e.providerName.trim()&&e.endpointUrl.trim()&&e.apiKey.trim(),v=e.providerName.trim()&&e.endpointUrl.trim()&&(e.apiKey.trim()||e.savedKeyAvailable)&&e.selectedModelIds.length>0&&!e.saving;ew.useEffect(()=>{i.current=e,o.current=t},[e,t]);let b=ew.useRef(null),y=ew.useRef(null),w=ew.useCallback(async e=>{let t=i.current;b.current=e,o.current({...t,loadingModels:!0,error:""});try{let e=await vI({providerName:t.providerName,protocol:t.protocol,endpointUrl:t.endpointUrl,apiKey:t.apiKey}),n=t.selectedModelIds.filter(t=>e.models.some(e=>e.id===t));o.current({...i.current,models:e.models,selectedModelIds:n,loadingModels:!1,error:""})}catch(e){o.current({...i.current,loadingModels:!1,error:e instanceof Error?e.message:"模型拉取失败"})}},[]);ew.useEffect(()=>{if((null!==y.current&&(window.clearTimeout(y.current),y.current=null),x)&&g!==b.current)return y.current=window.setTimeout(()=>{y.current=null,w(g)},1300),()=>{null!==y.current&&(window.clearTimeout(y.current),y.current=null)}},[x,g,w]);let j=ew.useCallback(()=>{x&&g!==b.current&&(null!==y.current&&(window.clearTimeout(y.current),y.current=null),w(g))},[x,g,w]);function k(n){t({...e,...n})}let N=e.models.length>0&&e.selectedModelIds.length===e.models.length,S=e.models.length>18,C=c.trim().toLowerCase(),M=C.length>0?e.models.filter(e=>{let t=e.id.toLowerCase(),n=(e.displayName??"").toLowerCase();return t.includes(C)||n.includes(C)}):e.models;if(!e.editing||e.builtin){let t=e.selectedModelIds.map(t=>e.models.find(e=>e.id===t)?.displayName||t).filter(Boolean),n=esR.find(t=>t.value===e.protocol)?.label??e.protocol;return(0,eb.jsxs)("section",{className:(0,ez.cn)("grid min-h-16 grid-cols-[minmax(0,1fr)_auto] items-center gap-3 rounded-lg border bg-card px-3 py-2.5",!e.enabled&&"opacity-60"),children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[e.builtin?(0,eb.jsx)(lq,{className:"size-3.5 shrink-0 text-muted-foreground"}):null,(0,eb.jsx)("span",{className:"truncate text-sm font-medium",children:e.providerName}),e.builtin?(0,eb.jsx)("span",{className:"ui-text-kbd rounded-full bg-muted px-2 py-0.5 text-muted-foreground",children:"官渠"}):null,(0,eb.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:n}),e.enabled?null:(0,eb.jsx)("span",{className:"ui-text-kbd rounded-full bg-destructive/10 px-2 py-0.5 text-destructive",children:"已禁用"})]}),(0,eb.jsx)("div",{className:"mt-1 truncate text-xs text-muted-foreground",children:t.length>0?t.join(", "):"未选择模型"})]}),(0,eb.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[e.id?(0,eb.jsx)(bG,{checked:e.enabled,disabled:e.togglingEnabled,onCheckedChange:e=>a(!0===e),"aria-label":e.enabled?"禁用此路由":"启用此路由",title:e.enabled?"已启用(点击禁用)":"已禁用(点击启用)"}):null,e.builtin?null:(0,eb.jsxs)(eO.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>k({editing:!0}),children:[(0,eb.jsx)(UH,{className:"size-4"}),"编辑"]})]})]})}return(0,eb.jsxs)("section",{className:"grid min-w-0 gap-3 rounded-lg border bg-card p-3","data-tour":"model-route-form",children:[(0,eb.jsxs)("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_11rem]",children:[(0,eb.jsx)(eA,{value:e.providerName,placeholder:"提供商名称",onChange:e=>k({providerName:e.currentTarget.value}),onBlur:j}),(0,eb.jsx)(x7,{value:e.protocol,onValueChange:e=>k({protocol:e}),options:esR,title:"选择协议",className:"w-full"})]}),(0,eb.jsxs)("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_minmax(0,18rem)]",children:[(0,eb.jsxs)("div",{className:"relative",children:[(0,eb.jsx)(eA,{value:e.endpointUrl,placeholder:"API 端点 URL,例如 https://api.openai.com/v1",className:"pr-8",onChange:e=>k({endpointUrl:e.currentTarget.value}),onBlur:j}),(0,eb.jsx)(esL,{value:e.endpointUrl,title:"复制端点 URL"})]}),(0,eb.jsxs)("div",{className:"relative",children:[(0,eb.jsx)(eA,{value:e.apiKey,type:"text",placeholder:"API Key",autoComplete:"off",spellCheck:!1,className:"pr-8 font-mono",onChange:e=>k({apiKey:e.currentTarget.value}),onBlur:j}),(0,eb.jsx)(esL,{value:e.apiKey,title:"复制 API Key"})]})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)("div",{className:"flex items-center justify-between gap-2",children:(0,eb.jsxs)("label",{className:"flex cursor-pointer items-center gap-2 text-sm font-medium",children:[(0,eb.jsx)(bG,{checked:e.proxyEnabled,onCheckedChange:e=>k({proxyEnabled:!0===e}),"aria-label":"启用代理"}),"启用代理"]})}),e.proxyEnabled?(0,eb.jsxs)("div",{className:"relative",children:[(0,eb.jsx)(eA,{value:e.proxyUrl,placeholder:"http://127.0.0.1:7890",autoComplete:"off",spellCheck:!1,className:"pr-8 font-mono",onChange:e=>k({proxyUrl:e.currentTarget.value})}),(0,eb.jsx)(esL,{value:e.proxyUrl,title:"复制代理地址"})]}):null,(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"启用后该渠道的所有模型请求都经此代理。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsxs)("div",{className:"flex min-h-6 items-center justify-between gap-2",children:[(0,eb.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm font-medium",children:[(0,eb.jsx)(h3,{className:"size-4 text-muted-foreground"}),"可用模型",e.models.length>0?(0,eb.jsxs)("span",{className:"text-xs font-normal text-muted-foreground tabular-nums",children:[e.selectedModelIds.length,"/",e.models.length]}):null]}),(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[e.loadingModels?(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:"拉取中"}):null,e.models.length>0?(0,eb.jsxs)(eO.Button,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>k({selectedModelIds:N?[]:e.models.map(e=>e.id)}),children:[(0,eb.jsx)(esA,{className:"size-3.5"}),N?"全不选":"全选"]}):null]})]}),S?(0,eb.jsxs)("div",{className:"relative",children:[(0,eb.jsx)(vu,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),(0,eb.jsx)(eA,{value:c,placeholder:"搜索模型…",autoComplete:"off",spellCheck:!1,className:"h-8 pl-8 pr-8 text-sm",onChange:e=>d(e.currentTarget.value)}),c?(0,eb.jsx)("button",{type:"button",tabIndex:-1,title:"清除",onClick:()=>d(""),className:"absolute right-1 top-1/2 flex size-6 -translate-y-1/2 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:(0,eb.jsx)(fV.XIcon,{className:"size-3.5"})}):null]}):null,e.models.length>0?0===M.length?(0,eb.jsxs)("div",{className:"rounded-md border border-dashed px-3 py-4 text-sm text-muted-foreground",children:["没有匹配「",c,"」的模型。"]}):(0,eb.jsx)("div",{className:"grid max-h-64 gap-1 overflow-auto pr-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:M.map(t=>{let n=e.selectedModelIds.includes(t.id),r=l[t.id]??{state:"idle"};return(0,eb.jsxs)("div",{className:(0,ez.cn)("grid min-h-8 grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-2 rounded-md px-2 text-sm hover:bg-muted/60",n&&"bg-muted/70"),children:[(0,eb.jsxs)("label",{className:"flex min-w-0 cursor-pointer items-center gap-2",children:[(0,eb.jsx)(vM,{checked:n,onCheckedChange:n=>{var r;return r=t.id,void k({selectedModelIds:!0===n?[...e.selectedModelIds,r]:e.selectedModelIds.filter(e=>e!==r)})}}),(0,eb.jsx)("span",{className:"truncate",children:t.displayName||t.id})]}),(0,eb.jsxs)("div",{className:"flex items-center gap-1",children:[(0,eb.jsx)(eA,{type:"number",className:"h-6 w-16 px-1.5 text-center text-xs tabular-nums",value:t.contextLength||200,min:1,max:1e4,onChange:n=>{var r,a;return r=t.id,a=Number.parseInt(n.currentTarget.value,10)||0,void k({models:e.models.map(e=>e.id===r?{...e,contextLength:a>0?a:void 0}:e)})}}),(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:"k"})]}),(0,eb.jsxs)(wh,{children:[(0,eb.jsx)(wg,{asChild:!0,children:(0,eb.jsx)("button",{type:"button",title:"failed"===r.state?`测试失败:${r.reason??""}`:"success"===r.state?"测试通过(右键高级测试)":"测试此模型(右键高级测试)",disabled:"testing"===r.state,onClick:()=>void h(e.id,t.id),className:(0,ez.cn)("flex size-6 shrink-0 items-center justify-center rounded transition-colors hover:bg-muted disabled:opacity-60","success"===r.state&&"text-emerald-500","failed"===r.state&&"text-destructive","idle"===r.state&&"text-muted-foreground","testing"===r.state&&"text-muted-foreground"),children:"testing"===r.state?(0,eb.jsx)(HR,{className:"size-3.5"}):"success"===r.state?(0,eb.jsx)(h6,{className:"size-3.5"}):"failed"===r.state?(0,eb.jsx)(fV.XIcon,{className:"size-3.5"}):(0,eb.jsx)(HE,{className:"size-3.5"})})}),(0,eb.jsx)(wN,{children:(0,eb.jsxs)(wS,{onSelect:()=>m(t.id),children:[(0,eb.jsx)(esT,{className:"size-4"}),"高级测试…"]})})]})]},t.id)})}):(0,eb.jsx)("div",{className:"rounded-md border border-dashed px-3 py-4 text-sm text-muted-foreground",children:"填写端点和密钥后会自动拉取模型。"})]}),e.error?(0,eb.jsxs)(etY,{variant:"destructive",className:"min-w-0 max-w-full overflow-hidden",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"模型路由错误"}),(0,eb.jsx)(etJ,{className:"max-h-32 max-w-full min-w-0 overflow-y-auto whitespace-pre-wrap break-all",children:e.error})]}):null,(0,eb.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,eb.jsxs)(eO.Button,{type:"button",variant:"destructive",onClick:r,disabled:e.saving,children:[(0,eb.jsx)(yn,{className:"size-4"}),"删除"]}),(0,eb.jsx)(eO.Button,{type:"button",onClick:n,disabled:!v,children:e.saving?"保存中":"保存"})]}),(0,eb.jsx)(dX,{open:!!u?.open,onOpenChange:e=>{e||f(null)},children:(0,eb.jsxs)(fU,{className:"max-w-xl",children:[(0,eb.jsxs)(fq,{children:[(0,eb.jsx)(fK,{children:"高级模型测试"}),(0,eb.jsx)(fG,{children:"用自定义提示词向所选模型发起一次真实请求,查看完整回复与延迟。"})]}),u?(0,eb.jsx)(esF,{draft:e,state:u,onChange:e=>f(t=>t?{...t,...e}:t),onRun:()=>void p(e.id,{modelId:u.modelId,prompt:u.prompt,stream:u.stream})}):null]})})]})}function esF({draft:e,state:t,onChange:n,onRun:r}){let[a,i]=ew.useState(!1),o=t.result,l=o?.content??"";return(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsxs)("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_auto] md:items-center",children:[(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"目标模型"}),(0,eb.jsx)(x7,{value:t.modelId,onValueChange:e=>n({modelId:e}),options:e.models.map(e=>({value:e.id,label:e.displayName||e.id})),placeholder:"选择模型",title:"选择模型",className:"w-full"})]}),(0,eb.jsxs)("label",{className:"flex cursor-pointer items-center gap-2 pt-1 text-sm md:pt-5",children:[(0,eb.jsx)(bG,{checked:t.stream,onCheckedChange:e=>n({stream:!0===e}),"aria-label":"流式"}),"流式"]})]}),(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"测试提示词"}),(0,eb.jsx)(w2,{value:t.prompt,rows:3,placeholder:"hi",spellCheck:!1,className:"resize-y font-mono text-sm",onChange:e=>n({prompt:e.currentTarget.value})})]}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,eb.jsx)(eO.Button,{type:"button",size:"sm",onClick:r,disabled:t.running||!t.modelId,children:t.running?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(HR,{className:"size-4"}),"测试中"]}):(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(HE,{className:"size-4"}),"测试"]})}),o&&"number"==typeof o.latencyMs?(0,eb.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums",children:["延迟 ",o.latencyMs," ms"]}):null]}),o&&!o.ok?(0,eb.jsxs)(etY,{variant:"destructive",className:"min-w-0 max-w-full overflow-hidden",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"测试失败"}),(0,eb.jsx)(etJ,{className:"max-h-40 max-w-full min-w-0 overflow-y-auto whitespace-pre-wrap break-all",children:o.error||"未知错误"})]}):null,o&&o.ok?(0,eb.jsxs)("div",{className:"grid gap-1",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"模型回复"}),(0,eb.jsxs)(eO.Button,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",disabled:!l,onClick:async()=>{if(l)try{await navigator.clipboard.writeText(l),i(!0),window.setTimeout(()=>i(!1),1200)}catch{}},children:[a?(0,eb.jsx)(h6,{className:"size-3.5 text-emerald-500"}):(0,eb.jsx)(lV,{className:"size-3.5"}),"复制"]})]}),(0,eb.jsx)("div",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/40 p-2 font-mono text-xs",children:l||"(空回复)"})]}):null]})}async function esB(){return esH("/api/local/subagent-config")}async function esV(e){return esH("/api/local/subagent-config",{method:"PUT",body:JSON.stringify(e)})}async function esH(e,t){let n=await fetch((0,eT.localAPIURL)(e),{cache:"no-store",...t,headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error("string"==typeof r?.error?r.error:"subagent config api failed");return r}function esU(e){return{...e,models:[...e.models??[]]}}function esq(e){return{explore:esU(e.explore),workflow:esU(e.workflow),operator:esU(e.operator),custom:{...e.custom,models:[...e.custom.models??[]]}}}let esW={explore:{title:"探索子代理",icon:(0,eb.jsx)(HC,{className:"size-4"}),tint:"text-sky-600 dark:text-sky-400",description:"只读的代码库探索/调研专家。彻底阅读、搜索代码库,返回带文件路径+行号引用的完整结论,替主 agent 节省上下文。",tools:"仅阅读(vantaloom_read)"},workflow:{title:"工作流子代理",icon:(0,eb.jsx)(u1,{className:"size-4"}),tint:"text-violet-600 dark:text-violet-400",description:"按 workflow-*.yml 严格执行可重复的多步流程,并把其中确定性的步骤自动固化为脚本、给 yml 添加批注。",tools:"阅读 / 编辑 / 终端(vantaloom_read · vantaloom_edit · vantaloom_shell)"},operator:{title:"操作员子代理",icon:(0,eb.jsx)(u0,{className:"size-4"}),tint:"text-pink-600 dark:text-pink-400",description:"专门驱动交互式终端(未来含浏览器)。执行大量终端操作并把结果回报给主 agent。",tools:"阅读 / 终端(vantaloom_read · vantaloom_shell)"}};function esK(){let[e,t]=ew.useState("explore"),[n,r]=ew.useState(null),{models:a,loading:i}=vH(),[o,l]=ew.useState(!0),[s,c]=ew.useState(!1),[d,u]=ew.useState(""),[f,m]=ew.useState(!1),[h,p]=ew.useState(null),g=ew.useRef(null);async function x(){if(n&&!s){c(!0),u("");try{let e=await esV({explore:n.explore,workflow:n.workflow,operator:n.operator,custom:n.custom});g.current=e,r(esq(e)),m(!1),p(Date.now())}catch(e){u(e instanceof Error?e.message:"Save failed")}finally{c(!1)}}}if(ew.useEffect(()=>{!async function(){try{let e=await esB();g.current=e,r(esq(e))}catch(e){u(e instanceof Error?e.message:"Failed to load config")}finally{l(!1)}}()},[]),o)return(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取子代理配置"});if(!n)return(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"读取失败"}),(0,eb.jsx)(etJ,{children:d||"无法加载子代理配置"})]});let v=e=>({id:e,title:esW[e].title,icon:esW[e].icon,content:(0,eb.jsx)("div",{className:"mx-auto w-full max-w-2xl",children:(0,eb.jsx)(esG,{tourId:`subagent-${e}`,meta:esW[e],value:n[e],models:a,modelsLoading:i,onChange:t=>{r(n=>n?{...n,[e]:{...n[e],...t}}:n),m(!0),p(null)}})})});return(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex flex-col gap-0.5 border-b px-4 py-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(uH,{}),"子代理配置"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:"子代理配置"})]}),d?(0,eb.jsx)("div",{className:"px-4 pt-4 md:px-5",children:(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"错误"}),(0,eb.jsx)(etJ,{children:d})]})}):null,(0,eb.jsx)(etm,{sections:[v("explore"),v("workflow"),v("operator"),{id:"custom",title:"自定义子代理",icon:(0,eb.jsx)(uH,{className:"size-4"}),content:(0,eb.jsx)("div",{className:"mx-auto w-full max-w-2xl",children:(0,eb.jsx)(esX,{value:n.custom,models:a,modelsLoading:i,onChange:function(e){r(t=>t?{...t,custom:{...t.custom,...e}}:t),m(!0),p(null)}})})}],sectionId:e,onSelectionChange:({sectionId:e})=>e&&t(e),defaultSectionId:"explore",labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto pb-28"}),(0,eb.jsx)(env,{dirty:f,saving:s,savedAt:h,onSave:()=>void x(),onReset:function(){g.current&&(r(esq(g.current)),m(!1),u(""))}})]})}function esG({meta:e,value:t,models:n,modelsLoading:r,onChange:a,tourId:i}){return(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":i,children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)("span",{className:e.tint,children:e.icon}),(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:e.title})]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:e.description}),(0,eb.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,eb.jsx)("span",{className:"text-foreground/70",children:"可用工具:"}),e.tools,(0,eb.jsx)("span",{className:"ml-1 text-muted-foreground/70",children:"(固定,不可更改)"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"可用模型"}),(0,eb.jsx)(Ye,{mode:"multi",models:n,loading:r,value:t.models??[],onChange:e=>a({models:e})}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"可选多个模型;首个作为默认。开启“允许上级指定模型”后,上级 agent 只能从这里选;留空则继承派发它的上级 agent 当前使用的模型。"})]}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"允许上级指定模型"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"开启后,上级 agent 可在派发时动态指定该子代理使用的模型。"})]}),(0,eb.jsx)(bG,{checked:t.allowCallerModel,onCheckedChange:e=>a({allowCallerModel:e})})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"系统提示词"}),t.promptOverride?(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>a({promptOverride:""}),children:"恢复默认"}):null]}),(0,eb.jsx)(w2,{value:t.promptOverride,onChange:e=>a({promptOverride:e.currentTarget.value}),placeholder:"留空使用内置默认提示词;在此输入将覆盖默认提示词(环境/工具说明仍会自动附加)。",rows:t.promptOverride?10:3,className:"resize-y text-sm"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"覆盖该官方子代理的预设系统提示词。派发时还会自动附加工作区、操作系统与工具使用说明。"})]})]})}function esX({value:e,models:t,modelsLoading:n,onChange:r}){return(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"subagent-custom",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:(0,eb.jsx)(uH,{className:"size-4"})}),(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"自定义子代理"})]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"主 agent 可以自取名字、从下面的模型池中选一个模型来召唤自定义子代理,并可选择是否继承当前对话上下文。自定义子代理拥有完整工具集,还能进一步派发上面三种官方子代理。"}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"可用模型池"}),(0,eb.jsx)(Ye,{mode:"multi",models:t,loading:n,value:e.models??[],onChange:e=>r({models:e})}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"主 agent 召唤自定义子代理时会从这个池中选择一个模型。留空则沿用上级 agent 的模型。"})]})]})}function esY({section:e}={}){return"agent-config"===e||"subagent-config"===e||"cc-engine-config"===e||"assets"===e||"layout"===e?(0,eb.jsx)("div",{className:"h-full min-h-0","data-tour":`preferences-${e}`,children:"agent-config"===e?(0,eb.jsx)(esc,{}):"subagent-config"===e?(0,eb.jsx)(esK,{}):"cc-engine-config"===e?(0,eb.jsx)(esb,{}):"layout"===e?(0,eb.jsx)(esk,{}):(0,eb.jsx)(enC,{scope:"global"})}):(0,eb.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:(0,eb.jsx)("div",{className:"mx-auto w-full max-w-3xl","data-tour":`preferences-${e??"model-routes"}`,children:"model-groups"===e?(0,eb.jsx)(esO,{}):(0,eb.jsx)(es_,{})})})}function esZ(){return(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex flex-col gap-0.5 border-b px-4 py-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(uK,{}),"模型设置"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:"模型设置"})]}),(0,eb.jsx)(etm,{sections:[{id:"routes",title:"模型路由",icon:(0,eb.jsx)(h3,{className:"size-4"}),content:(0,eb.jsx)(es_,{})},{id:"groups",title:"聚合模型",icon:(0,eb.jsx)(k$,{className:"size-4"}),content:(0,eb.jsx)(esO,{})}],defaultSectionId:"routes",labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto"})]})}let esJ=[1e4,3e4,12e4,3e5,6e5];function esQ(e){return{compression:{...e.compression},summary:{...e.summary},approval:{...e.approval},behavior:{maxToolCalls:e.behavior?.maxToolCalls??0,retryCount:e.behavior?.retryCount??0,retryDelaysMs:e.behavior?.retryDelaysMs??[],loopMaxIterations:e.behavior?.loopMaxIterations??25,loopHookWait:e.behavior?.loopHookWait??"defer",loopHookWaitTimeoutSec:e.behavior?.loopHookWaitTimeoutSec??0}}}function es0(e){return(e&&e.length?e:esJ).map(e=>Math.round(e/1e3)).join(", ")}function es1(){let[e,t]=ew.useState("context"),[n,r]=ew.useState(""),[a,i]=ew.useState(!0),[o,l]=ew.useState(!1),[s,c]=ew.useState(null),[d,u]=ew.useState(null),[f,m]=ew.useState(!1),h=ew.useRef(null),[p,g]=ew.useState([]),[x,v]=ew.useState(""),[b,y]=ew.useState(null),[w,j]=ew.useState(!1),k=ew.useRef(null),{models:N,loading:S}=vH();function C(e,t){u(n=>n?{...n,[e]:{...n[e],...t}}:n),m(!0),c(null)}async function M(){if(!o){l(!0),r("");try{if(f&&d){let e=await ks({compression:d.compression,summary:d.summary,approval:d.approval,behavior:d.behavior});h.current=e,u(esQ(e)),v(es0(e.behavior?.retryDelaysMs)),m(!1)}if(w&&b){let e=await esV({explore:b.explore,workflow:b.workflow,operator:b.operator,custom:b.custom});k.current=e,y(esq(e)),j(!1)}c(Date.now())}catch(e){r(e instanceof Error?e.message:"Save failed")}finally{l(!1)}}}if(ew.useEffect(()=>{!async function(){try{let[e,t,n]=await Promise.all([kl(),vE(),esB()]);h.current=e,u(esQ(e)),v(es0(e.behavior?.retryDelaysMs)),g(t.models),k.current=n,y(esq(n))}catch(e){r(e instanceof Error?e.message:"Failed to load config")}finally{i(!1)}}()},[]),a)return(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取代理配置"});if(!d||!b)return(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"读取失败"}),(0,eb.jsx)(etJ,{children:n||"无法加载代理配置"})]});let E=(0,eb.jsxs)("div",{className:"grid w-full gap-6",children:[(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-compression",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"压缩上下文"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"当对话 token 达到模型上下文窗口的指定百分比时自动压缩。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"自动压缩阈值"}),(0,eb.jsxs)("span",{className:"text-sm tabular-nums text-muted-foreground",children:[d.compression.autoThresholdPercent,"%"]})]}),(0,eb.jsx)(enx,{value:[d.compression.autoThresholdPercent],onValueChange:([e])=>C("compression",{autoThresholdPercent:e}),min:0,max:100,step:5}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"0% 表示禁用自动压缩。建议设为 70%-85%。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"压缩模型"}),(0,eb.jsx)(es2,{models:p,value:d.compression.modelRef,onValueChange:e=>C("compression",{modelRef:e}),placeholder:"使用主模型"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"用于执行上下文压缩的模型。留空则使用当前对话主模型。"})]})]}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-summary",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"对话摘要"}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"对话标题摘要"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"每轮对话结束后自动更新对话标题。"})]}),(0,eb.jsx)(bG,{checked:d.summary.enableTitleSummary,onCheckedChange:e=>C("summary",{enableTitleSummary:e})})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"轮次标题摘要"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"为每轮 agent 操作生成摘要标题。"})]}),(0,eb.jsx)(bG,{checked:d.summary.enableRoundSummary,onCheckedChange:e=>C("summary",{enableRoundSummary:e})})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"摘要模型"}),(0,eb.jsx)(es2,{models:p,value:d.summary.modelRef,onValueChange:e=>C("summary",{modelRef:e}),placeholder:"使用主模型"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"用于生成对话摘要的模型。留空则使用当前对话主模型。"})]})]})]}),I=(0,eb.jsxs)("div",{className:"grid w-full gap-6",children:[(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"自动重试与工具调用上限"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"控制本机(vantaloom)agent 单次运行的工具调用上限,以及请求失败后的自动重试。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"最大工具调用次数"}),(0,eb.jsx)(eA,{type:"number",min:0,value:d.behavior.maxToolCalls,onChange:e=>C("behavior",{maxToolCalls:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"单次运行累计调用工具达到该次数后强制暂停(可点击“继续”恢复)。设为 0 表示不限次(默认)。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"自动重试次数"}),(0,eb.jsx)(eA,{type:"number",min:0,value:d.behavior.retryCount,onChange:e=>C("behavior",{retryCount:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"模型/服务商请求失败时自动重试的次数(仅在尚未产出内容时重试,避免重复输出)。设为 0 表示不重试。"})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"重试间隔梯度(秒)"}),(0,eb.jsx)(eA,{value:x,onChange:e=>{let t=e.currentTarget.value;v(t),C("behavior",{retryDelaysMs:t.split(/[,,\s]+/).map(e=>Number.parseInt(e.trim(),10)).filter(e=>Number.isFinite(e)&&e>0).map(e=>1e3*e)})},placeholder:"10, 30, 120, 300, 600"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"用逗号分隔每次重试的等待秒数(指数级递增),例如 10, 30, 120, 300, 600。超出列表长度时使用最后一项。留空使用内置默认梯度。"})]})]}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"循环模式"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"开启循环模式后,每轮运行结束会自动注入“继续”并续跑,直到执行树中没有未完成(且未阻塞)的任务。以下设置控制其自动续跑的上限与遇到钩子时的处理方式。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"最大循环次数"}),(0,eb.jsx)(eA,{type:"number",min:1,value:d.behavior.loopMaxIterations,onChange:e=>C("behavior",{loopMaxIterations:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"连续自动续跑达到该次数后强制暂停以避免无限计费(发送新消息可继续)。设为 0 表示使用内置默认值(25)。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"钩子处理"}),(0,eb.jsx)(x7,{value:d.behavior.loopHookWait??"defer",onValueChange:e=>C("behavior",{loopHookWait:"wait"===e?"wait":"defer"}),title:"钩子处理",className:"w-full",options:[{value:"defer",label:"有钩子运行时暂停"},{value:"wait",label:"等待钩子完成后继续"}]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"当存在会自动唤醒本对话的钩子(如进程退出、定时器)时:选择“暂停”则交由钩子驱动;选择“等待”则等钩子完成后再继续循环。"})]}),"wait"===d.behavior.loopHookWait?(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"等待超时(秒,0 = 直到无钩子)"}),(0,eb.jsx)(eA,{type:"number",min:0,value:d.behavior.loopHookWaitTimeoutSec??0,onChange:e=>C("behavior",{loopHookWaitTimeoutSec:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"在“等待”模式下,最多等待多少秒后无论钩子是否完成都继续。设为 0 表示一直等到没有钩子在运行(仍受 30 分钟的硬性上限约束)。"})]}):null]})]}),P=(0,eb.jsx)("div",{className:"grid w-full gap-6",children:(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-approval",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"命令审批"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"在 Auto 权限模式下,使用 AI 模型审批 Agent 发起的命令是否可以自动执行。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"审批模型"}),(0,eb.jsx)(es2,{models:p,value:d.approval.modelRef,onValueChange:e=>C("approval",{modelRef:e}),placeholder:"未配置(全部放行)"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"留空表示 Auto 模式下不进行 AI 审批,所有非危险命令自动放行。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"审批提示词"}),(0,eb.jsx)(w2,{value:d.approval.prompt,onChange:e=>C("approval",{prompt:e.currentTarget.value}),placeholder:"可选:给审批模型的额外指导,例如允许哪些操作、拒绝哪些操作",rows:4,className:"resize-none text-sm"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"与系统提示词一起发送给审批模型,帮助它判断命令是否安全。"})]})]})}),O=e=>({id:e,title:esW[e].title,icon:esW[e].icon,content:(0,eb.jsx)("div",{className:"w-full",children:(0,eb.jsx)(esG,{tourId:`subagent-${e}`,meta:esW[e],value:b[e],models:N,modelsLoading:S,onChange:t=>{y(n=>n?{...n,[e]:{...n[e],...t}}:n),j(!0),c(null)}})})});return(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex flex-col gap-0.5 border-b px-4 py-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(uH,{}),"代理配置"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:"代理配置"})]}),n?(0,eb.jsx)("div",{className:"px-4 pt-4 md:px-5",children:(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"错误"}),(0,eb.jsx)(etJ,{children:n})]})}):null,(0,eb.jsx)(etm,{sections:[{id:"context",title:"上下文",icon:(0,eb.jsx)(k$,{}),content:E},{id:"behavior",title:"运行行为",icon:(0,eb.jsx)(enW,{}),content:I},{id:"approval",title:"命令审批",icon:(0,eb.jsx)(kB,{}),content:P},O("explore"),O("workflow"),O("operator"),{id:"custom",title:"自定义子代理",icon:(0,eb.jsx)(uH,{className:"size-4"}),content:(0,eb.jsx)("div",{className:"w-full",children:(0,eb.jsx)(esX,{value:b.custom,models:N,modelsLoading:S,onChange:function(e){y(t=>t?{...t,custom:{...t.custom,...e}}:t),j(!0),c(null)}})})}],sectionId:e,onSelectionChange:({sectionId:e})=>{e&&t(e)},defaultSectionId:"context",labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto"}),(0,eb.jsx)(env,{dirty:f||w,saving:o,savedAt:s,onSave:()=>void M(),onReset:function(){h.current&&(u(esQ(h.current)),v(es0(h.current.behavior?.retryDelaysMs))),k.current&&y(esq(k.current)),m(!1),j(!1),r("")}})]})}function es2({models:e,value:t,onValueChange:n,placeholder:r}){return(0,eb.jsx)(x7,{value:t||"__none__",onValueChange:e=>n("__none__"===e?"":e),placeholder:r,title:"选择模型",className:"w-full",options:[{value:"__none__",label:r},...e.map(e=>({value:e.id,label:e.label}))]})}let es5=(0,ek.default)("wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]),es4={totals:{machines:0,online:0,runtime:0,tokens:0},machines:[],topology:{nodes:[],links:[]},pathTotals:{direct:0,p2p:0,relay:0,broken:0},latency:[],candidates:[]},es3={metrics:{online:0,health:0,latency:"local",events:0},machines:[],trend:[],networkLinks:[],events:[],serviceHealth:[]};function es6(e,t){let[n,r]=ew.useState(t);return ew.useEffect(()=>{let n=!0,a=!1;async function i(){if(!a){a=!0;try{let t=await fetch((0,eT.localAPIURL)(e),{cache:"no-store"});if(!t.ok)return;let a=await t.json();n&&r(a)}catch{n&&r(t)}finally{a=!1}}}i();let o=window.setInterval(i,2e3);return()=>{n=!1,window.clearInterval(o)}},[t,e]),n}let es8={online:{label:"在线",dot:"bg-foreground"},warning:{label:"警告",dot:"bg-muted-foreground"},offline:{label:"离线",dot:"bg-destructive"}},es7={direct:{label:"直连",dot:"bg-foreground"},p2p:{label:"P2P",dot:"bg-foreground"},relay:{label:"中继",dot:"bg-muted-foreground"},down:{label:"断开",dot:"bg-destructive"}};function es9(){return(0,eb.jsx)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:(0,eb.jsx)(ece,{})})})}function ece(){let e=es6("/api/local/machines/fleet",es4),{nodes:t,links:n}=e.topology,r=new Map(t.map(e=>[e.id,e.label])),a=e=>r.get(e)??e;return(0,eb.jsxs)("div",{className:"space-y-4 text-foreground",children:[(0,eb.jsxs)("div",{children:[(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"系统中各机器与连接的明细(自动生成)。下表列出每台机器的在线状态,以及机器之间的连接方式与实时延迟。"}),(0,eb.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 text-xs text-muted-foreground",children:[(0,eb.jsxs)("span",{children:["机器 ",e.totals.online,"/",e.totals.machines," 在线"]}),(0,eb.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,eb.jsx)("span",{className:"size-2 rounded-full bg-foreground"}),"直连 ",e.pathTotals.direct]}),(0,eb.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,eb.jsx)("span",{className:"size-2 rounded-full bg-foreground"}),"P2P ",e.pathTotals.p2p]}),(0,eb.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,eb.jsx)("span",{className:"size-2 rounded-full bg-muted-foreground"}),"中继 ",e.pathTotals.relay]}),(0,eb.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,eb.jsx)("span",{className:"size-2 rounded-full bg-destructive"}),"断开 ",e.pathTotals.broken]})]})]}),(0,eb.jsxs)("section",{className:"rounded-xl border bg-card",children:[(0,eb.jsx)("div",{className:"border-b border-border/60 px-3 py-2 text-sm font-medium",children:"机器"}),(0,eb.jsx)("div",{className:"overflow-x-auto",children:(0,eb.jsxs)("table",{className:"w-full min-w-[28rem] border-collapse text-sm",children:[(0,eb.jsx)("thead",{children:(0,eb.jsxs)("tr",{className:"text-left text-xs text-muted-foreground",children:[(0,eb.jsx)("th",{className:"px-3 py-2 font-medium",children:"名称"}),(0,eb.jsx)("th",{className:"px-3 py-2 font-medium",children:"状态"}),(0,eb.jsx)("th",{className:"px-3 py-2 font-medium",children:"详情"})]})}),(0,eb.jsx)("tbody",{children:0===t.length?(0,eb.jsx)("tr",{children:(0,eb.jsx)("td",{colSpan:3,className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"暂未发现机器。登录 Hub 账户并把机器加入同一工作组后,这里会自动列出。"})}):t.map(e=>{let t=es8[e.state??"offline"];return(0,eb.jsxs)("tr",{className:"border-b border-border/60 last:border-b-0",children:[(0,eb.jsx)("td",{className:"px-3 py-2 font-medium",children:e.label}),(0,eb.jsx)("td",{className:"px-3 py-2",children:(0,eb.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,eb.jsx)("span",{className:`size-2 rounded-full ${t.dot}`}),t.label]})}),(0,eb.jsx)("td",{className:"px-3 py-2 text-muted-foreground",children:e.meta??"—"})]},e.id)})})]})})]}),(0,eb.jsxs)("section",{className:"rounded-xl border bg-card",children:[(0,eb.jsx)("div",{className:"border-b border-border/60 px-3 py-2 text-sm font-medium",children:"连接"}),(0,eb.jsx)("div",{className:"overflow-x-auto",children:(0,eb.jsxs)("table",{className:"w-full min-w-[32rem] border-collapse text-sm",children:[(0,eb.jsx)("thead",{children:(0,eb.jsxs)("tr",{className:"text-left text-xs text-muted-foreground",children:[(0,eb.jsx)("th",{className:"px-3 py-2 font-medium",children:"来源"}),(0,eb.jsx)("th",{className:"px-3 py-2 font-medium",children:"目标"}),(0,eb.jsx)("th",{className:"px-3 py-2 font-medium",children:"类型"}),(0,eb.jsx)("th",{className:"px-3 py-2 font-medium",children:"详情 / 延迟"})]})}),(0,eb.jsx)("tbody",{children:0===n.length?(0,eb.jsx)("tr",{children:(0,eb.jsx)("td",{colSpan:4,className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"暂无连接。"})}):n.map(e=>{let t=es7[e.kind??"direct"],n=e.label??e.meta;return(0,eb.jsxs)("tr",{className:"border-b border-border/60 last:border-b-0",children:[(0,eb.jsx)("td",{className:"px-3 py-2",children:a(e.from)}),(0,eb.jsx)("td",{className:"px-3 py-2",children:a(e.to)}),(0,eb.jsx)("td",{className:"px-3 py-2",children:(0,eb.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,eb.jsx)("span",{className:`size-2 rounded-full ${t.dot}`}),t.label]})}),(0,eb.jsx)("td",{className:"px-3 py-2 text-muted-foreground",children:n??"—"})]},e.id)})})]})})]})]})}let ect=(0,ek.default)("gift",[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]]),ecn=(0,ek.default)("trending-up",[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]]),ecr=[{value:"24h",label:"近 24 小时"},{value:"7d",label:"近 7 天"},{value:"30d",label:"近 30 天"}];function eca(){return(0,eb.jsx)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:(0,eb.jsx)(eci,{})})})}function eci(){let{user:e}=ti(),[t,n]=ew.useState(null),[r,a]=ew.useState(!0),[i,o]=ew.useState(null),[l,s]=ew.useState("7d"),[c,d]=ew.useState("all"),[u,f]=ew.useState([]),[m,h]=ew.useState([]),[p,g]=ew.useState(!0),[x,v]=ew.useState(""),[b,y]=ew.useState(!1),[w,j]=ew.useState(null),k=ew.useCallback(async()=>{a(!0),o(null);try{n(await e4())}catch(e){o(e instanceof Error?e.message:"读取余额失败")}finally{a(!1)}},[]);ew.useEffect(()=>{e&&(k(),e8().then(e=>f(e.models)).catch(()=>f([])))},[e,k]),ew.useEffect(()=>{if(!e)return;let t=!1;return g(!0),e3(l,"all"===c?void 0:c).then(e=>{t||h(e.points)}).catch(()=>{t||h([])}).finally(()=>{t||g(!1)}),()=>{t=!0}},[e,l,c]);let N=ew.useMemo(()=>m.reduce((e,t)=>(e.costMicro+=t.costMicro,e.requests+=t.requests,e.totalTokens+=t.totalTokens,e),{costMicro:0,requests:0,totalTokens:0}),[m]),S=ew.useMemo(()=>m.map(e=>{var t;let n;return{label:(t=e.time,n=new Date(t),"24h"===l?n.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit"})),cost:e.costMicro/1e6,requests:e.requests,tokens:e.totalTokens}}),[m,l]);async function C(){let e=x.trim();if(e){y(!0),j(null);try{let t=await e6(e);j({kind:"ok",text:`兑换成功,到账 ${e2(t.valueMicro)}`}),v(""),n(e=>e?{...e,balanceMicro:t.balanceMicro,balanceUsd:t.balanceMicro/1e6}:e)}catch(e){j({kind:"err",text:e instanceof Error?e.message:"兑换失败,请检查兑换码"})}finally{y(!1)}}}return e?(0,eb.jsxs)("div",{className:"grid gap-6 text-foreground",children:[(0,eb.jsx)("div",{className:"min-w-0",children:(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"查看官方渠道的账户余额、调用用量,并使用兑换码充值。"})}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)(es5,{className:"size-4 text-muted-foreground"}),(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"账户余额"})]}),(0,eb.jsxs)(eO.Button,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void k(),disabled:r,children:[r?(0,eb.jsx)(eM,{className:"animate-spin"}):(0,eb.jsx)(yt,{}),"刷新"]})]}),i?(0,eb.jsx)("p",{className:"text-xs text-destructive",children:i}):(0,eb.jsx)("p",{className:"text-3xl font-semibold tracking-tight",children:r&&!t?"—":e2(t?.balanceMicro??0,4)})]}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)(ect,{className:"size-4 text-muted-foreground"}),(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"兑换码充值"})]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"输入兑换码,金额将立即计入账户余额。"}),(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)(eA,{value:x,onChange:e=>v(e.target.value),placeholder:"请输入兑换码",className:"font-mono",onKeyDown:e=>{"Enter"===e.key&&C()}}),(0,eb.jsxs)(eO.Button,{className:"shrink-0",onClick:()=>void C(),disabled:b||!x.trim(),children:[b?(0,eb.jsx)(eM,{className:"animate-spin"}):null,"兑换"]})]}),w?(0,eb.jsx)("p",{className:(0,ez.cn)("text-xs","ok"===w.kind?"text-primary":"text-destructive"),children:w.text}):null]}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)(ecn,{className:"size-4 text-muted-foreground"}),(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"用量趋势"})]}),(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsxs)(gU,{value:c,onValueChange:d,children:[(0,eb.jsx)(xj,{size:"sm",className:"w-44",children:(0,eb.jsx)(gG,{placeholder:"全部模型"})}),(0,eb.jsxs)(xS,{children:[(0,eb.jsx)(xC,{value:"all",children:"全部模型"}),u.map(e=>(0,eb.jsx)(xC,{value:e.id,children:e.displayName||e.id},e.id))]})]}),(0,eb.jsxs)(gU,{value:l,onValueChange:s,children:[(0,eb.jsx)(xj,{size:"sm",className:"w-32",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:ecr.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})]})]}),(0,eb.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,eb.jsx)(eco,{label:"花费",value:e2(N.costMicro,4)}),(0,eb.jsx)(eco,{label:"请求数",value:N.requests.toLocaleString("zh-CN")}),(0,eb.jsx)(eco,{label:"Tokens",value:N.totalTokens.toLocaleString("zh-CN")})]}),(0,eb.jsx)("div",{className:"h-56 w-full",children:p&&0===m.length?(0,eb.jsx)("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:(0,eb.jsx)(eM,{className:"size-5 animate-spin"})}):0===S.length?(0,eb.jsx)("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:"所选区间暂无用量记录"}):(0,eb.jsx)(Mj,{width:"100%",height:"100%",children:(0,eb.jsxs)(JB,{data:S,margin:{top:8,right:8,left:0,bottom:0},children:[(0,eb.jsx)("defs",{children:(0,eb.jsxs)("linearGradient",{id:"usageCost",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,eb.jsx)("stop",{offset:"5%",stopColor:"var(--color-primary)",stopOpacity:.35}),(0,eb.jsx)("stop",{offset:"95%",stopColor:"var(--color-primary)",stopOpacity:0})]})}),(0,eb.jsx)(Qf,{strokeDasharray:"3 3",stroke:"var(--color-border)",vertical:!1}),(0,eb.jsx)(QE,{dataKey:"label",tick:{fontSize:11},stroke:"var(--color-muted-foreground)",tickLine:!1,axisLine:!1}),(0,eb.jsx)(Q$,{tick:{fontSize:11},stroke:"var(--color-muted-foreground)",tickLine:!1,axisLine:!1,width:48,tickFormatter:e=>`$${e.toFixed(2)}`}),(0,eb.jsx)(VZ,{contentStyle:{borderRadius:8,border:"1px solid var(--color-border)",background:"var(--color-popover)",fontSize:12},formatter:e=>[`$${Number(e).toFixed(4)}`,"花费"]}),(0,eb.jsx)(JR,{type:"monotone",dataKey:"cost",stroke:"var(--color-primary)",strokeWidth:2,fill:"url(#usageCost)"})]})})})]})]}):(0,eb.jsxs)("div",{className:"flex flex-col items-center gap-3 rounded-lg border bg-card py-16 text-center text-foreground",children:[(0,eb.jsx)(es5,{className:"size-8 text-muted-foreground/40"}),(0,eb.jsx)("p",{className:"text-sm font-medium",children:"未登录 Hub 账户"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"请先在「系统设置 · Hub 账户」中登录,再查看余额与用量。"})]})}function eco({label:e,value:t}){return(0,eb.jsxs)("div",{className:"rounded-md bg-muted/55 px-3 py-2",children:[(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:e}),(0,eb.jsx)("p",{className:"mt-0.5 truncate text-sm font-semibold",children:t})]})}let ecl=(0,ek.default)("circle-arrow-up",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);function ecs(e,t){if(e.isLocal)return(0,eT.localAPIURL)(t);let n=t.replace(/^\/v1(?=\/)/,"");return(0,eT.localAPIURL)(`/v1/remote/${e.id}${n}`)}async function ecc(e){try{let t=await fetch(`https://registry.npmjs.org/@vantaloom/runtime-${e}`,{headers:{Accept:"application/vnd.npm.install-v1+json"},cache:"no-store"});if(!t.ok)return;let n=await t.json();return n?.["dist-tags"]?.latest}catch{return}}function ecd(){return(0,eb.jsx)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:(0,eb.jsx)(ecu,{})})})}function ecu(){let[e,t]=ew.useState([]),[n,r]=ew.useState(!0),a=ew.useRef(!0),i=ew.useCallback((e,n)=>{t(t=>t.map(t=>t.machine.id===e?{...t,...n}:t))},[]),o=ew.useCallback(async()=>{r(!0);let e=[];try{let t=await fetch((0,eT.localAPIURL)("/v1/remote/machines"),{cache:"no-store"});e=(await t.json()).machines??[]}catch{e=[]}a.current&&(t(e.map(e=>({machine:e,loading:!0}))),r(!1),await Promise.all(e.map(async e=>{if(!e.isLocal&&"online"!==e.status){a.current&&i(e.id,{loading:!1,error:"离线"});return}try{let t,n=await fetch(ecs(e,"/v1/runtime/info"),{cache:"no-store"});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.text();try{t=JSON.parse(r)}catch{throw Error("该机器运行时过旧,不支持版本检测")}let o=await ecc(t.platform);a.current&&i(e.id,{info:t,latest:o,loading:!1})}catch(t){a.current&&i(e.id,{loading:!1,error:t instanceof Error?t.message:"无法获取版本"})}})))},[i]);async function l(e){if(e.info&&!e.updating){i(e.machine.id,{updating:!0});try{await fetch(ecs(e.machine,"/v1/runtime/update"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({version:e.latest})})}catch{}window.setTimeout(()=>{a.current&&o()},25e3)}}return ew.useEffect(()=>(a.current=!0,o(),()=>{a.current=!1}),[o]),(0,eb.jsxs)("div",{className:"flex flex-col gap-5 text-foreground","data-tour":"check-update",children:[(0,eb.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,eb.jsx)("div",{children:(0,eb.jsx)("p",{className:"text-sm text-muted-foreground",children:"工作组内各机器的运行时版本与可用更新。点击「立即更新」可让对应机器自动更新(该机器会短暂重启)。"})}),(0,eb.jsxs)(eO.Button,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void o(),disabled:n,children:[(0,eb.jsx)(yt,{className:(0,ez.cn)("size-4",n&&"animate-spin")}),"刷新"]})]}),n&&0===e.length?(0,eb.jsxs)("div",{className:"flex items-center justify-center gap-2 rounded-xl border bg-card p-8 text-sm text-muted-foreground",children:[(0,eb.jsx)(eM,{className:"size-4 animate-spin"})," 正在获取机器列表…"]}):0===e.length?(0,eb.jsx)("div",{className:"rounded-xl border bg-card p-8 text-center text-sm text-muted-foreground",children:"暂无可用机器。"}):(0,eb.jsx)("div",{className:"flex flex-col gap-2",children:e.map(e=>{let t=!!e.info&&!!e.latest&&e.latest!==e.info.version;return(0,eb.jsxs)("div",{className:"flex items-center gap-4 rounded-xl border bg-card px-4 py-3",children:[(0,eb.jsx)(eP,{className:"size-5 shrink-0 text-muted-foreground"}),(0,eb.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)("span",{className:"truncate text-sm font-medium",children:e.machine.name}),e.machine.isLocal?(0,eb.jsx)("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:"本机"}):null]}),(0,eb.jsx)("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:e.loading?"读取版本中…":e.error?(0,eb.jsx)("span",{className:"text-amber-600",children:e.error}):(0,eb.jsxs)(eb.Fragment,{children:[function(e){switch(e){case"windows":return"Windows";case"darwin":return"macOS";case"linux":return"Linux";case"android":return"Android";default:return e||"未知"}}(e.info?.os??e.machine.platform??"")," · 当前 ",(0,eb.jsx)("span",{className:"font-mono",children:e.info?.version??"?"}),e.latest?(0,eb.jsxs)(eb.Fragment,{children:[" · 最新 ",(0,eb.jsx)("span",{className:"font-mono",children:e.latest})]}):null,e.info?.updatedAt?(0,eb.jsxs)(eb.Fragment,{children:[" · 更新于 ",function(e){if(!e)return"—";let t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t):"—"}(e.info.updatedAt)]}):null]})})]}),e.loading?(0,eb.jsx)(eM,{className:"size-4 animate-spin text-muted-foreground"}):e.updating?(0,eb.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-primary",children:[(0,eb.jsx)(eM,{className:"size-4 animate-spin"})," 更新中…"]}):t?(0,eb.jsxs)(eO.Button,{size:"sm",onClick:()=>void l(e),children:[(0,eb.jsx)(ecl,{className:"size-4"})," 立即更新"]}):e.info?(0,eb.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,eb.jsx)(eI,{className:"size-4 text-emerald-500"})," 已是最新"]}):null]},e.machine.id)})}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"最新版本号来自 npm(@vantaloom/runtime-<平台>)。更新过程中该机器会停止并重启运行时, 若你的手机正连着它会短暂断开,更新完成后重新连接即可。"})]})}let ecf=(0,ek.default)("image-plus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]),ecm=[{value:"bug",label:"功能异常"},{value:"feature",label:"功能建议"},{value:"billing",label:"计费与余额"},{value:"other",label:"其他"}],ech=Object.fromEntries(ecm.map(e=>[e.value,e.label])),ecp={pending:{label:"待审批",variant:"secondary"},preparing:{label:"准备完成",variant:"outline"},done:{label:"已完成",variant:"default"},noplan:{label:"暂时无计划",variant:"secondary"}};function ecg(){return(0,eb.jsx)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:(0,eb.jsx)(ecx,{})})})}function ecx(){let{user:e}=ti(),[t,n]=ew.useState(""),[r,a]=ew.useState("bug"),[i,o]=ew.useState(""),[l,s]=ew.useState([]),[c,d]=ew.useState(!1),[u,f]=ew.useState(null),[m,h]=ew.useState(!1),p=ew.useRef(null),[g,x]=ew.useState([]),[v,b]=ew.useState(!0),[y,w]=ew.useState(null),j=ew.useCallback(async()=>{b(!0);try{let e=await e9();x(e.issues)}catch{x([])}finally{b(!1)}},[]);function k(e){let t=Array.from(e).filter(e=>e.type.startsWith("image/"));f(null),s(e=>{let n=[...e];for(let e of t){if(n.length>=10){f({kind:"err",text:`最多上传 10 张图片`});break}if(e.size>8388608){f({kind:"err",text:`「${e.name}」过大(上限 8MB)`});continue}n.push({id:`${e.name}-${e.size}-${n.length}`,file:e,url:URL.createObjectURL(e)})}return n})}async function N(){if(!t.trim())return void f({kind:"err",text:"请填写标题"});d(!0),f(null);try{let{issue:e}=await e7({title:t.trim(),type:r,content:i.trim()}),c=!1;for(let t of l)try{await te(e.id,t.file)}catch{c=!0}f({kind:"ok",text:c?"反馈已提交,但部分图片上传失败,请在下方列表确认":"反馈已提交,感谢您的反馈!"}),n(""),a("bug"),o(""),l.forEach(e=>URL.revokeObjectURL(e.url)),s([]),j()}catch(e){f({kind:"err",text:e instanceof Error?e.message:"提交失败,请重试"})}finally{d(!1)}}return ew.useEffect(()=>{e&&j()},[e,j]),ew.useEffect(()=>()=>{l.forEach(e=>URL.revokeObjectURL(e.url))},[]),e?(0,eb.jsxs)("div",{className:"grid gap-6 text-foreground",children:[(0,eb.jsx)("div",{className:"min-w-0",children:(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"提交功能异常、建议或计费问题,我们会在看板中跟进处理。"})}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"标题"}),(0,eb.jsx)(eA,{value:t,onChange:e=>n(e.target.value),maxLength:120,placeholder:"简要描述问题"})]}),(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"类型"}),(0,eb.jsxs)(gU,{value:r,onValueChange:a,children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:ecm.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]})]}),(0,eb.jsxs)("div",{className:"grid gap-1.5",children:[(0,eb.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"详细描述"}),(0,eb.jsx)(w2,{value:i,onChange:e=>o(e.target.value),rows:5,placeholder:"详细描述问题的复现步骤、期望行为等",onPaste:e=>{let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith("image/"));t.length>0&&(e.preventDefault(),k(t))}})]}),(0,eb.jsxs)("div",{className:(0,ez.cn)("grid gap-3 rounded-lg border border-dashed p-3 transition-colors",m?"border-primary bg-primary/5":"border-input"),onDragOver:e=>{e.preventDefault(),h(!0)},onDragLeave:()=>h(!1),onDrop:e=>{e.preventDefault(),h(!1),e.dataTransfer.files.length>0&&k(e.dataTransfer.files)},children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,eb.jsxs)("p",{className:"text-xs text-muted-foreground",children:["可拖拽、粘贴或选择图片(最多 ",10," 张,单张 ≤ 8MB)"]}),(0,eb.jsxs)(eO.Button,{type:"button",variant:"outline",size:"sm",className:"shrink-0",onClick:()=>p.current?.click(),children:[(0,eb.jsx)(ecf,{}),"添加图片"]}),(0,eb.jsx)("input",{ref:p,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&k(e.target.files),e.target.value=""}})]}),l.length>0?(0,eb.jsx)("div",{className:"flex flex-wrap gap-2",children:l.map(e=>(0,eb.jsxs)("div",{className:"relative size-16 overflow-hidden rounded-md border",children:[(0,eb.jsx)("img",{src:e.url,alt:e.file.name,className:"size-full object-cover"}),(0,eb.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.id,void s(e=>{let n=e.find(e=>e.id===t);return n&&URL.revokeObjectURL(n.url),e.filter(e=>e.id!==t)})},className:"absolute right-0.5 top-0.5 rounded-full bg-black/55 p-0.5 text-white hover:bg-black/75","aria-label":"移除图片",children:(0,eb.jsx)(fV.XIcon,{className:"size-3"})})]},e.id))}):null]}),u?(0,eb.jsx)("p",{className:(0,ez.cn)("text-xs","ok"===u.kind?"text-primary":"text-destructive"),children:u.text}):null,(0,eb.jsx)("div",{className:"flex justify-end",children:(0,eb.jsxs)(eO.Button,{onClick:()=>void N(),disabled:c||!t.trim(),children:[c?(0,eb.jsx)(eM,{className:"animate-spin"}):(0,eb.jsx)(eoI,{}),"提交反馈"]})})]}),(0,eb.jsxs)("section",{className:"grid gap-3",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"我的反馈"}),v?(0,eb.jsx)("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:(0,eb.jsx)(eM,{className:"size-5 animate-spin"})}):0===g.length?(0,eb.jsx)("p",{className:"rounded-lg border bg-card p-6 text-center text-xs text-muted-foreground",children:"你还没有提交过反馈。"}):g.map(e=>{let t=ecp[e.status]??{label:e.status,variant:"secondary"};return(0,eb.jsxs)("article",{className:"grid gap-2 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,eb.jsx)("p",{className:"min-w-0 flex-1 break-words text-sm font-medium",children:e.title}),(0,eb.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[(0,eb.jsx)(Vp,{variant:"outline",children:ech[e.type]??e.type}),(0,eb.jsx)(Vp,{variant:t.variant,children:t.label})]})]}),e.content?(0,eb.jsx)("p",{className:"whitespace-pre-wrap break-words text-xs text-muted-foreground",children:e.content}):null,e.images.length>0?(0,eb.jsx)("div",{className:"flex flex-wrap gap-2",children:e.images.map(t=>(0,eb.jsx)("button",{type:"button",className:"size-16 overflow-hidden rounded-md border",onClick:()=>w({issueId:e.id,imageId:t.id}),children:(0,eb.jsx)(ecy,{issueId:e.id,imageId:t.id})},t.id))}):null,(0,eb.jsx)("p",{className:"text-[11px] text-muted-foreground",children:new Date(e.createdAt).toLocaleString("zh-CN")})]},e.id)})]}),(0,eb.jsx)(ecv,{}),(0,eb.jsx)(dX,{open:null!==y,onOpenChange:e=>{e||w(null)},children:(0,eb.jsx)(fU,{className:"max-w-3xl",children:y?(0,eb.jsx)(ecw,{issueId:y.issueId,imageId:y.imageId,className:"max-h-[75vh] w-full object-contain"}):null})})]}):(0,eb.jsxs)("div",{className:"grid gap-6 text-foreground",children:[(0,eb.jsx)(ecv,{}),(0,eb.jsxs)("div",{className:"flex flex-col items-center gap-3 rounded-lg border bg-card py-16 text-center",children:[(0,eb.jsx)(kM,{className:"size-8 text-muted-foreground/40"}),(0,eb.jsx)("p",{className:"text-sm font-medium",children:"未登录 Hub 账户"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"请先在「系统设置 · Hub 账户」中登录,再提交问题反馈。"})]})]})}function ecv(){let[e,t]=ew.useState(!1),[n,r]=ew.useState(!0),[a,i]=ew.useState(!1),[o,l]=ew.useState(null);async function s(n){if(!a){t(n),i(!0),l(null);try{let e=await ks({telemetry:{enabled:n}});t(e.telemetry?.enabled??n)}catch(n){t(e),l(n instanceof Error?n.message:"保存失败,请重试")}finally{i(!1)}}}return ew.useEffect(()=>{let e=!1;return async function(){try{let n=await kl();e||t(n.telemetry?.enabled??!1)}catch{}finally{e||r(!1)}}(),()=>{e=!0}},[]),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eb.jsx)(uV,{className:"size-4 text-muted-foreground"}),(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"错误诊断上报"})]}),(0,eb.jsxs)("p",{className:"text-xs text-muted-foreground",children:["默认",(0,eb.jsx)("span",{className:"font-medium text-foreground",children:"关闭"}),"。开启后,",(0,eb.jsx)("span",{className:"font-medium text-foreground",children:"仅当出现网络错误时"}),",应用会把少量非隐私设备信息(系统 / 架构 / 版本 / 代理模式 / 网络开关 等) 与",(0,eb.jsx)("span",{className:"font-medium text-foreground",children:"完整错误文本"}),"上报到 Hub,用于协助排查连接问题。"]}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"允许错误诊断上报"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"关闭时应用不会进行任何遥测网络请求。"})]}),(0,eb.jsx)(bG,{checked:e,disabled:n||a,onCheckedChange:e=>void s(e)})]}),(0,eb.jsx)("div",{className:"rounded-md bg-muted/50 px-3 py-2",children:(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"绝不会上报:API 密钥、代理地址、文件路径、对话内容,以及你的 Hub 身份。"})}),o?(0,eb.jsx)("p",{className:"text-xs text-destructive",children:o}):null]})}function ecb(e,t){let[n,r]=ew.useState(null);return ew.useEffect(()=>{let n=!0,a=null;return tt(e,t).then(e=>{a=e,n?r(e):URL.revokeObjectURL(e)}).catch(()=>{}),()=>{n=!1,a&&URL.revokeObjectURL(a)}},[e,t]),n}function ecy({issueId:e,imageId:t}){let n=ecb(e,t);return n?(0,eb.jsx)("img",{src:n,alt:"",className:"size-full object-cover"}):(0,eb.jsx)("div",{className:"flex size-full items-center justify-center bg-muted"})}function ecw({issueId:e,imageId:t,className:n}){let r=ecb(e,t);return r?(0,eb.jsx)("img",{src:r,alt:"",className:n}):(0,eb.jsx)("div",{className:"flex h-64 items-center justify-center text-muted-foreground",children:(0,eb.jsx)(eM,{className:"size-5 animate-spin"})})}function ecj(){return(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex flex-col gap-0.5 border-b px-4 py-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(Yw,{}),"系统设置"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:"系统设置"})]}),(0,eb.jsx)(etm,{sections:[{id:"topology",title:"组网关系",icon:(0,eb.jsx)(enH,{}),content:(0,eb.jsx)(ece,{})},{id:"update",title:"检查更新",icon:(0,eb.jsx)(yt,{}),content:(0,eb.jsx)(ecu,{})},{id:"account",title:"账户设置",icon:(0,eb.jsx)(eC,{}),content:(0,eb.jsx)(esa,{})},{id:"balance",title:"余额用量",icon:(0,eb.jsx)(es5,{}),content:(0,eb.jsx)(eci,{})},{id:"feedback",title:"问题反馈",icon:(0,eb.jsx)(kM,{}),content:(0,eb.jsx)(ecx,{})}],defaultSectionId:"topology",labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto"})]})}let eck=(0,ek.default)("pause",[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]]);function ecN(e){if(!Number.isFinite(e)||e<0)return"—";if(e<1024)return`${e} B`;let t=["KB","MB","GB","TB"],n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n.toFixed(n>=100?0:1)} ${t[r]}`}function ecS({status:e}){switch(e){case"active":return(0,eb.jsx)(Vp,{variant:"default",children:"下载中"});case"complete":return(0,eb.jsx)(Vp,{className:"border-transparent bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",children:"已完成"});case"error":return(0,eb.jsx)(Vp,{variant:"destructive",children:"失败"});case"paused":return(0,eb.jsx)(Vp,{variant:"secondary",children:"已暂停"});case"canceled":return(0,eb.jsx)(Vp,{variant:"outline",children:"已取消"});default:return(0,eb.jsx)(Vp,{variant:"outline",children:"等待中"})}}let ecC=["complete","error","canceled"];function ecM({download:e}){let{status:t,percent:n,totalBytes:r}=e,a=Math.max(0,Math.min(100,n));return r<0&&"active"===t?(0,eb.jsx)("div",{className:"relative h-1.5 w-full overflow-hidden rounded-full bg-muted",children:(0,eb.jsx)("div",{className:(0,ez.cn)("absolute inset-y-0 w-1/3 rounded-full bg-primary/70","vtl-download-indeterminate")})}):(0,eb.jsx)("div",{className:"relative h-1.5 w-full overflow-hidden rounded-full bg-muted",children:(0,eb.jsx)("div",{className:(0,ez.cn)("h-full rounded-full transition-all","error"===t?"bg-destructive":"complete"===t?"bg-emerald-500":"paused"===t?"bg-muted-foreground/60":"bg-primary","active"===t&&"vtl-download-stripes bg-[length:1rem_1rem]"),style:{width:`${a}%`}})})}function ecE({download:e}){var t,n,r;let a,[i,o]=ew.useState(!1),l=ew.useCallback(async e=>{o(!0);try{await e()}catch{}finally{o(!1)}},[]),{status:s}=e,c="active"===s?!Number.isFinite(t=e.speedBps)||t<=0?"":`${ecN(t)}/s`:"",d="active"===s?function(e){if(!Number.isFinite(e)||e<0)return"";let t=Math.round(e),n=Math.floor(t/3600),r=Math.floor(t%3600/60),a=t%60;return n>0?`${n}:${String(r).padStart(2,"0")}:${String(a).padStart(2,"0")}`:`${String(r).padStart(2,"0")}:${String(a).padStart(2,"0")}`}(e.etaSeconds):"",u=!(e.totalBytes<0&&"active"===s),f="active"===s,m="paused"===s,h="error"===s||"canceled"===s,p="active"===s||"paused"===s||"waiting"===s,g=ecC.includes(s);return(0,eb.jsxs)("div",{className:"grid gap-2 rounded-lg border bg-card p-3",children:[(0,eb.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eb.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,eb.jsx)("span",{className:"truncate text-sm font-medium text-foreground",children:e.label||e.url||e.id}),(0,eb.jsx)(ecS,{status:s}),e.attempt>1&&(0,eb.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:["重试 ",e.attempt]})]}),e.dest&&(0,eb.jsx)("p",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:e.dest})]}),(0,eb.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[i&&(0,eb.jsx)(HR,{className:"size-3.5"}),f&&(0,eb.jsx)(eO.Button,{size:"icon",variant:"ghost",className:"size-7",disabled:i,title:"暂停","aria-label":"暂停",onClick:()=>l(()=>h2(e.id,"pause")),children:(0,eb.jsx)(eck,{className:"size-3.5"})}),m&&(0,eb.jsx)(eO.Button,{size:"icon",variant:"ghost",className:"size-7",disabled:i,title:"继续","aria-label":"继续",onClick:()=>l(()=>h2(e.id,"resume")),children:(0,eb.jsx)(HE,{className:"size-3.5"})}),h&&(0,eb.jsx)(eO.Button,{size:"icon",variant:"ghost",className:"size-7",disabled:i,title:"重试","aria-label":"重试",onClick:()=>l(()=>h2(e.id,"retry")),children:(0,eb.jsx)(yt,{className:"size-3.5"})}),p&&(0,eb.jsx)(eO.Button,{size:"icon",variant:"ghost",className:"size-7",disabled:i,title:"取消","aria-label":"取消",onClick:()=>l(()=>h2(e.id,"cancel")),children:(0,eb.jsx)(fV.XIcon,{className:"size-3.5"})}),g&&(0,eb.jsx)(eO.Button,{size:"icon",variant:"ghost",className:"size-7 text-muted-foreground hover:text-destructive",disabled:i,title:"移除","aria-label":"移除",onClick:()=>l(()=>h2(e.id,"remove")),children:(0,eb.jsx)(yn,{className:"size-3.5"})})]})]}),(0,eb.jsx)(ecM,{download:e}),(0,eb.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[u&&(0,eb.jsxs)("span",{className:"tabular-nums",children:[Math.round(e.percent),"%"]}),(0,eb.jsx)("span",{className:"tabular-nums",children:(n=e.downloadedBytes,r=e.totalBytes,a=ecN(n),r<0?a:`${a} / ${ecN(r)}`)}),c&&(0,eb.jsx)("span",{className:"tabular-nums",children:c}),d&&(0,eb.jsxs)("span",{className:"tabular-nums",children:["剩余 ",d]}),e.connections>0&&(0,eb.jsxs)("span",{className:"tabular-nums",children:[e.connections," 连接"]})]}),"error"===s&&e.error&&(0,eb.jsx)("p",{className:"text-[11px] text-destructive",children:e.error})]})}function ecI(){let[e,t]=ew.useState([]),[n,r]=ew.useState("loading"),[a,i]=ew.useState(0),o=ew.useCallback(()=>{r("loading"),i(e=>e+1)},[]);return(ew.useEffect(()=>{let e,n=!1,a=new AbortController,i=e=>{n||(t(e),r("ready"))};async function o(){try{let e=await hQ({signal:a.signal});if(n)return;t(e.downloads),r("ready")}catch(e){if(n||a.signal.aborted)return;if(e instanceof hJ)return void r("unavailable")}try{await h0(i,{signal:a.signal}),n||l()}catch(e){if(n||a.signal.aborted)return;if(e instanceof hJ)return void r("unavailable");r(e=>"ready"===e?"ready":"error"),l()}}function l(){n||(e=setTimeout(()=>{n||o()},2e3))}return o(),()=>{n=!0,a.abort(),e&&clearTimeout(e)}},[a]),"loading"===n)?(0,eb.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border bg-card p-6 text-sm text-muted-foreground",children:[(0,eb.jsx)(HR,{className:"size-4"}),"正在获取下载状态…"]}):"unavailable"===n||"error"===n?(0,eb.jsxs)("div",{className:"grid gap-3 rounded-lg border border-destructive/30 bg-destructive/5 p-6",children:[(0,eb.jsx)("p",{className:"text-sm text-destructive",children:"无法获取下载状态"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"请确认本机运行时已启动,稍后重试。"}),(0,eb.jsx)("div",{children:(0,eb.jsxs)(eO.Button,{variant:"outline",size:"sm",onClick:o,children:[(0,eb.jsx)(yt,{className:"size-3.5"}),"重试"]})})]}):0===e.length?(0,eb.jsx)("div",{className:"rounded-lg border bg-card p-10 text-center text-sm text-muted-foreground",children:"暂无下载任务"}):(0,eb.jsx)("div",{className:"grid gap-2",children:e.map(e=>(0,eb.jsx)(ecE,{download:e},e.id))})}function ecP({label:e,description:t,value:n,min:r,max:a,onChange:i,disabled:o}){return(0,eb.jsxs)("label",{className:"grid gap-1.5",children:[(0,eb.jsx)("span",{className:"text-xs font-medium text-foreground",children:e}),t&&(0,eb.jsx)("span",{className:"text-[11px] text-muted-foreground",children:t}),(0,eb.jsx)(eA,{type:"number",inputMode:"numeric",min:r,max:a,value:Number.isFinite(n)?n:0,disabled:o,onChange:e=>{let t=Number(e.target.value);if(Number.isNaN(t))return;let n=t;void 0!==r&&(n=Math.max(r,n)),void 0!==a&&(n=Math.min(a,n)),i(n)},className:"max-w-[12rem]"})]})}function ecO(){let[e,t]=ew.useState(null),[n,r]=ew.useState("loading"),[a,i]=ew.useState(!1),[o,l]=ew.useState(!1),[s,c]=ew.useState(null),[d,u]=ew.useState(0),f=ew.useCallback(()=>{r("loading"),u(e=>e+1)},[]);ew.useEffect(()=>{let e=!1,n=new AbortController;return async function(){try{let a=await h5({signal:n.signal});if(e)return;t(a),r("ready")}catch(t){if(e||n.signal.aborted)return;r(t instanceof hJ?"unavailable":"error")}}(),()=>{e=!0,n.abort()}},[d]);let m=ew.useCallback((e,n)=>{t(t=>t?{...t,[e]:n}:t),l(!1)},[]),h=ew.useCallback(async()=>{if(e){i(!0),c(null),l(!1);try{let n=await h4(e);t(n),l(!0)}catch{c("保存失败,请稍后重试。")}finally{i(!1)}}},[e]);return"loading"===n?(0,eb.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border bg-card p-6 text-sm text-muted-foreground",children:[(0,eb.jsx)(HR,{className:"size-4"}),"正在加载下载设置…"]}):"unavailable"!==n&&"error"!==n&&e?(0,eb.jsxs)("section",{className:"grid gap-4 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("label",{className:"grid gap-1.5",children:[(0,eb.jsx)("span",{className:"text-xs font-medium text-foreground",children:"下载目录"}),(0,eb.jsx)("span",{className:"text-[11px] text-muted-foreground",children:"下载文件的默认保存位置。"}),(0,eb.jsx)(eA,{type:"text",value:e.downloadDir,disabled:a,placeholder:"例如 D:\\\\Downloads",onChange:e=>m("downloadDir",e.target.value)})]}),(0,eb.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,eb.jsx)(ecP,{label:"最大同时下载数",description:"同时进行的任务数量上限。",value:e.maxConcurrentDownloads,min:1,max:32,disabled:a,onChange:e=>m("maxConcurrentDownloads",e)}),(0,eb.jsx)(ecP,{label:"单任务最大连接数",description:"单个任务的并发分段连接数(1–16)。",value:e.maxConnectionsPerTask,min:1,max:16,disabled:a,onChange:e=>m("maxConnectionsPerTask",e)}),(0,eb.jsx)(ecP,{label:"失败重试次数",description:"任务失败后的自动重试上限。",value:e.maxRetries,min:0,max:20,disabled:a,onChange:e=>m("maxRetries",e)})]}),(0,eb.jsxs)("label",{className:"grid gap-1.5",children:[(0,eb.jsx)("span",{className:"text-xs font-medium text-foreground",children:"代理"}),(0,eb.jsx)("span",{className:"text-[11px] text-muted-foreground",children:"下载使用的代理地址,留空则不使用代理。"}),(0,eb.jsx)(eA,{type:"text",value:e.proxy,disabled:a,placeholder:"例如 http://127.0.0.1:7890(留空=不使用)",onChange:e=>m("proxy",e.target.value)})]}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-lg border bg-background p-3",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("p",{className:"text-sm font-medium text-foreground",children:"校验文件哈希"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"下载完成后校验文件哈希以确保完整性。"})]}),(0,eb.jsx)(bG,{checked:e.verifyChecksums,disabled:a,onCheckedChange:e=>m("verifyChecksums",e),"aria-label":"校验文件哈希"})]}),(0,eb.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,eb.jsxs)(eO.Button,{size:"sm",disabled:a,onClick:h,children:[a?(0,eb.jsx)(HR,{className:"size-3.5"}):null,a?"正在保存…":"保存设置"]}),o&&!a&&(0,eb.jsx)("span",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"已保存"}),s&&(0,eb.jsx)("span",{className:"text-xs text-destructive",children:s})]})]}):(0,eb.jsxs)("div",{className:"grid gap-3 rounded-lg border border-destructive/30 bg-destructive/5 p-6",children:[(0,eb.jsx)("p",{className:"text-sm text-destructive",children:"无法获取下载设置"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"请确认本机运行时已启动,稍后重试。"}),(0,eb.jsx)("div",{children:(0,eb.jsxs)(eO.Button,{variant:"outline",size:"sm",onClick:f,children:[(0,eb.jsx)(yt,{className:"size-3.5"}),"重试"]})})]})}function ecz(){return(0,eb.jsxs)("div",{className:"grid gap-6","data-tour":"system-downloads",children:[(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsx)("h4",{className:"text-sm font-medium text-foreground",children:"下载任务"}),(0,eb.jsx)(ecI,{})]}),(0,eb.jsxs)("div",{className:"grid gap-3",children:[(0,eb.jsx)("h4",{className:"text-sm font-medium text-foreground",children:"全局设置"}),(0,eb.jsx)(ecO,{})]})]})}function ecA(){return(0,eb.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:(0,eb.jsx)("div",{className:"mx-auto w-full max-w-3xl",children:(0,eb.jsxs)("div",{className:"grid gap-6",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsxs)("h3",{className:"flex items-center gap-2 text-base font-semibold tracking-normal",children:[(0,eb.jsx)(bJ,{className:"size-4"}),"下载"]}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"管理本机的下载任务,并配置下载目录、并发与代理等全局选项。"})]}),(0,eb.jsx)(ecz,{})]})})})}let ecT=[{value:"system",label:"跟随系统",help:"读取操作系统的系统代理设置(Windows 注册表 / Clash「系统代理」模式)。注意:macOS / Linux 上没有系统代理读取能力,此项等价于「仅环境变量」。"},{value:"env",label:"仅环境变量",help:"只使用 HTTP_PROXY / HTTPS_PROXY / NO_PROXY 环境变量,忽略系统代理设置。"},{value:"direct",label:"直连",help:"不使用任何代理,直接连接。在「只能走代理」的网络环境下会失败。"},{value:"custom",label:"自定义",help:"手动指定代理地址(见下方)。注意:当前仅支持 http / https 代理(CONNECT 隧道),socks5 代理可能无法生效。"}];function ecR(e){let t=e.network;return{enableUTLS:t?.enableUTLS??!0,enableBrowserHeaders:t?.enableBrowserHeaders??!0,proxyMode:t?.proxyMode??"system",customProxyURL:t?.customProxyURL??"",retryCount:t?.retryCount??3,retryDelaysMs:t?.retryDelaysMs??[],enableFallback:t?.enableFallback??!0,streamIdleTimeoutMs:t?.streamIdleTimeoutMs??0}}function ecD(){let[e,t]=ew.useState(null),[n,r]=ew.useState(!0),[a,i]=ew.useState(!1),[o,l]=ew.useState(""),[s,c]=ew.useState(!1),[d,u]=ew.useState(null),f=ew.useRef(null);function m(e){t(t=>t?{...t,...e}:t),c(!0),u(null)}async function h(){if(e&&!a){i(!0),l("");try{let n=await ks({network:e});f.current=n,t(ecR(n)),c(!1),u(Date.now())}catch(e){l(e instanceof Error?e.message:"Save failed")}finally{i(!1)}}}if(ew.useEffect(()=>{!async function(){try{let e=await kl();f.current=e,t(ecR(e))}catch(e){l(e instanceof Error?e.message:"Failed to load config")}finally{r(!1)}}()},[]),n)return(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取网络设置"});if(!e)return(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"读取失败"}),(0,eb.jsx)(etJ,{children:o||"无法加载网络设置"})]});let p=ecT.find(t=>t.value===e.proxyMode),g=function(e){if(!e)return e;try{let t=new URL(e);return(t.username||t.password)&&(t.username=t.username?"***":"",t.password=t.password?"***":""),t.toString()}catch{return e.replace(/\/\/[^/@]+@/,"//***:***@")}}(e.customProxyURL??"");return(0,eb.jsxs)("div",{className:"grid gap-6 pb-20",children:[o?(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"错误"}),(0,eb.jsx)(etJ,{children:o})]}):null,(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"传输层伪装"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"模拟真实浏览器的 TLS 指纹与请求头,避免被 Cloudflare 等防护按机器人流量重置连接。"}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"启用 uTLS 指纹伪装"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"使用 Chrome 的 TLS ClientHello 指纹(JA3/JA4),绕过基于指纹的连接重置。建议保持开启。"})]}),(0,eb.jsx)(bG,{checked:e.enableUTLS,onCheckedChange:e=>m({enableUTLS:e})})]}),e.enableUTLS?null:(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(m0,{}),(0,eb.jsx)(etZ,{children:"已关闭 uTLS 指纹伪装"}),(0,eb.jsx)(etJ,{children:"关闭后部分 Cloudflare 渠道可能连接被重置(TCP reset / 握手失败)。仅在 uTLS 反而导致连接异常时关闭。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"启用浏览器请求头"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"为出站请求注入 Chrome 的 User-Agent / sec-ch-ua 等请求头,进一步降低被识别为机器人的概率。"})]}),(0,eb.jsx)(bG,{checked:e.enableBrowserHeaders,onCheckedChange:e=>m({enableBrowserHeaders:e})})]})]}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"代理模式"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"控制所有出站请求(模型列表拉取 + 对话流)如何解析代理。换机器表现不一时,通常是这里的问题。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"代理模式"}),(0,eb.jsxs)(gU,{value:e.proxyMode,onValueChange:e=>m({proxyMode:e}),children:[(0,eb.jsx)(xj,{className:"w-full",children:(0,eb.jsx)(gG,{})}),(0,eb.jsx)(xS,{children:ecT.map(e=>(0,eb.jsx)(xC,{value:e.value,children:e.label},e.value))})]}),p?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:p.help}):null]}),"custom"===e.proxyMode?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"自定义代理地址"}),(0,eb.jsx)(eA,{value:e.customProxyURL??"",onChange:e=>m({customProxyURL:e.currentTarget.value}),placeholder:"http://127.0.0.1:7890",spellCheck:!1,autoComplete:"off"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"仅支持 http / https 代理。若填写包含账号密码(user:pass),日志中会被脱敏处理。"}),g&&g!==e.customProxyURL?(0,eb.jsxs)("p",{className:"text-xs text-muted-foreground",children:["脱敏预览:",g]}):null]})]}):null]}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"重试与降级"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"请求因网络抖动(连接重置 / 网关 5xx)失败时的自动恢复策略。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"重试次数"}),(0,eb.jsxs)("span",{className:"text-sm tabular-nums text-muted-foreground",children:[e.retryCount," 次"]})]}),(0,eb.jsx)(enx,{value:[e.retryCount],onValueChange:([e])=>m({retryCount:e}),min:0,max:10,step:1}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"可重试的请求失败后自动重试的次数(仅在尚未产出内容时重试,避免重复输出)。设为 0 表示不重试。默认 3。"})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"启用降级回退"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"连接失败时自动逐级降级:uTLS → 直连 → 标准 TLS,绕开坏代理 / 回环 / 指纹被重置等问题。关闭后将严格按当前模式连接(便于排查真实错误)。"})]}),(0,eb.jsx)(bG,{checked:e.enableFallback,onCheckedChange:e=>m({enableFallback:e})})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"吐字超时(秒)"}),(0,eb.jsx)(eA,{type:"number",inputMode:"numeric",min:0,step:1,value:e.streamIdleTimeoutMs&&e.streamIdleTimeoutMs>0?Math.round(e.streamIdleTimeoutMs/1e3):0,onChange:e=>{let t=Number(e.currentTarget.value);m({streamIdleTimeoutMs:1e3*(Number.isFinite(t)&&t>0?Math.round(t):0)})},placeholder:"0",spellCheck:!1,autoComplete:"off",className:"w-32"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"上游超过该时间未返回任何内容则判定为错误并重试;0 = 不限制(默认)。常用值如 30 / 60 / 120 秒。"})]})]}),(0,eb.jsx)(env,{dirty:s,saving:a,savedAt:d,onSave:()=>void h(),onReset:function(){f.current&&(t(ecR(f.current)),c(!1),l(""))}})]})}function ec_(){return(0,eb.jsx)(ecD,{})}function ecL(){return(0,eb.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"shrink-0 border-b px-6 py-4",children:[(0,eb.jsx)("h2",{className:"text-base font-semibold tracking-normal",children:"网络设置"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"调整出站请求的传输伪装、代理模式与失败重试,以适配不同网络环境并应对 Cloudflare 连接异常。"})]}),(0,eb.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-6",children:(0,eb.jsx)("div",{className:"mx-auto max-w-2xl",children:(0,eb.jsx)(ec_,{})})})]})}function ec$(){return(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex flex-col gap-0.5 border-b px-4 py-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(enH,{}),"网络与下载"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:"网络与下载"})]}),(0,eb.jsx)(etm,{sections:[{id:"network",title:"网络设置",icon:(0,eb.jsx)(enH,{}),content:(0,eb.jsx)(ec_,{})},{id:"downloads",title:"下载",icon:(0,eb.jsx)(bJ,{}),content:(0,eb.jsx)(ecz,{})}],defaultSectionId:"network",labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto"})]})}let ecF=(0,ek.default)("list-ordered",[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]]),ecB=[{value:"",label:"不使用(仅搜索引擎兜底)",help:"不接入 AI 搜索渠道,只用下方的搜索引擎兜底抓取。无需任何 Key。"},{value:"hub",label:"官方自带搜索(Hub)",help:"使用 Vantaloom Hub 的官方搜索(Grok 实时联网),无需自备 Key——直接用你的 Hub 登录额度,按次计费。需登录 Hub 账户。"},{value:"tavily",label:"Tavily(国际 · 为 LLM 优化)",help:"专为 AI agent 设计,结果干净、含摘要,免费额度较大。需走代理访问。在 tavily.com 获取 API Key。"},{value:"bocha",label:"博查 Bocha(国内 · 直连免代理)",help:"国产、为大模型设计的搜索 API,人民币计费、国内直连无需翻墙。在 bochaai.com 获取 API Key。"},{value:"brave",label:"Brave Search(国际 · 独立索引)",help:"独立网页索引,隐私友好、价格便宜。需走代理访问。在 brave.com/search/api 获取订阅 Token。"},{value:"serper",label:"Serper(国际 · Google 结果)",help:"Google 搜索结果转 JSON,便宜快速。需走代理访问。在 serper.dev 获取 API Key。"}],ecV=[{value:"bing",label:"Bing(默认,较稳定)"},{value:"duckduckgo",label:"DuckDuckGo"}],ecH=[{value:"auto",label:"自动(先 Jina 后 Firecrawl)",help:"默认。先用 Jina Reader(免费、轻),失败或为空时若配置了 Firecrawl Key 再用 Firecrawl 兜底。"},{value:"jina",label:"仅 Jina Reader",help:"只用 Jina Reader(r.jina.ai)。免费可用、有速率限制;填 Key 可提高限额。"},{value:"firecrawl",label:"仅 Firecrawl",help:"只用 Firecrawl(正文抽取更强),必须配置下方的 Firecrawl API Key。"}];function ecU(e){let t=e.search;return{enable:t?.enable??!0,provider:t?.provider??"",apiKey:t?.apiKey??"",endpoint:t?.endpoint??"",enableEngineFallback:t?.enableEngineFallback??!0,engine:t?.engine??"bing",defaultReader:t?.defaultReader??"auto",jinaApiKey:t?.jinaApiKey??"",firecrawlApiKey:t?.firecrawlApiKey??"",maxResults:t?.maxResults??8,githubToken:t?.githubToken??""}}function ecq({draft:e,update:t,hubUser:n}){let r=ecB.find(t=>t.value===(e.provider??""));return(0,eb.jsxs)("div",{className:"grid gap-6",children:[(0,eb.jsx)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"启用联网搜索工具"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"为智能体提供 联网搜索 + 网页阅读 能力(vantaloom_search),无需启动浏览器。即使不配置任何 Key,也能用下方的搜索引擎兜底 + Jina 阅读开箱即用。"})]}),(0,eb.jsx)(bG,{checked:e.enable,onCheckedChange:e=>t({enable:e})})]})}),(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"AI 搜索渠道"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"检索层:把关键词转成排序的「标题 / 链接 / 摘要」。配置后质量更好;不配置则只走下方搜索引擎兜底。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"搜索渠道"}),(0,eb.jsx)(x7,{value:e.provider?e.provider:"none",onValueChange:e=>t({provider:"none"===e?"":e}),options:ecB.map(e=>({value:e.value||"none",label:e.label})),title:"选择搜索渠道",className:"w-full"}),r?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:r.help}):null]}),e.provider&&"hub"!==e.provider?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"API Key"}),(0,eb.jsx)(eA,{value:e.apiKey??"",onChange:e=>t({apiKey:e.currentTarget.value}),placeholder:"搜索渠道 API Key",className:"font-mono text-xs",spellCheck:!1,autoComplete:"off"})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"自定义接口地址(可选)"}),(0,eb.jsx)(eA,{value:e.endpoint??"",onChange:e=>t({endpoint:e.currentTarget.value}),placeholder:"留空使用渠道默认地址",className:"font-mono text-xs",spellCheck:!1,autoComplete:"off"})]})]}):null,"hub"===e.provider?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(ete,{}),n?(0,eb.jsxs)("p",{className:"text-xs text-muted-foreground",children:["已登录 Hub(",n.email||n.name,"),将使用官方搜索额度按次计费。无需填写 Key 或接口地址。"]}):(0,eb.jsx)("p",{className:"text-xs text-destructive",children:"尚未登录 Hub。官方搜索需要先在「Hub 账户」设置中登录。"})]}):null]})]})}function ecW({draft:e,update:t}){return(0,eb.jsx)("div",{className:"grid gap-6",children:(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"搜索引擎兜底(无需 Key)"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"未配置 AI 渠道或渠道失败时,自动解析搜索引擎结果页,过滤出条目与网址。请求带浏览器指纹(uTLS + 请求头),降低被拦截概率。"}),(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,eb.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"启用搜索引擎兜底"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"关闭后,未配置 AI 渠道时将无法搜索。建议保持开启。"})]}),(0,eb.jsx)(bG,{checked:e.enableEngineFallback,onCheckedChange:e=>t({enableEngineFallback:e})})]}),e.enableEngineFallback?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"兜底搜索引擎"}),(0,eb.jsx)(x7,{value:e.engine??"bing",onValueChange:e=>t({engine:e}),options:ecV,title:"选择兜底搜索引擎",className:"w-full"})]})]}):null]})})}function ecK({draft:e,update:t}){let n=ecH.find(t=>t.value===(e.defaultReader??"auto"));return(0,eb.jsx)("div",{className:"grid gap-6",children:(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"网页阅读"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"阅读层:把网页抽取成干净的正文 Markdown,不启动浏览器。智能体每次调用可自选引擎,下面是它未指定时的默认。"}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"默认阅读引擎"}),(0,eb.jsx)(x7,{value:e.defaultReader??"auto",onValueChange:e=>t({defaultReader:e}),options:ecH.map(e=>({value:e.value,label:e.label})),title:"选择默认阅读引擎",className:"w-full"}),n?(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:n.help}):null]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"Jina Reader API Key(可选)"}),(0,eb.jsx)(eA,{value:e.jinaApiKey??"",onChange:e=>t({jinaApiKey:e.currentTarget.value}),placeholder:"留空也可用(免费有速率限制)",className:"font-mono text-xs",spellCheck:!1,autoComplete:"off"})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"Firecrawl API Key"}),(0,eb.jsx)(eA,{value:e.firecrawlApiKey??"",onChange:e=>t({firecrawlApiKey:e.currentTarget.value}),placeholder:"使用 Firecrawl 阅读时必填",className:"font-mono text-xs",spellCheck:!1,autoComplete:"off"})]})]})})}function ecG({draft:e,update:t}){return(0,eb.jsx)("div",{className:"grid gap-6",children:(0,eb.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold",children:"可信信源(公共 API · 无需 Key)"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"智能体可在搜索时指定来源,直接调用各站点的官方公共 API,结果比通用网页搜索干净得多——已内置启用,无需配置:"}),(0,eb.jsxs)("ul",{className:"ml-4 list-disc space-y-1 text-xs text-muted-foreground",children:[(0,eb.jsxs)("li",{children:[(0,eb.jsx)("span",{className:"font-medium text-foreground",children:"GitHub / Gitee"})," — 按 star 排序搜索开源仓库"]}),(0,eb.jsxs)("li",{children:[(0,eb.jsx)("span",{className:"font-medium text-foreground",children:"维基百科"})," — 词条检索(支持多语言)"]}),(0,eb.jsxs)("li",{children:[(0,eb.jsx)("span",{className:"font-medium text-foreground",children:"Fandom"})," — 游戏 / 动漫 / 影视等粉丝维基"]})]}),(0,eb.jsx)(ete,{}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"GitHub Token(可选)"}),(0,eb.jsx)(eA,{value:e.githubToken??"",onChange:e=>t({githubToken:e.currentTarget.value}),placeholder:"留空也可用(匿名限速 10 次/分钟),填入可提高限额",className:"font-mono text-xs",spellCheck:!1,autoComplete:"off"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"仅用于 GitHub 来源的搜索限速提升。在 github.com/settings/tokens 生成(无需任何权限范围即可)。"})]})]})})}function ecX({draft:e,update:t}){return(0,eb.jsx)("div",{className:"grid gap-6",children:(0,eb.jsx)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsxs)("div",{className:"flex items-center justify-between",children:[(0,eb.jsx)(Yd,{className:"text-sm",children:"默认返回结果数"}),(0,eb.jsxs)("span",{className:"text-sm tabular-nums text-muted-foreground",children:[e.maxResults||8," 条"]})]}),(0,eb.jsx)(enx,{value:[e.maxResults||8],onValueChange:([e])=>t({maxResults:e}),min:1,max:20,step:1}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"每次搜索返回给智能体的结果条数上限(智能体也可在调用时显式指定)。默认 8。"})]})})})}function ecY(){let e,{user:t}=ti(),[n,r]=ew.useState(null),[a,i]=ew.useState(!0),[o,l]=ew.useState(!1),[s,c]=ew.useState(""),[d,u]=ew.useState(!1),[f,m]=ew.useState(null),h=ew.useRef(null);async function p(){if(n&&!o){l(!0),c("");try{let e=await ks({search:n});h.current=e,r(ecU(e)),u(!1),m(Date.now())}catch(e){c(e instanceof Error?e.message:"Save failed")}finally{l(!1)}}}if(ew.useEffect(()=>{!async function(){try{let e=await kl();h.current=e,r(ecU(e))}catch(e){c(e instanceof Error?e.message:"Failed to load config")}finally{i(!1)}}()},[]),a)e=(0,eb.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取搜索设置"});else if(n){let a={draft:n,update:function(e){r(t=>t?{...t,...e}:t),u(!0),m(null)},hubUser:t};e=(0,eb.jsx)(etm,{sections:[{id:"provider",title:"搜索渠道",icon:(0,eb.jsx)(vu,{}),content:(0,eb.jsx)(ecq,{...a})},{id:"engine",title:"搜索引擎兜底",icon:(0,eb.jsx)(qz,{}),content:(0,eb.jsx)(ecW,{...a})},{id:"reader",title:"网页阅读",icon:(0,eb.jsx)(to,{}),content:(0,eb.jsx)(ecK,{...a})},{id:"sources",title:"可信信源",icon:(0,eb.jsx)(kB,{}),content:(0,eb.jsx)(ecG,{...a})},{id:"limits",title:"结果数量",icon:(0,eb.jsx)(ecF,{}),content:(0,eb.jsx)(ecX,{...a})}],defaultSectionId:"provider",labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto"})}else e=(0,eb.jsxs)(etY,{variant:"destructive",children:[(0,eb.jsx)(eE,{}),(0,eb.jsx)(etZ,{children:"读取失败"}),(0,eb.jsx)(etJ,{children:s||"无法加载搜索设置"})]});return(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex flex-col gap-0.5 border-b px-4 py-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(vu,{}),"搜索设置"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:"搜索设置"})]}),e,(0,eb.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-10 flex justify-center px-6 pb-4",children:(0,eb.jsxs)("div",{className:(0,ez.cn)("pointer-events-auto flex items-center gap-3 rounded-full border border-border bg-card/95 px-4 py-2 shadow-lg backdrop-blur transition-opacity",d||s||f?"opacity-100":"pointer-events-none opacity-0"),children:[s?(0,eb.jsx)("span",{className:"text-xs text-hot-pink",children:s}):d?(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:"有未保存的更改"}):f?(0,eb.jsxs)("span",{className:"flex items-center gap-1 text-xs text-emerald-600 dark:text-emerald-400 [&_svg]:size-3.5",children:[(0,eb.jsx)(h6,{}),"已保存"]}):null,d?(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"sm",disabled:o,onClick:function(){h.current&&(r(ecU(h.current)),u(!1),c(""))},children:"撤销"}):null,(0,eb.jsxs)(eO.Button,{type:"button",size:"sm",disabled:!d||o,onClick:()=>void p(),children:[o?(0,eb.jsx)(eM,{className:"size-4 animate-spin"}):(0,eb.jsx)(h6,{className:"size-4"}),"保存"]})]})})]})}let ecZ=(0,ek.default)("blocks",[["path",{d:"M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2",key:"1ah6g2"}],["rect",{x:"14",y:"2",width:"8",height:"8",rx:"1",key:"88lufb"}]]),ecJ="local",ecQ=[{id:"cloakbrowser",label:"CloakBrowser 默认",description:"源码级反爬的真 Chromium,最适合 agent 在真实站点稳定工作。"},{id:"chrome-for-testing",label:"Chrome for Testing",description:"Google 官方纯净自动化 Chromium,更轻量、自动化友好。"}];function ec0(){let{machines:e}=vd(),t=ew.useMemo(()=>{let t=[],n=!1;for(let r of e)if(r.isLocal)n=!0,t.unshift({id:ecJ,name:"本机",online:!0,reachable:!0,isLocal:!0});else{let e="online"===r.status;t.push({id:r.id,name:r.name,online:e,reachable:r.reachable??e,isLocal:!1})}return n||t.unshift({id:ecJ,name:"本机",online:!0,reachable:!0,isLocal:!0}),t},[e]),[n,r]=ew.useState(ecJ);return ew.useEffect(()=>{t.some(e=>e.id===n)||r(t[0]?.id??ecJ)},[t,n]),(0,eb.jsxs)("div",{className:"vtl-app-background relative flex h-full min-h-0 flex-col text-foreground",children:[(0,eb.jsxs)("header",{className:"flex flex-col gap-0.5 border-b px-4 py-3",children:[(0,eb.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground [&_svg]:size-3.5",children:[(0,eb.jsx)(ecZ,{}),"官方扩展"]}),(0,eb.jsx)("h1",{className:"truncate text-sm font-semibold text-foreground",children:"官方扩展"})]}),0===t.length?(0,eb.jsx)("div",{className:"grid min-h-0 flex-1 place-items-center p-6 text-sm text-muted-foreground",children:"暂无可管理的机器。"}):(0,eb.jsx)(etm,{sections:t.map(e=>({id:e.id,title:e.name,icon:(0,eb.jsx)(eP,{}),badge:(0,eb.jsxs)("span",{className:"flex items-center gap-1",children:[(0,eb.jsx)("span",{className:(0,ez.cn)("size-1.5 rounded-full",e.online?"bg-emerald-500":"bg-muted-foreground/40"),"aria-hidden":!0}),e.online?"在线":"离线"]}),content:(0,eb.jsx)(ec1,{machine:e})})),sectionId:n,onSelectionChange:({sectionId:e})=>{e&&r(e)},defaultSectionId:t[0]?.id,labels:{back:"返回"},className:"min-h-0 flex-1 rounded-none border-0",sidebarClassName:"min-h-0",contentClassName:"min-h-0 overflow-y-auto pb-28"})]})}function ec1({machine:e}){var t;let n=(t=e?.id??ecJ)===ecJ?void 0:t,r=e?.reachable??!0,[a,i]=ew.useState(null),[o,l]=ew.useState(!0),[s,c]=ew.useState(!1),[d,u]=ew.useState(0),[f,m]=ew.useState(!1),h=ew.useCallback(()=>u(e=>e+1),[]);ew.useEffect(()=>{if(!r){l(!1),c(!0),i(null);return}let e=!0,t=new AbortController;async function a(){try{let r=await Yk(n,{signal:t.signal});if(!e)return;i(r.extensions??[]),c(!1)}catch{if(!e)return;c(!0)}finally{e&&l(!1)}}a();let o=f?window.setInterval(a,3e3):void 0;return()=>{e=!1,t.abort(),o&&window.clearInterval(o)}},[n,r,d,f]);let p=a?.find(e=>"browser"===e.id)??(a?ec2:void 0);return o?(0,eb.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border bg-card p-6 text-sm text-muted-foreground",children:[(0,eb.jsx)(HR,{className:"size-4"}),"正在获取扩展状态…"]}):s||!a?(0,eb.jsxs)("div",{className:"grid gap-3 rounded-lg border border-destructive/30 bg-destructive/5 p-6",children:[(0,eb.jsx)("p",{className:"text-sm text-destructive",children:"无法获取扩展状态"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:r?"请确认该机器的运行时已启动,稍后重试。":"该机器当前不可达(离线或无连接路径)。"}),r&&(0,eb.jsx)("div",{children:(0,eb.jsxs)(eO.Button,{variant:"outline",size:"sm",onClick:h,children:[(0,eb.jsx)(yt,{className:"size-3.5"}),"重试"]})})]}):p?(0,eb.jsx)(ec5,{machineId:n,extension:p,onChanged:h,setPolling:m}):(0,eb.jsx)("div",{className:"rounded-lg border bg-card p-6 text-sm text-muted-foreground",children:"该机器暂无可用的官方扩展。"})}let ec2={id:"browser",name:"Vantaloom 浏览器",installed:!1,enabled:!1,running:!1,variant:"cloakbrowser",version:"",available:["cloakbrowser","chrome-for-testing"]};function ec5({machineId:e,extension:t,onChanged:n,setPolling:r}){var a;let[i,o]=ew.useState(null),[l,s]=ew.useState(null),[c,d]=ew.useState(t.variant??"cloakbrowser");ew.useEffect(()=>{t.installed&&t.variant&&d(t.variant)},[t.installed,t.variant]);let u="install"===i;async function f(e,t,a=!1){o(e),s(null),a&&r(!0);try{await t(),n()}catch{s("操作失败,请稍后重试。")}finally{o(null),a&&r(!1)}}async function m(t){o("enable"),s(null),r(!0);try{await YE(e,t),n();let r=Date.now()+3e4;for(;Date.now()<r;){await new Promise(e=>setTimeout(e,1500));try{let n=(await Yk(e,{timeoutMs:6e3})).extensions.find(e=>"browser"===e.id);if(n&&n.running===t)break}catch{}}n()}catch{s(t?"启动失败,请稍后重试。":"停止失败,请稍后重试。")}finally{o(null),r(!1)}}let h="enable"===i,p=h&&!t.running||t.enabled&&!t.running,g=h&&t.running,x=t.installed?t.running?(0,eb.jsx)(Vp,{variant:"default",children:"运行中"}):p?(0,eb.jsx)(Vp,{variant:"secondary",className:"bg-amber-500/15 text-amber-600 dark:text-amber-400",children:"启动中"}):(0,eb.jsx)(Vp,{variant:"secondary",className:"bg-muted text-muted-foreground",children:"已停止"}):(0,eb.jsx)(Vp,{variant:"outline",children:"未安装"}),v=ecQ.filter(e=>!t.available?.length||t.available.includes(e.id));return(0,eb.jsxs)("section",{className:"grid gap-4 rounded-lg border bg-card p-4",children:[(0,eb.jsxs)("div",{className:"flex items-start gap-3",children:[(0,eb.jsx)("span",{className:"grid size-10 shrink-0 place-items-center rounded-md bg-primary/10 text-primary [&_svg]:size-5",children:(0,eb.jsx)(qz,{})}),(0,eb.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eb.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,eb.jsx)("h4",{className:"text-sm font-semibold text-foreground",children:"Vantaloom 浏览器"}),x,t.installed&&t.version&&(0,eb.jsxs)("span",{className:"text-xs text-muted-foreground",children:["v",t.version]})]}),(0,eb.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:"让 Agent 可操作真实浏览器:网站预览直连真实浏览器,可在指定机器上运行并远程观看 Agent 的操作过程。"})]})]}),(0,eb.jsxs)("div",{className:"grid gap-2",children:[(0,eb.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"浏览器内核"}),(0,eb.jsx)("div",{className:"grid gap-2 sm:grid-cols-2",children:v.map(e=>{let n=c===e.id,r=t.installed;return(0,eb.jsxs)("button",{type:"button",disabled:r||null!==i,onClick:()=>d(e.id),className:(0,ez.cn)("flex flex-col gap-1 rounded-lg border p-3 text-left transition-colors",n?"border-primary bg-primary/5 text-foreground":"border-border bg-background text-muted-foreground hover:bg-muted/60 hover:text-foreground",(r||null!==i)&&"opacity-60"),"aria-pressed":n,children:[(0,eb.jsx)("span",{className:"text-sm font-medium text-foreground",children:e.label}),(0,eb.jsx)("span",{className:"text-xs text-muted-foreground",children:e.description})]},e.id)})}),t.installed&&(0,eb.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["已安装的内核为 ",(a=t.variant,ecQ.find(e=>e.id===a)?.label??a),",如需更换请先卸载。"]})]}),(0,eb.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:t.installed?(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsxs)(eO.Button,{size:"sm",disabled:null!==i,onClick:()=>m(!t.running),children:[h?(0,eb.jsx)(HR,{className:"size-3.5"}):t.running?(0,eb.jsx)(kH,{className:"size-3.5"}):(0,eb.jsx)(HE,{className:"size-3.5"}),g?"停止中…":p?"启动中…":t.running?"停止浏览器":"启动浏览器"]}),(0,eb.jsxs)(eO.Button,{size:"sm",variant:"outline",disabled:null!==i,onClick:()=>f("update",()=>YC(e),!0),children:["update"===i?(0,eb.jsx)(HR,{className:"size-3.5"}):(0,eb.jsx)(yt,{className:"size-3.5"}),"update"===i?"正在更新…":"更新"]}),(0,eb.jsxs)(eO.Button,{size:"sm",variant:"destructive",disabled:null!==i,onClick:()=>f("uninstall",()=>YM(e)),children:["uninstall"===i?(0,eb.jsx)(HR,{className:"size-3.5"}):(0,eb.jsx)(yn,{className:"size-3.5"}),"卸载"]})]}):(0,eb.jsxs)(eO.Button,{size:"sm",disabled:null!==i,onClick:()=>f("install",()=>YS(e,c),!0),children:[u?(0,eb.jsx)(HR,{className:"size-3.5"}):null,u?"正在安装…":"安装"]})}),t.installed&&(0,eb.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-lg border bg-background p-3",children:[(0,eb.jsxs)("div",{className:"min-w-0",children:[(0,eb.jsx)("p",{className:"text-sm font-medium text-foreground",children:"在此机器上运行"}),(0,eb.jsx)("p",{className:"text-xs text-muted-foreground",children:"开启后该机器的 Agent 可使用浏览器工具;关闭则停止浏览器与边车进程。"})]}),(0,eb.jsx)(bG,{checked:t.enabled,disabled:null!==i,onCheckedChange:e=>void m(e),"aria-label":"在此机器上运行浏览器扩展"})]}),l&&(0,eb.jsx)("p",{className:"text-xs text-destructive",children:l})]})}let ec4=["light","dark","jelly"],ec3={light:{label:"Light",icon:ell,className:"text-sidebar-foreground/60"},dark:{label:"Dark",icon:eli,className:"text-sidebar-foreground/60"},jelly:{label:"Jelly",icon:function(e){return(0,eb.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[(0,eb.jsx)("path",{d:"M6.5 11.5C6.5 8 8.7 5.5 12 5.5s5.5 2.5 5.5 6v.6c0 .8-.6 1.4-1.4 1.4H7.9c-.8 0-1.4-.6-1.4-1.4v-.6Z"}),(0,eb.jsx)("path",{d:"M7.8 13.5c.4 1 1.1 1.5 2 1.5s1.6-.5 2-1.5c.4 1 1.1 1.5 2 1.5s1.6-.5 2-1.5"}),(0,eb.jsx)("path",{d:"M9 15.5c0 1.4-1.2 1.4-1.2 2.8 0 .7.3 1.2.8 1.7"}),(0,eb.jsx)("path",{d:"M12 15.5c0 1.6-1.4 1.6-1.4 3.2 0 .7.3 1.2.8 1.8"}),(0,eb.jsx)("path",{d:"M15 15.5c0 1.4 1.2 1.4 1.2 2.8 0 .7-.3 1.2-.8 1.7"})]})},className:"text-primary"}};function ec6(){let{resolvedTheme:e,setTheme:t}=(0,m1.useTheme)(),[n,r]=ew.useState(elb.defaultAppearanceTheme);ew.useEffect(()=>{let e=window.localStorage.getItem(elb.appearanceThemeStorageKey)??elb.defaultAppearanceTheme;r(e),(0,elb.applyAppearanceTheme)({theme:e})},[]);let a=n===elb.jellyAppearanceTheme?"jelly":"dark"===e?"dark":"light",i=ec4.indexOf(a),o=ec4[(i+1)%ec4.length]??"light",{icon:l,label:s,className:c}=ec3[a];function d(e){r(e),window.localStorage.setItem(elb.appearanceThemeStorageKey,e),(0,elb.applyAppearanceTheme)({theme:e})}return(0,eb.jsx)(eO.Button,{type:"button",variant:"ghost",size:"icon-sm",className:(0,ez.cn)("size-10 hover:bg-muted hover:text-sidebar-foreground",c),"aria-label":`${en2.theme}: ${s}`,title:`${en2.theme}: ${s}`,onClick:function(){if("jelly"===o){t("dark"),d(elb.jellyAppearanceTheme);return}d(elb.defaultAppearanceTheme),t(o)},children:(0,eb.jsx)(l,{})})}let ec8=(0,ek.default)("chart-area",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z",key:"q0gr47"}]]);(0,ek.default)("layout-dashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]),(0,ek.default)("route",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]]);let ec7=[{id:"run-ui-polish",title:"组件库视觉回归检查",machine:"Studio-PC",agent:"UI Polish",state:"running",started:"14:08",runtime:"22m",progress:68,load:54},{id:"run-runner-build",title:"Linux runner 镜像构建",machine:"Linux-runner-02",agent:"Build Agent",state:"running",started:"14:15",runtime:"15m",progress:41,load:86},{id:"run-access-audit",title:"工作组权限审阅",machine:"Studio-PC",agent:"Access Agent",state:"blocked",started:"14:21",runtime:"9m",progress:37,load:18},{id:"run-docs",title:"发布说明摘要",machine:"MacBook-build",agent:"Docs Agent",state:"queued",started:"等待",runtime:"0m",progress:0,load:0},{id:"run-cache-clean",title:"缓存清理策略验证",machine:"Linux-runner-02",agent:"Ops Sentinel",state:"failed",started:"13:54",runtime:"6m",progress:28,load:12}],ec9=[{id:"worker-studio",machine:"Studio-PC",role:"local coordinator",active:3,capacity:6,cpu:42,memory:68},{id:"worker-runner",machine:"Linux-runner-02",role:"gpu worker",active:4,capacity:5,cpu:76,memory:81},{id:"worker-mac",machine:"MacBook-build",role:"build host",active:0,capacity:3,cpu:8,memory:24}],ede=[{id:"confirm-shell",title:"Studio-PC 请求执行发布前文件写入",meta:"UI Polish · apply_patch",tone:"normal"},{id:"confirm-service",title:"Linux-runner-02 请求重启 runner 服务",meta:"Ops Sentinel · Restart-Service",tone:"warning"},{id:"confirm-token",title:"工作组 token 加入新机器",meta:"Access Agent · admin required",tone:"normal"}],edt=[["14:29","Studio-PC","pnpm --filter vantaloom-app lint","完成"],["14:27","Linux-runner-02","docker build agent-runtime","运行中"],["14:22","Studio-PC","apply_patch agent settings","完成"],["14:17","MacBook-build","pnpm typecheck","排队"],["14:03","Linux-runner-02","cache prune dry-run","失败"]],edn={cpu:{label:"CPU",color:"var(--chart-1)"},memory:{label:"Memory",color:"var(--chart-3)"},network:{label:"Network",color:"var(--chart-5)"}};function edr(e,t,n=42,r){return(0,eb.jsx)("section",{className:(0,ez.cn)("size-full rounded-xl border bg-card p-5",r&&"vtl-jelly-image-card",r&&r.includes("/bg")&&"vtl-jelly-image-card-shadowless"),style:r?en0({image:r,opacity:.74,blur:"8px"}):void 0,children:(0,eb.jsx)(erb,{label:e,value:t,minSize:n})})}function eda(e,t,n=""){return{title:e,dataSource:t,refreshRate:"10s",note:n}}let edi={metrics:{online:2,health:88.4,latency:"38ms",events:17},machines:[{id:"studio",name:"Studio-PC",os:"Windows",status:"online",link:"direct",heartbeat:"3s",cpu:42,memory:68,disk:71,network:24},{id:"runner",name:"Linux-runner-02",os:"Linux",status:"online",link:"p2p",heartbeat:"5s",cpu:76,memory:81,disk:62,network:43},{id:"mac",name:"MacBook-build",os:"macOS",status:"sleeping",link:"direct",heartbeat:"2m",cpu:8,memory:24,disk:48,network:6}],trend:[{time:"09:00",cpu:36,memory:54,network:24},{time:"10:00",cpu:48,memory:61,network:29},{time:"11:00",cpu:44,memory:58,network:34},{time:"12:00",cpu:63,memory:72,network:41},{time:"13:00",cpu:58,memory:69,network:37},{time:"14:00",cpu:71,memory:76,network:46}],networkLinks:[["Studio-PC","Linux-runner-02","P2P","38ms","0.3%"],["Studio-PC","MacBook-build","Direct","12ms","0.0%"],["Linux-runner-02","MacBook-build","Relay fallback","84ms","1.1%"]],events:[["14:31","Linux-runner-02 心跳延迟升高"],["14:28","Studio-PC 完成 2 个工具调用"],["14:19","MacBook-build 进入睡眠状态"],["14:12","工作组权限策略同步完成"],["14:04","P2P 链路切换到备用路径"]],serviceHealth:[{id:"local-service",name:"Local service",state:"正常",samples:[96,98,97,95,96,94,97,98,96,95,97,96]},{id:"agent-runtime",name:"Agent runtime",state:"正常",samples:[91,93,94,90,88,92,94,93,91,89,92,94]},{id:"p2p-mesh",name:"P2P mesh",state:"波动",samples:[78,82,76,73,68,71,74,79,83,80,77,72]},{id:"plugin-bridge",name:"Plugin bridge",state:"告警",samples:[88,86,84,82,79,74,63,54,48,52,67,76]}]},edo=[{id:"metric-runs",title:"运行中",description:"当前正在执行的运行数量。",icon:(0,eb.jsx)(u1,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eda("运行中","运行队列"),render:e=>edr(e.title,"07",44,enY)},{id:"metric-queued",title:"排队",description:"等待调度的任务数量。",icon:(0,eb.jsx)(uV,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eda("排队","调度器"),render:e=>edr(e.title,"04",44,enZ)},{id:"metric-blocked",title:"待确认",description:"等待人工确认的任务数量。",icon:(0,eb.jsx)(eiE,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eda("待确认","确认队列"),render:e=>edr(e.title,"03",44,enJ)},{id:"metric-workers",title:"Worker",description:"当前可调度 worker 数量。",icon:(0,eb.jsx)(Yw,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eda("Worker","Agent worker"),render:e=>edr(e.title,"14",44,enQ)},{id:"queue",title:"任务队列",description:"运行队列 Roadmap。",icon:(0,eb.jsx)(uZ,{className:"size-4"}),defaultSize:{w:7,h:5},defaultConfig:eda("任务队列","运行队列"),render:e=>(0,eb.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,eb.jsx)(en1,{title:e.title}),(0,eb.jsx)(eaY,{items:ec7})]})},{id:"workers",title:"Agent worker",description:"各 worker 的负载和容量。",icon:(0,eb.jsx)(Yw,{className:"size-4"}),defaultSize:{w:5,h:5},defaultConfig:eda("Agent worker","Worker 状态"),render:e=>(0,eb.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,eb.jsx)(en1,{title:e.title}),(0,eb.jsx)(eaJ,{workers:ec9})]})},{id:"log",title:"最近执行",description:"最近执行记录 Roadmap。",icon:(0,eb.jsx)(erk,{className:"size-4"}),defaultSize:{w:7,h:4},defaultConfig:eda("最近执行","执行日志"),render:e=>(0,eb.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,eb.jsx)(en1,{title:e.title}),(0,eb.jsx)(eaX,{items:edt})]})},{id:"confirmations",title:"待确认",description:"等待人工确认的事项。",icon:(0,eb.jsx)(eap,{className:"size-4"}),defaultSize:{w:5,h:4},defaultConfig:eda("待确认","确认队列"),render:e=>(0,eb.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,eb.jsx)(en1,{title:e.title}),(0,eb.jsx)(eaG,{items:ede})]})}],edl=[{id:"metric-runs",kind:"metric-runs",x:0,y:0,w:3,h:2},{id:"metric-queued",kind:"metric-queued",x:3,y:0,w:3,h:2},{id:"metric-blocked",kind:"metric-blocked",x:6,y:0,w:3,h:2},{id:"metric-workers",kind:"metric-workers",x:9,y:0,w:3,h:2},{id:"queue",kind:"queue",x:0,y:2,w:7,h:5},{id:"workers",kind:"workers",x:7,y:2,w:5,h:5},{id:"log",kind:"log",x:0,y:7,w:7,h:4},{id:"confirmations",kind:"confirmations",x:7,y:7,w:5,h:4}];function eds(e=edi){return[{id:"metric-online",title:"在线机器",description:"当前在线机器数量。",icon:(0,eb.jsx)(eP,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eda("在线机器","机器心跳"),render:t=>edr(t.title,String(e.metrics.online),44,enY)},{id:"metric-health",title:"健康度",description:"工作组整体健康度。",icon:(0,eb.jsx)(eI,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eda("健康度","服务遥测"),render:t=>edr(t.title,`${e.metrics.health}%`,44,enZ)},{id:"metric-latency",title:"平均延迟",description:"机器连接平均延迟。",icon:(0,eb.jsx)(erE,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eda("平均延迟","网络遥测"),render:t=>edr(t.title,e.metrics.latency,44,enJ)},{id:"metric-events",title:"事件",description:"最近事件数量。",icon:(0,eb.jsx)(eap,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eda("事件","事件流"),render:t=>edr(t.title,String(e.metrics.events),44,enQ)},{id:"machines",title:"机器健康矩阵",description:"各机器资源和心跳状态。",icon:(0,eb.jsx)(eP,{className:"size-4"}),defaultSize:{w:7,h:5},defaultConfig:eda("机器健康矩阵","机器遥测"),render:t=>(0,eb.jsxs)("section",{className:"vtl-jelly-image-card flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",style:en0({image:"/themes/jelly/card1.png",opacity:.88,blur:"10px"}),children:[(0,eb.jsx)(en1,{title:t.title}),(0,eb.jsx)(ea2,{machines:e.machines})]})},{id:"trend",title:"资源趋势",description:"CPU、内存和网络趋势。",icon:(0,eb.jsx)(ec8,{className:"size-4"}),defaultSize:{w:5,h:5},defaultConfig:eda("资源趋势","机器遥测"),render:t=>(0,eb.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,eb.jsx)(en1,{title:t.title}),(0,eb.jsx)(ea8,{config:edn,data:e.trend})]})},{id:"network",title:"网络连接",description:"机器之间连接状态。",icon:(0,eb.jsx)(enH,{className:"size-4"}),defaultSize:{w:6,h:4},defaultConfig:eda("网络连接","网络遥测"),render:t=>(0,eb.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,eb.jsx)(en1,{title:t.title}),(0,eb.jsx)(ea6,{links:e.networkLinks})]})},{id:"events",title:"事件流",description:"最近遥测事件。",icon:(0,eb.jsx)(eap,{className:"size-4"}),defaultSize:{w:6,h:4},defaultConfig:eda("事件流","事件流"),render:t=>(0,eb.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,eb.jsx)(en1,{title:t.title}),(0,eb.jsx)(ea1,{events:e.events})]})},{id:"services",title:"服务健康",description:"服务 30 分钟粒度健康条。",icon:(0,eb.jsx)(Yw,{className:"size-4"}),defaultSize:{w:12,h:3},defaultConfig:eda("服务健康","服务遥测"),render:t=>(0,eb.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,eb.jsx)(en1,{title:t.title}),(0,eb.jsx)(ea7,{services:e.serviceHealth})]})}]}eds();let edc=[{id:"metric-online",kind:"metric-online",x:0,y:0,w:3,h:2},{id:"metric-health",kind:"metric-health",x:3,y:0,w:3,h:2},{id:"metric-latency",kind:"metric-latency",x:6,y:0,w:3,h:2},{id:"metric-events",kind:"metric-events",x:9,y:0,w:3,h:2},{id:"machines",kind:"machines",x:0,y:2,w:7,h:5},{id:"trend",kind:"trend",x:7,y:2,w:5,h:5},{id:"network",kind:"network",x:0,y:7,w:6,h:4},{id:"events",kind:"events",x:6,y:7,w:6,h:4},{id:"services",kind:"services",x:0,y:11,w:12,h:3}],edd={totals:{machines:4,online:2,runtime:3,tokens:7},machines:[{id:"studio",name:"Studio-PC",role:"本机",group:"Core",os:"Windows 11",runtime:"0.16.4",state:"online",tags:["admin","shell","files","scheduler"],agent:"6/8",cpu:42,memory:68,version:"Agent runtime 0.16.4",admin:"Allay"},{id:"runner",name:"Linux-runner-02",role:"GPU worker",group:"Compute",os:"Ubuntu 24.04",runtime:"0.16.3",state:"online",tags:["gpu","agent","files"],agent:"4/6",cpu:76,memory:81,version:"Agent runtime 0.16.3",admin:"Ops"},{id:"mac",name:"MacBook-build",role:"构建机",group:"Build",os:"macOS 15.4",runtime:"0.15.9",state:"sleeping",tags:["build","readonly"],agent:"0/3",cpu:8,memory:24,version:"Agent runtime 0.15.9",admin:"Allay"},{id:"observer",name:"Observer-01",role:"只读观测节点",group:"Edge",os:"Debian 13",runtime:"0.16.2",state:"warning",tags:["readonly","audit"],agent:"1/2",cpu:18,memory:36,version:"Agent runtime 0.16.2",admin:"Security"}],topology:{nodes:[{id:"studio",label:"Studio-PC",meta:"本机",x:50,y:18},{id:"runner",label:"Linux-runner-02",meta:"GPU worker",x:22,y:60},{id:"mac",label:"MacBook-build",meta:"构建机",x:76,y:58,state:"warning"},{id:"observer",label:"Observer-01",meta:"只读观测",x:50,y:82,state:"warning"}],links:[{id:"sr",from:"studio",to:"runner",kind:"p2p",label:"P2P",meta:"38ms / 0.3%"},{id:"sm",from:"studio",to:"mac",kind:"direct",label:"Direct",meta:"12ms / 0%"},{id:"ro",from:"runner",to:"observer",kind:"relay",label:"Relay",meta:"84ms / 1.1%"},{id:"mo",from:"mac",to:"observer",kind:"down",label:"Down",meta:"lost"}]},pathTotals:{direct:1,p2p:1,relay:1,broken:1},latency:[{time:"09:00",p2p:42,direct:12,relay:96},{time:"10:00",p2p:39,direct:12,relay:88},{time:"11:00",p2p:44,direct:14,relay:91},{time:"12:00",p2p:38,direct:12,relay:84},{time:"13:00",p2p:36,direct:11,relay:86},{time:"14:00",p2p:41,direct:13,relay:93}],candidates:[["Studio-PC","Linux-runner-02","P2P","symmetric NAT","38ms","0.3%"],["Studio-PC","MacBook-build","Direct","open port 4178","12ms","0.0%"],["Linux-runner-02","Observer-01","Relay","udp blocked","84ms","1.1%"],["MacBook-build","Observer-01","Interrupted","sleep","-","-"]]};function edu({clipboardItems:e=[],onClipboardItemsChange:t,onOverlayOpenChange:n}){return(0,eb.jsx)(erp,{boardId:"runtime-operations",definitions:edo,initialLayouts:edl,clipboardItems:e,actionLabel:"运行页面卡片操作",paletteGroupTitle:"运行页面卡片",onClipboardItemsChange:t,onOverlayOpenChange:n})}function edf({clipboardItems:e=[],onClipboardItemsChange:t,onOverlayOpenChange:n}){let r=es6("/api/local/machines/telemetry",es3),a=ew.useMemo(()=>eds(r),[r]);return(0,eb.jsx)(erp,{boardId:"telemetry",definitions:a,initialLayouts:edc,clipboardItems:e,actionLabel:"遥测页面卡片操作",paletteGroupTitle:"遥测页面卡片",onClipboardItemsChange:t,onOverlayOpenChange:n})}function edm({className:e,title:t="Vantaloom"}){return(0,eb.jsxs)("svg",{viewBox:"180 350 1130 260",fill:"currentColor",role:"img","aria-label":t,className:(0,ez.cn)("[[data-vtl-theme=jelly]_&]:opacity-70",e),children:[(0,eb.jsx)("path",{d:"m658 393 2 1v47l57 1v1l-12 2-45 5v89l2 14 4 7 6 3h12l8-2-5-10-1-4v-11l3-8 4-6 7-7 14-8 16-6 33-9h3l-1-16-4-8-6-5-10-3h-15l-13 3-16 7-7 5 1-4 8-8 14-8 12-4 7-1h23l16 4 9 6 4 5 4 9 1 5 1 69 2 11 3 5 7 5v1h-28l-6-4-4-11v-7h-2l-2 4-7 8-11 8-10 4-4 1h-21l-9-4-7-5-14 7-7 2h-18l-11-4-6-5-5-10-1-4-1-33v-61l1-4-26 3-9-7-4-3 4-1 34-2v-34l2-5zm107 104-19 6-17 8-10 9-4 8-1 4v11l3 8 8 7 7 2h8l10-3 10-7 6-7 1-2v-44z"}),(0,eb.jsx)("path",{d:"m1147 452h15l11 3 10 9 5 10v3h2l2-5 10-10 12-7 11-3h18l10 3 6 4 7 8 4 12 1 9 1 62 3 12 4 5 3 3h-38l-1-86-2-9-5-7-7-3h-12l-10 3-9 6-7 8-1 88h-26l-1-88-3-9-5-6-6-2h-11l-9 3-9 7-4 6-1 89h-34l6-14 4-19 1-10v-28l-3-19-6-18-4-9h28l3 8 3 13 7-8 8-7 10-5z"}),(0,eb.jsx)("path",{d:"m556 449h19l13 4 10 9 4 9 2 13 1 67 3 10 4 5 5 4h-40l-1-85-3-12-4-6-7-4-3-1h-14l-11 4-10 7-5 8-1 6-1 83h-25l-1-99-2-17 1-1h24l2 6 2 13 9-10 12-8 11-4z"}),(0,eb.jsx)("path",{d:"m409 450h22l16 4 9 6 6 9 3 11 1 71 2 9 3 5 6 4v1h-27l-6-4-3-7-2-9-11 12-13 8-9 3-7 1h-13l-12-3-10-7-6-10-1-4v-13l5-12 4-5 12-9 18-8 35-10 6-2v-14l-3-8-5-5-7-3-4-1h-15l-13 3-20 10 6-9 10-7 13-5zm27 47-23 8-13 7-8 7-5 9-1 4v11l5 10 5 4 8 3h10l11-4 8-6 5-6 1-4v-43z"}),(0,eb.jsx)("path",{d:"m918 450h22l15 3 16 8 12 11 7 8 7 14 3 11v21l-3 12-4 8-5-5-8-17-11-33-7-13-9-10-10-6-7-2h-12l-11 4-8 7-7 10-4 13-1 7v18l3 14 4 10 6 8 9 8 10 4 6 1h9l9-2 7-4 5 1 5 5v2l-10 5-13 3h-22l-15-4-16-8-10-9-6-7-7-14-3-14v-16l3-13 6-12 8-10 12-9 12-5z"}),(0,eb.jsx)("path",{d:"m224 442h17l15 3 10 5 10 9 9 13 14 29 13 28 6 14v2h2l1-5 16-39 17-40 4-8h9l-2 6-18 42-11 26-17 40-9 21-3-1-29-58-10-19-12-23-8-11-9-10-9-7-10-4-5-1h-19l-15 3 4-4 13-6 16-4z"}),(0,eb.jsx)("path",{d:"m1010 450h19l17 4 13 7 12 11 7 11 5 13 2 11v10l-3 16-4 10-9 12-8 7-12 7-13 4-7 1h-25l-16-4-13-7-11-9-7-9-7-14-2-9v-17l3-12 5-10 3-1 7 18 11 33 8 14 8 9 8 5 12 3h8l12-3 10-7 6-8 5-12 2-11v-19l-3-14-5-12-8-10-10-6-7-2h-13l-11 4-6 4-4-2-6-5 3-3 10-5z"}),(0,eb.jsx)("path",{d:"m848 371h1l1 171 2 9 4 6 6 5 19 5 6 2v1h-65l-1-188z"})]})}function edh(e){return()=>new Promise(t=>{e(),window.setTimeout(t,60)})}function edp(e){return"u"<typeof document?null:document.querySelector(e)}function edg(){return null!=edp('[role="menu"]')}function edx(){return null!=edp('[data-tour="init-wizard"]')}function edv(){let e=edp('[data-tour="init-wizard"] [aria-current="step"]'),t=e?.getAttribute("aria-label")?.match(/第\s*(\d+)/);return t?Number(t[1]):0}!function(e=edd){eda("机器","机器组"),eda("在线","机器心跳"),eda("Runtime","Agent runtime"),eda("Token","机器注册"),eda("机器组","机器组"),eda("拓扑图","网络拓扑"),eda("直连","网络拓扑"),eda("P2P","网络拓扑"),eda("Relay","网络拓扑"),eda("中断","网络拓扑"),eda("延迟","网络遥测"),eda("候选路径","网络候选路径")}(),eda("日志与审计","审计事件"),eda("筛选","审计筛选"),eda("拒绝事件","审计事件"),eda("事件趋势","审计事件");var edb=e.i(64990);function edy(){let e=sv(),[t,n]=ew.useState(!1);ew.useEffect(()=>{try{n("1"===window.localStorage.getItem("vtl:sidebar-collapsed"))}catch{}},[]);let r=ew.useCallback(()=>{n(e=>{let t=!e;try{window.localStorage.setItem("vtl:sidebar-collapsed",t?"1":"0")}catch{}return t})},[]),[a,i]=ew.useState("home"),[o,l]=ew.useState(!1),[s,c]=ew.useState(),[d,u]=ew.useState(),[f,m]=ew.useState([]),[h,p]=ew.useState([]),[g,x]=ew.useState("conversation"),[v,b]=ew.useState(0),y=s?.conversation.id,w=s?.conversation.ownerMachineId;ew.useEffect(()=>{m([]),p([]),x("conversation")},[y]),ew.useEffect(()=>{let e;if(!y||"new-agent-conversation"!==a&&"project-conversation"!==a)return void p([]);let t=!1,n=async()=>{let r=await sL(y,w);t||(p(r),e=window.setTimeout(n,!function e(t){return t.some(t=>t.running||e(t.children??[]))}(r)?6e3:2e3))};return n(),()=>{t=!0,e&&window.clearTimeout(e)}},[y,w,a]);let[j,k]=ew.useState();ew.useEffect(()=>{k(void 0)},[a]);let[N,S]=ew.useState(!1),[C,M]=ew.useState(!1),[E,I]=ew.useState([]),[P,O]=ew.useState([]),[z,A]=ew.useState({}),[T,R]=ew.useState(),[D,_]=ew.useState(u9),[L,$]=ew.useState([]),[F,B]=ew.useState(),[V,H]=ew.useState(),[U,q]=ew.useState(),[W,K]=ew.useState(),G=ew.useRef(!1),X=ew.useCallback(e=>{_(t=>iZ(e,t))},[]),Y=ew.useCallback(e=>{$(t=>iZ(e,t))},[]),Z=ew.useCallback(async(e,t)=>{let n="u">typeof performance?performance.now():Date.now();console.debug(`[open] click conversation=${e} owner=${t??"local"}`),u({id:e,ownerMachineId:t}),i("new-agent-conversation");let r=()=>Math.round(("u">typeof performance?performance.now():Date.now())-n);try{let n=await sW(e,t);console.debug(`[open] detail loaded in ${r()}ms (id=${e})`),c(n),u(t=>t?.id===e?void 0:t)}catch(n){if(n instanceof sN){let r=n.openedBy?.displayName||"另一台设备";if(window.confirm(`此对话正在「${r}」上打开,无法同时操作。是否强制接管(对方将被踢出)?`)){try{let n=await sW(e,t,{force:!0});c(n)}finally{u(t=>t?.id===e?void 0:t)}return}u(t=>t?.id===e?void 0:t),s||i("home");return}console.warn(`[open] failed after ${r()}ms (id=${e})`,n),u(t=>t?.id===e?void 0:t),s||i("home")}},[s]),J=ew.useCallback(async(e,t)=>{m([]),await Z(e,t)},[Z]),Q=ew.useCallback(()=>{c(void 0),i("new-agent-conversation")},[]),ee=ew.useCallback(async()=>{let e=await sR();e?await Z(e.conversation.id,e.conversation.ownerMachineId):Q()},[Z,Q]),et=ew.useCallback(async()=>{G.current=!0,_(u9),$([]),i("new-canvas");try{let e=await enD({title:"新画布",nodes:u9,edges:[]});H(e.canvas.id),q("local")}catch{H(void 0),q(void 0),G.current=!1}},[]),en=ew.useCallback(async(e,t)=>{try{await enL(e,t);let n=await enR(e,t);G.current=!0,_(n.nodes),$(n.edges),H(n.canvas.id),q(n.canvas.ownerMachineId),i("new-canvas")}catch{}},[]),er=ew.useCallback(e=>{K(e),i("project-overview")},[]),ea=ew.useCallback(e=>{K(e),i("kanban")},[]),ei=ew.useCallback(e=>{K(e),i("project-settings")},[]),eo=ew.useCallback(async(e,t)=>{K(e);let n=t;if(!n)try{n=(await eib(e)).canvasId}catch{}if(!n)try{n=(await enD({title:"工程画布",nodes:u9,edges:[]})).canvas.id,await eiw(e,{canvasId:n}).catch(()=>{})}catch{return}await en(n)},[en]),el=ew.useCallback(async(e,t,n)=>{K(e),m([]),u({id:t,ownerMachineId:n}),i("project-conversation");try{let e=await sW(t,n);c(e)}catch{}finally{u(e=>e?.id===t?void 0:e)}},[]),es=ew.useCallback(()=>{i("new-project")},[]),ec=ew.useCallback(async e=>{try{let t=await eiC(e);await el(e,t.id,t.ownerMachineId)}catch{}},[el]);ew.useEffect(()=>{if(!V)return;if(G.current){G.current=!1;return}let e=window.setTimeout(()=>{en_(V,{nodes:D,edges:L,nodeIds:D.map(e=>e.id)},U).catch(()=>{})},800);return()=>window.clearTimeout(e)},[D,L,V,U]);let ed=ew.useCallback(({item:t})=>{if(!e||"new-canvas"!==t.id&&"all-canvases"!==t.id&&"open-recent-canvas"!==t.id){if("new-canvas"===t.id)return void et();if("all-canvases"===t.id)return void i("all-canvases");if("new-agent-conversation"===t.id)return void Q();if("import-claude-session"===t.id)return void S(!0);if("open-recent-conversation"===t.id)return void ee();if("runs"===t.id)return void i("runs");if("telemetry"===t.id)return void i("telemetry");("preferences"===t.id||"preferences-models"===t.id||"preferences-agents"===t.id||"system-general"===t.id||"network-downloads"===t.id||"preferences-model-routes"===t.id||"preferences-model-groups"===t.id||"preferences-agent-config"===t.id||"preferences-subagent-config"===t.id||"preferences-cc-engine-config"===t.id||"preferences-assets"===t.id||"preferences-layout"===t.id||"preferences-official-extensions"===t.id||"network-topology"===t.id||"network-settings"===t.id||"search-settings"===t.id||"system-downloads"===t.id||"check-update"===t.id||"account"===t.id||"balance-usage"===t.id||"feedback"===t.id)&&i(t.id)}},[et,e,ee,Q]),{start:eu}=(0,edb.useTour)(),ef=ew.useCallback(()=>{var e;eu((e={select:e=>ed({item:{id:e}}),startNewConversation:Q,goHome:()=>{i("home"),c(void 0)}},{id:"product-tour",steps:[{id:"intro",centered:!0,title:"欢迎使用 Vantaloom 👋",body:(0,eb.jsxs)(eb.Fragment,{children:["这是一份手把手向导,会高亮关键位置并在需要时",(0,eb.jsx)("b",{children:"请你亲自操作"}),"(没做完不会出现「下一步」)。 全程界面都可正常点击;随时按 ",(0,eb.jsx)("kbd",{children:"Esc"})," 或右上角 ✕ 退出。"]})},{id:"theme",before:edh(()=>e.goHome()),target:()=>edp('[role="menu"]')??edp('[data-tour="account-button"]'),gate:edg,gateHint:"点击用户名按钮展开菜单",padding:6,title:"切换主题",body:(0,eb.jsxs)(eb.Fragment,{children:["点击左下角的 ",(0,eb.jsx)("b",{children:"用户名按钮"})," 打开菜单。展开后,里面的 ",(0,eb.jsx)("b",{children:"外观 / 主题"})," 项每点一次就在"," ",(0,eb.jsx)("b",{children:"浅色 → 深色 → 果冻"})," 之间循环。"]})},{id:"model-routes-add",before:edh(()=>e.select("preferences-model-routes")),target:()=>edp('[data-tour="model-route-form"]')??edp('[data-tour="add-model-route"]'),gate:()=>null!=edp('[data-tour="model-route-form"]'),gateHint:"点击「添加模型路由」",title:"配置模型渠道(1/2)",body:(0,eb.jsxs)(eb.Fragment,{children:["进入 ",(0,eb.jsx)("b",{children:"设置 → 模型路由"}),"。请点 ",(0,eb.jsx)("b",{children:"添加模型路由"})," 新增一个第三方渠道(任何 OpenAI / Anthropic 兼容 API 都行)。"]})},{id:"model-routes-fields",before:edh(()=>e.select("preferences-model-routes")),target:'[data-tour="model-route-form"]',waitForTarget:2500,title:"配置模型渠道(2/2)",body:(0,eb.jsxs)(eb.Fragment,{children:["表单各项:",(0,eb.jsx)("b",{children:"提供商名称"})," 仅作标识;",(0,eb.jsx)("b",{children:"协议"})," 选 OpenAI / Anthropic 风格;",(0,eb.jsx)("b",{children:"Endpoint URL"})," 填到 ",(0,eb.jsx)("code",{children:"/v1"})," 这一级;",(0,eb.jsx)("b",{children:"API Key"})," 是密钥;",(0,eb.jsx)("b",{children:"可用模型"})," 勾选启用并可设上下文长度。",(0,eb.jsx)("br",{}),"⚠️ 填完",(0,eb.jsx)("b",{children:"务必点「保存」"}),",否则不生效。"]})},{id:"agent-config-compression",before:edh(()=>e.select("preferences-agent-config")),target:'[data-tour="agent-config-compression"]',title:"代理配置 · 压缩上下文",body:(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("b",{children:"设置 → 代理配置"})," 的第一块:当对话 token 接近模型上下文窗口的设定百分比时,自动用",(0,eb.jsx)("b",{children:"压缩模型"})," 压缩历史。阈值 0% 表示关闭,建议 70%-85%。"]})},{id:"agent-config-summary",before:edh(()=>e.select("preferences-agent-config")),target:'[data-tour="agent-config-summary"]',title:"代理配置 · 对话摘要",body:(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("b",{children:"对话摘要"}),":开启后用",(0,eb.jsx)("b",{children:"摘要模型"}),"自动生成 / 更新对话标题与每轮的轮次标题,方便在侧边栏 与时间轴里快速辨认。"]})},{id:"agent-config-approval",before:edh(()=>e.select("preferences-agent-config")),target:'[data-tour="agent-config-approval"]',title:"代理配置 · 命令审批",body:(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("b",{children:"命令审批"}),":在 Auto 权限模式下,用",(0,eb.jsx)("b",{children:"审批模型"})," + ",(0,eb.jsx)("b",{children:"审批提示词"})," 判断 Agent 发起的命令 是否自动放行。留空则非危险命令全部放行。改完记得 ",(0,eb.jsx)("b",{children:"保存"}),"。"]})},{id:"subagent-explore",before:edh(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-explore"]',title:"子代理 · 探索",body:(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("b",{children:"设置 → 子代理配置"}),"。",(0,eb.jsx)("b",{children:"探索"})," 子代理擅长只读检索代码 / 资料。可单独设它的",(0,eb.jsx)("b",{children:"使用模型"}),"(留空则继承上级)与",(0,eb.jsx)("b",{children:"系统提示词"}),"。"]})},{id:"subagent-workflow",before:edh(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-workflow"]',title:"子代理 · 工作流",body:(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("b",{children:"工作流"})," 子代理负责多步骤任务编排,同样可单独配模型与提示词。"]})},{id:"subagent-operator",before:edh(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-operator"]',title:"子代理 · 操作",body:(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("b",{children:"操作"})," 子代理执行写文件 / 跑命令等动手类任务,工具集固定。"]})},{id:"subagent-custom",before:edh(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-custom"]',title:"子代理 · 自定义",body:(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("b",{children:"自定义子代理"}),":主 Agent 可自取名字、从你设的",(0,eb.jsx)("b",{children:"可用模型池"}),"里挑模型来召唤,拥有完整 工具集,还能再派发上面三种官方子代理。"]})},{id:"check-update",before:edh(()=>e.select("check-update")),target:'[data-tour="check-update"]',title:"检查更新",body:(0,eb.jsxs)(eb.Fragment,{children:["这里查看各机器的运行时版本并 ",(0,eb.jsx)("b",{children:"立即更新"}),"。原理:从 npm 拉取最新运行时包、就地替换二进制与 前端,",(0,eb.jsx)("b",{children:"无需重装"}),";P2P mesh 未变时更新还",(0,eb.jsx)("b",{children:"不需要管理员权限"}),"。"]})},{id:"hub-account",before:edh(()=>e.select("account")),target:'[data-tour="hub-account"]',title:"Hub 账户",body:(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("b",{children:"设置 → Hub 账户"}),"。上方是你的",(0,eb.jsx)("b",{children:"账户信息"}),"与",(0,eb.jsx)("b",{children:"设备绑定"}),"状态——Hub 负责多机互联、组网 下发与云端身份。"]})},{id:"hub-account-danger",before:edh(()=>e.select("account")),target:'[data-tour="hub-account-danger"]',title:"Hub 账户 · 危险操作",body:(0,eb.jsxs)(eb.Fragment,{children:["下方的 ",(0,eb.jsx)("b",{children:"危险操作"})," 区可",(0,eb.jsx)("b",{children:"解除设备绑定"}),"或",(0,eb.jsx)("b",{children:"退出登录"}),"。这些操作不可逆,会把本机移出 账户,请谨慎。"]})},{id:"new-conversation",before:edh(()=>e.goHome()),target:'[data-tour="home-new-conversation"]',gate:edx,gateHint:"点击「新建对话」继续",title:"创建新对话",body:(0,eb.jsxs)(eb.Fragment,{children:["回到主页,请点 ",(0,eb.jsx)("b",{children:"新建对话"})," 进入初始化向导(侧边栏顶部也有同样入口)。"]})},{id:"wizard-1",target:'[data-tour="init-wizard"]',placement:"left",padding:4,waitForTarget:5e3,gate:()=>!edx()||edv()>=2,gateHint:"配好运行环境后点向导的「下一步」",title:"向导 ① 运行环境与引擎",body:(0,eb.jsxs)(eb.Fragment,{children:["先选在",(0,eb.jsx)("b",{children:"哪台机器"}),"上运行;本机运行时还能选 ",(0,eb.jsx)("b",{children:"运行引擎"}),"——",(0,eb.jsx)("b",{children:"Vantaloom"})," / ",(0,eb.jsx)("b",{children:"Claude Code"})," / ",(0,eb.jsx)("b",{children:"reclaude"}),"(Claude Code 仅限本机)。 整个向导区域已高亮,配好后点向导自己的 ",(0,eb.jsx)("b",{children:"下一步"}),"。"]})},{id:"wizard-2",target:'[data-tour="init-wizard"]',placement:"left",padding:4,gate:()=>!edx()||edv()>=3,gateHint:"选好工作目录后点向导的「下一步」",title:"向导 ② 选择工作目录",body:(0,eb.jsxs)(eb.Fragment,{children:["先给对话",(0,eb.jsx)("b",{children:"起个名字"}),",再选 ",(0,eb.jsx)("b",{children:"工作目录"}),"——这是智能体能读写的根目录 (Claude Code 用单个目录作为工作根目录)。选好后点向导的「下一步」。"]})},{id:"wizard-3",target:'[data-tour="init-wizard"]',placement:"left",padding:4,gate:()=>!edx()||edv()>=4,gateHint:"配好模型后点向导的「下一步」",title:"向导 ③ 模型设置",body:(0,eb.jsxs)(eb.Fragment,{children:["选择这段对话使用的",(0,eb.jsx)("b",{children:"模型"}),"——",(0,eb.jsx)("b",{children:"Vantaloom"})," 用你刚配置的模型路由,",(0,eb.jsx)("b",{children:"Claude Code"})," 则由其自身提供模型。选好后点向导的「下一步」。"]})},{id:"wizard-4",target:'[data-tour="init-wizard"]',placement:"left",padding:4,gate:()=>!edx(),gateHint:"点向导的「确认开始」创建对话",title:"向导 ④ 确认开始",body:(0,eb.jsxs)(eb.Fragment,{children:["核对无误后,点向导右下角的 ",(0,eb.jsx)("b",{children:"确认开始"})," 创建对话。创建成功后会自动进入对话界面。"]})},{id:"composer-toolbar",target:'[data-slot="agent-input-composer-toolbar"]',waitForTarget:6e3,title:"输入框下方的按钮",body:(0,eb.jsxs)(eb.Fragment,{children:["输入框下面一排:",(0,eb.jsx)("b",{children:"权限模式"}),"(工具调用是否需审批)、",(0,eb.jsx)("b",{children:"模型选择"}),"、右侧 ",(0,eb.jsx)("b",{children:"发送 / 停止"}),"按钮(运行中变停止),以及 ",(0,eb.jsx)("b",{children:"上下文用量"})," 指示。"]})},{id:"queue-stack",target:'[data-slot="agent-input-composer-textarea"]',waitForTarget:3e3,title:"待发送栈(Tab 键)",body:(0,eb.jsxs)(eb.Fragment,{children:["输入内容后按 ",(0,eb.jsx)("kbd",{children:"Tab"})," 可把它压入",(0,eb.jsx)("b",{children:"待发送栈"}),"而不立即发送,便于排队多条指令。栈里每条都能 点击:用 ",(0,eb.jsx)("b",{children:"引导"})," 在合适时机插入对话,或删除。"]})},{id:"pane-toolbar",target:'[data-tour="pane-toolbar"]',waitForTarget:3e3,title:"工作区顶栏",body:(0,eb.jsxs)(eb.Fragment,{children:["右侧工作区最上面一排:左边 ",(0,eb.jsx)("b",{children:"布局标签"})," 切换分屏预设,中间 ",(0,eb.jsx)("b",{children:"位置切换"})," 控制对话面板在左 / 居中 / 在右。"]})},{id:"pane-split",target:'[aria-label="上下二分"]',waitForTarget:4e3,gate:()=>null!=edp('[aria-label="上下二分"][data-state="active"]'),gateHint:"点「上下二分」分栏",title:"动手 · 上下分栏",body:(0,eb.jsxs)(eb.Fragment,{children:["在布局标签里点 ",(0,eb.jsx)("b",{children:"上下二分"}),"(顶部面板图标),把右侧工作区分成上下两块。"]})},{id:"pane-add-top",target:'[data-tour="pane-add"]',waitForTarget:3e3,gate:()=>null!=edp('[placeholder="搜索组件..."]')||null!=edp('[data-slot="multi-tab-list"]'),gateHint:"点上面板的「添加」",autoAdvance:!0,title:"动手 · 添加上面板组件",body:(0,eb.jsxs)(eb.Fragment,{children:["点",(0,eb.jsx)("b",{children:"上面板"}),"中间的 ",(0,eb.jsx)("b",{children:"添加"})," 按钮,打开组件选择面板。"]})},{id:"pane-pick-multitab",target:'[data-tour="pane-template-multi-tab-system"]',waitForTarget:3e3,gate:()=>null!=edp('[data-slot="multi-tab-list"]'),gateHint:"选择「多标签页系统」",title:"动手 · 选多文件标签组件",body:(0,eb.jsxs)(eb.Fragment,{children:["在弹出面板里找到 ",(0,eb.jsx)("b",{children:"多标签页系统"}),"(即多文件标签组件)并点击添加,它会填入上面板。"]})},{id:"multi-tab",target:'[data-slot="multi-tab-list"]',waitForTarget:3e3,title:"多文件标签组件",body:(0,eb.jsxs)(eb.Fragment,{children:["顶部是",(0,eb.jsx)("b",{children:"多文件标签条"}),":点 ",(0,eb.jsx)("b",{children:"+"})," 新增标签、点标签切换文件、",(0,eb.jsx)("b",{children:"×"})," 关闭。单文件内还能在",(0,eb.jsx)("b",{children:"查看 / 编辑"})," 与 ",(0,eb.jsx)("b",{children:"代码 / 预览 / 十六进制"})," 间切换,编辑后记得保存。"]})},{id:"pane-add-bottom",target:'[data-tour="pane-add"]',waitForTarget:3e3,gate:()=>null!=edp('[placeholder="搜索组件..."]')||null!=edp('[data-slot="terminal-tab-group"]'),gateHint:"点下面板的「添加」",autoAdvance:!0,title:"动手 · 添加下面板组件",body:(0,eb.jsxs)(eb.Fragment,{children:["现在点",(0,eb.jsx)("b",{children:"下面板"}),"的 ",(0,eb.jsx)("b",{children:"添加"})," 按钮,再次打开组件选择面板。"]})},{id:"pane-pick-terminal",target:'[data-tour="pane-template-terminal-tab-group"]',waitForTarget:3e3,gate:()=>null!=edp('[data-slot="terminal-tab-group"]'),gateHint:"选择「终端标签组」",title:"动手 · 选终端",body:(0,eb.jsxs)(eb.Fragment,{children:["在面板里找到 ",(0,eb.jsx)("b",{children:"终端标签组"})," 并点击添加,它会填入下面板。"]})},{id:"terminal",target:'[data-slot="terminal-tab-group"]',waitForTarget:3e3,title:"终端组件",body:(0,eb.jsxs)(eb.Fragment,{children:["终端支持多会话标签:点 ",(0,eb.jsx)("b",{children:"+"})," 新开会话、点标签切换、",(0,eb.jsx)("b",{children:"×"})," 关闭。直接输入命令即可,输出实时回显,与本机真实 shell 一致。"]})},{id:"pane-cut-clear",target:'[aria-label="剪切窗口内容"]',waitForTarget:3e3,title:"剪切与粉碎",body:(0,eb.jsxs)(eb.Fragment,{children:["顶栏的 ",(0,eb.jsx)("b",{children:"剪切"}),"(剪刀)把窗口内容移动到别处;",(0,eb.jsx)("b",{children:"粉碎"}),"(碎纸机)清空该窗口。均对单个 pane 生效。"]})},{id:"control-room",target:'[data-tour="control-room-toggle"]',waitForTarget:3e3,title:"导播台视角",body:(0,eb.jsxs)(eb.Fragment,{children:["点位置切换中间的 ",(0,eb.jsx)("b",{children:"「隐藏面板」"}),"(矩形图标)进入",(0,eb.jsx)("b",{children:"导播台"}),":对话偏左,右侧悬浮显示主 Agent 与各子 Agent 的实时预览小窗,点小窗即可切换主面板。"]})},{id:"outro",centered:!0,title:"完成 🎉",body:(0,eb.jsxs)(eb.Fragment,{children:["你已走过核心功能。随时可从空白页的 ",(0,eb.jsx)("b",{children:"使用教程"})," 重新打开本向导。开始创造吧!"]})}]}))},[ed,Q,eu]),em=ew.useCallback(()=>{i("account")},[]),eh=d?.id??s?.conversation.id,ep=!!d&&s?.conversation.id!==d.id,eg="new-agent-conversation"===a||"project-conversation"===a,ex=(0,eb.jsxs)("section",{className:(0,ez.cn)("relative h-full min-w-0 flex-1 overflow-hidden",e&&"pt-[calc(3rem+env(safe-area-inset-top))]"),children:["runs"===a?(0,eb.jsx)(edu,{clipboardItems:E,onClipboardItemsChange:I,onOverlayOpenChange:M}):"telemetry"===a?(0,eb.jsx)(edf,{clipboardItems:E,onClipboardItemsChange:I,onOverlayOpenChange:M}):"preferences-models"===a?(0,eb.jsx)(esZ,{}):"preferences-agents"===a?(0,eb.jsx)(es1,{}):"system-general"===a?(0,eb.jsx)(ecj,{}):"network-downloads"===a?(0,eb.jsx)(ec$,{}):"preferences-model-routes"===a?(0,eb.jsx)(esY,{section:"model-routes"}):"preferences-model-groups"===a?(0,eb.jsx)(esY,{section:"model-groups"}):"preferences-agent-config"===a?(0,eb.jsx)(esY,{section:"agent-config"}):"preferences-subagent-config"===a?(0,eb.jsx)(esY,{section:"subagent-config"}):"preferences-cc-engine-config"===a?(0,eb.jsx)(esY,{section:"cc-engine-config"}):"preferences-assets"===a?(0,eb.jsx)(esY,{section:"assets"}):"preferences-layout"===a?(0,eb.jsx)(esY,{section:"layout"}):"preferences-official-extensions"===a?(0,eb.jsx)(ec0,{}):"network-topology"===a?(0,eb.jsx)(es9,{}):"network-settings"===a?(0,eb.jsx)(ecL,{}):"search-settings"===a?(0,eb.jsx)(ecY,{}):"system-downloads"===a?(0,eb.jsx)(ecA,{}):"preferences"===a?(0,eb.jsx)(esY,{}):"check-update"===a?(0,eb.jsx)(ecd,{}):"balance-usage"===a?(0,eb.jsx)(eca,{}):"feedback"===a?(0,eb.jsx)(ecg,{}):"account"===a?(0,eb.jsx)(esr,{}):e||"new-canvas"!==a?e||"all-canvases"!==a?"new-project"===a?(0,eb.jsx)(eiD,{onCreated:e=>{window.dispatchEvent(new CustomEvent(eix)),er(e)},onCancel:()=>i("home")}):"project-overview"===a&&W?(0,eb.jsx)(eoZ,{projectId:W,onOpenSettings:ei,onOpenConversation:(e,t)=>{el(W,e,t)}}):"project-settings"===a&&W?(0,eb.jsx)(eiG,{projectId:W,onClose:()=>i("project-overview")}):"kanban"===a&&W?(0,eb.jsx)(eoH,{projectId:W}):("new-agent-conversation"===a||"project-conversation"===a)&&ep?(0,eb.jsxs)("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 text-muted-foreground",children:[(0,eb.jsx)(eM,{className:"size-6 animate-spin"}),(0,eb.jsx)("span",{className:"text-sm",children:"正在打开对话…"})]}):"new-agent-conversation"===a||"project-conversation"===a?(0,eb.jsx)(ee8,{conversation:s,clipboardItems:E,clipboardDraggingId:T,onClipboardItemsChange:I,onClipboardDraggingChange:R,onOverlayOpenChange:l,onConversationCreated:e=>{c(e)},onCancelDraft:()=>i("home"),subagentStack:f,onSubagentStackChange:m,subagentTree:h,mobileView:g,onMobilePaneCountChange:b}):e?(0,eb.jsx)(edj,{activeConversationId:eh,onItemSelect:ed,onOpenConversation:(e,t)=>{J(e,t)},onOpenConversationSettings:(e,t)=>{k({id:e,owner:t})},onConversationDeleted:e=>{k(t=>t?.id===e?void 0:t)}}):(0,eb.jsx)(edw,{onNewConversation:Q,onStartTour:ef}):(0,eb.jsx)(eis,{clipboardItems:E,onClipboardItemsChange:I,onOverlayOpenChange:M}):(0,eb.jsx)(eig,{nodes:D,edges:L,selectedNodeId:F,clipboardItems:E,onNodesChange:X,onEdgesChange:Y,onNodesSet:_,onEdgesSet:$,onSelectedNodeChange:B,onClipboardItemsChange:I}),j?(0,eb.jsx)("div",{className:(0,ez.cn)("absolute inset-0 z-30",e&&"pt-[calc(3rem+env(safe-area-inset-top))]"),children:(0,eb.jsx)(enP,{conversationId:j.id,ownerMachineId:j.owner,open:!0,onOpenChange:e=>{e||k(void 0)},onEnterConversation:(e,t)=>{J(e,t)}})}):null,(0,eb.jsx)(enA,{open:N,onOpenChange:S,onEnterConversation:(e,t)=>{J(e,t)}}),(0,eb.jsx)(elt,{hidden:!!j||(eg?o:C),items:E,trashItems:P,draggingId:T,onDraggingChange:R,onItemsChange:I,onTrashItemsChange:O,onTrashClipboardItemsChange:A,trashClipboardItems:z})]});return(0,eb.jsxs)("main",{className:"vtl-app-background relative flex h-svh overflow-hidden text-foreground select-none [-webkit-touch-callout:none]",children:[e?(0,eb.jsx)(el4,{navItems:el8,contents:el7,activeWorkspace:a,activeConversationId:eh,activeProjectId:W,onItemSelect:ed,onOpenConversation:(e,t)=>{J(e,t)},onOpenProjectCanvas:(e,t)=>{eo(e,t)},onOpenProjectOverview:er,onOpenProjectKanban:ea,onOpenProjectSettings:ei,onNewProjectConversation:e=>{ec(e)},onOpenProjectConversation:(e,t,n)=>{el(e,t,n)},onNewProject:()=>{es()},onOpenConversationSettings:(e,t)=>{k({id:e,owner:t})},onConversationDeleted:e=>{s?.conversation.id===e&&(c(void 0),i("home")),k(t=>t?.id===e?void 0:t)},onAccountSettings:em,subagentTree:h,activeSubagentPath:f,onOpenSubagent:e=>m(e),title:eg&&s?s.conversation.title?.trim()||"新 Agent 对话":en2.product,trailing:eg&&s?(0,eb.jsx)(kI,{view:g,onViewChange:x,paneCount:v}):(0,eb.jsx)(ec6,{}),children:ex}):(0,eb.jsxs)(eb.Fragment,{children:[(0,eb.jsx)("div",{className:(0,ez.cn)("relative hidden h-svh shrink-0 overflow-hidden p-3 transition-[width,padding] duration-300 ease-out md:block",t?"w-0 p-0":"w-[19.5rem]"),children:(0,eb.jsx)(elS,{navItems:el8,contents:el7,activeWorkspace:a,activeConversationId:eh,activeCanvasId:V,activeProjectId:W,onItemSelect:ed,onOpenConversation:(e,t)=>{J(e,t)},onOpenCanvas:(e,t)=>{en(e,t)},onOpenProjectCanvas:(e,t)=>{eo(e,t)},onOpenProjectOverview:er,onOpenProjectKanban:ea,onOpenProjectSettings:ei,onNewProjectConversation:e=>{ec(e)},onOpenProjectConversation:(e,t,n)=>{el(e,t,n)},onNewProject:()=>{es()},onOpenConversationSettings:(e,t)=>{k({id:e,owner:t})},onConversationDeleted:e=>{s?.conversation.id===e&&(c(void 0),i("home")),k(t=>t?.id===e?void 0:t)},onAccountSettings:em,subagentTree:h,activeSubagentPath:f,onOpenSubagent:e=>m(e)})}),(0,eb.jsx)("div",{className:(0,ez.cn)("group/sb-handle absolute inset-y-0 z-30 hidden w-8 md:block","transition-[left] duration-300 ease-out",t?"left-0":"left-[18.5rem]"),children:(0,eb.jsx)("button",{type:"button",onClick:r,"aria-label":t?"展开侧边栏":"收起侧边栏",title:t?"展开侧边栏":"收起侧边栏",className:"absolute top-1/2 left-0 flex h-14 w-6 -translate-y-1/2 items-center justify-center rounded-r-md border border-l-0 border-border bg-background/85 text-muted-foreground opacity-0 shadow-md backdrop-blur transition-opacity duration-200 hover:text-foreground focus-visible:opacity-100 group-hover/sb-handle:opacity-100",children:t?(0,eb.jsx)(tc,{className:"size-4"}):(0,eb.jsx)(ts,{className:"size-4"})})})]}),e?null:ex]})}function edw({onNewConversation:e,onStartTour:t}){return(0,eb.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col items-center justify-center gap-5 px-6 text-center",children:[(0,eb.jsx)(edm,{className:"h-20 w-auto max-w-[78vw] text-foreground"}),(0,eb.jsx)("p",{className:"max-w-sm text-sm text-muted-foreground",children:"从左侧选择一个会话,或新建对话"}),(0,eb.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[(0,eb.jsxs)(eO.Button,{type:"button",onClick:e,"data-tour":"home-new-conversation",children:[(0,eb.jsx)(tl,{className:"size-4"}),"新建对话"]}),(0,eb.jsxs)(eO.Button,{type:"button",variant:"outline",onClick:t,children:[(0,eb.jsx)(to,{className:"size-4"}),"使用教程"]})]})]})}function edj({activeConversationId:e,onItemSelect:t,onOpenConversation:n,onOpenConversationSettings:r,onConversationDeleted:a}){return(0,eb.jsx)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col px-3 pt-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]",children:(0,eb.jsx)(elT,{activeConversationId:e,onItemSelect:t,onOpenConversation:n,onOpenConversationSettings:r,onConversationDeleted:a})})}function edk(){let{ready:e,user:t,logout:n}=ti();return e?t?(0,eb.jsx)(edy,{}):(0,eb.jsx)(tn,{onComplete:()=>{window.location.reload()}}):(0,eb.jsx)("main",{className:"grid min-h-svh place-items-center bg-background",children:(0,eb.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,eb.jsx)("div",{className:"size-8 animate-spin rounded-full border-2 border-muted-foreground/20 border-t-primary"}),(0,eb.jsx)("span",{className:"text-sm text-muted-foreground",children:"连接中..."})]})})}function edN(){return(0,eb.jsx)(ta,{children:(0,eb.jsx)(edk,{})})}e.s(["default",()=>edN],66204)}]);