lantern-harness 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +6 -6
  3. package/builtin/session/lh-spaces.mjs +102 -0
  4. package/cli/data-root.mjs +80 -3
  5. package/cli/lantern.mjs +2 -1
  6. package/cli/server.mjs +4 -0
  7. package/cli/spaces.mjs +91 -5
  8. package/config/app.defaults.json +4 -2
  9. package/dist/500.html +9 -5
  10. package/dist/_astro/Base.ByB0D4ZA.css +1 -0
  11. package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.lxEwQ1R4.js → Base.astro_astro_type_script_index_0_lang.Cg_8YLVA.js} +1 -1
  12. package/dist/_astro/CaseGenerateApp.BlZyjWEr.js +9 -0
  13. package/dist/_astro/CasesLibrary.C76La3Xj.js +1 -0
  14. package/dist/_astro/ChatApp.gfsPLvan.js +269 -0
  15. package/dist/_astro/ColumnResize.Bs6GL3DJ.js +1 -0
  16. package/dist/_astro/DatePicker.BdwFRioL.js +1 -0
  17. package/dist/_astro/{DocsFileBrowser.DkE26UTR.js → DocsFileBrowser.BxAyrkkw.js} +1 -1
  18. package/dist/_astro/KnowledgeLibrary.Cv488Hot.js +1 -0
  19. package/dist/_astro/NavLibraries.ALZ9e12z.js +1 -0
  20. package/dist/_astro/PluginsPage.B2uxCiHL.js +1 -0
  21. package/dist/_astro/{PluginsPage.BNzpPg2H.js → PluginsPage.DEkyOfQE.js} +2 -2
  22. package/dist/_astro/PromptsLibrary.BUC1OiCH.js +1 -0
  23. package/dist/_astro/RequirementsLibrary.D3olQI63.js +1 -0
  24. package/dist/_astro/{SearchableSelect.DMS2XmXc.js → SearchableSelect.DP74JRWW.js} +1 -1
  25. package/dist/_astro/SelectDropdown.D2i7-lQC.js +1 -0
  26. package/dist/_astro/{SettingsDialog.DC0e7580.js → SettingsDialog.CrMDjSLJ.js} +1 -1
  27. package/dist/_astro/SlideOverDrawer.C7UVeCX1.js +1 -0
  28. package/dist/_astro/SpaceSwitcher.Wf8EPYUx.js +7 -0
  29. package/dist/_astro/TasksBoard.2j7rGT9O.js +1 -0
  30. package/dist/_astro/TemplatesLibrary.J0x7yIcY.js +1 -0
  31. package/dist/_astro/TodosBoard.BugeB7_7.js +1 -0
  32. package/dist/_astro/app-config.vqDkEMS3.js +1 -0
  33. package/dist/_astro/doc-roots.DAJP9Svr.js +1 -0
  34. package/dist/_astro/i18n.9qZsrs3u.js +7 -0
  35. package/dist/_astro/{open-docs-in-session.D3JCwMWB.js → open-docs-in-session.fLwnA5qh.js} +1 -1
  36. package/dist/_astro/plugins.DSUPSizB.js +1 -0
  37. package/dist/_astro/project-docs.Cd2gKPKh.js +1 -0
  38. package/dist/_astro/{settings.BoQ0e0m1.js → settings.CkbipdPI.js} +2 -2
  39. package/dist/_astro/{useListAnim.CnbC_9MC.js → useListAnim.Y3N2budK.js} +1 -1
  40. package/dist/cases/generate/index.html +10 -6
  41. package/dist/cases/library/index.html +10 -6
  42. package/dist/docs/changelog/index.html +69 -6
  43. package/dist/docs/install/index.html +22 -8
  44. package/dist/docs/manual/index.html +74 -11
  45. package/dist/index.html +10 -6
  46. package/dist/knowledge/index.html +10 -6
  47. 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 +9 -5
  48. package/dist/plugins/index.html +10 -6
  49. package/dist/prompts/index.html +10 -6
  50. package/dist/requirements/index.html +10 -6
  51. package/dist/tasks/index.html +253 -0
  52. package/dist/templates/index.html +10 -6
  53. 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 +9 -5
  54. 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 +9 -5
  55. 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 +9 -5
  56. 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 +9 -5
  57. 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 +9 -5
  58. package/dist/todos/index.html +253 -0
  59. package/docs//345/205/250/345/261/200/346/217/222/344/273/266.md +2 -2
  60. package/docs//345/256/211/350/243/205/346/211/213/345/206/214.md +10 -8
  61. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +73 -23
  62. package/lh-plugins/lh-project-docs.mjs +2 -0
  63. package/lh-plugins/lh-tasks.mjs +223 -0
  64. package/lh-plugins/lh-todos.mjs +297 -0
  65. package/lh-plugins/storage-domain.mjs +1 -0
  66. package/package.json +1 -1
  67. package/dist/_astro/Base.B9f_iFAZ.css +0 -1
  68. package/dist/_astro/CaseGenerateApp.Br4uKjun.js +0 -9
  69. package/dist/_astro/CasesLibrary.CpPoVQ4P.js +0 -1
  70. package/dist/_astro/ChatApp.CYSPlSNP.js +0 -258
  71. package/dist/_astro/KnowledgeLibrary.DZinlAWn.js +0 -1
  72. package/dist/_astro/NavLibraries.EayBsg5g.js +0 -1
  73. package/dist/_astro/PluginsPage.CY61glLU.js +0 -1
  74. package/dist/_astro/PromptsLibrary.DfrrCjs7.js +0 -1
  75. package/dist/_astro/RequirementsLibrary.Dt0Gj6Nr.js +0 -1
  76. package/dist/_astro/SelectDropdown.Dc7QaPbH.js +0 -1
  77. package/dist/_astro/SpaceSwitcher.Yy2w8MDF.js +0 -7
  78. package/dist/_astro/TemplatesLibrary.uK-SjK1z.js +0 -1
  79. package/dist/_astro/app-config.CpjKWnzM.js +0 -1
  80. package/dist/_astro/i18n.BVvhz-vw.js +0 -7
  81. package/dist/_astro/plugins.CrpY8UI9.js +0 -1
@@ -1 +0,0 @@
1
- import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.CpjKWnzM.js";import{a as r,f as i,o as a,r as o,u as s}from"./SelectDropdown.Dc7QaPbH.js";import{t as c}from"./jsx-runtime.BUXbF_vF.js";import{t as l}from"./ConfirmDialog.BYz4HREM.js";import{i as u,n as d,r as f,t as p}from"./DocsFileBrowser.DkE26UTR.js";import{a as m,o as h,r as g}from"./plugins.CrpY8UI9.js";import{t as _,u as v}from"./open-docs-in-session.D3JCwMWB.js";var y=e(t(),1),b=c(),x=10;async function S(e=`.`){let{entries:t}=await s(`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 s=f(`knowledge`),[c,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(!0),[E,D]=(0,y.useState)(s?!0:null),[O,k]=(0,y.useState)(()=>s??[]),[A,j]=(0,y.useState)(null),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)({}),[I,L]=(0,y.useState)(null),R=d(O,x),z=(0,y.useCallback)(async()=>{j(null);try{let e=await S(`.`);k(e),u(`knowledge`,e)}catch(e){j(e instanceof Error?e.message:String(e))}},[]);(0,y.useEffect)(()=>{let e=m(e=>T(!!e.knowledgeLib));return n().then(()=>{T(g(`knowledgeLib`)),C(!0)}),e},[]),(0,y.useEffect)(()=>{c&&w&&(async()=>{await a(`knowledge`)?(await v().catch(()=>null),await z(),D(!0)):D(!1)})()},[c,w,z]);let B=(0,y.useMemo)(()=>Object.keys(P).filter(e=>P[e]),[P]);function V(){g(`knowledgeGen`)?window.location.href=`${t}?plugin=knowledgeGen`:j(h(`knowledgeGen`))}async function H(e){N(!0),j(null);try{await i(`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 r(`knowledge`,e.entry.path);else{for(let t of e.paths)await r(`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}」?将从 ${o(`knowledge`)} 中移除。`:I?.kind===`batch`?`确认删除已选中的 ${I.paths.length} 个知识库文件?此操作不可恢复。`:``;return c?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)(p,{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)(l,{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:h(`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 +0,0 @@
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,E as o,M as s,N as c,O as l,S as u,T as d,_ as f,a as p,b as m,g as h,h as g,i as _,j as v,k as y,m as b,p as x,r as S,t as C,u as w,v as ee,w as T,x as te,y as ne}from"./app-config.CpjKWnzM.js";import{t as re}from"./jsx-runtime.BUXbF_vF.js";import{a as E,i as D,n as O,r as k,t as ie}from"./ConfirmDialog.BYz4HREM.js";import{a as ae,i as oe,r as A}from"./plugins.CrpY8UI9.js";import{n as j}from"./i18n.BVvhz-vw.js";var M=e(t(),1),N=e(n(),1),P=`/__tb_nav/groups`;function se(){return S().navGroups}function F(){return d(S().navIcons)}function ce(e,t){let n={...F(),[e]:t};return w({navIcons:n}),C(),n}function le(){return S().navOrder}function ue(e,t){let n=T(e),r=o(t,n);return w({navGroups:n,navOrder:r}),C(),{groups:n,order:r}}function I(e,t){return JSON.stringify(e)===JSON.stringify(t)}async function de(e){if(!p())return null;try{let t=await fetch(P,{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 T(n.groups,!1)}catch{return null}}async function fe(){if(!p())return;let e=S(),t=null;try{let e=await fetch(P,{signal:AbortSignal.timeout(4e3)});e.ok&&(t=await e.json())}catch{return}if(!t)return;if(t.scanned){let n=T(t.groups,!1),r=o(e.navOrder,n);(!I(n,e.navGroups)||!I(r,e.navOrder))&&(w({navGroups:n,navOrder:r}),C());return}if(!e.navGroups.length)return;let n=await de(e.navGroups);n&&!I(n,e.navGroups)&&(w({navGroups:n,navOrder:o(e.navOrder,n)}),C())}var L=re(),R=`/`;function z(e){return`${R.endsWith(`/`)?R:`${R}/`}${e.replace(/^\//,``)}`}function B(e,t){return e.includes(`/${t}`)}function V(e){return[`tw-nav-item`,e?`is-active font-medium`:``].filter(Boolean).join(` `)}function H(e){return x(`tw.nav.groupOpen.${e}`)}function U(){return x(`tw.nav.docsOpen`)}function W(e,t){try{let t=localStorage.getItem(H(e));if(t===`1`)return!0;if(t===`0`)return!1;if(e===`docs`){let e=localStorage.getItem(U());if(e===`1`)return!0;if(e===`0`)return!1}}catch{}return t}function pe(e,t){try{localStorage.setItem(H(e),t?`1`:`0`),e===`docs`&&localStorage.setItem(U(),t?`1`:`0`)}catch{}}function G(e){return e.id===`docs`&&(e.name===`文档库`||e.name===`Documents`)?j(`nav.docs`):e.name}function me(e){return e.type===`group`?G(e.group):j(m(e.id).i18n)}function K(e){return e.type===`item`?u(e.id):te(e.group.id)}function he(){let[e,t]=(0,M.useState)(()=>window.location.pathname);return(0,M.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 q({children:e}){return(0,L.jsx)(`svg`,{className:`tw-nav-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:e})}function J({id:e,icon:t}){return(0,L.jsx)(q,{children:Y[t??b[e]]})}var Y={check:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M9 11l3 3L22 4`}),(0,L.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,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M12 20h9`}),(0,L.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`})]}),book:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 0 1 6.5 17H20`}),(0,L.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,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M14 3v5h5`}),(0,L.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,L.jsx)(`path`,{d:`M8 13h8`}),(0,L.jsx)(`path`,{d:`M8 17h6`})]}),layers:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M12 3 3 8l9 5 9-5-9-5z`}),(0,L.jsx)(`path`,{d:`m3 13 9 5 9-5`})]}),list:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M8 6h13`}),(0,L.jsx)(`path`,{d:`M8 12h13`}),(0,L.jsx)(`path`,{d:`M8 18h13`}),(0,L.jsx)(`path`,{d:`M3 6h.01`}),(0,L.jsx)(`path`,{d:`M3 12h.01`}),(0,L.jsx)(`path`,{d:`M3 18h.01`})]}),folder:(0,L.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,L.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,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`ellipse`,{cx:`12`,cy:`6`,rx:`8`,ry:`3`}),(0,L.jsx)(`path`,{d:`M4 6v6c0 1.7 3.6 3 8 3s8-1.3 8-3V6`}),(0,L.jsx)(`path`,{d:`M4 12v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]}),target:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8`}),(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`})]}),code:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`m8 8-4 4 4 4`}),(0,L.jsx)(`path`,{d:`m16 8 4 4-4 4`})]}),flask:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M9 3h6`}),(0,L.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,L.jsx)(`path`,{d:`M7.5 14h9`})]}),home:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M3 10.5 12 3l9 7.5`}),(0,L.jsx)(`path`,{d:`M5 9.5V20h14V9.5`})]}),clipboard:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M9 4h6v3H9z`}),(0,L.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,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`circle`,{cx:`12`,cy:`14`,r:`5`}),(0,L.jsx)(`path`,{d:`M9 6l2 2`}),(0,L.jsx)(`path`,{d:`M15 6l-2 2`}),(0,L.jsx)(`path`,{d:`M7 11H4`}),(0,L.jsx)(`path`,{d:`M20 11h-3`}),(0,L.jsx)(`path`,{d:`M7 17H4`}),(0,L.jsx)(`path`,{d:`M20 17h-3`})]}),calendar:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`rect`,{x:`3`,y:`5`,width:`18`,height:`16`,rx:`2`}),(0,L.jsx)(`path`,{d:`M8 3v4`}),(0,L.jsx)(`path`,{d:`M16 3v4`}),(0,L.jsx)(`path`,{d:`M3 10h18`})]}),chart:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M4 20V10`}),(0,L.jsx)(`path`,{d:`M10 20V4`}),(0,L.jsx)(`path`,{d:`M16 20v-7`}),(0,L.jsx)(`path`,{d:`M2 20h20`})]}),globe:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,L.jsx)(`path`,{d:`M3 12h18`}),(0,L.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,L.jsxs)(L.Fragment,{children:[(0,L.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,L.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,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`circle`,{cx:`9`,cy:`8`,r:`3.5`}),(0,L.jsx)(`path`,{d:`M2.5 20a6.5 6.5 0 0 1 13 0`}),(0,L.jsx)(`path`,{d:`M16 5.5a3.5 3.5 0 0 1 0 7`}),(0,L.jsx)(`path`,{d:`M18 20a6 6 0 0 0-2-4.5`})]}),terminal:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`m5 8 4 4-4 4`}),(0,L.jsx)(`path`,{d:`M13 16h6`})]}),tag:(0,L.jsxs)(L.Fragment,{children:[(0,L.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,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:`1.2`})]}),flag:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M5 21V4`}),(0,L.jsx)(`path`,{d:`M5 5h11l-2 4 2 4H5z`})]}),zap:(0,L.jsx)(`path`,{d:`M13 2 4 14h6l-1 8 9-12h-6l1-8z`})};function X(){return(0,L.jsxs)(L.Fragment,{children:[(0,L.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,L.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,L.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,L.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 ge(){return(0,L.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:[(0,L.jsx)(`path`,{d:`M21 4H14`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M10 4H3`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M21 12H12`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M8 12H3`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M21 20H16`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M12 20H3`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M14 2v4`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M8 10v4`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M16 18v4`,strokeLinecap:`round`})]})}function _e(){return(0,L.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:[(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,L.jsx)(`path`,{d:`M12 8v8`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M8 12h8`,strokeLinecap:`round`})]})}function Z(){return(0,L.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,children:[(0,L.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.7`}),(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.7`}),(0,L.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.7`})]})}function ve(){return(0,L.jsx)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,L.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 ye(){return(0,L.jsxs)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,L.jsx)(`path`,{d:`M9 6H5a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h4`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M16 8l4 4-4 4`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,L.jsx)(`path`,{d:`M20 12H9`,strokeLinecap:`round`})]})}function be(){return(0,L.jsxs)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,L.jsx)(`circle`,{cx:`8.5`,cy:`8.5`,r:`4.5`}),(0,L.jsx)(`rect`,{x:`12`,y:`12`,width:`9`,height:`9`,rx:`2`})]})}function xe(){return(0,L.jsxs)(q,{children:[(0,L.jsx)(`path`,{d:`M8 6v12`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M5 9l3-3 3 3`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,L.jsx)(`path`,{d:`M16 18V6`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M13 15l3 3 3-3`,strokeLinecap:`round`,strokeLinejoin:`round`})]})}function Q(){return(0,L.jsxs)(`svg`,{className:`tw-nav-drag-grip`,viewBox:`0 0 20 20`,"aria-hidden":!0,children:[(0,L.jsx)(`circle`,{cx:`7`,cy:`5`,r:`1.25`,fill:`currentColor`}),(0,L.jsx)(`circle`,{cx:`13`,cy:`5`,r:`1.25`,fill:`currentColor`}),(0,L.jsx)(`circle`,{cx:`7`,cy:`10`,r:`1.25`,fill:`currentColor`}),(0,L.jsx)(`circle`,{cx:`13`,cy:`10`,r:`1.25`,fill:`currentColor`}),(0,L.jsx)(`circle`,{cx:`7`,cy:`15`,r:`1.25`,fill:`currentColor`}),(0,L.jsx)(`circle`,{cx:`13`,cy:`15`,r:`1.25`,fill:`currentColor`})]})}function Se(e,t,n){let[r,i]=(0,M.useState)(null),a=(0,M.useRef)(null),o=(0,M.useRef)(e);o.current=e;let c=(0,M.useRef)(t);c.current=t;let l=(0,M.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=s(o.current,e,n);i.join(`|`)!==o.current.join(`|`)&&(o.current=i,c.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}}function $(e,t){let n=m(e).plugin;return!n||t[n]!==!1}function Ce({id:e,icon:t,pathname:n,actionOpen:r,onMenu:i}){let a=m(e),o=B(n,a.match);return(0,L.jsxs)(`div`,{className:[V(o),r?`is-action-open`:``].filter(Boolean).join(` `),"data-plugin-nav":a.plugin,children:[(0,L.jsxs)(`a`,{href:z(a.href),className:`tw-nav-item-main`,children:[(0,L.jsx)(J,{id:e,icon:t}),(0,L.jsx)(`span`,{className:`tw-nav-label`,children:j(a.i18n)})]}),(0,L.jsx)(`button`,{type:`button`,className:`tw-nav-hover-btn`,"aria-label":j(`nav.more`),onClick:e=>{e.preventDefault(),e.stopPropagation(),i(e.currentTarget)},children:(0,L.jsx)(Z,{})})]})}function we(e,t,n){return e.items.some(e=>{let t=m(e).plugin;return(!t||A(t))&&B(n,m(e).match)})?!0:i(t,e.id).some(e=>we(e,t,n))}function Te(e,t){return e.items.some(e=>{let t=m(e).plugin;return!t||A(t)})?!0:i(t,e.id).some(e=>Te(e,t))}function Ee({group:e,groups:t,icons:n,pathname:r,openItem:a,openGroupId:o,onMenu:s,onItemMenu:c}){let l=e.items.filter(e=>{let t=m(e).plugin;return!t||A(t)}),u=i(t,e.id),d=we(e,t,r),[f,p]=(0,M.useState)(()=>W(e.id,!0)),[h,g]=(0,M.useState)(!1),_=(0,M.useRef)(null),v=(0,M.useRef)(null),y=(0,M.useRef)(null);if((0,M.useEffect)(()=>b,[]),!Te(e,t))return null;function b(){y.current&&_.current&&_.current.removeEventListener(`transitionend`,y.current),y.current=null,v.current!==null&&(window.clearTimeout(v.current),v.current=null)}function x(){b(),pe(e.id,!0),g(!1),p(!0)}function S(t){if(t.preventDefault(),!f||h){x();return}g(!0),pe(e.id,!1);let n=_.current,r=!1,i=()=>{r||(r=!0,b(),p(!1),g(!1))},a=e=>{e.target===n&&e.propertyName===`grid-template-rows`&&i()};b(),y.current=a,n?.addEventListener(`transitionend`,a),v.current=window.setTimeout(i,360)}return(0,L.jsxs)(`details`,{className:`tw-nav-details ${h?`is-closing`:``}`,open:f||h,"data-nav-group":e.id,children:[(0,L.jsxs)(`summary`,{className:[`tw-nav-item tw-nav-summary`,d?`is-branch-active`:``,o===e.id?`is-action-open`:``].filter(Boolean).join(` `),onClick:S,children:[(0,L.jsx)(X,{}),(0,L.jsx)(`span`,{className:`tw-nav-label min-w-0 flex-1 truncate`,children:G(e)}),(0,L.jsx)(`button`,{type:`button`,className:`tw-nav-hover-btn`,"aria-label":j(`nav.groupActions`),onClick:t=>{t.preventDefault(),t.stopPropagation(),s(e,t.currentTarget)},children:(0,L.jsx)(ge,{})}),(0,L.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,L.jsx)(`path`,{d:`M7 5l6 5-6 5`,strokeLinecap:`round`,strokeLinejoin:`round`})})]}),(0,L.jsx)(`div`,{className:`tw-nav-subtree-anim`,ref:_,children:(0,L.jsxs)(`div`,{className:`tw-nav-subtree`,children:[l.map(e=>(0,L.jsx)(Ce,{id:e,icon:n[e],pathname:r,actionOpen:a===e,onMenu:t=>c(e,t)},e)),u.map(e=>(0,L.jsx)(Ee,{group:e,groups:t,icons:n,pathname:r,openItem:a,openGroupId:o,onMenu:s,onItemMenu:c},e.id))]})})]})}function De({open:e,draft:t,groups:n,plugins:r,icons:i,onClose:a,onSave:o,onDelete:s}){let[c,l]=(0,M.useState)(``),[u,d]=(0,M.useState)([]),[f,p]=(0,M.useState)(``),m=(0,M.useRef)(null),h=new Set(n.filter(e=>e.id!==t?.id).flatMap(e=>e.items)),_=g.filter(e=>$(e.id,r)&&(!h.has(e.id)||u.includes(e.id))),v=Se(u,d);(0,M.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 y(e){d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function b(){let e=c.trim();if(!e){p(j(`nav.groupNameRequired`));return}if(!u.length){p(j(`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=>_.find(t=>t.id===e)).filter(e=>!!e),..._.filter(e=>!u.includes(e.id))];return(0,L.jsxs)(D,{open:e,onClose:a,transition:!0,className:`relative z-110`,children:[(0,L.jsx)(O,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":!0}),(0,L.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,L.jsxs)(E,{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,L.jsx)(k,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:t?.id?j(`nav.editGroupTitle`):t?.parentId?j(`nav.addSubgroup`):j(`nav.createGroup`)}),(0,L.jsxs)(`label`,{className:`tw-confirm-msg mt-4 block text-xs font-medium text-stone-500`,children:[j(`nav.groupName`),(0,L.jsx)(`input`,{ref:m,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),b())},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,L.jsxs)(`div`,{className:`mt-4`,children:[(0,L.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:j(`nav.groupItems`)}),(0,L.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:j(`nav.groupItemsHint`)}),(0,L.jsxs)(`div`,{ref:v.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,L.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`:``,v.dragId===e.id?`is-dragging`:``].filter(Boolean).join(` `),onPointerDown:t?t=>{t.target.closest(`input`)||v.onPointerDown(e.id,t)}:void 0,children:[t?(0,L.jsx)(Q,{}):(0,L.jsx)(`span`,{className:`tw-nav-drag-grip`}),(0,L.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>y(e.id),className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/40`}),(0,L.jsx)(`span`,{className:`tw-nav-editor-ico`,children:(0,L.jsx)(J,{id:e.id,icon:i[e.id]})}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:j(e.i18n)})]},e.id)}),x.length?null:(0,L.jsx)(`div`,{className:`px-3 py-4 text-center text-[12px] text-stone-400`,children:j(`nav.noAddableItems`)})]})]}),f?(0,L.jsx)(`p`,{className:`mt-2 text-[12px] text-red-600`,children:f}):null,(0,L.jsxs)(`div`,{className:`mt-5 flex items-center gap-2`,children:[t?.id&&s?(0,L.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:j(`nav.deleteGroup`)}):null,(0,L.jsx)(`div`,{className:`flex-1`}),(0,L.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:j(`nav.groupCancel`)}),(0,L.jsx)(`button`,{type:`button`,onClick:b,className:`h-8 px-3 text-sm rounded-lg text-white bg-[#4176e6] hover:bg-[#3566d0]`,children:j(`nav.groupSave`)})]})]})})]})}function Oe({ids:e,labelOf:t,onChange:n,onEnd:r,indent:i}){let a=Se(e,n,r);return(0,L.jsx)(`div`,{ref:a.listRef,className:`flex flex-col`,children:e.map(e=>(0,L.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,L.jsx)(Q,{}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t(e)})]},e))})}function ke({open:e,focusGroupId:t,nodes:n,groups:r,onClose:i,onCommit:a}){let[o,s]=(0,M.useState)(()=>n.map(K)),[c,l]=(0,M.useState)(()=>Object.fromEntries(r.map(e=>[e.id,[...e.items]]))),u=(0,M.useRef)(o);u.current=o;let d=(0,M.useRef)(c);d.current=c;let f=(0,M.useRef)(r);f.current=r;let p=(0,M.useRef)(n);p.current=n;let h=()=>{let e=f.current.map(e=>({...e,items:d.current[e.id]??e.items}));a(u.current,e)};(0,M.useEffect)(()=>{if(!e)return;let t=p.current.map(K);u.current=t,s(t);let n=Object.fromEntries(f.current.map(e=>[e.id,[...e.items]]));d.current=n,l(n)},[e]);let g=e=>{u.current=e,s(e)},_=(e,t)=>{let n={...d.current,[e]:t};d.current=n,l(n)},v=new Map(n.map(e=>[K(e),me(e)])),y=t?r.find(e=>e.id===t):void 0;return(0,L.jsxs)(D,{open:e,onClose:i,transition:!0,className:`relative z-110`,children:[(0,L.jsx)(O,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":!0}),(0,L.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,L.jsxs)(E,{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,L.jsx)(k,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:j(`nav.sortMenuTitle`)}),(0,L.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:j(`nav.sortHint`)}),(0,L.jsx)(`div`,{className:`mt-4 max-h-80 overflow-auto rounded-lg border border-stone-200 p-1`,children:y?(0,L.jsx)(Oe,{ids:c[y.id]??y.items,labelOf:e=>j(m(e).i18n),onChange:e=>_(y.id,e),onEnd:h,indent:!0}):(0,L.jsx)(Oe,{ids:o,labelOf:e=>v.get(e)??e,onChange:g,onEnd:h})}),(0,L.jsx)(`div`,{className:`mt-5 flex justify-end`,children:(0,L.jsx)(`button`,{type:`button`,onClick:i,className:`h-8 px-3 text-sm rounded-lg text-white bg-[#4176e6] hover:bg-[#3566d0]`,children:j(`nav.done`)})})]})})]})}function Ae(e){let t=[];for(let n of e.filter(e=>!e.parentId)){t.push({group:n,indent:!1});for(let r of i(e,n.id))t.push({group:r,indent:!0})}return t}function je(){return(0,L.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,L.jsx)(`path`,{d:`M7 5l5 5-5 5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}var Me=120;function Ne(){let[e,t]=(0,M.useState)(null),n=(0,M.useRef)(null),r=(0,M.useCallback)(()=>{n.current!==null&&(window.clearTimeout(n.current),n.current=null)},[]),i=(0,M.useCallback)(e=>{r(),t({value:e,closing:!1})},[r]),a=(0,M.useCallback)(()=>{r(),t(e=>e&&!e.closing?{...e,closing:!0}:e),n.current=window.setTimeout(()=>{n.current=null,t(null)},Me)},[r]),o=(0,M.useCallback)(()=>{r(),t(null)},[r]);return(0,M.useEffect)(()=>r,[r]),{value:e?.value??null,closing:!!e?.closing,open:i,close:a,closeNow:o}}function Pe(e,t){return{onMouseOver:()=>e?.(),onMouseOut:e=>{let n=e.relatedTarget;n&&e.currentTarget.contains(n)||t?.()}}}function Fe({anchor:e,current:t,itemId:n,closing:r,onPick:i,onHoverEnter:a,onHoverLeave:o}){let s=(0,M.useRef)(null),[c,l]=(0,M.useState)({top:e.top,left:e.right+8});return(0,M.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,N.createPortal)((0,L.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},...Pe(a,o),children:[(0,L.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:j(`nav.chooseIcon`)}),(0,L.jsx)(`div`,{className:`tw-nav-icon-grid`,children:h.map(e=>(0,L.jsx)(`button`,{type:`button`,className:[`tw-nav-icon-cell`,t===e?`is-current`:``].filter(Boolean).join(` `),onClick:()=>i(e),children:(0,L.jsx)(J,{id:n,icon:e})},e))})]}),document.body)}function Ie({rect:e,closing:t=!1,onClose:n,onHoverEnter:r,onHoverLeave:i,children:a}){let o=(0,M.useRef)(null),[s,c]=(0,M.useState)({top:e.top,left:e.right+6});return(0,M.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,M.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,N.createPortal)((0,L.jsx)(`div`,{ref:o,className:[`tw-nav-group-pop`,t?`is-closing`:``].filter(Boolean).join(` `),style:{top:s.top,left:s.left},...Pe(r,i),children:a}),document.body)}function Le(){let e=he(),[t,n]=(0,M.useState)(()=>se()),[i,o]=(0,M.useState)(()=>F()),[s,u]=(0,M.useState)(()=>le()),[d,p]=(0,M.useState)(()=>oe()),[h,g]=(0,M.useState)(null),[b,x]=(0,M.useState)(!1),[S,C]=(0,M.useState)(null),[w,T]=(0,M.useState)(!1),[te,re]=(0,M.useState)(null),E=Ne(),D=Ne(),O=E.value,k=D.value,A=(0,M.useRef)(null);(0,M.useEffect)(()=>()=>{A.current!==null&&window.clearTimeout(A.current)},[]);function N(e){re(e),T(!0)}function P(e){g(e),x(!0)}function I(){x(!1),C(null)}(0,M.useEffect)(()=>{let e=!0,t=ae(e=>{p({...e})});return _().then(async()=>{e&&(await fe(),e&&(n(se()),u(le()),o(F()),p(oe())))}),()=>{e=!1,t()}},[]);let R=ee(t,s);function z(e,t){let r=ue(e,t);n(r.groups),u(r.order),de(r.groups).then(e=>{if(!e||JSON.stringify(e)===JSON.stringify(r.groups))return;let t=ue(e,r.order);n(t.groups),u(t.order)})}function B(){V(),D.close(),E.close()}function V(){A.current!==null&&(window.clearTimeout(A.current),A.current=null)}function H(){V(),A.current=window.setTimeout(()=>{A.current=null,D.close()},220)}function U(e,t){V(),D.open({itemId:e,rect:t.getBoundingClientRect()})}function W(e,t){O?.kind===`itemMenu`&&O.itemId===e?B():(D.closeNow(),E.open({kind:`itemMenu`,itemId:e,rect:t.getBoundingClientRect()}))}function pe(e,t){O?.kind===`groupMenu`&&O.group.id===e.id?B():(D.closeNow(),E.open({kind:`groupMenu`,group:e,rect:t.getBoundingClientRect()}))}function me(e,n){z(f(t,e,n),s),B()}function K(e){let{groups:n,owner:i}=r(t,e);z(n,i?a(s,e,i,n):s),B()}let q=O?.kind===`assign`||O?.kind===`itemMenu`?O.itemId:void 0,J=O?.kind===`groupMenu`?O.group.id:void 0,Y=O?.kind===`itemMenu`?O:null,X=O?.kind===`groupMenu`?O:null,Z=O?.kind===`assign`?O:null,Q=Y?t.find(e=>e.items.includes(Y.itemId))??null:null;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`tw-nav-ready`,"aria-hidden":`true`}),R.map(n=>n.type===`item`?$(n.id,d)?(0,L.jsx)(Ce,{id:n.id,icon:i[n.id],pathname:e,actionOpen:q===n.id,onMenu:e=>W(n.id,e)},n.id):null:(0,L.jsx)(Ee,{group:n.group,groups:t,icons:i,pathname:e,openItem:q,openGroupId:J,onMenu:pe,onItemMenu:W},n.group.id)),Y?(0,L.jsxs)(Ie,{rect:Y.rect,closing:E.closing,onClose:B,onHoverEnter:V,onHoverLeave:H,children:[(0,L.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:j(m(Y.itemId).i18n)}),(0,L.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`&&(V(),D.close())},children:[Q?(0,L.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item is-leave`,onClick:()=>K(Y.itemId),children:[(0,L.jsx)(ye,{}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:j(`nav.leaveGroup`)})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>E.open({kind:`assign`,itemId:Y.itemId,rect:Y.rect}),children:[(0,L.jsx)(ve,{}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:j(`nav.assignGroup`)})]}),(0,L.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=Y.itemId;B(),P({name:``,items:[e]})},children:[(0,L.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,L.jsx)(_e,{})}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:j(`nav.addToGroup`)})]})]}),(0,L.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=Q?.id??null;B(),N(e)},children:[(0,L.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,L.jsx)(xe,{})}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:j(`nav.sortMenu`)})]}),(0,L.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,"data-submenu":`icons`,onMouseEnter:e=>U(Y.itemId,e.currentTarget),onClick:e=>U(Y.itemId,e.currentTarget),children:[(0,L.jsx)(be,{}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:j(`nav.chooseIcon`)}),(0,L.jsx)(je,{})]})]})]}):null,k&&Y&&k.itemId===Y.itemId?(0,L.jsx)(Fe,{anchor:k.rect,itemId:k.itemId,current:i[k.itemId],closing:D.closing,onHoverEnter:V,onHoverLeave:H,onPick:e=>{o(ce(k.itemId,e)),B()}}):null,X?(0,L.jsxs)(Ie,{rect:X.rect,closing:E.closing,onClose:B,children:[(0,L.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:G(X.group)}),(0,L.jsxs)(`div`,{className:`tw-nav-group-pop-list`,children:[X.group.parentId?null:(0,L.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item is-create`,onClick:()=>{let e=X.group.id;B(),P({name:``,items:[],parentId:e})},children:[(0,L.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,L.jsx)(_e,{})}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:j(`nav.addSubgroup`)})]}),(0,L.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=X.group;B(),P({id:e.id,name:e.name,items:[...e.items],parentId:e.parentId})},children:[(0,L.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,L.jsx)(ge,{})}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:j(`nav.editGroupTitle`)})]})]})]}):null,Z?(0,L.jsxs)(Ie,{rect:Z.rect,closing:E.closing,onClose:B,children:[(0,L.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:j(`nav.assignGroup`)}),(0,L.jsx)(`div`,{className:`tw-nav-group-pop-list`,children:t.length?Ae(t).map(({group:e,indent:t})=>{let n=e.items.includes(Z.itemId);return(0,L.jsxs)(`button`,{type:`button`,className:[`tw-nav-group-pop-item`,n?`is-current`:``,t?`is-child`:``].filter(Boolean).join(` `),onClick:()=>{n||me(e.id,Z.itemId)},children:[(0,L.jsx)(ve,{}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:G(e)}),n?(0,L.jsx)(`span`,{className:`tw-nav-group-pop-tag`,children:j(`nav.currentGroup`)}):null]},e.id)}):(0,L.jsx)(`div`,{className:`tw-nav-group-pop-empty`,children:j(`nav.noGroups`)})})]}):null,(0,L.jsx)(De,{open:b&&!S,draft:h,groups:t,plugins:d,icons:i,onClose:I,onSave:e=>{let n=c(t,e);z(n.groups,y(s,n.groups,n.id)),I()},onDelete:h?.id?()=>C(h.id):void 0}),(0,L.jsx)(ke,{open:w,focusGroupId:te,nodes:R,groups:t,onClose:()=>T(!1),onCommit:(e,t)=>z(t,e)}),(0,L.jsx)(ie,{open:!!S,title:j(`nav.deleteGroup`),message:t.find(e=>e.id===S)?.parentId?j(`nav.deleteSubgroupMsg`):j(`nav.deleteGroupMsg`),confirmLabel:j(`nav.deleteGroup`),cancelLabel:j(`nav.groupCancel`),danger:`outline`,onClose:()=>C(null),onConfirm:()=>{if(S){let e=t.find(e=>e.id===S),n=ne(t,S),r=v(t,S);z(r,e?l(s,e,r,n):s)}I()}})]})}export{Le as default};
@@ -1 +0,0 @@
1
- export{t as default}from"./PluginsPage.BNzpPg2H.js";
@@ -1 +0,0 @@
1
- import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.CpjKWnzM.js";import{a as r,f as i,o as a,r as o,u as s}from"./SelectDropdown.Dc7QaPbH.js";import{i as c}from"./prompts-meta.F4wwkjUA.js";import{t as l}from"./jsx-runtime.BUXbF_vF.js";import{t as u}from"./ConfirmDialog.BYz4HREM.js";import{i as d,n as f,r as p,t as m}from"./DocsFileBrowser.DkE26UTR.js";import{a as h,o as g,r as _}from"./plugins.CrpY8UI9.js";import{t as v,u as y}from"./open-docs-in-session.D3JCwMWB.js";var b=e(t(),1),x=l(),S=10;async function C(e=`.`){let{entries:t}=await s(`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=p(`prompts`),[t,s]=(0,b.useState)(!1),[l,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=f(D,S),R=(0,b.useCallback)(async()=>{A(null);try{let e=await C(`.`);O(e),d(`prompts`,e)}catch(e){A(e instanceof Error?e.message:String(e))}},[]);(0,b.useEffect)(()=>{let e=h(e=>w(!!e.prompts));return n().then(()=>{w(_(`prompts`)),s(!0)}),e},[]),(0,b.useEffect)(()=>{t&&l&&(async()=>{await a(`prompts`)?(await y().catch(()=>null),await R(),E(!0)):E(!1)})()},[t,l,R]);let z=(0,b.useMemo)(()=>Object.keys(N).filter(e=>N[e]),[N]);async function B(e){M(!0),A(null);try{await i(`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){c(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 r(`prompts`,e.entry.path);else{for(let t of e.paths)c(t)||await r(`prompts`,t);P({})}await R()}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}function W(){_(`promptGen`)?window.location.href=`/?plugin=promptGen`:A(g(`promptGen`))}let G=F?.kind===`one`?`删除「${F.entry.name}」?将从 ${o(`prompts`)} 中移除。`:F?.kind===`batch`?`确认删除已选中的 ${F.paths.length} 个提示词?此操作不可恢复。`:``;return t?l?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)(m,{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=>!c(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=c(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)(u,{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:g(`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 +0,0 @@
1
- import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.CpjKWnzM.js";import{_ as r,a as i,c as a,d as o,f as s,g as c,h as ee,i as te,l,o as ne,p as u,r as re,s as ie,u as d,v as ae}from"./SelectDropdown.Dc7QaPbH.js";import{t as f}from"./jsx-runtime.BUXbF_vF.js";import{t as oe}from"./ConfirmDialog.BYz4HREM.js";import{a as se,o as ce,r as p}from"./plugins.CrpY8UI9.js";import{n as le,r as ue,t as de}from"./useListAnim.CnbC_9MC.js";import{t as m}from"./NamePromptDialog.DGBlDH_k.js";var h=e(t(),1),g=f(),fe=5;function _({className:e=`w-4 h-4`,open:t=!1}){return(0,g.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,g.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`}):(0,g.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 v({className:e=`w-3 h-3`}){return(0,g.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,g.jsx)(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z`}),(0,g.jsx)(`path`,{d:`m15 5 4 4`})]})}function y({className:e=`w-3 h-3`}){return(0,g.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,g.jsx)(`path`,{d:`M3 6h18`}),(0,g.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,g.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,g.jsx)(`path`,{d:`M10 11v6`}),(0,g.jsx)(`path`,{d:`M14 11v6`})]})}function b({node:e,depth:t,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o}){let s=r[e.path]??i,c=n===e.path;return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,g.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.path),e.children.length&&a(e.path)},"aria-expanded":e.children.length?s:void 0,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${c?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,g.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,g.jsx)(_,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,g.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,g.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,g.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,g.jsx)(`div`,{className:`tw-collapse-inner`,children:e.children.map(e=>(0,g.jsx)(b,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function pe(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function x(){let[e,t]=(0,h.useState)(()=>p(`requirements`)),[f,x]=(0,h.useState)(!1),[S,me]=(0,h.useState)(null),[C,he]=(0,h.useState)([]),[ge,_e]=(0,h.useState)(0),[w,T]=(0,h.useState)(`.`),[E,D]=(0,h.useState)([]),[ve,O]=(0,h.useState)({}),[k,ye]=(0,h.useState)(!0),[A,j]=(0,h.useState)(null),[M,N]=(0,h.useState)(!1),[P,F]=(0,h.useState)(null),[be,I]=(0,h.useState)(!1),[L,R]=(0,h.useState)(null),[z,B]=(0,h.useState)(null),[xe,V]=(0,h.useState)(1),[H,Se]=ue(fe),[Ce,U]=(0,h.useState)(null),W=(0,h.useRef)(null),{cls:we,play:G}=de(),K=(0,h.useCallback)(async()=>{let e=await ie(`requirements`);he(e.tree),_e(e.totalFiles)},[]),q=(0,h.useCallback)(async(e=w)=>{j(null);try{let[t]=await Promise.all([d(`requirements`,e),K()]);D(t.entries),T(t.path)}catch(e){j(e instanceof Error?e.message:String(e))}},[w,K]);(0,h.useEffect)(()=>{let e=se(e=>t(!!e.requirements));return n().then(()=>{t(p(`requirements`)),x(!0)}),e},[]),(0,h.useEffect)(()=>{f&&e&&(async()=>{let e=await ne(`requirements`);if(me(e),e)try{let[e]=await Promise.all([d(`requirements`,`.`),K()]);D(e.entries),T(e.path)}catch(e){j(e instanceof Error?e.message:String(e))}})()},[f,e,K]);function Te(){ye(e=>!e),O({})}async function J(e){G(),T(e),V(1),F(null),U(null),j(null);try{let t=await d(`requirements`,e);D(t.entries)}catch(e){j(e instanceof Error?e.message:String(e))}}async function Ee(e){I(!1),N(!0),j(null);try{await o(`requirements`,w,e),await q(w)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}async function De(e){if(e.type===`file`){N(!0),j(null);try{await s(`requirements`,e.path)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}async function Oe(e){if(e?.length){N(!0),j(null);try{for(let t of Array.from(e))await ae(`requirements`,w,t);await q(w)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1),W.current&&(W.current.value=``)}}}function ke(e){let t=a(C,e.path),n=t?.fileCount??0,r=t?te(t):0;R({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function Ae(e){R({name:e.name,path:e.path,isDir:!1})}function Y(e,t){B({...e,isDir:t})}async function je(){let e=L;if(e&&(R(null),!e.blocked)){N(!0),j(null);try{await i(`requirements`,e.path),P&&l(P.path,e.path)&&F(null);let t=l(w,e.path)?u(e.path):w;await q(t)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}async function Me(e){let t=z;if(t&&(B(null),e!==t.name)){N(!0),j(null);try{let n=await r(`requirements`,t.path,e);await q(c(w,t.path,n))}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}let Ne=(()=>{if(!L)return``;if(!L.isDir)return`删除文件「${L.name}」?将移入系统废纸篓,可随时找回。`;if(L.blocked){let e=[];return L.files&&e.push(`${L.files} 个文件`),L.dirs&&e.push(`${L.dirs} 个子文件夹`),`文件夹「${L.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${L.name}」?将移入系统废纸篓。`})();async function Pe(e){if(e.type!==`file`)return;let t=e.name.toLowerCase();if(!t.endsWith(`.md`)&&!t.endsWith(`.txt`))j(`仅 .md / .txt 支持就地预览;docx 请双击用本机程序打开。`);else{N(!0),j(null);try{let t=await ee(`requirements`,e.path);F({path:t.path,content:t.content})}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}if(!f)return(0,g.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,g.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,g.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:ce(`requirements`)});if(S===null)return(0,g.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,g.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!S)return(0,g.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:`需求文档库需要本地文档服务,当前未就绪。`});let X=E.filter(e=>e.type===`file`),Z=E.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/H)),$=Math.min(xe,Q),Fe=X.slice(($-1)*H,$*H);function Ie(e){G(),Se(e),V(1)}return(0,g.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,g.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,g.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,g.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,g.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>I(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,g.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1`,children:[(0,g.jsx)(`div`,{className:`group flex items-center rounded-md ${w===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,g.jsxs)(`button`,{type:`button`,onClick:()=>{J(`.`),Te()},"aria-expanded":k,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${w===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,g.jsx)(_,{open:k,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,g.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部需求`}),(0,g.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,ge,`)`]})]})}),(0,g.jsx)(`div`,{className:`tw-collapse ${k?`is-open`:``}`,children:(0,g.jsx)(`div`,{className:`tw-collapse-inner`,children:C.map(e=>(0,g.jsx)(b,{node:e,depth:0,activePath:w,expanded:ve,globalOpen:k,onToggle:e=>O(t=>({...t,[e]:!(t[e]??k)})),onSelect:e=>void J(e)},e.path))})})]})]}),(0,g.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,g.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,g.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,g.jsx)(`span`,{className:`text-stone-400`,children:re(`requirements`)}),w===`.`?``:w]}),(0,g.jsx)(`input`,{ref:W,type:`file`,multiple:!0,accept:`.md,.txt,.docx,text/plain,text/markdown,application/vnd.openxmlformats-officedocument.wordprocessingml.document`,className:`hidden`,onChange:e=>void Oe(e.target.files)}),(0,g.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>W.current?.click(),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,g.jsx)(`div`,{className:`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,g.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,g.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,g.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,g.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void J(e.path),children:[(0,g.jsx)(_,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,g.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,g.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!0),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,g.jsx)(v,{className:`w-3.5 h-3.5`})}),(0,g.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>ke({name:e.name,path:e.path}),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,g.jsx)(y,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,g.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加需求文档(.md / .txt / .docx)`}):(0,g.jsx)(`ul`,{className:`${we}space-y-1`,children:Fe.map(e=>{let t=Ce===e.path;return(0,g.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors ${t?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,g.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,onClick:()=>{U(e.path),Pe(e)},onDoubleClick:t=>{t.preventDefault(),De(e)},children:[(0,g.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,g.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:pe(e.size)})]}),(0,g.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,g.jsx)(v,{className:`w-3.5 h-3.5`})}),(0,g.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>Ae(e),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,g.jsx)(y,{className:`w-3.5 h-3.5`})})]},e.path)})})]}),P?(0,g.jsxs)(`div`,{className:`rounded-lg border border-stone-200 overflow-hidden`,children:[(0,g.jsxs)(`div`,{className:`px-3 py-2 bg-stone-50 border-b border-stone-200 flex items-center justify-between`,children:[(0,g.jsx)(`span`,{className:`text-xs text-stone-500 truncate`,children:P.path}),(0,g.jsx)(`button`,{type:`button`,className:`text-xs text-stone-500 hover:text-stone-800`,onClick:()=>F(null),children:`关闭预览`})]}),(0,g.jsx)(`pre`,{className:`max-h-80 overflow-auto p-4 text-xs leading-5 text-stone-700 whitespace-pre-wrap bg-white`,children:P.content})]}):null]}),X.length>0?(0,g.jsx)(le,{page:$,totalPages:Q,pageSize:H,busy:M,onPage:e=>{G(),V(e)},onPageSize:Ie}):null]}),(0,g.jsx)(m,{open:be,title:`新建文件夹`,onClose:()=>I(!1),onConfirm:e=>void Ee(e)}),(0,g.jsx)(m,{open:z!=null,title:z?.isDir?`重命名文件夹`:`重命名文件`,label:z?.isDir?`文件夹名称`:`文件名称`,initialValue:z?.name??``,lockExtension:z!=null&&!z.isDir,confirmLabel:`保存`,onClose:()=>B(null),onConfirm:e=>void Me(e)}),(0,g.jsx)(oe,{open:L!=null,title:L?.blocked?`无法删除文件夹`:L?.isDir?`删除文件夹`:`删除需求文件`,message:Ne,confirmLabel:L?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!L?.blocked,hideCancel:!!L?.blocked,onClose:()=>R(null),onConfirm:()=>void je()})]})}export{x as default};
@@ -1 +0,0 @@
1
- import{t as e}from"./jsx-runtime.BUXbF_vF.js";import{i as t,n,r,t as i}from"./listbox.DdDDDJ5Z.js";function a(e){return e===`requirements`?`/__tb_requirements`:e===`cases`?`/__tb_cases`:e===`prompts`?`/__tb_prompts`:e===`knowledge`?`/__tb_knowledge`:`/__tb_templates`}async function o(e,t,n){let r=await fetch(`${a(e)}${t}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n??{})}),i=await r.json();if(!r.ok)throw Error(i.error||`HTTP ${r.status}`);return i}async function s(e){try{return(await fetch(`${a(e)}/health`,{signal:AbortSignal.timeout(1500)})).ok}catch{return!1}}async function c(e,t=`.`){let n=await o(e,`/list`,{path:t});return{path:n.path,entries:n.entries??[]}}async function l(e){let t=await fetch(`${a(e)}/tree`,{signal:AbortSignal.timeout(3e3)}),n=await t.json();if(!t.ok)throw Error(n.error||`HTTP ${t.status}`);return{tree:n.tree??[],totalFiles:n.totalFiles??0}}async function u(e,t,n){return(await o(e,`/mkdir`,{parent:t,name:n})).path}async function d(e,t,n){let r=await n.arrayBuffer(),i=new Uint8Array(r),a=``;for(let e=0;e<i.length;e++)a+=String.fromCharCode(i[e]);let s=btoa(a);return o(e,`/upload`,{parent:t,name:n.name,contentBase64:s})}async function f(e,t){let n=await o(e,`/read`,{path:t});if(n.encoding===`utf-8`&&typeof n.content==`string`)return{path:n.path,content:n.content,encoding:n.encoding};throw Error(`该文件不是可预览的文本`)}async function p(e,t){let n=await o(e,`/read`,{path:t});if(n.encoding===`utf-8`&&typeof n.content==`string`)return{path:n.path,encoding:`utf-8`,content:n.content};if(typeof n.contentBase64==`string`)return{path:n.path,encoding:`base64`,contentBase64:n.contentBase64};throw Error(`无法读取文件`)}async function m(e,t,n){await o(e,`/write-text`,{path:t,content:n})}async function h(e,t,n){await o(e,`/write-binary`,{path:t,contentBase64:n})}async function g(e,t){await o(e,`/delete`,{path:t})}async function _(e,t,n){return(await o(e,`/rename`,{path:t,name:n})).path}function v(e){let t=e.lastIndexOf(`/`);return t<0?`.`:e.slice(0,t)}function y(e,t){return e===t||e.startsWith(`${t}/`)}function b(e,t,n){return y(e,t)?n+e.slice(t.length):e}function x(e,t){for(let n of e){if(n.path===t)return n;let e=x(n.children,t);if(e)return e}return null}function S(e){let t=0;for(let n of e.children)t+=1+S(n);return t}async function C(e,t){await o(e,`/open`,{path:t})}var w={cases:{path:`用例管理`,label:`用例管理`,legacyPaths:[`cases`,`用例`]},requirements:{path:`需求文档库`,label:`需求文档库`,legacyPaths:[`requirements`,`需求`]},prompts:{path:`提示词管理`,label:`提示词管理`,legacyPaths:[`prompts`,`提示词`]},knowledge:{path:`知识库管理`,label:`知识库管理`,legacyPaths:[`knowledge`,`知识库`]},templates:{path:`测试模板库`,label:`测试模板库`,legacyPaths:[`templates`,`模板`]}};function T(e){return w[e]?.label??e}function E(e){return`${T(e)}/`}var D=e();function O({className:e=`w-4 h-4 text-stone-400 shrink-0`}){return(0,D.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,D.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})}function k(){return(0,D.jsx)(`svg`,{className:`w-4 h-4 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":!0,children:(0,D.jsx)(`path`,{fillRule:`evenodd`,d:`M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z`,clipRule:`evenodd`})})}function A({options:e,value:a,onChange:o,disabled:s=!1,className:c=``,compact:l=!1,ariaLabel:u,showCheck:d=!0,centerContent:f=!1}){let p=e.find(e=>e.value===a),m=f?`relative justify-center`:`justify-between`,h=f?`w-4 h-4 text-stone-400 shrink-0 absolute right-2.5`:void 0;return(0,D.jsx)(r,{value:a,onChange:o,disabled:s,children:(0,D.jsxs)(`div`,{className:`relative ${l?`inline-block`:`mt-1`} ${c}`,children:[(0,D.jsxs)(t,{"aria-label":u,className:`${l?`w-full h-8 flex items-center gap-1.5 rounded-lg border border-stone-300 bg-white px-2.5 text-sm text-left text-stone-700 outline-none cursor-pointer hover:border-stone-400 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`:`w-full h-9 flex items-center gap-2 rounded-lg border border-stone-200 bg-white px-3 text-sm text-left text-stone-800 outline-none cursor-pointer hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`} ${m}`,children:[(0,D.jsx)(`span`,{className:`truncate`,children:p?.label??a}),(0,D.jsx)(O,{className:h})]}),(0,D.jsx)(i,{transition:!0,anchor:{to:`bottom start`,gap:4},className:`tw-select-menu tw-menu-anim z-80 max-h-56 w-(--button-width) overflow-auto rounded-lg p-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:e.map(e=>(0,D.jsxs)(n,{value:e.value,className:`group cursor-pointer select-none flex items-center gap-2 rounded-md px-3 py-2 text-sm data-[focus]:bg-stone-50 ${d?`text-stone-700 data-[selected]:text-stone-900`:`data-[selected]:text-(--tw-accent) data-[selected]:font-medium`} ${f?`justify-center px-2`:``}`,children:[d?(0,D.jsx)(`span`,{className:`w-4 shrink-0 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100`,children:(0,D.jsx)(k,{})}):null,(0,D.jsx)(`span`,{className:`truncate`,children:e.label})]},e.value))})]})})}export{_,g as a,m as b,x as c,u as d,C as f,b as g,f as h,S as i,y as l,p as m,T as n,s as o,v as p,E as r,l as s,A as t,c as u,d as v,h as y};
@@ -1,7 +0,0 @@
1
- import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{f as n,i as r}from"./app-config.CpjKWnzM.js";import{n as i}from"./llm.BZEzE0x2.js";import{t as a}from"./prompts-meta.F4wwkjUA.js";import{l as o}from"./settings.BoQ0e0m1.js";import{t as s}from"./jsx-runtime.BUXbF_vF.js";import{a as c,i as l,n as u,r as d,t as f}from"./ConfirmDialog.BYz4HREM.js";import{i as p,n as m,r as h,t as g}from"./menu.CqkL87bV.js";import{n as _}from"./i18n.BVvhz-vw.js";var v=e(t(),1),y=`/__tb_spaces`;async function b(e,t){try{let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})}),r=await n.json();return n.ok?r:{ok:!1,error:r?.error||`请求失败(HTTP ${n.status})`}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function x(e){try{return(await fetch(y,{signal:e??AbortSignal.timeout(2e3)})).ok}catch{return!1}}async function ee(e){try{let t=e?.stats?`${y}?stats=1`:y,r=await fetch(t);if(!r.ok)return null;let i=await r.json();return i?.activeId&&n(i.activeId),i}catch{return null}}async function S(e){let t=await b(`${y}/switch`,{id:e});return t.ok&&n(e),t}function C(e,t){return b(`${y}/create`,{name:e,managedParent:t?.managedParent,switch:t?.switch===!0,systemPrompt:t?.systemPrompt})}function te(e,t){return b(`${y}/rename`,{id:e,name:t})}function ne(e,t){return b(`${y}/copy`,{id:e,name:t})}function re(e,t){return b(`${y}/delete`,{id:e,purge:t,confirm:t===!0})}function ie(e,t=`full`){return`${y}/export?id=${encodeURIComponent(e)}${t===`content`?`&scope=content`:``}`}function w(e){return b(`${y}/discover`,Array.isArray(e)&&e.length?{adopt:e}:{})}async function ae(e,t){let n=await e.arrayBuffer(),r=new Uint8Array(n),i=``,a=32768;for(let e=0;e<r.length;e+=a)i+=String.fromCharCode(...r.subarray(e,e+a));let o=btoa(i);return b(`${y}/import`,{zipBase64:o,name:t})}function T(e){return e.isPublic?_(`space.publicName`):e.name}function E(e,t){let n=e.includes(`\\`)?`\\`:`/`,r=t.replace(/[/\\]+$/,``),i=`${r}${n}空间池`;if(e===i)return r;let a=`${i}${n}`;return e.startsWith(a)?`${r}${n}${e.slice(a.length)}`:e}function oe(e){if(!e||e<=0)return`—`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=0,r=e;for(;r>=1024&&n<t.length-1;)r/=1024,n+=1;return`${r<10&&n>0?r.toFixed(1):Math.round(r)} ${t[n]}`}var se=`你是提示词作者。根据用户对这个数据空间的要求,写一份「默认提示词」正文(Markdown 纯文本,不要用代码围栏)。
2
- 这份提示词将作为 Lantern Harness 该空间里 AI 助手的默认人设与回答原则。
3
- 要求:
4
- - 用「你是…」起头设定角色;
5
- - 紧扣用户描述的领域与工作方式;
6
- - 写几条简洁的回答原则(问什么答什么、先结论);
7
- - 只输出提示词正文,不要解释、不要标题。`;function ce(e){let t=String(e??``).replace(/^\uFEFF/,``).trim(),n=/^```(?:markdown|md|text)?\s*\n([\s\S]*?)\n```$/i.exec(t);return n&&(t=n[1].trim()),t}var D=s();function le(e){return e instanceof DOMException&&e.name===`AbortError`||e instanceof Error&&e.name===`AbortError`}function O({hint:e,children:t}){return e?(0,D.jsx)(`span`,{className:`inline-flex cursor-help`,"data-hint":e,"data-hint-always":``,children:t}):t}function k({open:e,onClose:t,onListChanged:s}){let[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(null),[y,b]=(0,v.useState)(``),[x,S]=(0,v.useState)(``),[k,A]=(0,v.useState)(``),[j,M]=(0,v.useState)(``),[N,P]=(0,v.useState)(``),[F,I]=(0,v.useState)(null),[L,ue]=(0,v.useState)(``),[R,z]=(0,v.useState)(null),[B,V]=(0,v.useState)(null),[H,U]=(0,v.useState)(``),[W,G]=(0,v.useState)([]),[de,K]=(0,v.useState)({}),fe=(0,v.useRef)(null),pe=(0,v.useRef)(null),q=(0,v.useRef)(null),[J,me]=(0,v.useState)(!1),Y=(0,v.useCallback)(async(e=!1)=>{e&&g(`stats`);let t=await ee({stats:e});e&&g(null),t?(m(t),s?.(t)):b(`无法读取数据空间列表(本地服务未运行?)`)},[s]),he=(0,v.useRef)(Y);(0,v.useEffect)(()=>{he.current=Y},[Y]);function X(){q.current?.abort()}(0,v.useEffect)(()=>{e?(b(``),S(``),P(``),he.current(!1)):X()},[e]),(0,v.useLayoutEffect)(()=>{let e=pe.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,96)}px`)},[j,e]);async function ge(){if(J||h!==null)return;let e=j.trim();if(!e){b(_(`space.promptNeedReq`));return}b(``);let t=new AbortController;q.current=t,me(!0);try{await r();let n=o();if(!n?.apiKey?.trim()||!n.model?.trim()||!n.baseURL?.trim()){b(_(`space.promptNeedModel`));return}let a=k.trim(),s=await i(n,[{role:`system`,content:se},{role:`user`,content:(a?`空间名称:${a}\n\n`:``)+`用户要求:\n${e}`}],t.signal);if(t.signal.aborted)return;let c=ce(s);if(!c){b(_(`space.promptGenEmpty`));return}P(c)}catch(e){if(le(e)||t.signal.aborted)return;b(e instanceof Error?e.message:String(e))}finally{q.current===t&&(q.current=null),me(!1)}}async function Z(e){if(h!==null)return!1;let t=k.trim();if(!t)return b(_(`space.needName`)),!1;X();let r=N.trim();g(`create`),b(``);let i=await C(t,{switch:!0,...r?{systemPrompt:r}:{}});if(g(null),!i.ok)return b(i.error||_(`space.create`)+` 失败`),!1;let a=i.space?.id;return a&&n(a),window.location.reload(),!0}async function _e(){if($)return;let e=k.trim(),n=j.trim();!e&&!n?t():await Z({closeAfter:!0})}async function ve(){if(!F)return;let e=L.trim();if(!e)return;g(`rename`),b(``);let t=await te(F.id,e);g(null),t.ok?(I(null),await Y(!1)):b(t.error||`重命名失败`)}async function ye(){if(!B)return;let e=H.trim();if(!e)return;g(`copy`),b(``);let t=await ne(B.id,e);g(null),t.ok?(V(null),S(`已复制为「${t.space?.name}」`),await Y(!1)):b(t.error||`复制失败`)}async function be(e,t){g(`delete`),b(``);let r=await re(e.id,t);g(null),r.ok?(z(null),e.isActive?(n(`public`),window.location.reload()):(S(r.purged?`已删除「${e.name}」及其数据`:`已从列表移除「${e.name}」(数据保留在磁盘)`),await Y(!1))):b(r.error||`删除失败`)}async function xe(){g(`discover`),b(``),S(``),G([]);let e=await w();if(g(null),!e.ok){b(e.error||`扫描失败`);return}let t=e.added?.length??0,n=e.backfilled?.length??0,r=e.skipped?.length??0,i=e.candidates??[],a=[];t?a.push(_(`space.discoverAdded`,{n:t})):i.length||a.push(_(`space.discoverNone`)),n&&a.push(_(`space.discoverBackfilled`,{n})),r&&a.push(_(`space.discoverSkipped`,{n:r})),S(a.join(`;`)),G(i),K(Object.fromEntries(i.map(e=>[e.path,e.hasContent===!0]))),await Y(!1)}async function Se(){let e=W.filter(e=>de[e.path]).map(e=>e.path);if(!e.length){G([]),S(_(`space.candidatesIgnored`));return}g(`discover`),b(``);let t=await w(e);if(g(null),!t.ok){b(t.error||`纳入失败`);return}G([]);let n=t.added?.length??0,r=t.skipped??[],i=[n?_(`space.candidatesAdopted`,{n}):_(`space.candidatesIgnored`)];r.length&&i.push(_(`space.candidatesRejected`,{names:r.map(e=>e.reason).join(`、`)})),S(i.join(`;`)),await Y(!1)}async function Ce(e){let t=e.target.files?.[0];if(e.target.value=``,!t)return;g(`import`),b(``);let n=await ae(t);g(null),n.ok?(S(`已导入为「${n.space?.name}」`),await Y(!1)):b(n.error||`导入失败`)}let we=p?.spaces??[],Q=p?.baseRoot,$=h!==null,Te=!!j.trim()&&!$&&!J;return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(l,{open:e,onClose:t,transition:!0,className:`relative z-95`,children:[(0,D.jsx)(u,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,D.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,D.jsxs)(c,{transition:!0,className:`tw-dialog-panel-anim tw-space-dialog w-full max-w-3xl rounded-xl shadow-xl border border-stone-200 bg-white flex flex-col max-h-[86vh]`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-5 pt-4 pb-3 border-b border-stone-200`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(d,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:_(`space.manageTitle`)}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-stone-500 leading-relaxed`,children:_(`space.manageDesc`)})]}),(0,D.jsx)(`button`,{type:`button`,onClick:t,className:`tw-confirm-cancel shrink-0 w-7 h-7 flex items-center justify-center rounded-md text-stone-400 hover:bg-stone-100 hover:text-stone-700 transition-colors`,"aria-label":`关闭`,children:`✕`})]}),(0,D.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4`,children:[(0,D.jsxs)(`div`,{className:`mb-5`,children:[(0,D.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-2`,children:_(`space.newTitle`)}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`input`,{value:k,onChange:e=>A(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),Z())},placeholder:_(`space.namePlaceholder`),className:`flex-1 min-w-0 h-9 px-3 text-sm rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors`}),(0,D.jsx)(`button`,{type:`button`,disabled:!k.trim()||$,onClick:()=>void Z(),className:`h-9 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:h===`create`?`…`:_(`space.create`)}),(0,D.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>fe.current?.click(),className:`h-9 px-3 text-sm rounded-lg border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-40 transition-colors`,children:h===`import`?`…`:_(`space.import`)}),(0,D.jsx)(`input`,{ref:fe,type:`file`,accept:`.zip,application/zip`,className:`hidden`,onChange:e=>void Ce(e)})]}),p?(0,D.jsx)(`div`,{className:`mt-1.5 text-[11px] text-stone-400 truncate`,children:(0,D.jsx)(`code`,{children:E(p.dataRoot,p.baseRoot)})}):null,(0,D.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-stone-200`,children:[(0,D.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-1.5`,children:_(`space.promptBriefLabel`)}),(0,D.jsxs)(`div`,{className:`tw-space-prompt-composer pt-1 rounded-lg bg-white border border-stone-200 outline-none transition-colors focus-within:ring-2 focus-within:ring-[#4176e6]/30 focus-within:border-[#4176e6]`,children:[(0,D.jsx)(`textarea`,{ref:pe,value:j,onChange:e=>M(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing){if(e.preventDefault(),J){X();return}Te&&ge()}},placeholder:_(`space.promptBriefPlaceholder`),rows:1,disabled:$,className:`block w-full min-h-6 pl-3.5 pr-2 pt-0.5 pb-0 text-sm leading-5 text-stone-800 bg-transparent resize-none focus:outline-none placeholder:text-stone-400 disabled:opacity-60`}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-2 px-3 pb-2 pt-1`,children:[(0,D.jsx)(`span`,{className:`flex-1`}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>{J?X():ge()},disabled:!J&&!Te,"aria-label":_(J?`space.promptStop`:`space.promptGenerate`),className:`w-7 h-7 shrink-0 rounded-full flex items-center justify-center outline-none transition-colors ${J?`bg-stone-200 text-stone-700 hover:bg-stone-300`:`bg-[#4176e6] text-white hover:bg-[#3565c7] disabled:bg-[#a9c3ef] disabled:cursor-not-allowed`}`,children:J?(0,D.jsx)(`span`,{className:`w-2.5 h-2.5 bg-current rounded-xs`}):(0,D.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:`w-4 h-4`,"aria-hidden":!0,children:[(0,D.jsx)(`path`,{d:`m5 12 7-7 7 7`}),(0,D.jsx)(`path`,{d:`M12 19V5`})]})})]})]}),(0,D.jsxs)(`div`,{className:`mt-1.5 flex items-start gap-3`,children:[(0,D.jsx)(`p`,{className:`flex-1 min-w-0 text-[11px] text-stone-400 leading-snug`,children:_(`space.promptHint`)}),J?(0,D.jsxs)(`p`,{className:`tw-busy-status shrink-0`,"aria-live":`polite`,children:[_(`space.promptGeneratingStatus`),(0,D.jsx)(`span`,{className:`tw-busy-ellipsis`,"aria-hidden":!0})]}):null]}),(0,D.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2 mb-1.5`,children:[(0,D.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,children:_(`space.promptBodyLabel`)}),(0,D.jsx)(`span`,{className:`text-[11px] text-stone-400 font-mono truncate`,children:a})]}),(0,D.jsx)(`textarea`,{value:N,onChange:e=>P(e.target.value),placeholder:_(`space.promptBodyPlaceholder`),rows:6,disabled:$,className:`w-full min-h-30 px-3 py-2 text-sm leading-relaxed rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors resize-y font-[inherit]`})]})]}),y?(0,D.jsxs)(`div`,{className:`mb-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700 flex items-start gap-2`,children:[(0,D.jsx)(`span`,{className:`flex-1 min-w-0`,children:y}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>b(``),className:`shrink-0 w-5 h-5 -mr-0.5 flex items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,"aria-label":`关闭`,children:`✕`})]}):null,x?(0,D.jsxs)(`div`,{className:`mb-3 rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs text-emerald-700 flex items-start gap-2`,children:[(0,D.jsx)(`span`,{className:`flex-1 min-w-0`,children:x}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>S(``),className:`shrink-0 w-5 h-5 -mr-0.5 flex items-center justify-center rounded text-emerald-700/70 hover:bg-emerald-100 hover:text-emerald-900`,"aria-label":`关闭`,children:`✕`})]}):null,W.length?(0,D.jsxs)(`div`,{className:`mb-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2.5`,children:[(0,D.jsx)(`div`,{className:`text-xs font-medium text-amber-800`,children:_(`space.candidatesTitle`,{n:W.length})}),(0,D.jsx)(`p`,{className:`mt-1 text-[11px] leading-snug text-amber-700/90`,children:_(`space.candidatesHint`)}),(0,D.jsx)(`div`,{className:`mt-2 max-h-44 overflow-auto rounded-md border border-amber-200/70 bg-white divide-y divide-stone-100`,children:W.map(e=>(0,D.jsxs)(`label`,{className:`flex items-start gap-2 px-2.5 py-1.5 cursor-pointer hover:bg-stone-50`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:de[e.path]===!0,onChange:t=>K(n=>({...n,[e.path]:t.target.checked})),className:`mt-0.5 accent-[#4176e6]`}),(0,D.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(`span`,{className:`block text-xs text-stone-800 truncate`,children:e.name}),(0,D.jsx)(`span`,{className:`block text-[10px] text-stone-400 truncate font-mono`,children:Q?E(e.path,Q):e.path})]})]},e.path))}),(0,D.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>K(Object.fromEntries(W.map(e=>[e.path,!0]))),className:`text-[11px] text-[#4176e6] hover:underline`,children:_(`space.candidatesSelectAll`)}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>K({}),className:`text-[11px] text-stone-500 hover:underline`,children:_(`space.candidatesClear`)}),(0,D.jsx)(`span`,{className:`flex-1`}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>{G([]),K({}),S(_(`space.candidatesIgnored`))},className:`px-2.5 py-1 text-[11px] rounded-md border border-stone-200 text-stone-600 hover:bg-stone-50`,children:_(`space.candidatesIgnore`)}),(0,D.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void Se(),className:`px-2.5 py-1 text-[11px] rounded-md bg-[#4176e6] text-white hover:bg-[#3565c7] disabled:opacity-40`,children:_(`space.candidatesAdopt`)})]})]}):null,(0,D.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,D.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:_(`space.listTitle`)}),(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void xe(),"data-hint":_(`space.discoverTitle`),"data-hint-always":``,className:`text-xs text-[#4176e6] hover:underline disabled:opacity-40`,children:_(h===`discover`?`space.discovering`:`space.discover`)}),(0,D.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void Y(!0),"data-hint":_(`space.sizeTitle`),"data-hint-always":``,className:`text-xs text-[#4176e6] hover:underline disabled:opacity-40`,children:_(h===`stats`?`space.sizing`:`space.size`)})]})]}),(0,D.jsx)(`div`,{className:`rounded-lg border border-stone-200 divide-y divide-stone-100 overflow-hidden`,children:we.length===0?(0,D.jsx)(`div`,{className:`px-3 py-6 text-center text-xs text-stone-400`,children:_(`space.empty`)}):we.map(e=>(0,D.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5`,children:[(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-stone-800 truncate`,children:T(e)}),e.isPublic?(0,D.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-stone-100 text-stone-500`,children:_(`space.builtin`)}):null,e.isActive?(0,D.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-[#4176e6]/10 text-[#3565c7]`,children:_(`space.activeTag`)}):null,e.exists?null:(0,D.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-amber-50 text-amber-600`,children:_(`space.missing`)}),e.bytes==null?null:(0,D.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-stone-100 text-stone-500 tabular-nums`,children:oe(e.bytes)})]}),(0,D.jsx)(`div`,{className:`mt-0.5 text-[11px] text-stone-400 truncate cursor-help hover:text-stone-500`,"data-hint":Q?E(e.path,Q):e.path,"data-hint-always":``,children:Q?E(e.path,Q):e.path})]}),(0,D.jsxs)(`div`,{className:`shrink-0 flex flex-wrap justify-end items-center gap-1`,children:[(0,D.jsx)(O,{hint:e.removable?void 0:_(`space.publicLocked`),children:(0,D.jsx)(`button`,{type:`button`,disabled:!e.removable||$,onClick:()=>{I(e),ue(e.name)},className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-30 disabled:cursor-not-allowed disabled:pointer-events-none transition-colors`,children:_(`space.rename`)})}),(0,D.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>{V(e),U(`${e.name}-copy`)},className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:_(`space.copy`)}),(0,D.jsx)(`a`,{href:ie(e.id,`content`),"data-hint":_(`space.exportContentTitle`),"data-hint-always":``,className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 inline-flex items-center transition-colors`,children:_(`space.exportContent`)}),(0,D.jsx)(`a`,{href:ie(e.id,`full`),"data-hint":_(`space.exportFullTitle`),"data-hint-always":``,className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 inline-flex items-center transition-colors`,children:_(`space.exportFull`)}),(0,D.jsx)(O,{hint:e.removable?void 0:_(`space.publicLocked`),children:(0,D.jsx)(`button`,{type:`button`,disabled:!e.removable||$,onClick:()=>z({kind:`remove`,space:e}),className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-30 disabled:cursor-not-allowed disabled:pointer-events-none transition-colors`,children:_(`space.removeList`)})}),(0,D.jsx)(O,{hint:e.removable?void 0:_(`space.publicLocked`),children:(0,D.jsx)(`button`,{type:`button`,disabled:!e.removable||$,onClick:()=>z({kind:`delete`,space:e}),className:`h-7 px-2 text-xs rounded-md border border-red-200 text-red-600 hover:bg-red-50 disabled:opacity-30 disabled:cursor-not-allowed disabled:pointer-events-none transition-colors`,children:_(`space.deleteDisk`)})})]})]},e.id))})]}),(0,D.jsx)(`div`,{className:`flex justify-end gap-2 px-5 py-3 border-t border-stone-200`,children:(0,D.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void _e(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:h===`create`?`…`:_(`space.done`)})})]})})]}),(0,D.jsxs)(l,{open:F!==null,onClose:()=>I(null),transition:!0,className:`relative z-96`,children:[(0,D.jsx)(u,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,D.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,D.jsxs)(c,{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,D.jsx)(d,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:_(`space.rename`)}),(0,D.jsx)(`input`,{autoFocus:!0,value:L,onChange:e=>ue(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ve())},className:`mt-4 w-full h-9 px-3 text-sm rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors`}),(0,D.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>I(null),className:`tw-confirm-cancel h-8 px-3 text-sm rounded-lg border border-stone-200 text-stone-600 hover:bg-stone-100 transition-colors`,children:`取消`}),(0,D.jsx)(`button`,{type:`button`,disabled:!L.trim()||$,onClick:()=>void ve(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:h===`rename`?`…`:`确定`})]})]})})]}),(0,D.jsxs)(l,{open:B!==null,onClose:()=>V(null),transition:!0,className:`relative z-96`,children:[(0,D.jsx)(u,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,D.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,D.jsxs)(c,{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,D.jsx)(d,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:_(`space.confirmCopyTitle`)}),(0,D.jsx)(`p`,{className:`tw-confirm-msg mt-3 text-sm text-stone-600 leading-relaxed`,children:_(`space.confirmCopyMsg`,{name:B?.name??``})}),(0,D.jsxs)(`label`,{className:`mt-3 block text-xs font-medium text-stone-500`,children:[_(`space.copyName`),(0,D.jsx)(`input`,{autoFocus:!0,value:H,onChange:e=>U(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ye())},className:`mt-1.5 w-full h-9 px-3 text-sm rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors`})]}),(0,D.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>V(null),className:`tw-confirm-cancel h-8 px-3 text-sm rounded-lg border border-stone-200 text-stone-600 hover:bg-stone-100 transition-colors`,children:`取消`}),(0,D.jsx)(`button`,{type:`button`,disabled:!H.trim()||$,onClick:()=>void ye(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:h===`copy`?`…`:_(`space.copy`)})]})]})})]}),(0,D.jsx)(f,{open:R?.kind===`remove`,title:_(`space.confirmRemoveTitle`),message:R?.kind===`remove`?_(`space.confirmRemoveMsg`,{name:R.space.name,path:R.space.path}):``,confirmLabel:_(`space.removeList`),onClose:()=>z(null),onConfirm:()=>{R?.kind===`remove`&&be(R.space,!1)}}),(0,D.jsx)(f,{open:R?.kind===`delete`,title:_(`space.confirmDeleteTitle`),message:R?.kind===`delete`?_(`space.confirmDeleteMsg`,{name:R.space.name,path:R.space.path}):``,confirmLabel:_(`space.deleteDisk`),danger:`solid`,onClose:()=>z(null),onConfirm:()=>{R?.kind===`delete`&&be(R.space,!0)}})]})}var A=`tw.spaces.list.v1`;function j(){try{let e=sessionStorage.getItem(A);if(!e)return null;let t=JSON.parse(e);return t&&Array.isArray(t.spaces)?t:null}catch{return null}}function M(e){try{sessionStorage.setItem(A,JSON.stringify(e))}catch{}}function N(e){try{e?document.documentElement.dataset.spaceService=`none`:delete document.documentElement.dataset.spaceService}catch{}}function P(){let e=j(),[t,n]=(0,v.useState)(e!==null),[r,i]=(0,v.useState)(e!==null),[a,o]=(0,v.useState)(e),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(``);(0,v.useEffect)(()=>{let e=!0;return(async()=>{let t=await x();if(!e)return;if(i(!0),!t){n(!1),N(!0);return}N(!1),n(!0);let r=await ee();e&&r&&(o(r),M(r))})(),()=>{e=!1}},[]);async function y(e){if(e===a?.activeId)return;u(!0),f(``);let t=await S(e);t.ok?(a&&M({...a,activeId:e,spaces:a.spaces.map(t=>({...t,isActive:t.id===e}))}),window.location.reload()):(u(!1),f(t.error||`切换失败`))}if(!r)return null;if(!t)return(0,D.jsx)(`div`,{className:`tw-nav-space`,children:(0,D.jsxs)(`div`,{className:`tw-nav-space-btn tw-nav-space-btn--off`,children:[(0,D.jsx)(`span`,{className:`tw-nav-space-ico`,"aria-hidden":`true`,children:(0,D.jsx)(F,{})}),(0,D.jsxs)(`span`,{className:`tw-nav-space-text`,children:[(0,D.jsx)(`span`,{className:`tw-nav-space-cap`,children:_(`space.offlineCap`)}),(0,D.jsx)(`span`,{className:`tw-nav-space-name`,children:_(`space.offline`)})]})]})});let b=a?.spaces.find(e=>e.isActive),C=(a?.spaces??[]).filter(e=>!e.isActive);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`tw-nav-space`,children:(0,D.jsxs)(h,{as:`div`,className:`tw-nav-space-menu`,children:[(0,D.jsxs)(g,{className:`tw-nav-space-btn`,"data-hint":_(`space.label`),children:[(0,D.jsx)(`span`,{className:`tw-nav-space-ico`,"aria-hidden":`true`,children:(0,D.jsx)(F,{})}),(0,D.jsxs)(`span`,{className:`tw-nav-space-text`,children:[(0,D.jsx)(`span`,{className:`tw-nav-space-cap`,children:_(`space.current`)}),(0,D.jsx)(`span`,{className:`tw-nav-space-name`,children:l?_(`space.switching`):b?T(b):`—`})]}),(0,D.jsx)(`svg`,{className:`tw-nav-space-caret`,viewBox:`0 0 24 24`,width:`13`,height:`13`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,D.jsx)(`path`,{d:`m6 9 6 6 6-6`})})]}),(0,D.jsxs)(p,{transition:!0,anchor:{to:`bottom start`,gap:`0.375rem`},className:`tw-nav-space-pop tw-menu-anim`,children:[d?(0,D.jsx)(`div`,{className:`tw-nav-space-err`,role:`alert`,children:d}):null,(0,D.jsx)(`div`,{className:`tw-nav-space-group`,children:_(`space.others`)}),C.length===0?(0,D.jsx)(`p`,{className:`tw-nav-space-hint`,children:_(`space.othersEmpty`)}):C.map(e=>(0,D.jsx)(m,{children:(0,D.jsxs)(`button`,{type:`button`,className:`tw-nav-space-item`,disabled:l,onClick:()=>void y(e.id),children:[(0,D.jsx)(`span`,{className:`tw-nav-space-item-main`,children:(0,D.jsx)(`span`,{className:`tw-nav-space-item-name`,"data-hint":T(e),children:T(e)})}),(0,D.jsx)(`svg`,{className:`tw-nav-space-item-go`,viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,D.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]})},e.id)),(0,D.jsx)(`div`,{className:`tw-nav-space-sep`}),(0,D.jsx)(m,{children:(0,D.jsxs)(`button`,{type:`button`,className:`tw-nav-space-item tw-nav-space-item--manage`,onClick:()=>c(!0),children:[(0,D.jsx)(`span`,{className:`tw-nav-space-item-ico`,"aria-hidden":`true`,children:(0,D.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,D.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,D.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9c.2.6.7 1 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z`})]})}),(0,D.jsx)(`span`,{className:`tw-nav-space-item-main`,children:(0,D.jsx)(`span`,{className:`tw-nav-space-item-name`,children:_(`space.manage`)})}),(0,D.jsx)(`svg`,{className:`tw-nav-space-item-go`,viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,D.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]})})]})]})}),(0,D.jsx)(k,{open:s,onClose:()=>c(!1),onListChanged:e=>{o(e),M(e)}})]})}function F(){return(0,D.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`15`,height:`15`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`path`,{d:`M3 7.5 12 3l9 4.5-9 4.5-9-4.5Z`}),(0,D.jsx)(`path`,{d:`m3 12.5 9 4.5 9-4.5`}),(0,D.jsx)(`path`,{d:`m3 17 9 4.5 9-4.5`})]})}export{P as default};
@@ -1 +0,0 @@
1
- import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.CpjKWnzM.js";import{a as r,i,r as a,t as o}from"./ExcelFieldTags.B_XMwNNx.js";import{_ as s,a as c,c as ee,d as te,f as ne,g as l,h as u,i as re,l as ie,m as d,o as ae,p as oe,r as se,s as ce,u as f,v as le}from"./SelectDropdown.Dc7QaPbH.js";import{t as p}from"./jsx-runtime.BUXbF_vF.js";import{t as ue}from"./ConfirmDialog.BYz4HREM.js";import{a as de,o as fe,r as m}from"./plugins.CrpY8UI9.js";import{n as h,r as pe,t as me}from"./useListAnim.CnbC_9MC.js";import{t as g}from"./NamePromptDialog.DGBlDH_k.js";var _=e(t(),1),v=p(),he=5;async function ge(e){let t=e.name.toLowerCase();try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await d(`templates`,e.path);if(t.encoding===`base64`&&t.contentBase64)return r(t.contentBase64).headers}else if(t.endsWith(`.csv`)){let t=await u(`templates`,e.path);return a(t.content).headers}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await u(`templates`,e.path);return i(t.content).headers}}catch{}return[]}function y({className:e=`w-4 h-4`,open:t=!1}){return(0,v.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,v.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`}):(0,v.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 b({className:e=`w-3 h-3`}){return(0,v.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,v.jsx)(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z`}),(0,v.jsx)(`path`,{d:`m15 5 4 4`})]})}function x({className:e=`w-3 h-3`}){return(0,v.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,v.jsx)(`path`,{d:`M3 6h18`}),(0,v.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,v.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,v.jsx)(`path`,{d:`M10 11v6`}),(0,v.jsx)(`path`,{d:`M14 11v6`})]})}function S({node:e,depth:t,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o}){let s=r[e.path]??i,c=n===e.path;return(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,v.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.path),e.children.length&&a(e.path)},"aria-expanded":e.children.length?s:void 0,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${c?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,v.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,v.jsx)(y,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,v.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,v.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,v.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,v.jsx)(`div`,{className:`tw-collapse-inner`,children:e.children.map(e=>(0,v.jsx)(S,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function _e(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function C(){let[e,t]=(0,_.useState)(()=>m(`templates`)),[r,i]=(0,_.useState)(!1),[a,u]=(0,_.useState)(null),[d,p]=(0,_.useState)([]),[C,ve]=(0,_.useState)(0),[w,T]=(0,_.useState)(`.`),[E,D]=(0,_.useState)([]),[ye,be]=(0,_.useState)({}),[xe,O]=(0,_.useState)({}),[k,Se]=(0,_.useState)(!0),[A,j]=(0,_.useState)(null),[M,N]=(0,_.useState)(!1),[Ce,P]=(0,_.useState)(!1),[F,I]=(0,_.useState)(null),[L,R]=(0,_.useState)(null),[z,B]=(0,_.useState)(1),[V,we]=pe(he),[Te,H]=(0,_.useState)(null),U=(0,_.useRef)(null),{cls:Ee,play:W}=me(),G=(0,_.useCallback)(async e=>{let t={};await Promise.all(e.map(async e=>{let n=await ge(e);n.length&&(t[e.path]=n)})),be(t)},[]),K=(0,_.useCallback)(async()=>{let e=await ce(`templates`);p(e.tree),ve(e.totalFiles)},[]),q=(0,_.useCallback)(async(e=w)=>{j(null);try{let[t]=await Promise.all([f(`templates`,e),K()]);D(t.entries),T(t.path);let n=t.entries.filter(e=>e.type===`file`);await G(n)}catch(e){j(e instanceof Error?e.message:String(e))}},[w,G,K]);(0,_.useEffect)(()=>{let e=de(e=>t(!!e.templates));return n().then(()=>{t(m(`templates`)),i(!0)}),e},[]),(0,_.useEffect)(()=>{r&&e&&(async()=>{let e=await ae(`templates`);if(u(e),e)try{let[e]=await Promise.all([f(`templates`,`.`),K()]);D(e.entries),T(e.path),await G(e.entries.filter(e=>e.type===`file`))}catch(e){j(e instanceof Error?e.message:String(e))}})()},[r,e,G,K]);function De(){Se(e=>!e),O({})}async function J(e){W(),T(e),B(1),H(null),j(null);try{let t=await f(`templates`,e);D(t.entries),await G(t.entries.filter(e=>e.type===`file`))}catch(e){j(e instanceof Error?e.message:String(e))}}async function Oe(e){P(!1),N(!0),j(null);try{await te(`templates`,w,e),await q(w)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}async function ke(e){if(e?.length){N(!0),j(null);try{for(let t of Array.from(e))await le(`templates`,w,t);await q(w)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1),U.current&&(U.current.value=``)}}}async function Ae(e){if(e.type===`file`){N(!0),j(null);try{await ne(`templates`,e.path)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}function je(e){let t=ee(d,e.path),n=t?.fileCount??0,r=t?re(t):0;I({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function Me(e){I({name:e.name,path:e.path,isDir:!1})}function Y(e,t){R({...e,isDir:t})}async function Ne(){let e=F;if(e&&(I(null),!e.blocked)){N(!0),j(null);try{await c(`templates`,e.path);let t=ie(w,e.path)?oe(e.path):w;await q(t)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}async function Pe(e){let t=L;if(t&&(R(null),e!==t.name)){N(!0),j(null);try{let n=await s(`templates`,t.path,e);await q(l(w,t.path,n))}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}let Fe=(()=>{if(!F)return``;if(!F.isDir)return`删除文件「${F.name}」?将移入系统废纸篓,可随时找回。`;if(F.blocked){let e=[];return F.files&&e.push(`${F.files} 个文件`),F.dirs&&e.push(`${F.dirs} 个子文件夹`),`文件夹「${F.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${F.name}」?将移入系统废纸篓。`})();if(!r)return(0,v.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,v.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!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:fe(`templates`)});if(a===null)return(0,v.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,v.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!a)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:`模板库需要本地文档服务,当前未就绪。`});let X=E.filter(e=>e.type===`file`),Z=E.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/V)),$=Math.min(z,Q),Ie=X.slice(($-1)*V,$*V);function Le(e){W(),we(e),B(1)}return(0,v.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,v.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,v.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,v.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,v.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>P(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,v.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1`,children:[(0,v.jsx)(`div`,{className:`group flex items-center rounded-md ${w===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,v.jsxs)(`button`,{type:`button`,onClick:()=>{J(`.`),De()},"aria-expanded":k,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${w===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,v.jsx)(y,{open:k,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,v.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部模板`}),(0,v.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,C,`)`]})]})}),(0,v.jsx)(`div`,{className:`tw-collapse ${k?`is-open`:``}`,children:(0,v.jsx)(`div`,{className:`tw-collapse-inner`,children:d.map(e=>(0,v.jsx)(S,{node:e,depth:0,activePath:w,expanded:xe,globalOpen:k,onToggle:e=>O(t=>({...t,[e]:!(t[e]??k)})),onSelect:e=>void J(e)},e.path))})})]})]}),(0,v.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,v.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,v.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,v.jsx)(`span`,{className:`text-stone-400`,children:se(`templates`)}),w===`.`?``:w]}),(0,v.jsx)(`input`,{ref:U,type:`file`,multiple:!0,accept:`.md,.txt,.docx,.xlsx,.xls,.csv,text/plain,text/markdown,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,className:`hidden`,onChange:e=>void ke(e.target.files)}),(0,v.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>U.current?.click(),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,v.jsx)(`div`,{className:`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,v.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,v.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,v.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,v.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void J(e.path),children:[(0,v.jsx)(y,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,v.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,v.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!0),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,v.jsx)(b,{className:`w-3.5 h-3.5`})}),(0,v.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>je({name:e.name,path:e.path}),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,v.jsx)(x,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,v.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加模板(.md / .xlsx / .docx 等)`}):(0,v.jsx)(`ul`,{className:`${Ee}space-y-1`,children:Ie.map(e=>{let t=ye[e.path]??[],n=Te===e.path;return(0,v.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2 rounded-lg border transition-colors ${n?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,v.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,disabled:M,onClick:()=>H(e.path),onDoubleClick:()=>void Ae(e),children:[(0,v.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,v.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:_e(e.size)}),t.length>0?(0,v.jsx)(o,{fields:t}):null]}),(0,v.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40 shrink-0 mt-0.5`,children:(0,v.jsx)(b,{className:`w-3.5 h-3.5`})}),(0,v.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>Me(e),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40 shrink-0 mt-0.5`,children:(0,v.jsx)(x,{className:`w-3.5 h-3.5`})})]},e.path)})})]})]}),X.length>0?(0,v.jsx)(h,{page:$,totalPages:Q,pageSize:V,busy:M,onPage:e=>{W(),B(e)},onPageSize:Le}):null]}),(0,v.jsx)(g,{open:Ce,title:`新建文件夹`,onClose:()=>P(!1),onConfirm:e=>void Oe(e)}),(0,v.jsx)(g,{open:L!=null,title:L?.isDir?`重命名文件夹`:`重命名文件`,label:L?.isDir?`文件夹名称`:`文件名称`,initialValue:L?.name??``,lockExtension:L!=null&&!L.isDir,confirmLabel:`保存`,onClose:()=>R(null),onConfirm:e=>void Pe(e)}),(0,v.jsx)(ue,{open:F!=null,title:F?.blocked?`无法删除文件夹`:F?.isDir?`删除文件夹`:`删除模板`,message:Fe,confirmLabel:F?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!F?.blocked,hideCancel:!!F?.blocked,onClose:()=>I(null),onConfirm:()=>void Ne()})]})}export{C as default};
@@ -1 +0,0 @@
1
- var e=[{id:`functional`,label:`功能测试`,casesFolder:`功能测试`,templateFolder:`功能测试用例`},{id:`api`,label:`接口测试`,casesFolder:`接口测试`,templateFolder:`接口测试用例`},{id:`performance`,label:`性能测试`,casesFolder:`性能测试`,templateFolder:`性能测试用例`},{id:`automation`,label:`自动化测试`,casesFolder:`自动化测试`,templateFolder:`自动化测试用例`}];function t(){return`ct_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function n(e){let t=e.trim()||`未命名类型`;return{casesFolder:t,templateFolder:`${t}用例`}}function r(e){if(!e||typeof e!=`object`)return null;let r=e,i=String(r.label??``).trim();if(!i)return null;let a=String(r.id??``).trim()||t(),o=n(i);return{id:a,label:i,casesFolder:typeof r.casesFolder==`string`&&r.casesFolder.trim()?r.casesFolder.trim():o.casesFolder,templateFolder:typeof r.templateFolder==`string`&&r.templateFolder.trim()?r.templateFolder.trim():o.templateFolder}}function i(t){if(!Array.isArray(t))return e.map(e=>({...e}));let n=[],i=new Set;for(let e of t){let t=r(e);t&&!i.has(t.id)&&(i.add(t.id),n.push(t))}return n.length?n:e.map(e=>({...e}))}function a(){return t()}var o=[`测试规范`,`方法论`,`环境约定`];function s(e){if(!Array.isArray(e))return[...o];let t=[],n=new Set;for(let r of e){let e=String(r??``).trim();!e||e.length>40||n.has(e)||(n.add(e),t.push(e))}return t.length?t:[...o]}var c=[{id:`case`,label:`用例生成提示词`,hint:`用于编写「用例生成」提示词:指导模型按需求与模板输出可入库用例;须约束 JSON 结构、字段对齐模板、步骤换行与覆盖策略,不要限定固定用例条数。`},{id:`general`,label:`通用提示词`,hint:`用于编写通用测试/工作台提示词:角色、输出风格与约束清晰,可直接作为系统或任务提示词使用。`}];function l(){return`pk_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function u(e){return`生成「${e.trim()||`自定义`}」类提示词:角色、输出风格与约束清晰,可直接作为系统或任务提示词使用。`}function ee(e){if(!e||typeof e!=`object`)return null;let t=e,n=String(t.label??``).trim();if(!n)return null;let r=String(t.id??``).trim()||l(),i=typeof t.hint==`string`&&t.hint.trim()?t.hint.trim():u(n);return r===`case`&&i.includes(`「测试用例生成」`)&&(i=c[0].hint),{id:r,label:n,hint:i}}function d(e){if(!Array.isArray(e))return c.map(e=>({...e}));let t=[],n=new Set;for(let r of e){let e=ee(r);e&&!n.has(e.id)&&(n.add(e.id),t.push(e))}return t.length?t:c.map(e=>({...e}))}function te(){return l()}var f=[{id:`cases`,href:`cases/library/`,i18n:`nav.caseManage`,plugin:`cases`,match:`cases`},{id:`prompts`,href:`prompts/`,i18n:`nav.prompts`,plugin:`prompts`,match:`prompts`},{id:`knowledgeLib`,href:`knowledge/`,i18n:`nav.knowledge`,plugin:`knowledgeLib`,match:`knowledge`},{id:`requirements`,href:`requirements/`,i18n:`nav.requirements`,plugin:`requirements`,match:`requirements`},{id:`templates`,href:`templates/`,i18n:`nav.templates`,plugin:`templates`,match:`templates`}],p=[],m=[`check`,`pencil`,`book`,`fileText`,`layers`,`list`,`folder`,`star`,`database`,`target`,`code`,`flask`,`home`,`clipboard`,`bug`,`calendar`,`chart`,`globe`,`link`,`users`,`terminal`,`tag`,`flag`,`zap`],h={cases:`check`,prompts:`pencil`,knowledgeLib:`book`,requirements:`fileText`,templates:`layers`};function ne(e){return typeof e==`string`&&m.includes(e)}function g(e){let t={...h};if(!e||typeof e!=`object`||Array.isArray(e))return t;for(let n of f){let r=e[n.id];ne(r)&&(t[n.id]=r)}return t}var re=new Set(f.map(e=>e.id));function _(e){return typeof e==`string`&&re.has(e)}function ie(e){return f.find(t=>t.id===e)}function v(e){return`item:${e}`}function y(e){return`group:${e}`}function b(){return`ng_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function ae(){return p.map(e=>({id:e.id,name:e.name,items:[...e.items]}))}function x(e,t=!0){if(e==null||!Array.isArray(e))return t?ae():[];let n=new Set,r=[],i=new Set;for(let t of e){if(!t||typeof t!=`object`)continue;let e=t,a=String(e.name??``).trim();if(!a)continue;let o=String(e.id??``).trim()||b();i.has(o)&&(o=b());let s=[];if(Array.isArray(e.items))for(let t of e.items)_(t)&&!n.has(t)&&(n.add(t),s.push(t));let c=String(e.parentId??``).trim()||void 0;i.add(o),r.push({id:o,name:a,items:s,parentId:c})}let a=new Set(r.map(e=>e.id)),o=r.map(e=>{let t=e.parentId;return(!t||t===e.id||!a.has(t))&&(t=void 0),t?{...e,parentId:t}:{id:e.id,name:e.name,items:e.items}}),s=new Map(o.map(e=>[e.id,e])),c=o.map(e=>{if(!e.parentId)return e;let t=s.get(e.parentId);if(t?.parentId){let n=t.parentId;return n&&n!==e.id&&a.has(n)?{...e,parentId:n}:{id:e.id,name:e.name,items:e.items}}return e}),l=new Set(c.map(e=>e.parentId).filter(e=>!!e));return c.filter(e=>e.items.length>0||l.has(e.id))}function S(e,t){let n=t.name.trim(),r=t.items.filter((e,t,n)=>_(e)&&n.indexOf(e)===t);if(!n||!r.length)return{groups:e,id:t.id?.trim()||``};let i=t.id?.trim()||b(),a=e.find(e=>e.id===i),o=t.parentId===void 0?a?.parentId:t.parentId.trim()||void 0;if(o===i&&(o=void 0),o){let t=e.find(e=>e.id===o);t?t.parentId&&(o=t.parentId):o=void 0}let s=new Set(r),c=e.filter(e=>e.id!==i).map(e=>({...e,items:e.items.filter(e=>!s.has(e))}));return c.push(o?{id:i,name:n,items:r,parentId:o}:{id:i,name:n,items:r}),{groups:x(c),id:i}}function C(e,t){return e.filter(e=>e.parentId===t).map(e=>e.id)}function w(e,t){return e.filter(e=>e.parentId===t)}function T(e,t){let n=e.find(e=>e.id===t);if(!n)return e;let r=e.filter(e=>e.id!==t);return n.parentId?r.map(e=>e.id===n.parentId?{...e,items:[...e.items,...n.items]}:e.parentId===t?{...e,parentId:n.parentId}:e):r.map(e=>e.parentId===t?{id:e.id,name:e.name,items:e.items}:e)}function E(e,t,n){let r=e.find(e=>e.id===t);return!r||!_(n)||r.items.includes(n)?e:S(e,{id:r.id,name:r.name,items:[...r.items,n]}).groups}function D(e,t){let n=e.find(e=>e.items.includes(t))??null;return n?{groups:e.map(e=>e.id===n.id?{...e,items:e.items.filter(e=>e!==t)}:e).filter(e=>e.items.length>0),owner:n}:{groups:e,owner:null}}function O(e,t,n,r){let i=v(t),a=y(n.id),o=r.some(e=>e.id===n.id),s=e.indexOf(a),c=e.filter(e=>e!==i&&(o||e!==a)),l=s<0?c.length:o?s+1:s;return c.splice(l,0,i),A(c,r)}function oe(e){let t=new Map(e.map(e=>[e.id,e])),n=new Map;for(let r of e){let e=r.parentId?t.get(r.parentId)??r:r;for(let t of r.items)n.set(t,e)}let r=new Set,i=[];for(let e of f){let t=n.get(e.id);if(t){if(r.has(t.id))continue;r.add(t.id),i.push({type:`group`,group:t})}else i.push({type:`item`,id:e.id})}return i}function k(e){return oe(e).map(e=>e.type===`item`?v(e.id):y(e.group.id))}function se(e){let t=new Set,n=new Set;for(let r of e){r.parentId||n.add(y(r.id));for(let e of r.items)t.add(e)}for(let e of f)t.has(e.id)||n.add(v(e.id));return n}function A(e,t){let n=se(t),r=[],i=new Set;if(Array.isArray(e))for(let t of e)typeof t==`string`&&n.has(t)&&!i.has(t)&&(i.add(t),r.push(t));for(let e of k(t))i.has(e)||r.push(e);return r}function ce(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Set(e.flatMap(e=>e.items)),i=A(t,e),a=[];for(let e of i)if(e.startsWith(`group:`)){let t=n.get(e.slice(6));t&&a.push({type:`group`,group:t})}else if(e.startsWith(`item:`)){let t=e.slice(5);_(t)&&!r.has(t)&&a.push({type:`item`,id:t})}return a}function le(e,t,n){let r=t.find(e=>e.id===n);if(!r)return A(e,t);let i=new Set(r.items.map(e=>v(e))),a=y(n),o=[...e],s=o.length;for(let e=0;e<o.length;e++){let t=o[e];if(t===a||i.has(t)){s=o.slice(0,e).filter(e=>e!==a&&!i.has(e)).length;break}}let c=o.filter(e=>e!==a&&!i.has(e));return c.splice(s,0,a),A(c,t)}function ue(e,t,n,r=[]){if(t.parentId)return A(e,n);let i=y(t.id),a=[...r.map(e=>y(e)),...t.items.map(e=>v(e))],o=e.filter(e=>e!==i);return o.push(...a),A(o,n)}function de(e,t,n){let r=e.indexOf(t),i=e.indexOf(n);if(r<0||i<0||r===i)return[...e];let a=[...e],[o]=a.splice(r,1);return o===void 0?[...e]:(a.splice(i,0,o),a)}var j=`tw.space.active-id`,fe=`tw.spaces.list.v1`;function M(e,t){try{return(e===`local`?localStorage:sessionStorage).getItem(t)?.trim()||``}catch{return``}}function N(e,t,n){try{(e===`local`?localStorage:sessionStorage).setItem(t,n)}catch{}}function pe(e){let t=String(e||``).trim();t&&(N(`session`,j,t),N(`local`,j,t))}function P(){let e=M(`session`,j);if(e)return e;let t=M(`local`,j);if(t)return t;try{let e=sessionStorage.getItem(fe);if(!e)return``;let t=JSON.parse(e);return String(t?.activeId||``).trim()}catch{return``}}function F(e){let t=P();return t?`${e}::${t}`:e}var I=`/__tb_config`,L=`tw.app.config.v1`,R=`tw.app.apikey.v1`,z=`tw.app.model.v1`,B=!1,V=null,H=``,U=!1,me={language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``};function W(){return`p_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function he(e){if(!e||typeof e!=`object`)return null;let t=String(e.name??``).trim()||`未命名提供商`,n=String(e.baseURL??``).trim(),r=String(e.model??``).trim();return{id:String(e.id??``).trim()||W(),name:t,baseURL:n,model:r,apiKey:typeof e.apiKey==`string`&&e.apiKey.trim()?e.apiKey.trim():void 0,availableModels:Array.isArray(e.availableModels)?e.availableModels.filter(e=>typeof e==`string`):void 0}}function ge(e){let t=typeof e.baseURL==`string`?e.baseURL.trim():``,n=typeof e.model==`string`?e.model.trim():``;return!t&&!n&&!e.apiKey?[]:[{id:W(),name:`默认`,baseURL:t||`https://api.deepseek.com/v1`,model:n,apiKey:typeof e.apiKey==`string`&&e.apiKey.trim()?e.apiKey.trim():void 0,availableModels:Array.isArray(e.availableModels)?e.availableModels.filter(e=>typeof e==`string`):void 0}]}function G(e){let t=e?.reasoningEffort===`low`||e?.reasoningEffort===`high`||e?.reasoningEffort===`max`?e.reasoningEffort:`high`,n=[];Array.isArray(e?.providers)&&e.providers.length?n=e.providers.map(e=>he(e)).filter(e=>!!e):e&&(e.baseURL||e.model||e.apiKey)&&(n=ge(e));let r=typeof e?.activeId==`string`?e.activeId:``;return n.length&&!n.some(e=>e.id===r)&&(r=n[0].id),n.length||(r=``),{activeId:r,reasoningEffort:t,providers:n}}function K(){return{version:1,model:{activeId:``,reasoningEffort:`high`,providers:[]},access:`readonly`,general:{...me},plugins:{cases:!1,caseGen:!1,prompts:!1,promptGen:!1,knowledgeLib:!1,knowledgeGen:!1,requirements:!1,templates:!1,knowledge:!1,memory:!1,pluginDev:!1},caseTypes:e.map(e=>({...e})),promptKinds:c.map(e=>({...e})),knowledgeCategories:[...o],navGroups:p.map(e=>({...e,items:[...e.items]})),navIcons:{...h},navOrder:k(p)}}function q(e){let t=K();if(!e||typeof e!=`object`)return t;let n=e.general&&typeof e.general==`object`?e.general:{},r={...t.plugins,...e.plugins??{}},a=x(e.navGroups);return{version:typeof e.version==`number`?e.version:1,model:G(e.model),access:e.access===`readwrite`||e.access===`full`||e.access===`readonly`?e.access:`readonly`,general:{language:n.language===`en`?`en`:`zh-CN`,appearance:n.appearance===`light`||n.appearance===`dark`||n.appearance===`system`?n.appearance:`system`,sessionFontSize:typeof n.sessionFontSize==`number`&&n.sessionFontSize>=12&&n.sessionFontSize<=22?Math.round(n.sessionFontSize):14,toolStepDetail:n.toolStepDetail===`concise`||n.toolStepDetail===`standard`||n.toolStepDetail===`detailed`||n.toolStepDetail===`full`?n.toolStepDetail:`standard`,busySendBehavior:n.busySendBehavior===`interrupt`?`interrupt`:`queue`,subagentModel:typeof n.subagentModel==`string`?n.subagentModel.trim():``},plugins:r,caseTypes:i(e.caseTypes),promptKinds:d(e.promptKinds),knowledgeCategories:s(e.knowledgeCategories),navGroups:a,navIcons:g(e.navIcons),navOrder:A(e.navOrder,a)}}function _e(){try{let e=localStorage.getItem(z);if(e)return G(JSON.parse(e))}catch{}try{let e=localStorage.getItem(F(L));if(e){let t=JSON.parse(e);if(t?.model)return G(t.model)}}catch{}return null}function ve(e){try{localStorage.setItem(z,JSON.stringify(e))}catch{}}function J(){try{let e=localStorage.getItem(F(L)),t=_e();if(!e)return t?q({...K(),model:t}):null;let n=q(JSON.parse(e));return t&&(n.model=t),n}catch{return null}}function Y(e){try{let{model:t,...n}=e;localStorage.setItem(F(L),JSON.stringify(n)),ve(t)}catch{}}function ye(){try{return localStorage.getItem(R)?.trim()||localStorage.getItem(F(R))?.trim()||``}catch{return``}}function be(e){try{e?localStorage.setItem(R,e):localStorage.removeItem(R),localStorage.removeItem(F(R))}catch{}}function xe(){try{let e=K(),t=!1,n=localStorage.getItem(`tw-llm-settings`);if(n){let r=JSON.parse(n);e.model=G({providers:[{id:W(),name:r.name||`默认`,baseURL:r.baseURL||``,model:r.model||``,apiKey:r.apiKey,availableModels:r.availableModels}],reasoningEffort:r.reasoningEffort}),e.model.providers[0]&&(e.model.activeId=e.model.providers[0].id),t=!0}let r=localStorage.getItem(`tw-access-level`);(r===`readonly`||r===`readwrite`||r===`full`)&&(e.access=r,t=!0);let i=localStorage.getItem(`tw.general.prefs.v1`);i&&(e.general=q({general:JSON.parse(i)}).general,t=!0);let a=localStorage.getItem(`tw.plugins.enabled.v1`);if(a){let n=JSON.parse(a);e.plugins={...e.plugins,...n},t=!0}return t?e:null}catch{return null}}function X(e){let t=e.model.providers;return t.length?t.find(t=>t.id===e.model.activeId)??t[0]??null:null}function Se(){return B}function Z(){return V||Ce(),V??K()}function Ce(){if(!U&&(U=!0,typeof window<`u`))try{let e=J();e&&(V=e)}catch{}}function we(){return H}function Te(){return[...V?.model.providers??[]]}async function Ee(){try{let e=await fetch(I,{signal:AbortSignal.timeout(2e3)});if(e.ok){let t=await e.json();V=q(t.config);let n=X(V),r=String(t.apiKey??``).trim();return H=r||n?.apiKey?.trim()||``,r&&n&&!n.apiKey&&(H=r),B=!0,Y(V),V}}catch{}B=!1;let e=J();return e||=xe()??K(),V=e,H=X(e)?.apiKey?.trim()||ye(),Y(V),V}var Q=null;async function $(e){if(Y(e),B)try{await fetch(I,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({config:e})})}catch{}}function De(e){let t=V??K(),n=q({...t,...e,model:e.model?{...t.model,...e.model,providers:e.model.providers??t.model.providers}:t.model,general:{...t.general,...e.general??{}},plugins:{...t.plugins,...e.plugins??{}},caseTypes:e.caseTypes??t.caseTypes,promptKinds:e.promptKinds??t.promptKinds,knowledgeCategories:e.knowledgeCategories??t.knowledgeCategories,navGroups:e.navGroups??t.navGroups,navIcons:e.navIcons??t.navIcons,navOrder:e.navOrder??t.navOrder});return V=n,H=X(n)?.apiKey?.trim()||``,Q&&clearTimeout(Q),Q=setTimeout(()=>{Q=null,$(n)},280),n}function Oe(){return Q&&=(clearTimeout(Q),null),$(V??K())}function ke(e){if(H=e.trim(),B||be(H),!V)return;let t=V.model.providers.map(e=>e.id===V.model.activeId?{...e,apiKey:H||void 0}:e);V=q({...V,model:{...V.model,providers:t}})}function Ae(){let e=V;if(!e)return null;let t=X(e);if(!t?.baseURL?.trim()||!t.model?.trim())return null;let n=(t.apiKey||H).trim();return n?{baseURL:t.baseURL.trim(),apiKey:n,model:t.model.trim(),reasoningEffort:e.model.reasoningEffort,availableModels:t.availableModels}:null}function je(){return W()}export{D as A,e as B,w as C,O as D,A as E,u as F,a as H,te as I,d as L,de as M,S as N,ue as O,c as P,o as R,v as S,g as T,i as U,n as V,E as _,Se as a,ie as b,ke as c,P as d,pe as f,m as g,f as h,Ee as i,T as j,le as k,Ae as l,h as m,we as n,Te as o,F as p,Z as r,je as s,Oe as t,De as u,ce as v,x as w,y as x,C as y,s as z};
@@ -1,7 +0,0 @@
1
- import{a as e}from"./react-dom.CqAxpHMt.js";import{s as t}from"./settings.BoQ0e0m1.js";var n=e({applyDomI18n:()=>o,t:()=>a}),r={"nav.home":`我的工作台`,"nav.requirements":`需求文档库`,"nav.caseManage":`用例管理`,"nav.cases":`用例`,"nav.templates":`测试模板库`,"nav.docs":`文档库`,"nav.createGroup":`创建分组`,"nav.createSubgroup":`创建子分组`,"nav.assignGroup":`选择分组`,"nav.more":`更多操作`,"nav.groupActions":`分组操作`,"nav.addSubgroup":`添加子分组`,"nav.addToGroup":`添加到分组`,"nav.chooseIcon":`选择图标`,"nav.leaveGroup":`取消分组`,"nav.currentGroup":`当前`,"nav.noGroups":`还没有分组`,"nav.noAddableItems":`没有可添加的菜单项`,"nav.editGroup":`编辑`,"nav.editGroupTitle":`编辑分组`,"nav.sortMenu":`排序`,"nav.sortMenuTitle":`菜单排序`,"nav.sortHint":`按住拖动调整顺序`,"nav.sortUp":`上移`,"nav.sortDown":`下移`,"nav.done":`完成`,"nav.deleteGroup":`删除分组`,"nav.deleteGroupMsg":`删除分组后,其中的菜单项会在菜单栏平铺显示。`,"nav.deleteSubgroupMsg":`删除子分组后,其中的菜单项会回到上级分组。`,"nav.groupName":`分组名称`,"nav.groupItems":`选择菜单项`,"nav.groupItemsHint":`已加入其他分组的菜单不会列出。`,"nav.groupNameRequired":`请填写分组名称`,"nav.groupItemsRequired":`请至少选择一项`,"nav.groupSave":`保存`,"nav.groupCancel":`取消`,"nav.prompts":`提示词管理`,"nav.knowledge":`知识库管理`,"nav.plugins":`我的插件`,"nav.brand":`Lantern Harness`,"nav.settings":`设置`,"nav.changelog":`变更日志`,"nav.changelogShort":`版本日志`,"nav.helpCenter":`帮助中心`,"docs.nav.title":`文档`,"docs.nav.changelog":`版本日志`,"docs.nav.manual":`操作手册`,"docs.nav.install":`安装手册`,"nav.repo":`GitHub 仓库`,"nav.repoShort":`仓库`,"nav.npm":`npm 包`,"nav.npmShort":`npm`,"nav.site":`炊烟小站`,"nav.siteShort":`小站`,"nav.board":`问题与建议`,"nav.boardShort":`问题与建议`,"space.label":`数据空间`,"space.current":`当前空间`,"space.switchTo":`切换到该空间`,"space.manage":`管理空间`,"space.others":`其他空间`,"space.manageTitle":`空间管理`,"space.manageDesc":`每个数据空间是一份相互隔离的数据目录:需求 / 用例 / 提示词 / 知识库 / 模板、会话与配置互不影响。`,"space.listTitle":`全部空间`,"space.newTitle":`新建空间`,"space.nameLabel":`空间名称`,"space.namePlaceholder":`输入空间名称`,"space.create":`新建`,"space.promptBriefLabel":`提示词要求`,"space.promptBriefPlaceholder":`描述这个空间里的助手应怎样工作,Enter 或点发送生成提示词;Shift+Enter 换行`,"space.promptGenerate":`生成提示词`,"space.promptGenerating":`生成中…`,"space.promptGeneratingStatus":`正在生成提示词`,"space.promptStop":`停止生成`,"space.promptBodyLabel":`默认提示词`,"space.promptBodyPlaceholder":`将写入该空间的 默认提示词.md`,"space.promptHint":`创建后写入该空间的提示词管理,作为默认提示词。`,"space.promptNeedReq":`请先填写提示词要求,再生成。`,"space.promptNeedBody":`请先填写默认提示词。`,"space.promptNeedModel":`请先在设置里配置可用的模型后再生成。`,"space.promptGenEmpty":`模型没有给出可用提示词,请重试或直接手写。`,"space.needName":`请先填写空间名称。`,"space.created":`已创建「{name}」`,"space.createdWithPrompt":`已创建「{name}」,默认提示词已写入该空间的提示词管理`,"space.name":`名称`,"space.location":`位置`,"space.size":`体积`,"space.sizeTitle":`统计各空间占用的磁盘大小`,"space.sizing":`统计中…`,"space.status":`状态`,"space.builtin":`默认`,"space.publicName":`公共空间`,"space.activeTag":`当前`,"space.missing":`目录不存在`,"space.rename":`重命名`,"space.copy":`复制`,"space.export":`导出`,"space.exportContent":`导出内容库`,"space.exportContentTitle":`不含密钥、会话、记忆与缓存,适合分享内容`,"space.exportFull":`导出备份`,"space.exportFullTitle":`含密钥、会话与全部本机状态,适合自己备份`,"space.discover":`扫描文件夹`,"space.discoverTitle":`扫描托管目录,纳入带 .lantern/space.json 清单的空间文件夹;其它文件夹列出来等你确认`,"space.discovering":`扫描中…`,"space.discoverAdded":`已纳入 {n} 个空间`,"space.discoverNone":`没有发现可纳入的空间文件夹`,"space.discoverBackfilled":`并为 {n} 个已有空间补写了 space.json 清单`,"space.discoverSkipped":`跳过 {n} 个(重名、名称非法或缺空间元数据)`,"space.candidatesTitle":`扫描到 {n} 个不是数据空间的文件夹,要纳入吗?`,"space.candidatesHint":`勾选后纳入列表;不会写入空间清单(.lantern/space.json),文件夹内容保持原样。`,"space.candidatesSelectAll":`全选`,"space.candidatesClear":`全不选`,"space.candidatesIgnore":`忽略`,"space.candidatesIgnored":`已忽略,未纳入任何文件夹`,"space.candidatesAdopt":`纳入所选`,"space.candidatesAdopted":`已纳入 {n} 个文件夹`,"space.candidatesRejected":`未纳入:{names}`,"space.removeList":`移出列表`,"space.deleteDisk":`删除数据`,"space.import":`导入`,"space.refresh":`刷新`,"space.empty":`还没有自定义空间,点「新建空间」开始。`,"space.newParentHint":`新建的空间会落在:`,"space.switching":`正在切换…`,"space.reloadHint":`切换后页面会自动重载。`,"space.confirmRemoveTitle":`移出列表`,"space.confirmRemoveMsg":`将从列表中移除「{name}」,磁盘数据保留在:
2
- {path}
3
- 之后可在管理界面重新纳入。`,"space.confirmDeleteTitle":`删除数据`,"space.confirmDeleteMsg":`将永久删除「{name}」及其全部数据,无法恢复:
4
- {path}`,"space.confirmCopyTitle":`复制空间`,"space.confirmCopyMsg":`将复制「{name}」的全部内容到新空间,文件较多时可能耗时较久。`,"space.done":`完成`,"space.copyName":`副本名称`,"space.importPick":`选择要导入的 zip 备份`,"space.othersEmpty":`还没有其他空间。可点下方「管理空间」新建或导入。`,"space.busyRuns":`仍有会话在运行,请先停止后再切换空间。`,"space.publicLocked":`公共空间不支持重命名或删除。`,"space.offline":`工作区不可用`,"space.offlineCap":`未连接本地服务`,"settings.general":`通用设置`,"settings.model":`模型`,"settings.close":`关闭`,"settings.access":`权限`,"settings.accessDesc":`选择新会话的默认权限模式`,"settings.language":`语言`,"settings.appearance":`外观`,"settings.appear.light":`浅色`,"settings.appear.dark":`深色`,"settings.appear.system":`跟随系统`,"settings.fontSize":`字号大小`,"settings.fontSizeDesc":`调整正文与会话内容的字号(不影响侧栏布局)`,"settings.toolSteps":`工作步骤展示`,"settings.toolStepsDesc":`选择希望看到多少工具调用细节`,"settings.busySend":`繁忙时的发送行为`,"settings.busySendDesc":`智能体运行时 Enter 键和发送按钮的行为;Cmd/Ctrl+Enter 使用另一行为`,"settings.busySend.queue":`排队发送`,"settings.busySend.interrupt":`插话发送`,"settings.subagentModel":`子代理模型`,"settings.subagentModelDesc":`子代理默认跟随主会话模型;可改为当前提供商下的其它模型`,"settings.subagentModel.inherit":`跟随主会话`,"settings.platformVersion":`平台版本`,"settings.access.readonly":`仅可查看`,"settings.access.readwrite":`工作区内修改`,"settings.access.full":`完全权限`,"settings.step.concise":`简洁`,"settings.step.standard":`标准`,"settings.step.detailed":`详细`,"settings.step.full":`完全展开`,"settings.modelIntro":`填入各提供商的 API 密钥即可使用其模型。`,"settings.edit":`编辑`,"settings.delete":`删除`,"settings.addProvider":`+ 添加模型提供商`,"settings.back":`返回`,"settings.editProvider":`编辑提供商`,"settings.addProviderTitle":`添加提供商`,"settings.cancel":`取消`,"settings.save":`保存`,"settings.displayName":`显示名称`,"settings.preset":`服务商预设`,"settings.baseUrl":`Base URL`,"settings.apiKey":`API Key`,"settings.modelField":`模型`,"settings.keyHint":`模型保存在本机 ~/.config/lantern-harness/models.json,所有空间共用,不会上传 GitHub。`,"settings.modelPlaceholder":`请输入模型名`,"settings.recognizing":`识别中…`,"settings.recognized":`已识别 {n} 个`,"settings.recognizeFail":`识别失败,可手动填模型名`,"settings.recognizeKeep":`刷新失败,沿用已有列表`,"settings.deleteConfirm":`确定删除该模型提供商?`,"chat.emptyTitle":`提灯的人不问路`,"chat.emptyNoModel":`使用前请先配置模型。`,"chat.configureModel":`配置模型`,"chat.workbench":`我的工作台`,"chat.newSession":`新会话`,"chat.workspace":`工作区`,"tool.running":`工具执行中…`,"tool.callingKind":`正在调用{kind}`,"tool.doneKind":`{kind}完成`,"tool.callingNamed":`正在调用{kind}:{name}`,"tool.doneNamed":`{kind}完成:{name}`,"tool.callingFull":`正在调用{kind}({name})…`,"tool.doneFull":`{kind}已完成({name})`,"tool.kind.kb":`知识库`,"tool.kind.fs":`本地文件`,"tool.kind.memory":`会话记忆`,"tool.kind.webSearch":`网页搜索`,"tool.kind.webFetch":`网页获取`},i={"zh-CN":r,en:{"nav.home":`My Workbench`,"nav.requirements":`Requirements`,"nav.caseManage":`Test Cases`,"nav.cases":`Cases`,"nav.templates":`Test Templates`,"nav.docs":`Documents`,"nav.createGroup":`New group`,"nav.createSubgroup":`New subgroup`,"nav.assignGroup":`Choose group`,"nav.more":`More actions`,"nav.groupActions":`Group actions`,"nav.addSubgroup":`Add subgroup`,"nav.addToGroup":`Add to group`,"nav.chooseIcon":`Choose icon`,"nav.leaveGroup":`Leave group`,"nav.currentGroup":`Current`,"nav.noGroups":`No groups yet`,"nav.noAddableItems":`Nothing to add`,"nav.editGroup":`Edit`,"nav.editGroupTitle":`Edit group`,"nav.sortMenu":`Sort`,"nav.sortMenuTitle":`Sort menu`,"nav.sortHint":`Drag to reorder`,"nav.sortUp":`Move up`,"nav.sortDown":`Move down`,"nav.done":`Done`,"nav.deleteGroup":`Delete group`,"nav.deleteGroupMsg":`Items in this group will be shown flat in the menu.`,"nav.deleteSubgroupMsg":`Items in this subgroup will return to its parent group.`,"nav.groupName":`Group name`,"nav.groupItems":`Choose menu items`,"nav.groupItemsHint":`Items already in another group are hidden.`,"nav.groupNameRequired":`Enter a group name`,"nav.groupItemsRequired":`Select at least one item`,"nav.groupSave":`Save`,"nav.groupCancel":`Cancel`,"nav.prompts":`Prompts`,"nav.knowledge":`Knowledge Mgmt`,"nav.plugins":`My Plugins`,"nav.brand":`Lantern Harness`,"nav.settings":`Settings`,"nav.changelog":`Changelog`,"nav.changelogShort":`Changelog`,"nav.helpCenter":`Help Center`,"docs.nav.title":`Docs`,"docs.nav.changelog":`Changelog`,"docs.nav.manual":`User Guide`,"docs.nav.install":`Install Guide`,"nav.repo":`GitHub`,"nav.repoShort":`Repo`,"nav.npm":`npm package`,"nav.npmShort":`npm`,"nav.site":`Yycy Docs`,"nav.siteShort":`Site`,"nav.board":`Questions & suggestions`,"nav.boardShort":`Suggestions`,"space.label":`Data space`,"space.current":`Current space`,"space.switchTo":`Switch to this space`,"space.manage":`Manage spaces`,"space.others":`Other spaces`,"space.manageTitle":`Spaces`,"space.manageDesc":`Each data space is a fully isolated data directory: requirements, cases, prompts, knowledge, templates, sessions and config never leak across spaces.`,"space.listTitle":`All spaces`,"space.newTitle":`New space`,"space.nameLabel":`Space name`,"space.namePlaceholder":`Enter a space name`,"space.create":`Create`,"space.promptBriefLabel":`Prompt requirements`,"space.promptBriefPlaceholder":`Describe how the assistant should work. Enter or send to generate; Shift+Enter for a new line`,"space.promptGenerate":`Generate prompt`,"space.promptGenerating":`Generating…`,"space.promptGeneratingStatus":`Generating prompt`,"space.promptStop":`Stop generating`,"space.promptBodyLabel":`Default prompt`,"space.promptBodyPlaceholder":`Saved as 默认提示词.md in this space`,"space.promptHint":`Saved to this space’s Prompt management as the default prompt.`,"space.promptNeedReq":`Write prompt requirements before generating.`,"space.promptNeedBody":`Fill in the default prompt first.`,"space.promptNeedModel":`Configure a working model in Settings before generating.`,"space.promptGenEmpty":`The model returned an empty prompt. Retry, or write one yourself.`,"space.needName":`Enter a space name first.`,"space.created":`Created "{name}"`,"space.createdWithPrompt":`Created "{name}". The default prompt is in Prompt management.`,"space.name":`Name`,"space.location":`Location`,"space.size":`Size`,"space.sizeTitle":`Measure disk usage for each space`,"space.sizing":`Measuring…`,"space.status":`Status`,"space.builtin":`Default`,"space.publicName":`Public space`,"space.activeTag":`Active`,"space.missing":`Directory missing`,"space.rename":`Rename`,"space.copy":`Copy`,"space.export":`Export`,"space.exportContent":`Export content`,"space.exportContentTitle":`Excludes keys, sessions, memories and caches — safe to share`,"space.exportFull":`Export backup`,"space.exportFullTitle":`Includes keys, sessions and all local state — for your own backup`,"space.discover":`Scan folder`,"space.discoverTitle":`Scan the managed folder for space folders carrying a .lantern/space.json manifest; other folders are listed for your confirmation`,"space.discovering":`Scanning…`,"space.discoverAdded":`Adopted {n} space(s)`,"space.discoverNone":`No adoptable space folder found`,"space.discoverBackfilled":`Wrote space.json manifests for {n} existing space(s)`,"space.discoverSkipped":`Skipped {n} (name conflict, invalid name, or missing space metadata)`,"space.candidatesTitle":`Found {n} folder(s) that are not spaces. Adopt them?`,"space.candidatesHint":`Checked folders are added to the list. No space manifest (.lantern/space.json) is written; folder contents stay untouched.`,"space.candidatesSelectAll":`Select all`,"space.candidatesClear":`Select none`,"space.candidatesIgnore":`Ignore`,"space.candidatesIgnored":`Ignored — nothing was adopted`,"space.candidatesAdopt":`Adopt selected`,"space.candidatesAdopted":`Adopted {n} folder(s)`,"space.candidatesRejected":`Not adopted: {names}`,"space.removeList":`Unlist`,"space.deleteDisk":`Delete data`,"space.import":`Import`,"space.refresh":`Refresh`,"space.empty":`No custom space yet — click "New space" to start.`,"space.newParentHint":`New spaces are created under:`,"space.switching":`Switching…`,"space.reloadHint":`The page reloads automatically after switching.`,"space.confirmRemoveTitle":`Remove from list`,"space.confirmRemoveMsg":`This removes "{name}" from the list but keeps its data on disk:
5
- {path}
6
- It can be added back later.`,"space.confirmDeleteTitle":`Delete data`,"space.confirmDeleteMsg":`This permanently deletes "{name}" and all of its data, with no way to undo:
7
- {path}`,"space.confirmCopyTitle":`Copy space`,"space.confirmCopyMsg":`All content of "{name}" will be copied into a new space. This can take a while for large spaces.`,"space.done":`Done`,"space.copyName":`New copy name`,"space.importPick":`Choose a zip backup to import`,"space.othersEmpty":`No other spaces yet. Open Manage spaces below to create or import one.`,"space.busyRuns":`A session is still running. Stop it before switching spaces.`,"space.publicLocked":`The built-in public space cannot be renamed or deleted.`,"space.offline":`Workspace unavailable`,"space.offlineCap":`Local service offline`,"settings.general":`General`,"settings.model":`Models`,"settings.close":`Close`,"settings.access":`Permissions`,"settings.accessDesc":`Default permission mode for new sessions`,"settings.language":`Language`,"settings.appearance":`Appearance`,"settings.appear.light":`Light`,"settings.appear.dark":`Dark`,"settings.appear.system":`System`,"settings.fontSize":`Font size`,"settings.fontSizeDesc":`Body and session text size (sidebar layout stays fixed)`,"settings.toolSteps":`Tool step detail`,"settings.toolStepsDesc":`How much tool-call detail to show`,"settings.busySend":`Send while busy`,"settings.busySendDesc":`Enter / Send while the agent is running; Cmd/Ctrl+Enter uses the other action`,"settings.busySend.queue":`Queue`,"settings.busySend.interrupt":`Interrupt`,"settings.subagentModel":`Subagent model`,"settings.subagentModelDesc":`Subagents inherit the main chat model by default; pick another from the active provider`,"settings.subagentModel.inherit":`Follow main chat`,"settings.platformVersion":`Platform version`,"settings.access.readonly":`View only`,"settings.access.readwrite":`Edit in workspace`,"settings.access.full":`Full access`,"settings.step.concise":`Concise`,"settings.step.standard":`Standard`,"settings.step.detailed":`Detailed`,"settings.step.full":`Full`,"settings.modelIntro":`Add each provider’s API key to use its models.`,"settings.edit":`Edit`,"settings.delete":`Delete`,"settings.addProvider":`+ Add model provider`,"settings.back":`Back`,"settings.editProvider":`Edit provider`,"settings.addProviderTitle":`Add provider`,"settings.cancel":`Cancel`,"settings.save":`Save`,"settings.displayName":`Display name`,"settings.preset":`Provider preset`,"settings.baseUrl":`Base URL`,"settings.apiKey":`API Key`,"settings.modelField":`Model`,"settings.keyHint":`Models are saved in ~/.config/lantern-harness/models.json and shared across spaces; never pushed to GitHub.`,"settings.modelPlaceholder":`Enter model id`,"settings.recognizing":`Detecting…`,"settings.recognized":`{n} models found`,"settings.recognizeFail":`Detection failed — enter a model id manually`,"settings.recognizeKeep":`Refresh failed — keeping previous list`,"settings.deleteConfirm":`Delete this model provider?`,"chat.emptyTitle":`Those who carry the lantern do not ask the way.`,"chat.emptyNoModel":`Configure a model to get started.`,"chat.configureModel":`Configure model`,"chat.workbench":`My Workbench`,"chat.newSession":`New chat`,"chat.workspace":`Workspace`,"tool.running":`Running tool…`,"tool.callingKind":`Calling {kind}`,"tool.doneKind":`{kind} done`,"tool.callingNamed":`Calling {kind}: {name}`,"tool.doneNamed":`{kind} done: {name}`,"tool.callingFull":`Calling {kind} ({name})…`,"tool.doneFull":`{kind} finished ({name})`,"tool.kind.kb":`knowledge base`,"tool.kind.fs":`local files`,"tool.kind.memory":`memory`,"tool.kind.webSearch":`web search`,"tool.kind.webFetch":`web fetch`}};function a(e,n,r){let a=i[r??(typeof window<`u`?t().language:`zh-CN`)]?.[e]??i[`zh-CN`][e]??e;if(n)for(let[e,t]of Object.entries(n))a=a.replaceAll(`{${e}}`,String(t));return a}function o(e){if(typeof document>`u`)return;let n=e??t().language;document.documentElement.lang=n===`en`?`en`:`zh-CN`,document.querySelectorAll(`[data-i18n]`).forEach(e=>{let t=e.dataset.i18n;t&&t in r&&(e.textContent=a(t,void 0,n))}),document.querySelectorAll(`[data-i18n-hint]`).forEach(e=>{let t=e.dataset.i18nHint;t&&t in r&&(e.dataset.hint=a(t,void 0,n))})}export{a as n,n as t};
@@ -1 +0,0 @@
1
- import{r as e,t,u as n}from"./app-config.CpjKWnzM.js";var r=[`内容库`,`生成能力`,`记忆与检索`,`开发工具`],i=[{id:`cases`,category:`内容库`,name:`用例管理`,description:`侧栏进入用例库:浏览、搜索、打开与删除用例。关闭后入口隐藏,「生成测试用例」一并关闭;磁盘文件仍保留。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1},{id:`caseGen`,category:`生成能力`,name:`生成测试用例`,description:`在工作台用「/」打开配置:选类型、模板与提示词后生成用例并写入用例库。需同时开启「用例管理」。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1,hasPanel:!0,requires:`cases`},{id:`prompts`,category:`内容库`,name:`提示词管理`,description:`侧栏进入提示词库:浏览、搜索、打开与删除提示词。关闭后入口隐藏,「生成提示词」一并关闭;磁盘文件仍保留。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1},{id:`promptGen`,category:`生成能力`,name:`生成提示词`,description:`用「/」打开配置后对话生成提示词;质检通过后写入提示词库。需同时开启「提示词管理」。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1,hasPanel:!0,requires:`prompts`},{id:`knowledgeLib`,category:`内容库`,name:`知识库管理`,description:`侧栏进入知识库:浏览、搜索、打开与删除文档。关闭后入口隐藏,「生成知识库」一并关闭;磁盘文件仍保留。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1},{id:`knowledgeGen`,category:`生成能力`,name:`生成知识库`,description:`用「/」打开配置后对话生成规范、方法论或环境约定;质检通过后写入知识库。需同时开启「知识库管理」。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1,hasPanel:!0,requires:`knowledgeLib`},{id:`requirements`,category:`内容库`,name:`需求文档库`,description:`侧栏进入需求文档库:浏览、搜索、上传与整理需求文档。关闭后入口隐藏;磁盘文件仍保留,生成用例时也不再引用。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1},{id:`templates`,category:`内容库`,name:`测试模板库`,description:`侧栏进入测试模板库:浏览、上传与整理用例 / 报告模板。关闭后入口隐藏;磁盘文件仍保留,生成用例时不再选用模板。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1},{id:`knowledge`,category:`记忆与检索`,name:`知识库检索`,description:`工作台输入「@」引用知识库与模板文档;发送后由模型按需读取。关闭后 @ 只列工作区文件。`,version:`1.4.0`,requiresDev:!1,defaultEnabled:!1},{id:`memory`,category:`记忆与检索`,name:`会话记忆`,description:`五轨记忆(用户档案 / 全局事实 / 项目关键 / 项目日志 / 每日):待确认、归档与便签,在工作台「记忆」Tab 管理。`,version:`2.0.0`,requiresDev:!0,defaultEnabled:!1},{id:`pluginDev`,category:`开发工具`,name:`插件开发`,description:`用固定提示词开发扩展插件:先评估形态与范围并用选项确认,确认后才改代码,完成后并入「扩展插件」。需要读写项目源码。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1,hasPanel:!0}];function a(e=i){return r.map(t=>({category:t,items:e.filter(e=>e.category===t)})).filter(e=>e.items.length>0)}var o=`tw-plugins-changed`;function s(){let e={};for(let t of i)e[t.id]=t.defaultEnabled;return e}function c(e,t){let n={...e};if(t){if(n[t.id]=t.enabled,t.enabled){let e=p(t.id)?.requires;e&&(n[e]=!0)}else for(let e of i)e.requires===t.id&&(n[e.id]=!1)}for(let e of i)e.requires&&!n[e.requires]&&(n[e.id]=!1);return n}function l(){let t=s(),n=e().plugins??{};for(let e of i)typeof n[e.id]==`boolean`&&(t[e.id]=n[e.id]);return c(t)}function u(e){return l()[e]}function d(e,r){let i=c(l(),{id:e,enabled:r});return n({plugins:i}),t(),typeof window<`u`&&window.dispatchEvent(new CustomEvent(o,{detail:i})),i}function f(e){if(typeof window>`u`)return()=>{};let t=t=>{let n=t.detail;e(n??l())};return window.addEventListener(o,t),()=>{window.removeEventListener(o,t)}}function p(e){return i.find(t=>t.id===e)}function m(e){let t=p(e),n=t?.name??e;return t?.requires&&!u(t.requires)?`请先在「我的插件」中启用「${p(t.requires)?.name??t.requires}」`:`请先在「我的插件」中启用「${n}」`}export{f as a,l as i,a as n,m as o,u as r,d as s,i as t};