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
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{dt as n,i as r}from"./session-events-BuMTbIwu.js";import{C as i,S as a,x as o}from"./vendor-radix-L0yJCKJX.js";import{c as s,l as c,r as l,s as u}from"./preload-helper-DvgLbiBV.js";import{n as d,t as f}from"./team-D3XOVbxL.js";import{t as p}from"./arrow-left-gaino9Tb.js";import{t as m}from"./calendar-clock-DfHUrEw9.js";import{t as h}from"./download-BR2L5Wme.js";import{n as g,t as _}from"./triangle-alert-cGqHxFsZ.js";import{t as v}from"./pencil-DkC0bPYD.js";import{t as y}from"./play-BVeNn6fv.js";import{t as b}from"./plus-kzdwas-3.js";import{F as x,I as S,K as C,L as w,Q as T,S as E,U as D,V as O,W as k,Y as A,_t as j,a as M,b as N,d as P,f as ee,g as te,gt as ne,it as re,m as ie,nt as ae,p as F,st as I,vt as L,y as R}from"./index-DSa8Dzp7.js";import{t as z}from"./ScrollArea-BdOqyQ3g.js";var B={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`}]]};B.node;var oe=c(B),V={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`}]]};V.node;var se=c(V),ce={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`}]]};ce.node;var H=c(ce),U=e(n()),W=e=>(t,n)=>{let r=(0,U.useRef)(!1);e(()=>()=>{r.current=!1},[]),e(()=>{if(!r.current)r.current=!0;else return t()},n)},G=e=>typeof e==`function`,K=e=>e!=null,le=e=>K(e)&&G(e.then),q=e=>{let t=(0,U.useRef)(e);t.current=(0,U.useMemo)(()=>e,[e]);let n=(0,U.useRef)(void 0);return n.current||=function(...e){return t.current.apply(this,e)},n.current},J=W(U.useEffect),ue=(e,{manual:t,ready:n=!0,defaultParams:r=[],refreshDeps:i=[],refreshDepsAction:a})=>{let o=(0,U.useRef)(!1);return o.current=!1,J(()=>{!t&&n&&(o.current=!0,e.run(...r))},[n]),J(()=>{o.current||t||(o.current=!0,a?a():e.refresh())},[...i]),{onBefore:()=>{if(!n)return{stopNow:!0}}}};ue.onInit=({ready:e=!0,manual:t})=>({loading:!t&&e});function de(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 Y=(e,t)=>{let{current:n}=(0,U.useRef)({deps:t,obj:void 0,initialized:!1});return(n.initialized===!1||!de(n.deps,t))&&(n.deps=t,n.obj=e(),n.initialized=!0),n.obj};function fe(e){let t=(0,U.useRef)(e);return t.current=e,t}var pe=e=>{let t=fe(e);(0,U.useEffect)(()=>()=>{t.current()},[])},X=new Map,me=e=>{e?.timer&&clearTimeout(e.timer)},he=(e,t,n)=>{me(X.get(e));let r;t>-1&&(r=setTimeout(()=>{X.delete(e)},t)),X.set(e,Object.assign(Object.assign({},n),{timer:r}))},Z=e=>X.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,U.useRef)(void 0),s=(0,U.useRef)(void 0),c=(e,t)=>{i?i(t):he(e,n,t),ye(e,t.data)},l=(e,t=[])=>a?a(t):Z(e);return Y(()=>{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})})},[]),pe(()=>{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,U.useRef)(void 0),s=(0,U.useRef)(void 0),c=(0,U.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,U.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]),J(()=>{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,U.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,U.useRef)(void 0),a=(0,U.useRef)(void 0),o=(0,U.useRef)(0),s=()=>{var e;i.current&&clearTimeout(i.current),(e=a.current)==null||e.call(a)};return J(()=>{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,U.useRef)(void 0),i=()=>{var e;(e=r.current)==null||e.call(r)};return(0,U.useEffect)(()=>{if(t){let t=Ye(e.refresh.bind(e),n);r.current=Qe(()=>{t()})}return()=>{i()}},[t,n]),pe(()=>{i()}),{}},et=(e,{retryInterval:t,retryCount:n})=>{let r=(0,U.useRef)(void 0),i=(0,U.useRef)(0),a=(0,U.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,U.useRef)(void 0),a=(0,U.useRef)(void 0),o={};return n!==void 0&&(o.leading=n),r!==void 0&&(o.trailing=r),(0,U.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,U.useEffect)(()=>{let t=e?.();if(!le(t))return t},[])},it=()=>{let[,e]=(0,U.useState)({});return q(()=>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=G(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=fe(e),l=it(),u=Y(()=>{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)}}),pe(()=>{u.cancel()}),{loading:u.state.loading,data:u.state.data,error:u.state.error,params:u.state.params||[],cancel:q(u.cancel.bind(u)),refresh:q(u.refresh.bind(u)),refreshAsync:q(u.refreshAsync.bind(u)),run:q(u.run.bind(u)),runAsync:q((...e)=>u.runAsync(...e)),mutate:q(u.mutate.bind(u))}}function st(e,t,n){return ot(e,t,[...n||[],He,Ue,Je,$e,nt,ue,xe,et])}var ct=st;function lt(e,t){if(!We)return;if(!e)return t;let n;return n=G(e)?e():`current`in e?e.current:e,n}var ut=(e=>(t,n,r)=>{let i=(0,U.useRef)(!1),a=(0,U.useRef)([]),o=(0,U.useRef)([]),s=(0,U.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||!de(a.current,c)||!de(o.current,n))&&((e=s.current)==null||e.call(s),a.current=c,o.current=n,s.current=t())}),pe(()=>{var e;(e=s.current)==null||e.call(s),i.current=!1})})(U.useEffect);function dt(e,t){let n=fe(e),r=t?.wait??1e3,i=(0,U.useMemo)(()=>(0,Ve.default)((...e)=>n.current(...e),r,t),[]);return pe(()=>{i.cancel()}),{run:i,cancel:i.cancel,flush:i.flush}}function ft(e,t,n={}){let{enable:r=!0}=n,i=fe(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,U.useState)(),[h,g]=(0,U.useState)(!1),_=a===`top`,v=(0,U.useRef)(void 0),y=(0,U.useRef)(0),b=(0,U.useRef)(!1),x=(0,U.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=q(()=>{x||(g(!0),w(p))}),O=e=>o(void 0,void 0,void 0,function*(){return(yield T(e)).currentData}),k=q(()=>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 J(()=>{b.current&&(b.current=!1,M())},[p]),ft(`scroll`,()=>{S||h||M()},{target:n}),J(()=>{w()},[...s]),{data:p,loading:!h&&S,error:C,loadingMore:h,noMore:x,loadMore:D,loadMoreAsync:k,reload:q(A),reloadAsync:q(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,U.useState)(`installed`),[i,a]=(0,U.useState)(!1),[o,c]=(0,U.useState)(null),[l,u]=(0,U.useState)(``),[d,f]=(0,U.useState)(null),[p,m]=(0,U.useState)(null),[_,v]=(0,U.useState)(null),[y,S]=(0,U.useState)(null),[C,w]=(0,U.useState)(null),[E,O]=(0,U.useState)(``),[k,A]=(0,U.useState)(null),[j,M]=(0,U.useState)(!1),[N,P]=(0,U.useState)(null),[ee,te]=(0,U.useState)(null),[re,ie]=(0,U.useState)(``),[F,R]=(0,U.useState)(``),[z,B]=(0,U.useState)(null),[oe,V]=(0,U.useState)(null),se=(0,U.useRef)(null),{run:ce}=dt(e=>{R(e)},{wait:500}),{data:H=[],loading:W,error:G,run:K,runAsync:le}=ct(wt,{refreshDeps:[e],ready:e,onSuccess:e=>{e.length>0&&!o&&c(e[0].id)}}),{data:q,loading:J,error:ue,runAsync:de}=ct(Tt,{manual:!0}),{data:Y,loading:fe,loadingMore:pe,noMore:X,error:me,reload:he}=gt(async e=>{let t=e?.list?.length??0;return kt(F,t)},{target:se,isNoMore:e=>!e?.hasMore,reloadDeps:[F],manual:!e||n!==`catalog`}),{runAsync:Z,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:()=>{le(),a(!1),V(null),B(null)},onError:()=>{B(null)}}),ve=(0,U.useMemo)(()=>{let e=l.trim().toLowerCase();return e?H.filter(t=>[t.name,t.endpoint,t.description].some(t=>t.toLowerCase().includes(e))):H},[l,H]),Q=(0,U.useMemo)(()=>ve.find(e=>e.id===o)??ve[0],[ve,o]),ye=(0,U.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===C)??ye[0];(0,U.useEffect)(()=>{if(!e||!H.some(e=>e.oauthStatus===`authorizing`||e.status===`connecting`||e.status===`reconnecting`))return;let t=window.setInterval(()=>{le()},1e3);return()=>window.clearInterval(t)},[e,le,H]),(0,U.useEffect)(()=>{p&&H.some(e=>e.name===p.serverName&&(e.oauthStatus===`authenticated`||e.oauthStatus===`disabled`||e.oauthStatus===`unavailable`))&&m(null)},[p,H]),(0,U.useEffect)(()=>{e&&n===`installed`&&Q&&de(Q.name).catch(()=>void 0)},[e,de,Q,n]);let xe=async(e,n)=>{v({type:e,name:n}),f(null);try{let t=e===`delete`?``:`/${e}`;await x(`/mcp/${encodeURIComponent(n)}${t}`,{method:e===`delete`?`DELETE`:`POST`}),await le(),e===`delete`&&(te(null),c(null))}catch(n){f(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}),f(null);try{if(e===`login`){let e=await x(`/mcp/${encodeURIComponent(n.name)}/oauth/login`,{method:`POST`});m({serverName:n.name,url:e.authorizationUrl})}else await x(`/mcp/${encodeURIComponent(n.name)}/oauth/logout`,{method:`POST`}),m(null);await le()}catch(n){f(n instanceof Error?n.message:t(e===`login`?`mcp.error.loginFailed`:`mcp.error.logoutFailed`))}finally{v(null)}},Ce=async(e,n)=>{S(n),f(null);try{await x(`/mcp/${encodeURIComponent(e.name)}/logging-level`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({level:n})}),await le(),de(e.name).catch(()=>void 0)}catch(e){f(e instanceof Error?e.message:t(`mcp.error.loggingLevelFailed`))}finally{S(null)}},we=async e=>{if(be){M(!0),P(null),A(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:E}})});A(t)}catch(e){P(e instanceof Error?e.message:t(`mcp.error.completionFailed`))}finally{M(!1)}}},Te=(0,U.useMemo)(()=>new Set(H.map(e=>e.name.toLowerCase())),[H]),Ee=e=>{V(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:K,"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:W,children:(0,$.jsx)(ae,{className:D(`h-4 w-4`,W&&`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)(b,{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:H.length})}),(0,$.jsx)(jt,{active:n===`catalog`,onClick:()=>{r(`catalog`),Y||he()},children:t(`mcp.tab.catalog`)})]}),d&&(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)(ne,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1 min-w-0`,children:d}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>f(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:[W&&H.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)(I,{className:`w-4 h-4 animate-spin`}),t(`mcp.servers.loading`)]}),G&&!W&&(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:G.message}),(0,$.jsx)(`button`,{type:`button`,onClick:K,className:`rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900`,children:t(`mcp.action.retry`)})]}),!G&&!W&&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),te(null),f(null),w(null),O(``),A(null),P(null)},className:D(`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:D(`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:D(`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:D(`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:D(`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)(I,{className:`h-3.5 w-3.5 animate-spin text-[#2563eb]`,"aria-hidden":`true`}),p?.serverName===Q.name?(0,$.jsx)(`a`,{href:p.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:()=>te(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:()=>te(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:()=>{w(e.key),A(null),P(null)},className:D(`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:E,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:j,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(j?`mcp.completion.completing`:`mcp.completion.complete`)})]}),N&&(0,$.jsx)(`span`,{role:`alert`,className:`text-[11px] font-mono text-red-600 dark:text-red-400`,children:N}),k&&(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:k.values.length>0?k.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 `,k.sha256,k.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 de(Q.name),disabled:J,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)(ae,{className:D(`h-3.5 w-3.5`,J&&`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`||y!==null,"aria-pressed":(Q.logging?.level??`warning`)===e,className:D(`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:y===e?t(`mcp.log.setting`):e},e))}),ue?(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:ue.message}):q?.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:q.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:D(`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(J?`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)(T,{className:`h-3.5 w-3.5 text-[#9CA3AF] dark:text-[#71717a]`}),(0,$.jsx)(`input`,{type:`text`,"aria-label":t(`mcp.catalog.searchAria`),value:re,onChange:e=>{ie(e.target.value),ce(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:se,className:`overflow-y-auto flex-1 min-h-0`,children:[me?(0,$.jsxs)(`div`,{role:`alert`,className:`flex flex-col gap-3 items-center py-12 font-mono text-center`,children:[(0,$.jsx)(ne,{className:`w-6 h-6 text-red-500`}),(0,$.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:me.message}),(0,$.jsx)(`button`,{type:`button`,onClick:he,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`)})]}):fe&&!Y?(0,$.jsx)(`div`,{className:`flex justify-center items-center py-12`,children:(0,$.jsx)(I,{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:[Y?.list.map(e=>{let n=Te.has(Ot(e.name).toLowerCase()),r=z===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:D(`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)(g,{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)(L,{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)(h,{className:D(`h-3 w-3`,r&&`animate-pulse`)}),t(r?`mcp.catalog.installing`:`mcp.catalog.install`)]})]})]},e.name)}),Y?.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`)})]}),pe&&(0,$.jsx)(`div`,{className:`flex justify-center items-center py-4`,children:(0,$.jsx)(I,{className:`h-5 w-5 text-[#9CA3AF] dark:text-[#71717a] animate-spin`})}),X&&Y&&Y.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:Y?.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)(g,{className:`w-3 h-3`})]})]})]})]})}),(0,$.jsx)(Mt,{open:i,onOpenChange:a,onAdd:Z,saving:ge,error:_e?.message??null}),oe&&(0,$.jsx)(Nt,{pkg:oe,onClose:()=>V(null),installing:ge,error:_e?.message??null,onInstall:e=>(B(oe.name),Z(e))})]})}function jt({active:e,children:t,onClick:n}){return(0,$.jsx)(`button`,{onClick:n,className:D(`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,U.useState)(`form`),[l,u]=(0,U.useState)(``),[d,f]=(0,U.useState)(``),[p,m]=(0,U.useState)(``),[h,g]=(0,U.useState)(null),[_,v]=(0,U.useState)(`{
|
|
2
|
-
"name": "my-server",
|
|
3
|
-
"command": "npx",
|
|
4
|
-
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
|
|
5
|
-
}`);(0,U.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)(w,{onCloseAutoFocus:e=>M(`[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)(O,{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)(k,{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,U.useState)(o),[u,d]=(0,U.useState)(`-y ${e.name}`),[f,p]=(0,U.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)(w,{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)(O,{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)(k,{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:D(`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]=U.useState(!1),[l,u]=U.useState(-1),d=U.useRef(null),f=n.find(t=>t.value===e);U.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 U.useEffect(()=>{!s||l<0||(d.current?.children[l])?.scrollIntoView({block:`nearest`})},[l,s]),(0,$.jsxs)(P,{open:s,onOpenChange:c,children:[(0,$.jsx)(F,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,role:`combobox`,"aria-expanded":s,"aria-haspopup":`listbox`,"aria-label":o,disabled:i,onKeyDown:p,className:D(`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)(j,{className:`h-3.5 w-3.5 shrink-0 opacity-60`})]})}),(0,$.jsx)(ee,{align:`start`,sideOffset:4,onKeyDown:p,className:`w-[var(--radix-popover-trigger-width)] max-h-[240px] p-1 overflow-hidden`,children:(0,$.jsx)(z,{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:D(`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)(L,{className:D(`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=E(e=>e.configuredModels),a=n??r??new URLSearchParams(window.location.search).get(`project`)??``,o=N(e=>e.schedules),c=N(e=>e.isLoading),l=N(e=>e.error),u=N(e=>e.loadSchedules),d=N(e=>e.createSchedule),f=N(e=>e.updateSchedule),p=N(e=>e.deleteSchedule),h=N(e=>e.toggleSchedule),g=N(e=>e.runSchedule),[_,x]=(0,U.useState)(!1),[S,w]=(0,U.useState)(`cron`),[T,O]=(0,U.useState)(``),[k,A]=(0,U.useState)(``),[j,M]=(0,U.useState)(``),[P,ee]=(0,U.useState)(``),[te,ne]=(0,U.useState)(``),[re,ie]=(0,U.useState)(``),[F,z]=(0,U.useState)(``),[B,oe]=(0,U.useState)(`default`),[V,se]=(0,U.useState)(`worktree`),[ce,H]=(0,U.useState)(!1),[W,G]=(0,U.useState)(null),[K,le]=(0,U.useState)(null),[q,J]=(0,U.useState)(null),[ue,de]=(0,U.useState)(``),[Y,fe]=(0,U.useState)(!0),[pe,X]=(0,U.useState)(null),me=(0,U.useRef)(!1);(0,U.useEffect)(()=>{e&&!me.current&&(me.current=!0,u()),e||(me.current=!1)},[e,u]);let he=pe??l,Z=W!==null||ce,ge=()=>{x(!0),w(`cron`),O(``),A(``),M(``),ee(``),ne(a),ie(``),z(``),oe(`default`),se(`worktree`),X(null)},_e=()=>{x(!1),X(null)},ve=async()=>{X(null);let e=P.trim();if(!e){X(t(`schedule.error.promptRequired`));return}let n=te.trim();if(!n){X(t(`schedule.error.projectRequired`));return}let r;if(S===`cron`){let e=T.trim();if(!e){X(t(`schedule.error.cronRequired`));return}r={kind:`cron`,cron:e}}else if(S===`interval`){let e=Vt(k);if(e===null){X(t(`schedule.error.invalidInterval`));return}r={kind:`interval`,intervalMs:e}}else{let e=j?new Date(j):null;if(!e||Number.isNaN(e.getTime())){X(t(`schedule.error.runAtRequired`));return}r={kind:`once`,runAt:e.toISOString()}}let i={prompt:e,projectPath:n,trigger:r,permissionMode:B,isolation:V,enabled:!0};re.trim()&&(i.title=re.trim()),F.trim()&&(i.modelId=F.trim()),H(!0);try{await d(i),x(!1)}catch{}finally{H(!1)}},Q=async e=>{X(null),G(`run:${e.id}`);try{await g(e.id)}catch{}finally{G(null)}},ye=async e=>{X(null),G(`toggle:${e.id}`);try{await h(e.id,!e.enabled)}catch{}finally{G(null)}},be=async e=>{let t=`delete:${e.id}`;if(K!==t){le(t);return}X(null),G(t);try{await p(e.id),le(null)}catch{}finally{G(null)}},xe=e=>{J(e.id),de(e.prompt),fe(e.enabled),X(null)},Se=async e=>{let n=ue.trim();if(!n){X(t(`schedule.error.promptRequired`));return}X(null),G(`edit:${e.id}`);try{await f(e.id,{prompt:n,enabled:Y}),J(null)}catch{}finally{G(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)(m,{className:`h-4 w-4`}),t(`schedule.title`),c&&(0,$.jsx)(I,{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||Z,"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)(ae,{className:`h-3.5 w-3.5`}),t(`schedule.refresh`)]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>_?_e():ge(),disabled:Z,"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)(b,{className:`h-3.5 w-3.5`}),t(`schedule.new`)]})]})]}),he&&(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:he}),_&&(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:()=>w(e.value),className:D(`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:T,onChange:e=>O(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:k,onChange:e=>A(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:j,onChange:e=>M(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:re,onChange:e=>ie(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=>ee(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:te,onChange:e=>ne(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:F,onChange:z,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:B,onChange:e=>oe(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:V,onChange:e=>se(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:ce,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:ce,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:[ce?(0,$.jsx)(I,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(b,{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=q===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:D(`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:ue,onChange:e=>de(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":Y,"aria-label":t(Y?`schedule.disableAria`:`schedule.enableAria`,{title:e.title||e.prompt}),onClick:()=>fe(e=>!e),className:`flex items-center gap-2 text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]`,children:[(0,$.jsx)(`span`,{className:D(`flex h-5 w-9 items-center rounded-full px-1 transition-colors`,Y?`bg-emerald-500`:`bg-[#E5E7EB] dark:bg-[#27272a]`),children:(0,$.jsx)(`span`,{className:D(`h-3.5 w-3.5 rounded-full bg-white transition-transform`,Y?`translate-x-4`:`translate-x-0`)})}),t(Y?`schedule.enabled`:`schedule.disabled`)]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>J(null),disabled:Z,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:Z,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:[W===`edit:${e.id}`?(0,$.jsx)(I,{className:`h-3 w-3 animate-spin`}):(0,$.jsx)(L,{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:Z,onClick:()=>void ye(e),className:D(`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:D(`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:Z,className:`rounded p-1 text-[#6B7280] hover:bg-[#F3F4F6] disabled:opacity-40 dark:text-[#a1a1aa] dark:hover:bg-[#27272a]`,children:W===`run:${e.id}`?(0,$.jsx)(I,{className:`h-3 w-3 animate-spin`}):(0,$.jsx)(y,{className:`h-3 w-3`})}),(0,$.jsx)(`button`,{type:`button`,"aria-label":t(`schedule.editAria`,{title:e.title||e.prompt}),onClick:()=>xe(e),disabled:Z,className:`rounded p-1 text-[#6B7280] hover:bg-[#F3F4F6] disabled:opacity-40 dark:text-[#a1a1aa] dark:hover:bg-[#27272a]`,children:(0,$.jsx)(v,{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:Z,className:D(`rounded p-1 text-[9px] disabled:opacity-40`,K===`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:W===`delete:${e.id}`?(0,$.jsx)(I,{className:`h-3 w-3 animate-spin`}):K===`delete:${e.id}`?(0,$.jsx)(`span`,{className:`px-0.5 text-[8.5px]`,children:t(`schedule.confirmDelete`)}):(0,$.jsx)(C,{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,U.useState)(null),[a,o]=(0,U.useState)(``),[c,l]=(0,U.useState)(null),[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(null),[m,h]=(0,U.useState)(!1),[g,_]=(0,U.useState)(!1),[v,y]=(0,U.useState)(`confirm`),[S,w]=(0,U.useState)(null),[T,E]=(0,U.useState)(null),{data:O=[],loading:k,error:A,run:j,runAsync:M}=ct(()=>Kt(n),{refreshDeps:[e,n],ready:e,onSuccess:e=>{e.length>0&&!r&&i(e[0].id)}}),N=O.filter(e=>e.name.toLowerCase().includes(a.toLowerCase())),P=(0,U.useMemo)(()=>O.find(e=>e.id===r)??O[0],[O,r]),ee=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)(U.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)(b,{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:k,children:(0,$.jsx)(ae,{className:D(`h-4 w-4`,k&&`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)(ne,{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:[k&&O.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)(I,{className:`h-4 w-4 animate-spin`}),t(`skills.installed.loading`)]}),A&&!k&&(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&&N.length===0&&!k&&(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`)}),N.map(e=>(0,$.jsxs)(`button`,{onClick:()=>{i(e.id),p(null),l(null)},className:D(`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:D(`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))]})]}),P?(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:P.name}),(0,$.jsxs)(`span`,{className:`text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]`,children:[`v`,P.version]})]}),(0,$.jsx)(`p`,{className:`text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]`,children:P.description||t(`skills.noDescription`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`button`,{onClick:()=>void ee(`toggle`,P,!P.enabled),disabled:u!==null,className:D(`h-7 px-3 rounded-md text-[11px] font-mono font-semibold`,P.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===P.name?t(`skills.action.saving`):P.enabled?t(`skills.action.disable`):t(`skills.action.enable`)}),(0,$.jsxs)(`button`,{onClick:()=>p(P.name),disabled:!P.removable||u!==null,title:P.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)(C,{className:`h-3 w-3`}),P.removable?t(`skills.uninstall.action`):t(`skills.uninstall.managed`)]})]}),f===P.name&&(0,$.jsxs)(`div`,{role:`alertdialog`,"aria-label":t(`skills.uninstall.confirmAria`,{name:P.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 ee(`delete`,P),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:P.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:P.location})]})]}),P.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:P.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))})]}),P.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:P.allowedTools.length})}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:P.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:O.map(e=>e.name),onOpenChange:h,onInstall:e=>{E(e),w(null),y(`confirm`),_(!0)}}),(0,$.jsx)(Qt,{open:g,status:v,error:S,onCancel:()=>_(!1),onConfirm:async()=>{if(T){y(`installing`),w(null);try{let e=await x(`/skills/install`,{method:`POST`,headers:{"Content-Type":`application/json`,...Gt(n)},body:JSON.stringify(T)});if(e.success===!1)throw Error(e.error||t(`skills.error.installFailed`));await M(),_(!1),h(!1)}catch(e){w(e instanceof Error?e.message:t(`skills.error.installFailed`)),y(`failed`)}}},onRetry:()=>y(`confirm`)})]})}function Xt({active:e,children:t,onClick:n}){return(0,$.jsx)(`button`,{onClick:n,className:D(`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,U.useState)(`catalog`),[l,u]=(0,U.useState)(``),[d,f]=(0,U.useState)(null),[p,m]=(0,U.useState)(``),[h,g]=(0,U.useState)(``),{data:_=[],loading:v,error:y,run:b}=ct(qt,{ready:t&&e&&o===`catalog`}),x=_.filter(e=>e.name.toLowerCase().includes(l.toLowerCase())),C=()=>{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})},T=d?i.includes(d):!1,E=o===`catalog`&&(!d||T||v||!!y)||o===`repo`&&!p||o===`local`&&!h;return(0,$.jsx)(S,{open:e,onOpenChange:n,children:(0,$.jsxs)(w,{onCloseAutoFocus:e=>M(`[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)(O,{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)(k,{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)(I,{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:D(`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:D(`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:C,disabled:E,className:D(`h-7 px-3 rounded-md text-[11px] font-mono font-semibold`,E?`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)(w,{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)(O,{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,U.useState)([]),[c,l]=(0,U.useState)([]),[u,d]=(0,U.useState)(),[f,p]=(0,U.useState)(),[m,h]=(0,U.useState)(``),[g,_]=(0,U.useState)(``),[v,y]=(0,U.useState)(``),[b,C]=(0,U.useState)(``),[T,E]=(0,U.useState)(``),[D,A]=(0,U.useState)(``),[j,N]=(0,U.useState)(!1),[P,ee]=(0,U.useState)(!1),[te,re]=(0,U.useState)(!1),[ie,ae]=(0,U.useState)(!1),[F,L]=(0,U.useState)(null);(0,U.useEffect)(()=>{if(!e)return;let t=!0;return l([]),d(void 0),p(void 0),h(``),_(``),y(``),C(``),E(``),A(``),N(!1),L(null),ee(!0),x(`/providers`).then(e=>{t&&o(e)}).catch(e=>{t&&L(e instanceof Error?e.message:i(`settings.models.addModal.loadProvidersError`))}).finally(()=>{t&&ee(!1)}),()=>{t=!1}},[e,i]),(0,U.useEffect)(()=>{if(!u)return;let e=!0;return l([]),p(void 0),L(null),u.factoryWireApi||u.custom?(re(!1),()=>{e=!1}):(re(!0),x(`/providers/${u.id}/models`).then(t=>{e&&l(t)}).catch(t=>{e&&L(t instanceof Error?t.message:i(`settings.models.addModal.loadModelsError`))}).finally(()=>{e&&re(!1)}),()=>{e=!1})},[u,i]);let R=u?.factoryWireApi,z=!!(R||u?.custom),B=z?b.trim():f?.id,V=async()=>{if(!u||!B||!u.configured&&!D)return;if(R){if(!en.test(g.trim())){L(i(`settings.models.addModal.channelIdError`));return}let e;try{e=new URL(T.trim())}catch{L(i(`settings.models.addModal.invalidBaseUrl`));return}if(![`http:`,`https:`].includes(e.protocol)){L(i(`settings.models.addModal.invalidBaseUrl`));return}}ae(!0);let e=R?g.trim():u.id,r=await n({provider:e,model:B,displayName:m||(z?B:f?.name??``),apiKey:D||void 0,...R?{modelProvider:{id:e,name:v.trim()||e,baseUrl:T.trim(),wireApi:R}}:{}});ae(!1),r&&t(!1)};return(0,$.jsx)(S,{open:e,onOpenChange:t,children:(0,$.jsxs)(w,{onCloseAutoFocus:e=>M(`[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)(O,{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)(k,{className:`h-4 w-4`})})]}),(F||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)(ne,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{children:F||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:P,onChange:e=>{d(a.find(t=>t.id===e)),h(``),_(``),y(``),C(``),E(``)},placeholder:i(P?`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`):``}`}})})]}),z?(0,$.jsxs)($.Fragment,{children:[R&&(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),L(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=>{E(e.target.value),L(null)},placeholder:R===`anthropic-messages`?`https://gateway.example.com`:`https://gateway.example.com/v1`,className:`field`}),(0,$.jsx)(`span`,{className:`text-[11px] text-zinc-400`,children:i(R===`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=>{C(e.target.value),L(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||te,onChange:e=>{let t=c.find(t=>t.id===e);p(t),t&&h(t.name)},placeholder:i(te?`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:j?`text`:`password`,value:D,onChange:e=>A(e.target.value),className:`field w-full pr-10`,placeholder:i(`settings.models.addModal.apiKeyPlaceholder`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>N(!j),"aria-label":i(j?`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:j?(0,$.jsx)(oe,{className:`h-4 w-4`}):(0,$.jsx)(se,{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:ie||!u||!B||R&&(!g.trim()||!T.trim())||!u.configured&&(!u.supportsApiKey||D.trim().length===0),onClick:()=>void V(),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:[ie&&(0,$.jsx)(I,{className:`h-4 w-4 animate-spin`}),i(ie?`settings.models.addModal.saving`:`settings.models.addModal.saveModel`)]})]})]})})}function nn(e){let t=s(),[n,r]=(0,U.useState)(``),[i,a]=(0,U.useState)(``),[o,c]=(0,U.useState)(``),[l,u]=(0,U.useState)(``),[d,f]=(0,U.useState)(!1),[p,m]=(0,U.useState)(null);(0,U.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)(w,{onCloseAutoFocus:e=>M(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)(O,{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)(k,{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)(I,{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,U.useState)(e.name),[c,l]=(0,U.useState)(e.defaultBaseUrl??``),[u,d]=(0,U.useState)(e.wireApi??`openai-completions`),[f,p]=(0,U.useState)(e.apiKeyEnv??``),[m,h]=(0,U.useState)(``),[g,_]=(0,U.useState)(null),[v,y]=(0,U.useState)(!1);(0,U.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)(w,{onCloseAutoFocus:t=>M(`[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)(O,{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)(k,{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)(I,{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,U.useMemo)(()=>n??new URLSearchParams(window.location.search).get(`project`)??``,[n]),[a,o]=(0,U.useState)(null),[c,l]=(0,U.useState)(null),[u,d]=(0,U.useState)(``),[f,p]=(0,U.useState)(``),[m,h]=(0,U.useState)(!1),[g,v]=(0,U.useState)(null),[y,b]=(0,U.useState)(null),[S,C]=(0,U.useState)(null),w=(0,U.useRef)(0),T=(0,U.useRef)(i);T.current=i;let E=r?`${i}\0${r}`:``,O=(0,U.useRef)(E);O.current=E;let k=u===i?a:null,j=f===E?c:null,M=(0,U.useCallback)(async()=>{let t=++w.current;if(!i){o(null),l(null),d(``),p(``),C(null);return}h(!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),p(n?E:``)}catch(n){if(t!==w.current)return;C(n instanceof Error?n.message:e(`settings.hooks.loadFailed`))}finally{t===w.current&&h(!1)}},[i,r,E,e]);(0,U.useEffect)(()=>(b(null),M(),()=>{w.current+=1}),[M]);let N=async t=>{if(!k)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`&&k.currentDigest?{expectedDigest:k.currentDigest}:{}})});T.current===n&&(o(e),d(n),b(null))}catch(t){T.current===n&&C(t instanceof Error?t.message:e(`settings.hooks.updateFailed`))}finally{v(null)}},P=async t=>{if(!r||!j)return;let n=E;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})});O.current===n&&(l(e),p(n))}catch(t){O.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 ee=k?.state===`trusted`,te=k?.state===`untrusted`||k?.state===`modified`,ne=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:[ee?(0,$.jsx)(A,{className:`h-4 w-4 text-emerald-600`}):(0,$.jsx)(_,{className:D(`h-4 w-4`,te?`text-amber-600`:`text-[#71717a]`)}),(0,$.jsx)(`span`,{className:`text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]`,children:e(k?an[k.state]:`settings.hooks.heading`)}),m&&(0,$.jsx)(I,{className:`h-3.5 w-3.5 animate-spin`})]}),(0,$.jsx)(`p`,{className:`mt-1 break-all text-[10.5px] text-[#71717a]`,children:i}),k?.currentDigest&&(0,$.jsx)(`p`,{className:`mt-1 text-[10px] text-[#9CA3AF]`,children:k.currentDigest})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void M(),disabled:m||g!==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)(ae,{className:`h-3.5 w-3.5`}),e(`settings.common.reload`)]}),ee?(0,$.jsx)(`button`,{type:`button`,onClick:()=>b(`revoke`),disabled:g!==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:g!==null||!k?.currentDigest||k.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||g!==null||ne,onClick:()=>void P(j?.paused===!0),className:D(`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:D(`h-4 w-4 rounded-full bg-white transition-transform`,j?.enabled?`translate-x-5`:`translate-x-0`)})})]}),y&&k&&(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:k.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 N(y),disabled:g!==null,className:D(`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(g?`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:[(k?.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}`)),k&&k.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,U.useMemo)(()=>t??n??new URLSearchParams(window.location.search).get(`project`)??``,[n,t]),[i,a]=(0,U.useState)([]),[o,c]=(0,U.useState)([]),[l,u]=(0,U.useState)(sn),[d,f]=(0,U.useState)(!1),[p,m]=(0,U.useState)(``),[g,_]=(0,U.useState)(``),[v,y]=(0,U.useState)(``),[S,w]=(0,U.useState)(``),[T,E]=(0,U.useState)(!1),[O,k]=(0,U.useState)(null),[j,M]=(0,U.useState)(null),[N,P]=(0,U.useState)(``),[ee,te]=(0,U.useState)(``),[ne,ie]=(0,U.useState)(!1),[F,L]=(0,U.useState)(null),[z,B]=(0,U.useState)(`local`),oe=(0,U.useRef)(0),V=(0,U.useRef)(r);V.current=r;let se=S===r?i:[],ce=S===r?o:[],W=(0,U.useCallback)(async()=>{let t=++oe.current;if(!r){a([]),w(``),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!==oe.current)return;a(e),c(n);let o=i?.policy??sn;u(o),f(i?.environmentRequiresSha??!1),m(o.allowedGitHosts.join(`, `)),_(o.allowedMarketplaces.join(`, `)),y(o.allowedLocalRoots.join(`, `)),w(r)}catch(n){if(t!==oe.current)return;M(n instanceof Error?n.message:e(`settings.plugins.loadFailed`))}finally{t===oe.current&&E(!1)}},[r,e]);(0,U.useEffect)(()=>(W(),()=>{oe.current+=1}),[W]);let G=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:z})}),V.current===i&&await W()}catch(t){V.current===i&&M(t instanceof Error?t.message:e(`settings.plugins.updateFailed`))}finally{k(null)}},K=e=>[...new Set(e.split(`,`).map(e=>e.trim()).filter(Boolean))],le=async()=>{await q(`policy:save`,()=>x(`/plugins/policy`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({projectPath:r,scope:`local`,policy:{...l,allowedGitHosts:K(p),allowedMarketplaces:K(g),allowedLocalRoots:K(v)}})}))},q=async(t,n,i)=>{let a=r;k(t),M(null);try{await n(),V.current===a&&(i?.(),L(null),await W())}catch(t){V.current===a&&M(t instanceof Error?t.message:e(`settings.plugins.actionFailed`))}finally{k(null)}},J=async()=>{let e=N.trim();e&&ne&&await q(`install`,()=>x(`/plugins/install`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({projectPath:r,source:e,trust:!0})}),()=>{P(``),ie(!1)})},ue=async e=>{let t=`update:${e.name}`;if(F!==t){L(t);return}await q(t,()=>x(`/plugins/${encodeURIComponent(e.name)}/update`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({projectPath:r,trust:!0})}))},de=async e=>{let t=`uninstall:${e.name}`;if(F!==t){L(t);return}await q(t,()=>x(`/plugins/${encodeURIComponent(e.name)}/uninstall`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({projectPath:r,confirm:!0})}))},Y=async()=>{let e=ee.trim();e&&await q(`marketplace:add`,()=>x(`/plugins/marketplaces`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({projectPath:r,source:e})}),()=>te(``))},fe=async e=>{await q(`marketplace:refresh:${e.name}`,()=>x(`/plugins/marketplaces/${encodeURIComponent(e.name)}/refresh`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({projectPath:r})}))},pe=async e=>{let t=`marketplace:remove:${e.name}`;if(F!==t){L(t);return}await q(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)(re,{className:`h-4 w-4`}),e(`settings.plugins.heading`),T&&(0,$.jsx)(I,{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 W(),disabled:T||O!==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)(ae,{className:`h-3.5 w-3.5`}),e(`settings.common.reload`)]})]}),j&&(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:j}),(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)(A,{className:`h-3.5 w-3.5`}),e(`settings.plugins.sourcePolicy`)]}),(0,$.jsx)(`button`,{type:`button`,"aria-label":e(`settings.plugins.savePolicyAria`),onClick:()=>void le(),disabled:O!==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(O===`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:D(`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:D(`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:D(`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:D(`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:g,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=>y(e.target.value),placeholder:`/opt/approved/plugins`,className:`field h-7 px-2 text-[9.5px]`})]}),l.restrictToAllowedSources&&!p.trim()&&!g.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)(h,{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:N,onChange:e=>P(e.target.value),placeholder:`plugin@marketplace, owner/repo, or ./path`,disabled:O!==null,className:`field h-8 min-w-0 flex-1 px-2 text-[10.5px]`}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void J(),disabled:!N.trim()||!ne||O!==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:[O===`install`?(0,$.jsx)(I,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(h,{className:`h-3.5 w-3.5`}),e(`settings.plugins.install`)]})]}),(0,$.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":ne,onClick:()=>ie(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:D(`flex h-3.5 w-3.5 items-center justify-center rounded-sm border`,ne?`border-amber-600 bg-amber-600 text-white`:`border-[#D1D5DB] dark:border-[#52525b]`),children:ne?`✓`:``}),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":z===t.value,title:e(t.descriptionKey),onClick:()=>B(t.value),className:D(`rounded px-2 py-1 text-[9.5px] transition-colors`,z===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:[se.map(t=>{let n=O===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||O!==null,onClick:()=>void G(t,!t.enabled),className:D(`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:D(`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 ue(t),disabled:O!==null,className:D(`rounded px-1.5 py-1 text-[9px] disabled:opacity-40`,F===`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:O===`update:${t.name}`?(0,$.jsx)(I,{className:`h-3 w-3 animate-spin`}):F===`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 de(t),disabled:O!==null,className:D(`rounded px-1.5 py-1 text-[9px] disabled:opacity-40`,F===`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:O===`uninstall:${t.name}`?(0,$.jsx)(I,{className:`h-3 w-3 animate-spin`}):F===`uninstall:${t.name}`?e(`settings.plugins.confirmRemove`):(0,$.jsx)(C,{className:`h-3 w-3`})})]})]})]},t.name)}),!T&&se.length===0&&!j&&(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)(H,{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:ce.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:ee,onChange:e=>te(e.target.value),placeholder:`owner/repo, HTTPS Git URL, or ./path`,disabled:O!==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 Y(),disabled:!ee.trim()||O!==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:[O===`marketplace:add`?(0,$.jsx)(I,{className:`h-3 w-3 animate-spin`}):(0,$.jsx)(b,{className:`h-3 w-3`}),e(`settings.plugins.add`)]})]}),ce.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:O!==null,onClick:()=>void fe(t),className:`rounded p-1 text-[#9CA3AF] hover:bg-[#F3F4F6] disabled:opacity-40 dark:hover:bg-[#27272a]`,children:O===`marketplace:refresh:${t.name}`?(0,$.jsx)(I,{className:`h-3 w-3 animate-spin`}):(0,$.jsx)(ae,{className:`h-3 w-3`})}),(0,$.jsx)(`button`,{type:`button`,"aria-label":e(`settings.plugins.removeMarketplaceAria`,{name:t.name}),disabled:O!==null,onClick:()=>void pe(t),className:D(`rounded p-1 text-[#9CA3AF] disabled:opacity-40`,F===`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:F===`marketplace:remove:${t.name}`?(0,$.jsx)(`span`,{className:`px-1 text-[8.5px]`,children:e(`settings.plugins.confirm`)}):(0,$.jsx)(C,{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||O!==null,onClick:()=>{P(`${n.name}@${t.name}`),ie(!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)),!T&&ce.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,U.useMemo)(()=>t??new URLSearchParams(window.location.search).get(`project`)??``,[t]),[r,i]=(0,U.useState)(null),[a,o]=(0,U.useState)(``),[c,l]=(0,U.useState)(!1),[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(null),[m,h]=(0,U.useState)(null),[g,v]=(0,U.useState)(!1),y=(0,U.useRef)(0),b=(0,U.useRef)(n);b.current=n;let S=a===n?r:null,C=(0,U.useCallback)(async()=>{let t=++y.current;if(!n){i(null),o(``),h(null);return}l(!0),h(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;h(n instanceof Error?n.message:e(`settings.trust.loadFailed`))}finally{t===y.current&&l(!1)}},[n,e]);(0,U.useEffect)(()=>(p(null),v(!1),C(),()=>{y.current+=1}),[C]);let w=async t=>{if(!S)return;let r=n;d(t),h(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),p(null),v(e.reloadRequired===!0))}catch(t){b.current===r&&h(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 T=S?.state===`trusted`,E=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:[T?(0,$.jsx)(A,{className:`w-4 h-4 text-emerald-600`}):(0,$.jsx)(_,{className:D(`h-4 w-4`,E?`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)(I,{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)(ae,{className:`h-3.5 w-3.5`}),e(`settings.common.reload`)]}),T?(0,$.jsx)(`button`,{type:`button`,onClick:()=>p(`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:()=>p(`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`)})]})]}),(m||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:m||S?.error}),g&&(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:()=>p(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:D(`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:m,loadModels:h,isLoading:g,error:_}=E(),y=l(),[b,S]=(0,U.useState)(`general`),[w,T]=(0,U.useState)(!1),[O,k]=(0,U.useState)(null),[A,M]=(0,U.useState)(null),[N,P]=(0,U.useState)(null),[ee,re]=(0,U.useState)([]),[ae,F]=(0,U.useState)(null),[L,R]=(0,U.useState)(null),[z,B]=(0,U.useState)(null),[oe,V]=(0,U.useState)(null),[se,ce]=(0,U.useState)({}),[H,W]=(0,U.useState)(null),[G,K]=(0,U.useState)(null),[le,q]=(0,U.useState)(``),[J,ue]=(0,U.useState)(`all`),de=(0,U.useRef)(null),Y=(0,U.useRef)(null),fe=(0,U.useRef)(0),[pe,X]=(0,U.useState)(typeof Notification>`u`?`unsupported`:Notification.permission),me=[{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`)}],he=(0,U.useMemo)(()=>ie.map(t=>({action:e(mn[t.id]),combo:te(t),scope:t.scope})),[t]).filter(e=>{let t=e.action.toLowerCase().includes(le.toLowerCase()),n=J===`all`||e.scope.toLowerCase()===J;return t&&n}),Z=m.reduce((e,t)=>{let n=t.provider||`unknown`;return e[n]||(e[n]=[]),e[n].push(t),e},{}),ge=new Map(ee.map(e=>[e.id,e]));for(let e of ee)e.custom&&!Z[e.id]&&(Z[e.id]=[]);let _e=(0,U.useCallback)(async()=>{try{re(await x(`/providers`)),V(null)}catch(t){V(t instanceof Error?t.message:e(`settings.models.loadChannelsFailed`))}},[e]);(0,U.useEffect)(()=>{n&&(S(i),h(),_e(),y.loadSettings())},[n,h,_e,y.loadSettings,i]);let ve=()=>{let e=Y.current;(e?.isConnected?e:document.querySelector(`[data-settings-trigger]`))?.focus({preventScroll:!0})},Q=()=>{a(),requestAnimationFrame(ve)};(0,U.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]`)&&(Y.current=e);let t=requestAnimationFrame(()=>{de.current?.focus({preventScroll:!0})});return()=>{cancelAnimationFrame(t),requestAnimationFrame(ve)}},[n]);let ye=async t=>{W(`save`),K(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 h(),await _e(),!0}catch(t){return K(t instanceof Error?t.message:e(`settings.models.saveFailed`)),!1}finally{W(null)}},be=async()=>{typeof Notification<`u`&&X(await Notification.requestPermission())},xe=async t=>{W(`delete`),K(null);try{await x(`/models/${t}`,{method:`DELETE`}),await h(),P(null)}catch(t){K(t instanceof Error?t.message:e(`settings.models.deleteFailed`))}finally{W(null)}},Se=async(t,n)=>{W(`update`),K(null);try{return await x(`/models/${t}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}),await h(),!0}catch(t){return K(t instanceof Error?t.message:e(`settings.models.updateFailed`)),!1}finally{W(null)}},Ce=async(t,n)=>{B({providerId:t,type:`update`}),V(null);try{return await x(`/providers/${t}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}),await Promise.all([h(),_e()]),!0}catch(t){return V(t instanceof Error?t.message:e(`settings.models.updateChannelFailed`)),!1}finally{B(null)}},we=async(t,n)=>{B({providerId:t.id,type:`probe`}),V(null);try{let e=await x(`/providers/${t.id}/probe`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({modelId:n})});ce(n=>({...n,[t.id]:e}))}catch(t){V(t instanceof Error?t.message:e(`settings.models.probeFailed`))}finally{B(null)}},Te=async t=>{B({providerId:t.id,type:`delete`}),V(null);try{await x(`/providers/${t.id}?removeModels=true`,{method:`DELETE`}),R(null),k(null),ce(e=>{let n={...e};return delete n[t.id],n}),await Promise.all([h(),_e()])}catch(t){V(t instanceof Error?t.message:e(`settings.models.deleteChannelFailed`))}finally{B(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`?me.length-1:(t+n+me.length)%me.length;S(me[r].value),e.currentTarget.closest(`[role="tablist"]`)?.querySelectorAll(`[role="tab"]`)[r]?.focus()},De=e=>{k(O===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)||w||A||ae||Date.now()-fe.current<250)return;let t=e.target instanceof Element?e.target:null;if(!(e.defaultPrevented||t?.closest(`[role="dialog"]`))){if(e.preventDefault(),N){P(null);return}if(L){R(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:de,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)(p,{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(me.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:()=>S(e.value),onKeyDown:t=>Ee(t,me.indexOf(e)),role:`tab`,id:`settings-tab-${e.value}`,"aria-controls":`settings-panel-${e.value}`,"aria-selected":b===e.value,tabIndex:b===e.value?0:-1,className:D(`w-full rounded-md px-3 py-1.5 text-left text-[13px] transition-colors`,b===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:me.find(e=>e.value===b)?.label??e(`settings.title`)}),y.isLoading&&b===`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)(I,{className:`h-3.5 w-3.5 animate-spin`}),e(`settings.general.loading`)]}),y.error&&b===`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)(ne,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1 min-w-0`,children:y.error}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void y.loadSettings(),className:`underline shrink-0`,children:e(`settings.common.retry`)})]}),b===`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||oe)&&(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)(ne,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1 min-w-0`,children:oe||G||_}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{K(null),V(null),_&&h()},className:`underline shrink-0`,children:e(_?`settings.common.retry`:`settings.common.dismiss`)})]}),N&&(0,$.jsxs)(`div`,{role:`alertdialog`,"aria-label":e(`settings.models.deleteModelAria`,{name:N.displayName||N.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:N.displayName||N.model})}),(0,$.jsxs)(`div`,{className:`flex gap-2 items-center`,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:e(`settings.common.cancel`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void xe(N.id),disabled:H!==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(H===`delete`?`settings.models.deleting`:`settings.models.deleteModel`)})]})]}),L&&(0,$.jsxs)(`div`,{role:`alertdialog`,"aria-label":e(`settings.models.deleteChannelAria`,{name:L.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:L.name,count:Z[L.id]?.length??0})}),(0,$.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>R(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(L),disabled:z!==null,className:`h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60`,children:z?.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:[g&&m.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)(I,{className:`w-4 h-4 animate-spin`}),e(`settings.models.loading`)]}),Object.entries(Z).map(([t,n])=>{let r=pn[t]||{bg:`#71717a`,label:`?`},i=ge.get(t),a=O===t,o=se[t],s=z?.providerId===t&&z.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:D(`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)(j,{className:D(`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:z!==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)(I,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(d,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`button`,{type:`button`,"data-edit-provider-trigger":i.id,onClick:()=>{V(null),F(i)},disabled:z!==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)(v,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>R(i),disabled:z!==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)(C,{className:`h-3.5 w-3.5`})})]})]}),o&&(0,$.jsxs)(`div`,{role:`status`,className:D(`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:()=>{K(null),M(t)},disabled:H!==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)(v,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`button`,{onClick:()=>P(t),disabled:H!==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)(C,{className:`h-3.5 w-3.5`})})]})]},t.id))]})]},t)}),!g&&!_&&Object.keys(Z).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:()=>{K(null),T(!0)},disabled:H!==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`)})]}),b===`general`&&(0,$.jsxs)(`div`,{id:`settings-panel-general`,role:`tabpanel`,"aria-labelledby":`settings-tab-general`,"aria-busy":y.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:y.language,onChange:e=>y.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:y.autoSaveSessions,onChange:e=>y.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:f(t,`settingsTitle`)}),(0,$.jsx)(`span`,{className:`text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono`,children:f(t,`settingsHint`)})]}),(0,$.jsx)(vn,{label:f(t,`settingsTitle`),enabled:y.agentTeamsEnabled,onChange:e=>y.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:y.communicationStyle??`auto`,onChange:e=>y.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:()=>y.updateSettings({uiTheme:t}),className:D(`px-3 py-1 rounded text-[12px] font-mono transition-colors`,y.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:y.codeTheme,onChange:e=>y.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:y.notifyBuild,onChange:e=>y.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:y.notifyErrors,onChange:e=>y.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:y.notifySounds,onChange:e=>y.updateSettings({notifySounds:e})})]}),(y.notifyBuild||y.notifyErrors)&&pe!==`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(pe===`denied`?`settings.notifications.blocked`:pe===`unsupported`?`settings.notifications.unavailable`:`settings.notifications.enablePrompt`)}),pe==="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:y.privacyTelemetry,onChange:e=>y.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:y.privacyCrash,onChange:e=>y.updateSettings({privacyCrash:e})})]})]})]}),b===`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:le,onChange:e=>q(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:J,onChange:e=>ue(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:()=>{q(``),ue(`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`)})]}),he.map((t,n)=>(0,$.jsxs)(`div`,{className:D(`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}`)),he.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`)})]})]}),b===`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:b===`mcp`})}),b===`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:b===`skills`})}),b===`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,{})}),b===`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,{})}),b===`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:b===`schedules`})}),b===`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,{})})]})})})]}),w&&(0,$.jsx)(tn,{open:!0,onOpenChange:e=>{e||(fe.current=Date.now()),T(e)},onSave:ye,saveError:G}),A&&(0,$.jsx)(nn,{open:!0,onOpenChange:e=>{e||(fe.current=Date.now(),M(null))},model:A,onSave:Se,saveError:G}),ae&&(0,$.jsx)(rn,{provider:ae,onOpenChange:e=>{e||(fe.current=Date.now(),F(null))},onSave:Ce,saveError:oe})]})}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:D(`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:D(`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};
|
|
@@ -1 +0,0 @@
|
|
|
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-BuMTbIwu.js";import{C as a}from"./vendor-radix-L0yJCKJX.js";import{c as o,i as s,l as c,s as l}from"./preload-helper-DvgLbiBV.js";import{t as u}from"./archive-CsFSEMp9.js";import{t as d}from"./chevron-right-Bvu2j6hB.js";import{t as f}from"./download-BR2L5Wme.js";import{t as p}from"./pencil-DkC0bPYD.js";import{t as m}from"./plus-kzdwas-3.js";import{t as h}from"./settings-msYyNDKx.js";import{t as g}from"./terminal-Cp5WYo8w.js";import{A as _,C as v,J as y,K as b,M as x,O as S,P as C,Q as ee,U as w,W as T,d as E,et as D,f as O,ft as k,gt as te,h as A,i as j,j as M,k as ne,n as N,nt as P,p as F,q as re,r as I,s as ie,st as L,t as R,ut as z,vt as ae,w as oe,x as B,y as V}from"./index-DSa8Dzp7.js";import{t as se}from"./ScrollArea-BdOqyQ3g.js";var ce={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`}]]};ce.node;var le=c(ce),H={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};H.node;var ue=c(H),U={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`]};U.node;var de=c(U),W={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`}]]};W.node;var fe=c(W),G={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`}]]};G.node;var pe=c(G),me={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`}]]};me.node;var he=c(me),K=e(n(),1);async function ge(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 q=a();function _e(){let e=o(),n=V(e=>e.archivedSessions),r=V(e=>e.archivedCatalogLoadState),a=V(e=>e.archivedCatalogError),s=V(e=>e.loadArchivedSessions),c=V(e=>e.unarchiveSession),l=V(e=>e.setError),d=V(e=>i(e.historySurfaceSelection)),[p,m]=(0,K.useState)(!1),[h,g]=(0,K.useState)(null),[v,y]=(0,K.useState)(null),b=e=>{e&&t(V.getState())||(m(e),e&&s())},x=()=>{t(V.getState())||s()};return d?null:(0,q.jsxs)(E,{open:p,onOpenChange:b,children:[(0,q.jsx)(F,{asChild:!0,children:(0,q.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,q.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[(0,q.jsx)(u,{className:`h-3.5 w-3.5 text-[hsl(var(--deck-ink-faint))]`}),e(`archive.title`)]}),n.length>0&&(0,q.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,q.jsxs)(O,{role:`dialog`,"aria-label":e(`archive.title`),side:`right`,align:`end`,sideOffset:8,className:`w-[340px] overflow-hidden p-0`,children:[(0,q.jsxs)(`div`,{className:`flex h-10 items-center justify-between border-b border-[hsl(var(--deck-hairline))] px-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`font-mono text-[11px] font-medium uppercase tracking-[0.08em] text-[hsl(var(--deck-ink))]`,children:e(`archive.title`)}),(0,q.jsx)(`div`,{className:`text-[9.5px] text-[hsl(var(--deck-ink-faint))]`,children:e(`archive.subtitle`)})]}),(0,q.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,q.jsx)(P,{className:w(`h-3 w-3`,(r===`loading`||r===`hydrating`)&&`animate-spin`)})})]}),a?(0,q.jsxs)(`div`,{className:`px-3 py-4 text-[11px] text-red-600 dark:text-red-400`,children:[(0,q.jsx)(`div`,{children:a}),(0,q.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,q.jsxs)(`div`,{className:`flex h-24 items-center justify-center gap-2 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]`,children:[(0,q.jsx)(L,{className:`h-3 w-3 animate-spin`}),e(`archive.loading`)]}):n.length===0?(0,q.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,q.jsx)(se,{className:`max-h-[340px]`,children:(0,q.jsx)(`div`,{className:`divide-y divide-[hsl(var(--deck-hairline))]`,children:n.map(n=>{let r=_(n),i=M(r),a=h===i,o=n.projectPath.split(`/`).filter(Boolean).at(-1)??n.projectPath;return(0,q.jsxs)(`div`,{className:`flex min-h-[58px] items-center gap-2 px-3 py-2`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`div`,{className:`truncate font-mono text-[11.5px] text-[hsl(var(--deck-ink))]`,children:I(n,e)}),(0,q.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,q.jsx)(`span`,{className:`truncate`,children:o}),n.archivedAt&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,q.jsx)(`span`,{children:new Date(n.archivedAt).toLocaleString()})]})]}),n.archivedBySessionId!==n.sessionId&&(0,q.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,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,q.jsx)(`button`,{type:`button`,disabled:v!==null,onClick:async()=>{if(!t(V.getState())){y(i);try{await ge(r)}catch(e){l(e instanceof Error?e.message:`Session export failed`)}finally{y(null)}}},"aria-label":e(`session.action.export`,{title:I(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:v===i?(0,q.jsx)(L,{className:`h-3.5 w-3.5 animate-spin`}):(0,q.jsx)(f,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(`button`,{type:`button`,disabled:a||n.archivedBySessionId!==n.sessionId,onClick:async()=>{if(!t(V.getState())){g(i);try{await c(r)}finally{g(null)}}},"aria-label":e(`archive.restore`,{title:I(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,q.jsx)(L,{className:`h-3.5 w-3.5 animate-spin`}):(0,q.jsx)(le,{className:`h-3.5 w-3.5`})})]})]},i)})})})]})]})}var ve={en:`sidebar.language.en`,zh:`sidebar.language.zh`};function ye({className:e,variant:t=`pill`}){let{locale:n,setLocale:r}=l(),i=o();if(t===`compact`){let t=n===`en`?`zh`:`en`;return(0,q.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(ve[n])})}return(0,q.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,q.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(ve[e])},e)})})}function be({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,q.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,q.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,q.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,q.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,q.jsxs)(`span`,{className:`flex-1 min-w-0 font-mono`,children:[(0,q.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,q.jsx)(`span`,{className:`truncate`,children:i}),(0,q.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,q.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,q.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,q.jsx)(`span`,{className:`mt-0.5 block truncate text-[9.5px] text-[hsl(var(--deck-ink-faint))]`,children:e.displayCwd})]})]})]})}var xe={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 Se({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:ee,onEditingTitleChange:k,onSaveRename:A,onCancelRename:j}){let M=o(),[ne,N]=(0,K.useState)(!1),P=(0,K.useRef)(null),I=(0,K.useRef)(null);return a?(0,q.jsxs)(`div`,{className:`flex h-9 w-full items-center gap-2 bg-[hsl(var(--deck-surface))] px-3`,children:[(0,q.jsx)(`input`,{type:`text`,value:s,onChange:e=>k(e.target.value),onKeyDown:e=>{e.key===`Enter`&&A(),e.key===`Escape`&&j()},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,q.jsx)(`button`,{"aria-label":M(`session.action.save`,{title:c}),onClick:A,className:`flex h-6 w-6 items-center justify-center rounded text-[hsl(var(--deck-accent))] hover:bg-[hsl(var(--deck-canvas))]`,children:(0,q.jsx)(ae,{className:`w-3 h-3`})}),(0,q.jsx)(`button`,{"aria-label":M(`session.action.cancel`,{title:c}),onClick:j,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,q.jsx)(T,{className:`w-3 h-3`})})]}):(0,q.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,q.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,q.jsxs)(`button`,{type:`button`,"aria-label":M(`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,q.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)]`:xe[e.taskStatus]),title:e.pendingInteraction?M(e.pendingInteraction.type===`question`?`interaction.badge.question`:e.pendingInteraction.type===`elicitation`?`interaction.badge.elicitation`:`interaction.badge.permission`):e.taskStatus}),(0,q.jsxs)(`span`,{className:`flex-1 min-w-0 font-mono`,children:[(0,q.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,q.jsx)(`span`,{className:`truncate`,children:c}),r&&(0,q.jsx)(`span`,{title:M(`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,q.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:M(e.pendingInteraction.type===`question`?`interaction.badge.question`:e.pendingInteraction.type===`elicitation`?`interaction.badge.elicitation`:`interaction.badge.permission`),children:[(0,q.jsx)(te,{className:`h-2.5 w-2.5`}),M(e.pendingInteraction.type===`question`?`interaction.badge.question`:e.pendingInteraction.type===`elicitation`?`interaction.badge.elicitation`:`interaction.badge.permission`)]}),e.relationType===`fork`&&e.parentId&&(0,q.jsxs)(`span`,{title:`${M(`session.forkedFrom`)} ${e.parentId.slice(0,6)}`,"aria-label":`${M(`session.forkedFrom`)} ${e.parentId.slice(0,6)}`,className:`shrink-0 text-[9px] text-[hsl(var(--deck-accent))]`,children:[M(`session.forkedFrom`),` `,e.parentId.slice(0,6)]}),e.taskRetriedFrom&&(0,q.jsx)(`span`,{title:`${M(`session.retriedFrom`)} ${e.taskRetriedFrom.sessionId.slice(0,6)}`,className:`shrink-0 text-[9px] text-[hsl(var(--deck-accent))]`,children:M(`session.retryShort`)})]}),(0,q.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,q.jsx)(`span`,{className:`truncate`,children:l.project}),(0,q.jsx)(`span`,{className:`opacity-50`,children:`·`}),(0,q.jsx)(`span`,{className:`truncate`,children:l.environment}),l.queue&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`opacity-50`,children:`·`}),(0,q.jsx)(`span`,{className:`text-amber-700 truncate dark:text-amber-400`,children:l.queue})]}),l.diff&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`opacity-50`,children:`·`}),(0,q.jsx)(`span`,{className:`truncate text-[hsl(var(--deck-accent))]`,children:l.diff})]})]}),l.reason&&(0,q.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,q.jsx)(L,{className:`h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]`})]}),(0,q.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,q.jsx)(`button`,{type:`button`,"aria-label":M(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,q.jsx)(L,{className:`h-3 w-3 animate-spin`}):(0,q.jsx)(re,{className:`h-3 w-3`})}),e.taskRetryAvailable&&(e.taskStatus===`failed`||e.taskStatus===`interrupted`||e.taskStatus===`cancelled`)&&(0,q.jsx)(`button`,{ref:P,type:`button`,"aria-label":M(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,q.jsx)(L,{className:`h-3 w-3 animate-spin`}):(0,q.jsx)(D,{className:`h-3 w-3`})}),(0,q.jsxs)(E,{open:ne,onOpenChange:N,children:[(0,q.jsx)(F,{asChild:!0,children:(0,q.jsx)(`button`,{type:`button`,"aria-label":M(`session.action.more`,{title:c}),"aria-expanded":ne,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,q.jsx)(de,{className:`h-3.5 w-3.5`})})}),(0,q.jsxs)(O,{ref:I,role:`menu`,"aria-label":M(`session.action.more`,{title:c}),side:`right`,align:`start`,sideOffset:6,className:`w-40 p-1`,onOpenAutoFocus:e=>{e.preventDefault(),I.current?.querySelector(`[role="menuitem"]:not([disabled])`)?.focus()},onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),N(!1),window.setTimeout(()=>P.current?.focus(),0))},children:[(0,q.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-label":M(`session.action.fork`,{title:c}),disabled:i,onClick:e=>{e.stopPropagation(),y(),N(!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,q.jsx)(fe,{className:`h-3 w-3`,"aria-hidden":!0}),M(`session.action.forkShort`)]}),(0,q.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-label":M(`session.action.rename`,{title:c}),onClick:e=>{C(e),N(!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,q.jsx)(p,{className:`h-3 w-3`,"aria-hidden":!0}),M(`session.action.renameShort`)]}),(0,q.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-label":M(`session.action.archive`,{title:c}),disabled:e.taskStatus===`running`||e.taskStatus===`queued`,onClick:e=>{e.stopPropagation(),x(),N(!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,q.jsx)(u,{className:`h-3 w-3`,"aria-hidden":!0}),M(`session.action.archiveShort`)]}),(0,q.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-label":M(`session.action.export`,{title:c}),disabled:h,onClick:e=>{e.stopPropagation(),S(),N(!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,q.jsx)(L,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):(0,q.jsx)(f,{className:`h-3 w-3`,"aria-hidden":!0}),M(h?`session.action.exportingShort`:`session.action.exportShort`)]}),(0,q.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-label":M(`session.action.delete`,{title:c}),onClick:e=>{ee(e),N(!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,q.jsx)(b,{className:`h-3 w-3`,"aria-hidden":!0}),M(`session.action.deleteShort`)]})]})]})]})]})}function Ce({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 _=o(),v=[{icon:h,action:a,labelKey:`sidebar.section.settings`}];return(0,q.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,q.jsx)(`button`,{onClick:e,className:`rounded-md p-1 transition-colors hover:bg-[hsl(var(--deck-surface))]`,"aria-label":_(`sidebar.action.expand`),children:(0,q.jsx)(ie,{size:28})}),(0,q.jsx)(`button`,{onClick:t,"aria-label":_(`sidebar.action.newTaskShort`),title:_(`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,q.jsx)(m,{className:`h-4 w-4 stroke-[2.5]`})}),(0,q.jsx)(`button`,{type:`button`,onClick:n,"aria-label":_(`sidebar.action.taskBoard`),"aria-current":u?`page`:void 0,title:_(`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,q.jsx)(he,{className:`h-4 w-4`})}),(0,q.jsx)(`button`,{onClick:i,disabled:d,"aria-label":_(`sidebar.action.terminalToggle`),title:_(`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,q.jsx)(g,{className:`w-4 h-4`})}),(0,q.jsxs)(`button`,{onClick:r,disabled:f,"aria-label":_(`sidebar.action.searchTasks`),title:`${_(`sidebar.action.searchTasks`)} (${A(`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,q.jsx)(ee,{className:`h-4 w-4`}),l>0&&(0,q.jsx)(`span`,{"aria-label":_(`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,q.jsx)(`div`,{className:`flex-1`}),(0,q.jsx)(`div`,{className:`my-2 h-px w-6 bg-[hsl(var(--deck-hairline))]`}),v.map(({icon:e,action:t,labelKey:n})=>(0,q.jsx)(`button`,{"data-settings-trigger":!0,onClick:t,"aria-label":_(n),title:_(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,q.jsx)(e,{className:`w-4 h-4`})},n)),(0,q.jsx)(ye,{variant:`compact`}),(0,q.jsx)(`div`,{className:`mt-1`,children:(0,q.jsx)(`div`,{role:`status`,"aria-label":_(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:_(c?`sidebar.status.feedLive`:`sidebar.status.feedOffline`)})})]})}var we=`blade.sidebar.project-order.v1`;function J(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 Te(){if(typeof window>`u`)return[];try{let e=JSON.parse(window.localStorage.getItem(`blade.sidebar.project-order.v1`)??`[]`);return Array.isArray(e)?J(e):[]}catch{return[]}}function Y(e){if(typeof window<`u`)try{window.localStorage.setItem(we,JSON.stringify(J(e)))}catch{}}function Ee(e,t){let n=new Map(J(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 X(e,t,n){let r=J(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 De(e,t,n){let r=J(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 Oe({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,q.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,q.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,q.jsx)(pe,{className:`h-3.5 w-3.5`})}),(0,q.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,q.jsx)(d,{className:w(`h-3 w-3 text-[hsl(var(--deck-ink-faint))] transition-transform duration-150`,!c&&`rotate-90`)})}),(0,q.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,q.jsx)(k,{className:w(`h-3.5 w-3.5 shrink-0`,i?`text-[hsl(var(--deck-accent))]`:`text-[hsl(var(--deck-ink-faint))]`)}),(0,q.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,q.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,q.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,q.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]`,children:[n.toString().padStart(2,`0`),r?`+`:``]})]}),f&&(0,q.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,q.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=M(_(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(R);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=oe(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(R),r=t.reduce((e,t)=>Math.max(e,N(t)),0);return{path:e,name:v(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,y]=(0,K.useState)({}),[b,x]=(0,K.useState)({}),[C,ee]=(0,K.useState)(Te),[T,E]=(0,K.useState)(null),[D,O]=(0,K.useState)(null),[k,A]=(0,K.useState)(``),j=l===`ready`||n.length>0,N=l===`loading`||l===`hydrating`,F=N||l===`error`,re=j?n.length:t.length,I=(0,K.useMemo)(()=>e===`status`?Me(t):[],[t,e]),ie=(0,K.useMemo)(()=>e===`project`?Ne(t,r,i.map(e=>e.path)):[],[r,i,t,e]),R=(0,K.useMemo)(()=>Ee(ie,C),[ie,C]),z=(0,K.useMemo)(()=>{if(!j)return[];let e=new Map(t.map(e=>[M(_(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(M(n)),o=ze(t,a);i.push({kind:`local`,path:a?oe(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]),ae=(0,K.useMemo)(()=>!j||e!==`status`?[]:Fe.flatMap(e=>{let t=He(z.filter(t=>Be(t)===e));return t.length===0?[]:[{code:Re[e],entries:t}]}),[z,j,e]),B=(0,K.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 z){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:v(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),Ee(s,C)},[r,i,z,C,j,e]),V=(0,K.useMemo)(()=>e===`project`?He(z.filter(e=>e.kind===`remote`)):[],[z,e]),se=e=>e.kind===`local`&&!!e.session.pendingInteraction,ce=e=>e.kind===`local`&&c.includes(M(_(e.session))),le=e=>e.kind===`local`?!!(a&&S(_(e.session),a)):!!(s&&ne(e.summary.locator,s.locator)),H=(e,t)=>{let n=b[e]??!1,r=n?t:t.filter((e,t)=>{if(t<Pe)return!0;let n=_(e);return!!e.pendingInteraction||c.includes(M(n))||!!(a&&S(n,a))}),i=t.length-r.length,o=n?t.length>Pe:i>0;return(0,q.jsxs)(q.Fragment,{children:[r.map(p),o&&(0,q.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})})]})},ue=(e,t)=>{let n=b[e]??!1,r=n?t:t.filter((e,t)=>t<Pe||se(e)||ce(e)||le(e)),i=t.length-r.length,a=n?t.length>Pe:i>0;return(0,q.jsxs)(q.Fragment,{children:[r.map(e=>e.kind===`local`?p(e.session):m(e.summary)),a&&(0,q.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})})]})},U=N?(0,q.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,q.jsx)(L,{className:`h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]`}),(0,q.jsx)(`span`,{className:`flex-1 min-w-0`,children:h(`sidebar.catalog.syncing`)}),(0,q.jsx)(`span`,{className:`tabular-nums shrink-0`,children:h(`sidebar.catalog.loaded`,{count:re})})]}):l===`error`?(0,q.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,q.jsx)(te,{className:`w-3 h-3 shrink-0`}),(0,q.jsx)(`span`,{className:`flex-1 min-w-0`,children:h(`sidebar.catalog.incomplete`)}),(0,q.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,q.jsx)(P,{className:`h-2.5 w-2.5`}),h(`sidebar.catalog.retry`)]})]}):null;if(j){if(e===`status`)return(0,q.jsxs)(`div`,{className:`flex flex-col`,children:[U,ae.map((e,t)=>(0,q.jsxs)(`div`,{children:[(0,q.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,q.jsx)(`span`,{children:h(Ie[e.code])}),(0,q.jsxs)(`span`,{className:`text-[hsl(var(--deck-ink-faint))]`,children:[e.entries.length.toString().padStart(2,`0`),F?`+`:``]})]}),ue(`status:${e.code}`,e.entries)]},e.code))]});let t=B.some(e=>e.isActive||e.entries.some(le)),n=e=>e.entries.some(le),r=(e,t)=>{if(e.join(`\0`)===B.map(e=>e.path).join(`\0`))return;ee(e),Y(e);let n=B.find(e=>e.path===t);A(h(`sidebar.project.reordered`,{name:n?.name??t,position:e.indexOf(t)+1}))};return(0,q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,q.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:k}),U,V.length>0&&(0,q.jsxs)(`section`,{"data-remote-session-group":!0,children:[(0,q.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,q.jsx)(`span`,{children:h(`sidebar.project.remoteSessions`)}),(0,q.jsx)(`span`,{children:V.length.toString().padStart(2,`0`)})]}),ue(`remote-sessions`,V)]}),B.length>0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.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`)}),B.map((e,i)=>{let a=e.entries.filter(ce).length,o=n(e),s=a>0,c=e.entries.some(se),l=g[e.path]??(t&&!e.isActive&&!(o||e.hasRunning||s||c));return(0,q.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(X(B.map(e=>e.path),n,e.path),n),E(null),O(null)},className:w(`relative transition-colors`,D===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,q.jsx)(Oe,{name:e.name,path:e.path,count:e.entries.length,countIsPartial:F,isActive:e.isActive,hasRunning:e.hasRunning,unreadCount:a,collapsed:l,onSelect:()=>u(e.path),onCreateTask:()=>d(e.path),reorderPosition:i+1,reorderCount:B.length,isDragging:T===e.path,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.path),E(e.path)},onDragEnd:()=>{E(null),O(null)},onReorderKeyDown:t=>{if(t.key!==`ArrowUp`&&t.key!==`ArrowDown`)return;t.preventDefault();let n=De(B.map(e=>e.path),e.path,t.key===`ArrowUp`?-1:1);r(n,e.path)},onToggle:()=>y(t=>({...t,[e.path]:!l}))}),!l&&ue(`project:${e.path}`,e.entries)]},e.path)})]})]})}if(e===`status`)return(0,q.jsxs)(`div`,{className:`flex flex-col`,children:[U,I.map((e,t)=>(0,q.jsxs)(`div`,{children:[(0,q.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,q.jsx)(`span`,{children:h(Ie[e.code])}),(0,q.jsxs)(`span`,{className:`text-[hsl(var(--deck-ink-faint))]`,children:[e.sessions.length.toString().padStart(2,`0`),F?`+`:``]})]}),H(`status:${e.code}`,e.sessions)]},e.code))]});let de=R.some(e=>e.isActive),W=e=>!!(a&&e.sessions.some(e=>S(_(e),a))),fe=(e,t)=>{if(e.join(`\0`)===R.map(e=>e.path).join(`\0`))return;ee(e),Y(e);let n=R.find(e=>e.path===t);A(h(`sidebar.project.reordered`,{name:n?.name??t,position:e.indexOf(t)+1}))};return(0,q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,q.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:k}),U,R.length>0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.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`)}),R.map((e,t)=>{let n=e.sessions.filter(e=>c.includes(M(_(e)))).length,r=W(e),i=n>0,a=e.sessions.some(e=>!!e.pendingInteraction),o=g[e.path]??(de&&!e.isActive&&!(r||e.hasRunning||i||a));return(0,q.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&&fe(X(R.map(e=>e.path),n,e.path),n),E(null),O(null)},className:w(`relative transition-colors`,D===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,q.jsx)(Oe,{name:e.name,path:e.path,count:e.sessions.length,countIsPartial:F,isActive:e.isActive,hasRunning:e.hasRunning,unreadCount:n,collapsed:o,onSelect:()=>u(e.path),onCreateTask:()=>d(e.path),reorderPosition:t+1,reorderCount:R.length,isDragging:T===e.path,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.path),E(e.path)},onDragEnd:()=>{E(null),O(null)},onReorderKeyDown:t=>{if(t.key!==`ArrowUp`&&t.key!==`ArrowDown`)return;t.preventDefault();let n=De(R.map(e=>e.path),e.path,t.key===`ArrowUp`?-1:1);fe(n,e.path)},onToggle:()=>y(t=>({...t,[e.path]:!o}))}),!o&&H(`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:v,mainView:b,setMainView:C,setBoardProjectPath:T,setFilePreviewOpen:E}=r(),D=V(e=>e.sessions),O=V(e=>e.surfaceCatalog),k=V(e=>e.surfaceCatalogLoadState),te=V(e=>e.historySurfaceSelection),N=i(te),P=V(e=>e.currentSessionRef),F=V(e=>e.forkingSessionRef),re=V(e=>e.selectSession),L=V(e=>e.openHistorySurface),R=V(e=>e.startTemporarySession),ae=V(e=>e.deleteSession),oe=V(e=>e.archiveSession),ce=V(e=>e.forkSession),le=V(e=>e.updateSession),H=V(e=>e.loadSessions),U=V(e=>e.loadSurfaceCatalog),de=V(e=>e.setError),W=V(e=>e.taskEventsConnected),fe=V(e=>e.taskWorkspaceInfo),G=V(e=>e.boundProjects),pe=V(e=>e.selectedProjectPath),me=V(e=>e.bindProject),ve=V(e=>e.selectProject),xe=V(e=>e.cancelTask),we=V(e=>e.cancellingTaskKeys),J=V(e=>e.retryTask),Te=V(e=>e.retryingTaskKeys),Y=V(e=>e.unreadTaskKeys),[Ee,X]=(0,K.useState)(null),[De,Oe]=(0,K.useState)(``),[ke,Ae]=(0,K.useState)(null),[Z,je]=(0,K.useState)(!1),Me=pe??fe?.cwd??null,Ne=e=>I(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:B(e,a)}},Fe=()=>{C(`workspace`),R(Me??void 0),n?.()},Ie=()=>{V.getState().closeHistorySurface(),E(!1),T(Me),C(`board`),n?.()},Le=async e=>{G.some(t=>t.path===e)?ve(e):await me(e),C(`workspace`),R(e),n?.()},Re=async e=>{G.some(t=>t.path===e)?ve(e):await me(e),C(`workspace`),R(e),n?.()},Q=e=>{e(),n?.()},$=()=>{t(V.getState())||Q(d)},ze=async(e,n)=>{e.stopPropagation(),!t(V.getState())&&await ae(_(n))},Be=async e=>{if(t(V.getState()))return;let n=_(e),r=M(n);if(!ke){Ae(r);try{await ge(n)}catch(e){de(e instanceof Error?e.message:`Session export failed`)}finally{Ae(null)}}},Ve=(e,n)=>{e.stopPropagation(),!t(V.getState())&&(X(M(_(n))),Oe(Ne(n)))},He=async e=>{if(!t(V.getState())){if(!De.trim()){X(null);return}try{await le(_(e),De.trim()),X(null),await H()}catch(e){console.error(`Failed to rename session:`,e)}}},We=()=>{X(null),Oe(``)};return l?(0,q.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,q.jsxs)(`div`,{className:`flex flex-col gap-6 px-5 pt-5 pb-5`,children:[(0,q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,q.jsx)(ie,{size:26}),(0,q.jsx)(`span`,{className:`font-mono text-[15px] font-semibold tracking-[-0.01em] text-[hsl(var(--deck-ink))]`,children:`Blade`}),(0,q.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,q.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,q.jsx)(ue,{className:`h-3 w-3 text-[hsl(var(--deck-ink-muted))]`})})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.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,q.jsxs)(`span`,{className:`flex gap-2 items-center`,children:[(0,q.jsx)(m,{className:`h-3.5 w-3.5 stroke-[2.5]`}),a(`sidebar.action.newTask`)]}),(0,q.jsx)(`span`,{className:`rounded-sm bg-white/10 px-1.5 py-[1px] font-mono text-[10px] text-white/80`,children:A(`newTask`)})]}),(0,q.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,q.jsx)(he,{className:`h-3.5 w-3.5`}),a(`sidebar.action.taskBoard`)]}),(0,q.jsxs)(`button`,{onClick:$,disabled:N,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,q.jsx)(g,{className:`h-3.5 w-3.5`}),a(`sidebar.action.terminal`)]}),!N&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>Q(()=>v(!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,q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(ee,{className:`h-3.5 w-3.5`}),a(`sidebar.action.searchTasks`)]}),(0,q.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:Y.length>0?Y.length:A(`searchTasks`)})]})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.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,q.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,q.jsx)(`button`,{type:`button`,onClick:()=>je(!0),disabled:N,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,q.jsx)(z,{className:`h-3.5 w-3.5`})})]})]}),(0,q.jsx)(se,{className:`flex-1 px-0`,children:(0,q.jsxs)(`div`,{className:`flex flex-col`,children:[(D.length>0||O.length>0||G.length>0||k===`loading`||k===`hydrating`||k===`error`)&&(0,q.jsx)(Ue,{view:f,sessions:D,surfaceCatalog:O,activeProjectPath:Me,boundProjects:G,currentSessionRef:P,historySurfaceSelection:te,unreadTaskKeys:Y,catalogLoadState:k,onRetryCatalog:()=>{U()},onSelectProject:e=>void Le(e).catch(()=>void 0),onCreateTask:e=>void Re(e).catch(()=>void 0),renderLocalRow:e=>{let r=_(e),i=M(r),a=S(r,P),o=Ee===i,s=S(r,F),c=!!F;return(0,q.jsx)(Se,{session:e,sessionRef:r,isActive:a,isForking:s,isUnread:Y.includes(M(r)),anyForking:c,isEditing:o,editingTitle:De,title:Ne(e),context:Pe(e),isCancelling:we.includes(M(r)),isRetrying:Te.includes(M(r)),isExporting:ke===i,onSelect:()=>(n?.(),C(`workspace`),re(r)),onCancelTask:()=>{t(V.getState())||xe(r).catch(()=>void 0)},onRetryTask:()=>{t(V.getState())||J(r).catch(()=>void 0)},onFork:()=>{t(V.getState())||ce(e)},onArchive:()=>{t(V.getState())||oe(r)},onExport:()=>void Be(e),onStartRename:t=>Ve(t,e),onDelete:t=>ze(t,e),onEditingTitleChange:Oe,onSaveRename:()=>He(e),onCancelRename:We},i)},renderRemoteRow:e=>(0,q.jsx)(be,{summary:e,isActive:ne(e.locator,te?.locator),onSelect:()=>(n?.(),C(`workspace`),L(e.locator))},x(e.locator))}),O.length===0&&D.length===0&&(0,q.jsx)(`div`,{className:`px-5 mt-6`,children:(0,q.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,q.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,q.jsx)(y,{className:`h-3.5 w-3.5 text-[hsl(var(--deck-ink-faint))]`})}),(0,q.jsx)(`div`,{className:`font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]`,children:a(`sidebar.empty.title`)}),(0,q.jsx)(`div`,{className:`mt-1 text-[10.5px] text-[hsl(var(--deck-ink-faint))]`,children:a(`sidebar.empty.hint`)})]})})]})}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 px-5 pt-3 pb-5`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-0.5 border-t border-[hsl(var(--deck-hairline))] pt-3`,children:[!N&&(0,q.jsx)(_e,{}),[{icon:h,action:()=>Q(s),labelKey:`sidebar.section.settings`}].map(({icon:e,action:t,labelKey:n})=>(0,q.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,q.jsx)(e,{className:`h-3.5 w-3.5 text-[hsl(var(--deck-ink-faint))]`}),a(n)]},n))]}),(0,q.jsxs)(`div`,{className:`flex gap-2 justify-between items-center`,children:[(0,q.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[0.14em] text-[hsl(var(--deck-ink-faint))]`,children:a(`sidebar.language.label`)}),(0,q.jsx)(ye,{})]}),(0,q.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,q.jsx)(`div`,{className:`flex h-7 w-7 items-center justify-center rounded-md bg-[hsl(var(--deck-canvas-veil))]`,children:(0,q.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-[hsl(var(--deck-ink))]`})}),(0,q.jsxs)(`div`,{className:`flex flex-1 flex-col gap-[1px]`,children:[(0,q.jsx)(`span`,{className:`font-mono text-[12px] text-[hsl(var(--deck-ink))]`,children:a(`sidebar.status.user`)}),(0,q.jsxs)(`span`,{className:w(`flex gap-1 items-center font-mono text-[10px]`,W?`text-[hsl(var(--deck-accent))]`:`text-[hsl(var(--deck-ink-faint))]`),children:[(0,q.jsx)(`span`,{className:w(`h-1 w-1 rounded-full`,W?`bg-[hsl(var(--deck-accent))] shadow-[0_0_5px_hsl(var(--deck-accent-glow)/0.9)]`:`bg-[hsl(var(--deck-ink-faint))]/60`)}),a(W?`sidebar.status.feedLive`:`sidebar.status.feedOffline`)]})]})]})]}),!N&&(0,q.jsx)(j,{open:Z,onOpenChange:je})]}):(0,q.jsx)(Ce,{className:e,onExpand:c,onNewChat:Fe,onOpenBoard:Ie,onOpenTaskSwitcher:()=>Q(()=>v(!0)),onToggleTerminal:$,onToggleSettings:()=>Q(s),isTerminalOpen:u,taskEventsConnected:W,unreadCount:Y.length,boardActive:b===`board`,terminalDisabled:N,taskSwitcherDisabled:N})}export{We as Sidebar};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{l as e}from"./preload-helper-DvgLbiBV.js";var t={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};t.node;var n=e(t);export{n as t};
|