auto-coder-web 0.1.109__py3-none-any.whl → 0.1.110__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.109.dist-info → auto_coder_web-0.1.110.dist-info}/METADATA +2 -2
- {auto_coder_web-0.1.109.dist-info → auto_coder_web-0.1.110.dist-info}/RECORD +7 -7
- {auto_coder_web-0.1.109.dist-info → auto_coder_web-0.1.110.dist-info}/WHEEL +0 -0
- {auto_coder_web-0.1.109.dist-info → auto_coder_web-0.1.110.dist-info}/entry_points.txt +0 -0
- {auto_coder_web-0.1.109.dist-info → auto_coder_web-0.1.110.dist-info}/top_level.txt +0 -0
auto_coder_web/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.1.
|
1
|
+
__version__ = "0.1.110"
|
@@ -474,7 +474,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
474
474
|
monaco.config({ paths: { vs: '...' } })
|
475
475
|
|
476
476
|
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
477
|
-
`},y4e=f8t(A8t)(YKe),v8t={config:p8t},b8t=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return function(r){return t.reduceRight(function(s,o){return o(s)},r)}};function XKe(n,e){return Object.keys(e).forEach(function(t){e[t]instanceof Object&&n[t]&&Object.assign(e[t],XKe(n[t],e[t]))}),A4e(A4e({},n),e)}var _8t={type:"cancelation",msg:"operation is manually canceled"};function tZ(n){var e=!1,t=new Promise(function(i,r){n.then(function(s){return e?r(_8t):i(s)}),n.catch(r)});return t.cancel=function(){return e=!0},t}var y8t=d8t.create({config:h8t,isInitialized:!1,resolve:null,reject:null,monaco:null}),ZKe=qFt(y8t,2),$5=ZKe[0],iq=ZKe[1];function C8t(n){var e=v8t.config(n),t=e.monaco,i=VFt(e,["monaco"]);iq(function(r){return{config:XKe(r.config,i),monaco:t}})}function w8t(){var n=$5(function(e){var t=e.monaco,i=e.isInitialized,r=e.resolve;return{monaco:t,isInitialized:i,resolve:r}});if(!n.isInitialized){if(iq({isInitialized:!0}),n.monaco)return n.resolve(n.monaco),tZ(nZ);if(window.monaco&&window.monaco.editor)return JKe(window.monaco),n.resolve(window.monaco),tZ(nZ);b8t(S8t,E8t)(k8t)}return tZ(nZ)}function S8t(n){return document.body.appendChild(n)}function x8t(n){var e=document.createElement("script");return n&&(e.src=n),e}function E8t(n){var e=$5(function(i){var r=i.config,s=i.reject;return{config:r,reject:s}}),t=x8t("".concat(e.config.paths.vs,"/loader.js"));return t.onload=function(){return n()},t.onerror=e.reject,t}function k8t(){var n=$5(function(t){var i=t.config,r=t.resolve,s=t.reject;return{config:i,resolve:r,reject:s}}),e=window.require;e.config(n.config),e(["vs/editor/editor.main"],function(t){JKe(t),n.resolve(t)},function(t){n.reject(t)})}function JKe(n){$5().monaco||iq({monaco:n})}function L8t(){return $5(function(n){var e=n.monaco;return e})}var nZ=new Promise(function(n,e){return iq({resolve:n,reject:e})}),Sy={config:C8t,init:w8t,__getMonacoInstance:L8t},I8t={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},iZ=I8t,T8t={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},N8t=T8t;function D8t({children:n}){return Ne.createElement("div",{style:N8t.container},n)}var R8t=D8t,M8t=R8t;function O8t({width:n,height:e,isEditorReady:t,loading:i,_ref:r,className:s,wrapperProps:o}){return Ne.createElement("section",{style:{...iZ.wrapper,width:n,height:e},...o},!t&&Ne.createElement(M8t,null,i),Ne.createElement("div",{ref:r,style:{...iZ.fullWidth,...!t&&iZ.hide},className:s}))}var B8t=O8t,eQe=_.memo(B8t);function P8t(n){_.useEffect(n,[])}var tQe=P8t;function F8t(n,e,t=!0){let i=_.useRef(!0);_.useEffect(i.current||!t?()=>{i.current=!1}:n,e)}var Yh=F8t;function mR(){}function sk(n,e,t,i){return $8t(n,i)||H8t(n,e,t,i)}function $8t(n,e){return n.editor.getModel(nQe(n,e))}function H8t(n,e,t,i){return n.editor.createModel(e,t,i?nQe(n,i):void 0)}function nQe(n,e){return n.Uri.parse(e)}function z8t({original:n,modified:e,language:t,originalLanguage:i,modifiedLanguage:r,originalModelPath:s,modifiedModelPath:o,keepCurrentOriginalModel:a=!1,keepCurrentModifiedModel:l=!1,theme:c="light",loading:u="Loading...",options:d={},height:h="100%",width:f="100%",className:g,wrapperProps:m={},beforeMount:p=mR,onMount:A=mR}){let[v,b]=_.useState(!1),[y,C]=_.useState(!0),w=_.useRef(null),E=_.useRef(null),k=_.useRef(null),I=_.useRef(A),T=_.useRef(p),D=_.useRef(!1);tQe(()=>{let B=Sy.init();return B.then(F=>(E.current=F)&&C(!1)).catch(F=>(F==null?void 0:F.type)!=="cancelation"&&console.error("Monaco initialization: error:",F)),()=>w.current?M():B.cancel()}),Yh(()=>{if(w.current&&E.current){let B=w.current.getOriginalEditor(),F=sk(E.current,n||"",i||t||"text",s||"");F!==B.getModel()&&B.setModel(F)}},[s],v),Yh(()=>{if(w.current&&E.current){let B=w.current.getModifiedEditor(),F=sk(E.current,e||"",r||t||"text",o||"");F!==B.getModel()&&B.setModel(F)}},[o],v),Yh(()=>{let B=w.current.getModifiedEditor();B.getOption(E.current.editor.EditorOption.readOnly)?B.setValue(e||""):e!==B.getValue()&&(B.executeEdits("",[{range:B.getModel().getFullModelRange(),text:e||"",forceMoveMarkers:!0}]),B.pushUndoStop())},[e],v),Yh(()=>{var B,F;(F=(B=w.current)==null?void 0:B.getModel())==null||F.original.setValue(n||"")},[n],v),Yh(()=>{let{original:B,modified:F}=w.current.getModel();E.current.editor.setModelLanguage(B,i||t||"text"),E.current.editor.setModelLanguage(F,r||t||"text")},[t,i,r],v),Yh(()=>{var B;(B=E.current)==null||B.editor.setTheme(c)},[c],v),Yh(()=>{var B;(B=w.current)==null||B.updateOptions(d)},[d],v);let O=_.useCallback(()=>{var W;if(!E.current)return;T.current(E.current);let B=sk(E.current,n||"",i||t||"text",s||""),F=sk(E.current,e||"",r||t||"text",o||"");(W=w.current)==null||W.setModel({original:B,modified:F})},[t,e,r,n,i,s,o]),R=_.useCallback(()=>{var B;!D.current&&k.current&&(w.current=E.current.editor.createDiffEditor(k.current,{automaticLayout:!0,...d}),O(),(B=E.current)==null||B.editor.setTheme(c),b(!0),D.current=!0)},[d,c,O]);_.useEffect(()=>{v&&I.current(w.current,E.current)},[v]),_.useEffect(()=>{!y&&!v&&R()},[y,v,R]);function M(){var F,W,U,H;let B=(F=w.current)==null?void 0:F.getModel();a||((W=B==null?void 0:B.original)==null||W.dispose()),l||((U=B==null?void 0:B.modified)==null||U.dispose()),(H=w.current)==null||H.dispose()}return Ne.createElement(eQe,{width:f,height:h,isEditorReady:v,loading:u,_ref:k,className:g,wrapperProps:m})}var U8t=z8t;_.memo(U8t);function W8t(n){let e=_.useRef();return _.useEffect(()=>{e.current=n},[n]),e.current}var j8t=W8t,E6=new Map;function V8t({defaultValue:n,defaultLanguage:e,defaultPath:t,value:i,language:r,path:s,theme:o="light",line:a,loading:l="Loading...",options:c={},overrideServices:u={},saveViewState:d=!0,keepCurrentModel:h=!1,width:f="100%",height:g="100%",className:m,wrapperProps:p={},beforeMount:A=mR,onMount:v=mR,onChange:b,onValidate:y=mR}){let[C,w]=_.useState(!1),[E,k]=_.useState(!0),I=_.useRef(null),T=_.useRef(null),D=_.useRef(null),O=_.useRef(v),R=_.useRef(A),M=_.useRef(),B=_.useRef(i),F=j8t(s),W=_.useRef(!1),U=_.useRef(!1);tQe(()=>{let z=Sy.init();return z.then(q=>(I.current=q)&&k(!1)).catch(q=>(q==null?void 0:q.type)!=="cancelation"&&console.error("Monaco initialization: error:",q)),()=>T.current?$():z.cancel()}),Yh(()=>{var q,j,K,Z;let z=sk(I.current,n||i||"",e||r||"",s||t||"");z!==((q=T.current)==null?void 0:q.getModel())&&(d&&E6.set(F,(j=T.current)==null?void 0:j.saveViewState()),(K=T.current)==null||K.setModel(z),d&&((Z=T.current)==null||Z.restoreViewState(E6.get(s))))},[s],C),Yh(()=>{var z;(z=T.current)==null||z.updateOptions(c)},[c],C),Yh(()=>{!T.current||i===void 0||(T.current.getOption(I.current.editor.EditorOption.readOnly)?T.current.setValue(i):i!==T.current.getValue()&&(U.current=!0,T.current.executeEdits("",[{range:T.current.getModel().getFullModelRange(),text:i,forceMoveMarkers:!0}]),T.current.pushUndoStop(),U.current=!1))},[i],C),Yh(()=>{var q,j;let z=(q=T.current)==null?void 0:q.getModel();z&&r&&((j=I.current)==null||j.editor.setModelLanguage(z,r))},[r],C),Yh(()=>{var z;a!==void 0&&((z=T.current)==null||z.revealLine(a))},[a],C),Yh(()=>{var z;(z=I.current)==null||z.editor.setTheme(o)},[o],C);let H=_.useCallback(()=>{var z;if(!(!D.current||!I.current)&&!W.current){R.current(I.current);let q=s||t,j=sk(I.current,i||n||"",e||r||"",q||"");T.current=(z=I.current)==null?void 0:z.editor.create(D.current,{model:j,automaticLayout:!0,...c},u),d&&T.current.restoreViewState(E6.get(q)),I.current.editor.setTheme(o),a!==void 0&&T.current.revealLine(a),w(!0),W.current=!0}},[n,e,t,i,r,s,c,u,d,o,a]);_.useEffect(()=>{C&&O.current(T.current,I.current)},[C]),_.useEffect(()=>{!E&&!C&&H()},[E,C,H]),B.current=i,_.useEffect(()=>{var z,q;C&&b&&((z=M.current)==null||z.dispose(),M.current=(q=T.current)==null?void 0:q.onDidChangeModelContent(j=>{U.current||b(T.current.getValue(),j)}))},[C,b]),_.useEffect(()=>{if(C){let z=I.current.editor.onDidChangeMarkers(q=>{var K;let j=(K=T.current.getModel())==null?void 0:K.uri;if(j&&q.find(Z=>Z.path===j.path)){let Z=I.current.editor.getModelMarkers({resource:j});y==null||y(Z)}});return()=>{z==null||z.dispose()}}return()=>{}},[C,y]);function $(){var z,q;(z=M.current)==null||z.dispose(),h?d&&E6.set(s,T.current.saveViewState()):(q=T.current.getModel())==null||q.dispose(),T.current.dispose()}return Ne.createElement(eQe,{width:f,height:g,isEditorReady:C,loading:l,_ref:D,className:m,wrapperProps:p})}var q8t=V8t,rf=_.memo(q8t),rq=rf;Sy.config({paths:{vs:"/monaco-editor/min/vs"},"vs/nls":{availableLanguages:{"*":"zh-cn"}}});const Gbe=({initialContent:n,onContentChange:e,onEditorReady:t,onSubmit:i,onToggleCollapse:r})=>{const s=(o,a)=>{o.addCommand(a.KeyMod.CtrlCmd|a.KeyCode.Enter,()=>{i()}),r&&o.addCommand(a.KeyMod.CtrlCmd|a.KeyCode.KeyL,()=>{r()}),a.languages.registerCompletionItemProvider("markdown",{triggerCharacters:["@"],provideCompletionItems:async(l,c)=>{const u=l.getValueInRange({startLineNumber:c.lineNumber,startColumn:1,endLineNumber:c.lineNumber,endColumn:c.column}),d=l.getWordUntilPosition(c),h=u.charAt(d.startColumn-2),f=u.charAt(d.startColumn-3),g=d.word;return console.log("prefix:",h,"word:",g),h==="@"&&f==="@"?{suggestions:(await(await fetch(`/api/completions/symbols?name=${encodeURIComponent(g)}`)).json()).completions.map(v=>({label:v.display,kind:a.languages.CompletionItemKind.Function,insertText:v.path,detail:"",documentation:`Location: ${v.path}`})),incomplete:!0}:h==="@"?{suggestions:(await(await fetch(`/api/completions/files?name=${encodeURIComponent(g)}`)).json()).completions.map(v=>({label:v.display,kind:a.languages.CompletionItemKind.File,insertText:v.path,detail:"",documentation:`Location: ${v.location}`})),incomplete:!0}:{suggestions:[]}}}),t(o,a)};return S.jsx("div",{className:"h-full w-full",children:S.jsx(rf,{height:"100%",defaultLanguage:"markdown",defaultValue:n,onChange:e,theme:"vs-dark",onMount:s,loading:S.jsx("div",{className:"flex items-center justify-center h-full",children:"加载编辑器中..."}),beforeMount:o=>{window.MonacoEnvironment={getWorkerUrl:(a,l)=>"/monaco-editor/min/vs/base/worker/workerMain.js"}},options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"on",lineNumbers:"on",folding:!0,fontSize:14,tabSize:2,automaticLayout:!0,contextmenu:!0,scrollbar:{verticalScrollbarSize:12,horizontalScrollbarSize:12},suggestOnTriggerCharacters:!0,quickSuggestions:!0,acceptSuggestionOnEnter:"smart",fixedOverflowWidgets:!0,suggest:{insertMode:"replace",snippetsPreventQuickSuggestions:!1}}})})};Sy.config({paths:{vs:"/monaco-editor/min/vs"},"vs/nls":{availableLanguages:{"*":"zh-cn"}}});const G8t=_.forwardRef(({value:n,placeholder:e="",onChange:t,onSubmit:i,disabled:r=!1,onToggleExpand:s,onSelectHistoryTask:o,isProcessing:a=!1,currentEventFileId:l,onCancelTask:c,isCancelling:u=!1},d)=>{const h=_.useRef(null),[f,g]=_.useState(!1),[m,p]=_.useState([]),[A,v]=_.useState([]),[b,y]=_.useState(!1),C=_.useRef(null);_.useEffect(()=>{(async()=>{try{const O=localStorage.getItem("commandHistory");O&&p(JSON.parse(O)),await w()}catch(O){console.error("Failed to load command history",O)}})()},[]);const w=async()=>{try{y(!0);const D=await fetch("/api/auto-command/history");if(D.ok){const O=await D.json();v(O.tasks||[])}}catch(D){console.error("Failed to load task history from server",D)}finally{y(!1)}};_.useEffect(()=>{f&&w()},[f]);const E=D=>{D.trim()!==""&&p(O=>{const R=O.filter(B=>B!==D),M=[D,...R].slice(0,20);return localStorage.setItem("commandHistory",JSON.stringify(M)),M})},k=D=>{t(D),g(!1),h.current&&h.current.focus()},I=D=>{t(D.query),g(!1),o&&o(D),h.current&&h.current.focus()};_.useEffect(()=>{const D=O=>{C.current&&!C.current.contains(O.target)&&g(!1)};return f&&document.addEventListener("mousedown",D),()=>{document.removeEventListener("mousedown",D)}},[f]),_.useImperativeHandle(d,()=>({focus:()=>{h.current&&h.current.focus()},editor:h.current}));const T=(D,O)=>{h.current=D,!n&&e&&D.updateOptions({padding:{top:12,bottom:12}}),D.addCommand(O.KeyMod.CtrlCmd|O.KeyCode.Enter,()=>{n.trim()&&E(n),i()}),s&&D.addCommand(O.KeyMod.CtrlCmd|O.KeyCode.KeyL,()=>{s()}),O.languages.registerCompletionItemProvider("markdown",{triggerCharacters:["@"],provideCompletionItems:async(R,M)=>{const B=R.getValueInRange({startLineNumber:M.lineNumber,startColumn:1,endLineNumber:M.lineNumber,endColumn:M.column}),F=R.getWordUntilPosition(M),W=B.charAt(F.startColumn-2),U=B.charAt(F.startColumn-3),H=F.word;return console.log("prefix:",W,"word:",H),W==="@"&&U==="@"?{suggestions:(await(await fetch(`/api/completions/symbols?name=${encodeURIComponent(H)}`)).json()).completions.map(j=>({label:j.display,kind:O.languages.CompletionItemKind.Function,insertText:j.path,detail:"",documentation:`Location: ${j.path}`})),incomplete:!0}:W==="@"?{suggestions:(await(await fetch(`/api/completions/files?name=${encodeURIComponent(H)}`)).json()).completions.map(j=>({label:j.display,kind:O.languages.CompletionItemKind.File,insertText:j.path,detail:"",documentation:`Location: ${j.location}`})),incomplete:!0}:{suggestions:[]}}})};return S.jsxs("div",{className:"w-full h-9 rounded-full overflow-hidden bg-gray-800 border border-gray-700 shadow-lg pl-16 pr-16",children:[S.jsx("div",{className:"absolute left-3.5 top-0 bottom-0 flex items-center z-10",children:S.jsx("svg",{className:"w-4 h-4 text-purple-500 opacity-80",viewBox:"0 0 24 24",fill:"currentColor",children:S.jsx("path",{d:"M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2M7.5 13A2.5 2.5 0 0 0 5 15.5A2.5 2.5 0 0 0 7.5 18a2.5 2.5 0 0 0 2.5-2.5A2.5 2.5 0 0 0 7.5 13m9 0a2.5 2.5 0 0 0-2.5 2.5a2.5 2.5 0 0 0 2.5 2.5a2.5 2.5 0 0 0 2.5-2.5a2.5 2.5 0 0 0-2.5-2.5z"})})}),S.jsxs("div",{className:"absolute left-10 top-0 bottom-0 flex items-center z-10",children:[S.jsx("button",{type:"button",className:"p-1 rounded-full text-gray-400 hover:text-gray-200 transition-colors focus:outline-none",onClick:()=>g(!f),title:"命令历史",disabled:a||u,children:S.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:S.jsx("path",{d:"M13.5,8H12V13L16.28,15.54L17,14.33L13.5,12.25V8M13,3A9,9 0 0,0 4,12H1L4.96,16.03L9,12H6A7,7 0 0,1 13,5A7,7 0 0,1 20,12A7,7 0 0,1 13,19C11.07,19 9.32,18.21 8.06,16.94L6.64,18.36C8.27,20 10.5,21 13,21A9,9 0 0,0 22,12A9,9 0 0,0 13,3"})})}),f&&S.jsxs("div",{ref:C,className:"absolute left-0 top-full mt-2 w-96 max-h-80 overflow-y-auto bg-gray-800 border border-gray-700 rounded-md shadow-lg z-20",children:[S.jsx("div",{className:"py-1 border-b border-gray-700",children:S.jsxs("div",{className:"px-4 py-2 text-sm text-gray-300 font-semibold flex justify-between items-center",children:[S.jsx("span",{children:"历史任务"}),b?S.jsx("span",{className:"text-xs text-gray-400",children:"加载中..."}):S.jsx("button",{type:"button",className:"text-xs text-blue-400 hover:text-blue-300 focus:outline-none",onClick:w,children:"刷新"})]})}),A.length>0?S.jsx("div",{className:"mb-4",children:S.jsx("ul",{className:"py-1",children:A.map(D=>{var O;return S.jsx("li",{className:"px-3 py-2 hover:bg-gray-700 cursor-pointer",children:S.jsxs("button",{type:"button",className:"w-full text-left flex flex-col",onClick:()=>I(D),children:[S.jsx("span",{className:"text-sm text-gray-200 truncate",children:D.query}),S.jsxs("div",{className:"flex items-center text-xs mt-1",children:[S.jsx("span",{className:`px-1.5 py-0.5 rounded ${D.status==="completed"?"bg-green-900 text-green-300":"bg-red-900 text-red-300"}`,children:D.status==="completed"?"完成":"错误"}),S.jsx("span",{className:"text-gray-400 ml-2",children:new Date(D.timestamp).toLocaleString()}),S.jsxs("span",{className:"text-gray-400 ml-2",children:[((O=D.messages)==null?void 0:O.length)||0," 条消息"]}),D.event_file_id&&S.jsxs("span",{className:"text-blue-400 ml-2 flex items-center",children:[S.jsx("svg",{className:"w-3 h-3 mr-1",viewBox:"0 0 24 24",fill:"currentColor",children:S.jsx("path",{d:"M13 9h5.5L13 3.5V9M6 2h8l6 6v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4c0-1.11.89-2 2-2m9 16v-2H6v2h9m3-4v-2H6v2h12z"})}),"可恢复"]})]})]})},D.id)})})}):S.jsx("div",{className:"px-4 py-3 text-sm text-gray-400 text-center",children:b?"加载历史任务...":"没有历史任务"}),S.jsx("div",{className:"py-1 border-t border-gray-700",children:S.jsxs("div",{className:"px-4 py-2 text-sm text-gray-300 font-semibold flex justify-between items-center",children:[S.jsx("span",{children:"最近使用的命令"}),m.length>0&&S.jsx("button",{type:"button",className:"text-xs text-red-400 hover:text-red-300 focus:outline-none",onClick:()=>{window.confirm("确定要清空历史命令吗?")&&(p([]),localStorage.removeItem("commandHistory"))},children:"清空历史"})]})}),m.length>0?S.jsx("ul",{className:"py-1",children:m.map((D,O)=>S.jsx("li",{children:S.jsx("button",{type:"button",className:"w-full text-left px-4 py-2 text-sm text-gray-200 hover:bg-gray-700 truncate",onClick:()=>k(D),children:D})},O))}):S.jsx("div",{className:"px-4 py-3 text-sm text-gray-400 text-center",children:"没有本地历史命令"})]})]}),S.jsx(rf,{height:"100%",defaultLanguage:"markdown",value:n,onChange:D=>t(D||""),theme:"vs-dark",onMount:T,loading:null,beforeMount:D=>{window.MonacoEnvironment={getWorkerUrl:(O,R)=>"/monaco-editor/min/vs/base/worker/workerMain.js"}},options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"on",lineNumbers:"off",folding:!1,fontSize:12,lineHeight:16,automaticLayout:!0,contextmenu:!1,overviewRulerLanes:0,overviewRulerBorder:!1,hideCursorInOverviewRuler:!0,glyphMargin:!1,renderLineHighlight:"none",lineDecorationsWidth:0,lineNumbersMinChars:0,suggestOnTriggerCharacters:!0,quickSuggestions:!0,acceptSuggestionOnEnter:"smart",fixedOverflowWidgets:!0,padding:{top:8,bottom:8},scrollbar:{vertical:"hidden",horizontal:"hidden",useShadows:!1,alwaysConsumeMouseWheel:!1},suggest:{insertMode:"replace",snippetsPreventQuickSuggestions:!1},readOnly:r}}),S.jsxs("div",{className:"absolute right-0 top-0 bottom-0 flex items-center pr-2",children:[S.jsx("button",{type:"button",className:"p-1 mx-1 rounded-full transition-colors bg-gray-700 hover:bg-gray-600 z-10",onClick:s,disabled:a,title:"展开编辑器",children:S.jsx("svg",{className:"w-3.5 h-3.5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8h16M4 16h16"})})}),a&&l&&c?S.jsx("button",{type:"button",className:`p-1 rounded-full transition-colors z-10 ${u?"bg-gray-600 text-gray-300":"bg-red-600 hover:bg-red-700 text-white"}`,onClick:()=>{!u&&c&&l&&window.confirm("确定要取消当前运行的任务吗?")&&c(l)},disabled:u,title:u?"正在取消任务...":"取消当前任务",children:u?S.jsxs("svg",{className:"w-3.5 h-3.5 animate-spin",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[S.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),S.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"})]}):S.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:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}):S.jsx("button",{type:"button",className:"p-1 rounded-full text-white bg-indigo-600 hover:bg-indigo-700 transition-colors z-10",onClick:i,disabled:a||!n.trim(),children:S.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})})]})]})});var k6={exports:{}},C4e;function K8t(){if(C4e)return k6.exports;C4e=1;var n=typeof Reflect=="object"?Reflect:null,e=n&&typeof n.apply=="function"?n.apply:function(C,w,E){return Function.prototype.apply.call(C,w,E)},t;n&&typeof n.ownKeys=="function"?t=n.ownKeys:Object.getOwnPropertySymbols?t=function(C){return Object.getOwnPropertyNames(C).concat(Object.getOwnPropertySymbols(C))}:t=function(C){return Object.getOwnPropertyNames(C)};function i(y){console&&console.warn&&console.warn(y)}var r=Number.isNaN||function(C){return C!==C};function s(){s.init.call(this)}k6.exports=s,k6.exports.once=A,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(y){if(typeof y!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof y)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(y){if(typeof y!="number"||y<0||r(y))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+y+".");o=y}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(C){if(typeof C!="number"||C<0||r(C))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+C+".");return this._maxListeners=C,this};function l(y){return y._maxListeners===void 0?s.defaultMaxListeners:y._maxListeners}s.prototype.getMaxListeners=function(){return l(this)},s.prototype.emit=function(C){for(var w=[],E=1;E<arguments.length;E++)w.push(arguments[E]);var k=C==="error",I=this._events;if(I!==void 0)k=k&&I.error===void 0;else if(!k)return!1;if(k){var T;if(w.length>0&&(T=w[0]),T instanceof Error)throw T;var D=new Error("Unhandled error."+(T?" ("+T.message+")":""));throw D.context=T,D}var O=I[C];if(O===void 0)return!1;if(typeof O=="function")e(O,this,w);else for(var R=O.length,M=g(O,R),E=0;E<R;++E)e(M[E],this,w);return!0};function c(y,C,w,E){var k,I,T;if(a(w),I=y._events,I===void 0?(I=y._events=Object.create(null),y._eventsCount=0):(I.newListener!==void 0&&(y.emit("newListener",C,w.listener?w.listener:w),I=y._events),T=I[C]),T===void 0)T=I[C]=w,++y._eventsCount;else if(typeof T=="function"?T=I[C]=E?[w,T]:[T,w]:E?T.unshift(w):T.push(w),k=l(y),k>0&&T.length>k&&!T.warned){T.warned=!0;var D=new Error("Possible EventEmitter memory leak detected. "+T.length+" "+String(C)+" listeners added. Use emitter.setMaxListeners() to increase limit");D.name="MaxListenersExceededWarning",D.emitter=y,D.type=C,D.count=T.length,i(D)}return y}s.prototype.addListener=function(C,w){return c(this,C,w,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(C,w){return c(this,C,w,!0)};function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(y,C,w){var E={fired:!1,wrapFn:void 0,target:y,type:C,listener:w},k=u.bind(E);return k.listener=w,E.wrapFn=k,k}s.prototype.once=function(C,w){return a(w),this.on(C,d(this,C,w)),this},s.prototype.prependOnceListener=function(C,w){return a(w),this.prependListener(C,d(this,C,w)),this},s.prototype.removeListener=function(C,w){var E,k,I,T,D;if(a(w),k=this._events,k===void 0)return this;if(E=k[C],E===void 0)return this;if(E===w||E.listener===w)--this._eventsCount===0?this._events=Object.create(null):(delete k[C],k.removeListener&&this.emit("removeListener",C,E.listener||w));else if(typeof E!="function"){for(I=-1,T=E.length-1;T>=0;T--)if(E[T]===w||E[T].listener===w){D=E[T].listener,I=T;break}if(I<0)return this;I===0?E.shift():m(E,I),E.length===1&&(k[C]=E[0]),k.removeListener!==void 0&&this.emit("removeListener",C,D||w)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(C){var w,E,k;if(E=this._events,E===void 0)return this;if(E.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):E[C]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete E[C]),this;if(arguments.length===0){var I=Object.keys(E),T;for(k=0;k<I.length;++k)T=I[k],T!=="removeListener"&&this.removeAllListeners(T);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(w=E[C],typeof w=="function")this.removeListener(C,w);else if(w!==void 0)for(k=w.length-1;k>=0;k--)this.removeListener(C,w[k]);return this};function h(y,C,w){var E=y._events;if(E===void 0)return[];var k=E[C];return k===void 0?[]:typeof k=="function"?w?[k.listener||k]:[k]:w?p(k):g(k,k.length)}s.prototype.listeners=function(C){return h(this,C,!0)},s.prototype.rawListeners=function(C){return h(this,C,!1)},s.listenerCount=function(y,C){return typeof y.listenerCount=="function"?y.listenerCount(C):f.call(y,C)},s.prototype.listenerCount=f;function f(y){var C=this._events;if(C!==void 0){var w=C[y];if(typeof w=="function")return 1;if(w!==void 0)return w.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function g(y,C){for(var w=new Array(C),E=0;E<C;++E)w[E]=y[E];return w}function m(y,C){for(;C+1<y.length;C++)y[C]=y[C+1];y.pop()}function p(y){for(var C=new Array(y.length),w=0;w<C.length;++w)C[w]=y[w].listener||y[w];return C}function A(y,C){return new Promise(function(w,E){function k(T){y.removeListener(C,I),E(T)}function I(){typeof y.removeListener=="function"&&y.removeListener("error",k),w([].slice.call(arguments))}b(y,C,I,{once:!0}),C!=="error"&&v(y,k,{once:!0})})}function v(y,C,w){typeof y.on=="function"&&b(y,"error",C,w)}function b(y,C,w,E){if(typeof y.on=="function")E.once?y.once(C,w):y.on(C,w);else if(typeof y.addEventListener=="function")y.addEventListener(C,function k(I){E.once&&y.removeEventListener(C,k),w(I)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof y)}return k6.exports}var Jx=K8t();class Q8t extends Jx.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){try{const t=await fetch("/api/auto-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e})});if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);const i=await t.json();return this.eventFileId=i.event_file_id,this.startEventStream(),{event_file_id:i.event_file_id}}catch(t){throw console.error("Error executing command:",t),t}}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)},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)},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}}}const sc=new Q8t,Y8t=({projectName:n,isProcessing:e,autoSearchTerm:t,setAutoSearchTerm:i,onSubmit:r,onSelectHistoryTask:s,currentEventFileId:o})=>{const[a,l]=_.useState(!1),[c,u]=_.useState(""),[d,h]=_.useState(!1),f=_.useRef(null),g=_.useRef(null);Ne.useEffect(()=>{const C=w=>{h(!1)};return sc.on("taskComplete",C),()=>{sc.off("taskComplete",C)}},[]);const m=(C,w)=>{g.current=C,t&&u(t),C.focus()},p=()=>{a?i(c):u(t),l(!a)},A=C=>{C!==void 0&&u(C)},v=()=>{c.trim()&&(i(c),l(!1),setTimeout(()=>{const C=new Event("submit");window.lastEditorContent=c,r(C)},50))},b=()=>{if(t.trim()&&!e){const C=new Event("submit");r(C)}},y=async C=>{h(!0);try{const w=await fetch("/api/auto-command/cancel",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event_file_id:C})});if(!w.ok)throw new Error(`Failed to cancel task: ${w.statusText}`);console.log(`Task ${C} cancellation request sent`)}catch(w){console.error("Error cancelling task:",w),h(!1),alert(`Failed to cancel task: ${w}`)}};return S.jsxs(S.Fragment,{children:[a&&S.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-70 flex items-center justify-center z-50 p-4",children:S.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-xl w-full max-w-4xl p-4 border border-gray-700 flex flex-col h-[80vh] overflow-hidden",children:[S.jsxs("div",{className:"flex items-center justify-between mb-3",children:[S.jsx("h3",{className:"text-xl font-semibold text-white",children:ee("expandedEditor")}),S.jsx("button",{onClick:p,className:"text-gray-400 hover:text-white transition-colors",children:S.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),S.jsx("div",{className:"flex-1 overflow-hidden border border-gray-700 rounded-md mb-3",children:S.jsx("div",{className:"h-full w-full",children:S.jsx(Gbe,{initialContent:t,onContentChange:A,onEditorReady:m,onSubmit:v,onToggleCollapse:p})})}),S.jsxs("div",{className:"flex justify-end space-x-3",children:[S.jsx("button",{className:"px-5 py-2 bg-gray-700 text-white rounded-md hover:bg-gray-600 transition-colors focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 focus:ring-offset-gray-800",onClick:p,children:ee("cancel")}),S.jsx("button",{className:"px-5 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700 transition-colors focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 focus:ring-offset-gray-800 disabled:opacity-50 disabled:cursor-not-allowed",onClick:v,disabled:!c.trim(),children:ee("submit")})]})]})}),S.jsx("form",{onSubmit:r,className:"w-full relative mb-4 max-w-3xl mx-auto px-3 sm:px-0",children:S.jsxs("div",{className:"w-full relative",children:[S.jsx("div",{className:"absolute left-3.5 top-0 bottom-0 flex items-center z-10",children:S.jsx("svg",{className:"w-4 h-4 text-purple-500 opacity-80",viewBox:"0 0 24 24",fill:"currentColor",children:S.jsx("path",{d:"M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2M7.5 13A2.5 2.5 0 0 0 5 15.5A2.5 2.5 0 0 0 7.5 18a2.5 2.5 0 0 0 2.5-2.5A2.5 2.5 0 0 0 7.5 13m9 0a2.5 2.5 0 0 0-2.5 2.5a2.5 2.5 0 0 0 2.5 2.5a2.5 2.5 0 0 0 2.5-2.5a2.5 2.5 0 0 0-2.5-2.5z"})})}),S.jsx(G8t,{ref:f,value:t,onChange:i,onSubmit:b,disabled:e,placeholder:`${ee("searchIn")} ${n||ee("yourProject")}`,onToggleExpand:p,onSelectHistoryTask:s,isProcessing:e,currentEventFileId:o,onCancelTask:y,isCancelling:d})]})})]})},iQe=({message:n,onResponse:e,onClose:t})=>{const[i,r]=_.useState(""),[s,o]=_.useState(!1),[a,l]=_.useState(null),c=_.useRef(null),u=n.options&&n.options.length>0,d=_.useRef(null);_.useEffect(()=>{const g=m=>{d.current&&!d.current.contains(m.target)&&!n.responseRequired&&t()};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[n.responseRequired,t]);const h=async g=>{if(g.preventDefault(),i.trim()&&!s){o(!0);try{await e(i,n.eventId)}catch(m){console.error("Error submitting response:",m)}finally{o(!1)}}},f=async g=>{if(!s){l(g),o(!0);try{await e(g,n.eventId)}catch(m){console.error("Error selecting option:",m)}finally{o(!1),l(null)}}};return S.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-80 flex items-center justify-center z-50 p-4 backdrop-blur-sm",children:S.jsxs("div",{ref:d,className:"bg-gray-800 rounded-lg shadow-2xl max-w-md w-full p-5 border border-gray-600",children:[S.jsxs("div",{className:"flex items-center justify-between mb-3",children:[S.jsx("h3",{className:"text-lg font-semibold text-white",children:ee("askUserDialogTitle")}),!n.responseRequired&&S.jsx("button",{onClick:t,className:"text-gray-400 hover:text-white transition-colors","aria-label":"Close dialog",children:S.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),S.jsxs("div",{className:"mb-4",children:[S.jsx("p",{className:"text-gray-200 mb-3 text-sm leading-relaxed",children:n.content}),u&&S.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:n.options.map((g,m)=>S.jsx("button",{className:`px-3 py-1.5 rounded text-white text-sm transition-colors flex items-center justify-center min-w-[80px] ${a===g?"bg-indigo-800":"bg-indigo-600 hover:bg-indigo-700"}`,onClick:()=>f(g),disabled:s,children:a===g&&s?S.jsxs(S.Fragment,{children:[S.jsx("span",{className:"mr-2",children:g}),S.jsxs("svg",{className:"animate-spin h-4 w-4 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[S.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),S.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},m))}),S.jsx("form",{onSubmit:h,className:"mt-3",children:S.jsxs("div",{className:"flex items-center",children:[S.jsx("input",{ref:c,type:"text",className:"flex-1 bg-gray-700 border border-gray-600 rounded-l py-2 px-3 text-white text-sm focus:outline-none focus:ring-1 focus:ring-indigo-500",placeholder:ee("askUserDialogPlaceholder"),value:i,onChange:g=>r(g.target.value),disabled:s,autoFocus:!0}),S.jsx("button",{type:"submit",className:"bg-indigo-600 hover:bg-indigo-700 text-white py-2 px-3 rounded-r text-sm transition-colors border-l-0 border border-indigo-600 disabled:opacity-50 min-w-[60px]",disabled:!i.trim()||s,children:s?S.jsxs("svg",{className:"animate-spin h-4 w-4 text-white mx-auto",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[S.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),S.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"})]}):ee("askUserDialogSend")})]})})]}),n.responseRequired&&S.jsxs("div",{className:"text-xs text-amber-400 flex items-center bg-amber-900 bg-opacity-20 p-2 rounded",children:[S.jsx("svg",{className:"w-4 h-4 mr-1 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:S.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"})}),S.jsx("span",{children:ee("askUserDialogResponseRequired")})]})]})})},X8t=_.lazy(()=>Yt(()=>Promise.resolve().then(()=>Pbn),void 0)),Z8t=_.lazy(()=>Yt(()=>Promise.resolve().then(()=>$bn),void 0)),J8t=({projectName:n,onSwitchToExpertMode:e})=>{const[t,i]=_.useState(""),[r,s]=_.useState(""),[o,a]=_.useState([]),[l,c]=_.useState(!1),[u,d]=_.useState(!1),[h,f]=_.useState(null),[g,m]=_.useState(null),[p,A]=_.useState(!0),[v,b]=_.useState(!0),[y,C]=_.useState("messages"),[w,E]=_.useState([]),k=_.useRef(o);_.useEffect(()=>{k.current=o},[o]);const I=_.useCallback(async(M=!1,B,F)=>{if(!(!B||!F)){console.log(k.current);try{await fetch("/api/auto-command/save-history",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:B,event_file_id:F,messages:k.current,status:M?"error":"completed",timestamp:Date.now()})}),console.log("Task history saved successfully")}catch(W){console.error("Failed to save task history:",W)}}},[]),T=async(M,B)=>{if(!B){console.error("Cannot respond to event: No event ID provided");return}if(!g){console.error("Cannot respond to event: No event file ID available");return}(h==null?void 0:h.eventId)===B&&f(null);try{const F=await fetch("/api/auto-command/response",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event_id:B,event_file_id:g,response:M})});if(!F.ok){const W=await F.json();throw new Error(`Failed to send response: ${W.detail||F.statusText}`)}console.log("Response sent successfully to event:",B)}catch(F){console.error("Error sending response to server:",F),a(W=>[...W,{id:"error-"+Date.now(),type:"ERROR",content:`Failed to send your response to the server: ${F instanceof Error?F.message:String(F)}`}])}};_.useEffect(()=>(sc.on("message",M=>{if(M.type==="ASK_USER"){const B={...M,id:M.id||`msg-${Date.now()}`,timestamp:Date.now()};f(B)}a(B=>{const F={...M,id:M.id||`msg-${Date.now()}`,timestamp:Date.now()},W=B.findIndex(U=>U.id===F.id);if(W>=0){const U=[...B];return U[W]=F,U}return[...B,F]})}),()=>{sc.closeEventStream(),sc.removeAllListeners()}),[]),_.useEffect(()=>{y==="current-change"&&g&&D(g)},[y,g]);const D=async M=>{try{if(!M){console.log("No event file ID available");return}let B=`/api/current-changes?event_file_id=${encodeURIComponent(M)}`;const F=await fetch(B);if(F.ok){const W=await F.json();E(W.commits||[])}else console.error("Failed to fetch current changes:",F.statusText)}catch(B){console.error("Error fetching current changes:",B)}};_.useEffect(()=>(sc.removeAllListeners("taskComplete"),sc.on("taskComplete",M=>{r&&g?(c(!1),console.log("AutoModePage: Set isProcessing to false"),I(M,r,g)):console.warn("Cannot save task history: missing query or event file ID")}),()=>{sc.removeAllListeners("taskComplete")}),[r,g,I]);const O=async M=>{M.preventDefault();const B=window.lastEditorContent||t;if(window.lastEditorContent&&delete window.lastEditorContent,B.trim())try{c(!0),console.log("AutoModePage: Set isProcessing to true"),s(B),a([{id:"user-"+Date.now(),type:"USER",content:B,isUser:!0}]);const F=await sc.executeCommand(B);console.log("AutoModePage: Command executed, received event_file_id:",F.event_file_id),m(F.event_file_id),console.log("AutoModePage: Set currentEventFileId to:",F.event_file_id),i("")}catch(F){console.error("Error executing command:",F),a(W=>[...W,{id:"error-"+Date.now(),type:"ERROR",content:"Failed to execute command. Please try again."}])}finally{console.log("query submitted")}},R=M=>{i(M.query),s(M.query),console.log("Restoring history task messages:",M.messages),a(M.messages),M.event_file_id&&m(M.event_file_id),A(!0),console.log("Restored history task:",M)};return S.jsxs("div",{className:"flex-1 flex flex-col h-screen bg-gray-900",children:[h&&S.jsx(iQe,{message:h,onResponse:T,onClose:()=>f(null)}),S.jsxs("div",{className:`w-full max-w-4xl mx-auto px-4 py-6 flex flex-col ${o.length===0?"justify-center":""} h-full`,children:[S.jsxs("div",{className:"flex flex-col items-center justify-center mb-6 space-y-3",children:[S.jsxs("div",{className:"flex items-center",children:[S.jsx("svg",{className:"w-8 h-8 mr-3",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:S.jsx("path",{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z",stroke:"#8B5CF6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),S.jsx("span",{className:"bg-gradient-to-r from-indigo-500 to-purple-500 text-transparent bg-clip-text font-bold text-3xl",children:"auto-coder.web"})]}),S.jsxs("div",{className:"text-gray-400 text-sm font-mono font-medium",children:[ee("projectName"),": ",n]})]}),o.length>0&&p&&S.jsx("div",{className:"flex-1 mb-6 flex flex-col items-center w-full",children:S.jsxs("div",{className:`w-full ${v?"max-w-full px-4":"max-w-5xl"} flex`,children:[S.jsxs("div",{className:"w-48 sticky top-0 self-start max-h-screen bg-gray-800 rounded-l-lg p-4 flex flex-col shadow-lg",children:[S.jsxs("div",{className:"space-y-3 mb-6",children:[S.jsx("h3",{className:"text-gray-300 font-medium text-xs uppercase tracking-wider mb-2",children:"导航菜单"}),S.jsxs("button",{className:`w-full px-3 py-2 text-left font-medium text-xs rounded-md flex items-center ${y==="messages"?"bg-indigo-600 text-white":"text-gray-300 hover:bg-gray-700 hover:text-white"}`,onClick:()=>C("messages"),children:[S.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})}),ee("showMessages")]}),S.jsxs("button",{className:`w-full px-3 py-2 text-left font-medium text-xs rounded-md flex items-center ${y==="current-change"?"bg-indigo-600 text-white":"text-gray-300 hover:bg-gray-700 hover:text-white"}`,onClick:()=>C("current-change"),children:[S.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:S.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"})}),ee("currentChange")]}),S.jsxs("button",{className:`w-full px-3 py-2 text-left font-medium text-xs rounded-md flex items-center ${y==="commits"?"bg-indigo-600 text-white":"text-gray-300 hover:bg-gray-700 hover:text-white"}`,onClick:()=>C("commits"),children:[S.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})}),ee("viewChange")]})]}),S.jsxs("div",{className:"mt-auto flex flex-col space-y-2 pt-4 border-t border-gray-700",children:[S.jsx("button",{className:"w-full flex items-center justify-center text-gray-400 hover:text-white p-2 transition-colors rounded hover:bg-gray-700",onClick:()=>b(!v),title:v?"全屏宽度":"限制宽度",children:v?S.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:S.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"})}):S.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8h16M4 16h16"})})}),S.jsx("button",{className:"w-full flex items-center justify-center text-gray-400 hover:text-white p-2 transition-colors rounded hover:bg-gray-700",onClick:()=>A(!1),title:"关闭",children:S.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),S.jsx("div",{className:`flex-1 ${v?"overflow-y-auto":""} bg-gray-800 rounded-r-lg p-5 shadow-lg`,children:y==="messages"?S.jsx(Obn,{messages:o,currentTask:r.length>0?r.length>20?`${r.substring(0,20)}...`:r:n||ee("noProjectSelected"),onUserResponse:T}):y==="current-change"?S.jsx(_.Suspense,{fallback:S.jsx("div",{className:"p-4 text-gray-400 text-center",children:"Loading Changes..."}),children:S.jsx(Z8t,{projectName:n,commits:w})}):S.jsx(_.Suspense,{fallback:S.jsx("div",{className:"p-4 text-gray-400 text-center",children:"Loading Commits..."}),children:S.jsx(X8t,{projectName:n})})})]})}),o.length>0&&!p&&S.jsxs("button",{className:"mb-6 py-2 px-4 bg-gray-800 hover:bg-gray-700 text-gray-300 rounded-lg flex items-center justify-center transition-colors",onClick:()=>A(!0),children:[S.jsx("svg",{className:"w-5 h-5 mr-2",fill:"currentColor",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",children:S.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm1-11a1 1 0 10-2 0v2H7a1 1 0 100 2h2v2a1 1 0 102 0v-2h2a1 1 0 100-2h-2V7z",clipRule:"evenodd"})}),ee("showMessages")]}),S.jsx(Y8t,{projectName:n,isProcessing:l,autoSearchTerm:t,setAutoSearchTerm:i,onSubmit:O,onSelectHistoryTask:R,currentEventFileId:g}),S.jsxs("div",{className:"text-center text-gray-400 mt-4",children:[S.jsx("p",{className:"mb-2",children:ee("autoModeDescription")}),S.jsxs("p",{children:[ee("tryExamples"),":"]}),S.jsxs("div",{className:"flex flex-wrap justify-center gap-2 mt-3",children:[S.jsx("button",{className:"px-3 py-1 bg-gray-800 hover:bg-gray-700 rounded-full text-sm text-gray-300 transition-colors",onClick:()=>i("Add authentication to the app"),disabled:l,children:"Add authentication"}),S.jsx("button",{className:"px-3 py-1 bg-gray-800 hover:bg-gray-700 rounded-full text-sm text-gray-300 transition-colors",onClick:()=>i("Create a new API endpoint"),disabled:l,children:"Create API endpoint"}),S.jsx("button",{className:"px-3 py-1 bg-gray-800 hover:bg-gray-700 rounded-full text-sm text-gray-300 transition-colors",onClick:()=>i("Fix bugs in the code"),disabled:l,children:"Fix bugs"})]})]})]})]})};function w4e(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,i)}return t}function ok(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?w4e(Object(t),!0).forEach(function(i){he(n,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):w4e(Object(t)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(t,i))})}return n}function e7t(n){var e=n.length;if(e===0||e===1)return n;if(e===2)return[n[0],n[1],"".concat(n[0],".").concat(n[1]),"".concat(n[1],".").concat(n[0])];if(e===3)return[n[0],n[1],n[2],"".concat(n[0],".").concat(n[1]),"".concat(n[0],".").concat(n[2]),"".concat(n[1],".").concat(n[0]),"".concat(n[1],".").concat(n[2]),"".concat(n[2],".").concat(n[0]),"".concat(n[2],".").concat(n[1]),"".concat(n[0],".").concat(n[1],".").concat(n[2]),"".concat(n[0],".").concat(n[2],".").concat(n[1]),"".concat(n[1],".").concat(n[0],".").concat(n[2]),"".concat(n[1],".").concat(n[2],".").concat(n[0]),"".concat(n[2],".").concat(n[0],".").concat(n[1]),"".concat(n[2],".").concat(n[1],".").concat(n[0])];if(e>=4)return[n[0],n[1],n[2],n[3],"".concat(n[0],".").concat(n[1]),"".concat(n[0],".").concat(n[2]),"".concat(n[0],".").concat(n[3]),"".concat(n[1],".").concat(n[0]),"".concat(n[1],".").concat(n[2]),"".concat(n[1],".").concat(n[3]),"".concat(n[2],".").concat(n[0]),"".concat(n[2],".").concat(n[1]),"".concat(n[2],".").concat(n[3]),"".concat(n[3],".").concat(n[0]),"".concat(n[3],".").concat(n[1]),"".concat(n[3],".").concat(n[2]),"".concat(n[0],".").concat(n[1],".").concat(n[2]),"".concat(n[0],".").concat(n[1],".").concat(n[3]),"".concat(n[0],".").concat(n[2],".").concat(n[1]),"".concat(n[0],".").concat(n[2],".").concat(n[3]),"".concat(n[0],".").concat(n[3],".").concat(n[1]),"".concat(n[0],".").concat(n[3],".").concat(n[2]),"".concat(n[1],".").concat(n[0],".").concat(n[2]),"".concat(n[1],".").concat(n[0],".").concat(n[3]),"".concat(n[1],".").concat(n[2],".").concat(n[0]),"".concat(n[1],".").concat(n[2],".").concat(n[3]),"".concat(n[1],".").concat(n[3],".").concat(n[0]),"".concat(n[1],".").concat(n[3],".").concat(n[2]),"".concat(n[2],".").concat(n[0],".").concat(n[1]),"".concat(n[2],".").concat(n[0],".").concat(n[3]),"".concat(n[2],".").concat(n[1],".").concat(n[0]),"".concat(n[2],".").concat(n[1],".").concat(n[3]),"".concat(n[2],".").concat(n[3],".").concat(n[0]),"".concat(n[2],".").concat(n[3],".").concat(n[1]),"".concat(n[3],".").concat(n[0],".").concat(n[1]),"".concat(n[3],".").concat(n[0],".").concat(n[2]),"".concat(n[3],".").concat(n[1],".").concat(n[0]),"".concat(n[3],".").concat(n[1],".").concat(n[2]),"".concat(n[3],".").concat(n[2],".").concat(n[0]),"".concat(n[3],".").concat(n[2],".").concat(n[1]),"".concat(n[0],".").concat(n[1],".").concat(n[2],".").concat(n[3]),"".concat(n[0],".").concat(n[1],".").concat(n[3],".").concat(n[2]),"".concat(n[0],".").concat(n[2],".").concat(n[1],".").concat(n[3]),"".concat(n[0],".").concat(n[2],".").concat(n[3],".").concat(n[1]),"".concat(n[0],".").concat(n[3],".").concat(n[1],".").concat(n[2]),"".concat(n[0],".").concat(n[3],".").concat(n[2],".").concat(n[1]),"".concat(n[1],".").concat(n[0],".").concat(n[2],".").concat(n[3]),"".concat(n[1],".").concat(n[0],".").concat(n[3],".").concat(n[2]),"".concat(n[1],".").concat(n[2],".").concat(n[0],".").concat(n[3]),"".concat(n[1],".").concat(n[2],".").concat(n[3],".").concat(n[0]),"".concat(n[1],".").concat(n[3],".").concat(n[0],".").concat(n[2]),"".concat(n[1],".").concat(n[3],".").concat(n[2],".").concat(n[0]),"".concat(n[2],".").concat(n[0],".").concat(n[1],".").concat(n[3]),"".concat(n[2],".").concat(n[0],".").concat(n[3],".").concat(n[1]),"".concat(n[2],".").concat(n[1],".").concat(n[0],".").concat(n[3]),"".concat(n[2],".").concat(n[1],".").concat(n[3],".").concat(n[0]),"".concat(n[2],".").concat(n[3],".").concat(n[0],".").concat(n[1]),"".concat(n[2],".").concat(n[3],".").concat(n[1],".").concat(n[0]),"".concat(n[3],".").concat(n[0],".").concat(n[1],".").concat(n[2]),"".concat(n[3],".").concat(n[0],".").concat(n[2],".").concat(n[1]),"".concat(n[3],".").concat(n[1],".").concat(n[0],".").concat(n[2]),"".concat(n[3],".").concat(n[1],".").concat(n[2],".").concat(n[0]),"".concat(n[3],".").concat(n[2],".").concat(n[0],".").concat(n[1]),"".concat(n[3],".").concat(n[2],".").concat(n[1],".").concat(n[0])]}var rZ={};function t7t(n){if(n.length===0||n.length===1)return n;var e=n.join(".");return rZ[e]||(rZ[e]=e7t(n)),rZ[e]}function n7t(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=arguments.length>2?arguments[2]:void 0,i=n.filter(function(s){return s!=="token"}),r=t7t(i);return r.reduce(function(s,o){return ok(ok({},s),t[o])},e)}function S4e(n){return n.join(" ")}function i7t(n,e){var t=0;return function(i){return t+=1,i.map(function(r,s){return rQe({node:r,stylesheet:n,useInlineStyles:e,key:"code-segment-".concat(t,"-").concat(s)})})}}function rQe(n){var e=n.node,t=n.stylesheet,i=n.style,r=i===void 0?{}:i,s=n.useInlineStyles,o=n.key,a=e.properties,l=e.type,c=e.tagName,u=e.value;if(l==="text")return u;if(c){var d=i7t(t,s),h;if(!s)h=ok(ok({},a),{},{className:S4e(a.className)});else{var f=Object.keys(t).reduce(function(A,v){return v.split(".").forEach(function(b){A.includes(b)||A.push(b)}),A},[]),g=a.className&&a.className.includes("token")?["token"]:[],m=a.className&&g.concat(a.className.filter(function(A){return!f.includes(A)}));h=ok(ok({},a),{},{className:S4e(m)||void 0,style:n7t(a.className,Object.assign({},a.style,r),t)})}var p=d(e.children);return Ne.createElement(c,qe({key:o},h),p)}}const r7t=function(n,e){var t=n.listLanguages();return t.indexOf(e)!==-1};var s7t=["language","children","style","customStyle","codeTagProps","useInlineStyles","showLineNumbers","showInlineLineNumbers","startingLineNumber","lineNumberContainerStyle","lineNumberStyle","wrapLines","wrapLongLines","lineProps","renderer","PreTag","CodeTag","code","astGenerator"];function x4e(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,i)}return t}function R1(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?x4e(Object(t),!0).forEach(function(i){he(n,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):x4e(Object(t)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(t,i))})}return n}var o7t=/\n/g;function a7t(n){return n.match(o7t)}function l7t(n){var e=n.lines,t=n.startingLineNumber,i=n.style;return e.map(function(r,s){var o=s+t;return Ne.createElement("span",{key:"line-".concat(s),className:"react-syntax-highlighter-line-number",style:typeof i=="function"?i(o):i},"".concat(o,`
|
477
|
+
`},y4e=f8t(A8t)(YKe),v8t={config:p8t},b8t=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return function(r){return t.reduceRight(function(s,o){return o(s)},r)}};function XKe(n,e){return Object.keys(e).forEach(function(t){e[t]instanceof Object&&n[t]&&Object.assign(e[t],XKe(n[t],e[t]))}),A4e(A4e({},n),e)}var _8t={type:"cancelation",msg:"operation is manually canceled"};function tZ(n){var e=!1,t=new Promise(function(i,r){n.then(function(s){return e?r(_8t):i(s)}),n.catch(r)});return t.cancel=function(){return e=!0},t}var y8t=d8t.create({config:h8t,isInitialized:!1,resolve:null,reject:null,monaco:null}),ZKe=qFt(y8t,2),$5=ZKe[0],iq=ZKe[1];function C8t(n){var e=v8t.config(n),t=e.monaco,i=VFt(e,["monaco"]);iq(function(r){return{config:XKe(r.config,i),monaco:t}})}function w8t(){var n=$5(function(e){var t=e.monaco,i=e.isInitialized,r=e.resolve;return{monaco:t,isInitialized:i,resolve:r}});if(!n.isInitialized){if(iq({isInitialized:!0}),n.monaco)return n.resolve(n.monaco),tZ(nZ);if(window.monaco&&window.monaco.editor)return JKe(window.monaco),n.resolve(window.monaco),tZ(nZ);b8t(S8t,E8t)(k8t)}return tZ(nZ)}function S8t(n){return document.body.appendChild(n)}function x8t(n){var e=document.createElement("script");return n&&(e.src=n),e}function E8t(n){var e=$5(function(i){var r=i.config,s=i.reject;return{config:r,reject:s}}),t=x8t("".concat(e.config.paths.vs,"/loader.js"));return t.onload=function(){return n()},t.onerror=e.reject,t}function k8t(){var n=$5(function(t){var i=t.config,r=t.resolve,s=t.reject;return{config:i,resolve:r,reject:s}}),e=window.require;e.config(n.config),e(["vs/editor/editor.main"],function(t){JKe(t),n.resolve(t)},function(t){n.reject(t)})}function JKe(n){$5().monaco||iq({monaco:n})}function L8t(){return $5(function(n){var e=n.monaco;return e})}var nZ=new Promise(function(n,e){return iq({resolve:n,reject:e})}),Sy={config:C8t,init:w8t,__getMonacoInstance:L8t},I8t={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},iZ=I8t,T8t={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},N8t=T8t;function D8t({children:n}){return Ne.createElement("div",{style:N8t.container},n)}var R8t=D8t,M8t=R8t;function O8t({width:n,height:e,isEditorReady:t,loading:i,_ref:r,className:s,wrapperProps:o}){return Ne.createElement("section",{style:{...iZ.wrapper,width:n,height:e},...o},!t&&Ne.createElement(M8t,null,i),Ne.createElement("div",{ref:r,style:{...iZ.fullWidth,...!t&&iZ.hide},className:s}))}var B8t=O8t,eQe=_.memo(B8t);function P8t(n){_.useEffect(n,[])}var tQe=P8t;function F8t(n,e,t=!0){let i=_.useRef(!0);_.useEffect(i.current||!t?()=>{i.current=!1}:n,e)}var Yh=F8t;function mR(){}function sk(n,e,t,i){return $8t(n,i)||H8t(n,e,t,i)}function $8t(n,e){return n.editor.getModel(nQe(n,e))}function H8t(n,e,t,i){return n.editor.createModel(e,t,i?nQe(n,i):void 0)}function nQe(n,e){return n.Uri.parse(e)}function z8t({original:n,modified:e,language:t,originalLanguage:i,modifiedLanguage:r,originalModelPath:s,modifiedModelPath:o,keepCurrentOriginalModel:a=!1,keepCurrentModifiedModel:l=!1,theme:c="light",loading:u="Loading...",options:d={},height:h="100%",width:f="100%",className:g,wrapperProps:m={},beforeMount:p=mR,onMount:A=mR}){let[v,b]=_.useState(!1),[y,C]=_.useState(!0),w=_.useRef(null),E=_.useRef(null),k=_.useRef(null),I=_.useRef(A),T=_.useRef(p),D=_.useRef(!1);tQe(()=>{let B=Sy.init();return B.then(F=>(E.current=F)&&C(!1)).catch(F=>(F==null?void 0:F.type)!=="cancelation"&&console.error("Monaco initialization: error:",F)),()=>w.current?M():B.cancel()}),Yh(()=>{if(w.current&&E.current){let B=w.current.getOriginalEditor(),F=sk(E.current,n||"",i||t||"text",s||"");F!==B.getModel()&&B.setModel(F)}},[s],v),Yh(()=>{if(w.current&&E.current){let B=w.current.getModifiedEditor(),F=sk(E.current,e||"",r||t||"text",o||"");F!==B.getModel()&&B.setModel(F)}},[o],v),Yh(()=>{let B=w.current.getModifiedEditor();B.getOption(E.current.editor.EditorOption.readOnly)?B.setValue(e||""):e!==B.getValue()&&(B.executeEdits("",[{range:B.getModel().getFullModelRange(),text:e||"",forceMoveMarkers:!0}]),B.pushUndoStop())},[e],v),Yh(()=>{var B,F;(F=(B=w.current)==null?void 0:B.getModel())==null||F.original.setValue(n||"")},[n],v),Yh(()=>{let{original:B,modified:F}=w.current.getModel();E.current.editor.setModelLanguage(B,i||t||"text"),E.current.editor.setModelLanguage(F,r||t||"text")},[t,i,r],v),Yh(()=>{var B;(B=E.current)==null||B.editor.setTheme(c)},[c],v),Yh(()=>{var B;(B=w.current)==null||B.updateOptions(d)},[d],v);let O=_.useCallback(()=>{var W;if(!E.current)return;T.current(E.current);let B=sk(E.current,n||"",i||t||"text",s||""),F=sk(E.current,e||"",r||t||"text",o||"");(W=w.current)==null||W.setModel({original:B,modified:F})},[t,e,r,n,i,s,o]),R=_.useCallback(()=>{var B;!D.current&&k.current&&(w.current=E.current.editor.createDiffEditor(k.current,{automaticLayout:!0,...d}),O(),(B=E.current)==null||B.editor.setTheme(c),b(!0),D.current=!0)},[d,c,O]);_.useEffect(()=>{v&&I.current(w.current,E.current)},[v]),_.useEffect(()=>{!y&&!v&&R()},[y,v,R]);function M(){var F,W,U,H;let B=(F=w.current)==null?void 0:F.getModel();a||((W=B==null?void 0:B.original)==null||W.dispose()),l||((U=B==null?void 0:B.modified)==null||U.dispose()),(H=w.current)==null||H.dispose()}return Ne.createElement(eQe,{width:f,height:h,isEditorReady:v,loading:u,_ref:k,className:g,wrapperProps:m})}var U8t=z8t;_.memo(U8t);function W8t(n){let e=_.useRef();return _.useEffect(()=>{e.current=n},[n]),e.current}var j8t=W8t,E6=new Map;function V8t({defaultValue:n,defaultLanguage:e,defaultPath:t,value:i,language:r,path:s,theme:o="light",line:a,loading:l="Loading...",options:c={},overrideServices:u={},saveViewState:d=!0,keepCurrentModel:h=!1,width:f="100%",height:g="100%",className:m,wrapperProps:p={},beforeMount:A=mR,onMount:v=mR,onChange:b,onValidate:y=mR}){let[C,w]=_.useState(!1),[E,k]=_.useState(!0),I=_.useRef(null),T=_.useRef(null),D=_.useRef(null),O=_.useRef(v),R=_.useRef(A),M=_.useRef(),B=_.useRef(i),F=j8t(s),W=_.useRef(!1),U=_.useRef(!1);tQe(()=>{let z=Sy.init();return z.then(q=>(I.current=q)&&k(!1)).catch(q=>(q==null?void 0:q.type)!=="cancelation"&&console.error("Monaco initialization: error:",q)),()=>T.current?$():z.cancel()}),Yh(()=>{var q,j,K,Z;let z=sk(I.current,n||i||"",e||r||"",s||t||"");z!==((q=T.current)==null?void 0:q.getModel())&&(d&&E6.set(F,(j=T.current)==null?void 0:j.saveViewState()),(K=T.current)==null||K.setModel(z),d&&((Z=T.current)==null||Z.restoreViewState(E6.get(s))))},[s],C),Yh(()=>{var z;(z=T.current)==null||z.updateOptions(c)},[c],C),Yh(()=>{!T.current||i===void 0||(T.current.getOption(I.current.editor.EditorOption.readOnly)?T.current.setValue(i):i!==T.current.getValue()&&(U.current=!0,T.current.executeEdits("",[{range:T.current.getModel().getFullModelRange(),text:i,forceMoveMarkers:!0}]),T.current.pushUndoStop(),U.current=!1))},[i],C),Yh(()=>{var q,j;let z=(q=T.current)==null?void 0:q.getModel();z&&r&&((j=I.current)==null||j.editor.setModelLanguage(z,r))},[r],C),Yh(()=>{var z;a!==void 0&&((z=T.current)==null||z.revealLine(a))},[a],C),Yh(()=>{var z;(z=I.current)==null||z.editor.setTheme(o)},[o],C);let H=_.useCallback(()=>{var z;if(!(!D.current||!I.current)&&!W.current){R.current(I.current);let q=s||t,j=sk(I.current,i||n||"",e||r||"",q||"");T.current=(z=I.current)==null?void 0:z.editor.create(D.current,{model:j,automaticLayout:!0,...c},u),d&&T.current.restoreViewState(E6.get(q)),I.current.editor.setTheme(o),a!==void 0&&T.current.revealLine(a),w(!0),W.current=!0}},[n,e,t,i,r,s,c,u,d,o,a]);_.useEffect(()=>{C&&O.current(T.current,I.current)},[C]),_.useEffect(()=>{!E&&!C&&H()},[E,C,H]),B.current=i,_.useEffect(()=>{var z,q;C&&b&&((z=M.current)==null||z.dispose(),M.current=(q=T.current)==null?void 0:q.onDidChangeModelContent(j=>{U.current||b(T.current.getValue(),j)}))},[C,b]),_.useEffect(()=>{if(C){let z=I.current.editor.onDidChangeMarkers(q=>{var K;let j=(K=T.current.getModel())==null?void 0:K.uri;if(j&&q.find(Z=>Z.path===j.path)){let Z=I.current.editor.getModelMarkers({resource:j});y==null||y(Z)}});return()=>{z==null||z.dispose()}}return()=>{}},[C,y]);function $(){var z,q;(z=M.current)==null||z.dispose(),h?d&&E6.set(s,T.current.saveViewState()):(q=T.current.getModel())==null||q.dispose(),T.current.dispose()}return Ne.createElement(eQe,{width:f,height:g,isEditorReady:C,loading:l,_ref:D,className:m,wrapperProps:p})}var q8t=V8t,rf=_.memo(q8t),rq=rf;Sy.config({paths:{vs:"/monaco-editor/min/vs"},"vs/nls":{availableLanguages:{"*":"zh-cn"}}});const Gbe=({initialContent:n,onContentChange:e,onEditorReady:t,onSubmit:i,onToggleCollapse:r})=>{const s=(o,a)=>{o.addCommand(a.KeyMod.CtrlCmd|a.KeyCode.Enter,()=>{i()}),r&&o.addCommand(a.KeyMod.CtrlCmd|a.KeyCode.KeyL,()=>{r()}),a.languages.registerCompletionItemProvider("markdown",{triggerCharacters:["@"],provideCompletionItems:async(l,c)=>{const u=l.getValueInRange({startLineNumber:c.lineNumber,startColumn:1,endLineNumber:c.lineNumber,endColumn:c.column}),d=l.getWordUntilPosition(c),h=u.charAt(d.startColumn-2),f=u.charAt(d.startColumn-3),g=d.word;return console.log("prefix:",h,"word:",g),h==="@"&&f==="@"?{suggestions:(await(await fetch(`/api/completions/symbols?name=${encodeURIComponent(g)}`)).json()).completions.map(v=>({label:v.display,kind:a.languages.CompletionItemKind.Function,insertText:v.path,detail:"",documentation:`Location: ${v.path}`})),incomplete:!0}:h==="@"?{suggestions:(await(await fetch(`/api/completions/files?name=${encodeURIComponent(g)}`)).json()).completions.map(v=>({label:v.display,kind:a.languages.CompletionItemKind.File,insertText:v.path,detail:"",documentation:`Location: ${v.location}`})),incomplete:!0}:{suggestions:[]}}}),t(o,a)};return S.jsx("div",{className:"h-full w-full",children:S.jsx(rf,{height:"100%",defaultLanguage:"markdown",defaultValue:n,onChange:e,theme:"vs-dark",onMount:s,loading:S.jsx("div",{className:"flex items-center justify-center h-full",children:"加载编辑器中..."}),beforeMount:o=>{window.MonacoEnvironment={getWorkerUrl:(a,l)=>"/monaco-editor/min/vs/base/worker/workerMain.js"}},options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"on",lineNumbers:"on",folding:!0,fontSize:14,tabSize:2,automaticLayout:!0,contextmenu:!0,scrollbar:{verticalScrollbarSize:12,horizontalScrollbarSize:12},suggestOnTriggerCharacters:!0,quickSuggestions:!0,acceptSuggestionOnEnter:"smart",fixedOverflowWidgets:!0,suggest:{insertMode:"replace",snippetsPreventQuickSuggestions:!1}}})})};Sy.config({paths:{vs:"/monaco-editor/min/vs"},"vs/nls":{availableLanguages:{"*":"zh-cn"}}});const G8t=_.forwardRef(({value:n,placeholder:e="",onChange:t,onSubmit:i,disabled:r=!1,onToggleExpand:s,onSelectHistoryTask:o,isProcessing:a=!1,currentEventFileId:l,onCancelTask:c,isCancelling:u=!1},d)=>{const h=_.useRef(null),[f,g]=_.useState(!1),[m,p]=_.useState([]),[A,v]=_.useState([]),[b,y]=_.useState(!1),C=_.useRef(null);_.useEffect(()=>{(async()=>{try{const O=localStorage.getItem("commandHistory");O&&p(JSON.parse(O)),await w()}catch(O){console.error("Failed to load command history",O)}})()},[]);const w=async()=>{try{y(!0);const D=await fetch("/api/auto-command/history");if(D.ok){const O=await D.json();v(O.tasks||[])}}catch(D){console.error("Failed to load task history from server",D)}finally{y(!1)}};_.useEffect(()=>{f&&w()},[f]);const E=D=>{D.trim()!==""&&p(O=>{const R=O.filter(B=>B!==D),M=[D,...R].slice(0,20);return localStorage.setItem("commandHistory",JSON.stringify(M)),M})},k=D=>{t(D),g(!1),h.current&&h.current.focus()},I=D=>{t(D.query),g(!1),o&&o(D),h.current&&h.current.focus()};_.useEffect(()=>{const D=O=>{C.current&&!C.current.contains(O.target)&&g(!1)};return f&&document.addEventListener("mousedown",D),()=>{document.removeEventListener("mousedown",D)}},[f]),_.useImperativeHandle(d,()=>({focus:()=>{h.current&&h.current.focus()},editor:h.current}));const T=(D,O)=>{h.current=D,!n&&e&&D.updateOptions({padding:{top:12,bottom:12}}),D.addCommand(O.KeyMod.CtrlCmd|O.KeyCode.Enter,()=>{n.trim()&&E(n),i()}),s&&D.addCommand(O.KeyMod.CtrlCmd|O.KeyCode.KeyL,()=>{s()}),O.languages.registerCompletionItemProvider("markdown",{triggerCharacters:["@"],provideCompletionItems:async(R,M)=>{const B=R.getValueInRange({startLineNumber:M.lineNumber,startColumn:1,endLineNumber:M.lineNumber,endColumn:M.column}),F=R.getWordUntilPosition(M),W=B.charAt(F.startColumn-2),U=B.charAt(F.startColumn-3),H=F.word;return console.log("prefix:",W,"word:",H),W==="@"&&U==="@"?{suggestions:(await(await fetch(`/api/completions/symbols?name=${encodeURIComponent(H)}`)).json()).completions.map(j=>({label:j.display,kind:O.languages.CompletionItemKind.Function,insertText:j.path,detail:"",documentation:`Location: ${j.path}`})),incomplete:!0}:W==="@"?{suggestions:(await(await fetch(`/api/completions/files?name=${encodeURIComponent(H)}`)).json()).completions.map(j=>({label:j.display,kind:O.languages.CompletionItemKind.File,insertText:j.path,detail:"",documentation:`Location: ${j.location}`})),incomplete:!0}:{suggestions:[]}}})};return S.jsxs("div",{className:"w-full h-9 rounded-full overflow-hidden bg-gray-800 border border-gray-700 shadow-lg pl-16 pr-16",children:[S.jsx("div",{className:"absolute left-3.5 top-0 bottom-0 flex items-center z-10",children:S.jsx("svg",{className:"w-4 h-4 text-purple-500 opacity-80",viewBox:"0 0 24 24",fill:"currentColor",children:S.jsx("path",{d:"M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2M7.5 13A2.5 2.5 0 0 0 5 15.5A2.5 2.5 0 0 0 7.5 18a2.5 2.5 0 0 0 2.5-2.5A2.5 2.5 0 0 0 7.5 13m9 0a2.5 2.5 0 0 0-2.5 2.5a2.5 2.5 0 0 0 2.5 2.5a2.5 2.5 0 0 0 2.5-2.5a2.5 2.5 0 0 0-2.5-2.5z"})})}),S.jsxs("div",{className:"absolute left-10 top-0 bottom-0 flex items-center z-10",children:[S.jsx("button",{type:"button",className:"p-1 rounded-full text-gray-400 hover:text-gray-200 transition-colors focus:outline-none",onClick:()=>g(!f),title:"命令历史",disabled:a||u,children:S.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:S.jsx("path",{d:"M13.5,8H12V13L16.28,15.54L17,14.33L13.5,12.25V8M13,3A9,9 0 0,0 4,12H1L4.96,16.03L9,12H6A7,7 0 0,1 13,5A7,7 0 0,1 20,12A7,7 0 0,1 13,19C11.07,19 9.32,18.21 8.06,16.94L6.64,18.36C8.27,20 10.5,21 13,21A9,9 0 0,0 22,12A9,9 0 0,0 13,3"})})}),f&&S.jsxs("div",{ref:C,className:"absolute left-0 top-full mt-2 w-96 max-h-80 overflow-y-auto bg-gray-800 border border-gray-700 rounded-md shadow-lg z-20",children:[S.jsx("div",{className:"py-1 border-b border-gray-700",children:S.jsxs("div",{className:"px-4 py-2 text-sm text-gray-300 font-semibold flex justify-between items-center",children:[S.jsx("span",{children:"历史任务"}),b?S.jsx("span",{className:"text-xs text-gray-400",children:"加载中..."}):S.jsx("button",{type:"button",className:"text-xs text-blue-400 hover:text-blue-300 focus:outline-none",onClick:w,children:"刷新"})]})}),A.length>0?S.jsx("div",{className:"mb-4",children:S.jsx("ul",{className:"py-1",children:A.map(D=>{var O;return S.jsx("li",{className:"px-3 py-2 hover:bg-gray-700 cursor-pointer",children:S.jsxs("button",{type:"button",className:"w-full text-left flex flex-col",onClick:()=>I(D),children:[S.jsx("span",{className:"text-sm text-gray-200 truncate",children:D.query}),S.jsxs("div",{className:"flex items-center text-xs mt-1",children:[S.jsx("span",{className:`px-1.5 py-0.5 rounded ${D.status==="completed"?"bg-green-900 text-green-300":"bg-red-900 text-red-300"}`,children:D.status==="completed"?"完成":"错误"}),S.jsx("span",{className:"text-gray-400 ml-2",children:new Date(D.timestamp).toLocaleString()}),S.jsxs("span",{className:"text-gray-400 ml-2",children:[((O=D.messages)==null?void 0:O.length)||0," 条消息"]}),D.event_file_id&&S.jsxs("span",{className:"text-blue-400 ml-2 flex items-center",children:[S.jsx("svg",{className:"w-3 h-3 mr-1",viewBox:"0 0 24 24",fill:"currentColor",children:S.jsx("path",{d:"M13 9h5.5L13 3.5V9M6 2h8l6 6v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4c0-1.11.89-2 2-2m9 16v-2H6v2h9m3-4v-2H6v2h12z"})}),"可恢复"]})]})]})},D.id)})})}):S.jsx("div",{className:"px-4 py-3 text-sm text-gray-400 text-center",children:b?"加载历史任务...":"没有历史任务"}),S.jsx("div",{className:"py-1 border-t border-gray-700",children:S.jsxs("div",{className:"px-4 py-2 text-sm text-gray-300 font-semibold flex justify-between items-center",children:[S.jsx("span",{children:"最近使用的命令"}),m.length>0&&S.jsx("button",{type:"button",className:"text-xs text-red-400 hover:text-red-300 focus:outline-none",onClick:()=>{window.confirm("确定要清空历史命令吗?")&&(p([]),localStorage.removeItem("commandHistory"))},children:"清空历史"})]})}),m.length>0?S.jsx("ul",{className:"py-1",children:m.map((D,O)=>S.jsx("li",{children:S.jsx("button",{type:"button",className:"w-full text-left px-4 py-2 text-sm text-gray-200 hover:bg-gray-700 truncate",onClick:()=>k(D),children:D})},O))}):S.jsx("div",{className:"px-4 py-3 text-sm text-gray-400 text-center",children:"没有本地历史命令"})]})]}),S.jsx(rf,{height:"100%",defaultLanguage:"markdown",value:n,onChange:D=>t(D||""),theme:"vs-dark",onMount:T,loading:null,beforeMount:D=>{window.MonacoEnvironment={getWorkerUrl:(O,R)=>"/monaco-editor/min/vs/base/worker/workerMain.js"}},options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"on",lineNumbers:"off",folding:!1,fontSize:12,lineHeight:16,automaticLayout:!0,contextmenu:!1,overviewRulerLanes:0,overviewRulerBorder:!1,hideCursorInOverviewRuler:!0,glyphMargin:!1,renderLineHighlight:"none",lineDecorationsWidth:0,lineNumbersMinChars:0,suggestOnTriggerCharacters:!0,quickSuggestions:!0,acceptSuggestionOnEnter:"smart",fixedOverflowWidgets:!0,padding:{top:8,bottom:8},scrollbar:{vertical:"hidden",horizontal:"hidden",useShadows:!1,alwaysConsumeMouseWheel:!1},suggest:{insertMode:"replace",snippetsPreventQuickSuggestions:!1},readOnly:r}}),S.jsxs("div",{className:"absolute right-0 top-0 bottom-0 flex items-center pr-2",children:[S.jsx("button",{type:"button",className:"p-1 mx-1 rounded-full transition-colors bg-gray-700 hover:bg-gray-600 z-10",onClick:s,disabled:a,title:"展开编辑器",children:S.jsx("svg",{className:"w-3.5 h-3.5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8h16M4 16h16"})})}),a&&l&&c?S.jsx("button",{type:"button",className:`p-1 rounded-full transition-colors z-10 ${u?"bg-gray-600 text-gray-300":"bg-red-600 hover:bg-red-700 text-white"}`,onClick:()=>{!u&&c&&l&&window.confirm("确定要取消当前运行的任务吗?")&&c(l)},disabled:u,title:u?"正在取消任务...":"取消当前任务",children:u?S.jsxs("svg",{className:"w-3.5 h-3.5 animate-spin",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[S.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),S.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"})]}):S.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:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}):S.jsx("button",{type:"button",className:"p-1 rounded-full text-white bg-indigo-600 hover:bg-indigo-700 transition-colors z-10",onClick:i,disabled:a||!n.trim(),children:S.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})})]})]})});var k6={exports:{}},C4e;function K8t(){if(C4e)return k6.exports;C4e=1;var n=typeof Reflect=="object"?Reflect:null,e=n&&typeof n.apply=="function"?n.apply:function(C,w,E){return Function.prototype.apply.call(C,w,E)},t;n&&typeof n.ownKeys=="function"?t=n.ownKeys:Object.getOwnPropertySymbols?t=function(C){return Object.getOwnPropertyNames(C).concat(Object.getOwnPropertySymbols(C))}:t=function(C){return Object.getOwnPropertyNames(C)};function i(y){console&&console.warn&&console.warn(y)}var r=Number.isNaN||function(C){return C!==C};function s(){s.init.call(this)}k6.exports=s,k6.exports.once=A,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(y){if(typeof y!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof y)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(y){if(typeof y!="number"||y<0||r(y))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+y+".");o=y}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(C){if(typeof C!="number"||C<0||r(C))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+C+".");return this._maxListeners=C,this};function l(y){return y._maxListeners===void 0?s.defaultMaxListeners:y._maxListeners}s.prototype.getMaxListeners=function(){return l(this)},s.prototype.emit=function(C){for(var w=[],E=1;E<arguments.length;E++)w.push(arguments[E]);var k=C==="error",I=this._events;if(I!==void 0)k=k&&I.error===void 0;else if(!k)return!1;if(k){var T;if(w.length>0&&(T=w[0]),T instanceof Error)throw T;var D=new Error("Unhandled error."+(T?" ("+T.message+")":""));throw D.context=T,D}var O=I[C];if(O===void 0)return!1;if(typeof O=="function")e(O,this,w);else for(var R=O.length,M=g(O,R),E=0;E<R;++E)e(M[E],this,w);return!0};function c(y,C,w,E){var k,I,T;if(a(w),I=y._events,I===void 0?(I=y._events=Object.create(null),y._eventsCount=0):(I.newListener!==void 0&&(y.emit("newListener",C,w.listener?w.listener:w),I=y._events),T=I[C]),T===void 0)T=I[C]=w,++y._eventsCount;else if(typeof T=="function"?T=I[C]=E?[w,T]:[T,w]:E?T.unshift(w):T.push(w),k=l(y),k>0&&T.length>k&&!T.warned){T.warned=!0;var D=new Error("Possible EventEmitter memory leak detected. "+T.length+" "+String(C)+" listeners added. Use emitter.setMaxListeners() to increase limit");D.name="MaxListenersExceededWarning",D.emitter=y,D.type=C,D.count=T.length,i(D)}return y}s.prototype.addListener=function(C,w){return c(this,C,w,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(C,w){return c(this,C,w,!0)};function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(y,C,w){var E={fired:!1,wrapFn:void 0,target:y,type:C,listener:w},k=u.bind(E);return k.listener=w,E.wrapFn=k,k}s.prototype.once=function(C,w){return a(w),this.on(C,d(this,C,w)),this},s.prototype.prependOnceListener=function(C,w){return a(w),this.prependListener(C,d(this,C,w)),this},s.prototype.removeListener=function(C,w){var E,k,I,T,D;if(a(w),k=this._events,k===void 0)return this;if(E=k[C],E===void 0)return this;if(E===w||E.listener===w)--this._eventsCount===0?this._events=Object.create(null):(delete k[C],k.removeListener&&this.emit("removeListener",C,E.listener||w));else if(typeof E!="function"){for(I=-1,T=E.length-1;T>=0;T--)if(E[T]===w||E[T].listener===w){D=E[T].listener,I=T;break}if(I<0)return this;I===0?E.shift():m(E,I),E.length===1&&(k[C]=E[0]),k.removeListener!==void 0&&this.emit("removeListener",C,D||w)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(C){var w,E,k;if(E=this._events,E===void 0)return this;if(E.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):E[C]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete E[C]),this;if(arguments.length===0){var I=Object.keys(E),T;for(k=0;k<I.length;++k)T=I[k],T!=="removeListener"&&this.removeAllListeners(T);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(w=E[C],typeof w=="function")this.removeListener(C,w);else if(w!==void 0)for(k=w.length-1;k>=0;k--)this.removeListener(C,w[k]);return this};function h(y,C,w){var E=y._events;if(E===void 0)return[];var k=E[C];return k===void 0?[]:typeof k=="function"?w?[k.listener||k]:[k]:w?p(k):g(k,k.length)}s.prototype.listeners=function(C){return h(this,C,!0)},s.prototype.rawListeners=function(C){return h(this,C,!1)},s.listenerCount=function(y,C){return typeof y.listenerCount=="function"?y.listenerCount(C):f.call(y,C)},s.prototype.listenerCount=f;function f(y){var C=this._events;if(C!==void 0){var w=C[y];if(typeof w=="function")return 1;if(w!==void 0)return w.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function g(y,C){for(var w=new Array(C),E=0;E<C;++E)w[E]=y[E];return w}function m(y,C){for(;C+1<y.length;C++)y[C]=y[C+1];y.pop()}function p(y){for(var C=new Array(y.length),w=0;w<C.length;++w)C[w]=y[w].listener||y[w];return C}function A(y,C){return new Promise(function(w,E){function k(T){y.removeListener(C,I),E(T)}function I(){typeof y.removeListener=="function"&&y.removeListener("error",k),w([].slice.call(arguments))}b(y,C,I,{once:!0}),C!=="error"&&v(y,k,{once:!0})})}function v(y,C,w){typeof y.on=="function"&&b(y,"error",C,w)}function b(y,C,w,E){if(typeof y.on=="function")E.once?y.once(C,w):y.on(C,w);else if(typeof y.addEventListener=="function")y.addEventListener(C,function k(I){E.once&&y.removeEventListener(C,k),w(I)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof y)}return k6.exports}var Jx=K8t();class Q8t extends Jx.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){try{const t=await fetch("/api/auto-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e})});if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);const i=await t.json();return this.eventFileId=i.event_file_id,this.startEventStream(),{event_file_id:i.event_file_id}}catch(t){throw console.error("Error executing command:",t),t}}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)},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)},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}}}const sc=new Q8t,Y8t=({projectName:n,isProcessing:e,autoSearchTerm:t,setAutoSearchTerm:i,onSubmit:r,onSelectHistoryTask:s,currentEventFileId:o})=>{const[a,l]=_.useState(!1),[c,u]=_.useState(""),[d,h]=_.useState(!1),f=_.useRef(null),g=_.useRef(null);Ne.useEffect(()=>{const C=w=>{h(!1)};return sc.on("taskComplete",C),()=>{sc.off("taskComplete",C)}},[]);const m=(C,w)=>{g.current=C,t&&u(t),C.focus()},p=()=>{a?i(c):u(t),l(!a)},A=C=>{C!==void 0&&u(C)},v=()=>{c.trim()&&(i(c),l(!1),setTimeout(()=>{const C=new Event("submit");window.lastEditorContent=c,r(C)},50))},b=()=>{if(t.trim()&&!e){const C=new Event("submit");r(C)}},y=async C=>{h(!0);try{const w=await fetch("/api/auto-command/cancel",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event_file_id:C})});if(!w.ok)throw new Error(`Failed to cancel task: ${w.statusText}`);console.log(`Task ${C} cancellation request sent`)}catch(w){console.error("Error cancelling task:",w),h(!1),alert(`Failed to cancel task: ${w}`)}};return S.jsxs(S.Fragment,{children:[a&&S.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-70 flex items-center justify-center z-50 p-4",children:S.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-xl w-full max-w-4xl p-4 border border-gray-700 flex flex-col h-[80vh] overflow-hidden",children:[S.jsxs("div",{className:"flex items-center justify-between mb-3",children:[S.jsx("h3",{className:"text-xl font-semibold text-white",children:ee("expandedEditor")}),S.jsx("button",{onClick:p,className:"text-gray-400 hover:text-white transition-colors",children:S.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),S.jsx("div",{className:"flex-1 overflow-hidden border border-gray-700 rounded-md mb-3",children:S.jsx("div",{className:"h-full w-full",children:S.jsx(Gbe,{initialContent:t,onContentChange:A,onEditorReady:m,onSubmit:v,onToggleCollapse:p})})}),S.jsxs("div",{className:"flex justify-end space-x-3",children:[S.jsx("button",{className:"px-5 py-2 bg-gray-700 text-white rounded-md hover:bg-gray-600 transition-colors focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 focus:ring-offset-gray-800",onClick:p,children:ee("cancel")}),S.jsx("button",{className:"px-5 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700 transition-colors focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 focus:ring-offset-gray-800 disabled:opacity-50 disabled:cursor-not-allowed",onClick:v,disabled:!c.trim(),children:ee("submit")})]})]})}),S.jsx("form",{onSubmit:r,className:"w-full relative mb-4 max-w-3xl mx-auto px-3 sm:px-0",children:S.jsxs("div",{className:"w-full relative",children:[S.jsx("div",{className:"absolute left-3.5 top-0 bottom-0 flex items-center z-10",children:S.jsx("svg",{className:"w-4 h-4 text-purple-500 opacity-80",viewBox:"0 0 24 24",fill:"currentColor",children:S.jsx("path",{d:"M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2M7.5 13A2.5 2.5 0 0 0 5 15.5A2.5 2.5 0 0 0 7.5 18a2.5 2.5 0 0 0 2.5-2.5A2.5 2.5 0 0 0 7.5 13m9 0a2.5 2.5 0 0 0-2.5 2.5a2.5 2.5 0 0 0 2.5 2.5a2.5 2.5 0 0 0 2.5-2.5a2.5 2.5 0 0 0-2.5-2.5z"})})}),S.jsx(G8t,{ref:f,value:t,onChange:i,onSubmit:b,disabled:e,placeholder:`${ee("searchIn")} ${n||ee("yourProject")}`,onToggleExpand:p,onSelectHistoryTask:s,isProcessing:e,currentEventFileId:o,onCancelTask:y,isCancelling:d})]})})]})},iQe=({message:n,onResponse:e,onClose:t})=>{const[i,r]=_.useState(""),[s,o]=_.useState(!1),[a,l]=_.useState(null),c=_.useRef(null),u=n.options&&n.options.length>0,d=_.useRef(null);_.useEffect(()=>{const g=m=>{};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[]);const h=async g=>{if(g.preventDefault(),i.trim()&&!s){o(!0);try{await e(i,n.eventId)}catch(m){console.error("Error submitting response:",m)}finally{o(!1)}}},f=async g=>{if(!s){l(g),o(!0);try{await e(g,n.eventId)}catch(m){console.error("Error selecting option:",m)}finally{o(!1),l(null)}}};return S.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-80 flex items-center justify-center z-50 p-4 backdrop-blur-sm",children:S.jsxs("div",{ref:d,className:"bg-gray-800 rounded-lg shadow-2xl max-w-md w-full p-5 border border-gray-600",children:[S.jsx("div",{className:"flex items-center justify-between mb-3",children:S.jsx("h3",{className:"text-lg font-semibold text-white",children:ee("askUserDialogTitle")})}),S.jsxs("div",{className:"mb-4",children:[S.jsx("p",{className:"text-gray-200 mb-3 text-sm leading-relaxed",children:n.content}),u&&S.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:n.options.map((g,m)=>S.jsx("button",{className:`px-3 py-1.5 rounded text-white text-sm transition-colors flex items-center justify-center min-w-[80px] ${a===g?"bg-indigo-800":"bg-indigo-600 hover:bg-indigo-700"}`,onClick:()=>f(g),disabled:s,children:a===g&&s?S.jsxs(S.Fragment,{children:[S.jsx("span",{className:"mr-2",children:g}),S.jsxs("svg",{className:"animate-spin h-4 w-4 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[S.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),S.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},m))}),S.jsx("form",{onSubmit:h,className:"mt-3",children:S.jsxs("div",{className:"flex items-center",children:[S.jsx("input",{ref:c,type:"text",className:"flex-1 bg-gray-700 border border-gray-600 rounded-l py-2 px-3 text-white text-sm focus:outline-none focus:ring-1 focus:ring-indigo-500",placeholder:ee("askUserDialogPlaceholder"),value:i,onChange:g=>r(g.target.value),disabled:s,autoFocus:!0}),S.jsx("button",{type:"submit",className:"bg-indigo-600 hover:bg-indigo-700 text-white py-2 px-3 rounded-r text-sm transition-colors border-l-0 border border-indigo-600 disabled:opacity-50 min-w-[60px]",disabled:!i.trim()||s,children:s?S.jsxs("svg",{className:"animate-spin h-4 w-4 text-white mx-auto",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[S.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),S.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"})]}):ee("askUserDialogSend")})]})})]}),n.responseRequired&&S.jsxs("div",{className:"text-xs text-amber-400 flex items-center bg-amber-900 bg-opacity-20 p-2 rounded",children:[S.jsx("svg",{className:"w-4 h-4 mr-1 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:S.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"})}),S.jsx("span",{children:ee("askUserDialogResponseRequired")})]})]})})},X8t=_.lazy(()=>Yt(()=>Promise.resolve().then(()=>Pbn),void 0)),Z8t=_.lazy(()=>Yt(()=>Promise.resolve().then(()=>$bn),void 0)),J8t=({projectName:n,onSwitchToExpertMode:e})=>{const[t,i]=_.useState(""),[r,s]=_.useState(""),[o,a]=_.useState([]),[l,c]=_.useState(!1),[u,d]=_.useState(!1),[h,f]=_.useState(null),[g,m]=_.useState(null),[p,A]=_.useState(!0),[v,b]=_.useState(!0),[y,C]=_.useState("messages"),[w,E]=_.useState([]),k=_.useRef(o);_.useEffect(()=>{k.current=o},[o]);const I=_.useCallback(async(M=!1,B,F)=>{if(!(!B||!F)){console.log(k.current);try{await fetch("/api/auto-command/save-history",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:B,event_file_id:F,messages:k.current,status:M?"error":"completed",timestamp:Date.now()})}),console.log("Task history saved successfully")}catch(W){console.error("Failed to save task history:",W)}}},[]),T=async(M,B)=>{if(!B){console.error("Cannot respond to event: No event ID provided");return}if(!g){console.error("Cannot respond to event: No event file ID available");return}(h==null?void 0:h.eventId)===B&&f(null);try{const F=await fetch("/api/auto-command/response",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event_id:B,event_file_id:g,response:M})});if(!F.ok){const W=await F.json();throw new Error(`Failed to send response: ${W.detail||F.statusText}`)}console.log("Response sent successfully to event:",B)}catch(F){console.error("Error sending response to server:",F),a(W=>[...W,{id:"error-"+Date.now(),type:"ERROR",content:`Failed to send your response to the server: ${F instanceof Error?F.message:String(F)}`}])}};_.useEffect(()=>(sc.on("message",M=>{if(M.type==="ASK_USER"){const B={...M,id:M.id||`msg-${Date.now()}`,timestamp:Date.now()};f(B)}a(B=>{const F={...M,id:M.id||`msg-${Date.now()}`,timestamp:Date.now()},W=B.findIndex(U=>U.id===F.id);if(W>=0){const U=[...B];return U[W]=F,U}return[...B,F]})}),()=>{sc.closeEventStream(),sc.removeAllListeners()}),[]),_.useEffect(()=>{y==="current-change"&&g&&D(g)},[y,g]);const D=async M=>{try{if(!M){console.log("No event file ID available");return}let B=`/api/current-changes?event_file_id=${encodeURIComponent(M)}`;const F=await fetch(B);if(F.ok){const W=await F.json();E(W.commits||[])}else console.error("Failed to fetch current changes:",F.statusText)}catch(B){console.error("Error fetching current changes:",B)}};_.useEffect(()=>(sc.removeAllListeners("taskComplete"),sc.on("taskComplete",M=>{r&&g?(c(!1),console.log("AutoModePage: Set isProcessing to false"),I(M,r,g)):console.warn("Cannot save task history: missing query or event file ID")}),()=>{sc.removeAllListeners("taskComplete")}),[r,g,I]);const O=async M=>{M.preventDefault();const B=window.lastEditorContent||t;if(window.lastEditorContent&&delete window.lastEditorContent,B.trim())try{c(!0),console.log("AutoModePage: Set isProcessing to true"),s(B),a([{id:"user-"+Date.now(),type:"USER",content:B,isUser:!0}]);const F=await sc.executeCommand(B);console.log("AutoModePage: Command executed, received event_file_id:",F.event_file_id),m(F.event_file_id),console.log("AutoModePage: Set currentEventFileId to:",F.event_file_id),i("")}catch(F){console.error("Error executing command:",F),a(W=>[...W,{id:"error-"+Date.now(),type:"ERROR",content:"Failed to execute command. Please try again."}])}finally{console.log("query submitted")}},R=M=>{i(M.query),s(M.query),console.log("Restoring history task messages:",M.messages),a(M.messages),M.event_file_id&&m(M.event_file_id),A(!0),console.log("Restored history task:",M)};return S.jsxs("div",{className:"flex-1 flex flex-col h-screen bg-gray-900",children:[h&&S.jsx(iQe,{message:h,onResponse:T,onClose:()=>f(null)}),S.jsxs("div",{className:`w-full max-w-4xl mx-auto px-4 py-6 flex flex-col ${o.length===0?"justify-center":""} h-full`,children:[S.jsxs("div",{className:"flex flex-col items-center justify-center mb-6 space-y-3",children:[S.jsxs("div",{className:"flex items-center",children:[S.jsx("svg",{className:"w-8 h-8 mr-3",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:S.jsx("path",{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z",stroke:"#8B5CF6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),S.jsx("span",{className:"bg-gradient-to-r from-indigo-500 to-purple-500 text-transparent bg-clip-text font-bold text-3xl",children:"auto-coder.web"})]}),S.jsxs("div",{className:"text-gray-400 text-sm font-mono font-medium",children:[ee("projectName"),": ",n]})]}),o.length>0&&p&&S.jsx("div",{className:"flex-1 mb-6 flex flex-col items-center w-full",children:S.jsxs("div",{className:`w-full ${v?"max-w-full px-4":"max-w-5xl"} flex`,children:[S.jsxs("div",{className:"w-48 sticky top-0 self-start max-h-screen bg-gray-800 rounded-l-lg p-4 flex flex-col shadow-lg",children:[S.jsxs("div",{className:"space-y-3 mb-6",children:[S.jsx("h3",{className:"text-gray-300 font-medium text-xs uppercase tracking-wider mb-2",children:"导航菜单"}),S.jsxs("button",{className:`w-full px-3 py-2 text-left font-medium text-xs rounded-md flex items-center ${y==="messages"?"bg-indigo-600 text-white":"text-gray-300 hover:bg-gray-700 hover:text-white"}`,onClick:()=>C("messages"),children:[S.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})}),ee("showMessages")]}),S.jsxs("button",{className:`w-full px-3 py-2 text-left font-medium text-xs rounded-md flex items-center ${y==="current-change"?"bg-indigo-600 text-white":"text-gray-300 hover:bg-gray-700 hover:text-white"}`,onClick:()=>C("current-change"),children:[S.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:S.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"})}),ee("currentChange")]}),S.jsxs("button",{className:`w-full px-3 py-2 text-left font-medium text-xs rounded-md flex items-center ${y==="commits"?"bg-indigo-600 text-white":"text-gray-300 hover:bg-gray-700 hover:text-white"}`,onClick:()=>C("commits"),children:[S.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})}),ee("viewChange")]})]}),S.jsxs("div",{className:"mt-auto flex flex-col space-y-2 pt-4 border-t border-gray-700",children:[S.jsx("button",{className:"w-full flex items-center justify-center text-gray-400 hover:text-white p-2 transition-colors rounded hover:bg-gray-700",onClick:()=>b(!v),title:v?"全屏宽度":"限制宽度",children:v?S.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:S.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"})}):S.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8h16M4 16h16"})})}),S.jsx("button",{className:"w-full flex items-center justify-center text-gray-400 hover:text-white p-2 transition-colors rounded hover:bg-gray-700",onClick:()=>A(!1),title:"关闭",children:S.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),S.jsx("div",{className:`flex-1 ${v?"overflow-y-auto":""} bg-gray-800 rounded-r-lg p-5 shadow-lg`,children:y==="messages"?S.jsx(Obn,{messages:o,currentTask:r.length>0?r.length>20?`${r.substring(0,20)}...`:r:n||ee("noProjectSelected"),onUserResponse:T}):y==="current-change"?S.jsx(_.Suspense,{fallback:S.jsx("div",{className:"p-4 text-gray-400 text-center",children:"Loading Changes..."}),children:S.jsx(Z8t,{projectName:n,commits:w})}):S.jsx(_.Suspense,{fallback:S.jsx("div",{className:"p-4 text-gray-400 text-center",children:"Loading Commits..."}),children:S.jsx(X8t,{projectName:n})})})]})}),o.length>0&&!p&&S.jsxs("button",{className:"mb-6 py-2 px-4 bg-gray-800 hover:bg-gray-700 text-gray-300 rounded-lg flex items-center justify-center transition-colors",onClick:()=>A(!0),children:[S.jsx("svg",{className:"w-5 h-5 mr-2",fill:"currentColor",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",children:S.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm1-11a1 1 0 10-2 0v2H7a1 1 0 100 2h2v2a1 1 0 102 0v-2h2a1 1 0 100-2h-2V7z",clipRule:"evenodd"})}),ee("showMessages")]}),S.jsx(Y8t,{projectName:n,isProcessing:l,autoSearchTerm:t,setAutoSearchTerm:i,onSubmit:O,onSelectHistoryTask:R,currentEventFileId:g}),S.jsxs("div",{className:"text-center text-gray-400 mt-4",children:[S.jsx("p",{className:"mb-2",children:ee("autoModeDescription")}),S.jsxs("p",{children:[ee("tryExamples"),":"]}),S.jsxs("div",{className:"flex flex-wrap justify-center gap-2 mt-3",children:[S.jsx("button",{className:"px-3 py-1 bg-gray-800 hover:bg-gray-700 rounded-full text-sm text-gray-300 transition-colors",onClick:()=>i("Add authentication to the app"),disabled:l,children:"Add authentication"}),S.jsx("button",{className:"px-3 py-1 bg-gray-800 hover:bg-gray-700 rounded-full text-sm text-gray-300 transition-colors",onClick:()=>i("Create a new API endpoint"),disabled:l,children:"Create API endpoint"}),S.jsx("button",{className:"px-3 py-1 bg-gray-800 hover:bg-gray-700 rounded-full text-sm text-gray-300 transition-colors",onClick:()=>i("Fix bugs in the code"),disabled:l,children:"Fix bugs"})]})]})]})]})};function w4e(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,i)}return t}function ok(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?w4e(Object(t),!0).forEach(function(i){he(n,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):w4e(Object(t)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(t,i))})}return n}function e7t(n){var e=n.length;if(e===0||e===1)return n;if(e===2)return[n[0],n[1],"".concat(n[0],".").concat(n[1]),"".concat(n[1],".").concat(n[0])];if(e===3)return[n[0],n[1],n[2],"".concat(n[0],".").concat(n[1]),"".concat(n[0],".").concat(n[2]),"".concat(n[1],".").concat(n[0]),"".concat(n[1],".").concat(n[2]),"".concat(n[2],".").concat(n[0]),"".concat(n[2],".").concat(n[1]),"".concat(n[0],".").concat(n[1],".").concat(n[2]),"".concat(n[0],".").concat(n[2],".").concat(n[1]),"".concat(n[1],".").concat(n[0],".").concat(n[2]),"".concat(n[1],".").concat(n[2],".").concat(n[0]),"".concat(n[2],".").concat(n[0],".").concat(n[1]),"".concat(n[2],".").concat(n[1],".").concat(n[0])];if(e>=4)return[n[0],n[1],n[2],n[3],"".concat(n[0],".").concat(n[1]),"".concat(n[0],".").concat(n[2]),"".concat(n[0],".").concat(n[3]),"".concat(n[1],".").concat(n[0]),"".concat(n[1],".").concat(n[2]),"".concat(n[1],".").concat(n[3]),"".concat(n[2],".").concat(n[0]),"".concat(n[2],".").concat(n[1]),"".concat(n[2],".").concat(n[3]),"".concat(n[3],".").concat(n[0]),"".concat(n[3],".").concat(n[1]),"".concat(n[3],".").concat(n[2]),"".concat(n[0],".").concat(n[1],".").concat(n[2]),"".concat(n[0],".").concat(n[1],".").concat(n[3]),"".concat(n[0],".").concat(n[2],".").concat(n[1]),"".concat(n[0],".").concat(n[2],".").concat(n[3]),"".concat(n[0],".").concat(n[3],".").concat(n[1]),"".concat(n[0],".").concat(n[3],".").concat(n[2]),"".concat(n[1],".").concat(n[0],".").concat(n[2]),"".concat(n[1],".").concat(n[0],".").concat(n[3]),"".concat(n[1],".").concat(n[2],".").concat(n[0]),"".concat(n[1],".").concat(n[2],".").concat(n[3]),"".concat(n[1],".").concat(n[3],".").concat(n[0]),"".concat(n[1],".").concat(n[3],".").concat(n[2]),"".concat(n[2],".").concat(n[0],".").concat(n[1]),"".concat(n[2],".").concat(n[0],".").concat(n[3]),"".concat(n[2],".").concat(n[1],".").concat(n[0]),"".concat(n[2],".").concat(n[1],".").concat(n[3]),"".concat(n[2],".").concat(n[3],".").concat(n[0]),"".concat(n[2],".").concat(n[3],".").concat(n[1]),"".concat(n[3],".").concat(n[0],".").concat(n[1]),"".concat(n[3],".").concat(n[0],".").concat(n[2]),"".concat(n[3],".").concat(n[1],".").concat(n[0]),"".concat(n[3],".").concat(n[1],".").concat(n[2]),"".concat(n[3],".").concat(n[2],".").concat(n[0]),"".concat(n[3],".").concat(n[2],".").concat(n[1]),"".concat(n[0],".").concat(n[1],".").concat(n[2],".").concat(n[3]),"".concat(n[0],".").concat(n[1],".").concat(n[3],".").concat(n[2]),"".concat(n[0],".").concat(n[2],".").concat(n[1],".").concat(n[3]),"".concat(n[0],".").concat(n[2],".").concat(n[3],".").concat(n[1]),"".concat(n[0],".").concat(n[3],".").concat(n[1],".").concat(n[2]),"".concat(n[0],".").concat(n[3],".").concat(n[2],".").concat(n[1]),"".concat(n[1],".").concat(n[0],".").concat(n[2],".").concat(n[3]),"".concat(n[1],".").concat(n[0],".").concat(n[3],".").concat(n[2]),"".concat(n[1],".").concat(n[2],".").concat(n[0],".").concat(n[3]),"".concat(n[1],".").concat(n[2],".").concat(n[3],".").concat(n[0]),"".concat(n[1],".").concat(n[3],".").concat(n[0],".").concat(n[2]),"".concat(n[1],".").concat(n[3],".").concat(n[2],".").concat(n[0]),"".concat(n[2],".").concat(n[0],".").concat(n[1],".").concat(n[3]),"".concat(n[2],".").concat(n[0],".").concat(n[3],".").concat(n[1]),"".concat(n[2],".").concat(n[1],".").concat(n[0],".").concat(n[3]),"".concat(n[2],".").concat(n[1],".").concat(n[3],".").concat(n[0]),"".concat(n[2],".").concat(n[3],".").concat(n[0],".").concat(n[1]),"".concat(n[2],".").concat(n[3],".").concat(n[1],".").concat(n[0]),"".concat(n[3],".").concat(n[0],".").concat(n[1],".").concat(n[2]),"".concat(n[3],".").concat(n[0],".").concat(n[2],".").concat(n[1]),"".concat(n[3],".").concat(n[1],".").concat(n[0],".").concat(n[2]),"".concat(n[3],".").concat(n[1],".").concat(n[2],".").concat(n[0]),"".concat(n[3],".").concat(n[2],".").concat(n[0],".").concat(n[1]),"".concat(n[3],".").concat(n[2],".").concat(n[1],".").concat(n[0])]}var rZ={};function t7t(n){if(n.length===0||n.length===1)return n;var e=n.join(".");return rZ[e]||(rZ[e]=e7t(n)),rZ[e]}function n7t(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=arguments.length>2?arguments[2]:void 0,i=n.filter(function(s){return s!=="token"}),r=t7t(i);return r.reduce(function(s,o){return ok(ok({},s),t[o])},e)}function S4e(n){return n.join(" ")}function i7t(n,e){var t=0;return function(i){return t+=1,i.map(function(r,s){return rQe({node:r,stylesheet:n,useInlineStyles:e,key:"code-segment-".concat(t,"-").concat(s)})})}}function rQe(n){var e=n.node,t=n.stylesheet,i=n.style,r=i===void 0?{}:i,s=n.useInlineStyles,o=n.key,a=e.properties,l=e.type,c=e.tagName,u=e.value;if(l==="text")return u;if(c){var d=i7t(t,s),h;if(!s)h=ok(ok({},a),{},{className:S4e(a.className)});else{var f=Object.keys(t).reduce(function(A,v){return v.split(".").forEach(function(b){A.includes(b)||A.push(b)}),A},[]),g=a.className&&a.className.includes("token")?["token"]:[],m=a.className&&g.concat(a.className.filter(function(A){return!f.includes(A)}));h=ok(ok({},a),{},{className:S4e(m)||void 0,style:n7t(a.className,Object.assign({},a.style,r),t)})}var p=d(e.children);return Ne.createElement(c,qe({key:o},h),p)}}const r7t=function(n,e){var t=n.listLanguages();return t.indexOf(e)!==-1};var s7t=["language","children","style","customStyle","codeTagProps","useInlineStyles","showLineNumbers","showInlineLineNumbers","startingLineNumber","lineNumberContainerStyle","lineNumberStyle","wrapLines","wrapLongLines","lineProps","renderer","PreTag","CodeTag","code","astGenerator"];function x4e(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,i)}return t}function R1(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?x4e(Object(t),!0).forEach(function(i){he(n,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):x4e(Object(t)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(t,i))})}return n}var o7t=/\n/g;function a7t(n){return n.match(o7t)}function l7t(n){var e=n.lines,t=n.startingLineNumber,i=n.style;return e.map(function(r,s){var o=s+t;return Ne.createElement("span",{key:"line-".concat(s),className:"react-syntax-highlighter-line-number",style:typeof i=="function"?i(o):i},"".concat(o,`
|
478
478
|
`))})}function c7t(n){var e=n.codeString,t=n.codeStyle,i=n.containerStyle,r=i===void 0?{float:"left",paddingRight:"10px"}:i,s=n.numberStyle,o=s===void 0?{}:s,a=n.startingLineNumber;return Ne.createElement("code",{style:Object.assign({},t,r)},l7t({lines:e.replace(/\n$/,"").split(`
|
479
479
|
`),style:o,startingLineNumber:a}))}function u7t(n){return"".concat(n.toString().length,".25em")}function sQe(n,e){return{type:"element",tagName:"span",properties:{key:"line-number--".concat(n),className:["comment","linenumber","react-syntax-highlighter-line-number"],style:e},children:[{type:"text",value:n}]}}function oQe(n,e,t){var i={display:"inline-block",minWidth:u7t(t),paddingRight:"1em",textAlign:"right",userSelect:"none"},r=typeof n=="function"?n(e):n,s=R1(R1({},i),r);return s}function m7(n){var e=n.children,t=n.lineNumber,i=n.lineNumberStyle,r=n.largestLineNumber,s=n.showInlineLineNumbers,o=n.lineProps,a=o===void 0?{}:o,l=n.className,c=l===void 0?[]:l,u=n.showLineNumbers,d=n.wrapLongLines,h=n.wrapLines,f=h===void 0?!1:h,g=f?R1({},typeof a=="function"?a(t):a):{};if(g.className=g.className?[].concat(Et(g.className.trim().split(/\s+/)),Et(c)):c,t&&s){var m=oQe(i,t,r);e.unshift(sQe(t,m))}return d&u&&(g.style=R1({display:"flex"},g.style)),{type:"element",tagName:"span",properties:g,children:e}}function aQe(n){for(var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],i=0;i<n.length;i++){var r=n[i];if(r.type==="text")t.push(m7({children:[r],className:Et(new Set(e))}));else if(r.children){var s=e.concat(r.properties.className);aQe(r.children,s).forEach(function(o){return t.push(o)})}}return t}function d7t(n,e,t,i,r,s,o,a,l){var c,u=aQe(n.value),d=[],h=-1,f=0;function g(C,w){var E=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return m7({children:C,lineNumber:w,lineNumberStyle:a,largestLineNumber:o,showInlineLineNumbers:r,lineProps:t,className:E,showLineNumbers:i,wrapLongLines:l,wrapLines:e})}function m(C,w){if(i&&w&&r){var E=oQe(a,w,o);C.unshift(sQe(w,E))}return C}function p(C,w){var E=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return e||E.length>0?g(C,w,E):m(C,w)}for(var A=function(){var w=u[f],E=w.children[0].value,k=a7t(E);if(k){var I=E.split(`
|
480
480
|
`);I.forEach(function(T,D){var O=i&&d.length+s,R={type:"text",value:"".concat(T,`
|
@@ -1966,7 +1966,7 @@ li.version="2.30.1";mti(ra);li.fn=Ln;li.min=rii;li.max=sii;li.now=oii;li.utc=nA;
|
|
1966
1966
|
\`\`\`
|
1967
1967
|
|
1968
1968
|
特别注意,你最后调用 response_user 函数的时候,要给函数传递的是 json 文本数据,符合上面的格式要求。
|
1969
|
-
`,D=`split_task ${JSON.stringify(T)}`;if(e)try{b(e.id),t()}catch(M){console.error("Failed to update task status:",M),Tt.warning(ee("failedToSaveTodo"))}else t();const O=M=>{var B,F;if(f(M)){console.log("Task split result:",M);let W=0,U=null;try{if(U=g(M),U&&(y(U),console.log("Split result saved to TodoPanel:",U),W=U.tasks_count||((B=U.tasks)==null?void 0:B.length)||0,e&&e.id)){const H=((F=U.tasks)==null?void 0:F.map((z,q)=>({id:q,title:z.title,description:z.description||null,references:Array.isArray(z.references)?z.references:[],steps:Array.isArray(z.steps)?z.steps:[],acceptance_criteria:Array.isArray(z.acceptance_criteria)?z.acceptance_criteria:[],priority:z.priority||e.priority,estimate:z.estimate||null})))||[],$={...e,tasks:H,status:"developing",tags:[...e.tags||[]].filter(z=>z!=="正在拆解").concat(["已拆解"]),analysis:U.analysis||null,dependencies:U.dependencies||null};fetch(`/api/todos/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify($)}).then(z=>{if(!z.ok)throw new Error(ee("failedToSaveTodo"));return z.json()}).then(()=>{console.log("Task split result saved to backend successfully"),C(!0),w(e.id),b(null);const z={...e,tags:[...e.tags||[]].filter(q=>q!=="正在拆解").concat(["已拆解"]),analysis:U.analysis||null,dependencies:U.dependencies||null,tasks:H};i(z)}).catch(z=>{console.error("Failed to save split result to backend:",z),Tt.warning(ee("failedToSaveTodo"))})}}catch(H){console.error("Error parsing task result:",H)}Tt.success(ee("taskSplitSuccess",{count:String(W)}))}},R=M=>{console.log("Task complete event received, has error:",M),d(!1),M&&Tt.error(ee("failedToSplitTask")),b(null),sc.removeListener("message",O),sc.removeListener("taskComplete",R),h.current=!1};sc.on("message",O),sc.on("taskComplete",R),h.current=!0,await sc.executeCommand(D)}catch(T){console.error(ee("failedToSplitTask"),T),Tt.error(ee("failedToSplitTask")),d(!1),t(),h.current&&(sc.removeListener("message",function(){}),sc.removeListener("taskComplete",function(){}),h.current=!1)}},k=[{value:"P0",label:ee("priorityP0")},{value:"P1",label:ee("priorityP1")},{value:"P2",label:ee("priorityP2")},{value:"P3",label:ee("priorityP3")}];return S.jsxs(qs,{title:ee("editTodoTitle"),open:n,onCancel:t,footer:[S.jsx(yn,{type:"default",icon:S.jsx(l5t,{}),loading:u,onClick:E,className:"bg-purple-700 hover:bg-purple-800 border-none text-white",children:ee("splitTask")},"split"),S.jsx(yn,{onClick:t,children:ee("cancel")},"cancel"),S.jsx(yn,{type:"primary",loading:o,onClick:m,className:"bg-blue-600 hover:bg-blue-700 border-none",children:ee("save")},"save")],className:"dark-theme-modal",styles:{content:{backgroundColor:"#1f2937",padding:"20px"},header:{backgroundColor:"#1f2937",borderBottom:"1px solid #374151"},body:{backgroundColor:"#1f2937"}},width:700,children:[S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{className:"block text-gray-300 mb-1",children:ee("todoTitle")}),S.jsx(yi,{value:r.title,onChange:T=>s({...r,title:T.target.value}),placeholder:ee("todoTitlePlaceholder"),className:"custom-input bg-gray-800 border-gray-700 text-gray-200"})]}),S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{className:"block text-gray-300 mb-1",children:ee("todoDescription")}),S.jsx(msi,{value:r.description,onChange:T=>s({...r,description:T.target.value}),placeholder:ee("todoDescriptionPlaceholder"),rows:6,className:"custom-input bg-gray-800 border-gray-700 text-gray-200"})]}),S.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{className:"block text-gray-300 mb-1",children:ee("priority")}),S.jsx(qi,{value:r.priority,onChange:T=>s({...r,priority:T}),options:k,className:"custom-select w-full"})]}),S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{className:"block text-gray-300 mb-1",children:ee("dueDate")}),S.jsx(IT,{value:r.dueDate?li(r.dueDate):void 0,onChange:T=>s({...r,dueDate:T?T.toISOString():void 0}),className:"custom-input bg-gray-800 border-gray-700 text-gray-200 w-full"})]})]}),S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{className:"block text-gray-300 mb-1",children:ee("tags")}),S.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:(I=r.tags)==null?void 0:I.map(T=>S.jsx(Sv,{closable:!0,onClose:()=>A(T),className:"text-xs bg-gray-700 border-none text-gray-300 rounded-full px-3 py-1",children:T},T))}),S.jsxs("div",{className:"flex",children:[S.jsx(yi,{value:l,onChange:T=>c(T.target.value),placeholder:ee("addTagPlaceholder"),className:"custom-input bg-gray-800 border-gray-700 text-gray-200 flex-1 mr-2",onPressEnter:p}),S.jsx(yn,{icon:S.jsx(hc,{}),onClick:p,className:"bg-gray-700 hover:bg-gray-600 border-none text-gray-200",children:ee("addTag")})]})]})]})},vsi=({visible:n,todo:e,onClose:t,onConfirm:i,isExecuting:r,confirmMode:s=!0})=>{const o=()=>r?S.jsx(_h,{size:"large"}):s?S.jsx(ex,{style:{color:"#faad14"}}):S.jsx(JOt,{style:{color:"#1890ff"}}),a=()=>ee(r?"taskExecutingMessage":s?"taskConfirmExecuteMessage":"taskAutoExecuteMessage"),l=()=>!r&&s?ee("taskConfirmExecuteDescription"):r?null:ee("taskAutoExecuteDescription"),c=()=>{s?t():document.dispatchEvent(new CustomEvent("closeExecuteModal"))},u=()=>r?[S.jsx(yn,{onClick:c,disabled:!0,className:"bg-gray-700 border-none text-gray-400",children:ee("close")},"close")]:s?[S.jsx(yn,{onClick:t,className:"bg-gray-700 hover:bg-gray-600 border-none text-gray-200",children:ee("cancel")},"cancel"),S.jsx(yn,{type:"primary",onClick:i,className:"bg-blue-600 hover:bg-blue-700 border-none",children:ee("confirm")},"confirm")]:[S.jsx(yn,{onClick:c,className:"bg-gray-700 hover:bg-gray-600 border-none text-gray-200",children:ee("close")},"close")];return S.jsxs(qs,{title:ee("taskAutoExecuteTitle"),open:n,onCancel:r?void 0:c,footer:u(),closable:!r,maskClosable:!r,className:"dark-theme-modal",styles:{content:{backgroundColor:"#1f2937",padding:"20px"},header:{backgroundColor:"#1f2937",borderBottom:"1px solid #374151"},body:{backgroundColor:"#1f2937"}},width:500,children:[S.jsx(ZV,{icon:o(),title:S.jsx("span",{className:"text-gray-200",children:e==null?void 0:e.title}),subTitle:S.jsx("span",{className:"text-gray-400",children:a()}),className:"bg-gray-800 rounded-lg p-4 border border-gray-700"}),l()&&S.jsx("div",{className:"mt-4 text-gray-400 text-sm",children:S.jsx("p",{children:l()})})]})},{Panel:fui}=sw,{Paragraph:bsi}=lh,_si={background:"#1e293b",borderColor:"#334155",color:"#f8fafc",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},ysi=({analysis:n,updateAnalysis:e,onBlur:t})=>S.jsx(o0,{bordered:!1,style:_si,className:"rounded-lg overflow-hidden",children:S.jsx(bsi,{style:{color:"#cbd5e1",lineHeight:1.6,fontSize:"14px"},editable:{onChange:e,tooltip:"Click to edit analysis",icon:S.jsx(pf,{style:{color:"#0ea5e9"}}),onEnd:t},children:n})}),{Panel:gui}=sw,{Text:V8,Paragraph:Csi}=lh,{TextArea:pui}=yi,wsi={background:"#1e293b",borderColor:"#334155",color:"#f8fafc",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},Ssi=({tasks:n,tasksCount:e,updateTaskData:t,updateArrayField:i,saveData:r,parsedResult:s,setParsedResult:o,addSubTask:a,deleteSubTask:l,onTaskDataBlur:c,onArrayFieldBlur:u})=>{const d=()=>a?S.jsx("div",{className:"flex justify-end mb-4",children:S.jsx(yn,{type:"primary",icon:S.jsx(hc,{}),onClick:a,style:{backgroundColor:"#0ea5e9"},children:"添加子任务"})}):null,h=()=>S.jsx(yu,{dataSource:n,itemLayout:"vertical",split:!1,className:"space-y-4",renderItem:(m,p)=>S.jsx(yu.Item,{className:"p-0",children:S.jsxs(o0,{bordered:!1,className:"rounded-lg overflow-hidden transition-all duration-300 hover:shadow-xl",style:wsi,title:S.jsxs("div",{className:"flex justify-between items-center py-1",children:[S.jsxs("div",{className:"flex items-center",children:[S.jsx(XS,{count:m.id!==void 0?m.id:p,style:{backgroundColor:"#0ea5e9",marginRight:"12px",boxShadow:"0 0 0 2px rgba(14, 165, 233, 0.2)"}}),S.jsx(V8,{style:{color:"#f8fafc",fontWeight:600,fontSize:"15px"},editable:{onChange:A=>t(p,"title",A),tooltip:"Click to edit title",icon:S.jsx(pf,{style:{color:"#0ea5e9"}}),onEnd:c},children:m.title})]}),S.jsxs("div",{className:"flex items-center space-x-2",children:[l&&S.jsx(Er,{title:"删除此子任务",children:S.jsx(yn,{type:"text",danger:!0,icon:S.jsx(bd,{}),onClick:A=>{A.stopPropagation(),l(p)},size:"small"})}),S.jsx(Er,{title:"Click to change priority",children:S.jsx(qi,{value:m.priority||"P2",style:{width:70},bordered:!1,dropdownStyle:{backgroundColor:"#1e293b",color:"#f8fafc"},onChange:A=>t(p,"priority",A),onBlur:c,options:[{value:"P0",label:"P0"},{value:"P1",label:"P1"},{value:"P2",label:"P2"},{value:"P3",label:"P3"}],suffixIcon:null,className:"priority-select"})}),S.jsx(Er,{title:"Click to edit estimate",children:S.jsx(yi,{prefix:S.jsx(KV,{style:{color:"#0ea5e9"}}),value:m.estimate||"",onChange:A=>t(p,"estimate",A.target.value),onBlur:c,style:{width:100,backgroundColor:"#334155",color:"#e2e8f0",border:"none",borderRadius:"4px",padding:"0 8px"},size:"small"})})]})]}),headStyle:{backgroundColor:"#0f172a",borderBottom:"1px solid #334155",padding:"12px 16px"},bodyStyle:{padding:"16px"},children:[S.jsx(Csi,{style:{color:"#cbd5e1",lineHeight:1.6,fontSize:"14px",marginBottom:"16px"},editable:{onChange:A=>t(p,"description",A),tooltip:"Click to edit description",icon:S.jsx(pf,{style:{color:"#0ea5e9"}}),onEnd:c},children:m.description}),m.references&&m.references.length>0&&S.jsxs("div",{className:"mb-5",children:[S.jsxs("div",{className:"flex items-center mb-2",children:[S.jsx(fKe,{style:{color:"#0ea5e9",marginRight:"8px"}}),S.jsx(V8,{style:{color:"#0ea5e9",fontWeight:500},children:ee("references")})]}),S.jsx("div",{className:"flex flex-wrap gap-2",children:m.references.map((A,v)=>S.jsx(yi,{value:A,onChange:b=>i(p,"references",v,b.target.value),onBlur:u,style:{backgroundColor:"#1e293b",color:"#94a3b8",border:"1px solid #334155",borderRadius:"4px",padding:"2px 8px",width:"auto",marginRight:"8px",marginBottom:"8px"},size:"small"},v))})]}),S.jsxs("div",{className:"mb-5",children:[S.jsxs("div",{className:"flex items-center justify-between mb-3",children:[S.jsxs("div",{className:"flex items-center",children:[S.jsx(gKe,{style:{color:"#0ea5e9",marginRight:"8px"}}),S.jsx(V8,{style:{color:"#0ea5e9",fontWeight:500},children:ee("implementationSteps")})]}),S.jsx(yn,{type:"text",icon:S.jsx(hc,{}),size:"small",onClick:()=>{const A=[...m.steps||[],""],v=[...s.tasks];v[p]={...m,steps:A};const b={...s,tasks:v};o(b),r(b)},style:{color:"#0ea5e9"}})]}),S.jsx("div",{className:"mb-2",style:{color:"#cbd5e1",background:"#0f172a",padding:"12px",borderRadius:"6px"},children:m.steps&&m.steps.length>0&&m.steps.map((A,v)=>S.jsxs("div",{className:"flex items-start mb-3",children:[S.jsx("div",{className:"mr-3 mt-1",children:S.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:"#0ea5e9",display:"inline-block"}})}),S.jsxs("div",{className:"flex-1 relative",children:[S.jsx(yi.TextArea,{value:A,onChange:b=>i(p,"steps",v,b.target.value),onBlur:u,style:{backgroundColor:"transparent",color:"#e2e8f0",border:"1px solid #334155",borderRadius:"4px",width:"100%",resize:"vertical",minHeight:"60px"},autoSize:{minRows:2,maxRows:6}}),S.jsx(yn,{type:"text",danger:!0,icon:S.jsx(bd,{}),size:"small",onClick:()=>{const b=[...m.steps];b.splice(v,1);const y=[...s.tasks];y[p]={...m,steps:b};const C={...s,tasks:y};o(C),r(C)},style:{position:"absolute",right:"-30px",top:"0"}})]})]},v))})]}),m.acceptance_criteria&&m.acceptance_criteria.length>0&&S.jsxs("div",{className:"mb-2",children:[S.jsxs("div",{className:"flex items-center mb-3",children:[S.jsx(uKe,{style:{color:"#0ea5e9",marginRight:"8px"}}),S.jsx(V8,{style:{color:"#0ea5e9",fontWeight:500},children:ee("acceptanceCriteria")})]}),S.jsx("div",{className:"space-y-2",children:m.acceptance_criteria.map((A,v)=>S.jsxs("div",{style:{color:"#e2e8f0",border:"none",background:"#0f172a",padding:"8px 12px",borderRadius:"4px",display:"flex",alignItems:"flex-start"},children:[S.jsx(XS,{count:v+1,size:"small",style:{backgroundColor:"#0ea5e9",marginRight:"8px",marginTop:"6px"}}),S.jsx(yi.TextArea,{value:A,onChange:b=>i(p,"acceptance_criteria",v,b.target.value),style:{backgroundColor:"transparent",color:"#e2e8f0",border:"none",width:"100%",resize:"vertical"},autoSize:{minRows:1,maxRows:4}})]},v))})]})]})})}),f=()=>S.jsxs("div",{className:"flex flex-col items-center",children:[S.jsx(ia,{image:ia.PRESENTED_IMAGE_SIMPLE,description:S.jsx("span",{className:"text-gray-400",children:ee("noSubTasks")})}),a&&S.jsx(yn,{type:"primary",icon:S.jsx(hc,{}),onClick:a,style:{marginTop:"16px",backgroundColor:"#0ea5e9"},children:"添加子任务"})]}),g=()=>n&&n.length>0?S.jsxs("div",{children:[d(),h()]}):f();return S.jsx("div",{children:g()})},{Panel:mui}=sw,{Text:WUe}=lh,xsi={background:"#1e293b",borderColor:"#334155",color:"#f8fafc",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},Esi=({dependencies:n,updateDependency:e,updateDependencyItem:t,onDependencyBlur:i,onDependencyItemBlur:r})=>!n||n.length===0?null:S.jsx("div",{children:S.jsx(yu,{dataSource:n,split:!1,className:"space-y-4",renderItem:(s,o)=>S.jsx(yu.Item,{className:"p-0",children:S.jsx(o0,{bordered:!1,className:"rounded-lg overflow-hidden transition-all duration-300 hover:shadow-xl",style:xsi,bodyStyle:{padding:"16px"},children:S.jsxs("div",{children:[S.jsxs("div",{className:"flex items-center mb-3",children:[S.jsx(XS,{status:"processing",color:"#0ea5e9",style:{marginRight:"8px"}}),S.jsx(WUe,{style:{color:"#f8fafc",fontWeight:600},editable:{onChange:a=>e(o,"task",a),tooltip:"Click to edit task",icon:S.jsx(pf,{style:{color:"#0ea5e9"}}),onEnd:i},children:s.task})]}),S.jsxs(WUe,{style:{color:"#94a3b8",display:"block",marginBottom:"8px"},children:[ee("dependsOn"),":"]}),S.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:s.depends_on.map((a,l)=>S.jsx(yi,{value:a,onChange:c=>t(o,l,c.target.value),onBlur:r,style:{backgroundColor:"#0f172a",color:"#0ea5e9",border:"1px solid #0ea5e9",borderRadius:"4px",padding:"2px 8px",width:"auto",marginRight:"8px",marginBottom:"8px"},size:"small"},l))})]})})})})}),{Title:ksi}=lh,Lsi=({visible:n,result:e,todoId:t,onClose:i})=>{var U,H;const[r,s]=_.useState(["1"]),[o,a]=_.useState(!0),[l,c]=_.useState(null),[u,d]=_.useState(null),[h,f]=_.useState(!1),[g,m]=_.useState(!1);_.useEffect(()=>{if(a(!0),c(null),e)try{let $;typeof e=="string"?$=Tpt.extract(e)||{}:$=e,$.tasks&&Array.isArray($.tasks)&&($.tasks=$.tasks.map((z,q)=>({...z,id:z.id!==void 0?z.id:q}))),d($)}catch($){console.error("Error parsing result:",$),c("Failed to parse task split result")}else d(null);a(!1)},[e]);const p=async $=>{var z,q,j;if(!$){console.log("saveData: No data provided to save");return}console.log("saveData: Starting save operation",{updatedResult:$}),f(!0),m(!1);try{if(!t)throw console.error("saveData: No todoId found in result object"),new Error("No todoId found in result");const K={tasks:$.tasks.map(ae=>({id:ae.id,title:ae.title,description:ae.description,references:ae.references,steps:ae.steps,acceptance_criteria:ae.acceptance_criteria,priority:ae.priority,estimate:ae.estimate,status:ae.status||"pending"})),analysis:$.analysis,dependencies:$.dependencies};console.log("saveData: Prepared update data",{updateData:K}),console.log(`saveData: Sending PUT request to /api/todos/${t}`);const Z=await Hr.put(`/api/todos/${t}`,K);if(console.log("saveData: Received response",{status:Z.status,statusText:Z.statusText,data:Z.data}),Z.status!==200)throw console.error("saveData: API returned non-200 status",{status:Z.status,statusText:Z.statusText}),new Error(`Failed to save changes: ${Z.statusText}`);console.log("saveData: Changes saved successfully"),Tt.success("Changes saved successfully")}catch(K){console.error("saveData: Error saving changes:",K),Hr.isAxiosError(K)&&console.error("saveData: Axios error details:",{status:(z=K.response)==null?void 0:z.status,statusText:(q=K.response)==null?void 0:q.statusText,data:(j=K.response)==null?void 0:j.data,message:K.message}),Tt.error(`Failed to save changes: ${K instanceof Error?K.message:"Unknown error"}`)}finally{console.log("saveData: Operation complete"),f(!1)}},A=($,z,q)=>{if(!u)return;const j={...u},K=[...j.tasks];K[$]={...K[$],[z]:q},j.tasks=K,d(j),m(!0)},v=()=>{g&&u&&p(u)},b=($,z,q)=>{A($,z,q)},y=($,z,q,j)=>{if(!u)return;const K={...u},Z=[...K.tasks],ae=[...Z[$][z]];ae[q]=j,Z[$]={...Z[$],[z]:ae},K.tasks=Z,d(K),m(!0)},C=()=>{g&&u&&p(u)},w=($,z,q,j)=>{y($,z,q,j)},E=$=>{if(!u)return;const z={...u};z.analysis=$,d(z),m(!0)},k=()=>{g&&u&&p(u)},I=$=>{E($)},T=($,z,q)=>{if(!u||!u.dependencies)return;const j={...u},K=[...j.dependencies];z==="task"?K[$]={...K[$],task:q}:z==="depends_on"&&(K[$]={...K[$],depends_on:q}),j.dependencies=K,d(j),m(!0)},D=()=>{g&&u&&p(u)},O=($,z,q)=>{T($,z,q)},R=($,z,q)=>{if(!u||!u.dependencies)return;const j={...u},K=[...j.dependencies],Z=[...K[$].depends_on];Z[z]=q,K[$]={...K[$],depends_on:Z},j.dependencies=K,d(j),m(!0)},M=()=>{g&&u&&p(u)},B=($,z,q)=>{R($,z,q)},F=()=>{if(!u)return;const $={...u},z=[...$.tasks],q={id:z.length+1,title:`新任务 ${z.length+1}`,description:"",references:[],steps:[],acceptance_criteria:[],priority:"P2",estimate:"1d"};z.push(q),$.tasks=z,$.tasks_count=z.length,d($),p($),Tt.success("新子任务添加成功")},W=$=>{if(!u)return;const z={...u},q=[...z.tasks];q.splice($,1),q.forEach((j,K)=>{j.id=K+1}),z.tasks=q,z.tasks_count=q.length,z.dependencies&&z.dependencies.length>0&&(z.dependencies=z.dependencies.filter(j=>j.task!==`Task ${$+1}`&&!j.depends_on.includes(`Task ${$+1}`)),z.dependencies.forEach(j=>{const K=j.task.match(/Task (\d+)/);if(K){const Z=parseInt(K[1]);Z>$+1&&(j.task=`Task ${Z-1}`)}j.depends_on=j.depends_on.map(Z=>{const ae=Z.match(/Task (\d+)/);if(ae){const te=parseInt(ae[1]);if(te>$+1)return`Task ${te-1}`}return Z})})),d(z),p(z),Tt.success("子任务删除成功")};return n?o?S.jsx("div",{className:"task-split-result-view bg-slate-900 rounded-xl p-6 mb-4 shadow-lg",children:S.jsxs("div",{className:"text-center py-8",children:[S.jsx("div",{className:"inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-sky-500 border-r-transparent"}),S.jsx("p",{className:"text-sky-400 mt-4 font-medium",children:ee("loading")})]})}):l||!u?S.jsx("div",{className:"task-split-result-view bg-slate-900 rounded-xl p-6 mb-4 shadow-lg",children:S.jsx(uI,{message:ee("errorTitle"),description:l||ee("noSplitResultData"),type:"error",showIcon:!0,style:{background:"#450a0a",borderColor:"#b91c1c",borderRadius:"8px"}})}):S.jsxs("div",{className:"task-split-result-view bg-slate-900 rounded-xl p-6 mb-4 animate-fadeIn shadow-lg",children:[S.jsxs("div",{className:"flex items-center justify-between mb-6",children:[S.jsx(ksi,{level:4,style:{color:"#f8fafc",margin:0,fontWeight:600},children:ee("taskSplitResultTitle")}),S.jsxs("div",{className:"flex items-center",children:[h&&S.jsx("span",{style:{color:"#60a5fa",marginRight:"10px",fontSize:"14px"},children:"Saving changes..."}),g&&!h&&S.jsx("span",{style:{color:"#fbbf24",marginRight:"10px",fontSize:"14px"},children:"Unsaved changes"}),S.jsx(Er,{title:ee("taskSplitResultHelp")||"Task breakdown and analysis",children:S.jsx(hKe,{style:{color:"#60a5fa",fontSize:"18px"}})}),i&&S.jsx(yn,{type:"text",icon:S.jsx(nm,{}),onClick:()=>{g&&u?p(u).then(()=>{i()}):i()},style:{marginLeft:"8px",color:"#94a3b8"},size:"small"})]})]}),S.jsxs(sw,{activeKey:r,onChange:$=>s($),expandIcon:({isActive:$})=>S.jsx(S3t,{rotate:$?90:0,style:{color:"#0ea5e9"}}),className:"bg-transparent border-0 shadow-none",ghost:!0,children:[S.jsx(sw.Panel,{header:S.jsxs("div",{style:{background:"#0f172a",borderRadius:"6px",padding:"8px 12px",marginBottom:"8px",borderLeft:"3px solid #0ea5e9"},className:"flex items-center",children:[S.jsx(gKe,{style:{color:"#0ea5e9",marginRight:"8px"}}),S.jsx("span",{style:{color:"#f8fafc",fontWeight:500},children:ee("taskAnalysis")})]}),className:"mb-4",children:S.jsx(ysi,{analysis:u.analysis,updateAnalysis:I,onBlur:k})},"2"),S.jsx(sw.Panel,{header:S.jsxs("div",{style:{background:"#0f172a",borderRadius:"6px",padding:"8px 12px",marginBottom:"8px",borderLeft:"3px solid #0ea5e9"},className:"flex items-center",children:[S.jsx(h3t,{style:{color:"#0ea5e9",marginRight:"8px"}}),S.jsxs("span",{style:{color:"#f8fafc",fontWeight:500},children:[ee("subTasks"),S.jsx(XS,{count:u.tasks_count||((U=u.tasks)==null?void 0:U.length)||0,style:{backgroundColor:"#0ea5e9",marginLeft:"8px"}})]})]}),className:"mb-4",children:S.jsx(Ssi,{tasks:u.tasks,tasksCount:u.tasks_count||((H=u.tasks)==null?void 0:H.length)||0,updateTaskData:b,updateArrayField:w,saveData:p,parsedResult:u,setParsedResult:d,addSubTask:F,deleteSubTask:W,onTaskDataBlur:v,onArrayFieldBlur:C})},"3"),u.dependencies&&u.dependencies.length>0&&S.jsx(sw.Panel,{header:S.jsxs("div",{style:{background:"#0f172a",borderRadius:"6px",padding:"8px 12px",marginBottom:"8px",borderLeft:"3px solid #0ea5e9"},className:"flex items-center",children:[S.jsx(fKe,{style:{color:"#0ea5e9",marginRight:"8px"}}),S.jsx("span",{style:{color:"#f8fafc",fontWeight:500},children:ee("taskDependencies")})]}),className:"mb-4",children:S.jsx(Esi,{dependencies:u.dependencies,updateDependency:O,updateDependencyItem:B,onDependencyBlur:D,onDependencyItemBlur:M})},"4")]})]}):null},{Title:Isi,Text:q8}=lh,Tsi=n=>{switch(n){case"completed":return S.jsx(uKe,{style:{color:"#52c41a"}});case"failed":return S.jsx(dKe,{style:{color:"#f5222d"}});case"executing":return S.jsx(_D,{spin:!0,style:{color:"#3b82f6"}});default:return S.jsx(KV,{style:{color:"#faad14"}})}},Nsi=n=>{switch(n){case"completed":return"success";case"failed":return"error";case"executing":return"blue";default:return"warning"}},Dsi=({todoId:n,onClose:e})=>{const[t,i]=_.useState(null),[r,s]=_.useState(!0),[o,a]=_.useState(null),[l,c]=_.useState(null),u=f=>{if(!f||f.length===0)return 0;const g=f.filter(m=>m.status==="completed").length;return Math.round(g/f.length*100)},d=async()=>{try{const f=await Hr.get(`/api/todos/${n}/tasks/status`);i(f.data),s(!1);const g=f.data.tasks.every(p=>p.status==="completed"),m=f.data.tasks.some(p=>p.status==="failed");(g||m)&&l&&(clearInterval(l),c(null))}catch(f){console.error("Error fetching task status:",f),a("Failed to fetch task status"),s(!1)}};if(_.useEffect(()=>{d();const f=setInterval(d,3e3);return c(f),()=>{l&&clearInterval(l)}},[n]),r)return S.jsx(o0,{className:"task-status-card",headStyle:{backgroundColor:"#2d2d2d",borderBottom:"1px solid #374151"},bodyStyle:{backgroundColor:"#2d2d2d"},children:S.jsxs("div",{className:"task-status-loading",children:[S.jsx(_h,{size:"large"}),S.jsx(q8,{style:{color:"#e5e7eb"},children:"加载任务状态..."})]})});if(o)return S.jsx(o0,{className:"task-status-card",headStyle:{backgroundColor:"#2d2d2d",borderBottom:"1px solid #374151"},bodyStyle:{backgroundColor:"#2d2d2d"},children:S.jsx(uI,{message:"Error",description:o,type:"error",showIcon:!0})});if(!t||!t.tasks||t.tasks.length===0)return S.jsx(o0,{className:"task-status-card",headStyle:{backgroundColor:"#2d2d2d",borderBottom:"1px solid #374151"},bodyStyle:{backgroundColor:"#2d2d2d"},children:S.jsx(uI,{message:"No Tasks",description:"No tasks found for this todo item.",type:"info",showIcon:!0})});const h=u(t.tasks);return S.jsxs(o0,{className:"task-status-card",title:S.jsxs("div",{className:"task-status-header",children:[S.jsx(Isi,{level:4,style:{color:"#e5e7eb"},children:"任务执行状态"}),S.jsx(cKe,{type:"circle",percent:h,width:60,strokeColor:"#3b82f6"})]}),headStyle:{backgroundColor:"#2d2d2d",borderBottom:"1px solid #374151"},bodyStyle:{backgroundColor:"#2d2d2d"},children:[S.jsx(yu,{itemLayout:"horizontal",dataSource:t.tasks,renderItem:(f,g)=>S.jsx(yu.Item,{children:S.jsx(yu.Item.Meta,{avatar:Tsi(f.status),title:S.jsxs(JS,{children:[S.jsx(q8,{strong:!0,style:{color:"#e5e7eb"},children:`Task ${g+1}: ${f.title}`}),S.jsx(Sv,{color:Nsi(f.status),children:f.status==="completed"?"已完成":f.status==="failed"?"失败":f.status==="executing"?"执行中":"等待中"})]}),description:S.jsx(q8,{style:{color:"#9ca3af"},children:f.event_file_id?`ID: ${f.event_file_id}`:""})})})}),S.jsx(xGe,{style:{borderColor:"#374151"}}),S.jsx("div",{className:"task-status-footer",children:S.jsx(q8,{style:{color:"#9ca3af"},children:h===100?"所有任务已完成":`${t.tasks.filter(f=>f.status==="completed").length} / ${t.tasks.length} 任务完成`})})]})},Rsi={P0:"red",P1:"orange",P2:"blue",P3:"gray"},Msi=[{value:"P0",label:ee("priorityP0")},{value:"P1",label:ee("priorityP1")},{value:"P2",label:ee("priorityP2")},{value:"P3",label:ee("priorityP3")}],G8=(n=[])=>(n||[]).filter((t,i,r)=>r.indexOf(t)===i),Osi=()=>{const[n,e]=_.useState([]),[t,i]=_.useState(!1),[r,s]=_.useState({}),[o,a]=_.useState(!1),[l,c]=_.useState(null),[u,d]=_.useState(null),[h,f]=_.useState(!1),[g,m]=_.useState(!1),[p,A]=_.useState(null),[v,b]=_.useState(!1),[y,C]=_.useState(!0),[w,E]=_.useState(null),[k,I]=_.useState(null),[T,D]=_.useState(null),[O,R]=_.useState(null),{splittingTodoId:M,setSplittingTodoId:B,lastSplitResult:F,setLastSplitResult:W,splitCompleted:U,setSplitCompleted:H,lastSplitTodoId:$,setLastSplitTodoId:z}=Dpt();_.useEffect(()=>{ne();const Ee=()=>{m(!1)};return document.addEventListener("closeExecuteModal",Ee),()=>{document.removeEventListener("closeExecuteModal",Ee)}},[]),_.useEffect(()=>{U&&$&&F&&(ne(),I(F),E($),H(!1))},[U,$,F,H]);const q=[{id:"pending",title:ee("statusPending")},{id:"developing",title:ee("statusDeveloping")},{id:"testing",title:ee("statusTesting")},{id:"done",title:ee("statusDone")}],j=async Ee=>{const{source:Me,destination:je}=Ee;if(!je)return;const Ve=n.find(rt=>rt.id===Ee.draggableId);if(Ve&&(Me.droppableId==="testing"||Me.droppableId==="done")&&(je.droppableId==="pending"||je.droppableId==="developing")){c("测试中或已完成的任务不能移动到待办或开发中状态");return}const ke=Me.droppableId==="pending"&&je.droppableId==="developing";if(ke&&Ve&&(!Ve.tasks||Ve.tasks.length===0)){c(ee("cannotExecuteEmptyTasks")||"无法执行空任务,请先拆解任务");return}const Ye=[...n];e(rt=>{const st=[...rt];if(Me.droppableId!==je.droppableId)return st.map(Ue=>Ue.id===Ee.draggableId?{...Ue,status:je.droppableId}:Ue).sort((Ue,vt)=>Ue.id===Ee.draggableId?0:vt.id===Ee.draggableId?1:0);const pt=st.filter(Ue=>Ue.status===Me.droppableId),[ut]=pt.splice(Me.index,1);return pt.splice(je.index,0,ut),st.map(Ue=>Ue.status===Me.droppableId&&pt.find(vt=>vt.id===Ue.id)||Ue)});try{await fetch("/api/todos/reorder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source_status:Me.droppableId,source_index:Me.index,destination_status:je.droppableId,destination_index:je.index,todo_id:Ee.draggableId})}),ke&&Ve&&(A(Ve),C(!0),m(!0))}catch(rt){console.error("Failed to reorder todos:",rt),e(Ye),c(ee("failedToSaveChanges"))}},K=()=>{p&&(C(!1),ae(p))},Z=async()=>{if(p){e(Ee=>Ee.map(Me=>Me.id===p.id?{...Me,status:"pending"}:Me));try{await fetch("/api/todos/reorder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source_status:"developing",destination_status:"pending",todo_id:p.id,source_index:0,destination_index:0})})}catch(Ee){console.error("Failed to move task back to pending:",Ee),c(ee("failedToSaveChanges"))}m(!1)}},ae=async Ee=>{b(!0);try{const Me=await fetch(`/api/todos/${Ee.id}/execute-tasks`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!Me.ok)throw new Error("Failed to execute tasks");const je=await Me.json();console.log("Task execution started:",je),e(Ve=>Ve.map(ke=>ke.id===Ee.id?{...ke,status:"developing",updated_at:new Date().toISOString()}:ke)),w===Ee.id&&E(null),D(Ee.id),X(Ee.id),await ne()}catch(Me){console.error("Failed to execute tasks:",Me),c(ee("failedToExecuteTask"))}finally{b(!1),m(!1)}},[te,G]=_.useState(null),X=Ee=>{te&&clearInterval(te);const Me=setInterval(async()=>{try{const je=await fetch(`/api/todos/${Ee}/tasks/status`);if(!je.ok)throw new Error("Failed to fetch task status");const Ve=await je.json();console.log("Task status:",Ve),Y(Ee,Ve);const ke=Ve.tasks.every(rt=>rt.status==="completed"),Ye=Ve.tasks.some(rt=>rt.status==="failed");(ke||Ye)&&(clearInterval(Me),G(null),await ne())}catch(je){console.error("Error polling task status:",je)}},3e3);return G(Me),()=>{clearInterval(Me),G(null)}},Y=(Ee,Me)=>{e(je=>je.map(Ve=>{if(Ve.id===Ee&&Ve.tasks){const ke=Ve.tasks.map((Ye,rt)=>rt<Me.tasks.length?{...Ye,status:Me.tasks[rt].status}:Ye);return{...Ve,tasks:ke}}return Ve}))},ne=async()=>{a(!0),c(null);try{const Ee=await fetch("/api/todos");if(!Ee.ok)throw new Error(ee("failedToFetchTodos"));const Me=await Ee.json();e(Me)}catch(Ee){console.error(ee("failedToFetchTodos"),Ee),c(ee("failedToLoadTodos"))}finally{a(!1)}},le=async()=>{if(r.title)try{const Ee=await fetch("/api/todos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:r.title,priority:r.priority||"P2",tags:G8(r.tags)||[]})});if(!Ee.ok)throw new Error(ee("failedToCreateTodo"));const Me=await Ee.json();e(je=>[...je,Me]),i(!1),s({})}catch(Ee){console.error(ee("failedToCreateTodo"),Ee),c(ee("failedToCreateNewTodo"))}},de=Ee=>{d(Ee),f(!0)},me=async Ee=>{try{const Me={...Ee,tags:G8(Ee.tags)},je=await fetch(`/api/todos/${Ee.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Me)});if(!je.ok)throw new Error(ee("failedToSaveTodo"));const Ve=await je.json();e(ke=>ke.map(Ye=>Ye.id===Ve.id?Ve:Ye))}catch(Me){throw console.error(ee("failedToSaveTodo"),Me),c(ee("failedToSaveTodo")),Me}},_e=async Ee=>{try{if(!(await fetch(`/api/todos/${Ee}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw new Error(ee("failedToDeleteTodo"));e(je=>je.filter(Ve=>Ve.id!==Ee)),w===Ee&&(E(null),I(null)),T===Ee&&D(null)}catch(Me){console.error(ee("failedToDeleteTodo"),Me),c(ee("failedToDeleteTodo"))}},Ce=async Ee=>{try{a(!0);const Me=await fetch(`/api/todos/${Ee}`);if(!Me.ok)throw new Error(ee("failedToFetchTodo"));const je=await Me.json();return e(Ve=>Ve.map(ke=>ke.id===Ee?je:ke)),je}catch(Me){return console.error(ee("failedToFetchTodo"),Me),c(ee("failedToLoadTodo")),null}finally{a(!1)}},Le=async(Ee,Me)=>{if(Ee.stopPropagation(),w===Me.id)E(null),I(null);else{let je=Me;const Ve=await Ce(Me.id);if(Ve&&(je=Ve),F&&$===je.id)I(F),E(je.id);else if(je.tasks&&je.tasks.length>0){const ke={original_task:{title:je.title,description:je.description||""},analysis:je.analysis||"",tasks:je.tasks,dependencies:je.dependencies||[]};I(ke),E(je.id)}}},$e=async(Ee,Me)=>{if(Ee.stopPropagation(),w===Me.id)E(null),I(null);else{let je=Me;const Ve=await Ce(Me.id);if(Ve&&(je=Ve),je.tasks&&je.tasks.length>0){const ke={original_task:{title:je.title,description:je.description||""},analysis:je.analysis||"",tasks:je.tasks,dependencies:je.dependencies||[]};I(ke),E(je.id)}}},We=async Ee=>{E(null),I(null),await Ce(Ee)},ze=(Ee,Me)=>{Ee.tags&&Ee.tags.includes("正在拆解");const je=w===Ee.id;F!==null&&Ee.id;const Ve=Ee.id===M;return Ee.status==="developing"?S.jsxs("div",{className:"todo-actions flex items-center gap-2",children:[Ve?S.jsx(XS,{status:"processing",text:S.jsx("span",{className:"text-blue-400 text-xs",children:"正在拆解..."})}):S.jsx(XS,{status:"processing",text:S.jsx("span",{className:"text-blue-400 text-xs",children:ee("taskRunningStatus")})}),Ee.tasks&&Ee.tasks.length>0&&S.jsx(yn,{type:T===Ee.id?"primary":"text",size:"small",icon:S.jsx(_D,{}),onClick:ke=>{ke.stopPropagation(),D(T===Ee.id?null:Ee.id)},className:"text-gray-400 hover:text-blue-400 p-0 flex items-center justify-center",title:"查看任务状态"}),Ee.tasks&&Ee.tasks.length>0&&S.jsx(yn,{type:"text",size:"small",icon:S.jsx(Dce,{}),onClick:ke=>{ke.stopPropagation(),Le(ke,Ee)},className:`text-gray-400 hover:text-blue-400 p-0 flex items-center justify-center ${je?"bg-blue-900/30":""}`,title:"查看任务拆解结果"}),S.jsx("div",{className:"todo-tags flex gap-1",children:G8(Ee.tags).map(ke=>S.jsx(Sv,{className:"text-xs bg-gray-600 border-none text-gray-300 rounded-full px-2",children:ke},ke))})]}):S.jsxs("div",{className:"todo-actions flex items-center gap-2",children:[S.jsx(yn,{type:"text",size:"small",icon:S.jsx(pf,{}),onClick:ke=>{ke.stopPropagation(),Me(Ee)},className:"text-gray-400 hover:text-blue-400 p-0 flex items-center justify-center"}),(Ee.status==="pending"||Ee.status==="testing"||Ee.status==="done")&&S.jsx(Zx,{title:ee("confirmDeleteTask")||"确定要删除这个任务吗?",okText:ee("yes")||"是",cancelText:ee("no")||"否",onConfirm:ke=>{ke==null||ke.stopPropagation(),_e(Ee.id)},onCancel:ke=>ke==null?void 0:ke.stopPropagation(),children:S.jsx(yn,{type:"text",size:"small",danger:!0,icon:S.jsx(bd,{}),onClick:ke=>ke.stopPropagation(),className:"text-gray-400 hover:text-red-500 p-0 flex items-center justify-center",title:ee("deleteTask")||"删除任务"})}),(Ee.status==="testing"||Ee.status==="done")&&Ee.tasks&&Ee.tasks.length>0&&S.jsx(yn,{type:T===Ee.id?"primary":"text",size:"small",icon:S.jsx(_D,{}),onClick:ke=>{ke.stopPropagation(),D(T===Ee.id?null:Ee.id)},className:"text-gray-400 hover:text-blue-400 p-0 flex items-center justify-center",title:"查看任务状态"}),Ee.tasks&&Ee.tasks.length>0&&S.jsx(yn,{type:"text",size:"small",icon:S.jsx(Dce,{}),onClick:ke=>{ke.stopPropagation(),$e(ke,Ee)},className:`text-gray-400 hover:text-blue-400 p-0 flex items-center justify-center ${je?"bg-blue-900/30":""}`,title:ee(je?"hideTaskSplitResult":"viewTaskSplitResult")}),S.jsx("div",{className:"todo-tags flex gap-1",children:G8(Ee.tags).map(ke=>S.jsx(Sv,{className:"text-xs bg-gray-600 border-none text-gray-300 rounded-full px-2",children:ke},ke))})]})},Be=Ee=>{R(Me=>Me===Ee?null:Ee)};return S.jsxs("div",{className:"todo-container bg-gray-900 p-4",style:{height:"650px"},"data-testid":"todo-panel",children:[l&&S.jsx(uI,{message:l,type:"error",showIcon:!0,closable:!0,onClose:()=>c(null),className:"mb-4"}),S.jsx("div",{className:"todo-header mb-4",children:S.jsx(yn,{type:"primary",icon:S.jsx(hc,{}),onClick:()=>i(!0),className:"bg-blue-600 hover:bg-blue-700 border-none text-sm",children:ee("createNewTask")})}),S.jsxs(fti,{fallbackRender:({error:Ee})=>S.jsx("div",{className:"text-red-500 p-4",children:ee("droppableError",{message:Ee.message})}),children:[S.jsx(wei,{onDragEnd:j,children:S.jsx("div",{className:"todo-board flex gap-4 h-[calc(100%-80px)]",children:o?S.jsx("div",{className:"text-gray-400 text-center p-4",children:ee("loading")}):q.map(Ee=>S.jsx(Ipt,{droppableId:Ee.id,children:(Me,je)=>S.jsxs("div",{...Me.droppableProps,ref:Me.innerRef,className:`todo-column flex-col transition-all duration-300 ${je.isDraggingOver?"border-blue-500":"border-gray-700"} ${O===null?"flex-1":O===Ee.id?"flex w-full":"hidden"} bg-gray-800 rounded-lg p-4 border flex`,children:[S.jsxs("div",{className:"flex justify-between items-center mb-3",children:[S.jsx("h3",{className:"text-gray-300 font-medium",children:Ee.title}),S.jsx(Er,{title:O===Ee.id?ee("restorePanel"):ee("maximizePanel"),children:S.jsx(yn,{type:"text",size:"small",icon:O===Ee.id?S.jsx($3t,{}):S.jsx(iOt,{}),onClick:()=>Be(Ee.id),className:"text-gray-400 hover:text-blue-400"})})]}),S.jsxs("div",{className:"flex-1 overflow-y-auto max-h-[calc(100vh-220px)] pr-1 custom-scrollbar",children:[n.filter(Ve=>Ve.status===Ee.id).map((Ve,ke)=>S.jsxs(Ne.Fragment,{children:[S.jsx(oti,{draggableId:Ve.id,index:ke,children:(Ye,rt)=>S.jsxs("div",{ref:Ye.innerRef,...Ye.draggableProps,...Ye.dragHandleProps,className:`todo-card bg-gray-700 p-3 mb-3 rounded border ${rt.isDragging?"border-blue-500 shadow-lg":Ve.status==="developing"?"border-blue-400":"border-gray-600"} transition-all duration-150`,children:[S.jsxs("div",{className:"todo-card-header flex items-center justify-between mb-2",children:[S.jsx(Sv,{color:Rsi[Ve.priority],className:"border-none text-xs px-2 rounded-full",children:Ve.priority}),ze(Ve,de)]}),S.jsx("div",{className:"todo-title text-gray-200 text-sm mb-1",children:Ve.title}),Ve.dueDate&&S.jsx("div",{className:"todo-due-date text-gray-400 text-xs",children:ee("dueDate",{date:new Date(Ve.dueDate).toLocaleDateString()})}),Ve.status==="developing"&&S.jsxs("div",{className:"todo-execution-status flex items-center gap-1 text-blue-400 text-xs mt-2",children:[S.jsx(_D,{spin:!0}),S.jsx("span",{children:ee("taskExecutingInBackground")})]}),Ve.status==="pending"&&M&&Ve.id===M&&S.jsxs("div",{className:"todo-splitting-status flex items-center gap-1 text-blue-400 text-xs mt-2",children:[S.jsx(_D,{spin:!0}),S.jsx("span",{children:"正在后台运行拆解任务..."})]})]})}),w===Ve.id&&k&&S.jsx(Lsi,{visible:!0,result:k,todoId:Ve.id,onClose:()=>We(Ve.id)}),T===Ve.id&&(Ve.status==="developing"||Ve.status==="testing"||Ve.status==="done")&&S.jsx(Dsi,{todoId:Ve.id,onClose:()=>D(null)})]},Ve.id)),Me.placeholder]})]})},Ee.id))})}),S.jsxs(qs,{title:ee("createNewTask"),open:t,onCancel:()=>i(!1),onOk:le,className:"dark-theme-modal",styles:{content:{backgroundColor:"#1f2937",padding:"20px"},header:{backgroundColor:"#1f2937",borderBottom:"1px solid #374151"},body:{backgroundColor:"#1f2937"}},children:[S.jsx(yi,{placeholder:ee("taskTitlePlaceholder"),className:"custom-input bg-gray-800 border-gray-700 text-gray-200 mb-3",value:r.title,onChange:Ee=>s({...r,title:Ee.target.value})}),S.jsx(qi,{className:"custom-select w-full",placeholder:ee("priorityPlaceholder"),value:r.priority,onChange:Ee=>s({...r,priority:Ee}),options:Msi})]}),S.jsx(Asi,{visible:h,todo:u,onClose:()=>f(!1),onSave:me}),S.jsx(vsi,{visible:g,todo:p,onClose:Z,onConfirm:K,isExecuting:v,confirmMode:y})]})]})},Bsi=({isOpen:n,onClose:e,content:t,format:i,language:r="javascript",title:s="内容预览"})=>{const o=_.useRef(null);return _.useEffect(()=>{const a=c=>{c.key==="Escape"&&n&&e()},l=c=>{o.current&&!o.current.contains(c.target)&&n&&e()};return document.addEventListener("keydown",a),document.addEventListener("mousedown",l),()=>{document.removeEventListener("keydown",a),document.removeEventListener("mousedown",l)}},[n,e]),n?S.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-70",children:S.jsxs("div",{ref:o,className:"bg-gray-900 rounded-lg shadow-xl w-4/5 h-4/5 max-w-6xl flex flex-col",children:[S.jsxs("div",{className:"flex justify-between items-center p-4 border-b border-gray-700",children:[S.jsx("h3",{className:"text-lg font-medium text-white",children:s}),S.jsx("button",{onClick:e,className:"text-gray-400 hover:text-white focus:outline-none",children:S.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]}),S.jsx("div",{className:"flex-1 overflow-auto p-4",children:i==="markdown"?S.jsx("div",{className:"prose prose-invert prose-sm max-w-none",children:S.jsx(z0,{className:"text-gray-200 break-words",components:{code:({className:a,children:l,...c})=>{const u=/language-(\w+)/.exec(a||"");return!u?S.jsx("code",{className:a,...c,children:l}):S.jsx(Yc,{language:u?u[1]:"",style:Tu,PreTag:"div",wrapLines:!0,wrapLongLines:!0,children:String(l).replace(/\n$/,"")})}},children:t})}):S.jsx("div",{className:"h-full",children:S.jsx(_gt,{code:t,language:r,onChange:()=>{}})})})]})}):null},Psi=_.lazy(()=>Yt(()=>import("./HistoryPanel-gJupyfFp.js"),[])),Fsi=({projectName:n,activePanel:e,setActivePanel:t,clipboardContent:i,setClipboardContent:r,previewFiles:s,setPreviewFiles:o,requestId:a,setRequestId:l,selectedFiles:c,onSwitchToAutoMode:u,setSelectedFiles:d})=>{const[h,f]=_.useState("terminal"),[g,m]=_.useState(!1),[p,A]=_.useState(!1),[v,b]=_.useState(""),[y,C]=_.useState("markdown"),[w,E]=_.useState("plaintext"),[k,I]=_.useState("内容预览"),[T,D]=_.useState(null),[O,R]=_.useState(null);_.useEffect(()=>{a&&(R(a),console.log("ExpertModePage: Updated currentEventFileId from requestId:",a))},[a]),_.useEffect(()=>{const F=W=>{!W.target.closest(".tools-dropdown-container")&&g&&m(!1)};return document.addEventListener("mousedown",F),()=>{document.removeEventListener("mousedown",F)}},[g]),_.useEffect(()=>{const F=Gn.subscribe(qn.UI.ACTIVATE_PANEL,W=>{W==="history"&&t("history")});return()=>{F()}},[t]),_.useEffect(()=>{const F=Gn.subscribe(qn.CHAT.NEW_MESSAGE,W=>{var U;if(console.log("ExpertModePage: Received message via eventBus:",W.type),W.type==="ASK_USER"){const H={...W,id:W.id||`msg-${Date.now()}`,timestamp:Date.now()};D(H);try{vgt()}catch{}console.log("ExpertModePage: Set activeAskUserMessage from eventBus")}W.event_file_id&&!O&&(R(W.event_file_id),console.log("ExpertModePage: Set currentEventFileId from message:",W.event_file_id)),(U=W.metadata)!=null&&U.event_file_id&&!O&&(R(W.metadata.event_file_id),console.log("ExpertModePage: Set currentEventFileId from message metadata:",W.metadata.event_file_id))});return()=>{F()}},[O]),_.useEffect(()=>{const F=Gn.subscribe(qn.UI.SHOW_MODAL,W=>{b(W.content),C(W.format),E(W.language||"plaintext"),I(W.title||"内容预览"),A(!0)});return()=>{F()}},[]);const M=async(F,W)=>{if(!W){console.error("Cannot respond to event: No event ID provided");return}if(!O){console.error("Cannot respond to event: No event file ID available");return}(T==null?void 0:T.eventId)===W&&D(null);try{console.log("ExpertModePage: Sending response to event:",{event_id:W,event_file_id:O,response:F});const U=await fetch("/api/auto-command/response",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event_id:W,event_file_id:O,response:F})});if(!U.ok){const H=await U.json();throw new Error(`Failed to send response: ${H.detail||U.statusText}`)}console.log("Response sent successfully to event:",W)}catch(U){console.error("Error sending response to server:",U),Gn.publish(qn.CHAT.NEW_MESSAGE,{type:"ERROR",content:`Failed to send your response to the server: ${U instanceof Error?U.message:String(U)}`})}},B=F=>{F.stopPropagation(),m(!g)};return S.jsxs(S.Fragment,{children:[T&&S.jsx(iQe,{message:T,onResponse:M,onClose:()=>D(null)}),S.jsxs(kI,{className:"flex-1 flex",sizes:[25,75],minSize:[180,400],gutterSize:3,snapOffset:20,children:[S.jsx("div",{className:"border-r border-gray-700 flex flex-col",children:S.jsx(lQn,{setPreviewFiles:o,setActivePanel:t,setClipboardContent:r,clipboardContent:i,setRequestId:l,projectName:n,setSelectedFiles:d})}),S.jsx("div",{className:"relative flex flex-col flex-grow h-full w-full overflow-hidden",children:S.jsx("div",{className:"absolute inset-0",children:S.jsxs(kI,{direction:"vertical",sizes:[75,25],minSize:[180,80],gutterSize:5,snapOffset:20,dragInterval:1,cursor:"row-resize",className:"split-vertical",onDragEnd:()=>{window.dispatchEvent(new Event("resize"))},children:[S.jsxs("div",{className:"flex flex-col overflow-hidden",children:[S.jsx("div",{className:"bg-gray-800 p-2 border-b border-gray-700",children:S.jsxs("div",{className:"flex space-x-2",children:[S.jsxs("button",{className:`px-2 py-1 rounded text-xs font-medium transition-all duration-300
|
1969
|
+
`,D=`split_task ${JSON.stringify(T)}`;if(e)try{b(e.id),t()}catch(M){console.error("Failed to update task status:",M),Tt.warning(ee("failedToSaveTodo"))}else t();const O=M=>{var B,F;if(f(M)){console.log("Task split result:",M);let W=0,U=null;try{if(U=g(M),U&&(y(U),console.log("Split result saved to TodoPanel:",U),W=U.tasks_count||((B=U.tasks)==null?void 0:B.length)||0,e&&e.id)){const H=((F=U.tasks)==null?void 0:F.map((z,q)=>({id:q,title:z.title,description:z.description||null,references:Array.isArray(z.references)?z.references:[],steps:Array.isArray(z.steps)?z.steps:[],acceptance_criteria:Array.isArray(z.acceptance_criteria)?z.acceptance_criteria:[],priority:z.priority||e.priority,estimate:z.estimate||null})))||[],$={...e,tasks:H,status:"developing",tags:[...e.tags||[]].filter(z=>z!=="正在拆解").concat(["已拆解"]),analysis:U.analysis||null,dependencies:U.dependencies||null};fetch(`/api/todos/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify($)}).then(z=>{if(!z.ok)throw new Error(ee("failedToSaveTodo"));return z.json()}).then(()=>{console.log("Task split result saved to backend successfully"),C(!0),w(e.id),b(null);const z={...e,tags:[...e.tags||[]].filter(q=>q!=="正在拆解").concat(["已拆解"]),analysis:U.analysis||null,dependencies:U.dependencies||null,tasks:H};i(z)}).catch(z=>{console.error("Failed to save split result to backend:",z),Tt.warning(ee("failedToSaveTodo"))})}}catch(H){console.error("Error parsing task result:",H)}Tt.success(ee("taskSplitSuccess",{count:String(W)}))}},R=M=>{console.log("Task complete event received, has error:",M),d(!1),M&&Tt.error(ee("failedToSplitTask")),b(null),sc.removeListener("message",O),sc.removeListener("taskComplete",R),h.current=!1};sc.on("message",O),sc.on("taskComplete",R),h.current=!0,await sc.executeCommand(D)}catch(T){console.error(ee("failedToSplitTask"),T),Tt.error(ee("failedToSplitTask")),d(!1),t(),h.current&&(sc.removeListener("message",function(){}),sc.removeListener("taskComplete",function(){}),h.current=!1)}},k=[{value:"P0",label:ee("priorityP0")},{value:"P1",label:ee("priorityP1")},{value:"P2",label:ee("priorityP2")},{value:"P3",label:ee("priorityP3")}];return S.jsxs(qs,{title:ee("editTodoTitle"),open:n,onCancel:t,footer:[S.jsx(yn,{type:"default",icon:S.jsx(l5t,{}),loading:u,onClick:E,className:"bg-purple-700 hover:bg-purple-800 border-none text-white",children:ee("splitTask")},"split"),S.jsx(yn,{onClick:t,children:ee("cancel")},"cancel"),S.jsx(yn,{type:"primary",loading:o,onClick:m,className:"bg-blue-600 hover:bg-blue-700 border-none",children:ee("save")},"save")],className:"dark-theme-modal",styles:{content:{backgroundColor:"#1f2937",padding:"20px"},header:{backgroundColor:"#1f2937",borderBottom:"1px solid #374151"},body:{backgroundColor:"#1f2937"}},width:700,children:[S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{className:"block text-gray-300 mb-1",children:ee("todoTitle")}),S.jsx(yi,{value:r.title,onChange:T=>s({...r,title:T.target.value}),placeholder:ee("todoTitlePlaceholder"),className:"custom-input bg-gray-800 border-gray-700 text-gray-200"})]}),S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{className:"block text-gray-300 mb-1",children:ee("todoDescription")}),S.jsx(msi,{value:r.description,onChange:T=>s({...r,description:T.target.value}),placeholder:ee("todoDescriptionPlaceholder"),rows:6,className:"custom-input bg-gray-800 border-gray-700 text-gray-200"})]}),S.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{className:"block text-gray-300 mb-1",children:ee("priority")}),S.jsx(qi,{value:r.priority,onChange:T=>s({...r,priority:T}),options:k,className:"custom-select w-full"})]}),S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{className:"block text-gray-300 mb-1",children:ee("dueDate")}),S.jsx(IT,{value:r.dueDate?li(r.dueDate):void 0,onChange:T=>s({...r,dueDate:T?T.toISOString():void 0}),className:"custom-input bg-gray-800 border-gray-700 text-gray-200 w-full"})]})]}),S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{className:"block text-gray-300 mb-1",children:ee("tags")}),S.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:(I=r.tags)==null?void 0:I.map(T=>S.jsx(Sv,{closable:!0,onClose:()=>A(T),className:"text-xs bg-gray-700 border-none text-gray-300 rounded-full px-3 py-1",children:T},T))}),S.jsxs("div",{className:"flex",children:[S.jsx(yi,{value:l,onChange:T=>c(T.target.value),placeholder:ee("addTagPlaceholder"),className:"custom-input bg-gray-800 border-gray-700 text-gray-200 flex-1 mr-2",onPressEnter:p}),S.jsx(yn,{icon:S.jsx(hc,{}),onClick:p,className:"bg-gray-700 hover:bg-gray-600 border-none text-gray-200",children:ee("addTag")})]})]})]})},vsi=({visible:n,todo:e,onClose:t,onConfirm:i,isExecuting:r,confirmMode:s=!0})=>{const o=()=>r?S.jsx(_h,{size:"large"}):s?S.jsx(ex,{style:{color:"#faad14"}}):S.jsx(JOt,{style:{color:"#1890ff"}}),a=()=>ee(r?"taskExecutingMessage":s?"taskConfirmExecuteMessage":"taskAutoExecuteMessage"),l=()=>!r&&s?ee("taskConfirmExecuteDescription"):r?null:ee("taskAutoExecuteDescription"),c=()=>{s?t():document.dispatchEvent(new CustomEvent("closeExecuteModal"))},u=()=>r?[S.jsx(yn,{onClick:c,disabled:!0,className:"bg-gray-700 border-none text-gray-400",children:ee("close")},"close")]:s?[S.jsx(yn,{onClick:t,className:"bg-gray-700 hover:bg-gray-600 border-none text-gray-200",children:ee("cancel")},"cancel"),S.jsx(yn,{type:"primary",onClick:i,className:"bg-blue-600 hover:bg-blue-700 border-none",children:ee("confirm")},"confirm")]:[S.jsx(yn,{onClick:c,className:"bg-gray-700 hover:bg-gray-600 border-none text-gray-200",children:ee("close")},"close")];return S.jsxs(qs,{title:ee("taskAutoExecuteTitle"),open:n,onCancel:r?void 0:c,footer:u(),closable:!r,maskClosable:!r,className:"dark-theme-modal",styles:{content:{backgroundColor:"#1f2937",padding:"20px"},header:{backgroundColor:"#1f2937",borderBottom:"1px solid #374151"},body:{backgroundColor:"#1f2937"}},width:500,children:[S.jsx(ZV,{icon:o(),title:S.jsx("span",{className:"text-gray-200",children:e==null?void 0:e.title}),subTitle:S.jsx("span",{className:"text-gray-400",children:a()}),className:"bg-gray-800 rounded-lg p-4 border border-gray-700"}),l()&&S.jsx("div",{className:"mt-4 text-gray-400 text-sm",children:S.jsx("p",{children:l()})})]})},{Panel:fui}=sw,{Paragraph:bsi}=lh,_si={background:"#1e293b",borderColor:"#334155",color:"#f8fafc",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},ysi=({analysis:n,updateAnalysis:e,onBlur:t})=>S.jsx(o0,{bordered:!1,style:_si,className:"rounded-lg overflow-hidden",children:S.jsx(bsi,{style:{color:"#cbd5e1",lineHeight:1.6,fontSize:"14px"},editable:{onChange:e,tooltip:"Click to edit analysis",icon:S.jsx(pf,{style:{color:"#0ea5e9"}}),onEnd:t},children:n})}),{Panel:gui}=sw,{Text:V8,Paragraph:Csi}=lh,{TextArea:pui}=yi,wsi={background:"#1e293b",borderColor:"#334155",color:"#f8fafc",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},Ssi=({tasks:n,tasksCount:e,updateTaskData:t,updateArrayField:i,saveData:r,parsedResult:s,setParsedResult:o,addSubTask:a,deleteSubTask:l,onTaskDataBlur:c,onArrayFieldBlur:u})=>{const d=()=>a?S.jsx("div",{className:"flex justify-end mb-4",children:S.jsx(yn,{type:"primary",icon:S.jsx(hc,{}),onClick:a,style:{backgroundColor:"#0ea5e9"},children:"添加子任务"})}):null,h=()=>S.jsx(yu,{dataSource:n,itemLayout:"vertical",split:!1,className:"space-y-4",renderItem:(m,p)=>S.jsx(yu.Item,{className:"p-0",children:S.jsxs(o0,{bordered:!1,className:"rounded-lg overflow-hidden transition-all duration-300 hover:shadow-xl",style:wsi,title:S.jsxs("div",{className:"flex justify-between items-center py-1",children:[S.jsxs("div",{className:"flex items-center",children:[S.jsx(XS,{count:m.id!==void 0?m.id:p,style:{backgroundColor:"#0ea5e9",marginRight:"12px",boxShadow:"0 0 0 2px rgba(14, 165, 233, 0.2)"}}),S.jsx(V8,{style:{color:"#f8fafc",fontWeight:600,fontSize:"15px"},editable:{onChange:A=>t(p,"title",A),tooltip:"Click to edit title",icon:S.jsx(pf,{style:{color:"#0ea5e9"}}),onEnd:c},children:m.title})]}),S.jsxs("div",{className:"flex items-center space-x-2",children:[l&&S.jsx(Er,{title:"删除此子任务",children:S.jsx(yn,{type:"text",danger:!0,icon:S.jsx(bd,{}),onClick:A=>{A.stopPropagation(),l(p)},size:"small"})}),S.jsx(Er,{title:"Click to change priority",children:S.jsx(qi,{value:m.priority||"P2",style:{width:70},bordered:!1,dropdownStyle:{backgroundColor:"#1e293b",color:"#f8fafc"},onChange:A=>t(p,"priority",A),onBlur:c,options:[{value:"P0",label:"P0"},{value:"P1",label:"P1"},{value:"P2",label:"P2"},{value:"P3",label:"P3"}],suffixIcon:null,className:"priority-select"})}),S.jsx(Er,{title:"Click to edit estimate",children:S.jsx(yi,{prefix:S.jsx(KV,{style:{color:"#0ea5e9"}}),value:m.estimate||"",onChange:A=>t(p,"estimate",A.target.value),onBlur:c,style:{width:100,backgroundColor:"#334155",color:"#e2e8f0",border:"none",borderRadius:"4px",padding:"0 8px"},size:"small"})})]})]}),headStyle:{backgroundColor:"#0f172a",borderBottom:"1px solid #334155",padding:"12px 16px"},bodyStyle:{padding:"16px"},children:[S.jsx(Csi,{style:{color:"#cbd5e1",lineHeight:1.6,fontSize:"14px",marginBottom:"16px"},editable:{onChange:A=>t(p,"description",A),tooltip:"Click to edit description",icon:S.jsx(pf,{style:{color:"#0ea5e9"}}),onEnd:c},children:m.description}),m.references&&m.references.length>0&&S.jsxs("div",{className:"mb-5",children:[S.jsxs("div",{className:"flex items-center mb-2",children:[S.jsx(fKe,{style:{color:"#0ea5e9",marginRight:"8px"}}),S.jsx(V8,{style:{color:"#0ea5e9",fontWeight:500},children:ee("references")})]}),S.jsx("div",{className:"flex flex-wrap gap-2",children:m.references.map((A,v)=>S.jsx(yi,{value:A,onChange:b=>i(p,"references",v,b.target.value),onBlur:u,style:{backgroundColor:"#1e293b",color:"#94a3b8",border:"1px solid #334155",borderRadius:"4px",padding:"2px 8px",width:"auto",marginRight:"8px",marginBottom:"8px"},size:"small"},v))})]}),S.jsxs("div",{className:"mb-5",children:[S.jsxs("div",{className:"flex items-center justify-between mb-3",children:[S.jsxs("div",{className:"flex items-center",children:[S.jsx(gKe,{style:{color:"#0ea5e9",marginRight:"8px"}}),S.jsx(V8,{style:{color:"#0ea5e9",fontWeight:500},children:ee("implementationSteps")})]}),S.jsx(yn,{type:"text",icon:S.jsx(hc,{}),size:"small",onClick:()=>{const A=[...m.steps||[],""],v=[...s.tasks];v[p]={...m,steps:A};const b={...s,tasks:v};o(b),r(b)},style:{color:"#0ea5e9"}})]}),S.jsx("div",{className:"mb-2",style:{color:"#cbd5e1",background:"#0f172a",padding:"12px",borderRadius:"6px"},children:m.steps&&m.steps.length>0&&m.steps.map((A,v)=>S.jsxs("div",{className:"flex items-start mb-3",children:[S.jsx("div",{className:"mr-3 mt-1",children:S.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:"#0ea5e9",display:"inline-block"}})}),S.jsxs("div",{className:"flex-1 relative",children:[S.jsx(yi.TextArea,{value:A,onChange:b=>i(p,"steps",v,b.target.value),onBlur:u,style:{backgroundColor:"transparent",color:"#e2e8f0",border:"1px solid #334155",borderRadius:"4px",width:"100%",resize:"vertical",minHeight:"60px"},autoSize:{minRows:2,maxRows:6}}),S.jsx(yn,{type:"text",danger:!0,icon:S.jsx(bd,{}),size:"small",onClick:()=>{const b=[...m.steps];b.splice(v,1);const y=[...s.tasks];y[p]={...m,steps:b};const C={...s,tasks:y};o(C),r(C)},style:{position:"absolute",right:"-30px",top:"0"}})]})]},v))})]}),m.acceptance_criteria&&m.acceptance_criteria.length>0&&S.jsxs("div",{className:"mb-2",children:[S.jsxs("div",{className:"flex items-center mb-3",children:[S.jsx(uKe,{style:{color:"#0ea5e9",marginRight:"8px"}}),S.jsx(V8,{style:{color:"#0ea5e9",fontWeight:500},children:ee("acceptanceCriteria")})]}),S.jsx("div",{className:"space-y-2",children:m.acceptance_criteria.map((A,v)=>S.jsxs("div",{style:{color:"#e2e8f0",border:"none",background:"#0f172a",padding:"8px 12px",borderRadius:"4px",display:"flex",alignItems:"flex-start"},children:[S.jsx(XS,{count:v+1,size:"small",style:{backgroundColor:"#0ea5e9",marginRight:"8px",marginTop:"6px"}}),S.jsx(yi.TextArea,{value:A,onChange:b=>i(p,"acceptance_criteria",v,b.target.value),style:{backgroundColor:"transparent",color:"#e2e8f0",border:"none",width:"100%",resize:"vertical"},autoSize:{minRows:1,maxRows:4}})]},v))})]})]})})}),f=()=>S.jsxs("div",{className:"flex flex-col items-center",children:[S.jsx(ia,{image:ia.PRESENTED_IMAGE_SIMPLE,description:S.jsx("span",{className:"text-gray-400",children:ee("noSubTasks")})}),a&&S.jsx(yn,{type:"primary",icon:S.jsx(hc,{}),onClick:a,style:{marginTop:"16px",backgroundColor:"#0ea5e9"},children:"添加子任务"})]}),g=()=>n&&n.length>0?S.jsxs("div",{children:[d(),h()]}):f();return S.jsx("div",{children:g()})},{Panel:mui}=sw,{Text:WUe}=lh,xsi={background:"#1e293b",borderColor:"#334155",color:"#f8fafc",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},Esi=({dependencies:n,updateDependency:e,updateDependencyItem:t,onDependencyBlur:i,onDependencyItemBlur:r})=>!n||n.length===0?null:S.jsx("div",{children:S.jsx(yu,{dataSource:n,split:!1,className:"space-y-4",renderItem:(s,o)=>S.jsx(yu.Item,{className:"p-0",children:S.jsx(o0,{bordered:!1,className:"rounded-lg overflow-hidden transition-all duration-300 hover:shadow-xl",style:xsi,bodyStyle:{padding:"16px"},children:S.jsxs("div",{children:[S.jsxs("div",{className:"flex items-center mb-3",children:[S.jsx(XS,{status:"processing",color:"#0ea5e9",style:{marginRight:"8px"}}),S.jsx(WUe,{style:{color:"#f8fafc",fontWeight:600},editable:{onChange:a=>e(o,"task",a),tooltip:"Click to edit task",icon:S.jsx(pf,{style:{color:"#0ea5e9"}}),onEnd:i},children:s.task})]}),S.jsxs(WUe,{style:{color:"#94a3b8",display:"block",marginBottom:"8px"},children:[ee("dependsOn"),":"]}),S.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:s.depends_on.map((a,l)=>S.jsx(yi,{value:a,onChange:c=>t(o,l,c.target.value),onBlur:r,style:{backgroundColor:"#0f172a",color:"#0ea5e9",border:"1px solid #0ea5e9",borderRadius:"4px",padding:"2px 8px",width:"auto",marginRight:"8px",marginBottom:"8px"},size:"small"},l))})]})})})})}),{Title:ksi}=lh,Lsi=({visible:n,result:e,todoId:t,onClose:i})=>{var U,H;const[r,s]=_.useState(["1"]),[o,a]=_.useState(!0),[l,c]=_.useState(null),[u,d]=_.useState(null),[h,f]=_.useState(!1),[g,m]=_.useState(!1);_.useEffect(()=>{if(a(!0),c(null),e)try{let $;typeof e=="string"?$=Tpt.extract(e)||{}:$=e,$.tasks&&Array.isArray($.tasks)&&($.tasks=$.tasks.map((z,q)=>({...z,id:z.id!==void 0?z.id:q}))),d($)}catch($){console.error("Error parsing result:",$),c("Failed to parse task split result")}else d(null);a(!1)},[e]);const p=async $=>{var z,q,j;if(!$){console.log("saveData: No data provided to save");return}console.log("saveData: Starting save operation",{updatedResult:$}),f(!0),m(!1);try{if(!t)throw console.error("saveData: No todoId found in result object"),new Error("No todoId found in result");const K={tasks:$.tasks.map(ae=>({id:ae.id,title:ae.title,description:ae.description,references:ae.references,steps:ae.steps,acceptance_criteria:ae.acceptance_criteria,priority:ae.priority,estimate:ae.estimate,status:ae.status||"pending"})),analysis:$.analysis,dependencies:$.dependencies};console.log("saveData: Prepared update data",{updateData:K}),console.log(`saveData: Sending PUT request to /api/todos/${t}`);const Z=await Hr.put(`/api/todos/${t}`,K);if(console.log("saveData: Received response",{status:Z.status,statusText:Z.statusText,data:Z.data}),Z.status!==200)throw console.error("saveData: API returned non-200 status",{status:Z.status,statusText:Z.statusText}),new Error(`Failed to save changes: ${Z.statusText}`);console.log("saveData: Changes saved successfully"),Tt.success("Changes saved successfully")}catch(K){console.error("saveData: Error saving changes:",K),Hr.isAxiosError(K)&&console.error("saveData: Axios error details:",{status:(z=K.response)==null?void 0:z.status,statusText:(q=K.response)==null?void 0:q.statusText,data:(j=K.response)==null?void 0:j.data,message:K.message}),Tt.error(`Failed to save changes: ${K instanceof Error?K.message:"Unknown error"}`)}finally{console.log("saveData: Operation complete"),f(!1)}},A=($,z,q)=>{if(!u)return;const j={...u},K=[...j.tasks];K[$]={...K[$],[z]:q},j.tasks=K,d(j),m(!0)},v=()=>{g&&u&&p(u)},b=($,z,q)=>{A($,z,q)},y=($,z,q,j)=>{if(!u)return;const K={...u},Z=[...K.tasks],ae=[...Z[$][z]];ae[q]=j,Z[$]={...Z[$],[z]:ae},K.tasks=Z,d(K),m(!0)},C=()=>{g&&u&&p(u)},w=($,z,q,j)=>{y($,z,q,j)},E=$=>{if(!u)return;const z={...u};z.analysis=$,d(z),m(!0)},k=()=>{g&&u&&p(u)},I=$=>{E($)},T=($,z,q)=>{if(!u||!u.dependencies)return;const j={...u},K=[...j.dependencies];z==="task"?K[$]={...K[$],task:q}:z==="depends_on"&&(K[$]={...K[$],depends_on:q}),j.dependencies=K,d(j),m(!0)},D=()=>{g&&u&&p(u)},O=($,z,q)=>{T($,z,q)},R=($,z,q)=>{if(!u||!u.dependencies)return;const j={...u},K=[...j.dependencies],Z=[...K[$].depends_on];Z[z]=q,K[$]={...K[$],depends_on:Z},j.dependencies=K,d(j),m(!0)},M=()=>{g&&u&&p(u)},B=($,z,q)=>{R($,z,q)},F=()=>{if(!u)return;const $={...u},z=[...$.tasks],q={id:z.length+1,title:`新任务 ${z.length+1}`,description:"",references:[],steps:[],acceptance_criteria:[],priority:"P2",estimate:"1d"};z.push(q),$.tasks=z,$.tasks_count=z.length,d($),p($),Tt.success("新子任务添加成功")},W=$=>{if(!u)return;const z={...u},q=[...z.tasks];q.splice($,1),q.forEach((j,K)=>{j.id=K+1}),z.tasks=q,z.tasks_count=q.length,z.dependencies&&z.dependencies.length>0&&(z.dependencies=z.dependencies.filter(j=>j.task!==`Task ${$+1}`&&!j.depends_on.includes(`Task ${$+1}`)),z.dependencies.forEach(j=>{const K=j.task.match(/Task (\d+)/);if(K){const Z=parseInt(K[1]);Z>$+1&&(j.task=`Task ${Z-1}`)}j.depends_on=j.depends_on.map(Z=>{const ae=Z.match(/Task (\d+)/);if(ae){const te=parseInt(ae[1]);if(te>$+1)return`Task ${te-1}`}return Z})})),d(z),p(z),Tt.success("子任务删除成功")};return n?o?S.jsx("div",{className:"task-split-result-view bg-slate-900 rounded-xl p-6 mb-4 shadow-lg",children:S.jsxs("div",{className:"text-center py-8",children:[S.jsx("div",{className:"inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-sky-500 border-r-transparent"}),S.jsx("p",{className:"text-sky-400 mt-4 font-medium",children:ee("loading")})]})}):l||!u?S.jsx("div",{className:"task-split-result-view bg-slate-900 rounded-xl p-6 mb-4 shadow-lg",children:S.jsx(uI,{message:ee("errorTitle"),description:l||ee("noSplitResultData"),type:"error",showIcon:!0,style:{background:"#450a0a",borderColor:"#b91c1c",borderRadius:"8px"}})}):S.jsxs("div",{className:"task-split-result-view bg-slate-900 rounded-xl p-6 mb-4 animate-fadeIn shadow-lg",children:[S.jsxs("div",{className:"flex items-center justify-between mb-6",children:[S.jsx(ksi,{level:4,style:{color:"#f8fafc",margin:0,fontWeight:600},children:ee("taskSplitResultTitle")}),S.jsxs("div",{className:"flex items-center",children:[h&&S.jsx("span",{style:{color:"#60a5fa",marginRight:"10px",fontSize:"14px"},children:"Saving changes..."}),g&&!h&&S.jsx("span",{style:{color:"#fbbf24",marginRight:"10px",fontSize:"14px"},children:"Unsaved changes"}),S.jsx(Er,{title:ee("taskSplitResultHelp")||"Task breakdown and analysis",children:S.jsx(hKe,{style:{color:"#60a5fa",fontSize:"18px"}})}),i&&S.jsx(yn,{type:"text",icon:S.jsx(nm,{}),onClick:()=>{g&&u?p(u).then(()=>{i()}):i()},style:{marginLeft:"8px",color:"#94a3b8"},size:"small"})]})]}),S.jsxs(sw,{activeKey:r,onChange:$=>s($),expandIcon:({isActive:$})=>S.jsx(S3t,{rotate:$?90:0,style:{color:"#0ea5e9"}}),className:"bg-transparent border-0 shadow-none",ghost:!0,children:[S.jsx(sw.Panel,{header:S.jsxs("div",{style:{background:"#0f172a",borderRadius:"6px",padding:"8px 12px",marginBottom:"8px",borderLeft:"3px solid #0ea5e9"},className:"flex items-center",children:[S.jsx(gKe,{style:{color:"#0ea5e9",marginRight:"8px"}}),S.jsx("span",{style:{color:"#f8fafc",fontWeight:500},children:ee("taskAnalysis")})]}),className:"mb-4",children:S.jsx(ysi,{analysis:u.analysis,updateAnalysis:I,onBlur:k})},"2"),S.jsx(sw.Panel,{header:S.jsxs("div",{style:{background:"#0f172a",borderRadius:"6px",padding:"8px 12px",marginBottom:"8px",borderLeft:"3px solid #0ea5e9"},className:"flex items-center",children:[S.jsx(h3t,{style:{color:"#0ea5e9",marginRight:"8px"}}),S.jsxs("span",{style:{color:"#f8fafc",fontWeight:500},children:[ee("subTasks"),S.jsx(XS,{count:u.tasks_count||((U=u.tasks)==null?void 0:U.length)||0,style:{backgroundColor:"#0ea5e9",marginLeft:"8px"}})]})]}),className:"mb-4",children:S.jsx(Ssi,{tasks:u.tasks,tasksCount:u.tasks_count||((H=u.tasks)==null?void 0:H.length)||0,updateTaskData:b,updateArrayField:w,saveData:p,parsedResult:u,setParsedResult:d,addSubTask:F,deleteSubTask:W,onTaskDataBlur:v,onArrayFieldBlur:C})},"3"),u.dependencies&&u.dependencies.length>0&&S.jsx(sw.Panel,{header:S.jsxs("div",{style:{background:"#0f172a",borderRadius:"6px",padding:"8px 12px",marginBottom:"8px",borderLeft:"3px solid #0ea5e9"},className:"flex items-center",children:[S.jsx(fKe,{style:{color:"#0ea5e9",marginRight:"8px"}}),S.jsx("span",{style:{color:"#f8fafc",fontWeight:500},children:ee("taskDependencies")})]}),className:"mb-4",children:S.jsx(Esi,{dependencies:u.dependencies,updateDependency:O,updateDependencyItem:B,onDependencyBlur:D,onDependencyItemBlur:M})},"4")]})]}):null},{Title:Isi,Text:q8}=lh,Tsi=n=>{switch(n){case"completed":return S.jsx(uKe,{style:{color:"#52c41a"}});case"failed":return S.jsx(dKe,{style:{color:"#f5222d"}});case"executing":return S.jsx(_D,{spin:!0,style:{color:"#3b82f6"}});default:return S.jsx(KV,{style:{color:"#faad14"}})}},Nsi=n=>{switch(n){case"completed":return"success";case"failed":return"error";case"executing":return"blue";default:return"warning"}},Dsi=({todoId:n,onClose:e})=>{const[t,i]=_.useState(null),[r,s]=_.useState(!0),[o,a]=_.useState(null),[l,c]=_.useState(null),u=f=>{if(!f||f.length===0)return 0;const g=f.filter(m=>m.status==="completed").length;return Math.round(g/f.length*100)},d=async()=>{try{const f=await Hr.get(`/api/todos/${n}/tasks/status`);i(f.data),s(!1);const g=f.data.tasks.every(p=>p.status==="completed"),m=f.data.tasks.some(p=>p.status==="failed");(g||m)&&l&&(clearInterval(l),c(null))}catch(f){console.error("Error fetching task status:",f),a("Failed to fetch task status"),s(!1)}};if(_.useEffect(()=>{d();const f=setInterval(d,3e3);return c(f),()=>{l&&clearInterval(l)}},[n]),r)return S.jsx(o0,{className:"task-status-card",headStyle:{backgroundColor:"#2d2d2d",borderBottom:"1px solid #374151"},bodyStyle:{backgroundColor:"#2d2d2d"},children:S.jsxs("div",{className:"task-status-loading",children:[S.jsx(_h,{size:"large"}),S.jsx(q8,{style:{color:"#e5e7eb"},children:"加载任务状态..."})]})});if(o)return S.jsx(o0,{className:"task-status-card",headStyle:{backgroundColor:"#2d2d2d",borderBottom:"1px solid #374151"},bodyStyle:{backgroundColor:"#2d2d2d"},children:S.jsx(uI,{message:"Error",description:o,type:"error",showIcon:!0})});if(!t||!t.tasks||t.tasks.length===0)return S.jsx(o0,{className:"task-status-card",headStyle:{backgroundColor:"#2d2d2d",borderBottom:"1px solid #374151"},bodyStyle:{backgroundColor:"#2d2d2d"},children:S.jsx(uI,{message:"No Tasks",description:"No tasks found for this todo item.",type:"info",showIcon:!0})});const h=u(t.tasks);return S.jsxs(o0,{className:"task-status-card",title:S.jsxs("div",{className:"task-status-header",children:[S.jsx(Isi,{level:4,style:{color:"#e5e7eb"},children:"任务执行状态"}),S.jsx(cKe,{type:"circle",percent:h,width:60,strokeColor:"#3b82f6"})]}),headStyle:{backgroundColor:"#2d2d2d",borderBottom:"1px solid #374151"},bodyStyle:{backgroundColor:"#2d2d2d"},children:[S.jsx(yu,{itemLayout:"horizontal",dataSource:t.tasks,renderItem:(f,g)=>S.jsx(yu.Item,{children:S.jsx(yu.Item.Meta,{avatar:Tsi(f.status),title:S.jsxs(JS,{children:[S.jsx(q8,{strong:!0,style:{color:"#e5e7eb"},children:`Task ${g+1}: ${f.title}`}),S.jsx(Sv,{color:Nsi(f.status),children:f.status==="completed"?"已完成":f.status==="failed"?"失败":f.status==="executing"?"执行中":"等待中"})]}),description:S.jsx(q8,{style:{color:"#9ca3af"},children:f.event_file_id?`ID: ${f.event_file_id}`:""})})})}),S.jsx(xGe,{style:{borderColor:"#374151"}}),S.jsx("div",{className:"task-status-footer",children:S.jsx(q8,{style:{color:"#9ca3af"},children:h===100?"所有任务已完成":`${t.tasks.filter(f=>f.status==="completed").length} / ${t.tasks.length} 任务完成`})})]})},Rsi={P0:"red",P1:"orange",P2:"blue",P3:"gray"},Msi=[{value:"P0",label:ee("priorityP0")},{value:"P1",label:ee("priorityP1")},{value:"P2",label:ee("priorityP2")},{value:"P3",label:ee("priorityP3")}],G8=(n=[])=>(n||[]).filter((t,i,r)=>r.indexOf(t)===i),Osi=()=>{const[n,e]=_.useState([]),[t,i]=_.useState(!1),[r,s]=_.useState({}),[o,a]=_.useState(!1),[l,c]=_.useState(null),[u,d]=_.useState(null),[h,f]=_.useState(!1),[g,m]=_.useState(!1),[p,A]=_.useState(null),[v,b]=_.useState(!1),[y,C]=_.useState(!0),[w,E]=_.useState(null),[k,I]=_.useState(null),[T,D]=_.useState(null),[O,R]=_.useState(null),{splittingTodoId:M,setSplittingTodoId:B,lastSplitResult:F,setLastSplitResult:W,splitCompleted:U,setSplitCompleted:H,lastSplitTodoId:$,setLastSplitTodoId:z}=Dpt();_.useEffect(()=>{ne();const Ee=()=>{m(!1)};return document.addEventListener("closeExecuteModal",Ee),()=>{document.removeEventListener("closeExecuteModal",Ee)}},[]),_.useEffect(()=>{U&&$&&F&&(ne(),I(F),E($),H(!1))},[U,$,F,H]);const q=[{id:"pending",title:ee("statusPending")},{id:"developing",title:ee("statusDeveloping")},{id:"testing",title:ee("statusTesting")},{id:"done",title:ee("statusDone")}],j=async Ee=>{const{source:Me,destination:je}=Ee;if(!je)return;const Ve=n.find(rt=>rt.id===Ee.draggableId);if(Ve&&(Me.droppableId==="testing"||Me.droppableId==="done")&&(je.droppableId==="pending"||je.droppableId==="developing")){c("测试中或已完成的任务不能移动到待办或开发中状态");return}const ke=Me.droppableId==="pending"&&je.droppableId==="developing";if(ke&&Ve&&(!Ve.tasks||Ve.tasks.length===0)){c(ee("cannotExecuteEmptyTasks")||"无法执行空任务,请先拆解任务");return}const Ye=[...n];e(rt=>{const st=[...rt];if(Me.droppableId!==je.droppableId)return st.map(Ue=>Ue.id===Ee.draggableId?{...Ue,status:je.droppableId}:Ue).sort((Ue,vt)=>Ue.id===Ee.draggableId?0:vt.id===Ee.draggableId?1:0);const pt=st.filter(Ue=>Ue.status===Me.droppableId),[ut]=pt.splice(Me.index,1);return pt.splice(je.index,0,ut),st.map(Ue=>Ue.status===Me.droppableId&&pt.find(vt=>vt.id===Ue.id)||Ue)});try{await fetch("/api/todos/reorder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source_status:Me.droppableId,source_index:Me.index,destination_status:je.droppableId,destination_index:je.index,todo_id:Ee.draggableId})}),ke&&Ve&&(A(Ve),C(!0),m(!0))}catch(rt){console.error("Failed to reorder todos:",rt),e(Ye),c(ee("failedToSaveChanges"))}},K=()=>{p&&(C(!1),ae(p))},Z=async()=>{if(p){e(Ee=>Ee.map(Me=>Me.id===p.id?{...Me,status:"pending"}:Me));try{await fetch("/api/todos/reorder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source_status:"developing",destination_status:"pending",todo_id:p.id,source_index:0,destination_index:0})})}catch(Ee){console.error("Failed to move task back to pending:",Ee),c(ee("failedToSaveChanges"))}m(!1)}},ae=async Ee=>{b(!0);try{const Me=await fetch(`/api/todos/${Ee.id}/execute-tasks`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!Me.ok)throw new Error("Failed to execute tasks");const je=await Me.json();console.log("Task execution started:",je),e(Ve=>Ve.map(ke=>ke.id===Ee.id?{...ke,status:"developing",updated_at:new Date().toISOString()}:ke)),w===Ee.id&&E(null),D(Ee.id),X(Ee.id),await ne()}catch(Me){console.error("Failed to execute tasks:",Me),c(ee("failedToExecuteTask"))}finally{b(!1),m(!1)}},[te,G]=_.useState(null),X=Ee=>{te&&clearInterval(te);const Me=setInterval(async()=>{try{const je=await fetch(`/api/todos/${Ee}/tasks/status`);if(!je.ok)throw new Error("Failed to fetch task status");const Ve=await je.json();console.log("Task status:",Ve),Y(Ee,Ve);const ke=Ve.tasks.every(rt=>rt.status==="completed"),Ye=Ve.tasks.some(rt=>rt.status==="failed");(ke||Ye)&&(clearInterval(Me),G(null),await ne())}catch(je){console.error("Error polling task status:",je)}},3e3);return G(Me),()=>{clearInterval(Me),G(null)}},Y=(Ee,Me)=>{e(je=>je.map(Ve=>{if(Ve.id===Ee&&Ve.tasks){const ke=Ve.tasks.map((Ye,rt)=>rt<Me.tasks.length?{...Ye,status:Me.tasks[rt].status}:Ye);return{...Ve,tasks:ke}}return Ve}))},ne=async()=>{a(!0),c(null);try{const Ee=await fetch("/api/todos");if(!Ee.ok)throw new Error(ee("failedToFetchTodos"));const Me=await Ee.json();e(Me)}catch(Ee){console.error(ee("failedToFetchTodos"),Ee),c(ee("failedToLoadTodos"))}finally{a(!1)}},le=async()=>{if(r.title)try{const Ee=await fetch("/api/todos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:r.title,priority:r.priority||"P2",tags:G8(r.tags)||[]})});if(!Ee.ok)throw new Error(ee("failedToCreateTodo"));const Me=await Ee.json();e(je=>[...je,Me]),i(!1),s({})}catch(Ee){console.error(ee("failedToCreateTodo"),Ee),c(ee("failedToCreateNewTodo"))}},de=Ee=>{d(Ee),f(!0)},me=async Ee=>{try{const Me={...Ee,tags:G8(Ee.tags)},je=await fetch(`/api/todos/${Ee.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Me)});if(!je.ok)throw new Error(ee("failedToSaveTodo"));const Ve=await je.json();e(ke=>ke.map(Ye=>Ye.id===Ve.id?Ve:Ye))}catch(Me){throw console.error(ee("failedToSaveTodo"),Me),c(ee("failedToSaveTodo")),Me}},_e=async Ee=>{try{if(!(await fetch(`/api/todos/${Ee}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw new Error(ee("failedToDeleteTodo"));e(je=>je.filter(Ve=>Ve.id!==Ee)),w===Ee&&(E(null),I(null)),T===Ee&&D(null)}catch(Me){console.error(ee("failedToDeleteTodo"),Me),c(ee("failedToDeleteTodo"))}},Ce=async Ee=>{try{a(!0);const Me=await fetch(`/api/todos/${Ee}`);if(!Me.ok)throw new Error(ee("failedToFetchTodo"));const je=await Me.json();return e(Ve=>Ve.map(ke=>ke.id===Ee?je:ke)),je}catch(Me){return console.error(ee("failedToFetchTodo"),Me),c(ee("failedToLoadTodo")),null}finally{a(!1)}},Le=async(Ee,Me)=>{if(Ee.stopPropagation(),w===Me.id)E(null),I(null);else{let je=Me;const Ve=await Ce(Me.id);if(Ve&&(je=Ve),F&&$===je.id)I(F),E(je.id);else if(je.tasks&&je.tasks.length>0){const ke={original_task:{title:je.title,description:je.description||""},analysis:je.analysis||"",tasks:je.tasks,dependencies:je.dependencies||[]};I(ke),E(je.id)}}},$e=async(Ee,Me)=>{if(Ee.stopPropagation(),w===Me.id)E(null),I(null);else{let je=Me;const Ve=await Ce(Me.id);if(Ve&&(je=Ve),je.tasks&&je.tasks.length>0){const ke={original_task:{title:je.title,description:je.description||""},analysis:je.analysis||"",tasks:je.tasks,dependencies:je.dependencies||[]};I(ke),E(je.id)}}},We=async Ee=>{E(null),I(null),await Ce(Ee)},ze=(Ee,Me)=>{Ee.tags&&Ee.tags.includes("正在拆解");const je=w===Ee.id;F!==null&&Ee.id;const Ve=Ee.id===M;return Ee.status==="developing"?S.jsxs("div",{className:"todo-actions flex items-center gap-2",children:[Ve?S.jsx(XS,{status:"processing",text:S.jsx("span",{className:"text-blue-400 text-xs",children:"正在拆解..."})}):S.jsx(XS,{status:"processing",text:S.jsx("span",{className:"text-blue-400 text-xs",children:ee("taskRunningStatus")})}),Ee.tasks&&Ee.tasks.length>0&&S.jsx(yn,{type:T===Ee.id?"primary":"text",size:"small",icon:S.jsx(_D,{}),onClick:ke=>{ke.stopPropagation(),D(T===Ee.id?null:Ee.id)},className:"text-gray-400 hover:text-blue-400 p-0 flex items-center justify-center",title:"查看任务状态"}),Ee.tasks&&Ee.tasks.length>0&&S.jsx(yn,{type:"text",size:"small",icon:S.jsx(Dce,{}),onClick:ke=>{ke.stopPropagation(),Le(ke,Ee)},className:`text-gray-400 hover:text-blue-400 p-0 flex items-center justify-center ${je?"bg-blue-900/30":""}`,title:"查看任务拆解结果"}),S.jsx("div",{className:"todo-tags flex gap-1",children:G8(Ee.tags).map(ke=>S.jsx(Sv,{className:"text-xs bg-gray-600 border-none text-gray-300 rounded-full px-2",children:ke},ke))})]}):S.jsxs("div",{className:"todo-actions flex items-center gap-2",children:[S.jsx(yn,{type:"text",size:"small",icon:S.jsx(pf,{}),onClick:ke=>{ke.stopPropagation(),Me(Ee)},className:"text-gray-400 hover:text-blue-400 p-0 flex items-center justify-center"}),(Ee.status==="pending"||Ee.status==="testing"||Ee.status==="done")&&S.jsx(Zx,{title:ee("confirmDeleteTask")||"确定要删除这个任务吗?",okText:ee("yes")||"是",cancelText:ee("no")||"否",onConfirm:ke=>{ke==null||ke.stopPropagation(),_e(Ee.id)},onCancel:ke=>ke==null?void 0:ke.stopPropagation(),children:S.jsx(yn,{type:"text",size:"small",danger:!0,icon:S.jsx(bd,{}),onClick:ke=>ke.stopPropagation(),className:"text-gray-400 hover:text-red-500 p-0 flex items-center justify-center",title:ee("deleteTask")||"删除任务"})}),(Ee.status==="testing"||Ee.status==="done")&&Ee.tasks&&Ee.tasks.length>0&&S.jsx(yn,{type:T===Ee.id?"primary":"text",size:"small",icon:S.jsx(_D,{}),onClick:ke=>{ke.stopPropagation(),D(T===Ee.id?null:Ee.id)},className:"text-gray-400 hover:text-blue-400 p-0 flex items-center justify-center",title:"查看任务状态"}),Ee.tasks&&Ee.tasks.length>0&&S.jsx(yn,{type:"text",size:"small",icon:S.jsx(Dce,{}),onClick:ke=>{ke.stopPropagation(),$e(ke,Ee)},className:`text-gray-400 hover:text-blue-400 p-0 flex items-center justify-center ${je?"bg-blue-900/30":""}`,title:ee(je?"hideTaskSplitResult":"viewTaskSplitResult")}),S.jsx("div",{className:"todo-tags flex gap-1",children:G8(Ee.tags).map(ke=>S.jsx(Sv,{className:"text-xs bg-gray-600 border-none text-gray-300 rounded-full px-2",children:ke},ke))})]})},Be=Ee=>{R(Me=>Me===Ee?null:Ee)};return S.jsxs("div",{className:"todo-container bg-gray-900 p-4",style:{height:"650px"},"data-testid":"todo-panel",children:[l&&S.jsx(uI,{message:l,type:"error",showIcon:!0,closable:!0,onClose:()=>c(null),className:"mb-4"}),S.jsx("div",{className:"todo-header mb-4",children:S.jsx(yn,{type:"primary",icon:S.jsx(hc,{}),onClick:()=>i(!0),className:"bg-blue-600 hover:bg-blue-700 border-none text-sm",children:ee("createNewTask")})}),S.jsxs(fti,{fallbackRender:({error:Ee})=>S.jsx("div",{className:"text-red-500 p-4",children:ee("droppableError",{message:Ee.message})}),children:[S.jsx(wei,{onDragEnd:j,children:S.jsx("div",{className:"todo-board flex gap-4 h-[calc(100%-80px)]",children:o?S.jsx("div",{className:"text-gray-400 text-center p-4",children:ee("loading")}):q.map(Ee=>S.jsx(Ipt,{droppableId:Ee.id,children:(Me,je)=>S.jsxs("div",{...Me.droppableProps,ref:Me.innerRef,className:`todo-column flex-col transition-all duration-300 ${je.isDraggingOver?"border-blue-500":"border-gray-700"} ${O===null?"flex-1":O===Ee.id?"flex w-full":"hidden"} bg-gray-800 rounded-lg p-4 border flex`,children:[S.jsxs("div",{className:"flex justify-between items-center mb-3",children:[S.jsx("h3",{className:"text-gray-300 font-medium",children:Ee.title}),S.jsx(Er,{title:O===Ee.id?ee("restorePanel"):ee("maximizePanel"),children:S.jsx(yn,{type:"text",size:"small",icon:O===Ee.id?S.jsx($3t,{}):S.jsx(iOt,{}),onClick:()=>Be(Ee.id),className:"text-gray-400 hover:text-blue-400"})})]}),S.jsxs("div",{className:"flex-1 overflow-y-auto max-h-[calc(100vh-220px)] pr-1 custom-scrollbar",children:[n.filter(Ve=>Ve.status===Ee.id).map((Ve,ke)=>S.jsxs(Ne.Fragment,{children:[S.jsx(oti,{draggableId:Ve.id,index:ke,children:(Ye,rt)=>S.jsxs("div",{ref:Ye.innerRef,...Ye.draggableProps,...Ye.dragHandleProps,className:`todo-card bg-gray-700 p-3 mb-3 rounded border ${rt.isDragging?"border-blue-500 shadow-lg":Ve.status==="developing"?"border-blue-400":"border-gray-600"} transition-all duration-150`,children:[S.jsxs("div",{className:"todo-card-header flex items-center justify-between mb-2",children:[S.jsx(Sv,{color:Rsi[Ve.priority],className:"border-none text-xs px-2 rounded-full",children:Ve.priority}),ze(Ve,de)]}),S.jsx("div",{className:"todo-title text-gray-200 text-sm mb-1",children:Ve.title}),Ve.dueDate&&S.jsx("div",{className:"todo-due-date text-gray-400 text-xs",children:ee("dueDate",{date:new Date(Ve.dueDate).toLocaleDateString()})}),Ve.status==="developing"&&S.jsxs("div",{className:"todo-execution-status flex items-center gap-1 text-blue-400 text-xs mt-2",children:[S.jsx(_D,{spin:!0}),S.jsx("span",{children:ee("taskExecutingInBackground")})]}),Ve.status==="pending"&&M&&Ve.id===M&&S.jsxs("div",{className:"todo-splitting-status flex items-center gap-1 text-blue-400 text-xs mt-2",children:[S.jsx(_D,{spin:!0}),S.jsx("span",{children:"正在后台运行拆解任务..."})]})]})}),w===Ve.id&&k&&S.jsx(Lsi,{visible:!0,result:k,todoId:Ve.id,onClose:()=>We(Ve.id)}),T===Ve.id&&(Ve.status==="developing"||Ve.status==="testing"||Ve.status==="done")&&S.jsx(Dsi,{todoId:Ve.id,onClose:()=>D(null)})]},Ve.id)),Me.placeholder]})]})},Ee.id))})}),S.jsxs(qs,{title:ee("createNewTask"),open:t,onCancel:()=>i(!1),onOk:le,className:"dark-theme-modal",styles:{content:{backgroundColor:"#1f2937",padding:"20px"},header:{backgroundColor:"#1f2937",borderBottom:"1px solid #374151"},body:{backgroundColor:"#1f2937"}},children:[S.jsx(yi,{placeholder:ee("taskTitlePlaceholder"),className:"custom-input bg-gray-800 border-gray-700 text-gray-200 mb-3",value:r.title,onChange:Ee=>s({...r,title:Ee.target.value})}),S.jsx(qi,{className:"custom-select w-full",placeholder:ee("priorityPlaceholder"),value:r.priority,onChange:Ee=>s({...r,priority:Ee}),options:Msi})]}),S.jsx(Asi,{visible:h,todo:u,onClose:()=>f(!1),onSave:me}),S.jsx(vsi,{visible:g,todo:p,onClose:Z,onConfirm:K,isExecuting:v,confirmMode:y})]})]})},Bsi=({isOpen:n,onClose:e,content:t,format:i,language:r="javascript",title:s="内容预览"})=>{const o=_.useRef(null);return _.useEffect(()=>{const a=c=>{c.key==="Escape"&&n&&e()},l=c=>{o.current&&!o.current.contains(c.target)&&n&&e()};return document.addEventListener("keydown",a),document.addEventListener("mousedown",l),()=>{document.removeEventListener("keydown",a),document.removeEventListener("mousedown",l)}},[n,e]),n?S.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-70",children:S.jsxs("div",{ref:o,className:"bg-gray-900 rounded-lg shadow-xl w-4/5 h-4/5 max-w-6xl flex flex-col",children:[S.jsxs("div",{className:"flex justify-between items-center p-4 border-b border-gray-700",children:[S.jsx("h3",{className:"text-lg font-medium text-white",children:s}),S.jsx("button",{onClick:e,className:"text-gray-400 hover:text-white focus:outline-none",children:S.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]}),S.jsx("div",{className:"flex-1 overflow-auto p-4",children:i==="markdown"?S.jsx("div",{className:"prose prose-invert prose-sm max-w-none",children:S.jsx(z0,{className:"text-gray-200 break-words",components:{code:({className:a,children:l,...c})=>{const u=/language-(\w+)/.exec(a||"");return!u?S.jsx("code",{className:a,...c,children:l}):S.jsx(Yc,{language:u?u[1]:"",style:Tu,PreTag:"div",wrapLines:!0,wrapLongLines:!0,children:String(l).replace(/\n$/,"")})}},children:t})}):S.jsx("div",{className:"h-full",children:S.jsx(_gt,{code:t,language:r,onChange:()=>{}})})})]})}):null},Psi=_.lazy(()=>Yt(()=>import("./HistoryPanel-gJupyfFp.js"),[])),Fsi=({projectName:n,activePanel:e,setActivePanel:t,clipboardContent:i,setClipboardContent:r,previewFiles:s,setPreviewFiles:o,requestId:a,setRequestId:l,selectedFiles:c,onSwitchToAutoMode:u,setSelectedFiles:d})=>{const[h,f]=_.useState("terminal"),[g,m]=_.useState(!1),[p,A]=_.useState(!1),[v,b]=_.useState(""),[y,C]=_.useState("markdown"),[w,E]=_.useState("plaintext"),[k,I]=_.useState("内容预览"),[T,D]=_.useState(null),[O,R]=_.useState(null);_.useEffect(()=>{a&&(R(a),console.log("ExpertModePage: Updated currentEventFileId from requestId:",a))},[a]),_.useEffect(()=>{const F=W=>{!W.target.closest(".tools-dropdown-container")&&g&&m(!1)};return document.addEventListener("mousedown",F),()=>{document.removeEventListener("mousedown",F)}},[g]),_.useEffect(()=>{const F=Gn.subscribe(qn.UI.ACTIVATE_PANEL,W=>{W==="history"&&t("history")});return()=>{F()}},[t]),_.useEffect(()=>{const F=Gn.subscribe(qn.CHAT.NEW_MESSAGE,W=>{var U;if(console.log("ExpertModePage: Received message via eventBus:",W.type),W.type==="ASK_USER"){const H={...W,id:W.id||`msg-${Date.now()}`,timestamp:Date.now()};D(H);try{vgt()}catch{}console.log("ExpertModePage: Set activeAskUserMessage from eventBus")}W.event_file_id&&!O&&(R(W.event_file_id),console.log("ExpertModePage: Set currentEventFileId from message:",W.event_file_id)),(U=W.metadata)!=null&&U.event_file_id&&!O&&(R(W.metadata.event_file_id),console.log("ExpertModePage: Set currentEventFileId from message metadata:",W.metadata.event_file_id))});return()=>{F()}},[O]),_.useEffect(()=>{const F=Gn.subscribe(qn.UI.SHOW_MODAL,W=>{b(W.content),C(W.format),E(W.language||"plaintext"),I(W.title||"内容预览"),A(!0)});return()=>{F()}},[]);const M=async(F,W)=>{if(!W){console.error("Cannot respond to event: No event ID provided");return}if(!O){console.error("Cannot respond to event: No event file ID available");return}(T==null?void 0:T.eventId)===W&&D(null);try{console.log("ExpertModePage: Sending response to event:",{event_id:W,event_file_id:O,response:F});const U=await fetch("/api/auto-command/response",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event_id:W,event_file_id:O,response:F})});if(!U.ok){const H=await U.json();throw new Error(`Failed to send response: ${H.detail||U.statusText}`)}console.log("Response sent successfully to event:",W)}catch(U){console.error("Error sending response to server:",U),Gn.publish(qn.CHAT.NEW_MESSAGE,{type:"ERROR",content:`Failed to send your response to the server: ${U instanceof Error?U.message:String(U)}`})}},B=F=>{F.stopPropagation(),m(!g)};return S.jsxs(S.Fragment,{children:[T&&S.jsx(iQe,{message:T,onResponse:M,onClose:()=>{}}),S.jsxs(kI,{className:"flex-1 flex",sizes:[25,75],minSize:[180,400],gutterSize:3,snapOffset:20,children:[S.jsx("div",{className:"border-r border-gray-700 flex flex-col",children:S.jsx(lQn,{setPreviewFiles:o,setActivePanel:t,setClipboardContent:r,clipboardContent:i,setRequestId:l,projectName:n,setSelectedFiles:d})}),S.jsx("div",{className:"relative flex flex-col flex-grow h-full w-full overflow-hidden",children:S.jsx("div",{className:"absolute inset-0",children:S.jsxs(kI,{direction:"vertical",sizes:[75,25],minSize:[180,80],gutterSize:5,snapOffset:20,dragInterval:1,cursor:"row-resize",className:"split-vertical",onDragEnd:()=>{window.dispatchEvent(new Event("resize"))},children:[S.jsxs("div",{className:"flex flex-col overflow-hidden",children:[S.jsx("div",{className:"bg-gray-800 p-2 border-b border-gray-700",children:S.jsxs("div",{className:"flex space-x-2",children:[S.jsxs("button",{className:`px-2 py-1 rounded text-xs font-medium transition-all duration-300
|
1970
1970
|
${e==="history"?"bg-gradient-to-r from-blue-500 to-indigo-600 text-white shadow-md shadow-blue-500/20 hover:shadow-lg hover:shadow-blue-500/30 hover:from-blue-600 hover:to-indigo-700 transform hover:-translate-y-0.5":"bg-gray-800/60 text-gray-400 hover:bg-gray-700/80 hover:text-white hover:shadow-sm"} flex items-center space-x-2`,onClick:()=>t("history"),children:[S.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),S.jsx("span",{children:ee("devHistory")})]}),S.jsxs("button",{className:`px-2 py-1 rounded text-xs font-medium transition-all duration-300
|
1971
1971
|
${e==="code"?"bg-gradient-to-r from-blue-500 to-indigo-600 text-white shadow-md shadow-blue-500/20 hover:shadow-lg hover:shadow-blue-500/30 hover:from-blue-600 hover:to-indigo-700 transform hover:-translate-y-0.5":"bg-gray-800/60 text-gray-400 hover:bg-gray-700/80 hover:text-white hover:shadow-sm"} flex items-center space-x-2`,onClick:()=>t("code"),children:[S.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),S.jsx("span",{children:ee("codeViewer")})]}),S.jsxs("button",{className:`px-2 py-1 rounded text-xs font-medium transition-all duration-300
|
1972
1972
|
${e==="preview_static"?"bg-gradient-to-r from-blue-500 to-indigo-600 text-white shadow-md shadow-blue-500/20 hover:shadow-lg hover:shadow-blue-500/30 hover:from-blue-600 hover:to-indigo-700 transform hover:-translate-y-0.5":"bg-gray-800/60 text-gray-400 hover:bg-gray-700/80 hover:text-white hover:shadow-sm"} flex items-center space-x-1`,onClick:()=>t("preview_static"),title:ee("previewChangesStatic"),children:[S.jsxs("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),S.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"})]}),S.jsx("span",{children:ee("previewChangesStatic")})]}),S.jsxs("button",{className:`px-2 py-1 rounded text-xs font-medium transition-all duration-300
|
@@ -1,13 +1,13 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: auto_coder_web
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.110
|
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.382
|
11
11
|
Requires-Dist: aiofiles
|
12
12
|
Requires-Dist: psutil
|
13
13
|
Requires-Dist: watchdog
|
@@ -7,7 +7,7 @@ auto_coder_web/lang.py,sha256=cXypkDesnMwZ0U6D_CZtxhDTAOp__hoJzYTulQ_8xPc,1108
|
|
7
7
|
auto_coder_web/proxy.py,sha256=YovNqtVQJrVFN6UoIRR7K0-DP3AjMX3wXpsuueLnZe8,11959
|
8
8
|
auto_coder_web/terminal.py,sha256=65F-mjFaZdoKK5k29re7_H7az6mZeOVqTrC8Wuvn-4g,9835
|
9
9
|
auto_coder_web/types.py,sha256=hwHLmYXaCZo-V66dAOsCK2weBAd87gexBeJBpfjO5aU,1693
|
10
|
-
auto_coder_web/version.py,sha256=
|
10
|
+
auto_coder_web/version.py,sha256=IdGt47yTByl81nIAWmL37jegJ46MzryO0ztrSBIalyA,24
|
11
11
|
auto_coder_web/agentic_message_parser/__init__.py,sha256=a6tHO-3fWK2uIU-E3wPISO3H-5I9XHKjofyPxj-m7pY,358
|
12
12
|
auto_coder_web/agentic_message_parser/message_parser.py,sha256=-uGG2QDXS7aLPi7zJopDwlt0S__JFHgKPPZs68LpKhI,2690
|
13
13
|
auto_coder_web/agentic_message_parser/tool_parsers.py,sha256=hCjd02ErCu5u5EmElOPHc6w0UZFX4M59FVJwfy3WkV8,2653
|
@@ -181,7 +181,7 @@ auto_coder_web/web/assets/liquid-BLUt9KkL.js,sha256=AdRP6IHXvDgzYyS8i2a4IEkF7CD3
|
|
181
181
|
auto_coder_web/web/assets/lua-nf6ki56Z.js,sha256=O3vMsGoiFHDMGSxTP1bHnDnRPebfmFnC7kf8-ovGkO8,2369
|
182
182
|
auto_coder_web/web/assets/m3-Cpb6xl2v.js,sha256=PmotBCyVZvUGHh9t9juODmjXptTEP5K6bnPj2WgYO6c,3063
|
183
183
|
auto_coder_web/web/assets/main-BtXMe4GC.css,sha256=ignxjTN7WLBWHVyJZ4q_RW9r0mNWDV3DshtmAxTkKto,272486
|
184
|
-
auto_coder_web/web/assets/main.js,sha256=
|
184
|
+
auto_coder_web/web/assets/main.js,sha256=QeLpwCvSOatyDct-s24mrDCBcQpWBAHN_3m-o4tDmMk,7467832
|
185
185
|
auto_coder_web/web/assets/markdown-DSZPf7rp.js,sha256=3ZMgfYxjKX9U8l6GFCNrO28Hj7JU-4rKrEqXIezyqT4,4034
|
186
186
|
auto_coder_web/web/assets/mdx-CiikeQLk.js,sha256=iprIzvjW16191tAVyafTYuIz_I_E9WKkVH56DJUxgD0,5114
|
187
187
|
auto_coder_web/web/assets/mindmap-definition-ALO5MXBD-BK4Kd7cQ.js,sha256=5tpSNXZ2bGGSkZUrJthQpoYwZamfFE4SPWRpGo6fJ4Y,100975
|
@@ -347,8 +347,8 @@ auto_coder_web/web/monaco-editor/min/vs/language/typescript/tsWorker.js,sha256=_
|
|
347
347
|
auto_coder_web/web/sounds/ding-dong.wav,sha256=BveDrGCyt_YMHaJwFJ80L5NfbUF5cl5QjzR-SRehxTk,35324
|
348
348
|
auto_coder_web/web/sounds/gentle-notification.wav,sha256=bzd0MwECdrjmNz7mbqv_y03S7WwD3G6agbIh1rWJ9cQ,72124
|
349
349
|
auto_coder_web/web/sounds/soft-chime.wav,sha256=Akpw7_rHLnX3rE13dRYpyZbmQFLGtp8P53LCdAkT9sA,40364
|
350
|
-
auto_coder_web-0.1.
|
351
|
-
auto_coder_web-0.1.
|
352
|
-
auto_coder_web-0.1.
|
353
|
-
auto_coder_web-0.1.
|
354
|
-
auto_coder_web-0.1.
|
350
|
+
auto_coder_web-0.1.110.dist-info/METADATA,sha256=O7qAKMRdtCzh2-r6nCU3Iwto3dw-iXM_n2j6s5h-078,1436
|
351
|
+
auto_coder_web-0.1.110.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
352
|
+
auto_coder_web-0.1.110.dist-info/entry_points.txt,sha256=oh8kd1ZecWDgdv-bIj_ru3phvl4scuxwXl9DK0Khltg,61
|
353
|
+
auto_coder_web-0.1.110.dist-info/top_level.txt,sha256=UCzEw494Im0KvR-FTYf2jh-okqHvLsC_0JLOrQZoSpg,15
|
354
|
+
auto_coder_web-0.1.110.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|