nx-kv 0.65.0 → 0.65.2

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 (76) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/package.json +1 -1
  3. package/src/core/db/seed-templates.ts +2 -86
  4. package/src/modules/localtask/task-lifecycle.ts +1 -1
  5. package/src/modules/promptplug/delivery.ts +151 -0
  6. package/src/modules/promptplug/factory.ts +3 -3
  7. package/src/modules/promptplug/index.ts +3 -1
  8. package/src/modules/promptplug/plugins/getloop.ts +8 -7
  9. package/src/modules/{tasktool/plugins/goal-template.ts → promptplug/plugins/goal-prompt.ts} +4 -3
  10. package/src/modules/tasktool/delivery.ts +231 -0
  11. package/src/modules/tasktool/get.ts +2 -2
  12. package/src/modules/tasktool/plugins/taskgoal-store.ts +1 -1
  13. package/src/modules/tasktool/plugins/timegoal-task-store.ts +2 -2
  14. package/src/modules/tasktool/plugins/waitgoal-config.ts +1 -25
  15. package/src/modules/tasktool/plugins/waitgoal.ts +0 -4
  16. package/src/modules/tasktool/preview.ts +3 -4
  17. package/src/modules/tasktool/wait.ts +16 -283
  18. package/src/modules/templates/actions/templates-default.ts +2 -5
  19. package/src/modules/templates/actions/templates-update.ts +1 -3
  20. package/src/modules/templates/service.ts +11 -13
  21. package/src/modules/templates/support.ts +0 -15
  22. package/src/web/frontend/App.tsx +0 -12
  23. package/src/web/frontend/api/client.generated.ts +2 -2
  24. package/src/web/frontend/components/md/live-block.tsx +1 -5
  25. package/src/web/frontend/components/md/md-panes-root.tsx +0 -4
  26. package/src/web/frontend/components/md/md-panes.tsx +1 -11
  27. package/src/web/frontend/modules/md/styles/docs.css +0 -7
  28. package/src/web/frontend/modules/md/styles/editor.css +0 -17
  29. package/src/web/frontend/modules/md/use-templates.ts +3 -13
  30. package/src/web/frontend/page/dir/index.tsx +3 -15
  31. package/src/web/frontend/page/dir/task-actions.ts +1 -16
  32. package/src/web/frontend/page/dir/task.tsx +2 -16
  33. package/src/web/frontend/page/group/index.tsx +6 -19
  34. package/src/web/frontend/page/settings/index.tsx +1 -1
  35. package/src/web/frontend/page/templates/index.tsx +5 -54
  36. package/src/web/frontend/page/templates/manage.tsx +1 -5
  37. package/src/web/frontend/page/templates/style.css +1 -43
  38. package/src/web/frontend/page/templates/template-list.tsx +7 -15
  39. package/src/web/frontend/routes/route-eq.ts +2 -3
  40. package/src/web/frontend/routes/templates.ts +0 -10
  41. package/src/web/frontend/styles-v2/shell.css +7 -0
  42. package/src/web/frontend/types.ts +2 -1
  43. package/src/web/public/assets/{bar-csH6ZW39.js → bar-Dc5Tq1eE.js} +1 -1
  44. package/src/web/public/assets/{composer-launch-Ba9cBxhb.js → composer-launch-fp2IzGzQ.js} +1 -1
  45. package/src/web/public/assets/{composer-panel-7SHKllt5.js → composer-panel-Dh681iO6.js} +1 -1
  46. package/src/web/public/assets/dir-d16q1GLe.js +3 -0
  47. package/src/web/public/assets/{doc-BmGb9F-k.js → doc-DRSKD0Re.js} +1 -1
  48. package/src/web/public/assets/group-Dc3ZgW24.js +1 -0
  49. package/src/web/public/assets/{index-D1wpt-oL.css → index-BIVxGd6t.css} +1 -1
  50. package/src/web/public/assets/index-Bg0m8gbJ.js +2 -0
  51. package/src/web/public/assets/{md-history-DVI47hu4.js → md-history-DNtgaIdH.js} +6 -6
  52. package/src/web/public/assets/{refs-P8HrKv4T.js → refs-TzxZYy7T.js} +1 -1
  53. package/src/web/public/assets/{repo-form-modal-BiBZ63DZ.js → repo-form-modal-Dg3hJWUV.js} +1 -1
  54. package/src/web/public/assets/{repos-B9D8q6U7.js → repos-uNqSR5YB.js} +1 -1
  55. package/src/web/public/assets/task-DuFOXLPC.js +11 -0
  56. package/src/web/public/assets/{task-utils-DPGXUIOk.js → task-utils-DAPxKm4c.js} +1 -1
  57. package/src/web/public/assets/templates-CwYDIBYn.css +1 -0
  58. package/src/web/public/assets/templates-DNiGvmdq.js +10 -0
  59. package/src/web/public/assets/{use-rail-drag-TGx8CLcY.js → use-rail-drag-DxIYcszo.js} +1 -1
  60. package/src/web/public/index.html +6 -7
  61. package/src/web/frontend/modules/md/fill-session.ts +0 -36
  62. package/src/web/frontend/modules/md/new-task-from-template.ts +0 -22
  63. package/src/web/frontend/modules/md/task-intent.ts +0 -29
  64. package/src/web/frontend/modules/prompts/render-template-body.ts +0 -14
  65. package/src/web/frontend/modules/prompts/template-preview.ts +0 -62
  66. package/src/web/frontend/page/templates/fill.tsx +0 -126
  67. package/src/web/public/assets/dir-D5AImCiy.js +0 -3
  68. package/src/web/public/assets/fill-session-fHxQHFaD.js +0 -1
  69. package/src/web/public/assets/group-CTktws14.js +0 -1
  70. package/src/web/public/assets/index-Byb7MFTl.js +0 -2
  71. package/src/web/public/assets/new-task-from-template-DDWu4yR4.js +0 -1
  72. package/src/web/public/assets/render-template-body-bXdedFig.js +0 -1
  73. package/src/web/public/assets/task-BBk0TQZi.js +0 -11
  74. package/src/web/public/assets/task-intent-CX5DZccN.js +0 -1
  75. package/src/web/public/assets/templates-BN9i9-6c.js +0 -11
  76. package/src/web/public/assets/templates-plA8R7jJ.css +0 -1
@@ -1 +1 @@
1
- import{c as e,d as t,f as n,h as r,i,l as a,t as o,u as s}from"./popup-DZ2Khv2c.js";import{t as c}from"./button-3JlUeln_.js";import{n as l}from"./doc-BmGb9F-k.js";var u=r(n(),1),d=t();function f({text:e,className:t=``,title:n,children:r}){let i=a();return(0,d.jsx)(`span`,{className:`copyable`+(t?` `+t:``),title:n||`点击复制`,onClick:async()=>{let t=String(e??``);try{await navigator.clipboard.writeText(t),i(`已复制: `+(t.length>60?t.slice(0,57)+`...`:t))}catch{try{let e=document.createElement(`textarea`);e.value=t,e.style.cssText=`position:fixed;opacity:0`,document.body.appendChild(e),e.select(),document.execCommand(`copy`),e.remove(),i(`已复制: `+(t.length>60?t.slice(0,57)+`...`:t))}catch{i(`复制失败(剪贴板不可用)`)}}},children:r===void 0?e:r})}var p=class extends u.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[nx-kv] 视图渲染失败:`,e,t)}render(){return this.state.error?(0,d.jsxs)(`div`,{className:`card`,style:{padding:16},children:[(0,d.jsx)(`div`,{className:`colhead`,children:(0,d.jsx)(`h3`,{children:`这个面板出错了`})}),(0,d.jsx)(`div`,{style:{whiteSpace:`pre-wrap`,wordBreak:`break-all`,marginBottom:10},children:String(this.state.error?.message||this.state.error)}),(0,d.jsx)(`div`,{className:`muted`,style:{marginBottom:10},children:`其他面板不受影响,可以切到别的 tab 继续操作;控制台有完整堆栈。`}),(0,d.jsx)(`button`,{className:`btn`,onClick:()=>this.setState({error:null}),children:`重试`})]}):this.props.children}};function m(){return s(`/api/repos`)}function h(){return s(`/api/boards`)}function g(){return s(`/api/repos/ref/check`)}function _(){return s(`/api/setting`)}function v(e){return s(`/api/setting`,{method:`POST`,body:e})}function y(e){return s(`/api/repos/remote/list?id=`+encodeURIComponent(e))}function b(e,t){return s(`/api/repos/remote/check?id=`+encodeURIComponent(e)+(t?`&url=`+encodeURIComponent(t):``))}function x(e){return s(`/api/repos/bind`,{method:`POST`,body:e})}function S(e){return s(`/api/repos/ref/sync`,{method:`POST`,body:e})}function C(e){return s(`/api/repos/ref/clone`,{method:`POST`,body:e})}function w(e,t){return s(`/api/boards/${encodeURIComponent(e)}`,{method:`PATCH`,body:t})}function T(e){return s(`/api/boards`,{method:`POST`,body:e})}function E(e){return s(`/api/boards/${encodeURIComponent(e)}`,{method:`DELETE`,body:{}})}function D(e){return s(`/api/boards/import`,{method:`POST`,body:e})}function O(){return s(`/api/boards/export`)}function k(e){return s(`/api/boards/rekey`,{method:`POST`,body:e})}function A(e){return s(`/api/boards/assign`,{method:`POST`,body:e})}function j(e){return s(`/api/boards/prune`,{method:`POST`,body:e})}function M(e){return s(`/api/repos`,{method:`POST`,body:e})}function N(e,t){return s(`/api/repos/${encodeURIComponent(e)}`,{method:`PATCH`,body:t})}function P(e){return s(`/api/repos/${encodeURIComponent(e)}`,{method:`DELETE`})}function F(e){return s(`/api/repos/detect`,{method:`POST`,body:e})}function I(e){return s(`/api/repos/open`,{method:`POST`,body:e})}function L(e){return s(`/api/repos/clone`,{method:`POST`,body:e})}function R(e){return s(`/api/repos/remote/pick`,{method:`POST`,body:e})}function z(){return s(`/api/docs`)}function B(){return s(`/api/docs/bindings`)}function V(e){return s(`/api/docs/item`,{method:`DELETE`,body:e})}function H(e){return String(e||``).trim().replace(/\s+/g,`-`).replace(/[<>:"\\|?*\x00-\x1f]/g,`-`).replace(/\.git$/i,``).replace(/\/{2,}/g,`/`).replace(/^\/+|\/+$/g,``).slice(0,160).toLowerCase()}function U(e){let t=String(e||``).trim();if(!t)return``;t=t.replace(/\/+$/,``);let n=/^git@([^:/]+):(.+)$/i.exec(t);n?t=`${n[1]??``}/${n[2]??``}`:/^[a-z][a-z0-9+.-]*:\/\//i.test(t)&&(t=t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``),t=t.replace(/^[^/]*@/,``),t=t.replace(/^([^/]+?):\d+(\/|$)/,`$1$2`),t=t.replace(/^([a-z]):/i,`$1`)),t=t.replace(/\.git$/i,``),t=t.replace(/\/{2,}/g,`/`);let r={"ssh.github.com":`github.com`,"www.github.com":`github.com`},i=t.indexOf(`/`);if(i>0){let e=t.slice(0,i).toLowerCase();t=(r[e]||e)+t.slice(i)}return t=t.replace(/^\/+|\/+$/g,``),t.toLowerCase()}var W={path:``,name:``,desc:``,type:`dev`,remote:``,key:``,icon:``};function G({editing:t,repos:n,onClose:r,onSaved:s}){let f=e(),p=a(),{dialog:m,node:h}=i(),{openByDocId:g}=l(),_=(0,u.useMemo)(()=>t&&n.find(e=>e.id===t)||null,[t,n]),[v,y]=(0,u.useState)(()=>_?{path:_.path||``,name:_.name||``,desc:_.desc||``,type:_.type||`dev`,remote:_.remote||``,key:_.key||``,icon:_.icon||``}:W),[b,x]=(0,u.useState)(()=>_?_.keyCustom===!0:!1),[S,C]=(0,u.useState)(null),[w,T]=(0,u.useState)(()=>!!_);(0,u.useEffect)(()=>{let e=v.path.trim();if(!e){C(null);return}let t=!0,n=setTimeout(async()=>{C({loading:!0});try{let n=await F({path:e});if(!t)return;C({loading:!1,...n}),n.recommended&&!w&&y(e=>({...e,remote:n.recommended,key:b?e.key:n.key||e.key}))}catch(e){t&&C({loading:!1,error:e.message})}},400);return()=>{t=!1,clearTimeout(n)}},[v.path,w,b]);let E=e=>t=>y(n=>({...n,[e]:t.target.value})),D=e=>{let t=e.target.value;T(!0),C(null),y(e=>({...e,remote:t,key:b?e.key:U(t)}))},O=e=>{x(!0),y(t=>({...t,key:e.target.value}))},k=_&&_.descDocs||null;return(0,d.jsxs)(o,{title:t?`编辑仓库 · ${t}`:`添加仓库`,onClose:r,children:[(0,d.jsxs)(`div`,{className:`form-grid`,children:[(0,d.jsxs)(`div`,{className:`form-field`,children:[(0,d.jsx)(`label`,{htmlFor:`repo-path`,children:`仓库绝对路径 *`}),(0,d.jsx)(`input`,{id:`repo-path`,placeholder:`D:/code/my-project`,spellCheck:`false`,value:v.path,onChange:E(`path`)})]}),(0,d.jsxs)(`div`,{className:`form-field`,children:[(0,d.jsx)(`label`,{htmlFor:`repo-name`,children:`名称`}),(0,d.jsx)(`input`,{id:`repo-name`,placeholder:`留空则用目录末段`,value:v.name,onChange:E(`name`)})]}),(0,d.jsxs)(`div`,{className:`form-field`,children:[(0,d.jsx)(`label`,{htmlFor:`repo-icon`,children:`图标`}),(0,d.jsx)(`input`,{id:`repo-icon`,maxLength:8,placeholder:`emoji 或单字符(留空 = 默认文件夹图标)`,value:v.icon,onChange:E(`icon`)})]}),k?(0,d.jsxs)(`div`,{className:`form-field`,children:[(0,d.jsx)(`label`,{children:`项目描述(文档)`}),(0,d.jsxs)(`div`,{className:`rp-docpick`,children:[(0,d.jsxs)(`button`,{type:`button`,className:`rp-doc`,onClick:()=>{r(),g(k.main?.docId)},children:[k.main?.title,k.main?.exists?null:(0,d.jsx)(`span`,{className:`rp-doc-todo`,children:`未写`})]}),(k.links||[]).length?(0,d.jsxs)(`span`,{className:`muted`,children:[`另有 `,(k.links||[]).length,` 篇补充文档`]}):null]})]}):null,(0,d.jsxs)(`div`,{className:`form-field`,children:[(0,d.jsx)(`label`,{htmlFor:`repo-type`,children:`类型`}),(0,d.jsxs)(`select`,{id:`repo-type`,value:v.type,onChange:E(`type`),children:[(0,d.jsx)(`option`,{value:`dev`,children:`开发仓库(本机开发的)`}),(0,d.jsx)(`option`,{value:`ref`,children:`参考仓库(远程 clone 下来的)`})]})]}),(0,d.jsxs)(`div`,{className:`form-field`,children:[(0,d.jsx)(`label`,{htmlFor:`repo-remote`,children:`远程 git 地址`}),(0,d.jsx)(`input`,{id:`repo-remote`,spellCheck:`false`,placeholder:`https://github.com/me/x.git(导出时导它,不含本地路径)`,value:v.remote,onChange:D}),S?(0,d.jsx)(`div`,{className:`form-hint`,children:S.loading?`正在从目录读取 git remote…`:S.error?`读取 git remote 失败:${S.error}`:S.recommended?`已按目录 git remote 自动填入${(S.remotes||[]).length>1?`(另有 ${(S.remotes||[]).length-1} 条候选)`:``}`:S.exists===!1?`该路径不存在 —— 请检查后重填`:S.isGit?`目录是 git 仓库,但没有配置 remote —— 请手工填写`:`目录不是 git 仓库 —— 请手工填写`}):null,(0,d.jsx)(`div`,{className:`form-hint`,children:`有远程地址时,下面的 key 会按它自动归一化:ssh / https / 带 .git / 带 user 的写法 都归一成 host/owner/repo(如 github.com/on-devplan/nx-kv)。`})]}),(0,d.jsxs)(`div`,{className:`form-field`,children:[(0,d.jsx)(`label`,{htmlFor:`repo-key`,children:`仓库 key *(全局唯一身份)`}),(0,d.jsx)(`input`,{id:`repo-key`,spellCheck:`false`,placeholder:`github.com/on-devplan/nx-kv`,value:v.key,onChange:O}),(0,d.jsx)(`div`,{className:`form-hint`,children:`没有远程地址时必须手工填写;已有仓库可查看,改 key 会波及引用它的队列 / 看板 / 关系。`})]}),(0,d.jsxs)(`div`,{className:`form-acts`,children:[(0,d.jsx)(c,{onClick:r,children:`取消`}),(0,d.jsx)(c,{disabled:!v.path.trim()||!v.key.trim()&&!v.remote.trim(),onClick:()=>f(async()=>{if(!v.path.trim())return;let e=v.remote.trim(),n=v.key.trim(),i=n?H(n):U(e);if(!i){p(`仓库 key 必填:没有远程 git 地址时必须手工填写 key(不会再自动生成 local/<目录名>)`);return}let a={path:v.path.trim(),name:v.name.trim()||void 0,type:v.type===`ref`?`ref`:`dev`,remote:e||void 0,icon:v.icon.trim()};if(t){let t=_&&_.key||``;if(b&&n===``){if(!e){p(`清空自定义 key 需要仓库有远程地址(否则 key 必填)`);return}a.key=``,a.keyCustom=!1}else if(b&&i!==t){if(!await m({title:`修改仓库 key`,message:`key 是仓库身份,改掉会连锁影响:\n\n「${t||`(空)`}」→「${i}」\n\n队列/看板/参考关系会跟随新 key 级联更新;旧 key 上的文档归属不会自动迁移,需要在文档列表里重新绑定。确认修改?`,danger:!0}))return;a.key=i,a.keyCustom=!0}}else a.key=i,b&&(a.keyCustom=!0);t?await N(encodeURIComponent(t),a):await M(a),r(),await s()}),children:t?`保存修改`:`添加仓库`})]})]}),h]})}export{V as C,N as D,w as E,f as O,k as S,v as T,I as _,L as a,C as b,O as c,D as d,h as f,m as g,y as h,b as i,p as k,g as l,z as m,A as n,T as o,B as p,x as r,E as s,G as t,_ as u,R as v,P as w,S as x,j as y};
1
+ import{c as e,d as t,f as n,h as r,i,l as a,t as o,u as s}from"./popup-DZ2Khv2c.js";import{t as c}from"./button-3JlUeln_.js";import{n as l}from"./doc-DRSKD0Re.js";var u=r(n(),1),d=t();function f({text:e,className:t=``,title:n,children:r}){let i=a();return(0,d.jsx)(`span`,{className:`copyable`+(t?` `+t:``),title:n||`点击复制`,onClick:async()=>{let t=String(e??``);try{await navigator.clipboard.writeText(t),i(`已复制: `+(t.length>60?t.slice(0,57)+`...`:t))}catch{try{let e=document.createElement(`textarea`);e.value=t,e.style.cssText=`position:fixed;opacity:0`,document.body.appendChild(e),e.select(),document.execCommand(`copy`),e.remove(),i(`已复制: `+(t.length>60?t.slice(0,57)+`...`:t))}catch{i(`复制失败(剪贴板不可用)`)}}},children:r===void 0?e:r})}var p=class extends u.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[nx-kv] 视图渲染失败:`,e,t)}render(){return this.state.error?(0,d.jsxs)(`div`,{className:`card`,style:{padding:16},children:[(0,d.jsx)(`div`,{className:`colhead`,children:(0,d.jsx)(`h3`,{children:`这个面板出错了`})}),(0,d.jsx)(`div`,{style:{whiteSpace:`pre-wrap`,wordBreak:`break-all`,marginBottom:10},children:String(this.state.error?.message||this.state.error)}),(0,d.jsx)(`div`,{className:`muted`,style:{marginBottom:10},children:`其他面板不受影响,可以切到别的 tab 继续操作;控制台有完整堆栈。`}),(0,d.jsx)(`button`,{className:`btn`,onClick:()=>this.setState({error:null}),children:`重试`})]}):this.props.children}};function m(){return s(`/api/repos`)}function h(){return s(`/api/boards`)}function g(){return s(`/api/repos/ref/check`)}function _(){return s(`/api/setting`)}function v(e){return s(`/api/setting`,{method:`POST`,body:e})}function y(e){return s(`/api/repos/remote/list?id=`+encodeURIComponent(e))}function b(e,t){return s(`/api/repos/remote/check?id=`+encodeURIComponent(e)+(t?`&url=`+encodeURIComponent(t):``))}function x(e){return s(`/api/repos/bind`,{method:`POST`,body:e})}function S(e){return s(`/api/repos/ref/sync`,{method:`POST`,body:e})}function C(e){return s(`/api/repos/ref/clone`,{method:`POST`,body:e})}function w(e,t){return s(`/api/boards/${encodeURIComponent(e)}`,{method:`PATCH`,body:t})}function T(e){return s(`/api/boards`,{method:`POST`,body:e})}function E(e){return s(`/api/boards/${encodeURIComponent(e)}`,{method:`DELETE`,body:{}})}function D(e){return s(`/api/boards/import`,{method:`POST`,body:e})}function O(){return s(`/api/boards/export`)}function k(e){return s(`/api/boards/rekey`,{method:`POST`,body:e})}function A(e){return s(`/api/boards/assign`,{method:`POST`,body:e})}function j(e){return s(`/api/boards/prune`,{method:`POST`,body:e})}function M(e){return s(`/api/repos`,{method:`POST`,body:e})}function N(e,t){return s(`/api/repos/${encodeURIComponent(e)}`,{method:`PATCH`,body:t})}function P(e){return s(`/api/repos/${encodeURIComponent(e)}`,{method:`DELETE`})}function F(e){return s(`/api/repos/detect`,{method:`POST`,body:e})}function I(e){return s(`/api/repos/open`,{method:`POST`,body:e})}function L(e){return s(`/api/repos/clone`,{method:`POST`,body:e})}function R(e){return s(`/api/repos/remote/pick`,{method:`POST`,body:e})}function z(){return s(`/api/docs`)}function B(){return s(`/api/docs/bindings`)}function V(e){return s(`/api/docs/item`,{method:`DELETE`,body:e})}function H(e){return String(e||``).trim().replace(/\s+/g,`-`).replace(/[<>:"\\|?*\x00-\x1f]/g,`-`).replace(/\.git$/i,``).replace(/\/{2,}/g,`/`).replace(/^\/+|\/+$/g,``).slice(0,160).toLowerCase()}function U(e){let t=String(e||``).trim();if(!t)return``;t=t.replace(/\/+$/,``);let n=/^git@([^:/]+):(.+)$/i.exec(t);n?t=`${n[1]??``}/${n[2]??``}`:/^[a-z][a-z0-9+.-]*:\/\//i.test(t)&&(t=t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``),t=t.replace(/^[^/]*@/,``),t=t.replace(/^([^/]+?):\d+(\/|$)/,`$1$2`),t=t.replace(/^([a-z]):/i,`$1`)),t=t.replace(/\.git$/i,``),t=t.replace(/\/{2,}/g,`/`);let r={"ssh.github.com":`github.com`,"www.github.com":`github.com`},i=t.indexOf(`/`);if(i>0){let e=t.slice(0,i).toLowerCase();t=(r[e]||e)+t.slice(i)}return t=t.replace(/^\/+|\/+$/g,``),t.toLowerCase()}var W={path:``,name:``,desc:``,type:`dev`,remote:``,key:``,icon:``};function G({editing:t,repos:n,onClose:r,onSaved:s}){let f=e(),p=a(),{dialog:m,node:h}=i(),{openByDocId:g}=l(),_=(0,u.useMemo)(()=>t&&n.find(e=>e.id===t)||null,[t,n]),[v,y]=(0,u.useState)(()=>_?{path:_.path||``,name:_.name||``,desc:_.desc||``,type:_.type||`dev`,remote:_.remote||``,key:_.key||``,icon:_.icon||``}:W),[b,x]=(0,u.useState)(()=>_?_.keyCustom===!0:!1),[S,C]=(0,u.useState)(null),[w,T]=(0,u.useState)(()=>!!_);(0,u.useEffect)(()=>{let e=v.path.trim();if(!e){C(null);return}let t=!0,n=setTimeout(async()=>{C({loading:!0});try{let n=await F({path:e});if(!t)return;C({loading:!1,...n}),n.recommended&&!w&&y(e=>({...e,remote:n.recommended,key:b?e.key:n.key||e.key}))}catch(e){t&&C({loading:!1,error:e.message})}},400);return()=>{t=!1,clearTimeout(n)}},[v.path,w,b]);let E=e=>t=>y(n=>({...n,[e]:t.target.value})),D=e=>{let t=e.target.value;T(!0),C(null),y(e=>({...e,remote:t,key:b?e.key:U(t)}))},O=e=>{x(!0),y(t=>({...t,key:e.target.value}))},k=_&&_.descDocs||null;return(0,d.jsxs)(o,{title:t?`编辑仓库 · ${t}`:`添加仓库`,onClose:r,children:[(0,d.jsxs)(`div`,{className:`form-grid`,children:[(0,d.jsxs)(`div`,{className:`form-field`,children:[(0,d.jsx)(`label`,{htmlFor:`repo-path`,children:`仓库绝对路径 *`}),(0,d.jsx)(`input`,{id:`repo-path`,placeholder:`D:/code/my-project`,spellCheck:`false`,value:v.path,onChange:E(`path`)})]}),(0,d.jsxs)(`div`,{className:`form-field`,children:[(0,d.jsx)(`label`,{htmlFor:`repo-name`,children:`名称`}),(0,d.jsx)(`input`,{id:`repo-name`,placeholder:`留空则用目录末段`,value:v.name,onChange:E(`name`)})]}),(0,d.jsxs)(`div`,{className:`form-field`,children:[(0,d.jsx)(`label`,{htmlFor:`repo-icon`,children:`图标`}),(0,d.jsx)(`input`,{id:`repo-icon`,maxLength:8,placeholder:`emoji 或单字符(留空 = 默认文件夹图标)`,value:v.icon,onChange:E(`icon`)})]}),k?(0,d.jsxs)(`div`,{className:`form-field`,children:[(0,d.jsx)(`label`,{children:`项目描述(文档)`}),(0,d.jsxs)(`div`,{className:`rp-docpick`,children:[(0,d.jsxs)(`button`,{type:`button`,className:`rp-doc`,onClick:()=>{r(),g(k.main?.docId)},children:[k.main?.title,k.main?.exists?null:(0,d.jsx)(`span`,{className:`rp-doc-todo`,children:`未写`})]}),(k.links||[]).length?(0,d.jsxs)(`span`,{className:`muted`,children:[`另有 `,(k.links||[]).length,` 篇补充文档`]}):null]})]}):null,(0,d.jsxs)(`div`,{className:`form-field`,children:[(0,d.jsx)(`label`,{htmlFor:`repo-type`,children:`类型`}),(0,d.jsxs)(`select`,{id:`repo-type`,value:v.type,onChange:E(`type`),children:[(0,d.jsx)(`option`,{value:`dev`,children:`开发仓库(本机开发的)`}),(0,d.jsx)(`option`,{value:`ref`,children:`参考仓库(远程 clone 下来的)`})]})]}),(0,d.jsxs)(`div`,{className:`form-field`,children:[(0,d.jsx)(`label`,{htmlFor:`repo-remote`,children:`远程 git 地址`}),(0,d.jsx)(`input`,{id:`repo-remote`,spellCheck:`false`,placeholder:`https://github.com/me/x.git(导出时导它,不含本地路径)`,value:v.remote,onChange:D}),S?(0,d.jsx)(`div`,{className:`form-hint`,children:S.loading?`正在从目录读取 git remote…`:S.error?`读取 git remote 失败:${S.error}`:S.recommended?`已按目录 git remote 自动填入${(S.remotes||[]).length>1?`(另有 ${(S.remotes||[]).length-1} 条候选)`:``}`:S.exists===!1?`该路径不存在 —— 请检查后重填`:S.isGit?`目录是 git 仓库,但没有配置 remote —— 请手工填写`:`目录不是 git 仓库 —— 请手工填写`}):null,(0,d.jsx)(`div`,{className:`form-hint`,children:`有远程地址时,下面的 key 会按它自动归一化:ssh / https / 带 .git / 带 user 的写法 都归一成 host/owner/repo(如 github.com/on-devplan/nx-kv)。`})]}),(0,d.jsxs)(`div`,{className:`form-field`,children:[(0,d.jsx)(`label`,{htmlFor:`repo-key`,children:`仓库 key *(全局唯一身份)`}),(0,d.jsx)(`input`,{id:`repo-key`,spellCheck:`false`,placeholder:`github.com/on-devplan/nx-kv`,value:v.key,onChange:O}),(0,d.jsx)(`div`,{className:`form-hint`,children:`没有远程地址时必须手工填写;已有仓库可查看,改 key 会波及引用它的队列 / 看板 / 关系。`})]}),(0,d.jsxs)(`div`,{className:`form-acts`,children:[(0,d.jsx)(c,{onClick:r,children:`取消`}),(0,d.jsx)(c,{disabled:!v.path.trim()||!v.key.trim()&&!v.remote.trim(),onClick:()=>f(async()=>{if(!v.path.trim())return;let e=v.remote.trim(),n=v.key.trim(),i=n?H(n):U(e);if(!i){p(`仓库 key 必填:没有远程 git 地址时必须手工填写 key(不会再自动生成 local/<目录名>)`);return}let a={path:v.path.trim(),name:v.name.trim()||void 0,type:v.type===`ref`?`ref`:`dev`,remote:e||void 0,icon:v.icon.trim()};if(t){let t=_&&_.key||``;if(b&&n===``){if(!e){p(`清空自定义 key 需要仓库有远程地址(否则 key 必填)`);return}a.key=``,a.keyCustom=!1}else if(b&&i!==t){if(!await m({title:`修改仓库 key`,message:`key 是仓库身份,改掉会连锁影响:\n\n「${t||`(空)`}」→「${i}」\n\n队列/看板/参考关系会跟随新 key 级联更新;旧 key 上的文档归属不会自动迁移,需要在文档列表里重新绑定。确认修改?`,danger:!0}))return;a.key=i,a.keyCustom=!0}}else a.key=i,b&&(a.keyCustom=!0);t?await N(encodeURIComponent(t),a):await M(a),r(),await s()}),children:t?`保存修改`:`添加仓库`})]})]}),h]})}export{V as C,N as D,w as E,f as O,k as S,v as T,I as _,L as a,C as b,O as c,D as d,h as f,m as g,y as h,b as i,p as k,g as l,z as m,A as n,T as o,B as p,x as r,E as s,G as t,_ as u,R as v,P as w,S as x,j as y};
@@ -1,4 +1,4 @@
1
- import{c as e,d as t,f as n,h as r,i,l as a,o,r as s,t as c,u as l}from"./popup-DZ2Khv2c.js";import{r as u}from"./workspace-DojQ3RP4.js";import{C as d,D as f,E as p,O as m,S as h,T as g,_,a as v,b as y,c as b,d as x,f as S,g as C,h as w,i as T,l as E,m as D,n as O,o as ee,p as k,r as A,s as j,t as M,u as N,v as P,w as F,x as I,y as L}from"./repo-form-modal-BiBZ63DZ.js";import{n as R}from"./app-context-BqCBcDsx.js";import{t as z}from"./button-3JlUeln_.js";import{i as B,n as V}from"./doc-BmGb9F-k.js";import{n as H,t as U}from"./list-filter-CWxiOSg_.js";import{t as te}from"./route-crumb-C4DgkJ8G.js";import{t as ne}from"./bar-csH6ZW39.js";import{t as re}from"./member-picker-BZgE3HGb.js";var W=r(n(),1),G=t(),K={new:{label:`新增`,cls:`new`},changed:{label:`有差异`,cls:`changed`},same:{label:`一致`,cls:`same`}};function ie({onClose:t,onChanged:n,repos:r,boards:i}){let o=e(),s=a(),[c,u]=(0,W.useState)(`import`),[d,f]=(0,W.useState)({}),[p,m]=(0,W.useState)({}),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(``),[y,b]=(0,W.useState)(``),[x,S]=(0,W.useState)(null),[C,w]=(0,W.useState)({}),[T,E]=(0,W.useState)({}),[D,O]=(0,W.useState)(`ours`),[ee,k]=(0,W.useState)(`none`),[A,j]=(0,W.useState)(``),[M,N]=(0,W.useState)(null),[P,F]=(0,W.useState)(!1),I=(0,W.useMemo)(()=>r||[],[r]),L=(0,W.useMemo)(()=>I.map(e=>e.key),[I]),R=(0,W.useMemo)(()=>(i||[]).map(e=>e.name),[i]),z=e=>{let t={};for(let n of L)t[n]=e;f(t)},B=e=>{let t={};for(let n of R)t[n]=e;m(t)},V=()=>{let e={};for(let t of L)e[t]=!d[t];f(e)},H=()=>o(async()=>{let e=Object.keys(d).filter(e=>d[e]),t=Object.keys(p).filter(e=>p[e]),n={repos:e.length&&e.length!==L.length?e:void 0,boards:t.length&&t.length!==R.length?t.map(e=>`board/${e}`):void 0,noUnassigned:h},r=new URLSearchParams;n.repos?.length&&r.set(`repos`,n.repos.join(`,`)),n.boards?.length&&r.set(`boards`,n.boards.join(`,`)),h&&r.set(`no-unassigned`,`1`);let i=await l(`/api/repos/export`+(r.toString()?`?`+r:``));v(JSON.stringify(i,null,2)),s(`已生成布局:${i.repos.length} 个仓库 / ${i.boards.length} 个看板`)}),U=()=>{if(!_)return;let e=new Blob([_],{type:`application/json`}),t=document.createElement(`a`);t.href=URL.createObjectURL(e),t.download=`nx-kv-layout-${new Date().toISOString().slice(0,10)}.json`,t.click(),URL.revokeObjectURL(t.href)},te=async e=>{let t=e.target.files?.[0];t&&(b(await t.text()),S(null),N(null))},ne=()=>o(async()=>{if(y.trim()){F(!0);try{let e=await l(`/api/repos/import/diff`,{method:`POST`,body:{json:y}});S(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;w(t);let n={};for(let t of e.boards)n[t.key]=t.status!==`same`;E(n),N(null),s(`差异:新增 ${e.summary.new} · 有差异 ${e.summary.changed} · 一致 ${e.summary.same} · 本地未拥有 ${e.summary.missing}`)}finally{F(!1)}}}),re=()=>o(async()=>{let e=Object.keys(C).filter(e=>C[e]),t=Object.keys(T).filter(e=>T[e]);F(!0);try{let r=await l(`/api/repos/import`,{method:`POST`,body:{json:y,strategy:D,clone:ee,selection:e.length?e:void 0,boards:t.length?t:void 0}});N(r),s(`导入完成:新建 ${r.created.length} · 覆盖 ${r.updated.length} · 另存 ${r.duplicated.length}`),await ie(),n&&await n()}finally{F(!1)}}),ie=(0,W.useCallback)(async()=>{try{let e=await l(`/api/repos/import/diff`,{method:`POST`,body:{json:y}});S(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;w(t)}catch{}},[y]),q=(0,W.useMemo)(()=>x?A?x.repos.filter(e=>e.status===A):x.repos:[],[x,A]),ae=(e,t)=>o(async()=>{if(t){F(!0);try{await l(`/api/repos/clone`,{method:`POST`,body:{remote:t,key:e,type:`ref`,depth:1}}),s(`已克隆: ${e}`),await ie(),n&&await n()}finally{F(!1)}}}),oe=e=>{let t={...C};for(let n of q)t[n.key]=e;w(t)};(0,W.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopImmediatePropagation(),t())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]);let se=(0,W.useMemo)(()=>{let e={new:0,changed:0,same:0};if(!x)return e;for(let t of x.repos)e[t.status]=(e[t.status]||0)+1;return e},[x]);return(0,G.jsx)(`div`,{className:`rp-full`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,G.jsxs)(`div`,{className:`rp-full-box`,children:[(0,G.jsxs)(`div`,{className:`rp-full-head`,children:[(0,G.jsxs)(`div`,{className:`rp-full-title`,children:[`导入导出`,(0,G.jsx)(`span`,{className:`muted`,children:`以全局 key 为身份 · 不含本地路径 · 逐条选择与冲突方案`})]}),(0,G.jsxs)(`div`,{className:`rp-full-tabs`,children:[(0,G.jsx)(`button`,{className:`rp-tab`+(c===`import`?` on`:``),onClick:()=>u(`import`),children:`导入`}),(0,G.jsx)(`button`,{className:`rp-tab`+(c===`export`?` on`:``),onClick:()=>u(`export`),children:`导出`})]}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:t,children:`关闭`})]}),c===`export`?(0,G.jsxs)(`div`,{className:`rp-full-body`,children:[(0,G.jsxs)(`div`,{className:`rp-full-col`,children:[(0,G.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,G.jsx)(`span`,{children:`导出范围`}),(0,G.jsxs)(`span`,{className:`acts`,children:[(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>z(!0),children:`全选仓库`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>z(!1),children:`全不选`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:V,children:`反选`})]})]}),(0,G.jsxs)(`div`,{className:`rp-full-sel`,children:[I.map(e=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!d[e.key],onChange:t=>f(n=>({...n,[e.key]:t.target.checked}))}),(0,G.jsx)(`span`,{className:e.type===`ref`?`rp-full-tag-ref`:``,children:e.name}),(0,G.jsx)(`span`,{className:`muted rp-full-key`,title:e.key,children:e.key})]},e.key)),I.length?null:(0,G.jsx)(`div`,{className:`muted`,children:`还没有仓库`})]}),(0,G.jsxs)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:[(0,G.jsx)(`span`,{children:`看板`}),(0,G.jsxs)(`span`,{className:`acts`,children:[(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>B(!0),children:`全选`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>B(!1),children:`全不选`})]})]}),(0,G.jsxs)(`div`,{className:`rp-full-sel`,children:[(i||[]).map(e=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!p[e.name],onChange:t=>m(n=>({...n,[e.name]:t.target.checked}))}),(0,G.jsx)(`span`,{children:e.name})]},e.name)),i?.length?null:(0,G.jsx)(`div`,{className:`muted`,children:`还没有看板`})]}),(0,G.jsxs)(`label`,{className:`rp-pick-item`,style:{marginTop:10},children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked)}),(0,G.jsx)(`span`,{children:`不带未分组的仓库`})]}),(0,G.jsxs)(`div`,{className:`form-acts`,children:[(0,G.jsx)(`button`,{className:`btn`,onClick:H,children:`生成布局`}),(0,G.jsx)(`button`,{className:`btn ghost`,disabled:!_,onClick:U,children:`下载 JSON`})]})]}),(0,G.jsxs)(`div`,{className:`rp-full-col`,children:[(0,G.jsx)(`div`,{className:`rp-full-colhead`,children:(0,G.jsx)(`span`,{children:`导出结果`})}),(0,G.jsx)(`textarea`,{className:`rp-full-out`,readOnly:!0,value:_,spellCheck:`false`,placeholder:`点「生成布局」后在这里预览 JSON(可直接复制或下载)`})]})]}):(0,G.jsxs)(`div`,{className:`rp-full-body`,children:[(0,G.jsxs)(`div`,{className:`rp-full-col`,children:[(0,G.jsx)(`div`,{className:`rp-full-colhead`,children:(0,G.jsx)(`span`,{children:`导入来源`})}),(0,G.jsx)(`input`,{type:`file`,accept:`.json,application/json`,onChange:te}),(0,G.jsx)(`textarea`,{className:`rp-full-input`,rows:7,spellCheck:`false`,placeholder:`粘贴布局 JSON,或选一个 .json 文件`,value:y,onChange:e=>{b(e.target.value),S(null)}}),(0,G.jsx)(`div`,{className:`form-hint`,children:`每个仓库的 key 必须有:文件里已写 key 就直接用;只写了远程地址就按 host/owner/repo 归一化; 两样都没有会在差异检查阶段直接报错(不会按名字猜 key)。要改 key 就改上面的 JSON 再检查。`}),(0,G.jsx)(`div`,{className:`form-acts`,children:(0,G.jsx)(`button`,{className:`btn`,disabled:!y.trim()||P,onClick:ne,children:`差异检查`})}),x?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:12},children:(0,G.jsx)(`span`,{children:`冲突方案`})}),(0,G.jsx)(`div`,{className:`rp-strategy`,children:[[`ours`,`保留本地`,`本地已有的不动,只新建缺失的`],[`overwrite`,`强制覆盖`,`用导入文件覆盖本地字段(key 不变)`],[`duplicate`,`另存新 key`,`为冲突项新建 key-import-1/2/3,两条并存`]].map(([e,t,n])=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,title:n,children:[(0,G.jsx)(`input`,{type:`radio`,name:`strategy`,checked:D===e,onChange:()=>O(e)}),(0,G.jsx)(`span`,{children:t})]},e))}),(0,G.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:(0,G.jsx)(`span`,{children:`克隆`})}),(0,G.jsxs)(`select`,{value:ee,onChange:e=>k(e.target.value),children:[(0,G.jsx)(`option`,{value:`none`,children:`不克隆,只登记`}),(0,G.jsx)(`option`,{value:`ref`,children:`克隆参考仓库`}),(0,G.jsx)(`option`,{value:`dev`,children:`克隆开发仓库`}),(0,G.jsx)(`option`,{value:`all`,children:`全部克隆`})]}),(0,G.jsx)(`div`,{className:`form-acts`,children:(0,G.jsxs)(`button`,{className:`btn`,disabled:P,onClick:re,children:[`执行导入(已选 `,Object.values(C).filter(Boolean).length,`)`]})})]}):null,M?(0,G.jsxs)(`div`,{className:`rp-import-result`,children:[(0,G.jsxs)(`div`,{children:[`新建 `,M.created.length,` · 覆盖 `,M.updated.length,` · 另存 `,M.duplicated.length,` · 跳过 `,M.skipped.length]}),(0,G.jsxs)(`div`,{className:`muted`,children:[`看板 新建 `,M.boardsCreated,` / 合并 `,M.boardsMerged,` · 参考关系 `,M.links]}),M.cloned.length?(0,G.jsxs)(`div`,{children:[`克隆 `,M.cloned.length,` 个`]}):null,M.unmatched.length?(0,G.jsxs)(`div`,{className:`rp-layout-warn`,children:[`本地未拥有 `,M.unmatched.length,` 条(见下方差异表)`]}):null]}):null]}),(0,G.jsx)(`div`,{className:`rp-full-col rp-full-col-wide`,children:x?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,G.jsxs)(`span`,{children:[`差异(新增 `,se.new,` · 有差异 `,se.changed,` · 一致 `,se.same,x.summary.missing?` · 本地未拥有 ${x.summary.missing}`:``,`)`]}),(0,G.jsxs)(`span`,{className:`acts`,children:[(0,G.jsx)(`button`,{className:`rp-chip`+(A===``?` on`:``),onClick:()=>j(``),children:`全部`}),(0,G.jsx)(`button`,{className:`rp-chip`+(A===`new`?` on`:``),onClick:()=>j(`new`),children:`新增`}),(0,G.jsx)(`button`,{className:`rp-chip`+(A===`changed`?` on`:``),onClick:()=>j(`changed`),children:`有差异`}),(0,G.jsx)(`button`,{className:`rp-chip`+(A===`same`?` on`:``),onClick:()=>j(`same`),children:`一致`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>oe(!0),children:`全选`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>oe(!1),children:`全不选`})]})]}),(0,G.jsx)(`div`,{className:`rp-diff-table-wrap`,children:(0,G.jsxs)(`table`,{className:`rp-diff-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{style:{width:`32px`}}),(0,G.jsx)(`th`,{style:{width:`90px`},children:`状态`}),(0,G.jsx)(`th`,{children:`仓库 key`}),(0,G.jsx)(`th`,{children:`差异字段`})]})}),(0,G.jsxs)(`tbody`,{children:[q.map(e=>(0,G.jsxs)(`tr`,{className:`rp-diff-row `+(K[e.status]?.cls??``),children:[(0,G.jsx)(`td`,{children:(0,G.jsx)(`input`,{type:`checkbox`,disabled:e.status===`same`,checked:!!C[e.key],onChange:t=>w(n=>({...n,[e.key]:t.target.checked}))})}),(0,G.jsx)(`td`,{children:(0,G.jsx)(`span`,{className:`rp-status `+(K[e.status]?.cls??``),children:K[e.status]?.label})}),(0,G.jsxs)(`td`,{className:`mono rp-diff-key`,children:[e.key,e.status===`new`&&e.canClone?(0,G.jsx)(`span`,{className:`rp-can-clone`,title:`导入时可克隆`,children:`可克隆`}):null,e.status===`new`&&e.canClone?(0,G.jsx)(`button`,{className:`btn small ghost rp-clone-btn`,title:`现在就克隆到本地(用这个 key 登记 → 组里的占位自动补齐)`,disabled:P,onClick:()=>ae(e.key,e.incoming?.remote||``),children:`克隆到本地`}):null]}),(0,G.jsx)(`td`,{className:`rp-diff-fields`,children:e.fields.length?e.fields.map(e=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`b`,{children:e.field}),`: `,(0,G.jsx)(`span`,{className:`rp-was`,children:JSON.stringify(e.local)}),` → `,(0,G.jsx)(`span`,{className:`rp-now`,children:JSON.stringify(e.incoming)})]},e.field)):(0,G.jsx)(`span`,{className:`muted`,children:`—`})})]},e.key)),x.missing.map(e=>(0,G.jsxs)(`tr`,{className:`rp-diff-row missing`,children:[(0,G.jsx)(`td`,{}),(0,G.jsx)(`td`,{children:(0,G.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`})}),(0,G.jsx)(`td`,{className:`mono rp-diff-key`,children:e}),(0,G.jsx)(`td`,{className:`rp-diff-fields muted`,children:`文件里被引用,但文件与本地都没有定义`})]},`miss-`+e))]})]})}),x.boards.length?(0,G.jsxs)(`div`,{className:`rp-diff-boards`,children:[(0,G.jsx)(`div`,{className:`rp-full-colhead`,children:(0,G.jsx)(`span`,{children:`看板`})}),x.boards.map(e=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!T[e.key],onChange:t=>E(n=>({...n,[e.key]:t.target.checked}))}),(0,G.jsx)(`span`,{className:`rp-status `+(K[e.status]?.cls??``),children:K[e.status]?.label}),(0,G.jsx)(`span`,{children:e.key}),(0,G.jsxs)(`span`,{className:`muted`,children:[`(`,e.incoming.repos.length,` 个成员`,e.missingMembers?.length?`,本地未拥有 ${e.missingMembers.length}`:``,`)`]})]},e.key)),x.boards.flatMap(e=>e.missingMembers||[]).map(e=>(0,G.jsxs)(`div`,{className:`rp-missing-item`,children:[(0,G.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`}),(0,G.jsx)(`span`,{className:`mono rp-missing-key`,children:e.key}),e.remote?(0,G.jsx)(`span`,{className:`muted rp-missing-remote`,title:e.remote,children:e.remote}):null,e.clonable?(0,G.jsx)(`button`,{className:`btn small`,disabled:P,onClick:()=>ae(e.key,e.remote),children:`克隆到本地`}):(0,G.jsx)(`span`,{className:`muted`,title:`没有远程地址 —— 自行创建后用 repo key set 指定同一个 key`,children:`需手工创建`})]},e.key))]}):null]}):(0,G.jsx)(`div`,{className:`muted rp-full-empty`,children:`粘贴或选择一份布局 JSON,点「差异检查」后在这里逐条查看与勾选。`})})]})]})})}var q=10;function ae({repo:e,onClose:t,onSaved:n}){let r=R(),i=a(),o=e.getLoop&&typeof e.getLoop==`object`?e.getLoop:null,[s,l]=(0,W.useState)(!!(o&&o.enabled)),[u,d]=(0,W.useState)(o&&o.waitMinutes!==void 0&&o.waitMinutes!==null?String(o.waitMinutes):String(q)),[p,m]=(0,W.useState)(!1),h=e=>{let t=String(e??``).trim();if(t===``)return q;let n=Number(t);return Number.isFinite(n)&&n>=0?Math.min(Math.floor(n),600):q},g=async t=>{m(!0);try{let a=t&&t.enabled!==void 0?t.enabled:s;await f(e.id,{"get-loop":a?`on`:`off`,...a?{"get-loop-minutes":h(u)}:{}});let o=h(u);i(a?`已保存「${e.name}」的持续 get 设置(${o>0?`${o} 分钟阻塞窗口`:`不阻塞,没活立即返回`})`:`已关闭「${e.name}」的持续 get`),r.refreshRepos&&r.refreshRepos(),n&&n()}catch(e){i(String(e.message||e))}finally{m(!1)}},_=async e=>{l(e),await g({enabled:e})};return(0,G.jsx)(c,{title:`持续 get · ${e.name}`,onClose:t,size:`md`,children:(0,G.jsxs)(`div`,{className:`rp-gl`,children:[(0,G.jsxs)(`div`,{className:`rp-gl-head`,children:[(0,G.jsxs)(`div`,{className:`rp-gl-title`,children:[(0,G.jsx)(`span`,{className:`rp-gl-name`,children:`持续 get`}),(0,G.jsx)(`span`,{className:`rp-gl-desc`,children:`无任务时阻塞等待新任务回填(waitgoal)`})]}),(0,G.jsxs)(`button`,{className:`toggle`+(s?` on`:``),onClick:()=>_(!s),disabled:p,children:[(0,G.jsx)(`span`,{className:`dot`}),s?`开`:`关`]})]}),s&&(0,G.jsxs)(`div`,{className:`rp-gl-body`,children:[(0,G.jsxs)(`div`,{className:`rp-gl-row`,children:[(0,G.jsx)(`span`,{children:`阻塞窗口`}),(0,G.jsxs)(`span`,{className:`rp-gl-unit`,children:[(0,G.jsx)(`input`,{className:`rp-gl-min`,value:u,onChange:e=>d(e.target.value),inputMode:`numeric`,title:`0 = 不阻塞:没任务时 get 立即返回 timeout`}),`分钟`]})]}),(0,G.jsx)(`div`,{className:`rp-gl-note`,children:`这里只决定没有任务时 get 最多阻塞多久(0 = 不阻塞,立即返回 timeout)。领到任务后那段「继续 get 直到 timeout」的提示词是全局的,只有一份:要改文案去 设置 → 提示词模板 → 持续 get。`}),(0,G.jsxs)(`div`,{className:`rp-gl-acts`,children:[(0,G.jsx)(`span`,{className:`spacer`}),(0,G.jsx)(z,{variant:`primary`,disabled:p,onClick:()=>g(),children:`保存持续 get 设置`})]})]})]})})}var oe=o(`board`),se=o(`repo`),ce=o(`repo-ref`),le=o(`doc`),ue=o(`docs`),de=o(`search`),fe=o(`plus`),pe=o(`refresh`),me=o(`open`),J=o(`chevron-down`),he=o(`check`);o(`x`);var ge=o(`users`);o(`folder`);var _e=o(`unlink`),ve=o(`overview`),ye=o(`edit`),be=o(`trash`),Y=o(`link`);function xe({path:e}){let t=String(e||``),n=t.replace(/\\/g,`/`).lastIndexOf(`/`);return n<0?(0,G.jsx)(m,{text:t,title:void 0,children:t}):(0,G.jsxs)(m,{text:t,title:`点击复制完整路径`,children:[(0,G.jsx)(`span`,{className:`anc`,children:t.slice(0,n)}),t.slice(n)]})}function Se({docs:e,onOpen:t}){let n=e&&e.main,r=e&&e.links||[],i=+!!n+r.length,a=n&&n.exists?[n.title,n.summary&&`摘要:${n.summary}`].filter(Boolean).join(`
1
+ import{c as e,d as t,f as n,h as r,i,l as a,o,r as s,t as c,u as l}from"./popup-DZ2Khv2c.js";import{r as u}from"./workspace-DojQ3RP4.js";import{C as d,D as f,E as p,O as m,S as h,T as g,_,a as v,b as y,c as b,d as x,f as S,g as C,h as w,i as T,l as E,m as D,n as O,o as ee,p as k,r as A,s as j,t as M,u as N,v as P,w as F,x as I,y as L}from"./repo-form-modal-Dg3hJWUV.js";import{n as R}from"./app-context-BqCBcDsx.js";import{t as z}from"./button-3JlUeln_.js";import{i as B,n as V}from"./doc-DRSKD0Re.js";import{n as H,t as U}from"./list-filter-CWxiOSg_.js";import{t as te}from"./route-crumb-C4DgkJ8G.js";import{t as ne}from"./bar-Dc5Tq1eE.js";import{t as re}from"./member-picker-BZgE3HGb.js";var W=r(n(),1),G=t(),K={new:{label:`新增`,cls:`new`},changed:{label:`有差异`,cls:`changed`},same:{label:`一致`,cls:`same`}};function ie({onClose:t,onChanged:n,repos:r,boards:i}){let o=e(),s=a(),[c,u]=(0,W.useState)(`import`),[d,f]=(0,W.useState)({}),[p,m]=(0,W.useState)({}),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(``),[y,b]=(0,W.useState)(``),[x,S]=(0,W.useState)(null),[C,w]=(0,W.useState)({}),[T,E]=(0,W.useState)({}),[D,O]=(0,W.useState)(`ours`),[ee,k]=(0,W.useState)(`none`),[A,j]=(0,W.useState)(``),[M,N]=(0,W.useState)(null),[P,F]=(0,W.useState)(!1),I=(0,W.useMemo)(()=>r||[],[r]),L=(0,W.useMemo)(()=>I.map(e=>e.key),[I]),R=(0,W.useMemo)(()=>(i||[]).map(e=>e.name),[i]),z=e=>{let t={};for(let n of L)t[n]=e;f(t)},B=e=>{let t={};for(let n of R)t[n]=e;m(t)},V=()=>{let e={};for(let t of L)e[t]=!d[t];f(e)},H=()=>o(async()=>{let e=Object.keys(d).filter(e=>d[e]),t=Object.keys(p).filter(e=>p[e]),n={repos:e.length&&e.length!==L.length?e:void 0,boards:t.length&&t.length!==R.length?t.map(e=>`board/${e}`):void 0,noUnassigned:h},r=new URLSearchParams;n.repos?.length&&r.set(`repos`,n.repos.join(`,`)),n.boards?.length&&r.set(`boards`,n.boards.join(`,`)),h&&r.set(`no-unassigned`,`1`);let i=await l(`/api/repos/export`+(r.toString()?`?`+r:``));v(JSON.stringify(i,null,2)),s(`已生成布局:${i.repos.length} 个仓库 / ${i.boards.length} 个看板`)}),U=()=>{if(!_)return;let e=new Blob([_],{type:`application/json`}),t=document.createElement(`a`);t.href=URL.createObjectURL(e),t.download=`nx-kv-layout-${new Date().toISOString().slice(0,10)}.json`,t.click(),URL.revokeObjectURL(t.href)},te=async e=>{let t=e.target.files?.[0];t&&(b(await t.text()),S(null),N(null))},ne=()=>o(async()=>{if(y.trim()){F(!0);try{let e=await l(`/api/repos/import/diff`,{method:`POST`,body:{json:y}});S(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;w(t);let n={};for(let t of e.boards)n[t.key]=t.status!==`same`;E(n),N(null),s(`差异:新增 ${e.summary.new} · 有差异 ${e.summary.changed} · 一致 ${e.summary.same} · 本地未拥有 ${e.summary.missing}`)}finally{F(!1)}}}),re=()=>o(async()=>{let e=Object.keys(C).filter(e=>C[e]),t=Object.keys(T).filter(e=>T[e]);F(!0);try{let r=await l(`/api/repos/import`,{method:`POST`,body:{json:y,strategy:D,clone:ee,selection:e.length?e:void 0,boards:t.length?t:void 0}});N(r),s(`导入完成:新建 ${r.created.length} · 覆盖 ${r.updated.length} · 另存 ${r.duplicated.length}`),await ie(),n&&await n()}finally{F(!1)}}),ie=(0,W.useCallback)(async()=>{try{let e=await l(`/api/repos/import/diff`,{method:`POST`,body:{json:y}});S(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;w(t)}catch{}},[y]),q=(0,W.useMemo)(()=>x?A?x.repos.filter(e=>e.status===A):x.repos:[],[x,A]),ae=(e,t)=>o(async()=>{if(t){F(!0);try{await l(`/api/repos/clone`,{method:`POST`,body:{remote:t,key:e,type:`ref`,depth:1}}),s(`已克隆: ${e}`),await ie(),n&&await n()}finally{F(!1)}}}),oe=e=>{let t={...C};for(let n of q)t[n.key]=e;w(t)};(0,W.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopImmediatePropagation(),t())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]);let se=(0,W.useMemo)(()=>{let e={new:0,changed:0,same:0};if(!x)return e;for(let t of x.repos)e[t.status]=(e[t.status]||0)+1;return e},[x]);return(0,G.jsx)(`div`,{className:`rp-full`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,G.jsxs)(`div`,{className:`rp-full-box`,children:[(0,G.jsxs)(`div`,{className:`rp-full-head`,children:[(0,G.jsxs)(`div`,{className:`rp-full-title`,children:[`导入导出`,(0,G.jsx)(`span`,{className:`muted`,children:`以全局 key 为身份 · 不含本地路径 · 逐条选择与冲突方案`})]}),(0,G.jsxs)(`div`,{className:`rp-full-tabs`,children:[(0,G.jsx)(`button`,{className:`rp-tab`+(c===`import`?` on`:``),onClick:()=>u(`import`),children:`导入`}),(0,G.jsx)(`button`,{className:`rp-tab`+(c===`export`?` on`:``),onClick:()=>u(`export`),children:`导出`})]}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:t,children:`关闭`})]}),c===`export`?(0,G.jsxs)(`div`,{className:`rp-full-body`,children:[(0,G.jsxs)(`div`,{className:`rp-full-col`,children:[(0,G.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,G.jsx)(`span`,{children:`导出范围`}),(0,G.jsxs)(`span`,{className:`acts`,children:[(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>z(!0),children:`全选仓库`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>z(!1),children:`全不选`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:V,children:`反选`})]})]}),(0,G.jsxs)(`div`,{className:`rp-full-sel`,children:[I.map(e=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!d[e.key],onChange:t=>f(n=>({...n,[e.key]:t.target.checked}))}),(0,G.jsx)(`span`,{className:e.type===`ref`?`rp-full-tag-ref`:``,children:e.name}),(0,G.jsx)(`span`,{className:`muted rp-full-key`,title:e.key,children:e.key})]},e.key)),I.length?null:(0,G.jsx)(`div`,{className:`muted`,children:`还没有仓库`})]}),(0,G.jsxs)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:[(0,G.jsx)(`span`,{children:`看板`}),(0,G.jsxs)(`span`,{className:`acts`,children:[(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>B(!0),children:`全选`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>B(!1),children:`全不选`})]})]}),(0,G.jsxs)(`div`,{className:`rp-full-sel`,children:[(i||[]).map(e=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!p[e.name],onChange:t=>m(n=>({...n,[e.name]:t.target.checked}))}),(0,G.jsx)(`span`,{children:e.name})]},e.name)),i?.length?null:(0,G.jsx)(`div`,{className:`muted`,children:`还没有看板`})]}),(0,G.jsxs)(`label`,{className:`rp-pick-item`,style:{marginTop:10},children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked)}),(0,G.jsx)(`span`,{children:`不带未分组的仓库`})]}),(0,G.jsxs)(`div`,{className:`form-acts`,children:[(0,G.jsx)(`button`,{className:`btn`,onClick:H,children:`生成布局`}),(0,G.jsx)(`button`,{className:`btn ghost`,disabled:!_,onClick:U,children:`下载 JSON`})]})]}),(0,G.jsxs)(`div`,{className:`rp-full-col`,children:[(0,G.jsx)(`div`,{className:`rp-full-colhead`,children:(0,G.jsx)(`span`,{children:`导出结果`})}),(0,G.jsx)(`textarea`,{className:`rp-full-out`,readOnly:!0,value:_,spellCheck:`false`,placeholder:`点「生成布局」后在这里预览 JSON(可直接复制或下载)`})]})]}):(0,G.jsxs)(`div`,{className:`rp-full-body`,children:[(0,G.jsxs)(`div`,{className:`rp-full-col`,children:[(0,G.jsx)(`div`,{className:`rp-full-colhead`,children:(0,G.jsx)(`span`,{children:`导入来源`})}),(0,G.jsx)(`input`,{type:`file`,accept:`.json,application/json`,onChange:te}),(0,G.jsx)(`textarea`,{className:`rp-full-input`,rows:7,spellCheck:`false`,placeholder:`粘贴布局 JSON,或选一个 .json 文件`,value:y,onChange:e=>{b(e.target.value),S(null)}}),(0,G.jsx)(`div`,{className:`form-hint`,children:`每个仓库的 key 必须有:文件里已写 key 就直接用;只写了远程地址就按 host/owner/repo 归一化; 两样都没有会在差异检查阶段直接报错(不会按名字猜 key)。要改 key 就改上面的 JSON 再检查。`}),(0,G.jsx)(`div`,{className:`form-acts`,children:(0,G.jsx)(`button`,{className:`btn`,disabled:!y.trim()||P,onClick:ne,children:`差异检查`})}),x?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:12},children:(0,G.jsx)(`span`,{children:`冲突方案`})}),(0,G.jsx)(`div`,{className:`rp-strategy`,children:[[`ours`,`保留本地`,`本地已有的不动,只新建缺失的`],[`overwrite`,`强制覆盖`,`用导入文件覆盖本地字段(key 不变)`],[`duplicate`,`另存新 key`,`为冲突项新建 key-import-1/2/3,两条并存`]].map(([e,t,n])=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,title:n,children:[(0,G.jsx)(`input`,{type:`radio`,name:`strategy`,checked:D===e,onChange:()=>O(e)}),(0,G.jsx)(`span`,{children:t})]},e))}),(0,G.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:(0,G.jsx)(`span`,{children:`克隆`})}),(0,G.jsxs)(`select`,{value:ee,onChange:e=>k(e.target.value),children:[(0,G.jsx)(`option`,{value:`none`,children:`不克隆,只登记`}),(0,G.jsx)(`option`,{value:`ref`,children:`克隆参考仓库`}),(0,G.jsx)(`option`,{value:`dev`,children:`克隆开发仓库`}),(0,G.jsx)(`option`,{value:`all`,children:`全部克隆`})]}),(0,G.jsx)(`div`,{className:`form-acts`,children:(0,G.jsxs)(`button`,{className:`btn`,disabled:P,onClick:re,children:[`执行导入(已选 `,Object.values(C).filter(Boolean).length,`)`]})})]}):null,M?(0,G.jsxs)(`div`,{className:`rp-import-result`,children:[(0,G.jsxs)(`div`,{children:[`新建 `,M.created.length,` · 覆盖 `,M.updated.length,` · 另存 `,M.duplicated.length,` · 跳过 `,M.skipped.length]}),(0,G.jsxs)(`div`,{className:`muted`,children:[`看板 新建 `,M.boardsCreated,` / 合并 `,M.boardsMerged,` · 参考关系 `,M.links]}),M.cloned.length?(0,G.jsxs)(`div`,{children:[`克隆 `,M.cloned.length,` 个`]}):null,M.unmatched.length?(0,G.jsxs)(`div`,{className:`rp-layout-warn`,children:[`本地未拥有 `,M.unmatched.length,` 条(见下方差异表)`]}):null]}):null]}),(0,G.jsx)(`div`,{className:`rp-full-col rp-full-col-wide`,children:x?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,G.jsxs)(`span`,{children:[`差异(新增 `,se.new,` · 有差异 `,se.changed,` · 一致 `,se.same,x.summary.missing?` · 本地未拥有 ${x.summary.missing}`:``,`)`]}),(0,G.jsxs)(`span`,{className:`acts`,children:[(0,G.jsx)(`button`,{className:`rp-chip`+(A===``?` on`:``),onClick:()=>j(``),children:`全部`}),(0,G.jsx)(`button`,{className:`rp-chip`+(A===`new`?` on`:``),onClick:()=>j(`new`),children:`新增`}),(0,G.jsx)(`button`,{className:`rp-chip`+(A===`changed`?` on`:``),onClick:()=>j(`changed`),children:`有差异`}),(0,G.jsx)(`button`,{className:`rp-chip`+(A===`same`?` on`:``),onClick:()=>j(`same`),children:`一致`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>oe(!0),children:`全选`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>oe(!1),children:`全不选`})]})]}),(0,G.jsx)(`div`,{className:`rp-diff-table-wrap`,children:(0,G.jsxs)(`table`,{className:`rp-diff-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{style:{width:`32px`}}),(0,G.jsx)(`th`,{style:{width:`90px`},children:`状态`}),(0,G.jsx)(`th`,{children:`仓库 key`}),(0,G.jsx)(`th`,{children:`差异字段`})]})}),(0,G.jsxs)(`tbody`,{children:[q.map(e=>(0,G.jsxs)(`tr`,{className:`rp-diff-row `+(K[e.status]?.cls??``),children:[(0,G.jsx)(`td`,{children:(0,G.jsx)(`input`,{type:`checkbox`,disabled:e.status===`same`,checked:!!C[e.key],onChange:t=>w(n=>({...n,[e.key]:t.target.checked}))})}),(0,G.jsx)(`td`,{children:(0,G.jsx)(`span`,{className:`rp-status `+(K[e.status]?.cls??``),children:K[e.status]?.label})}),(0,G.jsxs)(`td`,{className:`mono rp-diff-key`,children:[e.key,e.status===`new`&&e.canClone?(0,G.jsx)(`span`,{className:`rp-can-clone`,title:`导入时可克隆`,children:`可克隆`}):null,e.status===`new`&&e.canClone?(0,G.jsx)(`button`,{className:`btn small ghost rp-clone-btn`,title:`现在就克隆到本地(用这个 key 登记 → 组里的占位自动补齐)`,disabled:P,onClick:()=>ae(e.key,e.incoming?.remote||``),children:`克隆到本地`}):null]}),(0,G.jsx)(`td`,{className:`rp-diff-fields`,children:e.fields.length?e.fields.map(e=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`b`,{children:e.field}),`: `,(0,G.jsx)(`span`,{className:`rp-was`,children:JSON.stringify(e.local)}),` → `,(0,G.jsx)(`span`,{className:`rp-now`,children:JSON.stringify(e.incoming)})]},e.field)):(0,G.jsx)(`span`,{className:`muted`,children:`—`})})]},e.key)),x.missing.map(e=>(0,G.jsxs)(`tr`,{className:`rp-diff-row missing`,children:[(0,G.jsx)(`td`,{}),(0,G.jsx)(`td`,{children:(0,G.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`})}),(0,G.jsx)(`td`,{className:`mono rp-diff-key`,children:e}),(0,G.jsx)(`td`,{className:`rp-diff-fields muted`,children:`文件里被引用,但文件与本地都没有定义`})]},`miss-`+e))]})]})}),x.boards.length?(0,G.jsxs)(`div`,{className:`rp-diff-boards`,children:[(0,G.jsx)(`div`,{className:`rp-full-colhead`,children:(0,G.jsx)(`span`,{children:`看板`})}),x.boards.map(e=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!T[e.key],onChange:t=>E(n=>({...n,[e.key]:t.target.checked}))}),(0,G.jsx)(`span`,{className:`rp-status `+(K[e.status]?.cls??``),children:K[e.status]?.label}),(0,G.jsx)(`span`,{children:e.key}),(0,G.jsxs)(`span`,{className:`muted`,children:[`(`,e.incoming.repos.length,` 个成员`,e.missingMembers?.length?`,本地未拥有 ${e.missingMembers.length}`:``,`)`]})]},e.key)),x.boards.flatMap(e=>e.missingMembers||[]).map(e=>(0,G.jsxs)(`div`,{className:`rp-missing-item`,children:[(0,G.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`}),(0,G.jsx)(`span`,{className:`mono rp-missing-key`,children:e.key}),e.remote?(0,G.jsx)(`span`,{className:`muted rp-missing-remote`,title:e.remote,children:e.remote}):null,e.clonable?(0,G.jsx)(`button`,{className:`btn small`,disabled:P,onClick:()=>ae(e.key,e.remote),children:`克隆到本地`}):(0,G.jsx)(`span`,{className:`muted`,title:`没有远程地址 —— 自行创建后用 repo key set 指定同一个 key`,children:`需手工创建`})]},e.key))]}):null]}):(0,G.jsx)(`div`,{className:`muted rp-full-empty`,children:`粘贴或选择一份布局 JSON,点「差异检查」后在这里逐条查看与勾选。`})})]})]})})}var q=10;function ae({repo:e,onClose:t,onSaved:n}){let r=R(),i=a(),o=e.getLoop&&typeof e.getLoop==`object`?e.getLoop:null,[s,l]=(0,W.useState)(!!(o&&o.enabled)),[u,d]=(0,W.useState)(o&&o.waitMinutes!==void 0&&o.waitMinutes!==null?String(o.waitMinutes):String(q)),[p,m]=(0,W.useState)(!1),h=e=>{let t=String(e??``).trim();if(t===``)return q;let n=Number(t);return Number.isFinite(n)&&n>=0?Math.min(Math.floor(n),600):q},g=async t=>{m(!0);try{let a=t&&t.enabled!==void 0?t.enabled:s;await f(e.id,{"get-loop":a?`on`:`off`,...a?{"get-loop-minutes":h(u)}:{}});let o=h(u);i(a?`已保存「${e.name}」的持续 get 设置(${o>0?`${o} 分钟阻塞窗口`:`不阻塞,没活立即返回`})`:`已关闭「${e.name}」的持续 get`),r.refreshRepos&&r.refreshRepos(),n&&n()}catch(e){i(String(e.message||e))}finally{m(!1)}},_=async e=>{l(e),await g({enabled:e})};return(0,G.jsx)(c,{title:`持续 get · ${e.name}`,onClose:t,size:`md`,children:(0,G.jsxs)(`div`,{className:`rp-gl`,children:[(0,G.jsxs)(`div`,{className:`rp-gl-head`,children:[(0,G.jsxs)(`div`,{className:`rp-gl-title`,children:[(0,G.jsx)(`span`,{className:`rp-gl-name`,children:`持续 get`}),(0,G.jsx)(`span`,{className:`rp-gl-desc`,children:`无任务时阻塞等待新任务回填(waitgoal)`})]}),(0,G.jsxs)(`button`,{className:`toggle`+(s?` on`:``),onClick:()=>_(!s),disabled:p,children:[(0,G.jsx)(`span`,{className:`dot`}),s?`开`:`关`]})]}),s&&(0,G.jsxs)(`div`,{className:`rp-gl-body`,children:[(0,G.jsxs)(`div`,{className:`rp-gl-row`,children:[(0,G.jsx)(`span`,{children:`阻塞窗口`}),(0,G.jsxs)(`span`,{className:`rp-gl-unit`,children:[(0,G.jsx)(`input`,{className:`rp-gl-min`,value:u,onChange:e=>d(e.target.value),inputMode:`numeric`,title:`0 = 不阻塞:没任务时 get 立即返回 timeout`}),`分钟`]})]}),(0,G.jsx)(`div`,{className:`rp-gl-note`,children:`这里只决定没有任务时 get 最多阻塞多久(0 = 不阻塞,立即返回 timeout)。领到任务后那段「继续 get 直到 timeout」的提示词是全局的,只有一份:要改文案去 设置 → 提示词模板 → 持续 get。`}),(0,G.jsxs)(`div`,{className:`rp-gl-acts`,children:[(0,G.jsx)(`span`,{className:`spacer`}),(0,G.jsx)(z,{variant:`primary`,disabled:p,onClick:()=>g(),children:`保存持续 get 设置`})]})]})]})})}var oe=o(`board`),se=o(`repo`),ce=o(`repo-ref`),le=o(`doc`),ue=o(`docs`),de=o(`search`),fe=o(`plus`),pe=o(`refresh`),me=o(`open`),J=o(`chevron-down`),he=o(`check`);o(`x`);var ge=o(`users`);o(`folder`);var _e=o(`unlink`),ve=o(`overview`),ye=o(`edit`),be=o(`trash`),Y=o(`link`);function xe({path:e}){let t=String(e||``),n=t.replace(/\\/g,`/`).lastIndexOf(`/`);return n<0?(0,G.jsx)(m,{text:t,title:void 0,children:t}):(0,G.jsxs)(m,{text:t,title:`点击复制完整路径`,children:[(0,G.jsx)(`span`,{className:`anc`,children:t.slice(0,n)}),t.slice(n)]})}function Se({docs:e,onOpen:t}){let n=e&&e.main,r=e&&e.links||[],i=+!!n+r.length,a=n&&n.exists?[n.title,n.summary&&`摘要:${n.summary}`].filter(Boolean).join(`
2
2
  `):`查看完整文档列表(主篇 / 补充 / reference / 组内),可就地编辑`,o=(e,t)=>e.title||e.desc||`第 ${t+1} 篇`,s=[];return n&&n.exists&&s.push({id:`main`,label:o(n,0),kind:`repo`,main:!0,title:n.title||n.summary||``}),r.forEach((e,t)=>{s.push({id:(e.docId||e.refId||`link`)+`:`+t,label:o(e,t),kind:`repo`,title:String(e.title||e.desc||``)})}),(0,G.jsxs)(`div`,{className:`rp-docs-entry`,role:`button`,tabIndex:0,title:a,onClick:t,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&t()},children:[s.length?(0,G.jsx)(B,{items:s,onMore:t}):(0,G.jsx)(`span`,{className:`rp-docs-entry-main ghost`,children:`+ 写项目介绍`}),(0,G.jsx)(`span`,{className:`rp-docs-entry-n`,children:i>0?`${i} 篇 · 查看详情`:`查看详情`})]})}function Ce({chips:e,acts:t}){let[n,r]=(0,W.useState)(!1),i=n?e:e.slice(0,4);return(0,G.jsxs)(G.Fragment,{children:[i.map(e=>(0,G.jsx)(`span`,{className:`rp-link-chip rp-link-chip-repo`,children:(0,G.jsxs)(`button`,{className:`rp-link-chip-main`,title:[`本仓库直接绑定的参考仓库`,`点击跳到这个参考仓库`].join(`
3
3
  `),onClick:()=>t.gotoRefRepo(e.key),children:[(0,G.jsx)(`b`,{children:`自`}),(0,G.jsx)(`span`,{className:`rp-link-chip-name`,children:e.name})]})},e.key)),e.length>4?(0,G.jsx)(`button`,{className:`rp-bind-more`,title:`展开本行全部参考仓库`,onClick:()=>r(e=>!e),children:n?`收起`:`+${e.length-4}`}):null]})}function we({r:e,mode:t,filterBoard:n,refRepoChipsByRepo:r,acts:i}){let a=r.get(e.key)||[];return(0,G.jsxs)(`tr`,{id:`rp-row-`+e.key,children:[(0,G.jsxs)(`td`,{className:`rp-name`,children:[(0,G.jsxs)(`strong`,{children:[e.icon?(0,G.jsx)(`span`,{className:`rp-icon`,"aria-hidden":!0,children:e.icon}):null,e.name,e.getLoop&&e.getLoop.enabled?(0,G.jsx)(`span`,{className:`rp-gl-dot`,title:`持续 get 已开启(${Number(e.getLoop.waitMinutes)>0?`${Number(e.getLoop.waitMinutes)} 分钟阻塞窗口`:`不阻塞,没活立即返回`})`,"aria-label":`持续 get 已开启`}):null]}),(0,G.jsx)(`span`,{className:`mono rp-name-path`,children:(0,G.jsx)(xe,{path:e.path})})]}),(0,G.jsx)(`td`,{className:`rp-cell-docs`,children:(0,G.jsx)(Se,{docs:e.descDocs,onOpen:()=>i.docs(e)})}),t===`group`?null:(0,G.jsx)(`td`,{className:`rp-boards`,children:(e.boards||[]).length?(e.boards||[]).map(e=>(0,G.jsx)(`button`,{type:`button`,className:`rp-board-chip`,title:`跳到分组「${e.name}」`,onClick:()=>i.filter?.(e.id),children:e.name},e.id)):(0,G.jsx)(`span`,{className:`muted rp-refs-none`,children:`—`})}),t===`group`?null:(0,G.jsxs)(`td`,{className:`rp-refs`,children:[a.length?(0,G.jsx)(Ce,{chips:a,acts:i}):(0,G.jsx)(`span`,{className:`muted rp-refs-none`,children:`—`}),(0,G.jsx)(z,{small:!0,className:`rp-ref-bind`,title:`管理这个仓库绑定的参考仓库`,onClick:()=>i.bind(e),children:`绑定`})]}),(0,G.jsxs)(`td`,{className:`rp-acts`+(t===`group`?` rp-acts-wrap`:``),children:[(0,G.jsx)(ne,{kind:`repos-row`,renderers:{edit:()=>(0,G.jsxs)(z,{small:!0,onClick:()=>i.edit(e),children:[(0,G.jsx)(`span`,{className:`rp-btn-ico`,children:(0,G.jsx)(ye,{size:12})}),`编辑`]}),open:()=>(0,G.jsxs)(z,{small:!0,title:`在文件管理器中打开`,onClick:()=>i.open(e),children:[(0,G.jsx)(`span`,{className:`rp-btn-ico`,children:(0,G.jsx)(me,{size:12})}),`打开`]}),del:()=>(0,G.jsxs)(z,{small:!0,danger:!0,onClick:()=>i.del(e),children:[(0,G.jsx)(`span`,{className:`rp-btn-ico`,children:(0,G.jsx)(be,{size:12})}),`删除`]}),getloop:()=>(0,G.jsx)(z,{small:!0,title:`持续 get(waitgoal)配置`,onClick:()=>i.getloop(e),children:(0,G.jsxs)(`span`,{className:`rp-gl-menu-it`,children:[e.getLoop&&e.getLoop.enabled?(0,G.jsx)(`span`,{className:`rp-gl-dot`,"aria-hidden":!0}):null,`持续 get…`]})}),remote:()=>(0,G.jsx)(z,{small:!0,onClick:()=>i.remote(e),children:`对齐 remote`})},actions:{edit:()=>i.edit(e),open:()=>i.open(e),del:()=>i.del(e),getloop:()=>i.getloop(e),remote:()=>i.remote(e)},titles:{getloop:`持续 get(waitgoal)配置`,remote:`key 与远程 git 地址对齐`,del:`删除仓库登记(磁盘文件不受影响)`}}),t===`group`&&n?(0,G.jsxs)(z,{small:!0,danger:!0,title:`只从这个分组摘除(不影响仓库本体与其它分组)`,onClick:()=>i.unbindBoard?.(e,n.id),children:[(0,G.jsx)(`span`,{className:`rp-btn-ico`,children:(0,G.jsx)(_e,{size:12})}),`移出本组`]}):null]})]})}function Te({shown:e,devRepos:t,mode:n,filterBoard:r,refRepoChipsByRepo:i,acts:a,onAddMember:o}){let s=n===`group`;return(0,G.jsx)(`div`,{className:`rp-table-wrap`,id:`rp-repos`,children:(0,G.jsxs)(`table`,{className:`rp-table`+(s?` rp-table-group`:``),children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{scope:`col`,style:{width:s?`30%`:`22%`},children:`仓库`}),(0,G.jsxs)(`th`,{scope:`col`,style:{width:s?`46%`:`30%`},children:[`文档`,(0,G.jsx)(`span`,{className:`rp-th-hint`,children:`主篇标题 · 查看详情打开完整文档列表`})]}),s?null:(0,G.jsx)(`th`,{scope:`col`,style:{width:`14%`},children:`所在组`}),s?null:(0,G.jsx)(`th`,{scope:`col`,style:{width:`16%`},children:`参考仓库`}),(0,G.jsx)(`th`,{scope:`col`,style:{width:`322px`},children:`操作`})]})}),(0,G.jsxs)(`tbody`,{children:[e.map(e=>(0,G.jsx)(we,{r:e,mode:n,filterBoard:r,refRepoChipsByRepo:i,acts:a},e.id)),e.length?null:(0,G.jsx)(`tr`,{children:(0,G.jsx)(`td`,{colSpan:s?3:5,className:`muted rp-empty`,children:s?(0,G.jsxs)(G.Fragment,{children:[`这个分组里还没有仓库`,` `,r?(0,G.jsx)(z,{small:!0,onClick:()=>o(r.id),children:`添加成员`}):null]}):n==="default"?`没有未归组的仓库 —— 所有仓库都至少在一个分组里。`:t.length?`没有匹配的仓库:换个关键字,或切换分组看看。`:`还没有登记开发仓库 —— 点右上「登记仓库」加一条。`})})]})]})})}var Ee=`main`,De=`default`;function Oe({branches:e,value:t,onChange:n,onCreate:r}){let[i,a]=(0,W.useState)(!1),[o,s]=(0,W.useState)(``),c=(0,W.useRef)(null),l=(0,W.useRef)(null),u=e.find(e=>e.id===t)||e[0];(0,W.useEffect)(()=>{if(!i)return;let e=e=>{c.current&&!c.current.contains(e.target)&&a(!1)},t=e=>{e.key===`Escape`&&(e.stopPropagation(),a(!1))};document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t,!0);let n=window.setTimeout(()=>l.current?.focus(),20);return()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t,!0),window.clearTimeout(n)}},[i]);let d=(0,W.useMemo)(()=>{let t=o.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||String(e.key||``).toLowerCase().includes(t)):e},[e,o]),f=e=>{a(!1),s(``),e!==t&&n(e)};return(0,G.jsxs)(`div`,{className:`rp-branch`,ref:c,children:[(0,G.jsxs)(`button`,{type:`button`,className:`rp-branch-btn`+(i?` open`:``),title:`切换分组:main = 全部仓库;其余项 = 项目组`,"aria-haspopup":`listbox`,"aria-expanded":i,onClick:()=>a(e=>!e),children:[u&&u.virtual&&u.id===`main`?(0,G.jsx)(ve,{size:14}):(0,G.jsx)(oe,{size:14}),(0,G.jsx)(`span`,{className:`rp-branch-name`,children:u?u.name:Ee}),(0,G.jsx)(`span`,{className:`rp-branch-btn-caret`,children:(0,G.jsx)(J,{size:13})})]}),i?(0,G.jsxs)(`div`,{className:`rp-branch-pop`,role:`listbox`,"aria-label":`分组`,children:[(0,G.jsxs)(`div`,{className:`rp-branch-filter`,children:[(0,G.jsx)(de,{size:13}),(0,G.jsx)(`input`,{ref:l,value:o,placeholder:`筛选分组…`,"aria-label":`筛选分组`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&d[0]&&f(d[0].id)}})]}),(0,G.jsxs)(`div`,{className:`rp-branch-list`,children:[d.map(e=>(0,G.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e.id===t,className:`rp-branch-item`+(e.id===t?` on`:``),title:e.virtual?e.id===`main`?`全部:所有仓库 / 参考仓库 / 文档`:`没有归组的仓库都落在这里`:`项目组「${e.name}」`,onClick:()=>f(e.id),children:[(0,G.jsx)(`span`,{className:`rp-branch-item-ico`,children:e.virtual&&e.id===`main`?(0,G.jsx)(ve,{size:13}):(0,G.jsx)(oe,{size:13})}),(0,G.jsx)(`span`,{className:`rp-branch-item-name`,children:e.name}),(0,G.jsx)(`span`,{className:`rp-branch-item-n`,children:e.repoCount}),(0,G.jsx)(`span`,{className:`rp-branch-item-check`,children:e.id===t?(0,G.jsx)(he,{size:13}):null})]},e.id)),d.length?null:(0,G.jsx)(`div`,{className:`rp-branch-empty`,children:`没有匹配的分组`})]}),r?(0,G.jsxs)(`button`,{type:`button`,className:`rp-branch-new`,onClick:()=>{a(!1),s(``),r()},children:[(0,G.jsx)(fe,{size:13}),(0,G.jsx)(`span`,{children:`新建分组`})]}):null]}):null]})}function ke(e,t){if(!t||!e)return!1;let n=e.main;return n&&[n.title,n.summary,n.desc].some(e=>e&&String(e).toLowerCase().includes(t))?!0:(e.links||[]).some(e=>[e.title,e.desc].some(e=>e&&String(e).toLowerCase().includes(t)))}function Ae(e,t,n,r,i){let a;if(n){let t=new Set((n.repos||[]).filter(e=>e.present!==!1).map(e=>e.key));a=e.filter(e=>t.has(e.key))}else a=r==="default"?t:e;return i?a.filter(e=>[e.name,e.key,e.path,e.desc].some(e=>e&&String(e).toLowerCase().includes(i))||ke(e.descDocs,i)):a}function je(e,t,n,r){let i;if(t){let n=new Set((t.refs||[]).map(e=>e.id));i=e.filter(e=>n.has(e.key))}else i=n==="default"?[]:e;return r?i.filter(e=>[e.name,e.key,e.remote,e.path,e.desc].some(e=>e&&String(e).toLowerCase().includes(r))):i}function X(e,t){let n=[{id:Ee,name:`main`,repoCount:t.dev,refCount:t.ref,docCount:t.docs||0,virtual:!0}];for(let t of e)n.push({id:t.id,name:t.name,key:t.key||t.id,repoCount:(t.repos||[]).filter(e=>e.present!==!1).length,refCount:(t.refs||[]).length,docCount:Number(t.docCount)||0});return n.push({id:De,name:`default`,repoCount:t.ungrouped,refCount:0,docCount:0,virtual:!0}),n}function Me({repos:e,boardList:t,branch:n,kw:r,docCount:i}){let a=(0,W.useMemo)(()=>e.filter(e=>(e.type||`dev`)!==`ref`),[e]),o=(0,W.useMemo)(()=>e.filter(e=>e.type===`ref`),[e]),s=(0,W.useMemo)(()=>t.find(e=>e.id===n)||null,[t,n]),c=(0,W.useMemo)(()=>a.filter(e=>!(e.boards||[]).length),[a]);return{devRepos:a,refRepos:o,branchBoard:s,ungrouped:c,branches:(0,W.useMemo)(()=>X(t,{dev:a.length,ref:o.length,ungrouped:c.length,docs:i}),[t,a.length,o.length,c.length,i]),groupRefReposByRepo:(0,W.useMemo)(()=>{let e=new Map,n=new Map(o.map(e=>[e.key,e]));for(let r of t){let t=r.key||`board/${r.name}`;for(let i of(r.repos||[]).map(e=>e.key))for(let a of r.refs||[]){let o=n.get(a.id);if(!o)continue;e.has(i)||e.set(i,[]);let s=e.get(i);if(!s)continue;let c=s.find(e=>e.key===o.key);if(c){c.group&&c.group.name!==r.name&&(c.alsoIn=[...c.alsoIn||[],r.name]);continue}s.push({key:o.key,id:o.id,name:o.name,remote:o.remote||``,group:{id:r.id,key:t,name:r.name}})}}return e},[t,o]),refRepoChipsByRepo:(0,W.useMemo)(()=>{let e=new Map,t=new Map(o.map(e=>[e.key,e]));for(let n of a){let r=(n.linked||[]).filter(e=>e&&e.kind===`ref`).map(e=>{let n=t.get(e.id);return n?{key:n.key,name:n.name}:null}).filter(e=>e!==null);e.set(n.key,r)}return e},[a,o]),refRepoBackLinks:(0,W.useMemo)(()=>{let e=new Map;for(let t of a)for(let n of t.linked||[]){if(!n||n.kind!==`ref`)continue;e.has(n.id)||e.set(n.id,[]);let r=e.get(n.id);r&&r.push({repo:t})}return e},[a]),repoRows:(0,W.useMemo)(()=>Ae(a,c,s,n,r),[a,c,s,n,r]),refRows:(0,W.useMemo)(()=>je(o,s,n,r),[o,s,n,r])}}var Z=`nx-kv-repos-branch-v1`;function Ne(){try{let e=localStorage.getItem(Z);return(e==null?null:String(e))||null}catch{return null}}function Pe(e){try{let t=String(e||``);t&&localStorage.setItem(Z,t)}catch{}}function Fe({value:e,onChange:t,placeholder:n,count:r}){return(0,G.jsxs)(`label`,{className:`rp-q`,title:`全局检索:仓库 / 参考仓库 / 文档 一起搜`,children:[(0,G.jsx)(de,{size:13}),(0,G.jsx)(`input`,{value:e,placeholder:n||`搜索仓库 / 参考仓库 / 文档…`,"aria-label":`全局检索`,onChange:e=>t(e.target.value)}),e?(0,G.jsx)(`span`,{className:`rp-q-n`,children:r===void 0?``:r}):null,e?(0,G.jsx)(`button`,{type:`button`,className:`rp-q-x`,title:`清空检索`,onClick:()=>t(``),children:`×`}):null]})}function Ie({tabs:e,value:t,onChange:n}){return(0,G.jsx)(`div`,{className:`rp-blocks`,children:(0,G.jsx)(`div`,{className:`rp-block-tabs`,role:`tablist`,"aria-label":`区块`,children:e.map(e=>(0,G.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===t,disabled:e.disabled,className:`rp-block-tab`+(e.id===t?` on`:``),title:e.tip||`${e.label}(${e.count})`,onClick:()=>{!e.disabled&&e.id!==t&&n(e.id)},children:[(0,G.jsx)(`span`,{className:`rp-block-tab-ico`,children:e.icon}),(0,G.jsx)(`span`,{className:`rp-block-tab-label`,children:e.label}),(0,G.jsx)(`span`,{className:`rp-block-tab-n`,children:e.count})]},e.id))})})}function Le({rows:e,mode:t,group:n,boardList:r,refRepoBackLinks:i,checkOf:a,onSync:o,onOpen:s,onDocs:c,onBind:l,onUnbindGroup:u,onUnbindRepo:d,onGoBind:f,onManage:p}){let h=t===`group`,[g,_]=(0,W.useState)({});return e.length?(0,G.jsx)(`div`,{className:`rp-table-wrap`,id:`rp-refs`,children:(0,G.jsxs)(`table`,{className:`rp-table rp-table-ref`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{scope:`col`,style:{width:`26%`},children:`参考仓库`}),(0,G.jsx)(`th`,{scope:`col`,style:{width:`24%`},children:`远程地址`}),(0,G.jsx)(`th`,{scope:`col`,children:`绑定对象`}),(0,G.jsx)(`th`,{scope:`col`,style:{width:`322px`},children:`操作`})]})}),(0,G.jsx)(`tbody`,{children:e.map(e=>{let t=a.get(e.id),p=r.map(t=>(t.refs||[]).find(t=>t.id===e.key)?{board:t}:null).filter(e=>e!==null),v=i.get(e.key)||[],y=!!g[e.id];return(0,G.jsxs)(`tr`,{id:`rp-refrepo-row-`+e.key,children:[(0,G.jsxs)(`td`,{className:`rp-ref-cell-name`,children:[(0,G.jsxs)(`strong`,{children:[(0,G.jsx)(`span`,{className:`rp-ref-dot`+(t?t.ok?` ok`:` bad`:``),title:t?t.ok?`检查通过`:(t.issues||[]).join(`
4
4
  `):`尚未检查`}),e.name]}),(0,G.jsx)(Se,{docs:e.descDocs,onOpen:()=>c(e)})]}),(0,G.jsx)(`td`,{className:`mono rp-ref-cell-remote`,children:(0,G.jsx)(m,{text:e.remote||``,title:`点击复制远程地址`,children:e.remote||`(无)`})}),(0,G.jsx)(`td`,{className:`rp-ref-cell-links`,children:p.length||v.length?(0,G.jsxs)(G.Fragment,{children:[p.length?(0,G.jsxs)(`div`,{className:`rp-bind-row`,children:[(0,G.jsx)(`span`,{className:`rp-bind-label`,children:`组`}),(y?p:p.slice(0,3)).map(t=>(0,G.jsxs)(`span`,{className:`rp-link-chip rp-link-chip-group`,children:[(0,G.jsxs)(`button`,{className:`rp-link-chip-main`,title:[`点击跳到这个分组`,`组级绑定(组内共享)`].join(`
@@ -0,0 +1,11 @@
1
+ import{a as e,d as t,f as n,h as r,i,l as a,t as o}from"./popup-DZ2Khv2c.js";import{r as s,t as c,v as l}from"./workspace-DojQ3RP4.js";import{n as u}from"./app-context-BqCBcDsx.js";import{A as d,a as f,c as p,d as m,i as h,l as g,m as _,n as v,o as y,r as b,s as x,t as S}from"./md-history-DNtgaIdH.js";import{n as C,r as w,t as T}from"./frontmatter-CN6IlxWU.js";import{t as E}from"./status-tag-8cLH8hl9.js";import{r as D,t as O}from"./md-parse-C9Vd6ejP.js";import{i as k,r as ee,t as A}from"./use-rail-drag-DxIYcszo.js";import{t as j}from"./board-view-BVennxTs.js";import{t as te}from"./route-crumb-C4DgkJ8G.js";import{c as M,d as N,f as P,l as F,m as ne,o as I,p as L,s as re,u as ie}from"./index-Bg0m8gbJ.js";import{a as R,i as z,n as ae,o as B}from"./composer-launch-fp2IzGzQ.js";import{C as V,T as oe,_ as H,a as U,b as W,c as G,d as se,f as ce,g as K,h as le,l as ue,m as de,n as fe,o as pe,p as me,r as q,s as he,t as ge,v as _e,x as ve,y as ye}from"./task-utils-DAPxKm4c.js";var J=r(n(),1),be=/^>\s*\[![A-Za-z][\w-]*\][ \t]*(.*)$/,xe=/完成总结/,Se=/反馈/,Ce=/第\s*(\d+)\s*轮/;function we(e){let t=String(e??``).split(`
2
+ `),n=t[0],r=n?n.match(be):null;if(!r)return null;let i=t.slice(1).map(e=>e.replace(/^>[ \t]?/,``)).filter(e=>e.trim()!==``).join(`
3
+ `);return{title:String(r[1]??``).trim(),body:i}}function Te(e){let t=x(String(e??``));if(!t.length)return[];let n=[],r=null,i=``;return t.forEach((e,t)=>{let a=String(e||``).trim(),o=we(a);if(o&&xe.test(o.title)){let e=Number((o.title.match(Ce)||[])[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&&Se.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 Ee(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??1} 轮 · ${n}`}var Y=t();function De(e,t,n){return!e||t<0?null:e.querySelector(`.mdw-lp-block[data-i="${t}"]`)||[...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)[n]||null}function Oe({nodes:e=[],scrollRoot:t=null,onJump:n=null}){let[r,i]=(0,J.useState)(!1),[a,o]=(0,J.useState)(0),{railRef:s,pos:c,dragging:l,draggedRef:u,handleProps:d}=A(),f=(0,J.useMemo)(()=>(e||[]).map(e=>({...e,title:Ee(e)})),[e]);(0,J.useEffect)(()=>{let e=t;if(!e||!f.length)return;let n=()=>{let t=e.getBoundingClientRect(),n=0;for(let r of f){let i=De(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,f]);let p=(0,J.useCallback)(e=>{let r=t,i=r?De(r,e.blockIndex,e.round-1):null;i&&(i.scrollIntoView({behavior:`smooth`,block:`start`}),o(e.round)),n?.(e)},[t,n]);return f.length?(0,Y.jsxs)(`aside`,{ref:s,className:`doc-rail ack-rail`+(r?` open`:``)+(l?` dragging`:``),style:c?{left:c.x,top:c.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(u.current){u.current=!1;return}i(e=>!e)},...d,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:f.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:()=>p(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:`验收轮次`}),f.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:`doc-rail-row`+(a===e.round?` on`:``),title:e.ackText,onClick:()=>p(e),children:[`第 `,e.round,` 轮`]},e.round))]})})]}):null}var ke=[{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 Ae({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:[ke.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 je=[{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 Me({onClose:e}){return(0,Y.jsx)(o,{title:`快捷键`,onClose:e,size:`lg`,className:`mdw-sheet`,children:(0,Y.jsx)(`div`,{className:`mdw-sheet-cols`,children:je.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 Ne={origin:`起点`,reopen:`反馈`,comment:`评论`,current:`当前`};function Pe({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=Ne[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 X({open:e,nodes:t,onOpenNode:n,onClose:r}){return e?(0,Y.jsxs)(o,{title:`任务链`,onClose:r,size:`md`,className:`mdw-chain-modal`,children:[(0,Y.jsx)(`p`,{className:`mdw-chain-hint`,children:`从早到晚排列。点非当前节点可在旁路打开内容。`}),(0,Y.jsx)(Pe,{nodes:t,onOpenNode:e=>{n?.(e),r?.()}})]}):null}function Fe({id:e,isDraft:t,topicKey:n,task:r,taskRow:i}){let[a,o]=(0,J.useState)(null);(0,J.useEffect)(()=>{o(null)},[e]);let s=i?.timegoal||null,c=a||{duration:s?.duration||``,prompt:s?.prompt||``},l=t||!!i&&i.status===`pending`,u=t||!!i&&i.status!==`done`&&i.status!==`cancelled`&&(i.status===`pending`||!!s),d=!t&&!!s&&r!=null,[f,p]=(0,J.useState)({busy:!1,error:``,data:null}),m=(0,J.useCallback)(()=>{if(t||!n||r==null)return;p(e=>({...e,busy:!0,error:``}));let e=new URLSearchParams({id:String(r),key:String(n)});le(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,r]);return(0,J.useEffect)(()=>{d&&m()},[d,m]),{goalDraft:a,setGoalDraft:o,goal:c,goalEditable:l,goalPromptEditable:u,declaredGoal:s,goalLog:f,loadGoalLog:m,canShowGoalLog:d}}function Ie({isDraft:e,task:t,taskRow:n,topicKey:r,topic:i,isGlobal:a,groupAnchored:o,groupId:s,app:l,model:u,historyId:d,toast:f}){let[p,m]=(0,J.useState)(null);(0,J.useEffect)(()=>{if(e||t==null||/^draft/i.test(String(t))){m(null);return}let n=!1,r=a?`key=${encodeURIComponent(j)}&id=${Number(t)}`:`cwd=${encodeURIComponent(i?.cwd||``)}&id=${Number(t)}`;return _e(r).then(e=>{n||m(e)}).catch(()=>{n||m(null)}),()=>{n=!0}},[e,t,a,i?.cwd,n?.history?.length,n?.forkOf,n?.reopenCount]);let h=(0,J.useMemo)(()=>{if(e||!n)return[];let i=(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:i,attachmentCount:0,current:!0}),e}let o=Array.isArray(p?.ancestors)?[...p.ancestors].reverse():[],s=Array.isArray(p?.children)?p.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:i,attachmentCount:0,current:!0,taskId:Number(t),dirKey:r||`__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,p,t,r]),g=(0,J.useMemo)(()=>{if(d==null||!n)return null;let e=Number(d);return(n.history||[]).find(t=>Number(t.id)===e)||null},[d,n]),_=Array.isArray(p?.children)?p.children:[],v=_.length===0,y=_.length?_[_.length-1]??null:null;return{chainApi:p,chainNodes:h,historyNode:g,chainChildren:_,isChainTip:v,latestChild:y,openLatestRound:(0,J.useCallback)(()=>{y&&l.openPage&&(o?l.openPage({groupId:s,task:String(y.id),name:`#${y.id}`}):l.openPage({dirKey:String(y.key||r||`__GLOBAL__`),task:String(y.id),name:`#${y.id}`}))},[y,l.openPage,o,s,r]),openHistoryBeside:(0,J.useCallback)(n=>{let i=u||l.model;if(i&&!e){if(n?.current){f(`当前节点就是本页`);return}if(n?.historyId!=null){c(i,{component:`page`,name:`链 #${t} · ${n.kind||n.historyId}`,config:{dirKey:r||`__GLOBAL__`,task:String(t),historyId:Number(n.historyId)}});return}if(n?.taskId!=null&&n?.dirKey){c(i,{component:`page`,name:n.excerpt?String(n.excerpt).slice(0,24):`#${n.taskId}`,config:{dirKey:String(n.dirKey),task:String(n.taskId)}});return}f(`这个节点没有可打开的内容`)}},[u,l.model,e,r,t,f])}}function Le({id:e}){let[t,n]=(0,J.useState)(null),r=(0,J.useRef)(``);return(0,J.useEffect)(()=>{n(null),r.current=``},[e]),(0,J.useEffect)(()=>{let e=()=>n(null);return document.addEventListener(`scroll`,e,!0),()=>document.removeEventListener(`scroll`,e,!0)},[]),{selMenu:t,setSelMenu:n,lastSel:r,placeSelMenu:(0,J.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,J.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,J.useCallback)(()=>{n(null),r.current=``},[])}}function Re({id:e,taskRow:t,dockTab:n,dockOpen:r}){let[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(!1),c=(0,J.useRef)(null),l=String(t?.roundSummary||``).length>140;return(0,J.useEffect)(()=>{a(!1),s(!1)},[e,t?.roundSummary]),(0,J.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 ze({doc:e,id:t,isDraft:n,task:r,taskRow:i,topicKey:o,topic:c,isGlobal:u,boardCtx:d,docFm:f,groupAnchored:m,groupId:h,rows:g,app:_,model:v,tabId:b,tpl:x,refreshLocal:E,markDirty:k,histRef:ee,editorApiRef:A,attachAreaRef:te,setDirty:M,goal:ne,goalEditable:re,goalPromptEditable:ae,declaredGoal:B,guard:H,dialog:U,showDockTab:W}){let G=a(),K=(0,J.useCallback)((e,t)=>{let n=(e||``).trim()||`未命名任务`,r=T(t),i=Object.keys(r).length>0,a=C(t);return a=p(a),a=/^#\s+/m.test(a)?a.replace(/^#\s+.+$/m,`# ${n}`):`# ${n}\n\n${a}`,i?w(a,r):a},[]),le=(0,J.useCallback)(()=>{let e=(ne.duration||``).trim(),t=(ne.prompt||``).trim();if(t&&!e)return{error:`时间目标要填时长(如 2h / 90m);只写附加要求无效`};if(!n){let n=B?.duration||``,r=B?.prompt||``,i=e!==n;return!i&&t===r?{}:i?re?e?{duration:e,goalPrompt:t}:{clearGoal:!0}:{error:`已领取计时,时长不可改(附加要求仍可直接改)`}:ae?{goalPrompt:t}:{}}return e?{duration:e,goalPrompt:t}:{}},[ne,re,ae,n,B]),fe=(0,J.useCallback)(()=>H(async()=>{if(!e)return;let i=(e.title||``).trim()||`未命名任务`,a=T(e.body),s=K(i,e.body),f=a.project?g.find(e=>!e.isGlobal&&e.repo&&e.repo.key===a.project):null,p=!!(d&&a.project&&d.members.some(e=>e.key===a.project)),y=le();if(y.error){G(y.error);return}if(!n){let n=await ye({cwd:u?f?f.cwd:void 0:c?.cwd,key:u&&!f?j:void 0,id:Number(r),text:s,...y});if(n?.moved){let a=n.key||o,c=String(n.task?.id??r),u=I(L(a),c);R(c,e.attachments),N(t,u,{title:i,body:n.task?.text||s}),v&&b&&v.doAction(l.updateNodeAttributes(b,{config:m?{groupId:h,task:c}:{dirKey:a,task:c}})),_.onNavigate&&_.onNavigate(m?`#/group/${encodeURIComponent(h||``)}?task=${encodeURIComponent(c)}`:`#/dir/${encodeURIComponent(a||``)}?task=${encodeURIComponent(c)}`),M(!1),S(ee.current,u),G(`已改归属项目:任务迁到「${n.name}」#${c}`),E?.();return}R(r,e.attachments),P(t,{title:i,body:s}),M(!1),S(ee.current,t),G(y.clearGoal?`已同步 MD · 时间目标已清除`:y.duration?`已同步 MD · 时间目标已更新`:`已同步 MD`),E?.();return}let x=await ue({...p?{text:s,board:d.board.id,project:a.project}:a.project?{text:s,project:a.project}:u?{global:!0,text:s}:{cwd:c?.cwd,text:s},...y}),C=x?.task?.id??x?.id;if(C!=null){let n=x?.key||o,r=L(n);R(C,e.attachments);let a=I(r,String(C));N(t,a,{title:i,body:s}),v&&b&&v.doAction(l.updateNodeAttributes(b,{config:m?{groupId:h,task:String(C)}:{dirKey:n,task:String(C)}})),_.onNavigate&&_.onNavigate(m?`#/group/${encodeURIComponent(h||``)}?task=${encodeURIComponent(String(C))}`:`#/dir/${encodeURIComponent(n||``)}?task=${encodeURIComponent(String(C))}`),M(!1),S(ee.current,a)}G(`已提交:${O(i)}`),E?.()}),[e,t,n,r,o,c,u,d,m,h,g,_,v,b,E,ee,M,K,le,H,G]),pe=(0,J.useCallback)(async e=>{let t=await e.text(),n=e.name.replace(/\.md$/i,``);await H(async()=>{let r=t.startsWith(`#`)?t:`# ${n}\n\n${t}`,i=await ue(u?{global:!0,text:r}:{cwd:c?.cwd,text:r});G(`已导入:${e.name}`),E?.();let a=i?.task?.id??i?.id;a!=null&&_.openPage&&(m?_.openPage({groupId:h,task:String(a),name:`#${a}`}):_.openPage({dirKey:o,task:String(a),name:`#${a}`}))})},[u,m,f.project,c?.cwd,o,h,_,E,H,G]),me=(0,J.useCallback)(async()=>{if(!e||n)return;let t=e.title||`#${r}`;await U({title:`删除任务「${t}」`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})&&H(async()=>{await V(u?{key:j,id:Number(r)}:{cwd:c?.cwd,id:Number(r)}),G(`已删除「${t}」`);let e=b&&(v||_.model||null)?.getNodeById?.(b),n=e&&e.getConfig&&e.getConfig()||{};typeof e?.getWindowId==`function`&&e.getWindowId()===`float`||n.beside||!_.onNavigate?v&&b&&v.doAction(l.deleteTab(b)):m?_.onNavigate(`#/group/`+encodeURIComponent(h||``)):u?_.onNavigate(`#/global`):_.onNavigate(`#/dir/`+encodeURIComponent(o||``)),E?.()})},[e,n,r,u,c,v,b,_,m,h,o,E,H,G,U]),q=String(i?.status??``),he=!n&&!!i&&(q===`pending`||q===`claimed`),ge=!n&&!!i&&q===`pending`,_e=he||ge,ve=(0,J.useCallback)(t=>{(t===`done`?!he:!ge)||H(async()=>{let n=e?.title||`#${r}`,a=u?{key:j}:{cwd:c?.cwd};if(t===`done`){let e=q===`claimed`,t=String(i?.claimedByName||i?.claimedBy||``).trim(),o=await U({title:`标为完成「${n}」`,message:e?`该任务正被${t?` ${t} `:` agent `}领取中。你是最终验收方——确认它已经做完、直接标为完成?可写一句完成总结(agent 稍后的回执会被忽略,不算冲突)。`:`任务还没被领取。确认把当前正文视为已完成?可写一句完成总结。`,input:!0,placeholder:`完成总结(可选;留空使用默认说明)`,okText:`标为完成`});if(o==null)return;await ce({...a,ids:[Number(r)],status:`done`,summary:String(o).trim()}),G(`已标为完成 #${r}`)}else{if(!await U({title:`取消任务「${n}」`,message:`只处理待领取任务。取消为终态,原文留档。`,danger:!0,okText:`取消任务`}))return;await ce({...a,ids:[Number(r)],status:`cancelled`}),G(`已取消 #${r}`)}E?.()})},[he,ge,e,r,u,c,q,i,E,H,G,U]),be=!n&&!!i&&(q===`pending`||q===`plan`);return{composeText:K,goalPatchOf:le,submit:fe,importMd:pe,delTask:me,canComplete:he,canCancel:ge,canCloseTask:_e,closeTask:ve,canPlan:be,togglePlan:(0,J.useCallback)(()=>{if(!be)return;let e=q===`plan`?`pending`:`plan`;H(async()=>{let t=u?{key:j}:{cwd:c?.cwd};await oe({...t,id:Number(r),to:e}),G(e===`plan`?`已把 #${r} 转成草稿态(不进队列)`:`已把 #${r} 转回待领取`),E?.()})},[be,q,r,u,c,H,G,E]),addFiles:(0,J.useCallback)(async(i,a={})=>{if(!e)return;let{items:o,imageInserts:s,fileInserts:l}=await z(i),d=ie(t)||e,f=d.body||``,p=s.join(``),m=f,h=null;if(p){let e=y(f,p,a);m=e.body,h=e.insertAt+p.length}l.length&&(m=y(m,l.join(``),{}).body);let g={};if(m!==f&&(g.body=m),o.length&&(g.attachments=[...d.attachments||[],...o]),Object.keys(g).length){if(P(t,g),a.mode===`edit`&&h!=null&&requestAnimationFrame(()=>{A.current?.focus?.();let e=document.querySelector(`.mdw-editor`);if(e)try{e.setSelectionRange(h,h)}catch{}}),!n){g.attachments&&R(r,g.attachments);let e=K(d.title,g.body||m);P(t,{body:e,title:D(e)});try{await ye({cwd:u?void 0:c?.cwd,key:u?j:void 0,id:Number(r),text:e}),M(!1),E?.(),G(o.length?`已添加附件并同步(${o.length})`:`已同步附件`)}catch(e){k(),G(`附件已插入,同步失败:${e.message||e}`)}return}k()}},[e,t,n,r,c,u,M,E,k,K,A,G]),newTask:(0,J.useCallback)(()=>{let e=F(),t=I(L(m?h:o),e),n={};d&&d.board&&d.board.id&&(n.board=d.board.id),f.project&&(n.project=f.project),P(t,{title:``,body:w(x?x.defaultPick().body:``,n)}),_.openPage&&_.openPage(m?{groupId:h,task:e,name:`新任务`}:{dirKey:o,task:e,name:`新任务`})},[d,f.project,m,h,o,_,x]),cloneCur:(0,J.useCallback)(()=>{if(n||r==null||/^draft/i.test(String(r))){G(`草稿没有可克隆的队列任务`);return}H(async()=>{let t=await se(u?{id:Number(r)}:{id:Number(r),cwd:c?.cwd});G(`已克隆为新任务 #${t.task?.id??t.id}`),E?.();let n=t?.task?.id??t?.id;n!=null&&_.openPage&&(m?_.openPage({groupId:h,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(克隆)`}):_.openPage({dirKey:o,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(克隆)`}))})},[n,r,u,c,m,h,o,_,e,E,H,G]),forkCur:(0,J.useCallback)(()=>{if(n||r==null||/^draft/i.test(String(r))){G(`草稿没有可 Fork 的队列任务`);return}H(async()=>{let t=await de(u?{id:Number(r)}:{id:Number(r),cwd:c?.cwd});G(`已 Fork 为新任务 #${t.task?.id??t.id}(保留任务链)`),E?.();let n=t?.task?.id??t?.id;n!=null&&_.openPage&&(m?_.openPage({groupId:h,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(Fork)`}):_.openPage({dirKey:o,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(Fork)`}))})},[n,r,u,c,m,h,o,_,e,E,H,G]),openProgress:(0,J.useCallback)(()=>{let e=v||_.model;if(!e)return;let t=f&&f.board?String(f.board):``;s(e,{component:`progress`,name:`进程`,config:t?{groupKey:t,task:r==null?void 0:String(r)}:{dirKey:o||`__GLOBAL__`,task:r==null?void 0:String(r)},location:`right`})},[v,_.model,f,r,o]),openAttachPanel:(0,J.useCallback)(()=>{W(`attach`),setTimeout(()=>te.current?.open(),0)},[W,te])}}function Be({doc:e,isDraft:t,task:n,taskRow:r,topicKey:i,topic:o,isGlobal:s,dirKey:c,groupAnchored:u,groupId:d,app:f,model:p,tabId:m,refreshLocal:h,closeSelMenu:g,lastSel:_,selMenu:v,dirty:y,setDirty:b,guard:x}){let S=a(),C=(0,J.useCallback)(async()=>{if(t||n==null||/^draft/i.test(String(n)))return null;let e=s?`key=${encodeURIComponent(j)}&id=${Number(n)}`:`cwd=${encodeURIComponent(o?.cwd||``)}&id=${Number(n)}`;return me(e).catch(()=>null)},[t,n,s,o?.cwd]),w=(0,J.useCallback)(()=>{let t=p||f.model;t&&ae(t,{mode:`feedback`,taskLabel:n==null?``:`#`+n,taskTitle:String(e?.title||``).replace(/^#+\s*/,``),prevQuote:String(r?.roundSummary||``).trim()||String(e?.body||``).trim().slice(0,400),src:{dirKey:i||c||`__GLOBAL__`,task:String(n),name:`原文 #${n}`},onSubmit:e=>T(e)})},[p,f.model,n,e,r,i,c]),T=(0,J.useCallback)(({text:a,attachments:c=[],inserts:l=``}={})=>{let p=String(a||``).trim();if(g(),!p&&!(c&&c.length)){S(`写一下反馈`);return}let m=e?.title||`#${n}`;x(async()=>{let a=await C(),g=String(a?.text??``).trim()||String(e?.body??``).trim();if(!g&&!t){S(`拿不到任务当前正文,已取消反馈(防止丢内容)`);return}let _=p||`(见附件)`;l&&(_=`${_}${l}`);let v={base:g,feedback:_,ackSummary:a?.roundSummary||r?.roundSummary||``,feedbackHeading:pe,bold:!0},y=U(v),b=!t&&n!=null&&!/^draft/i.test(String(n))?{forkOf:String(n),forkKind:`reopen`}:{},x=await ue(s?{global:!0,text:y,...b}:{cwd:o?.cwd,text:y,...b}),w=String(x?.task?.id??x?.id??``);if(!w){S(`反馈已提交,但未拿到新任务编号`),h?.();return}let T=x?.key||i;P(I(L(T),w),{title:D(y),body:y}),c?.length&&R(w,c),S(`已反馈「${m}」→ 新任务 #${w}`),h?.(),f.openPage&&(u?f.openPage({groupId:d,task:w,name:`${m.slice(0,24)}(反馈)`}):f.openPage({dirKey:T,task:w,name:`${m.slice(0,24)}(反馈)`}))})},[e,n,r,t,s,o,i,u,d,f,h,g,x,S,C]),E=(0,J.useCallback)(({text:r,attachments:a=[],inserts:c=``,quote:u}={})=>{let d=String(r||``).trim(),f=String(u||_.current||``).trim();if(g(),!d&&!(a&&a.length)){S(`写一下要提的问题`);return}if(!f&&!d){S(`先划选一段再评论`);return}if(t||n==null||/^draft/i.test(String(n))){S(`草稿先提交成任务再评论`);return}let v=e?.title||`#${n}`;x(async()=>{let t=!y&&!c&&!(a&&a.length),r;if(!t){let t=await C(),n=String(t?.text??``).trim()||String(e?.body??``).trim();if(!n){S(`拿不到任务当前正文,已取消评论(防止丢内容)`);return}let i={base:n,feedback:[G(f),d||`(见附件)`,c].filter(Boolean).join(`
8
+
9
+ `),ackSummary:``,feedbackHeading:he,bold:!1};r=U(i)}let u=await W({...s?{key:j}:{cwd:o?.cwd},id:Number(n),...r?{text:r}:{},kind:`comment`,quote:f,feedback:d,attachments:(a||[]).map(e=>({id:e.id,name:e.name,type:e.type,size:e.size,url:e.url||``}))}),g=u?.key||i,_=String(u?.task?.id??n),x=String(u?.task?.text??r??``);x&&P(I(L(g),_),{title:D(x),body:x}),a?.length&&R(_,[...e?.attachments||[],...a]),p&&m&&g!==i&&p.doAction(l.updateNodeAttributes(m,{config:{dirKey:g,task:_}})),b(!1),S(`已回写评论「${v}」#${_}`),h?.()})},[e,n,t,s,o,i,p,m,h,g,_,y,b,x,S,C]);return{fetchServerTask:C,openFeedback:w,spawnFeedbackTask:T,submitCommentInPlace:E,openCommentFromToolbar:(0,J.useCallback)(()=>{let t=String(window.getSelection()||``).trim()||(v?.text?String(v.text):``);if(!t){S(`先划选一段再评论`);return}_.current=t;let r=p||f.model;r&&(ae(r,{mode:`comment`,quote:t,taskLabel:n==null?``:`#`+n,taskTitle:String(e?.title||``).replace(/^#+\s*/,``),src:{dirKey:i||c||`__GLOBAL__`,task:String(n),name:`原文 #${n}`},onSubmit:e=>E({...e,quote:t})}),g())},[e,n,i,c,p,f.model,_,v,E,g,S])}}function Ve({doc:e,beside:t,topicKey:n,topic:r,task:i,app:a}){let o=(0,J.useMemo)(()=>e?T(e.body):{},[e&&e.body]);return{docFm:o,parentRef:(0,J.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];if(!l)return null;let u=l.trim(),d=(r?.tasks||[]).find(e=>String(e.id)===String(i)?!1:D(e.text||``)===u||String(e.text||``).includes(`# ${u}`));return d?{dirKey:n,task:String(d.id),name:`#${d.id}`}:null},[t,o.parent,o.parentDir,e?.body,n,r,i]),boardCtx:(0,J.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(e=>!!e).map(e=>({key:e.key,name:e.name}))}},[o.board,a.repoData])}}var He=o;function Ue({state:e,onClose:t}){let n=a(),r=e?.data,i=async()=>{try{await navigator.clipboard.writeText(String(r?.rendered||``)),n(`已复制原文`)}catch{n(`复制失败(剪贴板不可用)`)}},o=r?.switches||{},s=r?[`ack ${o.ack?.on?`开(${o.ack.count} 条)`:`关`}`,`模板 全部内置(插件类)`,`持续 get ${r.getLoop?.enabled?`开(${r.getLoop.waitMinutes} 分钟)`:`关`}`].join(` · `):``,c=r?`预览:agent 执行 get 会收到的提示词${r.task?.id?` · #${r.task.id}`:` · 草稿`}`:`预览:agent 执行 get 会收到的提示词`;return(0,Y.jsxs)(He,{title:c,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:i,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:s})]})]})}var We=k;function Ge({attachments:e}){let t=e.filter(e=>e.kind===`mdfile`),[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)({}),o=async e=>{if(r(e),!i[e]||i[e].error){a(t=>({...t,[e]:{html:``,path:``,stale:!1,missing:!1,loading:!0}}));try{let t=await K(e);a(n=>({...n,[e]:{html:m(String(t.body||``)),path:String(t.absPath||``),stale:!!t.stale,missing:!!t.missing}}))}catch(t){a(n=>({...n,[e]:{html:``,path:``,stale:!1,missing:!1,error:t.message||String(t)}}))}}};if(!t.length)return(0,Y.jsx)(`div`,{className:`mdw-dock-empty`,children:"没有 md 附件——用 `nx-kv localtask attach --mdfile <本地 md 路径>` 挂一个外部 md 文件。"});let s=n?i[n]:null;return(0,Y.jsxs)(`div`,{className:`mdw-md-tab`,children:[(0,Y.jsx)(`div`,{className:`mdw-md-list`,role:`list`,children:t.map(e=>(0,Y.jsxs)(`button`,{type:`button`,role:`listitem`,className:`mdw-md-item${n===String(e.id)?` is-on`:``}`,onClick:()=>o(String(e.id)),title:e.absPath||``,children:[(0,Y.jsx)(`span`,{className:`mdw-md-item-name`,children:e.name||`md`}),(0,Y.jsxs)(`span`,{className:`mdw-md-item-path mono`,children:[e.absPath||`(路径为空)`,e.missing?` · 文件已不在`:``]})]},String(e.id)))}),(0,Y.jsxs)(`div`,{className:`mdw-md-view`,children:[n?null:(0,Y.jsx)(`div`,{className:`mdw-dock-empty`,children:`选一条 md 看预览。`}),s?.loading?(0,Y.jsx)(`div`,{className:`mdw-dock-empty`,children:`读取中…`}):null,s?.error?(0,Y.jsxs)(`div`,{className:`mdw-dock-empty`,children:[`读取失败:`,s.error]}):null,s&&!s.loading&&!s.error?s.missing?(0,Y.jsxs)(`div`,{className:`mdw-dock-empty`,children:[`源文件已不在:`,s.path||`(路径为空)`]}):(0,Y.jsxs)(`div`,{className:`mdw-md-render`,children:[s.stale?(0,Y.jsx)(`div`,{className:`att-md-warn`,children:`内容已变化(与登记指纹不一致),以下为磁盘当前内容。`}):null,(0,Y.jsx)(`article`,{dangerouslySetInnerHTML:{__html:s.html}})]}):null]})]})}function Ke({dockOpen:t,dockTab:n,dockH:r,dockRef:i,dockMax:a,showDockTab:o,onDockDragStart:c,toggleDockMax:l,setDockOpen:u,canShowGoalLog:f,goalLog:p,openGoalLog:m,isDraft:h,task:g,topic:_,topicKey:v,isGlobal:y,doc:b,id:x,model:S,app:C,refreshLocal:w,markDirty:T,saveDoc:E,persistAtt:D,attachAreaRef:O,reviewBarRef:k,reviewSumRef:ee,taskRow:A,ackOpen:te,setAckOpen:M,ackOverflow:N,ackLong:P,ackHtml:F,isChainTip:ne,latestChild:I,openFeedback:L,openLatestRound:re,attachments:ie}){if(!t)return null;let R=ie.filter(e=>e.kind===`mdfile`).length;return(0,Y.jsxs)(`div`,{className:`mdw-dock`,ref:i,style:{height:`${r}px`},children:[(0,Y.jsx)(`div`,{className:`mdw-dock-drag`,role:`separator`,"aria-orientation":`horizontal`,title:`上下拖动调整信息面板高度(双击最大化 / 还原)`,onMouseDown:c,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":n===`attach`,className:`mdw-dock-tab${n===`attach`?` is-on`:``}`,onClick:()=>o(`attach`),children:`附件`}),(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`md`,className:`mdw-dock-tab${n===`md`?` is-on`:``}`,onClick:()=>o(`md`),title:`只聚合 kind='mdfile' 的附件(md 预览)`,children:[`md`,R?(0,Y.jsx)(`span`,{className:`mdw-dock-tab-num`,children:R}):null]}),f?(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`check`,className:`mdw-dock-tab${n===`check`?` is-on`:``}`,onClick:m,children:[`check`,(0,Y.jsx)(`span`,{className:`mdw-dock-tab-num`,children:p.data?.count??0})]}):null,(0,Y.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`feedback`,className:`mdw-dock-tab${n===`feedback`?` is-on`:``}`,onClick:()=>o(`feedback`),children:`反馈`})]}),(0,Y.jsxs)(`div`,{className:`mdw-dock-acts`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:l,title:a?`还原面板高度`:`最大化面板高度`,"aria-label":a?`还原面板高度`:`最大化面板高度`,children:(0,Y.jsx)(e,{name:a?`collapse`:`expand`,title:void 0})}),(0,Y.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:()=>u(!1),title:`关闭面板(底部状态栏仍保留入口)`,"aria-label":`关闭面板`,children:(0,Y.jsx)(e,{name:`x`,title:void 0})})]})]}),(0,Y.jsxs)(`div`,{className:`mdw-dock-body`,children:[n===`attach`?h?(0,Y.jsx)(B,{attachments:b.attachments,onRemove:e=>{let t=(b.attachments||[]).filter(t=>t.id!==e);T(),E(x,{attachments:t}),h||D(g,t)}}):_?(0,Y.jsx)(We,{ref:O,host:`task`,hostId:Number(g),hostKey:y?j:void 0,hostCwd:y?void 0:_.cwd,allow:{file:!0,url:!0,folder:!0,task:!0,ref:!0},taskOptions:(_.tasks||[]).map(e=>({id:e.id,text:e.text,status:e.status})),onChanged:w,onOpenTask:e=>{C.openPage&&e&&e.seq!=null&&C.openPage({dirKey:e.key||v,task:String(e.seq),name:`#${e.seq}`})},onOpenDoc:e=>{let t=d(e);S&&t&&s(S,{component:`doc`,name:e.split(`/`).pop()||e,config:{docId:t},location:`center`})}}):(0,Y.jsx)(`div`,{className:`mdw-dock-empty`,children:`没有可挂载附件的上下文。`}):null,n===`md`?(0,Y.jsx)(Ge,{attachments:ie}):null,n===`check`?(0,Y.jsxs)(`div`,{className:`mdw-dock-check`,children:[p.busy&&!p.data?(0,Y.jsx)(`div`,{className:`mdw-dock-empty`,children:`读取中…`}):null,p.error?(0,Y.jsxs)(`div`,{className:`mdw-dock-empty`,children:[`读取失败:`,p.error]}):null,p.data?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`mdw-dock-meta mono`,children:[`时间目标 ${p.data.duration||`—`}`,p.data.startedAt?` · 开始 ${p.data.startedAt}`:``,p.data.deadline?` · 截止 ${p.data.deadline}`:` · 尚未开始计时`,p.data.archived?` · 已归档`:``,` · ${p.data.count||0} 轮`]}),(p.data.count||0)>0?(0,Y.jsx)(`div`,{className:`mdw-goal-log`,children:p.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?`已到点`:`未到点`,` · 已用`,` `,fe(e.elapsedSec),` · 剩余 `,fe(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,n===`feedback`?!h&&A?.completedAt?(0,Y.jsxs)(`div`,{className:`mdw-review`,ref:k,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:A.completedAt}),A.roundSummary?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{ref:ee,className:`mdw-review-sum${te?` is-open`:``}`,title:te||!(N||P)?`agent 的完成总结(ack)`:`点击下方展开全文`,dangerouslySetInnerHTML:{__html:F}}),(N||P||te)&&(0,Y.jsx)(`button`,{type:`button`,className:`mdw-review-more`,onClick:()=>M(e=>!e),children:te?`收起`:`展开全文`})]}):null]}),(0,Y.jsx)(`div`,{className:`mdw-review-acts`,children:ne?(0,Y.jsx)(`button`,{type:`button`,className:`ghost`,onClick:L,title:`新开一条任务携带反馈(原任务不动)`,children:`反馈`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`mdw-review-later`,title:`这条任务已有后续轮次——在旧轮次上反馈会把链分叉,请到最新一轮反馈`,children:`已进入后续轮次`}),I?(0,Y.jsxs)(`button`,{type:`button`,className:`ghost`,onClick:re,title:`到最新一轮 #${I.id} 反馈`,children:[`去最新一轮 #`,I.id]}):null]})})]}):(0,Y.jsx)(`div`,{className:`mdw-dock-empty`,children:`任务完成后,agent 的完成总结会显示在这里。`}):null]})]})}function qe({dockOpen:t,dockTab:n,showDockTab:r,setDockOpen:i,canShowGoalLog:a,goalLog:o,openGoalLog:s,isDraft:c,taskRow:l,mdCount:u=0}){return(0,Y.jsxs)(`div`,{className:`mdw-sbar`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${t&&n===`attach`?` is-on`:``}`,onClick:()=>r(`attach`),title:`附件(点击展开信息面板)`,children:[(0,Y.jsx)(e,{name:`list`,title:void 0}),(0,Y.jsx)(`span`,{className:`mdw-sbar-lab`,children:`附件`})]}),(0,Y.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${t&&n===`md`?` is-on`:``}`,onClick:()=>r(`md`),title:`md 附件预览(点击展开信息面板)`,children:[(0,Y.jsx)(e,{name:`overview`,title:void 0}),(0,Y.jsx)(`span`,{className:`mdw-sbar-lab`,children:`md`}),u>0?(0,Y.jsx)(`span`,{className:`mdw-sbar-num`,children:u}):null]}),a?(0,Y.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${t&&n===`check`?` is-on`:``}`,onClick:s,title:`时间目标每轮 check(点击展开信息面板)`,children:[(0,Y.jsx)(e,{name:`clock`,title:void 0}),(0,Y.jsx)(`span`,{className:`mdw-sbar-lab`,children:`check`}),(0,Y.jsx)(`span`,{className:`mdw-sbar-num`,children:o.data?.count??0})]}):null,(0,Y.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${t&&n===`feedback`?` is-on`:``}`,onClick:()=>r(`feedback`),title:`完成总结 / 反馈(点击展开信息面板)`,children:[(0,Y.jsx)(e,{name:`edit`,title:void 0}),(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)(E,{t:l,title:void 0})}):null,(0,Y.jsx)(`button`,{type:`button`,className:`mdw-sbar-chev${t?` is-open`:``}`,onClick:()=>i(e=>!e),title:t?`收起信息面板`:`展开信息面板`,"aria-expanded":t,"aria-label":t?`收起信息面板`:`展开信息面板`,children:(0,Y.jsx)(e,{name:`chevron`,title:void 0})})]})}function Je({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}}var Ye={origin:`起点`,reopen:`反馈`,comment:`评论`};function Xe({historyId:e,historyNode:t,closeBesideSelf:n}){let r=Ye[String(t?.kind??``)]||`节点`,i=t?q(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 Ze({boardCtx:e,docFm:t,goalEditable:n,doc:r,id:i,markDirty:a}){if(!e)return null;let o=e.members.find(e=>e.key===t.project);return(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=>{P(i,{body:w(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:o?.name||t.project||`—`})]})}function Qe({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 $e({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:`×`})]})}var et=X;function tt({dirKey:e,groupId:t,task:n,beside:r=!1,tabId:o,model:s,historyId:d=null}){let p=u(),m=a(),{dialog:y,node:S}=i(),C=p.rows||[],T=p.refreshLocal,E=p.tpl,O=!(!t||e),k=(0,J.useMemo)(()=>O?ge(C,p.repoData&&p.repoData.boards||[],t,n):null,[O,C,p.repoData,t,n]),A=k&&k.topic&&k.topic.key||e||``,N=!O&&(!A||A===`__GLOBAL__`),F=M(n),ie=L(O&&F?t:A),z=I(ie,n),B=(0,J.useMemo)(()=>O?k&&k.topic||null:N?C.find(e=>e.isGlobal)||null:C.find(e=>e.key===A)||null,[C,A,N,O,k]),V=(0,J.useMemo)(()=>(B?.tasks||[]).find(e=>String(e.id)===String(n))||null,[B,n]),oe=ne(),U=oe[z]||null,W=U&&U.mode===`edit`?`edit`:`split`,{dockOpen:G,setDockOpen:se,dockTab:ce,dockH:K,dockRef:le,dockMax:ue,showDockTab:de,onDockDragStart:fe,toggleDockMax:pe}=ee(),{goalDraft:me,setGoalDraft:he,goal:_e,goalEditable:ye,goalPromptEditable:be,declaredGoal:xe,goalLog:Se,loadGoalLog:Ce,canShowGoalLog:we}=Fe({id:z,isDraft:F,topicKey:A,task:n,taskRow:V}),{chainNodes:Ee,historyNode:De,isChainTip:ke,latestChild:je,openLatestRound:Ne,openHistoryBeside:Pe}=Ie({isDraft:F,task:n,taskRow:V,topicKey:A,topic:B,isGlobal:N,groupAnchored:O,groupId:t,app:p,model:s||null,historyId:d,toast:m}),{selMenu:X,setSelMenu:He,lastSel:We,placeSelMenu:Ge,onEditorTextSel:Ye,closeSelMenu:tt}=Le({id:z}),{ackOpen:nt,setAckOpen:rt,ackOverflow:it,reviewSumRef:at,ackLong:ot}=Re({id:z,taskRow:V,dockTab:ce,dockOpen:G}),[st,ct]=(0,J.useState)(null),[lt,ut]=(0,J.useState)(!1),[dt,ft]=(0,J.useState)(!1),[pt,mt]=(0,J.useState)(!1),ht=(0,J.useRef)(null),gt=(0,J.useRef)(null),_t=(0,J.useRef)(null),vt=(0,J.useRef)(null),yt=(0,J.useRef)(null),bt=(0,J.useRef)(null),xt=(0,J.useRef)(new Map),[Z,St]=(0,J.useState)([]);(0,J.useEffect)(()=>{let e=!0,t=V;if(!t||!t.id)return;let n=new URLSearchParams({id:String(t.id)});return A?n.set(`key`,A):t.cwd&&n.set(`cwd`,t.cwd),H(n.toString()).then(t=>{e&&St(t&&(t.attachments||t.data?.attachments)||[])}).catch(()=>{e&&St([])}),()=>{e=!1}},[V,A]);let Ct=(0,J.useMemo)(()=>U?q(g(U.body),Z.length?Z:U.attachments):``,[U,Z]),wt=(0,J.useMemo)(()=>V?.roundSummary?q(V.roundSummary):``,[V?.roundSummary]),Tt=(0,J.useMemo)(()=>U?Te(U.body):[],[U&&U.body]),[Et,Dt]=(0,J.useState)(null);(0,J.useEffect)(()=>{let e=vt.current;if(!e)return;let t=()=>e.closest(`.mdw-lp`)||e.closest(`.mdw-preview`)||null;Dt(t());let n=typeof MutationObserver<`u`?new MutationObserver(()=>Dt(t())):null;return n?.observe(e,{childList:!0,subtree:!0}),()=>n?.disconnect()},[U&&U.mode]);let Ot=(0,J.useCallback)(e=>e().catch(e=>m(String(e.message||e))),[m]),Q=(0,J.useCallback)(()=>mt(!0),[]),{docFm:kt,parentRef:$,boardCtx:At}=Ve({doc:U,beside:r,topicKey:A,topic:B,task:n,app:p});(0,J.useEffect)(()=>{oe[z]||(F?re(z,{title:``,body:E?w(E.defaultPick().body,O?{board:t}:{}):``}):V&&re(z,{title:D(V.text),body:V.text}))},[z,F,V,O,t]);let{composeText:jt,submit:Mt,importMd:Nt,delTask:Pt,canComplete:Ft,canCancel:It,closeTask:Lt,canPlan:Rt,togglePlan:zt,addFiles:Bt,newTask:Vt,cloneCur:Ht,forkCur:Ut,openProgress:Wt,openAttachPanel:Gt}=ze({doc:U,id:z,isDraft:F,task:n,taskRow:V,topicKey:A,topic:B,isGlobal:N,boardCtx:At,docFm:kt,groupAnchored:O,groupId:t,rows:C,app:p,model:s||null,tabId:o,tpl:E,refreshLocal:T,markDirty:Q,histRef:xt,editorApiRef:bt,attachAreaRef:_t,setDirty:mt,goal:_e,goalEditable:ye,goalPromptEditable:be,declaredGoal:xe,guard:Ot,dialog:y,showDockTab:de}),{openFeedback:Kt,submitCommentInPlace:qt,openCommentFromToolbar:Jt}=Be({doc:U,isDraft:F,task:n,taskRow:V,topicKey:A,topic:B,isGlobal:N,dirKey:e,groupAnchored:O,groupId:t,app:p,model:s||null,tabId:o,refreshLocal:T,closeSelMenu:tt,lastSel:We,selMenu:X,dirty:pt,setDirty:mt,guard:Ot}),Yt=(0,J.useCallback)(()=>{de(`check`),Ce()},[de,Ce]),{goalBadge:Xt,goalMenu:Zt}=Je({goal:_e,goalDraft:me,setGoalDraft:he,goalEditable:ye,goalPromptEditable:be,declaredGoal:xe,openGoalLog:Yt,markDirty:Q,task:n}),Qt=(0,J.useCallback)(()=>{ct({busy:!0});let e={cwd:N?B?.cwd||void 0:B?.cwd,key:N?j:A,...F?{text:jt((U?.title||``).trim()||`未命名任务`,U?.body||``)}:{id:Number(n)}};ve(e).then(e=>ct({data:e})).catch(e=>ct({error:String(e.message||e)}))},[N,B?.cwd,A,F,U?.title,U?.body,n,jt]),$t=(e,t=`typing`)=>{if(!U)return;v(xt.current,z,{title:U.title,body:U.body},t),Q();let n={title:e};W!==`split`&&/^# (?!#)/m.test(U.body)&&(n.body=U.body.replace(/^# (?!#).+$/m,`# ${e||`未命名任务`}`)),P(z,n)},en=(e,t=`op`)=>{if(!U)return;v(xt.current,z,{title:U.title,body:U.body},t),Q();let n={body:e};W!==`split`&&(n.title=D(e)),P(z,n)},tn=()=>{if(!U)return;let e=h(xt.current,z,{title:U.title,body:U.body});e&&(P(z,{title:e.title,body:e.body}),Q(),requestAnimationFrame(()=>bt.current?.caretFromDiff?.(U.body,e.body)))},nn=()=>{if(!U)return;let e=b(xt.current,z,{title:U.title,body:U.body});e&&(P(z,{title:e.title,body:e.body}),Q(),requestAnimationFrame(()=>bt.current?.caretFromDiff?.(U.body,e.body)))},rn=e=>{if(!U||W===`edit`)return;let t=e.target instanceof Element?e.target:null;if(t?.closest(`#mdw-sel-menu`)||t?.closest(`textarea`))return;let n=window.getSelection(),r=String(n||``).trim();if(!r||r.length<1){He(null);return}if(!n)return;if(!vt.current?.contains(n.anchorNode)){He(null);return}let i=e=>e?.nodeType===3?e.parentElement:e,a=i(n.anchorNode)?.closest?.(`.mdw-lp-block`),o=i(n.focusNode)?.closest?.(`.mdw-lp-block`),s=null;if(a&&o&&a!==o&&vt.current?.contains(o)){let e=Number(a.getAttribute(`data-i`)),t=Number(o.getAttribute(`data-i`));Number.isInteger(e)&&Number.isInteger(t)&&e!==t&&(s=[Math.min(e,t),Math.max(e,t)])}let c=n.getRangeAt(0),l=c.getClientRects(),u=l[l.length-1]??c.getBoundingClientRect();Ge(`task`,r,u.right-60,u.bottom+8,s?{blockRange:s}:{})},an=(0,J.useCallback)(()=>{if(!$){m(`这条任务没有可定位的原文`);return}let e=s||p.model;e&&c(e,{component:`page`,name:$.name||`原文 ${$.task}`,config:{dirKey:$.dirKey,task:String($.task)}})},[$,s,p.model,m]),on=(0,J.useCallback)(()=>{let e=s||p.model;e&&o&&e.doAction(l.deleteTab(o))},[s,p.model,o]),sn=e=>{gt.current&&(gt.current.accept=e),gt.current?.click()};return(0,J.useEffect)(()=>{if(!$||r)return;let e=e=>{(e.ctrlKey||e.metaKey)&&e.shiftKey&&String(e.key||``).toLowerCase()===`o`&&(e.preventDefault(),an())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[$,r,an]),d==null?U?(0,Y.jsxs)(`div`,{className:`mdw${r?` is-beside`:``}`,"data-mode":W,onMouseUp:rn,children:[S,st&&(0,Y.jsx)(Ue,{state:st,onClose:()=>ct(null)}),(0,Y.jsx)(et,{open:dt,nodes:Ee,onOpenNode:Pe,onClose:()=>ft(!1)}),r&&(0,Y.jsx)($e,{onClose:on}),(0,Y.jsxs)(`div`,{className:`mdw-main`,children:[(0,Y.jsxs)(`div`,{className:`mdw-top`,children:[(0,Y.jsx)(te,{}),(0,Y.jsxs)(`div`,{className:`mdw-head`,children:[(0,Y.jsx)(`div`,{className:`mdw-title`,children:F?U.title||`新 MD 任务`:U.title||`任务`}),(0,Y.jsxs)(`div`,{className:`mdw-path`,children:[N?`全局任务池`:B?.cwd||B?.name||`—`,!N&&B?.cwdExists===!1&&(0,Y.jsxs)(`span`,{className:`mdw-path-warn`,title:`工作目录已不存在:目录被删除或磁盘未挂载。任务本身还在,只是不再有对应目录。`,children:[` `,`· 目录已不存在`]}),F?` / (${n})`:` / #${n}`,pt?` · 未保存`:``]})]})]}),(0,Y.jsx)(Ze,{boardCtx:At,docFm:kt,goalEditable:ye,doc:U,id:z,markDirty:Q}),(0,Y.jsx)(_,{mode:W,onMode:e=>P(z,{mode:e}),showMark:W!==`edit`,submitLabel:F?`提交为任务`:`保存并同步`,onNew:Vt,onSubmit:Mt,onChain:F?null:()=>ft(!0),onPreview:Qt,onImg:()=>sn(`image/*`),onAtt:()=>F?sn(`image/*,.pdf,.zip,.txt,.json,.csv`):Gt(),onImport:()=>ht.current?.click(),onClone:F?null:Ht,onFork:F?null:Ut,onComplete:Ft?()=>Lt(`done`):null,onPlan:Rt?zt:null,planLabel:String(V?.status||``)===`plan`?`转回待领取`:`转为草稿(plan)`,onCancelTask:It?()=>Lt(`cancel`):null,onMark:Jt,onDraft:()=>m(`草稿随页签保留(刷新后需从侧栏或页签重新打开)`),onDelete:F?null:Pt,onOverview:()=>p.onNavigate&&p.onNavigate(`#/overview`),onProg:Wt,onSource:$?an:null,onShortcuts:()=>ut(!0),goalBadge:Xt,goalMenu:Zt}),(0,Y.jsx)(f,{ref:vt,mode:W,title:U.title,body:U.body,previewHtml:Ct,onTitle:$t,onBody:en,attachments:Z.length?[...U.attachments,...Z]:U.attachments,docKey:z,editorApiRef:bt,onFiles:Bt,onTextSel:Ye,onSave:Mt,onUndo:tn,onRedo:nn,onCloseSelMenu:tt,attachHost:F?null:{host:`task`,hostId:Number(n),hostKey:N?j:void 0,hostCwd:N?void 0:B?.cwd,allow:{file:!0,url:!0,folder:!0,task:!0,ref:!0},taskOptions:(B?.tasks||[]).map(e=>({id:e.id,text:e.text,status:e.status}))}}),(0,Y.jsx)(Ke,{dockOpen:G,dockTab:ce,dockH:K,dockRef:le,dockMax:ue,showDockTab:de,onDockDragStart:fe,toggleDockMax:pe,setDockOpen:se,canShowGoalLog:we,goalLog:Se,openGoalLog:Yt,isDraft:F,task:n,topic:B,topicKey:A,isGlobal:N,doc:U,id:z,model:s||null,app:p,refreshLocal:T,markDirty:Q,saveDoc:P,persistAtt:R,attachAreaRef:_t,reviewBarRef:yt,reviewSumRef:at,taskRow:V,ackOpen:nt,setAckOpen:rt,ackOverflow:it,ackLong:ot,ackHtml:wt,isChainTip:ke,latestChild:je,openFeedback:Kt,openLatestRound:Ne,attachments:Z.length?Z:U.attachments}),(0,Y.jsx)(qe,{dockOpen:G,dockTab:ce,showDockTab:de,setDockOpen:se,canShowGoalLog:we,goalLog:Se,openGoalLog:Yt,isDraft:F,taskRow:V,mdCount:(Z.length?Z:U.attachments).filter(e=>e.kind===`mdfile`).length})]}),(0,Y.jsx)(Oe,{nodes:Tt,scrollRoot:Et}),(0,Y.jsx)(Ae,{at:X,onFormat:e=>{bt.current?.format?.(e),tt()},onCompose:()=>{let t=s||p.model;if(!t)return;let r=String(X?.text||We.current||``);ae(t,{mode:`comment`,quote:r,taskLabel:n==null?``:`#`+n,taskTitle:String(U?.title||``).replace(/^#+\s*/,``),src:{dirKey:A||e||`__GLOBAL__`,task:String(n),name:`原文 #${n}`},onSubmit:e=>qt({...e,quote:r})}),tt()},onCopy:()=>{let e=X?.blockRange,t=``;if(e&&U){let n=x(U.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||We.current||X?.text||``),m(`已复制`),tt()},onDelete:X?.blockRange?()=>{let e=X.blockRange;e&&(bt.current?.deleteBlockRange?.(e[0],e[1])?m(`已删除 ${e[1]-e[0]+1} 个块(Ctrl+Z 可撤销)`):m(`选区已失效`),tt())}:void 0}),(0,Y.jsx)(`input`,{ref:gt,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,t.length&&Bt(t)}}),(0,Y.jsx)(`input`,{ref:ht,type:`file`,accept:`.md,text/markdown,text/plain`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&Nt(t)}}),lt&&(0,Y.jsx)(Me,{onClose:()=>ut(!1)})]}):p.localReady===!1||F?(0,Y.jsx)(`div`,{className:`mdw`,children:(0,Y.jsx)(`div`,{className:`pad muted`,children:`载入中…`})}):(0,Y.jsx)(Qe,{task:n,app:p,groupAnchored:O,groupId:t,isGlobal:N,dirKey:e}):(0,Y.jsx)(Xe,{historyId:d,historyNode:De,closeBesideSelf:on})}export{tt as default};
@@ -1,4 +1,4 @@
1
- import{u as e}from"./popup-DZ2Khv2c.js";import{d as t}from"./md-history-DVI47hu4.js";import{n,o as r}from"./board-view-BVennxTs.js";function i(t){return e(`/api/localtasks/chain?${t}`)}function a(t){return e(`/api/localtasks/timegoal-log?${t}`)}function o(t){return e(`/api/localtasks/reorder`,{method:`PATCH`,body:t})}function s(t){return e(`/api/localtasks/item`,{method:`PATCH`,body:t})}function c(t){return e(`/api/localtasks/item?${t}`).catch(()=>null)}function l(t){return e(`/api/localtasks`,{method:`POST`,body:t})}function u(t){return e(`/api/localtasks/plan`,{method:`PATCH`,body:t})}function d(t){return e(`/api/localtasks/reopen`,{method:`POST`,body:t})}function f(t){return e(`/api/localtasks/item`,{method:`DELETE`,body:t})}function p(t){return e(`/api/localtasks/items`,{method:`DELETE`,body:t})}function m(t){return e(`/api/localtasks/items/cancel`,{method:`POST`,body:t})}function h(t){return e(`/api/localtasks/items/close`,{method:`POST`,body:t})}function g(t){return e(`/api/localtasks/clone`,{method:`POST`,body:t})}function _(t){return e(`/api/localtasks/fork`,{method:`POST`,body:t})}function v(t){return e(`/api/localtasks/attachments?${t}`)}function y(t){return e(`/api/docs/mdfile?attachment=${encodeURIComponent(t)}`)}function b(t){return e(`/api/localtasks/preview`,{method:`POST`,body:t})}var x=`## 验收反馈`,S=`## 反馈修改`;function C(e){return String(e??``).split(`
1
+ import{u as e}from"./popup-DZ2Khv2c.js";import{d as t}from"./md-history-DNtgaIdH.js";import{n,o as r}from"./board-view-BVennxTs.js";function i(t){return e(`/api/localtasks/chain?${t}`)}function a(t){return e(`/api/localtasks/timegoal-log?${t}`)}function o(t){return e(`/api/localtasks/reorder`,{method:`PATCH`,body:t})}function s(t){return e(`/api/localtasks/item`,{method:`PATCH`,body:t})}function c(t){return e(`/api/localtasks/item?${t}`).catch(()=>null)}function l(t){return e(`/api/localtasks`,{method:`POST`,body:t})}function u(t){return e(`/api/localtasks/plan`,{method:`PATCH`,body:t})}function d(t){return e(`/api/localtasks/reopen`,{method:`POST`,body:t})}function f(t){return e(`/api/localtasks/item`,{method:`DELETE`,body:t})}function p(t){return e(`/api/localtasks/items`,{method:`DELETE`,body:t})}function m(t){return e(`/api/localtasks/items/cancel`,{method:`POST`,body:t})}function h(t){return e(`/api/localtasks/items/close`,{method:`POST`,body:t})}function g(t){return e(`/api/localtasks/clone`,{method:`POST`,body:t})}function _(t){return e(`/api/localtasks/fork`,{method:`POST`,body:t})}function v(t){return e(`/api/localtasks/attachments?${t}`)}function y(t){return e(`/api/docs/mdfile?attachment=${encodeURIComponent(t)}`)}function b(t){return e(`/api/localtasks/preview`,{method:`POST`,body:t})}var x=`## 验收反馈`,S=`## 反馈修改`;function C(e){return String(e??``).split(`
2
2
  `).map(e=>e.trim()?`**${e}**`:e).join(`
3
3
  `)}function w(e){let t=String(e??``).trim();return t?`> 锚定:\n> ${t.replace(/\n/g,`
4
4
  > `)}`:``}var T=`NOTE`,E=`WARNING`,D=/完成总结/,O=/第\s*(\d+)\s*轮/,k=/^>\s*\[![A-Za-z][\w-]*\][ \t]*(.*)$/;function A(e){return`第 ${Number(e)||1} 轮 · 完成总结`}function j(e){return`第 ${Number(e)||1} 轮 · 验收反馈`}function M(e){return String(e??``).split(`
@@ -0,0 +1 @@
1
+ .tpl-page{flex-direction:column;gap:12px;display:flex}.tpl-head-note{margin:2px 0 0;font-size:12px}.tpl-search{padding:2px 0 8px}.tpl-list{flex-direction:column;gap:8px;min-width:0;display:flex}.tpl-card{border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);border-radius:10px;flex-direction:column;gap:6px;min-width:0;padding:10px 12px;display:flex}.tpl-card.is-default{border-color:var(--mdw-accent-line,#b7d4c8)}.tpl-card-head{flex-wrap:wrap;align-items:center;gap:8px;min-width:0;display:flex}.tpl-card-name{font-size:13px;font-weight:600}.tpl-badge{background:var(--mdw-accent-soft,#e8f2ee);color:var(--mdw-accent,#2f6f5e);border:1px solid var(--mdw-accent-line,#b7d4c8);border-radius:999px;padding:0 6px;font-size:10.5px;line-height:1.7}.tpl-badge.soft{background:var(--soft,#f1f0ec);color:var(--mid,#8a8578);border-color:var(--line,#e4e2dc)}.tpl-card-grow{flex:auto;min-width:0;max-width:none}.tpl-card-acts{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:6px;display:flex}.tpl-card-sum{color:var(--ink-2,#4b515a);-webkit-line-clamp:2;-webkit-box-orient:vertical;font-size:11.5px;line-height:1.6;display:-webkit-box;overflow:hidden}.tpl-card-scope{border-top:1px dashed var(--line,#e4e2dc);padding-top:6px}.tpl-preview{border:1px dashed var(--line,#e4e2dc);background:var(--soft,#f7f6f3);border-radius:8px;flex-direction:column;gap:6px;margin-top:2px;padding:9px 11px;display:flex}.tpl-preview-note{color:var(--mid,#8a8578);font-size:10.5px}.tpl-preview-body{min-width:0;max-height:300px;overflow:auto}.tpl-card-hint{color:var(--mid,#8a8578);font-size:11px;line-height:1.6}.tpl-card-hint code{background:var(--soft,#f1f0ec);border:1px solid var(--line,#e4e2dc);border-radius:3px;padding:0 3px;font:400 10.5px ui-monospace,Consolas,monospace}.tpl-mng-page{gap:12px}.tpl-mng-page .page-head h2{align-items:center;gap:7px;display:flex}.tpl-mng-search{padding:2px 0 6px}.tpl-mng-list{flex-direction:column;gap:6px;min-width:0;display:flex}.tpl-mng-row{border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);border-radius:9px;grid-template-columns:22px minmax(0,1fr) auto;align-items:center;gap:8px;padding:8px 10px;display:grid}.tpl-mng-row.is-dragging{opacity:.5}.tpl-mng-row.is-over{border-color:var(--mdw-accent,#2f6f5e);box-shadow:inset 0 -2px 0 var(--mdw-accent,#2f6f5e)}.tpl-mng-grip{cursor:grab;color:var(--mid,#8a8578);justify-content:center;align-items:center;display:flex}.tpl-mng-grip:active{cursor:grabbing}.tpl-mng-main{min-width:0}.tpl-mng-line{flex-wrap:wrap;align-items:center;gap:6px;min-width:0;display:flex}.tpl-mng-name{color:var(--ink,#222);font-size:12.5px;font-weight:600}.tpl-mng-scope-sum{text-overflow:ellipsis;white-space:nowrap;margin-top:3px;font-size:10.5px;overflow:hidden}.tpl-mng-acts{align-items:center;gap:2px;display:flex}.tpl-mng-scope{border-top:1px dashed var(--line,#e4e2dc);grid-column:1/-1;padding-top:8px}.tpl-card .iconbtn.is-on{background:var(--mdw-accent-soft,#e8f2ee);color:var(--mdw-accent,#2f6f5e)}.tpl-page .page-head h2,.tpl-mng-page .page-head h2{align-items:center;gap:7px;display:flex}
@@ -0,0 +1,10 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Bg0m8gbJ.js","assets/popup-DZ2Khv2c.js","assets/popup-BAvk7J7u.css","assets/workspace-DojQ3RP4.js","assets/repo-form-modal-Dg3hJWUV.js","assets/button-3JlUeln_.js","assets/button-DA4lNJeC.css","assets/doc-DRSKD0Re.js","assets/app-context-BqCBcDsx.js","assets/md-history-DNtgaIdH.js","assets/frontmatter-CN6IlxWU.js","assets/status-tag-8cLH8hl9.js","assets/md-history-CLIs9Dr0.css","assets/use-rail-drag-DxIYcszo.js","assets/list-filter-CWxiOSg_.js","assets/route-crumb-C4DgkJ8G.js","assets/board-view-BVennxTs.js","assets/doc-Iuxssa-b.css","assets/model-CtG2jIDv.js","assets/index-BIVxGd6t.css"])))=>i.map(i=>d[i]);
2
+ import{a as e,d as t,f as n,h as r,i,l as a}from"./popup-DZ2Khv2c.js";import{v as o}from"./workspace-DojQ3RP4.js";import{n as s}from"./app-context-BqCBcDsx.js";import{t as c}from"./button-3JlUeln_.js";import{a as l,d as u,i as d,n as f,r as p,t as m}from"./md-history-DNtgaIdH.js";import{n as h,t as g}from"./list-filter-CWxiOSg_.js";import{n as _,t as v}from"./route-crumb-C4DgkJ8G.js";import{a as y,n as b}from"./index-Bg0m8gbJ.js";import{t as x}from"./manage-session-CS8UvmUd.js";var S=r(n(),1),C=t(),w={topic:`目录`,repo:`项目`,group:`组`};function T(){let e=s(),t=e.rows||[],n=e.repoData?.repos||[],r=e.repoData?.boards||[];return(0,S.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 E(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=w[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 D({scope:e,onChange:t,originTopic:n=``,catalog:r,classPrefix:i=`setp`}){let o=a(),s=T(),c=r||s,[l,u]=(0,S.useState)(null),d=Array.isArray(e)?e:[],f=d.includes(`*`),p=d.filter(e=>e!==`*`),m=i,h=n?c.topicByKey.get(n)||(/^[0-9a-f]{16}$/.test(n)?`${n.slice(0,6)}…`:n):``,g=async e=>{try{await t(e)}catch(e){o(String(e.message||e))}},_=async e=>{if(d.includes(e)){o(`已经在可见范围里了`),u(null);return}await g([...d,e]),u(null)},v=(0,S.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,C.jsxs)(`div`,{className:`${m}-scope-block`,children:[(0,C.jsx)(`div`,{className:`${m}-scope`,children:d.map(e=>(0,C.jsxs)(`button`,{type:`button`,className:`${m}-scope-chip on`,title:`${e} —— 点击移除`,onClick:()=>g(d.filter(t=>t!==e)),children:[E(e,c),` ×`]},e))}),(0,C.jsxs)(`div`,{className:`${m}-scope-add`,children:[(0,C.jsx)(`span`,{className:`${m}-scope-add-label`,children:`添加`}),(0,C.jsx)(`button`,{type:`button`,className:`${m}-scope-add-btn`,disabled:f,title:f?`已绑定全局`:`加上「全局」绑定(与目录/项目/组平级)`,onClick:()=>!f&&g([`*`,...p]),children:`全局`}),[`topic`,`repo`,`group`].map(e=>(0,C.jsx)(`button`,{type:`button`,className:`${m}-scope-add-btn`+(l===e?` on`:``),onClick:()=>u(l===e?null:e),children:w[e]},e)),h?(0,C.jsxs)(`span`,{className:`${m}-scope-origin`,title:`创建于主题 ${n}`,children:[`创建于 `,h]}):null]}),l&&(0,C.jsx)(`div`,{className:`${m}-scope-pick`,role:`listbox`,"aria-label":`选择可见对象`,children:v.length?v.map(e=>(0,C.jsxs)(`button`,{type:`button`,className:`${m}-scope-pick-it`,disabled:d.includes(e.entry),title:e.sub||e.entry,onClick:()=>_(e.entry),children:[(0,C.jsx)(`span`,{className:`${m}-scope-pick-name`,children:e.label}),d.includes(e.entry)?(0,C.jsx)(`span`,{className:`${m}-scope-pick-done`,children:`已加`}):null]},e.entry)):(0,C.jsx)(`div`,{className:`${m}-scope-pick-empty`,children:`暂无可选项`})})]})}function O(e){return String(e||``).split(`
3
+ `).map(e=>e.trim().replace(/^#{1,6}\s+/,``).replace(/^[-*+]\s+\[[ x]\]\s*/i,``).replace(/^[-*+]\s+/,``).replace(/^>\s?/,``)).filter(Boolean).slice(0,2).join(` · `)}function k(){let t=s(),n=t.tpl,r=a(),{dialog:o,node:l}=i(),[d,f]=(0,S.useState)(null),[p,m]=(0,S.useState)(null),[_,v]=(0,S.useState)(!1),[y,b]=(0,S.useState)(``),x=e=>t.onNavigate?.(e);if(!n)return(0,C.jsx)(`div`,{className:`rp-page tpl-page`,children:(0,C.jsx)(`div`,{className:`muted`,style:{padding:20},children:`模板服务未就绪…`})});if(n.unsupported)return(0,C.jsx)(`div`,{className:`rp-page tpl-page`,children:(0,C.jsx)(`div`,{className:`muted`,style:{padding:20},children:`当前服务比面板旧——重启面板后才有模板功能。`})});let w=n.templates||[],T=g(w,y,e=>[e.name,O(e.body),(e.scope||[]).join(` `)]),E=async(e,t)=>{if(!_){v(!0);try{await e(),t&&r(t)}catch(e){r(String(e.message||e))}finally{v(!1)}}},k=async e=>{await o({title:`删除模板「${e.name}」`,danger:!0,okText:`删除`})&&await E(()=>n.remove(e.id),`已删除「${e.name}」`)};return(0,C.jsxs)(`div`,{className:`rp-page tpl-page`,children:[l,(0,C.jsxs)(`div`,{className:`page-head`,children:[(0,C.jsxs)(`div`,{className:`title-block`,children:[(0,C.jsxs)(`h2`,{children:[(0,C.jsx)(e,{name:`list`,size:16}),` 任务模板`]}),(0,C.jsx)(`p`,{className:`muted tpl-head-note`,children:`新建任务时的正文骨架;正式内容在编辑页自行填写。`})]}),(0,C.jsx)(`div`,{className:`acts`,children:(0,C.jsxs)(c,{variant:`primary`,small:!0,disabled:_,onClick:()=>x(`#/templates/new`),children:[(0,C.jsx)(e,{name:`plus`,size:13}),` 新建`]})})]}),!w.length&&(0,C.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`还没有模板(内置默认模板加载中…)。`}),w.length>1?(0,C.jsx)(`div`,{className:`tpl-search`,children:(0,C.jsx)(h,{value:y,onChange:b,placeholder:`搜索名称 / 正文 / 可见范围…`,title:`过滤任务模板`,count:T.length,className:`wide`})}):null,(0,C.jsxs)(`div`,{className:`tpl-list`,children:[T.map(t=>{let r=t.id===n.defaultId,i=d===t.id,a=p===t.id;return(0,C.jsxs)(`div`,{className:`tpl-card`+(r?` is-default`:``),children:[(0,C.jsxs)(`div`,{className:`tpl-card-head`,children:[(0,C.jsx)(`span`,{className:`tpl-card-name`,children:t.name}),r&&(0,C.jsx)(`span`,{className:`tpl-badge`,children:`默认`}),t.builtin&&(0,C.jsx)(`span`,{className:`tpl-badge soft`,children:`内置`}),(0,C.jsx)(`span`,{className:`grow tpl-card-grow`}),(0,C.jsxs)(`div`,{className:`tpl-card-acts`,children:[(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:a?`收起预览`:`预览`,onClick:()=>m(a?null:t.id),children:(0,C.jsx)(e,{name:`monitor`,size:14})}),(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`+(i?` is-on`:``),title:`可见范围`,disabled:_,onClick:()=>f(i?null:t.id),children:(0,C.jsx)(e,{name:`globe`,size:14})}),(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`编辑`,disabled:_,onClick:()=>x(`#/templates/edit/${encodeURIComponent(t.id)}`),children:(0,C.jsx)(e,{name:`edit`,size:14})}),!r&&(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`设为默认`,disabled:_,onClick:()=>E(()=>n.setDefault(t.id),`默认模板已设为「${t.name}」`),children:(0,C.jsx)(e,{name:`star`,size:14})}),!t.builtin&&(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`删除`,disabled:_,onClick:()=>k(t),children:(0,C.jsx)(e,{name:`trash`,size:14})})]})]}),(0,C.jsx)(`div`,{className:`tpl-card-sum`,children:O(t.body)||`(空模板)`}),i&&(0,C.jsx)(`div`,{className:`tpl-card-scope`,children:(0,C.jsx)(D,{scope:t.scope,originTopic:t.originTopic,onChange:e=>n.update(t.id,{scope:e})})}),a&&(0,C.jsx)(`div`,{className:`tpl-preview`,children:(0,C.jsx)(`div`,{className:`tpl-preview-body mdw-lp-view`,dangerouslySetInnerHTML:{__html:u(t.body)}})})]},t.id)}),w.length&&!T.length?(0,C.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`(没有匹配的模板)`}):null]})]})}function A({config:t}){let n=s(),r=a(),i=n.tpl,o=(0,S.useMemo)(()=>x(t?.id),[t?.id]),l=b(o?{topic:o.topic||``,group:o.group||``,repo:o.repo||``}:{topic:`__no_topic__`}),[u,d]=(0,S.useState)(``),[f,p]=(0,S.useState)(null),[m,_]=(0,S.useState)(null),[w,T]=(0,S.useState)(null),[E,O]=(0,S.useState)(!1),k=l.templates||[],A=g(k,u,e=>[e.name,e.body,(e.scope||[]).join(` `)]),j=async(e,t)=>{if(!E){O(!0);try{await e(),t&&r(t)}catch(e){r(String(e.message||e))}finally{O(!1)}}},M=async(e,t)=>{if(e===t)return;let n=k.map(e=>e.id),r=n.indexOf(e),a=n.indexOf(t);r<0||a<0||(n.splice(r,1),n.splice(a,0,e),await j(()=>i.reorder(n)))},N=()=>{let e=o?.group?[`group:${o.group}`]:o?.repo?[`repo:${o.repo}`]:o?.topic?[`topic:${o.topic}`]:[];y(async()=>{let{openTemplateEditor:e}=await import(`./index-Bg0m8gbJ.js`).then(e=>e.i);return{openTemplateEditor:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])).then(({openTemplateEditor:t})=>{n.model&&t(n.model,{mode:`new`,scope:e,topic:o?.topic||``,name:``})})},P=o?.label||o?.topic||o?.group||o?.repo||`本主题`;return(0,C.jsxs)(`div`,{className:`rp-page tpl-mng-page`,children:[(0,C.jsx)(v,{}),(0,C.jsxs)(`div`,{className:`page-head`,children:[(0,C.jsxs)(`div`,{className:`title-block`,children:[(0,C.jsxs)(`h2`,{children:[(0,C.jsx)(e,{name:`gear`,size:16}),` 管理模板 · `,P]}),(0,C.jsx)(`p`,{className:`muted tpl-head-note`,children:`只显示本主题可见的模板。拖动左侧把手调整顺序,点图标改可见范围;搜索框会同步隐藏不匹配的行。`})]}),(0,C.jsx)(`div`,{className:`acts`,children:(0,C.jsxs)(c,{variant:`primary`,small:!0,disabled:E,onClick:N,children:[(0,C.jsx)(e,{name:`plus`,size:13}),` 新建模板`]})})]}),(0,C.jsx)(`div`,{className:`tpl-mng-search`,children:(0,C.jsx)(h,{value:u,onChange:d,placeholder:`搜索名称 / 正文 / 可见范围…`,title:`过滤本主题模板`,count:A.length,className:`wide`})}),k.length?(0,C.jsx)(`div`,{className:`tpl-mng-list`,children:A.map(t=>{let r=t.id===i?.defaultId;return(0,C.jsxs)(`div`,{className:[`tpl-mng-row`,f===t.id?`is-dragging`:``,m===t.id&&f!==t.id?`is-over`:``].filter(Boolean).join(` `),draggable:!0,onDragStart:e=>{p(t.id),e.dataTransfer.effectAllowed=`move`},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,_(t.id)},onDrop:e=>{e.preventDefault(),_(null),f&&M(f,t.id),p(null)},onDragEnd:()=>{p(null),_(null)},children:[(0,C.jsx)(`span`,{className:`tpl-mng-grip`,title:`拖动排序`,children:(0,C.jsx)(e,{name:`grip`,size:14})}),(0,C.jsxs)(`div`,{className:`tpl-mng-main`,children:[(0,C.jsxs)(`div`,{className:`tpl-mng-line`,children:[(0,C.jsx)(`span`,{className:`tpl-mng-name`,children:t.name}),r&&(0,C.jsx)(`span`,{className:`tpl-badge`,children:`默认`}),t.builtin&&(0,C.jsx)(`span`,{className:`tpl-badge soft`,children:`内置`})]}),(t.scope||[]).length>0&&!w&&(0,C.jsxs)(`div`,{className:`tpl-mng-scope-sum muted`,children:[`可见:`,(t.scope||[]).join(` / `)]})]}),(0,C.jsxs)(`div`,{className:`tpl-mng-acts`,children:[(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`可见范围`,onClick:()=>T(w===t.id?null:t.id),children:(0,C.jsx)(e,{name:`globe`,size:14})}),(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`编辑`,onClick:()=>n.onNavigate?.(`#/templates/edit/${encodeURIComponent(t.id)}`),children:(0,C.jsx)(e,{name:`edit`,size:14})}),!r&&(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`设为默认`,disabled:E,onClick:()=>j(()=>i.setDefault(t.id),`默认模板已设为「${t.name}」`),children:(0,C.jsx)(e,{name:`star`,size:14})}),!t.builtin&&(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`删除`,disabled:E,onClick:()=>j(()=>i.remove(t.id),`已删除「${t.name}」`),children:(0,C.jsx)(e,{name:`trash`,size:14})})]}),w===t.id&&(0,C.jsx)(`div`,{className:`tpl-mng-scope`,children:(0,C.jsx)(D,{scope:t.scope,originTopic:t.originTopic,onChange:e=>i.update(t.id,{scope:e})})})]},t.id)})}):(0,C.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`本主题下没有可见模板。`})]})}var j=e=>`tpl:${e||`new`}`,M=`## 背景
4
+
5
+
6
+ ## 验收
7
+ - [ ] …
8
+
9
+ ## 约束
10
+ - …`;function N({templateId:e,initialName:t,initialBody:n,isNew:r,onSave:i,onClose:o,busy:s}){let c=a(),[h,g]=(0,S.useState)(t||``),[_,y]=(0,S.useState)(n||``),[b,x]=(0,S.useState)(`split`),[w,T]=(0,S.useState)(!1),E=(0,S.useRef)(null),D=(0,S.useRef)(new Map),O=j(r?`new`:e),k=(0,S.useMemo)(()=>u(_||``),[_]),A=(e,t,n=`typing`)=>{f(D.current,O,{title:h,body:_},n),g(e),y(t),T(!0)},M=(e,t=`typing`)=>A(e,_,t),N=(e,t=`op`)=>A(h,e,t),P=()=>{let e=d(D.current,O,{title:h,body:_});e&&(g(e.title||``),y(e.body||``),T(!0))},F=()=>{let e=p(D.current,O,{title:h,body:_});e&&(g(e.title||``),y(e.body||``),T(!0))},I=async()=>{if(!(h||``).trim()){c(`模板名不能为空(标题即名称)`);return}await i({name:h.trim(),body:_}),m(D.current,O),T(!1)};return(0,C.jsx)(`div`,{className:`mdw mdw-tpl-edpage`,"data-mode":b,children:(0,C.jsxs)(`div`,{className:`mdw-main`,children:[(0,C.jsxs)(`div`,{className:`mdw-top`,children:[(0,C.jsx)(v,{}),(0,C.jsxs)(`div`,{className:`mdw-head`,children:[(0,C.jsx)(`div`,{className:`mdw-title`,children:r?`新建模板`:`编辑模板`}),(0,C.jsxs)(`div`,{className:`mdw-path`,children:[`任务模板`,h?` / ${h}`:``,w?` · 未保存`:``]})]})]}),(0,C.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,C.jsx)(`div`,{className:`mdw-toolbar-left`,children:(0,C.jsx)(`div`,{className:`seg`,role:`group`,"aria-label":`编辑模式`,children:[{id:`split`,label:`并排`},{id:`edit`,label:`源码`}].map(e=>(0,C.jsx)(`button`,{type:`button`,className:b===e.id?`on`:``,onClick:()=>x(e.id),children:e.label},e.id))})}),(0,C.jsxs)(`div`,{className:`mdw-actions`,role:`group`,"aria-label":`模板操作`,children:[(0,C.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:s,onClick:o,children:`关闭`}),(0,C.jsx)(`button`,{type:`button`,className:`btn sm primary`,disabled:s||!w,onClick:I,children:r?`创建`:`保存`})]})]}),(0,C.jsx)(l,{mode:b,title:h,body:_,previewHtml:k,onTitle:M,onBody:N,docKey:O,editorApiRef:E,onSave:I,onUndo:P,onRedo:F,attachments:[]})]})})}function P({config:e,model:t,tabId:n}){let r=s(),i=r.tpl,c=a(),[l,u]=(0,S.useState)(!1),d=e||{},f=d.mode||(d.id?`edit`:``),p=f===`new`,m=d.id||``;if(f===`manage`)return(0,C.jsx)(A,{config:d});let h=()=>{let e=_();if(e&&r.onNavigate){r.onNavigate(e);return}if(r.onNavigate){r.onNavigate(`#/overview`);return}if(t&&n)try{t.doAction(o.deleteTab(n))}catch{}};if(!i)return(0,C.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,C.jsx)(v,{}),(0,C.jsx)(`div`,{className:`pad muted`,children:`模板服务未就绪 —— 面板还在装载。`})]});if(!p&&!m)return(0,C.jsx)(k,{});let g=p?null:(i.templates||[]).find(e=>e.id===m);if(!p&&!g)return(0,C.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,C.jsx)(v,{}),(0,C.jsxs)(`div`,{className:`pad muted`,children:[`找不到模板「`,m,`」——可能已删除。`]})]});let y=async({name:e,body:t})=>{u(!0);try{if(p){let n={};Array.isArray(d.scope)&&(n.scope=d.scope),d.topic&&(n.topic=d.topic),await i.add(e,t,!1,n),c(`已创建模板`)}else await i.update(m,{name:e,body:t}),c(`已保存模板`);h()}catch(e){c(String(e.message||e))}finally{u(!1)}},b=p?d.name||``:g?.name??``,x=p?M:g?.body??``;return(0,C.jsx)(N,{templateId:m,initialName:b,initialBody:x,isNew:p,busy:l,onSave:y,onClose:h},p?`new:${d.topic||``}:${(d.scope||[]).join(`,`)}`:m)}export{P as default};
@@ -1 +1 @@
1
- import{d as e,f as t,h as n,i as r,l as i,t as a,u as o}from"./popup-DZ2Khv2c.js";import{C as s,D as c,E as l,M as u,O as d,S as f,d as p,j as ee,k as m}from"./md-history-DVI47hu4.js";var h=n(t(),1),g=e(),_=a,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 te(e,{onRemove:t,onPreview:n,onPreviewMd:r,onOpenTask:i,onOpenDoc:a,onEditNote:o,onReplace:s}){let c=e.kind===`image`?m(e.id):``;return(0,g.jsxs)(`div`,{className:`att-item att-kind-${e.kind}`,children:[e.kind===`image`?(0,g.jsx)(`button`,{type:`button`,className:`att-thumb`,onClick:()=>n({src:c,name:e.name}),title:`点击看大图`,children:(0,g.jsx)(`img`,{src:c,alt:e.name,loading:`lazy`})}):(0,g.jsx)(`span`,{className:`att-kind-badge`,children:d(e.kind)}),(0,g.jsxs)(`span`,{className:`att-item-main`,children:[e.kind===`task`?(0,g.jsx)(`button`,{type:`button`,className:`att-link`,title:`跳转到任务 #${e.targetSeq??``}`,onClick:()=>i?.({key:e.targetKey,seq:e.targetSeq}),children:e.name}):e.kind===`ref`?(0,g.jsx)(`button`,{type:`button`,className:`att-link`,title:e.note||e.title||e.name||`打开文档`,onClick:()=>a?.(e.refId?`ref:`+e.refId:e.locator||e.targetRef),children:e.title||e.name}):e.kind===`url`?(0,g.jsx)(`a`,{className:`att-link`,href:e.url,target:`_blank`,rel:`noreferrer`,title:e.url,children:e.name}):(0,g.jsx)(`span`,{className:`att-item-name`,title:e.name,children:e.name}),(0,g.jsxs)(`span`,{className:`att-item-meta`,children:[e.sizeText?(0,g.jsx)(`span`,{children:e.sizeText}):null,e.kind===`mdfile`?(0,g.jsxs)(`span`,{className:`att-note`,title:e.absPath||``,children:[e.absPath||`(路径为空)`,e.missing?` · 源文件已不在`:``]}):null,e.kind===`folder`?(0,g.jsxs)(`span`,{className:`att-note`,title:e.absPath||``,children:[e.absPath||`(路径为空)`,e.missing?` · 目录已不在`:``]}):null,e.note?(0,g.jsx)(`span`,{className:`att-note`,children:e.note}):null]})]}),e.kind===`mdfile`?(0,g.jsx)(`span`,{className:`att-item-acts`,children:(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`按 md 渲染磁盘当前内容(读时核对指纹)`,onClick:()=>r?.(e),children:`预览`})}):null,e.kind===`file`||e.kind===`image`?(0,g.jsxs)(`span`,{className:`att-item-acts`,children:[(0,g.jsx)(`a`,{className:`att-act`,href:m(e.id),target:`_blank`,rel:`noreferrer`,children:`打开`}),(0,g.jsx)(`a`,{className:`att-act`,href:m(e.id),download:e.name,children:`下载`})]}):null,e.kind===`ref`?(0,g.jsxs)(`span`,{className:`att-item-acts`,children:[o?(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`改这条绑定的一行说明(交付清单会透出)`,onClick:()=>o(e),children:`✎ 说明`}):null,(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`换成另一篇文档(替换这条绑定)`,onClick:()=>s?.(e),children:`⇄ 更换`})]}):null,(0,g.jsx)(`button`,{type:`button`,className:`att-x`,"aria-label":`移除 ${e.name}`,onClick:()=>t(e),children:`×`})]},e.id)}function y({host:e=`task`,hostId:t,hostKey:n,hostCwd:a,refId:d,allow:m={file:!0,url:!0,folder:!0,task:!1,ref:!1},taskOptions:y=[],docOptions:b,disabled:x=!1,disabledText:S=`提交任务后可以在这里挂附件(当前是草稿)。`,openRef:C,onChanged:w,onOpenTask:T,onOpenDoc:E}){let D=i(),{dialog:ne,node:re}=r(),[O,k]=(0,h.useState)([]),[A,j]=(0,h.useState)(!1),[M,N]=(0,h.useState)(``),[ie,P]=(0,h.useState)(!1),[ae,F]=(0,h.useState)(!1),[oe,I]=(0,h.useState)(!1),[L,se]=(0,h.useState)(`position`),[R,z]=(0,h.useState)(null),[B,V]=(0,h.useState)(null),[H,U]=(0,h.useState)(!1),[W,G]=(0,h.useState)(null),[K,q]=(0,h.useState)(null),J=(0,h.useMemo)(()=>ee(e,{hostId:t,hostKey:n,hostCwd:a,refId:d}),[e,t,n,a,d]),Y=(0,h.useCallback)(async()=>{if(x){k([]);return}j(!0),N(``);try{let e=await J.list();k((e.attachments||[]).map(u))}catch(e){N(String(e.message||e))}finally{j(!1)}},[J,x]);(0,h.useEffect)(()=>{Y()},[Y]),(0,h.useImperativeHandle)(C,()=>({open:()=>P(!0),refresh:Y}),[Y]),(0,h.useEffect)(()=>{if(!W)return;let e=e=>{e.key===`Escape`&&G(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[W]);let X=(0,h.useMemo)(()=>[...O].sort(v[L]||v.position),[O,L]),Z=X.filter(e=>e.area===`inline`),Q=X.filter(e=>e.area===`area`),ce=async(e,t)=>{if(x)return;let n=s(t),r=n.length?n:[...e||[]].filter(e=>e&&e.size>0);if(!r.length)return;I(!0);let i=0;for(let e of r)try{let t=await l(e),n=t.fileId||t.id;if(!n)throw Error(`上传未返回 fileId`);await J.attach({fileId:n,name:t.name}),i+=1}catch(t){D(`「${e.name||`文件`}」添加失败:${t.message||t}`)}I(!1),i&&(D(`已挂到附件区 ${i} 个文件`),await Y(),w?.())},$=async r=>{if(r&&e!==`doc`)try{let e=await ne({title:`说明 · ${r.name}`,input:!0,placeholder:`这一行里大概是什么(交付清单会透出给 agent)`,value:r.note||``,okText:`保存说明`});if(e===null)return;let i=typeof e==`string`?e:e&&e.value||``,s={id:Number(t),...n?{key:n}:a?{cwd:a}:{},attachment:r.id,note:i};await o(`/api/localtasks/attach-note`,{method:`PATCH`,body:s}),D(i?`已保存说明:${i}`:`已清空说明`),await Y(),w?.()}catch(e){D(`改说明失败:${e.message||e}`)}},le=e=>{e&&(V(e),P(!0))},ue=async e=>{let t=R;if(t){U(!0);try{await J.detach(t.id,!!e),z(null),D(e?`已移除并删除资源:${t.name}`:`已解除关联:${t.name}`),await Y(),w?.()}catch(e){D(`移除失败:${e.message||e}`)}finally{U(!1)}}},de=async e=>{if(e)try{let t=await o(`/api/docs/mdfile?attachment=${encodeURIComponent(String(e.id))}`),n=String(t.body||``);q({name:e.name||`md`,html:p(n),path:String(t.absPath||e.absPath||``),stale:!!t.stale,missing:!!t.missing})}catch(e){D(`读取失败:${e.message||e}`)}},fe=!A&&!M&&!O.length;return(0,g.jsxs)(`div`,{className:`att-area${x?` is-disabled`:``}`,onDragOver:e=>{!x&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),F(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||F(!1)},onDrop:e=>{F(!1),!x&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),ce(null,e))},children:[re,(0,g.jsxs)(`div`,{className:`att-area-head`+(ae&&!x?` is-over`:``),children:[(0,g.jsxs)(`span`,{className:`att-area-title`,children:[`附件`,O.length?(0,g.jsx)(`span`,{className:`att-count`,children:O.length}):null,oe?(0,g.jsx)(`span`,{className:`att-area-note`,children:`上传中…`}):null]}),(0,g.jsxs)(`span`,{className:`att-area-acts`,children:[O.length?(0,g.jsxs)(`select`,{className:`att-sort`,value:L,onChange:e=>se(e.target.value),"aria-label":`附件排序`,children:[(0,g.jsx)(`option`,{value:`position`,children:`按添加顺序`}),(0,g.jsx)(`option`,{value:`name`,children:`按名称`}),(0,g.jsx)(`option`,{value:`kind`,children:`按类型`})]}):null,(0,g.jsx)(`button`,{type:`button`,className:`btn ghost att-add-btn`,disabled:x,onClick:()=>P(!0),children:`添加附件`})]})]}),x?(0,g.jsx)(`div`,{className:`att-empty`,children:S}):null,A?(0,g.jsx)(`div`,{className:`att-empty`,children:`加载附件…`}):null,M?(0,g.jsxs)(`div`,{className:`att-empty att-err-text`,children:[`附件加载失败:`,M]}):null,fe?(0,g.jsx)(`div`,{className:`att-empty`,children:`还没有附件。拖文件到这里,或点「添加附件」——只挂附件区,不写正文。`}):null,Z.length?(0,g.jsxs)(`div`,{className:`att-section`,children:[(0,g.jsxs)(`div`,{className:`att-section-head`,children:[c.inline,(0,g.jsx)(`span`,{className:`att-section-hint`,children:`正文里的引用,删正文行会跟着消失`})]}),Z.map(t=>te(t,{onRemove:z,onPreview:G,onPreviewMd:de,onOpenTask:T,onOpenDoc:E,onEditNote:e===`task`?$:void 0,onReplace:le,key:t.id}))]}):null,Q.length?(0,g.jsxs)(`div`,{className:`att-section`,children:[(0,g.jsxs)(`div`,{className:`att-section-head`,children:[c.area,(0,g.jsx)(`span`,{className:`att-section-hint`,children:`不依赖正文,删正文行也不会丢`})]}),Q.map(t=>te(t,{onRemove:z,onPreview:G,onPreviewMd:de,onOpenTask:T,onOpenDoc:E,onEditNote:e===`task`?$:void 0,onReplace:le,key:t.id}))]}):null,(0,g.jsx)(f,{open:ie,host:e,hostId:t,hostKey:n,hostCwd:a,refId:d,allow:m,taskOptions:y,docOptions:b,replaceAttachment:B?B.id:null,replaceNote:B&&B.note||``,onClose:()=>{P(!1),V(null)},onDone:async()=>{V(null),await Y(),w?.()}}),R?(0,g.jsx)(_,{title:`移除附件`,size:`sm`,busy:H,onClose:H?void 0:()=>z(null),footer:(0,g.jsxs)(`div`,{className:`att-foot`,children:[(0,g.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:H,onClick:()=>z(null),children:`取消`}),(0,g.jsx)(`button`,{type:`button`,className:`btn`,disabled:H,onClick:()=>ue(!1),children:`只解除关联`}),(0,g.jsx)(`button`,{type:`button`,className:`btn danger`,disabled:H,onClick:()=>ue(!0),children:R.kind===`file`?`连文件一起删`:`连资源一起删`})]}),children:(0,g.jsxs)(`div`,{className:`att-confirm`,children:[(0,g.jsx)(`div`,{className:`att-confirm-name`,children:R.name}),(0,g.jsxs)(`div`,{className:`att-confirm-text`,children:[`只解除关联:从这份`,e===`task`?`任务`:`文档`,`的附件清单里移除,资源仍留在孤儿池,可被重新挂载。 连资源一起删:在本机没有其它任务/文档引用它时,删除资源行(本机文件同时删字节);仍被引用时只解除关联。`]})]})}):null,K?(0,g.jsx)(_,{title:(0,g.jsxs)(`span`,{children:[K.name,(0,g.jsx)(`span`,{className:`att-md-path`,children:K.path})]}),size:`lg`,onClose:()=>q(null),footer:(0,g.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:()=>q(null),children:`关闭`}),children:K.missing?(0,g.jsxs)(`div`,{className:`att-empty`,children:[`源文件已不在:`,K.path||`(路径为空)`]}):(0,g.jsxs)(`div`,{className:`att-md-preview`,children:[K.stale?(0,g.jsx)(`div`,{className:`att-md-warn`,children:`内容已变化(与登记指纹不一致),以下为磁盘当前内容。`}):null,(0,g.jsx)(`article`,{dangerouslySetInnerHTML:{__html:K.html}})]})}):null,W?(0,g.jsx)(`div`,{className:`att-lightbox`,role:`dialog`,"aria-label":`图片预览`,onMouseDown:e=>{e.target===e.currentTarget&&G(null)},children:(0,g.jsxs)(`div`,{className:`att-lightbox-card`,children:[(0,g.jsxs)(`div`,{className:`att-lightbox-head`,children:[(0,g.jsx)(`span`,{className:`att-lightbox-name`,children:W.name}),(0,g.jsx)(`a`,{className:`att-lightbox-open`,href:W.src,target:`_blank`,rel:`noreferrer`,children:`新窗口打开`}),(0,g.jsx)(`button`,{type:`button`,className:`pp-x`,"aria-label":`关闭`,onClick:()=>G(null),children:`×`})]}),(0,g.jsx)(`img`,{className:`att-lightbox-img`,src:W.src,alt:W.name})]})}):null]})}function b(e=`task`,t=!0){let n=(0,h.useCallback)(t=>`nxkv.${e}Dock${t}`,[e]),[r,i]=(0,h.useState)(()=>{let e=localStorage.getItem(n(`Open`));return e===null?t:e!==`0`}),[a,o]=(0,h.useState)(()=>localStorage.getItem(n(`Tab`))||`attach`),[s,c]=(0,h.useState)(()=>{let e=Number(localStorage.getItem(n(`H`)));return Number.isFinite(e)&&e>=96?e:176}),l=(0,h.useRef)(s);l.current=s;let u=(0,h.useRef)(null),[d,f]=(0,h.useState)(!1),p=(0,h.useRef)(176);return(0,h.useEffect)(()=>{localStorage.setItem(n(`Open`),r?`1`:`0`)},[r,n]),(0,h.useEffect)(()=>{localStorage.setItem(n(`Tab`),a)},[a,n]),{dockOpen:r,setDockOpen:i,dockTab:a,setDockTab:o,dockH:s,dockHRef:l,dockRef:u,dockMax:d,setDockMax:f,dockPrevHRef:p,showDockTab:(0,h.useCallback)(e=>{o(e),i(!0)},[]),onDockDragStart:(0,h.useCallback)(e=>{if(!r)return;e.preventDefault(),f(!1);let t=e.clientY,i=l.current,a=u.current?.parentElement?.clientHeight||window.innerHeight,o=e=>Math.max(96,Math.min(Math.round(a*.62),Math.round(e))),s=e=>{let n=o(i-(e.clientY-t));l.current=n,c(n)},d=()=>{window.removeEventListener(`mousemove`,s),window.removeEventListener(`mouseup`,d),document.body.style.userSelect=``,document.body.style.cursor=``,localStorage.setItem(n(`H`),String(l.current))};document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`,window.addEventListener(`mousemove`,s),window.addEventListener(`mouseup`,d)},[r,n]),toggleDockMax:(0,h.useCallback)(()=>{if(d){c(p.current),f(!1);return}p.current=l.current;let e=u.current?.parentElement?.clientHeight||window.innerHeight,t=Math.max(96,Math.round(e*.62));l.current=t,c(t),f(!0)},[d])}}var x=`nx-kv-ack-rail-pos`,S=`nx-kv-doc-rail-pos`;function C(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=Number(t),l=Number(n),u=Number(r),d=Number(i),f=Math.max(s,u-a-s),p=Math.max(s,d-o-s);return{x:Math.min(f,Math.max(s,c)),y:Math.min(p,Math.max(s,l))}}function w(e=x){try{let t=JSON.parse(localStorage.getItem(e)||`null`);if(!t||typeof t!=`object`)return null;let n=Number(t.x),r=Number(t.y);return!Number.isFinite(n)||!Number.isFinite(r)?null:{x:n,y:r}}catch{return null}}function T(e,t=x){try{e?localStorage.setItem(t,JSON.stringify({x:Math.round(e.x),y:Math.round(e.y)})):localStorage.removeItem(t)}catch{}}var E=4;function D(e){let[t,n]=(0,h.useState)(()=>w(e)),[r,i]=(0,h.useState)(!1),a=(0,h.useRef)(null),o=(0,h.useRef)(null),s=(0,h.useRef)(!1);(0,h.useEffect)(()=>{let e=a.current,t=e&&e.parentElement;if(!e||!t)return;let r=()=>{n(n=>{if(!n)return n;let r=t.getBoundingClientRect(),i=e.getBoundingClientRect(),a=C({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 r(),window.addEventListener(`resize`,r,{passive:!0}),()=>window.removeEventListener(`resize`,r)},[]);let c=(0,h.useCallback)(e=>{if(e.pointerType===`mouse`&&e.button!==0)return;let t=a.current,n=t&&t.parentElement;if(!t||!n)return;let r=t.style.bottom;t.style.bottom=`auto`;let i=t.getBoundingClientRect();t.style.bottom=r||``;let s=n.getBoundingClientRect();o.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startLeft:i.left-s.left,startTop:i.top-s.top,parentW:s.width,parentH:s.height,railW:i.width,railH:i.height,moved:!1};try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}},[]),l=(0,h.useCallback)(e=>{let t=o.current;if(!t||e.pointerId!==t.pointerId)return;let r=e.clientX-t.startX,a=e.clientY-t.startY;if(!t.moved){if(Math.hypot(r,a)<E)return;t.moved=!0,s.current=!0,i(!0),document.body.style.userSelect=`none`}let c=C({x:t.startLeft+r,y:t.startTop+a,parentW:t.parentW,parentH:t.parentH,railW:t.railW,railH:t.railH});c&&(t.last=c,n(c))},[]),u=(0,h.useCallback)(t=>{let n=o.current;n&&t.pointerId===n.pointerId&&(o.current=null,n.moved&&(i(!1),document.body.style.userSelect=``,T(n.last,e)))},[e]),d=(0,h.useCallback)(()=>{n(null),T(null,e)},[e]);return{railRef:a,pos:t,dragging:r,draggedRef:s,resetPos:d,handleProps:{onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:u,onDoubleClick:d}}}export{y as i,S as n,b as r,D as t};
1
+ import{d as e,f as t,h as n,i as r,l as i,t as a,u as o}from"./popup-DZ2Khv2c.js";import{C as s,D as c,E as l,M as u,O as d,S as f,d as p,j as ee,k as m}from"./md-history-DNtgaIdH.js";var h=n(t(),1),g=e(),_=a,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 te(e,{onRemove:t,onPreview:n,onPreviewMd:r,onOpenTask:i,onOpenDoc:a,onEditNote:o,onReplace:s}){let c=e.kind===`image`?m(e.id):``;return(0,g.jsxs)(`div`,{className:`att-item att-kind-${e.kind}`,children:[e.kind===`image`?(0,g.jsx)(`button`,{type:`button`,className:`att-thumb`,onClick:()=>n({src:c,name:e.name}),title:`点击看大图`,children:(0,g.jsx)(`img`,{src:c,alt:e.name,loading:`lazy`})}):(0,g.jsx)(`span`,{className:`att-kind-badge`,children:d(e.kind)}),(0,g.jsxs)(`span`,{className:`att-item-main`,children:[e.kind===`task`?(0,g.jsx)(`button`,{type:`button`,className:`att-link`,title:`跳转到任务 #${e.targetSeq??``}`,onClick:()=>i?.({key:e.targetKey,seq:e.targetSeq}),children:e.name}):e.kind===`ref`?(0,g.jsx)(`button`,{type:`button`,className:`att-link`,title:e.note||e.title||e.name||`打开文档`,onClick:()=>a?.(e.refId?`ref:`+e.refId:e.locator||e.targetRef),children:e.title||e.name}):e.kind===`url`?(0,g.jsx)(`a`,{className:`att-link`,href:e.url,target:`_blank`,rel:`noreferrer`,title:e.url,children:e.name}):(0,g.jsx)(`span`,{className:`att-item-name`,title:e.name,children:e.name}),(0,g.jsxs)(`span`,{className:`att-item-meta`,children:[e.sizeText?(0,g.jsx)(`span`,{children:e.sizeText}):null,e.kind===`mdfile`?(0,g.jsxs)(`span`,{className:`att-note`,title:e.absPath||``,children:[e.absPath||`(路径为空)`,e.missing?` · 源文件已不在`:``]}):null,e.kind===`folder`?(0,g.jsxs)(`span`,{className:`att-note`,title:e.absPath||``,children:[e.absPath||`(路径为空)`,e.missing?` · 目录已不在`:``]}):null,e.note?(0,g.jsx)(`span`,{className:`att-note`,children:e.note}):null]})]}),e.kind===`mdfile`?(0,g.jsx)(`span`,{className:`att-item-acts`,children:(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`按 md 渲染磁盘当前内容(读时核对指纹)`,onClick:()=>r?.(e),children:`预览`})}):null,e.kind===`file`||e.kind===`image`?(0,g.jsxs)(`span`,{className:`att-item-acts`,children:[(0,g.jsx)(`a`,{className:`att-act`,href:m(e.id),target:`_blank`,rel:`noreferrer`,children:`打开`}),(0,g.jsx)(`a`,{className:`att-act`,href:m(e.id),download:e.name,children:`下载`})]}):null,e.kind===`ref`?(0,g.jsxs)(`span`,{className:`att-item-acts`,children:[o?(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`改这条绑定的一行说明(交付清单会透出)`,onClick:()=>o(e),children:`✎ 说明`}):null,(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`换成另一篇文档(替换这条绑定)`,onClick:()=>s?.(e),children:`⇄ 更换`})]}):null,(0,g.jsx)(`button`,{type:`button`,className:`att-x`,"aria-label":`移除 ${e.name}`,onClick:()=>t(e),children:`×`})]},e.id)}function y({host:e=`task`,hostId:t,hostKey:n,hostCwd:a,refId:d,allow:m={file:!0,url:!0,folder:!0,task:!1,ref:!1},taskOptions:y=[],docOptions:b,disabled:x=!1,disabledText:S=`提交任务后可以在这里挂附件(当前是草稿)。`,openRef:C,onChanged:w,onOpenTask:T,onOpenDoc:E}){let D=i(),{dialog:ne,node:re}=r(),[O,k]=(0,h.useState)([]),[A,j]=(0,h.useState)(!1),[M,N]=(0,h.useState)(``),[ie,P]=(0,h.useState)(!1),[ae,F]=(0,h.useState)(!1),[oe,I]=(0,h.useState)(!1),[L,se]=(0,h.useState)(`position`),[R,z]=(0,h.useState)(null),[B,V]=(0,h.useState)(null),[H,U]=(0,h.useState)(!1),[W,G]=(0,h.useState)(null),[K,q]=(0,h.useState)(null),J=(0,h.useMemo)(()=>ee(e,{hostId:t,hostKey:n,hostCwd:a,refId:d}),[e,t,n,a,d]),Y=(0,h.useCallback)(async()=>{if(x){k([]);return}j(!0),N(``);try{let e=await J.list();k((e.attachments||[]).map(u))}catch(e){N(String(e.message||e))}finally{j(!1)}},[J,x]);(0,h.useEffect)(()=>{Y()},[Y]),(0,h.useImperativeHandle)(C,()=>({open:()=>P(!0),refresh:Y}),[Y]),(0,h.useEffect)(()=>{if(!W)return;let e=e=>{e.key===`Escape`&&G(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[W]);let X=(0,h.useMemo)(()=>[...O].sort(v[L]||v.position),[O,L]),Z=X.filter(e=>e.area===`inline`),Q=X.filter(e=>e.area===`area`),ce=async(e,t)=>{if(x)return;let n=s(t),r=n.length?n:[...e||[]].filter(e=>e&&e.size>0);if(!r.length)return;I(!0);let i=0;for(let e of r)try{let t=await l(e),n=t.fileId||t.id;if(!n)throw Error(`上传未返回 fileId`);await J.attach({fileId:n,name:t.name}),i+=1}catch(t){D(`「${e.name||`文件`}」添加失败:${t.message||t}`)}I(!1),i&&(D(`已挂到附件区 ${i} 个文件`),await Y(),w?.())},$=async r=>{if(r&&e!==`doc`)try{let e=await ne({title:`说明 · ${r.name}`,input:!0,placeholder:`这一行里大概是什么(交付清单会透出给 agent)`,value:r.note||``,okText:`保存说明`});if(e===null)return;let i=typeof e==`string`?e:e&&e.value||``,s={id:Number(t),...n?{key:n}:a?{cwd:a}:{},attachment:r.id,note:i};await o(`/api/localtasks/attach-note`,{method:`PATCH`,body:s}),D(i?`已保存说明:${i}`:`已清空说明`),await Y(),w?.()}catch(e){D(`改说明失败:${e.message||e}`)}},le=e=>{e&&(V(e),P(!0))},ue=async e=>{let t=R;if(t){U(!0);try{await J.detach(t.id,!!e),z(null),D(e?`已移除并删除资源:${t.name}`:`已解除关联:${t.name}`),await Y(),w?.()}catch(e){D(`移除失败:${e.message||e}`)}finally{U(!1)}}},de=async e=>{if(e)try{let t=await o(`/api/docs/mdfile?attachment=${encodeURIComponent(String(e.id))}`),n=String(t.body||``);q({name:e.name||`md`,html:p(n),path:String(t.absPath||e.absPath||``),stale:!!t.stale,missing:!!t.missing})}catch(e){D(`读取失败:${e.message||e}`)}},fe=!A&&!M&&!O.length;return(0,g.jsxs)(`div`,{className:`att-area${x?` is-disabled`:``}`,onDragOver:e=>{!x&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),F(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||F(!1)},onDrop:e=>{F(!1),!x&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),ce(null,e))},children:[re,(0,g.jsxs)(`div`,{className:`att-area-head`+(ae&&!x?` is-over`:``),children:[(0,g.jsxs)(`span`,{className:`att-area-title`,children:[`附件`,O.length?(0,g.jsx)(`span`,{className:`att-count`,children:O.length}):null,oe?(0,g.jsx)(`span`,{className:`att-area-note`,children:`上传中…`}):null]}),(0,g.jsxs)(`span`,{className:`att-area-acts`,children:[O.length?(0,g.jsxs)(`select`,{className:`att-sort`,value:L,onChange:e=>se(e.target.value),"aria-label":`附件排序`,children:[(0,g.jsx)(`option`,{value:`position`,children:`按添加顺序`}),(0,g.jsx)(`option`,{value:`name`,children:`按名称`}),(0,g.jsx)(`option`,{value:`kind`,children:`按类型`})]}):null,(0,g.jsx)(`button`,{type:`button`,className:`btn ghost att-add-btn`,disabled:x,onClick:()=>P(!0),children:`添加附件`})]})]}),x?(0,g.jsx)(`div`,{className:`att-empty`,children:S}):null,A?(0,g.jsx)(`div`,{className:`att-empty`,children:`加载附件…`}):null,M?(0,g.jsxs)(`div`,{className:`att-empty att-err-text`,children:[`附件加载失败:`,M]}):null,fe?(0,g.jsx)(`div`,{className:`att-empty`,children:`还没有附件。拖文件到这里,或点「添加附件」——只挂附件区,不写正文。`}):null,Z.length?(0,g.jsxs)(`div`,{className:`att-section`,children:[(0,g.jsxs)(`div`,{className:`att-section-head`,children:[c.inline,(0,g.jsx)(`span`,{className:`att-section-hint`,children:`正文里的引用,删正文行会跟着消失`})]}),Z.map(t=>te(t,{onRemove:z,onPreview:G,onPreviewMd:de,onOpenTask:T,onOpenDoc:E,onEditNote:e===`task`?$:void 0,onReplace:le,key:t.id}))]}):null,Q.length?(0,g.jsxs)(`div`,{className:`att-section`,children:[(0,g.jsxs)(`div`,{className:`att-section-head`,children:[c.area,(0,g.jsx)(`span`,{className:`att-section-hint`,children:`不依赖正文,删正文行也不会丢`})]}),Q.map(t=>te(t,{onRemove:z,onPreview:G,onPreviewMd:de,onOpenTask:T,onOpenDoc:E,onEditNote:e===`task`?$:void 0,onReplace:le,key:t.id}))]}):null,(0,g.jsx)(f,{open:ie,host:e,hostId:t,hostKey:n,hostCwd:a,refId:d,allow:m,taskOptions:y,docOptions:b,replaceAttachment:B?B.id:null,replaceNote:B&&B.note||``,onClose:()=>{P(!1),V(null)},onDone:async()=>{V(null),await Y(),w?.()}}),R?(0,g.jsx)(_,{title:`移除附件`,size:`sm`,busy:H,onClose:H?void 0:()=>z(null),footer:(0,g.jsxs)(`div`,{className:`att-foot`,children:[(0,g.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:H,onClick:()=>z(null),children:`取消`}),(0,g.jsx)(`button`,{type:`button`,className:`btn`,disabled:H,onClick:()=>ue(!1),children:`只解除关联`}),(0,g.jsx)(`button`,{type:`button`,className:`btn danger`,disabled:H,onClick:()=>ue(!0),children:R.kind===`file`?`连文件一起删`:`连资源一起删`})]}),children:(0,g.jsxs)(`div`,{className:`att-confirm`,children:[(0,g.jsx)(`div`,{className:`att-confirm-name`,children:R.name}),(0,g.jsxs)(`div`,{className:`att-confirm-text`,children:[`只解除关联:从这份`,e===`task`?`任务`:`文档`,`的附件清单里移除,资源仍留在孤儿池,可被重新挂载。 连资源一起删:在本机没有其它任务/文档引用它时,删除资源行(本机文件同时删字节);仍被引用时只解除关联。`]})]})}):null,K?(0,g.jsx)(_,{title:(0,g.jsxs)(`span`,{children:[K.name,(0,g.jsx)(`span`,{className:`att-md-path`,children:K.path})]}),size:`lg`,onClose:()=>q(null),footer:(0,g.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:()=>q(null),children:`关闭`}),children:K.missing?(0,g.jsxs)(`div`,{className:`att-empty`,children:[`源文件已不在:`,K.path||`(路径为空)`]}):(0,g.jsxs)(`div`,{className:`att-md-preview`,children:[K.stale?(0,g.jsx)(`div`,{className:`att-md-warn`,children:`内容已变化(与登记指纹不一致),以下为磁盘当前内容。`}):null,(0,g.jsx)(`article`,{dangerouslySetInnerHTML:{__html:K.html}})]})}):null,W?(0,g.jsx)(`div`,{className:`att-lightbox`,role:`dialog`,"aria-label":`图片预览`,onMouseDown:e=>{e.target===e.currentTarget&&G(null)},children:(0,g.jsxs)(`div`,{className:`att-lightbox-card`,children:[(0,g.jsxs)(`div`,{className:`att-lightbox-head`,children:[(0,g.jsx)(`span`,{className:`att-lightbox-name`,children:W.name}),(0,g.jsx)(`a`,{className:`att-lightbox-open`,href:W.src,target:`_blank`,rel:`noreferrer`,children:`新窗口打开`}),(0,g.jsx)(`button`,{type:`button`,className:`pp-x`,"aria-label":`关闭`,onClick:()=>G(null),children:`×`})]}),(0,g.jsx)(`img`,{className:`att-lightbox-img`,src:W.src,alt:W.name})]})}):null]})}function b(e=`task`,t=!0){let n=(0,h.useCallback)(t=>`nxkv.${e}Dock${t}`,[e]),[r,i]=(0,h.useState)(()=>{let e=localStorage.getItem(n(`Open`));return e===null?t:e!==`0`}),[a,o]=(0,h.useState)(()=>localStorage.getItem(n(`Tab`))||`attach`),[s,c]=(0,h.useState)(()=>{let e=Number(localStorage.getItem(n(`H`)));return Number.isFinite(e)&&e>=96?e:176}),l=(0,h.useRef)(s);l.current=s;let u=(0,h.useRef)(null),[d,f]=(0,h.useState)(!1),p=(0,h.useRef)(176);return(0,h.useEffect)(()=>{localStorage.setItem(n(`Open`),r?`1`:`0`)},[r,n]),(0,h.useEffect)(()=>{localStorage.setItem(n(`Tab`),a)},[a,n]),{dockOpen:r,setDockOpen:i,dockTab:a,setDockTab:o,dockH:s,dockHRef:l,dockRef:u,dockMax:d,setDockMax:f,dockPrevHRef:p,showDockTab:(0,h.useCallback)(e=>{o(e),i(!0)},[]),onDockDragStart:(0,h.useCallback)(e=>{if(!r)return;e.preventDefault(),f(!1);let t=e.clientY,i=l.current,a=u.current?.parentElement?.clientHeight||window.innerHeight,o=e=>Math.max(96,Math.min(Math.round(a*.62),Math.round(e))),s=e=>{let n=o(i-(e.clientY-t));l.current=n,c(n)},d=()=>{window.removeEventListener(`mousemove`,s),window.removeEventListener(`mouseup`,d),document.body.style.userSelect=``,document.body.style.cursor=``,localStorage.setItem(n(`H`),String(l.current))};document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`,window.addEventListener(`mousemove`,s),window.addEventListener(`mouseup`,d)},[r,n]),toggleDockMax:(0,h.useCallback)(()=>{if(d){c(p.current),f(!1);return}p.current=l.current;let e=u.current?.parentElement?.clientHeight||window.innerHeight,t=Math.max(96,Math.round(e*.62));l.current=t,c(t),f(!0)},[d])}}var x=`nx-kv-ack-rail-pos`,S=`nx-kv-doc-rail-pos`;function C(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=Number(t),l=Number(n),u=Number(r),d=Number(i),f=Math.max(s,u-a-s),p=Math.max(s,d-o-s);return{x:Math.min(f,Math.max(s,c)),y:Math.min(p,Math.max(s,l))}}function w(e=x){try{let t=JSON.parse(localStorage.getItem(e)||`null`);if(!t||typeof t!=`object`)return null;let n=Number(t.x),r=Number(t.y);return!Number.isFinite(n)||!Number.isFinite(r)?null:{x:n,y:r}}catch{return null}}function T(e,t=x){try{e?localStorage.setItem(t,JSON.stringify({x:Math.round(e.x),y:Math.round(e.y)})):localStorage.removeItem(t)}catch{}}var E=4;function D(e){let[t,n]=(0,h.useState)(()=>w(e)),[r,i]=(0,h.useState)(!1),a=(0,h.useRef)(null),o=(0,h.useRef)(null),s=(0,h.useRef)(!1);(0,h.useEffect)(()=>{let e=a.current,t=e&&e.parentElement;if(!e||!t)return;let r=()=>{n(n=>{if(!n)return n;let r=t.getBoundingClientRect(),i=e.getBoundingClientRect(),a=C({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 r(),window.addEventListener(`resize`,r,{passive:!0}),()=>window.removeEventListener(`resize`,r)},[]);let c=(0,h.useCallback)(e=>{if(e.pointerType===`mouse`&&e.button!==0)return;let t=a.current,n=t&&t.parentElement;if(!t||!n)return;let r=t.style.bottom;t.style.bottom=`auto`;let i=t.getBoundingClientRect();t.style.bottom=r||``;let s=n.getBoundingClientRect();o.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startLeft:i.left-s.left,startTop:i.top-s.top,parentW:s.width,parentH:s.height,railW:i.width,railH:i.height,moved:!1};try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}},[]),l=(0,h.useCallback)(e=>{let t=o.current;if(!t||e.pointerId!==t.pointerId)return;let r=e.clientX-t.startX,a=e.clientY-t.startY;if(!t.moved){if(Math.hypot(r,a)<E)return;t.moved=!0,s.current=!0,i(!0),document.body.style.userSelect=`none`}let c=C({x:t.startLeft+r,y:t.startTop+a,parentW:t.parentW,parentH:t.parentH,railW:t.railW,railH:t.railH});c&&(t.last=c,n(c))},[]),u=(0,h.useCallback)(t=>{let n=o.current;n&&t.pointerId===n.pointerId&&(o.current=null,n.moved&&(i(!1),document.body.style.userSelect=``,T(n.last,e)))},[e]),d=(0,h.useCallback)(()=>{n(null),T(null,e)},[e]);return{railRef:a,pos:t,dragging:r,draggedRef:s,resetPos:d,handleProps:{onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:u,onDoubleClick:d}}}export{y as i,S as n,b as r,D as t};
@@ -12,27 +12,26 @@
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-Byb7MFTl.js"></script>
15
+ <script type="module" crossorigin src="/assets/index-Bg0m8gbJ.js"></script>
16
16
  <link rel="modulepreload" crossorigin href="/assets/popup-DZ2Khv2c.js">
17
17
  <link rel="modulepreload" crossorigin href="/assets/workspace-DojQ3RP4.js">
18
18
  <link rel="modulepreload" crossorigin href="/assets/button-3JlUeln_.js">
19
19
  <link rel="modulepreload" crossorigin href="/assets/app-context-BqCBcDsx.js">
20
20
  <link rel="modulepreload" crossorigin href="/assets/frontmatter-CN6IlxWU.js">
21
21
  <link rel="modulepreload" crossorigin href="/assets/status-tag-8cLH8hl9.js">
22
- <link rel="modulepreload" crossorigin href="/assets/md-history-DVI47hu4.js">
23
- <link rel="modulepreload" crossorigin href="/assets/use-rail-drag-TGx8CLcY.js">
22
+ <link rel="modulepreload" crossorigin href="/assets/md-history-DNtgaIdH.js">
23
+ <link rel="modulepreload" crossorigin href="/assets/use-rail-drag-DxIYcszo.js">
24
24
  <link rel="modulepreload" crossorigin href="/assets/list-filter-CWxiOSg_.js">
25
25
  <link rel="modulepreload" crossorigin href="/assets/board-view-BVennxTs.js">
26
26
  <link rel="modulepreload" crossorigin href="/assets/route-crumb-C4DgkJ8G.js">
27
- <link rel="modulepreload" crossorigin href="/assets/doc-BmGb9F-k.js">
28
- <link rel="modulepreload" crossorigin href="/assets/repo-form-modal-BiBZ63DZ.js">
27
+ <link rel="modulepreload" crossorigin href="/assets/doc-DRSKD0Re.js">
28
+ <link rel="modulepreload" crossorigin href="/assets/repo-form-modal-Dg3hJWUV.js">
29
29
  <link rel="modulepreload" crossorigin href="/assets/model-CtG2jIDv.js">
30
- <link rel="modulepreload" crossorigin href="/assets/render-template-body-bXdedFig.js">
31
30
  <link rel="stylesheet" crossorigin href="/assets/popup-BAvk7J7u.css">
32
31
  <link rel="stylesheet" crossorigin href="/assets/button-DA4lNJeC.css">
33
32
  <link rel="stylesheet" crossorigin href="/assets/md-history-CLIs9Dr0.css">
34
33
  <link rel="stylesheet" crossorigin href="/assets/doc-Iuxssa-b.css">
35
- <link rel="stylesheet" crossorigin href="/assets/index-D1wpt-oL.css">
34
+ <link rel="stylesheet" crossorigin href="/assets/index-BIVxGd6t.css">
36
35
  </head>
37
36
  <body>
38
37
  <div id="root"></div>
@@ -1,36 +0,0 @@
1
- // 参数填写页的一次性会话(#151):从「新建任务」下拉点带槽位的模板时建立,
2
- // 路由只带 sessionId(#/templates/fill/<id>),上下文放这里,避免给 AppRoute 加
3
- // 一堆一次性的 query 键。会话是内存态——这是中间页,刷新即丢是可接受的。
4
- export interface FillSession {
5
- templateId: string;
6
- /** 可见域三把钥匙(用于主题级模板管理返回等,当前主要供展示) */
7
- topic?: string;
8
- group?: string;
9
- repo?: string;
10
- /** 新建落点:dirKey 开目录任务页;groupId 开组锚定页 */
11
- dirKey?: string;
12
- groupId?: string;
13
- /** 任务正文 frontmatter 的归属(组任务路由用) */
14
- board?: string;
15
- project?: string;
16
- /** 填完是否直接提交落库(false = 进编辑页保留草稿) */
17
- submit?: boolean;
18
- }
19
-
20
- let seq = 0;
21
- const sessions = new Map<string, FillSession>();
22
-
23
- export function putFillSession(session: FillSession): string {
24
- seq += 1;
25
- const id = `fill_${Date.now().toString(36)}_${seq}`;
26
- sessions.set(id, { ...session });
27
- return id;
28
- }
29
-
30
- export function getFillSession(id: unknown): FillSession | undefined {
31
- return sessions.get(String(id || ''));
32
- }
33
-
34
- export function dropFillSession(id: unknown): void {
35
- sessions.delete(String(id || ''));
36
- }
@@ -1,22 +0,0 @@
1
- // 「按模板新建任务」的统一入口(#151):模板正文里有 {{槽位}} 时先去参数填写
2
- // 中间页,否则直接走原来的纯文本草稿路径。目录页与组页共用这一层,避免两版
3
- // 下拉又漂移(用户明确要求「以 repo 那个为准」)。
4
- import { putFillSession, type FillSession } from './fill-session.js';
5
- import { templateSlots } from '../prompts/template-preview.js';
6
-
7
- interface NavApp {
8
- onNavigate?: (hash: string) => void;
9
- }
10
-
11
- /** 含有槽位 → 已转向参数页并返回 true;无槽位 → 调用方继续原来的新建路径。 */
12
- export function startFillIfSlotted(
13
- tpl: { id?: string; body?: unknown } | null | undefined,
14
- ctx: Omit<FillSession, 'templateId'>,
15
- app: NavApp,
16
- ): boolean {
17
- const slots = templateSlots(tpl?.body);
18
- if (!slots.length || !tpl?.id) return false;
19
- const sessionId = putFillSession({ ...ctx, templateId: String(tpl.id) });
20
- app.onNavigate?.(`#/templates/fill/${sessionId}`);
21
- return true;
22
- }
@@ -1,29 +0,0 @@
1
- // 参数填写页 → 任务编辑器的一次性意图(#151)。
2
- //
3
- // 「直接提交」按钮需要:参数页渲染出纯文本草稿 → 开任务页 → 任务页自动触发提交
4
- // 落库为待领取任务。App.openPage 的 config 只认 {dirKey|groupId, task},多带字段
5
- // 会被丢掉(路由反向映射也只认这套键),所以不往 config 里塞 autoSubmit 标志,
6
- // 改用一个以 docId 为键的一次性 intent:参数页 set,任务页 mount 时 take(取后即删)。
7
- // StrictMode 双跑 / 重复挂载都只会消费一次。
8
- export interface TaskIntent {
9
- /** 进页后自动触发 submit() 落库为待领取任务 */
10
- submit?: boolean;
11
- }
12
-
13
- const pending = new Map<string, TaskIntent>();
14
-
15
- const keyOf = (id: unknown): string => String(id || '');
16
-
17
- export function setTaskIntent(id: unknown, intent: TaskIntent): void {
18
- const k = keyOf(id);
19
- if (k) pending.set(k, { ...intent });
20
- }
21
-
22
- /** 取走并清除(同一 docId 只消费一次)。 */
23
- export function takeTaskIntent(id: unknown): TaskIntent | undefined {
24
- const k = keyOf(id);
25
- if (!k) return undefined;
26
- const v = pending.get(k);
27
- if (v) pending.delete(k);
28
- return v;
29
- }