import{j as e,L as E,s as y}from"./vendor-tanstack-DE4ALVGD.js";import{q as D,I as o,y as R,H as C,B as T,g as w,h as x,bv as I,bE as L,bG as B,az as M,aA as S,aB as p,aC as h,bJ as O,C as z,o as V,dE as i}from"./index-CNL5pSma.js";import"./automation-schema-CEK5nVQx.js";import"./form-_6uPI_KA.js";import"./radio-group-GICFyAZR.js";import{f as k}from"./event-to-trigger-BEzU9b5I.js";import{D as A,a as F,b as J,d as j}from"./dropdown-menu-D34zumpn.js";import{f as P,J as _}from"./utilities-CAE5cWs6.js";import{E as G,p as H,a as Q,b as U,R as q}from"./event-resource-display-DhoQRh61.js";import{f as Y}from"./vendor-date-Bck8LDfw.js";import"./vendor-react-HBv6Kpyp.js";import"./vendor-radix-K8EF6rBE.js";import"./vendor-recharts-B3wzJa9e.js";import"./vendor-forms-BvpM0AtX.js";function Z({event:s}){const t=()=>{navigator.clipboard.writeText(s.id),R.success("ID copied")};return e.jsxs(A,{children:[e.jsx(F,{asChild:!0,children:e.jsxs(D,{variant:"outline",className:"size-8 p-0","aria-label":"Event actions",children:[e.jsx("span",{className:"sr-only",children:"Open menu"}),e.jsx(o,{id:"MoreVertical",className:"size-4"})]})}),e.jsxs(J,{align:"end",children:[e.jsx(E,{to:"/automations/create",search:{eventId:s.id,eventDate:k(s.occurred)},children:e.jsxs(j,{children:[e.jsx(o,{id:"Zap",className:"mr-2 size-4"}),"Automate"]})}),e.jsxs(j,{onClick:t,children:[e.jsx(o,{id:"Copy",className:"mr-2 size-4"}),"Copy ID"]})]})]})}const d=({children:s})=>e.jsx("dt",{className:"text-sm font-medium",children:s}),f=({children:s})=>e.jsx("dd",{className:"text-sm",children:s});function v(s){return s["prefect.resource.role"]||null}function g(s){return s["prefect.resource.id"]||""}function K(s){return s["prefect.resource.name"]||s["prefect.name"]||s["prefect-cloud.name"]||null}function W({event:s}){const t=Y(new Date(s.occurred),"yyyy/MM/dd hh:mm:ss a"),n=(s.related??[]).filter(a=>v(a)!=="tag"),c=(s.related??[]).filter(a=>v(a)==="tag");return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("dl",{children:[e.jsx(d,{children:"Event"}),e.jsx(f,{children:s.event})]}),e.jsxs("dl",{children:[e.jsx(d,{children:"Occurred"}),e.jsx(f,{children:t})]}),e.jsx(G,{event:s}),(n.length>0||c.length>0)&&e.jsxs("dl",{children:[e.jsx(d,{children:"Related Resources"}),e.jsxs("dd",{className:"flex flex-col gap-2 text-sm",children:[n.map(a=>{const r=g(a),l=K(a),u=H(r),b=q[u],m=U[u],N=l||r.split(".").pop()||r;return e.jsxs(Q,{resource:a,relatedResources:s.related??[],className:"flex items-center gap-2 hover:underline",children:[m&&e.jsx("span",{children:m}),e.jsx(o,{id:b,className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:N})]},r)}),c.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{children:"Tags"}),c.map(a=>{const r=g(a),l=r.split(".").pop()||r;return e.jsx(C,{variant:"secondary",children:l},r)})]})]})]})]})}function X({event:s}){const t=P(s.event);return e.jsx(T,{children:e.jsxs(w,{children:[e.jsx(x,{children:e.jsx(I,{to:"/events",className:"text-xl font-semibold",children:"Event Feed"})}),e.jsx(L,{}),e.jsx(x,{className:"text-xl font-semibold",children:e.jsx(B,{children:t})})]})})}function $({event:s,defaultTab:t="details",onTabChange:n}){return e.jsxs(M,{defaultValue:t,onValueChange:n,children:[e.jsxs(S,{children:[e.jsx(p,{value:"details",children:"Details"}),e.jsx(p,{value:"raw",children:"Raw"})]}),e.jsx(h,{value:"details",className:"pt-4",children:e.jsx(W,{event:s})}),e.jsx(h,{value:"raw",className:"pt-4",children:e.jsx(_,{value:JSON.stringify(s,null,2),className:"max-h-[600px] overflow-auto"})})]})}function ee({eventId:s,eventDate:t,defaultTab:n,onTabChange:c}){const{data:a}=y(O(s,t));return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(X,{event:a}),e.jsx(Z,{event:a})]}),e.jsx(z,{children:e.jsx(V,{children:e.jsx($,{event:a,defaultTab:n,onTabChange:c})})})]})}function se(s){const[t,n,c]=s.split("-").map(Number);return new Date(t,n-1,c)}function je(){const{eventDate:s,eventId:t}=i.useParams(),n=i.useSearch(),c=i.useNavigate(),a=se(s),r=l=>{c({to:".",search:{tab:l},replace:!0})};return e.jsx(ee,{eventId:t,eventDate:a,defaultTab:n.tab,onTabChange:r})}export{je as component};
//# sourceMappingURL=event._eventDate._eventId-DhpRyIC1.js.map
