nx-kv 0.67.2 → 0.68.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.
- package/CHANGELOG.md +54 -0
- package/package.json +1 -1
- package/src/web/frontend/components/layout/vsc-crumbs-model.ts +232 -0
- package/src/web/frontend/components/layout/vsc-crumbs.css +88 -0
- package/src/web/frontend/components/layout/vsc-crumbs.tsx +99 -0
- package/src/web/frontend/page/dir/task.tsx +14 -15
- package/src/web/frontend/page/settings/index.tsx +20 -0
- package/src/web/frontend/page/settings/style.css +24 -0
- package/src/web/frontend/types.ts +2 -0
- package/src/web/frontend/workspace/open.ts +4 -2
- package/src/web/public/assets/{bar-C0Q_Qe4z.js → bar-C-XvccT_.js} +1 -1
- package/src/web/public/assets/{composer-launch-BF3_hyn5.js → composer-launch-DocQvHKh.js} +1 -1
- package/src/web/public/assets/{composer-panel-BWJzkrXS.js → composer-panel-BYxKIE03.js} +1 -1
- package/src/web/public/assets/{dag-C3OiVSpt.js → dag-EGY58BeS.js} +1 -1
- package/src/web/public/assets/{dir-BD8bocip.js → dir-BjMCzD3e.js} +1 -1
- package/src/web/public/assets/doc-CKbuO1Gj.js +6 -0
- package/src/web/public/assets/{group-DaBalriD.js → group-Bh5tkQR3.js} +1 -1
- package/src/web/public/assets/{index-q51dndMj.js → index-cyRcywoY.js} +3 -3
- package/src/web/public/assets/{md-history-COQu16vy.js → md-history-sxG54jJ_.js} +1 -1
- package/src/web/public/assets/{progress-CDh6DY7g.js → progress-CPQSMxLp.js} +1 -1
- package/src/web/public/assets/{refs-t79ynSY8.js → refs-Bzf1kVpx.js} +1 -1
- package/src/web/public/assets/{repo-form-modal-dZqpHyUj.js → repo-form-modal-geOSTx9x.js} +1 -1
- package/src/web/public/assets/{repos-DdhOQJqF.js → repos-BbKWW4no.js} +1 -1
- package/src/web/public/assets/route-crumb-CqDySF_k.js +1 -0
- package/src/web/public/assets/{settings-BWHjNegB.css → settings-d2ah_h6O.css} +1 -1
- package/src/web/public/assets/{settings-2rNJ_YAJ.js → settings-iqLRF9ip.js} +1 -1
- package/src/web/public/assets/task-BeaiJyO3.js +14 -0
- package/src/web/public/assets/task-Dcd2eA8B.css +1 -0
- package/src/web/public/assets/{task-ops-CWb5frMG.js → task-ops-BKVm1WHw.js} +1 -1
- package/src/web/public/assets/{templates-B9Nu7yqL.js → templates-B32TlcGk.js} +3 -3
- package/src/web/public/assets/{tool-bar-DPXnjdQF.js → tool-bar-DpfJRjFG.js} +1 -1
- package/src/web/public/assets/{use-rail-drag-B6J0iqFK.js → use-rail-drag-DcUzHeV_.js} +1 -1
- package/src/web/public/index.html +7 -8
- package/src/web/public/assets/doc-CVIVBV6n.js +0 -6
- package/src/web/public/assets/list-search-DFvFY408.js +0 -1
- package/src/web/public/assets/route-crumb-BKq2jry0.js +0 -1
- package/src/web/public/assets/task-PK9OACFo.js +0 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,f as t,h as n,i as r,l as i,t as a,u as o}from"./popup-dBtYqEM1.js";import{d as s}from"./task-status-Cjsm0xF7.js";import{S as c,_ as l,g as u,o as d,p as f,v as p,x as ee,y as m}from"./md-history-COQu16vy.js";var h=n(t(),1),g=e(),_=a,v={position:(e,t)=>(e.position||0)-(t.position||0)||String(e.id).localeCompare(String(t.id)),name:(e,t)=>String(e.name||``).localeCompare(String(t.name||``)),kind:(e,t)=>String(e.kind).localeCompare(String(t.kind))||String(e.name||``).localeCompare(String(t.name||``))};function y(e,{onRemove:t,onPreview:n,onPreviewMd:r,onOpenTask:i,onOpenDoc:a,onEditNote:o,onReplace:s}){let c=e.kind===`image`?m(e.id):``;return(0,g.jsxs)(`div`,{className:`att-item att-kind-${e.kind}`,children:[e.kind===`image`?(0,g.jsx)(`button`,{type:`button`,className:`att-thumb`,onClick:()=>n({src:c,name:e.name}),title:`点击看大图`,children:(0,g.jsx)(`img`,{src:c,alt:e.name,loading:`lazy`})}):(0,g.jsx)(`span`,{className:`att-kind-badge`,children:p(e.kind)}),(0,g.jsxs)(`span`,{className:`att-item-main`,children:[e.kind===`task`?(0,g.jsx)(`button`,{type:`button`,className:`att-link`,title:`跳转到任务 #${e.targetSeq??``}`,onClick:()=>i?.({key:e.targetKey,seq:e.targetSeq}),children:e.name}):e.kind===`ref`?(0,g.jsx)(`button`,{type:`button`,className:`att-link`,title:e.note||e.title||e.name||`打开文档`,onClick:()=>a?.(e.refId?`ref:`+e.refId:e.locator||e.targetRef),children:e.title||e.name}):e.kind===`url`?(0,g.jsx)(`a`,{className:`att-link`,href:e.url,target:`_blank`,rel:`noreferrer`,title:e.url,children:e.name}):(0,g.jsx)(`span`,{className:`att-item-name`,title:e.name,children:e.name}),(0,g.jsxs)(`span`,{className:`att-item-meta`,children:[e.sizeText?(0,g.jsx)(`span`,{children:e.sizeText}):null,e.kind===`mdfile`?(0,g.jsxs)(`span`,{className:`att-note`,title:e.absPath||``,children:[e.absPath||`(路径为空)`,e.missing?` · 源文件已不在`:``]}):null,e.kind===`folder`?(0,g.jsxs)(`span`,{className:`att-note`,title:e.absPath||``,children:[e.absPath||`(路径为空)`,e.missing?` · 目录已不在`:``]}):null,e.note?(0,g.jsx)(`span`,{className:`att-note`,children:e.note}):null]})]}),e.kind===`mdfile`?(0,g.jsx)(`span`,{className:`att-item-acts`,children:(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`按 md 渲染磁盘当前内容(读时核对指纹)`,onClick:()=>r?.(e),children:`预览`})}):null,e.kind===`file`||e.kind===`image`?(0,g.jsxs)(`span`,{className:`att-item-acts`,children:[(0,g.jsx)(`a`,{className:`att-act`,href:m(e.id),target:`_blank`,rel:`noreferrer`,children:`打开`}),(0,g.jsx)(`a`,{className:`att-act`,href:m(e.id),download:e.name,children:`下载`})]}):null,e.kind===`ref`?(0,g.jsxs)(`span`,{className:`att-item-acts`,children:[o?(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`改这条绑定的一行说明(交付清单会透出)`,onClick:()=>o(e),children:`✎ 说明`}):null,(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`换成另一篇文档(替换这条绑定)`,onClick:()=>s?.(e),children:`⇄ 更换`})]}):null,(0,g.jsx)(`button`,{type:`button`,className:`att-x`,"aria-label":`移除 ${e.name}`,onClick:()=>t(e),children:`×`})]},e.id)}function b({host:e=`task`,hostId:t,hostKey:n,hostCwd:a,refId:p,allow:m={file:!0,url:!0,folder:!0,task:!1,ref:!1,repo:!1},taskOptions:b=[],docOptions:x,disabled:S=!1,disabledText:C=`提交任务后可以在这里挂附件(当前是草稿)。`,openRef:w,onChanged:T,onOpenTask:E,onOpenDoc:D}){let O=i(),{dialog:te,node:ne}=r(),[k,A]=(0,h.useState)([]),[j,M]=(0,h.useState)(!1),[N,P]=(0,h.useState)(``),[re,F]=(0,h.useState)(!1),[ie,I]=(0,h.useState)(!1),[ae,L]=(0,h.useState)(!1),[R,oe]=(0,h.useState)(`position`),[z,B]=(0,h.useState)(null),[V,H]=(0,h.useState)(null),[U,W]=(0,h.useState)(!1),[G,K]=(0,h.useState)(null),[q,J]=(0,h.useState)(null),Y=(0,h.useMemo)(()=>ee(e,{hostId:t,hostKey:n,hostCwd:a,refId:p}),[e,t,n,a,p]),X=(0,h.useCallback)(async()=>{if(S){A([]);return}M(!0),P(``);try{let e=await Y.list();A((e.attachments||[]).map(c))}catch(e){P(String(e.message||e))}finally{M(!1)}},[Y,S]);(0,h.useEffect)(()=>{X()},[X]),(0,h.useImperativeHandle)(w,()=>({open:()=>F(!0),refresh:X}),[X]),(0,h.useEffect)(()=>{if(!G)return;let e=e=>{e.key===`Escape`&&K(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[G]);let Z=(0,h.useMemo)(()=>[...k].sort(v[R]||v.position),[k,R]),Q=Z.filter(e=>e.area===`inline`),$=Z.filter(e=>e.area===`area`),se=async(e,t)=>{if(S)return;let n=f(t),r=n.length?n:[...e||[]].filter(e=>e&&e.size>0);if(!r.length)return;L(!0);let i=0;for(let e of r)try{let t=await u(e),n=t.fileId||t.id;if(!n)throw Error(`上传未返回 fileId`);await Y.attach({fileId:n,name:t.name}),i+=1}catch(t){O(`「${e.name||`文件`}」添加失败:${t.message||t}`)}L(!1),i&&(O(`已挂到附件区 ${i} 个文件`),await X(),T?.())},ce=async r=>{if(r&&e!==`doc`)try{let e=await te({title:`说明 · ${r.name}`,input:!0,placeholder:`这一行里大概是什么(交付清单会透出给 agent)`,value:r.note||``,okText:`保存说明`});if(e===null)return;let i=typeof e==`string`?e:e&&e.value||``,s={id:Number(t),...n?{key:n}:a?{cwd:a}:{},attachment:r.id,note:i};await o(`/api/localtasks/attach-note`,{method:`PATCH`,body:s}),O(i?`已保存说明:${i}`:`已清空说明`),await X(),T?.()}catch(e){O(`改说明失败:${e.message||e}`)}},le=e=>{e&&(H(e),F(!0))},ue=async()=>{let e=z;if(e){W(!0);try{await Y.detach(e.id),B(null),O(`已解除关联:${e.name}`),await X(),T?.()}catch(e){O(`移除失败:${e.message||e}`)}finally{W(!1)}}},de=async e=>{if(e)try{let t=await o(`/api/docs/mdfile?attachment=${encodeURIComponent(String(e.id))}`),n=String(t.body||``);J({name:e.name||`md`,html:s(n),path:String(t.absPath||e.absPath||``),stale:!!t.stale,missing:!!t.missing})}catch(e){O(`读取失败:${e.message||e}`)}},fe=!j&&!N&&!k.length;return(0,g.jsxs)(`div`,{className:`att-area${S?` is-disabled`:``}`,onDragOver:e=>{!S&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),I(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||I(!1)},onDrop:e=>{I(!1),!S&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),se(null,e))},children:[ne,(0,g.jsxs)(`div`,{className:`att-area-head`+(ie&&!S?` is-over`:``),children:[(0,g.jsxs)(`span`,{className:`att-area-title`,children:[`附件`,k.length?(0,g.jsx)(`span`,{className:`att-count`,children:k.length}):null,ae?(0,g.jsx)(`span`,{className:`att-area-note`,children:`上传中…`}):null]}),(0,g.jsxs)(`span`,{className:`att-area-acts`,children:[k.length?(0,g.jsxs)(`select`,{className:`att-sort`,value:R,onChange:e=>oe(e.target.value),"aria-label":`附件排序`,children:[(0,g.jsx)(`option`,{value:`position`,children:`按添加顺序`}),(0,g.jsx)(`option`,{value:`name`,children:`按名称`}),(0,g.jsx)(`option`,{value:`kind`,children:`按类型`})]}):null,(0,g.jsx)(`button`,{type:`button`,className:`btn ghost att-add-btn`,disabled:S,onClick:()=>F(!0),children:`添加附件`})]})]}),S?(0,g.jsx)(`div`,{className:`att-empty`,children:C}):null,j?(0,g.jsx)(`div`,{className:`att-empty`,children:`加载附件…`}):null,N?(0,g.jsxs)(`div`,{className:`att-empty att-err-text`,children:[`附件加载失败:`,N]}):null,fe?(0,g.jsx)(`div`,{className:`att-empty`,children:`还没有附件。拖文件到这里,或点「添加附件」——只挂附件区,不写正文。`}):null,Q.length?(0,g.jsxs)(`div`,{className:`att-section`,children:[(0,g.jsxs)(`div`,{className:`att-section-head`,children:[l.inline,(0,g.jsx)(`span`,{className:`att-section-hint`,children:`正文里的引用,删正文行会跟着消失`})]}),Q.map(t=>y(t,{onRemove:B,onPreview:K,onPreviewMd:de,onOpenTask:E,onOpenDoc:D,onEditNote:e===`task`?ce:void 0,onReplace:le,key:t.id}))]}):null,$.length?(0,g.jsxs)(`div`,{className:`att-section`,children:[(0,g.jsxs)(`div`,{className:`att-section-head`,children:[l.area,(0,g.jsx)(`span`,{className:`att-section-hint`,children:`不依赖正文,删正文行也不会丢`})]}),$.map(t=>y(t,{onRemove:B,onPreview:K,onPreviewMd:de,onOpenTask:E,onOpenDoc:D,onEditNote:e===`task`?ce:void 0,onReplace:le,key:t.id}))]}):null,(0,g.jsx)(d,{open:re,host:e,hostId:t,hostKey:n,hostCwd:a,refId:p,allow:m,taskOptions:b,docOptions:x,replaceAttachment:V?V.id:null,replaceNote:V&&V.note||``,onClose:()=>{F(!1),H(null)},onDone:async()=>{H(null),await X(),T?.()}}),z?(0,g.jsx)(_,{title:`移除附件`,size:`sm`,busy:U,onClose:U?void 0:()=>B(null),footer:(0,g.jsxs)(`div`,{className:`att-foot`,children:[(0,g.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:U,onClick:()=>B(null),children:`取消`}),(0,g.jsx)(`button`,{type:`button`,className:`btn`,disabled:U,onClick:()=>void ue(),children:`移除(解除关联)`})]}),children:(0,g.jsxs)(`div`,{className:`att-confirm`,children:[(0,g.jsx)(`div`,{className:`att-confirm-name`,children:z.name}),(0,g.jsxs)(`div`,{className:`att-confirm-text`,children:[`会从这份`,e===`task`?`任务`:`文档`,`的附件清单里移除,资源本身(行与字节)保留在孤儿池, 之后仍可重新挂载;需要清理时由库级 GC 统一回收。`]})]})}):null,q?(0,g.jsx)(_,{title:(0,g.jsxs)(`span`,{children:[q.name,(0,g.jsx)(`span`,{className:`att-md-path`,children:q.path})]}),size:`lg`,onClose:()=>J(null),footer:(0,g.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:()=>J(null),children:`关闭`}),children:q.missing?(0,g.jsxs)(`div`,{className:`att-empty`,children:[`源文件已不在:`,q.path||`(路径为空)`]}):(0,g.jsxs)(`div`,{className:`att-md-preview`,children:[q.stale?(0,g.jsx)(`div`,{className:`att-md-warn`,children:`内容已变化(与登记指纹不一致),以下为磁盘当前内容。`}):null,(0,g.jsx)(`article`,{dangerouslySetInnerHTML:{__html:q.html}})]})}):null,G?(0,g.jsx)(`div`,{className:`att-lightbox`,role:`dialog`,"aria-label":`图片预览`,onMouseDown:e=>{e.target===e.currentTarget&&K(null)},children:(0,g.jsxs)(`div`,{className:`att-lightbox-card`,children:[(0,g.jsxs)(`div`,{className:`att-lightbox-head`,children:[(0,g.jsx)(`span`,{className:`att-lightbox-name`,children:G.name}),(0,g.jsx)(`a`,{className:`att-lightbox-open`,href:G.src,target:`_blank`,rel:`noreferrer`,children:`新窗口打开`}),(0,g.jsx)(`button`,{type:`button`,className:`pp-x`,"aria-label":`关闭`,onClick:()=>K(null),children:`×`})]}),(0,g.jsx)(`img`,{className:`att-lightbox-img`,src:G.src,alt:G.name})]})}):null]})}function x(e=`task`,t=!0){let n=(0,h.useCallback)(t=>`nxkv.${e}Dock${t}`,[e]),[r,i]=(0,h.useState)(()=>{let e=localStorage.getItem(n(`Open`));return e===null?t:e!==`0`}),[a,o]=(0,h.useState)(()=>localStorage.getItem(n(`Tab`))||`attach`),[s,c]=(0,h.useState)(()=>{let e=Number(localStorage.getItem(n(`H`)));return Number.isFinite(e)&&e>=96?e:176}),l=(0,h.useRef)(s);l.current=s;let u=(0,h.useRef)(null),[d,f]=(0,h.useState)(!1),p=(0,h.useRef)(176);return(0,h.useEffect)(()=>{localStorage.setItem(n(`Open`),r?`1`:`0`)},[r,n]),(0,h.useEffect)(()=>{localStorage.setItem(n(`Tab`),a)},[a,n]),{dockOpen:r,setDockOpen:i,dockTab:a,setDockTab:o,dockH:s,dockHRef:l,dockRef:u,dockMax:d,setDockMax:f,dockPrevHRef:p,showDockTab:(0,h.useCallback)(e=>{o(e),i(!0)},[]),onDockDragStart:(0,h.useCallback)(e=>{if(!r)return;e.preventDefault(),f(!1);let t=e.clientY,i=l.current,a=u.current?.parentElement?.clientHeight||window.innerHeight,o=e=>Math.max(96,Math.min(Math.round(a*.62),Math.round(e))),s=e=>{let n=o(i-(e.clientY-t));l.current=n,c(n)},d=()=>{window.removeEventListener(`mousemove`,s),window.removeEventListener(`mouseup`,d),document.body.style.userSelect=``,document.body.style.cursor=``,localStorage.setItem(n(`H`),String(l.current))};document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`,window.addEventListener(`mousemove`,s),window.addEventListener(`mouseup`,d)},[r,n]),toggleDockMax:(0,h.useCallback)(()=>{if(d){c(p.current),f(!1);return}p.current=l.current;let e=u.current?.parentElement?.clientHeight||window.innerHeight,t=Math.max(96,Math.round(e*.62));l.current=t,c(t),f(!0)},[d])}}var S=`nx-kv-ack-rail-pos`,C=`nx-kv-doc-rail-pos`;function w(e={}){let{x:t,y:n,parentW:r,parentH:i,railW:a=0,railH:o=0,margin:s=8}=e||{};if(![t,n,r,i].every(e=>Number.isFinite(e)))return null;let c=Number(t),l=Number(n),u=Number(r),d=Number(i),f=Math.max(s,u-a-s),p=Math.max(s,d-o-s);return{x:Math.min(f,Math.max(s,c)),y:Math.min(p,Math.max(s,l))}}function T(e=S){try{let t=JSON.parse(localStorage.getItem(e)||`null`);if(!t||typeof t!=`object`)return null;let n=Number(t.x),r=Number(t.y);return!Number.isFinite(n)||!Number.isFinite(r)?null:{x:n,y:r}}catch{return null}}function E(e,t=S){try{e?localStorage.setItem(t,JSON.stringify({x:Math.round(e.x),y:Math.round(e.y)})):localStorage.removeItem(t)}catch{}}var D=4;function O(e){let[t,n]=(0,h.useState)(()=>T(e)),[r,i]=(0,h.useState)(!1),a=(0,h.useRef)(null),o=(0,h.useRef)(null),s=(0,h.useRef)(!1);(0,h.useEffect)(()=>{let e=a.current,t=e&&e.parentElement;if(!e||!t)return;let r=()=>{n(n=>{if(!n)return n;let r=t.getBoundingClientRect(),i=e.getBoundingClientRect(),a=w({x:n.x,y:n.y,parentW:r.width,parentH:r.height,railW:i.width,railH:i.height});return a&&(a.x!==n.x||a.y!==n.y)?a:n})};return r(),window.addEventListener(`resize`,r,{passive:!0}),()=>window.removeEventListener(`resize`,r)},[]);let c=(0,h.useCallback)(e=>{if(e.pointerType===`mouse`&&e.button!==0)return;let t=a.current,n=t&&t.parentElement;if(!t||!n)return;let r=t.style.bottom;t.style.bottom=`auto`;let i=t.getBoundingClientRect();t.style.bottom=r||``;let s=n.getBoundingClientRect();o.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startLeft:i.left-s.left,startTop:i.top-s.top,parentW:s.width,parentH:s.height,railW:i.width,railH:i.height,moved:!1};try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}},[]),l=(0,h.useCallback)(e=>{let t=o.current;if(!t||e.pointerId!==t.pointerId)return;let r=e.clientX-t.startX,a=e.clientY-t.startY;if(!t.moved){if(Math.hypot(r,a)<D)return;t.moved=!0,s.current=!0,i(!0),document.body.style.userSelect=`none`}let c=w({x:t.startLeft+r,y:t.startTop+a,parentW:t.parentW,parentH:t.parentH,railW:t.railW,railH:t.railH});c&&(t.last=c,n(c))},[]),u=(0,h.useCallback)(t=>{let n=o.current;n&&t.pointerId===n.pointerId&&(o.current=null,n.moved&&(i(!1),document.body.style.userSelect=``,E(n.last,e)))},[e]),d=(0,h.useCallback)(()=>{n(null),E(null,e)},[e]);return{railRef:a,pos:t,dragging:r,draggedRef:s,resetPos:d,handleProps:{onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:u,onDoubleClick:d}}}export{b as i,C as n,x as r,O as t};
|
|
1
|
+
import{d as e,f as t,h as n,i as r,l as i,t as a,u as o}from"./popup-dBtYqEM1.js";import{d as s}from"./task-status-Cjsm0xF7.js";import{S as c,_ as l,g as u,o as d,p as f,v as p,x as ee,y as m}from"./md-history-sxG54jJ_.js";var h=n(t(),1),g=e(),_=a,v={position:(e,t)=>(e.position||0)-(t.position||0)||String(e.id).localeCompare(String(t.id)),name:(e,t)=>String(e.name||``).localeCompare(String(t.name||``)),kind:(e,t)=>String(e.kind).localeCompare(String(t.kind))||String(e.name||``).localeCompare(String(t.name||``))};function y(e,{onRemove:t,onPreview:n,onPreviewMd:r,onOpenTask:i,onOpenDoc:a,onEditNote:o,onReplace:s}){let c=e.kind===`image`?m(e.id):``;return(0,g.jsxs)(`div`,{className:`att-item att-kind-${e.kind}`,children:[e.kind===`image`?(0,g.jsx)(`button`,{type:`button`,className:`att-thumb`,onClick:()=>n({src:c,name:e.name}),title:`点击看大图`,children:(0,g.jsx)(`img`,{src:c,alt:e.name,loading:`lazy`})}):(0,g.jsx)(`span`,{className:`att-kind-badge`,children:p(e.kind)}),(0,g.jsxs)(`span`,{className:`att-item-main`,children:[e.kind===`task`?(0,g.jsx)(`button`,{type:`button`,className:`att-link`,title:`跳转到任务 #${e.targetSeq??``}`,onClick:()=>i?.({key:e.targetKey,seq:e.targetSeq}),children:e.name}):e.kind===`ref`?(0,g.jsx)(`button`,{type:`button`,className:`att-link`,title:e.note||e.title||e.name||`打开文档`,onClick:()=>a?.(e.refId?`ref:`+e.refId:e.locator||e.targetRef),children:e.title||e.name}):e.kind===`url`?(0,g.jsx)(`a`,{className:`att-link`,href:e.url,target:`_blank`,rel:`noreferrer`,title:e.url,children:e.name}):(0,g.jsx)(`span`,{className:`att-item-name`,title:e.name,children:e.name}),(0,g.jsxs)(`span`,{className:`att-item-meta`,children:[e.sizeText?(0,g.jsx)(`span`,{children:e.sizeText}):null,e.kind===`mdfile`?(0,g.jsxs)(`span`,{className:`att-note`,title:e.absPath||``,children:[e.absPath||`(路径为空)`,e.missing?` · 源文件已不在`:``]}):null,e.kind===`folder`?(0,g.jsxs)(`span`,{className:`att-note`,title:e.absPath||``,children:[e.absPath||`(路径为空)`,e.missing?` · 目录已不在`:``]}):null,e.note?(0,g.jsx)(`span`,{className:`att-note`,children:e.note}):null]})]}),e.kind===`mdfile`?(0,g.jsx)(`span`,{className:`att-item-acts`,children:(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`按 md 渲染磁盘当前内容(读时核对指纹)`,onClick:()=>r?.(e),children:`预览`})}):null,e.kind===`file`||e.kind===`image`?(0,g.jsxs)(`span`,{className:`att-item-acts`,children:[(0,g.jsx)(`a`,{className:`att-act`,href:m(e.id),target:`_blank`,rel:`noreferrer`,children:`打开`}),(0,g.jsx)(`a`,{className:`att-act`,href:m(e.id),download:e.name,children:`下载`})]}):null,e.kind===`ref`?(0,g.jsxs)(`span`,{className:`att-item-acts`,children:[o?(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`改这条绑定的一行说明(交付清单会透出)`,onClick:()=>o(e),children:`✎ 说明`}):null,(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`换成另一篇文档(替换这条绑定)`,onClick:()=>s?.(e),children:`⇄ 更换`})]}):null,(0,g.jsx)(`button`,{type:`button`,className:`att-x`,"aria-label":`移除 ${e.name}`,onClick:()=>t(e),children:`×`})]},e.id)}function b({host:e=`task`,hostId:t,hostKey:n,hostCwd:a,refId:p,allow:m={file:!0,url:!0,folder:!0,task:!1,ref:!1,repo:!1},taskOptions:b=[],docOptions:x,disabled:S=!1,disabledText:C=`提交任务后可以在这里挂附件(当前是草稿)。`,openRef:w,onChanged:T,onOpenTask:E,onOpenDoc:D}){let O=i(),{dialog:te,node:ne}=r(),[k,A]=(0,h.useState)([]),[j,M]=(0,h.useState)(!1),[N,P]=(0,h.useState)(``),[re,F]=(0,h.useState)(!1),[ie,I]=(0,h.useState)(!1),[ae,L]=(0,h.useState)(!1),[R,oe]=(0,h.useState)(`position`),[z,B]=(0,h.useState)(null),[V,H]=(0,h.useState)(null),[U,W]=(0,h.useState)(!1),[G,K]=(0,h.useState)(null),[q,J]=(0,h.useState)(null),Y=(0,h.useMemo)(()=>ee(e,{hostId:t,hostKey:n,hostCwd:a,refId:p}),[e,t,n,a,p]),X=(0,h.useCallback)(async()=>{if(S){A([]);return}M(!0),P(``);try{let e=await Y.list();A((e.attachments||[]).map(c))}catch(e){P(String(e.message||e))}finally{M(!1)}},[Y,S]);(0,h.useEffect)(()=>{X()},[X]),(0,h.useImperativeHandle)(w,()=>({open:()=>F(!0),refresh:X}),[X]),(0,h.useEffect)(()=>{if(!G)return;let e=e=>{e.key===`Escape`&&K(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[G]);let Z=(0,h.useMemo)(()=>[...k].sort(v[R]||v.position),[k,R]),Q=Z.filter(e=>e.area===`inline`),$=Z.filter(e=>e.area===`area`),se=async(e,t)=>{if(S)return;let n=f(t),r=n.length?n:[...e||[]].filter(e=>e&&e.size>0);if(!r.length)return;L(!0);let i=0;for(let e of r)try{let t=await u(e),n=t.fileId||t.id;if(!n)throw Error(`上传未返回 fileId`);await Y.attach({fileId:n,name:t.name}),i+=1}catch(t){O(`「${e.name||`文件`}」添加失败:${t.message||t}`)}L(!1),i&&(O(`已挂到附件区 ${i} 个文件`),await X(),T?.())},ce=async r=>{if(r&&e!==`doc`)try{let e=await te({title:`说明 · ${r.name}`,input:!0,placeholder:`这一行里大概是什么(交付清单会透出给 agent)`,value:r.note||``,okText:`保存说明`});if(e===null)return;let i=typeof e==`string`?e:e&&e.value||``,s={id:Number(t),...n?{key:n}:a?{cwd:a}:{},attachment:r.id,note:i};await o(`/api/localtasks/attach-note`,{method:`PATCH`,body:s}),O(i?`已保存说明:${i}`:`已清空说明`),await X(),T?.()}catch(e){O(`改说明失败:${e.message||e}`)}},le=e=>{e&&(H(e),F(!0))},ue=async()=>{let e=z;if(e){W(!0);try{await Y.detach(e.id),B(null),O(`已解除关联:${e.name}`),await X(),T?.()}catch(e){O(`移除失败:${e.message||e}`)}finally{W(!1)}}},de=async e=>{if(e)try{let t=await o(`/api/docs/mdfile?attachment=${encodeURIComponent(String(e.id))}`),n=String(t.body||``);J({name:e.name||`md`,html:s(n),path:String(t.absPath||e.absPath||``),stale:!!t.stale,missing:!!t.missing})}catch(e){O(`读取失败:${e.message||e}`)}},fe=!j&&!N&&!k.length;return(0,g.jsxs)(`div`,{className:`att-area${S?` is-disabled`:``}`,onDragOver:e=>{!S&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),I(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||I(!1)},onDrop:e=>{I(!1),!S&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),se(null,e))},children:[ne,(0,g.jsxs)(`div`,{className:`att-area-head`+(ie&&!S?` is-over`:``),children:[(0,g.jsxs)(`span`,{className:`att-area-title`,children:[`附件`,k.length?(0,g.jsx)(`span`,{className:`att-count`,children:k.length}):null,ae?(0,g.jsx)(`span`,{className:`att-area-note`,children:`上传中…`}):null]}),(0,g.jsxs)(`span`,{className:`att-area-acts`,children:[k.length?(0,g.jsxs)(`select`,{className:`att-sort`,value:R,onChange:e=>oe(e.target.value),"aria-label":`附件排序`,children:[(0,g.jsx)(`option`,{value:`position`,children:`按添加顺序`}),(0,g.jsx)(`option`,{value:`name`,children:`按名称`}),(0,g.jsx)(`option`,{value:`kind`,children:`按类型`})]}):null,(0,g.jsx)(`button`,{type:`button`,className:`btn ghost att-add-btn`,disabled:S,onClick:()=>F(!0),children:`添加附件`})]})]}),S?(0,g.jsx)(`div`,{className:`att-empty`,children:C}):null,j?(0,g.jsx)(`div`,{className:`att-empty`,children:`加载附件…`}):null,N?(0,g.jsxs)(`div`,{className:`att-empty att-err-text`,children:[`附件加载失败:`,N]}):null,fe?(0,g.jsx)(`div`,{className:`att-empty`,children:`还没有附件。拖文件到这里,或点「添加附件」——只挂附件区,不写正文。`}):null,Q.length?(0,g.jsxs)(`div`,{className:`att-section`,children:[(0,g.jsxs)(`div`,{className:`att-section-head`,children:[l.inline,(0,g.jsx)(`span`,{className:`att-section-hint`,children:`正文里的引用,删正文行会跟着消失`})]}),Q.map(t=>y(t,{onRemove:B,onPreview:K,onPreviewMd:de,onOpenTask:E,onOpenDoc:D,onEditNote:e===`task`?ce:void 0,onReplace:le,key:t.id}))]}):null,$.length?(0,g.jsxs)(`div`,{className:`att-section`,children:[(0,g.jsxs)(`div`,{className:`att-section-head`,children:[l.area,(0,g.jsx)(`span`,{className:`att-section-hint`,children:`不依赖正文,删正文行也不会丢`})]}),$.map(t=>y(t,{onRemove:B,onPreview:K,onPreviewMd:de,onOpenTask:E,onOpenDoc:D,onEditNote:e===`task`?ce:void 0,onReplace:le,key:t.id}))]}):null,(0,g.jsx)(d,{open:re,host:e,hostId:t,hostKey:n,hostCwd:a,refId:p,allow:m,taskOptions:b,docOptions:x,replaceAttachment:V?V.id:null,replaceNote:V&&V.note||``,onClose:()=>{F(!1),H(null)},onDone:async()=>{H(null),await X(),T?.()}}),z?(0,g.jsx)(_,{title:`移除附件`,size:`sm`,busy:U,onClose:U?void 0:()=>B(null),footer:(0,g.jsxs)(`div`,{className:`att-foot`,children:[(0,g.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:U,onClick:()=>B(null),children:`取消`}),(0,g.jsx)(`button`,{type:`button`,className:`btn`,disabled:U,onClick:()=>void ue(),children:`移除(解除关联)`})]}),children:(0,g.jsxs)(`div`,{className:`att-confirm`,children:[(0,g.jsx)(`div`,{className:`att-confirm-name`,children:z.name}),(0,g.jsxs)(`div`,{className:`att-confirm-text`,children:[`会从这份`,e===`task`?`任务`:`文档`,`的附件清单里移除,资源本身(行与字节)保留在孤儿池, 之后仍可重新挂载;需要清理时由库级 GC 统一回收。`]})]})}):null,q?(0,g.jsx)(_,{title:(0,g.jsxs)(`span`,{children:[q.name,(0,g.jsx)(`span`,{className:`att-md-path`,children:q.path})]}),size:`lg`,onClose:()=>J(null),footer:(0,g.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:()=>J(null),children:`关闭`}),children:q.missing?(0,g.jsxs)(`div`,{className:`att-empty`,children:[`源文件已不在:`,q.path||`(路径为空)`]}):(0,g.jsxs)(`div`,{className:`att-md-preview`,children:[q.stale?(0,g.jsx)(`div`,{className:`att-md-warn`,children:`内容已变化(与登记指纹不一致),以下为磁盘当前内容。`}):null,(0,g.jsx)(`article`,{dangerouslySetInnerHTML:{__html:q.html}})]})}):null,G?(0,g.jsx)(`div`,{className:`att-lightbox`,role:`dialog`,"aria-label":`图片预览`,onMouseDown:e=>{e.target===e.currentTarget&&K(null)},children:(0,g.jsxs)(`div`,{className:`att-lightbox-card`,children:[(0,g.jsxs)(`div`,{className:`att-lightbox-head`,children:[(0,g.jsx)(`span`,{className:`att-lightbox-name`,children:G.name}),(0,g.jsx)(`a`,{className:`att-lightbox-open`,href:G.src,target:`_blank`,rel:`noreferrer`,children:`新窗口打开`}),(0,g.jsx)(`button`,{type:`button`,className:`pp-x`,"aria-label":`关闭`,onClick:()=>K(null),children:`×`})]}),(0,g.jsx)(`img`,{className:`att-lightbox-img`,src:G.src,alt:G.name})]})}):null]})}function x(e=`task`,t=!0){let n=(0,h.useCallback)(t=>`nxkv.${e}Dock${t}`,[e]),[r,i]=(0,h.useState)(()=>{let e=localStorage.getItem(n(`Open`));return e===null?t:e!==`0`}),[a,o]=(0,h.useState)(()=>localStorage.getItem(n(`Tab`))||`attach`),[s,c]=(0,h.useState)(()=>{let e=Number(localStorage.getItem(n(`H`)));return Number.isFinite(e)&&e>=96?e:176}),l=(0,h.useRef)(s);l.current=s;let u=(0,h.useRef)(null),[d,f]=(0,h.useState)(!1),p=(0,h.useRef)(176);return(0,h.useEffect)(()=>{localStorage.setItem(n(`Open`),r?`1`:`0`)},[r,n]),(0,h.useEffect)(()=>{localStorage.setItem(n(`Tab`),a)},[a,n]),{dockOpen:r,setDockOpen:i,dockTab:a,setDockTab:o,dockH:s,dockHRef:l,dockRef:u,dockMax:d,setDockMax:f,dockPrevHRef:p,showDockTab:(0,h.useCallback)(e=>{o(e),i(!0)},[]),onDockDragStart:(0,h.useCallback)(e=>{if(!r)return;e.preventDefault(),f(!1);let t=e.clientY,i=l.current,a=u.current?.parentElement?.clientHeight||window.innerHeight,o=e=>Math.max(96,Math.min(Math.round(a*.62),Math.round(e))),s=e=>{let n=o(i-(e.clientY-t));l.current=n,c(n)},d=()=>{window.removeEventListener(`mousemove`,s),window.removeEventListener(`mouseup`,d),document.body.style.userSelect=``,document.body.style.cursor=``,localStorage.setItem(n(`H`),String(l.current))};document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`,window.addEventListener(`mousemove`,s),window.addEventListener(`mouseup`,d)},[r,n]),toggleDockMax:(0,h.useCallback)(()=>{if(d){c(p.current),f(!1);return}p.current=l.current;let e=u.current?.parentElement?.clientHeight||window.innerHeight,t=Math.max(96,Math.round(e*.62));l.current=t,c(t),f(!0)},[d])}}var S=`nx-kv-ack-rail-pos`,C=`nx-kv-doc-rail-pos`;function w(e={}){let{x:t,y:n,parentW:r,parentH:i,railW:a=0,railH:o=0,margin:s=8}=e||{};if(![t,n,r,i].every(e=>Number.isFinite(e)))return null;let c=Number(t),l=Number(n),u=Number(r),d=Number(i),f=Math.max(s,u-a-s),p=Math.max(s,d-o-s);return{x:Math.min(f,Math.max(s,c)),y:Math.min(p,Math.max(s,l))}}function T(e=S){try{let t=JSON.parse(localStorage.getItem(e)||`null`);if(!t||typeof t!=`object`)return null;let n=Number(t.x),r=Number(t.y);return!Number.isFinite(n)||!Number.isFinite(r)?null:{x:n,y:r}}catch{return null}}function E(e,t=S){try{e?localStorage.setItem(t,JSON.stringify({x:Math.round(e.x),y:Math.round(e.y)})):localStorage.removeItem(t)}catch{}}var D=4;function O(e){let[t,n]=(0,h.useState)(()=>T(e)),[r,i]=(0,h.useState)(!1),a=(0,h.useRef)(null),o=(0,h.useRef)(null),s=(0,h.useRef)(!1);(0,h.useEffect)(()=>{let e=a.current,t=e&&e.parentElement;if(!e||!t)return;let r=()=>{n(n=>{if(!n)return n;let r=t.getBoundingClientRect(),i=e.getBoundingClientRect(),a=w({x:n.x,y:n.y,parentW:r.width,parentH:r.height,railW:i.width,railH:i.height});return a&&(a.x!==n.x||a.y!==n.y)?a:n})};return r(),window.addEventListener(`resize`,r,{passive:!0}),()=>window.removeEventListener(`resize`,r)},[]);let c=(0,h.useCallback)(e=>{if(e.pointerType===`mouse`&&e.button!==0)return;let t=a.current,n=t&&t.parentElement;if(!t||!n)return;let r=t.style.bottom;t.style.bottom=`auto`;let i=t.getBoundingClientRect();t.style.bottom=r||``;let s=n.getBoundingClientRect();o.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startLeft:i.left-s.left,startTop:i.top-s.top,parentW:s.width,parentH:s.height,railW:i.width,railH:i.height,moved:!1};try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}},[]),l=(0,h.useCallback)(e=>{let t=o.current;if(!t||e.pointerId!==t.pointerId)return;let r=e.clientX-t.startX,a=e.clientY-t.startY;if(!t.moved){if(Math.hypot(r,a)<D)return;t.moved=!0,s.current=!0,i(!0),document.body.style.userSelect=`none`}let c=w({x:t.startLeft+r,y:t.startTop+a,parentW:t.parentW,parentH:t.parentH,railW:t.railW,railH:t.railH});c&&(t.last=c,n(c))},[]),u=(0,h.useCallback)(t=>{let n=o.current;n&&t.pointerId===n.pointerId&&(o.current=null,n.moved&&(i(!1),document.body.style.userSelect=``,E(n.last,e)))},[e]),d=(0,h.useCallback)(()=>{n(null),E(null,e)},[e]);return{railRef:a,pos:t,dragging:r,draggedRef:s,resetPos:d,handleProps:{onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:u,onDoubleClick:d}}}export{b as i,C as n,x as r,O as t};
|
|
@@ -12,19 +12,18 @@
|
|
|
12
12
|
<!-- .ico 兜底:浏览器不认上面的 <link> 时会自己请求 /favicon.ico -->
|
|
13
13
|
<link rel="icon" type="image/x-icon" href="/favicon.ico">
|
|
14
14
|
<link rel="apple-touch-icon" sizes="512x512" href="/logo-rounded.png">
|
|
15
|
-
<script type="module" crossorigin src="/assets/index-
|
|
15
|
+
<script type="module" crossorigin src="/assets/index-cyRcywoY.js"></script>
|
|
16
16
|
<link rel="modulepreload" crossorigin href="/assets/popup-dBtYqEM1.js">
|
|
17
|
-
<link rel="modulepreload" crossorigin href="/assets/tool-bar-
|
|
17
|
+
<link rel="modulepreload" crossorigin href="/assets/tool-bar-DpfJRjFG.js">
|
|
18
18
|
<link rel="modulepreload" crossorigin href="/assets/button-Cs6w2CDi.js">
|
|
19
19
|
<link rel="modulepreload" crossorigin href="/assets/app-context-CngKv8Tc.js">
|
|
20
20
|
<link rel="modulepreload" crossorigin href="/assets/task-status-Cjsm0xF7.js">
|
|
21
|
-
<link rel="modulepreload" crossorigin href="/assets/md-history-
|
|
22
|
-
<link rel="modulepreload" crossorigin href="/assets/use-rail-drag-
|
|
23
|
-
<link rel="modulepreload" crossorigin href="/assets/list-search-DFvFY408.js">
|
|
21
|
+
<link rel="modulepreload" crossorigin href="/assets/md-history-sxG54jJ_.js">
|
|
22
|
+
<link rel="modulepreload" crossorigin href="/assets/use-rail-drag-DcUzHeV_.js">
|
|
24
23
|
<link rel="modulepreload" crossorigin href="/assets/board-view-C8OQhkyi.js">
|
|
25
|
-
<link rel="modulepreload" crossorigin href="/assets/route-crumb-
|
|
26
|
-
<link rel="modulepreload" crossorigin href="/assets/doc-
|
|
27
|
-
<link rel="modulepreload" crossorigin href="/assets/repo-form-modal-
|
|
24
|
+
<link rel="modulepreload" crossorigin href="/assets/route-crumb-CqDySF_k.js">
|
|
25
|
+
<link rel="modulepreload" crossorigin href="/assets/doc-CKbuO1Gj.js">
|
|
26
|
+
<link rel="modulepreload" crossorigin href="/assets/repo-form-modal-geOSTx9x.js">
|
|
28
27
|
<link rel="stylesheet" crossorigin href="/assets/popup-BAvk7J7u.css">
|
|
29
28
|
<link rel="stylesheet" crossorigin href="/assets/tool-bar-CLIs9Dr0.css">
|
|
30
29
|
<link rel="stylesheet" crossorigin href="/assets/button-DA4lNJeC.css">
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{a as e,d as t,f as n,h as r,i,l as a,m as o,u as s}from"./popup-dBtYqEM1.js";import{D as c,N as l,a as u,c as d,f,i as p,l as m,o as h,r as g,s as _,t as v}from"./tool-bar-DPXnjdQF.js";import{n as y}from"./app-context-CngKv8Tc.js";import{d as b,p as x,u as ee}from"./task-status-Cjsm0xF7.js";import{C as S,a as C,b as w,h as T,i as te,m as E,n as D,r as O,t as k,u as A}from"./md-history-COQu16vy.js";import{i as j,n as M,r as ne,t as N}from"./use-rail-drag-B6J0iqFK.js";import{t as P}from"./list-search-DFvFY408.js";import{t as re}from"./route-crumb-BKq2jry0.js";function ie(){return s(`/api/docs/index`)}function ae(){return s(`/api/boards`)}function F(){return s(`/api/repos`)}function oe(){return s(`/api/docs/index`)}function se(e){return s(`/api/docs/attachments?ref=${encodeURIComponent(e)}`)}function ce(e){return s(`/api/docs/item?ref=`+encodeURIComponent(e))}function I(e){return s(`/api/repos/docs`,{method:`POST`,body:e})}function le(e){return s(`/api/docs/unbind`,{method:`POST`,body:e})}function ue(e){return s(`/api/docs/link`,{method:`POST`,body:e})}function L(e){return s(`/api/docs/bindings?ref=`+encodeURIComponent(e))}function de(e){let t=new URLSearchParams;return e.host&&t.set(`host`,e.host),e.group&&t.set(`group`,e.group),s(`/api/docs/bindings?`+t.toString())}function fe(e){return s(`/api/docs/ref`,{method:`POST`,body:e})}function pe(e){return s(`/api/docs/unbind`,{method:`POST`,body:e})}function R(e,t){return s(`/api/docs/item`,{method:`PATCH`,body:{ref:e,desc:t}})}function me(e){return s(`/api/docs/main`,{method:`POST`,body:e})}function z(e){return s(`/api/docs/item`,{method:`PATCH`,body:e})}function he(e){return s(`/api/docs/item`,{method:`DELETE`,body:e})}var B=`nx-kv:docs-changed`;function V(){typeof window>`u`||window.dispatchEvent(new CustomEvent(B))}function ge(e){if(typeof window>`u`)return()=>{};let t=()=>e();return window.addEventListener(B,t),()=>window.removeEventListener(B,t)}async function _e({owner:e,repo:t,group:n,desc:r=``,title:i=``}){let a=await fe({owner:e,repo:t,group:n,desc:r});return i&&await z({ref:`ref:`+a.refId,body:`# ${i}\n\n(待补)\n`}),V(),a.refId}async function ve(e,t){let n=await R(e,String(t||``).trim());return V(),String(n?.desc??t??``)}async function ye(e){await pe({ref:e.refId,type:e.type,repo:e.repoKey,group:e.groupKey||void 0}),V()}async function be(e){if(e.type===`group_repo`)throw Error(`组内仓库描述没有主篇概念`);await me(e.type===`group`?{ref:e.refId,board:e.repoKey}:{ref:e.refId,repo:e.repoKey}),V()}var H=t();function xe({refId:e,writable:t,onChanged:n,onOpenDoc:r}){return(0,H.jsx)(j,{host:`doc`,refId:e,allow:{file:!0,url:!0,folder:!0,task:!1,ref:!0,repo:!1},disabled:!t,disabledText:`只读文档不能添加附件。`,onChanged:n,onOpenDoc:r})}function Se({dock:t,attCount:n=0,bindCount:r=0,attachNode:i,bindNode:a}){let{dockOpen:o,dockTab:s,dockH:c,dockRef:l,dockMax:u,showDockTab:d,onDockDragStart:f,toggleDockMax:p,setDockOpen:m}=t;if(!o)return null;let h=s===`bind`?`bind`:`attach`;return(0,H.jsxs)(`div`,{className:`mdw-dock docp-dock`,ref:l,style:{height:`${c}px`},children:[(0,H.jsx)(`div`,{className:`mdw-dock-drag`,role:`separator`,"aria-orientation":`horizontal`,title:`上下拖动调整信息面板高度(双击最大化 / 还原)`,onMouseDown:f,onDoubleClick:p}),(0,H.jsxs)(`div`,{className:`mdw-dock-head`,children:[(0,H.jsxs)(`div`,{className:`mdw-dock-tabs`,role:`tablist`,"aria-label":`信息面板`,children:[(0,H.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":h===`attach`,className:`mdw-dock-tab${h===`attach`?` is-on`:``}`,onClick:()=>d(`attach`),children:[`附件`,n?(0,H.jsx)(`span`,{className:`mdw-dock-tab-num`,children:n}):null]}),(0,H.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":h===`bind`,className:`mdw-dock-tab${h===`bind`?` is-on`:``}`,onClick:()=>d(`bind`),children:[`归属`,r?(0,H.jsx)(`span`,{className:`mdw-dock-tab-num`,children:r}):null]})]}),(0,H.jsxs)(`div`,{className:`mdw-dock-acts`,children:[(0,H.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:p,title:u?`还原面板高度`:`最大化面板高度`,"aria-label":u?`还原面板高度`:`最大化面板高度`,children:(0,H.jsx)(e,{name:u?`collapse`:`expand`,title:void 0})}),(0,H.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:()=>m(!1),title:`关闭面板(底部状态栏仍保留入口)`,"aria-label":`关闭面板`,children:(0,H.jsx)(e,{name:`x`,title:void 0})})]})]}),(0,H.jsxs)(`div`,{className:`mdw-dock-body`,children:[(0,H.jsx)(`div`,{className:`docp-dock-pane`,hidden:h!==`attach`,children:i}),(0,H.jsx)(`div`,{className:`docp-dock-pane`,hidden:h!==`bind`,children:a})]})]})}function Ce({dock:t,attCount:n=0,bindCount:r=0}){let{dockOpen:i,dockTab:a,showDockTab:o,setDockOpen:s}=t;return(0,H.jsxs)(`div`,{className:`mdw-sbar`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${i&&a===`attach`?` is-on`:``}`,onClick:()=>o(`attach`),title:`附件(点击展开信息面板)`,children:[(0,H.jsx)(e,{name:`list`,title:void 0}),(0,H.jsx)(`span`,{className:`mdw-sbar-lab`,children:`附件`}),n?(0,H.jsx)(`span`,{className:`mdw-sbar-num`,children:n}):null]}),(0,H.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${i&&a===`bind`?` is-on`:``}`,onClick:()=>o(`bind`),title:`归属:这篇文档被哪些仓库 / 项目组引用(点击展开信息面板)`,children:[(0,H.jsx)(e,{name:`repo`,title:void 0}),(0,H.jsx)(`span`,{className:`mdw-sbar-lab`,children:`归属`}),r?(0,H.jsx)(`span`,{className:`mdw-sbar-num`,children:r}):null]}),(0,H.jsx)(`span`,{className:`mdw-sbar-grow`}),(0,H.jsx)(`span`,{className:`docp-sbar-hint`,children:`双链 [[]] 点击跳转 · Ctrl+S 保存 · 正文存库(v6 起不落盘)`}),(0,H.jsx)(`button`,{type:`button`,className:`mdw-sbar-chev${i?` is-open`:``}`,onClick:()=>s(e=>!e),title:i?`收起信息面板`:`展开信息面板`,"aria-expanded":i,"aria-label":i?`收起信息面板`:`展开信息面板`,children:(0,H.jsx)(e,{name:`chevron`,title:void 0})})]})}var U=r(n(),1);function we({t:e}){let t=e.main?`主篇`:`附加`;return(0,H.jsxs)(`span`,{className:`nb-tag nb-`+e.kind+(e.main?` nb-main`:``),"data-btag":e.id,title:e.title||e.label,children:[(0,H.jsx)(`span`,{className:`k`,children:(0,H.jsx)(`span`,{className:`dot`})}),(0,H.jsx)(`span`,{className:`role`+(e.main?` main`:``),children:t}),(0,H.jsx)(`span`,{className:`name`,children:e.label}),e.onRemove?(0,H.jsx)(`button`,{type:`button`,className:`x`,title:`解绑(文档本身不删除)`,onClick:t=>{t.stopPropagation(),e.onRemove?.()},children:`✕`}):null]})}function W({items:e,addLabel:t,onAdd:n,onMore:r,empty:i}){let a=(0,U.useRef)(null),[o,s]=(0,U.useState)(!1),[c,l]=(0,U.useState)(0),u=(0,U.useCallback)(()=>{let e=a.current;if(!e||!e.clientWidth)return;let t=Array.from(e.querySelectorAll(`:scope > [data-btag]`));if(o){t.forEach(e=>{e.style.display=``}),l(0);return}t.forEach(e=>{e.style.display=``});let n=e.querySelector(`:scope > [data-badd]`),r=e.querySelector(`:scope > [data-bmore]`),i=(n?.offsetWidth||0)+(r?.offsetWidth||0)+6,s=e.clientWidth-(i>6?i:0)-2,c=e.getBoundingClientRect().left,u=0;for(let e of t)e.getBoundingClientRect().right-c>s&&(e.style.display=`none`,u+=1);l(u)},[o]);(0,U.useLayoutEffect)(()=>{u()},[e,u]),(0,U.useEffect)(()=>{let e=a.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>u());return t.observe(e),()=>t.disconnect()},[u]);let d=c>0||o;return(0,H.jsxs)(`div`,{className:`nb-tags`+(o?` open`:``),ref:a,children:[e.map(e=>(0,H.jsx)(we,{t:e},e.id)),!e.length&&i?(0,H.jsx)(`span`,{className:`nb-empty`,children:i}):null,d&&!r?(0,H.jsx)(`button`,{type:`button`,className:`nb-tag more`,"data-bmore":!0,title:o?`收起`:`展开全部`,onClick:()=>s(e=>!e),children:o?`收起`:`+${c}`}):null,d&&r?(0,H.jsxs)(`button`,{type:`button`,className:`nb-tag more`,"data-bmore":!0,title:`查看全部`,onClick:r,children:[`+`,c||0]}):null,n?(0,H.jsxs)(`button`,{type:`button`,className:`nb-tag add`,"data-badd":!0,onClick:n,children:[(0,H.jsx)(`b`,{children:`+`}),t||`加绑`]}):null]})}function G(e){let t=String(e||``);return t.startsWith(`ref:`)?t.slice(4):/^ref_[0-9a-f]{16}$/i.test(t)?t:``}function Te(e,t,n=``){let r=a(),[i,o]=(0,U.useState)([]),[s,c]=(0,U.useState)(0),[l,u]=(0,U.useState)([]),[d,f]=(0,U.useState)([]),[p,m]=(0,U.useState)(!1),[h,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)(`repo`),[y,b]=(0,U.useState)(``),[x,ee]=(0,U.useState)(``),[S,C]=(0,U.useState)(``),w=(0,U.useCallback)(()=>c(e=>e+1),[]);(0,U.useEffect)(()=>{let e=!0;return F().then(t=>{if(!e)return;let n=(Array.isArray(t)?t:t?.repos||[]).filter(e=>e&&e.key&&(e.type||`dev`)!==`group`).map(e=>({key:String(e.key),name:String(e.name||e.key),kind:`repo`}));u(n)}).catch(()=>{}),ae().then(t=>{if(!e)return;let n=(Array.isArray(t)?t:t?.boards||[]).filter(e=>e&&(e.key||e.id)).map(e=>({key:String(e.key||`board/`+(e.name||e.id)),name:String(e.name||e.key),kind:`group`}));f(n)}).catch(()=>{}),()=>{e=!1}},[]),(0,U.useEffect)(()=>{if(!e){o([]);return}let t=!0;return L(e).then(e=>{t&&o(Array.isArray(e?.bindings)?e.bindings:[])}).catch(()=>{t&&o([])}),()=>{t=!1}},[e,s]);let T=(0,U.useCallback)(e=>{let t=l.find(t=>t.key===e)||d.find(t=>t.key===e);return t?t.name:e},[l,d]);async function te(e){if(!p&&window.confirm(`解绑:${e.repoKey} 不再引用这篇文档?\n(文档本身不删除,只摘掉这条归属)`)){m(!0);try{await le({ref:e.refId,type:e.type,repo:e.repoKey,group:e.groupKey||void 0}),r(`已解绑`),w()}catch(e){r(`解绑失败:`+(e?.message||`未知错误`))}finally{m(!1)}}}function E(){v(`repo`),b(``),C(``),g(!0)}async function D(){if(!y){r(`先选一个宿主`);return}let t=G(e||``);if(!t){r(`这篇文档还没有 refId(外部目录不能加绑)`);return}m(!0);try{_===`repo`?await I({id:y,ref:t}):await ue({board:y,ref:t}),g(!1),r(_===`repo`?`已加绑到仓库文档集`:`已加绑到组附加文档`),w()}catch(e){r(`加绑失败:`+(e?.message||`未知错误`))}finally{m(!1)}}let O=(0,U.useMemo)(()=>i.map(e=>{let n=e.type===`group_repo`?e.groupKey:null;return{id:`${e.refId}:${e.repoKey}:${e.groupKey||``}:${e.position}`,label:n?`${T(e.repoKey)} · 组 ${T(n)}`:T(e.repoKey),kind:e.type===`group`?`group`:`repo`,main:e.main,title:`${e.repoKey}${n?` @ `+n:``}\n${e.desc||e.refId}`,onRemove:t?()=>te(e):void 0}}),[i,t,T]),k=(0,U.useMemo)(()=>A(O,x,e=>[e.label,e.title]),[O,x]),j=_===`repo`?l:d,M=(0,U.useMemo)(()=>new Set(i.filter(e=>e.type!==`group_repo`).map(e=>e.repoKey)),[i]),ne=(0,U.useMemo)(()=>j.filter(e=>!M.has(e.key)),[j,M]),N=(0,U.useMemo)(()=>A(ne,S,e=>[e.name,e.key]),[ne,S]),re=e?(0,H.jsxs)(`div`,{className:`docp-bind-panel`,title:`这篇文档被谁引用 —— tag 上的 ✕ 解绑(不删文档)`,children:[i.length>1?(0,H.jsx)(P,{value:x,onChange:ee,placeholder:`搜索归属…`,title:`过滤归属`,count:k.length,className:`wide`}):null,(0,H.jsx)(W,{items:k,addLabel:`加绑宿主`,onAdd:t&&G(e||``)?E:void 0,empty:`没有任何归属(孤儿文档)—— 不会被任何仓库 / 组面板列出`}),!i.length&&t?(0,H.jsx)(`div`,{className:`docp-bind-orphan`,children:`孤儿状态:给这篇文档加绑一个仓库或项目组,它才会出现在对应面板的文档集里。`}):null]}):null,ie=h?(0,H.jsx)(`div`,{className:`nb-overlay`,onClick:e=>{e.target===e.currentTarget&&g(!1)},children:(0,H.jsxs)(`div`,{className:`nb-modal`,children:[(0,H.jsxs)(`div`,{className:`nb-modal-head`,children:[(0,H.jsx)(`span`,{className:`t`,children:`加绑宿主`}),(0,H.jsx)(`span`,{className:`sub`,children:n||`当前文档`}),(0,H.jsx)(`button`,{type:`button`,className:`close`,onClick:()=>g(!1),children:`✕`})]}),(0,H.jsxs)(`div`,{className:`nb-modal-body`,children:[(0,H.jsxs)(`div`,{className:`nb-frow`,children:[(0,H.jsx)(`label`,{children:`宿主类型`}),(0,H.jsxs)(`div`,{className:`nb-seg`,children:[(0,H.jsx)(`button`,{type:`button`,className:_===`repo`?`on`:``,onClick:()=>{v(`repo`),b(``),C(``)},children:`仓库`}),(0,H.jsx)(`button`,{type:`button`,className:_===`group`?`on`:``,onClick:()=>{v(`group`),b(``),C(``)},children:`项目组`})]})]}),(0,H.jsxs)(`div`,{className:`nb-frow`,children:[(0,H.jsx)(`label`,{children:_===`repo`?`选择仓库`:`选择项目组`}),j.length>1?(0,H.jsx)(P,{value:S,onChange:C,placeholder:_===`repo`?`搜索仓库…`:`搜索项目组…`,title:`过滤可加绑的宿主`,count:N.length,className:`wide`}):null,(0,H.jsx)(`div`,{className:`nb-list`,children:N.length?N.map(e=>(0,H.jsxs)(`label`,{style:{fontWeight:400},children:[(0,H.jsx)(`input`,{type:`radio`,name:`nb-host`,checked:y===e.key,onChange:()=>b(e.key)}),(0,H.jsx)(`span`,{children:e.name}),(0,H.jsx)(`span`,{className:`p`,children:e.key})]},e.key)):(0,H.jsxs)(`label`,{children:[`(没有可加绑的`,_===`repo`?`仓库`:`项目组`,`)`]})})]})]}),(0,H.jsxs)(`div`,{className:`nb-modal-foot`,children:[(0,H.jsx)(`span`,{className:`note`,children:_===`repo`?`落点:repo.doc.add`:`落点:docs.link`}),(0,H.jsx)(`button`,{type:`button`,className:`nb-btn`,onClick:()=>g(!1),children:`取消`}),(0,H.jsx)(`button`,{type:`button`,className:`nb-btn primary`,disabled:p,onClick:D,children:`加绑`})]})]})}):null;return{count:i.length,strip:re,modal:ie}}var Ee=l(),K=`doc`,q=[{id:`edit`,label:`编辑`},{id:`doc`,label:`文档`},{id:`view`,label:`查看`}];function De({crumb:t=null,title:n,pathLabel:r=``,dirty:i=!1,writable:a=!1,onSave:o=null,onSaveLabel:s=`保存`,menuGroups:c=[],saving:l=!1,external:f=!1,afterTitle:y=null}){let b=p(),{layout:x,setLayout:ee}=h(K),[S,C]=(0,U.useState)(!1),w={};for(let e of c||[])for(let t of e?.items||[])t&&t.id&&(w[t.id]=t);w.save=o&&{id:`save`,label:l?`保存中…`:s,run:o,primary:!0,disabled:l||!i};let T=e=>e===`more`||!!w[e],te=x.filter(e=>m(K,e)&&T(e.id)),E=x.filter(e=>_(K,e)&&T(e.id)),D=e=>{let t=w[e];t&&t.run?.(),b.setOpen(!1)},O=t=>{if(t===`more`)return(0,H.jsx)(`div`,{className:`docp-more`,ref:b.ref,children:(0,H.jsxs)(`button`,{type:`button`,className:`btn ghost sm${b.open?` on`:``}`,title:`更多操作`,"aria-haspopup":`menu`,"aria-expanded":b.open,onClick:e=>g(b,e,`right`),children:[(0,H.jsx)(e,{name:`dots`}),`更多`]})},`more`);let n=w[t];if(!n)return null;let r=d(K,t);return(0,H.jsxs)(`button`,{type:`button`,className:n.primary||t===`save`?`btn sm primary docp-save`:`btn ghost sm`,disabled:!!n.disabled,onClick:()=>D(t),children:[r.icon?(0,H.jsx)(e,{name:r.icon}):null,n.label||d(K,t).label||t]},t)},k=q.map(e=>({...e,items:E.filter(t=>d(K,t.id).menuGroup===e.id)})).filter(e=>e.items.length),A=E.filter(e=>!d(K,e.id).menuGroup),j=(0,H.jsxs)(`div`,{className:`mdw-top`,children:[t,(0,H.jsxs)(`div`,{className:`mdw-head`,children:[(0,H.jsx)(`div`,{className:`mdw-title`,children:n||`文档`}),(0,H.jsxs)(`div`,{className:`mdw-path`,children:[r,i?` · 未保存`:``,f?` · 外部`:``]})]})]});return a?(0,H.jsxs)(H.Fragment,{children:[j,(0,H.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,H.jsx)(`div`,{className:`mdw-toolbar-left`,children:y}),(0,H.jsxs)(`div`,{className:`mdw-actions`,children:[te.map(e=>O(e.id)),(0,H.jsxs)(v,{menu:b,className:`mdw-act-menu`,children:[k.map(t=>(0,H.jsxs)(`div`,{className:`mdw-fmt-menu-group`,role:`group`,"aria-label":t.label,children:[(0,H.jsx)(`div`,{className:`mdw-fmt-menu-cap`,children:t.label}),t.items.map(t=>{let n=w[t.id],r=d(K,t.id),i=n?.danger||r.danger;return(0,H.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(i?` danger`:``),onClick:()=>D(t.id),children:[r.icon?(0,H.jsx)(e,{name:r.icon}):null,n?.label||r.label||t.id,n?.hint?(0,H.jsx)(`span`,{className:`hint`,children:n.hint}):null]},t.id)})]},t.id)),A.map(t=>{let n=w[t.id],r=d(K,t.id);return(0,H.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(n?.danger||r.danger?` danger`:``),onClick:()=>D(t.id),children:[r.icon?(0,H.jsx)(e,{name:r.icon}):null,n?.label||r.label||t.id]},t.id)}),(0,H.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),(0,H.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{b.setOpen(!1),C(!0)},children:[(0,H.jsx)(e,{name:`gear`}),`自定义工具栏…`]})]})]})]}),S&&(0,Ee.createPortal)((0,H.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>C(!1),children:(0,H.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,H.jsx)(u,{kind:K,layout:x,setLayout:ee,onClose:()=>C(!1)})})}),document.body)]}):(0,H.jsxs)(H.Fragment,{children:[j,(0,H.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,H.jsx)(`div`,{className:`mdw-toolbar-left`,children:y}),(0,H.jsx)(`div`,{className:`mdw-actions`,children:(0,H.jsx)(`span`,{className:`docp-tag ext`,children:`只读`})})]})]})}function Oe(e,t,n){return{id:e,label:t,items:n.filter(Boolean)}}function J(e,t){return e?e.doc&&e.doc.ref?`ref:`+e.doc.ref:e.docId?e.docId:``:``}function Y(e){return e?e.docId?e.docId:e.refId?`ref:`+e.refId:``:``}function ke(e,t){return e?String(e.title||e.desc||t):t}function Ae({kind:e,owner:t,model:n}){let{openByDocId:r}=Q(n),i=e===`board`?`组介绍`:`项目介绍`,a=e===`board`&&t?.id||t?.key||``,o=t?.name,c=(0,U.useMemo)(()=>J(t,e),[t,e]),[l,u]=(0,U.useState)([]),[d,f]=(0,U.useState)(``),[p,m]=(0,U.useState)(0),h=(0,U.useCallback)(()=>m(e=>e+1),[]);(0,U.useEffect)(()=>{let t=!0;if(!a){u([]),f(``);return}let n=(e,t)=>{let n=[],r=Y(e);f(r||c),r&&e&&n.push({docId:r,label:ke(e,`主篇`),main:!0});for(let e of t){let t=Y(e);t&&n.push({docId:t,label:ke(e,`补充`),main:!1})}u(n)};return e===`repo`?s(`/api/repos/docs?id=`+encodeURIComponent(a)).then(e=>{t&&n(e?.main||null,e?.links||[])}).catch(()=>{t&&(u([]),f(c))}):s(`/api/boards/`+encodeURIComponent(String(a))).then(e=>{t&&n(e?.introMain||null,e?.introExtras||[])}).catch(()=>{t&&(u([]),f(c))}),()=>{t=!1}},[e,a,c,p]);let g=(0,U.useMemo)(()=>e===`repo`&&a?{repoKey:a}:e===`board`&&a?{boardKey:a,boardName:o||``}:{},[e,a,o]);return{kind:e,label:i,ownerKey:a,docRef:c,mainDocId:d,links:l,openMain:(0,U.useCallback)(()=>{let e=d||c;e&&r(e,null,g)},[d,c,r,g]),openDoc:(0,U.useCallback)(e=>r(e,null,g),[r,g]),createMain:(0,U.useCallback)(async()=>{if(!a)return;let t=`ref:`+await _e({owner:e===`board`?`group`:`repo`,...e===`board`?{group:a}:{repo:a},title:o||i});f(t),u([{docId:t,label:o||i,main:!0}]),r(t,null,g)},[e,a,o,i,r,g]),reload:h,canEdit:!!d||!!c}}function je(e){return e<=1?18:e===2?12:8}function Me({headings:e=[],scrollRoot:t=null,links:n=[],activeDocId:r=``,onOpenDoc:i=null,onAddRef:a=null}){let[o,s]=(0,U.useState)(!1),[c,l]=(0,U.useState)(``),{railRef:u,pos:d,dragging:f,draggedRef:p,handleProps:m}=N(M),h=(0,U.useMemo)(()=>e||[],[e]),g=(0,U.useMemo)(()=>n||[],[n]);(0,U.useEffect)(()=>{let e=t;if(!e||!h.length)return;let n=()=>h.map(t=>{let n=e.querySelector(`#${CSS.escape(t.id)}`);if(!n)return null;let r=n.getBoundingClientRect(),i=e.getBoundingClientRect();return{id:t.id,y:r.top-i.top}}).filter(e=>!!e),r=()=>{let e=n();if(!e.length)return;let t=e[0].id;for(let n of e)n.y<=28&&(t=n.id);l(t)};return r(),e.addEventListener(`scroll`,r,{passive:!0}),()=>e.removeEventListener(`scroll`,r)},[t,h]);let _=(0,U.useCallback)(e=>{let n=t;if(!n)return;let r=n.querySelector(`#${CSS.escape(e)}`);if(!r){n.scrollTo({top:0,behavior:`smooth`}),l(e);return}r.scrollIntoView({behavior:`smooth`,block:`start`}),l(e)},[t]);return!h.length&&!g.length&&!a?null:(0,H.jsxs)(`aside`,{ref:u,className:`doc-rail`+(o?` open`:``)+(f?` dragging`:``),style:d?{left:d.x,top:d.y,right:`auto`,bottom:`auto`}:void 0,"aria-label":`文档目录`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`doc-rail-menu`,title:o?`收起目录(按住拖动 · 双击回默认位)`:`展开目录 · 按住拖动 · 双击回默认位`,"aria-expanded":o,onClick:()=>{if(p.current){p.current=!1;return}s(e=>!e)},...m,children:[(0,H.jsx)(`span`,{}),(0,H.jsx)(`span`,{}),(0,H.jsx)(`span`,{})]}),(0,H.jsx)(`div`,{className:`doc-rail-ticks`,role:`navigation`,"aria-label":`章节`,children:h.map(e=>(0,H.jsx)(`button`,{type:`button`,className:`doc-rail-tick`+(c===e.id?` on`:``),style:{"--tw":`${je(e.level)}px`},title:e.text,"aria-current":c===e.id?`true`:void 0,onClick:()=>_(e.id)},e.id))}),o&&(0,H.jsxs)(`div`,{className:`doc-rail-panel`,children:[h.length>0&&(0,H.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,H.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`本章`}),h.map(e=>(0,H.jsx)(`button`,{type:`button`,className:`doc-rail-row`+(c===e.id?` on`:``),"data-lv":e.level,onClick:()=>_(e.id),children:e.text},e.id))]}),(g.length>0||a)&&(0,H.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,H.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`介绍文档`}),g.map(e=>(0,H.jsxs)(`button`,{type:`button`,className:`doc-rail-row`+(e.docId===r?` on`:``),title:e.label,disabled:!i,onClick:()=>i&&i(e.docId),children:[e.main?`● `:`○ `,e.label]},e.docId)),a&&(0,H.jsx)(`button`,{type:`button`,className:`doc-rail-add`,onClick:a,children:`+ 补充文档`})]})]})]})}function Ne({kind:e,owner:t,model:n}){let r=y(),i=a(),{label:o,docRef:s,mainDocId:c,links:l,openMain:u,createMain:d}=Ae({kind:e,owner:t,model:n}),[p,m]=(0,U.useState)(!1);if(!t)return null;let h=!!(s||c),g=l.find(e=>e.main)?.label||`文档库`,_=l.filter(e=>!e.main).length,v=()=>{let i=n||r.model;i&&f(i,{component:`refs`,name:`文档列表`,config:e===`repo`?{repoKey:t.key||``}:{boardKey:t.id||t.key||``,boardName:t.name||``},location:`right`})};if(!h){let e=()=>{p||(m(!0),d().then(()=>r.refreshRepos?.()).catch(e=>i(String(e.message||e))).finally(()=>m(!1)))};return(0,H.jsx)(`div`,{className:`nx-intro`,children:(0,H.jsxs)(`div`,{className:`nx-intro-head`,children:[(0,H.jsx)(`button`,{type:`button`,className:`nx-intro-link-main is-empty`,title:`还没有${o}——点这里写第一篇`,disabled:p,onClick:e,children:p?`新建中…`:o}),(0,H.jsx)(`span`,{className:`nx-intro-path mono`,children:`未编写`}),(0,H.jsx)(`span`,{className:`nx-intro-spacer`}),(0,H.jsx)(`button`,{type:`button`,className:`nx-intro-btn`,disabled:p,onClick:e,children:`+ 新建`}),(0,H.jsx)(`button`,{type:`button`,className:`nx-intro-btn`,title:`在右侧栏列出${o}的全部文章(也可以在那里新建)`,onClick:v,children:`查看详情`})]})})}return(0,H.jsx)(`div`,{className:`nx-intro`,children:(0,H.jsxs)(`div`,{className:`nx-intro-head`,children:[(0,H.jsx)(`button`,{type:`button`,className:`nx-intro-link-main`,title:`打开${o}(在主内容区阅读 / 编辑)`,onClick:u,children:o}),(0,H.jsx)(`span`,{className:`nx-intro-path mono`,children:g}),(0,H.jsx)(`span`,{className:`nx-intro-spacer`}),(0,H.jsxs)(`button`,{type:`button`,className:`nx-intro-btn`,title:`在右侧栏列出${o}的全部文章(点标题在主内容区打开,可编辑)`,onClick:v,children:[`查看详情`,_>0?` ${_}`:``]})]})})}function X(e){let t=String(e??``).replace(/^/,``).replace(/\r\n/g,`
|
|
2
|
-
`),n=t.match(/^---\n([\s\S]*?)\n---\n?/),r=n?t.slice(n[0].length):t;for(let e of r.split(`
|
|
3
|
-
`)){let t=e.trim();if(t)return t}return``}function Z(e){let t=X(e).match(/^#\s+(.+)$/);return t?(t[1]??``).trim():``}function Pe(e,t){let n=String(e??``),r=String(t||``).trim()||`未命名文档`,i=n.replace(/\r\n/g,`
|
|
4
|
-
`),a=i.match(/^---\n([\s\S]*?)\n---\n?/),o=a?i.slice(0,a[0].length):``,s=(a?i.slice(a[0].length):i).split(`
|
|
5
|
-
`),c=s.findIndex(e=>e.trim());if(c<0)return`${o}# ${r}\n`;let l=s[c]??``;return/^#\s+/.test(l.trim())?s[c]=`# ${r}`:s.splice(c,0,`# ${r}`),`${o}${s.join(`
|
|
6
|
-
`)}`}function Q(e){let t=y(),n=a(),r=e||t.model,i=(0,U.useRef)(null),o=(0,U.useCallback)(async()=>{if(!i.current)try{i.current=(await ie()).index||[]}catch{i.current=[]}return i.current??[]},[]),s=(0,U.useCallback)(async(e,t,n={})=>{let i=(t||await o()).find(t=>t.docId===e);f(r,{component:`doc`,name:i?i.name:e,config:{docId:e,...n.repoKey?{repoKey:n.repoKey}:{},...n.boardKey?{boardKey:n.boardKey,boardName:n.boardName||``}:{}},location:`center`})},[r,o]),c=(0,U.useCallback)(async e=>{let t=await o(),r=x(e,t);if(r&&`docId`in r)return s(r.docId,t);if(r&&`candidates`in r)return n(`「${e}」同名文档多份:${r.candidates.join(`、`)}`);n(`未找到「${e}」——在仓库/组面板点 + 新建文档后再引用`)},[o,s,n]);return{nav:c,onClick:(0,U.useCallback)(e=>{let t=e.target.closest(`[data-wl]`);t&&(e.preventDefault(),c(t.getAttribute(`data-wl`)))},[c]),ensureIndex:o,openByDocId:s}}var Fe=o({default:()=>Le,useWikiNav:()=>Q}),Ie=b;function Le({docId:e,repoKey:t,boardKey:n,boardName:r,model:o,tabId:s}){let l=a(),u=y(),{dialog:d,node:p}=i(),m=(0,U.useRef)(new Map),h=(0,U.useRef)(null),g=(0,U.useRef)(null),{onClick:_,openByDocId:v}=Q(o),b=t?`repo`:n?`board`:``,x=t||n||``,A=(0,U.useMemo)(()=>t?{repoKey:t}:n?{boardKey:n,boardName:r||``}:{},[t,n,r]),[j,M]=(0,U.useState)(null),[N,P]=(0,U.useState)(``),[ie,F]=(0,U.useState)(!1),[I,le]=(0,U.useState)(`split`),[ue,L]=(0,U.useState)(``),[fe,pe]=(0,U.useState)(!1),R=ne(`doc`,!1),[me,B]=(0,U.useState)([]),[ge,ye]=(0,U.useState)(null),be=(0,U.useRef)(null);(0,U.useEffect)(()=>{be.current=j},[j]),(0,U.useEffect)(()=>{L(j?.desc||``)},[j?.refId,j?.desc]);let we=(0,U.useCallback)(async()=>{P(``);try{let t=await ce(e||``);M(t),F(!1)}catch(e){P(String(e.message||e)),M(null)}},[e]);(0,U.useEffect)(()=>{M(null),we()},[we]);let W=(0,U.useCallback)(()=>{if(!x){B([]);return}let t=e?[{docId:e,label:`当前`,main:!0}]:[],n=n=>{let r=[];for(let e of n){if(!e.refId)continue;let t=`ref:`+e.refId;r.some(e=>e.docId===t)||r.push({docId:t,label:e.title||e.desc||e.summary||`未命名文档`,main:!!e.main})}return e&&!r.some(t=>t.docId===e)&&r.push(t[0]),r};if(b===`repo`){de({host:x}).then(e=>B(n(e.bindings||[]))).catch(()=>B(t));return}ae().then(async e=>{let t=(e&&e.boards||(Array.isArray(e)?e:[])).find(e=>e.id===x||e.key===x),r=await de({group:String(t?.key||x)});B(n(r.bindings||[]))}).catch(()=>B(t))},[x,b,e]);(0,U.useEffect)(()=>{W()},[W]);let[G,Ee]=(0,U.useState)(null);(0,U.useEffect)(()=>{oe().then(e=>{let t=new Set;for(let n of e.index||[])t.add(n.name),n.path&&t.add(String(n.path).replace(/\\/g,`/`).toLowerCase());Ee(t)}).catch(()=>{})},[]);let K=!!(j&&j.writable),q=Te(e,K,j?j.title||j.desc||j.summary||`未命名文档`:``),[J,Y]=(0,U.useState)([]),[ke,Ae]=(0,U.useState)(0);(0,U.useEffect)(()=>{let t=!0;if(!e){Y([]);return}return se(e).then(e=>{t&&Y(e&&(e.attachments||e.data?.attachments)||[])}).catch(()=>{t&&Y([])}),()=>{t=!1}},[e,ke]);let je=(0,U.useMemo)(()=>j?Ie(j.body,J,K?G:null):``,[j,G,K,J]),Ne=(0,U.useMemo)(()=>j?ee(j.body):[],[j]);(0,U.useEffect)(()=>{let e=g.current;if(!e)return;let t=()=>e.querySelector(`.mdw-preview, .mdw-lp`)||null;ye(t());let n=typeof MutationObserver<`u`?new MutationObserver(()=>ye(t())):null;return n&&n.observe(e,{childList:!0,subtree:!0}),()=>{n&&n.disconnect()}},[j,I,je]);let X=e=>e().catch(e=>l(String(e.message||e))),Fe=(0,U.useCallback)(e=>v(e,null,A),[v,A]),Le=(0,U.useCallback)(()=>{let e=o;e&&x&&f(e,{component:`refs`,name:`文档列表`,config:t?{repoKey:t}:{boardKey:n,boardName:r||``},location:`right`})},[o,x,t,n,r]),Re=()=>{x&&X(async()=>{let e=await d({title:`补充介绍文档`,input:!0,placeholder:`文档描述(列表里显示这一行,便于快速定位)`});if(e===null)return;let t=String(e).trim();if(!t)return;let n=await _e(b===`repo`?{owner:`repo`,repo:x,desc:t,title:t}:{owner:`group`,group:x,desc:t,title:t});l(`已补充:${t}`),W(),v(`ref:`+n,null,A)})},$=(0,U.useRef)(!1),ze=()=>X(async()=>{if(j&&K&&!$.current){$.current=!0;try{let t=j.body,n=await z({ref:e,body:t});M(e=>e&&{...e,body:t,summary:n.summary,desc:n.desc??e.desc}),F(!1),k(m.current,e),W(),V(),l(n.summary?`已保存,摘要已回写`:`已保存`)}finally{$.current=!1}}}),Be=(t,n=`op`)=>{j&&(D(m.current,e,{body:j.body},n),F(!0),M(e=>e&&{...e,body:t,title:Z(t)||e.title}))},Ve=(t,n=`typing`)=>{if(!j)return;D(m.current,e,{body:j.body},n),F(!0);let r=Pe(j.body,t);M(e=>e&&{...e,body:r,title:t})},He=()=>{if(!j)return;let t=te(m.current,e,{body:j.body});t&&(M(e=>e&&{...e,body:t.body,title:Z(t.body)||e.title}),F(!0),requestAnimationFrame(()=>h.current?.caretFromDiff?.(j.body||``,t.body)))},Ue=()=>{if(!j)return;let t=O(m.current,e,{body:j.body});t&&(M(e=>e&&{...e,body:t.body,title:Z(t.body)||e.title}),F(!0),requestAnimationFrame(()=>h.current?.caretFromDiff?.(j.body||``,t.body)))},We=async(t,n={})=>{if(!K)return;let r=[...t||[]];if(r.length)try{let t=await T(r,{onProgress:(e,t,n)=>l(`正在上传 ${e}/${t}:${n.name}`)}),i=E(t);if(!i)return;let a=be.current||j;if(!a)return;let o=S(a.body,i,n);D(m.current,e,{body:a.body}),F(!0),M(e=>e&&{...e,body:o.body,title:Z(o.body)||e.title}),l(`已插入 ${t.length} 个附件`)}catch(e){l(`附件上传失败:${String(e.message||e)}`)}},Ge=()=>{j&&X(async()=>{let t=await d({title:`改描述`,input:!0,value:j.desc||``,placeholder:`一句话描述(列表 / 提示词模板里显示)`});if(t===null)return;let n=String(t).trim(),r=await z({ref:e,desc:n});M(e=>e&&{...e,desc:r.desc??n}),l(`描述已更新`),V()})},Ke=async()=>{if(!j||!K||fe||!e)return;let t=ue.trim();if(t!==String(j.desc||``).trim()){pe(!0);try{let n=await ve(e,t);M(e=>e&&{...e,desc:n}),l(`描述已更新`)}catch(e){l(String(e.message||e)),L(j.desc||``)}finally{pe(!1)}}},qe=()=>{if(!j)return;let r=j.desc||j.title||j.refId||e;X(async()=>{if(!await d({title:`删除文档「${r}」`,message:`库内文档 ${r} 及其正文会被一并删除,不可恢复。`,danger:!0,okText:`删除`}))return;await he({ref:e}),l(`已删除:${r}`),V();let i=s&&(o||u.model||null)?.getNodeById?.(s),a=i&&i.getConfig&&i.getConfig()||{};typeof i?.getWindowId==`function`&&i.getWindowId()===`float`||a.beside||!u.onNavigate||!t&&!n?o&&s&&o.doAction(c.deleteTab(s)):t?u.onNavigate(`#/repos`):u.onNavigate(`#/group/`+encodeURIComponent(n||``))})};if(j&&j.dir)return(0,H.jsxs)(`div`,{className:`mdw docp`,children:[(0,H.jsxs)(`div`,{className:`docp-head`,children:[(0,H.jsx)(`span`,{className:`docp-path mono`,children:j.path}),(0,H.jsx)(`span`,{className:`docp-tag ext`,children:`外部目录 · 只读`})]}),(0,H.jsxs)(`div`,{className:`docp-files`,children:[(j.files||[]).map(e=>(0,H.jsx)(`button`,{className:`docp-file`,onClick:()=>v(`path:`+e,null),children:e},e)),!(j.files||[]).length&&(0,H.jsx)(`div`,{className:`muted pad`,children:`(目录里还没有 .md 文档)`})]})]});if(N)return(0,H.jsx)(`div`,{className:`mdw docp`,children:(0,H.jsxs)(`div`,{className:`pad stack`,children:[(0,H.jsx)(`div`,{children:(0,H.jsx)(`strong`,{children:`文档打开失败`})}),(0,H.jsx)(`div`,{className:`hint`,children:N})]})});if(!j)return(0,H.jsx)(`div`,{className:`mdw`,children:(0,H.jsx)(`div`,{className:`pad muted`,children:`载入中…`})});if(j.missing){let e=!!j.kind;return(0,H.jsxs)(`div`,{className:`mdw docp`,children:[(0,H.jsx)(`div`,{className:`docp-head`,children:(0,H.jsx)(`span`,{className:`docp-path mono`,children:j.path||j.desc||j.title||`未命名文档`})}),(0,H.jsxs)(`div`,{className:`pad stack`,children:[(0,H.jsx)(`div`,{children:(0,H.jsx)(`strong`,{children:e?`这条文档没有正文`:`文档还没有正文`})}),(0,H.jsx)(`div`,{className:`hint`,children:e?String(j.reason||`历史索引条目或外部文件镜像,正文不在库内。`):`正文的唯一来源是库内 ref_bodies。`})]})]})}let Je=K?I:`read`;return(0,H.jsxs)(`div`,{className:`mdw docp`,"data-mode":Je,onClick:_,ref:g,children:[(0,H.jsxs)(`div`,{className:`mdw-main`,children:[(0,H.jsx)(De,{crumb:(0,H.jsx)(re,{}),title:j.title||j.desc||j.summary||`未命名文档`,pathLabel:j.path||``,dirty:ie,writable:K,external:!!j.external,menuGroups:[Oe(`edit`,`编辑`,[{id:`mode`,label:I===`edit`?`返回实时预览`:`源码模式`,hint:I===`edit`?`当前`:``,run:()=>le(I===`edit`?`split`:`edit`)}]),Oe(`doc`,`文档`,[{id:`rename`,label:`改描述`,run:Ge},{id:`delete`,label:`删除`,run:qe,danger:!0}]),Oe(`view`,`查看`,[x&&{id:`list`,label:`文字列表`,hint:`右侧边栏`,run:Le}])],onSave:ze}),(0,H.jsxs)(`div`,{className:`docp-desc`+(j.desc?``:` empty`),children:[(0,H.jsx)(`span`,{className:`k`,children:`描述`}),K?(0,H.jsx)(`input`,{className:`docp-desc-input`,value:ue,disabled:fe,spellCheck:!1,placeholder:`未填写——写一句这篇讲什么,列表与提示词里用它快速定位`,"aria-label":`文档描述(失焦或回车保存)`,onChange:e=>L(e.target.value),onBlur:()=>{Ke()},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.blur()):e.key===`Escape`&&(L(j.desc||``),e.currentTarget.blur())}}):(0,H.jsx)(`span`,{className:`v`,children:j.desc||`未填写——写一句这篇讲什么,列表与提示词里用它快速定位`})]}),(0,H.jsx)(C,{mode:Je,title:j.title,body:j.body,previewHtml:je,onTitle:K?Ve:void 0,onBody:K?Be:void 0,onFiles:K?We:null,attachments:J,docKey:e,editorApiRef:h,onSave:K?ze:null,onUndo:K?He:null,onRedo:K?Ue:null}),(0,H.jsx)(Se,{dock:R,attCount:J.length,bindCount:q.count,attachNode:(0,H.jsx)(xe,{refId:e,writable:K,onChanged:()=>Ae(e=>e+1),onOpenDoc:e=>{let t=w(e);t&&v(t,null,A)}}),bindNode:q.strip}),(0,H.jsx)(Ce,{dock:R,attCount:J.length,bindCount:q.count})]}),(0,H.jsx)(Me,{headings:Ne,scrollRoot:ge,links:me,activeDocId:e,onOpenDoc:x?Fe:null,onAddRef:x?Re:null}),p,q.modal]})}export{_e as a,ge as c,W as i,de as l,Q as n,ye as o,Ne as r,be as s,Fe as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,d as t}from"./popup-dBtYqEM1.js";var n=t();function r({value:t,onChange:r,placeholder:i,count:a,title:o,className:s}){let c=o||`搜索`;return(0,n.jsxs)(`label`,{className:`nx-list-search`+(s?` `+s:``),title:o||`输入关键词过滤列表`,children:[(0,n.jsx)(e,{name:`search`,size:13}),(0,n.jsx)(`input`,{value:t,placeholder:i||`搜索…`,"aria-label":c,onChange:e=>r(e.target.value)}),t&&a!==void 0?(0,n.jsx)(`span`,{className:`nx-list-search-n`,children:a}):null,t?(0,n.jsx)(`button`,{type:`button`,className:`nx-list-search-x`,title:`清空搜索`,"aria-label":`清空搜索`,onClick:()=>r(``),children:`×`}):null]})}export{r as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as e,f as t,h as n}from"./popup-dBtYqEM1.js";import{n as r}from"./app-context-CngKv8Tc.js";import{t as i}from"./board-view-C8OQhkyi.js";var a=n(t(),1),o=i;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`templates`:return e.mode===`new`?[`新建模板`]:e.mode===`edit`?[`编辑模板`]:[`任务模板`];case`doc`:{let e=t.repoName||t.boardName||``;return e?[e]:[`文档`]}default:return[]}}function c(e,t={}){if(!e||!e.view)return[];switch(e.view){case`dir`:{if(!t.dirName)return[];let n=[];if(n.push({label:t.dirName,hash:e.task?`#/dir/${encodeURIComponent(e.key||``)}`:``}),e.task){let r=/^draft/i.test(String(e.task))?`draft`:t.pageTitle||`#${e.task}`;n.push({label:r,hash:``})}return n}case`group`:if(e.task){let n=/^draft/i.test(String(e.task))?`draft`:t.pageTitle||`#${e.task}`;return[{label:t.boardName||`项目组`,hash:`#/group/${encodeURIComponent(e.key||``)}`},{label:n,hash:``}]}return[{label:t.boardName||`项目组`,hash:``}];case`repos`:return[{label:`仓库管理`,hash:``}];case`templates`:return e.mode===`new`?[{label:`任务模板`,hash:`#/templates`},{label:`新建模板`,hash:``}]:e.mode===`edit`?[{label:`任务模板`,hash:`#/templates`},{label:`编辑模板`,hash:``}]:[{label:`任务模板`,hash:``}];case`doc`:{let n=t.repoName||t.boardName||``,r=l(e,t);return n?[{label:n,hash:r},{label:`文档`,hash:``}]:[{label:`文档`,hash:``}]}default:return[]}}function l(e,t){if(!e||!e.view)return``;switch(e.view){case`dir`:return e.task?`#/dir/${encodeURIComponent(e.key||``)}`:`#/repos`;case`group`:return e.task?`#/group/${encodeURIComponent(e.key||``)}`:`#/repos`;case`doc`:return e.repoKey?`#/repos`:e.boardKey?`#/group/${encodeURIComponent(e.boardKey)}`:`#/repos`;default:return`#/repos`}}function u(e,t=[],n={}){if(!e)return{boardName:``,dirName:``,pageTitle:``};let r=(n.boards||[]).find(t=>t.id===e.key);if(e.view===`group`&&e.task){let i=o(t,n.boards||[],e.key,e.task);return{boardName:i.board&&i.board.name||r&&r.name||``,dirName:i.topic?i.topic.name:``,pageTitle:i.taskRow?`#${i.taskRow.id}`:``}}let i=(t||[]).find(t=>t.key===e.key),a=i&&e.task?(i.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:r&&r.name||``,dirName:i?i.name:``,pageTitle:a?`#${a.id}`:``}}var d=[];function f(e){e&&(d[d.length-1]!==e&&d.push(e),d.length>30&&d.shift())}function p(){return d.length>1?(d.pop(),d[d.length-1]??``):``}var m=e();function h({route:e,ctx:t={},onNavigate:n,onBack:r,inline:i=!1}){let o=(0,a.useMemo)(()=>c(e,t),[e,t]),s=(0,a.useMemo)(()=>l(e,t),[e,t]);return o.length?(0,m.jsxs)(`nav`,{className:`nx-crumb`+(i?` nx-crumb-inline`:``),"aria-label":`当前位置`,children:[!!(s&&n)&&(0,m.jsx)(`button`,{type:`button`,className:`nx-crumb-back`,title:`返回上一级`,"aria-label":`返回上一级`,onClick:()=>r?r():n(s),children:`←`}),(0,m.jsx)(`span`,{className:`nx-crumb-br`,"aria-hidden":!0,children:`[`}),o.map((e,t)=>{let r=t!==o.length-1&&!!e.hash&&!!n;return(0,m.jsxs)(`span`,{className:`nx-crumb-i`,children:[t>0?(0,m.jsx)(`span`,{className:`nx-crumb-sep`,children:`/`}):null,r?(0,m.jsx)(`button`,{type:`button`,className:`nx-crumb-t nx-crumb-link`,title:`前往 ${e.label}`,onClick:()=>n(e.hash),children:e.label}):(0,m.jsx)(`span`,{className:`nx-crumb-t`,children:e.label})]},`${e.label}-${t}`)}),(0,m.jsx)(`span`,{className:`nx-crumb-br`,"aria-hidden":!0,children:`]`})]}):null}function g(){let e=r(),t=e.route||{},n=e.rows||[],i=e.repoData||{},o=(0,a.useMemo)(()=>u(t,n,i),[t,n,i]);return(0,a.useMemo)(()=>s(t,o),[t,o]).length?(0,m.jsx)(h,{route:t,ctx:o,onNavigate:e.onNavigate,onBack:()=>{let n=p();if(n&&e.onNavigate){e.onNavigate(n);return}let r=l(t,o);r&&e.onNavigate&&e.onNavigate(r)},inline:!0}):null}export{p as n,f as r,g as t};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import{a as e,d as t,f as n,h as r,i,l as a,t as o,u as s}from"./popup-dBtYqEM1.js";import{D as c,f as l,n as u,u as d}from"./tool-bar-DPXnjdQF.js";import{n as f}from"./app-context-CngKv8Tc.js";import{d as p,g as m,h,l as g,m as _,s as v}from"./task-status-Cjsm0xF7.js";import{C as y,E as b,T as x,a as S,b as C,i as w,n as T,r as E,s as D,t as O,w as ee}from"./md-history-COQu16vy.js";import{i as k,r as A,t as j}from"./use-rail-drag-B6J0iqFK.js";import{t as te}from"./route-crumb-BKq2jry0.js";import{C as ne,S as re,_ as ie,b as ae,g as M,h as N,v as P,x as F,y as I}from"./index-q51dndMj.js";import{a as L,i as R,n as z,o as oe}from"./composer-launch-BF3_hyn5.js";import{a as B,d as V,f as H,g as se,i as U,l as ce,m as le,n as ue,o as W,r as de,s as fe,t as G,u as pe}from"./reopen-text-B2d9SZi0.js";import{n as K,r as me,t as he}from"./task-utils-Dh33OFKe.js";import{n as ge}from"./group-project-memo-G-O6sPRw.js";var q=r(n(),1);function _e(e){return s(`/api/localtasks/chain?${e}`)}function ve(e){return s(`/api/localtasks/timegoal-log?${e}`)}function ye(e){return s(`/api/localtasks/clone`,{method:`POST`,body:e})}function be(e){return s(`/api/localtasks/fork`,{method:`POST`,body:e})}function xe(e){return s(`/api/localtasks/attachments?${e}`)}function Se(e){return s(`/api/docs/mdfile?attachment=${encodeURIComponent(e)}`)}function Ce(e){return s(`/api/localtasks/preview`,{method:`POST`,body:e})}function we(e){let t=String(e??``).split(`
|
|
2
|
-
`),n=B(t[0]);return n?{head:n,body:t.slice(1).map(e=>e.replace(/^>[ \t]?/,``)).filter(e=>e.trim()!==``).join(`
|
|
3
|
-
`)}:null}function Te(e){let t=ee(String(e??``));if(!t.length)return[];let n=[],r=null,i=``;return t.forEach((e,t)=>{let a=String(e||``).trim(),o=we(a);if(o&&U(o.head)===`summary`){let e=o.head.round;r={round:Number.isFinite(e)&&e>0?e:n.length+1,blockIndex:t,feedbackBlockIndex:-1,ackText:o.body,feedbackText:``},n.push(r),i=`ack`;return}if(a===`## 上一轮完成总结`){r={round:n.length+1,blockIndex:t,feedbackBlockIndex:-1,ackText:``,feedbackText:``},n.push(r),i=`ack`;return}if(o&&U(o.head)===`feedback`){r&&i===`ack`&&(r.feedbackBlockIndex=t,r.feedbackText=o.body,i=`feedback`);return}if(a===`## 验收反馈`){r&&i===`ack`&&(r.feedbackBlockIndex=t,i=`feedback`);return}a&&r&&(i===`ack`?r.ackText+=(r.ackText?`
|
|
4
|
-
`:``)+a:r.feedbackText+=(r.feedbackText?`
|
|
5
|
-
`:``)+a)}),n.filter(e=>e.ackText!==``)}function Ee(e){let t=String(e?.ackText||``).split(`
|
|
6
|
-
`).map(e=>e.replace(/^#+\s*/,``).replace(/\*\*/g,``).trim()).find(e=>e!==``);if(!t)return`第 ${e?.round??1} 轮`;let n=t.length>24?`${t.slice(0,24)}…`:t;return`第 ${e?.round??1} 轮 · ${n}`}var J=t();function De(e,t,n){return!e||t<0?null:e.querySelector(`.mdw-lp-block[data-i="${t}"]`)||[...Array.from(e.querySelectorAll(`h2`)).filter(e=>(e.textContent||``).trim()===`上一轮完成总结`),...Array.from(e.querySelectorAll(`.md-callout-t`)).filter(e=>/完成总结/.test(e.textContent||``))].sort((e,t)=>e.compareDocumentPosition(t)&4?-1:1)[n]||null}function Oe({nodes:e=[],scrollRoot:t=null,onJump:n=null}){let[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(0),{railRef:s,pos:c,dragging:l,draggedRef:u,handleProps:d}=j(),f=(0,q.useMemo)(()=>(e||[]).map(e=>({...e,title:Ee(e)})),[e]);(0,q.useEffect)(()=>{let e=t;if(!e||!f.length)return;let n=()=>{let t=e.getBoundingClientRect(),n=0;for(let r of f){let i=De(e,r.blockIndex,r.round-1);i&&i.getBoundingClientRect().top-t.top<=40&&(n=r.round)}o(n)};return n(),e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},[t,f]);let p=(0,q.useCallback)(e=>{let r=t,i=r?De(r,e.blockIndex,e.round-1):null;i&&(i.scrollIntoView({behavior:`smooth`,block:`start`}),o(e.round)),n?.(e)},[t,n]);return f.length?(0,J.jsxs)(`aside`,{ref:s,className:`doc-rail ack-rail`+(r?` open`:``)+(l?` dragging`:``),style:c?{left:c.x,top:c.y,right:`auto`,bottom:`auto`}:void 0,"aria-label":`验收轮次`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`doc-rail-menu`,title:r?`收起轮次(双击回默认位)`:`展开轮次 · 按住拖动 · 双击回默认位`,"aria-expanded":r,onClick:()=>{if(u.current){u.current=!1;return}i(e=>!e)},...d,children:[(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{})]}),(0,J.jsx)(`div`,{className:`doc-rail-ticks`,role:`navigation`,"aria-label":`验收轮次`,children:f.map(e=>(0,J.jsx)(`button`,{type:`button`,className:`doc-rail-tick`+(a===e.round?` on`:``),style:{"--tw":`18px`},title:e.title,"aria-current":a===e.round?`true`:void 0,onClick:()=>p(e)},e.round))}),r&&(0,J.jsx)(`div`,{className:`doc-rail-panel`,children:(0,J.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,J.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`验收轮次`}),f.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`doc-rail-row`+(a===e.round?` on`:``),title:e.ackText,onClick:()=>p(e),children:[`第 `,e.round,` 轮`]},e.round))]})})]}):null}var ke=[{op:`bold`,label:`B`,title:`粗体`,cls:`b`},{op:`italic`,label:`I`,title:`斜体`,cls:`i`},{op:`code`,label:`</>`,title:`代码`,cls:`code`},{op:`link`,label:`链`,title:`链接`,cls:`link`}];function Ae({at:e,onFormat:t,onCopy:n,onCompose:r,onDelete:i}){if(!e)return null;let a=e.kind||`task`,o=a===`format`||a===`both`;return(0,J.jsx)(`div`,{id:`mdw-sel-menu`,className:`mdw-sel-menu open kind-${a}`,style:{left:e.x,top:e.y},role:`menu`,onMouseDown:e=>{e.target.closest?.(`textarea, input, button`)||e.preventDefault()},children:o?(0,J.jsxs)(`div`,{className:`mdw-sel-fmt`,role:`group`,"aria-label":`选区格式`,children:[ke.map(e=>(0,J.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn ${e.cls}`,title:e.title,onClick:()=>t?.(e.op),children:e.label},e.op)),(0,J.jsx)(`span`,{className:`mdw-sel-sep`,"aria-hidden":!0}),(0,J.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn`,title:`复制`,onClick:n,children:`复制`}),(0,J.jsx)(`span`,{className:`mdw-sel-sep`,"aria-hidden":!0}),(0,J.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn comment`,title:`评论 → 打开 md 编辑面板`,onClick:()=>r?.(),children:`评论`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`cap`,children:`选区`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>r?.(),children:`评论`}),(0,J.jsx)(`div`,{className:`sep`}),(0,J.jsx)(`button`,{type:`button`,onClick:n,children:`复制选区`}),i?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`sep`}),(0,J.jsx)(`button`,{type:`button`,className:`danger`,title:`删除选区触到的整段块`,onClick:i,children:`删除选区`})]}):null]})})}var je=[{title:`格式`,items:[[`Ctrl/⌘ B`,`粗体`],[`Ctrl/⌘ I`,`斜体`],[`Ctrl/⌘ E`,`行内代码`],[`Ctrl/⌘ K`,`链接`],[`1 – 6`,`正文 / 标题 / 小标题 / 列表 / 待办 / 引用`]]},{title:`编辑`,items:[[`/`,`行首唤起命令菜单`],[`Tab / ⇧Tab`,`缩进 / 反缩进`],[`Enter`,`新建块(列表自动续行)`],[`⇧Enter`,`块内软换行`],[`Ctrl/⌘ Z`,`撤销`],[`Ctrl/⌘ ⇧Z`,`重做`]]},{title:`导航与文件`,items:[[`Ctrl/⌘ F`,`查找(Enter 下一个,F3 继续)`],[`Ctrl/⌘ S`,`保存并同步`],[`Ctrl/⌘ ⇧ O`,`评论任务:右侧并排打开原文`],[`Ctrl/⌘ /`,`打开 / 关闭本速查`],[`Enter(标题内)`,`跳到正文`]]}];function Me({onClose:e}){return(0,J.jsx)(o,{title:`快捷键`,onClose:e,size:`lg`,className:`mdw-sheet`,children:(0,J.jsx)(`div`,{className:`mdw-sheet-cols`,children:je.map(e=>(0,J.jsxs)(`section`,{className:e.title===`导航与文件`?`wide`:void 0,children:[(0,J.jsx)(`h4`,{children:e.title}),(0,J.jsx)(`dl`,{children:e.items.map(([e,t])=>(0,J.jsxs)(`div`,{className:`mdw-sheet-row`,children:[(0,J.jsx)(`dt`,{children:(0,J.jsx)(`kbd`,{children:e})}),(0,J.jsx)(`dd`,{children:t})]},e))})]},e.title))})})}var Y=148,Ne=58,X=20,Pe=46,Fe={origin:`起点`,reopen:`反馈`,feedback:`反馈`,comment:`评论`,fork:`分支`},Ie={pending:`待领取`,claimed:`已领取`,done:`已完成`,cancelled:`已取消`,plan:`草稿`},Le={origin:`#6B7078`,reopen:`#B4703A`,feedback:`#B4703A`,comment:`#3F6E9E`,fork:`#7A5FA8`},Re={pending:`#8A8F98`,claimed:`#C99A2E`,done:`#2F6F5E`,cancelled:`#C0392B`,plan:`#9AA0A8`};function ze(e){let t=e.children||[];if(!t.length)return Y;let n=t.reduce((e,t)=>e+ze(t),0)+X*(t.length-1);return Math.max(Y,n)}function Be(e){let t=String(e||``).trim();if(!t)return``;let n=/^(\d{4})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2})/.exec(t);return n?`${n[2]}-${n[3]} ${n[4]}:${n[5]}`:t.slice(0,16)}function Ve({root:e,onOpen:t}){let n=[],r=[],i=0,a=(e,t)=>{let o=ze(e),s=e.children||[],c={id:String(e.id),x:0,y:t*104,depth:t,kind:String(e.forkKind||(t===0?`origin`:``)),status:String(e.status||``),label:String(e.excerpt||`#${e.id}`),time:Be(e.createdAt),current:!!e.current,missing:!!e.missing,node:e};if(!s.length)c.x=i+(o-Y)/2,i+=o+X;else{let e=i,n=s.map(e=>a(e,t+1)),l=n[0],u=n[n.length-1];c.x=(l.x+u.x)/2,c.x=Math.min(Math.max(c.x,e),e+o-Y);for(let e of n)r.push({from:c,to:e});i=Math.max(i,e+o+X)}return n.push(c),c};a(e,0);let o=Math.max(Y,i-X)+24,s=(Math.max(0,...n.map(e=>e.depth))+1)*104-Pe+24;return(0,J.jsx)(`div`,{className:`mdw-chain-graph-wrap`,children:(0,J.jsxs)(`svg`,{className:`mdw-chain-graph`,width:o+8,height:s+8,viewBox:`-12 -12 ${o} ${s}`,role:`img`,"aria-label":`任务链树图`,children:[r.map((e,t)=>{let n=e.from.x+Y/2,r=e.from.y+Ne,i=e.to.x+Y/2,a=e.to.y,o=r+(a-r)/2;return(0,J.jsx)(`path`,{d:`M ${n} ${r} V ${o} H ${i} V ${a}`,fill:`none`,stroke:`var(--line, #D8D6D0)`,strokeWidth:`1.4`},`e${t}`)}),n.map(e=>{let n=Le[e.kind]||`#6B7078`,r=Re[e.status]||`#8A8F98`,i=Fe[e.kind]||(e.depth===0?`起点`:`?`),a=Ie[e.status]||e.status||``;return(0,J.jsxs)(`g`,{className:`mdw-chain-node`+(e.current?` is-current`:``)+(e.missing?` is-missing`:``),transform:`translate(${e.x}, ${e.y})`,onClick:()=>{!e.current&&!e.missing&&t?.(e.node)},style:{cursor:e.current||e.missing?`default`:`pointer`},children:[(0,J.jsx)(`title`,{children:`#${e.id} ${i}${a?` · `+a:``}\n${e.label}${e.time?`
|
|
7
|
-
`+e.time:``}${e.current?`
|
|
8
|
-
(当前任务)`:``}`}),(0,J.jsx)(`rect`,{width:Y,height:Ne,rx:`8`,fill:e.current?`var(--soft, #F4F6F4)`:`var(--paper, #FFFFFF)`,stroke:e.current?`var(--mdw-accent, #2F6F5E)`:`var(--line, #D8D6D0)`,strokeWidth:e.current?2:1}),(0,J.jsx)(`rect`,{x:`8`,y:`7`,width:i.length*12+12,height:`16`,rx:`8`,fill:n,opacity:`0.12`}),(0,J.jsx)(`text`,{x:`14`,y:`19`,fontSize:`10`,fontWeight:`600`,fill:n,children:i}),(0,J.jsxs)(`text`,{x:138,y:`19`,fontSize:`10`,fill:`var(--faint, #8A8F98)`,textAnchor:`end`,children:[`#`,e.id]}),(0,J.jsx)(`text`,{x:`10`,y:`37`,fontSize:`11.5`,fill:`var(--ink, #16181C)`,children:e.label.length>15?e.label.slice(0,15)+`…`:e.label}),(0,J.jsx)(`circle`,{cx:`13`,cy:`47`,r:`3`,fill:r}),(0,J.jsx)(`text`,{x:`21`,y:`50`,fontSize:`10`,fill:`var(--ink-2, #454A52)`,children:a}),e.time?(0,J.jsx)(`text`,{x:138,y:`50`,fontSize:`9.5`,fill:`var(--faint, #8A8F98)`,textAnchor:`end`,children:e.time}):null]},`n${e.id}`)})]})})}var He={origin:`起点`,reopen:`反馈`,feedback:`反馈`,comment:`评论`,fork:`分支`,current:`当前`};function Ue({nodes:e=[],onOpenNode:t}){return e.length?(0,J.jsx)(`ol`,{className:`mdw-chain-list`,"aria-label":`任务链节点`,children:e.map((n,r)=>{let i=n.current?`current`:`t-${n.dirKey||``}-${n.id??n.taskId??r}`,a=He[n.kind||``]||n.kind||`?`,o=n.excerpt||n.feedback||a,s=[n.taskId==null?null:`#${n.taskId}`,n.at||null,n.attachmentCount?`📎${n.attachmentCount}`:null].filter(Boolean).join(` · `);return(0,J.jsxs)(`li`,{className:`mdw-chain-li${n.current?` is-current`:``}`,children:[(0,J.jsxs)(`div`,{className:`mdw-chain-rail`,"aria-hidden":!0,children:[(0,J.jsx)(`span`,{className:`mdw-chain-dot`}),r<e.length-1?(0,J.jsx)(`span`,{className:`mdw-chain-line`}):null]}),(0,J.jsxs)(`button`,{type:`button`,className:`mdw-chain-card${n.kind===`comment`?` is-comment`:``}`,title:n.current?`当前任务(本页)`:`查看:${o}`,disabled:!!n.current,onClick:()=>{n.current||t?.(n)},children:[(0,J.jsx)(`span`,{className:`mdw-chain-kind`,children:a}),(0,J.jsx)(`span`,{className:`mdw-chain-ex`,children:o||`—`}),s?(0,J.jsx)(`span`,{className:`mdw-chain-meta`,children:s}):null]})]},i)})}):(0,J.jsx)(`div`,{className:`mdw-chain-empty muted`,children:`这条任务还没有链(反馈 / 评论派生后会出现)`})}function We({open:e,nodes:t,tree:n,onOpenNode:r,onClose:i}){return e?(0,J.jsxs)(o,{title:`任务链`,onClose:i,size:`lg`,className:`mdw-chain-modal`,children:[(0,J.jsxs)(`p`,{className:`mdw-chain-hint`,children:[n?`单向树:每条任务至多一个来源(评论 / 反馈 / 分支),后代分叉并列。点任意节点旁路打开。`:`从早到晚排列。点非当前节点可在旁路打开内容。`,` `,`agent 实收提示词为交付重排版(最新轮在前);原始意图读正文的 WARNING 块。`]}),n?(0,J.jsx)(Ve,{root:n,onOpen:e=>{r?.({...e,taskId:e.id,dirKey:e.key,kind:e.forkKind}),i?.()}}):(0,J.jsx)(Ue,{nodes:t,onOpenNode:e=>{r?.(e),i?.()}})]}):null}function Ge({id:e,isDraft:t,topicKey:n,task:r,taskRow:i}){let[a,o]=(0,q.useState)(null);(0,q.useEffect)(()=>{o(null)},[e]);let s=i?.timegoal||null,c=a||{duration:s?.duration||``,prompt:s?.prompt||``},l=t||!!i&&i.status===`pending`,u=t||!!i&&i.status!==`done`&&i.status!==`cancelled`&&(i.status===`pending`||!!s),d=!t&&!!s&&r!=null,[f,p]=(0,q.useState)({busy:!1,error:``,data:null}),m=(0,q.useCallback)(()=>{!t&&n&&r!=null&&(p(e=>({...e,busy:!0,error:``})),ve(new URLSearchParams({id:String(r),key:String(n)}).toString()).then(e=>p(t=>({...t,data:e,busy:!1}))).catch(e=>p(t=>({...t,busy:!1,error:String(e.message||e)}))))},[t,n,r]);return(0,q.useEffect)(()=>{d&&m()},[d,m]),{goalDraft:a,setGoalDraft:o,goal:c,goalEditable:l,goalPromptEditable:u,declaredGoal:s,goalLog:f,loadGoalLog:m,canShowGoalLog:d}}function Ke({isDraft:e,task:t,taskRow:n,topicKey:r,topic:i,groupAnchored:a,groupId:o,app:s,model:c,historyId:l,toast:u}){let[f,p]=(0,q.useState)(null);(0,q.useEffect)(()=>{if(e||t==null||/^draft/i.test(String(t))){p(null);return}let n=!1;return _e(`cwd=${encodeURIComponent(i?.cwd||``)}&id=${Number(t)}`).then(e=>{n||p(e)}).catch(()=>{n||p(null)}),()=>{n=!0}},[e,t,i?.cwd,n?.history?.length,n?.forkOf,n?.reopenCount]);let m=(0,q.useMemo)(()=>e||!f?null:f.tree||null,[e,f]),h=(0,q.useMemo)(()=>{if(e||!n)return[];let i=(String(n.text||``).split(`
|
|
9
|
-
`).map(e=>e.trim()).find(Boolean)||``).replace(/^#+\s*/,``).slice(0,100),a=Array.isArray(n.history)?n.history:[];if(a.length){let e=a.map(e=>({historyId:e.id,kind:e.kind,at:e.at,excerpt:e.excerpt||e.feedback||``,feedback:e.feedback,quote:e.quote,attachmentCount:(e.attachments||[]).length,current:!1}));return e.push({historyId:null,kind:`current`,at:n.lastReopenedAt||n.createdAt||``,excerpt:i,attachmentCount:0,current:!0}),e}let o=Array.isArray(f?.ancestors)?[...f.ancestors].reverse():[],s=Array.isArray(f?.children)?f.children:[];if(!o.length&&!s.length&&!n.forkOf)return[];let c=[];for(let e of o)e.missing||c.push({historyId:null,kind:e.forkKind||`origin`,at:e.createdAt||``,excerpt:e.excerpt||`#${e.id}`,attachmentCount:0,current:!1,taskId:e.id,dirKey:e.key});c.push({historyId:null,kind:`current`,at:n.createdAt||``,excerpt:i,attachmentCount:0,current:!0,taskId:Number(t),dirKey:r});for(let e of s)c.push({historyId:null,kind:e.forkKind||`comment`,at:e.createdAt||``,excerpt:e.excerpt||`#${e.id}`,attachmentCount:0,current:!1,taskId:e.id,dirKey:e.key});return c},[e,n,f,t,r]),g=(0,q.useMemo)(()=>{if(l==null||!n)return null;let e=Number(l);return(n.history||[]).find(t=>Number(t.id)===e)||null},[l,n]),_=Array.isArray(f?.children)?f.children:[],v=_.length===0,y=_.length?_[_.length-1]??null:null;return{chainApi:f,chainNodes:h,chainTree:m,historyNode:g,chainChildren:_,isChainTip:v,latestChild:y,openLatestRound:(0,q.useCallback)(()=>{y&&s.openPage&&(a?s.openPage({groupId:o,task:String(y.id),name:`#${y.id}`}):s.openPage({dirKey:String(y.key||r||``),task:String(y.id),name:`#${y.id}`}))},[y,s.openPage,a,o,r]),openHistoryBeside:(0,q.useCallback)(n=>{let i=c||s.model;if(i&&!e){if(n?.current){u(`当前节点就是本页`);return}if(n?.historyId!=null){d(i,{component:`page`,name:`链 #${t} · ${n.kind||n.historyId}`,config:{dirKey:r,task:String(t),historyId:Number(n.historyId)}});return}if(n?.taskId!=null&&n?.dirKey){d(i,{component:`page`,name:n.excerpt?String(n.excerpt).slice(0,24):`#${n.taskId}`,config:{dirKey:String(n.dirKey),task:String(n.taskId)}});return}u(`这个节点没有可打开的内容`)}},[c,s.model,e,r,t,u])}}function qe({id:e}){let[t,n]=(0,q.useState)(null),r=(0,q.useRef)(``);return(0,q.useEffect)(()=>{n(null),r.current=``},[e]),(0,q.useEffect)(()=>{let e=()=>n(null);return document.addEventListener(`scroll`,e,!0),()=>document.removeEventListener(`scroll`,e,!0)},[]),{selMenu:t,setSelMenu:n,lastSel:r,placeSelMenu:(0,q.useCallback)((e,t,i,a,o={})=>{r.current=t,n({kind:e,text:t,...o,x:Math.min(window.innerWidth-300,Math.max(8,i)),y:Math.min(window.innerHeight-240,Math.max(8,a))})},[]),onEditorTextSel:(0,q.useCallback)(e=>{if(!e?.text||e.text.length<1){n(null);return}r.current=e.text,n({kind:`format`,text:e.text,x:Math.min(window.innerWidth-300,Math.max(8,e.x)),y:Math.min(window.innerHeight-240,Math.max(8,e.y))})},[]),closeSelMenu:(0,q.useCallback)(()=>{n(null),r.current=``},[])}}function Je({id:e,taskRow:t,dockTab:n,dockOpen:r}){let[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1),c=(0,q.useRef)(null),l=String(t?.roundSummary||``).length>140;return(0,q.useEffect)(()=>{a(!1),s(!1)},[e,t?.roundSummary]),(0,q.useLayoutEffect)(()=>{let e=c.current;if(!e){s(!1);return}let t=()=>{i||s(e.scrollHeight>e.clientHeight+1)};t();let n=requestAnimationFrame(t),r=typeof ResizeObserver<`u`?new ResizeObserver(t):null;return r?.observe(e),()=>{cancelAnimationFrame(n),r?.disconnect()}},[i,t?.roundSummary,t?.completedAt,n,r]),{ackOpen:i,setAckOpen:a,ackOverflow:o,reviewSumRef:c,ackLong:l}}function Ye({doc:e,id:t,isDraft:n,task:r,taskRow:i,topicKey:o,topic:s,boardCtx:u,docFm:d,groupAnchored:f,groupId:p,app:b,model:S,tabId:C,tpl:w,refreshLocal:T,markDirty:E,histRef:D,editorApiRef:ee,attachAreaRef:k,setDirty:A,goal:j,goalEditable:te,goalPromptEditable:ne,declaredGoal:ie,guard:M,dialog:z,showDockTab:oe}){let B=a(),H=(0,q.useCallback)((e,t)=>{let n=(e||``).trim()||`未命名任务`,r=_(t),i=Object.keys(r).length>0,a=h(t);return a=x(a),a=/^#\s+/m.test(a)?a.replace(/^#\s+.+$/m,`# ${n}`):`# ${n}\n\n${a}`,i?m(a,r):a},[]),U=(0,q.useCallback)(()=>{let e=(j.duration||``).trim(),t=(j.prompt||``).trim();if(t&&!e)return{error:`时间目标要填时长(如 2h / 90m);只写附加要求无效`};if(!n){let n=ie?.duration||``,r=ie?.prompt||``,i=e!==n;return!i&&t===r?{}:i?te?e?{duration:e,goalPrompt:t}:{clearGoal:!0}:{error:`已领取计时,时长不可改(附加要求仍可直接改)`}:ne?{goalPrompt:t}:{}}return e?{duration:e,goalPrompt:t}:{}},[j,te,ne,n,ie]),ue=(0,q.useCallback)(()=>M(async()=>{if(!e)return;let i=(e.title||``).trim()||`未命名任务`,a=_(e.body),l=H(i,e.body),d=!!(u&&a.project&&u.members.some(e=>e.key===a.project)),m=U();if(m.error){B(m.error);return}if(!n){let n=await V({cwd:s?.cwd,id:Number(r),text:l,...m});if(n?.moved){let a=n.key||o,s=String(n.task?.id??r),u=N(re(a),s);L(s,e.attachments),ae(t,u,{title:i,body:n.task?.text||l}),S&&C&&S.doAction(c.updateNodeAttributes(C,{config:f?{groupId:p,task:s}:{dirKey:a,task:s}})),b.onNavigate&&b.onNavigate(f?`#/group/${encodeURIComponent(p||``)}?task=${encodeURIComponent(s)}`:`#/dir/${encodeURIComponent(a||``)}?task=${encodeURIComponent(s)}`),A(!1),O(D.current,u),B(`已改归属项目:任务迁到「${n.name}」#${s}`),T?.();return}L(r,e.attachments),F(t,{title:i,body:l}),A(!1),O(D.current,t),B(m.clearGoal?`已同步 MD · 时间目标已清除`:m.duration?`已同步 MD · 时间目标已更新`:`已同步 MD`),T?.();return}let h=await fe({...d?{text:l,board:u.board.id,project:a.project}:a.project?{text:l,project:a.project}:{cwd:s?.cwd,text:l},...m}),g=h?.task?.id??h?.id;if(g!=null){let n=h?.key||o,r=re(n);L(g,e.attachments);let a=N(r,String(g));ae(t,a,{title:i,body:l}),S&&C&&S.doAction(c.updateNodeAttributes(C,{config:f?{groupId:p,task:String(g)}:{dirKey:n,task:String(g)}})),b.onNavigate&&b.onNavigate(f?`#/group/${encodeURIComponent(p||``)}?task=${encodeURIComponent(String(g))}`:`#/dir/${encodeURIComponent(n||``)}?task=${encodeURIComponent(String(g))}`),A(!1),O(D.current,a)}B(`已提交:${v(i)}`),T?.()}),[e,t,n,r,o,s,u,f,p,b,S,C,T,D,A,H,U,M,B]),W=(0,q.useCallback)(async e=>{let t=await e.text(),n=e.name.replace(/\.md$/i,``);await M(async()=>{let r=t.startsWith(`#`)?t:`# ${n}\n\n${t}`,i=await fe({cwd:s?.cwd,text:r});B(`已导入:${e.name}`),T?.();let a=i?.task?.id??i?.id;a!=null&&b.openPage&&(f?b.openPage({groupId:p,task:String(a),name:`#${a}`}):b.openPage({dirKey:o,task:String(a),name:`#${a}`}))})},[f,d.project,s?.cwd,o,p,b,T,M,B]),de=(0,q.useCallback)(async()=>{if(!e||n)return;let t=e.title||`#${r}`;await z({title:`删除任务「${t}」`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})&&M(async()=>{await le({cwd:s?.cwd,id:Number(r)}),B(`已删除「${t}」`);let e=C&&(S||b.model||null)?.getNodeById?.(C),n=e&&e.getConfig&&e.getConfig()||{};typeof e?.getWindowId==`function`&&e.getWindowId()===`float`||n.beside||!b.onNavigate?S&&C&&S.doAction(c.deleteTab(C)):f?b.onNavigate(`#/group/`+encodeURIComponent(p||``)):b.onNavigate(`#/dir/`+encodeURIComponent(o||``)),T?.()})},[e,n,r,s,S,C,b,f,p,o,T,M,B,z]),G=String(i?.status??``),pe=!n&&!!i&&(G===`pending`||G===`claimed`),K=!n&&!!i&&G===`pending`,me=pe||K,he=(0,q.useCallback)(t=>{(t===`done`?!pe:!K)||M(async()=>{let n=e?.title||`#${r}`,a={cwd:s?.cwd};if(t===`done`){let e=G===`claimed`,t=String(i?.claimedByName||i?.claimedBy||``).trim(),o=await z({title:`标为完成「${n}」`,message:e?`该任务正被${t?` ${t} `:` agent `}领取中。你是最终验收方——确认它已经做完、直接标为完成?可写一句完成总结(agent 稍后的回执会被忽略,不算冲突)。`:`任务还没被领取。确认把当前正文视为已完成?可写一句完成总结。`,input:!0,placeholder:`完成总结(可选;留空使用默认说明)`,okText:`标为完成`});if(o==null)return;await ce({...a,ids:[Number(r)],status:`done`,summary:String(o).trim()}),B(`已标为完成 #${r}`)}else{if(!await z({title:`取消任务「${n}」`,message:`只处理待领取任务。取消为终态,原文留档。`,danger:!0,okText:`取消任务`}))return;await ce({...a,ids:[Number(r)],status:`cancelled`}),B(`已取消 #${r}`)}T?.()})},[pe,K,e,r,s,G,i,T,M,B,z]),ge=!n&&!!i&&(G===`pending`||G===`plan`);return{composeText:H,goalPatchOf:U,submit:ue,importMd:W,delTask:de,canComplete:pe,canCancel:K,canCloseTask:me,closeTask:he,canPlan:ge,togglePlan:(0,q.useCallback)(()=>{if(!ge)return;let e=G===`plan`?`pending`:`plan`;M(async()=>{let t={cwd:s?.cwd};await se({...t,id:Number(r),to:e}),B(e===`plan`?`已把 #${r} 转成草稿态(不进队列)`:`已把 #${r} 转回待领取`),T?.()})},[ge,G,r,s,M,B,T]),addFiles:(0,q.useCallback)(async(i,a={})=>{if(!e)return;let{items:o,imageInserts:c,fileInserts:l}=await R(i),u=I(t)||e,d=u.body||``,f=c.join(``),p=d,m=null;if(f){let e=y(d,f,a);p=e.body,m=e.insertAt+f.length}l.length&&(p=y(p,l.join(``),{}).body);let h={};if(p!==d&&(h.body=p),o.length&&(h.attachments=[...u.attachments||[],...o]),Object.keys(h).length){if(F(t,h),a.mode===`edit`&&m!=null&&requestAnimationFrame(()=>{ee.current?.focus?.();let e=document.querySelector(`.mdw-editor`);if(e)try{e.setSelectionRange(m,m)}catch{}}),!n){h.attachments&&L(r,h.attachments);let e=H(u.title,h.body||p);F(t,{body:e,title:g(e)});try{await V({cwd:s?.cwd,id:Number(r),text:e}),A(!1),T?.(),B(o.length?`已添加附件并同步(${o.length})`:`已同步附件`)}catch(e){E(),B(`附件已插入,同步失败:${e.message||e}`)}return}E()}},[e,t,n,r,s,A,T,E,H,ee,B]),newTask:(0,q.useCallback)(()=>{let e=P(),t=N(re(f?p:o),e),n={};u&&u.board&&u.board.id&&(n.board=u.board.id),d.project&&(n.project=d.project),F(t,{title:``,body:m(w?w.defaultPick().body:``,n)}),b.openPage&&b.openPage(f?{groupId:p,task:e,name:`新任务`}:{dirKey:o,task:e,name:`新任务`})},[u,d.project,f,p,o,b,w]),cloneCur:(0,q.useCallback)(()=>{if(n||r==null||/^draft/i.test(String(r))){B(`草稿没有可克隆的队列任务`);return}M(async()=>{let t=await ye({id:Number(r),cwd:s?.cwd});B(`已克隆为新任务 #${t.task?.id??t.id}`),T?.();let n=t?.task?.id??t?.id;n!=null&&b.openPage&&(f?b.openPage({groupId:p,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(克隆)`}):b.openPage({dirKey:o,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(克隆)`}))})},[n,r,s,f,p,o,b,e,T,M,B]),forkCur:(0,q.useCallback)(()=>{if(n||r==null||/^draft/i.test(String(r))){B(`草稿没有可 Fork 的队列任务`);return}M(async()=>{let t=await be({id:Number(r),cwd:s?.cwd});B(`已 Fork 为新任务 #${t.task?.id??t.id}(保留任务链)`),T?.();let n=t?.task?.id??t?.id;n!=null&&b.openPage&&(f?b.openPage({groupId:p,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(Fork)`}):b.openPage({dirKey:o,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(Fork)`}))})},[n,r,s,f,p,o,b,e,T,M,B]),openProgress:(0,q.useCallback)(()=>{let e=S||b.model;if(!e)return;let t=d&&d.board?String(d.board):``;l(e,{component:`progress`,name:`进程`,config:t?{groupKey:t,task:r==null?void 0:String(r)}:{dirKey:o,task:r==null?void 0:String(r)},location:`right`})},[S,b.model,d,r,o]),openAttachPanel:(0,q.useCallback)(()=>{oe(`attach`),setTimeout(()=>k.current?.open(),0)},[oe,k])}}function Xe({doc:e,isDraft:t,task:n,taskRow:r,topicKey:i,topic:o,dirKey:s,groupAnchored:l,groupId:u,app:d,model:f,tabId:p,refreshLocal:m,closeSelMenu:h,lastSel:_,selMenu:v,dirty:y,setDirty:b,guard:x}){let S=a(),C=(0,q.useCallback)(async()=>{if(t||n==null||/^draft/i.test(String(n)))return null;let e=`cwd=${encodeURIComponent(o?.cwd||``)}&id=${Number(n)}`;return pe(e).catch(()=>null)},[t,n,o?.cwd]),w=(0,q.useCallback)(()=>{let t=f||d.model;t&&z(t,{mode:`feedback`,taskLabel:n==null?``:`#`+n,taskTitle:String(e?.title||``).replace(/^#+\s*/,``),prevQuote:String(r?.roundSummary||``).trim()||String(e?.body||``).trim().slice(0,400),src:{dirKey:i||s||``,task:String(n),name:`原文 #${n}`},onSubmit:e=>T(e)})},[f,d.model,n,e,r,i,s]),T=(0,q.useCallback)(({text:a,attachments:s=[],inserts:c=``}={})=>{let f=String(a||``).trim();if(h(),!f&&!(s&&s.length)){S(`写一下反馈`);return}let p=e?.title||`#${n}`;x(async()=>{let a=await C(),h=String(a?.text??``).trim()||String(e?.body??``).trim();if(!h&&!t){S(`拿不到任务当前正文,已取消反馈(防止丢内容)`);return}let _=f||`(见附件)`;c&&(_=`${_}${c}`);let v={base:h,feedback:_,ackSummary:a?.roundSummary||r?.roundSummary||``,feedbackHeading:ue,bold:!0},y=G(v),b=!t&&n!=null&&!/^draft/i.test(String(n))?{forkOf:String(n),forkKind:`reopen`}:{},x=await fe({cwd:o?.cwd,text:y,...b}),w=String(x?.task?.id??x?.id??``);if(!w){S(`反馈已提交,但未拿到新任务编号`),m?.();return}let T=x?.key||i;F(N(re(T),w),{title:g(y),body:y}),s?.length&&L(w,s),S(`已反馈「${p}」→ 新任务 #${w}`),m?.(),d.openPage&&(l?d.openPage({groupId:u,task:w,name:`${p.slice(0,24)}(反馈)`}):d.openPage({dirKey:T,task:w,name:`${p.slice(0,24)}(反馈)`}))})},[e,n,r,t,o,i,l,u,d,m,h,x,S,C]),E=(0,q.useCallback)(({text:r,attachments:a=[],inserts:s=``,quote:l}={})=>{let u=String(r||``).trim(),d=String(l||_.current||``).trim();if(h(),!u&&!(a&&a.length)){S(`写一下要提的问题`);return}if(!d&&!u){S(`先划选一段再评论`);return}if(t||n==null||/^draft/i.test(String(n))){S(`草稿先提交成任务再评论`);return}let v=e?.title||`#${n}`;x(async()=>{let t=!y&&!s&&!(a&&a.length),r;if(!t){let t=await C(),n=String(t?.text??``).trim()||String(e?.body??``).trim();if(!n){S(`拿不到任务当前正文,已取消评论(防止丢内容)`);return}let i={base:n,feedback:[W(d),u||`(见附件)`,s].filter(Boolean).join(`
|
|
10
|
-
|
|
11
|
-
`),ackSummary:``,feedbackHeading:de,bold:!1};r=G(i)}let l=await H({cwd:o?.cwd,id:Number(n),...r?{text:r}:{},kind:`comment`,quote:d,feedback:u,attachments:(a||[]).map(e=>({id:e.id,name:e.name,type:e.type,size:e.size,url:e.url||``}))}),h=l?.key||i,_=String(l?.task?.id??n),x=String(l?.task?.text??r??``);x&&F(N(re(h),_),{title:g(x),body:x}),a?.length&&L(_,[...e?.attachments||[],...a]),f&&p&&h!==i&&f.doAction(c.updateNodeAttributes(p,{config:{dirKey:h,task:_}})),b(!1),S(`已回写评论「${v}」#${_}`),m?.()})},[e,n,t,o,i,f,p,m,h,_,y,b,x,S,C]);return{fetchServerTask:C,openFeedback:w,spawnFeedbackTask:T,submitCommentInPlace:E,openCommentFromToolbar:(0,q.useCallback)(()=>{let t=String(window.getSelection()||``).trim()||(v?.text?String(v.text):``);if(!t){S(`先划选一段再评论`);return}_.current=t;let r=f||d.model;r&&(z(r,{mode:`comment`,quote:t,taskLabel:n==null?``:`#`+n,taskTitle:String(e?.title||``).replace(/^#+\s*/,``),src:{dirKey:i||s||``,task:String(n),name:`原文 #${n}`},onSubmit:e=>E({...e,quote:t})}),h())},[e,n,i,s,f,d.model,_,v,E,h,S])}}function Ze({doc:e,beside:t,topicKey:n,topic:r,task:i,app:a}){let o=(0,q.useMemo)(()=>e?_(e.body):{},[e&&e.body]);return{docFm:o,parentRef:(0,q.useMemo)(()=>{if(t)return null;let a=String(o.parent||``).trim(),s=String(o.parentDir||n||``).trim();if(a&&!/^draft/i.test(a))return{dirKey:s||n,task:a,name:`#${a}`};let c=String(e?.body||``).match(/>\s*锚定自「([^」]+)」/);if(!c)return null;let l=c[1];if(!l)return null;let u=l.trim(),d=(r?.tasks||[]).find(e=>String(e.id)===String(i)?!1:g(e.text||``)===u||String(e.text||``).includes(`# ${u}`));return d?{dirKey:n,task:String(d.id),name:`#${d.id}`}:null},[t,o.parent,o.parentDir,e?.body,n,r,i]),boardCtx:(0,q.useMemo)(()=>{let e=o.board;if(!e)return null;let t=(a.repoData&&a.repoData.boards||[]).find(t=>t.id===e||t.key===e||t.name===e);if(!t)return null;let n=a.repoData&&a.repoData.repos||[],r=new Map(n.map(e=>[e.key,e]));return{board:t,members:(t.repos||[]).map(e=>r.get(e.key)).filter(e=>!!e).map(e=>({key:e.key,name:e.name}))}},[o.board,a.repoData])}}var Qe=o;function $e({state:e,onClose:t}){let n=a(),r=e?.data,i=async()=>{try{await navigator.clipboard.writeText(String(r?.rendered||``)),n(`已复制原文`)}catch{n(`复制失败(剪贴板不可用)`)}},o=r?.switches||{},s=r?[`ack ${o.ack?.on?`开(${o.ack.count} 条)`:`关`}`,`模板 全部内置(插件类)`,`持续 get ${r.getLoop?.enabled?`开(${r.getLoop.waitMinutes} 分钟)`:`关`}`].join(` · `):``,c=r?`预览:agent 执行 get 会收到的提示词${r.task?.id?` · #${r.task.id}`:` · 草稿`}`:`预览:agent 执行 get 会收到的提示词`;return(0,J.jsxs)(Qe,{title:c,size:`wide`,onClose:t,footer:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`mdw-prev-hint`,children:`与 CLI 取任务共用同一份排版;不含「已取得下一条任务…」头部行。`}),(0,J.jsx)(`span`,{className:`grow`}),(0,J.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:i,disabled:!r,children:`复制原文`}),(0,J.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:t,children:`关闭`})]}),children:[e.busy&&(0,J.jsx)(`div`,{className:`mdw-prev-note`,children:`渲染中…`}),e.error&&(0,J.jsxs)(`div`,{className:`mdw-prev-note`,children:[`预览失败:`,e.error,/接口不存在/.test(String(e.error))&&(0,J.jsx)(`div`,{className:`mdw-prev-hint`,children:`本机面板服务较旧:重启面板(结束当前 serve 进程后重新启动)即可生效,刷新页面不够。`})]}),r&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`pre`,{className:`mdw-prev-body`,children:r.rendered||``}),r.segments?.length?(0,J.jsxs)(`details`,{className:`mdw-prev-seg`,children:[(0,J.jsxs)(`summary`,{children:[`段落来源(`,r.segments.length,` 段)`]}),(0,J.jsx)(`ol`,{children:r.segments.map((e,t)=>(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`span`,{className:`mdw-prev-seg-lab`,children:e.label}),(0,J.jsxs)(`span`,{className:`mdw-prev-seg-n`,children:[String(e.text||``).length,` 字`]})]},t))}),(0,J.jsx)(`div`,{className:`mdw-prev-note`,children:`改这些段去「设置 → 提示词 / 模板」;「持续 get」在项目级设置里。`})]}):(0,J.jsx)(`div`,{className:`mdw-prev-note`,children:`当前没有任何模板段:交付时就只有任务正文。`}),(0,J.jsx)(`div`,{className:`mdw-prev-switch`,children:s})]})]})}var et=k;function tt({attachments:e}){let t=e.filter(e=>e.kind===`mdfile`),[n,r]=(0,q.useState)(null),[i,a]=(0,q.useState)({}),o=async e=>{if(r(e),!i[e]||i[e].error){a(t=>({...t,[e]:{html:``,path:``,stale:!1,missing:!1,loading:!0}}));try{let t=await Se(e);a(n=>({...n,[e]:{html:p(String(t.body||``)),path:String(t.absPath||``),stale:!!t.stale,missing:!!t.missing}}))}catch(t){a(n=>({...n,[e]:{html:``,path:``,stale:!1,missing:!1,error:t.message||String(t)}}))}}};if(!t.length)return(0,J.jsx)(`div`,{className:`mdw-dock-empty`,children:"没有 md 附件——用 `nx-kv localtask attach --mdfile <本地 md 路径>` 挂一个外部 md 文件。"});let s=n?i[n]:null;return(0,J.jsxs)(`div`,{className:`mdw-md-tab`,children:[(0,J.jsx)(`div`,{className:`mdw-md-list`,role:`list`,children:t.map(e=>(0,J.jsxs)(`button`,{type:`button`,role:`listitem`,className:`mdw-md-item${n===String(e.id)?` is-on`:``}`,onClick:()=>o(String(e.id)),title:e.absPath||``,children:[(0,J.jsx)(`span`,{className:`mdw-md-item-name`,children:e.name||`md`}),(0,J.jsxs)(`span`,{className:`mdw-md-item-path mono`,children:[e.absPath||`(路径为空)`,e.missing?` · 文件已不在`:``]})]},String(e.id)))}),(0,J.jsxs)(`div`,{className:`mdw-md-view`,children:[n?null:(0,J.jsx)(`div`,{className:`mdw-dock-empty`,children:`选一条 md 看预览。`}),s?.loading?(0,J.jsx)(`div`,{className:`mdw-dock-empty`,children:`读取中…`}):null,s?.error?(0,J.jsxs)(`div`,{className:`mdw-dock-empty`,children:[`读取失败:`,s.error]}):null,s&&!s.loading&&!s.error?s.missing?(0,J.jsxs)(`div`,{className:`mdw-dock-empty`,children:[`源文件已不在:`,s.path||`(路径为空)`]}):(0,J.jsxs)(`div`,{className:`mdw-md-render`,children:[s.stale?(0,J.jsx)(`div`,{className:`att-md-warn`,children:`内容已变化(与登记指纹不一致),以下为磁盘当前内容。`}):null,(0,J.jsx)(`article`,{dangerouslySetInnerHTML:{__html:s.html}})]}):null]})]})}function nt({dockOpen:t,dockTab:n,dockH:r,dockRef:i,dockMax:a,showDockTab:o,onDockDragStart:s,toggleDockMax:c,setDockOpen:u,canShowGoalLog:d,goalLog:f,openGoalLog:p,isDraft:m,task:h,topic:g,topicKey:_,doc:v,id:y,model:b,app:x,refreshLocal:S,markDirty:w,saveDoc:T,persistAtt:E,attachAreaRef:D,reviewBarRef:O,reviewSumRef:ee,taskRow:k,ackOpen:A,setAckOpen:j,ackOverflow:te,ackLong:ne,ackHtml:re,isChainTip:ie,latestChild:ae,openFeedback:M,openLatestRound:N,attachments:P}){if(!t)return null;let F=P.filter(e=>e.kind===`mdfile`).length;return(0,J.jsxs)(`div`,{className:`mdw-dock`,ref:i,style:{height:`${r}px`},children:[(0,J.jsx)(`div`,{className:`mdw-dock-drag`,role:`separator`,"aria-orientation":`horizontal`,title:`上下拖动调整信息面板高度(双击最大化 / 还原)`,onMouseDown:s,onDoubleClick:c}),(0,J.jsxs)(`div`,{className:`mdw-dock-head`,children:[(0,J.jsxs)(`div`,{className:`mdw-dock-tabs`,role:`tablist`,"aria-label":`信息面板`,children:[(0,J.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`attach`,className:`mdw-dock-tab${n===`attach`?` is-on`:``}`,onClick:()=>o(`attach`),children:`附件`}),(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`md`,className:`mdw-dock-tab${n===`md`?` is-on`:``}`,onClick:()=>o(`md`),title:`只聚合 kind='mdfile' 的附件(md 预览)`,children:[`md`,F?(0,J.jsx)(`span`,{className:`mdw-dock-tab-num`,children:F}):null]}),d?(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`check`,className:`mdw-dock-tab${n===`check`?` is-on`:``}`,onClick:p,children:[`check`,(0,J.jsx)(`span`,{className:`mdw-dock-tab-num`,children:f.data?.count??0})]}):null,(0,J.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`feedback`,className:`mdw-dock-tab${n===`feedback`?` is-on`:``}`,onClick:()=>o(`feedback`),children:`反馈`})]}),(0,J.jsxs)(`div`,{className:`mdw-dock-acts`,children:[(0,J.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:c,title:a?`还原面板高度`:`最大化面板高度`,"aria-label":a?`还原面板高度`:`最大化面板高度`,children:(0,J.jsx)(e,{name:a?`collapse`:`expand`,title:void 0})}),(0,J.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:()=>u(!1),title:`关闭面板(底部状态栏仍保留入口)`,"aria-label":`关闭面板`,children:(0,J.jsx)(e,{name:`x`,title:void 0})})]})]}),(0,J.jsxs)(`div`,{className:`mdw-dock-body`,children:[n===`attach`?m?(0,J.jsx)(oe,{attachments:v.attachments,onRemove:e=>{let t=(v.attachments||[]).filter(t=>t.id!==e);w(),T(y,{attachments:t}),m||E(h,t)}}):g?(0,J.jsx)(et,{ref:D,host:`task`,hostId:Number(h),hostCwd:g.cwd,allow:{file:!0,url:!0,folder:!0,task:!0,ref:!0,repo:!0},taskOptions:(g.tasks||[]).map(e=>({id:e.id,text:e.text,status:e.status})),onChanged:S,onOpenTask:e=>{x.openPage&&e&&e.seq!=null&&x.openPage({dirKey:e.key||_,task:String(e.seq),name:`#${e.seq}`})},onOpenDoc:e=>{let t=C(e);b&&t&&l(b,{component:`doc`,name:e.split(`/`).pop()||e,config:{docId:t},location:`center`})}}):(0,J.jsx)(`div`,{className:`mdw-dock-empty`,children:`没有可挂载附件的上下文。`}):null,n===`md`?(0,J.jsx)(tt,{attachments:P}):null,n===`check`?(0,J.jsxs)(`div`,{className:`mdw-dock-check`,children:[f.busy&&!f.data?(0,J.jsx)(`div`,{className:`mdw-dock-empty`,children:`读取中…`}):null,f.error?(0,J.jsxs)(`div`,{className:`mdw-dock-empty`,children:[`读取失败:`,f.error]}):null,f.data?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`mdw-dock-meta mono`,children:[`时间目标 ${f.data.duration||`—`}`,f.data.startedAt?` · 开始 ${f.data.startedAt}`:``,f.data.deadline?` · 截止 ${f.data.deadline}`:` · 尚未开始计时`,f.data.archived?` · 已归档`:``,` · ${f.data.count||0} 轮`]}),(f.data.count||0)>0?(0,J.jsx)(`div`,{className:`mdw-goal-log`,children:f.data.entries.map((e,t)=>(0,J.jsxs)(`div`,{className:`mdw-goal-log-row`,children:[(0,J.jsxs)(`div`,{className:`mdw-goal-log-head mono`,children:[`R`,t+1,` · `,e.checkedAt,` · `,e.reached?`已到点`:`未到点`,` · 已用`,` `,K(e.elapsedSec),` · 剩余 `,K(e.remainingSec)]}),e.summary?(0,J.jsx)(`div`,{className:`mdw-goal-log-body`,children:e.summary}):null,e.progress?(0,J.jsx)(`div`,{className:`mdw-goal-log-prog`,children:e.progress}):null]},`${e.checkedAt}-${t}`))}):(0,J.jsx)(`div`,{className:`mdw-dock-empty`,children:`还没有 check 记录——任务领取后每轮 check 会出现在这里。`})]}):null]}):null,n===`feedback`?!m&&k?.completedAt?(0,J.jsxs)(`div`,{className:`mdw-review`,ref:O,children:[(0,J.jsxs)(`div`,{className:`mdw-review-main`,children:[(0,J.jsx)(`span`,{className:`mdw-review-badge`,children:`已完成 · 等待验收`}),(0,J.jsx)(`span`,{className:`mdw-review-at mono`,children:k.completedAt}),k.roundSummary?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{ref:ee,className:`mdw-review-sum${A?` is-open`:``}`,title:A||!(te||ne)?`agent 的完成总结(ack)`:`点击下方展开全文`,dangerouslySetInnerHTML:{__html:re}}),(te||ne||A)&&(0,J.jsx)(`button`,{type:`button`,className:`mdw-review-more`,onClick:()=>j(e=>!e),children:A?`收起`:`展开全文`})]}):null]}),(0,J.jsxs)(`div`,{className:`mdw-review-acts`,children:[(0,J.jsx)(`button`,{type:`button`,className:`ghost`,onClick:M,title:`新开一条任务携带反馈(原任务不动;链在此分叉成树)`,children:`反馈`}),!ie&&ae?(0,J.jsxs)(`button`,{type:`button`,className:`ghost`,onClick:N,title:`这条任务已有后续轮次——去最新一轮 #${ae.id}(反馈也可以留在这里,会从本节点分叉)`,children:[`去最新一轮 #`,ae.id]}):null]})]}):(0,J.jsx)(`div`,{className:`mdw-dock-empty`,children:`任务完成后,agent 的完成总结会显示在这里。`}):null]})]})}function rt({dockOpen:t,dockTab:n,showDockTab:r,setDockOpen:i,canShowGoalLog:a,goalLog:o,openGoalLog:s,isDraft:c,taskRow:l,mdCount:u=0}){return(0,J.jsxs)(`div`,{className:`mdw-sbar`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${t&&n===`attach`?` is-on`:``}`,onClick:()=>r(`attach`),title:`附件(点击展开信息面板)`,children:[(0,J.jsx)(e,{name:`list`,title:void 0}),(0,J.jsx)(`span`,{className:`mdw-sbar-lab`,children:`附件`})]}),(0,J.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${t&&n===`md`?` is-on`:``}`,onClick:()=>r(`md`),title:`md 附件预览(点击展开信息面板)`,children:[(0,J.jsx)(e,{name:`overview`,title:void 0}),(0,J.jsx)(`span`,{className:`mdw-sbar-lab`,children:`md`}),u>0?(0,J.jsx)(`span`,{className:`mdw-sbar-num`,children:u}):null]}),a?(0,J.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${t&&n===`check`?` is-on`:``}`,onClick:s,title:`时间目标每轮 check(点击展开信息面板)`,children:[(0,J.jsx)(e,{name:`clock`,title:void 0}),(0,J.jsx)(`span`,{className:`mdw-sbar-lab`,children:`check`}),(0,J.jsx)(`span`,{className:`mdw-sbar-num`,children:o.data?.count??0})]}):null,(0,J.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${t&&n===`feedback`?` is-on`:``}`,onClick:()=>r(`feedback`),title:`完成总结 / 反馈(点击展开信息面板)`,children:[(0,J.jsx)(e,{name:`edit`,title:void 0}),(0,J.jsx)(`span`,{className:`mdw-sbar-lab`,children:`反馈`})]}),(0,J.jsx)(`span`,{className:`mdw-sbar-grow`}),!c&&l?(0,J.jsx)(`span`,{className:`mdw-sbar-stat`,title:`任务状态`,children:(0,J.jsx)(D,{t:l,title:void 0})}):null,(0,J.jsx)(`button`,{type:`button`,className:`mdw-sbar-chev${t?` is-open`:``}`,onClick:()=>i(e=>!e),title:t?`收起信息面板`:`展开信息面板`,"aria-expanded":t,"aria-label":t?`收起信息面板`:`展开信息面板`,children:(0,J.jsx)(e,{name:`chevron`,title:void 0})})]})}function it({goal:e,setGoalDraft:t,goalEditable:n,goalPromptEditable:r,declaredGoal:i,openGoalLog:a,markDirty:o,task:s}){let c=(e.duration||``).trim(),l=(e.prompt||``).trim(),u=!!r;return{goalBadge:c||l?{label:`⏱ ${c||`目标`}`,title:l||(n?`任务级时间目标(在「更多」里设置;领取即计时)`:`已领取计时,时长不可改(附加要求仍可编辑)`)}:null,goalMenu:n||u||i?(0,J.jsxs)(`div`,{className:`mdw-goal-menu`,children:[(0,J.jsx)(`div`,{className:`mdw-goal-menu-lab`,children:`时间目标`}),n?(0,J.jsx)(`input`,{className:`mdw-goal-dur mono`,value:e.duration,placeholder:`2h / 90m / 30分钟,留空不带`,onChange:n=>{t({...e,duration:n.target.value}),o()}}):(0,J.jsxs)(`span`,{className:`mdw-goal-ro mono`,title:`已领取计时,时长不可改`,children:[i?.duration||`—`,` · 已领取计时`]}),u?(0,J.jsx)(`input`,{className:`mdw-goal-prompt`,value:e.prompt,placeholder:`附加要求(可选;领取后仍可改,下一轮 check 即生效)`,onChange:n=>{t({...e,prompt:n.target.value}),o()}}):i?.prompt?(0,J.jsx)(`span`,{className:`mdw-goal-ro`,title:`任务已到终态,附加要求不可改`,children:i.prompt}):null,i&&s!=null?(0,J.jsx)(`button`,{type:`button`,className:`ghost`,onClick:a,title:`查看时间目标的每轮 check 记录`,children:`查看每轮 check 日志`}):null]}):null}}var at={origin:`起点`,reopen:`反馈`,comment:`评论`};function ot({historyId:e,historyNode:t,closeBesideSelf:n}){let r=at[String(t?.kind??``)]||`节点`,i=t?me(t.text||``,t.attachments||[]):``;return(0,J.jsxs)(`div`,{className:`mdw is-beside`,children:[(0,J.jsxs)(`div`,{className:`mdw-beside-h`,children:[(0,J.jsxs)(`span`,{className:`mdw-beside-lab`,children:[`链节点 · `,r,` #`,e]}),(0,J.jsx)(`span`,{className:`grow`}),(0,J.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭`,"aria-label":`关闭`,onClick:n,children:`×`})]}),(0,J.jsx)(`div`,{className:`mdw-hist-ro`,children:t?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`mdw-hist-meta`,children:[(0,J.jsx)(`span`,{children:t.at||`—`}),t.quote?(0,J.jsxs)(`span`,{children:[`锚定:`,t.quote.slice(0,80)]}):null,t.feedback?(0,J.jsxs)(`span`,{children:[`反馈:`,t.feedback.slice(0,80)]}):null,t.summary?(0,J.jsxs)(`span`,{children:[`上轮总结:`,t.summary.slice(0,80)]}):null]}),(0,J.jsx)(`article`,{className:`md-body`,dangerouslySetInnerHTML:{__html:i||`<p class="muted">(空)</p>`}})]}):(0,J.jsxs)(`div`,{className:`muted`,children:[`找不到链节点 #`,e]})})]})}function st({boardCtx:e,docFm:t,projectEditable:n,doc:r,id:i,markDirty:a}){if(!e)return null;let o=e.members.find(e=>e.key===t.project);return(0,J.jsxs)(`div`,{className:`mdw-goal`,children:[(0,J.jsx)(`span`,{className:`mdw-goal-lab`,title:`归属项目(限本组成员):决定提交进哪个项目的队列;由组面板「新增任务」创建时自动携带本组语义`,children:`归属项目`}),n?(0,J.jsx)(`select`,{className:`mdw-proj-pick`,value:t.project||``,onChange:n=>{ge(e.board.id,n.target.value),F(i,{body:m(r.body,{...t,board:e.board.id,project:n.target.value})}),a()},children:e.members.map(e=>(0,J.jsx)(`option`,{value:e.key,children:e.name},e.key))}):(0,J.jsx)(`span`,{className:`mdw-proj-ro`,title:`归属项目(在本组创建时写入,随任务走)`,children:o?.name||t.project||`—`})]})}function ct({task:e,app:t,groupAnchored:n,groupId:r,dirKey:i}){return(0,J.jsx)(`div`,{className:`mdw`,children:(0,J.jsxs)(`div`,{className:`pad stack`,children:[(0,J.jsx)(`div`,{children:(0,J.jsxs)(`strong`,{children:[`找不到任务 #`,e]})}),(0,J.jsx)(`div`,{className:`hint`,children:`它可能已被删除(软删除可用 nx-kv localtask task restore 恢复),或这个深链写错了。`}),(0,J.jsx)(`div`,{children:(0,J.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>t.onNavigate&&t.onNavigate(n?`#/group/`+encodeURIComponent(r||``):`#/dir/`+encodeURIComponent(i||``)),children:`回到目录`})})]})})}function lt({onClose:e}){return(0,J.jsxs)(`div`,{className:`mdw-beside-h`,children:[(0,J.jsx)(`span`,{className:`mdw-beside-lab`,children:`原文(旁路)`}),(0,J.jsx)(`span`,{className:`grow`}),(0,J.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭原文面板`,"aria-label":`关闭原文面板`,onClick:e,children:`×`})]})}var ut=We;function dt({dirKey:e,groupId:t,task:n,beside:r=!1,tabId:o,model:s,historyId:l=null}){let p=f(),h=a(),{dialog:_,node:v}=i(),y=p.rows||[],x=p.refreshLocal,C=p.tpl,D=!(!t||e),O=(0,q.useMemo)(()=>D?he(y,p.repoData&&p.repoData.boards||[],t,n):null,[D,y,p.repoData,t,n]),k=O&&O.topic&&O.topic.key||e||``,j=ie(n),ae=re(D&&j?t:k),P=N(ae,n),I=(0,q.useMemo)(()=>D?O&&O.topic||null:y.find(e=>e.key===k)||null,[y,k,D,O]),R=(0,q.useMemo)(()=>(I?.tasks||[]).find(e=>String(e.id)===String(n))||null,[I,n]),oe=ne(),B=oe[P]||null,V=B&&B.mode===`edit`?`edit`:`split`,{dockOpen:H,setDockOpen:se,dockTab:U,dockH:ce,dockRef:le,dockMax:ue,showDockTab:W,onDockDragStart:de,toggleDockMax:fe}=A(),{goalDraft:G,setGoalDraft:pe,goal:K,goalEditable:ge,goalPromptEditable:_e,declaredGoal:ve,goalLog:ye,loadGoalLog:be,canShowGoalLog:Se}=Ge({id:P,isDraft:j,topicKey:k,task:n,taskRow:R}),{chainNodes:we,chainTree:Ee,historyNode:De,isChainTip:ke,latestChild:je,openLatestRound:Y,openHistoryBeside:Ne}=Ke({isDraft:j,task:n,taskRow:R,topicKey:k,topic:I,groupAnchored:D,groupId:t,app:p,model:s||null,historyId:l,toast:h}),{selMenu:X,setSelMenu:Pe,lastSel:Fe,placeSelMenu:Ie,onEditorTextSel:Le,closeSelMenu:Re}=qe({id:P}),{ackOpen:ze,setAckOpen:Be,ackOverflow:Ve,reviewSumRef:He,ackLong:Ue}=Je({id:P,taskRow:R,dockTab:U,dockOpen:H}),[We,Qe]=(0,q.useState)(null),[et,tt]=(0,q.useState)(!1),[at,dt]=(0,q.useState)(!1),[ft,pt]=(0,q.useState)(!1),mt=(0,q.useRef)(null),ht=(0,q.useRef)(null),gt=(0,q.useRef)(null),_t=(0,q.useRef)(null),vt=(0,q.useRef)(null),yt=(0,q.useRef)(null),bt=(0,q.useRef)(new Map),[Z,xt]=(0,q.useState)([]);(0,q.useEffect)(()=>{let e=!0,t=R;if(!t||!t.id)return;let n=new URLSearchParams({id:String(t.id)});return k?n.set(`key`,k):t.cwd&&n.set(`cwd`,t.cwd),xe(n.toString()).then(t=>{e&&xt(t&&(t.attachments||t.data?.attachments)||[])}).catch(()=>{e&&xt([])}),()=>{e=!1}},[R,k]);let St=(0,q.useMemo)(()=>B?me(b(B.body),Z.length?Z:B.attachments):``,[B,Z]),Ct=(0,q.useMemo)(()=>R?.roundSummary?me(R.roundSummary):``,[R?.roundSummary]),wt=(0,q.useMemo)(()=>B?Te(B.body):[],[B&&B.body]),[Tt,Et]=(0,q.useState)(null);(0,q.useEffect)(()=>{let e=_t.current;if(!e)return;let t=()=>e.closest(`.mdw-lp`)||e.closest(`.mdw-preview`)||null;Et(t());let n=typeof MutationObserver<`u`?new MutationObserver(()=>Et(t())):null;return n?.observe(e,{childList:!0,subtree:!0}),()=>n?.disconnect()},[B&&B.mode]);let Dt=(0,q.useCallback)(e=>e().catch(e=>h(String(e.message||e))),[h]),Q=(0,q.useCallback)(()=>pt(!0),[]),{docFm:Ot,parentRef:$,boardCtx:kt}=Ze({doc:B,beside:r,topicKey:k,topic:I,task:n,app:p});(0,q.useEffect)(()=>{oe[P]||(j?M(P,{title:``,body:C?m(C.defaultPick().body,D?{board:t}:{}):``}):R&&M(P,{title:g(R.text),body:R.text}))},[P,j,R,D,t]);let{composeText:At,submit:jt,importMd:Mt,delTask:Nt,canComplete:Pt,canCancel:Ft,closeTask:It,canPlan:Lt,togglePlan:Rt,addFiles:zt,newTask:Bt,cloneCur:Vt,forkCur:Ht,openProgress:Ut,openAttachPanel:Wt}=Ye({doc:B,id:P,isDraft:j,task:n,taskRow:R,topicKey:k,topic:I,boardCtx:kt,docFm:Ot,groupAnchored:D,groupId:t,app:p,model:s||null,tabId:o,tpl:C,refreshLocal:x,markDirty:Q,histRef:bt,editorApiRef:yt,attachAreaRef:gt,setDirty:pt,goal:K,goalEditable:ge,goalPromptEditable:_e,declaredGoal:ve,guard:Dt,dialog:_,showDockTab:W}),{openFeedback:Gt,submitCommentInPlace:Kt,openCommentFromToolbar:qt}=Xe({doc:B,isDraft:j,task:n,taskRow:R,topicKey:k,topic:I,dirKey:e,groupAnchored:D,groupId:t,app:p,model:s||null,tabId:o,refreshLocal:x,closeSelMenu:Re,lastSel:Fe,selMenu:X,dirty:ft,setDirty:pt,guard:Dt}),Jt=(0,q.useCallback)(()=>{W(`check`),be()},[W,be]),{goalBadge:Yt,goalMenu:Xt}=it({goal:K,goalDraft:G,setGoalDraft:pe,goalEditable:ge,goalPromptEditable:_e,declaredGoal:ve,openGoalLog:Jt,markDirty:Q,task:n}),Zt=(0,q.useCallback)(()=>{Qe({busy:!0}),Ce({cwd:I?.cwd,key:k,...j?{text:At((B?.title||``).trim()||`未命名任务`,B?.body||``)}:{id:Number(n)}}).then(e=>Qe({data:e})).catch(e=>Qe({error:String(e.message||e)}))},[I?.cwd,k,j,B?.title,B?.body,n,At]),Qt=(e,t=`typing`)=>{if(!B)return;T(bt.current,P,{title:B.title,body:B.body},t),Q();let n={title:e};V!==`split`&&/^# (?!#)/m.test(B.body)&&(n.body=B.body.replace(/^# (?!#).+$/m,`# ${e||`未命名任务`}`)),F(P,n)},$t=(e,t=`op`)=>{if(!B)return;T(bt.current,P,{title:B.title,body:B.body},t),Q();let n={body:e};V!==`split`&&(n.title=g(e)),F(P,n)},en=()=>{if(!B)return;let e=w(bt.current,P,{title:B.title,body:B.body});e&&(F(P,{title:e.title,body:e.body}),Q(),requestAnimationFrame(()=>yt.current?.caretFromDiff?.(B.body,e.body)))},tn=()=>{if(!B)return;let e=E(bt.current,P,{title:B.title,body:B.body});e&&(F(P,{title:e.title,body:e.body}),Q(),requestAnimationFrame(()=>yt.current?.caretFromDiff?.(B.body,e.body)))},nn=e=>{if(!B||V===`edit`)return;let t=e.target instanceof Element?e.target:null;if(t?.closest(`#mdw-sel-menu`)||t?.closest(`textarea`))return;let n=window.getSelection(),r=String(n||``).trim();if(!r||r.length<1){Pe(null);return}if(!n)return;if(!_t.current?.contains(n.anchorNode)){Pe(null);return}let i=e=>e?.nodeType===3?e.parentElement:e,a=i(n.anchorNode)?.closest?.(`.mdw-lp-block`),o=i(n.focusNode)?.closest?.(`.mdw-lp-block`),s=null;if(a&&o&&a!==o&&_t.current?.contains(o)){let e=Number(a.getAttribute(`data-i`)),t=Number(o.getAttribute(`data-i`));Number.isInteger(e)&&Number.isInteger(t)&&e!==t&&(s=[Math.min(e,t),Math.max(e,t)])}let c=n.getRangeAt(0),l=c.getClientRects(),u=l[l.length-1]??c.getBoundingClientRect();Ie(`task`,r,u.right-60,u.bottom+8,s?{blockRange:s}:{})},rn=(0,q.useCallback)(()=>{if(!$){h(`这条任务没有可定位的原文`);return}let e=s||p.model;e&&d(e,{component:`page`,name:$.name||`原文 ${$.task}`,config:{dirKey:$.dirKey,task:String($.task)}})},[$,s,p.model,h]),an=(0,q.useCallback)(()=>{let e=s||p.model;e&&o&&e.doAction(c.deleteTab(o))},[s,p.model,o]),on=e=>{ht.current&&(ht.current.accept=e),ht.current?.click()};return(0,q.useEffect)(()=>{if(!$||r)return;let e=e=>{(e.ctrlKey||e.metaKey)&&e.shiftKey&&String(e.key||``).toLowerCase()===`o`&&(e.preventDefault(),rn())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[$,r,rn]),l==null?B?(0,J.jsxs)(`div`,{className:`mdw${r?` is-beside`:``}`,"data-mode":V,onMouseUp:nn,children:[v,We&&(0,J.jsx)($e,{state:We,onClose:()=>Qe(null)}),(0,J.jsx)(ut,{open:at,nodes:we,tree:Ee,onOpenNode:Ne,onClose:()=>dt(!1)}),r&&(0,J.jsx)(lt,{onClose:an}),(0,J.jsxs)(`div`,{className:`mdw-main`,children:[(0,J.jsxs)(`div`,{className:`mdw-top`,children:[(0,J.jsx)(te,{}),(0,J.jsxs)(`div`,{className:`mdw-head`,children:[(0,J.jsx)(`div`,{className:`mdw-title`,children:j?B.title||`新 MD 任务`:B.title||`任务`}),(0,J.jsxs)(`div`,{className:`mdw-path`,children:[I?.cwd||I?.name||`—`,I?.cwdExists===!1&&(0,J.jsxs)(`span`,{className:`mdw-path-warn`,title:`工作目录已不存在:目录被删除或磁盘未挂载。任务本身还在,只是不再有对应目录。`,children:[` `,`· 目录已不存在`]}),j?` / (${n})`:` / #${n}`,ft?` · 未保存`:``]})]})]}),(0,J.jsx)(st,{boardCtx:kt,docFm:Ot,projectEditable:j||!R||R.status===`pending`||R.status===`plan`,doc:B,id:P,markDirty:Q}),(0,J.jsx)(u,{mode:V,onMode:e=>F(P,{mode:e}),showMark:V!==`edit`,submitLabel:j?`提交为任务`:`保存并同步`,onNew:Bt,onSubmit:jt,onChain:j?null:()=>dt(!0),onPreview:Zt,onImg:()=>on(`image/*`),onAtt:()=>j?on(`image/*,.pdf,.zip,.txt,.json,.csv`):Wt(),onImport:()=>mt.current?.click(),onClone:j?null:Vt,onFork:j?null:Ht,onComplete:Pt?()=>It(`done`):null,onPlan:Lt?Rt:null,planLabel:String(R?.status||``)===`plan`?`转回待领取`:`转为草稿(plan)`,onCancelTask:Ft?()=>It(`cancel`):null,onMark:qt,onDraft:()=>h(`草稿随页签保留(刷新后需从侧栏或页签重新打开)`),onDelete:j?null:Nt,onOverview:()=>p.onNavigate&&p.onNavigate(`#/overview`),onProg:Ut,onSource:$?rn:null,onShortcuts:()=>tt(!0),goalBadge:Yt,goalMenu:Xt}),(0,J.jsx)(S,{ref:_t,mode:V,title:B.title,body:B.body,previewHtml:St,onTitle:Qt,onBody:$t,attachments:Z.length?[...B.attachments,...Z]:B.attachments,docKey:P,editorApiRef:yt,onFiles:zt,onTextSel:Le,onSave:jt,onUndo:en,onRedo:tn,onCloseSelMenu:Re,attachHost:j?null:{host:`task`,hostId:Number(n),hostCwd:I?.cwd,allow:{file:!0,url:!0,folder:!0,task:!0,ref:!0,repo:!0},taskOptions:(I?.tasks||[]).map(e=>({id:e.id,text:e.text,status:e.status}))}}),(0,J.jsx)(nt,{dockOpen:H,dockTab:U,dockH:ce,dockRef:le,dockMax:ue,showDockTab:W,onDockDragStart:de,toggleDockMax:fe,setDockOpen:se,canShowGoalLog:Se,goalLog:ye,openGoalLog:Jt,isDraft:j,task:n,topic:I,topicKey:k,doc:B,id:P,model:s||null,app:p,refreshLocal:x,markDirty:Q,saveDoc:F,persistAtt:L,attachAreaRef:gt,reviewBarRef:vt,reviewSumRef:He,taskRow:R,ackOpen:ze,setAckOpen:Be,ackOverflow:Ve,ackLong:Ue,ackHtml:Ct,isChainTip:ke,latestChild:je,openFeedback:Gt,openLatestRound:Y,attachments:Z.length?Z:B.attachments}),(0,J.jsx)(rt,{dockOpen:H,dockTab:U,showDockTab:W,setDockOpen:se,canShowGoalLog:Se,goalLog:ye,openGoalLog:Jt,isDraft:j,taskRow:R,mdCount:(Z.length?Z:B.attachments).filter(e=>e.kind===`mdfile`).length})]}),(0,J.jsx)(Oe,{nodes:wt,scrollRoot:Tt}),(0,J.jsx)(Ae,{at:X,onFormat:e=>{yt.current?.format?.(e),Re()},onCompose:()=>{let t=s||p.model;if(!t)return;let r=String(X?.text||Fe.current||``);z(t,{mode:`comment`,quote:r,taskLabel:n==null?``:`#`+n,taskTitle:String(B?.title||``).replace(/^#+\s*/,``),src:{dirKey:k||e||``,task:String(n),name:`原文 #${n}`},onSubmit:e=>Kt({...e,quote:r})}),Re()},onCopy:()=>{let e=X?.blockRange,t=``;if(e&&B){let n=ee(B.body);e[1]<n.length&&(t=n.slice(e[0],e[1]+1).filter(e=>String(e??``).trim()).join(`
|
|
12
|
-
|
|
13
|
-
`))}navigator.clipboard?.writeText(t||Fe.current||X?.text||``),h(`已复制`),Re()},onDelete:X?.blockRange?()=>{let e=X.blockRange;e&&(yt.current?.deleteBlockRange?.(e[0],e[1])?h(`已删除 ${e[1]-e[0]+1} 个块(Ctrl+Z 可撤销)`):h(`选区已失效`),Re())}:void 0}),(0,J.jsx)(`input`,{ref:ht,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,t.length&&zt(t)}}),(0,J.jsx)(`input`,{ref:mt,type:`file`,accept:`.md,text/markdown,text/plain`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&Mt(t)}}),et&&(0,J.jsx)(Me,{onClose:()=>tt(!1)})]}):p.localReady===!1||j?(0,J.jsx)(`div`,{className:`mdw`,children:(0,J.jsx)(`div`,{className:`pad muted`,children:`载入中…`})}):(0,J.jsx)(ct,{task:n,app:p,groupAnchored:D,groupId:t,dirKey:e}):(0,J.jsx)(ot,{historyId:l,historyNode:De,closeBesideSelf:an})}export{dt as default};
|