lantern-harness 0.1.7 → 0.1.9
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 +33 -0
- package/README.md +2 -2
- package/cli/server.mjs +2 -0
- package/config/app.defaults.json +1 -0
- package/dist/500.html +3 -3
- package/dist/_astro/Base.4X_wsSoR.css +1 -0
- package/dist/_astro/Base.astro_astro_type_script_index_0_lang.Dy7fJoxu.js +1 -0
- package/dist/_astro/{CaseExecBoard.BAV4EE3o.js → CaseExecBoard.DKdfW5fM.js} +1 -1
- package/dist/_astro/{CaseGenerateApp.Bz4ryNJG.js → CaseGenerateApp.Bm8AyH9s.js} +1 -1
- package/dist/_astro/{CasesLibrary.BPifyHUA.js → CasesLibrary.CvVJZ74h.js} +1 -1
- package/dist/_astro/{ChatApp.DLo31SYZ.js → ChatApp.BS-wLBRa.js} +3 -3
- package/dist/_astro/{DashboardBoard.DtuJX0Oi.js → DashboardBoard.DCtfrrJz.js} +2 -2
- package/dist/_astro/{DocsFileBrowser.D3cKurQE.js → DocsFileBrowser.BtRoZ787.js} +1 -1
- package/dist/_astro/{DocsPager.rzu4mnzw.js → DocsPager.C20ue_JZ.js} +1 -1
- package/dist/_astro/{KnowledgeLibrary.B0sO4QR1.js → KnowledgeLibrary.CV4DyStj.js} +1 -1
- package/dist/_astro/{NavLibraries.Cvg3wery.js → NavLibraries.DmD2lZBZ.js} +1 -1
- package/dist/_astro/PluginsPage.B59AMDrB.js +1 -0
- package/dist/_astro/{PluginsPage.DIltPILi.js → PluginsPage.BEAPymNL.js} +1 -1
- package/dist/_astro/PmBugsBoard.CPEyBp0l.js +1 -0
- package/dist/_astro/PmIterationsBoard.zCeLpcBo.js +1 -0
- package/dist/_astro/{PmProjectDetail.DqDoIg8a.js → PmProjectDetail.ejIam5sD.js} +1 -1
- package/dist/_astro/{PmProjectsBoard.nOC1Hugt.js → PmProjectsBoard.DbXzir8o.js} +1 -1
- package/dist/_astro/PmRequirementsBoard.CynewRfv.js +1 -0
- package/dist/_astro/PmRequirementsBoard.D9eUMJWI.js +1 -0
- package/dist/_astro/{PmShared.CZnXaUq-.js → PmShared.BxTHKdjY.js} +1 -1
- package/dist/_astro/{PromptsLibrary.DU9EuSim.js → PromptsLibrary.Bkruu80b.js} +1 -1
- package/dist/_astro/{ReportsPage.Cr88iz8c.js → ReportsPage.BoBQshMQ.js} +1 -1
- package/dist/_astro/{RequirementsLibrary.BwriF8F0.js → RequirementsLibrary.BC0A8qdk.js} +1 -1
- package/dist/_astro/{SearchableSelect.Ctg8V1Z1.js → SearchableSelect.CXa1hiDd.js} +1 -1
- package/dist/_astro/SettingsDialog.Dc-9QNJI.js +1 -0
- package/dist/_astro/{SpaceSwitcher.BEJo5KFi.js → SpaceSwitcher.CI3KDBOA.js} +1 -1
- package/dist/_astro/{TasksBoard.BZi_GBPG.js → TasksBoard.Bb--oVV8.js} +1 -1
- package/dist/_astro/{TemplatesLibrary.T4K9jUex.js → TemplatesLibrary.D1wZq94E.js} +1 -1
- package/dist/_astro/{TestStatsBoard.Dd1Kcmx6.js → TestStatsBoard.DlVezlXl.js} +1 -1
- package/dist/_astro/{TodosBoard.C4yd_JFb.js → TodosBoard.S84wqcWY.js} +1 -1
- package/dist/_astro/UiAutoBoard.BKp9ifxg.js +1 -0
- package/dist/_astro/app-config.DUyozIL9.js +1 -0
- package/dist/_astro/i18n.B52gLzii.js +7 -0
- package/dist/_astro/{open-docs-in-session.B0ZdZNj2.js → open-docs-in-session.Xg3OSOfc.js} +1 -1
- package/dist/_astro/{plugins.D5ypJIXn.js → plugins.BDZqJNOy.js} +1 -1
- package/dist/_astro/{pm.BsnTv63L.js → pm.Bl3hz9fF.js} +4 -4
- package/dist/_astro/{settings.CnDCvwnQ.js → settings.C6NWuiFO.js} +2 -2
- package/dist/_astro/{spaces-client.Cai2tHEI.js → spaces-client.k_ciWMai.js} +1 -1
- package/dist/_astro/update.Bl_HfSe6.js +1 -0
- package/dist/_astro/{view-prefs.HCowOWXL.js → view-prefs.Dyu_lmN2.js} +1 -1
- package/dist/case-exec/index.html +4 -4
- package/dist/cases/generate/index.html +4 -4
- package/dist/cases/library/index.html +4 -4
- package/dist/dashboard/index.html +4 -4
- package/dist/docs/changelog/index.html +33 -4
- package/dist/docs/install/index.html +3 -3
- package/dist/docs/manual/index.html +24 -6
- package/dist/index.html +4 -4
- package/dist/knowledge/index.html +4 -4
- package/dist/knowledge//345/212/237/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/347/274/226/345/206/231/350/247/204/350/214/203/index.html +3 -3
- package/dist/plugins/index.html +4 -4
- package/dist/pm/bugs/index.html +4 -4
- package/dist/pm/iterations/index.html +4 -4
- package/dist/pm/projects/detail/index.html +4 -4
- package/dist/pm/projects/index.html +4 -4
- package/dist/pm/requirements/index.html +4 -4
- package/dist/prompts/index.html +4 -4
- package/dist/reports/index.html +4 -4
- package/dist/requirements/index.html +4 -4
- package/dist/tasks/index.html +4 -4
- package/dist/templates/index.html +4 -4
- package/dist/templates//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +3 -3
- package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +3 -3
- package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +3 -3
- package/dist/templates//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +3 -3
- package/dist/templates//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +3 -3
- package/dist/test-stats/index.html +4 -4
- package/dist/todos/index.html +4 -4
- package/dist/ui-automation/index.html +281 -0
- package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +17 -3
- package/lh-plugins/lh-uiauto.mjs +1237 -0
- package/lh-plugins/storage-domain.mjs +7 -0
- package/lh-plugins/uiauto-argv-guard.cjs +41 -0
- package/package.json +1 -1
- package/dist/_astro/Base.Bum3N3jp.css +0 -1
- package/dist/_astro/Base.astro_astro_type_script_index_0_lang.D0snmAJ_.js +0 -1
- package/dist/_astro/PluginsPage.uvmSuXzi.js +0 -1
- package/dist/_astro/PmBugsBoard.CiaIhCHv.js +0 -1
- package/dist/_astro/PmIterationsBoard.H67QwKFw.js +0 -1
- package/dist/_astro/PmRequirementsBoard.BPjZ7khP.js +0 -1
- package/dist/_astro/PmRequirementsBoard.CanxvcKg.js +0 -1
- package/dist/_astro/SettingsDialog.kpJwoEl3.js +0 -1
- package/dist/_astro/app-config.DKMxjv3g.js +0 -1
- package/dist/_astro/i18n.BXeGGutk.js +0 -7
- package/dist/_astro/update.DXCPfU4a.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{p as n}from"./app-config.
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{p as n}from"./app-config.DUyozIL9.js";import{a as r,n as i,o as a,r as o}from"./view-prefs.Dyu_lmN2.js";import{t as s}from"./jsx-runtime.BUXbF_vF.js";import{n as c,t as l}from"./DocsPager.C20ue_JZ.js";import{t as u}from"./SelectDropdown.Buv7rQJ_.js";import{t as d}from"./OverflowHint.lzmplP5j.js";import{t as f}from"./useListAnim.CpGB1cft.js";var p=`tw.docs.files.v1.`;function m(e){try{let t=sessionStorage.getItem(n(p+e));if(!t)return null;let r=JSON.parse(t);return Array.isArray(r)?r:null}catch{return null}}function h(e,t){try{sessionStorage.setItem(n(p+e),JSON.stringify(t))}catch{}}var g=e(t(),1);function _(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function v(e){if(!e)return`—`;try{return new Date(e).toLocaleString(`zh-CN`,{hour12:!1,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}catch{return`—`}}var y=s(),b=[{value:`mtime`,label:`按修改时间`},{value:`name`,label:`按文件名`}],x=b.map(e=>e.value),S=`h-8 px-3 text-sm border border-stone-300 rounded-lg bg-white text-stone-800 focus:outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6]`,C=`transition-colors duration-150 hover:bg-stone-50 hover:shadow-[inset_3px_0_0_0_var(--tw-accent)] cursor-pointer`,w=`w-38 shrink-0`,T=`w-16 shrink-0 text-left`,E=`w-40 shrink-0 text-right`,D=`text-sm text-stone-400 py-10 text-center border border-dashed border-stone-200 rounded-lg`;function O(e,t,n){let[s,l]=(0,g.useState)(()=>n?o(`docs.${n}.search`):``),[u,d]=(0,g.useState)(()=>n?i(`docs.${n}.sort`,x,`mtime`):`mtime`),[f,p]=(0,g.useState)(1),[m,h]=c(t),_=(0,g.useMemo)(()=>{let t=s.trim().toLowerCase(),n=[...t?e.filter(e=>e.name.toLowerCase().includes(t)||e.path.toLowerCase().includes(t)):e];return u===`name`?n.sort((e,t)=>e.name.localeCompare(t.name,`zh`)):n.sort((e,t)=>(t.mtime??0)-(e.mtime??0)),n},[e,s,u]),v=Math.max(1,Math.ceil(_.length/m)),y=Math.min(f,v);return{query:s,setQuery:e=>{l(e),n&&a(`docs.${n}.search`,e),p(1)},sortBy:u,setSortBy:e=>{d(e),n&&r(`docs.${n}.sort`,e),p(1)},page:y,setPage:p,pageSize:m,setPageSize:e=>{h(e),p(1)},filtered:_,totalPages:v,pageFiles:(0,g.useMemo)(()=>_.slice((y-1)*m,y*m),[_,y,m])}}function k({files:e,filtered:t,pageFiles:n,query:r,onQuery:i,sortBy:a,onSortBy:o,page:s,totalPages:c,pageSize:p,onPage:m,onPageSize:h,busy:g=!1,emptyText:x,searchPlaceholder:O,selectAllLabel:k=`全选本页`,renderBadge:A,renderActions:j,onRowDoubleClick:M,selectable:N,selected:P,onToggleRow:F,onSelectPage:I}){let L=N??(()=>!0),R=n.filter(L),z=R.length>0&&R.every(e=>P[e.path]),B=!z&&R.some(e=>P[e.path]),{cls:V,play:H}=f(),U=e=>{H(),i(e)};return(0,y.jsxs)(y.Fragment,{children:[e.length>0?(0,y.jsxs)(`div`,{className:`shrink-0 px-4 py-2 border-b border-stone-100 bg-stone-50/60 flex items-center gap-2 flex-wrap`,children:[(0,y.jsx)(`input`,{type:`search`,value:r,onChange:e=>U(e.target.value),placeholder:O,"aria-label":O,className:`${S} flex-1 min-w-48`}),(0,y.jsx)(u,{compact:!0,options:b,value:a,onChange:e=>{H(),o(e)},ariaLabel:`排序方式`,showCheck:!1,className:`w-34 shrink-0`})]}):null,(0,y.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4`,children:e.length===0?(0,y.jsx)(`p`,{className:D,children:x}):t.length===0?(0,y.jsxs)(`p`,{className:D,children:[`没有匹配「`,r.trim(),`」的文件。`]}):(0,y.jsxs)(`ul`,{className:`${V}divide-y divide-stone-100 border border-stone-200 rounded-lg overflow-hidden`,children:[(0,y.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 bg-stone-50 text-xs text-stone-500`,children:[(0,y.jsx)(`input`,{type:`checkbox`,checked:z,ref:e=>{e&&(e.indeterminate=B)},onChange:()=>I(R.map(e=>e.path),!z),disabled:g||R.length===0,className:`rounded border-stone-300`,"aria-label":k}),(0,y.jsx)(`span`,{className:`flex-1 min-w-0`,children:`文件名`}),(0,y.jsx)(`span`,{className:w,children:`创建时间`}),(0,y.jsx)(`span`,{className:w,children:`修改时间`}),(0,y.jsx)(`span`,{className:T,children:`大小`}),(0,y.jsx)(`span`,{className:E,children:`操作`})]}),n.map(e=>{let t=L(e);return(0,y.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2.5 ${C}`,onDoubleClick:M?()=>M(e):void 0,children:[(0,y.jsx)(`input`,{type:`checkbox`,checked:!!P[e.path],disabled:g||!t,onChange:()=>F(e.path),onDoubleClick:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:`rounded border-stone-300`,"aria-label":`选择 ${e.name}`}),(0,y.jsxs)(`div`,{className:`flex-1 min-w-0 text-left flex items-center gap-2`,children:[(0,y.jsx)(d,{text:e.name,className:`text-sm text-stone-800 truncate`}),A?A(e):null]}),(0,y.jsx)(`span`,{className:`${w} text-[11px] text-stone-500 tabular-nums`,children:v(e.ctime??e.mtime)}),(0,y.jsx)(`span`,{className:`${w} text-[11px] text-stone-500 tabular-nums`,children:v(e.mtime)}),(0,y.jsx)(`span`,{className:`${T} text-[11px] text-stone-400`,children:_(e.size)}),(0,y.jsx)(`div`,{className:`${E} flex justify-end gap-1 flex-wrap`,onDoubleClick:e=>e.stopPropagation(),children:j(e)})]},e.path)})]})}),e.length>0?(0,y.jsx)(l,{page:s,totalPages:c,pageSize:p,busy:g,onPage:e=>{H(),m(e)},onPageSize:e=>{H(),h(e)}}):null]})}export{h as i,O as n,m as r,k as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{p as n}from"./app-config.
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{p as n}from"./app-config.DUyozIL9.js";import{t as r}from"./jsx-runtime.BUXbF_vF.js";import{t as i}from"./SelectDropdown.Buv7rQJ_.js";var a=e(t(),1),o=[5,10,20,50],s=`tw.docs.page-size.v1`;function c(e){return typeof e==`number`&&o.includes(e)}function l(e,t=s){try{let r=localStorage.getItem(n(t)),i=r===null?NaN:Number(r);return c(i)?i:e}catch{return e}}function u(e,t=s){if(c(e))try{localStorage.setItem(n(t),String(e))}catch{}}var d=r(),f=`h-8 px-3 shrink-0 whitespace-nowrap text-sm text-stone-600 border border-stone-200 rounded-lg hover:bg-stone-50 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer`,p=o.map(e=>({value:String(e),label:String(e)}));function m(e,t){let[n,r]=(0,a.useState)(()=>l(e,t));return[n,(0,a.useCallback)(e=>{c(e)&&(u(e,t),r(e))},[t])]}function h({page:e,totalPages:t,pageSize:n,busy:r=!1,onPage:a,onPageSize:o}){return(0,d.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-t border-stone-100 flex items-center justify-between gap-2 flex-wrap`,children:[(0,d.jsxs)(`span`,{className:`text-xs text-stone-500 flex items-center gap-1.5`,children:[(0,d.jsxs)(`span`,{children:[`第 `,e,` / `,t,` 页 ·`]}),(0,d.jsx)(i,{compact:!0,centerContent:!0,options:p,value:String(n),onChange:e=>o(Number(e)),disabled:r,ariaLabel:`每页条数`,showCheck:!1,className:`w-18`}),(0,d.jsx)(`span`,{children:`条`})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,d.jsx)(`button`,{type:`button`,disabled:r||e<=1,onClick:()=>a(1),className:f,children:`首页`}),(0,d.jsx)(`button`,{type:`button`,disabled:r||e<=1,onClick:()=>a(e-1),className:f,children:`上一页`}),(0,d.jsx)(`button`,{type:`button`,disabled:r||e>=t,onClick:()=>a(e+1),className:f,children:`下一页`}),(0,d.jsx)(`button`,{type:`button`,disabled:r||e>=t,onClick:()=>a(t),className:f,children:`末页`})]})]})}export{m as n,h as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.DUyozIL9.js";import{a as r,o as i,r as a}from"./plugins.BDZqJNOy.js";import{t as o}from"./jsx-runtime.BUXbF_vF.js";import{t as s}from"./ConfirmDialog.CBVsDJ8f.js";import{l as c,n as l,r as u,s as d}from"./project-docs.Cd2gKPKh.js";import{n as f}from"./doc-roots.DAJP9Svr.js";import{i as p,n as m,r as h,t as g}from"./DocsFileBrowser.BtRoZ787.js";import{t as _,u as v}from"./open-docs-in-session.Xg3OSOfc.js";var y=e(t(),1),b=o(),x=10;async function S(e=`.`){let{entries:t}=await d(`knowledge`,e),n=[];for(let e of t)e.type===`file`?e.name.endsWith(`.md`)&&n.push(e):n.push(...await S(e.path));return n}function C({staticCount:e=0,base:t}){let o=h(`knowledge`),[d,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(!0),[E,D]=(0,y.useState)(o?!0:null),[O,k]=(0,y.useState)(()=>o??[]),[A,j]=(0,y.useState)(null),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)({}),[I,L]=(0,y.useState)(null),R=m(O,x,`knowledge`),z=(0,y.useCallback)(async()=>{j(null);try{let e=await S(`.`);k(e),p(`knowledge`,e)}catch(e){j(e instanceof Error?e.message:String(e))}},[]);(0,y.useEffect)(()=>{let e=r(e=>T(!!e.knowledgeLib));return n().then(()=>{T(a(`knowledgeLib`)),C(!0)}),e},[]),(0,y.useEffect)(()=>{d&&w&&(async()=>{await u(`knowledge`)?(await v().catch(()=>null),await z(),D(!0)):D(!1)})()},[d,w,z]);let B=(0,y.useMemo)(()=>Object.keys(P).filter(e=>P[e]),[P]);function V(){a(`knowledgeGen`)?window.location.href=`${t}?plugin=knowledgeGen`:j(i(`knowledgeGen`))}async function H(e){N(!0),j(null);try{await c(`knowledge`,e.path)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}async function U(e){N(!0),j(null);try{await _(`knowledge`,e)}catch(e){j(e instanceof Error?e.message:String(e)),N(!1)}}async function W(){let e=I;if(e){L(null),N(!0),j(null);try{if(e.kind===`one`)await l(`knowledge`,e.entry.path);else{for(let t of e.paths)await l(`knowledge`,t);F({})}await z()}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}let G=I?.kind===`one`?`删除「${I.entry.name}」?将从 ${f(`knowledge`)} 中移除。`:I?.kind===`batch`?`确认删除已选中的 ${I.paths.length} 个知识库文件?此操作不可恢复。`:``;return d?w?E===null?(0,b.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,b.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,b.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):E?(0,b.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,children:[(0,b.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,b.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0`,children:[R.query.trim()?(0,b.jsxs)(b.Fragment,{children:[`匹配 `,(0,b.jsx)(`span`,{className:`font-medium text-stone-800`,children:R.filtered.length}),` 个`,(0,b.jsxs)(`span`,{className:`text-stone-400`,children:[` · 共 `,O.length]})]}):(0,b.jsxs)(b.Fragment,{children:[`共 `,(0,b.jsx)(`span`,{className:`font-medium text-stone-800`,children:O.length}),` 个知识库文件`]}),B.length>0?(0,b.jsxs)(`span`,{className:`text-stone-400`,children:[` · 已选 `,B.length]}):null]}),(0,b.jsx)(`button`,{type:`button`,disabled:M||B.length===0,onClick:()=>L({kind:`batch`,paths:B}),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-red-600 border border-red-200 rounded-lg hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,b.jsx)(`button`,{type:`button`,disabled:M,onClick:V,className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`生成知识库`})]}),A?(0,b.jsx)(`div`,{className:`shrink-0 mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:A}):null,(0,b.jsx)(g,{files:O,filtered:R.filtered,pageFiles:R.pageFiles,query:R.query,onQuery:R.setQuery,sortBy:R.sortBy,onSortBy:R.setSortBy,page:R.page,totalPages:R.totalPages,pageSize:R.pageSize,onPage:R.setPage,onPageSize:R.setPageSize,busy:M,emptyText:`暂无知识库文件,点击「生成知识库」前往我的工作台。`,searchPlaceholder:`搜索文件名或路径…`,selected:P,onToggleRow:e=>F(t=>({...t,[e]:!t[e]})),onSelectPage:(e,t)=>F(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r}),onRowDoubleClick:e=>void H(e),renderBadge:e=>{let t=e.path.includes(`/`)?e.path.split(`/`)[0]:``;return t?(0,b.jsx)(`span`,{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded bg-amber-50 text-amber-800 border border-amber-100`,children:t}):null},renderActions:e=>(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>void U(e),className:`text-xs whitespace-nowrap text-white bg-[#4176e6] px-2 py-1 rounded hover:bg-[#3565c7] cursor-pointer disabled:opacity-40`,children:`在会话中打开`}),(0,b.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>L({kind:`one`,entry:e}),className:`text-xs whitespace-nowrap text-red-600 hover:bg-red-50 px-2 py-1 rounded cursor-pointer disabled:opacity-40`,children:`删除`})]})}),(0,b.jsx)(s,{open:I!=null,title:I?.kind===`batch`?`批量删除`:`删除知识库文件`,message:G,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>L(null),onConfirm:()=>void W()})]}):(0,b.jsxs)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:[`知识库管理需要本地文档服务,当前未就绪`,e>0?`(构建期约有 ${e} 份文档可浏览)`:``,`。`]}):(0,b.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`knowledgeLib`)}):(0,b.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,b.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,b.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{C as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,n as t,t as n}from"./react-dom.CqAxpHMt.js";import{A as r,C as i,D as a,F as o,I as s,L as c,M as l,N as u,O as d,P as f,R as p,S as m,T as h,_ as g,a as _,b as v,g as y,h as b,i as x,j as S,k as C,m as w,p as T,r as E,t as D,u as O,v as ee,w as te,x as k,y as A}from"./app-config.DKMxjv3g.js";import{a as ne,i as re,r as j}from"./plugins.D5ypJIXn.js";import{i as M,n as N,r as P,t as F}from"./dialog.DXHznyjD.js";import{t as I}from"./jsx-runtime.BUXbF_vF.js";import{t as ie}from"./ConfirmDialog.CBVsDJ8f.js";import{n as L}from"./i18n.BXeGGutk.js";var R=e(t(),1),z=e(n(),1),B=`/__tb_nav/groups`;function ae(){return E().navGroups}function oe(){return d(E().navIcons)}function se(e,t){let n={...oe(),[e]:t};return O({navIcons:n}),D(),n}function ce(){return E().navOrder}function le(e,t){let n=a(e),r=C(t,n);return O({navGroups:n,navOrder:r}),D(),{groups:n,order:r}}function V(e,t){return JSON.stringify(e)===JSON.stringify(t)}async function ue(e){if(!_())return null;try{let t=await fetch(B,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({groups:e}),signal:AbortSignal.timeout(4e3)});if(!t.ok)return null;let n=await t.json();return a(n.groups,!1)}catch{return null}}async function de(){if(!_())return;let e=E(),t=null;try{let e=await fetch(B,{signal:AbortSignal.timeout(4e3)});e.ok&&(t=await e.json())}catch{return}if(!t)return;if(t.scanned){let n=a(t.groups,!1),r=C(e.navOrder,n);(!V(n,e.navGroups)||!V(r,e.navOrder))&&(O({navGroups:n,navOrder:r}),D());return}if(!e.navGroups.length)return;let n=await ue(e.navGroups);n&&!V(n,e.navGroups)&&(O({navGroups:n,navOrder:C(e.navOrder,n)}),D())}function H(e,t,n){let[r,i]=(0,R.useState)(null),a=(0,R.useRef)(null),o=(0,R.useRef)(e);o.current=e;let s=(0,R.useRef)(t);s.current=t;let l=(0,R.useRef)(n);l.current=n;function u(e,t){if(t.button!==0)return;t.preventDefault(),t.stopPropagation();let n=a.current;if(!n)return;i(e);let r=e=>{let t=[...n.querySelectorAll(`[data-sort-key]`)];for(let n of t){let t=n.getBoundingClientRect();if(e>=t.top&&e<=t.bottom)return n.dataset.sortKey}return null},u=t=>{let n=r(t.clientY);if(!n||n===e)return;let i=c(o.current,e,n);i.join(`|`)!==o.current.join(`|`)&&(o.current=i,s.current(i))},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d),i(null),l.current?.()};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)}return{listRef:a,dragId:r,onPointerDown:u}}var U=I(),W=`/`;function G(e){return`${W.endsWith(`/`)?W:`${W}/`}${e.replace(/^\//,``)}`}function K(e,t){let n=W.replace(/\/$/,``),r=e.slice(n.length).replace(/^\/+/,``);return r===t||r.startsWith(`${t}/`)}function q(e){return[`tw-nav-item`,e?`is-active font-medium`:``].filter(Boolean).join(` `)}function fe(e){return T(`tw.nav.groupOpen.${e}`)}function pe(){return T(`tw.nav.docsOpen`)}function me(e,t){try{let t=localStorage.getItem(fe(e));if(t===`1`)return!0;if(t===`0`)return!1;if(e===`docs`){let e=localStorage.getItem(pe());if(e===`1`)return!0;if(e===`0`)return!1}}catch{}return t}function J(e,t){try{localStorage.setItem(fe(e),t?`1`:`0`),e===`docs`&&localStorage.setItem(pe(),t?`1`:`0`)}catch{}}function Y(e){return e.id===`docs`&&(e.name===`文档库`||e.name===`Documents`)?L(`nav.docs`):e.name}function he(e){return e.type===`group`?Y(e.group):L(v(e.id).i18n)}function X(e){return e.type===`item`?te(e.id):k(e.group.id)}function ge(){let[e,t]=(0,R.useState)(()=>window.location.pathname);return(0,R.useEffect)(()=>{let e=()=>t(window.location.pathname);return document.addEventListener(`astro:page-load`,e),document.addEventListener(`astro:after-swap`,e),window.addEventListener(`popstate`,e),()=>{document.removeEventListener(`astro:page-load`,e),document.removeEventListener(`astro:after-swap`,e),window.removeEventListener(`popstate`,e)}},[]),e}function Z({children:e}){return(0,U.jsx)(`svg`,{className:`tw-nav-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:e})}function Q({id:e,icon:t}){return(0,U.jsx)(Z,{children:_e[t??w[e]]})}var _e={dashboard:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,U.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,U.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1.5`}),(0,U.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`,rx:`1.5`})]}),check:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M9 11l3 3L22 4`}),(0,U.jsx)(`path`,{d:`M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11`})]}),pencil:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M12 20h9`}),(0,U.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`})]}),book:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 0 1 6.5 17H20`}),(0,U.jsx)(`path`,{d:`M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z`})]}),fileText:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M14 3v5h5`}),(0,U.jsx)(`path`,{d:`M6 2h8l6 6v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z`}),(0,U.jsx)(`path`,{d:`M8 13h8`}),(0,U.jsx)(`path`,{d:`M8 17h6`})]}),layers:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M12 3 3 8l9 5 9-5-9-5z`}),(0,U.jsx)(`path`,{d:`m3 13 9 5 9-5`})]}),list:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M8 6h13`}),(0,U.jsx)(`path`,{d:`M8 12h13`}),(0,U.jsx)(`path`,{d:`M8 18h13`}),(0,U.jsx)(`path`,{d:`M3 6h.01`}),(0,U.jsx)(`path`,{d:`M3 12h.01`}),(0,U.jsx)(`path`,{d:`M3 18h.01`})]}),folder:(0,U.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`}),star:(0,U.jsx)(`path`,{d:`m12 3 2.1 5.9L20 11l-5 4.3 1.7 6.2-5.7-3.9-5.7 3.9L7 15.3 2 11l5.9-2.1L12 3z`}),database:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`ellipse`,{cx:`12`,cy:`6`,rx:`8`,ry:`3`}),(0,U.jsx)(`path`,{d:`M4 6v6c0 1.7 3.6 3 8 3s8-1.3 8-3V6`}),(0,U.jsx)(`path`,{d:`M4 12v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]}),target:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8`}),(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`})]}),code:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`m8 8-4 4 4 4`}),(0,U.jsx)(`path`,{d:`m16 8 4 4-4 4`})]}),flask:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M9 3h6`}),(0,U.jsx)(`path`,{d:`M10 3v6l-5 8a2 2 0 0 0 1.7 3h10.6a2 2 0 0 0 1.7-3l-5-8V3`}),(0,U.jsx)(`path`,{d:`M7.5 14h9`})]}),home:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M3 10.5 12 3l9 7.5`}),(0,U.jsx)(`path`,{d:`M5 9.5V20h14V9.5`})]}),clipboard:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M9 4h6v3H9z`}),(0,U.jsx)(`path`,{d:`M8 4H6a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-2`})]}),bug:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`14`,r:`5`}),(0,U.jsx)(`path`,{d:`M9 6l2 2`}),(0,U.jsx)(`path`,{d:`M15 6l-2 2`}),(0,U.jsx)(`path`,{d:`M7 11H4`}),(0,U.jsx)(`path`,{d:`M20 11h-3`}),(0,U.jsx)(`path`,{d:`M7 17H4`}),(0,U.jsx)(`path`,{d:`M20 17h-3`})]}),calendar:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`rect`,{x:`3`,y:`5`,width:`18`,height:`16`,rx:`2`}),(0,U.jsx)(`path`,{d:`M8 3v4`}),(0,U.jsx)(`path`,{d:`M16 3v4`}),(0,U.jsx)(`path`,{d:`M3 10h18`})]}),chart:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M4 20V10`}),(0,U.jsx)(`path`,{d:`M10 20V4`}),(0,U.jsx)(`path`,{d:`M16 20v-7`}),(0,U.jsx)(`path`,{d:`M2 20h20`})]}),globe:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,U.jsx)(`path`,{d:`M3 12h18`}),(0,U.jsx)(`path`,{d:`M12 3c2.5 2.5 4 5.7 4 9s-1.5 6.5-4 9c-2.5-2.5-4-5.7-4-9s1.5-6.5 4-9z`})]}),link:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M10 13a4 4 0 0 0 5.7 0l2.3-2.3a4 4 0 0 0-5.7-5.7L11 6.3`}),(0,U.jsx)(`path`,{d:`M14 11a4 4 0 0 0-5.7 0L6 13.3a4 4 0 0 0 5.7 5.7L13 17.7`})]}),users:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`9`,cy:`8`,r:`3.5`}),(0,U.jsx)(`path`,{d:`M2.5 20a6.5 6.5 0 0 1 13 0`}),(0,U.jsx)(`path`,{d:`M16 5.5a3.5 3.5 0 0 1 0 7`}),(0,U.jsx)(`path`,{d:`M18 20a6 6 0 0 0-2-4.5`})]}),terminal:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`m5 8 4 4-4 4`}),(0,U.jsx)(`path`,{d:`M13 16h6`})]}),tag:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M20.6 13.4 13.4 20.6a2 2 0 0 1-2.8 0l-7.2-7.2a2 2 0 0 1-.6-1.4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 1.4.6l6.2 6.2a2 2 0 0 1 0 2.6z`}),(0,U.jsx)(`circle`,{cx:`8`,cy:`8`,r:`1.2`})]}),flag:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M5 21V4`}),(0,U.jsx)(`path`,{d:`M5 5h11l-2 4 2 4H5z`})]}),zap:(0,U.jsx)(`path`,{d:`M13 2 4 14h6l-1 8 9-12h-6l1-8z`})};function ve(){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`svg`,{className:`tw-nav-ico tw-nav-ico--closed`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,U.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})}),(0,U.jsx)(`svg`,{className:`tw-nav-ico tw-nav-ico--open`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,U.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`})})]})}function ye(){return(0,U.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:[(0,U.jsx)(`path`,{d:`M21 4H14`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M10 4H3`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M21 12H12`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M8 12H3`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M21 20H16`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M12 20H3`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M14 2v4`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M8 10v4`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M16 18v4`,strokeLinecap:`round`})]})}function be(){return(0,U.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,U.jsx)(`path`,{d:`M12 8v8`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M8 12h8`,strokeLinecap:`round`})]})}function xe(){return(0,U.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,children:[(0,U.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.7`}),(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.7`}),(0,U.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.7`})]})}function Se(){return(0,U.jsx)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,U.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function Ce(){return(0,U.jsxs)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,U.jsx)(`path`,{d:`M9 6H5a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h4`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M16 8l4 4-4 4`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,U.jsx)(`path`,{d:`M20 12H9`,strokeLinecap:`round`})]})}function we(){return(0,U.jsxs)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,U.jsx)(`circle`,{cx:`8.5`,cy:`8.5`,r:`4.5`}),(0,U.jsx)(`rect`,{x:`12`,y:`12`,width:`9`,height:`9`,rx:`2`})]})}function Te(){return(0,U.jsxs)(Z,{children:[(0,U.jsx)(`path`,{d:`M8 6v12`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M5 9l3-3 3 3`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,U.jsx)(`path`,{d:`M16 18V6`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M13 15l3 3 3-3`,strokeLinecap:`round`,strokeLinejoin:`round`})]})}function Ee(){return(0,U.jsxs)(`svg`,{className:`tw-nav-drag-grip`,viewBox:`0 0 20 20`,"aria-hidden":!0,children:[(0,U.jsx)(`circle`,{cx:`7`,cy:`5`,r:`1.25`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`13`,cy:`5`,r:`1.25`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`7`,cy:`10`,r:`1.25`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`13`,cy:`10`,r:`1.25`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`7`,cy:`15`,r:`1.25`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`13`,cy:`15`,r:`1.25`,fill:`currentColor`})]})}function $(e,t){if(i(e))return!1;let n=v(e).plugin;return!n||t[n]!==!1}function De({id:e,icon:t,pathname:n,actionOpen:r,onMenu:i}){let a=v(e),o=K(n,a.match);return(0,U.jsxs)(`div`,{className:[q(o),r?`is-action-open`:``].filter(Boolean).join(` `),"data-plugin-nav":a.plugin,children:[(0,U.jsxs)(`a`,{href:G(a.href),className:`tw-nav-item-main`,children:[(0,U.jsx)(Q,{id:e,icon:t}),(0,U.jsx)(`span`,{className:`tw-nav-label`,children:L(a.i18n)})]}),(0,U.jsx)(`button`,{type:`button`,className:`tw-nav-hover-btn`,"aria-label":L(`nav.more`),onClick:e=>{e.preventDefault(),e.stopPropagation(),i(e.currentTarget)},children:(0,U.jsx)(xe,{})})]})}function Oe(e,t,n){return e.items.some(e=>{if(i(e))return!1;let t=v(e).plugin;return(!t||j(t))&&K(n,v(e).match)})?!0:h(t,e.id).some(e=>Oe(e,t,n))}function ke(e,t){return e.items.some(e=>{if(i(e))return!1;let t=v(e).plugin;return!t||j(t)})?!0:h(t,e.id).some(e=>ke(e,t))}function Ae({group:e,groups:t,order:n,icons:r,pathname:a,openItem:o,openGroupId:s,onMenu:c,onItemMenu:l}){let u=e.items.filter(e=>{if(i(e))return!1;let t=v(e).plugin;return!t||j(t)}),d=f(t,e.id,n),p=Oe(e,t,a),[m,h]=(0,R.useState)(()=>me(e.id,!0)),[g,_]=(0,R.useState)(!1),y=(0,R.useRef)(null),b=(0,R.useRef)(null),x=(0,R.useRef)(null);if((0,R.useEffect)(()=>S,[]),!ke(e,t))return null;function S(){x.current&&y.current&&y.current.removeEventListener(`transitionend`,x.current),x.current=null,b.current!==null&&(window.clearTimeout(b.current),b.current=null)}function C(){S(),J(e.id,!0),_(!1),h(!0)}function w(t){if(t.preventDefault(),!m||g){C();return}_(!0),J(e.id,!1);let n=y.current,r=!1,i=()=>{r||(r=!0,S(),h(!1),_(!1))},a=e=>{e.target===n&&e.propertyName===`grid-template-rows`&&i()};S(),x.current=a,n?.addEventListener(`transitionend`,a),b.current=window.setTimeout(i,360)}return(0,U.jsxs)(`details`,{className:`tw-nav-details ${g?`is-closing`:``}`,open:m||g,"data-nav-group":e.id,children:[(0,U.jsxs)(`summary`,{className:[`tw-nav-item tw-nav-summary`,p?`is-branch-active`:``,s===e.id?`is-action-open`:``].filter(Boolean).join(` `),onClick:w,children:[(0,U.jsx)(ve,{}),(0,U.jsx)(`span`,{className:`tw-nav-label min-w-0 flex-1 truncate`,children:Y(e)}),(0,U.jsx)(`button`,{type:`button`,className:`tw-nav-hover-btn`,"aria-label":L(`nav.groupActions`),onClick:t=>{t.preventDefault(),t.stopPropagation(),c(e,t.currentTarget)},children:(0,U.jsx)(ye,{})}),(0,U.jsx)(`svg`,{className:`tw-nav-chevron opacity-70`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,U.jsx)(`path`,{d:`M7 5l6 5-6 5`,strokeLinecap:`round`,strokeLinejoin:`round`})})]}),(0,U.jsx)(`div`,{className:`tw-nav-subtree-anim`,ref:y,children:(0,U.jsxs)(`div`,{className:`tw-nav-subtree`,children:[u.map(e=>(0,U.jsx)(De,{id:e,icon:r[e],pathname:a,actionOpen:o===e,onMenu:t=>l(e,t)},e)),d.map(e=>(0,U.jsx)(Ae,{group:e,groups:t,order:n,icons:r,pathname:a,openItem:o,openGroupId:s,onMenu:c,onItemMenu:l},e.id))]})})]})}function je({open:e,draft:t,groups:n,plugins:r,icons:i,onClose:a,onSave:o,onDelete:s}){let[c,l]=(0,R.useState)(``),[u,d]=(0,R.useState)([]),[f,p]=(0,R.useState)(``),m=(0,R.useRef)(null),h=new Set(n.filter(e=>e.id!==t?.id).flatMap(e=>e.items)),g=b.filter(e=>$(e.id,r)&&(!h.has(e.id)||u.includes(e.id))),_=H(u,d);(0,R.useEffect)(()=>{if(!e||!t)return;l(t.name),d(t.items.filter(e=>$(e,r))),p(``);let n=window.setTimeout(()=>{m.current?.focus(),m.current?.select()},50);return()=>window.clearTimeout(n)},[e,t,r]);function v(e){d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function y(){let e=c.trim();if(!e){p(L(`nav.groupNameRequired`));return}if(!u.length){p(L(`nav.groupItemsRequired`));return}let n=(t?.items??[]).filter(e=>!$(e,r));o({id:t?.id,name:e,items:[...n,...u],parentId:t?.parentId})}let x=[...u.map(e=>g.find(t=>t.id===e)).filter(e=>!!e),...g.filter(e=>!u.includes(e.id))];return(0,U.jsxs)(P,{open:e,onClose:a,transition:!0,className:`relative z-110`,children:[(0,U.jsx)(F,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":!0}),(0,U.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,U.jsxs)(M,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim w-full max-w-sm rounded-xl shadow-xl border border-stone-200 p-5 bg-white`,children:[(0,U.jsx)(N,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:t?.id?L(`nav.editGroupTitle`):t?.parentId?L(`nav.addSubgroup`):L(`nav.createGroup`)}),(0,U.jsxs)(`label`,{className:`tw-confirm-msg mt-4 block text-xs font-medium text-stone-500`,children:[L(`nav.groupName`),(0,U.jsx)(`input`,{ref:m,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),y())},className:`mt-1.5 w-full h-9 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6]`})]}),(0,U.jsxs)(`div`,{className:`mt-4`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:L(`nav.groupItems`)}),(0,U.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:L(`nav.groupItemsHint`)}),(0,U.jsxs)(`div`,{ref:_.listRef,className:`mt-2 max-h-52 overflow-auto rounded-lg border border-stone-200 p-1`,children:[x.map(e=>{let t=u.includes(e.id);return(0,U.jsxs)(`label`,{"data-sort-key":t?e.id:void 0,className:[`flex items-center gap-2 rounded-md px-3 py-2 text-sm text-stone-700 cursor-pointer hover:bg-stone-50`,t?`tw-nav-drag-row`:``,_.dragId===e.id?`is-dragging`:``].filter(Boolean).join(` `),onPointerDown:t?t=>{t.target.closest(`input`)||_.onPointerDown(e.id,t)}:void 0,children:[t?(0,U.jsx)(Ee,{}):(0,U.jsx)(`span`,{className:`tw-nav-drag-grip`}),(0,U.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>v(e.id),className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/40`}),(0,U.jsx)(`span`,{className:`tw-nav-editor-ico`,children:(0,U.jsx)(Q,{id:e.id,icon:i[e.id]})}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:L(e.i18n)})]},e.id)}),x.length?null:(0,U.jsx)(`div`,{className:`px-3 py-4 text-center text-[12px] text-stone-400`,children:L(`nav.noAddableItems`)})]})]}),f?(0,U.jsx)(`p`,{className:`mt-2 text-[12px] text-red-600`,children:f}):null,(0,U.jsxs)(`div`,{className:`mt-5 flex items-center gap-2`,children:[t?.id&&s?(0,U.jsx)(`button`,{type:`button`,onClick:s,className:`h-8 px-3 text-sm rounded-lg border border-red-200 text-red-600 hover:bg-red-50`,children:L(`nav.deleteGroup`)}):null,(0,U.jsx)(`div`,{className:`flex-1`}),(0,U.jsx)(`button`,{type:`button`,onClick:a,className:`tw-confirm-cancel h-8 px-3 text-sm rounded-lg border border-stone-200 text-stone-600 hover:bg-stone-100`,children:L(`nav.groupCancel`)}),(0,U.jsx)(`button`,{type:`button`,onClick:y,className:`h-8 px-3 text-sm rounded-lg text-white bg-[#4176e6] hover:bg-[#3566d0]`,children:L(`nav.groupSave`)})]})]})})]})}function Me({ids:e,labelOf:t,onChange:n,onEnd:r,indent:i}){let a=H(e,n,r);return(0,U.jsx)(`div`,{ref:a.listRef,className:`flex flex-col`,children:e.map(e=>(0,U.jsxs)(`div`,{"data-sort-key":e,className:[`tw-nav-drag-row px-3 py-2 text-sm text-stone-700 hover:bg-stone-50`,i?`tw-nav-drag-row--nested`:``,a.dragId===e?`is-dragging`:``].filter(Boolean).join(` `),onPointerDown:t=>a.onPointerDown(e,t),children:[(0,U.jsx)(Ee,{}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t(e)})]},e))})}function Ne({open:e,focusGroupId:t,nodes:n,groups:r,order:i,visible:a,onClose:o,onCommit:s,onChildCommit:c}){let l=e=>!a||a(e),u=e=>e.items.some(l)||r.filter(t=>t.parentId===e.id).some(e=>u(e)),d=n.filter(e=>e.type===`item`?l(e.id):u(e.group)),[p,m]=(0,R.useState)(()=>d.map(X)),[h,g]=(0,R.useState)(()=>Object.fromEntries(r.map(e=>[e.id,[...e.items]]))),[_,y]=(0,R.useState)([]),b=(0,R.useRef)(p);b.current=p;let x=(0,R.useRef)(h);x.current=h;let S=(0,R.useRef)(r);S.current=r;let C=(0,R.useRef)(i);C.current=i;let w=(0,R.useRef)(d);w.current=d;let T=(0,R.useRef)(_);T.current=_;let E=()=>{let e=S.current.map(e=>({...e,items:x.current[e.id]??e.items}));s(b.current,e)},D=()=>{t&&c(t,T.current)};(0,R.useEffect)(()=>{if(!e)return;let n=w.current.map(X);b.current=n,m(n);let r=Object.fromEntries(S.current.map(e=>[e.id,[...e.items]]));x.current=r,g(r);let i=t?f(S.current,t,C.current).map(e=>e.id):[];T.current=i,y(i)},[e,t]);let O=e=>{b.current=e,m(e)},ee=e=>{T.current=e,y(e)},te=(e,t)=>{let n=(x.current[e]??[]).filter(e=>!l(e)),r={...x.current,[e]:t.length?[...t,...n]:n};x.current=r,g(r)},k=new Map(d.map(e=>[X(e),he(e)])),A=t?r.find(e=>e.id===t):void 0,ne=A?(h[A.id]??A.items).filter(l):[],re=A?f(r,A.id,i):[],j=_.length?_:re.map(e=>e.id);return(0,U.jsxs)(P,{open:e,onClose:o,transition:!0,className:`relative z-110`,children:[(0,U.jsx)(F,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":!0}),(0,U.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,U.jsxs)(M,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim w-full max-w-sm rounded-xl shadow-xl border border-stone-200 p-5 bg-white`,children:[(0,U.jsx)(N,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:L(`nav.sortMenuTitle`)}),(0,U.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:L(`nav.sortHint`)}),(0,U.jsx)(`div`,{className:`mt-4 max-h-80 overflow-auto rounded-lg border border-stone-200 p-1`,children:A?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Me,{ids:ne,labelOf:e=>L(v(e).i18n),onChange:e=>te(A.id,e),onEnd:E,indent:!0}),j.length?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`mt-1 border-t border-stone-100 px-3 pb-1 pt-2 text-[11px] font-medium text-stone-400`,children:L(`nav.subgroups`)}),(0,U.jsx)(Me,{ids:j,labelOf:e=>{let t=r.find(t=>t.id===e);return t?Y(t):e},onChange:ee,onEnd:D,indent:!0})]}):null]}):(0,U.jsx)(Me,{ids:p,labelOf:e=>k.get(e)??e,onChange:O,onEnd:E})})]})})]})}function Pe(e,t){let n=[];for(let r of e.filter(e=>!e.parentId)){n.push({group:r,indent:!1});for(let i of f(e,r.id,t))n.push({group:i,indent:!0})}return n}function Fe(){return(0,U.jsx)(`svg`,{className:`tw-nav-group-pop-arrow`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,U.jsx)(`path`,{d:`M7 5l5 5-5 5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}var Ie=120;function Le(){let[e,t]=(0,R.useState)(null),n=(0,R.useRef)(null),r=(0,R.useCallback)(()=>{n.current!==null&&(window.clearTimeout(n.current),n.current=null)},[]),i=(0,R.useCallback)(e=>{r(),t({value:e,closing:!1})},[r]),a=(0,R.useCallback)(()=>{r(),t(e=>e&&!e.closing?{...e,closing:!0}:e),n.current=window.setTimeout(()=>{n.current=null,t(null)},Ie)},[r]),o=(0,R.useCallback)(()=>{r(),t(null)},[r]);return(0,R.useEffect)(()=>r,[r]),{value:e?.value??null,closing:!!e?.closing,open:i,close:a,closeNow:o}}function Re(e,t){return{onMouseOver:()=>e?.(),onMouseOut:e=>{let n=e.relatedTarget;n&&e.currentTarget.contains(n)||t?.()}}}function ze({anchor:e,current:t,itemId:n,closing:r,onPick:i,onHoverEnter:a,onHoverLeave:o}){let s=(0,R.useRef)(null),[c,l]=(0,R.useState)({top:e.top,left:e.right+8});return(0,R.useEffect)(()=>{let t=s.current;if(!t)return;let n=t.offsetWidth,r=t.offsetHeight,i=e.right+8,a=e.top-6;i+n>window.innerWidth-8&&(i=Math.max(8,e.left-n-6)),a+r>window.innerHeight-8&&(a=Math.max(8,window.innerHeight-r-8)),a<8&&(a=8),l({top:a,left:i})},[e]),(0,z.createPortal)((0,U.jsxs)(`div`,{ref:s,className:[`tw-nav-group-pop`,`tw-nav-icon-pop`,r?`is-closing`:``].filter(Boolean).join(` `),style:{top:c.top,left:c.left},...Re(a,o),children:[(0,U.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:L(`nav.chooseIcon`)}),(0,U.jsx)(`div`,{className:`tw-nav-icon-grid`,children:y.map(e=>(0,U.jsx)(`button`,{type:`button`,className:[`tw-nav-icon-cell`,t===e?`is-current`:``].filter(Boolean).join(` `),onClick:()=>i(e),children:(0,U.jsx)(Q,{id:n,icon:e})},e))})]}),document.body)}function Be({rect:e,closing:t=!1,onClose:n,onHoverEnter:r,onHoverLeave:i,children:a}){let o=(0,R.useRef)(null),[s,c]=(0,R.useState)({top:e.top,left:e.right+6});return(0,R.useEffect)(()=>{let t=o.current;if(!t)return;let n=t.offsetWidth,r=t.offsetHeight,i=e.right+6,a=e.top;i+n>window.innerWidth-8&&(i=Math.max(8,e.left-n-6)),a+r>window.innerHeight-8&&(a=Math.max(8,window.innerHeight-r-8)),c({top:a,left:i})},[e]),(0,R.useEffect)(()=>{let e=e=>{let t=e.target;o.current?.contains(t)||t?.closest?.(`.tw-nav-icon-pop`)||t?.closest?.(`.tw-nav-hover-btn`)||n()},t=e=>{e.key===`Escape`&&n()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),window.addEventListener(`resize`,n),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t),window.removeEventListener(`resize`,n)}},[n]),(0,z.createPortal)((0,U.jsx)(`div`,{ref:o,className:[`tw-nav-group-pop`,t?`is-closing`:``].filter(Boolean).join(` `),style:{top:s.top,left:s.left},...Re(r,i),children:a}),document.body)}function Ve(){let e=ge(),[t,n]=(0,R.useState)(()=>ae()),[i,a]=(0,R.useState)(()=>oe()),[c,d]=(0,R.useState)(()=>ce()),[f,h]=(0,R.useState)(()=>re()),[_,y]=(0,R.useState)(null),[b,C]=(0,R.useState)(!1),[w,T]=(0,R.useState)(null),[E,D]=(0,R.useState)(!1),[O,te]=(0,R.useState)(null),k=Le(),j=Le(),M=k.value,N=j.value,P=(0,R.useRef)(null);(0,R.useEffect)(()=>()=>{P.current!==null&&window.clearTimeout(P.current)},[]);function F(e){te(e),D(!0)}function I(e){y(e),C(!0)}function z(){C(!1),T(null)}(0,R.useEffect)(()=>{let e=!0,t=ne(e=>{h({...e})});return x().then(async()=>{e&&(await de(),e&&(n(ae()),d(ce()),a(oe()),h(re())))}),()=>{e=!1,t()}},[]);let B=ee(t,c);function V(e,t){let r=le(e,t);n(r.groups),d(r.order),ue(r.groups).then(e=>{if(!e||JSON.stringify(e)===JSON.stringify(r.groups))return;let t=le(e,r.order);n(t.groups),d(t.order)})}function H(){W(),j.close(),k.close()}function W(){P.current!==null&&(window.clearTimeout(P.current),P.current=null)}function G(){W(),P.current=window.setTimeout(()=>{P.current=null,j.close()},220)}function K(e,t){W(),j.open({itemId:e,rect:t.getBoundingClientRect()})}function q(e,t){M?.kind===`itemMenu`&&M.itemId===e?H():(j.closeNow(),k.open({kind:`itemMenu`,itemId:e,rect:t.getBoundingClientRect()}))}function fe(e,t){M?.kind===`groupMenu`&&M.group.id===e.id?H():(j.closeNow(),k.open({kind:`groupMenu`,group:e,rect:t.getBoundingClientRect()}))}function pe(e,n){V(g(t,e,n),c),H()}function me(e){let{groups:n,owner:r}=o(t,e);V(n,r?S(c,e,r,n):c),H()}let J=M?.kind===`assign`||M?.kind===`itemMenu`?M.itemId:void 0,he=M?.kind===`groupMenu`?M.group.id:void 0,X=M?.kind===`itemMenu`?M:null,Z=M?.kind===`groupMenu`?M:null,Q=M?.kind===`assign`?M:null,_e=X?t.find(e=>e.items.includes(X.itemId))??null:null;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`tw-nav-ready`,"aria-hidden":`true`}),B.map(n=>n.type===`item`?$(n.id,f)?(0,U.jsx)(De,{id:n.id,icon:i[n.id],pathname:e,actionOpen:J===n.id,onMenu:e=>q(n.id,e)},n.id):null:(0,U.jsx)(Ae,{group:n.group,groups:t,order:c,icons:i,pathname:e,openItem:J,openGroupId:he,onMenu:fe,onItemMenu:q},n.group.id)),X?(0,U.jsxs)(Be,{rect:X.rect,closing:k.closing,onClose:H,onHoverEnter:W,onHoverLeave:G,children:[(0,U.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:L(v(X.itemId).i18n)}),(0,U.jsxs)(`div`,{className:`tw-nav-group-pop-list`,onMouseOver:e=>{let t=e.target.closest(`.tw-nav-group-pop-item`);t&&t.getAttribute(`data-submenu`)!==`icons`&&(W(),j.close())},children:[_e?(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item is-leave`,onClick:()=>me(X.itemId),children:[(0,U.jsx)(Ce,{}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.leaveGroup`)})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>k.open({kind:`assign`,itemId:X.itemId,rect:X.rect}),children:[(0,U.jsx)(Se,{}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.assignGroup`)})]}),(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=X.itemId;H(),I({name:``,items:[e]})},children:[(0,U.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,U.jsx)(be,{})}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.addToGroup`)})]})]}),(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=_e?.id??null;H(),F(e)},children:[(0,U.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,U.jsx)(Te,{})}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.sortMenu`)})]}),(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,"data-submenu":`icons`,onMouseEnter:e=>K(X.itemId,e.currentTarget),onClick:e=>K(X.itemId,e.currentTarget),children:[(0,U.jsx)(we,{}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.chooseIcon`)}),(0,U.jsx)(Fe,{})]})]})]}):null,N&&X&&N.itemId===X.itemId?(0,U.jsx)(ze,{anchor:N.rect,itemId:N.itemId,current:i[N.itemId],closing:j.closing,onHoverEnter:W,onHoverLeave:G,onPick:e=>{a(se(N.itemId,e)),H()}}):null,Z?(0,U.jsxs)(Be,{rect:Z.rect,closing:k.closing,onClose:H,children:[(0,U.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:Y(Z.group)}),(0,U.jsxs)(`div`,{className:`tw-nav-group-pop-list`,children:[Z.group.parentId?null:(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item is-create`,onClick:()=>{let e=Z.group.id;H(),I({name:``,items:[],parentId:e})},children:[(0,U.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,U.jsx)(be,{})}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.addSubgroup`)})]}),(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=Z.group;H(),F(e.parentId??null)},children:[(0,U.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,U.jsx)(Te,{})}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.sortMenu`)})]}),(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=Z.group;H(),I({id:e.id,name:e.name,items:[...e.items],parentId:e.parentId})},children:[(0,U.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,U.jsx)(ye,{})}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.editGroupTitle`)})]})]})]}):null,Q?(0,U.jsxs)(Be,{rect:Q.rect,closing:k.closing,onClose:H,children:[(0,U.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:L(`nav.assignGroup`)}),(0,U.jsx)(`div`,{className:`tw-nav-group-pop-list`,children:t.length?Pe(t,c).map(({group:e,indent:t})=>{let n=e.items.includes(Q.itemId);return(0,U.jsxs)(`button`,{type:`button`,className:[`tw-nav-group-pop-item`,n?`is-current`:``,t?`is-child`:``].filter(Boolean).join(` `),onClick:()=>{n||pe(e.id,Q.itemId)},children:[(0,U.jsx)(Se,{}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:Y(e)}),n?(0,U.jsx)(`span`,{className:`tw-nav-group-pop-tag`,children:L(`nav.currentGroup`)}):null]},e.id)}):(0,U.jsx)(`div`,{className:`tw-nav-group-pop-empty`,children:L(`nav.noGroups`)})})]}):null,(0,U.jsx)(je,{open:b&&!w,draft:_,groups:t,plugins:f,icons:i,onClose:z,onSave:e=>{let n=p(t,e);V(n.groups,u(c,n.groups,n.id)),z()},onDelete:_?.id?()=>T(_.id):void 0}),(0,U.jsx)(Ne,{open:E,focusGroupId:O,nodes:B,groups:t,order:c,visible:e=>$(e,f),onClose:()=>D(!1),onCommit:(e,t)=>{let n=c.filter(e=>m(e,t));V(t,[...e,...n.filter(t=>!e.includes(t))])},onChildCommit:(e,n)=>V(t,r(c,t,e,n))}),(0,U.jsx)(ie,{open:!!w,title:L(`nav.deleteGroup`),message:t.find(e=>e.id===w)?.parentId?L(`nav.deleteSubgroupMsg`):L(`nav.deleteGroupMsg`),confirmLabel:L(`nav.deleteGroup`),cancelLabel:L(`nav.groupCancel`),danger:`outline`,onClose:()=>T(null),onConfirm:()=>{if(w){let e=t.find(e=>e.id===w),n=A(t,w),r=s(t,w);V(r,e?l(c,e,r,n):c)}z()}})]})}export{Ve as default};
|
|
1
|
+
import{c as e,n as t,t as n}from"./react-dom.CqAxpHMt.js";import{A as r,C as i,D as a,F as o,I as s,L as c,M as l,N as u,O as d,P as f,R as p,S as m,T as h,_ as g,a as _,b as v,g as y,h as b,i as x,j as S,k as C,m as w,p as T,r as E,t as D,u as O,v as ee,w as te,x as k,y as A}from"./app-config.DUyozIL9.js";import{a as ne,i as re,r as j}from"./plugins.BDZqJNOy.js";import{i as M,n as N,r as P,t as F}from"./dialog.DXHznyjD.js";import{t as I}from"./jsx-runtime.BUXbF_vF.js";import{t as ie}from"./ConfirmDialog.CBVsDJ8f.js";import{n as L}from"./i18n.B52gLzii.js";var R=e(t(),1),z=e(n(),1),B=`/__tb_nav/groups`;function ae(){return E().navGroups}function oe(){return d(E().navIcons)}function se(e,t){let n={...oe(),[e]:t};return O({navIcons:n}),D(),n}function ce(){return E().navOrder}function le(e,t){let n=a(e),r=C(t,n);return O({navGroups:n,navOrder:r}),D(),{groups:n,order:r}}function V(e,t){return JSON.stringify(e)===JSON.stringify(t)}async function ue(e){if(!_())return null;try{let t=await fetch(B,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({groups:e}),signal:AbortSignal.timeout(4e3)});if(!t.ok)return null;let n=await t.json();return a(n.groups,!1)}catch{return null}}async function de(){if(!_())return;let e=E(),t=null;try{let e=await fetch(B,{signal:AbortSignal.timeout(4e3)});e.ok&&(t=await e.json())}catch{return}if(!t)return;if(t.scanned){let n=a(t.groups,!1),r=C(e.navOrder,n);(!V(n,e.navGroups)||!V(r,e.navOrder))&&(O({navGroups:n,navOrder:r}),D());return}if(!e.navGroups.length)return;let n=await ue(e.navGroups);n&&!V(n,e.navGroups)&&(O({navGroups:n,navOrder:C(e.navOrder,n)}),D())}function H(e,t,n){let[r,i]=(0,R.useState)(null),a=(0,R.useRef)(null),o=(0,R.useRef)(e);o.current=e;let s=(0,R.useRef)(t);s.current=t;let l=(0,R.useRef)(n);l.current=n;function u(e,t){if(t.button!==0)return;t.preventDefault(),t.stopPropagation();let n=a.current;if(!n)return;i(e);let r=e=>{let t=[...n.querySelectorAll(`[data-sort-key]`)];for(let n of t){let t=n.getBoundingClientRect();if(e>=t.top&&e<=t.bottom)return n.dataset.sortKey}return null},u=t=>{let n=r(t.clientY);if(!n||n===e)return;let i=c(o.current,e,n);i.join(`|`)!==o.current.join(`|`)&&(o.current=i,s.current(i))},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d),i(null),l.current?.()};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)}return{listRef:a,dragId:r,onPointerDown:u}}var U=I(),W=`/`;function G(e){return`${W.endsWith(`/`)?W:`${W}/`}${e.replace(/^\//,``)}`}function K(e,t){let n=W.replace(/\/$/,``),r=e.slice(n.length).replace(/^\/+/,``);return r===t||r.startsWith(`${t}/`)}function q(e){return[`tw-nav-item`,e?`is-active font-medium`:``].filter(Boolean).join(` `)}function fe(e){return T(`tw.nav.groupOpen.${e}`)}function pe(){return T(`tw.nav.docsOpen`)}function me(e,t){try{let t=localStorage.getItem(fe(e));if(t===`1`)return!0;if(t===`0`)return!1;if(e===`docs`){let e=localStorage.getItem(pe());if(e===`1`)return!0;if(e===`0`)return!1}}catch{}return t}function J(e,t){try{localStorage.setItem(fe(e),t?`1`:`0`),e===`docs`&&localStorage.setItem(pe(),t?`1`:`0`)}catch{}}function Y(e){return e.id===`docs`&&(e.name===`文档库`||e.name===`Documents`)?L(`nav.docs`):e.name}function he(e){return e.type===`group`?Y(e.group):L(v(e.id).i18n)}function X(e){return e.type===`item`?te(e.id):k(e.group.id)}function ge(){let[e,t]=(0,R.useState)(()=>window.location.pathname);return(0,R.useEffect)(()=>{let e=()=>t(window.location.pathname);return document.addEventListener(`astro:page-load`,e),document.addEventListener(`astro:after-swap`,e),window.addEventListener(`popstate`,e),()=>{document.removeEventListener(`astro:page-load`,e),document.removeEventListener(`astro:after-swap`,e),window.removeEventListener(`popstate`,e)}},[]),e}function Z({children:e}){return(0,U.jsx)(`svg`,{className:`tw-nav-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:e})}function Q({id:e,icon:t}){return(0,U.jsx)(Z,{children:_e[t??w[e]]})}var _e={dashboard:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,U.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,U.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1.5`}),(0,U.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`,rx:`1.5`})]}),check:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M9 11l3 3L22 4`}),(0,U.jsx)(`path`,{d:`M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11`})]}),pencil:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M12 20h9`}),(0,U.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`})]}),book:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 0 1 6.5 17H20`}),(0,U.jsx)(`path`,{d:`M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z`})]}),fileText:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M14 3v5h5`}),(0,U.jsx)(`path`,{d:`M6 2h8l6 6v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z`}),(0,U.jsx)(`path`,{d:`M8 13h8`}),(0,U.jsx)(`path`,{d:`M8 17h6`})]}),layers:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M12 3 3 8l9 5 9-5-9-5z`}),(0,U.jsx)(`path`,{d:`m3 13 9 5 9-5`})]}),list:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M8 6h13`}),(0,U.jsx)(`path`,{d:`M8 12h13`}),(0,U.jsx)(`path`,{d:`M8 18h13`}),(0,U.jsx)(`path`,{d:`M3 6h.01`}),(0,U.jsx)(`path`,{d:`M3 12h.01`}),(0,U.jsx)(`path`,{d:`M3 18h.01`})]}),folder:(0,U.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`}),star:(0,U.jsx)(`path`,{d:`m12 3 2.1 5.9L20 11l-5 4.3 1.7 6.2-5.7-3.9-5.7 3.9L7 15.3 2 11l5.9-2.1L12 3z`}),database:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`ellipse`,{cx:`12`,cy:`6`,rx:`8`,ry:`3`}),(0,U.jsx)(`path`,{d:`M4 6v6c0 1.7 3.6 3 8 3s8-1.3 8-3V6`}),(0,U.jsx)(`path`,{d:`M4 12v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]}),target:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8`}),(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`})]}),code:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`m8 8-4 4 4 4`}),(0,U.jsx)(`path`,{d:`m16 8 4 4-4 4`})]}),flask:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M9 3h6`}),(0,U.jsx)(`path`,{d:`M10 3v6l-5 8a2 2 0 0 0 1.7 3h10.6a2 2 0 0 0 1.7-3l-5-8V3`}),(0,U.jsx)(`path`,{d:`M7.5 14h9`})]}),home:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M3 10.5 12 3l9 7.5`}),(0,U.jsx)(`path`,{d:`M5 9.5V20h14V9.5`})]}),clipboard:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M9 4h6v3H9z`}),(0,U.jsx)(`path`,{d:`M8 4H6a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-2`})]}),bug:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`14`,r:`5`}),(0,U.jsx)(`path`,{d:`M9 6l2 2`}),(0,U.jsx)(`path`,{d:`M15 6l-2 2`}),(0,U.jsx)(`path`,{d:`M7 11H4`}),(0,U.jsx)(`path`,{d:`M20 11h-3`}),(0,U.jsx)(`path`,{d:`M7 17H4`}),(0,U.jsx)(`path`,{d:`M20 17h-3`})]}),calendar:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`rect`,{x:`3`,y:`5`,width:`18`,height:`16`,rx:`2`}),(0,U.jsx)(`path`,{d:`M8 3v4`}),(0,U.jsx)(`path`,{d:`M16 3v4`}),(0,U.jsx)(`path`,{d:`M3 10h18`})]}),chart:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M4 20V10`}),(0,U.jsx)(`path`,{d:`M10 20V4`}),(0,U.jsx)(`path`,{d:`M16 20v-7`}),(0,U.jsx)(`path`,{d:`M2 20h20`})]}),globe:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,U.jsx)(`path`,{d:`M3 12h18`}),(0,U.jsx)(`path`,{d:`M12 3c2.5 2.5 4 5.7 4 9s-1.5 6.5-4 9c-2.5-2.5-4-5.7-4-9s1.5-6.5 4-9z`})]}),link:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M10 13a4 4 0 0 0 5.7 0l2.3-2.3a4 4 0 0 0-5.7-5.7L11 6.3`}),(0,U.jsx)(`path`,{d:`M14 11a4 4 0 0 0-5.7 0L6 13.3a4 4 0 0 0 5.7 5.7L13 17.7`})]}),users:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`9`,cy:`8`,r:`3.5`}),(0,U.jsx)(`path`,{d:`M2.5 20a6.5 6.5 0 0 1 13 0`}),(0,U.jsx)(`path`,{d:`M16 5.5a3.5 3.5 0 0 1 0 7`}),(0,U.jsx)(`path`,{d:`M18 20a6 6 0 0 0-2-4.5`})]}),terminal:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`m5 8 4 4-4 4`}),(0,U.jsx)(`path`,{d:`M13 16h6`})]}),tag:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M20.6 13.4 13.4 20.6a2 2 0 0 1-2.8 0l-7.2-7.2a2 2 0 0 1-.6-1.4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 1.4.6l6.2 6.2a2 2 0 0 1 0 2.6z`}),(0,U.jsx)(`circle`,{cx:`8`,cy:`8`,r:`1.2`})]}),flag:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M5 21V4`}),(0,U.jsx)(`path`,{d:`M5 5h11l-2 4 2 4H5z`})]}),zap:(0,U.jsx)(`path`,{d:`M13 2 4 14h6l-1 8 9-12h-6l1-8z`})};function ve(){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`svg`,{className:`tw-nav-ico tw-nav-ico--closed`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,U.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})}),(0,U.jsx)(`svg`,{className:`tw-nav-ico tw-nav-ico--open`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,U.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`})})]})}function ye(){return(0,U.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:[(0,U.jsx)(`path`,{d:`M21 4H14`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M10 4H3`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M21 12H12`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M8 12H3`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M21 20H16`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M12 20H3`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M14 2v4`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M8 10v4`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M16 18v4`,strokeLinecap:`round`})]})}function be(){return(0,U.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,U.jsx)(`path`,{d:`M12 8v8`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M8 12h8`,strokeLinecap:`round`})]})}function xe(){return(0,U.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,children:[(0,U.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.7`}),(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.7`}),(0,U.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.7`})]})}function Se(){return(0,U.jsx)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,U.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function Ce(){return(0,U.jsxs)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,U.jsx)(`path`,{d:`M9 6H5a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h4`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M16 8l4 4-4 4`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,U.jsx)(`path`,{d:`M20 12H9`,strokeLinecap:`round`})]})}function we(){return(0,U.jsxs)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,U.jsx)(`circle`,{cx:`8.5`,cy:`8.5`,r:`4.5`}),(0,U.jsx)(`rect`,{x:`12`,y:`12`,width:`9`,height:`9`,rx:`2`})]})}function Te(){return(0,U.jsxs)(Z,{children:[(0,U.jsx)(`path`,{d:`M8 6v12`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M5 9l3-3 3 3`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,U.jsx)(`path`,{d:`M16 18V6`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M13 15l3 3 3-3`,strokeLinecap:`round`,strokeLinejoin:`round`})]})}function Ee(){return(0,U.jsxs)(`svg`,{className:`tw-nav-drag-grip`,viewBox:`0 0 20 20`,"aria-hidden":!0,children:[(0,U.jsx)(`circle`,{cx:`7`,cy:`5`,r:`1.25`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`13`,cy:`5`,r:`1.25`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`7`,cy:`10`,r:`1.25`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`13`,cy:`10`,r:`1.25`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`7`,cy:`15`,r:`1.25`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`13`,cy:`15`,r:`1.25`,fill:`currentColor`})]})}function $(e,t){if(i(e))return!1;let n=v(e).plugin;return!n||t[n]!==!1}function De({id:e,icon:t,pathname:n,actionOpen:r,onMenu:i}){let a=v(e),o=K(n,a.match);return(0,U.jsxs)(`div`,{className:[q(o),r?`is-action-open`:``].filter(Boolean).join(` `),"data-plugin-nav":a.plugin,children:[(0,U.jsxs)(`a`,{href:G(a.href),className:`tw-nav-item-main`,children:[(0,U.jsx)(Q,{id:e,icon:t}),(0,U.jsx)(`span`,{className:`tw-nav-label`,children:L(a.i18n)})]}),(0,U.jsx)(`button`,{type:`button`,className:`tw-nav-hover-btn`,"aria-label":L(`nav.more`),onClick:e=>{e.preventDefault(),e.stopPropagation(),i(e.currentTarget)},children:(0,U.jsx)(xe,{})})]})}function Oe(e,t,n){return e.items.some(e=>{if(i(e))return!1;let t=v(e).plugin;return(!t||j(t))&&K(n,v(e).match)})?!0:h(t,e.id).some(e=>Oe(e,t,n))}function ke(e,t){return e.items.some(e=>{if(i(e))return!1;let t=v(e).plugin;return!t||j(t)})?!0:h(t,e.id).some(e=>ke(e,t))}function Ae({group:e,groups:t,order:n,icons:r,pathname:a,openItem:o,openGroupId:s,onMenu:c,onItemMenu:l}){let u=e.items.filter(e=>{if(i(e))return!1;let t=v(e).plugin;return!t||j(t)}),d=f(t,e.id,n),p=Oe(e,t,a),[m,h]=(0,R.useState)(()=>me(e.id,!0)),[g,_]=(0,R.useState)(!1),y=(0,R.useRef)(null),b=(0,R.useRef)(null),x=(0,R.useRef)(null);if((0,R.useEffect)(()=>S,[]),!ke(e,t))return null;function S(){x.current&&y.current&&y.current.removeEventListener(`transitionend`,x.current),x.current=null,b.current!==null&&(window.clearTimeout(b.current),b.current=null)}function C(){S(),J(e.id,!0),_(!1),h(!0)}function w(t){if(t.preventDefault(),!m||g){C();return}_(!0),J(e.id,!1);let n=y.current,r=!1,i=()=>{r||(r=!0,S(),h(!1),_(!1))},a=e=>{e.target===n&&e.propertyName===`grid-template-rows`&&i()};S(),x.current=a,n?.addEventListener(`transitionend`,a),b.current=window.setTimeout(i,360)}return(0,U.jsxs)(`details`,{className:`tw-nav-details ${g?`is-closing`:``}`,open:m||g,"data-nav-group":e.id,children:[(0,U.jsxs)(`summary`,{className:[`tw-nav-item tw-nav-summary`,p?`is-branch-active`:``,s===e.id?`is-action-open`:``].filter(Boolean).join(` `),onClick:w,children:[(0,U.jsx)(ve,{}),(0,U.jsx)(`span`,{className:`tw-nav-label min-w-0 flex-1 truncate`,children:Y(e)}),(0,U.jsx)(`button`,{type:`button`,className:`tw-nav-hover-btn`,"aria-label":L(`nav.groupActions`),onClick:t=>{t.preventDefault(),t.stopPropagation(),c(e,t.currentTarget)},children:(0,U.jsx)(ye,{})}),(0,U.jsx)(`svg`,{className:`tw-nav-chevron opacity-70`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,U.jsx)(`path`,{d:`M7 5l6 5-6 5`,strokeLinecap:`round`,strokeLinejoin:`round`})})]}),(0,U.jsx)(`div`,{className:`tw-nav-subtree-anim`,ref:y,children:(0,U.jsxs)(`div`,{className:`tw-nav-subtree`,children:[u.map(e=>(0,U.jsx)(De,{id:e,icon:r[e],pathname:a,actionOpen:o===e,onMenu:t=>l(e,t)},e)),d.map(e=>(0,U.jsx)(Ae,{group:e,groups:t,order:n,icons:r,pathname:a,openItem:o,openGroupId:s,onMenu:c,onItemMenu:l},e.id))]})})]})}function je({open:e,draft:t,groups:n,plugins:r,icons:i,onClose:a,onSave:o,onDelete:s}){let[c,l]=(0,R.useState)(``),[u,d]=(0,R.useState)([]),[f,p]=(0,R.useState)(``),m=(0,R.useRef)(null),h=new Set(n.filter(e=>e.id!==t?.id).flatMap(e=>e.items)),g=b.filter(e=>$(e.id,r)&&(!h.has(e.id)||u.includes(e.id))),_=H(u,d);(0,R.useEffect)(()=>{if(!e||!t)return;l(t.name),d(t.items.filter(e=>$(e,r))),p(``);let n=window.setTimeout(()=>{m.current?.focus(),m.current?.select()},50);return()=>window.clearTimeout(n)},[e,t,r]);function v(e){d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function y(){let e=c.trim();if(!e){p(L(`nav.groupNameRequired`));return}if(!u.length){p(L(`nav.groupItemsRequired`));return}let n=(t?.items??[]).filter(e=>!$(e,r));o({id:t?.id,name:e,items:[...n,...u],parentId:t?.parentId})}let x=[...u.map(e=>g.find(t=>t.id===e)).filter(e=>!!e),...g.filter(e=>!u.includes(e.id))];return(0,U.jsxs)(P,{open:e,onClose:a,transition:!0,className:`relative z-110`,children:[(0,U.jsx)(F,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":!0}),(0,U.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,U.jsxs)(M,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim w-full max-w-sm rounded-xl shadow-xl border border-stone-200 p-5 bg-white`,children:[(0,U.jsx)(N,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:t?.id?L(`nav.editGroupTitle`):t?.parentId?L(`nav.addSubgroup`):L(`nav.createGroup`)}),(0,U.jsxs)(`label`,{className:`tw-confirm-msg mt-4 block text-xs font-medium text-stone-500`,children:[L(`nav.groupName`),(0,U.jsx)(`input`,{ref:m,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),y())},className:`mt-1.5 w-full h-9 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6]`})]}),(0,U.jsxs)(`div`,{className:`mt-4`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:L(`nav.groupItems`)}),(0,U.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:L(`nav.groupItemsHint`)}),(0,U.jsxs)(`div`,{ref:_.listRef,className:`mt-2 max-h-52 overflow-auto rounded-lg border border-stone-200 p-1`,children:[x.map(e=>{let t=u.includes(e.id);return(0,U.jsxs)(`label`,{"data-sort-key":t?e.id:void 0,className:[`flex items-center gap-2 rounded-md px-3 py-2 text-sm text-stone-700 cursor-pointer hover:bg-stone-50`,t?`tw-nav-drag-row`:``,_.dragId===e.id?`is-dragging`:``].filter(Boolean).join(` `),onPointerDown:t?t=>{t.target.closest(`input`)||_.onPointerDown(e.id,t)}:void 0,children:[t?(0,U.jsx)(Ee,{}):(0,U.jsx)(`span`,{className:`tw-nav-drag-grip`}),(0,U.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>v(e.id),className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/40`}),(0,U.jsx)(`span`,{className:`tw-nav-editor-ico`,children:(0,U.jsx)(Q,{id:e.id,icon:i[e.id]})}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:L(e.i18n)})]},e.id)}),x.length?null:(0,U.jsx)(`div`,{className:`px-3 py-4 text-center text-[12px] text-stone-400`,children:L(`nav.noAddableItems`)})]})]}),f?(0,U.jsx)(`p`,{className:`mt-2 text-[12px] text-red-600`,children:f}):null,(0,U.jsxs)(`div`,{className:`mt-5 flex items-center gap-2`,children:[t?.id&&s?(0,U.jsx)(`button`,{type:`button`,onClick:s,className:`h-8 px-3 text-sm rounded-lg border border-red-200 text-red-600 hover:bg-red-50`,children:L(`nav.deleteGroup`)}):null,(0,U.jsx)(`div`,{className:`flex-1`}),(0,U.jsx)(`button`,{type:`button`,onClick:a,className:`tw-confirm-cancel h-8 px-3 text-sm rounded-lg border border-stone-200 text-stone-600 hover:bg-stone-100`,children:L(`nav.groupCancel`)}),(0,U.jsx)(`button`,{type:`button`,onClick:y,className:`h-8 px-3 text-sm rounded-lg text-white bg-[#4176e6] hover:bg-[#3566d0]`,children:L(`nav.groupSave`)})]})]})})]})}function Me({ids:e,labelOf:t,onChange:n,onEnd:r,indent:i}){let a=H(e,n,r);return(0,U.jsx)(`div`,{ref:a.listRef,className:`flex flex-col`,children:e.map(e=>(0,U.jsxs)(`div`,{"data-sort-key":e,className:[`tw-nav-drag-row px-3 py-2 text-sm text-stone-700 hover:bg-stone-50`,i?`tw-nav-drag-row--nested`:``,a.dragId===e?`is-dragging`:``].filter(Boolean).join(` `),onPointerDown:t=>a.onPointerDown(e,t),children:[(0,U.jsx)(Ee,{}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t(e)})]},e))})}function Ne({open:e,focusGroupId:t,nodes:n,groups:r,order:i,visible:a,onClose:o,onCommit:s,onChildCommit:c}){let l=e=>!a||a(e),u=e=>e.items.some(l)||r.filter(t=>t.parentId===e.id).some(e=>u(e)),d=n.filter(e=>e.type===`item`?l(e.id):u(e.group)),[p,m]=(0,R.useState)(()=>d.map(X)),[h,g]=(0,R.useState)(()=>Object.fromEntries(r.map(e=>[e.id,[...e.items]]))),[_,y]=(0,R.useState)([]),b=(0,R.useRef)(p);b.current=p;let x=(0,R.useRef)(h);x.current=h;let S=(0,R.useRef)(r);S.current=r;let C=(0,R.useRef)(i);C.current=i;let w=(0,R.useRef)(d);w.current=d;let T=(0,R.useRef)(_);T.current=_;let E=()=>{let e=S.current.map(e=>({...e,items:x.current[e.id]??e.items}));s(b.current,e)},D=()=>{t&&c(t,T.current)};(0,R.useEffect)(()=>{if(!e)return;let n=w.current.map(X);b.current=n,m(n);let r=Object.fromEntries(S.current.map(e=>[e.id,[...e.items]]));x.current=r,g(r);let i=t?f(S.current,t,C.current).map(e=>e.id):[];T.current=i,y(i)},[e,t]);let O=e=>{b.current=e,m(e)},ee=e=>{T.current=e,y(e)},te=(e,t)=>{let n=(x.current[e]??[]).filter(e=>!l(e)),r={...x.current,[e]:t.length?[...t,...n]:n};x.current=r,g(r)},k=new Map(d.map(e=>[X(e),he(e)])),A=t?r.find(e=>e.id===t):void 0,ne=A?(h[A.id]??A.items).filter(l):[],re=A?f(r,A.id,i):[],j=_.length?_:re.map(e=>e.id);return(0,U.jsxs)(P,{open:e,onClose:o,transition:!0,className:`relative z-110`,children:[(0,U.jsx)(F,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":!0}),(0,U.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,U.jsxs)(M,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim w-full max-w-sm rounded-xl shadow-xl border border-stone-200 p-5 bg-white`,children:[(0,U.jsx)(N,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:L(`nav.sortMenuTitle`)}),(0,U.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:L(`nav.sortHint`)}),(0,U.jsx)(`div`,{className:`mt-4 max-h-80 overflow-auto rounded-lg border border-stone-200 p-1`,children:A?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Me,{ids:ne,labelOf:e=>L(v(e).i18n),onChange:e=>te(A.id,e),onEnd:E,indent:!0}),j.length?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`mt-1 border-t border-stone-100 px-3 pb-1 pt-2 text-[11px] font-medium text-stone-400`,children:L(`nav.subgroups`)}),(0,U.jsx)(Me,{ids:j,labelOf:e=>{let t=r.find(t=>t.id===e);return t?Y(t):e},onChange:ee,onEnd:D,indent:!0})]}):null]}):(0,U.jsx)(Me,{ids:p,labelOf:e=>k.get(e)??e,onChange:O,onEnd:E})})]})})]})}function Pe(e,t){let n=[];for(let r of e.filter(e=>!e.parentId)){n.push({group:r,indent:!1});for(let i of f(e,r.id,t))n.push({group:i,indent:!0})}return n}function Fe(){return(0,U.jsx)(`svg`,{className:`tw-nav-group-pop-arrow`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,U.jsx)(`path`,{d:`M7 5l5 5-5 5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}var Ie=120;function Le(){let[e,t]=(0,R.useState)(null),n=(0,R.useRef)(null),r=(0,R.useCallback)(()=>{n.current!==null&&(window.clearTimeout(n.current),n.current=null)},[]),i=(0,R.useCallback)(e=>{r(),t({value:e,closing:!1})},[r]),a=(0,R.useCallback)(()=>{r(),t(e=>e&&!e.closing?{...e,closing:!0}:e),n.current=window.setTimeout(()=>{n.current=null,t(null)},Ie)},[r]),o=(0,R.useCallback)(()=>{r(),t(null)},[r]);return(0,R.useEffect)(()=>r,[r]),{value:e?.value??null,closing:!!e?.closing,open:i,close:a,closeNow:o}}function Re(e,t){return{onMouseOver:()=>e?.(),onMouseOut:e=>{let n=e.relatedTarget;n&&e.currentTarget.contains(n)||t?.()}}}function ze({anchor:e,current:t,itemId:n,closing:r,onPick:i,onHoverEnter:a,onHoverLeave:o}){let s=(0,R.useRef)(null),[c,l]=(0,R.useState)({top:e.top,left:e.right+8});return(0,R.useEffect)(()=>{let t=s.current;if(!t)return;let n=t.offsetWidth,r=t.offsetHeight,i=e.right+8,a=e.top-6;i+n>window.innerWidth-8&&(i=Math.max(8,e.left-n-6)),a+r>window.innerHeight-8&&(a=Math.max(8,window.innerHeight-r-8)),a<8&&(a=8),l({top:a,left:i})},[e]),(0,z.createPortal)((0,U.jsxs)(`div`,{ref:s,className:[`tw-nav-group-pop`,`tw-nav-icon-pop`,r?`is-closing`:``].filter(Boolean).join(` `),style:{top:c.top,left:c.left},...Re(a,o),children:[(0,U.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:L(`nav.chooseIcon`)}),(0,U.jsx)(`div`,{className:`tw-nav-icon-grid`,children:y.map(e=>(0,U.jsx)(`button`,{type:`button`,className:[`tw-nav-icon-cell`,t===e?`is-current`:``].filter(Boolean).join(` `),onClick:()=>i(e),children:(0,U.jsx)(Q,{id:n,icon:e})},e))})]}),document.body)}function Be({rect:e,closing:t=!1,onClose:n,onHoverEnter:r,onHoverLeave:i,children:a}){let o=(0,R.useRef)(null),[s,c]=(0,R.useState)({top:e.top,left:e.right+6});return(0,R.useEffect)(()=>{let t=o.current;if(!t)return;let n=t.offsetWidth,r=t.offsetHeight,i=e.right+6,a=e.top;i+n>window.innerWidth-8&&(i=Math.max(8,e.left-n-6)),a+r>window.innerHeight-8&&(a=Math.max(8,window.innerHeight-r-8)),c({top:a,left:i})},[e]),(0,R.useEffect)(()=>{let e=e=>{let t=e.target;o.current?.contains(t)||t?.closest?.(`.tw-nav-icon-pop`)||t?.closest?.(`.tw-nav-hover-btn`)||n()},t=e=>{e.key===`Escape`&&n()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),window.addEventListener(`resize`,n),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t),window.removeEventListener(`resize`,n)}},[n]),(0,z.createPortal)((0,U.jsx)(`div`,{ref:o,className:[`tw-nav-group-pop`,t?`is-closing`:``].filter(Boolean).join(` `),style:{top:s.top,left:s.left},...Re(r,i),children:a}),document.body)}function Ve(){let e=ge(),[t,n]=(0,R.useState)(()=>ae()),[i,a]=(0,R.useState)(()=>oe()),[c,d]=(0,R.useState)(()=>ce()),[f,h]=(0,R.useState)(()=>re()),[_,y]=(0,R.useState)(null),[b,C]=(0,R.useState)(!1),[w,T]=(0,R.useState)(null),[E,D]=(0,R.useState)(!1),[O,te]=(0,R.useState)(null),k=Le(),j=Le(),M=k.value,N=j.value,P=(0,R.useRef)(null);(0,R.useEffect)(()=>()=>{P.current!==null&&window.clearTimeout(P.current)},[]);function F(e){te(e),D(!0)}function I(e){y(e),C(!0)}function z(){C(!1),T(null)}(0,R.useEffect)(()=>{let e=!0,t=ne(e=>{h({...e})});return x().then(async()=>{e&&(await de(),e&&(n(ae()),d(ce()),a(oe()),h(re())))}),()=>{e=!1,t()}},[]);let B=ee(t,c);function V(e,t){let r=le(e,t);n(r.groups),d(r.order),ue(r.groups).then(e=>{if(!e||JSON.stringify(e)===JSON.stringify(r.groups))return;let t=le(e,r.order);n(t.groups),d(t.order)})}function H(){W(),j.close(),k.close()}function W(){P.current!==null&&(window.clearTimeout(P.current),P.current=null)}function G(){W(),P.current=window.setTimeout(()=>{P.current=null,j.close()},220)}function K(e,t){W(),j.open({itemId:e,rect:t.getBoundingClientRect()})}function q(e,t){M?.kind===`itemMenu`&&M.itemId===e?H():(j.closeNow(),k.open({kind:`itemMenu`,itemId:e,rect:t.getBoundingClientRect()}))}function fe(e,t){M?.kind===`groupMenu`&&M.group.id===e.id?H():(j.closeNow(),k.open({kind:`groupMenu`,group:e,rect:t.getBoundingClientRect()}))}function pe(e,n){V(g(t,e,n),c),H()}function me(e){let{groups:n,owner:r}=o(t,e);V(n,r?S(c,e,r,n):c),H()}let J=M?.kind===`assign`||M?.kind===`itemMenu`?M.itemId:void 0,he=M?.kind===`groupMenu`?M.group.id:void 0,X=M?.kind===`itemMenu`?M:null,Z=M?.kind===`groupMenu`?M:null,Q=M?.kind===`assign`?M:null,_e=X?t.find(e=>e.items.includes(X.itemId))??null:null;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`tw-nav-ready`,"aria-hidden":`true`}),B.map(n=>n.type===`item`?$(n.id,f)?(0,U.jsx)(De,{id:n.id,icon:i[n.id],pathname:e,actionOpen:J===n.id,onMenu:e=>q(n.id,e)},n.id):null:(0,U.jsx)(Ae,{group:n.group,groups:t,order:c,icons:i,pathname:e,openItem:J,openGroupId:he,onMenu:fe,onItemMenu:q},n.group.id)),X?(0,U.jsxs)(Be,{rect:X.rect,closing:k.closing,onClose:H,onHoverEnter:W,onHoverLeave:G,children:[(0,U.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:L(v(X.itemId).i18n)}),(0,U.jsxs)(`div`,{className:`tw-nav-group-pop-list`,onMouseOver:e=>{let t=e.target.closest(`.tw-nav-group-pop-item`);t&&t.getAttribute(`data-submenu`)!==`icons`&&(W(),j.close())},children:[_e?(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item is-leave`,onClick:()=>me(X.itemId),children:[(0,U.jsx)(Ce,{}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.leaveGroup`)})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>k.open({kind:`assign`,itemId:X.itemId,rect:X.rect}),children:[(0,U.jsx)(Se,{}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.assignGroup`)})]}),(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=X.itemId;H(),I({name:``,items:[e]})},children:[(0,U.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,U.jsx)(be,{})}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.addToGroup`)})]})]}),(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=_e?.id??null;H(),F(e)},children:[(0,U.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,U.jsx)(Te,{})}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.sortMenu`)})]}),(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,"data-submenu":`icons`,onMouseEnter:e=>K(X.itemId,e.currentTarget),onClick:e=>K(X.itemId,e.currentTarget),children:[(0,U.jsx)(we,{}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.chooseIcon`)}),(0,U.jsx)(Fe,{})]})]})]}):null,N&&X&&N.itemId===X.itemId?(0,U.jsx)(ze,{anchor:N.rect,itemId:N.itemId,current:i[N.itemId],closing:j.closing,onHoverEnter:W,onHoverLeave:G,onPick:e=>{a(se(N.itemId,e)),H()}}):null,Z?(0,U.jsxs)(Be,{rect:Z.rect,closing:k.closing,onClose:H,children:[(0,U.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:Y(Z.group)}),(0,U.jsxs)(`div`,{className:`tw-nav-group-pop-list`,children:[Z.group.parentId?null:(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item is-create`,onClick:()=>{let e=Z.group.id;H(),I({name:``,items:[],parentId:e})},children:[(0,U.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,U.jsx)(be,{})}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.addSubgroup`)})]}),(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=Z.group;H(),F(e.parentId??null)},children:[(0,U.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,U.jsx)(Te,{})}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.sortMenu`)})]}),(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=Z.group;H(),I({id:e.id,name:e.name,items:[...e.items],parentId:e.parentId})},children:[(0,U.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,U.jsx)(ye,{})}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.editGroupTitle`)})]})]})]}):null,Q?(0,U.jsxs)(Be,{rect:Q.rect,closing:k.closing,onClose:H,children:[(0,U.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:L(`nav.assignGroup`)}),(0,U.jsx)(`div`,{className:`tw-nav-group-pop-list`,children:t.length?Pe(t,c).map(({group:e,indent:t})=>{let n=e.items.includes(Q.itemId);return(0,U.jsxs)(`button`,{type:`button`,className:[`tw-nav-group-pop-item`,n?`is-current`:``,t?`is-child`:``].filter(Boolean).join(` `),onClick:()=>{n||pe(e.id,Q.itemId)},children:[(0,U.jsx)(Se,{}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:Y(e)}),n?(0,U.jsx)(`span`,{className:`tw-nav-group-pop-tag`,children:L(`nav.currentGroup`)}):null]},e.id)}):(0,U.jsx)(`div`,{className:`tw-nav-group-pop-empty`,children:L(`nav.noGroups`)})})]}):null,(0,U.jsx)(je,{open:b&&!w,draft:_,groups:t,plugins:f,icons:i,onClose:z,onSave:e=>{let n=p(t,e);V(n.groups,u(c,n.groups,n.id)),z()},onDelete:_?.id?()=>T(_.id):void 0}),(0,U.jsx)(Ne,{open:E,focusGroupId:O,nodes:B,groups:t,order:c,visible:e=>$(e,f),onClose:()=>D(!1),onCommit:(e,t)=>{let n=c.filter(e=>m(e,t));V(t,[...e,...n.filter(t=>!e.includes(t))])},onChildCommit:(e,n)=>V(t,r(c,t,e,n))}),(0,U.jsx)(ie,{open:!!w,title:L(`nav.deleteGroup`),message:t.find(e=>e.id===w)?.parentId?L(`nav.deleteSubgroupMsg`):L(`nav.deleteGroupMsg`),confirmLabel:L(`nav.deleteGroup`),cancelLabel:L(`nav.groupCancel`),danger:`outline`,onClose:()=>T(null),onConfirm:()=>{if(w){let e=t.find(e=>e.id===w),n=A(t,w),r=s(t,w);V(r,e?l(c,e,r,n):c)}z()}})]})}export{Ve as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{t as default}from"./PluginsPage.BEAPymNL.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.DUyozIL9.js";import{a as r,c as i,i as a,n as o,t as s}from"./plugins.BDZqJNOy.js";import{o as c}from"./case-exec.BipZCK6G.js";import{a as l,n as u}from"./view-prefs.Dyu_lmN2.js";import{t as d}from"./jsx-runtime.BUXbF_vF.js";import"./settings.C6NWuiFO.js";import{t as f}from"./OverflowHint.lzmplP5j.js";import{N as p,v as m}from"./pm.Bl3hz9fF.js";import{s as h,w as g}from"./tasks.otRBFydq.js";import{s as _}from"./report-prompt.Cmw4XzfY.js";import{r as v}from"./test-stats.MEm3K2rB.js";var y=e(t(),1),b=`/__tb_fs`,x=`你可以使用本地文件工具(侧栏工作区已连接时):
|
|
2
2
|
- 侧栏「工作区」决定当前目录;fs_* 默认相对该工作区
|
|
3
3
|
- working_directory_get / working_directory_set:查看或切换当前工作区(已注册列表内)
|
|
4
4
|
- 「仅可查看」「工作区内修改」:用工作区相对路径
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{o as n}from"./plugins.BDZqJNOy.js";import{t as r}from"./jsx-runtime.BUXbF_vF.js";import{t as ee}from"./ConfirmDialog.CBVsDJ8f.js";import{n as te,t as ne}from"./DocsPager.C20ue_JZ.js";import{t as i}from"./SelectDropdown.Buv7rQJ_.js";import{A as a,F as o,I as re,M as ie,b as ae,g as oe,h as se,i as s,k as c,m as l,n as u,p as ce,r as d,t as f}from"./pm.Bl3hz9fF.js";import{D as p,E as le,O as ue,S as de,T as fe,_ as m,a as pe,c as me,d as he,f as h,g as ge,h as _e,k as ve,l as ye,m as g,n as be,p as xe,s as Se,t as Ce,u as we,y as _}from"./PmShared.BxTHKdjY.js";var v=e(t(),1),y=r(),Te=20,Ee=`tw.pm-bugs.page-size.v1`,De=[`all`,...d],Oe=[`all`,...f],ke=`pm.bugs.project`,Ae=`pm.bugs.iteration`,je=`pm.bugs.status`,Me=`pm.bugs.severity`,Ne=`pm.bugs.keyword`,b=f.map(e=>({value:e,label:u[e]})),x=d.map(e=>({value:e,label:s[e]}));function S(e=``){return{projectId:e,iterationId:``,requirementId:``,title:``,severity:`minor`,status:`pending`,reproduceSteps:``,expectedResult:``,actualResult:``,environment:``,githubIssue:``,attachment:``,remark:``}}function Pe(e){try{let t=new URL(e,`http://localhost`).searchParams.get(`p`)??``;return/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(t)}catch{return!1}}function C({scopeProjectId:e=``}={}){let t=!!e,r=ue(`bugs`),{store:d,live:f,loading:C,error:w,setError:T,reload:E}=ve(),[D,O]=p(ke,`all`),k=e||D,[A,j]=p(Ae,`all`),[M,Fe]=le(je,De,`all`),[N,Ie]=le(Me,Oe,`all`),[P,Le]=p(Ne),[Re,F]=(0,v.useState)(1),[I,ze]=te(Te,Ee),[L,R]=(0,v.useState)(null),[z,B]=(0,v.useState)(!1),[V,Be]=(0,v.useState)(!1),H=(0,v.useRef)(null),U=(0,v.useRef)(new Set),[W,G]=(0,v.useState)(null),[Ve,K]=(0,v.useState)(null),q=(0,v.useMemo)(()=>a(L?.attachment??``),[L?.attachment]);(0,v.useEffect)(()=>{for(let e of q)U.current.add(e.url)},[q]);let He=(0,v.useMemo)(()=>[{value:`all`,label:`全部项目`},...d.projects.map(e=>({value:e.id,label:e.name}))],[d.projects]),Ue=(0,v.useMemo)(()=>[{value:`all`,label:`全部迭代`},...d.iterations.filter(e=>k===`all`||e.projectId===k).map(e=>({value:e.id,label:e.name}))],[d.iterations,k]),We=(0,v.useMemo)(()=>{let e=new Map(d.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[d.projects]),Ge=(0,v.useMemo)(()=>{let e=new Map(d.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[d.iterations]),J=(0,v.useMemo)(()=>ie(ae(d.bugs,{projectId:k,iterationId:A,status:M,severity:N,keyword:P})),[d.bugs,k,A,M,N,P]),Y=t?d.bugs.filter(e=>e.projectId===k).length:d.bugs.length,Ke=Math.max(1,Math.ceil(J.length/I)),X=Math.min(Re,Ke),Z=J.slice((X-1)*I,X*I);(0,v.useEffect)(()=>{t||f===!0&&D!==`all`&&!d.projects.some(e=>e.id===D)&&O(`all`)},[f,d.projects,D,O,t]),(0,v.useEffect)(()=>{f===!0&&A!==`all`&&!d.iterations.some(e=>e.id===A&&(k===`all`||e.projectId===k))&&j(`all`)},[f,d.iterations,k,A,j]);let qe=L?d.iterations.filter(e=>e.projectId===L.projectId):[],Je=L?d.requirements.filter(e=>e.projectId===L.projectId):[];async function Ye(){if(!L)return;if(!L.projectId){T(`请先选择所属项目`);return}let e=L.reproduceSteps.trim();if(!e){T(`缺陷描述不能为空`);return}let t=ce(e);B(!0);try{let n={projectId:L.projectId,iterationId:L.iterationId,requirementId:L.requirementId,title:t,severity:L.severity,status:L.status,reproduceSteps:e,expectedResult:L.expectedResult,actualResult:L.actualResult,environment:L.environment,githubIssue:L.githubIssue,attachment:L.attachment,remark:L.remark};L.id?await o(`bugs`,L.id,n):await se(`bugs`,[n]),R(null),U.current.clear(),T(``),await E(!0)}catch(e){T(e instanceof Error?e.message:String(e))}finally{B(!1)}}let Q=(0,v.useCallback)(async e=>{if(e&&e.length){Be(!0);try{let t=await re(Array.from(e));R(e=>{if(!e)return e;let n=a(e.attachment);return{...e,attachment:c([...n,...t])}}),T(``)}catch(e){T(e instanceof Error?e.message:String(e))}finally{Be(!1),H.current&&(H.current.value=``)}}},[T]),$=L!==null;(0,v.useEffect)(()=>{if(!$)return;let e=e=>{let t=Array.from(e.clipboardData?.files??[]);t.length&&(e.preventDefault(),Q(t))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[$,Q]);async function Xe(e){if(!L)return;let t=c(q.filter(t=>t.url!==e));if(L.id)try{await o(`bugs`,L.id,{attachment:t}),await E(!0)}catch(e){T(e instanceof Error?e.message:String(e));return}R(e=>e&&{...e,attachment:t}),l([e],L.id??``)}function Ze(){let e=[...U.current,...q.map(e=>e.url)];U.current.clear(),R(null),e.length&&l(e)}async function Qe(e,t){B(!0);try{await o(`bugs`,e.id,{status:t}),await E(!0)}catch(e){T(e instanceof Error?e.message:String(e))}finally{B(!1)}}async function $e(){let e=W;if(e){G(null),B(!0);try{await oe(`bugs`,[e.id]),await E(!0)}catch(e){T(e instanceof Error?e.message:String(e))}finally{B(!1)}}}if(!r.ready)return(0,y.jsx)(ge,{label:`正在读取插件开关`});if(!r.on)return(0,y.jsx)(m,{children:n(`bugs`)});if(f===null)return(0,y.jsx)(ge,{label:`正在连接项目管理服务`});if(!f)return(0,y.jsx)(m,{children:`缺陷管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(d.projects.length===0&&!C&&!t)return(0,y.jsx)(m,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来记录缺陷。`});let et=[{value:`all`,label:`全部`},...x];return(0,y.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`共 `,(0,y.jsx)(`span`,{className:`font-medium text-stone-600`,children:Y}),` 条缺陷`,J.length===Y?``:` · 筛选出 ${J.length} 条`]}),(0,y.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,y.jsx)(i,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选缺陷`,className:`w-36`,options:He,value:D,onChange:e=>{O(e),j(`all`),F(1)}}),(0,y.jsx)(i,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选缺陷`,className:`w-32`,options:Ue,value:A,onChange:e=>{j(e),F(1)}}),(0,y.jsx)(i,{flat:!0,showCheck:!1,ariaLabel:`按严重程度筛选缺陷`,className:`w-32`,options:[{value:`all`,label:`全部严重程度`},...b],value:N,onChange:e=>{Ie(e),F(1)}}),(0,y.jsxs)(`label`,{className:`relative block`,children:[(0,y.jsx)(g,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,y.jsx)(`input`,{value:P,onChange:e=>{Le(e.target.value),F(1)},placeholder:`搜索编号 / 标题…`,className:`h-9 w-48 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,y.jsxs)(`button`,{type:`button`,disabled:z,onClick:()=>R(S(k===`all`?``:k)),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:[(0,y.jsx)(g,{name:`plus`,size:14}),`新建缺陷`]})]})]}),(0,y.jsx)(`div`,{className:`mt-3 flex shrink-0 flex-wrap items-center gap-2`,children:(0,y.jsx)(xe,{ariaLabel:`按状态筛选缺陷`,options:et,value:M,onChange:e=>{Fe(e),F(1)}})}),w?(0,y.jsx)(he,{message:w,onClose:()=>T(``)}):null,(0,y.jsxs)(`div`,{className:`mt-3 flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,y.jsxs)(`table`,{className:`tw-data-table w-full border-collapse text-sm`,children:[(0,y.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,y.jsxs)(`tr`,{children:[(0,y.jsx)(`th`,{className:`w-px px-4 py-2.5 text-left font-medium whitespace-nowrap`,children:`ID`}),(0,y.jsx)(`th`,{className:`px-4 py-2.5 text-left font-medium`,children:`缺陷标题`}),(0,y.jsx)(`th`,{className:`w-28 px-3 py-2.5 text-left font-medium whitespace-nowrap`,children:`严重程度`}),(0,y.jsx)(`th`,{className:`w-32 px-3 py-2.5 text-left font-medium whitespace-nowrap`,children:`缺陷状态`}),t?null:(0,y.jsx)(`th`,{className:`w-40 px-3 py-2.5 text-left font-medium whitespace-nowrap`,children:`所属项目`}),(0,y.jsx)(`th`,{className:`w-40 px-3 py-2.5 text-left font-medium whitespace-nowrap`,children:`所属迭代`}),(0,y.jsx)(`th`,{className:`w-24 px-3 py-2.5 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,y.jsxs)(`tbody`,{children:[C&&!d.bugs.length?(0,y.jsx)(`tr`,{children:(0,y.jsx)(`td`,{colSpan:t?6:7,className:`px-4 py-16 text-center`,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):Z.length===0?(0,y.jsx)(`tr`,{children:(0,y.jsx)(`td`,{colSpan:t?6:7,children:Y?(0,y.jsx)(ye,{children:`没有符合筛选条件的缺陷。`}):(0,y.jsx)(we,{icon:`bug`,title:`暂无缺陷`,hint:`记录第一个缺陷,跟踪严重程度与修复状态。`,action:(0,y.jsxs)(`button`,{type:`button`,onClick:()=>R(S(k===`all`?``:k)),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,y.jsx)(g,{name:`plus`,size:13}),`新建缺陷`]})})})}):null,Z.map(e=>(0,y.jsxs)(`tr`,{className:`border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,y.jsx)(`td`,{className:`whitespace-nowrap px-4 py-2.5 font-mono text-xs text-stone-400`,children:e.autoId}),(0,y.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,y.jsx)(`button`,{type:`button`,onClick:()=>R({id:e.id,projectId:e.projectId,iterationId:e.iterationId,requirementId:e.requirementId,title:e.title,severity:e.severity,status:e.status,reproduceSteps:e.reproduceSteps||e.title,expectedResult:e.expectedResult,actualResult:e.actualResult,environment:e.environment,githubIssue:e.githubIssue,attachment:e.attachment,remark:e.remark}),className:`max-w-full truncate text-left text-stone-800 hover:text-[#3370ff]`,children:e.title})}),(0,y.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,y.jsx)(de,{tone:Ce[e.severity],children:u[e.severity]})}),(0,y.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,y.jsx)(i,{unstyled:!0,ariaLabel:`修改 ${e.title} 的状态`,disabled:z,options:x,value:e.status,onChange:t=>void Qe(e,t),renderOptionPrefix:e=>(0,y.jsx)(Se,{tone:be[e.value]}),renderTrigger:()=>(0,y.jsx)(de,{tone:be[e.status],children:s[e.status]})})}),t?null:(0,y.jsx)(`td`,{className:`truncate px-3 py-2.5 text-sm text-stone-600`,children:(0,y.jsx)(`a`,{href:fe(e.projectId),className:`transition-colors hover:text-[#3370ff]`,children:We(e.projectId)})}),(0,y.jsx)(`td`,{className:`truncate px-3 py-2.5 text-sm text-stone-500`,children:Ge(e.iterationId)}),(0,y.jsx)(`td`,{className:`px-3 py-2.5 text-center`,children:(0,y.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,disabled:z,onClick:()=>G(e),className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 disabled:opacity-40`,children:(0,y.jsx)(g,{name:`trash`,size:15})})})]},e.id))]})]})}),J.length>0?(0,y.jsx)(ne,{page:X,totalPages:Ke,pageSize:I,busy:z,onPage:F,onPageSize:e=>{ze(e),F(1)}}):null]}),(0,y.jsx)(me,{open:L!==null,title:L?.id?`编辑缺陷`:`新建缺陷`,busy:z,submitLabel:L?.id?`保存`:`创建`,onClose:Ze,onSubmit:()=>void Ye(),children:L?(0,y.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,y.jsx)(h,{label:`所属项目`,required:!0,children:(0,y.jsx)(_,{ariaLabel:`所属项目`,options:d.projects.map(e=>({value:e.id,label:e.name})),value:L.projectId,onChange:e=>R({...L,projectId:e,iterationId:``,requirementId:``})})}),(0,y.jsx)(h,{label:`所属迭代`,children:(0,y.jsx)(_,{ariaLabel:`所属迭代`,options:[{value:``,label:`不关联迭代`},...qe.map(e=>({value:e.id,label:e.name}))],value:L.iterationId,onChange:e=>R({...L,iterationId:e}),disabled:qe.length===0})}),(0,y.jsx)(h,{label:`关联需求`,children:(0,y.jsx)(_,{ariaLabel:`关联需求`,options:[{value:``,label:`不关联需求`},...Je.map(e=>({value:e.id,label:`${e.autoId} ${e.title}`}))],value:L.requirementId,onChange:e=>R({...L,requirementId:e}),disabled:Je.length===0})}),(0,y.jsx)(h,{label:`缺陷描述`,required:!0,children:(0,y.jsx)(`textarea`,{autoFocus:!0,value:L.reproduceSteps,onChange:e=>R({...L,reproduceSteps:e.target.value}),placeholder:`描述问题现象、复现步骤与影响范围`,rows:5,className:pe})}),(0,y.jsx)(h,{label:`严重程度`,children:(0,y.jsx)(_,{ariaLabel:`严重程度`,options:b,value:L.severity,onChange:e=>R({...L,severity:e}),renderOptionPrefix:e=>(0,y.jsx)(Se,{tone:Ce[e.value]})})}),(0,y.jsx)(h,{label:`附件`,children:(0,y.jsxs)(`div`,{className:`space-y-2`,children:[q.length?(0,y.jsx)(`ul`,{className:`space-y-1.5`,children:q.map(e=>{let t=Pe(e.url);return(0,y.jsxs)(`li`,{className:`flex items-center gap-2 rounded-lg border border-stone-200 px-2 py-1.5`,children:[t?(0,y.jsx)(`button`,{type:`button`,onClick:()=>K(e),"aria-label":`预览附件 ${e.name}`,className:`shrink-0 cursor-zoom-in`,children:(0,y.jsx)(`img`,{src:e.url,alt:e.name,className:`h-9 w-9 rounded-md border border-stone-100 object-cover`})}):(0,y.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-stone-100 text-stone-400`,children:(0,y.jsx)(g,{name:`file`,size:15})}),t?(0,y.jsx)(`button`,{type:`button`,onClick:()=>K(e),className:`min-w-0 flex-1 truncate text-left text-sm text-stone-700 hover:text-[#3370ff]`,children:e.name}):(0,y.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`min-w-0 flex-1 truncate text-sm text-stone-700 hover:text-[#3370ff]`,children:e.name}),(0,y.jsx)(`button`,{type:`button`,"aria-label":`移除附件 ${e.name}`,onClick:()=>Xe(e.url),className:`flex h-6 w-6 shrink-0 items-center justify-center rounded text-stone-300 hover:bg-red-50 hover:text-red-600`,children:`✕`})]},e.url)})}):null,(0,y.jsx)(`input`,{ref:H,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void Q(e.target.files)}),(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`button`,{type:`button`,disabled:V,onClick:()=>H.current?.click(),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-dashed border-stone-300 px-2.5 text-xs text-stone-500 transition-colors hover:border-stone-400 hover:text-stone-700 disabled:opacity-40`,children:[(0,y.jsx)(g,{name:V?`file`:`plus`,size:13}),V?`上传中…`:`上传文件 / 图片`]}),(0,y.jsx)(`span`,{className:`text-xs text-stone-400`,children:`可直接粘贴截图 / 图片(⌘V / Ctrl+V),支持多张`})]})]})}),(0,y.jsx)(h,{label:`备注`,children:(0,y.jsx)(`textarea`,{value:L.remark,onChange:e=>R({...L,remark:e.target.value}),rows:2,className:pe})})]}):null}),(0,y.jsx)(ee,{open:W!==null,title:`删除缺陷`,message:`确定删除「${W?.title??``}」?此操作无法恢复。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>G(null),onConfirm:()=>void $e()}),(0,y.jsx)(_e,{file:Ve,onClose:()=>K(null)})]})}export{C as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{o as n}from"./plugins.BDZqJNOy.js";import{t as r}from"./jsx-runtime.BUXbF_vF.js";import{t as i}from"./ConfirmDialog.CBVsDJ8f.js";import{t as a}from"./DatePicker.CMfX7F6z.js";import{t as o}from"./SelectDropdown.Buv7rQJ_.js";import{D as ee,F as s,O as te,P as ne,a as c,g as re,h as ie,o as l,x as u}from"./pm.Bl3hz9fF.js";import{D as d,E as f,O as p,S as m,T as ae,_ as h,a as oe,c as se,d as ce,f as g,g as _,i as v,k as le,l as ue,m as y,r as b,s as de,u as x,v as S,y as C}from"./PmShared.BxTHKdjY.js";var w=e(t(),1),T=r(),E=10,fe=[`all`,...c],pe=`pm.iterations.project`,me=`pm.iterations.status`,D=`pm.iterations.keyword`,O=c.map(e=>({value:e,label:l[e]}));function k(e=``){return{projectId:e,name:``,startDate:``,endDate:``,status:`planning`,remark:``}}function A({scopeProjectId:e=``}={}){let t=!!e,r=p(`iterations`),{store:c,live:A,loading:j,error:M,setError:N,reload:P}=le(),[F,I]=d(pe,`all`),L=e||F,[R,he]=f(me,fe,`all`),[z,ge]=d(D),[_e,B]=(0,w.useState)(1),[V,H]=(0,w.useState)(null),[U,W]=(0,w.useState)(!1),[G,K]=(0,w.useState)(null),q=ne(),ve=(0,w.useMemo)(()=>{let e=new Map(c.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`未关联项目`},[c.projects]),ye=(0,w.useMemo)(()=>[{value:`all`,label:`全部项目`},...c.projects.map(e=>({value:e.id,label:e.name}))],[c.projects]),J=(0,w.useMemo)(()=>u(c.iterations,{projectId:L,status:R,keyword:z}),[c.iterations,L,R,z]),Y=t?c.iterations.filter(e=>e.projectId===L).length:c.iterations.length,X=Math.max(1,Math.ceil(J.length/E)),Z=Math.min(_e,X),Q=J.slice((Z-1)*E,Z*E);(0,w.useEffect)(()=>{t||A===!0&&F!==`all`&&!c.projects.some(e=>e.id===F)&&I(`all`)},[A,c.projects,F,I,t]);async function be(){if(!V)return;if(!V.projectId){N(`请先选择所属项目`);return}let e=V.name.trim();if(!e)N(`迭代名称不能为空`);else if(V.startDate&&V.endDate&&V.endDate<V.startDate)N(`迭代结束日期不能早于开始日期`);else{W(!0);try{let t={projectId:V.projectId,name:e,startDate:V.startDate,endDate:V.endDate,status:V.status,remark:V.remark};V.id?await s(`iterations`,V.id,t):await ie(`iterations`,[t]),H(null),N(``),await P(!0)}catch(e){N(e instanceof Error?e.message:String(e))}finally{W(!1)}}}async function $(e,t){W(!0);try{await s(`iterations`,e.id,{status:t}),await P(!0)}catch(e){N(e instanceof Error?e.message:String(e))}finally{W(!1)}}async function xe(){let e=G;if(e){K(null),W(!0);try{await re(`iterations`,[e.id]),await P(!0)}catch(e){N(e instanceof Error?e.message:String(e))}finally{W(!1)}}}return r.ready?r.on?A===null?(0,T.jsx)(_,{label:`正在连接项目管理服务`}):A?c.projects.length===0&&!j&&!t?(0,T.jsx)(h,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来维护迭代。`}):(0,T.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,T.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`共 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-600`,children:Y}),` 个迭代`,J.length===Y?``:` · 筛选出 ${J.length} 个`]}),(0,T.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,T.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选迭代`,className:`w-36`,options:ye,value:F,onChange:e=>{I(e),B(1)}}),(0,T.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按状态筛选迭代`,className:`w-28`,options:[{value:`all`,label:`全部状态`},...O],value:R,onChange:e=>{he(e),B(1)}}),(0,T.jsxs)(`label`,{className:`relative block`,children:[(0,T.jsx)(y,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,T.jsx)(`input`,{value:z,onChange:e=>{ge(e.target.value),B(1)},placeholder:`搜索迭代名称…`,className:`h-9 w-44 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,T.jsxs)(`button`,{type:`button`,disabled:U,onClick:()=>H(k(L===`all`?``:L)),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:[(0,T.jsx)(y,{name:`plus`,size:14}),`新建迭代`]})]})]}),M?(0,T.jsx)(ce,{message:M,onClose:()=>N(``)}):null,(0,T.jsx)(`div`,{className:`mt-4 min-h-0 flex-1 overflow-auto pb-4`,children:j&&!c.iterations.length?(0,T.jsx)(`div`,{className:`flex min-h-[200px] items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})}):Q.length===0?Y?(0,T.jsx)(ue,{children:`没有符合筛选条件的迭代。`}):(0,T.jsx)(x,{icon:`calendar`,title:`暂无迭代`,hint:`新建一个迭代,用开始 / 截止日期跟踪进度。`,action:(0,T.jsxs)(`button`,{type:`button`,onClick:()=>H(k(L===`all`?``:L)),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,T.jsx)(y,{name:`plus`,size:13}),`新建迭代`]})}):(0,T.jsx)(`div`,{className:`space-y-3`,children:Q.map(e=>{let n=te(e,q),r=ee(e,q),i=e.endDate&&e.status!==`done`?Math.round((Date.parse(`${e.endDate}T00:00:00`)-Date.parse(`${q}T00:00:00`))/864e5):null;return(0,T.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3.5 transition-[border-color,box-shadow] hover:border-[#ddd6fe] hover:shadow-sm`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`truncate text-[15px] font-medium text-stone-800`,children:e.name}),(0,T.jsx)(m,{tone:b[e.status],children:l[e.status]})]}),(0,T.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-stone-500`,children:[t?null:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`a`,{href:ae(e.projectId),className:`transition-colors hover:text-[#3370ff]`,children:ve(e.projectId)}),(0,T.jsx)(`span`,{className:`text-stone-300`,children:`·`})]}),(0,T.jsxs)(`span`,{className:`tabular-nums`,children:[e.startDate||`—`,` → `,e.endDate||`—`]}),r===null?i!==null&&i>=0&&e.endDate?(0,T.jsxs)(`span`,{className:`text-stone-400`,children:[`还剩 `,i,` 天`]}):null:(0,T.jsxs)(`span`,{className:`text-red-500`,children:[`逾期 `,r,` 天`]})]}),e.remark?(0,T.jsx)(`p`,{className:`mt-1 line-clamp-1 text-xs text-stone-400`,children:e.remark}):null]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.status===`planning`?(0,T.jsxs)(`button`,{type:`button`,disabled:U,onClick:()=>void $(e,`in_progress`),className:`inline-flex h-8 items-center gap-1 rounded-lg px-2 text-xs text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:[(0,T.jsx)(y,{name:`play`,size:12}),`开始`]}):null,e.status===`in_progress`?(0,T.jsxs)(`button`,{type:`button`,disabled:U,onClick:()=>void $(e,`done`),className:`inline-flex h-8 items-center gap-1 rounded-lg px-2 text-xs text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:[(0,T.jsx)(y,{name:`check`,size:12}),`完成`]}):null,(0,T.jsx)(`button`,{type:`button`,"aria-label":`编辑 ${e.name}`,onClick:()=>H({id:e.id,projectId:e.projectId,name:e.name,startDate:e.startDate,endDate:e.endDate,status:e.status,remark:e.remark}),className:`flex h-8 w-8 items-center justify-center rounded-lg text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,children:(0,T.jsx)(y,{name:`pencil`,size:15})}),(0,T.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.name}`,disabled:U,onClick:()=>K(e),className:`flex h-8 w-8 items-center justify-center rounded-lg text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 disabled:opacity-40`,children:(0,T.jsx)(y,{name:`trash`,size:15})})]})]}),(0,T.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,T.jsx)(`div`,{className:`h-2 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,T.jsx)(`div`,{className:`h-full rounded-full bg-[#3370ff] transition-[width] duration-300`,style:{width:`${n}%`}})}),(0,T.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs tabular-nums text-stone-500`,children:[n,`%`]})]})]},e.id)})})}),J.length>0?(0,T.jsx)(S,{page:Z,totalPages:X,busy:U,onPage:B}):null,(0,T.jsx)(se,{open:V!==null,title:V?.id?`编辑迭代`:`新建迭代`,busy:U,submitLabel:V?.id?`保存`:`创建`,onClose:()=>H(null),onSubmit:()=>void be(),children:V?(0,T.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,T.jsx)(g,{label:`所属项目`,required:!0,children:(0,T.jsx)(C,{ariaLabel:`所属项目`,options:c.projects.map(e=>({value:e.id,label:e.name})),value:V.projectId,onChange:e=>H({...V,projectId:e}),disabled:c.projects.length===0})}),(0,T.jsx)(g,{label:`迭代名称`,required:!0,children:(0,T.jsx)(`input`,{autoFocus:!0,value:V.name,onChange:e=>H({...V,name:e.target.value}),placeholder:`如:v1.0 迭代`,className:v})}),(0,T.jsx)(g,{label:`开始日期`,children:(0,T.jsx)(a,{value:V.startDate,onChange:e=>H({...V,startDate:e}),placeholder:`选择开始日期`,className:`${v} tabular-nums`})}),(0,T.jsx)(g,{label:`截止日期`,children:(0,T.jsx)(a,{value:V.endDate,onChange:e=>H({...V,endDate:e}),placeholder:`选择截止日期`,className:`${v} tabular-nums`})}),(0,T.jsx)(g,{label:`状态`,children:(0,T.jsx)(C,{ariaLabel:`迭代状态`,options:O,value:V.status,onChange:e=>H({...V,status:e}),renderOptionPrefix:e=>(0,T.jsx)(de,{tone:b[e.value]})})}),(0,T.jsx)(g,{label:`备注`,children:(0,T.jsx)(`textarea`,{value:V.remark,onChange:e=>H({...V,remark:e.target.value}),placeholder:`迭代目标、范围等(可选)`,rows:3,className:oe})})]}):null}),(0,T.jsx)(i,{open:G!==null,title:`删除迭代`,message:`确定删除「${G?.name??``}」?关联的需求与缺陷会保留,但不再关联到这个迭代。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>K(null),onConfirm:()=>void xe()})]}):(0,T.jsx)(h,{children:`迭代管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,T.jsx)(h,{children:n(`iterations`)}):(0,T.jsx)(_,{label:`正在读取插件开关`})}export{A as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{o as n}from"./plugins.
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{o as n}from"./plugins.BDZqJNOy.js";import{t as r}from"./jsx-runtime.BUXbF_vF.js";import{c as i,j as a}from"./pm.Bl3hz9fF.js";import{E as o,O as s,S as c,_ as l,b as u,g as d,k as f,m as p,o as m,u as h,x as g}from"./PmShared.BxTHKdjY.js";import _ from"./PmBugsBoard.CPEyBp0l.js";import v from"./PmIterationsBoard.zCeLpcBo.js";import{t as y}from"./PmRequirementsBoard.CynewRfv.js";var b=e(t(),1),x=r(),S=[`iterations`,`requirements`,`bugs`],C=`pm.project.tab`,w=`/pm/projects/`;function T(){let e=s(`projects`);return e.ready?e.on?(0,x.jsx)(u,{children:(0,x.jsx)(E,{})}):(0,x.jsx)(l,{children:n(`projects`)}):(0,x.jsx)(d,{label:`正在读取插件开关`})}function E(){let{store:e,live:t,loading:n}=f(),[r,s]=(0,b.useState)(``),[u,T]=o(C,S,`iterations`);(0,b.useEffect)(()=>{s(new URLSearchParams(window.location.search).get(`id`)??``)},[]);let E=(0,b.useMemo)(()=>e.projects.find(e=>e.id===r),[e.projects,r]),O=(0,b.useMemo)(()=>a(e),[e]);if(t===null)return(0,x.jsx)(d,{label:`正在连接项目管理服务`});if(!t)return(0,x.jsx)(l,{children:`项目详情需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(!E)return n&&!e.projects.length?(0,x.jsx)(d,{label:`正在读取项目`}):(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,x.jsx)(D,{}),(0,x.jsx)(h,{icon:`folder`,title:`没有找到这个项目`,hint:`它可能已被删除,或链接里的项目 id 不正确。`})]});let k=O[E.id],A=[{value:`iterations`,label:`迭代`,count:k?.iterations??0},{value:`requirements`,label:`需求`,count:k?.requirements??0},{value:`bugs`,label:`缺陷`,count:k?.bugs??0}];return(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,x.jsxs)(`header`,{className:`flex shrink-0 items-start gap-3`,children:[(0,x.jsx)(`a`,{href:w,"aria-label":`返回项目列表`,className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-stone-500 transition-colors hover:bg-stone-100 hover:text-stone-800`,children:(0,x.jsx)(p,{name:`arrowLeft`,size:18})}),(0,x.jsx)(`span`,{className:`tw-pm-tile flex h-9 w-9 shrink-0 items-center justify-center rounded-xl text-sm font-bold`,children:E.name.slice(0,1)}),(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,x.jsx)(`h1`,{className:`truncate text-lg font-semibold text-stone-800`,children:E.name}),(0,x.jsx)(c,{tone:m[E.status],children:i[E.status]})]}),(0,x.jsx)(`p`,{className:`mt-0.5 text-xs ${E.description?`text-stone-400`:`text-stone-300 italic`}`,children:E.description||`暂无描述`})]})]}),(0,x.jsxs)(`div`,{className:`mt-5 flex shrink-0 flex-wrap items-center justify-between gap-3`,children:[(0,x.jsx)(g,{tabs:A,value:u,onChange:T,ariaLabel:`项目二级菜单`}),(0,x.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`需求完成 `,k?.requirementPercent??0,`% · 缺陷完成 `,k?.bugClosedPercent??100,`%`]})]}),(0,x.jsxs)(`div`,{className:`mt-4 flex min-h-0 flex-1 flex-col`,children:[u===`iterations`?(0,x.jsx)(v,{scopeProjectId:E.id}):null,u===`requirements`?(0,x.jsx)(y,{scopeProjectId:E.id}):null,u===`bugs`?(0,x.jsx)(_,{scopeProjectId:E.id}):null]})]})}function D(){return(0,x.jsxs)(`a`,{href:w,className:`mb-2 inline-flex w-fit items-center gap-1.5 text-sm text-stone-500 transition-colors hover:text-stone-800`,children:[(0,x.jsx)(p,{name:`arrowLeft`,size:16}),`返回项目列表`]})}export{T as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{o as n}from"./plugins.
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{o as n}from"./plugins.BDZqJNOy.js";import{t as r}from"./jsx-runtime.BUXbF_vF.js";import{t as i}from"./ConfirmDialog.CBVsDJ8f.js";import{t as ee}from"./SelectDropdown.Buv7rQJ_.js";import{F as a,S as o,c as s,g as te,h as ne,j as re,s as c}from"./pm.Bl3hz9fF.js";import{D as ie,E as l,O as u,S as d,T as f,_ as p,a as m,c as h,d as g,f as _,g as v,i as y,k as b,l as x,m as S,o as C,s as ae,u as oe,v as se,y as ce}from"./PmShared.BxTHKdjY.js";var w=e(t(),1),T=r(),E=10,D=c.map(e=>({value:e,label:s[e]})),O=[`all`,...c],k=`pm.projects.status`,A=`pm.projects.keyword`;function j(){return{name:``,description:``,status:`planning`}}function M(){let e=u(`projects`),{store:t,live:r,loading:c,error:M,setError:N,reload:P}=b(),[F,I]=l(k,O,`all`),[L,R]=ie(A),[z,B]=(0,w.useState)(1),[V,H]=(0,w.useState)(null),[U,W]=(0,w.useState)(!1),[G,K]=(0,w.useState)(null),[q,J]=(0,w.useState)(null),Y=(0,w.useRef)(null),le=(0,w.useMemo)(()=>re(t),[t]),X=(0,w.useMemo)(()=>o(t.projects,{status:F,keyword:L}),[t.projects,F,L]),Z=Math.max(1,Math.ceil(X.length/E)),Q=Math.min(z,Z),$=X.slice((Q-1)*E,Q*E);(0,w.useEffect)(()=>{if(!q)return;function e(e){Y.current?.contains(e.target)||J(null)}function t(e){e.key===`Escape`&&J(null)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[q]);async function ue(){if(!V)return;let e=V.name.trim();if(!e)N(`项目名称不能为空`);else{W(!0);try{V.id?await a(`projects`,V.id,{name:e,description:V.description,status:V.status}):await ne(`projects`,[{name:e,description:V.description,status:V.status}]),H(null),N(``),await P(!0)}catch(e){N(e instanceof Error?e.message:String(e))}finally{W(!1)}}}async function de(e){J(null),W(!0);try{await a(`projects`,e.id,{status:e.status===`archived`?`planning`:`archived`}),await P(!0)}catch(e){N(e instanceof Error?e.message:String(e))}finally{W(!1)}}async function fe(){let e=G;if(e){K(null),W(!0);try{await te(`projects`,[e.id]),await P(!0)}catch(e){N(e instanceof Error?e.message:String(e))}finally{W(!1)}}}return e.ready?e.on?r===null?(0,T.jsx)(v,{label:`正在连接项目管理服务`}):r?(0,T.jsxs)(`section`,{className:`flex min-h-0 flex-col`,children:[(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,T.jsx)(`div`,{className:`text-xs text-stone-400`,children:t.projects.length?(0,T.jsxs)(T.Fragment,{children:[`共 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-600`,children:t.projects.length}),` 个项目`,X.length===t.projects.length?``:` · 筛选出 ${X.length} 个`]}):`暂无项目`}),(0,T.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,T.jsx)(ee,{flat:!0,showCheck:!1,ariaLabel:`按状态筛选项目`,className:`w-32`,options:[{value:`all`,label:`全部状态`},...D],value:F,onChange:e=>{I(e),B(1)}}),(0,T.jsxs)(`label`,{className:`relative block`,children:[(0,T.jsx)(S,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,T.jsx)(`input`,{value:L,onChange:e=>{R(e.target.value),B(1)},placeholder:`搜索项目名称 / 描述…`,className:`h-9 w-52 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,T.jsxs)(`button`,{type:`button`,disabled:U,onClick:()=>H(j()),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:[(0,T.jsx)(S,{name:`plus`,size:14}),`新建项目`]})]})]}),M?(0,T.jsx)(g,{message:M,onClose:()=>N(``)}):null,(0,T.jsx)(`div`,{className:`mt-4 min-h-0 flex-1 overflow-auto pt-1 pb-4`,children:c&&!t.projects.length?(0,T.jsx)(`div`,{className:`flex min-h-[200px] items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})}):$.length===0?t.projects.length?(0,T.jsx)(x,{children:`没有符合筛选条件的项目。`}):(0,T.jsx)(oe,{icon:`folder`,title:`暂无项目`,hint:`创建第一个项目开始吧`,action:(0,T.jsxs)(`button`,{type:`button`,onClick:()=>H(j()),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,T.jsx)(S,{name:`plus`,size:13}),`新建项目`]})}):(0,T.jsx)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3`,children:$.map(e=>{let t=le[e.id];return(0,T.jsxs)(`article`,{className:`tw-pm-card group relative rounded-2xl border border-stone-200 bg-white`,children:[(0,T.jsx)(`span`,{className:`pointer-events-none absolute inset-0 overflow-hidden rounded-2xl`,"aria-hidden":`true`,children:(0,T.jsx)(`span`,{className:`tw-pm-card-accent absolute -right-6 -top-6 h-20 w-20 rounded-full bg-[#f1edff]`})}),(0,T.jsx)(`a`,{href:f(e.id),"aria-label":`打开项目 ${e.name}`,className:`absolute inset-0 z-0 rounded-2xl`}),(0,T.jsxs)(`div`,{className:`pointer-events-none relative z-10 flex h-full flex-col p-5`,children:[(0,T.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,T.jsx)(`span`,{className:`tw-pm-tile flex h-8 w-8 shrink-0 items-center justify-center rounded-xl text-xs font-bold`,children:e.name.slice(0,1)}),(0,T.jsx)(`h3`,{className:`truncate text-[15px] font-semibold text-stone-800`,children:e.name})]}),(0,T.jsx)(d,{tone:C[e.status],children:s[e.status]})]}),(0,T.jsx)(`p`,{className:`mt-3 line-clamp-2 min-h-[40px] text-sm ${e.description?`text-stone-500`:`italic text-stone-300`}`,children:e.description||`暂无描述`}),(0,T.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-x-2.5 gap-y-1 text-xs text-stone-500`,children:[(0,T.jsxs)(`span`,{children:[t?.iterations??0,` 迭代`]}),(0,T.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,T.jsxs)(`span`,{children:[t?.requirements??0,` 需求`]}),(0,T.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,T.jsxs)(`span`,{children:[t?.bugs??0,` 缺陷`]})]}),(0,T.jsxs)(`div`,{className:`mt-auto flex items-center justify-between pt-4`,children:[(0,T.jsxs)(`div`,{className:`pointer-events-auto relative`,ref:q===e.id?Y:void 0,children:[(0,T.jsx)(`button`,{type:`button`,"aria-label":`${e.name} 的操作`,"aria-haspopup":`menu`,"aria-expanded":q===e.id,onClick:()=>J(q===e.id?null:e.id),className:`flex h-8 w-8 items-center justify-center rounded-lg text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,children:(0,T.jsx)(S,{name:`more`,size:18})}),q===e.id?(0,T.jsxs)(`div`,{role:`menu`,className:`absolute left-0 top-9 z-30 w-36 overflow-hidden rounded-lg border border-stone-200 bg-white py-1 shadow-lg`,children:[(0,T.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{J(null),H({id:e.id,name:e.name,description:e.description,status:e.status})},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-stone-700 hover:bg-stone-50`,children:[(0,T.jsx)(S,{name:`pencil`,size:14}),`编辑`]}),(0,T.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>void de(e),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-stone-700 hover:bg-stone-50`,children:[(0,T.jsx)(S,{name:`folder`,size:14}),e.status===`archived`?`取消归档`:`归档`]}),(0,T.jsx)(`div`,{className:`my-1 border-t border-stone-100`}),(0,T.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{J(null),K(e)},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-red-600 hover:bg-red-50`,children:[(0,T.jsx)(S,{name:`trash`,size:14}),`删除`]})]}):null]}),(0,T.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-stone-400`,children:[`需求完成 `,t?.requirementPercent??0,`%`,(0,T.jsx)(S,{name:`chevronRight`,size:14,className:`tw-pm-card-chevron text-stone-300`})]})]})]})]},e.id)})})}),X.length>0?(0,T.jsx)(se,{page:Q,totalPages:Z,busy:U,onPage:B}):null,(0,T.jsx)(h,{open:V!==null,title:V?.id?`编辑项目`:`新建项目`,busy:U,submitLabel:V?.id?`保存`:`创建`,onClose:()=>H(null),onSubmit:()=>void ue(),children:V?(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(_,{label:`项目名称`,required:!0,children:(0,T.jsx)(`input`,{autoFocus:!0,value:V.name,onChange:e=>H({...V,name:e.target.value}),placeholder:`输入项目名称`,className:y})}),(0,T.jsx)(_,{label:`描述`,children:(0,T.jsx)(`textarea`,{value:V.description,onChange:e=>H({...V,description:e.target.value}),placeholder:`项目描述(可选)`,rows:4,className:m})}),(0,T.jsx)(_,{label:`状态`,children:(0,T.jsx)(ce,{ariaLabel:`项目状态`,options:D,value:V.status,onChange:e=>H({...V,status:e}),renderOptionPrefix:e=>(0,T.jsx)(ae,{tone:C[e.value]})})})]}):null}),(0,T.jsx)(i,{open:G!==null,title:`删除项目`,message:`确定删除「${G?.name??``}」?该项目下的迭代、需求与缺陷会一并删除,且无法恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:`solid`,onClose:()=>K(null),onConfirm:()=>void fe()})]}):(0,T.jsx)(p,{children:`项目列表需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,T.jsx)(p,{children:n(`projects`)}):(0,T.jsx)(v,{label:`正在读取插件开关`})}export{M as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{o as n}from"./plugins.BDZqJNOy.js";import{t as r}from"./jsx-runtime.BUXbF_vF.js";import{t as i}from"./ConfirmDialog.CBVsDJ8f.js";import{n as a,t as ee}from"./DocsPager.C20ue_JZ.js";import{t as o}from"./SelectDropdown.Buv7rQJ_.js";import{A as s,C as c,E as l,F as u,I as d,d as f,f as p,g as m,h,k as g,l as _,m as te,u as v}from"./pm.Bl3hz9fF.js";import{C as y,D as b,E as x,O as ne,S as re,T as ie,_ as S,a as ae,c as oe,d as se,f as C,g as ce,h as w,k as le,l as ue,m as T,p as de,s as E,u as fe,w as D,y as O}from"./PmShared.BxTHKdjY.js";var k=e(t(),1),A=r();function pe({value:e,onChange:t,entity:n,recordId:r=``,seenUrls:i,onError:a,onPersisted:ee}){let o=s(e),[c,f]=(0,k.useState)(!1),[p,m]=(0,k.useState)(!1),[h,_]=(0,k.useState)(null),v=(0,k.useRef)(null);(0,k.useEffect)(()=>{for(let t of s(e))i.current.add(t.url)},[e,i]);let y=(0,k.useCallback)(async n=>{if(n&&n.length){f(!0);try{let r=await d(Array.from(n));t(g([...s(e),...r])),a(``)}catch(e){a(e instanceof Error?e.message:String(e))}finally{f(!1),v.current&&(v.current.value=``)}}},[t,a,e]);(0,k.useEffect)(()=>{let e=e=>{let t=Array.from(e.clipboardData?.files??[]);t.length&&(e.preventDefault(),y(t))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[y]);async function b(e){let i=g(o.filter(t=>t.url!==e));if(r)try{await u(n,r,{attachment:i}),ee?.()}catch(e){a(e instanceof Error?e.message:String(e));return}t(i),te([e],r)}return(0,A.jsxs)(`div`,{className:`space-y-2 rounded-lg transition-colors ${p?`bg-[#3370ff]/5 ring-1 ring-[#3370ff]/40`:``}`,onDragOver:e=>{e.preventDefault(),m(!0)},onDragLeave:()=>m(!1),onDrop:e=>{e.preventDefault(),m(!1),y(e.dataTransfer?.files??null)},children:[o.length?(0,A.jsx)(`ul`,{className:`space-y-1.5`,children:o.map(e=>(0,A.jsxs)(`li`,{className:`flex items-center gap-2 rounded-lg border border-stone-200 px-2 py-1.5`,children:[l(e.url)?(0,A.jsx)(`button`,{type:`button`,onClick:()=>_(e),"aria-label":`预览附件 ${e.name}`,className:`shrink-0 cursor-zoom-in`,children:(0,A.jsx)(`img`,{src:e.url,alt:e.name,className:`h-9 w-9 rounded-md border border-stone-100 object-cover`})}):(0,A.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-stone-100 text-stone-400`,children:(0,A.jsx)(T,{name:`file`,size:15})}),l(e.url)?(0,A.jsx)(`button`,{type:`button`,onClick:()=>_(e),className:`min-w-0 flex-1 truncate text-left text-sm text-stone-700 hover:text-[#3370ff]`,children:e.name}):(0,A.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`min-w-0 flex-1 truncate text-sm text-stone-700 hover:text-[#3370ff]`,children:e.name}),(0,A.jsx)(`button`,{type:`button`,"aria-label":`移除附件 ${e.name}`,onClick:()=>void b(e.url),className:`flex h-6 w-6 shrink-0 items-center justify-center rounded text-stone-300 hover:bg-red-50 hover:text-red-600`,children:`✕`})]},e.url))}):null,(0,A.jsx)(`input`,{ref:v,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void y(e.target.files)}),(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsxs)(`button`,{type:`button`,disabled:c,onClick:()=>v.current?.click(),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-dashed border-stone-300 px-2.5 text-xs text-stone-500 transition-colors hover:border-stone-400 hover:text-stone-700 disabled:opacity-40`,children:[(0,A.jsx)(T,{name:c?`file`:`plus`,size:13}),c?`上传中…`:`上传文件 / 图片`]}),(0,A.jsx)(`span`,{className:`text-xs text-stone-400`,children:`可拖拽到这里,或直接粘贴截图(⌘V / Ctrl+V),支持多张`})]}),(0,A.jsx)(w,{file:h,onClose:()=>_(null)})]})}var me=20,he=`tw.pm-requirements.page-size.v1`,ge=[`all`,...f],_e=[`all`,..._],ve=`pm.requirements.project`,ye=`pm.requirements.iteration`,be=`pm.requirements.status`,xe=`pm.requirements.priority`,Se=`pm.requirements.keyword`,j=_.map(e=>({value:e,label:v[e]})),M=f.map(e=>({value:e,label:p[e]}));function N(e=``){return{projectId:e,iterationId:``,title:``,priority:`medium`,status:`pending`,description:``,acceptanceCriteria:[],githubIssue:``,attachment:``}}function P({scopeProjectId:e=``}={}){let t=!!e,r=ne(`pmRequirements`),{store:l,live:d,loading:f,error:g,setError:_,reload:w}=le(),[P,F]=b(ve,`all`),I=e||P,[L,R]=b(ye,`all`),[z,Ce]=x(be,ge,`all`),[B,we]=x(xe,_e,`all`),[V,Te]=b(Se),[Ee,H]=(0,k.useState)(1),[U,De]=a(me,he),[W,G]=(0,k.useState)(null),[K,q]=(0,k.useState)(!1),[J,Y]=(0,k.useState)(null),X=(0,k.useRef)(new Set),Oe=(0,k.useMemo)(()=>[{value:`all`,label:`全部项目`},...l.projects.map(e=>({value:e.id,label:e.name}))],[l.projects]),ke=(0,k.useMemo)(()=>[{value:`all`,label:`全部迭代`},...l.iterations.filter(e=>I===`all`||e.projectId===I).map(e=>({value:e.id,label:e.name}))],[l.iterations,I]),Ae=(0,k.useMemo)(()=>{let e=new Map(l.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[l.projects]),je=(0,k.useMemo)(()=>{let e=new Map(l.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[l.iterations]),Z=(0,k.useMemo)(()=>c(l.requirements,{projectId:I,iterationId:L,status:z,priority:B,keyword:V}),[l.requirements,I,L,z,B,V]),Q=t?l.requirements.filter(e=>e.projectId===I).length:l.requirements.length,Me=Math.max(1,Math.ceil(Z.length/U)),$=Math.min(Ee,Me),Ne=Z.slice(($-1)*U,$*U);(0,k.useEffect)(()=>{t||d===!0&&P!==`all`&&!l.projects.some(e=>e.id===P)&&F(`all`)},[d,l.projects,P,F,t]),(0,k.useEffect)(()=>{d===!0&&L!==`all`&&!l.iterations.some(e=>e.id===L&&(I===`all`||e.projectId===I))&&R(`all`)},[d,l.iterations,I,L,R]);let Pe=W?l.iterations.filter(e=>e.projectId===W.projectId):[];async function Fe(){if(!W)return;if(!W.projectId){_(`请先选择所属项目`);return}let e=W.title.trim();if(!e)_(`需求描述不能为空`);else{q(!0);try{let t={projectId:W.projectId,iterationId:W.iterationId,title:e,priority:W.priority,status:W.status,description:W.description,acceptanceCriteria:W.acceptanceCriteria.filter(e=>e.text.trim()),githubIssue:W.githubIssue,attachment:W.attachment};W.id?await u(`requirements`,W.id,t):await h(`requirements`,[t]),G(null),X.current.clear(),_(``),await w(!0)}catch(e){_(e instanceof Error?e.message:String(e))}finally{q(!1)}}}function Ie(){let e=[...X.current,...s(W?.attachment??``).map(e=>e.url)];X.current.clear(),G(null),e.length&&te(e)}async function Le(e,t){q(!0);try{await u(`requirements`,e.id,{status:t}),await w(!0)}catch(e){_(e instanceof Error?e.message:String(e))}finally{q(!1)}}async function Re(){let e=J;if(e){Y(null),q(!0);try{await m(`requirements`,[e.id]),await w(!0)}catch(e){_(e instanceof Error?e.message:String(e))}finally{q(!1)}}}if(!r.ready)return(0,A.jsx)(ce,{label:`正在读取插件开关`});if(!r.on)return(0,A.jsx)(S,{children:n(`pmRequirements`)});if(d===null)return(0,A.jsx)(ce,{label:`正在连接项目管理服务`});if(!d)return(0,A.jsx)(S,{children:`需求管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(l.projects.length===0&&!f&&!t)return(0,A.jsx)(S,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来维护需求。`});let ze=[{value:`all`,label:`全部`},...M];return(0,A.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,A.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,A.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`共 `,(0,A.jsx)(`span`,{className:`font-medium text-stone-600`,children:Q}),` 条需求`,Z.length===Q?``:` · 筛选出 ${Z.length} 条`]}),(0,A.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,A.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选需求`,className:`w-36`,options:Oe,value:P,onChange:e=>{F(e),R(`all`),H(1)}}),(0,A.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选需求`,className:`w-32`,options:ke,value:L,onChange:e=>{R(e),H(1)}}),(0,A.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按优先级筛选需求`,className:`w-28`,options:[{value:`all`,label:`全部优先级`},...j],value:B,onChange:e=>{we(e),H(1)}}),(0,A.jsxs)(`label`,{className:`relative block`,children:[(0,A.jsx)(T,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,A.jsx)(`input`,{value:V,onChange:e=>{Te(e.target.value),H(1)},placeholder:`搜索编号 / 名称…`,className:`h-9 w-44 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,A.jsxs)(`button`,{type:`button`,disabled:K,onClick:()=>G(N(I===`all`?``:I)),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:[(0,A.jsx)(T,{name:`plus`,size:14}),`新建需求`]})]})]}),(0,A.jsx)(`div`,{className:`mt-3 flex shrink-0 flex-wrap items-center gap-2`,children:(0,A.jsx)(de,{ariaLabel:`按状态筛选需求`,options:ze,value:z,onChange:e=>{Ce(e),H(1)}})}),g?(0,A.jsx)(se,{message:g,onClose:()=>_(``)}):null,(0,A.jsxs)(`div`,{className:`mt-3 flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,A.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,A.jsxs)(`table`,{className:`tw-data-table w-full border-collapse text-sm`,children:[(0,A.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,A.jsxs)(`tr`,{children:[(0,A.jsx)(`th`,{className:`w-24 px-4 py-2.5 text-left font-medium whitespace-nowrap`,children:`ID`}),(0,A.jsx)(`th`,{className:`px-4 py-2.5 text-left font-medium`,children:`需求描述`}),(0,A.jsx)(`th`,{className:`w-24 px-3 py-2.5 text-left font-medium whitespace-nowrap`,children:`优先级`}),(0,A.jsx)(`th`,{className:`w-32 px-3 py-2.5 text-left font-medium whitespace-nowrap`,children:`需求状态`}),t?null:(0,A.jsx)(`th`,{className:`w-40 px-3 py-2.5 text-left font-medium whitespace-nowrap`,children:`所属项目`}),(0,A.jsx)(`th`,{className:`w-40 px-3 py-2.5 text-left font-medium whitespace-nowrap`,children:`所属迭代`}),(0,A.jsx)(`th`,{className:`w-24 px-3 py-2.5 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,A.jsxs)(`tbody`,{children:[f&&!l.requirements.length?(0,A.jsx)(`tr`,{children:(0,A.jsx)(`td`,{colSpan:t?6:7,className:`px-4 py-16 text-center`,children:(0,A.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):Ne.length===0?(0,A.jsx)(`tr`,{children:(0,A.jsx)(`td`,{colSpan:t?6:7,children:Q?(0,A.jsx)(ue,{children:`没有符合筛选条件的需求。`}):(0,A.jsx)(fe,{icon:`file`,title:`暂无需求`,hint:`拆出第一条需求,再关联迭代、补充描述。`,action:(0,A.jsxs)(`button`,{type:`button`,onClick:()=>G(N(I===`all`?``:I)),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,A.jsx)(T,{name:`plus`,size:13}),`新建需求`]})})})}):null,Ne.map(e=>(0,A.jsxs)(`tr`,{className:`border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,A.jsx)(`td`,{className:`px-4 py-2.5 font-mono text-xs text-stone-400`,children:e.autoId}),(0,A.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,A.jsx)(`button`,{type:`button`,onClick:()=>G({id:e.id,projectId:e.projectId,iterationId:e.iterationId,title:e.title,priority:e.priority,status:e.status,description:e.description,acceptanceCriteria:e.acceptanceCriteria.map(e=>({...e})),githubIssue:e.githubIssue,attachment:e.attachment}),className:`max-w-full truncate text-left text-stone-800 hover:text-[#3370ff]`,children:e.title})}),(0,A.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,A.jsx)(re,{tone:y[e.priority],children:v[e.priority]})}),(0,A.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,A.jsx)(o,{unstyled:!0,ariaLabel:`修改 ${e.title} 的状态`,disabled:K,options:M,value:e.status,onChange:t=>void Le(e,t),renderOptionPrefix:e=>(0,A.jsx)(E,{tone:D[e.value]}),renderTrigger:()=>(0,A.jsx)(re,{tone:D[e.status],children:p[e.status]})})}),t?null:(0,A.jsx)(`td`,{className:`truncate px-3 py-2.5 text-sm text-stone-600`,children:(0,A.jsx)(`a`,{href:ie(e.projectId),className:`transition-colors hover:text-[#3370ff]`,children:Ae(e.projectId)})}),(0,A.jsx)(`td`,{className:`truncate px-3 py-2.5 text-sm text-stone-500`,children:je(e.iterationId)}),(0,A.jsx)(`td`,{className:`px-3 py-2.5 text-center`,children:(0,A.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,disabled:K,onClick:()=>Y(e),className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 disabled:opacity-40`,children:(0,A.jsx)(T,{name:`trash`,size:15})})})]},e.id))]})]})}),Z.length>0?(0,A.jsx)(ee,{page:$,totalPages:Me,pageSize:U,busy:K,onPage:H,onPageSize:e=>{De(e),H(1)}}):null]}),(0,A.jsx)(oe,{open:W!==null,title:W?.id?`编辑需求`:`新建需求`,busy:K,submitLabel:W?.id?`保存`:`创建`,onClose:()=>Ie(),onSubmit:()=>void Fe(),children:W?(0,A.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,A.jsx)(C,{label:`所属项目`,required:!0,children:(0,A.jsx)(O,{ariaLabel:`所属项目`,options:l.projects.map(e=>({value:e.id,label:e.name})),value:W.projectId,onChange:e=>{let t=l.iterations.some(t=>t.id===W.iterationId&&t.projectId===e);G({...W,projectId:e,iterationId:t?W.iterationId:``})}})}),(0,A.jsx)(C,{label:`所属迭代`,children:(0,A.jsx)(O,{ariaLabel:`所属迭代`,options:[{value:``,label:`不关联迭代`},...Pe.map(e=>({value:e.id,label:e.name}))],value:W.iterationId,onChange:e=>G({...W,iterationId:e}),disabled:Pe.length===0})}),(0,A.jsx)(C,{label:`需求描述`,required:!0,children:(0,A.jsx)(`textarea`,{autoFocus:!0,value:W.title,onChange:e=>G({...W,title:e.target.value}),placeholder:`一句话写清要做什么`,rows:3,className:ae})}),(0,A.jsx)(C,{label:`优先级`,children:(0,A.jsx)(O,{ariaLabel:`优先级`,options:j,value:W.priority,onChange:e=>G({...W,priority:e}),renderOptionPrefix:e=>(0,A.jsx)(E,{tone:y[e.value]})})}),(0,A.jsx)(C,{label:`需求状态`,children:(0,A.jsx)(O,{ariaLabel:`需求状态`,options:M,value:W.status,onChange:e=>G({...W,status:e}),renderOptionPrefix:e=>(0,A.jsx)(E,{tone:D[e.value]})})}),(0,A.jsx)(C,{label:`附件`,children:(0,A.jsx)(pe,{value:W.attachment,onChange:e=>G(t=>t&&{...t,attachment:e}),entity:`requirements`,recordId:W.id??``,seenUrls:X,onError:_,onPersisted:()=>void w(!0)})}),(0,A.jsx)(C,{label:`备注`,children:(0,A.jsx)(`textarea`,{value:W.description,onChange:e=>G({...W,description:e.target.value}),placeholder:`补充背景、目标与范围(可选)`,rows:4,className:ae})})]}):null}),(0,A.jsx)(i,{open:J!==null,title:`删除需求`,message:`确定删除「${J?.title??``}」?关联的缺陷会保留,但不再关联到这条需求。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>Y(null),onConfirm:()=>void Re()})]})}export{P as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{t as default}from"./PmRequirementsBoard.CynewRfv.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,n as t,t as n}from"./react-dom.CqAxpHMt.js";import{i as r}from"./app-config.
|
|
1
|
+
import{c as e,n as t,t as n}from"./react-dom.CqAxpHMt.js";import{i as r}from"./app-config.DUyozIL9.js";import{a as i,r as a}from"./plugins.BDZqJNOy.js";import{a as o,n as s,o as c,r as l}from"./view-prefs.Dyu_lmN2.js";import{t as u}from"./jsx-runtime.BUXbF_vF.js";import{t as d}from"./SelectDropdown.Buv7rQJ_.js";import{_ as f,v as p,y as m}from"./pm.Bl3hz9fF.js";import{t as h}from"./SlideOverDrawer.TPbGEoWn.js";var g=e(t(),1),_=e(n(),1),v=u(),y=8e3;function b(e,t,n){let[r,i]=(0,g.useState)(()=>s(e,t,n));return[r,(0,g.useCallback)(t=>{i(t),o(e,t)},[e])]}function x(e,t=``){let[n,r]=(0,g.useState)(()=>l(e)||t);return[n,(0,g.useCallback)(n=>{r(n),c(e,n===t?``:n)},[e,t])]}function S(e){let[t,n]=(0,g.useState)(!1),[o,s]=(0,g.useState)(()=>a(e));return(0,g.useEffect)(()=>{let t=!0,o=i(()=>s(a(e)));return r().then(()=>{t&&(s(a(e)),n(!0))}),()=>{t=!1,o()}},[e]),{ready:t,on:o}}var C=(0,g.createContext)(null);function w(e){let[t,n]=(0,g.useState)(f),[r,i]=(0,g.useState)(null),[a,o]=(0,g.useState)(!0),[s,c]=(0,g.useState)(``),l=(0,g.useRef)(!0),u=(0,g.useCallback)(async(e=!1)=>{e||o(!0);try{let e=await m();return l.current?(n(e),i(!0),c(``),e):null}catch(e){return l.current&&c(e instanceof Error?e.message:String(e)),null}finally{l.current&&!e&&o(!1)}},[]);return(0,g.useEffect)(()=>{if(!e){o(!1);return}l.current=!0;let t=null;return(async()=>{let e=await p();l.current&&(e?(i(!0),await u(),t=window.setInterval(()=>void u(!0),y)):(i(!1),o(!1)))})(),()=>{l.current=!1,t!==null&&window.clearInterval(t)}},[e,u]),{store:t,live:r,loading:a,error:s,setError:c,reload:u}}function T({children:e}){let t=w(!0);return(0,v.jsx)(C.Provider,{value:t,children:e})}function E(){let e=(0,g.useContext)(C),t=w(e===null);return e??t}var D={gray:`bg-stone-100 text-stone-600`,blue:`bg-[#e1eaff] text-[#1f4ec2]`,amber:`bg-[#fff1e3] text-[#a85b00]`,yellow:`bg-[#fff7d6] text-[#8a6100]`,red:`bg-[#fee4e3] text-[#c02a26]`,purple:`bg-[#efe7ff] text-[#5b32b4]`,green:`bg-[#d9f5d2] text-[#1d7a12]`,muted:`bg-stone-100 text-stone-400`},O={planning:`blue`,in_progress:`amber`,archived:`gray`},k={planning:`blue`,in_progress:`amber`,done:`green`},A={urgent:`red`,high:`amber`,medium:`yellow`,low:`gray`},j={pending:`gray`,todo:`blue`,in_progress:`blue`,testing:`purple`,done:`green`,cancelled:`muted`},M={critical:`red`,major:`amber`,minor:`yellow`,trivial:`gray`},N={pending:`gray`,todo:`blue`,fixed:`amber`,verifying:`purple`,passed:`green`,cancelled:`muted`},P={gray:`#a8a29e`,blue:`#3370ff`,amber:`#f59e0b`,yellow:`#eab308`,red:`#ef4444`,purple:`#8b5cf6`,green:`#22c55e`,muted:`#d6d3d1`};function F({tone:e}){return(0,v.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:P[e]}})}function I({tone:e,children:t}){return(0,v.jsx)(`span`,{className:`inline-flex h-6 shrink-0 items-center rounded-md px-2 text-xs font-medium ${D[e]}`,children:t})}var L={plus:[`M12 5v14`,`M5 12h14`],more:[],chevronRight:[`m9 5 7 7-7 7`],arrowLeft:[`M19 12H5`,`m11 18-6-6 6-6`],pencil:[`M12 20h9`,`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`],trash:[`M3 6h18`,`M8 6V4h8v2`,`M19 6l-1 14H6L5 6`,`M10 11v6`,`M14 11v6`],check:[`m4.5 12.5 5 5 10-11`],play:[`M8 5.5v13l11-6.5Z`],search:[`M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14Z`,`m20 20-3.6-3.6`],folder:[`M3 7.5A2.5 2.5 0 0 1 5.5 5h3.2l2 2h7.8A2.5 2.5 0 0 1 21 9.5v7A2.5 2.5 0 0 1 18.5 19h-13A2.5 2.5 0 0 1 3 16.5Z`],calendar:[`M4 7.5A2.5 2.5 0 0 1 6.5 5h11A2.5 2.5 0 0 1 20 7.5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2Z`,`M8 3v4`,`M16 3v4`,`M4 10h16`],file:[`M7 3.5h6.5L18 8v12.5H7Z`,`M13.5 3.5V8H18`,`M10 12.5h5`,`M10 16h5`],bug:[`M8.5 9.5h7V14a3.5 3.5 0 0 1-7 0Z`,`M9.5 6.2 12 8l2.5-1.8`,`M4.5 13H8.5`,`M15.5 13h4`,`M6 18.5l2-2`,`M18 18.5l-2-2`]};function R({name:e,size:t=16,className:n=``}){return e===`more`?(0,v.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`currentColor`,"aria-hidden":`true`,className:n,children:[(0,v.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.6`}),(0,v.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.6`}),(0,v.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.6`})]}):(0,v.jsx)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:n,children:L[e].map(e=>(0,v.jsx)(`path`,{d:e},e))})}function z({tabs:e,value:t,onChange:n,ariaLabel:r}){return(0,v.jsx)(`div`,{className:`tw-pm-tabs`,role:`tablist`,"aria-label":r,children:e.map(e=>(0,v.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.value,onClick:()=>n(e.value),className:`tw-pm-tab`,children:[e.label,typeof e.count==`number`?(0,v.jsx)(`span`,{className:`tw-pm-tab-count`,children:e.count}):null]},e.value))})}function B({options:e,value:t,onChange:n,ariaLabel:r}){return(0,v.jsx)(`div`,{className:`tw-pm-pills`,role:`group`,"aria-label":r,children:e.map(e=>(0,v.jsx)(`button`,{type:`button`,"aria-pressed":t===e.value,onClick:()=>n(e.value),children:e.label},e.value))})}function V({icon:e,title:t,hint:n,action:r}){return(0,v.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-4 py-20 text-center`,children:[(0,v.jsx)(`span`,{className:`tw-pm-tile mb-4 flex h-16 w-16 items-center justify-center rounded-2xl`,children:(0,v.jsx)(R,{name:e,size:30})}),(0,v.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:t}),(0,v.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:n}),r?(0,v.jsx)(`div`,{className:`mt-4`,children:r}):null]})}function H(e){return`/pm/projects/detail/?id=${encodeURIComponent(e)}`}var U=`h-9 w-full rounded-md border border-transparent bg-transparent px-2 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`,W=`min-h-[72px] w-full resize-y rounded-md border border-stone-200 bg-white px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`;function G(e){return(0,v.jsx)(d,{flat:!0,menuMatchTrigger:!0,ariaLabel:e.ariaLabel,options:e.options,value:e.value,onChange:e.onChange,disabled:e.disabled,renderOptionPrefix:e.renderOptionPrefix})}function K({page:e,totalPages:t,busy:n=!1,onPage:r}){let i=`h-7 shrink-0 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-40`;return(0,v.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-center gap-2 pt-3`,children:[(0,v.jsx)(`button`,{type:`button`,className:i,disabled:n||e<=1,onClick:()=>r(e-1),children:`上一页`}),(0,v.jsxs)(`span`,{className:`px-2 text-xs tabular-nums text-stone-400`,children:[e,` / `,t]}),(0,v.jsx)(`button`,{type:`button`,className:i,disabled:n||e>=t,onClick:()=>r(e+1),children:`下一页`})]})}function q({label:e}){return(0,v.jsx)(`div`,{className:`flex min-h-[240px] items-center justify-center rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":e,children:(0,v.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}function J({children:e}){return(0,v.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:e})}function Y({children:e}){return(0,v.jsx)(`div`,{className:`px-4 py-16 text-center text-sm text-stone-400`,children:e})}function X({open:e,title:t,busy:n,submitLabel:r,onClose:i,onSubmit:a,children:o}){return(0,v.jsx)(h,{open:e,onClose:i,title:t,footer:(0,v.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-stone-100 px-2 py-3`,children:[(0,v.jsx)(`button`,{type:`button`,onClick:i,className:`h-8 rounded-lg border border-stone-200 px-3 text-sm text-stone-600 hover:bg-stone-100`,children:`取消`}),(0,v.jsx)(`button`,{type:`button`,disabled:n,onClick:a,className:`h-8 rounded-lg bg-[#3370ff] px-3 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:r})]}),children:o})}function Z({label:e,required:t,children:n}){return(0,v.jsxs)(`div`,{className:`flex items-start gap-3 px-2 py-2`,children:[(0,v.jsx)(`div`,{className:`flex h-9 w-[88px] shrink-0 items-center text-sm text-stone-600`,children:(0,v.jsxs)(`span`,{className:`truncate`,children:[e,t?(0,v.jsx)(`span`,{className:`ml-0.5 text-red-500`,children:`*`}):null]})}),(0,v.jsx)(`div`,{className:`min-w-0 flex-1 [&>div]:mt-0`,children:n})]})}function Q({file:e,onClose:t}){return e?(0,_.createPortal)((0,v.jsxs)(`div`,{className:`fixed inset-0 z-[70] flex items-center justify-center bg-stone-900/70 p-6 sm:p-10`,role:`dialog`,"aria-modal":`true`,"aria-label":e.name,onClick:t,children:[(0,v.jsx)(`img`,{src:e.url,alt:e.name,className:`max-h-full max-w-full rounded-lg bg-white object-contain shadow-2xl`,onClick:e=>e.stopPropagation()}),(0,v.jsx)(`button`,{type:`button`,"aria-label":`关闭预览`,onClick:t,className:`absolute right-4 top-4 flex h-9 w-9 items-center justify-center rounded-full bg-white/90 text-lg text-stone-600 shadow-md transition-colors hover:bg-white hover:text-stone-900`,children:`✕`})]}),document.body):null}function $({message:e,onClose:t}){return(0,v.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,v.jsx)(`span`,{className:`min-w-0 flex-1`,children:e}),(0,v.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]})}export{A as C,x as D,b as E,S as O,I as S,H as T,J as _,W as a,T as b,X as c,$ as d,Z as f,q as g,Q as h,U as i,E as k,Y as l,R as m,N as n,O as o,B as p,k as r,F as s,M as t,V as u,K as v,j as w,z as x,G as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.DUyozIL9.js";import{a as r,o as i,r as a}from"./plugins.BDZqJNOy.js";import{t as o}from"./jsx-runtime.BUXbF_vF.js";import{t as s}from"./ConfirmDialog.CBVsDJ8f.js";import{l as c,n as l,r as u,s as d}from"./project-docs.Cd2gKPKh.js";import{n as f}from"./doc-roots.DAJP9Svr.js";import{i as p}from"./prompts-meta.F4wwkjUA.js";import{i as m,n as h,r as g,t as _}from"./DocsFileBrowser.BtRoZ787.js";import{t as v,u as y}from"./open-docs-in-session.Xg3OSOfc.js";var b=e(t(),1),x=o(),S=10;async function C(e=`.`){let{entries:t}=await d(`prompts`,e),n=[];for(let e of t)e.type===`file`?n.push(e):n.push(...await C(e.path));return n}function w(){let e=g(`prompts`),[t,o]=(0,b.useState)(!1),[d,w]=(0,b.useState)(!0),[T,E]=(0,b.useState)(e?!0:null),[D,O]=(0,b.useState)(()=>e??[]),[k,A]=(0,b.useState)(null),[j,M]=(0,b.useState)(!1),[N,P]=(0,b.useState)({}),[F,I]=(0,b.useState)(null),L=h(D,S,`prompts`),R=(0,b.useCallback)(async()=>{A(null);try{let e=await C(`.`);O(e),m(`prompts`,e)}catch(e){A(e instanceof Error?e.message:String(e))}},[]);(0,b.useEffect)(()=>{let e=r(e=>w(!!e.prompts));return n().then(()=>{w(a(`prompts`)),o(!0)}),e},[]),(0,b.useEffect)(()=>{t&&d&&(async()=>{await u(`prompts`)?(await y().catch(()=>null),await R(),E(!0)):E(!1)})()},[t,d,R]);let z=(0,b.useMemo)(()=>Object.keys(N).filter(e=>N[e]),[N]);async function B(e){M(!0),A(null);try{await c(`prompts`,e.path)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}async function V(e){M(!0),A(null);try{await v(`prompts`,e)}catch(e){A(e instanceof Error?e.message:String(e)),M(!1)}}function H(e){p(e.path)?A(`默认提示词不可删除`):I({kind:`one`,entry:e})}async function U(){let e=F;if(e){I(null),M(!0),A(null);try{if(e.kind===`one`)await l(`prompts`,e.entry.path);else{for(let t of e.paths)p(t)||await l(`prompts`,t);P({})}await R()}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}function W(){a(`promptGen`)?window.location.href=`/?plugin=promptGen`:A(i(`promptGen`))}let G=F?.kind===`one`?`删除「${F.entry.name}」?将从 ${f(`prompts`)} 中移除。`:F?.kind===`batch`?`确认删除已选中的 ${F.paths.length} 个提示词?此操作不可恢复。`:``;return t?d?T===null?(0,x.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,x.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,x.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):T?(0,x.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,children:[(0,x.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,x.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0`,children:[L.query.trim()?(0,x.jsxs)(x.Fragment,{children:[`匹配 `,(0,x.jsx)(`span`,{className:`font-medium text-stone-800`,children:L.filtered.length}),` 个`,(0,x.jsxs)(`span`,{className:`text-stone-400`,children:[` · 共 `,D.length]})]}):(0,x.jsxs)(x.Fragment,{children:[`共 `,(0,x.jsx)(`span`,{className:`font-medium text-stone-800`,children:D.length}),` 个提示词`]}),z.length>0?(0,x.jsxs)(`span`,{className:`text-stone-400`,children:[` · 已选 `,z.length]}):null]}),(0,x.jsx)(`button`,{type:`button`,disabled:j||z.length===0,onClick:()=>I({kind:`batch`,paths:z}),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-red-600 border border-red-200 rounded-lg hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,x.jsx)(`button`,{type:`button`,disabled:j,onClick:W,className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`生成提示词`})]}),k?(0,x.jsx)(`div`,{className:`shrink-0 mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:k}):null,(0,x.jsx)(_,{files:D,filtered:L.filtered,pageFiles:L.pageFiles,query:L.query,onQuery:L.setQuery,sortBy:L.sortBy,onSortBy:L.setSortBy,page:L.page,totalPages:L.totalPages,pageSize:L.pageSize,onPage:L.setPage,onPageSize:L.setPageSize,busy:j,emptyText:`暂无提示词,点击「生成提示词」前往我的工作台。`,searchPlaceholder:`搜索文件名或路径…`,selectable:e=>!p(e.path),selected:N,onToggleRow:e=>P(t=>({...t,[e]:!t[e]})),onSelectPage:(e,t)=>P(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r}),onRowDoubleClick:e=>void B(e),renderActions:e=>{let t=p(e.path);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>void V(e),className:`text-xs whitespace-nowrap text-white bg-[#4176e6] px-2 py-1 rounded hover:bg-[#3565c7] cursor-pointer disabled:opacity-40`,children:`在会话中打开`}),(0,x.jsx)(`button`,{type:`button`,disabled:j||t,"data-hint":t?`默认提示词不可删除`:void 0,onClick:()=>H(e),className:`text-xs whitespace-nowrap text-red-600 hover:bg-red-50 px-2 py-1 rounded cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent`,children:`删除`})]})}}),(0,x.jsx)(s,{open:F!=null,title:F?.kind===`batch`?`批量删除`:`删除提示词`,message:G,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>I(null),onConfirm:()=>void U()})]}):(0,x.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`提示词管理需要本地文档服务,当前未就绪。`}):(0,x.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`prompts`)}):(0,x.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,x.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,x.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{w as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n,p as r}from"./app-config.
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n,p as r}from"./app-config.DUyozIL9.js";import{a as i,o as a,r as ee}from"./plugins.BDZqJNOy.js";import{t as o}from"./jsx-runtime.BUXbF_vF.js";import{n as s,t as c}from"./DocsPager.C20ue_JZ.js";import{t as l}from"./SelectDropdown.Buv7rQJ_.js";import{a as u,i as d,o as f,r as te,s as ne,t as p}from"./report-prompt.Cmw4XzfY.js";var m=e(t(),1),h=`tw.reports.kind.v1`,g=Object.keys(p);function _(e){return typeof e==`string`&&g.includes(e)}function v(e=`day`){try{let t=localStorage.getItem(r(h));return _(t)?t:e}catch{return e}}function y(e){if(_(e))try{localStorage.setItem(r(h),e)}catch{}}var b=o(),x=[`day`,`week`,`month`],S=20,C=`tw.reports.page-size.v1`;function w(e){return e.replace(/\.(md|markdown|txt)$/i,``)}function T(e){return e.replace(/\.(md|markdown|txt|html?)$/i,``)}function E(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return`—`;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}/${n(t.getMonth()+1)}/${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function D(e){return!Number.isFinite(e)||e<=0?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}var O={day:`日`,week:`周`,month:`月`};function k(){let[e,t]=(0,m.useState)(!1),[r,o]=(0,m.useState)(!0),[h,g]=(0,m.useState)(()=>v()),_=(0,m.useRef)(h),[k,A]=(0,m.useState)([]),[j,re]=(0,m.useState)(``),[M,N]=(0,m.useState)(!1),[P,F]=(0,m.useState)(null),[I,L]=(0,m.useState)(``),[R,z]=(0,m.useState)([]),[B,V]=(0,m.useState)(``),[H,U]=(0,m.useState)(!1),[W,G]=(0,m.useState)(1),[K,q]=s(S,C),J=(0,m.useCallback)(async(e,t)=>{N(!0),F(null);try{if(t?.ensure)try{await ne(!0)}catch{}let n=await d(e);A(n.items),re(n.dir)}catch(e){let t=e instanceof Error?e.message:String(e);F(t.includes(`404`)?`工作汇报需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`:t),A([])}finally{N(!1)}},[]);(0,m.useEffect)(()=>{let e=i(e=>o(!!e.reports));return n().then(()=>{o(ee(`reports`)),t(!0)}),e},[]);let Y=(0,m.useCallback)(async()=>{try{let e=await te();z(e.items),V(e.promptFile)}catch{}},[]);(0,m.useEffect)(()=>{e&&r&&(async()=>{await J(_.current,{ensure:!0}),await Y()})()},[e,r,J,Y]);function ie(e){y(e),e!==h&&(g(e),G(1),A([]),J(e))}async function ae(e){if(e&&e!==B){U(!0),F(null);try{let t=await f(e);V(t),z(e=>e.map(e=>({...e,selected:e.name===t})))}catch(e){F(e instanceof Error?e.message:String(e))}finally{U(!1)}}}let oe=(0,m.useMemo)(()=>R.length?R.map(e=>({value:e.name,label:w(e.name)})):[{value:``,label:`暂无提示词`}],[R]),X=(0,m.useMemo)(()=>[...k].sort((e,t)=>t.generatedAt-e.generatedAt),[k]),Z=Math.max(1,Math.ceil(X.length/K)),Q=Math.min(W,Z),se=(0,m.useMemo)(()=>X.slice((Q-1)*K,Q*K),[X,Q,K]),ce=`/?report=${h}`;async function le(e){if(!I){L(e.name),F(null);try{await u(e.kind,e.name)}catch(e){F(e instanceof Error?e.message:String(e))}finally{L(``)}}}if(!e)return(0,b.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex items-center justify-center min-h-[220px]`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,b.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!r)return(0,b.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:a(`reports`)});let $=X[0];return(0,b.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,b.jsxs)(`div`,{className:`shrink-0 border-b border-stone-100 px-4 py-3`,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,b.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-stone-100/80 p-0.5`,children:x.map(e=>(0,b.jsx)(`button`,{type:`button`,onClick:()=>ie(e),className:`h-8 rounded-md px-3 text-sm transition-colors ${h===e?`bg-white font-medium text-stone-900 shadow-sm`:`text-stone-600 hover:text-stone-900`}`,children:p[e]},e))}),(0,b.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,b.jsx)(l,{className:`w-[172px]`,flat:!0,options:oe,value:B,onChange:e=>void ae(e),disabled:!R.length||H,ariaLabel:`选择工作汇报提示词`,menuMinWidth:200}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>void(async()=>{await J(h),await Y()})(),disabled:M,"aria-label":`刷新`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-stone-200 text-stone-500 transition-colors hover:bg-stone-50 hover:text-stone-800 disabled:opacity-40`,children:(0,b.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,b.jsx)(`path`,{d:`M21 12a9 9 0 1 1-3-6.7`}),(0,b.jsx)(`path`,{d:`M21 4v5h-5`})]})}),(0,b.jsx)(`a`,{href:ce,className:`inline-flex h-9 items-center whitespace-nowrap rounded-lg bg-[#3370ff] px-3 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9]`,children:`去工作台写汇报`})]})]}),(0,b.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-stone-400`,children:[(0,b.jsxs)(`span`,{children:[p[h],` · 共 `,k.length,` 篇`]}),$?(0,b.jsxs)(`span`,{className:`tabular-nums`,children:[`最近生成 `,E($.generatedAt)]}):null,(0,b.jsx)(`span`,{className:`min-w-0 truncate`,children:j||`—`}),(0,b.jsx)(`span`,{className:`ml-auto hidden shrink-0 sm:inline`,children:`点击卡片用系统默认程序打开`})]})]}),P?(0,b.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,b.jsx)(`span`,{className:`min-w-0 flex-1`,children:P}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>F(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,b.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto bg-stone-50/60 p-3 sm:p-4`,children:M&&k.length===0?(0,b.jsx)(`div`,{className:`flex min-h-[180px] items-center justify-center`,"aria-busy":`true`,children:(0,b.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})}):k.length===0?(0,b.jsxs)(`div`,{className:`flex min-h-[260px] flex-col items-center justify-center gap-2 rounded-xl border border-dashed border-stone-300 px-6 py-10 text-center`,children:[(0,b.jsx)(`span`,{className:`flex h-12 w-12 items-center justify-center rounded-xl bg-stone-100 text-stone-400`,children:(0,b.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`22`,height:`22`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,b.jsx)(`path`,{d:`M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z`}),(0,b.jsx)(`path`,{d:`M14 3v5h5`}),(0,b.jsx)(`path`,{d:`M9 13h6M9 17h4`})]})}),(0,b.jsxs)(`div`,{className:`text-sm font-medium text-stone-700`,children:[`还没有`,p[h]]}),(0,b.jsxs)(`p`,{className:`max-w-md text-xs leading-5 text-stone-400`,children:[`保存到 `,j||`工作汇报/${p[h]}`,` 后会自动出现在这里。`]})]}):(0,b.jsx)(`ul`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,380px),1fr))] gap-2.5`,children:se.map(e=>(0,b.jsx)(`li`,{children:(0,b.jsxs)(`button`,{type:`button`,onClick:()=>void le(e),disabled:!!I,className:`group flex w-full items-center gap-3 rounded-xl border border-stone-200 bg-white px-3.5 py-3 text-left transition-colors hover:border-[#3370ff]/50 hover:bg-stone-50 disabled:cursor-progress disabled:opacity-60`,children:[(0,b.jsx)(`span`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-stone-100 text-[13px] font-semibold text-stone-600`,children:O[e.kind]}),(0,b.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,b.jsx)(`span`,{className:`block truncate text-sm font-medium text-stone-800 transition-colors group-hover:text-[#3370ff]`,children:T(e.name)}),(0,b.jsxs)(`span`,{className:`mt-0.5 block truncate text-xs text-stone-400 tabular-nums`,children:[E(e.generatedAt),` · `,D(e.size)]})]}),(0,b.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 text-xs text-stone-400 transition-colors group-hover:text-[#3370ff]`,children:[I===e.name?`打开中…`:`打开`,(0,b.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,b.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]})]})},e.name))})}),k.length>0?(0,b.jsx)(c,{page:Q,totalPages:Z,pageSize:K,busy:M,onPage:G,onPageSize:e=>{q(e),G(1)}}):(0,b.jsx)(`div`,{className:`pb-2.5`})]})}export{k as default};
|