@qodalis/console 0.0.0-stage → 1.0.0-beta.33

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.
@@ -0,0 +1,2 @@
1
+ import{u as O,a8 as Ae,r as h,j as e,ae as Te,d as Be,af as Fe,a as De,T as _e,b as Ve,X as je,P as ze,E as Ne,f as ae,ab as Le,ag as Ye,ah as Ue,ai as We,F as Ge,aj as Qe,l as Xe,m as we,a0 as Je}from"./index-DNbEWPIs.js";import{B as y}from"./Badge-DXfBhPf0.js";import{a as Ce,i as Ee,e as Me,s as Ze,d as W,C as es,F as ss,b as ts,t as ns}from"./ConfigInput-Di-TZY52.js";const ye={default:{label:"config.sourceDefault",hint:"config.sourceDefaultHint"},file:{label:"config.sourceFile",hint:"config.sourceFileHint"},environment:{label:"config.sourceEnvironment",hint:"config.sourceEnvironmentHint"},database:{label:"config.sourceDatabase",hint:"config.sourceDatabaseHint"},runtime:{label:"config.sourceRuntime",hint:"config.sourceRuntimeHint"},code:{label:"config.sourceCode",hint:"config.originCodeHint"}};function is(s,t){return s==="file"&&(t==null?void 0:t.kind)==="configuration"?{label:"config.sourceConfiguration",hint:"config.sourceConfigurationHint"}:ye[s]??ye.default}function rs(s,t){return s(t.key,t.params)}function os(s){const{providerId:t,writable:i,storage:l,section:c,highlighted:f=!1,added:m,edits:g,serverErrors:P,query:C,saving:k,stale:b,conflict:u,editors:I,onEdit:M,onAddKey:R,onReload:D}=s,{t:v}=O(),{isPending:B}=Ae(),N=i&&c.mutable,H=[...c.entries,...m].filter(x=>Ce(x,C)),q=new Set(c.entries.map(x=>x.key)),_=h.useRef(null);return h.useEffect(()=>{var x,E;f&&((E=(x=_.current)==null?void 0:x.scrollIntoView)==null||E.call(x,{block:"start",behavior:"smooth"}))},[f]),e.jsxs("section",{ref:_,id:`cfg-section-${t}-${c.id}`,"aria-labelledby":`cfg-${t}-${c.id}`,"aria-current":f?"location":void 0,"data-highlighted":f||void 0,className:`bg-surface border rounded-xl overflow-hidden scroll-mt-4 ${f?"border-primary ring-2 ring-primary/40":"border-border"}`,children:[e.jsxs("div",{className:"px-4 sm:px-5 py-3 border-b border-border/75 flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("h3",{id:`cfg-${t}-${c.id}`,className:"text-sm font-semibold text-heading",children:c.title||c.id}),!N&&e.jsx(y,{variant:"neutral",children:v("config.readOnly")}),c.description&&e.jsx("p",{className:"basis-full text-xs text-subtle",children:c.description})]}),b&&e.jsxs("div",{role:"status",className:"px-4 sm:px-5 py-2 bg-warning/10 border-b border-warning/30 text-warning text-xs flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"flex-1 min-w-[12rem]",children:v("config.changedOnServer")}),e.jsx("button",{type:"button",onClick:D,className:"px-2 py-1 rounded-md border border-warning/40 hover:bg-warning/10",children:v("config.reload")})]}),u&&e.jsxs("div",{role:"alert",className:"px-4 sm:px-5 py-2 bg-error/[0.06] border-b border-error/30 text-error text-xs flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"flex-1 min-w-[12rem]",children:v("config.conflict")}),e.jsx("button",{type:"button",onClick:D,className:"px-2 py-1 rounded-md border border-error/40 hover:bg-error/10",children:v("config.reload")})]}),H.length===0&&c.entries.length+m.length>0&&e.jsx("div",{className:"px-5 py-4 text-xs text-subtle",children:v("config.noMatches")}),c.entries.length+m.length===0&&e.jsx("div",{className:"px-5 py-4 text-xs text-subtle",children:v("config.noEntries")}),e.jsx("div",{className:"divide-y divide-border/50",children:H.map(x=>e.jsx(as,{id:`cfg-${t}-${c.id}-${x.key}`,entry:x,storage:l,editable:N&&x.mutable,freeKey:c.allowCustomKeys&&!x.sensitive&&x.default===null,pendingRestart:x.requiresRestart&&B(Te(t,c.id,x.key)),isNew:m.includes(x),edit:g[x.key],serverError:P[x.key],saving:k,editors:I,onEdit:E=>M(x.key,E)},x.key))}),N&&c.allowCustomKeys&&!C.trim()&&e.jsx(ls,{taken:x=>q.has(x)||m.some(E=>E.key===x),disabled:k,onAdd:R})]})}function as({id:s,entry:t,storage:i,editable:l,freeKey:c,pendingRestart:f,isNew:m,edit:g,serverError:P,saving:C,editors:k,onEdit:b}){const{t:u}=O(),I=t.label||t.key,M=!!g&&(m||Ee(t,g)),R=g&&M?Me(t,g):null,v=(R&&"problem"in R?rs(u,R.problem):void 0)??P,B=is(t.source,i),N=t.sensitive||t.type==="secret",H=l&&!N&&!m&&(g==null?void 0:g.kind)!=="reset"&&t.origin!=="code"&&(c||!Ze(t.value,t.default)||t.source!=="default"&&t.source!=="code"),q=N?!t.isSet:t.value===null||t.value===""||Array.isArray(t.value)&&t.value.length===0;return e.jsxs("div",{className:`px-4 sm:px-5 py-3 flex flex-col md:flex-row md:items-start gap-2 md:gap-6 ${M?"bg-primary/[0.04]":""}`,"data-config-key":t.key,children:[e.jsxs("div",{className:"md:w-64 shrink-0 min-w-0",children:[e.jsx("label",{htmlFor:s,className:"block text-sm text-text break-words",children:I}),I!==t.key&&e.jsx("div",{className:"text-[11px] font-mono text-subtle break-all",children:t.key}),t.description&&e.jsx("div",{className:"text-[11px] text-subtle mt-0.5",children:t.description}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[!m&&e.jsx("span",{title:u(B.hint),"data-source":t.source,className:"inline-flex",children:e.jsx(y,{variant:"neutral",children:u(B.label)})}),!m&&t.origin==="code"&&t.source!=="code"&&e.jsx("span",{title:u("config.originCodeHint"),"data-origin":"code",className:"inline-flex",children:e.jsx(y,{variant:"info",children:u("config.originCode")})}),!m&&t.origin==="setting"&&e.jsx("span",{title:u("config.originSettingHint"),"data-origin":"setting",className:"inline-flex",children:e.jsx(y,{variant:"success",children:u("config.originSetting")})}),t.required&&(q?e.jsx("span",{"data-required":"missing",className:"inline-flex",children:e.jsx(y,{variant:"warning",children:u("config.requiredMissing")})}):e.jsx("span",{"data-required":!0,className:"inline-flex",children:e.jsx(y,{variant:"neutral",children:u("config.required")})})),f?e.jsx("span",{title:u("restart.pendingBadgeHint"),"data-pending-restart":!0,className:"inline-flex",children:e.jsxs(y,{variant:"warning",children:["⟳ ",u("restart.pendingBadge")]})}):t.requiresRestart&&e.jsx(y,{variant:"neutral",children:u("config.restartBadge")}),!l&&e.jsx(y,{variant:"neutral",children:u("config.readOnly")}),N&&(t.isSet?e.jsx(y,{variant:"info",children:u("config.secretSet")}):e.jsx(y,{variant:"neutral",children:u("config.secretNotSet")})),M&&e.jsx(y,{variant:"info",children:u("config.modified")})]})]}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-1.5",children:[l?(g==null?void 0:g.kind)==="reset"&&!N?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-warning",children:c?u("config.willRemove"):u("config.willReset",{value:W(t.default)})}),e.jsx("button",{type:"button",onClick:()=>b(void 0),className:"px-2 py-1 rounded-md bg-control hover:bg-control-hover text-text",children:u("config.undo")})]}):e.jsx(es,{id:s,entry:t,edit:g,onEdit:b,disabled:C,error:v,editors:k}):e.jsx("div",{id:s,className:"text-sm font-mono text-text break-all whitespace-pre-wrap",children:N?t.isSet?"••••••••":"—":W(t.value)}),v&&e.jsx("div",{role:"alert",className:"text-xs text-error",children:v}),l&&(H||g&&g.kind!=="reset")&&e.jsxs("div",{className:"flex flex-wrap gap-3 text-[11px]",children:[g&&!N&&e.jsx("button",{type:"button",onClick:()=>b(void 0),className:"text-subtle hover:text-text underline-offset-2 hover:underline",children:u("config.undo")}),H&&e.jsx("button",{type:"button",onClick:()=>b({kind:"reset"}),className:"text-subtle hover:text-text underline-offset-2 hover:underline",children:u(c?"config.removeKey":"config.resetToDefault")})]})]})]})}function ls({taken:s,disabled:t,onAdd:i}){const{t:l}=O(),[c,f]=h.useState(""),[m,g]=h.useState("string"),[P,C]=h.useState(null);function k(){const b=c.trim();if(!ts.test(b))return C(l("config.invalidKey"));if(s(b))return C(l("config.keyExists",{key:b}));i({key:b,label:b,description:"",type:m,value:null,default:null,source:"runtime",mutable:!0,requiresRestart:!1,sensitive:!1}),f(""),C(null)}return e.jsxs("div",{className:"px-4 sm:px-5 py-3 border-t border-border/75",children:[e.jsx("div",{className:"text-xs font-medium text-muted mb-2",children:l("config.addKey")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("input",{type:"text",value:c,onChange:b=>{f(b.target.value),C(null)},onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),k())},placeholder:l("config.newKeyPlaceholder"),"aria-label":l("config.newKey"),disabled:t,className:"flex-1 min-w-[10rem] max-w-xs px-3 py-2 text-sm font-mono bg-control border border-border rounded-lg text-text placeholder-subtle focus:outline-none focus:border-primary/50"}),e.jsx(Be,{value:m,onChange:g,options:ss.map(b=>({value:b,label:b})),label:l("config.newKeyType"),disabled:t,size:"md",width:"auto"}),e.jsx("button",{type:"button",onClick:k,disabled:t||!c.trim(),className:"px-3 py-2 text-sm bg-control hover:bg-control-hover text-text rounded-lg disabled:opacity-40",children:l("config.add")})]}),P&&e.jsx("div",{role:"alert",className:"mt-1.5 text-xs text-error",children:P})]})}const cs=new Set(["memory","database","redis"]);function F(s){return s.kind==="file"?/appsettings/i.test(`${s.detail} ${s.title}`)?"appsettings":"file":cs.has(s.kind)?s.kind:"custom"}function ke(s,t){return s.store??(s.writable?t:null)}function ds(s){const t=new Map;for(const i of s){if(!i)continue;const l=F(i),c=l==="custom"?`custom:${i.title}`:l,f=t.get(c);f?f.persistent&&!i.persistent&&t.set(c,i):t.set(c,i)}return[...t.values()]}const us={memory:"config.storeMemory",file:"config.storeFile",appsettings:"config.storeAppsettings",database:"config.storeDatabase",redis:"config.storeRedis"};function J(){const{t:s}=O();return t=>{const i=F(t);return i==="custom"?t.title||s("config.storeCustom"):s(us[i])}}function le(){const{t:s}=O(),t=J();return i=>[[i.title||t(i),i.detail].filter(Boolean).join(": "),i.persistent?"":s("config.storeNotPersistent")].filter(Boolean).join(`
2
+ `)}const fs={memory:"M7 7h10v10H7zM9 3v4M15 3v4M9 17v4M15 17v4M3 9h4M3 15h4M17 9h4M17 15h4",file:"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8zM14 3v5h5M9 13h6M9 17h4",appsettings:"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8zM14 3v5h5M10 12c-1 0-1 .5-1 1.5S8.5 15 8 15c.5 0 1 .5 1 1.5s0 1.5 1 1.5M14 12c1 0 1 .5 1 1.5s.5 1.5 1 1.5c-.5 0-1 .5-1 1.5s0 1.5-1 1.5",database:"M4 6c0-1.7 3.6-3 8-3s8 1.3 8 3-3.6 3-8 3-8-1.3-8-3zM4 6v12c0 1.7 3.6 3 8 3s8-1.3 8-3V6M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3",redis:"M12 3 3 7.5 12 12l9-4.5zM3 12l9 4.5 9-4.5M3 16.5 12 21l9-4.5",custom:"M21 8 12 3 3 8v8l9 5 9-5zM3 8l9 5 9-5M12 13v8"};function X({store:s,className:t="w-3.5 h-3.5"}){const i=F(s);return e.jsx("svg",{"data-store-icon":i,"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:`shrink-0 ${t}`,children:e.jsx("path",{d:fs[i]})})}function xs({store:s}){const t=J(),i=le();return e.jsxs("span",{"data-store-badge":F(s),title:i(s),className:`ml-auto inline-flex items-center ${s.persistent?"text-subtle":"text-warning"}`,children:[e.jsx(X,{store:s}),e.jsxs("span",{className:"sr-only",children:["(",t(s),")"]})]})}const gs={store:"config.storageStore",runtime:"config.storageRuntime",options:"config.storageOptions",environment:"config.storageEnvironment",configuration:"config.storageConfiguration",custom:"config.storageCustom"};function ms({defaultStore:s,stores:t}){const{t:i}=O(),l=J(),c=le(),f=s!==null&&!s.persistent;return e.jsxs("div",{role:f?"alert":"note","data-store-kind":s==null?void 0:s.kind,className:`px-4 sm:px-6 py-2 border-b text-xs flex flex-wrap items-center gap-x-4 gap-y-1 ${f?"bg-warning/10 border-warning/30 text-warning":"border-border/75 text-muted"}`,children:[s&&e.jsxs("div",{"data-default-store":!0,className:"flex flex-wrap items-center gap-x-1.5 gap-y-1 min-w-0",children:[e.jsx("span",{children:i("config.storeDefault")}),e.jsx(X,{store:s}),e.jsx("span",{className:"font-medium text-heading",children:l(s)}),s.detail&&e.jsx("span",{className:"font-mono break-all",children:s.detail}),f&&e.jsx("span",{className:"basis-full sm:basis-auto sm:ml-2 font-medium",children:i("config.storeNotPersistent")})]}),t.length>0&&e.jsxs("div",{"data-store-summary":!0,title:i("config.storesHint"),className:"flex flex-wrap items-center gap-x-1.5 gap-y-1 min-w-0",children:[e.jsx("span",{children:i("config.storesInUse")}),e.jsx("ul",{"aria-label":i("config.storesInUse"),className:"contents",children:t.map((m,g)=>e.jsxs("li",{className:"inline-flex items-center gap-1.5",children:[g>0&&e.jsx("span",{"aria-hidden":"true",className:"text-subtle",children:"·"}),e.jsxs("span",{"data-store-summary-item":F(m),title:c(m),className:`inline-flex items-center gap-1 ${m.persistent?"text-heading":"text-warning"}`,children:[e.jsx(X,{store:m}),l(m)]})]},`${F(m)}:${m.title}`))})]})]})}function ps({store:s}){const{t}=O(),i=J(),l=le();return e.jsxs("div",{role:s.persistent?void 0:"alert","data-provider-store":s.kind,className:`text-xs flex flex-wrap items-center gap-x-1.5 gap-y-1 ${s.persistent?"text-subtle":"p-2 rounded-lg bg-warning/10 border border-warning/30 text-warning"}`,children:[e.jsx("span",{children:t("config.storeSavedTo")}),e.jsxs("span",{title:l(s),className:"inline-flex items-center gap-1 font-medium text-heading",children:[e.jsx(X,{store:s}),i(s)]}),s.detail&&e.jsxs("span",{className:"font-mono break-all",children:["(",s.detail,")"]}),!s.persistent&&e.jsx("span",{className:"basis-full font-medium",children:t("config.storeNotPersistent")})]})}function hs({storage:s}){const{t}=O(),i=(s.sources??[]).filter(l=>typeof l=="string"&&l!=="");return e.jsxs("div",{"data-provider-storage":s.kind,className:"text-xs text-subtle space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{children:t("config.storageReadsFrom")}),e.jsx(y,{variant:"neutral",children:t(gs[s.kind]??"config.storageCustom")}),s.description&&e.jsx("span",{children:s.description}),i.length===1&&e.jsxs("span",{className:"font-mono",children:["(",i[0],")"]})]}),i.length>1&&e.jsxs("div",{children:[e.jsx("div",{children:t("config.storageSources")}),e.jsx("ol",{"aria-label":t("config.storageSources"),className:"mt-0.5 ml-4 list-decimal font-mono",children:i.map(l=>e.jsx("li",{children:l},l))})]})]})}const bs=new Map,Se=new Set;function vs(){const s=Fe("config"),[t,i]=h.useState(0);return h.useEffect(()=>{const l=()=>i(c=>c+1);return Se.add(l),()=>{Se.delete(l)}},[]),h.useMemo(()=>{const l=new Map;bs.forEach((c,f)=>l.set(f,{kind:"component",Component:c}));for(const{extension:c,module:f}of s)for(const[m,g]of Object.entries(f.configEditors??{}))typeof g=="function"&&l.set(m,{kind:"module",extension:c,mount:g});return l},[s,t])}const T=(s,t)=>`${s}/${t}`;function js({label:s}){return e.jsxs(Xe,{label:s,className:"p-4 sm:p-6 grid gap-6 lg:grid-cols-[14rem_1fr]",children:[e.jsx("div",{className:"space-y-2",children:Array.from({length:4},(t,i)=>e.jsx(we,{className:"h-8 w-full rounded-lg"},i))}),e.jsx("div",{className:"space-y-6",children:Array.from({length:2},(t,i)=>e.jsxs("div",{className:"bg-surface border border-border rounded-xl p-5 space-y-4",children:[e.jsx(we,{className:"h-4 w-40"}),e.jsx(Je,{lines:4})]},i))})]})}function ks(){const{t:s}=O(),{data:t,loading:i,error:l,refetch:c,refresh:f}=De(Ue,[]),m=vs(),g=_e(),[P,C]=Ve(),[k,b]=h.useState(""),[u,I]=h.useState({}),[M,R]=h.useState({}),[D,v]=h.useState({}),[B,N]=h.useState(new Set),[H,q]=h.useState(new Set),[_,x]=h.useState(!1),[E,ce]=h.useState(!1),[Z,ee]=h.useState(null),[se,te]=h.useState(null),$=h.useMemo(()=>[...(t==null?void 0:t.providers)??[]].sort((n,o)=>n.order-o.order||n.title.localeCompare(o.title)),[t]),de=P.get("provider"),w=$.find(n=>n.id===de)??(je(de)?$.find(n=>je(n.id)):void 0)??$[0],V=P.get("section"),z=(t==null?void 0:t.defaultStore)??null,ue=n=>ke(n,z),fe=h.useMemo(()=>ds($.map(n=>ke(n,z))),[$,z]),xe=h.useRef(u);xe.current=u;const ne=h.useRef(new Set);h.useEffect(()=>{if(g)return g.subscribe("config:changed",n=>{const o=n;if(typeof o.provider!="string"||typeof o.section!="string")return;const r=T(o.provider,o.section);if(ne.current.has(r))return;const d=xe.current[r];d&&Object.keys(d).length>0?q(a=>new Set(a).add(r)):f()})},[g,f]);const ie=h.useCallback(n=>{const o=r=>{if(!(n in r))return r;const d={...r};return delete d[n],d};I(o),R(o),v(o),N(r=>{const d=new Set(r);return d.delete(n),d}),q(r=>{const d=new Set(r);return d.delete(n),d})},[]),Re=h.useCallback(n=>{ie(n),f()},[ie,f]);function ge(n,o,r,d){const a=T(n,o);I(p=>{const j={...p[a]};return d?j[r]=d:delete j[r],{...p,[a]:j}}),d||R(p=>{var j;return(j=p[a])!=null&&j.some(K=>K.key===r)?{...p,[a]:p[a].filter(K=>K.key!==r)}:p}),v(p=>{var K;if(!((K=p[a])!=null&&K[r]))return p;const j={...p[a]};return delete j[r],{...p,[a]:j}}),te(null)}function $e(n,o,r){const d=T(n,o);R(a=>({...a,[d]:[...a[d]??[],r]})),ge(n,o,r.key,{kind:"set",draft:ns(r.type,null)})}const{pending:L,problems:G}=h.useMemo(()=>{const n=[];let o=0;for(const r of $)for(const d of r.sections){const a=T(r.id,d.id),p=u[a]??{},j=M[a]??[],K=[...d.entries,...j],he={},re=[];for(const[Q,be]of Object.entries(p)){const S=K.find(qe=>qe.key===Q);if(!S)continue;const oe=j.includes(S);if(!oe&&!Ee(S,be))continue;const U=Me(S,be);if("problem"in U){o++;continue}he[Q]=U.value;const ve=S.sensitive||S.type==="secret";re.push({key:Q,label:S.label||Q,before:oe?"—":ve?S.isSet?s("config.secretSet"):s("config.secretNotSet"):W(S.value),after:ve?U.value===null?s("config.secretCleared"):s("config.secretReplaced"):U.value===null?oe||S.default===null?s("config.removed"):`${W(S.default)} (${s("config.defaultValue")})`:W(U.value),requiresRestart:S.requiresRestart})}re.length>0&&n.push({provider:r,sectionId:d.id,title:`${r.title} › ${d.title||d.id}`,version:d.version,changes:he,rows:re})}return{pending:n,problems:o}},[$,u,M,s]),Y=L.reduce((n,o)=>n+o.rows.length,0);async function Ke(){ce(!0),ee(null);let n=!1,o=!1;for(const r of L){const d=T(r.provider.id,r.sectionId);ne.current.add(d);try{const a=await We(r.provider.id,r.sectionId,r.changes,r.version);a!=null&&a.requiresRestart&&(n=!0),ie(d)}catch(a){o=!0,a instanceof Ge?v(p=>({...p,[d]:a.errors})):a instanceof Qe?N(p=>new Set(p).add(d)):ee(`${r.title}: ${a instanceof Error?a.message:String(a)}`)}finally{ne.current.delete(d)}}ce(!1),x(!1),(!o||n)&&te(n?"restart":"saved"),f()}function Pe(){I({}),R({}),v({}),N(new Set),te(null),H.size>0&&(q(new Set),f())}const A=k.trim()!=="",me=A?$.map(n=>({provider:n,sections:n.sections.filter(o=>[...o.entries,...M[T(n.id,o.id)]??[]].some(r=>Ce(r,k)))})).filter(n=>n.sections.length>0):w?[{provider:w,sections:w.sections}]:[],pe=!A&&V&&(w!=null&&w.sections.some(n=>n.id===V))?V:null,Oe=!A&&!!t&&!!V&&!!w&&!pe,Ie=n=>L.some(o=>o.provider.id===n),He=L.some(n=>n.rows.some(o=>o.requiresRestart));return e.jsxs("div",{children:[e.jsx(ze,{title:s("config.title"),subtitle:s("config.subtitle"),actions:e.jsxs("div",{className:"flex items-center gap-2",children:[(Y>0||G>0)&&e.jsx("button",{type:"button",onClick:Pe,disabled:E,className:"px-3 py-1.5 text-xs bg-control hover:bg-control-hover text-text rounded-lg transition-colors disabled:opacity-40",children:s("config.discard")}),e.jsx("button",{type:"button",onClick:()=>{ee(null),x(!0)},disabled:Y===0||G>0||E,title:G>0?s("config.fixProblems",{count:G}):void 0,className:"px-3 py-1.5 text-xs bg-primary hover:bg-primary-hover text-on-primary rounded-lg transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:Y>0?s("config.saveCount",{count:Y}):s("config.saveChanges")})]})}),(z||fe.length>0)&&e.jsx(ms,{defaultStore:z,stores:fe}),i&&!t?e.jsx(js,{label:s("config.loading")}):l&&!t?e.jsx("div",{className:"p-4 sm:p-6",children:e.jsx(Ne,{title:s("config.loadFailed"),error:l,onRetry:c})}):$.length===0?e.jsx("div",{className:"p-4 sm:p-6",children:e.jsx(ae,{message:s("config.noProviders")})}):e.jsxs("div",{className:"p-4 sm:p-6 grid gap-4 lg:gap-6 lg:grid-cols-[14rem_minmax(0,1fr)] items-start",children:[e.jsx("nav",{"aria-label":s("config.providers"),className:"lg:sticky lg:top-4 min-w-0",children:e.jsx("ul",{className:"flex lg:flex-col gap-1 overflow-x-auto -mx-4 px-4 sm:mx-0 sm:px-0 pb-1 lg:pb-0",children:$.map(n=>{const o=!A&&n.id===(w==null?void 0:w.id),r=ue(n);return e.jsx("li",{className:"shrink-0",children:e.jsxs("button",{type:"button","aria-current":o?"page":void 0,onClick:()=>{b(""),C(d=>{const a=new URLSearchParams(d);return a.set("provider",n.id),a.delete("section"),a},{replace:!0})},className:`w-full text-left px-3 py-2 rounded-lg text-sm transition-colors flex items-center gap-2 whitespace-nowrap ${o?"bg-primary/15 text-heading":"text-muted hover:bg-control hover:text-text"}`,children:[e.jsx("span",{className:"truncate",children:n.title}),!n.writable&&e.jsxs("span",{className:"sr-only",children:["(",s("config.readOnly"),")"]}),r&&e.jsx(xs,{store:r}),Ie(n.id)&&e.jsx("span",{"aria-label":s("config.unsaved"),title:s("config.unsaved"),className:`${r?"":"ml-auto "}w-1.5 h-1.5 rounded-full bg-primary shrink-0`})]})},n.id)})})}),e.jsxs("div",{className:"space-y-4 min-w-0",children:[e.jsx("input",{type:"search",value:k,onChange:n=>b(n.target.value),placeholder:s("config.searchPlaceholder"),"aria-label":s("config.search"),className:"w-full max-w-md px-3 py-1.5 text-sm bg-control border border-border rounded-lg text-text placeholder-subtle focus:outline-none focus:border-primary/50"}),se&&e.jsx("div",{role:"status",className:`p-3 rounded-lg text-sm border ${se==="restart"?"bg-warning/10 border-warning/30 text-warning":"bg-success/10 border-success/30 text-success"}`,children:s(se==="restart"?"config.restartRequired":"config.saved")}),Z&&!_&&e.jsx(Ne,{title:s("config.saveFailed"),error:Z,compact:!0}),A&&me.length===0&&e.jsx(ae,{message:s("config.noMatches")}),Oe&&e.jsx("div",{role:"note",className:"p-3 rounded-lg text-sm border border-border bg-control/40 text-muted",children:s("config.sectionMissing",{section:V})}),me.map(({provider:n,sections:o})=>{const r=ue(n),d=n.storage&&!(r&&n.storage.kind==="store")?n.storage:null;return e.jsxs("div",{className:"space-y-4",children:[(A||n.description||r||d)&&e.jsxs("div",{className:"space-y-1",children:[A&&e.jsx("h2",{className:"text-sm font-semibold text-heading",children:n.title}),n.description&&e.jsx("p",{className:"text-xs text-subtle",children:n.description}),r&&e.jsx(ps,{store:r}),d&&e.jsx(hs,{storage:d})]}),o.length===0&&e.jsx(ae,{message:s("config.noSections")}),o.map(a=>{const p=T(n.id,a.id);return e.jsx(Le,{label:a.title||a.id,resetKeys:[a],children:e.jsx(os,{providerId:n.id,writable:n.writable,storage:n.storage,section:a,highlighted:n.id===(w==null?void 0:w.id)&&a.id===pe,added:M[p]??[],edits:u[p]??{},serverErrors:D[p]??{},query:k,saving:E,stale:H.has(p),conflict:B.has(p),editors:m,onEdit:(j,K)=>ge(n.id,a.id,j,K),onAddKey:j=>$e(n.id,a.id,j),onReload:()=>Re(p)})},p)})]},n.id)})]})]}),e.jsx(Ye,{open:_,size:"lg",title:s("config.confirmTitle"),message:e.jsxs("div",{className:"space-y-4 text-left",children:[e.jsx("p",{children:s("config.confirmMessage",{count:Y})}),L.map(n=>e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-semibold text-heading mb-1",children:n.title}),e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sr-only",children:e.jsxs("tr",{children:[e.jsx("th",{children:s("config.key")}),e.jsx("th",{children:s("config.before")}),e.jsx("th",{children:s("config.after")})]})}),e.jsx("tbody",{children:n.rows.map(o=>e.jsxs("tr",{className:"border-t border-border/50 align-top","data-diff-key":o.key,children:[e.jsxs("td",{className:"py-1.5 pr-3 text-text break-words w-1/3",children:[o.label,o.requiresRestart&&e.jsx("span",{className:"text-warning",children:" *"})]}),e.jsx("td",{className:"py-1.5 pr-3 font-mono text-error/90 line-through decoration-error/40 break-all",children:o.before}),e.jsx("td",{className:"py-1.5 font-mono text-success break-all",children:o.after})]},o.key))})]})]},`${n.provider.id}/${n.sectionId}`)),He&&e.jsxs("p",{className:"text-xs text-warning",children:["* ",s("config.restartBadge")]})]}),confirmLabel:s("config.confirmSave"),busyLabel:s("config.saving"),busy:E,error:Z,onConfirm:Ke,onCancel:()=>x(!1)})]})}export{ks as default};
@@ -0,0 +1 @@
1
+ import{i as v,j as s,ab as h,r as g,f as j}from"./index-DNbEWPIs.js";import{b as N}from"./paging-CCKbuXJo.js";function k(i,d,o){const c=o==="asc"?1:-1,x=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});return i.map((r,n)=>({row:r,index:n,value:d(r)})).sort((r,n)=>{const l=r.value===null||r.value===void 0||r.value==="",u=n.value===null||n.value===void 0||n.value==="";if(l||u)return l===u?r.index-n.index:l?1:-1;const a=typeof r.value=="number"&&typeof n.value=="number"?r.value-n.value:x.compare(String(r.value),String(n.value));return a!==0?a*c:r.index-n.index}).map(r=>r.row)}function E({columns:i,data:d,onRowClick:o,keyExtractor:c,defaultSort:x,page:r,emptyMessage:n,plain:l=!1}){const{t:u}=v(),[a,f]=g.useState(x??null),m=a?i.find(e=>e.key===a.key&&e.sortValue):void 0,b=m&&a?k(d,m.sortValue,a.direction):d,y=r?N(b,r.index,r.size):b;function p(e){f(t=>(t==null?void 0:t.key)===e?{key:e,direction:t.direction==="asc"?"desc":"asc"}:{key:e,direction:"asc"})}return s.jsxs("div",{className:l?"overflow-x-auto":"bg-surface border border-border rounded-xl overflow-x-auto",children:[s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsx("tr",{className:"border-b border-border/75",children:i.map(e=>{const t=(a==null?void 0:a.key)===e.key&&!!e.sortValue;return s.jsx("th",{"aria-sort":t?a.direction==="asc"?"ascending":"descending":void 0,className:`px-4 py-3 text-left text-xs text-subtle font-medium uppercase tracking-wide ${e.className??""}`,children:e.sortValue?s.jsxs("button",{type:"button",onClick:()=>p(e.key),title:u("sortBy",{column:e.header}),className:`inline-flex items-center gap-1 uppercase tracking-wide hover:text-text ${t?"text-text":""}`,children:[e.header,s.jsx("span",{"aria-hidden":!0,className:`text-[9px] ${t?"":"opacity-30"}`,children:t&&a.direction==="desc"?"▼":"▲"})]}):e.header},e.key)})})}),s.jsx("tbody",{children:y.map(e=>s.jsx("tr",{onClick:o?()=>o(e):void 0,onKeyDown:o?t=>{t.target!==t.currentTarget||t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),o(e))}:void 0,tabIndex:o?0:void 0,className:`border-b border-border/50 last:border-0 ${o?"cursor-pointer hover:bg-control focus-visible:bg-control focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary/60":""}`,children:i.map(t=>s.jsx("td",{className:`px-4 py-3 text-text ${t.className??""}`,children:t.render?t.render(e):String(e[t.key]??"")},t.key))},c(e)))})]}),d.length===0&&(n??s.jsx(j,{}))]})}function $(i){const{t:d}=v();return s.jsx(h,{label:d("table"),resetKeys:[i.data],children:s.jsx(E,{...i})})}export{$ as D};
@@ -0,0 +1,3 @@
1
+ import{J as k,A as w,r as d,j as r,u as p,T as X,a2 as Ie,a3 as I,a4 as Pe,a5 as Ee,a6 as te,E as we,a7 as Ce,U as $e,i as Re,M as Te,a8 as qe,O as Me,q as Y,w as De,a as Be,Q as Le}from"./index-DNbEWPIs.js";import{B as W}from"./Badge-DXfBhPf0.js";import{c as Oe}from"./commandInfo-B8tZOPKW.js";const Ue="/api/v1/qcli/plugins/dependencies",D=e=>!!e&&typeof e=="object"&&!Array.isArray(e),j=e=>typeof e=="string"&&e?e:void 0,L=e=>Array.isArray(e)?e.filter(n=>typeof n=="string"&&!!n):void 0,oe=["requires","optional","capability"],le=["ok","missing","incompatible","not-loaded","cycle","invalid"];function se(e){if(!D(e))return;const n={};for(const[t,s]of Object.entries(e))typeof s=="string"?n[t]=s:D(s)&&(n[t]=`${s.order==="before"?"before:":""}${typeof s.range=="string"?s.range:"*"}`);return n}function Q(e){const n=se(e.requires),t=se(e.optional),s=L(e.requiresCapability),i=L(e.provides);return{...n?{requires:n}:{},...t?{optional:t}:{},...s?{requiresCapability:s}:{},...i?{provides:i}:{}}}function Xn(e){return e.requires!==void 0||e.optional!==void 0||e.requiresCapability!==void 0||e.provides!==void 0}function J(e){const n=/^before:/i.test(e);return{range:(n?e.slice(7):e).trim()||"*",...n?{order:"before"}:{}}}function Fe(e){if(!D(e)||typeof e.id!="string"||!e.id)return null;const n=oe.includes(e.kind)?e.kind:"requires",t=le.includes(e.status)?e.status:"invalid",s=L(e.providedBy);return{kind:n,id:e.id,...j(e.range)?{range:e.range}:{},...e.order==="before"?{order:"before"}:{},status:t,...j(e.version)?{version:e.version}:{},...s?{providedBy:s}:{},...j(e.message)?{message:e.message}:{}}}function ce(e){const n=Array.isArray(e.dependencies)?e.dependencies.map(Fe).filter(s=>s!==null):void 0,t=L(e.dependents);return{...n?{dependencies:n}:{},...t?{dependents:t}:{}}}function de(e){if(e.dependencies)return e.dependencies;const n=[];for(const[t,s]of Object.entries(e.requires??{}))n.push({kind:"requires",id:t,...J(s)});for(const[t,s]of Object.entries(e.optional??{}))n.push({kind:"optional",id:t,range:J(s).range});for(const t of e.requiresCapability??[])n.push({kind:"capability",id:t});return n}function _e(e){return(e??[]).filter(n=>n.status!=="ok"&&n.kind!=="optional")}function Ve(e){if(!D(e)||typeof e.id!="string"||!e.id)return null;const n=L(e.provides);return{id:e.id,...j(e.package)?{package:e.package}:{},...j(e.version)?{version:e.version}:{},status:j(e.status)??"loaded",...j(e.source)?{source:e.source}:{},...n?{provides:n}:{}}}function Ke(e){return!D(e)||typeof e.from!="string"||typeof e.to!="string"||!e.from||!e.to?null:{from:e.from,to:e.to,kind:oe.includes(e.kind)?e.kind:"requires",...j(e.range)?{range:e.range}:{},...j(e.capability)?{capability:e.capability}:{},...e.order==="before"?{order:"before"}:{},status:le.includes(e.status)?e.status:"ok",...j(e.version)?{version:e.version}:{},...j(e.message)?{message:e.message}:{}}}async function Qn(){let e;try{e=await k(Ue)}catch(i){if(i instanceof w&&(i.status===404||i.status===405))return null;throw i}if(!D(e)||!Array.isArray(e.nodes))return null;const n=e.nodes.map(Ve).filter(i=>i!==null),t=(Array.isArray(e.edges)?e.edges:[]).map(Ke).filter(i=>i!==null),s=new Set(n.map(i=>i.id));for(const i of t)for(const l of[i.from,i.to])s.has(l)||(s.add(l),n.push({id:l,status:"missing"}));return{nodes:n,edges:t}}function et(){return k("/api/v1/qcli/plugins")}function nt(e){return k(`/api/v1/qcli/plugins/${encodeURIComponent(e)}/toggle`,{method:"POST"})}const ze=["requires","optional","requiresCapability","provides","dependencies","dependents"];async function tt(){try{const e=await k("/api/v1/qcli/plugins/installed");return Array.isArray(e)?e.filter(n=>!!n&&typeof n=="object"&&typeof n.id=="string").map(n=>{const t={...n};for(const s of ze)delete t[s];return{...t,...Q(n),...ce(n)}}):null}catch(e){if(e instanceof Error&&/not found/i.test(e.message))return null;throw e}}const Ge="🧩",He={core:"🖥️",qodaliscli:"🖥️",cliservernode:"🖥️",qodaliscliserver:"🖥️",abstractions:"🧱",qodaliscliabstractions:"🧱",cliserverabstractions:"🧱",qodaliscliserverabstractions:"🧱",admin:"🎛️",audit:"🛡️",auditefcore:"🗄️",aws:"☁️",jobs:"⏱️",jobsefcore:"🗄️",users:"👥",usersefcore:"🗄️",weather:"🌤️",logsseq:"📜",filesystem:"📁",filesystemjson:"📄",filesystemsqlite:"🪶",filesystems3:"🪣",filesystemefcore:"🗄️",dataexplorer:"📊",dataexplorersql:"🪶",dataexplorerpostgres:"🐘",dataexplorermysql:"🐬",dataexplorermssql:"🗃️",dataexplorermongo:"🍃",dataexplorerredis:"🔴",dataexplorerelasticsearch:"🔍"},Ye=[/^@[^/]+\//,/^qodalis\.cli\.plugin\./,/^qodalis-cli-server-plugin-/,/^cli-server-plugin-/,/^console-module-/,/^cli-dashboard-module-/];function We(e){let n=e.trim().toLowerCase();for(const t of Ye)n=n.replace(t,"");return n.replace(/[^\p{L}\p{N}]/gu,"")}function Je(...e){for(const n of e){const t=n?He[We(n)]:void 0;if(t)return t}}function pe(...e){return Je(...e)??Ge}function Ze(e){return/^https?:\/\/[^\s]+$/i.test(e)||/^\/(?![/\\])[^\s]*$/.test(e)}function Xe(e,...n){const t=typeof e=="string"?e.trim():"";if(t){if(Ze(t))return{kind:"image",src:t};if(!/^[a-z][a-z0-9+.-]*:/i.test(t)&&[...t].length<=8)return{kind:"text",text:t}}return{kind:"text",text:pe(...n)}}const re="h-8 w-8 shrink-0 rounded-lg flex items-center justify-center bg-control";function st({icon:e,names:n}){const[t,s]=d.useState(null),i=Xe(e,...n);if(i.kind==="image"&&t!==i.src)return r.jsx("span",{className:re,"aria-hidden":!0,"data-testid":"module-icon",children:r.jsx("img",{src:i.src,alt:"",loading:"lazy",className:"h-6 w-6 object-contain",onError:()=>s(i.src)})});const l=i.kind==="text"?i.text:pe(...n);return r.jsx("span",{className:`${re} text-lg leading-none`,"aria-hidden":!0,"data-testid":"module-icon",children:l})}function rt({enabled:e,onToggle:n,className:t=""}){const[s,i]=d.useState(!1),{t:l}=p();async function a(f){f.preventDefault(),f.stopPropagation(),i(!0);try{await n()}finally{i(!1)}}const o=l(e?"plugins.disablePlugin":"plugins.enablePlugin");return r.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":o,onClick:a,disabled:s,className:`inline-flex h-5 w-9 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60 disabled:opacity-50 ${e?"bg-primary":"bg-subtle"} ${t}`,title:o,children:r.jsx("span",{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-on-primary transition-transform ${e?"translate-x-4":"translate-x-0.5"}`})})}function Qe(e){return`/plugins/${encodeURIComponent(e)}`}function it(e){const n=e.get("tab");return n==="marketplace"||n==="updates"||n==="dependencies"?n:"installed"}function at(e){return e.get("kind")==="server"?"server":"console"}const en={console:"dashboard",server:"server"};function ot(e){const n=e.get("platform");return n==="all"||n==="node"||n==="python"||n==="dotnet"?n:"this"}function lt(e){const n=e.get("installed");return n==="yes"||n==="no"?n:"any"}function ct(e,n){if(!e||!/^https?:\/\//i.test(e))return null;try{const t=new URL(e);return t.search="",t.hash="",t.searchParams.set("kind",en[n]),{href:t.toString(),host:t.host}}catch{return null}}const dt=250,nn={unreachable:"marketplace.errUnreachable",unverified:"marketplace.errUnverified",integrity:"marketplace.errIntegrity",clash:"marketplace.errClash",forbidden:"marketplace.errForbidden"},tn={500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout"};function sn(e){if(!(e instanceof w)||e.status<400)return null;const n=e.body.trim();return n!==""&&!n.startsWith("<")&&I(n).trim()!==""&&!(n.startsWith("{")&&I(n)===n)?null:{status:e.status,statusText:e.statusText.trim()||tn[e.status]||""}}function ue(){const{t:e}=p();return d.useCallback(n=>{const t=sn(n);return t?`${e("marketplace.errStatus",{status:String(t.status)})}${t.statusText?` ${t.statusText}`:""}`:I(n)},[e])}function pt(){const{t:e}=p(),n=ue();return d.useCallback(t=>{const s=Pe(t);return s==="other"?n(t):e(nn[s])},[e,n])}function ut(){const{t:e}=p();return d.useCallback(n=>{const t=/(?:console|dashboard) api (\d+)/i.exec(n);return t?e("marketplace.blockedApi",{version:t[1]}):/verified/i.test(n)?e("marketplace.blockedUnverified"):/disabled|\boff\b/i.test(n)?e("marketplace.blockedOff"):n},[e])}function ft(e){var t;const n=(t=X())==null?void 0:t.subscribe;d.useEffect(()=>n?Ie(n,()=>e()):void 0,[n,e])}const C="/api/v1/qcli/server/marketplace",rn="plugins:install",an="server:plugins-changed",fe=["node","python","dotnet"],on={node:"Node",python:"Python",dotnet:".NET"},me={npm:"node",pypi:"python",nuget:"dotnet"},u=e=>!!e&&typeof e=="object"&&!Array.isArray(e),m=e=>typeof e=="string"?e:"",c=e=>typeof e=="string"&&e?e:void 0,ge=e=>typeof e=="string"&&fe.includes(e),ie=e=>typeof e=="string"&&/^https?:\/\//i.test(e)?e:void 0;function mt(e,n){return e==="python"?`pip install ${n}`:e==="dotnet"?`dotnet add package ${n}`:`npm install ${n}`}function ln(e){const n=Array.isArray(e)?e.filter(u).map(s=>[s.platform??me[m(s.registry)],s]):u(e)?Object.entries(e):[],t={};for(const[s,i]of n)!ge(s)||!u(i)||typeof i.package!="string"||!i.package||(t[s]={package:i.package,...c(i.registry)?{registry:i.registry}:{},latest:typeof i.latest=="string"?i.latest:null,...c(i.install)?{install:i.install}:{},...c(i.readme)?{readme:i.readme}:{},...c(i.readmeFormat)?{readmeFormat:i.readmeFormat}:{}});return t}function cn(e){return!u(e)||typeof e.package!="string"?null:{package:e.package,latest:typeof e.latest=="string"?e.latest:null,installed:typeof e.installed=="string"?e.installed:null,compatible:e.compatible!==!1,...c(e.reason)?{reason:e.reason}:{}}}function xe(e){const n=u(e.publisher)?e.publisher:{},t=m(e.name),s=ie(e.homepage),i=ie(u(e.repository)?e.repository.url:e.repository),l=cn(e.platform);return{name:t,title:m(e.title)||m(e.shortName)||t,description:m(e.description),...c(e.icon)?{icon:e.icon}:{},publisher:{name:m(n.name),verified:n.verified===!0},platforms:ln(e.platforms),platform:l,otherPlatforms:Array.isArray(e.otherPlatforms)?e.otherPlatforms.filter(a=>typeof a=="string"):[],autoInstall:e.autoInstall!==!1,...c(e.autoInstallReason)?{autoInstallReason:e.autoInstallReason}:{},installed:Ee(e.installed)??(l!=null&&l.installed?{version:l.installed,source:"marketplace"}:null),updateAvailable:e.updateAvailable===!0,allowed:e.allowed===!0,...c(e.blockedReason)?{blockedReason:e.blockedReason}:{},...s?{homepage:s}:{},...i?{repository:i}:{}}}function dn(e){return{version:m(e.version),platform:m(e.platform)||me[m(e.registry)]||"",...c(e.package)?{package:e.package}:{},...c(e.status)?{status:e.status}:{},...c(e.publishedAt)?{publishedAt:e.publishedAt}:{},...c(e.serverRange)?{serverRange:e.serverRange}:{},...typeof e.allowed=="boolean"?{allowed:e.allowed}:{},...c(e.blockedReason)?{blockedReason:e.blockedReason}:{},...Q(e)}}const pn=(e,n)=>n.localeCompare(e,void 0,{numeric:!0});function un(e){const n=Array.isArray(e.versions)?e.versions.filter(u).map(dn).filter(s=>s.version):[];n.sort((s,i)=>pn(s.version,i.version));const t=te(e.config)??(Array.isArray(e.versions)?e.versions.filter(u).map(s=>te(s.config)).find(s=>s):void 0);return{...xe(e),readme:m(e.readme),versions:n,...t?{config:t}:{},...c(e.license)?{license:e.license}:{}}}async function gt(){try{const e=await k(C);return u(e)?{marketplaceUrl:m(e.marketplaceUrl),install:e.install==="listed"||e.install==="off"?e.install:"verified",platform:ge(e.platform)?e.platform:null,serverVersion:c(e.serverVersion)??null,enabled:e.enabled!==!1}:null}catch(e){if(e instanceof w&&(e.status===404||e.status===405))return null;throw e}}function xt(e,n){var s;if(e!=null&&e.platform)return e.platform;if(!(n!=null&&n.platform))return null;const t=n.platform.package;for(const i of fe)if(((s=n.platforms[i])==null?void 0:s.package)===t)return i;return/^@/.test(t)?"node":/^[A-Z][A-Za-z0-9]*(\.[A-Z][A-Za-z0-9]*)+$/.test(t)?"dotnet":null}async function yt({query:e="",page:n=1,pageSize:t=20}={}){const s=new URLSearchParams({page:String(n),pageSize:String(t)});e.trim()&&s.set("query",e.trim());const i=await k(`${C}/plugins?${s}`),l=Array.isArray(i==null?void 0:i.items)?i.items.filter(u).map(xe):[];return{items:l,total:typeof(i==null?void 0:i.total)=="number"?i.total:l.length,page:typeof(i==null?void 0:i.page)=="number"?i.page:n,pageSize:typeof(i==null?void 0:i.pageSize)=="number"?i.pageSize:t}}async function fn(e){return un(await k(`${C}/plugins/${encodeURIComponent(e)}`))}const mn=["loaded","pending","failed","skipped","removed","needs-configuration","needs-dependencies"];function ye(e){const n=e.name;return{name:n,package:m(e.package)||n,version:m(e.version),title:m(e.title)||n,...c(e.icon)?{icon:e.icon}:{},...c(e.description)?{description:e.description}:{},...c(e.installedAt)?{installedAt:e.installedAt}:{},...c(e.installedBy)?{installedBy:e.installedBy}:{},status:mn.includes(m(e.status))?e.status:"pending",loadedVersion:typeof e.loadedVersion=="string"?e.loadedVersion:null,...c(e.error)?{error:e.error}:{},...e.updateAvailable===!0?{updateAvailable:!0}:{},...Array.isArray(e.missing)?{missing:e.missing.filter(t=>typeof t=="string")}:{},...c(e.settings)?{settings:e.settings}:{},...Q(e),...ce(e),...e.auto===!0?{auto:!0}:{}}}function gn(e){return`/config?${new URLSearchParams({provider:e.settings??e.name})}`}async function bt(){let e;try{e=await k(`${C}/installed`)}catch(t){if(t instanceof w&&(t.status===404||t.status===405))return[];throw t}return(Array.isArray(e)?e:u(e)&&Array.isArray(e.items)?e.items:[]).filter(u).filter(t=>typeof t.name=="string"&&t.name).map(ye)}function ee(e){return u(e)?{...typeof e.name=="string"?ye(e):{},restartRequired:e.restartRequired!==!1,...typeof e.changed=="boolean"?{changed:e.changed}:{},...c(e.previousVersion)?{previousVersion:e.previousVersion}:{},...Array.isArray(e.installed)?{installedPlugins:e.installed.filter(u).filter(n=>typeof n.name=="string").map(n=>({name:n.name,version:m(n.version)}))}:{}}:{restartRequired:!0}}const T=(e,n)=>Array.isArray(e)?e.filter(u).map(n).filter(t=>t!==null):[],F=e=>typeof e.name=="string"&&e.name?e.name:null;function xn(e,n,t){if(!u(e))return null;const s=u(e.plugin)?e.plugin:{},i=T(e.conflicts,a=>typeof a.id=="string"&&a.id?{id:a.id,...c(a.kind)?{kind:a.kind}:{},reason:m(a.reason)||"missing",...c(a.range)?{range:a.range}:{},...c(a.found)?{found:a.found}:{},...Array.isArray(a.requiredBy)?{requiredBy:a.requiredBy.filter(o=>typeof o=="string")}:{},...c(a.message)?{message:a.message}:{}}:null),l=a=>{const o=F(a);return o?{name:o,...c(a.package)?{package:a.package}:{},...c(a.version)?{version:a.version}:{},...c(a.from)?{from:a.from}:{},...c(a.range)?{range:a.range}:{},...Array.isArray(a.requiredBy)?{requiredBy:a.requiredBy.filter(f=>typeof f=="string")}:{}}:null};return{action:e.action==="update"||e.action==="remove"||e.action==="install"?e.action:n,ok:e.ok!==!1&&i.length===0,plugin:{name:m(s.name)||t,...c(s.version)?{version:s.version}:{}},install:T(e.install,l),update:T(e.update,l),satisfied:T(e.satisfied,a=>{const o=F(a);return o?{name:o,...c(a.version)?{version:a.version}:{},...c(a.range)?{range:a.range}:{},...c(a.source)?{source:a.source}:{}}:null}),optional:T(e.optional,a=>{const o=F(a);return o?{name:o,...c(a.range)?{range:a.range}:{},installed:a.installed===!0}:null}),capabilities:T(e.capabilities,a=>typeof a.capability=="string"&&a.capability?{capability:a.capability,providedBy:Array.isArray(a.providedBy)?a.providedBy.filter(o=>typeof o=="string"):[]}:null),conflicts:i,dependents:T(e.dependents,a=>{const o=F(a);return o?{name:o,...c(a.version)?{version:a.version}:{},...c(a.range)?{range:a.range}:{}}:null})}}async function yn(e,n,t){const s=new URLSearchParams({action:e,name:n});t&&s.set("version",t);try{return xn(await k(`${C}/plan?${s}`),e,n)}catch(i){if(i instanceof w&&(i.status===404||i.status===405))return null;throw i}}async function bn(e,n,t={}){return ee(await k(`${C}/installed`,{method:"POST",body:JSON.stringify({name:e,...t.dependencies!==void 0?{dependencies:t.dependencies}:{}})}))}async function hn(e,n,t={}){return ee(await k(`${C}/installed/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({...t.force?{force:!0}:{}})}))}async function kn(e,n={}){const t=n.force?"?force=true":"";return ee(await k(`${C}/installed/${encodeURIComponent(e)}${t}`,{method:"DELETE"}))}const vn=["dependency-conflict","has-dependents","breaks-dependents"];function be(e){if(!(e instanceof w))return null;try{const n=JSON.parse(e.body);if(!u(n)||n.code!=="dependency-failed")return null;const t=a=>typeof a=="string"?a:u(a)&&typeof a.name=="string"?a.name:"",s=a=>u(a)&&typeof a.version=="string"&&a.version?` ${a.version}`:"",i=Array.isArray(n.failed)?n.failed.map(t).filter(Boolean).join(", "):t(n.failed),l=Array.isArray(n.installed)?n.installed.filter(a=>t(a)).map(a=>`${t(a)}${s(a)}`):[];return{failed:i,installed:l,error:m(n.error)}}catch{return null}}function jn(e){if(!(e instanceof w))return null;try{const n=JSON.parse(e.body);return u(n)&&typeof n.code=="string"?n.code:null}catch{return null}}function Nn(e){const n=I(e).toLowerCase(),t=e instanceof w?e.status:0,s=jn(e);return t===409&&s&&vn.includes(s)?s:s==="dependency-failed"?"dependency-failed":/integrity|sha512|checksum/.test(n)?"integrity":t===502||t===503||t===504||/unreachable/.test(n)?"unreachable":t===403?/verified/.test(n)?"unverified":"forbidden":/needs setup in code/.test(n)?"setup":/incompatible|needs server/.test(n)?"incompatible":/not available for/.test(n)?"unavailable":t===409?"clash":"other"}function Sn(e){const n=I(e),t=n.indexOf(": ");return t>=0?n.slice(t+2):""}function An({title:e,message:n}){const t=d.useRef(null);return d.useEffect(()=>{var s,i;(i=(s=t.current)==null?void 0:s.scrollIntoView)==null||i.call(s,{block:"nearest",behavior:"smooth"})},[e,n]),r.jsx("div",{ref:t,"data-testid":"action-failure",children:r.jsx(we,{title:e,error:n,compact:!0})})}function In({message:e,onDismiss:n}){const{t}=p();return r.jsxs("div",{role:"status",className:"flex items-start justify-between gap-3 rounded-lg border border-info/30 bg-info/[0.06] px-3 py-2 text-sm text-info",children:[r.jsx("span",{children:e}),r.jsx("button",{type:"button",onClick:n,className:"shrink-0 text-xs underline-offset-2 hover:underline",children:t("marketplace.dismiss")})]})}function he(e){return e?on[e]??e:""}function Pn(e){const{t:n}=p(),t=ue();return d.useCallback(s=>{var l;const i=Sn(s);switch(Nn(s)){case"unreachable":return n("serverMarketplace.errUnreachable");case"integrity":return n("serverMarketplace.errIntegrity");case"unverified":return n("marketplace.errUnverified");case"forbidden":return n("serverMarketplace.errForbidden");case"incompatible":return n("serverMarketplace.errIncompatible",{reason:i||I(s)});case"setup":return i?n("serverMarketplace.errSetup",{reason:i}):n("serverMarketplace.errSetupPlain");case"unavailable":{const a=(l=/not available for (\w+)/i.exec(I(s)))==null?void 0:l[1];return n("serverMarketplace.errUnavailable",{platform:he(a??e)||i})}case"clash":return n("serverMarketplace.errClash");case"dependency-conflict":return n("dependencies.errDependencyConflict");case"has-dependents":return n("dependencies.errHasDependents");case"breaks-dependents":return n("dependencies.errBreaksDependents");case"dependency-failed":{const a=be(s);return`${n("dependencies.errDependencyFailed",{plugin:(a==null?void 0:a.failed)||"?",reason:(a==null?void 0:a.error)||I(s)})} ${a!=null&&a.installed.length?n("dependencies.errDependencyFailedInstalled",{plugins:a.installed.join(", ")}):n("dependencies.errDependencyFailedNone")}`}default:return t(s)}},[n,e,t])}function ht(){const{t:e}=p();return d.useCallback((n,t)=>{if(/server plugins disabled/i.test(n))return e("serverMarketplace.blockedDisabled");if(/install disabled/i.test(n))return e("marketplace.blockedOff");if(/verified/i.test(n))return e("marketplace.blockedUnverified");const s=/not available for (\w+)/i.exec(n);return s?e("serverMarketplace.notAvailable",{platform:he(t??s[1])}):/needs setup in code/i.test(n)?e("serverMarketplace.needsSetup"):/needs server|incompatible/i.test(n)?e("serverMarketplace.incompatible",{reason:n}):n},[e])}function kt(e){var t;const n=(t=X())==null?void 0:t.subscribe;d.useEffect(()=>n==null?void 0:n(an,()=>e()),[n,e])}function vt(e,n){if(e.homepage)return e.homepage;if(e.repository)return e.repository;if(/^https?:\/\//i.test(n))return`${n.replace(/\/+$/,"")}/plugins/${e.name.split("/").map(encodeURIComponent).join("/")}`}function ke(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean)}function V(e){return ke(e).join("-")}function ve(e){const n=Ce(e);if(n)return V(n);const t=ke(e),s=t.lastIndexOf("plugin");return s>=0&&s<t.length-1?t.slice(s+1).join("-"):null}function je(e,n){const t=ve(e);return t!==null&&t===V(n)}function jt(e,n){const t=(e??[]).filter(s=>je(s.id,n));return t.length===1?t[0]:void 0}function Nt(e,n){return(e??[]).filter(t=>je(n,t.id))}function St(e,n){const t=new Set((n.processors??[]).map(s=>s.toLowerCase()));return(e??[]).filter(s=>{const i=Oe(s);return i?i===n.id:t.has(s.command.toLowerCase())})}function At(e){const n=new Set,t=s=>{var i,l;(i=s.requiredPermissions)==null||i.forEach(a=>n.add(a)),(l=s.processors)==null||l.forEach(t)};return t(e),[...n]}const K={ok:{key:"dependencies.statusOk",variant:"success"},missing:{key:"dependencies.statusMissing",variant:"error"},incompatible:{key:"dependencies.statusIncompatible",variant:"error"},"not-loaded":{key:"dependencies.statusNotLoaded",variant:"warning"},cycle:{key:"dependencies.statusCycle",variant:"error"},invalid:{key:"dependencies.statusInvalid",variant:"error"}};function En(e,n){return e==="optional"&&(n==="missing"||n==="not-loaded")?{key:"dependencies.statusNotInstalled",variant:"neutral"}:K[n]}const It=(e,n)=>n!=="ok"&&e!=="optional",wn={requires:"dependencies.kindRequires",optional:"dependencies.kindOptional",capability:"dependencies.kindCapability"};function Pt(e){return e==="loaded"?"ok":e==="needs-dependencies"||e==="needs-configuration"||e==="pending"?"waiting":e==="failed"||e==="missing"?"broken":e==="absent"?"absent":"other"}const ae={loaded:"serverMarketplace.statusLoaded",pending:"serverMarketplace.statusPending",failed:"serverMarketplace.statusFailed",skipped:"serverMarketplace.statusSkipped",removed:"serverMarketplace.statusRemoved","needs-configuration":"serverMarketplace.statusNeedsConfiguration","needs-dependencies":"dependencies.statusNeedsDependencies",missing:"dependencies.statusMissing",absent:"dependencies.statusNotInstalled"};function Et(){const{t:e}=p();return d.useCallback(n=>ae[n]?e(ae[n]):n,[e])}function O(){const{t:e}=p();return d.useCallback(n=>!n||n==="*"?e("dependencies.anyVersion"):n,[e])}function Cn(){const{t:e}=p(),n=O();return d.useCallback(t=>{const s=n(t.range);switch(t.reason){case"missing":return e("dependencies.conflictMissing",{id:t.id});case"incompatible":return t.found?e("dependencies.conflictIncompatible",{id:t.id,found:t.found,range:s}):e("dependencies.conflictIncompatibleNone",{id:t.id,range:s});case"needs-setup":return e("dependencies.conflictNeedsSetup",{id:t.id});case"capability":return e("dependencies.conflictCapability",{id:t.id});case"breaks-dependent":return e("dependencies.conflictBreaksDependent",{id:t.id,range:s});case"cycle":return e("dependencies.conflictCycle",{id:t.id});case"invalid":return e("dependencies.conflictInvalid",{id:t.id});case"blocked":return e("dependencies.conflictBlocked",{id:t.id});default:return t.message?`${t.id}: ${t.message}`:`${t.id}: ${t.reason}`}},[e,n])}function $n(e,n){const t=V(n);return(e??[]).find(s=>s.pluginId===n||s.id===n)??(e??[]).find(s=>(s.pluginId?V(s.pluginId):ve(s.id))===t)}function Rn(e){return`/plugins?${new URLSearchParams({tab:"marketplace",kind:"server",q:e})}`}function Tn(e,n){const t=$n(e,n);return t?{path:Qe(t.id),installed:!0}:{path:Rn(n),installed:!1}}function Ne(e,n){return n?e==="remove"?n.dependents.length>0||n.conflicts.length>0?"force":"none":n.conflicts.length===0?n.ok?"none":"blocked":e==="update"&&n.conflicts.every(t=>t.reason==="breaks-dependent")?"force":"blocked":"none"}const qn="plugin.needs-dependencies:";function wt(e){var t;const n=(t=X())==null?void 0:t.subscribe;d.useEffect(()=>n==null?void 0:n($e,s=>{typeof s.key=="string"&&s.key.startsWith(qn)&&e()}),[n,e])}const Mn={install:"serverMarketplace.confirmInstall",update:"serverMarketplace.confirmUpdate",remove:"serverMarketplace.confirmRemove"},Dn={install:"marketplace.install",update:"marketplace.update",remove:"marketplace.remove"},G="px-3 py-1.5 text-sm sm:text-xs rounded-lg transition-colors disabled:opacity-50 inline-flex items-center justify-center gap-1.5 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60";function E({title:e,testId:n,tone:t="default",children:s}){const i=t==="error"?"border-error/30 bg-error/[0.06]":t==="warning"?"border-warning/30 bg-warning/[0.06]":"border-border bg-control/30",l=t==="error"?"text-error":t==="warning"?"text-warning":"text-heading";return r.jsxs("section",{"data-testid":n,className:`rounded-lg border px-3 py-2 space-y-1 ${i}`,children:[r.jsx("h4",{className:`text-xs font-semibold ${l}`,children:e}),r.jsx("ul",{className:"space-y-1 text-xs",children:s})]})}const q=({children:e})=>r.jsx("span",{className:"font-mono text-text break-all",children:e});function Bn({action:e,plan:n}){const{t}=p(),s=O(),i=Cn(),l=o=>o&&o.length>0?r.jsxs("span",{className:"text-subtle",children:[" · ",t("dependencies.requiredByNames",{names:o.join(", ")})]}):null,a=Ne(e,n);return r.jsxs("div",{className:"space-y-2","data-testid":"dependency-plan",children:[n.conflicts.length>0&&r.jsxs(E,{title:t(a==="force"?"dependencies.conflictsForceTitle":"dependencies.conflictsTitle"),testId:"plan-conflicts",tone:a==="force"?"warning":"error",children:[n.conflicts.map(o=>r.jsxs("li",{children:[r.jsx("span",{className:"text-text",children:i(o)}),l(o.requiredBy),o.message&&r.jsx("span",{className:"block text-[11px] text-muted",children:o.message})]},`${o.id}:${o.reason}`)),a==="blocked"&&r.jsx("li",{className:"text-muted pt-1",children:t(e==="install"?"dependencies.conflictsInstallHint":"dependencies.conflictsUpdateHint")})]}),e==="remove"&&n.dependents.length>0&&r.jsxs(E,{title:t("dependencies.removeDependentsTitle"),testId:"plan-dependents",tone:"warning",children:[n.dependents.map(o=>r.jsxs("li",{children:[r.jsx(q,{children:o.name}),o.version&&r.jsxs("span",{className:"text-subtle",children:[" v",o.version]}),o.range&&r.jsxs("span",{className:"text-subtle",children:[" · ",t("dependencies.needsRange",{range:s(o.range)})]})]},o.name)),r.jsx("li",{className:"text-muted pt-1",children:t("dependencies.removeDependentsHint")})]}),n.install.length>0&&r.jsx(E,{title:t("dependencies.planInstall"),testId:"plan-install",children:n.install.map(o=>r.jsxs("li",{children:[r.jsx(q,{children:o.name}),o.version&&r.jsxs("span",{className:"text-subtle",children:[" v",o.version]}),l(o.requiredBy)]},o.name))}),n.update.length>0&&r.jsx(E,{title:t("dependencies.planUpdate"),testId:"plan-update",children:n.update.map(o=>r.jsxs("li",{children:[r.jsx(q,{children:o.name}),r.jsxs("span",{className:"text-subtle",children:[" ",o.from?`v${o.from} → `:"",o.version?`v${o.version}`:""]}),l(o.requiredBy)]},o.name))}),e!=="remove"&&n.dependents.length>0&&r.jsx(E,{title:t("dependencies.requiredByTitle"),testId:"plan-dependents",children:n.dependents.map(o=>r.jsxs("li",{children:[r.jsx(q,{children:o.name}),o.range&&r.jsxs("span",{className:"text-subtle",children:[" · ",t("dependencies.needsRange",{range:s(o.range)})]})]},o.name))}),n.satisfied.length>0&&r.jsx(E,{title:t("dependencies.planSatisfied"),testId:"plan-satisfied",children:n.satisfied.map(o=>r.jsxs("li",{children:[r.jsx(q,{children:o.name}),o.version&&r.jsxs("span",{className:"text-subtle",children:[" v",o.version]}),r.jsxs("span",{className:"text-subtle",children:[" · ",t("dependencies.needsRange",{range:s(o.range)})]})]},o.name))}),n.capabilities.length>0&&r.jsx(E,{title:t("dependencies.planCapabilities"),testId:"plan-capabilities",children:n.capabilities.map(o=>r.jsxs("li",{children:[r.jsx(q,{children:o.capability}),r.jsxs("span",{className:"text-subtle",children:[" · ",o.providedBy.length>0?t("dependencies.providedBy",{plugins:o.providedBy.join(", ")}):t("dependencies.noProvider")]})]},o.capability))}),n.optional.length>0&&r.jsx(E,{title:t("dependencies.planOptional"),testId:"plan-optional",children:n.optional.map(o=>r.jsxs("li",{children:[r.jsx(q,{children:o.name}),r.jsxs("span",{className:"text-subtle",children:[" · ",o.installed?t("dependencies.optionalPresent"):t("dependencies.optionalAbsent")]})]},o.name))})]})}function Ln({action:e,target:n,plan:t,planError:s,onConfirm:i,onCancel:l}){var $;const{t:a}=p(),o=Re(),f=d.useRef(null),A=n.title||n.name,v=(($=n.publisher)==null?void 0:$.name)||"—",g=Ne(e,t),P=t&&e==="install"?{dependencies:!0}:{},N=!!t&&t.install.length+t.update.length+t.satisfied.length+t.capabilities.length+t.optional.length+t.conflicts.length+t.dependents.length>0;return r.jsx(Te,{open:!0,onClose:l,title:a(Mn[e],{title:A}),size:N?"md":"sm",showClose:!1,initialFocus:f,actions:r.jsxs(r.Fragment,{children:[r.jsx("button",{ref:f,type:"button",onClick:l,className:`${G} bg-control hover:bg-control-hover text-text`,children:o.t("confirmCancel")}),g==="force"?r.jsx("button",{type:"button",onClick:()=>i({force:!0}),className:`${G} bg-error/20 hover:bg-error/30 text-error`,children:a(e==="remove"?"dependencies.removeAnyway":"dependencies.updateAnyway")}):r.jsx("button",{type:"button",disabled:g==="blocked","aria-describedby":g==="blocked"?"plan-blocked-reason":void 0,onClick:()=>i(P),className:`${G} bg-error/20 hover:bg-error/30 text-error disabled:cursor-not-allowed`,children:a(Dn[e])})]}),children:r.jsxs("div",{className:"space-y-2","data-testid":"server-plugin-confirm",children:[e==="remove"?r.jsx("p",{children:a("serverMarketplace.confirmRemoveMessage",{package:n.package})}):r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-warning",children:a("serverMarketplace.confirmRisk")}),r.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs",children:[r.jsx("dt",{className:"text-subtle",children:a("serverMarketplace.publisher")}),r.jsxs("dd",{className:"text-text",children:[v,n.publisher&&!n.publisher.verified&&` (${a("marketplace.unverified")})`]}),r.jsx("dt",{className:"text-subtle",children:a("serverMarketplace.package")}),r.jsxs("dd",{className:"font-mono text-text break-all",children:[n.package,n.version?`@${n.version}`:""]})]})]}),t&&N&&r.jsx(Bn,{action:e,plan:t}),g==="blocked"&&r.jsx("p",{id:"plan-blocked-reason",role:"alert",className:"text-xs text-error",children:a(e==="install"?"dependencies.installBlocked":"dependencies.updateBlocked",{title:A})}),s&&r.jsx("p",{"data-testid":"plan-error",className:"text-xs text-muted",children:a("dependencies.planFailed",{message:s})}),r.jsx("p",{className:"text-xs text-muted",children:a("serverMarketplace.confirmRestart")})]})})}function On({message:e,onDismiss:n}){const{t}=p(),{canRestart:s,requestRestart:i}=qe();return r.jsxs("div",{role:"status","data-testid":"restart-notice",className:"flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-sm",children:[r.jsx("span",{className:"text-text",children:e}),r.jsx("span",{className:"font-medium text-warning",children:t("serverMarketplace.restartToApply")}),r.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[s&&r.jsx("button",{type:"button",onClick:i,className:"px-3 py-1 rounded-md text-xs bg-primary hover:bg-primary-hover text-on-primary",children:t("restart.restartServer")}),r.jsx("button",{type:"button",onClick:n,className:"text-xs underline-offset-2 hover:underline text-muted",children:t("marketplace.dismiss")})]})]})}const Un={install:"serverMarketplace.installFailed",update:"serverMarketplace.updateFailed",remove:"serverMarketplace.removeFailed"},Fn={install:"serverMarketplace.installing",update:"serverMarketplace.updating",remove:"serverMarketplace.removing"};function _n(e){const{t:n}=p(),[t,s]=d.useState(null),[i,l]=d.useState(null),a=Me(),o=Pn(),[f,A]=d.useState(null),[v,g]=d.useState(null),[P,N]=d.useState(null),$=d.useCallback(async(x,y,M)=>{var B;const S=y.title||y.name;g(null),N(null),A({name:y.name,action:x,title:S});try{const b=x==="install"?await bn(y.name,void 0,{dependencies:M.dependencies}):x==="update"?await hn(y.name,void 0,{force:M.force}):await kn(y.name,{force:M.force}),U=b.version??y.version??"";if(x==="update"&&b.changed===!1)N({message:n("serverMarketplace.alreadyVersion",{title:S,version:U}),restart:!1});else{const ne=(b.installedPlugins??[]).filter(R=>R.name!==y.name&&R.name!==b.name),Ae=x==="install"&&ne.length>0?n("dependencies.didInstallWith",{title:S,version:U,plugins:ne.map(R=>R.version?`${R.name} ${R.version}`:R.name).join(", ")}):x==="install"?n("serverMarketplace.didInstall",{title:S,version:U}):x==="update"?n("serverMarketplace.didUpdate",{title:S,version:U}):n("serverMarketplace.didRemove",{title:S});N({message:Ae,restart:b.restartRequired})}e(),x!=="remove"&&b.status==="needs-configuration"&&a(gn({name:b.name??y.name,settings:b.settings}))}catch(b){g({title:n(Un[x],{title:S}),message:o(b)}),(B=be(b))!=null&&B.installed.length&&e()}finally{A(null)}},[n,o,e,a]),z=d.useCallback(async(x,y)=>{g(null),l(y.title||y.name);let M=null,S=null;try{M=await yn(x,y.name,x==="remove"?null:y.version)}catch(b){S=I(b)}finally{l(null)}const B=await new Promise(b=>s({action:x,target:y,plan:M,planError:S,resolve:b}));return s(null),B?(await $(x,y,B),!0):!1},[$]),h=r.jsxs(r.Fragment,{children:[t&&r.jsx(Ln,{action:t.action,target:t.target,plan:t.plan,planError:t.planError,onConfirm:x=>t.resolve(x),onCancel:()=>t.resolve(null)}),i&&r.jsxs("div",{role:"status","data-testid":"plan-checking",className:"flex items-center gap-2 text-xs text-muted",children:[r.jsx(Y,{}),n("dependencies.checking",{title:i})]}),f&&r.jsxs("div",{role:"status",className:"flex items-center gap-2 text-xs text-muted",children:[r.jsx(Y,{}),n(Fn[f.action],{title:f.title})]}),v&&r.jsx(An,{title:v.title,message:v.message}),P&&(P.restart?r.jsx(On,{message:P.message,onDismiss:()=>N(null)}):r.jsx(In,{message:P.message,onDismiss:()=>N(null)}))]});return{run:z,busy:f,status:h}}const Vn="font-mono text-sm text-accent hover:underline break-all rounded focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60",Kn="px-3 py-1.5 text-xs rounded-lg transition-colors inline-flex items-center gap-1.5 bg-primary text-on-primary hover:bg-primary/90 disabled:opacity-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60",zn="shrink-0 text-[10px] uppercase tracking-wide text-subtle bg-control border border-border/75 px-1.5 py-0.5 rounded";function Gn({status:e,kind:n}){const{t}=p();if(!e)return r.jsx(W,{variant:"neutral",children:t("dependencies.statusDeclared")});const s=En(n,e);return r.jsx(W,{variant:s.variant,dot:!0,children:t(s.key)})}function Z({id:e,packages:n}){const{t}=p(),{path:s,installed:i}=Tn(n,e);return r.jsx(Le,{to:s,className:Vn,title:i?t("dependencies.openPlugin",{id:e}):t("dependencies.findInMarketplace",{id:e}),children:e})}function Se({title:e,hint:n}){return r.jsxs("div",{className:"mb-3",children:[r.jsx("h3",{className:"text-sm font-semibold text-heading",children:e}),n&&r.jsx("p",{className:"text-xs text-subtle",children:n})]})}function Ct({plugin:e,packages:n}){const{t}=p(),s=O(),i=de(e);return r.jsxs("section",{"data-testid":"dependencies-section",children:[r.jsx(Se,{title:t("dependencies.sectionTitle"),hint:t("dependencies.sectionHint")}),i.length===0?r.jsx("p",{className:"text-xs text-subtle",children:t("dependencies.none")}):r.jsx("ul",{className:"bg-surface border border-border rounded-xl divide-y divide-border",children:i.map(l=>r.jsxs("li",{"data-testid":"dependency-row","data-status":l.status??"declared",className:"px-3 sm:px-4 py-2.5 flex items-start gap-3",children:[r.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 min-w-0",children:[l.kind==="capability"?r.jsx("span",{className:"font-mono text-sm text-text break-all",children:l.id}):r.jsx(Z,{id:l.id,packages:n}),r.jsx("span",{className:zn,children:t(wn[l.kind])}),l.kind!=="capability"&&r.jsx("span",{className:"text-xs text-muted font-mono",children:s(l.range)}),l.order==="before"&&r.jsx("span",{className:"text-[11px] text-subtle",children:t("dependencies.loadsBefore")})]}),(l.version||l.providedBy&&l.providedBy.length>0||l.message)&&r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-subtle",children:[l.version&&r.jsx("span",{children:t("dependencies.found",{version:l.version})}),l.providedBy&&l.providedBy.length>0&&r.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1",children:[t("dependencies.providedByLabel"),l.providedBy.map(a=>r.jsx(Z,{id:a,packages:n},a))]}),l.message&&r.jsx("span",{className:"text-muted",children:l.message})]})]}),r.jsx("span",{"data-testid":"dependency-status",className:"shrink-0",children:r.jsx(Gn,{status:l.status,kind:l.kind})})]},`${l.kind}:${l.id}`))})]})}function $t({dependents:e,packages:n}){const{t}=p();return r.jsxs("section",{"data-testid":"required-by-section",children:[r.jsx(Se,{title:t("dependencies.requiredByTitle"),hint:t("dependencies.requiredByHint")}),e.length===0?r.jsx("p",{className:"text-xs text-subtle",children:t("dependencies.requiredByNone")}):r.jsx("ul",{className:"flex flex-wrap gap-2",children:e.map(s=>r.jsx("li",{className:"px-3 py-1.5 bg-surface border border-border rounded-lg",children:r.jsx(Z,{id:s,packages:n})},s))})]})}async function Hn(e){return(await Promise.all(e.map(t=>fn(t).catch(()=>null)))).filter(t=>!!t&&t.allowed&&!!t.platform&&t.autoInstall).map(t=>({name:t.name,title:t.title,package:t.platform.package,publisher:t.publisher,version:t.platform.latest}))}function Yn(){const{t:e}=p(),n=O();return d.useCallback(t=>{const s=t.kind==="capability"?e("dependencies.capabilityName",{id:t.id}):t.range&&t.range!=="*"?`${t.id} ${t.range}`:t.id,i=e(K[t.status].key).toLowerCase();return t.status==="incompatible"&&t.version?e("dependencies.problemIncompatible",{name:s,version:t.version,range:n(t.range)}):e("dependencies.problem",{name:s,status:i})},[e,n])}function Rt({title:e,dependencies:n,onChanged:t,className:s="",action:i,badge:l=!0}){const{t:a}=p(),o=Yn(),f=De().hasPermission(rn),A=_e(n),v=A.filter(h=>h.kind==="requires"&&h.status==="missing").map(h=>h.id).join(`
2
+ `),g=Be(()=>f&&v?Hn(v.split(`
3
+ `)):Promise.resolve([]),[f,v]),{run:P,busy:N,status:$}=_n(t??(()=>{}));async function z(){for(const h of g.data??[])if(!await P("install",h))break}return r.jsxs("div",{"data-testid":"needs-dependencies",className:`space-y-2 ${s}`,children:[l&&r.jsx(W,{variant:"warning",dot:!0,children:a("dependencies.statusNeedsDependencies")}),r.jsx("p",{className:"text-xs text-warning",children:a("dependencies.needsDependenciesHint")}),A.length>0&&r.jsx("ul",{className:"text-[11px] text-muted font-mono break-all space-y-0.5",children:A.map(h=>r.jsx("li",{children:o(h)},`${h.kind}:${h.id}`))}),(i||g.data&&g.data.length>0||g.loading&&!!v)&&r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i,g.loading&&v&&r.jsx(Y,{size:12,label:a("dependencies.checkingMarketplace")}),g.data&&g.data.length>0&&r.jsx("button",{type:"button",onClick:()=>void z(),disabled:N!==null,"aria-label":a("dependencies.installMissingOf",{title:e}),className:Kn,children:a("dependencies.installMissing")})]}),$]})}function _({id:e,range:n}){const{t}=p(),s=O(),i=n!==void 0?J(n):null;return r.jsxs("li",{className:"inline-flex items-center gap-1.5 font-mono text-[11px] text-text bg-control border border-border/75 px-1.5 py-0.5 rounded",children:[r.jsx("span",{className:"break-all",children:e}),i&&r.jsx("span",{className:"text-subtle",children:s(i.range)}),(i==null?void 0:i.order)==="before"&&r.jsxs("span",{className:"text-subtle font-sans",children:["· ",t("dependencies.loadsBefore")]})]})}function H({title:e,testId:n,children:t}){return r.jsxs("div",{"data-testid":n,className:"flex flex-col sm:flex-row sm:items-baseline gap-1 sm:gap-3",children:[r.jsx("span",{className:"text-xs text-subtle sm:w-24 shrink-0",children:e}),r.jsx("ul",{className:"flex flex-wrap gap-1.5",children:t})]})}function Tt({version:e}){const{t:n}=p(),t=Object.entries(e.requires??{}),s=Object.entries(e.optional??{}),i=e.requiresCapability??[],l=e.provides??[];return t.length+s.length+i.length+l.length===0?r.jsx("p",{"data-testid":"version-no-dependencies",className:"text-xs text-subtle",children:n("dependencies.versionNone")}):r.jsxs("div",{className:"space-y-2","data-testid":"version-dependencies",children:[(t.length>0||i.length>0)&&r.jsxs(H,{title:n("dependencies.requiresTitle"),testId:"version-requires",children:[t.map(([o,f])=>r.jsx(_,{id:o,range:f},o)),i.map(o=>r.jsx(_,{id:n("dependencies.capabilityName",{id:o})},`cap:${o}`))]}),s.length>0&&r.jsx(H,{title:n("dependencies.optionalTitle"),testId:"version-optional",children:s.map(([o,f])=>r.jsx(_,{id:o,range:f},o))}),l.length>0&&r.jsx(H,{title:n("dependencies.providesTitle"),testId:"version-provides",children:l.map(o=>r.jsx(_,{id:o},o))})]})}function qt({plugin:e}){const{t:n}=p(),t=de(e).filter(i=>i.kind!=="optional"),s=e.dependents??[];return t.length===0&&s.length===0?null:r.jsxs("div",{"data-testid":"dependency-summary",className:"mt-0.5 space-y-0.5 text-[11px] text-subtle",children:[t.length>0&&r.jsxs("div",{"data-testid":"summary-requires",className:"break-words",children:[n("dependencies.requiresLine")," ",t.map((i,l)=>{const a=i.kind==="capability"?n("dependencies.capabilityName",{id:i.id}):i.id,o=i.status!==void 0&&i.status!=="ok";return r.jsxs("span",{children:[l>0&&", ",r.jsxs("span",{className:`font-mono ${o?"text-warning":"text-muted"}`,title:i.status?n(K[i.status].key):void 0,children:[a,o&&` (${n(K[i.status].key).toLowerCase()})`]})]},`${i.kind}:${i.id}`)})]}),s.length>0&&r.jsxs("div",{"data-testid":"summary-required-by",className:"break-words",children:[n("dependencies.requiredByLine")," ",r.jsx("span",{className:"font-mono text-muted",children:s.join(", ")})]})]})}export{Nt as $,O as A,Gn as B,Pt as C,wn as D,Tn as E,An as F,Rn as G,Qe as H,it as I,et as J,tt as K,bt as L,st as M,In as N,gn as O,rn as P,Rt as Q,On as R,fe as S,rt as T,nt as U,Tt as V,qt as W,jt as X,V as Y,ve as Z,St as _,he as a,Ct as a0,$t as a1,At as a2,lt as b,vt as c,Pn as d,fn as e,mt as f,gt as g,Xn as h,bn as i,dt as j,kt as k,_n as l,ht as m,at as n,xt as o,ot as p,ct as q,ft as r,yt as s,ut as t,pt as u,hn as v,wt as w,Qn as x,Et as y,It as z};
@@ -0,0 +1,2 @@
1
+ import{r,J as K,aa as q,u as M,b as U,a as G,j as s,P as X,ab as H,d as Y,f as V,ac as z,ad as Q,E as Z,e as $}from"./index-DNbEWPIs.js";import{B as I}from"./Badge-DXfBhPf0.js";import{B as ee}from"./ButtonGroup-cc0CHohH.js";import{D as te}from"./DataTable-_7R5GVOB.js";import"./paging-CCKbuXJo.js";const se=1500;function O(t,u,c){clearTimeout(t.current),t.current=setTimeout(()=>{t.current=void 0,u()},c)}function ne(t,u,c,a={}){const{filter:h,paused:o=!1,delay:p=se}=a,v=r.useRef(c),x=r.useRef(h),y=r.useRef(o),m=r.useRef(!1),i=r.useRef(void 0);r.useEffect(()=>{v.current=c,x.current=h});const l=u;r.useEffect(()=>{const E=d=>{x.current&&!x.current(d)||(y.current?m.current=!0:O(i,()=>v.current(),p))},w=l.split(`
2
+ `).map(d=>t(d,E));return()=>{clearTimeout(i.current),w.forEach(d=>d())}},[l,p,t]),r.useEffect(()=>{y.current=o,o?i.current!==void 0&&(clearTimeout(i.current),i.current=void 0,m.current=!0):m.current&&(m.current=!1,O(i,()=>v.current(),p))},[o,p])}function re(t){return Array.isArray(t)?t:Array.isArray(t==null?void 0:t.clients)?t.clients:[]}async function le(){return re(await K("/api/v1/qcli/ws/clients"))}function ae(t,u,c={}){const{subscribe:a}=q();ne(a,t,u,c)}let ce=0;function oe(t){return t==="events"?"info":t==="shell"?"success":"neutral"}const R=200;function me(){const{t,formatDate:u}=M(),{subscribe:c}=q(),[a,h]=r.useState([]),[o,p]=r.useState(!1),v=r.useRef(!1),[x,y]=r.useState([]),[m,i]=U(),l=m.get("type")??"all",E=m.get("q")??"",w=(e,n)=>i(j=>{const N=new URLSearchParams(j);return n?N.set(e,n):N.delete(e),N},{replace:!0}),d=e=>w("type",e==="all"?null:e),b=r.useRef(null),[g,A]=r.useState(!0),{data:f,loading:W,error:T,refetch:L,refresh:S}=G(le,[]);r.useEffect(()=>{const e=setInterval(S,1e4);return()=>clearInterval(e)},[S]),ae("session:*",S),r.useEffect(()=>c("*",n=>{const j=n.type??"unknown",N={id:++ce,time:new Date,type:j,event:n,payload:JSON.stringify(n)},B=J=>{const C=[...J,N];return C.length>R?C.slice(C.length-R):C};v.current?y(B):h(B)}),[c]),r.useEffect(()=>{g&&b.current&&(b.current.scrollTop=b.current.scrollHeight)},[a,g]);const F=Array.from(new Set([...a.map(e=>{const n=e.type.split(":");return n[0]+(n.length>1?":*":"")}),...l!=="all"?[l]:[]]));function _(){const e=!o;v.current=e,p(e),!e&&x.length>0&&(h(n=>[...n,...x].slice(-R)),y([]))}const k=E.trim().toLowerCase(),P=a.filter(e=>k&&!e.type.toLowerCase().includes(k)&&!e.payload.toLowerCase().includes(k)?!1:l==="all"?!0:l.endsWith(":*")?e.type.startsWith(l.slice(0,-1)):e.type===l),D=[{key:"id",header:t("events.colId"),render:e=>s.jsxs("span",{className:"font-mono text-xs text-muted",children:[e.id.slice(0,12),"..."]})},{key:"type",header:t("events.colType"),sortValue:e=>e.type,render:e=>s.jsx(I,{variant:oe(e.type),children:e.type})},{key:"connectedAt",header:t("events.colConnected"),sortValue:e=>Date.parse(e.connectedAt),render:e=>s.jsx("span",{className:"text-xs text-muted",children:u(e.connectedAt,{timeStyle:"medium"})})},{key:"remoteAddress",header:t("events.colRemote"),render:e=>s.jsx("span",{className:"font-mono text-xs text-muted",children:e.remoteAddress})}];return s.jsxs("div",{children:[s.jsx(X,{title:t("nav.events"),subtitle:t("events.subtitle")}),s.jsx("div",{className:"p-4 sm:p-6",children:s.jsxs("div",{className:"flex flex-col lg:flex-row gap-4 lg:h-[calc(100vh-12rem)]",children:[s.jsx(H,{label:t("events.liveEvents"),resetKeys:[a,l],children:s.jsxs("div",{className:"flex-[2] flex flex-col max-lg:h-[60vh] bg-surface border border-border rounded-xl overflow-hidden",children:[s.jsxs("div",{className:"px-4 py-3 border-b border-border/75 flex items-center gap-3 flex-wrap",children:[s.jsx("span",{className:"text-sm font-medium text-heading",children:t("events.liveEvents")}),s.jsx("span",{className:"text-xs text-subtle",children:t("events.shown",{shown:a.length,max:R})}),s.jsx("input",{type:"search",value:E,onChange:e=>w("q",e.target.value||null),placeholder:t("events.search"),"aria-label":t("events.search"),className:"ml-auto w-40 text-xs bg-control border border-border text-text rounded px-2 py-1 placeholder-subtle focus:outline-none"}),s.jsx(Y,{label:t("events.filterLabel"),options:[{value:"all",label:t("events.allTypes")},...F.map(e=>({value:e,label:e}))],value:l,onChange:d,onClear:l!=="all"?()=>d("all"):void 0}),s.jsx(ee,{label:t("events.liveEvents"),items:[{key:"pause",label:o?t("events.resumeHeld",{count:x.length}):t("events.pause"),tone:o?"warning":"default",pressed:o,onClick:_},{key:"scroll",label:t(g?"events.autoScrollOn":"events.autoScrollOff"),tone:g?"primary":"default",pressed:g,onClick:()=>A(!g)},{key:"clear",label:t("events.clear"),tone:"danger",onClick:()=>{h([]),y([])}}]})]}),s.jsx("div",{ref:b,onScroll:()=>{if(!b.current)return;const{scrollTop:e,scrollHeight:n,clientHeight:j}=b.current;A(n-e-j<60)},className:"flex-1 overflow-y-auto p-3 font-mono text-xs space-y-0.5",children:P.length===0?a.length>0?s.jsx(V,{className:"font-sans",message:t("events.noMatch",{count:a.length}),action:s.jsx("button",{type:"button",onClick:()=>i(e=>{const n=new URLSearchParams(e);return n.delete("type"),n.delete("q"),n},{replace:!0}),className:"text-xs text-accent hover:underline",children:t("events.clear")})}):s.jsx("div",{className:"text-subtle py-4 text-center font-sans",children:t("events.waiting")}):P.map(e=>s.jsxs("div",{className:"flex items-start gap-2 py-0.5 hover:bg-control rounded px-1",children:[s.jsxs("span",{className:"text-subtle shrink-0",children:["[",u(e.time,{timeStyle:"medium"}),"]"]}),s.jsx(I,{variant:z(e.type),children:e.type}),(()=>{const n=Q(e.event,t);return n&&s.jsx("span",{className:"text-text shrink-0 max-w-[50%] truncate",title:n,children:n})})(),s.jsx("span",{className:"text-muted truncate flex-1 text-[10px]",title:e.payload,children:e.payload})]},e.id))})]})}),s.jsx(H,{label:t("events.connectedClients"),resetKeys:[f],children:s.jsx("div",{className:"flex-1 flex flex-col max-lg:h-72",children:s.jsxs("div",{className:"bg-surface border border-border rounded-xl overflow-hidden flex flex-col h-full",children:[s.jsxs("div",{className:"px-4 py-3 border-b border-border/75 flex items-center justify-between",children:[s.jsx("span",{className:"text-sm font-medium text-heading",children:t("events.connectedClients")}),s.jsxs("div",{className:"flex items-center gap-2",children:[f&&s.jsx("span",{className:"text-xs text-subtle",children:t("events.connectedCount",{count:f.length})}),s.jsx("button",{onClick:L,className:"text-[10px] px-2 py-0.5 rounded bg-control text-muted hover:bg-control-hover transition-colors",children:t("common.refresh")})]})]}),s.jsx("div",{className:"flex-1 overflow-auto",children:T&&!f?s.jsx("div",{className:"p-3",children:s.jsx(Z,{error:T,onRetry:L,compact:!0})}):W&&!f?s.jsx($,{rows:3,columns:D.length,plain:!0}):f&&f.length>0?s.jsx(te,{columns:D,data:f,keyExtractor:e=>e.id,plain:!0}):s.jsx(V,{message:t("events.noClients")})})]})})})]})})]})}export{me as default};
@@ -0,0 +1,2 @@
1
+ import{am as Ye,r,an as Ze,j as t,ao as Je,ap as Qe,u as Ie,aq as he,ar as et,as as tt,A as st,S as rt,at as Fe,C as at,au as nt,c as ot,aa as lt,b as ct,av as it,aw as ut,ax as dt,ay as Le,az as mt,aA as gt,aB as xt,aC as ht,aD as ft,P as pt,d as ke,aE as vt,E as bt,q as jt,aF as St,aG as Ce,aH as Te,l as wt,m as z}from"./index-DNbEWPIs.js";const _=44,Et=20,Me=2,yt=24,Nt=2;function Rt({columns:s,xTicks:d,formatValue:p,integer:h=!1,height:j=180,selectedKey:i=null,onSelect:u,stale:H=!1,ariaLabel:k}){const[W,N]=Ye(),[w,F]=r.useState(null),R=Math.max(0,N-_),v=j-Et,$=s.map(c=>c.segments.reduce((S,o)=>S+o.value,0)),{max:D,ticks:b}=Ze(Math.max(0,...$),h),f=s.length?R/s.length:0,E=Math.max(1,Math.min(yt,f-Me)),M=c=>v-c/D*v,L=w!==null?s[w]:void 0,V=w!==null?M($[w]):0;return t.jsxs("div",{ref:W,className:`relative select-none transition-opacity ${H?"opacity-50":""}`,onPointerLeave:()=>F(null),children:[N>0&&t.jsxs("svg",{width:N,height:j,role:"group","aria-label":k,className:"block overflow-visible",children:[b.map(c=>t.jsxs("g",{children:[t.jsx("line",{x1:_,x2:N,y1:M(c),y2:M(c),stroke:"var(--qcli-border)",strokeWidth:1,shapeRendering:"crispEdges"}),t.jsx("text",{x:_-8,y:M(c),dy:"0.32em",textAnchor:"end",className:"fill-subtle text-[10px] tabular-nums",children:p(c)})]},c)),s.map((c,S)=>{const o=_+S*f+(f-E)/2,m=i===c.key,g=i!==null&&!m;let x=v;const A=c.segments.filter(y=>y.value>0);return t.jsxs("g",{tabIndex:0,role:"button","aria-label":c.ariaLabel,"aria-pressed":u?m:void 0,className:"outline-none focus-visible:[&>rect.hit]:stroke-[var(--qcli-primary)]",style:{cursor:u?"pointer":"default"},onPointerEnter:()=>F(S),onFocus:()=>F(S),onBlur:()=>F(null),onClick:()=>u==null?void 0:u(m?null:c.key),onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),u==null||u(m?null:c.key))},children:[t.jsx("rect",{className:"hit",x:_+S*f,y:0,width:f,height:v,fill:w===S||m?"var(--qcli-control)":"transparent",stroke:"transparent",strokeWidth:1,rx:4}),A.map((y,B)=>{const Z=B===A.length-1,C=Math.max(Nt,y.value/D*v),O=Math.max(1,B>0?C-Me:C);return x-=C,t.jsx("path",{d:Je(o,x,E,O,Z),fill:y.color,opacity:g?.35:1},y.key)})]},c.key)}),t.jsx("line",{x1:_,x2:N,y1:v,y2:v,stroke:"var(--qcli-border)",strokeWidth:1,shapeRendering:"crispEdges"}),d.map(c=>t.jsx("text",{x:_+(c.index+.5)*f,y:j-4,textAnchor:"middle",className:"fill-subtle text-[10px]",children:c.label},c.index))]}),L&&t.jsx(Qe,{x:_+(w+.5)*f,y:V,width:N,title:L.title,rows:L.rows})]})}const me={DEBUG:"var(--qcli-subtle)",INFO:"var(--qcli-info)",WARN:"var(--qcli-warning)",ERROR:"var(--qcli-error)"},Lt=["ERROR","WARN","INFO","DEBUG"],kt=3e4;function Ct({filters:s,search:d,onPick:p}){const{t:h,formatDate:j,formatNumber:i}=Ie(),[u,H]=r.useState(null),[k,W]=r.useState(!1),[N,w]=r.useState(!1),[F,R]=r.useState(!1),[v,$]=r.useState(0),D=he(s.levels),{range:b,customFrom:f,customTo:E,service:M}=s;if(r.useEffect(()=>{if(b!=="live")return;const o=setInterval(()=>$(m=>m+1),kt);return()=>clearInterval(o)},[b]),r.useEffect(()=>{if(k)return;let o=!1;const m=et({range:b,customFrom:f,customTo:E});return R(!0),tt({level:D,search:d,service:M||void 0,from:new Date(m.from).toISOString(),to:new Date(m.to).toISOString(),buckets:m.buckets}).then(g=>{o||(Array.isArray(g==null?void 0:g.buckets)?(H(g),w(!1)):W(!0))}).catch(g=>{o||(g instanceof st&&(g.status===404||g.status===501)?W(!0):w(!0))}).finally(()=>{o||R(!1)}),()=>{o=!0}},[D,d,M,b,f,E,v,k]),k||!u&&N)return null;if(!u)return t.jsx(rt,{height:142,label:h("logs.volume")});const L=u.buckets.length>0&&u.bucketMs*u.buckets.length>36*36e5,V=o=>j(o,L?{weekday:"short",hour:"2-digit"}:{hour:"2-digit",minute:"2-digit"}),c=o=>`${j(o,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})} – ${j(o+u.bucketMs,{hour:"2-digit",minute:"2-digit"})}`,S=Fe.filter(o=>s.levels.has(o));return t.jsx(at,{title:h("logs.volume"),note:h("logs.volumeNote"),legend:t.jsx(ot,{items:S.map(o=>({label:o,color:me[o],value:i(u.totals[o]??0)}))}),children:t.jsx(Rt,{columns:u.buckets.map(o=>{const m=Date.parse(o.start),g=S.reduce((x,A)=>x+(o[A]??0),0);return{key:String(m),segments:Lt.filter(x=>s.levels.has(x)).map(x=>({key:x,value:o[x]??0,color:me[x]})),title:c(m),rows:[...S].reverse().map(x=>({label:x,value:i(o[x]??0),color:me[x]})),ariaLabel:h("logs.volumeColumn",{time:c(m),total:g,errors:o.ERROR??0})}}),xTicks:nt(u.buckets.length,6).map(o=>({index:o,label:V(Date.parse(u.buckets[o].start))})),formatValue:o=>i(o,{notation:"compact"}),integer:!0,height:120,onSelect:o=>{o&&p(Number(o),Number(o)+u.bucketMs)},stale:F,ariaLabel:h("logs.volume")})})}const ge={DEBUG:"text-muted",INFO:"text-info",WARN:"text-warning",ERROR:"text-error"},Tt={DEBUG:"bg-subtle/20",INFO:"bg-info/20",WARN:"bg-warning/20",ERROR:"bg-error/20"},Mt={live:"logs.rangeLive","15m":"logs.range15m","1h":"logs.range1h","24h":"logs.range24h","7d":"logs.range7d",custom:"logs.rangeCustom"},At={year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"},Ot=100,Y=1e3,Ae=new WeakMap;let It=0;function Ft(s){let d=Ae.get(s);return d===void 0&&(d=++It,Ae.set(s,d)),d}const Oe=["","","","live","",""].join("\0"),Dt=300,Pt=48,xe="px-3 py-1.5 text-sm bg-control border border-border rounded-lg text-text focus:outline-none focus:border-primary/50";function _t(s,d){if(!d)return s;const p=s.toLowerCase().indexOf(d.toLowerCase());return p===-1?s:t.jsxs(t.Fragment,{children:[s.slice(0,p),t.jsx("span",{className:"bg-warning/30 text-heading",children:s.slice(p,p+d.length)}),s.slice(p+d.length)]})}function Ht(s){return s.charAt(0).toUpperCase()+s.slice(1)}function Ut(){const{t:s,formatDate:d}=Ie(),{subscribe:p}=lt(),[h,j]=r.useState([]),[i,u]=r.useState(null),[H,k]=r.useState(0),[W,N]=r.useState(!1),[w,F]=r.useState(!0),[R,v]=r.useState(null),[$,D]=ct(),[b]=r.useState(()=>it($)),[f]=r.useState(()=>$.get("at")),[E,M]=r.useState(new Set(b.levels)),[L,V]=r.useState(b.search),[c,S]=r.useState(b.search),[o,m]=r.useState(b.service),[g,x]=r.useState(b.range),[A,y]=r.useState(b.customFrom),[B,Z]=r.useState(b.customTo),C=r.useRef(null),[O,ne]=r.useState(()=>!f),[oe,De]=r.useState(!1),le=r.useRef(!1),I=r.useRef([]),[fe,ce]=r.useState(0),[Pe,_e]=r.useState(()=>new Set),[He,pe]=r.useState(null),P=i!==null&&ut(i),J={levels:E,search:L,service:o,range:g,customFrom:A,customTo:B},Q=r.useRef(J),T=r.useRef(P);r.useLayoutEffect(()=>{Q.current=J,T.current=P});const q=r.useRef(0),ve=r.useRef({}),ie=r.useRef(!1),ee=r.useRef(null),te=r.useRef(Y),ue=r.useCallback((e,n)=>{const a=Q.current;return dt({level:T.current?he(a.levels):void 0,search:T.current?a.search:void 0,service:T.current&&a.service||void 0,...T.current?n??Le(a):{},limit:Ot,offset:e})},[]),K=[he(E)??"",c,o,g,A,B].join("\0"),be=r.useRef(K);r.useLayoutEffect(()=>{be.current=K});const[je,We]=r.useState(null),Se=P&&je!==null&&je!==K&&!R,X=r.useCallback(()=>{const e=++q.current,n=T.current?be.current:Oe,a=T.current?Le(Q.current):{};ue(0,a).then(l=>{if(e!==q.current)return;const{entries:U,...ze}=l;ve.current=mt(a,U[0]),I.current=[],ce(0),j([...U].reverse()),te.current=Math.max(Y,U.length),u(ze),k(U.length),We(n),v(null)}).catch(l=>{e===q.current&&v(l instanceof Error?{message:l.message}:{key:"logs.loadFailed"})}).finally(()=>{e===q.current&&F(!1)})},[ue]);r.useEffect(()=>{X()},[X]),r.useEffect(()=>{const e=setTimeout(()=>S(L),Dt);return()=>clearTimeout(e)},[L]);const se=r.useRef(null);r.useEffect(()=>{P&&(se.current===null&&(se.current=Oe),se.current!==K&&(se.current=K,X()))},[K,P,X]);async function de(){if(ie.current)return;ie.current=!0,N(!0);const e=q.current;try{const n=await ue(H,T.current?ve.current:void 0);if(e!==q.current)return;const a=C.current;a&&(ee.current=a.scrollHeight-a.scrollTop),j(l=>{const U=[...[...n.entries].reverse(),...l];return te.current=Math.max(Y,U.length),U}),k(l=>l+n.entries.length),u(l=>l&&{...l,total:n.total,hasMore:n.hasMore}),v(null)}catch(n){v({...n instanceof Error?{message:n.message}:{key:"logs.loadMoreFailed"},more:!0})}finally{ie.current=!1,N(!1)}}r.useEffect(()=>p("log:entry",n=>{const a=n;!a.timestamp||!a.level||!a.message||T.current&&!gt(a,Q.current)||(le.current?(I.current.push(a),I.current.length>Y&&I.current.splice(0,I.current.length-Y),ce(I.current.length)):j(l=>[...l,a]),T.current||(u(l=>l&&l.total!=null?{...l,total:l.total+1}:l),k(l=>l+1)))}),[p]),r.useEffect(()=>{const e=h.length-te.current;e<=0||(j(n=>n.slice(n.length-te.current)),k(n=>Math.max(0,n-e)),u(n=>n&&{...n,hasMore:!0}))},[h]),r.useLayoutEffect(()=>{const e=C.current;e&&(ee.current!==null?(e.scrollTop=e.scrollHeight-ee.current,ee.current=null):O&&(e.scrollTop=e.scrollHeight))},[h,O]);const re=r.useMemo(()=>f?h.find(e=>e.timestamp===f)??null:null,[h,f]),we=r.useRef(!1);r.useEffect(()=>{var n,a;if(!re||we.current)return;const e=(n=C.current)==null?void 0:n.querySelector('[data-focused="true"]');e&&(we.current=!0,(a=e.scrollIntoView)==null||a.call(e,{block:"center"}))});function $e(){const e=!le.current;if(le.current=e,De(e),!e&&I.current.length>0){const n=I.current;I.current=[],ce(0),j(a=>[...a,...n])}}function Be(e){_e(n=>{const a=new Set(n);return a.has(e)?a.delete(e):a.add(e),a})}async function Ge(e){try{await navigator.clipboard.writeText(Ce(e)),pe(e),setTimeout(()=>pe(n=>n===e?null:n),1500)}catch{}}function Ue(e){M(n=>{const a=new Set(n);return a.has(e)?a.size>1&&a.delete(e):a.add(e),a})}const G=h.filter(e=>xt(e,J)),Ee=ht(J).toString();r.useEffect(()=>{D(new URLSearchParams(Ee),{replace:!0})},[Ee,D]);function qe(e,n){x("custom"),y(Te(e)),Z(Te(n))}const ae=(i==null?void 0:i.services)??[],Ke=P&&(ae.length>1||(i==null?void 0:i.persistent)===!0),ye=P,Ve=ae.length>1||new Set(h.map(e=>e.service).filter(Boolean)).size>1;function Xe(){const e=G.map(Ce).join(`
2
+ `),n=new Blob([e],{type:"text/plain"}),a=URL.createObjectURL(n),l=document.createElement("a");l.href=a,l.download=`server-logs-${new Date().toISOString().slice(0,19).replace(/[:.]/g,"-")}.txt`,l.click(),URL.revokeObjectURL(a)}const Ne=i!==null&&ft(i,H),Re=i!=null&&i.store?i.persistent?s("logs.storePersistent",{store:Ht(i.store)}):s("logs.storeMemory"):null;return t.jsxs("div",{children:[t.jsx(pt,{title:s("nav.logs"),subtitle:Re?`${s("logs.shown",{count:G.length})} · ${Re}`:s("logs.shown",{count:G.length}),actions:t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("button",{onClick:Xe,disabled:G.length===0,title:s("logs.exportTitle"),className:"px-3 py-1.5 text-xs bg-control hover:bg-control-hover text-text rounded-lg transition-colors disabled:opacity-40",children:s("logs.export")})})}),t.jsxs("div",{className:"p-4 sm:p-6 space-y-4",children:[P&&t.jsx(Ct,{filters:{levels:E,search:c,service:o,range:g,customFrom:A,customTo:B},search:c,onPick:qe}),t.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[t.jsx("div",{className:"flex items-center gap-2",role:"group","aria-label":s("logs.levels"),children:Fe.map(e=>t.jsx("button",{onClick:()=>Ue(e),"aria-pressed":E.has(e),title:s(E.has(e)?"logs.hideLevel":"logs.showLevel",{level:e}),className:`px-2.5 py-1 text-xs font-medium rounded-lg border transition-colors ${E.has(e)?`${Tt[e]} ${ge[e]} border-current/30`:"bg-surface/75 text-subtle border-border/75"}`,children:e},e))}),t.jsx("input",{type:"text",placeholder:s("logs.search"),"aria-label":s("logs.search"),value:L,onChange:e=>V(e.target.value),className:`flex-1 max-w-sm placeholder-subtle ${xe}`}),Ke&&t.jsx(ke,{label:s("logs.service"),options:[{value:"",label:s("logs.allServices")},...ae.map(e=>({value:e,label:e}))],value:o,onChange:m,onClear:o?()=>m(""):void 0,searchable:ae.length>8}),ye&&t.jsx(ke,{label:s("logs.range"),options:vt.map(e=>({value:e,label:s(Mt[e])})),value:g,onChange:x}),ye&&g==="custom"&&t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted",children:[t.jsxs("label",{className:"flex items-center gap-1",children:[s("logs.from"),t.jsx("input",{type:"datetime-local",value:A,onChange:e=>y(e.target.value),className:xe})]}),t.jsxs("label",{className:"flex items-center gap-1",children:[s("logs.to"),t.jsx("input",{type:"datetime-local",value:B,onChange:e=>Z(e.target.value),className:xe})]})]})]}),(w||Se)&&t.jsx($t,{label:s("logs.loading")}),R&&t.jsx(bt,{error:"message"in R?R.message:s(R.key),onRetry:R.more?()=>void de():X}),!w&&!Se&&t.jsxs("div",{className:"bg-surface border border-border rounded-xl overflow-hidden",children:[t.jsxs("div",{className:"px-4 py-3 border-b border-border/75 flex items-center justify-between",children:[t.jsx("span",{className:"text-sm font-medium text-heading",children:s("logs.output")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:$e,"aria-pressed":oe,title:s("logs.pauseTitle"),className:`text-[10px] px-2 py-0.5 rounded ${oe?"bg-warning/20 text-warning":"bg-control text-muted"}`,children:oe?fe>0?s("logs.resumeHeld",{count:fe}):s("logs.resume"):s("logs.pause")}),t.jsx("button",{onClick:()=>ne(!O),"aria-pressed":O,title:s("logs.autoScrollTitle"),className:`text-[10px] px-2 py-0.5 rounded ${O?"bg-primary/20 text-accent":"bg-control text-muted"}`,children:s(O?"logs.autoScrollOn":"logs.autoScrollOff")})]})]}),t.jsxs("div",{className:"relative",children:[t.jsxs("div",{ref:C,onScroll:()=>{if(!C.current)return;const{scrollTop:e,scrollHeight:n,clientHeight:a}=C.current;ne(n-e-a<60),e<Pt&&Ne&&n>a&&de()},className:"overflow-y-auto max-h-[60vh] p-3 font-mono text-xs leading-5",children:[Ne&&t.jsx("div",{className:"flex justify-center pb-2",children:t.jsx("button",{onClick:()=>void de(),disabled:W,className:"px-3 py-1 rounded-lg bg-control hover:bg-control-hover text-[11px] font-sans text-accent transition-colors disabled:opacity-50",children:W?t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(jt,{size:11}),s("common.loading")]}):(i==null?void 0:i.total)!=null?s("logs.loadOlder",{remaining:Math.max(i.total-H,0)}):s("logs.loadOlderMore")})}),G.length===0?t.jsx("div",{className:"text-subtle py-4 text-center",children:s("logs.noMatches")}):G.map(e=>t.jsxs("div",{"data-focused":e===re||void 0,className:`group flex flex-wrap sm:flex-nowrap items-start gap-2 py-0.5 rounded px-1 ${e===re?"bg-error/10 ring-1 ring-error/50":"hover:bg-control"}`,children:[t.jsx("time",{dateTime:e.timestamp,className:"text-subtle shrink-0 text-[10px]",children:d(e.timestamp,At)}),t.jsx("span",{className:`shrink-0 font-bold w-12 text-[10px] ${ge[e.level]??"text-muted"}`,children:e.level}),Ve&&e.service&&t.jsx("span",{className:"shrink-0 text-[10px] px-1 rounded bg-control text-muted max-w-[80px] sm:max-w-[120px] truncate",title:e.service,children:e.service}),e.source&&t.jsxs("span",{className:"text-subtle shrink-0 text-[10px] max-w-[80px] sm:max-w-[120px] truncate",title:e.source,children:["[",e.source,"]"]}),t.jsxs("div",{className:`flex-1 min-w-0 max-sm:min-w-[12rem] ${ge[e.level]??"text-text"}`,children:[t.jsx("span",{className:"whitespace-pre-wrap break-all",children:_t(e.message,L)}),e.exception&&(()=>{const{preview:n,hidden:a}=St(e.exception),l=a===0||Pe.has(e)!==(e===re);return t.jsxs(t.Fragment,{children:[t.jsx("pre",{className:"mt-0.5 text-[10px] text-muted whitespace-pre-wrap break-all",children:l?e.exception:n}),a>0&&t.jsx("button",{onClick:()=>Be(e),className:"text-[10px] font-sans text-accent hover:underline",children:l?s("logs.hideException"):s("logs.showException",{count:a})})]})})()]}),t.jsx("button",{onClick:()=>void Ge(e),title:s("logs.copyTitle"),className:"shrink-0 text-[10px] font-sans px-1.5 rounded bg-control text-muted hover:text-text opacity-0 group-hover:opacity-100 focus:opacity-100 transition-opacity",children:s(He===e?"logs.copied":"logs.copy")})]},Ft(e)))]}),!O&&G.length>0&&t.jsx("button",{onClick:()=>ne(!0),className:"absolute bottom-3 right-5 px-3 py-1 text-[11px] rounded-full bg-primary hover:bg-primary-hover text-on-primary shadow-lg transition-colors",children:s("logs.jumpToNewest")})]})]})]})]})}const Wt=["72%","54%","88%","64%","80%","46%","70%","60%"];function $t({label:s}){return t.jsxs(wt,{label:s,className:"bg-surface border border-border rounded-xl overflow-hidden",children:[t.jsxs("div",{className:"px-4 py-3.5 border-b border-border/75 flex justify-between",children:[t.jsx(z,{className:"h-3.5 w-20"}),t.jsx(z,{className:"h-3.5 w-28"})]}),t.jsx("div",{className:"p-3 space-y-2.5",children:Wt.map((d,p)=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(z,{className:"h-2.5 w-28 shrink-0"}),t.jsx(z,{className:"h-2.5 w-9 shrink-0"}),t.jsx(z,{className:"h-2.5",style:{width:d}})]},p))})]})}export{Ut as default};
@@ -0,0 +1 @@
1
+ import{u as R,c4 as B,w as L,c5 as D,y as G,r as y,c6 as U,a as Y,j as t,P as H,c7 as T,E as w,L as V,f as q,N as A,b as Q,c8 as z,c9 as J,Q as K}from"./index-DNbEWPIs.js";import{B as E}from"./Badge-DXfBhPf0.js";import{B as I}from"./ButtonGroup-cc0CHohH.js";const W={info:"info",warning:"warning",error:"error"},g="px-2.5 py-1.5 min-h-9 sm:min-h-0 text-xs rounded-lg transition-colors inline-flex items-center gap-1.5 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60",S=`${g} bg-primary text-on-primary hover:bg-primary-hover`,p=`${g} bg-control hover:bg-control-hover text-text`,X=`${g} bg-control text-error hover:bg-error/10`;function Z(){const[e,n]=Q(),a=e.get("unread")==="1",o=e.get("severity"),i=T.includes(o)?o:null,d=(r,c)=>n(b=>{const f=new URLSearchParams(b);return c===null?f.delete(r):f.set(r,c),f},{replace:!0});return{unread:a,severity:i,setUnread:r=>d("unread",r?"1":null),setSeverity:r=>d("severity",r)}}function ee({item:e,canManage:n,busy:a,onAction:o}){const{t:i,formatRelative:d,formatDate:r}=R(),c=e.link;return t.jsxs("article",{"aria-label":e.title,"data-testid":"notification-card",className:`bg-surface border rounded-xl p-4 flex gap-3 ${e.read?"border-border":"border-primary/40"}`,children:[t.jsx(z,{severity:e.severity,className:"mt-0.5"}),t.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("h3",{className:`text-sm break-words min-w-0 ${e.read?"text-text":"text-heading font-semibold"}`,children:e.title}),!e.read&&t.jsx(E,{variant:"info",dot:!0,children:i("notifications.unread")})]}),e.message&&t.jsx("p",{className:"text-xs text-muted whitespace-pre-wrap break-words",children:e.message}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-subtle",children:[t.jsx(E,{variant:W[e.severity],children:i(`notifications.${e.severity}`)}),t.jsx("span",{className:"font-mono",children:e.kind}),t.jsx("time",{dateTime:e.updatedAt,title:r(e.updatedAt),children:d(e.updatedAt)})]}),t.jsxs("div",{role:"group","aria-label":i("notifications.itemActions",{title:e.title}),className:"flex flex-wrap items-center gap-2 pt-1",children:[c&&(J(c)?t.jsxs("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:S,onClick:()=>!e.read&&o("read"),children:[i("notifications.open")," ↗"]}):t.jsx(K,{to:c,className:S,onClick:()=>!e.read&&o("read"),children:i("notifications.open")})),!e.read&&t.jsx("button",{type:"button",disabled:a,onClick:()=>o("read"),className:p,children:i("notifications.markRead")}),t.jsx("button",{type:"button",disabled:a,onClick:()=>o("dismiss"),className:p,children:i("notifications.dismiss")}),n&&t.jsx("button",{type:"button",disabled:a,onClick:()=>o("clear"),className:X,children:i("notifications.clearEveryone")})]})]})]})}function ie(){var k;const{t:e}=R(),{unread:n,severity:a,setUnread:o,setSeverity:i}=Z(),{revision:d,unreadCount:r,markRead:c,markAllRead:b,dismiss:f}=B(),O=L().hasPermission(D),{confirm:P,dialog:_}=G(),h=y.useCallback(()=>U({unread:n,severity:a}),[n,a]),l=Y(h,[h,d]),[F,N]=y.useState(null),[v,m]=y.useState(null);async function M(s,x){if(!(x==="clear"&&!await P({title:e("notifications.confirmClear"),message:e("notifications.confirmClearMessage",{title:s.title}),confirmLabel:e("notifications.clearEveryone"),tone:"danger"}))){N(s.id),m(null);try{x==="read"?await c(s.id):await f(s.id,x==="clear")}catch(C){m(e("notifications.actionFailed",{message:A(C)}))}finally{N(null)}}}async function $(){m(null);try{await b()}catch(s){m(e("notifications.actionFailed",{message:A(s)}))}}const u=((k=l.data)==null?void 0:k.items)??(!l.loading&&!l.error?[]:null),j=n||a!==null;return t.jsxs("div",{children:[_,t.jsx(H,{title:e("notifications.title"),subtitle:r>0?e("notifications.subtitle",{count:r}):e("notifications.subtitleNone"),actions:t.jsxs("div",{className:"flex flex-wrap gap-2",children:[r>0&&t.jsx("button",{type:"button",onClick:()=>void $(),className:p,children:e("notifications.markAllRead")}),t.jsx("button",{type:"button",onClick:l.refetch,className:p,children:e("common.refresh")})]})}),t.jsxs("div",{className:"p-4 sm:p-6 space-y-4 max-w-4xl",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx(I,{label:e("notifications.filterStatus"),items:[{key:"all",label:e("notifications.filterAll"),pressed:!n,tone:n?"default":"primary",onClick:()=>o(!1)},{key:"unread",label:e("notifications.filterUnread"),pressed:n,tone:n?"primary":"default",onClick:()=>o(!0)}]}),t.jsx(I,{label:e("notifications.severity"),items:[{key:"any",label:e("notifications.severityAll"),pressed:a===null,tone:a===null?"primary":"default",onClick:()=>i(null)},...T.map(s=>({key:s,label:e(`notifications.${s}`),pressed:a===s,tone:a===s?"primary":"default",onClick:()=>i(s)}))]})]}),v&&t.jsx(w,{error:v,title:e("notifications.title"),compact:!0}),l.loading&&!l.data&&t.jsx(V,{items:4,label:e("notifications.title"),className:"bg-surface border border-border rounded-xl p-4"}),l.error&&!l.data&&t.jsx(w,{title:e("notifications.loadFailed"),error:l.error,onRetry:l.refetch}),u&&u.length===0&&t.jsx(q,{className:"bg-surface border border-border rounded-xl",message:e(j?"notifications.noMatch":"notifications.empty"),detail:j?void 0:e("notifications.emptyHint")}),u&&u.length>0&&t.jsx("div",{className:"space-y-3",children:u.map(s=>t.jsx(ee,{item:s,canManage:O,busy:F===s.id,onAction:x=>void M(s,x)},s.id))})]})]})}export{ie as default};
@@ -0,0 +1 @@
1
+ import{_,u,a as N,w as J,r as W,j as e,$ as X,P as Y,E as y,f as B,Q as p,e as Z,a0 as z,g as G,N as ee,a1 as se,W as ne}from"./index-DNbEWPIs.js";import{B as q}from"./Badge-DXfBhPf0.js";import{C as te}from"./commandInfo-B8tZOPKW.js";import{D as ae}from"./DataTable-_7R5GVOB.js";import{X as K,Y as k,Z as ie,T as re,Q as oe,_ as de,$ as le,h as ce,a0 as me,a1 as ue,U as xe,M as O,a2 as pe,H as ge,J as he,K as fe}from"./DependencyParts-BI02t_lf.js";import"./paging-CCKbuXJo.js";async function be(){const[a,s]=await Promise.all([he(),fe().catch(()=>null)]);return{modules:Array.isArray(a)?a:[],packages:s}}async function je(){try{return await ne()}catch{return[]}}const ve=a=>`/commands?q=${encodeURIComponent(a)}`;function x({title:a,hint:s,children:n}){return e.jsxs("section",{children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-heading",children:a}),s&&e.jsx("p",{className:"text-xs text-subtle",children:s})]}),n]})}function C({current:a}){const{t:s}=u();return e.jsx("nav",{"aria-label":s("plugins.breadcrumb"),className:"text-xs text-subtle",children:e.jsxs("ol",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("li",{children:e.jsx(p,{to:"/plugins",className:"text-accent hover:underline rounded focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60",children:s("nav.plugins")})}),e.jsx("li",{"aria-hidden":!0,children:"/"}),e.jsx("li",{"aria-current":"page",className:"truncate text-muted",children:a})]})})}function $({items:a,title:s,label:n}){return e.jsx(te,{items:a,max:3,title:s,label:n,chipClassName:"font-mono text-[11px] text-muted bg-control border border-border/75 px-1.5 py-0.5 rounded"})}function A({icon:a,names:s,name:n,version:d,byline:t,description:m,status:h,action:g}){const{t:i}=u();return e.jsxs("div",{className:"bg-surface border border-border rounded-xl p-4 sm:p-5 flex items-start gap-4",children:[e.jsx(O,{icon:a,names:s}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h2",{className:"font-semibold text-heading text-base truncate",children:n}),d&&e.jsxs("span",{className:"text-[10px] text-subtle font-mono bg-control px-1.5 py-0.5 rounded",children:["v",d]}),h]}),t&&e.jsx("div",{className:"text-xs text-subtle mt-0.5",children:t}),e.jsx("p",{className:"text-sm text-muted mt-2",children:m||i("plugins.noDescription")})]}),g&&e.jsx("div",{className:"shrink-0 pt-1",children:g})]})}function Ne({commands:a}){const{t:s}=u(),n=new Map(a.map(t=>[t.command,pe(t)])),d=[...n.values()].some(t=>t.length>0);return e.jsx(ae,{keyExtractor:t=>t.command,data:a,defaultSort:{key:"command",direction:"asc"},columns:[{key:"command",header:s("commands.colCommand"),sortValue:t=>t.command,render:t=>e.jsxs(p,{to:ve(t.command),title:s("plugins.openInCommands",{command:t.command}),className:"font-mono text-sm text-accent hover:underline rounded focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60",children:[t.icon&&e.jsx("span",{"aria-hidden":!0,className:"mr-1.5",children:t.icon}),t.command]})},{key:"description",header:s("commands.colDescription"),render:t=>e.jsx("span",{className:"text-muted",children:t.description||"—"})},{key:"sub",header:s("commands.subCommands"),render:t=>e.jsx($,{items:(t.processors??[]).map(m=>m.command),label:s("commands.subCommands"),title:s("commands.subCommandsOf",{command:t.command})})},...d?[{key:"permissions",header:s("plugins.colPermissions"),render:t=>e.jsx($,{items:n.get(t.command)??[],label:s("plugins.colPermissions"),title:s("commands.permissionsOf",{command:t.command})})}]:[]]})}function ye({pages:a}){const{t:s,locale:n}=u();return e.jsx(x,{title:s("plugins.pagesTitle"),hint:s("plugins.pagesHint"),children:e.jsx("ul",{className:"flex flex-wrap gap-2",children:a.map(d=>e.jsx("li",{children:e.jsxs(p,{to:`/x/${d.id}`,className:"inline-flex items-center gap-2 px-3 py-2 text-sm bg-surface border border-border rounded-lg text-text hover:border-primary/50 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60",children:[d.icon&&e.jsx("span",{"aria-hidden":!0,children:d.icon}),se(d,n)]})},d.id))})})}function ke({providers:a}){const{t:s}=u();return e.jsx(x,{title:s("plugins.configTitle"),hint:s("plugins.configHint"),children:e.jsx("ul",{className:"flex flex-wrap gap-2",children:a.map(n=>e.jsx("li",{children:e.jsxs(p,{to:`/config?provider=${encodeURIComponent(n.id)}`,className:"inline-flex items-center gap-2 px-3 py-2 text-sm bg-surface border border-border rounded-lg text-text hover:border-primary/50 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60",children:[n.title||n.id,e.jsx("span",{className:"text-xs text-subtle",children:s("plugins.configSections",{count:n.sections.length})})]})},n.id))})})}function F({id:a,icon:s,name:n,version:d,detail:t,status:m}){return e.jsxs(p,{to:ge(a),className:"flex items-start gap-3 bg-surface border border-border rounded-xl p-3 hover:border-primary/50 hover:bg-control/40 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60",children:[e.jsx(O,{icon:s,names:[a,n]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-semibold text-heading text-sm truncate",children:n}),d&&e.jsxs("span",{className:"text-[10px] text-subtle font-mono bg-control px-1.5 py-0.5 rounded",children:["v",d]}),m]}),t&&e.jsx("div",{className:"text-[11px] text-subtle font-mono mt-0.5 truncate",title:t,children:t})]})]})}function U({enabled:a}){const{t:s}=u();return e.jsx(q,{variant:a?"success":"neutral",dot:!0,children:s(a?"common.enabled":"common.disabled")})}function Ee(){var w,T,D,S,E,H,M,I,L;const a=_().id??"",{t:s}=u(),n=N(be,[]),d=N(G,[]),t=N(je,[]),{extensions:m}=J(),[h,g]=W.useState(null),i=(w=n.data)==null?void 0:w.modules.find(r=>r.id===a),o=i||(D=(T=n.data)==null?void 0:T.packages)==null?void 0:D.find(r=>r.id===a),c=o??(i?((E=(S=n.data)==null?void 0:S.packages)==null?void 0:E.find(r=>r.pluginId===i.id))??K((H=n.data)==null?void 0:H.packages,i.id):void 0),f=i?k(i.id):o?ie(o.id):null,P=f?m.filter(r=>k(r.id)===f):[],j=f?(t.data??[]).filter(r=>k(r.id)===f||!!(o!=null&&o.settings)&&r.id===o.settings):[];function Q(){n.refetch(),d.refetch(),t.refetch()}async function V(r){g(null);try{await xe(r.id)}catch(l){g(s("plugins.toggleFailed",{name:r.name||r.id,message:ee(l)}))}n.refresh()}if(n.loading&&!n.data)return e.jsx(X,{label:s("plugins.loadingDetails")});const b=i?i.name||i.id:o?o.name||o.id:a,v=e.jsx(Y,{title:s("nav.plugins"),subtitle:i?s("plugins.moduleKind"):o?s("plugins.packageKind"):void 0,actions:e.jsx("button",{onClick:Q,className:"px-3 py-1.5 text-xs bg-control hover:bg-control-hover text-text rounded-lg transition-colors",children:s("common.refresh")})});return n.error?e.jsxs("div",{children:[v,e.jsxs("div",{className:"p-4 sm:p-6 space-y-4",children:[e.jsx(C,{current:a}),e.jsx(y,{error:n.error,onRetry:n.refetch})]})]}):!i&&!o?e.jsxs("div",{children:[v,e.jsxs("div",{className:"p-4 sm:p-6 space-y-4",children:[e.jsx(C,{current:a}),e.jsx(B,{className:"bg-surface border border-border rounded-xl",message:s("plugins.notFound"),detail:s("plugins.notFoundDetail",{id:a}),action:e.jsx(p,{to:"/plugins",className:"text-sm text-accent hover:underline",children:s("plugins.backToPlugins")})})]})]}):e.jsxs("div",{children:[v,e.jsxs("div",{className:"p-4 sm:p-6 space-y-8",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(C,{current:b}),i?e.jsx(A,{icon:i.icon,names:[i.id,i.name],name:b,version:i.version,byline:i.author?s("plugins.byAuthor",{author:i.author}):void 0,description:i.description,status:e.jsx(U,{enabled:i.enabled}),action:e.jsx(re,{enabled:i.enabled,onToggle:()=>V(i)})}):o&&e.jsx(A,{icon:o.icon,names:[o.id,o.name],name:b,version:o.version,byline:e.jsx("span",{className:"font-mono",children:o.id}),description:o.description,status:o.status==="needs-dependencies"?e.jsx(q,{variant:"warning",dot:!0,children:s("dependencies.statusNeedsDependencies")}):void 0}),(o==null?void 0:o.status)==="needs-dependencies"&&e.jsx(oe,{title:b,dependencies:o.dependencies,onChanged:n.refresh,badge:!1,className:"rounded-xl border border-warning/30 bg-warning/[0.06] px-4 py-3"}),h&&e.jsx(y,{error:h,title:s("plugins.manager"),compact:!0})]}),i&&e.jsxs(x,{title:s("plugins.commandsTitle"),hint:s("plugins.commandsHint"),children:[d.loading&&!d.data&&e.jsx(Z,{rows:3,columns:3,label:s("commands.loadingCommands")}),d.error&&e.jsx(y,{error:d.error,onRetry:d.refetch,compact:!0}),d.data&&!d.error&&(()=>{const r=de(d.data,i);return r.length>0?e.jsx(Ne,{commands:r}):e.jsx(B,{className:"bg-surface border border-border rounded-xl",message:s("plugins.noModuleCommands")})})()]}),o&&n.data&&(()=>{const r=le(n.data.modules,o.id);return r.length>0&&e.jsx(x,{title:s("plugins.commandModules"),hint:s("plugins.providedModulesHint"),children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3",children:r.map(l=>{var R;return e.jsx(F,{id:l.id,icon:l.icon,name:l.name||l.id,version:l.version,detail:s("plugins.processorCount",{count:l.processorCount??((R=l.processors)==null?void 0:R.length)??0}),status:e.jsx(U,{enabled:l.enabled})},l.id)})})})})(),c&&(c.dependencies!==void 0||ce(c))&&e.jsx(me,{plugin:c,packages:(M=n.data)==null?void 0:M.packages}),(c==null?void 0:c.dependents)!==void 0&&e.jsx(ue,{dependents:c.dependents,packages:(I=n.data)==null?void 0:I.packages}),P.length>0&&e.jsx(ye,{pages:P}),t.loading&&!t.data&&e.jsx(z,{lines:2,label:s("plugins.loadingDetails")}),j.length>0&&e.jsx(ke,{providers:j}),j.length===0&&!!((L=t.data)!=null&&L.length)&&e.jsx(x,{title:s("plugins.configTitle"),children:e.jsx("p",{"data-testid":"no-settings",className:"text-xs text-subtle",children:s("marketplace.noSettings")})}),i&&(()=>{var l;const r=K((l=n.data)==null?void 0:l.packages,i.id);return r&&e.jsx(x,{title:s("plugins.packageTitle"),hint:s("plugins.packageHint"),children:e.jsx("div",{className:"max-w-md",children:e.jsx(F,{id:r.id,icon:r.icon,name:r.name||r.id,version:r.version,detail:r.id})})})})()]})]})}export{Ee as default};