auto-coder-web 0.1.91__py3-none-any.whl → 0.1.92__py3-none-any.whl
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.
- auto_coder_web/version.py +1 -1
- auto_coder_web/web/assets/main.js +2 -2
- {auto_coder_web-0.1.91.dist-info → auto_coder_web-0.1.92.dist-info}/METADATA +2 -2
- {auto_coder_web-0.1.91.dist-info → auto_coder_web-0.1.92.dist-info}/RECORD +7 -7
- {auto_coder_web-0.1.91.dist-info → auto_coder_web-0.1.92.dist-info}/WHEEL +0 -0
- {auto_coder_web-0.1.91.dist-info → auto_coder_web-0.1.92.dist-info}/entry_points.txt +0 -0
- {auto_coder_web-0.1.91.dist-info → auto_coder_web-0.1.92.dist-info}/top_level.txt +0 -0
auto_coder_web/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.1.
|
1
|
+
__version__ = "0.1.92"
|
@@ -526,7 +526,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
526
526
|
`),o=5,a=n.language||"javascript",l=()=>{e&&Ki.publish(Qi.UI.SHOW_MODAL,{content:n.content,format:"markdown",language:a,title:J("generatingCode")})};return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title",children:[e&&s.length>o&&x.jsx("button",{onClick:()=>i(!t),className:"message-toggle-button",children:t?x.jsx("svg",{className:"message-toggle-icon text-blue-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon text-blue-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon",children:n.isStreaming?x.jsxs("svg",{className:"animate-spin w-3.5 h-3.5 text-blue-400",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[x.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),x.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):x.jsx("svg",{className:"w-3.5 h-3.5 text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})})}),x.jsx("span",{className:"text-blue-400 message-title-text text-xs",children:n.isStreaming?J("generatingCode"):J("generatedCode")}),e&&x.jsxs(x.Fragment,{children:[x.jsx("button",{onClick:()=>{navigator.clipboard.writeText(r)},className:"ml-auto message-copy-button text-gray-400 hover:text-blue-400",title:J("copy")||"Copy",children:x.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})})}),x.jsx("button",{onClick:l,className:"ml-1 message-maximize-button text-gray-400 hover:text-blue-400",title:J("maximize")||"Maximize",children:x.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 4h-4m4 0l-5-5"})})})]})]}),!t&&x.jsx("div",{className:"message-content-container border border-gray-800",children:x.jsx(zl,{language:a,style:Cc,customStyle:{margin:0,padding:"0.25rem",backgroundColor:"transparent",fontSize:"0.75rem"},wrapLines:!0,wrapLongLines:!0,children:r})})]})},V4t=({message:n})=>{var s;const[e,t]=b.useState(!1),i=n.language||"javascript",r=()=>{var o;Ki.publish(Qi.UI.SHOW_MODAL,{content:n.content,format:"markdown",language:i,title:((o=n.metadata)==null?void 0:o.fileName)||J("generatedCode")})};return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title",children:[x.jsx("button",{onClick:()=>t(!e),className:"message-toggle-button",children:e?x.jsx("svg",{className:"message-toggle-icon text-blue-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon text-blue-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon",children:x.jsx("svg",{className:"w-3.5 h-3.5 text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})})}),x.jsx("span",{className:"text-blue-400 message-title-text text-xs",children:J("generatedCode")||"Generated Code"}),x.jsx("button",{onClick:()=>{navigator.clipboard.writeText(n.content)},className:"ml-auto message-copy-button text-gray-400 hover:text-blue-400",title:J("copy")||"Copy",children:x.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})})}),x.jsx("button",{onClick:r,className:"ml-1 message-maximize-button text-gray-400 hover:text-blue-400",title:J("maximize")||"Maximize",children:x.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 4h-4m4 0l-5-5"})})})]}),!e&&x.jsxs("div",{className:"message-content-container border border-gray-800",children:[((s=n.metadata)==null?void 0:s.fileName)&&x.jsxs("div",{className:"px-2 py-0.5 bg-gray-800/50 border-b border-gray-800 flex items-center",children:[x.jsx("svg",{className:"w-3 h-3 mr-1 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),x.jsx("span",{className:"text-gray-300 font-mono text-xs",children:n.metadata.fileName})]}),x.jsx("div",{className:"p-0 bg-gray-800/20",children:x.jsx(zl,{language:i,style:Cc,customStyle:{margin:0,padding:"0.25rem",backgroundColor:"transparent",fontSize:"0.75rem"},wrapLines:!0,wrapLongLines:!0,children:n.content})})]})]})},K4t=({message:n})=>{var i;const e=n.type==="STREAM"&&((i=n.metadata)==null?void 0:i.stream_out_type)==="code_rank",t=e&&!n.isStreaming;return e?x.jsx(G4t,{message:n,isCompleted:t}):x.jsx(Q4t,{message:n})},G4t=({message:n,isCompleted:e})=>{const[t,i]=b.useState(e),r=n.content||"";r.split(`
|
527
527
|
`);const s=n.language||"javascript";return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title",children:[x.jsx("button",{onClick:()=>i(!t),className:"message-toggle-button",children:t?x.jsx("svg",{className:"message-toggle-icon text-purple-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon text-purple-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon",children:x.jsx("svg",{className:"w-4 h-4 text-purple-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),x.jsx("span",{className:"text-purple-400 message-title-text",children:n.isStreaming?J("rankingCode"):J("rankedCode")}),n.isStreaming&&x.jsx("span",{className:"ml-2",children:x.jsxs("svg",{className:"animate-spin h-4 w-4 text-yellow-400",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[x.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),x.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})]}),!t&&x.jsx("div",{className:"message-content-container",children:x.jsx(zl,{language:s,style:Cc,customStyle:{margin:0,padding:"1rem",backgroundColor:"transparent"},wrapLines:!0,wrapLongLines:!0,children:r})})]})},Q4t=({message:n})=>{var r;const e=n.language||"javascript",[t,i]=b.useState(!0);return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title",children:[x.jsx("button",{onClick:()=>i(!t),className:"message-toggle-button",children:t?x.jsx("svg",{className:"message-toggle-icon text-purple-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon text-purple-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon",children:x.jsx("svg",{className:"w-4 h-4 text-purple-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),x.jsx("span",{className:"text-purple-400 message-title-text",children:J("rankedCode")||"Ranked Code"})]}),!t&&x.jsxs("div",{className:"message-content-container",children:[((r=n.metadata)==null?void 0:r.rankTitle)&&x.jsxs("div",{className:"px-4 py-2 bg-gray-800/50 border-b border-gray-700 flex items-center",children:[x.jsx("svg",{className:"w-4 h-4 mr-2 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M13 10V3L4 14h7v7l9-11h-7z"})}),x.jsx("span",{className:"text-gray-300 font-mono",children:n.metadata.rankTitle})]}),x.jsx("div",{className:"p-0 bg-gray-800/20",children:x.jsx(zl,{language:e,style:Cc,customStyle:{margin:0,padding:"1rem",backgroundColor:"transparent"},wrapLines:!0,wrapLongLines:!0,children:n.content})})]})]})},q4t=({message:n})=>{var i;const e=n.type==="STREAM"&&((i=n.metadata)==null?void 0:i.stream_out_type)==="lint",t=e&&!n.isStreaming;return e?x.jsx(Y4t,{message:n,isCompleted:t}):x.jsx(X4t,{message:n})},Y4t=({message:n,isCompleted:e})=>{const[t,i]=b.useState(e),r=n.content||"",s=r.split(`
|
528
528
|
`);return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title",children:[e&&s.length>5&&x.jsx("button",{onClick:()=>i(!t),className:"message-toggle-button",children:t?x.jsx("svg",{className:"message-toggle-icon text-yellow-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon text-yellow-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon",children:n.isStreaming?x.jsxs("svg",{className:"animate-spin w-3.5 h-3.5 text-yellow-400",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[x.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),x.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):x.jsx("svg",{className:"w-3.5 h-3.5 text-yellow-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),x.jsx("span",{className:"text-yellow-400 message-title-text text-xs",children:n.isStreaming?J("analyzingCode")||"Analyzing Code":J("lintResults")||"Lint Results"})]}),!t&&x.jsx("div",{className:"message-content-container border border-gray-800",children:x.jsx("div",{className:"p-2 whitespace-pre-wrap text-xs text-white",children:r})})]})},X4t=({message:n})=>{var i;const[e,t]=b.useState(!1);return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title",children:[x.jsx("button",{onClick:()=>t(!e),className:"message-toggle-button",children:e?x.jsx("svg",{className:"message-toggle-icon text-yellow-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon text-yellow-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon",children:x.jsx("svg",{className:"w-3.5 h-3.5 text-yellow-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),x.jsx("span",{className:"text-yellow-400 message-title-text text-xs",children:J("lintResults")||"Lint Results"})]}),!e&&x.jsxs("div",{className:"message-content-container border border-gray-800",children:[((i=n.metadata)==null?void 0:i.fileName)&&x.jsxs("div",{className:"px-2 py-0.5 bg-gray-800/50 border-b border-gray-800 flex items-center",children:[x.jsx("svg",{className:"w-3 h-3 mr-1 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),x.jsx("span",{className:"text-gray-300 font-mono text-xs",children:n.metadata.fileName})]}),x.jsx("div",{className:"p-2 whitespace-pre-wrap text-xs text-white",children:n.content})]})]})};function z8e(n,e=2){let t;if(typeof n=="string"){if(t=parseFloat(n),isNaN(t))return""}else t=n;if(typeof t!="number"||isNaN(t))return"";const i=e<0?0:e;return t.toFixed(i)}const Z4t=(n,e,t=5)=>{if(n===void 0||e===void 0)return"$0.00000";const i=n+e;return`$${z8e(i,t)}`},J4t=({message:n})=>{const e=b.useRef(null),[t,i]=b.useState(!0),r=()=>{e.current&&i(e.current.offsetWidth>500)};return b.useEffect(()=>{r();const s=new ResizeObserver(()=>{r()});return e.current&&s.observe(e.current),()=>{e.current&&s.unobserve(e.current)}},[]),x.jsx("div",{ref:e,className:"font-mono text-[11px] text-gray-400 flex flex-row items-center gap-2 flex-wrap",children:n.metadata&&x.jsxs(x.Fragment,{children:[n.metadata.file_number!==void 0&&n.metadata.total_files!==void 0&&x.jsx("div",{className:"flex items-center",children:x.jsxs("span",{children:[J("indexingFiles",{file_number:n.metadata.file_number,file_increment:Number(z8e(n.metadata.file_number/n.metadata.total_files*100))}),"% "]})}),n.metadata.updated_files!==void 0&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"flex items-center",children:x.jsx("span",{className:"text-green-500 ml-1",children:n.metadata.updated_files})}),x.jsxs("div",{className:"flex items-center",children:[x.jsxs("span",{children:[J("removedFiles"),": "]}),x.jsx("span",{className:"text-red-500 ml-1",children:n.metadata.removed_files})]})]}),n.metadata.input_tokens!==void 0&&x.jsxs("div",{className:"flex items-center",children:[x.jsxs("span",{children:[J("tokens"),": "]}),x.jsxs("span",{className:"text-green-500 ml-1",children:["↑ ",n.metadata.input_tokens]}),x.jsxs("span",{className:"text-red-500 ml-1",children:["↓ ",n.metadata.output_tokens]})]}),n.metadata.input_cost!==void 0&&x.jsxs("div",{className:"flex items-center",children:[x.jsxs("span",{children:[J("apiCost"),": "]}),x.jsx("span",{className:"text-white ml-1",children:Z4t(n.metadata.input_cost,n.metadata.output_cost,5)})]})]})})},eBt=({message:n})=>{const e=()=>{Ki.publish(Qi.CHAT.REFRESH_FROM_MESSAGE,{messageId:n.id,messageContent:n.content})};return x.jsxs("div",{className:"message-font group relative",children:[" ",x.jsx("button",{onClick:e,className:"absolute top-1 right-1 p-1 rounded text-gray-400 hover:text-gray-200 transition-opacity",title:J("refreshFromHere")||"Refresh from here",children:x.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m-15.357-2a8.001 8.001 0 0015.357 2M15 15H9"})})}),x.jsxs("div",{className:"message-title",children:[x.jsx("span",{className:"message-title-icon",children:x.jsx("svg",{className:"w-4 h-4 text-indigo-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}),x.jsx("span",{className:"text-indigo-400 message-title-text",children:J("user")||"User"})]}),x.jsxs("div",{className:"prose prose-invert prose-xs max-w-none pt-1",children:[" ",x.jsx($p,{className:"text-gray-200 break-words",components:{code:({className:t,children:i,...r})=>{const s=/language-(\w+)/.exec(t||"");return!s?x.jsx("code",{className:t,...r,children:i}):x.jsx(zl,{language:s?s[1]:"",style:Cc,PreTag:"div",wrapLines:!0,wrapLongLines:!0,children:String(i).replace(/\n$/,"")})}},children:n.content})]})]})},tBt=({message:n})=>{const[e,t]=b.useState(!0),i=b.useMemo(()=>{try{return JSON.parse(n.content).content||""}catch{return n.content}},[n.content]),r=n.language||"javascript",s=()=>{Ki.publish(Qi.UI.SHOW_MODAL,{content:i,format:"markdown",language:r,title:J("unmergedBlocks")})};return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title",children:[x.jsx("button",{onClick:()=>t(!e),className:"message-toggle-button",children:e?x.jsx("svg",{className:"message-toggle-icon text-blue-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon text-blue-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon",children:x.jsx("svg",{className:"w-3.5 h-3.5 text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 7v8a2 2 0 002 2h6M8 7V5a2 2 0 012-2h4.586a1 1 0 01.707.293l4.414 4.414a1 1 0 01.293.707V15a2 2 0 01-2 2h-2M8 7H6a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2v-2"})})}),x.jsx("span",{className:"text-blue-400 message-title-text text-xs",children:J("unmergedBlocks")||"Unmerged Blocks"}),x.jsx("button",{onClick:()=>{navigator.clipboard.writeText(i)},className:"ml-auto message-copy-button text-gray-400 hover:text-blue-400",title:J("copy")||"Copy",children:x.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})})}),x.jsx("button",{onClick:s,className:"ml-1 message-maximize-button text-gray-400 hover:text-blue-400",title:J("maximize")||"Maximize",children:x.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 4h-4m4 0l-5-5"})})})]}),!e&&x.jsx("div",{className:"message-content-container border border-gray-800",children:x.jsx("div",{className:"p-0 bg-gray-800/20",children:x.jsxs(zl,{language:r,style:Cc,customStyle:{margin:0,padding:"0.25rem",backgroundColor:"transparent",fontSize:"0.75rem"},wrapLines:!0,wrapLongLines:!0,children:[i," "]})})})]})},nBt=({message:n})=>{var i;const e=n.type==="STREAM"&&((i=n.metadata)==null?void 0:i.stream_out_type)==="compile",t=e&&!n.isStreaming;return e?x.jsx(iBt,{message:n,isCompleted:t}):x.jsx(rBt,{message:n})},iBt=({message:n,isCompleted:e})=>{const[t,i]=b.useState(e),r=n.content||"",s=r.split(`
|
529
|
-
`);return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title",children:[e&&s.length>5&&x.jsx("button",{onClick:()=>i(!t),className:"message-toggle-button",children:t?x.jsx("svg",{className:"message-toggle-icon text-orange-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon text-orange-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon",children:n.isStreaming?x.jsxs("svg",{className:"animate-spin w-3.5 h-3.5 text-orange-400",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[x.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),x.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):x.jsx("svg",{className:"w-3.5 h-3.5 text-orange-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),x.jsx("span",{className:"text-orange-400 message-title-text text-xs",children:n.isStreaming?J("analyzingCompile")||"Analyzing Compile...":J("compileResults")||"Compile Results"})]}),!t&&x.jsx("div",{className:"message-content-container border border-gray-800",children:x.jsx("div",{className:"p-2 whitespace-pre-wrap text-xs",children:r})})]})},rBt=({message:n})=>{const[e,t]=b.useState(!1),i=b.useMemo(()=>{try{return JSON.parse(n.content).content||n.content}catch{return n.content}},[n.content]),r="bash",s=()=>{Ki.publish(Qi.UI.SHOW_MODAL,{content:i,format:"plaintext",language:r,title:J("compileResults")})};return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title",children:[x.jsx("button",{onClick:()=>t(!e),className:"message-toggle-button",children:e?x.jsx("svg",{className:"message-toggle-icon text-orange-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon text-orange-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon",children:x.jsx("svg",{className:"w-3.5 h-3.5 text-orange-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),x.jsx("span",{className:"text-orange-400 message-title-text text-xs",children:J("compileResults")||"Compile Results"}),x.jsx("button",{onClick:()=>navigator.clipboard.writeText(i),className:"ml-auto message-copy-button text-gray-400 hover:text-orange-400",title:J("copy")||"Copy",children:x.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})})}),x.jsx("button",{onClick:s,className:"ml-1 message-maximize-button text-gray-400 hover:text-orange-400",title:J("maximize")||"Maximize",children:x.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 4h-4m4 0l-5-5"})})})]}),!e&&x.jsx("div",{className:"message-content-container border border-gray-800",children:x.jsx("div",{className:"p-0 bg-gray-800/20",children:x.jsx(zl,{language:r,style:Cc,customStyle:{margin:0,padding:"0.25rem",backgroundColor:"transparent",fontSize:"0.75rem"},wrapLines:!0,wrapLongLines:!0,children:i})})})]})},sBt=({message:n})=>{const[e,t]=b.useState(!0),i=JSON.parse(n.content);i.tool_name;const r=i.path,s=i.diff,o=a=>{const l=[],c=/<<<<<<< SEARCH\n([\s\S]*?)=======\n([\s\S]*?)>>>>>>> REPLACE/gm;let d;for(;(d=c.exec(a))!==null;)l.push({search:d[1].trimEnd(),replace:d[2].trimEnd()});return l.map((u,h)=>x.jsx("div",{className:"mb-1.5 border border-gray-700 rounded overflow-hidden text-xs font-mono shadow-sm",children:x.jsxs("div",{className:"flex",children:[x.jsxs("div",{className:"w-1/2 border-r border-gray-700",children:[x.jsx("div",{className:"bg-gray-800 px-1.5 py-0.5 text-xs font-medium text-gray-300 border-b border-gray-700",children:"SEARCH"}),x.jsx("div",{className:"bg-gray-900 h-56 overflow-auto",children:x.jsx("pre",{className:"px-1.5 py-1 whitespace-pre text-red-300 min-w-full text-xs",children:u.search})})]}),x.jsxs("div",{className:"w-1/2",children:[x.jsx("div",{className:"bg-gray-800 px-1.5 py-0.5 text-xs font-medium text-gray-300 border-b border-gray-700",children:"REPLACE"}),x.jsx("div",{className:"bg-gray-900 h-56 overflow-auto",children:x.jsx("pre",{className:"px-1.5 py-1 whitespace-pre text-green-300 min-w-full text-xs",children:u.replace})})]})]})},h))};return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title flex items-center",children:[x.jsx("button",{onClick:()=>t(!e),className:"message-toggle-button text-gray-400",children:e?x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon",children:x.jsxs("svg",{className:"w-4 h-4 text-yellow-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 20h9"}),x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 4h9"}),x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M4 12h16"})]})}),x.jsx("span",{className:"message-title-text ml-1 text-yellow-400 font-semibold",children:J("agenticEditReplaceInFileToolTitle")})]}),x.jsx("div",{className:"mt-1 text-gray-300 text-xs whitespace-pre-wrap break-words px-2 py-1",children:x.jsx("span",{title:r,className:"hover:underline cursor-help",children:r})}),!e&&x.jsx("div",{className:"mt-2 text-white",children:o(s)})]})},oBt=({message:n})=>{const[e,t]=b.useState(!0);let i="",r=!1,s="",o="";try{const a=JSON.parse(n.content||"{}");i=a.tool_name||"",r=a.success??!1,s=a.message||"",o=a.content||"",i==="ReplaceInFileTool"&&(i=J("agenticEditToolResultReplaceInFileTool")),i==="WriteToFileTool"&&(i=J("agenticEditToolResultWriteToFileTool")),i==="ReadFileTool"&&(i=J("agenticEditToolResultReadFileTool")),i==="ListFilesTool"&&(i=J("agenticEditToolResultListFilesTool")),i==="SearchFilesTool"&&(i=J("agenticEditToolResultSearchFilesTool"))}catch(a){console.error("Failed to parse tool result content:",a),s=n.content}return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title flex items-center",children:[x.jsx("button",{onClick:()=>t(!e),className:"message-toggle-button text-gray-400",children:e?x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon",children:x.jsxs("svg",{className:"w-4 h-4 text-yellow-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 20h9"}),x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 4h9"}),x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M4 12h16"})]})}),x.jsx("span",{className:"message-title-text ml-1 text-yellow-400 font-semibold",children:i}),x.jsx("span",{className:`text-xs px-2 py-0.5 ml-2 rounded-full ${r?"bg-green-600/30 text-green-400":"bg-red-600/30 text-red-400"}`,children:r?"Success":"Failed"})]}),x.jsx("div",{className:"mt-1 text-gray-300 text-xs whitespace-pre-wrap break-words px-2 py-1",children:x.jsx("span",{title:s,className:"hover:underline cursor-help",children:s})}),!e&&o&&x.jsx("div",{className:"mt-2 p-2 bg-gray-900 overflow-auto text-xs font-mono whitespace-pre-wrap text-gray-200 border-t border-gray-700 max-h-[400px] scrollbar-thin scrollbar-thumb-gray-600",children:o})]})},aBt=({message:n})=>{const[e,t]=b.useState(!0);let i="",r="",s="";try{const o=JSON.parse(n.content||"{}");i=o.path||"N/A";const a=o.content||"";r=a.substring(0,150),s=a.length>150?"...":""}catch(o){console.error("Failed to parse WriteToFileTool content:",o),i="Error parsing content",r=""}return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title flex items-center cursor-pointer",onClick:()=>t(!e),children:[x.jsx("button",{className:"message-toggle-button text-gray-400 mr-1",children:e?x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon mr-1",children:x.jsx("svg",{className:"w-4 h-4 text-purple-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),x.jsx("span",{className:"message-title-text text-purple-400 font-semibold",children:J("agenticEditWriteToFileToolTitle")})]}),x.jsx("div",{className:"mt-1 text-cyan-300 bg-gray-800 px-2 py-1 rounded text-sm font-mono break-all",children:i}),!e&&x.jsxs("div",{className:"mt-2",children:[x.jsx("div",{className:"text-gray-400 text-xs mb-1",children:"Content Snippet:"}),x.jsxs("pre",{className:"bg-gray-900 p-2 rounded text-xs font-mono whitespace-pre-wrap overflow-x-auto text-gray-300 max-h-40",children:[r,s]})]})]})},lBt=({message:n})=>{const[e,t]=b.useState(!1);let i="",r=[];try{const s=JSON.parse(n.content||"{}");i=s.question||"N/A";const o=s.options;if(typeof o=="string")try{r=JSON.parse(o),Array.isArray(r)||(r=[])}catch{r=[]}else Array.isArray(o)?r=o:r=[]}catch(s){console.error("Failed to parse AskFollowupQuestionTool content:",s),i="Error parsing content"}return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title flex items-center cursor-pointer",onClick:()=>t(!e),children:[x.jsx("button",{className:"message-toggle-button text-gray-400 mr-1",children:e?x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon mr-1",children:x.jsx("svg",{className:"w-4 h-4 text-orange-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.79 4 4s-1.79 4-4 4c-1.742 0-3.223-.835-3.772-2M12 5v.01M12 19v.01M3.34 16.66l.01-.01M20.66 7.34l-.01.01M16.66 20.66l-.01-.01M7.34 3.34l.01.01M12 22a10 10 0 110-20 10 10 0 010 20z"})})}),x.jsx("span",{className:"message-title-text text-orange-400 font-semibold",children:"AutoCoder is asking a question:"})]}),!e&&x.jsxs("div",{className:"mt-2 space-y-2",children:[x.jsx("div",{className:"text-gray-200",children:i}),r.length>0&&x.jsxs("div",{children:[x.jsx("div",{className:"text-gray-400 text-xs mb-1",children:"Options:"}),x.jsx("ul",{className:"list-disc list-inside text-sm text-gray-300 space-y-1",children:r.map((s,o)=>x.jsx("li",{children:s},o))})]})]})]})},cBt=({message:n})=>{const[e,t]=b.useState(""),[i,r]=b.useState(!1),[s,o]=b.useState(!0);return b.useEffect(()=>{try{const a=JSON.parse(n.content||"{}"),l=a.command||"N/A";t(l),r(a.requires_approval||!1),o(l.length>=80)}catch(a){console.error("Failed to parse ExecuteCommandTool content:",a),t("Error parsing content")}},[n.content]),x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title flex items-center cursor-pointer",onClick:()=>o(!s),children:[x.jsx("button",{className:"message-toggle-button text-gray-400 mr-1",children:s?x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon mr-1",children:x.jsx("svg",{className:"w-4 h-4 text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 9l4-4 4 4m0 6l-4 4-4-4"})})}),x.jsx("span",{className:"message-title-text text-green-400 font-semibold",children:"AutoCoder wants to execute this command:"})]}),!s&&x.jsx("div",{className:"mt-1 text-yellow-300 bg-gray-800 px-2 py-1 rounded text-sm font-mono break-all",children:e}),x.jsxs("div",{className:`mt-1 text-xs ${i?"text-red-400":"text-gray-400"}`,children:["(Requires Approval: ",i?"Yes":"No",")"]})]})},dBt=({message:n})=>{let e="";try{e=JSON.parse(n.content||"{}").path||"N/A"}catch(t){console.error("Failed to parse ListCodeDefinitionNamesTool content:",t),e="Error parsing content"}return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title flex items-center",children:[x.jsx("span",{className:"message-title-icon mr-1",children:x.jsx("svg",{className:"w-4 h-4 text-teal-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})})}),x.jsx("span",{className:"message-title-text text-teal-400 font-semibold",children:"AutoCoder wants to list definitions in:"})]}),x.jsx("div",{className:"mt-1 text-cyan-300 bg-gray-800 px-2 py-1 rounded text-sm font-mono break-all",children:e})]})},uBt=({message:n})=>{let e="",t=!1;try{const i=JSON.parse(n.content||"{}");e=i.path||"N/A",t=i.recursive||!1}catch(i){console.error("Failed to parse ListFilesTool content:",i),e="Error parsing content"}return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title flex items-center",children:[x.jsx("span",{className:"message-title-icon mr-1",children:x.jsx("svg",{className:"w-4 h-4 text-indigo-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})})}),x.jsx("span",{className:"message-title-text text-indigo-400 font-semibold",children:J("agenticEditListFilesToolTitle")})]}),x.jsx("div",{className:"mt-1 text-cyan-300 bg-gray-800 px-2 py-1 rounded text-sm font-mono break-all",children:e}),x.jsxs("div",{className:"mt-1 text-xs text-gray-400",children:["(",t?"Recursively":"Top Level Only",")"]})]})},hBt=({message:n})=>{let e="";try{e=JSON.parse(n.content||"{}").path||"N/A"}catch(t){console.error("Failed to parse ReadFileTool content:",t),e="Error parsing content"}return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title flex items-center",children:[x.jsx("span",{className:"message-title-icon mr-1",children:x.jsxs("svg",{className:"w-4 h-4 text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})}),x.jsx("span",{className:"message-title-text text-blue-400 font-semibold",children:J("agenticEditReadFileToolTitle")})]}),x.jsx("div",{className:"mt-1 text-cyan-300 bg-gray-800 px-2 py-1 rounded text-sm font-mono break-words max-h-[120px] overflow-auto scrollbar-thin scrollbar-thumb-gray-600",children:x.jsx("span",{title:e,className:"hover:underline cursor-help",children:e})})]})},fBt=({message:n})=>{const[e,t]=b.useState(!0);let i="",r="",s="";try{const o=JSON.parse(n.content||"{}");i=o.path||"N/A",r=o.regex||"N/A",s=o.file_pattern||"*"}catch(o){console.error("Failed to parse SearchFilesTool content:",o),i="Error parsing content"}return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title flex items-center cursor-pointer",onClick:()=>t(!e),children:[x.jsx("button",{className:"message-toggle-button text-gray-400 mr-1",children:e?x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon mr-1",children:x.jsx("svg",{className:"w-4 h-4 text-pink-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),x.jsx("span",{className:"message-title-text text-pink-400 font-semibold",children:J("agenticEditSearchFilesToolTitle")})]}),x.jsx("div",{className:"mt-1 text-cyan-300 bg-gray-800 px-2 py-1 rounded text-sm font-mono break-all",children:i}),!e&&x.jsxs("div",{className:"mt-2 space-y-1",children:[x.jsxs("div",{className:"text-xs",children:[x.jsx("span",{className:"text-gray-400",children:"File Pattern: "}),x.jsx("span",{className:"text-yellow-300 font-mono",children:s})]}),x.jsxs("div",{className:"text-xs",children:[x.jsx("span",{className:"text-gray-400",children:"Regex: "}),x.jsx("span",{className:"text-yellow-300 font-mono break-all",children:r})]})]})]})},gBt=({message:n})=>{const[e,t]=b.useState(!0);let i="",r="",s="",o="";try{const a=JSON.parse(n.content||"{}");i=a.server_name||"Default",r=a.tool_name||"Default";const l=a.query||"";s=l.substring(0,100),o=l.length>100?"...":""}catch(a){console.error("Failed to parse UseMcpTool content:",a),i="Error",r="Parsing",s="Content"}return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title flex items-center cursor-pointer",onClick:()=>t(!e),children:[x.jsx("button",{className:"message-toggle-button text-gray-400 mr-1",children:e?x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon mr-1",children:x.jsxs("svg",{className:"w-4 h-4 text-cyan-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}),x.jsx("span",{className:"message-title-text text-cyan-400 font-semibold",children:"AutoCoder wants to use an MCP tool:"})]}),!e&&x.jsxs("div",{className:"mt-2 space-y-1",children:[x.jsxs("div",{className:"text-xs",children:[x.jsx("span",{className:"text-gray-400",children:"Server: "}),x.jsx("span",{className:"text-blue-300 font-mono",children:i})]}),x.jsxs("div",{className:"text-xs",children:[x.jsx("span",{className:"text-gray-400",children:"Tool: "}),x.jsx("span",{className:"text-blue-300 font-mono",children:r})]}),x.jsxs("div",{className:"text-xs",children:[x.jsx("span",{className:"text-gray-400",children:"Query Snippet: "}),x.jsxs("pre",{className:"bg-gray-900 p-1 rounded text-xs font-mono whitespace-pre-wrap overflow-x-auto text-gray-300",children:[s,o]})]})]})]})},pBt=({message:n})=>{let e="",t="";try{const r=JSON.parse(n.content||"{}");e=r.result||"N/A",t=r.command||""}catch(r){console.error("Failed to parse AttemptCompletionTool content:",r),e="Error parsing content"}const i={...n,content:e};return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title flex items-center mb-2",children:[x.jsx("span",{className:"message-title-icon mr-1",children:x.jsx("svg",{className:"w-4 h-4 text-lime-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})}),x.jsx("span",{className:"message-title-text text-lime-400 font-semibold",children:"任务完成"})]}),x.jsx("div",{className:"completion-result",children:x.jsx(l2,{message:i})}),t&&x.jsxs("div",{className:"mt-2",children:[x.jsx("span",{className:"text-gray-400 text-xs",children:"Suggested command: "}),x.jsx("span",{className:"text-yellow-300 bg-gray-800 px-2 py-1 rounded text-sm font-mono break-all",children:t})]})]})},mBt=({message:n})=>{var g,m;const[e,t]=b.useState(!1),[i,r]=b.useState([]),[s,o]=b.useState(null),[a,l]=b.useState(""),c=()=>{var p;if(t(!e),!e&&((p=n.metadata)==null?void 0:p.command)==="read_files"&&n.content){const A=j8e(n.content);r(A)}},d=p=>{s===p?o(null):(o(p),l(i[p].content))},u=b.useCallback((p,A)=>{},[]),h=b.useCallback(p=>{p!==void 0&&l(p)},[]),f=b.useCallback(()=>{},[]);return x.jsxs("div",{className:"message-font message-content-container",children:[x.jsxs("div",{className:"bg-gradient-to-r from-gray-800 to-gray-750 px-4 py-3 border-b border-gray-700 flex items-center justify-between cursor-pointer",onClick:c,children:[x.jsxs("div",{className:"flex items-center",children:[x.jsx("span",{className:"message-title-icon",children:x.jsx("svg",{className:"w-5 h-5 text-indigo-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),x.jsx("span",{className:"text-indigo-400 message-title-text",children:J("agenticFilterCommandResult",{command:(g=n.metadata)==null?void 0:g.command})})]}),x.jsx("div",{className:"text-gray-400",children:x.jsx("svg",{className:`w-5 h-5 transition-transform duration-200 ${e?"transform rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 9l-7 7-7-7"})})})]}),e&&x.jsx("div",{className:"p-4 bg-gray-800/30",children:((m=n.metadata)==null?void 0:m.command)==="read_files"?x.jsxs("div",{className:"text-gray-200",children:[x.jsxs("div",{className:"mb-4",children:[x.jsxs("h3",{className:"font-medium text-gray-300 mb-2",children:[J("files"),":"]}),x.jsx("div",{className:"space-y-1",children:i.map((p,A)=>x.jsxs("div",{className:`flex items-center p-2 rounded cursor-pointer hover:bg-gray-700/50 ${s===A?"bg-gray-700/70 border-l-2 border-indigo-500":""}`,onClick:()=>d(A),children:[x.jsx("svg",{className:"w-4 h-4 mr-2 text-indigo-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),x.jsx("span",{className:"truncate",children:p.file}),x.jsx("svg",{className:`w-4 h-4 ml-auto transition-transform duration-200 ${s===A?"transform rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 9l-7 7-7-7"})})]},A))})]}),s!==null&&x.jsx("div",{className:"border border-gray-700 rounded-lg overflow-hidden",style:{height:"400px"},children:x.jsx(Rue,{initialContent:i[s].content,onContentChange:h,onEditorReady:u,onSubmit:f})})]}):x.jsx("div",{className:"prose prose-invert prose-sm max-w-none",children:x.jsx($p,{className:"text-gray-200 break-words",components:{code:({className:p,children:A,...v})=>{const _=/language-(\w+)/.exec(p||"");return!_?x.jsx("code",{className:p,...v,children:A}):x.jsx(zl,{language:_?_[1]:"",style:Cc,PreTag:"div",wrapLines:!0,wrapLongLines:!0,customStyle:{borderRadius:"0.375rem",fontSize:"14px"},children:String(A).replace(/\n$/,"")})}},children:n.content})})})]})},ABt=({message:n})=>{var e,t;return x.jsxs("div",{className:"font-mono text-sm",children:[x.jsx("div",{className:"text-indigo-400 font-semibold mb-1",children:J("commandPreparation")}),x.jsxs("div",{className:"mb-2",children:[x.jsxs("span",{className:"text-gray-400",children:[J("command"),": "]}),x.jsx("span",{className:"text-white font-semibold",children:(e=n.metadata)==null?void 0:e.command})]}),((t=n.metadata)==null?void 0:t.parameters)&&Object.keys(n.metadata.parameters).length>0&&x.jsxs("div",{children:[x.jsxs("div",{className:"text-gray-400 mb-1",children:[J("parameters"),":"]}),x.jsx("div",{className:"bg-gray-800 p-2 rounded",children:Object.entries(n.metadata.parameters).map(([i,r])=>x.jsxs("div",{className:"grid grid-cols-[120px_1fr] gap-2 mb-1",children:[x.jsxs("span",{className:"text-indigo-300",children:[i,":"]}),x.jsx("span",{className:"text-white break-all",children:typeof r=="object"?JSON.stringify(r):String(r)})]},i))})]})]})},vBt=({message:n})=>{var i;const e=n.type==="STREAM"&&((i=n.metadata)==null?void 0:i.stream_out_type)==="command_suggestion",t=e&&!n.isStreaming;return e?x.jsx(bBt,{message:n,isCompleted:t}):x.jsx(_Bt,{message:n})},bBt=({message:n,isCompleted:e})=>{const[t,i]=b.useState(e),r=n.content||"",s=r.split(`
|
529
|
+
`);return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title",children:[e&&s.length>5&&x.jsx("button",{onClick:()=>i(!t),className:"message-toggle-button",children:t?x.jsx("svg",{className:"message-toggle-icon text-orange-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon text-orange-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon",children:n.isStreaming?x.jsxs("svg",{className:"animate-spin w-3.5 h-3.5 text-orange-400",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[x.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),x.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):x.jsx("svg",{className:"w-3.5 h-3.5 text-orange-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),x.jsx("span",{className:"text-orange-400 message-title-text text-xs",children:n.isStreaming?J("analyzingCompile")||"Analyzing Compile...":J("compileResults")||"Compile Results"})]}),!t&&x.jsx("div",{className:"message-content-container border border-gray-800",children:x.jsx("div",{className:"p-2 whitespace-pre-wrap text-xs",children:r})})]})},rBt=({message:n})=>{const[e,t]=b.useState(!1),i=b.useMemo(()=>{try{return JSON.parse(n.content).content||n.content}catch{return n.content}},[n.content]),r="bash",s=()=>{Ki.publish(Qi.UI.SHOW_MODAL,{content:i,format:"plaintext",language:r,title:J("compileResults")})};return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title",children:[x.jsx("button",{onClick:()=>t(!e),className:"message-toggle-button",children:e?x.jsx("svg",{className:"message-toggle-icon text-orange-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon text-orange-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon",children:x.jsx("svg",{className:"w-3.5 h-3.5 text-orange-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),x.jsx("span",{className:"text-orange-400 message-title-text text-xs",children:J("compileResults")||"Compile Results"}),x.jsx("button",{onClick:()=>navigator.clipboard.writeText(i),className:"ml-auto message-copy-button text-gray-400 hover:text-orange-400",title:J("copy")||"Copy",children:x.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})})}),x.jsx("button",{onClick:s,className:"ml-1 message-maximize-button text-gray-400 hover:text-orange-400",title:J("maximize")||"Maximize",children:x.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 4h-4m4 0l-5-5"})})})]}),!e&&x.jsx("div",{className:"message-content-container border border-gray-800",children:x.jsx("div",{className:"p-0 bg-gray-800/20",children:x.jsx(zl,{language:r,style:Cc,customStyle:{margin:0,padding:"0.25rem",backgroundColor:"transparent",fontSize:"0.75rem"},wrapLines:!0,wrapLongLines:!0,children:i})})})]})},sBt=({message:n})=>{const[e,t]=b.useState(!0),i=JSON.parse(n.content);i.tool_name;const r=i.path,s=i.diff,o=a=>{const l=[],c=/<<<<<<< SEARCH\n([\s\S]*?)=======\n([\s\S]*?)>>>>>>> REPLACE/gm;let d;for(;(d=c.exec(a))!==null;)l.push({search:d[1].trimEnd(),replace:d[2].trimEnd()});return l.map((u,h)=>x.jsx("div",{className:"mb-1.5 border border-gray-700 rounded overflow-hidden text-xs font-mono shadow-sm",children:x.jsxs("div",{className:"flex",children:[x.jsxs("div",{className:"w-1/2 border-r border-gray-700",children:[x.jsx("div",{className:"bg-gray-800 px-1.5 py-0.5 text-xs font-medium text-gray-300 border-b border-gray-700",children:"SEARCH"}),x.jsx("div",{className:"bg-gray-900 h-56 overflow-auto",children:x.jsx("pre",{className:"px-1.5 py-1 whitespace-pre text-red-300 min-w-full text-xs",children:u.search})})]}),x.jsxs("div",{className:"w-1/2",children:[x.jsx("div",{className:"bg-gray-800 px-1.5 py-0.5 text-xs font-medium text-gray-300 border-b border-gray-700",children:"REPLACE"}),x.jsx("div",{className:"bg-gray-900 h-56 overflow-auto",children:x.jsx("pre",{className:"px-1.5 py-1 whitespace-pre text-green-300 min-w-full text-xs",children:u.replace})})]})]})},h))};return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title flex items-center",children:[x.jsx("button",{onClick:()=>t(!e),className:"message-toggle-button text-gray-400",children:e?x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon",children:x.jsxs("svg",{className:"w-4 h-4 text-yellow-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 20h9"}),x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 4h9"}),x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M4 12h16"})]})}),x.jsx("span",{className:"message-title-text ml-1 text-yellow-400 font-semibold",children:J("agenticEditReplaceInFileToolTitle")})]}),x.jsx("div",{className:"mt-1 text-gray-300 text-xs whitespace-pre-wrap break-words px-2 py-1",children:x.jsx("span",{title:r,className:"hover:underline cursor-help",children:r})}),!e&&x.jsx("div",{className:"mt-2 text-white",children:o(s)})]})},oBt=({message:n})=>{const[e,t]=b.useState(!0);let i="",r=!1,s="",o="";try{const a=JSON.parse(n.content||"{}");i=a.tool_name||"",r=a.success??!1,s=a.message||"",o=a.content||"",i==="ReplaceInFileTool"&&(i=J("agenticEditToolResultReplaceInFileTool")),i==="WriteToFileTool"&&(i=J("agenticEditToolResultWriteToFileTool")),i==="ReadFileTool"&&(i=J("agenticEditToolResultReadFileTool")),i==="ListFilesTool"&&(i=J("agenticEditToolResultListFilesTool")),i==="SearchFilesTool"&&(i=J("agenticEditToolResultSearchFilesTool")),typeof o!="string"&&(Array.isArray(o)||o!==null&&typeof o=="object"&&Object.keys(o).length>0?o=JSON.stringify(o,null,2):o=String(o))}catch(a){console.error("Failed to parse tool result content:",a),s=n.content}return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title flex items-center",children:[x.jsx("button",{onClick:()=>t(!e),className:"message-toggle-button text-gray-400",children:e?x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon",children:x.jsxs("svg",{className:"w-4 h-4 text-yellow-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 20h9"}),x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 4h9"}),x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M4 12h16"})]})}),x.jsx("span",{className:"message-title-text ml-1 text-yellow-400 font-semibold",children:i}),x.jsx("span",{className:`text-xs px-2 py-0.5 ml-2 rounded-full ${r?"bg-green-600/30 text-green-400":"bg-red-600/30 text-red-400"}`,children:r?"Success":"Failed"})]}),x.jsx("div",{className:"mt-1 text-gray-300 text-xs whitespace-pre-wrap break-words px-2 py-1",children:x.jsx("span",{title:s,className:"hover:underline cursor-help",children:s})}),!e&&o&&x.jsx("div",{className:"mt-2 p-2 bg-gray-900 overflow-auto text-xs font-mono whitespace-pre-wrap text-gray-200 border-t border-gray-700 max-h-[400px] scrollbar-thin scrollbar-thumb-gray-600",children:o})]})},aBt=({message:n})=>{const[e,t]=b.useState(!0);let i="",r="",s="";try{const o=JSON.parse(n.content||"{}");i=o.path||"N/A";const a=o.content||"";r=a.substring(0,150),s=a.length>150?"...":""}catch(o){console.error("Failed to parse WriteToFileTool content:",o),i="Error parsing content",r=""}return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title flex items-center cursor-pointer",onClick:()=>t(!e),children:[x.jsx("button",{className:"message-toggle-button text-gray-400 mr-1",children:e?x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon mr-1",children:x.jsx("svg",{className:"w-4 h-4 text-purple-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),x.jsx("span",{className:"message-title-text text-purple-400 font-semibold",children:J("agenticEditWriteToFileToolTitle")})]}),x.jsx("div",{className:"mt-1 text-cyan-300 bg-gray-800 px-2 py-1 rounded text-sm font-mono break-all",children:i}),!e&&x.jsxs("div",{className:"mt-2",children:[x.jsx("div",{className:"text-gray-400 text-xs mb-1",children:"Content Snippet:"}),x.jsxs("pre",{className:"bg-gray-900 p-2 rounded text-xs font-mono whitespace-pre-wrap overflow-x-auto text-gray-300 max-h-40",children:[r,s]})]})]})},lBt=({message:n})=>{const[e,t]=b.useState(!1);let i="",r=[];try{const s=JSON.parse(n.content||"{}");i=s.question||"N/A";const o=s.options;if(typeof o=="string")try{r=JSON.parse(o),Array.isArray(r)||(r=[])}catch{r=[]}else Array.isArray(o)?r=o:r=[]}catch(s){console.error("Failed to parse AskFollowupQuestionTool content:",s),i="Error parsing content"}return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title flex items-center cursor-pointer",onClick:()=>t(!e),children:[x.jsx("button",{className:"message-toggle-button text-gray-400 mr-1",children:e?x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon mr-1",children:x.jsx("svg",{className:"w-4 h-4 text-orange-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.79 4 4s-1.79 4-4 4c-1.742 0-3.223-.835-3.772-2M12 5v.01M12 19v.01M3.34 16.66l.01-.01M20.66 7.34l-.01.01M16.66 20.66l-.01-.01M7.34 3.34l.01.01M12 22a10 10 0 110-20 10 10 0 010 20z"})})}),x.jsx("span",{className:"message-title-text text-orange-400 font-semibold",children:"AutoCoder is asking a question:"})]}),!e&&x.jsxs("div",{className:"mt-2 space-y-2",children:[x.jsx("div",{className:"text-gray-200",children:i}),r.length>0&&x.jsxs("div",{children:[x.jsx("div",{className:"text-gray-400 text-xs mb-1",children:"Options:"}),x.jsx("ul",{className:"list-disc list-inside text-sm text-gray-300 space-y-1",children:r.map((s,o)=>x.jsx("li",{children:s},o))})]})]})]})},cBt=({message:n})=>{const[e,t]=b.useState(""),[i,r]=b.useState(!1),[s,o]=b.useState(!0);return b.useEffect(()=>{try{const a=JSON.parse(n.content||"{}"),l=a.command||"N/A";t(l),r(a.requires_approval||!1),o(l.length>=80)}catch(a){console.error("Failed to parse ExecuteCommandTool content:",a),t("Error parsing content")}},[n.content]),x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title flex items-center cursor-pointer",onClick:()=>o(!s),children:[x.jsx("button",{className:"message-toggle-button text-gray-400 mr-1",children:s?x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon mr-1",children:x.jsx("svg",{className:"w-4 h-4 text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 9l4-4 4 4m0 6l-4 4-4-4"})})}),x.jsx("span",{className:"message-title-text text-green-400 font-semibold",children:"AutoCoder wants to execute this command:"})]}),!s&&x.jsx("div",{className:"mt-1 text-yellow-300 bg-gray-800 px-2 py-1 rounded text-sm font-mono break-all",children:e}),x.jsxs("div",{className:`mt-1 text-xs ${i?"text-red-400":"text-gray-400"}`,children:["(Requires Approval: ",i?"Yes":"No",")"]})]})},dBt=({message:n})=>{let e="";try{e=JSON.parse(n.content||"{}").path||"N/A"}catch(t){console.error("Failed to parse ListCodeDefinitionNamesTool content:",t),e="Error parsing content"}return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title flex items-center",children:[x.jsx("span",{className:"message-title-icon mr-1",children:x.jsx("svg",{className:"w-4 h-4 text-teal-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})})}),x.jsx("span",{className:"message-title-text text-teal-400 font-semibold",children:"AutoCoder wants to list definitions in:"})]}),x.jsx("div",{className:"mt-1 text-cyan-300 bg-gray-800 px-2 py-1 rounded text-sm font-mono break-all",children:e})]})},uBt=({message:n})=>{let e="",t=!1;try{const i=JSON.parse(n.content||"{}");e=i.path||"N/A",t=i.recursive||!1}catch(i){console.error("Failed to parse ListFilesTool content:",i),e="Error parsing content"}return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title flex items-center",children:[x.jsx("span",{className:"message-title-icon mr-1",children:x.jsx("svg",{className:"w-4 h-4 text-indigo-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})})}),x.jsx("span",{className:"message-title-text text-indigo-400 font-semibold",children:J("agenticEditListFilesToolTitle")})]}),x.jsx("div",{className:"mt-1 text-cyan-300 bg-gray-800 px-2 py-1 rounded text-sm font-mono break-all",children:e}),x.jsxs("div",{className:"mt-1 text-xs text-gray-400",children:["(",t?"Recursively":"Top Level Only",")"]})]})},hBt=({message:n})=>{let e="";try{e=JSON.parse(n.content||"{}").path||"N/A"}catch(t){console.error("Failed to parse ReadFileTool content:",t),e="Error parsing content"}return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title flex items-center",children:[x.jsx("span",{className:"message-title-icon mr-1",children:x.jsxs("svg",{className:"w-4 h-4 text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})}),x.jsx("span",{className:"message-title-text text-blue-400 font-semibold",children:J("agenticEditReadFileToolTitle")})]}),x.jsx("div",{className:"mt-1 text-cyan-300 bg-gray-800 px-2 py-1 rounded text-sm font-mono break-words max-h-[120px] overflow-auto scrollbar-thin scrollbar-thumb-gray-600",children:x.jsx("span",{title:e,className:"hover:underline cursor-help",children:e})})]})},fBt=({message:n})=>{const[e,t]=b.useState(!0);let i="",r="",s="";try{const o=JSON.parse(n.content||"{}");i=o.path||"N/A",r=o.regex||"N/A",s=o.file_pattern||"*"}catch(o){console.error("Failed to parse SearchFilesTool content:",o),i="Error parsing content"}return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title flex items-center cursor-pointer",onClick:()=>t(!e),children:[x.jsx("button",{className:"message-toggle-button text-gray-400 mr-1",children:e?x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon mr-1",children:x.jsx("svg",{className:"w-4 h-4 text-pink-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),x.jsx("span",{className:"message-title-text text-pink-400 font-semibold",children:J("agenticEditSearchFilesToolTitle")})]}),x.jsx("div",{className:"mt-1 text-cyan-300 bg-gray-800 px-2 py-1 rounded text-sm font-mono break-all",children:i}),!e&&x.jsxs("div",{className:"mt-2 space-y-1",children:[x.jsxs("div",{className:"text-xs",children:[x.jsx("span",{className:"text-gray-400",children:"File Pattern: "}),x.jsx("span",{className:"text-yellow-300 font-mono",children:s})]}),x.jsxs("div",{className:"text-xs",children:[x.jsx("span",{className:"text-gray-400",children:"Regex: "}),x.jsx("span",{className:"text-yellow-300 font-mono break-all",children:r})]})]})]})},gBt=({message:n})=>{const[e,t]=b.useState(!0);let i="",r="",s="",o="";try{const a=JSON.parse(n.content||"{}");i=a.server_name||"Default",r=a.tool_name||"Default";const l=a.query||"";s=l.substring(0,100),o=l.length>100?"...":""}catch(a){console.error("Failed to parse UseMcpTool content:",a),i="Error",r="Parsing",s="Content"}return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title flex items-center cursor-pointer",onClick:()=>t(!e),children:[x.jsx("button",{className:"message-toggle-button text-gray-400 mr-1",children:e?x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon mr-1",children:x.jsxs("svg",{className:"w-4 h-4 text-cyan-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}),x.jsx("span",{className:"message-title-text text-cyan-400 font-semibold",children:"AutoCoder wants to use an MCP tool:"})]}),!e&&x.jsxs("div",{className:"mt-2 space-y-1",children:[x.jsxs("div",{className:"text-xs",children:[x.jsx("span",{className:"text-gray-400",children:"Server: "}),x.jsx("span",{className:"text-blue-300 font-mono",children:i})]}),x.jsxs("div",{className:"text-xs",children:[x.jsx("span",{className:"text-gray-400",children:"Tool: "}),x.jsx("span",{className:"text-blue-300 font-mono",children:r})]}),x.jsxs("div",{className:"text-xs",children:[x.jsx("span",{className:"text-gray-400",children:"Query Snippet: "}),x.jsxs("pre",{className:"bg-gray-900 p-1 rounded text-xs font-mono whitespace-pre-wrap overflow-x-auto text-gray-300",children:[s,o]})]})]})]})},pBt=({message:n})=>{let e="",t="";try{const r=JSON.parse(n.content||"{}");e=r.result||"N/A",t=r.command||""}catch(r){console.error("Failed to parse AttemptCompletionTool content:",r),e="Error parsing content"}const i={...n,content:e};return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title flex items-center mb-2",children:[x.jsx("span",{className:"message-title-icon mr-1",children:x.jsx("svg",{className:"w-4 h-4 text-lime-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})}),x.jsx("span",{className:"message-title-text text-lime-400 font-semibold",children:"任务完成"})]}),x.jsx("div",{className:"completion-result",children:x.jsx(l2,{message:i})}),t&&x.jsxs("div",{className:"mt-2",children:[x.jsx("span",{className:"text-gray-400 text-xs",children:"Suggested command: "}),x.jsx("span",{className:"text-yellow-300 bg-gray-800 px-2 py-1 rounded text-sm font-mono break-all",children:t})]})]})},mBt=({message:n})=>{var g,m;const[e,t]=b.useState(!1),[i,r]=b.useState([]),[s,o]=b.useState(null),[a,l]=b.useState(""),c=()=>{var p;if(t(!e),!e&&((p=n.metadata)==null?void 0:p.command)==="read_files"&&n.content){const A=j8e(n.content);r(A)}},d=p=>{s===p?o(null):(o(p),l(i[p].content))},u=b.useCallback((p,A)=>{},[]),h=b.useCallback(p=>{p!==void 0&&l(p)},[]),f=b.useCallback(()=>{},[]);return x.jsxs("div",{className:"message-font message-content-container",children:[x.jsxs("div",{className:"bg-gradient-to-r from-gray-800 to-gray-750 px-4 py-3 border-b border-gray-700 flex items-center justify-between cursor-pointer",onClick:c,children:[x.jsxs("div",{className:"flex items-center",children:[x.jsx("span",{className:"message-title-icon",children:x.jsx("svg",{className:"w-5 h-5 text-indigo-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),x.jsx("span",{className:"text-indigo-400 message-title-text",children:J("agenticFilterCommandResult",{command:(g=n.metadata)==null?void 0:g.command})})]}),x.jsx("div",{className:"text-gray-400",children:x.jsx("svg",{className:`w-5 h-5 transition-transform duration-200 ${e?"transform rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 9l-7 7-7-7"})})})]}),e&&x.jsx("div",{className:"p-4 bg-gray-800/30",children:((m=n.metadata)==null?void 0:m.command)==="read_files"?x.jsxs("div",{className:"text-gray-200",children:[x.jsxs("div",{className:"mb-4",children:[x.jsxs("h3",{className:"font-medium text-gray-300 mb-2",children:[J("files"),":"]}),x.jsx("div",{className:"space-y-1",children:i.map((p,A)=>x.jsxs("div",{className:`flex items-center p-2 rounded cursor-pointer hover:bg-gray-700/50 ${s===A?"bg-gray-700/70 border-l-2 border-indigo-500":""}`,onClick:()=>d(A),children:[x.jsx("svg",{className:"w-4 h-4 mr-2 text-indigo-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),x.jsx("span",{className:"truncate",children:p.file}),x.jsx("svg",{className:`w-4 h-4 ml-auto transition-transform duration-200 ${s===A?"transform rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 9l-7 7-7-7"})})]},A))})]}),s!==null&&x.jsx("div",{className:"border border-gray-700 rounded-lg overflow-hidden",style:{height:"400px"},children:x.jsx(Rue,{initialContent:i[s].content,onContentChange:h,onEditorReady:u,onSubmit:f})})]}):x.jsx("div",{className:"prose prose-invert prose-sm max-w-none",children:x.jsx($p,{className:"text-gray-200 break-words",components:{code:({className:p,children:A,...v})=>{const _=/language-(\w+)/.exec(p||"");return!_?x.jsx("code",{className:p,...v,children:A}):x.jsx(zl,{language:_?_[1]:"",style:Cc,PreTag:"div",wrapLines:!0,wrapLongLines:!0,customStyle:{borderRadius:"0.375rem",fontSize:"14px"},children:String(A).replace(/\n$/,"")})}},children:n.content})})})]})},ABt=({message:n})=>{var e,t;return x.jsxs("div",{className:"font-mono text-sm",children:[x.jsx("div",{className:"text-indigo-400 font-semibold mb-1",children:J("commandPreparation")}),x.jsxs("div",{className:"mb-2",children:[x.jsxs("span",{className:"text-gray-400",children:[J("command"),": "]}),x.jsx("span",{className:"text-white font-semibold",children:(e=n.metadata)==null?void 0:e.command})]}),((t=n.metadata)==null?void 0:t.parameters)&&Object.keys(n.metadata.parameters).length>0&&x.jsxs("div",{children:[x.jsxs("div",{className:"text-gray-400 mb-1",children:[J("parameters"),":"]}),x.jsx("div",{className:"bg-gray-800 p-2 rounded",children:Object.entries(n.metadata.parameters).map(([i,r])=>x.jsxs("div",{className:"grid grid-cols-[120px_1fr] gap-2 mb-1",children:[x.jsxs("span",{className:"text-indigo-300",children:[i,":"]}),x.jsx("span",{className:"text-white break-all",children:typeof r=="object"?JSON.stringify(r):String(r)})]},i))})]})]})},vBt=({message:n})=>{var i;const e=n.type==="STREAM"&&((i=n.metadata)==null?void 0:i.stream_out_type)==="command_suggestion",t=e&&!n.isStreaming;return e?x.jsx(bBt,{message:n,isCompleted:t}):x.jsx(_Bt,{message:n})},bBt=({message:n,isCompleted:e})=>{const[t,i]=b.useState(e),r=n.content||"",s=r.split(`
|
530
530
|
`),o=3,a=s.length>o?s.slice(0,o).join(`
|
531
531
|
`)+"...":r;return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title",children:[x.jsx("button",{onClick:()=>i(!t),className:"message-toggle-button",children:t?x.jsx("svg",{className:"message-toggle-icon text-yellow-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon text-yellow-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon",children:x.jsx("svg",{className:"w-4 h-4 text-yellow-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})})}),x.jsxs("span",{className:"text-yellow-400 message-title-text",children:[n.isStreaming?J("processingStatus"):J("processingComplete"),"(",J("agenticFilterContext"),")"]}),n.isStreaming&&x.jsx("span",{className:"ml-2",children:x.jsxs("svg",{className:"animate-spin h-4 w-4 text-yellow-400",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[x.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),x.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})]}),x.jsx("div",{className:"message-content-container bg-gray-800/50 p-2 whitespace-pre-wrap text-white break-words",children:t?a:r})]})},_Bt=({message:n})=>{const[e,t]=b.useState(!1);return x.jsxs("div",{className:"message-font",children:[x.jsxs("div",{className:"message-title",children:[x.jsx("button",{onClick:()=>t(!e),className:"message-toggle-button",children:e?x.jsx("svg",{className:"message-toggle-icon text-blue-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})}):x.jsx("svg",{className:"message-toggle-icon text-blue-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z",clipRule:"evenodd"})})}),x.jsx("span",{className:"message-title-icon",children:x.jsx("svg",{className:"w-4 h-4 text-blue-400",viewBox:"0 0 20 20",fill:"currentColor",children:x.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})})}),x.jsx("span",{className:"text-blue-400 message-title-text",children:J("agenticFilterCommandChoose",{command:n.content.split("(")[0]})})]}),!e&&x.jsx("div",{className:"message-content-container bg-gray-800/50 p-2 whitespace-pre-wrap text-white break-words",children:n.content})]})},V8e=({messages:n,onUserResponse:e})=>{const t=r=>{if(r.length===0)return[];const s=r.slice(0,-1),o=r[r.length-1],a=["code_generate","agentic_filter"];return[...s.filter(c=>{var d;return!(c.contentType==="command_prepare_stat"||c.type==="STREAM"&&!c.isStreaming&&a.includes((d=c.metadata)==null?void 0:d.stream_out_type)||c.content==="Agent attempted task completion.")}),o]},i=r=>{var s,o,a,l,c,d,u,h,f,g,m,p,A,v,_,y,C,S;if(r.isUser)return x.jsx(eBt,{message:r});if((o=(s=r.metadata)==null?void 0:s.path)!=null&&o.startsWith("/agent/")){if(((a=r.metadata)==null?void 0:a.path)==="/agent/edit"||((l=r.metadata)==null?void 0:l.path)==="/agent/edit/thinking")return x.jsx(vIe,{message:r});if(((c=r.metadata)==null?void 0:c.path)==="/agent/edit/tool/call"){const E=JSON.parse(r.content);if(E.tool_name==="ReplaceInFileTool")return x.jsx(sBt,{message:r});if(E.tool_name==="WriteToFileTool")return x.jsx(aBt,{message:r});if(E.tool_name==="AskFollowupQuestionTool")return x.jsx(lBt,{message:r});if(E.tool_name==="ExecuteCommandTool")return x.jsx(cBt,{message:r});if(E.tool_name==="ListCodeDefinitionNamesTool")return x.jsx(dBt,{message:r});if(E.tool_name==="ListFilesTool")return x.jsx(uBt,{message:r});if(E.tool_name==="ReadFileTool")return x.jsx(hBt,{message:r});if(E.tool_name==="SearchFilesTool")return x.jsx(fBt,{message:r});if(E.tool_name==="UseMcpTool")return x.jsx(gBt,{message:r});if(E.tool_name==="AttemptCompletionTool")return x.jsx(pBt,{message:r})}return((d=r.metadata)==null?void 0:d.path)==="/agent/edit/tool/result"?x.jsx(oBt,{message:r}):((u=r.metadata)==null?void 0:u.path)==="/agent/edit/plan/mode/respond"||((h=r.metadata)==null?void 0:h.path)==="/agent/edit/completion"?x.jsx(l2,{message:r}):x.jsx(l2,{message:r})}return((f=r.metadata)==null?void 0:f.stream_out_type)==="agentic_filter"?r.contentType==="command_execute_stat"?x.jsx(mBt,{message:r}):r.contentType==="command_prepare"?x.jsx(ABt,{message:r}):r.contentType==="text"?x.jsx(F4t,{message:r}):x.jsx(vBt,{message:r}):r.type==="COMPLETION"?x.jsx(M4t,{message:r}):((g=r.metadata)==null?void 0:g.stream_out_type)==="file_number_list"?x.jsx(H4t,{message:r}):((m=r.metadata)==null?void 0:m.stream_out_type)==="index_build"?x.jsx(J4t,{message:r}):((p=r.metadata)==null?void 0:p.stream_out_type)==="code_generate"?x.jsx(j4t,{message:r}):((A=r.metadata)==null?void 0:A.stream_out_type)==="lint"?x.jsx(q4t,{message:r}):((v=r.metadata)==null?void 0:v.stream_out_type)==="compile"?x.jsx(nBt,{message:r}):((_=r.metadata)==null?void 0:_.stream_out_type)==="code_rank"?x.jsx(K4t,{message:r}):((y=r.metadata)==null?void 0:y.stream_out_type)==="unmerged_blocks"?x.jsx(tBt,{message:r}):r.contentType==="summary"?x.jsx($4t,{message:r}):r.contentType==="token_stat"?x.jsx(T4t,{message:r}):r.contentType==="command_execute_stat"?x.jsx(D4t,{message:r}):r.contentType==="context_used"?x.jsx(R4t,{message:r}):r.isThinking||r.isStreaming||r.type==="STREAM"?x.jsx(vIe,{message:r}):((C=r.metadata)==null?void 0:C.stream_out_type)==="command_suggestion"?x.jsx(O4t,{message:r}):r.contentType==="markdown"&&!((S=r.metadata)!=null&&S.stream_out_type)?x.jsx(l2,{message:r}):x.jsx(l2,{message:r})};return x.jsx(x.Fragment,{children:t(n).map((r,s)=>x.jsxs("div",{className:`flex ${r.isUser?"justify-end":"justify-start"} mb-2 w-full`,children:[!r.isUser&&x.jsx("div",{className:"w-7 h-7 rounded-full bg-indigo-600 flex items-center justify-center mr-2 flex-shrink-0",children:x.jsx("svg",{className:"w-4 h-4 text-white",viewBox:"0 0 24 24",fill:"currentColor",children:x.jsx("path",{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z"})})}),x.jsxs("div",{className:`w-[80%] ${r.isUser?"bg-indigo-600":r.type==="ERROR"?"bg-red-900/80":r.isThinking||r.isStreaming?"bg-gray-700/50":"bg-gray-700"}
|
532
532
|
rounded-xl px-3 py-2 ${r.isUser?"rounded-tr-none":"rounded-tl-none"}`,children:[i(r),r.type==="ASK_USER"&&r.options&&r.options.length>0&&x.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:r.options.map((o,a)=>x.jsx("button",{className:"px-2 py-1 bg-indigo-600 hover:bg-indigo-700 rounded-full text-xs text-white transition-colors",onClick:()=>e(o,r.eventId),children:o},a))})]}),r.isUser&&x.jsx("div",{className:"w-7 h-7 rounded-full bg-gray-600 flex items-center justify-center ml-2 flex-shrink-0",children:x.jsx("svg",{className:"w-4 h-4 text-gray-300",viewBox:"0 0 24 24",fill:"currentColor",children:x.jsx("path",{d:"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"})})})]},r.id||s))})};/*!
|
@@ -1336,7 +1336,7 @@ ${e.toString()}`}}class l6{constructor(e=new oI,t=!1,i,r=LJt){this._services=e,t
|
|
1336
1336
|
scrollbar-thin scrollbar-thumb-gray-700 scrollbar-track-gray-800`,style:{width:"100%"},children:[x.jsx("div",{className:`flex-1 ${W?"flex-grow h-full":"min-h-[80px]"}`,style:W?{display:"flex",flexDirection:"column",height:"calc(100vh - 180px)"}:{},children:x.jsx(wvn,{isMaximized:r||W,onEditorDidMount:o,onShouldSendMessage:()=>a(!0),onToggleMaximize:()=>{W||s(G=>!G)}})}),x.jsx("div",{className:"flex flex-col mt-0 gap-0 flex-shrink-0",children:x.jsx("div",{className:"space-y-0 bg-gray-850 p-0.5 rounded-lg shadow-inner border border-gray-700/50",children:x.jsxs("div",{className:"flex items-center justify-between px-0",children:[x.jsxs("div",{className:"flex items-center space-x-0.5",children:[x.jsx("span",{className:"text-[9px] font-medium text-gray-400",children:"Mode:"}),x.jsx(er,{title:`Switch between Chat and Write mode (${navigator.platform.indexOf("Mac")===0?"⌘":"Ctrl"} + .)`,children:x.jsx(ki,{size:"small",value:d?"rule":l?"write":"chat",onChange:G=>{G==="rule"?(u(!0),c(!1)):(u(!1),c(G==="write"))},options:[{value:"chat",label:"Chat"},{value:"write",label:"Write"},{value:"rule",label:"Rule"}],style:{width:80},className:"text-xs",popupMatchSelectWidth:!1})}),x.jsxs("kbd",{className:"px-0.5 py-0 ml-1 text-[8px] font-semibold text-gray-400 bg-gray-800 border border-gray-600 rounded shadow-sm",children:[navigator.platform.indexOf("Mac")===0?"⌘":"Ctrl"," + Enter"]}),x.jsx("span",{className:"text-[8px] text-gray-500 inline-flex items-center",children:"to send"}),x.jsxs("div",{className:"text-gray-400 text-[8px]",children:["/",navigator.platform.indexOf("Mac")===0?"⌘":"Ctrl"," + L to maximize/minimize"]})]}),x.jsxs("div",{className:"flex items-center space-x-1 mr-1",children:[x.jsx("button",{className:`p-0.5 rounded-md transition-all duration-200
|
1337
1337
|
${P?"text-yellow-400 hover:text-yellow-300":"text-gray-400 hover:text-gray-300"}`,onClick:()=>{const G=!P;$(G),en(async()=>{const{default:q}=await Promise.resolve().then(()=>N4t);return{default:q}},void 0).then(({default:q})=>{q.publish("agentic.mode.changed",G)})},title:"Step By Step",children:x.jsx("span",{className:`text-xs ${P?"":"opacity-50"}`,children:J("agentButtonLabel")})}),x.jsx("span",{className:"text-[9px] text-gray-400 opacity-70 hover:opacity-100 transition-opacity duration-200 whitespace-nowrap",children:J("agentButtonLabelDesc")})]}),x.jsx("button",{className:`p-0.5 rounded-md transition-all duration-200
|
1338
1338
|
focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed
|
1339
|
-
${m?"text-gray-400 hover:text-gray-300":"text-blue-500 hover:text-blue-600"}`,onClick:m?Q:f,disabled:I,title:J(m?I?"cancelling":"stop":"send"),children:(()=>{let G;return m?I?G=x.jsx("div",{className:"relative",children:x.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[x.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),x.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}):G=x.jsx("div",{className:"relative",children:x.jsx("svg",{className:"h-3.5 w-3.5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}):G=x.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5 transform rotate-45",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})}),x.jsx("div",{className:"flex items-center justify-center",children:G})})()})]})})})]})]})};class a_n extends YR.EventEmitter{constructor(){super(),this.eventSource=null,this.streamEvents=new Map,this.lastEventType=null,this.messageId=0,this.currentStreamMessageId=null,this.isStreamingActive=!1,this.eventFileId=null}async executeCommand(e,t=!1){try{const i=await fetch("/api/auto-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e,include_conversation_history:t})});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);const r=await i.json();return this.eventFileId=r.event_file_id,this.startEventStream(),{event_file_id:r.event_file_id}}catch(i){throw console.error("Error executing command:",i),i}}startEventStream(){if(this.closeEventStream(),!this.eventFileId){console.error("No event file ID available");return}this.eventSource=new EventSource(`/api/auto-command/events?event_file_id=${this.eventFileId}`),this.eventSource.onmessage=e=>{try{const t=JSON.parse(e.data);this.handleEvent(t)}catch(t){console.error("Error parsing event data:",t)}},this.eventSource.onerror=e=>{console.error("EventSource error:",e),this.closeEventStream()}}handleEvent(e){let t;switch(e.event_type==="STREAM"?this.lastEventType!=="STREAM"?(t=`msg-${this.messageId++}`,this.currentStreamMessageId=t):t=this.currentStreamMessageId||`msg-${this.messageId++}`:(t=`msg-${this.messageId++}`,this.lastEventType==="STREAM"&&this.currentStreamMessageId&&this.finalizeStreamMessage(this.currentStreamMessageId),this.currentStreamMessageId=null),e.event_type){case"STREAM":this.handleStreamEvent(e,t);break;case"RESULT":this.handleResultEvent(e,t);break;case"ASK_USER":this.handleAskUserEvent(e,t);break;case"USER_RESPONSE":this.handleUserResponseEvent(e,t);break;case"ERROR":this.handleErrorEvent(e,t);break;case"COMPLETION":this.handleCompletionEvent(e,t);break;default:console.warn("Unknown event type:",e.event_type)}this.lastEventType=e.event_type}handleStreamEvent(e,t){const i=e.content;this.isStreamingActive=!0;let r=this.streamEvents.get(t);if(r)r.content+=i.content,r.isThinking=i.is_thinking,r.isStreaming=!0,i.state==="complete"?(r.isStreaming=!1,this.streamEvents.delete(t),this.emit("message",r),this.isStreamingActive=!1):(this.streamEvents.set(t,r),this.emit("message",r));else{const s={id:t,type:e.event_type,content:i.content,contentType:i.content_type,isThinking:i.is_thinking,isStreaming:!0,eventId:e.event_id,language:i.language,metadata:e.metadata};i.state!=="complete"?this.streamEvents.set(t,s):(s.isStreaming=!1,this.isStreamingActive=!1),this.emit("message",s)}}handleResultEvent(e,t){const i=e.content;let r,s=i.content_type,o={...i.metadata,...e.metadata};typeof i.content=="string"?r=i.content:this.isTokenStatContent(i.content)?(s="token_stat",r=JSON.stringify(i.content),o={...o,model_name:i.content.model_name,elapsed_time:i.content.elapsed_time,first_token_time:i.content.first_token_time,input_tokens:i.content.input_tokens,output_tokens:i.content.output_tokens,input_cost:i.content.input_cost,output_cost:i.content.output_cost,speed:i.content.speed}):this.isSummaryContent(i.content)?(s="summary",r=i.content.summary):this.isIndexBuildStartContent(i.content)?(s="index_build_start",r=`Processing files: ${i.content.file_number}/${i.content.total_files}`,o={...o,file_number:i.content.file_number,total_files:i.content.total_files}):this.isIndexBuildEndContent(i.content)?(s="index_build_end",r=`Index build completed: Updated ${i.content.updated_files} files, Removed ${i.content.removed_files} files`,o={...o,updated_files:i.content.updated_files,removed_files:i.content.removed_files,input_tokens:i.content.input_tokens,output_tokens:i.content.output_tokens,input_cost:i.content.input_cost,output_cost:i.content.output_cost}):this.isCommandPrepareStatContent(i.content)?(s="command_prepare_stat",r=`Command: ${i.content.command}`,o={...o,command:i.content.command,parameters:i.content.parameters}):this.isCommandExecuteStatContent(i.content)?(s="command_execute_stat",r=i.content.content,o={...o,command:i.content.command}):this.isContextUsedContent(i.content)?(s="context_used",r=i.content.description,o={...o,files:i.content.files}):r=JSON.stringify(i.content);const a={id:t,type:e.event_type,content:r,contentType:s,metadata:o,eventId:e.event_id};this.emit("message",a)}isTokenStatContent(e){return e&&typeof e.model_name=="string"&&typeof e.elapsed_time=="number"&&typeof e.input_tokens=="number"&&typeof e.output_tokens=="number"}isCommandPrepareStatContent(e){return e&&typeof e.command=="string"&&typeof e.parameters=="object"}isSummaryContent(e){return e&&typeof e.summary=="string"}isCommandExecuteStatContent(e){return e&&typeof e.command=="string"&&typeof e.content=="string"}isIndexBuildStartContent(e){return e&&typeof e.file_number=="number"&&typeof e.total_files=="number"}isIndexBuildEndContent(e){return e&&typeof e.updated_files=="number"&&typeof e.removed_files=="number"&&typeof e.input_tokens=="number"&&typeof e.output_tokens=="number"}isContextUsedContent(e){return e&&Array.isArray(e.files)&&typeof e.title=="string"&&typeof e.description=="string"}handleAskUserEvent(e,t){const i=e.content,r={id:t,type:e.event_type,content:i.prompt,options:i.options,responseRequired:i.required,eventId:e.event_id};this.emit("message",r)}handleUserResponseEvent(e,t){const i=e.content,r={id:t,type:e.event_type,content:i.response,isUser:!0,eventId:e.event_id,responseTo:e.response_to};this.emit("message",r)}handleErrorEvent(e,t){const i=e.content,r={id:t,type:e.event_type,content:i.error_message,metadata:i.details,eventId:e.event_id};this.emit("message",r),setTimeout(()=>{this.emit("taskComplete",!0),Ki.publish(Qi.CODING.TASK_COMPLETE,{success:!0,event_file_id:this.eventFileId})},300)}handleCompletionEvent(e,t){const i=e.content,r={id:t,type:e.event_type,content:i.success_message,eventId:e.event_id,metadata:{success_code:i.success_code,completion_time:i.completion_time,details:i.details,result:i.result}};this.emit("message",r),setTimeout(()=>{this.emit("taskComplete",!1),Ki.publish(Qi.CODING.TASK_COMPLETE,{success:!0,event_file_id:this.eventFileId})},1e3)}finalizeStreamMessage(e){const t=this.streamEvents.get(e);t&&(t.isStreaming=!1,t.isThinking=!1,this.streamEvents.delete(e),this.emit("message",t))}closeEventStream(){this.eventSource&&(this.eventSource.close(),this.eventSource=null),Array.from(this.streamEvents.keys()).forEach(e=>{this.finalizeStreamMessage(e)}),this.streamEvents.clear(),this.lastEventType=null,this.currentStreamMessageId=null,this.isStreamingActive=!1}async sendUserResponse(e,t){if(!this.eventFileId)throw new Error("No event file ID available");try{const i=await fetch("/api/auto-command/response",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event_id:e,event_file_id:this.eventFileId,response:t})});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`)}catch(i){throw console.error("Error sending user response:",i),i}}async cancelTask(){if(!this.eventFileId){console.warn("No event file ID available to cancel task.");return}console.log(`AgenticEditService: Cancelling task with event_file_id: ${this.eventFileId}`);try{const e=await fetch("/api/auto-command/cancel",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event_file_id:this.eventFileId})});if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);console.log(`AgenticEditService: Task cancellation request sent for event_file_id: ${this.eventFileId}`),this.closeEventStream()}catch(e){console.error("Error cancelling agentic edit task:",e)}}}const gP=new a_n;class l_n extends YR.EventEmitter{constructor(){super(),this.config={human_as_model:!1,skip_build_index:!0,project_type:"py",extra_conf:{},available_keys:[]},this.fetchConfig(),this.fetchConfigKeys()}getConfig(){return{...this.config}}async fetchConfig(){try{const e=await fetch("/api/conf");if(!e.ok)throw new Error("Failed to fetch configuration");const t=await e.json(),{human_as_model:i,skip_build_index:r,project_type:s,...o}=t.conf;return this.config={...this.config,human_as_model:i==="true",skip_build_index:r==="true",project_type:s,extra_conf:this.convertToStringValues(o)},this.emit("configUpdated",this.config),this.config}catch(e){return console.error("Error fetching config:",e),this.emit("error","Failed to fetch configuration"),null}}convertToStringValues(e){const t={};for(const i in e)t[i]=String(e[i]);return t}async fetchConfigKeys(){try{const e=await fetch("/api/conf/keys");if(!e.ok)throw new Error("Failed to fetch configuration keys");const t=await e.json();return this.config={...this.config,available_keys:t.keys},this.emit("configKeysUpdated",this.config.available_keys),this.config.available_keys}catch(e){return console.error("Error fetching configuration keys:",e),this.emit("error","Failed to fetch configuration keys"),null}}async updateConfig(e,t){try{if(!(await fetch("/api/conf",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({[e]:String(t)})})).ok)throw new Error("Failed to update configuration");return e==="human_as_model"||e==="skip_build_index"?this.config={...this.config,[e]:!!t}:e==="project_type"?this.config={...this.config,project_type:String(t)}:this.config={...this.config,extra_conf:{...this.config.extra_conf,[e]:String(t)}},this.emit("configUpdated",this.config),!0}catch(i){return console.error("Error updating config:",i),this.emit("error",`Failed to update configuration key: ${e}`),!1}}async reloadConfig(){await this.fetchConfig(),await this.fetchConfigKeys()}}const pP=new l_n,tGe=n=>{const e=new Audio(n);return e.load(),e},c_n=tGe("/sounds/gentle-notification.wav"),d_n=tGe("/sounds/soft-chime.wav"),u_n=(n=.3)=>{try{const e=c_n.cloneNode();e.volume=Math.max(0,Math.min(1,n)),e.play().catch(t=>{console.warn("Failed to play sound effect:",t)})}catch(e){console.error("Error playing sound effect:",e)}},h_n=(n=.3)=>{try{const e=d_n.cloneNode();e.volume=Math.max(0,Math.min(1,n)),e.play().catch(t=>{console.warn("Failed to play sound effect:",t)})}catch(e){console.error("Error playing sound effect:",e)}},f_n=()=>{h_n(.3)},g_n=(n=.3)=>{u_n(n)},p_n=({setPreviewFiles:n,setRequestId:e,setActivePanel:t,setClipboardContent:i,clipboardContent:r,projectName:s="",setSelectedFiles:o})=>{const[a,l]=Se.useState(!1),[c,d]=b.useState(!1),[u,h]=b.useState(!1),f=b.useRef(!1);b.useEffect(()=>{f.current=u},[u]);const g=()=>{_([]);const ze=new Date().toISOString().replace(/[:.]/g,"-");ve(`chat_${ze}`),Ae(!0)},m=()=>{Ae(!1),ve("")},p=async()=>{if(!be.trim()){yt.error("Chat name cannot be empty");return}try{W(be),_([]),P(ze=>[be,...ze]),await Ke(be,[]),await ut(be);try{(await fetch("/api/chat-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:"/new"})})).ok||console.warn("Failed to send /new command to chat router")}catch(ze){console.error("Error sending /new command:",ze)}yt.success("New chat created successfully"),Ae(!1)}catch(ze){console.error("Error creating new chat:",ze),yt.error("Failed to create new chat")}},A=async()=>{const Ze=`chat_${new Date().toISOString().replace(/[:.]/g,"-")}`;try{_([]),W(Ze),P(lt=>[Ze,...lt.filter(St=>St!==Ze)]),await Ke(Ze,[]),await ut(Ze);try{(await fetch("/api/chat-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:"/new"})})).ok||console.warn("Failed to send /new command to chat router")}catch(lt){console.error("Error sending /new command:",lt)}yt.success("New chat created successfully")}catch(lt){console.error("Error creating new chat directly:",lt),yt.error("Failed to create new chat")}},[v,_]=b.useState([]),[y,C]=b.useState([]),[S,E]=b.useState(!1),[L,I]=b.useState(""),[T,D]=b.useState([]),[B,R]=b.useState({human_as_model:!1,extra_conf:{},available_keys:[]}),[O,P]=b.useState([]),[$,W]=b.useState(""),[j,H]=b.useState(!1),[F,U]=b.useState(!1),K=b.useRef(null),V=b.useRef(null),[Q,te]=b.useState(!0),se=b.useRef(!1);b.useEffect(()=>{se.current=Q},[Q]);const[Z,G]=b.useState(!1),[q,X]=b.useState(!1),[ie,oe]=b.useState(!1),[ce,Ae]=b.useState(!1),[be,ve]=b.useState(""),[xe,Ue]=b.useState(!0),[He,$e]=b.useState(!1),[Ne,Ce]=b.useState(!1),[Ie,Re]=b.useState(0),[Fe,_e]=b.useState(!1),[We,Xe]=b.useState({inputTokens:0,outputTokens:0,totalCost:0,contextWindowUsage:0,maxContextWindow:100,cacheHits:0,cacheMisses:0}),et=b.useRef("");b.useEffect(()=>{et.current=L},[L]),b.useEffect(()=>{let ze=0,Ze=0,lt=0,St=0,kt=100,qt=0,Ft=0;v.forEach(ln=>{var $t,Ve;ln.contentType==="token_stat"&&ln.metadata&&(ze+=ln.metadata.input_tokens||0,Ze+=ln.metadata.output_tokens||0,lt+=(ln.metadata.input_cost||0)+(ln.metadata.output_cost||0),St=Math.max(St,ln.metadata.context_window||0),kt=ln.metadata.max_context_window||kt,qt+=ln.metadata.cache_hit||0,Ft+=ln.metadata.cache_miss||0),(($t=ln.metadata)==null?void 0:$t.stream_out_type)==="index_build"&&((Ve=ln.metadata)!=null&&Ve.input_tokens)&&(ze+=ln.metadata.input_tokens||0,Ze+=ln.metadata.output_tokens||0,lt+=(ln.metadata.input_cost||0)+(ln.metadata.output_cost||0),St=Math.max(St,ln.metadata.context_window||0),kt=ln.metadata.max_context_window||kt,qt+=ln.metadata.cache_hit||0,Ft+=ln.metadata.cache_miss||0)}),Xe({inputTokens:ze,outputTokens:Ze,totalCost:lt,contextWindowUsage:St,maxContextWindow:kt,cacheHits:qt,cacheMisses:Ft})},[v]),b.useEffect(()=>{var ze;xe&&((ze=V.current)==null||ze.scrollIntoView({behavior:"smooth"}))},[v,xe]);const tt=b.useCallback(()=>{const ze=document.getElementById("chat-messages-container");if(ze){const Ze=ze.scrollHeight-ze.scrollTop-ze.clientHeight<100;Ue(Ze)}},[]);b.useEffect(()=>{const ze=document.getElementById("chat-messages-container");return ze&&(ze.addEventListener("scroll",tt),tt()),()=>{const Ze=document.getElementById("chat-messages-container");Ze&&Ze.removeEventListener("scroll",tt)}},[tt]),b.useEffect(()=>{q&&(Me(),X(!1))},[q]),b.useEffect(()=>{const ze=lt=>{R(lt)},Ze=lt=>{yt.error(lt)};return pP.on("configUpdated",ze),pP.on("error",Ze),()=>{pP.off("configUpdated",ze),pP.off("error",Ze)}},[]),b.useEffect(()=>{rt(),Pe()},[]);const rt=async()=>{try{const Ze=await(await fetch("/api/chat-lists")).json();if(Ze.chat_lists&&Ze.chat_lists.length>0)W(Ze.chat_lists[0]),P(Ze.chat_lists),await Ye(Ze.chat_lists[0]);else{const St=`chat_${new Date().toISOString().replace(/[:.]/g,"-")}`;W(St),P([St])}}catch(ze){console.error("Error fetching chat lists:",ze),yt.error("Failed to fetch chat lists")}},Pe=async()=>{try{const ze=await fetch("/api/chat-session/name");if(!ze.ok)throw new Error("Failed to fetch current session name");const Ze=await ze.json();Ze.session_name&&(W(Ze.session_name),O.includes(Ze.session_name)||P(lt=>[Ze.session_name,...lt]),await Ye(Ze.session_name))}catch(ze){console.error("Error getting current session name:",ze)}},ut=async ze=>{if(!ze.trim())return!1;try{if(!(await fetch("/api/chat-session/name",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_name:ze})})).ok)throw new Error("Failed to set current session name");return!0}catch(Ze){return console.error("Error setting current session name:",Ze),!1}},Ke=async(ze,Ze=[])=>{if(console.log("save chat list:",ze),console.log("messages:",Ze),!ze.trim()){yt.error("Please enter a name for the chat list");return}try{const lt=await fetch("/api/chat-lists/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:ze,messages:Ze})});lt.ok?(H(!1),rt(),await ut(ze)):console.error("Failed to save chat list",lt.json())}catch(lt){console.error("Error saving chat list:",lt)}},Ye=async ze=>{try{const St=(await(await fetch(`/api/chat-lists/${ze}`)).json()).messages.map(kt=>"role"in kt?{id:kt.id||Date.now().toString(),type:kt.role==="user"?"USER_RESPONSE":"RESULT",content:kt.content,contentType:kt.contentType||"markdown",language:kt.language,metadata:kt.metadata,isUser:kt.role==="user",isStreaming:!1,isThinking:!1}:{...kt,isStreaming:!1,isThinking:!1,type:kt.type||(kt.isUser?"USER_RESPONSE":"RESULT"),contentType:kt.contentType||"markdown"});_(St)}catch(Ze){console.error("Error loading chat list:",Ze),yt.error("Failed to load chat list")}},nt=()=>{if(v.length>0){const ze=v.find(Ze=>Ze.isUser||Ze.type==="USER_RESPONSE");if(ze&&ze.content)return ze.content.substring(0,4)}return"New Chat"},Qe=async ze=>{try{(await fetch(`/api/chat-lists/${ze}`,{method:"DELETE"})).ok?(yt.success("Chat list deleted successfully"),rt()):yt.error("Failed to delete chat list")}catch(Ze){console.error("Error deleting chat list:",Ze),yt.error("Failed to delete chat list")}},ct=async(ze,Ze)=>{try{if(!Ze.trim())return yt.error("Chat name cannot be empty"),!1;const lt=await fetch("/api/chat-lists/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({old_name:ze,new_name:Ze})});if(!lt.ok){const St=await lt.json();throw new Error(St.detail||"Failed to rename chat list")}return P(St=>{const kt=[...St],qt=kt.indexOf(ze);return qt!==-1&&(kt[qt]=Ze),kt}),$===ze&&W(Ze),yt.success(`Chat renamed to ${Ze}`),!0}catch(lt){return console.error("Error renaming chat list:",lt),yt.error(`Failed to rename chat: ${lt.message||"Unknown error"}`),!1}},[Wt,tn]=b.useState(null),[En,Tt]=b.useState(0),Pt=b.useCallback(async ze=>{if(ze)yt.error("Task completed with errors"),f.current&&(console.log("play error sound"),g_n());else{yt.success("Task completed successfully");const Ze=et.current;if(_e(!0),await new Promise(lt=>setTimeout(lt,0)),se.current&&Ze)try{const lt=await fetch(`/api/current-changes?event_file_id=${Ze}`);if(!lt.ok)throw new Error("Failed to fetch current changes");const St=await lt.json();if(console.log("ChatPanel: Received current changes:",St),St.commits&&St.commits.length>0){const kt=St.commits[0].hash,qt=await fetch(`/api/commits/${kt}`);if(!qt.ok)throw new Error("Failed to fetch commit details");const ln=(await qt.json()).files;console.log("ChatPanel: Changed files:",ln);const $t=ln.map(Ve=>({path:Ve.filename,isSelected:!0,modifiedBy:"expert_chat_box"}));o($t),t("code")}}catch(lt){console.error("Error fetching current changes:",lt),yt.error("Failed to fetch changed files")}}U(!1),e(""),I(""),f.current&&(console.log("play task completed"),f_n())},[Q,o,t,U,e,I,_e,u]),Jt=b.useCallback(async()=>{const ze=Date.now();if(ze-En>=3e4)try{const lt=await fetch("/api/file-groups");if(!lt.ok)throw new Error("Failed to fetch file groups");const St=await lt.json();C(St.groups),Tt(ze)}catch{console.error("Failed to load file groups")}},[En]);b.useEffect(()=>{Jt()},[]);const Ut=(ze,Ze)=>{K.current=ze},Kt=ze=>{const Ze=Date.now(),lt=O3(),St=Ie+1;Re(St);const kt={id:`user-${lt}-${Ze}-${St}`,type:"USER_RESPONSE",content:ze,contentType:"markdown",isUser:!0,isStreaming:!0,isThinking:!1};return _(qt=>{const Ft=[...qt,kt];return Ft.length>0&&$&&Ke($,Ft),Ft}),kt.id},_t=ze=>{const Ze=Date.now(),lt=O3(),St=Ie+1;Re(St);const kt={id:`bot-${lt}-${Ze}-${St}`,type:"RESULT",content:ze,contentType:"markdown",isUser:!1,isStreaming:!1,isThinking:!1};return _(qt=>{const Ft=[...qt,kt];return Ft.length>0&&$&&Ke($,Ft),Ft}),kt.id},ae=(ze,Ze)=>{_(lt=>lt.map(St=>St.id===ze?{...St,isStreaming:Ze==="sending",isThinking:Ze==="sending"}:St))},ue=async()=>{},ye=()=>v;b.useEffect(()=>{Fe&&$&&v.length>0&&(Ke($,v),console.log("Chat list saved with latest messages:",$),_e(!1))},[v,Fe,$]);const Le=ze=>{ze.on("message",Ze=>{console.log("ChatPanel: Received message from service:",ze===kS?"chatService":"codingService",Ze.type,Ze.id),Ki.publish(Qi.CHAT.NEW_MESSAGE,Ze),_(lt=>{const St=lt.findIndex(kt=>kt.id===Ze.id);if(St!==-1){const kt=[...lt];return kt[St]=Ze,kt}else return[...lt,Ze]})}),ze.on("taskComplete",Pt)},Ee=b.useCallback(ze=>{_(Ze=>{const lt=Ze.findIndex(St=>St.id===ze.messageId);return lt===-1?Ze:Ze.slice(0,lt)}),K.current&&(K.current.setValue(ze.messageContent),setTimeout(()=>{K.current&&K.current.focus()},100)),setTimeout(()=>{var Ze;(Ze=V.current)==null||Ze.scrollIntoView({behavior:"smooth"})},200)},[]);b.useEffect(()=>{Le(kS),Le(H2),Le(gP);const ze=Ki.subscribe(Qi.CHAT.REFRESH_FROM_MESSAGE,Ee),Ze=Ki.subscribe(Qi.CHAT.NEW_MESSAGE,Ft=>{if(Ft&&typeof Ft=="object"&&Ft.action&&Ft.commit_id){console.log("ChatPanel: Received object message from eventBus:",Ft);const{action:ln,commit_id:$t,mode:Ve}=Ft;Ve==="chat"&&te(!1);let Rt="";ln==="review"&&(Rt=`/review commit=${$t}`),Rt&&K.current&&(K.current.setValue(Rt),X(!0))}else typeof Ft=="string"&&(console.log("ChatPanel: Received string message from eventBus:",Ft),K.current&&(K.current.setValue(Ft),X(!0)))}),lt=Ki.subscribe(Qi.RAG.ENABLED_CHANGED,Ft=>{console.log("ChatPanel: RAG enabled changed to",Ft),$e(Ft)}),St=Ki.subscribe(Qi.MCPS.ENABLED_CHANGED,Ft=>{console.log("ChatPanel: MCPs enabled changed to",Ft),Ce(Ft)}),kt=Ki.subscribe(Qi.CHAT.NEW_CHAT,A),qt=Ki.subscribe("agentic.mode.changed",Ft=>{console.log("ChatPanel: Step By Step mode changed to",Ft),l(Ft)});return()=>{kS.removeAllListeners(),H2.removeAllListeners(),gP.removeAllListeners(),ze(),Ze(),lt(),kt(),St(),qt()}},[Ee]);const Me=async()=>{var lt,St,kt;const ze=(St=(lt=K.current)==null?void 0:lt.getValue())==null?void 0:St.trim();if(!ze){yt.warning("Please enter a message");return}$&&v.length>0&&(await Ke($,v),console.log("Chat list saved before sending new message:",$));const Ze=Kt(ze);(kt=K.current)==null||kt.setValue(""),U(!0),ae(Ze,"sent");try{let qt=ze;if(c){console.log("ChatPanel: Rule mode enabled, accessing context prompt");try{const Ft=await fetch("/api/rules/context/prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:ze})});if(!Ft.ok)throw new Error(`Failed to get rule context prompt: ${Ft.statusText}`);const ln=await Ft.json();ln.prompt&&(qt=ln.prompt,console.log("ChatPanel: Received prompt from rules API"),_t(J("ruleModePromptGenerated")))}catch(Ft){console.error("Error fetching rule context prompt:",Ft),yt.error("获取Rule分析提示失败,将使用原始文本")}}if(Q||c)if(a){console.log("ChatPanel: Step By Step enabled, using agenticEditService");const Ft=await gP.executeCommand(qt,!0);console.log("ChatPanel: Received result from agenticEditService:",Ft),e(Ft.event_file_id),I(Ft.event_file_id)}else{console.log("ChatPanel: Sending message to codingService");const Ft=await H2.executeCommand(`${qt}`);console.log("ChatPanel: Received result from codingService:",Ft),e(Ft.event_file_id),I(Ft.event_file_id)}else{console.log("ChatPanel: Sending message to chatService");let Ft=qt;if(He&&Ne&&!Q){Gr.warning({title:J("ragMcpConflictTitle"),content:J("ragMcpConflictContent"),centered:!0}),U(!1);return}He&&!Ne&&!Q?(console.log("ChatPanel: RAG enabled, prepending /rag to message"),Ft=`/rag ${qt}`):Ne&&!He&&!Q&&(console.log("ChatPanel: MCPs enabled, prepending /mcp to message"),Ft=`/mcp ${qt}`);const ln=await kS.executeCommand(Ft);console.log("ChatPanel: Received result from chatService:",ln),e(ln.event_file_id),I(ln.event_file_id)}}catch(qt){console.error("Error sending message:",qt),yt.error("Failed to send message"),ae(Ze,"error"),_t(J("processingError")),U(!1)}},Ge=async()=>{try{Q?a?(console.log("ChatPanel: Stopping agentic edit task"),await gP.cancelTask()):(console.log("ChatPanel: Stopping coding task"),await H2.cancelTask()):(console.log("ChatPanel: Stopping chat task"),await kS.cancelTask()),yt.info(J("generationStopped")),U(!1)}catch(ze){console.error("Error stopping generation:",ze),yt.error("Failed to stop generation")}},ht=async()=>{const ze=document.getElementById("chat-messages-container");if(!ze){yt.error("未找到消息列表区域");return}const Ze=ze.style.height,lt=ze.style.maxHeight,St=ze.style.overflow;try{ze.style.height=ze.scrollHeight+"px",ze.style.maxHeight="none",ze.style.overflow="visible",await new Promise(ln=>requestAnimationFrame(ln));const qt=(await q$e(ze,{backgroundColor:"#1a1a1a",scale:2,useCORS:!0})).toDataURL("image/png"),Ft=document.createElement("a");Ft.href=qt,Ft.download=`chat_${new Date().toISOString().replace(/[:.]/g,"-")}.png`,Ft.click()}catch(kt){console.error("导出图片失败:",kt),yt.error("导出图片失败")}finally{ze.style.height=Ze,ze.style.maxHeight=lt,ze.style.overflow=St}},gt=async ze=>{Gr.confirm({title:"确认删除",content:`确定要删除对话 "${ze}" 吗?此操作不可撤销。`,okText:"删除",okType:"danger",cancelText:"取消",onOk:async()=>{await Qe(ze),yt.success("对话已删除")}})};return[J("newChat"),...O.length>0?[{type:"divider"}]:[],...O.map(ze=>({key:ze,label:x.jsxs("div",{className:`flex justify-between items-center w-full group ${$===ze?"bg-indigo-700/40 rounded-sm":""}`,children:[x.jsx("span",{className:`truncate max-w-[180px] ${$===ze?"text-white font-medium":"text-gray-200"}`,children:ze}),x.jsx(an,{type:"text",size:"small",className:"opacity-0 group-hover:opacity-100 transition-opacity text-white",icon:x.jsx(Ac,{}),onClick:Ze=>{Ze.stopPropagation(),gt(ze)}})]})}))],x.jsxs(x.Fragment,{children:[x.jsxs(bb,{className:"h-screen flex flex-col overflow-hidden",children:[x.jsxs(bb.Header,{className:"bg-gray-800 px-2 py-0.5 h-8 flex justify-between items-center border-b border-gray-700 shadow-sm transition-all duration-300 sticky top-0 z-10",children:[x.jsxs("div",{className:"flex items-center space-x-2 flex-1 min-w-0 overflow-hidden",children:[x.jsxs("div",{className:"flex items-center flex-shrink-0",children:[x.jsx("svg",{className:"w-3 h-3 mr-0.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z",stroke:"#8B5CF6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),x.jsx("span",{className:"bg-gradient-to-r from-indigo-500 to-purple-500 text-transparent bg-clip-text font-bold text-xs",children:"auto-coder.web"})]}),x.jsxs("div",{className:"flex items-center min-w-0 flex-1 overflow-hidden",children:[x.jsx("span",{className:"text-gray-400 text-xs mx-0.5",children:"|"}),x.jsx("div",{className:"flex items-center min-w-0 flex-1 overflow-hidden",children:x.jsx("span",{className:"text-gray-200 text-xs font-medium truncate",children:s||J("noProjectSelected")})})]})]}),x.jsxs("div",{className:"flex items-center space-x-1 flex-shrink-0",children:[x.jsx(l8t,{chatListName:$,chatLists:O,setChatListName:W,loadChatList:Ye,setCurrentSessionName:ut,showNewChatModal:g,deleteChatList:Qe,getChatTitle:nt,renameChatList:ct}),x.jsx(er,{title:"清空当前对话",children:x.jsx(an,{icon:x.jsx(uvt,{style:{fontSize:"10px"}}),onClick:()=>{$?Gr.confirm({title:"确认清空",content:"确定要清空当前对话中的所有消息吗?此操作不可撤销。",okText:"清空",okType:"danger",cancelText:"取消",onOk:async()=>{_([]),$&&(await Ke($,[]),yt.success("对话已清空"))}}):yt.warning("请先选择或创建一个对话")},className:"text-gray-300 border-gray-600 bg-gray-700 hover:bg-gray-600 px-1 py-0 h-6 w-6 flex items-center justify-center",size:"small"})}),x.jsx(er,{title:"保存当前对话",children:x.jsx(an,{icon:x.jsx(T5e,{style:{fontSize:"10px"}}),onClick:()=>{$&&v.length>0?(_e(!0),yt.success("对话已保存")):$?yt.warning("没有消息可保存"):yt.warning("请先选择或创建一个对话")},className:"text-gray-300 border-gray-600 bg-gray-700 hover:bg-gray-600 px-1 py-0 h-6 w-6 flex items-center justify-center",size:"small"})}),x.jsx(er,{title:"设置",children:x.jsx(an,{icon:x.jsx(bue,{style:{fontSize:"10px"}}),onClick:()=>E(!S),className:"text-gray-300 border-gray-600 bg-gray-700 hover:bg-gray-600 px-1 py-0 h-6 w-6 flex items-center justify-center",size:"small"})}),x.jsx(er,{title:"导出对话为图片",children:x.jsx(an,{icon:x.jsx(ybt,{style:{fontSize:"10px"}}),onClick:ht,className:"text-gray-300 border-gray-600 bg-gray-700 hover:bg-gray-600 px-1 py-0 h-6 w-6 flex items-center justify-center",size:"small"})})]})]}),x.jsxs(bb.Content,{className:"flex-1 overflow-hidden flex flex-col",children:[x.jsxs("div",{className:"flex-1 overflow-y-auto bg-gray-900 p-2 transition-all duration-300",id:"chat-messages-container",style:{backgroundImage:"radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.05) 1px, transparent 0)",backgroundSize:"20px 20px"},children:[v.length>0&&x.jsx("div",{className:"sticky top-0 right-0 float-right bg-gray-800/90 backdrop-blur-sm border border-gray-700 rounded-md p-2 m-1 shadow-md z-10",children:x.jsxs("div",{className:"font-mono text-xs text-gray-400 flex flex-col items-end gap-1 text-[11px]",children:[x.jsxs("div",{className:"flex items-center",children:[x.jsxs("span",{children:[J("tokens"),": "]}),x.jsxs("span",{className:"text-green-500 ml-1",children:["↑ ",We.inputTokens]}),x.jsxs("span",{className:"text-red-500 ml-1",children:["↓ ",We.outputTokens]})]}),(We.cacheHits>0||We.cacheMisses>0)&&x.jsxs("div",{className:"flex items-center",children:[x.jsxs("span",{children:[J("cache"),": "]}),x.jsxs("span",{className:"text-white ml-1",children:["⊕ ",We.cacheHits]}),x.jsxs("span",{className:"text-white ml-1",children:["→ ",We.cacheMisses]})]}),x.jsxs("div",{className:"flex items-center",children:[x.jsxs("span",{children:[J("apiCost"),": "]}),x.jsxs("span",{className:"text-white ml-1",children:["$",We.totalCost.toFixed(5)]})]})]})}),v.length===0?x.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400 animate-fade-in",children:[x.jsx(A3,{style:{fontSize:"36px",marginBottom:"10px",opacity:.5}}),x.jsx(Su.Title,{level:5,className:"text-gray-300 mb-1",children:"开始一个新的对话"}),x.jsx(Su.Text,{className:"text-gray-400 text-center max-w-md text-xs",children:"有任何问题都可以在下方输入,我会尽力帮助您。"})]}):x.jsx("div",{className:"space-y-4 animate-fade-in",children:x.jsx(V8e,{messages:ye(),onUserResponse:async(ze,Ze)=>{if(Ze&&Wt){const{requestId:lt,eventData:St}=Wt;await fetch("/api/event/response",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({request_id:lt,event:St,response:JSON.stringify({value:ze})})}),tn(null)}}})}),x.jsx("div",{ref:V}),!xe&&v.length>0&&x.jsx(an,{type:"primary",shape:"circle",size:"small",icon:x.jsx(FR,{}),onClick:()=>{var ze;(ze=V.current)==null||ze.scrollIntoView({behavior:"smooth"}),Ue(!0)},className:"fixed bottom-24 right-4 z-10 bg-indigo-600 hover:bg-indigo-700 border-0 shadow-lg flex items-center justify-center",style:{width:"36px",height:"36px"}})]}),x.jsx("div",{className:"border-t border-gray-700 bg-gray-800 transition-all duration-300 shadow-inner",children:x.jsx(o_n,{fileGroups:y,selectedGroups:T,setSelectedGroups:D,fetchFileGroups:Jt,isMaximized:Z,setIsMaximized:G,handleEditorDidMount:Ut,setShouldSendMessage:X,isWriteMode:Q,setIsWriteMode:te,isRuleMode:c,setIsRuleMode:d,handleRevert:ue,handleSendMessage:Me,handleStopGeneration:Ge,sendLoading:F,setConfig:R,isFullScreen:Z,showFileGroupSelect:!0,soundEnabled:u,setSoundEnabled:h})})]})]}),x.jsx(Gr,{title:x.jsx("span",{style:{color:"#FFFFFF"},children:"创建新对话"}),open:ce,onOk:p,onCancel:m,okText:"创建",cancelText:"取消",centered:!0,okButtonProps:{disabled:!be.trim(),style:{backgroundColor:"#8B5CF6",borderColor:"#8B5CF6"}},bodyStyle:{backgroundColor:"#1F2937",color:"#E5E7EB"},style:{top:20},className:"custom-modal",children:x.jsxs("div",{className:"mb-4",children:[x.jsx(Su.Text,{strong:!0,className:"block mb-2",style:{color:"#FFFFFF"},children:"对话名称"}),x.jsx(Xn,{value:be,onChange:ze=>ve(ze.target.value),placeholder:"请输入新对话的名称",onPressEnter:p,prefix:x.jsx(A3,{style:{color:"#8B5CF6"}}),autoFocus:!0,size:"large",style:{backgroundColor:"#374151",borderColor:"#4B5563",color:"#FFFFFF"}}),!be.trim()&&x.jsx(Su.Text,{type:"danger",className:"mt-1 block",children:"对话名称不能为空"})]})})]})};function rme(n){var i;if(!n)return"plaintext";const e=(i=n.split(".").pop())==null?void 0:i.toLowerCase(),t={ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",html:"html",htm:"html",css:"css",scss:"scss",less:"less",json:"json",xml:"xml",svg:"xml",py:"python",java:"java",c:"c",cpp:"cpp",h:"cpp",hpp:"cpp",cs:"csharp",go:"go",rs:"rust",php:"php",rb:"ruby",swift:"swift",kt:"kotlin",scala:"scala",sh:"shell",bash:"shell",zsh:"shell",fish:"shell",yml:"yaml",yaml:"yaml",toml:"toml",ini:"ini",conf:"plaintext",config:"plaintext",md:"markdown",markdown:"markdown",txt:"plaintext",sql:"sql",dockerfile:"dockerfile",dockerignore:"plaintext",gitignore:"plaintext",env:"plaintext"};return e?n.toLowerCase().endsWith("dockerfile")?"dockerfile":n.toLowerCase().endsWith("makefile")?"makefile":t[e]||"plaintext":"plaintext"}const m_n=({treeData:n,onSelect:e,onRefresh:t,projectName:i})=>{const[r,s]=b.useState(n),[o,a]=b.useState(null),[l,c]=b.useState(!1),[d,u]=b.useState(""),[h,f]=b.useState(!1),[g,m]=b.useState(!1),[p,A]=b.useState(""),[v,_]=b.useState(""),[y,C]=b.useState(!1),[S,E]=b.useState(""),[L,I]=b.useState("");b.useEffect(()=>{s(n),d&&$(d)},[n]);const T=async K=>{try{if(!(await fetch(`/api/files/${K.key}`,{method:"DELETE"})).ok)throw new Error("Failed to delete");yt.success(`Successfully deleted ${K.title}`),t()}catch(V){yt.error("Failed to delete file/directory"),console.error("Error:",V)}},D=({event:K,node:V})=>{K.preventDefault(),a(V)},B=async()=>{if(!p.trim())return;const K=v?`${v}/${p}`.replace(/\/\//g,"/"):p;try{const V=await fetch(`/api/file/${K}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:""})});if(!V.ok){const Q=await V.json();throw new Error(Q.detail||"Failed to create file")}yt.success(`Successfully created ${p}`),m(!1),A(""),t()}catch(V){console.error("Error creating file:",V),yt.error(V instanceof Error?V.message:"Failed to create file")}},R=async()=>{if(!S.trim())return;const K=L?`${L}/${S}`.replace(/\/\//g,"/"):S;try{const V=await fetch(`/api/directory/${K}`,{method:"POST"});if(!V.ok){const Q=await V.json();throw new Error(Q.detail||"Failed to create directory")}yt.success(`Successfully created directory ${S}`),C(!1),E(""),t()}catch(V){console.error("Error creating directory:",V),yt.error(V instanceof Error?V.message:"Failed to create directory")}},O=K=>{const V=K.toString().split(".");return V.length>1?V[V.length-1].toLowerCase():""},P=K=>!K.isLeaf,$=K=>{const V=K.toLowerCase();if(u(K),!V){s(n),f(!1);return}f(!0);const Q=G=>G.reduce((q,X)=>(X.isLeaf?q.push(X):X.children&&q.push(...Q(X.children)),q),[]),Z=Q(n).filter(G=>G.key.toString().toLowerCase().includes(V)).map(G=>{var q;return{...G,title:x.jsxs("div",{className:"file-node",children:[x.jsx("span",{className:`file-icon file file-${O(G.key.toString())}`,children:x.jsx(LE,{})}),x.jsx("span",{className:"file-name",children:(q=G.title)==null?void 0:q.toString()}),x.jsx("div",{className:"path-breadcrumb",children:G.key.toString()})]})}});s(Z)},W=()=>{const K=[];return o&&P(o)&&(K.push({key:"new-file",icon:x.jsx(Qye,{}),label:"New File",onClick:()=>{_(o.key.toString()),m(!0)}}),K.push({key:"new-directory",icon:x.jsx(qye,{}),label:"New Directory",onClick:()=>{I(o.key.toString()),C(!0)}})),K.push({key:"info",icon:x.jsx(I5e,{}),label:"File Info",onClick:()=>{o&&yt.info(`Path: ${o.key}`)}},{key:"copy",icon:x.jsx(vue,{}),label:"Copy Path",onClick:()=>{o&&(navigator.clipboard.writeText(o.key.toString()),yt.success("Path copied to clipboard"))}},{type:"divider"},{key:"delete",icon:x.jsx(Ac,{}),label:"Delete",danger:!0,onClick:()=>{o&&Gr.confirm({title:"Delete Confirmation",content:`Are you sure you want to delete ${o.title}?`,okText:"Yes",okType:"danger",cancelText:"No",onOk(){T(o)}})}}),K},j=async()=>{if(!l){c(!0);try{await t(),yt.success("Refreshed file tree successfully")}catch(K){yt.error("Failed to refresh file tree"),console.error("Error refreshing file tree:",K)}finally{c(!1)}}},H=K=>{var se;const V=((se=K.title)==null?void 0:se.toString())||"",Q=!K.isLeaf,te=O(V);return x.jsxs("div",{className:"file-node",children:[x.jsx("span",{className:`file-icon ${Q?"folder":`file file-${te}`}`,children:Q?x.jsx(m3,{}):x.jsx(LE,{})}),x.jsx("span",{className:"file-name",children:V})]})},F=K=>K.map(V=>{const Q={...V,title:H(V)};return V.children&&(Q.children=F(V.children)),Q}),U=Se.useMemo(()=>h?r:F(r),[r,h]);return x.jsxs("div",{className:"file-tree-container",children:[x.jsx(Gr,{title:v?`Create New File in ${v}`:"Create New File in Root Directory",open:g,onOk:B,onCancel:()=>{m(!1),A(""),_("")},okButtonProps:{disabled:!p.trim()},className:"vscode-dark-modal",children:x.jsx(Rn,{layout:"vertical",children:x.jsx(Rn.Item,{label:"File Name",required:!0,help:"Enter the file name with extension (e.g., example.js)",children:x.jsx(Xn,{value:p,onChange:K=>A(K.target.value),placeholder:"Enter file name",autoFocus:!0})})})}),x.jsx(Gr,{title:L?`Create New Directory in ${L}`:"Create New Directory in Root",open:y,onOk:R,onCancel:()=>{C(!1),E(""),I("")},okButtonProps:{disabled:!S.trim()},className:"vscode-dark-modal",children:x.jsx(Rn,{layout:"vertical",children:x.jsx(Rn.Item,{label:"Directory Name",required:!0,help:"Enter the directory name",children:x.jsx(Xn,{value:S,onChange:K=>E(K.target.value),placeholder:"Enter directory name",autoFocus:!0})})})}),x.jsxs("div",{className:"file-tree-header",children:[x.jsx("div",{className:"file-tree-header-title",children:i||"Project Files"}),x.jsxs("div",{className:"file-tree-actions",children:[x.jsx(er,{title:"New File",children:x.jsx("button",{onClick:()=>{_(""),m(!0)},className:"action-button","aria-label":"Create new file",children:x.jsx(Qye,{})})}),x.jsx(er,{title:"New Directory",children:x.jsx("button",{onClick:()=>{I(""),C(!0)},className:"action-button","aria-label":"Create new directory",children:x.jsx(qye,{})})}),x.jsx(er,{title:"Refresh",children:x.jsx("button",{onClick:j,className:"action-button","aria-label":"Refresh file tree",children:l?x.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[x.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),x.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):x.jsx(n_,{})})})]})]}),x.jsx("div",{className:"file-tree-search",children:x.jsx(Xn,{prefix:x.jsx(jC,{className:"text-gray-400"}),placeholder:"Search files...",className:"custom-input",allowClear:!0,value:d,onChange:K=>$(K.target.value)})}),x.jsx("div",{className:"file-tree-content",children:n.length===0?x.jsxs("div",{className:"empty-state",children:[x.jsx("div",{className:"empty-state-icon",children:x.jsx(m3,{})}),x.jsx("div",{className:"empty-state-text",children:"No files found"})]}):U.length===0&&h?x.jsxs("div",{className:"empty-state",children:[x.jsx("div",{className:"empty-state-icon",children:x.jsx(jC,{})}),x.jsx("div",{className:"empty-state-text",children:"No matching files found"})]}):x.jsx(P1,{menu:{items:W()},trigger:["contextMenu"],overlayClassName:"vscode-dark-dropdown",children:x.jsx("div",{className:"file-tree",children:x.jsx(QR,{showIcon:!1,defaultExpandAll:!0,onSelect:e,onRightClick:D,treeData:U,height:999999})})})})]})};M_.config({paths:{vs:"/monaco-editor/min/vs"},"vs/nls":{availableLanguages:{"*":"zh-cn"}}});const A_n=n=>{n.editor.defineTheme("customVsDarkTheme",{base:"vs-dark",inherit:!0,rules:[{token:"comment",foreground:"6A9955",fontStyle:"italic"},{token:"keyword",foreground:"569CD6"},{token:"string",foreground:"CE9178"},{token:"number",foreground:"B5CEA8"},{token:"regexp",foreground:"D16969"},{token:"operator",foreground:"D4D4D4"},{token:"namespace",foreground:"4EC9B0"},{token:"type.identifier",foreground:"4EC9B0"},{token:"function",foreground:"DCDCAA"},{token:"variable",foreground:"9CDCFE"},{token:"variable.predefined",foreground:"4FC1FF"},{token:"class",foreground:"4EC9B0"},{token:"interface",foreground:"4EC9B0"},{token:"enum",foreground:"4EC9B0"}],colors:{"editor.foreground":"#D4D4D4","editor.background":"#1E1E1E","editorCursor.foreground":"#AEAFAD","editor.lineHighlightBackground":"#2D2D30","editorLineNumber.foreground":"#858585","editor.selectionBackground":"#264F78","editor.inactiveSelectionBackground":"#3A3D41"}})},nGe=({code:n,language:e,onChange:t})=>{const i=b.useRef(null),r=b.useRef(null),[s,o]=b.useState(!1),a=()=>{if(!(!e||e==="plaintext"||!r.current)){console.log(`Attempting to load language support for: ${e}`);try{if(r.current.languages.getLanguages().some(f=>f.id===e||f.aliases&&f.aliases.includes(e))){if(console.log(`Language ${e} is already supported`),i.current){const f=i.current.getModel();f&&(r.current.editor.setModelLanguage(f,e),console.log(`Explicitly set model language to: ${e}`),setTimeout(()=>{i.current.updateOptions({})},100))}return}const h=document.createElement("script");h.src=`/monaco-editor/min/vs/basic-languages/${e}/${e}.js`,h.async=!0,h.onload=()=>{if(console.log(`Language support loaded for: ${e}`),i.current){const f=i.current.getModel();f&&(r.current.editor.setModelLanguage(f,e),setTimeout(()=>{i.current.updateOptions({})},100))}},h.onerror=f=>{console.warn(`Failed to load language support for ${e}:`,f)},document.body.appendChild(h)}catch(d){console.error("Error loading language support:",d)}}};b.useEffect(()=>{s&&a()},[e,s]);const l=d=>{console.log("Monaco editor will mount"),r.current=d,A_n(d),d.languages.typescript.typescriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0}),d.languages.typescript.javascriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0}),d.languages.onLanguage("*",()=>{d.languages.setLanguageConfiguration("*",{wordPattern:/(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g})})},c=(d,u)=>{console.log("Monaco editor did mount"),i.current=d,r.current=u,o(!0);const h=d.getModel();h&&e&&u.editor.setModelLanguage(h,e),a(),d.updateOptions({minimap:{enabled:!0},fontSize:14,lineNumbers:"on",folding:!0,automaticLayout:!0,renderWhitespace:"selection",wordWrap:"on",scrollbar:{vertical:"visible",horizontal:"visible",verticalScrollbarSize:10,horizontalScrollbarSize:10,verticalSliderSize:10,horizontalSliderSize:10,arrowSize:30},suggestOnTriggerCharacters:!0,acceptSuggestionOnEnter:"on",tabCompletion:"on",wordBasedSuggestions:"currentDocument",parameterHints:{enabled:!0,cycle:!0},bracketPairColorization:{enabled:!0},guides:{indentation:!0,bracketPairs:!0}})};return x.jsx("div",{className:"monaco-editor-container",children:x.jsx(O7,{height:"100%",defaultLanguage:"plaintext",language:e,theme:"customVsDarkTheme",value:n,onChange:t,beforeMount:l,onMount:c,loading:x.jsx("div",{className:"loading",children:"Loading editor..."}),options:{fontLigatures:!0,contextmenu:!0,fixedOverflowWidgets:!0,colorDecorators:!0,formatOnType:!1,formatOnPaste:!1,parameterHints:{enabled:!1}}})})},v_n=({selectedFiles:n})=>{const[e,t]=b.useState(n||[]),[i,r]=b.useState(null),[s,o]=b.useState([]),[a,l]=b.useState([]),[c,d]=b.useState(!1);b.useEffect(()=>{if(s.length>0){const y=s.map(C=>({path:C.key,isSelected:C.key===i,label:C.label}));Ki.publish(Qi.EDITOR.TABS_CHANGED,y)}},[s,i]),b.useEffect(()=>{n&&(t(n),n.forEach(y=>{u(y.path)}),n.length>0&&r(n[0].path))},[n]),b.useEffect(()=>{h()},[]);const u=async y=>{try{const C=await fetch(`/api/file/${y}`);if(!C.ok)throw new Error("Failed to fetch file content");const S=await C.json();o(E=>E.find(I=>I.key===y)?E.map(I=>I.key===y?{...I,content:S.content}:I):[...E,{key:y,label:y.split("/").pop()||y,content:S.content}])}catch(C){console.error("Error fetching file content:",C),yt.error(`Failed to load ${y}`)}},h=async()=>{try{const y=await fetch("/api/files");if(!y.ok)throw new Error("Failed to fetch file tree");const C=await y.json(),S=L=>{const I=L.isLeaf;return{title:L.title,key:L.key,icon:I?"file":"folder",children:L.children?L.children.map(S):void 0,isLeaf:I}},E=C.tree.map(S);l(E)}catch(y){console.error("Error fetching file tree:",y)}},f=async()=>{if(!(!i||c))try{d(!0);const y=s.find(S=>S.key===i);if(!y)return;if(!(await fetch(`/api/file/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:y.content})})).ok)throw new Error("Failed to save file");yt.success("File saved successfully")}catch(y){console.error("Error saving file:",y),yt.error("Failed to save file")}finally{d(!1)}},g=async(y,C)=>{const S=y[0];if(S&&C.node.isLeaf){const E={path:S,isSelected:!0};e.some(L=>L.path===S)||t(L=>[...L,E]),r(S),u(S)}},m=y=>{r(y)},p=(y,C)=>{typeof y=="string"&&C==="remove"&&(o(S=>S.filter(E=>E.key!==y)),t(S=>S.filter(E=>E.path!==y)),i===y&&s.length>0&&r(s[0].key))},A=y=>{navigator.clipboard.writeText(y).then(()=>{yt.success("File path copied to clipboard")}).catch(C=>{console.error("Failed to copy file path: ",C),yt.error("Failed to copy file path")})},v=y=>{o(C=>C.filter(S=>S.key===y)),t(C=>C.filter(S=>S.path===y)),i!==y&&r(y)},_=(y,C)=>x.jsxs(Yo,{children:[x.jsx(Yo.Item,{onClick:()=>A(y),children:J("codeEditor.copyPath")},"copyPath"),x.jsx(Yo.Item,{onClick:()=>v(y),children:J("codeEditor.closeOtherTabs")},"closeOthers")]});return x.jsxs("div",{className:"code-editor-container",children:[x.jsx("div",{className:"code-editor-header",children:x.jsxs("div",{className:"code-editor-header-content",children:[x.jsx("div",{className:"file-info",children:x.jsx("span",{className:"file-path",children:i||"No file selected"})}),i&&x.jsxs("button",{onClick:f,disabled:!i,className:"save-button",children:[x.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-3m-1 4l-3 3m0 0l-3-3m3 3V4"})}),"Save"]})]})}),x.jsxs(DE,{className:"code-editor-content",sizes:[20,80],minSize:100,expandToMin:!1,gutterSize:10,gutterAlign:"center",snapOffset:30,dragInterval:1,direction:"horizontal",children:[x.jsx("div",{className:"file-tree-panel",children:x.jsx(m_n,{treeData:a,onSelect:g,onRefresh:h})}),x.jsx("div",{className:"editor-panel",children:x.jsx(Sp,{type:"editable-card",onChange:m,onEdit:p,activeKey:i||void 0,children:s.map(y=>{const C=e.find(S=>S.path===y.key);return x.jsx(Sp.TabPane,{tab:x.jsx(P1,{overlay:_(y.key,y.label),trigger:["contextMenu"],overlayClassName:"vscode-dark-dropdown",children:x.jsx("span",{style:{color:(C==null?void 0:C.modifiedBy)==="expert_chat_box"?"#ff4d4f":"inherit",display:"inline-block"},children:y.label})}),closable:!0,children:x.jsx(nGe,{code:y.content,language:rme(y.key),onChange:S=>{o(E=>E.map(L=>L.key===y.key?{...L,content:S||""}:L))}})},y.key)})})})]})]})},b_n=({selectedFiles:n})=>x.jsx(v_n,{selectedFiles:n});function __n(n,e){const t=b.useRef(null),i=(...r)=>{t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{n(...r)},e)};return Se.useEffect(()=>()=>{t.current&&clearTimeout(t.current)},[]),i}const y_n={js:"#f7df1e",jsx:"#61dafb",ts:"#3178c6",tsx:"#3178c6",css:"#264de4",scss:"#cc6699",html:"#e34c26",json:"#8bc34a",md:"#42a5f5",py:"#3572A5",java:"#b07219",go:"#00ADD8",rs:"#dea584",c:"#555555",cpp:"#f34b7d",sh:"#89e051"},C_n=n=>{var t;const e=((t=n.split(".").pop())==null?void 0:t.toLowerCase())||"";return y_n[e]||"#9ca3af"},w_n=n=>!n.isLeaf,S_n=n=>{const e=[],t=i=>{i.isLeaf?e.push(i.key):i.children&&i.children.forEach(t)};return n.forEach(t),e},x_n=({treeData:n,checkedKeys:e,onCheckedKeysChange:t,onFileSelect:i,onAddFiles:r,selectedGroup:s,onRefreshTree:o})=>{const[a,l]=b.useState(n),[c,d]=b.useState(!1),[u,h]=b.useState(""),[f,g]=b.useState([]),[m,p]=b.useState(null),[A,v]=b.useState(!1),[_,y]=b.useState({x:0,y:0}),C=b.useRef(null),[S,E]=b.useState(!0),[L,I]=b.useState(!1),[T,D]=b.useState([]),[B,R]=b.useState(!0),O=__n(G=>{P(G)},500);b.useEffect(()=>{l(n);const G=new Set,q=X=>{X.forEach(ie=>{var oe;if(ie.isLeaf){const Ae=(oe=ie.key.split(".").pop())==null?void 0:oe.toLowerCase();Ae&&G.add(Ae)}ie.children&&q(ie.children)})};q(n),D(Array.from(G))},[n]);const P=(G,q=n)=>{const X=G.toLowerCase();if(!X){l(q);return}const ie=Ae=>Ae.map(be=>{var Ue;const ve={...be};typeof be.title=="string"&&be.title;const xe=be.key.toString();return(Ue=be.children)!=null&&Ue.length?(ve.children=ie(be.children),ve.children.length>0||xe.toLowerCase().includes(X)?ve:null):xe.toLowerCase().includes(X)?ve:null}).filter(Boolean),oe=ie(q);l(oe);const ce=(Ae,be=[])=>(Ae.forEach(ve=>{var Ue;if(!w_n(ve))return;((Ue=ve.children)==null?void 0:Ue.some(He=>He.key.toString().toLowerCase().includes(X)))&&be.push(ve.key.toString()),ve.children&&ce(ve.children,be)}),be);g(ce(q))},$=G=>G.map(q=>{const X=q.isLeaf,ie=q.key.toString();let oe;if(X){const xe=C_n(ie);oe=x.jsx(LE,{className:"file-icon",style:{color:xe}})}else oe=f.includes(ie)?x.jsx(Ste,{className:"file-icon folder-icon"}):x.jsx(m3,{className:"file-icon folder-icon"});const ce=ie.split("/"),Ae=ce[ce.length-1],be=()=>{if(!u)return Ae;const xe=Ae.toLowerCase().indexOf(u.toLowerCase());if(xe===-1)return Ae;const Ue=Ae.substring(0,xe),He=Ae.substring(xe,xe+u.length),$e=Ae.substring(xe+u.length);return x.jsxs("span",{children:[Ue,x.jsx("span",{className:"search-highlight",children:He}),$e]})},ve={...q,title:x.jsxs("span",{className:"file-node-title",title:ie,children:[oe,x.jsx("span",{className:"file-name",children:be()})]})};return q.children&&(ve.children=$(q.children)),ve}),W=$(a),j=(G,q)=>{G.preventDefault(),G.stopPropagation(),p(q),v(!0),y({x:G.clientX,y:G.clientY})},H=()=>{if(!m)return null;const G=!m.isLeaf,q=m.key.toString();return x.jsxs(Yo,{className:"file-context-menu",onClick:({key:X})=>F(X,q,G),children:[G?x.jsxs(x.Fragment,{children:[x.jsx(Yo.Item,{icon:x.jsx(Ste,{}),children:f.includes(q)?"Collapse":"Expand"},"expand"),x.jsx(Yo.Item,{icon:x.jsx(Ab,{}),children:"Select All Files Inside"},"selectAll"),x.jsx(Yo.Divider,{})]}):x.jsxs(x.Fragment,{children:[x.jsx(Yo.Item,{icon:x.jsx(Ab,{}),children:e.includes(q)?"Deselect":"Select"},"select"),x.jsx(Yo.Item,{icon:x.jsx(LE,{}),children:"Preview File"},"preview"),x.jsx(Yo.Divider,{})]}),x.jsx(Yo.Item,{icon:x.jsx(vue,{}),children:"Copy Path"},"copy"),s&&!G&&x.jsxs(Yo.Item,{icon:x.jsx(Pa,{}),disabled:!s,children:["Add to ",s.name]},"add")]})},F=(G,q,X)=>{switch(v(!1),G){case"expand":f.includes(q)?g(f.filter(ie=>ie!==q)):g([...f,q]);break;case"selectAll":if(X){const ie=V(q,n),oe=Array.from(new Set([...e,...ie]));t(oe)}break;case"select":e.includes(q)?t(e.filter(ie=>ie!==q)):t([...e,q]);break;case"preview":i==null||i(q);break;case"copy":navigator.clipboard.writeText(q).then(()=>yt.success("Path copied to clipboard")).catch(()=>yt.error("Failed to copy path"));break;case"add":if(s&&r){const ie=[];if(X){const oe=V(q,n);ie.push(...oe)}else ie.push(q);console.log("Files to add from context menu:",ie),t(ie),setTimeout(()=>{r()},100)}break}},U=G=>{if(!S||!s)return;G.node.key;const q=G.dragNode.key;!G.dragNode.isLeaf&&G.node.isLeaf||G.dragNode.isLeaf&&(e.includes(q)||(t([...e,q]),yt.success("File added to selection")))},K=(G,q)=>{let ie=(Array.isArray(G)?G:G.checked).filter(oe=>{const ce=(Ae,be)=>{for(const ve of Ae){if(ve.key===be)return!!ve.isLeaf;if(ve.children&&ce(ve.children,be))return!0}return!1};return ce(n,oe)});console.log("Processed checked keys:",ie),t(ie)},V=(G,q)=>{const X=[],ie=Ae=>Ae.replace(/\\/g,"/"),oe=ie(G);return((Ae,be)=>{const ve=(Ue,He)=>{const $e=ie(Ue);for(const Ne of He){if(ie(Ne.key.toString())===$e)return Ne;if(Ne.children){const Ie=ve(Ue,Ne.children);if(Ie)return Ie}}return null},xe=ve(Ae,be);if(xe&&xe.children){const Ue=He=>{He.isLeaf?X.push(He.key.toString()):He.children&&He.children.forEach(Ue)};xe.children.forEach(Ue)}})(oe,q),X},Q=()=>e.length,te=()=>S_n(a),se=()=>{const G=te();if(B)t(G),yt.success(`已选择 ${G.length} 个文件`);else{const q=G.filter(X=>!e.includes(X));t(q),yt.success(`已反选 ${q.length} 个文件`)}R(!B)},Z=()=>x.jsx(Yo,{className:"file-type-filter-menu",children:x.jsx(Yo.ItemGroup,{title:"Filter by File Type",children:T.map(G=>x.jsx(Yo.Item,{children:x.jsx(yA,{children:G})},G))})});return x.jsxs("div",{className:"file-directory-selector",children:[x.jsxs("div",{className:"search-container",children:[x.jsxs("div",{className:"search-header",style:{display:"flex",gap:"8px",alignItems:"center"},children:[x.jsx(Xn,{prefix:x.jsx(jC,{className:"text-gray-400"}),placeholder:"Search files...",className:"search-input",value:u,onChange:G=>{const q=G.target.value;h(q),O(q)},suffix:x.jsx(P1,{overlay:Z(),trigger:["click"],open:L,onOpenChange:I,children:x.jsx(qvt,{className:"filter-icon"})})}),o&&x.jsx(er,{title:"刷新目录树",children:x.jsx(an,{icon:c?x.jsx(Yye,{spin:!0,style:{transition:"transform 0.3s"}}):x.jsx(Yye,{}),loading:c,onClick:async()=>{try{d(!0),await o(),h(""),P("")}finally{d(!1)}},className:"refresh-tree-button"})})]}),s&&x.jsxs("div",{className:"action-buttons",children:[x.jsxs(an,{type:"primary",onClick:r,disabled:e.length===0,icon:x.jsx(Pa,{}),className:"add-button",block:!0,children:["Add Selected (",Q(),")"]}),x.jsx(er,{title:B?"全选当前可见文件":"反选当前可见文件",children:x.jsx(an,{onClick:se,icon:B?x.jsx(Ab,{}):x.jsx(Tpt,{}),className:`selection-toggle-button ${B?"select-all-mode":"invert-mode"}`})})]})]}),x.jsxs("div",{className:"file-tree-container",children:[x.jsx(QR,{ref:C,checkable:!0,treeData:W,checkedKeys:e,expandedKeys:f,onExpand:g,onCheck:K,onSelect:(G,q)=>{const X=q.node;X.isLeaf&&i&&i(X.key)},onRightClick:({event:G,node:q})=>j(G,q),onDoubleClick:(G,q)=>{q.isLeaf&&i&&i(q.key)},draggable:S,onDrop:U,className:"custom-dark-tree",showIcon:!1,showLine:{showLeafIcon:!1},blockNode:!0,autoExpandParent:!1,virtual:!1}),A&&x.jsx("div",{className:"context-menu-wrapper",style:{position:"fixed",top:_.y,left:_.x},children:H()})]})]})},E_n=({selectedGroup:n,onFileSelect:e,onRemoveFile:t,onUpdateDescription:i,onAddExternalFile:r})=>{const[s,o]=b.useState(!1),[a,l]=b.useState("");return n?x.jsxs("div",{className:"space-y-4",children:[x.jsxs("div",{className:"space-y-4",children:[x.jsxs("div",{className:"flex justify-between items-center",children:[x.jsx("h3",{className:"text-white font-medium text-lg",children:n.name}),x.jsx(an,{type:"primary",size:"small",className:"bg-blue-600 hover:bg-blue-700 border-none",icon:s?x.jsx(T5e,{}):x.jsx(Bu,{}),onClick:async()=>{if(s)try{await i(n.name,a),yt.success("Description updated successfully")}catch{yt.error("Failed to update description")}else l(n.description||"");o(!s)},children:s?"Save Description":"Edit Description"})]}),s?x.jsx("div",{className:"h-48",children:x.jsx(O7,{height:"100%",defaultLanguage:"markdown",theme:"vs-dark",value:a,onChange:c=>l(c||""),options:{minimap:{enabled:!1},fontSize:14,lineNumbers:"off",wordWrap:"on",automaticLayout:!0}})}):x.jsx("p",{className:"text-gray-400 text-sm",children:n.description||"No description"})]}),x.jsxs("div",{children:[x.jsxs("div",{className:"flex justify-between items-center mb-2",children:[x.jsxs("h4",{className:"text-white font-medium",children:["Files (",n.files.length,")"]}),x.jsx(an,{type:"primary",size:"small",icon:x.jsx(Pa,{}),onClick:r,className:"bg-blue-600 hover:bg-blue-700 border-none",children:"Add External File"})]}),n.files.length===0?x.jsx("div",{className:"empty-files-container",children:x.jsx(So,{description:x.jsx("span",{className:"text-gray-400",children:"No files added yet"}),image:So.PRESENTED_IMAGE_SIMPLE,className:"custom-empty-state"})}):x.jsx(od,{dataSource:n.files.map(c=>({path:c})),rowKey:"path",showHeader:!1,columns:[{title:"Path",dataIndex:"path",key:"path",render:c=>{const d=c.split("/").pop();return x.jsx("span",{className:"text-gray-300 cursor-pointer hover:text-blue-400",title:c,onDoubleClick:u=>{u.stopPropagation(),e(c)},children:d})}},{title:"Action",key:"action",width:40,render:(c,{path:d})=>x.jsx(Ac,{className:"text-red-400 cursor-pointer hover:text-red-500",onClick:u=>{u.stopPropagation(),t(n.name,d)}})}],pagination:!1,size:"small",className:"dark-mode-table",locale:{emptyText:x.jsx("div",{className:"py-4",children:x.jsx(So,{description:x.jsx("span",{className:"text-gray-400",children:"No files in this group"}),image:So.PRESENTED_IMAGE_SIMPLE,className:"custom-empty-state"})})}})]})]}):x.jsx("div",{className:"text-gray-400 text-center mt-4",children:"Select a group to view details"})},k_n=()=>{const[n,e]=b.useState([]),[t,i]=b.useState(null),[r,s]=b.useState(null),[o,a]=b.useState(""),[l,c]=b.useState([]),[d,u]=b.useState([]),[h,f]=b.useState([]),[g,m]=b.useState(!1),[p,A]=b.useState(""),[v,_]=b.useState(""),[y,C]=b.useState(!1),[S,E]=b.useState(!1),[L,I]=b.useState(100),[T,D]=b.useState(10),[B,R]=b.useState(!1),[O,P]=b.useState([]),[$,W]=b.useState(!1),[j,H]=b.useState(!1),[F,U]=b.useState(""),K=async()=>{try{const q=await fetch("/api/file-groups");if(!q.ok)throw new Error("Failed to fetch file groups");const X=await q.json();e(X.groups)}catch{yt.error("Failed to load file groups")}},V=async()=>{try{const q=await fetch("/api/files");if(!q.ok)throw new Error("Failed to fetch file tree");const X=await q.json();c(X.tree),u(X.tree)}catch{yt.error("Failed to load file tree")}};b.useEffect(()=>{K(),V()},[]);const Q=async()=>{try{if(!(await fetch("/api/file-groups",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:p,description:v})})).ok)throw new Error("Failed to create group");yt.success("Group created successfully"),m(!1),A(""),_(""),K()}catch{yt.error("Failed to create group")}},te=async q=>{try{if(!(await fetch(`/api/file-groups/${q}`,{method:"DELETE"})).ok)throw new Error("Failed to delete group");yt.success("Group deleted successfully"),K(),(t==null?void 0:t.name)===q&&i(null)}catch{yt.error("Failed to delete group")}},se=async()=>{if(!(!t||h.length===0))try{const q=await fetch(`/api/file-groups/${t.name}/files`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:h})});if(!q.ok)throw new Error("Failed to add files");if(yt.success("Files added successfully"),K(),f([]),q.ok&&(K(),t)){const ie=(await(await fetch("/api/file-groups")).json()).groups.find(oe=>oe.name===t.name);ie&&i(ie)}}catch{yt.error("Failed to add files")}},Z=async(q,X)=>{try{if(!(await fetch(`/api/file-groups/${q}/files`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[X]})})).ok)throw new Error("Failed to remove file");if(yt.success("File removed successfully"),K(),t){const ce=(await(await fetch("/api/file-groups")).json()).groups.find(Ae=>Ae.name===t.name);ce&&i(ce)}}catch{yt.error("Failed to remove file")}},G=async q=>{try{const X=await fetch(`/api/file/${q}`);if(!X.ok)throw new Error("Failed to fetch file content");const ie=await X.json();s(q),a(ie.content)}catch{yt.error("Failed to load file content")}};return x.jsxs("div",{className:"flex flex-col",style:{height:"650px"},children:[x.jsx("div",{className:"bg-gray-800 p-2 border-b border-gray-700",children:x.jsx("div",{className:"flex justify-between items-center",children:x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("h2",{className:"text-white text-lg font-semibold",children:"File Groups"}),x.jsx("div",{className:"flex gap-2",children:x.jsx(an,{type:"primary",icon:x.jsx(Pa,{}),onClick:()=>m(!0),className:"bg-blue-600 hover:bg-blue-700 border-none"})})]})})}),x.jsx("div",{className:"flex-1 overflow-hidden",children:x.jsxs("div",{className:"h-full flex",children:[x.jsx("div",{className:"w-60 bg-gray-900 border-r border-gray-700 overflow-y-auto p-4",children:x.jsx(od,{dataSource:n,rowKey:"name",rowClassName:q=>q.name===(t==null?void 0:t.name)?"bg-blue-600":"bg-transparent",onRow:q=>({onClick:()=>i(q),className:"cursor-pointer hover:bg-gray-800"}),className:"dark-mode-table",size:"small",pagination:!1,columns:[{title:"Group",dataIndex:"name",key:"name",render:(q,X)=>x.jsxs("div",{className:"flex justify-between items-center",children:[x.jsx("span",{className:"text-white font-medium",children:q}),x.jsx("span",{className:"text-gray-500 text-xs",children:X.files.length})]})},{title:"Action",key:"action",width:40,render:(q,X)=>x.jsx(an,{type:"text",danger:!0,icon:x.jsx(Ac,{}),onClick:ie=>{ie.stopPropagation(),te(X.name)}})}],locale:{emptyText:x.jsx("div",{className:"py-4",children:x.jsx(So,{description:x.jsx("span",{className:"text-gray-400",children:"No file groups yet"}),image:So.PRESENTED_IMAGE_SIMPLE,className:"custom-empty-state"})})}})}),x.jsx("div",{className:"w-80 bg-gray-900 border-r border-gray-700 overflow-y-auto p-4",children:x.jsx(E_n,{selectedGroup:t,onFileSelect:G,onRemoveFile:Z,onUpdateDescription:async(q,X)=>{try{if(!(await fetch(`/api/file-groups/${q}/files`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:X})})).ok)throw new Error("Failed to update description");return t&&(t.description=X),Promise.resolve()}catch(ie){return Promise.reject(ie)}},onAddExternalFile:()=>H(!0)})}),x.jsx("div",{className:"min-w-[16rem] max-w-[16rem] bg-gray-900 border-r border-gray-700 overflow-hidden",children:x.jsx("div",{className:"h-full w-full overflow-x-auto overflow-y-auto",children:x.jsx(x_n,{treeData:l,checkedKeys:h,onCheckedKeysChange:f,onFileSelect:G,onAddFiles:se,selectedGroup:t,onRefreshTree:V})})}),x.jsx("div",{className:"flex-1 bg-gray-900",children:r?x.jsx(O7,{height:"100%",defaultLanguage:"plaintext",language:rme(r||""),theme:"vs-dark",value:o,options:{readOnly:!0,minimap:{enabled:!0},fontSize:14,lineNumbers:"on",folding:!0,automaticLayout:!0}}):x.jsx("div",{className:"h-full flex items-center justify-center",children:x.jsx(So,{description:x.jsx("span",{className:"text-gray-400",children:"Select a file to preview"}),image:So.PRESENTED_IMAGE_SIMPLE,className:"custom-empty-state"})})})]})}),x.jsx(Gr,{title:"Add External File",open:j,className:"dark-theme-modal",styles:{content:{backgroundColor:"#1f2937",padding:"20px"},header:{backgroundColor:"#1f2937",borderBottom:"1px solid #374151"},body:{backgroundColor:"#1f2937"},mask:{backgroundColor:"rgba(0, 0, 0, 0.6)"}},onOk:async()=>{if(!t||!F.trim())return;const q=F.trim(),X=q.startsWith("http://")||q.startsWith("https://");try{let ie=[];if(X)ie=[q];else{const Ae=encodeURIComponent(q),be=await fetch(`/api/list-files?dir_path=${Ae}`);if(!be.ok)throw new Error("Failed to list files");const ve=await be.json();if(Array.isArray(ve))ie=ve.map(xe=>xe.path);else{yt.error("Unexpected response from list-files API");return}}await fetch(`/api/file-groups/${t.name}/files`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:ie})}),yt.success("External file(s) added successfully"),H(!1),U(""),K();const ce=(await(await fetch("/api/file-groups")).json()).groups.find(Ae=>Ae.name===t.name);ce&&i(ce)}catch(ie){console.error(ie),yt.error("Failed to add external file(s)")}},onCancel:()=>{H(!1),U("")},okButtonProps:{disabled:!F.trim()},children:x.jsx("div",{className:"space-y-4",children:x.jsxs("div",{children:[x.jsx("label",{className:"block text-sm font-medium text-gray-200 mb-2",children:"File Path or URL"}),x.jsx(Xn,{value:F,onChange:q=>U(q.target.value),placeholder:"Enter full file path or URL (e.g., /absolute/path/to/file or https://example.com/file)",className:"bg-gray-800 border-gray-700 text-gray-200"})]})})}),x.jsx(Gr,{title:"Create New Group",open:g,onOk:Q,onCancel:()=>m(!1),okButtonProps:{disabled:!p.trim()},className:"dark-theme-modal",styles:{content:{backgroundColor:"#1f2937",padding:"20px"},header:{backgroundColor:"#1f2937",borderBottom:"1px solid #374151"},body:{backgroundColor:"#1f2937"},mask:{backgroundColor:"rgba(0, 0, 0, 0.6)"}},children:x.jsxs("div",{className:"space-y-4",children:[x.jsxs("div",{children:[x.jsx("label",{className:"block text-sm font-medium text-gray-200 mb-2",children:"Group Name"}),x.jsx(Xn,{value:p,onChange:q=>A(q.target.value),placeholder:"Enter group name",className:"bg-gray-800 border-gray-700 text-gray-200"})]}),x.jsxs("div",{children:[x.jsx("label",{className:"block text-sm font-medium text-gray-200 mb-2",children:"Description"}),x.jsx(Xn.TextArea,{value:v,onChange:q=>_(q.target.value),placeholder:"Enter group description",rows:4,className:"bg-gray-800 border-gray-700 text-gray-200"})]})]})}),x.jsx(Gr,{title:"Auto Create Groups",open:y,onOk:async()=>{E(!0);try{const q=await fetch("/api/file-groups/auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_size_limit:L,group_num_limit:T,skip_diff:B})});if(!q.ok)throw new Error("Failed to auto create groups");const X=await q.json();X.groups&&Array.isArray(X.groups)&&(P(X.groups.map(ie=>({...ie,selected:!0}))),W(!0)),await K(),C(!1)}catch{yt.error("Failed to create groups automatically")}finally{E(!1)}},onCancel:()=>{S||C(!1)},confirmLoading:S,okButtonProps:{loading:S},cancelButtonProps:{disabled:S},className:"dark-theme-modal",styles:{content:{backgroundColor:"#1f2937",padding:"20px"},header:{backgroundColor:"#1f2937",borderBottom:"1px solid #374151"},body:{backgroundColor:"#1f2937"},mask:{backgroundColor:"rgba(0, 0, 0, 0.6)"}},children:x.jsxs("div",{className:"space-y-4",children:[x.jsxs("div",{children:[x.jsx("label",{className:"block text-sm font-medium text-gray-200 mb-2",children:"Number of Latest Files to Process"}),x.jsx(Xn,{type:"number",value:L,onChange:q=>I(parseInt(q.target.value)||100),placeholder:"Default: 100",className:"dark-theme-input"})]}),x.jsxs("div",{children:[x.jsx("label",{className:"block text-sm font-medium text-gray-200 mb-2",children:"Maximum Number of Groups"}),x.jsx(Xn,{type:"number",value:T,onChange:q=>D(parseInt(q.target.value)||10),placeholder:"Default: 10",className:"dark-theme-input"})]}),x.jsxs("div",{className:"flex items-center space-x-2",children:[x.jsx(Cf,{checked:B,onChange:R,className:"bg-gray-600"}),x.jsx("span",{className:"text-gray-200",children:"Skip Git Diff Information"})]})]})}),x.jsx(Gr,{title:"Select Groups to Create",open:$,onOk:async()=>{try{const q=O.filter(X=>X.selected);for(const X of q)await fetch("/api/file-groups",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:X.name,description:X.description})});await K(),yt.success("Selected groups created successfully"),W(!1)}catch{yt.error("Failed to create selected groups")}},onCancel:()=>{W(!1),P([])},width:800,className:"dark-theme-modal",styles:{content:{backgroundColor:"#1f2937",padding:"20px"},header:{backgroundColor:"#1f2937",borderBottom:"1px solid #374151"},body:{backgroundColor:"#1f2937"},mask:{backgroundColor:"rgba(0, 0, 0, 0.6)"}},children:x.jsx("div",{className:"space-y-4",children:O.map((q,X)=>x.jsx("div",{className:"p-4 bg-gray-800 rounded-lg",children:x.jsxs("div",{className:"flex items-center space-x-3",children:[x.jsx(yA,{checked:q.selected,onChange:ie=>{const oe=[...O];oe[X].selected=ie.target.checked,P(oe)}}),x.jsxs("div",{className:"flex-1",children:[x.jsx("h3",{className:"text-white font-medium text-lg",children:q.name}),x.jsx("p",{className:"text-gray-400 text-sm mt-1",children:q.description})]})]})},X))})})]})},I_n=({availableKeys:n,onModelChange:e})=>{const[t,i]=b.useState([]),[r,s]=b.useState(!1),[o,a]=b.useState(!1),[l,c]=b.useState({model:"",code_model:[],chat_model:"",generate_rerank_model:"",index_model:"",index_filter_model:"",commit_model:""}),d=async()=>{s(!0);try{const g=await fetch("/api/models");if(!g.ok)throw new Error("Failed to fetch models");const m=await g.json();i(m)}catch(g){console.error("Error fetching models:",g),yt.error(J("processingError"))}finally{s(!1)}},u=async g=>{try{const m=await fetch(`/api/conf/${g}`,{method:"DELETE"});if(!m.ok){let p="Failed to delete configuration key";try{const A=await m.json();A&&A.detail&&(p=A.detail)}catch{}throw new Error(p)}}catch(m){console.error(`Error deleting configuration key ${g}:`,m),yt.error(m.message||`Failed to delete ${g}`)}};b.useEffect(()=>{d()},[]),b.useEffect(()=>{(async()=>{a(!0);try{const m=await fetch("/api/conf");if(!m.ok)throw new Error("Failed to fetch configuration");const A=(await m.json()).conf,v={...l};A.model&&(v.model=A.model),A.code_model&&(v.code_model=typeof A.code_model=="string"?A.code_model.split(","):A.code_model),A.chat_model&&(v.chat_model=A.chat_model),A.generate_rerank_model&&(v.generate_rerank_model=A.generate_rerank_model),A.index_model&&(v.index_model=A.index_model),A.index_filter_model&&(v.index_filter_model=A.index_filter_model),A.commit_model&&(v.commit_model=A.commit_model),c(v)}catch(m){console.error("Error fetching current configuration:",m)}finally{a(!1)}})()},[]),b.useEffect(()=>{const g={...l};n.forEach(m=>{(m.key==="model"||m.key==="code_model"||m.key==="chat_model"||m.key==="generate_rerank_model"||m.key==="index_model"||m.key==="index_filter_model"||m.key==="commit_model")&&!g[m.key]&&(g[m.key]=m.value||"")}),c(g)},[n]),b.useEffect(()=>{const g=p=>{const A=Array.isArray(p)?p:[];c(v=>JSON.stringify(v.code_model)!==JSON.stringify(A)?(console.log("ModelConfig received update:",A),{...v,code_model:A}):v)},m=Ki.subscribe(Qi.CONFIG.CODE_MODEL_UPDATED,g);return()=>{m()}},[]);const h=(g,m)=>{const p=Array.isArray(m)?m.length===0:m==="";if(c(A=>({...A,[g]:m})),p)u(g),e(g,Array.isArray(m)?"":m);else{let A=m;if(g==="code_model"&&Array.isArray(m)&&(A=m.join(",")),e(g,A),g==="code_model"&&!p){const v=Array.isArray(m)?m:[];JSON.stringify(l.code_model)!==JSON.stringify(v)&&(console.log("ModelConfig publishing update:",v),Ki.publish(Qi.CONFIG.CODE_MODEL_UPDATED,v))}}},f={loading:r||o,className:"custom-select",popupClassName:"custom-select-dropdown",showSearch:!0,filterOption:(g,m)=>(m==null?void 0:m.label.toLowerCase().includes(g.toLowerCase()))||!1,style:{width:"100%"}};return r||o?x.jsxs("div",{className:"space-y-2",children:[x.jsx(Mf.Input,{active:!0,block:!0,style:{height:32,backgroundColor:"#1e293b"}}),x.jsx(Mf.Input,{active:!0,block:!0,style:{height:32,backgroundColor:"#1e293b"}}),x.jsx(Mf.Input,{active:!0,block:!0,style:{height:32,backgroundColor:"#1e293b"}}),x.jsx(Mf.Input,{active:!0,block:!0,style:{height:32,backgroundColor:"#1e293b"}})]}):x.jsxs("div",{children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("h3",{className:"settings-title",children:J("modelConfiguration")}),x.jsx(an,{type:"text",icon:x.jsx(n_,{}),onClick:()=>{d()},loading:r,className:"text-gray-400 hover:text-white"})]}),x.jsxs("div",{className:"space-y-3",children:[x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("defaultModel")}),x.jsx(ki,{...f,allowClear:!0,value:l.model||void 0,onChange:g=>h("model",g||""),options:t.map(g=>({value:g.name,label:g.name}))}),x.jsx("p",{className:"model-config-description",children:J("defaultModelDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("codeModel")}),x.jsx(ki,{...f,allowClear:!0,mode:"multiple",value:l.code_model||[],onChange:g=>h("code_model",g||[]),options:t.map(g=>({value:g.name,label:g.name})),tagRender:g=>{const{label:m,value:p,closable:A,onClose:v}=g;return x.jsx(aA,{color:"blue",closable:A,onClose:v,style:{marginRight:3},children:m})}}),x.jsx("p",{className:"model-config-description",children:J("codeModelDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("chatModel")}),x.jsx(ki,{...f,allowClear:!0,value:l.chat_model||void 0,onChange:g=>h("chat_model",g||""),options:t.map(g=>({value:g.name,label:g.name}))}),x.jsx("p",{className:"model-config-description",children:J("chatModelDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("rerankModel")}),x.jsx(ki,{...f,allowClear:!0,value:l.generate_rerank_model||void 0,onChange:g=>h("generate_rerank_model",g||""),options:t.map(g=>({value:g.name,label:g.name}))}),x.jsx("p",{className:"model-config-description",children:J("rerankModelDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("indexModel")}),x.jsx(ki,{...f,allowClear:!0,value:l.index_model||void 0,onChange:g=>h("index_model",g||""),options:t.map(g=>({value:g.name,label:g.name}))}),x.jsx("p",{className:"model-config-description",children:J("indexModelDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("indexFilterModel")}),x.jsx(ki,{...f,allowClear:!0,value:l.index_filter_model||void 0,onChange:g=>h("index_filter_model",g||""),options:t.map(g=>({value:g.name,label:g.name}))}),x.jsx("p",{className:"model-config-description",children:J("indexFilterModelDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("commitModel")}),x.jsx(ki,{...f,allowClear:!0,value:l.commit_model||void 0,onChange:g=>h("commit_model",g||""),options:t.map(g=>({value:g.name,label:g.name}))}),x.jsx("p",{className:"model-config-description",children:J("commitModelDescription")})]})]})]})},L_n=({visible:n,onClose:e,model:t})=>{const[i,r]=b.useState(""),[s,o]=b.useState(!1),[a,l]=b.useState([]),c=async()=>{if(i.trim()){o(!0),l(u=>[...u,{role:"user",content:i}]);try{const u=await d(i,t);u&&typeof u=="object"&&u.error?l(h=>[...h,{role:"error",content:u.error}]):(l(h=>[...h,{role:"assistant",content:u}]),r(""))}catch(u){l(h=>[...h,{role:"error",content:u.message||"对话失败"}])}finally{o(!1)}}},d=async(u,h)=>{try{const g=await(await fetch("/api/direct_chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:typeof h=="string"?h:(h==null?void 0:h.name)||"v3_chat",content:u,product_mode:(h==null?void 0:h.product_mode)||"lite"})})).json();return g.success?g.result:{error:g.error||"模型返回失败"}}catch(f){return{error:f.message||"请求失败"}}};return x.jsxs(Gr,{open:n,title:J("modelDialogTestTitle"),onCancel:e,footer:null,width:540,className:"dark-modal",destroyOnClose:!0,children:[x.jsxs("div",{style:{minHeight:240,maxHeight:340,overflowY:"auto",background:"#1e293b",borderRadius:8,padding:12,marginBottom:12},children:[a.length===0&&x.jsx("div",{style:{color:"#64748b",textAlign:"center",marginTop:60},children:J("noDialogMessages")||"暂无消息"}),a.map((u,h)=>x.jsx("div",{style:{marginBottom:8,textAlign:u.role==="user"?"right":"left"},children:x.jsx("span",{style:{display:"inline-block",background:u.role==="user"?"#0ea5e9":u.role==="error"?"#fff1f0":"#334155",color:u.role==="user"?"#fff":u.role==="error"?"#d4380d":"#e0e7ef",borderRadius:6,padding:"6px 12px",maxWidth:320,wordBreak:"break-all",border:u.role==="error"?"1.5px solid #ff4d4f":void 0,fontWeight:u.role==="error"?500:void 0},children:u.content})},h)),s&&x.jsx("div",{style:{textAlign:"center",marginTop:12},children:x.jsx(zh,{})})]}),x.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8,marginBottom:4},children:[x.jsx(Xn,{style:{flex:1,color:"#fff",height:40,borderRadius:8},value:i,onChange:u=>r(u.target.value),onPressEnter:c,disabled:s,placeholder:J("dialogInputPlaceholder")||"请输入内容...",autoFocus:!0,className:"model-chat-input-dark"}),x.jsx(an,{type:"primary",icon:x.jsx(Pbt,{}),onClick:c,loading:s,disabled:!i.trim(),style:{height:40,borderRadius:8,padding:"0 24px",fontWeight:500,fontSize:16,display:"flex",alignItems:"center",boxShadow:"0 2px 8px rgba(30,64,175,0.10)",background:"linear-gradient(90deg, #2563eb 0%, #3b82f6 100%)",border:"none",color:"#fff"},children:J("send")||"发送"})]})]})},N_n=()=>{var O;const[n,e]=b.useState(!1),[t,i]=b.useState(null),[r]=Rn.useForm(),[s,o]=b.useState([]),[a,l]=b.useState([]),[c,d]=b.useState(!1),[u,h]=b.useState(!1),[f,g]=b.useState(!1),[m,p]=b.useState(null),[A,v]=b.useState(""),_=async()=>{d(!0);try{const P=await fetch("/api/models");if(!P.ok)throw new Error("Failed to fetch models");const $=await P.json();o($)}catch(P){console.error("Error fetching models:",P),yt.error(J("modelOperationFailed",{message:String(P)}))}finally{d(!1)}},y=async()=>{h(!0);try{const P=await fetch("/api/providers");if(!P.ok)throw new Error("Failed to fetch providers");const $=await P.json();l($)}catch(P){console.error("Error fetching providers:",P),yt.error(J("modelOperationFailed",{message:String(P)}))}finally{h(!1)}};b.useEffect(()=>{_(),y();const P=()=>{console.log("Received provider update event, refreshing providers..."),y()},$=Ki.subscribe(Qi.PROVIDER.UPDATED,P);return()=>{$()}},[]);const C=async P=>{try{const $={...P,input_price:Number(P.input_price),output_price:Number(P.output_price),average_speed:Number(P.average_speed||0),max_output_tokens:Number(P.max_output_tokens||8096)};let W="/api/models";const j=m?"PUT":"POST";if(m&&(W=`/api/models?model_name=${encodeURIComponent(m.name)}`),!(await fetch(W,{method:j,headers:{"Content-Type":"application/json"},body:JSON.stringify($)})).ok)throw new Error("Failed to save model");yt.success(J(m?"modelUpdateSuccess":"modelAddSuccess")),g(!1),_(),Ki.publish(Qi.CONFIG.MODEL_LIST_UPDATED)}catch($){console.error("Error saving model:",$),yt.error(J("modelOperationFailed",{message:String($)}))}},S=async P=>{try{if(!(await fetch(`/api/models?model_name=${encodeURIComponent(P)}`,{method:"DELETE"})).ok)throw new Error("Failed to delete model");yt.success(J("modelDeleteSuccess")),_(),Ki.publish(Qi.CONFIG.MODEL_LIST_UPDATED)}catch($){console.error("Error deleting model:",$),yt.error(J("modelOperationFailed",{message:String($)}))}},E=P=>{p(P),r.setFieldsValue({...P,provider:I(P.base_url)}),v(I(P.base_url)),g(!0)},L=()=>{p(null),r.resetFields(),v(""),g(!0)},I=P=>{const $=a.find(W=>W.base_url===P);return $?$.name:""},T=P=>{v(P);const $=a.find(W=>W.name===P);$?(r.setFieldValue("base_url",$.base_url),r.setFieldValue("model_type",$.model_type||"saas/openai"),r.setFieldValue("provider",P),r.setFieldValue("model_name",void 0),r.setFieldValue("input_price",void 0),r.setFieldValue("output_price",void 0),r.setFieldValue("is_reasoning",!1)):(r.setFieldValue("base_url",void 0),r.setFieldValue("model_type",void 0),r.setFieldValue("model_name",void 0),r.setFieldValue("input_price",void 0),r.setFieldValue("output_price",void 0),r.setFieldValue("is_reasoning",!1))},D=()=>{y(),yt.success(J("modelOperationFailed",{message:"Providers refreshed"}))},B=P=>{const $=a.find(W=>W.name===A);if($){const W=$.models.find(j=>j.id===P);W&&r.setFieldsValue({model_name:P,input_price:W.input_price,output_price:W.output_price,is_reasoning:W.is_reasoning,name:P,max_output_tokens:W.max_output_tokens||8096})}},R=[{title:J("modelName"),dataIndex:"name",key:"name"},{title:J("modelDescription"),dataIndex:"description",key:"description",ellipsis:!0},{title:J("modelProvider"),dataIndex:"base_url",key:"provider",render:P=>{const $=I(P);return J($)||$}},{title:J("modelType"),dataIndex:"model_name",key:"model_name"},{title:J("modelTypeInterface"),dataIndex:"model_type",key:"model_type"},{title:J("modelInputPrice"),dataIndex:"input_price",key:"input_price"},{title:J("modelOutputPrice"),dataIndex:"output_price",key:"output_price"},{title:J("modelIsReasoning"),dataIndex:"is_reasoning",key:"is_reasoning",render:P=>P?"✓":"✗"},{title:J("modelApiKeyConfigured")||"API Key已配置",dataIndex:"api_key",key:"api_key_configured",render:P=>P&&P.trim()!==""?"✓":x.jsx("span",{style:{color:"red"},children:"✗"})},{title:J("more"),key:"action",render:(P,$)=>x.jsxs("div",{className:"flex gap-2",children:[x.jsx(an,{type:"text",icon:x.jsx(Bu,{}),onClick:()=>E($),title:J("editModel"),className:"dark-button"}),x.jsx(an,{type:"text",icon:x.jsx(A3,{}),onClick:()=>{i($),e(!0)},title:J("dialogTest"),className:"dark-button"}),x.jsx(F1,{title:J("confirmDeleteModel"),onConfirm:()=>S($.name),okText:J("confirm"),cancelText:J("cancel"),overlayClassName:"dark-popconfirm",children:x.jsx(an,{type:"text",danger:!0,icon:x.jsx(Ac,{}),title:J("deleteModel"),className:"dark-button"})})]})}];return x.jsxs("div",{className:"model-management-container p-2 overflow-y-auto h-full bg-gray-900",children:[x.jsxs("div",{className:"flex justify-between items-center mb-4",children:[x.jsx("h2",{className:"text-xl text-white",children:J("modelManagement")}),x.jsxs("div",{className:"flex gap-2",children:[x.jsxs(an,{icon:x.jsx(n_,{}),onClick:()=>{_(),y()},className:"dark-button",children:[u||c?x.jsx(zh,{size:"small"}):null,J("more")]}),x.jsx(an,{type:"primary",icon:x.jsx(Pa,{}),onClick:L,className:"dark-button",children:J("addModel")})]})]}),x.jsx(od,{dataSource:s,columns:R,rowKey:"name",loading:c,pagination:{pageSize:10},className:"model-table dark-table",locale:{emptyText:x.jsx("div",{className:"text-gray-400 py-8",children:"No data"})}}),x.jsx(Gr,{title:x.jsx("span",{className:"text-white",children:J(m?"editModel":"addModel")}),open:f,onCancel:()=>g(!1),footer:null,width:700,className:"dark-modal",closeIcon:x.jsx("span",{className:"text-white",children:"×"}),children:x.jsxs(Rn,{form:r,layout:"vertical",onFinish:C,initialValues:{is_reasoning:!1,average_speed:0},className:"dark-form",children:[x.jsx(Rn.Item,{name:"name",label:x.jsxs("span",{className:"text-white",children:[x.jsx(er,{title:J("modelNameTooltip"),children:x.jsx(IE,{style:{color:"white",marginRight:4}})}),J("modelName")]}),rules:[{required:!0,message:"Please input model name"}],children:x.jsx(Xn,{className:"dark-input"})}),x.jsx(Rn.Item,{name:"description",label:x.jsx("span",{className:"text-white",children:J("modelDescription")}),children:x.jsx(Xn.TextArea,{rows:2,className:"dark-input"})}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(Rn.Item,{name:"provider",label:x.jsx("span",{className:"text-white",children:J("modelProvider")}),rules:[{required:!0,message:"Please select provider"}],children:x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(ki,{onChange:T,className:"dark-select flex-1",loading:u,allowClear:!0,children:a.map(P=>x.jsx(ki.Option,{value:P.name,children:J(P.name)||P.name},P.name))}),x.jsx(an,{icon:x.jsx(n_,{}),onClick:D,className:"dark-button",title:J("more")})]})}),x.jsx(Rn.Item,{name:"model_type",label:x.jsx("span",{className:"text-white",children:J("modelTypeInterface")}),rules:[{required:!0,message:"Interface type is required"}],children:x.jsx(Xn,{disabled:!0,className:"dark-input"})})]}),x.jsx(Rn.Item,{name:"model_name",label:x.jsxs("span",{className:"text-white",children:[x.jsx(er,{title:J("modelTypeTooltip"),children:x.jsx(IE,{style:{color:"white",marginRight:4}})}),J("modelType")]}),rules:[{required:!0,message:"Please select model type"}],children:x.jsx(ki,{onChange:B,disabled:!A,className:"dark-select",children:A&&((O=a.find(P=>P.name===A))==null?void 0:O.models.map(P=>x.jsx(ki.Option,{value:P.id,children:P.name},P.id)))})}),x.jsx(Rn.Item,{name:"base_url",label:x.jsx("span",{className:"text-white",children:J("modelBaseUrl")}),rules:[{required:!0,message:"Please input base URL"}],children:x.jsx(Xn,{disabled:!0,className:"dark-input"})}),x.jsx(Rn.Item,{name:"api_key",label:x.jsx("span",{className:"text-white",children:J("modelApiKey")}),rules:[{required:!0,message:"Please input API key"}],children:x.jsx(Xn.Password,{placeholder:"Path to API key file (optional)",className:"dark-input",iconRender:P=>P?x.jsx(c5e,{}):x.jsx(d5e,{})})}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(Rn.Item,{name:"input_price",label:x.jsx("span",{className:"text-white",children:J("modelInputPrice")}),rules:[{required:!0,message:"Please input price"}],children:x.jsx(Xn,{type:"number",step:"0.1",min:"0",className:"dark-input"})}),x.jsx(Rn.Item,{name:"output_price",label:x.jsx("span",{className:"text-white",children:J("modelOutputPrice")}),rules:[{required:!0,message:"Please input price"}],children:x.jsx(Xn,{type:"number",step:"0.1",min:"0",className:"dark-input"})})]}),x.jsx(Rn.Item,{name:"average_speed",label:x.jsx("span",{className:"text-white",children:J("modelAverageSpeed")}),children:x.jsx(Xn,{type:"number",step:"0.1",min:"0",className:"dark-input"})}),x.jsx(Rn.Item,{name:"max_output_tokens",label:x.jsx("span",{className:"text-white",children:J("maxOutputTokens")||"Max Output Tokens"}),children:x.jsx(Xn,{type:"number",step:"1",min:"1",placeholder:"Defaults to 8096",className:"dark-input"})}),x.jsx(Rn.Item,{name:"is_reasoning",label:x.jsx("span",{className:"text-white",children:J("modelIsReasoning")}),valuePropName:"checked",children:x.jsx(Cf,{className:"dark-switch"})}),x.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[x.jsx(an,{onClick:()=>g(!1),className:"dark-button",children:J("cancelModelEdit")}),x.jsx(an,{type:"primary",htmlType:"submit",className:"dark-button",children:J("saveModel")})]})]})}),x.jsx(L_n,{visible:n,onClose:()=>e(!1),model:t})]})},T_n=()=>{const[n]=Rn.useForm(),[e,t]=b.useState([]),[i,r]=b.useState(!1),[s,o]=b.useState(!1),[a,l]=b.useState(null),c=async()=>{r(!0);try{const m=await fetch("/api/providers");if(!m.ok)throw new Error("Failed to fetch providers");const p=await m.json();t(p)}catch(m){console.error("Error fetching providers:",m),yt.error(J("modelOperationFailed",{message:String(m)}))}finally{r(!1)}};b.useEffect(()=>{c()},[]);const d=async m=>{try{const p={name:m.name,base_url:m.base_url,model_type:m.model_type,models:m.models||[]},A=a?`/api/providers/${a.name}`:"/api/providers";if(!(await fetch(A,{method:a?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)})).ok)throw new Error("Failed to save provider");yt.success(J(a?"providerUpdateSuccess":"providerAddSuccess")),o(!1),c(),Ki.publish(Qi.PROVIDER.UPDATED)}catch(p){console.error("Error saving provider:",p),yt.error(J("modelOperationFailed",{message:String(p)}))}},u=async m=>{try{if(!(await fetch(`/api/providers/${m}`,{method:"DELETE"})).ok)throw new Error("Failed to delete provider");yt.success(J("providerDeleteSuccess")),c(),Ki.publish(Qi.PROVIDER.UPDATED)}catch(p){console.error("Error deleting provider:",p),yt.error(J("modelOperationFailed",{message:String(p)}))}},h=m=>{l(m),n.setFieldsValue({...m}),o(!0)},f=()=>{l(null),n.resetFields(),n.setFieldsValue({models:[{id:"",name:"",input_price:0,output_price:0,is_reasoning:!1}]}),o(!0)},g=[{title:J("providerName"),dataIndex:"name",key:"name"},{title:J("providerBaseUrl"),dataIndex:"base_url",key:"base_url",ellipsis:!0},{title:J("providerModels"),dataIndex:"models",key:"models",render:m=>`${m.length} ${m.length===1?"model":"models"}`},{title:J("more"),key:"action",render:(m,p)=>x.jsxs("div",{className:"flex gap-2",children:[x.jsx(an,{type:"text",icon:x.jsx(Bu,{}),onClick:()=>h(p),title:J("editProvider"),className:"dark-button"}),x.jsx(F1,{title:J("confirmDeleteProvider"),onConfirm:()=>u(p.name),okText:J("confirm"),cancelText:J("cancel"),overlayClassName:"dark-popconfirm",children:x.jsx(an,{type:"text",danger:!0,icon:x.jsx(Ac,{}),title:J("deleteProvider"),className:"dark-button"})})]})}];return x.jsxs("div",{className:"provider-management-container p-2 overflow-y-auto h-full bg-gray-900",children:[x.jsxs("div",{className:"flex justify-between items-center mb-4",children:[x.jsx("h2",{className:"text-xl text-white",children:J("providerManagement")}),x.jsx(an,{type:"primary",icon:x.jsx(Pa,{}),onClick:f,className:"dark-button",children:J("addProvider")})]}),x.jsx(od,{dataSource:e,columns:g,rowKey:"name",loading:i,pagination:{pageSize:10},className:"provider-table dark-table",locale:{emptyText:x.jsx("div",{className:"text-gray-400 py-8",children:"No data"})}}),x.jsx(Gr,{title:x.jsx("span",{className:"text-white",children:J(a?"editProvider":"addProvider")}),open:s,onCancel:()=>o(!1),footer:null,width:800,className:"dark-modal",closeIcon:x.jsx("span",{className:"text-white",children:"×"}),children:x.jsxs(Rn,{form:n,layout:"vertical",onFinish:d,className:"dark-form",children:[x.jsx(Rn.Item,{name:"name",label:x.jsx("span",{className:"text-white",children:J("providerName")}),rules:[{required:!0,message:"Please input provider name"}],children:x.jsx(Xn,{className:"dark-input"})}),x.jsx(Rn.Item,{name:"base_url",label:x.jsx("span",{className:"text-white",children:J("providerBaseUrl")}),rules:[{required:!0,message:"Please input base URL"}],children:x.jsx(Xn,{className:"dark-input"})}),x.jsx(Rn.Item,{name:"model_type",label:x.jsx("span",{className:"text-white",children:J("modelTypeInterface")}),initialValue:"saas/openai",children:x.jsxs(ki,{className:"dark-select",children:[x.jsx(ki.Option,{value:"saas/openai",children:"saas/openai"}),x.jsx(ki.Option,{value:"saas/gemini",children:"saas/gemini"})]})}),x.jsxs("div",{className:"mb-4",children:[x.jsx("label",{className:"text-white block mb-2",children:J("providerModels")}),x.jsx(Rn.List,{name:"models",children:(m,{add:p,remove:A})=>x.jsxs(x.Fragment,{children:[m.map(({key:v,name:_,...y})=>x.jsxs("div",{className:"bg-gray-800 p-3 mb-3 rounded-md",children:[x.jsxs("div",{className:"flex justify-between items-center mb-2",children:[x.jsxs("span",{className:"text-white",children:["Model #",_+1]}),x.jsx(an,{type:"text",icon:x.jsx(fbt,{}),onClick:()=>A(_),className:"dark-button"})]}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(Rn.Item,{...y,name:[_,"id"],label:x.jsx("span",{className:"text-white",children:"Model ID"}),tooltip:{title:J("modelIdTooltip"),icon:x.jsx(IE,{style:{color:"white"}})},rules:[{required:!0,message:"Please input model ID"}],children:x.jsx(Xn,{className:"dark-input"})}),x.jsx(Rn.Item,{...y,name:[_,"name"],label:x.jsx("span",{className:"text-white",children:"Model Name"}),tooltip:{title:J("modelNameTooltip"),icon:x.jsx(IE,{style:{color:"white"}})},rules:[{required:!0,message:"Please input model name"}],children:x.jsx(Xn,{className:"dark-input"})})]}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(Rn.Item,{...y,name:[_,"input_price"],label:x.jsx("span",{className:"text-white",children:J("modelInputPrice")}),rules:[{required:!0,message:"Please input price"}],children:x.jsx(Xn,{type:"number",step:"0.1",min:"0",className:"dark-input"})}),x.jsx(Rn.Item,{...y,name:[_,"output_price"],label:x.jsx("span",{className:"text-white",children:J("modelOutputPrice")}),rules:[{required:!0,message:"Please input price"}],children:x.jsx(Xn,{type:"number",step:"0.1",min:"0",className:"dark-input"})})]}),x.jsx(Rn.Item,{...y,name:[_,"is_reasoning"],label:x.jsx("span",{className:"text-white",children:J("modelIsReasoning")}),valuePropName:"checked",children:x.jsx("input",{type:"checkbox",className:"mr-2"})})]},v)),x.jsx(Rn.Item,{children:x.jsx(an,{type:"dashed",onClick:()=>p({id:"",name:"",input_price:0,output_price:0,is_reasoning:!1}),icon:x.jsx(Sbt,{}),className:"dark-button w-full",children:"Add Model"})})]})})]}),x.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[x.jsx(an,{onClick:()=>o(!1),className:"dark-button",children:J("cancel")}),x.jsx(an,{type:"primary",htmlType:"submit",className:"dark-button",children:J("save")})]})]})})]})},D_n=()=>{const[n,e]=b.useState([]),[t,i]=b.useState(!1),[r,s]=b.useState(!1),[o,a]=b.useState(null),[l]=Rn.useForm(),c=async()=>{i(!0);try{const A=await fetch("/api/compilers");if(!A.ok)throw new Error("Failed to fetch compilers");const v=await A.json();e(v.data||[])}catch(A){console.error("Error fetching compilers:",A),yt.error(J("processingError"))}finally{i(!1)}},d=async()=>{i(!0);try{const A=await fetch("/api/compilers/initialize",{method:"POST"});if(!A.ok)throw new Error("Failed to initialize compilers");const v=await A.json();e(v.data||[]),yt.success(J("settingsUpdateSuccess"))}catch(A){console.error("Error initializing compilers:",A),yt.error(J("processingError"))}finally{i(!1)}};b.useEffect(()=>{c()},[]);const u=()=>{a(null),l.resetFields(),s(!0)},h=A=>{a(A),l.setFieldsValue({...A,args:A.args}),s(!0)},f=()=>{s(!1)},g=async()=>{try{const v={...await l.validateFields()};let _;if(o?_=await fetch(`/api/compilers/${o.name}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(v)}):_=await fetch("/api/compilers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(v)}),!_.ok){const y=await _.json();throw new Error(y.detail||"Failed to save compiler")}yt.success(o?J("compilerUpdateSuccess")||"Compiler updated successfully":J("compilerCreateSuccess")||"Compiler created successfully"),s(!1),c()}catch(A){console.error("Error saving compiler:",A),yt.error(A instanceof Error?A.message:J("processingError"))}},m=async A=>{try{const v=await fetch(`/api/compilers/${A}`,{method:"DELETE"});if(!v.ok){const _=await v.json();throw new Error(_.detail||"Failed to delete compiler")}yt.success(J("compilerDeleteSuccess")||"Compiler deleted successfully"),c()}catch(v){console.error("Error deleting compiler:",v),yt.error(v instanceof Error?v.message:J("processingError"))}},p=[{title:J("compilerName")||"Name",dataIndex:"name",key:"name"},{title:J("compilerType")||"Type",dataIndex:"type",key:"type"},{title:J("workingDirectory")||"Working Directory",dataIndex:"working_dir",key:"working_dir",ellipsis:!0},{title:J("compilerCommand")||"Command",dataIndex:"command",key:"command"},{title:J("actions")||"Actions",key:"actions",render:(A,v)=>x.jsxs(GC,{size:"small",children:[x.jsx(an,{type:"text",icon:x.jsx(Bu,{}),onClick:()=>h(v),className:"text-gray-400 hover:text-white dark-button"}),x.jsx(F1,{title:J("deleteConfirmation")||"Are you sure you want to delete this compiler?",onConfirm:()=>m(v.name),okText:J("yes")||"Yes",cancelText:J("no")||"No",children:x.jsx(an,{type:"text",danger:!0,icon:x.jsx(Ac,{}),className:"text-gray-400 hover:text-red-500 dark-button"})})]})}];return x.jsxs("div",{children:[x.jsxs("div",{className:"flex items-center justify-between mb-4",children:[x.jsx("h3",{className:"settings-title",children:J("compilerConfiguration")||"Compiler Configuration"}),x.jsxs(GC,{children:[x.jsx(an,{type:"text",icon:x.jsx(n_,{}),onClick:c,loading:t,className:"text-gray-400 hover:text-white dark-button"}),x.jsx(an,{type:"primary",icon:x.jsx(Pa,{}),onClick:u,className:"bg-blue-600 hover:bg-blue-700 dark-button",children:J("addCompiler")||"Add Compiler"}),n.length===0&&x.jsx(an,{onClick:d,className:"bg-green-600 hover:bg-green-700 text-white dark-button",children:J("initializeDefault")||"Initialize Default"})]})]}),x.jsx(od,{dataSource:n,columns:p,rowKey:"name",loading:t,pagination:!1,className:"compiler-table dark-table",locale:{emptyText:J("noCompilers")||"No compilers configured"}}),x.jsx(Gr,{title:o?J("editCompiler")||"Edit Compiler":J("addCompiler")||"Add Compiler",open:r,onCancel:f,onOk:g,okText:J("save")||"Save",cancelText:J("cancel")||"Cancel",className:"dark-modal",children:x.jsxs(Rn,{form:l,layout:"vertical",name:"compilerForm",className:"dark-form",children:[x.jsx(Rn.Item,{name:"name",label:J("compilerName")||"Name",rules:[{required:!0,message:J("nameRequired")||"Please enter a name"}],children:x.jsx(Xn,{disabled:!!o,className:"dark-input"})}),x.jsx(Rn.Item,{name:"type",label:J("compilerType")||"Type",rules:[{required:!0,message:J("typeRequired")||"Please enter a build tool type"}],children:x.jsx(Xn,{className:"dark-input",placeholder:J("compilerTypePlaceholder")||"Enter build tool type (e.g. maven, vite)"})}),x.jsx(Rn.Item,{name:"working_dir",label:J("workingDirectory")||"Working Directory",rules:[{required:!0,message:J("workingDirRequired")||"Please enter a working directory"}],children:x.jsx(Xn,{className:"dark-input",placeholder:J("workingDirPlaceholder")||"Enter relative path for working directory"})}),x.jsx(Rn.Item,{name:"command",label:J("compilerCommand")||"Command",rules:[{required:!0,message:J("compilerCommandRequired")||"Please enter a command"}],children:x.jsx(Xn,{className:"dark-input"})}),x.jsx(Rn.Item,{name:"args",label:J("arguments")||"Arguments",children:x.jsx(ki,{mode:"tags",className:"dark-select compiler-select compiler-tag-select",dropdownClassName:"dark-select-dropdown",placeholder:J("enterArguments")||"Enter arguments, separated by spaces",tokenSeparators:[" "]})}),x.jsx(Rn.Item,{name:"triggers",label:J("triggersLabel")||"Source file extensions",children:x.jsx(ki,{mode:"tags",className:"dark-select compiler-select compiler-tag-select",dropdownClassName:"dark-select-dropdown",placeholder:J("enterFileExtensions")||"Enter file extensions (e.g. .py,.js)",tokenSeparators:[","]})}),x.jsx(Rn.Item,{name:"extract_regex",label:J("extractRegex")||"Error Extraction Regex",tooltip:J("extractRegexTooltip")||"Regular expression to extract error information from compiler output",children:x.jsx(Xn,{className:"dark-input"})})]})})]})},R_n=()=>{const[n,e]=b.useState([]),[t,i]=b.useState(!1),[r,s]=b.useState(!1),[o,a]=b.useState(null),[l]=Rn.useForm(),c=async()=>{i(!0);try{const p=await fetch("/api/rags");if(!p.ok)throw new Error("Failed to fetch RAGs");const A=await p.json();e(A.data||[])}catch(p){console.error("Error fetching RAGs:",p),yt.error(J("processingError"))}finally{i(!1)}};b.useEffect(()=>{c()},[]);const d=()=>{a(null),l.resetFields(),s(!0)},u=p=>{a(p),l.setFieldsValue({...p}),s(!0)},h=()=>{s(!1)},f=async()=>{try{const A={...await l.validateFields()};let v;if(o?v=await fetch(`/api/rags/${o.name}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)}):v=await fetch("/api/rags",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)}),!v.ok){const _=await v.json();throw new Error(_.detail||"Failed to save RAG")}yt.success(o?J("ragUpdateSuccess")||"RAG updated successfully":J("ragAddSuccess")||"RAG added successfully"),s(!1),c(),EventBus.publish(EVENTS.RAG.UPDATED),EventBus.publish(EVENTS.RAG.UPDATED)}catch(p){console.error("Error saving RAG:",p),yt.error(p instanceof Error?p.message:J("processingError"))}},g=async p=>{try{const A=await fetch(`/api/rags/${p}`,{method:"DELETE"});if(!A.ok){const v=await A.json();throw new Error(v.detail||"Failed to delete RAG")}yt.success(J("ragDeleteSuccess")||"RAG deleted successfully"),c()}catch(A){console.error("Error deleting RAG:",A),yt.error(A instanceof Error?A.message:J("processingError"))}},m=[{title:J("ragName")||"Name",dataIndex:"name",key:"name"},{title:J("ragBaseUrl")||"RAG URL",dataIndex:"base_url",key:"base_url",ellipsis:!0},{title:J("ragApiKey")||"API Key",dataIndex:"api_key",key:"api_key",render:p=>p?"••••••••":""},{title:J("actions")||"Actions",key:"actions",render:(p,A)=>x.jsxs(GC,{size:"small",children:[x.jsx(an,{type:"text",icon:x.jsx(Bu,{}),onClick:()=>u(A),className:"text-gray-400 hover:text-white dark-button"}),x.jsx(F1,{title:J("confirmDeleteRag")||"Are you sure you want to delete this RAG?",onConfirm:()=>g(A.name),okText:J("yes")||"Yes",cancelText:J("no")||"No",children:x.jsx(an,{type:"text",danger:!0,icon:x.jsx(Ac,{}),className:"text-gray-400 hover:text-red-500 dark-button"})})]})}];return x.jsxs("div",{children:[x.jsxs("div",{className:"flex items-center justify-between mb-4",children:[x.jsx("h3",{className:"settings-title",children:J("ragConfiguration")||"RAG Configuration"}),x.jsxs(GC,{children:[x.jsx(an,{type:"text",icon:x.jsx(n_,{}),onClick:c,loading:t,className:"text-gray-400 hover:text-white dark-button"}),x.jsx(an,{type:"primary",icon:x.jsx(Pa,{}),onClick:d,className:"bg-blue-600 hover:bg-blue-700 dark-button",children:J("addRag")||"Add RAG"})]})]}),x.jsx(od,{dataSource:n,columns:m,rowKey:"name",loading:t,pagination:!1,className:"compiler-table dark-table",locale:{emptyText:J("noRags")||"No RAGs configured"}}),x.jsx(Gr,{title:o?J("editRag")||"Edit RAG":J("addRag")||"Add RAG",open:r,onCancel:h,onOk:f,okText:J("save")||"Save",cancelText:J("cancel")||"Cancel",className:"dark-modal",children:x.jsxs(Rn,{form:l,layout:"vertical",name:"ragForm",className:"dark-form",children:[x.jsx(Rn.Item,{name:"name",label:J("ragName")||"Name",rules:[{required:!0,message:J("nameRequired")||"Please enter a name"}],children:x.jsx(Xn,{disabled:!!o,className:"dark-input"})}),x.jsx(Rn.Item,{name:"base_url",label:J("ragBaseUrl")||"RAG URL",rules:[{required:!0,message:"Please enter RAG URL"}],children:x.jsx(Xn,{className:"dark-input"})}),x.jsx(Rn.Item,{name:"api_key",label:J("ragApiKey")||"API Key",rules:[{required:!0,message:"Please enter API Key"}],children:x.jsx(Xn.Password,{className:"dark-input",defaultValue:"xxxx"})})]})})]})},M_n=({availableKeys:n,onSettingChange:e})=>{const[t,i]=b.useState(!1),[r,s]=b.useState({project_type:"",index_filter_model_max_input_length:51200,conversation_prune_safe_zone_tokens:51200,auto_merge:"editblock",generate_times_same_model:1,rank_times_same_model:1,enable_agentic_filter:!1,enable_agentic_edit:!1,skip_build_index:!1,skip_filter_index:!1});b.useEffect(()=>{(async()=>{i(!0);try{const l=await fetch("/api/conf");if(!l.ok)throw new Error("Failed to fetch configuration");const d=(await l.json()).conf,u={...r};d.project_type!==void 0&&(u.project_type=d.project_type),d.index_filter_model_max_input_length!==void 0&&(u.index_filter_model_max_input_length=Number(d.index_filter_model_max_input_length)),d.conversation_prune_safe_zone_tokens!==void 0&&(u.conversation_prune_safe_zone_tokens=Number(d.conversation_prune_safe_zone_tokens)),d.auto_merge!==void 0&&(u.auto_merge=d.auto_merge),d.generate_times_same_model!==void 0&&(u.generate_times_same_model=Number(d.generate_times_same_model)),d.rank_times_same_model!==void 0&&(u.rank_times_same_model=Number(d.rank_times_same_model)),d.enable_agentic_filter!==void 0&&(u.enable_agentic_filter=String(d.enable_agentic_filter).toLowerCase()==="true"),d.enable_agentic_edit!==void 0&&(u.enable_agentic_edit=String(d.enable_agentic_edit).toLowerCase()==="true"),d.skip_build_index!==void 0&&(u.skip_build_index=String(d.skip_build_index).toLowerCase()==="true"),d.skip_filter_index!==void 0&&(u.skip_filter_index=String(d.skip_filter_index).toLowerCase()==="true"),s(u)}catch(l){console.error("Error fetching current configuration:",l)}finally{i(!1)}})()},[]),b.useEffect(()=>{const a={...r};n.forEach(l=>{l.key==="project_type"&&a.project_type===void 0&&(a.project_type=l.default||""),l.key==="index_filter_model_max_input_length"&&a.index_filter_model_max_input_length===void 0&&(a.index_filter_model_max_input_length=Number(l.default)||51200),l.key==="conversation_prune_safe_zone_tokens"&&a.conversation_prune_safe_zone_tokens===void 0&&(a.conversation_prune_safe_zone_tokens=Number(l.default)||51200),l.key==="auto_merge"&&a.auto_merge===void 0&&(a.auto_merge=l.default||"editblock"),l.key==="generate_times_same_model"&&a.generate_times_same_model===void 0&&(a.generate_times_same_model=Number(l.default)||1),l.key==="rank_times_same_model"&&a.rank_times_same_model===void 0&&(a.rank_times_same_model=Number(l.default)||1),l.key==="enable_agentic_filter"&&a.enable_agentic_filter===void 0&&(a.enable_agentic_filter=String(l.default).toLowerCase()==="true"||!1),l.key==="enable_agentic_edit"&&a.enable_agentic_edit===void 0&&(a.enable_agentic_edit=String(l.default).toLowerCase()==="true"||!1),l.key==="skip_build_index"&&a.skip_build_index===void 0&&(a.skip_build_index=String(l.default).toLowerCase()==="true"||!1),l.key==="skip_filter_index"&&a.skip_filter_index===void 0&&(a.skip_filter_index=String(l.default).toLowerCase()==="true"||!1)}),s(a)},[n]);const o=(a,l)=>{s(c=>({...c,[a]:l})),e(a,l)};return t?x.jsx("div",{className:"p-4 text-white",children:J("loading")}):x.jsx("div",{className:"p-2 text-white",children:x.jsxs("div",{className:"space-y-2",children:[x.jsxs("div",{className:"model-config-item",children:[x.jsx(er,{title:J("projectTypeTooltip")||"Specify file extensions (e.g., .py,.ts) to help the model understand the project context.",children:x.jsx("label",{className:"model-config-label",children:J("projectType")||"Project Type"})}),x.jsx("div",{className:"mt-1",children:x.jsx(ki,{mode:"tags",size:"small",style:{width:"100%"},placeholder:"e.g. .py,.ts",value:r.project_type?r.project_type.split(","):[],onChange:a=>o("project_type",a.join(",")),className:"custom-select",tokenSeparators:[","],maxTagCount:"responsive"})}),x.jsx("p",{className:"model-config-description",children:J("projectTypeDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx(er,{title:J("enableBuildIndexTooltip")||"If enabled, the system will automatically build or update the code index.",children:x.jsx("label",{className:"model-config-label",children:J("enableBuildIndexToggle")||"Enable Build Index"})}),x.jsx("div",{className:"mt-1",children:x.jsx(ki,{value:!r.skip_build_index,onChange:a=>o("skip_build_index",!a),size:"small",style:{width:"100%"},options:[{value:!0,label:J("enable")},{value:!1,label:J("disable")}]})}),x.jsx("p",{className:"model-config-description",children:J("enableBuildIndexDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx(er,{title:J("enableFilterIndexTooltip")||"If enabled, the system will automatically filter the index when processing queries.",children:x.jsx("label",{className:"model-config-label",children:J("enableFilterIndexToggle")||"Enable Filter Index"})}),x.jsx("div",{className:"mt-1",children:x.jsx(ki,{value:!r.skip_filter_index,onChange:a=>o("skip_filter_index",!a),size:"small",style:{width:"100%"},options:[{value:!0,label:J("enable")},{value:!1,label:J("disable")}]})}),x.jsx("p",{className:"model-config-description",children:J("enableFilterIndexDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("enableAgenticFilter")}),x.jsx("div",{className:"mt-1",children:x.jsx(ki,{value:r.enable_agentic_filter,onChange:a=>o("enable_agentic_filter",a),size:"small",style:{width:"100%"},options:[{value:!0,label:J("enable")},{value:!1,label:J("disable")}]})}),x.jsx("p",{className:"model-config-description",children:J("enableAgenticFilterDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("enableAgenticEdit")}),x.jsx("div",{className:"mt-1",children:x.jsx(ki,{value:r.enable_agentic_edit,onChange:a=>o("enable_agentic_edit",a),size:"small",style:{width:"100%"},options:[{value:!0,label:J("enable")},{value:!1,label:J("disable")}]})}),x.jsx("p",{className:"model-config-description",children:J("enableAgenticEditDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("indexMaxInputLength")}),x.jsx("div",{className:"mt-1",children:x.jsx(r2,{value:r.index_filter_model_max_input_length,onChange:a=>o("index_filter_model_max_input_length",a??51200),min:1e3,max:1e6,size:"small"})}),x.jsx("p",{className:"model-config-description",children:J("indexMaxInputLengthDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("conversationPruneSafeZoneTokens")||"Conversation Prune Safe Zone Tokens"}),x.jsx("div",{className:"mt-1",children:x.jsx(r2,{value:r.conversation_prune_safe_zone_tokens,onChange:a=>o("conversation_prune_safe_zone_tokens",a??51200),min:1e3,max:1e6,size:"small"})}),x.jsx("p",{className:"model-config-description",children:J("conversationPruneSafeZoneTokensDescription")||"Reserved token count during context pruning to avoid losing important information."})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("autoMergeMethod")}),x.jsx("div",{className:"mt-1",children:x.jsx(ki,{value:r.auto_merge,onChange:a=>o("auto_merge",a),size:"small",style:{width:"100%"},options:[{value:"wholefile",label:J("wholeFile")},{value:"editblock",label:J("editBlock")},{value:"diff",label:J("diff")},{value:"strict_diff",label:J("strictDiff")}]})}),x.jsx("p",{className:"model-config-description",children:J("autoMergeMethodDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("generateTimesSameModel")}),x.jsx("div",{className:"mt-1",children:x.jsx(r2,{value:r.generate_times_same_model,onChange:a=>o("generate_times_same_model",a??1),min:1,max:10,size:"small"})}),x.jsx("p",{className:"model-config-description",children:J("generateTimesSameModelDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("rankTimesSameModel")}),x.jsx("div",{className:"mt-1",children:x.jsx(r2,{value:r.rank_times_same_model,onChange:a=>o("rank_times_same_model",a??1),min:1,max:10,size:"small"})}),x.jsx("p",{className:"model-config-description",children:J("rankTimesSameModelDescription")})]})]})})},O_n=({availableKeys:n,onSettingChange:e})=>{const[t,i]=b.useState(!1),[r,s]=b.useState({enable_auto_fix_merge:!1,enable_auto_fix_lint:!1,enable_auto_fix_compile:!1,enable_active_context:!1,enable_active_context_in_generate:!1,enable_task_history:!1,include_project_structure:!0});b.useEffect(()=>{(async()=>{i(!0);try{const l=await fetch("/api/conf");if(!l.ok)throw new Error("Failed to fetch configuration");const d=(await l.json()).conf,u={...r};d.enable_auto_fix_merge!==void 0&&(u.enable_auto_fix_merge=d.enable_auto_fix_merge==="true"),d.enable_auto_fix_lint!==void 0&&(u.enable_auto_fix_lint=d.enable_auto_fix_lint==="true"),d.enable_auto_fix_compile!==void 0&&(u.enable_auto_fix_compile=d.enable_auto_fix_compile==="true"),d.enable_active_context!==void 0&&(u.enable_active_context=d.enable_active_context==="true"),d.enable_active_context_in_generate!==void 0&&(u.enable_active_context_in_generate=d.enable_active_context_in_generate==="true"),d.enable_task_history!==void 0&&(u.enable_task_history=d.enable_task_history==="true"),d.include_project_structure!==void 0&&(u.include_project_structure=d.include_project_structure==="true"),s(u)}catch(l){console.error("Error fetching current configuration:",l)}finally{i(!1)}})()},[]),b.useEffect(()=>{const a={...r};n.forEach(l=>{l.key==="enable_auto_fix_merge"&&a.enable_auto_fix_merge===void 0&&(a.enable_auto_fix_merge=l.default==="true"),l.key==="enable_auto_fix_lint"&&a.enable_auto_fix_lint===void 0&&(a.enable_auto_fix_lint=l.default==="true"),l.key==="enable_auto_fix_compile"&&a.enable_auto_fix_compile===void 0&&(a.enable_auto_fix_compile=l.default==="true"),l.key==="enable_active_context"&&a.enable_active_context===void 0&&(a.enable_active_context=l.default==="true"),l.key==="enable_active_context_in_generate"&&a.enable_active_context_in_generate===void 0&&(a.enable_active_context_in_generate=l.default==="true"),l.key==="enable_task_history"&&a.enable_task_history===void 0&&(a.enable_task_history=l.default==="true"),l.key==="include_project_structure"&&a.include_project_structure===void 0&&(a.include_project_structure=l.default==="true"||l.default===void 0)}),s(a)},[n]);const o=(a,l)=>{s(c=>({...c,[a]:l})),e(a,l)};return t?x.jsx("div",{className:"p-4 text-white",children:J("loading")}):x.jsxs("div",{children:[x.jsx("h3",{className:"settings-title",children:J("advancedSettings")}),x.jsxs("div",{className:"space-y-4",children:[x.jsxs("div",{className:"model-config-item",children:[x.jsxs("div",{className:"flex justify-between items-center",children:[x.jsx("label",{className:"model-config-label",children:J("advancedSettings_enableAutoFixMerge")}),x.jsx(Cf,{checked:r.enable_auto_fix_merge,onChange:a=>o("enable_auto_fix_merge",a),className:"bg-gray-600"})]}),x.jsx("p",{className:"model-config-description",children:J("advancedSettings_enableAutoFixMergeDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsxs("div",{className:"flex justify-between items-center",children:[x.jsx("label",{className:"model-config-label",children:J("enableAutoFixLint")}),x.jsx(Cf,{checked:r.enable_auto_fix_lint,onChange:a=>o("enable_auto_fix_lint",a),className:"bg-gray-600"})]}),x.jsx("p",{className:"model-config-description",children:J("enableAutoFixLintDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsxs("div",{className:"flex justify-between items-center",children:[x.jsx("label",{className:"model-config-label",children:J("enableAutoFixCompile")}),x.jsx(Cf,{checked:r.enable_auto_fix_compile,onChange:a=>o("enable_auto_fix_compile",a),className:"bg-gray-600"})]}),x.jsx("p",{className:"model-config-description",children:J("enableAutoFixCompileDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsxs("div",{className:"flex justify-between items-center",children:[x.jsx("label",{className:"model-config-label",children:J("enableActiveContext")}),x.jsx(Cf,{checked:r.enable_active_context,onChange:a=>o("enable_active_context",a),className:"bg-gray-600"})]}),x.jsx("p",{className:"model-config-description",children:J("enableActiveContextDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsxs("div",{className:"flex justify-between items-center",children:[x.jsx("label",{className:"model-config-label",children:J("enableActiveContextInGenerate")}),x.jsx(Cf,{checked:r.enable_active_context_in_generate,onChange:a=>o("enable_active_context_in_generate",a),className:"bg-gray-600"})]}),x.jsx("p",{className:"model-config-description",children:J("enableActiveContextInGenerateDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsxs("div",{className:"flex justify-between items-center",children:[x.jsx("label",{className:"model-config-label",children:J("enableTaskHistory")}),x.jsx(Cf,{checked:r.enable_task_history,onChange:a=>o("enable_task_history",a),className:"bg-gray-600"})]}),x.jsx("p",{className:"model-config-description",children:J("enableTaskHistoryDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsxs("div",{className:"flex justify-between items-center",children:[x.jsx("label",{className:"model-config-label",children:J("includeProjectStructure")}),x.jsx(Cf,{checked:r.include_project_structure,onChange:a=>o("include_project_structure",a),className:"bg-gray-600"})]}),x.jsx("p",{className:"model-config-description",children:J("includeProjectStructureDescription")})]})]})]})},{Option:aOe}=ki,B_n=({visible:n,server:e,onCancel:t,onUpdateSuccess:i})=>{const[r]=Rn.useForm(),[s,o]=b.useState([]),[a,l]=b.useState(1),[c,d]=b.useState(!1);b.useEffect(()=>{if(e&&n){const p=e.env?Object.entries(e.env).map(([A,v],_)=>({id:_+1,key:A,value:v})):[];o(p),l(p.length+1),r.setFieldsValue({description:e.description||"",mcp_type:e.mcp_type||"command",command:e.command||"",args:e.args||[],url:e.url||""})}else n||(r.resetFields(),o([]))},[e,n,r]);const u=()=>{o([...s,{id:a,key:"",value:""}]),l(a+1)},h=p=>{o(s.filter(A=>A.id!==p))},f=(p,A,v)=>{o(s.map(_=>_.id===p?{..._,[A]:v}:_))},g=p=>{const A=s.filter(_=>_.key),v={};return A.forEach(_=>{v[_.key]=_.value}),{name:e==null?void 0:e.name,description:p.description||"",mcp_type:p.mcp_type||"command",command:p.mcp_type==="command"?p.command||"":void 0,args:p.args||[],env:Object.keys(v).length>0?v:void 0,url:p.mcp_type==="sse"?p.url||"":void 0}},m=async()=>{if(e)try{const p=await r.validateFields();for(const y of s)if(!y.key&&y.value){yt.error(J("envKeyRequired")||"Environment variable key is required if value is provided");return}d(!0);const A=g(p),v=await fetch("/api/mcp/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)}),_=await v.json();if(!v.ok)throw new Error(_.detail||_.message||"Updating server failed");yt.success(_.message||J("marketplaceUpdateSuccess",{name:e.name})),i(),t()}catch(p){console.error("Error updating server:",p),p instanceof Error&&p.message.includes("Failed to validate fields")||yt.error(J("marketplaceUpdateError",{error:p instanceof Error?p.message:String(p)}))}finally{d(!1)}};return x.jsx(Gr,{title:`${J("edit")||"Edit"} MCP Server: ${e==null?void 0:e.name}`,visible:n,onCancel:t,footer:[x.jsx(an,{onClick:t,className:"dark-button",children:J("cancel")||"Cancel"},"back"),x.jsx(an,{type:"primary",loading:c,onClick:m,className:"dark-button",children:J("update")||"Update"},"submit")],width:600,destroyOnClose:!0,className:"dark-modal",children:x.jsxs(Rn,{form:r,layout:"vertical",className:"dark-form",children:[x.jsx(Rn.Item,{label:"Name (Read-only)",children:x.jsx(Xn,{className:"dark-input",readOnly:!0,value:e==null?void 0:e.name})}),x.jsx(Rn.Item,{name:"description",label:J("mcpServerDescription")||"Description",children:x.jsx(Xn,{className:"dark-input",placeholder:"e.g., My updated custom MCP server"})}),x.jsx(Rn.Item,{name:"mcp_type",label:J("mcpServerType")||"Type",children:x.jsxs(ki,{className:"dark-select",dropdownClassName:"dark-select-dropdown",placeholder:"Select server type",onChange:p=>{p==="sse"&&yt.info(J("mcpSseNotSupported")||"SSE type is not currently supported."),r.validateFields(["command","url"])},children:[x.jsx(aOe,{value:"command",children:"Command"}),x.jsx(aOe,{value:"sse",children:"SSE (Server-Sent Events)"})]})}),x.jsx(Rn.Item,{noStyle:!0,shouldUpdate:(p,A)=>p.mcp_type!==A.mcp_type,children:({getFieldValue:p})=>p("mcp_type")==="command"?x.jsx(Rn.Item,{name:"command",label:J("mcpServerCommand")||"Command",rules:[{required:!0,message:J("commandRequired")||"Please enter a command"}],children:x.jsx(Xn,{className:"dark-input",placeholder:"e.g., python, npm, /path/to/executable"})}):null}),x.jsx(Rn.Item,{noStyle:!0,shouldUpdate:(p,A)=>p.mcp_type!==A.mcp_type,children:({getFieldValue:p})=>p("mcp_type")==="sse"?x.jsx(Rn.Item,{name:"url",label:J("mcpServerUrl")||"URL",rules:[{required:!0,message:J("urlRequired")||"Please enter a URL for SSE server"}],children:x.jsx(Xn,{className:"dark-input",placeholder:"e.g., http://localhost:8000/events"})}):null}),x.jsx(Rn.Item,{name:"args",label:J("mcpServerArgs")||"Arguments",children:x.jsx(ki,{mode:"tags",className:"dark-select compiler-select compiler-tag-select",dropdownClassName:"dark-select-dropdown",placeholder:"Enter arguments and press Enter/Space",tokenSeparators:[" ",`
|
1339
|
+
${m?"text-gray-400 hover:text-gray-300":"text-blue-500 hover:text-blue-600"}`,onClick:m?Q:f,disabled:I,title:J(m?I?"cancelling":"stop":"send"),children:(()=>{let G;return m?I?G=x.jsx("div",{className:"relative",children:x.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[x.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),x.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}):G=x.jsx("div",{className:"relative",children:x.jsx("svg",{className:"h-3.5 w-3.5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}):G=x.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5 transform rotate-45",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})}),x.jsx("div",{className:"flex items-center justify-center",children:G})})()})]})})})]})]})};class a_n extends YR.EventEmitter{constructor(){super(),this.eventSource=null,this.streamEvents=new Map,this.lastEventType=null,this.messageId=0,this.currentStreamMessageId=null,this.isStreamingActive=!1,this.eventFileId=null}async executeCommand(e,t=!1){try{const i=await fetch("/api/auto-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e,include_conversation_history:t})});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);const r=await i.json();return this.eventFileId=r.event_file_id,this.startEventStream(),{event_file_id:r.event_file_id}}catch(i){throw console.error("Error executing command:",i),i}}startEventStream(){if(this.closeEventStream(),!this.eventFileId){console.error("No event file ID available");return}this.eventSource=new EventSource(`/api/auto-command/events?event_file_id=${this.eventFileId}`),this.eventSource.onmessage=e=>{try{const t=JSON.parse(e.data);this.handleEvent(t)}catch(t){console.error("Error parsing event data:",t)}},this.eventSource.onerror=e=>{console.error("EventSource error:",e),this.closeEventStream()}}handleEvent(e){let t;switch(e.event_type==="STREAM"?this.lastEventType!=="STREAM"?(t=`msg-${this.messageId++}`,this.currentStreamMessageId=t):t=this.currentStreamMessageId||`msg-${this.messageId++}`:(t=`msg-${this.messageId++}`,this.lastEventType==="STREAM"&&this.currentStreamMessageId&&this.finalizeStreamMessage(this.currentStreamMessageId),this.currentStreamMessageId=null),e.event_type){case"STREAM":this.handleStreamEvent(e,t);break;case"RESULT":this.handleResultEvent(e,t);break;case"ASK_USER":this.handleAskUserEvent(e,t);break;case"USER_RESPONSE":this.handleUserResponseEvent(e,t);break;case"ERROR":this.handleErrorEvent(e,t);break;case"COMPLETION":this.handleCompletionEvent(e,t);break;default:console.warn("Unknown event type:",e.event_type)}this.lastEventType=e.event_type}handleStreamEvent(e,t){const i=e.content;this.isStreamingActive=!0;let r=this.streamEvents.get(t);if(r)r.content+=i.content,r.isThinking=i.is_thinking,r.isStreaming=!0,i.state==="complete"?(r.isStreaming=!1,this.streamEvents.delete(t),this.emit("message",r),this.isStreamingActive=!1):(this.streamEvents.set(t,r),this.emit("message",r));else{const s={id:t,type:e.event_type,content:i.content,contentType:i.content_type,isThinking:i.is_thinking,isStreaming:!0,eventId:e.event_id,language:i.language,metadata:e.metadata};i.state!=="complete"?this.streamEvents.set(t,s):(s.isStreaming=!1,this.isStreamingActive=!1),this.emit("message",s)}}handleResultEvent(e,t){const i=e.content;let r,s=i.content_type,o={...i.metadata,...e.metadata};typeof i.content=="string"?r=i.content:this.isTokenStatContent(i.content)?(s="token_stat",r=JSON.stringify(i.content),o={...o,model_name:i.content.model_name,elapsed_time:i.content.elapsed_time,first_token_time:i.content.first_token_time,input_tokens:i.content.input_tokens,output_tokens:i.content.output_tokens,input_cost:i.content.input_cost,output_cost:i.content.output_cost,speed:i.content.speed}):this.isSummaryContent(i.content)?(s="summary",r=i.content.summary):this.isIndexBuildStartContent(i.content)?(s="index_build_start",r=`Processing files: ${i.content.file_number}/${i.content.total_files}`,o={...o,file_number:i.content.file_number,total_files:i.content.total_files}):this.isIndexBuildEndContent(i.content)?(s="index_build_end",r=`Index build completed: Updated ${i.content.updated_files} files, Removed ${i.content.removed_files} files`,o={...o,updated_files:i.content.updated_files,removed_files:i.content.removed_files,input_tokens:i.content.input_tokens,output_tokens:i.content.output_tokens,input_cost:i.content.input_cost,output_cost:i.content.output_cost}):this.isCommandPrepareStatContent(i.content)?(s="command_prepare_stat",r=`Command: ${i.content.command}`,o={...o,command:i.content.command,parameters:i.content.parameters}):this.isCommandExecuteStatContent(i.content)?(s="command_execute_stat",r=i.content.content,o={...o,command:i.content.command}):this.isContextUsedContent(i.content)?(s="context_used",r=i.content.description,o={...o,files:i.content.files}):r=JSON.stringify(i.content);const a={id:t,type:e.event_type,content:r,contentType:s,metadata:o,eventId:e.event_id};this.emit("message",a)}isTokenStatContent(e){return e&&typeof e.model_name=="string"&&typeof e.elapsed_time=="number"&&typeof e.input_tokens=="number"&&typeof e.output_tokens=="number"}isCommandPrepareStatContent(e){return e&&typeof e.command=="string"&&typeof e.parameters=="object"}isSummaryContent(e){return e&&typeof e.summary=="string"}isCommandExecuteStatContent(e){return e&&typeof e.command=="string"&&typeof e.content=="string"}isIndexBuildStartContent(e){return e&&typeof e.file_number=="number"&&typeof e.total_files=="number"}isIndexBuildEndContent(e){return e&&typeof e.updated_files=="number"&&typeof e.removed_files=="number"&&typeof e.input_tokens=="number"&&typeof e.output_tokens=="number"}isContextUsedContent(e){return e&&Array.isArray(e.files)&&typeof e.title=="string"&&typeof e.description=="string"}handleAskUserEvent(e,t){const i=e.content,r={id:t,type:e.event_type,content:i.prompt,options:i.options,responseRequired:i.required,eventId:e.event_id};this.emit("message",r)}handleUserResponseEvent(e,t){const i=e.content,r={id:t,type:e.event_type,content:i.response,isUser:!0,eventId:e.event_id,responseTo:e.response_to};this.emit("message",r)}handleErrorEvent(e,t){const i=e.content,r={id:t,type:e.event_type,content:i.error_message,metadata:i.details,eventId:e.event_id};this.emit("message",r),setTimeout(()=>{this.emit("taskComplete",!0),Ki.publish(Qi.CODING.TASK_COMPLETE,{success:!0,event_file_id:this.eventFileId})},300)}handleCompletionEvent(e,t){const i=e.content,r={id:t,type:e.event_type,content:i.success_message,eventId:e.event_id,metadata:{success_code:i.success_code,completion_time:i.completion_time,details:i.details,result:i.result}};this.emit("message",r),setTimeout(()=>{this.emit("taskComplete",!1),Ki.publish(Qi.CODING.TASK_COMPLETE,{success:!0,event_file_id:this.eventFileId})},1e3)}finalizeStreamMessage(e){const t=this.streamEvents.get(e);t&&(t.isStreaming=!1,t.isThinking=!1,this.streamEvents.delete(e),this.emit("message",t))}closeEventStream(){this.eventSource&&(this.eventSource.close(),this.eventSource=null),Array.from(this.streamEvents.keys()).forEach(e=>{this.finalizeStreamMessage(e)}),this.streamEvents.clear(),this.lastEventType=null,this.currentStreamMessageId=null,this.isStreamingActive=!1}async sendUserResponse(e,t){if(!this.eventFileId)throw new Error("No event file ID available");try{const i=await fetch("/api/auto-command/response",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event_id:e,event_file_id:this.eventFileId,response:t})});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`)}catch(i){throw console.error("Error sending user response:",i),i}}async cancelTask(){if(!this.eventFileId){console.warn("No event file ID available to cancel task.");return}console.log(`AgenticEditService: Cancelling task with event_file_id: ${this.eventFileId}`);try{const e=await fetch("/api/auto-command/cancel",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event_file_id:this.eventFileId})});if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);console.log(`AgenticEditService: Task cancellation request sent for event_file_id: ${this.eventFileId}`),this.closeEventStream()}catch(e){console.error("Error cancelling agentic edit task:",e)}}}const gP=new a_n;class l_n extends YR.EventEmitter{constructor(){super(),this.config={human_as_model:!1,skip_build_index:!0,project_type:"py",extra_conf:{},available_keys:[]},this.fetchConfig(),this.fetchConfigKeys()}getConfig(){return{...this.config}}async fetchConfig(){try{const e=await fetch("/api/conf");if(!e.ok)throw new Error("Failed to fetch configuration");const t=await e.json(),{human_as_model:i,skip_build_index:r,project_type:s,...o}=t.conf;return this.config={...this.config,human_as_model:i==="true",skip_build_index:r==="true",project_type:s,extra_conf:this.convertToStringValues(o)},this.emit("configUpdated",this.config),this.config}catch(e){return console.error("Error fetching config:",e),this.emit("error","Failed to fetch configuration"),null}}convertToStringValues(e){const t={};for(const i in e)t[i]=String(e[i]);return t}async fetchConfigKeys(){try{const e=await fetch("/api/conf/keys");if(!e.ok)throw new Error("Failed to fetch configuration keys");const t=await e.json();return this.config={...this.config,available_keys:t.keys},this.emit("configKeysUpdated",this.config.available_keys),this.config.available_keys}catch(e){return console.error("Error fetching configuration keys:",e),this.emit("error","Failed to fetch configuration keys"),null}}async updateConfig(e,t){try{if(!(await fetch("/api/conf",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({[e]:String(t)})})).ok)throw new Error("Failed to update configuration");return e==="human_as_model"||e==="skip_build_index"?this.config={...this.config,[e]:!!t}:e==="project_type"?this.config={...this.config,project_type:String(t)}:this.config={...this.config,extra_conf:{...this.config.extra_conf,[e]:String(t)}},this.emit("configUpdated",this.config),!0}catch(i){return console.error("Error updating config:",i),this.emit("error",`Failed to update configuration key: ${e}`),!1}}async reloadConfig(){await this.fetchConfig(),await this.fetchConfigKeys()}}const pP=new l_n,tGe=n=>{const e=new Audio(n);return e.load(),e},c_n=tGe("/sounds/gentle-notification.wav"),d_n=tGe("/sounds/soft-chime.wav"),u_n=(n=.3)=>{try{const e=c_n.cloneNode();e.volume=Math.max(0,Math.min(1,n)),e.play().catch(t=>{console.warn("Failed to play sound effect:",t)})}catch(e){console.error("Error playing sound effect:",e)}},h_n=(n=.3)=>{try{const e=d_n.cloneNode();e.volume=Math.max(0,Math.min(1,n)),e.play().catch(t=>{console.warn("Failed to play sound effect:",t)})}catch(e){console.error("Error playing sound effect:",e)}},f_n=()=>{h_n(.3)},g_n=(n=.3)=>{u_n(n)},p_n=({setPreviewFiles:n,setRequestId:e,setActivePanel:t,setClipboardContent:i,clipboardContent:r,projectName:s="",setSelectedFiles:o})=>{const[a,l]=Se.useState(!1),[c,d]=b.useState(!1),[u,h]=b.useState(!1),f=b.useRef(!1);b.useEffect(()=>{f.current=u},[u]);const g=()=>{_([]);const ze=new Date().toISOString().replace(/[:.]/g,"-");ve(`chat_${ze}`),Ae(!0)},m=()=>{Ae(!1),ve("")},p=async()=>{if(!be.trim()){yt.error("Chat name cannot be empty");return}try{W(be),_([]),P(ze=>[be,...ze]),await Ke(be,[]),await ut(be);try{(await fetch("/api/chat-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:"/new"})})).ok||console.warn("Failed to send /new command to chat router")}catch(ze){console.error("Error sending /new command:",ze)}yt.success("New chat created successfully"),Ae(!1)}catch(ze){console.error("Error creating new chat:",ze),yt.error("Failed to create new chat")}},A=async()=>{const Ze=`chat_${new Date().toISOString().replace(/[:.]/g,"-")}`;try{_([]),W(Ze),P(lt=>[Ze,...lt.filter(St=>St!==Ze)]),await Ke(Ze,[]),await ut(Ze);try{(await fetch("/api/chat-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:"/new"})})).ok||console.warn("Failed to send /new command to chat router")}catch(lt){console.error("Error sending /new command:",lt)}yt.success("New chat created successfully")}catch(lt){console.error("Error creating new chat directly:",lt),yt.error("Failed to create new chat")}},[v,_]=b.useState([]),[y,C]=b.useState([]),[S,E]=b.useState(!1),[L,I]=b.useState(""),[T,D]=b.useState([]),[B,R]=b.useState({human_as_model:!1,extra_conf:{},available_keys:[]}),[O,P]=b.useState([]),[$,W]=b.useState(""),[j,H]=b.useState(!1),[F,U]=b.useState(!1),K=b.useRef(null),V=b.useRef(null),[Q,te]=b.useState(!0),se=b.useRef(!1);b.useEffect(()=>{se.current=Q},[Q]);const[Z,G]=b.useState(!1),[q,X]=b.useState(!1),[ie,oe]=b.useState(!1),[ce,Ae]=b.useState(!1),[be,ve]=b.useState(""),[xe,Ue]=b.useState(!0),[He,$e]=b.useState(!1),[Ne,Ce]=b.useState(!1),[Ie,Re]=b.useState(0),[Fe,_e]=b.useState(!1),[We,Xe]=b.useState({inputTokens:0,outputTokens:0,totalCost:0,contextWindowUsage:0,maxContextWindow:100,cacheHits:0,cacheMisses:0}),et=b.useRef("");b.useEffect(()=>{et.current=L},[L]),b.useEffect(()=>{let ze=0,Ze=0,lt=0,St=0,kt=100,qt=0,Ft=0;v.forEach(ln=>{var $t,Ve;ln.contentType==="token_stat"&&ln.metadata&&(ze+=ln.metadata.input_tokens||0,Ze+=ln.metadata.output_tokens||0,lt+=(ln.metadata.input_cost||0)+(ln.metadata.output_cost||0),St=Math.max(St,ln.metadata.context_window||0),kt=ln.metadata.max_context_window||kt,qt+=ln.metadata.cache_hit||0,Ft+=ln.metadata.cache_miss||0),(($t=ln.metadata)==null?void 0:$t.stream_out_type)==="index_build"&&((Ve=ln.metadata)!=null&&Ve.input_tokens)&&(ze+=ln.metadata.input_tokens||0,Ze+=ln.metadata.output_tokens||0,lt+=(ln.metadata.input_cost||0)+(ln.metadata.output_cost||0),St=Math.max(St,ln.metadata.context_window||0),kt=ln.metadata.max_context_window||kt,qt+=ln.metadata.cache_hit||0,Ft+=ln.metadata.cache_miss||0)}),Xe({inputTokens:ze,outputTokens:Ze,totalCost:lt,contextWindowUsage:St,maxContextWindow:kt,cacheHits:qt,cacheMisses:Ft})},[v]),b.useEffect(()=>{var ze;xe&&((ze=V.current)==null||ze.scrollIntoView({behavior:"smooth"}))},[v,xe]);const tt=b.useCallback(()=>{const ze=document.getElementById("chat-messages-container");if(ze){const Ze=ze.scrollHeight-ze.scrollTop-ze.clientHeight<100;Ue(Ze)}},[]);b.useEffect(()=>{const ze=document.getElementById("chat-messages-container");return ze&&(ze.addEventListener("scroll",tt),tt()),()=>{const Ze=document.getElementById("chat-messages-container");Ze&&Ze.removeEventListener("scroll",tt)}},[tt]),b.useEffect(()=>{q&&(Me(),X(!1))},[q]),b.useEffect(()=>{const ze=lt=>{R(lt)},Ze=lt=>{yt.error(lt)};return pP.on("configUpdated",ze),pP.on("error",Ze),()=>{pP.off("configUpdated",ze),pP.off("error",Ze)}},[]),b.useEffect(()=>{rt(),Pe()},[]);const rt=async()=>{try{const Ze=await(await fetch("/api/chat-lists")).json();if(Ze.chat_lists&&Ze.chat_lists.length>0)W(Ze.chat_lists[0]),P(Ze.chat_lists),await Ye(Ze.chat_lists[0]);else{const St=`chat_${new Date().toISOString().replace(/[:.]/g,"-")}`;W(St),P([St])}}catch(ze){console.error("Error fetching chat lists:",ze),yt.error("Failed to fetch chat lists")}},Pe=async()=>{try{const ze=await fetch("/api/chat-session/name");if(!ze.ok)throw new Error("Failed to fetch current session name");const Ze=await ze.json();Ze.session_name&&(W(Ze.session_name),O.includes(Ze.session_name)||P(lt=>[Ze.session_name,...lt]),await Ye(Ze.session_name))}catch(ze){console.error("Error getting current session name:",ze)}},ut=async ze=>{if(!ze.trim())return!1;try{if(!(await fetch("/api/chat-session/name",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_name:ze})})).ok)throw new Error("Failed to set current session name");return!0}catch(Ze){return console.error("Error setting current session name:",Ze),!1}},Ke=async(ze,Ze=[])=>{if(console.log("save chat list:",ze),console.log("messages:",Ze),!ze.trim()){yt.error("Please enter a name for the chat list");return}try{const lt=await fetch("/api/chat-lists/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:ze,messages:Ze})});lt.ok?(H(!1),rt(),await ut(ze)):console.error("Failed to save chat list",lt.json())}catch(lt){console.error("Error saving chat list:",lt)}},Ye=async ze=>{try{const St=(await(await fetch(`/api/chat-lists/${ze}`)).json()).messages.map(kt=>"role"in kt?{id:kt.id||Date.now().toString(),type:kt.role==="user"?"USER_RESPONSE":"RESULT",content:kt.content,contentType:kt.contentType||"markdown",language:kt.language,metadata:kt.metadata,isUser:kt.role==="user",isStreaming:!1,isThinking:!1}:{...kt,isStreaming:!1,isThinking:!1,type:kt.type||(kt.isUser?"USER_RESPONSE":"RESULT"),contentType:kt.contentType||"markdown"});_(St)}catch(Ze){console.error("Error loading chat list:",Ze),yt.error("Failed to load chat list")}},nt=()=>{if(v.length>0){const ze=v.find(Ze=>Ze.isUser||Ze.type==="USER_RESPONSE");if(ze&&ze.content)return ze.content.substring(0,4)}return"New Chat"},Qe=async ze=>{try{(await fetch(`/api/chat-lists/${ze}`,{method:"DELETE"})).ok?(yt.success("Chat list deleted successfully"),rt()):yt.error("Failed to delete chat list")}catch(Ze){console.error("Error deleting chat list:",Ze),yt.error("Failed to delete chat list")}},ct=async(ze,Ze)=>{try{if(!Ze.trim())return yt.error("Chat name cannot be empty"),!1;const lt=await fetch("/api/chat-lists/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({old_name:ze,new_name:Ze})});if(!lt.ok){const St=await lt.json();throw new Error(St.detail||"Failed to rename chat list")}return P(St=>{const kt=[...St],qt=kt.indexOf(ze);return qt!==-1&&(kt[qt]=Ze),kt}),$===ze&&W(Ze),yt.success(`Chat renamed to ${Ze}`),!0}catch(lt){return console.error("Error renaming chat list:",lt),yt.error(`Failed to rename chat: ${lt.message||"Unknown error"}`),!1}},[Wt,tn]=b.useState(null),[En,Tt]=b.useState(0),Pt=b.useCallback(async ze=>{if(ze)yt.error("Task completed with errors"),f.current&&(console.log("play error sound"),g_n());else{yt.success("Task completed successfully");const Ze=et.current;if(_e(!0),await new Promise(lt=>setTimeout(lt,0)),se.current&&Ze)try{const lt=await fetch(`/api/current-changes?event_file_id=${Ze}`);if(!lt.ok)throw new Error("Failed to fetch current changes");const St=await lt.json();if(console.log("ChatPanel: Received current changes:",St),St.commits&&St.commits.length>0){const kt=St.commits[0].hash,qt=await fetch(`/api/commits/${kt}`);if(!qt.ok)throw new Error("Failed to fetch commit details");const ln=(await qt.json()).files;console.log("ChatPanel: Changed files:",ln);const $t=ln.map(Ve=>({path:Ve.filename,isSelected:!0,modifiedBy:"expert_chat_box"}));o($t),t("code")}}catch(lt){console.error("Error fetching current changes:",lt),yt.error("Failed to fetch changed files")}}U(!1),e(""),I(""),f.current&&(console.log("play task completed"),f_n())},[Q,o,t,U,e,I,_e,u]),Jt=b.useCallback(async()=>{const ze=Date.now();if(ze-En>=3e4)try{const lt=await fetch("/api/file-groups");if(!lt.ok)throw new Error("Failed to fetch file groups");const St=await lt.json();C(St.groups),Tt(ze)}catch{console.error("Failed to load file groups")}},[En]);b.useEffect(()=>{Jt()},[]);const Ut=(ze,Ze)=>{K.current=ze},Kt=ze=>{const Ze=Date.now(),lt=O3(),St=Ie+1;Re(St);const kt={id:`user-${lt}-${Ze}-${St}`,type:"USER_RESPONSE",content:ze,contentType:"markdown",isUser:!0,isStreaming:!0,isThinking:!1};return _(qt=>{const Ft=[...qt,kt];return Ft.length>0&&$&&Ke($,Ft),Ft}),kt.id},_t=ze=>{const Ze=Date.now(),lt=O3(),St=Ie+1;Re(St);const kt={id:`bot-${lt}-${Ze}-${St}`,type:"RESULT",content:ze,contentType:"markdown",isUser:!1,isStreaming:!1,isThinking:!1};return _(qt=>{const Ft=[...qt,kt];return Ft.length>0&&$&&Ke($,Ft),Ft}),kt.id},ae=(ze,Ze)=>{_(lt=>lt.map(St=>St.id===ze?{...St,isStreaming:Ze==="sending",isThinking:Ze==="sending"}:St))},ue=async()=>{},ye=()=>v;b.useEffect(()=>{Fe&&$&&v.length>0&&(Ke($,v),console.log("Chat list saved with latest messages:",$),_e(!1))},[v,Fe,$]);const Le=ze=>{ze.on("message",Ze=>{console.log("ChatPanel: Received message from service:",ze===kS?"chatService":"codingService",Ze.type,Ze.id),Ki.publish(Qi.CHAT.NEW_MESSAGE,Ze),_(lt=>{const St=lt.findIndex(kt=>kt.id===Ze.id);if(St!==-1){const kt=[...lt];return kt[St]=Ze,kt}else return[...lt,Ze]})}),ze.on("taskComplete",Pt)},Ee=b.useCallback(ze=>{_(Ze=>{const lt=Ze.findIndex(St=>St.id===ze.messageId);return lt===-1?Ze:Ze.slice(0,lt)}),K.current&&(K.current.setValue(ze.messageContent),setTimeout(()=>{K.current&&K.current.focus()},100)),setTimeout(()=>{var Ze;(Ze=V.current)==null||Ze.scrollIntoView({behavior:"smooth"})},200)},[]);b.useEffect(()=>{Le(kS),Le(H2),Le(gP);const ze=Ki.subscribe(Qi.CHAT.REFRESH_FROM_MESSAGE,Ee),Ze=Ki.subscribe(Qi.CHAT.NEW_MESSAGE,Ft=>{if(Ft&&typeof Ft=="object"&&Ft.action&&Ft.commit_id){console.log("ChatPanel: Received object message from eventBus:",Ft);const{action:ln,commit_id:$t,mode:Ve}=Ft;Ve==="chat"&&te(!1);let Rt="";ln==="review"&&(Rt=`/review commit=${$t}`),Rt&&K.current&&(K.current.setValue(Rt),X(!0))}else typeof Ft=="string"&&(console.log("ChatPanel: Received string message from eventBus:",Ft),K.current&&(K.current.setValue(Ft),X(!0)))}),lt=Ki.subscribe(Qi.RAG.ENABLED_CHANGED,Ft=>{console.log("ChatPanel: RAG enabled changed to",Ft),$e(Ft)}),St=Ki.subscribe(Qi.MCPS.ENABLED_CHANGED,Ft=>{console.log("ChatPanel: MCPs enabled changed to",Ft),Ce(Ft)}),kt=Ki.subscribe(Qi.CHAT.NEW_CHAT,A),qt=Ki.subscribe("agentic.mode.changed",Ft=>{console.log("ChatPanel: Step By Step mode changed to",Ft),l(Ft)});return()=>{kS.removeAllListeners(),H2.removeAllListeners(),gP.removeAllListeners(),ze(),Ze(),lt(),kt(),St(),qt()}},[Ee]);const Me=async()=>{var lt,St,kt;const ze=(St=(lt=K.current)==null?void 0:lt.getValue())==null?void 0:St.trim();if(!ze){yt.warning("Please enter a message");return}$&&v.length>0&&(await Ke($,v),console.log("Chat list saved before sending new message:",$));const Ze=Kt(ze);(kt=K.current)==null||kt.setValue(""),U(!0),ae(Ze,"sent");try{let qt=ze;if(c){console.log("ChatPanel: Rule mode enabled, accessing context prompt");try{const Ft=await fetch("/api/rules/context/prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:ze})});if(!Ft.ok)throw new Error(`Failed to get rule context prompt: ${Ft.statusText}`);const ln=await Ft.json();ln.prompt&&(qt=ln.prompt,console.log("ChatPanel: Received prompt from rules API"),_t(J("ruleModePromptGenerated")))}catch(Ft){console.error("Error fetching rule context prompt:",Ft),yt.error("获取Rule分析提示失败,将使用原始文本")}}if(Q||c)if(a){console.log("ChatPanel: Step By Step enabled, using agenticEditService");const Ft=await gP.executeCommand(qt,!0);console.log("ChatPanel: Received result from agenticEditService:",Ft),e(Ft.event_file_id),I(Ft.event_file_id)}else{console.log("ChatPanel: Sending message to codingService");const Ft=await H2.executeCommand(`${qt}`);console.log("ChatPanel: Received result from codingService:",Ft),e(Ft.event_file_id),I(Ft.event_file_id)}else{console.log("ChatPanel: Sending message to chatService");let Ft=qt;if(He&&Ne&&!Q){Gr.warning({title:J("ragMcpConflictTitle"),content:J("ragMcpConflictContent"),centered:!0}),U(!1);return}He&&!Ne&&!Q?(console.log("ChatPanel: RAG enabled, prepending /rag to message"),Ft=`/rag ${qt}`):Ne&&!He&&!Q&&(console.log("ChatPanel: MCPs enabled, prepending /mcp to message"),Ft=`/mcp ${qt}`);const ln=await kS.executeCommand(Ft);console.log("ChatPanel: Received result from chatService:",ln),e(ln.event_file_id),I(ln.event_file_id)}}catch(qt){console.error("Error sending message:",qt),yt.error("Failed to send message"),ae(Ze,"error"),_t(J("processingError")),U(!1)}},Ge=async()=>{try{Q||c?a?(console.log("ChatPanel: Stopping agentic edit task"),await gP.cancelTask()):(console.log("ChatPanel: Stopping coding task"),await H2.cancelTask()):(console.log("ChatPanel: Stopping chat task"),await kS.cancelTask()),yt.info(J("generationStopped")),U(!1)}catch(ze){console.error("Error stopping generation:",ze),yt.error("Failed to stop generation")}},ht=async()=>{const ze=document.getElementById("chat-messages-container");if(!ze){yt.error("未找到消息列表区域");return}const Ze=ze.style.height,lt=ze.style.maxHeight,St=ze.style.overflow;try{ze.style.height=ze.scrollHeight+"px",ze.style.maxHeight="none",ze.style.overflow="visible",await new Promise(ln=>requestAnimationFrame(ln));const qt=(await q$e(ze,{backgroundColor:"#1a1a1a",scale:2,useCORS:!0})).toDataURL("image/png"),Ft=document.createElement("a");Ft.href=qt,Ft.download=`chat_${new Date().toISOString().replace(/[:.]/g,"-")}.png`,Ft.click()}catch(kt){console.error("导出图片失败:",kt),yt.error("导出图片失败")}finally{ze.style.height=Ze,ze.style.maxHeight=lt,ze.style.overflow=St}},gt=async ze=>{Gr.confirm({title:"确认删除",content:`确定要删除对话 "${ze}" 吗?此操作不可撤销。`,okText:"删除",okType:"danger",cancelText:"取消",onOk:async()=>{await Qe(ze),yt.success("对话已删除")}})};return[J("newChat"),...O.length>0?[{type:"divider"}]:[],...O.map(ze=>({key:ze,label:x.jsxs("div",{className:`flex justify-between items-center w-full group ${$===ze?"bg-indigo-700/40 rounded-sm":""}`,children:[x.jsx("span",{className:`truncate max-w-[180px] ${$===ze?"text-white font-medium":"text-gray-200"}`,children:ze}),x.jsx(an,{type:"text",size:"small",className:"opacity-0 group-hover:opacity-100 transition-opacity text-white",icon:x.jsx(Ac,{}),onClick:Ze=>{Ze.stopPropagation(),gt(ze)}})]})}))],x.jsxs(x.Fragment,{children:[x.jsxs(bb,{className:"h-screen flex flex-col overflow-hidden",children:[x.jsxs(bb.Header,{className:"bg-gray-800 px-2 py-0.5 h-8 flex justify-between items-center border-b border-gray-700 shadow-sm transition-all duration-300 sticky top-0 z-10",children:[x.jsxs("div",{className:"flex items-center space-x-2 flex-1 min-w-0 overflow-hidden",children:[x.jsxs("div",{className:"flex items-center flex-shrink-0",children:[x.jsx("svg",{className:"w-3 h-3 mr-0.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z",stroke:"#8B5CF6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),x.jsx("span",{className:"bg-gradient-to-r from-indigo-500 to-purple-500 text-transparent bg-clip-text font-bold text-xs",children:"auto-coder.web"})]}),x.jsxs("div",{className:"flex items-center min-w-0 flex-1 overflow-hidden",children:[x.jsx("span",{className:"text-gray-400 text-xs mx-0.5",children:"|"}),x.jsx("div",{className:"flex items-center min-w-0 flex-1 overflow-hidden",children:x.jsx("span",{className:"text-gray-200 text-xs font-medium truncate",children:s||J("noProjectSelected")})})]})]}),x.jsxs("div",{className:"flex items-center space-x-1 flex-shrink-0",children:[x.jsx(l8t,{chatListName:$,chatLists:O,setChatListName:W,loadChatList:Ye,setCurrentSessionName:ut,showNewChatModal:g,deleteChatList:Qe,getChatTitle:nt,renameChatList:ct}),x.jsx(er,{title:"清空当前对话",children:x.jsx(an,{icon:x.jsx(uvt,{style:{fontSize:"10px"}}),onClick:()=>{$?Gr.confirm({title:"确认清空",content:"确定要清空当前对话中的所有消息吗?此操作不可撤销。",okText:"清空",okType:"danger",cancelText:"取消",onOk:async()=>{_([]),$&&(await Ke($,[]),yt.success("对话已清空"))}}):yt.warning("请先选择或创建一个对话")},className:"text-gray-300 border-gray-600 bg-gray-700 hover:bg-gray-600 px-1 py-0 h-6 w-6 flex items-center justify-center",size:"small"})}),x.jsx(er,{title:"保存当前对话",children:x.jsx(an,{icon:x.jsx(T5e,{style:{fontSize:"10px"}}),onClick:()=>{$&&v.length>0?(_e(!0),yt.success("对话已保存")):$?yt.warning("没有消息可保存"):yt.warning("请先选择或创建一个对话")},className:"text-gray-300 border-gray-600 bg-gray-700 hover:bg-gray-600 px-1 py-0 h-6 w-6 flex items-center justify-center",size:"small"})}),x.jsx(er,{title:"设置",children:x.jsx(an,{icon:x.jsx(bue,{style:{fontSize:"10px"}}),onClick:()=>E(!S),className:"text-gray-300 border-gray-600 bg-gray-700 hover:bg-gray-600 px-1 py-0 h-6 w-6 flex items-center justify-center",size:"small"})}),x.jsx(er,{title:"导出对话为图片",children:x.jsx(an,{icon:x.jsx(ybt,{style:{fontSize:"10px"}}),onClick:ht,className:"text-gray-300 border-gray-600 bg-gray-700 hover:bg-gray-600 px-1 py-0 h-6 w-6 flex items-center justify-center",size:"small"})})]})]}),x.jsxs(bb.Content,{className:"flex-1 overflow-hidden flex flex-col",children:[x.jsxs("div",{className:"flex-1 overflow-y-auto bg-gray-900 p-2 transition-all duration-300",id:"chat-messages-container",style:{backgroundImage:"radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.05) 1px, transparent 0)",backgroundSize:"20px 20px"},children:[v.length>0&&x.jsx("div",{className:"sticky top-0 right-0 float-right bg-gray-800/90 backdrop-blur-sm border border-gray-700 rounded-md p-2 m-1 shadow-md z-10",children:x.jsxs("div",{className:"font-mono text-xs text-gray-400 flex flex-col items-end gap-1 text-[11px]",children:[x.jsxs("div",{className:"flex items-center",children:[x.jsxs("span",{children:[J("tokens"),": "]}),x.jsxs("span",{className:"text-green-500 ml-1",children:["↑ ",We.inputTokens]}),x.jsxs("span",{className:"text-red-500 ml-1",children:["↓ ",We.outputTokens]})]}),(We.cacheHits>0||We.cacheMisses>0)&&x.jsxs("div",{className:"flex items-center",children:[x.jsxs("span",{children:[J("cache"),": "]}),x.jsxs("span",{className:"text-white ml-1",children:["⊕ ",We.cacheHits]}),x.jsxs("span",{className:"text-white ml-1",children:["→ ",We.cacheMisses]})]}),x.jsxs("div",{className:"flex items-center",children:[x.jsxs("span",{children:[J("apiCost"),": "]}),x.jsxs("span",{className:"text-white ml-1",children:["$",We.totalCost.toFixed(5)]})]})]})}),v.length===0?x.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400 animate-fade-in",children:[x.jsx(A3,{style:{fontSize:"36px",marginBottom:"10px",opacity:.5}}),x.jsx(Su.Title,{level:5,className:"text-gray-300 mb-1",children:"开始一个新的对话"}),x.jsx(Su.Text,{className:"text-gray-400 text-center max-w-md text-xs",children:"有任何问题都可以在下方输入,我会尽力帮助您。"})]}):x.jsx("div",{className:"space-y-4 animate-fade-in",children:x.jsx(V8e,{messages:ye(),onUserResponse:async(ze,Ze)=>{if(Ze&&Wt){const{requestId:lt,eventData:St}=Wt;await fetch("/api/event/response",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({request_id:lt,event:St,response:JSON.stringify({value:ze})})}),tn(null)}}})}),x.jsx("div",{ref:V}),!xe&&v.length>0&&x.jsx(an,{type:"primary",shape:"circle",size:"small",icon:x.jsx(FR,{}),onClick:()=>{var ze;(ze=V.current)==null||ze.scrollIntoView({behavior:"smooth"}),Ue(!0)},className:"fixed bottom-24 right-4 z-10 bg-indigo-600 hover:bg-indigo-700 border-0 shadow-lg flex items-center justify-center",style:{width:"36px",height:"36px"}})]}),x.jsx("div",{className:"border-t border-gray-700 bg-gray-800 transition-all duration-300 shadow-inner",children:x.jsx(o_n,{fileGroups:y,selectedGroups:T,setSelectedGroups:D,fetchFileGroups:Jt,isMaximized:Z,setIsMaximized:G,handleEditorDidMount:Ut,setShouldSendMessage:X,isWriteMode:Q,setIsWriteMode:te,isRuleMode:c,setIsRuleMode:d,handleRevert:ue,handleSendMessage:Me,handleStopGeneration:Ge,sendLoading:F,setConfig:R,isFullScreen:Z,showFileGroupSelect:!0,soundEnabled:u,setSoundEnabled:h})})]})]}),x.jsx(Gr,{title:x.jsx("span",{style:{color:"#FFFFFF"},children:"创建新对话"}),open:ce,onOk:p,onCancel:m,okText:"创建",cancelText:"取消",centered:!0,okButtonProps:{disabled:!be.trim(),style:{backgroundColor:"#8B5CF6",borderColor:"#8B5CF6"}},bodyStyle:{backgroundColor:"#1F2937",color:"#E5E7EB"},style:{top:20},className:"custom-modal",children:x.jsxs("div",{className:"mb-4",children:[x.jsx(Su.Text,{strong:!0,className:"block mb-2",style:{color:"#FFFFFF"},children:"对话名称"}),x.jsx(Xn,{value:be,onChange:ze=>ve(ze.target.value),placeholder:"请输入新对话的名称",onPressEnter:p,prefix:x.jsx(A3,{style:{color:"#8B5CF6"}}),autoFocus:!0,size:"large",style:{backgroundColor:"#374151",borderColor:"#4B5563",color:"#FFFFFF"}}),!be.trim()&&x.jsx(Su.Text,{type:"danger",className:"mt-1 block",children:"对话名称不能为空"})]})})]})};function rme(n){var i;if(!n)return"plaintext";const e=(i=n.split(".").pop())==null?void 0:i.toLowerCase(),t={ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",html:"html",htm:"html",css:"css",scss:"scss",less:"less",json:"json",xml:"xml",svg:"xml",py:"python",java:"java",c:"c",cpp:"cpp",h:"cpp",hpp:"cpp",cs:"csharp",go:"go",rs:"rust",php:"php",rb:"ruby",swift:"swift",kt:"kotlin",scala:"scala",sh:"shell",bash:"shell",zsh:"shell",fish:"shell",yml:"yaml",yaml:"yaml",toml:"toml",ini:"ini",conf:"plaintext",config:"plaintext",md:"markdown",markdown:"markdown",txt:"plaintext",sql:"sql",dockerfile:"dockerfile",dockerignore:"plaintext",gitignore:"plaintext",env:"plaintext"};return e?n.toLowerCase().endsWith("dockerfile")?"dockerfile":n.toLowerCase().endsWith("makefile")?"makefile":t[e]||"plaintext":"plaintext"}const m_n=({treeData:n,onSelect:e,onRefresh:t,projectName:i})=>{const[r,s]=b.useState(n),[o,a]=b.useState(null),[l,c]=b.useState(!1),[d,u]=b.useState(""),[h,f]=b.useState(!1),[g,m]=b.useState(!1),[p,A]=b.useState(""),[v,_]=b.useState(""),[y,C]=b.useState(!1),[S,E]=b.useState(""),[L,I]=b.useState("");b.useEffect(()=>{s(n),d&&$(d)},[n]);const T=async K=>{try{if(!(await fetch(`/api/files/${K.key}`,{method:"DELETE"})).ok)throw new Error("Failed to delete");yt.success(`Successfully deleted ${K.title}`),t()}catch(V){yt.error("Failed to delete file/directory"),console.error("Error:",V)}},D=({event:K,node:V})=>{K.preventDefault(),a(V)},B=async()=>{if(!p.trim())return;const K=v?`${v}/${p}`.replace(/\/\//g,"/"):p;try{const V=await fetch(`/api/file/${K}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:""})});if(!V.ok){const Q=await V.json();throw new Error(Q.detail||"Failed to create file")}yt.success(`Successfully created ${p}`),m(!1),A(""),t()}catch(V){console.error("Error creating file:",V),yt.error(V instanceof Error?V.message:"Failed to create file")}},R=async()=>{if(!S.trim())return;const K=L?`${L}/${S}`.replace(/\/\//g,"/"):S;try{const V=await fetch(`/api/directory/${K}`,{method:"POST"});if(!V.ok){const Q=await V.json();throw new Error(Q.detail||"Failed to create directory")}yt.success(`Successfully created directory ${S}`),C(!1),E(""),t()}catch(V){console.error("Error creating directory:",V),yt.error(V instanceof Error?V.message:"Failed to create directory")}},O=K=>{const V=K.toString().split(".");return V.length>1?V[V.length-1].toLowerCase():""},P=K=>!K.isLeaf,$=K=>{const V=K.toLowerCase();if(u(K),!V){s(n),f(!1);return}f(!0);const Q=G=>G.reduce((q,X)=>(X.isLeaf?q.push(X):X.children&&q.push(...Q(X.children)),q),[]),Z=Q(n).filter(G=>G.key.toString().toLowerCase().includes(V)).map(G=>{var q;return{...G,title:x.jsxs("div",{className:"file-node",children:[x.jsx("span",{className:`file-icon file file-${O(G.key.toString())}`,children:x.jsx(LE,{})}),x.jsx("span",{className:"file-name",children:(q=G.title)==null?void 0:q.toString()}),x.jsx("div",{className:"path-breadcrumb",children:G.key.toString()})]})}});s(Z)},W=()=>{const K=[];return o&&P(o)&&(K.push({key:"new-file",icon:x.jsx(Qye,{}),label:"New File",onClick:()=>{_(o.key.toString()),m(!0)}}),K.push({key:"new-directory",icon:x.jsx(qye,{}),label:"New Directory",onClick:()=>{I(o.key.toString()),C(!0)}})),K.push({key:"info",icon:x.jsx(I5e,{}),label:"File Info",onClick:()=>{o&&yt.info(`Path: ${o.key}`)}},{key:"copy",icon:x.jsx(vue,{}),label:"Copy Path",onClick:()=>{o&&(navigator.clipboard.writeText(o.key.toString()),yt.success("Path copied to clipboard"))}},{type:"divider"},{key:"delete",icon:x.jsx(Ac,{}),label:"Delete",danger:!0,onClick:()=>{o&&Gr.confirm({title:"Delete Confirmation",content:`Are you sure you want to delete ${o.title}?`,okText:"Yes",okType:"danger",cancelText:"No",onOk(){T(o)}})}}),K},j=async()=>{if(!l){c(!0);try{await t(),yt.success("Refreshed file tree successfully")}catch(K){yt.error("Failed to refresh file tree"),console.error("Error refreshing file tree:",K)}finally{c(!1)}}},H=K=>{var se;const V=((se=K.title)==null?void 0:se.toString())||"",Q=!K.isLeaf,te=O(V);return x.jsxs("div",{className:"file-node",children:[x.jsx("span",{className:`file-icon ${Q?"folder":`file file-${te}`}`,children:Q?x.jsx(m3,{}):x.jsx(LE,{})}),x.jsx("span",{className:"file-name",children:V})]})},F=K=>K.map(V=>{const Q={...V,title:H(V)};return V.children&&(Q.children=F(V.children)),Q}),U=Se.useMemo(()=>h?r:F(r),[r,h]);return x.jsxs("div",{className:"file-tree-container",children:[x.jsx(Gr,{title:v?`Create New File in ${v}`:"Create New File in Root Directory",open:g,onOk:B,onCancel:()=>{m(!1),A(""),_("")},okButtonProps:{disabled:!p.trim()},className:"vscode-dark-modal",children:x.jsx(Rn,{layout:"vertical",children:x.jsx(Rn.Item,{label:"File Name",required:!0,help:"Enter the file name with extension (e.g., example.js)",children:x.jsx(Xn,{value:p,onChange:K=>A(K.target.value),placeholder:"Enter file name",autoFocus:!0})})})}),x.jsx(Gr,{title:L?`Create New Directory in ${L}`:"Create New Directory in Root",open:y,onOk:R,onCancel:()=>{C(!1),E(""),I("")},okButtonProps:{disabled:!S.trim()},className:"vscode-dark-modal",children:x.jsx(Rn,{layout:"vertical",children:x.jsx(Rn.Item,{label:"Directory Name",required:!0,help:"Enter the directory name",children:x.jsx(Xn,{value:S,onChange:K=>E(K.target.value),placeholder:"Enter directory name",autoFocus:!0})})})}),x.jsxs("div",{className:"file-tree-header",children:[x.jsx("div",{className:"file-tree-header-title",children:i||"Project Files"}),x.jsxs("div",{className:"file-tree-actions",children:[x.jsx(er,{title:"New File",children:x.jsx("button",{onClick:()=>{_(""),m(!0)},className:"action-button","aria-label":"Create new file",children:x.jsx(Qye,{})})}),x.jsx(er,{title:"New Directory",children:x.jsx("button",{onClick:()=>{I(""),C(!0)},className:"action-button","aria-label":"Create new directory",children:x.jsx(qye,{})})}),x.jsx(er,{title:"Refresh",children:x.jsx("button",{onClick:j,className:"action-button","aria-label":"Refresh file tree",children:l?x.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[x.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),x.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):x.jsx(n_,{})})})]})]}),x.jsx("div",{className:"file-tree-search",children:x.jsx(Xn,{prefix:x.jsx(jC,{className:"text-gray-400"}),placeholder:"Search files...",className:"custom-input",allowClear:!0,value:d,onChange:K=>$(K.target.value)})}),x.jsx("div",{className:"file-tree-content",children:n.length===0?x.jsxs("div",{className:"empty-state",children:[x.jsx("div",{className:"empty-state-icon",children:x.jsx(m3,{})}),x.jsx("div",{className:"empty-state-text",children:"No files found"})]}):U.length===0&&h?x.jsxs("div",{className:"empty-state",children:[x.jsx("div",{className:"empty-state-icon",children:x.jsx(jC,{})}),x.jsx("div",{className:"empty-state-text",children:"No matching files found"})]}):x.jsx(P1,{menu:{items:W()},trigger:["contextMenu"],overlayClassName:"vscode-dark-dropdown",children:x.jsx("div",{className:"file-tree",children:x.jsx(QR,{showIcon:!1,defaultExpandAll:!0,onSelect:e,onRightClick:D,treeData:U,height:999999})})})})]})};M_.config({paths:{vs:"/monaco-editor/min/vs"},"vs/nls":{availableLanguages:{"*":"zh-cn"}}});const A_n=n=>{n.editor.defineTheme("customVsDarkTheme",{base:"vs-dark",inherit:!0,rules:[{token:"comment",foreground:"6A9955",fontStyle:"italic"},{token:"keyword",foreground:"569CD6"},{token:"string",foreground:"CE9178"},{token:"number",foreground:"B5CEA8"},{token:"regexp",foreground:"D16969"},{token:"operator",foreground:"D4D4D4"},{token:"namespace",foreground:"4EC9B0"},{token:"type.identifier",foreground:"4EC9B0"},{token:"function",foreground:"DCDCAA"},{token:"variable",foreground:"9CDCFE"},{token:"variable.predefined",foreground:"4FC1FF"},{token:"class",foreground:"4EC9B0"},{token:"interface",foreground:"4EC9B0"},{token:"enum",foreground:"4EC9B0"}],colors:{"editor.foreground":"#D4D4D4","editor.background":"#1E1E1E","editorCursor.foreground":"#AEAFAD","editor.lineHighlightBackground":"#2D2D30","editorLineNumber.foreground":"#858585","editor.selectionBackground":"#264F78","editor.inactiveSelectionBackground":"#3A3D41"}})},nGe=({code:n,language:e,onChange:t})=>{const i=b.useRef(null),r=b.useRef(null),[s,o]=b.useState(!1),a=()=>{if(!(!e||e==="plaintext"||!r.current)){console.log(`Attempting to load language support for: ${e}`);try{if(r.current.languages.getLanguages().some(f=>f.id===e||f.aliases&&f.aliases.includes(e))){if(console.log(`Language ${e} is already supported`),i.current){const f=i.current.getModel();f&&(r.current.editor.setModelLanguage(f,e),console.log(`Explicitly set model language to: ${e}`),setTimeout(()=>{i.current.updateOptions({})},100))}return}const h=document.createElement("script");h.src=`/monaco-editor/min/vs/basic-languages/${e}/${e}.js`,h.async=!0,h.onload=()=>{if(console.log(`Language support loaded for: ${e}`),i.current){const f=i.current.getModel();f&&(r.current.editor.setModelLanguage(f,e),setTimeout(()=>{i.current.updateOptions({})},100))}},h.onerror=f=>{console.warn(`Failed to load language support for ${e}:`,f)},document.body.appendChild(h)}catch(d){console.error("Error loading language support:",d)}}};b.useEffect(()=>{s&&a()},[e,s]);const l=d=>{console.log("Monaco editor will mount"),r.current=d,A_n(d),d.languages.typescript.typescriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0}),d.languages.typescript.javascriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0}),d.languages.onLanguage("*",()=>{d.languages.setLanguageConfiguration("*",{wordPattern:/(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g})})},c=(d,u)=>{console.log("Monaco editor did mount"),i.current=d,r.current=u,o(!0);const h=d.getModel();h&&e&&u.editor.setModelLanguage(h,e),a(),d.updateOptions({minimap:{enabled:!0},fontSize:14,lineNumbers:"on",folding:!0,automaticLayout:!0,renderWhitespace:"selection",wordWrap:"on",scrollbar:{vertical:"visible",horizontal:"visible",verticalScrollbarSize:10,horizontalScrollbarSize:10,verticalSliderSize:10,horizontalSliderSize:10,arrowSize:30},suggestOnTriggerCharacters:!0,acceptSuggestionOnEnter:"on",tabCompletion:"on",wordBasedSuggestions:"currentDocument",parameterHints:{enabled:!0,cycle:!0},bracketPairColorization:{enabled:!0},guides:{indentation:!0,bracketPairs:!0}})};return x.jsx("div",{className:"monaco-editor-container",children:x.jsx(O7,{height:"100%",defaultLanguage:"plaintext",language:e,theme:"customVsDarkTheme",value:n,onChange:t,beforeMount:l,onMount:c,loading:x.jsx("div",{className:"loading",children:"Loading editor..."}),options:{fontLigatures:!0,contextmenu:!0,fixedOverflowWidgets:!0,colorDecorators:!0,formatOnType:!1,formatOnPaste:!1,parameterHints:{enabled:!1}}})})},v_n=({selectedFiles:n})=>{const[e,t]=b.useState(n||[]),[i,r]=b.useState(null),[s,o]=b.useState([]),[a,l]=b.useState([]),[c,d]=b.useState(!1);b.useEffect(()=>{if(s.length>0){const y=s.map(C=>({path:C.key,isSelected:C.key===i,label:C.label}));Ki.publish(Qi.EDITOR.TABS_CHANGED,y)}},[s,i]),b.useEffect(()=>{n&&(t(n),n.forEach(y=>{u(y.path)}),n.length>0&&r(n[0].path))},[n]),b.useEffect(()=>{h()},[]);const u=async y=>{try{const C=await fetch(`/api/file/${y}`);if(!C.ok)throw new Error("Failed to fetch file content");const S=await C.json();o(E=>E.find(I=>I.key===y)?E.map(I=>I.key===y?{...I,content:S.content}:I):[...E,{key:y,label:y.split("/").pop()||y,content:S.content}])}catch(C){console.error("Error fetching file content:",C),yt.error(`Failed to load ${y}`)}},h=async()=>{try{const y=await fetch("/api/files");if(!y.ok)throw new Error("Failed to fetch file tree");const C=await y.json(),S=L=>{const I=L.isLeaf;return{title:L.title,key:L.key,icon:I?"file":"folder",children:L.children?L.children.map(S):void 0,isLeaf:I}},E=C.tree.map(S);l(E)}catch(y){console.error("Error fetching file tree:",y)}},f=async()=>{if(!(!i||c))try{d(!0);const y=s.find(S=>S.key===i);if(!y)return;if(!(await fetch(`/api/file/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:y.content})})).ok)throw new Error("Failed to save file");yt.success("File saved successfully")}catch(y){console.error("Error saving file:",y),yt.error("Failed to save file")}finally{d(!1)}},g=async(y,C)=>{const S=y[0];if(S&&C.node.isLeaf){const E={path:S,isSelected:!0};e.some(L=>L.path===S)||t(L=>[...L,E]),r(S),u(S)}},m=y=>{r(y)},p=(y,C)=>{typeof y=="string"&&C==="remove"&&(o(S=>S.filter(E=>E.key!==y)),t(S=>S.filter(E=>E.path!==y)),i===y&&s.length>0&&r(s[0].key))},A=y=>{navigator.clipboard.writeText(y).then(()=>{yt.success("File path copied to clipboard")}).catch(C=>{console.error("Failed to copy file path: ",C),yt.error("Failed to copy file path")})},v=y=>{o(C=>C.filter(S=>S.key===y)),t(C=>C.filter(S=>S.path===y)),i!==y&&r(y)},_=(y,C)=>x.jsxs(Yo,{children:[x.jsx(Yo.Item,{onClick:()=>A(y),children:J("codeEditor.copyPath")},"copyPath"),x.jsx(Yo.Item,{onClick:()=>v(y),children:J("codeEditor.closeOtherTabs")},"closeOthers")]});return x.jsxs("div",{className:"code-editor-container",children:[x.jsx("div",{className:"code-editor-header",children:x.jsxs("div",{className:"code-editor-header-content",children:[x.jsx("div",{className:"file-info",children:x.jsx("span",{className:"file-path",children:i||"No file selected"})}),i&&x.jsxs("button",{onClick:f,disabled:!i,className:"save-button",children:[x.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:x.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-3m-1 4l-3 3m0 0l-3-3m3 3V4"})}),"Save"]})]})}),x.jsxs(DE,{className:"code-editor-content",sizes:[20,80],minSize:100,expandToMin:!1,gutterSize:10,gutterAlign:"center",snapOffset:30,dragInterval:1,direction:"horizontal",children:[x.jsx("div",{className:"file-tree-panel",children:x.jsx(m_n,{treeData:a,onSelect:g,onRefresh:h})}),x.jsx("div",{className:"editor-panel",children:x.jsx(Sp,{type:"editable-card",onChange:m,onEdit:p,activeKey:i||void 0,children:s.map(y=>{const C=e.find(S=>S.path===y.key);return x.jsx(Sp.TabPane,{tab:x.jsx(P1,{overlay:_(y.key,y.label),trigger:["contextMenu"],overlayClassName:"vscode-dark-dropdown",children:x.jsx("span",{style:{color:(C==null?void 0:C.modifiedBy)==="expert_chat_box"?"#ff4d4f":"inherit",display:"inline-block"},children:y.label})}),closable:!0,children:x.jsx(nGe,{code:y.content,language:rme(y.key),onChange:S=>{o(E=>E.map(L=>L.key===y.key?{...L,content:S||""}:L))}})},y.key)})})})]})]})},b_n=({selectedFiles:n})=>x.jsx(v_n,{selectedFiles:n});function __n(n,e){const t=b.useRef(null),i=(...r)=>{t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{n(...r)},e)};return Se.useEffect(()=>()=>{t.current&&clearTimeout(t.current)},[]),i}const y_n={js:"#f7df1e",jsx:"#61dafb",ts:"#3178c6",tsx:"#3178c6",css:"#264de4",scss:"#cc6699",html:"#e34c26",json:"#8bc34a",md:"#42a5f5",py:"#3572A5",java:"#b07219",go:"#00ADD8",rs:"#dea584",c:"#555555",cpp:"#f34b7d",sh:"#89e051"},C_n=n=>{var t;const e=((t=n.split(".").pop())==null?void 0:t.toLowerCase())||"";return y_n[e]||"#9ca3af"},w_n=n=>!n.isLeaf,S_n=n=>{const e=[],t=i=>{i.isLeaf?e.push(i.key):i.children&&i.children.forEach(t)};return n.forEach(t),e},x_n=({treeData:n,checkedKeys:e,onCheckedKeysChange:t,onFileSelect:i,onAddFiles:r,selectedGroup:s,onRefreshTree:o})=>{const[a,l]=b.useState(n),[c,d]=b.useState(!1),[u,h]=b.useState(""),[f,g]=b.useState([]),[m,p]=b.useState(null),[A,v]=b.useState(!1),[_,y]=b.useState({x:0,y:0}),C=b.useRef(null),[S,E]=b.useState(!0),[L,I]=b.useState(!1),[T,D]=b.useState([]),[B,R]=b.useState(!0),O=__n(G=>{P(G)},500);b.useEffect(()=>{l(n);const G=new Set,q=X=>{X.forEach(ie=>{var oe;if(ie.isLeaf){const Ae=(oe=ie.key.split(".").pop())==null?void 0:oe.toLowerCase();Ae&&G.add(Ae)}ie.children&&q(ie.children)})};q(n),D(Array.from(G))},[n]);const P=(G,q=n)=>{const X=G.toLowerCase();if(!X){l(q);return}const ie=Ae=>Ae.map(be=>{var Ue;const ve={...be};typeof be.title=="string"&&be.title;const xe=be.key.toString();return(Ue=be.children)!=null&&Ue.length?(ve.children=ie(be.children),ve.children.length>0||xe.toLowerCase().includes(X)?ve:null):xe.toLowerCase().includes(X)?ve:null}).filter(Boolean),oe=ie(q);l(oe);const ce=(Ae,be=[])=>(Ae.forEach(ve=>{var Ue;if(!w_n(ve))return;((Ue=ve.children)==null?void 0:Ue.some(He=>He.key.toString().toLowerCase().includes(X)))&&be.push(ve.key.toString()),ve.children&&ce(ve.children,be)}),be);g(ce(q))},$=G=>G.map(q=>{const X=q.isLeaf,ie=q.key.toString();let oe;if(X){const xe=C_n(ie);oe=x.jsx(LE,{className:"file-icon",style:{color:xe}})}else oe=f.includes(ie)?x.jsx(Ste,{className:"file-icon folder-icon"}):x.jsx(m3,{className:"file-icon folder-icon"});const ce=ie.split("/"),Ae=ce[ce.length-1],be=()=>{if(!u)return Ae;const xe=Ae.toLowerCase().indexOf(u.toLowerCase());if(xe===-1)return Ae;const Ue=Ae.substring(0,xe),He=Ae.substring(xe,xe+u.length),$e=Ae.substring(xe+u.length);return x.jsxs("span",{children:[Ue,x.jsx("span",{className:"search-highlight",children:He}),$e]})},ve={...q,title:x.jsxs("span",{className:"file-node-title",title:ie,children:[oe,x.jsx("span",{className:"file-name",children:be()})]})};return q.children&&(ve.children=$(q.children)),ve}),W=$(a),j=(G,q)=>{G.preventDefault(),G.stopPropagation(),p(q),v(!0),y({x:G.clientX,y:G.clientY})},H=()=>{if(!m)return null;const G=!m.isLeaf,q=m.key.toString();return x.jsxs(Yo,{className:"file-context-menu",onClick:({key:X})=>F(X,q,G),children:[G?x.jsxs(x.Fragment,{children:[x.jsx(Yo.Item,{icon:x.jsx(Ste,{}),children:f.includes(q)?"Collapse":"Expand"},"expand"),x.jsx(Yo.Item,{icon:x.jsx(Ab,{}),children:"Select All Files Inside"},"selectAll"),x.jsx(Yo.Divider,{})]}):x.jsxs(x.Fragment,{children:[x.jsx(Yo.Item,{icon:x.jsx(Ab,{}),children:e.includes(q)?"Deselect":"Select"},"select"),x.jsx(Yo.Item,{icon:x.jsx(LE,{}),children:"Preview File"},"preview"),x.jsx(Yo.Divider,{})]}),x.jsx(Yo.Item,{icon:x.jsx(vue,{}),children:"Copy Path"},"copy"),s&&!G&&x.jsxs(Yo.Item,{icon:x.jsx(Pa,{}),disabled:!s,children:["Add to ",s.name]},"add")]})},F=(G,q,X)=>{switch(v(!1),G){case"expand":f.includes(q)?g(f.filter(ie=>ie!==q)):g([...f,q]);break;case"selectAll":if(X){const ie=V(q,n),oe=Array.from(new Set([...e,...ie]));t(oe)}break;case"select":e.includes(q)?t(e.filter(ie=>ie!==q)):t([...e,q]);break;case"preview":i==null||i(q);break;case"copy":navigator.clipboard.writeText(q).then(()=>yt.success("Path copied to clipboard")).catch(()=>yt.error("Failed to copy path"));break;case"add":if(s&&r){const ie=[];if(X){const oe=V(q,n);ie.push(...oe)}else ie.push(q);console.log("Files to add from context menu:",ie),t(ie),setTimeout(()=>{r()},100)}break}},U=G=>{if(!S||!s)return;G.node.key;const q=G.dragNode.key;!G.dragNode.isLeaf&&G.node.isLeaf||G.dragNode.isLeaf&&(e.includes(q)||(t([...e,q]),yt.success("File added to selection")))},K=(G,q)=>{let ie=(Array.isArray(G)?G:G.checked).filter(oe=>{const ce=(Ae,be)=>{for(const ve of Ae){if(ve.key===be)return!!ve.isLeaf;if(ve.children&&ce(ve.children,be))return!0}return!1};return ce(n,oe)});console.log("Processed checked keys:",ie),t(ie)},V=(G,q)=>{const X=[],ie=Ae=>Ae.replace(/\\/g,"/"),oe=ie(G);return((Ae,be)=>{const ve=(Ue,He)=>{const $e=ie(Ue);for(const Ne of He){if(ie(Ne.key.toString())===$e)return Ne;if(Ne.children){const Ie=ve(Ue,Ne.children);if(Ie)return Ie}}return null},xe=ve(Ae,be);if(xe&&xe.children){const Ue=He=>{He.isLeaf?X.push(He.key.toString()):He.children&&He.children.forEach(Ue)};xe.children.forEach(Ue)}})(oe,q),X},Q=()=>e.length,te=()=>S_n(a),se=()=>{const G=te();if(B)t(G),yt.success(`已选择 ${G.length} 个文件`);else{const q=G.filter(X=>!e.includes(X));t(q),yt.success(`已反选 ${q.length} 个文件`)}R(!B)},Z=()=>x.jsx(Yo,{className:"file-type-filter-menu",children:x.jsx(Yo.ItemGroup,{title:"Filter by File Type",children:T.map(G=>x.jsx(Yo.Item,{children:x.jsx(yA,{children:G})},G))})});return x.jsxs("div",{className:"file-directory-selector",children:[x.jsxs("div",{className:"search-container",children:[x.jsxs("div",{className:"search-header",style:{display:"flex",gap:"8px",alignItems:"center"},children:[x.jsx(Xn,{prefix:x.jsx(jC,{className:"text-gray-400"}),placeholder:"Search files...",className:"search-input",value:u,onChange:G=>{const q=G.target.value;h(q),O(q)},suffix:x.jsx(P1,{overlay:Z(),trigger:["click"],open:L,onOpenChange:I,children:x.jsx(qvt,{className:"filter-icon"})})}),o&&x.jsx(er,{title:"刷新目录树",children:x.jsx(an,{icon:c?x.jsx(Yye,{spin:!0,style:{transition:"transform 0.3s"}}):x.jsx(Yye,{}),loading:c,onClick:async()=>{try{d(!0),await o(),h(""),P("")}finally{d(!1)}},className:"refresh-tree-button"})})]}),s&&x.jsxs("div",{className:"action-buttons",children:[x.jsxs(an,{type:"primary",onClick:r,disabled:e.length===0,icon:x.jsx(Pa,{}),className:"add-button",block:!0,children:["Add Selected (",Q(),")"]}),x.jsx(er,{title:B?"全选当前可见文件":"反选当前可见文件",children:x.jsx(an,{onClick:se,icon:B?x.jsx(Ab,{}):x.jsx(Tpt,{}),className:`selection-toggle-button ${B?"select-all-mode":"invert-mode"}`})})]})]}),x.jsxs("div",{className:"file-tree-container",children:[x.jsx(QR,{ref:C,checkable:!0,treeData:W,checkedKeys:e,expandedKeys:f,onExpand:g,onCheck:K,onSelect:(G,q)=>{const X=q.node;X.isLeaf&&i&&i(X.key)},onRightClick:({event:G,node:q})=>j(G,q),onDoubleClick:(G,q)=>{q.isLeaf&&i&&i(q.key)},draggable:S,onDrop:U,className:"custom-dark-tree",showIcon:!1,showLine:{showLeafIcon:!1},blockNode:!0,autoExpandParent:!1,virtual:!1}),A&&x.jsx("div",{className:"context-menu-wrapper",style:{position:"fixed",top:_.y,left:_.x},children:H()})]})]})},E_n=({selectedGroup:n,onFileSelect:e,onRemoveFile:t,onUpdateDescription:i,onAddExternalFile:r})=>{const[s,o]=b.useState(!1),[a,l]=b.useState("");return n?x.jsxs("div",{className:"space-y-4",children:[x.jsxs("div",{className:"space-y-4",children:[x.jsxs("div",{className:"flex justify-between items-center",children:[x.jsx("h3",{className:"text-white font-medium text-lg",children:n.name}),x.jsx(an,{type:"primary",size:"small",className:"bg-blue-600 hover:bg-blue-700 border-none",icon:s?x.jsx(T5e,{}):x.jsx(Bu,{}),onClick:async()=>{if(s)try{await i(n.name,a),yt.success("Description updated successfully")}catch{yt.error("Failed to update description")}else l(n.description||"");o(!s)},children:s?"Save Description":"Edit Description"})]}),s?x.jsx("div",{className:"h-48",children:x.jsx(O7,{height:"100%",defaultLanguage:"markdown",theme:"vs-dark",value:a,onChange:c=>l(c||""),options:{minimap:{enabled:!1},fontSize:14,lineNumbers:"off",wordWrap:"on",automaticLayout:!0}})}):x.jsx("p",{className:"text-gray-400 text-sm",children:n.description||"No description"})]}),x.jsxs("div",{children:[x.jsxs("div",{className:"flex justify-between items-center mb-2",children:[x.jsxs("h4",{className:"text-white font-medium",children:["Files (",n.files.length,")"]}),x.jsx(an,{type:"primary",size:"small",icon:x.jsx(Pa,{}),onClick:r,className:"bg-blue-600 hover:bg-blue-700 border-none",children:"Add External File"})]}),n.files.length===0?x.jsx("div",{className:"empty-files-container",children:x.jsx(So,{description:x.jsx("span",{className:"text-gray-400",children:"No files added yet"}),image:So.PRESENTED_IMAGE_SIMPLE,className:"custom-empty-state"})}):x.jsx(od,{dataSource:n.files.map(c=>({path:c})),rowKey:"path",showHeader:!1,columns:[{title:"Path",dataIndex:"path",key:"path",render:c=>{const d=c.split("/").pop();return x.jsx("span",{className:"text-gray-300 cursor-pointer hover:text-blue-400",title:c,onDoubleClick:u=>{u.stopPropagation(),e(c)},children:d})}},{title:"Action",key:"action",width:40,render:(c,{path:d})=>x.jsx(Ac,{className:"text-red-400 cursor-pointer hover:text-red-500",onClick:u=>{u.stopPropagation(),t(n.name,d)}})}],pagination:!1,size:"small",className:"dark-mode-table",locale:{emptyText:x.jsx("div",{className:"py-4",children:x.jsx(So,{description:x.jsx("span",{className:"text-gray-400",children:"No files in this group"}),image:So.PRESENTED_IMAGE_SIMPLE,className:"custom-empty-state"})})}})]})]}):x.jsx("div",{className:"text-gray-400 text-center mt-4",children:"Select a group to view details"})},k_n=()=>{const[n,e]=b.useState([]),[t,i]=b.useState(null),[r,s]=b.useState(null),[o,a]=b.useState(""),[l,c]=b.useState([]),[d,u]=b.useState([]),[h,f]=b.useState([]),[g,m]=b.useState(!1),[p,A]=b.useState(""),[v,_]=b.useState(""),[y,C]=b.useState(!1),[S,E]=b.useState(!1),[L,I]=b.useState(100),[T,D]=b.useState(10),[B,R]=b.useState(!1),[O,P]=b.useState([]),[$,W]=b.useState(!1),[j,H]=b.useState(!1),[F,U]=b.useState(""),K=async()=>{try{const q=await fetch("/api/file-groups");if(!q.ok)throw new Error("Failed to fetch file groups");const X=await q.json();e(X.groups)}catch{yt.error("Failed to load file groups")}},V=async()=>{try{const q=await fetch("/api/files");if(!q.ok)throw new Error("Failed to fetch file tree");const X=await q.json();c(X.tree),u(X.tree)}catch{yt.error("Failed to load file tree")}};b.useEffect(()=>{K(),V()},[]);const Q=async()=>{try{if(!(await fetch("/api/file-groups",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:p,description:v})})).ok)throw new Error("Failed to create group");yt.success("Group created successfully"),m(!1),A(""),_(""),K()}catch{yt.error("Failed to create group")}},te=async q=>{try{if(!(await fetch(`/api/file-groups/${q}`,{method:"DELETE"})).ok)throw new Error("Failed to delete group");yt.success("Group deleted successfully"),K(),(t==null?void 0:t.name)===q&&i(null)}catch{yt.error("Failed to delete group")}},se=async()=>{if(!(!t||h.length===0))try{const q=await fetch(`/api/file-groups/${t.name}/files`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:h})});if(!q.ok)throw new Error("Failed to add files");if(yt.success("Files added successfully"),K(),f([]),q.ok&&(K(),t)){const ie=(await(await fetch("/api/file-groups")).json()).groups.find(oe=>oe.name===t.name);ie&&i(ie)}}catch{yt.error("Failed to add files")}},Z=async(q,X)=>{try{if(!(await fetch(`/api/file-groups/${q}/files`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[X]})})).ok)throw new Error("Failed to remove file");if(yt.success("File removed successfully"),K(),t){const ce=(await(await fetch("/api/file-groups")).json()).groups.find(Ae=>Ae.name===t.name);ce&&i(ce)}}catch{yt.error("Failed to remove file")}},G=async q=>{try{const X=await fetch(`/api/file/${q}`);if(!X.ok)throw new Error("Failed to fetch file content");const ie=await X.json();s(q),a(ie.content)}catch{yt.error("Failed to load file content")}};return x.jsxs("div",{className:"flex flex-col",style:{height:"650px"},children:[x.jsx("div",{className:"bg-gray-800 p-2 border-b border-gray-700",children:x.jsx("div",{className:"flex justify-between items-center",children:x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("h2",{className:"text-white text-lg font-semibold",children:"File Groups"}),x.jsx("div",{className:"flex gap-2",children:x.jsx(an,{type:"primary",icon:x.jsx(Pa,{}),onClick:()=>m(!0),className:"bg-blue-600 hover:bg-blue-700 border-none"})})]})})}),x.jsx("div",{className:"flex-1 overflow-hidden",children:x.jsxs("div",{className:"h-full flex",children:[x.jsx("div",{className:"w-60 bg-gray-900 border-r border-gray-700 overflow-y-auto p-4",children:x.jsx(od,{dataSource:n,rowKey:"name",rowClassName:q=>q.name===(t==null?void 0:t.name)?"bg-blue-600":"bg-transparent",onRow:q=>({onClick:()=>i(q),className:"cursor-pointer hover:bg-gray-800"}),className:"dark-mode-table",size:"small",pagination:!1,columns:[{title:"Group",dataIndex:"name",key:"name",render:(q,X)=>x.jsxs("div",{className:"flex justify-between items-center",children:[x.jsx("span",{className:"text-white font-medium",children:q}),x.jsx("span",{className:"text-gray-500 text-xs",children:X.files.length})]})},{title:"Action",key:"action",width:40,render:(q,X)=>x.jsx(an,{type:"text",danger:!0,icon:x.jsx(Ac,{}),onClick:ie=>{ie.stopPropagation(),te(X.name)}})}],locale:{emptyText:x.jsx("div",{className:"py-4",children:x.jsx(So,{description:x.jsx("span",{className:"text-gray-400",children:"No file groups yet"}),image:So.PRESENTED_IMAGE_SIMPLE,className:"custom-empty-state"})})}})}),x.jsx("div",{className:"w-80 bg-gray-900 border-r border-gray-700 overflow-y-auto p-4",children:x.jsx(E_n,{selectedGroup:t,onFileSelect:G,onRemoveFile:Z,onUpdateDescription:async(q,X)=>{try{if(!(await fetch(`/api/file-groups/${q}/files`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:X})})).ok)throw new Error("Failed to update description");return t&&(t.description=X),Promise.resolve()}catch(ie){return Promise.reject(ie)}},onAddExternalFile:()=>H(!0)})}),x.jsx("div",{className:"min-w-[16rem] max-w-[16rem] bg-gray-900 border-r border-gray-700 overflow-hidden",children:x.jsx("div",{className:"h-full w-full overflow-x-auto overflow-y-auto",children:x.jsx(x_n,{treeData:l,checkedKeys:h,onCheckedKeysChange:f,onFileSelect:G,onAddFiles:se,selectedGroup:t,onRefreshTree:V})})}),x.jsx("div",{className:"flex-1 bg-gray-900",children:r?x.jsx(O7,{height:"100%",defaultLanguage:"plaintext",language:rme(r||""),theme:"vs-dark",value:o,options:{readOnly:!0,minimap:{enabled:!0},fontSize:14,lineNumbers:"on",folding:!0,automaticLayout:!0}}):x.jsx("div",{className:"h-full flex items-center justify-center",children:x.jsx(So,{description:x.jsx("span",{className:"text-gray-400",children:"Select a file to preview"}),image:So.PRESENTED_IMAGE_SIMPLE,className:"custom-empty-state"})})})]})}),x.jsx(Gr,{title:"Add External File",open:j,className:"dark-theme-modal",styles:{content:{backgroundColor:"#1f2937",padding:"20px"},header:{backgroundColor:"#1f2937",borderBottom:"1px solid #374151"},body:{backgroundColor:"#1f2937"},mask:{backgroundColor:"rgba(0, 0, 0, 0.6)"}},onOk:async()=>{if(!t||!F.trim())return;const q=F.trim(),X=q.startsWith("http://")||q.startsWith("https://");try{let ie=[];if(X)ie=[q];else{const Ae=encodeURIComponent(q),be=await fetch(`/api/list-files?dir_path=${Ae}`);if(!be.ok)throw new Error("Failed to list files");const ve=await be.json();if(Array.isArray(ve))ie=ve.map(xe=>xe.path);else{yt.error("Unexpected response from list-files API");return}}await fetch(`/api/file-groups/${t.name}/files`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:ie})}),yt.success("External file(s) added successfully"),H(!1),U(""),K();const ce=(await(await fetch("/api/file-groups")).json()).groups.find(Ae=>Ae.name===t.name);ce&&i(ce)}catch(ie){console.error(ie),yt.error("Failed to add external file(s)")}},onCancel:()=>{H(!1),U("")},okButtonProps:{disabled:!F.trim()},children:x.jsx("div",{className:"space-y-4",children:x.jsxs("div",{children:[x.jsx("label",{className:"block text-sm font-medium text-gray-200 mb-2",children:"File Path or URL"}),x.jsx(Xn,{value:F,onChange:q=>U(q.target.value),placeholder:"Enter full file path or URL (e.g., /absolute/path/to/file or https://example.com/file)",className:"bg-gray-800 border-gray-700 text-gray-200"})]})})}),x.jsx(Gr,{title:"Create New Group",open:g,onOk:Q,onCancel:()=>m(!1),okButtonProps:{disabled:!p.trim()},className:"dark-theme-modal",styles:{content:{backgroundColor:"#1f2937",padding:"20px"},header:{backgroundColor:"#1f2937",borderBottom:"1px solid #374151"},body:{backgroundColor:"#1f2937"},mask:{backgroundColor:"rgba(0, 0, 0, 0.6)"}},children:x.jsxs("div",{className:"space-y-4",children:[x.jsxs("div",{children:[x.jsx("label",{className:"block text-sm font-medium text-gray-200 mb-2",children:"Group Name"}),x.jsx(Xn,{value:p,onChange:q=>A(q.target.value),placeholder:"Enter group name",className:"bg-gray-800 border-gray-700 text-gray-200"})]}),x.jsxs("div",{children:[x.jsx("label",{className:"block text-sm font-medium text-gray-200 mb-2",children:"Description"}),x.jsx(Xn.TextArea,{value:v,onChange:q=>_(q.target.value),placeholder:"Enter group description",rows:4,className:"bg-gray-800 border-gray-700 text-gray-200"})]})]})}),x.jsx(Gr,{title:"Auto Create Groups",open:y,onOk:async()=>{E(!0);try{const q=await fetch("/api/file-groups/auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_size_limit:L,group_num_limit:T,skip_diff:B})});if(!q.ok)throw new Error("Failed to auto create groups");const X=await q.json();X.groups&&Array.isArray(X.groups)&&(P(X.groups.map(ie=>({...ie,selected:!0}))),W(!0)),await K(),C(!1)}catch{yt.error("Failed to create groups automatically")}finally{E(!1)}},onCancel:()=>{S||C(!1)},confirmLoading:S,okButtonProps:{loading:S},cancelButtonProps:{disabled:S},className:"dark-theme-modal",styles:{content:{backgroundColor:"#1f2937",padding:"20px"},header:{backgroundColor:"#1f2937",borderBottom:"1px solid #374151"},body:{backgroundColor:"#1f2937"},mask:{backgroundColor:"rgba(0, 0, 0, 0.6)"}},children:x.jsxs("div",{className:"space-y-4",children:[x.jsxs("div",{children:[x.jsx("label",{className:"block text-sm font-medium text-gray-200 mb-2",children:"Number of Latest Files to Process"}),x.jsx(Xn,{type:"number",value:L,onChange:q=>I(parseInt(q.target.value)||100),placeholder:"Default: 100",className:"dark-theme-input"})]}),x.jsxs("div",{children:[x.jsx("label",{className:"block text-sm font-medium text-gray-200 mb-2",children:"Maximum Number of Groups"}),x.jsx(Xn,{type:"number",value:T,onChange:q=>D(parseInt(q.target.value)||10),placeholder:"Default: 10",className:"dark-theme-input"})]}),x.jsxs("div",{className:"flex items-center space-x-2",children:[x.jsx(Cf,{checked:B,onChange:R,className:"bg-gray-600"}),x.jsx("span",{className:"text-gray-200",children:"Skip Git Diff Information"})]})]})}),x.jsx(Gr,{title:"Select Groups to Create",open:$,onOk:async()=>{try{const q=O.filter(X=>X.selected);for(const X of q)await fetch("/api/file-groups",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:X.name,description:X.description})});await K(),yt.success("Selected groups created successfully"),W(!1)}catch{yt.error("Failed to create selected groups")}},onCancel:()=>{W(!1),P([])},width:800,className:"dark-theme-modal",styles:{content:{backgroundColor:"#1f2937",padding:"20px"},header:{backgroundColor:"#1f2937",borderBottom:"1px solid #374151"},body:{backgroundColor:"#1f2937"},mask:{backgroundColor:"rgba(0, 0, 0, 0.6)"}},children:x.jsx("div",{className:"space-y-4",children:O.map((q,X)=>x.jsx("div",{className:"p-4 bg-gray-800 rounded-lg",children:x.jsxs("div",{className:"flex items-center space-x-3",children:[x.jsx(yA,{checked:q.selected,onChange:ie=>{const oe=[...O];oe[X].selected=ie.target.checked,P(oe)}}),x.jsxs("div",{className:"flex-1",children:[x.jsx("h3",{className:"text-white font-medium text-lg",children:q.name}),x.jsx("p",{className:"text-gray-400 text-sm mt-1",children:q.description})]})]})},X))})})]})},I_n=({availableKeys:n,onModelChange:e})=>{const[t,i]=b.useState([]),[r,s]=b.useState(!1),[o,a]=b.useState(!1),[l,c]=b.useState({model:"",code_model:[],chat_model:"",generate_rerank_model:"",index_model:"",index_filter_model:"",commit_model:""}),d=async()=>{s(!0);try{const g=await fetch("/api/models");if(!g.ok)throw new Error("Failed to fetch models");const m=await g.json();i(m)}catch(g){console.error("Error fetching models:",g),yt.error(J("processingError"))}finally{s(!1)}},u=async g=>{try{const m=await fetch(`/api/conf/${g}`,{method:"DELETE"});if(!m.ok){let p="Failed to delete configuration key";try{const A=await m.json();A&&A.detail&&(p=A.detail)}catch{}throw new Error(p)}}catch(m){console.error(`Error deleting configuration key ${g}:`,m),yt.error(m.message||`Failed to delete ${g}`)}};b.useEffect(()=>{d()},[]),b.useEffect(()=>{(async()=>{a(!0);try{const m=await fetch("/api/conf");if(!m.ok)throw new Error("Failed to fetch configuration");const A=(await m.json()).conf,v={...l};A.model&&(v.model=A.model),A.code_model&&(v.code_model=typeof A.code_model=="string"?A.code_model.split(","):A.code_model),A.chat_model&&(v.chat_model=A.chat_model),A.generate_rerank_model&&(v.generate_rerank_model=A.generate_rerank_model),A.index_model&&(v.index_model=A.index_model),A.index_filter_model&&(v.index_filter_model=A.index_filter_model),A.commit_model&&(v.commit_model=A.commit_model),c(v)}catch(m){console.error("Error fetching current configuration:",m)}finally{a(!1)}})()},[]),b.useEffect(()=>{const g={...l};n.forEach(m=>{(m.key==="model"||m.key==="code_model"||m.key==="chat_model"||m.key==="generate_rerank_model"||m.key==="index_model"||m.key==="index_filter_model"||m.key==="commit_model")&&!g[m.key]&&(g[m.key]=m.value||"")}),c(g)},[n]),b.useEffect(()=>{const g=p=>{const A=Array.isArray(p)?p:[];c(v=>JSON.stringify(v.code_model)!==JSON.stringify(A)?(console.log("ModelConfig received update:",A),{...v,code_model:A}):v)},m=Ki.subscribe(Qi.CONFIG.CODE_MODEL_UPDATED,g);return()=>{m()}},[]);const h=(g,m)=>{const p=Array.isArray(m)?m.length===0:m==="";if(c(A=>({...A,[g]:m})),p)u(g),e(g,Array.isArray(m)?"":m);else{let A=m;if(g==="code_model"&&Array.isArray(m)&&(A=m.join(",")),e(g,A),g==="code_model"&&!p){const v=Array.isArray(m)?m:[];JSON.stringify(l.code_model)!==JSON.stringify(v)&&(console.log("ModelConfig publishing update:",v),Ki.publish(Qi.CONFIG.CODE_MODEL_UPDATED,v))}}},f={loading:r||o,className:"custom-select",popupClassName:"custom-select-dropdown",showSearch:!0,filterOption:(g,m)=>(m==null?void 0:m.label.toLowerCase().includes(g.toLowerCase()))||!1,style:{width:"100%"}};return r||o?x.jsxs("div",{className:"space-y-2",children:[x.jsx(Mf.Input,{active:!0,block:!0,style:{height:32,backgroundColor:"#1e293b"}}),x.jsx(Mf.Input,{active:!0,block:!0,style:{height:32,backgroundColor:"#1e293b"}}),x.jsx(Mf.Input,{active:!0,block:!0,style:{height:32,backgroundColor:"#1e293b"}}),x.jsx(Mf.Input,{active:!0,block:!0,style:{height:32,backgroundColor:"#1e293b"}})]}):x.jsxs("div",{children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("h3",{className:"settings-title",children:J("modelConfiguration")}),x.jsx(an,{type:"text",icon:x.jsx(n_,{}),onClick:()=>{d()},loading:r,className:"text-gray-400 hover:text-white"})]}),x.jsxs("div",{className:"space-y-3",children:[x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("defaultModel")}),x.jsx(ki,{...f,allowClear:!0,value:l.model||void 0,onChange:g=>h("model",g||""),options:t.map(g=>({value:g.name,label:g.name}))}),x.jsx("p",{className:"model-config-description",children:J("defaultModelDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("codeModel")}),x.jsx(ki,{...f,allowClear:!0,mode:"multiple",value:l.code_model||[],onChange:g=>h("code_model",g||[]),options:t.map(g=>({value:g.name,label:g.name})),tagRender:g=>{const{label:m,value:p,closable:A,onClose:v}=g;return x.jsx(aA,{color:"blue",closable:A,onClose:v,style:{marginRight:3},children:m})}}),x.jsx("p",{className:"model-config-description",children:J("codeModelDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("chatModel")}),x.jsx(ki,{...f,allowClear:!0,value:l.chat_model||void 0,onChange:g=>h("chat_model",g||""),options:t.map(g=>({value:g.name,label:g.name}))}),x.jsx("p",{className:"model-config-description",children:J("chatModelDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("rerankModel")}),x.jsx(ki,{...f,allowClear:!0,value:l.generate_rerank_model||void 0,onChange:g=>h("generate_rerank_model",g||""),options:t.map(g=>({value:g.name,label:g.name}))}),x.jsx("p",{className:"model-config-description",children:J("rerankModelDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("indexModel")}),x.jsx(ki,{...f,allowClear:!0,value:l.index_model||void 0,onChange:g=>h("index_model",g||""),options:t.map(g=>({value:g.name,label:g.name}))}),x.jsx("p",{className:"model-config-description",children:J("indexModelDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("indexFilterModel")}),x.jsx(ki,{...f,allowClear:!0,value:l.index_filter_model||void 0,onChange:g=>h("index_filter_model",g||""),options:t.map(g=>({value:g.name,label:g.name}))}),x.jsx("p",{className:"model-config-description",children:J("indexFilterModelDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("commitModel")}),x.jsx(ki,{...f,allowClear:!0,value:l.commit_model||void 0,onChange:g=>h("commit_model",g||""),options:t.map(g=>({value:g.name,label:g.name}))}),x.jsx("p",{className:"model-config-description",children:J("commitModelDescription")})]})]})]})},L_n=({visible:n,onClose:e,model:t})=>{const[i,r]=b.useState(""),[s,o]=b.useState(!1),[a,l]=b.useState([]),c=async()=>{if(i.trim()){o(!0),l(u=>[...u,{role:"user",content:i}]);try{const u=await d(i,t);u&&typeof u=="object"&&u.error?l(h=>[...h,{role:"error",content:u.error}]):(l(h=>[...h,{role:"assistant",content:u}]),r(""))}catch(u){l(h=>[...h,{role:"error",content:u.message||"对话失败"}])}finally{o(!1)}}},d=async(u,h)=>{try{const g=await(await fetch("/api/direct_chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:typeof h=="string"?h:(h==null?void 0:h.name)||"v3_chat",content:u,product_mode:(h==null?void 0:h.product_mode)||"lite"})})).json();return g.success?g.result:{error:g.error||"模型返回失败"}}catch(f){return{error:f.message||"请求失败"}}};return x.jsxs(Gr,{open:n,title:J("modelDialogTestTitle"),onCancel:e,footer:null,width:540,className:"dark-modal",destroyOnClose:!0,children:[x.jsxs("div",{style:{minHeight:240,maxHeight:340,overflowY:"auto",background:"#1e293b",borderRadius:8,padding:12,marginBottom:12},children:[a.length===0&&x.jsx("div",{style:{color:"#64748b",textAlign:"center",marginTop:60},children:J("noDialogMessages")||"暂无消息"}),a.map((u,h)=>x.jsx("div",{style:{marginBottom:8,textAlign:u.role==="user"?"right":"left"},children:x.jsx("span",{style:{display:"inline-block",background:u.role==="user"?"#0ea5e9":u.role==="error"?"#fff1f0":"#334155",color:u.role==="user"?"#fff":u.role==="error"?"#d4380d":"#e0e7ef",borderRadius:6,padding:"6px 12px",maxWidth:320,wordBreak:"break-all",border:u.role==="error"?"1.5px solid #ff4d4f":void 0,fontWeight:u.role==="error"?500:void 0},children:u.content})},h)),s&&x.jsx("div",{style:{textAlign:"center",marginTop:12},children:x.jsx(zh,{})})]}),x.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8,marginBottom:4},children:[x.jsx(Xn,{style:{flex:1,color:"#fff",height:40,borderRadius:8},value:i,onChange:u=>r(u.target.value),onPressEnter:c,disabled:s,placeholder:J("dialogInputPlaceholder")||"请输入内容...",autoFocus:!0,className:"model-chat-input-dark"}),x.jsx(an,{type:"primary",icon:x.jsx(Pbt,{}),onClick:c,loading:s,disabled:!i.trim(),style:{height:40,borderRadius:8,padding:"0 24px",fontWeight:500,fontSize:16,display:"flex",alignItems:"center",boxShadow:"0 2px 8px rgba(30,64,175,0.10)",background:"linear-gradient(90deg, #2563eb 0%, #3b82f6 100%)",border:"none",color:"#fff"},children:J("send")||"发送"})]})]})},N_n=()=>{var O;const[n,e]=b.useState(!1),[t,i]=b.useState(null),[r]=Rn.useForm(),[s,o]=b.useState([]),[a,l]=b.useState([]),[c,d]=b.useState(!1),[u,h]=b.useState(!1),[f,g]=b.useState(!1),[m,p]=b.useState(null),[A,v]=b.useState(""),_=async()=>{d(!0);try{const P=await fetch("/api/models");if(!P.ok)throw new Error("Failed to fetch models");const $=await P.json();o($)}catch(P){console.error("Error fetching models:",P),yt.error(J("modelOperationFailed",{message:String(P)}))}finally{d(!1)}},y=async()=>{h(!0);try{const P=await fetch("/api/providers");if(!P.ok)throw new Error("Failed to fetch providers");const $=await P.json();l($)}catch(P){console.error("Error fetching providers:",P),yt.error(J("modelOperationFailed",{message:String(P)}))}finally{h(!1)}};b.useEffect(()=>{_(),y();const P=()=>{console.log("Received provider update event, refreshing providers..."),y()},$=Ki.subscribe(Qi.PROVIDER.UPDATED,P);return()=>{$()}},[]);const C=async P=>{try{const $={...P,input_price:Number(P.input_price),output_price:Number(P.output_price),average_speed:Number(P.average_speed||0),max_output_tokens:Number(P.max_output_tokens||8096)};let W="/api/models";const j=m?"PUT":"POST";if(m&&(W=`/api/models?model_name=${encodeURIComponent(m.name)}`),!(await fetch(W,{method:j,headers:{"Content-Type":"application/json"},body:JSON.stringify($)})).ok)throw new Error("Failed to save model");yt.success(J(m?"modelUpdateSuccess":"modelAddSuccess")),g(!1),_(),Ki.publish(Qi.CONFIG.MODEL_LIST_UPDATED)}catch($){console.error("Error saving model:",$),yt.error(J("modelOperationFailed",{message:String($)}))}},S=async P=>{try{if(!(await fetch(`/api/models?model_name=${encodeURIComponent(P)}`,{method:"DELETE"})).ok)throw new Error("Failed to delete model");yt.success(J("modelDeleteSuccess")),_(),Ki.publish(Qi.CONFIG.MODEL_LIST_UPDATED)}catch($){console.error("Error deleting model:",$),yt.error(J("modelOperationFailed",{message:String($)}))}},E=P=>{p(P),r.setFieldsValue({...P,provider:I(P.base_url)}),v(I(P.base_url)),g(!0)},L=()=>{p(null),r.resetFields(),v(""),g(!0)},I=P=>{const $=a.find(W=>W.base_url===P);return $?$.name:""},T=P=>{v(P);const $=a.find(W=>W.name===P);$?(r.setFieldValue("base_url",$.base_url),r.setFieldValue("model_type",$.model_type||"saas/openai"),r.setFieldValue("provider",P),r.setFieldValue("model_name",void 0),r.setFieldValue("input_price",void 0),r.setFieldValue("output_price",void 0),r.setFieldValue("is_reasoning",!1)):(r.setFieldValue("base_url",void 0),r.setFieldValue("model_type",void 0),r.setFieldValue("model_name",void 0),r.setFieldValue("input_price",void 0),r.setFieldValue("output_price",void 0),r.setFieldValue("is_reasoning",!1))},D=()=>{y(),yt.success(J("modelOperationFailed",{message:"Providers refreshed"}))},B=P=>{const $=a.find(W=>W.name===A);if($){const W=$.models.find(j=>j.id===P);W&&r.setFieldsValue({model_name:P,input_price:W.input_price,output_price:W.output_price,is_reasoning:W.is_reasoning,name:P,max_output_tokens:W.max_output_tokens||8096})}},R=[{title:J("modelName"),dataIndex:"name",key:"name"},{title:J("modelDescription"),dataIndex:"description",key:"description",ellipsis:!0},{title:J("modelProvider"),dataIndex:"base_url",key:"provider",render:P=>{const $=I(P);return J($)||$}},{title:J("modelType"),dataIndex:"model_name",key:"model_name"},{title:J("modelTypeInterface"),dataIndex:"model_type",key:"model_type"},{title:J("modelInputPrice"),dataIndex:"input_price",key:"input_price"},{title:J("modelOutputPrice"),dataIndex:"output_price",key:"output_price"},{title:J("modelIsReasoning"),dataIndex:"is_reasoning",key:"is_reasoning",render:P=>P?"✓":"✗"},{title:J("modelApiKeyConfigured")||"API Key已配置",dataIndex:"api_key",key:"api_key_configured",render:P=>P&&P.trim()!==""?"✓":x.jsx("span",{style:{color:"red"},children:"✗"})},{title:J("more"),key:"action",render:(P,$)=>x.jsxs("div",{className:"flex gap-2",children:[x.jsx(an,{type:"text",icon:x.jsx(Bu,{}),onClick:()=>E($),title:J("editModel"),className:"dark-button"}),x.jsx(an,{type:"text",icon:x.jsx(A3,{}),onClick:()=>{i($),e(!0)},title:J("dialogTest"),className:"dark-button"}),x.jsx(F1,{title:J("confirmDeleteModel"),onConfirm:()=>S($.name),okText:J("confirm"),cancelText:J("cancel"),overlayClassName:"dark-popconfirm",children:x.jsx(an,{type:"text",danger:!0,icon:x.jsx(Ac,{}),title:J("deleteModel"),className:"dark-button"})})]})}];return x.jsxs("div",{className:"model-management-container p-2 overflow-y-auto h-full bg-gray-900",children:[x.jsxs("div",{className:"flex justify-between items-center mb-4",children:[x.jsx("h2",{className:"text-xl text-white",children:J("modelManagement")}),x.jsxs("div",{className:"flex gap-2",children:[x.jsxs(an,{icon:x.jsx(n_,{}),onClick:()=>{_(),y()},className:"dark-button",children:[u||c?x.jsx(zh,{size:"small"}):null,J("more")]}),x.jsx(an,{type:"primary",icon:x.jsx(Pa,{}),onClick:L,className:"dark-button",children:J("addModel")})]})]}),x.jsx(od,{dataSource:s,columns:R,rowKey:"name",loading:c,pagination:{pageSize:10},className:"model-table dark-table",locale:{emptyText:x.jsx("div",{className:"text-gray-400 py-8",children:"No data"})}}),x.jsx(Gr,{title:x.jsx("span",{className:"text-white",children:J(m?"editModel":"addModel")}),open:f,onCancel:()=>g(!1),footer:null,width:700,className:"dark-modal",closeIcon:x.jsx("span",{className:"text-white",children:"×"}),children:x.jsxs(Rn,{form:r,layout:"vertical",onFinish:C,initialValues:{is_reasoning:!1,average_speed:0},className:"dark-form",children:[x.jsx(Rn.Item,{name:"name",label:x.jsxs("span",{className:"text-white",children:[x.jsx(er,{title:J("modelNameTooltip"),children:x.jsx(IE,{style:{color:"white",marginRight:4}})}),J("modelName")]}),rules:[{required:!0,message:"Please input model name"}],children:x.jsx(Xn,{className:"dark-input"})}),x.jsx(Rn.Item,{name:"description",label:x.jsx("span",{className:"text-white",children:J("modelDescription")}),children:x.jsx(Xn.TextArea,{rows:2,className:"dark-input"})}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(Rn.Item,{name:"provider",label:x.jsx("span",{className:"text-white",children:J("modelProvider")}),rules:[{required:!0,message:"Please select provider"}],children:x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(ki,{onChange:T,className:"dark-select flex-1",loading:u,allowClear:!0,children:a.map(P=>x.jsx(ki.Option,{value:P.name,children:J(P.name)||P.name},P.name))}),x.jsx(an,{icon:x.jsx(n_,{}),onClick:D,className:"dark-button",title:J("more")})]})}),x.jsx(Rn.Item,{name:"model_type",label:x.jsx("span",{className:"text-white",children:J("modelTypeInterface")}),rules:[{required:!0,message:"Interface type is required"}],children:x.jsx(Xn,{disabled:!0,className:"dark-input"})})]}),x.jsx(Rn.Item,{name:"model_name",label:x.jsxs("span",{className:"text-white",children:[x.jsx(er,{title:J("modelTypeTooltip"),children:x.jsx(IE,{style:{color:"white",marginRight:4}})}),J("modelType")]}),rules:[{required:!0,message:"Please select model type"}],children:x.jsx(ki,{onChange:B,disabled:!A,className:"dark-select",children:A&&((O=a.find(P=>P.name===A))==null?void 0:O.models.map(P=>x.jsx(ki.Option,{value:P.id,children:P.name},P.id)))})}),x.jsx(Rn.Item,{name:"base_url",label:x.jsx("span",{className:"text-white",children:J("modelBaseUrl")}),rules:[{required:!0,message:"Please input base URL"}],children:x.jsx(Xn,{disabled:!0,className:"dark-input"})}),x.jsx(Rn.Item,{name:"api_key",label:x.jsx("span",{className:"text-white",children:J("modelApiKey")}),rules:[{required:!0,message:"Please input API key"}],children:x.jsx(Xn.Password,{placeholder:"Path to API key file (optional)",className:"dark-input",iconRender:P=>P?x.jsx(c5e,{}):x.jsx(d5e,{})})}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(Rn.Item,{name:"input_price",label:x.jsx("span",{className:"text-white",children:J("modelInputPrice")}),rules:[{required:!0,message:"Please input price"}],children:x.jsx(Xn,{type:"number",step:"0.1",min:"0",className:"dark-input"})}),x.jsx(Rn.Item,{name:"output_price",label:x.jsx("span",{className:"text-white",children:J("modelOutputPrice")}),rules:[{required:!0,message:"Please input price"}],children:x.jsx(Xn,{type:"number",step:"0.1",min:"0",className:"dark-input"})})]}),x.jsx(Rn.Item,{name:"average_speed",label:x.jsx("span",{className:"text-white",children:J("modelAverageSpeed")}),children:x.jsx(Xn,{type:"number",step:"0.1",min:"0",className:"dark-input"})}),x.jsx(Rn.Item,{name:"max_output_tokens",label:x.jsx("span",{className:"text-white",children:J("maxOutputTokens")||"Max Output Tokens"}),children:x.jsx(Xn,{type:"number",step:"1",min:"1",placeholder:"Defaults to 8096",className:"dark-input"})}),x.jsx(Rn.Item,{name:"is_reasoning",label:x.jsx("span",{className:"text-white",children:J("modelIsReasoning")}),valuePropName:"checked",children:x.jsx(Cf,{className:"dark-switch"})}),x.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[x.jsx(an,{onClick:()=>g(!1),className:"dark-button",children:J("cancelModelEdit")}),x.jsx(an,{type:"primary",htmlType:"submit",className:"dark-button",children:J("saveModel")})]})]})}),x.jsx(L_n,{visible:n,onClose:()=>e(!1),model:t})]})},T_n=()=>{const[n]=Rn.useForm(),[e,t]=b.useState([]),[i,r]=b.useState(!1),[s,o]=b.useState(!1),[a,l]=b.useState(null),c=async()=>{r(!0);try{const m=await fetch("/api/providers");if(!m.ok)throw new Error("Failed to fetch providers");const p=await m.json();t(p)}catch(m){console.error("Error fetching providers:",m),yt.error(J("modelOperationFailed",{message:String(m)}))}finally{r(!1)}};b.useEffect(()=>{c()},[]);const d=async m=>{try{const p={name:m.name,base_url:m.base_url,model_type:m.model_type,models:m.models||[]},A=a?`/api/providers/${a.name}`:"/api/providers";if(!(await fetch(A,{method:a?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)})).ok)throw new Error("Failed to save provider");yt.success(J(a?"providerUpdateSuccess":"providerAddSuccess")),o(!1),c(),Ki.publish(Qi.PROVIDER.UPDATED)}catch(p){console.error("Error saving provider:",p),yt.error(J("modelOperationFailed",{message:String(p)}))}},u=async m=>{try{if(!(await fetch(`/api/providers/${m}`,{method:"DELETE"})).ok)throw new Error("Failed to delete provider");yt.success(J("providerDeleteSuccess")),c(),Ki.publish(Qi.PROVIDER.UPDATED)}catch(p){console.error("Error deleting provider:",p),yt.error(J("modelOperationFailed",{message:String(p)}))}},h=m=>{l(m),n.setFieldsValue({...m}),o(!0)},f=()=>{l(null),n.resetFields(),n.setFieldsValue({models:[{id:"",name:"",input_price:0,output_price:0,is_reasoning:!1}]}),o(!0)},g=[{title:J("providerName"),dataIndex:"name",key:"name"},{title:J("providerBaseUrl"),dataIndex:"base_url",key:"base_url",ellipsis:!0},{title:J("providerModels"),dataIndex:"models",key:"models",render:m=>`${m.length} ${m.length===1?"model":"models"}`},{title:J("more"),key:"action",render:(m,p)=>x.jsxs("div",{className:"flex gap-2",children:[x.jsx(an,{type:"text",icon:x.jsx(Bu,{}),onClick:()=>h(p),title:J("editProvider"),className:"dark-button"}),x.jsx(F1,{title:J("confirmDeleteProvider"),onConfirm:()=>u(p.name),okText:J("confirm"),cancelText:J("cancel"),overlayClassName:"dark-popconfirm",children:x.jsx(an,{type:"text",danger:!0,icon:x.jsx(Ac,{}),title:J("deleteProvider"),className:"dark-button"})})]})}];return x.jsxs("div",{className:"provider-management-container p-2 overflow-y-auto h-full bg-gray-900",children:[x.jsxs("div",{className:"flex justify-between items-center mb-4",children:[x.jsx("h2",{className:"text-xl text-white",children:J("providerManagement")}),x.jsx(an,{type:"primary",icon:x.jsx(Pa,{}),onClick:f,className:"dark-button",children:J("addProvider")})]}),x.jsx(od,{dataSource:e,columns:g,rowKey:"name",loading:i,pagination:{pageSize:10},className:"provider-table dark-table",locale:{emptyText:x.jsx("div",{className:"text-gray-400 py-8",children:"No data"})}}),x.jsx(Gr,{title:x.jsx("span",{className:"text-white",children:J(a?"editProvider":"addProvider")}),open:s,onCancel:()=>o(!1),footer:null,width:800,className:"dark-modal",closeIcon:x.jsx("span",{className:"text-white",children:"×"}),children:x.jsxs(Rn,{form:n,layout:"vertical",onFinish:d,className:"dark-form",children:[x.jsx(Rn.Item,{name:"name",label:x.jsx("span",{className:"text-white",children:J("providerName")}),rules:[{required:!0,message:"Please input provider name"}],children:x.jsx(Xn,{className:"dark-input"})}),x.jsx(Rn.Item,{name:"base_url",label:x.jsx("span",{className:"text-white",children:J("providerBaseUrl")}),rules:[{required:!0,message:"Please input base URL"}],children:x.jsx(Xn,{className:"dark-input"})}),x.jsx(Rn.Item,{name:"model_type",label:x.jsx("span",{className:"text-white",children:J("modelTypeInterface")}),initialValue:"saas/openai",children:x.jsxs(ki,{className:"dark-select",children:[x.jsx(ki.Option,{value:"saas/openai",children:"saas/openai"}),x.jsx(ki.Option,{value:"saas/gemini",children:"saas/gemini"})]})}),x.jsxs("div",{className:"mb-4",children:[x.jsx("label",{className:"text-white block mb-2",children:J("providerModels")}),x.jsx(Rn.List,{name:"models",children:(m,{add:p,remove:A})=>x.jsxs(x.Fragment,{children:[m.map(({key:v,name:_,...y})=>x.jsxs("div",{className:"bg-gray-800 p-3 mb-3 rounded-md",children:[x.jsxs("div",{className:"flex justify-between items-center mb-2",children:[x.jsxs("span",{className:"text-white",children:["Model #",_+1]}),x.jsx(an,{type:"text",icon:x.jsx(fbt,{}),onClick:()=>A(_),className:"dark-button"})]}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(Rn.Item,{...y,name:[_,"id"],label:x.jsx("span",{className:"text-white",children:"Model ID"}),tooltip:{title:J("modelIdTooltip"),icon:x.jsx(IE,{style:{color:"white"}})},rules:[{required:!0,message:"Please input model ID"}],children:x.jsx(Xn,{className:"dark-input"})}),x.jsx(Rn.Item,{...y,name:[_,"name"],label:x.jsx("span",{className:"text-white",children:"Model Name"}),tooltip:{title:J("modelNameTooltip"),icon:x.jsx(IE,{style:{color:"white"}})},rules:[{required:!0,message:"Please input model name"}],children:x.jsx(Xn,{className:"dark-input"})})]}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(Rn.Item,{...y,name:[_,"input_price"],label:x.jsx("span",{className:"text-white",children:J("modelInputPrice")}),rules:[{required:!0,message:"Please input price"}],children:x.jsx(Xn,{type:"number",step:"0.1",min:"0",className:"dark-input"})}),x.jsx(Rn.Item,{...y,name:[_,"output_price"],label:x.jsx("span",{className:"text-white",children:J("modelOutputPrice")}),rules:[{required:!0,message:"Please input price"}],children:x.jsx(Xn,{type:"number",step:"0.1",min:"0",className:"dark-input"})})]}),x.jsx(Rn.Item,{...y,name:[_,"is_reasoning"],label:x.jsx("span",{className:"text-white",children:J("modelIsReasoning")}),valuePropName:"checked",children:x.jsx("input",{type:"checkbox",className:"mr-2"})})]},v)),x.jsx(Rn.Item,{children:x.jsx(an,{type:"dashed",onClick:()=>p({id:"",name:"",input_price:0,output_price:0,is_reasoning:!1}),icon:x.jsx(Sbt,{}),className:"dark-button w-full",children:"Add Model"})})]})})]}),x.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[x.jsx(an,{onClick:()=>o(!1),className:"dark-button",children:J("cancel")}),x.jsx(an,{type:"primary",htmlType:"submit",className:"dark-button",children:J("save")})]})]})})]})},D_n=()=>{const[n,e]=b.useState([]),[t,i]=b.useState(!1),[r,s]=b.useState(!1),[o,a]=b.useState(null),[l]=Rn.useForm(),c=async()=>{i(!0);try{const A=await fetch("/api/compilers");if(!A.ok)throw new Error("Failed to fetch compilers");const v=await A.json();e(v.data||[])}catch(A){console.error("Error fetching compilers:",A),yt.error(J("processingError"))}finally{i(!1)}},d=async()=>{i(!0);try{const A=await fetch("/api/compilers/initialize",{method:"POST"});if(!A.ok)throw new Error("Failed to initialize compilers");const v=await A.json();e(v.data||[]),yt.success(J("settingsUpdateSuccess"))}catch(A){console.error("Error initializing compilers:",A),yt.error(J("processingError"))}finally{i(!1)}};b.useEffect(()=>{c()},[]);const u=()=>{a(null),l.resetFields(),s(!0)},h=A=>{a(A),l.setFieldsValue({...A,args:A.args}),s(!0)},f=()=>{s(!1)},g=async()=>{try{const v={...await l.validateFields()};let _;if(o?_=await fetch(`/api/compilers/${o.name}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(v)}):_=await fetch("/api/compilers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(v)}),!_.ok){const y=await _.json();throw new Error(y.detail||"Failed to save compiler")}yt.success(o?J("compilerUpdateSuccess")||"Compiler updated successfully":J("compilerCreateSuccess")||"Compiler created successfully"),s(!1),c()}catch(A){console.error("Error saving compiler:",A),yt.error(A instanceof Error?A.message:J("processingError"))}},m=async A=>{try{const v=await fetch(`/api/compilers/${A}`,{method:"DELETE"});if(!v.ok){const _=await v.json();throw new Error(_.detail||"Failed to delete compiler")}yt.success(J("compilerDeleteSuccess")||"Compiler deleted successfully"),c()}catch(v){console.error("Error deleting compiler:",v),yt.error(v instanceof Error?v.message:J("processingError"))}},p=[{title:J("compilerName")||"Name",dataIndex:"name",key:"name"},{title:J("compilerType")||"Type",dataIndex:"type",key:"type"},{title:J("workingDirectory")||"Working Directory",dataIndex:"working_dir",key:"working_dir",ellipsis:!0},{title:J("compilerCommand")||"Command",dataIndex:"command",key:"command"},{title:J("actions")||"Actions",key:"actions",render:(A,v)=>x.jsxs(GC,{size:"small",children:[x.jsx(an,{type:"text",icon:x.jsx(Bu,{}),onClick:()=>h(v),className:"text-gray-400 hover:text-white dark-button"}),x.jsx(F1,{title:J("deleteConfirmation")||"Are you sure you want to delete this compiler?",onConfirm:()=>m(v.name),okText:J("yes")||"Yes",cancelText:J("no")||"No",children:x.jsx(an,{type:"text",danger:!0,icon:x.jsx(Ac,{}),className:"text-gray-400 hover:text-red-500 dark-button"})})]})}];return x.jsxs("div",{children:[x.jsxs("div",{className:"flex items-center justify-between mb-4",children:[x.jsx("h3",{className:"settings-title",children:J("compilerConfiguration")||"Compiler Configuration"}),x.jsxs(GC,{children:[x.jsx(an,{type:"text",icon:x.jsx(n_,{}),onClick:c,loading:t,className:"text-gray-400 hover:text-white dark-button"}),x.jsx(an,{type:"primary",icon:x.jsx(Pa,{}),onClick:u,className:"bg-blue-600 hover:bg-blue-700 dark-button",children:J("addCompiler")||"Add Compiler"}),n.length===0&&x.jsx(an,{onClick:d,className:"bg-green-600 hover:bg-green-700 text-white dark-button",children:J("initializeDefault")||"Initialize Default"})]})]}),x.jsx(od,{dataSource:n,columns:p,rowKey:"name",loading:t,pagination:!1,className:"compiler-table dark-table",locale:{emptyText:J("noCompilers")||"No compilers configured"}}),x.jsx(Gr,{title:o?J("editCompiler")||"Edit Compiler":J("addCompiler")||"Add Compiler",open:r,onCancel:f,onOk:g,okText:J("save")||"Save",cancelText:J("cancel")||"Cancel",className:"dark-modal",children:x.jsxs(Rn,{form:l,layout:"vertical",name:"compilerForm",className:"dark-form",children:[x.jsx(Rn.Item,{name:"name",label:J("compilerName")||"Name",rules:[{required:!0,message:J("nameRequired")||"Please enter a name"}],children:x.jsx(Xn,{disabled:!!o,className:"dark-input"})}),x.jsx(Rn.Item,{name:"type",label:J("compilerType")||"Type",rules:[{required:!0,message:J("typeRequired")||"Please enter a build tool type"}],children:x.jsx(Xn,{className:"dark-input",placeholder:J("compilerTypePlaceholder")||"Enter build tool type (e.g. maven, vite)"})}),x.jsx(Rn.Item,{name:"working_dir",label:J("workingDirectory")||"Working Directory",rules:[{required:!0,message:J("workingDirRequired")||"Please enter a working directory"}],children:x.jsx(Xn,{className:"dark-input",placeholder:J("workingDirPlaceholder")||"Enter relative path for working directory"})}),x.jsx(Rn.Item,{name:"command",label:J("compilerCommand")||"Command",rules:[{required:!0,message:J("compilerCommandRequired")||"Please enter a command"}],children:x.jsx(Xn,{className:"dark-input"})}),x.jsx(Rn.Item,{name:"args",label:J("arguments")||"Arguments",children:x.jsx(ki,{mode:"tags",className:"dark-select compiler-select compiler-tag-select",dropdownClassName:"dark-select-dropdown",placeholder:J("enterArguments")||"Enter arguments, separated by spaces",tokenSeparators:[" "]})}),x.jsx(Rn.Item,{name:"triggers",label:J("triggersLabel")||"Source file extensions",children:x.jsx(ki,{mode:"tags",className:"dark-select compiler-select compiler-tag-select",dropdownClassName:"dark-select-dropdown",placeholder:J("enterFileExtensions")||"Enter file extensions (e.g. .py,.js)",tokenSeparators:[","]})}),x.jsx(Rn.Item,{name:"extract_regex",label:J("extractRegex")||"Error Extraction Regex",tooltip:J("extractRegexTooltip")||"Regular expression to extract error information from compiler output",children:x.jsx(Xn,{className:"dark-input"})})]})})]})},R_n=()=>{const[n,e]=b.useState([]),[t,i]=b.useState(!1),[r,s]=b.useState(!1),[o,a]=b.useState(null),[l]=Rn.useForm(),c=async()=>{i(!0);try{const p=await fetch("/api/rags");if(!p.ok)throw new Error("Failed to fetch RAGs");const A=await p.json();e(A.data||[])}catch(p){console.error("Error fetching RAGs:",p),yt.error(J("processingError"))}finally{i(!1)}};b.useEffect(()=>{c()},[]);const d=()=>{a(null),l.resetFields(),s(!0)},u=p=>{a(p),l.setFieldsValue({...p}),s(!0)},h=()=>{s(!1)},f=async()=>{try{const A={...await l.validateFields()};let v;if(o?v=await fetch(`/api/rags/${o.name}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)}):v=await fetch("/api/rags",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)}),!v.ok){const _=await v.json();throw new Error(_.detail||"Failed to save RAG")}yt.success(o?J("ragUpdateSuccess")||"RAG updated successfully":J("ragAddSuccess")||"RAG added successfully"),s(!1),c(),EventBus.publish(EVENTS.RAG.UPDATED),EventBus.publish(EVENTS.RAG.UPDATED)}catch(p){console.error("Error saving RAG:",p),yt.error(p instanceof Error?p.message:J("processingError"))}},g=async p=>{try{const A=await fetch(`/api/rags/${p}`,{method:"DELETE"});if(!A.ok){const v=await A.json();throw new Error(v.detail||"Failed to delete RAG")}yt.success(J("ragDeleteSuccess")||"RAG deleted successfully"),c()}catch(A){console.error("Error deleting RAG:",A),yt.error(A instanceof Error?A.message:J("processingError"))}},m=[{title:J("ragName")||"Name",dataIndex:"name",key:"name"},{title:J("ragBaseUrl")||"RAG URL",dataIndex:"base_url",key:"base_url",ellipsis:!0},{title:J("ragApiKey")||"API Key",dataIndex:"api_key",key:"api_key",render:p=>p?"••••••••":""},{title:J("actions")||"Actions",key:"actions",render:(p,A)=>x.jsxs(GC,{size:"small",children:[x.jsx(an,{type:"text",icon:x.jsx(Bu,{}),onClick:()=>u(A),className:"text-gray-400 hover:text-white dark-button"}),x.jsx(F1,{title:J("confirmDeleteRag")||"Are you sure you want to delete this RAG?",onConfirm:()=>g(A.name),okText:J("yes")||"Yes",cancelText:J("no")||"No",children:x.jsx(an,{type:"text",danger:!0,icon:x.jsx(Ac,{}),className:"text-gray-400 hover:text-red-500 dark-button"})})]})}];return x.jsxs("div",{children:[x.jsxs("div",{className:"flex items-center justify-between mb-4",children:[x.jsx("h3",{className:"settings-title",children:J("ragConfiguration")||"RAG Configuration"}),x.jsxs(GC,{children:[x.jsx(an,{type:"text",icon:x.jsx(n_,{}),onClick:c,loading:t,className:"text-gray-400 hover:text-white dark-button"}),x.jsx(an,{type:"primary",icon:x.jsx(Pa,{}),onClick:d,className:"bg-blue-600 hover:bg-blue-700 dark-button",children:J("addRag")||"Add RAG"})]})]}),x.jsx(od,{dataSource:n,columns:m,rowKey:"name",loading:t,pagination:!1,className:"compiler-table dark-table",locale:{emptyText:J("noRags")||"No RAGs configured"}}),x.jsx(Gr,{title:o?J("editRag")||"Edit RAG":J("addRag")||"Add RAG",open:r,onCancel:h,onOk:f,okText:J("save")||"Save",cancelText:J("cancel")||"Cancel",className:"dark-modal",children:x.jsxs(Rn,{form:l,layout:"vertical",name:"ragForm",className:"dark-form",children:[x.jsx(Rn.Item,{name:"name",label:J("ragName")||"Name",rules:[{required:!0,message:J("nameRequired")||"Please enter a name"}],children:x.jsx(Xn,{disabled:!!o,className:"dark-input"})}),x.jsx(Rn.Item,{name:"base_url",label:J("ragBaseUrl")||"RAG URL",rules:[{required:!0,message:"Please enter RAG URL"}],children:x.jsx(Xn,{className:"dark-input"})}),x.jsx(Rn.Item,{name:"api_key",label:J("ragApiKey")||"API Key",rules:[{required:!0,message:"Please enter API Key"}],children:x.jsx(Xn.Password,{className:"dark-input",defaultValue:"xxxx"})})]})})]})},M_n=({availableKeys:n,onSettingChange:e})=>{const[t,i]=b.useState(!1),[r,s]=b.useState({project_type:"",index_filter_model_max_input_length:51200,conversation_prune_safe_zone_tokens:51200,auto_merge:"editblock",generate_times_same_model:1,rank_times_same_model:1,enable_agentic_filter:!1,enable_agentic_edit:!1,skip_build_index:!1,skip_filter_index:!1});b.useEffect(()=>{(async()=>{i(!0);try{const l=await fetch("/api/conf");if(!l.ok)throw new Error("Failed to fetch configuration");const d=(await l.json()).conf,u={...r};d.project_type!==void 0&&(u.project_type=d.project_type),d.index_filter_model_max_input_length!==void 0&&(u.index_filter_model_max_input_length=Number(d.index_filter_model_max_input_length)),d.conversation_prune_safe_zone_tokens!==void 0&&(u.conversation_prune_safe_zone_tokens=Number(d.conversation_prune_safe_zone_tokens)),d.auto_merge!==void 0&&(u.auto_merge=d.auto_merge),d.generate_times_same_model!==void 0&&(u.generate_times_same_model=Number(d.generate_times_same_model)),d.rank_times_same_model!==void 0&&(u.rank_times_same_model=Number(d.rank_times_same_model)),d.enable_agentic_filter!==void 0&&(u.enable_agentic_filter=String(d.enable_agentic_filter).toLowerCase()==="true"),d.enable_agentic_edit!==void 0&&(u.enable_agentic_edit=String(d.enable_agentic_edit).toLowerCase()==="true"),d.skip_build_index!==void 0&&(u.skip_build_index=String(d.skip_build_index).toLowerCase()==="true"),d.skip_filter_index!==void 0&&(u.skip_filter_index=String(d.skip_filter_index).toLowerCase()==="true"),s(u)}catch(l){console.error("Error fetching current configuration:",l)}finally{i(!1)}})()},[]),b.useEffect(()=>{const a={...r};n.forEach(l=>{l.key==="project_type"&&a.project_type===void 0&&(a.project_type=l.default||""),l.key==="index_filter_model_max_input_length"&&a.index_filter_model_max_input_length===void 0&&(a.index_filter_model_max_input_length=Number(l.default)||51200),l.key==="conversation_prune_safe_zone_tokens"&&a.conversation_prune_safe_zone_tokens===void 0&&(a.conversation_prune_safe_zone_tokens=Number(l.default)||51200),l.key==="auto_merge"&&a.auto_merge===void 0&&(a.auto_merge=l.default||"editblock"),l.key==="generate_times_same_model"&&a.generate_times_same_model===void 0&&(a.generate_times_same_model=Number(l.default)||1),l.key==="rank_times_same_model"&&a.rank_times_same_model===void 0&&(a.rank_times_same_model=Number(l.default)||1),l.key==="enable_agentic_filter"&&a.enable_agentic_filter===void 0&&(a.enable_agentic_filter=String(l.default).toLowerCase()==="true"||!1),l.key==="enable_agentic_edit"&&a.enable_agentic_edit===void 0&&(a.enable_agentic_edit=String(l.default).toLowerCase()==="true"||!1),l.key==="skip_build_index"&&a.skip_build_index===void 0&&(a.skip_build_index=String(l.default).toLowerCase()==="true"||!1),l.key==="skip_filter_index"&&a.skip_filter_index===void 0&&(a.skip_filter_index=String(l.default).toLowerCase()==="true"||!1)}),s(a)},[n]);const o=(a,l)=>{s(c=>({...c,[a]:l})),e(a,l)};return t?x.jsx("div",{className:"p-4 text-white",children:J("loading")}):x.jsx("div",{className:"p-2 text-white",children:x.jsxs("div",{className:"space-y-2",children:[x.jsxs("div",{className:"model-config-item",children:[x.jsx(er,{title:J("projectTypeTooltip")||"Specify file extensions (e.g., .py,.ts) to help the model understand the project context.",children:x.jsx("label",{className:"model-config-label",children:J("projectType")||"Project Type"})}),x.jsx("div",{className:"mt-1",children:x.jsx(ki,{mode:"tags",size:"small",style:{width:"100%"},placeholder:"e.g. .py,.ts",value:r.project_type?r.project_type.split(","):[],onChange:a=>o("project_type",a.join(",")),className:"custom-select",tokenSeparators:[","],maxTagCount:"responsive"})}),x.jsx("p",{className:"model-config-description",children:J("projectTypeDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx(er,{title:J("enableBuildIndexTooltip")||"If enabled, the system will automatically build or update the code index.",children:x.jsx("label",{className:"model-config-label",children:J("enableBuildIndexToggle")||"Enable Build Index"})}),x.jsx("div",{className:"mt-1",children:x.jsx(ki,{value:!r.skip_build_index,onChange:a=>o("skip_build_index",!a),size:"small",style:{width:"100%"},options:[{value:!0,label:J("enable")},{value:!1,label:J("disable")}]})}),x.jsx("p",{className:"model-config-description",children:J("enableBuildIndexDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx(er,{title:J("enableFilterIndexTooltip")||"If enabled, the system will automatically filter the index when processing queries.",children:x.jsx("label",{className:"model-config-label",children:J("enableFilterIndexToggle")||"Enable Filter Index"})}),x.jsx("div",{className:"mt-1",children:x.jsx(ki,{value:!r.skip_filter_index,onChange:a=>o("skip_filter_index",!a),size:"small",style:{width:"100%"},options:[{value:!0,label:J("enable")},{value:!1,label:J("disable")}]})}),x.jsx("p",{className:"model-config-description",children:J("enableFilterIndexDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("enableAgenticFilter")}),x.jsx("div",{className:"mt-1",children:x.jsx(ki,{value:r.enable_agentic_filter,onChange:a=>o("enable_agentic_filter",a),size:"small",style:{width:"100%"},options:[{value:!0,label:J("enable")},{value:!1,label:J("disable")}]})}),x.jsx("p",{className:"model-config-description",children:J("enableAgenticFilterDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("enableAgenticEdit")}),x.jsx("div",{className:"mt-1",children:x.jsx(ki,{value:r.enable_agentic_edit,onChange:a=>o("enable_agentic_edit",a),size:"small",style:{width:"100%"},options:[{value:!0,label:J("enable")},{value:!1,label:J("disable")}]})}),x.jsx("p",{className:"model-config-description",children:J("enableAgenticEditDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("indexMaxInputLength")}),x.jsx("div",{className:"mt-1",children:x.jsx(r2,{value:r.index_filter_model_max_input_length,onChange:a=>o("index_filter_model_max_input_length",a??51200),min:1e3,max:1e6,size:"small"})}),x.jsx("p",{className:"model-config-description",children:J("indexMaxInputLengthDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("conversationPruneSafeZoneTokens")||"Conversation Prune Safe Zone Tokens"}),x.jsx("div",{className:"mt-1",children:x.jsx(r2,{value:r.conversation_prune_safe_zone_tokens,onChange:a=>o("conversation_prune_safe_zone_tokens",a??51200),min:1e3,max:1e6,size:"small"})}),x.jsx("p",{className:"model-config-description",children:J("conversationPruneSafeZoneTokensDescription")||"Reserved token count during context pruning to avoid losing important information."})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("autoMergeMethod")}),x.jsx("div",{className:"mt-1",children:x.jsx(ki,{value:r.auto_merge,onChange:a=>o("auto_merge",a),size:"small",style:{width:"100%"},options:[{value:"wholefile",label:J("wholeFile")},{value:"editblock",label:J("editBlock")},{value:"diff",label:J("diff")},{value:"strict_diff",label:J("strictDiff")}]})}),x.jsx("p",{className:"model-config-description",children:J("autoMergeMethodDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("generateTimesSameModel")}),x.jsx("div",{className:"mt-1",children:x.jsx(r2,{value:r.generate_times_same_model,onChange:a=>o("generate_times_same_model",a??1),min:1,max:10,size:"small"})}),x.jsx("p",{className:"model-config-description",children:J("generateTimesSameModelDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsx("label",{className:"model-config-label",children:J("rankTimesSameModel")}),x.jsx("div",{className:"mt-1",children:x.jsx(r2,{value:r.rank_times_same_model,onChange:a=>o("rank_times_same_model",a??1),min:1,max:10,size:"small"})}),x.jsx("p",{className:"model-config-description",children:J("rankTimesSameModelDescription")})]})]})})},O_n=({availableKeys:n,onSettingChange:e})=>{const[t,i]=b.useState(!1),[r,s]=b.useState({enable_auto_fix_merge:!1,enable_auto_fix_lint:!1,enable_auto_fix_compile:!1,enable_active_context:!1,enable_active_context_in_generate:!1,enable_task_history:!1,include_project_structure:!0});b.useEffect(()=>{(async()=>{i(!0);try{const l=await fetch("/api/conf");if(!l.ok)throw new Error("Failed to fetch configuration");const d=(await l.json()).conf,u={...r};d.enable_auto_fix_merge!==void 0&&(u.enable_auto_fix_merge=d.enable_auto_fix_merge==="true"),d.enable_auto_fix_lint!==void 0&&(u.enable_auto_fix_lint=d.enable_auto_fix_lint==="true"),d.enable_auto_fix_compile!==void 0&&(u.enable_auto_fix_compile=d.enable_auto_fix_compile==="true"),d.enable_active_context!==void 0&&(u.enable_active_context=d.enable_active_context==="true"),d.enable_active_context_in_generate!==void 0&&(u.enable_active_context_in_generate=d.enable_active_context_in_generate==="true"),d.enable_task_history!==void 0&&(u.enable_task_history=d.enable_task_history==="true"),d.include_project_structure!==void 0&&(u.include_project_structure=d.include_project_structure==="true"),s(u)}catch(l){console.error("Error fetching current configuration:",l)}finally{i(!1)}})()},[]),b.useEffect(()=>{const a={...r};n.forEach(l=>{l.key==="enable_auto_fix_merge"&&a.enable_auto_fix_merge===void 0&&(a.enable_auto_fix_merge=l.default==="true"),l.key==="enable_auto_fix_lint"&&a.enable_auto_fix_lint===void 0&&(a.enable_auto_fix_lint=l.default==="true"),l.key==="enable_auto_fix_compile"&&a.enable_auto_fix_compile===void 0&&(a.enable_auto_fix_compile=l.default==="true"),l.key==="enable_active_context"&&a.enable_active_context===void 0&&(a.enable_active_context=l.default==="true"),l.key==="enable_active_context_in_generate"&&a.enable_active_context_in_generate===void 0&&(a.enable_active_context_in_generate=l.default==="true"),l.key==="enable_task_history"&&a.enable_task_history===void 0&&(a.enable_task_history=l.default==="true"),l.key==="include_project_structure"&&a.include_project_structure===void 0&&(a.include_project_structure=l.default==="true"||l.default===void 0)}),s(a)},[n]);const o=(a,l)=>{s(c=>({...c,[a]:l})),e(a,l)};return t?x.jsx("div",{className:"p-4 text-white",children:J("loading")}):x.jsxs("div",{children:[x.jsx("h3",{className:"settings-title",children:J("advancedSettings")}),x.jsxs("div",{className:"space-y-4",children:[x.jsxs("div",{className:"model-config-item",children:[x.jsxs("div",{className:"flex justify-between items-center",children:[x.jsx("label",{className:"model-config-label",children:J("advancedSettings_enableAutoFixMerge")}),x.jsx(Cf,{checked:r.enable_auto_fix_merge,onChange:a=>o("enable_auto_fix_merge",a),className:"bg-gray-600"})]}),x.jsx("p",{className:"model-config-description",children:J("advancedSettings_enableAutoFixMergeDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsxs("div",{className:"flex justify-between items-center",children:[x.jsx("label",{className:"model-config-label",children:J("enableAutoFixLint")}),x.jsx(Cf,{checked:r.enable_auto_fix_lint,onChange:a=>o("enable_auto_fix_lint",a),className:"bg-gray-600"})]}),x.jsx("p",{className:"model-config-description",children:J("enableAutoFixLintDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsxs("div",{className:"flex justify-between items-center",children:[x.jsx("label",{className:"model-config-label",children:J("enableAutoFixCompile")}),x.jsx(Cf,{checked:r.enable_auto_fix_compile,onChange:a=>o("enable_auto_fix_compile",a),className:"bg-gray-600"})]}),x.jsx("p",{className:"model-config-description",children:J("enableAutoFixCompileDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsxs("div",{className:"flex justify-between items-center",children:[x.jsx("label",{className:"model-config-label",children:J("enableActiveContext")}),x.jsx(Cf,{checked:r.enable_active_context,onChange:a=>o("enable_active_context",a),className:"bg-gray-600"})]}),x.jsx("p",{className:"model-config-description",children:J("enableActiveContextDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsxs("div",{className:"flex justify-between items-center",children:[x.jsx("label",{className:"model-config-label",children:J("enableActiveContextInGenerate")}),x.jsx(Cf,{checked:r.enable_active_context_in_generate,onChange:a=>o("enable_active_context_in_generate",a),className:"bg-gray-600"})]}),x.jsx("p",{className:"model-config-description",children:J("enableActiveContextInGenerateDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsxs("div",{className:"flex justify-between items-center",children:[x.jsx("label",{className:"model-config-label",children:J("enableTaskHistory")}),x.jsx(Cf,{checked:r.enable_task_history,onChange:a=>o("enable_task_history",a),className:"bg-gray-600"})]}),x.jsx("p",{className:"model-config-description",children:J("enableTaskHistoryDescription")})]}),x.jsxs("div",{className:"model-config-item",children:[x.jsxs("div",{className:"flex justify-between items-center",children:[x.jsx("label",{className:"model-config-label",children:J("includeProjectStructure")}),x.jsx(Cf,{checked:r.include_project_structure,onChange:a=>o("include_project_structure",a),className:"bg-gray-600"})]}),x.jsx("p",{className:"model-config-description",children:J("includeProjectStructureDescription")})]})]})]})},{Option:aOe}=ki,B_n=({visible:n,server:e,onCancel:t,onUpdateSuccess:i})=>{const[r]=Rn.useForm(),[s,o]=b.useState([]),[a,l]=b.useState(1),[c,d]=b.useState(!1);b.useEffect(()=>{if(e&&n){const p=e.env?Object.entries(e.env).map(([A,v],_)=>({id:_+1,key:A,value:v})):[];o(p),l(p.length+1),r.setFieldsValue({description:e.description||"",mcp_type:e.mcp_type||"command",command:e.command||"",args:e.args||[],url:e.url||""})}else n||(r.resetFields(),o([]))},[e,n,r]);const u=()=>{o([...s,{id:a,key:"",value:""}]),l(a+1)},h=p=>{o(s.filter(A=>A.id!==p))},f=(p,A,v)=>{o(s.map(_=>_.id===p?{..._,[A]:v}:_))},g=p=>{const A=s.filter(_=>_.key),v={};return A.forEach(_=>{v[_.key]=_.value}),{name:e==null?void 0:e.name,description:p.description||"",mcp_type:p.mcp_type||"command",command:p.mcp_type==="command"?p.command||"":void 0,args:p.args||[],env:Object.keys(v).length>0?v:void 0,url:p.mcp_type==="sse"?p.url||"":void 0}},m=async()=>{if(e)try{const p=await r.validateFields();for(const y of s)if(!y.key&&y.value){yt.error(J("envKeyRequired")||"Environment variable key is required if value is provided");return}d(!0);const A=g(p),v=await fetch("/api/mcp/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)}),_=await v.json();if(!v.ok)throw new Error(_.detail||_.message||"Updating server failed");yt.success(_.message||J("marketplaceUpdateSuccess",{name:e.name})),i(),t()}catch(p){console.error("Error updating server:",p),p instanceof Error&&p.message.includes("Failed to validate fields")||yt.error(J("marketplaceUpdateError",{error:p instanceof Error?p.message:String(p)}))}finally{d(!1)}};return x.jsx(Gr,{title:`${J("edit")||"Edit"} MCP Server: ${e==null?void 0:e.name}`,visible:n,onCancel:t,footer:[x.jsx(an,{onClick:t,className:"dark-button",children:J("cancel")||"Cancel"},"back"),x.jsx(an,{type:"primary",loading:c,onClick:m,className:"dark-button",children:J("update")||"Update"},"submit")],width:600,destroyOnClose:!0,className:"dark-modal",children:x.jsxs(Rn,{form:r,layout:"vertical",className:"dark-form",children:[x.jsx(Rn.Item,{label:"Name (Read-only)",children:x.jsx(Xn,{className:"dark-input",readOnly:!0,value:e==null?void 0:e.name})}),x.jsx(Rn.Item,{name:"description",label:J("mcpServerDescription")||"Description",children:x.jsx(Xn,{className:"dark-input",placeholder:"e.g., My updated custom MCP server"})}),x.jsx(Rn.Item,{name:"mcp_type",label:J("mcpServerType")||"Type",children:x.jsxs(ki,{className:"dark-select",dropdownClassName:"dark-select-dropdown",placeholder:"Select server type",onChange:p=>{p==="sse"&&yt.info(J("mcpSseNotSupported")||"SSE type is not currently supported."),r.validateFields(["command","url"])},children:[x.jsx(aOe,{value:"command",children:"Command"}),x.jsx(aOe,{value:"sse",children:"SSE (Server-Sent Events)"})]})}),x.jsx(Rn.Item,{noStyle:!0,shouldUpdate:(p,A)=>p.mcp_type!==A.mcp_type,children:({getFieldValue:p})=>p("mcp_type")==="command"?x.jsx(Rn.Item,{name:"command",label:J("mcpServerCommand")||"Command",rules:[{required:!0,message:J("commandRequired")||"Please enter a command"}],children:x.jsx(Xn,{className:"dark-input",placeholder:"e.g., python, npm, /path/to/executable"})}):null}),x.jsx(Rn.Item,{noStyle:!0,shouldUpdate:(p,A)=>p.mcp_type!==A.mcp_type,children:({getFieldValue:p})=>p("mcp_type")==="sse"?x.jsx(Rn.Item,{name:"url",label:J("mcpServerUrl")||"URL",rules:[{required:!0,message:J("urlRequired")||"Please enter a URL for SSE server"}],children:x.jsx(Xn,{className:"dark-input",placeholder:"e.g., http://localhost:8000/events"})}):null}),x.jsx(Rn.Item,{name:"args",label:J("mcpServerArgs")||"Arguments",children:x.jsx(ki,{mode:"tags",className:"dark-select compiler-select compiler-tag-select",dropdownClassName:"dark-select-dropdown",placeholder:"Enter arguments and press Enter/Space",tokenSeparators:[" ",`
|
1340
1340
|
`," "]})}),x.jsxs(Rn.Item,{label:J("mcpServerEnv")||"Environment Variables",children:[s.map(p=>x.jsxs("div",{className:"env-var-item",style:{display:"flex",marginBottom:8,gap:"8px"},children:[x.jsx(Xn,{className:"dark-input",placeholder:J("mcpServerKey")||"Key",value:p.key,onChange:A=>f(p.id,"key",A.target.value),style:{flex:1}}),x.jsx(Xn,{className:"dark-input",placeholder:J("mcpServerValue")||"Value",value:p.value,onChange:A=>f(p.id,"value",A.target.value),style:{flex:1}}),x.jsx(an,{type:"text",danger:!0,icon:x.jsx(Ac,{}),onClick:()=>h(p.id),className:"dark-button"})]},p.id)),x.jsx(an,{type:"dashed",onClick:u,icon:x.jsx(Pa,{}),className:"dark-dashed-button w-full",children:J("mcpServerAddEnv")||"Add Variable"})]})]})})},P_n=()=>{const[n,e]=b.useState([]),[t,i]=b.useState(!0),[r,s]=b.useState(null),[o,a]=b.useState(!1),[l,c]=b.useState(null),d=b.useCallback(async()=>{var p;i(!0);try{const A=await fetch("/api/mcp/list"),v=await A.json();if(!A.ok)throw new Error(v.detail||"Failed to fetch server list");const _=v;if((p=_.raw_result)!=null&&p.error)throw new Error(_.raw_result.error);if(!_.raw_result){console.warn("API response missing raw_result field."),e([]);return}const y=[],C=(_.raw_result.external_servers||[]).map(E=>({...E,displayType:"External"})),S=(_.raw_result.marketplace_items||[]).map(E=>({...E,displayType:"Marketplace"}));e([...y,...C,...S])}catch(A){console.error("Error fetching marketplace servers:",A),yt.error(A instanceof Error?A.message:J("mcpListBuiltinError",{error:"Unknown error"}))}finally{i(!1)}},[]);b.useEffect(()=>{d()},[d]);const u=async p=>{s(p);try{const v=await fetch("/api/mcp/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({server_config:p})}),_=await v.json();if(!v.ok)throw new Error(_.detail||_.message||"Installation failed");yt.success(_.message||J("mcpInstallSuccess",{result:p}))}catch(A){console.error(`Error installing server ${p}:`,A),yt.error(J("mcpInstallError",{error:A instanceof Error?A.message:String(A)}))}finally{s(null)}},h=p=>{c(p),a(!0)},f=()=>{a(!1),c(null)},g=()=>{a(!1),c(null),d()},m=p=>{const A=[];return(p.displayType==="External"||p.displayType==="Marketplace")&&A.push(x.jsx(an,{type:"text",icon:x.jsx(Bu,{}),onClick:()=>h(p),disabled:!!r,className:"dark-button",title:J("edit")||"Edit"},"edit")),A.push(x.jsx(an,{type:"primary",icon:x.jsx(Ivt,{}),onClick:()=>u(p.name),loading:r===p.name,disabled:!!r,className:"dark-button",children:J("install")||"Install"},"install")),A};return x.jsxs(x.Fragment,{children:[x.jsx(zh,{spinning:t,children:n.length===0&&!t?x.jsx(So,{description:J("noServersAvailable")||"No servers available"}):x.jsx(fc,{itemLayout:"horizontal",dataSource:n.sort((p,A)=>`${p.displayType}-${p.name}`.localeCompare(`${A.displayType}-${A.name}`)),renderItem:p=>x.jsx(fc.Item,{className:"mcp-server-list-item",actions:m(p),children:x.jsx(fc.Item.Meta,{title:x.jsx("span",{className:"server-info",children:`${p.displayType}: ${p.name}`}),description:x.jsx("span",{className:"server-description",children:p.description||"No description available"})})})})}),x.jsx(B_n,{visible:o,server:l,onCancel:f,onUpdateSuccess:g})]})},{Option:HJ}=ki,{TabPane:lOe}=Sp,F_n=()=>{const[n]=Rn.useForm(),[e,t]=b.useState([]),[i,r]=b.useState(1),[s,o]=b.useState(!1),[a,l]=b.useState([]),[c,d]=b.useState(!1),[u,h]=b.useState("builtin");b.useEffect(()=>{(async()=>{try{d(!0);const C=await fetch("/api/mcp/list");if(!C.ok)throw new Error(J("fetchServerError")||"Failed to fetch MCP servers");const S=await C.json();S.raw_result&&S.raw_result.builtin_servers&&l(S.raw_result.builtin_servers)}catch(C){console.error("Error fetching MCP servers:",C),yt.error(J("fetchServerError")||"Failed to fetch MCP servers")}finally{d(!1)}})()},[]);const f=()=>{t([...e,{id:i,key:"",value:""}]),r(i+1)},g=y=>{t(e.filter(C=>C.id!==y))},m=(y,C,S)=>{t(e.map(E=>E.id===y?{...E,[C]:S}:E))},p=y=>{const C=e.filter(E=>E.key),S={};return C.forEach(E=>{S[E.key]=E.value}),{name:y.name,description:y.description||"",mcp_type:y.type||"command",command:y.command||"",args:y.args||[],env:Object.keys(S).length>0?S:null,url:y.url||""}},A=async()=>{try{const y=await n.validateFields();for(const L of e)if(!L.key){yt.error(J("envKeyRequired")||"Environment variable key is required");return}o(!0);const C=p(y),S=await fetch("/api/mcp/add",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(C)}),E=await S.json();if(!S.ok)throw new Error(E.detail||E.message||J("addToMarketplaceFailed")||"Adding server to marketplace failed");yt.success(E.message||J("marketplaceAddSuccess",{name:y.name})),n.resetFields(),t([])}catch(y){console.error("Error adding server to marketplace:",y),y instanceof Error&&y.message.includes("Failed to validate fields")||yt.error(J("marketplaceAddError",{error:y instanceof Error?y.message:String(y)}))}finally{o(!1)}},v=y=>{const C=a.find(L=>L.name===y);if(!C)return;const S=[];let E=1;C.env&&Object.entries(C.env).forEach(([L,I])=>{S.push({id:E,key:L,value:I}),E++}),n.setFieldsValue({name:C.name,description:C.description,type:C.mcp_type,command:C.command||"",args:C.args||[],url:C.url||""}),t(S),r(E)},_=()=>x.jsxs(Rn,{form:n,layout:"vertical",onFinish:A,className:"dark-form p-4",children:[x.jsx(Rn.Item,{name:"name",label:J("mcpServerName"),rules:[{required:!0,message:J("nameRequired")}],children:x.jsx(Xn,{className:"dark-input",placeholder:J("mcpServerNamePlaceholder")})}),x.jsx(Rn.Item,{name:"description",label:J("mcpServerDescription"),children:x.jsx(Xn,{className:"dark-input",placeholder:J("mcpServerDescriptionPlaceholder")})}),x.jsx(Rn.Item,{name:"type",label:J("mcpServerType"),initialValue:"command",children:x.jsxs(ki,{className:"dark-select",placeholder:J("mcpServerTypePlaceholder"),onChange:y=>{y==="sse"&&yt.info(J("mcpSseNotSupported")||"SSE type is not currently supported.")},children:[x.jsx(HJ,{value:"command",children:J("mcpTypeCommand")}),x.jsx(HJ,{value:"sse",children:J("mcpTypeSse")})]})}),x.jsx(Rn.Item,{name:"command",label:J("mcpServerCommand"),rules:[({getFieldValue:y})=>({validator(C,S){return y("type")==="sse"||S?Promise.resolve():Promise.reject(new Error(J("commandRequired")))}})],children:x.jsx(Xn,{className:"dark-input",placeholder:J("mcpServerCommandPlaceholder")})}),x.jsx(Rn.Item,{name:"args",label:J("mcpServerArgs"),children:x.jsx(ki,{mode:"tags",className:"dark-select compiler-select compiler-tag-select",dropdownClassName:"dark-select-dropdown",placeholder:J("mcpServerArgsPlaceholder"),tokenSeparators:[" ",`
|
1341
1341
|
`," "]})}),x.jsxs(Rn.Item,{label:J("mcpServerEnv"),children:[e.map((y,C)=>x.jsxs("div",{className:"env-var-item",children:[x.jsx(Xn,{className:"dark-input",placeholder:J("mcpServerKey"),value:y.key,onChange:S=>m(y.id,"key",S.target.value)}),x.jsx(Xn,{className:"dark-input",placeholder:J("mcpServerValue"),value:y.value,onChange:S=>m(y.id,"value",S.target.value)}),x.jsx(an,{type:"text",danger:!0,icon:x.jsx(Ac,{}),onClick:()=>g(y.id),className:"dark-button"})]},y.id)),x.jsx(an,{type:"dashed",onClick:f,icon:x.jsx(Pa,{}),className:"dark-dashed-button w-full",children:J("mcpServerAddEnv")})]}),x.jsx(Rn.Item,{name:"url",label:J("mcpServerUrl"),rules:[({getFieldValue:y})=>({validator(C,S){return y("type")!=="sse"||S?Promise.resolve():Promise.reject(new Error(J("urlRequired")))}})],children:x.jsx(Xn,{className:"dark-input",placeholder:J("mcpServerUrlPlaceholder")})}),x.jsx(Rn.Item,{children:x.jsx(an,{type:"primary",htmlType:"submit",loading:s,className:"dark-button",children:J("addToMarketplace")})})]});return x.jsxs("div",{className:"manually-add-mcp-container",children:[x.jsx("style",{children:`
|
1342
1342
|
.env-var-item {
|
@@ -1,13 +1,13 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: auto_coder_web
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.92
|
4
4
|
Summary: auto-coder.web: A Python Project
|
5
5
|
Author: allwefantasy
|
6
6
|
Classifier: Programming Language :: Python :: 3.10
|
7
7
|
Classifier: Programming Language :: Python :: 3.11
|
8
8
|
Classifier: Programming Language :: Python :: 3.12
|
9
9
|
Description-Content-Type: text/markdown
|
10
|
-
Requires-Dist: auto-coder >=0.1.
|
10
|
+
Requires-Dist: auto-coder >=0.1.361
|
11
11
|
Requires-Dist: aiofiles
|
12
12
|
Requires-Dist: psutil
|
13
13
|
Requires-Dist: watchdog
|
@@ -8,7 +8,7 @@ auto_coder_web/lang.py,sha256=cXypkDesnMwZ0U6D_CZtxhDTAOp__hoJzYTulQ_8xPc,1108
|
|
8
8
|
auto_coder_web/proxy.py,sha256=m-J6dtOF0oNnW9BS-Lh6azGZRrvHn1RZ-DEPmZ9NJ3Y,11771
|
9
9
|
auto_coder_web/terminal.py,sha256=jtAH7FaC573cgxc7FnI_mOZ3D2dSCO3PrZN0OehtbNQ,9521
|
10
10
|
auto_coder_web/types.py,sha256=TT-0UruUi67wz7w1DpjFyYeaCnkdKYviJvlpSnrdtD4,1435
|
11
|
-
auto_coder_web/version.py,sha256=
|
11
|
+
auto_coder_web/version.py,sha256=jibR5k16CvIIIRqIusW7mrU6CMM0wet7LwtTuFLXbmU,23
|
12
12
|
auto_coder_web/common_router/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
13
|
auto_coder_web/common_router/active_context_router.py,sha256=wbwG-J2iS5uBorN20q2PVoyJCVueECBR66xYjtIEWhM,6228
|
14
14
|
auto_coder_web/common_router/auto_coder_conf_router.py,sha256=oIRZE5OqeSfp-TYkGtX1M1Qd54iBYxftQtDbivdRj1o,1059
|
@@ -86,7 +86,7 @@ auto_coder_web/web/assets/liquid-CPaH0eVF.js,sha256=uXE_OsLEw3W8B-ReZOUwybkJu3J6
|
|
86
86
|
auto_coder_web/web/assets/lua-nf6ki56Z.js,sha256=O3vMsGoiFHDMGSxTP1bHnDnRPebfmFnC7kf8-ovGkO8,2369
|
87
87
|
auto_coder_web/web/assets/m3-Cpb6xl2v.js,sha256=PmotBCyVZvUGHh9t9juODmjXptTEP5K6bnPj2WgYO6c,3063
|
88
88
|
auto_coder_web/web/assets/main-edBorJ-r.css,sha256=2EjqbJmBx8v_d7KU5EIUMrfTMTQz5suqTLPWurl1k7A,242355
|
89
|
-
auto_coder_web/web/assets/main.js,sha256=
|
89
|
+
auto_coder_web/web/assets/main.js,sha256=19fcIW4q5ad6QLVIfK3bixVTmoPYNPVlxK5f4MG2vAI,6654180
|
90
90
|
auto_coder_web/web/assets/markdown-DSZPf7rp.js,sha256=3ZMgfYxjKX9U8l6GFCNrO28Hj7JU-4rKrEqXIezyqT4,4034
|
91
91
|
auto_coder_web/web/assets/mdx-DRx1b0qs.js,sha256=awzor_jnBNHRhTxk3_jcpGXsNUFbi9Ow0OIqWYq4CQA,5113
|
92
92
|
auto_coder_web/web/assets/mips-B_c3zf-v.js,sha256=L4uNgcwtDWPbyL0qnO-2w9x2PdI02UJcc8yQrYnHahA,2825
|
@@ -240,8 +240,8 @@ auto_coder_web/web/monaco-editor/min/vs/language/typescript/tsWorker.js,sha256=_
|
|
240
240
|
auto_coder_web/web/sounds/ding-dong.wav,sha256=BveDrGCyt_YMHaJwFJ80L5NfbUF5cl5QjzR-SRehxTk,35324
|
241
241
|
auto_coder_web/web/sounds/gentle-notification.wav,sha256=bzd0MwECdrjmNz7mbqv_y03S7WwD3G6agbIh1rWJ9cQ,72124
|
242
242
|
auto_coder_web/web/sounds/soft-chime.wav,sha256=Akpw7_rHLnX3rE13dRYpyZbmQFLGtp8P53LCdAkT9sA,40364
|
243
|
-
auto_coder_web-0.1.
|
244
|
-
auto_coder_web-0.1.
|
245
|
-
auto_coder_web-0.1.
|
246
|
-
auto_coder_web-0.1.
|
247
|
-
auto_coder_web-0.1.
|
243
|
+
auto_coder_web-0.1.92.dist-info/METADATA,sha256=eEwV9rb4zIDCQ1YVFLtp2g4xdawbYgKxzVkH001zWSM,1435
|
244
|
+
auto_coder_web-0.1.92.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
245
|
+
auto_coder_web-0.1.92.dist-info/entry_points.txt,sha256=oh8kd1ZecWDgdv-bIj_ru3phvl4scuxwXl9DK0Khltg,61
|
246
|
+
auto_coder_web-0.1.92.dist-info/top_level.txt,sha256=UCzEw494Im0KvR-FTYf2jh-okqHvLsC_0JLOrQZoSpg,15
|
247
|
+
auto_coder_web-0.1.92.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|