import{c as u,g as N,q as w,s as C,as as k,h as P,o as E,r as j,t as m,j as e,m as i,B as q,p as D,k as l,T as S,ab as A,x as $,F as L,E as y,A as R}from"./index-zgZmtGWP.js";import{R as Q,S as _}from"./switch-DMndCyaK.js";import{S as z}from"./ConfirmDialog-BXch8StB.js";import{C as v}from"./card-DPbDbxNS.js";/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const F=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],K=u("ChevronRight",F);/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const T=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],b=u("CircleAlert",T);/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const B=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]],O=u("CircleArrowRight",B);/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const M=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],U=u("Clock",M);function ee(s){return N({queryKey:w.projects.detail(s),queryFn:()=>C.projects.getById(s),enabled:!!s})}function se(s){const t=k(),a=P(),{updateProject:n,deleteProject:r}=E(),[x,o]=j.useState(!1),[h,c]=j.useState(!1),[g,p]=j.useState(!1);return{editModalOpen:x,setEditModalOpen:o,deleteDialogOpen:h,setDeleteDialogOpen:c,autoRefresh:g,setAutoRefresh:p,handleRefresh:()=>{s&&(a.invalidateQueries({queryKey:["projects","getById",s]}),a.invalidateQueries({queryKey:["logs","metrics",s]}),a.invalidateQueries({queryKey:["logs","metadataKeys",s]}),a.invalidateQueries({queryKey:["projects","config",s]}))},handleDeleteProject:()=>{c(!0)},handleConfirmDelete:()=>{r.mutate(s,{onSuccess:()=>{m.success("Project deleted successfully"),t({to:"/projects"})},onError:d=>{m.error("Failed to delete project",{description:d instanceof Error?d.message:"Unknown error occurred"})}})},handleEditProject:()=>{o(!0)},handleEditSubmit:d=>{n.mutate({id:s,data:d},{onSuccess:()=>{o(!1),m.success("Project updated successfully")},onError:f=>{m.error("Failed to update project",{description:f instanceof Error?f.message:"Unknown error occurred"})}})},updateProject:n,deleteProject:r}}function re({project:s,isRefreshing:t,autoRefresh:a,onAutoRefreshChange:n,onEdit:r,onDelete:x,onClearLogs:o,onRefresh:h}){const c=new Date(s.createdAt),g=c.toLocaleDateString(),p=c.toLocaleTimeString();return e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-start gap-4 bg-white/60 backdrop-blur-sm border-gray-200/50 shadow-lg p-6 rounded-lg",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(i,{to:"/projects",className:"text-sm text-muted-foreground hover:text-foreground transition-colors flex items-center",children:[e.jsx(O,{className:"h-3.5 w-3.5 mr-1 rotate-180"}),"Projects"]}),e.jsx(K,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:s.name})]}),e.jsx("h1",{className:"text-3xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-foreground to-foreground/70",children:s.name}),s.description&&e.jsx("p",{className:"text-muted-foreground max-w-2xl",children:s.description}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-1",children:[e.jsx(q,{variant:"outline",className:"font-mono text-xs",children:s.id}),e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(D,{className:"h-3 w-3"}),g]}),e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(U,{className:"h-3 w-3"}),p]})]})]}),e.jsxs("div",{className:"flex space-x-2 mt-4 md:mt-0 items-center",children:[e.jsxs(l,{variant:"outline",size:"sm",onClick:r,className:"transition-all hover:border-primary/50 hover:bg-primary/5",children:[e.jsx(z,{className:"h-4 w-4 mr-2"}),"Edit"]}),o&&e.jsxs(l,{variant:"outline",size:"sm",onClick:o,className:"transition-all hover:border-orange-500/50 hover:bg-orange-50 text-orange-600 hover:text-orange-700",children:[e.jsx(S,{className:"h-4 w-4 mr-2"}),"Clear Logs"]}),e.jsxs(l,{variant:"destructive",size:"sm",onClick:x,className:"transition-all hover:bg-destructive/90",children:[e.jsx(A,{className:"h-4 w-4 mr-2"}),"Delete"]}),e.jsxs(l,{variant:"outline",size:"sm",onClick:h,disabled:t,className:"transition-all hover:border-primary/50 hover:bg-primary/5",children:[t?e.jsx("span",{className:"mr-2 border-2 border-primary/30 border-t-primary rounded-full w-4 h-4 animate-spin inline-block"}):e.jsx(Q,{className:"h-4 w-4 mr-2"}),"Refresh"]}),e.jsxs("div",{className:"flex items-center ml-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground mr-2",children:"Auto-refresh"}),e.jsx(_,{checked:a,onCheckedChange:n,disabled:t,id:"auto-refresh-toggle"})]})]})]})}function te(){return e.jsx("div",{className:"flex items-center justify-center h-[calc(100vh-10rem)]",children:e.jsx(v,{className:"w-full max-w-md p-6 shadow-lg",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-4",children:[e.jsx(b,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Project Not Found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Unable to load project details"})]}),e.jsx(l,{asChild:!0,children:e.jsx(i,{to:"/projects",children:"Go to Projects"})})]})})})}function ae(){return e.jsx("div",{className:"flex items-center justify-center h-[calc(100vh-10rem)]",children:e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[e.jsx("div",{className:"border-4 border-primary/30 border-t-primary rounded-full w-12 h-12 animate-spin"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading project details..."})]})})}function oe({projectId:s,project:t}){return e.jsx("div",{className:"flex items-center justify-center h-[calc(100vh-10rem)]",children:e.jsx(v,{className:"w-full max-w-md p-6 shadow-lg",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-4",children:[e.jsx(b,{className:"h-12 w-12 text-destructive"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Error Loading Project"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:t?"An error occurred while fetching project data":`Project not found (ID: ${s})`})]}),e.jsx(l,{asChild:!0,children:e.jsx(i,{to:"/projects",children:"Go to Projects"})})]})})})}function le({projectId:s,currentPage:t}){const a=$(),r=t||(a.pathname.includes("/logs")?"logs":a.pathname.includes("/traces")?"traces":"details");return e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 mb-8",children:[e.jsx(i,{to:"/projects/$projectId/logs",params:{projectId:s},className:`group bg-white/60 backdrop-blur-sm border border-gray-200/50 shadow-lg rounded-lg p-6 hover:shadow-xl transition-all duration-200 hover:bg-gradient-to-r hover:from-blue-50 hover:to-purple-50 ${r==="logs"?"ring-2 ring-blue-500 bg-blue-50/30":""}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-lg transition-colors ${r==="logs"?"bg-blue-200 group-hover:bg-blue-300":"bg-blue-100 group-hover:bg-blue-200"}`,children:e.jsx(L,{className:"h-6 w-6 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Project Logs"}),e.jsx("p",{className:"text-sm text-gray-600",children:r==="logs"?"Currently viewing logs - manage and filter entries":"View and manage application logs"})]})]}),e.jsx(y,{className:`h-5 w-5 transition-colors ${r==="logs"?"text-blue-600":"text-gray-400 group-hover:text-blue-600"}`})]})}),e.jsx(i,{to:"/projects/$projectId/traces",params:{projectId:s},className:`group bg-white/60 backdrop-blur-sm border border-gray-200/50 shadow-lg rounded-lg p-6 hover:shadow-xl transition-all duration-200 hover:bg-gradient-to-r hover:from-purple-50 hover:to-indigo-50 ${r==="traces"?"ring-2 ring-purple-500 bg-purple-50/30":""}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-lg transition-colors ${r==="traces"?"bg-purple-200 group-hover:bg-purple-300":"bg-purple-100 group-hover:bg-purple-200"}`,children:e.jsx(R,{className:"h-6 w-6 text-purple-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Project Traces"}),e.jsx("p",{className:"text-sm text-gray-600",children:r==="traces"?"Currently viewing traces - analyze distributed requests":"Analyze distributed tracing data"})]})]}),e.jsx(y,{className:`h-5 w-5 transition-colors ${r==="traces"?"text-purple-600":"text-gray-400 group-hover:text-purple-600"}`})]})})]})}export{b as C,te as P,le as Q,se as a,ae as b,oe as c,re as d,K as e,U as f,ee as u};
