blade-code 0.10.8 → 0.10.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blade.js +3 -3
- package/dist/{chunk-nymm525r.js → chunk-095x2ykj.js} +1 -1
- package/dist/{chunk-zvk3g177.js → chunk-17g172md.js} +1 -1
- package/dist/{chunk-j4tttsaz.js → chunk-25cqav2f.js} +2 -2
- package/dist/{chunk-6vsszvgg.js → chunk-27dr7bz0.js} +2 -2
- package/dist/{chunk-yfs9tq3y.js → chunk-2c9ssx8y.js} +2 -2
- package/dist/{chunk-cbpqcdga.js → chunk-2wmnzxfz.js} +1 -1
- package/dist/{chunk-vgp8m9fg.js → chunk-2zwyvfbm.js} +2 -2
- package/dist/chunk-39xzkky9.js +1 -0
- package/dist/chunk-3e5etzj8.js +2 -0
- package/dist/{chunk-v8pq6qmv.js → chunk-41wym9fn.js} +2 -2
- package/dist/{chunk-8sfycn3y.js → chunk-469ht1ty.js} +3 -3
- package/dist/{chunk-8gcvpmwk.js → chunk-484ve631.js} +1 -1
- package/dist/chunk-4gegd63m.js +1 -0
- package/dist/{chunk-wmnszjmv.js → chunk-4gkn11cb.js} +2 -2
- package/dist/chunk-4gptj397.js +1 -0
- package/dist/chunk-4v7h259s.js +2 -0
- package/dist/chunk-4xsqe5sn.js +2 -0
- package/dist/chunk-4yh4yeep.js +1 -0
- package/dist/chunk-5410er6c.js +1 -0
- package/dist/{chunk-fj8v7pep.js → chunk-5ehe3xra.js} +1 -1
- package/dist/{chunk-b5szbtmp.js → chunk-60764481.js} +2 -2
- package/dist/{chunk-2thg3fq1.js → chunk-686at39n.js} +1 -1
- package/dist/{chunk-r7tsa2zv.js → chunk-6c1qjy1v.js} +1 -1
- package/dist/{chunk-8h0yxh6y.js → chunk-6rcwvrd1.js} +1 -1
- package/dist/{chunk-y4c3wwpa.js → chunk-7by8mhzq.js} +1 -1
- package/dist/{chunk-g00wj2we.js → chunk-8g4n4578.js} +1 -1
- package/dist/{chunk-eq2qj9ja.js → chunk-8j01ssaf.js} +1 -1
- package/dist/{chunk-7zsyejr1.js → chunk-9dd2qmky.js} +1 -1
- package/dist/{chunk-a8h3fymk.js → chunk-afbky4f9.js} +2 -2
- package/dist/chunk-amp9a6rq.js +2 -0
- package/dist/{chunk-kagpk2x5.js → chunk-b3qwhhpy.js} +2 -2
- package/dist/{chunk-xa05phpw.js → chunk-bzvwcyma.js} +3 -3
- package/dist/{chunk-fxpq9nh6.js → chunk-c23vgww8.js} +1 -1
- package/dist/chunk-cgk8cft8.js +1 -0
- package/dist/chunk-cr7ncgsh.js +6 -0
- package/dist/chunk-dg6abzwy.js +1 -0
- package/dist/{chunk-954vmnrn.js → chunk-e0vwbx8b.js} +1 -1
- package/dist/chunk-e2f1kgt4.js +1 -0
- package/dist/{chunk-van4ysq6.js → chunk-f8nw8dcq.js} +277 -262
- package/dist/{chunk-h421wzbm.js → chunk-gk1wq9rv.js} +2 -2
- package/dist/{chunk-d0g4t8fw.js → chunk-gv15jmxf.js} +1 -1
- package/dist/chunk-h4azdqke.js +10 -0
- package/dist/{chunk-pv9sw79c.js → chunk-h7szqxtg.js} +2 -2
- package/dist/{chunk-qgp08qmz.js → chunk-jdy3ceqv.js} +1 -1
- package/dist/{chunk-m2xrx1je.js → chunk-jxhpwm5k.js} +2 -2
- package/dist/{chunk-w0nscjd2.js → chunk-jzn1qtrc.js} +2 -2
- package/dist/chunk-k0n4prs1.js +2 -0
- package/dist/{chunk-7hbw6q6d.js → chunk-kg4xd3yf.js} +1 -1
- package/dist/chunk-m4b00d6v.js +1 -0
- package/dist/{chunk-vsg8f0e6.js → chunk-mzgwy44f.js} +1 -1
- package/dist/{chunk-8gcg2z3y.js → chunk-n2hn6tn2.js} +2 -2
- package/dist/chunk-n4e454dw.js +2 -0
- package/dist/{chunk-33ave20b.js → chunk-ncxavkjp.js} +1 -1
- package/dist/chunk-nezwz71s.js +1 -0
- package/dist/{chunk-s9aj3p11.js → chunk-ns9emet3.js} +1 -1
- package/dist/chunk-p7s0rwk3.js +1 -0
- package/dist/{chunk-nhc49pan.js → chunk-p839x5dd.js} +1 -1
- package/dist/chunk-qtypjqb8.js +3 -0
- package/dist/{chunk-xmcsn7y0.js → chunk-r7mhhrp6.js} +2 -2
- package/dist/chunk-racbf4zb.js +1 -0
- package/dist/chunk-smpky1s8.js +1 -0
- package/dist/{chunk-8gnfj89a.js → chunk-st9vr8w3.js} +2 -2
- package/dist/{chunk-senkwdh6.js → chunk-tfefpqz1.js} +1 -1
- package/dist/{chunk-66hb7kxm.js → chunk-vtwvwcz9.js} +2 -2
- package/dist/chunk-wc7dt3vm.js +1 -0
- package/dist/{chunk-rxqft6td.js → chunk-wr9p5hk3.js} +2 -2
- package/dist/chunk-xnb07jbj.js +1 -0
- package/dist/{chunk-cf8e7e92.js → chunk-y9d70cks.js} +2 -2
- package/dist/{chunk-h28ptrrt.js → chunk-ybvdac8k.js} +1 -1
- package/dist/{chunk-4h9ff923.js → chunk-zns1crmz.js} +1 -1
- package/dist/web/assets/{ChatView-Fqy97qw9.js → ChatView-BPzsdviX.js} +2 -2
- package/dist/web/assets/{CodeBlockHighlighter-EgdsVoMQ.js → CodeBlockHighlighter-7DiEw-B3.js} +1 -1
- package/dist/web/assets/{FilePreview-xicd9-Sl.js → FilePreview-5FjwAe93.js} +2 -2
- package/dist/web/assets/{MarkdownRenderer-DBSjC_z3.js → MarkdownRenderer-CjsMv0q1.js} +3 -3
- package/dist/web/assets/SettingsModal-EPwoV6vp.js +5 -0
- package/dist/web/assets/{TaskSwitcher-DXcj0iJ_.js → TaskSwitcher-BOKaxmnf.js} +1 -1
- package/dist/web/assets/{TerminalPanel-DWVY-Elm.js → TerminalPanel-CZJYrbjQ.js} +1 -1
- package/dist/web/assets/index-CU-jckjp.css +1 -0
- package/dist/web/assets/index-I_DKONsY.js +32 -0
- package/dist/web/assets/{vendor-icons-Cv18Q6rW.js → vendor-icons-ICv1v-tf.js} +71 -66
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/dist/chunk-1w6azndv.js +0 -1
- package/dist/chunk-2gwaqpge.js +0 -1
- package/dist/chunk-2pjd4cys.js +0 -1
- package/dist/chunk-2zn5en0w.js +0 -1
- package/dist/chunk-3w1z6fwm.js +0 -1
- package/dist/chunk-43x4qbvt.js +0 -1
- package/dist/chunk-52csdk21.js +0 -3
- package/dist/chunk-6j8wgp2s.js +0 -2
- package/dist/chunk-7evtr0yr.js +0 -10
- package/dist/chunk-bxm2hq0m.js +0 -1
- package/dist/chunk-c8da4b3d.js +0 -1
- package/dist/chunk-kvnwhwx3.js +0 -1
- package/dist/chunk-nz57y1ad.js +0 -6
- package/dist/chunk-p2m56new.js +0 -2
- package/dist/chunk-rkvfsx8e.js +0 -2
- package/dist/chunk-v1c58sm6.js +0 -1
- package/dist/chunk-w26jhcj9.js +0 -1
- package/dist/chunk-x6wgh726.js +0 -1
- package/dist/chunk-ymzcxryf.js +0 -1
- package/dist/chunk-zknv3d6y.js +0 -2
- package/dist/chunk-zp4x2mwj.js +0 -1
- package/dist/web/assets/SettingsModal-Bkh5rMAJ.js +0 -5
- package/dist/web/assets/index-Bi5ijAQP.css +0 -1
- package/dist/web/assets/index-CxEh32hc.js +0 -32
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{r,e as qe,g as Rt,j as e}from"./vendor-react-DG5dkZ_t.js";import{u as me,j as D,v as z,D as Fe,e as Pe,w as Ke,g as Be,a as Ue,P as Jt,x as Yt,y as Vt,S as Qt,z as Xt,b as Zt,A as ea,E as ta,K as aa,F as sa}from"./index-CxEh32hc.js";import{_ as ae,n as X,o as ue,p as rt,q as lt,r as Ot}from"./vendor-radix-DXRuAJHH.js";import{a as Se,i as ct,f as Re,L as ne,k as na,_ as pt,C as Dt,D as ot,X as Oe,T as _e,y as Lt,a8 as ra,a9 as la,u as ut,Z as $t,O as oa,aa as ia,ab as da,ac as ca,P as ft}from"./vendor-icons-Cv18Q6rW.js";var ua=function(t){return function(a,s){var l=r.useRef(!1);t(function(){return function(){l.current=!1}},[]),t(function(){if(!l.current)l.current=!0;else return a()},s)}},It=function(t){return typeof t=="function"},ve=function(t){var a=r.useRef(t);a.current=r.useMemo(function(){return t},[t]);var s=r.useRef(void 0);return s.current||(s.current=function(){for(var l=[],n=0;n<arguments.length;n++)l[n]=arguments[n];return a.current.apply(this,l)}),s.current};const Xe=ua(r.useEffect);var Ut=function(t,a){var s=a.manual,l=a.ready,n=l===void 0?!0:l,m=a.defaultParams,f=m===void 0?[]:m,g=a.refreshDeps,u=g===void 0?[]:g,i=a.refreshDepsAction,j=r.useRef(!1);return j.current=!1,Xe(function(){!s&&n&&(j.current=!0,t.run.apply(t,ae([],X(f),!1)))},[n]),Xe(function(){j.current||s||(j.current=!0,i?i():t.refresh())},ae([],X(u),!1)),{onBefore:function(){if(!n)return{stopNow:!0}}}};Ut.onInit=function(t){var a=t.ready,s=a===void 0?!0:a,l=t.manual;return{loading:!l&&s}};function it(t,a){if(t===a)return!0;for(var s=0;s<t.length;s++)if(!Object.is(t[s],a[s]))return!1;return!0}var _t=function(t,a){var s=r.useRef({deps:a,obj:void 0,initialized:!1}).current;return(s.initialized===!1||!it(s.deps,a))&&(s.deps=a,s.obj=t(),s.initialized=!0),s.obj};function et(t){var a=r.useRef(t);return a.current=t,a}var He=function(t){var a=et(t);r.useEffect(function(){return function(){a.current()}},[])},Je=new Map,ma=function(t,a,s){var l=Je.get(t);l!=null&&l.timer&&clearTimeout(l.timer);var n=void 0;a>-1&&(n=setTimeout(function(){Je.delete(t)},a)),Je.set(t,ue(ue({},s),{timer:n}))},xa=function(t){return Je.get(t)},Ye=new Map,pa=function(t){return Ye.get(t)},fa=function(t,a){Ye.set(t,a),a.then(function(s){return Ye.delete(t),s}).catch(function(){Ye.delete(t)})},Ce={},ga=function(t,a){Ce[t]&&Ce[t].forEach(function(s){return s(a)})},at=function(t,a){return Ce[t]||(Ce[t]=[]),Ce[t].push(a),function(){var l=Ce[t].indexOf(a);Ce[t].splice(l,1)}},ha=function(t,a){var s=a.cacheKey,l=a.cacheTime,n=l===void 0?5*60*1e3:l,m=a.staleTime,f=m===void 0?0:m,g=a.setCache,u=a.getCache,i=r.useRef(void 0),j=r.useRef(void 0),c=function(b,x){g?g(x):ma(b,n,x),ga(b,x.data)},h=function(b,x){return x===void 0&&(x=[]),u?u(x):xa(b)};return _t(function(){if(s){var b=h(s);b&&Object.hasOwnProperty.call(b,"data")&&(t.state.data=b.data,t.state.params=b.params,(f===-1||Date.now()-b.time<=f)&&(t.state.loading=!1)),i.current=at(s,function(x){t.setState({data:x})})}},[]),He(function(){var b;(b=i.current)===null||b===void 0||b.call(i)}),s?{onBefore:function(b){var x=h(s,b);return!x||!Object.hasOwnProperty.call(x,"data")?{}:f===-1||Date.now()-x.time<=f?{loading:!1,data:x==null?void 0:x.data,error:void 0,returnNow:!0}:{data:x==null?void 0:x.data,error:void 0}},onRequest:function(b,x){var E=pa(s);return E&&E!==j.current?{servicePromise:E}:(E=b.apply(void 0,ae([],X(x),!1)),j.current=E,fa(s,E),{servicePromise:E})},onSuccess:function(b,x){var E;s&&((E=i.current)===null||E===void 0||E.call(i),c(s,{data:b,params:x,time:Date.now()}),i.current=at(s,function(N){t.setState({data:N})}))},onMutate:function(b){var x;s&&((x=i.current)===null||x===void 0||x.call(i),c(s,{data:b,params:t.state.params,time:Date.now()}),i.current=at(s,function(E){t.setState({data:E})}))}}:{}};function ba(t){var a=typeof t;return t!=null&&(a=="object"||a=="function")}var mt=ba,va=typeof qe=="object"&&qe&&qe.Object===Object&&qe,ka=va,ja=ka,ya=typeof self=="object"&&self&&self.Object===Object&&self,Ea=ja||ya||Function("return this")(),Kt=Ea,Na=Kt,wa=function(){return Na.Date.now()},Ca=wa,Aa=/\s/;function Sa(t){for(var a=t.length;a--&&Aa.test(t.charAt(a)););return a}var Fa=Sa,Pa=Fa,Ba=/^\s+/;function Ta(t){return t&&t.slice(0,Pa(t)+1).replace(Ba,"")}var Ma=Ta,Ra=Kt,Oa=Ra.Symbol,Ht=Oa,gt=Ht,zt=Object.prototype,Da=zt.hasOwnProperty,La=zt.toString,Ie=gt?gt.toStringTag:void 0;function $a(t){var a=Da.call(t,Ie),s=t[Ie];try{t[Ie]=void 0;var l=!0}catch{}var n=La.call(t);return l&&(a?t[Ie]=s:delete t[Ie]),n}var Ia=$a,Ua=Object.prototype,_a=Ua.toString;function Ka(t){return _a.call(t)}var Ha=Ka,ht=Ht,za=Ia,Ga=Ha,Wa="[object Null]",qa="[object Undefined]",bt=ht?ht.toStringTag:void 0;function Ja(t){return t==null?t===void 0?qa:Wa:bt&&bt in Object(t)?za(t):Ga(t)}var Ya=Ja;function Va(t){return t!=null&&typeof t=="object"}var Qa=Va,Xa=Ya,Za=Qa,es="[object Symbol]";function ts(t){return typeof t=="symbol"||Za(t)&&Xa(t)==es}var as=ts,ss=Ma,vt=mt,ns=as,kt=NaN,rs=/^[-+]0x[0-9a-f]+$/i,ls=/^0b[01]+$/i,os=/^0o[0-7]+$/i,is=parseInt;function ds(t){if(typeof t=="number")return t;if(ns(t))return kt;if(vt(t)){var a=typeof t.valueOf=="function"?t.valueOf():t;t=vt(a)?a+"":a}if(typeof t!="string")return t===0?t:+t;t=ss(t);var s=ls.test(t);return s||os.test(t)?is(t.slice(2),s?2:8):rs.test(t)?kt:+t}var cs=ds,us=mt,st=Ca,jt=cs,ms="Expected a function",xs=Math.max,ps=Math.min;function fs(t,a,s){var l,n,m,f,g,u,i=0,j=!1,c=!1,h=!0;if(typeof t!="function")throw new TypeError(ms);a=jt(a)||0,us(s)&&(j=!!s.leading,c="maxWait"in s,m=c?xs(jt(s.maxWait)||0,a):m,h="trailing"in s?!!s.trailing:h);function b(S){var F=l,T=n;return l=n=void 0,i=S,f=t.apply(T,F),f}function x(S){return i=S,g=setTimeout(B,a),j?b(S):f}function E(S){var F=S-u,T=S-i,k=a-F;return c?ps(k,m-T):k}function N(S){var F=S-u,T=S-i;return u===void 0||F>=a||F<0||c&&T>=m}function B(){var S=st();if(N(S))return $(S);g=setTimeout(B,E(S))}function $(S){return g=void 0,h&&l?b(S):(l=n=void 0,f)}function y(){g!==void 0&&clearTimeout(g),i=0,l=u=n=g=void 0}function C(){return g===void 0?f:$(st())}function H(){var S=st(),F=N(S);if(l=arguments,n=this,u=S,F){if(g===void 0)return x(u);if(c)return clearTimeout(g),g=setTimeout(B,a),b(u)}return g===void 0&&(g=setTimeout(B,a)),f}return H.cancel=y,H.flush=C,H}var Gt=fs;const Wt=Rt(Gt);var gs=function(t,a){var s=a.debounceWait,l=a.debounceLeading,n=a.debounceTrailing,m=a.debounceMaxWait,f=r.useRef(void 0),g=r.useMemo(function(){var u={};return l!==void 0&&(u.leading=l),n!==void 0&&(u.trailing=n),m!==void 0&&(u.maxWait=m),u},[l,n,m]);return r.useEffect(function(){if(s){var u=t.runAsync.bind(t);return f.current=Wt(function(i){i()},s,g),t.runAsync=function(){for(var i=[],j=0;j<arguments.length;j++)i[j]=arguments[j];return new Promise(function(c,h){var b;(b=f.current)===null||b===void 0||b.call(f,function(){u.apply(void 0,ae([],X(i),!1)).then(c).catch(h)})})},function(){var i;(i=f.current)===null||i===void 0||i.cancel(),t.runAsync=u}}},[s,g]),s?{onCancel:function(){var u;(u=f.current)===null||u===void 0||u.cancel()}}:{}},hs=function(t,a){var s=a.loadingDelay,l=a.ready,n=r.useRef(void 0);if(!s)return{};var m=function(){n.current&&clearTimeout(n.current)};return{onBefore:function(){return m(),l!==!1&&(n.current=setTimeout(function(){t.setState({loading:!0})},s)),{loading:!1}},onFinally:function(){m()},onCancel:function(){m()}}},ze=!!(typeof window<"u"&&window.document&&window.document.createElement);function xt(){return ze?document.visibilityState!=="hidden":!0}var Ve=new Set;function bs(t){return Ve.add(t),function(){Ve.has(t)&&Ve.delete(t)}}if(ze){var vs=function(){xt()&&Ve.forEach(function(t){return t()})};window.addEventListener("visibilitychange",vs,!1)}var ks=function(t,a){var s=a.pollingInterval,l=a.pollingWhenHidden,n=l===void 0?!0:l,m=a.pollingErrorRetryCount,f=m===void 0?-1:m,g=r.useRef(void 0),u=r.useRef(void 0),i=r.useRef(0),j=function(){var c;g.current&&clearTimeout(g.current),(c=u.current)===null||c===void 0||c.call(u)};return Xe(function(){s||j()},[s]),s?{onBefore:function(){j()},onError:function(){i.current+=1},onSuccess:function(){i.current=0},onFinally:function(){f===-1||f!==-1&&i.current<=f?g.current=setTimeout(function(){!n&&!xt()?u.current=bs(function(){t.refresh()}):t.refresh()},s):i.current=0},onCancel:function(){j()}}:{}};function js(t,a){var s=!1;return function(){for(var l=[],n=0;n<arguments.length;n++)l[n]=arguments[n];s||(s=!0,t.apply(void 0,ae([],X(l),!1)),setTimeout(function(){s=!1},a))}}var ys=function(){return ze&&typeof navigator.onLine<"u"?navigator.onLine:!0},Qe=new Set;function Es(t){return Qe.add(t),function(){Qe.has(t)&&Qe.delete(t)}}if(ze){var yt=function(){!xt()||!ys()||Qe.forEach(function(t){return t()})};window.addEventListener("visibilitychange",yt,!1),window.addEventListener("focus",yt,!1)}var Ns=function(t,a){var s=a.refreshOnWindowFocus,l=a.focusTimespan,n=l===void 0?5e3:l,m=r.useRef(void 0),f=function(){var g;(g=m.current)===null||g===void 0||g.call(m)};return r.useEffect(function(){if(s){var g=js(t.refresh.bind(t),n);m.current=Es(function(){g()})}return function(){f()}},[s,n]),He(function(){f()}),{}},ws=function(t,a){var s=a.retryInterval,l=a.retryCount,n=r.useRef(void 0),m=r.useRef(0),f=r.useRef(!1);return l?{onBefore:function(){f.current||(m.current=0),f.current=!1,n.current&&clearTimeout(n.current)},onSuccess:function(){m.current=0},onError:function(){if(m.current+=1,l===-1||m.current<=l){var g=s??Math.min(1e3*Math.pow(2,m.current),3e4);n.current=setTimeout(function(){f.current=!0,t.refresh()},g)}else m.current=0},onCancel:function(){m.current=0,n.current&&clearTimeout(n.current)}}:{}},Cs=Gt,As=mt,Ss="Expected a function";function Fs(t,a,s){var l=!0,n=!0;if(typeof t!="function")throw new TypeError(Ss);return As(s)&&(l="leading"in s?!!s.leading:l,n="trailing"in s?!!s.trailing:n),Cs(t,a,{leading:l,maxWait:a,trailing:n})}var Ps=Fs;const Bs=Rt(Ps);var Ts=function(t,a){var s=a.throttleWait,l=a.throttleLeading,n=a.throttleTrailing,m=r.useRef(void 0),f={};return l!==void 0&&(f.leading=l),n!==void 0&&(f.trailing=n),r.useEffect(function(){if(s){var g=t.runAsync.bind(t);return m.current=Bs(function(u){u()},s,f),t.runAsync=function(){for(var u=[],i=0;i<arguments.length;i++)u[i]=arguments[i];return new Promise(function(j,c){var h;(h=m.current)===null||h===void 0||h.call(m,function(){g.apply(void 0,ae([],X(u),!1)).then(j).catch(c)})})},function(){var u;t.runAsync=g,(u=m.current)===null||u===void 0||u.cancel()}}},[s,l,n]),s?{onCancel:function(){var g;(g=m.current)===null||g===void 0||g.cancel()}}:{}},Ms=function(t){r.useEffect(function(){var a=t==null?void 0:t();if(!(a&&typeof a=="object"&&typeof a.then=="function"))return a},[])},Rs=function(){var t=X(r.useState({}),2),a=t[1];return ve(function(){return a({})})},Os=function(){function t(a,s,l,n){n===void 0&&(n={}),this.serviceRef=a,this.options=s,this.subscribe=l,this.initState=n,this.pluginImpls=[],this.count=0,this.state={loading:!1,params:void 0,data:void 0,error:void 0},this.state=ue(ue(ue({},this.state),{loading:!s.manual}),n)}return t.prototype.setState=function(a){a===void 0&&(a={}),this.state=ue(ue({},this.state),a),this.subscribe()},t.prototype.runPluginHandler=function(a){for(var s=[],l=1;l<arguments.length;l++)s[l-1]=arguments[l];var n=this.pluginImpls.map(function(m){var f;return(f=m[a])===null||f===void 0?void 0:f.call.apply(f,ae([m],X(s),!1))}).filter(Boolean);return Object.assign.apply(Object,ae([{}],X(n),!1))},t.prototype.runAsync=function(){for(var a=[],s=0;s<arguments.length;s++)a[s]=arguments[s];return rt(this,void 0,void 0,function(){var l,n,m,f,g,u,i,j,c,h,b,x,E,N,B,$,y,C,H,S,F;return lt(this,function(T){switch(T.label){case 0:if(this.count+=1,l=this.count,n=this.runPluginHandler("onBefore",a),m=n.stopNow,f=m===void 0?!1:m,g=n.returnNow,u=g===void 0?!1:g,i=Ot(n,["stopNow","returnNow"]),f)return[2,Promise.resolve(i.data)];if(this.setState(ue({loading:!0,params:a},i)),u)return[2,Promise.resolve(i.data)];(E=(x=this.options).onBefore)===null||E===void 0||E.call(x,a),T.label=1;case 1:return T.trys.push([1,3,,4]),j=this.runPluginHandler("onRequest",this.serviceRef.current,a).servicePromise,j||(j=(b=this.serviceRef).current.apply(b,ae([],X(a),!1))),[4,j];case 2:return c=T.sent(),l!==this.count?[2,new Promise(function(){})]:(this.setState({data:c,error:void 0,loading:!1}),(B=(N=this.options).onSuccess)===null||B===void 0||B.call(N,c,a),this.runPluginHandler("onSuccess",c,a),(y=($=this.options).onFinally)===null||y===void 0||y.call($,a,c,void 0),l===this.count&&this.runPluginHandler("onFinally",a,c,void 0),[2,c]);case 3:if(h=T.sent(),l!==this.count)return[2,new Promise(function(){})];throw this.setState({error:h,loading:!1}),(H=(C=this.options).onError)===null||H===void 0||H.call(C,h,a),this.runPluginHandler("onError",h,a),(F=(S=this.options).onFinally)===null||F===void 0||F.call(S,a,void 0,h),l===this.count&&this.runPluginHandler("onFinally",a,void 0,h),h;case 4:return[2]}})})},t.prototype.run=function(){for(var a=this,s=[],l=0;l<arguments.length;l++)s[l]=arguments[l];this.runAsync.apply(this,ae([],X(s),!1)).catch(function(n){a.options.onError||console.error(n)})},t.prototype.cancel=function(){this.count+=1,this.setState({loading:!1}),this.runPluginHandler("onCancel")},t.prototype.refresh=function(){this.run.apply(this,ae([],X(this.state.params||[]),!1))},t.prototype.refreshAsync=function(){return this.runAsync.apply(this,ae([],X(this.state.params||[]),!1))},t.prototype.mutate=function(a){var s=It(a)?a(this.state.data):a;this.runPluginHandler("onMutate",s),this.setState({data:s})},t}();function Ds(t,a,s){a===void 0&&(a={}),s===void 0&&(s=[]);var l=a.manual,n=l===void 0?!1:l,m=a.ready,f=m===void 0?!0:m,g=Ot(a,["manual","ready"]),u=ue({manual:n,ready:f},g),i=et(t),j=Rs(),c=_t(function(){var h=s.map(function(b){var x;return(x=b==null?void 0:b.onInit)===null||x===void 0?void 0:x.call(b,u)}).filter(Boolean);return new Os(i,u,j,Object.assign.apply(Object,ae([{}],X(h),!1)))},[]);return c.options=u,c.pluginImpls=s.map(function(h){return h(c,u)}),Ms(function(){if(!n&&f){var h=c.state.params||a.defaultParams||[];c.run.apply(c,ae([],X(h),!1))}}),He(function(){c.cancel()}),{loading:c.state.loading,data:c.state.data,error:c.state.error,params:c.state.params||[],cancel:ve(c.cancel.bind(c)),refresh:ve(c.refresh.bind(c)),refreshAsync:ve(c.refreshAsync.bind(c)),run:ve(c.run.bind(c)),runAsync:ve(c.runAsync.bind(c)),mutate:ve(c.mutate.bind(c))}}function Me(t,a,s){return Ds(t,a,ae(ae([],X([]),!1),[gs,hs,ks,Ns,Ts,Ut,ha,ws],!1))}function Ze(t,a){if(ze){if(!t)return a;var s;return It(t)?s=t():"current"in t?s=t.current:s=t,s}}var Ls=function(t){var a=function(s,l,n){var m=r.useRef(!1),f=r.useRef([]),g=r.useRef([]),u=r.useRef(void 0);t(function(){var i,j=Array.isArray(n)?n:[n],c=j.map(function(h){return Ze(h)});if(!m.current){m.current=!0,f.current=c,g.current=l,u.current=s();return}(c.length!==f.current.length||!it(f.current,c)||!it(g.current,l))&&((i=u.current)===null||i===void 0||i.call(u),f.current=c,g.current=l,u.current=s())}),He(function(){var i;(i=u.current)===null||i===void 0||i.call(u),m.current=!1})};return a},$s=Ls(r.useEffect);function Is(){var t=(typeof global>"u"?"undefined":typeof global)=="object"&&global&&global.Object===Object&&global,a=typeof self=="object"&&self&&self.Object===Object&&self;return t||a}Is()||(global.Date=Date);function Us(t,a){var s,l=et(t),n=(s=a==null?void 0:a.wait)!==null&&s!==void 0?s:1e3,m=r.useMemo(function(){return Wt(function(){for(var f=[],g=0;g<arguments.length;g++)f[g]=arguments[g];return l.current.apply(l,ae([],X(f),!1))},n,a)},[]);return He(function(){m.cancel()}),{run:m,cancel:m.cancel,flush:m.flush}}function _s(t,a,s){s===void 0&&(s={});var l=s.enable,n=l===void 0?!0:l,m=et(a);$s(function(){if(n){var f=Ze(s.target,window);if(f!=null&&f.addEventListener){var g=function(i){return m.current(i)},u=Array.isArray(t)?t:[t];return u.forEach(function(i){f.addEventListener(i,g,{capture:s.capture,once:s.once,passive:s.passive})}),function(){u.forEach(function(i){f.removeEventListener(i,g,{capture:s.capture})})}}}},[t,s.capture,s.once,s.passive,n],s.target)}var Ks=function(t){return t===document||t===document.documentElement||t===document.body?Math.max(window.pageYOffset,document.documentElement.scrollTop,document.body.scrollTop):t.scrollTop},Et=function(t){return t.scrollHeight||Math.max(document.documentElement.scrollHeight,document.body.scrollHeight)},Hs=function(t){return t.clientHeight||Math.max(document.documentElement.clientHeight,document.body.clientHeight)},zs=function(t,a){a===void 0&&(a={});var s=a.target,l=a.isNoMore,n=a.threshold,m=n===void 0?100:n,f=a.direction,g=f===void 0?"bottom":f,u=a.reloadDeps,i=u===void 0?[]:u,j=a.manual,c=a.onBefore,h=a.onSuccess,b=a.onError,x=a.onFinally,E=X(r.useState(),2),N=E[0],B=E[1],$=X(r.useState(!1),2),y=$[0],C=$[1],H=g==="top",S=r.useRef(void 0),F=r.useRef(0),T=r.useMemo(function(){return l?l(N):!1},[N]),k=Me(function(L){return rt(void 0,void 0,void 0,function(){var w;return lt(this,function(v){switch(v.label){case 0:return[4,t(L)];case 1:return w=v.sent(),[2,{currentData:w,lastData:L}]}})})},{manual:j,onFinally:function(L,w,v){C(!1),x==null||x(w==null?void 0:w.currentData,v)},onBefore:function(){return c==null?void 0:c()},onSuccess:function(L){var w,v,R;L.lastData?B(ue(ue({},L.currentData),{list:H?ae(ae([],X(L.currentData.list),!1),X((v=L.lastData.list)!==null&&v!==void 0?v:[]),!1):ae(ae([],X((R=L.lastData.list)!==null&&R!==void 0?R:[]),!1),X(L.currentData.list),!1)})):B(ue(ue({},L.currentData),{list:ae([],X((w=L.currentData.list)!==null&&w!==void 0?w:[]),!1)})),setTimeout(function(){requestAnimationFrame(function(){if(H){var Y=Ze(s);if(Y=Y===document?document.documentElement:Y,Y){var xe=Et(Y);Y.scrollTo(0,xe-F.current)}}else te()})}),h==null||h(L.currentData)},onError:function(L){return b==null?void 0:b(L)}}),M=k.loading,V=k.error,q=k.run,ee=k.runAsync,Z=k.cancel,J=ve(function(){T||(C(!0),q(N))}),Q=function(L){return rt(void 0,void 0,void 0,function(){var w;return lt(this,function(v){switch(v.label){case 0:return[4,ee(L)];case 1:return w=v.sent(),[2,w.currentData]}})})},P=ve(function(){return T?Promise.reject():(C(!0),Q(N))}),_=function(){return C(!1),q()},G=function(){return C(!1),Q()},te=function(){var L=Ze(s);if(L){var w=L===document?document.documentElement:L,v=Ks(w),R=Et(w),Y=Hs(w);H?(S.current!==void 0&&S.current>v&&v<=m&&J(),S.current=v,F.current=R-v):R-v<=Y+m&&J()}};return _s("scroll",function(){M||y||te()},{target:s}),Xe(function(){q()},ae([],X(i),!1)),{data:N,loading:!y&&M,error:V,loadingMore:y,noMore:T,loadMore:J,loadMoreAsync:P,reload:ve(_),reloadAsync:ve(G),mutate:B,cancel:Z}};const Nt={connected:"text-[#16A34A] dark:text-[#22C55E]",connecting:"text-[#2563eb] dark:text-[#3b82f6]",reconnecting:"text-[#2563eb] dark:text-[#60a5fa]",offline:"text-[#f59e0b]",error:"text-[#ef4444]"},Gs={connected:"mcp.status.connected",connecting:"mcp.status.connecting",reconnecting:"mcp.status.reconnecting",offline:"mcp.status.offline",error:"mcp.status.error"},Ws={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"},qs={Official:"mcp.catalog.tag.official",Popular:"mcp.catalog.tag.popular",Community:"mcp.catalog.tag.community"},wt=20,Js=["debug","info","notice","warning","error","critical","alert","emergency"],Ct=(t,a)=>t.status!=="reconnecting"||!t.recovery?a(Gs[t.status]):a("mcp.status.recoveringAttempt",{attempt:t.recovery.attempt,max:t.recovery.maxAttempts}),Ys=async()=>z("/mcp"),Vs=async t=>z(`/mcp/${encodeURIComponent(t)}/logs?limit=20`),Qs="mcp server @modelcontextprotocol",Xs=3,qt=t=>{var a;return((a=t.split("/").pop())==null?void 0:a.replace(/^server-/,""))||t},Zs=async(t,a)=>{const s=t&&t.length>=Xs?t:Qs,l=`https://registry.npmjs.org/-/v1/search?text=${encodeURIComponent(s)}&size=${wt}&from=${a}`,n=await z(l);return{list:n.objects.map(m=>m.package),total:n.total,hasMore:a+wt<n.total}};function en({active:t}){const a=me(),[s,l]=r.useState("installed"),[n,m]=r.useState(!1),[f,g]=r.useState(null),[u,i]=r.useState(""),[j,c]=r.useState(null),[h,b]=r.useState(null),[x,E]=r.useState(null),[N,B]=r.useState(null),[$,y]=r.useState(null),[C,H]=r.useState(""),[S,F]=r.useState(null),[T,k]=r.useState(!1),[M,V]=r.useState(null),[q,ee]=r.useState(null),[Z,J]=r.useState(""),[Q,P]=r.useState(""),[_,G]=r.useState(null),[te,L]=r.useState(null),w=r.useRef(null),{run:v}=Us(o=>{P(o)},{wait:500}),{data:R=[],loading:Y,error:xe,run:je,runAsync:re}=Me(Ys,{refreshDeps:[t],ready:t,onSuccess:o=>{o.length>0&&!f&&g(o[0].id)}}),{data:ge,loading:ye,error:pe,runAsync:Ee}=Me(Vs,{manual:!0}),{data:oe,loading:ke,loadingMore:p,noMore:K,error:ie,reload:se}=zs(async o=>{var U;const W=((U=o==null?void 0:o.list)==null?void 0:U.length)??0;return Zs(Q,W)},{target:w,isNoMore:o=>!(o!=null&&o.hasMore),reloadDeps:[Q],manual:!t||s!=="catalog"}),{runAsync:de,loading:ce,error:he}=Me(async o=>{await z("/mcp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:o.name,config:o})})},{manual:!0,onSuccess:()=>{re(),m(!1),L(null),G(null)},onError:()=>{G(null)}}),Ne=r.useMemo(()=>{const o=u.trim().toLowerCase();return o?R.filter(W=>[W.name,W.endpoint,W.description].some(U=>U.toLowerCase().includes(o))):R},[u,R]),A=r.useMemo(()=>Ne.find(o=>o.id===f)??Ne[0],[Ne,f]),Te=r.useMemo(()=>{if(!A)return[];const o=(A.prompts??[]).flatMap(U=>U.arguments.map(fe=>({key:`prompt:${U.name}:${fe.name}`,label:`${U.name}.${fe.name}`,reference:{type:"prompt",name:U.name},argument:fe.name}))),W=(A.resourceTemplates??[]).flatMap(U=>(U.variables??[]).map(fe=>({key:`resource:${U.uriTemplate}:${fe}`,label:`${U.uriTemplate} · ${fe}`,reference:{type:"resource",uri:U.uriTemplate},argument:fe})));return[...o,...W]},[A]),be=Te.find(o=>o.key===$)??Te[0];r.useEffect(()=>{if(!t||!R.some(W=>W.oauthStatus==="authorizing"||W.status==="connecting"||W.status==="reconnecting"))return;const o=window.setInterval(()=>{re()},1e3);return()=>window.clearInterval(o)},[t,re,R]),r.useEffect(()=>{h&&R.some(o=>o.name===h.serverName&&(o.oauthStatus==="authenticated"||o.oauthStatus==="disabled"||o.oauthStatus==="unavailable"))&&b(null)},[h,R]),r.useEffect(()=>{!t||s!=="installed"||!A||Ee(A.name).catch(()=>{})},[t,Ee,A,s]);const De=async(o,W)=>{E({type:o,name:W}),c(null);try{const U=o==="delete"?"":`/${o}`;await z(`/mcp/${encodeURIComponent(W)}${U}`,{method:o==="delete"?"DELETE":"POST"}),await re(),o==="delete"&&(ee(null),g(null))}catch(U){c(U instanceof Error?U.message:a(o==="connect"?"mcp.error.connectFailed":o==="disconnect"?"mcp.error.disconnectFailed":"mcp.error.deleteFailed"))}finally{E(null)}},Le=async(o,W)=>{E({type:o,name:W.name}),c(null);try{if(o==="login"){const U=await z(`/mcp/${encodeURIComponent(W.name)}/oauth/login`,{method:"POST"});b({serverName:W.name,url:U.authorizationUrl})}else await z(`/mcp/${encodeURIComponent(W.name)}/oauth/logout`,{method:"POST"}),b(null);await re()}catch(U){c(U instanceof Error?U.message:a(o==="login"?"mcp.error.loginFailed":"mcp.error.logoutFailed"))}finally{E(null)}},tt=async(o,W)=>{B(W),c(null);try{await z(`/mcp/${encodeURIComponent(o.name)}/logging-level`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({level:W})}),await re(),Ee(o.name).catch(()=>{})}catch(U){c(U instanceof Error?U.message:a("mcp.error.loggingLevelFailed"))}finally{B(null)}},Ge=async o=>{if(be){k(!0),V(null),F(null);try{const W=await z(`/mcp/${encodeURIComponent(o.name)}/complete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reference:be.reference,argument:{name:be.argument,value:C}})});F(W)}catch(W){V(W instanceof Error?W.message:a("mcp.error.completionFailed"))}finally{k(!1)}}},We=r.useMemo(()=>new Set(R.map(o=>o.name.toLowerCase())),[R]),d=o=>{L(o)},O=o=>o.startsWith("@modelcontextprotocol/"),I=o=>O(o.name)?"Official":"Community";return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex h-full min-h-0 flex-col",children:e.jsxs("div",{className:"flex overflow-hidden flex-col flex-1 gap-4 p-4 min-h-0 sm:gap-5 sm:p-8",children:[e.jsxs("div",{className:"flex justify-between items-center shrink-0",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"MCP"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("button",{onClick:je,"aria-label":a("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:Y,children:e.jsx(Se,{className:D("h-4 w-4",Y&&"animate-spin")})}),e.jsxs("button",{"data-mcp-add-server-trigger":!0,onClick:()=>m(!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:[e.jsx(ct,{className:"h-3.5 w-3.5"}),a("mcp.action.addServer")]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit shrink-0",children:[e.jsx(At,{active:s==="installed",onClick:()=>l("installed"),children:a("mcp.tab.installed",{count:R.length})}),e.jsx(At,{active:s==="catalog",onClick:()=>{l("catalog"),oe||se()},children:a("mcp.tab.catalog")})]}),j&&e.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:[e.jsx(Re,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0",children:j}),e.jsx("button",{type:"button",onClick:()=>c(null),className:"underline shrink-0",children:a("mcp.action.dismiss")})]}),s==="installed"?e.jsxs("div",{className:"flex overflow-hidden flex-col flex-1 gap-3 min-h-0 sm:flex-row sm:gap-5",children:[e.jsxs("div",{className:"flex h-[180px] w-full shrink-0 flex-col gap-3 overflow-hidden sm:h-auto sm:w-[220px]",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] shrink-0",children:a("mcp.servers.title")}),e.jsx("input",{type:"search","aria-label":a("mcp.servers.searchAria"),value:u,onChange:o=>i(o.target.value),placeholder:a("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]"}),e.jsxs("div",{className:"flex overflow-y-auto flex-col flex-1 gap-2 pr-1 min-h-0",children:[Y&&R.length===0&&e.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-8 text-sm font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsx(ne,{className:"w-4 h-4 animate-spin"}),a("mcp.servers.loading")]}),xe&&!Y&&e.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:[e.jsx("span",{children:xe.message}),e.jsx("button",{type:"button",onClick:je,className:"rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900",children:a("mcp.action.retry")})]}),!xe&&!Y&&Ne.length===0&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:a(u?"mcp.servers.noMatch":"mcp.servers.none")}),Ne.map(o=>e.jsxs("button",{onClick:()=>{g(o.id),ee(null),c(null),y(null),H(""),F(null),V(null)},className:D("text-left rounded-lg px-3 py-2 flex flex-col gap-1 transition-colors shrink-0",o.id===(A==null?void 0:A.id)?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:o.name}),e.jsx("span",{className:D("text-[11px] font-mono font-semibold",Nt[o.status]),children:Ct(o,a)})]}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] truncate",children:o.endpoint})]},o.id))]})]}),A?e.jsxs("div",{className:"flex overflow-y-auto flex-col flex-1 gap-3 pr-2 min-h-0",children:[e.jsxs("div",{className:"flex justify-between items-center shrink-0",children:[e.jsx("span",{className:"text-base font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:A.name}),e.jsx("span",{className:D("text-xs font-mono font-semibold",Nt[A.status]),children:Ct(A,a)})]}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:A.description}),A.error&&e.jsx("p",{className:"text-[12px] font-mono text-[#ef4444]",children:a("mcp.server.errorLabel",{error:A.error})}),A.instructions&&e.jsxs("div",{className:"rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.instructions.title")}),e.jsxs("span",{className:"truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["sha256 ",A.instructions.sha256]})]}),e.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:A.instructions.text??a("mcp.instructions.detailsOmittedByPolicy")}),(A.instructions.truncated||A.instructions.detailsOmitted)&&e.jsx("span",{className:"mt-1 block text-[9px] font-mono text-amber-600 dark:text-amber-400",children:A.instructions.detailsOmitted?a("mcp.instructions.detailsOmitted"):a("mcp.instructions.truncated")})]}),A.tasks&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.tasks.title")}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:A.tasks.enabled?a("mcp.tasks.summary",{count:A.tasks.maxTasksPerSession,interval:A.tasks.pollIntervalMs}):a("mcp.tasks.disabledByDefault")})]}),e.jsx("span",{className:D("text-[10px] font-mono font-semibold uppercase",A.tasks.enabled?"text-[#16A34A] dark:text-[#22C55E]":"text-[#9CA3AF] dark:text-[#71717a]"),children:A.tasks.enabled?a("mcp.tasks.enabled"):a("mcp.tasks.disabled")})]}),A.oauthEnabled&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]",children:"OAuth"}),e.jsx("span",{role:A.oauthStatus==="authorizing"?"status":void 0,className:D("text-[11px] font-mono",A.oauthStatus==="authenticated"?"text-[#16A34A] dark:text-[#22C55E]":A.oauthStatus==="error"?"text-[#ef4444]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:a(Ws[A.oauthStatus])})]}),A.oauthStatus==="authenticated"?e.jsx("button",{type:"button",onClick:()=>void Le("logout",A),disabled:x!==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:(x==null?void 0:x.type)==="logout"?a("mcp.oauth.signingOut"):a("mcp.oauth.signOut")}):A.oauthStatus==="authorizing"?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin text-[#2563eb]","aria-hidden":"true"}),(h==null?void 0:h.serverName)===A.name?e.jsx("a",{href:h.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:a("mcp.oauth.continueAuthorization")}):e.jsx("button",{type:"button",onClick:()=>void Le("login",A),disabled:x!==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:a("mcp.oauth.resumeAuthorization")})]}):A.oauthStatus==="unavailable"?null:e.jsx("button",{type:"button",onClick:()=>void Le("login",A),disabled:x!==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:(x==null?void 0:x.type)==="login"?a("mcp.oauth.opening"):a("mcp.oauth.authorize")})]}),e.jsxs("div",{className:"flex gap-2 items-center",children:[A.status==="connected"||A.status==="reconnecting"?e.jsx("button",{onClick:()=>void De("disconnect",A.name),disabled:x!==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:(x==null?void 0:x.type)==="disconnect"&&x.name===A.name?a("mcp.action.disconnecting"):A.status==="reconnecting"?a("mcp.action.stopRecovery"):a("mcp.action.disconnect")}):e.jsx("button",{onClick:()=>void De("connect",A.name),disabled:x!==null||A.oauthEnabled&&A.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:(x==null?void 0:x.type)==="connect"&&x.name===A.name?a("mcp.action.connecting"):A.oauthEnabled&&A.oauthStatus!=="authenticated"?a("mcp.action.authorizeFirst"):a("mcp.action.connect")}),e.jsx("button",{onClick:()=>ee(A.name),disabled:x!==null,className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#ef4444] text-[11px] font-mono font-semibold",children:a("mcp.action.delete")})]}),q===A.name&&e.jsxs("div",{role:"alertdialog","aria-label":a("mcp.server.deleteAria",{name:A.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:[e.jsx("span",{className:"text-[11px] font-mono text-red-700 dark:text-red-300",children:a("mcp.delete.confirm")}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("button",{type:"button",onClick:()=>ee(null),className:"h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:a("mcp.action.cancel")}),e.jsx("button",{type:"button",onClick:()=>void De("delete",A.name),disabled:x!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:(x==null?void 0:x.type)==="delete"?a("mcp.action.deleting"):a("mcp.action.deleteServer")})]})]}),e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a("mcp.tools.title",{count:A.tools.length})}),e.jsx("div",{className:"flex flex-wrap gap-2",children:A.tools.length===0?e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.tools.none")}):A.tools.map(o=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:o},o))}),e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a("mcp.completion.title")}),A.status!=="connected"?e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.completion.connectPrompt")}):A.completionSupported?Te.length===0?e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.completion.noTargets")}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("div",{"aria-label":a("mcp.completion.targetAria"),className:"flex max-h-20 flex-wrap gap-1 overflow-y-auto",children:Te.map(o=>e.jsx("button",{type:"button","aria-pressed":(be==null?void 0:be.key)===o.key,onClick:()=>{y(o.key),F(null),V(null)},className:D("max-w-full truncate rounded px-2 py-1 text-[10px] font-mono",(be==null?void 0:be.key)===o.key?"bg-[#111827] text-white dark:bg-[#E5E5E5] dark:text-[#111827]":"bg-[#F3F4F6] text-[#6B7280] dark:bg-[#18181b] dark:text-[#a1a1aa]"),children:o.label},o.key))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text","aria-label":a("mcp.completion.partialAria"),value:C,onChange:o=>H(o.target.value),placeholder:a("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]"}),e.jsx("button",{type:"button",onClick:()=>void Ge(A),disabled:T,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:a(T?"mcp.completion.completing":"mcp.completion.complete")})]}),M&&e.jsx("span",{role:"alert",className:"text-[11px] font-mono text-red-600 dark:text-red-400",children:M}),S&&e.jsxs("div",{"aria-label":a("mcp.completion.suggestionsAria"),className:"rounded-md bg-[#F3F4F6] p-2 dark:bg-[#18181b]",children:[e.jsx("div",{className:"flex flex-wrap gap-1",children:S.values.length>0?S.values.map(o=>e.jsx("span",{className:"rounded bg-white px-2 py-1 text-[10px] font-mono text-[#111827] dark:bg-[#0C0C0C] dark:text-[#E5E5E5]",children:o||a("mcp.completion.empty")},o)):e.jsx("span",{className:"text-[10px] font-mono text-[#9CA3AF]",children:a("mcp.completion.noSuggestions")})}),e.jsxs("span",{className:"mt-1 block truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["sha256 ",S.sha256,S.truncated?a("mcp.meta.truncatedSuffix"):""]})]})]}):e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.completion.unsupported")}),e.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a("mcp.diagnostics.title")}),e.jsx("button",{type:"button","aria-label":a("mcp.diagnostics.refreshAria",{name:A.name}),onClick:()=>void Ee(A.name),disabled:ye,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:e.jsx(Se,{className:D("h-3.5 w-3.5",ye&&"animate-spin")})})]}),e.jsx("div",{"aria-label":a("mcp.log.levelAria"),className:"flex flex-wrap gap-1",children:Js.map(o=>{var W,U;return e.jsx("button",{type:"button",onClick:()=>void tt(A,o),disabled:A.status!=="connected"||N!==null,"aria-pressed":(((W=A.logging)==null?void 0:W.level)??"warning")===o,className:D("rounded px-2 py-1 text-[10px] font-mono transition-colors disabled:opacity-40",(((U=A.logging)==null?void 0:U.level)??"warning")===o?"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:N===o?a("mcp.log.setting"):o},o)})}),pe?e.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:pe.message}):ge!=null&&ge.entries.length?e.jsx("div",{"aria-label":a("mcp.diagnostics.logsAria",{name:A.name}),className:"flex max-h-52 flex-col gap-1.5 overflow-y-auto rounded-md bg-[#F3F4F6] p-2 dark:bg-[#18181b]",children:ge.entries.map(o=>e.jsxs("div",{className:"rounded bg-white px-2.5 py-2 dark:bg-[#0C0C0C]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:D("text-[10px] font-mono font-semibold uppercase",["error","critical","alert","emergency"].includes(o.level)?"text-red-600 dark:text-red-400":o.level==="warning"?"text-amber-600 dark:text-amber-400":"text-[#2563eb] dark:text-[#60a5fa]"),children:o.level}),e.jsxs("span",{className:"truncate text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[o.logger||A.name," · r",o.revision]})]}),e.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-words text-[11px] font-mono text-[#374151] dark:text-[#d4d4d8]",children:o.message}),e.jsxs("span",{className:"mt-1 block truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["sha256 ",o.dataSha256,o.truncated?a("mcp.meta.truncatedSuffix"):"",o.detailsOmitted?a("mcp.meta.detailsOmittedSuffix"):""]})]},o.revision))}):e.jsx("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a(ye?"mcp.log.loading":"mcp.log.none")})]}):e.jsx("div",{className:"flex flex-1 justify-center items-center",children:e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:a("mcp.server.selectPrompt")})})]}):e.jsxs("div",{className:"flex flex-col flex-1 gap-4 min-h-0",children:[e.jsx("div",{className:"flex gap-3 items-center shrink-0",children:e.jsxs("div",{className:"flex-1 h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] flex items-center px-3 gap-2",children:[e.jsx(na,{className:"h-3.5 w-3.5 text-[#9CA3AF] dark:text-[#71717a]"}),e.jsx("input",{type:"text","aria-label":a("mcp.catalog.searchAria"),value:Z,onChange:o=>{J(o.target.value),v(o.target.value)},placeholder:a("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"})]})}),e.jsxs("div",{ref:w,className:"overflow-y-auto flex-1 min-h-0",children:[ie?e.jsxs("div",{role:"alert",className:"flex flex-col gap-3 items-center py-12 font-mono text-center",children:[e.jsx(Re,{className:"w-6 h-6 text-red-500"}),e.jsx("span",{className:"text-xs text-red-600 dark:text-red-400",children:ie.message}),e.jsx("button",{type:"button",onClick:se,className:"rounded-md border border-[#E5E7EB] px-3 py-1.5 text-[11px] text-[#6B7280] dark:border-[#27272a] dark:text-[#a1a1aa]",children:a("mcp.catalog.retry")})]}):ke&&!oe?e.jsx("div",{className:"flex justify-center items-center py-12",children:e.jsx(ne,{className:"h-6 w-6 text-[#9CA3AF] dark:text-[#71717a] animate-spin"})}):e.jsxs("div",{className:"grid grid-cols-1 gap-3 pb-4 sm:grid-cols-2",children:[oe==null?void 0:oe.list.map(o=>{var le,$e;const W=We.has(qt(o.name).toLowerCase()),U=_===o.name,fe=I(o);return e.jsxs("div",{className:"rounded-lg bg-white dark:bg-[#0C0C0C] p-4 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex gap-2 justify-between items-center",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] truncate",children:o.name}),e.jsx("span",{className:D("text-[10px] font-mono px-2 py-0.5 rounded shrink-0",fe==="Official"?"bg-[#16A34A]/20 dark:bg-[#22C55E]/20 text-[#16A34A] dark:text-[#22C55E]":"bg-[#3b82f6]/20 text-[#3b82f6]"),children:a(qs[fe])})]}),e.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] line-clamp-2",children:o.description||a("mcp.catalog.noDescription")}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsxs("span",{children:["v",o.version]}),((le=o.publisher)==null?void 0:le.username)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:a("mcp.catalog.byAuthor",{author:o.publisher.username})})]})]}),e.jsxs("div",{className:"flex justify-between items-center pt-2 mt-auto",children:[e.jsxs("a",{href:(($e=o.links)==null?void 0:$e.npm)||`https://www.npmjs.com/package/${o.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:[e.jsx(pt,{className:"w-3 h-3"}),"npm"]}),W?e.jsxs("span",{className:"text-[11px] font-mono text-[#16A34A] dark:text-[#22C55E] flex items-center gap-1",children:[e.jsx(Dt,{className:"w-3 h-3"}),a("mcp.catalog.installed")]}):e.jsxs("button",{onClick:()=>d(o),disabled:U,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:[e.jsx(ot,{className:D("h-3 w-3",U&&"animate-pulse")}),a(U?"mcp.catalog.installing":"mcp.catalog.install")]})]})]},o.name)}),(oe==null?void 0:oe.list.length)===0&&e.jsx("div",{className:"col-span-full py-12 text-center text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.catalog.noPackages")})]}),p&&e.jsx("div",{className:"flex justify-center items-center py-4",children:e.jsx(ne,{className:"h-5 w-5 text-[#9CA3AF] dark:text-[#71717a] animate-spin"})}),K&&oe&&oe.list.length>0&&e.jsx("div",{className:"text-center py-4 text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.catalog.noMore")})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-[#E5E7EB] dark:border-[#1f2937] shrink-0",children:[e.jsx("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.catalog.packagesFound",{count:(oe==null?void 0:oe.total)??0})}),e.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:[a("mcp.catalog.browseGlama"),e.jsx(pt,{className:"w-3 h-3"})]})]})]})]})}),e.jsx(tn,{open:n,onOpenChange:m,onAdd:de,saving:ce,error:(he==null?void 0:he.message)??null}),te&&e.jsx(an,{pkg:te,onClose:()=>L(null),installing:ce,error:(he==null?void 0:he.message)??null,onInstall:o=>(G(te.name),de(o))})]})}function At({active:t,children:a,onClick:s}){return e.jsx("button",{onClick:s,className:D("px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors",t?"bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:a})}function tn({open:t,onOpenChange:a,onAdd:s,saving:l,error:n}){const m=me(),[f,g]=r.useState("form"),[u,i]=r.useState(""),[j,c]=r.useState(""),[h,b]=r.useState(""),[x,E]=r.useState(null),[N,B]=r.useState(`{
|
|
2
|
-
"name": "my-server",
|
|
3
|
-
"command": "npx",
|
|
4
|
-
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
|
|
5
|
-
}`);r.useEffect(()=>{t&&E(null)},[t]);const $=async()=>{if(E(null),f==="json"){let y;try{y=JSON.parse(N)}catch{E(m("mcp.add.invalidJson"));return}await s(y).catch(()=>{})}else{if(!u||!j){E(m("mcp.add.nameCommandRequired"));return}await s({name:u,command:j,args:h.split(" ").filter(Boolean)}).catch(()=>{})}};return e.jsx(Fe,{open:t,onOpenChange:a,children:e.jsxs(Pe,{onCloseAutoFocus:y=>Ke("[data-mcp-add-server-trigger]",y),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:[e.jsx(Be,{className:"sr-only",children:m("mcp.add.title")}),e.jsxs("div",{className:"flex flex-col gap-4 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:m("mcp.add.title")}),e.jsx("button",{onClick:()=>a(!1),"aria-label":m("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:e.jsx(Oe,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit",children:[e.jsx(St,{active:f==="form",onClick:()=>g("form"),children:m("mcp.add.modeForm")}),e.jsx(St,{active:f==="json",onClick:()=>g("json"),children:"JSON"})]}),f==="json"?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:m("mcp.add.jsonConfig")}),e.jsx("textarea",{"aria-label":m("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:N,onChange:y=>B(y.target.value)})]}):e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:m("mcp.add.serverName")}),e.jsx("input",{"aria-label":m("mcp.add.serverName"),type:"text",value:u,onChange:y=>i(y.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]"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:m("mcp.add.command")}),e.jsx("input",{"aria-label":m("mcp.add.commandAria"),type:"text",value:j,onChange:y=>c(y.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]"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:m("mcp.add.argsLabel")}),e.jsx("input",{"aria-label":m("mcp.add.argsAria"),type:"text",value:h,onChange:y=>b(y.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]"})]})]}),(x||n)&&e.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:x||n}),e.jsxs("div",{className:"flex gap-2 justify-end items-center pt-2",children:[e.jsx("button",{onClick:()=>a(!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:m("mcp.action.cancel")}),e.jsx("button",{onClick:()=>void $(),disabled:l,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:m(l?"mcp.add.adding":"mcp.add.submit")})]})]})]})})}function an({pkg:t,onClose:a,onInstall:s,installing:l,error:n}){const m=me(),f=qt(t.name),[g,u]=r.useState(f),[i,j]=r.useState(`-y ${t.name}`),[c,h]=r.useState(null),b=async()=>{if(h(null),!g.trim()){h(m("mcp.install.nameRequired"));return}await s({name:g.trim(),command:"npx",args:i.split(" ").filter(Boolean)}).catch(()=>{})};return e.jsx(Fe,{open:!0,onOpenChange:a,children:e.jsxs(Pe,{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:[e.jsx(Be,{className:"sr-only",children:m("mcp.install.titleWithName",{name:t.name})}),e.jsxs("div",{className:"flex flex-col gap-4 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:m("mcp.install.title")}),e.jsx("button",{onClick:a,"aria-label":m("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:e.jsx(Oe,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"rounded-md bg-white dark:bg-[#0C0C0C] p-3",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t.name}),e.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] mt-1",children:t.description||m("mcp.catalog.noDescription")})]}),e.jsx("div",{className:"h-px bg-[#E5E7EB] dark:bg-[#1f2937]"}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:m("mcp.add.serverName")}),e.jsx("input",{"aria-label":m("mcp.add.serverName"),type:"text",value:g,onChange:x=>u(x.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]"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:m("mcp.install.args")}),e.jsx("input",{"aria-label":m("mcp.add.argsAria"),type:"text",value:i,onChange:x=>j(x.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]"}),e.jsx("span",{className:"text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:m("mcp.install.commandPreview",{args:i})})]})]}),(c||n)&&e.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:c||n}),e.jsxs("div",{className:"flex gap-2 justify-end items-center pt-2",children:[e.jsx("button",{onClick:a,className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:m("mcp.action.cancel")}),e.jsx("button",{onClick:()=>void b(),disabled:l,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:m(l?"mcp.catalog.installing":"mcp.catalog.install")})]})]})]})})}function St({active:t,children:a,onClick:s}){return e.jsx("button",{onClick:s,className:D("px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors",t?"bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:a})}const dt=t=>t?{"x-blade-directory":t}:void 0,sn=async t=>z("/skills",{headers:dt(t)}),nn=async()=>z("/skills/catalog"),Ft={Official:"skills.install.catalog.tag.official",Popular:"skills.install.catalog.tag.popular",Community:"skills.install.catalog.tag.community"};function rn({active:t}){const a=me(),s=Ue(w=>{var v,R;return((v=w.currentSessionRef)==null?void 0:v.projectPath)??w.selectedProjectPath??((R=w.taskWorkspaceInfo)==null?void 0:R.cwd)??null}),[l,n]=r.useState(null),[m,f]=r.useState(""),[g,u]=r.useState(null),[i,j]=r.useState(null),[c,h]=r.useState(null),[b,x]=r.useState(!1),[E,N]=r.useState(!1),[B,$]=r.useState("confirm"),[y,C]=r.useState(null),[H,S]=r.useState(null),{data:F=[],loading:T,error:k,run:M,runAsync:V}=Me(()=>sn(s),{refreshDeps:[t,s],ready:t,onSuccess:w=>{w.length>0&&!l&&n(w[0].id)}}),{data:q=[],loading:ee,error:Z,run:J}=Me(nn,{refreshDeps:[t],ready:t}),Q=F.filter(w=>w.name.toLowerCase().includes(m.toLowerCase())),P=r.useMemo(()=>F.find(w=>w.id===l)??F[0],[F,l]),_=async(w,v,R)=>{j({type:w,name:v.name}),u(null);try{await z(w==="delete"?`/skills/${encodeURIComponent(v.name)}`:`/skills/${encodeURIComponent(v.name)}/toggle`,{method:w==="delete"?"DELETE":"POST",headers:{...dt(s),...w==="toggle"?{"Content-Type":"application/json"}:{}},body:w==="toggle"?JSON.stringify({enabled:R}):void 0}),await V(),w==="delete"&&(h(null),n(null))}catch(Y){u(Y instanceof Error?Y.message:a(w==="delete"?"skills.error.deleteFailed":"skills.error.toggleFailed"))}finally{j(null)}},G=()=>{x(!0)},te=w=>{S(w),C(null),$("confirm"),N(!0)},L=async()=>{if(H){$("installing"),C(null);try{const w=await z("/skills/install",{method:"POST",headers:{"Content-Type":"application/json",...dt(s)},body:JSON.stringify(H)});if(w.success===!1)throw new Error(w.error||a("skills.error.installFailed"));await V(),N(!1),x(!1)}catch(w){C(w instanceof Error?w.message:a("skills.error.installFailed")),$("failed")}}};return e.jsxs(r.Fragment,{children:[e.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:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:a("skills.title")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{"data-skill-install-trigger":!0,onClick:G,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:[e.jsx(ct,{className:"h-3.5 w-3.5"}),a("skills.action.install")]}),e.jsx("button",{onClick:M,"aria-label":a("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:T,children:e.jsx(Se,{className:D("h-4 w-4",T&&"animate-spin")})})]})]}),g&&e.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:[e.jsx(Re,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:g}),e.jsx("button",{type:"button",onClick:()=>u(null),className:"shrink-0 underline",children:a("skills.action.dismiss")})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-hidden sm:flex-row sm:gap-5",children:[e.jsxs("div",{className:"flex h-[180px] w-full shrink-0 flex-col gap-3 overflow-hidden sm:h-auto sm:w-[220px]",children:[e.jsx("div",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] shrink-0",children:a("skills.installed.title")}),e.jsx("input",{type:"search","aria-label":a("skills.installed.searchAria"),value:m,onChange:w=>f(w.target.value),placeholder:a("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"}),e.jsxs("div",{className:"flex flex-col gap-2 overflow-y-auto flex-1 min-h-0 pr-1",children:[T&&F.length===0&&e.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-8 text-sm font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsx(ne,{className:"h-4 w-4 animate-spin"}),a("skills.installed.loading")]}),k&&!T&&e.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:[e.jsx("span",{children:k.message}),e.jsx("button",{type:"button",onClick:M,className:"rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900",children:a("skills.action.retry")})]}),!k&&Q.length===0&&!T&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:a(m?"skills.installed.noMatch":"skills.installed.empty")}),Q.map(w=>e.jsxs("button",{onClick:()=>{n(w.id),h(null),u(null)},className:D("flex w-full min-w-0 flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors",w.id===l?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:w.name}),e.jsx("span",{className:D("text-[11px] font-mono font-semibold",w.enabled?"text-[#16A34A] dark:text-[#22C55E]":"text-[#f59e0b]"),children:w.enabled?a("skills.status.enabled"):a("skills.status.disabled")})]}),e.jsx("span",{className:"block w-full min-w-0 truncate text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:w.description||a("skills.noDescriptionShort")})]},w.id))]})]}),P?e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-y-auto pr-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-base font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:P.name}),e.jsxs("span",{className:"text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["v",P.version]})]}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:P.description||a("skills.noDescription")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>void _("toggle",P,!P.enabled),disabled:i!==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]",i&&"opacity-60 cursor-not-allowed"),children:(i==null?void 0:i.type)==="toggle"&&i.name===P.name?a("skills.action.saving"):P.enabled?a("skills.action.disable"):a("skills.action.enable")}),e.jsxs("button",{onClick:()=>h(P.name),disabled:!P.removable||i!==null,title:P.removable?void 0:a("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:[e.jsx(_e,{className:"h-3 w-3"}),P.removable?a("skills.uninstall.action"):a("skills.uninstall.managed")]})]}),c===P.name&&e.jsxs("div",{role:"alertdialog","aria-label":a("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:[e.jsx("span",{className:"text-[11px] font-mono text-red-700 dark:text-red-300",children:a("skills.uninstall.confirmPrompt")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>h(null),className:"h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:a("skills.action.cancel")}),e.jsx("button",{type:"button",onClick:()=>void _("delete",P),disabled:i!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:(i==null?void 0:i.type)==="delete"?a("skills.uninstall.inProgress"):a("skills.uninstall.confirm")})]})]}),e.jsx("div",{className:"h-px bg-[#E5E7EB] dark:bg-[#1f2937]"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a("skills.details.title")}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[12px] font-mono",children:[e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a]",children:a("skills.details.provider")}),e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5]",children:P.provider}),e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a]",children:a("skills.details.location")}),e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5] truncate",children:P.location})]})]}),P.capabilities.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a("skills.details.capabilities")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:P.capabilities.map(w=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:w},w))})]}),P.allowedTools.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a("skills.details.allowedTools",{count:P.allowedTools.length})}),e.jsx("div",{className:"flex flex-wrap gap-2",children:P.allowedTools.map(w=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:w},w))})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:a("skills.detail.emptyState")})})]})]}),e.jsx(ln,{open:b,catalog:q,installed:F.map(w=>w.name),catalogLoading:ee,catalogError:(Z==null?void 0:Z.message)??null,onRetryCatalog:J,onOpenChange:x,onInstall:te}),e.jsx(on,{open:E,status:B,error:y,onCancel:()=>N(!1),onConfirm:L,onRetry:()=>$("confirm")})]})}function nt({active:t,children:a,onClick:s}){return e.jsx("button",{onClick:s,className:D("px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors",t?"bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:a})}function ln({open:t,onOpenChange:a,onInstall:s,catalog:l,installed:n,catalogLoading:m,catalogError:f,onRetryCatalog:g}){const u=me(),[i,j]=r.useState("catalog"),[c,h]=r.useState(""),[b,x]=r.useState(null),[E,N]=r.useState(""),[B,$]=r.useState(""),y=l.filter(F=>F.name.toLowerCase().includes(c.toLowerCase())),C=()=>{if(i==="catalog"){if(!b)return;s({source:"catalog",name:b});return}if(i==="repo"){if(!E)return;s({source:"repo",url:E});return}B&&s({source:"local",path:B})},H=b?n.includes(b):!1,S=i==="catalog"&&(!b||H||m||!!f)||i==="repo"&&!E||i==="local"&&!B;return e.jsx(Fe,{open:t,onOpenChange:a,children:e.jsxs(Pe,{onCloseAutoFocus:F=>Ke("[data-skill-install-trigger]",F),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:[e.jsx(Be,{className:"sr-only",children:u("skills.install.title")}),e.jsxs("div",{className:"flex flex-col gap-4 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:u("skills.install.title")}),e.jsx("button",{onClick:()=>a(!1),"aria-label":u("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:e.jsx(Oe,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit",children:[e.jsx(nt,{active:i==="catalog",onClick:()=>j("catalog"),children:u("skills.install.tab.catalog")}),e.jsx(nt,{active:i==="repo",onClick:()=>j("repo"),children:u("skills.install.tab.repo")}),e.jsx(nt,{active:i==="local",onClick:()=>j("local"),children:u("skills.install.tab.local")})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[i==="catalog"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{"aria-label":u("skills.install.catalog.searchAria"),value:c,onChange:F=>h(F.target.value),placeholder:u("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]"}),e.jsxs("div",{className:"flex max-h-[min(240px,30dvh)] flex-col gap-2 overflow-y-auto",children:[m&&e.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-6 text-sm font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsx(ne,{className:"h-4 w-4 animate-spin"}),u("skills.install.catalog.loading")]}),f&&!m&&e.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:[e.jsx("span",{children:f}),e.jsx("button",{type:"button",onClick:g,className:"rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900",children:u("skills.action.retry")})]}),!m&&!f&&y.length===0&&e.jsx("div",{className:"text-center py-6 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:u("skills.install.catalog.empty")}),!m&&!f&&y.map(F=>{const T=n.includes(F.name),k=b===F.name;return e.jsxs("button",{onClick:()=>x(F.name),className:D("rounded-lg px-3 py-2 flex flex-col gap-1 text-left transition-colors",k?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:F.name}),e.jsx("span",{className:D("text-[10px] font-mono px-2 py-0.5 rounded",F.tag==="Official"?"bg-[#22C55E]/20 text-[#16A34A] dark:text-[#22C55E]":"bg-[#3b82f6]/20 text-[#3b82f6]"),children:Ft[F.tag]?u(Ft[F.tag]):F.tag})]}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:F.description}),e.jsx("span",{className:"text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:u("skills.install.catalog.byAuthor",{author:F.author})}),T&&e.jsx("span",{className:"text-[10px] font-mono text-[#16A34A] dark:text-[#22C55E]",children:u("skills.status.installed")})]},F.name)})]})]}),i==="repo"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:u("skills.install.repo.label")}),e.jsx("input",{"aria-label":u("skills.install.repo.inputAria"),value:E,onChange:F=>N(F.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]"}),e.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:u("skills.install.repo.credentialsHint")})]}),i==="local"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:u("skills.install.local.label")}),e.jsx("input",{"aria-label":u("skills.install.local.inputAria"),value:B,onChange:F=>$(F.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]"})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx("button",{onClick:()=>a(!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:u("skills.action.cancel")}),e.jsx("button",{onClick:C,disabled:S,className:D("h-7 px-3 rounded-md text-[11px] font-mono font-semibold",S?"bg-[#E5E7EB] text-[#9CA3AF] cursor-not-allowed dark:bg-[#27272a] dark:text-[#71717a]":"bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C]"),children:u("skills.action.installShort")})]})]})]})})}function on({open:t,status:a,error:s,onCancel:l,onConfirm:n,onRetry:m}){const f=me();return e.jsx(Fe,{open:t,onOpenChange:g=>!g&&l(),children:e.jsxs(Pe,{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:[e.jsx(Be,{className:"sr-only",children:f("skills.status.dialogTitle")}),e.jsxs("div",{className:"p-5 flex flex-col gap-3",children:[a==="confirm"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:f("skills.status.confirm.title")}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:f("skills.status.confirm.prompt")}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:l,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:f("skills.action.cancel")}),e.jsx("button",{onClick:n,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:f("skills.action.installShort")})]})]}),a==="installing"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:f("skills.status.installing.title")}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:f("skills.status.installing.description")}),e.jsx("div",{className:"h-1.5 rounded-full bg-[#E5E7EB] dark:bg-[#18181b] overflow-hidden",children:e.jsx("div",{className:"h-full w-[45%] bg-[#16A34A] dark:bg-[#22C55E]"})}),e.jsx("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"~35%"}),e.jsx("button",{onClick:l,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:f("skills.action.hide")})]}),a==="failed"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:f("skills.status.failed.title")}),e.jsx("p",{className:"text-[12px] font-mono text-[#f87171]",children:s||f("skills.status.failed.fallback")}),e.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:f("skills.status.failed.hint")}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:l,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:f("skills.action.close")}),e.jsx("button",{onClick:m,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:f("skills.action.retry")})]})]})]})]})})}function Ae({value:t,onChange:a,options:s,placeholder:l="Select...",disabled:n=!1,className:m,"aria-label":f}){const[g,u]=r.useState(!1),[i,j]=r.useState(-1),c=r.useRef(null),h=s.find(x=>x.value===t);r.useEffect(()=>{if(g){const x=s.findIndex(E=>E.value===t);j(x>=0?x:0)}},[g,s,t]);const b=x=>{if(!n){if(!g){(x.key==="Enter"||x.key===" "||x.key==="ArrowDown")&&(x.preventDefault(),u(!0));return}switch(x.key){case"ArrowDown":x.preventDefault(),j(E=>Math.min(E+1,s.length-1));break;case"ArrowUp":x.preventDefault(),j(E=>Math.max(E-1,0));break;case"Enter":case" ":x.preventDefault(),i>=0&&i<s.length&&(a(s[i].value),u(!1));break;case"Escape":x.preventDefault(),u(!1);break}}};return r.useEffect(()=>{var E;if(!g||i<0)return;const x=(E=c.current)==null?void 0:E.children[i];x==null||x.scrollIntoView({block:"nearest"})},[i,g]),e.jsxs(Jt,{open:g,onOpenChange:u,children:[e.jsx(Yt,{asChild:!0,children:e.jsxs("button",{type:"button",role:"combobox","aria-expanded":g,"aria-haspopup":"listbox","aria-label":f,disabled:n,onKeyDown:b,className:D("field flex items-center justify-between gap-2 text-left",!h&&"text-zinc-400 dark:text-zinc-500",n&&"cursor-not-allowed opacity-50",m),children:[e.jsx("span",{className:"truncate",children:h?h.label:l}),e.jsx(Lt,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),e.jsx(Vt,{align:"start",sideOffset:4,onKeyDown:b,className:"w-[var(--radix-popover-trigger-width)] max-h-[240px] p-1 overflow-hidden",children:e.jsx(Qt,{className:"max-h-[232px]",children:e.jsx("div",{ref:c,role:"listbox",children:s.map((x,E)=>e.jsxs("button",{type:"button",role:"option","aria-selected":x.value===t,"data-value":x.value,"data-highlighted":E===i||void 0,onClick:()=>{a(x.value),u(!1)},onMouseEnter:()=>j(E),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",E===i&&"bg-zinc-100 dark:bg-zinc-800",x.value===t&&"text-zinc-900 dark:text-zinc-50 font-medium"),children:[e.jsx(Dt,{className:D("h-3.5 w-3.5 shrink-0",x.value===t?"opacity-100":"opacity-0")}),e.jsx("span",{className:"truncate",children:x.label})]},x.value))})})})]})}const dn=[{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"}],cn=/^[a-z][a-z0-9._-]{0,63}$/;function un({open:t,onOpenChange:a,onSave:s,saveError:l}){const n=me(),[m,f]=r.useState([]),[g,u]=r.useState([]),[i,j]=r.useState(),[c,h]=r.useState(),[b,x]=r.useState(""),[E,N]=r.useState(""),[B,$]=r.useState(""),[y,C]=r.useState(""),[H,S]=r.useState(""),[F,T]=r.useState(""),[k,M]=r.useState(!1),[V,q]=r.useState(!1),[ee,Z]=r.useState(!1),[J,Q]=r.useState(!1),[P,_]=r.useState(null);r.useEffect(()=>{if(!t)return;let v=!0;return u([]),j(void 0),h(void 0),x(""),N(""),$(""),C(""),S(""),T(""),M(!1),_(null),q(!0),z("/providers").then(R=>{v&&f(R)}).catch(R=>{v&&_(R instanceof Error?R.message:n("settings.models.addModal.loadProvidersError"))}).finally(()=>{v&&q(!1)}),()=>{v=!1}},[t,n]),r.useEffect(()=>{if(!i)return;let v=!0;return u([]),h(void 0),_(null),i.factoryWireApi||i.custom?(Z(!1),()=>{v=!1}):(Z(!0),z(`/providers/${i.id}/models`).then(R=>{v&&u(R)}).catch(R=>{v&&_(R instanceof Error?R.message:n("settings.models.addModal.loadModelsError"))}).finally(()=>{v&&Z(!1)}),()=>{v=!1})},[i,n]);const G=i==null?void 0:i.factoryWireApi,te=!!(G||i!=null&&i.custom),L=te?y.trim():c==null?void 0:c.id,w=async()=>{if(!i||!L||!i.configured&&!F)return;if(G){if(!cn.test(E.trim())){_(n("settings.models.addModal.channelIdError"));return}let Y;try{Y=new URL(H.trim())}catch{_(n("settings.models.addModal.invalidBaseUrl"));return}if(!["http:","https:"].includes(Y.protocol)){_(n("settings.models.addModal.invalidBaseUrl"));return}}Q(!0);const v=G?E.trim():i.id,R=await s({provider:v,model:L,displayName:b||(te?L:(c==null?void 0:c.name)??""),apiKey:F||void 0,...G?{modelProvider:{id:v,name:B.trim()||v,baseUrl:H.trim(),wireApi:G}}:{}});Q(!1),R&&a(!1)};return e.jsx(Fe,{open:t,onOpenChange:a,children:e.jsxs(Pe,{onCloseAutoFocus:v=>Ke("[data-add-model-trigger]",v),onEscapeKeyDown:v=>{v.preventDefault(),a(!1)},onKeyDown:v=>{v.key==="Escape"&&(v.preventDefault(),v.stopPropagation(),a(!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:[e.jsx(Be,{className:"sr-only",children:n("settings.models.addModal.title")}),e.jsxs("div",{className:"flex flex-col gap-5 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"font-mono text-base font-semibold",children:n("settings.models.addModal.title")}),e.jsx("button",{type:"button",onClick:()=>a(!1),"aria-label":n("settings.models.addModal.close"),className:"flex h-8 w-8 items-center justify-center rounded-md",children:e.jsx(Oe,{className:"h-4 w-4"})})]}),(P||l)&&e.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:[e.jsx(Re,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:P||l})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[n("settings.models.addModal.provider"),e.jsx(Ae,{"aria-label":n("settings.models.addModal.provider"),value:(i==null?void 0:i.id)??"",disabled:V,onChange:v=>{j(m.find(R=>R.id===v)),x(""),N(""),$(""),C(""),S("")},placeholder:n(V?"settings.models.addModal.loadingProviders":"settings.models.addModal.selectProvider"),options:m.map(v=>{const R=v.factoryWireApi==="openai-completions"?n("settings.models.addModal.customOpenAI"):v.factoryWireApi==="anthropic-messages"?n("settings.models.addModal.customAnthropic"):v.name;return{value:v.id,label:`${R} (${v.modelCount})${v.configured?n("settings.models.addModal.configuredSuffix"):""}`}})})]}),te?e.jsxs(e.Fragment,{children:[G&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[n("settings.models.addModal.channelId"),e.jsx("input",{"aria-label":n("settings.models.addModal.channelId"),value:E,onChange:v=>{N(v.target.value),_(null)},placeholder:"team-gateway",autoComplete:"off",spellCheck:!1,className:"field"}),e.jsx("span",{className:"text-[11px] text-zinc-400",children:n("settings.models.addModal.channelIdHint")})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[n("settings.models.addModal.channelName"),e.jsx("input",{"aria-label":n("settings.models.addModal.channelName"),value:B,onChange:v=>$(v.target.value),placeholder:"Team Gateway",className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[n("settings.models.addModal.baseUrl"),e.jsx("input",{"aria-label":n("settings.models.addModal.baseUrl"),value:H,onChange:v=>{S(v.target.value),_(null)},placeholder:G==="anthropic-messages"?"https://gateway.example.com":"https://gateway.example.com/v1",className:"field"}),e.jsx("span",{className:"text-[11px] text-zinc-400",children:n(G==="anthropic-messages"?"settings.models.addModal.anthropicProtocol":"settings.models.addModal.openaiProtocol")})]})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[n("settings.models.addModal.modelId"),e.jsx("input",{"aria-label":n("settings.models.addModal.modelId"),value:y,onChange:v=>{C(v.target.value),_(null)},placeholder:"vendor-model-2026",className:"field"})]})]}):e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[n("settings.models.addModal.model"),e.jsx(Ae,{"aria-label":n("settings.models.addModal.model"),value:(c==null?void 0:c.id)??"",disabled:!i||ee,onChange:v=>{const R=g.find(Y=>Y.id===v);h(R),R&&x(R.name)},placeholder:n(ee?"settings.models.addModal.loadingModels":"settings.models.addModal.selectModel"),options:g.map(v=>({value:v.id,label:`${v.name} - ${Math.round(v.contextWindow/1e3)}K${v.reasoning?n("settings.models.addModal.reasoningSuffix"):""}${v.input.includes("image")?n("settings.models.addModal.visionSuffix"):""}`}))})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[n("settings.models.addModal.displayName"),e.jsx("input",{value:b,onChange:v=>x(v.target.value),placeholder:(c==null?void 0:c.name)??n("settings.models.addModal.displayNamePlaceholder"),className:"field"})]}),(i==null?void 0:i.supportsApiKey)&&!i.configured&&e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[n("settings.models.addModal.apiKey"),e.jsxs("span",{className:"relative",children:[e.jsx("input",{"aria-label":n("settings.models.addModal.apiKeyAria"),type:k?"text":"password",value:F,onChange:v=>T(v.target.value),className:"field w-full pr-10",placeholder:n("settings.models.addModal.apiKeyPlaceholder")}),e.jsx("button",{type:"button",onClick:()=>M(!k),"aria-label":n(k?"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:k?e.jsx(ra,{className:"h-4 w-4"}):e.jsx(la,{className:"h-4 w-4"})})]})]}),i&&!i.configured&&!i.supportsApiKey&&e.jsx("p",{className:"font-mono text-sm text-amber-600",children:n("settings.models.addModal.oauthNote")}),e.jsxs("button",{type:"button",disabled:J||!i||!L||G&&(!E.trim()||!H.trim())||!i.configured&&(!i.supportsApiKey||F.trim().length===0),onClick:()=>void w(),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:[J&&e.jsx(ne,{className:"h-4 w-4 animate-spin"}),n(J?"settings.models.addModal.saving":"settings.models.addModal.saveModel")]})]})]})})}function mn(t){const a=me(),[s,l]=r.useState(""),[n,m]=r.useState(""),[f,g]=r.useState(""),[u,i]=r.useState(""),[j,c]=r.useState(!1),[h,b]=r.useState(null);r.useEffect(()=>{var N,B,$,y,C;l(((N=t.model)==null?void 0:N.displayName)??""),m((($=(B=t.model)==null?void 0:B.overrides)==null?void 0:$.baseUrl)??""),g(((C=(y=t.model)==null?void 0:y.overrides)==null?void 0:C.streamIdleTimeout)!==void 0?String(t.model.overrides.streamIdleTimeout):""),i(""),b(null)},[t.model]);const x=async()=>{if(!t.model)return;b(null);const N=f.trim()?Number(f):void 0;if(N!==void 0&&(!Number.isFinite(N)||N<1e3)){b(a("settings.models.editModal.streamIdleTimeoutError"));return}c(!0);try{u.trim()&&await z(`/providers/${t.model.provider}/credential`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:u.trim()})});const B={...t.model.overrides};n.trim()?B.baseUrl=n.trim():delete B.baseUrl,N!==void 0?B.streamIdleTimeout=N:delete B.streamIdleTimeout,await t.onSave(t.model.id,{displayName:s||void 0,overrides:Object.keys(B).length>0?B:void 0})&&t.onOpenChange(!1)}catch(B){b(B instanceof Error?B.message:a("settings.models.editModal.credentialError"))}finally{c(!1)}},E=t.model?`[data-edit-model-trigger="${t.model.id.replace(/"/g,'\\"')}"]`:"[data-edit-model-trigger]";return e.jsx(Fe,{open:t.open,onOpenChange:t.onOpenChange,children:e.jsxs(Pe,{onCloseAutoFocus:N=>Ke(E,N),onEscapeKeyDown:N=>{N.preventDefault(),t.onOpenChange(!1)},onKeyDown:N=>{N.key==="Escape"&&(N.preventDefault(),N.stopPropagation(),t.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:[e.jsx(Be,{className:"sr-only",children:a("settings.models.editModal.srTitle")}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h2",{className:"font-mono font-semibold",children:a("settings.models.editModal.title")}),e.jsx("button",{type:"button",onClick:()=>t.onOpenChange(!1),"aria-label":a("settings.models.editModal.close"),className:"flex justify-center items-center w-8 h-8 rounded-md",children:e.jsx(Oe,{className:"w-4 h-4"})})]}),(h||t.saveError)&&e.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||t.saveError}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[a("settings.models.editModal.displayName"),e.jsx("input",{value:s,onChange:N=>l(N.target.value),className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[a("settings.models.editModal.replaceApiKey"),e.jsx("input",{type:"password",value:u,onChange:N=>i(N.target.value),placeholder:a("settings.models.editModal.replaceApiKeyPlaceholder"),className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[a("settings.models.editModal.baseUrlOverride"),e.jsx("input",{value:n,onChange:N=>m(N.target.value),placeholder:a("settings.models.editModal.baseUrlPlaceholder"),className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[a("settings.models.editModal.streamIdleTimeout"),e.jsx("input",{type:"number",min:1e3,step:1e3,value:f,onChange:N=>g(N.target.value),placeholder:"300000",className:"field"})]}),e.jsxs("button",{type:"button",onClick:()=>void x(),disabled:j,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:[j&&e.jsx(ne,{className:"w-4 h-4 animate-spin"}),a(j?"settings.models.editModal.saving":"settings.models.editModal.save")]})]})})}function xn({provider:t,onOpenChange:a,onSave:s,saveError:l}){const n=me(),[m,f]=r.useState(t.name),[g,u]=r.useState(t.defaultBaseUrl??""),[i,j]=r.useState(t.wireApi??"openai-completions"),[c,h]=r.useState(t.apiKeyEnv??""),[b,x]=r.useState(""),[E,N]=r.useState(null),[B,$]=r.useState(!1);r.useEffect(()=>{f(t.name),u(t.defaultBaseUrl??""),j(t.wireApi??"openai-completions"),h(t.apiKeyEnv??""),x(""),N(null)},[t]);const y=async()=>{if(!m.trim()){N(n("settings.models.editProvider.channelNameRequired"));return}try{const C=new URL(g.trim());if(!["http:","https:"].includes(C.protocol))throw new Error}catch{N(n("settings.models.editProvider.invalidBaseUrl"));return}$(!0),N(null);try{await s(t.id,{name:m.trim(),baseUrl:g.trim(),wireApi:i,apiKeyEnv:c.trim()||null,...b.trim()?{apiKey:b.trim()}:{}})&&a(!1)}finally{$(!1)}};return e.jsx(Fe,{open:!0,onOpenChange:a,children:e.jsxs(Pe,{onCloseAutoFocus:C=>Ke(`[data-edit-provider-trigger="${t.id.replace(/"/g,'\\"')}"]`,C),onEscapeKeyDown:C=>{C.preventDefault(),a(!1)},onKeyDown:C=>{C.key==="Escape"&&(C.preventDefault(),C.stopPropagation(),a(!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:[e.jsx(Be,{className:"sr-only",children:n("settings.models.editProvider.title")}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-mono font-semibold",children:n("settings.models.editProvider.title")}),e.jsx("p",{className:"mt-1 font-mono text-[11px] text-zinc-400",children:t.id})]}),e.jsx("button",{type:"button",onClick:()=>a(!1),"aria-label":n("settings.models.editProvider.close"),className:"flex justify-center items-center w-8 h-8 rounded-md",children:e.jsx(Oe,{className:"w-4 h-4"})})]}),(E||l)&&e.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:E||l}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[n("settings.models.editProvider.channelName"),e.jsx("input",{"aria-label":n("settings.models.editProvider.channelName"),value:m,onChange:C=>f(C.target.value),className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[n("settings.models.editProvider.wireApi"),e.jsx(Ae,{"aria-label":n("settings.models.editProvider.wireApi"),value:i,onChange:C=>j(C),options:[{value:"openai-completions",label:"OpenAI Chat Completions"},{value:"anthropic-messages",label:"Anthropic Messages"}]})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[n("settings.models.editProvider.baseUrl"),e.jsx("input",{"aria-label":n("settings.models.editProvider.baseUrlAria"),value:g,onChange:C=>{u(C.target.value),N(null)},className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[n("settings.models.editProvider.apiKeyEnv"),e.jsx("input",{"aria-label":n("settings.models.editProvider.apiKeyEnv"),value:c,onChange:C=>h(C.target.value),placeholder:n("settings.models.editProvider.apiKeyEnvPlaceholder"),autoComplete:"off",spellCheck:!1,className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[n("settings.models.editProvider.replaceApiKey"),e.jsx("input",{"aria-label":n("settings.models.editProvider.apiKeyAria"),type:"password",value:b,onChange:C=>x(C.target.value),placeholder:n("settings.models.editProvider.apiKeyPlaceholder"),className:"field"})]}),e.jsxs("button",{type:"button",onClick:()=>void y(),disabled:B,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:[B&&e.jsx(ne,{className:"w-4 h-4 animate-spin"}),n(B?"settings.models.editProvider.saving":"settings.models.editProvider.save")]})]})})}const pn={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 fn(){const t=me(),a=Ue(P=>P.currentSessionRef),s=a==null?void 0:a.projectPath,l=a==null?void 0:a.sessionId,n=r.useMemo(()=>s??new URLSearchParams(window.location.search).get("project")??"",[s]),[m,f]=r.useState(null),[g,u]=r.useState(null),[i,j]=r.useState(""),[c,h]=r.useState(""),[b,x]=r.useState(!1),[E,N]=r.useState(null),[B,$]=r.useState(null),[y,C]=r.useState(null),H=r.useRef(0),S=r.useRef(n);S.current=n;const F=l?`${n}\0${l}`:"",T=r.useRef(F);T.current=F;const k=i===n?m:null,M=c===F?g:null,V=r.useCallback(async()=>{const P=++H.current;if(!n){f(null),u(null),j(""),h(""),C(null);return}x(!0),C(null);try{const _=await z(`/hooks/trust?projectPath=${encodeURIComponent(n)}`);if(P!==H.current)return;const G=l?await z(`/hooks/session?projectPath=${encodeURIComponent(n)}&sessionId=${encodeURIComponent(l)}`):null;if(P!==H.current)return;f(_),u(G),j(n),h(G?F:"")}catch(_){if(P!==H.current)return;C(_ instanceof Error?_.message:t("settings.hooks.loadFailed"))}finally{P===H.current&&x(!1)}},[n,l,F,t]);r.useEffect(()=>($(null),V(),()=>{H.current+=1}),[V]);const q=async P=>{if(!k)return;const _=n;N(P),C(null);try{const G=await z("/hooks/trust",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:n,action:P,...P==="trust"&&k.currentDigest?{expectedDigest:k.currentDigest}:{}})});S.current===_&&(f(G),j(_),$(null))}catch(G){S.current===_&&C(G instanceof Error?G.message:t("settings.hooks.updateFailed"))}finally{N(null)}},ee=async P=>{if(!l||!M)return;const _=F;N("session"),C(null);try{const G=await z("/hooks/session",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:n,sessionId:l,enabled:P})});T.current===_&&(u(G),h(_))}catch(G){T.current===_&&C(G instanceof Error?G.message:t("settings.hooks.sessionUpdateFailed"))}finally{N(null)}};if(!n)return e.jsx("div",{className:"font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.hooks.selectSession")});const Z=(k==null?void 0:k.state)==="trusted",J=(k==null?void 0:k.state)==="untrusted"||(k==null?void 0:k.state)==="modified",Q=M!==null&&!M.enabled&&!M.paused;return e.jsxs("div",{className:"flex min-h-0 flex-col gap-3 font-mono",children:[e.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:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[Z?e.jsx(ut,{className:"h-4 w-4 text-emerald-600"}):e.jsx($t,{className:D("h-4 w-4",J?"text-amber-600":"text-[#71717a]")}),e.jsx("span",{className:"text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t(k?pn[k.state]:"settings.hooks.heading")}),b&&e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"})]}),e.jsx("p",{className:"mt-1 break-all text-[10.5px] text-[#71717a]",children:n}),(k==null?void 0:k.currentDigest)&&e.jsx("p",{className:"mt-1 text-[10px] text-[#9CA3AF]",children:k.currentDigest})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>void V(),disabled:b||E!==null,"aria-label":t("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:[e.jsx(Se,{className:"h-3.5 w-3.5"}),t("settings.common.reload")]}),Z?e.jsx("button",{type:"button",onClick:()=>$("revoke"),disabled:E!==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:t("settings.hooks.revoke")}):e.jsx("button",{type:"button",onClick:()=>$("trust"),disabled:E!==null||!(k!=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:t("settings.hooks.trustDigest")})]})]}),y&&e.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:y}),e.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:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t("settings.hooks.currentSession")}),e.jsx("div",{className:"mt-0.5 text-[9.5px] text-[#9CA3AF]",children:l?M?M.paused?t("settings.hooks.session.paused"):M.enabled?t("settings.hooks.session.active"):M.configEnabled?t("settings.hooks.session.unavailable"):t("settings.hooks.session.disabled"):t("settings.hooks.session.loading"):t("settings.hooks.session.open")})]}),e.jsx("button",{type:"button",role:"switch","aria-label":M!=null&&M.paused?t("settings.hooks.session.enableAria"):M!=null&&M.enabled?t("settings.hooks.session.pauseAria"):t("settings.hooks.session.unavailableAria"),"aria-checked":(M==null?void 0:M.enabled)??!1,disabled:!M||E!==null||Q,onClick:()=>void ee((M==null?void 0:M.paused)===!0),className:D("flex h-6 w-11 items-center rounded-full px-1 transition-colors disabled:opacity-40",M!=null&&M.enabled?"bg-emerald-500":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:D("h-4 w-4 rounded-full bg-white transition-transform",M!=null&&M.enabled?"translate-x-5":"translate-x-0")})})]}),B&&k&&e.jsxs("div",{role:"alertdialog","aria-label":t(B==="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:[e.jsx("span",{className:"max-w-[620px] text-[11px] text-amber-900 dark:text-amber-200",children:B==="trust"?t("settings.hooks.confirmTrust",{count:k.configuredHooks}):t("settings.hooks.confirmRevoke")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>$(null),className:"h-7 rounded px-2 text-[11px] text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.common.cancel")}),e.jsx("button",{type:"button",onClick:()=>void q(B),disabled:E!==null,className:D("h-7 rounded px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",B==="trust"?"bg-emerald-600":"bg-red-600"),children:t(E?"settings.hooks.saving":B==="trust"?"settings.hooks.trustReviewed":"settings.hooks.revokeTrust")})]})]}),e.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[((k==null?void 0:k.definitions)??[]).map((P,_)=>e.jsxs("div",{className:"border-b border-[#E5E7EB] px-3 py-2 last:border-b-0 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"font-semibold text-[#111827] dark:text-[#E5E5E5]",children:P.event}),e.jsx("span",{className:"rounded bg-[#E5E7EB] px-1.5 py-0.5 text-[9px] uppercase text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]",children:P.type}),P.name&&e.jsx("span",{className:"text-[#71717a]",children:P.name}),P.pluginName&&e.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:[P.pluginName," · ",P.pluginSource]})]}),P.matcher&&e.jsx("div",{className:"mt-1 break-all text-[9.5px] text-[#9CA3AF]",children:P.matcher}),e.jsx("pre",{className:"mt-1.5 whitespace-pre-wrap break-all text-[10.5px] text-[#374151] dark:text-[#d4d4d8]",children:P.target})]},`${P.event}-${P.type}-${_}`)),k&&k.definitions.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:t("settings.hooks.empty")})]})]})}const Pt={restrictToAllowedSources:!1,requireGitCommitSha:!1,allowedGitHosts:[],allowedMarketplaces:[],allowedLocalRoots:[]},gn=[{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"}],Bt={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 hn(){const t=me(),a=Ue(p=>{var K;return(K=p.currentSessionRef)==null?void 0:K.projectPath}),s=Ue(p=>p.selectedProjectPath),l=r.useMemo(()=>a??s??new URLSearchParams(window.location.search).get("project")??"",[s,a]),[n,m]=r.useState([]),[f,g]=r.useState([]),[u,i]=r.useState(Pt),[j,c]=r.useState(!1),[h,b]=r.useState(""),[x,E]=r.useState(""),[N,B]=r.useState(""),[$,y]=r.useState(""),[C,H]=r.useState(!1),[S,F]=r.useState(null),[T,k]=r.useState(null),[M,V]=r.useState(""),[q,ee]=r.useState(""),[Z,J]=r.useState(!1),[Q,P]=r.useState(null),[_,G]=r.useState("local"),te=r.useRef(0),L=r.useRef(l);L.current=l;const w=$===l?n:[],v=$===l?f:[],R=r.useCallback(async()=>{const p=++te.current;if(!l){m([]),y(""),k(null);return}H(!0),k(null);try{const[K,ie,se]=await Promise.all([z(`/plugins?projectPath=${encodeURIComponent(l)}`),z(`/plugins/catalog?projectPath=${encodeURIComponent(l)}`),z(`/plugins/policy?projectPath=${encodeURIComponent(l)}`)]);if(p!==te.current)return;m(K),g(ie);const de=(se==null?void 0:se.policy)??Pt;i(de),c((se==null?void 0:se.environmentRequiresSha)??!1),b(de.allowedGitHosts.join(", ")),E(de.allowedMarketplaces.join(", ")),B(de.allowedLocalRoots.join(", ")),y(l)}catch(K){if(p!==te.current)return;k(K instanceof Error?K.message:t("settings.plugins.loadFailed"))}finally{p===te.current&&H(!1)}},[l,t]);r.useEffect(()=>(R(),()=>{te.current+=1}),[R]);const Y=async(p,K)=>{const ie=l;F(p.name),k(null);try{await z(`/plugins/${encodeURIComponent(p.name)}/state`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:ie,enabled:K,scope:_})}),L.current===ie&&await R()}catch(se){L.current===ie&&k(se instanceof Error?se.message:t("settings.plugins.updateFailed"))}finally{F(null)}},xe=p=>[...new Set(p.split(",").map(K=>K.trim()).filter(Boolean))],je=async()=>{await re("policy:save",()=>z("/plugins/policy",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,scope:"local",policy:{...u,allowedGitHosts:xe(h),allowedMarketplaces:xe(x),allowedLocalRoots:xe(N)}})}))},re=async(p,K,ie)=>{const se=l;F(p),k(null);try{await K(),L.current===se&&(ie==null||ie(),P(null),await R())}catch(de){L.current===se&&k(de instanceof Error?de.message:t("settings.plugins.actionFailed"))}finally{F(null)}},ge=async()=>{const p=M.trim();!p||!Z||await re("install",()=>z("/plugins/install",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,source:p,trust:!0})}),()=>{V(""),J(!1)})},ye=async p=>{const K=`update:${p.name}`;if(Q!==K){P(K);return}await re(K,()=>z(`/plugins/${encodeURIComponent(p.name)}/update`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,trust:!0})}))},pe=async p=>{const K=`uninstall:${p.name}`;if(Q!==K){P(K);return}await re(K,()=>z(`/plugins/${encodeURIComponent(p.name)}/uninstall`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,confirm:!0})}))},Ee=async()=>{const p=q.trim();p&&await re("marketplace:add",()=>z("/plugins/marketplaces",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,source:p})}),()=>ee(""))},oe=async p=>{await re(`marketplace:refresh:${p.name}`,()=>z(`/plugins/marketplaces/${encodeURIComponent(p.name)}/refresh`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l})}))},ke=async p=>{const K=`marketplace:remove:${p.name}`;if(Q!==K){P(K);return}await re(K,()=>z(`/plugins/marketplaces/${encodeURIComponent(p.name)}/remove`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,confirm:!0})}))};return l?e.jsxs("div",{className:"flex min-h-0 flex-col gap-3 font-mono",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:[e.jsx(oa,{className:"h-4 w-4"}),t("settings.plugins.heading"),C&&e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"})]}),e.jsx("p",{className:"mt-1 break-all text-[10.5px] text-[#71717a]",children:l}),e.jsx("p",{className:"mt-1 text-[10px] text-[#9CA3AF]",children:t("settings.plugins.changesNote")})]}),e.jsxs("button",{type:"button",onClick:()=>void R(),disabled:C||S!==null,"aria-label":t("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:[e.jsx(Se,{className:"h-3.5 w-3.5"}),t("settings.common.reload")]})]}),T&&e.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:T}),e.jsxs("div",{className:"rounded-md border border-[#E5E7EB] p-3 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:[e.jsx(ut,{className:"h-3.5 w-3.5"}),t("settings.plugins.sourcePolicy")]}),e.jsx("button",{type:"button","aria-label":t("settings.plugins.savePolicyAria"),onClick:()=>void je(),disabled:S!==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:t(S==="policy:save"?"settings.plugins.saving":"settings.plugins.saveForProject")})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-2",children:[e.jsxs("button",{type:"button",role:"switch","aria-label":t("settings.plugins.restrictAria"),"aria-checked":u.restrictToAllowedSources,onClick:()=>i(p=>({...p,restrictToAllowedSources:!p.restrictToAllowedSources})),className:"flex items-center gap-2 text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:[e.jsx("span",{className:D("h-3.5 w-6 rounded-full p-0.5",u.restrictToAllowedSources?"bg-amber-500":"bg-[#D1D5DB] dark:bg-[#3f3f46]"),children:e.jsx("span",{className:D("block h-2.5 w-2.5 rounded-full bg-white transition-transform",u.restrictToAllowedSources&&"translate-x-2.5")})}),t("settings.plugins.restrictAllowlists")]}),e.jsxs("button",{type:"button",role:"switch","aria-label":t("settings.plugins.requireShaAria"),"aria-checked":u.requireGitCommitSha,disabled:j,onClick:()=>i(p=>({...p,requireGitCommitSha:!p.requireGitCommitSha})),className:"flex items-center gap-2 text-[9.5px] text-[#6B7280] disabled:opacity-50 dark:text-[#a1a1aa]",children:[e.jsx("span",{className:D("h-3.5 w-6 rounded-full p-0.5",u.requireGitCommitSha?"bg-emerald-500":"bg-[#D1D5DB] dark:bg-[#3f3f46]"),children:e.jsx("span",{className:D("block h-2.5 w-2.5 rounded-full bg-white transition-transform",u.requireGitCommitSha&&"translate-x-2.5")})}),t("settings.plugins.requireSha"),j?t("settings.plugins.environmentLocked"):""]})]}),e.jsxs("div",{className:"mt-2 grid gap-1.5 sm:grid-cols-3",children:[e.jsx("input",{"aria-label":t("settings.plugins.gitHostsAria"),value:h,onChange:p=>b(p.target.value),placeholder:"github.com, *.corp.test",className:"field h-7 px-2 text-[9.5px]"}),e.jsx("input",{"aria-label":t("settings.plugins.marketplacesAria"),value:x,onChange:p=>E(p.target.value),placeholder:"team-market, official",className:"field h-7 px-2 text-[9.5px]"}),e.jsx("input",{"aria-label":t("settings.plugins.localRootsAria"),value:N,onChange:p=>B(p.target.value),placeholder:"/opt/approved/plugins",className:"field h-7 px-2 text-[9.5px]"})]}),u.restrictToAllowedSources&&!h.trim()&&!x.trim()&&!N.trim()&&e.jsx("p",{className:"mt-1.5 text-[9px] text-amber-700 dark:text-amber-400",children:t("settings.plugins.emptyAllowlists")})]}),e.jsxs("div",{className:"rounded-md border border-[#E5E7EB] p-3 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:[e.jsx(ot,{className:"h-3.5 w-3.5"}),t("settings.plugins.installHeading")]}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx("input",{"aria-label":t("settings.plugins.sourceAria"),value:M,onChange:p=>V(p.target.value),placeholder:"plugin@marketplace, owner/repo, or ./path",disabled:S!==null,className:"field h-8 min-w-0 flex-1 px-2 text-[10.5px]"}),e.jsxs("button",{type:"button",onClick:()=>void ge(),disabled:!M.trim()||!Z||S!==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:[S==="install"?e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ot,{className:"h-3.5 w-3.5"}),t("settings.plugins.install")]})]}),e.jsxs("button",{type:"button",role:"checkbox","aria-checked":Z,onClick:()=>J(p=>!p),className:"mt-2 flex items-center gap-2 text-left text-[9.5px] text-amber-700 dark:text-amber-400",children:[e.jsx("span",{className:D("flex h-3.5 w-3.5 items-center justify-center rounded-sm border",Z?"border-amber-600 bg-amber-600 text-white":"border-[#D1D5DB] dark:border-[#52525b]"),children:Z?"✓":""}),t("settings.plugins.trustSource")]})]}),e.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:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t("settings.plugins.activationScope")}),e.jsx("div",{className:"mt-0.5 text-[9px] text-[#9CA3AF]",children:t("settings.plugins.activationScopeHint")})]}),e.jsx("div",{role:"radiogroup","aria-label":t("settings.plugins.scopeAria"),className:"flex rounded-md bg-[#F3F4F6] p-0.5 dark:bg-[#18181b]",children:gn.map(p=>e.jsx("button",{type:"button",role:"radio","aria-checked":_===p.value,title:t(p.descriptionKey),onClick:()=>G(p.value),className:D("rounded px-2 py-1 text-[9.5px] transition-colors",_===p.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(p.labelKey)},p.value))})]}),e.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[w.map(p=>{var de;const K=S===p.name,ie=[p.commands?t("settings.plugins.capability.commands",{count:p.commands}):"",p.skills?t("settings.plugins.capability.skills",{count:p.skills}):"",p.agents?t("settings.plugins.capability.agents",{count:p.agents}):"",p.hooks?t("settings.plugins.capability.hooks",{count:p.hooks}):"",p.mcpServers?t("settings.plugins.capability.mcp",{count:p.mcpServers}):""].filter(Boolean),se=["global","project","local","invocation"].filter(ce=>{var he;return((he=p.settingLayers)==null?void 0:he[ce])!==void 0}).map(ce=>`${t(Bt[ce])} ${t(p.settingLayers[ce]?"settings.plugins.layer.on":"settings.plugins.layer.off")}`);return e.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:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-[12px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:p.name}),e.jsxs("span",{className:"text-[9.5px] text-[#9CA3AF]",children:["v",p.version]}),e.jsx("span",{className:"rounded bg-[#E5E7EB] px-1.5 py-0.5 text-[9px] uppercase text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]",children:p.source}),e.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:t("settings.plugins.effective",{scope:t(Bt[p.effectiveScope])})})]}),e.jsx("p",{className:"mt-1 text-[10.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:p.description}),e.jsx("p",{className:"mt-1 text-[9.5px] text-[#9CA3AF]",children:ie.join(" · ")||t("settings.plugins.noResources")}),se.length>0&&e.jsx("p",{className:"mt-1 text-[9px] text-[#9CA3AF]",children:se.join(" · ")}),p.managed&&e.jsxs("p",{className:"mt-1 text-[9px] text-[#9CA3AF]",children:[t("settings.plugins.managed"),p.marketplace?` · ${p.marketplace}`:"",p.revision?` · ${p.revision.slice(0,12)}`:""]}),!p.configurable&&e.jsx("p",{className:"mt-1 text-[9.5px] text-amber-600 dark:text-amber-400",children:t("settings.plugins.invocationScoped")}),(de=p.compatibilityIssues)==null?void 0:de.map(ce=>e.jsx("p",{className:"mt-1 text-[9.5px] text-red-600 dark:text-red-400",children:ce.message},`${ce.code}:${ce.message}`))]}),e.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-1.5",children:[e.jsx("button",{type:"button",role:"switch","aria-label":p.status==="error"?t("settings.plugins.unavailableAria",{name:p.name}):p.enabled?t("settings.plugins.disableAria",{name:p.name}):t("settings.plugins.enableAria",{name:p.name}),"aria-checked":p.enabled,disabled:p.status==="error"||!p.configurable||K||S!==null,onClick:()=>void Y(p,!p.enabled),className:D("flex h-6 w-11 items-center rounded-full px-1 transition-colors disabled:opacity-40",p.enabled?"bg-emerald-500":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:D("h-4 w-4 rounded-full bg-white transition-transform",p.enabled?"translate-x-5":"translate-x-0")})}),p.managed&&e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{type:"button","aria-label":t("settings.plugins.updateAria",{name:p.name}),onClick:()=>void ye(p),disabled:S!==null,className:D("rounded px-1.5 py-1 text-[9px] disabled:opacity-40",Q===`update:${p.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:S===`update:${p.name}`?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):Q===`update:${p.name}`?t("settings.plugins.confirmUpdate"):t("settings.plugins.update")}),e.jsx("button",{type:"button","aria-label":t("settings.plugins.uninstallAria",{name:p.name}),onClick:()=>void pe(p),disabled:S!==null,className:D("rounded px-1.5 py-1 text-[9px] disabled:opacity-40",Q===`uninstall:${p.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:S===`uninstall:${p.name}`?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):Q===`uninstall:${p.name}`?t("settings.plugins.confirmRemove"):e.jsx(_e,{className:"h-3 w-3"})})]})]})]},p.name)}),!C&&w.length===0&&!T&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:t("settings.plugins.empty")})]}),e.jsxs("div",{className:"rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[#E5E7EB] px-3 py-2 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:[e.jsx(ia,{className:"h-3.5 w-3.5"}),t("settings.plugins.marketplaces")]}),e.jsx("span",{className:"text-[9px] text-[#9CA3AF]",children:t("settings.plugins.configuredCount",{count:v.length})})]}),e.jsxs("div",{className:"flex gap-2 border-b border-[#E5E7EB] p-2 dark:border-[#27272a]",children:[e.jsx("input",{"aria-label":t("settings.plugins.marketplaceSourceAria"),value:q,onChange:p=>ee(p.target.value),placeholder:"owner/repo, HTTPS Git URL, or ./path",disabled:S!==null,className:"field h-7 min-w-0 flex-1 px-2 text-[10px]"}),e.jsxs("button",{type:"button","aria-label":t("settings.plugins.addMarketplaceAria"),onClick:()=>void Ee(),disabled:!q.trim()||S!==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:[S==="marketplace:add"?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):e.jsx(ct,{className:"h-3 w-3"}),t("settings.plugins.add")]})]}),v.map(p=>e.jsxs("div",{className:"border-b border-[#E5E7EB] px-3 py-2 last:border-b-0 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"text-[10.5px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:[p.name,e.jsxs("span",{className:"ml-2 font-normal text-[#9CA3AF]",children:[p.sourceType," · ",p.revision.slice(0,12)]})]}),e.jsx("p",{className:"mt-0.5 text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:p.description||t("settings.plugins.noDescription")})]}),e.jsxs("div",{className:"flex shrink-0 gap-1",children:[e.jsx("button",{type:"button","aria-label":t("settings.plugins.refreshMarketplaceAria",{name:p.name}),disabled:S!==null,onClick:()=>void oe(p),className:"rounded p-1 text-[#9CA3AF] hover:bg-[#F3F4F6] disabled:opacity-40 dark:hover:bg-[#27272a]",children:S===`marketplace:refresh:${p.name}`?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):e.jsx(Se,{className:"h-3 w-3"})}),e.jsx("button",{type:"button","aria-label":t("settings.plugins.removeMarketplaceAria",{name:p.name}),disabled:S!==null,onClick:()=>void ke(p),className:D("rounded p-1 text-[#9CA3AF] disabled:opacity-40",Q===`marketplace:remove:${p.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:Q===`marketplace:remove:${p.name}`?e.jsx("span",{className:"px-1 text-[8.5px]",children:t("settings.plugins.confirm")}):e.jsx(_e,{className:"h-3 w-3"})})]})]}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1",children:[p.plugins.slice(0,12).map(K=>e.jsxs("button",{type:"button",disabled:K.installed||S!==null,onClick:()=>{V(`${K.name}@${p.name}`),J(!1)},title:K.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:[K.name,K.installed?t("settings.plugins.installedSuffix"):""]},K.name)),p.plugins.length>12&&e.jsxs("span",{className:"px-1 py-0.5 text-[8.5px] text-[#9CA3AF]",children:["+",p.plugins.length-12]})]})]},p.name)),!C&&v.length===0&&e.jsx("div",{className:"px-3 py-4 text-center text-[10px] text-[#9CA3AF]",children:t("settings.plugins.marketplaceEmpty")})]})]}):e.jsx("div",{className:"font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.plugins.selectProject")})}const bn={not_required:"settings.trust.state.notRequired",trusted:"settings.trust.state.trusted",untrusted:"settings.trust.state.review",error:"settings.trust.state.error"};function vn(){const t=me(),a=Ue(T=>{var k;return(k=T.currentSessionRef)==null?void 0:k.projectPath}),s=r.useMemo(()=>a??new URLSearchParams(window.location.search).get("project")??"",[a]),[l,n]=r.useState(null),[m,f]=r.useState(""),[g,u]=r.useState(!1),[i,j]=r.useState(null),[c,h]=r.useState(null),[b,x]=r.useState(null),[E,N]=r.useState(!1),B=r.useRef(0),$=r.useRef(s);$.current=s;const y=m===s?l:null,C=r.useCallback(async()=>{const T=++B.current;if(!s){n(null),f(""),x(null);return}u(!0),x(null);try{const k=await z(`/workspace-trust?projectPath=${encodeURIComponent(s)}`);if(T!==B.current)return;n(k),f(s)}catch(k){if(T!==B.current)return;x(k instanceof Error?k.message:t("settings.trust.loadFailed"))}finally{T===B.current&&u(!1)}},[s,t]);r.useEffect(()=>(h(null),N(!1),C(),()=>{B.current+=1}),[C]);const H=async T=>{if(!y)return;const k=s;j(T),x(null);try{const M=await z("/workspace-trust",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:k,action:T})});$.current===k&&(n(M),f(k),h(null),N(M.reloadRequired===!0))}catch(M){$.current===k&&x(M instanceof Error?M.message:t("settings.trust.updateFailed"))}finally{j(null)}};if(!s)return e.jsx("div",{className:"font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.trust.selectSession")});const S=(y==null?void 0:y.state)==="trusted",F=(y==null?void 0:y.state)==="untrusted";return e.jsxs("div",{className:"flex flex-col gap-3 min-h-0 font-mono",children:[e.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:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[S?e.jsx(ut,{className:"w-4 h-4 text-emerald-600"}):e.jsx($t,{className:D("h-4 w-4",F?"text-amber-600":"text-[#71717a]")}),e.jsx("span",{className:"text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t(y?bn[y.state]:"settings.trust.heading")}),g&&e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"})]}),e.jsx("p",{className:"mt-1 break-all text-[10.5px] text-[#71717a]",children:s}),y&&e.jsxs("p",{className:"mt-1 break-all text-[10px] text-[#9CA3AF]",children:[y.decision,y.inheritedFrom?t("settings.trust.inheritedFrom",{source:y.inheritedFrom}):""]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>void C(),disabled:g||i!==null,"aria-label":t("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:[e.jsx(Se,{className:"h-3.5 w-3.5"}),t("settings.common.reload")]}),S?e.jsx("button",{type:"button",onClick:()=>h("revoke"),disabled:i!==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:t("settings.trust.revoke")}):e.jsx("button",{type:"button",onClick:()=>h("trust"),disabled:i!==null||(y==null?void 0:y.state)==="error"||!y||y.sensitiveSources===0,className:"h-8 rounded-md bg-emerald-600 px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",children:t("settings.trust.trustWorkspace")})]})]}),(b||(y==null?void 0:y.error))&&e.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:b||(y==null?void 0:y.error)}),E&&e.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:t("settings.trust.restartNotice")}),c&&y&&e.jsxs("div",{role:"alertdialog","aria-label":t(c==="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:[e.jsx("span",{className:"max-w-[620px] text-[11px] text-amber-900 dark:text-amber-200",children:c==="trust"?t("settings.trust.confirmTrust",{count:y.sensitiveSources}):t("settings.trust.confirmRevoke")}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("button",{type:"button",onClick:()=>h(null),className:"h-7 rounded px-2 text-[11px] text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.common.cancel")}),e.jsx("button",{type:"button",onClick:()=>void H(c),disabled:i!==null,className:D("h-7 rounded px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",c==="trust"?"bg-emerald-600":"bg-red-600"),children:t(i?"settings.trust.saving":c==="trust"?"settings.trust.trustReviewed":"settings.trust.revokeTrust")})]})]}),e.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[((y==null?void 0:y.sources)??[]).map(T=>e.jsxs("div",{className:"border-b border-[#E5E7EB] px-3 py-2 last:border-b-0 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"font-semibold text-[#111827] dark:text-[#E5E5E5]",children:T.path}),e.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.kind})]}),T.warning&&e.jsx("p",{className:"mt-1 text-[10px] text-amber-700 dark:text-amber-300",children:T.warning}),e.jsx("div",{className:"mt-1.5 flex flex-col gap-1",children:T.effects.map((k,M)=>e.jsxs("div",{className:"break-all text-[10.5px] text-[#374151] dark:text-[#d4d4d8]",children:[e.jsx("span",{className:"text-[#9CA3AF]",children:k.kind})," · ",k.name,k.target?` → ${k.target}`:""]},`${k.kind}-${k.name}-${M}`))})]},`${T.kind}-${T.path}`)),y&&y.sources.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:t("settings.trust.empty")})]})]})}const kn={anthropic:{bg:"#d97757",label:"A"},gemini:{bg:"#4285f4",label:"G"},"azure-openai":{bg:"#0078d4",label:"Az"},"gpt-openai-platform":{bg:"#10a37f",label:"GP"}},jn={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"},Tt={auto:"settings.style.auto",pragmatic:"settings.style.pragmatic",friendly:"settings.style.friendly",explanatory:"settings.style.explanatory"},Mt={Global:"settings.shortcuts.scope.global",Chat:"settings.shortcuts.scope.chat",Layout:"settings.shortcuts.scope.layout"};function Cn(){var Ge,We;const t=me(),{locale:a}=Xt(),{isSettingsOpen:s,settingsSection:l,toggleSettings:n,isSidebarOpen:m,setSidebarOpen:f}=Zt(),{configuredModels:g,loadModels:u,isLoading:i,error:j}=ea(),c=ta(),[h,b]=r.useState("general"),[x,E]=r.useState(!1),[N,B]=r.useState(null),[$,y]=r.useState(null),[C,H]=r.useState(null),[S,F]=r.useState([]),[T,k]=r.useState(null),[M,V]=r.useState(null),[q,ee]=r.useState(null),[Z,J]=r.useState(null),[Q,P]=r.useState({}),[_,G]=r.useState(null),[te,L]=r.useState(null),[w,v]=r.useState(""),[R,Y]=r.useState("all"),xe=r.useRef(null),je=r.useRef(null),re=r.useRef(0),[ge,ye]=r.useState(typeof Notification>"u"?"unsupported":Notification.permission),pe=[{value:"general",label:t("settings.tab.general"),category:t("settings.category.settings")},{value:"trust",label:t("settings.tab.trust"),category:t("settings.category.settings")},{value:"models",label:t("settings.tab.models"),category:t("settings.category.settings")},{value:"shortcuts",label:t("settings.tab.shortcuts"),category:t("settings.category.settings")},{value:"mcp",label:t("settings.tab.mcp"),category:t("settings.category.integrations")},{value:"skills",label:t("settings.tab.skills"),category:t("settings.category.integrations")},{value:"plugins",label:t("settings.tab.plugins"),category:t("settings.category.integrations")},{value:"hooks",label:t("settings.tab.hooks"),category:t("settings.category.integrations")}],oe=r.useMemo(()=>aa.map(d=>({action:t(jn[d.id]),combo:sa(d),scope:d.scope})),[a]).filter(d=>{const O=d.action.toLowerCase().includes(w.toLowerCase()),I=R==="all"||d.scope.toLowerCase()===R;return O&&I}),ke=g.reduce((d,O)=>{const I=O.provider||"unknown";return d[I]||(d[I]=[]),d[I].push(O),d},{}),p=new Map(S.map(d=>[d.id,d]));for(const d of S)d.custom&&!ke[d.id]&&(ke[d.id]=[]);const K=r.useCallback(async()=>{try{F(await z("/providers")),J(null)}catch(d){J(d instanceof Error?d.message:t("settings.models.loadChannelsFailed"))}},[t]);r.useEffect(()=>{s&&(b(l),u(),K(),c.loadSettings())},[s,u,K,c.loadSettings,l]);const ie=()=>{const d=je.current,O=d!=null&&d.isConnected?d:document.querySelector("[data-settings-trigger]");O==null||O.focus({preventScroll:!0})},se=()=>{n(),requestAnimationFrame(ie)};r.useLayoutEffect(()=>{if(!s)return;const d=document.activeElement instanceof HTMLElement?document.activeElement:null;d&&d!==document.body&&d!==document.documentElement&&!d.closest("[data-settings-panel]")&&(je.current=d);const O=requestAnimationFrame(()=>{var I;(I=xe.current)==null||I.focus({preventScroll:!0})});return()=>{cancelAnimationFrame(O),requestAnimationFrame(ie)}},[s]);const de=async d=>{G("save"),L(null);try{return await z("/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:d.provider,displayName:d.displayName,model:d.model,apiKey:d.apiKey,modelProvider:d.modelProvider,overrides:d.overrides})}),await u(),await K(),!0}catch(O){return L(O instanceof Error?O.message:t("settings.models.saveFailed")),!1}finally{G(null)}},ce=async()=>{typeof Notification>"u"||ye(await Notification.requestPermission())},he=async d=>{G("delete"),L(null);try{await z(`/models/${d}`,{method:"DELETE"}),await u(),H(null)}catch(O){L(O instanceof Error?O.message:t("settings.models.deleteFailed"))}finally{G(null)}},Ne=async(d,O)=>{G("update"),L(null);try{return await z(`/models/${d}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)}),await u(),!0}catch(I){return L(I instanceof Error?I.message:t("settings.models.updateFailed")),!1}finally{G(null)}},A=async(d,O)=>{ee({providerId:d,type:"update"}),J(null);try{return await z(`/providers/${d}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)}),await Promise.all([u(),K()]),!0}catch(I){return J(I instanceof Error?I.message:t("settings.models.updateChannelFailed")),!1}finally{ee(null)}},Te=async(d,O)=>{ee({providerId:d.id,type:"probe"}),J(null);try{const I=await z(`/providers/${d.id}/probe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modelId:O})});P(o=>({...o,[d.id]:I}))}catch(I){J(I instanceof Error?I.message:t("settings.models.probeFailed"))}finally{ee(null)}},be=async d=>{ee({providerId:d.id,type:"delete"}),J(null);try{await z(`/providers/${d.id}?removeModels=true`,{method:"DELETE"}),V(null),B(null),P(O=>{const I={...O};return delete I[d.id],I}),await Promise.all([u(),K()])}catch(O){J(O instanceof Error?O.message:t("settings.models.deleteChannelFailed"))}finally{ee(null)}},De=(d,O)=>{var W,U;const I=d.key==="ArrowRight"||d.key==="ArrowDown"?1:d.key==="ArrowLeft"||d.key==="ArrowUp"?-1:0;if(I===0&&d.key!=="Home"&&d.key!=="End")return;d.preventDefault();const o=d.key==="Home"?0:d.key==="End"?pe.length-1:(O+I+pe.length)%pe.length;b(pe[o].value),(U=(W=d.currentTarget.closest('[role="tablist"]'))==null?void 0:W.querySelectorAll('[role="tab"]')[o])==null||U.focus()},Le=d=>{B(N===d?null:d)},tt=d=>{if(!s||d.key!=="Escape"||!(d.target instanceof Node)||!d.currentTarget.contains(d.target)||x||$||T||Date.now()-re.current<250)return;const O=d.target instanceof Element?d.target:null;if(!(d.defaultPrevented||O!=null&&O.closest('[role="dialog"]'))){if(d.preventDefault(),C){H(null);return}if(M){V(null);return}se()}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-settings-panel":!0,onKeyDown:tt,className:"flex h-full min-h-0 bg-white dark:bg-[#09090b]",children:[e.jsxs("nav",{role:"tablist","aria-label":t("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:[e.jsx("div",{className:"p-4 shrink-0",children:e.jsxs("button",{ref:xe,type:"button",onClick:se,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:[e.jsx(da,{className:"h-3.5 w-3.5"}),t("settings.action.back")]})}),e.jsx("div",{className:"overflow-y-auto flex-1 px-3 pb-4",children:Object.entries(pe.reduce((d,O)=>(d[O.category]||(d[O.category]=[]),d[O.category].push(O),d),{})).map(([d,O])=>e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"mb-1 px-3 text-[10px] font-semibold uppercase tracking-wider text-[#9CA3AF] dark:text-[#71717a]",children:d}),O.map(I=>e.jsx("button",{onClick:()=>b(I.value),onKeyDown:o=>De(o,pe.indexOf(I)),role:"tab",id:`settings-tab-${I.value}`,"aria-controls":`settings-panel-${I.value}`,"aria-selected":h===I.value,tabIndex:h===I.value?0:-1,className:D("w-full rounded-md px-3 py-1.5 text-left text-[13px] transition-colors",h===I.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:I.label},I.value))]},d))})]}),e.jsx("div",{className:"flex overflow-hidden flex-col flex-1 min-h-0",children:e.jsx("div",{className:"overflow-y-auto flex-1 p-6 sm:p-10",children:e.jsxs("div",{className:"mx-auto max-w-2xl",children:[e.jsx("h1",{className:"mb-6 text-xl font-semibold text-[#111827] dark:text-[#E5E5E5]",children:((Ge=pe.find(d=>d.value===h))==null?void 0:Ge.label)??t("settings.title")}),c.isLoading&&h==="general"&&e.jsxs("div",{role:"status",className:"flex shrink-0 items-center gap-2 text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"}),t("settings.general.loading")]}),c.error&&h==="general"&&e.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:[e.jsx(Re,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0",children:c.error}),e.jsx("button",{type:"button",onClick:()=>void c.loadSettings(),className:"underline shrink-0",children:t("settings.common.retry")})]}),h==="models"&&e.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:[e.jsx("p",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono shrink-0",children:t("settings.models.description")}),(j||te||Z)&&e.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:[e.jsx(Re,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0",children:Z||te||j}),e.jsx("button",{type:"button",onClick:()=>{L(null),J(null),j&&u()},className:"underline shrink-0",children:t(j?"settings.common.retry":"settings.common.dismiss")})]}),C&&e.jsxs("div",{role:"alertdialog","aria-label":t("settings.models.deleteModelAria",{name:C.displayName||C.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:[e.jsx("span",{className:"text-[11px] font-mono text-red-700 dark:text-red-300",children:t("settings.models.deleteModelPrompt",{name:C.displayName||C.model})}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("button",{type:"button",onClick:()=>H(null),className:"h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.common.cancel")}),e.jsx("button",{type:"button",onClick:()=>void he(C.id),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:t(_==="delete"?"settings.models.deleting":"settings.models.deleteModel")})]})]}),M&&e.jsxs("div",{role:"alertdialog","aria-label":t("settings.models.deleteChannelAria",{name:M.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:[e.jsx("span",{className:"text-[11px] font-mono text-red-700 dark:text-red-300",children:t("settings.models.deleteChannelPrompt",{name:M.name,count:((We=ke[M.id])==null?void 0:We.length)??0})}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("button",{type:"button",onClick:()=>V(null),className:"h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.common.cancel")}),e.jsx("button",{type:"button",onClick:()=>void be(M),disabled:q!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:(q==null?void 0:q.type)==="delete"?t("settings.models.deleting"):t("settings.models.deleteChannel")})]})]}),e.jsx("div",{className:"overflow-y-auto flex-1 min-h-0",children:e.jsxs("div",{className:"flex flex-col gap-2 pr-2",children:[i&&g.length===0&&e.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-8 text-sm font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsx(ne,{className:"w-4 h-4 animate-spin"}),t("settings.models.loading")]}),Object.entries(ke).map(([d,O])=>{const I=kn[d]||{bg:"#71717a",label:"?"},o=p.get(d),W=N===d,U=Q[d],fe=(q==null?void 0:q.providerId)===d&&q.type==="probe";return e.jsxs("div",{className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsxs("button",{onClick:()=>Le(d),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:[e.jsxs("div",{className:"flex gap-3 items-center min-w-0",children:[e.jsx("div",{className:"flex justify-center items-center w-8 h-8 text-xs font-bold text-white rounded shrink-0",style:{backgroundColor:I.bg},children:I.label}),e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5 text-left",children:[e.jsx("span",{className:"truncate text-sm font-semibold font-mono text-[#111827] dark:text-[#E5E5E5]",children:(o==null?void 0:o.name)??d.replace(/-/g," ")}),e.jsxs("span",{className:"truncate text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[O.length===1?t("settings.models.modelCountOne",{count:O.length}):t("settings.models.modelCountMany",{count:O.length}),o!=null&&o.custom?` · ${o.wireApi}`:""]})]})]}),e.jsxs("div",{className:"flex gap-3 items-center shrink-0",children:[e.jsxs("span",{className:D("text-xs font-mono",(o==null?void 0:o.configured)===!1?"text-amber-600":"text-[#16A34A]"),children:["●"," ",(o==null?void 0:o.configured)===!1?t("settings.models.missingCredential"):t("settings.models.configured")]}),e.jsx(Lt,{className:D("h-4 w-4 text-[#9CA3AF] transition-transform dark:text-[#71717a]",W&&"rotate-180")})]})]}),(o==null?void 0:o.custom)&&e.jsxs("div",{className:"flex gap-1 items-center pr-3 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{var le;return void Te(o,(le=O[0])==null?void 0:le.id)},disabled:q!==null||O.length===0,"aria-label":t("settings.models.testChannelAria",{name:o.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:fe?e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ca,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button","data-edit-provider-trigger":o.id,onClick:()=>{J(null),k(o)},disabled:q!==null,"aria-label":t("settings.models.editChannelAria",{name:o.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:e.jsx(ft,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>V(o),disabled:q!==null,"aria-label":t("settings.models.deleteChannelActionAria",{name:o.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:e.jsx(_e,{className:"h-3.5 w-3.5"})})]})]}),U&&e.jsxs("div",{role:"status",className:D("border-t px-4 py-2 font-mono text-[11px]",U.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:[U.message," · ",U.latencyMs,"ms · ",U.wireApi]}),W&&e.jsxs("div",{className:"border-t border-[#E5E7EB] dark:border-zinc-800",children:[(o==null?void 0:o.custom)&&e.jsxs("div",{className:"border-b border-[#E5E7EB] px-4 py-2 font-mono text-[11px] text-[#71717a] dark:border-zinc-800",children:[e.jsx("span",{className:"font-semibold",children:o.id})," ","· ",o.defaultBaseUrl]}),O.map(le=>{var $e;return e.jsxs("div",{className:"px-4 py-3 flex items-center justify-between hover:bg-[#E5E7EB] dark:hover:bg-[#1f1f23] group",children:[e.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[e.jsx("span",{className:"text-sm text-[#111827] dark:text-[#E5E5E5] font-mono truncate",children:le.displayName||le.model}),e.jsxs("span",{className:"text-xs text-[#9CA3AF] dark:text-[#71717a] font-mono truncate",children:[le.displayName&&`${le.model} · `,(($e=le.overrides)==null?void 0:$e.baseUrl)||t("settings.models.defaultEndpoint")]})]}),e.jsxs("div",{className:"flex gap-2 items-center opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:[e.jsx("button",{"data-edit-model-trigger":le.id,onClick:()=>{L(null),y(le)},disabled:_!==null,"aria-label":t("settings.models.editModelAria",{name:le.displayName||le.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:e.jsx(ft,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>H(le),disabled:_!==null,"aria-label":t("settings.models.deleteModelAria",{name:le.displayName||le.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:e.jsx(_e,{className:"h-3.5 w-3.5"})})]})]},le.id)})]})]},d)}),!i&&!j&&Object.keys(ke).length===0&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:t("settings.models.empty")})]})}),e.jsx("button",{"data-add-model-trigger":!0,onClick:()=>{L(null),E(!0)},disabled:_!==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:t("settings.models.add")})]}),h==="general"&&e.jsxs("div",{id:"settings-panel-general",role:"tabpanel","aria-labelledby":"settings-tab-general","aria-busy":c.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:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:t("settings.tab.general")}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.general.responseLanguage")}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:t("settings.general.responseLanguageHint")})]}),e.jsx(Ae,{"aria-label":t("settings.general.responseLanguage"),value:c.language,onChange:d=>c.updateSettings({language:d}),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:"Русский"}]})]}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.general.autoSave")}),e.jsx(we,{label:t("settings.general.autoSave"),enabled:c.autoSaveSessions,onChange:d=>c.updateSettings({autoSaveSessions:d})})]}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.general.communicationStyle")}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:t("settings.general.communicationStyleHint")})]}),e.jsx(Ae,{"aria-label":t("settings.general.communicationStyle"),value:c.communicationStyle??"auto",onChange:d=>c.updateSettings({communicationStyle:d}),className:"h-8 w-auto min-w-[140px] text-[12px]",options:dn.map(d=>({value:d.id,label:Tt[d.id]?t(Tt[d.id]):d.name}))})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:t("settings.appearance.heading")}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.appearance.theme")}),e.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(d=>e.jsx("button",{onClick:()=>c.updateSettings({uiTheme:d}),className:D("px-3 py-1 rounded text-[12px] font-mono transition-colors",c.uiTheme===d?"bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5]":"text-[#9CA3AF] dark:text-[#71717a] hover:text-[#111827] dark:hover:text-[#E5E5E5]"),children:t(d==="dark"?"settings.appearance.theme.dark":d==="light"?"settings.appearance.theme.light":"settings.appearance.theme.system")},d))})]}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.appearance.compactSidebar")}),e.jsx(we,{label:t("settings.appearance.compactSidebar"),enabled:!m,onChange:d=>f(!d)})]}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.appearance.codeTheme")}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:t("settings.appearance.codeThemeHint")})]}),e.jsx(Ae,{"aria-label":t("settings.appearance.codeTheme"),value:c.theme,onChange:d=>c.updateSettings({theme:d}),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"}]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:t("settings.notifications.heading")}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.notifications.buildFinished")}),e.jsx(we,{label:t("settings.notifications.buildFinished"),enabled:c.notifyBuild,onChange:d=>c.updateSettings({notifyBuild:d})})]}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.notifications.errorsOnly")}),e.jsx(we,{label:t("settings.notifications.errorsOnly"),enabled:c.notifyErrors,onChange:d=>c.updateSettings({notifyErrors:d})})]}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.notifications.systemSounds")}),e.jsx(we,{label:t("settings.notifications.systemSounds"),enabled:c.notifySounds,onChange:d=>c.updateSettings({notifySounds:d})})]}),(c.notifyBuild||c.notifyErrors)&&ge!=="granted"&&e.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:[e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:t(ge==="denied"?"settings.notifications.blocked":ge==="unsupported"?"settings.notifications.unavailable":"settings.notifications.enablePrompt")}),ge==="default"&&e.jsx("button",{type:"button",onClick:()=>void ce(),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:t("settings.common.enable")})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:t("settings.privacy.heading")}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.privacy.telemetry")}),e.jsx(we,{label:t("settings.privacy.telemetry"),enabled:c.privacyTelemetry,onChange:d=>c.updateSettings({privacyTelemetry:d})})]}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.privacy.crash")}),e.jsx(we,{label:t("settings.privacy.crash"),enabled:c.privacyCrash,onChange:d=>c.updateSettings({privacyCrash:d})})]})]})]}),h==="shortcuts"&&e.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:[e.jsxs("div",{className:"flex flex-col gap-2 shrink-0 sm:flex-row sm:items-center sm:gap-3",children:[e.jsx("input",{"aria-label":t("settings.shortcuts.searchPlaceholder"),value:w,onChange:d=>v(d.target.value),placeholder:t("settings.shortcuts.searchPlaceholder"),className:"field flex-1 text-[12px]"}),e.jsx(Ae,{"aria-label":t("settings.shortcuts.col.scope"),value:R,onChange:d=>Y(d),className:"w-auto min-w-[120px] text-[12px]",options:[{value:"all",label:t("settings.shortcuts.scope.all")},{value:"global",label:t("settings.shortcuts.scope.global")},{value:"chat",label:t("settings.shortcuts.scope.chat")},{value:"layout",label:t("settings.shortcuts.scope.layout")}]}),e.jsx("button",{onClick:()=>{v(""),Y("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:t("settings.shortcuts.reset")})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-auto border border-[#E5E7EB] dark:border-[#27272a] rounded-lg bg-[#E5E7EB] dark:bg-[#111827]",children:[e.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:[e.jsx("span",{children:t("settings.shortcuts.col.action")}),e.jsx("span",{children:t("settings.shortcuts.col.shortcut")}),e.jsx("span",{children:t("settings.shortcuts.col.scope")})]}),oe.map((d,O)=>e.jsxs("div",{className:D("grid min-w-[520px] grid-cols-[1fr_180px_120px] gap-2 px-3 py-2 text-[13px] font-mono",O%2===0?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C]"),children:[e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5]",children:d.action}),e.jsx("div",{className:"flex gap-1 items-center",children:d.combo.map(I=>e.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:I},I))}),e.jsx("span",{className:"text-[#6B7280] dark:text-[#94a3b8] text-[12px]",children:Mt[d.scope]?t(Mt[d.scope]):d.scope})]},`${d.action}-${d.scope}`)),oe.length===0&&e.jsx("div",{className:"px-3 py-6 text-center text-[12px] text-[#6B7280] dark:text-[#94a3b8] font-mono",children:t("settings.shortcuts.empty")})]})]}),h==="mcp"&&e.jsx("div",{id:"settings-panel-mcp",role:"tabpanel","aria-labelledby":"settings-tab-mcp",className:"flex-1 min-h-0",children:e.jsx(en,{active:h==="mcp"})}),h==="skills"&&e.jsx("div",{id:"settings-panel-skills",role:"tabpanel","aria-labelledby":"settings-tab-skills",className:"flex-1 min-h-0",children:e.jsx(rn,{active:h==="skills"})}),h==="hooks"&&e.jsx("div",{id:"settings-panel-hooks",role:"tabpanel","aria-labelledby":"settings-tab-hooks",className:"flex-1 min-h-0",children:e.jsx(fn,{})}),h==="plugins"&&e.jsx("div",{id:"settings-panel-plugins",role:"tabpanel","aria-labelledby":"settings-tab-plugins",className:"flex-1 min-h-0",children:e.jsx(hn,{})}),h==="trust"&&e.jsx("div",{id:"settings-panel-trust",role:"tabpanel","aria-labelledby":"settings-tab-trust",className:"flex-1 min-h-0",children:e.jsx(vn,{})})]})})})]}),x&&e.jsx(un,{open:!0,onOpenChange:d=>{d||(re.current=Date.now()),E(d)},onSave:de,saveError:te}),$&&e.jsx(mn,{open:!0,onOpenChange:d=>{d||(re.current=Date.now(),y(null))},model:$,onSave:Ne,saveError:te}),T&&e.jsx(xn,{provider:T,onOpenChange:d=>{d||(re.current=Date.now(),k(null))},onSave:A,saveError:Z})]})}function we({label:t,enabled:a,onChange:s}){return e.jsx("button",{type:"button",role:"switch","aria-label":t,"aria-checked":a,onClick:()=>s(!a),className:D("flex h-6 w-11 items-center rounded-full px-1 transition-colors",a?"bg-[#22C55E]":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:D("h-4 w-4 rounded-full transition-transform",a?"translate-x-5 bg-white":"translate-x-0 bg-white dark:bg-[#a1a1aa]")})})}export{Cn as SettingsModal};
|