nx-kv 0.34.0 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/package.json +1 -1
  3. package/src/modules/localtask/repo/rows.js +2 -0
  4. package/src/modules/localtask/repo/tasks.js +4 -2
  5. package/src/modules/localtask/task-lifecycle.js +21 -8
  6. package/src/modules/localtask/task-view.js +2 -0
  7. package/src/shared/feedback-text.js +118 -0
  8. package/src/web/frontend/components/md/ack-rail.jsx +14 -4
  9. package/src/web/frontend/components/md/md-panes.jsx +10 -3
  10. package/src/web/frontend/components/repos/get-loop-modal.jsx +181 -0
  11. package/src/web/frontend/components/tool-acts/layout-panel.jsx +1 -1
  12. package/src/web/frontend/components/tool-acts/modules.js +25 -0
  13. package/src/web/frontend/modules/board/ack-nodes.js +49 -1
  14. package/src/web/frontend/modules/board/reopen-text.js +32 -19
  15. package/src/web/frontend/modules/md/md-parse.js +41 -3
  16. package/src/web/frontend/modules/md/style.css +29 -8
  17. package/src/web/frontend/page/dag/index.jsx +104 -17
  18. package/src/web/frontend/page/dir/landing.jsx +3 -1
  19. package/src/web/frontend/page/dir/task.jsx +40 -3
  20. package/src/web/frontend/page/repos/index.jsx +90 -25
  21. package/src/web/frontend/page/settings/index.jsx +5 -368
  22. package/src/web/frontend/page/settings/style.css +4 -147
  23. package/src/web/frontend/style-v2.css +65 -0
  24. package/src/web/public/assets/{Introduction-DU27b_b_.js → Introduction-DO6_gTk-.js} +1 -1
  25. package/src/web/public/assets/{bar-CNuQf706.js → bar-DoiwB4eA.js} +1 -1
  26. package/src/web/public/assets/button-M9TUn-AR.js +1 -0
  27. package/src/web/public/assets/{cloud-DgNCxJsL.js → cloud-DSu1a2Dn.js} +1 -1
  28. package/src/web/public/assets/{composer-launch-BKeKTPp4.js → composer-launch-D-b7HKk5.js} +1 -1
  29. package/src/web/public/assets/{composer-panel-DP322mVs.js → composer-panel-CJuaj0Jp.js} +1 -1
  30. package/src/web/public/assets/dag-_5FWJlq5.js +1 -0
  31. package/src/web/public/assets/{dir-Cipgyv3a.js → dir-GUpDi0kq.js} +1 -1
  32. package/src/web/public/assets/{group-m61-WL4C.js → group-BzC_R2k-.js} +1 -1
  33. package/src/web/public/assets/{index-CeIJd4ee.js → index-B_HPAoNR.js} +3 -3
  34. package/src/web/public/assets/{index-BEkITE6q.css → index-CZBR0CbL.css} +1 -1
  35. package/src/web/public/assets/{md-panes-PS7K93Lg.js → md-panes-BvQXV_C9.js} +2 -2
  36. package/src/web/public/assets/{md-parse-DN9INgZn.js → md-parse-C2bDc3IZ.js} +1 -1
  37. package/src/web/public/assets/{overview-BmoTQJuu.js → overview-sLaedHVZ.js} +1 -1
  38. package/src/web/public/assets/{progress-CWy9bYKr.js → progress-DOI2YFEi.js} +1 -1
  39. package/src/web/public/assets/{refs-DAy1kYGf.js → refs-D97SxNRW.js} +1 -1
  40. package/src/web/public/assets/reopen-text-BylkngqC.js +12 -0
  41. package/src/web/public/assets/repos-ZPiaK93i.css +1 -0
  42. package/src/web/public/assets/repos-fp0D_GDq.js +10 -0
  43. package/src/web/public/assets/{route-crumb-lOriqwxP.js → route-crumb-C5LPu1Qx.js} +1 -1
  44. package/src/web/public/assets/settings-BBKNCMHm.css +1 -0
  45. package/src/web/public/assets/settings-D13mfwe0.js +6 -0
  46. package/src/web/public/assets/{status-tag-DGlwjAg2.js → status-tag-D4wxIj1q.js} +1 -1
  47. package/src/web/public/assets/task-Cu-rh5jA.js +11 -0
  48. package/src/web/public/assets/{templates-D900RS5b.js → templates-xbR-qZMs.js} +1 -1
  49. package/src/web/public/assets/tool-bar-CHoZSF6T.js +1 -0
  50. package/src/web/public/index.html +3 -3
  51. package/src/web/public/assets/button-BPYMY-zh.js +0 -1
  52. package/src/web/public/assets/dag-C4702bOt.js +0 -1
  53. package/src/web/public/assets/reopen-text-DIFfS71D.js +0 -6
  54. package/src/web/public/assets/repos-D_NT51Dq.js +0 -9
  55. package/src/web/public/assets/settings-CBrQ3Iz5.css +0 -1
  56. package/src/web/public/assets/settings-Vp3ZMC1M.js +0 -7
  57. package/src/web/public/assets/task-CRpctHxx.js +0 -9
  58. package/src/web/public/assets/tool-bar-C-rnP0vv.js +0 -1
@@ -1,4 +1,4 @@
1
- import{S as e,_ as t,l as n,o as r,v as i,y as a}from"./task-status-BP6y8MVu.js";import{a as o,c as s,l as c,o as l,s as u,u as d}from"./md-parse-DN9INgZn.js";import{E as f,N as p,k as m}from"./index-CeIJd4ee.js";import{n as h,o as g,r as _,t as v}from"./upload-L1g-pfvZ.js";import{t as y}from"./status-tag-DGlwjAg2.js";var b=e(a(),1),x=p(),S={inline:`正文内嵌`,area:`附件区`},C=e=>e===`attach`||e===`doc`?`area`:`inline`,w=/\.(png|jpe?g|gif|webp|bmp|svg)$/i;function T(e){let t=Number(e)||0;return t?t<1024?`${t} B`:t<1048576?`${(t/1024).toFixed(0)} KB`:`${(t/1024/1024).toFixed(1)} MB`:``}function E(e){return`/api/file/content/${encodeURIComponent(String(e))}`}function D(e){let t=String(e||``).replace(/\\/g,`/`);return/^(rel|path):/.test(t)?t:/^\/|[A-Za-z]:\//.test(t)?`path:${t}`:t?`rel:${t}`:``}function O(e){let t=String(e.role||`inline`),n=e.kind===`file`&&(e.isImage===!0||/^image\//i.test(e.mime||``)||w.test(e.name||``)),r=typeof e.url==`string`?e.url:e.url&&e.url.href?e.url.href:``;return{...e,role:t,area:C(t),areaLabel:S[C(t)],kind:e.kind===`file`&&n?`image`:e.kind,sizeText:T(e.size),href:e.kind===`file`?E(e.id):e.href||r,targetSeq:e.targetSeq??(e.meta&&e.meta.seq)??null,targetKey:e.targetKey||e.meta&&e.meta.topicKey||``,targetRef:e.targetKey||e.meta&&e.meta.refId||``,locator:e.locator||e.relPath||e.meta&&e.meta.locator||``}}var k={image:`图片`,file:`文件`,url:`链接`,task:`任务`,ref:`文档`},A=e=>k[e]||`附件`;function j(e,{hostId:n,hostKey:r,hostCwd:i,refId:a}){if(e===`task`){let e=r?{key:r}:i?{cwd:i}:{},a=new URLSearchParams({id:String(n)});return r?a.set(`key`,r):i&&a.set(`cwd`,i),{list:()=>t(`/api/localtasks/attachments?${a.toString()}`),attach:r=>t(`/api/localtasks/attach`,{method:`POST`,body:{id:Number(n),...e,...r,noEmbed:!0}}),detach:(r,i)=>t(`/api/localtasks/attach`,{method:`DELETE`,body:{id:Number(n),...e,attachment:r,purge:i}})}}let o=new URLSearchParams({ref:String(a||``)});return{list:()=>t(`/api/docs/attachments?${o.toString()}`),attach:e=>t(`/api/docs/attach`,{method:`POST`,body:{ref:a,...e,noEmbed:!0}}),detach:(e,n)=>t(`/api/docs/attach`,{method:`DELETE`,body:{ref:a,attachment:e,purge:n}})}}function M(e){return e.source===`file`?{fileId:e.fileId,name:e.name}:e.source===`url`?{url:e.url,name:e.name}:e.source===`task`?{task:String(e.seq),name:e.name}:e.source===`ref`?{doc:e.docRef,name:e.name}:{}}function N(e,t,n){return{value:e,start:t,end:n}}function P(e,t,n=t,r=``){if(!e)return null;let{value:i,selectionStart:a,selectionEnd:o}=e,s=i.slice(a,o)||r,c=i.slice(0,a)+t+s+n+i.slice(o),l=a+t.length;return N(c,l,l+s.length)}function F(e,t){if(!e)return null;let{value:n,selectionStart:r,selectionEnd:i}=e,a=n.lastIndexOf(`
1
+ import{S as e,_ as t,l as n,o as r,v as i,y as a}from"./task-status-BP6y8MVu.js";import{a as o,c as s,l as c,o as l,s as u,u as d}from"./md-parse-C2bDc3IZ.js";import{E as f,N as p,k as m}from"./index-B_HPAoNR.js";import{n as h,o as g,r as _,t as v}from"./upload-L1g-pfvZ.js";import{t as y}from"./status-tag-D4wxIj1q.js";var b=e(a(),1),x=p(),S={inline:`正文内嵌`,area:`附件区`},C=e=>e===`attach`||e===`doc`?`area`:`inline`,w=/\.(png|jpe?g|gif|webp|bmp|svg)$/i;function T(e){let t=Number(e)||0;return t?t<1024?`${t} B`:t<1048576?`${(t/1024).toFixed(0)} KB`:`${(t/1024/1024).toFixed(1)} MB`:``}function E(e){return`/api/file/content/${encodeURIComponent(String(e))}`}function D(e){let t=String(e||``).replace(/\\/g,`/`);return/^(rel|path):/.test(t)?t:/^\/|[A-Za-z]:\//.test(t)?`path:${t}`:t?`rel:${t}`:``}function O(e){let t=String(e.role||`inline`),n=e.kind===`file`&&(e.isImage===!0||/^image\//i.test(e.mime||``)||w.test(e.name||``)),r=typeof e.url==`string`?e.url:e.url&&e.url.href?e.url.href:``;return{...e,role:t,area:C(t),areaLabel:S[C(t)],kind:e.kind===`file`&&n?`image`:e.kind,sizeText:T(e.size),href:e.kind===`file`?E(e.id):e.href||r,targetSeq:e.targetSeq??(e.meta&&e.meta.seq)??null,targetKey:e.targetKey||e.meta&&e.meta.topicKey||``,targetRef:e.targetKey||e.meta&&e.meta.refId||``,locator:e.locator||e.relPath||e.meta&&e.meta.locator||``}}var k={image:`图片`,file:`文件`,url:`链接`,task:`任务`,ref:`文档`},A=e=>k[e]||`附件`;function j(e,{hostId:n,hostKey:r,hostCwd:i,refId:a}){if(e===`task`){let e=r?{key:r}:i?{cwd:i}:{},a=new URLSearchParams({id:String(n)});return r?a.set(`key`,r):i&&a.set(`cwd`,i),{list:()=>t(`/api/localtasks/attachments?${a.toString()}`),attach:r=>t(`/api/localtasks/attach`,{method:`POST`,body:{id:Number(n),...e,...r,noEmbed:!0}}),detach:(r,i)=>t(`/api/localtasks/attach`,{method:`DELETE`,body:{id:Number(n),...e,attachment:r,purge:i}})}}let o=new URLSearchParams({ref:String(a||``)});return{list:()=>t(`/api/docs/attachments?${o.toString()}`),attach:e=>t(`/api/docs/attach`,{method:`POST`,body:{ref:a,...e,noEmbed:!0}}),detach:(e,n)=>t(`/api/docs/attach`,{method:`DELETE`,body:{ref:a,attachment:e,purge:n}})}}function M(e){return e.source===`file`?{fileId:e.fileId,name:e.name}:e.source===`url`?{url:e.url,name:e.name}:e.source===`task`?{task:String(e.seq),name:e.name}:e.source===`ref`?{doc:e.docRef,name:e.name}:{}}function N(e,t,n){return{value:e,start:t,end:n}}function P(e,t,n=t,r=``){if(!e)return null;let{value:i,selectionStart:a,selectionEnd:o}=e,s=i.slice(a,o)||r,c=i.slice(0,a)+t+s+n+i.slice(o),l=a+t.length;return N(c,l,l+s.length)}function F(e,t){if(!e)return null;let{value:n,selectionStart:r,selectionEnd:i}=e,a=n.lastIndexOf(`
2
2
  `,r-1)+1,o=(()=>{let e=n.indexOf(`
3
3
  `,i);return e===-1?n.length:e})(),s=n.slice(a,o),c=s.split(`
4
4
  `),l=c.every(e=>e.startsWith(t)||e===``),u=c.map(e=>!e&&c.length>1?e:l?e.startsWith(t)?e.slice(t.length):e:e.startsWith(t)?e:t+e).join(`
@@ -22,7 +22,7 @@ import{S as e,_ as t,l as n,o as r,v as i,y as a}from"./task-status-BP6y8MVu.js"
22
22
  `).length,r=getComputedStyle(e),i=parseFloat(r.lineHeight);(!Number.isFinite(i)||i<=0)&&(i=(parseFloat(r.fontSize)||13)*1.7);let a=parseFloat(r.paddingTop)||0;e.scrollTop=Math.max(0,a+(n-2)*i-e.clientHeight/3)}function Y(e){if(!e)return[];let t=[];if(e.files?.length)for(let n of e.files)n&&n.size>0&&t.push(n);if(!t.length&&e.items?.length)for(let n of e.items){if(n.kind!==`file`)continue;let e=n.getAsFile();e&&e.size>0&&t.push(e)}return t}function le(e,t){let n=String(e??``),r=String(t??``),i=Math.min(n.length,r.length),a=0;for(;a<i&&n[a]===r[a];)a+=1;return a}function ue(e){if(!e)return null;let t=e.selectionStart;if(t!==e.selectionEnd||t<=0)return null;let n=e.value||``;if(n[t-1]!==`@`)return null;let r=t>=2?n[t-2]:``;return/[A-Za-z0-9_]/.test(r)?null:{at:t-1,caret:t}}function de(e){if(!e)return``;let t=String(e.name||e.title||e.locator||`附件`).replace(/[[\]]/g,``);if(e.kind===`image`||e.isImage)return r({name:t,id:e.id,kind:`image`});if(e.kind===`file`)return r({name:t,id:e.id,kind:`file`});if(e.kind===`url`){let n=e.url||e.href||``;return n?`[${t}](${n})`:``}if(e.kind===`task`){let n=e.taskId||``;return n?`[${t}](nxkv://task/${n})`:e.href?`[${t}](${e.href})`:``}if(e.kind===`ref`){let n=e.refId||``;return n?`[${t}](nxkv://ref/${n})`:e.href?`[${t}](${e.href})`:``}return``}function fe(e,t,n){let r=t&&!/\s/.test(t)?` `:``,i=n&&!/\s/.test(n)?` `:``;return{text:r+e+i,caretAt:r.length+e.length+i.length}}var X=i(),Z={file:`本机文件`,url:`外部链接`,task:`任务引用`,ref:`文档引用`},pe=0,me=()=>`p${Date.now()}-${pe+=1}`,Q=e=>(String(e&&(e.title||e.text)||``).split(/\r?\n/).map(e=>e.trim()).find(Boolean)||``).replace(/^#+\s*/,``).trim().slice(0,80);function he({open:e,host:r=`task`,hostId:i,hostKey:a,hostCwd:o,refId:s,allow:c={file:!0,url:!0,task:!1,ref:!1},taskOptions:l=[],docOptions:u=null,onClose:d,onDone:f}){let[p,m]=(0,b.useState)([]),[x,S]=(0,b.useState)(!1),[C,w]=(0,b.useState)(!1),[E,D]=(0,b.useState)(``),[O,k]=(0,b.useState)(``),[N,P]=(0,b.useState)(``),[F,I]=(0,b.useState)(``),[L,ee]=(0,b.useState)(u||[]),R=(0,b.useRef)(null),z=(0,b.useRef)(null),te=(0,b.useMemo)(()=>j(r,{hostId:i,hostKey:a,hostCwd:o,refId:s}),[r,i,a,o,s]);(0,b.useEffect)(()=>{if(!e)return;m([]),S(!1),w(!1),D(``),k(``),P(``),I(``);let t=setTimeout(()=>z.current?.focus(),0);return()=>clearTimeout(t)},[e]),(0,b.useEffect)(()=>{if(!e||u||!c.ref)return;let n=!0;return t(`/api/docs`).then(e=>{if(!n)return;let t=(e.docs||[]).map(e=>({ref:e.docId||`rel:${e.rel}`,title:e.title||e.name||e.rel,rel:e.rel}));ee(t)}).catch(()=>{}),()=>{n=!1}},[e,u,c.ref]);let B=e=>{if(!c.file)return;let t=[...e||[]].filter(e=>e&&e.size>0);t.length&&m(e=>[...e,...t.map((e,t)=>{let n=_(e,t);return{key:me(),source:`file`,file:e,name:n,mime:e.type||``,size:e.size,status:`pending`}})])},V=()=>{let e=String(E||``).trim();if(!/^https?:\/\//i.test(e)){k(`需要 http(s) 绝对地址`);return}k(``),D(``),m(t=>[...t,{key:me(),source:`url`,url:e,name:e,size:0,status:`pending`}])},H=e=>{let t=Q(e);m(n=>[...n,{key:me(),source:`task`,seq:Number(e.id),name:`#${e.id} ${t}`.trim(),size:0,status:`pending`}]),P(``)},ne=e=>{m(t=>[...t,{key:me(),source:`ref`,docRef:e.ref,name:e.title||e.name||e.rel||e.ref,rel:e.rel||``,size:0,status:`pending`}]),I(``)},U=e=>m(t=>t.filter(t=>t.key!==e)),W=async e=>{m(t=>t.map(t=>t.key===e.key?{...t,status:`uploading`,error:``}:t));try{let t=e.fileId;if(e.source===`file`&&!t){let n=await g(e.file,{local:!0});if(t=n.fileId||n.id,!t)throw Error(`上传未返回 fileId`)}return await te.attach(M({...e,fileId:t})),m(t=>t.filter(t=>t.key!==e.key)),!0}catch(t){return m(n=>n.map(n=>n.key===e.key?{...n,status:`error`,error:String(t&&t.message||t)}:n)),!1}},G=async e=>{if(C)return;let t=e?p.filter(t=>t.key===e):p;if(!t.length)return;w(!0);let n=!1,r=0;for(let e of t)await W(e)?n=!0:r+=1;w(!1),n&&f?.(),r||d?.()},K=(0,b.useMemo)(()=>{let e=N.trim().toLowerCase();return l.filter(e=>String(e.id)!==String(i)).filter(t=>!e||`${t.id} ${t.text||``}`.toLowerCase().includes(e)).slice(0,12)},[l,N,i]),q=(0,b.useMemo)(()=>{let e=F.trim().toLowerCase();return L.filter(t=>!e||`${t.title||``} ${t.rel||``} ${t.ref}`.toLowerCase().includes(e)).slice(0,12)},[L,F]),re=e=>{let t=v(e);t.length&&(e.preventDefault(),B(t))},J=p.filter(e=>e.status!==`error`).length;return e?(0,X.jsxs)(n,{title:`添加附件`,size:`md`,onClose:C?void 0:d,busy:C,className:`att-modal`,footer:(0,X.jsxs)(`div`,{className:`att-foot`,children:[(0,X.jsx)(`span`,{className:`att-foot-hint`,children:p.length?`待确认 ${J} 项${p.some(e=>e.status===`error`)?`(失败项可单独重试)`:``}`:`拖文件进来,或选择下面的来源`}),(0,X.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:C,onClick:d,children:`取消`}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:C||!J,onClick:()=>G(),children:C?`提交中…`:`确认添加`})]}),children:[(0,X.jsxs)(`div`,{ref:z,className:`att-drop`+(x?` is-over`:``),onDragOver:e=>{e.preventDefault(),S(!0)},onDragLeave:e=>{e.target===e.currentTarget&&S(!1)},onDrop:e=>{e.preventDefault(),S(!1),B(h(e))},onPaste:re,onKeyDown:e=>{e.key===`Enter`&&!e.defaultPrevented&&!/INPUT|TEXTAREA|SELECT|BUTTON/.test(e.target.tagName)&&(e.preventDefault(),G())},tabIndex:0,children:[(0,X.jsx)(`div`,{className:`att-drop-title`,children:`拖拽文件到这里,或`}),(0,X.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:()=>R.current?.click(),children:`选择文件(可多选)`}),(0,X.jsx)(`div`,{className:`att-drop-sub`,children:`支持截图直接粘贴(Ctrl/⌘ + V)`}),(0,X.jsx)(`input`,{ref:R,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=e.target.files;e.target.value=``,B(t)}})]}),c.url&&(0,X.jsxs)(`div`,{className:`att-row att-url-row`,children:[(0,X.jsx)(`input`,{className:`pp-input`,placeholder:`添加 URL(http/https)`,value:E,onChange:e=>{D(e.target.value),k(``)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),V())},spellCheck:`false`}),(0,X.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:V,children:`添加`}),O?(0,X.jsx)(`span`,{className:`att-err-text`,children:O}):null]}),c.task&&(0,X.jsxs)(`div`,{className:`att-pick`,children:[(0,X.jsx)(`div`,{className:`att-pick-head`,children:`关联任务(本主题)`}),(0,X.jsx)(`input`,{className:`pp-input`,placeholder:`搜索任务编号或标题`,value:N,onChange:e=>P(e.target.value),onKeyDown:e=>{e.key===`Enter`&&K.length&&(e.preventDefault(),H(K[0]))},spellCheck:`false`}),K.length?(0,X.jsx)(`div`,{className:`att-pick-list`,children:K.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`att-pick-item`,onClick:()=>H(e),children:[(0,X.jsxs)(`span`,{className:`att-pick-main`,children:[`#`,e.id,` `,Q(e)||`(无标题)`]}),(0,X.jsx)(y,{t:e,className:`att-sbadge`})]},e.id))}):(0,X.jsx)(`div`,{className:`att-empty-inline`,children:l.length?`没有匹配的任务`:`本主题暂无其它任务`})]}),c.ref&&(0,X.jsxs)(`div`,{className:`att-pick`,children:[(0,X.jsx)(`div`,{className:`att-pick-head`,children:`关联文档(ref)`}),(0,X.jsx)(`input`,{className:`pp-input`,placeholder:`搜索标题或路径`,value:F,onChange:e=>I(e.target.value),onKeyDown:e=>{e.key===`Enter`&&q.length&&(e.preventDefault(),ne(q[0]))},spellCheck:`false`}),q.length?(0,X.jsx)(`div`,{className:`att-pick-list`,children:q.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`att-pick-item`,onClick:()=>ne(e),children:[(0,X.jsx)(`span`,{className:`att-pick-main`,children:e.title||e.rel||e.ref}),e.rel?(0,X.jsx)(`span`,{className:`att-pick-path`,children:e.rel}):null]},e.ref))}):(0,X.jsx)(`div`,{className:`att-empty-inline`,children:L.length?`没有匹配的文档`:`文档树为空`})]}),p.length?(0,X.jsxs)(`div`,{className:`att-pending`,children:[(0,X.jsx)(`div`,{className:`att-pending-head`,children:`待确认清单`}),p.map(e=>(0,X.jsxs)(`div`,{className:`att-pending-item`+(e.status===`error`?` is-error`:``),children:[(0,X.jsx)(`span`,{className:`att-badge`,children:Z[e.source]}),(0,X.jsx)(`span`,{className:`att-pending-name`,title:e.name,children:e.name}),(0,X.jsx)(`span`,{className:`att-pending-type`,children:A(e.source===`file`?/^image\//i.test(e.mime)?`image`:`file`:e.source)}),e.size?(0,X.jsx)(`span`,{className:`att-pending-size`,children:T(e.size)}):null,e.status===`uploading`?(0,X.jsx)(`span`,{className:`att-pending-state`,children:`上传中…`}):null,e.status===`error`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`att-err-text`,title:e.error,children:e.error||`失败`}),(0,X.jsx)(`button`,{type:`button`,className:`btn ghost att-mini`,disabled:C,onClick:()=>G(e.key),children:`重试`})]}):null,(0,X.jsx)(`button`,{type:`button`,className:`att-x`,"aria-label":`移除待确认项`,disabled:C,onClick:()=>U(e.key),children:`×`})]},e.key))]}):null]}):null}function ge({host:e,itemsOverride:t=null,onInsert:n}){let[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)([]),s=e?JSON.stringify({h:e.host,id:e.hostId,k:e.hostKey,c:e.hostCwd,r:e.refId}):``,c=(0,b.useCallback)(async()=>{if(!e){o([]),i(e=>e&&{...e,loading:!1,error:``});return}try{let t=await j(e.host,e).list();o((t.attachments||[]).map(O)),i(e=>e&&{...e,loading:!1,error:``})}catch(e){o([]),i(t=>t&&{...t,loading:!1,error:String(e&&e.message||e)})}},[s]),l=(0,b.useCallback)(({index:e,ta:t,at:n,caret:r})=>{if(!t)return;let a=t.getBoundingClientRect(),o=H(t.value,r).line,s=Math.min(window.innerWidth-340,a.left+8),l=Math.min(window.innerHeight-360,a.top+o*20-t.scrollTop+8);i({index:e,at:n,caret:r,x:s,y:l,query:``,active:0,loading:!0,error:``}),c()},[s,c]),u=(0,b.useCallback)(()=>i(e=>e&&null),[]),d=t??a,f=(0,b.useMemo)(()=>{let e=String(r?.query||``).trim().toLowerCase();return e?d.filter(t=>String(t.name||t.title||t.locator||``).toLowerCase().includes(e)):d},[d,r?.query]);return{menu:r,items:f,active:f.length?Math.min(Math.max(0,r?.active??0),f.length-1):0,open:l,close:u,reload:c,move:(0,b.useCallback)((e,t)=>{i(n=>{if(!n)return n;let r=f.length;if(!r)return n;let i=t?e:((n.active+e)%r+r)%r;return{...n,active:i}})},[f.length]),setQuery:(0,b.useCallback)(e=>{i(t=>t&&{...t,query:e,active:0})},[]),pick:(0,b.useCallback)(e=>{let t=r;if(i(null),!e||!t)return;let a=de(e);a&&n({index:t.index,embed:a,at:t.at,caret:t.caret})},[r,n])}}function _e({items:e,query:t,onQuery:n,active:r,onHover:i,onPick:a,loading:o,error:s,position:c,host:l=null,onReload:u=null,onAddFiles:d=null}){let p=(0,b.useRef)(null),h=(0,b.useRef)(null),g=(0,b.useRef)(null),_=m()||{},[v,y]=(0,b.useState)(!1);(0,b.useEffect)(()=>{h.current?.focus()},[]),(0,b.useEffect)(()=>{let e=p.current;e&&e.querySelector(`.mdw-atpick-item.on`)?.scrollIntoView?.({block:`nearest`})},[r,e]);let x=e=>{let t=_.model;if(t){if(e.kind===`task`&&e.topicKey&&e.seq){f(t,{component:`page`,name:`原文 #${e.seq}`,config:{dirKey:String(e.topicKey),task:String(e.seq)}});return}if(e.kind===`ref`){let n=D(e.locator||e.relPath||``);if(!n)return;f(t,{component:`doc`,name:e.title||e.name||`文档`,config:{docId:n}})}}},S=e=>e.kind===`task`?!!(e.topicKey&&e.seq):e.kind===`ref`&&!!(e.refId||e.locator||e.relPath);return(0,X.jsxs)(`div`,{className:`mdw-atpick`,role:`dialog`,"aria-label":`选择附件`,style:c,children:[(0,X.jsx)(`div`,{className:`mdw-atpick-search`,children:(0,X.jsx)(`input`,{ref:h,value:t,onChange:e=>n(e.target.value),placeholder:`搜索附件…`,"aria-label":`搜索附件`,onKeyDown:t=>{if(t.key===`ArrowDown`||t.key===`ArrowUp`){t.preventDefault(),i(t.key===`ArrowDown`?1:-1);return}if(t.key===`Enter`){t.preventDefault(),e[r]&&a(e[r]);return}t.key===`Escape`&&(t.preventDefault(),a(null))}})}),o?(0,X.jsx)(`div`,{className:`mdw-atpick-empty`,children:`读取附件…`}):s?(0,X.jsxs)(`div`,{className:`mdw-atpick-empty`,children:[`读取失败:`,s]}):e.length?(0,X.jsx)(`div`,{className:`mdw-atpick-list`,ref:p,children:e.map((e,t)=>{let n=e.name||e.title||e.locator||`附件`,o=S(e);return(0,X.jsxs)(`div`,{className:`mdw-atpick-row`,children:[(0,X.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===r,className:`mdw-atpick-item${t===r?` on`:``}`,onMouseEnter:()=>i(t,!0),onMouseDown:t=>{t.preventDefault(),a(e)},children:[(0,X.jsx)(`span`,{className:`lab`,title:n,children:n}),(0,X.jsx)(`span`,{className:`hint`,children:[e.kindLabel||e.badge,e.sizeText,e.areaLabel].filter(Boolean).join(` · `)})]}),o&&(0,X.jsx)(`button`,{type:`button`,className:`mdw-atpick-open`,title:`在右侧并排显示原文,方便对照`,"aria-label":`查看原文:${n}`,onMouseDown:t=>{t.preventDefault(),x(e)},children:`↗`})]},e.id||e.url||e.refId||e.taskId||t)})}):(0,X.jsx)(`div`,{className:`mdw-atpick-empty`,children:t?`没有匹配的附件`:`这条任务还没有附件`}),(0,X.jsxs)(`div`,{className:`mdw-atpick-foot`,children:[(0,X.jsx)(`span`,{className:`mdw-atpick-cap`,children:`↑↓ 选择 · Enter 引用 · Esc 取消`}),(0,X.jsx)(`span`,{className:`grow`}),l?(0,X.jsx)(`button`,{type:`button`,className:`mdw-atpick-add`,title:`添加附件(本机文件 / 外部链接 / 任务 / 文档)`,onMouseDown:e=>e.preventDefault(),onClick:()=>y(!0),children:`+ 添加附件`}):d?(0,X.jsx)(`button`,{type:`button`,className:`mdw-atpick-add`,title:`上传本机文件(草稿:先挂进会话草稿,提交任务时一并带上)`,onMouseDown:e=>e.preventDefault(),onClick:()=>g.current?.click(),children:`+ 添加附件`}):null]}),d&&(0,X.jsx)(`input`,{ref:g,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);t.length&&d(t),g.current&&(g.current.value=``)}}),l&&(0,X.jsx)(he,{open:v,host:l.host,hostId:l.hostId,hostKey:l.hostKey,hostCwd:l.hostCwd,refId:l.refId,allow:l.allow,taskOptions:l.taskOptions,docOptions:l.docOptions,onClose:()=>y(!1),onDone:async()=>{await u?.()}})]})}var ve={b:`bold`,i:`italic`,e:`code`,k:`link`};function ye(e){let t=String(e||``).replace(/^\uFEFF/,``).trimStart();if(t.startsWith(`---`)){let e=t.indexOf(`
23
23
  ---`,3);e>0&&(t=t.slice(e+4).trimStart())}return/^#[ \t]+\S/.test(t)}function be(e){e&&(e.style.height=`0px`,e.style.height=`${e.scrollHeight}px`)}function xe(e,t){let n=c(e);if(!n.trim())return``;let r=(t||[]).filter(e=>e?.type===`image`);return d(n,r).replace(/<p class="mdw-empty">[\s\S]*?<\/p>/g,``)}function Se(e){let t=String(e||``);return/^---\s*$/.test(t.split(`
24
24
  `,1)[0]||``)&&t.includes(`
25
- `)?`fm`:/^#\s/m.test(t)&&!/^##/m.test(t)?`h1`:/^##\s/m.test(t)&&!/^###/m.test(t)?`h2`:/^###\s/m.test(t)?`h3`:/^[-*]\s/m.test(t)?`li`:/^>\s/m.test(t)?`quote`:`p`}function Ce({index:e,text:t,focused:n,hit:r,onFocus:i,onToggleTodo:a,onChange:s,onBlur:u,onKeyDown:d,onPasteFiles:f,onTaReady:p,onTextSel:m,attachments:h,pendingSelRef:g,pendingFormatRef:_}){let v=(0,b.useRef)(null),y=c(t),x=l(y)?``:xe(y,h),S=Se(y);return(0,b.useLayoutEffect)(()=>{if(!n||!v.current)return;let t=v.current;p?.(t),be(t);let r=g?.current;if(r&&r.index===e){g.current=null,t.focus();try{t.setSelectionRange(r.start,r.end)}catch{}let e=_?.current;if(e){_.current=null;let n=z(t,e);n&&s(n.value)}return}if(document.activeElement!==t){if(document.activeElement?.closest?.(`.mdw-atpick`))return;t.focus();let e=t.value.length;try{t.setSelectionRange(e,e)}catch{}}},[n,t,e,g,_,p,s]),n?(0,X.jsx)(`div`,{className:`mdw-lp-block is-edit kind-${S}`,"data-i":e,children:(0,X.jsx)(`textarea`,{ref:v,className:`mdw-lp-src`,value:y,rows:1,spellCheck:!1,"aria-label":`正文`,placeholder:`输入… Enter 新块 · 行首 / 命令`,onChange:e=>{s(e.target.value),be(e.target)},onBlur:u,onKeyDown:d,onPaste:e=>{let t=Y(e.clipboardData);t.length&&(e.preventDefault(),f?.(t,v.current))},onMouseUp:e=>{let t=v.current;if(!t||t.selectionStart===t.selectionEnd)return;let n=t.value.slice(t.selectionStart,t.selectionEnd);n&&m?.({text:n,x:e.clientX-80,y:e.clientY-44})}})}):(0,X.jsx)(`div`,{className:`mdw-lp-block is-view kind-${S}${o(t)?` is-empty`:``}${r?` is-hit`:``}`,"data-i":e,role:`button`,tabIndex:0,onClick:t=>{let n=t.target.closest?.(`.mdw-cb`);if(n){t.stopPropagation();let r=[...t.currentTarget.querySelectorAll(`.mdw-cb`)];a?.(e,r.indexOf(n));return}let r=window.getSelection();r&&!r.isCollapsed&&String(r).trim()||i(e)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),i(e))},children:x?(0,X.jsx)(`div`,{className:`mdw-lp-view`,dangerouslySetInnerHTML:{__html:x}}):(0,X.jsx)(`div`,{className:`mdw-lp-gap`})})}function we(e){return s(e)}function Te(e){return e.key===`ArrowDown`||e.key===`ArrowUp`||e.code===`ArrowDown`||e.code===`ArrowUp`}function $(e){if(!e?.items?.length)return 0;let t=e.active;return typeof t!=`number`||Number.isNaN(t)?0:Math.min(Math.max(0,t),e.items.length-1)}function Ee(e,t,{move:n,pick:r,close:i}){let a=t.current;return a?.items?.length?Te(e)?(e.preventDefault(),e.stopPropagation(),n(e.key===`ArrowUp`||e.code===`ArrowUp`?-1:1),!0):e.key===`Enter`||e.key===`Tab`?(e.preventDefault(),e.stopPropagation(),r(a.items[$(a)]),!0):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i(),!0):!1}function De({items:e,active:t,onPick:n,onHover:r,style:i}){let a=(0,b.useRef)(null),o=$({items:e,active:t});return(0,b.useEffect)(()=>{let e=a.current;e&&e.querySelector(`.mdw-slash-item.on`)?.scrollIntoView?.({block:`nearest`})},[o,e]),e.length?(0,X.jsxs)(`div`,{ref:a,className:`mdw-slash`,role:`listbox`,"aria-activedescendant":`mdw-slash-opt-${o}`,style:i,onMouseDown:e=>e.preventDefault(),children:[(0,X.jsx)(`div`,{className:`mdw-slash-cap`,children:`插入 · ↑↓ 选择 · Enter 确认`}),e.map((e,t)=>(0,X.jsxs)(`button`,{id:`mdw-slash-opt-${t}`,type:`button`,role:`option`,tabIndex:-1,"aria-selected":t===o,className:`mdw-slash-item${t===o?` on`:``}`,onMouseEnter:()=>r(t),onMouseDown:t=>{t.preventDefault(),n(e)},children:[(0,X.jsx)(`span`,{className:`lab`,children:e.label}),(0,X.jsx)(`span`,{className:`hint`,children:e.hint})]},e.id))]}):null}function Oe({value:e,onTitle:t,placeholder:n,className:r,onFocus:i,onEnter:a}){let o=(0,b.useRef)(null);return(0,b.useLayoutEffect)(()=>{let e=o.current;if(!e)return;let t=()=>{e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`};t();let n=null;return typeof ResizeObserver<`u`?(n=new ResizeObserver(()=>t()),n.observe(e)):window.addEventListener(`resize`,t),()=>{n?n.disconnect():window.removeEventListener(`resize`,t)}},[e]),(0,X.jsx)(`textarea`,{ref:o,className:r,value:e,placeholder:n,rows:1,spellCheck:!1,"aria-label":`标题`,onChange:e=>t(e.target.value,`typing`),onFocus:i,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),a?.())}})}function ke({title:e,body:t,onTitle:n,onBody:r,articleRef:i,attachments:a,docKey:s,onFiles:d,editorApiRef:f,onTextSel:p,onCloseSelMenu:m,hideTitle:h=!1,attachHost:g=null}){let[_,v]=(0,b.useState)(null),[y,S]=(0,b.useState)(!1),[C,w]=(0,b.useState)(null),T=(0,b.useRef)(null),E=(0,b.useRef)(null),D=(0,b.useRef)(null),O=(0,b.useRef)(null),k=(0,b.useRef)(0),A=we(t),[j,M]=(0,b.useState)(!1),[N,P]=(0,b.useState)(``),[F,I]=(0,b.useState)(0),R=(0,b.useRef)(null),V=(0,b.useMemo)(()=>{let e=N.trim().toLowerCase();if(!e)return[];let t=[];return A.forEach((n,r)=>{let i=String(n??``).toLowerCase(),a=i.indexOf(e);for(;a!==-1;)t.push({block:r,start:a}),a=i.indexOf(e,a+e.length)}),t},[A,N]),H=e=>{let t=V.length;if(!t)return;let n=(e%t+t)%t;I(n);let r=V[n];(i.current?.querySelector(`.mdw-lp-block[data-i="${r.block}"]`))?.scrollIntoView?.({block:`center`})},ne=V[F]?.block??-1,U=A.length===0||A.every(e=>!String(e).trim()),W=e=>{let t=typeof e==`function`?e(O.current):e;O.current=t,w(t)};(0,b.useEffect)(()=>{v(null),W(null)},[s]),(0,b.useEffect)(()=>{O.current=C},[C]);let G=(e,t=`op`)=>r(u(e),t),K=(e,t,n=`op`)=>{let r=A.slice();r[e]=t,G(r,n)},q=(e,t)=>{t&&(T.current={index:e,start:t.start,end:t.end},K(e,t.value))},J=(e,t)=>{let n=ie(t);if(!n){W(null);return}let r=ae(n.query);if(!r.length){W(null);return}let i=t.getBoundingClientRect(),a=Math.min(window.innerWidth-220,i.left),o=Math.min(window.innerHeight-220,i.bottom+4);W(t=>{let i=t&&t.index===e&&t.query===n.query?$({...t,items:r}):0;return{index:e,query:n.query,items:r,active:i,x:a,y:o}})},se=e=>{W(t=>{if(!t?.items?.length)return t;let n=t.items.length,r=$(t);return{...t,active:(r+e+n)%n}})},ce=e=>{let t=D.current,n=O.current?.index??_;if(!t||n==null||!e)return;let r=oe(t,e);W(null),r&&q(n,r)},de=(0,b.useMemo)(()=>g?null:(a||[]).filter(e=>e.type===`image`).map(e=>({kind:`image`,id:e.name,name:e.name,sizeText:e.size})),[g,a]),Z=ge({host:g,itemsOverride:g?null:de,onInsert:({index:e,embed:t,at:n,caret:r})=>{let i=c(A[e]??``),a=fe(t,n>0?i[n-1]:``,i[r]||``),o=i.slice(0,n)+a.text+i.slice(r),s=n+a.caretAt;K(e,o),T.current={index:e,start:s,end:s},v(e)}}),pe=e=>{let t=Z.menu,n=t?{index:t.index,at:t.at,caret:t.caret}:{index:_??0,at:null,caret:null};if(t){let e=c(A[t.index]??``);K(t.index,e.slice(0,t.at)+e.slice(t.caret))}requestAnimationFrame(()=>{d?.(e,{mode:`live`,focusIndex:n.index,...n.at==null?{}:{caretInBlock:n.at}})})},me=(e,t)=>{let n=D.current,r=re(n&&_===e?n:{value:c(A[e]??``),selectionStart:0,selectionEnd:0},t);r&&(q(e,r),v(e))},Q=(0,b.useCallback)((e,t)=>{if(!Number.isInteger(e)||!Number.isInteger(t)||e<0||t<e||t>=A.length)return!1;let n=A.slice();n.splice(e,t-e+1),G(n);let r=Math.min(e,Math.max(0,n.length-1));return T.current={index:r,start:0,end:0},v(r),!0},[A,r]);(0,b.useImperativeHandle)(f,()=>({format(e){let t=D.current;t&&_!=null&&(t.focus(),q(_,z(t,e)))},turn(e){me(_??0,e)},focus(){D.current?.focus()},openFind(){M(!0),requestAnimationFrame(()=>R.current?.focus())},formatSelection(e){let t=window.getSelection();if(!t||t.isCollapsed)return!1;let n=String(t.toString()||``);if(!n.trim())return!1;let r=t.anchorNode,a=(r?.nodeType===3?r.parentElement:r)?.closest?.(`.mdw-lp-block`);if(!a||!i.current?.contains(a))return!1;let o=Number(a.getAttribute(`data-i`));if(!Number.isInteger(o)||o<0||o>=A.length)return!1;let s=c(A[o]??``).indexOf(n);return s!==-1&&(T.current={index:o,start:s,end:s+n.length},E.current=e,m?.(),v(o),!0)},deleteBlockRange(e,t){return Q(e,t)},caretFromDiff(e,t){let n=le(u(we(e)),u(we(t))),r=0;for(let e=0;e<A.length;e+=1){let t=u(A.slice(0,e+1)).length;if(n<=t){let t=Math.max(0,Math.min(n-r,c(A[e]??``).length));if(_===e){let e=D.current;e&&(e.focus(),e.setSelectionRange(t,t))}else T.current={index:e,start:t,end:t},v(e);return}r=t+2}}}),[_,r,A,Q]),(0,b.useEffect)(()=>{if(!C)return;let e=e=>{Ee(e,O,{move:se,pick:ce,close:()=>W(null)})};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[C]),(0,b.useEffect)(()=>{let e=e=>{if(e.key!==`Backspace`&&e.key!==`Delete`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target;if(t&&(t.tagName===`TEXTAREA`||t.tagName===`INPUT`||t.isContentEditable))return;let n=window.getSelection();if(!n||n.isCollapsed||n.rangeCount===0)return;let r=String(n.toString()||``);if(!r.trim())return;let a=e=>e?.nodeType===3?e.parentElement:e,o=a(n.anchorNode)?.closest?.(`.mdw-lp-block`);if(!o||!i.current?.contains(o))return;let s=Number(o.getAttribute(`data-i`));if(!Number.isInteger(s)||s<0||s>=A.length)return;let l=a(n.focusNode)?.closest?.(`.mdw-lp-block`);if(l&&l!==o&&i.current?.contains(l)){let t=Number(l.getAttribute(`data-i`));Number.isInteger(t)&&t>=0&&t<A.length&&t!==s&&(e.preventDefault(),Q(Math.min(s,t),Math.max(s,t)),m?.());return}let u=c(A[s]??``),d=u.indexOf(r);d!==-1&&(e.preventDefault(),K(s,u.slice(0,d)+u.slice(d+r.length)),T.current={index:s,start:d,end:d},m?.(),v(s))};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[A,r,i,m,Q]);let he=(e,t)=>{let n=c(A[e]??``),r=t.target;if(D.current=r,t.nativeEvent?.isComposing||t.keyCode===229||Ee(t,O,{move:se,pick:ce,close:()=>W(null)}))return;if(t.key===`Escape`){t.preventDefault(),W(null),r.blur(),v(null);return}let i=t.metaKey||t.ctrlKey;if(i&&!t.altKey){let n=t.key.toLowerCase(),i={b:`bold`,i:`italic`,e:`code`,k:`link`};if(i[n]){t.preventDefault(),q(e,z(r,i[n]));return}}if(t.key===`Tab`){t.preventDefault(),q(e,L(r,t.shiftKey));return}if(t.key===`Enter`&&!t.shiftKey&&!i){let i=ee(r);if(i){t.preventDefault(),q(e,i);return}t.preventDefault(),W(null);let a=r.selectionStart,o=r.selectionEnd,s=n.slice(0,a).replace(/\n+$/,``),c=n.slice(o),l=A.slice();l[e]=s,l.splice(e+1,0,c),T.current={index:e+1,start:0,end:0},G(l),v(e+1);return}if(t.key===`Backspace`&&o(n)&&e===0&&A.length>1){t.preventDefault(),W(null);let n=A.slice();n.splice(e,1),G(n),v(0);return}if(t.key===`Backspace`&&r.selectionStart===0&&r.selectionEnd===0&&e>0&&!O.current&&!l(c(A[e-1]??``))){t.preventDefault(),W(null);let r=c(A[e-1]??``),i=A.slice();i[e-1]=r+n,i.splice(e,1),T.current={index:e-1,start:r.length,end:r.length},G(i),v(e-1);return}if(t.key===`Backspace`&&r.selectionStart===r.selectionEnd&&!O.current){let i=r.selectionStart,a=n.lastIndexOf(`
25
+ `)?`fm`:/^#\s/m.test(t)&&!/^##/m.test(t)?`h1`:/^##\s/m.test(t)&&!/^###/m.test(t)?`h2`:/^###\s/m.test(t)?`h3`:/^[-*]\s/m.test(t)?`li`:/^>\s/m.test(t)?`quote`:`p`}function Ce({index:e,text:t,focused:n,hit:r,onFocus:i,onToggleTodo:a,onChange:s,onBlur:u,onKeyDown:d,onPasteFiles:f,onTaReady:p,onTextSel:m,attachments:h,pendingSelRef:g,pendingFormatRef:_}){let v=(0,b.useRef)(null),y=c(t),x=l(y),S=x?``:xe(y,h),C=Se(y);return(0,b.useLayoutEffect)(()=>{if(!n||!v.current)return;let t=v.current;p?.(t),be(t);let r=g?.current;if(r&&r.index===e){g.current=null,t.focus();try{t.setSelectionRange(r.start,r.end)}catch{}let e=_?.current;if(e){_.current=null;let n=z(t,e);n&&s(n.value)}return}if(document.activeElement!==t){if(document.activeElement?.closest?.(`.mdw-atpick`))return;t.focus();let e=t.value.length;try{t.setSelectionRange(e,e)}catch{}}},[n,t,e,g,_,p,s]),x?null:n?(0,X.jsx)(`div`,{className:`mdw-lp-block is-edit kind-${C}`,"data-i":e,children:(0,X.jsx)(`textarea`,{ref:v,className:`mdw-lp-src`,value:y,rows:1,spellCheck:!1,"aria-label":`正文`,placeholder:`输入… Enter 新块 · 行首 / 命令`,onChange:e=>{s(e.target.value),be(e.target)},onBlur:u,onKeyDown:d,onPaste:e=>{let t=Y(e.clipboardData);t.length&&(e.preventDefault(),f?.(t,v.current))},onMouseUp:e=>{let t=v.current;if(!t||t.selectionStart===t.selectionEnd)return;let n=t.value.slice(t.selectionStart,t.selectionEnd);n&&m?.({text:n,x:e.clientX-80,y:e.clientY-44})}})}):(0,X.jsx)(`div`,{className:`mdw-lp-block is-view kind-${C}${o(t)?` is-empty`:``}${r?` is-hit`:``}`,"data-i":e,role:`button`,tabIndex:0,onClick:t=>{let n=t.target.closest?.(`.mdw-cb`);if(n){t.stopPropagation();let r=[...t.currentTarget.querySelectorAll(`.mdw-cb`)];a?.(e,r.indexOf(n));return}let r=window.getSelection();r&&!r.isCollapsed&&String(r).trim()||i(e)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),i(e))},children:S?(0,X.jsx)(`div`,{className:`mdw-lp-view`,dangerouslySetInnerHTML:{__html:S}}):(0,X.jsx)(`div`,{className:`mdw-lp-gap`})})}function we(e){return s(e)}function Te(e){return e.key===`ArrowDown`||e.key===`ArrowUp`||e.code===`ArrowDown`||e.code===`ArrowUp`}function $(e){if(!e?.items?.length)return 0;let t=e.active;return typeof t!=`number`||Number.isNaN(t)?0:Math.min(Math.max(0,t),e.items.length-1)}function Ee(e,t,{move:n,pick:r,close:i}){let a=t.current;return a?.items?.length?Te(e)?(e.preventDefault(),e.stopPropagation(),n(e.key===`ArrowUp`||e.code===`ArrowUp`?-1:1),!0):e.key===`Enter`||e.key===`Tab`?(e.preventDefault(),e.stopPropagation(),r(a.items[$(a)]),!0):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i(),!0):!1}function De({items:e,active:t,onPick:n,onHover:r,style:i}){let a=(0,b.useRef)(null),o=$({items:e,active:t});return(0,b.useEffect)(()=>{let e=a.current;e&&e.querySelector(`.mdw-slash-item.on`)?.scrollIntoView?.({block:`nearest`})},[o,e]),e.length?(0,X.jsxs)(`div`,{ref:a,className:`mdw-slash`,role:`listbox`,"aria-activedescendant":`mdw-slash-opt-${o}`,style:i,onMouseDown:e=>e.preventDefault(),children:[(0,X.jsx)(`div`,{className:`mdw-slash-cap`,children:`插入 · ↑↓ 选择 · Enter 确认`}),e.map((e,t)=>(0,X.jsxs)(`button`,{id:`mdw-slash-opt-${t}`,type:`button`,role:`option`,tabIndex:-1,"aria-selected":t===o,className:`mdw-slash-item${t===o?` on`:``}`,onMouseEnter:()=>r(t),onMouseDown:t=>{t.preventDefault(),n(e)},children:[(0,X.jsx)(`span`,{className:`lab`,children:e.label}),(0,X.jsx)(`span`,{className:`hint`,children:e.hint})]},e.id))]}):null}function Oe({value:e,onTitle:t,placeholder:n,className:r,onFocus:i,onEnter:a}){let o=(0,b.useRef)(null);return(0,b.useLayoutEffect)(()=>{let e=o.current;if(!e)return;let t=()=>{e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`};t();let n=null;return typeof ResizeObserver<`u`?(n=new ResizeObserver(()=>t()),n.observe(e)):window.addEventListener(`resize`,t),()=>{n?n.disconnect():window.removeEventListener(`resize`,t)}},[e]),(0,X.jsx)(`textarea`,{ref:o,className:r,value:e,placeholder:n,rows:1,spellCheck:!1,"aria-label":`标题`,onChange:e=>t(e.target.value,`typing`),onFocus:i,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),a?.())}})}function ke({title:e,body:t,onTitle:n,onBody:r,articleRef:i,attachments:a,docKey:s,onFiles:d,editorApiRef:f,onTextSel:p,onCloseSelMenu:m,hideTitle:h=!1,attachHost:g=null}){let[_,v]=(0,b.useState)(null),[y,S]=(0,b.useState)(!1),[C,w]=(0,b.useState)(null),T=(0,b.useRef)(null),E=(0,b.useRef)(null),D=(0,b.useRef)(null),O=(0,b.useRef)(null),k=(0,b.useRef)(0),A=we(t),[j,M]=(0,b.useState)(!1),[N,P]=(0,b.useState)(``),[F,I]=(0,b.useState)(0),R=(0,b.useRef)(null),V=(0,b.useMemo)(()=>{let e=N.trim().toLowerCase();if(!e)return[];let t=[];return A.forEach((n,r)=>{let i=String(n??``).toLowerCase(),a=i.indexOf(e);for(;a!==-1;)t.push({block:r,start:a}),a=i.indexOf(e,a+e.length)}),t},[A,N]),H=e=>{let t=V.length;if(!t)return;let n=(e%t+t)%t;I(n);let r=V[n];(i.current?.querySelector(`.mdw-lp-block[data-i="${r.block}"]`))?.scrollIntoView?.({block:`center`})},ne=V[F]?.block??-1,U=A.length===0||A.every(e=>!String(e).trim()),W=e=>{let t=typeof e==`function`?e(O.current):e;O.current=t,w(t)};(0,b.useEffect)(()=>{v(null),W(null)},[s]),(0,b.useEffect)(()=>{O.current=C},[C]);let G=(e,t=`op`)=>r(u(e),t),K=(e,t,n=`op`)=>{let r=A.slice();r[e]=t,G(r,n)},q=(e,t)=>{t&&(T.current={index:e,start:t.start,end:t.end},K(e,t.value))},J=(e,t)=>{let n=ie(t);if(!n){W(null);return}let r=ae(n.query);if(!r.length){W(null);return}let i=t.getBoundingClientRect(),a=Math.min(window.innerWidth-220,i.left),o=Math.min(window.innerHeight-220,i.bottom+4);W(t=>{let i=t&&t.index===e&&t.query===n.query?$({...t,items:r}):0;return{index:e,query:n.query,items:r,active:i,x:a,y:o}})},se=e=>{W(t=>{if(!t?.items?.length)return t;let n=t.items.length,r=$(t);return{...t,active:(r+e+n)%n}})},ce=e=>{let t=D.current,n=O.current?.index??_;if(!t||n==null||!e)return;let r=oe(t,e);W(null),r&&q(n,r)},de=(0,b.useMemo)(()=>g?null:(a||[]).filter(e=>e.type===`image`).map(e=>({kind:`image`,id:e.name,name:e.name,sizeText:e.size})),[g,a]),Z=ge({host:g,itemsOverride:g?null:de,onInsert:({index:e,embed:t,at:n,caret:r})=>{let i=c(A[e]??``),a=fe(t,n>0?i[n-1]:``,i[r]||``),o=i.slice(0,n)+a.text+i.slice(r),s=n+a.caretAt;K(e,o),T.current={index:e,start:s,end:s},v(e)}}),pe=e=>{let t=Z.menu,n=t?{index:t.index,at:t.at,caret:t.caret}:{index:_??0,at:null,caret:null};if(t){let e=c(A[t.index]??``);K(t.index,e.slice(0,t.at)+e.slice(t.caret))}requestAnimationFrame(()=>{d?.(e,{mode:`live`,focusIndex:n.index,...n.at==null?{}:{caretInBlock:n.at}})})},me=(e,t)=>{let n=D.current,r=re(n&&_===e?n:{value:c(A[e]??``),selectionStart:0,selectionEnd:0},t);r&&(q(e,r),v(e))},Q=(0,b.useCallback)((e,t)=>{if(!Number.isInteger(e)||!Number.isInteger(t)||e<0||t<e||t>=A.length)return!1;let n=A.slice();n.splice(e,t-e+1),G(n);let r=Math.min(e,Math.max(0,n.length-1));return T.current={index:r,start:0,end:0},v(r),!0},[A,r]);(0,b.useImperativeHandle)(f,()=>({format(e){let t=D.current;t&&_!=null&&(t.focus(),q(_,z(t,e)))},turn(e){me(_??0,e)},focus(){D.current?.focus()},openFind(){M(!0),requestAnimationFrame(()=>R.current?.focus())},formatSelection(e){let t=window.getSelection();if(!t||t.isCollapsed)return!1;let n=String(t.toString()||``);if(!n.trim())return!1;let r=t.anchorNode,a=(r?.nodeType===3?r.parentElement:r)?.closest?.(`.mdw-lp-block`);if(!a||!i.current?.contains(a))return!1;let o=Number(a.getAttribute(`data-i`));if(!Number.isInteger(o)||o<0||o>=A.length)return!1;let s=c(A[o]??``).indexOf(n);return s!==-1&&(T.current={index:o,start:s,end:s+n.length},E.current=e,m?.(),v(o),!0)},deleteBlockRange(e,t){return Q(e,t)},caretFromDiff(e,t){let n=le(u(we(e)),u(we(t))),r=0;for(let e=0;e<A.length;e+=1){let t=u(A.slice(0,e+1)).length;if(n<=t){let t=Math.max(0,Math.min(n-r,c(A[e]??``).length));if(_===e){let e=D.current;e&&(e.focus(),e.setSelectionRange(t,t))}else T.current={index:e,start:t,end:t},v(e);return}r=t+2}}}),[_,r,A,Q]),(0,b.useEffect)(()=>{if(!C)return;let e=e=>{Ee(e,O,{move:se,pick:ce,close:()=>W(null)})};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[C]),(0,b.useEffect)(()=>{let e=e=>{if(e.key!==`Backspace`&&e.key!==`Delete`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target;if(t&&(t.tagName===`TEXTAREA`||t.tagName===`INPUT`||t.isContentEditable))return;let n=window.getSelection();if(!n||n.isCollapsed||n.rangeCount===0)return;let r=String(n.toString()||``);if(!r.trim())return;let a=e=>e?.nodeType===3?e.parentElement:e,o=a(n.anchorNode)?.closest?.(`.mdw-lp-block`);if(!o||!i.current?.contains(o))return;let s=Number(o.getAttribute(`data-i`));if(!Number.isInteger(s)||s<0||s>=A.length)return;let l=a(n.focusNode)?.closest?.(`.mdw-lp-block`);if(l&&l!==o&&i.current?.contains(l)){let t=Number(l.getAttribute(`data-i`));Number.isInteger(t)&&t>=0&&t<A.length&&t!==s&&(e.preventDefault(),Q(Math.min(s,t),Math.max(s,t)),m?.());return}let u=c(A[s]??``),d=u.indexOf(r);d!==-1&&(e.preventDefault(),K(s,u.slice(0,d)+u.slice(d+r.length)),T.current={index:s,start:d,end:d},m?.(),v(s))};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[A,r,i,m,Q]);let he=(e,t)=>{let n=c(A[e]??``),r=t.target;if(D.current=r,t.nativeEvent?.isComposing||t.keyCode===229||Ee(t,O,{move:se,pick:ce,close:()=>W(null)}))return;if(t.key===`Escape`){t.preventDefault(),W(null),r.blur(),v(null);return}let i=t.metaKey||t.ctrlKey;if(i&&!t.altKey){let n=t.key.toLowerCase(),i={b:`bold`,i:`italic`,e:`code`,k:`link`};if(i[n]){t.preventDefault(),q(e,z(r,i[n]));return}}if(t.key===`Tab`){t.preventDefault(),q(e,L(r,t.shiftKey));return}if(t.key===`Enter`&&!t.shiftKey&&!i){let i=ee(r);if(i){t.preventDefault(),q(e,i);return}t.preventDefault(),W(null);let a=r.selectionStart,o=r.selectionEnd,s=n.slice(0,a).replace(/\n+$/,``),c=n.slice(o),l=A.slice();l[e]=s,l.splice(e+1,0,c),T.current={index:e+1,start:0,end:0},G(l),v(e+1);return}if(t.key===`Backspace`&&o(n)&&e===0&&A.length>1){t.preventDefault(),W(null);let n=A.slice();n.splice(e,1),G(n),v(0);return}if(t.key===`Backspace`&&r.selectionStart===0&&r.selectionEnd===0&&e>0&&!O.current&&!l(c(A[e-1]??``))){t.preventDefault(),W(null);let r=c(A[e-1]??``),i=A.slice();i[e-1]=r+n,i.splice(e,1),T.current={index:e-1,start:r.length,end:r.length},G(i),v(e-1);return}if(t.key===`Backspace`&&r.selectionStart===r.selectionEnd&&!O.current){let i=r.selectionStart,a=n.lastIndexOf(`
26
26
  `,i-1)+1,o=n.indexOf(`
27
27
  `,i),s=o===-1?n.length:o;if(te(n.slice(a,s))){t.preventDefault(),W(null);let r=n.slice(0,a).replace(/\n$/,``),i=o===-1?``:n.slice(s+1),c=A.slice();!r&&!i?(c[e]=``,T.current={index:e,start:0,end:0},G(c),v(e)):i?(c[e]=r,c.splice(e+1,0,``,i),T.current={index:e+1,start:0,end:0},G(c),v(e+1)):(c[e]=r,c.splice(e+1,0,``),T.current={index:e+1,start:0,end:0},G(c),v(e+1));return}}if(t.key===`Delete`&&r.selectionStart===n.length&&r.selectionEnd===n.length&&e<A.length-1&&!O.current&&!l(c(A[e+1]??``))){t.preventDefault(),W(null);let r=c(A[e+1]??``),i=A.slice();i[e]=n+r,i.splice(e+1,1),T.current={index:e,start:n.length,end:n.length},G(i),v(e);return}if(t.key===`Enter`&&t.shiftKey&&!i&&!O.current){let i=r.selectionStart,a=r.selectionEnd;if(i===0&&a===0){t.preventDefault(),W(null);let n=A.slice();n.splice(e,0,``),T.current={index:e,start:0,end:0},G(n),v(e);return}if(i===n.length&&a===n.length){t.preventDefault(),W(null);let n=A.slice();n.splice(e+1,0,``),T.current={index:e+1,start:0,end:0},G(n),v(e+1);return}return}if(!O.current&&r.selectionStart===r.selectionEnd&&!t.shiftKey&&!t.altKey){if(t.key===`ArrowUp`&&r.selectionStart===0&&e>0){t.preventDefault();let n=c(A[e-1]??``).length;T.current={index:e-1,start:n,end:n},v(e-1);return}if(t.key===`ArrowDown`&&r.selectionEnd===n.length&&e<A.length-1){t.preventDefault(),T.current={index:e+1,start:0,end:0},v(e+1);return}if(t.key===`ArrowUp`||t.key===`ArrowDown`){let n={start:r.selectionStart,end:r.selectionEnd},i=t.key;requestAnimationFrame(()=>{let t=D.current;if(!t||t!==document.activeElement||t.selectionStart!==n.start||t.selectionEnd!==n.end)return;let r=c(A[e]??``).length;if(i===`ArrowUp`&&n.start>0&&e>0){let t=c(A[e-1]??``).length;T.current={index:e-1,start:t,end:t},v(e-1)}else i===`ArrowDown`&&n.end<r&&e<A.length-1&&(T.current={index:e+1,start:0,end:0},v(e+1))})}}},ve=(e,t)=>{e?.length&&d&&d(e,{mode:`live`,focusIndex:_,caretInBlock:t?t.selectionStart:null})};return(0,X.jsxs)(`div`,{className:`mdw-lp${y?` is-drop`:``}`,onDragEnter:e=>{[...e.dataTransfer.types].includes(`Files`)&&(e.preventDefault(),S(!0))},onDragOver:e=>{[...e.dataTransfer.types].includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||S(!1)},onDrop:e=>{S(!1);let t=Y(e.dataTransfer);t.length&&(e.preventDefault(),ve(t,null))},children:[(0,X.jsxs)(`div`,{className:`mdw-lp-sheet`,ref:i,children:[j&&(0,X.jsx)(Ae,{query:N,setQuery:e=>{P(e),I(0)},index:F,total:V.length,onNext:()=>H(F+1),onPrev:()=>H(F-1),onClose:()=>M(!1),inputRef:R}),!h&&(0,X.jsx)(Oe,{className:`mdw-lp-title`,value:e,placeholder:`无标题`,onTitle:n,onFocus:()=>{v(null),W(null)},onEnter:()=>{A.length&&v(0)}}),(0,X.jsx)(`div`,{className:`mdw-lp-blocks${U?` is-empty-doc`:``}`,children:A.map((e,t)=>(0,X.jsx)(Ce,{index:t,text:e,focused:_===t,hit:ne===t,attachments:a,pendingSelRef:T,pendingFormatRef:E,onFocus:e=>{v(e),W(null)},onTaReady:e=>{D.current=e},onChange:e=>{K(t,e,`typing`),cancelAnimationFrame(k.current),k.current=requestAnimationFrame(()=>{let e=D.current;if(!e)return;J(t,e);let n=ue(e);n?Z.open({index:t,ta:e,at:n.at,caret:n.caret}):Z.close()})},onBlur:()=>{requestAnimationFrame(()=>{document.activeElement?.closest?.(`.mdw-lp-block.is-edit`)||document.activeElement?.closest?.(`.mdw-slash`)||document.activeElement?.closest?.(`.mdw-atpick`)||(v(null),W(null))})},onKeyDown:e=>he(t,e),onToggleTodo:(e,t)=>{let n=B(c(A[e]??``),t);n&&K(e,n)},onPasteFiles:(e,t)=>ve(e,t),onTextSel:p},`${s}-${t}`))}),U&&_===null?(0,X.jsx)(`button`,{type:`button`,className:`mdw-lp-add is-empty-hint`,"aria-label":`开始输入`,onClick:()=>v(0),children:(0,X.jsx)(`span`,{className:`mdw-lp-add-hint`,children:`输入正文,或键入 / 唤起命令…`})}):(0,X.jsx)(`button`,{type:`button`,className:`mdw-lp-add`,"aria-label":`继续输入`,onClick:()=>{G([...A,``]),v(A.length)}})]}),C&&(0,x.createPortal)((0,X.jsx)(De,{items:C.items,active:C.active,onHover:e=>W(t=>t&&{...t,active:e}),onPick:ce,style:{left:C.x,top:C.y}}),document.body),Z.menu&&(0,x.createPortal)((0,X.jsx)(_e,{items:Z.items,query:Z.menu.query,onQuery:Z.setQuery,active:Z.active,onHover:Z.move,onPick:Z.pick,loading:Z.menu.loading,error:Z.menu.error,position:{left:Z.menu.x,top:Z.menu.y},host:g,onReload:Z.reload,onAddFiles:g?null:pe}),document.body)]})}function Ae({query:e,setQuery:t,index:n,total:r,onNext:i,onPrev:a,onClose:o,inputRef:s}){return(0,X.jsxs)(`div`,{className:`mdw-find`,role:`search`,children:[(0,X.jsx)(`input`,{ref:s,className:`mdw-find-input`,value:e,placeholder:`查找…`,"aria-label":`查找`,onChange:e=>t(e.target.value),onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),o();return}e.key===`Enter`&&(e.preventDefault(),e.shiftKey?a():i()),e.key===`F3`&&(e.preventDefault(),e.shiftKey?a():i())}}),(0,X.jsx)(`span`,{className:`mdw-find-count`,children:r?`${n+1}/${r}`:`无结果`}),(0,X.jsx)(`button`,{type:`button`,className:`mdw-find-nav`,title:`上一个`,"aria-label":`上一个匹配`,onClick:a,children:`↑`}),(0,X.jsx)(`button`,{type:`button`,className:`mdw-find-nav`,title:`下一个`,"aria-label":`下一个匹配`,onClick:i,children:`↓`}),(0,X.jsx)(`button`,{type:`button`,className:`mdw-find-nav`,title:`关闭`,"aria-label":`关闭查找`,onClick:o,children:`×`})]})}function je({title:e,body:t,onTitle:n,onBody:r,editorApiRef:i,onFiles:a,onTextSel:o}){let s=(0,b.useRef)(null),c=(0,b.useRef)(null),l=(0,b.useRef)(null),u=(0,b.useRef)(null),[d,f]=(0,b.useState)(!0),[p,m]=(0,b.useState)(!0),[h,g]=(0,b.useState)(!1),[_,v]=(0,b.useState)(!1),[y,S]=(0,b.useState)(``),[C,w]=(0,b.useState)(0),[T,E]=(0,b.useState)({line:1,col:1}),[D,O]=(0,b.useState)(!0),[k,A]=(0,b.useState)(null),j=(0,b.useRef)(null),M=(0,b.useRef)(0),N=V(t),P=se(t,y),F=e=>{let t=typeof e==`function`?e(j.current):e;j.current=t,A(t)};(0,b.useEffect)(()=>{j.current=k},[k]);let I=()=>{let e=s.current;e&&E(H(e.value,e.selectionStart))},R=e=>{let t=ie(e);if(!t){F(null);return}let n=ae(t.query);if(!n.length){F(null);return}let r=e.getBoundingClientRect(),i=H(e.value,e.selectionStart).line,a=Math.min(window.innerWidth-220,r.left+12),o=Math.min(window.innerHeight-220,r.top+i*20-e.scrollTop+8);F(e=>{let r=e&&e.query===t.query?$({...e,items:n}):0;return{query:t.query,items:n,active:r,x:a,y:o}})},te=e=>{F(t=>{if(!t?.items?.length)return t;let n=t.items.length,r=$(t);return{...t,active:(r+e+n)%n}})},B=e=>{e&&(u.current={start:e.start,end:e.end},r(e.value))},U=e=>{let t=s.current;if(!t||!e)return;let n=oe(t,e);F(null),n&&B(n)};(0,b.useEffect)(()=>{if(!k)return;let e=e=>{Ee(e,j,{move:te,pick:U,close:()=>F(null)})};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[k]),(0,b.useLayoutEffect)(()=>{let e=u.current,t=s.current;if(e&&t){u.current=null;try{t.setSelectionRange(e.start,e.end)}catch{}}},[t]),(0,b.useEffect)(()=>{_&&(l.current?.focus(),l.current?.select())},[_]),(0,b.useEffect)(()=>{w(0)},[y,t]);let W=e=>{let t=s.current;if(!t||!P.length)return;let n=(e%P.length+P.length)%P.length;w(n);let r=P[n];t.focus();try{t.setSelectionRange(r.start,r.end)}catch{}ce(t,r.start),requestAnimationFrame(()=>l.current?.focus())},G=()=>{v(!0);let e=s.current;if(e&&e.selectionStart!==e.selectionEnd){let t=e.value.slice(e.selectionStart,e.selectionEnd);t&&!t.includes(`
28
28
  `)&&t.length<80&&S(t)}};(0,b.useImperativeHandle)(i,()=>({format(e){let t=s.current;t&&(t.focus(),B(z(t,e)))},turn(e){let t=s.current;t&&(t.focus(),B(J(t,e)))},insertAtCursor(e){let t=s.current;t&&B(ne(t,e))},getCursor(){let e=s.current;return e?e.selectionStart:null},caretFromDiff(e,t){let n=s.current;if(!n)return;let r=Math.min(le(e,t),n.value.length);n.focus(),n.setSelectionRange(r,r)},toggleWrap(){f(e=>!e)},getWrap:()=>d,openFind:G,focus(){s.current?.focus()}}),[r,d]);let K=e=>{let t=s.current;if(!t||e.nativeEvent?.isComposing||e.keyCode===229||Ee(e,j,{move:te,pick:U,close:()=>F(null)}))return;let n=e.metaKey||e.ctrlKey;if(n&&!e.altKey&&e.key.toLowerCase()===`f`){e.preventDefault(),G();return}if(e.key===`F3`){e.preventDefault(),_?e.shiftKey?W(C-1):W(C+1):G();return}if(n&&!e.altKey){let n=e.key.toLowerCase(),r={b:`bold`,i:`italic`,e:`code`,k:`link`};if(r[n]){e.preventDefault(),B(z(t,r[n]));return}}if(e.key===`Tab`){e.preventDefault(),B(L(t,e.shiftKey));return}if(e.key===`Enter`&&!e.shiftKey&&!n){let n=ee(t);n&&(e.preventDefault(),B(n)),F(null)}},q=e=>{if(!e?.length||!a)return;let t=s.current;a(e,{insertAt:t?t.selectionStart:null,mode:`edit`})},re=()=>{c.current&&s.current&&(c.current.scrollTop=s.current.scrollTop)},ue=p?Array.from({length:Math.max(1,N.lines)},(e,t)=>t+1):null;return(0,X.jsxs)(`div`,{className:`mdw-pane mdw-pane-edit${h?` is-drop`:``}`,onDragEnter:e=>{[...e.dataTransfer.types].includes(`Files`)&&(e.preventDefault(),g(!0))},onDragOver:e=>{[...e.dataTransfer.types].includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||g(!1)},onDrop:e=>{if(g(!1),e.defaultPrevented)return;let t=Y(e.dataTransfer);t.length&&(e.preventDefault(),q(t))},children:[(0,X.jsx)(Oe,{className:`mdw-title-input`,value:e,placeholder:`任务标题`,onTitle:n,onEnter:()=>{let e=s.current;e&&(e.focus(),e.setSelectionRange(0,0))}}),_&&(0,X.jsx)(Ae,{query:y,setQuery:S,index:C,total:P.length,inputRef:l,onNext:()=>W(C+1),onPrev:()=>W(C-1),onClose:()=>{v(!1),s.current?.focus()}}),(0,X.jsxs)(`div`,{className:`mdw-editor-row${p?` has-gutter`:``}${D?` has-ruler`:``}`,children:[p&&(0,X.jsx)(`div`,{className:`mdw-gutter`,ref:c,"aria-hidden":!0,children:ue.map(e=>(0,X.jsx)(`div`,{className:`mdw-gutter-ln`,children:e},e))}),(0,X.jsxs)(`div`,{className:`mdw-editor-stage`,children:[D&&(0,X.jsx)(`div`,{className:`mdw-ruler`,"aria-hidden":!0,title:`约 80 字符参考`}),(0,X.jsx)(`textarea`,{ref:s,className:`mdw-editor${d?` is-wrap`:` is-nowrap`}`,value:t,spellCheck:!1,wrap:d?`soft`:`off`,"aria-label":`正文源码`,placeholder:`用 Markdown 写任务——行首 / 出命令 · Ctrl/⌘F 查找 · Ctrl/⌘B 粗体`,onChange:e=>{r(e.target.value,`typing`),I(),cancelAnimationFrame(M.current),M.current=requestAnimationFrame(()=>{s.current&&R(s.current)})},onKeyDown:K,onKeyUp:I,onClick:()=>{I(),ie(s.current)||F(null)},onSelect:I,onScroll:re,onPaste:e=>{let t=Y(e.clipboardData);t.length&&(e.preventDefault(),q(t))},onDrop:e=>{let t=Y(e.dataTransfer);t.length&&(e.preventDefault(),q(t))},onMouseUp:e=>{I();let t=s.current;if(!t||t.selectionStart===t.selectionEnd){o?.(null);return}let n=t.value.slice(t.selectionStart,t.selectionEnd);n&&o?.({text:n,x:e.clientX-80,y:e.clientY-44})}})]})]}),(0,X.jsxs)(`div`,{className:`mdw-editor-status`,role:`status`,children:[(0,X.jsxs)(`span`,{children:[`Ln `,T.line,`, Col `,T.col]}),(0,X.jsxs)(`span`,{children:[N.lines,` 行`]}),(0,X.jsxs)(`span`,{children:[N.words,` 词`]}),(0,X.jsxs)(`span`,{children:[N.chars,` 字`]}),(0,X.jsx)(`button`,{type:`button`,className:`mdw-wrap-toggle${p?` on`:``}`,title:`显示/隐藏行号`,onClick:()=>m(e=>!e),children:`行号`}),(0,X.jsx)(`button`,{type:`button`,className:`mdw-wrap-toggle${D?` on`:``}`,title:`80 字符参考线`,onClick:()=>O(e=>!e),children:`参考线`}),(0,X.jsx)(`button`,{type:`button`,className:`mdw-wrap-toggle${_?` on`:``}`,title:`查找 Ctrl/⌘F`,onClick:()=>_?v(!1):G(),children:`查找`}),(0,X.jsx)(`button`,{type:`button`,className:`mdw-wrap-toggle${d?` on`:``}`,title:d?`自动换行开(点击关闭)`:`自动换行关(点击开启)`,onClick:()=>f(e=>!e),children:d?`换行`:`不换行`})]}),k&&(0,x.createPortal)((0,X.jsx)(De,{items:k.items,active:k.active,onHover:e=>F(t=>t&&{...t,active:e}),onPick:U,style:{left:k.x,top:k.y}}),document.body)]})}var Me=(0,b.forwardRef)(function({mode:e,title:t,body:n,previewHtml:r,onTitle:i,onBody:a,attachments:o=[],docKey:s=`draft`,editorApiRef:c=null,onFiles:l=null,onTextSel:u=null,onSave:d=null,onUndo:f=null,onRedo:p=null,onCloseSelMenu:m=null,hideTitle:h=!1,attachHost:g=null},_){return(0,b.useEffect)(()=>{let t=t=>{if(!(t.metaKey||t.ctrlKey)||t.altKey)return;let n=t.target;if(!n||typeof n.closest!=`function`)return;let r=t.key.toLowerCase(),i=n.closest(`.mdw-editor,.mdw-lp-src,.mdw-lp-title,.mdw-title-input`);if(r===`f`&&e!==`edit`){if(!n.closest(`.mdw`))return;t.preventDefault(),c.current?.openFind?.();return}if(!i){e===`split`&&ve[r]&&c.current?.formatSelection?.(ve[r])&&t.preventDefault();return}if(r===`s`){t.preventDefault(),d?.();return}if(r===`z`){t.preventDefault(),t.shiftKey?p?.():f?.();return}r===`y`&&(t.preventDefault(),p?.())};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[d,f,p,e,c]),e===`edit`?(0,X.jsx)(`div`,{className:`mdw-split mode-edit`,children:(0,X.jsx)(je,{title:t,body:n,onTitle:i,onBody:a,editorApiRef:c,onFiles:l,onTextSel:u})}):!a&&!i?(0,X.jsx)(`div`,{className:`mdw-split mode-read`,children:(0,X.jsx)(`div`,{className:`mdw-pane mdw-preview`,children:(0,X.jsxs)(`div`,{className:`mdw-reader`,children:[t&&!ye(n)?(0,X.jsx)(`h1`,{className:`mdw-reader-title`,children:t}):null,(0,X.jsx)(`article`,{ref:_,dangerouslySetInnerHTML:{__html:r}})]})})}):(0,X.jsx)(`div`,{className:`mdw-split mode-split live`,children:(0,X.jsx)(ke,{title:t,body:n,onTitle:i,onBody:a,articleRef:_,attachments:o,docKey:s,onFiles:l,editorApiRef:c,onTextSel:u,onCloseSelMenu:m,hideTitle:h,attachHost:g})})});export{E as a,O as c,A as i,he as n,D as o,S as r,j as s,Me as t};
@@ -2,7 +2,7 @@ import{s as e}from"./task-status-BP6y8MVu.js";function t(e){return String(e||``)
2
2
  `)}\n---\n${n}`:n}function u(e,t=`未命名任务`){let n=c(e).split(`
3
3
  `);for(let e of n){let t=e.match(/^#\s+(.+)$/);if(t)return t[1].trim();if(e.trim())return e.trim().slice(0,48)}return t}function d(e){let t=(e||`untitled`).trim().replace(/[\\/:*?"<>|]+/g,`-`).slice(0,48);return t.endsWith(`.md`)?t:`${t}.md`}function f(e,t){let n=String(e||``).trim().toLowerCase().replace(/\s+/g,`-`).replace(/[^\w\u4e00-\u9fff-]+/g,``).slice(0,48)||`h`,r=n,i=2;for(;t&&t.has(r);)r=`${n}-${i}`,i+=1;return t&&t.add(r),r}function p(e){let t=[],n=new Set,r=!1;for(let i of String(e||``).split(`
4
4
  `)){if(i.startsWith("```")){r=!r;continue}if(r)continue;let e=i.match(/^(#{1,3})\s+(.+)$/);if(!e)continue;let a=e[2].trim();t.push({level:e[1].length,text:a,id:f(a,n)})}return t}function m(e){return String(e).replace(/[&<>"']/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`})[e])}function h(e,n){let r=t(e);return!r||n.has(r)||n.has(r.split(`/`).pop())}function g(t,n){return m(t).replace(/`([^`]+)`/g,`<code>$1</code>`).replace(/\*\*([^*]+)\*\*/g,`<b>$1</b>`).replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g,(t,n,r)=>{let i=String(r??``).trim();return e(i)?`<img class="md-att-img" src="/api/file/content/${i}" alt="${n}">`:t}).replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(t,n,r)=>{let i=String(r??``).trim();return e(i)?`<a class="md-att" href="/api/file/content/${i}" download="${n}" title="附件:${n}">${n}</a>`:t}).replace(/\[([^\]]+)\]\((nxkv:\/\/[^)\s]+)\)/g,(e,t,n)=>/^nxkv:\/\/(?:task|ref)\//i.test(n)?`<a class="md-wl" data-nxkv="${n}" title="内部资源:${n}">${t}</a>`:e).replace(/\[\[([^\[\]|]+)(?:\|([^\[\]]+))?\]\]/g,(e,t,r)=>{let i=t.trim(),a=(r||t).trim(),o=n&&!h(i,n);return`<a class="md-wl${o?` md-wl-miss`:``}" data-wl="${m(i)}" title="${o?`未解析:`:`双链:`}${m(i)}">${m(a)}</a>`})}function _(t,n=[],r=null){let i={};for(let e of n)e.type===`image`&&e.url&&(i[e.name]=e.url);let a=c(t).split(`
5
- `),o=``,s=!1,l=!1,u=new Set,d=()=>{s&&=(o+=`</ul>`,!1)};for(let t of a){if(t.startsWith("```")){l?(o+=`</code></pre>`,l=!1):(d(),o+=`<pre class="mdw-code"><code>`,l=!0);continue}if(l){o+=`${m(t)}\n`;continue}let n=t.match(/^!\[([^\]]*)\]\(([^)]+)\)\s*$/);if(n){d();let t=n[2].trim();if(e(t)){o+=`<p><img class="md-att-img" src="/api/file/content/${t}" alt="${m(n[1])}"></p>`;continue}let r=i[n[2]]||n[2],a=/^(data:|blob:|https?:|#)/.test(r)?r:``;o+=a?`<p><img src="${a}" alt="${m(n[1])}"></p>`:`<p><code>![${m(n[1])}](${m(n[2])})</code></p>`;continue}if(t.startsWith(`> `)){d(),o+=`<blockquote>${g(t.slice(2),r)}</blockquote>`;continue}if(t.startsWith(`### `)){d();{let e=t.slice(4),n=f(e.trim(),u);o+=`<h3 id="${m(n)}">${g(e,r)}</h3>`}continue}if(t.startsWith(`## `)){d();{let e=t.slice(3),n=f(e.trim(),u);o+=`<h2 id="${m(n)}">${g(e,r)}</h2>`}continue}if(t.startsWith(`# `)){d();{let e=t.slice(2),n=f(e.trim(),u);o+=`<h1 id="${m(n)}">${g(e,r)}</h1>`}continue}let a=t.match(/^-\s+(\[[ xX]\])?\s*(.*)$/);if(a){s||=(o+=`<ul>`,!0);let e=a[1]&&/x/i.test(a[1]);a[1]?o+=`<li class="${e?`done`:`todo`}"><span class="mdw-cb" aria-hidden="true">${e?`☑`:`☐`}</span>${g(a[2],r)}</li>`:o+=`<li>${g(a[2],r)}</li>`;continue}d(),t.trim()&&(o+=`<p>${g(t,r)}</p>`)}l&&(o+=`</code></pre>`),d();let p=n.filter(e=>e.type!==`image`&&!o.includes(String(e.id)));return p.length&&(o+=p.map(e=>`<div class="mdw-attach-chip">${m(e.name)}<span class="sz">${m(e.size||``)}</span></div>`).join(``)),o||`<p class="mdw-empty">(空文档)</p>`}var v=`## 背景
5
+ `),o=``,s=!1,l=!1,u=new Set,d=()=>{s&&=(o+=`</ul>`,!1)};for(let t=0;t<a.length;t++){let n=a[t];if(n.startsWith("```")){l?(o+=`</code></pre>`,l=!1):(d(),o+=`<pre class="mdw-code"><code>`,l=!0);continue}if(l){o+=`${m(n)}\n`;continue}let c=n.match(/^!\[([^\]]*)\]\(([^)]+)\)\s*$/);if(c){d();let t=c[2].trim();if(e(t)){o+=`<p><img class="md-att-img" src="/api/file/content/${t}" alt="${m(c[1])}"></p>`;continue}let n=i[c[2]]||c[2],r=/^(data:|blob:|https?:|#)/.test(n)?n:``;o+=r?`<p><img src="${r}" alt="${m(c[1])}"></p>`:`<p><code>![${m(c[1])}](${m(c[2])})</code></p>`;continue}if(n.startsWith(`>`)){d();let e=[],n=t;for(;n<a.length&&a[n].startsWith(`>`);)e.push(a[n].replace(/^>[ \t]?/,``)),n+=1;t=n-1;let i=e.length&&e[0]?e[0].match(/^\[!([A-Za-z][\w-]*)\][ \t]*(.*)$/):null;if(i){let t=String(i[1]||``).toLowerCase(),n=String(i[2]||``).trim(),a=[],s=[];for(let t of e.slice(1)){if(!t.trim()){s.length&&(a.push(s),s=[]);continue}s.push(t)}s.length&&a.push(s);let c=a.map(e=>e.map(e=>g(e,r)).join(`<br>`)).join(`<br><br>`);o+=`<div class="md-callout md-callout-${m(t)}">`+(n?`<div class="md-callout-t">${g(n,r)}</div>`:``)+`<div class="md-callout-b">${c}</div></div>`;continue}o+=`<blockquote>${e.map(e=>g(e,r)).join(`<br>`)}</blockquote>`;continue}if(n.startsWith(`### `)){d();{let e=n.slice(4),t=f(e.trim(),u);o+=`<h3 id="${m(t)}">${g(e,r)}</h3>`}continue}if(n.startsWith(`## `)){d();{let e=n.slice(3),t=f(e.trim(),u);o+=`<h2 id="${m(t)}">${g(e,r)}</h2>`}continue}if(n.startsWith(`# `)){d();{let e=n.slice(2),t=f(e.trim(),u);o+=`<h1 id="${m(t)}">${g(e,r)}</h1>`}continue}let p=n.match(/^-\s+(\[[ xX]\])?\s*(.*)$/);if(p){s||=(o+=`<ul>`,!0);let e=p[1]&&/x/i.test(p[1]);p[1]?o+=`<li class="${e?`done`:`todo`}"><span class="mdw-cb" aria-hidden="true">${e?`☑`:`☐`}</span>${g(p[2],r)}</li>`:o+=`<li>${g(p[2],r)}</li>`;continue}d(),n.trim()&&(o+=`<p>${g(n,r)}</p>`)}l&&(o+=`</code></pre>`),d();let p=n.filter(e=>e.type!==`image`&&!o.includes(String(e.id)));return p.length&&(o+=p.map(e=>`<div class="mdw-attach-chip">${m(e.name)}<span class="sz">${m(e.size||``)}</span></div>`).join(``)),o||`<p class="mdw-empty">(空文档)</p>`}var v=`## 背景
6
6
 
7
7
  (一句话说清要改什么)
8
8
 
@@ -1 +1 @@
1
- import{S as e,_ as t,f as n,g as r,v as i,y as a}from"./task-status-BP6y8MVu.js";import{h as o}from"./md-parse-DN9INgZn.js";import{s,t as c}from"./board-view-t8CKtq17.js";import{t as l}from"./status-tag-DGlwjAg2.js";import{t as u}from"./route-crumb-lOriqwxP.js";var d=e(a(),1),f=i();function p({rows:e,onNavigate:i,refreshLocal:a}){let o=r(),{dialog:l,node:p}=n(),[h,g]=(0,d.useState)(()=>new Set),[_,v]=(0,d.useState)(``),y=(0,d.useMemo)(()=>{let t=[];for(let n of e){let e=s(n.tasks||[]),r=n.isGlobal?`#/global`:`#/dir/`+encodeURIComponent(n.key);for(let i of[...e.pending,...e.claimed])t.push({t:i,secKey:n.isGlobal?c:n.key,proj:n.isGlobal?`全局`:n.name||n.key,cwd:n.cwd||``,waiting:!!n.waiting,base:r})}return t},[e]),b=(0,d.useMemo)(()=>e.filter(e=>e.waiting).length,[e]),x=(0,d.useMemo)(()=>{let e=[],t=new Map;for(let n of y)t.has(n.proj)||(t.set(n.proj,0),e.push(n.proj)),t.set(n.proj,t.get(n.proj)+1);return e.map(e=>({proj:e,count:t.get(e)}))},[y]),S=x.some(e=>e.proj===_)?_:``,C=(0,d.useMemo)(()=>S?y.filter(e=>e.proj===S):y,[y,S]),w=(0,d.useMemo)(()=>C.filter(e=>e.t.status!==`claimed`).length,[C]),T=(0,d.useMemo)(()=>{let e=new Set(C.map(e=>Number(e.t.id)));return[...h].filter(t=>e.has(t))},[h,C]),E=T.length,D=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},O=e=>{g(e?new Set:new Set(C.map(e=>Number(e.t.id))))},k=C.length>0&&T.length===C.length,A=async()=>{let e=new Set(T),n=[];for(let t of y){if(!e.has(Number(t.t.id)))continue;let r=n.find(e=>e.key===t.secKey);r||(r={key:t.secKey,name:t.proj,ids:[]},n.push(r)),r.ids.push(Number(t.t.id))}let r=n.reduce((e,t)=>e+t.ids.length,0);if(!r)return;let i=n.length>1?`(跨 ${n.length} 个目录)`:``;if(!await l({title:`删除 ${r} 条任务${i}`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`}))return;let s=0,c=0,u=[];for(let e of n)try{let n=await t(`/api/localtasks/items`,{method:`DELETE`,body:{key:e.key,ids:e.ids}});s+=Number(n?.count??0),c+=(n?.missing||[]).length}catch(t){let n=String(t.message||t);if(/接口不存在/.test(n)){o(`本机面板服务较旧,重启面板后再试(批量删除接口未上线)`);return}u.push(`${e.name}: ${n}`)}u.length?o(`已删除 ${s} 条;${u.length} 个目录失败:${u[0]}${u.length>1?` 等 ${u.length} 项`:``}`):o(`已删除 ${s} 条${c?`(${c} 条未找到,可能已被删除)`:``}`),g(new Set),a?.()},j=(e,t)=>{i(e.t.boardMark?`#/group/${encodeURIComponent(e.t.boardMark)}?task=${encodeURIComponent(t)}`:`${e.base}?task=${encodeURIComponent(t)}`)};return(0,f.jsxs)(`div`,{className:`ov-wrap`,children:[(0,f.jsx)(u,{}),p,(0,f.jsxs)(`div`,{className:`ov-head`,children:[(0,f.jsx)(`h2`,{children:`全部目录总览`}),(0,f.jsxs)(`span`,{className:`muted`,children:[C.length,` 个未完成任务(待领取 `,w,`)`,b?` · ${b} 个目录等待回填`:``]}),C.length>0&&(0,f.jsxs)(`label`,{className:`ov-all`,children:[(0,f.jsx)(`input`,{type:`checkbox`,checked:k,ref:e=>{e&&(e.indeterminate=!k&&E>0)},onChange:()=>O(k),"aria-label":`全选未完成任务`}),`全选`]})]}),x.length>1&&(0,f.jsxs)(`div`,{className:`ov-tabs`,role:`tablist`,"aria-label":`按项目筛选`,children:[(0,f.jsxs)(`button`,{type:`button`,className:`ov-tab`+(S?``:` on`),onClick:()=>v(``),children:[`全部 `,y.length]}),x.map(e=>(0,f.jsxs)(`button`,{type:`button`,className:`ov-tab`+(S===e.proj?` on`:``),onClick:()=>v(e.proj),children:[e.proj,` `,e.count]},e.proj))]}),C.length?(0,f.jsx)(`div`,{className:`ov-list`,children:C.map(e=>(0,f.jsx)(m,{t:e.t,proj:e.proj,waiting:e.waiting,checked:h.has(Number(e.t.id)),onToggle:D,onOpenTask:t=>j(e,t),meta:e.t.status===`claimed`&&e.t.consumedAt?String(e.t.consumedAt).slice(5,16):``},`${e.secKey}-${e.t.id}`))}):(0,f.jsx)(`div`,{className:`ov-task muted`,children:`没有未完成的任务——当前队列都清空了。在侧边栏点 + 添加目录,或让 agent 在任意目录提交任务。`}),E>0&&(0,f.jsxs)(`div`,{className:`ov-bar`,role:`toolbar`,"aria-label":`批量删除操作条`,children:[(0,f.jsxs)(`span`,{className:`ov-bar-n`,children:[`已选 `,(0,f.jsx)(`b`,{children:E}),` 条任务`]}),(0,f.jsx)(`span`,{className:`grow`}),(0,f.jsx)(`button`,{type:`button`,className:`mini`,onClick:()=>g(new Set),children:`取消选择`}),(0,f.jsxs)(`button`,{type:`button`,className:`btn small danger`,onClick:A,children:[`删除选中 `,E]})]})]})}function m({t:e,proj:t,waiting:n,checked:r,onToggle:i,onOpenTask:a,meta:s=``}){return(0,f.jsxs)(`div`,{className:`ov-task link`,role:`button`,tabIndex:0,title:`打开任务详情`,onClick:()=>a(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),a(e.id))},children:[(0,f.jsx)(`label`,{className:`ov-ck`,onClick:e=>e.stopPropagation(),children:(0,f.jsx)(`input`,{type:`checkbox`,checked:r,onChange:()=>i(Number(e.id)),"aria-label":`选择 #${e.id}`})}),(0,f.jsxs)(`span`,{className:`mono faint`,children:[`#`,e.id]}),(0,f.jsx)(`span`,{className:`tx`,title:e.text,children:o(e.text,e.text||`未命名任务`)}),e.boardMark?(0,f.jsx)(`span`,{className:`tag t-board`,title:`项目组任务:详情在组页打开`,children:`组`}):null,t?(0,f.jsxs)(`span`,{className:`tag t-proj`,title:`所属项目`,children:[t,n?(0,f.jsx)(`span`,{className:`wdot`}):null]}):null,e.from===`cloud`&&(0,f.jsx)(`span`,{className:`tag t-cloud`,children:`云端`}),s?(0,f.jsx)(`span`,{className:`m mono`,children:s}):null,(0,f.jsx)(l,{t:e})]})}export{p as default};
1
+ import{S as e,_ as t,f as n,g as r,v as i,y as a}from"./task-status-BP6y8MVu.js";import{h as o}from"./md-parse-C2bDc3IZ.js";import{s,t as c}from"./board-view-t8CKtq17.js";import{t as l}from"./status-tag-D4wxIj1q.js";import{t as u}from"./route-crumb-C5LPu1Qx.js";var d=e(a(),1),f=i();function p({rows:e,onNavigate:i,refreshLocal:a}){let o=r(),{dialog:l,node:p}=n(),[h,g]=(0,d.useState)(()=>new Set),[_,v]=(0,d.useState)(``),y=(0,d.useMemo)(()=>{let t=[];for(let n of e){let e=s(n.tasks||[]),r=n.isGlobal?`#/global`:`#/dir/`+encodeURIComponent(n.key);for(let i of[...e.pending,...e.claimed])t.push({t:i,secKey:n.isGlobal?c:n.key,proj:n.isGlobal?`全局`:n.name||n.key,cwd:n.cwd||``,waiting:!!n.waiting,base:r})}return t},[e]),b=(0,d.useMemo)(()=>e.filter(e=>e.waiting).length,[e]),x=(0,d.useMemo)(()=>{let e=[],t=new Map;for(let n of y)t.has(n.proj)||(t.set(n.proj,0),e.push(n.proj)),t.set(n.proj,t.get(n.proj)+1);return e.map(e=>({proj:e,count:t.get(e)}))},[y]),S=x.some(e=>e.proj===_)?_:``,C=(0,d.useMemo)(()=>S?y.filter(e=>e.proj===S):y,[y,S]),w=(0,d.useMemo)(()=>C.filter(e=>e.t.status!==`claimed`).length,[C]),T=(0,d.useMemo)(()=>{let e=new Set(C.map(e=>Number(e.t.id)));return[...h].filter(t=>e.has(t))},[h,C]),E=T.length,D=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},O=e=>{g(e?new Set:new Set(C.map(e=>Number(e.t.id))))},k=C.length>0&&T.length===C.length,A=async()=>{let e=new Set(T),n=[];for(let t of y){if(!e.has(Number(t.t.id)))continue;let r=n.find(e=>e.key===t.secKey);r||(r={key:t.secKey,name:t.proj,ids:[]},n.push(r)),r.ids.push(Number(t.t.id))}let r=n.reduce((e,t)=>e+t.ids.length,0);if(!r)return;let i=n.length>1?`(跨 ${n.length} 个目录)`:``;if(!await l({title:`删除 ${r} 条任务${i}`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`}))return;let s=0,c=0,u=[];for(let e of n)try{let n=await t(`/api/localtasks/items`,{method:`DELETE`,body:{key:e.key,ids:e.ids}});s+=Number(n?.count??0),c+=(n?.missing||[]).length}catch(t){let n=String(t.message||t);if(/接口不存在/.test(n)){o(`本机面板服务较旧,重启面板后再试(批量删除接口未上线)`);return}u.push(`${e.name}: ${n}`)}u.length?o(`已删除 ${s} 条;${u.length} 个目录失败:${u[0]}${u.length>1?` 等 ${u.length} 项`:``}`):o(`已删除 ${s} 条${c?`(${c} 条未找到,可能已被删除)`:``}`),g(new Set),a?.()},j=(e,t)=>{i(e.t.boardMark?`#/group/${encodeURIComponent(e.t.boardMark)}?task=${encodeURIComponent(t)}`:`${e.base}?task=${encodeURIComponent(t)}`)};return(0,f.jsxs)(`div`,{className:`ov-wrap`,children:[(0,f.jsx)(u,{}),p,(0,f.jsxs)(`div`,{className:`ov-head`,children:[(0,f.jsx)(`h2`,{children:`全部目录总览`}),(0,f.jsxs)(`span`,{className:`muted`,children:[C.length,` 个未完成任务(待领取 `,w,`)`,b?` · ${b} 个目录等待回填`:``]}),C.length>0&&(0,f.jsxs)(`label`,{className:`ov-all`,children:[(0,f.jsx)(`input`,{type:`checkbox`,checked:k,ref:e=>{e&&(e.indeterminate=!k&&E>0)},onChange:()=>O(k),"aria-label":`全选未完成任务`}),`全选`]})]}),x.length>1&&(0,f.jsxs)(`div`,{className:`ov-tabs`,role:`tablist`,"aria-label":`按项目筛选`,children:[(0,f.jsxs)(`button`,{type:`button`,className:`ov-tab`+(S?``:` on`),onClick:()=>v(``),children:[`全部 `,y.length]}),x.map(e=>(0,f.jsxs)(`button`,{type:`button`,className:`ov-tab`+(S===e.proj?` on`:``),onClick:()=>v(e.proj),children:[e.proj,` `,e.count]},e.proj))]}),C.length?(0,f.jsx)(`div`,{className:`ov-list`,children:C.map(e=>(0,f.jsx)(m,{t:e.t,proj:e.proj,waiting:e.waiting,checked:h.has(Number(e.t.id)),onToggle:D,onOpenTask:t=>j(e,t),meta:e.t.status===`claimed`&&e.t.consumedAt?String(e.t.consumedAt).slice(5,16):``},`${e.secKey}-${e.t.id}`))}):(0,f.jsx)(`div`,{className:`ov-task muted`,children:`没有未完成的任务——当前队列都清空了。在侧边栏点 + 添加目录,或让 agent 在任意目录提交任务。`}),E>0&&(0,f.jsxs)(`div`,{className:`ov-bar`,role:`toolbar`,"aria-label":`批量删除操作条`,children:[(0,f.jsxs)(`span`,{className:`ov-bar-n`,children:[`已选 `,(0,f.jsx)(`b`,{children:E}),` 条任务`]}),(0,f.jsx)(`span`,{className:`grow`}),(0,f.jsx)(`button`,{type:`button`,className:`mini`,onClick:()=>g(new Set),children:`取消选择`}),(0,f.jsxs)(`button`,{type:`button`,className:`btn small danger`,onClick:A,children:[`删除选中 `,E]})]})]})}function m({t:e,proj:t,waiting:n,checked:r,onToggle:i,onOpenTask:a,meta:s=``}){return(0,f.jsxs)(`div`,{className:`ov-task link`,role:`button`,tabIndex:0,title:`打开任务详情`,onClick:()=>a(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),a(e.id))},children:[(0,f.jsx)(`label`,{className:`ov-ck`,onClick:e=>e.stopPropagation(),children:(0,f.jsx)(`input`,{type:`checkbox`,checked:r,onChange:()=>i(Number(e.id)),"aria-label":`选择 #${e.id}`})}),(0,f.jsxs)(`span`,{className:`mono faint`,children:[`#`,e.id]}),(0,f.jsx)(`span`,{className:`tx`,title:e.text,children:o(e.text,e.text||`未命名任务`)}),e.boardMark?(0,f.jsx)(`span`,{className:`tag t-board`,title:`项目组任务:详情在组页打开`,children:`组`}):null,t?(0,f.jsxs)(`span`,{className:`tag t-proj`,title:`所属项目`,children:[t,n?(0,f.jsx)(`span`,{className:`wdot`}):null]}):null,e.from===`cloud`&&(0,f.jsx)(`span`,{className:`tag t-cloud`,children:`云端`}),s?(0,f.jsx)(`span`,{className:`m mono`,children:s}):null,(0,f.jsx)(l,{t:e})]})}export{p as default};
@@ -1,3 +1,3 @@
1
- import{S as e,_ as t,f as n,g as r,p as i,v as a,y as o}from"./task-status-BP6y8MVu.js";import{g as s,m as c}from"./md-parse-DN9INgZn.js";import{r as l,t as u}from"./board-view-t8CKtq17.js";import{C as d,T as f}from"./index-CeIJd4ee.js";var p=e(o(),1);function m(e){let t=e&&e.taskId!==void 0&&e.taskId!==null?e.taskId:e&&e.id;return String(t??``)}function h(e,t){let n=String(e??``).toLowerCase(),r=(t||[]).map(e=>String(e).toLowerCase()).filter(Boolean);if(!r.length)return!0;let i=0;for(let e of r){let t=n.indexOf(e,i);if(t<0)return!1;i=t+e.length}return!0}function g(e,t){let n=String(e??``).toLowerCase(),r=String(t??``).toLowerCase().split(``),i=0;for(let e of r){let t=n.indexOf(e,i);if(t<0)return!1;i=t+1}return!0}function _(e,t){let n=String(t??``).trim().toLowerCase();if(!n)return!0;let r=n.startsWith(`#`)?n.slice(1).trim():n;if(!r)return!0;let i=m(e),a=String(e&&e.title||``).toLowerCase();if(r.includes(`*`)){let e=r.split(`*`).filter(Boolean);return h(a,e)?!0:h(i,e)}return/^\d+$/.test(r)?i===r||i.startsWith(r)?!0:g(a,r):a.includes(r)}var v=a();function y(e){if(e==null||e<0||Number.isNaN(e))return`—`;let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%60/60),i=t%60;return n?`${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}:${String(i).padStart(2,`0`)}`:`${String(r).padStart(2,`0`)}:${String(i).padStart(2,`0`)}`}function b(e,t){if(e.status!==`run`)return`—`;let n=e.receivedAt?Date.parse(e.receivedAt):NaN;return Number.isFinite(n)?y(t-n):`—`}function x({dirKey:e,task:a,rows:o=[],refreshLocal:m,model:h,onOpenTask:g,onClosePage:y,group:x=null}){let S=r(),{dialog:C,node:w}=n(),T=!e||e===`__GLOBAL__`,E=(0,p.useMemo)(()=>T?(o||[]).find(e=>e.isGlobal)||null:(o||[]).find(t=>t.key===e)||null,[o,e,T]),D=(0,p.useMemo)(()=>(E?.tasks||[]).filter(e=>!e.deletedAt&&!l(e)),[E]),[O,k]=(0,p.useState)(Date.now()),[A,j]=(0,p.useState)(()=>new Set),[M,N]=(0,p.useState)(!1);(0,p.useEffect)(()=>{let e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);let P=(0,p.useMemo)(()=>{if(!x)return[];let e=[x.id,x.key,x.name].filter(Boolean),t=x.repos||[],n=new Map;for(let e of t)e&&e.key&&n.set(e.key,e);let r=(e,n)=>{let r=t.find(t=>t&&(t.key===e||t.name===e||t.path&&t.path===e));return r&&r.name?r.name:e?String(e).split(`/`).pop()||String(e):n&&n.name||``},i=[];for(let t of o||[]){if(!t||t.isGlobal||!Array.isArray(t.tasks))continue;let a=t.repo&&n.get(t.repo.key)||null,o=!!a;for(let n of t.tasks){if(!n||n.deletedAt)continue;let l={};try{l=s(n.text||``)}catch{l={}}(o||l.board&&e.includes(l.board))&&i.push({...c(n),key:`${t.key}:${n.id}`,taskId:n.id,topicKey:t.key,topicCwd:t.cwd||``,project:l.project||``,projectName:o&&a.name||r(l.project,t)})}}let a={run:0,wait:1,done:2};return i.sort((e,t)=>(a[e.status]??9)-(a[t.status]??9)||e.projectName.localeCompare(t.projectName)||Number(e.taskId)-Number(t.taskId))},[x,o]),[F,I]=(0,p.useState)(``),[L,R]=(0,p.useState)(``),z=(0,p.useMemo)(()=>{let e=new Map;for(let t of P)t.projectName&&!e.has(t.projectName)&&e.set(t.projectName,!0);return[...e.keys()]},[P]),B=(0,p.useMemo)(()=>{let e=x?(()=>{let e=F&&z.includes(F)?F:``;return P.filter(t=>!e||t.projectName===e)})():(()=>{let e=D.map(c),t={run:0,wait:1,done:2};return e.sort((e,n)=>(t[e.status]??9)-(t[n.status]??9))})(),t=L.trim().toLowerCase();return t?e.filter(e=>_(e,t)):e},[x,P,F,z,D,L]),V=e=>x?e.key:e.id;(0,p.useEffect)(()=>{j(e=>{if(!e.size)return e;let t=new Set(B.map(V)),n=new Set([...e].filter(e=>t.has(e)));return n.size===e.size?e:n})},[B,x]);let H=B.filter(e=>e.status===`run`).length,U=B.filter(e=>e.status===`wait`).length,W=B.filter(e=>e.status===`done`).length,G=B.length?Math.round(W*100/B.length):0,K=B.length>0&&A.size===B.length,q=B.filter(e=>A.has(V(e))),J=e=>{j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Y=()=>{j(K?new Set:new Set(B.map(V)))},X=async()=>{if(M||!q.length)return;let n=q.map(e=>`#${e.taskId??e.id} ${e.title}`),r=n.length<=6?n.join(`
1
+ import{S as e,_ as t,f as n,g as r,p as i,v as a,y as o}from"./task-status-BP6y8MVu.js";import{g as s,m as c}from"./md-parse-C2bDc3IZ.js";import{r as l,t as u}from"./board-view-t8CKtq17.js";import{C as d,T as f}from"./index-B_HPAoNR.js";var p=e(o(),1);function m(e){let t=e&&e.taskId!==void 0&&e.taskId!==null?e.taskId:e&&e.id;return String(t??``)}function h(e,t){let n=String(e??``).toLowerCase(),r=(t||[]).map(e=>String(e).toLowerCase()).filter(Boolean);if(!r.length)return!0;let i=0;for(let e of r){let t=n.indexOf(e,i);if(t<0)return!1;i=t+e.length}return!0}function g(e,t){let n=String(e??``).toLowerCase(),r=String(t??``).toLowerCase().split(``),i=0;for(let e of r){let t=n.indexOf(e,i);if(t<0)return!1;i=t+1}return!0}function _(e,t){let n=String(t??``).trim().toLowerCase();if(!n)return!0;let r=n.startsWith(`#`)?n.slice(1).trim():n;if(!r)return!0;let i=m(e),a=String(e&&e.title||``).toLowerCase();if(r.includes(`*`)){let e=r.split(`*`).filter(Boolean);return h(a,e)?!0:h(i,e)}return/^\d+$/.test(r)?i===r||i.startsWith(r)?!0:g(a,r):a.includes(r)}var v=a();function y(e){if(e==null||e<0||Number.isNaN(e))return`—`;let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%60/60),i=t%60;return n?`${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}:${String(i).padStart(2,`0`)}`:`${String(r).padStart(2,`0`)}:${String(i).padStart(2,`0`)}`}function b(e,t){if(e.status!==`run`)return`—`;let n=e.receivedAt?Date.parse(e.receivedAt):NaN;return Number.isFinite(n)?y(t-n):`—`}function x({dirKey:e,task:a,rows:o=[],refreshLocal:m,model:h,onOpenTask:g,onClosePage:y,group:x=null}){let S=r(),{dialog:C,node:w}=n(),T=!e||e===`__GLOBAL__`,E=(0,p.useMemo)(()=>T?(o||[]).find(e=>e.isGlobal)||null:(o||[]).find(t=>t.key===e)||null,[o,e,T]),D=(0,p.useMemo)(()=>(E?.tasks||[]).filter(e=>!e.deletedAt&&!l(e)),[E]),[O,k]=(0,p.useState)(Date.now()),[A,j]=(0,p.useState)(()=>new Set),[M,N]=(0,p.useState)(!1);(0,p.useEffect)(()=>{let e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);let P=(0,p.useMemo)(()=>{if(!x)return[];let e=[x.id,x.key,x.name].filter(Boolean),t=x.repos||[],n=new Map;for(let e of t)e&&e.key&&n.set(e.key,e);let r=(e,n)=>{let r=t.find(t=>t&&(t.key===e||t.name===e||t.path&&t.path===e));return r&&r.name?r.name:e?String(e).split(`/`).pop()||String(e):n&&n.name||``},i=[];for(let t of o||[]){if(!t||t.isGlobal||!Array.isArray(t.tasks))continue;let a=t.repo&&n.get(t.repo.key)||null,o=!!a;for(let n of t.tasks){if(!n||n.deletedAt)continue;let l={};try{l=s(n.text||``)}catch{l={}}(o||l.board&&e.includes(l.board))&&i.push({...c(n),key:`${t.key}:${n.id}`,taskId:n.id,topicKey:t.key,topicCwd:t.cwd||``,project:l.project||``,projectName:o&&a.name||r(l.project,t)})}}let a={run:0,wait:1,done:2};return i.sort((e,t)=>(a[e.status]??9)-(a[t.status]??9)||e.projectName.localeCompare(t.projectName)||Number(e.taskId)-Number(t.taskId))},[x,o]),[F,I]=(0,p.useState)(``),[L,R]=(0,p.useState)(``),z=(0,p.useMemo)(()=>{let e=new Map;for(let t of P)t.projectName&&!e.has(t.projectName)&&e.set(t.projectName,!0);return[...e.keys()]},[P]),B=(0,p.useMemo)(()=>{let e=x?(()=>{let e=F&&z.includes(F)?F:``;return P.filter(t=>!e||t.projectName===e)})():(()=>{let e=D.map(c),t={run:0,wait:1,done:2};return e.sort((e,n)=>(t[e.status]??9)-(t[n.status]??9))})(),t=L.trim().toLowerCase();return t?e.filter(e=>_(e,t)):e},[x,P,F,z,D,L]),V=e=>x?e.key:e.id;(0,p.useEffect)(()=>{j(e=>{if(!e.size)return e;let t=new Set(B.map(V)),n=new Set([...e].filter(e=>t.has(e)));return n.size===e.size?e:n})},[B,x]);let H=B.filter(e=>e.status===`run`).length,U=B.filter(e=>e.status===`wait`).length,W=B.filter(e=>e.status===`done`).length,G=B.length?Math.round(W*100/B.length):0,K=B.length>0&&A.size===B.length,q=B.filter(e=>A.has(V(e))),J=e=>{j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Y=()=>{j(K?new Set:new Set(B.map(V)))},X=async()=>{if(M||!q.length)return;let n=q.map(e=>`#${e.taskId??e.id} ${e.title}`),r=n.length<=6?n.join(`
2
2
  `):`${n.slice(0,6).join(`
3
3
  `)}… 共 ${n.length} 条`;if(await C({title:`删除选中的 ${q.length} 条任务`,message:`${r}\n\n软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})){N(!0);try{let n=0,r=0;if(x){let e=new Map;for(let t of q)e.has(t.topicKey)||e.set(t.topicKey,{cwd:t.topicCwd,ids:[]}),e.get(t.topicKey).ids.push(t.taskId);for(let{cwd:i,ids:a}of e.values()){let e=await t(`/api/localtasks/items`,{method:`DELETE`,body:{cwd:i,ids:a}});n+=e?.count??a.length,r+=e?.missing?.length||0}}else{let e=q.map(e=>e.id),i=await t(`/api/localtasks/items`,{method:`DELETE`,body:{...T?{key:u}:{cwd:E.cwd},ids:e}});n=i?.count??e.length,r=i?.missing?.length||0}let i=r?`(${r} 条已不存在)`:``;if(h)for(let t of q){let n=x?t.topicKey:e,r=x?t.taskId:t.id,i=f(h,`page`,{dirKey:n,task:String(r)});i&&y&&y(i.getId())}j(new Set),m(),S(`已删除 ${n} 条任务${i}`)}catch(e){S(`删除失败: `+(e.message||e))}finally{N(!1)}}},Z=e=>{g&&(x?g(e.taskId,e.topicKey):g(e.id))},Q=a!=null&&String(a)!==``?String(a):``;return(0,v.jsxs)(`div`,{className:`mdw-prog-host`,children:[w,(0,v.jsxs)(`div`,{className:`mdw-prog-h`,children:[(0,v.jsx)(`span`,{className:`t`,children:x?`${x.name} · 任务进程`:E?.name||(T?`全局任务池`:`任务进程`)}),B.length>0&&(0,v.jsx)(`button`,{type:`button`,className:`mdw-prog-all`,onClick:Y,title:K?`取消全选`:`全选任务`,children:K?`取消全选`:`全选`}),h&&(0,v.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭进程面板`,"aria-label":`关闭进程面板`,onClick:()=>d(h),children:(0,v.jsx)(i,{name:`x`,size:14})})]}),(x?P.length>0:D.length>0)&&(0,v.jsxs)(`div`,{className:`mdw-prog-search`,children:[(0,v.jsx)(i,{name:`search`,size:13}),(0,v.jsx)(`input`,{value:L,onChange:e=>R(e.target.value),placeholder:`搜索编号或标题(如 12 → #12、#120-129;1*2 通配)`,spellCheck:`false`,"aria-label":`按编号或标题搜索任务`}),L&&(0,v.jsx)(`button`,{type:`button`,className:`mdw-prog-qclear`,"aria-label":`清空搜索`,title:`清空搜索`,onClick:()=>R(``),children:(0,v.jsx)(i,{name:`x`,size:11})})]}),x&&z.length>1&&(0,v.jsxs)(`div`,{className:`mdw-prog-filters`,role:`tablist`,"aria-label":`按项目筛选进程卡`,children:[(0,v.jsxs)(`button`,{type:`button`,className:`mdw-prog-fchip`+(!F||!z.includes(F)?` on`:``),onClick:()=>I(``),children:[`全部 `,(0,v.jsx)(`b`,{children:P.length})]}),z.map(e=>(0,v.jsxs)(`button`,{type:`button`,className:`mdw-prog-fchip`+(F===e?` on`:``),onClick:()=>I(F===e?``:e),children:[e,` `,(0,v.jsx)(`b`,{children:P.filter(t=>t.projectName===e).length})]},e))]}),(0,v.jsxs)(`div`,{className:`mdw-prog-sum`,children:[(0,v.jsxs)(`div`,{className:`counts`,children:[(0,v.jsxs)(`span`,{className:`run`,children:[`进行中 `,(0,v.jsx)(`b`,{children:H})]}),(0,v.jsxs)(`span`,{className:`wait`,children:[`等待 `,(0,v.jsx)(`b`,{children:U})]}),(0,v.jsxs)(`span`,{className:`done`,children:[`已完成 `,(0,v.jsx)(`b`,{children:W})]})]}),(0,v.jsx)(`div`,{className:`bar`,title:`已完成 ${W} / 共 ${B.length}`,children:(0,v.jsx)(`i`,{style:{width:`${G}%`}})})]}),A.size>0&&(0,v.jsxs)(`div`,{className:`mdw-prog-sel`,children:[(0,v.jsxs)(`span`,{className:`n`,children:[`已选 `,(0,v.jsx)(`b`,{children:A.size}),` / `,B.length]}),(0,v.jsx)(`button`,{type:`button`,className:`mdw-prog-clear`,onClick:()=>j(new Set),children:`清除`}),(0,v.jsxs)(`button`,{type:`button`,className:`mdw-prog-del`,onClick:X,disabled:M,children:[(0,v.jsx)(i,{name:`trash`,size:12}),`删除所选`]})]}),(0,v.jsxs)(`div`,{className:`mdw-prog-list`,children:[!B.length&&(0,v.jsx)(`div`,{className:`mdw-prog-empty`,children:L.trim()?(0,v.jsxs)(v.Fragment,{children:[`没有匹配的卡片`,(0,v.jsx)(`br`,{}),`试试编号(如 127)或标题关键词`]}):x?(0,v.jsxs)(v.Fragment,{children:[`本组成员项目还没有任务`,(0,v.jsx)(`br`,{}),`任务会随成员队列自动聚到这里`]}):(0,v.jsxs)(v.Fragment,{children:[`此目录还没有 MD 任务`,(0,v.jsx)(`br`,{}),`写 MD 提交或导入`]})}),B.map(e=>{let t=V(e),n=A.has(t),r=Q!==``&&String(e.taskId??e.id)===Q;return(0,v.jsxs)(`div`,{className:`mdw-tcard-row${n?` on`:``}`,children:[(0,v.jsx)(`input`,{type:`checkbox`,className:`mdw-tcard-pick`,checked:n,onChange:()=>J(t),"aria-label":`选择任务 #${e.taskId??e.id} ${e.title}`,title:`选择此任务(可多选后批量删除)`}),(0,v.jsx)(`button`,{type:`button`,className:`mdw-tcard ${e.status}${r?` focus`:``}`,onClick:()=>Z(e),children:(0,v.jsxs)(`div`,{className:`mdw-tcard-h`,children:[(0,v.jsx)(`span`,{className:`st ${e.status}`}),(0,v.jsxs)(`div`,{className:`titles`,children:[(0,v.jsxs)(`div`,{className:`n`,children:[e.title,x&&e.projectName&&(0,v.jsx)(`span`,{className:`rp-ptag mdw-tcard-proj`,title:`归属项目:${e.projectName}`,children:e.projectName})]}),(0,v.jsx)(`div`,{className:`sub`,children:e.detail})]}),(0,v.jsxs)(`span`,{className:`mdw-tcard-num`,title:`任务编号 #${e.taskId??e.id}`,children:[`#`,e.taskId??e.id]}),(0,v.jsx)(`span`,{className:`el ${e.status}`,title:`从领取时刻起计;待领取与已完成回填不计时间`,children:b(e,O)})]})})]},t)})]}),(0,v.jsx)(`div`,{className:`mdw-prog-note`,children:x?`组内各项目的任务聚在这里;可按项目筛选,勾选后批量删除。`:`本目录的任务;点卡打开,勾选后批量删除。`})]})}export{x as default};
@@ -1 +1 @@
1
- import{S as e,_ as t,p as n,v as r,y as i}from"./task-status-BP6y8MVu.js";import{S as a}from"./index-CeIJd4ee.js";import{i as o}from"./Introduction-DU27b_b_.js";var s=e(i(),1),c=r();function l(e){return e?e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``:``}function u(e){let t=e.rel||e.path||``;return String(t).replace(/[\\/]+$/,``).split(/[\\/]/).pop()||t||`未命名`}function d(e){let t=[],n=e&&(e.main||e.introMain);n&&t.push({...n,docId:l(n),main:!0,label:e.repo?e.repo.name:`主篇`});for(let n of e&&(e.extras||e.introExtras)||[]){let e=l(n);e&&t.push({...n,docId:e,main:!1,label:u(n)})}for(let n of e&&(e.links||e.docLinks)||[]){let e=l(n);e&&t.push({...n,docId:e,main:!1,label:u(n)})}return t.filter(e=>e.docId)}function f({repoKey:e,boardKey:r,boardName:i,model:l}){let{openByDocId:u}=o(l),[f,p]=(0,s.useState)(null),[m,h]=(0,s.useState)(``),[g,_]=(0,s.useState)(0),v=(0,s.useCallback)(()=>_(e=>e+1),[]);(0,s.useEffect)(()=>{let n=!0;return h(``),(async()=>{try{let i=e?await t(`/api/repos/docs?id=`+encodeURIComponent(e)):await t(`/api/boards/`+encodeURIComponent(String(r)));n&&p(i)}catch(e){n&&(p(null),h(String(e.message||e)))}})(),()=>{n=!1}},[e,r,g]);let y=d(f),b=f?f.repo?f.repo.name:f.name||i||`项目组`:i||`文档列表`,x=e?{repoKey:e}:{boardKey:r,boardName:i};return(0,c.jsxs)(`div`,{className:`nx-refs`,children:[(0,c.jsxs)(`div`,{className:`nx-refs-h`,children:[(0,c.jsxs)(`span`,{className:`t`,title:b,children:[b,` · 文档列表`]}),(0,c.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`刷新`,"aria-label":`刷新文档列表`,onClick:v,children:(0,c.jsx)(n,{name:`refresh`,size:13})}),l&&(0,c.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭文档列表面板`,"aria-label":`关闭文档列表面板`,onClick:()=>a(l,`refs`),children:(0,c.jsx)(n,{name:`x`,size:14})})]}),(0,c.jsxs)(`div`,{className:`nx-refs-list`,children:[m?(0,c.jsx)(`div`,{className:`nx-refs-empty`,children:m}):null,!m&&!f?(0,c.jsx)(`div`,{className:`nx-refs-empty`,children:`读取中…`}):null,!m&&f&&!y.length?(0,c.jsxs)(`div`,{className:`nx-refs-empty`,children:[`还没有文档`,(0,c.jsx)(`br`,{}),e?`在目录页「查看详情」里点「+ 补充」开始写`:`在项目组页「查看详情」里点「+ 补充」开始写`]}):null,y.map(e=>(0,c.jsxs)(`button`,{type:`button`,className:`nx-refs-row`+(e.main?` main`:``),title:`${e.rel||e.path||``}${e.note?`\n${e.note}`:``}`,onClick:()=>u(e.docId,null,x),children:[(0,c.jsxs)(`span`,{className:`nx-refs-row-label`,children:[e.main?`● `:`○ `,e.label]}),e.tag?(0,c.jsx)(`span`,{className:`nx-refs-row-tag`,children:e.tag}):null,(0,c.jsx)(`span`,{className:`nx-refs-row-sub mono`,children:e.rel||e.path||``})]},e.docId))]}),(0,c.jsx)(`div`,{className:`nx-refs-note`,children:`点一行在工作区打开文档页签;完整管理与就地编辑走「查看详情」。`})]})}export{f as default};
1
+ import{S as e,_ as t,p as n,v as r,y as i}from"./task-status-BP6y8MVu.js";import{S as a}from"./index-B_HPAoNR.js";import{i as o}from"./Introduction-DO6_gTk-.js";var s=e(i(),1),c=r();function l(e){return e?e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``:``}function u(e){let t=e.rel||e.path||``;return String(t).replace(/[\\/]+$/,``).split(/[\\/]/).pop()||t||`未命名`}function d(e){let t=[],n=e&&(e.main||e.introMain);n&&t.push({...n,docId:l(n),main:!0,label:e.repo?e.repo.name:`主篇`});for(let n of e&&(e.extras||e.introExtras)||[]){let e=l(n);e&&t.push({...n,docId:e,main:!1,label:u(n)})}for(let n of e&&(e.links||e.docLinks)||[]){let e=l(n);e&&t.push({...n,docId:e,main:!1,label:u(n)})}return t.filter(e=>e.docId)}function f({repoKey:e,boardKey:r,boardName:i,model:l}){let{openByDocId:u}=o(l),[f,p]=(0,s.useState)(null),[m,h]=(0,s.useState)(``),[g,_]=(0,s.useState)(0),v=(0,s.useCallback)(()=>_(e=>e+1),[]);(0,s.useEffect)(()=>{let n=!0;return h(``),(async()=>{try{let i=e?await t(`/api/repos/docs?id=`+encodeURIComponent(e)):await t(`/api/boards/`+encodeURIComponent(String(r)));n&&p(i)}catch(e){n&&(p(null),h(String(e.message||e)))}})(),()=>{n=!1}},[e,r,g]);let y=d(f),b=f?f.repo?f.repo.name:f.name||i||`项目组`:i||`文档列表`,x=e?{repoKey:e}:{boardKey:r,boardName:i};return(0,c.jsxs)(`div`,{className:`nx-refs`,children:[(0,c.jsxs)(`div`,{className:`nx-refs-h`,children:[(0,c.jsxs)(`span`,{className:`t`,title:b,children:[b,` · 文档列表`]}),(0,c.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`刷新`,"aria-label":`刷新文档列表`,onClick:v,children:(0,c.jsx)(n,{name:`refresh`,size:13})}),l&&(0,c.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭文档列表面板`,"aria-label":`关闭文档列表面板`,onClick:()=>a(l,`refs`),children:(0,c.jsx)(n,{name:`x`,size:14})})]}),(0,c.jsxs)(`div`,{className:`nx-refs-list`,children:[m?(0,c.jsx)(`div`,{className:`nx-refs-empty`,children:m}):null,!m&&!f?(0,c.jsx)(`div`,{className:`nx-refs-empty`,children:`读取中…`}):null,!m&&f&&!y.length?(0,c.jsxs)(`div`,{className:`nx-refs-empty`,children:[`还没有文档`,(0,c.jsx)(`br`,{}),e?`在目录页「查看详情」里点「+ 补充」开始写`:`在项目组页「查看详情」里点「+ 补充」开始写`]}):null,y.map(e=>(0,c.jsxs)(`button`,{type:`button`,className:`nx-refs-row`+(e.main?` main`:``),title:`${e.rel||e.path||``}${e.note?`\n${e.note}`:``}`,onClick:()=>u(e.docId,null,x),children:[(0,c.jsxs)(`span`,{className:`nx-refs-row-label`,children:[e.main?`● `:`○ `,e.label]}),e.tag?(0,c.jsx)(`span`,{className:`nx-refs-row-tag`,children:e.tag}):null,(0,c.jsx)(`span`,{className:`nx-refs-row-sub mono`,children:e.rel||e.path||``})]},e.docId))]}),(0,c.jsx)(`div`,{className:`nx-refs-note`,children:`点一行在工作区打开文档页签;完整管理与就地编辑走「查看详情」。`})]})}export{f as default};
@@ -0,0 +1,12 @@
1
+ var e=`## 验收反馈`,t=`## 反馈修改`;function n(e){return String(e??``).split(`
2
+ `).map(e=>e.trim()?`**${e}**`:e).join(`
3
+ `)}function r(e){let t=String(e??``).trim();return t?`> 锚定:\n> ${t.replace(/\n/g,`
4
+ > `)}`:``}var i=/完成总结/,a=/第\s*(\d+)\s*轮/,o=/^>\s*\[![A-Za-z][\w-]*\][ \t]*(.*)$/;function s(e){return`第 ${Number(e)||1} 轮 · 完成总结`}function c(e){return`第 ${Number(e)||1} 轮 · 验收反馈`}function l(e){return String(e??``).split(`
5
+ `).map(e=>e.trim()?`> ${e}`:`>`).join(`
6
+ `)}function u({round:e,ack:t}={}){let n=String(t??``).trim();return n?`> [!NOTE] ${s(e)}\n${l(n)}`:``}function d({round:e,quote:t,feedback:i,bold:a=!1}={}){let o=String(i??``).trim();if(!o)return``;let s=a?n(o):o,u=r(t),d=u?`${u.replace(/^> ?/gm,``)}\n\n${s}`:s;return`> [!WARNING] ${c(e)}\n${l(d)}`}function f(e){let t=String(e??``),n=0,r=0,o=t.match(/^## 上一轮完成总结\s*$/gm);n+=o?o.length:0;for(let e of t.matchAll(/^>\s*\[![A-Za-z][\w-]*\][ \t]*(.*)$/gm)){let t=String(e[1]??``);if(!i.test(t))continue;n+=1;let o=t.match(a);o&&(r=Math.max(r,Number(o[1])))}return Math.max(n,r)}function p(e){return f(e)+1}function m(e,t){let n=String(e??``),r=String(t??``).trim();if(!r||!n)return!1;if(n.includes(`## 上一轮完成总结\n\n${r}`))return!0;let a=n.split(`
7
+ `);for(let e=0;e<a.length;e++){let t=a[e].match(o);if(!t||!i.test(String(t[1]??``)))continue;let n=[];for(let t=e+1;t<a.length&&a[t].startsWith(`>`);t++)n.push(a[t].replace(/^>[ \t]?/,``));if(n.join(`
8
+ `).trim()===r)return!0}return!1}function h({base:e,ack:t,quote:n,feedback:r,bold:i=!0,round:a}={}){let o=String(e??``).trimEnd(),s=Number(a)||p(o),c=[];o&&c.push(o);let l=String(t??``).trim();l&&!m(o,l)&&c.push(u({round:s,ack:l}));let f=d({round:s,quote:n,feedback:r,bold:i});return f&&c.push(f),c.length?`${c.join(`
9
+
10
+ `)}\n`:``}function g({base:t,feedback:r,ackSummary:i,feedbackHeading:a=e,bold:o=!0,round:s}={}){if(String(a??``)===`## 反馈修改`){let e=[],i=String(t??``).trim();i&&e.push(i);let s=String(r??``).trim();return s&&e.push(`${a}\n\n${o?n(s):s}`),e.length?`${e.join(`
11
+
12
+ `)}\n`:``}return h({base:t,ack:i,feedback:r,bold:o,round:s})}export{r as i,e as n,t as r,g as t};
@@ -0,0 +1 @@
1
+ .pp-field{flex-direction:column;gap:4px;min-width:0;display:flex;position:relative}.pp-field-ta{box-sizing:border-box;resize:vertical;border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);width:100%;color:var(--ink,#16181c);border-radius:7px;padding:7px 9px;font-family:ui-monospace,Consolas,monospace;font-size:12px;line-height:1.6}.pp-field-ta:focus{border-color:var(--mdw-accent,#2f6f5e);outline:none}.pp-field-bar{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.pp-field-ph-btn{border:1px solid var(--line,#e4e2dc);font:inherit;color:var(--ink-2,#4b515a);cursor:pointer;background:0 0;border-radius:6px;padding:1px 7px;font-size:11px}.pp-field-ph-btn:hover{background:var(--soft,#f1f0ec)}.pp-field-ph-btn.on{background:var(--mdw-accent-soft,#e8f2ee);border-color:var(--mdw-accent,#2f6f5e)}.pp-field-used{flex-wrap:wrap;gap:4px;display:inline-flex}.pp-field-used-chip{color:var(--mid,#838a93);background:var(--soft,#f1f0ec);border-radius:5px;padding:0 5px;font-size:10px}.pp-field-menu{z-index:30;background:var(--paper,#fff);border:1px solid var(--soft-2,#ddd9d0);min-width:230px;max-height:320px;box-shadow:var(--shadow);border-radius:8px;margin-top:4px;padding:4px;position:absolute;top:100%;left:0;overflow:auto}.pp-field-menu-sec{padding:2px 0}.pp-field-menu-lab{letter-spacing:.06em;text-transform:uppercase;color:var(--mid,#838a93);padding:4px 8px 2px;font-size:10px}.pp-field-menu-item{cursor:pointer;width:100%;font:inherit;color:var(--ink,#16181c);text-align:left;background:0 0;border:0;border-radius:5px;align-items:baseline;gap:8px;padding:4px 8px;font-size:11.5px;display:flex}.pp-field-menu-item:hover{background:var(--soft,#f1f0ec)}.pp-field-menu-desc{color:var(--mid,#838a93);font-size:10.5px}.pp-field-hint{color:var(--mid,#838a93);font-size:11px;line-height:1.6}.pp-items-item{align-items:flex-start;gap:8px;margin-bottom:8px;display:flex}.pp-items-no{background:var(--soft,#f1f0ec);width:18px;height:18px;color:var(--mid,#838a93);border-radius:50%;flex:none;justify-content:center;align-items:center;margin-top:6px;font-size:10px;display:flex}.pp-items-body{flex:1;min-width:0}.pp-items-row{cursor:pointer;width:100%;font:inherit;text-align:left;background:0 0;border:0;border-radius:7px;align-items:center;gap:10px;padding:6px 8px;display:flex}.pp-items-row:hover{background:var(--soft,#f1f0ec)}.pp-items-row .pp-items-no{width:auto;height:auto;color:var(--mid,#838a93);font-variant-numeric:tabular-nums;background:0 0;margin-top:0;font-size:10.5px}.pp-items-title{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--ink,#16181c);flex:1;font-size:12.5px;overflow:hidden}.pp-items-len{color:var(--faint,#a9aeb4);font-variant-numeric:tabular-nums;flex:none;font-size:10.5px}
@@ -0,0 +1,10 @@
1
+ import{S as e,_ as t,f as n,g as r,h as i,l as a,v as o,y as s}from"./task-status-BP6y8MVu.js";import{A as c,k as ee}from"./index-B_HPAoNR.js";import{t as l}from"./route-crumb-C5LPu1Qx.js";import{i as u,n as d}from"./Introduction-DO6_gTk-.js";import{t as f}from"./bar-DoiwB4eA.js";import{t as p}from"./member-picker--32VkTmv.js";import{t as m}from"./button-M9TUn-AR.js";var h=e(s(),1),g=o(),_={new:{label:`新增`,cls:`new`},changed:{label:`有差异`,cls:`changed`},same:{label:`一致`,cls:`same`}};function te({onClose:e,onChanged:n,repos:a,boards:o}){let s=i(),c=r(),[ee,l]=(0,h.useState)(`import`),[u,d]=(0,h.useState)({}),[f,p]=(0,h.useState)({}),[m,te]=(0,h.useState)(!1),[v,y]=(0,h.useState)(``),[b,x]=(0,h.useState)(``),[S,C]=(0,h.useState)(null),[w,T]=(0,h.useState)({}),[E,D]=(0,h.useState)({}),[ne,re]=(0,h.useState)(`ours`),[ie,ae]=(0,h.useState)(`none`),[O,k]=(0,h.useState)(``),[A,j]=(0,h.useState)(null),[M,N]=(0,h.useState)(!1),P=(0,h.useMemo)(()=>a||[],[a]),F=(0,h.useMemo)(()=>P.map(e=>e.key),[P]),oe=(0,h.useMemo)(()=>(o||[]).map(e=>e.name),[o]),se=e=>{let t={};for(let n of F)t[n]=e;d(t)},ce=e=>{let t={};for(let n of oe)t[n]=e;p(t)},le=()=>{let e={};for(let t of F)e[t]=!u[t];d(e)},ue=()=>s(async()=>{let e=Object.keys(u).filter(e=>u[e]),n=Object.keys(f).filter(e=>f[e]),r={repos:e.length&&e.length!==F.length?e:void 0,boards:n.length&&n.length!==oe.length?n.map(e=>`board/${e}`):void 0,noUnassigned:m},i=new URLSearchParams;r.repos?.length&&i.set(`repos`,r.repos.join(`,`)),r.boards?.length&&i.set(`boards`,r.boards.join(`,`)),m&&i.set(`no-unassigned`,`1`);let a=await t(`/api/repos/export`+(i.toString()?`?`+i:``));y(JSON.stringify(a,null,2)),c(`已生成布局:${a.repos.length} 个仓库 / ${a.boards.length} 个看板`)}),de=()=>{if(!v)return;let e=new Blob([v],{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)},I=async e=>{let t=e.target.files?.[0];t&&(x(await t.text()),C(null),j(null))},L=()=>s(async()=>{if(b.trim()){N(!0);try{let e=await t(`/api/repos/import/diff`,{method:`POST`,body:{json:b}});C(e);let n={};for(let t of e.repos)n[t.key]=t.status!==`same`;T(n);let r={};for(let t of e.boards)r[t.key]=t.status!==`same`;D(r),j(null),c(`差异:新增 ${e.summary.new} · 有差异 ${e.summary.changed} · 一致 ${e.summary.same} · 本地未拥有 ${e.summary.missing}`)}finally{N(!1)}}}),fe=()=>s(async()=>{let e=Object.keys(w).filter(e=>w[e]),r=Object.keys(E).filter(e=>E[e]);N(!0);try{let i=await t(`/api/repos/import`,{method:`POST`,body:{json:b,strategy:ne,clone:ie,selection:e.length?e:void 0,boards:r.length?r:void 0}});j(i),c(`导入完成:新建 ${i.created.length} · 覆盖 ${i.updated.length} · 另存 ${i.duplicated.length}`),await pe(),n&&await n()}finally{N(!1)}}),pe=(0,h.useCallback)(async()=>{try{let e=await t(`/api/repos/import/diff`,{method:`POST`,body:{json:b}});C(e);let n={};for(let t of e.repos)n[t.key]=t.status!==`same`;T(n)}catch{}},[b]),me=(0,h.useMemo)(()=>S?O?S.repos.filter(e=>e.status===O):S.repos:[],[S,O]),R=(e,r)=>s(async()=>{if(r){N(!0);try{await t(`/api/repos/clone`,{method:`POST`,body:{remote:r,key:e,type:`ref`,depth:1}}),c(`已克隆: ${e}`),await pe(),n&&await n()}finally{N(!1)}}}),he=e=>{let t={...w};for(let n of me)t[n.key]=e;T(t)};(0,h.useEffect)(()=>{let t=t=>{t.key===`Escape`&&(t.stopImmediatePropagation(),e())};return document.addEventListener(`keydown`,t,!0),()=>document.removeEventListener(`keydown`,t,!0)},[e]);let ge=(0,h.useMemo)(()=>{if(!S)return null;let e={new:0,changed:0,same:0};for(let t of S.repos)e[t.status]=(e[t.status]||0)+1;return e},[S]);return(0,g.jsx)(`div`,{className:`rp-full`,onMouseDown:t=>{t.target===t.currentTarget&&e()},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`+(ee===`import`?` on`:``),onClick:()=>l(`import`),children:`导入`}),(0,g.jsx)(`button`,{className:`rp-tab`+(ee===`export`?` on`:``),onClick:()=>l(`export`),children:`导出`})]}),(0,g.jsx)(`button`,{className:`btn small ghost`,onClick:e,children:`关闭`})]}),ee===`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:()=>se(!0),children:`全选仓库`}),(0,g.jsx)(`button`,{className:`btn small ghost`,onClick:()=>se(!1),children:`全不选`}),(0,g.jsx)(`button`,{className:`btn small ghost`,onClick:le,children:`反选`})]})]}),(0,g.jsxs)(`div`,{className:`rp-full-sel`,children:[P.map(e=>(0,g.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,g.jsx)(`input`,{type:`checkbox`,checked:!!u[e.key],onChange:t=>d(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)),P.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:()=>ce(!0),children:`全选`}),(0,g.jsx)(`button`,{className:`btn small ghost`,onClick:()=>ce(!1),children:`全不选`})]})]}),(0,g.jsxs)(`div`,{className:`rp-full-sel`,children:[(o||[]).map(e=>(0,g.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,g.jsx)(`input`,{type:`checkbox`,checked:!!f[e.name],onChange:t=>p(n=>({...n,[e.name]:t.target.checked}))}),(0,g.jsx)(`span`,{children:e.name})]},e.name)),o?.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:m,onChange:e=>te(e.target.checked)}),(0,g.jsx)(`span`,{children:`不带未分组的仓库`})]}),(0,g.jsxs)(`div`,{className:`form-acts`,children:[(0,g.jsx)(`button`,{className:`btn`,onClick:ue,children:`生成布局`}),(0,g.jsx)(`button`,{className:`btn ghost`,disabled:!v,onClick:de,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:v,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:I}),(0,g.jsx)(`textarea`,{className:`rp-full-input`,rows:7,spellCheck:`false`,placeholder:`粘贴布局 JSON,或选一个 .json 文件`,value:b,onChange:e=>{x(e.target.value),C(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:!b.trim()||M,onClick:L,children:`差异检查`})}),S?(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:ne===e,onChange:()=>re(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:ie,onChange:e=>ae(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:M,onClick:fe,children:[`执行导入(已选 `,Object.values(w).filter(Boolean).length,`)`]})})]}):null,A?(0,g.jsxs)(`div`,{className:`rp-import-result`,children:[(0,g.jsxs)(`div`,{children:[`新建 `,A.created.length,` · 覆盖 `,A.updated.length,` · 另存 `,A.duplicated.length,` · 跳过 `,A.skipped.length]}),(0,g.jsxs)(`div`,{className:`muted`,children:[`看板 新建 `,A.boardsCreated,` / 合并 `,A.boardsMerged,` · 参考关系 `,A.links]}),A.cloned.length?(0,g.jsxs)(`div`,{children:[`克隆 `,A.cloned.length,` 个`]}):null,A.unmatched.length?(0,g.jsxs)(`div`,{className:`rp-layout-warn`,children:[`本地未拥有 `,A.unmatched.length,` 条(见下方差异表)`]}):null]}):null]}),(0,g.jsx)(`div`,{className:`rp-full-col rp-full-col-wide`,children:S?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,g.jsxs)(`span`,{children:[`差异(新增 `,ge.new,` · 有差异 `,ge.changed,` · 一致 `,ge.same,S.summary.missing?` · 本地未拥有 ${S.summary.missing}`:``,`)`]}),(0,g.jsxs)(`span`,{className:`acts`,children:[(0,g.jsx)(`button`,{className:`rp-chip`+(O===``?` on`:``),onClick:()=>k(``),children:`全部`}),(0,g.jsx)(`button`,{className:`rp-chip`+(O===`new`?` on`:``),onClick:()=>k(`new`),children:`新增`}),(0,g.jsx)(`button`,{className:`rp-chip`+(O===`changed`?` on`:``),onClick:()=>k(`changed`),children:`有差异`}),(0,g.jsx)(`button`,{className:`rp-chip`+(O===`same`?` on`:``),onClick:()=>k(`same`),children:`一致`}),(0,g.jsx)(`button`,{className:`btn small ghost`,onClick:()=>he(!0),children:`全选`}),(0,g.jsx)(`button`,{className:`btn small ghost`,onClick:()=>he(!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:[me.map(e=>(0,g.jsxs)(`tr`,{className:`rp-diff-row `+_[e.status]?.cls,children:[(0,g.jsx)(`td`,{children:(0,g.jsx)(`input`,{type:`checkbox`,disabled:e.status===`same`,checked:!!w[e.key],onChange:t=>T(n=>({...n,[e.key]:t.target.checked}))})}),(0,g.jsx)(`td`,{children:(0,g.jsx)(`span`,{className:`rp-status `+_[e.status]?.cls,children:_[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:M,onClick:()=>R(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)),S.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))]})]})}),S.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:`看板`})}),S.boards.map(e=>(0,g.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,g.jsx)(`input`,{type:`checkbox`,checked:!!E[e.key],onChange:t=>D(n=>({...n,[e.key]:t.target.checked}))}),(0,g.jsx)(`span`,{className:`rp-status `+_[e.status]?.cls,children:_[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)),S.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:M,onClick:()=>R(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,点「差异检查」后在这里逐条查看与勾选。`})})]})]})})}function v(e){let t=String(e??``);return t.trim()?t.replace(/\{\{#[^}]*\}\}/g,``).replace(/\{\{\/[^}]*\}\}/g,``).replace(/\{\{[^}]*\}\}/g,``).replace(/「\s*」/g,``).replace(/〔\s*〕/g,``).replace(/\s+/g,` `).trim()||t.replace(/\s+/g,` `).trim():``}function y({value:e,onChange:t,placeholder:n,rows:r=3,hint:i=``}){return(0,g.jsxs)(`div`,{className:`pp-field`,children:[(0,g.jsx)(`textarea`,{className:`pp-field-ta mono`,rows:r,value:e,placeholder:n,spellCheck:!1,onChange:e=>t(e.target.value)}),i?(0,g.jsx)(`div`,{className:`pp-field-hint`,children:i}):null]})}function b({items:e,onChange:t,disabled:n=!1,placeholder:r,rows:i=3,accordion:a=!1,openIndex:o,onOpenChange:s}){let[c,ee]=(0,h.useState)(-1),l=o===void 0?c:o,u=e=>{ee(e),s&&s(e)},d=(n,r)=>t(e.map((e,t)=>t===n?r:e)),f=n=>{t(e.filter((e,t)=>t!==n)),u(e=>e===n?-1:e>n?e-1:e)};return a?(0,g.jsx)(`div`,{className:`pp-items`,children:e.map((e,t)=>{let a=l===t,o=v(e.split(`
2
+ `)[0]);return(0,g.jsx)(`div`,{className:`pp-items-item`,children:a?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,g.jsx)(`div`,{className:`pp-items-body`,children:(0,g.jsx)(y,{value:e,onChange:e=>d(t,e),placeholder:r,rows:i})}),(0,g.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:n,onClick:()=>f(t),title:`删除第 ${t+1} 条`,children:`删除`})]}):(0,g.jsxs)(`button`,{type:`button`,className:`pp-items-row`,disabled:n,title:`点击展开编辑`,onClick:()=>u(t),children:[(0,g.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,g.jsx)(`span`,{className:`pp-items-title`,children:o||`(空)`}),(0,g.jsxs)(`span`,{className:`pp-items-len`,children:[String(e).length,` 字`]})]})},t)})}):(0,g.jsx)(g.Fragment,{children:e.map((e,t)=>(0,g.jsxs)(`div`,{className:`pp-items-item`,children:[(0,g.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,g.jsx)(`div`,{className:`pp-items-body`,children:(0,g.jsx)(y,{value:e,onChange:e=>d(t,e),placeholder:r,rows:i})}),(0,g.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:n,onClick:()=>f(t),title:`删除第 ${t+1} 条`,children:`删除`})]},t))})}var x=10,S=2e3,C=`不要直接结束本轮:完成上面的任务(%s)之后,继续调用 nx-kv localtask get(带 --summary 当前现状)领取下一条任务,直到 get 返回 timeout 为止。`;function w({repo:e,onClose:n,onSaved:i}){let o=ee()||{},s=r(),c=e.getLoop&&typeof e.getLoop==`object`?e.getLoop:null,[l,u]=(0,h.useState)(!!(c&&c.enabled)),[d,f]=(0,h.useState)(String(c&&c.waitMinutes||10)),[p,_]=(0,h.useState)(()=>{let e=c&&c.template;return(Array.isArray(e)?e:e==null?[]:[e]).map(e=>String(e??``).trim()).filter(Boolean).map(e=>e.replaceAll(`{{task.id}}`,`%s`))}),[te,v]=(0,h.useState)(-1),[y,w]=(0,h.useState)(``),[T,E]=(0,h.useState)(!1),D=async n=>{E(!0);try{let r=n&&n.enabled!==void 0?n.enabled:l,a=p.map(e=>String(e??``).trim().replaceAll(`%s`,`{{task.id}}`)).filter(Boolean).slice(0,x);await t(`/api/repos/`+encodeURIComponent(e.id),{method:`PATCH`,body:{getLoop:{enabled:r,...r?{waitMinutes:Number(d)||10,template:a}:{}}}}),s(r?`已保存「${e.name}」的持续 get 设置(模板 ${a.length} 条)`:`已关闭「${e.name}」的持续 get`),o.refreshRepos&&o.refreshRepos(),i&&i()}catch(e){s(String(e.message||e))}finally{E(!1)}},ne=async e=>{u(e),await D({enabled:e})},re=()=>{let e=y.trim();!e||p.length>=x||(_([...p,e.slice(0,S)]),v(p.length),w(``))};return(0,g.jsx)(a,{title:`持续 get · ${e.name}`,onClose:n,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`+(l?` on`:``),onClick:()=>ne(!l),disabled:T,children:[(0,g.jsx)(`span`,{className:`dot`}),l?`开`:`关`]})]}),l&&(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:d,onChange:e=>f(e.target.value),inputMode:`numeric`}),`分钟`]})]}),(0,g.jsxs)(`div`,{className:`rp-gl-tpl`,children:[(0,g.jsx)(`div`,{className:`rp-gl-h`,children:`收尾模板`}),(0,g.jsxs)(`div`,{className:`rp-gl-oneline`,children:[(0,g.jsx)(m,{variant:`secondary`,title:`填入内置默认(继续 get 直到 timeout)`,onClick:()=>w(C),children:`填入内置默认`}),(0,g.jsx)(`input`,{className:`rp-gl-oneline-input`,value:y,placeholder:`一句话(%s = 任务编号)`,onChange:e=>w(e.target.value),onKeyDown:e=>{e.key===`Enter`&&re()}}),(0,g.jsx)(m,{variant:`secondary`,disabled:T||!y.trim(),onClick:re,children:`添加`})]}),p.length?(0,g.jsx)(b,{items:p,onChange:_,disabled:T,placeholder:`一句话(%s = 任务编号)`,accordion:!0,openIndex:te,onOpenChange:v}):(0,g.jsx)(`div`,{className:`rp-gl-note`,children:`未配置模板 —— 用默认「完成后续调 localtask get;没活时每轮最多阻塞 {{getloop.waitMinutes}} 分钟,直到 timeout」。`})]}),(0,g.jsxs)(`div`,{className:`rp-gl-acts`,children:[(0,g.jsx)(m,{variant:`secondary`,disabled:T||p.length>=x,title:p.length>=x?`最多 ${x} 条`:`新增一条「继续 get」指令`,onClick:()=>{_([...p,``]),v(p.length)},children:`添加一条…`}),(0,g.jsx)(`span`,{className:`spacer`}),(0,g.jsx)(m,{variant:`primary`,disabled:T,onClick:()=>D(),children:`保存持续 get 设置`})]})]})]})})}function T(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 E(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 D={path:``,name:``,desc:``,notes:``,type:`dev`,remote:``,key:``,icon:``};function ne({path:e}){let t=String(e||``),n=t.replace(/\\/g,`/`).lastIndexOf(`/`);return n<0?(0,g.jsx)(c,{text:t,children:t}):(0,g.jsxs)(c,{text:t,title:`点击复制完整路径`,children:[(0,g.jsx)(`span`,{className:`anc`,children:t.slice(0,n)}),t.slice(n)]})}function re({docs:e,onOpen:t}){let n=e&&e.main,r=e&&e.links||[],i=+!!n+r.length;return(0,g.jsxs)(`button`,{type:`button`,className:`rp-docs-entry`,title:`查看完整文档列表(主篇 / 补充 / reference / 组内),可就地编辑`,onClick:t,children:[(0,g.jsx)(`span`,{className:`rp-docs-entry-main`+(n&&n.exists?``:` ghost`),children:n&&n.exists?n.summary||n.title:`+ 写项目介绍`}),(0,g.jsx)(`span`,{className:`rp-docs-entry-n`,children:i>0?`${i} 篇 · 查看详情`:`查看详情`})]})}function ie({r:e,filterBoard:t,refsOfRepo:n,acts:r}){let i=n.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)||10} 分钟阻塞窗口)`,"aria-label":`持续 get 已开启`}):null]}),(0,g.jsx)(`span`,{className:`mono rp-name-path`,children:(0,g.jsx)(ne,{path:e.path})})]}),(0,g.jsx)(`td`,{className:`rp-cell-docs`,children:(0,g.jsx)(re,{docs:e.descDocs,onOpen:()=>r.docs(e)})}),(0,g.jsxs)(`td`,{className:`rp-refs`,children:[i.length?i.map(t=>(0,g.jsxs)(`button`,{className:`rp-ref-chip`,title:`直接绑定:${t.remote||``}${t.note?`
3
+ `+t.note:``}\n点击改绑定描述`,onClick:()=>r.refNote(t,e),children:[t.note?(0,g.jsx)(`span`,{className:`rp-ref-chip-dot`}):null,t.name]},t.key)):(0,g.jsx)(`span`,{className:`muted rp-refs-none`,children:`—`}),(0,g.jsx)(m,{small:!0,className:`rp-ref-bind`,title:`管理这个仓库绑定的参考仓库`,onClick:()=>r.bind(e),children:`绑定`})]}),(0,g.jsx)(`td`,{className:`rp-cell-groups`,children:(e.boards||[]).length?e.boards.map(e=>(0,g.jsx)(`button`,{className:`rp-group-chip`+(t&&t.id===e.id?` on`:``),title:`只看「${e.name}」${e.note?`\n组内描述:${e.note}`:``}`,onClick:()=>r.filter(e.id),children:e.name},e.id)):(0,g.jsx)(`span`,{className:`muted rp-refs-none`,children:`—`})}),(0,g.jsx)(`td`,{className:`rp-acts`,children:(0,g.jsx)(f,{kind:`repos-row`,renderers:{edit:()=>(0,g.jsx)(m,{small:!0,onClick:()=>r.edit(e),children:`编辑`}),open:()=>(0,g.jsx)(m,{small:!0,title:`在文件管理器中打开`,onClick:()=>r.open(e),children:`打开`}),del:()=>(0,g.jsx)(m,{small:!0,danger:!0,onClick:()=>r.del(e),children:`删除`}),getloop:()=>(0,g.jsx)(m,{small:!0,title:`持续 get(waitgoal)配置`,onClick:()=>r.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)(m,{small:!0,onClick:()=>r.remote(e),children:`对齐 remote`})},actions:{edit:()=>r.edit(e),open:()=>r.open(e),del:()=>r.del(e),getloop:()=>r.getloop(e),remote:()=>r.remote(e)},titles:{getloop:`持续 get(waitgoal)配置`,remote:`key 与远程 git 地址对齐`,del:`删除仓库登记(磁盘文件不受影响)`}})})]})}function ae(){let e=i(),o=r(),{dialog:s,node:_}=n(),v=ee()||{},{openByDocId:y}=u(),[b,x]=(0,h.useState)(D),[S,C]=(0,h.useState)(null),[ne,ae]=(0,h.useState)(!1),[O,k]=(0,h.useState)(!1),[A,j]=(0,h.useState)(null),[M,N]=(0,h.useState)(null),[P,F]=(0,h.useState)(``),[oe,se]=(0,h.useState)(``),[ce,le]=(0,h.useState)(!1),[ue,de]=(0,h.useState)(!1),[I,L]=(0,h.useState)(null),[fe,pe]=(0,h.useState)(!1),[me,R]=(0,h.useState)(``),[he,ge]=(0,h.useState)(null),[z,_e]=(0,h.useState)([]),[B,ve]=(0,h.useState)([]),ye=e=>t=>x(n=>({...n,[e]:t.target.value})),be=e=>{let t=e.target.value;x(e=>({...e,remote:t,key:O?e.key:E(t)}))},xe=e=>{k(!0),x(t=>({...t,key:e.target.value}))},[Se,Ce]=(0,h.useState)(!1),[we,Te]=(0,h.useState)(null),[Ee,De]=(0,h.useState)(!1),[Oe,ke]=(0,h.useState)({gitRepoRoot:``,gitDevRoot:``}),[Ae,je]=(0,h.useState)(!1),[V,Me]=(0,h.useState)({url:``,name:``,desc:``,depth:`1`}),[Ne,Pe]=(0,h.useState)({}),[Fe,Ie]=(0,h.useState)(null),[Le,Re]=(0,h.useState)(null),[ze,Be]=(0,h.useState)({}),[H,Ve]=(0,h.useState)(null),[He,Ue]=(0,h.useState)({}),[U,We]=(0,h.useState)(null),[Ge,Ke]=(0,h.useState)(``),[qe,Je]=(0,h.useState)(!1),[W,Ye]=(0,h.useState)(null),[G,Xe]=(0,h.useState)(null),[Ze,Qe]=(0,h.useState)(!1),[$e,et]=(0,h.useState)(null),[tt,nt]=(0,h.useState)(null),rt=()=>{x(D),C(null),ae(!1),k(!1)},K=(0,h.useCallback)(async()=>{_e(await t(`/api/repos`).catch(()=>[])||[])},[]),q=(0,h.useCallback)(async()=>{N(await t(`/api/boards`).catch(()=>null))},[]),it=(0,h.useCallback)(async()=>{let e=await t(`/api/docs`).catch(()=>null);ve(e&&e.docs||[])},[]);(0,h.useEffect)(()=>{K(),q(),it()},[K,q,it]),(0,h.useEffect)(()=>{let e=()=>{let e=location.hash.split(`?`)[1]||``;if(!e)return;let t=new URLSearchParams(e),n=t.get(`board`);n&&(F(n),t.get(`add`)&&j(n))};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let at=(0,h.useCallback)(async()=>{Te(await t(`/api/setting`).catch(()=>null))},[]),J=(0,h.useCallback)(async()=>{Ie(await t(`/api/repos/ref/check`).catch(()=>null))},[]);(0,h.useEffect)(()=>{at(),J()},[at,J]);let ot=()=>e(async()=>{let e={};Oe.gitRepoRoot.trim()&&(e.gitRepoRoot=Oe.gitRepoRoot.trim()),Oe.gitDevRoot.trim()&&(e.gitDevRoot=Oe.gitDevRoot.trim()),Object.keys(e).length&&(Te(await t(`/api/setting`,{method:`POST`,body:e})),De(!1),o(`已保存存储根目录`))}),st=()=>e(async()=>{let e=V.url.trim();if(!e)return;let n={url:e,name:V.name.trim()||void 0,desc:V.desc.trim()||void 0,depth:parseInt(V.depth,10)||1,"no-bind":!0},r=X.filter(e=>Ne[`repo:`+e.id]).map(e=>e.id),i=Y.filter(e=>Ne[`board:`+e.id]).map(e=>e.id);r.length&&(n.bind=r),i.length&&(n.board=i);let a=await t(`/api/repos/ref/clone`,{method:`POST`,body:n});je(!1),Me({url:``,name:``,desc:``,depth:`1`}),Pe({}),o(`已克隆: ${a.name} → ${a.dest||a.path}`),await Promise.all([K(),q(),J()])}),ct=n=>e(async()=>{let e=await t(`/api/repos/ref/sync`,{method:`POST`,body:{id:n.id}});o(e.status===`updated`?`已更新: ${e.name}`:e.status===`upToDate`?`${e.name} 已是最新`:`${e.name}: ${e.status} ${e.output||``}`)}),lt=()=>e(async()=>{let e=await t(`/api/repos/ref/sync`,{method:`POST`,body:{all:!0}}),n=e.results.filter(e=>e.status!==`updated`&&e.status!==`upToDate`);o(`同步 ${e.synced} 个${n.length?`,${n.length} 个有问题(见检查结果)`:`,全部完成`}`),await J()}),ut=e=>{let t={};for(let n of e.linked||[])t[n.kind+`:`+n.id]=!0;Be(t),Re(e)},dt=()=>e(async()=>{if(!Le)return;let e=new Set((Le.linked||[]).map(e=>e.kind+`:`+e.id)),n=new Set(Object.keys(ze).filter(e=>ze[e]));for(let r of n){if(e.has(r))continue;let[n,i]=r.split(`:`);await t(`/api/repos/bind`,{method:`POST`,body:{id:Le.key,[n]:[i]}})}for(let r of e){if(n.has(r))continue;let[e,i]=r.split(`:`);await t(`/api/repos/bind`,{method:`POST`,body:{id:Le.key,[e]:[i],remove:!0}})}Re(null),await Promise.all([K(),J()])}),ft=()=>e(async()=>{if(!H)return;let e=new Set;for(let t of H.linked||[])t.kind===`ref`&&e.add(t.id);for(let t of Z)(t.linked||[]).some(e=>e.kind===`repo`&&e.id===H.key)&&e.add(t.key);let n=new Set(Object.keys(He).filter(e=>He[e]));for(let r of n)e.has(r)||await t(`/api/repos/bind`,{method:`POST`,body:{id:r,repo:[H.key]}});for(let r of e)n.has(r)||await t(`/api/repos/bind`,{method:`POST`,body:{id:r,repo:[H.key],remove:!0}});Ve(null),await Promise.all([K(),J()])}),pt=(e,t,n,r)=>{let i=(e.linked||[]).find(e=>e.kind===t&&e.id===n);We({ref:e,kind:t,targetId:n,targetName:r}),Ke(i?.note||``)},mt=()=>e(async()=>{let{ref:e,kind:n,targetId:r}=U;await t(`/api/repos/ref/note`,{method:`POST`,body:{id:e.key,[n]:r,note:Ge}}),We(null),await Promise.all([K(),J()]),o(`已保存绑定描述`)}),ht=(n,r,i)=>e(async()=>{await t(`/api/repos/bind`,{method:`POST`,body:{id:n.key,[r]:[i],remove:!0}}),await Promise.all([K(),J()])}),gt=(0,h.useCallback)(async()=>{await Promise.all([K(),q(),J()])},[K,q,J]),_t=async e=>{let n=e&&e.key?e.key:``;if(!n){o(`这个仓库还没有 key —— 先 nx-kv repo key set <id> <key>`);return}try{let e=await t(`/api/repos/remote/list?id=`+encodeURIComponent(n));if(!e||!Array.isArray(e.remotes))throw Error(`远程地址读取失败`);Ye(e),Xe(null),Qe(!0)}catch(e){o(String(e&&e.message||e))}},vt=n=>e(async()=>{await t(`/api/repos/remote/pick`,{method:`POST`,body:{id:W.key,url:n}}),Qe(!1),o(`已对齐 remote`),await Promise.all([K(),J()])}),yt=async e=>{let n=W?W.key:``;if(!n){Xe({url:``,status:`unreachable`,detail:`没有仓库标识`});return}Xe({url:e||W.current||``,status:`checking`,detail:`检查中…`});try{let r=await t(`/api/repos/remote/check?id=`+encodeURIComponent(n)+(e?`&url=`+encodeURIComponent(e):``));Xe(r)}catch(t){Xe({url:e||W.current||``,status:`unreachable`,detail:String(t&&t.message||t)})}},Y=(0,h.useMemo)(()=>M&&M.boards||[],[M]),X=(0,h.useMemo)(()=>z.filter(e=>(e.type||`dev`)!==`ref`),[z]),Z=(0,h.useMemo)(()=>z.filter(e=>e.type===`ref`),[z]),bt=(0,h.useMemo)(()=>{let e=X;P&&(e=e.filter(e=>(e.boards||[]).some(e=>e.id===P)));let t=oe.trim().toLowerCase();if(!t)return e;let n=e=>{let n=e.descDocs&&e.descDocs.main;return n&&[n.title,n.summary,n.rel].some(e=>e&&String(e).toLowerCase().includes(t))?!0:(e.descDocs&&e.descDocs.links||[]).some(e=>[e.title,e.tag,e.note,e.rel].some(e=>e&&String(e).toLowerCase().includes(t)))};return e.filter(e=>[e.name,e.key,e.path,e.desc].some(e=>e&&String(e).toLowerCase().includes(t))||(e.boards||[]).some(e=>String(e.name||``).toLowerCase().includes(t))||n(e))},[X,P,oe]),Q=(0,h.useMemo)(()=>Y.find(e=>e.id===P)||null,[Y,P]),xt=(0,h.useMemo)(()=>Y.find(e=>e.id===A)||null,[Y,A]),St=(0,h.useMemo)(()=>{let e=new Map;return(Fe?.refs||[]).forEach(t=>e.set(t.id,t)),e},[Fe]),Ct=(0,h.useMemo)(()=>{let e=new Map,t=(t,n,r)=>{e.has(t)||e.set(t,[]),e.get(t).push({key:n.key,id:n.id,name:n.name,remote:n.remote||``,note:r||``})},n=new Map(Z.map(e=>[e.key,e])),r=new Set;for(let e of X)for(let i of e.linked||[]){if(i.kind!==`ref`)continue;let a=n.get(i.id);a&&(r.add(e.key+`:`+a.key),t(e.key,a,i.note))}for(let e of Z)for(let n of e.linked||[])n.kind===`repo`&&(r.has(n.id+`:`+e.key)||t(n.id,e,n.note));return e},[X,Z]),wt=(0,h.useMemo)(()=>{if(!Q)return[];let e=new Set((Q.repos||[]).map(e=>e.key)),t=Q.key||`board/${Q.name}`;return Z.map(n=>{let r=(n.linked||[]).find(e=>e.kind===`board`&&e.id===t),i=(n.linked||[]).filter(t=>t.kind===`repo`&&e.has(t.id));return!r&&!i.length?null:{...n,boardNote:r?.note||``,viaRepos:i.map(e=>(Q.repos||[]).find(t=>t.key===e.id)?.name||e.id)}}).filter(Boolean)},[Z,Q]),Tt=(0,h.useMemo)(()=>{let e=new Map,t=(t,n,r,i,a)=>{if(!t)return;e.has(t)||e.set(t,[]);let o=e.get(t);o.some(e=>e.label===r)||o.push({key:t+`|`+r,kind:n,label:r,tip:i||r,target:a})};for(let e of z){let n=e.descDocs&&e.descDocs.main;n&&n.rel&&t(n.rel,`repo`,`仓:${e.name}`,`「${e.name}」的项目介绍主篇`,e.key);for(let n of e.descDocs&&e.descDocs.links||[])t(String(n.docId||``).startsWith(`rel:`)?String(n.docId).slice(4):``,`repo`,`仓:${e.name}`,`「${e.name}」的补充文档${n.tag?`(${n.tag})`:``}`,e.key);for(let n of e.boards||[])t(n.noteDocRel,`scoped`,`组内:${n.name} / ${e.name}`,`「${e.name}」在组「${n.name}」里的组内描述`,n.id)}for(let e of Y){e.docRel&&t(e.docRel,`board`,`组:${e.name}`,`组「${e.name}」的介绍文档`,e.id);for(let n of e.docLinks||[])t(n.rel,`board`,`组:${e.name}`,`组「${e.name}」的补充文档`,e.id);for(let n of e.repos||[])t(n.noteDocRel,`scoped`,`组内:${e.name} / ${n.name||n.key}`,`组「${e.name}」里的组内描述`,e.id)}return e},[z,Y]),Et=()=>{x(D),C(null),k(!1),ae(!0)},[Dt,Ot]=(0,h.useState)(`all`),[kt,At]=(0,h.useState)(``),jt=(0,h.useMemo)(()=>{let e=kt.trim().toLowerCase(),t=B.map(e=>({d:e,hosts:Tt.get(e.rel)||[]})).filter(t=>!e||[t.d.title,t.d.name,t.d.rel].some(t=>t&&String(t).toLowerCase().includes(e))||t.hosts.some(t=>t.label.toLowerCase().includes(e)));return Dt===`orphan`?t.filter(e=>!e.hosts.length):Dt===`all`?t:t.filter(e=>e.hosts.some(e=>e.kind===Dt))},[B,Tt,Dt,kt]),Mt=(0,h.useMemo)(()=>{let e={all:B.length,repo:0,board:0,scoped:0,orphan:0};for(let t of B){let n=Tt.get(t.rel)||[];n.length||(e.orphan+=1);for(let t of[`repo`,`board`,`scoped`])n.some(e=>e.kind===t)&&(e[t]+=1)}return e},[B,Tt]),Nt=(e,t=`start`)=>{if(!e)return;let n=e.parentElement;for(;n;){let e=getComputedStyle(n);if((e.overflowY===`auto`||e.overflowY===`scroll`)&&n.scrollHeight>n.clientHeight)break;n=n.parentElement}n||=document.scrollingElement||document.documentElement;let r=n.getBoundingClientRect?n.getBoundingClientRect().top:0,i=e.getBoundingClientRect().top-r,a=t===`center`?(n.clientHeight-e.offsetHeight)/2:12;n.scrollTop=Math.max(0,n.scrollTop+i-a)},Pt=e=>Nt(document.getElementById(e)),Ft=e=>{if(!e||!e.target)return;if(e.kind===`board`){F(e.target),Pt(`rp-repos`);return}F(``);let t=document.getElementById(`rp-row-`+e.target);if(!t){Pt(`rp-repos`);return}Nt(t,`center`),t.classList.add(`rp-row-flash`),setTimeout(()=>t.classList.remove(`rp-row-flash`),1400)},It=(0,h.useMemo)(()=>{if(!S)return null;let e=z.find(e=>e.id===S);return e&&e.descDocs||null},[S,z]),Lt=()=>e(async()=>{if(!b.path.trim())return;let e=b.remote.trim(),n=b.key.trim(),r=n?T(n):E(e);if(!r){o(`仓库 key 必填:没有远程 git 地址时必须手工填写 key(不会再自动生成 local/<目录名>)`);return}let i={path:b.path.trim(),name:b.name.trim()||void 0,notes:b.notes,type:b.type===`ref`?`ref`:`dev`,remote:e||void 0,icon:b.icon.trim()};if(S){let t=z.find(e=>e.id===S),a=t&&t.key||``;if(O&&n===``){if(!e){o(`清空自定义 key 需要仓库有远程地址(否则 key 必填)`);return}i.key=``,i.keyCustom=!1}else if(O&&r!==a){if(!await s({title:`修改仓库 key`,message:`key 是仓库身份,改掉会连锁影响:\n\n「${a||`(空)`}」→「${r}」\n\n队列/看板/参考关系会跟随新 key 级联更新;docs/ 下按旧 key 生成的文档路径不会自动迁移,需要手动处理。确认修改?`,danger:!0}))return;i.key=r,i.keyCustom=!0}}else i.key=r,O&&(i.keyCustom=!0);S?await t(`/api/repos/${encodeURIComponent(S)}`,{method:`PATCH`,body:i}):await t(`/api/repos`,{method:`POST`,body:i}),rt(),await Promise.all([K(),q(),J()])}),$=(n,r)=>e(async()=>{if(n===`open`)await t(`/api/repos/open`,{method:`POST`,body:{id:r.id}});else if(n===`edit`)C(r.id),x({path:r.path,name:r.name||``,desc:r.desc||``,type:r.type||`dev`,remote:r.remote||``,notes:r.notes||``,key:r.key||``,icon:r.icon||``}),k(r.keyCustom===!0),ae(!0);else if(n===`del`){if(!await s({message:`删除仓库登记「${r.name}」?(仅移除登记,磁盘文件不受影响;各看板里的归属同步摘除)`,danger:!0}))return;await t(`/api/repos/${encodeURIComponent(r.id)}`,{method:`DELETE`}),await Promise.all([K(),q(),J()])}}),Rt=()=>e(async()=>{let e={name:I.name.trim()};e.name&&(I.id||(e.desc=I.desc.trim()||void 0),I.id?await t(`/api/boards/${encodeURIComponent(I.id)}`,{method:`PATCH`,body:e}):await t(`/api/boards`,{method:`POST`,body:e}),L(null),await q())}),zt=n=>e(async()=>{await s({message:`删看板「${n.name}」?它里面的 ${n.repos.length} 个仓库**仍留在中心清单里**(只是少了一份归属)。`,danger:!0})&&(await t(`/api/boards/${encodeURIComponent(n.id)}`,{method:`DELETE`,body:{}}),await Promise.all([K(),q()]))}),Bt=()=>e(async()=>{if(!me.trim())return;let e=await t(`/api/boards/import`,{method:`POST`,body:{json:me}});pe(!1),R(``),o(`已导入:新建 ${e.created} 个看板、合并 ${e.merged} 个、匹配仓库 ${e.matched} 个`+(e.unmatched.length?`;未匹配 ${e.unmatched.length} 条(见 CLI board import 输出)`:``)),await Promise.all([K(),q()])}),Vt=()=>e(async()=>{let e=await t(`/api/boards/export`);ge(JSON.stringify(e,null,2))}),Ht=async e=>{let t=e.target.files?.[0];t&&R(await t.text())},Ut=(0,h.useMemo)(()=>{let e=new Map;for(let t of[...X,...Z]){let n=String(t.path||``).split(/[\\/]/).filter(Boolean).pop()||``;for(let r of[t.name,n]){let n=String(r||``).toLowerCase();n&&!e.has(n)&&e.set(n,t)}}let t=[];for(let n of M&&M.boards||[])for(let r of n.repos||[]){if(r.present!==!1)continue;let i=String(r.key||``).split(`/`).filter(Boolean).pop()||``,a=e.get(String(r.name||``).toLowerCase())||e.get(i.toLowerCase())||null;t.push({...r,board:n.name,boardId:n.id,match:a})}return t},[M,X,Z]);if(M===null)return(0,g.jsxs)(`div`,{className:`rp-page`,children:[(0,g.jsx)(l,{}),(0,g.jsx)(`div`,{className:`muted`,style:{padding:20},children:`读取中…`}),_]});let Wt=n=>e(async()=>{await t(`/api/repos/clone`,{method:`POST`,body:{remote:n.remote,key:n.key,name:n.name||void 0,type:`dev`}}),o(`已克隆并登记:${n.name||n.key}`),K(),q()}),Gt=(n,r)=>e(async()=>{await t(`/api/boards/rekey`,{method:`POST`,body:{from:n.key,to:r}}),o(`已把「${n.name||n.key}」这个位置接到本机仓库`),K(),q()}),Kt=n=>e(async()=>{let e=await s({title:`把「${n.name||n.key}」接到哪个本机仓库?`,input:!0,placeholder:`本机仓库:id / key / 名称 / 绝对路径`});e&&(await t(`/api/boards/rekey`,{method:`POST`,body:{from:n.key,to:e}}),o(`已重绑——这个位置现在指向本机仓库`),K(),q())}),qt=n=>e(async()=>{confirm(`把「${n.name||n.key}」从组「${n.board}」里移除?\n\n只摘这个组里的位置:本机仓库与看板本身都不动。`)&&(await t(`/api/boards/assign`,{method:`POST`,body:{key:n.key,board:n.boardId,remove:!0}}),o(`已从组「${n.board}」移除`),q())}),Jt=()=>e(async()=>{let e=await t(`/api/boards/prune`,{method:`POST`,body:{apply:!1}});if(!e?.total){o(`没有可清理的占位(有远程地址的那些留着等 clone)`);return}let n=e.items.map(e=>`· ${e.name}(组 ${e.board})`).join(`
4
+ `);confirm(`清理 ${e.total} 个无来源占位?\n\n${n}\n\n它们没有远程地址,克隆不回来,只能删。`)&&(await t(`/api/boards/prune`,{method:`POST`,body:{apply:!0}}),o(`已清理 ${e.total} 个占位`),q())}),Yt=(n,r)=>e(async()=>{n&&(await t(`/api/docs/item`,{method:`POST`,body:{rel:n,body:`# ${r||n}\n\n`}}).catch(()=>{}),y(`rel:`+n),K(),it())}),Xt=e=>e.docPath?y(`path:`+e.docPath):Yt(e.docRel,`${e.name} · 组介绍`),Zt=e=>{let t=new Set((B||[]).map(e=>String(e.rel||``).toLowerCase())),n=`${e}.md`;if(!t.has(n.toLowerCase()))return n;for(let r=2;;r+=1)if(n=`${e}-${r}.md`,!t.has(n.toLowerCase()))return n},Qt=()=>e(async()=>{let e=Zt(`note/untitled`);await t(`/api/docs/item`,{method:`POST`,body:{rel:e,body:``}}).catch(()=>{}),de(!1),y(`rel:`+e),await it()}),$t=n=>e(async()=>{let e=Tt.get(n.rel)||[];await s({message:`删除文档「${n.title||n.rel}」?磁盘文件会被删除。`+(e.length?`它正被 ${e.length} 处引用(${e.map(e=>e.label).join(`、`)})。`:``),danger:!0})&&(await t(`/api/docs/item`,{method:`DELETE`,body:{ref:n.docId}}),o(`已删除:${n.rel}`),await Promise.all([it(),K(),q()]))}),en={open:e=>$(`open`,e),edit:e=>$(`edit`,e),del:e=>$(`del`,e),remote:e=>_t(e),getloop:e=>nt(e),docs:e=>et({kind:`repo`,owner:e}),filter:e=>F(t=>t===e?``:e),bind:e=>{let t={};for(let n of e.linked||[])n.kind===`ref`&&(t[n.id]=!0);for(let n of Z)t[n.key]||(n.linked||[]).some(t=>t.kind===`repo`&&t.id===e.key)&&(t[n.key]=!0);Ue(t),Ve(e)},refNote:(e,t)=>{let n=Z.find(t=>t.key===e.key);n&&pt(n,`repo`,t.key,t.name)}};return(0,g.jsxs)(`div`,{className:`rp-page`,children:[(0,g.jsxs)(`div`,{className:`page-head`,children:[(0,g.jsx)(`div`,{className:`title-block`,children:(0,g.jsx)(`h2`,{children:`仓库管理`})}),(0,g.jsx)(`div`,{className:`acts`,children:(0,g.jsx)(f,{kind:`repos`,titles:{add:`登记本机开发仓库`,boards:`分组管理:建组 / 成员 / 组介绍文档`,refs:`参考仓库面板:克隆 / 绑定 / 同步 / 检查 / 存储根`,transfer:`布局与仓库的导入导出(逐条选择 / 冲突方案 / 差异检查)`},actions:{add:Et,boards:()=>le(!0),refs:()=>Ce(!0),transfer:()=>Je(!0)}})})]}),Ut.length>0&&(0,g.jsxs)(`section`,{className:`rp-pending`,"data-testid":`rp-pending-init`,children:[(0,g.jsxs)(`header`,{className:`rp-pending-head`,children:[(0,g.jsxs)(`div`,{className:`rp-pending-head-main`,children:[(0,g.jsxs)(`h3`,{children:[`待初始化`,(0,g.jsx)(`span`,{className:`rp-pending-count`,children:Ut.length})]}),(0,g.jsx)(`p`,{children:`组里有位置、本机没有登记。接到本机仓库、克隆下来,或者直接移除。`})]}),(0,g.jsx)(m,{small:!0,onClick:Jt,children:`清理无来源占位`})]}),(0,g.jsx)(`div`,{className:`rp-pending-list`,children:Ut.map(e=>(0,g.jsxs)(`article`,{className:`rp-pending-card`,children:[(0,g.jsxs)(`div`,{className:`rp-pending-info`,children:[(0,g.jsxs)(`div`,{className:`rp-pending-title`,children:[(0,g.jsx)(`strong`,{children:e.name||e.key}),(0,g.jsxs)(`span`,{className:`rp-pending-board`,children:[`组 · `,e.board]}),e.remote?null:(0,g.jsx)(`span`,{className:`rp-pending-tag`,children:`无远程地址`})]}),(0,g.jsx)(`code`,{className:`rp-pending-key`,children:e.key}),e.desc?(0,g.jsx)(`p`,{className:`rp-pending-desc`,children:e.desc}):null]}),(0,g.jsxs)(`div`,{className:`rp-pending-acts`,children:[e.match?(0,g.jsxs)(m,{small:!0,title:`把组里这个位置指向本机仓库「${e.match.name}」(仓库身份不变)`,onClick:()=>Gt(e,e.match.id),children:[`绑定到「`,e.match.name,`」`]}):null,e.remote?(0,g.jsx)(m,{small:!0,onClick:()=>Wt(e),children:`克隆到本地`}):null,(0,g.jsx)(m,{small:!0,onClick:()=>Kt(e),children:`选本机仓库`}),(0,g.jsx)(m,{small:!0,danger:!0,title:`只从组里摘掉这个位置,本机仓库与看板都不动`,onClick:()=>qt(e),children:`移除`})]})]},e.key+`@`+e.boardId))})]}),(0,g.jsxs)(`div`,{className:`rp-filters`,"data-testid":`rp-filters`,children:[(0,g.jsxs)(`div`,{className:`rp-filters-main`,children:[(0,g.jsxs)(`button`,{className:`rp-chip`+(P?``:` on`),onClick:()=>F(``),title:`显示全部开发仓库`,children:[`全部 `,(0,g.jsx)(`b`,{children:X.length})]}),Y.map(e=>(0,g.jsxs)(`button`,{className:`rp-chip`+(P===e.id?` on`:``),onClick:()=>F(P===e.id?``:e.id),title:`只看「${e.name}」里的仓库(${e.repos.length} 个)`,children:[e.name,` `,(0,g.jsx)(`b`,{children:e.repos.length})]},e.id))]}),(0,g.jsxs)(`div`,{className:`rp-filters-side`,children:[(0,g.jsx)(`input`,{className:`rp-search`,type:`search`,value:oe,onChange:e=>se(e.target.value),placeholder:`搜仓库 / 路径 / 分组 / 文档…`,"aria-label":`检索仓库与文档`}),oe?(0,g.jsx)(m,{small:!0,onClick:()=>se(``),children:`清空`}):null,(0,g.jsxs)(`span`,{className:`muted rp-search-count`,children:[bt.length,` / `,X.length]}),(0,g.jsx)(m,{small:!0,title:`按仓库 / 组内 / 分组三档检索文档`,onClick:()=>de(!0),children:`文档检索`})]})]}),Q?(0,g.jsxs)(`div`,{className:`rp-context`,"data-testid":`rp-context`,children:[(0,g.jsx)(`span`,{className:`rp-context-name`,children:Q.name}),Q.desc?(0,g.jsx)(`span`,{className:`rp-context-desc`,title:Q.desc,children:Q.desc}):(0,g.jsx)(`span`,{className:`muted rp-context-desc`,children:`还没有领域描述 —— 点「组介绍文档」补一段:侧重什么、谁配合谁、关键路径与搜索关键词在哪。`}),(0,g.jsxs)(`span`,{className:`acts`,children:[(0,g.jsx)(m,{small:!0,title:`打开这个分组的组介绍文档`,onClick:()=>Xt(Q),children:`组介绍文档 ✎`}),(0,g.jsx)(`a`,{className:`btn small ghost`,href:`#/group/`+encodeURIComponent(Q.id),title:`组页里看这个组的成员与任务`,children:`组页 ↗`}),(0,g.jsx)(m,{small:!0,onClick:()=>j(Q.id),children:`添加成员`})]})]}):null,Q?(0,g.jsxs)(`div`,{className:`rp-ref-mounted`,"data-testid":`rp-board-refs`,children:[(0,g.jsxs)(`div`,{className:`rp-ref-mounted-head`,children:[(0,g.jsxs)(`span`,{className:`rp-ref-mounted-label`,children:[`「`,Q.name,`」的参考仓库 `,(0,g.jsx)(`b`,{children:wt.length})]}),(0,g.jsx)(`span`,{className:`muted`,children:`组级参考 + 成员仓库各自的参考(多对多:一个参考可同时服务多个组/仓库)`})]}),wt.length?wt.map(e=>{let t=St.get(e.id),n=(e.linked||[]).find(e=>e.kind===`board`&&e.id===(Q.key||`board/${Q.name}`));return(0,g.jsxs)(`div`,{className:`rp-ref-mounted-item`,children:[(0,g.jsx)(`span`,{className:`rp-ref-dot`+(t?t.ok?` ok`:` bad`:``),title:t?t.ok?`检查通过`:t.issues.join(`
5
+ `):`尚未检查`}),(0,g.jsx)(c,{text:e.remote||e.name,title:`点击复制远程地址`,className:`rp-ref-mounted-name`,children:e.name}),e.desc?(0,g.jsx)(`span`,{className:`muted rp-ref-mounted-desc`,title:e.desc,children:e.desc}):null,e.boardNote?(0,g.jsx)(`button`,{className:`rp-ref-note-chip`,title:`${e.boardNote}\n点击编辑这条命名空间描述`,onClick:()=>pt(e,`board`,Q.id,Q.name),children:e.boardNote.split(`
6
+ `)[0]}):(0,g.jsx)(m,{small:!0,title:`写「${e.name}」在这个组里参考什么(命名空间描述)`,onClick:()=>pt(e,`board`,Q.id,Q.name),children:`写描述`}),e.viaRepos.length?(0,g.jsxs)(`span`,{className:`muted`,title:`经由成员仓库: `+e.viaRepos.join(`、`),children:[`经由 `,e.viaRepos.join(`、`)]}):null,(0,g.jsxs)(`span`,{className:`acts`,children:[(0,g.jsx)(m,{small:!0,onClick:()=>ct(e),children:`同步`}),(0,g.jsx)(m,{small:!0,onClick:()=>$(`open`,e),children:`打开`}),n?(0,g.jsx)(m,{small:!0,danger:!0,title:`只从本组摘除(不影响其它绑定)`,onClick:()=>ht(e,`board`,Q.id),children:`移出本组`}):null]})]},e.id)}):(0,g.jsx)(`div`,{className:`muted rp-refs-none`,children:`这个组还没有绑定的参考仓库 —— 在下方参考仓库面板里点「绑定」勾选本组,或在成员仓库行上绑定。`})]}):null,Se?(0,g.jsxs)(a,{size:`wide`,title:`参考仓库 · ${Z.length}`,onClose:()=>Ce(!1),children:[(0,g.jsx)(`div`,{className:`rp-modal-bar`,children:(0,g.jsxs)(`span`,{className:`acts`,children:[(0,g.jsx)(m,{small:!0,onClick:()=>{Pe({}),je(!0)},children:`克隆参考仓库`}),(0,g.jsx)(m,{small:!0,onClick:lt,children:`同步全部`}),(0,g.jsx)(m,{small:!0,onClick:J,children:`检查`}),(0,g.jsx)(m,{small:!0,onClick:()=>{ke({gitRepoRoot:we?.gitRepoRoot||``,gitDevRoot:we?.gitDevRoot||``}),De(!0)},children:`存储根`})]})}),we?.gitRepoRoot?null:(0,g.jsx)(`div`,{className:`rp-ref-warn`,children:`存储根未设置 —— 克隆会被拒绝。点「存储根」设一个非 C 盘目录(参考仓库体积不小,别放系统盘)。`}),(0,g.jsx)(`div`,{className:`rp-ref-table-wrap`,children:(0,g.jsxs)(`table`,{className:`rp-ref-table`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsxs)(`tr`,{children:[(0,g.jsx)(`th`,{scope:`col`,style:{width:`30px`}}),(0,g.jsx)(`th`,{scope:`col`,style:{width:`17%`},children:`参考仓库`}),(0,g.jsx)(`th`,{scope:`col`,style:{width:`22%`},children:`远程地址`}),(0,g.jsx)(`th`,{scope:`col`,children:`绑定(组 / 仓库 · 点击写描述 · × 摘除)`}),(0,g.jsx)(`th`,{scope:`col`,style:{width:`220px`},children:`操作`})]})}),(0,g.jsxs)(`tbody`,{children:[Z.map(e=>{let t=St.get(e.id),n=e.linked||[];return(0,g.jsxs)(`tr`,{children:[(0,g.jsx)(`td`,{children:(0,g.jsx)(`span`,{className:`rp-ref-dot`+(t?t.ok?` ok`:` bad`:``),title:t?t.ok?`检查通过`:t.issues.join(`
7
+ `):`尚未检查`})}),(0,g.jsxs)(`td`,{className:`rp-ref-cell-name`,children:[(0,g.jsx)(`strong`,{children:e.name}),(0,g.jsx)(re,{docs:e.descDocs,onOpen:()=>en.docs(e)})]}),(0,g.jsx)(`td`,{className:`mono rp-ref-cell-remote`,children:(0,g.jsx)(c,{text:e.remote||``,title:`点击复制远程地址`,children:e.remote||`(无)`})}),(0,g.jsxs)(`td`,{className:`rp-ref-cell-links`,children:[n.length?n.map(t=>{let n=t.kind===`board`?Y.find(e=>(e.key||`board/${e.name}`)===t.id)?.name||t.id:X.find(e=>e.key===t.id)?.name||t.id;return(0,g.jsxs)(`span`,{className:`rp-link-chip`,children:[(0,g.jsxs)(`button`,{className:`rp-link-chip-main`,title:t.note?`${t.note}\n点击编辑这条绑定描述`:`点击写「${e.name}」绑定到这里的描述`,onClick:()=>pt(e,t.kind,t.id,n),children:[(0,g.jsx)(`b`,{children:t.kind===`board`?`组`:`仓`}),` `,n,t.note?(0,g.jsx)(`i`,{className:`rp-link-chip-note`,title:t.note,children:t.note.split(`
8
+ `)[0]}):null]}),(0,g.jsx)(`button`,{className:`rp-link-chip-x`,title:`摘除这条绑定(不影响其它)`,onClick:()=>ht(e,t.kind,t.id),children:`×`})]},t.kind+`:`+t.id)}):(0,g.jsx)(`span`,{className:`muted rp-refs-none`,children:`未绑定`}),(0,g.jsx)(m,{small:!0,className:`rp-ref-bind`,onClick:()=>ut(e),children:`绑定…`})]}),(0,g.jsxs)(`td`,{className:`rp-acts`,children:[(0,g.jsx)(m,{small:!0,onClick:()=>ct(e),children:`同步`}),(0,g.jsx)(m,{small:!0,onClick:()=>$(`open`,e),children:`打开`}),(0,g.jsx)(m,{small:!0,onClick:()=>$(`edit`,e),children:`编辑`}),(0,g.jsx)(m,{small:!0,danger:!0,onClick:()=>$(`del`,e),children:`删除`})]})]},e.id)}),Z.length?null:(0,g.jsx)(`tr`,{children:(0,g.jsx)(`td`,{colSpan:`5`,className:`muted rp-empty`,children:`还没有参考仓库 —— 点「克隆参考仓库」抓一个远程仓库下来(或用 CLI: nx-kv repo ref clone <url>)。`})})]})]})})]}):null,(0,g.jsx)(`div`,{className:`rp-table-wrap`,id:`rp-repos`,children:(0,g.jsxs)(`table`,{className:`rp-table`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsxs)(`tr`,{children:[(0,g.jsx)(`th`,{scope:`col`,style:{width:`17%`},children:`仓库`}),(0,g.jsxs)(`th`,{scope:`col`,style:{width:`24%`},children:[`文档`,(0,g.jsx)(`span`,{className:`rp-th-hint`,children:`主篇摘要 · 查看详情打开完整文档列表`})]}),(0,g.jsx)(`th`,{scope:`col`,style:{width:`15%`},children:`参考仓库`}),(0,g.jsx)(`th`,{scope:`col`,style:{width:`12%`},children:`分组`}),(0,g.jsx)(`th`,{scope:`col`,style:{width:`250px`},children:`操作`})]})}),(0,g.jsxs)(`tbody`,{children:[bt.map(e=>(0,g.jsx)(ie,{r:e,filterBoard:Q,refsOfRepo:Ct,acts:en},e.id)),bt.length?null:(0,g.jsx)(`tr`,{children:(0,g.jsx)(`td`,{colSpan:`5`,className:`muted rp-empty`,children:X.length?(0,g.jsxs)(g.Fragment,{children:[`这个分组还没有成员`,` `,Q?(0,g.jsx)(m,{small:!0,onClick:()=>j(Q.id),children:`添加成员`}):null]}):`还没有登记开发仓库 —— 点右上「登记仓库」加一条。`})})]})]})}),ue?(0,g.jsxs)(a,{size:`wide`,title:`文档检索 · ${B.length}`,onClose:()=>de(!1),children:[(0,g.jsxs)(`div`,{className:`rp-modal-bar rp-doc-bar`,children:[(0,g.jsx)(`input`,{className:`rp-search`,type:`search`,value:kt,onChange:e=>At(e.target.value),placeholder:`搜标题 / 路径 / 组名 / 仓库名…`,"aria-label":`检索文档`}),kt?(0,g.jsx)(m,{small:!0,onClick:()=>At(``),children:`清空`}):null,(0,g.jsx)(`span`,{className:`acts`,children:(0,g.jsx)(m,{small:!0,onClick:Qt,children:`新建文档`})})]}),B.length?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`div`,{className:`rp-doc-scopes`,children:[[`all`,`全部`,Mt.all],[`repo`,`仓库文档`,Mt.repo],[`scoped`,`组内文档`,Mt.scoped],[`board`,`分组文档`,Mt.board],[`orphan`,`未绑定`,Mt.orphan]].map(([e,t,n])=>(0,g.jsxs)(`button`,{className:`rp-chip`+(Dt===e?` on`:``),onClick:()=>Ot(e),children:[t,` `,(0,g.jsx)(`b`,{children:n})]},e))}),(0,g.jsxs)(`div`,{className:`rp-doc-rows rp-doc-rows-modal`,children:[jt.map(({d:e,hosts:t})=>(0,g.jsxs)(`div`,{className:`rp-doc-row`,children:[(0,g.jsx)(`button`,{type:`button`,className:`rp-doc-row-title`,title:`打开「${e.title||e.rel}」`,onClick:()=>y(e.docId),children:e.title||e.name||e.rel}),(0,g.jsx)(`code`,{className:`rp-doc-row-rel`,title:e.rel,children:e.rel}),(0,g.jsx)(`span`,{className:`rp-doc-row-hosts`,children:t.length?t.map(e=>(0,g.jsx)(`button`,{type:`button`,className:`rp-bind-chip `+e.kind,title:`${e.tip}\n点击跳到这个宿主`,onClick:()=>{Ft(e),de(!1)},children:e.label},e.key)):(0,g.jsx)(`span`,{className:`rp-bind-chip none`,children:`未绑定`})}),(0,g.jsxs)(`span`,{className:`rp-doc-row-acts`,children:[(0,g.jsx)(m,{small:!0,onClick:()=>y(e.docId),children:`打开编辑`}),(0,g.jsx)(m,{small:!0,danger:!0,onClick:()=>$t(e),children:`删除`})]})]},e.docId)),jt.length?null:(0,g.jsx)(`div`,{className:`rp-board-empty muted`,children:`这一档没有匹配的文档。`})]})]}):(0,g.jsx)(`div`,{className:`rp-board-empty muted`,children:`还没有文档 —— 点「新建文档」给一个相对路径(如 note/inbox.md)就开写; 或在仓库行上点「+ 写项目介绍」。`})]}):null,ce?(0,g.jsxs)(a,{size:`wide`,title:`分组管理 · ${Y.length}`,onClose:()=>le(!1),children:[(0,g.jsxs)(`div`,{className:`rp-modal-bar`,children:[(0,g.jsxs)(`span`,{className:`acts`,children:[(0,g.jsx)(m,{small:!0,onClick:()=>L({id:null,name:``,desc:``}),children:`新建分组`}),(0,g.jsx)(m,{small:!0,title:`粘贴/选择看板 JSON`,onClick:()=>pe(!0),children:`导入`}),(0,g.jsx)(m,{small:!0,title:`导出全部看板为 JSON`,onClick:Vt,children:`导出`})]}),(0,g.jsx)(`span`,{className:`muted`,children:`一个分组 = 一个主题;同一个仓库可以同时在多个分组里。`})]}),Y.length?(0,g.jsxs)(`div`,{className:`rp-board-admin`,children:[(0,g.jsxs)(`div`,{className:`rp-board-admin-head`,children:[(0,g.jsx)(`span`,{children:`分组`}),(0,g.jsx)(`span`,{children:`成员`}),(0,g.jsx)(`span`,{children:`组介绍`}),(0,g.jsx)(`span`,{children:`操作`})]}),Y.map(e=>{let t=(e.repos||[]).filter(e=>e.present!==!1),n=(e.repos||[]).filter(e=>e.present===!1);return(0,g.jsxs)(`div`,{className:`rp-board-admin-row`,children:[(0,g.jsxs)(`span`,{className:`rp-board-admin-name`,children:[e.name,(0,g.jsx)(`button`,{className:`rp-mini-link`,title:`只看「${e.name}」里的仓库`,onClick:()=>{F(e.id),le(!1)},children:`筛选`})]}),(0,g.jsxs)(`span`,{className:`rp-board-admin-members`,children:[t.slice(0,4).map(e=>(0,g.jsx)(`span`,{className:`rp-board-mchip`,title:e.note||e.key,children:e.name||e.key},e.key)),t.length>4?(0,g.jsxs)(`span`,{className:`rp-board-more`,children:[`+`,t.length-4]}):null,n.length?(0,g.jsxs)(`span`,{className:`rp-board-missing`,children:[n.length,` 待初始化`]}):null,e.repos.length?null:(0,g.jsx)(`span`,{className:`muted`,children:`—`})]}),(0,g.jsxs)(`span`,{className:`rp-board-admin-doc`,children:[(0,g.jsx)(m,{small:!0,title:`打开组介绍文档`,onClick:()=>Xt(e),children:`组介绍 ✎`}),e.docLinks&&e.docLinks.length?(0,g.jsxs)(`span`,{className:`muted`,children:[`+`,e.docLinks.length]}):null]}),(0,g.jsxs)(`span`,{className:`rp-board-admin-acts`,children:[(0,g.jsx)(`a`,{className:`btn small ghost`,href:`#/group/`+encodeURIComponent(e.id),title:`组页:成员与任务`,children:`组页 ↗`}),(0,g.jsx)(m,{small:!0,onClick:()=>j(e.id),children:`成员`}),(0,g.jsx)(m,{small:!0,onClick:()=>L({id:e.id,name:e.name,desc:e.desc||``}),children:`编辑`}),(0,g.jsx)(m,{small:!0,danger:!0,onClick:()=>zt(e),children:`删除`})]})]},e.id)}),M.unassigned?.length?(0,g.jsxs)(`div`,{className:`rp-boards-unassigned`,children:[`未分组 `,(0,g.jsx)(`b`,{children:M.unassigned.length}),` 个 —— 不属于任何分组,只在「全部」里可见。`]}):null]}):(0,g.jsx)(`div`,{className:`rp-board-empty muted`,children:`还没有分组 —— 点「新建分组」建一个当主题用(如「前端」「AI 工具」),再把仓库点选进去。`})]}):null,ne?(0,g.jsx)(a,{title:S?`编辑仓库 · ${S}`:`添加仓库`,onClose:rt,children:(0,g.jsxs)(`div`,{className:`form-grid`,children:[(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsx)(`label`,{htmlFor:`repo-path`,children:`仓库绝对路径 *`}),(0,g.jsx)(`input`,{id:`repo-path`,placeholder:`D:/code/my-project`,spellCheck:`false`,value:b.path,onChange:ye(`path`)})]}),(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsx)(`label`,{htmlFor:`repo-name`,children:`名称`}),(0,g.jsx)(`input`,{id:`repo-name`,placeholder:`留空则用目录末段`,value:b.name,onChange:ye(`name`)})]}),(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsx)(`label`,{htmlFor:`repo-icon`,children:`图标`}),(0,g.jsx)(`input`,{id:`repo-icon`,maxLength:8,placeholder:`emoji 或单字符(留空 = 默认文件夹图标)`,value:b.icon,onChange:ye(`icon`)})]}),It?(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsx)(`label`,{children:`项目描述(文档)`}),(0,g.jsxs)(`div`,{className:`rp-docpick`,children:[(0,g.jsxs)(`button`,{type:`button`,className:`rp-doc`,onClick:()=>{ae(!1),y(It.main.docId)},children:[It.main.title,It.main.exists?null:(0,g.jsx)(`span`,{className:`rp-doc-todo`,children:`未写`})]}),It.links.length?(0,g.jsxs)(`span`,{className:`muted`,children:[`另有 `,It.links.length,` 篇补充文档`]}):null]})]}):null,(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsx)(`label`,{htmlFor:`repo-type`,children:`类型`}),(0,g.jsxs)(`select`,{id:`repo-type`,value:b.type,onChange:ye(`type`),children:[(0,g.jsx)(`option`,{value:`dev`,children:`开发仓库(本机开发的)`}),(0,g.jsx)(`option`,{value:`ref`,children:`参考仓库(远程 clone 下来的)`})]})]}),(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsx)(`label`,{htmlFor:`repo-remote`,children:`远程 git 地址`}),(0,g.jsx)(`input`,{id:`repo-remote`,spellCheck:`false`,placeholder:`https://github.com/me/x.git(导出时导它,不含本地路径)`,value:b.remote,onChange:be}),(0,g.jsx)(`div`,{className:`form-hint`,children:`有远程地址时,下面的 key 会按它自动归一化:ssh / https / 带 .git / 带 user 的写法 都归一成 host/owner/repo(如 github.com/on-devplan/nx-kv)。`})]}),(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsx)(`label`,{htmlFor:`repo-key`,children:`仓库 key *(全局唯一身份)`}),(0,g.jsx)(`input`,{id:`repo-key`,spellCheck:`false`,placeholder:`github.com/on-devplan/nx-kv`,value:b.key,onChange:xe}),(0,g.jsx)(`div`,{className:`form-hint`,children:`没有远程地址时必须手工填写;已有仓库可查看,改 key 会波及引用它的队列 / 看板 / 关系。`})]}),(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsx)(`label`,{htmlFor:`repo-notes`,children:`备注`}),(0,g.jsx)(`textarea`,{id:`repo-notes`,placeholder:`补充信息(可选)`,value:b.notes,onChange:ye(`notes`)})]}),(0,g.jsxs)(`div`,{className:`form-acts`,children:[(0,g.jsx)(m,{onClick:rt,children:`取消`}),(0,g.jsx)(m,{disabled:!b.path.trim()||!b.key.trim()&&!b.remote.trim(),onClick:Lt,children:S?`保存修改`:`添加仓库`})]})]})}):null,I?(0,g.jsx)(a,{title:I.id?`编辑看板`:`新建看板`,onClose:()=>L(null),children:(0,g.jsxs)(`div`,{className:`form-grid`,children:[(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsx)(`label`,{htmlFor:`bd-name`,children:`看板名称 *`}),(0,g.jsx)(`input`,{id:`bd-name`,placeholder:`如 前端 / AI 工具`,value:I.name,onChange:e=>L(t=>({...t,name:e.target.value}))})]}),I.id?(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsx)(`label`,{children:`领域描述(文档)`}),(0,g.jsx)(`div`,{className:`rp-docpick`,children:(0,g.jsx)(`button`,{type:`button`,className:`rp-doc`+(I.desc?``:` ghost`),title:`打开组介绍文档`,onClick:()=>{let e=Y.find(e=>e.id===I.id);L(null),e&&(e.docRel||e.doc&&e.doc.rel)&&y(`rel:`+(e.docRel||e.doc.rel))},children:I.desc||`未写`})})]}):(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsx)(`label`,{htmlFor:`bd-desc`,children:`初始描述`}),(0,g.jsx)(`textarea`,{id:`bd-desc`,rows:3,spellCheck:`false`,placeholder:`新建时给的介绍正文(之后以 board/<组>.md 文档为准)。
9
+ 如:这组仓库在这个环境里的侧重、配合关系、关键路径与搜索关键词。`,value:I.desc,onChange:e=>L(t=>({...t,desc:e.target.value}))})]}),(0,g.jsxs)(`div`,{className:`form-acts`,children:[(0,g.jsx)(m,{onClick:()=>L(null),children:`取消`}),(0,g.jsx)(m,{disabled:!I.name.trim(),onClick:Rt,children:I.id?`保存`:`新建看板`})]})]})}):null,fe?(0,g.jsx)(a,{title:`导入看板 JSON`,size:`lg`,onClose:()=>{pe(!1),R(``)},children:(0,g.jsxs)(`div`,{className:`form-grid`,children:[(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsx)(`label`,{htmlFor:`bd-imp`,children:`看板 JSON`}),(0,g.jsxs)(`div`,{className:`form-hint`,children:[`结构 `,`{ boards:[{ name, repos:[{ path|name }] }] }`,` —— 按 path 或 name 匹配已登记仓库,匹配不上的会如实报告`]}),(0,g.jsx)(`input`,{id:`bd-imp-file`,type:`file`,accept:`.json,application/json`,onChange:Ht}),(0,g.jsx)(`textarea`,{id:`bd-imp`,rows:10,spellCheck:`false`,placeholder:`{"boards":[{"name":"前端","repos":[{"path":"D:/code/a_js/proj/nx-ft"}]}]}`,value:me,onChange:e=>R(e.target.value)})]}),(0,g.jsxs)(`div`,{className:`form-acts`,children:[(0,g.jsx)(m,{onClick:()=>{pe(!1),R(``)},children:`取消`}),(0,g.jsx)(m,{disabled:!me.trim(),onClick:Bt,children:`导入`})]})]})}):null,he?(0,g.jsx)(a,{title:`看板 JSON(可回灌给导入)`,size:`lg`,onClose:()=>ge(null),children:(0,g.jsx)(`textarea`,{className:`bd-exp`,rows:14,readOnly:!0,value:he,spellCheck:`false`})}):null,xt?(0,g.jsx)(p,{board:xt,boards:Y,repos:z,onClose:()=>j(null),onChanged:async()=>{await Promise.all([K(),q()])}}):null,Ae?(0,g.jsx)(a,{title:`克隆参考仓库`,onClose:()=>{je(!1),Pe({})},children:(0,g.jsxs)(`div`,{className:`form-grid`,children:[(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsx)(`label`,{htmlFor:`ref-url`,children:`远程 git 地址 *`}),(0,g.jsx)(`input`,{id:`ref-url`,spellCheck:`false`,placeholder:`git@github.com:lib/x.git 或 https://github.com/lib/x`,value:V.url,onChange:e=>Me(t=>({...t,url:e.target.value}))})]}),(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsx)(`label`,{htmlFor:`ref-name`,children:`名称`}),(0,g.jsx)(`input`,{id:`ref-name`,placeholder:`留空则用 URL 末段`,value:V.name,onChange:e=>Me(t=>({...t,name:e.target.value}))})]}),(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsx)(`label`,{htmlFor:`ref-desc`,children:`它参考什么`}),(0,g.jsx)(`input`,{id:`ref-desc`,spellCheck:`false`,placeholder:`如:liquid glass 的官方实现参考`,value:V.desc,onChange:e=>Me(t=>({...t,desc:e.target.value}))})]}),(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsx)(`label`,{children:`克隆后绑定到(可多选)`}),(0,g.jsxs)(`div`,{className:`rp-pick-list`,children:[(0,g.jsxs)(`div`,{className:`rp-pick-group`,children:[(0,g.jsx)(`span`,{className:`rp-pick-group-label`,children:`开发仓库`}),X.map(e=>(0,g.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,g.jsx)(`input`,{type:`checkbox`,checked:!!Ne[`repo:`+e.id],onChange:t=>Pe(n=>({...n,[`repo:`+e.id]:t.target.checked}))}),(0,g.jsx)(`span`,{title:e.path,children:e.name})]},e.id)),X.length?null:(0,g.jsx)(`span`,{className:`muted`,children:`(还没有开发仓库)`})]}),(0,g.jsxs)(`div`,{className:`rp-pick-group`,children:[(0,g.jsx)(`span`,{className:`rp-pick-group-label`,children:`看板(项目组)`}),Y.map(e=>(0,g.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,g.jsx)(`input`,{type:`checkbox`,checked:!!Ne[`board:`+e.id],onChange:t=>Pe(n=>({...n,[`board:`+e.id]:t.target.checked}))}),(0,g.jsx)(`span`,{title:e.desc||``,children:e.name})]},e.id)),Y.length?null:(0,g.jsx)(`span`,{className:`muted`,children:`(还没有看板)`})]})]}),(0,g.jsx)(`div`,{className:`form-hint`,children:`一个参考可同时服务多个仓库/组;之后随时在「绑定…」里增删。`})]}),(0,g.jsxs)(`div`,{className:`form-acts`,children:[(0,g.jsx)(m,{onClick:()=>{je(!1),Pe({})},children:`取消`}),(0,g.jsx)(m,{disabled:!V.url.trim()||!we?.gitRepoRoot,title:we?.gitRepoRoot?`克隆到 ${we.gitRepoRoot}`:`先在「存储根」设置 gitRepoRoot`,onClick:st,children:`克隆`})]})]})}):null,Le?(0,g.jsx)(a,{title:`绑定 · ${Le.name}`,onClose:()=>Re(null),children:(0,g.jsxs)(`div`,{className:`form-grid`,children:[(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsx)(`div`,{className:`form-hint`,children:`勾选 = 绑定,取消 = 摘除(保存时对比差异)。一个参考可同时绑多个仓库/组。`}),(0,g.jsxs)(`div`,{className:`rp-pick-list`,children:[(0,g.jsxs)(`div`,{className:`rp-pick-group`,children:[(0,g.jsx)(`span`,{className:`rp-pick-group-label`,children:`开发仓库`}),X.map(e=>(0,g.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,g.jsx)(`input`,{type:`checkbox`,checked:!!ze[`repo:`+e.id],onChange:t=>Be(n=>({...n,[`repo:`+e.id]:t.target.checked}))}),(0,g.jsx)(`span`,{title:e.path,children:e.name})]},e.id)),X.length?null:(0,g.jsx)(`span`,{className:`muted`,children:`(还没有开发仓库)`})]}),(0,g.jsxs)(`div`,{className:`rp-pick-group`,children:[(0,g.jsx)(`span`,{className:`rp-pick-group-label`,children:`看板(项目组)`}),Y.map(e=>(0,g.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,g.jsx)(`input`,{type:`checkbox`,checked:!!ze[`board:`+e.id],onChange:t=>Be(n=>({...n,[`board:`+e.id]:t.target.checked}))}),(0,g.jsx)(`span`,{title:e.desc||``,children:e.name})]},e.id)),Y.length?null:(0,g.jsx)(`span`,{className:`muted`,children:`(还没有看板)`})]})]})]}),(0,g.jsxs)(`div`,{className:`form-acts`,children:[(0,g.jsx)(m,{onClick:()=>Re(null),children:`取消`}),(0,g.jsx)(m,{onClick:dt,children:`保存绑定`})]})]})}):null,H?(0,g.jsx)(a,{title:`「${H.name}」的参考仓库`,onClose:()=>Ve(null),children:(0,g.jsxs)(`div`,{className:`form-grid`,children:[(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsxs)(`div`,{className:`form-hint`,children:[`勾选 = 绑到「`,H.name,`」,取消 = 摘除。组级参考(绑在看板上)自动对该组所有成员生效,不在这里重复勾。`]}),(0,g.jsx)(`div`,{className:`rp-pick-list`,children:(0,g.jsxs)(`div`,{className:`rp-pick-group`,children:[(0,g.jsx)(`span`,{className:`rp-pick-group-label`,children:`参考仓库`}),Z.map(e=>(0,g.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,g.jsx)(`input`,{type:`checkbox`,checked:!!He[e.key],onChange:t=>Ue(n=>({...n,[e.key]:t.target.checked}))}),(0,g.jsx)(`span`,{title:e.remote||``,children:e.name}),e.desc?(0,g.jsx)(`span`,{className:`muted rp-pick-desc`,children:e.desc}):null]},e.key)),Z.length?null:(0,g.jsx)(`span`,{className:`muted`,children:`(还没有参考仓库 —— 先在参考面板里克隆)`})]})})]}),(0,g.jsxs)(`div`,{className:`form-acts`,children:[(0,g.jsx)(m,{onClick:()=>Ve(null),children:`取消`}),(0,g.jsx)(m,{onClick:ft,children:`保存绑定`})]})]})}):null,U?(0,g.jsx)(a,{title:`绑定描述 · ${U.ref.name} @ ${U.kind===`board`?`「`+U.targetName+`」`:U.targetName}`,onClose:()=>We(null),children:(0,g.jsxs)(`div`,{className:`form-grid`,children:[(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsxs)(`label`,{htmlFor:`link-note`,children:[`「`,U.ref.name,`」`,U.kind===`board`?`在这个组里`:`在这个仓库里`,`参考什么`]}),(0,g.jsx)(`div`,{className:`form-hint`,children:`写这条参考在此处的角色与用法(可多行、可含关键路径/搜索词)。留空保存 = 清除。`}),(0,g.jsx)(`textarea`,{id:`link-note`,rows:5,spellCheck:`false`,placeholder:`如:project-graph 画布交互的实现参考;
10
+ 看 src/extensions/ 的注册方式,搜 registerExtension。`,value:Ge,onChange:e=>Ke(e.target.value)})]}),(0,g.jsxs)(`div`,{className:`form-acts`,children:[(0,g.jsx)(m,{onClick:()=>We(null),children:`取消`}),(0,g.jsx)(m,{onClick:mt,children:`保存`})]})]})}):null,Ee?(0,g.jsx)(a,{title:`参考仓库存储根`,onClose:()=>De(!1),children:(0,g.jsxs)(`div`,{className:`form-grid`,children:[(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsx)(`label`,{htmlFor:`roots-ref`,children:`参考仓库存储根(gitRepoRoot)`}),(0,g.jsx)(`input`,{id:`roots-ref`,spellCheck:`false`,placeholder:`如 D:/gitrepo-ref(非 C 盘)`,value:Oe.gitRepoRoot,onChange:e=>ke(t=>({...t,gitRepoRoot:e.target.value}))}),(0,g.jsx)(`div`,{className:`form-hint`,children:`repo ref clone 的落盘位置。不设 = 克隆被拒绝。`})]}),(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsx)(`label`,{htmlFor:`roots-dev`,children:`开发仓库克隆根(gitDevRoot,可选)`}),(0,g.jsx)(`input`,{id:`roots-dev`,spellCheck:`false`,placeholder:`导入布局时开发仓库克隆到哪里`,value:Oe.gitDevRoot,onChange:e=>ke(t=>({...t,gitDevRoot:e.target.value}))})]}),(0,g.jsxs)(`div`,{className:`form-acts`,children:[(0,g.jsx)(m,{onClick:()=>De(!1),children:`取消`}),(0,g.jsx)(m,{onClick:ot,children:`保存`})]})]})}):null,qe?(0,g.jsx)(te,{onClose:()=>Je(!1),onChanged:gt,repos:z,boards:Y}):null,tt?(0,g.jsx)(w,{repo:z.find(e=>e.id===tt.id)||tt,onClose:()=>nt(null),onSaved:K}):null,Ze&&W?(0,g.jsx)(a,{title:`对齐 remote · ${W.name}`,onClose:()=>Qe(!1),children:(0,g.jsxs)(`div`,{className:`form-grid`,"data-testid":`rp-remote-modal`,children:[(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsxs)(`div`,{className:`form-hint`,children:[`当前采纳:`,(0,g.jsx)(`b`,{children:W.current||`(无)`}),`。换一条即对齐(key 随之重算;自定义 key 不动)。`]}),(0,g.jsxs)(`div`,{className:`rp-remote-list`,children:[W.remotes.map(e=>(0,g.jsxs)(`div`,{className:`rp-remote-item`,children:[(0,g.jsx)(`span`,{className:`rp-remote-name`,children:e.name}),(0,g.jsx)(`span`,{className:`mono rp-remote-url`,children:e.url}),(0,g.jsx)(`span`,{className:`rp-remote-kind`,children:e.kind}),e.current?(0,g.jsx)(`span`,{className:`rp-remote-on`,children:`当前`}):null,(0,g.jsxs)(`span`,{className:`acts`,children:[e.current?null:(0,g.jsx)(m,{small:!0,onClick:()=>vt(e.url),children:`对齐这条`}),(0,g.jsx)(m,{small:!0,onClick:()=>yt(e.url),children:`检查`})]})]},e.name+`|`+e.url)),W.remotes.length?null:(0,g.jsx)(`div`,{className:`muted`,children:`这个仓库没有配置 remote —— 先在 git 里 git remote add`})]})]}),G?(0,g.jsxs)(`div`,{className:`form-field`,children:[(0,g.jsx)(`label`,{children:`存在性检查`}),(0,g.jsxs)(`div`,{className:`rp-remote-check`,children:[(0,g.jsx)(`span`,{className:`rp-status `+(G.status===`exists`?`same`:G.status===`missing`?`new`:G.status===`checking`?`checking`:`missing`),children:G.status===`exists`?`存在`:G.status===`missing`?`不存在`:G.status===`checking`?`检查中`:`不可达`}),(0,g.jsx)(`span`,{className:`mono rp-remote-url`,children:G.url}),(0,g.jsx)(`span`,{className:`muted`,children:G.detail})]})]}):null,(0,g.jsxs)(`div`,{className:`form-acts`,children:[(0,g.jsx)(m,{onClick:()=>Qe(!1),children:`关闭`}),(0,g.jsx)(m,{onClick:()=>yt(``),children:`检查当前 remote`})]})]})}):null,$e?(0,g.jsx)(d,{kind:$e.kind,owner:$e.owner,model:v.model,onClose:()=>et(null),onChanged:()=>{K(),it()}}):null,_]})}export{ae as default};
@@ -1 +1 @@
1
- import{S as e,v as t,y as n}from"./task-status-BP6y8MVu.js";import{n as r}from"./board-view-t8CKtq17.js";import{k as i,t as a}from"./index-CeIJd4ee.js";var o=e(n(),1);function s(e,t={}){if(!e||!e.view)return[];switch(e.view){case`dir`:{let n=[];return t.dirName&&n.push(t.dirName),e.task&&(/^draft/i.test(String(e.task))?n.push(`draft`):n.push(t.pageTitle||`#${e.task}`)),n}case`group`:if(e.task){let n=[t.boardName||`项目组`];return/^draft/i.test(String(e.task))?n.push(`draft`):n.push(t.pageTitle||`#${e.task}`),n}return t.boardName?[t.boardName]:[`项目组`];case`repos`:return[`仓库管理`];case`cloud`:return[`云端总览`];case`overview`:return[`全部目录总览`];case`templates`:return e.mode===`new`?[`新建模板`]:e.mode===`edit`?[`编辑模板`]:[`任务模板`];case`doc`:{let e=t.repoName||t.boardName||``;return e?[e]:[`文档`]}default:return[]}}function c(e){if(!e||!e.view)return``;switch(e.view){case`dir`:return e.task?`#/dir/${encodeURIComponent(e.key||``)}`:`#/overview`;case`group`:return e.task?`#/group/${encodeURIComponent(e.key||``)}`:`#/overview`;case`overview`:return``;case`doc`:return e.repoKey?`#/repos`:e.boardKey?`#/group/${encodeURIComponent(e.boardKey)}`:`#/repos`;default:return`#/overview`}}function l(e,t=[],n={}){if(!e)return{boardName:``,dirName:``,pageTitle:``};let i=(n.boards||[]).find(t=>t.id===e.key);if(e.view===`group`&&e.task){let a=r(t,n.boards||[],e.key,e.task);return{boardName:a.board&&a.board.name||i&&i.name||``,dirName:a.topic?a.topic.name:``,pageTitle:a.taskRow?`#${a.taskRow.id}`:``}}let a=(t||[]).find(t=>t.key===e.key),o=a&&e.task?(a.tasks||[]).find(t=>String(t.id)===String(e.task)):null;if(e.view===`doc`){let t=(n.repos||[]).find(t=>t.key===e.repoKey),r=(n.boards||[]).find(t=>t.id===e.boardKey||t.key===e.boardKey);return{boardName:e.boardName||r&&r.name||``,dirName:``,pageTitle:``,repoName:t&&t.name||``}}return{boardName:i&&i.name||``,dirName:a?a.name:``,pageTitle:o?`#${o.id}`:``}}var u=t();function d({route:e,ctx:t,onNavigate:n,onBack:r,inline:i=!1}){let a=(0,o.useMemo)(()=>s(e,t),[e,t]),l=(0,o.useMemo)(()=>c(e,t),[e,t]);if(!a.length)return null;let d=`nx-crumb`+(i?` nx-crumb-inline`:``),f=(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`span`,{className:`nx-crumb-br`,"aria-hidden":!0,children:`[`}),a.map((e,t)=>(0,u.jsxs)(`span`,{className:`nx-crumb-i`,children:[t>0?(0,u.jsx)(`span`,{className:`nx-crumb-sep`,children:`/`}):null,(0,u.jsx)(`span`,{className:`nx-crumb-t`,children:e})]},`${e}-${t}`)),(0,u.jsx)(`span`,{className:`nx-crumb-br`,"aria-hidden":!0,children:`]`})]});return l&&n?(0,u.jsx)(`nav`,{className:d,"aria-label":`当前位置`,children:(0,u.jsx)(`button`,{type:`button`,className:`nx-crumb-path`,title:`返回上一级`,"aria-label":`返回上一级(${a.join(` / `)})`,onClick:()=>r?r():n(l),children:f})}):(0,u.jsx)(`nav`,{className:d,"aria-label":`当前位置`,children:f})}function f(){let e=i()||{},t=e.route||{},n=e.rows||[],r=e.repoData||{},f=(0,o.useMemo)(()=>l(t,n,r),[t,n,r]);return(0,o.useMemo)(()=>s(t,f),[t,f]).length?(0,u.jsx)(d,{route:t,ctx:f,onNavigate:e.onNavigate,onBack:()=>{let n=a();if(n&&e.onNavigate){e.onNavigate(n);return}let r=c(t,f);r&&e.onNavigate&&e.onNavigate(r)},inline:!0}):null}export{f as t};
1
+ import{S as e,v as t,y as n}from"./task-status-BP6y8MVu.js";import{n as r}from"./board-view-t8CKtq17.js";import{k as i,t as a}from"./index-B_HPAoNR.js";var o=e(n(),1);function s(e,t={}){if(!e||!e.view)return[];switch(e.view){case`dir`:{let n=[];return t.dirName&&n.push(t.dirName),e.task&&(/^draft/i.test(String(e.task))?n.push(`draft`):n.push(t.pageTitle||`#${e.task}`)),n}case`group`:if(e.task){let n=[t.boardName||`项目组`];return/^draft/i.test(String(e.task))?n.push(`draft`):n.push(t.pageTitle||`#${e.task}`),n}return t.boardName?[t.boardName]:[`项目组`];case`repos`:return[`仓库管理`];case`cloud`:return[`云端总览`];case`overview`:return[`全部目录总览`];case`templates`:return e.mode===`new`?[`新建模板`]:e.mode===`edit`?[`编辑模板`]:[`任务模板`];case`doc`:{let e=t.repoName||t.boardName||``;return e?[e]:[`文档`]}default:return[]}}function c(e){if(!e||!e.view)return``;switch(e.view){case`dir`:return e.task?`#/dir/${encodeURIComponent(e.key||``)}`:`#/overview`;case`group`:return e.task?`#/group/${encodeURIComponent(e.key||``)}`:`#/overview`;case`overview`:return``;case`doc`:return e.repoKey?`#/repos`:e.boardKey?`#/group/${encodeURIComponent(e.boardKey)}`:`#/repos`;default:return`#/overview`}}function l(e,t=[],n={}){if(!e)return{boardName:``,dirName:``,pageTitle:``};let i=(n.boards||[]).find(t=>t.id===e.key);if(e.view===`group`&&e.task){let a=r(t,n.boards||[],e.key,e.task);return{boardName:a.board&&a.board.name||i&&i.name||``,dirName:a.topic?a.topic.name:``,pageTitle:a.taskRow?`#${a.taskRow.id}`:``}}let a=(t||[]).find(t=>t.key===e.key),o=a&&e.task?(a.tasks||[]).find(t=>String(t.id)===String(e.task)):null;if(e.view===`doc`){let t=(n.repos||[]).find(t=>t.key===e.repoKey),r=(n.boards||[]).find(t=>t.id===e.boardKey||t.key===e.boardKey);return{boardName:e.boardName||r&&r.name||``,dirName:``,pageTitle:``,repoName:t&&t.name||``}}return{boardName:i&&i.name||``,dirName:a?a.name:``,pageTitle:o?`#${o.id}`:``}}var u=t();function d({route:e,ctx:t,onNavigate:n,onBack:r,inline:i=!1}){let a=(0,o.useMemo)(()=>s(e,t),[e,t]),l=(0,o.useMemo)(()=>c(e,t),[e,t]);if(!a.length)return null;let d=`nx-crumb`+(i?` nx-crumb-inline`:``),f=(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`span`,{className:`nx-crumb-br`,"aria-hidden":!0,children:`[`}),a.map((e,t)=>(0,u.jsxs)(`span`,{className:`nx-crumb-i`,children:[t>0?(0,u.jsx)(`span`,{className:`nx-crumb-sep`,children:`/`}):null,(0,u.jsx)(`span`,{className:`nx-crumb-t`,children:e})]},`${e}-${t}`)),(0,u.jsx)(`span`,{className:`nx-crumb-br`,"aria-hidden":!0,children:`]`})]});return l&&n?(0,u.jsx)(`nav`,{className:d,"aria-label":`当前位置`,children:(0,u.jsx)(`button`,{type:`button`,className:`nx-crumb-path`,title:`返回上一级`,"aria-label":`返回上一级(${a.join(` / `)})`,onClick:()=>r?r():n(l),children:f})}):(0,u.jsx)(`nav`,{className:d,"aria-label":`当前位置`,children:f})}function f(){let e=i()||{},t=e.route||{},n=e.rows||[],r=e.repoData||{},f=(0,o.useMemo)(()=>l(t,n,r),[t,n,r]);return(0,o.useMemo)(()=>s(t,f),[t,f]).length?(0,u.jsx)(d,{route:t,ctx:f,onNavigate:e.onNavigate,onBack:()=>{let n=a();if(n&&e.onNavigate){e.onNavigate(n);return}let r=c(t,f);r&&e.onNavigate&&e.onNavigate(r)},inline:!0}):null}export{f as t};
@@ -0,0 +1 @@
1
+ .setp{height:100%;min-height:0;color:var(--ink);font-size:12.5px;display:flex}.setp-nav{background:var(--soft);border-right:1px solid var(--line);flex-direction:column;flex:none;gap:2px;width:172px;padding:10px 8px;display:flex;overflow:auto}.setp-navitem{cursor:pointer;text-align:left;width:100%;color:var(--ink-2);background:0 0;border:0;border-radius:6px;align-items:center;gap:8px;padding:7px 9px;font-family:inherit;font-size:12.5px;display:flex}.setp-navitem:hover{background:var(--soft-2);color:var(--ink)}.setp-navitem.on{background:var(--paper);color:var(--ink);font-weight:650;box-shadow:0 1px 2px #14161a12}.setp-navitem .ic{color:var(--mid)}.setp-navitem.on .ic{color:var(--ink)}.setp-body{flex-direction:column;flex:1;gap:10px;min-width:0;padding:12px 16px 18px;display:flex;overflow:auto}.setp-h{letter-spacing:1px;color:var(--mid);text-transform:uppercase;font:600 10.5px Bahnschrift,Segoe UI,sans-serif}.setp-row{justify-content:space-between;align-items:center;gap:10px;min-height:26px;display:flex}.setp-row>span:first-child{color:var(--ink-2)}.setp-row .toggle{flex:none}.setp-input{flex:1;align-items:center;gap:6px;min-width:0;display:flex}.setp-input input{border:1px solid var(--line);background:var(--paper);min-width:0;height:24px;color:var(--ink);border-radius:6px;flex:1;padding:0 8px;font:400 11.5px ui-monospace,Consolas,monospace}.setp-input input:focus{outline:2px solid var(--soft-2);outline-offset:-1px}.setp-note{color:var(--faint);font-size:11px;line-height:1.65}.setp-badge{color:var(--mid);background:var(--soft);border-radius:8px;align-items:center;padding:0 6px;font-size:10px;line-height:1.6;display:inline-flex}.setp-badge.soft{color:var(--faint,#8a8578);border:1px solid var(--line);background:0 0}.setp-proj-a{border-top:1px solid var(--line,#e4e2dc);flex-wrap:wrap;align-items:center;gap:8px;margin-top:14px;padding-top:12px;display:flex}.setp-proj-a .spacer{flex:auto}.setp-suffix{flex-direction:column;gap:8px;margin-top:4px;display:flex}.setp-suffix-item{align-items:flex-start;gap:6px;display:flex}.setp-suffix-item .setp-suffix-no{color:var(--faint);text-align:right;flex:none;min-width:16px;margin-top:8px;font-family:ui-monospace,Consolas,monospace;font-size:10.5px}.setp-suffix-item .setp-suffix-ta{min-height:64px}.setp-suffix-item .btn{flex:none;margin-top:6px}.setp-suffix-ta{resize:vertical;border:1px solid var(--line);background:var(--paper);width:100%;min-height:110px;color:var(--ink);border-radius:8px;padding:8px 10px;font:400 11.5px/1.7 ui-monospace,Consolas,monospace}.setp-suffix-ta:focus{outline:2px solid var(--soft-2);outline-offset:-1px}.setp-suffix .mono{background:var(--soft);border-radius:4px;padding:0 4px;font-family:ui-monospace,Consolas,monospace;font-size:10.5px}.setp-prompts{background:0 0;border:0;border-radius:0;flex-direction:column;gap:0;min-height:0;margin-top:2px;display:flex}.setp-prompts-nav{border-bottom:1px solid var(--line,#e4e2dc);background:0 0;flex:none;align-items:center;gap:4px;padding:2px 0 8px;display:flex}.setp-prompts-tab{cursor:pointer;color:var(--ink-2,#4b515a);background:0 0;border:0;border-radius:999px;padding:4px 12px;font:600 12px inherit}.setp-prompts-tab:hover{background:var(--soft,#f1f0ec);color:var(--ink,#16181c)}.setp-prompts-tab.is-on{background:var(--mdw-accent-soft,#e8f2ee);color:var(--mdw-accent,#2f6f5e)}.setp-prompts-pane{flex:1;min-width:0;padding:12px 14px 14px;overflow:auto}.setp-prompts-pane>*{max-width:720px}.setp-tpl{flex-direction:column;gap:10px;min-width:0;display:flex}.setp-tpl-cards{flex-direction:column;gap:10px;display:flex}.setp-tpl-card{border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);border-radius:10px;flex-direction:column;gap:8px;min-width:0;padding:12px 12px 10px;display:flex}.setp-tpl-card.is-default{border-color:var(--mdw-accent-line,#b7d4c8)}.setp-tpl-card-head{flex-wrap:wrap;align-items:center;gap:8px;min-width:0;display:flex}.setp-tpl-card-name{text-overflow:ellipsis;white-space:nowrap;min-width:0;max-width:100%;color:var(--ink,#16181c);font-size:13px;font-weight:600;overflow:hidden}.setp-tpl-card-scope{padding-top:2px}.setp-tpl-card-foot{flex-wrap:wrap;align-items:center;gap:6px;min-width:0;display:flex}.setp-tpl-card-new{justify-content:flex-start;display:flex}.setp-scope-block{flex-direction:column;gap:6px;display:flex}.setp-scope{flex-wrap:wrap;align-items:center;gap:6px;display:flex}.setp-scope-label{color:var(--ink-2,#4b515a);font-size:11.5px}.setp-scope-chip{border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);color:var(--ink-2,#4b515a);font:inherit;cursor:pointer;border-radius:999px;padding:2px 10px;font-size:11.5px}.setp-scope-chip:hover{border-color:var(--mdw-accent-line,#b7d4c8)}.setp-scope-chip.on{background:var(--mdw-accent-soft,#e8f2ee);border-color:var(--mdw-accent-line,#b7d4c8);color:var(--mdw-accent,#2f6f5e)}.setp-scope-none{color:#9e4c00;font-size:11px}.setp-scope-origin{color:var(--faint,#8a8578);margin-left:auto;font-size:11px}.setp-scope-add{flex-wrap:wrap;align-items:center;gap:6px;display:flex}.setp-scope-add-label{color:var(--faint,#8a8578);font-size:11px}.setp-scope-add-btn{border:1px dashed var(--line,#e4e2dc);color:var(--ink-2,#4b515a);font:inherit;cursor:pointer;background:0 0;border-radius:6px;padding:2px 8px;font-size:11px}.setp-scope-add-btn:hover{border-color:var(--mdw-accent-line,#b7d4c8);color:var(--mdw-accent,#2f6f5e)}.setp-scope-add-btn.on{border-style:solid;border-color:var(--mdw-accent-line,#b7d4c8);background:var(--mdw-accent-soft,#e8f2ee);color:var(--mdw-accent,#2f6f5e)}.setp-scope-pick{border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);border-radius:8px;flex-direction:column;gap:2px;max-height:160px;padding:6px;display:flex;overflow:auto}.setp-scope-pick-empty{color:var(--faint,#8a8578);padding:6px 8px;font-size:11.5px}.setp-scope-pick-it{cursor:pointer;text-align:left;width:100%;font:inherit;color:var(--ink,#16181c);background:0 0;border:0;border-radius:6px;align-items:center;gap:8px;padding:5px 8px;font-size:12px;display:flex}.setp-scope-pick-it:hover:not(:disabled){background:var(--soft,#f1f0ec)}.setp-scope-pick-it:disabled{opacity:.55;cursor:default}.setp-scope-pick-name{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;overflow:hidden}.setp-scope-pick-done{color:var(--faint,#8a8578);flex:none;font-size:10.5px}.setp-tpl-editor{flex-direction:column;gap:10px;min-width:0;display:flex}.setp-block-tabs{flex-wrap:wrap;gap:6px;min-width:0;display:flex}.setp-block-tab{min-width:0;max-width:100%;font:inherit;cursor:pointer;border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);color:var(--ink,#16181c);border-radius:8px;flex-direction:column;align-items:flex-start;gap:1px;padding:5px 9px;font-size:12px;display:flex}.setp-block-tab small{text-overflow:ellipsis;white-space:nowrap;max-width:100%;color:var(--faint,#8a8578);font-size:10.5px;overflow:hidden}.setp-block-tab.is-on{border-color:var(--mdw-accent-line,#b7d4c8);background:var(--mdw-accent-soft,#e8f2ee);color:var(--mdw-accent,#2f6f5e)}.setp-block-card{border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);border-radius:8px;flex-direction:column;gap:8px;min-width:0;padding:10px;display:flex}.setp-block-card-head{flex-wrap:wrap;justify-content:space-between;align-items:flex-start;gap:8px;display:flex}.setp-block-card-title{flex-direction:column;gap:2px;min-width:0;display:flex}.setp-block-card-title b{font-size:12.5px}.setp-block-card-actions{flex-wrap:wrap;gap:6px;display:flex}.setp-tpl-editor-box{border-top:1px solid var(--line,#e4e2dc);flex-direction:column;gap:8px;min-width:0;padding-top:8px;display:flex}.setp-tpl-editor-head{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:8px;display:flex}.setp-tpl-textarea{resize:vertical;border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);width:100%;min-height:150px;color:var(--ink,#16181c);border-radius:8px;padding:8px 10px;font:400 11.5px/1.7 ui-monospace,Consolas,monospace}.setp-tpl-textarea:focus{outline:2px solid var(--soft-2,#e4e2dc);outline-offset:-1px}.setp-tpl-textarea[readonly]{background:var(--soft,#f1f0ec);color:var(--ink-2,#4b515a)}.setp-params{border:1px dashed var(--line,#e4e2dc);background:var(--soft,#f1f0ec);border-radius:8px;flex-direction:column;gap:4px;min-width:0;padding:7px 9px;display:flex}.setp-params-head{color:var(--ink-2,#4b515a);font-size:11px;font-weight:600}.setp-params-row{flex-wrap:wrap;align-items:baseline;gap:8px;min-width:0;display:flex}.setp-params-label{width:52px;color:var(--mid,#8a8578);flex:none;font-size:11px}.setp-params-items{flex-wrap:wrap;gap:3px 12px;min-width:0;display:flex}.setp-param{white-space:normal;align-items:baseline;gap:4px;font-size:11.5px;line-height:1.6;display:inline-flex}.setp-param code{white-space:nowrap;border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);color:var(--ink,#16181c);border-radius:4px;flex:none;padding:0 4px;font:400 11px/1.5 ui-monospace,Consolas,monospace}.setp-param span{color:var(--ink-2,#4b515a)}.setp-blocks{flex-direction:column;gap:10px;display:flex}.setp-blocks .setp-row{margin:0}.setp-mode-picks{grid-template-columns:1fr 1fr;gap:8px;display:grid}@media (width<=720px){.setp-mode-picks{grid-template-columns:1fr}}.setp-mode-pick{text-align:left;cursor:pointer;font:inherit;border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);color:var(--ink,#16181c);border-radius:8px;padding:8px 10px}.setp-mode-pick b{font-size:12px;display:block}.setp-mode-pick small{color:var(--faint,#8a8578);margin-top:2px;font-size:11px;line-height:1.5;display:block}.setp-mode-pick.is-on{border-color:var(--mdw-accent-line,#b7d4c8);background:var(--mdw-accent-soft,#e8f2ee)}.setp-block{border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);border-radius:8px;flex-direction:column;gap:6px;padding:8px 10px;display:flex}.setp-block.is-off{opacity:.55}.setp-block-head{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.setp-block-toggle{cursor:pointer;align-items:center;gap:6px;font-size:12px;display:flex}.setp-block-toggle b{font-weight:600}.setp-block-tag{color:var(--ink-2,#4b515a);background:var(--soft,#f1f0ec);border-radius:4px;padding:1px 5px;font:400 11px ui-monospace,Consolas,monospace}.setp-block-preset{font:inherit;border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);color:var(--ink,#16181c);border-radius:6px;padding:3px 6px;font-size:11.5px}.setp-blocks .setp-area{resize:vertical;border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);width:100%;min-height:70px;color:var(--ink,#16181c);border-radius:8px;padding:8px 10px;font:400 11.5px/1.7 ui-monospace,Consolas,monospace}.setp-blocks .setp-area:focus{outline:2px solid var(--soft-2,#e4e2dc);outline-offset:-1px}.setp-vars{flex-direction:column;gap:6px;min-width:0;display:flex}.setp-vars-wrap{overflow-x:auto}.setp-vars table{border-collapse:collapse;width:100%;min-width:420px;margin:2px 0 10px;font-size:11.5px}.setp-vars th,.setp-vars td{text-align:left;border-bottom:1px solid var(--line,#e4e2dc);vertical-align:top;padding:4px 8px}.setp-vars th{color:var(--mid,#8a8578);white-space:nowrap;font-weight:600}.setp-vars td:first-child{white-space:nowrap}.setp-vars code{background:var(--soft,#f1f0ec);color:var(--ink,#16181c);border-radius:4px;padding:1px 4px;font:400 11px/1.5 ui-monospace,Consolas,monospace}.setp-vars h4{color:var(--ink,#16181c);margin:10px 0 2px;font-size:12px}
@@ -0,0 +1,6 @@
1
+ import{S as e,_ as t,f as n,g as r,p as i,v as a,y as o}from"./task-status-BP6y8MVu.js";import{k as s,n as c,o as l}from"./index-B_HPAoNR.js";import{t as u}from"./button-M9TUn-AR.js";var d=e(o(),1),f=Object.freeze([{id:`xml`,label:`XML 区块(默认)`,desc:`每段系统内容包进独立标签,agent 一眼分清任务原文与系统规则`},{id:`plain`,label:`正文直追加`,desc:`不包标签,按空行拼接(与改造前的 instruction 逐字一致)`}]),p=8e3,m=`builtin`,h=`系统内置`,g=`{{#if repo}},〔项目介绍 · {{repo.name}}〕({{repo.introPath}}):,{{repo.intro}},{{#if repo.docs}},项目补充文档(可直接读取):,{{#each repo.docs}}, - {{path}}{{#if tag}} [{{tag}}]{{/if}}{{#if note}} # {{note}}{{/if}},{{/each}},{{/if}},{{/if}},{{#if group}},〔项目组上下文 · {{group.name}}〕,{{#if group.desc}},组定位:{{group.desc}},{{/if}},{{#if group.intro}},组介绍({{group.introPath}}):,{{group.intro}},{{/if}},{{#if group.note}},本项目在组里的位置:{{group.note}},{{/if}},{{#if group.peers}},组内成员:,{{#each group.peers}}, - {{name}}:{{#if note}}{{note}}{{else}}(无组内描述){{/if}},{{/each}},{{/if}},{{#if group.docs}},组绑定参考文件(可直接读取):,{{#each group.docs}}, - {{path}}{{#if tag}} [{{tag}}]{{/if}}{{#if note}} # {{note}}{{/if}},{{/each}},{{/if}},{{/if}}`.split(`,`).join(`
2
+ `),_=[`{{#if attach}}`,`〔附件〕本任务包含 {{attach.count}} 个附件(正文内嵌 {{attach.inlineCount}} · 附件区 {{attach.areaCount}})。请先识别附件内容(图片先看图、文档先读内容)再开始处理,不要跳过附件。`,``,`附件清单:`,`{{#each attach.list}}`,` - [{{originLabel}}] {{kindLabel}} {{name}}{{#if sizeText}}({{sizeText}}){{/if}}:{{#if file}}{{#if file.exists}}{{file.localPath}}{{else}}未同步到本地(fileId {{file.fileId}}){{/if}}{{/if}}{{#if url}}{{url.href}}{{/if}}{{#if task}}{{#if task.resolved}}#{{task.seq}} {{task.title}} · 地址 {{task.address}}({{task.statusLabel}}){{else}}地址 {{task.address}}({{task.statusLabel}}){{/if}}{{/if}}{{#if ref}}{{ref.title}}{{#if ref.relPath}}({{ref.relPath}}){{/if}}{{/if}}`,`{{/each}}`,``,`取用方式:`,`{{#each attach.list}}`,` - {{kindLabel}} 《{{name}}》:{{usage}}`,`{{/each}}`,`{{#if attach.syncSummary}}`,`同步情况:{{attach.syncSummary.text}}`,`{{/if}}`,`{{/if}}`].join(`
3
+ `),v=[`{{#if goal.check}}`,`{{goal.check}}`,`{{/if}}`,`{{#if goal.statusLine}}`,`{{goal.statusLine}}`,`{{/if}}`].join(`
4
+ `),y=[`{{#if ext.count}}`,`本队列({{ext.topic}})还有 {{ext.count}} 条待领取任务:`,`{{#each ext.list}}`,` - #{{id}} {{title}}`,`{{/each}}`,`先完成当前任务,再领取下一条;不要因为后面还有活就提前收尾或分心。`,`{{/if}}`].join(`
5
+ `),b=`完成之后必须调用 nx-kv localtask done --id {{task.id}} --summary "<完成总结>" 汇报结果。`,x=[`{{#if getloop}}`,`{{getloop.text}}`,`{{/if}}`].join(`
6
+ `),S=Object.freeze([{id:`context`,tag:`nx-kv.context`,label:`组 / 项目上下文`,desc:`任务所在组、项目关键路径与参考文件;直接用 repo / group 变量拼装`,defaultTemplate:g},{id:`attachment`,tag:`nx-kv.attachment`,label:`附件识别`,desc:`任务带附件时出现:数量 / 清单 / 本地路径`,defaultTemplate:_},{id:`timecheck`,tag:`nx-kv.timecheck`,label:`时间目标检查`,desc:`任务带时间目标时出现:check 指令或目录级状态`,defaultTemplate:v},{id:`ext`,tag:`nx-kv.ext`,label:`待领取队列(ext)`,desc:`同主题还有多少待领取任务与标题;队列空时不出现`,defaultTemplate:y},{id:`ack`,tag:`nx-kv.ack`,label:`ack 完成总结`,desc:`完成任务时调用 localtask done 回填的指令;默认已内置,可见可改`,defaultTemplate:b},{id:`getloop`,tag:`nx-kv.getloop`,label:`持续 get`,desc:`项目开启「持续 get」时出现:完成本任务并回填后继续领取下一条`,defaultTemplate:x}]);function C(e){let t=String(e??``).trim();return t.length>8e3?t.slice(0,p):t}function w(e){return{id:m,name:h,template:e.defaultTemplate,builtin:!0}}function T(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=String(e.id??``).trim().slice(0,64);return t?{id:t,name:String(e.name??``).trim().slice(0,60)||`未命名模板`,template:C(e.template),builtin:!1}:null}function E(e){let t=e&&typeof e==`object`&&!Array.isArray(e)?e:{},n={};for(let e of S){let r=t[e.id],i=Array.isArray(r)?r:Array.isArray(r?.list)?r.list:[],a=[w(e)],o=new Set([m]);for(let e of i){if(e&&typeof e==`object`&&(e.id===`builtin`||e.builtin))continue;let t=T(e);if(t&&!o.has(t.id)&&(o.add(t.id),a.push(t),a.length>=20))break}let s=String(r?.active??``).trim();n[e.id]={active:a.some(e=>e.id===s)?s:m,list:a}}return n}var D=a(),O={context:[{label:`项目`,items:[[`repo.name`,`项目名`],[`repo.intro`,`项目介绍正文`],[`repo.introPath`,`介绍全文路径`],[`repo.docs`,`补充文档(可循环 path/tag/note)`],[`repo.docCount`,`补充文档数`]]},{label:`组`,items:[[`group.name`,`组名`],[`group.desc`,`组定位`],[`group.intro`,`组介绍正文`],[`group.note`,`本项目在组里的位置`],[`group.peers`,`组内成员(可循环 name/note)`],[`group.docs`,`组绑定参考文件(可循环)`],[`groups`,`其余组(可循环 name/desc/path)`]]},{label:`通用`,items:[[`task.id`,`任务号`],[`task.text`,`任务原文`],[`params`,`外部参数(k=v)`]]}],attachment:[{label:`统计`,items:[[`attach.count`,`附件总数`],[`attach.inlineCount`,`正文内嵌数量`],[`attach.areaCount`,`附件区数量`],[`attach.hasInline`,`是否有正文内嵌`],[`attach.hasArea`,`是否有附件区条目`],[`attach.needsSyncCount`,`需要同步到本地的文件数`]]},{label:`附件条目(通用,attach.list 内循环)`,items:[[`kind`,`类型:file / url / task / ref`],[`kindLabel`,`类型显示名:附件/图片/链接/任务/文档`],[`name`,`展示名(任务型为实时标题,不是正文)`],[`size`,`字节数`],[`sizeText`,`可读大小(1.2 MB)`],[`mime`,`MIME 类型`],[`storage`,`存储来源:local / cloud / url / internal`],[`role`,`关系角色:inline / reference / doc / attach`],[`origin`,`来源:inline(正文内嵌)/ area(附件区)`],[`originLabel`,`来源显示名`],[`usage`,`取用说明(按类型生成,含确切命令)`],[`cmd`,`取用命令(file 未同步 / task / ref;url 为空)`],[`locator`,`简短定位串(路径 / 链接 / #seq 标题 / 文档路径)`],[`isImage`,`是否图片(kind=file 的子类型)`],[`needsSync`,`该条是否需要先同步到本地`]]},{label:`文件型(kind=file)· file 子对象`,items:[[`file.localPath`,`本地绝对路径(已同步时才有值)`],[`file.fileId`,`资源 id(未同步时用它拉取)`],[`file.exists`,`本机盘上是否已有副本`],[`file.syncCmd`,`未同步时的命令:nx-kv file sync --ids <fileId>`],[`localPath`,`file.localPath 的平铺别名(旧模板兼容)`],[`fileId`,`file.fileId 的平铺别名`]]},{label:`链接型(kind=url)· url 子对象`,items:[[`url.href`,`可访问的完整链接,可直接抓取`],[`url.host`,`链接域名(host)`],[`href`,`url.href 的平铺别名`],[`host`,`url.host 的平铺别名`],[`urlText`,`链接字符串别名`]]},{label:`任务型(kind=task)· task 子对象`,items:[[`task.taskId`,`本机 tasks.id(join 用;任务被清理后为 0)`],[`task.topicKey`,`任务所在 topic key`],[`task.topicName`,`任务所在 topic 名`],[`task.seq`,`topic 内编号(对外显示的任务号)`],[`task.title`,`实时标题(正文首行,不是正文)`],[`task.status`,`实时状态:pending/claimed/done/cancelled`],[`task.statusLabel`,`状态显示名`],[`task.address`,`地址 topicKey:seq`],[`task.storedAddress`,`附件行里存的旧地址(搬家前)`],[`task.addressDrift`,`地址是否已漂移(任务搬过 topic)`],[`task.resolved`,`正文当前是否可读`],[`task.purged`,`目标任务是否已被清理`],[`task.deleted`,`目标任务是否已软删`],[`task.showCmd`,`取正文命令:nx-kv localtask show --id <seq> --key <topicKey>`],[`seq`,`task.seq 的平铺别名`],[`title`,`task.title 的平铺别名`],[`showCmd`,`task.showCmd 的平铺别名`]]},{label:`文档型(kind=ref)· ref 子对象`,items:[[`ref.refId`,`refs 表 id`],[`ref.title`,`文档标题`],[`ref.relPath`,`文档相对路径 / 外部 md 绝对路径`],[`ref.readCmd`,`读取命令:nx-kv docs get rel:<路径>(或 path:<绝对路径>)`],[`refId`,`ref.refId 的平铺别名`],[`relPath`,`ref.relPath 的平铺别名`],[`readCmd`,`ref.readCmd 的平铺别名`]]},{label:`同步汇总`,items:[[`attach.syncSummary.text`,`本次批量同步的一行汇总`],[`attach.syncSummary.dir`,`同步目录`],[`attach.syncSummary.downloaded`,`已下载数`],[`attach.syncSummary.skipped`,`跳过数`],[`attach.syncSummary.failureCount`,`失败数`]]},{label:`通用`,items:[[`task.id`,`任务号`],[`task.text`,`任务原文(交付模板等处仍在用)`]]}],timecheck:[{label:`时间目标`,items:[[`goal.check`,`时间检查指令(任务级)`],[`goal.statusLine`,`目录级目标状态行`],[`goal.name`,`目标名`],[`goal.deadline`,`截止时间`],[`goal.remainingSec`,`剩余秒数`],[`goal.remainingMin`,`剩余分钟(向上取整)`],[`goal.overtimeSec`,`超时秒数`],[`goal.reached`,`是否到点`]]},{label:`通用`,items:[[`task.id`,`任务号`]]}],ext:[{label:`队列`,items:[[`ext.topic`,`主题 / 队列名`],[`ext.count`,`待领取任务数`],[`ext.list`,`待领取清单(可循环 id/title/topic)`]]},{label:`通用`,items:[[`task.id`,`任务号`]]}],ack:[{label:`通用`,items:[[`task.id`,`任务号`],[`task.text`,`任务原文`],[`source`,`任务来源(local/global)`],[`summary`,`领取方现状`],[`name`,`领取方名字`],[`cwd`,`领取方目录`],[`params`,`外部参数(k=v)`]]}],getloop:[{label:`持续 get`,items:[[`getloop.text`,`持续 get 指令正文`],[`getloop.waitMinutes`,`单轮等待分钟数`]]},{label:`通用`,items:[[`task.id`,`任务号`]]}]};function k({blockId:e}){let t=O[e]||[];return t.length?(0,D.jsxs)(`div`,{className:`setp-params`,"aria-label":`可使用参数`,children:[(0,D.jsx)(`div`,{className:`setp-params-head`,children:`可使用参数`}),t.map(e=>(0,D.jsxs)(`div`,{className:`setp-params-row`,children:[(0,D.jsx)(`span`,{className:`setp-params-label`,children:e.label}),(0,D.jsx)(`div`,{className:`setp-params-items`,children:e.items.map(([e,t])=>(0,D.jsxs)(`span`,{className:`setp-param`,children:[(0,D.jsx)(`code`,{children:e}),(0,D.jsx)(`span`,{children:t})]},e))})]},e.label))]}):null}function A(){return`bt_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function j(e){return S.find(t=>t.id===e)||S[0]}function M(e,t,n){let r=e[t];return r.list.find(e=>e.id===n)||r.list.find(e=>e.id===r.active)||r.list[0]}function N(){let e=r(),{dialog:i,node:a}=n(),[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(S[0].id),[p,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(!1),v=(e,t=null)=>{s(t=>({...t||{},lists:e}));let n=t||(p&&p.blockId===c?p:null),r=n?.blockId||c,i=M(e,r,n?.id||e[r].active);h({blockId:r,id:i.id,name:i.name,template:i.template})},y=()=>{t(`/api/localtasks`).then(e=>{let t=e?.settings||{},n=E(t.blockTemplates),r=t.appendMode===`plain`?`plain`:`xml`;s({lists:n,appendMode:r});let i=S[0],a=M(n,i.id,n[i.id].active);l(i.id),h({blockId:i.id,id:a.id,name:a.name,template:a.template})}).catch(t=>e(`读取失败:`+(t.message||t)))};if((0,d.useEffect)(y,[]),!o)return(0,D.jsx)(`div`,{className:`setp-note`,children:`读取提示词模板…`});let b=j(c),x=o.lists[c],C=p?.id===m,w=async(n,r,i=null)=>{if(!g){_(!0);try{let a=await t(`/api/localtasks/setting`,{method:`PATCH`,body:{blockTemplates:n}});v(E(a?.blockTemplates),i),e(r)}catch(t){e(String(t.message||t))}finally{_(!1)}}},T=()=>JSON.parse(JSON.stringify(o.lists)),O=e=>{if(g)return;l(e);let t=M(o.lists,e,o.lists[e].active);h({blockId:e,id:t.id,name:t.name,template:t.template})},N=e=>{let t=M(o.lists,c,e);h({blockId:c,id:t.id,name:t.name,template:t.template})},P=e=>h(t=>({...t,...e})),F=()=>{if(C){e(`系统内置模板不可编辑;请先「复制」一份再改`);return}let t=String(p.name||``).trim().slice(0,60)||`未命名模板`,n=String(p.template??``),r=T(),i=r[c],a=i.list.findIndex(e=>e.id===p.id),o={id:p.id,name:t,template:n,builtin:!1};a>=0?i.list[a]=o:i.list.push(o),w(r,`已保存模板(当前生效项保存后立即生效)`,{blockId:c,id:p.id})},I=()=>{if(g)return;let e=T(),t={id:A(),name:`新模板`,template:``,builtin:!1};e[c].list.push(t),w(e,`已新建模板,填写后保存,再点「启用」`,{blockId:c,id:t.id})},L=(e=p?.id)=>{if(g||!e)return;let t=M(o.lists,c,e),n=T(),r={id:A(),name:`${t.name||`模板`} 副本`.slice(0,60),template:t.template||``,builtin:!1};n[c].list.push(r),w(n,`已复制模板`,{blockId:c,id:r.id})},R=()=>{if(g||C)return;let e=String(p.name||``).trim().slice(0,60)||`未命名模板`,t=T(),n=t[c],r=n.list.findIndex(e=>e.id===p.id),i={id:p.id,name:e,template:String(p.template??``),builtin:!1};r>=0?n.list[r]=i:n.list.push(i),n.active=p.id,w(t,`已保存并启用「${e}」`,{blockId:c,id:p.id})},z=e=>{if(g||e===x.active)return;let t=T();t[c].active=e,w(t,`已启用「${M(o.lists,c,e).name}」`,{blockId:c,id:e})},B=async t=>{if(g)return;if(t===`builtin`){e(`系统内置模板不可删除`);return}let n=M(o.lists,c,t);if(!await i({title:`删除模板?`,message:`将删除「${n.name}」,保存后不可恢复。该区块的系统内置模板会保留。`,okText:`删除`,danger:!0}))return;let r=T(),a=r[c];a.list=a.list.filter(e=>e.id!==t),a.active===t&&(a.active=m),w(r,`已删除模板,当前生效项已回落到系统内置`)},V=()=>{if(g||x.active===`builtin`)return;let e=T();e[c].active=m,w(e,`已恢复系统内置模板`,{blockId:c,id:m})},H=async n=>{if(!(g||n===o.appendMode)){_(!0);try{let r=await t(`/api/localtasks/setting`,{method:`PATCH`,body:{appendMode:n}});s(e=>({...e,appendMode:r?.appendMode===`plain`?`plain`:`xml`})),e(`已保存追加模式(全局生效)`)}catch(t){e(String(t.message||t))}finally{_(!1)}}};return(0,D.jsxs)(`div`,{className:`setp-tpl-editor`,children:[(0,D.jsx)(`div`,{className:`setp-mode-picks`,children:f.map(e=>(0,D.jsxs)(`button`,{type:`button`,className:`setp-mode-pick`+(o.appendMode===e.id?` is-on`:``),disabled:g,onClick:()=>H(e.id),children:[(0,D.jsx)(`b`,{children:e.label}),(0,D.jsx)(`small`,{children:e.desc})]},e.id))}),(0,D.jsx)(`nav`,{className:`setp-block-tabs`,"aria-label":`提示词区块`,children:S.map(e=>{let t=M(o.lists,e.id,o.lists[e.id].active);return(0,D.jsxs)(`button`,{type:`button`,className:`setp-block-tab`+(e.id===c?` is-on`:``),disabled:g,onClick:()=>O(e.id),children:[(0,D.jsx)(`span`,{children:e.label}),(0,D.jsx)(`small`,{children:t.builtin?`系统内置`:t.name})]},e.id)})}),(0,D.jsxs)(`div`,{className:`setp-block-card`,children:[(0,D.jsxs)(`div`,{className:`setp-block-card-head`,children:[(0,D.jsxs)(`div`,{className:`setp-block-card-title`,children:[(0,D.jsx)(`b`,{children:b.label}),(0,D.jsx)(`span`,{className:`setp-note`,children:b.desc})]}),(0,D.jsxs)(`div`,{className:`setp-block-card-actions`,children:[(0,D.jsx)(u,{variant:`secondary`,disabled:g,onClick:I,children:`新建模板`}),(0,D.jsx)(u,{variant:`secondary`,disabled:g||x.active===`builtin`,onClick:V,children:`恢复内置`})]})]}),(0,D.jsx)(`div`,{className:`setp-tpl-list`,role:`listbox`,"aria-label":`${b.label}模板列表`,children:x.list.map(e=>{let t=e.id===x.active,n=e.id===p?.id;return(0,D.jsxs)(`div`,{className:`setp-tpl-pick${t?` is-on`:``}${n?` is-sel`:``}`,children:[(0,D.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,className:`setp-tpl-name`,title:e.name,onClick:()=>N(e.id),children:[(0,D.jsx)(`span`,{className:`setp-tpl-name-text`,children:e.name}),e.builtin&&(0,D.jsx)(`span`,{className:`setp-badge`,children:`内置`}),t&&(0,D.jsx)(`span`,{className:`setp-badge`,children:`启用中`})]}),(0,D.jsx)(u,{variant:`secondary`,className:`setp-tpl-act`,disabled:g,title:e.builtin?`复制系统内置模板`:`复制该模板`,onClick:()=>L(e.id),children:`复制`}),(0,D.jsx)(u,{variant:`secondary`,className:`setp-tpl-act`,disabled:g||t,title:`设为该区块当前生效模板`,onClick:()=>z(e.id),children:`启用`}),(0,D.jsx)(u,{variant:`secondary`,danger:!0,className:`setp-tpl-act`,disabled:g||e.builtin,title:e.builtin?`系统内置模板不可删除`:`删除该模板`,onClick:()=>B(e.id),children:`删除`})]},e.id)})}),p&&(0,D.jsxs)(`div`,{className:`setp-tpl-editor-box`,children:[(0,D.jsxs)(`div`,{className:`setp-tpl-editor-head`,children:[(0,D.jsx)(`span`,{children:C?`系统内置`:`编辑 · ${p.name||`未命名模板`}`}),(0,D.jsx)(`span`,{className:`setp-note`,children:p.id===x.active?`当前生效,保存后立即参与领取`:`未启用;保存后可点「启用」`})]}),!C&&(0,D.jsxs)(`div`,{className:`setp-row`,children:[(0,D.jsx)(`span`,{children:`模板名`}),(0,D.jsx)(`div`,{className:`setp-input`,children:(0,D.jsx)(`input`,{value:p.name,maxLength:60,disabled:g,onChange:e=>P({name:e.target.value})})})]}),(0,D.jsx)(`textarea`,{className:`setp-area setp-tpl-textarea`,value:p.template,readOnly:C,spellCheck:!1,disabled:g,placeholder:C?``:`在这里写该区块的模板`,onChange:e=>P({template:e.target.value})}),(0,D.jsx)(k,{blockId:c}),(0,D.jsxs)(`div`,{className:`setp-proj-a`,children:[C?(0,D.jsx)(u,{variant:`secondary`,disabled:g,onClick:L,children:`复制为我的模板`}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(u,{variant:`primary`,disabled:g,onClick:F,children:`保存`}),(0,D.jsx)(u,{variant:`secondary`,disabled:g,onClick:y,children:`撤销改动`}),p.id!==x.active&&(0,D.jsx)(u,{variant:`secondary`,disabled:g,onClick:R,children:`保存并启用`})]}),(0,D.jsx)(`span`,{className:`spacer`})]})]})]}),a]})}function P(){let e=s()||{},t=e.rows||[],n=e.repoData&&e.repoData.repos||[],r=e.repoData&&e.repoData.boards||[];return(0,d.useMemo)(()=>{let e=new Map;for(let n of t)n&&n.key&&e.set(String(n.key),n.name||n.key);let i=new Map;for(let e of n)e&&e.key&&(e.type||`repo`)!==`group`&&i.set(String(e.key),e.name||e.key);let a=new Map;for(let e of n)e&&(e.type||``)===`group`&&e.key&&a.set(String(e.key),e.name||e.key);for(let e of r){let t=String(e&&(e.key||e.id)||``);t&&a.set(t,e&&e.name||t)}return{topicByKey:e,repoByKey:i,groupByKey:a,topics:t,repos:n,boards:r}},[t,n,r])}function F(e,t){if(e===`*`)return`全局`;let n=String(e).indexOf(`:`);if(n<0)return String(e);let r=String(e).slice(0,n),i=String(e).slice(n+1),a={topic:`目录`,repo:`项目`,group:`组`}[r]||r,o=``;return r===`topic`?o=t.topicByKey.get(i)||``:r===`repo`?o=t.repoByKey.get(i)||``:r===`group`&&(o=t.groupByKey.get(i)||``),o?`${a} · ${o}`:`${a} ${/^[0-9a-f]{16}$/.test(i)?`${i.slice(0,6)}…`:i}`}function I({scope:e,onChange:t,originTopic:n=``,catalog:i,classPrefix:a=`setp`}){let o=r(),s=P(),c=i||s,[l,u]=(0,d.useState)(null),f=Array.isArray(e)?e:[],p=f.includes(`*`),m=f.filter(e=>e!==`*`),h=a,g=n?c.topicByKey.get(n)||(/^[0-9a-f]{16}$/.test(n)?`${n.slice(0,6)}…`:n):``,_=async e=>{try{await t(e)}catch(e){o(String(e.message||e))}},v=async e=>{if(f.includes(e)){o(`已经在可见范围里了`),u(null);return}await _([...f,e]),u(null)},y=(0,d.useMemo)(()=>{if(l===`topic`)return(c.topics||[]).filter(e=>e&&e.key).map(e=>({entry:`topic:${e.key}`,label:e.name||e.key,sub:e.cwd||``}));if(l===`repo`)return(c.repos||[]).filter(e=>e&&e.key&&(e.type||`repo`)!==`group`&&e.key!==`__unbound__`).map(e=>({entry:`repo:${e.key}`,label:e.name||e.key,sub:e.key}));if(l===`group`){let e=new Set,t=[];for(let n of c.repos||[])n&&(n.type||``)===`group`&&n.key&&!e.has(n.key)&&(e.add(n.key),t.push({entry:`group:${n.key}`,label:n.name||n.key,sub:n.key}));for(let n of c.boards||[]){let r=n&&(n.key||n.id);r&&!e.has(r)&&(e.add(r),t.push({entry:`group:${r}`,label:n&&n.name||r,sub:String(r)}))}return t}return[]},[l,c]);return(0,D.jsxs)(`div`,{className:`${h}-scope-block`,children:[(0,D.jsx)(`div`,{className:`${h}-scope`,children:f.map(e=>(0,D.jsxs)(`button`,{type:`button`,className:`${h}-scope-chip on`,title:`${e} —— 点击移除`,onClick:()=>_(f.filter(t=>t!==e)),children:[F(e,c),` ×`]},e))}),(0,D.jsxs)(`div`,{className:`${h}-scope-add`,children:[(0,D.jsx)(`span`,{className:`${h}-scope-add-label`,children:`添加`}),(0,D.jsx)(`button`,{type:`button`,className:`${h}-scope-add-btn`,disabled:p,title:p?`已绑定全局`:`加上「全局」绑定(与目录/项目/组平级)`,onClick:()=>!p&&_([`*`,...m]),children:`全局`}),[`topic`,`repo`,`group`].map(e=>(0,D.jsx)(`button`,{type:`button`,className:`${h}-scope-add-btn`+(l===e?` on`:``),onClick:()=>u(l===e?null:e),children:{topic:`目录`,repo:`项目`,group:`组`}[e]},e)),g?(0,D.jsxs)(`span`,{className:`${h}-scope-origin`,title:`创建于主题 ${n}`,children:[`创建于 `,g]}):null]}),l&&(0,D.jsx)(`div`,{className:`${h}-scope-pick`,role:`listbox`,"aria-label":`选择可见对象`,children:y.length?y.map(e=>(0,D.jsxs)(`button`,{type:`button`,className:`${h}-scope-pick-it`,disabled:f.includes(e.entry),title:e.sub||e.entry,onClick:()=>v(e.entry),children:[(0,D.jsx)(`span`,{className:`${h}-scope-pick-name`,children:e.label}),f.includes(e.entry)?(0,D.jsx)(`span`,{className:`${h}-scope-pick-done`,children:`已加`}):null]},e.entry)):(0,D.jsx)(`div`,{className:`${h}-scope-pick-empty`,children:`暂无可选项`})})]})}function L({openTemplateEditor:e}){let t=c(),i=r(),{dialog:a,node:o}=n(),s=t.templates||[],[l,f]=(0,d.useState)(null),[p,m]=(0,d.useState)(!1);if(t.unsupported)return(0,D.jsx)(`div`,{className:`setp-note`,children:`当前服务比面板旧——重启面板后才有模板功能。`});let h=async(e,t)=>{if(!p){m(!0);try{await e(),t&&i(t)}catch(e){i(String(e.message||e))}finally{m(!1)}}},g=async e=>{await a({title:`删除模板「${e.name}」`,danger:!0,okText:`删除`})&&(await h(()=>t.remove(e.id),`已删除「${e.name}」`),l===e.id&&f(null))};return(0,D.jsxs)(`div`,{className:`setp-tpl setp-tpl-cards`,children:[o,!s.length&&(0,D.jsx)(`div`,{className:`setp-note`,children:`还没有模板(内置默认模板加载中…)。`}),s.map(n=>{let r=n.id===t.defaultId,i=l===n.id;return(0,D.jsxs)(`div`,{className:`setp-tpl-card`+(r?` is-default`:``),children:[(0,D.jsxs)(`div`,{className:`setp-tpl-card-head`,children:[(0,D.jsx)(`span`,{className:`setp-tpl-card-name`,children:n.name}),r&&(0,D.jsx)(`span`,{className:`setp-badge`,children:`默认`}),n.builtin&&(0,D.jsx)(`span`,{className:`setp-badge soft`,children:`内置`})]}),i&&(0,D.jsx)(`div`,{className:`setp-tpl-card-scope`,children:(0,D.jsx)(I,{scope:n.scope,originTopic:n.originTopic,onChange:e=>t.update(n.id,{scope:e})})}),(0,D.jsxs)(`div`,{className:`setp-tpl-card-foot`,children:[(0,D.jsx)(`span`,{className:`grow`}),(0,D.jsx)(u,{variant:`secondary`,disabled:p,onClick:()=>f(i?null:n.id),children:`可见绑定`}),(0,D.jsx)(u,{variant:`secondary`,disabled:p,onClick:()=>e?.({id:n.id,name:n.name,mode:`edit`}),children:`编辑`}),!r&&(0,D.jsx)(u,{variant:`secondary`,disabled:p,onClick:()=>h(()=>t.setDefault(n.id),`默认模板已设为「${n.name}」`),children:`设为默认`}),!n.builtin&&(0,D.jsx)(u,{variant:`secondary`,disabled:p,onClick:()=>g(n),children:`删除`})]})]},n.id)}),(0,D.jsx)(`div`,{className:`setp-tpl-card-new`,children:(0,D.jsx)(u,{variant:`secondary`,disabled:p,onClick:()=>e?.({mode:`new`,scope:[]}),children:`+ 新建模板`})})]})}function R(){let e=r(),n=s()||{},i=n.patchPrefs,[a,o]=(0,d.useState)([]),[c,l]=(0,d.useState)([]),[u,f]=(0,d.useState)([]),p=(0,d.useCallback)(()=>{Promise.all([t(`/api/repos`),t(`/api/boards`)]).then(([e,t])=>{o(Array.isArray(e)?e:e?.repos||[]),l(Array.isArray(t)?t:t?.boards||[]),f(n.prefs?.hidden||[])}).catch(t=>e(`读取失败:`+(t.message||t)))},[e,n.prefs]);(0,d.useEffect)(()=>{p()},[p]);let m=e=>{let t=n.prefs?.hidden||[],r=t.includes(e)?t.filter(t=>t!==e):[...t,e];i&&i({hidden:r}),f(r)},h=(e,t,n,r)=>(0,D.jsx)(`div`,{className:`setp-row`,children:(0,D.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,cursor:`pointer`},children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:!u.includes(t),onChange:()=>m(t)}),(0,D.jsx)(`span`,{children:n}),r?(0,D.jsx)(`span`,{className:`mono faint`,children:r}):null]})},e+`:`+t);return(0,D.jsxs)(`div`,{className:`setp-side`,children:[(0,D.jsx)(`div`,{className:`setp-note`,children:`勾掉的项目组 / 项目不在侧边栏显示(登记与数据都留着,随时勾回来)。`}),(0,D.jsx)(`div`,{className:`setp-row`,children:(0,D.jsx)(`span`,{children:`项目组(指针)`})}),c.map(e=>h(`board`,e.key||e.id,e.name,`${(e.repos||[]).length} 个模块`)),!c.length&&(0,D.jsx)(`div`,{className:`setp-note`,children:`还没有项目组。`}),(0,D.jsx)(`div`,{className:`setp-row`,children:(0,D.jsx)(`span`,{children:`项目 / 仓库(模块)`})}),a.map(e=>h(`repo`,e.key||e.id,e.name,e.path)),!a.length&&(0,D.jsx)(`div`,{className:`setp-note`,children:`还没有登记仓库。`})]})}var z=[{id:`pref`,label:`偏好`,icon:`flow`},{id:`work`,label:`工作区`,icon:`sidebar`},{id:`cloud`,label:`云端与存储`,icon:`cloud`},{id:`taskTemplates`,label:`任务模板`,icon:`list`},{id:`prompts`,label:`提示词模板`,icon:`flow`},{id:`sidebar`,label:`侧栏显示`,icon:`sidebar`}];function B(){let e=s()||{},a=r(),{dialog:o,node:c}=n(),f=e.prefs||{},p=e.patchPrefs||(()=>{}),m=e.model,[h,g]=(0,d.useState)(`pref`),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(!1),x=(0,d.useCallback)(async()=>{try{v(await t(`/api/setting`))}catch(e){a(`读取设置失败:`+(e.message||e))}},[a]);(0,d.useEffect)(()=>{x()},[x]);let S=e=>e().catch(e=>a(String(e.message||e))),C=e=>S(async()=>{b(!0);try{v(await t(`/api/setting`,{method:`POST`,body:e})),a(`已保存`)}finally{b(!1)}}),w={pref:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`setp-row`,children:[(0,D.jsx)(`span`,{children:`侧边栏默认收起`}),(0,D.jsxs)(`button`,{className:`toggle`+(f.defaultFolded?` on`:``),onClick:()=>p({defaultFolded:!f.defaultFolded}),children:[(0,D.jsx)(`span`,{className:`dot`}),f.defaultFolded?`开`:`关`]})]}),(f.hidden||[]).length>0&&(0,D.jsxs)(`div`,{className:`setp-row`,children:[(0,D.jsxs)(`span`,{children:[`隐藏仓库 `,f.hidden.length,` 个`]}),(0,D.jsx)(u,{variant:`secondary`,onClick:()=>p({hidden:[]}),children:`恢复显示`})]})]}),work:(0,D.jsx)(D.Fragment,{children:(0,D.jsxs)(`div`,{className:`setp-row`,children:[(0,D.jsx)(`span`,{children:`布局`}),(0,D.jsx)(u,{variant:`secondary`,onClick:async()=>{await o({title:`重置为初始两栏`,message:`丢掉存下来的布局,回到初始的两栏(目录 + 开始)?`,okText:`重置`})&&e.shell&&e.shell.resetLayout()},children:`重置为初始两栏`})]})}),cloud:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`setp-row`,children:[(0,D.jsx)(`span`,{children:`读任务时自动下载附件`}),(0,D.jsxs)(`button`,{className:`toggle`+(_&&_.autoSyncAttachments?` on`:``),disabled:!_||y,onClick:()=>C({autoSyncAttachments:!_.autoSyncAttachments}),children:[(0,D.jsx)(`span`,{className:`dot`}),_&&_.autoSyncAttachments?`开`:`关`]})]}),(0,D.jsxs)(`div`,{className:`setp-row`,children:[(0,D.jsx)(`span`,{children:`附件目录`}),(0,D.jsxs)(`span`,{className:`setp-input`,children:[(0,D.jsx)(`input`,{value:_&&_.attachmentsDir||``,placeholder:`(默认 ~/.nx-kv/attachments/)`,onChange:e=>v(t=>({...t,attachmentsDir:e.target.value}))}),(0,D.jsx)(u,{variant:`secondary`,disabled:!_||y,onClick:()=>C({attachmentsDir:_.attachmentsDir}),children:`保存`})]})]}),(0,D.jsxs)(`div`,{className:`setp-row`,children:[(0,D.jsx)(`span`,{children:`参考仓库存储根`}),(0,D.jsxs)(`span`,{className:`setp-input`,children:[(0,D.jsx)(`input`,{value:_&&_.gitRepoRoot||``,placeholder:`(未设置 —— clone 参考仓库前先设)`,onChange:e=>v(t=>({...t,gitRepoRoot:e.target.value}))}),(0,D.jsx)(u,{variant:`secondary`,disabled:!_||y,onClick:()=>C({gitRepoRoot:_.gitRepoRoot}),children:`保存`})]})]}),(0,D.jsxs)(`div`,{className:`setp-row`,children:[(0,D.jsx)(`span`,{children:`开发仓库克隆根`}),(0,D.jsxs)(`span`,{className:`setp-input`,children:[(0,D.jsx)(`input`,{value:_&&_.gitDevRoot||``,placeholder:`(未设置 —— 导入布局时只登记不克隆)`,onChange:e=>v(t=>({...t,gitDevRoot:e.target.value}))}),(0,D.jsx)(u,{variant:`secondary`,disabled:!_||y,onClick:()=>C({gitDevRoot:_.gitDevRoot}),children:`保存`})]})]})]}),taskTemplates:(0,D.jsx)(L,{openTemplateEditor:e=>{m&&l(m,e||{})}}),prompts:(0,D.jsx)(N,{}),sidebar:(0,D.jsx)(R,{})};return(0,D.jsxs)(`div`,{className:`setp`,children:[(0,D.jsx)(`nav`,{className:`setp-nav`,"aria-label":`设置分区`,children:z.map(e=>(0,D.jsxs)(`button`,{className:`setp-navitem`+(h===e.id?` on`:``),"aria-current":h===e.id,onClick:()=>g(e.id),children:[(0,D.jsx)(i,{name:e.icon,size:14}),(0,D.jsx)(`span`,{children:e.label})]},e.id))}),(0,D.jsxs)(`div`,{className:`setp-body`,children:[(0,D.jsx)(`div`,{className:`setp-h`,children:z.find(e=>e.id===h).label}),w[h]]}),c]})}export{B as default};