import{aM as x,aJ as e,r as C}from"./@ui-core-DKdciH1Z.js";import{C as g}from"./CodeSnippet-Dwuwo3ZI.js";import{b as k,C as V}from"./CollapsibleCard-3zV5aMxC.js";import{af as z,e as c,bp as h,aa as v,C as w,o as $,q as P,v as D,aq as W,bq as L,ar as b,au as y,az as H,a6 as A,ah as U,K as Q,y as _}from"./index-D7KLAbvI.js";import{a as q}from"./@react-router-DaIuhn3X.js";import"./json-faker-CIjiJcy9.js";import{J as F}from"./@json-schema-faker-BNHnzDB2.js";import{N as M,a as N}from"./NestedCollapsible-k41ntPyA.js";import{K as S,a as R,V as X}from"./KeyValue-DF0Uxg2V.js";import{P as K}from"./pipeline-link-DyLNQTVa.js";import{u as Z,D as B}from"./docker-image-collapsible-B8AO0RTi.js";import{S as G}from"./stack-info-full-BRoYiry5.js";import{u as Y}from"./stack-detail-query-IhXZFDdF.js";import"./@reactflow-CJzATMj6.js";import"./@zod-DKyD3xVW.js";import"./@monaco-editor-CSMpaClf.js";import"./@elkjs-B9k7DY1N.js";import"./eye-off-T0xdenj_.js";import"./eye-0EFEzbgA.js";import"./Infobox-DUoxxn6u.js";import"./alert-triangle-DWngjzfY.js";import"./ComponentIcon-BOKrWHiD.js";import"./bar-chart-square-check-Lt3fLSJ-.js";import"./layout-BRN9AeDt.js";import"./transform-Bq7p9csj.js";import"./constants-Dj_C1ZPH.js";function u({Component:s}){const{deploymentId:t}=q(),n=x({...z.detail(t),throwOnError:!0});if(n.isPending)return e.jsx(c,{className:"h-[200px] w-full"});if(n.isError)return null;const r=n.data;return e.jsx(s,{deployment:r})}function T(s){return"*".repeat(Math.min(s.length,10))}function E(s,t){if(!t)return s;const n=T(t);return s.replace(n,t)}function ee(s,t,n){const r=[];n&&r.push(`-H "Authorization: Bearer ${T(n)}"`),r.push('-H "Content-Type: application/json"');const a=r.join(` \\
  `);if(t){const l=h(JSON.stringify(t,null,2).split(`
`).join(`
    `));return`curl -X POST ${s}/invoke \\
  ${a} \\
  -d '{
    "parameters": ${l}
  }'`}return`curl -X POST ${s}/invoke \\
  ${a}`}function te(s,t){if(!t||typeof t!="object"||Array.isArray(t))return`zenml deployment invoke ${h(s)}`;const n=Object.entries(t).map(([r,a])=>{const l=typeof a=="object"&&a!==null,o=JSON.stringify(a),i=l?`'${h(o)}'`:h(o);return`--${r}=${i}`}).join(" ");return`zenml deployment invoke ${h(s)} ${n}`}function se({deploymentId:s,defaultBody:t}){const n=`from zenml.deployers.utils import invoke_deployment

`;let r="";if(t&&typeof t=="object"&&!Array.isArray(t)){const a=Object.entries(t).map(([l,o])=>{const i=JSON.stringify(o);return i==="null"?`    ${l}=None`:`    ${l}=${i}`}).join(`,
`);a&&(r=`,
${a}`)}return`${n}response = invoke_deployment(
    deployment_name_or_id="${s}"${r}
)`}function ne(s,t,n){const r=[];n&&r.push(`    "Authorization": "Bearer ${T(n)}"`),r.push('    "Content-Type": "application/json"');const a=r.join(`,
`);if(t){const l=JSON.stringify(t,null,2).split(`
`).map((o,i)=>i===0?o:`    ${o}`).join(`
`);return`const response = await fetch("${s}/invoke", {
  method: "POST",
  headers: {
${a}
  },
  body: JSON.stringify({
    parameters: ${l}
  })
});`}return`const response = await fetch("${s}/invoke", {
  method: "POST",
  headers: {
${a}
  }
});`}function re(){return e.jsx(u,{Component:ae})}function ae({deployment:s}){const[t,n]=C.useState(!0),[r,a]=C.useState("cli"),l=s.resources?.snapshot?.id,o=x({...v.detail(l),enabled:!!l});if(!l)return null;if(o.isPending)return e.jsx(c,{className:"h-[200px] w-full"});if(o.isError)return null;const d=o.data.metadata?.pipeline_spec?.input_schema,f=d?F.generate(d):{},p=s.body?.url,j=s.metadata?.auth_key??void 0;return e.jsxs(w,{open:t,onOpenChange:n,children:[e.jsx($,{className:"flex h-9 items-center gap-[10px]",children:e.jsxs(P,{className:"flex w-full gap-2",children:[e.jsx(k,{open:t}),"Invocation"]})}),e.jsx(D,{className:"space-y-5 border-t border-theme-border-moderate bg-theme-surface-primary px-5 py-3",children:e.jsxs(W,{value:r,onValueChange:a,children:[e.jsxs(L,{children:[e.jsx(b,{className:"flex items-center gap-2 truncate text-text-md",value:"cli",children:e.jsx("span",{children:"CLI"})}),e.jsx(b,{className:"flex items-center gap-2 truncate text-text-md",value:"python",children:e.jsx("span",{children:"Python"})}),!!p&&e.jsx(b,{className:"flex items-center gap-2 truncate text-text-md",value:"curl",children:e.jsx("span",{children:"cURL"})}),!!p&&e.jsx(b,{className:"flex items-center gap-2 truncate text-text-md",value:"ts",children:e.jsx("span",{children:"Typescript"})})]}),e.jsx(y,{className:"m-0 mt-5 border-0 bg-transparent p-0",value:"cli",children:e.jsx(g,{fullWidth:!0,highlightCode:!0,language:"bash",wrap:!0,code:te(s.name,f)})}),e.jsx(y,{className:"m-0 mt-5 border-0 bg-transparent p-0",value:"python",children:e.jsx(g,{fullWidth:!0,highlightCode:!0,language:"python",wrap:!0,code:se({deploymentId:s.id,defaultBody:f})})}),!!p&&e.jsx(y,{className:"m-0 mt-5 border-0 bg-transparent p-0",value:"curl",children:(()=>{const m=ee(p,f,j);return e.jsx(g,{fullWidth:!0,highlightCode:!0,wrap:!0,language:"bash",copyCode:E(m,j),code:m})})()}),!!p&&e.jsx(y,{className:"m-0 mt-5 border-0 bg-transparent p-0",value:"ts",children:(()=>{const m=ne(p,f,j);return e.jsx(g,{fullWidth:!0,wrap:!0,highlightCode:!0,language:"ts",copyCode:E(m,j),code:m})})()})]})})]})}function oe(){return e.jsx(u,{Component:le})}function le({deployment:s}){const t=s.resources?.deployer?.id,n=x({...H.componentDetail(t),enabled:!!t});if(!t)return null;if(n.isPending)return e.jsx(c,{className:"h-[200px] w-full"});if(n.isError)return null;const r=n.data;return e.jsx(M,{isInitialOpen:!0,title:"Deployer Configuration",data:r.metadata?.configuration})}function ie(){return e.jsx(u,{Component:ce})}function ce({deployment:s}){const[t,n]=C.useState(!0),r=s.id,a=s.resources?.snapshot,l=a?.id,o=a?.name,i=s.resources?.pipeline?.id,d=s.resources?.pipeline?.name;return e.jsxs(w,{open:t,onOpenChange:n,children:[e.jsx($,{className:"flex h-9 items-center gap-[10px]",children:e.jsxs(P,{className:"flex w-full gap-2",children:[e.jsx(k,{open:t}),"Details"]})}),e.jsx(D,{className:"border-t border-theme-border-moderate bg-theme-surface-primary px-5 py-3",children:e.jsxs("dl",{className:"grid grid-cols-1 gap-x-[10px] gap-y-2 md:grid-cols-3 md:gap-y-4",children:[e.jsx(S,{label:"Id",value:e.jsxs("div",{className:"group/copybutton flex items-center gap-0.5",children:[r,e.jsx(A,{copyText:r})]})}),e.jsx(S,{label:"Snapshot",value:l&&o?e.jsx(U,{snapshotId:l,snapshotName:o}):e.jsx(N,{})}),e.jsx(R,{className:"h-auto",children:"Pipeline"}),e.jsx(X,{className:"h-auto",children:i&&d?e.jsx(K,{pipelineId:i,pipelineName:d}):e.jsx(N,{})})]})})]})}function I({title:s,subtitle:t}){return e.jsx(Q,{className:"p-5",icon:e.jsx(_,{className:"h-[60px] w-[60px] fill-neutral-300"}),children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-text-lg font-semibold",children:s}),t&&e.jsx("p",{className:"text-text-md text-theme-text-secondary",children:t})]})})}function pe(){return e.jsx(u,{Component:ue})}function ue({deployment:s}){const t=s.resources?.snapshot?.id,n=x(v.detail(t)),r=n.data?.resources?.build?.id,a=Z({buildId:r},{enabled:!!r});if(!t)return null;if(n.isPending)return e.jsx(c,{className:"h-[200px] w-full"});if(n.isError)return e.jsx("div",{children:e.jsx(I,{title:"Unable to get the docker build",subtitle:"Something went wrong fetching the snapshot"})});if(!r)return null;if(a.isPending)return e.jsx(c,{className:"h-[200px] w-full"});if(a.isError)return e.jsx("div",{children:e.jsx(I,{title:"Unable to get the docker build",subtitle:"Something went wrong fetching the build"})});const o=a.data.metadata?.images?.deployer;return o?e.jsx(B,{displayCopyButton:!1,data:o}):null}function de(){return e.jsx(u,{Component:me})}function me({deployment:s}){const[t,n]=C.useState(!0),r=s.body?.url;return e.jsxs(w,{open:t,onOpenChange:n,children:[e.jsx($,{className:"flex h-9 items-center gap-[10px]",children:e.jsxs(P,{className:"flex w-full gap-2",children:[e.jsx(k,{open:t}),"Endpoint"]})}),e.jsx(D,{className:"border-t border-theme-border-moderate bg-theme-surface-primary px-5 py-3",children:e.jsx("dl",{className:"grid grid-cols-1 gap-x-[10px] gap-y-2 md:grid-cols-3 md:gap-y-4",children:e.jsx(S,{label:"Endpoint",value:r?e.jsxs("div",{className:"group/copybutton flex items-center gap-0.5",children:[e.jsx("a",{className:"link truncate",href:r,target:"_blank",rel:"noopener noreferrer",children:r}),e.jsx(A,{copyText:r})]}):e.jsx(N,{})})})})]})}function he(){return e.jsx(u,{Component:xe})}function xe({deployment:s}){const t=s.resources?.snapshot;return t?e.jsx(fe,{snapshotId:t.id}):e.jsx(J,{})}function fe({snapshotId:s}){const t=x({...v.detail(s)});if(t.isPending)return e.jsx(c,{className:"h-[200px] w-full"});if(t.isError)return e.jsx(O,{title:"Unable to get Stack",subtitle:"Something went wrong fetching the deployment snapshot"});const n=t.data?.resources?.stack?.id;return n?e.jsx(je,{snapshot:t.data,stackId:n}):e.jsx(J,{})}function je({snapshot:s,stackId:t}){const n=Y({stackId:t});if(n.isPending)return e.jsx(c,{className:"h-[200px] w-full"});if(n.isError)return e.jsx(O,{title:"Failed to fetch the stack",subtitle:"Something went wrong fetching the stack"});const r=n.data,a=s.metadata?.pipeline_configuration.settings||{};return e.jsx(G,{stack:r,objectConfig:a})}function O({title:s,subtitle:t}){return e.jsx(V,{title:"Stack",initialOpen:!0,children:e.jsx(Q,{className:"p-5",icon:e.jsx(_,{className:"h-[60px] w-[60px] fill-neutral-300"}),children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-text-lg font-semibold",children:s}),t&&e.jsx("p",{className:"text-text-md text-theme-text-secondary",children:t})]})})})}function J(){return e.jsx(O,{title:"No Stack",subtitle:"There is no stack associated with this deployment."})}function qe(){return e.jsxs("div",{className:"grid grid-cols-1 gap-5 p-5 lg:grid-cols-2 lg:px-[80px]",children:[e.jsxs("div",{className:"space-y-5",children:[e.jsx(de,{}),e.jsx(re,{}),e.jsx(ie,{}),e.jsx(oe,{})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsx(he,{}),e.jsx(pe,{})]})]})}export{qe as default};
