@customize-agent/server 4.1.26 → 4.1.28

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.
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[298],{16403:(e,t,r)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/documents",function(){return r(19562)}])},19562:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>ei});var s=r(65321),a=r(97109),l=r(26171),n=r(7576),o=r(35292),i=r(33442),c=r(17807),d=r(63455),u=r(11702),p=r(88762),m=r(85114),x=r(58569),h=r(84253),g=r(34052),v=r(68787),j=r(42700),f=r(2256),y=r(38770),w=r(38332),b=r(76506),A=r(50883),k=r(23718),S=r(23216),I=r(26619),C=r(8263),N=r(16285),T=r(8579),R=r(75548),z=r(7851),M=r(84742),E=r(29071),B=r(63552),F=r(26631),_=r(7225),D=r(83914),P=r(58209),L=r(38762),G=r(54746),W=r(93051),q=r(64068),H=r(64629),O=r(1310),K=r(67547),U=r(76830),V=r(6578),Q=r(48321);let{TextArea:X}=n.A,{Text:J}=o.A,Y=l.A;function Z(e){let{type:t="info",title:r,children:a,style:l}=e,n="error"===t?"var(--colorError)":"warning"===t?"var(--colorWarning)":"success"===t?"var(--colorSuccess)":"var(--colorInfo)";return(0,s.jsxs)("div",{style:{border:"1px solid ".concat(n),background:"error"===t?"var(--colorErrorBg)":"warning"===t?"var(--colorWarningBg)":"success"===t?"var(--colorSuccessBg)":"var(--colorInfoBg)",borderRadius:8,padding:"9px 12px",...l},children:[(0,s.jsx)(J,{strong:!0,style:{color:n},children:r}),a&&(0,s.jsx)("div",{style:{marginTop:4,color:"var(--colorTextSecondary)",fontSize:12},children:a})]})}function $(e){let{children:t,gap:r=12,style:a}=e;return(0,s.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:r,...a},children:t})}let ee=null;function et(){null==ee||ee.listeners.forEach(e=>e())}let er={role_binding:(0,s.jsx)(S.A,{}),knowledge_retrieval:(0,s.jsx)(I.A,{}),file_understanding:(0,s.jsx)(C.A,{}),fact_extraction:(0,s.jsx)(N.A,{}),chapter_generation:(0,s.jsx)(T.A,{}),asset_generation:(0,s.jsx)(R.A,{}),validation:(0,s.jsx)(z.A,{}),formatting:(0,s.jsx)(M.A,{}),llm_review:(0,s.jsx)(E.A,{}),export_ready:(0,s.jsx)(B.A,{}),reference:(0,s.jsx)(R.A,{})},es={施工组织设计:(0,s.jsx)(z.A,{}),投标文件:(0,s.jsx)(B.A,{}),技术方案:(0,s.jsx)(N.A,{}),报告:(0,s.jsx)(F.A,{}),自定义:(0,s.jsx)(T.A,{})};function ea(e){return[...new Set(e.map(e=>e.trim()).filter(Boolean))]}function el(e){return e.map(e=>({key:e.key,value:e.key,rawTitle:e.title,title:e.isFolder?(0,s.jsxs)("div",{className:"flex items-center justify-between w-full pr-4",children:[(0,s.jsxs)(i.A,{size:4,children:[(0,s.jsx)(_.A,{style:{color:"#faad14"}}),(0,s.jsx)("span",{children:e.title})]}),(0,s.jsxs)("span",{className:"text-xs text-[var(--colorTextTertiary)]",children:[e.fileCount||0," 项"]})]}):(0,s.jsx)("span",{title:e.key,children:e.title}),isFolder:e.isFolder,fileCount:e.fileCount||+!e.isFolder,isLeaf:e.isLeaf}))}let en={role_binding:"角色配置绑定",knowledge_retrieval:"知识库检索",file_understanding:"多模态文件理解",fact_extraction:"LLM 事实抽取",chapter_generation:"LLM 章节生成",asset_generation:"多模态资源生成",validation:"规则校验",formatting:"格式化排版",llm_review:"LLM 审查优化",export_ready:"导出就绪",reference:"参考资源处理"},eo={"knowledge-base":"知识库","document-readiness":"生成准备度检查","quality-repair":"质量补写","export-gate":"导出门禁","context-memory":"项目上下文","final-format":"正式排版","multimodal-files":"多模态文件理解",tender_announcement:"招标公告"};function ei(){var e,t,r,l,o,R,_,ei;let ec=(0,Q.Vr)(),{message:ed}=c.A.useApp(),[eu]=d.A.useForm(),ep=(0,a.useRef)(null),[em,ex]=(0,a.useState)([]),[eh,eg]=(0,a.useState)("construction-organization-design"),[ev,ej]=(0,a.useState)([]),[ef,ey]=(0,a.useState)([]),[ew,eb]=(0,a.useState)([]),[eA,ek]=(0,a.useState)([]),[eS,eI]=(0,a.useState)(!1),[eC,eN]=(0,a.useState)(!0),[eT,eR]=(0,a.useState)(!1),[ez,eM]=(0,a.useState)(null),[eE,eB]=(0,a.useState)(""),[eF,e_]=(0,a.useState)([]),[eD,eP]=(0,a.useState)(null),[eL,eG]=(0,a.useState)(null),[eW,eq]=(0,a.useState)(""),[eH,eO]=(0,a.useState)(!1),[eK,eU]=(0,a.useState)("idle"),[eV,eQ]=(0,a.useState)(null),[eX,eJ]=(0,a.useState)(null),[eY,eZ]=(0,a.useState)({start:0,end:0}),[e$,e0]=(0,a.useState)([]),[e1,e2]=(0,a.useState)(!1),[e6,e5]=(0,a.useState)(!1),[e8,e3]=(0,a.useState)({}),e4=(0,a.useMemo)(()=>{var e,t,r;return(null==(e=ew.find(e=>e.selected))?void 0:e.projectRoot)||(null==(t=ew.find(e=>e.isCurrent))?void 0:t.projectRoot)||(null==(r=ew[0])?void 0:r.projectRoot)||""},[ew]),[e7,e9]=(0,a.useState)([]),[te,tt]=(0,a.useState)(null),[tr,ts]=(0,a.useState)(null),[ta,tl]=(0,a.useState)("templates"),[tn,to]=(0,a.useState)(!1),[ti,tc]=(0,a.useState)("workflow"),[td,tu]=(0,a.useState)(null),tp=(0,a.useRef)(null),tm=(0,a.useRef)(null),tx=(0,a.useRef)(0),th=(0,a.useMemo)(()=>"activeGenDocId:".concat(e4||"default"),[e4]),tg=async()=>{try{e_((await (0,V.cQ)(e4||void 0)).documents)}catch(e){e_([])}};(0,a.useEffect)(()=>{let e=()=>{ee&&(e9(ee.flowSteps),tt(ee.activeFlowKey),eR(ee.loading),ee.documentId&&eP(ee.documentId),ee.draft&&eM(ee.draft),void 0!==ee.content&&eB(ee.content))},t=ee;return null==t||t.listeners.add(e),e(),()=>{null==t||t.listeners.delete(e)}},[]),(0,a.useEffect)(()=>{eN(!0),Promise.all([(0,V.Dl)().then(e=>{var t,r;ex(e.templates),eg(null!=(r=null==(t=e.templates[0])?void 0:t.id)?r:"construction-organization-design")}),(0,V.lv)().then(e=>{ej(e.roles),ey(e.configs)}),(0,V.dx)().then(e=>eb(e))]).catch(()=>ed.error(ec("common.error"))).finally(()=>eN(!1))},[ed,ec]),(0,a.useEffect)(()=>{e4&&(localStorage.removeItem("activeGenDocId"),tg())},[e4]),(0,a.useEffect)(()=>{if(0===eF.length)return;let e=localStorage.getItem(th);if(!e)return;if(!eF.find(t=>t.id===e&&"generating"===t.status))return void localStorage.removeItem(th);let t=setInterval(()=>{(async()=>{try{let{document:r}=await (0,V.v7)(e,!1,e4||void 0);await tg(),"generating"!==r.status&&(localStorage.removeItem(th),clearInterval(t))}catch(e){clearInterval(t)}})()},3e3);return()=>clearInterval(t)},[eF]);let tv=(0,a.useMemo)(()=>em.find(e=>e.id===eh),[em,eh]),tj=ef.map(e=>({label:e.name,value:e.id})),tf=Math.max(0,e7.findIndex(e=>e.key===te)),ty=e=>{var t;return e?(null==(t=ev.find(t=>t.id===e))?void 0:t.name)||eo[e]||"未知角色":""},tw=e=>e.subtitle||e.roleName||ty(e.roleId)||en[e.type]||e.type,tb=e=>{var t,r,s;return e.promptName||((t=e.promptId)?(null==(r=ew.find(e=>e.id===t))?void 0:r.projectName)||(null==(s=ev.find(e=>e.id===t))?void 0:s.name)||eo[t]||"未知提示词":"")},tA=()=>{tx.current+=1,eq(""),eQ(null),eJ(null),e0([]),e2(!1),eO(!1),eU("idle")},tk=async e=>{eP(e.id),eg(e.templateId);let t=tS(e.status);if(t||"failed"===e.status||"aborted"===e.status){tA(),ts(e),eM(null),eB(""),eR(t),tc("workflow"),to(!0);try{let{document:t}=await (0,V.v7)(e.id,!1,e.projectRoot||e4||void 0);tN(t),tS(t.status)?tT(t.id,t.projectRoot||e.projectRoot||e4||void 0):await tg()}catch(t){tN(e)}return}tc("editor"),e9([]),tt(null),tA();try{let{document:t}=await (0,V.v7)(e.id,!1,e.projectRoot||e4||void 0);eM(t.draft||null),eB(t.editedMarkdown||t.markdown)}catch(e){ed.error(ec("common.error"))}to(!0)},tS=e=>"completed"!==e&&"warning"!==e&&"failed"!==e&&"aborted"!==e,tI=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:eT;(null==ee?void 0:ee.loading)&&(ee.flowSteps=e,ee.activeFlowKey=t,ee.loading=r,et())},tC=e=>{var t,r,a,l,n;let o=e.executionStages||(null==(t=e.draft)?void 0:t.executionStages)||[];if(o.length>0){let t=o.map((t,r)=>{var a;let l,n=("failed"===e.status||"aborted"===e.status)&&"running"===t.status||"failed"===(l=t.status)?"error":"running"===l?"process":"finish";return{key:"".concat(t.type,"-").concat(r),title:t.title||en[t.type]||t.type,subtitle:tw(t),description:t.message||"",status:n,icon:"role_binding"===(a=t.type)?(0,s.jsx)(S.A,{}):"knowledge_retrieval"===a?(0,s.jsx)(I.A,{}):"file_understanding"===a?(0,s.jsx)(C.A,{}):"fact_extraction"===a?(0,s.jsx)(N.A,{}):"chapter_generation"===a?(0,s.jsx)(T.A,{}):"llm_review"===a?(0,s.jsx)(E.A,{}):"validation"===a?(0,s.jsx)(z.A,{}):"formatting"===a?(0,s.jsx)(M.A,{}):"export_ready"===a?(0,s.jsx)(B.A,{}):(0,s.jsx)(F.A,{}),subSteps:((e,t,r)=>{let s=Array.isArray(e.details)?e.details.filter(Boolean):[],a=e.progress?"".concat(e.progress.label||"进度",":").concat(e.progress.current,"/").concat(e.progress.total):"",l=[...a?[a]:[],...s];return 0===l.length?[{key:"stage-".concat(r),title:tb(e)?"提示词:".concat(tb(e)):tw(e),status:t}]:l.slice(0,8).map((e,s)=>({key:"stage-".concat(r,"-").concat(s),title:e,status:"process"===t&&0===s?"process":"error"===t&&0===s?"error":"warning"===t?"warning":"process"===t?"finish":t}))})(t,n,r)}});"generating"===e.status&&t.length>0&&(null==(r=t.at(-1))?void 0:r.status)==="finish"&&(t[t.length-1]={...t[t.length-1],status:"process"});let i="generating"===e.status?(null==(a=t.at(-1))?void 0:a.key)||"prepare":"failed"===e.status||"aborted"===e.status?(null==(l=t.find(e=>"error"===e.status))?void 0:l.key)||(null==(n=t.at(-1))?void 0:n.key)||"prepare":"done";return{steps:t,activeKey:i}}return{steps:[],activeKey:null}},tN=e=>{ts(e);let{steps:t,activeKey:r}=tC(e);e9(t),tt(r),eR(tS(e.status)),tI(t,r,tS(e.status)),("failed"===e.status||"aborted"===e.status)&&tc("workflow"),("completed"===e.status||"warning"===e.status)&&e.draft&&(eM(e.draft),eB(e.editedMarkdown||e.markdown),tc("editor"),e9([]),tt(null))},tT=(e,t)=>{tp.current&&clearInterval(tp.current),tp.current=setInterval(()=>{(async()=>{try{let{document:r}=await (0,V.v7)(e,!0,t||e4||void 0);tN(r),await tg(),tS(r.status)||(tp.current&&clearInterval(tp.current),tp.current=null,localStorage.removeItem(th))}catch(e){}})()},2e3)};(0,a.useEffect)(()=>()=>{tp.current&&(clearInterval(tp.current),tp.current=null),tm.current&&(clearTimeout(tm.current),tm.current=null)},[]),(0,a.useEffect)(()=>{if(!eT||!te)return;let e=window.setInterval(()=>e9(e=>{let t=e.map(e=>{if(e.key!==te||"process"!==e.status)return e;let t=e.subSteps.findIndex(e=>"process"===e.status),r=t<0?0:Math.min(t+1,e.subSteps.length-1);return{...e,subSteps:e.subSteps.map((e,t)=>t<r?{...e,status:"finish"}:t===r?{...e,status:"process"}:{...e,status:"wait"})}});return tI(t,te),t}),1400);return()=>window.clearInterval(e)},[te,eT]);let tR=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";eI(!0);try{let t=await (0,V.Fi)(e,e4||void 0);ek(el(t.nodes))}catch(e){ed.error("知识库文件加载失败")}finally{eI(!1)}},tz=async e=>{var t;let r=String(null!=(t=e.key)?t:"");if(r)try{let e=await (0,V.Fi)(r,e4||void 0),t=el(e.nodes),s=e=>e.map(e=>e.key===r?{...e,children:t}:e.children?{...e,children:s(e.children)}:e);ek(e=>s(e))}catch(e){ed.error("加载子文件夹失败")}},tM=e=>{let t=null!=e?e:{id:"tpl-".concat(Date.now()),name:"",description:"",category:"自定义",outputTitle:"",projectRoleConfigId:void 0,chapters:[],projectBindings:[]};eu.resetFields(),eu.setFieldsValue({...t,projectMaterialRoots:ea((t.projectBindings||[]).map(e=>e.materialRootPath).filter(Boolean))}),tR(),e5(!0)},tE=async()=>{try{await eu.validateFields();let e=eu.getFieldsValue(!0),t=ea(e.projectMaterialRoots||[]).map(e=>({materialRootPath:e})),{projectMaterialRoots:r,...s}=e,a={...s,chapters:[],projectBindings:t},l=await (0,V.l2)(a);ex(l.templates),eg(l.template.id),e5(!1),await tg(),ed.success(ec("common.success"))}catch(e){e instanceof Error&&ed.error(e.message)}},tB=async e=>{try{let t=await (0,V.bV)(e);ex(t.templates),eg(t.template.id),ed.success(ec("common.success"))}catch(e){ed.error(ec("common.error"))}},tF=async e=>{try{var t,r;let s=await (0,V.h0)(e);ex(s.templates),eg(null!=(r=null==(t=s.templates[0])?void 0:t.id)?r:""),ed.success(ec("common.success"))}catch(e){ed.error(ec("common.error"))}},t_=async e=>{tu(e),eg(e),eP(null),eM(null),eB(""),tA(),tc("workflow"),to(!0),tl("drafts"),eR(!0),tt("prepare"),e9([{key:"prepare",title:"正在准备运行模板",description:"正在校验模板绑定的项目资料包、提示词配置和资料索引,校验通过后会自动开始生成。",status:"process",icon:(0,s.jsx)(D.A,{}),subSteps:[{key:"validate",title:"模板运行前检查",status:"process"},{key:"start",title:"准备生成任务",status:"wait"}]}]);try{let{validation:t}=await (0,V.SM)(e,e4||void 0);e3(r=>({...r,[e]:t}));let r=t.issues.filter(e=>"error"===e.level);if(r.length>0){eR(!1),tt("prepare"),e9([{key:"prepare",title:"模板运行前检查未通过",description:r.map(e=>e.message).join("\n"),status:"error",icon:(0,s.jsx)(L.A,{}),subSteps:[{key:"validate",title:"模板运行前检查",status:"error"},{key:"start",title:"准备生成任务",status:"wait"}]}]),ed.warning("模板运行前检查未通过,请先处理阻断项");return}t.issues.length>0&&ed.warning("模板存在非阻断警告,已继续运行"),e9([{key:"prepare",title:"模板检查通过,正在创建生成任务",description:"已确认模板绑定资源可用,正在启动后台生成任务。",status:"process",icon:(0,s.jsx)(D.A,{}),subSteps:[{key:"validate",title:"模板运行前检查",status:"finish"},{key:"start",title:"准备生成任务",status:"process"}]}]),await tL(e)}catch(t){let e=t instanceof Error?t.message:"模板运行前检查失败";eR(!1),e9([{key:"prepare",title:"模板运行准备失败",description:e,status:"error",icon:(0,s.jsx)(L.A,{}),subSteps:[{key:"validate",title:"模板运行前检查",status:"error"},{key:"start",title:"准备生成任务",status:"wait"}]}]),ed.error(e)}finally{tu(t=>t===e?null:t)}},tD=async e=>{try{await (0,V.QG)(e.id,e.projectRoot||e4||void 0),eD===e.id&&(eP(null),eM(null),eB("")),await tg(),ed.success(ec("common.success"))}catch(e){ed.error(ec("common.error"))}},tP=async(e,t)=>{let r=Date.now(),s=0,a=Date.now();for(;;){let l;if(null==t?void 0:t.aborted)throw Error("用户中止");let n=new AbortController;t&&(t.pollController=n);try{({document:l}=await (0,V.v7)(e,!0,e4||void 0,n.signal))}finally{(null==t?void 0:t.pollController)===n&&(t.pollController=void 0)}if(tN(l),l.updatedAt!==s&&(s=l.updatedAt,a=Date.now()),("completed"===l.status||"warning"===l.status)&&l.draft)return l;if("failed"===l.status||"aborted"===l.status)throw Error(l.error||("aborted"===l.status?"生成已中止":"生成失败"));if(Date.now()-r>75e5||Date.now()-a>96e4)throw Error("生成任务疑似卡住,请点击继续生成或重新生成");await new Promise(e=>window.setTimeout(e,1500))}},tL=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eh;if(!e)return;if((null==ee?void 0:ee.aborted)&&(ee=null),null==ee?void 0:ee.loading){e9(ee.flowSteps),tt(ee.activeFlowKey),eR(!0);return}if(!e4)return void ed.error("未识别当前项目,请先选择或打开项目后再生成文件");eR(!0);let t=e7.length>0?e7:[{key:"prepare",title:"正在创建生成任务",description:"系统正在创建后台生成任务,请稍候。",status:"process",icon:(0,s.jsx)(D.A,{}),subSteps:[{key:"start",title:"准备生成任务",status:"process"}]}],r=te||"prepare";e9(t),tt(r);let a=(0,V.OX)({templateId:e,projectRoot:e4});ee={id:Date.now(),templateId:e,loading:!0,flowSteps:t,activeFlowKey:r,promise:a,listeners:new Set};let l=[];try{let e=await a;e.documentId&&(localStorage.setItem(th,e.documentId),eP(e.documentId),(null==ee?void 0:ee.promise)===a&&(ee.documentId=e.documentId)),await tg();let t=e.documentId?await tP(e.documentId,(null==ee?void 0:ee.promise)===a?ee:void 0):void 0,r=e.draft||(null==t?void 0:t.draft);if(!r)throw Error("生成结果为空");(e.documentId||(null==t?void 0:t.id))&&eP(e.documentId||t.id),l.forEach(e=>window.clearTimeout(e)),eM(r),eB((null==t?void 0:t.editedMarkdown)||(null==t?void 0:t.markdown)||r.markdown),(null==ee?void 0:ee.promise)===a&&(ee.draft=r,ee.content=(null==t?void 0:t.editedMarkdown)||(null==t?void 0:t.markdown)||r.markdown);let s=t||{id:e.documentId||"draft-".concat(Date.now()),templateId:eh,title:r.title,requirement:r.requirement,projectRoot:r.projectRoot||e4,projectId:r.projectId,markdown:r.markdown,status:r.validationIssues.some(e=>"error"===e.level||"warning"===e.level)||!r.exportGate.passed?"warning":"completed",draft:r,executionStages:r.executionStages,assets:r.assets||[],createdAt:r.generatedAt,updatedAt:Date.now()},{steps:n}=tC(s);e9(n),tI(n,"done",!1),tt("done"),(null==ee?void 0:ee.promise)===a&&(ee.activeFlowKey="done",ee.loading=!1,et(),ee=null),localStorage.removeItem(th),await tg(),ed.success(ec("common.success")),window.setTimeout(()=>{var e;return null==(e=ep.current)?void 0:e.scrollIntoView({behavior:"smooth",block:"start"})},200)}catch(r){localStorage.removeItem(th);let e=r instanceof Error?r.message:ec("common.error"),t=/用户中止|abort|aborted/i.test(e);t||e9(t=>{let r=t.map(t=>"process"===t.status?{...t,status:"error",description:e,subSteps:((e,t)=>{if("wait"===t)return e.subSteps.map(e=>({...e,status:"wait"}));if("finish"===t)return e.subSteps.map(e=>({...e,status:"finish"}));if("error"===t)return e.subSteps.map((e,t)=>({...e,status:0===t?"error":e.status}));let r=e.subSteps.findIndex(e=>"wait"===e.status);return e.subSteps.map((e,t)=>t<r||-1===r?{...e,status:"finish"}:t===r?{...e,status:"process"}:e)})(t,"error")}:t);return tI(r,te,!1),r}),(null==ee?void 0:ee.promise)===a&&(ee.loading=!1,ee.error=e,et(),ee=null),await tg().catch(()=>void 0),t||ed.error(e)}finally{l.forEach(e=>window.clearTimeout(e)),eR(!1),(null==ee?void 0:ee.promise)===a&&(ee.loading=!1,et())}},tG=(0,a.useRef)(!1);(0,a.useEffect)(()=>(tm.current&&(clearTimeout(tm.current),tm.current=null),!tn||"workflow"!==ti||td||eD||tG.current||(null==ee?void 0:ee.loading)||null==tv||!tv.projectRoleConfigId||(tG.current=!0,tm.current=setTimeout(()=>{tm.current=null,tn&&"workflow"===ti&&!eD&&eh==eh&&tL()},300)),tn||(tG.current=!1),()=>{tm.current&&(clearTimeout(tm.current),tm.current=null)}),[tn,ti,td,eD,tv,eh]);let tW=async e=>{try{eP(e.id),eg(e.templateId),tc("workflow"),to(!0),eR(!0);let t=await (0,V.UQ)(e.id,e.projectRoot||e4||void 0);localStorage.setItem(th,t.documentId),await tg();let r=await tP(t.documentId);r.draft&&(eM(r.draft),eB(r.editedMarkdown||r.markdown||r.draft.markdown),tc("editor")),localStorage.removeItem(th),await tg(),ed.success("已继续生成并完成")}catch(e){ed.error(e instanceof Error?e.message:"继续生成失败")}finally{eR(!1)}},tq=async e=>{if((null==ee?void 0:ee.loading)&&ee.documentId===e.id){var t;ee.aborted=!0,null==(t=ee.pollController)||t.abort(),ee.loading=!1,ee.error="用户中止",et(),ee=null,eR(!1)}localStorage.removeItem(th),tp.current&&(clearInterval(tp.current),tp.current=null);try{await (0,V.r)(e.id,e.projectRoot||e4||void 0),ed.success("已中止生成任务")}catch(e){ed.info("任务已不在运行,已刷新状态")}finally{await tg(),eD===e.id&&(eP(null),ts(null),eM(null),eB(""))}},tH=async e=>{if(ez){eG(e);try{ez.exportGate.passed||ed.warning("导出门禁存在风险项,已允许导出,请下载后人工复核。");let t={documentId:eD||void 0,title:ez.title,markdown:eE,format:e,enforceGate:!1,exportGate:ez.exportGate,useClientMarkdown:!0,projectRoot:ez.projectRoot||e4||void 0},r=await (0,V.UE)(t);((e,t,r)=>{let s=new Blob([e],{type:r}),a=URL.createObjectURL(s),l=document.createElement("a");l.href=a,l.download=t,l.target="_self",l.rel="noopener",l.style.display="none",document.body.appendChild(l),l.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window})),l.remove(),window.setTimeout(()=>URL.revokeObjectURL(a),1e3)})(r,"".concat(ez.title,".").concat("markdown"===e?"md":e),{markdown:"text/markdown;charset=utf-8",html:"text/html;charset=utf-8",pdf:"application/pdf",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}[e])}catch(e){ed.error(e instanceof Error?e.message:ec("common.error"))}finally{eG(null)}}},tO=async()=>{if(ez)try{if(eD)await (0,V.a6)(eD,{editedMarkdown:eE,markdown:eE},ez.projectRoot||e4||void 0);else{let e=await (0,V.Af)({...ez,markdown:eE});eM(e.draft)}await tg(),ed.success(ec("common.success"))}catch(e){ed.error(ec("common.error"))}},tK=(e,t)=>{e0(r=>[{id:"".concat(Date.now()),content:e,prompt:t,createdAt:Date.now()},...r].slice(0,12))},tU=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e&&eq(""),eQ(null),eJ(null),eZ({start:0,end:0})},tV=(e,t)=>{var r,s;return{title:(null==ez?void 0:ez.title)||"未命名文档",markdown:t,instruction:e,facts:null==ez||null==(r=ez.structuredFacts)?void 0:r.map(e=>"".concat(e.key,": ").concat(e.value)),chapters:null==ez||null==(s=ez.chapters)?void 0:s.map(e=>e.title),...(()=>{let e=eY.start,t=eY.end;return t>e?{selection:{start:e,end:t,text:eE.slice(e,t)},cursorOffset:e}:{cursorOffset:e}})()}},tQ=async()=>{let e=eW.trim();if(!ez||!e||eH)return;let t=tx.current+1;tx.current=t,eO(!0),eU("planning"),eJ(null);try{let r=await (0,V.Gi)({mode:"plan",...tV(e,eE)});if(tx.current!==t||eD!=eD)return;if(!r.plan)throw Error("AI 未返回修改计划");eQ(r.plan)}catch(e){tx.current===t&&ed.error(e instanceof Error?e.message:ec("common.error"))}finally{tx.current===t&&(eO(!1),eU("idle"))}},tX=async e=>{let t=eW.trim();if(!ez||!t||eH)return;let r=tx.current+1;tx.current=r,eO(!0),eU("applying");try{let s=await (0,V.Gi)({mode:"apply",...tV(t,eE),plan:e});if(tx.current!==r||eD!=eD)return;if(!s.markdown)throw Error("AI 未返回修改结果");eJ({plan:s.plan||e,markdown:s.markdown,beforeSnippet:s.beforeSnippet,afterSnippet:s.afterSnippet,summary:s.summary,changedChars:s.changedChars,prompt:t,before:eE})}catch(e){tx.current===r&&ed.error(e instanceof Error?e.message:ec("common.error"))}finally{tx.current===r&&(eO(!1),eU("idle"))}};if(eC)return(0,s.jsxs)("div",{className:"space-y-5 animateFadeIn",children:[(0,s.jsx)(p.A,{active:!0,title:!0,paragraph:{rows:1}}),(0,s.jsx)(p.A,{active:!0,paragraph:{rows:2}}),(0,s.jsx)(p.A,{active:!0,paragraph:{rows:8}})]});let tJ="workflow"===ti?"工作流:".concat((null==tv?void 0:tv.name)||"选择模板"):"编辑:".concat((null==ez?void 0:ez.title)||(null==tv?void 0:tv.outputTitle)||"文档");return(0,s.jsxs)("div",{className:"space-y-5 animateFadeIn",children:[(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-end justify-between gap-4 pb-6 mb-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("h1",{className:"text-3xl font-extrabold tracking-tight text-[var(--colorText)] mb-2.5 flex items-center gap-2",children:[(0,s.jsx)(S.A,{className:"text-[var(--colorAccent)]"}),ec("documents.title")]}),(0,s.jsx)("p",{className:"text-sm text-[var(--colorTextSecondary)]",children:ec("documents.description")})]}),(0,s.jsx)(m.Ay,{type:"primary",icon:(0,s.jsx)(G.A,{}),onClick:()=>tM(),className:"shadow-none rounded-lg",children:ec("documents.newTemplate")})]}),(0,s.jsxs)("div",{className:"bg-[var(--colorBgContainer)] rounded-2xl shadow-sm overflow-hidden",children:[(0,s.jsx)(x.A,{items:[{key:"templates",label:(0,s.jsxs)("span",{className:"px-4",children:["模板库 ",(0,s.jsx)(u.A,{className:"ml-2 border-0 bg-[var(--colorFillAlter)]",children:em.length})]})},{key:"drafts",label:(0,s.jsxs)("span",{className:"px-4",children:["生成记录 ",(0,s.jsx)(u.A,{className:"ml-2 border-0 bg-[var(--colorFillAlter)]",children:eF.length})]})}],activeKey:ta,onChange:tl,className:"documents-tabs",size:"large",tabBarStyle:{margin:0,padding:"0 16px",background:"var(--colorBgHover)",borderBottom:"1px solid var(--borderColor)"}}),(0,s.jsx)("div",{className:"p-4 bg-[var(--colorFillAlter)] min-h-[500px]",children:"templates"===ta?0===em.length?(0,s.jsx)("div",{className:"py-32 text-center border border-dashed border-[var(--borderColor)] rounded-2xl bg-[var(--colorBgContainer)]",children:(0,s.jsx)(h.A,{description:(0,s.jsx)("span",{className:"text-[var(--colorTextSecondary)]",children:ec("common.noData")})})}):(0,s.jsx)("div",{className:"grid grid-cols-1 gap-4",children:em.map(e=>(0,s.jsxs)("div",{className:"group flex items-center p-4 rounded-2xl transition-all cursor-pointer ".concat(eh===e.id?"bg-[var(--colorBgSelected)] shadow-md":"bg-[var(--colorBgContainer)] hover:bg-[var(--colorBgHover)] shadow-sm hover:shadow-md"),onClick:()=>eg(e.id),children:[(0,s.jsxs)("div",{className:"flex-1 min-w-0 pr-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-2 min-w-0",children:[function(e,t){let r=es[e]||(0,s.jsx)(F.A,{});return(0,s.jsx)("span",{style:{color:t?"var(--colorAccent)":"var(--colorTextSecondary)",fontSize:16,marginTop:2,flexShrink:0},children:r})}(e.category,eh===e.id),(0,s.jsx)("span",{className:"font-bold text-base text-[var(--colorText)] truncate",children:e.name}),eh===e.id&&(0,s.jsx)(u.A,{color:"blue",className:"border-0 m-0 shrink-0",children:"当前选中"}),(0,s.jsx)(u.A,{className:"border-0 bg-[var(--colorFillSecondary)] m-0 shrink-0",children:e.category})]}),e.description&&(0,s.jsx)("div",{className:"text-sm text-[var(--colorTextSecondary)] line-clamp-2 leading-relaxed mb-3",children:e.description}),e8[e.id]&&(0,s.jsxs)("div",{onClick:e=>e.stopPropagation(),className:"flex flex-col items-start gap-2",children:[(0,s.jsxs)("div",{className:"inline-flex items-center gap-2 p-1.5 px-3 rounded-lg border text-xs ".concat(e8[e.id].issues.some(e=>"error"===e.level)?"border-red-200 bg-red-50/50":e8[e.id].issues.length?"border-yellow-200 bg-yellow-50/50":"border-green-200 bg-green-50/50"),children:[(0,s.jsx)("span",{className:"font-medium",children:e8[e.id].issues.some(e=>"error"===e.level)?"检查未通过":e8[e.id].issues.length?"存在警告":"检查通过"}),(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"|"}),(0,s.jsxs)("span",{children:["项目资料 ",e8[e.id].fileDiagnostics.length]}),(0,s.jsxs)("span",{children:["提示词 ",e8[e.id].promptDiagnostics.length]}),!e8[e.id].issues.some(e=>"error"===e.level)&&e8[e.id].issues.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"|"}),(0,s.jsx)("span",{className:"text-blue-500 cursor-pointer hover:underline",onClick:()=>{t_(e.id)},children:"忽略警告并运行"})]})]}),e8[e.id].promptDiagnostics.length>0&&(0,s.jsxs)("div",{className:"flex max-w-full flex-col gap-1 rounded-lg border border-[var(--borderColor)] bg-[var(--colorFillQuaternary)] px-3 py-2 text-xs text-[var(--colorTextSecondary)]",children:[(0,s.jsx)("span",{className:"font-medium text-[var(--colorText)]",children:"实际提示词绑定"}),e8[e.id].promptDiagnostics.slice(0,3).map(e=>(0,s.jsxs)("div",{className:"max-w-full truncate",title:"".concat(e.roleName||e.roleId," -> ").concat(e.promptId,"\n").concat(e.contentPreview||""),children:[e.roleName||e.roleId," → ",e.promptId," \xb7 ",e.promptTitle||"未命名提示词"," \xb7 ",e.contentLength," 字符",e.contentHash?" \xb7 ".concat(e.contentHash):""]},"".concat(e.roleId,"-").concat(e.promptId))),e8[e.id].promptDiagnostics.length>3&&(0,s.jsxs)("span",{children:["另有 ",e8[e.id].promptDiagnostics.length-3," 个提示词绑定"]})]})]})]}),(0,s.jsxs)("div",{className:"flex shrink-0 flex-nowrap items-center gap-2 whitespace-nowrap transition-opacity ".concat(eh===e.id?"opacity-100":"opacity-0 group-hover:opacity-100"),onClick:e=>e.stopPropagation(),children:[(0,s.jsx)(m.Ay,{size:"small",onClick:t=>{t.stopPropagation(),tM(e)},className:"rounded-md",children:"配置"}),(0,s.jsx)(m.Ay,{size:"small",icon:(0,s.jsx)(W.A,{}),onClick:t=>{t.stopPropagation(),tB(e.id)},className:"rounded-md"}),(0,s.jsx)(Y,{title:ec("documents.deleteTemplateConfirm"),onConfirm:t=>{null==t||t.stopPropagation(),tF(e.id)},children:(0,s.jsx)(m.Ay,{size:"small",danger:!0,icon:(0,s.jsx)(P.A,{}),onClick:e=>e.stopPropagation(),className:"rounded-md"})}),(0,s.jsx)(m.Ay,{size:"small",type:"primary",icon:td===e.id?(0,s.jsx)(D.A,{}):(0,s.jsx)(q.A,{}),loading:td===e.id,disabled:!!td&&td!==e.id,onClick:t=>{t.stopPropagation(),t_(e.id)},className:"min-w-[72px] rounded-md justify-center",children:td===e.id?"准备中":"运行"})]})]},e.id))}):0===eF.length?(0,s.jsx)("div",{className:"py-32 text-center border border-dashed border-[var(--borderColor)] rounded-2xl bg-[var(--colorBgContainer)]",children:(0,s.jsx)(h.A,{description:(0,s.jsx)("span",{className:"text-[var(--colorTextSecondary)]",children:ec("common.noData")})})}):(0,s.jsx)("div",{className:"grid grid-cols-1 gap-4",children:eF.slice(0,15).map((e,t)=>{var r,a,l,n,o,i,c,d,p,x;let h,g;return(0,s.jsxs)("div",{className:"group flex items-center gap-4 p-4 rounded-2xl transition-all cursor-pointer ".concat(eD===e.id?"bg-[var(--colorBgSelected)] shadow-md":"bg-[var(--colorBgContainer)] hover:bg-[var(--colorBgHover)] shadow-sm hover:shadow-md"),onClick:()=>{tk(e)},children:[(0,s.jsx)("div",{className:"mt-1",children:"completed"===e.status?(0,s.jsx)(M.A,{className:"text-xl text-[var(--colorOk)]"}):"failed"===e.status||"aborted"===e.status?(0,s.jsx)(L.A,{className:"text-xl text-[var(--colorDanger)]"}):"warning"===e.status?(0,s.jsx)(z.A,{className:"text-xl text-[var(--colorWarning)]"}):(0,s.jsx)(H.A,{spin:!0,className:"text-xl text-blue-500"})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0 pr-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-2",children:[(0,s.jsx)("span",{className:"font-bold text-base text-[var(--colorText)] truncate",children:e.title}),(0,s.jsxs)(u.A,{className:"border-0 bg-[var(--colorFillSecondary)] m-0 shrink-0",children:["#",t+1]}),(0,s.jsx)(u.A,{color:"completed"===(h=e.status)?"success":"warning"===h?"warning":"failed"===h?"error":"aborted"===h?"default":"processing",className:"border-0 m-0 shrink-0",children:"completed"===(g=e.status)?"已完成":"warning"===g?"需复核":"failed"===g?"失败":"aborted"===g?"已中止":"生成中"})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-x-4 gap-y-2 text-xs text-[var(--colorTextSecondary)] mb-3",children:[(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,s.jsx)(O.A,{})," ",new Date(e.updatedAt).toLocaleString()]}),(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"|"}),(0,s.jsxs)("span",{children:["耗时 ",(e=>{let t=Math.max(0,Math.round(((e.completedAt||e.updatedAt)-e.createdAt)/1e3));if(t<60)return"".concat(t," 秒");let r=Math.floor(t/60),s=t%60;if(r<60)return s?"".concat(r," 分 ").concat(s," 秒"):"".concat(r," 分");let a=Math.floor(r/60),l=r%60;return l?"".concat(a," 小时 ").concat(l," 分"):"".concat(a," 小时")})(e)]}),e.partialChapters&&e.partialChapters.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"|"}),(0,s.jsxs)("span",{children:["进度 ",e.partialChapters.filter(e=>"completed"===e.status).length,"/",e.partialChapters.length," 章"]}),(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"|"}),(0,s.jsxs)("span",{children:["共 ",e.partialChapters.reduce((e,t)=>e+t.chars,0).toLocaleString()," 字"]})]})]}),("warning"===e.status||"failed"===e.status||"aborted"===e.status)&&(0,s.jsxs)("div",{className:"inline-flex items-center gap-2 p-1.5 px-3 rounded-lg border text-xs ".concat("failed"===e.status||"aborted"===e.status?"border-red-200 bg-red-50/50":"border-yellow-200 bg-yellow-50/50"),children:[(0,s.jsx)("span",{className:"font-medium",children:"failed"===e.status?(null==(a=e.draft)||null==(r=a.exportGate)?void 0:r.passed)===!1?"门禁未通过":"生成失败":"aborted"===e.status?"已中止":"需复核"}),(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"|"}),(0,s.jsx)("span",{className:"truncate max-w-[400px]",children:e.error||(null==(l=e.warningIssues)?void 0:l[0])||(null==(o=e.draft)||null==(n=o.validationIssues.find(e=>"error"===e.level||"warning"===e.level))?void 0:n.message)||(null==(d=e.draft)||null==(c=d.exportGate)||null==(i=c.checklist.find(e=>!e.passed))?void 0:i.label)||"需复核"})]})]}),(0,s.jsxs)("div",{className:"flex shrink-0 flex-nowrap items-center gap-2 whitespace-nowrap transition-opacity ".concat(eD===e.id?"opacity-100":"opacity-0 group-hover:opacity-100"),onClick:e=>e.stopPropagation(),children:[(0,s.jsx)(m.Ay,{size:"small",type:"primary",icon:tS(e.status)?(0,s.jsx)(H.A,{spin:!0}):(0,s.jsx)(q.A,{}),onClick:t=>{t.stopPropagation(),tk(e)},className:"min-w-[72px] rounded-md justify-center",children:"打开"}),tS(e.status)&&(0,s.jsx)(Y,{title:"确定中止此生成任务?",onConfirm:t=>{null==t||t.stopPropagation(),tq(e)},children:(0,s.jsx)(m.Ay,{size:"small",danger:!0,onClick:e=>e.stopPropagation(),className:"rounded-md",children:"中止"})}),("failed"===e.status||"aborted"===e.status||"warning"===e.status&&!!(null==(p=e.checkpointChapters)?void 0:p.length)&&/继续生成|重新生成|中断|卡住|未完成/u.test(e.error||(null==(x=e.warningIssues)?void 0:x.join(";"))||""))&&(0,s.jsx)(m.Ay,{size:"small",onClick:t=>{t.stopPropagation(),tW(e)},className:"rounded-md",children:"继续"}),(0,s.jsx)(Y,{title:"确认删除?",onConfirm:t=>{null==t||t.stopPropagation(),tD(e)},children:(0,s.jsx)(m.Ay,{size:"small",danger:!0,icon:(0,s.jsx)(P.A,{}),onClick:e=>e.stopPropagation(),className:"rounded-md"})})]})]},e.id)})})})]}),(0,s.jsx)(g.A,{title:tJ,open:tn,onClose:()=>{to(!1),tp.current&&(clearInterval(tp.current),tp.current=null)},size:"large",mask:{closable:!1},style:{borderRadius:"12px 0 0 12px"},styles:{body:{padding:"16px 24px"},header:{borderRadius:"12px 0 0 0",borderBottom:"1px solid var(--colorBorderSecondary)"}},extra:ez?(0,s.jsxs)(i.A,{wrap:!0,children:[(0,s.jsx)(m.Ay,{icon:(0,s.jsx)(K.A,{}),disabled:eH,onClick:()=>{tO()},children:ec("documents.saveDraft")}),(0,s.jsx)(m.Ay,{icon:(0,s.jsx)(U.A,{}),disabled:eH,loading:"markdown"===eL,onClick:()=>{tH("markdown")},children:"MD"}),(0,s.jsx)(m.Ay,{disabled:eH,loading:"html"===eL,onClick:()=>{tH("html")},children:"HTML"}),(0,s.jsx)(m.Ay,{disabled:eH,loading:"docx"===eL,onClick:()=>{tH("docx")},children:"DOCX"}),(0,s.jsx)(m.Ay,{type:"primary",disabled:eH,loading:"pdf"===eL,onClick:()=>{tH("pdf")},children:"PDF"})]}):eT&&"workflow"===ti?(0,s.jsx)(m.Ay,{danger:!0,onClick:()=>{(async()=>{if(eD&&await (0,V.r)(eD,e4||void 0).catch(()=>void 0),ee){var e;ee.aborted=!0,null==(e=ee.pollController)||e.abort(),ee.loading=!1,ee.error="用户中止",et(),ee=null}localStorage.removeItem(th),tp.current&&(clearInterval(tp.current),tp.current=null),eR(!1),e9([]),tt(null),to(!1),await tg(),ed.info("已中止生成任务")})()},children:"中止任务"}):void 0,children:(0,s.jsxs)($,{style:{width:"100%"},gap:16,children:["workflow"===ti&&e7.length>0&&(0,s.jsx)($,{gap:10,children:e7.map((e,t)=>{let r;return(0,s.jsxs)("div",{style:{display:"flex",gap:10,padding:10,border:"1px solid var(--colorBorderSecondary)",borderRadius:10,background:t===tf?"var(--colorFillAlter)":"var(--colorBgContainer)"},children:[(0,s.jsx)("span",{children:"process"===e.status?(0,s.jsx)(D.A,{}):"warning"===e.status?(0,s.jsx)(z.A,{style:{color:"var(--colorWarning)"}}):e.icon}),(0,s.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,s.jsxs)(i.A,{wrap:!0,children:[(0,s.jsx)(J,{strong:!0,children:e.title}),(0,s.jsx)(u.A,{color:"finish"===e.status?"success":"error"===e.status?"error":"warning"===e.status?"warning":"process"===e.status?"processing":"default",children:"warning"===(r=e.status)?"finish":r})]}),(0,s.jsx)("div",{style:{marginTop:4,color:"var(--colorTextSecondary)",fontSize:12,whiteSpace:"pre-wrap"},children:(0,s.jsxs)("div",{children:[e.subtitle&&(0,s.jsx)("div",{style:{marginBottom:4},children:(0,s.jsx)(u.A,{children:e.subtitle})}),(0,s.jsx)("div",{children:e.description}),(0,s.jsx)("div",{style:{marginTop:4},children:e.subSteps.map(e=>{var t;return(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,fontSize:12,color:"process"===e.status?"var(--colorPrimary)":"var(--colorTextSecondary)"},children:["process"===(t=e.status)?(0,s.jsx)(D.A,{}):"finish"===t?(0,s.jsx)(M.A,{}):"warning"===t?(0,s.jsx)(z.A,{style:{color:"var(--colorWarning)"}}):"error"===t?(0,s.jsx)(P.A,{}):(0,s.jsx)("span",{style:{display:"inline-block",height:6,width:6,borderRadius:"50%",background:"var(--colorTextTertiary)"}}),(0,s.jsx)("span",{children:e.title})]},e.key)})})]})})]})]},e.key)})}),"workflow"===ti&&(null==tr?void 0:tr.partialChapters)&&tr.partialChapters.length>0&&(0,s.jsx)(v.A,{size:"small",title:"章节进度",extra:(0,s.jsxs)(u.A,{color:"blue",children:[tr.partialChapters.filter(e=>"completed"===e.status).length,"/",tr.partialChapters.length]}),children:(0,s.jsx)($,{gap:6,style:{width:"100%"},children:tr.partialChapters.map(e=>(0,s.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",gap:8,fontSize:12},children:[(0,s.jsx)(J,{ellipsis:!0,style:{maxWidth:480},children:e.title}),(0,s.jsxs)(i.A,{size:6,children:[(0,s.jsx)(u.A,{color:"failed"===e.status?"error":"success",children:"failed"===e.status?"失败":"完成"}),(0,s.jsxs)(J,{type:"secondary",children:[e.chars.toLocaleString()," 字"]})]})]},e.id))})}),"workflow"===ti&&(null==tr||null==(t=tr.draft)||null==(e=t.exportGate)?void 0:e.passed)===!1&&(0,s.jsx)(Z,{type:"error",title:"生成已完成,但导出门禁未通过",children:"阻断项:".concat((null==(r=tr.draft.exportGate.blockingIssues)?void 0:r.slice(0,6).map(e=>e.message).join(";"))||tr.draft.exportGate.checklist.filter(e=>!e.passed).map(e=>e.label).join(";")||"存在阻断级校验错误","。可点击继续生成触发自动修复,或在“校验”页查看完整问题。")}),"workflow"===ti&&(null==tr||null==(l=tr.reviewMetadata)?void 0:l.diagnostics)&&(0,s.jsx)(Z,{type:"info",title:"后台自动优化",children:"策略:".concat(tr.reviewMetadata.diagnostics.strategy.mode,";LLM 调用 ").concat(tr.reviewMetadata.diagnostics.llm.calls," 次;噪声过滤 ").concat((null==(o=tr.reviewMetadata.diagnostics.evidence)?void 0:o.filteredNoise)||0," 条;质量门禁 阻断").concat((null==(R=tr.reviewMetadata.diagnostics.quality)?void 0:R.blockingCount)||0,"/重要").concat((null==(_=tr.reviewMetadata.diagnostics.quality)?void 0:_.importantCount)||0,"/轻微").concat((null==(ei=tr.reviewMetadata.diagnostics.quality)?void 0:ei.minorCount)||0,";自动限流调整 ").concat(tr.reviewMetadata.diagnostics.llm.limitAdjustments," 次。审查与诊断信息仅用于系统修复,不会写入正文或导出文件。")}),"workflow"===ti&&eT&&0===e7.length&&(0,s.jsxs)("div",{style:{textAlign:"center",padding:40},children:[(0,s.jsx)(j.A,{}),(0,s.jsx)("div",{style:{marginTop:12,color:"var(--colorTextSecondary)"},children:"正在准备生成…"})]}),ez&&(0,s.jsx)("div",{ref:ep,children:(0,s.jsx)(x.A,{items:[{key:"edit",label:ec("documents.edit"),children:(0,s.jsxs)($,{gap:16,style:{width:"100%"},children:[(0,s.jsx)(X,{rows:28,value:eE,disabled:eH,onSelect:e=>{var t,r,s;return eZ({start:null!=(t=e.currentTarget.selectionStart)?t:0,end:null!=(s=null!=(r=e.currentTarget.selectionEnd)?r:e.currentTarget.selectionStart)?s:0})},onChange:e=>{var t,r,s;eB(e.target.value),eQ(null),eJ(null),eZ({start:null!=(t=e.target.selectionStart)?t:0,end:null!=(s=null!=(r=e.target.selectionEnd)?r:e.target.selectionStart)?s:0})}}),(0,s.jsx)(v.A,{size:"small",style:{borderRadius:12,background:"linear-gradient(135deg, var(--colorFillAlter), var(--colorBgContainer))"},children:(0,s.jsxs)($,{gap:16,style:{width:"100%"},children:[(0,s.jsxs)(i.A,{align:"start",style:{width:"100%",justifyContent:"space-between"},children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)(i.A,{size:6,children:[(0,s.jsx)(E.A,{style:{color:"var(--colorAccent)"}}),(0,s.jsx)(J,{strong:!0,children:"精准修改"}),(0,s.jsx)(u.A,{color:"blue",children:"AI 辅助"})]}),(0,s.jsx)("div",{style:{marginTop:4,color:"var(--colorTextSecondary)",fontSize:12},children:"针对当前编辑内容补充更具体的要求,AI 会保留文档结构并按你的提示细化修改。"})]}),(0,s.jsxs)(m.Ay,{size:"small",icon:(0,s.jsx)(O.A,{}),onClick:()=>e2(e=>!e),disabled:0===e$.length,children:["历史版本 ",e$.length>0?e$.length:""]})]}),(0,s.jsx)(Z,{type:"info",title:"系统只负责识别修改范围,不改写你的提示词;选中文字后优先只改选区,没有选区时按光标所在小节/章节定位。"}),(0,s.jsx)(X,{rows:4,value:eW,disabled:eH,onChange:e=>{eq(e.target.value),eQ(null),eJ(null)},placeholder:"例如:写细一点;润色这段;第七章补充高处作业和临电安全措施;把安全检查频次改成每周一次。"}),(0,s.jsxs)(i.A,{wrap:!0,style:{width:"100%",justifyContent:"space-between"},children:[(0,s.jsx)(i.A,{wrap:!0,children:["写细一点","更专业","只润色选区","补充可执行措施"].map(e=>(0,s.jsx)(m.Ay,{size:"small",disabled:eH,onClick:()=>eq(t=>t?"".concat(t,";").concat(e):e),children:e},e))}),(0,s.jsx)(m.Ay,{type:"primary",icon:(0,s.jsx)(E.A,{}),loading:eH&&"planning"===eK,disabled:!eW.trim()||eH,onClick:()=>{tQ()},children:"识别修改范围"})]}),eV&&!eX&&(0,s.jsx)(v.A,{size:"small",style:{borderRadius:10,borderColor:"var(--colorAccent)"},children:(0,s.jsxs)($,{gap:8,style:{width:"100%"},children:[(0,s.jsxs)(i.A,{wrap:!0,children:[(0,s.jsx)(u.A,{color:"purple",children:eV.scope}),(0,s.jsx)(u.A,{color:"blue",children:eV.action}),(0,s.jsxs)(u.A,{color:eV.confidence>=.8?"green":"orange",children:["置信度 ",Math.round(100*eV.confidence),"%"]}),eV.targetTitle&&(0,s.jsx)(J,{strong:!0,children:eV.targetTitle})]}),(0,s.jsx)(J,{children:eV.summary}),(0,s.jsx)(J,{type:"secondary",style:{fontSize:12},children:"将按你的原始提示词执行,不添加额外编辑任务。"}),(0,s.jsxs)(i.A,{children:[(0,s.jsx)(m.Ay,{type:"primary",loading:eH&&"applying"===eK,onClick:()=>{tX(eV)},children:"执行并预览"}),(0,s.jsx)(m.Ay,{disabled:eH,onClick:()=>eQ(null),children:"取消"})]})]})}),eX&&(0,s.jsx)(v.A,{size:"small",style:{borderRadius:10,borderColor:"var(--colorSuccess)"},children:(0,s.jsxs)($,{gap:8,style:{width:"100%"},children:[(0,s.jsxs)(i.A,{wrap:!0,children:[(0,s.jsx)(u.A,{color:"green",children:"修改预览"}),(0,s.jsx)(J,{children:eX.summary||eX.plan.summary}),(0,s.jsxs)(u.A,{children:[eX.changedChars&&eX.changedChars>0?"+".concat(eX.changedChars):eX.changedChars," 字符"]})]}),(0,s.jsxs)(f.A,{gutter:12,children:[(0,s.jsxs)(y.A,{span:12,children:[(0,s.jsx)(J,{strong:!0,children:"修改前"}),(0,s.jsx)("div",{style:{marginTop:6,maxHeight:180,overflow:"auto",padding:10,borderRadius:8,background:"var(--colorFillAlter)",whiteSpace:"pre-wrap",fontSize:12},children:eX.beforeSnippet||"无片段预览"})]}),(0,s.jsxs)(y.A,{span:12,children:[(0,s.jsx)(J,{strong:!0,children:"修改后"}),(0,s.jsx)("div",{style:{marginTop:6,maxHeight:180,overflow:"auto",padding:10,borderRadius:8,background:"var(--colorFillAlter)",whiteSpace:"pre-wrap",fontSize:12},children:eX.afterSnippet||"无片段预览"})]})]}),(0,s.jsxs)(i.A,{children:[(0,s.jsx)(m.Ay,{type:"primary",onClick:()=>{eX&&(tK(eX.before,eX.prompt),eB(eX.markdown),tU(!0),ed.success("已应用精准修改"))},children:"应用到文档"}),(0,s.jsx)(m.Ay,{onClick:()=>eJ(null),children:"返回计划"}),(0,s.jsx)(m.Ay,{danger:!0,onClick:()=>{eQ(null),eJ(null)},children:"放弃"})]})]})}),e1&&(0,s.jsx)("div",{style:{borderTop:"1px solid var(--colorBorderSecondary)",paddingTop:12},children:(0,s.jsx)(w.A,{size:"small",dataSource:e$,locale:{emptyText:"暂无历史版本"},renderItem:e=>(0,s.jsx)(w.A.Item,{actions:[(0,s.jsx)(m.Ay,{size:"small",disabled:eH,onClick:()=>{tK(eE,"恢复前版本"),eB(e.content),tU(!0),ed.success("已恢复历史版本")},children:"恢复"},"restore")],children:(0,s.jsx)(w.A.Item.Meta,{title:(0,s.jsxs)(i.A,{children:[(0,s.jsx)(J,{children:new Date(e.createdAt).toLocaleString()}),(0,s.jsx)(u.A,{children:e.prompt})]}),description:(0,s.jsx)(J,{type:"secondary",ellipsis:!0,children:e.content.replace(/\s+/gu," ").slice(0,120)})})})})})]})})]})},{key:"chapters-facts",label:"章节与事实",children:(0,s.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[ez.chapters.length>0&&(0,s.jsxs)("div",{children:[(0,s.jsxs)(J,{strong:!0,style:{fontSize:13,marginBottom:8,display:"block"},children:["章节 (",ez.chapters.length,")"]}),(0,s.jsx)(w.A,{size:"small",dataSource:ez.chapters,renderItem:e=>(0,s.jsx)(w.A.Item,{children:(0,s.jsx)(w.A.Item.Meta,{title:e.title,description:"证据: ".concat(e.evidence.length," \xb7 缺失: ").concat(e.missingFacts.length)})})})]}),ez.structuredFacts.length>0&&(0,s.jsxs)("div",{children:[(0,s.jsxs)(J,{strong:!0,style:{fontSize:13,marginBottom:8,display:"block"},children:["结构化事实 (",ez.structuredFacts.length,")"]}),(0,s.jsx)(b.A,{size:"small",column:1,bordered:!0,children:ez.structuredFacts.map((e,t)=>(0,s.jsxs)(b.A.Item,{label:e.key,children:[(0,s.jsx)("span",{children:e.value}),(0,s.jsx)(u.A,{style:{marginLeft:8},children:e.confidence.toFixed(2)}),(0,s.jsx)(J,{type:"secondary",style:{fontSize:11,marginLeft:8},children:e.sourceFile})]},t))})]})]})},{key:"sources-missing",label:"来源与缺失",children:(0,s.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)(J,{strong:!0,style:{fontSize:13,marginBottom:8,display:"block"},children:["引用来源 (",ez.sources.length,")"]}),0===ez.sources.length?(0,s.jsx)(h.A,{description:"暂无"}):(0,s.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:ez.sources.map(e=>(0,s.jsxs)(u.A,{color:"blue",children:[e.filePath," (",e.count,")"]},e.filePath))})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)(J,{strong:!0,style:{fontSize:13,marginBottom:8,display:"block"},children:["缺失项 (",ez.missingItems.length,")"]}),0===ez.missingItems.length?(0,s.jsx)(h.A,{description:"无缺失"}):(0,s.jsx)(w.A,{size:"small",dataSource:ez.missingItems,renderItem:e=>(0,s.jsx)(w.A.Item,{children:e})})]})]})},{key:"validation",label:"校验 (".concat(ez.validationIssues.length,")"),children:0===ez.validationIssues.length?(0,s.jsx)(h.A,{description:"校验通过"}):(0,s.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[ez.validationIssues.map(e=>(0,s.jsxs)("div",{style:{border:"1px solid var(--colorBorderSecondary)",borderRadius:8,padding:12},children:[(0,s.jsx)(u.A,{color:"error"===e.level?"error":"warning"===e.level?"warning":"blue",children:e.level}),(0,s.jsx)("div",{style:{marginTop:6,whiteSpace:"pre-wrap",overflowWrap:"anywhere",wordBreak:"break-all",lineHeight:1.6},children:e.message}),e.suggestion&&(0,s.jsx)("div",{style:{marginTop:6,color:"var(--colorTextSecondary)",whiteSpace:"pre-wrap",overflowWrap:"anywhere",wordBreak:"break-all"},children:e.suggestion})]},"".concat(e.level,"-").concat(e.message))),ez.exportGate.checklist.length>0&&(0,s.jsxs)("div",{style:{marginTop:8},children:[(0,s.jsx)(J,{strong:!0,style:{fontSize:13,marginBottom:8,display:"block"},children:"导出门禁"}),(0,s.jsx)(w.A,{size:"small",dataSource:ez.exportGate.checklist,renderItem:e=>(0,s.jsxs)(w.A.Item,{children:[(0,s.jsx)(J,{style:{overflowWrap:"anywhere",wordBreak:"break-word"},children:e.label}),(0,s.jsx)(u.A,{color:e.passed?"success":"error",children:e.passed?"PASS":"FAIL"})]})})]})]})},{key:"stages",label:"执行阶段 (".concat(ez.executionStages.length,")"),children:(0,s.jsx)(w.A,{size:"small",dataSource:ez.executionStages,renderItem:e=>(0,s.jsxs)(w.A.Item,{children:[(0,s.jsx)(w.A.Item.Meta,{avatar:er[e.type]||(0,s.jsx)(F.A,{}),title:(0,s.jsx)(J,{title:e.roleId,style:{overflowWrap:"anywhere",wordBreak:"break-word"},children:"".concat(en[e.type]||e.type," \xb7 ").concat(e.roleName||ty(e.roleId))}),description:(0,s.jsx)(J,{type:"secondary",style:{whiteSpace:"pre-wrap",overflowWrap:"anywhere",wordBreak:"break-word"},children:e.message})}),(0,s.jsx)(u.A,{color:"success"===e.status?"success":"failed"===e.status?"error":"skipped"===e.status?"default":"warning",children:e.status})]})})}]})})]})}),(0,s.jsx)(g.A,{title:ec("documents.templateEditor"),open:e6,onClose:()=>e5(!1),size:"large",mask:{closable:!1},styles:{body:{padding:20,overflow:"auto"},header:{borderBottom:"1px solid var(--colorBorderSecondary)"}},extra:(0,s.jsxs)(i.A,{children:[(0,s.jsx)(m.Ay,{onClick:()=>e5(!1),children:ec("common.cancel")}),(0,s.jsx)(m.Ay,{type:"primary",onClick:()=>{tE()},children:ec("common.save")})]}),children:(0,s.jsxs)(d.A,{form:eu,layout:"vertical",requiredMark:"optional",children:[(0,s.jsxs)(f.A,{gutter:12,children:[(0,s.jsx)(d.A.Item,{name:"id",hidden:!0,children:(0,s.jsx)(n.A,{})}),(0,s.jsx)(y.A,{xs:24,md:8,children:(0,s.jsx)(d.A.Item,{name:"name",label:ec("documents.templateName"),rules:[{required:!0}],children:(0,s.jsx)(n.A,{})})}),(0,s.jsx)(y.A,{xs:24,md:8,children:(0,s.jsx)(d.A.Item,{name:"category",label:ec("documents.templateCategory"),children:(0,s.jsx)(n.A,{})})}),(0,s.jsx)(y.A,{xs:24,md:8,children:(0,s.jsx)(d.A.Item,{name:"outputTitle",label:ec("documents.outputTitle"),children:(0,s.jsx)(n.A,{})})}),(0,s.jsx)(y.A,{xs:24,md:12,children:(0,s.jsx)(d.A.Item,{name:"description",label:ec("documents.templateDescription"),children:(0,s.jsx)(n.A,{})})})]}),(0,s.jsx)(d.A.Item,{name:"projectRoleConfigId",label:ec("documents.projectRoleConfig"),rules:[{required:!0,message:ec("documents.projectRoleConfigRequired")}],children:(0,s.jsx)(A.A,{showSearch:!0,placeholder:ec("documents.projectRoleConfigRequired"),options:tj})}),(0,s.jsxs)("div",{className:"mb-6",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(J,{strong:!0,className:"text-base text-[var(--colorText)] block mb-1",children:"项目资料包绑定"}),(0,s.jsx)("div",{className:"text-xs text-[var(--colorTextSecondary)]",children:"直接选择整个项目文件夹,系统会自动识别招标正文、清单、图纸、补疑等资料类型。"})]}),(0,s.jsx)(u.A,{color:"blue",className:"border-0",children:"按项目资料包"})]}),eS?(0,s.jsxs)("div",{className:"text-center py-8",children:[(0,s.jsx)(j.A,{}),(0,s.jsx)("div",{className:"mt-3 text-[var(--colorTextSecondary)] text-xs",children:"正在加载知识库文件…"})]}):0===eA.length?(0,s.jsx)(h.A,{image:h.A.PRESENTED_IMAGE_SIMPLE,description:"暂无知识库文件"}):(0,s.jsx)(d.A.Item,{name:"projectMaterialRoots",rules:[{required:!0,message:"请选择项目资料包"}],children:(0,s.jsx)(k.A,{treeData:eA,loadData:tz,fieldNames:{label:"rawTitle",value:"value",children:"children"},onChange:e=>{var t;return t=e.map(e=>String(e)),void eu.setFieldValue("projectMaterialRoots",ea(t))},treeCheckable:!0,showCheckedStrategy:k.A.SHOW_PARENT,placeholder:"点击这里选择项目文件夹...",style:{width:"100%"},listHeight:360,showSearch:!0,maxTagCount:"responsive",size:"large"})})]})]})})]})}}},e=>{e.O(0,[717,883,665,44,563,7,787,195,455,506,230,636,593,792],()=>e(e.s=16403)),_N_E=e.O()}]);