blade-code 0.11.2 → 0.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blade.js +2 -2
- package/dist/{chunk-a3dz41pd.js → chunk-0759ckbc.js} +1 -1
- package/dist/{chunk-04qhtx2w.js → chunk-0pcrccgp.js} +1 -1
- package/dist/{chunk-0kxya4ye.js → chunk-33w0b9r4.js} +1 -1
- package/dist/{chunk-kaj8jaj5.js → chunk-3rxs9vxm.js} +1 -1
- package/dist/{chunk-f9qrjd2f.js → chunk-45xdp95z.js} +1 -1
- package/dist/{chunk-tx9tb485.js → chunk-5qrw9g8c.js} +1 -1
- package/dist/chunk-b3kvf23h.js +357 -0
- package/dist/{chunk-21qsfewd.js → chunk-b7pn03pb.js} +1 -1
- package/dist/{chunk-t3pkk95s.js → chunk-b8hm4td5.js} +1 -1
- package/dist/{chunk-s7x4x6xw.js → chunk-cmpxdek8.js} +1 -1
- package/dist/{chunk-8q6zsznc.js → chunk-crbt25b4.js} +1 -1
- package/dist/{chunk-ebvzp8tn.js → chunk-dv5ts9ae.js} +1 -1
- package/dist/{chunk-zwe1a7xe.js → chunk-dyf12wbv.js} +1 -1
- package/dist/{chunk-634ymwg5.js → chunk-fa5sebe2.js} +1 -1
- package/dist/{chunk-7rz5dt79.js → chunk-faedrfhd.js} +2 -2
- package/dist/{chunk-enmn892r.js → chunk-ffq1k7q5.js} +1 -1
- package/dist/{chunk-65v1vjvg.js → chunk-fnvh22vc.js} +1 -1
- package/dist/{chunk-p665f6pn.js → chunk-gfhb2h6z.js} +1 -1
- package/dist/{chunk-pjeks4cz.js → chunk-gqypt03h.js} +1 -1
- package/dist/{chunk-gymecxcc.js → chunk-hn2p1296.js} +1 -1
- package/dist/chunk-hnnhpv75.js +1 -0
- package/dist/{chunk-vemyfx92.js → chunk-hzz27w5w.js} +1 -1
- package/dist/{chunk-fb2x1026.js → chunk-jm1chm6x.js} +1 -1
- package/dist/{chunk-290p3r7a.js → chunk-kb4hwa5a.js} +1 -1
- package/dist/{chunk-qhcd0ww0.js → chunk-kdtj92em.js} +1 -1
- package/dist/{chunk-qyfbeg5h.js → chunk-mmpcq1yh.js} +1 -1
- package/dist/{chunk-k2rgg45h.js → chunk-mqfayxf7.js} +1 -1
- package/dist/{chunk-er6zghgg.js → chunk-nts19h6v.js} +1 -1
- package/dist/{chunk-re8p2y22.js → chunk-nvj4da2w.js} +1 -1
- package/dist/{chunk-yjcp8jk1.js → chunk-pbckwd41.js} +1 -1
- package/dist/{chunk-xnys4bgs.js → chunk-prqtwzxd.js} +1 -1
- package/dist/{chunk-g7pjgspy.js → chunk-qvew5nk3.js} +1 -1
- package/dist/{chunk-h4b4fn3t.js → chunk-qy6p8bpr.js} +1 -1
- package/dist/{chunk-6x5f6she.js → chunk-r5svk833.js} +1 -1
- package/dist/{chunk-3ee357pw.js → chunk-r9nyzqzb.js} +5 -5
- package/dist/{chunk-xrgeakpy.js → chunk-s3pnhdqk.js} +1 -1
- package/dist/{chunk-2fdghgmf.js → chunk-t0swttvj.js} +2 -2
- package/dist/{chunk-qa86anwd.js → chunk-x2crj6jq.js} +1 -1
- package/dist/chunk-yw3achrm.js +1 -0
- package/dist/{chunk-zf72e5w8.js → chunk-zc8erdkc.js} +1 -1
- package/dist/web/assets/ChatView-CvuKp3Yl.js +17 -0
- package/dist/web/assets/{CodeBlockHighlighter-OvLyFs9U.js → CodeBlockHighlighter-CYiAdOLs.js} +1 -1
- package/dist/web/assets/FilePreview-DGolvoH6.js +8 -0
- package/dist/web/assets/KanbanBoard-DdwrLpvb.js +1 -0
- package/dist/web/assets/{MarkdownRenderer-BTxnqChi.js → MarkdownRenderer-fJny7W8J.js} +3 -3
- package/dist/web/assets/{ScrollArea-BdOqyQ3g.js → ScrollArea-CSCl8r35.js} +1 -1
- package/dist/web/assets/{SessionHistorySurface-DaKE2oKU.js → SessionHistorySurface-dttyHhtN.js} +1 -1
- package/dist/web/assets/SettingsModal-Bn9m-F-v.js +5 -0
- package/dist/web/assets/Sidebar-JYvLuHTi.js +1 -0
- package/dist/web/assets/{TaskSwitcher-DKelLFZm.js → TaskSwitcher-InE9ArQH.js} +1 -1
- package/dist/web/assets/{TerminalPanel-D5Rieq62.js → TerminalPanel-BLRAlQoa.js} +1 -1
- package/dist/web/assets/{archive-CsFSEMp9.js → archive-D3alcPOa.js} +1 -1
- package/dist/web/assets/{arrow-left-gaino9Tb.js → arrow-left-CNfcSdE2.js} +1 -1
- package/dist/web/assets/{calendar-clock-DfHUrEw9.js → calendar-clock-BoRTfsxW.js} +1 -1
- package/dist/web/assets/chevron-right-B8JH5N50.js +1 -0
- package/dist/web/assets/{clock-3-dWIDc9IF.js → clock-3-BGymk4sE.js} +1 -1
- package/dist/web/assets/{copy-BPfhyh47.js → copy-CLG3LQ2v.js} +1 -1
- package/dist/web/assets/{dist-RGayDvc-.js → dist-BtGkS2rG.js} +1 -1
- package/dist/web/assets/{download-BR2L5Wme.js → download-DxK6pukC.js} +1 -1
- package/dist/web/assets/{folder-8dmZJ2a6.js → folder-B0xRimYH.js} +1 -1
- package/dist/web/assets/index-BJdxoBtv.css +1 -0
- package/dist/web/assets/{index-DSa8Dzp7.js → index-DkwePtIh.js} +4 -4
- package/dist/web/assets/{pause-DLZIDFMB.js → pause-CKNq9DgJ.js} +1 -1
- package/dist/web/assets/{pencil-DkC0bPYD.js → pencil-CMjIwtk5.js} +1 -1
- package/dist/web/assets/{play-BVeNn6fv.js → play-BOz9Sqzf.js} +1 -1
- package/dist/web/assets/plus-BJIEQjD7.js +1 -0
- package/dist/web/assets/preload-helper-HI3NtP3B.js +1 -0
- package/dist/web/assets/{session-events-BuMTbIwu.js → session-events-B-hnDC4L.js} +3 -3
- package/dist/web/assets/{settings-msYyNDKx.js → settings-CP6ArjQ7.js} +1 -1
- package/dist/web/assets/team-BHlihaeV.js +1 -0
- package/dist/web/assets/{teamService-Bus5RDi1.js → teamService-DDfifLYm.js} +1 -1
- package/dist/web/assets/{terminal-Cp5WYo8w.js → terminal-BYHhWXe-.js} +1 -1
- package/dist/web/assets/tooltip-DJBQZhJD.js +1 -0
- package/dist/web/assets/triangle-alert-BCJaJaVj.js +1 -0
- package/dist/web/assets/{vendor-radix-L0yJCKJX.js → vendor-radix-BCAvgfOW.js} +1 -1
- package/dist/web/assets/{vendor-react-CHEIQMI-.js → vendor-react-DQwAdeyS.js} +1 -1
- package/dist/web/index.html +5 -5
- package/package.json +1 -1
- package/dist/chunk-d4xsrx3z.js +0 -357
- package/dist/chunk-eg0s155w.js +0 -1
- package/dist/chunk-gff7a5q0.js +0 -1
- package/dist/web/assets/ChatView-DysPZPwF.js +0 -17
- package/dist/web/assets/FilePreview-CkSPwPdW.js +0 -8
- package/dist/web/assets/KanbanBoard-DH1wApt6.js +0 -1
- package/dist/web/assets/SettingsModal-CWlSSO_E.js +0 -5
- package/dist/web/assets/Sidebar-Dirk-XAQ.js +0 -1
- package/dist/web/assets/chevron-right-Bvu2j6hB.js +0 -1
- package/dist/web/assets/index-B7RyuO2x.css +0 -1
- package/dist/web/assets/message-square-plus-BgC981WF.js +0 -1
- package/dist/web/assets/plus-kzdwas-3.js +0 -1
- package/dist/web/assets/preload-helper-DvgLbiBV.js +0 -1
- package/dist/web/assets/team-D3XOVbxL.js +0 -1
- package/dist/web/assets/triangle-alert-cGqHxFsZ.js +0 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{dt as n,i as r}from"./session-events-B-hnDC4L.js";import{C as i,S as a,x as o}from"./vendor-radix-BCAvgfOW.js";import{c as s,l as c,r as l,s as u}from"./preload-helper-HI3NtP3B.js";import{n as d,r as f,t as p}from"./triangle-alert-BCJaJaVj.js";import{t as m}from"./arrow-left-CNfcSdE2.js";import{t as h}from"./calendar-clock-BoRTfsxW.js";import{t as g}from"./download-DxK6pukC.js";import{t as _}from"./pencil-CMjIwtk5.js";import{t as v}from"./play-BOz9Sqzf.js";import{t as y}from"./plus-BJIEQjD7.js";import{$ as b,F as x,I as S,L as C,S as w,U as T,V as E,W as D,X as O,_t as k,a as A,at as j,b as M,ct as N,d as P,f as F,g as I,m as ee,p as L,q as te,rt as ne,vt as re,y as R,yt as z}from"./index-DkwePtIh.js";import{t as B}from"./ScrollArea-CSCl8r35.js";import{t as ie}from"./team-BHlihaeV.js";var V={name:`eye-off`,size:24,node:[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};V.node;var ae=c(V),H={name:`eye`,size:24,node:[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};H.node;var oe=c(H),se={name:`store`,size:24,node:[[`path`,{d:`M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5`,key:`slp6dd`}],[`path`,{d:`M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244`,key:`o0xfot`}],[`path`,{d:`M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05`,key:`wn3emo`}]]};se.node;var U=c(se),W=e(n()),G=e=>(t,n)=>{let r=(0,W.useRef)(!1);e(()=>()=>{r.current=!1},[]),e(()=>{if(!r.current)r.current=!0;else return t()},n)},K=e=>typeof e==`function`,q=e=>e!=null,ce=e=>q(e)&&K(e.then),J=e=>{let t=(0,W.useRef)(e);t.current=(0,W.useMemo)(()=>e,[e]);let n=(0,W.useRef)(void 0);return n.current||=function(...e){return t.current.apply(this,e)},n.current},Y=G(W.useEffect),le=(e,{manual:t,ready:n=!0,defaultParams:r=[],refreshDeps:i=[],refreshDepsAction:a})=>{let o=(0,W.useRef)(!1);return o.current=!1,Y(()=>{!t&&n&&(o.current=!0,e.run(...r))},[n]),Y(()=>{o.current||t||(o.current=!0,a?a():e.refresh())},[...i]),{onBefore:()=>{if(!n)return{stopNow:!0}}}};le.onInit=({ready:e=!0,manual:t})=>({loading:!t&&e});function ue(e,t){if(e===t)return!0;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}var X=(e,t)=>{let{current:n}=(0,W.useRef)({deps:t,obj:void 0,initialized:!1});return(n.initialized===!1||!ue(n.deps,t))&&(n.deps=t,n.obj=e(),n.initialized=!0),n.obj};function de(e){let t=(0,W.useRef)(e);return t.current=e,t}var fe=e=>{let t=de(e);(0,W.useEffect)(()=>()=>{t.current()},[])},Z=new Map,pe=e=>{e?.timer&&clearTimeout(e.timer)},me=(e,t,n)=>{pe(Z.get(e));let r;t>-1&&(r=setTimeout(()=>{Z.delete(e)},t)),Z.set(e,Object.assign(Object.assign({},n),{timer:r}))},he=e=>Z.get(e),ge=new Map,_e=e=>ge.get(e),ve=(e,t)=>{ge.set(e,t),t.then(t=>(ge.delete(e),t)).catch(()=>{ge.delete(e)})},Q={},ye=(e,t)=>{Q[e]&&Q[e].forEach(e=>e(t))},be=(e,t)=>(Q[e]||(Q[e]=[]),Q[e].push(t),function(){let n=Q[e].indexOf(t);Q[e].splice(n,1)}),xe=(e,{cacheKey:t,cacheTime:n=3e5,staleTime:r=0,setCache:i,getCache:a})=>{let o=(0,W.useRef)(void 0),s=(0,W.useRef)(void 0),c=(e,t)=>{i?i(t):me(e,n,t),ye(e,t.data)},l=(e,t=[])=>a?a(t):he(e);return X(()=>{if(!t)return;let n=l(t);n&&Object.hasOwnProperty.call(n,`data`)&&(e.state.data=n.data,e.state.params=n.params,(r===-1||Date.now()-n.time<=r)&&(e.state.loading=!1)),o.current=be(t,t=>{e.setState({data:t})})},[]),fe(()=>{var e;(e=o.current)==null||e.call(o)}),t?{onBefore:e=>{let n=l(t,e);return!n||!Object.hasOwnProperty.call(n,`data`)?{}:r===-1||Date.now()-n.time<=r?{loading:!1,data:n?.data,error:void 0,returnNow:!0}:{data:n?.data,error:void 0}},onRequest:(e,n)=>{let r=_e(t);return r&&r!==s.current?{servicePromise:r}:(r=e(...n),s.current=r,ve(t,r),{servicePromise:r})},onSuccess:(n,r)=>{var i;t&&((i=o.current)==null||i.call(o),c(t,{data:n,params:r,time:Date.now()}),o.current=be(t,t=>{e.setState({data:t})}))},onMutate:n=>{var r;t&&((r=o.current)==null||r.call(o),c(t,{data:n,params:e.state.params,time:Date.now()}),o.current=be(t,t=>{e.setState({data:t})}))}}:{}},Se=t(((e,t)=>{function n(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}t.exports=n})),Ce=t(((e,t)=>{t.exports=typeof global==`object`&&global&&global.Object===Object&&global})),we=t(((e,t)=>{var n=Ce(),r=typeof self==`object`&&self&&self.Object===Object&&self;t.exports=n||r||Function(`return this`)()})),Te=t(((e,t)=>{var n=we();t.exports=function(){return n.Date.now()}})),Ee=t(((e,t)=>{var n=/\s/;function r(e){for(var t=e.length;t--&&n.test(e.charAt(t)););return t}t.exports=r})),De=t(((e,t)=>{var n=Ee(),r=/^\s+/;function i(e){return e&&e.slice(0,n(e)+1).replace(r,``)}t.exports=i})),Oe=t(((e,t)=>{t.exports=we().Symbol})),ke=t(((e,t)=>{var n=Oe(),r=Object.prototype,i=r.hasOwnProperty,a=r.toString,o=n?n.toStringTag:void 0;function s(e){var t=i.call(e,o),n=e[o];try{e[o]=void 0;var r=!0}catch{}var s=a.call(e);return r&&(t?e[o]=n:delete e[o]),s}t.exports=s})),Ae=t(((e,t)=>{var n=Object.prototype.toString;function r(e){return n.call(e)}t.exports=r})),je=t(((e,t)=>{var n=Oe(),r=ke(),i=Ae(),a=`[object Null]`,o=`[object Undefined]`,s=n?n.toStringTag:void 0;function c(e){return e==null?e===void 0?o:a:s&&s in Object(e)?r(e):i(e)}t.exports=c})),Me=t(((e,t)=>{function n(e){return typeof e==`object`&&!!e}t.exports=n})),Ne=t(((e,t)=>{var n=je(),r=Me(),i=`[object Symbol]`;function a(e){return typeof e==`symbol`||r(e)&&n(e)==i}t.exports=a})),Pe=t(((e,t)=>{var n=De(),r=Se(),i=Ne(),a=NaN,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,c=/^0o[0-7]+$/i,l=parseInt;function u(e){if(typeof e==`number`)return e;if(i(e))return a;if(r(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=r(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=n(e);var u=s.test(e);return u||c.test(e)?l(e.slice(2),u?2:8):o.test(e)?a:+e}t.exports=u})),Fe=t(((e,t)=>{var n=Se(),r=Te(),i=Pe(),a=`Expected a function`,o=Math.max,s=Math.min;function c(e,t,c){var l,u,d,f,p,m,h=0,g=!1,_=!1,v=!0;if(typeof e!=`function`)throw TypeError(a);t=i(t)||0,n(c)&&(g=!!c.leading,_=`maxWait`in c,d=_?o(i(c.maxWait)||0,t):d,v=`trailing`in c?!!c.trailing:v);function y(t){var n=l,r=u;return l=u=void 0,h=t,f=e.apply(r,n),f}function b(e){return h=e,p=setTimeout(C,t),g?y(e):f}function x(e){var n=e-m,r=e-h,i=t-n;return _?s(i,d-r):i}function S(e){var n=e-m,r=e-h;return m===void 0||n>=t||n<0||_&&r>=d}function C(){var e=r();if(S(e))return w(e);p=setTimeout(C,x(e))}function w(e){return p=void 0,v&&l?y(e):(l=u=void 0,f)}function T(){p!==void 0&&clearTimeout(p),h=0,l=m=u=p=void 0}function E(){return p===void 0?f:w(r())}function D(){var e=r(),n=S(e);if(l=arguments,u=this,m=e,n){if(p===void 0)return b(m);if(_)return clearTimeout(p),p=setTimeout(C,t),y(m)}return p===void 0&&(p=setTimeout(C,t)),f}return D.cancel=T,D.flush=E,D}t.exports=c})),Ie,Le=`__AHOOKS_CANCELLED_ERROR__`,Re=class e extends Error{constructor(t=`useRequest: the request was cancelled or superseded.`){super(t),this[Ie]=!0,this.name=`CancelledError`,Object.setPrototypeOf(this,e.prototype)}};Ie=Le;function ze(e){return e instanceof Re||typeof e==`object`&&!!e&&e[Le]===!0}function Be(e){var t;(t=e.current)==null||t.call(e,new Re),e.current=void 0}var Ve=e(Fe()),He=(e,{debounceWait:t,debounceLeading:n,debounceTrailing:r,debounceMaxWait:i,ready:a})=>{let o=(0,W.useRef)(void 0),s=(0,W.useRef)(void 0),c=(0,W.useMemo)(()=>{let e={};return n!==void 0&&(e.leading=n),r!==void 0&&(e.trailing=r),i!==void 0&&(e.maxWait=i),e},[n,r,i]);return(0,W.useEffect)(()=>{if(t){let n=e.runAsync.bind(e);return o.current=(0,Ve.default)(e=>{e()},t,c),e.runAsync=(...t)=>e.options.ready===!1?n(...t):(Be(s),new Promise((e,r)=>{var i;let a=!1;s.current=r,(i=o.current)==null||i.call(o,()=>{a=!0,s.current=void 0,n(...t).then(e).catch(r)}),!a&&c.trailing===!1&&Be(s)})),()=>{var t;(t=o.current)==null||t.cancel(),Be(s),e.runAsync=n}}},[t,c,e]),Y(()=>{var e;a===!1&&((e=o.current)==null||e.cancel(),Be(s))},[a]),t?{onCancel:()=>{var e;(e=o.current)==null||e.cancel(),Be(s)}}:{}},Ue=(e,{loadingDelay:t,ready:n})=>{let r=(0,W.useRef)(void 0);if(!t)return{};let i=()=>{r.current&&clearTimeout(r.current)};return{onBefore:()=>(i(),n!==!1&&(r.current=setTimeout(()=>{e.setState({loading:!0})},t)),{loading:!1}),onFinally:()=>{i()},onCancel:()=>{i()}}},We=!!(typeof window<`u`&&window.document&&window.document.createElement);function Ge(){return!We||document.visibilityState!==`hidden`}var Ke=new Set;function qe(e){return Ke.add(e),function(){Ke.has(e)&&Ke.delete(e)}}We&&window.addEventListener(`visibilitychange`,()=>{Ge()&&Ke.forEach(e=>e())},!1);var Je=(e,{pollingInterval:t,pollingWhenHidden:n=!0,pollingErrorRetryCount:r=-1})=>{let i=(0,W.useRef)(void 0),a=(0,W.useRef)(void 0),o=(0,W.useRef)(0),s=()=>{var e;i.current&&clearTimeout(i.current),(e=a.current)==null||e.call(a)};return Y(()=>{t||s()},[t]),t?{onBefore:()=>{s()},onError:()=>{o.current+=1},onSuccess:()=>{o.current=0},onFinally:()=>{r===-1||r!==-1&&o.current<=r?i.current=setTimeout(()=>{!n&&!Ge()?a.current=qe(()=>{e.refresh()}):e.refresh()},t):o.current=0},onCancel:()=>{s()}}:{}};function Ye(e,t){let n=!1;return(...r)=>{n||(n=!0,e(...r),setTimeout(()=>{n=!1},t))}}var Xe=()=>We&&navigator.onLine!==void 0?navigator.onLine:!0,Ze=new Set;function Qe(e){return Ze.add(e),function(){Ze.has(e)&&Ze.delete(e)}}if(We){let e=()=>{Ge()&&Xe()&&Ze.forEach(e=>e())};window.addEventListener(`visibilitychange`,e,!1),window.addEventListener(`focus`,e,!1)}var $e=(e,{refreshOnWindowFocus:t,focusTimespan:n=5e3})=>{let r=(0,W.useRef)(void 0),i=()=>{var e;(e=r.current)==null||e.call(r)};return(0,W.useEffect)(()=>{if(t){let t=Ye(e.refresh.bind(e),n);r.current=Qe(()=>{t()})}return()=>{i()}},[t,n]),fe(()=>{i()}),{}},et=(e,{retryInterval:t,retryCount:n})=>{let r=(0,W.useRef)(void 0),i=(0,W.useRef)(0),a=(0,W.useRef)(!1);return n?{onBefore:()=>{a.current||(i.current=0),a.current=!1,r.current&&clearTimeout(r.current)},onSuccess:()=>{i.current=0},onError:()=>{if(i.current+=1,n===-1||i.current<=n){let n=t??Math.min(1e3*2**i.current,3e4);r.current=setTimeout(()=>{a.current=!0,e.refresh()},n)}else i.current=0},onCancel:()=>{i.current=0,r.current&&clearTimeout(r.current)}}:{}},tt=e(t(((e,t)=>{var n=Fe(),r=Se(),i=`Expected a function`;function a(e,t,a){var o=!0,s=!0;if(typeof e!=`function`)throw TypeError(i);return r(a)&&(o=`leading`in a?!!a.leading:o,s=`trailing`in a?!!a.trailing:s),n(e,t,{leading:o,maxWait:t,trailing:s})}t.exports=a}))()),nt=(e,{throttleWait:t,throttleLeading:n,throttleTrailing:r})=>{let i=(0,W.useRef)(void 0),a=(0,W.useRef)(void 0),o={};return n!==void 0&&(o.leading=n),r!==void 0&&(o.trailing=r),(0,W.useEffect)(()=>{if(t){let n=e.runAsync.bind(e);return i.current=(0,tt.default)(e=>{e()},t,o),e.runAsync=(...e)=>(Be(a),new Promise((t,r)=>{var s;let c=!1;a.current=r,(s=i.current)==null||s.call(i,()=>{c=!0,a.current=void 0,n(...e).then(t).catch(r)}),!c&&o.trailing===!1&&Be(a)})),()=>{var t;e.runAsync=n,(t=i.current)==null||t.cancel(),Be(a)}}},[t,n,r]),t?{onCancel:()=>{var e;(e=i.current)==null||e.cancel(),Be(a)}}:{}},rt=e=>{(0,W.useEffect)(()=>{let t=e?.();if(!ce(t))return t},[])},it=()=>{let[,e]=(0,W.useState)({});return J(()=>e({}))},at=class{constructor(e,t,n,r={}){this.serviceRef=e,this.options=t,this.subscribe=n,this.initState=r,this.pluginImpls=[],this.count=0,this.state={loading:!1,params:void 0,data:void 0,error:void 0},this.state=Object.assign(Object.assign(Object.assign({},this.state),{loading:!t.manual}),r)}setState(e={}){this.state=Object.assign(Object.assign({},this.state),e),this.subscribe()}runPluginHandler(e,...t){let n=this.pluginImpls.map(n=>n[e]?.call(n,...t)).filter(Boolean);return Object.assign({},...n)}runAsync(...e){return o(this,void 0,void 0,function*(){var t,n,r,i,o,s,c,l,u,d;this.count+=1;let f=this.count,p=this.runPluginHandler(`onBefore`,e),{stopNow:m=!1,returnNow:h=!1}=p,g=a(p,[`stopNow`,`returnNow`]);if(m||(this.setState(Object.assign({loading:!0,params:e},g)),h))return Promise.resolve(g.data);(n=(t=this.options).onBefore)==null||n.call(t,e);try{let{servicePromise:t}=this.runPluginHandler(`onRequest`,this.serviceRef.current,e);t||=this.serviceRef.current(...e);let n=yield t;if(f!==this.count)throw new Re;return this.setState({data:n,error:void 0,loading:!1}),(i=(r=this.options).onSuccess)==null||i.call(r,n,e),this.runPluginHandler(`onSuccess`,n,e),(s=(o=this.options).onFinally)==null||s.call(o,e,n,void 0),f===this.count&&this.runPluginHandler(`onFinally`,e,n,void 0),n}catch(t){throw f===this.count?(this.setState({error:t,loading:!1}),(l=(c=this.options).onError)==null||l.call(c,t,e),this.runPluginHandler(`onError`,t,e),(d=(u=this.options).onFinally)==null||d.call(u,e,void 0,t),f===this.count&&this.runPluginHandler(`onFinally`,e,void 0,t),t):ze(t)?t:new Re}})}run(...e){this.runAsync(...e).catch(e=>{ze(e)||this.options.onError||console.error(e)})}cancel(){this.count+=1,this.setState({loading:!1}),this.runPluginHandler(`onCancel`)}refresh(){this.run(...this.state.params||[])}refreshAsync(){return this.runAsync(...this.state.params||[])}mutate(e){let t=K(e)?e(this.state.data):e;this.runPluginHandler(`onMutate`,t),this.setState({data:t})}};function ot(e,t={},n=[]){let{manual:r=!1,ready:i=!0}=t,o=a(t,[`manual`,`ready`]),s=Object.assign({manual:r,ready:i},o),c=de(e),l=it(),u=X(()=>{let e=n.map(e=>(e?.onInit)?.call(e,s)).filter(Boolean);return new at(c,s,l,Object.assign({},...e))},[]);return u.options=s,u.pluginImpls=n.map(e=>e(u,s)),rt(()=>{if(!r&&i){let e=u.state.params||t.defaultParams||[];u.run(...e)}}),fe(()=>{u.cancel()}),{loading:u.state.loading,data:u.state.data,error:u.state.error,params:u.state.params||[],cancel:J(u.cancel.bind(u)),refresh:J(u.refresh.bind(u)),refreshAsync:J(u.refreshAsync.bind(u)),run:J(u.run.bind(u)),runAsync:J((...e)=>u.runAsync(...e)),mutate:J(u.mutate.bind(u))}}function st(e,t,n){return ot(e,t,[...n||[],He,Ue,Je,$e,nt,le,xe,et])}var ct=st;function lt(e,t){if(!We)return;if(!e)return t;let n;return n=K(e)?e():`current`in e?e.current:e,n}var ut=(e=>(t,n,r)=>{let i=(0,W.useRef)(!1),a=(0,W.useRef)([]),o=(0,W.useRef)([]),s=(0,W.useRef)(void 0);e(()=>{var e;let c=(Array.isArray(r)?r:[r]).map(e=>lt(e));if(!i.current){i.current=!0,a.current=c,o.current=n,s.current=t();return}(c.length!==a.current.length||!ue(a.current,c)||!ue(o.current,n))&&((e=s.current)==null||e.call(s),a.current=c,o.current=n,s.current=t())}),fe(()=>{var e;(e=s.current)==null||e.call(s),i.current=!1})})(W.useEffect);function dt(e,t){let n=de(e),r=t?.wait??1e3,i=(0,W.useMemo)(()=>(0,Ve.default)((...e)=>n.current(...e),r,t),[]);return fe(()=>{i.cancel()}),{run:i,cancel:i.cancel,flush:i.flush}}function ft(e,t,n={}){let{enable:r=!0}=n,i=de(t);ut(()=>{if(!r)return;let t=lt(n.target,window);if(!t?.addEventListener)return;let a=e=>i.current(e),o=Array.isArray(e)?e:[e];return o.forEach(e=>{t.addEventListener(e,a,{capture:n.capture,once:n.once,passive:n.passive})}),()=>{o.forEach(e=>{t.removeEventListener(e,a,{capture:n.capture})})}},[e,n.capture,n.once,n.passive,r],n.target)}var pt=e=>e===document||e===document.documentElement||e===document.body?Math.max(window.pageYOffset,document.documentElement.scrollTop,document.body.scrollTop):e.scrollTop,mt=e=>e.scrollHeight||Math.max(document.documentElement.scrollHeight,document.body.scrollHeight),ht=e=>e.clientHeight||Math.max(document.documentElement.clientHeight,document.body.clientHeight),gt=(e,t={})=>{let{target:n,isNoMore:r,threshold:i=100,direction:a=`bottom`,reloadDeps:s=[],manual:c,onBefore:l,onSuccess:u,onError:d,onFinally:f}=t,[p,m]=(0,W.useState)(),[h,g]=(0,W.useState)(!1),_=a===`top`,v=(0,W.useRef)(void 0),y=(0,W.useRef)(0),b=(0,W.useRef)(!1),x=(0,W.useMemo)(()=>r?r(p):!1,[p]),{loading:S,error:C,run:w,runAsync:T,cancel:E}=ct(t=>o(void 0,void 0,void 0,function*(){return{currentData:yield e(t),lastData:t}}),{manual:c,onFinally:(e,t,n)=>{g(!1),f?.(t?.currentData,n)},onBefore:()=>l?.(),onSuccess:e=>{e.lastData?m(Object.assign(Object.assign({},e.currentData),{list:_?[...e.currentData.list,...e.lastData.list??[]]:[...e.lastData.list??[],...e.currentData.list]})):m(Object.assign(Object.assign({},e.currentData),{list:[...e.currentData.list??[]]})),_?setTimeout(()=>{requestAnimationFrame(()=>{let e=lt(n);if(e=e===document?document.documentElement:e,e){let t=mt(e);e.scrollTo(0,t-y.current)}})}):b.current=!0,u?.(e.currentData)},onError:e=>d?.(e)}),D=J(()=>{x||(g(!0),w(p))}),O=e=>o(void 0,void 0,void 0,function*(){return(yield T(e)).currentData}),k=J(()=>x?Promise.reject():(g(!0),O(p))),A=()=>(g(!1),w()),j=()=>(g(!1),O()),M=()=>{let e=lt(n);if(!e)return;let t=e===document?document.documentElement:e,r=pt(t),a=mt(t),o=ht(t);_?(v.current!==void 0&&v.current>r&&r<=i&&D(),v.current=r,y.current=a-r):a-r<=o+i&&D()};return Y(()=>{b.current&&(b.current=!1,M())},[p]),ft(`scroll`,()=>{S||h||M()},{target:n}),Y(()=>{w()},[...s]),{data:p,loading:!h&&S,error:C,loadingMore:h,noMore:x,loadMore:D,loadMoreAsync:k,reload:J(A),reloadAsync:J(j),mutate:m,cancel:E}},$=i(),_t={connected:`text-[#16A34A] dark:text-[#22C55E]`,connecting:`text-[#2563eb] dark:text-[#3b82f6]`,reconnecting:`text-[#2563eb] dark:text-[#60a5fa]`,offline:`text-[#f59e0b]`,error:`text-[#ef4444]`},vt={connected:`mcp.status.connected`,connecting:`mcp.status.connecting`,reconnecting:`mcp.status.reconnecting`,offline:`mcp.status.offline`,error:`mcp.status.error`},yt={disabled:`mcp.oauth.status.disabled`,unavailable:`mcp.oauth.status.unavailable`,unauthenticated:`mcp.oauth.status.unauthenticated`,authorizing:`mcp.oauth.status.authorizing`,authenticated:`mcp.oauth.status.authenticated`,error:`mcp.oauth.status.error`},bt={Official:`mcp.catalog.tag.official`,Popular:`mcp.catalog.tag.popular`,Community:`mcp.catalog.tag.community`},xt=20,St=[`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`],Ct=(e,t)=>e.status!==`reconnecting`||!e.recovery?t(vt[e.status]):t(`mcp.status.recoveringAttempt`,{attempt:e.recovery.attempt,max:e.recovery.maxAttempts}),wt=async()=>x(`/mcp`),Tt=async e=>x(`/mcp/${encodeURIComponent(e)}/logs?limit=20`),Et=`mcp server @modelcontextprotocol`,Dt=3,Ot=e=>e.split(`/`).pop()?.replace(/^server-/,``)||e,kt=async(e,t)=>{let n=e&&e.length>=Dt?e:Et,r=`https://registry.npmjs.org/-/v1/search?text=${encodeURIComponent(n)}&size=${xt}&from=${t}`,i=await x(r);return{list:i.objects.map(e=>e.package),total:i.total,hasMore:t+xt<i.total}};function At({active:e}){let t=s(),[n,r]=(0,W.useState)(`installed`),[i,a]=(0,W.useState)(!1),[o,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(``),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)(null),[_,v]=(0,W.useState)(null),[S,C]=(0,W.useState)(null),[w,E]=(0,W.useState)(null),[D,O]=(0,W.useState)(``),[A,j]=(0,W.useState)(null),[M,P]=(0,W.useState)(!1),[F,I]=(0,W.useState)(null),[ee,L]=(0,W.useState)(null),[te,re]=(0,W.useState)(``),[R,B]=(0,W.useState)(``),[ie,V]=(0,W.useState)(null),[ae,H]=(0,W.useState)(null),oe=(0,W.useRef)(null),{run:se}=dt(e=>{B(e)},{wait:500}),{data:U=[],loading:G,error:K,run:q,runAsync:ce}=ct(wt,{refreshDeps:[e],ready:e,onSuccess:e=>{e.length>0&&!o&&c(e[0].id)}}),{data:J,loading:Y,error:le,runAsync:ue}=ct(Tt,{manual:!0}),{data:X,loading:de,loadingMore:fe,noMore:Z,error:pe,reload:me}=gt(async e=>{let t=e?.list?.length??0;return kt(R,t)},{target:oe,isNoMore:e=>!e?.hasMore,reloadDeps:[R],manual:!e||n!==`catalog`}),{runAsync:he,loading:ge,error:_e}=ct(async e=>{await x(`/mcp`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e.name,config:e})})},{manual:!0,onSuccess:()=>{ce(),a(!1),H(null),V(null)},onError:()=>{V(null)}}),ve=(0,W.useMemo)(()=>{let e=l.trim().toLowerCase();return e?U.filter(t=>[t.name,t.endpoint,t.description].some(t=>t.toLowerCase().includes(e))):U},[l,U]),Q=(0,W.useMemo)(()=>ve.find(e=>e.id===o)??ve[0],[ve,o]),ye=(0,W.useMemo)(()=>{if(!Q)return[];let e=(Q.prompts??[]).flatMap(e=>e.arguments.map(t=>({key:`prompt:${e.name}:${t.name}`,label:`${e.name}.${t.name}`,reference:{type:`prompt`,name:e.name},argument:t.name}))),t=(Q.resourceTemplates??[]).flatMap(e=>(e.variables??[]).map(t=>({key:`resource:${e.uriTemplate}:${t}`,label:`${e.uriTemplate} · ${t}`,reference:{type:`resource`,uri:e.uriTemplate},argument:t})));return[...e,...t]},[Q]),be=ye.find(e=>e.key===w)??ye[0];(0,W.useEffect)(()=>{if(!e||!U.some(e=>e.oauthStatus===`authorizing`||e.status===`connecting`||e.status===`reconnecting`))return;let t=window.setInterval(()=>{ce()},1e3);return()=>window.clearInterval(t)},[e,ce,U]),(0,W.useEffect)(()=>{m&&U.some(e=>e.name===m.serverName&&(e.oauthStatus===`authenticated`||e.oauthStatus===`disabled`||e.oauthStatus===`unavailable`))&&h(null)},[m,U]),(0,W.useEffect)(()=>{e&&n===`installed`&&Q&&ue(Q.name).catch(()=>void 0)},[e,ue,Q,n]);let xe=async(e,n)=>{v({type:e,name:n}),p(null);try{let t=e===`delete`?``:`/${e}`;await x(`/mcp/${encodeURIComponent(n)}${t}`,{method:e===`delete`?`DELETE`:`POST`}),await ce(),e===`delete`&&(L(null),c(null))}catch(n){p(n instanceof Error?n.message:t(e===`connect`?`mcp.error.connectFailed`:e===`disconnect`?`mcp.error.disconnectFailed`:`mcp.error.deleteFailed`))}finally{v(null)}},Se=async(e,n)=>{v({type:e,name:n.name}),p(null);try{if(e===`login`){let e=await x(`/mcp/${encodeURIComponent(n.name)}/oauth/login`,{method:`POST`});h({serverName:n.name,url:e.authorizationUrl})}else await x(`/mcp/${encodeURIComponent(n.name)}/oauth/logout`,{method:`POST`}),h(null);await ce()}catch(n){p(n instanceof Error?n.message:t(e===`login`?`mcp.error.loginFailed`:`mcp.error.logoutFailed`))}finally{v(null)}},Ce=async(e,n)=>{C(n),p(null);try{await x(`/mcp/${encodeURIComponent(e.name)}/logging-level`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({level:n})}),await ce(),ue(e.name).catch(()=>void 0)}catch(e){p(e instanceof Error?e.message:t(`mcp.error.loggingLevelFailed`))}finally{C(null)}},we=async e=>{if(be){P(!0),I(null),j(null);try{let t=await x(`/mcp/${encodeURIComponent(e.name)}/complete`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({reference:be.reference,argument:{name:be.argument,value:D}})});j(t)}catch(e){I(e instanceof Error?e.message:t(`mcp.error.completionFailed`))}finally{P(!1)}}},Te=(0,W.useMemo)(()=>new Set(U.map(e=>e.name.toLowerCase())),[U]),Ee=e=>{H(e)},De=e=>e.startsWith(`@modelcontextprotocol/`),Oe=e=>De(e.name)?`Official`:`Community`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:(0,$.jsxs)(`div`,{className:`flex overflow-hidden flex-col flex-1 gap-4 p-4 min-h-0 sm:gap-5 sm:p-8`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between items-center shrink-0`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono`,children:`MCP`}),(0,$.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,$.jsx)(`button`,{onClick:q,"aria-label":t(`mcp.action.refreshServers`),className:`h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center`,disabled:G,children:(0,$.jsx)(ne,{className:T(`h-4 w-4`,G&&`animate-spin`)})}),(0,$.jsxs)(`button`,{"data-mcp-add-server-trigger":!0,onClick:()=>a(!0),className:`h-8 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-xs font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a]`,children:[(0,$.jsx)(y,{className:`h-3.5 w-3.5`}),t(`mcp.action.addServer`)]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit shrink-0`,children:[(0,$.jsx)(jt,{active:n===`installed`,onClick:()=>r(`installed`),children:t(`mcp.tab.installed`,{count:U.length})}),(0,$.jsx)(jt,{active:n===`catalog`,onClick:()=>{r(`catalog`),X||me()},children:t(`mcp.tab.catalog`)})]}),f&&(0,$.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:[(0,$.jsx)(k,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1 min-w-0`,children:f}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>p(null),className:`underline shrink-0`,children:t(`mcp.action.dismiss`)})]}),n===`installed`?(0,$.jsxs)(`div`,{className:`flex overflow-hidden flex-col flex-1 gap-3 min-h-0 sm:flex-row sm:gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex h-[180px] w-full shrink-0 flex-col gap-3 overflow-hidden sm:h-auto sm:w-[220px]`,children:[(0,$.jsx)(`span`,{className:`text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] shrink-0`,children:t(`mcp.servers.title`)}),(0,$.jsx)(`input`,{type:`search`,"aria-label":t(`mcp.servers.searchAria`),value:l,onChange:e=>u(e.target.value),placeholder:t(`mcp.servers.searchPlaceholder`),className:`h-8 shrink-0 rounded-md border border-transparent bg-[#F3F4F6] px-3 text-[12px] font-mono text-[#111827] outline-none placeholder:text-[#9CA3AF] focus:border-[#D1D5DB] dark:bg-[#18181b] dark:text-[#E5E5E5] dark:placeholder:text-[#71717a] dark:focus:border-[#3f3f46]`}),(0,$.jsxs)(`div`,{className:`flex overflow-y-auto flex-col flex-1 gap-2 pr-1 min-h-0`,children:[G&&U.length===0&&(0,$.jsxs)(`div`,{role:`status`,className:`flex items-center justify-center gap-2 py-8 text-sm font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:[(0,$.jsx)(N,{className:`w-4 h-4 animate-spin`}),t(`mcp.servers.loading`)]}),K&&!G&&(0,$.jsxs)(`div`,{role:`alert`,className:`flex flex-col gap-2 items-center py-6 font-mono text-xs text-center text-red-600 dark:text-red-400`,children:[(0,$.jsx)(`span`,{children:K.message}),(0,$.jsx)(`button`,{type:`button`,onClick:q,className:`rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900`,children:t(`mcp.action.retry`)})]}),!K&&!G&&ve.length===0&&(0,$.jsx)(`div`,{className:`text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono`,children:t(l?`mcp.servers.noMatch`:`mcp.servers.none`)}),ve.map(e=>(0,$.jsxs)(`button`,{onClick:()=>{c(e.id),L(null),p(null),E(null),O(``),j(null),I(null)},className:T(`text-left rounded-lg px-3 py-2 flex flex-col gap-1 transition-colors shrink-0`,e.id===Q?.id?`bg-[#E5E7EB] dark:bg-[#111827]`:`bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]`),children:[(0,$.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,$.jsx)(`span`,{className:`text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:e.name}),(0,$.jsx)(`span`,{className:T(`text-[11px] font-mono font-semibold`,_t[e.status]),children:Ct(e,t)})]}),(0,$.jsx)(`span`,{className:`text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] truncate`,children:e.endpoint})]},e.id))]})]}),Q?(0,$.jsxs)(`div`,{className:`flex overflow-y-auto flex-col flex-1 gap-3 pr-2 min-h-0`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between items-center shrink-0`,children:[(0,$.jsx)(`span`,{className:`text-base font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:Q.name}),(0,$.jsx)(`span`,{className:T(`text-xs font-mono font-semibold`,_t[Q.status]),children:Ct(Q,t)})]}),(0,$.jsx)(`p`,{className:`text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]`,children:Q.description}),Q.error&&(0,$.jsx)(`p`,{className:`text-[12px] font-mono text-[#ef4444]`,children:t(`mcp.server.errorLabel`,{error:Q.error})}),Q.instructions&&(0,$.jsxs)(`div`,{className:`rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]`,children:t(`mcp.instructions.title`)}),(0,$.jsxs)(`span`,{className:`truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:[`sha256 `,Q.instructions.sha256]})]}),(0,$.jsx)(`pre`,{className:`mt-1 max-h-36 overflow-y-auto whitespace-pre-wrap break-words text-[11px] font-mono text-[#374151] dark:text-[#d4d4d8]`,children:Q.instructions.text??t(`mcp.instructions.detailsOmittedByPolicy`)}),(Q.instructions.truncated||Q.instructions.detailsOmitted)&&(0,$.jsx)(`span`,{className:`mt-1 block text-[9px] font-mono text-amber-600 dark:text-amber-400`,children:Q.instructions.detailsOmitted?t(`mcp.instructions.detailsOmitted`):t(`mcp.instructions.truncated`)})]}),Q.tasks&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]`,children:t(`mcp.tasks.title`)}),(0,$.jsx)(`span`,{className:`text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]`,children:Q.tasks.enabled?t(`mcp.tasks.summary`,{count:Q.tasks.maxTasksPerSession,interval:Q.tasks.pollIntervalMs}):t(`mcp.tasks.disabledByDefault`)})]}),(0,$.jsx)(`span`,{className:T(`text-[10px] font-mono font-semibold uppercase`,Q.tasks.enabled?`text-[#16A34A] dark:text-[#22C55E]`:`text-[#9CA3AF] dark:text-[#71717a]`),children:Q.tasks.enabled?t(`mcp.tasks.enabled`):t(`mcp.tasks.disabled`)})]}),Q.oauthEnabled&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]`,children:`OAuth`}),(0,$.jsx)(`span`,{role:Q.oauthStatus===`authorizing`?`status`:void 0,className:T(`text-[11px] font-mono`,Q.oauthStatus===`authenticated`?`text-[#16A34A] dark:text-[#22C55E]`:Q.oauthStatus===`error`?`text-[#ef4444]`:`text-[#6B7280] dark:text-[#a1a1aa]`),children:t(yt[Q.oauthStatus])})]}),Q.oauthStatus===`authenticated`?(0,$.jsx)(`button`,{type:`button`,onClick:()=>void Se(`logout`,Q),disabled:_!==null,className:`h-7 rounded-md border border-[#D1D5DB] px-2.5 text-[11px] font-mono text-[#374151] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#d4d4d8]`,children:_?.type===`logout`?t(`mcp.oauth.signingOut`):t(`mcp.oauth.signOut`)}):Q.oauthStatus===`authorizing`?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(N,{className:`h-3.5 w-3.5 animate-spin text-[#2563eb]`,"aria-hidden":`true`}),m?.serverName===Q.name?(0,$.jsx)(`a`,{href:m.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex h-7 items-center rounded-md bg-[#2563eb] px-2.5 text-[11px] font-mono font-semibold text-white dark:bg-[#3b82f6]`,children:t(`mcp.oauth.continueAuthorization`)}):(0,$.jsx)(`button`,{type:`button`,onClick:()=>void Se(`login`,Q),disabled:_!==null,className:`h-7 rounded-md border border-[#D1D5DB] px-2.5 text-[11px] font-mono text-[#374151] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#d4d4d8]`,children:t(`mcp.oauth.resumeAuthorization`)})]}):Q.oauthStatus===`unavailable`?null:(0,$.jsx)(`button`,{type:`button`,onClick:()=>void Se(`login`,Q),disabled:_!==null,className:`h-7 rounded-md bg-[#2563eb] px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-50 dark:bg-[#3b82f6]`,children:_?.type===`login`?t(`mcp.oauth.opening`):t(`mcp.oauth.authorize`)})]}),(0,$.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[Q.status===`connected`||Q.status===`reconnecting`?(0,$.jsx)(`button`,{onClick:()=>void xe(`disconnect`,Q.name),disabled:_!==null,className:`h-7 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold`,children:_?.type===`disconnect`&&_.name===Q.name?t(`mcp.action.disconnecting`):Q.status===`reconnecting`?t(`mcp.action.stopRecovery`):t(`mcp.action.disconnect`)}):(0,$.jsx)(`button`,{onClick:()=>void xe(`connect`,Q.name),disabled:_!==null||Q.oauthEnabled&&Q.oauthStatus!==`authenticated`,className:`h-7 px-3 rounded-md bg-[#16A34A] dark:bg-[#22C55E] text-white dark:text-[#0C0C0C] text-[11px] font-mono font-semibold`,children:_?.type===`connect`&&_.name===Q.name?t(`mcp.action.connecting`):Q.oauthEnabled&&Q.oauthStatus!==`authenticated`?t(`mcp.action.authorizeFirst`):t(`mcp.action.connect`)}),(0,$.jsx)(`button`,{onClick:()=>L(Q.name),disabled:_!==null,className:`h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#ef4444] text-[11px] font-mono font-semibold`,children:t(`mcp.action.delete`)})]}),ee===Q.name&&(0,$.jsxs)(`div`,{role:`alertdialog`,"aria-label":t(`mcp.server.deleteAria`,{name:Q.name}),className:`flex flex-wrap gap-2 justify-between items-center px-3 py-2 bg-red-50 rounded-md border border-red-200 dark:border-red-900/60 dark:bg-red-950/30`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-mono text-red-700 dark:text-red-300`,children:t(`mcp.delete.confirm`)}),(0,$.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>L(null),className:`h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]`,children:t(`mcp.action.cancel`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void xe(`delete`,Q.name),disabled:_!==null,className:`h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60`,children:_?.type===`delete`?t(`mcp.action.deleting`):t(`mcp.action.deleteServer`)})]})]}),(0,$.jsx)(`span`,{className:`text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:t(`mcp.tools.title`,{count:Q.tools.length})}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Q.tools.length===0?(0,$.jsx)(`span`,{className:`text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:t(`mcp.tools.none`)}):Q.tools.map(e=>(0,$.jsx)(`span`,{className:`px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]`,children:e},e))}),(0,$.jsx)(`span`,{className:`text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:t(`mcp.completion.title`)}),Q.status===`connected`?Q.completionSupported?ye.length===0?(0,$.jsx)(`span`,{className:`text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:t(`mcp.completion.noTargets`)}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`div`,{"aria-label":t(`mcp.completion.targetAria`),className:`flex max-h-20 flex-wrap gap-1 overflow-y-auto`,children:ye.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":be?.key===e.key,onClick:()=>{E(e.key),j(null),I(null)},className:T(`max-w-full truncate rounded px-2 py-1 text-[10px] font-mono`,be?.key===e.key?`bg-[#111827] text-white dark:bg-[#E5E5E5] dark:text-[#111827]`:`bg-[#F3F4F6] text-[#6B7280] dark:bg-[#18181b] dark:text-[#a1a1aa]`),children:e.label},e.key))}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`input`,{type:`text`,"aria-label":t(`mcp.completion.partialAria`),value:D,onChange:e=>O(e.target.value),placeholder:t(`mcp.completion.partialPlaceholder`),className:`h-8 min-w-0 flex-1 rounded-md border border-transparent bg-[#F3F4F6] px-3 text-[11px] font-mono text-[#111827] outline-none placeholder:text-[#9CA3AF] focus:border-[#D1D5DB] dark:bg-[#18181b] dark:text-[#E5E5E5] dark:placeholder:text-[#71717a] dark:focus:border-[#3f3f46]`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void we(Q),disabled:M,className:`h-8 shrink-0 rounded-md bg-[#2563eb] px-3 text-[11px] font-mono font-semibold text-white disabled:opacity-50 dark:bg-[#3b82f6]`,children:t(M?`mcp.completion.completing`:`mcp.completion.complete`)})]}),F&&(0,$.jsx)(`span`,{role:`alert`,className:`text-[11px] font-mono text-red-600 dark:text-red-400`,children:F}),A&&(0,$.jsxs)(`div`,{"aria-label":t(`mcp.completion.suggestionsAria`),className:`rounded-md bg-[#F3F4F6] p-2 dark:bg-[#18181b]`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:A.values.length>0?A.values.map(e=>(0,$.jsx)(`span`,{className:`rounded bg-white px-2 py-1 text-[10px] font-mono text-[#111827] dark:bg-[#0C0C0C] dark:text-[#E5E5E5]`,children:e||t(`mcp.completion.empty`)},e)):(0,$.jsx)(`span`,{className:`text-[10px] font-mono text-[#9CA3AF]`,children:t(`mcp.completion.noSuggestions`)})}),(0,$.jsxs)(`span`,{className:`mt-1 block truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:[`sha256 `,A.sha256,A.truncated?t(`mcp.meta.truncatedSuffix`):``]})]})]}):(0,$.jsx)(`span`,{className:`text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:t(`mcp.completion.unsupported`)}):(0,$.jsx)(`span`,{className:`text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:t(`mcp.completion.connectPrompt`)}),(0,$.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:t(`mcp.diagnostics.title`)}),(0,$.jsx)(`button`,{type:`button`,"aria-label":t(`mcp.diagnostics.refreshAria`,{name:Q.name}),onClick:()=>void ue(Q.name),disabled:Y,className:`flex h-7 w-7 items-center justify-center rounded-md text-[#9CA3AF] transition-colors hover:bg-[#E5E7EB] hover:text-[#111827] disabled:opacity-50 dark:text-[#71717a] dark:hover:bg-[#27272a] dark:hover:text-[#E5E5E5]`,children:(0,$.jsx)(ne,{className:T(`h-3.5 w-3.5`,Y&&`animate-spin`)})})]}),(0,$.jsx)(`div`,{"aria-label":t(`mcp.log.levelAria`),className:`flex flex-wrap gap-1`,children:St.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>void Ce(Q,e),disabled:Q.status!==`connected`||S!==null,"aria-pressed":(Q.logging?.level??`warning`)===e,className:T(`rounded px-2 py-1 text-[10px] font-mono transition-colors disabled:opacity-40`,(Q.logging?.level??`warning`)===e?`bg-[#111827] text-white dark:bg-[#E5E5E5] dark:text-[#111827]`:`bg-[#F3F4F6] text-[#6B7280] hover:text-[#111827] dark:bg-[#18181b] dark:text-[#a1a1aa] dark:hover:text-[#E5E5E5]`),children:S===e?t(`mcp.log.setting`):e},e))}),le?(0,$.jsx)(`div`,{role:`alert`,className:`rounded-md bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:bg-red-950/30 dark:text-red-300`,children:le.message}):J?.entries.length?(0,$.jsx)(`div`,{"aria-label":t(`mcp.diagnostics.logsAria`,{name:Q.name}),className:`flex max-h-52 flex-col gap-1.5 overflow-y-auto rounded-md bg-[#F3F4F6] p-2 dark:bg-[#18181b]`,children:J.entries.map(e=>(0,$.jsxs)(`div`,{className:`rounded bg-white px-2.5 py-2 dark:bg-[#0C0C0C]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:T(`text-[10px] font-mono font-semibold uppercase`,[`error`,`critical`,`alert`,`emergency`].includes(e.level)?`text-red-600 dark:text-red-400`:e.level===`warning`?`text-amber-600 dark:text-amber-400`:`text-[#2563eb] dark:text-[#60a5fa]`),children:e.level}),(0,$.jsxs)(`span`,{className:`truncate text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:[e.logger||Q.name,` · r`,e.revision]})]}),(0,$.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words text-[11px] font-mono text-[#374151] dark:text-[#d4d4d8]`,children:e.message}),(0,$.jsxs)(`span`,{className:`mt-1 block truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:[`sha256 `,e.dataSha256,e.truncated?t(`mcp.meta.truncatedSuffix`):``,e.detailsOmitted?t(`mcp.meta.detailsOmittedSuffix`):``]})]},e.revision))}):(0,$.jsx)(`span`,{className:`text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:t(Y?`mcp.log.loading`:`mcp.log.none`)})]}):(0,$.jsx)(`div`,{className:`flex flex-1 justify-center items-center`,children:(0,$.jsx)(`span`,{className:`text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono`,children:t(`mcp.server.selectPrompt`)})})]}):(0,$.jsxs)(`div`,{className:`flex flex-col flex-1 gap-4 min-h-0`,children:[(0,$.jsx)(`div`,{className:`flex gap-3 items-center shrink-0`,children:(0,$.jsxs)(`div`,{className:`flex-1 h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] flex items-center px-3 gap-2`,children:[(0,$.jsx)(b,{className:`h-3.5 w-3.5 text-[#9CA3AF] dark:text-[#71717a]`}),(0,$.jsx)(`input`,{type:`text`,"aria-label":t(`mcp.catalog.searchAria`),value:te,onChange:e=>{re(e.target.value),se(e.target.value)},placeholder:t(`mcp.catalog.searchPlaceholder`),className:`flex-1 bg-transparent text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] focus:outline-none`})]})}),(0,$.jsxs)(`div`,{ref:oe,className:`overflow-y-auto flex-1 min-h-0`,children:[pe?(0,$.jsxs)(`div`,{role:`alert`,className:`flex flex-col gap-3 items-center py-12 font-mono text-center`,children:[(0,$.jsx)(k,{className:`w-6 h-6 text-red-500`}),(0,$.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:pe.message}),(0,$.jsx)(`button`,{type:`button`,onClick:me,className:`rounded-md border border-[#E5E7EB] px-3 py-1.5 text-[11px] text-[#6B7280] dark:border-[#27272a] dark:text-[#a1a1aa]`,children:t(`mcp.catalog.retry`)})]}):de&&!X?(0,$.jsx)(`div`,{className:`flex justify-center items-center py-12`,children:(0,$.jsx)(N,{className:`h-6 w-6 text-[#9CA3AF] dark:text-[#71717a] animate-spin`})}):(0,$.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 pb-4 sm:grid-cols-2`,children:[X?.list.map(e=>{let n=Te.has(Ot(e.name).toLowerCase()),r=ie===e.name,i=Oe(e);return(0,$.jsxs)(`div`,{className:`rounded-lg bg-white dark:bg-[#0C0C0C] p-4 flex flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2 justify-between items-center`,children:[(0,$.jsx)(`span`,{className:`text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] truncate`,children:e.name}),(0,$.jsx)(`span`,{className:T(`text-[10px] font-mono px-2 py-0.5 rounded shrink-0`,i===`Official`?`bg-[#16A34A]/20 dark:bg-[#22C55E]/20 text-[#16A34A] dark:text-[#22C55E]`:`bg-[#3b82f6]/20 text-[#3b82f6]`),children:t(bt[i])})]}),(0,$.jsx)(`p`,{className:`text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] line-clamp-2`,children:e.description||t(`mcp.catalog.noDescription`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:[(0,$.jsxs)(`span`,{children:[`v`,e.version]}),e.publisher?.username&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{children:`•`}),(0,$.jsx)(`span`,{children:t(`mcp.catalog.byAuthor`,{author:e.publisher.username})})]})]}),(0,$.jsxs)(`div`,{className:`flex justify-between items-center pt-2 mt-auto`,children:[(0,$.jsxs)(`a`,{href:e.links?.npm||`https://www.npmjs.com/package/${e.name}`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a] hover:text-[#111827] dark:hover:text-[#E5E5E5] flex items-center gap-1`,children:[(0,$.jsx)(d,{className:`w-3 h-3`}),`npm`]}),n?(0,$.jsxs)(`span`,{className:`text-[11px] font-mono text-[#16A34A] dark:text-[#22C55E] flex items-center gap-1`,children:[(0,$.jsx)(z,{className:`w-3 h-3`}),t(`mcp.catalog.installed`)]}):(0,$.jsxs)(`button`,{onClick:()=>Ee(e),disabled:r,className:`h-6 px-2 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-[10px] font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a] disabled:opacity-50`,children:[(0,$.jsx)(g,{className:T(`h-3 w-3`,r&&`animate-pulse`)}),t(r?`mcp.catalog.installing`:`mcp.catalog.install`)]})]})]},e.name)}),X?.list.length===0&&(0,$.jsx)(`div`,{className:`col-span-full py-12 text-center text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:t(`mcp.catalog.noPackages`)})]}),fe&&(0,$.jsx)(`div`,{className:`flex justify-center items-center py-4`,children:(0,$.jsx)(N,{className:`h-5 w-5 text-[#9CA3AF] dark:text-[#71717a] animate-spin`})}),Z&&X&&X.list.length>0&&(0,$.jsx)(`div`,{className:`text-center py-4 text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:t(`mcp.catalog.noMore`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between pt-2 border-t border-[#E5E7EB] dark:border-[#1f2937] shrink-0`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:t(`mcp.catalog.packagesFound`,{count:X?.total??0})}),(0,$.jsxs)(`a`,{href:`https://glama.ai/mcp/servers`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] font-mono text-[#3b82f6] hover:underline flex items-center gap-1`,children:[t(`mcp.catalog.browseGlama`),(0,$.jsx)(d,{className:`w-3 h-3`})]})]})]})]})}),(0,$.jsx)(Mt,{open:i,onOpenChange:a,onAdd:he,saving:ge,error:_e?.message??null}),ae&&(0,$.jsx)(Nt,{pkg:ae,onClose:()=>H(null),installing:ge,error:_e?.message??null,onInstall:e=>(V(ae.name),he(e))})]})}function jt({active:e,children:t,onClick:n}){return(0,$.jsx)(`button`,{onClick:n,className:T(`px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors`,e?`bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]`:`text-[#6B7280] dark:text-[#a1a1aa]`),children:t})}function Mt({open:e,onOpenChange:t,onAdd:n,saving:r,error:i}){let a=s(),[o,c]=(0,W.useState)(`form`),[l,u]=(0,W.useState)(``),[d,f]=(0,W.useState)(``),[p,m]=(0,W.useState)(``),[h,g]=(0,W.useState)(null),[_,v]=(0,W.useState)(`{
|
|
2
|
+
"name": "my-server",
|
|
3
|
+
"command": "npx",
|
|
4
|
+
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
|
|
5
|
+
}`);(0,W.useEffect)(()=>{e&&g(null)},[e]);let y=async()=>{if(g(null),o===`json`){let e;try{e=JSON.parse(_)}catch{g(a(`mcp.add.invalidJson`));return}await n(e).catch(()=>void 0)}else{if(!l||!d){g(a(`mcp.add.nameCommandRequired`));return}await n({name:l,command:d,args:p.split(` `).filter(Boolean)}).catch(()=>void 0)}};return(0,$.jsx)(S,{open:e,onOpenChange:t,children:(0,$.jsxs)(C,{onCloseAutoFocus:e=>A(`[data-mcp-add-server-trigger]`,e),className:`gap-0 overflow-y-auto rounded-xl border border-[#E5E7EB] bg-white p-0 dark:border-zinc-800 dark:bg-[#09090b] sm:max-w-[540px]`,"aria-describedby":void 0,hideCloseButton:!0,children:[(0,$.jsx)(E,{className:`sr-only`,children:a(`mcp.add.title`)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,$.jsx)(`h3`,{className:`text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono`,children:a(`mcp.add.title`)}),(0,$.jsx)(`button`,{onClick:()=>t(!1),"aria-label":a(`mcp.add.closeAria`),className:`h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center`,children:(0,$.jsx)(D,{className:`w-4 h-4`})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit`,children:[(0,$.jsx)(Pt,{active:o===`form`,onClick:()=>c(`form`),children:a(`mcp.add.modeForm`)}),(0,$.jsx)(Pt,{active:o===`json`,onClick:()=>c(`json`),children:`JSON`})]}),o===`json`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]`,children:a(`mcp.add.jsonConfig`)}),(0,$.jsx)(`textarea`,{"aria-label":a(`mcp.add.jsonConfigAria`),className:`min-h-[140px] rounded-md bg-white dark:bg-[#0C0C0C] text-[#111827] dark:text-[#E5E5E5] font-mono text-[12px] p-3 border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]`,value:_,onChange:e=>v(e.target.value)})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]`,children:a(`mcp.add.serverName`)}),(0,$.jsx)(`input`,{"aria-label":a(`mcp.add.serverName`),type:`text`,value:l,onChange:e=>u(e.target.value),placeholder:`my-server`,className:`h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]`})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]`,children:a(`mcp.add.command`)}),(0,$.jsx)(`input`,{"aria-label":a(`mcp.add.commandAria`),type:`text`,value:d,onChange:e=>f(e.target.value),placeholder:`npx`,className:`h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]`})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]`,children:a(`mcp.add.argsLabel`)}),(0,$.jsx)(`input`,{"aria-label":a(`mcp.add.argsAria`),type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:`-y @modelcontextprotocol/server-filesystem /tmp`,className:`h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]`})]})]}),(h||i)&&(0,$.jsx)(`div`,{role:`alert`,className:`rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:h||i}),(0,$.jsxs)(`div`,{className:`flex gap-2 justify-end items-center pt-2`,children:[(0,$.jsx)(`button`,{onClick:()=>t(!1),className:`h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold`,children:a(`mcp.action.cancel`)}),(0,$.jsx)(`button`,{onClick:()=>void y(),disabled:r,className:`h-7 px-3 rounded-md bg-[#16A34A] dark:bg-[#22C55E] text-white dark:text-[#0C0C0C] text-[11px] font-mono font-semibold disabled:opacity-60`,children:a(r?`mcp.add.adding`:`mcp.add.submit`)})]})]})]})})}function Nt({pkg:e,onClose:t,onInstall:n,installing:r,error:i}){let a=s(),o=Ot(e.name),[c,l]=(0,W.useState)(o),[u,d]=(0,W.useState)(`-y ${e.name}`),[f,p]=(0,W.useState)(null),m=async()=>{if(p(null),!c.trim()){p(a(`mcp.install.nameRequired`));return}await n({name:c.trim(),command:`npx`,args:u.split(` `).filter(Boolean)}).catch(()=>void 0)};return(0,$.jsx)(S,{open:!0,onOpenChange:t,children:(0,$.jsxs)(C,{className:`gap-0 overflow-y-auto rounded-xl border border-[#E5E7EB] bg-white p-0 dark:border-zinc-800 dark:bg-[#09090b] sm:max-w-[480px]`,"aria-describedby":void 0,hideCloseButton:!0,children:[(0,$.jsx)(E,{className:`sr-only`,children:a(`mcp.install.titleWithName`,{name:e.name})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,$.jsx)(`h3`,{className:`text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono`,children:a(`mcp.install.title`)}),(0,$.jsx)(`button`,{onClick:t,"aria-label":a(`mcp.install.closeAria`),className:`h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center`,children:(0,$.jsx)(D,{className:`w-4 h-4`})})]}),(0,$.jsxs)(`div`,{className:`rounded-md bg-white dark:bg-[#0C0C0C] p-3`,children:[(0,$.jsx)(`span`,{className:`text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:e.name}),(0,$.jsx)(`p`,{className:`text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] mt-1`,children:e.description||a(`mcp.catalog.noDescription`)})]}),(0,$.jsx)(`div`,{className:`h-px bg-[#E5E7EB] dark:bg-[#1f2937]`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]`,children:a(`mcp.add.serverName`)}),(0,$.jsx)(`input`,{"aria-label":a(`mcp.add.serverName`),type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`my-server`,className:`h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]`})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]`,children:a(`mcp.install.args`)}),(0,$.jsx)(`input`,{"aria-label":a(`mcp.add.argsAria`),type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:`-y package-name`,className:`h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]`}),(0,$.jsx)(`span`,{className:`text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:a(`mcp.install.commandPreview`,{args:u})})]})]}),(f||i)&&(0,$.jsx)(`div`,{role:`alert`,className:`rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:f||i}),(0,$.jsxs)(`div`,{className:`flex gap-2 justify-end items-center pt-2`,children:[(0,$.jsx)(`button`,{onClick:t,className:`h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold`,children:a(`mcp.action.cancel`)}),(0,$.jsx)(`button`,{onClick:()=>void m(),disabled:r,className:`h-7 px-3 rounded-md bg-[#16A34A] dark:bg-[#22C55E] text-white dark:text-[#0C0C0C] text-[11px] font-mono font-semibold disabled:opacity-60`,children:a(r?`mcp.catalog.installing`:`mcp.catalog.install`)})]})]})]})})}function Pt({active:e,children:t,onClick:n}){return(0,$.jsx)(`button`,{onClick:n,className:T(`px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors`,e?`bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]`:`text-[#6B7280] dark:text-[#a1a1aa]`),children:t})}function Ft({value:e,onChange:t,options:n,placeholder:r=`Select...`,disabled:i=!1,className:a,"aria-label":o}){let[s,c]=W.useState(!1),[l,u]=W.useState(-1),d=W.useRef(null),f=n.find(t=>t.value===e);W.useEffect(()=>{if(s){let t=n.findIndex(t=>t.value===e);u(t>=0?t:0)}},[s,n,e]);let p=e=>{if(!i){if(!s){(e.key===`Enter`||e.key===` `||e.key===`ArrowDown`)&&(e.preventDefault(),c(!0));return}switch(e.key){case`ArrowDown`:e.preventDefault(),u(e=>Math.min(e+1,n.length-1));break;case`ArrowUp`:e.preventDefault(),u(e=>Math.max(e-1,0));break;case`Enter`:case` `:e.preventDefault(),l>=0&&l<n.length&&(t(n[l].value),c(!1));break;case`Escape`:e.preventDefault(),c(!1)}}};return W.useEffect(()=>{!s||l<0||(d.current?.children[l])?.scrollIntoView({block:`nearest`})},[l,s]),(0,$.jsxs)(P,{open:s,onOpenChange:c,children:[(0,$.jsx)(L,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,role:`combobox`,"aria-expanded":s,"aria-haspopup":`listbox`,"aria-label":o,disabled:i,onKeyDown:p,className:T(`field flex items-center justify-between gap-2 text-left`,!f&&`text-zinc-400 dark:text-zinc-500`,i&&`cursor-not-allowed opacity-50`,a),children:[(0,$.jsx)(`span`,{className:`truncate`,children:f?f.label:r}),(0,$.jsx)(re,{className:`h-3.5 w-3.5 shrink-0 opacity-60`})]})}),(0,$.jsx)(F,{align:`start`,sideOffset:4,onKeyDown:p,className:`w-[var(--radix-popover-trigger-width)] max-h-[240px] p-1 overflow-hidden`,children:(0,$.jsx)(B,{className:`max-h-[232px]`,children:(0,$.jsx)(`div`,{ref:d,role:`listbox`,children:n.map((n,r)=>(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n.value===e,"data-value":n.value,"data-highlighted":r===l||void 0,onClick:()=>{t(n.value),c(!1)},onMouseEnter:()=>u(r),className:T(`flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left font-mono text-[13px] outline-none transition-colors`,r===l&&`bg-zinc-100 dark:bg-zinc-800`,n.value===e&&`text-zinc-900 dark:text-zinc-50 font-medium`),children:[(0,$.jsx)(z,{className:T(`h-3.5 w-3.5 shrink-0`,n.value===e?`opacity-100`:`opacity-0`)}),(0,$.jsx)(`span`,{className:`truncate`,children:n.label})]},n.value))})})})]})}var It=[{value:`cron`,labelKey:`schedule.trigger.cron`},{value:`interval`,labelKey:`schedule.trigger.interval`},{value:`once`,labelKey:`schedule.trigger.once`}],Lt=[{value:`default`,labelKey:`schedule.permission.default`},{value:`autoEdit`,labelKey:`schedule.permission.autoEdit`},{value:`yolo`,labelKey:`schedule.permission.yolo`},{value:`plan`,labelKey:`schedule.permission.plan`}],Rt=[{value:`worktree`,labelKey:`schedule.isolation.worktree`},{value:`local`,labelKey:`schedule.isolation.local`}],zt={queued:`schedule.status.queued`,running:`schedule.status.running`,completed:`schedule.status.completed`,failed:`schedule.status.failed`,cancelled:`schedule.status.cancelled`,interrupted:`schedule.status.interrupted`,error:`schedule.status.error`},Bt={s:1e3,m:6e4,h:36e5,d:864e5};function Vt(e){let t=/^\s*(\d+)\s*([smhd])\s*$/i.exec(e);if(!t)return null;let n=Number(t[1]);if(!Number.isFinite(n)||n<=0)return null;let r=n*Bt[t[2].toLowerCase()];return r<6e4?null:r}function Ht(e){return e%Bt.d===0?`${e/Bt.d}d`:e%Bt.h===0?`${e/Bt.h}h`:e%Bt.m===0?`${e/Bt.m}m`:`${Math.round(e/1e3)}s`}function Ut(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function Wt({active:e}){let t=s(),n=R(e=>e.currentSessionRef?.projectPath),r=R(e=>e.selectedProjectPath),i=w(e=>e.configuredModels),a=n??r??new URLSearchParams(window.location.search).get(`project`)??``,o=M(e=>e.schedules),c=M(e=>e.isLoading),l=M(e=>e.error),u=M(e=>e.loadSchedules),d=M(e=>e.createSchedule),f=M(e=>e.updateSchedule),p=M(e=>e.deleteSchedule),m=M(e=>e.toggleSchedule),g=M(e=>e.runSchedule),[b,x]=(0,W.useState)(!1),[S,C]=(0,W.useState)(`cron`),[E,D]=(0,W.useState)(``),[O,k]=(0,W.useState)(``),[A,j]=(0,W.useState)(``),[P,F]=(0,W.useState)(``),[I,ee]=(0,W.useState)(``),[L,re]=(0,W.useState)(``),[B,ie]=(0,W.useState)(``),[V,ae]=(0,W.useState)(`default`),[H,oe]=(0,W.useState)(`worktree`),[se,U]=(0,W.useState)(!1),[G,K]=(0,W.useState)(null),[q,ce]=(0,W.useState)(null),[J,Y]=(0,W.useState)(null),[le,ue]=(0,W.useState)(``),[X,de]=(0,W.useState)(!0),[fe,Z]=(0,W.useState)(null),pe=(0,W.useRef)(!1);(0,W.useEffect)(()=>{e&&!pe.current&&(pe.current=!0,u()),e||(pe.current=!1)},[e,u]);let me=fe??l,he=G!==null||se,ge=()=>{x(!0),C(`cron`),D(``),k(``),j(``),F(``),ee(a),re(``),ie(``),ae(`default`),oe(`worktree`),Z(null)},_e=()=>{x(!1),Z(null)},ve=async()=>{Z(null);let e=P.trim();if(!e){Z(t(`schedule.error.promptRequired`));return}let n=I.trim();if(!n){Z(t(`schedule.error.projectRequired`));return}let r;if(S===`cron`){let e=E.trim();if(!e){Z(t(`schedule.error.cronRequired`));return}r={kind:`cron`,cron:e}}else if(S===`interval`){let e=Vt(O);if(e===null){Z(t(`schedule.error.invalidInterval`));return}r={kind:`interval`,intervalMs:e}}else{let e=A?new Date(A):null;if(!e||Number.isNaN(e.getTime())){Z(t(`schedule.error.runAtRequired`));return}r={kind:`once`,runAt:e.toISOString()}}let i={prompt:e,projectPath:n,trigger:r,permissionMode:V,isolation:H,enabled:!0};L.trim()&&(i.title=L.trim()),B.trim()&&(i.modelId=B.trim()),U(!0);try{await d(i),x(!1)}catch{}finally{U(!1)}},Q=async e=>{Z(null),K(`run:${e.id}`);try{await g(e.id)}catch{}finally{K(null)}},ye=async e=>{Z(null),K(`toggle:${e.id}`);try{await m(e.id,!e.enabled)}catch{}finally{K(null)}},be=async e=>{let t=`delete:${e.id}`;if(q!==t){ce(t);return}Z(null),K(t);try{await p(e.id),ce(null)}catch{}finally{K(null)}},xe=e=>{Y(e.id),ue(e.prompt),de(e.enabled),Z(null)},Se=async e=>{let n=le.trim();if(!n){Z(t(`schedule.error.promptRequired`));return}Z(null),K(`edit:${e.id}`);try{await f(e.id,{prompt:n,enabled:X}),Y(null)}catch{}finally{K(null)}},Ce=e=>e.kind===`cron`?t(`schedule.cadence.cron`,{expr:e.cron??``}):e.kind===`interval`?t(`schedule.cadence.interval`,{interval:Ht(e.intervalMs??0)}):t(`schedule.cadence.once`,{time:e.runAt?Ut(e.runAt):``});return(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3 font-mono`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:[(0,$.jsx)(h,{className:`h-4 w-4`}),t(`schedule.title`),c&&(0,$.jsx)(N,{className:`h-3.5 w-3.5 animate-spin`})]}),(0,$.jsx)(`p`,{className:`mt-1 text-[10px] text-[#9CA3AF]`,children:t(`schedule.description`)})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void u(),disabled:c||he,"aria-label":t(`schedule.reloadAria`),className:`inline-flex h-8 items-center gap-1 rounded-md border border-[#E5E7EB] px-2 text-[11px] text-[#6B7280] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#a1a1aa]`,children:[(0,$.jsx)(ne,{className:`h-3.5 w-3.5`}),t(`schedule.refresh`)]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>b?_e():ge(),disabled:he,"aria-label":t(`schedule.newAria`),className:`inline-flex h-8 items-center gap-1 rounded-md bg-[#111827] px-3 text-[11px] text-white disabled:opacity-40 dark:bg-[#E5E5E5] dark:text-[#18181b]`,children:[(0,$.jsx)(y,{className:`h-3.5 w-3.5`}),t(`schedule.new`)]})]})]}),me&&(0,$.jsx)(`div`,{role:`alert`,className:`rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:me}),b&&(0,$.jsxs)(`div`,{className:`rounded-md border border-[#E5E7EB] p-3 dark:border-[#27272a]`,children:[(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":t(`schedule.trigger.kindAria`),className:`flex rounded-md bg-[#F3F4F6] p-0.5 dark:bg-[#18181b]`,children:It.map(e=>(0,$.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":S===e.value,onClick:()=>C(e.value),className:T(`flex-1 rounded px-2 py-1 text-[10px] transition-colors`,S===e.value?`bg-white font-semibold text-[#111827] shadow-sm dark:bg-[#27272a] dark:text-[#E5E5E5]`:`text-[#71717a] hover:text-[#374151] dark:hover:text-[#d4d4d8]`),children:t(e.labelKey)},e.value))}),(0,$.jsxs)(`div`,{className:`mt-2.5`,children:[S===`cron`&&(0,$.jsxs)(`label`,{className:`block`,children:[(0,$.jsx)(`span`,{className:`text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]`,children:t(`schedule.field.cron`)}),(0,$.jsx)(`input`,{value:E,onChange:e=>D(e.target.value),placeholder:t(`schedule.placeholder.cron`),"aria-label":t(`schedule.field.cron`),className:`field mt-1 h-8 px-2 text-[10.5px]`})]}),S===`interval`&&(0,$.jsxs)(`label`,{className:`block`,children:[(0,$.jsx)(`span`,{className:`text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]`,children:t(`schedule.field.interval`)}),(0,$.jsx)(`input`,{value:O,onChange:e=>k(e.target.value),placeholder:t(`schedule.placeholder.interval`),"aria-label":t(`schedule.field.interval`),className:`field mt-1 h-8 px-2 text-[10.5px]`})]}),S===`once`&&(0,$.jsxs)(`label`,{className:`block`,children:[(0,$.jsx)(`span`,{className:`text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]`,children:t(`schedule.field.runAt`)}),(0,$.jsx)(`input`,{type:`datetime-local`,value:A,onChange:e=>j(e.target.value),"aria-label":t(`schedule.field.runAt`),className:`field mt-1 h-8 px-2 text-[10.5px]`})]})]}),(0,$.jsxs)(`label`,{className:`mt-2.5 block`,children:[(0,$.jsx)(`span`,{className:`text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]`,children:t(`schedule.field.title`)}),(0,$.jsx)(`input`,{value:L,onChange:e=>re(e.target.value),placeholder:t(`schedule.placeholder.title`),"aria-label":t(`schedule.field.title`),className:`field mt-1 h-8 px-2 text-[10.5px]`})]}),(0,$.jsxs)(`label`,{className:`mt-2.5 block`,children:[(0,$.jsx)(`span`,{className:`text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]`,children:t(`schedule.field.prompt`)}),(0,$.jsx)(`textarea`,{value:P,onChange:e=>F(e.target.value),placeholder:t(`schedule.placeholder.prompt`),"aria-label":t(`schedule.field.prompt`),rows:3,className:`field mt-1 h-auto resize-y py-1.5 text-[10.5px]`})]}),(0,$.jsxs)(`label`,{className:`mt-2.5 block`,children:[(0,$.jsx)(`span`,{className:`text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]`,children:t(`schedule.field.project`)}),(0,$.jsx)(`input`,{value:I,onChange:e=>ee(e.target.value),placeholder:t(`schedule.placeholder.project`),"aria-label":t(`schedule.field.project`),className:`field mt-1 h-8 px-2 text-[10.5px]`})]}),(0,$.jsxs)(`div`,{className:`mt-2.5 grid gap-2 sm:grid-cols-3`,children:[(0,$.jsxs)(`label`,{className:`block`,children:[(0,$.jsx)(`span`,{className:`text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]`,children:t(`schedule.field.model`)}),(0,$.jsx)(Ft,{value:B,onChange:ie,placeholder:t(`schedule.model.current`),"aria-label":t(`schedule.field.model`),className:`field mt-1 h-8 px-2 text-[10.5px]`,options:[{value:``,label:t(`schedule.model.current`)},...i.map(e=>({value:e.id,label:e.displayName||e.model}))]})]}),(0,$.jsxs)(`label`,{className:`block`,children:[(0,$.jsx)(`span`,{className:`text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]`,children:t(`schedule.field.permissionMode`)}),(0,$.jsx)(Ft,{value:V,onChange:e=>ae(e),"aria-label":t(`schedule.field.permissionMode`),className:`field mt-1 h-8 px-2 text-[10.5px]`,options:Lt.map(e=>({value:e.value,label:t(e.labelKey)}))})]}),(0,$.jsxs)(`label`,{className:`block`,children:[(0,$.jsx)(`span`,{className:`text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]`,children:t(`schedule.field.isolation`)}),(0,$.jsx)(Ft,{value:H,onChange:e=>oe(e),"aria-label":t(`schedule.field.isolation`),className:`field mt-1 h-8 px-2 text-[10.5px]`,options:Rt.map(e=>({value:e.value,label:t(e.labelKey)}))})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:_e,disabled:se,className:`inline-flex h-8 items-center gap-1 rounded-md border border-[#E5E7EB] px-3 text-[10.5px] text-[#6B7280] disabled:opacity-40 dark:border-[#3f3f46] dark:text-[#a1a1aa]`,children:t(`schedule.cancel`)}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void ve(),disabled:se,className:`inline-flex h-8 items-center gap-1 rounded-md bg-[#111827] px-3 text-[10.5px] text-white disabled:opacity-40 dark:bg-[#E5E5E5] dark:text-[#18181b]`,children:[se?(0,$.jsx)(N,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(y,{className:`h-3.5 w-3.5`}),t(`schedule.create`)]})]})]}),(0,$.jsxs)(`div`,{className:`min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]`,children:[o.map(e=>{let n=J===e.id,r=e.lastStatus?t(zt[e.lastStatus]):t(`schedule.status.never`);return(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-[#E5E7EB] px-3 py-2.5 last:border-b-0 dark:border-[#27272a]`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-[12px] font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:e.title||e.prompt}),(0,$.jsx)(`span`,{className:`rounded bg-[#E5E7EB] px-1.5 py-0.5 text-[9px] text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]`,children:Ce(e.trigger)}),(0,$.jsx)(`span`,{className:T(`rounded px-1.5 py-0.5 text-[9px]`,e.enabled?`bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300`:`bg-[#F3F4F6] text-[#9CA3AF] dark:bg-[#27272a]`),children:e.enabled?t(`schedule.enabled`):t(`schedule.disabled`)})]}),n?(0,$.jsxs)(`div`,{className:`mt-2`,children:[(0,$.jsx)(`textarea`,{value:le,onChange:e=>ue(e.target.value),"aria-label":t(`schedule.field.prompt`),rows:3,className:`field h-auto resize-y py-1.5 text-[10.5px]`}),(0,$.jsxs)(`div`,{className:`mt-2 flex items-center justify-between`,children:[(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":X,"aria-label":t(X?`schedule.disableAria`:`schedule.enableAria`,{title:e.title||e.prompt}),onClick:()=>de(e=>!e),className:`flex items-center gap-2 text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]`,children:[(0,$.jsx)(`span`,{className:T(`flex h-5 w-9 items-center rounded-full px-1 transition-colors`,X?`bg-emerald-500`:`bg-[#E5E7EB] dark:bg-[#27272a]`),children:(0,$.jsx)(`span`,{className:T(`h-3.5 w-3.5 rounded-full bg-white transition-transform`,X?`translate-x-4`:`translate-x-0`)})}),t(X?`schedule.enabled`:`schedule.disabled`)]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>Y(null),disabled:he,className:`inline-flex h-7 items-center gap-1 rounded-md border border-[#E5E7EB] px-2 text-[9.5px] text-[#6B7280] disabled:opacity-40 dark:border-[#3f3f46] dark:text-[#a1a1aa]`,children:t(`schedule.cancel`)}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void Se(e),disabled:he,className:`inline-flex h-7 items-center gap-1 rounded-md bg-[#111827] px-2 text-[9.5px] text-white disabled:opacity-40 dark:bg-[#E5E5E5] dark:text-[#18181b]`,children:[G===`edit:${e.id}`?(0,$.jsx)(N,{className:`h-3 w-3 animate-spin`}):(0,$.jsx)(z,{className:`h-3 w-3`}),t(`schedule.save`)]})]})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[10.5px] text-[#6B7280] dark:text-[#a1a1aa]`,children:e.prompt}),(0,$.jsxs)(`p`,{className:`mt-1 text-[9.5px] text-[#9CA3AF]`,children:[t(`schedule.nextRun`),`:`,` `,e.nextRunAt?Ut(e.nextRunAt):t(`schedule.never`),` · `,t(`schedule.lastRun`),`:`,` `,e.lastRunAt?Ut(e.lastRunAt):t(`schedule.never`),` · `,r,` · `,t(`schedule.runCount`,{count:e.runCount})]}),e.lastError&&(0,$.jsx)(`p`,{className:`mt-1 text-[9.5px] text-red-600 dark:text-red-400`,children:e.lastError})]})]}),!n&&(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e.enabled,"aria-label":e.enabled?t(`schedule.disableAria`,{title:e.title||e.prompt}):t(`schedule.enableAria`,{title:e.title||e.prompt}),disabled:he,onClick:()=>void ye(e),className:T(`flex h-6 w-11 items-center rounded-full px-1 transition-colors disabled:opacity-40`,e.enabled?`bg-emerald-500`:`bg-[#E5E7EB] dark:bg-[#27272a]`),children:(0,$.jsx)(`span`,{className:T(`h-4 w-4 rounded-full bg-white transition-transform`,e.enabled?`translate-x-5`:`translate-x-0`)})}),(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":t(`schedule.runNowAria`,{title:e.title||e.prompt}),onClick:()=>void Q(e),disabled:he,className:`rounded p-1 text-[#6B7280] hover:bg-[#F3F4F6] disabled:opacity-40 dark:text-[#a1a1aa] dark:hover:bg-[#27272a]`,children:G===`run:${e.id}`?(0,$.jsx)(N,{className:`h-3 w-3 animate-spin`}):(0,$.jsx)(v,{className:`h-3 w-3`})}),(0,$.jsx)(`button`,{type:`button`,"aria-label":t(`schedule.editAria`,{title:e.title||e.prompt}),onClick:()=>xe(e),disabled:he,className:`rounded p-1 text-[#6B7280] hover:bg-[#F3F4F6] disabled:opacity-40 dark:text-[#a1a1aa] dark:hover:bg-[#27272a]`,children:(0,$.jsx)(_,{className:`h-3 w-3`})}),(0,$.jsx)(`button`,{type:`button`,"aria-label":t(`schedule.deleteAria`,{title:e.title||e.prompt}),onClick:()=>void be(e),disabled:he,className:T(`rounded p-1 text-[9px] disabled:opacity-40`,q===`delete:${e.id}`?`bg-red-100 text-red-700 dark:bg-red-950/50 dark:text-red-300`:`text-[#9CA3AF] hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-950/30`),children:G===`delete:${e.id}`?(0,$.jsx)(N,{className:`h-3 w-3 animate-spin`}):q===`delete:${e.id}`?(0,$.jsx)(`span`,{className:`px-0.5 text-[8.5px]`,children:t(`schedule.confirmDelete`)}):(0,$.jsx)(te,{className:`h-3 w-3`})})]})]})]},e.id)}),!c&&o.length===0&&(0,$.jsx)(`div`,{className:`px-3 py-8 text-center text-[11px] text-[#9CA3AF]`,children:t(`schedule.empty`)})]})]})}var Gt=e=>e?{"x-blade-directory":e}:void 0,Kt=async e=>x(`/skills`,{headers:Gt(e)}),qt=async()=>x(`/skills/catalog`),Jt={Official:`skills.install.catalog.tag.official`,Popular:`skills.install.catalog.tag.popular`,Community:`skills.install.catalog.tag.community`};function Yt({active:e}){let t=s(),n=R(e=>e.currentSessionRef?.projectPath??e.selectedProjectPath??e.taskWorkspaceInfo?.cwd??null),[r,i]=(0,W.useState)(null),[a,o]=(0,W.useState)(``),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)(!1),[g,_]=(0,W.useState)(!1),[v,b]=(0,W.useState)(`confirm`),[S,C]=(0,W.useState)(null),[w,E]=(0,W.useState)(null),{data:D=[],loading:O,error:A,run:j,runAsync:M}=ct(()=>Kt(n),{refreshDeps:[e,n],ready:e,onSuccess:e=>{e.length>0&&!r&&i(e[0].id)}}),P=D.filter(e=>e.name.toLowerCase().includes(a.toLowerCase())),F=(0,W.useMemo)(()=>D.find(e=>e.id===r)??D[0],[D,r]),I=async(e,r,a)=>{d({type:e,name:r.name}),l(null);try{await x(e===`delete`?`/skills/${encodeURIComponent(r.name)}`:`/skills/${encodeURIComponent(r.name)}/toggle`,{method:e===`delete`?`DELETE`:`POST`,headers:{...Gt(n),...e===`toggle`?{"Content-Type":`application/json`}:{}},body:e===`toggle`?JSON.stringify({enabled:a}):void 0}),await M(),e===`delete`&&(p(null),i(null))}catch(n){l(n instanceof Error?n.message:t(e===`delete`?`skills.error.deleteFailed`:`skills.error.toggleFailed`))}finally{d(null)}};return(0,$.jsxs)(W.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col gap-4 p-4 sm:gap-5 sm:p-8`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono`,children:t(`skills.title`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`button`,{"data-skill-install-trigger":!0,onClick:()=>{h(!0)},className:`h-8 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-xs font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a]`,children:[(0,$.jsx)(y,{className:`h-3.5 w-3.5`}),t(`skills.action.install`)]}),(0,$.jsx)(`button`,{onClick:j,"aria-label":t(`skills.action.refreshAria`),className:`h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center`,disabled:O,children:(0,$.jsx)(ne,{className:T(`h-4 w-4`,O&&`animate-spin`)})})]})]}),c&&(0,$.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:[(0,$.jsx)(k,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:c}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>l(null),className:`shrink-0 underline`,children:t(`skills.action.dismiss`)})]}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden sm:flex-row sm:gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex h-[180px] w-full shrink-0 flex-col gap-3 overflow-hidden sm:h-auto sm:w-[220px]`,children:[(0,$.jsx)(`div`,{className:`text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] shrink-0`,children:t(`skills.installed.title`)}),(0,$.jsx)(`input`,{type:`search`,"aria-label":t(`skills.installed.searchAria`),value:a,onChange:e=>o(e.target.value),placeholder:t(`skills.installed.searchPlaceholder`),className:`h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a] shrink-0`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 overflow-y-auto flex-1 min-h-0 pr-1`,children:[O&&D.length===0&&(0,$.jsxs)(`div`,{role:`status`,className:`flex items-center justify-center gap-2 py-8 text-sm font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:[(0,$.jsx)(N,{className:`h-4 w-4 animate-spin`}),t(`skills.installed.loading`)]}),A&&!O&&(0,$.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-center gap-2 py-6 text-center text-xs font-mono text-red-600 dark:text-red-400`,children:[(0,$.jsx)(`span`,{children:A.message}),(0,$.jsx)(`button`,{type:`button`,onClick:j,className:`rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900`,children:t(`skills.action.retry`)})]}),!A&&P.length===0&&!O&&(0,$.jsx)(`div`,{className:`text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono`,children:t(a?`skills.installed.noMatch`:`skills.installed.empty`)}),P.map(e=>(0,$.jsxs)(`button`,{onClick:()=>{i(e.id),p(null),l(null)},className:T(`flex w-full min-w-0 flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors`,e.id===r?`bg-[#E5E7EB] dark:bg-[#111827]`:`bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]`),children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:e.name}),(0,$.jsx)(`span`,{className:T(`text-[11px] font-mono font-semibold`,e.enabled?`text-[#16A34A] dark:text-[#22C55E]`:`text-[#f59e0b]`),children:e.enabled?t(`skills.status.enabled`):t(`skills.status.disabled`)})]}),(0,$.jsx)(`span`,{className:`block w-full min-w-0 truncate text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]`,children:e.description||t(`skills.noDescriptionShort`)})]},e.id))]})]}),F?(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-y-auto pr-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-base font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:F.name}),(0,$.jsxs)(`span`,{className:`text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:[`v`,F.version]})]}),(0,$.jsx)(`p`,{className:`text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]`,children:F.description||t(`skills.noDescription`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`button`,{onClick:()=>void I(`toggle`,F,!F.enabled),disabled:u!==null,className:T(`h-7 px-3 rounded-md text-[11px] font-mono font-semibold`,F.enabled?`bg-[#E5E7EB] text-[#111827] hover:bg-[#D1D5DB] dark:bg-[#27272a] dark:text-[#E5E5E5] dark:hover:bg-[#32323a]`:`bg-[#16A34A] text-white hover:bg-[#15803D] dark:bg-[#22C55E] dark:text-[#0C0C0C] dark:hover:bg-[#1ea34b]`,u&&`opacity-60 cursor-not-allowed`),children:u?.type===`toggle`&&u.name===F.name?t(`skills.action.saving`):F.enabled?t(`skills.action.disable`):t(`skills.action.enable`)}),(0,$.jsxs)(`button`,{onClick:()=>p(F.name),disabled:!F.removable||u!==null,title:F.removable?void 0:t(`skills.uninstall.managedHint`),className:`h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#ef4444] text-[11px] font-mono font-semibold flex items-center gap-1 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,$.jsx)(te,{className:`h-3 w-3`}),F.removable?t(`skills.uninstall.action`):t(`skills.uninstall.managed`)]})]}),f===F.name&&(0,$.jsxs)(`div`,{role:`alertdialog`,"aria-label":t(`skills.uninstall.confirmAria`,{name:F.name}),className:`flex flex-wrap items-center justify-between gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 dark:border-red-900/60 dark:bg-red-950/30`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-mono text-red-700 dark:text-red-300`,children:t(`skills.uninstall.confirmPrompt`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>p(null),className:`h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]`,children:t(`skills.action.cancel`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void I(`delete`,F),disabled:u!==null,className:`h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60`,children:u?.type===`delete`?t(`skills.uninstall.inProgress`):t(`skills.uninstall.confirm`)})]})]}),(0,$.jsx)(`div`,{className:`h-px bg-[#E5E7EB] dark:bg-[#1f2937]`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:t(`skills.details.title`)}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[12px] font-mono`,children:[(0,$.jsx)(`span`,{className:`text-[#9CA3AF] dark:text-[#71717a]`,children:t(`skills.details.provider`)}),(0,$.jsx)(`span`,{className:`text-[#111827] dark:text-[#E5E5E5]`,children:F.provider}),(0,$.jsx)(`span`,{className:`text-[#9CA3AF] dark:text-[#71717a]`,children:t(`skills.details.location`)}),(0,$.jsx)(`span`,{className:`text-[#111827] dark:text-[#E5E5E5] truncate`,children:F.location})]})]}),F.capabilities.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:t(`skills.details.capabilities`)}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:F.capabilities.map(e=>(0,$.jsx)(`span`,{className:`px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]`,children:e},e))})]}),F.allowedTools.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:t(`skills.details.allowedTools`,{count:F.allowedTools.length})}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:F.allowedTools.map(e=>(0,$.jsx)(`span`,{className:`px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]`,children:e},e))})]})]}):(0,$.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,$.jsx)(`span`,{className:`text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono`,children:t(`skills.detail.emptyState`)})})]})]}),(0,$.jsx)(Zt,{open:m,active:e,installed:D.map(e=>e.name),onOpenChange:h,onInstall:e=>{E(e),C(null),b(`confirm`),_(!0)}}),(0,$.jsx)(Qt,{open:g,status:v,error:S,onCancel:()=>_(!1),onConfirm:async()=>{if(w){b(`installing`),C(null);try{let e=await x(`/skills/install`,{method:`POST`,headers:{"Content-Type":`application/json`,...Gt(n)},body:JSON.stringify(w)});if(e.success===!1)throw Error(e.error||t(`skills.error.installFailed`));await M(),_(!1),h(!1)}catch(e){C(e instanceof Error?e.message:t(`skills.error.installFailed`)),b(`failed`)}}},onRetry:()=>b(`confirm`)})]})}function Xt({active:e,children:t,onClick:n}){return(0,$.jsx)(`button`,{onClick:n,className:T(`px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors`,e?`bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]`:`text-[#6B7280] dark:text-[#a1a1aa]`),children:t})}function Zt({open:e,active:t,onOpenChange:n,onInstall:r,installed:i}){let a=s(),[o,c]=(0,W.useState)(`catalog`),[l,u]=(0,W.useState)(``),[d,f]=(0,W.useState)(null),[p,m]=(0,W.useState)(``),[h,g]=(0,W.useState)(``),{data:_=[],loading:v,error:y,run:b}=ct(qt,{ready:t&&e&&o===`catalog`}),x=_.filter(e=>e.name.toLowerCase().includes(l.toLowerCase())),w=()=>{if(o===`catalog`){if(!d)return;r({source:`catalog`,name:d});return}if(o===`repo`){if(!p)return;r({source:`repo`,url:p});return}h&&r({source:`local`,path:h})},O=d?i.includes(d):!1,k=o===`catalog`&&(!d||O||v||!!y)||o===`repo`&&!p||o===`local`&&!h;return(0,$.jsx)(S,{open:e,onOpenChange:n,children:(0,$.jsxs)(C,{onCloseAutoFocus:e=>A(`[data-skill-install-trigger]`,e),className:`gap-0 overflow-y-auto rounded-xl border border-[#E5E7EB] bg-white p-0 dark:border-zinc-800 dark:bg-[#09090b] sm:max-w-[540px]`,"aria-describedby":void 0,hideCloseButton:!0,children:[(0,$.jsx)(E,{className:`sr-only`,children:a(`skills.install.title`)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono`,children:a(`skills.install.title`)}),(0,$.jsx)(`button`,{onClick:()=>n(!1),"aria-label":a(`skills.install.closeAria`),className:`h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center`,children:(0,$.jsx)(D,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit`,children:[(0,$.jsx)(Xt,{active:o===`catalog`,onClick:()=>c(`catalog`),children:a(`skills.install.tab.catalog`)}),(0,$.jsx)(Xt,{active:o===`repo`,onClick:()=>c(`repo`),children:a(`skills.install.tab.repo`)}),(0,$.jsx)(Xt,{active:o===`local`,onClick:()=>c(`local`),children:a(`skills.install.tab.local`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[o===`catalog`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`input`,{"aria-label":a(`skills.install.catalog.searchAria`),value:l,onChange:e=>u(e.target.value),placeholder:a(`skills.install.catalog.searchPlaceholder`),className:`h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]`}),(0,$.jsxs)(`div`,{className:`flex max-h-[min(240px,30dvh)] flex-col gap-2 overflow-y-auto`,children:[v&&(0,$.jsxs)(`div`,{role:`status`,className:`flex items-center justify-center gap-2 py-6 text-sm font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:[(0,$.jsx)(N,{className:`h-4 w-4 animate-spin`}),a(`skills.install.catalog.loading`)]}),y&&!v&&(0,$.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-center gap-2 py-6 text-center text-xs font-mono text-red-600 dark:text-red-400`,children:[(0,$.jsx)(`span`,{children:y.message}),(0,$.jsx)(`button`,{type:`button`,onClick:b,className:`rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900`,children:a(`skills.action.retry`)})]}),!v&&!y&&x.length===0&&(0,$.jsx)(`div`,{className:`text-center py-6 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono`,children:a(`skills.install.catalog.empty`)}),!v&&!y&&x.map(e=>{let t=i.includes(e.name),n=d===e.name;return(0,$.jsxs)(`button`,{onClick:()=>f(e.name),className:T(`rounded-lg px-3 py-2 flex flex-col gap-1 text-left transition-colors`,n?`bg-[#E5E7EB] dark:bg-[#111827]`:`bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]`),children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:e.name}),(0,$.jsx)(`span`,{className:T(`text-[10px] font-mono px-2 py-0.5 rounded`,e.tag===`Official`?`bg-[#22C55E]/20 text-[#16A34A] dark:text-[#22C55E]`:`bg-[#3b82f6]/20 text-[#3b82f6]`),children:Jt[e.tag]?a(Jt[e.tag]):e.tag})]}),(0,$.jsx)(`span`,{className:`text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]`,children:e.description}),(0,$.jsx)(`span`,{className:`text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:a(`skills.install.catalog.byAuthor`,{author:e.author})}),t&&(0,$.jsx)(`span`,{className:`text-[10px] font-mono text-[#16A34A] dark:text-[#22C55E]`,children:a(`skills.status.installed`)})]},e.name)})]})]}),o===`repo`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]`,children:a(`skills.install.repo.label`)}),(0,$.jsx)(`input`,{"aria-label":a(`skills.install.repo.inputAria`),value:p,onChange:e=>m(e.target.value),placeholder:`https://github.com/org/skill`,className:`h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]`}),(0,$.jsx)(`span`,{className:`inline-flex w-fit px-2 py-0.5 rounded bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]`,children:a(`skills.install.repo.credentialsHint`)})]}),o===`local`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]`,children:a(`skills.install.local.label`)}),(0,$.jsx)(`input`,{"aria-label":a(`skills.install.local.inputAria`),value:h,onChange:e=>g(e.target.value),placeholder:`/Users/bytedance/skills/my-skill`,className:`h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 pt-2`,children:[(0,$.jsx)(`button`,{onClick:()=>n(!1),className:`h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold`,children:a(`skills.action.cancel`)}),(0,$.jsx)(`button`,{onClick:w,disabled:k,className:T(`h-7 px-3 rounded-md text-[11px] font-mono font-semibold`,k?`bg-[#E5E7EB] text-[#9CA3AF] cursor-not-allowed dark:bg-[#27272a] dark:text-[#71717a]`:`bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C]`),children:a(`skills.action.installShort`)})]})]})]})})}function Qt({open:e,status:t,error:n,onCancel:r,onConfirm:i,onRetry:a}){let o=s();return(0,$.jsx)(S,{open:e,onOpenChange:e=>!e&&r(),children:(0,$.jsxs)(C,{className:`sm:max-w-[320px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl`,"aria-describedby":void 0,hideCloseButton:!0,children:[(0,$.jsx)(E,{className:`sr-only`,children:o(`skills.status.dialogTitle`)}),(0,$.jsxs)(`div`,{className:`p-5 flex flex-col gap-3`,children:[t===`confirm`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h4`,{className:`text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:o(`skills.status.confirm.title`)}),(0,$.jsx)(`p`,{className:`text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]`,children:o(`skills.status.confirm.prompt`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(`button`,{onClick:r,className:`h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold`,children:o(`skills.action.cancel`)}),(0,$.jsx)(`button`,{onClick:i,className:`h-6 px-2.5 rounded-md bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C] text-[11px] font-mono font-semibold`,children:o(`skills.action.installShort`)})]})]}),t===`installing`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h4`,{className:`text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:o(`skills.status.installing.title`)}),(0,$.jsx)(`p`,{className:`text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]`,children:o(`skills.status.installing.description`)}),(0,$.jsx)(`div`,{className:`h-1.5 rounded-full bg-[#E5E7EB] dark:bg-[#18181b] overflow-hidden`,children:(0,$.jsx)(`div`,{className:`h-full w-[45%] bg-[#16A34A] dark:bg-[#22C55E]`})}),(0,$.jsx)(`span`,{className:`text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:`~35%`}),(0,$.jsx)(`button`,{onClick:r,className:`self-end h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold`,children:o(`skills.action.hide`)})]}),t===`failed`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h4`,{className:`text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:o(`skills.status.failed.title`)}),(0,$.jsx)(`p`,{className:`text-[12px] font-mono text-[#f87171]`,children:n||o(`skills.status.failed.fallback`)}),(0,$.jsx)(`p`,{className:`text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]`,children:o(`skills.status.failed.hint`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(`button`,{onClick:r,className:`h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold`,children:o(`skills.action.close`)}),(0,$.jsx)(`button`,{onClick:a,className:`h-6 px-2.5 rounded-md bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C] text-[11px] font-mono font-semibold`,children:o(`skills.action.retry`)})]})]})]})]})})}var $t=[{id:`auto`,name:`Auto`,description:`Use the Blade default communication style`,source:`built-in`},{id:`pragmatic`,name:`Pragmatic`,description:`Direct, factual, concise, and action-oriented`,source:`built-in`},{id:`friendly`,name:`Friendly`,description:`Warm, collaborative, and task-focused`,source:`built-in`},{id:`explanatory`,name:`Explanatory`,description:`Explain codebase-specific choices and tradeoffs`,source:`built-in`}],en=/^[a-z][a-z0-9._-]{0,63}$/;function tn({open:e,onOpenChange:t,onSave:n,saveError:r}){let i=s(),[a,o]=(0,W.useState)([]),[c,l]=(0,W.useState)([]),[u,d]=(0,W.useState)(),[f,p]=(0,W.useState)(),[m,h]=(0,W.useState)(``),[g,_]=(0,W.useState)(``),[v,y]=(0,W.useState)(``),[b,w]=(0,W.useState)(``),[T,O]=(0,W.useState)(``),[j,M]=(0,W.useState)(``),[P,F]=(0,W.useState)(!1),[I,ee]=(0,W.useState)(!1),[L,te]=(0,W.useState)(!1),[ne,re]=(0,W.useState)(!1),[R,z]=(0,W.useState)(null);(0,W.useEffect)(()=>{if(!e)return;let t=!0;return l([]),d(void 0),p(void 0),h(``),_(``),y(``),w(``),O(``),M(``),F(!1),z(null),ee(!0),x(`/providers`).then(e=>{t&&o(e)}).catch(e=>{t&&z(e instanceof Error?e.message:i(`settings.models.addModal.loadProvidersError`))}).finally(()=>{t&&ee(!1)}),()=>{t=!1}},[e,i]),(0,W.useEffect)(()=>{if(!u)return;let e=!0;return l([]),p(void 0),z(null),u.factoryWireApi||u.custom?(te(!1),()=>{e=!1}):(te(!0),x(`/providers/${u.id}/models`).then(t=>{e&&l(t)}).catch(t=>{e&&z(t instanceof Error?t.message:i(`settings.models.addModal.loadModelsError`))}).finally(()=>{e&&te(!1)}),()=>{e=!1})},[u,i]);let B=u?.factoryWireApi,ie=!!(B||u?.custom),V=ie?b.trim():f?.id,H=async()=>{if(!u||!V||!u.configured&&!j)return;if(B){if(!en.test(g.trim())){z(i(`settings.models.addModal.channelIdError`));return}let e;try{e=new URL(T.trim())}catch{z(i(`settings.models.addModal.invalidBaseUrl`));return}if(![`http:`,`https:`].includes(e.protocol)){z(i(`settings.models.addModal.invalidBaseUrl`));return}}re(!0);let e=B?g.trim():u.id,r=await n({provider:e,model:V,displayName:m||(ie?V:f?.name??``),apiKey:j||void 0,...B?{modelProvider:{id:e,name:v.trim()||e,baseUrl:T.trim(),wireApi:B}}:{}});re(!1),r&&t(!1)};return(0,$.jsx)(S,{open:e,onOpenChange:t,children:(0,$.jsxs)(C,{onCloseAutoFocus:e=>A(`[data-add-model-trigger]`,e),onEscapeKeyDown:e=>{e.preventDefault(),t(!1)},onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),t(!1))},className:`gap-0 overflow-y-auto rounded-xl border border-[#E5E7EB] bg-white p-0 dark:border-zinc-800 dark:bg-[#09090b] sm:max-w-[480px]`,"aria-describedby":void 0,hideCloseButton:!0,children:[(0,$.jsx)(E,{className:`sr-only`,children:i(`settings.models.addModal.title`)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-5 p-4 sm:p-6`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h2`,{className:`font-mono text-base font-semibold`,children:i(`settings.models.addModal.title`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>t(!1),"aria-label":i(`settings.models.addModal.close`),className:`flex h-8 w-8 items-center justify-center rounded-md`,children:(0,$.jsx)(D,{className:`h-4 w-4`})})]}),(R||r)&&(0,$.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:[(0,$.jsx)(k,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{children:R||r})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-2 text-[13px] font-mono text-zinc-500`,children:[i(`settings.models.addModal.provider`),(0,$.jsx)(Ft,{"aria-label":i(`settings.models.addModal.provider`),value:u?.id??``,disabled:I,onChange:e=>{d(a.find(t=>t.id===e)),h(``),_(``),y(``),w(``),O(``)},placeholder:i(I?`settings.models.addModal.loadingProviders`:`settings.models.addModal.selectProvider`),options:a.map(e=>{let t=e.factoryWireApi===`openai-completions`?i(`settings.models.addModal.customOpenAI`):e.factoryWireApi===`anthropic-messages`?i(`settings.models.addModal.customAnthropic`):e.name;return{value:e.id,label:`${t} (${e.modelCount})${e.configured?i(`settings.models.addModal.configuredSuffix`):``}`}})})]}),ie?(0,$.jsxs)($.Fragment,{children:[B&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-2 text-[13px] font-mono text-zinc-500`,children:[i(`settings.models.addModal.channelId`),(0,$.jsx)(`input`,{"aria-label":i(`settings.models.addModal.channelId`),value:g,onChange:e=>{_(e.target.value),z(null)},placeholder:`team-gateway`,autoComplete:`off`,spellCheck:!1,className:`field`}),(0,$.jsx)(`span`,{className:`text-[11px] text-zinc-400`,children:i(`settings.models.addModal.channelIdHint`)})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-2 text-[13px] font-mono text-zinc-500`,children:[i(`settings.models.addModal.channelName`),(0,$.jsx)(`input`,{"aria-label":i(`settings.models.addModal.channelName`),value:v,onChange:e=>y(e.target.value),placeholder:`Team Gateway`,className:`field`})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-2 text-[13px] font-mono text-zinc-500`,children:[i(`settings.models.addModal.baseUrl`),(0,$.jsx)(`input`,{"aria-label":i(`settings.models.addModal.baseUrl`),value:T,onChange:e=>{O(e.target.value),z(null)},placeholder:B===`anthropic-messages`?`https://gateway.example.com`:`https://gateway.example.com/v1`,className:`field`}),(0,$.jsx)(`span`,{className:`text-[11px] text-zinc-400`,children:i(B===`anthropic-messages`?`settings.models.addModal.anthropicProtocol`:`settings.models.addModal.openaiProtocol`)})]})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-2 text-[13px] font-mono text-zinc-500`,children:[i(`settings.models.addModal.modelId`),(0,$.jsx)(`input`,{"aria-label":i(`settings.models.addModal.modelId`),value:b,onChange:e=>{w(e.target.value),z(null)},placeholder:`vendor-model-2026`,className:`field`})]})]}):(0,$.jsxs)(`label`,{className:`flex flex-col gap-2 text-[13px] font-mono text-zinc-500`,children:[i(`settings.models.addModal.model`),(0,$.jsx)(Ft,{"aria-label":i(`settings.models.addModal.model`),value:f?.id??``,disabled:!u||L,onChange:e=>{let t=c.find(t=>t.id===e);p(t),t&&h(t.name)},placeholder:i(L?`settings.models.addModal.loadingModels`:`settings.models.addModal.selectModel`),options:c.map(e=>({value:e.id,label:`${e.name} - ${Math.round(e.contextWindow/1e3)}K${e.reasoning?i(`settings.models.addModal.reasoningSuffix`):``}${e.input.includes(`image`)?i(`settings.models.addModal.visionSuffix`):``}`}))})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-2 text-[13px] font-mono text-zinc-500`,children:[i(`settings.models.addModal.displayName`),(0,$.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),placeholder:f?.name??i(`settings.models.addModal.displayNamePlaceholder`),className:`field`})]}),u?.supportsApiKey&&!u.configured&&(0,$.jsxs)(`label`,{className:`flex flex-col gap-2 text-[13px] font-mono text-zinc-500`,children:[i(`settings.models.addModal.apiKey`),(0,$.jsxs)(`span`,{className:`relative`,children:[(0,$.jsx)(`input`,{"aria-label":i(`settings.models.addModal.apiKeyAria`),type:P?`text`:`password`,value:j,onChange:e=>M(e.target.value),className:`field w-full pr-10`,placeholder:i(`settings.models.addModal.apiKeyPlaceholder`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>F(!P),"aria-label":i(P?`settings.models.addModal.hideApiKey`:`settings.models.addModal.showApiKey`),className:`absolute right-2 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded`,children:P?(0,$.jsx)(ae,{className:`h-4 w-4`}):(0,$.jsx)(oe,{className:`h-4 w-4`})})]})]}),u&&!u.configured&&!u.supportsApiKey&&(0,$.jsx)(`p`,{className:`font-mono text-sm text-amber-600`,children:i(`settings.models.addModal.oauthNote`)}),(0,$.jsxs)(`button`,{type:`button`,disabled:ne||!u||!V||B&&(!g.trim()||!T.trim())||!u.configured&&(!u.supportsApiKey||j.trim().length===0),onClick:()=>void H(),className:`flex min-h-9 items-center justify-center gap-2 rounded-md bg-green-600 px-4 py-2 font-mono text-sm font-semibold text-white disabled:opacity-50`,children:[ne&&(0,$.jsx)(N,{className:`h-4 w-4 animate-spin`}),i(ne?`settings.models.addModal.saving`:`settings.models.addModal.saveModel`)]})]})]})})}function nn(e){let t=s(),[n,r]=(0,W.useState)(``),[i,a]=(0,W.useState)(``),[o,c]=(0,W.useState)(``),[l,u]=(0,W.useState)(``),[d,f]=(0,W.useState)(!1),[p,m]=(0,W.useState)(null);(0,W.useEffect)(()=>{r(e.model?.displayName??``),a(e.model?.overrides?.baseUrl??``),c(e.model?.overrides?.streamIdleTimeout===void 0?``:String(e.model.overrides.streamIdleTimeout)),u(``),m(null)},[e.model]);let h=async()=>{if(!e.model)return;m(null);let r=o.trim()?Number(o):void 0;if(r!==void 0&&(!Number.isFinite(r)||r<1e3)){m(t(`settings.models.editModal.streamIdleTimeoutError`));return}f(!0);try{l.trim()&&await x(`/providers/${e.model.provider}/credential`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({apiKey:l.trim()})});let t={...e.model.overrides};i.trim()?t.baseUrl=i.trim():delete t.baseUrl,r===void 0?delete t.streamIdleTimeout:t.streamIdleTimeout=r,await e.onSave(e.model.id,{displayName:n||void 0,overrides:Object.keys(t).length>0?t:void 0})&&e.onOpenChange(!1)}catch(e){m(e instanceof Error?e.message:t(`settings.models.editModal.credentialError`))}finally{f(!1)}},g=e.model?`[data-edit-model-trigger="${e.model.id.replace(/"/g,`\\"`)}"]`:`[data-edit-model-trigger]`;return(0,$.jsx)(S,{open:e.open,onOpenChange:e.onOpenChange,children:(0,$.jsxs)(C,{onCloseAutoFocus:e=>A(g,e),onEscapeKeyDown:t=>{t.preventDefault(),e.onOpenChange(!1)},onKeyDown:t=>{t.key===`Escape`&&(t.preventDefault(),t.stopPropagation(),e.onOpenChange(!1))},className:`gap-4 overflow-y-auto bg-white p-4 dark:bg-[#09090b] sm:max-w-[480px] sm:p-6`,"aria-describedby":void 0,hideCloseButton:!0,children:[(0,$.jsx)(E,{className:`sr-only`,children:t(`settings.models.editModal.srTitle`)}),(0,$.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,$.jsx)(`h2`,{className:`font-mono font-semibold`,children:t(`settings.models.editModal.title`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>e.onOpenChange(!1),"aria-label":t(`settings.models.editModal.close`),className:`flex justify-center items-center w-8 h-8 rounded-md`,children:(0,$.jsx)(D,{className:`w-4 h-4`})})]}),(p||e.saveError)&&(0,$.jsx)(`div`,{role:`alert`,className:`rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:p||e.saveError}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-2 font-mono text-sm`,children:[t(`settings.models.editModal.displayName`),(0,$.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),className:`field`})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-2 font-mono text-sm`,children:[t(`settings.models.editModal.replaceApiKey`),(0,$.jsx)(`input`,{type:`password`,value:l,onChange:e=>u(e.target.value),placeholder:t(`settings.models.editModal.replaceApiKeyPlaceholder`),className:`field`})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-2 font-mono text-sm`,children:[t(`settings.models.editModal.baseUrlOverride`),(0,$.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),placeholder:t(`settings.models.editModal.baseUrlPlaceholder`),className:`field`})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-2 font-mono text-sm`,children:[t(`settings.models.editModal.streamIdleTimeout`),(0,$.jsx)(`input`,{type:`number`,min:1e3,step:1e3,value:o,onChange:e=>c(e.target.value),placeholder:`300000`,className:`field`})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void h(),disabled:d,className:`flex gap-2 justify-center items-center px-4 py-2 text-white bg-green-600 rounded-md min-h-9 disabled:opacity-60`,children:[d&&(0,$.jsx)(N,{className:`w-4 h-4 animate-spin`}),t(d?`settings.models.editModal.saving`:`settings.models.editModal.save`)]})]})})}function rn({provider:e,onOpenChange:t,onSave:n,saveError:r}){let i=s(),[a,o]=(0,W.useState)(e.name),[c,l]=(0,W.useState)(e.defaultBaseUrl??``),[u,d]=(0,W.useState)(e.wireApi??`openai-completions`),[f,p]=(0,W.useState)(e.apiKeyEnv??``),[m,h]=(0,W.useState)(``),[g,_]=(0,W.useState)(null),[v,y]=(0,W.useState)(!1);(0,W.useEffect)(()=>{o(e.name),l(e.defaultBaseUrl??``),d(e.wireApi??`openai-completions`),p(e.apiKeyEnv??``),h(``),_(null)},[e]);let b=async()=>{if(!a.trim()){_(i(`settings.models.editProvider.channelNameRequired`));return}try{let e=new URL(c.trim());if(![`http:`,`https:`].includes(e.protocol))throw Error()}catch{_(i(`settings.models.editProvider.invalidBaseUrl`));return}y(!0),_(null);try{await n(e.id,{name:a.trim(),baseUrl:c.trim(),wireApi:u,apiKeyEnv:f.trim()||null,...m.trim()?{apiKey:m.trim()}:{}})&&t(!1)}finally{y(!1)}};return(0,$.jsx)(S,{open:!0,onOpenChange:t,children:(0,$.jsxs)(C,{onCloseAutoFocus:t=>A(`[data-edit-provider-trigger="${e.id.replace(/"/g,`\\"`)}"]`,t),onEscapeKeyDown:e=>{e.preventDefault(),t(!1)},onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),t(!1))},className:`gap-4 overflow-y-auto bg-white p-4 dark:bg-[#09090b] sm:max-w-[480px] sm:p-6`,"aria-describedby":void 0,hideCloseButton:!0,children:[(0,$.jsx)(E,{className:`sr-only`,children:i(`settings.models.editProvider.title`)}),(0,$.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`font-mono font-semibold`,children:i(`settings.models.editProvider.title`)}),(0,$.jsx)(`p`,{className:`mt-1 font-mono text-[11px] text-zinc-400`,children:e.id})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>t(!1),"aria-label":i(`settings.models.editProvider.close`),className:`flex justify-center items-center w-8 h-8 rounded-md`,children:(0,$.jsx)(D,{className:`w-4 h-4`})})]}),(g||r)&&(0,$.jsx)(`div`,{role:`alert`,className:`rounded-md border border-red-200 bg-red-50 px-3 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:g||r}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-2 font-mono text-sm`,children:[i(`settings.models.editProvider.channelName`),(0,$.jsx)(`input`,{"aria-label":i(`settings.models.editProvider.channelName`),value:a,onChange:e=>o(e.target.value),className:`field`})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-2 font-mono text-sm`,children:[i(`settings.models.editProvider.wireApi`),(0,$.jsx)(Ft,{"aria-label":i(`settings.models.editProvider.wireApi`),value:u,onChange:e=>d(e),options:[{value:`openai-completions`,label:`OpenAI Chat Completions`},{value:`anthropic-messages`,label:`Anthropic Messages`}]})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-2 font-mono text-sm`,children:[i(`settings.models.editProvider.baseUrl`),(0,$.jsx)(`input`,{"aria-label":i(`settings.models.editProvider.baseUrlAria`),value:c,onChange:e=>{l(e.target.value),_(null)},className:`field`})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-2 font-mono text-sm`,children:[i(`settings.models.editProvider.apiKeyEnv`),(0,$.jsx)(`input`,{"aria-label":i(`settings.models.editProvider.apiKeyEnv`),value:f,onChange:e=>p(e.target.value),placeholder:i(`settings.models.editProvider.apiKeyEnvPlaceholder`),autoComplete:`off`,spellCheck:!1,className:`field`})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-2 font-mono text-sm`,children:[i(`settings.models.editProvider.replaceApiKey`),(0,$.jsx)(`input`,{"aria-label":i(`settings.models.editProvider.apiKeyAria`),type:`password`,value:m,onChange:e=>h(e.target.value),placeholder:i(`settings.models.editProvider.apiKeyPlaceholder`),className:`field`})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void b(),disabled:v,className:`flex gap-2 justify-center items-center px-4 py-2 text-white bg-green-600 rounded-md min-h-9 disabled:opacity-60`,children:[v&&(0,$.jsx)(N,{className:`w-4 h-4 animate-spin`}),i(v?`settings.models.editProvider.saving`:`settings.models.editProvider.save`)]})]})})}var an={disabled:`settings.hooks.state.disabled`,not_required:`settings.hooks.state.notRequired`,untrusted:`settings.hooks.state.review`,trusted:`settings.hooks.state.trusted`,modified:`settings.hooks.state.modified`,error:`settings.hooks.state.error`};function on(){let e=s(),t=R(e=>e.currentSessionRef),n=t?.projectPath,r=t?.sessionId,i=(0,W.useMemo)(()=>n??new URLSearchParams(window.location.search).get(`project`)??``,[n]),[a,o]=(0,W.useState)(null),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(``),[f,m]=(0,W.useState)(``),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(null),[y,b]=(0,W.useState)(null),[S,C]=(0,W.useState)(null),w=(0,W.useRef)(0),E=(0,W.useRef)(i);E.current=i;let D=r?`${i}\0${r}`:``,k=(0,W.useRef)(D);k.current=D;let A=u===i?a:null,j=f===D?c:null,M=(0,W.useCallback)(async()=>{let t=++w.current;if(!i){o(null),l(null),d(``),m(``),C(null);return}g(!0),C(null);try{let e=await x(`/hooks/trust?projectPath=${encodeURIComponent(i)}`);if(t!==w.current)return;let n=r?await x(`/hooks/session?projectPath=${encodeURIComponent(i)}&sessionId=${encodeURIComponent(r)}`):null;if(t!==w.current)return;o(e),l(n),d(i),m(n?D:``)}catch(n){if(t!==w.current)return;C(n instanceof Error?n.message:e(`settings.hooks.loadFailed`))}finally{t===w.current&&g(!1)}},[i,r,D,e]);(0,W.useEffect)(()=>(b(null),M(),()=>{w.current+=1}),[M]);let P=async t=>{if(!A)return;let n=i;v(t),C(null);try{let e=await x(`/hooks/trust`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({projectPath:i,action:t,...t===`trust`&&A.currentDigest?{expectedDigest:A.currentDigest}:{}})});E.current===n&&(o(e),d(n),b(null))}catch(t){E.current===n&&C(t instanceof Error?t.message:e(`settings.hooks.updateFailed`))}finally{v(null)}},F=async t=>{if(!r||!j)return;let n=D;v(`session`),C(null);try{let e=await x(`/hooks/session`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({projectPath:i,sessionId:r,enabled:t})});k.current===n&&(l(e),m(n))}catch(t){k.current===n&&C(t instanceof Error?t.message:e(`settings.hooks.sessionUpdateFailed`))}finally{v(null)}};if(!i)return(0,$.jsx)(`div`,{className:`font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]`,children:e(`settings.hooks.selectSession`)});let I=A?.state===`trusted`,ee=A?.state===`untrusted`||A?.state===`modified`,L=j!==null&&!j.enabled&&!j.paused;return(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3 font-mono`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 rounded-md border border-[#E5E7EB] bg-[#F9FAFB] p-3 dark:border-[#27272a] dark:bg-[#111113]`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[I?(0,$.jsx)(O,{className:`h-4 w-4 text-emerald-600`}):(0,$.jsx)(p,{className:T(`h-4 w-4`,ee?`text-amber-600`:`text-[#71717a]`)}),(0,$.jsx)(`span`,{className:`text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:e(A?an[A.state]:`settings.hooks.heading`)}),h&&(0,$.jsx)(N,{className:`h-3.5 w-3.5 animate-spin`})]}),(0,$.jsx)(`p`,{className:`mt-1 break-all text-[10.5px] text-[#71717a]`,children:i}),A?.currentDigest&&(0,$.jsx)(`p`,{className:`mt-1 text-[10px] text-[#9CA3AF]`,children:A.currentDigest})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void M(),disabled:h||_!==null,"aria-label":e(`settings.hooks.reloadAria`),className:`inline-flex h-8 items-center gap-1 rounded-md border border-[#E5E7EB] px-2 text-[11px] text-[#6B7280] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#a1a1aa]`,children:[(0,$.jsx)(ne,{className:`h-3.5 w-3.5`}),e(`settings.common.reload`)]}),I?(0,$.jsx)(`button`,{type:`button`,onClick:()=>b(`revoke`),disabled:_!==null,className:`h-8 rounded-md border border-red-200 px-2.5 text-[11px] text-red-600 disabled:opacity-50 dark:border-red-900 dark:text-red-400`,children:e(`settings.hooks.revoke`)}):(0,$.jsx)(`button`,{type:`button`,onClick:()=>b(`trust`),disabled:_!==null||!A?.currentDigest||A.state===`error`,className:`h-8 rounded-md bg-emerald-600 px-2.5 text-[11px] font-semibold text-white disabled:opacity-50`,children:e(`settings.hooks.trustDigest`)})]})]}),S&&(0,$.jsx)(`div`,{role:`alert`,className:`rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:S}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-md border border-[#E5E7EB] px-3 py-2 dark:border-[#27272a]`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-[11px] font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:e(`settings.hooks.currentSession`)}),(0,$.jsx)(`div`,{className:`mt-0.5 text-[9.5px] text-[#9CA3AF]`,children:r?j?j.paused?e(`settings.hooks.session.paused`):j.enabled?e(`settings.hooks.session.active`):j.configEnabled?e(`settings.hooks.session.unavailable`):e(`settings.hooks.session.disabled`):e(`settings.hooks.session.loading`):e(`settings.hooks.session.open`)})]}),(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":j?.paused?e(`settings.hooks.session.enableAria`):j?.enabled?e(`settings.hooks.session.pauseAria`):e(`settings.hooks.session.unavailableAria`),"aria-checked":j?.enabled??!1,disabled:!j||_!==null||L,onClick:()=>void F(j?.paused===!0),className:T(`flex h-6 w-11 items-center rounded-full px-1 transition-colors disabled:opacity-40`,j?.enabled?`bg-emerald-500`:`bg-[#E5E7EB] dark:bg-[#27272a]`),children:(0,$.jsx)(`span`,{className:T(`h-4 w-4 rounded-full bg-white transition-transform`,j?.enabled?`translate-x-5`:`translate-x-0`)})})]}),y&&A&&(0,$.jsxs)(`div`,{role:`alertdialog`,"aria-label":e(y===`trust`?`settings.hooks.confirmTrustAria`:`settings.hooks.confirmRevokeAria`),className:`flex flex-wrap items-center justify-between gap-3 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 dark:border-amber-900/70 dark:bg-amber-950/30`,children:[(0,$.jsx)(`span`,{className:`max-w-[620px] text-[11px] text-amber-900 dark:text-amber-200`,children:y===`trust`?e(`settings.hooks.confirmTrust`,{count:A.configuredHooks}):e(`settings.hooks.confirmRevoke`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>b(null),className:`h-7 rounded px-2 text-[11px] text-[#6B7280] dark:text-[#a1a1aa]`,children:e(`settings.common.cancel`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void P(y),disabled:_!==null,className:T(`h-7 rounded px-2.5 text-[11px] font-semibold text-white disabled:opacity-50`,y===`trust`?`bg-emerald-600`:`bg-red-600`),children:e(_?`settings.hooks.saving`:y===`trust`?`settings.hooks.trustReviewed`:`settings.hooks.revokeTrust`)})]})]}),(0,$.jsxs)(`div`,{className:`min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]`,children:[(A?.definitions??[]).map((e,t)=>(0,$.jsxs)(`div`,{className:`border-b border-[#E5E7EB] px-3 py-2 last:border-b-0 dark:border-[#27272a]`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[(0,$.jsx)(`span`,{className:`font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:e.event}),(0,$.jsx)(`span`,{className:`rounded bg-[#E5E7EB] px-1.5 py-0.5 text-[9px] uppercase text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]`,children:e.type}),e.name&&(0,$.jsx)(`span`,{className:`text-[#71717a]`,children:e.name}),e.pluginName&&(0,$.jsxs)(`span`,{className:`rounded bg-violet-100 px-1.5 py-0.5 text-[9px] text-violet-700 dark:bg-violet-950/50 dark:text-violet-300`,children:[e.pluginName,` · `,e.pluginSource]})]}),e.matcher&&(0,$.jsx)(`div`,{className:`mt-1 break-all text-[9.5px] text-[#9CA3AF]`,children:e.matcher}),(0,$.jsx)(`pre`,{className:`mt-1.5 whitespace-pre-wrap break-all text-[10.5px] text-[#374151] dark:text-[#d4d4d8]`,children:e.target})]},`${e.event}-${e.type}-${t}`)),A&&A.definitions.length===0&&(0,$.jsx)(`div`,{className:`px-3 py-8 text-center text-[11px] text-[#9CA3AF]`,children:e(`settings.hooks.empty`)})]})]})}var sn={restrictToAllowedSources:!1,requireGitCommitSha:!1,allowedGitHosts:[],allowedMarketplaces:[],allowedLocalRoots:[]},cn=[{value:`local`,labelKey:`settings.plugins.scope.local`,descriptionKey:`settings.plugins.scope.localDesc`},{value:`project`,labelKey:`settings.plugins.scope.project`,descriptionKey:`settings.plugins.scope.projectDesc`},{value:`global`,labelKey:`settings.plugins.scope.global`,descriptionKey:`settings.plugins.scope.globalDesc`}],ln={local:`settings.plugins.scope.local`,project:`settings.plugins.scope.project`,global:`settings.plugins.scope.global`,invocation:`settings.plugins.scope.invocation`,default:`settings.plugins.scope.default`};function un(){let e=s(),t=R(e=>e.currentSessionRef?.projectPath),n=R(e=>e.selectedProjectPath),r=(0,W.useMemo)(()=>t??n??new URLSearchParams(window.location.search).get(`project`)??``,[n,t]),[i,a]=(0,W.useState)([]),[o,c]=(0,W.useState)([]),[l,u]=(0,W.useState)(sn),[d,f]=(0,W.useState)(!1),[p,m]=(0,W.useState)(``),[h,_]=(0,W.useState)(``),[v,b]=(0,W.useState)(``),[S,C]=(0,W.useState)(``),[w,E]=(0,W.useState)(!1),[D,k]=(0,W.useState)(null),[A,M]=(0,W.useState)(null),[P,F]=(0,W.useState)(``),[I,ee]=(0,W.useState)(``),[L,re]=(0,W.useState)(!1),[z,B]=(0,W.useState)(null),[ie,V]=(0,W.useState)(`local`),ae=(0,W.useRef)(0),H=(0,W.useRef)(r);H.current=r;let oe=S===r?i:[],se=S===r?o:[],G=(0,W.useCallback)(async()=>{let t=++ae.current;if(!r){a([]),C(``),M(null);return}E(!0),M(null);try{let[e,n,i]=await Promise.all([x(`/plugins?projectPath=${encodeURIComponent(r)}`),x(`/plugins/catalog?projectPath=${encodeURIComponent(r)}`),x(`/plugins/policy?projectPath=${encodeURIComponent(r)}`)]);if(t!==ae.current)return;a(e),c(n);let o=i?.policy??sn;u(o),f(i?.environmentRequiresSha??!1),m(o.allowedGitHosts.join(`, `)),_(o.allowedMarketplaces.join(`, `)),b(o.allowedLocalRoots.join(`, `)),C(r)}catch(n){if(t!==ae.current)return;M(n instanceof Error?n.message:e(`settings.plugins.loadFailed`))}finally{t===ae.current&&E(!1)}},[r,e]);(0,W.useEffect)(()=>(G(),()=>{ae.current+=1}),[G]);let K=async(t,n)=>{let i=r;k(t.name),M(null);try{await x(`/plugins/${encodeURIComponent(t.name)}/state`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({projectPath:i,enabled:n,scope:ie})}),H.current===i&&await G()}catch(t){H.current===i&&M(t instanceof Error?t.message:e(`settings.plugins.updateFailed`))}finally{k(null)}},q=e=>[...new Set(e.split(`,`).map(e=>e.trim()).filter(Boolean))],ce=async()=>{await J(`policy:save`,()=>x(`/plugins/policy`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({projectPath:r,scope:`local`,policy:{...l,allowedGitHosts:q(p),allowedMarketplaces:q(h),allowedLocalRoots:q(v)}})}))},J=async(t,n,i)=>{let a=r;k(t),M(null);try{await n(),H.current===a&&(i?.(),B(null),await G())}catch(t){H.current===a&&M(t instanceof Error?t.message:e(`settings.plugins.actionFailed`))}finally{k(null)}},Y=async()=>{let e=P.trim();e&&L&&await J(`install`,()=>x(`/plugins/install`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({projectPath:r,source:e,trust:!0})}),()=>{F(``),re(!1)})},le=async e=>{let t=`update:${e.name}`;if(z!==t){B(t);return}await J(t,()=>x(`/plugins/${encodeURIComponent(e.name)}/update`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({projectPath:r,trust:!0})}))},ue=async e=>{let t=`uninstall:${e.name}`;if(z!==t){B(t);return}await J(t,()=>x(`/plugins/${encodeURIComponent(e.name)}/uninstall`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({projectPath:r,confirm:!0})}))},X=async()=>{let e=I.trim();e&&await J(`marketplace:add`,()=>x(`/plugins/marketplaces`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({projectPath:r,source:e})}),()=>ee(``))},de=async e=>{await J(`marketplace:refresh:${e.name}`,()=>x(`/plugins/marketplaces/${encodeURIComponent(e.name)}/refresh`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({projectPath:r})}))},fe=async e=>{let t=`marketplace:remove:${e.name}`;if(z!==t){B(t);return}await J(t,()=>x(`/plugins/marketplaces/${encodeURIComponent(e.name)}/remove`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({projectPath:r,confirm:!0})}))};return r?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3 font-mono`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:[(0,$.jsx)(j,{className:`h-4 w-4`}),e(`settings.plugins.heading`),w&&(0,$.jsx)(N,{className:`h-3.5 w-3.5 animate-spin`})]}),(0,$.jsx)(`p`,{className:`mt-1 break-all text-[10.5px] text-[#71717a]`,children:r}),(0,$.jsx)(`p`,{className:`mt-1 text-[10px] text-[#9CA3AF]`,children:e(`settings.plugins.changesNote`)})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void G(),disabled:w||D!==null,"aria-label":e(`settings.plugins.reloadAria`),className:`inline-flex h-8 items-center gap-1 rounded-md border border-[#E5E7EB] px-2 text-[11px] text-[#6B7280] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#a1a1aa]`,children:[(0,$.jsx)(ne,{className:`h-3.5 w-3.5`}),e(`settings.common.reload`)]})]}),A&&(0,$.jsx)(`div`,{role:`alert`,className:`rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:A}),(0,$.jsxs)(`div`,{className:`rounded-md border border-[#E5E7EB] p-3 dark:border-[#27272a]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:[(0,$.jsx)(O,{className:`h-3.5 w-3.5`}),e(`settings.plugins.sourcePolicy`)]}),(0,$.jsx)(`button`,{type:`button`,"aria-label":e(`settings.plugins.savePolicyAria`),onClick:()=>void ce(),disabled:D!==null,className:`rounded-md border border-[#D1D5DB] px-2 py-1 text-[9.5px] text-[#6B7280] disabled:opacity-40 dark:border-[#3f3f46] dark:text-[#a1a1aa]`,children:e(D===`policy:save`?`settings.plugins.saving`:`settings.plugins.saveForProject`)})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-x-4 gap-y-2`,children:[(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-label":e(`settings.plugins.restrictAria`),"aria-checked":l.restrictToAllowedSources,onClick:()=>u(e=>({...e,restrictToAllowedSources:!e.restrictToAllowedSources})),className:`flex items-center gap-2 text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]`,children:[(0,$.jsx)(`span`,{className:T(`h-3.5 w-6 rounded-full p-0.5`,l.restrictToAllowedSources?`bg-amber-500`:`bg-[#D1D5DB] dark:bg-[#3f3f46]`),children:(0,$.jsx)(`span`,{className:T(`block h-2.5 w-2.5 rounded-full bg-white transition-transform`,l.restrictToAllowedSources&&`translate-x-2.5`)})}),e(`settings.plugins.restrictAllowlists`)]}),(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-label":e(`settings.plugins.requireShaAria`),"aria-checked":l.requireGitCommitSha,disabled:d,onClick:()=>u(e=>({...e,requireGitCommitSha:!e.requireGitCommitSha})),className:`flex items-center gap-2 text-[9.5px] text-[#6B7280] disabled:opacity-50 dark:text-[#a1a1aa]`,children:[(0,$.jsx)(`span`,{className:T(`h-3.5 w-6 rounded-full p-0.5`,l.requireGitCommitSha?`bg-emerald-500`:`bg-[#D1D5DB] dark:bg-[#3f3f46]`),children:(0,$.jsx)(`span`,{className:T(`block h-2.5 w-2.5 rounded-full bg-white transition-transform`,l.requireGitCommitSha&&`translate-x-2.5`)})}),e(`settings.plugins.requireSha`),d?e(`settings.plugins.environmentLocked`):``]})]}),(0,$.jsxs)(`div`,{className:`mt-2 grid gap-1.5 sm:grid-cols-3`,children:[(0,$.jsx)(`input`,{"aria-label":e(`settings.plugins.gitHostsAria`),value:p,onChange:e=>m(e.target.value),placeholder:`github.com, *.corp.test`,className:`field h-7 px-2 text-[9.5px]`}),(0,$.jsx)(`input`,{"aria-label":e(`settings.plugins.marketplacesAria`),value:h,onChange:e=>_(e.target.value),placeholder:`team-market, official`,className:`field h-7 px-2 text-[9.5px]`}),(0,$.jsx)(`input`,{"aria-label":e(`settings.plugins.localRootsAria`),value:v,onChange:e=>b(e.target.value),placeholder:`/opt/approved/plugins`,className:`field h-7 px-2 text-[9.5px]`})]}),l.restrictToAllowedSources&&!p.trim()&&!h.trim()&&!v.trim()&&(0,$.jsx)(`p`,{className:`mt-1.5 text-[9px] text-amber-700 dark:text-amber-400`,children:e(`settings.plugins.emptyAllowlists`)})]}),(0,$.jsxs)(`div`,{className:`rounded-md border border-[#E5E7EB] p-3 dark:border-[#27272a]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:[(0,$.jsx)(g,{className:`h-3.5 w-3.5`}),e(`settings.plugins.installHeading`)]}),(0,$.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,$.jsx)(`input`,{"aria-label":e(`settings.plugins.sourceAria`),value:P,onChange:e=>F(e.target.value),placeholder:`plugin@marketplace, owner/repo, or ./path`,disabled:D!==null,className:`field h-8 min-w-0 flex-1 px-2 text-[10.5px]`}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void Y(),disabled:!P.trim()||!L||D!==null,className:`inline-flex h-8 items-center gap-1 rounded-md bg-[#111827] px-3 text-[10.5px] text-white disabled:opacity-40 dark:bg-[#E5E5E5] dark:text-[#18181b]`,children:[D===`install`?(0,$.jsx)(N,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(g,{className:`h-3.5 w-3.5`}),e(`settings.plugins.install`)]})]}),(0,$.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":L,onClick:()=>re(e=>!e),className:`mt-2 flex items-center gap-2 text-left text-[9.5px] text-amber-700 dark:text-amber-400`,children:[(0,$.jsx)(`span`,{className:T(`flex h-3.5 w-3.5 items-center justify-center rounded-sm border`,L?`border-amber-600 bg-amber-600 text-white`:`border-[#D1D5DB] dark:border-[#52525b]`),children:L?`✓`:``}),e(`settings.plugins.trustSource`)]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-md border border-[#E5E7EB] px-3 py-2 dark:border-[#27272a]`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-[10.5px] font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:e(`settings.plugins.activationScope`)}),(0,$.jsx)(`div`,{className:`mt-0.5 text-[9px] text-[#9CA3AF]`,children:e(`settings.plugins.activationScopeHint`)})]}),(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":e(`settings.plugins.scopeAria`),className:`flex rounded-md bg-[#F3F4F6] p-0.5 dark:bg-[#18181b]`,children:cn.map(t=>(0,$.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":ie===t.value,title:e(t.descriptionKey),onClick:()=>V(t.value),className:T(`rounded px-2 py-1 text-[9.5px] transition-colors`,ie===t.value?`bg-white font-semibold text-[#111827] shadow-sm dark:bg-[#27272a] dark:text-[#E5E5E5]`:`text-[#71717a] hover:text-[#374151] dark:hover:text-[#d4d4d8]`),children:e(t.labelKey)},t.value))})]}),(0,$.jsxs)(`div`,{className:`min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]`,children:[oe.map(t=>{let n=D===t.name,r=[t.commands?e(`settings.plugins.capability.commands`,{count:t.commands}):``,t.skills?e(`settings.plugins.capability.skills`,{count:t.skills}):``,t.agents?e(`settings.plugins.capability.agents`,{count:t.agents}):``,t.hooks?e(`settings.plugins.capability.hooks`,{count:t.hooks}):``,t.mcpServers?e(`settings.plugins.capability.mcp`,{count:t.mcpServers}):``].filter(Boolean),i=[`global`,`project`,`local`,`invocation`].filter(e=>t.settingLayers?.[e]!==void 0).map(n=>`${e(ln[n])} ${e(t.settingLayers[n]?`settings.plugins.layer.on`:`settings.plugins.layer.off`)}`);return(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-[#E5E7EB] px-3 py-2.5 last:border-b-0 dark:border-[#27272a]`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[12px] font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:t.name}),(0,$.jsxs)(`span`,{className:`text-[9.5px] text-[#9CA3AF]`,children:[`v`,t.version]}),(0,$.jsx)(`span`,{className:`rounded bg-[#E5E7EB] px-1.5 py-0.5 text-[9px] uppercase text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]`,children:t.source}),(0,$.jsx)(`span`,{className:`rounded bg-sky-50 px-1.5 py-0.5 text-[9px] text-sky-700 dark:bg-sky-950/40 dark:text-sky-300`,children:e(`settings.plugins.effective`,{scope:e(ln[t.effectiveScope])})})]}),(0,$.jsx)(`p`,{className:`mt-1 text-[10.5px] text-[#6B7280] dark:text-[#a1a1aa]`,children:t.description}),(0,$.jsx)(`p`,{className:`mt-1 text-[9.5px] text-[#9CA3AF]`,children:r.join(` · `)||e(`settings.plugins.noResources`)}),i.length>0&&(0,$.jsx)(`p`,{className:`mt-1 text-[9px] text-[#9CA3AF]`,children:i.join(` · `)}),t.managed&&(0,$.jsxs)(`p`,{className:`mt-1 text-[9px] text-[#9CA3AF]`,children:[e(`settings.plugins.managed`),t.marketplace?` · ${t.marketplace}`:``,t.revision?` · ${t.revision.slice(0,12)}`:``]}),!t.configurable&&(0,$.jsx)(`p`,{className:`mt-1 text-[9.5px] text-amber-600 dark:text-amber-400`,children:e(`settings.plugins.invocationScoped`)}),t.compatibilityIssues?.map(e=>(0,$.jsx)(`p`,{className:`mt-1 text-[9.5px] text-red-600 dark:text-red-400`,children:e.message},`${e.code}:${e.message}`))]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.status===`error`?e(`settings.plugins.unavailableAria`,{name:t.name}):t.enabled?e(`settings.plugins.disableAria`,{name:t.name}):e(`settings.plugins.enableAria`,{name:t.name}),"aria-checked":t.enabled,disabled:t.status===`error`||!t.configurable||n||D!==null,onClick:()=>void K(t,!t.enabled),className:T(`flex h-6 w-11 items-center rounded-full px-1 transition-colors disabled:opacity-40`,t.enabled?`bg-emerald-500`:`bg-[#E5E7EB] dark:bg-[#27272a]`),children:(0,$.jsx)(`span`,{className:T(`h-4 w-4 rounded-full bg-white transition-transform`,t.enabled?`translate-x-5`:`translate-x-0`)})}),t.managed&&(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":e(`settings.plugins.updateAria`,{name:t.name}),onClick:()=>void le(t),disabled:D!==null,className:T(`rounded px-1.5 py-1 text-[9px] disabled:opacity-40`,z===`update:${t.name}`?`bg-amber-100 text-amber-800 dark:bg-amber-950/50 dark:text-amber-300`:`text-[#6B7280] hover:bg-[#F3F4F6] dark:text-[#a1a1aa] dark:hover:bg-[#27272a]`),children:D===`update:${t.name}`?(0,$.jsx)(N,{className:`h-3 w-3 animate-spin`}):z===`update:${t.name}`?e(`settings.plugins.confirmUpdate`):e(`settings.plugins.update`)}),(0,$.jsx)(`button`,{type:`button`,"aria-label":e(`settings.plugins.uninstallAria`,{name:t.name}),onClick:()=>void ue(t),disabled:D!==null,className:T(`rounded px-1.5 py-1 text-[9px] disabled:opacity-40`,z===`uninstall:${t.name}`?`bg-red-100 text-red-700 dark:bg-red-950/50 dark:text-red-300`:`text-[#9CA3AF] hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-950/30`),children:D===`uninstall:${t.name}`?(0,$.jsx)(N,{className:`h-3 w-3 animate-spin`}):z===`uninstall:${t.name}`?e(`settings.plugins.confirmRemove`):(0,$.jsx)(te,{className:`h-3 w-3`})})]})]})]},t.name)}),!w&&oe.length===0&&!A&&(0,$.jsx)(`div`,{className:`px-3 py-8 text-center text-[11px] text-[#9CA3AF]`,children:e(`settings.plugins.empty`)})]}),(0,$.jsxs)(`div`,{className:`rounded-md border border-[#E5E7EB] dark:border-[#27272a]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-[#E5E7EB] px-3 py-2 dark:border-[#27272a]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:[(0,$.jsx)(U,{className:`h-3.5 w-3.5`}),e(`settings.plugins.marketplaces`)]}),(0,$.jsx)(`span`,{className:`text-[9px] text-[#9CA3AF]`,children:e(`settings.plugins.configuredCount`,{count:se.length})})]}),(0,$.jsxs)(`div`,{className:`flex gap-2 border-b border-[#E5E7EB] p-2 dark:border-[#27272a]`,children:[(0,$.jsx)(`input`,{"aria-label":e(`settings.plugins.marketplaceSourceAria`),value:I,onChange:e=>ee(e.target.value),placeholder:`owner/repo, HTTPS Git URL, or ./path`,disabled:D!==null,className:`field h-7 min-w-0 flex-1 px-2 text-[10px]`}),(0,$.jsxs)(`button`,{type:`button`,"aria-label":e(`settings.plugins.addMarketplaceAria`),onClick:()=>void X(),disabled:!I.trim()||D!==null,className:`inline-flex h-7 items-center gap-1 rounded-md border border-[#D1D5DB] px-2 text-[9.5px] text-[#6B7280] disabled:opacity-40 dark:border-[#3f3f46] dark:text-[#a1a1aa]`,children:[D===`marketplace:add`?(0,$.jsx)(N,{className:`h-3 w-3 animate-spin`}):(0,$.jsx)(y,{className:`h-3 w-3`}),e(`settings.plugins.add`)]})]}),se.map(t=>(0,$.jsxs)(`div`,{className:`border-b border-[#E5E7EB] px-3 py-2 last:border-b-0 dark:border-[#27272a]`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`text-[10.5px] font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:[t.name,(0,$.jsxs)(`span`,{className:`ml-2 font-normal text-[#9CA3AF]`,children:[t.sourceType,` · `,t.revision.slice(0,12)]})]}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]`,children:t.description||e(`settings.plugins.noDescription`)})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":e(`settings.plugins.refreshMarketplaceAria`,{name:t.name}),disabled:D!==null,onClick:()=>void de(t),className:`rounded p-1 text-[#9CA3AF] hover:bg-[#F3F4F6] disabled:opacity-40 dark:hover:bg-[#27272a]`,children:D===`marketplace:refresh:${t.name}`?(0,$.jsx)(N,{className:`h-3 w-3 animate-spin`}):(0,$.jsx)(ne,{className:`h-3 w-3`})}),(0,$.jsx)(`button`,{type:`button`,"aria-label":e(`settings.plugins.removeMarketplaceAria`,{name:t.name}),disabled:D!==null,onClick:()=>void fe(t),className:T(`rounded p-1 text-[#9CA3AF] disabled:opacity-40`,z===`marketplace:remove:${t.name}`?`bg-red-100 text-red-700 dark:bg-red-950/50 dark:text-red-300`:`hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-950/30`),children:z===`marketplace:remove:${t.name}`?(0,$.jsx)(`span`,{className:`px-1 text-[8.5px]`,children:e(`settings.plugins.confirm`)}):(0,$.jsx)(te,{className:`h-3 w-3`})})]})]}),(0,$.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[t.plugins.slice(0,12).map(n=>(0,$.jsxs)(`button`,{type:`button`,disabled:n.installed||D!==null,onClick:()=>{F(`${n.name}@${t.name}`),re(!1)},title:n.description,className:`rounded bg-[#F3F4F6] px-1.5 py-0.5 text-[8.5px] text-[#6B7280] disabled:opacity-40 dark:bg-[#27272a] dark:text-[#a1a1aa]`,children:[n.name,n.installed?e(`settings.plugins.installedSuffix`):``]},n.name)),t.plugins.length>12&&(0,$.jsxs)(`span`,{className:`px-1 py-0.5 text-[8.5px] text-[#9CA3AF]`,children:[`+`,t.plugins.length-12]})]})]},t.name)),!w&&se.length===0&&(0,$.jsx)(`div`,{className:`px-3 py-4 text-center text-[10px] text-[#9CA3AF]`,children:e(`settings.plugins.marketplaceEmpty`)})]})]}):(0,$.jsx)(`div`,{className:`font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]`,children:e(`settings.plugins.selectProject`)})}var dn={not_required:`settings.trust.state.notRequired`,trusted:`settings.trust.state.trusted`,untrusted:`settings.trust.state.review`,error:`settings.trust.state.error`};function fn(){let e=s(),t=R(e=>e.currentSessionRef?.projectPath),n=(0,W.useMemo)(()=>t??new URLSearchParams(window.location.search).get(`project`)??``,[t]),[r,i]=(0,W.useState)(null),[a,o]=(0,W.useState)(``),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(null),[f,m]=(0,W.useState)(null),[h,g]=(0,W.useState)(null),[_,v]=(0,W.useState)(!1),y=(0,W.useRef)(0),b=(0,W.useRef)(n);b.current=n;let S=a===n?r:null,C=(0,W.useCallback)(async()=>{let t=++y.current;if(!n){i(null),o(``),g(null);return}l(!0),g(null);try{let e=await x(`/workspace-trust?projectPath=${encodeURIComponent(n)}`);if(t!==y.current)return;i(e),o(n)}catch(n){if(t!==y.current)return;g(n instanceof Error?n.message:e(`settings.trust.loadFailed`))}finally{t===y.current&&l(!1)}},[n,e]);(0,W.useEffect)(()=>(m(null),v(!1),C(),()=>{y.current+=1}),[C]);let w=async t=>{if(!S)return;let r=n;d(t),g(null);try{let e=await x(`/workspace-trust`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({projectPath:r,action:t})});b.current===r&&(i(e),o(r),m(null),v(e.reloadRequired===!0))}catch(t){b.current===r&&g(t instanceof Error?t.message:e(`settings.trust.updateFailed`))}finally{d(null)}};if(!n)return(0,$.jsx)(`div`,{className:`font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]`,children:e(`settings.trust.selectSession`)});let E=S?.state===`trusted`,D=S?.state===`untrusted`;return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 min-h-0 font-mono`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 rounded-md border border-[#E5E7EB] bg-[#F9FAFB] p-3 dark:border-[#27272a] dark:bg-[#111113]`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[E?(0,$.jsx)(O,{className:`w-4 h-4 text-emerald-600`}):(0,$.jsx)(p,{className:T(`h-4 w-4`,D?`text-amber-600`:`text-[#71717a]`)}),(0,$.jsx)(`span`,{className:`text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:e(S?dn[S.state]:`settings.trust.heading`)}),c&&(0,$.jsx)(N,{className:`h-3.5 w-3.5 animate-spin`})]}),(0,$.jsx)(`p`,{className:`mt-1 break-all text-[10.5px] text-[#71717a]`,children:n}),S&&(0,$.jsxs)(`p`,{className:`mt-1 break-all text-[10px] text-[#9CA3AF]`,children:[S.decision,S.inheritedFrom?e(`settings.trust.inheritedFrom`,{source:S.inheritedFrom}):``]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void C(),disabled:c||u!==null,"aria-label":e(`settings.trust.reloadAria`),className:`inline-flex h-8 items-center gap-1 rounded-md border border-[#E5E7EB] px-2 text-[11px] text-[#6B7280] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#a1a1aa]`,children:[(0,$.jsx)(ne,{className:`h-3.5 w-3.5`}),e(`settings.common.reload`)]}),E?(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(`revoke`),disabled:u!==null,className:`h-8 rounded-md border border-red-200 px-2.5 text-[11px] text-red-600 disabled:opacity-50 dark:border-red-900 dark:text-red-400`,children:e(`settings.trust.revoke`)}):(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(`trust`),disabled:u!==null||S?.state===`error`||!S||S.sensitiveSources===0,className:`h-8 rounded-md bg-emerald-600 px-2.5 text-[11px] font-semibold text-white disabled:opacity-50`,children:e(`settings.trust.trustWorkspace`)})]})]}),(h||S?.error)&&(0,$.jsx)(`div`,{role:`alert`,className:`rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:h||S?.error}),_&&(0,$.jsx)(`div`,{role:`status`,className:`rounded-md border border-blue-200 bg-blue-50 px-3 py-2 text-[11px] text-blue-700 dark:border-blue-900/60 dark:bg-blue-950/30 dark:text-blue-300`,children:e(`settings.trust.restartNotice`)}),f&&S&&(0,$.jsxs)(`div`,{role:`alertdialog`,"aria-label":e(f===`trust`?`settings.trust.trustWorkspace`:`settings.trust.revokeAria`),className:`flex flex-wrap gap-3 justify-between items-center px-3 py-2 bg-amber-50 rounded-md border border-amber-300 dark:border-amber-900/70 dark:bg-amber-950/30`,children:[(0,$.jsx)(`span`,{className:`max-w-[620px] text-[11px] text-amber-900 dark:text-amber-200`,children:f===`trust`?e(`settings.trust.confirmTrust`,{count:S.sensitiveSources}):e(`settings.trust.confirmRevoke`)}),(0,$.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(null),className:`h-7 rounded px-2 text-[11px] text-[#6B7280] dark:text-[#a1a1aa]`,children:e(`settings.common.cancel`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void w(f),disabled:u!==null,className:T(`h-7 rounded px-2.5 text-[11px] font-semibold text-white disabled:opacity-50`,f===`trust`?`bg-emerald-600`:`bg-red-600`),children:e(u?`settings.trust.saving`:f===`trust`?`settings.trust.trustReviewed`:`settings.trust.revokeTrust`)})]})]}),(0,$.jsxs)(`div`,{className:`min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]`,children:[(S?.sources??[]).map(e=>(0,$.jsxs)(`div`,{className:`border-b border-[#E5E7EB] px-3 py-2 last:border-b-0 dark:border-[#27272a]`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[(0,$.jsx)(`span`,{className:`font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:e.path}),(0,$.jsx)(`span`,{className:`rounded bg-[#E5E7EB] px-1.5 py-0.5 text-[9px] uppercase text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]`,children:e.kind})]}),e.warning&&(0,$.jsx)(`p`,{className:`mt-1 text-[10px] text-amber-700 dark:text-amber-300`,children:e.warning}),(0,$.jsx)(`div`,{className:`mt-1.5 flex flex-col gap-1`,children:e.effects.map((e,t)=>(0,$.jsxs)(`div`,{className:`break-all text-[10.5px] text-[#374151] dark:text-[#d4d4d8]`,children:[(0,$.jsx)(`span`,{className:`text-[#9CA3AF]`,children:e.kind}),` · `,e.name,e.target?` → ${e.target}`:``]},`${e.kind}-${e.name}-${t}`))})]},`${e.kind}-${e.path}`)),S&&S.sources.length===0&&(0,$.jsx)(`div`,{className:`px-3 py-8 text-center text-[11px] text-[#9CA3AF]`,children:e(`settings.trust.empty`)})]})]})}var pn={anthropic:{bg:`#d97757`,label:`A`},gemini:{bg:`#4285f4`,label:`G`},"azure-openai":{bg:`#0078d4`,label:`Az`},"gpt-openai-platform":{bg:`#10a37f`,label:`GP`}},mn={searchTasks:`settings.shortcuts.action.searchTasks`,openCommands:`settings.shortcuts.action.openCommands`,newTask:`settings.shortcuts.action.newTask`,focusComposer:`settings.shortcuts.action.focusComposer`,toggleSidebar:`settings.shortcuts.action.toggleSidebar`},hn={auto:`settings.style.auto`,pragmatic:`settings.style.pragmatic`,friendly:`settings.style.friendly`,explanatory:`settings.style.explanatory`},gn={Global:`settings.shortcuts.scope.global`,Chat:`settings.shortcuts.scope.chat`,Layout:`settings.shortcuts.scope.layout`};function _n(){let e=s(),{locale:t}=u(),{isSettingsOpen:n,settingsSection:i,toggleSettings:a,isSidebarOpen:o,setSidebarOpen:c}=r(),{configuredModels:d,loadModels:p,isLoading:h,error:g}=w(),v=l(),[y,b]=(0,W.useState)(`general`),[S,C]=(0,W.useState)(!1),[E,D]=(0,W.useState)(null),[O,A]=(0,W.useState)(null),[j,M]=(0,W.useState)(null),[P,F]=(0,W.useState)([]),[L,ne]=(0,W.useState)(null),[R,z]=(0,W.useState)(null),[B,V]=(0,W.useState)(null),[ae,H]=(0,W.useState)(null),[oe,se]=(0,W.useState)({}),[U,G]=(0,W.useState)(null),[K,q]=(0,W.useState)(null),[ce,J]=(0,W.useState)(``),[Y,le]=(0,W.useState)(`all`),ue=(0,W.useRef)(null),X=(0,W.useRef)(null),de=(0,W.useRef)(0),[fe,Z]=(0,W.useState)(typeof Notification>`u`?`unsupported`:Notification.permission),pe=[{value:`general`,label:e(`settings.tab.general`),category:e(`settings.category.settings`)},{value:`trust`,label:e(`settings.tab.trust`),category:e(`settings.category.settings`)},{value:`models`,label:e(`settings.tab.models`),category:e(`settings.category.settings`)},{value:`shortcuts`,label:e(`settings.tab.shortcuts`),category:e(`settings.category.settings`)},{value:`mcp`,label:e(`settings.tab.mcp`),category:e(`settings.category.integrations`)},{value:`skills`,label:e(`settings.tab.skills`),category:e(`settings.category.integrations`)},{value:`plugins`,label:e(`settings.tab.plugins`),category:e(`settings.category.integrations`)},{value:`hooks`,label:e(`settings.tab.hooks`),category:e(`settings.category.integrations`)},{value:`schedules`,label:e(`settings.tab.schedules`),category:e(`settings.category.integrations`)}],me=(0,W.useMemo)(()=>ee.map(t=>({action:e(mn[t.id]),combo:I(t),scope:t.scope})),[t]).filter(e=>{let t=e.action.toLowerCase().includes(ce.toLowerCase()),n=Y===`all`||e.scope.toLowerCase()===Y;return t&&n}),he=d.reduce((e,t)=>{let n=t.provider||`unknown`;return e[n]||(e[n]=[]),e[n].push(t),e},{}),ge=new Map(P.map(e=>[e.id,e]));for(let e of P)e.custom&&!he[e.id]&&(he[e.id]=[]);let _e=(0,W.useCallback)(async()=>{try{F(await x(`/providers`)),H(null)}catch(t){H(t instanceof Error?t.message:e(`settings.models.loadChannelsFailed`))}},[e]);(0,W.useEffect)(()=>{n&&(b(i),p(),_e(),v.loadSettings())},[n,p,_e,v.loadSettings,i]);let ve=()=>{let e=X.current;(e?.isConnected?e:document.querySelector(`[data-settings-trigger]`))?.focus({preventScroll:!0})},Q=()=>{a(),requestAnimationFrame(ve)};(0,W.useLayoutEffect)(()=>{if(!n)return;let e=document.activeElement instanceof HTMLElement?document.activeElement:null;e&&e!==document.body&&e!==document.documentElement&&!e.closest(`[data-settings-panel]`)&&(X.current=e);let t=requestAnimationFrame(()=>{ue.current?.focus({preventScroll:!0})});return()=>{cancelAnimationFrame(t),requestAnimationFrame(ve)}},[n]);let ye=async t=>{G(`save`),q(null);try{return await x(`/models`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:t.provider,displayName:t.displayName,model:t.model,apiKey:t.apiKey,modelProvider:t.modelProvider,overrides:t.overrides})}),await p(),await _e(),!0}catch(t){return q(t instanceof Error?t.message:e(`settings.models.saveFailed`)),!1}finally{G(null)}},be=async()=>{typeof Notification<`u`&&Z(await Notification.requestPermission())},xe=async t=>{G(`delete`),q(null);try{await x(`/models/${t}`,{method:`DELETE`}),await p(),M(null)}catch(t){q(t instanceof Error?t.message:e(`settings.models.deleteFailed`))}finally{G(null)}},Se=async(t,n)=>{G(`update`),q(null);try{return await x(`/models/${t}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}),await p(),!0}catch(t){return q(t instanceof Error?t.message:e(`settings.models.updateFailed`)),!1}finally{G(null)}},Ce=async(t,n)=>{V({providerId:t,type:`update`}),H(null);try{return await x(`/providers/${t}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}),await Promise.all([p(),_e()]),!0}catch(t){return H(t instanceof Error?t.message:e(`settings.models.updateChannelFailed`)),!1}finally{V(null)}},we=async(t,n)=>{V({providerId:t.id,type:`probe`}),H(null);try{let e=await x(`/providers/${t.id}/probe`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({modelId:n})});se(n=>({...n,[t.id]:e}))}catch(t){H(t instanceof Error?t.message:e(`settings.models.probeFailed`))}finally{V(null)}},Te=async t=>{V({providerId:t.id,type:`delete`}),H(null);try{await x(`/providers/${t.id}?removeModels=true`,{method:`DELETE`}),z(null),D(null),se(e=>{let n={...e};return delete n[t.id],n}),await Promise.all([p(),_e()])}catch(t){H(t instanceof Error?t.message:e(`settings.models.deleteChannelFailed`))}finally{V(null)}},Ee=(e,t)=>{let n=e.key===`ArrowRight`||e.key===`ArrowDown`?1:e.key===`ArrowLeft`||e.key===`ArrowUp`?-1:0;if(n===0&&e.key!==`Home`&&e.key!==`End`)return;e.preventDefault();let r=e.key===`Home`?0:e.key===`End`?pe.length-1:(t+n+pe.length)%pe.length;b(pe[r].value),e.currentTarget.closest(`[role="tablist"]`)?.querySelectorAll(`[role="tab"]`)[r]?.focus()},De=e=>{D(E===e?null:e)};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{"data-settings-panel":!0,onKeyDown:e=>{if(!n||e.key!==`Escape`||!(e.target instanceof Node)||!e.currentTarget.contains(e.target)||S||O||L||Date.now()-de.current<250)return;let t=e.target instanceof Element?e.target:null;if(!(e.defaultPrevented||t?.closest(`[role="dialog"]`))){if(e.preventDefault(),j){M(null);return}if(R){z(null);return}Q()}},className:`flex h-full min-h-0 bg-white dark:bg-[#09090b]`,children:[(0,$.jsxs)(`nav`,{role:`tablist`,"aria-label":e(`settings.nav.aria`),className:`flex h-full w-[220px] shrink-0 flex-col border-r border-[#E5E7EB] bg-[#F9FAFB] dark:border-zinc-800 dark:bg-[#111113]`,children:[(0,$.jsx)(`div`,{className:`p-4 shrink-0`,children:(0,$.jsxs)(`button`,{ref:ue,type:`button`,onClick:Q,className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1.5 text-[12px] font-mono text-[#6B7280] transition-colors hover:bg-[#E5E7EB] hover:text-[#111827] dark:text-[#a1a1aa] dark:hover:bg-[#27272a] dark:hover:text-[#E5E5E5]`,children:[(0,$.jsx)(m,{className:`h-3.5 w-3.5`}),e(`settings.action.back`)]})}),(0,$.jsx)(`div`,{className:`overflow-y-auto flex-1 px-3 pb-4`,children:Object.entries(pe.reduce((e,t)=>(e[t.category]||(e[t.category]=[]),e[t.category].push(t),e),{})).map(([e,t])=>(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsx)(`div`,{className:`mb-1 px-3 text-[10px] font-semibold uppercase tracking-wider text-[#9CA3AF] dark:text-[#71717a]`,children:e}),t.map(e=>(0,$.jsx)(`button`,{onClick:()=>b(e.value),onKeyDown:t=>Ee(t,pe.indexOf(e)),role:`tab`,id:`settings-tab-${e.value}`,"aria-controls":`settings-panel-${e.value}`,"aria-selected":y===e.value,tabIndex:y===e.value?0:-1,className:T(`w-full rounded-md px-3 py-1.5 text-left text-[13px] transition-colors`,y===e.value?`bg-[#E5E7EB] font-medium text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]`:`text-[#6B7280] hover:bg-[#E5E7EB]/60 hover:text-[#111827] dark:text-[#a1a1aa] dark:hover:bg-[#27272a]/50 dark:hover:text-[#E5E5E5]`),children:e.label},e.value))]},e))})]}),(0,$.jsx)(`div`,{className:`flex overflow-hidden flex-col flex-1 min-h-0`,children:(0,$.jsx)(`div`,{className:`overflow-y-auto flex-1 p-6 sm:p-10`,children:(0,$.jsxs)(`div`,{className:`mx-auto max-w-2xl`,children:[(0,$.jsx)(`h1`,{className:`mb-6 text-xl font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:pe.find(e=>e.value===y)?.label??e(`settings.title`)}),v.isLoading&&y===`general`&&(0,$.jsxs)(`div`,{role:`status`,className:`flex shrink-0 items-center gap-2 text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:[(0,$.jsx)(N,{className:`h-3.5 w-3.5 animate-spin`}),e(`settings.general.loading`)]}),v.error&&y===`general`&&(0,$.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:[(0,$.jsx)(k,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1 min-w-0`,children:v.error}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void v.loadSettings(),className:`underline shrink-0`,children:e(`settings.common.retry`)})]}),y===`models`&&(0,$.jsxs)(`div`,{id:`settings-panel-models`,role:`tabpanel`,"aria-labelledby":`settings-tab-models`,className:`flex overflow-hidden flex-col flex-1 gap-6 min-h-0`,children:[(0,$.jsx)(`p`,{className:`text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono shrink-0`,children:e(`settings.models.description`)}),(g||K||ae)&&(0,$.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:[(0,$.jsx)(k,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1 min-w-0`,children:ae||K||g}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{q(null),H(null),g&&p()},className:`underline shrink-0`,children:e(g?`settings.common.retry`:`settings.common.dismiss`)})]}),j&&(0,$.jsxs)(`div`,{role:`alertdialog`,"aria-label":e(`settings.models.deleteModelAria`,{name:j.displayName||j.model}),className:`flex flex-wrap gap-2 justify-between items-center px-3 py-2 bg-red-50 rounded-md border border-red-200 dark:border-red-900/60 dark:bg-red-950/30`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-mono text-red-700 dark:text-red-300`,children:e(`settings.models.deleteModelPrompt`,{name:j.displayName||j.model})}),(0,$.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>M(null),className:`h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]`,children:e(`settings.common.cancel`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void xe(j.id),disabled:U!==null,className:`h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60`,children:e(U===`delete`?`settings.models.deleting`:`settings.models.deleteModel`)})]})]}),R&&(0,$.jsxs)(`div`,{role:`alertdialog`,"aria-label":e(`settings.models.deleteChannelAria`,{name:R.name}),className:`flex flex-wrap gap-2 justify-between items-center px-3 py-2 bg-red-50 rounded-md border border-red-200 dark:border-red-900/60 dark:bg-red-950/30`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-mono text-red-700 dark:text-red-300`,children:e(`settings.models.deleteChannelPrompt`,{name:R.name,count:he[R.id]?.length??0})}),(0,$.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>z(null),className:`h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]`,children:e(`settings.common.cancel`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void Te(R),disabled:B!==null,className:`h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60`,children:B?.type===`delete`?e(`settings.models.deleting`):e(`settings.models.deleteChannel`)})]})]}),(0,$.jsx)(`div`,{className:`overflow-y-auto flex-1 min-h-0`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 pr-2`,children:[h&&d.length===0&&(0,$.jsxs)(`div`,{role:`status`,className:`flex items-center justify-center gap-2 py-8 text-sm font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:[(0,$.jsx)(N,{className:`w-4 h-4 animate-spin`}),e(`settings.models.loading`)]}),Object.entries(he).map(([t,n])=>{let r=pn[t]||{bg:`#71717a`,label:`?`},i=ge.get(t),a=E===t,o=oe[t],s=B?.providerId===t&&B.type===`probe`;return(0,$.jsxs)(`div`,{className:`w-full bg-[#F3F4F6] dark:bg-[#18181b] rounded-lg overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsxs)(`button`,{onClick:()=>De(t),className:`flex min-w-0 flex-1 items-center justify-between p-4 text-left transition-colors hover:bg-[#E5E7EB] dark:hover:bg-[#1f1f23]`,children:[(0,$.jsxs)(`div`,{className:`flex gap-3 items-center min-w-0`,children:[(0,$.jsx)(`div`,{className:`flex justify-center items-center w-8 h-8 text-xs font-bold text-white rounded shrink-0`,style:{backgroundColor:r.bg},children:r.label}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5 text-left`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-semibold font-mono text-[#111827] dark:text-[#E5E5E5]`,children:i?.name??t.replace(/-/g,` `)}),(0,$.jsxs)(`span`,{className:`truncate text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:[n.length===1?e(`settings.models.modelCountOne`,{count:n.length}):e(`settings.models.modelCountMany`,{count:n.length}),i?.custom?` · ${i.wireApi}`:``]})]})]}),(0,$.jsxs)(`div`,{className:`flex gap-3 items-center shrink-0`,children:[(0,$.jsxs)(`span`,{className:T(`text-xs font-mono`,i?.configured===!1?`text-amber-600`:`text-[#16A34A]`),children:[`●`,` `,i?.configured===!1?e(`settings.models.missingCredential`):e(`settings.models.configured`)]}),(0,$.jsx)(re,{className:T(`h-4 w-4 text-[#9CA3AF] transition-transform dark:text-[#71717a]`,a&&`rotate-180`)})]})]}),i?.custom&&(0,$.jsxs)(`div`,{className:`flex gap-1 items-center pr-3 shrink-0`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void we(i,n[0]?.id),disabled:B!==null||n.length===0,"aria-label":e(`settings.models.testChannelAria`,{name:i.name}),className:`rounded p-1.5 text-[#71717a] hover:bg-[#E5E7EB] hover:text-[#111827] disabled:opacity-50 dark:hover:bg-[#27272a] dark:hover:text-[#E5E5E5]`,children:s?(0,$.jsx)(N,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(f,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`button`,{type:`button`,"data-edit-provider-trigger":i.id,onClick:()=>{H(null),ne(i)},disabled:B!==null,"aria-label":e(`settings.models.editChannelAria`,{name:i.name}),className:`rounded p-1.5 text-[#71717a] hover:bg-[#E5E7EB] hover:text-[#111827] disabled:opacity-50 dark:hover:bg-[#27272a] dark:hover:text-[#E5E5E5]`,children:(0,$.jsx)(_,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>z(i),disabled:B!==null,"aria-label":e(`settings.models.deleteChannelActionAria`,{name:i.name}),className:`rounded p-1.5 text-[#71717a] hover:bg-[#E5E7EB] hover:text-red-500 disabled:opacity-50 dark:hover:bg-[#27272a] dark:hover:text-red-400`,children:(0,$.jsx)(te,{className:`h-3.5 w-3.5`})})]})]}),o&&(0,$.jsxs)(`div`,{role:`status`,className:T(`border-t px-4 py-2 font-mono text-[11px]`,o.ok?`border-green-200 bg-green-50 text-green-700 dark:border-green-900/60 dark:bg-green-950/20 dark:text-green-300`:`border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/20 dark:text-amber-300`),children:[o.message,` · `,o.latencyMs,`ms · `,o.wireApi]}),a&&(0,$.jsxs)(`div`,{className:`border-t border-[#E5E7EB] dark:border-zinc-800`,children:[i?.custom&&(0,$.jsxs)(`div`,{className:`border-b border-[#E5E7EB] px-4 py-2 font-mono text-[11px] text-[#71717a] dark:border-zinc-800`,children:[(0,$.jsx)(`span`,{className:`font-semibold`,children:i.id}),` `,`· `,i.defaultBaseUrl]}),n.map(t=>(0,$.jsxs)(`div`,{className:`px-4 py-3 flex items-center justify-between hover:bg-[#E5E7EB] dark:hover:bg-[#1f1f23] group`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5 flex-1 min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-sm text-[#111827] dark:text-[#E5E5E5] font-mono truncate`,children:t.displayName||t.model}),(0,$.jsxs)(`span`,{className:`text-xs text-[#9CA3AF] dark:text-[#71717a] font-mono truncate`,children:[t.displayName&&`${t.model} · `,t.overrides?.baseUrl||e(`settings.models.defaultEndpoint`)]})]}),(0,$.jsxs)(`div`,{className:`flex gap-2 items-center opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100`,children:[(0,$.jsx)(`button`,{"data-edit-model-trigger":t.id,onClick:()=>{q(null),A(t)},disabled:U!==null,"aria-label":e(`settings.models.editModelAria`,{name:t.displayName||t.model}),className:`p-1.5 text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] rounded transition-colors`,children:(0,$.jsx)(_,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`button`,{onClick:()=>M(t),disabled:U!==null,"aria-label":e(`settings.models.deleteModelAria`,{name:t.displayName||t.model}),className:`p-1.5 text-[#9CA3AF] hover:text-red-500 hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-red-400 dark:hover:bg-[#27272a] rounded transition-colors`,children:(0,$.jsx)(te,{className:`h-3.5 w-3.5`})})]})]},t.id))]})]},t)}),!h&&!g&&Object.keys(he).length===0&&(0,$.jsx)(`div`,{className:`text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono`,children:e(`settings.models.empty`)})]})}),(0,$.jsx)(`button`,{"data-add-model-trigger":!0,onClick:()=>{q(null),C(!0)},disabled:U!==null,className:`w-full py-3 rounded-md text-[#6B7280] dark:text-[#a1a1aa] text-[13px] font-mono hover:bg-[#F3F4F6] dark:bg-[#18181b] transition-colors shrink-0`,children:e(`settings.models.add`)})]}),y===`general`&&(0,$.jsxs)(`div`,{id:`settings-panel-general`,role:`tabpanel`,"aria-labelledby":`settings-tab-general`,"aria-busy":v.isLoading,className:`flex flex-col gap-6 overflow-x-hidden overflow-y-auto pr-2 [&>div>div.flex]:flex-wrap [&>div>div.flex]:gap-2 [&_select]:max-w-full`,children:[(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`h3`,{className:`text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold`,children:e(`settings.tab.general`)}),(0,$.jsxs)(`div`,{className:`flex justify-between items-center py-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono`,children:e(`settings.general.responseLanguage`)}),(0,$.jsx)(`span`,{className:`text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono`,children:e(`settings.general.responseLanguageHint`)})]}),(0,$.jsx)(Ft,{"aria-label":e(`settings.general.responseLanguage`),value:v.language,onChange:e=>v.updateSettings({language:e}),className:`h-8 w-auto min-w-[140px] text-[12px]`,options:[{value:`en-US`,label:`English (US)`},{value:`zh-CN`,label:`简体中文`},{value:`zh-TW`,label:`繁體中文`},{value:`ja-JP`,label:`日本語`},{value:`ko-KR`,label:`한국어`},{value:`es-ES`,label:`Español`},{value:`fr-FR`,label:`Français`},{value:`de-DE`,label:`Deutsch`},{value:`pt-BR`,label:`Português (BR)`},{value:`ru-RU`,label:`Русский`}]})]}),(0,$.jsxs)(`div`,{className:`flex justify-between items-center py-2`,children:[(0,$.jsx)(`span`,{className:`text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono`,children:e(`settings.general.autoSave`)}),(0,$.jsx)(vn,{label:e(`settings.general.autoSave`),enabled:v.autoSaveSessions,onChange:e=>v.updateSettings({autoSaveSessions:e})})]}),(0,$.jsxs)(`div`,{className:`flex justify-between items-center gap-4 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono`,children:ie(t,`settingsTitle`)}),(0,$.jsx)(`span`,{className:`text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono`,children:ie(t,`settingsHint`)})]}),(0,$.jsx)(vn,{label:ie(t,`settingsTitle`),enabled:v.agentTeamsEnabled,onChange:e=>v.updateSettings({agentTeamsEnabled:e})})]}),(0,$.jsxs)(`div`,{className:`flex justify-between items-center py-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono`,children:e(`settings.general.communicationStyle`)}),(0,$.jsx)(`span`,{className:`text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono`,children:e(`settings.general.communicationStyleHint`)})]}),(0,$.jsx)(Ft,{"aria-label":e(`settings.general.communicationStyle`),value:v.communicationStyle??`auto`,onChange:e=>v.updateSettings({communicationStyle:e}),className:`h-8 w-auto min-w-[140px] text-[12px]`,options:$t.map(t=>({value:t.id,label:hn[t.id]?e(hn[t.id]):t.name}))})]})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`h3`,{className:`text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold`,children:e(`settings.appearance.heading`)}),(0,$.jsxs)(`div`,{className:`flex justify-between items-center py-2`,children:[(0,$.jsx)(`span`,{className:`text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono`,children:e(`settings.appearance.theme`)}),(0,$.jsx)(`div`,{className:`flex items-center gap-2 bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md p-1`,children:[`dark`,`light`,`system`].map(t=>(0,$.jsx)(`button`,{onClick:()=>v.updateSettings({uiTheme:t}),className:T(`px-3 py-1 rounded text-[12px] font-mono transition-colors`,v.uiTheme===t?`bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5]`:`text-[#9CA3AF] dark:text-[#71717a] hover:text-[#111827] dark:hover:text-[#E5E5E5]`),children:e(t===`dark`?`settings.appearance.theme.dark`:t===`light`?`settings.appearance.theme.light`:`settings.appearance.theme.system`)},t))})]}),(0,$.jsxs)(`div`,{className:`flex justify-between items-center py-2`,children:[(0,$.jsx)(`span`,{className:`text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono`,children:e(`settings.appearance.compactSidebar`)}),(0,$.jsx)(vn,{label:e(`settings.appearance.compactSidebar`),enabled:!o,onChange:e=>c(!e)})]}),(0,$.jsxs)(`div`,{className:`flex justify-between items-center py-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono`,children:e(`settings.appearance.codeTheme`)}),(0,$.jsx)(`span`,{className:`text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono`,children:e(`settings.appearance.codeThemeHint`)})]}),(0,$.jsx)(Ft,{"aria-label":e(`settings.appearance.codeTheme`),value:v.codeTheme,onChange:e=>v.updateSettings({codeTheme:e}),className:`h-8 w-auto min-w-[140px] text-[12px]`,options:[{value:`dracula`,label:`Dracula`},{value:`monokai`,label:`Monokai`},{value:`nord`,label:`Nord`},{value:`tokyo-night`,label:`Tokyo Night`},{value:`one-dark`,label:`One Dark`},{value:`catppuccin`,label:`Catppuccin`},{value:`gruvbox`,label:`Gruvbox`},{value:`github`,label:`GitHub`},{value:`solarized-light`,label:`Solarized Light`},{value:`solarized-dark`,label:`Solarized Dark`},{value:`ayu-dark`,label:`Ayu Dark`},{value:`rose-pine`,label:`Rose Pine`},{value:`kanagawa`,label:`Kanagawa`}]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`h3`,{className:`text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold`,children:e(`settings.notifications.heading`)}),(0,$.jsxs)(`div`,{className:`flex justify-between items-center py-2`,children:[(0,$.jsx)(`span`,{className:`text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono`,children:e(`settings.notifications.buildFinished`)}),(0,$.jsx)(vn,{label:e(`settings.notifications.buildFinished`),enabled:v.notifyBuild,onChange:e=>v.updateSettings({notifyBuild:e})})]}),(0,$.jsxs)(`div`,{className:`flex justify-between items-center py-2`,children:[(0,$.jsx)(`span`,{className:`text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono`,children:e(`settings.notifications.errorsOnly`)}),(0,$.jsx)(vn,{label:e(`settings.notifications.errorsOnly`),enabled:v.notifyErrors,onChange:e=>v.updateSettings({notifyErrors:e})})]}),(0,$.jsxs)(`div`,{className:`flex justify-between items-center py-2`,children:[(0,$.jsx)(`span`,{className:`text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono`,children:e(`settings.notifications.systemSounds`)}),(0,$.jsx)(vn,{label:e(`settings.notifications.systemSounds`),enabled:v.notifySounds,onChange:e=>v.updateSettings({notifySounds:e})})]}),(v.notifyBuild||v.notifyErrors)&&fe!==`granted`&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4 rounded-md border border-[#E5E7EB] bg-[#F9FAFB] px-3 py-2 dark:border-[#27272a] dark:bg-[#18181b]`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]`,children:e(fe===`denied`?`settings.notifications.blocked`:fe===`unsupported`?`settings.notifications.unavailable`:`settings.notifications.enablePrompt`)}),fe==="default"&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>void be(),className:`shrink-0 rounded-md bg-[#111827] px-2.5 py-1.5 text-[10px] font-mono text-white hover:bg-[#374151] dark:bg-[#E5E5E5] dark:text-[#111827]`,children:e(`settings.common.enable`)})]})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`h3`,{className:`text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold`,children:e(`settings.privacy.heading`)}),(0,$.jsxs)(`div`,{className:`flex justify-between items-center py-2`,children:[(0,$.jsx)(`span`,{className:`text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono`,children:e(`settings.privacy.telemetry`)}),(0,$.jsx)(vn,{label:e(`settings.privacy.telemetry`),enabled:v.privacyTelemetry,onChange:e=>v.updateSettings({privacyTelemetry:e})})]}),(0,$.jsxs)(`div`,{className:`flex justify-between items-center py-2`,children:[(0,$.jsx)(`span`,{className:`text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono`,children:e(`settings.privacy.crash`)}),(0,$.jsx)(vn,{label:e(`settings.privacy.crash`),enabled:v.privacyCrash,onChange:e=>v.updateSettings({privacyCrash:e})})]})]})]}),y===`shortcuts`&&(0,$.jsxs)(`div`,{id:`settings-panel-shortcuts`,role:`tabpanel`,"aria-labelledby":`settings-tab-shortcuts`,className:`flex overflow-hidden flex-col flex-1 gap-4 min-h-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 shrink-0 sm:flex-row sm:items-center sm:gap-3`,children:[(0,$.jsx)(`input`,{"aria-label":e(`settings.shortcuts.searchPlaceholder`),value:ce,onChange:e=>J(e.target.value),placeholder:e(`settings.shortcuts.searchPlaceholder`),className:`field flex-1 text-[12px]`}),(0,$.jsx)(Ft,{"aria-label":e(`settings.shortcuts.col.scope`),value:Y,onChange:e=>le(e),className:`w-auto min-w-[120px] text-[12px]`,options:[{value:`all`,label:e(`settings.shortcuts.scope.all`)},{value:`global`,label:e(`settings.shortcuts.scope.global`)},{value:`chat`,label:e(`settings.shortcuts.scope.chat`)},{value:`layout`,label:e(`settings.shortcuts.scope.layout`)}]}),(0,$.jsx)(`button`,{onClick:()=>{J(``),le(`all`)},className:`h-9 px-3 rounded-md bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono font-semibold`,children:e(`settings.shortcuts.reset`)})]}),(0,$.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-auto border border-[#E5E7EB] dark:border-[#27272a] rounded-lg bg-[#E5E7EB] dark:bg-[#111827]`,children:[(0,$.jsxs)(`div`,{className:`grid min-w-[520px] grid-cols-[1fr_180px_120px] gap-2 px-3 py-2 bg-white dark:bg-[#0C0C0C] text-[12px] text-[#6B7280] dark:text-[#94a3b8] font-mono font-semibold`,children:[(0,$.jsx)(`span`,{children:e(`settings.shortcuts.col.action`)}),(0,$.jsx)(`span`,{children:e(`settings.shortcuts.col.shortcut`)}),(0,$.jsx)(`span`,{children:e(`settings.shortcuts.col.scope`)})]}),me.map((t,n)=>(0,$.jsxs)(`div`,{className:T(`grid min-w-[520px] grid-cols-[1fr_180px_120px] gap-2 px-3 py-2 text-[13px] font-mono`,n%2==0?`bg-[#E5E7EB] dark:bg-[#111827]`:`bg-white dark:bg-[#0C0C0C]`),children:[(0,$.jsx)(`span`,{className:`text-[#111827] dark:text-[#E5E5E5]`,children:t.action}),(0,$.jsx)(`div`,{className:`flex gap-1 items-center`,children:t.combo.map(e=>(0,$.jsx)(`span`,{className:`px-2 py-0.5 rounded bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono font-semibold`,children:e},e))}),(0,$.jsx)(`span`,{className:`text-[#6B7280] dark:text-[#94a3b8] text-[12px]`,children:gn[t.scope]?e(gn[t.scope]):t.scope})]},`${t.action}-${t.scope}`)),me.length===0&&(0,$.jsx)(`div`,{className:`px-3 py-6 text-center text-[12px] text-[#6B7280] dark:text-[#94a3b8] font-mono`,children:e(`settings.shortcuts.empty`)})]})]}),y===`mcp`&&(0,$.jsx)(`div`,{id:`settings-panel-mcp`,role:`tabpanel`,"aria-labelledby":`settings-tab-mcp`,className:`flex-1 min-h-0`,children:(0,$.jsx)(At,{active:y===`mcp`})}),y===`skills`&&(0,$.jsx)(`div`,{id:`settings-panel-skills`,role:`tabpanel`,"aria-labelledby":`settings-tab-skills`,className:`flex-1 min-h-0`,children:(0,$.jsx)(Yt,{active:y===`skills`})}),y===`hooks`&&(0,$.jsx)(`div`,{id:`settings-panel-hooks`,role:`tabpanel`,"aria-labelledby":`settings-tab-hooks`,className:`flex-1 min-h-0`,children:(0,$.jsx)(on,{})}),y===`plugins`&&(0,$.jsx)(`div`,{id:`settings-panel-plugins`,role:`tabpanel`,"aria-labelledby":`settings-tab-plugins`,className:`flex-1 min-h-0`,children:(0,$.jsx)(un,{})}),y===`schedules`&&(0,$.jsx)(`div`,{id:`settings-panel-schedules`,role:`tabpanel`,"aria-labelledby":`settings-tab-schedules`,className:`flex-1 min-h-0`,children:(0,$.jsx)(Wt,{active:y===`schedules`})}),y===`trust`&&(0,$.jsx)(`div`,{id:`settings-panel-trust`,role:`tabpanel`,"aria-labelledby":`settings-tab-trust`,className:`flex-1 min-h-0`,children:(0,$.jsx)(fn,{})})]})})})]}),S&&(0,$.jsx)(tn,{open:!0,onOpenChange:e=>{e||(de.current=Date.now()),C(e)},onSave:ye,saveError:K}),O&&(0,$.jsx)(nn,{open:!0,onOpenChange:e=>{e||(de.current=Date.now(),A(null))},model:O,onSave:Se,saveError:K}),L&&(0,$.jsx)(rn,{provider:L,onOpenChange:e=>{e||(de.current=Date.now(),ne(null))},onSave:Ce,saveError:ae})]})}function vn({label:e,enabled:t,onChange:n}){return(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":e,"aria-checked":t,onClick:()=>n(!t),className:T(`flex h-6 w-11 items-center rounded-full px-1 transition-colors`,t?`bg-[#22C55E]`:`bg-[#E5E7EB] dark:bg-[#27272a]`),children:(0,$.jsx)(`span`,{className:T(`h-4 w-4 rounded-full transition-transform`,t?`translate-x-5 bg-white`:`translate-x-0 bg-white dark:bg-[#a1a1aa]`)})})}export{_n as SettingsModal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,dt as n,i as r,u as i}from"./session-events-B-hnDC4L.js";import{C as a}from"./vendor-radix-BCAvgfOW.js";import{c as o,i as s,l as c,s as l}from"./preload-helper-HI3NtP3B.js";import{t as u}from"./archive-D3alcPOa.js";import{t as d}from"./chevron-right-B8JH5N50.js";import{t as f}from"./download-DxK6pukC.js";import{t as p}from"./pencil-CMjIwtk5.js";import{t as m}from"./plus-BJIEQjD7.js";import{t as h}from"./settings-CP6ArjQ7.js";import{t as g}from"./terminal-BYHhWXe-.js";import{$ as _,A as v,C as y,J as b,M as x,O as S,P as C,U as w,W as ee,Y as T,_t as te,ct as E,d as D,dt as ne,f as O,h as k,i as re,j as A,k as ie,n as j,p as M,pt as N,q as ae,r as P,rt as oe,s as se,t as F,tt as I,w as ce,x as le,y as L,yt as R}from"./index-DkwePtIh.js";import{t as ue}from"./ScrollArea-CSCl8r35.js";var de={name:`archive-restore`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]};de.node;var z=c(de),B={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};B.node;var fe=c(B),V={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};V.node;var pe=c(V),H={name:`git-fork`,size:24,node:[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]};H.node;var me=c(H),U={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};U.node;var he=c(U),ge={name:`layout-dashboard`,size:24,node:[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]};ge.node;var _e=c(ge),W=e(n(),1);async function ve(e,t=!1){let n=await C.exportSessionMarkdown(e,t),r=new Blob([n.markdown],{type:`text/markdown;charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=n.filename,a.hidden=!0,document.body.appendChild(a);try{a.click()}finally{a.remove(),await new Promise(e=>{window.setTimeout(()=>{URL.revokeObjectURL(i),e()},0)})}return n}var G=a();function ye(){let e=o(),n=L(e=>e.archivedSessions),r=L(e=>e.archivedCatalogLoadState),a=L(e=>e.archivedCatalogError),s=L(e=>e.loadArchivedSessions),c=L(e=>e.unarchiveSession),l=L(e=>e.setError),d=L(e=>i(e.historySurfaceSelection)),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(null),[_,y]=(0,W.useState)(null),b=e=>{e&&t(L.getState())||(m(e),e&&s())},x=()=>{t(L.getState())||s()};return d?null:(0,G.jsxs)(D,{open:p,onOpenChange:b,children:[(0,G.jsx)(M,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,className:`flex h-8 w-full items-center justify-between rounded-md px-2.5 font-mono text-[12.5px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]`,"aria-label":e(`archive.open`),children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[(0,G.jsx)(u,{className:`h-3.5 w-3.5 text-[hsl(var(--deck-ink-faint))]`}),e(`archive.title`)]}),n.length>0&&(0,G.jsx)(`span`,{className:`rounded-sm bg-[hsl(var(--deck-surface))] px-1.5 py-0.5 text-[9px] text-[hsl(var(--deck-ink-faint))]`,children:n.length})]})}),(0,G.jsxs)(O,{role:`dialog`,"aria-label":e(`archive.title`),side:`right`,align:`end`,sideOffset:8,className:`w-[340px] overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex h-10 items-center justify-between border-b border-[hsl(var(--deck-hairline))] px-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`font-mono text-[11px] font-medium uppercase tracking-[0.08em] text-[hsl(var(--deck-ink))]`,children:e(`archive.title`)}),(0,G.jsx)(`div`,{className:`text-[9.5px] text-[hsl(var(--deck-ink-faint))]`,children:e(`archive.subtitle`)})]}),(0,G.jsx)(`button`,{type:`button`,onClick:x,"aria-label":e(`archive.refresh`),className:`flex h-6 w-6 items-center justify-center rounded text-[hsl(var(--deck-ink-faint))] hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]`,children:(0,G.jsx)(oe,{className:w(`h-3 w-3`,(r===`loading`||r===`hydrating`)&&`animate-spin`)})})]}),a?(0,G.jsxs)(`div`,{className:`px-3 py-4 text-[11px] text-red-600 dark:text-red-400`,children:[(0,G.jsx)(`div`,{children:a}),(0,G.jsx)(`button`,{type:`button`,onClick:x,className:`mt-2 font-mono text-[10px] text-[hsl(var(--deck-accent))] focus-visible:outline-none focus-visible:underline`,children:e(`archive.retry`)})]}):n.length===0&&(r===`loading`||r===`hydrating`)?(0,G.jsxs)(`div`,{className:`flex h-24 items-center justify-center gap-2 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]`,children:[(0,G.jsx)(E,{className:`h-3 w-3 animate-spin`}),e(`archive.loading`)]}):n.length===0?(0,G.jsx)(`div`,{className:`flex h-24 items-center justify-center px-6 text-center text-[10.5px] text-[hsl(var(--deck-ink-faint))]`,children:e(`archive.empty`)}):(0,G.jsx)(ue,{className:`max-h-[340px]`,children:(0,G.jsx)(`div`,{className:`divide-y divide-[hsl(var(--deck-hairline))]`,children:n.map(n=>{let r=v(n),i=A(r),a=h===i,o=n.projectPath.split(`/`).filter(Boolean).at(-1)??n.projectPath;return(0,G.jsxs)(`div`,{className:`flex min-h-[58px] items-center gap-2 px-3 py-2`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate font-mono text-[11.5px] text-[hsl(var(--deck-ink))]`,children:P(n,e)}),(0,G.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1.5 truncate font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]`,children:[(0,G.jsx)(`span`,{className:`truncate`,children:o}),n.archivedAt&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,G.jsx)(`span`,{children:new Date(n.archivedAt).toLocaleString()})]})]}),n.archivedBySessionId!==n.sessionId&&(0,G.jsx)(`div`,{className:`mt-0.5 truncate text-[9px] text-[hsl(var(--deck-accent))]`,children:e(`archive.inherited`,{id:n.archivedBySessionId?.slice(0,8)??``})})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,G.jsx)(`button`,{type:`button`,disabled:_!==null,onClick:async()=>{if(!t(L.getState())){y(i);try{await ve(r)}catch(e){l(e instanceof Error?e.message:`Session export failed`)}finally{y(null)}}},"aria-label":e(`session.action.export`,{title:P(n,e)}),title:e(`session.action.exportShort`),className:`flex h-7 w-7 items-center justify-center rounded text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] disabled:cursor-wait disabled:opacity-35`,children:_===i?(0,G.jsx)(E,{className:`h-3.5 w-3.5 animate-spin`}):(0,G.jsx)(f,{className:`h-3.5 w-3.5`})}),(0,G.jsx)(`button`,{type:`button`,disabled:a||n.archivedBySessionId!==n.sessionId,onClick:async()=>{if(!t(L.getState())){g(i);try{await c(r)}finally{g(null)}}},"aria-label":e(`archive.restore`,{title:P(n,e)}),title:n.archivedBySessionId===n.sessionId?e(`archive.restoreShort`):e(`archive.restoreAncestor`),className:`flex h-7 w-7 items-center justify-center rounded text-[hsl(var(--deck-accent))] transition-colors hover:bg-[hsl(var(--deck-accent-soft))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] disabled:cursor-not-allowed disabled:opacity-35`,children:a?(0,G.jsx)(E,{className:`h-3.5 w-3.5 animate-spin`}):(0,G.jsx)(z,{className:`h-3.5 w-3.5`})})]})]},i)})})})]})]})}var be={en:`sidebar.language.en`,zh:`sidebar.language.zh`};function xe({className:e,variant:t=`pill`}){let{locale:n,setLocale:r}=l(),i=o();if(t===`compact`){let t=n===`en`?`zh`:`en`;return(0,G.jsx)(`button`,{type:`button`,onClick:()=>r(t),"aria-label":i(`sidebar.language.aria`),title:i(`sidebar.language.label`),className:w(`flex justify-center items-center w-10 h-10 font-mono font-medium rounded-md transition-colors text-[11px] text-[hsl(var(--deck-ink-faint))] hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))]`,e),children:i(be[n])})}return(0,G.jsx)(`div`,{role:`group`,"aria-label":i(`sidebar.language.aria`),className:w(`inline-flex h-8 items-center rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] p-[2px] font-mono text-[11px]`,e),children:s.map(e=>{let t=e===n;return(0,G.jsx)(`button`,{type:`button`,onClick:()=>r(e),"aria-pressed":t,className:w(`flex justify-center items-center px-2 h-full transition-colors min-w-[28px] rounded-[4px]`,t?`bg-[hsl(var(--deck-ink))] text-[hsl(var(--deck-canvas))]`:`text-[hsl(var(--deck-ink-muted))] hover:text-[hsl(var(--deck-ink))]`),children:i(be[e])},e)})})}function Se({summary:e,isActive:t,onSelect:n}){let r=o(),i=e.title??e.locator.sessionId,a=r(e.capabilities.connection===`offline`?`history.connection.offline`:e.capabilities.connection===`local`?`history.connection.local`:`history.connection.online`);return(0,G.jsxs)(`div`,{className:w(`flex relative items-center w-full transition-colors min-h-[54px]`,t?`bg-[hsl(var(--deck-surface))]`:`hover:bg-[hsl(var(--deck-surface))]/60`),children:[t&&(0,G.jsx)(`span`,{className:`absolute left-0 top-1/2 h-6 w-[2px] -translate-y-1/2 rounded-r bg-[hsl(var(--deck-accent))]`}),(0,G.jsxs)(`button`,{type:`button`,"aria-label":r(`session.action.select`,{title:i}),"aria-current":t?`true`:void 0,onClick:n,className:`flex min-h-[54px] min-w-0 flex-1 cursor-pointer items-center gap-2 py-1.5 pl-4 pr-2 text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-[hsl(var(--deck-accent))]`,children:[(0,G.jsx)(`span`,{className:w(`h-1.5 w-1.5 shrink-0 rounded-full`,e.capabilities.connection===`offline`?`bg-amber-500`:`bg-blue-500 shadow-[0_0_5px_rgba(59,130,246,0.7)]`),title:a}),(0,G.jsxs)(`span`,{className:`flex-1 min-w-0 font-mono`,children:[(0,G.jsxs)(`span`,{className:w(`flex gap-2 items-center text-left truncate text-[12px]`,t?`text-[hsl(var(--deck-ink))]`:`text-[hsl(var(--deck-ink-muted))]`),children:[(0,G.jsx)(`span`,{className:`truncate`,children:i}),(0,G.jsx)(`span`,{className:`inline-flex shrink-0 items-center rounded border border-[hsl(var(--deck-border))] px-1.5 py-0.5 text-[8.5px] text-[hsl(var(--deck-ink-faint))]`,children:r(`history.badge.remote`)}),(0,G.jsx)(`span`,{className:`inline-flex shrink-0 items-center rounded border border-[hsl(var(--deck-border))] px-1.5 py-0.5 text-[8.5px] text-[hsl(var(--deck-ink-faint))]`,children:a}),(0,G.jsx)(`span`,{className:`inline-flex shrink-0 items-center rounded bg-[hsl(var(--deck-accent-soft))] px-1.5 py-0.5 text-[8.5px] text-[hsl(var(--deck-accent))]`,children:r(`history.badge.historyOnly`)})]}),(0,G.jsx)(`span`,{className:`mt-0.5 block truncate text-[9.5px] text-[hsl(var(--deck-ink-faint))]`,children:e.displayCwd})]})]})]})}var Ce={running:`bg-blue-500 dark:bg-blue-400 shadow-[0_0_5px_rgba(59,130,246,0.7)] animate-pulse`,queued:`bg-amber-400 dark:bg-amber-300`,interrupted:`bg-orange-500 dark:bg-orange-400`,failed:`bg-red-500 dark:bg-red-400`,cancelled:`bg-zinc-400 dark:bg-zinc-500`,completed:`bg-[hsl(var(--deck-accent))]`};function we({session:e,isActive:t,isForking:n,isUnread:r,anyForking:i,isEditing:a,editingTitle:s,title:c,context:l,isCancelling:d,isRetrying:m,isExporting:h,onSelect:g,onCancelTask:_,onRetryTask:v,onFork:y,onArchive:x,onExport:S,onStartRename:C,onDelete:T,onEditingTitleChange:ne,onSaveRename:k,onCancelRename:re}){let A=o(),[ie,j]=(0,W.useState)(!1),N=(0,W.useRef)(null),P=(0,W.useRef)(null);return a?(0,G.jsxs)(`div`,{className:`flex h-9 w-full items-center gap-2 bg-[hsl(var(--deck-surface))] px-3`,children:[(0,G.jsx)(`input`,{type:`text`,value:s,onChange:e=>ne(e.target.value),onKeyDown:e=>{e.key===`Enter`&&k(),e.key===`Escape`&&re()},autoFocus:!0,className:`flex-1 rounded bg-[hsl(var(--deck-canvas))] px-2 py-1 font-mono text-[13px] text-[hsl(var(--deck-ink))] outline-none focus:ring-1 focus:ring-[hsl(var(--deck-accent))]`}),(0,G.jsx)(`button`,{"aria-label":A(`session.action.save`,{title:c}),onClick:k,className:`flex h-6 w-6 items-center justify-center rounded text-[hsl(var(--deck-accent))] hover:bg-[hsl(var(--deck-canvas))]`,children:(0,G.jsx)(R,{className:`w-3 h-3`})}),(0,G.jsx)(`button`,{"aria-label":A(`session.action.cancel`,{title:c}),onClick:re,className:`flex h-6 w-6 items-center justify-center rounded text-[hsl(var(--deck-ink-faint))] hover:bg-[hsl(var(--deck-canvas))]`,children:(0,G.jsx)(ee,{className:`w-3 h-3`})})]}):(0,G.jsxs)(`div`,{className:w(`flex relative items-center w-full transition-colors group min-h-[54px]`,t?`bg-[hsl(var(--deck-surface))]`:`hover:bg-[hsl(var(--deck-surface))]/60`),children:[t&&(0,G.jsx)(`span`,{className:`absolute left-0 top-1/2 h-6 w-[2px] -translate-y-1/2 rounded-r bg-[hsl(var(--deck-accent))]`}),(0,G.jsxs)(`button`,{type:`button`,"aria-label":A(`session.action.select`,{title:c}),"aria-current":t?`true`:void 0,"aria-busy":n?`true`:void 0,onClick:g,className:`flex min-h-[54px] min-w-0 flex-1 cursor-pointer items-center gap-2 py-1.5 pl-4 pr-2 text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-[hsl(var(--deck-accent))]`,children:[(0,G.jsx)(`span`,{className:w(`h-1.5 w-1.5 shrink-0 rounded-full`,e.pendingInteraction?`animate-pulse bg-amber-500 shadow-[0_0_5px_rgba(245,158,11,0.75)]`:Ce[e.taskStatus]),title:e.pendingInteraction?A(e.pendingInteraction.type===`question`?`interaction.badge.question`:e.pendingInteraction.type===`elicitation`?`interaction.badge.elicitation`:`interaction.badge.permission`):e.taskStatus}),(0,G.jsxs)(`span`,{className:`flex-1 min-w-0 font-mono`,children:[(0,G.jsxs)(`span`,{className:w(`flex gap-2 items-center text-left truncate text-[12px]`,t?`text-[hsl(var(--deck-ink))]`:`text-[hsl(var(--deck-ink-muted))]`),children:[(0,G.jsx)(`span`,{className:`truncate`,children:c}),r&&(0,G.jsx)(`span`,{title:A(`taskSwitcher.new`),className:`h-1.5 w-1.5 shrink-0 rounded-full bg-[hsl(var(--deck-accent))] shadow-[0_0_5px_hsl(var(--deck-accent-glow)/0.75)]`}),e.pendingInteraction&&(0,G.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded bg-amber-100 px-1.5 py-0.5 text-[8.5px] text-amber-800 dark:bg-amber-950/60 dark:text-amber-300`,title:A(e.pendingInteraction.type===`question`?`interaction.badge.question`:e.pendingInteraction.type===`elicitation`?`interaction.badge.elicitation`:`interaction.badge.permission`),children:[(0,G.jsx)(te,{className:`h-2.5 w-2.5`}),A(e.pendingInteraction.type===`question`?`interaction.badge.question`:e.pendingInteraction.type===`elicitation`?`interaction.badge.elicitation`:`interaction.badge.permission`)]}),e.relationType===`fork`&&e.parentId&&(0,G.jsxs)(`span`,{title:`${A(`session.forkedFrom`)} ${e.parentId.slice(0,6)}`,"aria-label":`${A(`session.forkedFrom`)} ${e.parentId.slice(0,6)}`,className:`shrink-0 text-[9px] text-[hsl(var(--deck-accent))]`,children:[A(`session.forkedFrom`),` `,e.parentId.slice(0,6)]}),e.taskRetriedFrom&&(0,G.jsx)(`span`,{title:`${A(`session.retriedFrom`)} ${e.taskRetriedFrom.sessionId.slice(0,6)}`,className:`shrink-0 text-[9px] text-[hsl(var(--deck-accent))]`,children:A(`session.retryShort`)})]}),(0,G.jsxs)(`span`,{className:`mt-0.5 flex min-w-0 items-center gap-1.5 truncate text-[9.5px] text-[hsl(var(--deck-ink-faint))]`,children:[(0,G.jsx)(`span`,{className:`truncate`,children:l.project}),(0,G.jsx)(`span`,{className:`opacity-50`,children:`·`}),(0,G.jsx)(`span`,{className:`truncate`,children:l.environment}),l.queue&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`opacity-50`,children:`·`}),(0,G.jsx)(`span`,{className:`text-amber-700 truncate dark:text-amber-400`,children:l.queue})]}),l.diff&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`opacity-50`,children:`·`}),(0,G.jsx)(`span`,{className:`truncate text-[hsl(var(--deck-accent))]`,children:l.diff})]})]}),l.reason&&(0,G.jsx)(`span`,{title:l.reason,className:`mt-0.5 block truncate text-[9.5px] text-red-600 dark:text-red-400`,children:l.reason})]}),n&&(0,G.jsx)(E,{className:`h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]`})]}),(0,G.jsxs)(`div`,{className:w(`flex items-center gap-0.5 pr-2 transition-opacity group-focus-within:opacity-100`,e.taskStatus===`running`||e.taskStatus===`queued`||e.taskRetryAvailable&&(e.taskStatus===`failed`||e.taskStatus===`interrupted`||e.taskStatus===`cancelled`)?`opacity-100`:`opacity-50 group-hover:opacity-100`),children:[(e.taskStatus===`running`||e.taskStatus===`queued`)&&(0,G.jsx)(`button`,{type:`button`,"aria-label":A(d?`session.action.stopping`:`session.action.stop`,{title:c}),disabled:d,onClick:e=>{e.stopPropagation(),_()},className:`flex h-6 w-6 items-center justify-center rounded text-red-500 transition-colors hover:bg-red-500/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 disabled:cursor-wait disabled:opacity-60`,children:d?(0,G.jsx)(E,{className:`h-3 w-3 animate-spin`}):(0,G.jsx)(b,{className:`h-3 w-3`})}),e.taskRetryAvailable&&(e.taskStatus===`failed`||e.taskStatus===`interrupted`||e.taskStatus===`cancelled`)&&(0,G.jsx)(`button`,{ref:N,type:`button`,"aria-label":A(m?`session.action.retrying`:`session.action.retry`,{title:c}),disabled:m,onClick:e=>{e.stopPropagation(),v()},className:`flex h-6 w-6 items-center justify-center rounded text-[hsl(var(--deck-accent))] transition-colors hover:bg-[hsl(var(--deck-accent-soft))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] disabled:cursor-wait disabled:opacity-60`,children:m?(0,G.jsx)(E,{className:`h-3 w-3 animate-spin`}):(0,G.jsx)(I,{className:`h-3 w-3`})}),(0,G.jsxs)(D,{open:ie,onOpenChange:j,children:[(0,G.jsx)(M,{asChild:!0,children:(0,G.jsx)(`button`,{type:`button`,"aria-label":A(`session.action.more`,{title:c}),"aria-expanded":ie,className:`flex h-6 w-6 items-center justify-center rounded text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-canvas))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]`,children:(0,G.jsx)(pe,{className:`h-3.5 w-3.5`})})}),(0,G.jsxs)(O,{ref:P,role:`menu`,"aria-label":A(`session.action.more`,{title:c}),side:`right`,align:`start`,sideOffset:6,className:`w-40 p-1`,onOpenAutoFocus:e=>{e.preventDefault(),P.current?.querySelector(`[role="menuitem"]:not([disabled])`)?.focus()},onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),j(!1),window.setTimeout(()=>N.current?.focus(),0))},children:[(0,G.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-label":A(`session.action.fork`,{title:c}),disabled:i,onClick:e=>{e.stopPropagation(),y(),j(!1)},className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:bg-[hsl(var(--deck-surface))] focus-visible:text-[hsl(var(--deck-ink))] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-45`,children:[(0,G.jsx)(me,{className:`h-3 w-3`,"aria-hidden":!0}),A(`session.action.forkShort`)]}),(0,G.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-label":A(`session.action.rename`,{title:c}),onClick:e=>{C(e),j(!1)},className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:bg-[hsl(var(--deck-surface))] focus-visible:text-[hsl(var(--deck-ink))] focus-visible:outline-none`,children:[(0,G.jsx)(p,{className:`h-3 w-3`,"aria-hidden":!0}),A(`session.action.renameShort`)]}),(0,G.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-label":A(`session.action.archive`,{title:c}),disabled:e.taskStatus===`running`||e.taskStatus===`queued`,onClick:e=>{e.stopPropagation(),x(),j(!1)},className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:bg-[hsl(var(--deck-surface))] focus-visible:text-[hsl(var(--deck-ink))] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-35`,children:[(0,G.jsx)(u,{className:`h-3 w-3`,"aria-hidden":!0}),A(`session.action.archiveShort`)]}),(0,G.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-label":A(`session.action.export`,{title:c}),disabled:h,onClick:e=>{e.stopPropagation(),S(),j(!1)},className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:bg-[hsl(var(--deck-surface))] focus-visible:text-[hsl(var(--deck-ink))] focus-visible:outline-none disabled:cursor-wait disabled:opacity-45`,children:[h?(0,G.jsx)(E,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):(0,G.jsx)(f,{className:`h-3 w-3`,"aria-hidden":!0}),A(h?`session.action.exportingShort`:`session.action.exportShort`)]}),(0,G.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-label":A(`session.action.delete`,{title:c}),onClick:e=>{T(e),j(!1)},className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left font-mono text-[11px] text-red-600 transition-colors hover:bg-red-500/10 focus-visible:bg-red-500/10 focus-visible:outline-none dark:text-red-400`,children:[(0,G.jsx)(ae,{className:`h-3 w-3`,"aria-hidden":!0}),A(`session.action.deleteShort`)]})]})]})]})]})}function Te({onExpand:e,onNewChat:t,onOpenBoard:n,onOpenTaskSwitcher:r,onToggleTerminal:i,onToggleSettings:a,isTerminalOpen:s,taskEventsConnected:c,unreadCount:l,boardActive:u,terminalDisabled:d=!1,taskSwitcherDisabled:f=!1,className:p}){let v=o(),y=[{icon:h,action:a,labelKey:`sidebar.section.settings`}];return(0,G.jsxs)(`div`,{className:w(`flex flex-col gap-2 items-center py-5 h-screen border-r w-[64px] border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]`,p),children:[(0,G.jsx)(`button`,{onClick:e,className:`rounded-md p-1 transition-colors hover:bg-[hsl(var(--deck-surface))]`,"aria-label":v(`sidebar.action.expand`),children:(0,G.jsx)(se,{size:28})}),(0,G.jsx)(`button`,{onClick:t,"aria-label":v(`sidebar.action.newTaskShort`),title:v(`sidebar.action.newTaskShort`),className:`mt-6 flex h-10 w-10 items-center justify-center rounded-md bg-[hsl(var(--deck-ink))] text-[hsl(var(--deck-canvas))] transition-colors hover:bg-[hsl(var(--deck-ink))]/85`,children:(0,G.jsx)(m,{className:`h-4 w-4 stroke-[2.5]`})}),(0,G.jsx)(`button`,{type:`button`,onClick:n,"aria-label":v(`sidebar.action.taskBoard`),"aria-current":u?`page`:void 0,title:v(`sidebar.action.taskBoard`),className:w(`flex h-10 w-10 items-center justify-center rounded-md border transition-colors`,u?`border-[hsl(var(--deck-accent)/0.55)] bg-[hsl(var(--deck-accent-soft))] text-[hsl(var(--deck-accent))]`:`border-transparent text-[hsl(var(--deck-ink-muted))] hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))]`),children:(0,G.jsx)(_e,{className:`h-4 w-4`})}),(0,G.jsx)(`button`,{onClick:i,disabled:d,"aria-label":v(`sidebar.action.terminalToggle`),title:v(`sidebar.action.terminal`),className:w(`flex h-10 w-10 items-center justify-center rounded-md border transition-colors`,d&&`cursor-not-allowed opacity-35`,s?`border-[hsl(var(--deck-accent)/0.55)] bg-[hsl(var(--deck-accent-soft))] text-[hsl(var(--deck-accent))]`:`border-transparent text-[hsl(var(--deck-ink-muted))] hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))]`),children:(0,G.jsx)(g,{className:`w-4 h-4`})}),(0,G.jsxs)(`button`,{onClick:r,disabled:f,"aria-label":v(`sidebar.action.searchTasks`),title:`${v(`sidebar.action.searchTasks`)} (${k(`searchTasks`)})`,className:w(`relative flex h-10 w-10 items-center justify-center rounded-md border border-transparent text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))]`,f&&`cursor-not-allowed opacity-35`),children:[(0,G.jsx)(_,{className:`h-4 w-4`}),l>0&&(0,G.jsx)(`span`,{"aria-label":v(`sidebar.unreadTasks`,{count:l}),className:`absolute right-0.5 top-0.5 flex min-h-4 min-w-4 items-center justify-center rounded-full bg-[hsl(var(--deck-accent))] px-1 font-mono text-[8px] font-semibold text-white`,children:l>99?`99+`:l})]}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`div`,{className:`my-2 h-px w-6 bg-[hsl(var(--deck-hairline))]`}),y.map(({icon:e,action:t,labelKey:n})=>(0,G.jsx)(`button`,{"data-settings-trigger":!0,onClick:t,"aria-label":v(n),title:v(n),className:`flex h-10 w-10 items-center justify-center rounded-md text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))]`,children:(0,G.jsx)(e,{className:`w-4 h-4`})},n)),(0,G.jsx)(xe,{variant:`compact`}),(0,G.jsx)(`div`,{className:`mt-1`,children:(0,G.jsx)(`div`,{role:`status`,"aria-label":v(c?`sidebar.status.feedLive`:`sidebar.status.feedOffline`),className:w(`h-2 w-2 rounded-full`,c?`bg-[hsl(var(--deck-accent))] shadow-[0_0_6px_hsl(var(--deck-accent-glow)/0.9)]`:`bg-[hsl(var(--deck-ink-faint))]/60`),title:v(c?`sidebar.status.feedLive`:`sidebar.status.feedOffline`)})})]})}var Ee=`blade.sidebar.project-order.v1`;function K(e){let t=new Set,n=[];for(let r of e)typeof r==`string`&&r&&!t.has(r)&&(t.add(r),n.push(r));return n}function De(){if(typeof window>`u`)return[];try{let e=JSON.parse(window.localStorage.getItem(`blade.sidebar.project-order.v1`)??`[]`);return Array.isArray(e)?K(e):[]}catch{return[]}}function q(e){if(typeof window<`u`)try{window.localStorage.setItem(Ee,JSON.stringify(K(e)))}catch{}}function Oe(e,t){let n=new Map(K(t).map((e,t)=>[e,t])),r=n.size;return e.map((e,t)=>({project:e,rank:n.get(e.path)??r+t})).sort((e,t)=>e.rank-t.rank).map(({project:e})=>e)}function J(e,t,n){let r=K(e),i=r.indexOf(t),a=r.indexOf(n);if(i<0||a<0||i===a)return r;let[o]=r.splice(i,1);return r.splice(a,0,o),r}function Y(e,t,n){let r=K(e),i=r.indexOf(t),a=i+n;return i<0||a<0||a>=r.length||([r[i],r[a]]=[r[a],r[i]]),r}function X({name:e,path:t,count:n,countIsPartial:r=!1,isActive:i,hasRunning:a,unreadCount:s,collapsed:c,onToggle:l,onSelect:u,onCreateTask:f,reorderPosition:p,reorderCount:h,isDragging:g=!1,onDragStart:_,onDragEnd:v,onReorderKeyDown:y}){let b=o();return(0,G.jsxs)(`div`,{className:w(`group/proj flex w-full items-center gap-2 px-5 pb-1.5 pt-3 text-left transition-colors`,`hover:bg-[hsl(var(--deck-surface))]/40`),children:[(0,G.jsx)(`button`,{type:`button`,draggable:!0,"data-project-drag-handle":t,onDragStart:_,onDragEnd:v,onKeyDown:y,"aria-label":b(`sidebar.project.reorder`,{name:e,position:p,count:h}),title:b(`sidebar.project.reorderHint`),className:w(`-ml-2 flex h-6 w-4 shrink-0 cursor-grab items-center justify-center rounded-sm text-[hsl(var(--deck-ink-faint))] opacity-45 transition-[opacity,color,background-color] hover:bg-[hsl(var(--deck-surface-2))] hover:text-[hsl(var(--deck-ink-muted))] hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] active:cursor-grabbing group-hover/proj:opacity-100`,g&&`cursor-grabbing opacity-100 text-[hsl(var(--deck-accent))]`),children:(0,G.jsx)(he,{className:`h-3.5 w-3.5`})}),(0,G.jsx)(`button`,{type:`button`,onClick:l,"aria-expanded":!c,"aria-label":b(c?`sidebar.project.expand`:`sidebar.project.collapse`,{name:e}),className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]`,children:(0,G.jsx)(d,{className:w(`h-3 w-3 text-[hsl(var(--deck-ink-faint))] transition-transform duration-150`,!c&&`rotate-90`)})}),(0,G.jsxs)(`button`,{type:`button`,onClick:u??l,title:t,"aria-current":i?`true`:void 0,className:`flex min-h-6 min-w-0 flex-1 items-center gap-2 rounded-sm text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]`,children:[(0,G.jsx)(N,{className:w(`h-3.5 w-3.5 shrink-0`,i?`text-[hsl(var(--deck-accent))]`:`text-[hsl(var(--deck-ink-faint))]`)}),(0,G.jsx)(`span`,{className:w(`flex-1 truncate font-mono text-[11.5px] font-medium tracking-[-0.01em]`,i?`text-[hsl(var(--deck-ink))]`:`text-[hsl(var(--deck-ink-muted))]`),children:e}),a&&(0,G.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-blue-500 shadow-[0_0_5px_rgba(59,130,246,0.7)] animate-pulse dark:bg-blue-400`,"aria-hidden":!0}),s>0&&(0,G.jsx)(`span`,{"aria-label":b(`sidebar.unreadTasks`,{count:s}),className:`shrink-0 rounded-full bg-[hsl(var(--deck-accent))] px-1.5 py-0.5 font-mono text-[8px] font-semibold text-white`,children:s}),(0,G.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]`,children:[n.toString().padStart(2,`0`),r?`+`:``]})]}),f&&(0,G.jsx)(`button`,{type:`button`,onClick:f,title:b(`sidebar.project.newTask`,{name:e}),"aria-label":b(`sidebar.project.newTask`,{name:e}),className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-[hsl(var(--deck-ink-faint))] opacity-0 transition-[opacity,color,background-color] hover:bg-[hsl(var(--deck-surface-2))] hover:text-[hsl(var(--deck-accent))] focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] group-hover/proj:opacity-100`,children:(0,G.jsx)(m,{className:`h-3.5 w-3.5`})})]})}var ke=[`running`,`queued`,`interrupted`,`failed`,`cancelled`,`completed`],Ae={running:`RUNNING`,queued:`QUEUED`,interrupted:`INTERRUPTED`,failed:`FAILED`,cancelled:`CANCELLED`,completed:`DONE`},Z=e=>e.length>1?e.replace(/\/+$/,``):e;function je(e){let t=new Map;for(let n of e){if(!n)continue;let e=A(v(n));t.has(e)||t.set(e,n)}return Array.from(t.values())}function Me(e){let t=je(e),n=[];for(let e of ke){let r=t.filter(t=>t.taskStatus===e).sort(F);r.length>0&&n.push({code:Ae[e],status:e,sessions:r})}return n}function Ne(e,t,n=[]){let r=je(e),i=new Map,a=n.map(Z),o=new Map(a.map((e,t)=>[e,t]));for(let e of a)i.set(e,[]);for(let e of r){let n=ce(e,t),r=i.get(n);r?r.push(e):i.set(n,[e])}let s=t?Z(t):null,c=Array.from(i.entries()).map(([e,t])=>{let n=[...t].sort(F),r=t.reduce((e,t)=>Math.max(e,j(t)),0);return{path:e,name:y(e),isActive:s?Z(e)===s:!1,isBound:o.has(Z(e)),hasRunning:t.some(e=>e.taskStatus===`running`),lastActivity:r,sessions:n}});return c.sort((e,t)=>e.isBound===t.isBound?e.isBound&&t.isBound?(o.get(Z(e.path))??2**53-1)-(o.get(Z(t.path))??2**53-1):t.lastActivity-e.lastActivity:e.isBound?-1:1),c}var Pe=12,Fe=[`running`,`queued`,`interrupted`,`failed`,`cancelled`,`completed`],Ie={RUNNING:`sidebar.group.running`,QUEUED:`sidebar.group.queued`,INTERRUPTED:`sidebar.group.interrupted`,FAILED:`sidebar.group.failed`,CANCELLED:`sidebar.group.cancelled`,DONE:`sidebar.group.done`},Le={RUNNING:`text-blue-700 dark:text-blue-400`,QUEUED:`text-amber-700 dark:text-amber-400`,INTERRUPTED:`text-orange-700 dark:text-orange-400`,FAILED:`text-red-700 dark:text-red-400`,CANCELLED:`text-[hsl(var(--deck-ink-faint))]`,DONE:`text-[hsl(var(--deck-accent))]`},Re={running:`RUNNING`,queued:`QUEUED`,interrupted:`INTERRUPTED`,failed:`FAILED`,cancelled:`CANCELLED`,completed:`DONE`};function Q(e){return e.length>1?e.replace(/\/+$/,``):e}function $(e){let t=e.lastMessageTime||e.firstMessageTime;if(!t)return 0;let n=new Date(t).getTime();return Number.isNaN(n)?0:n}function ze(e,t){if(e.locator.workspace.kind!==`local`)throw Error(`Expected a local Session surface summary`);return t&&$(t)>=$(e)?t:{...t??{sessionId:e.locator.sessionId,projectPath:e.locator.workspace.projectPath,rootId:e.rootId,taskStatus:e.taskStatus,messageCount:e.messageCount,firstMessageTime:e.firstMessageTime,lastMessageTime:e.lastMessageTime,hasErrors:e.hasErrors},sessionId:e.locator.sessionId,projectPath:e.locator.workspace.projectPath,title:e.title,rootId:e.rootId,parentId:e.parentId,relationType:e.relationType,taskStatus:e.taskStatus,messageCount:e.messageCount,firstMessageTime:e.firstMessageTime,lastMessageTime:e.lastMessageTime,hasErrors:e.hasErrors,archivedAt:e.archivedAt,selectedModelId:e.selectedModelId}}function Be(e){return e.kind===`local`?e.session.taskStatus:e.summary.taskStatus}function Ve(e,t){return t.activityTime-e.activityTime}function He(e){return[...e].sort(Ve)}function Ue({view:e,sessions:t,surfaceCatalog:n,activeProjectPath:r,boundProjects:i,currentSessionRef:a,historySurfaceSelection:s,unreadTaskKeys:c,catalogLoadState:l,onSelectProject:u,onCreateTask:d,onRetryCatalog:f,renderLocalRow:p,renderRemoteRow:m}){let h=o(),[g,_]=(0,W.useState)({}),[b,x]=(0,W.useState)({}),[C,ee]=(0,W.useState)(De),[T,D]=(0,W.useState)(null),[ne,O]=(0,W.useState)(null),[k,re]=(0,W.useState)(``),j=l===`ready`||n.length>0,M=l===`loading`||l===`hydrating`,N=M||l===`error`,ae=j?n.length:t.length,P=(0,W.useMemo)(()=>e===`status`?Me(t):[],[t,e]),se=(0,W.useMemo)(()=>e===`project`?Ne(t,r,i.map(e=>e.path)):[],[r,i,t,e]),F=(0,W.useMemo)(()=>Oe(se,C),[se,C]),I=(0,W.useMemo)(()=>{if(!j)return[];let e=new Map(t.map(e=>[A(v(e)),e])),i=[];for(let t of n){if(t.locator.workspace.kind===`local`){let n={sessionId:t.locator.sessionId,projectPath:t.locator.workspace.projectPath},a=e.get(A(n)),o=ze(t,a);i.push({kind:`local`,path:a?ce(o,r):t.locator.workspace.projectPath,activityTime:$(o),session:o});continue}i.push({kind:`remote`,activityTime:$(t),summary:t})}return i},[r,t,n,j]),le=(0,W.useMemo)(()=>!j||e!==`status`?[]:Fe.flatMap(e=>{let t=He(I.filter(t=>Be(t)===e));return t.length===0?[]:[{code:Re[e],entries:t}]}),[I,j,e]),L=(0,W.useMemo)(()=>{if(!j||e!==`project`)return[];let t=i.map(e=>Q(e.path)),n=new Map(t.map((e,t)=>[e,t])),a=new Map;for(let e of t)a.set(e,[]);for(let e of I){if(e.kind!==`local`)continue;let t=a.get(e.path);t?t.push(e):a.set(e.path,[e])}let o=r?Q(r):null,s=Array.from(a.entries()).map(([e,t])=>({path:e,name:y(e),isActive:o?Q(e)===o:!1,isBound:n.has(Q(e)),hasRunning:t.some(e=>Be(e)===`running`),lastActivity:t.reduce((e,t)=>Math.max(e,t.activityTime),0),entries:He(t)}));return s.sort((e,t)=>e.isBound===t.isBound?e.isBound&&t.isBound?(n.get(Q(e.path))??2**53-1)-(n.get(Q(t.path))??2**53-1):t.lastActivity-e.lastActivity:e.isBound?-1:1),Oe(s,C)},[r,i,I,C,j,e]),R=(0,W.useMemo)(()=>e===`project`?He(I.filter(e=>e.kind===`remote`)):[],[I,e]),ue=e=>e.kind===`local`&&!!e.session.pendingInteraction,de=e=>e.kind===`local`&&c.includes(A(v(e.session))),z=e=>e.kind===`local`?!!(a&&S(v(e.session),a)):!!(s&&ie(e.summary.locator,s.locator)),B=(e,t)=>{let n=b[e]??!1,r=n?t:t.filter((e,t)=>{if(t<Pe)return!0;let n=v(e);return!!e.pendingInteraction||c.includes(A(n))||!!(a&&S(n,a))}),i=t.length-r.length,o=n?t.length>Pe:i>0;return(0,G.jsxs)(G.Fragment,{children:[r.map(p),o&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>x(t=>({...t,[e]:!n})),className:`mx-4 my-1 rounded-md px-3 py-1.5 text-left font-mono text-[10.5px] text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink-muted))]`,children:n?h(`sidebar.group.showLess`):h(`sidebar.group.showMore`,{count:i})})]})},fe=(e,t)=>{let n=b[e]??!1,r=n?t:t.filter((e,t)=>t<Pe||ue(e)||de(e)||z(e)),i=t.length-r.length,a=n?t.length>Pe:i>0;return(0,G.jsxs)(G.Fragment,{children:[r.map(e=>e.kind===`local`?p(e.session):m(e.summary)),a&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>x(t=>({...t,[e]:!n})),className:`mx-4 my-1 rounded-md px-3 py-1.5 text-left font-mono text-[10.5px] text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink-muted))]`,children:n?h(`sidebar.group.showLess`):h(`sidebar.group.showMore`,{count:i})})]})},V=M?(0,G.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`mx-4 mt-2 flex items-center gap-2 rounded-md bg-[hsl(var(--deck-surface))]/55 px-3 py-2 font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]`,children:[(0,G.jsx)(E,{className:`h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]`}),(0,G.jsx)(`span`,{className:`flex-1 min-w-0`,children:h(`sidebar.catalog.syncing`)}),(0,G.jsx)(`span`,{className:`tabular-nums shrink-0`,children:h(`sidebar.catalog.loaded`,{count:ae})})]}):l===`error`?(0,G.jsxs)(`div`,{role:`alert`,className:`mx-4 mt-2 flex items-center gap-2 rounded-md bg-amber-50/80 px-3 py-2 font-mono text-[9.5px] text-amber-800 dark:bg-amber-950/35 dark:text-amber-300`,children:[(0,G.jsx)(te,{className:`w-3 h-3 shrink-0`}),(0,G.jsx)(`span`,{className:`flex-1 min-w-0`,children:h(`sidebar.catalog.incomplete`)}),(0,G.jsxs)(`button`,{type:`button`,onClick:f,className:`inline-flex min-h-6 shrink-0 items-center gap-1 rounded px-1.5 font-medium hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-amber-500 dark:hover:bg-amber-900/50`,children:[(0,G.jsx)(oe,{className:`h-2.5 w-2.5`}),h(`sidebar.catalog.retry`)]})]}):null;if(j){if(e===`status`)return(0,G.jsxs)(`div`,{className:`flex flex-col`,children:[V,le.map((e,t)=>(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:w(`flex items-center justify-between px-5 pb-2 pt-3 font-mono text-[10px] tracking-[0.16em]`,Le[e.code]??`text-[hsl(var(--deck-ink-faint))]`,t===0&&`pt-2`),children:[(0,G.jsx)(`span`,{children:h(Ie[e.code])}),(0,G.jsxs)(`span`,{className:`text-[hsl(var(--deck-ink-faint))]`,children:[e.entries.length.toString().padStart(2,`0`),N?`+`:``]})]}),fe(`status:${e.code}`,e.entries)]},e.code))]});let t=L.some(e=>e.isActive||e.entries.some(z)),n=e=>e.entries.some(z),r=(e,t)=>{if(e.join(`\0`)===L.map(e=>e.path).join(`\0`))return;ee(e),q(e);let n=L.find(e=>e.path===t);re(h(`sidebar.project.reordered`,{name:n?.name??t,position:e.indexOf(t)+1}))};return(0,G.jsxs)(`div`,{className:`flex flex-col`,children:[(0,G.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:k}),V,R.length>0&&(0,G.jsxs)(`section`,{"data-remote-session-group":!0,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-5 pb-2 pt-3 font-mono text-[10px] tracking-[0.16em] text-[hsl(var(--deck-ink-faint))]`,children:[(0,G.jsx)(`span`,{children:h(`sidebar.project.remoteSessions`)}),(0,G.jsx)(`span`,{children:R.length.toString().padStart(2,`0`)})]}),fe(`remote-sessions`,R)]}),L.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`px-5 pb-0.5 pt-2 font-mono text-[9px] uppercase tracking-[0.16em] text-[hsl(var(--deck-ink-faint))]`,children:h(`sidebar.project.projects`)}),L.map((e,i)=>{let a=e.entries.filter(de).length,o=n(e),s=a>0,c=e.entries.some(ue),l=g[e.path]??(t&&!e.isActive&&!(o||e.hasRunning||s||c));return(0,G.jsxs)(`div`,{"data-project-group":e.path,onDragEnter:t=>{T&&T!==e.path&&(t.preventDefault(),O(e.path))},onDragOver:t=>{T&&T!==e.path&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`)},onDrop:t=>{t.preventDefault();let n=T||t.dataTransfer.getData(`text/plain`);n&&n!==e.path&&r(J(L.map(e=>e.path),n,e.path),n),D(null),O(null)},className:w(`relative transition-colors`,ne===e.path&&T!==e.path&&`bg-[hsl(var(--deck-accent-soft))]/55 before:absolute before:inset-y-1 before:left-0 before:w-0.5 before:rounded-full before:bg-[hsl(var(--deck-accent))]`),children:[(0,G.jsx)(X,{name:e.name,path:e.path,count:e.entries.length,countIsPartial:N,isActive:e.isActive,hasRunning:e.hasRunning,unreadCount:a,collapsed:l,onSelect:()=>u(e.path),onCreateTask:()=>d(e.path),reorderPosition:i+1,reorderCount:L.length,isDragging:T===e.path,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.path),D(e.path)},onDragEnd:()=>{D(null),O(null)},onReorderKeyDown:t=>{if(t.key!==`ArrowUp`&&t.key!==`ArrowDown`)return;t.preventDefault();let n=Y(L.map(e=>e.path),e.path,t.key===`ArrowUp`?-1:1);r(n,e.path)},onToggle:()=>_(t=>({...t,[e.path]:!l}))}),!l&&fe(`project:${e.path}`,e.entries)]},e.path)})]})]})}if(e===`status`)return(0,G.jsxs)(`div`,{className:`flex flex-col`,children:[V,P.map((e,t)=>(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:w(`flex items-center justify-between px-5 pb-2 pt-3 font-mono text-[10px] tracking-[0.16em]`,Le[e.code]??`text-[hsl(var(--deck-ink-faint))]`,t===0&&`pt-2`),children:[(0,G.jsx)(`span`,{children:h(Ie[e.code])}),(0,G.jsxs)(`span`,{className:`text-[hsl(var(--deck-ink-faint))]`,children:[e.sessions.length.toString().padStart(2,`0`),N?`+`:``]})]}),B(`status:${e.code}`,e.sessions)]},e.code))]});let pe=F.some(e=>e.isActive),H=e=>!!(a&&e.sessions.some(e=>S(v(e),a))),me=(e,t)=>{if(e.join(`\0`)===F.map(e=>e.path).join(`\0`))return;ee(e),q(e);let n=F.find(e=>e.path===t);re(h(`sidebar.project.reordered`,{name:n?.name??t,position:e.indexOf(t)+1}))};return(0,G.jsxs)(`div`,{className:`flex flex-col`,children:[(0,G.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:k}),V,F.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`px-5 pb-0.5 pt-2 font-mono text-[9px] uppercase tracking-[0.16em] text-[hsl(var(--deck-ink-faint))]`,children:h(`sidebar.project.projects`)}),F.map((e,t)=>{let n=e.sessions.filter(e=>c.includes(A(v(e)))).length,r=H(e),i=n>0,a=e.sessions.some(e=>!!e.pendingInteraction),o=g[e.path]??(pe&&!e.isActive&&!(r||e.hasRunning||i||a));return(0,G.jsxs)(`div`,{"data-project-group":e.path,onDragEnter:t=>{T&&T!==e.path&&(t.preventDefault(),O(e.path))},onDragOver:t=>{T&&T!==e.path&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`)},onDrop:t=>{t.preventDefault();let n=T||t.dataTransfer.getData(`text/plain`);n&&n!==e.path&&me(J(F.map(e=>e.path),n,e.path),n),D(null),O(null)},className:w(`relative transition-colors`,ne===e.path&&T!==e.path&&`bg-[hsl(var(--deck-accent-soft))]/55 before:absolute before:inset-y-1 before:left-0 before:w-0.5 before:rounded-full before:bg-[hsl(var(--deck-accent))]`),children:[(0,G.jsx)(X,{name:e.name,path:e.path,count:e.sessions.length,countIsPartial:N,isActive:e.isActive,hasRunning:e.hasRunning,unreadCount:n,collapsed:o,onSelect:()=>u(e.path),onCreateTask:()=>d(e.path),reorderPosition:t+1,reorderCount:F.length,isDragging:T===e.path,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.path),D(e.path)},onDragEnd:()=>{D(null),O(null)},onReorderKeyDown:t=>{if(t.key!==`ArrowUp`&&t.key!==`ArrowDown`)return;t.preventDefault();let n=Y(F.map(e=>e.path),e.path,t.key===`ArrowUp`?-1:1);me(n,e.path)},onToggle:()=>_(t=>({...t,[e.path]:!o}))}),!o&&B(`project:${e.path}`,e.sessions)]},e.path)})]})]})}function We({className:e,onNavigate:n}){let a=o(),{toggleSettings:s,toggleSidebar:c,isSidebarOpen:l,isTerminalOpen:u,toggleTerminal:d,sidebarView:f,setSidebarView:p,setTaskSwitcherOpen:y,mainView:b,setMainView:C,setBoardProjectPath:ee,setFilePreviewOpen:te}=r(),E=L(e=>e.sessions),D=L(e=>e.surfaceCatalog),O=L(e=>e.surfaceCatalogLoadState),j=L(e=>e.historySurfaceSelection),M=i(j),N=L(e=>e.currentSessionRef),ae=L(e=>e.forkingSessionRef),oe=L(e=>e.selectSession),F=L(e=>e.openHistorySurface),I=L(e=>e.startTemporarySession),ce=L(e=>e.deleteSession),R=L(e=>e.archiveSession),de=L(e=>e.forkSession),z=L(e=>e.updateSession),B=L(e=>e.loadSessions),V=L(e=>e.loadSurfaceCatalog),pe=L(e=>e.setError),H=L(e=>e.taskEventsConnected),me=L(e=>e.taskWorkspaceInfo),U=L(e=>e.boundProjects),he=L(e=>e.selectedProjectPath),ge=L(e=>e.bindProject),be=L(e=>e.selectProject),Ce=L(e=>e.cancelTask),Ee=L(e=>e.cancellingTaskKeys),K=L(e=>e.retryTask),De=L(e=>e.retryingTaskKeys),q=L(e=>e.unreadTaskKeys),[Oe,J]=(0,W.useState)(null),[Y,X]=(0,W.useState)(``),[ke,Ae]=(0,W.useState)(null),[Z,je]=(0,W.useState)(!1),Me=he??me?.cwd??null,Ne=e=>P(e,a),Pe=e=>{let t=e.taskSourceProjectPath||e.projectPath;return{project:t.split(`/`).filter(Boolean).at(-1)||t,environment:e.taskIsolation===`worktree`?e.taskWorktreeBranch||a(`session.env.worktree`):a(`session.env.local`),diff:e.taskDiffStat?`+${e.taskDiffStat.additions} −${e.taskDiffStat.deletions}`:void 0,queue:e.taskStatus===`queued`&&e.taskQueuePosition?a(`session.queued`,{position:e.taskQueuePosition,depth:e.taskQueueDepth??e.taskQueuePosition}):void 0,reason:le(e,a)}},Fe=()=>{C(`workspace`),I(Me??void 0),n?.()},Ie=()=>{L.getState().closeHistorySurface(),te(!1),ee(Me),C(`board`),n?.()},Le=async e=>{U.some(t=>t.path===e)?be(e):await ge(e),C(`workspace`),I(e),n?.()},Re=async e=>{U.some(t=>t.path===e)?be(e):await ge(e),C(`workspace`),I(e),n?.()},Q=e=>{e(),n?.()},$=()=>{t(L.getState())||Q(d)},ze=async(e,n)=>{e.stopPropagation(),!t(L.getState())&&await ce(v(n))},Be=async e=>{if(t(L.getState()))return;let n=v(e),r=A(n);if(!ke){Ae(r);try{await ve(n)}catch(e){pe(e instanceof Error?e.message:`Session export failed`)}finally{Ae(null)}}},Ve=(e,n)=>{e.stopPropagation(),!t(L.getState())&&(J(A(v(n))),X(Ne(n)))},He=async e=>{if(!t(L.getState())){if(!Y.trim()){J(null);return}try{await z(v(e),Y.trim()),J(null),await B()}catch(e){console.error(`Failed to rename session:`,e)}}},We=()=>{J(null),X(``)};return l?(0,G.jsxs)(`div`,{className:w(`flex flex-col h-screen border-r w-[260px] border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]`,e),children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-6 px-5 pt-5 pb-5`,children:[(0,G.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,G.jsx)(se,{size:26}),(0,G.jsx)(`span`,{className:`font-mono text-[15px] font-semibold tracking-[-0.01em] text-[hsl(var(--deck-ink))]`,children:`Blade`}),(0,G.jsx)(`span`,{className:`ml-1 rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-1 py-[1px] font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]`,children:a(`sidebar.brand.badge`)})]}),(0,G.jsx)(`button`,{onClick:c,"aria-label":a(`sidebar.action.collapse`),className:`flex h-8 w-8 items-center justify-center rounded transition-colors hover:bg-[hsl(var(--deck-surface))]`,children:(0,G.jsx)(fe,{className:`h-3 w-3 text-[hsl(var(--deck-ink-muted))]`})})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsxs)(`button`,{onClick:Fe,className:`flex h-9 w-full items-center justify-between rounded-md bg-[hsl(var(--deck-ink))] px-3 font-mono text-[13px] font-medium text-[hsl(var(--deck-canvas))] transition-colors hover:bg-[hsl(var(--deck-ink))]/88`,children:[(0,G.jsxs)(`span`,{className:`flex gap-2 items-center`,children:[(0,G.jsx)(m,{className:`h-3.5 w-3.5 stroke-[2.5]`}),a(`sidebar.action.newTask`)]}),(0,G.jsx)(`span`,{className:`rounded-sm bg-white/10 px-1.5 py-[1px] font-mono text-[10px] text-white/80`,children:k(`newTask`)})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:Ie,"aria-current":b===`board`?`page`:void 0,className:w(`flex h-9 w-full items-center gap-2 rounded-md border px-3 font-mono text-[12.5px] transition-colors`,b===`board`?`border-[hsl(var(--deck-accent)/0.45)] bg-[hsl(var(--deck-accent-soft))] text-[hsl(var(--deck-accent))]`:`border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] text-[hsl(var(--deck-ink-muted))] hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-ink))]`),children:[(0,G.jsx)(_e,{className:`h-3.5 w-3.5`}),a(`sidebar.action.taskBoard`)]}),(0,G.jsxs)(`button`,{onClick:$,disabled:M,className:w(`flex h-9 w-full items-center gap-2 rounded-md border px-3 font-mono text-[12.5px] transition-colors`,u?`border-[hsl(var(--deck-accent)/0.55)] bg-[hsl(var(--deck-accent-soft))] text-[hsl(var(--deck-accent))]`:`border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] text-[hsl(var(--deck-ink-muted))] hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-ink))]`),children:[(0,G.jsx)(g,{className:`h-3.5 w-3.5`}),a(`sidebar.action.terminal`)]}),!M&&(0,G.jsxs)(`button`,{type:`button`,onClick:()=>Q(()=>y(!0)),className:`flex h-9 w-full items-center justify-between rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-3 font-mono text-[12.5px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-ink))]`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(_,{className:`h-3.5 w-3.5`}),a(`sidebar.action.searchTasks`)]}),(0,G.jsx)(`span`,{className:`rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] px-1.5 py-[1px] font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]`,children:q.length>0?q.length:k(`searchTasks`)})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`div`,{className:`flex flex-1 items-center gap-0.5 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] p-0.5`,children:[`project`,`status`].map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>p(e),"aria-pressed":f===e,"aria-label":a(e===`project`?`sidebar.view.projectAria`:`sidebar.view.statusAria`),className:w(`flex-1 rounded-[5px] py-1 font-mono text-[11px] tracking-[0.02em] transition-colors`,f===e?`bg-[hsl(var(--deck-canvas))] text-[hsl(var(--deck-ink))] shadow-sm`:`text-[hsl(var(--deck-ink-faint))] hover:text-[hsl(var(--deck-ink-muted))]`),children:a(e===`project`?`sidebar.view.project`:`sidebar.view.status`)},e))}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>je(!0),disabled:M,title:a(`projects.bind.action`),"aria-label":a(`projects.bind.action`),className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] text-[hsl(var(--deck-ink-faint))] transition-colors hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-accent))]`,children:(0,G.jsx)(ne,{className:`h-3.5 w-3.5`})})]})]}),(0,G.jsx)(ue,{className:`flex-1 px-0`,children:(0,G.jsxs)(`div`,{className:`flex flex-col`,children:[(E.length>0||D.length>0||U.length>0||O===`loading`||O===`hydrating`||O===`error`)&&(0,G.jsx)(Ue,{view:f,sessions:E,surfaceCatalog:D,activeProjectPath:Me,boundProjects:U,currentSessionRef:N,historySurfaceSelection:j,unreadTaskKeys:q,catalogLoadState:O,onRetryCatalog:()=>{V()},onSelectProject:e=>void Le(e).catch(()=>void 0),onCreateTask:e=>void Re(e).catch(()=>void 0),renderLocalRow:e=>{let r=v(e),i=A(r),a=S(r,N),o=Oe===i,s=S(r,ae),c=!!ae;return(0,G.jsx)(we,{session:e,sessionRef:r,isActive:a,isForking:s,isUnread:q.includes(A(r)),anyForking:c,isEditing:o,editingTitle:Y,title:Ne(e),context:Pe(e),isCancelling:Ee.includes(A(r)),isRetrying:De.includes(A(r)),isExporting:ke===i,onSelect:()=>(n?.(),C(`workspace`),oe(r)),onCancelTask:()=>{t(L.getState())||Ce(r).catch(()=>void 0)},onRetryTask:()=>{t(L.getState())||K(r).catch(()=>void 0)},onFork:()=>{t(L.getState())||de(e)},onArchive:()=>{t(L.getState())||R(r)},onExport:()=>void Be(e),onStartRename:t=>Ve(t,e),onDelete:t=>ze(t,e),onEditingTitleChange:X,onSaveRename:()=>He(e),onCancelRename:We},i)},renderRemoteRow:e=>(0,G.jsx)(Se,{summary:e,isActive:ie(e.locator,j?.locator),onSelect:()=>(n?.(),C(`workspace`),F(e.locator))},x(e.locator))}),D.length===0&&E.length===0&&(0,G.jsx)(`div`,{className:`px-5 mt-6`,children:(0,G.jsxs)(`div`,{className:`rounded-md border border-dashed border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]/60 px-4 py-6 text-center`,children:[(0,G.jsx)(`div`,{className:`mx-auto mb-2 inline-flex h-8 w-8 items-center justify-center rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))]`,children:(0,G.jsx)(T,{className:`h-3.5 w-3.5 text-[hsl(var(--deck-ink-faint))]`})}),(0,G.jsx)(`div`,{className:`font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]`,children:a(`sidebar.empty.title`)}),(0,G.jsx)(`div`,{className:`mt-1 text-[10.5px] text-[hsl(var(--deck-ink-faint))]`,children:a(`sidebar.empty.hint`)})]})})]})}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 px-5 pt-3 pb-5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-0.5 border-t border-[hsl(var(--deck-hairline))] pt-3`,children:[!M&&(0,G.jsx)(ye,{}),[{icon:h,action:()=>Q(s),labelKey:`sidebar.section.settings`}].map(({icon:e,action:t,labelKey:n})=>(0,G.jsxs)(`button`,{"data-settings-trigger":!0,onClick:t,className:`flex h-8 w-full items-center gap-2.5 rounded-md px-2.5 font-mono text-[12.5px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))]`,children:[(0,G.jsx)(e,{className:`h-3.5 w-3.5 text-[hsl(var(--deck-ink-faint))]`}),a(n)]},n))]}),(0,G.jsxs)(`div`,{className:`flex gap-2 justify-between items-center`,children:[(0,G.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[0.14em] text-[hsl(var(--deck-ink-faint))]`,children:a(`sidebar.language.label`)}),(0,G.jsx)(xe,{})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-3 py-2`,children:[(0,G.jsx)(`div`,{className:`flex h-7 w-7 items-center justify-center rounded-md bg-[hsl(var(--deck-canvas-veil))]`,children:(0,G.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-[hsl(var(--deck-ink))]`})}),(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col gap-[1px]`,children:[(0,G.jsx)(`span`,{className:`font-mono text-[12px] text-[hsl(var(--deck-ink))]`,children:a(`sidebar.status.user`)}),(0,G.jsxs)(`span`,{className:w(`flex gap-1 items-center font-mono text-[10px]`,H?`text-[hsl(var(--deck-accent))]`:`text-[hsl(var(--deck-ink-faint))]`),children:[(0,G.jsx)(`span`,{className:w(`h-1 w-1 rounded-full`,H?`bg-[hsl(var(--deck-accent))] shadow-[0_0_5px_hsl(var(--deck-accent-glow)/0.9)]`:`bg-[hsl(var(--deck-ink-faint))]/60`)}),a(H?`sidebar.status.feedLive`:`sidebar.status.feedOffline`)]})]})]})]}),!M&&(0,G.jsx)(re,{open:Z,onOpenChange:je})]}):(0,G.jsx)(Te,{className:e,onExpand:c,onNewChat:Fe,onOpenBoard:Ie,onOpenTaskSwitcher:()=>Q(()=>y(!0)),onToggleTerminal:$,onToggleSettings:()=>Q(s),isTerminalOpen:u,taskEventsConnected:H,unreadCount:q.length,boardActive:b===`board`,terminalDisabled:M,taskSwitcherDisabled:M})}export{We as Sidebar};
|