import{j as e}from"./@radix-DAoBbclx.js";import{a as u,u as y,S as g,E as D}from"./SecretTooltip-B287TtRW.js";import{b as x,h as v}from"./@tanstack-2852wz5w.js";import{J as S,bs as b,bX as N,N as k,O as w,B as h,Q as C,R as E,U as T,e as K,I as B,bk as V,bl as O,a4 as Q,a5 as A,bY as q,r as z,k as F,a1 as L}from"./index-DnCFURX3.js";import{a as o}from"./@monaco-editor-Di1Jq_O0.js";import{S as M}from"./eye-C2BdTq-f.js";import{S as P}from"./key-icon-EM2iqIYg.js";import{S as _}from"./trash-DsZfFPdX.js";import{D as R,a as U}from"./DeleteAlertDialog-B-lA-7-t.js";import{a as $}from"./@react-router-BTai9D5g.js";import"./@elkjs-CmhuJAjY.js";import"./plus-E8wmxLMS.js";import"./@zod-3snSrKBm.js";import"./CodeSnippet-j6SUjNoa.js";import"./@reactflow-CLotj7HR.js";function H({secretId:s,keyName:t,open:r,setOpen:a}){const{data:l,isLoading:d,isError:c}=x({...u.secretDetail(s)}),i=v(),{mutate:m}=y({onError(n){b(n)&&N({status:"error",emphasis:"subtle",description:n.message,rounded:!0})},onSuccess(){i.invalidateQueries({queryKey:["secrets"]}),i.invalidateQueries({queryKey:["secretDetail",s]})}}),f=()=>{var n;if(l){const p={...(n=l.body)==null?void 0:n.values};delete p[t];const j={name:l.name,values:p};m({id:s,body:j})}};return d?e.jsx("div",{children:"Loading..."}):c?e.jsx("div",{children:"Error loading secret details"}):e.jsx(S,{open:r,onOpenChange:a,children:e.jsx(R,{title:"Delete Key",handleDelete:f,children:e.jsxs(U,{children:[e.jsx("p",{children:"Are you sure?"}),e.jsx("p",{children:"This action cannot be undone."})]})})})}function I({secretId:s,keyName:t}){const[r,a]=o.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(H,{secretId:s,keyName:t,open:r,setOpen:a}),e.jsxs(k,{children:[e.jsx(w,{asChild:!0,children:e.jsx(h,{intent:"secondary",emphasis:"minimal",className:"flex aspect-square items-center justify-center p-0",children:e.jsx(C,{className:"h-4 w-4 shrink-0 fill-theme-text-tertiary"})})}),e.jsx(E,{align:"end",sideOffset:7,children:e.jsxs(T,{onSelect:()=>a(!0),className:"cursor-pointer space-x-2",children:[e.jsx(_,{className:"h-3 w-3 fill-neutral-400"}),e.jsx("p",{children:"Delete"})]})})]})]})}const J=({value:s})=>{const[t,r]=o.useState(!1),a=typeof s=="string"?s:"",l="•".repeat(a.length);return e.jsxs("div",{className:"flex items-center gap-2 space-x-2",children:[e.jsx(M,{onClick:()=>r(!t),className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{children:t?a:l})]})};function X(s,t){return[{id:"key",header:"Key",accessorKey:"key",cell:({row:r})=>{const a=`from zenml.client import Client
secret = Client().get_secret("${t}")

# 'secret.secret_values' will contain a dictionary with all key-value pairs within your secret.
secret.secret_values["${r.original.key}"]
	  `;return e.jsxs("div",{className:"flex min-w-[10rem] items-center space-x-2",children:[e.jsx(P,{className:"h-5 w-5 shrink-0 fill-primary-400"}),e.jsx("div",{className:"flex flex-col",children:e.jsx("div",{className:"flex items-center space-x-1",children:e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx("div",{className:"grid grid-cols-1",children:e.jsx("span",{className:"truncate text-text-md font-semibold text-theme-text-primary",children:r.original.key})}),e.jsx(g,{code:a})]})})})]})}},{id:"value",header:"Value",accessorKey:"value",cell:({row:r})=>e.jsx(J,{value:r.getValue("value")})},{id:"actions",header:"",cell:({row:r})=>e.jsx(I,{secretId:s,keyName:r.original.key})}]}function Y({secretId:s}){var c;const[t,r]=o.useState(""),a=x({...u.secretDetail(s)});if(a.isPending)return e.jsx(K,{className:"h-[200px] w-full"});if(a.isError)return e.jsx("div",{children:a.error.message});const d=Object.entries(((c=a.data.body)==null?void 0:c.values)||{}).map(([i,m])=>({key:i,value:m})).filter(i=>i.key.toLowerCase().includes(t.toLowerCase()));return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-2",children:[e.jsx(B,{type:"text",placeholder:"Search Keys...",value:t,onChange:i=>r(i.target.value),inputSize:"md"}),e.jsxs(V,{children:[e.jsx(O,{asChild:!0,children:e.jsx(h,{size:"sm",intent:"primary",children:"Edit Keys"})}),e.jsx(D,{secretId:s,isSecretNameEditable:!1,dialogTitle:"Edit keys"})]})]}),e.jsx("div",{className:"w-full",children:e.jsx(Q,{columns:X(s,a.data.name),data:d})})]})}function G(s){const{setBreadcrumbs:t}=A();o.useEffect(()=>{s&&t([...q,{label:s.name,href:z.settings.secrets.detail(s.id)}])},[s,t])}function xe(){const{secretId:s}=$(),{data:t}=x({...u.secretDetail(s||"")});return G(t),e.jsx(e.Fragment,{children:e.jsxs(F,{className:"space-y-5 p-5",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-text-xl font-semibold",children:t==null?void 0:t.name}),e.jsxs("div",{className:"group/copybutton flex items-center space-x-1",children:[e.jsx("div",{className:"text-theme-text-secondary",children:s==null?void 0:s.slice(0,8)}),e.jsx(L,{copyText:s})]})]}),e.jsx(Y,{secretId:s||""})]})})}export{xe as default};
