nx-kv 0.43.0 → 0.44.0

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/package.json +1 -1
  3. package/src/modules/localtask/task-ops.js +17 -4
  4. package/src/modules/tasktool/index.js +12 -5
  5. package/src/modules/tasktool/plugins/goal-template.js +86 -0
  6. package/src/modules/tasktool/plugins/taskgoal-store.js +61 -43
  7. package/src/modules/tasktool/plugins/timegoal-task-store.js +40 -3
  8. package/src/modules/tasktool/wait.js +18 -2
  9. package/src/shared/prompt-blocks.js +21 -0
  10. package/src/web/frontend/page/dir/task-actions.js +13 -5
  11. package/src/web/frontend/page/dir/task-goal-section.jsx +29 -24
  12. package/src/web/frontend/page/dir/task-goal.js +6 -1
  13. package/src/web/frontend/page/dir/task.jsx +3 -3
  14. package/src/web/frontend/page/settings/prompt-template-params.js +38 -2
  15. package/src/web/public/assets/{Introduction-DAXj7E6q.js → Introduction-CDSLSy0q.js} +1 -1
  16. package/src/web/public/assets/{bar-KTPTE33i.js → bar-Dp9JHQEk.js} +1 -1
  17. package/src/web/public/assets/{cloud-CLco1knr.js → cloud-D13Ed3Pg.js} +1 -1
  18. package/src/web/public/assets/{composer-panel-D3N_wO9r.js → composer-panel-eKhM7jDM.js} +1 -1
  19. package/src/web/public/assets/{deleted-panel-B6sZddUs.js → deleted-panel-QHsQZ5Ez.js} +1 -1
  20. package/src/web/public/assets/{dir-DEbQhSfL.js → dir-CiDjsHfd.js} +1 -1
  21. package/src/web/public/assets/{group-CxqVtyyh.js → group-DDXtRIPf.js} +1 -1
  22. package/src/web/public/assets/{index-DNB8tgNi.js → index-Dq7eNqAB.js} +2 -2
  23. package/src/web/public/assets/{md-history-C9vOgGLz.js → md-history-DI1Ukbvc.js} +1 -1
  24. package/src/web/public/assets/{overview-9nXafXeK.js → overview-BE6O6j51.js} +1 -1
  25. package/src/web/public/assets/{refs-B5YIZ9SG.js → refs-BkncFh9X.js} +1 -1
  26. package/src/web/public/assets/{repos-Dbr-i-gg.js → repos-C9wx2OXj.js} +1 -1
  27. package/src/web/public/assets/{route-crumb-BfRi1GKw.js → route-crumb-_IyS9fTT.js} +1 -1
  28. package/src/web/public/assets/settings-DlgWRz3r.js +7 -0
  29. package/src/web/public/assets/{status-tag-p3fo3Hbr.js → status-tag-Bop-R-gG.js} +1 -1
  30. package/src/web/public/assets/task-CNbU9Z6v.js +11 -0
  31. package/src/web/public/assets/{templates-BGhPIp0x.js → templates-CK9nH5WD.js} +1 -1
  32. package/src/web/public/assets/{tool-bar-DpwpQ47h.js → tool-bar-9LD5jcE3.js} +1 -1
  33. package/src/web/public/index.html +1 -1
  34. package/src/web/public/assets/settings-B4FvZtu0.js +0 -6
  35. package/src/web/public/assets/task-CUb7dohw.js +0 -11
@@ -0,0 +1,11 @@
1
+ import{g as e,h as t,l as n,m as r,o as i,p as a,u as o,y as s}from"./task-status-BnymQMTw.js";import{r as c,t as l,v as u}from"./workspace-C_5X2gIr.js";import{n as d}from"./app-context-D7HAx67n.js";import{n as f,r as p,t as m}from"./frontmatter-QvrjUNzF.js";import{a as h,g,h as _,i as v,m as y,n as b,p as x,r as S,t as C,u as w,v as T}from"./md-history-DI1Ukbvc.js";import{a as E,r as D}from"./md-parse-awNLHAzO.js";import{n as O,t as k}from"./board-view-CZKZsyk-.js";import{c as A,d as ee,f as j,h as M,l as N,m as P,p as F,s as I,u as L}from"./index-Dq7eNqAB.js";import{t as R}from"./status-tag-Bop-R-gG.js";import{a as z,i as B,n as te,o as V}from"./composer-launch-Bf4rXhLs.js";import{t as ne}from"./route-crumb-_IyS9fTT.js";import{i as re,n as H,r as U,t as W}from"./reopen-text-BylkngqC.js";import{n as ie,u as ae}from"./tool-bar-9LD5jcE3.js";var G=s(e(),1),K=/^>\s*\[![A-Za-z][\w-]*\][ \t]*(.*)$/,q=/完成总结/,J=/反馈/,oe=/第\s*(\d+)\s*轮/;function se(e){let t=String(e??``).split(`
2
+ `),n=t.length&&String(t[0]).match(K);if(!n)return null;let r=t.slice(1).map(e=>e.replace(/^>[ \t]?/,``)).filter(e=>e.trim()!==``).join(`
3
+ `);return{title:String(n[1]??``).trim(),body:r}}function ce(e){let t=y(String(e??``));if(!t.length)return[];let n=[],r=null,i=``;return t.forEach((e,t)=>{let a=String(e||``).trim(),o=se(a);if(o&&q.test(o.title)){let e=Number((o.title.match(oe)||[])[1]);r={round:Number.isFinite(e)&&e>0?e:n.length+1,blockIndex:t,feedbackBlockIndex:-1,ackText:o.body,feedbackText:``},n.push(r),i=`ack`;return}if(a===`## 上一轮完成总结`){r={round:n.length+1,blockIndex:t,feedbackBlockIndex:-1,ackText:``,feedbackText:``},n.push(r),i=`ack`;return}if(o&&J.test(o.title)){r&&i===`ack`&&(r.feedbackBlockIndex=t,r.feedbackText=o.body,i=`feedback`);return}if(a===`## 验收反馈`){r&&i===`ack`&&(r.feedbackBlockIndex=t,i=`feedback`);return}a&&r&&(i===`ack`?r.ackText+=(r.ackText?`
4
+ `:``)+a:r.feedbackText+=(r.feedbackText?`
5
+ `:``)+a)}),n.filter(e=>e.ackText!==``)}function le(e){let t=String(e?.ackText||``).split(`
6
+ `).map(e=>e.replace(/^#+\s*/,``).replace(/\*\*/g,``).trim()).find(e=>e!==``);if(!t)return`第 ${e?.round??1} 轮`;let n=t.length>24?`${t.slice(0,24)}…`:t;return`第 ${e.round} 轮 · ${n}`}var ue=`nx-kv-ack-rail-pos`;function de(e={}){let{x:t,y:n,parentW:r,parentH:i,railW:a=0,railH:o=0,margin:s=8}=e||{};if(![t,n,r,i].every(e=>Number.isFinite(e)))return null;let c=Math.max(s,r-a-s),l=Math.max(s,i-o-s);return{x:Math.min(c,Math.max(s,t)),y:Math.min(l,Math.max(s,n))}}function fe(){try{let e=JSON.parse(localStorage.getItem(ue)||`null`);if(!e||typeof e!=`object`)return null;let t=Number(e.x),n=Number(e.y);return!Number.isFinite(t)||!Number.isFinite(n)?null:{x:t,y:n}}catch{return null}}function pe(e){try{e?localStorage.setItem(ue,JSON.stringify({x:Math.round(e.x),y:Math.round(e.y)})):localStorage.removeItem(ue)}catch{}}var Y=t(),me=4;function he(e,t,n){if(!e||t<0)return null;let r=e.querySelector(`.mdw-lp-block[data-i="${t}"]`);if(r)return r;let i=[...Array.from(e.querySelectorAll(`h2`)).filter(e=>(e.textContent||``).trim()===`上一轮完成总结`),...Array.from(e.querySelectorAll(`.md-callout-t`)).filter(e=>/完成总结/.test(e.textContent||``))].sort((e,t)=>e.compareDocumentPosition(t)&4?-1:1);return i[n]?i[n]:null}function ge({nodes:e=[],scrollRoot:t=null,onJump:n=null}){let[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(0),[s,c]=(0,G.useState)(fe),[l,u]=(0,G.useState)(!1),d=(0,G.useRef)(null),f=(0,G.useRef)(null),p=(0,G.useRef)(!1);(0,G.useEffect)(()=>{let e=d.current,t=e&&e.parentElement;if(!e||!t)return;let n=()=>{c(n=>{if(!n)return n;let r=t.getBoundingClientRect(),i=e.getBoundingClientRect(),a=de({x:n.x,y:n.y,parentW:r.width,parentH:r.height,railW:i.width,railH:i.height});return a&&(a.x!==n.x||a.y!==n.y)?a:n})};return n(),window.addEventListener(`resize`,n,{passive:!0}),()=>window.removeEventListener(`resize`,n)},[]);let m=(0,G.useCallback)(e=>{if(e.pointerType===`mouse`&&e.button!==0)return;let t=d.current,n=t&&t.parentElement;if(!t||!n)return;let r=t.style.bottom;t.style.bottom=`auto`;let i=t.getBoundingClientRect();r?t.style.bottom=r:t.style.bottom=``;let a=n.getBoundingClientRect();f.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startLeft:i.left-a.left,startTop:i.top-a.top,parentW:a.width,parentH:a.height,railW:i.width,railH:i.height,moved:!1};try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}},[]),h=(0,G.useCallback)(e=>{let t=f.current;if(!t||e.pointerId!==t.pointerId)return;let n=e.clientX-t.startX,r=e.clientY-t.startY;if(!t.moved){if(Math.hypot(n,r)<me)return;t.moved=!0,p.current=!0,u(!0),document.body.style.userSelect=`none`}let i=de({x:t.startLeft+n,y:t.startTop+r,parentW:t.parentW,parentH:t.parentH,railW:t.railW,railH:t.railH});i&&(t.last=i,c(i))},[]),g=(0,G.useCallback)(e=>{let t=f.current;t&&e.pointerId===t.pointerId&&(f.current=null,t.moved&&(u(!1),document.body.style.userSelect=``,pe(t.last)))},[]),_=(0,G.useCallback)(()=>{c(null),pe(null)},[]),v=(0,G.useMemo)(()=>(e||[]).map(e=>({...e,title:le(e)})),[e]);(0,G.useEffect)(()=>{let e=t;if(!e||!v.length)return;let n=()=>{let t=e.getBoundingClientRect(),n=0;for(let r of v){let i=he(e,r.blockIndex,r.round-1);i&&i.getBoundingClientRect().top-t.top<=40&&(n=r.round)}o(n)};return n(),e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},[t,v]);let y=(0,G.useCallback)(e=>{let r=t,i=r?he(r,e.blockIndex,e.round-1):null;i&&(i.scrollIntoView({behavior:`smooth`,block:`start`}),o(e.round)),n?.(e)},[t,n]);return v.length?(0,Y.jsxs)(`aside`,{ref:d,className:`doc-rail ack-rail`+(r?` open`:``)+(l?` dragging`:``),style:s?{left:s.x,top:s.y,right:`auto`,bottom:`auto`}:void 0,"aria-label":`验收轮次`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`doc-rail-menu`,title:r?`收起轮次(双击回默认位)`:`展开轮次 · 按住拖动 · 双击回默认位`,"aria-expanded":r,onClick:()=>{if(p.current){p.current=!1;return}i(e=>!e)},onPointerDown:m,onPointerMove:h,onPointerUp:g,onPointerCancel:g,onDoubleClick:_,children:[(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{})]}),(0,Y.jsx)(`div`,{className:`doc-rail-ticks`,role:`navigation`,"aria-label":`验收轮次`,children:v.map(e=>(0,Y.jsx)(`button`,{type:`button`,className:`doc-rail-tick`+(a===e.round?` on`:``),style:{"--tw":`18px`},title:e.title,"aria-current":a===e.round?`true`:void 0,onClick:()=>y(e)},e.round))}),r&&(0,Y.jsx)(`div`,{className:`doc-rail-panel`,children:(0,Y.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,Y.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`验收轮次`}),v.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:`doc-rail-row`+(a===e.round?` on`:``),title:e.ackText,onClick:()=>y(e),children:[`第 `,e.round,` 轮`]},e.round))]})})]}):null}var _e=[{op:`bold`,label:`B`,title:`粗体`,cls:`b`},{op:`italic`,label:`I`,title:`斜体`,cls:`i`},{op:`code`,label:`</>`,title:`代码`,cls:`code`},{op:`link`,label:`链`,title:`链接`,cls:`link`}];function ve({at:e,onFormat:t,onCopy:n,onCompose:r,onDelete:i}){if(!e)return null;let a=e.kind||`task`,o=a===`format`||a===`both`;return(0,Y.jsx)(`div`,{id:`mdw-sel-menu`,className:`mdw-sel-menu open kind-${a}`,style:{left:e.x,top:e.y},role:`menu`,onMouseDown:e=>{e.target.closest?.(`textarea, input, button`)||e.preventDefault()},children:o?(0,Y.jsxs)(`div`,{className:`mdw-sel-fmt`,role:`group`,"aria-label":`选区格式`,children:[_e.map(e=>(0,Y.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn ${e.cls}`,title:e.title,onClick:()=>t?.(e.op),children:e.label},e.op)),(0,Y.jsx)(`span`,{className:`mdw-sel-sep`,"aria-hidden":!0}),(0,Y.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn`,title:`复制`,onClick:n,children:`复制`}),(0,Y.jsx)(`span`,{className:`mdw-sel-sep`,"aria-hidden":!0}),(0,Y.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn comment`,title:`评论 → 打开 md 编辑面板`,onClick:()=>r?.(),children:`评论`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`cap`,children:`选区`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>r?.(),children:`评论`}),(0,Y.jsx)(`div`,{className:`sep`}),(0,Y.jsx)(`button`,{type:`button`,onClick:n,children:`复制选区`}),i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`sep`}),(0,Y.jsx)(`button`,{type:`button`,className:`danger`,title:`删除选区触到的整段块`,onClick:i,children:`删除选区`})]}):null]})})}var ye=[{title:`格式`,items:[[`Ctrl/⌘ B`,`粗体`],[`Ctrl/⌘ I`,`斜体`],[`Ctrl/⌘ E`,`行内代码`],[`Ctrl/⌘ K`,`链接`],[`1 – 6`,`正文 / 标题 / 小标题 / 列表 / 待办 / 引用`]]},{title:`编辑`,items:[[`/`,`行首唤起命令菜单`],[`Tab / ⇧Tab`,`缩进 / 反缩进`],[`Enter`,`新建块(列表自动续行)`],[`⇧Enter`,`块内软换行`],[`Ctrl/⌘ Z`,`撤销`],[`Ctrl/⌘ ⇧Z`,`重做`]]},{title:`导航与文件`,items:[[`Ctrl/⌘ F`,`查找(Enter 下一个,F3 继续)`],[`Ctrl/⌘ S`,`保存并同步`],[`Ctrl/⌘ ⇧ O`,`评论任务:右侧并排打开原文`],[`Ctrl/⌘ /`,`打开 / 关闭本速查`],[`Enter(标题内)`,`跳到正文`]]}];function be({onClose:e}){return(0,Y.jsx)(i,{title:`快捷键`,onClose:e,size:`lg`,className:`mdw-sheet`,children:(0,Y.jsx)(`div`,{className:`mdw-sheet-cols`,children:ye.map(e=>(0,Y.jsxs)(`section`,{className:e.title===`导航与文件`?`wide`:void 0,children:[(0,Y.jsx)(`h4`,{children:e.title}),(0,Y.jsx)(`dl`,{children:e.items.map(([e,t])=>(0,Y.jsxs)(`div`,{className:`mdw-sheet-row`,children:[(0,Y.jsx)(`dt`,{children:(0,Y.jsx)(`kbd`,{children:e})}),(0,Y.jsx)(`dd`,{children:t})]},e))})]},e.title))})})}var xe={origin:`起点`,reopen:`反馈`,comment:`评论`,current:`当前`};function Se({nodes:e=[],onOpenNode:t}){return e.length?(0,Y.jsx)(`ol`,{className:`mdw-chain-list`,"aria-label":`任务链节点`,children:e.map((n,r)=>{let i=n.current?`current`:`t-${n.dirKey||``}-${n.id??n.taskId??r}`,a=xe[n.kind]||n.kind||`?`,o=n.excerpt||n.feedback||a,s=[n.taskId==null?null:`#${n.taskId}`,n.at||null,n.attachmentCount?`📎${n.attachmentCount}`:null].filter(Boolean).join(` · `);return(0,Y.jsxs)(`li`,{className:`mdw-chain-li${n.current?` is-current`:``}`,children:[(0,Y.jsxs)(`div`,{className:`mdw-chain-rail`,"aria-hidden":!0,children:[(0,Y.jsx)(`span`,{className:`mdw-chain-dot`}),r<e.length-1?(0,Y.jsx)(`span`,{className:`mdw-chain-line`}):null]}),(0,Y.jsxs)(`button`,{type:`button`,className:`mdw-chain-card${n.kind===`comment`?` is-comment`:``}`,title:n.current?`当前任务(本页)`:`查看:${o}`,disabled:!!n.current,onClick:()=>{n.current||t?.(n)},children:[(0,Y.jsx)(`span`,{className:`mdw-chain-kind`,children:a}),(0,Y.jsx)(`span`,{className:`mdw-chain-ex`,children:o||`—`}),s?(0,Y.jsx)(`span`,{className:`mdw-chain-meta`,children:s}):null]})]},i)})}):(0,Y.jsx)(`div`,{className:`mdw-chain-empty muted`,children:`这条任务还没有链(反馈 / 评论派生后会出现)`})}function Ce({open:e,nodes:t,onOpenNode:n,onClose:r}){return e?(0,Y.jsxs)(i,{title:`任务链`,onClose:r,size:`md`,className:`mdw-chain-modal`,children:[(0,Y.jsx)(`p`,{className:`mdw-chain-hint`,children:`从早到晚排列。点非当前节点可在旁路打开内容。`}),(0,Y.jsx)(Se,{nodes:t,onOpenNode:e=>{n?.(e),r?.()}})]}):null}function we(){let[e,t]=(0,G.useState)(()=>localStorage.getItem(`nxkv.taskDockOpen`)!==`0`),[n,r]=(0,G.useState)(()=>localStorage.getItem(`nxkv.taskDockTab`)||`attach`),[i,a]=(0,G.useState)(()=>{let e=Number(localStorage.getItem(`nxkv.taskDockH`));return Number.isFinite(e)&&e>=96?e:176}),o=(0,G.useRef)(i);o.current=i;let s=(0,G.useRef)(null),[c,l]=(0,G.useState)(!1),u=(0,G.useRef)(176);return(0,G.useEffect)(()=>{localStorage.setItem(`nxkv.taskDockOpen`,e?`1`:`0`)},[e]),(0,G.useEffect)(()=>{localStorage.setItem(`nxkv.taskDockTab`,n)},[n]),{dockOpen:e,setDockOpen:t,dockTab:n,setDockTab:r,dockH:i,dockHRef:o,dockRef:s,dockMax:c,setDockMax:l,dockPrevHRef:u,showDockTab:(0,G.useCallback)(e=>{r(e),t(!0)},[]),onDockDragStart:(0,G.useCallback)(t=>{if(!e)return;t.preventDefault(),l(!1);let n=t.clientY,r=o.current,i=s.current?.parentElement?.clientHeight||window.innerHeight,c=e=>Math.max(96,Math.min(Math.round(i*.62),Math.round(e))),u=e=>{let t=c(r-(e.clientY-n));o.current=t,a(t)},d=()=>{window.removeEventListener(`mousemove`,u),window.removeEventListener(`mouseup`,d),document.body.style.userSelect=``,document.body.style.cursor=``,localStorage.setItem(`nxkv.taskDockH`,String(o.current))};document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`,window.addEventListener(`mousemove`,u),window.addEventListener(`mouseup`,d)},[e]),toggleDockMax:(0,G.useCallback)(()=>{if(c){a(u.current),l(!1);return}u.current=o.current;let e=s.current?.parentElement?.clientHeight||window.innerHeight,t=Math.max(96,Math.round(e*.62));o.current=t,a(t),l(!0)},[c])}}function Te({id:e,isDraft:t,topicKey:n,task:i,taskRow:a}){let[o,s]=(0,G.useState)(null);(0,G.useEffect)(()=>{s(null)},[e]);let c=a?.timegoal||null,l=o||{duration:c?.duration||``,prompt:c?.prompt||``},u=t||!!a&&a.status===`pending`,d=t||!!a&&a.status!==`done`&&a.status!==`cancelled`&&(a.status===`pending`||!!c),f=!t&&!!c&&i!=null,[p,m]=(0,G.useState)({busy:!1,error:``,data:null}),h=(0,G.useCallback)(()=>{if(t||!n||i==null)return;m(e=>({...e,busy:!0,error:``}));let e=new URLSearchParams({id:String(i),key:String(n)});r(`/api/localtasks/timegoal-log?${e.toString()}`).then(e=>m(t=>({...t,data:e,busy:!1}))).catch(e=>m(t=>({...t,busy:!1,error:String(e.message||e)})))},[t,n,i]);return(0,G.useEffect)(()=>{f&&h()},[f,h]),{goalDraft:o,setGoalDraft:s,goal:l,goalEditable:u,goalPromptEditable:d,declaredGoal:c,goalLog:p,loadGoalLog:h,canShowGoalLog:f}}function Ee({isDraft:e,task:t,taskRow:n,topicKey:i,topic:a,isGlobal:o,groupAnchored:s,groupId:c,app:u,model:d,historyId:f,toast:p}){let[m,h]=(0,G.useState)(null);(0,G.useEffect)(()=>{if(e||t==null||/^draft/i.test(String(t))){h(null);return}let n=!1,i=o?`key=${encodeURIComponent(k)}&id=${Number(t)}`:`cwd=${encodeURIComponent(a?.cwd||``)}&id=${Number(t)}`;return r(`/api/localtasks/chain?${i}`).then(e=>{n||h(e)}).catch(()=>{n||h(null)}),()=>{n=!0}},[e,t,o,a?.cwd,n?.history?.length,n?.forkOf,n?.reopenCount]);let g=(0,G.useMemo)(()=>{if(e||!n)return[];let r=(String(n.text||``).split(`
7
+ `).map(e=>e.trim()).find(Boolean)||``).replace(/^#+\s*/,``).slice(0,100),a=Array.isArray(n.history)?n.history:[];if(a.length){let e=a.map(e=>({historyId:e.id,kind:e.kind,at:e.at,excerpt:e.excerpt||e.feedback||``,feedback:e.feedback,quote:e.quote,attachmentCount:(e.attachments||[]).length,current:!1}));return e.push({historyId:null,kind:`current`,at:n.lastReopenedAt||n.createdAt||``,excerpt:r,attachmentCount:0,current:!0}),e}let o=Array.isArray(m?.ancestors)?[...m.ancestors].reverse():[],s=Array.isArray(m?.children)?m.children:[];if(!o.length&&!s.length&&!n.forkOf)return[];let c=[];for(let e of o)e.missing||c.push({historyId:null,kind:e.forkKind||`origin`,at:e.createdAt||``,excerpt:e.excerpt||`#${e.id}`,attachmentCount:0,current:!1,taskId:e.id,dirKey:e.key});c.push({historyId:null,kind:`current`,at:n.createdAt||``,excerpt:r,attachmentCount:0,current:!0,taskId:Number(t),dirKey:i||`__GLOBAL__`});for(let e of s)c.push({historyId:null,kind:e.forkKind||`comment`,at:e.createdAt||``,excerpt:e.excerpt||`#${e.id}`,attachmentCount:0,current:!1,taskId:e.id,dirKey:e.key});return c},[e,n,m,t,i]),_=(0,G.useMemo)(()=>{if(f==null||!n)return null;let e=Number(f);return(n.history||[]).find(t=>Number(t.id)===e)||null},[f,n]),v=Array.isArray(m?.children)?m.children:[],y=v.length===0,b=v.length?v[v.length-1]:null;return{chainApi:m,chainNodes:g,historyNode:_,chainChildren:v,isChainTip:y,latestChild:b,openLatestRound:(0,G.useCallback)(()=>{b&&u.openPage&&(s?u.openPage({groupId:c,task:String(b.id),name:`#${b.id}`}):u.openPage({dirKey:String(b.key||i||`__GLOBAL__`),task:String(b.id),name:`#${b.id}`}))},[b,u.openPage,s,c,i]),openHistoryBeside:(0,G.useCallback)(n=>{let r=d||u.model;if(r&&!e){if(n?.current){p(`当前节点就是本页`);return}if(n?.historyId!=null){l(r,{component:`page`,name:`链 #${t} · ${n.kind||n.historyId}`,config:{dirKey:i||`__GLOBAL__`,task:String(t),historyId:Number(n.historyId)}});return}if(n?.taskId!=null&&n?.dirKey){l(r,{component:`page`,name:n.excerpt?String(n.excerpt).slice(0,24):`#${n.taskId}`,config:{dirKey:String(n.dirKey),task:String(n.taskId)}});return}p(`这个节点没有可打开的内容`)}},[d,u.model,e,i,t,p])}}function De({id:e}){let[t,n]=(0,G.useState)(null),r=(0,G.useRef)(``);return(0,G.useEffect)(()=>{n(null),r.current=``},[e]),(0,G.useEffect)(()=>{let e=()=>n(null);return document.addEventListener(`scroll`,e,!0),()=>document.removeEventListener(`scroll`,e,!0)},[]),{selMenu:t,setSelMenu:n,lastSel:r,placeSelMenu:(0,G.useCallback)((e,t,i,a,o={})=>{r.current=t,n({kind:e,text:t,...o,x:Math.min(window.innerWidth-300,Math.max(8,i)),y:Math.min(window.innerHeight-240,Math.max(8,a))})},[]),onEditorTextSel:(0,G.useCallback)(e=>{if(!e?.text||e.text.length<1){n(null);return}r.current=e.text,n({kind:`format`,text:e.text,x:Math.min(window.innerWidth-300,Math.max(8,e.x)),y:Math.min(window.innerHeight-240,Math.max(8,e.y))})},[]),closeSelMenu:(0,G.useCallback)(()=>{n(null),r.current=``},[])}}function Oe({id:e,taskRow:t,dockTab:n,dockOpen:r}){let[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(!1),c=(0,G.useRef)(null),l=String(t?.roundSummary||``).length>140;return(0,G.useEffect)(()=>{a(!1),s(!1)},[e,t?.roundSummary]),(0,G.useLayoutEffect)(()=>{let e=c.current;if(!e){s(!1);return}let t=()=>{i||s(e.scrollHeight>e.clientHeight+1)};t();let n=requestAnimationFrame(t),r=typeof ResizeObserver<`u`?new ResizeObserver(t):null;return r?.observe(e),()=>{cancelAnimationFrame(n),r?.disconnect()}},[i,t?.roundSummary,t?.completedAt,n,r]),{ackOpen:i,setAckOpen:a,ackOverflow:o,reviewSumRef:c,ackLong:l}}function ke({doc:e,id:t,isDraft:n,task:i,taskRow:o,topicKey:s,topic:l,isGlobal:d,boardCtx:h,docFm:g,groupAnchored:v,groupId:y,rows:b,app:S,model:w,tabId:T,tpl:O,refreshLocal:A,markDirty:M,histRef:N,editorApiRef:R,attachAreaRef:te,setDirty:V,goal:ne,goalEditable:re,goalPromptEditable:H,declaredGoal:U,guard:W,dialog:ie,showDockTab:ae}){let K=a(),q=(0,G.useCallback)((e,t)=>{let n=(e||``).trim()||`未命名任务`,r=m(t),i=Object.keys(r).length>0,a=f(t);return a=_(a),a=/^#\s+/m.test(a)?a.replace(/^#\s+.+$/m,`# ${n}`):`# ${n}\n\n${a}`,i?p(a,r):a},[]),J=(0,G.useCallback)(()=>{let e=(ne.duration||``).trim(),t=(ne.prompt||``).trim();if(t&&!e)return{error:`时间目标要填时长(如 2h / 90m);只写附加要求无效`};if(!n){let n=U?.duration||``,r=U?.prompt||``,i=e!==n;return!i&&t===r?{}:i?re?e?{duration:e,goalPrompt:t}:{clearGoal:!0}:{error:`已领取计时,时长不可改(附加要求仍可直接改)`}:H?{goalPrompt:t}:{}}return e?{duration:e,goalPrompt:t}:{}},[ne,re,H,n,U]),oe=(0,G.useCallback)(()=>W(async()=>{if(!e)return;let a=(e.title||``).trim()||`未命名任务`,o=m(e.body),c=q(a,e.body),f=o.project?b.find(e=>!e.isGlobal&&e.repo&&e.repo.key===o.project):null,p=!!(h&&o.project&&h.members.some(e=>e.key===o.project)),g=J();if(g.error){K(g.error);return}if(!n){let n=await r(`/api/localtasks/item`,{method:`PATCH`,body:{cwd:d?f?f.cwd:void 0:l?.cwd,key:d&&!f?k:void 0,id:Number(i),text:c,...g}});if(n?.moved){let r=n.key||s,o=String(n.task?.id??i),l=I(P(r),o);z(o,e.attachments),j(t,l,{title:a,body:n.task?.text||c}),w&&T&&w.doAction(u.updateNodeAttributes(T,{config:v?{groupId:y,task:o}:{dirKey:r,task:o}})),S.onNavigate&&S.onNavigate(v?`#/group/${encodeURIComponent(y||``)}?task=${encodeURIComponent(o)}`:`#/dir/${encodeURIComponent(r||``)}?task=${encodeURIComponent(o)}`),V(!1),C(N.current,l),K(`已改归属项目:任务迁到「${n.name}」#${o}`),A();return}z(i,e.attachments),F(t,{title:a,body:c}),V(!1),C(N.current,t),K(g.clearGoal?`已同步 MD · 时间目标已清除`:g.duration?`已同步 MD · 时间目标已更新`:`已同步 MD`),A();return}let _=await r(`/api/localtasks`,{method:`POST`,body:{...p?{text:c,board:h.board.id,project:o.project}:o.project?{text:c,project:o.project}:d?{global:!0,text:c}:{cwd:l?.cwd,text:c},...g}}),x=_?.task?.id??_?.id;if(x!=null){let n=_?.key||s,r=P(n);z(x,e.attachments);let i=I(r,String(x));j(t,i,{title:a,body:c}),w&&T&&w.doAction(u.updateNodeAttributes(T,{config:v?{groupId:y,task:String(x)}:{dirKey:n,task:String(x)}})),S.onNavigate&&S.onNavigate(v?`#/group/${encodeURIComponent(y||``)}?task=${encodeURIComponent(String(x))}`:`#/dir/${encodeURIComponent(n||``)}?task=${encodeURIComponent(String(x))}`),V(!1),C(N.current,i)}K(`已提交:${D(a)}`),A()}),[e,t,n,i,s,l,d,h,v,y,b,S,w,T,A,N,V,q,J,W,K]),se=(0,G.useCallback)(async e=>{let t=await e.text(),n=e.name.replace(/\.md$/i,``);await W(async()=>{let i=t.startsWith(`#`)?t:`# ${n}\n\n${t}`,a=await r(`/api/localtasks`,{method:`POST`,body:d?{global:!0,text:i}:v&&g.project?{project:g.project,text:i}:{cwd:l?.cwd,text:i}});K(`已导入:${e.name}`),A();let o=a?.task?.id??a?.id;o!=null&&S.openPage&&(v?S.openPage({groupId:y,task:String(o),name:`#${o}`}):S.openPage({dirKey:s,task:String(o),name:`#${o}`}))})},[d,v,g.project,l?.cwd,s,y,S,A,W,K]),ce=(0,G.useCallback)(async()=>{if(!e||n)return;let t=e.title||`#${i}`;await ie({title:`删除任务「${t}」`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})&&W(async()=>{await r(`/api/localtasks/item`,{method:`DELETE`,body:d?{key:k,id:Number(i)}:{cwd:l.cwd,id:Number(i)}}),K(`已删除「${t}」`),w&&T&&w.doAction(u.deleteTab(T)),A()})},[e,n,i,d,l,w,T,A,W,K,ie]),le=!n&&!!o&&o.status===`pending`;return{composeText:q,goalPatchOf:J,submit:oe,importMd:se,delTask:ce,canClosePending:le,closeTask:(0,G.useCallback)(t=>{le&&W(async()=>{let n=e?.title||`#${i}`,a=d?{key:k}:{cwd:l?.cwd};if(t===`done`){let e=await ie({title:`标为完成「${n}」`,message:`任务还没被领取。确认把当前正文视为已完成?可写一句完成总结。`,input:!0,placeholder:`完成总结(可选;留空使用默认说明)`,okText:`标为完成`});if(e==null)return;await r(`/api/localtasks/items/close`,{method:`POST`,body:{...a,ids:[Number(i)],status:`done`,summary:String(e).trim()}}),K(`已标为完成 #${i}`)}else{if(!await ie({title:`取消任务「${n}」`,message:`只处理待领取任务。取消为终态,原文留档。`,danger:!0,okText:`取消任务`}))return;await r(`/api/localtasks/items/close`,{method:`POST`,body:{...a,ids:[Number(i)],status:`cancelled`}}),K(`已取消 #${i}`)}A()})},[le,e,i,d,l,A,W,K,ie]),addFiles:(0,G.useCallback)(async(a,o={})=>{if(!e)return;let{items:s,imageInserts:c,fileInserts:u}=await B(a),f=ee(t)||e,p=f.body||``,m=c.join(``),h=p,g=null;if(m){let e=x(p,m,o);h=e.body,g=e.insertAt+m.length}u.length&&(h=x(h,u.join(``),{}).body);let _={};if(h!==p&&(_.body=h),s.length&&(_.attachments=[...f.attachments||[],...s]),Object.keys(_).length){if(F(t,_),o.mode===`edit`&&g!=null&&requestAnimationFrame(()=>{R.current?.focus?.();let e=document.querySelector(`.mdw-editor`);if(e)try{e.setSelectionRange(g,g)}catch{}}),!n){_.attachments&&z(i,_.attachments);let e=q(f.title,_.body||h);F(t,{body:e,title:E(e)});try{await r(`/api/localtasks/item`,{method:`PATCH`,body:{cwd:d?void 0:l?.cwd,key:d?k:void 0,id:Number(i),text:e}}),V(!1),A(),K(s.length?`已添加附件并同步(${s.length})`:`已同步附件`)}catch(e){M(),K(`附件已插入,同步失败:${e.message||e}`)}return}M()}},[e,t,n,i,l,d,V,A,M,q,R,K]),newTask:(0,G.useCallback)(()=>{let e=L(),t=I(P(v?y:s),e),n={};h&&h.board&&h.board.id&&(n.board=h.board.id),g.project&&(n.project=g.project),F(t,{title:``,body:p(O?O.defaultBody():``,n)}),S.openPage&&S.openPage(v?{groupId:y,task:e,name:`新任务`}:{dirKey:s,task:e,name:`新任务`})},[h,g.project,v,y,s,S,O]),cloneCur:(0,G.useCallback)(()=>{if(n||i==null||/^draft/i.test(String(i))){K(`草稿没有可克隆的队列任务`);return}W(async()=>{let t=await r(`/api/localtasks/clone`,{method:`POST`,body:d?{id:Number(i)}:{id:Number(i),cwd:l?.cwd}});K(`已克隆为新任务 #${t.task?.id??t.id}`),A();let n=t?.task?.id??t?.id;n!=null&&S.openPage&&(v?S.openPage({groupId:y,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(克隆)`}):S.openPage({dirKey:s,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(克隆)`}))})},[n,i,d,l,v,y,s,S,e,A,W,K]),forkCur:(0,G.useCallback)(()=>{if(n||i==null||/^draft/i.test(String(i))){K(`草稿没有可 Fork 的队列任务`);return}W(async()=>{let t=await r(`/api/localtasks/fork`,{method:`POST`,body:d?{id:Number(i)}:{id:Number(i),cwd:l?.cwd}});K(`已 Fork 为新任务 #${t.task?.id??t.id}(保留任务链)`),A();let n=t?.task?.id??t?.id;n!=null&&S.openPage&&(v?S.openPage({groupId:y,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(Fork)`}):S.openPage({dirKey:s,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(Fork)`}))})},[n,i,d,l,v,y,s,S,e,A,W,K]),openProgress:(0,G.useCallback)(()=>{let e=w||S.model;if(!e)return;let t=g&&g.board?String(g.board):``;c(e,{component:`progress`,name:`进程`,config:t?{groupKey:t,task:i==null?void 0:String(i)}:{dirKey:s||`__GLOBAL__`,task:i==null?void 0:String(i)},location:`right`})},[w,S.model,g,i,s]),openAttachPanel:(0,G.useCallback)(()=>{ae(`attach`),setTimeout(()=>te.current?.open(),0)},[ae,te])}}function Ae({doc:e,isDraft:t,task:n,taskRow:i,topicKey:o,topic:s,isGlobal:c,dirKey:l,groupAnchored:d,groupId:f,app:p,model:m,tabId:h,refreshLocal:g,closeSelMenu:_,lastSel:v,selMenu:y,dirty:b,setDirty:x,guard:S}){let C=a(),w=(0,G.useCallback)(async()=>{if(t||n==null||/^draft/i.test(String(n)))return null;let e=c?`key=${encodeURIComponent(k)}&id=${Number(n)}`:`cwd=${encodeURIComponent(s?.cwd||``)}&id=${Number(n)}`;return r(`/api/localtasks/item?${e}`).catch(()=>null)},[t,n,c,s?.cwd]),T=(0,G.useCallback)(()=>{let t=m||p.model;t&&te(t,{mode:`feedback`,taskLabel:n==null?``:`#`+n,taskTitle:String(e?.title||``).replace(/^#+\s*/,``),prevQuote:String(i?.roundSummary||``).trim()||String(e?.body||``).trim().slice(0,400),src:{dirKey:o||l||`__GLOBAL__`,task:String(n),name:`原文 #${n}`},onSubmit:e=>D(e)})},[m,p.model,n,e,i,o,l]),D=(0,G.useCallback)(({text:a,attachments:l=[],inserts:u=``}={})=>{let m=String(a||``).trim();if(_(),!m&&!(l&&l.length)){C(`写一下反馈`);return}let h=e?.title||`#${n}`;S(async()=>{let a=await w(),_=String(a?.text??``).trim()||String(e?.body??``).trim();if(!_&&!t){C(`拿不到任务当前正文,已取消反馈(防止丢内容)`);return}let v=m||`(见附件)`;u&&(v=`${v}${u}`);let y=W({base:_,feedback:v,ackSummary:a?.roundSummary||i?.roundSummary||``,feedbackHeading:H,bold:!0}),b=!t&&n!=null&&!/^draft/i.test(String(n))?{forkOf:String(n),forkKind:`reopen`}:{},x=await r(`/api/localtasks`,{method:`POST`,body:c?{global:!0,text:y,...b}:{cwd:s?.cwd,text:y,...b}}),S=String(x?.task?.id??x?.id??``);if(!S){C(`反馈已提交,但未拿到新任务编号`),g();return}let T=x?.key||o;F(I(P(T),S),{title:E(y),body:y}),l?.length&&z(S,l),C(`已反馈「${h}」→ 新任务 #${S}`),g(),p.openPage&&(d?p.openPage({groupId:f,task:S,name:`${h.slice(0,24)}(反馈)`}):p.openPage({dirKey:T,task:S,name:`${h.slice(0,24)}(反馈)`}))})},[e,n,i,t,c,s,o,d,f,p,g,_,S,C,w]),O=(0,G.useCallback)(({text:i,attachments:a=[],inserts:l=``,quote:d}={})=>{let f=String(i||``).trim(),p=String(d||v.current||``).trim();if(_(),!f&&!(a&&a.length)){C(`写一下要提的问题`);return}if(!p&&!f){C(`先划选一段再评论`);return}if(t||n==null||/^draft/i.test(String(n))){C(`草稿先提交成任务再评论`);return}let y=e?.title||`#${n}`;S(async()=>{let t=!b&&!l&&!(a&&a.length),i;if(!t){let t=await w(),n=String(t?.text??``).trim()||String(e?.body??``).trim();if(!n){C(`拿不到任务当前正文,已取消评论(防止丢内容)`);return}let r=[re(p),f||`(见附件)`,l].filter(Boolean).join(`
8
+
9
+ `);i=W({base:n,feedback:r,ackSummary:``,feedbackHeading:U,bold:!1})}let d=await r(`/api/localtasks/reopen`,{method:`POST`,body:{...c?{key:k}:{cwd:s?.cwd},id:Number(n),...i?{text:i}:{},kind:`comment`,quote:p,feedback:f,attachments:(a||[]).map(e=>({id:e.id,name:e.name,type:e.type,size:e.size,url:e.url||``}))}}),_=d?.key||o,v=String(d?.task?.id??n),S=String(d?.task?.text??i??``);S&&F(I(P(_),v),{title:E(S),body:S}),a?.length&&z(v,[...e?.attachments||[],...a]),m&&h&&_!==o&&m.doAction(u.updateNodeAttributes(h,{config:{dirKey:_,task:v}})),x(!1),C(`已回写评论「${y}」#${v}`),g()})},[e,n,t,c,s,o,m,h,g,_,v,b,x,S,C,w]);return{fetchServerTask:w,openFeedback:T,spawnFeedbackTask:D,submitCommentInPlace:O,openCommentFromToolbar:(0,G.useCallback)(()=>{let t=String(window.getSelection()||``).trim()||(y?.text?String(y.text):``);if(!t){C(`先划选一段再评论`);return}v.current=t;let r=m||p.model;r&&(te(r,{mode:`comment`,quote:t,taskLabel:n==null?``:`#`+n,taskTitle:String(e?.title||``).replace(/^#+\s*/,``),src:{dirKey:o||l||`__GLOBAL__`,task:String(n),name:`原文 #${n}`},onSubmit:e=>O({...e,quote:t})}),_())},[e,n,o,l,m,p.model,v,y,O,_,C])}}function je({doc:e,beside:t,topicKey:n,topic:r,task:i,app:a}){let o=(0,G.useMemo)(()=>e?m(e.body):{},[e&&e.body]);return{docFm:o,parentRef:(0,G.useMemo)(()=>{if(t)return null;let a=String(o.parent||``).trim(),s=String(o.parentDir||n||``).trim();if(a&&!/^draft/i.test(a))return{dirKey:s||n,task:a,name:`#${a}`};let c=String(e?.body||``).match(/>\s*锚定自「([^」]+)」/);if(!c)return null;let l=c[1].trim(),u=(r?.tasks||[]).find(e=>String(e.id)===String(i)?!1:E(e.text||``)===l||String(e.text||``).includes(`# ${l}`));return u?{dirKey:n,task:String(u.id),name:`#${u.id}`}:null},[t,o.parent,o.parentDir,e?.body,n,r,i]),boardCtx:(0,G.useMemo)(()=>{let e=o.board;if(!e)return null;let t=(a.repoData&&a.repoData.boards||[]).find(t=>t.id===e||t.key===e||t.name===e);if(!t)return null;let n=a.repoData&&a.repoData.repos||[],r=new Map(n.map(e=>[e.key,e]));return{board:t,members:(t.repos||[]).map(e=>r.get(e.key)).filter(Boolean).map(e=>({key:e.key,name:e.name}))}},[o.board,a.repoData])}}function Me({state:e,onClose:t}){let n=a(),r=e?.data,o=async()=>{try{await navigator.clipboard.writeText(String(r?.rendered||``)),n(`已复制原文`)}catch{n(`复制失败(剪贴板不可用)`)}},s=r?.switches||{},c=r?[`ack ${s.ack?.on?`开(${s.ack.count} 条)`:`关`}`,`交付上下文 ${s.deliveryTemplate?.custom?`自定义`:`内置默认`}`,`持续 get ${r.getLoop?.enabled?`开(${r.getLoop.waitMinutes} 分钟)`:`关`}`].join(` · `):``,l=r?`预览:agent 执行 get 会收到的提示词${r.task?.id?` · #${r.task.id}`:` · 草稿`}`:`预览:agent 执行 get 会收到的提示词`;return(0,Y.jsxs)(i,{title:l,size:`wide`,onClose:t,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`mdw-prev-hint`,children:`与 CLI 取任务共用同一份排版;不含「已取得下一条任务…」头部行。`}),(0,Y.jsx)(`span`,{className:`grow`}),(0,Y.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:o,disabled:!r,children:`复制原文`}),(0,Y.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:t,children:`关闭`})]}),children:[e.busy&&(0,Y.jsx)(`div`,{className:`mdw-prev-note`,children:`渲染中…`}),e.error&&(0,Y.jsxs)(`div`,{className:`mdw-prev-note`,children:[`预览失败:`,e.error,/接口不存在/.test(String(e.error))&&(0,Y.jsx)(`div`,{className:`mdw-prev-hint`,children:`本机面板服务较旧:重启面板(结束当前 serve 进程后重新启动)即可生效,刷新页面不够。`})]}),r&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`pre`,{className:`mdw-prev-body`,children:r.rendered||``}),r.segments?.length?(0,Y.jsxs)(`details`,{className:`mdw-prev-seg`,children:[(0,Y.jsxs)(`summary`,{children:[`段落来源(`,r.segments.length,` 段)`]}),(0,Y.jsx)(`ol`,{children:r.segments.map((e,t)=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`span`,{className:`mdw-prev-seg-lab`,children:e.label}),(0,Y.jsxs)(`span`,{className:`mdw-prev-seg-n`,children:[String(e.text||``).length,` 字`]})]},t))}),(0,Y.jsx)(`div`,{className:`mdw-prev-note`,children:`改这些段去「设置 → 提示词 / 模板」;「持续 get」在项目级设置里。`})]}):(0,Y.jsx)(`div`,{className:`mdw-prev-note`,children:`当前没有任何模板段:交付时就只有任务正文。`}),(0,Y.jsx)(`div`,{className:`mdw-prev-switch`,children:c})]})]})}function Ne(e){let t=Math.max(0,Number(e)||0);return t>=3600?`${Math.floor(t/3600)}h ${Math.floor(t%3600/60)}m`:t>=60?`${Math.floor(t/60)}m ${t%60}s`:`${t}s`}function Pe({dockOpen:e,dockTab:t,dockH:n,dockRef:r,dockMax:i,showDockTab:a,onDockDragStart:s,toggleDockMax:l,setDockOpen:u,canShowGoalLog:d,goalLog:f,openGoalLog:p,isDraft:m,task:h,topic:g,topicKey:_,isGlobal:v,doc:y,id:b,model:x,app:S,refreshLocal:C,markDirty:T,saveDoc:E,persistAtt:D,attachAreaRef:O,reviewBarRef:A,reviewSumRef:ee,taskRow:j,ackOpen:M,setAckOpen:N,ackOverflow:P,ackLong:F,ackHtml:I,isChainTip:L,latestChild:R,openFeedback:z,openLatestRound:B}){return e?(0,Y.jsxs)(`div`,{className:`mdw-dock`,ref:r,style:{height:`${n}px`},children:[(0,Y.jsx)(`div`,{className:`mdw-dock-drag`,role:`separator`,"aria-orientation":`horizontal`,title:`上下拖动调整信息面板高度(双击最大化 / 还原)`,onMouseDown:s,onDoubleClick:l}),(0,Y.jsxs)(`div`,{className:`mdw-dock-head`,children:[(0,Y.jsxs)(`div`,{className:`mdw-dock-tabs`,role:`tablist`,"aria-label":`信息面板`,children:[(0,Y.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===`attach`,className:`mdw-dock-tab${t===`attach`?` is-on`:``}`,onClick:()=>a(`attach`),children:`附件`}),d?(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===`check`,className:`mdw-dock-tab${t===`check`?` is-on`:``}`,onClick:p,children:[`check`,(0,Y.jsx)(`span`,{className:`mdw-dock-tab-num`,children:f.data?.count??0})]}):null,(0,Y.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===`feedback`,className:`mdw-dock-tab${t===`feedback`?` is-on`:``}`,onClick:()=>a(`feedback`),children:`反馈`})]}),(0,Y.jsxs)(`div`,{className:`mdw-dock-acts`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:l,title:i?`还原面板高度`:`最大化面板高度`,"aria-label":i?`还原面板高度`:`最大化面板高度`,children:(0,Y.jsx)(o,{name:i?`collapse`:`expand`})}),(0,Y.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:()=>u(!1),title:`关闭面板(底部状态栏仍保留入口)`,"aria-label":`关闭面板`,children:(0,Y.jsx)(o,{name:`x`})})]})]}),(0,Y.jsxs)(`div`,{className:`mdw-dock-body`,children:[t===`attach`?m?(0,Y.jsx)(V,{attachments:y.attachments,onRemove:e=>{let t=(y.attachments||[]).filter(t=>t.id!==e);T(),E(b,{attachments:t}),m||D(h,t)}}):g?(0,Y.jsx)(ae,{ref:O,host:`task`,hostId:Number(h),hostKey:v?k:void 0,hostCwd:v?void 0:g.cwd,allow:{file:!0,url:!0,task:!0,ref:!0},taskOptions:(g.tasks||[]).map(e=>({id:e.id,text:e.text,status:e.status})),onChanged:C,onOpenTask:e=>{S.openPage&&e&&e.seq!=null&&S.openPage({dirKey:e.key||_,task:String(e.seq),name:`#${e.seq}`})},onOpenDoc:e=>{let t=w(e);x&&t&&c(x,{component:`doc`,name:e.split(`/`).pop()||e,config:{docId:t},location:`center`})}}):(0,Y.jsx)(`div`,{className:`mdw-dock-empty`,children:`没有可挂载附件的上下文。`}):null,t===`check`?(0,Y.jsxs)(`div`,{className:`mdw-dock-check`,children:[f.busy&&!f.data?(0,Y.jsx)(`div`,{className:`mdw-dock-empty`,children:`读取中…`}):null,f.error?(0,Y.jsxs)(`div`,{className:`mdw-dock-empty`,children:[`读取失败:`,f.error]}):null,f.data?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`mdw-dock-meta mono`,children:[`时间目标 ${f.data.duration||`—`}`,f.data.startedAt?` · 开始 ${f.data.startedAt}`:``,f.data.deadline?` · 截止 ${f.data.deadline}`:` · 尚未开始计时`,f.data.archived?` · 已归档`:``,` · ${f.data.count||0} 轮`]}),(f.data.count||0)>0?(0,Y.jsx)(`div`,{className:`mdw-goal-log`,children:f.data.entries.map((e,t)=>(0,Y.jsxs)(`div`,{className:`mdw-goal-log-row`,children:[(0,Y.jsxs)(`div`,{className:`mdw-goal-log-head mono`,children:[`R`,t+1,` · `,e.checkedAt,` · `,e.reached?`已到点`:`未到点`,` · 已用`,` `,Ne(e.elapsedSec),` · 剩余 `,Ne(e.remainingSec)]}),e.summary?(0,Y.jsx)(`div`,{className:`mdw-goal-log-body`,children:e.summary}):null,e.progress?(0,Y.jsx)(`div`,{className:`mdw-goal-log-prog`,children:e.progress}):null]},`${e.checkedAt}-${t}`))}):(0,Y.jsx)(`div`,{className:`mdw-dock-empty`,children:`还没有 check 记录——任务领取后每轮 check 会出现在这里。`})]}):null]}):null,t===`feedback`?!m&&j?.completedAt?(0,Y.jsxs)(`div`,{className:`mdw-review`,ref:A,children:[(0,Y.jsxs)(`div`,{className:`mdw-review-main`,children:[(0,Y.jsx)(`span`,{className:`mdw-review-badge`,children:`已完成 · 等待验收`}),(0,Y.jsx)(`span`,{className:`mdw-review-at mono`,children:j.completedAt}),j.roundSummary?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{ref:ee,className:`mdw-review-sum${M?` is-open`:``}`,title:M||!(P||F)?`agent 的完成总结(ack)`:`点击下方展开全文`,dangerouslySetInnerHTML:{__html:I}}),(P||F||M)&&(0,Y.jsx)(`button`,{type:`button`,className:`mdw-review-more`,onClick:()=>N(e=>!e),children:M?`收起`:`展开全文`})]}):null]}),(0,Y.jsx)(`div`,{className:`mdw-review-acts`,children:L?(0,Y.jsx)(`button`,{type:`button`,className:`ghost`,onClick:z,title:`新开一条任务携带反馈(原任务不动)`,children:`反馈`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`mdw-review-later`,title:`这条任务已有后续轮次——在旧轮次上反馈会把链分叉,请到最新一轮反馈`,children:`已进入后续轮次`}),R?(0,Y.jsxs)(`button`,{type:`button`,className:`ghost`,onClick:B,title:`到最新一轮 #${R.id} 反馈`,children:[`去最新一轮 #`,R.id]}):null]})})]}):(0,Y.jsx)(`div`,{className:`mdw-dock-empty`,children:`任务完成后,agent 的完成总结会显示在这里。`}):null]})]}):null}function Fe({dockOpen:e,dockTab:t,showDockTab:n,setDockOpen:r,canShowGoalLog:i,goalLog:a,openGoalLog:s,isDraft:c,taskRow:l}){return(0,Y.jsxs)(`div`,{className:`mdw-sbar`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${e&&t===`attach`?` is-on`:``}`,onClick:()=>n(`attach`),title:`附件(点击展开信息面板)`,children:[(0,Y.jsx)(o,{name:`list`}),(0,Y.jsx)(`span`,{className:`mdw-sbar-lab`,children:`附件`})]}),i?(0,Y.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${e&&t===`check`?` is-on`:``}`,onClick:s,title:`时间目标每轮 check(点击展开信息面板)`,children:[(0,Y.jsx)(o,{name:`clock`}),(0,Y.jsx)(`span`,{className:`mdw-sbar-lab`,children:`check`}),(0,Y.jsx)(`span`,{className:`mdw-sbar-num`,children:a.data?.count??0})]}):null,(0,Y.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${e&&t===`feedback`?` is-on`:``}`,onClick:()=>n(`feedback`),title:`完成总结 / 反馈(点击展开信息面板)`,children:[(0,Y.jsx)(o,{name:`edit`}),(0,Y.jsx)(`span`,{className:`mdw-sbar-lab`,children:`反馈`})]}),(0,Y.jsx)(`span`,{className:`mdw-sbar-grow`}),!c&&l?(0,Y.jsx)(`span`,{className:`mdw-sbar-stat`,title:`任务状态`,children:(0,Y.jsx)(R,{t:l})}):null,(0,Y.jsx)(`button`,{type:`button`,className:`mdw-sbar-chev${e?` is-open`:``}`,onClick:()=>r(e=>!e),title:e?`收起信息面板`:`展开信息面板`,"aria-expanded":e,"aria-label":e?`收起信息面板`:`展开信息面板`,children:(0,Y.jsx)(o,{name:`chevron`})})]})}function Ie({goal:e,setGoalDraft:t,goalEditable:n,goalPromptEditable:r,declaredGoal:i,openGoalLog:a,markDirty:o,task:s}){let c=(e.duration||``).trim(),l=(e.prompt||``).trim(),u=!!r;return{goalBadge:c||l?{label:`⏱ ${c||`目标`}`,title:l||(n?`任务级时间目标(在「更多」里设置;领取即计时)`:`已领取计时,时长不可改(附加要求仍可编辑)`)}:null,goalMenu:n||u||i?(0,Y.jsxs)(`div`,{className:`mdw-goal-menu`,children:[(0,Y.jsx)(`div`,{className:`mdw-goal-menu-lab`,children:`时间目标`}),n?(0,Y.jsx)(`input`,{className:`mdw-goal-dur mono`,value:e.duration,placeholder:`2h / 90m / 30分钟,留空不带`,onChange:n=>{t({...e,duration:n.target.value}),o()}}):(0,Y.jsxs)(`span`,{className:`mdw-goal-ro mono`,title:`已领取计时,时长不可改`,children:[i?.duration||`—`,` · 已领取计时`]}),u?(0,Y.jsx)(`input`,{className:`mdw-goal-prompt`,value:e.prompt,placeholder:`附加要求(可选;领取后仍可改,下一轮 check 即生效)`,onChange:n=>{t({...e,prompt:n.target.value}),o()}}):i?.prompt?(0,Y.jsx)(`span`,{className:`mdw-goal-ro`,title:`任务已到终态,附加要求不可改`,children:i.prompt}):null,i&&s!=null?(0,Y.jsx)(`button`,{type:`button`,className:`ghost`,onClick:a,title:`查看时间目标的每轮 check 记录`,children:`查看每轮 check 日志`}):null]}):null}}function Le({historyId:e,historyNode:t,closeBesideSelf:n}){let r={origin:`起点`,reopen:`反馈`,comment:`评论`}[t?.kind]||`节点`,i=t?T(t.text||``,t.attachments||[]):``;return(0,Y.jsxs)(`div`,{className:`mdw is-beside`,children:[(0,Y.jsxs)(`div`,{className:`mdw-beside-h`,children:[(0,Y.jsxs)(`span`,{className:`mdw-beside-lab`,children:[`链节点 · `,r,` #`,e]}),(0,Y.jsx)(`span`,{className:`grow`}),(0,Y.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭`,"aria-label":`关闭`,onClick:n,children:`×`})]}),(0,Y.jsx)(`div`,{className:`mdw-hist-ro`,children:t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`mdw-hist-meta`,children:[(0,Y.jsx)(`span`,{children:t.at||`—`}),t.quote?(0,Y.jsxs)(`span`,{children:[`锚定:`,t.quote.slice(0,80)]}):null,t.feedback?(0,Y.jsxs)(`span`,{children:[`反馈:`,t.feedback.slice(0,80)]}):null,t.summary?(0,Y.jsxs)(`span`,{children:[`上轮总结:`,t.summary.slice(0,80)]}):null]}),(0,Y.jsx)(`article`,{className:`md-body`,dangerouslySetInnerHTML:{__html:i||`<p class="muted">(空)</p>`}})]}):(0,Y.jsxs)(`div`,{className:`muted`,children:[`找不到链节点 #`,e]})})]})}function Re({boardCtx:e,docFm:t,goalEditable:n,doc:r,id:i,markDirty:a}){return e?(0,Y.jsxs)(`div`,{className:`mdw-goal`,children:[(0,Y.jsx)(`span`,{className:`mdw-goal-lab`,title:`归属项目(限本组成员):决定提交进哪个项目的队列;由组面板「新增任务」创建时自动携带本组语义`,children:`归属项目`}),n?(0,Y.jsx)(`select`,{className:`mdw-proj-pick`,value:t.project||``,onChange:n=>{F(i,{body:p(r.body,{...t,board:e.board.id,project:n.target.value})}),a()},children:e.members.map(e=>(0,Y.jsx)(`option`,{value:e.key,children:e.name},e.key))}):(0,Y.jsx)(`span`,{className:`mdw-proj-ro`,title:`归属项目(在本组创建时写入,随任务走)`,children:(e.members.find(e=>e.key===t.project)||{}).name||t.project||`—`})]}):null}function ze({task:e,app:t,groupAnchored:n,groupId:r,isGlobal:i,dirKey:a}){return(0,Y.jsx)(`div`,{className:`mdw`,children:(0,Y.jsxs)(`div`,{className:`pad stack`,children:[(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(`strong`,{children:[`找不到任务 #`,e]})}),(0,Y.jsx)(`div`,{className:`hint`,children:`它可能已被删除(软删除可用 nx-kv localtask task restore 恢复),或这个深链写错了。`}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>t.onNavigate&&t.onNavigate(n?`#/group/`+encodeURIComponent(r||``):i?`#/global`:`#/dir/`+encodeURIComponent(a||``)),children:`回到目录`})})]})})}function Be({onClose:e}){return(0,Y.jsxs)(`div`,{className:`mdw-beside-h`,children:[(0,Y.jsx)(`span`,{className:`mdw-beside-lab`,children:`原文(旁路)`}),(0,Y.jsx)(`span`,{className:`grow`}),(0,Y.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭原文面板`,"aria-label":`关闭原文面板`,onClick:e,children:`×`})]})}function Ve({dirKey:e,groupId:t,task:i,beside:o=!1,tabId:s,model:c,historyId:f=null}){let m=d()||{},_=a(),{dialog:x,node:C}=n(),w=m.rows||[],D=m.refreshLocal,ee=m.tpl,j=!(!t||e),L=(0,G.useMemo)(()=>j?O(w,m.repoData&&m.repoData.boards||[],t,i):null,[j,w,m.repoData,t,i]),R=L&&L.topic&&L.topic.key||e||``,B=!j&&(!R||R===`__GLOBAL__`),V=N(i),re=P(j&&V?t:R),H=I(re,i),U=(0,G.useMemo)(()=>j?L&&L.topic||null:B?w.find(e=>e.isGlobal)||null:w.find(e=>e.key===R)||null,[w,R,B,j,L]),W=(0,G.useMemo)(()=>(U?.tasks||[]).find(e=>String(e.id)===String(i))||null,[U,i]),ae=M(),K=ae[H]||null,q=K&&K.mode===`edit`?`edit`:`split`,{dockOpen:J,setDockOpen:oe,dockTab:se,dockH:le,dockRef:ue,dockMax:de,showDockTab:fe,onDockDragStart:pe,toggleDockMax:me}=we(),{goalDraft:he,setGoalDraft:_e,goal:ye,goalEditable:xe,goalPromptEditable:Se,declaredGoal:Ne,goalLog:Ve,loadGoalLog:He,canShowGoalLog:Ue}=Te({id:H,isDraft:V,topicKey:R,task:i,taskRow:W}),{chainNodes:We,historyNode:Ge,isChainTip:Ke,latestChild:qe,openLatestRound:Je,openHistoryBeside:Ye}=Ee({isDraft:V,task:i,taskRow:W,topicKey:R,topic:U,isGlobal:B,groupAnchored:j,groupId:t,app:m,model:c,historyId:f,toast:_}),{selMenu:X,setSelMenu:Xe,lastSel:Ze,placeSelMenu:Qe,onEditorTextSel:$e,closeSelMenu:Z}=De({id:H}),{ackOpen:et,setAckOpen:tt,ackOverflow:nt,reviewSumRef:rt,ackLong:it}=Oe({id:H,taskRow:W,dockTab:se,dockOpen:J}),[at,ot]=(0,G.useState)(null),[st,ct]=(0,G.useState)(!1),[lt,ut]=(0,G.useState)(!1),[dt,ft]=(0,G.useState)(!1),pt=(0,G.useRef)(null),mt=(0,G.useRef)(null),ht=(0,G.useRef)(null),gt=(0,G.useRef)(null),_t=(0,G.useRef)(null),vt=(0,G.useRef)(null),yt=(0,G.useRef)(new Map),[bt,xt]=(0,G.useState)([]);(0,G.useEffect)(()=>{let e=!0,t=W;if(!t||!t.id)return;let n=new URLSearchParams({id:String(t.id)});return R?n.set(`key`,R):t.cwd&&n.set(`cwd`,t.cwd),r(`/api/localtasks/attachments?${n.toString()}`).then(t=>{e&&xt(t&&(t.attachments||t.data?.attachments)||[])}).catch(()=>{e&&xt([])}),()=>{e=!1}},[W,R]);let St=(0,G.useMemo)(()=>K?T(g(K.body),bt.length?bt:K.attachments):``,[K,bt]),Ct=(0,G.useMemo)(()=>W?.roundSummary?T(W.roundSummary):``,[W?.roundSummary]),wt=(0,G.useMemo)(()=>K?ce(K.body):[],[K&&K.body]),[Tt,Et]=(0,G.useState)(null);(0,G.useEffect)(()=>{let e=gt.current;if(!e)return;let t=()=>e.closest(`.mdw-lp`)||e.closest(`.mdw-preview`)||null;Et(t());let n=typeof MutationObserver<`u`?new MutationObserver(()=>Et(t())):null;return n?.observe(e,{childList:!0,subtree:!0}),()=>n?.disconnect()},[K&&K.mode]);let Dt=(0,G.useCallback)(e=>e().catch(e=>_(String(e.message||e))),[_]),Q=(0,G.useCallback)(()=>ft(!0),[]),{docFm:Ot,parentRef:$,boardCtx:kt}=je({doc:K,beside:o,topicKey:R,topic:U,task:i,app:m});(0,G.useEffect)(()=>{ae[H]||(V?A(H,{title:``,body:ee?j?p(ee.defaultBody(),{board:t}):ee.defaultBody():``}):W&&A(H,{title:E(W.text),body:W.text}))},[H,V,W,j,t]);let{composeText:At,submit:jt,importMd:Mt,delTask:Nt,canClosePending:Pt,closeTask:Ft,addFiles:It,newTask:Lt,cloneCur:Rt,forkCur:zt,openProgress:Bt,openAttachPanel:Vt}=ke({doc:K,id:H,isDraft:V,task:i,taskRow:W,topicKey:R,topic:U,isGlobal:B,boardCtx:kt,docFm:Ot,groupAnchored:j,groupId:t,rows:w,app:m,model:c,tabId:s,tpl:ee,refreshLocal:D,markDirty:Q,histRef:yt,editorApiRef:vt,attachAreaRef:ht,setDirty:ft,goal:ye,goalEditable:xe,goalPromptEditable:Se,declaredGoal:Ne,guard:Dt,dialog:x,showDockTab:fe}),{openFeedback:Ht,submitCommentInPlace:Ut,openCommentFromToolbar:Wt}=Ae({doc:K,isDraft:V,task:i,taskRow:W,topicKey:R,topic:U,isGlobal:B,dirKey:e,groupAnchored:j,groupId:t,app:m,model:c,tabId:s,refreshLocal:D,closeSelMenu:Z,lastSel:Ze,selMenu:X,dirty:dt,setDirty:ft,guard:Dt}),Gt=(0,G.useCallback)(()=>{fe(`check`),He()},[fe,He]),{goalBadge:Kt,goalMenu:qt}=Ie({goal:ye,goalDraft:he,setGoalDraft:_e,goalEditable:xe,goalPromptEditable:Se,declaredGoal:Ne,openGoalLog:Gt,markDirty:Q,task:i}),Jt=(0,G.useCallback)(()=>{ot({busy:!0});let e={cwd:B?U?.cwd||void 0:U?.cwd,key:B?k:R,...V?{text:At((K?.title||``).trim()||`未命名任务`,K?.body||``)}:{id:Number(i)}};r(`/api/localtasks/preview`,{method:`POST`,body:e}).then(e=>ot({data:e})).catch(e=>ot({error:String(e.message||e)}))},[B,U?.cwd,R,V,K?.title,K?.body,i,At]),Yt=(e,t=`typing`)=>{if(!K)return;b(yt.current,H,{title:K.title,body:K.body},t),Q();let n={title:e};q!==`split`&&/^# (?!#)/m.test(K.body)&&(n.body=K.body.replace(/^# (?!#).+$/m,`# ${e||`未命名任务`}`)),F(H,n)},Xt=(e,t=`op`)=>{if(!K)return;b(yt.current,H,{title:K.title,body:K.body},t),Q();let n={body:e};q!==`split`&&(n.title=E(e)),F(H,n)},Zt=()=>{if(!K)return;let e=v(yt.current,H,{title:K.title,body:K.body});e&&(F(H,{title:e.title,body:e.body}),Q(),requestAnimationFrame(()=>vt.current?.caretFromDiff?.(K.body,e.body)))},Qt=()=>{if(!K)return;let e=S(yt.current,H,{title:K.title,body:K.body});e&&(F(H,{title:e.title,body:e.body}),Q(),requestAnimationFrame(()=>vt.current?.caretFromDiff?.(K.body,e.body)))},$t=e=>{if(!K||q===`edit`||e.target.closest?.(`#mdw-sel-menu`)||e.target.closest?.(`textarea`))return;let t=window.getSelection(),n=(t&&String(t)).trim();if(!n||n.length<1){Xe(null);return}if(!gt.current?.contains(t.anchorNode)){Xe(null);return}let r=e=>e?.nodeType===3?e.parentElement:e,i=r(t.anchorNode)?.closest?.(`.mdw-lp-block`),a=r(t.focusNode)?.closest?.(`.mdw-lp-block`),o=null;if(i&&a&&i!==a&&gt.current?.contains(a)){let e=Number(i.getAttribute(`data-i`)),t=Number(a.getAttribute(`data-i`));Number.isInteger(e)&&Number.isInteger(t)&&e!==t&&(o=[Math.min(e,t),Math.max(e,t)])}let s=t.getRangeAt(0),c=s.getClientRects(),l=c.length?c[c.length-1]:s.getBoundingClientRect();Qe(`task`,n,l.right-60,l.bottom+8,o?{blockRange:o}:{})},en=(0,G.useCallback)(()=>{if(!$){_(`这条任务没有可定位的原文`);return}let e=c||m.model;e&&l(e,{component:`page`,name:$.name||`原文 ${$.task}`,config:{dirKey:$.dirKey,task:String($.task)}})},[$,c,m.model,_]),tn=(0,G.useCallback)(()=>{let e=c||m.model;e&&s&&e.doAction(u.deleteTab(s))},[c,m.model,s]),nn=e=>{mt.current.accept=e,mt.current?.click()};return(0,G.useEffect)(()=>{if(!$||o)return;let e=e=>{(e.ctrlKey||e.metaKey)&&e.shiftKey&&String(e.key||``).toLowerCase()===`o`&&(e.preventDefault(),en())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[$,o,en]),f==null?K?(0,Y.jsxs)(`div`,{className:`mdw${o?` is-beside`:``}`,"data-mode":q,onMouseUp:$t,children:[C,at&&(0,Y.jsx)(Me,{state:at,onClose:()=>ot(null)}),(0,Y.jsx)(Ce,{open:lt,nodes:We,onOpenNode:Ye,onClose:()=>ut(!1)}),o&&(0,Y.jsx)(Be,{onClose:tn}),(0,Y.jsxs)(`div`,{className:`mdw-main`,children:[(0,Y.jsxs)(`div`,{className:`mdw-top`,children:[(0,Y.jsx)(ne,{}),(0,Y.jsxs)(`div`,{className:`mdw-head`,children:[(0,Y.jsx)(`div`,{className:`mdw-title`,children:V?K.title||`新 MD 任务`:K.title||`任务`}),(0,Y.jsxs)(`div`,{className:`mdw-path`,children:[B?`全局任务池`:U?.cwd||U?.name||`—`,V?` / (${i})`:` / #${i}`,dt?` · 未保存`:``]})]})]}),(0,Y.jsx)(Re,{boardCtx:kt,docFm:Ot,goalEditable:xe,doc:K,id:H,markDirty:Q}),(0,Y.jsx)(ie,{mode:q,onMode:e=>F(H,{mode:e}),showMark:q!==`edit`,submitLabel:V?`提交为任务`:`保存并同步`,onNew:Lt,onSubmit:jt,onChain:V?null:()=>ut(!0),onPreview:Jt,onImg:()=>nn(`image/*`),onAtt:()=>V?nn(`image/*,.pdf,.zip,.txt,.json,.csv`):Vt(),onImport:()=>pt.current?.click(),onClone:V?null:Rt,onFork:V?null:zt,onComplete:Pt?()=>Ft(`done`):null,onCancelTask:Pt?()=>Ft(`cancel`):null,onMark:Wt,onDraft:()=>_(`草稿随页签保留(刷新后需从侧栏或页签重新打开)`),onDelete:V?null:Nt,onOverview:()=>m.onNavigate&&m.onNavigate(`#/overview`),onProg:Bt,onSource:$?en:null,onShortcuts:()=>ct(!0),goalBadge:Kt,goalMenu:qt}),(0,Y.jsx)(h,{ref:gt,mode:q,title:K.title,body:K.body,previewHtml:St,onTitle:Yt,onBody:Xt,attachments:bt.length?[...K.attachments,...bt]:K.attachments,docKey:H,editorApiRef:vt,onFiles:It,onTextSel:$e,onSave:jt,onUndo:Zt,onRedo:Qt,onCloseSelMenu:Z,attachHost:V?null:{host:`task`,hostId:Number(i),hostKey:B?k:void 0,hostCwd:B?void 0:U?.cwd,allow:{file:!0,url:!0,task:!0,ref:!0},taskOptions:(U.tasks||[]).map(e=>({id:e.id,text:e.text,status:e.status}))}}),(0,Y.jsx)(Pe,{dockOpen:J,dockTab:se,dockH:le,dockRef:ue,dockMax:de,showDockTab:fe,onDockDragStart:pe,toggleDockMax:me,setDockOpen:oe,canShowGoalLog:Ue,goalLog:Ve,openGoalLog:Gt,isDraft:V,task:i,topic:U,topicKey:R,isGlobal:B,doc:K,id:H,model:c,app:m,refreshLocal:D,markDirty:Q,saveDoc:F,persistAtt:z,attachAreaRef:ht,reviewBarRef:_t,reviewSumRef:rt,taskRow:W,ackOpen:et,setAckOpen:tt,ackOverflow:nt,ackLong:it,ackHtml:Ct,isChainTip:Ke,latestChild:qe,openFeedback:Ht,openLatestRound:Je}),(0,Y.jsx)(Fe,{dockOpen:J,dockTab:se,showDockTab:fe,setDockOpen:oe,canShowGoalLog:Ue,goalLog:Ve,openGoalLog:Gt,isDraft:V,taskRow:W})]}),(0,Y.jsx)(ge,{nodes:wt,scrollRoot:Tt}),(0,Y.jsx)(ve,{at:X,onFormat:e=>{vt.current?.format?.(e),Z()},onCompose:()=>{let t=c||m.model;if(!t)return;let n=String(X?.text||Ze.current||``);te(t,{mode:`comment`,quote:n,taskLabel:i==null?``:`#`+i,taskTitle:String(K?.title||``).replace(/^#+\s*/,``),src:{dirKey:R||e||`__GLOBAL__`,task:String(i),name:`原文 #${i}`},onSubmit:e=>Ut({...e,quote:n})}),Z()},onCopy:()=>{let e=X?.blockRange,t=``;if(e&&K){let n=y(K.body);e[1]<n.length&&(t=n.slice(e[0],e[1]+1).filter(e=>String(e??``).trim()).join(`
10
+
11
+ `))}navigator.clipboard?.writeText(t||Ze.current||X?.text||``),_(`已复制`),Z()},onDelete:X?.blockRange?()=>{let e=X.blockRange;vt.current?.deleteBlockRange?.(e[0],e[1])?_(`已删除 ${e[1]-e[0]+1} 个块(Ctrl+Z 可撤销)`):_(`选区已失效`),Z()}:null}),(0,Y.jsx)(`input`,{ref:mt,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,t.length&&It(t)}}),(0,Y.jsx)(`input`,{ref:pt,type:`file`,accept:`.md,text/markdown,text/plain`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&Mt(t)}}),st&&(0,Y.jsx)(be,{onClose:()=>ct(!1)})]}):m.localReady===!1||V?(0,Y.jsx)(`div`,{className:`mdw`,children:(0,Y.jsx)(`div`,{className:`pad muted`,children:`载入中…`})}):(0,Y.jsx)(ze,{task:i,app:m,groupAnchored:j,groupId:t,isGlobal:B,dirKey:e}):(0,Y.jsx)(Le,{historyId:f,historyNode:Ge,closeBesideSelf:tn})}export{Ve as default};
@@ -1 +1 @@
1
- import{g as e,h as t,p as n,y as r}from"./task-status-BnymQMTw.js";import{n as i,v as a}from"./workspace-C_5X2gIr.js";import{n as o}from"./app-context-D7HAx67n.js";import{a as s,i as c,n as l,r as u,t as d,v as f}from"./md-history-C9vOgGLz.js";import{i as p,t as m}from"./index-DNB8tgNi.js";import{t as h}from"./route-crumb-BfRi1GKw.js";var g=r(e(),1),_=t(),v=e=>`tpl:${e||`new`}`;function y({templateId:e,initialName:t,initialBody:r,isNew:i,onSave:a,onClose:o,busy:p}){let m=n(),[y,b]=(0,g.useState)(t||``),[x,S]=(0,g.useState)(r||``),[C,w]=(0,g.useState)(`split`),[T,E]=(0,g.useState)(!1),D=(0,g.useRef)(null),O=(0,g.useRef)(new Map),k=v(i?`new`:e),A=(0,g.useMemo)(()=>f(x||``),[x]),j=(e,t,n=`typing`)=>{l(O.current,k,{title:y,body:x},n),b(e),S(t),E(!0)},M=(e,t=`typing`)=>j(e,x,t),N=(e,t=`op`)=>j(y,e,t),P=()=>{let e=c(O.current,k,{title:y,body:x});e&&(b(e.title||``),S(e.body||``),E(!0))},F=()=>{let e=u(O.current,k,{title:y,body:x});e&&(b(e.title||``),S(e.body||``),E(!0))},I=async()=>{if(!(y||``).trim()){m(`模板名不能为空(标题即名称)`);return}await a({name:y.trim(),body:x}),d(O.current,k),E(!1)};return(0,_.jsx)(`div`,{className:`mdw mdw-tpl-edpage`,"data-mode":C,children:(0,_.jsxs)(`div`,{className:`mdw-main`,children:[(0,_.jsxs)(`div`,{className:`mdw-top`,children:[(0,_.jsx)(h,{}),(0,_.jsxs)(`div`,{className:`mdw-head`,children:[(0,_.jsx)(`div`,{className:`mdw-title`,children:i?`新建模板`:`编辑模板`}),(0,_.jsxs)(`div`,{className:`mdw-path`,children:[`任务模板`,y?` / ${y}`:``,T?` · 未保存`:``]})]})]}),(0,_.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,_.jsx)(`div`,{className:`mdw-toolbar-left`,children:(0,_.jsx)(`div`,{className:`seg`,role:`group`,"aria-label":`编辑模式`,children:[{id:`split`,label:`并排`},{id:`edit`,label:`源码`}].map(e=>(0,_.jsx)(`button`,{type:`button`,className:C===e.id?`on`:``,onClick:()=>w(e.id),children:e.label},e.id))})}),(0,_.jsxs)(`div`,{className:`mdw-actions`,role:`group`,"aria-label":`模板操作`,children:[(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:p,onClick:o,children:`关闭`}),(0,_.jsx)(`button`,{type:`button`,className:`btn sm primary`,disabled:p||!T,onClick:I,children:i?`创建`:`保存`})]})]}),(0,_.jsx)(s,{mode:C,title:y,body:x,previewHtml:A,onTitle:M,onBody:N,docKey:k,editorApiRef:D,onSave:I,onUndo:P,onRedo:F,attachments:[]})]})})}function b({config:e,model:t,tabId:r}){let s=o()||{},c=s.tpl,l=n(),[u,d]=(0,g.useState)(!1),f=e||{},v=(f.mode||(f.id?`edit`:``))===`new`,b=f.id||``,x=()=>{let e=m();if(e&&s.onNavigate){s.onNavigate(e);return}if(s.onNavigate){s.onNavigate(`#/overview`);return}if(t&&r)try{t.doAction(a.deleteTab(r))}catch{}};if(!c)return(0,_.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,_.jsx)(h,{}),(0,_.jsx)(`div`,{className:`pad muted`,children:`模板服务未就绪 —— 面板还在装载。`})]});if(!v&&!b)return(0,_.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,_.jsx)(h,{}),(0,_.jsxs)(`div`,{className:`pad stack`,children:[(0,_.jsx)(`div`,{children:`模板在「设置 → 任务模板」管理;这里只承载全屏编辑。`}),(0,_.jsx)(`div`,{children:(0,_.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{t&&i(t,{component:`settings`,name:`设置`,config:{}}),x()},children:`打开设置`})})]})]});let S=v?null:(c.templates||[]).find(e=>e.id===b);if(!v&&!S)return(0,_.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,_.jsx)(h,{}),(0,_.jsxs)(`div`,{className:`pad muted`,children:[`找不到模板「`,b,`」——可能已删除。`]})]});let C=async({name:e,body:t})=>{d(!0);try{if(v){let n={};Array.isArray(f.scope)&&(n.scope=f.scope),f.topic&&(n.topic=f.topic),await c.add(e,t,!1,n),l(`已创建模板`)}else await c.update(b,{name:e,body:t}),l(`已保存模板`);x()}catch(e){l(String(e.message||e))}finally{d(!1)}},w=v?f.name||``:S.name,T=v?``:p(S.body||``,S.values||{});return(0,_.jsx)(y,{templateId:b,initialName:w,initialBody:T,isNew:v,busy:u,onSave:C,onClose:x},v?`new:${f.topic||``}:${(f.scope||[]).join(`,`)}`:b)}export{b as default};
1
+ import{g as e,h as t,p as n,y as r}from"./task-status-BnymQMTw.js";import{n as i,v as a}from"./workspace-C_5X2gIr.js";import{n as o}from"./app-context-D7HAx67n.js";import{a as s,i as c,n as l,r as u,t as d,v as f}from"./md-history-DI1Ukbvc.js";import{i as p,t as m}from"./index-Dq7eNqAB.js";import{t as h}from"./route-crumb-_IyS9fTT.js";var g=r(e(),1),_=t(),v=e=>`tpl:${e||`new`}`;function y({templateId:e,initialName:t,initialBody:r,isNew:i,onSave:a,onClose:o,busy:p}){let m=n(),[y,b]=(0,g.useState)(t||``),[x,S]=(0,g.useState)(r||``),[C,w]=(0,g.useState)(`split`),[T,E]=(0,g.useState)(!1),D=(0,g.useRef)(null),O=(0,g.useRef)(new Map),k=v(i?`new`:e),A=(0,g.useMemo)(()=>f(x||``),[x]),j=(e,t,n=`typing`)=>{l(O.current,k,{title:y,body:x},n),b(e),S(t),E(!0)},M=(e,t=`typing`)=>j(e,x,t),N=(e,t=`op`)=>j(y,e,t),P=()=>{let e=c(O.current,k,{title:y,body:x});e&&(b(e.title||``),S(e.body||``),E(!0))},F=()=>{let e=u(O.current,k,{title:y,body:x});e&&(b(e.title||``),S(e.body||``),E(!0))},I=async()=>{if(!(y||``).trim()){m(`模板名不能为空(标题即名称)`);return}await a({name:y.trim(),body:x}),d(O.current,k),E(!1)};return(0,_.jsx)(`div`,{className:`mdw mdw-tpl-edpage`,"data-mode":C,children:(0,_.jsxs)(`div`,{className:`mdw-main`,children:[(0,_.jsxs)(`div`,{className:`mdw-top`,children:[(0,_.jsx)(h,{}),(0,_.jsxs)(`div`,{className:`mdw-head`,children:[(0,_.jsx)(`div`,{className:`mdw-title`,children:i?`新建模板`:`编辑模板`}),(0,_.jsxs)(`div`,{className:`mdw-path`,children:[`任务模板`,y?` / ${y}`:``,T?` · 未保存`:``]})]})]}),(0,_.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,_.jsx)(`div`,{className:`mdw-toolbar-left`,children:(0,_.jsx)(`div`,{className:`seg`,role:`group`,"aria-label":`编辑模式`,children:[{id:`split`,label:`并排`},{id:`edit`,label:`源码`}].map(e=>(0,_.jsx)(`button`,{type:`button`,className:C===e.id?`on`:``,onClick:()=>w(e.id),children:e.label},e.id))})}),(0,_.jsxs)(`div`,{className:`mdw-actions`,role:`group`,"aria-label":`模板操作`,children:[(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:p,onClick:o,children:`关闭`}),(0,_.jsx)(`button`,{type:`button`,className:`btn sm primary`,disabled:p||!T,onClick:I,children:i?`创建`:`保存`})]})]}),(0,_.jsx)(s,{mode:C,title:y,body:x,previewHtml:A,onTitle:M,onBody:N,docKey:k,editorApiRef:D,onSave:I,onUndo:P,onRedo:F,attachments:[]})]})})}function b({config:e,model:t,tabId:r}){let s=o()||{},c=s.tpl,l=n(),[u,d]=(0,g.useState)(!1),f=e||{},v=(f.mode||(f.id?`edit`:``))===`new`,b=f.id||``,x=()=>{let e=m();if(e&&s.onNavigate){s.onNavigate(e);return}if(s.onNavigate){s.onNavigate(`#/overview`);return}if(t&&r)try{t.doAction(a.deleteTab(r))}catch{}};if(!c)return(0,_.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,_.jsx)(h,{}),(0,_.jsx)(`div`,{className:`pad muted`,children:`模板服务未就绪 —— 面板还在装载。`})]});if(!v&&!b)return(0,_.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,_.jsx)(h,{}),(0,_.jsxs)(`div`,{className:`pad stack`,children:[(0,_.jsx)(`div`,{children:`模板在「设置 → 任务模板」管理;这里只承载全屏编辑。`}),(0,_.jsx)(`div`,{children:(0,_.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{t&&i(t,{component:`settings`,name:`设置`,config:{}}),x()},children:`打开设置`})})]})]});let S=v?null:(c.templates||[]).find(e=>e.id===b);if(!v&&!S)return(0,_.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,_.jsx)(h,{}),(0,_.jsxs)(`div`,{className:`pad muted`,children:[`找不到模板「`,b,`」——可能已删除。`]})]});let C=async({name:e,body:t})=>{d(!0);try{if(v){let n={};Array.isArray(f.scope)&&(n.scope=f.scope),f.topic&&(n.topic=f.topic),await c.add(e,t,!1,n),l(`已创建模板`)}else await c.update(b,{name:e,body:t}),l(`已保存模板`);x()}catch(e){l(String(e.message||e))}finally{d(!1)}},w=v?f.name||``:S.name,T=v?``:p(S.body||``,S.values||{});return(0,_.jsx)(y,{templateId:b,initialName:w,initialBody:T,isNew:v,busy:u,onSave:C,onClose:x},v?`new:${f.topic||``}:${(f.scope||[]).join(`,`)}`:b)}export{b as default};
@@ -1 +1 @@
1
- import{g as e,h as t,l as n,m as r,o as i,p as a,y as o}from"./task-status-BnymQMTw.js";import{w as s}from"./workspace-C_5X2gIr.js";import{c,d as l,f as u,l as d,o as f,s as p}from"./md-history-C9vOgGLz.js";import{n as m,o as h}from"./upload-BIMbGcCB.js";var g=o(e(),1),_=t(),v={position:(e,t)=>(e.position||0)-(t.position||0)||String(e.id).localeCompare(String(t.id)),name:(e,t)=>String(e.name||``).localeCompare(String(t.name||``)),kind:(e,t)=>String(e.kind).localeCompare(String(t.kind))||String(e.name||``).localeCompare(String(t.name||``))};function y({host:e=`task`,hostId:t,hostKey:o,hostCwd:s,refId:c,allow:d={file:!0,url:!0,task:!1,ref:!1},taskOptions:y=[],docOptions:x,disabled:S=!1,disabledText:C=`提交任务后可以在这里挂附件(当前是草稿)。`,openRef:w,onChanged:T,onOpenTask:E,onOpenDoc:D}){let O=a(),{dialog:k,node:A}=n(),[j,M]=(0,g.useState)([]),[N,P]=(0,g.useState)(!1),[F,I]=(0,g.useState)(``),[L,R]=(0,g.useState)(!1),[z,B]=(0,g.useState)(!1),[V,H]=(0,g.useState)(!1),[U,W]=(0,g.useState)(`position`),[G,K]=(0,g.useState)(null),[q,J]=(0,g.useState)(null),[Y,ee]=(0,g.useState)(!1),[X,Z]=(0,g.useState)(null),Q=(0,g.useMemo)(()=>l(e,{hostId:t,hostKey:o,hostCwd:s,refId:c}),[e,t,o,s,c]),$=(0,g.useCallback)(async()=>{if(S){M([]);return}P(!0),I(``);try{let e=await Q.list();M((e.attachments||[]).map(u))}catch(e){I(String(e&&e.message||e))}finally{P(!1)}},[Q,S]);(0,g.useEffect)(()=>{$()},[$]),(0,g.useImperativeHandle)(w,()=>({open:()=>R(!0),refresh:$}),[$]),(0,g.useEffect)(()=>{if(!X)return;let e=e=>{e.key===`Escape`&&Z(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[X]);let te=(0,g.useMemo)(()=>[...j].sort(v[U]||v.position),[j,U]),ne=te.filter(e=>e.area===`inline`),re=te.filter(e=>e.area===`area`),ie=async(e,t)=>{if(S)return;let n=m(t),r=n.length?n:[...e||[]].filter(e=>e&&e.size>0);if(!r.length)return;H(!0);let i=0;for(let e of r)try{let t=await h(e,{local:!0}),n=t.fileId||t.id;if(!n)throw Error(`上传未返回 fileId`);await Q.attach({fileId:n,name:t.name}),i+=1}catch(t){O(`「${e.name||`文件`}」添加失败:${t&&t.message||t}`)}H(!1),i&&(O(`已挂到附件区 ${i} 个文件`),await $(),T?.())},ae=async n=>{if(n)try{let i=await k({title:`说明 · ${n.name}`,input:!0,placeholder:`这一行里大概是什么(交付清单会透出给 agent)`,value:n.note||``,okText:`保存说明`});if(i===null)return;let a=typeof i==`string`?i:i&&(i.value||i.note)||``,l=e===`doc`?`/api/docs/attach-note?ref=${encodeURIComponent(String(c||``))}`:`/api/localtasks/attach-note`,u=e===`doc`?{attachment:n.id,note:a}:{id:Number(t),...o?{key:o}:s?{cwd:s}:{},attachment:n.id,note:a};await r(l,{method:`PATCH`,body:u}),O(a?`已保存说明:${a}`:`已清空说明`),await $(),T?.()}catch(e){O(`改说明失败:${e&&e.message||e}`)}},oe=e=>{e&&(J(e),R(!0))},se=async e=>{let t=G;if(t){ee(!0);try{await Q.detach(t.id,!!e),K(null),O(e?`已移除并删除资源:${t.name}`:`已解除关联:${t.name}`),await $(),T?.()}catch(e){O(`移除失败:${e&&e.message||e}`)}finally{ee(!1)}}},ce=!N&&!F&&!j.length;return(0,_.jsxs)(`div`,{className:`att-area${S?` is-disabled`:``}`,onDragOver:e=>{!S&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),B(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||B(!1)},onDrop:e=>{B(!1),!S&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),ie(null,e))},children:[A,(0,_.jsxs)(`div`,{className:`att-area-head`+(z&&!S?` is-over`:``),children:[(0,_.jsxs)(`span`,{className:`att-area-title`,children:[`附件`,j.length?(0,_.jsx)(`span`,{className:`att-count`,children:j.length}):null,V?(0,_.jsx)(`span`,{className:`att-area-note`,children:`上传中…`}):null]}),(0,_.jsxs)(`span`,{className:`att-area-acts`,children:[j.length?(0,_.jsxs)(`select`,{className:`att-sort`,value:U,onChange:e=>W(e.target.value),"aria-label":`附件排序`,children:[(0,_.jsx)(`option`,{value:`position`,children:`按添加顺序`}),(0,_.jsx)(`option`,{value:`name`,children:`按名称`}),(0,_.jsx)(`option`,{value:`kind`,children:`按类型`})]}):null,(0,_.jsx)(`button`,{type:`button`,className:`btn ghost att-add-btn`,disabled:S,onClick:()=>R(!0),children:`添加附件`})]})]}),S?(0,_.jsx)(`div`,{className:`att-empty`,children:C}):null,N?(0,_.jsx)(`div`,{className:`att-empty`,children:`加载附件…`}):null,F?(0,_.jsxs)(`div`,{className:`att-empty att-err-text`,children:[`附件加载失败:`,F]}):null,ce?(0,_.jsx)(`div`,{className:`att-empty`,children:`还没有附件。拖文件到这里,或点「添加附件」——只挂附件区,不写正文。`}):null,ne.length?(0,_.jsxs)(`div`,{className:`att-section`,children:[(0,_.jsxs)(`div`,{className:`att-section-head`,children:[p.inline,(0,_.jsx)(`span`,{className:`att-section-hint`,children:`正文里的引用,删正文行会跟着消失`})]}),ne.map(e=>b(e,{onRemove:K,onPreview:Z,onOpenTask:E,onOpenDoc:D,onEditNote:ae,onReplace:oe,key:e.id}))]}):null,re.length?(0,_.jsxs)(`div`,{className:`att-section`,children:[(0,_.jsxs)(`div`,{className:`att-section-head`,children:[p.area,(0,_.jsx)(`span`,{className:`att-section-hint`,children:`不依赖正文,删正文行也不会丢`})]}),re.map(e=>b(e,{onRemove:K,onPreview:Z,onOpenTask:E,onOpenDoc:D,onEditNote:ae,onReplace:oe,key:e.id}))]}):null,(0,_.jsx)(f,{open:L,host:e,hostId:t,hostKey:o,hostCwd:s,refId:c,allow:d,taskOptions:y,docOptions:x,replaceAttachment:q?q.id:null,replaceNote:q&&q.note||``,onClose:()=>{R(!1),J(null)},onDone:async()=>{J(null),await $(),T?.()}}),G?(0,_.jsx)(i,{title:`移除附件`,size:`sm`,busy:Y,onClose:Y?void 0:()=>K(null),footer:(0,_.jsxs)(`div`,{className:`att-foot`,children:[(0,_.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:Y,onClick:()=>K(null),children:`取消`}),(0,_.jsx)(`button`,{type:`button`,className:`btn`,disabled:Y,onClick:()=>se(!1),children:`只解除关联`}),(0,_.jsx)(`button`,{type:`button`,className:`btn danger`,disabled:Y,onClick:()=>se(!0),children:G.kind===`file`?`连文件一起删`:`连资源一起删`})]}),children:(0,_.jsxs)(`div`,{className:`att-confirm`,children:[(0,_.jsx)(`div`,{className:`att-confirm-name`,children:G.name}),(0,_.jsxs)(`div`,{className:`att-confirm-text`,children:[`只解除关联:从这份`,e===`task`?`任务`:`文档`,`的附件清单里移除,资源仍留在孤儿池,可被重新挂载。 连资源一起删:在本机没有其它任务/文档引用它时,删除资源行(本机文件同时删字节);仍被引用时只解除关联。`]})]})}):null,X?(0,_.jsx)(`div`,{className:`att-lightbox`,role:`dialog`,"aria-label":`图片预览`,onMouseDown:e=>{e.target===e.currentTarget&&Z(null)},children:(0,_.jsxs)(`div`,{className:`att-lightbox-card`,children:[(0,_.jsxs)(`div`,{className:`att-lightbox-head`,children:[(0,_.jsx)(`span`,{className:`att-lightbox-name`,children:X.name}),(0,_.jsx)(`a`,{className:`att-lightbox-open`,href:X.src,target:`_blank`,rel:`noreferrer`,children:`新窗口打开`}),(0,_.jsx)(`button`,{type:`button`,className:`pp-x`,"aria-label":`关闭`,onClick:()=>Z(null),children:`×`})]}),(0,_.jsx)(`img`,{className:`att-lightbox-img`,src:X.src,alt:X.name})]})}):null]})}function b(e,{onRemove:t,onPreview:n,onOpenTask:r,onOpenDoc:i,onEditNote:a,onReplace:o}){let s=e.kind===`image`?d(e.id):``;return(0,_.jsxs)(`div`,{className:`att-item att-kind-${e.kind}`,children:[e.kind===`image`?(0,_.jsx)(`button`,{type:`button`,className:`att-thumb`,onClick:()=>n({src:s,name:e.name}),title:`点击看大图`,children:(0,_.jsx)(`img`,{src:s,alt:e.name,loading:`lazy`})}):(0,_.jsx)(`span`,{className:`att-kind-badge`,children:c(e.kind)}),(0,_.jsxs)(`span`,{className:`att-item-main`,children:[e.kind===`task`?(0,_.jsx)(`button`,{type:`button`,className:`att-link`,title:`跳转到任务 #${e.targetSeq??``}`,onClick:()=>r?.({key:e.targetKey,seq:e.targetSeq}),children:e.name}):e.kind===`ref`?(0,_.jsx)(`button`,{type:`button`,className:`att-link`,title:e.locator||e.targetRef||`打开文档`,onClick:()=>i?.(e.locator||e.targetRef),children:e.name}):e.kind===`url`?(0,_.jsx)(`a`,{className:`att-link`,href:e.url,target:`_blank`,rel:`noreferrer`,title:e.url,children:e.name}):(0,_.jsx)(`span`,{className:`att-item-name`,title:e.name,children:e.name}),(0,_.jsxs)(`span`,{className:`att-item-meta`,children:[e.sizeText?(0,_.jsx)(`span`,{children:e.sizeText}):null,e.note?(0,_.jsx)(`span`,{className:`att-note`,children:e.note}):null]})]}),e.kind===`file`||e.kind===`image`?(0,_.jsxs)(`span`,{className:`att-item-acts`,children:[(0,_.jsx)(`a`,{className:`att-act`,href:d(e.id),target:`_blank`,rel:`noreferrer`,children:`打开`}),(0,_.jsx)(`a`,{className:`att-act`,href:d(e.id),download:e.name,children:`下载`})]}):null,e.kind===`ref`?(0,_.jsxs)(`span`,{className:`att-item-acts`,children:[(0,_.jsx)(`button`,{type:`button`,className:`att-act`,title:`改这条绑定的一行说明(交付清单会透出)`,onClick:()=>a?.(e),children:`✎ 说明`}),(0,_.jsx)(`button`,{type:`button`,className:`att-act`,title:`换成另一篇文档(替换这条绑定)`,onClick:()=>o?.(e),children:`⇄ 更换`})]}):null,(0,_.jsx)(`button`,{type:`button`,className:`att-x`,"aria-label":`移除 ${e.name}`,onClick:()=>t(e),children:`×`})]},e.id)}var x=s(),S=[{id:`new`,label:`+ 新建页`,section:`primary`,noHide:!0},{id:`import`,label:`导入`,section:`bar`},{id:`progress`,label:`进程`,section:`bar`},{id:`orch`,label:`编排`,section:`bar`},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`deleted`,label:`已删除任务`,section:`more`},{id:`refs`,label:`查看列表`,section:`more`}],C=[{id:`new`,label:`+ 新增任务`,section:`primary`,noHide:!0},{id:`progress`,label:`进程`,section:`bar`},{id:`addMember`,label:`添加成员`,section:`bar`},{id:`orch`,label:`编排`,section:`bar`},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`deleted`,label:`已删除任务`,section:`more`},{id:`refs`,label:`查看列表`,section:`more`}],w=[{id:`new`,label:`新任务`,section:`primary`,noHide:!0},{id:`submit`,label:`提交`,section:`primary`,noHide:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`mode`,label:`源码模式`,section:`more`,menuGroup:`edit`},{id:`img`,label:`插入图片`,section:`more`,menuGroup:`edit`},{id:`att`,label:`添加附件`,section:`more`,menuGroup:`edit`},{id:`import`,label:`导入`,section:`more`,menuGroup:`edit`},{id:`draft`,label:`存草稿`,section:`more`,menuGroup:`edit`},{id:`chain`,label:`任务链`,section:`more`,menuGroup:`task`},{id:`clone`,label:`克隆任务`,section:`more`,menuGroup:`task`},{id:`fork`,label:`Fork 任务`,section:`more`,menuGroup:`task`},{id:`complete`,label:`标为完成`,section:`more`,menuGroup:`task`},{id:`cancel-task`,label:`取消任务`,section:`more`,menuGroup:`task`,danger:!0},{id:`mark`,label:`评论`,section:`more`,menuGroup:`task`},{id:`delete`,label:`删除`,section:`more`,menuGroup:`task`,danger:!0},{id:`preview`,label:`预览提示词`,section:`more`,menuGroup:`view`},{id:`overview`,label:`总览`,section:`more`,menuGroup:`view`},{id:`prog`,label:`进程`,section:`more`,menuGroup:`view`},{id:`source`,label:`原文`,section:`more`,menuGroup:`view`},{id:`shortcuts`,label:`快捷键`,section:`more`,menuGroup:`view`}],T=[{id:`save`,label:`保存`,section:`primary`,noHide:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`mode`,label:`源码模式`,section:`more`,menuGroup:`edit`},{id:`rename`,label:`重命名`,section:`more`,menuGroup:`doc`},{id:`delete`,label:`删除`,section:`more`,menuGroup:`doc`,danger:!0},{id:`list`,label:`文字列表`,section:`more`,menuGroup:`view`}],E=[{id:`add`,label:`登记仓库`,section:`primary`,noHide:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`boards`,label:`分组管理`,section:`more`,menuGroup:`manage`},{id:`refs`,label:`参考仓库管理`,section:`more`,menuGroup:`manage`},{id:`transfer`,label:`导入导出`,section:`more`,menuGroup:`manage`}],D=[{id:`edit`,label:`编辑`,section:`bar`},{id:`open`,label:`打开`,section:`bar`},{id:`del`,label:`删除`,section:`bar`,danger:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`getloop`,label:`持续 get…`,section:`more`,menuGroup:`repo`},{id:`remote`,label:`对齐 remote`,section:`more`,menuGroup:`repo`}],O={dir:Object.fromEntries(S.map(e=>[e.id,e])),group:Object.fromEntries(C.map(e=>[e.id,e])),task:Object.fromEntries(w.map(e=>[e.id,e])),doc:Object.fromEntries(T.map(e=>[e.id,e])),repos:Object.fromEntries(E.map(e=>[e.id,e])),"repos-row":Object.fromEntries(D.map(e=>[e.id,e]))};function k(e){return e===`group`?C:e===`task`?w:e===`doc`?T:e===`repos`?E:e===`repos-row`?D:S}function A(e,t){return O[e]&&O[e][t]||{}}function j(e,t){let n=A(e,t);return String(n.section||``).startsWith(`more`)||!!n.defaultInMore}function M(e,t){return A(e,t.id).noHide?!0:t.visible===void 0?!j(e,t.id):t.visible!==!1}function N(e,t){return t.id===`more`||A(e,t.id).noHide?!1:!M(e,t)}function P(e,t){let n=k(e),r=new Set(n.map(e=>e.id)),i=new Set,a=[];for(let n of t||[]){if(!n||!n.id||!r.has(n.id)||i.has(n.id))continue;i.add(n.id);let t=A(e,n.id);a.push(t.noHide?{...n,visible:!0}:n)}for(let t of n)i.has(t.id)||a.push({id:t.id,visible:t.noHide?!0:!j(e,t.id)});let o=a.findIndex(e=>e.id===`more`);if(o>=0&&o<a.length-1){let[t]=a.splice(o,1),n=a.length;for(let t=0;t<a.length;t++)if(j(e,a[t].id)&&!M(e,a[t])){n=t;break}a.splice(n,0,t)}return a}function F(e){return P(e,k(e).map(t=>({id:t.id,visible:t.noHide?!0:!j(e,t.id)})))}var I=e=>`nx-kv-tb-${e}`;function L(e){let[t,n]=(0,g.useState)(()=>{try{let t=JSON.parse(localStorage.getItem(I(e)));if(Array.isArray(t))return P(e,t)}catch{}return F(e)});return(0,g.useEffect)(()=>{try{localStorage.setItem(I(e),JSON.stringify(t))}catch{}},[t,e]),{layout:t,setLayout:n,resetLayout:()=>n(F(e))}}function R(e,t){return!!A(e,t).lockLast}function z(e,t,n){return e.map(e=>e.id===t?{...e,...n}:e)}function B(e,t,{id:n,anchorId:r=null,after:i=!1,visible:a}){let o=t.findIndex(e=>e.id===n);if(o<0||R(e,n))return t;let s={...t[o]};a!==void 0&&(s.visible=A(e,n).noHide?!0:!!a);let c=t.filter((e,t)=>t!==o),l;if(r===n)l=o;else if(r){let e=c.findIndex(e=>e.id===r);l=e<0?c.length:e+ +!!i}else{let e=c.findIndex(e=>e.id===`more`);l=e>=0?e:c.length}let u=c.findIndex(t=>R(e,t.id));u>=0&&l>u&&(l=u);let d=c.slice();return d.splice(l,0,s),d}function V(e,t,n,r){let i=t.filter(t=>M(e,t)&&!R(e,t.id)),a=i.findIndex(e=>e.id===n);if(a<0)return t;let o=a+r;if(o<0||o>=i.length)return t;let s=i[o];return B(e,t,{id:n,anchorId:s.id,after:r>0})}function H({kind:e,layout:t,setLayout:n,onClose:r}){let[i,a]=(0,g.useState)(()=>t.map(e=>({...e}))),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),u=(0,g.useRef)(null),d=i.filter(t=>M(e,t)),f=i.filter(t=>N(e,t)),p=d.filter(t=>!R(e,t.id)),m=()=>{let t=u.current;return t&&!R(e,t.id)?t:null},h=(t,n)=>{R(e,n.id)||(u.current={id:n.id,onBar:M(e,n)},l(n.id),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,n.id)))},v=()=>{u.current=null,l(null),s(null)},y=(t,n)=>{a(r=>B(e,r,{...n,id:t.id,visible:t.onBar===!1||n.visible}))},b=e=>{let t=e.clientY;for(let n of e.currentTarget.querySelectorAll(`[data-row-id]`)){let e=n.getBoundingClientRect();if(t<e.top)return{anchorId:n.dataset.rowId,after:!1};if(t<=e.bottom)return{anchorId:n.dataset.rowId,after:t>e.top+e.height/2}}return{anchorId:null,after:!1}},x=e=>{let t=m();if(!t)return;e.preventDefault();let n=b(e);s(n.anchorId?n.anchorId===t.id?null:`row:${n.anchorId}:${n.after?`after`:`before`}`:`zone:bar:end`)},S=e=>{e.preventDefault();let t=b(e),n=m();v(),n&&y(n,{anchorId:t.anchorId,after:t.after,visible:!0})},C=e=>{e.currentTarget.contains(e.relatedTarget)||s(e=>e&&e.startsWith(`zone:`)?null:e)},w=t=>{let n=m();n&&!A(e,n.id).noHide&&(t.preventDefault(),s(`menu`))},T=t=>{t.preventDefault();let n=m();v(),n&&!A(e,n.id).noHide&&a(e=>z(e,n.id,{visible:!1}))},E=e=>{e.currentTarget.contains(e.relatedTarget)||s(e=>e===`menu`?null:e)},D=e=>{let t=e.currentTarget.getBoundingClientRect();return(e.clientX-t.left)/(t.width||1)>.5},O=(e,t)=>{let n=m();n&&n.id!==e.id&&(t.preventDefault(),s(`chip:${e.id}:${D(t)?`after`:`before`}`))},k=(e,t)=>{let n=D(t);t.preventDefault();let r=m();v(),r&&y(r,{anchorId:e.id,after:n,visible:!0})},j=t=>{A(e,t).noHide||a(n=>{let r=n.find(e=>e.id===t);return z(n,t,{visible:!(r&&M(e,r))})})},P=(t,n)=>a(r=>V(e,r,t.id,n)),I=(e,t)=>{t.altKey&&(t.key===`ArrowUp`?(t.preventDefault(),P(e,-1)):t.key===`ArrowDown`&&(t.preventDefault(),P(e,1)))},L=()=>{n(i),r()},H=()=>a(F(e)),U=(t,n)=>{let r=o===`row:${t.id}:before`?` drop-before`:o===`row:${t.id}:after`?` drop-after`:``;return[`tlp-row`,n?``:`off`,R(e,t.id)?`lock`:``,c===t.id?`dragging`:``,r].filter(Boolean).join(` `)};return(0,_.jsxs)(`div`,{className:`tlp-panel`,role:`dialog`,"aria-label":`自定义工具栏`,children:[(0,_.jsxs)(`div`,{className:`tlp-head`,children:[(0,_.jsx)(`b`,{children:`自定义工具栏`}),(0,_.jsx)(`span`,{className:`tlp-head-sub`,children:`拖拽排序;关显隐 → 收入「更多」`})]}),(0,_.jsxs)(`div`,{className:`tlp-body`,children:[(0,_.jsxs)(`div`,{className:`tlp-section tlp-span`,children:[(0,_.jsx)(`div`,{className:`tlp-section-label`,children:`预览(可直接拖动这里的按钮排序)`}),(0,_.jsx)(`div`,{className:`tlp-preview`,role:`list`,"data-testid":`tlp-preview`,children:d.map(t=>{let n=o===`chip:${t.id}:before`?` drop-before`:o===`chip:${t.id}:after`?` drop-after`:``;return(0,_.jsx)(`span`,{className:[`tlp-chip`,A(e,t.id).section===`primary`?`primary`:``,c===t.id?`dragging`:``,n].filter(Boolean).join(` `),draggable:!R(e,t.id),role:`listitem`,onDragStart:e=>h(e,t),onDragEnd:v,onDragOver:e=>O(t,e),onDrop:e=>k(t,e),children:A(e,t.id).label||t.id},t.id)})})]}),(0,_.jsxs)(`div`,{className:`tlp-section`,children:[(0,_.jsx)(`div`,{className:`tlp-section-label`,children:`工具栏 · 拖进来即排序(行上/下半 = 前/后)`}),(0,_.jsxs)(`div`,{className:`tlp-list`+(o===`zone:bar:end`?` drop-on`:``),role:`list`,onDragOver:x,onDragLeave:C,onDrop:S,children:[p.length===0&&d.every(t=>R(e,t.id))?(0,_.jsx)(`div`,{className:`tlp-empty`,children:`空 —— 把「更多」里的项拖到这里`}):null,d.map(t=>{let n=A(e,t.id),r=p.findIndex(e=>e.id===t.id);return(0,_.jsxs)(`div`,{className:U(t,!0),draggable:!R(e,t.id),"data-row-id":t.id,tabIndex:R(e,t.id)?void 0:0,role:`listitem`,"aria-label":`${n.label||t.id}:拖动排序,Alt+上下换位`,onKeyDown:e=>I(t,e),onDragStart:e=>h(e,t),onDragEnd:v,children:[(0,_.jsx)(`span`,{className:`tlp-hnd`,title:R(e,t.id)?`锁定`:`拖动排序`,children:R(e,t.id)?`·`:`⋮⋮`}),(0,_.jsx)(`input`,{type:`checkbox`,checked:!0,disabled:!!n.noHide,onChange:()=>j(t.id),title:n.noHide?`不可隐藏`:`收入「更多」`}),(0,_.jsxs)(`span`,{className:`tlp-nm`,children:[n.label||t.id,n.noHide?(0,_.jsx)(`span`,{className:`tlp-sub`,children:`固定显示`}):null]}),R(e,t.id)?null:(0,_.jsxs)(`span`,{className:`tlp-acts`,children:[(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:r<=0,title:`上移`,onClick:()=>P(t,-1),children:`↑`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:r<0||r>=p.length-1,title:`下移`,onClick:()=>P(t,1),children:`↓`})]})]},t.id)})]})]}),(0,_.jsxs)(`div`,{className:`tlp-section`,children:[(0,_.jsx)(`div`,{className:`tlp-section-label`,children:`更多菜单(拖到上方 = 显示到工具栏;拖回这里 = 收入更多)`}),(0,_.jsxs)(`div`,{className:`tlp-list tlp-menu`+(o===`menu`?` dropping`:``),role:`list`,onDragOver:w,onDragLeave:E,onDrop:T,children:[f.map(t=>{let n=A(e,t.id);return(0,_.jsxs)(`div`,{className:U(t,!1),draggable:!0,role:`listitem`,onDragStart:e=>h(e,t),onDragEnd:v,children:[(0,_.jsx)(`span`,{className:`tlp-hnd`,title:`拖到上方工具栏 = 显示`,children:`⋮⋮`}),(0,_.jsx)(`input`,{type:`checkbox`,checked:!1,onChange:()=>j(t.id),title:`显示到工具栏`}),(0,_.jsx)(`span`,{className:`tlp-nm`,children:n.label||t.id})]},t.id)}),(0,_.jsx)(`div`,{className:`tlp-drop-hint`,role:`presentation`,children:o===`menu`?`松手 = 收入「更多」`:f.length?`把项拖到上方工具栏区域 = 显示到工具栏`:`工具栏上的按钮拖到这里即可收入「更多」`})]})]})]}),(0,_.jsxs)(`div`,{className:`tlp-foot`,children:[(0,_.jsx)(`span`,{className:`tlp-equiv`,children:`保存到本机 localStorage(每种工具区各存一份)`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:H,children:`恢复默认`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:r,children:`取消`}),(0,_.jsx)(`button`,{type:`button`,className:`btn sm primary`,onClick:L,children:`保存`})]})]})}var U=`task`,W=[{id:`edit`,label:`编辑`},{id:`task`,label:`任务`},{id:`view`,label:`查看`}];function G(){let[e,t]=(0,g.useState)(!1),[n,r]=(0,g.useState)({x:0,y:0}),i=(0,g.useRef)(null),a=(0,g.useRef)(null);return(0,g.useEffect)(()=>{if(!e)return;let n=e=>{i.current?.contains(e.target)||a.current?.contains(e.target)||t(!1)};return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),{open:e,setOpen:t,pos:n,setPos:r,ref:i,menuRef:a}}function K({menu:e,className:t=``,style:n,children:r}){return e.open?(0,x.createPortal)((0,_.jsx)(`div`,{className:`mdw-fmt-menu${t?` ${t}`:``}`,role:`menu`,ref:e.menuRef,style:{position:`fixed`,...e.pos,...n},children:r}),document.body):null}function q(e,t,n=`left`){let r=t.currentTarget.getBoundingClientRect(),i=r.bottom+4;e.setPos(n===`left`?{left:r.left,top:i}:{left:`auto`,right:Math.max(8,window.innerWidth-r.right),top:i}),e.setOpen(e=>!e)}function J({mode:e,onMode:t,showMark:n,submitLabel:r,onNew:i,onSubmit:a,onChain:o,onPreview:s,onImg:c,onAtt:l,onImport:u,onClone:d,onFork:f,onComplete:p,onCancelTask:m,onMark:h,onDraft:v,onDelete:y,onOverview:b,onProg:S,onSource:C,onShortcuts:w,goalBadge:T,goalMenu:E}){let D=G(),{layout:O,setLayout:k}=L(U),[j,P]=(0,g.useState)(!1);(0,g.useEffect)(()=>{D.setOpen(!1)},[e]);let F={new:i&&{label:`新任务`,run:i},submit:{label:r||`提交`,run:a,primary:!0},mode:t&&{label:e===`edit`?`返回实时预览`:`源码模式`,hint:e===`edit`?`当前`:``,run:()=>t(e===`edit`?`split`:`edit`)},img:c&&{label:`插入图片`,run:c},att:l&&{label:`添加附件`,run:l},import:u&&e!==`split`&&{label:`导入`,run:u},draft:v&&e!==`split`&&{label:`存草稿`,run:v},chain:o&&{label:`任务链`,run:o},clone:d&&{label:`克隆任务`,run:d},fork:f&&{label:`Fork 任务`,run:f},complete:p&&{label:`标为完成`,run:p},"cancel-task":m&&{label:`取消任务`,run:m,danger:!0},mark:n&&h&&{label:`评论`,run:h},delete:y&&{label:`删除`,run:y,danger:!0},preview:s&&{label:`预览提示词`,run:s},overview:b&&{label:`总览`,run:b},prog:S&&{label:`进程`,run:S},source:C&&{label:`原文`,run:C},shortcuts:w&&{label:`快捷键`,run:w}},I=e=>e===`more`||!!F[e],R=O.filter(e=>M(U,e)&&I(e.id)),z=O.filter(e=>N(U,e)&&I(e.id)),B=e=>{F[e]?.run?.(),D.setOpen(!1)},V=e=>{if(e===`more`)return(0,_.jsx)(`div`,{className:`mdw-actions-more`,ref:D.ref,children:(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm${D.open?` on`:``}`,title:`更多操作`,"aria-expanded":D.open,"aria-haspopup":`menu`,onClick:e=>q(D,e,`right`),children:`更多`})},`more`);let t=F[e];return t?(0,_.jsx)(`button`,{type:`button`,className:t.primary?`btn sm primary`:`btn ghost sm`,onClick:()=>B(e),children:t.label},e):null},J=W.map(e=>({...e,items:z.filter(t=>A(U,t.id).menuGroup===e.id)})).filter(e=>e.items.length),Y=z.filter(e=>!A(U,e.id).menuGroup);return(0,_.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,_.jsx)(`div`,{className:`mdw-toolbar-left`,children:T&&(0,_.jsx)(`button`,{type:`button`,className:`mdw-goal-badge`,title:T.title,"aria-haspopup":`menu`,"aria-expanded":D.open,onClick:e=>q(D,e,`right`),children:T.label})}),(0,_.jsxs)(`div`,{className:`mdw-actions`,role:`group`,"aria-label":`任务操作`,children:[R.map(e=>V(e.id)),(0,_.jsxs)(K,{menu:D,className:`mdw-act-menu`,children:[E,E&&(0,_.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),J.map(e=>(0,_.jsxs)(`div`,{className:`mdw-fmt-menu-group`,role:`group`,"aria-label":e.label,children:[(0,_.jsx)(`div`,{className:`mdw-fmt-menu-cap`,children:e.label}),e.items.map(e=>{let t=F[e.id],n=t?.danger||A(U,e.id).danger;return(0,_.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(n?` danger`:``),onClick:()=>B(e.id),children:[t?.label||A(U,e.id).label||e.id,t?.hint?(0,_.jsx)(`span`,{className:`hint`,children:t.hint}):null]},e.id)})]},e.id)),Y.map(e=>{let t=F[e.id];return(0,_.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(t?.danger||A(U,e.id).danger?` danger`:``),onClick:()=>B(e.id),children:t?.label||A(U,e.id).label||e.id},e.id)}),(0,_.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),(0,_.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{D.setOpen(!1),P(!0)},children:`自定义工具栏…`})]})]}),j&&(0,x.createPortal)((0,_.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>P(!1),children:(0,_.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,_.jsx)(H,{kind:U,layout:O,setLayout:k,onClose:()=>P(!1)})})}),document.body)]})}export{H as a,A as c,G as i,M as l,J as n,L as o,q as r,N as s,K as t,y as u};
1
+ import{g as e,h as t,l as n,m as r,o as i,p as a,y as o}from"./task-status-BnymQMTw.js";import{w as s}from"./workspace-C_5X2gIr.js";import{c,d as l,f as u,l as d,o as f,s as p}from"./md-history-DI1Ukbvc.js";import{n as m,o as h}from"./upload-BIMbGcCB.js";var g=o(e(),1),_=t(),v={position:(e,t)=>(e.position||0)-(t.position||0)||String(e.id).localeCompare(String(t.id)),name:(e,t)=>String(e.name||``).localeCompare(String(t.name||``)),kind:(e,t)=>String(e.kind).localeCompare(String(t.kind))||String(e.name||``).localeCompare(String(t.name||``))};function y({host:e=`task`,hostId:t,hostKey:o,hostCwd:s,refId:c,allow:d={file:!0,url:!0,task:!1,ref:!1},taskOptions:y=[],docOptions:x,disabled:S=!1,disabledText:C=`提交任务后可以在这里挂附件(当前是草稿)。`,openRef:w,onChanged:T,onOpenTask:E,onOpenDoc:D}){let O=a(),{dialog:k,node:A}=n(),[j,M]=(0,g.useState)([]),[N,P]=(0,g.useState)(!1),[F,I]=(0,g.useState)(``),[L,R]=(0,g.useState)(!1),[z,B]=(0,g.useState)(!1),[V,H]=(0,g.useState)(!1),[U,W]=(0,g.useState)(`position`),[G,K]=(0,g.useState)(null),[q,J]=(0,g.useState)(null),[Y,ee]=(0,g.useState)(!1),[X,Z]=(0,g.useState)(null),Q=(0,g.useMemo)(()=>l(e,{hostId:t,hostKey:o,hostCwd:s,refId:c}),[e,t,o,s,c]),$=(0,g.useCallback)(async()=>{if(S){M([]);return}P(!0),I(``);try{let e=await Q.list();M((e.attachments||[]).map(u))}catch(e){I(String(e&&e.message||e))}finally{P(!1)}},[Q,S]);(0,g.useEffect)(()=>{$()},[$]),(0,g.useImperativeHandle)(w,()=>({open:()=>R(!0),refresh:$}),[$]),(0,g.useEffect)(()=>{if(!X)return;let e=e=>{e.key===`Escape`&&Z(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[X]);let te=(0,g.useMemo)(()=>[...j].sort(v[U]||v.position),[j,U]),ne=te.filter(e=>e.area===`inline`),re=te.filter(e=>e.area===`area`),ie=async(e,t)=>{if(S)return;let n=m(t),r=n.length?n:[...e||[]].filter(e=>e&&e.size>0);if(!r.length)return;H(!0);let i=0;for(let e of r)try{let t=await h(e,{local:!0}),n=t.fileId||t.id;if(!n)throw Error(`上传未返回 fileId`);await Q.attach({fileId:n,name:t.name}),i+=1}catch(t){O(`「${e.name||`文件`}」添加失败:${t&&t.message||t}`)}H(!1),i&&(O(`已挂到附件区 ${i} 个文件`),await $(),T?.())},ae=async n=>{if(n)try{let i=await k({title:`说明 · ${n.name}`,input:!0,placeholder:`这一行里大概是什么(交付清单会透出给 agent)`,value:n.note||``,okText:`保存说明`});if(i===null)return;let a=typeof i==`string`?i:i&&(i.value||i.note)||``,l=e===`doc`?`/api/docs/attach-note?ref=${encodeURIComponent(String(c||``))}`:`/api/localtasks/attach-note`,u=e===`doc`?{attachment:n.id,note:a}:{id:Number(t),...o?{key:o}:s?{cwd:s}:{},attachment:n.id,note:a};await r(l,{method:`PATCH`,body:u}),O(a?`已保存说明:${a}`:`已清空说明`),await $(),T?.()}catch(e){O(`改说明失败:${e&&e.message||e}`)}},oe=e=>{e&&(J(e),R(!0))},se=async e=>{let t=G;if(t){ee(!0);try{await Q.detach(t.id,!!e),K(null),O(e?`已移除并删除资源:${t.name}`:`已解除关联:${t.name}`),await $(),T?.()}catch(e){O(`移除失败:${e&&e.message||e}`)}finally{ee(!1)}}},ce=!N&&!F&&!j.length;return(0,_.jsxs)(`div`,{className:`att-area${S?` is-disabled`:``}`,onDragOver:e=>{!S&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),B(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||B(!1)},onDrop:e=>{B(!1),!S&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),ie(null,e))},children:[A,(0,_.jsxs)(`div`,{className:`att-area-head`+(z&&!S?` is-over`:``),children:[(0,_.jsxs)(`span`,{className:`att-area-title`,children:[`附件`,j.length?(0,_.jsx)(`span`,{className:`att-count`,children:j.length}):null,V?(0,_.jsx)(`span`,{className:`att-area-note`,children:`上传中…`}):null]}),(0,_.jsxs)(`span`,{className:`att-area-acts`,children:[j.length?(0,_.jsxs)(`select`,{className:`att-sort`,value:U,onChange:e=>W(e.target.value),"aria-label":`附件排序`,children:[(0,_.jsx)(`option`,{value:`position`,children:`按添加顺序`}),(0,_.jsx)(`option`,{value:`name`,children:`按名称`}),(0,_.jsx)(`option`,{value:`kind`,children:`按类型`})]}):null,(0,_.jsx)(`button`,{type:`button`,className:`btn ghost att-add-btn`,disabled:S,onClick:()=>R(!0),children:`添加附件`})]})]}),S?(0,_.jsx)(`div`,{className:`att-empty`,children:C}):null,N?(0,_.jsx)(`div`,{className:`att-empty`,children:`加载附件…`}):null,F?(0,_.jsxs)(`div`,{className:`att-empty att-err-text`,children:[`附件加载失败:`,F]}):null,ce?(0,_.jsx)(`div`,{className:`att-empty`,children:`还没有附件。拖文件到这里,或点「添加附件」——只挂附件区,不写正文。`}):null,ne.length?(0,_.jsxs)(`div`,{className:`att-section`,children:[(0,_.jsxs)(`div`,{className:`att-section-head`,children:[p.inline,(0,_.jsx)(`span`,{className:`att-section-hint`,children:`正文里的引用,删正文行会跟着消失`})]}),ne.map(e=>b(e,{onRemove:K,onPreview:Z,onOpenTask:E,onOpenDoc:D,onEditNote:ae,onReplace:oe,key:e.id}))]}):null,re.length?(0,_.jsxs)(`div`,{className:`att-section`,children:[(0,_.jsxs)(`div`,{className:`att-section-head`,children:[p.area,(0,_.jsx)(`span`,{className:`att-section-hint`,children:`不依赖正文,删正文行也不会丢`})]}),re.map(e=>b(e,{onRemove:K,onPreview:Z,onOpenTask:E,onOpenDoc:D,onEditNote:ae,onReplace:oe,key:e.id}))]}):null,(0,_.jsx)(f,{open:L,host:e,hostId:t,hostKey:o,hostCwd:s,refId:c,allow:d,taskOptions:y,docOptions:x,replaceAttachment:q?q.id:null,replaceNote:q&&q.note||``,onClose:()=>{R(!1),J(null)},onDone:async()=>{J(null),await $(),T?.()}}),G?(0,_.jsx)(i,{title:`移除附件`,size:`sm`,busy:Y,onClose:Y?void 0:()=>K(null),footer:(0,_.jsxs)(`div`,{className:`att-foot`,children:[(0,_.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:Y,onClick:()=>K(null),children:`取消`}),(0,_.jsx)(`button`,{type:`button`,className:`btn`,disabled:Y,onClick:()=>se(!1),children:`只解除关联`}),(0,_.jsx)(`button`,{type:`button`,className:`btn danger`,disabled:Y,onClick:()=>se(!0),children:G.kind===`file`?`连文件一起删`:`连资源一起删`})]}),children:(0,_.jsxs)(`div`,{className:`att-confirm`,children:[(0,_.jsx)(`div`,{className:`att-confirm-name`,children:G.name}),(0,_.jsxs)(`div`,{className:`att-confirm-text`,children:[`只解除关联:从这份`,e===`task`?`任务`:`文档`,`的附件清单里移除,资源仍留在孤儿池,可被重新挂载。 连资源一起删:在本机没有其它任务/文档引用它时,删除资源行(本机文件同时删字节);仍被引用时只解除关联。`]})]})}):null,X?(0,_.jsx)(`div`,{className:`att-lightbox`,role:`dialog`,"aria-label":`图片预览`,onMouseDown:e=>{e.target===e.currentTarget&&Z(null)},children:(0,_.jsxs)(`div`,{className:`att-lightbox-card`,children:[(0,_.jsxs)(`div`,{className:`att-lightbox-head`,children:[(0,_.jsx)(`span`,{className:`att-lightbox-name`,children:X.name}),(0,_.jsx)(`a`,{className:`att-lightbox-open`,href:X.src,target:`_blank`,rel:`noreferrer`,children:`新窗口打开`}),(0,_.jsx)(`button`,{type:`button`,className:`pp-x`,"aria-label":`关闭`,onClick:()=>Z(null),children:`×`})]}),(0,_.jsx)(`img`,{className:`att-lightbox-img`,src:X.src,alt:X.name})]})}):null]})}function b(e,{onRemove:t,onPreview:n,onOpenTask:r,onOpenDoc:i,onEditNote:a,onReplace:o}){let s=e.kind===`image`?d(e.id):``;return(0,_.jsxs)(`div`,{className:`att-item att-kind-${e.kind}`,children:[e.kind===`image`?(0,_.jsx)(`button`,{type:`button`,className:`att-thumb`,onClick:()=>n({src:s,name:e.name}),title:`点击看大图`,children:(0,_.jsx)(`img`,{src:s,alt:e.name,loading:`lazy`})}):(0,_.jsx)(`span`,{className:`att-kind-badge`,children:c(e.kind)}),(0,_.jsxs)(`span`,{className:`att-item-main`,children:[e.kind===`task`?(0,_.jsx)(`button`,{type:`button`,className:`att-link`,title:`跳转到任务 #${e.targetSeq??``}`,onClick:()=>r?.({key:e.targetKey,seq:e.targetSeq}),children:e.name}):e.kind===`ref`?(0,_.jsx)(`button`,{type:`button`,className:`att-link`,title:e.locator||e.targetRef||`打开文档`,onClick:()=>i?.(e.locator||e.targetRef),children:e.name}):e.kind===`url`?(0,_.jsx)(`a`,{className:`att-link`,href:e.url,target:`_blank`,rel:`noreferrer`,title:e.url,children:e.name}):(0,_.jsx)(`span`,{className:`att-item-name`,title:e.name,children:e.name}),(0,_.jsxs)(`span`,{className:`att-item-meta`,children:[e.sizeText?(0,_.jsx)(`span`,{children:e.sizeText}):null,e.note?(0,_.jsx)(`span`,{className:`att-note`,children:e.note}):null]})]}),e.kind===`file`||e.kind===`image`?(0,_.jsxs)(`span`,{className:`att-item-acts`,children:[(0,_.jsx)(`a`,{className:`att-act`,href:d(e.id),target:`_blank`,rel:`noreferrer`,children:`打开`}),(0,_.jsx)(`a`,{className:`att-act`,href:d(e.id),download:e.name,children:`下载`})]}):null,e.kind===`ref`?(0,_.jsxs)(`span`,{className:`att-item-acts`,children:[(0,_.jsx)(`button`,{type:`button`,className:`att-act`,title:`改这条绑定的一行说明(交付清单会透出)`,onClick:()=>a?.(e),children:`✎ 说明`}),(0,_.jsx)(`button`,{type:`button`,className:`att-act`,title:`换成另一篇文档(替换这条绑定)`,onClick:()=>o?.(e),children:`⇄ 更换`})]}):null,(0,_.jsx)(`button`,{type:`button`,className:`att-x`,"aria-label":`移除 ${e.name}`,onClick:()=>t(e),children:`×`})]},e.id)}var x=s(),S=[{id:`new`,label:`+ 新建页`,section:`primary`,noHide:!0},{id:`import`,label:`导入`,section:`bar`},{id:`progress`,label:`进程`,section:`bar`},{id:`orch`,label:`编排`,section:`bar`},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`deleted`,label:`已删除任务`,section:`more`},{id:`refs`,label:`查看列表`,section:`more`}],C=[{id:`new`,label:`+ 新增任务`,section:`primary`,noHide:!0},{id:`progress`,label:`进程`,section:`bar`},{id:`addMember`,label:`添加成员`,section:`bar`},{id:`orch`,label:`编排`,section:`bar`},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`deleted`,label:`已删除任务`,section:`more`},{id:`refs`,label:`查看列表`,section:`more`}],w=[{id:`new`,label:`新任务`,section:`primary`,noHide:!0},{id:`submit`,label:`提交`,section:`primary`,noHide:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`mode`,label:`源码模式`,section:`more`,menuGroup:`edit`},{id:`img`,label:`插入图片`,section:`more`,menuGroup:`edit`},{id:`att`,label:`添加附件`,section:`more`,menuGroup:`edit`},{id:`import`,label:`导入`,section:`more`,menuGroup:`edit`},{id:`draft`,label:`存草稿`,section:`more`,menuGroup:`edit`},{id:`chain`,label:`任务链`,section:`more`,menuGroup:`task`},{id:`clone`,label:`克隆任务`,section:`more`,menuGroup:`task`},{id:`fork`,label:`Fork 任务`,section:`more`,menuGroup:`task`},{id:`complete`,label:`标为完成`,section:`more`,menuGroup:`task`},{id:`cancel-task`,label:`取消任务`,section:`more`,menuGroup:`task`,danger:!0},{id:`mark`,label:`评论`,section:`more`,menuGroup:`task`},{id:`delete`,label:`删除`,section:`more`,menuGroup:`task`,danger:!0},{id:`preview`,label:`预览提示词`,section:`more`,menuGroup:`view`},{id:`overview`,label:`总览`,section:`more`,menuGroup:`view`},{id:`prog`,label:`进程`,section:`more`,menuGroup:`view`},{id:`source`,label:`原文`,section:`more`,menuGroup:`view`},{id:`shortcuts`,label:`快捷键`,section:`more`,menuGroup:`view`}],T=[{id:`save`,label:`保存`,section:`primary`,noHide:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`mode`,label:`源码模式`,section:`more`,menuGroup:`edit`},{id:`rename`,label:`重命名`,section:`more`,menuGroup:`doc`},{id:`delete`,label:`删除`,section:`more`,menuGroup:`doc`,danger:!0},{id:`list`,label:`文字列表`,section:`more`,menuGroup:`view`}],E=[{id:`add`,label:`登记仓库`,section:`primary`,noHide:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`boards`,label:`分组管理`,section:`more`,menuGroup:`manage`},{id:`refs`,label:`参考仓库管理`,section:`more`,menuGroup:`manage`},{id:`transfer`,label:`导入导出`,section:`more`,menuGroup:`manage`}],D=[{id:`edit`,label:`编辑`,section:`bar`},{id:`open`,label:`打开`,section:`bar`},{id:`del`,label:`删除`,section:`bar`,danger:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`getloop`,label:`持续 get…`,section:`more`,menuGroup:`repo`},{id:`remote`,label:`对齐 remote`,section:`more`,menuGroup:`repo`}],O={dir:Object.fromEntries(S.map(e=>[e.id,e])),group:Object.fromEntries(C.map(e=>[e.id,e])),task:Object.fromEntries(w.map(e=>[e.id,e])),doc:Object.fromEntries(T.map(e=>[e.id,e])),repos:Object.fromEntries(E.map(e=>[e.id,e])),"repos-row":Object.fromEntries(D.map(e=>[e.id,e]))};function k(e){return e===`group`?C:e===`task`?w:e===`doc`?T:e===`repos`?E:e===`repos-row`?D:S}function A(e,t){return O[e]&&O[e][t]||{}}function j(e,t){let n=A(e,t);return String(n.section||``).startsWith(`more`)||!!n.defaultInMore}function M(e,t){return A(e,t.id).noHide?!0:t.visible===void 0?!j(e,t.id):t.visible!==!1}function N(e,t){return t.id===`more`||A(e,t.id).noHide?!1:!M(e,t)}function P(e,t){let n=k(e),r=new Set(n.map(e=>e.id)),i=new Set,a=[];for(let n of t||[]){if(!n||!n.id||!r.has(n.id)||i.has(n.id))continue;i.add(n.id);let t=A(e,n.id);a.push(t.noHide?{...n,visible:!0}:n)}for(let t of n)i.has(t.id)||a.push({id:t.id,visible:t.noHide?!0:!j(e,t.id)});let o=a.findIndex(e=>e.id===`more`);if(o>=0&&o<a.length-1){let[t]=a.splice(o,1),n=a.length;for(let t=0;t<a.length;t++)if(j(e,a[t].id)&&!M(e,a[t])){n=t;break}a.splice(n,0,t)}return a}function F(e){return P(e,k(e).map(t=>({id:t.id,visible:t.noHide?!0:!j(e,t.id)})))}var I=e=>`nx-kv-tb-${e}`;function L(e){let[t,n]=(0,g.useState)(()=>{try{let t=JSON.parse(localStorage.getItem(I(e)));if(Array.isArray(t))return P(e,t)}catch{}return F(e)});return(0,g.useEffect)(()=>{try{localStorage.setItem(I(e),JSON.stringify(t))}catch{}},[t,e]),{layout:t,setLayout:n,resetLayout:()=>n(F(e))}}function R(e,t){return!!A(e,t).lockLast}function z(e,t,n){return e.map(e=>e.id===t?{...e,...n}:e)}function B(e,t,{id:n,anchorId:r=null,after:i=!1,visible:a}){let o=t.findIndex(e=>e.id===n);if(o<0||R(e,n))return t;let s={...t[o]};a!==void 0&&(s.visible=A(e,n).noHide?!0:!!a);let c=t.filter((e,t)=>t!==o),l;if(r===n)l=o;else if(r){let e=c.findIndex(e=>e.id===r);l=e<0?c.length:e+ +!!i}else{let e=c.findIndex(e=>e.id===`more`);l=e>=0?e:c.length}let u=c.findIndex(t=>R(e,t.id));u>=0&&l>u&&(l=u);let d=c.slice();return d.splice(l,0,s),d}function V(e,t,n,r){let i=t.filter(t=>M(e,t)&&!R(e,t.id)),a=i.findIndex(e=>e.id===n);if(a<0)return t;let o=a+r;if(o<0||o>=i.length)return t;let s=i[o];return B(e,t,{id:n,anchorId:s.id,after:r>0})}function H({kind:e,layout:t,setLayout:n,onClose:r}){let[i,a]=(0,g.useState)(()=>t.map(e=>({...e}))),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),u=(0,g.useRef)(null),d=i.filter(t=>M(e,t)),f=i.filter(t=>N(e,t)),p=d.filter(t=>!R(e,t.id)),m=()=>{let t=u.current;return t&&!R(e,t.id)?t:null},h=(t,n)=>{R(e,n.id)||(u.current={id:n.id,onBar:M(e,n)},l(n.id),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,n.id)))},v=()=>{u.current=null,l(null),s(null)},y=(t,n)=>{a(r=>B(e,r,{...n,id:t.id,visible:t.onBar===!1||n.visible}))},b=e=>{let t=e.clientY;for(let n of e.currentTarget.querySelectorAll(`[data-row-id]`)){let e=n.getBoundingClientRect();if(t<e.top)return{anchorId:n.dataset.rowId,after:!1};if(t<=e.bottom)return{anchorId:n.dataset.rowId,after:t>e.top+e.height/2}}return{anchorId:null,after:!1}},x=e=>{let t=m();if(!t)return;e.preventDefault();let n=b(e);s(n.anchorId?n.anchorId===t.id?null:`row:${n.anchorId}:${n.after?`after`:`before`}`:`zone:bar:end`)},S=e=>{e.preventDefault();let t=b(e),n=m();v(),n&&y(n,{anchorId:t.anchorId,after:t.after,visible:!0})},C=e=>{e.currentTarget.contains(e.relatedTarget)||s(e=>e&&e.startsWith(`zone:`)?null:e)},w=t=>{let n=m();n&&!A(e,n.id).noHide&&(t.preventDefault(),s(`menu`))},T=t=>{t.preventDefault();let n=m();v(),n&&!A(e,n.id).noHide&&a(e=>z(e,n.id,{visible:!1}))},E=e=>{e.currentTarget.contains(e.relatedTarget)||s(e=>e===`menu`?null:e)},D=e=>{let t=e.currentTarget.getBoundingClientRect();return(e.clientX-t.left)/(t.width||1)>.5},O=(e,t)=>{let n=m();n&&n.id!==e.id&&(t.preventDefault(),s(`chip:${e.id}:${D(t)?`after`:`before`}`))},k=(e,t)=>{let n=D(t);t.preventDefault();let r=m();v(),r&&y(r,{anchorId:e.id,after:n,visible:!0})},j=t=>{A(e,t).noHide||a(n=>{let r=n.find(e=>e.id===t);return z(n,t,{visible:!(r&&M(e,r))})})},P=(t,n)=>a(r=>V(e,r,t.id,n)),I=(e,t)=>{t.altKey&&(t.key===`ArrowUp`?(t.preventDefault(),P(e,-1)):t.key===`ArrowDown`&&(t.preventDefault(),P(e,1)))},L=()=>{n(i),r()},H=()=>a(F(e)),U=(t,n)=>{let r=o===`row:${t.id}:before`?` drop-before`:o===`row:${t.id}:after`?` drop-after`:``;return[`tlp-row`,n?``:`off`,R(e,t.id)?`lock`:``,c===t.id?`dragging`:``,r].filter(Boolean).join(` `)};return(0,_.jsxs)(`div`,{className:`tlp-panel`,role:`dialog`,"aria-label":`自定义工具栏`,children:[(0,_.jsxs)(`div`,{className:`tlp-head`,children:[(0,_.jsx)(`b`,{children:`自定义工具栏`}),(0,_.jsx)(`span`,{className:`tlp-head-sub`,children:`拖拽排序;关显隐 → 收入「更多」`})]}),(0,_.jsxs)(`div`,{className:`tlp-body`,children:[(0,_.jsxs)(`div`,{className:`tlp-section tlp-span`,children:[(0,_.jsx)(`div`,{className:`tlp-section-label`,children:`预览(可直接拖动这里的按钮排序)`}),(0,_.jsx)(`div`,{className:`tlp-preview`,role:`list`,"data-testid":`tlp-preview`,children:d.map(t=>{let n=o===`chip:${t.id}:before`?` drop-before`:o===`chip:${t.id}:after`?` drop-after`:``;return(0,_.jsx)(`span`,{className:[`tlp-chip`,A(e,t.id).section===`primary`?`primary`:``,c===t.id?`dragging`:``,n].filter(Boolean).join(` `),draggable:!R(e,t.id),role:`listitem`,onDragStart:e=>h(e,t),onDragEnd:v,onDragOver:e=>O(t,e),onDrop:e=>k(t,e),children:A(e,t.id).label||t.id},t.id)})})]}),(0,_.jsxs)(`div`,{className:`tlp-section`,children:[(0,_.jsx)(`div`,{className:`tlp-section-label`,children:`工具栏 · 拖进来即排序(行上/下半 = 前/后)`}),(0,_.jsxs)(`div`,{className:`tlp-list`+(o===`zone:bar:end`?` drop-on`:``),role:`list`,onDragOver:x,onDragLeave:C,onDrop:S,children:[p.length===0&&d.every(t=>R(e,t.id))?(0,_.jsx)(`div`,{className:`tlp-empty`,children:`空 —— 把「更多」里的项拖到这里`}):null,d.map(t=>{let n=A(e,t.id),r=p.findIndex(e=>e.id===t.id);return(0,_.jsxs)(`div`,{className:U(t,!0),draggable:!R(e,t.id),"data-row-id":t.id,tabIndex:R(e,t.id)?void 0:0,role:`listitem`,"aria-label":`${n.label||t.id}:拖动排序,Alt+上下换位`,onKeyDown:e=>I(t,e),onDragStart:e=>h(e,t),onDragEnd:v,children:[(0,_.jsx)(`span`,{className:`tlp-hnd`,title:R(e,t.id)?`锁定`:`拖动排序`,children:R(e,t.id)?`·`:`⋮⋮`}),(0,_.jsx)(`input`,{type:`checkbox`,checked:!0,disabled:!!n.noHide,onChange:()=>j(t.id),title:n.noHide?`不可隐藏`:`收入「更多」`}),(0,_.jsxs)(`span`,{className:`tlp-nm`,children:[n.label||t.id,n.noHide?(0,_.jsx)(`span`,{className:`tlp-sub`,children:`固定显示`}):null]}),R(e,t.id)?null:(0,_.jsxs)(`span`,{className:`tlp-acts`,children:[(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:r<=0,title:`上移`,onClick:()=>P(t,-1),children:`↑`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:r<0||r>=p.length-1,title:`下移`,onClick:()=>P(t,1),children:`↓`})]})]},t.id)})]})]}),(0,_.jsxs)(`div`,{className:`tlp-section`,children:[(0,_.jsx)(`div`,{className:`tlp-section-label`,children:`更多菜单(拖到上方 = 显示到工具栏;拖回这里 = 收入更多)`}),(0,_.jsxs)(`div`,{className:`tlp-list tlp-menu`+(o===`menu`?` dropping`:``),role:`list`,onDragOver:w,onDragLeave:E,onDrop:T,children:[f.map(t=>{let n=A(e,t.id);return(0,_.jsxs)(`div`,{className:U(t,!1),draggable:!0,role:`listitem`,onDragStart:e=>h(e,t),onDragEnd:v,children:[(0,_.jsx)(`span`,{className:`tlp-hnd`,title:`拖到上方工具栏 = 显示`,children:`⋮⋮`}),(0,_.jsx)(`input`,{type:`checkbox`,checked:!1,onChange:()=>j(t.id),title:`显示到工具栏`}),(0,_.jsx)(`span`,{className:`tlp-nm`,children:n.label||t.id})]},t.id)}),(0,_.jsx)(`div`,{className:`tlp-drop-hint`,role:`presentation`,children:o===`menu`?`松手 = 收入「更多」`:f.length?`把项拖到上方工具栏区域 = 显示到工具栏`:`工具栏上的按钮拖到这里即可收入「更多」`})]})]})]}),(0,_.jsxs)(`div`,{className:`tlp-foot`,children:[(0,_.jsx)(`span`,{className:`tlp-equiv`,children:`保存到本机 localStorage(每种工具区各存一份)`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:H,children:`恢复默认`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:r,children:`取消`}),(0,_.jsx)(`button`,{type:`button`,className:`btn sm primary`,onClick:L,children:`保存`})]})]})}var U=`task`,W=[{id:`edit`,label:`编辑`},{id:`task`,label:`任务`},{id:`view`,label:`查看`}];function G(){let[e,t]=(0,g.useState)(!1),[n,r]=(0,g.useState)({x:0,y:0}),i=(0,g.useRef)(null),a=(0,g.useRef)(null);return(0,g.useEffect)(()=>{if(!e)return;let n=e=>{i.current?.contains(e.target)||a.current?.contains(e.target)||t(!1)};return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),{open:e,setOpen:t,pos:n,setPos:r,ref:i,menuRef:a}}function K({menu:e,className:t=``,style:n,children:r}){return e.open?(0,x.createPortal)((0,_.jsx)(`div`,{className:`mdw-fmt-menu${t?` ${t}`:``}`,role:`menu`,ref:e.menuRef,style:{position:`fixed`,...e.pos,...n},children:r}),document.body):null}function q(e,t,n=`left`){let r=t.currentTarget.getBoundingClientRect(),i=r.bottom+4;e.setPos(n===`left`?{left:r.left,top:i}:{left:`auto`,right:Math.max(8,window.innerWidth-r.right),top:i}),e.setOpen(e=>!e)}function J({mode:e,onMode:t,showMark:n,submitLabel:r,onNew:i,onSubmit:a,onChain:o,onPreview:s,onImg:c,onAtt:l,onImport:u,onClone:d,onFork:f,onComplete:p,onCancelTask:m,onMark:h,onDraft:v,onDelete:y,onOverview:b,onProg:S,onSource:C,onShortcuts:w,goalBadge:T,goalMenu:E}){let D=G(),{layout:O,setLayout:k}=L(U),[j,P]=(0,g.useState)(!1);(0,g.useEffect)(()=>{D.setOpen(!1)},[e]);let F={new:i&&{label:`新任务`,run:i},submit:{label:r||`提交`,run:a,primary:!0},mode:t&&{label:e===`edit`?`返回实时预览`:`源码模式`,hint:e===`edit`?`当前`:``,run:()=>t(e===`edit`?`split`:`edit`)},img:c&&{label:`插入图片`,run:c},att:l&&{label:`添加附件`,run:l},import:u&&e!==`split`&&{label:`导入`,run:u},draft:v&&e!==`split`&&{label:`存草稿`,run:v},chain:o&&{label:`任务链`,run:o},clone:d&&{label:`克隆任务`,run:d},fork:f&&{label:`Fork 任务`,run:f},complete:p&&{label:`标为完成`,run:p},"cancel-task":m&&{label:`取消任务`,run:m,danger:!0},mark:n&&h&&{label:`评论`,run:h},delete:y&&{label:`删除`,run:y,danger:!0},preview:s&&{label:`预览提示词`,run:s},overview:b&&{label:`总览`,run:b},prog:S&&{label:`进程`,run:S},source:C&&{label:`原文`,run:C},shortcuts:w&&{label:`快捷键`,run:w}},I=e=>e===`more`||!!F[e],R=O.filter(e=>M(U,e)&&I(e.id)),z=O.filter(e=>N(U,e)&&I(e.id)),B=e=>{F[e]?.run?.(),D.setOpen(!1)},V=e=>{if(e===`more`)return(0,_.jsx)(`div`,{className:`mdw-actions-more`,ref:D.ref,children:(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm${D.open?` on`:``}`,title:`更多操作`,"aria-expanded":D.open,"aria-haspopup":`menu`,onClick:e=>q(D,e,`right`),children:`更多`})},`more`);let t=F[e];return t?(0,_.jsx)(`button`,{type:`button`,className:t.primary?`btn sm primary`:`btn ghost sm`,onClick:()=>B(e),children:t.label},e):null},J=W.map(e=>({...e,items:z.filter(t=>A(U,t.id).menuGroup===e.id)})).filter(e=>e.items.length),Y=z.filter(e=>!A(U,e.id).menuGroup);return(0,_.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,_.jsx)(`div`,{className:`mdw-toolbar-left`,children:T&&(0,_.jsx)(`button`,{type:`button`,className:`mdw-goal-badge`,title:T.title,"aria-haspopup":`menu`,"aria-expanded":D.open,onClick:e=>q(D,e,`right`),children:T.label})}),(0,_.jsxs)(`div`,{className:`mdw-actions`,role:`group`,"aria-label":`任务操作`,children:[R.map(e=>V(e.id)),(0,_.jsxs)(K,{menu:D,className:`mdw-act-menu`,children:[E,E&&(0,_.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),J.map(e=>(0,_.jsxs)(`div`,{className:`mdw-fmt-menu-group`,role:`group`,"aria-label":e.label,children:[(0,_.jsx)(`div`,{className:`mdw-fmt-menu-cap`,children:e.label}),e.items.map(e=>{let t=F[e.id],n=t?.danger||A(U,e.id).danger;return(0,_.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(n?` danger`:``),onClick:()=>B(e.id),children:[t?.label||A(U,e.id).label||e.id,t?.hint?(0,_.jsx)(`span`,{className:`hint`,children:t.hint}):null]},e.id)})]},e.id)),Y.map(e=>{let t=F[e.id];return(0,_.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(t?.danger||A(U,e.id).danger?` danger`:``),onClick:()=>B(e.id),children:t?.label||A(U,e.id).label||e.id},e.id)}),(0,_.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),(0,_.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{D.setOpen(!1),P(!0)},children:`自定义工具栏…`})]})]}),j&&(0,x.createPortal)((0,_.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>P(!1),children:(0,_.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,_.jsx)(H,{kind:U,layout:O,setLayout:k,onClose:()=>P(!1)})})}),document.body)]})}export{H as a,A as c,G as i,M as l,J as n,L as o,q as r,N as s,K as t,y as u};
@@ -12,7 +12,7 @@
12
12
  <!-- .ico 兜底:浏览器不认上面的 <link> 时会自己请求 /favicon.ico -->
13
13
  <link rel="icon" type="image/x-icon" href="/favicon.ico">
14
14
  <link rel="apple-touch-icon" sizes="512x512" href="/logo-rounded.png">
15
- <script type="module" crossorigin src="/assets/index-DNB8tgNi.js"></script>
15
+ <script type="module" crossorigin src="/assets/index-Dq7eNqAB.js"></script>
16
16
  <link rel="modulepreload" crossorigin href="/assets/task-status-BnymQMTw.js">
17
17
  <link rel="modulepreload" crossorigin href="/assets/workspace-C_5X2gIr.js">
18
18
  <link rel="modulepreload" crossorigin href="/assets/app-context-D7HAx67n.js">
@@ -1,6 +0,0 @@
1
- import{g as e,h as t,l as n,m as r,p as i,u as a,y as o}from"./task-status-BnymQMTw.js";import{n as s}from"./app-context-D7HAx67n.js";import{n as c,o as l}from"./index-DNB8tgNi.js";import{t as u}from"./button-Cmo-6aoW.js";var d=o(e(),1),f=Object.freeze([{id:`xml`,label:`XML 区块(默认)`,desc:`每段系统内容包进独立标签,agent 一眼分清任务原文与系统规则`},{id:`plain`,label:`正文直追加`,desc:`不包标签,按空行拼接(与改造前的 instruction 逐字一致)`}]),p=8e3,m=`builtin`,h=`系统内置`,g=`{{#if repo}},{{#if repo.intro}},〔项目介绍 · {{repo.name}}〕({{repo.introPath}}):,{{repo.intro}},{{/if}},{{#if repo.docs}},项目补充文档(可直接读取):,{{#each repo.docs}}, - {{path}}{{#if tag}} [{{tag}}]{{/if}}{{#if note}} # {{note}}{{/if}},{{/each}},{{/if}},{{/if}},{{#if group}},〔项目组上下文 · {{group.name}}〕,{{#if group.desc}},组定位:{{group.desc}},{{/if}},{{#if group.intro}},组介绍({{group.introPath}}):,{{group.intro}},{{/if}},{{#if group.note}},本项目在组里的位置:{{group.note}},{{/if}},{{#if group.peers}},组内成员:,{{#each group.peers}}, - {{name}}:{{#if note}}{{note}}{{else}}(无组内描述){{/if}}{{#if path}}({{path}}){{/if}},{{/each}},{{/if}},{{#if group.docs}},组绑定参考文件(可直接读取):,{{#each group.docs}}, - {{path}}{{#if tag}} [{{tag}}]{{/if}}{{#if note}} # {{note}}{{/if}},{{/each}},{{/if}},{{/if}},{{#if refRepos.count}},参考仓库(可直接读取,共 {{refRepos.count}} 个):,{{#each refRepos.list}}, - {{name}}{{#if path}}({{path}}){{/if}}{{#if note}} # {{note}}{{/if}},{{/each}},{{/if}}`.split(`,`).join(`
2
- `),_=[`{{#if attach}}`,`〔附件〕本任务包含 {{attach.count}} 个附件(正文内嵌 {{attach.inlineCount}} · 附件区 {{attach.areaCount}})。请先识别附件内容(图片先看图、文档先读内容)再开始处理,不要跳过附件。`,``,`附件清单:`,`{{#each attach.list}}`,` - [{{originLabel}}] {{kindLabel}} {{name}}{{#if sizeText}}({{sizeText}}){{/if}}:{{#if file}}{{#if file.exists}}{{file.localPath}}{{else}}未同步到本地(fileId {{file.fileId}}){{/if}}{{/if}}{{#if url}}{{url.href}}{{/if}}{{#if task}}{{#if task.resolved}}#{{task.seq}} {{task.title}} · 地址 {{task.address}}({{task.statusLabel}}){{else}}地址 {{task.address}}({{task.statusLabel}}){{/if}}{{/if}}{{#if ref}}{{ref.title}}{{#if ref.relPath}}({{ref.relPath}}){{/if}}{{/if}}{{#if note}} # {{note}}{{/if}}`,`{{/each}}`,``,`取用方式:`,`{{#each attach.list}}`,` - {{kindLabel}} 《{{name}}》:{{usage}}`,`{{/each}}`,`{{#if attach.syncSummary}}`,`同步情况:{{attach.syncSummary.text}}`,`{{/if}}`,`{{#each attach.list}}{{#if ref}}{{#if ref.content}}〔文档原文 · {{ref.title}}〕({{ref.relPath}}):`,``,`{{ref.content}}`,``,`{{/if}}{{/if}}{{/each}}`,`{{/if}}`].join(`
3
- `),v=[`{{#if goal.check}}`,`{{goal.check}}`,`{{/if}}`,`{{#if goal.statusLine}}`,`{{goal.statusLine}}`,`{{/if}}`].join(`
4
- `),y=[`{{#if ext.count}}`,`本队列({{ext.topic}})还有 {{ext.count}} 条待领取任务:`,`{{#each ext.list}}`,` - #{{id}} {{title}}`,`{{/each}}`,`先完成当前任务,再领取下一条;不要因为后面还有活就提前收尾或分心。`,`{{/if}}`].join(`
5
- `),b=`完成之后必须调用 nx-kv localtask done --id {{task.id}} --summary "<完成总结>" 汇报结果。`,x=[`{{#if getloop}}`,`{{getloop.text}}`,`{{/if}}`].join(`
6
- `),S=Object.freeze([{id:`context`,tag:`nx-kv.context`,label:`组 / 项目上下文`,desc:`任务所在组、项目关键路径与参考文件;直接用 repo / group 变量拼装`,defaultTemplate:g},{id:`attachment`,tag:`nx-kv.attachment`,label:`附件识别`,desc:`任务带附件时出现:数量 / 清单 / 本地路径`,defaultTemplate:_},{id:`timecheck`,tag:`nx-kv.timecheck`,label:`时间目标检查`,desc:`任务带时间目标时出现:check 指令或目录级状态`,defaultTemplate:v},{id:`ext`,tag:`nx-kv.ext`,label:`待领取队列(ext)`,desc:`同主题还有多少待领取任务与标题;队列空时不出现`,defaultTemplate:y},{id:`ack`,tag:`nx-kv.ack`,label:`ack 完成总结`,desc:`完成任务时调用 localtask done 回填的指令;默认已内置,可见可改`,defaultTemplate:b},{id:`getloop`,tag:`nx-kv.getloop`,label:`持续 get`,desc:`项目开启「持续 get」时出现:完成本任务并回填后继续领取下一条`,defaultTemplate:x}]);function C(e){let t=String(e??``).trim();return t.length>8e3?t.slice(0,p):t}function w(e){return{id:m,name:h,template:e.defaultTemplate,builtin:!0}}function T(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=String(e.id??``).trim().slice(0,64);return t?{id:t,name:String(e.name??``).trim().slice(0,60)||`未命名模板`,template:C(e.template),builtin:!1}:null}function E(e){let t=e&&typeof e==`object`&&!Array.isArray(e)?e:{},n={};for(let e of S){let r=t[e.id],i=Array.isArray(r)?r:Array.isArray(r?.list)?r.list:[],a=[w(e)],o=new Set([m]);for(let e of i){if(e&&typeof e==`object`&&(e.id===`builtin`||e.builtin))continue;let t=T(e);if(t&&!o.has(t.id)&&(o.add(t.id),a.push(t),a.length>=20))break}let s=String(r?.active??``).trim();n[e.id]={active:a.some(e=>e.id===s)?s:m,list:a}}return n}var D={context:[{label:`项目`,items:[[`repo.name`,`项目名`],[`repo.intro`,`项目介绍正文`],[`repo.introPath`,`介绍全文路径`],[`repo.docs`,`补充文档(可循环 path/tag/note)`],[`repo.docCount`,`补充文档数`],[`repo.refRepos`,`本仓库直接绑定的参考仓库(repos 中 type=ref,不是文档库 refs;可循环 name/path/note)`],[`repo.refRepoCount`,`本仓库直接绑定的参考仓库数`]]},{label:`组`,items:[[`group.name`,`组名`],[`group.desc`,`组定位`],[`group.intro`,`组介绍正文`],[`group.note`,`本项目在组里的位置`],[`group.peers`,`组内成员(可循环 name/note)`],[`group.docs`,`组绑定参考文件(可循环)`],[`group.refRepos`,`本组绑定的参考仓库(repos 中 type=ref,不是文档库 refs;可循环 name/path/note)`],[`group.refRepoCount`,`本组绑定的参考仓库数`],[`groups`,`其余组(可循环 name/desc/path)`]]},{label:`参考仓库`,items:[[`refRepos.list`,`直接绑定 ∪ 组级绑定的去重并集(repos 中 type=ref,不是文档库 refs;可循环 name/path/note)`],[`refRepos.count`,`去重并集的条目数(无绑定时为 0,整段不出现)`]]},{label:`通用`,items:[[`task.id`,`任务号`],[`task.text`,`任务原文`],[`params`,`外部参数(k=v)`]]}],attachment:[{label:`统计`,items:[[`attach.count`,`附件总数`],[`attach.inlineCount`,`正文内嵌数量`],[`attach.areaCount`,`附件区数量`],[`attach.hasInline`,`是否有正文内嵌`],[`attach.hasArea`,`是否有附件区条目`],[`attach.needsSyncCount`,`需要同步到本地的文件数`]]},{label:`附件条目(通用,attach.list 内循环)`,items:[[`kind`,`类型:file / url / task / ref`],[`kindLabel`,`类型显示名:附件/图片/链接/任务/文档`],[`name`,`展示名(任务型为实时标题,不是正文)`],[`size`,`字节数`],[`sizeText`,`可读大小(1.2 MB)`],[`mime`,`MIME 类型`],[`storage`,`存储来源:local / cloud / url / internal`],[`role`,`关系角色:inline / reference / doc / attach`],[`origin`,`来源:inline(正文内嵌)/ area(附件区)`],[`originLabel`,`来源显示名`],[`usage`,`取用说明(按类型生成,含确切命令)`],[`cmd`,`取用命令(file 未同步 / task / ref;url 为空)`],[`locator`,`简短定位串(路径 / 链接 / #seq 标题 / 文档路径)`],[`isImage`,`是否图片(kind=file 的子类型)`],[`needsSync`,`该条是否需要先同步到本地`]]},{label:`文件型(kind=file)· file 子对象`,items:[[`file.localPath`,`本地绝对路径(已同步时才有值)`],[`file.fileId`,`资源 id(未同步时用它拉取)`],[`file.exists`,`本机盘上是否已有副本`],[`file.syncCmd`,`未同步时的命令:nx-kv file sync --ids <fileId>`],[`localPath`,`file.localPath 的平铺别名(旧模板兼容)`],[`fileId`,`file.fileId 的平铺别名`]]},{label:`链接型(kind=url)· url 子对象`,items:[[`url.href`,`可访问的完整链接,可直接抓取`],[`url.host`,`链接域名(host)`],[`href`,`url.href 的平铺别名`],[`host`,`url.host 的平铺别名`],[`urlText`,`链接字符串别名`]]},{label:`任务型(kind=task)· task 子对象`,items:[[`task.taskId`,`本机 tasks.id(join 用;任务被清理后为 0)`],[`task.topicKey`,`任务所在 topic key`],[`task.topicName`,`任务所在 topic 名`],[`task.seq`,`topic 内编号(对外显示的任务号)`],[`task.title`,`实时标题(正文首行,不是正文)`],[`task.status`,`实时状态:pending/claimed/done/cancelled`],[`task.statusLabel`,`状态显示名`],[`task.address`,`地址 topicKey:seq`],[`task.storedAddress`,`附件行里存的旧地址(搬家前)`],[`task.addressDrift`,`地址是否已漂移(任务搬过 topic)`],[`task.resolved`,`正文当前是否可读`],[`task.purged`,`目标任务是否已被清理`],[`task.deleted`,`目标任务是否已软删`],[`task.showCmd`,`取正文命令:nx-kv localtask show --id <seq> --key <topicKey>`],[`seq`,`task.seq 的平铺别名`],[`title`,`task.title 的平铺别名`],[`showCmd`,`task.showCmd 的平铺别名`]]},{label:`文档型(kind=ref)· ref 子对象`,items:[[`ref.refId`,`refs 表 id`],[`ref.title`,`文档标题`],[`ref.relPath`,`文档相对路径 / 外部 md 绝对路径`],[`ref.readCmd`,`读取命令:nx-kv docs get rel:<路径>(或 path:<绝对路径>)`],[`refId`,`ref.refId 的平铺别名`],[`relPath`,`ref.relPath 的平铺别名`],[`readCmd`,`ref.readCmd 的平铺别名`]]},{label:`同步汇总`,items:[[`attach.syncSummary.text`,`本次批量同步的一行汇总`],[`attach.syncSummary.dir`,`同步目录`],[`attach.syncSummary.downloaded`,`已下载数`],[`attach.syncSummary.skipped`,`跳过数`],[`attach.syncSummary.failureCount`,`失败数`]]},{label:`通用`,items:[[`task.id`,`任务号`],[`task.text`,`任务原文(交付模板等处仍在用)`]]}],timecheck:[{label:`时间目标`,items:[[`goal.check`,`时间检查指令(任务级)`],[`goal.statusLine`,`目录级目标状态行`],[`goal.name`,`目标名`],[`goal.deadline`,`截止时间`],[`goal.remainingSec`,`剩余秒数`],[`goal.remainingMin`,`剩余分钟(向上取整)`],[`goal.overtimeSec`,`超时秒数`],[`goal.reached`,`是否到点`]]},{label:`通用`,items:[[`task.id`,`任务号`]]}],ext:[{label:`队列`,items:[[`ext.topic`,`主题 / 队列名`],[`ext.count`,`待领取任务数`],[`ext.list`,`待领取清单(可循环 id/title/topic)`]]},{label:`通用`,items:[[`task.id`,`任务号`]]}],ack:[{label:`通用`,items:[[`task.id`,`任务号`],[`task.text`,`任务原文`],[`source`,`任务来源(local/global)`],[`summary`,`领取方现状`],[`name`,`领取方名字`],[`cwd`,`领取方目录`],[`params`,`外部参数(k=v)`]]}],getloop:[{label:`持续 get`,items:[[`getloop.text`,`持续 get 指令正文`],[`getloop.waitMinutes`,`单轮等待分钟数`]]},{label:`通用`,items:[[`task.id`,`任务号`]]}]},O=t();function k({blockId:e}){let t=D[e]||[];return t.length?(0,O.jsxs)(`div`,{className:`setp-params`,"aria-label":`可使用参数`,children:[(0,O.jsx)(`div`,{className:`setp-params-head`,children:`可使用参数`}),t.map(e=>(0,O.jsxs)(`div`,{className:`setp-params-row`,children:[(0,O.jsx)(`span`,{className:`setp-params-label`,children:e.label}),(0,O.jsx)(`div`,{className:`setp-params-items`,children:e.items.map(([e,t])=>(0,O.jsxs)(`span`,{className:`setp-param`,children:[(0,O.jsx)(`code`,{children:e}),(0,O.jsx)(`span`,{children:t})]},e))})]},e.label))]}):null}function A(){return`bt_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function j(e){return S.find(t=>t.id===e)||S[0]}function M(e,t,n){let r=e[t];return r.list.find(e=>e.id===n)||r.list.find(e=>e.id===r.active)||r.list[0]}function N(){let e=i(),{dialog:t,node:a}=n(),[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(S[0].id),[p,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(!1),v=(e,t=null)=>{s(t=>({...t||{},lists:e}));let n=t||(p&&p.blockId===c?p:null),r=n?.blockId||c,i=M(e,r,n?.id||e[r].active);h({blockId:r,id:i.id,name:i.name,template:i.template})},y=()=>{r(`/api/localtasks`).then(e=>{let t=e?.settings||{},n=E(t.blockTemplates),r=t.appendMode===`plain`?`plain`:`xml`;s({lists:n,appendMode:r});let i=S[0],a=M(n,i.id,n[i.id].active);l(i.id),h({blockId:i.id,id:a.id,name:a.name,template:a.template})}).catch(t=>e(`读取失败:`+(t.message||t)))};if((0,d.useEffect)(y,[]),!o)return(0,O.jsx)(`div`,{className:`setp-note`,children:`读取提示词模板…`});let b=j(c),x=o.lists[c],C=p?.id===m,w=async(t,n,i=null)=>{if(!g){_(!0);try{let a=await r(`/api/localtasks/setting`,{method:`PATCH`,body:{blockTemplates:t}});v(E(a?.blockTemplates),i),e(n)}catch(t){e(String(t.message||t))}finally{_(!1)}}},T=()=>JSON.parse(JSON.stringify(o.lists)),D=e=>{if(g)return;l(e);let t=M(o.lists,e,o.lists[e].active);h({blockId:e,id:t.id,name:t.name,template:t.template})},N=e=>{let t=M(o.lists,c,e);h({blockId:c,id:t.id,name:t.name,template:t.template})},P=e=>h(t=>({...t,...e})),F=()=>{if(C){e(`系统内置模板不可编辑;请先「复制」一份再改`);return}let t=String(p.name||``).trim().slice(0,60)||`未命名模板`,n=String(p.template??``),r=T(),i=r[c],a=i.list.findIndex(e=>e.id===p.id),o={id:p.id,name:t,template:n,builtin:!1};a>=0?i.list[a]=o:i.list.push(o),w(r,`已保存模板(当前生效项保存后立即生效)`,{blockId:c,id:p.id})},I=()=>{if(g)return;let e=T(),t={id:A(),name:`新模板`,template:``,builtin:!1};e[c].list.push(t),w(e,`已新建模板,填写后保存,再点「启用」`,{blockId:c,id:t.id})},L=(e=p?.id)=>{if(g||!e)return;let t=M(o.lists,c,e),n=T(),r={id:A(),name:`${t.name||`模板`} 副本`.slice(0,60),template:t.template||``,builtin:!1};n[c].list.push(r),w(n,`已复制模板`,{blockId:c,id:r.id})},R=()=>{if(g||C)return;let e=String(p.name||``).trim().slice(0,60)||`未命名模板`,t=T(),n=t[c],r=n.list.findIndex(e=>e.id===p.id),i={id:p.id,name:e,template:String(p.template??``),builtin:!1};r>=0?n.list[r]=i:n.list.push(i),n.active=p.id,w(t,`已保存并启用「${e}」`,{blockId:c,id:p.id})},z=e=>{if(g||e===x.active)return;let t=T();t[c].active=e,w(t,`已启用「${M(o.lists,c,e).name}」`,{blockId:c,id:e})},B=async n=>{if(g)return;if(n===`builtin`){e(`系统内置模板不可删除`);return}let r=M(o.lists,c,n);if(!await t({title:`删除模板?`,message:`将删除「${r.name}」,保存后不可恢复。该区块的系统内置模板会保留。`,okText:`删除`,danger:!0}))return;let i=T(),a=i[c];a.list=a.list.filter(e=>e.id!==n),a.active===n&&(a.active=m),w(i,`已删除模板,当前生效项已回落到系统内置`)},V=()=>{if(g||x.active===`builtin`)return;let e=T();e[c].active=m,w(e,`已恢复系统内置模板`,{blockId:c,id:m})},H=async t=>{if(!(g||t===o.appendMode)){_(!0);try{let n=await r(`/api/localtasks/setting`,{method:`PATCH`,body:{appendMode:t}});s(e=>({...e,appendMode:n?.appendMode===`plain`?`plain`:`xml`})),e(`已保存追加模式(全局生效)`)}catch(t){e(String(t.message||t))}finally{_(!1)}}};return(0,O.jsxs)(`div`,{className:`setp-tpl-editor`,children:[(0,O.jsx)(`div`,{className:`setp-mode-picks`,children:f.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:`setp-mode-pick`+(o.appendMode===e.id?` is-on`:``),disabled:g,onClick:()=>H(e.id),children:[(0,O.jsx)(`b`,{children:e.label}),(0,O.jsx)(`small`,{children:e.desc})]},e.id))}),(0,O.jsx)(`nav`,{className:`setp-block-tabs`,"aria-label":`提示词区块`,children:S.map(e=>{let t=M(o.lists,e.id,o.lists[e.id].active);return(0,O.jsxs)(`button`,{type:`button`,className:`setp-block-tab`+(e.id===c?` is-on`:``),disabled:g,onClick:()=>D(e.id),children:[(0,O.jsx)(`span`,{children:e.label}),(0,O.jsx)(`small`,{children:t.builtin?`系统内置`:t.name})]},e.id)})}),(0,O.jsxs)(`div`,{className:`setp-block-card`,children:[(0,O.jsxs)(`div`,{className:`setp-block-card-head`,children:[(0,O.jsxs)(`div`,{className:`setp-block-card-title`,children:[(0,O.jsx)(`b`,{children:b.label}),(0,O.jsx)(`span`,{className:`setp-note`,children:b.desc})]}),(0,O.jsxs)(`div`,{className:`setp-block-card-actions`,children:[(0,O.jsx)(u,{variant:`secondary`,disabled:g,onClick:I,children:`新建模板`}),(0,O.jsx)(u,{variant:`secondary`,disabled:g||x.active===`builtin`,onClick:V,children:`恢复内置`})]})]}),(0,O.jsx)(`div`,{className:`setp-tpl-list`,role:`listbox`,"aria-label":`${b.label}模板列表`,children:x.list.map(e=>{let t=e.id===x.active,n=e.id===p?.id;return(0,O.jsxs)(`div`,{className:`setp-tpl-pick${t?` is-on`:``}${n?` is-sel`:``}`,children:[(0,O.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,className:`setp-tpl-name`,title:e.name,onClick:()=>N(e.id),children:[(0,O.jsx)(`span`,{className:`setp-tpl-name-text`,children:e.name}),e.builtin&&(0,O.jsx)(`span`,{className:`setp-badge`,children:`内置`}),t&&(0,O.jsx)(`span`,{className:`setp-badge`,children:`启用中`})]}),(0,O.jsx)(u,{variant:`secondary`,className:`setp-tpl-act`,disabled:g,title:e.builtin?`复制系统内置模板`:`复制该模板`,onClick:()=>L(e.id),children:`复制`}),(0,O.jsx)(u,{variant:`secondary`,className:`setp-tpl-act`,disabled:g||t,title:`设为该区块当前生效模板`,onClick:()=>z(e.id),children:`启用`}),(0,O.jsx)(u,{variant:`secondary`,danger:!0,className:`setp-tpl-act`,disabled:g||e.builtin,title:e.builtin?`系统内置模板不可删除`:`删除该模板`,onClick:()=>B(e.id),children:`删除`})]},e.id)})}),p&&(0,O.jsxs)(`div`,{className:`setp-tpl-editor-box`,children:[(0,O.jsxs)(`div`,{className:`setp-tpl-editor-head`,children:[(0,O.jsx)(`span`,{children:C?`系统内置`:`编辑 · ${p.name||`未命名模板`}`}),(0,O.jsx)(`span`,{className:`setp-note`,children:p.id===x.active?`当前生效,保存后立即参与领取`:`未启用;保存后可点「启用」`})]}),!C&&(0,O.jsxs)(`div`,{className:`setp-row`,children:[(0,O.jsx)(`span`,{children:`模板名`}),(0,O.jsx)(`div`,{className:`setp-input`,children:(0,O.jsx)(`input`,{value:p.name,maxLength:60,disabled:g,onChange:e=>P({name:e.target.value})})})]}),(0,O.jsx)(`textarea`,{className:`setp-area setp-tpl-textarea`,value:p.template,readOnly:C,spellCheck:!1,disabled:g,placeholder:C?``:`在这里写该区块的模板`,onChange:e=>P({template:e.target.value})}),(0,O.jsx)(k,{blockId:c}),(0,O.jsxs)(`div`,{className:`setp-proj-a`,children:[C?(0,O.jsx)(u,{variant:`secondary`,disabled:g,onClick:L,children:`复制为我的模板`}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(u,{variant:`primary`,disabled:g,onClick:F,children:`保存`}),(0,O.jsx)(u,{variant:`secondary`,disabled:g,onClick:y,children:`撤销改动`}),p.id!==x.active&&(0,O.jsx)(u,{variant:`secondary`,disabled:g,onClick:R,children:`保存并启用`})]}),(0,O.jsx)(`span`,{className:`spacer`})]})]})]}),a]})}function P(){let e=s()||{},t=e.rows||[],n=e.repoData&&e.repoData.repos||[],r=e.repoData&&e.repoData.boards||[];return(0,d.useMemo)(()=>{let e=new Map;for(let n of t)n&&n.key&&e.set(String(n.key),n.name||n.key);let i=new Map;for(let e of n)e&&e.key&&(e.type||`repo`)!==`group`&&i.set(String(e.key),e.name||e.key);let a=new Map;for(let e of n)e&&(e.type||``)===`group`&&e.key&&a.set(String(e.key),e.name||e.key);for(let e of r){let t=String(e&&(e.key||e.id)||``);t&&a.set(t,e&&e.name||t)}return{topicByKey:e,repoByKey:i,groupByKey:a,topics:t,repos:n,boards:r}},[t,n,r])}function F(e,t){if(e===`*`)return`全局`;let n=String(e).indexOf(`:`);if(n<0)return String(e);let r=String(e).slice(0,n),i=String(e).slice(n+1),a={topic:`目录`,repo:`项目`,group:`组`}[r]||r,o=``;return r===`topic`?o=t.topicByKey.get(i)||``:r===`repo`?o=t.repoByKey.get(i)||``:r===`group`&&(o=t.groupByKey.get(i)||``),o?`${a} · ${o}`:`${a} ${/^[0-9a-f]{16}$/.test(i)?`${i.slice(0,6)}…`:i}`}function I({scope:e,onChange:t,originTopic:n=``,catalog:r,classPrefix:a=`setp`}){let o=i(),s=P(),c=r||s,[l,u]=(0,d.useState)(null),f=Array.isArray(e)?e:[],p=f.includes(`*`),m=f.filter(e=>e!==`*`),h=a,g=n?c.topicByKey.get(n)||(/^[0-9a-f]{16}$/.test(n)?`${n.slice(0,6)}…`:n):``,_=async e=>{try{await t(e)}catch(e){o(String(e.message||e))}},v=async e=>{if(f.includes(e)){o(`已经在可见范围里了`),u(null);return}await _([...f,e]),u(null)},y=(0,d.useMemo)(()=>{if(l===`topic`)return(c.topics||[]).filter(e=>e&&e.key).map(e=>({entry:`topic:${e.key}`,label:e.name||e.key,sub:e.cwd||``}));if(l===`repo`)return(c.repos||[]).filter(e=>e&&e.key&&(e.type||`repo`)!==`group`&&e.key!==`__unbound__`).map(e=>({entry:`repo:${e.key}`,label:e.name||e.key,sub:e.key}));if(l===`group`){let e=new Set,t=[];for(let n of c.repos||[])n&&(n.type||``)===`group`&&n.key&&!e.has(n.key)&&(e.add(n.key),t.push({entry:`group:${n.key}`,label:n.name||n.key,sub:n.key}));for(let n of c.boards||[]){let r=n&&(n.key||n.id);r&&!e.has(r)&&(e.add(r),t.push({entry:`group:${r}`,label:n&&n.name||r,sub:String(r)}))}return t}return[]},[l,c]);return(0,O.jsxs)(`div`,{className:`${h}-scope-block`,children:[(0,O.jsx)(`div`,{className:`${h}-scope`,children:f.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:`${h}-scope-chip on`,title:`${e} —— 点击移除`,onClick:()=>_(f.filter(t=>t!==e)),children:[F(e,c),` ×`]},e))}),(0,O.jsxs)(`div`,{className:`${h}-scope-add`,children:[(0,O.jsx)(`span`,{className:`${h}-scope-add-label`,children:`添加`}),(0,O.jsx)(`button`,{type:`button`,className:`${h}-scope-add-btn`,disabled:p,title:p?`已绑定全局`:`加上「全局」绑定(与目录/项目/组平级)`,onClick:()=>!p&&_([`*`,...m]),children:`全局`}),[`topic`,`repo`,`group`].map(e=>(0,O.jsx)(`button`,{type:`button`,className:`${h}-scope-add-btn`+(l===e?` on`:``),onClick:()=>u(l===e?null:e),children:{topic:`目录`,repo:`项目`,group:`组`}[e]},e)),g?(0,O.jsxs)(`span`,{className:`${h}-scope-origin`,title:`创建于主题 ${n}`,children:[`创建于 `,g]}):null]}),l&&(0,O.jsx)(`div`,{className:`${h}-scope-pick`,role:`listbox`,"aria-label":`选择可见对象`,children:y.length?y.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:`${h}-scope-pick-it`,disabled:f.includes(e.entry),title:e.sub||e.entry,onClick:()=>v(e.entry),children:[(0,O.jsx)(`span`,{className:`${h}-scope-pick-name`,children:e.label}),f.includes(e.entry)?(0,O.jsx)(`span`,{className:`${h}-scope-pick-done`,children:`已加`}):null]},e.entry)):(0,O.jsx)(`div`,{className:`${h}-scope-pick-empty`,children:`暂无可选项`})})]})}function L({openTemplateEditor:e}){let t=c(),r=i(),{dialog:a,node:o}=n(),s=t.templates||[],[l,f]=(0,d.useState)(null),[p,m]=(0,d.useState)(!1);if(t.unsupported)return(0,O.jsx)(`div`,{className:`setp-note`,children:`当前服务比面板旧——重启面板后才有模板功能。`});let h=async(e,t)=>{if(!p){m(!0);try{await e(),t&&r(t)}catch(e){r(String(e.message||e))}finally{m(!1)}}},g=async e=>{await a({title:`删除模板「${e.name}」`,danger:!0,okText:`删除`})&&(await h(()=>t.remove(e.id),`已删除「${e.name}」`),l===e.id&&f(null))};return(0,O.jsxs)(`div`,{className:`setp-tpl setp-tpl-cards`,children:[o,!s.length&&(0,O.jsx)(`div`,{className:`setp-note`,children:`还没有模板(内置默认模板加载中…)。`}),s.map(n=>{let r=n.id===t.defaultId,i=l===n.id;return(0,O.jsxs)(`div`,{className:`setp-tpl-card`+(r?` is-default`:``),children:[(0,O.jsxs)(`div`,{className:`setp-tpl-card-head`,children:[(0,O.jsx)(`span`,{className:`setp-tpl-card-name`,children:n.name}),r&&(0,O.jsx)(`span`,{className:`setp-badge`,children:`默认`}),n.builtin&&(0,O.jsx)(`span`,{className:`setp-badge soft`,children:`内置`})]}),i&&(0,O.jsx)(`div`,{className:`setp-tpl-card-scope`,children:(0,O.jsx)(I,{scope:n.scope,originTopic:n.originTopic,onChange:e=>t.update(n.id,{scope:e})})}),(0,O.jsxs)(`div`,{className:`setp-tpl-card-foot`,children:[(0,O.jsx)(`span`,{className:`grow`}),(0,O.jsx)(u,{variant:`secondary`,disabled:p,onClick:()=>f(i?null:n.id),children:`可见绑定`}),(0,O.jsx)(u,{variant:`secondary`,disabled:p,onClick:()=>e?.({id:n.id,name:n.name,mode:`edit`}),children:`编辑`}),!r&&(0,O.jsx)(u,{variant:`secondary`,disabled:p,onClick:()=>h(()=>t.setDefault(n.id),`默认模板已设为「${n.name}」`),children:`设为默认`}),!n.builtin&&(0,O.jsx)(u,{variant:`secondary`,disabled:p,onClick:()=>g(n),children:`删除`})]})]},n.id)}),(0,O.jsx)(`div`,{className:`setp-tpl-card-new`,children:(0,O.jsx)(u,{variant:`secondary`,disabled:p,onClick:()=>e?.({mode:`new`,scope:[]}),children:`+ 新建模板`})})]})}function R(){let e=i(),t=s()||{},n=t.patchPrefs,[a,o]=(0,d.useState)([]),[c,l]=(0,d.useState)([]),[u,f]=(0,d.useState)([]),p=(0,d.useCallback)(()=>{Promise.all([r(`/api/repos`),r(`/api/boards`)]).then(([e,n])=>{o(Array.isArray(e)?e:e?.repos||[]),l(Array.isArray(n)?n:n?.boards||[]),f(t.prefs?.hidden||[])}).catch(t=>e(`读取失败:`+(t.message||t)))},[e,t.prefs]);(0,d.useEffect)(()=>{p()},[p]);let m=e=>{let r=t.prefs?.hidden||[],i=r.includes(e)?r.filter(t=>t!==e):[...r,e];n&&n({hidden:i}),f(i)},h=(e,t,n,r)=>(0,O.jsx)(`div`,{className:`setp-row`,children:(0,O.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,cursor:`pointer`},children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:!u.includes(t),onChange:()=>m(t)}),(0,O.jsx)(`span`,{children:n}),r?(0,O.jsx)(`span`,{className:`mono faint`,children:r}):null]})},e+`:`+t);return(0,O.jsxs)(`div`,{className:`setp-side`,children:[(0,O.jsx)(`div`,{className:`setp-note`,children:`勾掉的项目组 / 项目不在侧边栏显示(登记与数据都留着,随时勾回来)。`}),(0,O.jsx)(`div`,{className:`setp-row`,children:(0,O.jsx)(`span`,{children:`项目组(指针)`})}),c.map(e=>h(`board`,e.key||e.id,e.name,`${(e.repos||[]).length} 个模块`)),!c.length&&(0,O.jsx)(`div`,{className:`setp-note`,children:`还没有项目组。`}),(0,O.jsx)(`div`,{className:`setp-row`,children:(0,O.jsx)(`span`,{children:`项目 / 仓库(模块)`})}),a.map(e=>h(`repo`,e.key||e.id,e.name,e.path)),!a.length&&(0,O.jsx)(`div`,{className:`setp-note`,children:`还没有登记仓库。`})]})}var z=[{id:`pref`,label:`偏好`,icon:`flow`},{id:`work`,label:`工作区`,icon:`sidebar`},{id:`cloud`,label:`云端与存储`,icon:`cloud`},{id:`taskTemplates`,label:`任务模板`,icon:`list`},{id:`prompts`,label:`提示词模板`,icon:`flow`},{id:`sidebar`,label:`侧栏显示`,icon:`sidebar`}];function B(){let e=s()||{},t=i(),{dialog:o,node:c}=n(),f=e.prefs||{},p=e.patchPrefs||(()=>{}),m=e.model,[h,g]=(0,d.useState)(`pref`),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(!1),x=(0,d.useCallback)(async()=>{try{v(await r(`/api/setting`))}catch(e){t(`读取设置失败:`+(e.message||e))}},[t]);(0,d.useEffect)(()=>{x()},[x]);let S=e=>e().catch(e=>t(String(e.message||e))),C=e=>S(async()=>{b(!0);try{v(await r(`/api/setting`,{method:`POST`,body:e})),t(`已保存`)}finally{b(!1)}}),w={pref:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`setp-row`,children:[(0,O.jsx)(`span`,{children:`侧边栏默认收起`}),(0,O.jsxs)(`button`,{className:`toggle`+(f.defaultFolded?` on`:``),onClick:()=>p({defaultFolded:!f.defaultFolded}),children:[(0,O.jsx)(`span`,{className:`dot`}),f.defaultFolded?`开`:`关`]})]}),(f.hidden||[]).length>0&&(0,O.jsxs)(`div`,{className:`setp-row`,children:[(0,O.jsxs)(`span`,{children:[`隐藏仓库 `,f.hidden.length,` 个`]}),(0,O.jsx)(u,{variant:`secondary`,onClick:()=>p({hidden:[]}),children:`恢复显示`})]})]}),work:(0,O.jsx)(O.Fragment,{children:(0,O.jsxs)(`div`,{className:`setp-row`,children:[(0,O.jsx)(`span`,{children:`布局`}),(0,O.jsx)(u,{variant:`secondary`,onClick:async()=>{await o({title:`重置为初始两栏`,message:`丢掉存下来的布局,回到初始的两栏(目录 + 开始)?`,okText:`重置`})&&e.shell&&e.shell.resetLayout()},children:`重置为初始两栏`})]})}),cloud:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`setp-row`,children:[(0,O.jsx)(`span`,{children:`读任务时自动下载附件`}),(0,O.jsxs)(`button`,{className:`toggle`+(_&&_.autoSyncAttachments?` on`:``),disabled:!_||y,onClick:()=>C({autoSyncAttachments:!_.autoSyncAttachments}),children:[(0,O.jsx)(`span`,{className:`dot`}),_&&_.autoSyncAttachments?`开`:`关`]})]}),(0,O.jsxs)(`div`,{className:`setp-row`,children:[(0,O.jsx)(`span`,{children:`附件目录`}),(0,O.jsxs)(`span`,{className:`setp-input`,children:[(0,O.jsx)(`input`,{value:_&&_.attachmentsDir||``,placeholder:`(默认 ~/.nx-kv/attachments/)`,onChange:e=>v(t=>({...t,attachmentsDir:e.target.value}))}),(0,O.jsx)(u,{variant:`secondary`,disabled:!_||y,onClick:()=>C({attachmentsDir:_.attachmentsDir}),children:`保存`})]})]}),(0,O.jsxs)(`div`,{className:`setp-row`,children:[(0,O.jsx)(`span`,{children:`参考仓库存储根`}),(0,O.jsxs)(`span`,{className:`setp-input`,children:[(0,O.jsx)(`input`,{value:_&&_.gitRepoRoot||``,placeholder:`(未设置 —— clone 参考仓库前先设)`,onChange:e=>v(t=>({...t,gitRepoRoot:e.target.value}))}),(0,O.jsx)(u,{variant:`secondary`,disabled:!_||y,onClick:()=>C({gitRepoRoot:_.gitRepoRoot}),children:`保存`})]})]}),(0,O.jsxs)(`div`,{className:`setp-row`,children:[(0,O.jsx)(`span`,{children:`开发仓库克隆根`}),(0,O.jsxs)(`span`,{className:`setp-input`,children:[(0,O.jsx)(`input`,{value:_&&_.gitDevRoot||``,placeholder:`(未设置 —— 导入布局时只登记不克隆)`,onChange:e=>v(t=>({...t,gitDevRoot:e.target.value}))}),(0,O.jsx)(u,{variant:`secondary`,disabled:!_||y,onClick:()=>C({gitDevRoot:_.gitDevRoot}),children:`保存`})]})]})]}),taskTemplates:(0,O.jsx)(L,{openTemplateEditor:e=>{m&&l(m,e||{})}}),prompts:(0,O.jsx)(N,{}),sidebar:(0,O.jsx)(R,{})};return(0,O.jsxs)(`div`,{className:`setp`,children:[(0,O.jsx)(`nav`,{className:`setp-nav`,"aria-label":`设置分区`,children:z.map(e=>(0,O.jsxs)(`button`,{className:`setp-navitem`+(h===e.id?` on`:``),"aria-current":h===e.id,onClick:()=>g(e.id),children:[(0,O.jsx)(a,{name:e.icon,size:14}),(0,O.jsx)(`span`,{children:e.label})]},e.id))}),(0,O.jsxs)(`div`,{className:`setp-body`,children:[(0,O.jsx)(`div`,{className:`setp-h`,children:z.find(e=>e.id===h).label}),w[h]]}),c]})}export{B as default};
@@ -1,11 +0,0 @@
1
- import{g as e,h as t,l as n,m as r,o as i,p as a,u as o,y as s}from"./task-status-BnymQMTw.js";import{r as c,t as l,v as u}from"./workspace-C_5X2gIr.js";import{n as d}from"./app-context-D7HAx67n.js";import{n as f,r as p,t as m}from"./frontmatter-QvrjUNzF.js";import{a as h,g,h as _,i as v,m as y,n as b,p as x,r as S,t as C,u as w,v as T}from"./md-history-C9vOgGLz.js";import{a as E,r as D}from"./md-parse-awNLHAzO.js";import{n as O,t as k}from"./board-view-CZKZsyk-.js";import{c as A,d as j,f as M,h as N,l as P,m as F,p as I,s as L,u as R}from"./index-DNB8tgNi.js";import{t as z}from"./status-tag-p3fo3Hbr.js";import{a as B,i as V,n as ee,o as H}from"./composer-launch-Bf4rXhLs.js";import{t as te}from"./route-crumb-BfRi1GKw.js";import{i as ne,n as U,r as W,t as G}from"./reopen-text-BylkngqC.js";import{n as re,u as K}from"./tool-bar-DpwpQ47h.js";var q=s(e(),1),J=/^>\s*\[![A-Za-z][\w-]*\][ \t]*(.*)$/,Y=/完成总结/,ie=/反馈/,ae=/第\s*(\d+)\s*轮/;function oe(e){let t=String(e??``).split(`
2
- `),n=t.length&&String(t[0]).match(J);if(!n)return null;let r=t.slice(1).map(e=>e.replace(/^>[ \t]?/,``)).filter(e=>e.trim()!==``).join(`
3
- `);return{title:String(n[1]??``).trim(),body:r}}function se(e){let t=y(String(e??``));if(!t.length)return[];let n=[],r=null,i=``;return t.forEach((e,t)=>{let a=String(e||``).trim(),o=oe(a);if(o&&Y.test(o.title)){let e=Number((o.title.match(ae)||[])[1]);r={round:Number.isFinite(e)&&e>0?e:n.length+1,blockIndex:t,feedbackBlockIndex:-1,ackText:o.body,feedbackText:``},n.push(r),i=`ack`;return}if(a===`## 上一轮完成总结`){r={round:n.length+1,blockIndex:t,feedbackBlockIndex:-1,ackText:``,feedbackText:``},n.push(r),i=`ack`;return}if(o&&ie.test(o.title)){r&&i===`ack`&&(r.feedbackBlockIndex=t,r.feedbackText=o.body,i=`feedback`);return}if(a===`## 验收反馈`){r&&i===`ack`&&(r.feedbackBlockIndex=t,i=`feedback`);return}a&&r&&(i===`ack`?r.ackText+=(r.ackText?`
4
- `:``)+a:r.feedbackText+=(r.feedbackText?`
5
- `:``)+a)}),n.filter(e=>e.ackText!==``)}function ce(e){let t=String(e?.ackText||``).split(`
6
- `).map(e=>e.replace(/^#+\s*/,``).replace(/\*\*/g,``).trim()).find(e=>e!==``);if(!t)return`第 ${e?.round??1} 轮`;let n=t.length>24?`${t.slice(0,24)}…`:t;return`第 ${e.round} 轮 · ${n}`}var le=`nx-kv-ack-rail-pos`;function ue(e={}){let{x:t,y:n,parentW:r,parentH:i,railW:a=0,railH:o=0,margin:s=8}=e||{};if(![t,n,r,i].every(e=>Number.isFinite(e)))return null;let c=Math.max(s,r-a-s),l=Math.max(s,i-o-s);return{x:Math.min(c,Math.max(s,t)),y:Math.min(l,Math.max(s,n))}}function de(){try{let e=JSON.parse(localStorage.getItem(le)||`null`);if(!e||typeof e!=`object`)return null;let t=Number(e.x),n=Number(e.y);return!Number.isFinite(t)||!Number.isFinite(n)?null:{x:t,y:n}}catch{return null}}function fe(e){try{e?localStorage.setItem(le,JSON.stringify({x:Math.round(e.x),y:Math.round(e.y)})):localStorage.removeItem(le)}catch{}}var X=t(),pe=4;function me(e,t,n){if(!e||t<0)return null;let r=e.querySelector(`.mdw-lp-block[data-i="${t}"]`);if(r)return r;let i=[...Array.from(e.querySelectorAll(`h2`)).filter(e=>(e.textContent||``).trim()===`上一轮完成总结`),...Array.from(e.querySelectorAll(`.md-callout-t`)).filter(e=>/完成总结/.test(e.textContent||``))].sort((e,t)=>e.compareDocumentPosition(t)&4?-1:1);return i[n]?i[n]:null}function he({nodes:e=[],scrollRoot:t=null,onJump:n=null}){let[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(0),[s,c]=(0,q.useState)(de),[l,u]=(0,q.useState)(!1),d=(0,q.useRef)(null),f=(0,q.useRef)(null),p=(0,q.useRef)(!1);(0,q.useEffect)(()=>{let e=d.current,t=e&&e.parentElement;if(!e||!t)return;let n=()=>{c(n=>{if(!n)return n;let r=t.getBoundingClientRect(),i=e.getBoundingClientRect(),a=ue({x:n.x,y:n.y,parentW:r.width,parentH:r.height,railW:i.width,railH:i.height});return a&&(a.x!==n.x||a.y!==n.y)?a:n})};return n(),window.addEventListener(`resize`,n,{passive:!0}),()=>window.removeEventListener(`resize`,n)},[]);let m=(0,q.useCallback)(e=>{if(e.pointerType===`mouse`&&e.button!==0)return;let t=d.current,n=t&&t.parentElement;if(!t||!n)return;let r=t.style.bottom;t.style.bottom=`auto`;let i=t.getBoundingClientRect();r?t.style.bottom=r:t.style.bottom=``;let a=n.getBoundingClientRect();f.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startLeft:i.left-a.left,startTop:i.top-a.top,parentW:a.width,parentH:a.height,railW:i.width,railH:i.height,moved:!1};try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}},[]),h=(0,q.useCallback)(e=>{let t=f.current;if(!t||e.pointerId!==t.pointerId)return;let n=e.clientX-t.startX,r=e.clientY-t.startY;if(!t.moved){if(Math.hypot(n,r)<pe)return;t.moved=!0,p.current=!0,u(!0),document.body.style.userSelect=`none`}let i=ue({x:t.startLeft+n,y:t.startTop+r,parentW:t.parentW,parentH:t.parentH,railW:t.railW,railH:t.railH});i&&(t.last=i,c(i))},[]),g=(0,q.useCallback)(e=>{let t=f.current;t&&e.pointerId===t.pointerId&&(f.current=null,t.moved&&(u(!1),document.body.style.userSelect=``,fe(t.last)))},[]),_=(0,q.useCallback)(()=>{c(null),fe(null)},[]),v=(0,q.useMemo)(()=>(e||[]).map(e=>({...e,title:ce(e)})),[e]);(0,q.useEffect)(()=>{let e=t;if(!e||!v.length)return;let n=()=>{let t=e.getBoundingClientRect(),n=0;for(let r of v){let i=me(e,r.blockIndex,r.round-1);i&&i.getBoundingClientRect().top-t.top<=40&&(n=r.round)}o(n)};return n(),e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},[t,v]);let y=(0,q.useCallback)(e=>{let r=t,i=r?me(r,e.blockIndex,e.round-1):null;i&&(i.scrollIntoView({behavior:`smooth`,block:`start`}),o(e.round)),n?.(e)},[t,n]);return v.length?(0,X.jsxs)(`aside`,{ref:d,className:`doc-rail ack-rail`+(r?` open`:``)+(l?` dragging`:``),style:s?{left:s.x,top:s.y,right:`auto`,bottom:`auto`}:void 0,"aria-label":`验收轮次`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`doc-rail-menu`,title:r?`收起轮次(双击回默认位)`:`展开轮次 · 按住拖动 · 双击回默认位`,"aria-expanded":r,onClick:()=>{if(p.current){p.current=!1;return}i(e=>!e)},onPointerDown:m,onPointerMove:h,onPointerUp:g,onPointerCancel:g,onDoubleClick:_,children:[(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{})]}),(0,X.jsx)(`div`,{className:`doc-rail-ticks`,role:`navigation`,"aria-label":`验收轮次`,children:v.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`doc-rail-tick`+(a===e.round?` on`:``),style:{"--tw":`18px`},title:e.title,"aria-current":a===e.round?`true`:void 0,onClick:()=>y(e)},e.round))}),r&&(0,X.jsx)(`div`,{className:`doc-rail-panel`,children:(0,X.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,X.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`验收轮次`}),v.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`doc-rail-row`+(a===e.round?` on`:``),title:e.ackText,onClick:()=>y(e),children:[`第 `,e.round,` 轮`]},e.round))]})})]}):null}var ge=[{op:`bold`,label:`B`,title:`粗体`,cls:`b`},{op:`italic`,label:`I`,title:`斜体`,cls:`i`},{op:`code`,label:`</>`,title:`代码`,cls:`code`},{op:`link`,label:`链`,title:`链接`,cls:`link`}];function _e({at:e,onFormat:t,onCopy:n,onCompose:r,onDelete:i}){if(!e)return null;let a=e.kind||`task`,o=a===`format`||a===`both`;return(0,X.jsx)(`div`,{id:`mdw-sel-menu`,className:`mdw-sel-menu open kind-${a}`,style:{left:e.x,top:e.y},role:`menu`,onMouseDown:e=>{e.target.closest?.(`textarea, input, button`)||e.preventDefault()},children:o?(0,X.jsxs)(`div`,{className:`mdw-sel-fmt`,role:`group`,"aria-label":`选区格式`,children:[ge.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn ${e.cls}`,title:e.title,onClick:()=>t?.(e.op),children:e.label},e.op)),(0,X.jsx)(`span`,{className:`mdw-sel-sep`,"aria-hidden":!0}),(0,X.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn`,title:`复制`,onClick:n,children:`复制`}),(0,X.jsx)(`span`,{className:`mdw-sel-sep`,"aria-hidden":!0}),(0,X.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn comment`,title:`评论 → 打开 md 编辑面板`,onClick:()=>r?.(),children:`评论`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`cap`,children:`选区`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>r?.(),children:`评论`}),(0,X.jsx)(`div`,{className:`sep`}),(0,X.jsx)(`button`,{type:`button`,onClick:n,children:`复制选区`}),i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`sep`}),(0,X.jsx)(`button`,{type:`button`,className:`danger`,title:`删除选区触到的整段块`,onClick:i,children:`删除选区`})]}):null]})})}var ve=[{title:`格式`,items:[[`Ctrl/⌘ B`,`粗体`],[`Ctrl/⌘ I`,`斜体`],[`Ctrl/⌘ E`,`行内代码`],[`Ctrl/⌘ K`,`链接`],[`1 – 6`,`正文 / 标题 / 小标题 / 列表 / 待办 / 引用`]]},{title:`编辑`,items:[[`/`,`行首唤起命令菜单`],[`Tab / ⇧Tab`,`缩进 / 反缩进`],[`Enter`,`新建块(列表自动续行)`],[`⇧Enter`,`块内软换行`],[`Ctrl/⌘ Z`,`撤销`],[`Ctrl/⌘ ⇧Z`,`重做`]]},{title:`导航与文件`,items:[[`Ctrl/⌘ F`,`查找(Enter 下一个,F3 继续)`],[`Ctrl/⌘ S`,`保存并同步`],[`Ctrl/⌘ ⇧ O`,`评论任务:右侧并排打开原文`],[`Ctrl/⌘ /`,`打开 / 关闭本速查`],[`Enter(标题内)`,`跳到正文`]]}];function ye({onClose:e}){return(0,X.jsx)(i,{title:`快捷键`,onClose:e,size:`lg`,className:`mdw-sheet`,children:(0,X.jsx)(`div`,{className:`mdw-sheet-cols`,children:ve.map(e=>(0,X.jsxs)(`section`,{className:e.title===`导航与文件`?`wide`:void 0,children:[(0,X.jsx)(`h4`,{children:e.title}),(0,X.jsx)(`dl`,{children:e.items.map(([e,t])=>(0,X.jsxs)(`div`,{className:`mdw-sheet-row`,children:[(0,X.jsx)(`dt`,{children:(0,X.jsx)(`kbd`,{children:e})}),(0,X.jsx)(`dd`,{children:t})]},e))})]},e.title))})})}var be={origin:`起点`,reopen:`反馈`,comment:`评论`,current:`当前`};function xe({nodes:e=[],onOpenNode:t}){return e.length?(0,X.jsx)(`ol`,{className:`mdw-chain-list`,"aria-label":`任务链节点`,children:e.map((n,r)=>{let i=n.current?`current`:`t-${n.dirKey||``}-${n.id??n.taskId??r}`,a=be[n.kind]||n.kind||`?`,o=n.excerpt||n.feedback||a,s=[n.taskId==null?null:`#${n.taskId}`,n.at||null,n.attachmentCount?`📎${n.attachmentCount}`:null].filter(Boolean).join(` · `);return(0,X.jsxs)(`li`,{className:`mdw-chain-li${n.current?` is-current`:``}`,children:[(0,X.jsxs)(`div`,{className:`mdw-chain-rail`,"aria-hidden":!0,children:[(0,X.jsx)(`span`,{className:`mdw-chain-dot`}),r<e.length-1?(0,X.jsx)(`span`,{className:`mdw-chain-line`}):null]}),(0,X.jsxs)(`button`,{type:`button`,className:`mdw-chain-card${n.kind===`comment`?` is-comment`:``}`,title:n.current?`当前任务(本页)`:`查看:${o}`,disabled:!!n.current,onClick:()=>{n.current||t?.(n)},children:[(0,X.jsx)(`span`,{className:`mdw-chain-kind`,children:a}),(0,X.jsx)(`span`,{className:`mdw-chain-ex`,children:o||`—`}),s?(0,X.jsx)(`span`,{className:`mdw-chain-meta`,children:s}):null]})]},i)})}):(0,X.jsx)(`div`,{className:`mdw-chain-empty muted`,children:`这条任务还没有链(反馈 / 评论派生后会出现)`})}function Se({open:e,nodes:t,onOpenNode:n,onClose:r}){return e?(0,X.jsxs)(i,{title:`任务链`,onClose:r,size:`md`,className:`mdw-chain-modal`,children:[(0,X.jsx)(`p`,{className:`mdw-chain-hint`,children:`从早到晚排列。点非当前节点可在旁路打开内容。`}),(0,X.jsx)(xe,{nodes:t,onOpenNode:e=>{n?.(e),r?.()}})]}):null}function Ce(){let[e,t]=(0,q.useState)(()=>localStorage.getItem(`nxkv.taskDockOpen`)!==`0`),[n,r]=(0,q.useState)(()=>localStorage.getItem(`nxkv.taskDockTab`)||`attach`),[i,a]=(0,q.useState)(()=>{let e=Number(localStorage.getItem(`nxkv.taskDockH`));return Number.isFinite(e)&&e>=96?e:176}),o=(0,q.useRef)(i);o.current=i;let s=(0,q.useRef)(null),[c,l]=(0,q.useState)(!1),u=(0,q.useRef)(176);return(0,q.useEffect)(()=>{localStorage.setItem(`nxkv.taskDockOpen`,e?`1`:`0`)},[e]),(0,q.useEffect)(()=>{localStorage.setItem(`nxkv.taskDockTab`,n)},[n]),{dockOpen:e,setDockOpen:t,dockTab:n,setDockTab:r,dockH:i,dockHRef:o,dockRef:s,dockMax:c,setDockMax:l,dockPrevHRef:u,showDockTab:(0,q.useCallback)(e=>{r(e),t(!0)},[]),onDockDragStart:(0,q.useCallback)(t=>{if(!e)return;t.preventDefault(),l(!1);let n=t.clientY,r=o.current,i=s.current?.parentElement?.clientHeight||window.innerHeight,c=e=>Math.max(96,Math.min(Math.round(i*.62),Math.round(e))),u=e=>{let t=c(r-(e.clientY-n));o.current=t,a(t)},d=()=>{window.removeEventListener(`mousemove`,u),window.removeEventListener(`mouseup`,d),document.body.style.userSelect=``,document.body.style.cursor=``,localStorage.setItem(`nxkv.taskDockH`,String(o.current))};document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`,window.addEventListener(`mousemove`,u),window.addEventListener(`mouseup`,d)},[e]),toggleDockMax:(0,q.useCallback)(()=>{if(c){a(u.current),l(!1);return}u.current=o.current;let e=s.current?.parentElement?.clientHeight||window.innerHeight,t=Math.max(96,Math.round(e*.62));o.current=t,a(t),l(!0)},[c])}}function we({id:e,isDraft:t,topicKey:n,task:i,taskRow:a}){let[o,s]=(0,q.useState)(null);(0,q.useEffect)(()=>{s(null)},[e]);let c=a?.timegoal||null,l=o||{duration:c?.duration||``,prompt:c?.prompt||``},u=t||!!a&&a.status===`pending`,d=!t&&!!c&&i!=null,[f,p]=(0,q.useState)({busy:!1,error:``,data:null}),m=(0,q.useCallback)(()=>{if(t||!n||i==null)return;p(e=>({...e,busy:!0,error:``}));let e=new URLSearchParams({id:String(i),key:String(n)});r(`/api/localtasks/timegoal-log?${e.toString()}`).then(e=>p(t=>({...t,data:e,busy:!1}))).catch(e=>p(t=>({...t,busy:!1,error:String(e.message||e)})))},[t,n,i]);return(0,q.useEffect)(()=>{d&&m()},[d,m]),{goalDraft:o,setGoalDraft:s,goal:l,goalEditable:u,declaredGoal:c,goalLog:f,loadGoalLog:m,canShowGoalLog:d}}function Te({isDraft:e,task:t,taskRow:n,topicKey:i,topic:a,isGlobal:o,groupAnchored:s,groupId:c,app:u,model:d,historyId:f,toast:p}){let[m,h]=(0,q.useState)(null);(0,q.useEffect)(()=>{if(e||t==null||/^draft/i.test(String(t))){h(null);return}let n=!1,i=o?`key=${encodeURIComponent(k)}&id=${Number(t)}`:`cwd=${encodeURIComponent(a?.cwd||``)}&id=${Number(t)}`;return r(`/api/localtasks/chain?${i}`).then(e=>{n||h(e)}).catch(()=>{n||h(null)}),()=>{n=!0}},[e,t,o,a?.cwd,n?.history?.length,n?.forkOf,n?.reopenCount]);let g=(0,q.useMemo)(()=>{if(e||!n)return[];let r=(String(n.text||``).split(`
7
- `).map(e=>e.trim()).find(Boolean)||``).replace(/^#+\s*/,``).slice(0,100),a=Array.isArray(n.history)?n.history:[];if(a.length){let e=a.map(e=>({historyId:e.id,kind:e.kind,at:e.at,excerpt:e.excerpt||e.feedback||``,feedback:e.feedback,quote:e.quote,attachmentCount:(e.attachments||[]).length,current:!1}));return e.push({historyId:null,kind:`current`,at:n.lastReopenedAt||n.createdAt||``,excerpt:r,attachmentCount:0,current:!0}),e}let o=Array.isArray(m?.ancestors)?[...m.ancestors].reverse():[],s=Array.isArray(m?.children)?m.children:[];if(!o.length&&!s.length&&!n.forkOf)return[];let c=[];for(let e of o)e.missing||c.push({historyId:null,kind:e.forkKind||`origin`,at:e.createdAt||``,excerpt:e.excerpt||`#${e.id}`,attachmentCount:0,current:!1,taskId:e.id,dirKey:e.key});c.push({historyId:null,kind:`current`,at:n.createdAt||``,excerpt:r,attachmentCount:0,current:!0,taskId:Number(t),dirKey:i||`__GLOBAL__`});for(let e of s)c.push({historyId:null,kind:e.forkKind||`comment`,at:e.createdAt||``,excerpt:e.excerpt||`#${e.id}`,attachmentCount:0,current:!1,taskId:e.id,dirKey:e.key});return c},[e,n,m,t,i]),_=(0,q.useMemo)(()=>{if(f==null||!n)return null;let e=Number(f);return(n.history||[]).find(t=>Number(t.id)===e)||null},[f,n]),v=Array.isArray(m?.children)?m.children:[],y=v.length===0,b=v.length?v[v.length-1]:null;return{chainApi:m,chainNodes:g,historyNode:_,chainChildren:v,isChainTip:y,latestChild:b,openLatestRound:(0,q.useCallback)(()=>{b&&u.openPage&&(s?u.openPage({groupId:c,task:String(b.id),name:`#${b.id}`}):u.openPage({dirKey:String(b.key||i||`__GLOBAL__`),task:String(b.id),name:`#${b.id}`}))},[b,u.openPage,s,c,i]),openHistoryBeside:(0,q.useCallback)(n=>{let r=d||u.model;if(r&&!e){if(n?.current){p(`当前节点就是本页`);return}if(n?.historyId!=null){l(r,{component:`page`,name:`链 #${t} · ${n.kind||n.historyId}`,config:{dirKey:i||`__GLOBAL__`,task:String(t),historyId:Number(n.historyId)}});return}if(n?.taskId!=null&&n?.dirKey){l(r,{component:`page`,name:n.excerpt?String(n.excerpt).slice(0,24):`#${n.taskId}`,config:{dirKey:String(n.dirKey),task:String(n.taskId)}});return}p(`这个节点没有可打开的内容`)}},[d,u.model,e,i,t,p])}}function Ee({id:e}){let[t,n]=(0,q.useState)(null),r=(0,q.useRef)(``);return(0,q.useEffect)(()=>{n(null),r.current=``},[e]),(0,q.useEffect)(()=>{let e=()=>n(null);return document.addEventListener(`scroll`,e,!0),()=>document.removeEventListener(`scroll`,e,!0)},[]),{selMenu:t,setSelMenu:n,lastSel:r,placeSelMenu:(0,q.useCallback)((e,t,i,a,o={})=>{r.current=t,n({kind:e,text:t,...o,x:Math.min(window.innerWidth-300,Math.max(8,i)),y:Math.min(window.innerHeight-240,Math.max(8,a))})},[]),onEditorTextSel:(0,q.useCallback)(e=>{if(!e?.text||e.text.length<1){n(null);return}r.current=e.text,n({kind:`format`,text:e.text,x:Math.min(window.innerWidth-300,Math.max(8,e.x)),y:Math.min(window.innerHeight-240,Math.max(8,e.y))})},[]),closeSelMenu:(0,q.useCallback)(()=>{n(null),r.current=``},[])}}function De({id:e,taskRow:t,dockTab:n,dockOpen:r}){let[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1),c=(0,q.useRef)(null),l=String(t?.roundSummary||``).length>140;return(0,q.useEffect)(()=>{a(!1),s(!1)},[e,t?.roundSummary]),(0,q.useLayoutEffect)(()=>{let e=c.current;if(!e){s(!1);return}let t=()=>{i||s(e.scrollHeight>e.clientHeight+1)};t();let n=requestAnimationFrame(t),r=typeof ResizeObserver<`u`?new ResizeObserver(t):null;return r?.observe(e),()=>{cancelAnimationFrame(n),r?.disconnect()}},[i,t?.roundSummary,t?.completedAt,n,r]),{ackOpen:i,setAckOpen:a,ackOverflow:o,reviewSumRef:c,ackLong:l}}function Oe({doc:e,id:t,isDraft:n,task:i,taskRow:o,topicKey:s,topic:l,isGlobal:d,boardCtx:h,docFm:g,groupAnchored:v,groupId:y,rows:b,app:S,model:w,tabId:T,tpl:O,refreshLocal:A,markDirty:N,histRef:P,editorApiRef:z,attachAreaRef:ee,setDirty:H,goal:te,goalEditable:ne,declaredGoal:U,guard:W,dialog:G,showDockTab:re}){let K=a(),J=(0,q.useCallback)((e,t)=>{let n=(e||``).trim()||`未命名任务`,r=m(t),i=Object.keys(r).length>0,a=f(t);return a=_(a),a=/^#\s+/m.test(a)?a.replace(/^#\s+.+$/m,`# ${n}`):`# ${n}\n\n${a}`,i?p(a,r):a},[]),Y=(0,q.useCallback)(()=>{let e=(te.duration||``).trim(),t=(te.prompt||``).trim();if(t&&!e)return{error:`时间目标要填时长(如 2h / 90m);只写附加要求无效`};if(!ne)return{};if(!n){let n=U?.duration||``,r=U?.prompt||``;return e===n&&t===r?{}:e?{duration:e,goalPrompt:t}:{clearGoal:!0}}return e?{duration:e,goalPrompt:t}:{}},[te,ne,n,U]),ie=(0,q.useCallback)(()=>W(async()=>{if(!e)return;let a=(e.title||``).trim()||`未命名任务`,o=m(e.body),c=J(a,e.body),f=o.project?b.find(e=>!e.isGlobal&&e.repo&&e.repo.key===o.project):null,p=!!(h&&o.project&&h.members.some(e=>e.key===o.project)),g=Y();if(g.error){K(g.error);return}if(!n){let n=await r(`/api/localtasks/item`,{method:`PATCH`,body:{cwd:d?f?f.cwd:void 0:l?.cwd,key:d&&!f?k:void 0,id:Number(i),text:c,...g}});if(n?.moved){let r=n.key||s,o=String(n.task?.id??i),l=L(F(r),o);B(o,e.attachments),M(t,l,{title:a,body:n.task?.text||c}),w&&T&&w.doAction(u.updateNodeAttributes(T,{config:v?{groupId:y,task:o}:{dirKey:r,task:o}})),S.onNavigate&&S.onNavigate(v?`#/group/${encodeURIComponent(y||``)}?task=${encodeURIComponent(o)}`:`#/dir/${encodeURIComponent(r||``)}?task=${encodeURIComponent(o)}`),H(!1),C(P.current,l),K(`已改归属项目:任务迁到「${n.name}」#${o}`),A();return}B(i,e.attachments),I(t,{title:a,body:c}),H(!1),C(P.current,t),K(g.clearGoal?`已同步 MD · 时间目标已清除`:g.duration?`已同步 MD · 时间目标已更新`:`已同步 MD`),A();return}let _=await r(`/api/localtasks`,{method:`POST`,body:{...p?{text:c,board:h.board.id,project:o.project}:o.project?{text:c,project:o.project}:d?{global:!0,text:c}:{cwd:l?.cwd,text:c},...g}}),x=_?.task?.id??_?.id;if(x!=null){let n=_?.key||s,r=F(n);B(x,e.attachments);let i=L(r,String(x));M(t,i,{title:a,body:c}),w&&T&&w.doAction(u.updateNodeAttributes(T,{config:v?{groupId:y,task:String(x)}:{dirKey:n,task:String(x)}})),S.onNavigate&&S.onNavigate(v?`#/group/${encodeURIComponent(y||``)}?task=${encodeURIComponent(String(x))}`:`#/dir/${encodeURIComponent(n||``)}?task=${encodeURIComponent(String(x))}`),H(!1),C(P.current,i)}K(`已提交:${D(a)}`),A()}),[e,t,n,i,s,l,d,h,v,y,b,S,w,T,A,P,H,J,Y,W,K]),ae=(0,q.useCallback)(async e=>{let t=await e.text(),n=e.name.replace(/\.md$/i,``);await W(async()=>{let i=t.startsWith(`#`)?t:`# ${n}\n\n${t}`,a=await r(`/api/localtasks`,{method:`POST`,body:d?{global:!0,text:i}:v&&g.project?{project:g.project,text:i}:{cwd:l?.cwd,text:i}});K(`已导入:${e.name}`),A();let o=a?.task?.id??a?.id;o!=null&&S.openPage&&(v?S.openPage({groupId:y,task:String(o),name:`#${o}`}):S.openPage({dirKey:s,task:String(o),name:`#${o}`}))})},[d,v,g.project,l?.cwd,s,y,S,A,W,K]),oe=(0,q.useCallback)(async()=>{if(!e||n)return;let t=e.title||`#${i}`;await G({title:`删除任务「${t}」`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})&&W(async()=>{await r(`/api/localtasks/item`,{method:`DELETE`,body:d?{key:k,id:Number(i)}:{cwd:l.cwd,id:Number(i)}}),K(`已删除「${t}」`),w&&T&&w.doAction(u.deleteTab(T)),A()})},[e,n,i,d,l,w,T,A,W,K,G]),se=!n&&!!o&&o.status===`pending`;return{composeText:J,goalPatchOf:Y,submit:ie,importMd:ae,delTask:oe,canClosePending:se,closeTask:(0,q.useCallback)(t=>{se&&W(async()=>{let n=e?.title||`#${i}`,a=d?{key:k}:{cwd:l?.cwd};if(t===`done`){let e=await G({title:`标为完成「${n}」`,message:`任务还没被领取。确认把当前正文视为已完成?可写一句完成总结。`,input:!0,placeholder:`完成总结(可选;留空使用默认说明)`,okText:`标为完成`});if(e==null)return;await r(`/api/localtasks/items/close`,{method:`POST`,body:{...a,ids:[Number(i)],status:`done`,summary:String(e).trim()}}),K(`已标为完成 #${i}`)}else{if(!await G({title:`取消任务「${n}」`,message:`只处理待领取任务。取消为终态,原文留档。`,danger:!0,okText:`取消任务`}))return;await r(`/api/localtasks/items/close`,{method:`POST`,body:{...a,ids:[Number(i)],status:`cancelled`}}),K(`已取消 #${i}`)}A()})},[se,e,i,d,l,A,W,K,G]),addFiles:(0,q.useCallback)(async(a,o={})=>{if(!e)return;let{items:s,imageInserts:c,fileInserts:u}=await V(a),f=j(t)||e,p=f.body||``,m=c.join(``),h=p,g=null;if(m){let e=x(p,m,o);h=e.body,g=e.insertAt+m.length}u.length&&(h=x(h,u.join(``),{}).body);let _={};if(h!==p&&(_.body=h),s.length&&(_.attachments=[...f.attachments||[],...s]),Object.keys(_).length){if(I(t,_),o.mode===`edit`&&g!=null&&requestAnimationFrame(()=>{z.current?.focus?.();let e=document.querySelector(`.mdw-editor`);if(e)try{e.setSelectionRange(g,g)}catch{}}),!n){_.attachments&&B(i,_.attachments);let e=J(f.title,_.body||h);I(t,{body:e,title:E(e)});try{await r(`/api/localtasks/item`,{method:`PATCH`,body:{cwd:d?void 0:l?.cwd,key:d?k:void 0,id:Number(i),text:e}}),H(!1),A(),K(s.length?`已添加附件并同步(${s.length})`:`已同步附件`)}catch(e){N(),K(`附件已插入,同步失败:${e.message||e}`)}return}N()}},[e,t,n,i,l,d,H,A,N,J,z,K]),newTask:(0,q.useCallback)(()=>{let e=R(),t=L(F(v?y:s),e),n={};h&&h.board&&h.board.id&&(n.board=h.board.id),g.project&&(n.project=g.project),I(t,{title:``,body:p(O?O.defaultBody():``,n)}),S.openPage&&S.openPage(v?{groupId:y,task:e,name:`新任务`}:{dirKey:s,task:e,name:`新任务`})},[h,g.project,v,y,s,S,O]),cloneCur:(0,q.useCallback)(()=>{if(n||i==null||/^draft/i.test(String(i))){K(`草稿没有可克隆的队列任务`);return}W(async()=>{let t=await r(`/api/localtasks/clone`,{method:`POST`,body:d?{id:Number(i)}:{id:Number(i),cwd:l?.cwd}});K(`已克隆为新任务 #${t.task?.id??t.id}`),A();let n=t?.task?.id??t?.id;n!=null&&S.openPage&&(v?S.openPage({groupId:y,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(克隆)`}):S.openPage({dirKey:s,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(克隆)`}))})},[n,i,d,l,v,y,s,S,e,A,W,K]),forkCur:(0,q.useCallback)(()=>{if(n||i==null||/^draft/i.test(String(i))){K(`草稿没有可 Fork 的队列任务`);return}W(async()=>{let t=await r(`/api/localtasks/fork`,{method:`POST`,body:d?{id:Number(i)}:{id:Number(i),cwd:l?.cwd}});K(`已 Fork 为新任务 #${t.task?.id??t.id}(保留任务链)`),A();let n=t?.task?.id??t?.id;n!=null&&S.openPage&&(v?S.openPage({groupId:y,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(Fork)`}):S.openPage({dirKey:s,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(Fork)`}))})},[n,i,d,l,v,y,s,S,e,A,W,K]),openProgress:(0,q.useCallback)(()=>{let e=w||S.model;if(!e)return;let t=g&&g.board?String(g.board):``;c(e,{component:`progress`,name:`进程`,config:t?{groupKey:t,task:i==null?void 0:String(i)}:{dirKey:s||`__GLOBAL__`,task:i==null?void 0:String(i)},location:`right`})},[w,S.model,g,i,s]),openAttachPanel:(0,q.useCallback)(()=>{re(`attach`),setTimeout(()=>ee.current?.open(),0)},[re,ee])}}function ke({doc:e,isDraft:t,task:n,taskRow:i,topicKey:o,topic:s,isGlobal:c,dirKey:l,groupAnchored:d,groupId:f,app:p,model:m,tabId:h,refreshLocal:g,closeSelMenu:_,lastSel:v,selMenu:y,dirty:b,setDirty:x,guard:S}){let C=a(),w=(0,q.useCallback)(async()=>{if(t||n==null||/^draft/i.test(String(n)))return null;let e=c?`key=${encodeURIComponent(k)}&id=${Number(n)}`:`cwd=${encodeURIComponent(s?.cwd||``)}&id=${Number(n)}`;return r(`/api/localtasks/item?${e}`).catch(()=>null)},[t,n,c,s?.cwd]),T=(0,q.useCallback)(()=>{let t=m||p.model;t&&ee(t,{mode:`feedback`,taskLabel:n==null?``:`#`+n,taskTitle:String(e?.title||``).replace(/^#+\s*/,``),prevQuote:String(i?.roundSummary||``).trim()||String(e?.body||``).trim().slice(0,400),src:{dirKey:o||l||`__GLOBAL__`,task:String(n),name:`原文 #${n}`},onSubmit:e=>D(e)})},[m,p.model,n,e,i,o,l]),D=(0,q.useCallback)(({text:a,attachments:l=[],inserts:u=``}={})=>{let m=String(a||``).trim();if(_(),!m&&!(l&&l.length)){C(`写一下反馈`);return}let h=e?.title||`#${n}`;S(async()=>{let a=await w(),_=String(a?.text??``).trim()||String(e?.body??``).trim();if(!_&&!t){C(`拿不到任务当前正文,已取消反馈(防止丢内容)`);return}let v=m||`(见附件)`;u&&(v=`${v}${u}`);let y=G({base:_,feedback:v,ackSummary:a?.roundSummary||i?.roundSummary||``,feedbackHeading:U,bold:!0}),b=!t&&n!=null&&!/^draft/i.test(String(n))?{forkOf:String(n),forkKind:`reopen`}:{},x=await r(`/api/localtasks`,{method:`POST`,body:c?{global:!0,text:y,...b}:{cwd:s?.cwd,text:y,...b}}),S=String(x?.task?.id??x?.id??``);if(!S){C(`反馈已提交,但未拿到新任务编号`),g();return}let T=x?.key||o;I(L(F(T),S),{title:E(y),body:y}),l?.length&&B(S,l),C(`已反馈「${h}」→ 新任务 #${S}`),g(),p.openPage&&(d?p.openPage({groupId:f,task:S,name:`${h.slice(0,24)}(反馈)`}):p.openPage({dirKey:T,task:S,name:`${h.slice(0,24)}(反馈)`}))})},[e,n,i,t,c,s,o,d,f,p,g,_,S,C,w]),O=(0,q.useCallback)(({text:i,attachments:a=[],inserts:l=``,quote:d}={})=>{let f=String(i||``).trim(),p=String(d||v.current||``).trim();if(_(),!f&&!(a&&a.length)){C(`写一下要提的问题`);return}if(!p&&!f){C(`先划选一段再评论`);return}if(t||n==null||/^draft/i.test(String(n))){C(`草稿先提交成任务再评论`);return}let y=e?.title||`#${n}`;S(async()=>{let t=!b&&!l&&!(a&&a.length),i;if(!t){let t=await w(),n=String(t?.text??``).trim()||String(e?.body??``).trim();if(!n){C(`拿不到任务当前正文,已取消评论(防止丢内容)`);return}let r=[ne(p),f||`(见附件)`,l].filter(Boolean).join(`
8
-
9
- `);i=G({base:n,feedback:r,ackSummary:``,feedbackHeading:W,bold:!1})}let d=await r(`/api/localtasks/reopen`,{method:`POST`,body:{...c?{key:k}:{cwd:s?.cwd},id:Number(n),...i?{text:i}:{},kind:`comment`,quote:p,feedback:f,attachments:(a||[]).map(e=>({id:e.id,name:e.name,type:e.type,size:e.size,url:e.url||``}))}}),_=d?.key||o,v=String(d?.task?.id??n),S=String(d?.task?.text??i??``);S&&I(L(F(_),v),{title:E(S),body:S}),a?.length&&B(v,[...e?.attachments||[],...a]),m&&h&&_!==o&&m.doAction(u.updateNodeAttributes(h,{config:{dirKey:_,task:v}})),x(!1),C(`已回写评论「${y}」#${v}`),g()})},[e,n,t,c,s,o,m,h,g,_,v,b,x,S,C,w]);return{fetchServerTask:w,openFeedback:T,spawnFeedbackTask:D,submitCommentInPlace:O,openCommentFromToolbar:(0,q.useCallback)(()=>{let t=String(window.getSelection()||``).trim()||(y?.text?String(y.text):``);if(!t){C(`先划选一段再评论`);return}v.current=t;let r=m||p.model;r&&(ee(r,{mode:`comment`,quote:t,taskLabel:n==null?``:`#`+n,taskTitle:String(e?.title||``).replace(/^#+\s*/,``),src:{dirKey:o||l||`__GLOBAL__`,task:String(n),name:`原文 #${n}`},onSubmit:e=>O({...e,quote:t})}),_())},[e,n,o,l,m,p.model,v,y,O,_,C])}}function Ae({doc:e,beside:t,topicKey:n,topic:r,task:i,app:a}){let o=(0,q.useMemo)(()=>e?m(e.body):{},[e&&e.body]);return{docFm:o,parentRef:(0,q.useMemo)(()=>{if(t)return null;let a=String(o.parent||``).trim(),s=String(o.parentDir||n||``).trim();if(a&&!/^draft/i.test(a))return{dirKey:s||n,task:a,name:`#${a}`};let c=String(e?.body||``).match(/>\s*锚定自「([^」]+)」/);if(!c)return null;let l=c[1].trim(),u=(r?.tasks||[]).find(e=>String(e.id)===String(i)?!1:E(e.text||``)===l||String(e.text||``).includes(`# ${l}`));return u?{dirKey:n,task:String(u.id),name:`#${u.id}`}:null},[t,o.parent,o.parentDir,e?.body,n,r,i]),boardCtx:(0,q.useMemo)(()=>{let e=o.board;if(!e)return null;let t=(a.repoData&&a.repoData.boards||[]).find(t=>t.id===e||t.key===e||t.name===e);if(!t)return null;let n=a.repoData&&a.repoData.repos||[],r=new Map(n.map(e=>[e.key,e]));return{board:t,members:(t.repos||[]).map(e=>r.get(e.key)).filter(Boolean).map(e=>({key:e.key,name:e.name}))}},[o.board,a.repoData])}}function je({state:e,onClose:t}){let n=a(),r=e?.data,o=async()=>{try{await navigator.clipboard.writeText(String(r?.rendered||``)),n(`已复制原文`)}catch{n(`复制失败(剪贴板不可用)`)}},s=r?.switches||{},c=r?[`ack ${s.ack?.on?`开(${s.ack.count} 条)`:`关`}`,`交付上下文 ${s.deliveryTemplate?.custom?`自定义`:`内置默认`}`,`持续 get ${r.getLoop?.enabled?`开(${r.getLoop.waitMinutes} 分钟)`:`关`}`].join(` · `):``,l=r?`预览:agent 执行 get 会收到的提示词${r.task?.id?` · #${r.task.id}`:` · 草稿`}`:`预览:agent 执行 get 会收到的提示词`;return(0,X.jsxs)(i,{title:l,size:`wide`,onClose:t,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`mdw-prev-hint`,children:`与 CLI 取任务共用同一份排版;不含「已取得下一条任务…」头部行。`}),(0,X.jsx)(`span`,{className:`grow`}),(0,X.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:o,disabled:!r,children:`复制原文`}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:t,children:`关闭`})]}),children:[e.busy&&(0,X.jsx)(`div`,{className:`mdw-prev-note`,children:`渲染中…`}),e.error&&(0,X.jsxs)(`div`,{className:`mdw-prev-note`,children:[`预览失败:`,e.error,/接口不存在/.test(String(e.error))&&(0,X.jsx)(`div`,{className:`mdw-prev-hint`,children:`本机面板服务较旧:重启面板(结束当前 serve 进程后重新启动)即可生效,刷新页面不够。`})]}),r&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`pre`,{className:`mdw-prev-body`,children:r.rendered||``}),r.segments?.length?(0,X.jsxs)(`details`,{className:`mdw-prev-seg`,children:[(0,X.jsxs)(`summary`,{children:[`段落来源(`,r.segments.length,` 段)`]}),(0,X.jsx)(`ol`,{children:r.segments.map((e,t)=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`span`,{className:`mdw-prev-seg-lab`,children:e.label}),(0,X.jsxs)(`span`,{className:`mdw-prev-seg-n`,children:[String(e.text||``).length,` 字`]})]},t))}),(0,X.jsx)(`div`,{className:`mdw-prev-note`,children:`改这些段去「设置 → 提示词 / 模板」;「持续 get」在项目级设置里。`})]}):(0,X.jsx)(`div`,{className:`mdw-prev-note`,children:`当前没有任何模板段:交付时就只有任务正文。`}),(0,X.jsx)(`div`,{className:`mdw-prev-switch`,children:c})]})]})}function Me(e){let t=Math.max(0,Number(e)||0);return t>=3600?`${Math.floor(t/3600)}h ${Math.floor(t%3600/60)}m`:t>=60?`${Math.floor(t/60)}m ${t%60}s`:`${t}s`}function Ne({dockOpen:e,dockTab:t,dockH:n,dockRef:r,dockMax:i,showDockTab:a,onDockDragStart:s,toggleDockMax:l,setDockOpen:u,canShowGoalLog:d,goalLog:f,openGoalLog:p,isDraft:m,task:h,topic:g,topicKey:_,isGlobal:v,doc:y,id:b,model:x,app:S,refreshLocal:C,markDirty:T,saveDoc:E,persistAtt:D,attachAreaRef:O,reviewBarRef:A,reviewSumRef:j,taskRow:M,ackOpen:N,setAckOpen:P,ackOverflow:F,ackLong:I,ackHtml:L,isChainTip:R,latestChild:z,openFeedback:B,openLatestRound:V}){return e?(0,X.jsxs)(`div`,{className:`mdw-dock`,ref:r,style:{height:`${n}px`},children:[(0,X.jsx)(`div`,{className:`mdw-dock-drag`,role:`separator`,"aria-orientation":`horizontal`,title:`上下拖动调整信息面板高度(双击最大化 / 还原)`,onMouseDown:s,onDoubleClick:l}),(0,X.jsxs)(`div`,{className:`mdw-dock-head`,children:[(0,X.jsxs)(`div`,{className:`mdw-dock-tabs`,role:`tablist`,"aria-label":`信息面板`,children:[(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===`attach`,className:`mdw-dock-tab${t===`attach`?` is-on`:``}`,onClick:()=>a(`attach`),children:`附件`}),d?(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===`check`,className:`mdw-dock-tab${t===`check`?` is-on`:``}`,onClick:p,children:[`check`,(0,X.jsx)(`span`,{className:`mdw-dock-tab-num`,children:f.data?.count??0})]}):null,(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===`feedback`,className:`mdw-dock-tab${t===`feedback`?` is-on`:``}`,onClick:()=>a(`feedback`),children:`反馈`})]}),(0,X.jsxs)(`div`,{className:`mdw-dock-acts`,children:[(0,X.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:l,title:i?`还原面板高度`:`最大化面板高度`,"aria-label":i?`还原面板高度`:`最大化面板高度`,children:(0,X.jsx)(o,{name:i?`collapse`:`expand`})}),(0,X.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:()=>u(!1),title:`关闭面板(底部状态栏仍保留入口)`,"aria-label":`关闭面板`,children:(0,X.jsx)(o,{name:`x`})})]})]}),(0,X.jsxs)(`div`,{className:`mdw-dock-body`,children:[t===`attach`?m?(0,X.jsx)(H,{attachments:y.attachments,onRemove:e=>{let t=(y.attachments||[]).filter(t=>t.id!==e);T(),E(b,{attachments:t}),m||D(h,t)}}):g?(0,X.jsx)(K,{ref:O,host:`task`,hostId:Number(h),hostKey:v?k:void 0,hostCwd:v?void 0:g.cwd,allow:{file:!0,url:!0,task:!0,ref:!0},taskOptions:(g.tasks||[]).map(e=>({id:e.id,text:e.text,status:e.status})),onChanged:C,onOpenTask:e=>{S.openPage&&e&&e.seq!=null&&S.openPage({dirKey:e.key||_,task:String(e.seq),name:`#${e.seq}`})},onOpenDoc:e=>{let t=w(e);x&&t&&c(x,{component:`doc`,name:e.split(`/`).pop()||e,config:{docId:t},location:`center`})}}):(0,X.jsx)(`div`,{className:`mdw-dock-empty`,children:`没有可挂载附件的上下文。`}):null,t===`check`?(0,X.jsxs)(`div`,{className:`mdw-dock-check`,children:[f.busy&&!f.data?(0,X.jsx)(`div`,{className:`mdw-dock-empty`,children:`读取中…`}):null,f.error?(0,X.jsxs)(`div`,{className:`mdw-dock-empty`,children:[`读取失败:`,f.error]}):null,f.data?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`mdw-dock-meta mono`,children:[`时间目标 ${f.data.duration||`—`}`,f.data.startedAt?` · 开始 ${f.data.startedAt}`:``,f.data.deadline?` · 截止 ${f.data.deadline}`:` · 尚未开始计时`,f.data.archived?` · 已归档`:``,` · ${f.data.count||0} 轮`]}),(f.data.count||0)>0?(0,X.jsx)(`div`,{className:`mdw-goal-log`,children:f.data.entries.map((e,t)=>(0,X.jsxs)(`div`,{className:`mdw-goal-log-row`,children:[(0,X.jsxs)(`div`,{className:`mdw-goal-log-head mono`,children:[`R`,t+1,` · `,e.checkedAt,` · `,e.reached?`已到点`:`未到点`,` · 已用`,` `,Me(e.elapsedSec),` · 剩余 `,Me(e.remainingSec)]}),e.summary?(0,X.jsx)(`div`,{className:`mdw-goal-log-body`,children:e.summary}):null,e.progress?(0,X.jsx)(`div`,{className:`mdw-goal-log-prog`,children:e.progress}):null]},`${e.checkedAt}-${t}`))}):(0,X.jsx)(`div`,{className:`mdw-dock-empty`,children:`还没有 check 记录——任务领取后每轮 check 会出现在这里。`})]}):null]}):null,t===`feedback`?!m&&M?.completedAt?(0,X.jsxs)(`div`,{className:`mdw-review`,ref:A,children:[(0,X.jsxs)(`div`,{className:`mdw-review-main`,children:[(0,X.jsx)(`span`,{className:`mdw-review-badge`,children:`已完成 · 等待验收`}),(0,X.jsx)(`span`,{className:`mdw-review-at mono`,children:M.completedAt}),M.roundSummary?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{ref:j,className:`mdw-review-sum${N?` is-open`:``}`,title:N||!(F||I)?`agent 的完成总结(ack)`:`点击下方展开全文`,dangerouslySetInnerHTML:{__html:L}}),(F||I||N)&&(0,X.jsx)(`button`,{type:`button`,className:`mdw-review-more`,onClick:()=>P(e=>!e),children:N?`收起`:`展开全文`})]}):null]}),(0,X.jsx)(`div`,{className:`mdw-review-acts`,children:R?(0,X.jsx)(`button`,{type:`button`,className:`ghost`,onClick:B,title:`新开一条任务携带反馈(原任务不动)`,children:`反馈`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`mdw-review-later`,title:`这条任务已有后续轮次——在旧轮次上反馈会把链分叉,请到最新一轮反馈`,children:`已进入后续轮次`}),z?(0,X.jsxs)(`button`,{type:`button`,className:`ghost`,onClick:V,title:`到最新一轮 #${z.id} 反馈`,children:[`去最新一轮 #`,z.id]}):null]})})]}):(0,X.jsx)(`div`,{className:`mdw-dock-empty`,children:`任务完成后,agent 的完成总结会显示在这里。`}):null]})]}):null}function Pe({dockOpen:e,dockTab:t,showDockTab:n,setDockOpen:r,canShowGoalLog:i,goalLog:a,openGoalLog:s,isDraft:c,taskRow:l}){return(0,X.jsxs)(`div`,{className:`mdw-sbar`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${e&&t===`attach`?` is-on`:``}`,onClick:()=>n(`attach`),title:`附件(点击展开信息面板)`,children:[(0,X.jsx)(o,{name:`list`}),(0,X.jsx)(`span`,{className:`mdw-sbar-lab`,children:`附件`})]}),i?(0,X.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${e&&t===`check`?` is-on`:``}`,onClick:s,title:`时间目标每轮 check(点击展开信息面板)`,children:[(0,X.jsx)(o,{name:`clock`}),(0,X.jsx)(`span`,{className:`mdw-sbar-lab`,children:`check`}),(0,X.jsx)(`span`,{className:`mdw-sbar-num`,children:a.data?.count??0})]}):null,(0,X.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${e&&t===`feedback`?` is-on`:``}`,onClick:()=>n(`feedback`),title:`完成总结 / 反馈(点击展开信息面板)`,children:[(0,X.jsx)(o,{name:`edit`}),(0,X.jsx)(`span`,{className:`mdw-sbar-lab`,children:`反馈`})]}),(0,X.jsx)(`span`,{className:`mdw-sbar-grow`}),!c&&l?(0,X.jsx)(`span`,{className:`mdw-sbar-stat`,title:`任务状态`,children:(0,X.jsx)(z,{t:l})}):null,(0,X.jsx)(`button`,{type:`button`,className:`mdw-sbar-chev${e?` is-open`:``}`,onClick:()=>r(e=>!e),title:e?`收起信息面板`:`展开信息面板`,"aria-expanded":e,"aria-label":e?`收起信息面板`:`展开信息面板`,children:(0,X.jsx)(o,{name:`chevron`})})]})}function Fe({goal:e,setGoalDraft:t,goalEditable:n,declaredGoal:r,openGoalLog:i,markDirty:a,task:o}){let s=(e.duration||``).trim(),c=(e.prompt||``).trim();return{goalBadge:s||c?{label:`⏱ ${s||`目标`}`,title:c||(n?`任务级时间目标(在「更多」里设置;领取即计时)`:`已领取计时,声明不可改`)}:null,goalMenu:n||r?(0,X.jsxs)(`div`,{className:`mdw-goal-menu`,children:[(0,X.jsx)(`div`,{className:`mdw-goal-menu-lab`,children:`时间目标`}),n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`input`,{className:`mdw-goal-dur mono`,value:e.duration,placeholder:`2h / 90m / 30分钟,留空不带`,onChange:n=>{t({...e,duration:n.target.value}),a()}}),(0,X.jsx)(`input`,{className:`mdw-goal-prompt`,value:e.prompt,placeholder:`附加要求(可选,随 check 指令一起固化)`,onChange:n=>{t({...e,prompt:n.target.value}),a()}})]}):(0,X.jsxs)(`span`,{className:`mdw-goal-ro mono`,title:r?.prompt||`已领取计时,声明不可改`,children:[r?.duration||`—`,` · 已领取计时`]}),r&&o!=null?(0,X.jsx)(`button`,{type:`button`,className:`ghost`,onClick:i,title:`查看时间目标的每轮 check 记录`,children:`查看每轮 check 日志`}):null]}):null}}function Ie({historyId:e,historyNode:t,closeBesideSelf:n}){let r={origin:`起点`,reopen:`反馈`,comment:`评论`}[t?.kind]||`节点`,i=t?T(t.text||``,t.attachments||[]):``;return(0,X.jsxs)(`div`,{className:`mdw is-beside`,children:[(0,X.jsxs)(`div`,{className:`mdw-beside-h`,children:[(0,X.jsxs)(`span`,{className:`mdw-beside-lab`,children:[`链节点 · `,r,` #`,e]}),(0,X.jsx)(`span`,{className:`grow`}),(0,X.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭`,"aria-label":`关闭`,onClick:n,children:`×`})]}),(0,X.jsx)(`div`,{className:`mdw-hist-ro`,children:t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`mdw-hist-meta`,children:[(0,X.jsx)(`span`,{children:t.at||`—`}),t.quote?(0,X.jsxs)(`span`,{children:[`锚定:`,t.quote.slice(0,80)]}):null,t.feedback?(0,X.jsxs)(`span`,{children:[`反馈:`,t.feedback.slice(0,80)]}):null,t.summary?(0,X.jsxs)(`span`,{children:[`上轮总结:`,t.summary.slice(0,80)]}):null]}),(0,X.jsx)(`article`,{className:`md-body`,dangerouslySetInnerHTML:{__html:i||`<p class="muted">(空)</p>`}})]}):(0,X.jsxs)(`div`,{className:`muted`,children:[`找不到链节点 #`,e]})})]})}function Le({boardCtx:e,docFm:t,goalEditable:n,doc:r,id:i,markDirty:a}){return e?(0,X.jsxs)(`div`,{className:`mdw-goal`,children:[(0,X.jsx)(`span`,{className:`mdw-goal-lab`,title:`归属项目(限本组成员):决定提交进哪个项目的队列;由组面板「新增任务」创建时自动携带本组语义`,children:`归属项目`}),n?(0,X.jsx)(`select`,{className:`mdw-proj-pick`,value:t.project||``,onChange:n=>{I(i,{body:p(r.body,{...t,board:e.board.id,project:n.target.value})}),a()},children:e.members.map(e=>(0,X.jsx)(`option`,{value:e.key,children:e.name},e.key))}):(0,X.jsx)(`span`,{className:`mdw-proj-ro`,title:`归属项目(在本组创建时写入,随任务走)`,children:(e.members.find(e=>e.key===t.project)||{}).name||t.project||`—`})]}):null}function Re({task:e,app:t,groupAnchored:n,groupId:r,isGlobal:i,dirKey:a}){return(0,X.jsx)(`div`,{className:`mdw`,children:(0,X.jsxs)(`div`,{className:`pad stack`,children:[(0,X.jsx)(`div`,{children:(0,X.jsxs)(`strong`,{children:[`找不到任务 #`,e]})}),(0,X.jsx)(`div`,{className:`hint`,children:`它可能已被删除(软删除可用 nx-kv localtask task restore 恢复),或这个深链写错了。`}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>t.onNavigate&&t.onNavigate(n?`#/group/`+encodeURIComponent(r||``):i?`#/global`:`#/dir/`+encodeURIComponent(a||``)),children:`回到目录`})})]})})}function ze({onClose:e}){return(0,X.jsxs)(`div`,{className:`mdw-beside-h`,children:[(0,X.jsx)(`span`,{className:`mdw-beside-lab`,children:`原文(旁路)`}),(0,X.jsx)(`span`,{className:`grow`}),(0,X.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭原文面板`,"aria-label":`关闭原文面板`,onClick:e,children:`×`})]})}function Be({dirKey:e,groupId:t,task:i,beside:o=!1,tabId:s,model:c,historyId:f=null}){let m=d()||{},_=a(),{dialog:x,node:C}=n(),w=m.rows||[],D=m.refreshLocal,j=m.tpl,M=!(!t||e),R=(0,q.useMemo)(()=>M?O(w,m.repoData&&m.repoData.boards||[],t,i):null,[M,w,m.repoData,t,i]),z=R&&R.topic&&R.topic.key||e||``,V=!M&&(!z||z===`__GLOBAL__`),H=P(i),ne=F(M&&H?t:z),U=L(ne,i),W=(0,q.useMemo)(()=>M?R&&R.topic||null:V?w.find(e=>e.isGlobal)||null:w.find(e=>e.key===z)||null,[w,z,V,M,R]),G=(0,q.useMemo)(()=>(W?.tasks||[]).find(e=>String(e.id)===String(i))||null,[W,i]),K=N(),J=K[U]||null,Y=J&&J.mode===`edit`?`edit`:`split`,{dockOpen:ie,setDockOpen:ae,dockTab:oe,dockH:ce,dockRef:le,dockMax:ue,showDockTab:de,onDockDragStart:fe,toggleDockMax:pe}=Ce(),{goalDraft:me,setGoalDraft:ge,goal:ve,goalEditable:be,declaredGoal:xe,goalLog:Me,loadGoalLog:Be,canShowGoalLog:Ve}=we({id:U,isDraft:H,topicKey:z,task:i,taskRow:G}),{chainNodes:He,historyNode:Ue,isChainTip:We,latestChild:Ge,openLatestRound:Ke,openHistoryBeside:qe}=Te({isDraft:H,task:i,taskRow:G,topicKey:z,topic:W,isGlobal:V,groupAnchored:M,groupId:t,app:m,model:c,historyId:f,toast:_}),{selMenu:Z,setSelMenu:Je,lastSel:Ye,placeSelMenu:Xe,onEditorTextSel:Ze,closeSelMenu:Qe}=Ee({id:U}),{ackOpen:$e,setAckOpen:et,ackOverflow:tt,reviewSumRef:nt,ackLong:rt}=De({id:U,taskRow:G,dockTab:oe,dockOpen:ie}),[it,at]=(0,q.useState)(null),[ot,st]=(0,q.useState)(!1),[ct,lt]=(0,q.useState)(!1),[ut,dt]=(0,q.useState)(!1),ft=(0,q.useRef)(null),pt=(0,q.useRef)(null),mt=(0,q.useRef)(null),ht=(0,q.useRef)(null),gt=(0,q.useRef)(null),_t=(0,q.useRef)(null),vt=(0,q.useRef)(new Map),[yt,bt]=(0,q.useState)([]);(0,q.useEffect)(()=>{let e=!0,t=G;if(!t||!t.id)return;let n=new URLSearchParams({id:String(t.id)});return z?n.set(`key`,z):t.cwd&&n.set(`cwd`,t.cwd),r(`/api/localtasks/attachments?${n.toString()}`).then(t=>{e&&bt(t&&(t.attachments||t.data?.attachments)||[])}).catch(()=>{e&&bt([])}),()=>{e=!1}},[G,z]);let xt=(0,q.useMemo)(()=>J?T(g(J.body),yt.length?yt:J.attachments):``,[J,yt]),St=(0,q.useMemo)(()=>G?.roundSummary?T(G.roundSummary):``,[G?.roundSummary]),Ct=(0,q.useMemo)(()=>J?se(J.body):[],[J&&J.body]),[wt,Tt]=(0,q.useState)(null);(0,q.useEffect)(()=>{let e=ht.current;if(!e)return;let t=()=>e.closest(`.mdw-lp`)||e.closest(`.mdw-preview`)||null;Tt(t());let n=typeof MutationObserver<`u`?new MutationObserver(()=>Tt(t())):null;return n?.observe(e,{childList:!0,subtree:!0}),()=>n?.disconnect()},[J&&J.mode]);let Et=(0,q.useCallback)(e=>e().catch(e=>_(String(e.message||e))),[_]),Q=(0,q.useCallback)(()=>dt(!0),[]),{docFm:Dt,parentRef:$,boardCtx:Ot}=Ae({doc:J,beside:o,topicKey:z,topic:W,task:i,app:m});(0,q.useEffect)(()=>{K[U]||(H?A(U,{title:``,body:j?M?p(j.defaultBody(),{board:t}):j.defaultBody():``}):G&&A(U,{title:E(G.text),body:G.text}))},[U,H,G,M,t]);let{composeText:kt,submit:At,importMd:jt,delTask:Mt,canClosePending:Nt,closeTask:Pt,addFiles:Ft,newTask:It,cloneCur:Lt,forkCur:Rt,openProgress:zt,openAttachPanel:Bt}=Oe({doc:J,id:U,isDraft:H,task:i,taskRow:G,topicKey:z,topic:W,isGlobal:V,boardCtx:Ot,docFm:Dt,groupAnchored:M,groupId:t,rows:w,app:m,model:c,tabId:s,tpl:j,refreshLocal:D,markDirty:Q,histRef:vt,editorApiRef:_t,attachAreaRef:mt,setDirty:dt,goal:ve,goalEditable:be,declaredGoal:xe,guard:Et,dialog:x,showDockTab:de}),{openFeedback:Vt,submitCommentInPlace:Ht,openCommentFromToolbar:Ut}=ke({doc:J,isDraft:H,task:i,taskRow:G,topicKey:z,topic:W,isGlobal:V,dirKey:e,groupAnchored:M,groupId:t,app:m,model:c,tabId:s,refreshLocal:D,closeSelMenu:Qe,lastSel:Ye,selMenu:Z,dirty:ut,setDirty:dt,guard:Et}),Wt=(0,q.useCallback)(()=>{de(`check`),Be()},[de,Be]),{goalBadge:Gt,goalMenu:Kt}=Fe({goal:ve,goalDraft:me,setGoalDraft:ge,goalEditable:be,declaredGoal:xe,openGoalLog:Wt,markDirty:Q,task:i}),qt=(0,q.useCallback)(()=>{at({busy:!0});let e={cwd:V?W?.cwd||void 0:W?.cwd,key:V?k:z,...H?{text:kt((J?.title||``).trim()||`未命名任务`,J?.body||``)}:{id:Number(i)}};r(`/api/localtasks/preview`,{method:`POST`,body:e}).then(e=>at({data:e})).catch(e=>at({error:String(e.message||e)}))},[V,W?.cwd,z,H,J?.title,J?.body,i,kt]),Jt=(e,t=`typing`)=>{if(!J)return;b(vt.current,U,{title:J.title,body:J.body},t),Q();let n={title:e};Y!==`split`&&/^# (?!#)/m.test(J.body)&&(n.body=J.body.replace(/^# (?!#).+$/m,`# ${e||`未命名任务`}`)),I(U,n)},Yt=(e,t=`op`)=>{if(!J)return;b(vt.current,U,{title:J.title,body:J.body},t),Q();let n={body:e};Y!==`split`&&(n.title=E(e)),I(U,n)},Xt=()=>{if(!J)return;let e=v(vt.current,U,{title:J.title,body:J.body});e&&(I(U,{title:e.title,body:e.body}),Q(),requestAnimationFrame(()=>_t.current?.caretFromDiff?.(J.body,e.body)))},Zt=()=>{if(!J)return;let e=S(vt.current,U,{title:J.title,body:J.body});e&&(I(U,{title:e.title,body:e.body}),Q(),requestAnimationFrame(()=>_t.current?.caretFromDiff?.(J.body,e.body)))},Qt=e=>{if(!J||Y===`edit`||e.target.closest?.(`#mdw-sel-menu`)||e.target.closest?.(`textarea`))return;let t=window.getSelection(),n=(t&&String(t)).trim();if(!n||n.length<1){Je(null);return}if(!ht.current?.contains(t.anchorNode)){Je(null);return}let r=e=>e?.nodeType===3?e.parentElement:e,i=r(t.anchorNode)?.closest?.(`.mdw-lp-block`),a=r(t.focusNode)?.closest?.(`.mdw-lp-block`),o=null;if(i&&a&&i!==a&&ht.current?.contains(a)){let e=Number(i.getAttribute(`data-i`)),t=Number(a.getAttribute(`data-i`));Number.isInteger(e)&&Number.isInteger(t)&&e!==t&&(o=[Math.min(e,t),Math.max(e,t)])}let s=t.getRangeAt(0),c=s.getClientRects(),l=c.length?c[c.length-1]:s.getBoundingClientRect();Xe(`task`,n,l.right-60,l.bottom+8,o?{blockRange:o}:{})},$t=(0,q.useCallback)(()=>{if(!$){_(`这条任务没有可定位的原文`);return}let e=c||m.model;e&&l(e,{component:`page`,name:$.name||`原文 ${$.task}`,config:{dirKey:$.dirKey,task:String($.task)}})},[$,c,m.model,_]),en=(0,q.useCallback)(()=>{let e=c||m.model;e&&s&&e.doAction(u.deleteTab(s))},[c,m.model,s]),tn=e=>{pt.current.accept=e,pt.current?.click()};return(0,q.useEffect)(()=>{if(!$||o)return;let e=e=>{(e.ctrlKey||e.metaKey)&&e.shiftKey&&String(e.key||``).toLowerCase()===`o`&&(e.preventDefault(),$t())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[$,o,$t]),f==null?J?(0,X.jsxs)(`div`,{className:`mdw${o?` is-beside`:``}`,"data-mode":Y,onMouseUp:Qt,children:[C,it&&(0,X.jsx)(je,{state:it,onClose:()=>at(null)}),(0,X.jsx)(Se,{open:ct,nodes:He,onOpenNode:qe,onClose:()=>lt(!1)}),o&&(0,X.jsx)(ze,{onClose:en}),(0,X.jsxs)(`div`,{className:`mdw-main`,children:[(0,X.jsxs)(`div`,{className:`mdw-top`,children:[(0,X.jsx)(te,{}),(0,X.jsxs)(`div`,{className:`mdw-head`,children:[(0,X.jsx)(`div`,{className:`mdw-title`,children:H?J.title||`新 MD 任务`:J.title||`任务`}),(0,X.jsxs)(`div`,{className:`mdw-path`,children:[V?`全局任务池`:W?.cwd||W?.name||`—`,H?` / (${i})`:` / #${i}`,ut?` · 未保存`:``]})]})]}),(0,X.jsx)(Le,{boardCtx:Ot,docFm:Dt,goalEditable:be,doc:J,id:U,markDirty:Q}),(0,X.jsx)(re,{mode:Y,onMode:e=>I(U,{mode:e}),showMark:Y!==`edit`,submitLabel:H?`提交为任务`:`保存并同步`,onNew:It,onSubmit:At,onChain:H?null:()=>lt(!0),onPreview:qt,onImg:()=>tn(`image/*`),onAtt:()=>H?tn(`image/*,.pdf,.zip,.txt,.json,.csv`):Bt(),onImport:()=>ft.current?.click(),onClone:H?null:Lt,onFork:H?null:Rt,onComplete:Nt?()=>Pt(`done`):null,onCancelTask:Nt?()=>Pt(`cancel`):null,onMark:Ut,onDraft:()=>_(`草稿随页签保留(刷新后需从侧栏或页签重新打开)`),onDelete:H?null:Mt,onOverview:()=>m.onNavigate&&m.onNavigate(`#/overview`),onProg:zt,onSource:$?$t:null,onShortcuts:()=>st(!0),goalBadge:Gt,goalMenu:Kt}),(0,X.jsx)(h,{ref:ht,mode:Y,title:J.title,body:J.body,previewHtml:xt,onTitle:Jt,onBody:Yt,attachments:yt.length?[...J.attachments,...yt]:J.attachments,docKey:U,editorApiRef:_t,onFiles:Ft,onTextSel:Ze,onSave:At,onUndo:Xt,onRedo:Zt,onCloseSelMenu:Qe,attachHost:H?null:{host:`task`,hostId:Number(i),hostKey:V?k:void 0,hostCwd:V?void 0:W?.cwd,allow:{file:!0,url:!0,task:!0,ref:!0},taskOptions:(W.tasks||[]).map(e=>({id:e.id,text:e.text,status:e.status}))}}),(0,X.jsx)(Ne,{dockOpen:ie,dockTab:oe,dockH:ce,dockRef:le,dockMax:ue,showDockTab:de,onDockDragStart:fe,toggleDockMax:pe,setDockOpen:ae,canShowGoalLog:Ve,goalLog:Me,openGoalLog:Wt,isDraft:H,task:i,topic:W,topicKey:z,isGlobal:V,doc:J,id:U,model:c,app:m,refreshLocal:D,markDirty:Q,saveDoc:I,persistAtt:B,attachAreaRef:mt,reviewBarRef:gt,reviewSumRef:nt,taskRow:G,ackOpen:$e,setAckOpen:et,ackOverflow:tt,ackLong:rt,ackHtml:St,isChainTip:We,latestChild:Ge,openFeedback:Vt,openLatestRound:Ke}),(0,X.jsx)(Pe,{dockOpen:ie,dockTab:oe,showDockTab:de,setDockOpen:ae,canShowGoalLog:Ve,goalLog:Me,openGoalLog:Wt,isDraft:H,taskRow:G})]}),(0,X.jsx)(he,{nodes:Ct,scrollRoot:wt}),(0,X.jsx)(_e,{at:Z,onFormat:e=>{_t.current?.format?.(e),Qe()},onCompose:()=>{let t=c||m.model;if(!t)return;let n=String(Z?.text||Ye.current||``);ee(t,{mode:`comment`,quote:n,taskLabel:i==null?``:`#`+i,taskTitle:String(J?.title||``).replace(/^#+\s*/,``),src:{dirKey:z||e||`__GLOBAL__`,task:String(i),name:`原文 #${i}`},onSubmit:e=>Ht({...e,quote:n})}),Qe()},onCopy:()=>{let e=Z?.blockRange,t=``;if(e&&J){let n=y(J.body);e[1]<n.length&&(t=n.slice(e[0],e[1]+1).filter(e=>String(e??``).trim()).join(`
10
-
11
- `))}navigator.clipboard?.writeText(t||Ye.current||Z?.text||``),_(`已复制`),Qe()},onDelete:Z?.blockRange?()=>{let e=Z.blockRange;_t.current?.deleteBlockRange?.(e[0],e[1])?_(`已删除 ${e[1]-e[0]+1} 个块(Ctrl+Z 可撤销)`):_(`选区已失效`),Qe()}:null}),(0,X.jsx)(`input`,{ref:pt,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,t.length&&Ft(t)}}),(0,X.jsx)(`input`,{ref:ft,type:`file`,accept:`.md,text/markdown,text/plain`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&jt(t)}}),ot&&(0,X.jsx)(ye,{onClose:()=>st(!1)})]}):m.localReady===!1||H?(0,X.jsx)(`div`,{className:`mdw`,children:(0,X.jsx)(`div`,{className:`pad muted`,children:`载入中…`})}):(0,X.jsx)(Re,{task:i,app:m,groupAnchored:M,groupId:t,isGlobal:V,dirKey:e}):(0,X.jsx)(Ie,{historyId:f,historyNode:Ue,closeBesideSelf:en})}export{Be as default};