@customize-agent/server 4.1.6 → 4.1.7

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),l=r(97109),a=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),f=r(42700),j=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),E=r(7851),B=r(84742),z=r(29071),M=r(63552),F=r(26631),_=r(7225),D=r(83914),P=r(58209),L=r(38762),G=r(54746),W=r(93051),O=r(64068),q=r(64629),H=r(1310),V=r(67547),K=r(76830),U=r(6578),Q=r(48321);let{TextArea:X}=n.A,{Text:J}=o.A,Y=a.A;function Z(e){let{type:t="info",title:r,children:l,style:a}=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",...a},children:[(0,s.jsx)(J,{strong:!0,style:{color:n},children:r}),l&&(0,s.jsx)("div",{style:{marginTop:4,color:"var(--colorTextSecondary)",fontSize:12},children:l})]})}function $(e){let{children:t,gap:r=12,style:l}=e;return(0,s.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:r,...l},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)(E.A,{}),formatting:(0,s.jsx)(B.A,{}),llm_review:(0,s.jsx)(z.A,{}),export_ready:(0,s.jsx)(M.A,{}),reference:(0,s.jsx)(R.A,{})},es={施工组织设计:(0,s.jsx)(E.A,{}),投标文件:(0,s.jsx)(M.A,{}),技术方案:(0,s.jsx)(N.A,{}),报告:(0,s.jsx)(F.A,{}),自定义:(0,s.jsx)(T.A,{})};function el(e){return[...new Set(e.map(e=>e.trim()).filter(Boolean))]}function ea(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,a,o;let R=(0,Q.Vr)(),{message:_}=c.A.useApp(),[ei]=d.A.useForm(),ec=(0,l.useRef)(null),[ed,eu]=(0,l.useState)([]),[ep,em]=(0,l.useState)("construction-organization-design"),[ex,eh]=(0,l.useState)([]),[eg,ev]=(0,l.useState)([]),[ef,ej]=(0,l.useState)([]),[ey,ew]=(0,l.useState)([]),[eb,eA]=(0,l.useState)(!1),[ek,eS]=(0,l.useState)(),[eI,eC]=(0,l.useState)(!0),[eN,eT]=(0,l.useState)(!1),[eR,eE]=(0,l.useState)(null),[eB,ez]=(0,l.useState)(""),[eM,eF]=(0,l.useState)([]),[e_,eD]=(0,l.useState)(null),[eP,eL]=(0,l.useState)(null),[eG,eW]=(0,l.useState)(""),[eO,eq]=(0,l.useState)(!1),[eH,eV]=(0,l.useState)("idle"),[eK,eU]=(0,l.useState)(null),[eQ,eX]=(0,l.useState)(null),[eJ,eY]=(0,l.useState)({start:0,end:0}),[eZ,e$]=(0,l.useState)([]),[e0,e1]=(0,l.useState)(!1),[e2,e6]=(0,l.useState)(!1),[e5,e8]=(0,l.useState)({}),e3=d.A.useWatch("projectRoleConfigId",ei),e4=(0,l.useMemo)(()=>eg.find(e=>e.id===e3),[eg,e3]),e7=(0,l.useMemo)(()=>new Set(((null==e4?void 0:e4.fileRoles)||[]).map(e=>e.roleId)),[e4]),e9=(0,l.useMemo)(()=>ex.filter(e=>"file"===e.type&&(!e3||e7.has(e.id))).map(e=>({label:e.name,value:e.id})),[ex,e7,e3]),te=d.A.useWatch("fileBindingGroups",ei)||{},tt=(0,l.useMemo)(()=>{var e,t,r;return(null==(e=ef.find(e=>e.selected))?void 0:e.projectRoot)||(null==(t=ef.find(e=>e.isCurrent))?void 0:t.projectRoot)||(null==(r=ef[0])?void 0:r.projectRoot)||""},[ef]);(0,l.useEffect)(()=>{if(!e2||!e3)return;let e=ei.getFieldValue("fileBindingGroups")||{},t=Object.fromEntries(Object.entries(e).filter(e=>{let[t]=e;return e7.has(t)}));Object.keys(t).length!==Object.keys(e).length&&ei.setFieldValue("fileBindingGroups",t)},[ei,e7,e3,e2]),(0,l.useEffect)(()=>{if(e2){if(0===e9.length)return void eS(void 0);ek&&e9.some(e=>e.value===ek)||eS(e9[0].value)}},[ek,e9,e2]);let[tr,ts]=(0,l.useState)([]),[tl,ta]=(0,l.useState)(null),[tn,to]=(0,l.useState)(null),[ti,tc]=(0,l.useState)("templates"),[td,tu]=(0,l.useState)(!1),[tp,tm]=(0,l.useState)("workflow"),[tx,th]=(0,l.useState)(null),tg=(0,l.useRef)(null),tv=(0,l.useRef)(null),tf=(0,l.useRef)(0),tj=(0,l.useMemo)(()=>"activeGenDocId:".concat(tt||"default"),[tt]),ty=async()=>{try{eF((await (0,U.cQ)(tt||void 0)).documents)}catch(e){eF([])}};(0,l.useEffect)(()=>{let e=()=>{ee&&(ts(ee.flowSteps),ta(ee.activeFlowKey),eT(ee.loading),ee.documentId&&eD(ee.documentId),ee.draft&&eE(ee.draft),void 0!==ee.content&&ez(ee.content))},t=ee;return null==t||t.listeners.add(e),e(),()=>{null==t||t.listeners.delete(e)}},[]),(0,l.useEffect)(()=>{eC(!0),Promise.all([(0,U.Dl)().then(e=>{var t,r;eu(e.templates),em(null!=(r=null==(t=e.templates[0])?void 0:t.id)?r:"construction-organization-design")}),(0,U.lv)().then(e=>{eh(e.roles),ev(e.configs)}),(0,U.dx)().then(e=>ej(e))]).catch(()=>_.error(R("common.error"))).finally(()=>eC(!1))},[_,R]),(0,l.useEffect)(()=>{tt&&(localStorage.removeItem("activeGenDocId"),ty())},[tt]),(0,l.useEffect)(()=>{if(0===eM.length)return;let e=localStorage.getItem(tj);if(!e)return;if(!eM.find(t=>t.id===e&&"generating"===t.status))return void localStorage.removeItem(tj);let t=setInterval(()=>{(async()=>{try{let{document:r}=await (0,U.v7)(e,!1,tt||void 0);await ty(),"generating"!==r.status&&(localStorage.removeItem(tj),clearInterval(t))}catch(e){clearInterval(t)}})()},3e3);return()=>clearInterval(t)},[eM]);let tw=(0,l.useMemo)(()=>ed.find(e=>e.id===ep),[ed,ep]),tb=eg.map(e=>({label:e.name,value:e.id})),tA=Math.max(0,tr.findIndex(e=>e.key===tl)),tk=e=>{var t;return e?(null==(t=ex.find(t=>t.id===e))?void 0:t.name)||eo[e]||"未知角色":""},tS=e=>e.subtitle||e.roleName||tk(e.roleId)||en[e.type]||e.type,tI=e=>{var t,r,s;return e.promptName||((t=e.promptId)?(null==(r=ef.find(e=>e.id===t))?void 0:r.projectName)||(null==(s=ex.find(e=>e.id===t))?void 0:s.name)||eo[t]||"未知提示词":"")},tC=()=>{tf.current+=1,eW(""),eU(null),eX(null),e$([]),e1(!1),eq(!1),eV("idle")},tN=async e=>{eD(e.id),em(e.templateId);let t=tT(e.status);if(t||"failed"===e.status||"aborted"===e.status){tC(),to(e),eE(null),ez(""),eT(t),tm("workflow"),tu(!0);try{let{document:t}=await (0,U.v7)(e.id,!1,e.projectRoot||tt||void 0);tB(t),tT(t.status)?tz(t.id,t.projectRoot||e.projectRoot||tt||void 0):await ty()}catch(t){tB(e)}return}tm("editor"),ts([]),ta(null),tC();try{let{document:t}=await (0,U.v7)(e.id,!1,e.projectRoot||tt||void 0);eE(t.draft||null),ez(t.editedMarkdown||t.markdown)}catch(e){_.error(R("common.error"))}tu(!0)},tT=e=>"completed"!==e&&"warning"!==e&&"failed"!==e&&"aborted"!==e,tR=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:eN;(null==ee?void 0:ee.loading)&&(ee.flowSteps=e,ee.activeFlowKey=t,ee.loading=r,et())},tE=e=>{var t,r,l,a,n;let o=e.executionStages||(null==(t=e.draft)?void 0:t.executionStages)||[];if(o.length>0){let t=o.map((t,r)=>{var l;let a,n=("failed"===e.status||"aborted"===e.status)&&"running"===t.status||"failed"===(a=t.status)?"error":"running"===a?"process":"fallback"===a?"warning":"finish";return{key:"".concat(t.type,"-").concat(r),title:t.title||en[t.type]||t.type,subtitle:tS(t),description:t.message||"",status:n,icon:"role_binding"===(l=t.type)?(0,s.jsx)(S.A,{}):"knowledge_retrieval"===l?(0,s.jsx)(I.A,{}):"file_understanding"===l?(0,s.jsx)(C.A,{}):"fact_extraction"===l?(0,s.jsx)(N.A,{}):"chapter_generation"===l?(0,s.jsx)(T.A,{}):"llm_review"===l?(0,s.jsx)(z.A,{}):"validation"===l?(0,s.jsx)(E.A,{}):"formatting"===l?(0,s.jsx)(B.A,{}):"export_ready"===l?(0,s.jsx)(M.A,{}):(0,s.jsx)(F.A,{}),subSteps:((e,t,r)=>{let s=Array.isArray(e.details)?e.details.filter(Boolean):[],l=e.progress?"".concat(e.progress.label||"进度",":").concat(e.progress.current,"/").concat(e.progress.total):"",a=[...l?[l]:[],...s];return 0===a.length?[{key:"stage-".concat(r),title:tI(e)?"提示词:".concat(tI(e)):tS(e),status:t}]:a.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==(l=t.at(-1))?void 0:l.key)||"prepare":"failed"===e.status||"aborted"===e.status?(null==(a=t.find(e=>"error"===e.status))?void 0:a.key)||(null==(n=t.at(-1))?void 0:n.key)||"prepare":"done";return{steps:t,activeKey:i}}return{steps:[],activeKey:null}},tB=e=>{to(e);let{steps:t,activeKey:r}=tE(e);ts(t),ta(r),eT(tT(e.status)),tR(t,r,tT(e.status)),("failed"===e.status||"aborted"===e.status)&&tm("workflow"),("completed"===e.status||"warning"===e.status)&&e.draft&&(eE(e.draft),ez(e.editedMarkdown||e.markdown),tm("editor"),ts([]),ta(null))},tz=(e,t)=>{tg.current&&clearInterval(tg.current),tg.current=setInterval(()=>{(async()=>{try{let{document:r}=await (0,U.v7)(e,!0,t||tt||void 0);tB(r),await ty(),tT(r.status)||(tg.current&&clearInterval(tg.current),tg.current=null,localStorage.removeItem(tj))}catch(e){}})()},2e3)};(0,l.useEffect)(()=>()=>{tg.current&&(clearInterval(tg.current),tg.current=null),tv.current&&(clearTimeout(tv.current),tv.current=null)},[]),(0,l.useEffect)(()=>{if(!eN||!tl)return;let e=window.setInterval(()=>ts(e=>{let t=e.map(e=>{if(e.key!==tl||"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 tR(t,tl),t}),1400);return()=>window.clearInterval(e)},[tl,eN]);let tM=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";eA(!0);try{let t=await (0,U.Fi)(e,tt||void 0);ew(ea(t.nodes))}catch(e){_.error("知识库文件加载失败")}finally{eA(!1)}},tF=async e=>{var t;let r=String(null!=(t=e.key)?t:"");if(r)try{let e=await (0,U.Fi)(r,tt||void 0),t=ea(e.nodes),s=e=>e.map(e=>e.key===r?{...e,children:t}:e.children?{...e,children:s(e.children)}:e);ew(e=>s(e))}catch(e){_.error("加载子文件夹失败")}},t_=e=>{var t,r,s;let l=null!=e?e:{id:"tpl-".concat(Date.now()),name:"",description:"",category:"自定义",outputTitle:"",projectRoleConfigId:void 0,chapters:[],fileBindings:[]};ei.resetFields(),ei.setFieldsValue({...l,fileBindingGroups:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.reduce((e,t)=>(t.roleId&&t.filePath&&(e[t.roleId]=el([...e[t.roleId]||[],t.filePath])),e),{})}(l.fileBindings)}),eS(null==(s=eg.find(e=>e.id===l.projectRoleConfigId))||null==(r=s.fileRoles)||null==(t=r[0])?void 0:t.roleId),tM(),e6(!0)},tD=(e,t)=>{let r=ei.getFieldValue("fileBindingGroups")||{};ei.setFieldValue("fileBindingGroups",{...r,[e]:el(t)})},tP=async()=>{try{var e;await ei.validateFields();let t=ei.getFieldsValue(!0),r=new Set(((null==(e=eg.find(e=>e.id===t.projectRoleConfigId))?void 0:e.fileRoles)||[]).map(e=>e.roleId)),s=t.fileBindingGroups||{},l=Object.entries(s).filter(e=>{let[t]=e;return 0===r.size||r.has(t)}).flatMap(e=>{let[t,r]=e;return el(r||[]).map(e=>({roleId:t,filePath:e}))}),{fileBindingGroups:a,...n}=t,o={...n,chapters:[],fileBindings:l},i=await (0,U.l2)(o);eu(i.templates),em(i.template.id),e6(!1),await ty(),_.success(R("common.success"))}catch(e){e instanceof Error&&_.error(e.message)}},tL=async e=>{try{let t=await (0,U.bV)(e);eu(t.templates),em(t.template.id),_.success(R("common.success"))}catch(e){_.error(R("common.error"))}},tG=async e=>{try{var t,r;let s=await (0,U.h0)(e);eu(s.templates),em(null!=(r=null==(t=s.templates[0])?void 0:t.id)?r:""),_.success(R("common.success"))}catch(e){_.error(R("common.error"))}},tW=async e=>{th(e),em(e),eD(null),eE(null),ez(""),tC(),tm("workflow"),tu(!0),tc("drafts"),eT(!0),ta("prepare"),ts([{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,U.SM)(e,tt||void 0);e8(r=>({...r,[e]:t}));let r=t.issues.filter(e=>"error"===e.level);if(r.length>0){eT(!1),ta("prepare"),ts([{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"}]}]),_.warning("模板运行前检查未通过,请先处理阻断项");return}t.issues.length>0&&_.warning("模板存在非阻断警告,已继续运行"),ts([{key:"prepare",title:"模板检查通过,正在创建生成任务",description:"已确认模板绑定资源可用,正在启动后台生成任务。",status:"process",icon:(0,s.jsx)(D.A,{}),subSteps:[{key:"validate",title:"模板运行前检查",status:"finish"},{key:"start",title:"准备生成任务",status:"process"}]}]),await tH(e)}catch(t){let e=t instanceof Error?t.message:"模板运行前检查失败";eT(!1),ts([{key:"prepare",title:"模板运行准备失败",description:e,status:"error",icon:(0,s.jsx)(L.A,{}),subSteps:[{key:"validate",title:"模板运行前检查",status:"error"},{key:"start",title:"准备生成任务",status:"wait"}]}]),_.error(e)}finally{th(t=>t===e?null:t)}},tO=async e=>{try{await (0,U.QG)(e.id,e.projectRoot||tt||void 0),e_===e.id&&(eD(null),eE(null),ez("")),await ty(),_.success(R("common.success"))}catch(e){_.error(R("common.error"))}},tq=async(e,t)=>{let r=Date.now(),s=0,l=Date.now();for(;;){let a;if(null==t?void 0:t.aborted)throw Error("用户中止");let n=new AbortController;t&&(t.pollController=n);try{({document:a}=await (0,U.v7)(e,!0,tt||void 0,n.signal))}finally{(null==t?void 0:t.pollController)===n&&(t.pollController=void 0)}if(tB(a),a.updatedAt!==s&&(s=a.updatedAt,l=Date.now()),("completed"===a.status||"warning"===a.status)&&a.draft)return a;if("failed"===a.status||"aborted"===a.status)throw Error(a.error||("aborted"===a.status?"生成已中止":"生成失败"));if(Date.now()-r>75e5||Date.now()-l>96e4)throw Error("生成任务疑似卡住,请点击继续生成或重新生成");await new Promise(e=>window.setTimeout(e,1500))}},tH=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ep;if(!e)return;if((null==ee?void 0:ee.aborted)&&(ee=null),null==ee?void 0:ee.loading){ts(ee.flowSteps),ta(ee.activeFlowKey),eT(!0);return}if(!tt)return void _.error("未识别当前项目,请先选择或打开项目后再生成文件");eT(!0);let t=tr.length>0?tr:[{key:"prepare",title:"正在创建生成任务",description:"系统正在创建后台生成任务,请稍候。",status:"process",icon:(0,s.jsx)(D.A,{}),subSteps:[{key:"start",title:"准备生成任务",status:"process"}]}],r=tl||"prepare";ts(t),ta(r);let l=(0,U.OX)({templateId:e,projectRoot:tt});ee={id:Date.now(),templateId:e,loading:!0,flowSteps:t,activeFlowKey:r,promise:l,listeners:new Set};let a=[];try{let e=await l;e.documentId&&(localStorage.setItem(tj,e.documentId),eD(e.documentId),(null==ee?void 0:ee.promise)===l&&(ee.documentId=e.documentId)),await ty();let t=e.documentId?await tq(e.documentId,(null==ee?void 0:ee.promise)===l?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))&&eD(e.documentId||t.id),a.forEach(e=>window.clearTimeout(e)),eE(r),ez((null==t?void 0:t.editedMarkdown)||(null==t?void 0:t.markdown)||r.markdown),(null==ee?void 0:ee.promise)===l&&(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:ep,title:r.title,requirement:r.requirement,projectRoot:r.projectRoot||tt,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}=tE(s);ts(n),tR(n,"done",!1),ta("done"),(null==ee?void 0:ee.promise)===l&&(ee.activeFlowKey="done",ee.loading=!1,et(),ee=null),localStorage.removeItem(tj),await ty(),_.success(R("common.success")),window.setTimeout(()=>{var e;return null==(e=ec.current)?void 0:e.scrollIntoView({behavior:"smooth",block:"start"})},200)}catch(r){localStorage.removeItem(tj);let e=r instanceof Error?r.message:R("common.error"),t=/用户中止|abort|aborted/i.test(e);t||ts(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 tR(r,tl,!1),r}),(null==ee?void 0:ee.promise)===l&&(ee.loading=!1,ee.error=e,et(),ee=null),await ty().catch(()=>void 0),t||_.error(e)}finally{a.forEach(e=>window.clearTimeout(e)),eT(!1),(null==ee?void 0:ee.promise)===l&&(ee.loading=!1,et())}},tV=(0,l.useRef)(!1);(0,l.useEffect)(()=>(tv.current&&(clearTimeout(tv.current),tv.current=null),!td||"workflow"!==tp||tx||e_||tV.current||(null==ee?void 0:ee.loading)||null==tw||!tw.projectRoleConfigId||(tV.current=!0,tv.current=setTimeout(()=>{tv.current=null,td&&"workflow"===tp&&!e_&&ep==ep&&tH()},300)),td||(tV.current=!1),()=>{tv.current&&(clearTimeout(tv.current),tv.current=null)}),[td,tp,tx,e_,tw,ep]);let tK=async e=>{try{eD(e.id),em(e.templateId),tm("workflow"),tu(!0),eT(!0);let t=await (0,U.UQ)(e.id,e.projectRoot||tt||void 0);localStorage.setItem(tj,t.documentId),await ty();let r=await tq(t.documentId);r.draft&&(eE(r.draft),ez(r.editedMarkdown||r.markdown||r.draft.markdown),tm("editor")),localStorage.removeItem(tj),await ty(),_.success("已继续生成并完成")}catch(e){_.error(e instanceof Error?e.message:"继续生成失败")}finally{eT(!1)}},tU=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,eT(!1)}localStorage.removeItem(tj),tg.current&&(clearInterval(tg.current),tg.current=null);try{await (0,U.r)(e.id,e.projectRoot||tt||void 0),_.success("已中止生成任务")}catch(e){_.info("任务已不在运行,已刷新状态")}finally{await ty(),e_===e.id&&(eD(null),to(null),eE(null),ez(""))}},tQ=async e=>{if(eR){eL(e);try{eR.exportGate.passed||_.warning("导出门禁存在风险项,已允许导出,请下载后人工复核。");let t={documentId:e_||void 0,title:eR.title,markdown:eB,format:e,enforceGate:!1,exportGate:eR.exportGate,useClientMarkdown:!0,projectRoot:eR.projectRoot||tt||void 0},r=await (0,U.UE)(t);((e,t,r)=>{let s=new Blob([e],{type:r}),l=URL.createObjectURL(s),a=document.createElement("a");a.href=l,a.download=t,a.target="_self",a.rel="noopener",a.style.display="none",document.body.appendChild(a),a.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window})),a.remove(),window.setTimeout(()=>URL.revokeObjectURL(l),1e3)})(r,"".concat(eR.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){_.error(e instanceof Error?e.message:R("common.error"))}finally{eL(null)}}},tX=async()=>{if(eR)try{if(e_)await (0,U.a6)(e_,{editedMarkdown:eB,markdown:eB},eR.projectRoot||tt||void 0);else{let e=await (0,U.Af)({...eR,markdown:eB});eE(e.draft)}await ty(),_.success(R("common.success"))}catch(e){_.error(R("common.error"))}},tJ=(e,t)=>{e$(r=>[{id:"".concat(Date.now()),content:e,prompt:t,createdAt:Date.now()},...r].slice(0,12))},tY=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e&&eW(""),eU(null),eX(null),eY({start:0,end:0})},tZ=(e,t)=>{var r,s;return{title:(null==eR?void 0:eR.title)||"未命名文档",markdown:t,instruction:e,facts:null==eR||null==(r=eR.structuredFacts)?void 0:r.map(e=>"".concat(e.key,": ").concat(e.value)),chapters:null==eR||null==(s=eR.chapters)?void 0:s.map(e=>e.title),...(()=>{let e=eJ.start,t=eJ.end;return t>e?{selection:{start:e,end:t,text:eB.slice(e,t)},cursorOffset:e}:{cursorOffset:e}})()}},t$=async()=>{let e=eG.trim();if(!eR||!e||eO)return;let t=tf.current+1;tf.current=t,eq(!0),eV("planning"),eX(null);try{let r=await (0,U.Gi)({mode:"plan",...tZ(e,eB)});if(tf.current!==t||e_!=e_)return;if(!r.plan)throw Error("AI 未返回修改计划");eU(r.plan)}catch(e){tf.current===t&&_.error(e instanceof Error?e.message:R("common.error"))}finally{tf.current===t&&(eq(!1),eV("idle"))}},t0=async e=>{let t=eG.trim();if(!eR||!t||eO)return;let r=tf.current+1;tf.current=r,eq(!0),eV("applying");try{let s=await (0,U.Gi)({mode:"apply",...tZ(t,eB),plan:e});if(tf.current!==r||e_!=e_)return;if(!s.markdown)throw Error("AI 未返回修改结果");eX({plan:s.plan||e,markdown:s.markdown,beforeSnippet:s.beforeSnippet,afterSnippet:s.afterSnippet,summary:s.summary,changedChars:s.changedChars,prompt:t,before:eB})}catch(e){tf.current===r&&_.error(e instanceof Error?e.message:R("common.error"))}finally{tf.current===r&&(eq(!1),eV("idle"))}};if(eI)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 t1="workflow"===tp?"工作流:".concat((null==tw?void 0:tw.name)||"选择模板"):"编辑:".concat((null==eR?void 0:eR.title)||(null==tw?void 0:tw.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)]"}),R("documents.title")]}),(0,s.jsx)("p",{className:"text-sm text-[var(--colorTextSecondary)]",children:R("documents.description")})]}),(0,s.jsx)(m.Ay,{type:"primary",icon:(0,s.jsx)(G.A,{}),onClick:()=>t_(),className:"shadow-none rounded-lg",children:R("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:ed.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:eM.length})]})}],activeKey:ti,onChange:tc,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"===ti?0===ed.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:R("common.noData")})})}):(0,s.jsx)("div",{className:"grid grid-cols-1 gap-4",children:ed.map(e=>(0,s.jsxs)("div",{className:"group flex items-center p-4 rounded-2xl transition-all cursor-pointer ".concat(ep===e.id?"bg-[var(--colorBgSelected)] shadow-md":"bg-[var(--colorBgContainer)] hover:bg-[var(--colorBgHover)] shadow-sm hover:shadow-md"),onClick:()=>em(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,ep===e.id),(0,s.jsx)("span",{className:"font-bold text-base text-[var(--colorText)] truncate",children:e.name}),ep===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}),e5[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(e5[e.id].issues.some(e=>"error"===e.level)?"border-red-200 bg-red-50/50":e5[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:e5[e.id].issues.some(e=>"error"===e.level)?"检查未通过":e5[e.id].issues.length?"存在警告":"检查通过"}),(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"|"}),(0,s.jsxs)("span",{children:["文件角色 ",e5[e.id].fileDiagnostics.length]}),(0,s.jsxs)("span",{children:["提示词 ",e5[e.id].promptDiagnostics.length]}),!e5[e.id].issues.some(e=>"error"===e.level)&&e5[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:()=>{tW(e.id)},children:"忽略警告并运行"})]})]}),e5[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:"实际提示词绑定"}),e5[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))),e5[e.id].promptDiagnostics.length>3&&(0,s.jsxs)("span",{children:["另有 ",e5[e.id].promptDiagnostics.length-3," 个提示词绑定"]})]})]})]}),(0,s.jsxs)("div",{className:"flex shrink-0 flex-nowrap items-center gap-2 whitespace-nowrap transition-opacity ".concat(ep===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(),t_(e)},className:"rounded-md",children:"配置"}),(0,s.jsx)(m.Ay,{size:"small",icon:(0,s.jsx)(W.A,{}),onClick:t=>{t.stopPropagation(),tL(e.id)},className:"rounded-md"}),(0,s.jsx)(Y,{title:R("documents.deleteTemplateConfirm"),onConfirm:t=>{null==t||t.stopPropagation(),tG(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:tx===e.id?(0,s.jsx)(D.A,{}):(0,s.jsx)(O.A,{}),loading:tx===e.id,disabled:!!tx&&tx!==e.id,onClick:t=>{t.stopPropagation(),tW(e.id)},className:"min-w-[72px] rounded-md justify-center",children:tx===e.id?"准备中":"运行"})]})]},e.id))}):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:R("common.noData")})})}):(0,s.jsx)("div",{className:"grid grid-cols-1 gap-4",children:eM.slice(0,15).map((e,t)=>{var r,l,a,n,o;let i,c;return(0,s.jsxs)("div",{className:"group flex items-center gap-4 p-4 rounded-2xl transition-all cursor-pointer ".concat(e_===e.id?"bg-[var(--colorBgSelected)] shadow-md":"bg-[var(--colorBgContainer)] hover:bg-[var(--colorBgHover)] shadow-sm hover:shadow-md"),onClick:()=>{tN(e)},children:[(0,s.jsx)("div",{className:"mt-1",children:"completed"===e.status?(0,s.jsx)(B.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)(E.A,{className:"text-xl text-[var(--colorWarning)]"}):(0,s.jsx)(q.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"===(i=e.status)?"success":"warning"===i?"warning":"failed"===i?"error":"aborted"===i?"default":"processing",className:"border-0 m-0 shrink-0",children:"completed"===(c=e.status)?"已完成":"warning"===c?"需复核":"failed"===c?"失败":"aborted"===c?"已中止":"生成中"})]}),(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)(H.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 l=Math.floor(r/60),a=r%60;return a?"".concat(l," 小时 ").concat(a," 分"):"".concat(l," 小时")})(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?"生成失败":"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==(r=e.warningIssues)?void 0:r[0])||(null==(a=e.draft)||null==(l=a.validationIssues.find(e=>"error"===e.level||"warning"===e.level))?void 0:l.message)||"需复核"})]})]}),(0,s.jsxs)("div",{className:"flex shrink-0 flex-nowrap items-center gap-2 whitespace-nowrap transition-opacity ".concat(e_===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:tT(e.status)?(0,s.jsx)(q.A,{spin:!0}):(0,s.jsx)(O.A,{}),onClick:t=>{t.stopPropagation(),tN(e)},className:"min-w-[72px] rounded-md justify-center",children:"打开"}),tT(e.status)&&(0,s.jsx)(Y,{title:"确定中止此生成任务?",onConfirm:t=>{null==t||t.stopPropagation(),tU(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==(n=e.checkpointChapters)?void 0:n.length)&&/继续生成|重新生成|中断|卡住|未完成/u.test(e.error||(null==(o=e.warningIssues)?void 0:o.join(";"))||""))&&(0,s.jsx)(m.Ay,{size:"small",onClick:t=>{t.stopPropagation(),tK(e)},className:"rounded-md",children:"继续"}),(0,s.jsx)(Y,{title:"确认删除?",onConfirm:t=>{null==t||t.stopPropagation(),tO(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:t1,open:td,onClose:()=>{tu(!1),tg.current&&(clearInterval(tg.current),tg.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:eR?(0,s.jsxs)(i.A,{wrap:!0,children:[(0,s.jsx)(m.Ay,{icon:(0,s.jsx)(V.A,{}),disabled:eO,onClick:()=>{tX()},children:R("documents.saveDraft")}),(0,s.jsx)(m.Ay,{icon:(0,s.jsx)(K.A,{}),disabled:eO,loading:"markdown"===eP,onClick:()=>{tQ("markdown")},children:"MD"}),(0,s.jsx)(m.Ay,{disabled:eO,loading:"html"===eP,onClick:()=>{tQ("html")},children:"HTML"}),(0,s.jsx)(m.Ay,{disabled:eO,loading:"docx"===eP,onClick:()=>{tQ("docx")},children:"DOCX"}),(0,s.jsx)(m.Ay,{type:"primary",disabled:eO,loading:"pdf"===eP,onClick:()=>{tQ("pdf")},children:"PDF"})]}):eN&&"workflow"===tp?(0,s.jsx)(m.Ay,{danger:!0,onClick:()=>{(async()=>{if(e_&&await (0,U.r)(e_,tt||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(tj),tg.current&&(clearInterval(tg.current),tg.current=null),eT(!1),ts([]),ta(null),tu(!1),await ty(),_.info("已中止生成任务")})()},children:"中止任务"}):void 0,children:(0,s.jsxs)($,{style:{width:"100%"},gap:16,children:["workflow"===tp&&tr.length>0&&(0,s.jsx)($,{gap:10,children:tr.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===tA?"var(--colorFillAlter)":"var(--colorBgContainer)"},children:[(0,s.jsx)("span",{children:"process"===e.status?(0,s.jsx)(D.A,{}):"warning"===e.status?(0,s.jsx)(E.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)(B.A,{}):"warning"===t?(0,s.jsx)(E.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"===tp&&(null==tn?void 0:tn.partialChapters)&&tn.partialChapters.length>0&&(0,s.jsx)(v.A,{size:"small",title:"章节进度",extra:(0,s.jsxs)(u.A,{color:"blue",children:[tn.partialChapters.filter(e=>"completed"===e.status).length,"/",tn.partialChapters.length]}),children:(0,s.jsx)($,{gap:6,style:{width:"100%"},children:tn.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"===tp&&(null==tn||null==(e=tn.reviewMetadata)?void 0:e.diagnostics)&&(0,s.jsx)(Z,{type:"info",title:"后台自动优化",children:"策略:".concat(tn.reviewMetadata.diagnostics.strategy.mode,";LLM 调用 ").concat(tn.reviewMetadata.diagnostics.llm.calls," 次;噪声过滤 ").concat((null==(t=tn.reviewMetadata.diagnostics.evidence)?void 0:t.filteredNoise)||0," 条;质量门禁 阻断").concat((null==(r=tn.reviewMetadata.diagnostics.quality)?void 0:r.blockingCount)||0,"/重要").concat((null==(a=tn.reviewMetadata.diagnostics.quality)?void 0:a.importantCount)||0,"/轻微").concat((null==(o=tn.reviewMetadata.diagnostics.quality)?void 0:o.minorCount)||0,";自动限流调整 ").concat(tn.reviewMetadata.diagnostics.llm.limitAdjustments," 次。审查与诊断信息仅用于系统修复,不会写入正文或导出文件。")}),"workflow"===tp&&eN&&0===tr.length&&(0,s.jsxs)("div",{style:{textAlign:"center",padding:40},children:[(0,s.jsx)(f.A,{}),(0,s.jsx)("div",{style:{marginTop:12,color:"var(--colorTextSecondary)"},children:"正在准备生成…"})]}),eR&&(0,s.jsx)("div",{ref:ec,children:(0,s.jsx)(x.A,{items:[{key:"edit",label:R("documents.edit"),children:(0,s.jsxs)($,{gap:16,style:{width:"100%"},children:[(0,s.jsx)(X,{rows:28,value:eB,disabled:eO,onSelect:e=>{var t,r,s;return eY({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;ez(e.target.value),eU(null),eX(null),eY({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)(z.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)(H.A,{}),onClick:()=>e1(e=>!e),disabled:0===eZ.length,children:["历史版本 ",eZ.length>0?eZ.length:""]})]}),(0,s.jsx)(Z,{type:"info",title:"系统只负责识别修改范围,不改写你的提示词;选中文字后优先只改选区,没有选区时按光标所在小节/章节定位。"}),(0,s.jsx)(X,{rows:4,value:eG,disabled:eO,onChange:e=>{eW(e.target.value),eU(null),eX(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:eO,onClick:()=>eW(t=>t?"".concat(t,";").concat(e):e),children:e},e))}),(0,s.jsx)(m.Ay,{type:"primary",icon:(0,s.jsx)(z.A,{}),loading:eO&&"planning"===eH,disabled:!eG.trim()||eO,onClick:()=>{t$()},children:"识别修改范围"})]}),eK&&!eQ&&(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:eK.scope}),(0,s.jsx)(u.A,{color:"blue",children:eK.action}),(0,s.jsxs)(u.A,{color:eK.confidence>=.8?"green":"orange",children:["置信度 ",Math.round(100*eK.confidence),"%"]}),eK.targetTitle&&(0,s.jsx)(J,{strong:!0,children:eK.targetTitle})]}),(0,s.jsx)(J,{children:eK.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:eO&&"applying"===eH,onClick:()=>{t0(eK)},children:"执行并预览"}),(0,s.jsx)(m.Ay,{disabled:eO,onClick:()=>eU(null),children:"取消"})]})]})}),eQ&&(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:eQ.summary||eQ.plan.summary}),(0,s.jsxs)(u.A,{children:[eQ.changedChars&&eQ.changedChars>0?"+".concat(eQ.changedChars):eQ.changedChars," 字符"]})]}),(0,s.jsxs)(j.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:eQ.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:eQ.afterSnippet||"无片段预览"})]})]}),(0,s.jsxs)(i.A,{children:[(0,s.jsx)(m.Ay,{type:"primary",onClick:()=>{eQ&&(tJ(eQ.before,eQ.prompt),ez(eQ.markdown),tY(!0),_.success("已应用精准修改"))},children:"应用到文档"}),(0,s.jsx)(m.Ay,{onClick:()=>eX(null),children:"返回计划"}),(0,s.jsx)(m.Ay,{danger:!0,onClick:()=>{eU(null),eX(null)},children:"放弃"})]})]})}),e0&&(0,s.jsx)("div",{style:{borderTop:"1px solid var(--colorBorderSecondary)",paddingTop:12},children:(0,s.jsx)(w.A,{size:"small",dataSource:eZ,locale:{emptyText:"暂无历史版本"},renderItem:e=>(0,s.jsx)(w.A.Item,{actions:[(0,s.jsx)(m.Ay,{size:"small",disabled:eO,onClick:()=>{tJ(eB,"恢复前版本"),ez(e.content),tY(!0),_.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:[eR.chapters.length>0&&(0,s.jsxs)("div",{children:[(0,s.jsxs)(J,{strong:!0,style:{fontSize:13,marginBottom:8,display:"block"},children:["章节 (",eR.chapters.length,")"]}),(0,s.jsx)(w.A,{size:"small",dataSource:eR.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)})})})]}),eR.structuredFacts.length>0&&(0,s.jsxs)("div",{children:[(0,s.jsxs)(J,{strong:!0,style:{fontSize:13,marginBottom:8,display:"block"},children:["结构化事实 (",eR.structuredFacts.length,")"]}),(0,s.jsx)(b.A,{size:"small",column:1,bordered:!0,children:eR.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:["引用来源 (",eR.sources.length,")"]}),0===eR.sources.length?(0,s.jsx)(h.A,{description:"暂无"}):(0,s.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:eR.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:["缺失项 (",eR.missingItems.length,")"]}),0===eR.missingItems.length?(0,s.jsx)(h.A,{description:"无缺失"}):(0,s.jsx)(w.A,{size:"small",dataSource:eR.missingItems,renderItem:e=>(0,s.jsx)(w.A.Item,{children:e})})]})]})},{key:"validation",label:"校验 (".concat(eR.validationIssues.length,")"),children:0===eR.validationIssues.length?(0,s.jsx)(h.A,{description:"校验通过"}):(0,s.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[eR.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))),eR.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:eR.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(eR.executionStages.length,")"),children:(0,s.jsx)(w.A,{size:"small",dataSource:eR.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||tk(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:R("documents.templateEditor"),open:e2,onClose:()=>e6(!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:()=>e6(!1),children:R("common.cancel")}),(0,s.jsx)(m.Ay,{type:"primary",onClick:()=>{tP()},children:R("common.save")})]}),children:(0,s.jsxs)(d.A,{form:ei,layout:"vertical",requiredMark:"optional",children:[(0,s.jsxs)(j.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:R("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:R("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:R("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:R("documents.templateDescription"),children:(0,s.jsx)(n.A,{})})})]}),(0,s.jsx)(d.A.Item,{name:"projectRoleConfigId",label:R("documents.projectRoleConfig"),rules:[{required:!0,message:R("documents.projectRoleConfigRequired")}],children:(0,s.jsx)(A.A,{showSearch:!0,placeholder:R("documents.projectRoleConfigRequired"),options:tb})}),(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:"按文件角色多选"})]}),eb?(0,s.jsxs)("div",{className:"text-center py-8",children:[(0,s.jsx)(f.A,{}),(0,s.jsx)("div",{className:"mt-3 text-[var(--colorTextSecondary)] text-xs",children:"正在加载知识库文件…"})]}):0===e9.length?(0,s.jsx)(h.A,{image:h.A.PRESENTED_IMAGE_SIMPLE,description:e3?"当前项目角色未配置文件角色":"请先选择项目角色"}):0===ey.length?(0,s.jsx)(h.A,{image:h.A.PRESENTED_IMAGE_SIMPLE,description:"暂无知识库文件"}):(0,s.jsx)("div",{className:"flex flex-col gap-4",children:e9.map(e=>{let t=e.value,r=t?el(te[t]||[]):[];return(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"font-medium text-sm text-[var(--colorText)]",children:e.label}),(0,s.jsx)(m.Ay,{type:"link",size:"small",danger:!0,disabled:0===r.length,onClick:()=>tD(t,[]),className:"p-0 h-auto",children:"清空"})]}),(0,s.jsx)(d.A.Item,{name:["fileBindingGroups",t],hidden:!0,children:(0,s.jsx)(n.A,{})}),(0,s.jsx)(k.A,{treeData:ey,loadData:tF,fieldNames:{label:"rawTitle",value:"value",children:"children"},value:r,onChange:e=>{tD(t,e.map(e=>String(e)))},treeCheckable:!0,showCheckedStrategy:k.A.SHOW_PARENT,placeholder:"点击这里搜索或选择文件...",style:{width:"100%"},listHeight:300,showSearch:!0,maxTagCount:"responsive",size:"large"})]},e.value)})})]})]})})]})}}},e=>{e.O(0,[580,665,576,209,7,787,195,455,506,230,636,593,792],()=>e(e.s=16403)),_N_E=e.O()}]);