lantern-harness 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/README.md +2 -2
- package/config/app.defaults.json +2 -1
- package/dist/500.html +8 -4
- package/dist/_astro/Base.CVuoZiOB.css +1 -0
- package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.-g0SuFCa.js → Base.astro_astro_type_script_index_0_lang.BY4OccDH.js} +1 -1
- package/dist/_astro/CaseExecBoard.GIKQ6ccZ.js +1 -0
- package/dist/_astro/{CaseGenerateApp.BQalnGiC.js → CaseGenerateApp.CGAvw04r.js} +1 -1
- package/dist/_astro/{CasesLibrary.u7ek8rOp.js → CasesLibrary.Bz6ol7zL.js} +1 -1
- package/dist/_astro/ChatApp.DZtDZRst.js +273 -0
- package/dist/_astro/ConfirmDialog.CBVsDJ8f.js +1 -0
- package/dist/_astro/DashboardBoard.CiTrVBqY.js +5 -0
- package/dist/_astro/{DocsFileBrowser.CHVgH1vj.js → DocsFileBrowser.CBXAmRPO.js} +1 -1
- package/dist/_astro/{DocsPager.DaiWchhj.js → DocsPager.CPwAnvW_.js} +1 -1
- package/dist/_astro/{KnowledgeLibrary.DSxgeW4L.js → KnowledgeLibrary._QhB3GHk.js} +1 -1
- package/dist/_astro/NamePromptDialog.Dl5kSnQI.js +1 -0
- package/dist/_astro/NavLibraries.fxwcz0b0.js +1 -0
- package/dist/_astro/PluginsPage.BfG3nVYJ.js +1 -0
- package/dist/_astro/{PluginsPage.Oh8hWup8.js → PluginsPage.n_0T_ww4.js} +2 -2
- package/dist/_astro/{PromptsLibrary.DWgox1du.js → PromptsLibrary.BLPVH34I.js} +1 -1
- package/dist/_astro/{ReportsPage.BlHA_AtE.js → ReportsPage.DMk4sUqZ.js} +1 -1
- package/dist/_astro/RequirementsLibrary.CyYBiauz.js +1 -0
- package/dist/_astro/{SearchableSelect.BMl1Bp59.js → SearchableSelect.yFomIhKQ.js} +1 -1
- package/dist/_astro/SettingsDialog.DrVaJAbf.js +1 -0
- package/dist/_astro/SpaceSwitcher.C84a-OBd.js +7 -0
- package/dist/_astro/TasksBoard.Dwva6gEQ.js +1 -0
- package/dist/_astro/TemplatesLibrary.DV_MUASP.js +1 -0
- package/dist/_astro/TestStatsBoard.Cl6mBowv.js +1 -0
- package/dist/_astro/TodosBoard.BTl5qvQt.js +1 -0
- package/dist/_astro/app-config.BAFE-Tim.js +1 -0
- package/dist/_astro/dialog.DXHznyjD.js +1 -0
- package/dist/_astro/i18n.DFwWWvim.js +7 -0
- package/dist/_astro/{open-docs-in-session.BC5D-BoF.js → open-docs-in-session.D7Hxuu0K.js} +1 -1
- package/dist/_astro/plugins.BHRarX88.js +1 -0
- package/dist/_astro/{settings.DBIYsQY-.js → settings.1aF-h9sh.js} +2 -2
- package/dist/_astro/tasks.hIKi1ek-.js +1 -0
- package/dist/_astro/{view-prefs.C9Mtta1E.js → view-prefs.DHPN5Yq6.js} +1 -1
- package/dist/case-exec/index.html +9 -5
- package/dist/cases/generate/index.html +9 -5
- package/dist/cases/library/index.html +9 -5
- package/dist/cn-holidays.json +42 -0
- package/dist/dashboard/index.html +268 -0
- package/dist/docs/changelog/index.html +29 -5
- package/dist/docs/install/index.html +8 -4
- package/dist/docs/manual/index.html +43 -10
- package/dist/index.html +9 -5
- package/dist/knowledge/index.html +9 -5
- 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 +8 -4
- package/dist/plugins/index.html +9 -5
- package/dist/prompts/index.html +9 -5
- package/dist/reports/index.html +9 -5
- package/dist/requirements/index.html +9 -5
- package/dist/tasks/index.html +9 -5
- package/dist/templates/index.html +9 -5
- 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 +8 -4
- 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 +8 -4
- 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 +8 -4
- 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 +8 -4
- 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 +8 -4
- package/dist/test-stats/index.html +9 -5
- package/dist/todos/index.html +9 -5
- package/docs//345/205/250/345/261/200/346/217/222/344/273/266.md +1 -1
- package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +33 -10
- package/lh-plugins/lh-tasks.mjs +1 -1
- package/package.json +2 -1
- package/dist/_astro/Base.C_AmDbI9.css +0 -1
- package/dist/_astro/CaseExecBoard.CNZh0sre.js +0 -1
- package/dist/_astro/ChatApp.Dk5uOXr0.js +0 -273
- package/dist/_astro/ConfirmDialog.Dbyjb4-6.js +0 -1
- package/dist/_astro/NamePromptDialog.DZSZ5Y16.js +0 -1
- package/dist/_astro/NavLibraries.BN5smOBt.js +0 -1
- package/dist/_astro/PluginsPage.BB18crT3.js +0 -1
- package/dist/_astro/RequirementsLibrary.2o-KMk7K.js +0 -1
- package/dist/_astro/SettingsDialog.Cs8z0Hhb.js +0 -1
- package/dist/_astro/SpaceSwitcher.DicPqrSH.js +0 -7
- package/dist/_astro/TasksBoard.dgJxOpVG.js +0 -1
- package/dist/_astro/TemplatesLibrary.BfC9HIuu.js +0 -1
- package/dist/_astro/TestStatsBoard.Dg23e0O_.js +0 -1
- package/dist/_astro/TodosBoard.CyvTZybr.js +0 -1
- package/dist/_astro/app-config.Crg0VdkS.js +0 -1
- package/dist/_astro/i18n.C8FKLrB5.js +0 -7
- package/dist/_astro/plugins.CNOYmeAe.js +0 -1
- package/dist/_astro/tasks.WhfT-DnC.js +0 -1
- /package/dist/{apple-touch-icon.png → brand/apple-touch-icon.png} +0 -0
- /package/dist/{brand-mark.png → brand/brand-mark.png} +0 -0
- /package/dist/{favicon.png → brand/favicon.png} +0 -0
- /package/dist/{icon-192.png → brand/icon-192.png} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{$ as n,A as r,D as i,E as a,G as o,J as s,L as c,M as l,O as u,P as d,Q as f,R as p,V as m,X as h,Z as g,_t as _,a as v,at as y,c as b,ct as x,d as S,dt as C,et as w,f as T,ft as E,g as D,gt as O,h as k,i as A,it as j,j as M,k as N,l as ee,m as P,mt as F,n as I,nt as L,o as te,ot as ne,p as re,pt as R,r as ie,s as ae,st as z,t as B,tt as V,u as H,ut as U,vt as W,y as G,z as K}from"./portal.Cm9XlIPf.js";import{n as q,r as oe,t as J}from"./active-element-history.CeefGkFQ.js";import{t as se}from"./jsx-runtime.BUXbF_vF.js";var Y=e(t(),1),ce=(0,Y.createContext)(()=>{});function le({value:e,children:t}){return Y.createElement(ce.Provider,{value:e},t)}function ue(e,t=typeof document<`u`?document.defaultView:null,n){let r=M(e,`escape`);oe(t,`keydown`,e=>{r&&(e.defaultPrevented||e.key===c.Escape&&n(e))})}function de(){let[e]=(0,Y.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`?window.matchMedia(`(pointer: coarse)`):null),[t,n]=(0,Y.useState)(e?.matches??!1);return R(()=>{if(!e)return;function t(e){n(e.matches)}return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[e]),t}function fe({defaultContainers:e=[],portals:t,mainTreeNode:n}={}){let r=C(()=>{let r=W(n),i=[];for(let t of e)t!==null&&(h(t)?i.push(t):`current`in t&&h(t.current)&&i.push(t.current));if(t!=null&&t.current)for(let e of t.current)i.push(e);for(let e of r?.querySelectorAll(`html > *, body > *`)??[])e!==document.body&&e!==document.head&&h(e)&&e.id!==`headlessui-portal-root`&&(n&&(e.contains(n)||e.contains(n?.getRootNode()?.host))||i.some(t=>e.contains(t))||i.push(e));return i});return{resolveContainers:r,contains:C(e=>r().some(t=>t.contains(e)))}}var pe=(0,Y.createContext)(null);function X({children:e,node:t}){let[n,r]=(0,Y.useState)(null),i=me(t??n);return Y.createElement(pe.Provider,{value:i},e,i===null&&Y.createElement(g,{features:f.Hidden,ref:e=>{if(e){for(let t of W(e)?.querySelectorAll(`html > *, body > *`)??[])if(t!==document.body&&t!==document.head&&h(t)&&t!=null&&t.contains(e)){r(t);break}}}}))}function me(e=null){return(0,Y.useContext)(pe)??e}function he(){let e=(0,Y.useRef)(!1);return R(()=>(e.current=!0,()=>{e.current=!1}),[]),e}var Z=(e=>(e[e.Forwards=0]=`Forwards`,e[e.Backwards=1]=`Backwards`,e))(Z||{});function ge(){let e=(0,Y.useRef)(0);return D(!0,`keydown`,t=>{t.key===`Tab`&&(e.current=+!!t.shiftKey)},!0),e}function _e(e){if(!e)return new Set;if(typeof e==`function`)return new Set(e());let t=new Set;for(let n of e.current)h(n.current)&&t.add(n.current);return t}var ve=`div`,Q=(e=>(e[e.None=0]=`None`,e[e.InitialFocus=1]=`InitialFocus`,e[e.TabLock=2]=`TabLock`,e[e.FocusLock=4]=`FocusLock`,e[e.RestoreFocus=8]=`RestoreFocus`,e[e.AutoFocus=16]=`AutoFocus`,e))(Q||{});function ye(e,t){let n=(0,Y.useRef)(null),r=m(n,t),{initialFocus:c,initialFocusFallback:l,containers:d,features:p=15,...h}=e;v()||(p=0);let _=P(n.current);Ce(p,{ownerDocument:_});let y=we(p,{ownerDocument:_,container:n,initialFocus:c,initialFocusFallback:l});Te(p,{ownerDocument:_,container:n,containers:d,previousActiveElement:y});let b=ge(),x=C(e=>{if(!s(n.current))return;let t=n.current;(e=>e())(()=>{z(b.current,{[Z.Forwards]:()=>{i(t,a.First,{skipElements:[e.relatedTarget,l]})},[Z.Backwards]:()=>{i(t,a.Last,{skipElements:[e.relatedTarget,l]})}})})}),S=M(!!(p&2),`focus-trap#tab-lock`),w=F(),T=(0,Y.useRef)(!1),E={ref:r,onKeyDown(e){e.key==`Tab`&&(T.current=!0,w.requestAnimationFrame(()=>{T.current=!1}))},onBlur(e){if(!(p&4))return;let t=_e(d);s(n.current)&&t.add(n.current);let r=e.relatedTarget;o(r)&&r.dataset.headlessuiFocusGuard!==`true`&&(Ee(t,r)||(T.current?i(n.current,z(b.current,{[Z.Forwards]:()=>a.Next,[Z.Backwards]:()=>a.Previous})|a.WrapAround,{relativeTo:e.target}):o(e.target)&&u(e.target)))}},D=L();return Y.createElement(Y.Fragment,null,S&&Y.createElement(g,{as:`button`,type:`button`,"data-headlessui-focus-guard":!0,onFocus:x,features:f.Focusable}),D({ourProps:E,theirProps:h,defaultTag:ve,name:`FocusTrap`}),S&&Y.createElement(g,{as:`button`,type:`button`,"data-headlessui-focus-guard":!0,onFocus:x,features:f.Focusable}))}var be=j(ye),xe=Object.assign(be,{features:Q});function Se(e=!0){let t=(0,Y.useRef)(J.slice());return q(([e],[n])=>{n===!0&&e===!1&&O(()=>{t.current.splice(0)}),n===!1&&e===!0&&(t.current=J.slice())},[e,J,t]),C(()=>t.current.find(e=>e!=null&&e.isConnected)??null)}function Ce(e,{ownerDocument:t}){let n=!!(e&8),r=Se(n);q(()=>{n||_(t?.body)&&u(r())},[n]),te(()=>{n&&u(r())})}function we(e,{ownerDocument:t,container:n,initialFocus:r,initialFocusFallback:o}){let s=(0,Y.useRef)(null),c=M(!!(e&1),`focus-trap#initial-focus`),l=he();return q(()=>{if(e===0)return;if(!c){o!=null&&o.current&&u(o.current);return}let d=n.current;d&&O(()=>{if(!l.current)return;let n=t?.activeElement;if(r!=null&&r.current){if(r?.current===n){s.current=n;return}}else if(d.contains(n)){s.current=n;return}if(r!=null&&r.current)u(r.current);else{if(e&16){if(i(d,a.First|a.AutoFocus)!==G.Error)return}else if(i(d,a.First)!==G.Error)return;if(o!=null&&o.current&&(u(o.current),t?.activeElement===o.current))return;console.warn(`There are no focusable elements inside the <FocusTrap />`)}s.current=t?.activeElement})},[o,c,e]),s}function Te(e,{ownerDocument:t,container:n,containers:r,previousActiveElement:i}){let a=he(),o=!!(e&4);oe(t?.defaultView,`focus`,e=>{if(!o||!a.current)return;let t=_e(r);s(n.current)&&t.add(n.current);let c=i.current;if(!c)return;let l=e.target;s(l)?Ee(t,l)?(i.current=l,u(l)):(e.preventDefault(),e.stopPropagation(),u(c)):u(i.current)},!0)}function Ee(e,t){for(let n of e)if(n.contains(t))return!0;return!1}function De(e){return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||!y(e.as??Fe)||Y.Children.count(e.children)===1}var Oe=(0,Y.createContext)(null);Oe.displayName=`TransitionContext`;var ke=(e=>(e.Visible=`visible`,e.Hidden=`hidden`,e))(ke||{});function Ae(){let e=(0,Y.useContext)(Oe);if(e===null)throw Error(`A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.`);return e}function je(){let e=(0,Y.useContext)(Me);if(e===null)throw Error(`A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.`);return e}var Me=(0,Y.createContext)(null);Me.displayName=`NestingContext`;function Ne(e){return`children`in e?Ne(e.children):e.current.filter(({el:e})=>e.current!==null).filter(({state:e})=>e===`visible`).length>0}function Pe(e,t){let n=E(e),r=(0,Y.useRef)([]),i=he(),a=F(),o=C((e,t=V.Hidden)=>{let o=r.current.findIndex(({el:t})=>t===e);o!==-1&&(z(t,{[V.Unmount](){r.current.splice(o,1)},[V.Hidden](){r.current[o].state=`hidden`}}),a.microTask(()=>{var e;!Ne(r)&&i.current&&((e=n.current)==null||e.call(n))}))}),s=C(e=>{let t=r.current.find(({el:t})=>t===e);return t?t.state!==`visible`&&(t.state=`visible`):r.current.push({el:e,state:`visible`}),()=>o(e,V.Unmount)}),c=(0,Y.useRef)([]),l=(0,Y.useRef)(Promise.resolve()),u=(0,Y.useRef)({enter:[],leave:[]}),d=C((e,n,r)=>{c.current.splice(0),t&&(t.chains.current[n]=t.chains.current[n].filter(([t])=>t!==e)),t?.chains.current[n].push([e,new Promise(e=>{c.current.push(e)})]),t?.chains.current[n].push([e,new Promise(e=>{Promise.all(u.current[n].map(([e,t])=>t)).then(()=>e())})]),n===`enter`?l.current=l.current.then(()=>t?.wait.current).then(()=>r(n)):r(n)}),f=C((e,t,n)=>{Promise.all(u.current[t].splice(0).map(([e,t])=>t)).then(()=>{var e;(e=c.current.shift())==null||e()}).then(()=>n(t))});return(0,Y.useMemo)(()=>({children:r,register:s,unregister:o,onStart:d,onStop:f,wait:l,chains:u}),[s,o,r,d,f,u,l])}var Fe=Y.Fragment,Ie=w.RenderStrategy;function Le(e,t){var n;let{transition:r=!0,beforeEnter:i,afterEnter:a,beforeLeave:o,afterLeave:s,enter:c,enterFrom:l,enterTo:u,entered:d,leave:f,leaveFrom:p,leaveTo:h,...g}=e,[_,y]=(0,Y.useState)(null),w=(0,Y.useRef)(null),E=De(e),D=m(...E?[w,t,y]:t===null?[]:[t]),O=(n=g.unmount)==null||n?V.Unmount:V.Hidden,{show:k,appear:A,initial:j}=Ae(),[M,N]=(0,Y.useState)(k?`visible`:`hidden`),ee=je(),{register:P,unregister:F}=ee;R(()=>P(w),[P,w]),R(()=>{if(O===V.Hidden&&w.current){if(k&&M!==`visible`){N(`visible`);return}return z(M,{hidden:()=>F(w),visible:()=>P(w)})}},[M,w,P,F,k,O]);let I=v();R(()=>{if(E&&I&&M===`visible`&&w.current===null)throw Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[w,M,I,E]);let te=j&&!A,re=A&&k&&j,ie=(0,Y.useRef)(!1),B=Pe(()=>{ie.current||(N(`hidden`),F(w))},ee),H=C(e=>{ie.current=!0;let t=e?`enter`:`leave`;B.onStart(w,t,e=>{e===`enter`?i?.():e===`leave`&&o?.()})}),U=C(e=>{let t=e?`enter`:`leave`;ie.current=!1,B.onStop(w,t,e=>{e===`enter`?a?.():e===`leave`&&s?.()}),t===`leave`&&!Ne(B)&&(N(`hidden`),F(w))});(0,Y.useEffect)(()=>{E&&r||(H(k),U(k))},[k,E,r]);let[,W]=S(!(!r||!E||!I||te),_,k,{start:H,end:U}),G=ne({ref:D,className:x(g.className,re&&c,re&&l,W.enter&&c,W.enter&&W.closed&&l,W.enter&&!W.closed&&u,W.leave&&f,W.leave&&!W.closed&&p,W.leave&&W.closed&&h,!W.transition&&k&&d)?.trim()||void 0,...T(W)}),K=0;M===`visible`&&(K|=b.Open),M===`hidden`&&(K|=b.Closed),k&&M===`hidden`&&(K|=b.Opening),!k&&M===`visible`&&(K|=b.Closing);let q=L();return Y.createElement(Me.Provider,{value:B},Y.createElement(ae,{value:K},q({ourProps:G,theirProps:g,defaultTag:Fe,features:Ie,visible:M===`visible`,name:`Transition.Child`})))}function Re(e,t){let{show:n,appear:r=!1,unmount:i=!0,...a}=e,o=(0,Y.useRef)(null),s=De(e),c=m(...s?[o,t]:t===null?[]:[t]);v();let l=H();if(n===void 0&&l!==null&&(n=(l&b.Open)===b.Open),n===void 0)throw Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[u,d]=(0,Y.useState)(n?`visible`:`hidden`),f=Pe(()=>{n||d(`hidden`)}),[p,h]=(0,Y.useState)(!0),g=(0,Y.useRef)([n]);R(()=>{p!==!1&&g.current[g.current.length-1]!==n&&(g.current.push(n),h(!1))},[g,n]);let _=(0,Y.useMemo)(()=>({show:n,appear:r,initial:p}),[n,r,p]);R(()=>{n?d(`visible`):!Ne(f)&&o.current!==null&&d(`hidden`)},[n,f]);let y={unmount:i},x=C(()=>{var t;p&&h(!1),(t=e.beforeEnter)==null||t.call(e)}),S=C(()=>{var t;p&&h(!1),(t=e.beforeLeave)==null||t.call(e)}),w=L();return Y.createElement(Me.Provider,{value:f},Y.createElement(Oe.Provider,{value:_},w({ourProps:{...y,as:Y.Fragment,children:Y.createElement(Ve,{ref:c,...y,...a,beforeEnter:x,beforeLeave:S})},theirProps:{},defaultTag:Y.Fragment,features:Ie,visible:u===`visible`,name:`Transition`})))}function ze(e,t){let n=(0,Y.useContext)(Oe)!==null,r=H()!==null;return Y.createElement(Y.Fragment,null,!n&&r?Y.createElement(Be,{ref:t,...e}):Y.createElement(Ve,{ref:t,...e}))}var Be=j(Re),Ve=j(Le),He=j(ze),Ue=Object.assign(Be,{Child:He,Root:Be}),We=(e=>(e[e.Open=0]=`Open`,e[e.Closed=1]=`Closed`,e))(We||{}),Ge=(e=>(e[e.SetTitleId=0]=`SetTitleId`,e))(Ge||{}),Ke={0(e,t){return e.titleId===t.id?e:{...e,titleId:t.id}}},qe=(0,Y.createContext)(null);qe.displayName=`DialogContext`;function Je(e){let t=(0,Y.useContext)(qe);if(t===null){let t=Error(`<${e} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,Je),t}return t}function Ye(e,t){return z(t.type,Ke,e,t)}var Xe=j(function(e,t){let i=(0,n.useId)(),{id:a=`headlessui-dialog-${i}`,open:o,onClose:s,initialFocus:c,role:u=`dialog`,autoFocus:f=!0,__demoMode:h=!1,unmount:g=!1,..._}=e,y=(0,Y.useRef)(!1);u=function(){return u===`dialog`||u===`alertdialog`?u:(y.current||(y.current=!0,console.warn(`Invalid role [${u}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),`dialog`)}();let x=H();o===void 0&&x!==null&&(o=(x&b.Open)===b.Open);let S=(0,Y.useRef)(null),w=m(S,t),T=P(S.current),E=+!o,[D,O]=(0,Y.useReducer)(Ye,{titleId:null,descriptionId:null,panelRef:(0,Y.createRef)()}),j=C(()=>s(!1)),M=C(e=>O({type:0,id:e})),F=v()?E===0:!1,[te,ne]=ie(),ae={get current(){return D.panelRef.current??S.current}},z=me(),{resolveContainers:V}=fe({mainTreeNode:z,portals:te,defaultContainers:[ae]}),W=x!==null&&(x&b.Closing)===b.Closing;r(h||W?!1:F,{allowed:C(()=>[S.current?.closest(`[data-headlessui-portal]`)??null]),disallowed:C(()=>[z?.closest(`body > *:not(#headlessui-portal-root)`)??null])});let G=d.get(null);R(()=>{if(F)return G.actions.push(a),()=>G.actions.pop(a)},[G,a,F]);let K=l(G,(0,Y.useCallback)(e=>G.selectors.isTop(e,a),[G,a]));k(K,V,e=>{e.preventDefault(),j()}),ue(K,T?.defaultView,e=>{e.preventDefault(),e.stopPropagation(),document.activeElement&&`blur`in document.activeElement&&typeof document.activeElement.blur==`function`&&document.activeElement.blur(),j()}),re(h||W?!1:F,T,V),N(F,S,j);let[q,oe]=p(),J=(0,Y.useMemo)(()=>[{dialogState:E,close:j,setTitleId:M,unmount:g},D],[E,j,M,g,D]),se=U({open:E===0}),ce={ref:w,id:a,role:u,tabIndex:-1,"aria-modal":h?void 0:E===0||void 0,"aria-labelledby":D.titleId,"aria-describedby":q,unmount:g},pe=!de(),X=Q.None;F&&!h&&(X|=Q.RestoreFocus,X|=Q.TabLock,f&&(X|=Q.AutoFocus),pe&&(X|=Q.InitialFocus));let he=L();return Y.createElement(ee,null,Y.createElement(A,{force:!0},Y.createElement(I,null,Y.createElement(qe.Provider,{value:J},Y.createElement(B,{target:S},Y.createElement(A,{force:!1},Y.createElement(oe,{slot:se},Y.createElement(ne,null,Y.createElement(xe,{initialFocus:c,initialFocusFallback:S,containers:V,features:X},Y.createElement(le,{value:j},he({ourProps:ce,theirProps:_,slot:se,defaultTag:Ze,features:Qe,visible:E===0,name:`Dialog`})))))))))))}),Ze=`div`,Qe=w.RenderStrategy|w.Static;function $e(e,t){let{transition:n=!1,open:r,...i}=e,a=H(),o=e.hasOwnProperty(`open`)||a!==null,s=e.hasOwnProperty(`onClose`);if(!o&&!s)throw Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!o)throw Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!s)throw Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(!a&&typeof e.open!=`boolean`)throw Error(`You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: ${e.open}`);if(typeof e.onClose!=`function`)throw Error(`You provided an \`onClose\` prop to the \`Dialog\`, but the value is not a function. Received: ${e.onClose}`);return(r!==void 0||n)&&!i.static?Y.createElement(X,null,Y.createElement(Ue,{show:r,transition:n,unmount:i.unmount},Y.createElement(Xe,{ref:t,...i}))):Y.createElement(X,null,Y.createElement(Xe,{ref:t,open:r,...i}))}var et=`div`;function tt(e,t){let r=(0,n.useId)(),{id:i=`headlessui-dialog-panel-${r}`,transition:a=!1,...o}=e,[{dialogState:s,unmount:c},l]=Je(`Dialog.Panel`),u=m(t,l.panelRef),d=U({open:s===0}),f={ref:u,id:i,onClick:C(e=>{e.stopPropagation()})},p=a?He:Y.Fragment,h=a?{unmount:c}:{},g=L();return Y.createElement(p,{...h},g({ourProps:f,theirProps:o,slot:d,defaultTag:et,name:`Dialog.Panel`}))}var nt=`div`;function rt(e,t){let{transition:n=!1,...r}=e,[{dialogState:i,unmount:a}]=Je(`Dialog.Backdrop`),o=U({open:i===0}),s={ref:t,"aria-hidden":!0},c=n?He:Y.Fragment,l=n?{unmount:a}:{},u=L();return Y.createElement(c,{...l},u({ourProps:s,theirProps:r,slot:o,defaultTag:nt,name:`Dialog.Backdrop`}))}var it=`h2`;function at(e,t){let r=(0,n.useId)(),{id:i=`headlessui-dialog-title-${r}`,...a}=e,[{dialogState:o,setTitleId:s}]=Je(`Dialog.Title`),c=m(t);(0,Y.useEffect)(()=>(s(i),()=>s(null)),[i,s]);let l=U({open:o===0}),u={ref:c,id:i};return L()({ourProps:u,theirProps:a,slot:l,defaultTag:it,name:`Dialog.Title`})}var ot=j($e),st=j(tt),ct=j(rt),lt=j(at),ut=Object.assign(ot,{Panel:st,Title:lt,Description:K}),$=se();function dt({open:e,title:t=`确认`,message:n,confirmLabel:r=`确定`,cancelLabel:i=`取消`,danger:a=!1,hideCancel:o=!1,onClose:s,onConfirm:c}){let l=a===!0||a===`solid`?`solid`:a===`outline`?`outline`:null;return(0,$.jsxs)(ut,{open:e,onClose:s,transition:!0,className:`relative z-110`,children:[(0,$.jsx)(ct,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,$.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,$.jsxs)(st,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim relative w-full max-w-sm rounded-xl shadow-xl border border-stone-200 p-5 bg-white`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:s,className:`tw-confirm-cancel absolute top-3.5 right-3.5 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,$.jsx)(lt,{className:`tw-confirm-title pr-8 text-base font-semibold text-stone-900`,children:t}),(0,$.jsx)(`p`,{className:`tw-confirm-msg mt-3 text-sm text-stone-600 leading-relaxed whitespace-pre-wrap`,children:n}),(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[o?null:(0,$.jsx)(`button`,{type:`button`,onClick:s,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:i}),(0,$.jsx)(`button`,{type:`button`,onClick:c,className:l===`outline`?`h-8 px-3 text-sm rounded-lg border border-red-300 text-red-600 bg-transparent hover:bg-red-50 transition-colors`:l===`solid`?`h-8 px-3 text-sm rounded-lg text-white bg-red-600 hover:bg-red-700 transition-colors`:`h-8 px-3 text-sm rounded-lg text-white bg-[#4176e6] hover:bg-[#3566d0] transition-colors`,children:r})]})]})})]})}export{st as a,ut as i,ct as n,Ue as o,lt as r,He as s,dt as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{a as n,i as r,n as i,r as a}from"./ConfirmDialog.Dbyjb4-6.js";import{t as o}from"./jsx-runtime.BUXbF_vF.js";var s=e(t(),1),c=o();function l({open:e,title:t=`新建文件夹`,label:o=`文件夹名称`,placeholder:l=`请输入名称`,initialValue:u=``,lockExtension:d=!1,confirmLabel:f=`创建`,cancelLabel:p=`取消`,onClose:m,onConfirm:h}){let[g,_]=(0,s.useState)(``),[v,y]=(0,s.useState)(``),b=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(e){let e=u,t=``;if(d){let n=u.lastIndexOf(`.`);n>0&&(e=u.slice(0,n),t=u.slice(n))}_(e),y(t);let n=window.setTimeout(()=>{b.current?.focus(),b.current?.select()},50);return()=>window.clearTimeout(n)}},[e,u,d]);function x(){let e=g.trim();e&&h(e+v)}return(0,c.jsxs)(r,{open:e,onClose:m,transition:!0,className:`relative z-50`,children:[(0,c.jsx)(i,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,c.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,c.jsxs)(n,{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,c.jsx)(a,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:t}),(0,c.jsxs)(`label`,{className:`tw-confirm-msg mt-4 block text-xs font-medium text-stone-500`,children:[o,(0,c.jsxs)(`span`,{className:`mt-1.5 flex items-center gap-0 rounded-lg border border-stone-200 focus-within:ring-2 focus-within:ring-[#4176e6]/30 focus-within:border-[#4176e6] transition-colors`,children:[(0,c.jsx)(`input`,{ref:b,value:g,onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),x())},placeholder:l,className:`flex-1 min-w-0 h-9 px-3 text-sm rounded-lg border-0 bg-transparent text-stone-800 outline-none`}),v?(0,c.jsx)(`span`,{className:`shrink-0 pr-3 text-sm text-stone-400 select-none`,children:v}):null]})]}),(0,c.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,c.jsx)(`button`,{type:`button`,onClick:m,className:`tw-confirm-cancel h-8 px-3 text-sm rounded-lg text-stone-600 hover:bg-stone-100 transition-colors`,children:p}),(0,c.jsx)(`button`,{type:`button`,disabled:!g.trim(),onClick:x,className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:f})]})]})})]})}export{l as t};
|
|
@@ -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,P as u,S as d,T as f,_ as p,a as m,b as h,g,h as _,i as v,j as y,k as b,m as x,p as S,r as C,t as w,u as T,v as ee,w as E,x as te,y as ne}from"./app-config.Crg0VdkS.js";import{a as re,i as ie,r as D}from"./plugins.CNOYmeAe.js";import{a as O,i as k,n as A,r as j,t as ae}from"./ConfirmDialog.Dbyjb4-6.js";import{t as oe}from"./jsx-runtime.BUXbF_vF.js";import{n as M}from"./i18n.C8FKLrB5.js";var N=e(t(),1),P=e(n(),1),F=`/__tb_nav/groups`;function se(){return C().navGroups}function I(){return o(C().navIcons)}function ce(e,t){let n={...I(),[e]:t};return T({navIcons:n}),w(),n}function le(){return C().navOrder}function ue(e,t){let n=f(e),r=a(t,n);return T({navGroups:n,navOrder:r}),w(),{groups:n,order:r}}function L(e,t){return JSON.stringify(e)===JSON.stringify(t)}async function de(e){if(!m())return null;try{let t=await fetch(F,{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 f(n.groups,!1)}catch{return null}}async function fe(){if(!m())return;let e=C(),t=null;try{let e=await fetch(F,{signal:AbortSignal.timeout(4e3)});e.ok&&(t=await e.json())}catch{return}if(!t)return;if(t.scanned){let n=f(t.groups,!1),r=a(e.navOrder,n);(!L(n,e.navGroups)||!L(r,e.navOrder))&&(T({navGroups:n,navOrder:r}),w());return}if(!e.navGroups.length)return;let n=await de(e.navGroups);n&&!L(n,e.navGroups)&&(T({navGroups:n,navOrder:a(e.navOrder,n)}),w())}var R=oe(),z=`/`;function B(e){return`${z.endsWith(`/`)?z:`${z}/`}${e.replace(/^\//,``)}`}function V(e,t){return e.includes(`/${t}`)}function H(e){return[`tw-nav-item`,e?`is-active font-medium`:``].filter(Boolean).join(` `)}function U(e){return S(`tw.nav.groupOpen.${e}`)}function W(){return S(`tw.nav.docsOpen`)}function pe(e,t){try{let t=localStorage.getItem(U(e));if(t===`1`)return!0;if(t===`0`)return!1;if(e===`docs`){let e=localStorage.getItem(W());if(e===`1`)return!0;if(e===`0`)return!1}}catch{}return t}function G(e,t){try{localStorage.setItem(U(e),t?`1`:`0`),e===`docs`&&localStorage.setItem(W(),t?`1`:`0`)}catch{}}function K(e){return e.id===`docs`&&(e.name===`文档库`||e.name===`Documents`)?M(`nav.docs`):e.name}function me(e){return e.type===`group`?K(e.group):M(h(e.id).i18n)}function q(e){return e.type===`item`?i(e.id):te(e.group.id)}function he(){let[e,t]=(0,N.useState)(()=>window.location.pathname);return(0,N.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 J({children:e}){return(0,R.jsx)(`svg`,{className:`tw-nav-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:e})}function Y({id:e,icon:t}){return(0,R.jsx)(J,{children:X[t??x[e]]})}var X={check:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`path`,{d:`M9 11l3 3L22 4`}),(0,R.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,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`path`,{d:`M12 20h9`}),(0,R.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`})]}),book:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 0 1 6.5 17H20`}),(0,R.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,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`path`,{d:`M14 3v5h5`}),(0,R.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,R.jsx)(`path`,{d:`M8 13h8`}),(0,R.jsx)(`path`,{d:`M8 17h6`})]}),layers:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`path`,{d:`M12 3 3 8l9 5 9-5-9-5z`}),(0,R.jsx)(`path`,{d:`m3 13 9 5 9-5`})]}),list:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`path`,{d:`M8 6h13`}),(0,R.jsx)(`path`,{d:`M8 12h13`}),(0,R.jsx)(`path`,{d:`M8 18h13`}),(0,R.jsx)(`path`,{d:`M3 6h.01`}),(0,R.jsx)(`path`,{d:`M3 12h.01`}),(0,R.jsx)(`path`,{d:`M3 18h.01`})]}),folder:(0,R.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,R.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,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`ellipse`,{cx:`12`,cy:`6`,rx:`8`,ry:`3`}),(0,R.jsx)(`path`,{d:`M4 6v6c0 1.7 3.6 3 8 3s8-1.3 8-3V6`}),(0,R.jsx)(`path`,{d:`M4 12v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]}),target:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8`}),(0,R.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,R.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`})]}),code:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`path`,{d:`m8 8-4 4 4 4`}),(0,R.jsx)(`path`,{d:`m16 8 4 4-4 4`})]}),flask:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`path`,{d:`M9 3h6`}),(0,R.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,R.jsx)(`path`,{d:`M7.5 14h9`})]}),home:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`path`,{d:`M3 10.5 12 3l9 7.5`}),(0,R.jsx)(`path`,{d:`M5 9.5V20h14V9.5`})]}),clipboard:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`path`,{d:`M9 4h6v3H9z`}),(0,R.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,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`circle`,{cx:`12`,cy:`14`,r:`5`}),(0,R.jsx)(`path`,{d:`M9 6l2 2`}),(0,R.jsx)(`path`,{d:`M15 6l-2 2`}),(0,R.jsx)(`path`,{d:`M7 11H4`}),(0,R.jsx)(`path`,{d:`M20 11h-3`}),(0,R.jsx)(`path`,{d:`M7 17H4`}),(0,R.jsx)(`path`,{d:`M20 17h-3`})]}),calendar:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`rect`,{x:`3`,y:`5`,width:`18`,height:`16`,rx:`2`}),(0,R.jsx)(`path`,{d:`M8 3v4`}),(0,R.jsx)(`path`,{d:`M16 3v4`}),(0,R.jsx)(`path`,{d:`M3 10h18`})]}),chart:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`path`,{d:`M4 20V10`}),(0,R.jsx)(`path`,{d:`M10 20V4`}),(0,R.jsx)(`path`,{d:`M16 20v-7`}),(0,R.jsx)(`path`,{d:`M2 20h20`})]}),globe:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,R.jsx)(`path`,{d:`M3 12h18`}),(0,R.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,R.jsxs)(R.Fragment,{children:[(0,R.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,R.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,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`circle`,{cx:`9`,cy:`8`,r:`3.5`}),(0,R.jsx)(`path`,{d:`M2.5 20a6.5 6.5 0 0 1 13 0`}),(0,R.jsx)(`path`,{d:`M16 5.5a3.5 3.5 0 0 1 0 7`}),(0,R.jsx)(`path`,{d:`M18 20a6 6 0 0 0-2-4.5`})]}),terminal:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`path`,{d:`m5 8 4 4-4 4`}),(0,R.jsx)(`path`,{d:`M13 16h6`})]}),tag:(0,R.jsxs)(R.Fragment,{children:[(0,R.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,R.jsx)(`circle`,{cx:`8`,cy:`8`,r:`1.2`})]}),flag:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`path`,{d:`M5 21V4`}),(0,R.jsx)(`path`,{d:`M5 5h11l-2 4 2 4H5z`})]}),zap:(0,R.jsx)(`path`,{d:`M13 2 4 14h6l-1 8 9-12h-6l1-8z`})};function Z(){return(0,R.jsxs)(R.Fragment,{children:[(0,R.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,R.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,R.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,R.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,R.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:[(0,R.jsx)(`path`,{d:`M21 4H14`,strokeLinecap:`round`}),(0,R.jsx)(`path`,{d:`M10 4H3`,strokeLinecap:`round`}),(0,R.jsx)(`path`,{d:`M21 12H12`,strokeLinecap:`round`}),(0,R.jsx)(`path`,{d:`M8 12H3`,strokeLinecap:`round`}),(0,R.jsx)(`path`,{d:`M21 20H16`,strokeLinecap:`round`}),(0,R.jsx)(`path`,{d:`M12 20H3`,strokeLinecap:`round`}),(0,R.jsx)(`path`,{d:`M14 2v4`,strokeLinecap:`round`}),(0,R.jsx)(`path`,{d:`M8 10v4`,strokeLinecap:`round`}),(0,R.jsx)(`path`,{d:`M16 18v4`,strokeLinecap:`round`})]})}function _e(){return(0,R.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:[(0,R.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,R.jsx)(`path`,{d:`M12 8v8`,strokeLinecap:`round`}),(0,R.jsx)(`path`,{d:`M8 12h8`,strokeLinecap:`round`})]})}function Q(){return(0,R.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,children:[(0,R.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.7`}),(0,R.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.7`}),(0,R.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.7`})]})}function ve(){return(0,R.jsx)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,R.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,R.jsxs)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,R.jsx)(`path`,{d:`M9 6H5a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h4`,strokeLinecap:`round`}),(0,R.jsx)(`path`,{d:`M16 8l4 4-4 4`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,R.jsx)(`path`,{d:`M20 12H9`,strokeLinecap:`round`})]})}function be(){return(0,R.jsxs)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,R.jsx)(`circle`,{cx:`8.5`,cy:`8.5`,r:`4.5`}),(0,R.jsx)(`rect`,{x:`12`,y:`12`,width:`9`,height:`9`,rx:`2`})]})}function xe(){return(0,R.jsxs)(J,{children:[(0,R.jsx)(`path`,{d:`M8 6v12`,strokeLinecap:`round`}),(0,R.jsx)(`path`,{d:`M5 9l3-3 3 3`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,R.jsx)(`path`,{d:`M16 18V6`,strokeLinecap:`round`}),(0,R.jsx)(`path`,{d:`M13 15l3 3 3-3`,strokeLinecap:`round`,strokeLinejoin:`round`})]})}function Se(){return(0,R.jsxs)(`svg`,{className:`tw-nav-drag-grip`,viewBox:`0 0 20 20`,"aria-hidden":!0,children:[(0,R.jsx)(`circle`,{cx:`7`,cy:`5`,r:`1.25`,fill:`currentColor`}),(0,R.jsx)(`circle`,{cx:`13`,cy:`5`,r:`1.25`,fill:`currentColor`}),(0,R.jsx)(`circle`,{cx:`7`,cy:`10`,r:`1.25`,fill:`currentColor`}),(0,R.jsx)(`circle`,{cx:`13`,cy:`10`,r:`1.25`,fill:`currentColor`}),(0,R.jsx)(`circle`,{cx:`7`,cy:`15`,r:`1.25`,fill:`currentColor`}),(0,R.jsx)(`circle`,{cx:`13`,cy:`15`,r:`1.25`,fill:`currentColor`})]})}function Ce(e,t,n){let[r,i]=(0,N.useState)(null),a=(0,N.useRef)(null),o=(0,N.useRef)(e);o.current=e;let s=(0,N.useRef)(t);s.current=t;let l=(0,N.useRef)(n);l.current=n;function u(e,t){if(t.button!==0)return;t.preventDefault(),t.stopPropagation();let n=a.current;if(!n)return;i(e);let r=e=>{let t=[...n.querySelectorAll(`[data-sort-key]`)];for(let n of t){let t=n.getBoundingClientRect();if(e>=t.top&&e<=t.bottom)return n.dataset.sortKey}return null},u=t=>{let n=r(t.clientY);if(!n||n===e)return;let i=c(o.current,e,n);i.join(`|`)!==o.current.join(`|`)&&(o.current=i,s.current(i))},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d),i(null),l.current?.()};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)}return{listRef:a,dragId:r,onPointerDown:u}}function $(e,t){if(d(e))return!1;let n=h(e).plugin;return!n||t[n]!==!1}function we({id:e,icon:t,pathname:n,actionOpen:r,onMenu:i}){let a=h(e),o=V(n,a.match);return(0,R.jsxs)(`div`,{className:[H(o),r?`is-action-open`:``].filter(Boolean).join(` `),"data-plugin-nav":a.plugin,children:[(0,R.jsxs)(`a`,{href:B(a.href),className:`tw-nav-item-main`,children:[(0,R.jsx)(Y,{id:e,icon:t}),(0,R.jsx)(`span`,{className:`tw-nav-label`,children:M(a.i18n)})]}),(0,R.jsx)(`button`,{type:`button`,className:`tw-nav-hover-btn`,"aria-label":M(`nav.more`),onClick:e=>{e.preventDefault(),e.stopPropagation(),i(e.currentTarget)},children:(0,R.jsx)(Q,{})})]})}function Te(e,t,n){return e.items.some(e=>{if(d(e))return!1;let t=h(e).plugin;return(!t||D(t))&&V(n,h(e).match)})?!0:E(t,e.id).some(e=>Te(e,t,n))}function Ee(e,t){return e.items.some(e=>{if(d(e))return!1;let t=h(e).plugin;return!t||D(t)})?!0:E(t,e.id).some(e=>Ee(e,t))}function De({group:e,groups:t,icons:n,pathname:r,openItem:i,openGroupId:a,onMenu:o,onItemMenu:s}){let c=e.items.filter(e=>{if(d(e))return!1;let t=h(e).plugin;return!t||D(t)}),l=E(t,e.id),u=Te(e,t,r),[f,p]=(0,N.useState)(()=>pe(e.id,!0)),[m,g]=(0,N.useState)(!1),_=(0,N.useRef)(null),v=(0,N.useRef)(null),y=(0,N.useRef)(null);if((0,N.useEffect)(()=>b,[]),!Ee(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(),G(e.id,!0),g(!1),p(!0)}function S(t){if(t.preventDefault(),!f||m){x();return}g(!0),G(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,R.jsxs)(`details`,{className:`tw-nav-details ${m?`is-closing`:``}`,open:f||m,"data-nav-group":e.id,children:[(0,R.jsxs)(`summary`,{className:[`tw-nav-item tw-nav-summary`,u?`is-branch-active`:``,a===e.id?`is-action-open`:``].filter(Boolean).join(` `),onClick:S,children:[(0,R.jsx)(Z,{}),(0,R.jsx)(`span`,{className:`tw-nav-label min-w-0 flex-1 truncate`,children:K(e)}),(0,R.jsx)(`button`,{type:`button`,className:`tw-nav-hover-btn`,"aria-label":M(`nav.groupActions`),onClick:t=>{t.preventDefault(),t.stopPropagation(),o(e,t.currentTarget)},children:(0,R.jsx)(ge,{})}),(0,R.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,R.jsx)(`path`,{d:`M7 5l6 5-6 5`,strokeLinecap:`round`,strokeLinejoin:`round`})})]}),(0,R.jsx)(`div`,{className:`tw-nav-subtree-anim`,ref:_,children:(0,R.jsxs)(`div`,{className:`tw-nav-subtree`,children:[c.map(e=>(0,R.jsx)(we,{id:e,icon:n[e],pathname:r,actionOpen:i===e,onMenu:t=>s(e,t)},e)),l.map(e=>(0,R.jsx)(De,{group:e,groups:t,icons:n,pathname:r,openItem:i,openGroupId:a,onMenu:o,onItemMenu:s},e.id))]})})]})}function Oe({open:e,draft:t,groups:n,plugins:r,icons:i,onClose:a,onSave:o,onDelete:s}){let[c,l]=(0,N.useState)(``),[u,d]=(0,N.useState)([]),[f,p]=(0,N.useState)(``),m=(0,N.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=Ce(u,d);(0,N.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(M(`nav.groupNameRequired`));return}if(!u.length){p(M(`nav.groupItemsRequired`));return}let n=(t?.items??[]).filter(e=>!$(e,r));o({id:t?.id,name:e,items:[...n,...u],parentId:t?.parentId})}let x=[...u.map(e=>g.find(t=>t.id===e)).filter(e=>!!e),...g.filter(e=>!u.includes(e.id))];return(0,R.jsxs)(k,{open:e,onClose:a,transition:!0,className:`relative z-110`,children:[(0,R.jsx)(A,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":!0}),(0,R.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,R.jsxs)(O,{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,R.jsx)(j,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:t?.id?M(`nav.editGroupTitle`):t?.parentId?M(`nav.addSubgroup`):M(`nav.createGroup`)}),(0,R.jsxs)(`label`,{className:`tw-confirm-msg mt-4 block text-xs font-medium text-stone-500`,children:[M(`nav.groupName`),(0,R.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,R.jsxs)(`div`,{className:`mt-4`,children:[(0,R.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:M(`nav.groupItems`)}),(0,R.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:M(`nav.groupItemsHint`)}),(0,R.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,R.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,R.jsx)(Se,{}):(0,R.jsx)(`span`,{className:`tw-nav-drag-grip`}),(0,R.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>y(e.id),className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/40`}),(0,R.jsx)(`span`,{className:`tw-nav-editor-ico`,children:(0,R.jsx)(Y,{id:e.id,icon:i[e.id]})}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:M(e.i18n)})]},e.id)}),x.length?null:(0,R.jsx)(`div`,{className:`px-3 py-4 text-center text-[12px] text-stone-400`,children:M(`nav.noAddableItems`)})]})]}),f?(0,R.jsx)(`p`,{className:`mt-2 text-[12px] text-red-600`,children:f}):null,(0,R.jsxs)(`div`,{className:`mt-5 flex items-center gap-2`,children:[t?.id&&s?(0,R.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:M(`nav.deleteGroup`)}):null,(0,R.jsx)(`div`,{className:`flex-1`}),(0,R.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:M(`nav.groupCancel`)}),(0,R.jsx)(`button`,{type:`button`,onClick:b,className:`h-8 px-3 text-sm rounded-lg text-white bg-[#4176e6] hover:bg-[#3566d0]`,children:M(`nav.groupSave`)})]})]})})]})}function ke({ids:e,labelOf:t,onChange:n,onEnd:r,indent:i}){let a=Ce(e,n,r);return(0,R.jsx)(`div`,{ref:a.listRef,className:`flex flex-col`,children:e.map(e=>(0,R.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,R.jsx)(Se,{}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t(e)})]},e))})}function Ae({open:e,focusGroupId:t,nodes:n,groups:r,visible:i,onClose:a,onCommit:o}){let s=e=>!i||i(e),c=n.filter(e=>e.type===`item`?s(e.id):e.group.items.some(s)),[l,u]=(0,N.useState)(()=>c.map(q)),[d,f]=(0,N.useState)(()=>Object.fromEntries(r.map(e=>[e.id,[...e.items]]))),p=(0,N.useRef)(l);p.current=l;let m=(0,N.useRef)(d);m.current=d;let g=(0,N.useRef)(r);g.current=r;let _=(0,N.useRef)(c);_.current=c;let v=()=>{let e=g.current.map(e=>({...e,items:m.current[e.id]??e.items}));o(p.current,e)};(0,N.useEffect)(()=>{if(!e)return;let t=_.current.map(q);p.current=t,u(t);let n=Object.fromEntries(g.current.map(e=>[e.id,[...e.items]]));m.current=n,f(n)},[e]);let y=e=>{p.current=e,u(e)},b=(e,t)=>{let n=(m.current[e]??[]).filter(e=>!s(e)),r={...m.current,[e]:t.length?[...t,...n]:n};m.current=r,f(r)},x=new Map(c.map(e=>[q(e),me(e)])),S=t?r.find(e=>e.id===t):void 0,C=S?(d[S.id]??S.items).filter(s):[];return(0,R.jsxs)(k,{open:e,onClose:a,transition:!0,className:`relative z-110`,children:[(0,R.jsx)(A,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":!0}),(0,R.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,R.jsxs)(O,{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,R.jsx)(j,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:M(`nav.sortMenuTitle`)}),(0,R.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:M(`nav.sortHint`)}),(0,R.jsx)(`div`,{className:`mt-4 max-h-80 overflow-auto rounded-lg border border-stone-200 p-1`,children:S?(0,R.jsx)(ke,{ids:C,labelOf:e=>M(h(e).i18n),onChange:e=>b(S.id,e),onEnd:v,indent:!0}):(0,R.jsx)(ke,{ids:l,labelOf:e=>x.get(e)??e,onChange:y,onEnd:v})})]})})]})}function je(e){let t=[];for(let n of e.filter(e=>!e.parentId)){t.push({group:n,indent:!1});for(let r of E(e,n.id))t.push({group:r,indent:!0})}return t}function Me(){return(0,R.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,R.jsx)(`path`,{d:`M7 5l5 5-5 5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}var Ne=120;function Pe(){let[e,t]=(0,N.useState)(null),n=(0,N.useRef)(null),r=(0,N.useCallback)(()=>{n.current!==null&&(window.clearTimeout(n.current),n.current=null)},[]),i=(0,N.useCallback)(e=>{r(),t({value:e,closing:!1})},[r]),a=(0,N.useCallback)(()=>{r(),t(e=>e&&!e.closing?{...e,closing:!0}:e),n.current=window.setTimeout(()=>{n.current=null,t(null)},Ne)},[r]),o=(0,N.useCallback)(()=>{r(),t(null)},[r]);return(0,N.useEffect)(()=>r,[r]),{value:e?.value??null,closing:!!e?.closing,open:i,close:a,closeNow:o}}function Fe(e,t){return{onMouseOver:()=>e?.(),onMouseOut:e=>{let n=e.relatedTarget;n&&e.currentTarget.contains(n)||t?.()}}}function Ie({anchor:e,current:t,itemId:n,closing:r,onPick:i,onHoverEnter:a,onHoverLeave:o}){let s=(0,N.useRef)(null),[c,l]=(0,N.useState)({top:e.top,left:e.right+8});return(0,N.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,P.createPortal)((0,R.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},...Fe(a,o),children:[(0,R.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:M(`nav.chooseIcon`)}),(0,R.jsx)(`div`,{className:`tw-nav-icon-grid`,children:g.map(e=>(0,R.jsx)(`button`,{type:`button`,className:[`tw-nav-icon-cell`,t===e?`is-current`:``].filter(Boolean).join(` `),onClick:()=>i(e),children:(0,R.jsx)(Y,{id:n,icon:e})},e))})]}),document.body)}function Le({rect:e,closing:t=!1,onClose:n,onHoverEnter:r,onHoverLeave:i,children:a}){let o=(0,N.useRef)(null),[s,c]=(0,N.useState)({top:e.top,left:e.right+6});return(0,N.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,N.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,P.createPortal)((0,R.jsx)(`div`,{ref:o,className:[`tw-nav-group-pop`,t?`is-closing`:``].filter(Boolean).join(` `),style:{top:s.top,left:s.left},...Fe(r,i),children:a}),document.body)}function Re(){let e=he(),[t,n]=(0,N.useState)(()=>se()),[i,a]=(0,N.useState)(()=>I()),[o,c]=(0,N.useState)(()=>le()),[d,f]=(0,N.useState)(()=>ie()),[m,g]=(0,N.useState)(null),[_,x]=(0,N.useState)(!1),[S,C]=(0,N.useState)(null),[w,T]=(0,N.useState)(!1),[E,te]=(0,N.useState)(null),D=Pe(),O=Pe(),k=D.value,A=O.value,j=(0,N.useRef)(null);(0,N.useEffect)(()=>()=>{j.current!==null&&window.clearTimeout(j.current)},[]);function oe(e){te(e),T(!0)}function P(e){g(e),x(!0)}function F(){x(!1),C(null)}(0,N.useEffect)(()=>{let e=!0,t=re(e=>{f({...e})});return v().then(async()=>{e&&(await fe(),e&&(n(se()),c(le()),a(I()),f(ie())))}),()=>{e=!1,t()}},[]);let L=ee(t,o);function z(e,t){let r=ue(e,t);n(r.groups),c(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),c(t.order)})}function B(){V(),O.close(),D.close()}function V(){j.current!==null&&(window.clearTimeout(j.current),j.current=null)}function H(){V(),j.current=window.setTimeout(()=>{j.current=null,O.close()},220)}function U(e,t){V(),O.open({itemId:e,rect:t.getBoundingClientRect()})}function W(e,t){k?.kind===`itemMenu`&&k.itemId===e?B():(O.closeNow(),D.open({kind:`itemMenu`,itemId:e,rect:t.getBoundingClientRect()}))}function pe(e,t){k?.kind===`groupMenu`&&k.group.id===e.id?B():(O.closeNow(),D.open({kind:`groupMenu`,group:e,rect:t.getBoundingClientRect()}))}function G(e,n){z(p(t,e,n),o),B()}function me(e){let{groups:n,owner:r}=y(t,e);z(n,r?l(o,e,r,n):o),B()}let q=k?.kind===`assign`||k?.kind===`itemMenu`?k.itemId:void 0,J=k?.kind===`groupMenu`?k.group.id:void 0,Y=k?.kind===`itemMenu`?k:null,X=k?.kind===`groupMenu`?k:null,Z=k?.kind===`assign`?k:null,Q=Y?t.find(e=>e.items.includes(Y.itemId))??null:null;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`tw-nav-ready`,"aria-hidden":`true`}),L.map(n=>n.type===`item`?$(n.id,d)?(0,R.jsx)(we,{id:n.id,icon:i[n.id],pathname:e,actionOpen:q===n.id,onMenu:e=>W(n.id,e)},n.id):null:(0,R.jsx)(De,{group:n.group,groups:t,icons:i,pathname:e,openItem:q,openGroupId:J,onMenu:pe,onItemMenu:W},n.group.id)),Y?(0,R.jsxs)(Le,{rect:Y.rect,closing:D.closing,onClose:B,onHoverEnter:V,onHoverLeave:H,children:[(0,R.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:M(h(Y.itemId).i18n)}),(0,R.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(),O.close())},children:[Q?(0,R.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item is-leave`,onClick:()=>me(Y.itemId),children:[(0,R.jsx)(ye,{}),(0,R.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:M(`nav.leaveGroup`)})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>D.open({kind:`assign`,itemId:Y.itemId,rect:Y.rect}),children:[(0,R.jsx)(ve,{}),(0,R.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:M(`nav.assignGroup`)})]}),(0,R.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=Y.itemId;B(),P({name:``,items:[e]})},children:[(0,R.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,R.jsx)(_e,{})}),(0,R.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:M(`nav.addToGroup`)})]})]}),(0,R.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=Q?.id??null;B(),oe(e)},children:[(0,R.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,R.jsx)(xe,{})}),(0,R.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:M(`nav.sortMenu`)})]}),(0,R.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,R.jsx)(be,{}),(0,R.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:M(`nav.chooseIcon`)}),(0,R.jsx)(Me,{})]})]})]}):null,A&&Y&&A.itemId===Y.itemId?(0,R.jsx)(Ie,{anchor:A.rect,itemId:A.itemId,current:i[A.itemId],closing:O.closing,onHoverEnter:V,onHoverLeave:H,onPick:e=>{a(ce(A.itemId,e)),B()}}):null,X?(0,R.jsxs)(Le,{rect:X.rect,closing:D.closing,onClose:B,children:[(0,R.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:K(X.group)}),(0,R.jsxs)(`div`,{className:`tw-nav-group-pop-list`,children:[X.group.parentId?null:(0,R.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,R.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,R.jsx)(_e,{})}),(0,R.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:M(`nav.addSubgroup`)})]}),(0,R.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,R.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,R.jsx)(ge,{})}),(0,R.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:M(`nav.editGroupTitle`)})]})]})]}):null,Z?(0,R.jsxs)(Le,{rect:Z.rect,closing:D.closing,onClose:B,children:[(0,R.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:M(`nav.assignGroup`)}),(0,R.jsx)(`div`,{className:`tw-nav-group-pop-list`,children:t.length?je(t).map(({group:e,indent:t})=>{let n=e.items.includes(Z.itemId);return(0,R.jsxs)(`button`,{type:`button`,className:[`tw-nav-group-pop-item`,n?`is-current`:``,t?`is-child`:``].filter(Boolean).join(` `),onClick:()=>{n||G(e.id,Z.itemId)},children:[(0,R.jsx)(ve,{}),(0,R.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:K(e)}),n?(0,R.jsx)(`span`,{className:`tw-nav-group-pop-tag`,children:M(`nav.currentGroup`)}):null]},e.id)}):(0,R.jsx)(`div`,{className:`tw-nav-group-pop-empty`,children:M(`nav.noGroups`)})})]}):null,(0,R.jsx)(Oe,{open:_&&!S,draft:m,groups:t,plugins:d,icons:i,onClose:F,onSave:e=>{let n=u(t,e);z(n.groups,r(o,n.groups,n.id)),F()},onDelete:m?.id?()=>C(m.id):void 0}),(0,R.jsx)(Ae,{open:w,focusGroupId:E,nodes:L,groups:t,visible:e=>$(e,d),onClose:()=>T(!1),onCommit:(e,t)=>z(t,e)}),(0,R.jsx)(ae,{open:!!S,title:M(`nav.deleteGroup`),message:t.find(e=>e.id===S)?.parentId?M(`nav.deleteSubgroupMsg`):M(`nav.deleteGroupMsg`),confirmLabel:M(`nav.deleteGroup`),cancelLabel:M(`nav.groupCancel`),danger:`outline`,onClose:()=>C(null),onConfirm:()=>{if(S){let e=t.find(e=>e.id===S),n=ne(t,S),r=s(t,S);z(r,e?b(o,e,r,n):o)}F()}})]})}export{Re as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{t as default}from"./PluginsPage.Oh8hWup8.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.Crg0VdkS.js";import{a as r,o as i,r as a}from"./plugins.CNOYmeAe.js";import{t as o}from"./ConfirmDialog.Dbyjb4-6.js";import{t as s}from"./jsx-runtime.BUXbF_vF.js";import{n as c,t as ee}from"./DocsPager.DaiWchhj.js";import{a as l,c as te,f as ne,h as u,i as re,l as ie,m as ae,n as oe,o as d,p as se,r as ce,s as f,t as le,u as ue}from"./project-docs.Cd2gKPKh.js";import{n as p}from"./doc-roots.DAJP9Svr.js";import{t as de}from"./useListAnim.CpGB1cft.js";import{t as m}from"./NamePromptDialog.DZSZ5Y16.js";var h=e(t(),1),g=s(),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)(()=>a(`requirements`)),[s,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]=c(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 re(`requirements`);he(e.tree),_e(e.totalFiles)},[]),q=(0,h.useCallback)(async(e=w)=>{j(null);try{let[t]=await Promise.all([f(`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=r(e=>t(!!e.requirements));return n().then(()=>{t(a(`requirements`)),x(!0)}),e},[]),(0,h.useEffect)(()=>{s&&e&&(async()=>{let e=await ce(`requirements`);if(me(e),e)try{let[e]=await Promise.all([f(`requirements`,`.`),K()]);D(e.entries),T(e.path)}catch(e){j(e instanceof Error?e.message:String(e))}})()},[s,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 f(`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 te(`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 ie(`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 u(`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=l(C,e.path),n=t?.fileCount??0,r=t?le(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 oe(`requirements`,e.path),P&&d(P.path,e.path)&&F(null);let t=d(w,e.path)?ue(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 ae(`requirements`,t.path,e);await q(se(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 ne(`requirements`,e.path);F({path:t.path,content:t.content})}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}if(!s)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:i(`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:p(`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)(ee,{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)(o,{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{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{a as n,i as r,n as i,s as ee}from"./app-config.Crg0VdkS.js";import{i as a,n as te,r as ne,t as re}from"./listbox.Di-t5U37.js";import{o as ie,s as ae,t as oe}from"./ConfirmDialog.Dbyjb4-6.js";import{t as o}from"./jsx-runtime.BUXbF_vF.js";import{i as se}from"./llm.BZEzE0x2.js";import{_ as ce,a as s,c as le,d as ue,g as c,h as de,i as fe,l,n as u,o as pe,r as me,s as he,t as ge,u as _e,v as ve}from"./settings.DBIYsQY-.js";import{n as d}from"./i18n.C8FKLrB5.js";var f=e(t(),1),ye=`0.1.4`,p=o();function be(e){try{return new URL(e).host}catch{return``}}var xe=[{value:`zh-CN`,label:`中文`},{value:`en`,label:`English`}],m=`w-full px-3 py-2 text-sm border border-stone-300 rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-[#4176e6]/35 focus:border-[#4176e6] transition-colors`,h=`inline-flex items-center gap-1.5 h-9 min-w-30 px-3 rounded-lg bg-stone-100 text-sm text-stone-700 hover:bg-stone-200/80 transition-colors outline-none focus:outline-none`;function Se({className:e=`w-3.5 h-3.5`}){return(0,p.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:(0,p.jsx)(`path`,{d:`M6 8l4 4 4-4`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function g({className:e=`w-4 h-4`}){return(0,p.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,p.jsx)(`path`,{d:`M5 10.5l3.5 3.5L15 6.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function Ce({className:e=`w-4 h-4`}){return(0,p.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,p.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,p.jsx)(`path`,{d:`M12 1v2M12 21v2M4.2 4.2l1.4 1.4M18.4 18.4l1.4 1.4M1 12h2M21 12h2M4.2 19.8l1.4-1.4M18.4 5.6l1.4-1.4`})]})}function we({className:e=`w-4 h-4`}){return(0,p.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,p.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,p.jsx)(`path`,{d:`M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5`}),(0,p.jsx)(`path`,{d:`M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]})}function Te({kind:e}){let t=`w-5 h-5`;return e===`sun`?(0,p.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,p.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,p.jsx)(`path`,{d:`M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`})]}):e===`moon`?(0,p.jsx)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,p.jsx)(`path`,{d:`M21 14.5A8.5 8.5 0 1 1 9.5 3a7 7 0 0 0 11.5 11.5z`})}):(0,p.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,p.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`12`,rx:`2`}),(0,p.jsx)(`path`,{d:`M8 20h8M12 16v4`})]})}function _({title:e,description:t,control:n}){return(0,p.jsxs)(`div`,{className:`flex items-center gap-4 py-4 border-b border-stone-100 last:border-b-0`,children:[(0,p.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,p.jsx)(`div`,{className:`text-sm font-medium text-stone-800`,children:e}),t?(0,p.jsx)(`div`,{className:`mt-0.5 text-xs text-stone-400 leading-5`,children:t}):null]}),(0,p.jsx)(`div`,{className:`shrink-0`,children:n})]})}function v({value:e,options:t,onChange:n}){let r=t.find(t=>t.value===e)?.label??e;return(0,p.jsxs)(ne,{value:e,onChange:n,children:[(0,p.jsxs)(a,{className:h,children:[(0,p.jsx)(`span`,{className:`flex-1 text-left truncate`,children:r}),(0,p.jsx)(Se,{className:`w-3.5 h-3.5 text-stone-400 shrink-0`})]}),(0,p.jsx)(re,{transition:!0,anchor:{to:`bottom end`,gap:6},className:`tw-select-menu tw-menu-anim z-60 min-w-40 rounded-xl py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:t.map(e=>(0,p.jsxs)(te,{value:e.value,className:`group cursor-pointer select-none flex items-center justify-between gap-3 px-3 py-2 text-sm text-stone-700 data-[focus]:bg-stone-50 data-[selected]:text-stone-900`,children:[(0,p.jsx)(`span`,{children:e.label}),(0,p.jsx)(g,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0`})]},e.value))})]})}function y(){let[e,t]=(0,f.useState)(!1),[o,h]=(0,f.useState)(`general`),[y,b]=(0,f.useState)([]),[x,S]=(0,f.useState)(``),[C,w]=(0,f.useState)(null),[T,E]=(0,f.useState)(``),[Ee,D]=(0,f.useState)(`DeepSeek`),[O,k]=(0,f.useState)(``),[A,j]=(0,f.useState)(``),[M,N]=(0,f.useState)(``),[P,F]=(0,f.useState)([]),[I,L]=(0,f.useState)(`idle`),[De,R]=(0,f.useState)(!1),[Oe,z]=(0,f.useState)(`readonly`),[ke,Ae]=(0,f.useState)(!1),[je,B]=(0,f.useState)(!1),[Me,V]=(0,f.useState)(null),[H,U]=(0,f.useState)({language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``}),[W,G]=(0,f.useState)(`14`),K=(0,f.useRef)(0),q=C!==null,J=H.language,Y=y.find(e=>e.id===x),X=(Y?.name||``).trim(),Ne=X||(J===`en`?`No model`:`未配置`),Pe=X?Y?.model?.trim()?`${X} · ${Y.model.trim()}`:X:J===`en`?`No model configured`:`未配置模型`;function Fe(e=`general`){h(e),r().then(()=>{Z(),t(!0)})}function Z(){Ae(n()),b(le()),S(s()),B(!!l()),U(he()),me(he()),z(pe()),w(null)}function Ie(e){if(!e){let e=ee();w(e),E(`DeepSeek`),D(`DeepSeek`),k(`https://api.deepseek.com/v1`),j(``),N(``),F([]),L(`idle`),R(!1);return}w(e.id),E(e.name),k(e.baseURL);let t=e.apiKey?.trim()||(e.id===s()?i().trim():``)||``;j(t),N(e.model),F(e.availableModels??[]),L(e.availableModels?.length?`ok`:`idle`),D(u.find(t=>t.baseURL===e.baseURL)?.label??`自定义`),R(!1)}(0,f.useEffect)(()=>{r().then(()=>Z());let e=e=>{let n=e.detail;h(n?.tab===`model`?`model`:`general`),r().then(()=>{Z(),t(!0)})};window.addEventListener(ge,e);let n=ue(e=>U(e)),i=_e(e=>z(e));return()=>{window.removeEventListener(ge,e),n(),i()}},[]),(0,f.useEffect)(()=>{if(!e||o!==`model`||!q)return;let t=O.trim(),n=A.trim();if(!t||!n){L(e=>e===`ok`?`ok`:`idle`);return}L(`loading`);let r=++K.current,i=setTimeout(()=>{se(t,n).then(e=>{r===K.current&&(F(e),L(`ok`))}).catch(()=>{r===K.current&&L(`fail`)})},800);return()=>clearTimeout(i)},[e,o,q,O,A]);function Le(e){D(e);let t=u.find(t=>t.label===e);t&&(t.baseURL&&k(t.baseURL),(!T.trim()||u.some(e=>e.label===T))&&E(t.label)),N(``)}function Q(e){U(c(e))}(0,f.useEffect)(()=>{G(String(H.sessionFontSize))},[H.sessionFontSize]);function Re(){let e=Number(W);if(!W.trim()||!Number.isFinite(e)){G(String(H.sessionFontSize));return}let t=c({sessionFontSize:Math.round(e)});U(t),G(String(t.sessionFontSize))}let ze=!!(T.trim()&&O.trim()&&A.trim()&&M.trim()),$=P.length>0;function Be(){if(!ze||!C)return;let e=ve({id:C,name:T.trim(),baseURL:O.trim(),apiKey:A.trim(),model:M.trim(),availableModels:$?P:void 0},{activate:!0});b(e),S(C),w(null),B(!!l())}function Ve(e){V(e)}function He(){let e=Me;if(!e)return;V(null);let t=fe(e);b(t),S(s()),C===e&&w(null),B(!!l())}function Ue(e){ce(e),S(e),B(!!l())}let We=[{value:`readonly`,label:d(`settings.access.readonly`,void 0,J)},{value:`readwrite`,label:d(`settings.access.readwrite`,void 0,J)},{value:`full`,label:d(`settings.access.full`,void 0,J)}],Ge=[{value:`concise`,label:d(`settings.step.concise`,void 0,J)},{value:`standard`,label:d(`settings.step.standard`,void 0,J)},{value:`detailed`,label:d(`settings.step.detailed`,void 0,J)},{value:`full`,label:d(`settings.step.full`,void 0,J)}],Ke=[{value:`queue`,label:d(`settings.busySend.queue`,void 0,J)},{value:`interrupt`,label:d(`settings.busySend.interrupt`,void 0,J)}],qe=[{value:`light`,label:d(`settings.appear.light`,void 0,J),icon:`sun`},{value:`dark`,label:d(`settings.appear.dark`,void 0,J),icon:`moon`},{value:`system`,label:d(`settings.appear.system`,void 0,J),icon:`monitor`}],Je=[{id:`general`,label:d(`settings.general`,void 0,J),icon:(0,p.jsx)(Ce,{})},{id:`model`,label:d(`settings.model`,void 0,J),icon:(0,p.jsx)(we,{})}],Ye=o===`general`?d(`settings.general`,void 0,J):q?y.some(e=>e.id===C)?d(`settings.editProvider`,void 0,J):d(`settings.addProviderTitle`,void 0,J):d(`settings.model`,void 0,J);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`tw-nav-foot-row`,children:[(0,p.jsxs)(`button`,{type:`button`,onClick:()=>Fe(`general`),className:`tw-nav-settings-btn`,"data-hint":je?`设置(已配置模型)`:`设置`,children:[(0,p.jsxs)(`svg`,{className:`tw-nav-ico w-4.5 h-4.5 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":`true`,children:[(0,p.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,p.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,p.jsx)(`span`,{"data-i18n":`nav.settings`,children:d(`nav.settings`,void 0,J)})]}),(0,p.jsxs)(`button`,{type:`button`,className:`tw-nav-provider-chip${X?``:` is-empty`}`,"data-hint":Pe,onClick:()=>Fe(`model`),children:[(0,p.jsx)(`span`,{className:`tw-nav-provider-dot`,"aria-hidden":`true`}),(0,p.jsx)(`span`,{className:`tw-nav-provider-name`,children:Ne})]})]}),(0,p.jsx)(ie,{show:e,children:(0,p.jsxs)(`div`,{className:`fixed inset-0 z-110 flex items-center justify-center p-4`,children:[(0,p.jsx)(ae,{children:(0,p.jsx)(`div`,{className:`tw-dialog-backdrop-anim absolute inset-0 bg-stone-950/45`,onClick:()=>t(!1),"aria-hidden":`true`})}),(0,p.jsx)(ae,{children:(0,p.jsxs)(`div`,{className:`tw-settings-dialog tw-dialog-panel-anim relative bg-white rounded-2xl shadow-2xl w-full max-w-3xl h-[min(92vh,720px)] overflow-hidden flex flex-col`,children:[(0,p.jsxs)(`div`,{className:`shrink-0 h-12 px-4 flex items-center justify-between border-b border-stone-100 bg-white`,children:[(0,p.jsx)(`h2`,{className:`text-sm font-semibold text-stone-800 truncate pr-3`,children:Ye}),(0,p.jsx)(`button`,{type:`button`,"aria-label":d(`settings.close`,void 0,J),onClick:()=>t(!1),className:`w-8 h-8 inline-flex items-center justify-center rounded-lg text-stone-400 hover:text-stone-700 hover:bg-stone-100 transition-colors`,children:(0,p.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,p.jsx)(`path`,{d:`M5 5l10 10M15 5L5 15`,strokeLinecap:`round`})})})]}),(0,p.jsxs)(`div`,{className:`flex-1 min-h-0 flex`,children:[(0,p.jsx)(`aside`,{className:`w-38 shrink-0 border-r border-stone-100 bg-[#f4f5f7] py-3 px-2 space-y-0.5`,children:Je.map(e=>{let t=o===e.id;return(0,p.jsxs)(`button`,{type:`button`,onClick:()=>{h(e.id),e.id===`model`&&w(null)},className:`w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-sm transition-colors ${t?`bg-[#e8f0fe] text-[#4176e6] font-medium`:`text-stone-600 hover:bg-white/70 hover:text-stone-800`}`,children:[(0,p.jsx)(`span`,{className:t?`text-[#4176e6]`:`text-stone-400`,children:e.icon}),e.label]},e.id)})}),(0,p.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col min-h-0 bg-white`,children:o===`general`?(0,p.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,p.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-1`,children:[(0,p.jsx)(_,{title:d(`settings.access`,void 0,J),description:d(`settings.accessDesc`,void 0,J),control:(0,p.jsx)(v,{value:Oe,options:We,onChange:e=>{z(e),de(e)}})}),(0,p.jsx)(_,{title:d(`settings.language`,void 0,J),control:(0,p.jsx)(v,{value:H.language,options:xe,onChange:e=>Q({language:e})})}),(0,p.jsxs)(`div`,{className:`py-4 border-b border-stone-100`,children:[(0,p.jsx)(`div`,{className:`text-sm font-medium text-stone-800 mb-3`,children:d(`settings.appearance`,void 0,J)}),(0,p.jsx)(`div`,{className:`grid grid-cols-3 gap-2.5`,children:qe.map(e=>{let t=H.appearance===e.value;return(0,p.jsxs)(`button`,{type:`button`,onClick:()=>Q({appearance:e.value}),className:`flex flex-col items-center justify-center gap-2 h-19 rounded-xl border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] text-[#4176e6] ring-1 ring-[#4176e6]/30`:`border-stone-200 text-stone-500 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,p.jsx)(Te,{kind:e.icon}),(0,p.jsx)(`span`,{className:`text-xs font-medium`,children:e.label})]},e.value)})})]}),(0,p.jsx)(_,{title:d(`settings.fontSize`,void 0,J),description:d(`settings.fontSizeDesc`,void 0,J),control:(0,p.jsxs)(`div`,{className:`inline-flex items-center gap-1.5`,children:[(0,p.jsx)(`input`,{type:`number`,min:12,max:22,value:W,onChange:e=>G(e.target.value),onBlur:Re,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},className:`w-14 h-9 px-2 text-sm text-center rounded-lg bg-stone-100 border-0 outline-none focus:ring-2 focus:ring-[#4176e6]/30`}),(0,p.jsx)(`span`,{className:`text-sm text-stone-400`,children:`px`})]})}),(0,p.jsx)(_,{title:d(`settings.toolSteps`,void 0,J),description:d(`settings.toolStepsDesc`,void 0,J),control:(0,p.jsx)(v,{value:H.toolStepDetail,options:Ge,onChange:e=>Q({toolStepDetail:e})})}),(0,p.jsx)(_,{title:d(`settings.busySend`,void 0,J),description:d(`settings.busySendDesc`,void 0,J),control:(0,p.jsx)(v,{value:H.busySendBehavior,options:Ke,onChange:e=>Q({busySendBehavior:e})})}),(0,p.jsx)(_,{title:d(`settings.subagentModel`,void 0,J),description:d(`settings.subagentModelDesc`,void 0,J),control:(0,p.jsx)(v,{value:H.subagentModel?.trim()?H.subagentModel:`inherit`,options:[{value:`inherit`,label:d(`settings.subagentModel.inherit`,void 0,J)},...Array.from(new Set([...Y?.availableModels??[],...Y?.model?[Y.model]:[]])).filter(Boolean).map(e=>({value:e,label:e}))],onChange:e=>Q({subagentModel:e===`inherit`?``:e})})})]}),(0,p.jsxs)(`div`,{className:`shrink-0 px-6 py-3 border-t border-stone-100 flex items-center justify-between text-[11px] text-stone-400`,children:[(0,p.jsx)(`span`,{children:d(`settings.platformVersion`,void 0,J)}),(0,p.jsxs)(`span`,{className:`tabular-nums text-stone-500`,children:[`v`,ye]})]})]}):q?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`shrink-0 px-5 pt-3 pb-2 flex items-center gap-2 border-b border-stone-100`,children:(0,p.jsx)(`button`,{type:`button`,onClick:()=>w(null),className:`text-sm text-stone-500 hover:text-stone-800`,children:d(`settings.back`,void 0,J)})}),(0,p.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:d(`settings.displayName`,void 0,J)}),(0,p.jsx)(`input`,{type:`text`,value:T,onChange:e=>E(e.target.value),placeholder:`DeepSeek`,className:m})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:d(`settings.preset`,void 0,J)}),(0,p.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:u.map(e=>{let t=Ee===e.label;return(0,p.jsxs)(`button`,{type:`button`,onClick:()=>Le(e.label),className:`text-left px-3 py-2 rounded-lg border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] ring-1 ring-[#4176e6]/30`:`border-stone-200 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,p.jsx)(`div`,{className:`text-sm ${t?`text-[#3565c7] font-medium`:`text-stone-700`}`,children:e.label}),(0,p.jsx)(`div`,{className:`text-[11px] text-stone-400 truncate`,children:e.baseURL?be(e.baseURL):`OpenAI compatible`})]},e.label)})})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:d(`settings.baseUrl`,void 0,J)}),(0,p.jsx)(`input`,{type:`text`,value:O,onChange:e=>k(e.target.value),placeholder:`https://api.deepseek.com/v1`,className:m})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:d(`settings.apiKey`,void 0,J)}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(`input`,{type:De?`text`:`password`,value:A,onChange:e=>j(e.target.value),placeholder:`sk-...`,className:`${m} pr-14`}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>R(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-[11px] text-stone-400 hover:text-stone-600 px-1.5 py-1`,children:De?J===`en`?`Hide`:`隐藏`:J===`en`?`Show`:`显示`})]}),ke?(0,p.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-5`,children:d(`settings.keyHint`,void 0,J)}):null]}),(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,p.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,children:d(`settings.modelField`,void 0,J)}),I===`loading`&&(0,p.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:d(`settings.recognizing`,void 0,J)}),$&&I===`ok`&&(0,p.jsx)(`span`,{className:`text-[11px] text-emerald-600`,children:d(`settings.recognized`,{n:P.length},J)}),I===`fail`&&!$&&(0,p.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:d(`settings.recognizeFail`,void 0,J)}),I===`fail`&&$&&(0,p.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:d(`settings.recognizeKeep`,void 0,J)})]}),$?(0,p.jsxs)(ne,{value:M,onChange:N,children:[(0,p.jsxs)(a,{className:`${m} flex items-center justify-between text-left hover:border-stone-400 cursor-pointer`,children:[(0,p.jsx)(`span`,{className:`truncate text-stone-800`,children:M||(J===`en`?`Select a model`:`请选择模型`)}),(0,p.jsx)(Se,{className:`w-4 h-4 shrink-0 ml-2 text-stone-400`})]}),(0,p.jsx)(re,{transition:!0,anchor:{to:`bottom start`,gap:6},className:`tw-select-menu tw-menu-anim z-60 w-(--button-width) max-h-60 overflow-auto rounded-lg py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:P.map(e=>(0,p.jsxs)(te,{value:e,className:`group cursor-pointer select-none flex items-center justify-between px-3 py-2 text-sm text-stone-700 data-[focus]:bg-[#edf3fe] data-[selected]:text-[#3565c7] data-[selected]:font-medium`,children:[(0,p.jsx)(`span`,{className:`truncate`,children:e}),(0,p.jsx)(g,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0 ml-2`})]},e))})]}):(0,p.jsx)(`input`,{type:`text`,value:M,onChange:e=>N(e.target.value),placeholder:d(`settings.modelPlaceholder`,void 0,J),className:m})]})]}),(0,p.jsxs)(`div`,{className:`shrink-0 px-5 py-3.5 bg-stone-50 border-t border-stone-100 flex justify-end gap-2`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:()=>w(null),className:`px-3.5 py-1.5 text-sm text-stone-600 hover:bg-stone-200/60 rounded-lg`,children:d(`settings.cancel`,void 0,J)}),(0,p.jsx)(`button`,{type:`button`,onClick:Be,disabled:!ze,className:`px-3.5 py-1.5 text-sm font-medium text-white bg-[#4176e6] hover:bg-[#3565c7] rounded-lg disabled:opacity-40 disabled:cursor-not-allowed`,children:d(`settings.save`,void 0,J)})]})]}):(0,p.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-5 bg-[#f4f5f7]`,children:[(0,p.jsx)(`p`,{className:`text-sm text-stone-500`,children:d(`settings.modelIntro`,void 0,J)}),(0,p.jsxs)(`div`,{className:`mt-5 space-y-2.5`,children:[y.map(e=>{let t=!!(e.apiKey?.trim()&&e.baseURL.trim()&&e.model.trim()),n=e.id===x;return(0,p.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-stone-200/90 bg-white px-4 py-3.5 shadow-[0_1px_0_rgba(15,23,42,0.02)]`,children:[(0,p.jsxs)(`button`,{type:`button`,"data-hint":n?J===`en`?`Active`:`当前使用`:J===`en`?`Set active`:`设为当前`,onClick:()=>Ue(e.id),className:`flex-1 min-w-0 flex items-center gap-2 text-left`,children:[(0,p.jsx)(`span`,{className:`text-sm font-medium text-stone-800 truncate`,children:e.name}),t?(0,p.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 bg-emerald-500`}):null]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:()=>Ie(e),className:`h-8 px-3 text-sm text-stone-700 rounded-lg border border-stone-200 bg-white hover:bg-stone-50`,children:d(`settings.edit`,void 0,J)}),y.length>1?(0,p.jsx)(`button`,{type:`button`,onClick:()=>Ve(e.id),className:`h-8 px-3 text-sm text-red-600 rounded-lg hover:bg-red-50`,children:d(`settings.delete`,void 0,J)}):null]})]},e.id)}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>Ie(null),className:`w-full h-12 rounded-xl border border-dashed border-stone-300 bg-white/60 text-sm text-stone-600 hover:border-[#4176e6] hover:text-[#4176e6] hover:bg-[#edf3fe]/50 transition-colors`,children:d(`settings.addProvider`,void 0,J)})]})]})})]})]})})]})}),(0,p.jsx)(oe,{open:Me!=null,title:d(`settings.delete`,void 0,J),message:d(`settings.deleteConfirm`,void 0,J),confirmLabel:d(`settings.delete`,void 0,J),cancelLabel:J===`en`?`Cancel`:`取消`,danger:!0,onClose:()=>V(null),onConfirm:He})]})}export{y as default};
|
|
@@ -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.Crg0VdkS.js";import{a as i,i as a,n as o,r as s,t as c}from"./ConfirmDialog.Dbyjb4-6.js";import{i as l,n as u,r as ee,t as d}from"./menu.Bkluqxic.js";import{t as f}from"./jsx-runtime.BUXbF_vF.js";import{n as p}from"./llm.BZEzE0x2.js";import{f as m}from"./project-docs.Cd2gKPKh.js";import{t as h}from"./prompts-meta.F4wwkjUA.js";import{l as te}from"./settings.DBIYsQY-.js";import{n as g}from"./i18n.C8FKLrB5.js";var _=e(t(),1),v=`/__tb_spaces`;async function y(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 b(e){try{return(await fetch(v,{signal:e??AbortSignal.timeout(2e3)})).ok}catch{return!1}}async function ne(e){try{let t=e?.stats?`${v}?stats=1`:v,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 re(e){let t=await y(`${v}/switch`,{id:e});return t.ok&&n(e),t}function ie(e,t){return y(`${v}/create`,{name:e,managedParent:t?.managedParent,switch:t?.switch===!0,systemPrompt:t?.systemPrompt,promptBrief:t?.promptBrief})}function x(e){let t=e instanceof Error?e.message:String(e??``);return!t.trim()||/^not found$/i.test(t.trim())?`本地服务版本较旧,还没有空间编辑接口;请重启本地服务后再试`:t}async function ae(e){try{let t=await fetch(`${v}/detail?id=${encodeURIComponent(e)}`),n=await t.json();return t.ok?n:{ok:!1,error:x(n?.error??`HTTP ${t.status}`)}}catch(e){return{ok:!1,error:x(e)}}}async function oe(e,t){let n=await y(`${v}/update`,{id:e,...t});return n.ok?n:{...n,error:x(n.error)}}function se(e,t){return y(`${v}/copy`,{id:e,name:t})}function ce(e,t){return y(`${v}/delete`,{id:e,purge:t,confirm:t===!0})}function le(e,t=`full`){return`${v}/export?id=${encodeURIComponent(e)}${t===`content`?`&scope=content`:``}`}function ue(e){return y(`${v}/discover`,Array.isArray(e)&&e.length?{adopt:e}:{})}async function de(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 y(`${v}/import`,{zipBase64:o,name:t})}function S(e){return e.isPublic?g(`space.publicName`):e.name}function C(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 fe(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 pe=`你是提示词作者。根据用户对这个数据空间的要求,写一份「默认提示词」正文(Markdown 纯文本,不要用代码围栏)。
|
|
2
|
-
这份提示词将作为 Lantern Harness 该空间里 AI 助手的默认人设与回答原则。
|
|
3
|
-
要求:
|
|
4
|
-
- 用「你是…」起头设定角色;
|
|
5
|
-
- 紧扣用户描述的领域与工作方式;
|
|
6
|
-
- 写几条简洁的回答原则(问什么答什么、先结论);
|
|
7
|
-
- 只输出提示词正文,不要解释、不要标题。`;function me(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 w=f();function he(e){return e instanceof DOMException&&e.name===`AbortError`||e instanceof Error&&e.name===`AbortError`}function ge({hint:e,children:t}){return e?(0,w.jsx)(`span`,{className:`inline-flex cursor-help`,"data-hint":e,"data-hint-always":``,children:t}):t}function _e(e){let{value:t,onChange:n,onGenerate:r,onStop:i,generating:a,disabled:o}=e,s=(0,_.useRef)(null);(0,_.useLayoutEffect)(()=>{let e=s.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,96)}px`)},[t]);let c=!!t.trim()&&!a&&!o;return(0,w.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,w.jsx)(`textarea`,{ref:s,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing){if(e.preventDefault(),a){i();return}c&&r()}},placeholder:g(`space.promptBriefPlaceholder`),rows:1,disabled:o,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,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-2 px-3 pb-2 pt-1`,children:[(0,w.jsx)(`span`,{className:`flex-1`}),(0,w.jsx)(`button`,{type:`button`,onClick:()=>a?i():r(),disabled:!a&&!c,"aria-label":g(a?`space.promptStop`:`space.promptGenerate`),className:`w-7 h-7 shrink-0 rounded-full flex items-center justify-center outline-none transition-colors ${a?`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:a?(0,w.jsx)(`span`,{className:`w-2.5 h-2.5 bg-current rounded-xs`}):(0,w.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:`w-4 h-4`,"aria-hidden":!0,children:[(0,w.jsx)(`path`,{d:`m5 12 7-7 7 7`}),(0,w.jsx)(`path`,{d:`M12 19V5`})]})})]})]})}function ve(e){return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2 mb-1.5`,children:[(0,w.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,children:g(`space.promptBodyLabel`)}),(0,w.jsx)(`span`,{className:`text-[11px] text-stone-400 font-mono truncate`,children:h})]}),(0,w.jsx)(`textarea`,{value:e.value,onChange:t=>e.onChange(t.target.value),placeholder:g(`space.promptBodyPlaceholder`),rows:8,disabled:e.disabled,className:`w-full min-h-36 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]`}),(0,w.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-snug`,children:e.hint??g(`space.promptHint`)})]})}function T({open:e,onClose:t,onListChanged:l}){let[u,ee]=(0,_.useState)(null),[d,f]=(0,_.useState)(null),[v,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(``),[T,E]=(0,_.useState)(!1),[D,O]=(0,_.useState)(``),[k,A]=(0,_.useState)(``),[j,M]=(0,_.useState)(``),[N,P]=(0,_.useState)(null),[F,I]=(0,_.useState)(``),[L,R]=(0,_.useState)(``),[ye,z]=(0,_.useState)(``),[B,be]=(0,_.useState)(!1),[xe,Se]=(0,_.useState)(!1),[V,H]=(0,_.useState)(null),[U,W]=(0,_.useState)(null),[Ce,we]=(0,_.useState)(``),[G,K]=(0,_.useState)([]),[Te,q]=(0,_.useState)({}),Ee=(0,_.useRef)(null),De=(0,_.useRef)(null),Oe=(0,_.useRef)(null),J=(0,_.useRef)(null),[ke,Ae]=(0,_.useState)(null),Y=(0,_.useCallback)(async(e=!1)=>{e&&f(`stats`);let t=await ne({stats:e});e&&f(null),t?(ee(t),l?.(t)):y(`无法读取数据空间列表(本地服务未运行?)`)},[l]),je=(0,_.useRef)(Y);(0,_.useEffect)(()=>{je.current=Y},[Y]);function X(){J.current?.abort()}(0,_.useEffect)(()=>{e?(y(``),x(``),E(!1),P(null),je.current(!1)):(X(),E(!1),P(null),Ae(null))},[e]);async function Me(e){if(ke||d!==null)return;let t=(e===`create`?k:L).trim();if(!t){y(g(`space.promptNeedReq`));return}y(``);let n=new AbortController;J.current=n,Ae(e);try{await r();let i=te();if(!i?.apiKey?.trim()||!i.model?.trim()||!i.baseURL?.trim()){y(g(`space.promptNeedModel`));return}let a=(e===`create`?D:F).trim(),o=await p(i,[{role:`system`,content:pe},{role:`user`,content:(a?`空间名称:${a}\n\n`:``)+`用户要求:\n${t}`}],n.signal);if(n.signal.aborted)return;let s=me(o);if(!s){y(g(`space.promptGenEmpty`));return}e===`create`?M(s):z(s)}catch(e){if(he(e)||n.signal.aborted)return;y(e instanceof Error?e.message:String(e))}finally{J.current===n&&(J.current=null),Ae(null)}}function Ne(){X(),y(``),x(``),O(``),A(``),M(``),E(!0),requestAnimationFrame(()=>De.current?.scrollIntoView({block:`nearest`}))}async function Pe(){if(d!==null)return;let e=D.trim();if(!e){y(g(`space.needName`));return}X();let t=j.trim(),r=k.trim();f(`create`),y(``);let i=await ie(e,{switch:!0,...t?{systemPrompt:t}:{},...r?{promptBrief:r}:{}});if(f(null),!i.ok){y(i.error||g(`space.create`)+` 失败`);return}let a=i.space?.id;a&&n(a),window.location.reload()}async function Fe(e){X(),y(``),x(``),P(e),I(e.name),R(``),Se(!1),z(``),be(!0),requestAnimationFrame(()=>Oe.current?.scrollIntoView({block:`nearest`}));let t=await ae(e.id),n=``,r=``;if(t.ok)n=t.brief??``,r=t.systemPrompt??``;else if(e.isActive)try{r=(await m(`prompts`,h)).content.trim()}catch{}if(be(!1),!t.ok&&!r){P(null),y(t.error||g(`space.detailFailed`));return}t.space&&I(t.space.name),z(r);let i=!n.trim()&&!!r;R(i?r:n),Se(i)}async function Ie(){if(!N||d!==null)return;let e=F.trim();if(!e){y(g(`space.needName`));return}X(),f(`update`),y(``);let t=await oe(N.id,{name:e,...xe?{}:{brief:L},systemPrompt:ye});if(f(null),!t.ok){y(t.error||g(`space.updateFailed`));return}let n=!!(t.space&&t.space.name!==N.name),r=N.isActive;P(null),x(g(`space.updated`,{name:t.space?.name??e})),n&&r?window.location.reload():await Y(!1)}async function Le(e){if(e.isActive||d!==null)return;f(`update`),y(``);let t=await re(e.id);f(null),t.ok?window.location.reload():y(t.error||`切换失败`)}async function Re(){if(!U)return;let e=Ce.trim();if(!e)return;f(`copy`),y(``);let t=await se(U.id,e);f(null),t.ok?(W(null),x(`已复制为「${t.space?.name}」`),await Y(!1)):y(t.error||`复制失败`)}async function ze(e,t){f(`delete`),y(``);let r=await ce(e.id,t);f(null),r.ok?(H(null),e.isActive?(n(`public`),window.location.reload()):(x(r.warning?r.warning:r.purged?`已删除「${e.name}」及其数据`:`已从列表移除「${e.name}」(数据保留在磁盘)`),await Y(!1))):y(r.error||`删除失败`)}async function Be(){f(`discover`),y(``),x(``),K([]);let e=await ue();if(f(null),!e.ok){y(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(g(`space.discoverAdded`,{n:t})):i.length||a.push(g(`space.discoverNone`)),n&&a.push(g(`space.discoverBackfilled`,{n})),r&&a.push(g(`space.discoverSkipped`,{n:r})),x(a.join(`;`)),K(i),q(Object.fromEntries(i.map(e=>[e.path,e.hasContent===!0]))),await Y(!1)}async function Ve(){let e=G.filter(e=>Te[e.path]).map(e=>e.path);if(!e.length){K([]),x(g(`space.candidatesIgnored`));return}f(`discover`),y(``);let t=await ue(e);if(f(null),!t.ok){y(t.error||`纳入失败`);return}K([]);let n=t.added?.length??0,r=t.skipped??[],i=[n?g(`space.candidatesAdopted`,{n}):g(`space.candidatesIgnored`)];r.length&&i.push(g(`space.candidatesRejected`,{names:r.map(e=>e.reason).join(`、`)})),x(i.join(`;`)),await Y(!1)}async function He(e){let t=e.target.files?.[0];if(e.target.value=``,!t)return;f(`import`),y(``);let n=await de(t);f(null),n.ok?(x(`已导入为「${n.space?.name}」`),await Y(!1)):y(n.error||`导入失败`)}let Z=u?.spaces??[],Ue=new Map(Z.map((e,t)=>[e.id,t])),We=e=>e.isPublic?0:e.isActive?1:2,Ge=[...Z].sort((e,t)=>We(e)-We(t)||(Ue.get(e.id)??0)-(Ue.get(t.id)??0)),Q=u?.baseRoot,$=d!==null,Ke=ke===`create`,qe=ke===`edit`;return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(a,{open:e,onClose:t,transition:!0,className:`relative z-95`,children:[(0,w.jsx)(o,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,w.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,w.jsxs)(i,{transition:!0,className:`tw-dialog-panel-anim tw-space-dialog w-full max-w-4xl rounded-xl shadow-xl border border-stone-200 bg-white flex flex-col h-[86vh]`,children:[(0,w.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-5 pt-4 pb-3 border-b border-stone-200`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(s,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:g(`space.manageTitle`)}),(0,w.jsx)(`p`,{className:`mt-1 text-xs text-stone-500 leading-relaxed`,children:g(`space.manageDesc`)})]}),(0,w.jsx)(`div`,{className:`shrink-0 flex items-center gap-2`,children:(0,w.jsx)(`button`,{type:`button`,onClick:t,className:`tw-confirm-cancel 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,w.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4`,children:[v?(0,w.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,w.jsx)(`span`,{className:`flex-1 min-w-0`,children:v}),(0,w.jsx)(`button`,{type:`button`,onClick:()=>y(``),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,b?(0,w.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,w.jsx)(`span`,{className:`flex-1 min-w-0`,children:b}),(0,w.jsx)(`button`,{type:`button`,onClick:()=>x(``),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,G.length?(0,w.jsxs)(`div`,{className:`mb-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2.5`,children:[(0,w.jsx)(`div`,{className:`text-xs font-medium text-amber-800`,children:g(`space.candidatesTitle`,{n:G.length})}),(0,w.jsx)(`p`,{className:`mt-1 text-[11px] leading-snug text-amber-700/90`,children:g(`space.candidatesHint`)}),(0,w.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:G.map(e=>(0,w.jsxs)(`label`,{className:`flex items-start gap-2 px-2.5 py-1.5 cursor-pointer hover:bg-stone-50`,children:[(0,w.jsx)(`input`,{type:`checkbox`,checked:Te[e.path]===!0,onChange:t=>q(n=>({...n,[e.path]:t.target.checked})),className:`mt-0.5 accent-[#4176e6]`}),(0,w.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,w.jsx)(`span`,{className:`block text-xs text-stone-800 truncate`,children:e.name}),(0,w.jsx)(`span`,{className:`block text-[10px] text-stone-400 truncate font-mono`,children:Q?C(e.path,Q):e.path})]})]},e.path))}),(0,w.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,w.jsx)(`button`,{type:`button`,onClick:()=>q(Object.fromEntries(G.map(e=>[e.path,!0]))),className:`text-[11px] text-[#4176e6] hover:underline`,children:g(`space.candidatesSelectAll`)}),(0,w.jsx)(`button`,{type:`button`,onClick:()=>q({}),className:`text-[11px] text-stone-500 hover:underline`,children:g(`space.candidatesClear`)}),(0,w.jsx)(`span`,{className:`flex-1`}),(0,w.jsx)(`button`,{type:`button`,onClick:()=>{K([]),q({}),x(g(`space.candidatesIgnored`))},className:`px-2.5 py-1 text-[11px] rounded-md border border-stone-200 text-stone-600 hover:bg-stone-50`,children:g(`space.candidatesIgnore`)}),(0,w.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void Ve(),className:`px-2.5 py-1 text-[11px] rounded-md bg-[#4176e6] text-white hover:bg-[#3565c7] disabled:opacity-40`,children:g(`space.candidatesAdopt`)})]})]}):null,T?(0,w.jsxs)(`div`,{ref:De,children:[(0,w.jsxs)(`div`,{className:`mb-2`,children:[(0,w.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:g(`space.newTitle`)}),(0,w.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-stone-400`,children:g(`space.newDesc`)})]}),(0,w.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,w.jsx)(`input`,{autoFocus:!0,value:D,onChange:e=>O(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),Pe())},placeholder:g(`space.namePlaceholder`),className:`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`})}),u?(0,w.jsx)(`div`,{className:`mt-1.5 text-[11px] text-stone-400 truncate`,children:(0,w.jsx)(`code`,{children:C(u.dataRoot,u.baseRoot)})}):null,(0,w.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-stone-200`,children:[(0,w.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-1.5`,children:g(`space.promptBriefLabel`)}),(0,w.jsx)(_e,{value:k,onChange:A,onGenerate:()=>void Me(`create`),onStop:X,generating:Ke,disabled:$}),(0,w.jsxs)(`div`,{className:`mt-1.5 flex items-start gap-3`,children:[(0,w.jsx)(`p`,{className:`flex-1 min-w-0 text-[11px] text-stone-400 leading-snug`,children:g(`space.promptHint`)}),Ke?(0,w.jsxs)(`p`,{className:`tw-busy-status shrink-0`,"aria-live":`polite`,children:[g(`space.promptGeneratingStatus`),(0,w.jsx)(`span`,{className:`tw-busy-ellipsis`,"aria-hidden":!0})]}):null]}),(0,w.jsx)(ve,{value:j,onChange:M,disabled:$})]})]}):N?(0,w.jsxs)(`div`,{ref:Oe,children:[(0,w.jsxs)(`div`,{className:`mb-2`,children:[(0,w.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:g(`space.editTitle`)}),(0,w.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-stone-400 font-mono truncate`,children:Q?C(N.path,Q):N.path})]}),(0,w.jsxs)(`label`,{className:`block text-xs font-medium text-stone-500`,children:[g(`space.nameLabel`),(0,w.jsx)(`input`,{autoFocus:!0,value:F,disabled:B||N.isPublic===!0,onChange:e=>I(e.target.value),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 disabled:bg-stone-50 disabled:text-stone-400`})]}),N.isPublic?(0,w.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:g(`space.publicNameLocked`)}):null,(0,w.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-stone-200`,children:[(0,w.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-1.5`,children:g(`space.promptBriefLabel`)}),(0,w.jsx)(_e,{value:L,onChange:e=>{R(e),Se(!1)},onGenerate:()=>void Me(`edit`),onStop:X,generating:qe,disabled:$||B}),(0,w.jsxs)(`div`,{className:`mt-1.5 flex items-start gap-3`,children:[(0,w.jsx)(`p`,{className:`flex-1 min-w-0 text-[11px] text-stone-400 leading-snug`,children:g(`space.promptBriefHint`)}),qe?(0,w.jsxs)(`p`,{className:`tw-busy-status shrink-0`,"aria-live":`polite`,children:[g(`space.promptGeneratingStatus`),(0,w.jsx)(`span`,{className:`tw-busy-ellipsis`,"aria-hidden":!0})]}):null]}),(0,w.jsx)(ve,{value:ye,onChange:z,disabled:$||B,hint:g(`space.promptEditHint`)}),B?(0,w.jsx)(`p`,{className:`mt-2 text-[11px] text-stone-400`,children:g(`space.loading`)}):null]})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,w.jsxs)(`div`,{className:`text-xs font-medium text-stone-500`,children:[g(`space.listTitle`),Z.length?(0,w.jsx)(`span`,{className:`ml-1.5 text-[11px] text-stone-400 tabular-nums`,children:Z.length}):null]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,w.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>Ee.current?.click(),className:`text-xs text-[#4176e6] hover:underline disabled:opacity-40`,children:d===`import`?`…`:g(`space.import`)}),(0,w.jsx)(`input`,{ref:Ee,type:`file`,accept:`.zip,application/zip`,className:`hidden`,onChange:e=>void He(e)}),(0,w.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void Be(),"data-hint":g(`space.discoverTitle`),"data-hint-always":``,className:`text-xs text-[#4176e6] hover:underline disabled:opacity-40`,children:g(d===`discover`?`space.discovering`:`space.discover`)}),(0,w.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void Y(!0),"data-hint":g(`space.sizeTitle`),"data-hint-always":``,className:`text-xs text-[#4176e6] hover:underline disabled:opacity-40`,children:g(d===`stats`?`space.sizing`:`space.size`)})]})]}),(0,w.jsx)(`div`,{className:`rounded-lg border border-stone-200 divide-y divide-stone-100 overflow-hidden`,children:Z.length===0?(0,w.jsx)(`div`,{className:`px-3 py-8 text-center text-xs text-stone-400`,children:g(`space.empty`)}):Ge.map(e=>(0,w.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5`,children:[(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,w.jsx)(`span`,{className:`text-sm font-medium text-stone-800 truncate`,children:S(e)}),e.isPublic?(0,w.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-stone-100 text-stone-500`,children:g(`space.builtin`)}):null,e.isActive?(0,w.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-[#4176e6]/10 text-[#3565c7]`,children:g(`space.activeTag`)}):null,e.exists?null:(0,w.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-amber-50 text-amber-600`,children:g(`space.missing`)}),e.bytes==null?null:(0,w.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-stone-100 text-stone-500 tabular-nums`,children:fe(e.bytes)})]}),(0,w.jsx)(`div`,{className:`mt-0.5 text-[11px] text-stone-400 truncate cursor-help hover:text-stone-500`,"data-hint":Q?C(e.path,Q):e.path,"data-hint-always":``,children:Q?C(e.path,Q):e.path})]}),(0,w.jsxs)(`div`,{className:`shrink-0 flex flex-wrap justify-end items-center gap-1`,children:[!e.isActive&&e.exists?(0,w.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void Le(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 transition-colors`,children:g(`space.switch`)}):null,(0,w.jsx)(`button`,{type:`button`,disabled:$||!e.exists,onClick:()=>void Fe(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 transition-colors`,children:g(`space.edit`)}),(0,w.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>{W(e),we(`${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:g(`space.copy`)}),(0,w.jsx)(`a`,{href:le(e.id,`content`),"data-hint":g(`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:g(`space.exportContent`)}),(0,w.jsx)(`a`,{href:le(e.id,`full`),"data-hint":g(`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:g(`space.exportFull`)}),(0,w.jsx)(ge,{hint:e.removable?void 0:g(`space.publicLocked`),children:(0,w.jsx)(`button`,{type:`button`,disabled:!e.removable||$,onClick:()=>H({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:g(`space.removeList`)})}),(0,w.jsx)(ge,{hint:e.removable?void 0:g(`space.publicLocked`),children:(0,w.jsx)(`button`,{type:`button`,disabled:!e.removable||$,onClick:()=>H({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:g(`space.deleteDisk`)})})]})]},e.id))})]})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-3 border-t border-stone-200`,children:[(0,w.jsx)(`button`,{type:`button`,disabled:$||T||N!==null,onClick:()=>{!T&&N===null&&Ne()},className:`h-8 px-3 text-xs font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-[#4176e6] transition-colors`,children:g(`space.addNew`)}),(0,w.jsx)(`span`,{className:`flex-1`}),T||N?(0,w.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>{X(),E(!1),P(null)},className:`tw-confirm-cancel h-8 px-4 text-sm rounded-lg border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-40 transition-colors`,children:g(`space.cancel`)}):null,T?(0,w.jsx)(`button`,{type:`button`,disabled:!D.trim()||$,onClick:()=>void Pe(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:d===`create`?`…`:g(`space.create`)}):N?(0,w.jsx)(`button`,{type:`button`,disabled:!F.trim()||$||B,onClick:()=>void Ie(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:d===`update`?`…`:g(`space.save`)}):null]})]})})]}),(0,w.jsxs)(a,{open:U!==null,onClose:()=>W(null),transition:!0,className:`relative z-96`,children:[(0,w.jsx)(o,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,w.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,w.jsxs)(i,{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,w.jsx)(s,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:g(`space.confirmCopyTitle`)}),(0,w.jsx)(`p`,{className:`tw-confirm-msg mt-3 text-sm text-stone-600 leading-relaxed`,children:g(`space.confirmCopyMsg`,{name:U?.name??``})}),(0,w.jsxs)(`label`,{className:`mt-3 block text-xs font-medium text-stone-500`,children:[g(`space.copyName`),(0,w.jsx)(`input`,{autoFocus:!0,value:Ce,onChange:e=>we(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),Re())},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,w.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,w.jsx)(`button`,{type:`button`,onClick:()=>W(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:g(`space.cancel`)}),(0,w.jsx)(`button`,{type:`button`,disabled:!Ce.trim()||$,onClick:()=>void Re(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:d===`copy`?`…`:g(`space.copy`)})]})]})})]}),(0,w.jsx)(c,{open:V?.kind===`remove`,title:g(`space.confirmRemoveTitle`),message:V?.kind===`remove`?g(`space.confirmRemoveMsg`,{name:V.space.name,path:V.space.path}):``,confirmLabel:g(`space.removeList`),onClose:()=>H(null),onConfirm:()=>{V?.kind===`remove`&&ze(V.space,!1)}}),(0,w.jsx)(c,{open:V?.kind===`delete`,title:g(`space.confirmDeleteTitle`),message:V?.kind===`delete`?g(`space.confirmDeleteMsg`,{name:V.space.name,path:V.space.path}):``,confirmLabel:g(`space.deleteDisk`),danger:`solid`,onClose:()=>H(null),onConfirm:()=>{V?.kind===`delete`&&ze(V.space,!0)}})]})}var E=`tw.spaces.list.v1`;function D(){try{let e=sessionStorage.getItem(E);if(!e)return null;let t=JSON.parse(e);return t&&Array.isArray(t.spaces)?t:null}catch{return null}}function O(e){try{sessionStorage.setItem(E,JSON.stringify(e))}catch{}}function k(e){try{e?document.documentElement.dataset.spaceService=`none`:delete document.documentElement.dataset.spaceService}catch{}}function A(){let e=D(),[t,n]=(0,_.useState)(e!==null),[r,i]=(0,_.useState)(e!==null),[a,o]=(0,_.useState)(e),[s,c]=(0,_.useState)(!1),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``);(0,_.useEffect)(()=>{let e=!0;return(async()=>{let t=await b();if(!e)return;if(i(!0),!t){n(!1),k(!0);return}k(!1),n(!0);let r=await ne();e&&r&&(o(r),O(r))})(),()=>{e=!1}},[]);async function te(e){if(e===a?.activeId)return;p(!0),h(``);let t=await re(e);t.ok?(a&&O({...a,activeId:e,spaces:a.spaces.map(t=>({...t,isActive:t.id===e}))}),window.location.reload()):(p(!1),h(t.error||`切换失败`))}if(!r)return null;if(!t)return(0,w.jsx)(`div`,{className:`tw-nav-space`,children:(0,w.jsxs)(`div`,{className:`tw-nav-space-btn tw-nav-space-btn--off`,children:[(0,w.jsx)(`span`,{className:`tw-nav-space-ico`,"aria-hidden":`true`,children:(0,w.jsx)(j,{})}),(0,w.jsxs)(`span`,{className:`tw-nav-space-text`,children:[(0,w.jsx)(`span`,{className:`tw-nav-space-cap`,children:g(`space.offlineCap`)}),(0,w.jsx)(`span`,{className:`tw-nav-space-name`,children:g(`space.offline`)})]})]})});let v=a?.spaces.find(e=>e.isActive),y=(a?.spaces??[]).filter(e=>!e.isActive);return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`div`,{className:`tw-nav-space`,children:(0,w.jsxs)(ee,{as:`div`,className:`tw-nav-space-menu`,children:[(0,w.jsxs)(d,{className:`tw-nav-space-btn`,"data-hint":g(`space.label`),children:[(0,w.jsx)(`span`,{className:`tw-nav-space-ico`,"aria-hidden":`true`,children:(0,w.jsx)(j,{})}),(0,w.jsxs)(`span`,{className:`tw-nav-space-text`,children:[(0,w.jsx)(`span`,{className:`tw-nav-space-cap`,children:g(`space.current`)}),(0,w.jsx)(`span`,{className:`tw-nav-space-name`,children:f?g(`space.switching`):v?S(v):`—`})]}),(0,w.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,w.jsx)(`path`,{d:`m6 9 6 6 6-6`})})]}),(0,w.jsxs)(l,{transition:!0,anchor:{to:`bottom start`,gap:`0.375rem`},className:`tw-nav-space-pop tw-menu-anim`,children:[m?(0,w.jsx)(`div`,{className:`tw-nav-space-err`,role:`alert`,children:m}):null,(0,w.jsx)(`div`,{className:`tw-nav-space-group`,children:g(`space.others`)}),y.length===0?(0,w.jsx)(`p`,{className:`tw-nav-space-hint`,children:g(`space.othersEmpty`)}):y.map(e=>(0,w.jsx)(u,{children:(0,w.jsxs)(`button`,{type:`button`,className:`tw-nav-space-item`,disabled:f,onClick:()=>void te(e.id),children:[(0,w.jsx)(`span`,{className:`tw-nav-space-item-main`,children:(0,w.jsx)(`span`,{className:`tw-nav-space-item-name`,"data-hint":S(e),children:S(e)})}),(0,w.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,w.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]})},e.id)),(0,w.jsx)(`div`,{className:`tw-nav-space-sep`}),(0,w.jsx)(u,{children:(0,w.jsxs)(`button`,{type:`button`,className:`tw-nav-space-item tw-nav-space-item--manage`,onClick:()=>c(!0),children:[(0,w.jsx)(`span`,{className:`tw-nav-space-item-ico`,"aria-hidden":`true`,children:(0,w.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,w.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,w.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,w.jsx)(`span`,{className:`tw-nav-space-item-main`,children:(0,w.jsx)(`span`,{className:`tw-nav-space-item-name`,children:g(`space.manage`)})}),(0,w.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,w.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]})})]})]})}),(0,w.jsx)(T,{open:s,onClose:()=>c(!1),onListChanged:e=>{o(e),O(e)}})]})}function j(){return(0,w.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`15`,height:`15`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,w.jsx)(`path`,{d:`M3 7.5 12 3l9 4.5-9 4.5-9-4.5Z`}),(0,w.jsx)(`path`,{d:`m3 12.5 9 4.5 9-4.5`}),(0,w.jsx)(`path`,{d:`m3 17 9 4.5 9-4.5`})]})}export{A 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.Crg0VdkS.js";import{a as ee,o as r,r as i}from"./plugins.CNOYmeAe.js";import{i as a,n as o,r as s,t as c}from"./view-prefs.C9Mtta1E.js";import{a as l,i as u,n as d,r as f,t as p}from"./ConfirmDialog.Dbyjb4-6.js";import{t as m}from"./jsx-runtime.BUXbF_vF.js";import{n as h,t as g}from"./ColumnResize.Bs6GL3DJ.js";import{t as _}from"./DatePicker.CMfX7F6z.js";import{t as v}from"./SelectDropdown.flhHcwyd.js";import{A as y,C as b,D as x,P as te,a as S,b as C,c as w,f as ne,g as T,h as re,i as E,m as D,n as O,o as ie,p as ae,r as oe,s as se,t as k,u as ce}from"./tasks.WhfT-DnC.js";import{a as A,l as j,n as M,o as N,r as P,s as F,t as I}from"./DrawerField.KANqQwFl.js";var L=e(t(),1),R=m(),le=8e3,z=[{key:`title`,min:200},{key:`status`,width:104,min:80},{key:`priority`,width:104,min:88},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`cycle`,width:76,min:60},{key:`todos`,width:84,min:68},{key:`progress`,width:132,min:104},{key:`note`,width:140,min:88},{key:`action`,width:56,min:52}],B={pool:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,closed:`bg-stone-100 text-stone-400`},ue={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},V={urgent_important:`bg-[#fee4e3] text-[#c02a26]`,important:`bg-[#fff1e3] text-[#a85b00]`,urgent:`bg-[#fff7d6] text-[#8a6100]`,normal:`bg-stone-100 text-stone-600`,"":`bg-stone-100 text-stone-500`},H={pending:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},de={pool:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,closed:`bg-stone-300`},fe={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},pe=oe.map(e=>({value:e,label:E[e]})),me=[{value:``,label:`未设置`},...k.map(e=>({value:e,label:O[e]}))],he=[{value:`all`,label:`全部优先级`},...k.map(e=>({value:e,label:O[e]}))],ge=[{value:`all`,label:`全部`},{value:`pool`,label:`任务池`},{value:`in_progress`,label:`进行中`},{value:`done`,label:`已完成`},{value:`closed`,label:`已关闭`}],_e=[`all`,`pool`,`in_progress`,`done`,`closed`],ve=`tasks.status-tab`,ye=`tasks.priority-filter`,be=`tasks.search`,xe=he.map(e=>e.value);function U(e){return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 rounded-xl border px-4 py-3 ${e.tone===`urgent`?`border-red-100 bg-red-50/60`:`border-stone-200 bg-white`}`,children:[(0,R.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums ${e.tone===`urgent`?`text-[#c02a26]`:`text-stone-900`}`,children:e.value}),(0,R.jsx)(`span`,{className:`truncate text-xs text-stone-500`,children:e.label})]})}function Se(e){let{open:t,task:n,todos:ee,onClose:r,onSaved:i}=e,[a,o]=(0,L.useState)({title:``}),[s,c]=(0,L.useState)(``),[p,m]=(0,L.useState)(!1);(0,L.useEffect)(()=>{t&&(c(``),m(!1),o(n?{title:n.title,status:n.status,priority:n.priority,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pool`,priority:``,startDate:y(),dueDate:y()}))},[t,n]);function h(e){o(t=>({...t,...e}))}let g=D({startDate:a.startDate??``,dueDate:a.dueDate??``}),v=n?ee.filter(e=>e.taskId===n.id):[],x=v.filter(e=>e.status===`done`).length,te=v.length?Math.round(x/v.length*100):0;async function w(){let e=(a.title??``).trim();if(!e)c(`请填写任务名称`);else if(a.startDate&&a.dueDate&&a.dueDate<a.startDate)c(`截止日期不能早于开始日期`);else{m(!0),c(``);try{n?await T(n.id,a):await S([{...a,title:e}],{mode:`manual`}),await i(),r()}catch(e){c(e instanceof Error?e.message:String(e))}finally{m(!1)}}}return(0,R.jsxs)(u,{open:t,onClose:r,transition:!0,className:`relative z-100`,children:[(0,R.jsx)(d,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,R.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,R.jsxs)(l,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,R.jsx)(f,{className:`text-base font-semibold text-stone-900`,children:n?`任务详情`:`新建任务`}),(0,R.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,R.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,R.jsx)(M,{icon:(0,R.jsx)(j,{}),label:`任务名称`,children:(0,R.jsx)(`input`,{autoFocus:!0,value:a.title,onChange:e=>h({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),w())},placeholder:`请输入内容`,className:I})}),(0,R.jsx)(M,{icon:(0,R.jsx)(F,{}),label:`任务状态`,children:(0,R.jsx)(P,{ariaLabel:`任务状态`,menuMinWidth:140,options:pe,value:a.status??`pool`,onChange:e=>h({status:e}),label:E[a.status??`pool`],pillClassName:B[a.status??`pool`],optionDotClassName:e=>de[e]})}),(0,R.jsx)(M,{icon:(0,R.jsx)(F,{}),label:`紧急程度`,children:(0,R.jsx)(P,{ariaLabel:`紧急程度`,menuMinWidth:140,options:me,value:a.priority??``,onChange:e=>h({priority:e}),label:a.priority?O[a.priority]:`未设置`,pillClassName:V[a.priority??``],optionDotClassName:e=>fe[e]})}),(0,R.jsx)(M,{icon:(0,R.jsx)(A,{}),label:`开始日期`,children:(0,R.jsx)(_,{value:a.startDate??``,onChange:e=>h({startDate:e}),className:`${I} tabular-nums`})}),(0,R.jsx)(M,{icon:(0,R.jsx)(A,{}),label:`截止日期`,children:(0,R.jsx)(_,{value:a.dueDate??``,onChange:e=>h({dueDate:e}),className:`${I} tabular-nums`})}),(0,R.jsx)(M,{icon:(0,R.jsx)(N,{}),label:`任务周期`,children:(0,R.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:g===null?`—`:`${g} 天`})}),(0,R.jsx)(M,{icon:(0,R.jsx)(N,{}),label:`待办进度`,children:(0,R.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:v.length?`${x}/${v.length} · ${te}%`:`还没有关联待办`})}),(0,R.jsx)(M,{icon:(0,R.jsx)(j,{}),label:`备注`,children:(0,R.jsx)(`textarea`,{value:a.note??``,onChange:e=>h({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),n&&v.length?(0,R.jsxs)(`div`,{className:`mx-6 mt-2 rounded-lg border border-stone-100 bg-stone-50/60 px-3 py-2`,children:[(0,R.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-stone-500`,children:`关联待办`}),(0,R.jsx)(`ul`,{className:`space-y-1.5`,children:v.map(e=>{let t=b(e,y());return(0,R.jsxs)(`li`,{className:`flex items-center gap-2 text-sm text-stone-700`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,R.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium ${H[t]}`,children:C[t]})]},e.id)})})]}):null,s?(0,R.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:s}):null]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:r,disabled:p,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>void w(),disabled:p,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:p?`保存中…`:n?`保存`:`新建`})]})]})})]})}function W(){let[e,t]=(0,L.useState)(!1),[l,u]=(0,L.useState)(!0),[d,f]=(0,L.useState)(!0),[m,y]=(0,L.useState)(null),[b,S]=(0,L.useState)([]),[C,oe]=(0,L.useState)([]),[k,A]=(0,L.useState)(null),[j,M]=(0,L.useState)(!1),[N,P]=(0,L.useState)(()=>o(be)),[F,I]=(0,L.useState)(()=>c(ve,_e,`all`)),[V,H]=(0,L.useState)(()=>c(ye,xe,`all`)),[W,G]=(0,L.useState)(null),[K,q]=(0,L.useState)(null);function Ce(e){s(ve,e),I(e)}function we(e){a(be,e),P(e)}function Te(e){s(ye,e),H(e)}let J=(0,L.useRef)(!0),Y=h(`lh:tasks:cols:v1`,z);(0,L.useEffect)(()=>(J.current=!0,()=>{J.current=!1}),[]);let X=(0,L.useCallback)(async()=>{try{let[e,t]=await Promise.all([ce(),d?x().catch(()=>[]):Promise.resolve([])]);if(!J.current)return;S(e),oe(t),A(null)}catch(e){if(!J.current)return;A(e instanceof Error?e.message:String(e))}},[d]);(0,L.useEffect)(()=>{let e=ee(e=>{u(!!e.tasks),f(!!e.todos)});return n().then(()=>{u(i(`tasks`)),f(i(`todos`)),t(!0)}),e},[]),(0,L.useEffect)(()=>{e&&l&&(async()=>{let e=await se();J.current&&(e?(await X(),J.current&&y(!0)):y(!1))})()},[e,l,X]),(0,L.useEffect)(()=>{if(m!==!0)return;let e=window.setInterval(()=>void X(),le),t=()=>void X();return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[m,X]);let Ee=(0,L.useMemo)(()=>re(C),[C]),Z=(0,L.useMemo)(()=>ae(b),[b]),De=(0,L.useMemo)(()=>w(b,{status:F,priority:V,keyword:N}),[b,F,V,N]),Q=(0,L.useMemo)(()=>ne(De),[De]);async function $(e,t){S(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await T(e,t);if(!J.current)return;S(t=>t.map(t=>t.id===e?n:t)),A(null)}catch(e){A(e instanceof Error?e.message:String(e)),await X()}}async function Oe(){let e=K;if(e){q(null),M(!0);try{await ie([e.id]),await Promise.all(C.filter(t=>t.taskId===e.id).map(e=>te(e.id,{taskId:``,linkedTask:``}).catch(()=>null))),await X()}catch(e){A(e instanceof Error?e.message:String(e))}finally{J.current&&M(!1)}}}return e?l?m===null?(0,R.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接任务服务`,children:(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,R.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):m?(0,R.jsxs)(`section`,{className:`flex min-h-0 flex-col gap-4`,children:[(0,R.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-6`,children:[(0,R.jsx)(U,{label:`全部任务`,value:Z.total}),(0,R.jsx)(U,{label:`任务池`,value:Z.pool}),(0,R.jsx)(U,{label:`进行中`,value:Z.in_progress}),(0,R.jsx)(U,{label:`已完成`,value:Z.done}),(0,R.jsx)(U,{label:`已关闭`,value:Z.closed}),(0,R.jsx)(U,{label:`需要紧急`,value:Z.urgent,tone:`urgent`})]}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-4 py-3`,children:[(0,R.jsx)(`input`,{value:N,onChange:e=>we(e.target.value),placeholder:`搜索任务…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,R.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-stone-100/80 p-0.5`,children:ge.map(e=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>Ce(e.value),className:`h-8 rounded-md px-3 text-sm transition-colors ${F===e.value?`bg-white font-medium text-stone-900 shadow-sm`:`text-stone-600 hover:text-stone-900`}`,children:e.label},e.value))}),(0,R.jsx)(v,{flat:!0,className:`w-[136px]`,ariaLabel:`优先级筛选`,options:he,value:V,onChange:e=>Te(e)}),(0,R.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>void X(),"aria-label":`刷新`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-stone-200 text-stone-500 transition-colors hover:bg-stone-50 hover:text-stone-800`,children:(0,R.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,R.jsx)(`path`,{d:`M21 12a9 9 0 1 1-3-6.7`}),(0,R.jsx)(`path`,{d:`M21 4v5h-5`})]})}),(0,R.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>G({task:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建任务`})]})]}),k?(0,R.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1`,children:k}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>A(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,R.jsxs)(`table`,{className:`tw-task-table w-full table-fixed border-collapse text-sm`,style:Y.tableStyle,children:[(0,R.jsx)(`colgroup`,{children:z.map(e=>(0,R.jsx)(`col`,{style:Y.widthOf(e.key)?{width:Y.widthOf(e.key)}:void 0},e.key))}),(0,R.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsxs)(`th`,{className:`relative px-3 py-2 text-left font-medium whitespace-nowrap`,children:[`任务描述`,(0,R.jsx)(g,{...Y.resizeProps(0)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务状态`,(0,R.jsx)(g,{...Y.resizeProps(1)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,R.jsx)(g,{...Y.resizeProps(2)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,R.jsx)(g,{...Y.resizeProps(3)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,R.jsx)(g,{...Y.resizeProps(4)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务周期`,(0,R.jsx)(g,{...Y.resizeProps(5)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办数量`,(0,R.jsx)(g,{...Y.resizeProps(6)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`完成进度`,(0,R.jsx)(g,{...Y.resizeProps(7)})]}),(0,R.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,R.jsx)(g,{...Y.resizeProps(8)})]}),(0,R.jsx)(`th`,{className:`px-1 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,R.jsxs)(`tbody`,{children:[Q.map(e=>{let t=D(e),n=Ee[e.id]??{total:0,done:0,percent:0};return(0,R.jsxs)(`tr`,{className:`group/row border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,R.jsx)(`td`,{className:`px-3 py-1 align-middle`,children:(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.source===`ai`?(0,R.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,children:`AI`}):null,(0,R.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),className:`min-w-0 truncate rounded-md px-1.5 py-1 text-left text-sm text-stone-800 hover:bg-stone-100`,children:e.title})]})}),(0,R.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,R.jsx)(v,{unstyled:!0,hideChevron:!0,showCheck:!1,centerContent:!0,ariaLabel:`任务状态`,menuMinWidth:120,options:pe,value:e.status,onChange:t=>void $(e.id,{status:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${B[e.status]}`,renderTrigger:()=>(0,R.jsx)(`span`,{className:`w-full truncate text-center`,children:E[e.status]}),renderOptionPrefix:e=>(0,R.jsx)(`span`,{className:`h-2 w-2 rounded-full ${de[e.value]}`})})}),(0,R.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,R.jsx)(v,{unstyled:!0,hideChevron:!0,showCheck:!1,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:me,value:e.priority,onChange:t=>void $(e.id,{priority:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${ue[e.priority]}`,renderTrigger:()=>(0,R.jsx)(`span`,{className:`w-full truncate text-center`,children:e.priority?O[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,R.jsx)(`span`,{className:`h-2 w-2 rounded-full ${fe[e.value]}`})})}),(0,R.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,R.jsx)(_,{value:e.startDate,onChange:t=>void $(e.id,{startDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,R.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,R.jsx)(_,{value:e.dueDate,onChange:t=>void $(e.id,{dueDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,R.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:t===null?`—`:`${t} 天`}),(0,R.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-500 tabular-nums`,children:d?n.total?`${n.total} 条`:`0`:(0,R.jsx)(`span`,{className:`whitespace-nowrap text-stone-400`,children:`待办事项未启用`})}),(0,R.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:d?(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,R.jsx)(`span`,{className:`block h-full rounded-full bg-[#3370ff] transition-[width]`,style:{width:`${n.percent}%`}})}),(0,R.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs text-stone-500 tabular-nums`,children:[n.percent,`%`]})]}):(0,R.jsx)(`span`,{className:`whitespace-nowrap text-xs text-stone-400`,children:`待办事项未启用`})}),(0,R.jsx)(`td`,{className:`truncate px-2 py-1 align-middle text-xs text-stone-500`,children:e.note||`—`}),(0,R.jsx)(`td`,{className:`px-1 py-1 text-right align-middle`,children:(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,R.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,R.jsx)(`path`,{d:`M14 4h6v6`}),(0,R.jsx)(`path`,{d:`M20 4 13 11`}),(0,R.jsx)(`path`,{d:`M10 20H4v-6`}),(0,R.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,R.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>q(e),"aria-label":`删除 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 focus:text-red-600 disabled:opacity-40`,children:(0,R.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,R.jsx)(`path`,{d:`M3 6h18`}),(0,R.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,R.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,R.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),Q.length===0?(0,R.jsx)(`tr`,{children:(0,R.jsx)(`td`,{colSpan:10,className:`px-3 py-16 text-center text-sm text-stone-400`,children:b.length===0?`还没有任务`:`没有匹配的任务,试试调整搜索或筛选`})}):null]})]})}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,R.jsxs)(`span`,{children:[`共 `,Q.length,` 条`]}),(0,R.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`任务下关联的待办可直接在「待办事项」里维护`})]})]}),(0,R.jsx)(Se,{open:W!==null,task:W?.task??null,todos:C,onClose:()=>G(null),onSaved:X}),(0,R.jsx)(p,{open:K!=null,title:`删除任务`,message:`删除「${K?.title??``}」?已关联的待办会保留,但不再挂在该任务下。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>q(null),onConfirm:()=>void Oe()})]}):(0,R.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:`任务管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,R.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:r(`tasks`)}):(0,R.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,R.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.Crg0VdkS.js";import{a as r,o as i,r as a}from"./plugins.CNOYmeAe.js";import{t as o}from"./ConfirmDialog.Dbyjb4-6.js";import{t as s}from"./jsx-runtime.BUXbF_vF.js";import{n as c,t as ee}from"./DocsPager.DaiWchhj.js";import{a as l,i as u,r as d,t as te}from"./ExcelFieldTags.B_XMwNNx.js";import{a as ne,c as re,d as f,f as p,h as ie,i as ae,l as oe,m as se,n as ce,o as le,p as ue,r as de,s as m,t as fe,u as pe}from"./project-docs.Cd2gKPKh.js";import{n as me}from"./doc-roots.DAJP9Svr.js";import{t as he}from"./useListAnim.CpGB1cft.js";import{t as h}from"./NamePromptDialog.DZSZ5Y16.js";var g=e(t(),1),_=s(),ge=5;async function _e(e){let t=e.name.toLowerCase();try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await f(`templates`,e.path);if(t.encoding===`base64`&&t.contentBase64)return l(t.contentBase64).headers}else if(t.endsWith(`.csv`)){let t=await p(`templates`,e.path);return d(t.content).headers}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await p(`templates`,e.path);return u(t.content).headers}}catch{}return[]}function v({className:e=`w-4 h-4`,open:t=!1}){return(0,_.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,_.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,_.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 y({className:e=`w-3 h-3`}){return(0,_.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,_.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,_.jsx)(`path`,{d:`m15 5 4 4`})]})}function b({className:e=`w-3 h-3`}){return(0,_.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,_.jsx)(`path`,{d:`M3 6h18`}),(0,_.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,_.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,_.jsx)(`path`,{d:`M10 11v6`}),(0,_.jsx)(`path`,{d:`M14 11v6`})]})}function x({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,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,_.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,_.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,_.jsx)(v,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,_.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,_.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,_.jsx)(`div`,{className:`tw-collapse-inner`,children:e.children.map(e=>(0,_.jsx)(x,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function S(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,g.useState)(()=>a(`templates`)),[s,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)([]),[C,ve]=(0,g.useState)(0),[w,T]=(0,g.useState)(`.`),[E,D]=(0,g.useState)([]),[ye,be]=(0,g.useState)({}),[xe,O]=(0,g.useState)({}),[k,Se]=(0,g.useState)(!0),[A,j]=(0,g.useState)(null),[M,N]=(0,g.useState)(!1),[Ce,P]=(0,g.useState)(!1),[F,I]=(0,g.useState)(null),[L,R]=(0,g.useState)(null),[we,z]=(0,g.useState)(1),[B,Te]=c(ge),[Ee,V]=(0,g.useState)(null),H=(0,g.useRef)(null),{cls:De,play:U}=he(),W=(0,g.useCallback)(async e=>{let t={};await Promise.all(e.map(async e=>{let n=await _e(e);n.length&&(t[e.path]=n)})),be(t)},[]),G=(0,g.useCallback)(async()=>{let e=await ae(`templates`);p(e.tree),ve(e.totalFiles)},[]),K=(0,g.useCallback)(async(e=w)=>{j(null);try{let[t]=await Promise.all([m(`templates`,e),G()]);D(t.entries),T(t.path);let n=t.entries.filter(e=>e.type===`file`);await W(n)}catch(e){j(e instanceof Error?e.message:String(e))}},[w,W,G]);(0,g.useEffect)(()=>{let e=r(e=>t(!!e.templates));return n().then(()=>{t(a(`templates`)),l(!0)}),e},[]),(0,g.useEffect)(()=>{s&&e&&(async()=>{let e=await de(`templates`);if(d(e),e)try{let[e]=await Promise.all([m(`templates`,`.`),G()]);D(e.entries),T(e.path),await W(e.entries.filter(e=>e.type===`file`))}catch(e){j(e instanceof Error?e.message:String(e))}})()},[s,e,W,G]);function Oe(){Se(e=>!e),O({})}async function q(e){U(),T(e),z(1),V(null),j(null);try{let t=await m(`templates`,e);D(t.entries),await W(t.entries.filter(e=>e.type===`file`))}catch(e){j(e instanceof Error?e.message:String(e))}}async function ke(e){P(!1),N(!0),j(null);try{await re(`templates`,w,e),await K(w)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}async function Ae(e){if(e?.length){N(!0),j(null);try{for(let t of Array.from(e))await ie(`templates`,w,t);await K(w)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1),H.current&&(H.current.value=``)}}}async function je(e){if(e.type===`file`){N(!0),j(null);try{await oe(`templates`,e.path)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}function Me(e){let t=ne(f,e.path),n=t?.fileCount??0,r=t?fe(t):0;I({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function Ne(e){I({name:e.name,path:e.path,isDir:!1})}function J(e,t){R({...e,isDir:t})}async function Y(){let e=F;if(e&&(I(null),!e.blocked)){N(!0),j(null);try{await ce(`templates`,e.path);let t=le(w,e.path)?pe(e.path):w;await K(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 se(`templates`,t.path,e);await K(ue(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(!s)return(0,_.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,_.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,_.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`templates`)});if(u===null)return(0,_.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,_.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!u)return(0,_.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/B)),$=Math.min(we,Q),Ie=X.slice(($-1)*B,$*B);function Le(e){U(),Te(e),z(1)}return(0,_.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,_.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,_.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,_.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>P(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1`,children:[(0,_.jsx)(`div`,{className:`group flex items-center rounded-md ${w===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{q(`.`),Oe()},"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,_.jsx)(v,{open:k,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部模板`}),(0,_.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,C,`)`]})]})}),(0,_.jsx)(`div`,{className:`tw-collapse ${k?`is-open`:``}`,children:(0,_.jsx)(`div`,{className:`tw-collapse-inner`,children:f.map(e=>(0,_.jsx)(x,{node:e,depth:0,activePath:w,expanded:xe,globalOpen:k,onToggle:e=>O(t=>({...t,[e]:!(t[e]??k)})),onSelect:e=>void q(e)},e.path))})})]})]}),(0,_.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,_.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,_.jsx)(`span`,{className:`text-stone-400`,children:me(`templates`)}),w===`.`?``:w]}),(0,_.jsx)(`input`,{ref:H,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 Ae(e.target.files)}),(0,_.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>H.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,_.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,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,_.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,_.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void q(e.path),children:[(0,_.jsx)(v,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>J({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,_.jsx)(y,{className:`w-3.5 h-3.5`})}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>Me({name:e.name,path:e.path}),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,_.jsx)(b,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,_.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,_.jsx)(`ul`,{className:`${De}space-y-1`,children:Ie.map(e=>{let t=ye[e.path]??[],n=Ee===e.path;return(0,_.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,_.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,disabled:M,onClick:()=>V(e.path),onDoubleClick:()=>void je(e),children:[(0,_.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,_.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:S(e.size)}),t.length>0?(0,_.jsx)(te,{fields:t}):null]}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>J({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,_.jsx)(y,{className:`w-3.5 h-3.5`})}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>Ne(e),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40 shrink-0 mt-0.5`,children:(0,_.jsx)(b,{className:`w-3.5 h-3.5`})})]},e.path)})})]})]}),X.length>0?(0,_.jsx)(ee,{page:$,totalPages:Q,pageSize:B,busy:M,onPage:e=>{U(),z(e)},onPageSize:Le}):null]}),(0,_.jsx)(h,{open:Ce,title:`新建文件夹`,onClose:()=>P(!1),onConfirm:e=>void ke(e)}),(0,_.jsx)(h,{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,_.jsx)(o,{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 Y()})]})}export{C 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.Crg0VdkS.js";import{a as r,o as i,r as a}from"./plugins.CNOYmeAe.js";import{i as ee,n as te}from"./view-prefs.C9Mtta1E.js";import{t as o}from"./ConfirmDialog.Dbyjb4-6.js";import{t as s}from"./jsx-runtime.BUXbF_vF.js";import{n as ne,t as c}from"./ColumnResize.Bs6GL3DJ.js";import{t as re}from"./DatePicker.CMfX7F6z.js";import{n as ie,t as ae}from"./DocsPager.DaiWchhj.js";import{t as oe}from"./TagSelect.u8DTop7v.js";import{a as se,c as ce,d as le,i as ue,l,n as u,o as d,r as f,s as p,t as m,u as h}from"./test-stats.BIHEJz5c.js";var g=e(t(),1),_=s(),de=8e3,v=600,fe=20,pe=`tw.test-stats.page-size.v1`,y=`test-stats.search`,b=[{key:`select`,width:32,min:28},{key:`index`,width:44,min:36},{key:`date`,width:140,min:120},{key:`dimensions`,min:240},{key:`count`,width:120,min:90},{key:`action`,width:64,min:56}],x=`h-8 w-full min-w-0 rounded-md border border-transparent bg-transparent px-1.5 text-center text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300 tabular-nums`,me=(0,_.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,_.jsx)(`path`,{d:`M3 6h18`}),(0,_.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,_.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,_.jsx)(`path`,{d:`M10 11v6M14 11v6`})]});function he(e){let[t,n]=(0,g.useState)(e.value?String(e.value):``),r=(0,g.useRef)(e.value),i=(0,g.useRef)(e.onCommit);i.current=e.onCommit,(0,g.useEffect)(()=>{e.value!==r.current&&(r.current=e.value,n(e.value?String(e.value):``))},[e.value]),(0,g.useEffect)(()=>{let e=t?l(t):0;if(e===r.current)return;let n=window.setTimeout(()=>{r.current=e,i.current(e)},v);return()=>window.clearTimeout(n)},[t]);function a(){let e=t?l(t):0;e!==r.current&&(r.current=e,i.current(e))}return(0,_.jsx)(`input`,{type:`text`,inputMode:`numeric`,"aria-label":e.ariaLabel,value:t,placeholder:e.placeholder??`0`,onChange:e=>n(e.target.value.replace(/[^\d]/g,``)),onBlur:a,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),t.currentTarget.blur()):t.key===`Escape`&&(t.preventDefault(),r.current=e.value,n(e.value?String(e.value):``),t.currentTarget.blur())},className:x})}function S(){let[e,t]=(0,g.useState)(!1),[s,l]=(0,g.useState)(!0),[v,x]=(0,g.useState)(null),[S,C]=(0,g.useState)([]),[ge,w]=(0,g.useState)([]),[T,E]=(0,g.useState)(null),[D,O]=(0,g.useState)(!1),[k,A]=(0,g.useState)(()=>te(y)),[j,M]=(0,g.useState)({}),[N,P]=(0,g.useState)(1),[F,I]=ie(fe,pe),[L,R]=(0,g.useState)(null),[z,B]=(0,g.useState)(null);function V(e){ee(y,e),A(e),P(1)}let H=(0,g.useRef)(!0),U=(0,g.useRef)(!1),W=ne(`lh:test-stats:cols:v1`,b);(0,g.useEffect)(()=>(H.current=!0,()=>{H.current=!1}),[]);let G=(0,g.useCallback)(async()=>{try{let e=await se();if(!H.current)return;C(e.items),w(e.dimensions),M(t=>{let n=new Set(e.items.map(e=>e.id)),r=!1,i={};for(let[e,a]of Object.entries(t))a&&(n.has(e)?i[e]=!0:r=!0);return r?i:t}),E(null)}catch(e){if(!H.current)return;E(e instanceof Error?e.message:String(e))}},[]);(0,g.useEffect)(()=>{let e=r(e=>l(!!e.testStats));return n().then(()=>{l(a(`testStats`)),t(!0)}),e},[]),(0,g.useEffect)(()=>{e&&s&&(async()=>{let e=await f();H.current&&(e?(await p(),await G(),H.current&&x(!0)):x(!1))})()},[e,s,G]),(0,g.useEffect)(()=>{if(v!==!0)return;let e=window.setInterval(()=>{U.current||G()},de),t=()=>{U.current||G()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[v,G]);let _e=h(),K=(0,g.useMemo)(()=>d(ue(S,{keyword:k})),[S,k]),q=(0,g.useMemo)(()=>ce(S),[S]),J=Math.max(1,Math.ceil(K.length/F)),Y=Math.min(N,J),X=(0,g.useMemo)(()=>K.slice((Y-1)*F,Y*F),[K,Y,F]),Z=(0,g.useMemo)(()=>S.filter(e=>j[e.id]),[S,j]),Q=X.length>0&&X.every(e=>j[e.id]);(0,g.useEffect)(()=>{if(!L)return;let e=K.findIndex(e=>e.id===L);if(e<0)return;P(Math.floor(e/F)+1);let t=window.setTimeout(()=>R(null),2e3);return()=>window.clearTimeout(t)},[L,K,F]);async function ve(){if(!D){O(!0),E(null),V(``);try{let e=await m([{date:_e,dimensions:[],count:0}],{mode:`manual`});if(!H.current)return;let t=e.items[0];if(e.dimensions.length&&w(e.dimensions),await G(),!H.current||!t)return;R(t.id)}catch(e){H.current&&E(e instanceof Error?e.message:String(e))}finally{H.current&&O(!1)}}}async function $(e,t){C(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let{item:n,dimensions:r}=await le(e,t);if(!H.current)return;C(t=>t.map(t=>t.id===e?n:t)),r.length&&w(r),E(null)}catch(e){if(!H.current)return;E(e instanceof Error?e.message:String(e)),await G()}}async function ye(){let e=z;if(e&&e.length!==0){B(null),O(!0);try{if(await u(e.map(e=>e.id)),!H.current)return;M({}),E(null),await G()}catch(e){H.current&&E(e instanceof Error?e.message:String(e))}finally{H.current&&O(!1)}}}return e?s?v===null?(0,_.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接测试统计服务`,children:(0,_.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,_.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):v?(0,_.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,_.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,_.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,_.jsx)(`span`,{className:`font-medium text-stone-800`,children:q.records}),` 条`,(0,_.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 覆盖 `,q.dimensions,` 个维度 · 数量合计 `,q.total,Z.length?` · 已选 ${Z.length} 条`:``]})]}),(0,_.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,_.jsx)(`input`,{value:k,onChange:e=>V(e.target.value),placeholder:`搜索日期 / 维度…`,className:`h-9 w-44 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,_.jsx)(`button`,{type:`button`,disabled:D||Z.length===0,onClick:()=>B(Z),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,_.jsx)(`button`,{type:`button`,disabled:D,onClick:()=>void ve(),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 添加记录`})]})]}),T?(0,_.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,_.jsx)(`span`,{className:`min-w-0 flex-1`,children:T}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>E(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,_.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{U.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{U.current=!!document.activeElement?.closest(`.tw-data-table`)},0)},children:(0,_.jsxs)(`table`,{className:`tw-data-table w-full table-fixed border-collapse text-sm`,style:W.tableStyle,children:[(0,_.jsx)(`colgroup`,{children:b.map(e=>(0,_.jsx)(`col`,{style:W.widthOf(e.key)?{width:W.widthOf(e.key)}:void 0},e.key))}),(0,_.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,children:(0,_.jsx)(`input`,{type:`checkbox`,"aria-label":`全选本页记录`,checked:Q,disabled:X.length===0,onChange:e=>{let t=e.target.checked;M(e=>{let n={...e};for(let e of X)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,_.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,"aria-label":`行号`}),(0,_.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`当前日期`,(0,_.jsx)(c,{...W.resizeProps(2)})]}),(0,_.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`测试统计维度`,(0,_.jsx)(c,{...W.resizeProps(3)})]}),(0,_.jsxs)(`th`,{className:`relative px-2 py-2 text-center font-medium whitespace-nowrap`,children:[`统计数量`,(0,_.jsx)(c,{...W.resizeProps(4)})]}),(0,_.jsx)(`th`,{className:`px-1 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,_.jsxs)(`tbody`,{children:[K.length===0?(0,_.jsx)(`tr`,{className:`border-t border-stone-100`,children:(0,_.jsx)(`td`,{colSpan:6,className:`px-4 py-14 text-center text-sm text-stone-400`,children:`还没有测试统计记录,点右上角「+ 添加记录」开始。`})}):null,X.map((e,t)=>(0,_.jsxs)(`tr`,{className:`group/row border-t border-stone-100 ${e.id===L?`tw-new-row`:`hover:bg-[#f7f8fa]`}`,children:[(0,_.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,_.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.date} ${e.dimensions.join(`/`)}`,checked:!!j[e.id],onChange:t=>M(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,_.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:(Y-1)*F+t+1}),(0,_.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,_.jsx)(re,{value:e.date,onChange:t=>void $(e.id,{date:t}),placeholder:`选择日期`,className:`h-8 w-full rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,_.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,_.jsx)(oe,{compact:!0,ariaLabel:`测试统计维度`,options:ge,value:e.dimensions[0]??``,onChange:t=>void $(e.id,{dimensions:t?[t]:[]}),placeholder:`选择或创建维度`})}),(0,_.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,_.jsx)(he,{value:e.count,ariaLabel:`统计数量`,onCommit:t=>void $(e.id,{count:t})})}),(0,_.jsx)(`td`,{className:`px-1 py-1 text-center align-middle`,children:(0,_.jsx)(`button`,{type:`button`,disabled:D,onClick:()=>B([e]),"aria-label":`删除 ${e.date} 的记录`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 focus:text-red-600 disabled:opacity-40`,children:me})})]},e.id))]})]})}),K.length>0?(0,_.jsx)(ae,{page:Y,totalPages:J,pageSize:F,busy:D,onPage:P,onPageSize:e=>{I(e),P(1)}}):(0,_.jsx)(`div`,{className:`pb-1`}),(0,_.jsx)(o,{open:z!==null,title:`删除测试统计`,message:z&&z.length>1?`确定删除选中的 ${z.length} 条记录吗?删除后不可恢复。`:`确定删除 ${z?.[0]?.date??``} 的这条记录吗?删除后不可恢复。`,confirmLabel:`删除`,danger:!0,onClose:()=>B(null),onConfirm:()=>void ye()})]}):(0,_.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:`测试统计需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,_.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`testStats`)}):(0,_.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,_.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,_.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{S 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.Crg0VdkS.js";import{a as r,o as i,r as a}from"./plugins.CNOYmeAe.js";import{i as o,n as ee,r as s,t as c}from"./view-prefs.C9Mtta1E.js";import{a as l,i as te,n as u,r as ne,t as re}from"./ConfirmDialog.Dbyjb4-6.js";import{t as d}from"./jsx-runtime.BUXbF_vF.js";import{n as f,t as p}from"./ColumnResize.Bs6GL3DJ.js";import{n as ie,t as m}from"./DatePicker.CMfX7F6z.js";import{t as h}from"./SelectDropdown.flhHcwyd.js";import{A as g,C as _,D as ae,E as oe,M as se,N as ce,P as v,S as y,T as le,_ as b,b as x,g as ue,j as de,k as fe,u as pe,v as S,w as me,x as he,y as C}from"./tasks.WhfT-DnC.js";import{a as w,c as ge,i as T,l as E,n as D,o as O,r as k,s as A,t as j}from"./DrawerField.KANqQwFl.js";var M=e(t(),1),N=d(),_e=8e3,ve=[{key:`select`,width:32,min:28},{key:`index`,width:36,min:28},{key:`title`,min:160},{key:`status`,width:104,min:76},{key:`priority`,width:104,min:84},{key:`task`,width:156,min:96},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`end`,width:108,min:88},{key:`cycle`,width:64,min:52},{key:`remain`,width:86,min:64},{key:`note`,width:120,min:80},{key:`action`,width:80,min:64}],ye=[`title`,`status`,`priority`,`linkedTask`,`startDate`,`dueDate`,`note`],be={in_progress:`bg-[#3370ff] text-white`,pending:`bg-stone-400 text-white`,done:`bg-[#34c724] text-white`,cancelled:`bg-stone-300 text-stone-600`,overdue:`bg-[#f54a45] text-white`},xe={in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,pending:`bg-stone-100 text-stone-600`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},P={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},Se={urgent_important:`bg-[#fee4e3] text-[#c02a26]`,important:`bg-[#fff1e3] text-[#a85b00]`,urgent:`bg-[#fff7d6] text-[#8a6100]`,normal:`bg-stone-100 text-stone-600`,"":`bg-stone-100 text-stone-500`},Ce={pending:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,cancelled:`bg-stone-300`},we={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},F={status:`按状态分组`,priority:`按紧急程度分组`,none:`不分组`},Te=[`status`,`priority`,`none`],Ee=`todos.group-by`,De=[`in_progress`,`pending`,`overdue`,`done`,`cancelled`],Oe=C.map(e=>({value:e,label:x[e]})),ke=[{value:``,label:`未设置`},...b.map(e=>({value:e,label:S[e]}))],Ae=Object.keys(F).map(e=>({value:e,label:F[e]})),je=[{value:`all`,label:`全部紧急程度`},...b.map(e=>({value:e,label:S[e]}))],Me=je.map(e=>e.value),Ne=`todos.priority-filter`,Pe=`todos.search`,Fe=`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300`;function Ie(e){let{value:t,placeholder:n,muted:r,onChange:i,onCommit:a,onCancel:o}=e;return(0,N.jsx)(`input`,{type:`text`,value:t,placeholder:n,onChange:e=>i(e.target.value),onBlur:a,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.blur()):e.key===`Escape`&&(e.preventDefault(),o(),e.currentTarget.blur())},className:`${Fe} ${r&&!t?`text-stone-300`:``}`})}function Le(e){return(0,N.jsx)(m,{value:e.value,onChange:e.onChange,placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}function Re(e){let{open:t,item:n,preset:r,tasks:i,tasksOn:a,onClose:o,onSaved:ee}=e,[s,c]=(0,M.useState)({title:``}),[re,d]=(0,M.useState)(``),[f,p]=(0,M.useState)(!1),[_,ae]=(0,M.useState)(!0);(0,M.useEffect)(()=>{t&&(d(``),p(!1),ae(!0),c(n?{title:n.title,status:n.status,priority:n.priority,linkedTask:n.linkedTask,taskId:n.taskId,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pending`,priority:``,startDate:g(),dueDate:g(),...r}))},[t,n,r]);let se=[{value:``,label:`不关联`},...i.filter(e=>e.status!==`closed`||e.id===n?.taskId).map(e=>({value:e.id,label:e.title}))];function y(e){c(t=>({...t,...e}))}let le=de({startDate:s.startDate??``,dueDate:s.dueDate??``}),b=ce({dueDate:s.dueDate??``}),ue=oe(s.status??`pending`),fe=ue?ie((n&&oe(n.status)?n.taskEndDate:``)||g()):``,pe=b===null?``:s.status===`done`?`已完成`:s.status===`cancelled`?`已取消`:b<0?`逾期 ${Math.abs(b)} 天`:b===0?`今天截止`:`${b} 天`;async function me(){let e=(s.title??``).trim();if(!e)d(`请填写待办名称`);else if(s.startDate&&s.dueDate&&s.dueDate<s.startDate)d(`截止日期不能早于开始日期`);else{p(!0),d(``);try{let t={...s,title:e};n?await v(n.id,t):await he([t],{mode:`manual`}),await ee(),o()}catch(e){d(e instanceof Error?e.message:String(e))}finally{p(!1)}}}return(0,N.jsxs)(te,{open:t,onClose:o,transition:!0,className:`relative z-100`,children:[(0,N.jsx)(u,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,N.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,N.jsxs)(l,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,N.jsx)(ne,{className:`text-base font-semibold text-stone-900`,children:n?`待办详情`:`新建待办`}),(0,N.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,N.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,N.jsx)(D,{icon:(0,N.jsx)(E,{}),label:`待办名称`,children:(0,N.jsx)(`input`,{autoFocus:!0,value:s.title,onChange:e=>y({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),me())},placeholder:`请输入内容`,className:j})}),(0,N.jsx)(D,{icon:(0,N.jsx)(A,{}),label:`待办状态`,children:(0,N.jsx)(k,{ariaLabel:`待办状态`,menuMinWidth:140,options:Oe,value:s.status??`pending`,onChange:e=>y({status:e}),label:x[s.status??`pending`],pillClassName:xe[s.status??`pending`],optionDotClassName:e=>Ce[e]})}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>ae(e=>!e),"aria-expanded":_,className:`flex w-full items-center gap-2 px-6 py-2 text-left text-sm text-stone-600 hover:bg-stone-50`,children:[(0,N.jsx)(`span`,{className:`flex h-4 w-4 items-center justify-center text-stone-400`,children:(0,N.jsx)(ge,{})}),(0,N.jsx)(`span`,{children:`任务详情`}),(0,N.jsx)(`span`,{className:`text-stone-400`,children:(0,N.jsx)(T,{open:_})})]}),_?(0,N.jsxs)(`div`,{className:`ml-[42px] border-l border-stone-100 pl-1`,children:[(0,N.jsx)(D,{icon:(0,N.jsx)(ge,{}),label:`所属任务`,children:a?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(h,{unstyled:!0,showCheck:!1,ariaLabel:`所属任务`,menuMinWidth:220,options:se,value:s.taskId??``,onChange:e=>{y({taskId:e,linkedTask:i.find(t=>t.id===e)?.title??``})},triggerClassName:`h-9 w-full rounded-md px-2 text-sm hover:border-stone-200 focus:border-[#3370ff]`,renderTrigger:()=>(0,N.jsx)(`span`,{className:`truncate ${s.taskId||s.linkedTask?`text-stone-800`:`text-stone-400`}`,children:s.taskId?i.find(e=>e.id===s.taskId)?.title??``:s.linkedTask||`请选择任务`})}),i.length===0?(0,N.jsx)(`p`,{className:`mt-1 px-2 text-xs text-stone-400`,children:`任务管理里还没有任务,可到「任务管理」新建后再关联。`}):null]}):(0,N.jsx)(`div`,{className:`flex h-9 items-center rounded-md bg-stone-50 px-2 text-sm text-stone-400`,children:(0,N.jsx)(`span`,{className:`truncate`,children:s.linkedTask?`${s.linkedTask}(任务管理插件未启用)`:`任务管理插件未启用,无法关联任务`})})}),(0,N.jsx)(D,{icon:(0,N.jsx)(A,{}),label:`重要紧急程度`,children:(0,N.jsx)(k,{ariaLabel:`重要紧急程度`,menuMinWidth:140,options:ke,value:s.priority??``,onChange:e=>y({priority:e}),label:s.priority?S[s.priority]:`未设置`,pillClassName:Se[s.priority??``],optionDotClassName:e=>we[e]})}),(0,N.jsx)(D,{icon:(0,N.jsx)(w,{}),label:`结束日期`,children:(0,N.jsxs)(`div`,{className:`flex h-9 items-center px-2 text-sm tabular-nums`,"aria-readonly":`true`,children:[fe?(0,N.jsx)(`span`,{className:`text-stone-800`,children:fe}):(0,N.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`}),(0,N.jsx)(`span`,{className:`ml-2 text-[11px] text-stone-400`,children:ue?`按完成日期自动记录`:`状态为已完成 / 已取消时自动记录`})]})})]}):null,(0,N.jsx)(D,{icon:(0,N.jsx)(w,{}),label:`开始日期`,children:(0,N.jsx)(m,{value:s.startDate??``,onChange:e=>y({startDate:e}),className:`${j} tabular-nums`})}),(0,N.jsx)(D,{icon:(0,N.jsx)(w,{}),label:`截止日期`,children:(0,N.jsx)(m,{value:s.dueDate??``,onChange:e=>y({dueDate:e}),className:`${j} tabular-nums`})}),(0,N.jsx)(D,{icon:(0,N.jsx)(O,{}),label:`待办周期`,children:(0,N.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:le===null?`—`:`${le} 天`})}),(0,N.jsx)(D,{icon:(0,N.jsx)(O,{}),label:`剩余天数`,children:(0,N.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:pe||`—`})}),(0,N.jsx)(D,{icon:(0,N.jsx)(E,{}),label:`备注`,children:(0,N.jsx)(`textarea`,{value:s.note??``,onChange:e=>y({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),re?(0,N.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:re}):null]}),(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:o,disabled:f,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>void me(),disabled:f,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:f?`保存中…`:n?`保存`:`新建`})]})]})})]})}function I(){let[e,t]=(0,M.useState)(!1),[l,te]=(0,M.useState)(!0),[u,ne]=(0,M.useState)(null),[d,C]=(0,M.useState)([]),[w,ge]=(0,M.useState)([]),[T,E]=(0,M.useState)(!1),[D,O]=(0,M.useState)(null),[k,A]=(0,M.useState)(!1),[j,Se]=(0,M.useState)(()=>ee(Pe)),[F,Fe]=(0,M.useState)(()=>c(Ne,Me,`all`)),[I,ze]=(0,M.useState)(()=>c(Ee,Te,`status`)),[Be,Ve]=(0,M.useState)({}),[L,He]=(0,M.useState)({});function Ue(e){s(Ee,e),ze(e)}function We(e){s(Ne,e),Fe(e)}function Ge(e){o(Pe,e),Se(e)}let[Ke,qe]=(0,M.useState)({}),[R,z]=(0,M.useState)(null),[B,V]=(0,M.useState)(null),[Je,Ye]=(0,M.useState)(!1),[Xe,Ze]=(0,M.useState)(null),H=(0,M.useRef)(!0),Qe=(0,M.useRef)(!1),U=(0,M.useRef)(!1),W=f(`lh:todos:cols:v1`,ve),$e=R!==null,G=(0,M.useRef)(R);G.current=R;let et=(0,M.useRef)(!1),tt=(0,M.useRef)(async()=>{});tt.current=ot,(0,M.useEffect)(()=>(H.current=!0,()=>{H.current=!1}),[]),(0,M.useEffect)(()=>{if(!$e)return;let e=e=>{let t=e.target;if(!(t instanceof Element)||t.closest(`.tw-new-row`)||t.closest(`.tw-date-panel`)||t.closest(`.tw-select-menu`))return;let n=G.current;if(!n)return;if(n.title.trim()){tt.current();return}let r=g();!n.note.trim()&&!n.taskId&&n.status===n.baseStatus&&n.priority===n.basePriority&&n.startDate===r&&n.dueDate===r&&z(null)};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[$e]);let K=(0,M.useCallback)(async()=>{try{let[e,t]=await Promise.all([ae(),T?pe().catch(()=>[]):Promise.resolve([])]);if(!H.current)return;let n=t;if(!Qe.current&&T){Qe.current=!0;let r=new Set(e.filter(e=>e.status===`pending`||e.status===`in_progress`).map(e=>e.taskId).filter(Boolean)),i=t.filter(e=>r.has(e.id)&&(e.status===`pool`||e.status===`done`));if(i.length){let e=await Promise.all(i.map(e=>ue(e.id,{status:`in_progress`}).catch(()=>null))),r=new Map(e.filter(e=>!!e).map(e=>[e.id,e]));n=t.map(e=>r.get(e.id)??e)}}C(e),ge(n),O(null)}catch(e){if(!H.current)return;O(e instanceof Error?e.message:String(e))}},[T]);(0,M.useEffect)(()=>{let e=r(e=>{te(!!e.todos),E(!!e.tasks)});return n().then(()=>{te(a(`todos`)),E(a(`tasks`)),t(!0)}),e},[]),(0,M.useEffect)(()=>{e&&l&&(async()=>{let e=await me();H.current&&(e?(await K(),H.current&&ne(!0)):ne(!1))})()},[e,l,K]),(0,M.useEffect)(()=>{if(u!==!0)return;let e=window.setInterval(()=>{U.current||K()},_e),t=()=>{U.current||K()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[u,K]),(0,M.useEffect)(()=>{if(!T||u!==!0||w.length===0)return;let e=d.filter(e=>!e.taskId&&e.linkedTask.trim());if(!e.length)return;let t=!1;return(async()=>{let n=[];for(let t of e){let e=w.find(e=>e.title.trim()===t.linkedTask.trim());if(e)try{n.push(await v(t.id,{taskId:e.id}))}catch{}}!t&&n.length&&C(e=>e.map(e=>n.find(t=>t.id===e.id)??e))})(),()=>{t=!0}},[T,u,d,w]);function nt(e,t,n){qe(r=>({...r,[e]:{...r[e],[t]:n}}))}function q(e){qe(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})}let rt=(0,M.useMemo)(()=>[{value:``,label:`不关联`},...w.filter(e=>e.status!==`closed`).map(e=>({value:e.id,label:e.title}))],[w]);function J(e){return e.taskId?w.find(t=>t.id===e.taskId)?.title??e.linkedTask:e.linkedTask}async function Y(e,t){C(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await v(e,t);if(!H.current)return;C(t=>t.map(t=>t.id===e?n:t)),O(null),t.taskId&&await K()}catch(e){O(e instanceof Error?e.message:String(e)),await K()}}async function it(e){let t=Ke[e],n=d.find(t=>t.id===e);if(!t||!n)return;let r={},i=n;for(let e of ye){let n=t[e];n!==void 0&&String(i[e]??``)!==String(n)&&(r[e]=n)}if(!Object.keys(r).length)q(e);else if(typeof r.title==`string`&&!r.title.trim())O(`待办名称不能为空`),q(e);else try{let t=await v(e,r);if(!H.current)return;C(n=>n.map(n=>n.id===e?t:n)),qe(t=>{let n=t[e];if(!n)return t;let i={...n};for(let e of Object.keys(r))String(i[e]??``)===String(r[e]??``)&&delete i[e];if(!Object.keys(i).length){let n={...t};return delete n[e],n}return{...t,[e]:i}}),O(null)}catch(t){O(t instanceof Error?t.message:String(t)),q(e)}}function at(e){let t=e.newStatus??`pending`,n=e.newPriority??``;z({groupKey:e.key,title:``,status:t,priority:n,taskId:``,startDate:g(),dueDate:g(),note:``,baseStatus:t,basePriority:n}),Ve(t=>({...t,[e.key]:!1}))}async function ot(){let e=G.current;if(!e||et.current)return;let t=e.title.trim();if(t){et.current=!0,Ye(!0);try{let n=w.find(t=>t.id===e.taskId);await he([{title:t,status:e.status,priority:e.priority,taskId:e.taskId,linkedTask:n?.title??``,startDate:e.startDate,dueDate:e.dueDate,note:e.note}],{mode:`manual`}),G.current===e&&z(null),O(null),await K()}catch(e){O(e instanceof Error?e.message:String(e))}finally{et.current=!1,H.current&&Ye(!1)}}}async function st(){let e=B;if(e){V(null),A(!0),O(null);try{await y(e.map(e=>e.id)),He({}),await K()}catch(e){O(e instanceof Error?e.message:String(e))}finally{H.current&&A(!1)}}}let X=g(),ct=(0,M.useMemo)(()=>le(d,{status:`all`,priority:F,keyword:j,today:X}),[d,F,j,X]),Z=(0,M.useMemo)(()=>fe(ct),[ct]),lt=(0,M.useMemo)(()=>I===`none`?[{key:`all`,label:`全部待办`,pill:`bg-stone-500 text-white`,items:Z}]:I===`priority`?[...b,``].map(e=>({key:`priority:${e||`none`}`,label:e?S[e]:`未设置`,pill:e?P[e]:`bg-stone-300 text-stone-600`,items:Z.filter(t=>t.priority===e),newPriority:e})):De.map(e=>({key:`status:${e}`,label:x[e],pill:be[e],items:Z.filter(t=>_(t,X)===e),newStatus:e===`overdue`?`pending`:e})),[I,Z,X]).filter(e=>e.items.length>0||R?.groupKey===e.key&&!!R),Q=Object.keys(L).filter(e=>L[e]),$=(0,M.useMemo)(()=>{let e={total:d.length,pending:0,in_progress:0,done:0,overdue:0};for(let t of d){let n=_(t,X);n===`overdue`?e.overdue+=1:n===`pending`?e.pending+=1:n===`in_progress`?e.in_progress+=1:n===`done`&&(e.done+=1)}return e},[d,X]);return e?l?u===null?(0,N.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接待办服务`,children:(0,N.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,N.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):u?(0,N.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,N.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,N.jsx)(`span`,{className:`font-medium text-stone-800`,children:$.total}),` 条`,(0,N.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 待开始 `,$.pending,` · 进行中 `,$.in_progress,` · 已完成 `,$.done,$.overdue?` · 已延期 ${$.overdue}`:``]})]}),(0,N.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`input`,{value:j,onChange:e=>Ge(e.target.value),placeholder:`搜索待办…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,N.jsx)(h,{flat:!0,className:`w-[132px]`,ariaLabel:`分组方式`,options:Ae,value:I,onChange:e=>Ue(e)}),(0,N.jsx)(h,{flat:!0,className:`w-[136px]`,ariaLabel:`紧急程度筛选`,options:je,value:F,onChange:e=>We(e)}),(0,N.jsx)(`button`,{type:`button`,disabled:k||Q.length===0,onClick:()=>V(d.filter(e=>L[e.id])),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,N.jsx)(`button`,{type:`button`,disabled:k,onClick:()=>Ze({item:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建待办`})]})]}),D?(0,N.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1`,children:D}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>O(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,N.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{U.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{U.current=!!document.activeElement?.closest(`.tw-todo-table`)},0)},children:(0,N.jsxs)(`table`,{className:`tw-todo-table w-full table-fixed border-collapse text-sm`,style:W.tableStyle,children:[(0,N.jsx)(`colgroup`,{children:ve.map(e=>(0,N.jsx)(`col`,{style:W.widthOf(e.key)?{width:W.widthOf(e.key)}:void 0},e.key))}),(0,N.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,N.jsxs)(`tr`,{children:[(0,N.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,children:(0,N.jsx)(`input`,{type:`checkbox`,"aria-label":`全选可见待办`,checked:Z.length>0&&Z.every(e=>L[e.id]),onChange:e=>{let t=e.target.checked;He(e=>{let n={...e};for(let e of Z)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,N.jsx)(`th`,{className:`px-1 py-2 text-left font-medium`,"aria-label":`行号`}),(0,N.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办名称`,(0,N.jsx)(p,{...W.resizeProps(2)})]}),(0,N.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办状态`,(0,N.jsx)(p,{...W.resizeProps(3)})]}),(0,N.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,N.jsx)(p,{...W.resizeProps(4)})]}),(0,N.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属任务`,(0,N.jsx)(p,{...W.resizeProps(5)})]}),(0,N.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,N.jsx)(p,{...W.resizeProps(6)})]}),(0,N.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,N.jsx)(p,{...W.resizeProps(7)})]}),(0,N.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`结束日期`,(0,N.jsx)(p,{...W.resizeProps(8)})]}),(0,N.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`周期`,(0,N.jsx)(p,{...W.resizeProps(9)})]}),(0,N.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`剩余`,(0,N.jsx)(p,{...W.resizeProps(10)})]}),(0,N.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,N.jsx)(p,{...W.resizeProps(11)})]}),(0,N.jsx)(`th`,{className:`px-1 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),lt.map(e=>{let t=Be[e.key]===!0;return(0,N.jsxs)(`tbody`,{children:[(0,N.jsx)(`tr`,{className:`border-t border-stone-100 bg-white`,children:(0,N.jsx)(`td`,{colSpan:13,className:`px-2 py-0 pt-3 pb-1.5`,children:(0,N.jsxs)(`button`,{type:`button`,onClick:()=>Ve(n=>({...n,[e.key]:!t})),className:`flex items-center gap-2 rounded-md px-1 py-0.5 text-left hover:bg-stone-50`,"aria-expanded":!t,children:[(0,N.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`12`,height:`12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`text-stone-400 transition-transform ${t?`-rotate-90`:``}`,children:(0,N.jsx)(`path`,{d:`m6 9 6 6 6-6`})}),(0,N.jsx)(`span`,{className:`rounded-md px-2 py-0.5 text-xs font-medium ${e.pill}`,children:e.label}),(0,N.jsxs)(`span`,{className:`text-xs text-stone-400 tabular-nums`,children:[e.items.length,` 条记录`]})]})})}),t?null:e.items.map((e,t)=>{let n=Ke[e.id]??{},r={...e,...n},i=_(r,X),a=de(r),o=ce(r,X),ee=o===null?`—`:r.status===`done`?`已完成`:r.status===`cancelled`?`已取消`:o<0?`逾期 ${Math.abs(o)} 天`:o===0?`今天截止`:`${o} 天`;return(0,N.jsxs)(`tr`,{className:`group/row border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,N.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.title}`,checked:!!L[e.id],onChange:t=>He(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:t+1}),(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[e.source===`ai`?(0,N.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,title:`AI 记录`,children:`AI`}):null,(0,N.jsx)(Ie,{value:r.title,placeholder:`输入待办名称`,onChange:t=>nt(e.id,`title`,t),onCommit:()=>void it(e.id),onCancel:()=>q(e.id)})]})}),(0,N.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,N.jsx)(h,{unstyled:!0,hideChevron:!0,showCheck:!1,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Oe,value:e.status,onChange:t=>void Y(e.id,{status:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${xe[i]}`,renderTrigger:()=>(0,N.jsx)(`span`,{className:`w-full truncate text-center`,children:x[e.status]}),renderOptionPrefix:e=>(0,N.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Ce[e.value]}`})})}),(0,N.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,N.jsx)(h,{unstyled:!0,hideChevron:!0,showCheck:!1,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:ke,value:e.priority,onChange:t=>void Y(e.id,{priority:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${P[e.priority]}`,renderTrigger:()=>(0,N.jsx)(`span`,{className:`w-full truncate text-center`,children:e.priority?S[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,N.jsx)(`span`,{className:`h-2 w-2 rounded-full ${we[e.value]}`})})}),(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:T?(0,N.jsx)(h,{unstyled:!0,showCheck:!1,ariaLabel:`所属任务`,menuMinWidth:220,options:rt,value:r.taskId,onChange:t=>{let n=w.find(e=>e.id===t);Y(e.id,{taskId:t,linkedTask:n?.title??``})},triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>(0,N.jsx)(`span`,{className:`truncate ${J(r)?`text-stone-800`:`text-stone-300`}`,children:J(r)||`未关联`})}):(0,N.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:J(r)?`${J(r)} · 插件未启用`:`任务管理插件未启用`})}),(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(Le,{value:r.startDate,onChange:t=>void Y(e.id,{startDate:t})})}),(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(Le,{value:r.dueDate,onChange:t=>void Y(e.id,{dueDate:t})})}),(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:se(r)?(0,N.jsx)(`span`,{className:`text-stone-500`,children:ie(se(r))}):(0,N.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}),(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:a===null?`—`:`${a} 天`}),(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums ${o!==null&&o<0&&i!==`done`&&i!==`cancelled`?`font-medium text-[#c02a26]`:`text-stone-500`}`,children:ee}),(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(Ie,{value:r.note,placeholder:`—`,muted:!0,onChange:t=>nt(e.id,`note`,t),onCommit:()=>void it(e.id),onCancel:()=>q(e.id)})}),(0,N.jsx)(`td`,{className:`px-1 py-1 text-right align-middle`,children:(0,N.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>Ze({item:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,N.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,N.jsx)(`path`,{d:`M14 4h6v6`}),(0,N.jsx)(`path`,{d:`M20 4 13 11`}),(0,N.jsx)(`path`,{d:`M10 20H4v-6`}),(0,N.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,N.jsx)(`button`,{type:`button`,disabled:k,onClick:()=>V([e]),"aria-label":`删除 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 focus:text-red-600 disabled:opacity-40`,children:(0,N.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,N.jsx)(`path`,{d:`M3 6h18`}),(0,N.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,N.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,N.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),t?null:R?.groupKey===e.key?(0,N.jsxs)(`tr`,{className:`tw-new-row border-t border-stone-100`,children:[(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:e.items.length+1}),(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(`input`,{autoFocus:!0,value:R.title,disabled:Je,placeholder:`输入待办名称,回车或点空白处保存`,onChange:e=>z(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),ot()):e.key===`Escape`&&(e.preventDefault(),z(null))},className:`h-8 w-full truncate rounded-md border border-[#3370ff]/40 bg-white px-2 text-sm text-stone-800 outline-none focus:border-[#3370ff]`})}),(0,N.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,N.jsx)(h,{unstyled:!0,hideChevron:!0,showCheck:!1,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Oe,value:R.status,onChange:e=>z(t=>t&&{...t,status:e}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${xe[R.status]}`,renderTrigger:()=>(0,N.jsx)(`span`,{className:`w-full truncate text-center`,children:x[R.status]}),renderOptionPrefix:e=>(0,N.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Ce[e.value]}`})})}),(0,N.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,N.jsx)(h,{unstyled:!0,hideChevron:!0,showCheck:!1,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:ke,value:R.priority,onChange:e=>z(t=>t&&{...t,priority:e}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${P[R.priority]}`,renderTrigger:()=>(0,N.jsx)(`span`,{className:`w-full truncate text-center`,children:R.priority?S[R.priority]:`未设置`}),renderOptionPrefix:e=>(0,N.jsx)(`span`,{className:`h-2 w-2 rounded-full ${we[e.value]}`})})}),(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:T?(0,N.jsx)(h,{unstyled:!0,showCheck:!1,ariaLabel:`所属任务`,menuMinWidth:220,options:rt,value:R.taskId,onChange:e=>z(t=>t&&{...t,taskId:e}),triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>{let e=w.find(e=>e.id===R.taskId);return(0,N.jsx)(`span`,{className:`truncate ${e?`text-stone-800`:`text-stone-300`}`,children:e?.title||`未关联`})}}):(0,N.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:`任务管理插件未启用`})}),(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(m,{value:R.startDate,onChange:e=>z(t=>t&&{...t,startDate:e}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(m,{value:R.dueDate,onChange:e=>z(t=>t&&{...t,dueDate:e}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:oe(R.status)?(0,N.jsx)(`span`,{className:`text-stone-500`,children:ie(g())}):(0,N.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}),(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}),(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}),(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(`input`,{value:R.note,disabled:Je,placeholder:`—`,onChange:e=>z(t=>t&&{...t,note:e.target.value}),className:`h-8 w-full truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors placeholder:text-stone-300 hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`})]}):(0,N.jsxs)(`tr`,{className:`border-t border-stone-100`,children:[(0,N.jsx)(`td`,{className:`px-2 py-0.5`}),(0,N.jsx)(`td`,{className:`px-1 py-0.5`}),(0,N.jsx)(`td`,{className:`px-1 py-0.5`,colSpan:11,children:(0,N.jsxs)(`button`,{type:`button`,disabled:Je,onClick:()=>at(e),className:`flex items-center gap-1 rounded px-1 py-0.5 text-xs text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-40`,children:[(0,N.jsx)(`span`,{className:`text-sm leading-none`,children:`+`}),`新增记录`]})})]})]},e.key)}),lt.length===0?(0,N.jsx)(`tbody`,{children:(0,N.jsx)(`tr`,{children:(0,N.jsx)(`td`,{colSpan:13,className:`px-3 py-16 text-center text-sm text-stone-400`,children:d.length===0?`还没有待办`:`没有匹配的待办,试试调整搜索或筛选`})})}):null]})}),(0,N.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,N.jsxs)(`span`,{children:[`共 `,Z.length,` 条`,Q.length?` · 已选 ${Q.length}`:``]}),(0,N.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`点击单元格直接编辑,回车或点空白处保存`})]}),(0,N.jsx)(Re,{open:Xe!==null,item:Xe?.item??null,preset:Xe?.preset,tasks:w,tasksOn:T,onClose:()=>Ze(null),onSaved:K}),(0,N.jsx)(re,{open:B!=null,title:B&&B.length>1?`批量删除`:`删除待办`,message:B&&B.length>1?`确认删除已选中的 ${B.length} 条待办?此操作不可恢复。`:`删除「${B?.[0]?.title??``}」?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>V(null),onConfirm:()=>void st()})]}):(0,N.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:`待办事项需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,N.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`todos`)}):(0,N.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,N.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,N.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{I 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 d(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 f(e){if(!Array.isArray(e))return c.map(e=>({...e}));let t=[],n=new Set;for(let r of e){let e=d(r);e&&!n.has(e.id)&&(n.add(e.id),t.push(e))}return t.length?t:c.map(e=>({...e}))}function p(){return l()}var m=[{id:`tasks`,href:`tasks/`,i18n:`nav.tasks`,plugin:`tasks`,match:`tasks`},{id:`todos`,href:`todos/`,i18n:`nav.todos`,plugin:`todos`,match:`todos`},{id:`reports`,href:`reports/`,i18n:`nav.reports`,plugin:`reports`,match:`reports`},{id:`testStats`,href:`test-stats/`,i18n:`nav.testStats`,plugin:`testStats`,match:`test-stats`},{id:`caseExec`,href:`case-exec/`,i18n:`nav.caseExec`,plugin:`caseExec`,match:`case-exec`},{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`}],h=[],ee=[`prompts`];function te(e){return ee.includes(e)}var g=[`check`,`pencil`,`book`,`fileText`,`layers`,`list`,`folder`,`star`,`database`,`target`,`code`,`flask`,`home`,`clipboard`,`bug`,`calendar`,`chart`,`globe`,`link`,`users`,`terminal`,`tag`,`flag`,`zap`],_={tasks:`clipboard`,todos:`list`,reports:`fileText`,testStats:`chart`,caseExec:`target`,cases:`check`,prompts:`pencil`,knowledgeLib:`book`,requirements:`fileText`,templates:`layers`};function ne(e){return typeof e==`string`&&g.includes(e)}function v(e){let t={..._};if(!e||typeof e!=`object`||Array.isArray(e))return t;for(let n of m){let r=e[n.id];ne(r)&&(t[n.id]=r)}return t}var y=new Set(m.map(e=>e.id));function b(e){return typeof e==`string`&&y.has(e)}function re(e){return m.find(t=>t.id===e)}function x(e){return`item:${e}`}function S(e){return`group:${e}`}function C(){return`ng_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function ie(){return h.map(e=>({id:e.id,name:e.name,items:[...e.items]}))}function w(e,t=!0){if(e==null||!Array.isArray(e))return t?ie():[];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()||C();i.has(o)&&(o=C());let s=[];if(Array.isArray(e.items))for(let t of e.items)b(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 T(e,t){let n=t.name.trim(),r=t.items.filter((e,t,n)=>b(e)&&n.indexOf(e)===t);if(!n||!r.length)return{groups:e,id:t.id?.trim()||``};let i=t.id?.trim()||C(),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:w(c),id:i}}function ae(e,t){return e.filter(e=>e.parentId===t).map(e=>e.id)}function oe(e,t){return e.filter(e=>e.parentId===t)}function se(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 ce(e,t,n){let r=e.find(e=>e.id===t);return!r||!b(n)||r.items.includes(n)?e:T(e,{id:r.id,name:r.name,items:[...r.items,n]}).groups}function le(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 ue(e,t,n,r){let i=x(t),a=S(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),O(c,r)}function E(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 m){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 D(e){return E(e).map(e=>e.type===`item`?x(e.id):S(e.group.id))}function de(e){let t=new Set,n=new Set;for(let r of e){r.parentId||n.add(S(r.id));for(let e of r.items)t.add(e)}for(let e of m)t.has(e.id)||n.add(x(e.id));return n}function O(e,t){let n=de(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 D(t))i.has(e)||r.push(e);return r}function k(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Set(e.flatMap(e=>e.items)),i=O(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);b(t)&&!r.has(t)&&a.push({type:`item`,id:t})}return a}function A(e,t,n){let r=t.find(e=>e.id===n);if(!r)return O(e,t);let i=new Set(r.items.map(e=>x(e))),a=S(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),O(c,t)}function fe(e,t,n,r=[]){if(t.parentId)return O(e,n);let i=S(t.id),a=[...r.map(e=>S(e)),...t.items.map(e=>x(e))],o=e.filter(e=>e!==i);return o.push(...a),O(o,n)}function pe(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`,me=`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 P(e){let t=String(e||``).trim();t&&(N(`session`,j,t),N(`local`,j,t))}function F(){let e=M(`session`,j);if(e)return e;let t=M(`local`,j);if(t)return t;try{let e=sessionStorage.getItem(me);if(!e)return``;let t=JSON.parse(e);return String(t?.activeId||``).trim()}catch{return``}}function I(e){let t=F();return t?`${e}::${t}`:e}var L=`/__tb_config`,R=`tw.app.config.v1`,z=`tw.app.apikey.v1`,B=`tw.app.model.v1`,V=!1,H=null,U=``,W=!1,he={language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``};function G(){return`p_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function ge(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()||G(),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 _e(e){let t=typeof e.baseURL==`string`?e.baseURL.trim():``,n=typeof e.model==`string`?e.model.trim():``;return!t&&!n&&!e.apiKey?[]:[{id:G(),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 K(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=>ge(e)).filter(e=>!!e):e&&(e.baseURL||e.model||e.apiKey)&&(n=_e(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 q(){return{version:1,model:{activeId:``,reasoningEffort:`high`,providers:[]},access:`readonly`,general:{...he},plugins:{cases:!1,caseGen:!1,prompts:!0,promptGen:!1,knowledgeLib:!1,knowledgeGen:!1,requirements:!1,templates:!1,knowledge:!1,memory:!1,pluginDev:!1,todos:!1,tasks:!1,reports:!1,testStats:!1,caseExec:!1},caseTypes:e.map(e=>({...e})),promptKinds:c.map(e=>({...e})),knowledgeCategories:[...o],navGroups:h.map(e=>({...e,items:[...e.items]})),navIcons:{..._},navOrder:D(h)}}function J(e){let t=q();if(!e||typeof e!=`object`)return t;let n=e.general&&typeof e.general==`object`?e.general:{},r={...t.plugins,...e.plugins??{}},a=w(e.navGroups);return{version:typeof e.version==`number`?e.version:1,model:K(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:f(e.promptKinds),knowledgeCategories:s(e.knowledgeCategories),navGroups:a,navIcons:v(e.navIcons),navOrder:O(e.navOrder,a)}}function ve(){try{let e=localStorage.getItem(B);if(e)return K(JSON.parse(e))}catch{}try{let e=localStorage.getItem(I(R));if(e){let t=JSON.parse(e);if(t?.model)return K(t.model)}}catch{}return null}function ye(e){try{localStorage.setItem(B,JSON.stringify(e))}catch{}}function Y(){try{let e=localStorage.getItem(I(R)),t=ve();if(!e)return t?J({...q(),model:t}):null;let n=J(JSON.parse(e));return t&&(n.model=t),n}catch{return null}}function X(e){try{let{model:t,...n}=e;localStorage.setItem(I(R),JSON.stringify(n)),ye(t)}catch{}}function be(){try{return localStorage.getItem(z)?.trim()||localStorage.getItem(I(z))?.trim()||``}catch{return``}}function xe(e){try{e?localStorage.setItem(z,e):localStorage.removeItem(z),localStorage.removeItem(I(z))}catch{}}function Se(){try{let e=q(),t=!1,n=localStorage.getItem(`tw-llm-settings`);if(n){let r=JSON.parse(n);e.model=K({providers:[{id:G(),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=J({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 Z(e){let t=e.model.providers;return t.length?t.find(t=>t.id===e.model.activeId)??t[0]??null:null}function Ce(){return V}function we(){return H||Te(),H??q()}function Te(){if(!W&&(W=!0,typeof window<`u`))try{let e=Y();e&&(H=e)}catch{}}function Ee(){return U}function De(){return[...H?.model.providers??[]]}async function Oe(){try{let e=await fetch(L,{signal:AbortSignal.timeout(2e3)});if(e.ok){let t=await e.json();H=J(t.config);let n=Z(H),r=String(t.apiKey??``).trim();return U=r||n?.apiKey?.trim()||``,r&&n&&!n.apiKey&&(U=r),V=!0,X(H),H}}catch{}V=!1;let e=Y();return e||=Se()??q(),H=e,U=Z(e)?.apiKey?.trim()||be(),X(H),H}var Q=null;async function $(e){if(X(e),V)try{await fetch(L,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({config:e})})}catch{}}function ke(e){let t=H??q(),n=J({...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 H=n,U=Z(n)?.apiKey?.trim()||``,Q&&clearTimeout(Q),Q=setTimeout(()=>{Q=null,$(n)},280),n}function Ae(){return Q&&=(clearTimeout(Q),null),$(H??q())}function je(e){if(U=e.trim(),V||xe(U),!H)return;let t=H.model.providers.map(e=>e.id===H.model.activeId?{...e,apiKey:U||void 0}:e);H=J({...H,model:{...H.model,providers:t}})}function Me(){let e=H;if(!e)return null;let t=Z(e);if(!t?.baseURL?.trim()||!t.model?.trim())return null;let n=(t.apiKey||U).trim();return n?{baseURL:t.baseURL.trim(),apiKey:n,model:t.model.trim(),reasoningEffort:e.model.reasoningEffort,availableModels:t.availableModels}:null}function Ne(){return G()}export{A,s as B,x as C,O as D,v as E,c as F,n as H,u as I,p as L,se as M,pe as N,ue as O,T as P,f as R,te as S,w as T,a as U,e as V,i as W,ce as _,Ce as a,re as b,je as c,F as d,P as f,g,m as h,Oe as i,le as j,fe as k,Me as l,_ as m,Ee as n,De as o,I as p,we as r,Ne as s,Ae as t,ke as u,k as v,oe as w,S as x,ae as y,o as z};
|