import{o as s}from"./rolldown-runtime-iuO8RvI4.js";import{L_ as e,Ll as i,Su as n,Tu as a}from"./shared-0-C4kdVF7Y.js";import{Mi as l,ki as r}from"./vendor-frame-CwiylG4Y.js";import{Am as t,Pm as c}from"./shared-1-3-6x7RKF.js";import{rn as o}from"./vendor-all-2-BJdkbLSj.js";import{$ as d,K as x,R as m}from"./shared-frame-DbQbH4Yr.js";import{wa as u}from"./shared-4-6CEyRAHb.js";import{dl as j}from"./shared-5-UQAFGbWu.js";import{C as f,O as h,_ as p,t as g}from"./cb23947a7-CjmKL2mL.js";var y=s(l()),b=r();function v(){const{linkId:s}=n(),a=e(p),{isLoading:l,account:r}=i();if(l)return(0,b.jsx)(w,{});if(!r){const s=window.location.pathname+window.location.search;return window.location.replace(`/login?returnTo=${encodeURIComponent(s)}`),(0,b.jsx)(w,{})}return a?(0,b.jsx)(N,{linkId:s}):(0,b.jsx)(j,{})}function N({linkId:s}){const e=o(),i=a(),{data:n,isLoading:l}=f(s),r=n?.link,{mutateAsync:j,isPending:p}=h(),[v,N]=(0,y.useState)(null),k=(0,y.useCallback)(async e=>{const{display_name:i,host_constraint:n,spec:a}=e;await j({linkId:s,display_name:i,host_constraint:n,spec:a}),N(i)},[j,s]),V=(0,y.useMemo)(()=>({linkId:s,prefill:r?.prefill,isPending:p,onSubmit:k}),[s,r?.prefill,p,k]);if(null!==v)return(0,b.jsx)(w,{children:(0,b.jsxs)("div",{className:"flex max-w-md flex-col items-center gap-md text-center",children:[(0,b.jsx)("div",{className:"flex size-12 items-center justify-center rounded-full bg-surface-2",children:(0,b.jsx)(d,{name:"Check",className:"text-primary"})}),(0,b.jsx)("h3",{className:"font-title",children:(0,b.jsx)(t,{id:"18njz72",dangerouslyVisiblePublicValues:{service:v}})}),(0,b.jsx)("p",{className:"font-large text-secondary",children:(0,b.jsx)(t,{id:"lx5ak",dangerouslyVisiblePublicValues:{reviewer:r?.created_by_display_name??c({id:"1inqsce",intl:e})}})}),(0,b.jsx)(m,{variant:"secondary",onClick:()=>i.push("/"),children:(0,b.jsx)(t,{id:"4x18ts"})})]})});if(l)return(0,b.jsx)(w,{children:(0,b.jsxs)("div",{role:"status",children:[(0,b.jsx)(x,{}),(0,b.jsx)("span",{className:"sr-only",children:c({id:"1hzsp26",intl:e})})]})});if(!r)return(0,b.jsx)(w,{children:(0,b.jsxs)("div",{className:"max-w-md space-y-2 text-center",children:[(0,b.jsx)("h3",{className:"font-title",children:(0,b.jsx)(t,{id:"1ausgi2"})}),(0,b.jsx)("p",{className:"font-large text-secondary",children:(0,b.jsx)(t,{id:"7lrpqy"})})]})});if(r.needs_org_switch)return(0,b.jsx)(w,{children:(0,b.jsxs)("div",{className:"max-w-md space-y-2 text-center",children:[(0,b.jsx)("h3",{className:"font-title",children:(0,b.jsx)(t,{id:"q12jnh"})}),(0,b.jsx)("p",{className:"font-large text-secondary",children:(0,b.jsx)(t,{id:"7poy9z",dangerouslyVisiblePublicValues:{organization:r.organization_name??c({id:"1rsv3i3",intl:e})}})})]})});const P=r.prefill?.display_name??r.prefill?.host_constraint?.[0]??c({id:"1vgk1ca",intl:e});return(0,b.jsx)(w,{children:(0,b.jsxs)("div",{className:"flex w-full max-w-[572px] flex-col gap-md",children:[(0,b.jsxs)("div",{className:"flex w-full flex-col gap-lg rounded-lg border bg-surface-1 p-lg",children:[(0,b.jsxs)("div",{className:"flex flex-col gap-xs",children:[(0,b.jsx)("h3",{className:"font-title",children:(0,b.jsx)(t,{id:"1yu4tx6",dangerouslyVisiblePublicValues:{service:P}})}),(0,b.jsx)(_,{link:r})]}),(0,b.jsx)("p",{className:"text-body text-secondary",children:(0,b.jsx)(t,{id:"1s5vpsh",dangerouslyVisiblePublicValues:{service:P}})}),(0,b.jsx)(g,{isOpen:!0,onClose:()=>{},onSuccess:()=>{},provision:V})]}),(0,b.jsx)(u,{variant:"neutral",icon:(0,b.jsx)(d,{name:"Info"}),className:"w-full",children:(0,b.jsx)(t,{id:"1fmo62h"})})]})})}function _({link:s}){const{created_by_display_name:e,created_by_email:i,organization_name:n}=s;return e||i?(0,b.jsx)("p",{className:"text-footnote text-muted",children:(0,b.jsx)(t,{id:"hf8kvx",dangerouslyVisiblePublicValues:{name:e??i,email:e?i??"\u2014":"\u2014",organization:n??"\u2014"}})}):null}function w({children:s}){return(0,b.jsx)("div",{className:"draggable-none flex min-h-screen items-center justify-center p-lg",children:s})}export{v as ProvisioningFillRoute};