@superdangerous/app-framework 4.16.19 → 4.16.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,7 +13,7 @@ A comprehensive, production-ready framework for building enterprise internal too
13
13
  ### Features
14
14
 
15
15
  - **[WebSocket](./docs/WEBSOCKET.md)** - Real-time communication implementation
16
- - **[Desktop](./docs/DESKTOP.md)** - Desktop application support with Tauri
16
+ - **[Desktop](./docs/DESKTOP.md)** - Desktop application support with Electron
17
17
  - **[Bundling](./docs/BUNDLING.md)** - Desktop bundling guide
18
18
  - **[AI](./docs/AI.md)** - AI service integration
19
19
  - **[Patterns](./docs/PATTERNS.md)** - Proven architectural patterns
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdangerous/app-framework",
3
- "version": "4.16.19",
3
+ "version": "4.16.20",
4
4
  "description": "Opinionated TypeScript framework for structured vibecoding - building internal web and desktop apps with batteries included",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/ui/dist/index.js CHANGED
@@ -8,7 +8,7 @@ ${fe.message}`:fe.message,Ws={...Bt,metadata:{...Bt.metadata||{},stack:In}},js=[
8
8
  ${de.metadata.stack}`:"";return Bt+In}).join(`
9
9
  `),K=new Blob([P],{type:"text/plain"}),fe=URL.createObjectURL(K),ke=document.createElement("a");ke.href=fe,ke.download=`logs-${new Date().toISOString()}.txt`,ke.click(),URL.revokeObjectURL(fe);}sonner.toast.success("Logs exported successfully");}catch{sonner.toast.error("Failed to export logs");}},_r=async()=>{try{let P=$.map(K=>{let fe=gr(K.timestamp),ke=K.category||K.source?` [${K.category||K.source}]`:"",de=`${fe} ${K.level.toUpperCase()}${ke} ${K.message}`,qe=K.metadata?.stack?`
10
10
  ${K.metadata.stack}`:"";return de+qe}).join(`
11
- `);await navigator.clipboard.writeText(P),sonner.toast.success("Logs copied to clipboard");}catch{sonner.toast.error("Failed to copy logs");}},gr=P=>{try{let K=new Date(P);return dateFns.format(K,"yyyy-MM-dd HH:mm:ss.SSS")}catch{return P}},vt=P=>P<1024?`${P} B`:P<1024*1024?`${(P/1024).toFixed(1)} KB`:`${(P/(1024*1024)).toFixed(1)} MB`,mr=P=>P?P.replace(/\x1b\[[0-9;]*m/g,"").replace(/\u001b\[[0-9;]*m/g,"").replace(/\x1b\[[0-9;]*m/g,"").replace(/\[[0-9;]+m/g,"").replace(/\[[\d;]*m/g,""):"",Kt=P=>jsxRuntime.jsxs("div",{className:"px-3 py-2 font-mono text-xs border-b border-gray-100 dark:border-gray-800 text-gray-800 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-900",children:[jsxRuntime.jsxs("div",{className:"flex items-start gap-2",children:[jsxRuntime.jsx("span",{className:"text-gray-500 dark:text-gray-400 whitespace-nowrap",children:gr(P.timestamp)}),jsxRuntime.jsx("span",{className:"flex-shrink-0",children:jsxRuntime.jsx(q,{level:P.level})}),(P.category||P.source)&&jsxRuntime.jsxs("span",{className:"text-gray-600 dark:text-gray-400 whitespace-nowrap",children:["[",P.category||P.source,"]"]}),jsxRuntime.jsx("span",{className:"whitespace-pre-wrap break-all",children:mr(P.message)})]}),P.metadata?.stack&&jsxRuntime.jsx("pre",{className:"ml-[180px] whitespace-pre overflow-x-auto text-[10px] leading-snug mt-1 text-gray-500 dark:text-gray-400",children:mr(P.metadata.stack)}),P.metadata&&!P.metadata.stack&&Object.keys(P.metadata).length>0&&jsxRuntime.jsx("div",{className:"ml-[180px] mt-1 text-gray-500 dark:text-gray-400",children:Object.entries(P.metadata).map(([K,fe])=>jsxRuntime.jsxs("span",{className:"mr-4",children:[jsxRuntime.jsxs("span",{className:"font-medium",children:[K,":"]})," ",typeof fe=="object"?JSON.stringify(fe):String(fe)]},K))})]},P.id),Rn=[...ne].sort((P,K)=>{let fe=P.filename||P.name||"",ke=K.filename||K.name||"",de=0;switch(to){case "filename":de=fe.localeCompare(ke);break;case "size":de=P.size-K.size;break;case "modified":de=new Date(P.modified).getTime()-new Date(K.modified).getTime();break}return ia==="asc"?de:-de}),$s=P=>{to===P?L(K=>K==="asc"?"desc":"asc"):(Gs(P),L("desc"));},qs=({field:P})=>to!==P?jsxRuntime.jsx(lucideReact.ArrowUpDown,{className:"h-3 w-3 ml-1 opacity-50"}):ia==="asc"?jsxRuntime.jsx(lucideReact.ArrowUp,{className:"h-3 w-3 ml-1"}):jsxRuntime.jsx(lucideReact.ArrowDown,{className:"h-3 w-3 ml-1"}),JO=async()=>{if(!(!Fe||!s)){try{await s(Fe),Q(P=>P.filter(K=>(K.filename||K.name)!==Fe)),sonner.toast.success("Archive deleted successfully");}catch{sonner.toast.error("Failed to delete archive");}Zr(null);}},e1=W?C:C.filter(P=>P.id!=="archives"),t1=M==="full"&&E;return jsxRuntime.jsxs("div",{className:N("flex flex-col h-full",B),children:[A&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4 shrink-0",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h1",{className:"text-3xl font-bold",children:"Logs"}),jsxRuntime.jsxs("div",{className:"text-muted-foreground flex items-center",children:["View system logs and diagnostic information \u2022 Current level:"," ",jsxRuntime.jsx(it,{className:N("ml-1 text-xs px-2 py-0",S[D]||S.info),children:D.toUpperCase()})]})]}),T==="current"&&jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[c>0&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(zt,{id:"auto-refresh",checked:oe,onCheckedChange:I}),jsxRuntime.jsx(gt,{htmlFor:"auto-refresh",className:"text-sm cursor-pointer",children:"Auto-refresh"})]}),p&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(zt,{id:"auto-scroll",checked:Z,onCheckedChange:ue}),jsxRuntime.jsx(gt,{htmlFor:"auto-scroll",className:"text-sm cursor-pointer",children:"Auto-scroll"})]}),jsxRuntime.jsx("div",{className:"h-6 w-px bg-border"}),r&&jsxRuntime.jsxs(j,{variant:"outline",size:"sm",onClick:()=>r().then(P=>P&&F(le(ye(P)))),children:[jsxRuntime.jsx(lucideReact.RefreshCw,{className:"h-4 w-4 mr-2"}),"Refresh"]}),R&&jsxRuntime.jsxs(j,{variant:"outline",size:"sm",onClick:_r,children:[jsxRuntime.jsx(lucideReact.Copy,{className:"h-4 w-4 mr-2"}),"Copy"]}),k&&jsxRuntime.jsxs(j,{variant:"outline",size:"sm",onClick:Ut,children:[jsxRuntime.jsx(lucideReact.Download,{className:"h-4 w-4 mr-2"}),"Export"]}),o&&x&&jsxRuntime.jsxs(j,{variant:"destructive",size:"sm",onClick:()=>or(true),children:[jsxRuntime.jsx(lucideReact.Trash2,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]}),!A&&T==="current"&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4 shrink-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[c>0&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(zt,{id:"auto-refresh-embedded",checked:oe,onCheckedChange:I}),jsxRuntime.jsx(gt,{htmlFor:"auto-refresh-embedded",className:"text-sm cursor-pointer",children:"Auto-refresh"})]}),p&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(zt,{id:"auto-scroll-embedded",checked:Z,onCheckedChange:ue}),jsxRuntime.jsx(gt,{htmlFor:"auto-scroll-embedded",className:"text-sm cursor-pointer",children:"Auto-scroll"})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[r&&jsxRuntime.jsxs(j,{variant:"outline",size:"sm",onClick:()=>r().then(P=>P&&F(le(ye(P)))),children:[jsxRuntime.jsx(lucideReact.RefreshCw,{className:"h-4 w-4 mr-2"}),"Refresh"]}),R&&jsxRuntime.jsxs(j,{variant:"outline",size:"sm",onClick:_r,children:[jsxRuntime.jsx(lucideReact.Copy,{className:"h-4 w-4 mr-2"}),"Copy"]}),k&&jsxRuntime.jsxs(j,{variant:"outline",size:"sm",onClick:Ut,children:[jsxRuntime.jsx(lucideReact.Download,{className:"h-4 w-4 mr-2"}),"Export"]}),o&&x&&jsxRuntime.jsxs(j,{variant:"destructive",size:"sm",onClick:()=>or(true),children:[jsxRuntime.jsx(lucideReact.Trash2,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 flex-1 min-h-0",children:[t1&&jsxRuntime.jsx(Ne,{className:"w-64 h-fit",children:jsxRuntime.jsxs("div",{className:"p-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold mb-4",children:"Categories"}),jsxRuntime.jsx("div",{className:"space-y-1",children:e1.map(P=>{let K=P.icon;return jsxRuntime.jsxs("button",{onClick:()=>we(P.id),className:N("w-full flex items-center gap-3 px-3 py-2 rounded-md text-sm transition-colors",T===P.id?"bg-primary text-primary-foreground":"hover:bg-muted"),children:[jsxRuntime.jsx(K,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{className:"text-left",children:P.label})]},P.id)})})]})}),jsxRuntime.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:T==="archives"?jsxRuntime.jsxs(Ne,{className:"p-0 overflow-hidden flex-1 flex flex-col min-h-0",children:[M==="full"&&jsxRuntime.jsxs("div",{className:"px-6 py-4 border-b shrink-0",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold",children:"Log Archives"}),jsxRuntime.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["Download or manage archived log files \u2022 ",Rn.length," file",Rn.length!==1?"s":""]})]}),M!=="full"&&jsxRuntime.jsxs("div",{className:"px-4 py-2 border-b shrink-0 text-sm text-muted-foreground",children:[Rn.length," archive",Rn.length!==1?"s":""," available"]}),Rn.length===0?jsxRuntime.jsx("div",{className:"p-6",children:jsxRuntime.jsxs(ct,{children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4"}),jsxRuntime.jsx(ut,{children:"No archived log files available"})]})}):jsxRuntime.jsx("div",{className:"overflow-auto",style:{maxHeight:_},children:jsxRuntime.jsxs("table",{className:"w-full",children:[jsxRuntime.jsx("thead",{className:"bg-background sticky top-0 z-10 border-b",children:jsxRuntime.jsxs("tr",{children:[jsxRuntime.jsx("th",{className:"text-left px-4 py-2 font-medium text-sm",children:jsxRuntime.jsxs("button",{className:"flex items-center hover:text-foreground",onClick:()=>$s("filename"),children:["Name",jsxRuntime.jsx(qs,{field:"filename"})]})}),jsxRuntime.jsx("th",{className:"text-right px-4 py-2 font-medium text-sm w-28",children:jsxRuntime.jsxs("button",{className:"flex items-center justify-end hover:text-foreground ml-auto",onClick:()=>$s("size"),children:["Size",jsxRuntime.jsx(qs,{field:"size"})]})}),jsxRuntime.jsx("th",{className:"text-right px-4 py-2 font-medium text-sm w-36",children:jsxRuntime.jsxs("button",{className:"flex items-center justify-end hover:text-foreground ml-auto",onClick:()=>$s("modified"),children:["Modified",jsxRuntime.jsx(qs,{field:"modified"})]})}),jsxRuntime.jsx("th",{className:"text-right px-4 py-2 font-medium text-sm w-24",children:"Actions"})]})}),jsxRuntime.jsx("tbody",{children:Rn.map(P=>{let K=P.filename||P.name||"unknown";return jsxRuntime.jsxs("tr",{className:"border-t hover:bg-muted/30",children:[jsxRuntime.jsx("td",{className:"px-4 py-2",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Archive,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),jsxRuntime.jsx("span",{className:"font-mono text-sm truncate",children:K})]})}),jsxRuntime.jsx("td",{className:"px-4 py-2 text-right text-sm text-muted-foreground font-mono",children:vt(P.size)}),jsxRuntime.jsx("td",{className:"px-4 py-2 text-right text-sm text-muted-foreground",children:dateFns.format(new Date(P.modified),"MMM d, yyyy HH:mm")}),jsxRuntime.jsx("td",{className:"px-4 py-2 text-right",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1",children:[i&&jsxRuntime.jsx(j,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>i(K),title:"Download",children:jsxRuntime.jsx(lucideReact.Download,{className:"h-4 w-4"})}),s&&jsxRuntime.jsx(j,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-destructive hover:text-destructive",onClick:()=>Zr(K),title:"Delete",children:jsxRuntime.jsx(lucideReact.Trash2,{className:"h-4 w-4"})})]})})]},K)})})]})})]}):jsxRuntime.jsxs(Ne,{className:"p-0 overflow-hidden",children:[jsxRuntime.jsx("div",{className:"px-4 py-3 border-b bg-gray-50 dark:bg-gray-900 flex items-center justify-between",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[h&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Level:"}),jsxRuntime.jsxs(Tt,{value:_e,onValueChange:Se,children:[jsxRuntime.jsx(ft,{className:"w-36 h-8",children:jsxRuntime.jsx(At,{children:_e==="all"?jsxRuntime.jsx("span",{children:"All Levels"}):jsxRuntime.jsx(q,{level:_e})})}),jsxRuntime.jsxs(bt,{children:[jsxRuntime.jsx(Be,{value:"all",children:"All Levels"}),jsxRuntime.jsx(Be,{value:"error",children:jsxRuntime.jsx(q,{level:"error"})}),jsxRuntime.jsx(Be,{value:"warn",children:jsxRuntime.jsx(q,{level:"warn"})}),jsxRuntime.jsx(Be,{value:"info",children:jsxRuntime.jsx(q,{level:"info"})}),jsxRuntime.jsx(Be,{value:"debug",children:jsxRuntime.jsx(q,{level:"debug"})}),jsxRuntime.jsx(Be,{value:"verbose",children:jsxRuntime.jsx(q,{level:"verbose"})})]})]})]}),h&&lt.length>0&&jsxRuntime.jsxs(Tt,{value:et,onValueChange:Ue,children:[jsxRuntime.jsx(ft,{className:"w-44 h-8",children:jsxRuntime.jsx(At,{})}),jsxRuntime.jsxs(bt,{children:[jsxRuntime.jsx(Be,{value:"all",children:"All Categories"}),lt.map(P=>jsxRuntime.jsx(Be,{value:P,children:P},P))]})]}),b&&jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(lucideReact.Search,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),jsxRuntime.jsx("input",{type:"text",placeholder:"Search logs...",value:Ee,onChange:P=>$e(P.target.value),className:"pl-8 pr-3 py-1.5 text-sm border rounded-md w-64 focus:outline-none focus:ring-2 focus:ring-primary"})]})]})}),jsxRuntime.jsx("div",{className:N("bg-white dark:bg-gray-900"),style:{height:_},children:v?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full",children:jsxRuntime.jsx("div",{className:"h-8 w-8 rounded-full border-2 border-gray-300 border-t-transparent animate-spin"})}):$.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full text-gray-400",children:jsxRuntime.jsxs("div",{className:"text-center",children:[jsxRuntime.jsx(lucideReact.Terminal,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),jsxRuntime.jsx("p",{children:"No logs to display"}),jsxRuntime.jsx("p",{className:"text-xs mt-1",children:"Logs will appear here as they are generated"})]})}):jsxRuntime.jsx(reactVirtuoso.Virtuoso,{ref:Oe,data:$,followOutput:Z?"smooth":false,overscan:200,itemContent:(P,K)=>Kt(K),style:{height:"100%"}})}),jsxRuntime.jsx("div",{className:"border-t bg-muted/50 px-4 py-2 flex justify-between items-center",children:jsxRuntime.jsxs("div",{className:"text-sm text-muted-foreground",children:[$.length," ",$.length===1?"line":"lines"]})})]})})]}),jsxRuntime.jsx(ho,{open:at,onOpenChange:or,title:"Delete Logs",description:"Are you sure you want to delete all logs? This action cannot be undone.",confirmLabel:"Delete",variant:"destructive",onConfirm:pr}),jsxRuntime.jsx(ho,{open:!!Fe,onOpenChange:P=>!P&&Zr(null),title:"Delete Archive",description:`Are you sure you want to delete "${Fe}"? This action cannot be undone.`,confirmLabel:"Delete",variant:"destructive",onConfirm:JO})]})}var an=class extends Error{constructor(t,r,n){super(t),this.name="ApiError",this.status=r,this.details=n;}};function EL(){return window.__TAURI__?"http://localhost:3000":undefined?.VITE_API_URL?undefined.VITE_API_URL:""}async function ha(e,t={}){let{timeout:r=3e4,retries:n=0,retryDelay:o=1e3,...a}=t,s=`${EL()}${e}`,l=new Headers(a.headers);!l.has("Content-Type")&&a.body&&typeof a.body=="string"&&l.set("Content-Type","application/json");let c=new AbortController,u=setTimeout(()=>c.abort(),r),d=null;for(let g=0;g<=n;g++)try{let p=await fetch(s,{...a,headers:l,signal:c.signal});clearTimeout(u);let m=p.headers.get("content-type"),f;if(m?.includes("application/json")?f=await p.json():f=await p.text(),typeof f=="object"&&"success"in f){let b=f;if(!b.success)throw new an(b.error||b.message||"Request failed",p.status,b.details);return b.data??b.logs??b.files??b.entries??b.items??b}if(!p.ok)throw new an(f.message||f.error||`HTTP ${p.status}`,p.status);return f}catch(p){if(d=p,p instanceof an&&p.status<500)throw p;if(p instanceof Error&&p.name==="AbortError")throw new an("Request timeout",408);g<n&&await new Promise(m=>setTimeout(m,o*(g+1)));}throw clearTimeout(u),d||new an("Request failed",500)}function TL({apiUrl:e="/api/logs"}){let t=Ce.useCallback(async()=>{try{let a=await ha(`${e}/entries`);return a?.entries||a?.logs||[]}catch(a){return console.warn("Failed to fetch logs:",a),[]}},[e]),r=Ce.useCallback(async()=>{try{let a=await ha(`${e}/files`);return (a?.files||a?.archives||[]).map(i=>({filename:i.filename||i.name,name:i.name,size:i.size,modified:i.modified}))}catch(a){return console.warn("Failed to fetch archives:",a),[]}},[e]),n=Ce.useCallback(async()=>{await ha(`${e}/clear`,{method:"POST"});},[e]),o=Ce.useCallback(a=>{window.open(`${e}/download/${a}`,"_blank");},[e]);return jsxRuntime.jsx(on,{onFetchLogs:t,onFetchArchives:r,onClearLogs:n,onDownloadArchive:o,enableSearch:true,enableFilter:true,enableExport:true,enableClear:true,enableAutoScroll:true,showCategories:true,showArchives:true,height:"calc(100vh - 200px)"})}function he(...e){return tailwindMerge.twMerge(clsx.clsx(e))}function gl({show:e,onRestart:t,onDismiss:r,className:n}){let[o,a]=Ce.useState(e),[i,s]=Ce.useState(false);return Ce.useEffect(()=>{e?(a(true),setTimeout(()=>s(true),10)):(s(false),setTimeout(()=>a(false),300));},[e]),o?jsxRuntime.jsx("div",{className:he("fixed top-0 left-0 right-0 z-50 transition-all duration-300 ease-in-out",i?"translate-y-0 opacity-100":"-translate-y-full opacity-0",n),children:jsxRuntime.jsxs(ct,{className:"rounded-none border-x-0 border-t-0 bg-amber-50 dark:bg-amber-950/50",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4 text-amber-600 dark:text-amber-400"}),jsxRuntime.jsxs(ut,{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-amber-800 dark:text-amber-200",children:"Configuration changes require a restart to take effect"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[t&&jsxRuntime.jsxs(j,{size:"sm",variant:"default",onClick:t,className:"bg-amber-600 hover:bg-amber-700 text-white",children:[jsxRuntime.jsx(lucideReact.RefreshCw,{className:"h-3 w-3 mr-1"}),"Restart Now"]}),r&&jsxRuntime.jsx(j,{size:"sm",variant:"ghost",onClick:r,className:"text-amber-700 hover:text-amber-800 dark:text-amber-300 dark:hover:text-amber-200",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3 w-3"})})]})]})]})}):null}function BL({categories:e,values:t,loading:r=false,saving:n=false,onSave:o,onReset:a,onRestart:i,showRestartBanner:s=false,className:l,title:c="Settings"}){let[u,d]=Ce.useState(t),[g,p]=Ce.useState({}),[m,f]=Ce.useState(e[0]?.id||""),[b,h]=Ce.useState({}),[k,x]=Ce.useState(false),R=(A,E)=>{d(_=>({..._,[A]:E})),x(true);let W=e.flatMap(_=>_.settings).find(_=>_.key===A);if(W?.validation){let _=W.validation(E);p(B=>({...B,[A]:_||""}));}},C=async()=>{let A={},E=false;if(e.forEach(W=>{W.settings.forEach(_=>{if(_.validation){let B=_.validation(u[_.key]);B&&(A[_.key]=B,E=true);}});}),E){p(A);return}await o(u),x(false);},S=()=>{d(t),p({}),x(false),a&&a();},D=e.find(A=>A.id===m)?.settings||[],M=A=>{let E=u[A.key]??A.defaultValue,W=g[A.key];switch(A.type){case "text":return jsxRuntime.jsx(Et,{value:E||"",onChange:_=>R(A.key,_.target.value),placeholder:A.placeholder,className:W?"border-red-500":""});case "password":return jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(Et,{type:b[A.key]?"text":"password",value:E||"",onChange:_=>R(A.key,_.target.value),placeholder:A.placeholder,className:he("pr-10",W?"border-red-500":"")}),jsxRuntime.jsx("button",{type:"button",onClick:()=>h(_=>({..._,[A.key]:!_[A.key]})),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700",children:b[A.key]?jsxRuntime.jsx(lucideReact.EyeOff,{className:"h-4 w-4"}):jsxRuntime.jsx(lucideReact.Eye,{className:"h-4 w-4"})})]});case "number":return jsxRuntime.jsx(Et,{type:"number",value:E||"",onChange:_=>R(A.key,parseFloat(_.target.value)),min:A.min,max:A.max,placeholder:A.placeholder,className:W?"border-red-500":""});case "boolean":return jsxRuntime.jsx(zt,{checked:E||false,onCheckedChange:_=>R(A.key,_)});case "select":return jsxRuntime.jsxs(Tt,{value:String(E||""),onValueChange:_=>R(A.key,_),children:[jsxRuntime.jsx(ft,{className:W?"border-red-500":"",children:jsxRuntime.jsx(At,{placeholder:"Select an option"})}),jsxRuntime.jsx(bt,{children:A.options?.map(_=>jsxRuntime.jsx(Be,{value:_.value,children:_.label},_.value))})]});case "custom":return A.customComponent;default:return null}};return r?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8",children:jsxRuntime.jsxs("div",{className:"text-center",children:[jsxRuntime.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading settings..."})]})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[s&&jsxRuntime.jsx(gl,{show:true,onRestart:i,onDismiss:()=>{}}),jsxRuntime.jsxs("div",{className:he("space-y-6",l),children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center",children:[jsxRuntime.jsx("h1",{className:"text-2xl font-bold",children:c}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs(j,{variant:"outline",size:"sm",onClick:S,disabled:!k||n,children:[jsxRuntime.jsx(lucideReact.RotateCcw,{className:"h-4 w-4"}),"Reset"]}),jsxRuntime.jsx(j,{size:"sm",onClick:C,disabled:!k||n||Object.keys(g).some(A=>g[A]),children:n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"Saving..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Save,{className:"h-4 w-4"}),"Save Changes"]})})]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-12 gap-6",children:[jsxRuntime.jsx("div",{className:"col-span-3",children:jsxRuntime.jsx(Ne,{className:"p-2",children:e.map(A=>jsxRuntime.jsxs("button",{onClick:()=>f(A.id),className:he("w-full text-left px-3 py-2 rounded-md transition-colors flex items-center gap-2",m===A.id?"bg-primary text-primary-foreground":"hover:bg-gray-100 dark:hover:bg-gray-800"),children:[A.icon,jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"font-medium",children:A.label}),A.description&&jsxRuntime.jsx("div",{className:"text-xs opacity-70",children:A.description})]})]},A.id))})}),jsxRuntime.jsx("div",{className:"col-span-9",children:jsxRuntime.jsx(Ne,{className:"p-6",children:jsxRuntime.jsx("div",{className:"space-y-6",children:D.map(A=>jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-between",children:jsxRuntime.jsxs(gt,{htmlFor:A.key,children:[A.label,A.requiresRestart&&jsxRuntime.jsx("span",{className:"ml-2 text-xs text-amber-600",children:"(Requires restart)"})]})}),A.description&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:A.description}),M(A),g[A.key]&&jsxRuntime.jsxs(ct,{variant:"destructive",className:"py-2",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4"}),jsxRuntime.jsx(ut,{children:g[A.key]})]})]},A.key))})})})]})]})]})}function Ln({url:e,className:t,checkInterval:r=5e3}){let[n,o]=Ce.useState(false),[a,i]=Ce.useState(true),s=Ce.useRef(false);Ce.useEffect(()=>{if(s.current)return;s.current=true;let d=true,g=e||"",p=async()=>{if(d)try{let f=await fetch(`${g}/api/health`,{credentials:"include"});d&&(o(f.ok),i(!1));}catch{d&&(o(false),i(false));}};p();let m=setInterval(p,r);return ()=>{d=false,clearInterval(m),s.current=false;}},[]);let l=a?"bg-gray-400":n?"bg-green-500":"bg-red-500",c=a?"Checking...":n?"Connected":"Disconnected",u=a?"Checking connection to backend API...":n?"Frontend is connected to the backend API via WebSockets. Real-time updates are enabled.":"Cannot connect to the backend API. Please check if the backend server is running.";return jsxRuntime.jsx(pa,{children:jsxRuntime.jsxs(ga,{children:[jsxRuntime.jsx(ma,{asChild:true,children:jsxRuntime.jsxs("button",{className:he("inline-flex items-center gap-2 px-3 py-1 rounded-full","bg-gray-800/50 backdrop-blur-sm","hover:bg-gray-800/70 transition-all duration-200","cursor-default select-none",t),type:"button","aria-label":`Connection status: ${c}`,children:[jsxRuntime.jsxs("div",{className:"relative flex items-center justify-center w-2 h-2",children:[jsxRuntime.jsx("div",{className:he("absolute w-2 h-2 rounded-full transition-all duration-300",l,n&&"shadow-lg shadow-green-500/50")}),n&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"absolute w-2 h-2 rounded-full bg-green-500 opacity-75",style:{animation:"calm-ping 3s cubic-bezier(0, 0, 0.2, 1) infinite"}}),jsxRuntime.jsx("div",{className:"absolute w-2 h-2 rounded-full bg-green-500 opacity-50",style:{animation:"calm-ping 3s cubic-bezier(0, 0, 0.2, 1) infinite 1s"}})]})]}),jsxRuntime.jsx("span",{className:"text-xs font-medium",children:c})]})}),jsxRuntime.jsx(fo,{side:"bottom",className:"max-w-xs",children:jsxRuntime.jsx("p",{className:"text-sm",children:u})})]})})}if(typeof document<"u"){let e=document.createElement("style");e.textContent=`
11
+ `);await navigator.clipboard.writeText(P),sonner.toast.success("Logs copied to clipboard");}catch{sonner.toast.error("Failed to copy logs");}},gr=P=>{try{let K=new Date(P);return dateFns.format(K,"yyyy-MM-dd HH:mm:ss.SSS")}catch{return P}},vt=P=>P<1024?`${P} B`:P<1024*1024?`${(P/1024).toFixed(1)} KB`:`${(P/(1024*1024)).toFixed(1)} MB`,mr=P=>P?P.replace(/\x1b\[[0-9;]*m/g,"").replace(/\u001b\[[0-9;]*m/g,"").replace(/\x1b\[[0-9;]*m/g,"").replace(/\[[0-9;]+m/g,"").replace(/\[[\d;]*m/g,""):"",Kt=P=>jsxRuntime.jsxs("div",{className:"px-3 py-2 font-mono text-xs border-b border-gray-100 dark:border-gray-800 text-gray-800 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-900",children:[jsxRuntime.jsxs("div",{className:"flex items-start gap-2",children:[jsxRuntime.jsx("span",{className:"text-gray-500 dark:text-gray-400 whitespace-nowrap",children:gr(P.timestamp)}),jsxRuntime.jsx("span",{className:"flex-shrink-0",children:jsxRuntime.jsx(q,{level:P.level})}),(P.category||P.source)&&jsxRuntime.jsxs("span",{className:"text-gray-600 dark:text-gray-400 whitespace-nowrap",children:["[",P.category||P.source,"]"]}),jsxRuntime.jsx("span",{className:"whitespace-pre-wrap break-all",children:mr(P.message)})]}),P.metadata?.stack&&jsxRuntime.jsx("pre",{className:"ml-[180px] whitespace-pre overflow-x-auto text-[10px] leading-snug mt-1 text-gray-500 dark:text-gray-400",children:mr(P.metadata.stack)}),P.metadata&&!P.metadata.stack&&Object.keys(P.metadata).length>0&&jsxRuntime.jsx("div",{className:"ml-[180px] mt-1 text-gray-500 dark:text-gray-400",children:Object.entries(P.metadata).map(([K,fe])=>jsxRuntime.jsxs("span",{className:"mr-4",children:[jsxRuntime.jsxs("span",{className:"font-medium",children:[K,":"]})," ",typeof fe=="object"?JSON.stringify(fe):String(fe)]},K))})]},P.id),Rn=[...ne].sort((P,K)=>{let fe=P.filename||P.name||"",ke=K.filename||K.name||"",de=0;switch(to){case "filename":de=fe.localeCompare(ke);break;case "size":de=P.size-K.size;break;case "modified":de=new Date(P.modified).getTime()-new Date(K.modified).getTime();break}return ia==="asc"?de:-de}),$s=P=>{to===P?L(K=>K==="asc"?"desc":"asc"):(Gs(P),L("desc"));},qs=({field:P})=>to!==P?jsxRuntime.jsx(lucideReact.ArrowUpDown,{className:"h-3 w-3 ml-1 opacity-50"}):ia==="asc"?jsxRuntime.jsx(lucideReact.ArrowUp,{className:"h-3 w-3 ml-1"}):jsxRuntime.jsx(lucideReact.ArrowDown,{className:"h-3 w-3 ml-1"}),JO=async()=>{if(!(!Fe||!s)){try{await s(Fe),Q(P=>P.filter(K=>(K.filename||K.name)!==Fe)),sonner.toast.success("Archive deleted successfully");}catch{sonner.toast.error("Failed to delete archive");}Zr(null);}},e1=W?C:C.filter(P=>P.id!=="archives"),t1=M==="full"&&E;return jsxRuntime.jsxs("div",{className:N("flex flex-col h-full",B),children:[A&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4 shrink-0",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h1",{className:"text-3xl font-bold",children:"Logs"}),jsxRuntime.jsxs("div",{className:"text-muted-foreground flex items-center",children:["View system logs and diagnostic information \u2022 Current level:"," ",jsxRuntime.jsx(it,{className:N("ml-1 text-xs px-2 py-0",S[D]||S.info),children:D.toUpperCase()})]})]}),T==="current"&&jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[c>0&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(zt,{id:"auto-refresh",checked:oe,onCheckedChange:I}),jsxRuntime.jsx(gt,{htmlFor:"auto-refresh",className:"text-sm cursor-pointer",children:"Auto-refresh"})]}),p&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(zt,{id:"auto-scroll",checked:Z,onCheckedChange:ue}),jsxRuntime.jsx(gt,{htmlFor:"auto-scroll",className:"text-sm cursor-pointer",children:"Auto-scroll"})]}),jsxRuntime.jsx("div",{className:"h-6 w-px bg-border"}),r&&jsxRuntime.jsxs(j,{variant:"outline",size:"sm",onClick:()=>r().then(P=>P&&F(le(ye(P)))),children:[jsxRuntime.jsx(lucideReact.RefreshCw,{className:"h-4 w-4 mr-2"}),"Refresh"]}),R&&jsxRuntime.jsxs(j,{variant:"outline",size:"sm",onClick:_r,children:[jsxRuntime.jsx(lucideReact.Copy,{className:"h-4 w-4 mr-2"}),"Copy"]}),k&&jsxRuntime.jsxs(j,{variant:"outline",size:"sm",onClick:Ut,children:[jsxRuntime.jsx(lucideReact.Download,{className:"h-4 w-4 mr-2"}),"Export"]}),o&&x&&jsxRuntime.jsxs(j,{variant:"destructive",size:"sm",onClick:()=>or(true),children:[jsxRuntime.jsx(lucideReact.Trash2,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]}),!A&&T==="current"&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4 shrink-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[c>0&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(zt,{id:"auto-refresh-embedded",checked:oe,onCheckedChange:I}),jsxRuntime.jsx(gt,{htmlFor:"auto-refresh-embedded",className:"text-sm cursor-pointer",children:"Auto-refresh"})]}),p&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(zt,{id:"auto-scroll-embedded",checked:Z,onCheckedChange:ue}),jsxRuntime.jsx(gt,{htmlFor:"auto-scroll-embedded",className:"text-sm cursor-pointer",children:"Auto-scroll"})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[r&&jsxRuntime.jsxs(j,{variant:"outline",size:"sm",onClick:()=>r().then(P=>P&&F(le(ye(P)))),children:[jsxRuntime.jsx(lucideReact.RefreshCw,{className:"h-4 w-4 mr-2"}),"Refresh"]}),R&&jsxRuntime.jsxs(j,{variant:"outline",size:"sm",onClick:_r,children:[jsxRuntime.jsx(lucideReact.Copy,{className:"h-4 w-4 mr-2"}),"Copy"]}),k&&jsxRuntime.jsxs(j,{variant:"outline",size:"sm",onClick:Ut,children:[jsxRuntime.jsx(lucideReact.Download,{className:"h-4 w-4 mr-2"}),"Export"]}),o&&x&&jsxRuntime.jsxs(j,{variant:"destructive",size:"sm",onClick:()=>or(true),children:[jsxRuntime.jsx(lucideReact.Trash2,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 flex-1 min-h-0",children:[t1&&jsxRuntime.jsx(Ne,{className:"w-64 h-fit",children:jsxRuntime.jsxs("div",{className:"p-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold mb-4",children:"Categories"}),jsxRuntime.jsx("div",{className:"space-y-1",children:e1.map(P=>{let K=P.icon;return jsxRuntime.jsxs("button",{onClick:()=>we(P.id),className:N("w-full flex items-center gap-3 px-3 py-2 rounded-md text-sm transition-colors",T===P.id?"bg-primary text-primary-foreground":"hover:bg-muted"),children:[jsxRuntime.jsx(K,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{className:"text-left",children:P.label})]},P.id)})})]})}),jsxRuntime.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:T==="archives"?jsxRuntime.jsxs(Ne,{className:"p-0 overflow-hidden flex-1 flex flex-col min-h-0",children:[M==="full"&&jsxRuntime.jsxs("div",{className:"px-6 py-4 border-b shrink-0",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold",children:"Log Archives"}),jsxRuntime.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["Download or manage archived log files \u2022 ",Rn.length," file",Rn.length!==1?"s":""]})]}),M!=="full"&&jsxRuntime.jsxs("div",{className:"px-4 py-2 border-b shrink-0 text-sm text-muted-foreground",children:[Rn.length," archive",Rn.length!==1?"s":""," available"]}),Rn.length===0?jsxRuntime.jsx("div",{className:"p-6",children:jsxRuntime.jsxs(ct,{children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4"}),jsxRuntime.jsx(ut,{children:"No archived log files available"})]})}):jsxRuntime.jsx("div",{className:"overflow-auto",style:{maxHeight:_},children:jsxRuntime.jsxs("table",{className:"w-full",children:[jsxRuntime.jsx("thead",{className:"bg-background sticky top-0 z-10 border-b",children:jsxRuntime.jsxs("tr",{children:[jsxRuntime.jsx("th",{className:"text-left px-4 py-2 font-medium text-sm",children:jsxRuntime.jsxs("button",{className:"flex items-center hover:text-foreground",onClick:()=>$s("filename"),children:["Name",jsxRuntime.jsx(qs,{field:"filename"})]})}),jsxRuntime.jsx("th",{className:"text-right px-4 py-2 font-medium text-sm w-28",children:jsxRuntime.jsxs("button",{className:"flex items-center justify-end hover:text-foreground ml-auto",onClick:()=>$s("size"),children:["Size",jsxRuntime.jsx(qs,{field:"size"})]})}),jsxRuntime.jsx("th",{className:"text-right px-4 py-2 font-medium text-sm w-36",children:jsxRuntime.jsxs("button",{className:"flex items-center justify-end hover:text-foreground ml-auto",onClick:()=>$s("modified"),children:["Modified",jsxRuntime.jsx(qs,{field:"modified"})]})}),jsxRuntime.jsx("th",{className:"text-right px-4 py-2 font-medium text-sm w-24",children:"Actions"})]})}),jsxRuntime.jsx("tbody",{children:Rn.map(P=>{let K=P.filename||P.name||"unknown";return jsxRuntime.jsxs("tr",{className:"border-t hover:bg-muted/30",children:[jsxRuntime.jsx("td",{className:"px-4 py-2",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Archive,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),jsxRuntime.jsx("span",{className:"font-mono text-sm truncate",children:K})]})}),jsxRuntime.jsx("td",{className:"px-4 py-2 text-right text-sm text-muted-foreground font-mono",children:vt(P.size)}),jsxRuntime.jsx("td",{className:"px-4 py-2 text-right text-sm text-muted-foreground",children:dateFns.format(new Date(P.modified),"MMM d, yyyy HH:mm")}),jsxRuntime.jsx("td",{className:"px-4 py-2 text-right",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1",children:[i&&jsxRuntime.jsx(j,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>i(K),title:"Download",children:jsxRuntime.jsx(lucideReact.Download,{className:"h-4 w-4"})}),s&&jsxRuntime.jsx(j,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-destructive hover:text-destructive",onClick:()=>Zr(K),title:"Delete",children:jsxRuntime.jsx(lucideReact.Trash2,{className:"h-4 w-4"})})]})})]},K)})})]})})]}):jsxRuntime.jsxs(Ne,{className:"p-0 overflow-hidden",children:[jsxRuntime.jsx("div",{className:"px-4 py-3 border-b bg-gray-50 dark:bg-gray-900 flex items-center justify-between",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[h&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Level:"}),jsxRuntime.jsxs(Tt,{value:_e,onValueChange:Se,children:[jsxRuntime.jsx(ft,{className:"w-36 h-8",children:jsxRuntime.jsx(At,{children:_e==="all"?jsxRuntime.jsx("span",{children:"All Levels"}):jsxRuntime.jsx(q,{level:_e})})}),jsxRuntime.jsxs(bt,{children:[jsxRuntime.jsx(Be,{value:"all",children:"All Levels"}),jsxRuntime.jsx(Be,{value:"error",children:jsxRuntime.jsx(q,{level:"error"})}),jsxRuntime.jsx(Be,{value:"warn",children:jsxRuntime.jsx(q,{level:"warn"})}),jsxRuntime.jsx(Be,{value:"info",children:jsxRuntime.jsx(q,{level:"info"})}),jsxRuntime.jsx(Be,{value:"debug",children:jsxRuntime.jsx(q,{level:"debug"})}),jsxRuntime.jsx(Be,{value:"verbose",children:jsxRuntime.jsx(q,{level:"verbose"})})]})]})]}),h&&lt.length>0&&jsxRuntime.jsxs(Tt,{value:et,onValueChange:Ue,children:[jsxRuntime.jsx(ft,{className:"w-44 h-8",children:jsxRuntime.jsx(At,{})}),jsxRuntime.jsxs(bt,{children:[jsxRuntime.jsx(Be,{value:"all",children:"All Categories"}),lt.map(P=>jsxRuntime.jsx(Be,{value:P,children:P},P))]})]}),b&&jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(lucideReact.Search,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),jsxRuntime.jsx("input",{type:"text",placeholder:"Search logs...",value:Ee,onChange:P=>$e(P.target.value),className:"pl-8 pr-3 py-1.5 text-sm border rounded-md w-64 focus:outline-none focus:ring-2 focus:ring-primary"})]})]})}),jsxRuntime.jsx("div",{className:N("bg-white dark:bg-gray-900"),style:{height:_},children:v?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full",children:jsxRuntime.jsx("div",{className:"h-8 w-8 rounded-full border-2 border-gray-300 border-t-transparent animate-spin"})}):$.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full text-gray-400",children:jsxRuntime.jsxs("div",{className:"text-center",children:[jsxRuntime.jsx(lucideReact.Terminal,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),jsxRuntime.jsx("p",{children:"No logs to display"}),jsxRuntime.jsx("p",{className:"text-xs mt-1",children:"Logs will appear here as they are generated"})]})}):jsxRuntime.jsx(reactVirtuoso.Virtuoso,{ref:Oe,data:$,followOutput:Z?"smooth":false,overscan:200,itemContent:(P,K)=>Kt(K),style:{height:"100%"}})}),jsxRuntime.jsx("div",{className:"border-t bg-muted/50 px-4 py-2 flex justify-between items-center",children:jsxRuntime.jsxs("div",{className:"text-sm text-muted-foreground",children:[$.length," ",$.length===1?"line":"lines"]})})]})})]}),jsxRuntime.jsx(ho,{open:at,onOpenChange:or,title:"Delete Logs",description:"Are you sure you want to delete all logs? This action cannot be undone.",confirmLabel:"Delete",variant:"destructive",onConfirm:pr}),jsxRuntime.jsx(ho,{open:!!Fe,onOpenChange:P=>!P&&Zr(null),title:"Delete Archive",description:`Are you sure you want to delete "${Fe}"? This action cannot be undone.`,confirmLabel:"Delete",variant:"destructive",onConfirm:JO})]})}var an=class extends Error{constructor(t,r,n){super(t),this.name="ApiError",this.status=r,this.details=n;}};function EL(){return undefined?.VITE_API_URL?undefined.VITE_API_URL:""}async function ha(e,t={}){let{timeout:r=3e4,retries:n=0,retryDelay:o=1e3,...a}=t,s=`${EL()}${e}`,l=new Headers(a.headers);!l.has("Content-Type")&&a.body&&typeof a.body=="string"&&l.set("Content-Type","application/json");let c=new AbortController,u=setTimeout(()=>c.abort(),r),d=null;for(let g=0;g<=n;g++)try{let p=await fetch(s,{...a,headers:l,signal:c.signal});clearTimeout(u);let m=p.headers.get("content-type"),f;if(m?.includes("application/json")?f=await p.json():f=await p.text(),typeof f=="object"&&"success"in f){let b=f;if(!b.success)throw new an(b.error||b.message||"Request failed",p.status,b.details);return b.data??b.logs??b.files??b.entries??b.items??b}if(!p.ok)throw new an(f.message||f.error||`HTTP ${p.status}`,p.status);return f}catch(p){if(d=p,p instanceof an&&p.status<500)throw p;if(p instanceof Error&&p.name==="AbortError")throw new an("Request timeout",408);g<n&&await new Promise(m=>setTimeout(m,o*(g+1)));}throw clearTimeout(u),d||new an("Request failed",500)}function TL({apiUrl:e="/api/logs"}){let t=Ce.useCallback(async()=>{try{let a=await ha(`${e}/entries`);return a?.entries||a?.logs||[]}catch(a){return console.warn("Failed to fetch logs:",a),[]}},[e]),r=Ce.useCallback(async()=>{try{let a=await ha(`${e}/files`);return (a?.files||a?.archives||[]).map(i=>({filename:i.filename||i.name,name:i.name,size:i.size,modified:i.modified}))}catch(a){return console.warn("Failed to fetch archives:",a),[]}},[e]),n=Ce.useCallback(async()=>{await ha(`${e}/clear`,{method:"POST"});},[e]),o=Ce.useCallback(a=>{window.open(`${e}/download/${a}`,"_blank");},[e]);return jsxRuntime.jsx(on,{onFetchLogs:t,onFetchArchives:r,onClearLogs:n,onDownloadArchive:o,enableSearch:true,enableFilter:true,enableExport:true,enableClear:true,enableAutoScroll:true,showCategories:true,showArchives:true,height:"calc(100vh - 200px)"})}function he(...e){return tailwindMerge.twMerge(clsx.clsx(e))}function gl({show:e,onRestart:t,onDismiss:r,className:n}){let[o,a]=Ce.useState(e),[i,s]=Ce.useState(false);return Ce.useEffect(()=>{e?(a(true),setTimeout(()=>s(true),10)):(s(false),setTimeout(()=>a(false),300));},[e]),o?jsxRuntime.jsx("div",{className:he("fixed top-0 left-0 right-0 z-50 transition-all duration-300 ease-in-out",i?"translate-y-0 opacity-100":"-translate-y-full opacity-0",n),children:jsxRuntime.jsxs(ct,{className:"rounded-none border-x-0 border-t-0 bg-amber-50 dark:bg-amber-950/50",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4 text-amber-600 dark:text-amber-400"}),jsxRuntime.jsxs(ut,{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-amber-800 dark:text-amber-200",children:"Configuration changes require a restart to take effect"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[t&&jsxRuntime.jsxs(j,{size:"sm",variant:"default",onClick:t,className:"bg-amber-600 hover:bg-amber-700 text-white",children:[jsxRuntime.jsx(lucideReact.RefreshCw,{className:"h-3 w-3 mr-1"}),"Restart Now"]}),r&&jsxRuntime.jsx(j,{size:"sm",variant:"ghost",onClick:r,className:"text-amber-700 hover:text-amber-800 dark:text-amber-300 dark:hover:text-amber-200",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3 w-3"})})]})]})]})}):null}function BL({categories:e,values:t,loading:r=false,saving:n=false,onSave:o,onReset:a,onRestart:i,showRestartBanner:s=false,className:l,title:c="Settings"}){let[u,d]=Ce.useState(t),[g,p]=Ce.useState({}),[m,f]=Ce.useState(e[0]?.id||""),[b,h]=Ce.useState({}),[k,x]=Ce.useState(false),R=(A,E)=>{d(_=>({..._,[A]:E})),x(true);let W=e.flatMap(_=>_.settings).find(_=>_.key===A);if(W?.validation){let _=W.validation(E);p(B=>({...B,[A]:_||""}));}},C=async()=>{let A={},E=false;if(e.forEach(W=>{W.settings.forEach(_=>{if(_.validation){let B=_.validation(u[_.key]);B&&(A[_.key]=B,E=true);}});}),E){p(A);return}await o(u),x(false);},S=()=>{d(t),p({}),x(false),a&&a();},D=e.find(A=>A.id===m)?.settings||[],M=A=>{let E=u[A.key]??A.defaultValue,W=g[A.key];switch(A.type){case "text":return jsxRuntime.jsx(Et,{value:E||"",onChange:_=>R(A.key,_.target.value),placeholder:A.placeholder,className:W?"border-red-500":""});case "password":return jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(Et,{type:b[A.key]?"text":"password",value:E||"",onChange:_=>R(A.key,_.target.value),placeholder:A.placeholder,className:he("pr-10",W?"border-red-500":"")}),jsxRuntime.jsx("button",{type:"button",onClick:()=>h(_=>({..._,[A.key]:!_[A.key]})),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700",children:b[A.key]?jsxRuntime.jsx(lucideReact.EyeOff,{className:"h-4 w-4"}):jsxRuntime.jsx(lucideReact.Eye,{className:"h-4 w-4"})})]});case "number":return jsxRuntime.jsx(Et,{type:"number",value:E||"",onChange:_=>R(A.key,parseFloat(_.target.value)),min:A.min,max:A.max,placeholder:A.placeholder,className:W?"border-red-500":""});case "boolean":return jsxRuntime.jsx(zt,{checked:E||false,onCheckedChange:_=>R(A.key,_)});case "select":return jsxRuntime.jsxs(Tt,{value:String(E||""),onValueChange:_=>R(A.key,_),children:[jsxRuntime.jsx(ft,{className:W?"border-red-500":"",children:jsxRuntime.jsx(At,{placeholder:"Select an option"})}),jsxRuntime.jsx(bt,{children:A.options?.map(_=>jsxRuntime.jsx(Be,{value:_.value,children:_.label},_.value))})]});case "custom":return A.customComponent;default:return null}};return r?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8",children:jsxRuntime.jsxs("div",{className:"text-center",children:[jsxRuntime.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading settings..."})]})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[s&&jsxRuntime.jsx(gl,{show:true,onRestart:i,onDismiss:()=>{}}),jsxRuntime.jsxs("div",{className:he("space-y-6",l),children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center",children:[jsxRuntime.jsx("h1",{className:"text-2xl font-bold",children:c}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs(j,{variant:"outline",size:"sm",onClick:S,disabled:!k||n,children:[jsxRuntime.jsx(lucideReact.RotateCcw,{className:"h-4 w-4"}),"Reset"]}),jsxRuntime.jsx(j,{size:"sm",onClick:C,disabled:!k||n||Object.keys(g).some(A=>g[A]),children:n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"Saving..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Save,{className:"h-4 w-4"}),"Save Changes"]})})]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-12 gap-6",children:[jsxRuntime.jsx("div",{className:"col-span-3",children:jsxRuntime.jsx(Ne,{className:"p-2",children:e.map(A=>jsxRuntime.jsxs("button",{onClick:()=>f(A.id),className:he("w-full text-left px-3 py-2 rounded-md transition-colors flex items-center gap-2",m===A.id?"bg-primary text-primary-foreground":"hover:bg-gray-100 dark:hover:bg-gray-800"),children:[A.icon,jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"font-medium",children:A.label}),A.description&&jsxRuntime.jsx("div",{className:"text-xs opacity-70",children:A.description})]})]},A.id))})}),jsxRuntime.jsx("div",{className:"col-span-9",children:jsxRuntime.jsx(Ne,{className:"p-6",children:jsxRuntime.jsx("div",{className:"space-y-6",children:D.map(A=>jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-between",children:jsxRuntime.jsxs(gt,{htmlFor:A.key,children:[A.label,A.requiresRestart&&jsxRuntime.jsx("span",{className:"ml-2 text-xs text-amber-600",children:"(Requires restart)"})]})}),A.description&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:A.description}),M(A),g[A.key]&&jsxRuntime.jsxs(ct,{variant:"destructive",className:"py-2",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4"}),jsxRuntime.jsx(ut,{children:g[A.key]})]})]},A.key))})})})]})]})]})}function Ln({url:e,className:t,checkInterval:r=5e3}){let[n,o]=Ce.useState(false),[a,i]=Ce.useState(true),s=Ce.useRef(false);Ce.useEffect(()=>{if(s.current)return;s.current=true;let d=true,g=e||"",p=async()=>{if(d)try{let f=await fetch(`${g}/api/health`,{credentials:"include"});d&&(o(f.ok),i(!1));}catch{d&&(o(false),i(false));}};p();let m=setInterval(p,r);return ()=>{d=false,clearInterval(m),s.current=false;}},[]);let l=a?"bg-gray-400":n?"bg-green-500":"bg-red-500",c=a?"Checking...":n?"Connected":"Disconnected",u=a?"Checking connection to backend API...":n?"Frontend is connected to the backend API via WebSockets. Real-time updates are enabled.":"Cannot connect to the backend API. Please check if the backend server is running.";return jsxRuntime.jsx(pa,{children:jsxRuntime.jsxs(ga,{children:[jsxRuntime.jsx(ma,{asChild:true,children:jsxRuntime.jsxs("button",{className:he("inline-flex items-center gap-2 px-3 py-1 rounded-full","bg-gray-800/50 backdrop-blur-sm","hover:bg-gray-800/70 transition-all duration-200","cursor-default select-none",t),type:"button","aria-label":`Connection status: ${c}`,children:[jsxRuntime.jsxs("div",{className:"relative flex items-center justify-center w-2 h-2",children:[jsxRuntime.jsx("div",{className:he("absolute w-2 h-2 rounded-full transition-all duration-300",l,n&&"shadow-lg shadow-green-500/50")}),n&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"absolute w-2 h-2 rounded-full bg-green-500 opacity-75",style:{animation:"calm-ping 3s cubic-bezier(0, 0, 0.2, 1) infinite"}}),jsxRuntime.jsx("div",{className:"absolute w-2 h-2 rounded-full bg-green-500 opacity-50",style:{animation:"calm-ping 3s cubic-bezier(0, 0, 0.2, 1) infinite 1s"}})]})]}),jsxRuntime.jsx("span",{className:"text-xs font-medium",children:c})]})}),jsxRuntime.jsx(fo,{side:"bottom",className:"max-w-xs",children:jsxRuntime.jsx("p",{className:"text-sm",children:u})})]})})}if(typeof document<"u"){let e=document.createElement("style");e.textContent=`
12
12
  @keyframes calm-ping {
13
13
  0% {
14
14
  transform: scale(1);