1import{v as pe,k as u,e as D,j as e,ag as Ne,X as Jt,B as A,g as Le,b as N,z as ke,l as Zt,M as ut,bj as mt,Q as V,bH as en,p as Pe,$ as Qe,bS as ve,bT as On,o as tn,bp as Mn,s as Fe,u as nn,a0 as qe,a1 as an,a2 as Ye,aC as ht,L as ge,I as ot,bC as Ee,a5 as We,a6 as He,a7 as Ke,a8 as Ue,a9 as ce,bx as _n,S as Xe,t as sn,bU as zn,bV as $n,bW as Dn,bX as An,bY as Fn,bZ as Bn,b_ as Wn,b$ as Hn,c0 as Kn,bK as Un,aW as Vn,bF as he,bJ as Gn,U as Qn,aN as qn,c1 as Pt,c2 as Ot,c3 as De,by as Yn,bE as Xn,T as de,c as Jn,aO as on,aB as rn,K as ln,H as Re,av as Ve,c4 as cn,m as gt,c5 as ye,bG as ft,h as pt,aq as dn,ar as un,as as mn,at as rt,aI as Zn,aJ as ea,aK as ta,bv as na,aL as aa,a as xt,c6 as hn,c7 as sa,az as gn,af as oa,ah as fn,R as pn,c8 as ra,c9 as ia,bQ as Mt,ca as la,cb as ca,cc as da,br as ua,cd as ma,ce as ha,cf as xn,cg as bn,ch as it,ci as et,bm as ie,ao as tt,cj as _t,ab as ga,ap as fa,ck as pa,D as vn,cl as xa,cm as ba,F as va,cn as ya,co as ja,n as wa,cp as zt,G as ka,cq as Na,ay as Ca,q as lt,f as Ia,P as Ta}from"./index-Cik2NVpk.js";import{W as $t,N as Sa,f as Ea}from"./new-tenant-saver-form-BYo0gcT0.js";import{F as ct}from"./XMarkIcon-I8HIRkQz.js";import{I as yn}from"./inline-error-CpSgE79A.js";import{u as Dt}from"./tenant-wrapper-CdXdZuAT.js";import{p as At}from"./member-primitives-C08kgAVg.js";import{u as jn,I as Ra,p as La}from"./invite-modal-gqxHvQbH.js";import{C as Pa,a as Oa,c as Ma,b as _a}from"./card-BckVfIl3.js";import{u as bt}from"./use-analytics-Bm0zM5VI.js";import{O as Ft}from"./organization-selector-qhCZBcmJ.js";import{T as Bt}from"./tenant-switcher-CtLygWtm.js";import{g as za,h as $a,j as Da}from"./usage-features-CzNmYDX1.js";import{g as Aa,a as wn}from"./resource-limit-status-DVtVdXcL.js";import{g as je}from"./global-emitter-CKe7NiBF.js";import{u as vt}from"./use-auth-disabled-DVU2g1f0.js";import{m as Fa}from"./index-avdEcLN7.js";import{B as Ba,a as Wa,b as Ha,c as Ka,d as Ua,e as Va}from"./breadcrumb-B0GT2tZh.js";import{H as Ga,u as Qa}from"./outlet-D9ObWrcM.js";import{R as nt}from"./redirect-CE0pmWfJ.js";import{e as Be,w as kn,i as Te,s as qa,a as Ya,t as Xa,b as Ja,n as at,o as Za,c as es}from"./onboarding-state-Dzx0ylxf.js";import{R as ts,a as ns}from"./radio-group-BfNA5qKJ.js";import{u as as}from"./use-onboarding-progress-cCXLR8Xu.js";import"./region-select-Bdg4qA9b.js";import"./shard-deployment-key-B25zaiaW.js";import"./tenant-region-badge-DbhQQioG.js";import"./PlusIcon-BfaRgijd.js";import"./index-CWT1opuj.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new t.Error().stack;
1n&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[n]="57f759c9-88b6-41fc-a9c4-0ff3066dd641",t._sentryDebugIdIdentifier="sentry-dbid-57f759c9-88b6-41fc-a9c4-0ff3066dd641")}catch{}})();/** 2 * @license lucide-react v1.8.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const ss=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],os=pe("bot",ss);/** 7 * @license lucide-react v1.8.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const rs=[["path",{d:"M17.925 20.056a6 6 0 0 0-11.851.001",key:"z69sun"}],["circle",{cx:"12",cy:"11",r:"4",key:"1gt34v"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],is=pe("circle-user-round",rs);/** 12 * @license lucide-react v1.8.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const ls=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.93 4.93 4.24 4.24",key:"1ymg45"}],["path",{d:"m14.83 9.17 4.24-4.24",key:"1cb5xl"}],["path",{d:"m14.83 14.83 4.24 4.24",key:"q42g0n"}],["path",{d:"m9.17 14.83-4.24 4.24",key:"bqpfvv"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}]],cs=pe("life-buoy",ls);/** 17 * @license lucide-react v1.8.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const ds=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],us=pe("menu",ds);/** 22 * @license lucide-react v1.8.0 - ISC 23 * 24 * This source code is licensed under the ISC license. 25 * See the LICENSE file in the root directory of this source tree. 26 */const ms=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],hs=pe("monitor",ms);/** 27 * @license lucide-react v1.8.0 - ISC 28 * 29 * This source code is licensed under the ISC license. 30 * See the LICENSE file in the root directory of this source tree. 31 */const gs=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],fs=pe("moon",gs);/** 32 * @license lucide-react v1.8.0 - ISC 33 * 34 * This source code is licensed under the ISC license. 35 * See the LICENSE file in the root directory of this source tree. 36 */const ps=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],xs=pe("sun",ps);/** 37 * @license lucide-react v1.8.0 - ISC 38 * 39 * This source code is licensed under the ISC license. 40 * See the LICENSE file in the root directory of this source tree. 41 */const bs=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],vs=pe("terminal",bs);function ys({title:t,titleId:n,...a},r){return u.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":n},a),t?u.createElement("title",{id:n},t):null,u.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M18 7.5v3m0 0v3m0-3h3m-3 0h-3m-2.25-4.125a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0ZM3 19.235v-.11a6.375 6.375 0 0 1 12.75 0v.109A12.318 12.318 0 0 1 9.374 21c-2.331 0-4.512-.645-6.374-1.766Z"}))}const js=u.forwardRef(ys);function ws({header:t,children:n,footer:a,banner:r,overlay:s,contentScroll:i=!0,className:o}){const l=!!a,g=!!r,h=D(g&&(l?"grid-rows-[auto_64px_minmax(0,1fr)_auto]":"grid-rows-[auto_64px_minmax(0,1fr)]"),!g&&(l?"grid-rows-[64px_minmax(0,1fr)_auto]":"grid-rows-[64px_minmax(0,1fr)]"));return e.jsxs("div",{className:D("grid h-full w-full min-h-0 min-w-0 overflow-hidden",h,o),children:[r,t,e.jsxs("div",{className:"relative min-h-0 min-w-0 overflow-hidden",children:[e.jsx("div",{className:D("h-full w-full min-h-0 min-w-0",i?"overflow-auto":"overflow-hidden"),...s?{inert:""}:{},children:n}),s]}),l?e.jsx("div",{className:"min-w-0 border-t bg-background",children:e.jsx("div",{className:"mx-auto flex min-h-9 w-full min-w-0 items-center px-2",children:a})}):null]})}function ks({onDismiss:t}){const{tenantId:n}=Ne();return e.jsxs("div",{role:"alert",className:"relative flex items-center justify-center gap-3 border-b border-yellow-300 bg-yellow-400 px-10 py-1.5 text-center text-sm font-medium text-yellow-950 dark:border-yellow-700 dark:bg-yellow-500",children:[e.jsx(Jt,{className:"h-4 w-4 flex-shrink-0"}),"You are using an auth-disabled instance of Hatchet.",n&&e.jsx(A,{asChild:!0,variant:"outline",size:"sm",className:"h-6 border-yellow-950/30 bg-transparent px-2 text-xs text-yellow-950 hover:bg-yellow-950/10 hover:text-yellow-950",children:e.jsx(Le,{to:N.tenantSettingsApiTokensRoute.to,params:{tenant:n},children:"View worker token"})}),e.jsx(A,{type:"button",variant:"ghost",size:"icon","aria-label":"Dismiss",onClick:t,className:"absolute right-1 top-1/2 h-6 w-6 -translate-y-1/2 text-yellow-950 hover:bg-yellow-950/10 hover:text-yellow-950",children:e.jsx(ct,{className:"h-4 w-4"})})]})}function Ns({value:t,onChange:n,options:a,loading:r}){const[s,i]=u.useState(!1);return e.jsxs(zn,{open:s,onOpenChange:i,children:[e.jsx($n,{asChild:!0,children:e.jsxs(A,{type:"button",variant:"outline",role:"combobox","aria-expanded":s,className:"w-full justify-between font-normal",children:[e.jsx("span",{className:D("truncate",!t&&"text-muted-foreground"),children:t||(r?"Loading members...":"Select a member...")}),e.jsx(Dn,{className:"ml-2 size-4 shrink-0 opacity-50"})]})}),e.jsx(An,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Fn,{children:[e.jsx(Bn,{placeholder:"Search members..."}),e.jsxs(Wn,{children:[e.jsx(Hn,{children:"No members found."}),a.map(o=>e.jsxs(Kn,{value:o,onSelect:()=>{n(o),i(!1)},className:"cursor-pointer",children:[e.jsx("span",{className:"truncate",children:o}),e.jsx(Un,{className:D("ml-auto size-4 shrink-0",t===o?"opacity-100":"opacity-0")})]},o))]})]})})]})}const Cs=({className:t,...n})=>{var v,C,L,z,F,P,R,I;const a=n.tenantOptions!==void 0,r=u.useMemo(()=>
41{const w=n.isControlPlaneEnabled?[ve.ADMIN,ve.MEMBER,ve.VIEWER]:[ve.OWNER,ve.ADMIN,ve.MEMBER,ve.VIEWER],k=On(w);return tn({email:Fe().email("Invalid email address"),role:a?k.optional():k,tenantId:a?Fe({required_error:"Select a tenant"}).min(1):Fe().optional(),canViewPayloads:Mn()})},[n.isControlPlaneEnabled,a]),{register:s,handleSubmit:i,control:o,watch:l,formState:{errors:g}}=nn({resolver:sn(r),defaultValues:{email:n.defaultEmail??"",tenantId:n.defaultTenantId,canViewPayloads:!0}}),h=At(l("role")),m=((C=(v=g.email)==null?void 0:v.message)==null?void 0:C.toString())||((L=n.fieldErrors)==null?void 0:L.email),j=((F=(z=g.role)==null?void 0:z.message)==null?void 0:F.toString())||((P=n.fieldErrors)==null?void 0:P.role),c=(I=(R=g.tenantId)==null?void 0:R.message)==null?void 0:I.toString();return e.jsxs(qe,{className:"max-w-lg",children:[e.jsxs(an,{children:[e.jsx(Ye,{children:"Add member to tenant"}),e.jsx(ht,{children:a?"Attach a user to a tenant directly. For larger teams, we recommend using user groups to manage user access to tenants.":"Invite a user to this tenant by email."})]}),e.jsx("div",{className:D("grid gap-6",t),children:e.jsx("form",{onSubmit:i(w=>{n.onSubmit({...w,canViewPayloads:At(w.role)?!0:w.canViewPayloads})}),children:e.jsxs("div",{className:"grid gap-4",children:[e.jsx(yn,{errors:n.formErrors??[]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(ge,{htmlFor:"email",children:"Email"}),n.emailOptions!==void 0?e.jsxs(e.Fragment,{children:[n.emailOptions.length===0&&!n.emailOptionsLoading?e.jsx(ot,{disabled:!0,placeholder:"All organization members are already in this tenant"}):e.jsx(Ee,{control:o,name:"email",render:({field:w})=>e.jsx(Ns,{value:w.value,onChange:w.onChange,options:n.emailOptions??[],loading:n.emailOptionsLoading})}),n.organizationId&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Not seeing your teammates?"," ",e.jsx(Le,{to:N.organizationTeamRoute.to,params:{organization:n.organizationId},onClick:n.onNavigateAway,className:"text-primary underline-offset-4 hover:underline",children:"Manage organization members"})]})]}):e.jsx(ot,{...s("email"),id:"email",placeholder:"[email protected]",type:"email",autoCapitalize:"none",autoComplete:"email",autoCorrect:"off",disabled:n.isLoading}),m&&e.jsx("div",{className:"text-sm text-red-500",children:m})]}),a&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(ge,{htmlFor:"tenant",children:"Tenant"}),e.jsx(Ee,{control:o,name:"tenantId",render:({field:w})=>e.jsxs(We,{onValueChange:k=>{var H;w.onChange(k),(H=n.onTenantChange)==null||H.call(n,k)},value:w.value,disabled:n.tenantOptionsLoading,children:[e.jsx(He,{className:"w-full focus:ring-0 focus-visible:ring-0",children:e.jsx(Ke,{id:"tenant",placeholder:n.tenantOptionsLoading?"Loading tenants...":"Tenant..."})}),e.jsx(Ue,{children:(n.tenantOptions??[]).map(k=>e.jsx(ce,{value:k.id,children:k.label},k.id))})]})}),c&&e.jsx("div",{className:"text-sm text-red-500",children:c})]}),!a&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(ge,{htmlFor:"role",children:"Role"}),e.jsx(Ee,{control:o,name:"role",render:({field:w})=>e.jsxs(We,{onValueChange:w.onChange,value:w.value,children:[e.jsx(He,{className:"w-[180px] focus:ring-0 focus-visible:ring-0",children:e.jsx(Ke,{id:"role",placeholder:"Role..."})}),e.jsxs(Ue,{children:[!n.isControlPlaneEnabled&&e.jsx(ce,{value:"OWNER",children:"Owner"}),e.jsx(ce,{value:"ADMIN",children:"Admin"}),e.jsx(ce,{value:"MEMBER",children:"Member"}),e.jsx(ce,{value:"VIEWER",children:"Viewer"})]})]})}),j&&e.jsx("div",{className:"text-sm text-red-500",children:j})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ee,{control:o,name:"canViewPayloads",render:({field:w})=>e.jsx(_n,{id:"canViewPayloads",checked:h||w.value,onCheckedChange:k=>w.onChange(k===!0),disabled:n.isLoading||h})}),e.jsxs("div",{className:"grid gap-1",children:[e.jsx(ge,{htmlFor:"canViewPayloads",children:"Can view payloads"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Owners and admins always see payloads. Uncheck to hide inputs, outputs, and events from this user."})]})]}),e.jsxs(A,{disabled:n.isLoading,children:[n.isLoading&&e.jsx(Xe,{}),a?"Add to tenant":"Invite user"]})]})})})]})},Is=({tenantId:t,organizationId:n,defaultEmail:a,onClose:r,onCreated:s})=>{var G,Y,B;const{isControlPlaneEnabled:i}=ke(),[o,l]=u.useState({}),[g,h]=u.useState([]),{handleApiError:m}=Zt({setErrors:h}),j=ut(),c=!!n,v=mt(),C=V({...v.organizationGetQuery(n??""),enabled:c}),[L,z]=u.useState(t),{tenantMemberListQuery:F}=Dt(),P=V({...F(L??""),enabled:c&&!!L}),R=u.useMemo(()=>{var y;return new Set((((y=P.data)==null?void 0:y.rows)??[]).map(p=>p.user.email))},[(G=P.data)==null?void 0:G.rows]),I=u.useMemo(()=>{var y;if(c)return(((y=C.data)==null?void 0:y.members)??[]).map(p=>p.email).filter(p=>
41!R.has(p))},[c,(Y=C.data)==null?void 0:Y.members,R]),w=u.useMemo(()=>{var y;if(c)return(((y=C.data)==null?void 0:y.tenants)??[]).filter(p=>p.status!==en.ARCHIVED).map(p=>({id:p.id,label:p.name??p.slug??p.id}))},[c,(B=C.data)==null?void 0:B.tenants]),{tenantInviteCreateMutation:k}=Dt(),H=Pe({mutationKey:["tenant-add-or-invite"],mutationFn:async y=>{if(y.mode==="add")return await v.organizationTenantMembersAddMutation(n,y.tenantId).mutationFn({memberIds:[y.memberId],canViewPayloads:y.canViewPayloads}),{tenantId:y.tenantId,invite:void 0};const p=await k(y.tenantId).mutationFn(y.data);return{tenantId:y.tenantId,invite:p}},onSuccess:({tenantId:y,invite:p})=>{j.invalidateQueries({queryKey:["tenant-member:list",y]}),n?j.invalidateQueries({queryKey:["organization:get",n]}):j.invalidateQueries({queryKey:["tenant-invite:list",y]}),p&&s(y,p),r()},onError:m});return e.jsx(Qe,{open:!0,onOpenChange:y=>!y&&r(),children:e.jsx(Cs,{isLoading:H.isPending,onSubmit:({email:y,role:p,tenantId:E,canViewPayloads:M})=>{var _;l({}),h([]);const Q=c?E:t;if(Q){if(n){if(R.has(y)){l({email:"This user is already a member of the selected tenant."});return}const X=(((_=C.data)==null?void 0:_.members)??[]).find(se=>se.email===y);if(!X){l({email:"Selected member could not be found."});return}H.mutate({mode:"add",tenantId:Q,memberId:X.metadata.id,canViewPayloads:M});return}H.mutate({mode:"invite",tenantId:Q,data:{email:y,role:p,canViewPayloads:M}})}},fieldErrors:o,formErrors:g,isControlPlaneEnabled:i,defaultEmail:a,defaultTenantId:c?t:void 0,tenantOptions:w,tenantOptionsLoading:c&&C.isLoading,emailOptions:I,emailOptionsLoading:C.isLoading||P.isLoading,organizationId:n,onTenantChange:z,onNavigateAway:r})})},Wt=100,Ts=tn({email:Fe().email("Invalid email address"),role:Xn(he)}),Ss=({organizationId:t,organizationName:n,onClose:a,onCreated:r})=>{var b,T,re,ne;const[s,i]=u.useState([]),[o,l]=u.useState([]),[g,h]=u.useState([]),[m,j]=u.useState(!1),{isControlPlaneEnabled:c}=ke(),{canInviteUser:v}=Vn(t),{handleApiError:C}=Zt({setErrors:i}),{register:L,handleSubmit:z,reset:F,control:P,watch:R,formState:{errors:I}}=nn({resolver:sn(Ts),defaultValues:{email:"",role:c?he.MEMBER:he.OWNER}}),w=R("role"),k=R("email"),H=ut(),G=mt(),Y=V({...G.organizationGetQuery(t),enabled:!!t&&c}),B=V({...G.organizationInviteListQuery(t),enabled:!!t&&c}),y=V({...G.userGroupsListQuery(t),enabled:!!t&&c}),p=u.useMemo(()=>{var d;return(((d=Y.data)==null?void 0:d.tenants)??[]).filter(S=>S.status!==en.ARCHIVED).map(S=>({label:S.name??S.slug??S.id,value:S.id}))},[(b=Y.data)==null?void 0:b.tenants]),E=u.useMemo(()=>new Map(p.map(d=>[d.value,d.label])),[p]),M=u.useMemo(()=>(y.data??[]).map(d=>({label:`${d.name} · ${d.role}`,value:d.metadata.id})),[y.data]),Q=u.useMemo(()=>new Map(M.map(d=>[d.value,d.label])),[M]),_=u.useMemo(()=>{var S;const d=k==null?void 0:k.trim().toLowerCase();return d?(((S=B.data)==null?void 0:S.rows)??[]).some(U=>U.status===Gn.PENDING&&U.inviteeEmail.toLowerCase()===d):!1},[k,(T=B.data)==null?void 0:T.rows]),X=c&&w===he.MEMBER,se=X&&M.length>0,K=G.organizationInviteCreateMutation(t),O=Pe({...K,mutationFn:async d=>{const S=c&&d.role===he.MEMBER,U={inviteeEmail:d.email,role:d.role,...S&&o.length>0?{tenants:o.map(({tenantId:J,tenantRole:Z})=>({tenantId:J,tenantRole:Z}))}:{},...S&&g.length>0?{userGroupIds:g}:{}};return await K.mutationFn(U),U},onSuccess:d=>{H.invalidateQueries({queryKey:["organization-invites:list",t]}),H.invalidateQueries({queryKey:["organization:entitlements:get",t]}),F(),l([]),h([]),r(d),a()},onError:d=>{var S;if(d instanceof Qn&&((S=d.response)==null?void 0:S.status)===403){j(!0);return}C(d)}}),oe=(ne=(re=I.email)==null?void 0:re.message)==null?void 0:ne.toString();return m||!v?e.jsx(qn,{open:!0,gate:"users",organizationId:t,onDismiss:a}):e.jsx(Qe,{open:!0,onOpenChange:d=>!d&&a(),children:e.jsxs(qe,{className:"max-w-xl",children:[e.jsxs(an,{children:[e.jsxs(Ye,{className:"flex items-center gap-2",children:[e.jsx(js,{className:"h-5 w-5"}),"Invite Member"]}),e.jsxs(ht,{children:["Invite a new member to ",n]})]}),e.jsxs("form",{onSubmit:z(d=>{i([]),O.mutate(d)}),className:"space-y-4",children:[e.jsx(yn,{errors:s}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"email",children:"Email Address"}),e.jsx(ot,{...L("email"),id:"email",type:"email",placeholder:"[email protected]",autoCapitalize:"none",autoComplete:"email",autoCorrect:"off",disabled:O.isPending}),oe&&e.jsx("div",{className:"text-sm text-red-500",children:oe}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"The user will receive an email invitation to join this organization."}),c&&_&&e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-yellow-500/50 bg-yellow-500/10 px-3 py-2 text-sm",children:[e.jsx(Jt,{className:"mt-0.5 size-4 shrink-0 text-yellow-500"}),e.jsx("p",{className:"text-muted-foreground",children:"An invite for this email is already pending â cancel it first to change its role, tenant access, or groups."})]})]}),c&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{htmlFor:"role",children:"Role"}
41),e.jsx(Ee,{control:P,name:"role",render:({field:d})=>e.jsxs(We,{onValueChange:S=>{d.onChange(S),S===he.OWNER&&(l([]),h([]))},value:d.value,children:[e.jsx(He,{children:e.jsx(Ke,{placeholder:"Select role..."})}),e.jsxs(Ue,{children:[e.jsx(ce,{value:he.MEMBER,children:"Member"}),e.jsx(ce,{value:he.OWNER,children:"Owner"})]})]})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Members access tenants based on their tags or can be added directly. Owners have full access to all tenants."})]}),X&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"Tenant access (optional)"}),e.jsx("div",{children:e.jsx(Pt,{title:"Tenants",type:Ot.Checkbox,options:p,values:o.map(d=>d.tenantId),setValues:d=>{const S=d.slice(0,Wt);l(U=>{const J=new Map(U.map(Z=>[Z.tenantId,Z]));return S.map(Z=>J.get(Z)??{tenantId:Z,tenantRole:De.MEMBER})})},emptyMessage:"No tenants found."})}),o.length>0&&e.jsx(Yn,{columns:[{columnLabel:"Tenant",cellRenderer:d=>E.get(d.tenantId)??d.tenantId},{columnLabel:"Role",cellRenderer:d=>e.jsxs(We,{value:d.tenantRole,onValueChange:S=>l(U=>U.map(J=>J.tenantId===d.tenantId?{...J,tenantRole:S}:J)),disabled:O.isPending,children:[e.jsx(He,{className:"h-8 w-32","aria-label":`Role for ${E.get(d.tenantId)??d.tenantId}`,children:e.jsx(Ke,{})}),e.jsxs(Ue,{children:[e.jsx(ce,{value:De.MEMBER,children:"Member"}),e.jsx(ce,{value:De.ADMIN,children:"Admin"}),e.jsx(ce,{value:De.VIEWER,children:"Viewer"})]})]})},{columnLabel:"",cellRenderer:d=>e.jsx("button",{type:"button",onClick:()=>l(S=>S.filter(U=>U.tenantId!==d.tenantId)),disabled:O.isPending,className:"rounded p-1 text-muted-foreground hover:text-destructive disabled:opacity-50","aria-label":`Remove ${E.get(d.tenantId)??d.tenantId}`,children:e.jsx(ct,{className:"size-4"})})}],data:o,rowKey:d=>d.tenantId}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"The invitee will be added to these tenants when they accept."})]}),se&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{children:"User groups (optional)"}),e.jsx("div",{children:e.jsx(Pt,{title:"User groups",type:Ot.Checkbox,options:M,values:g,setValues:d=>h(d.slice(0,Wt)),emptyMessage:"No user groups found."})}),g.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:g.map(d=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-md border bg-secondary px-3 py-1 text-sm text-secondary-foreground",children:[Q.get(d)??d,e.jsx("button",{type:"button",onClick:()=>h(g.filter(S=>S!==d)),disabled:O.isPending,className:"ml-0.5 rounded hover:text-destructive disabled:opacity-50","aria-label":`Remove ${Q.get(d)??d}`,children:e.jsx(ct,{className:"size-3.5"})})]},d))}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Group membership grants tenant access dynamically by tags."})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-4",children:[e.jsx(A,{type:"button",variant:"outline",onClick:a,children:"Cancel"}),e.jsx(A,{type:"submit",disabled:O.isPending,children:O.isPending?"Sending...":"Send Invitation"})]})]})]})})},Es={task_runs:{name:"Task runs",suffix:" daily"},task_runs_daily_limit:{name:"Task runs",suffix:" daily"},events:{name:"External events",suffix:" daily"},events_daily_limit:{name:"External events",suffix:" daily"},worker_slots_limit:{name:"Concurrent runs"},users:{name:"Users"}};function Rs({tenantId:t,organizationId:n,open:a,onClose:r}){var j;const{capture:s}=bt(),{isControlPlaneEnabled:i,canBill:o}=ke(),l=V({...de.controlPlane.subscriptionPlans(),enabled:a&&i&&o}),g=(j=l.data)==null?void 0:j.freeLimits,h=Pe({mutationKey:["welcome:developer-plan"],mutationFn:async()=>{if(!n)throw new Error("No organization id");return(await Jn.organizationSubscriptionUpdate(n,{plan:on.PayAsYouGo})).data},onSuccess:c=>{localStorage.removeItem($t),r(),c.checkoutUrl&&(window.location.href=c.checkoutUrl)}}),m=()=>{localStorage.removeItem($t),r()};return e.jsx(Qe,{open:a,onOpenChange:c=>{c||m()},children:e.jsxs(qe,{className:`${rn} max-h-[85vh] max-w-xl overflow-y-auto`,children:[e.jsx(Ye,{className:"sr-only",children:"Welcome to Hatchet"}),e.jsx(ln,{className:"max-w-none",title:e.jsxs("span",{className:"flex flex-col gap-3",children:[e.jsx(Re,{variant:"mark",className:"h-8 w-8"}),e.jsx("span",{children:"Welcome to Hatchet"})]}),description:e.jsx(ht,{children:"The free tier includes everything you need to start building. No credit card, no time limit."}),children:e.jsxs("div",{className:"flex w-full flex-col gap-6",children:[e.jsxs(Pa,{variant:"light",className:"bg-transparent ring-1 ring-border/50 border-none",children:[e.jsx(Oa,{className:"p-4 border-b border-border/50",children:e.jsx(Ma,{className:"font-mono font-normal tracking-wider up
41percase text-xs text-muted-foreground whitespace-nowrap",children:"Included free"})}),e.jsx(_a,{className:"p-4",children:l.isLoading?e.jsx("div",{className:"flex justify-center py-2",children:e.jsx(Xe,{})}):e.jsx("ul",{className:"space-y-2.5 text-sm",children:g==null?void 0:g.map(c=>{const v=Es[c.featureId];return e.jsxs("li",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:(v==null?void 0:v.name)??c.name}),e.jsxs("span",{className:"font-medium",children:[c.limit.toLocaleString(),(v==null?void 0:v.suffix)??""]})]},c.featureId)})})})]}),e.jsxs("div",{className:"flex w-full flex-col gap-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"When you're ready for production, Pay as you Go removes these limits. There's no base monthly fee and you pay nothing until you scale past what's included for free."}),e.jsx(A,{className:"w-full",disabled:h.isPending,onClick:()=>{s("welcome_modal_add_payment",{tenant_id:t,organization_id:n,cta:"upgrade_button"}),h.mutate()},children:h.isPending?"Redirectingâ¦":"Upgrade to Pay as you Go â starts at $0/month"}),e.jsx(A,{variant:"ghost",className:"w-full",onClick:()=>{s("welcome_modal_dismissed",{tenant_id:t,organization_id:n,cta:"start_building"}),m()},children:"Start Building with these Limits"})]})]})})]})})}const Ls="hatchet:dismissed-limit-notifications";function Nn(t,n,a){return`billing:${t}:${n}:${a}`}function Ps(t,n,a){return`tenant:${t}:${n}:${a}`}function Os(t,n){return!!n&&t[n]===!0}function Ms(){const[t,n]=Ve(Ls,{}),a=u.useCallback(r=>{n(s=>({...s,[r]:!0}))},[n]);return{dismissed:t,dismiss:a}}const Ht=2*6e4,Cn={warn:"yellow",exhausted:"red"};function Ge(t){return new Intl.NumberFormat("en-US").format(t)}const _s=(t,n,a,r)=>{if($a(t.featureId)||Da(t.featureId)||t.featureId==="tenants")return null;const s=Aa(t);return s==="ok"?null:{color:Cn[s],shortTitle:s==="exhausted"?"Limit reached":"Approaching limit",title:s==="exhausted"?`${t.name} limit reached`:`Approaching ${t.name} limit`,message:`${a}: ${Ge(t.usage)} / ${Ge(t.includedUsage)} used`,timestamp:r,dismissKey:Nn(n,t.featureId,s),url:N.organizationBillingRoute.to.replace("$organization",n)}},zs=()=>{var g,h,m,j;const{organizationId:t}=Ne(),n=cn(),{isControlPlaneEnabled:a,canBill:r}=ke(),s=u.useMemo(()=>{var c;if(!(!t||!n.isUserUniverseLoaded))return(c=n.organizations)==null?void 0:c.find(v=>v.metadata.id===t)},[n.isUserUniverseLoaded,n.organizations,t]),i=V({...de.controlPlane.usage(t??""),refetchInterval:Ht,enabled:a&&r&&!!t}),o=V({...de.controlPlane.tenantResourceLimits(t??""),refetchInterval:Ht,enabled:a&&r&&!!t});return{notifications:u.useMemo(()=>{var z,F,P,R;if(!t)return[];const c=((z=i.data)==null?void 0:z.periodEnd)??((F=i.data)==null?void 0:F.periodStart)??new Date(0).toISOString(),v=(s==null?void 0:s.name)??t,C=(((P=i.data)==null?void 0:P.features)??[]).map(I=>_s(I,t,v,c)).filter(I=>I!==null),L=za(((R=o.data)==null?void 0:R.tenants)??[]).map(I=>{const w=I.tenantName??v;return{color:Cn[I.status],shortTitle:I.status==="exhausted"?"Limit reached":"Approaching limit",title:I.status==="exhausted"?`${I.name} limit reached`:`Approaching ${I.name} limit`,message:`${w}: ${Ge(I.usage)} / ${Ge(I.includedUsage)} used`,timestamp:I.timestamp,dismissKey:Nn(t,I.featureId,I.status),url:N.organizationBillingRoute.to.replace("$organization",t)}});return[...C,...L]},[(g=o.data)==null?void 0:g.tenants,s==null?void 0:s.name,t,(h=i.data)==null?void 0:h.features,(m=i.data)==null?void 0:m.periodEnd,(j=i.data)==null?void 0:j.periodStart]),isLoading:i.isLoading||o.isLoading}},$s=()=>{const{pendingInvitesQuery:t,isLoading:n}=jn();return{notifications:u.useMemo(()=>{const r=t.data;if(!r||r.inviteCount===0)return[];const s=r.inviteCount,i=[...r.tenantInvites,...r.organizationInvites].map(o=>o.metadata.createdAt).filter(o=>!!o).reduce((o,l)=>l>o?l:o,"");return[{color:"green",shortTitle:s===1?"Invite":"Invites",title:s===1?r.tenantInvites[0]?`Invite to join ${r.tenantInvites[0].tenantName??"a tenant"}`:"Organization invite":`${s} pending invites`,message:`You have ${s} pending invite${s>1?"s":""} awaiting your response.`,timestamp:i,onClick:()=>je.emit("open-invite-modal",{})}]},[t.data]),isLoading:n}};function Ds(t){return t.length===1}const As=()=>{const{tenantMemberships:t}=gt(),n=vt(),a=u.useMemo(()=>(t??[]).map(h=>h.tenant).filter(h=>h!=null),[t]),r=Ds(a),s=r?a[0].metadata.id:"",i=V({...de.workflows.list(s,{limit:1}),enabled:r}),o=V({...de.tokens.list(s),enabled:r&&!n}),l=i.isLoading||o.isLoading;return{notifications:u.useMemo(()=>{var j,c,v,C;if(!r||l)return[];if(n)return[];const h=(((c=(j=i.data)==null?void 0:j.rows)==null?void 0:c.length)??0)>0,m=(((C=(v=o.data)==null?void 0:v.rows)==null?void 0:C.length)??0)>0;
41return h||m?[]:[{color:"blue",shortTitle:"Get started",title:"Get started with Hatchet",message:"Create an API token and run your first workflow",timestamp:new Date().toISOString(),url:N.tenantOverviewRoute.to.replace("$tenant",s)}]},[r,l,s,i.data,o.data,n]),isLoading:l}},Fs=2*6e4,Bs={[ye.WORKER]:"Total Workers",[ye.WORKER_SLOT]:"Concurrency Slots",[ye.EVENT]:"Events",[ye.TASK_RUN]:"Task Runs",[ye.CRON]:"Cron Triggers",[ye.SCHEDULE]:"Schedule Triggers",[ye.INCOMING_WEBHOOK]:"Incoming Webhooks"},Ws={warn:"yellow",exhausted:"red"},Hs=(t,n,a)=>{const r=wn(t);if(r==="ok")return null;const s=Bs[t.resource]??t.resource;return{color:Ws[r],shortTitle:r==="exhausted"?"Limit reached":"Approaching limit",title:r==="exhausted"?`${s} limit reached`:`Approaching ${s} limit`,message:`${a}: ${t.value} / ${t.limitValue} used`,timestamp:t.metadata.createdAt,dismissKey:Ps(n,t.resource,r),url:N.tenantSettingsBillingRoute.to.replace("$tenant",n)}},Ks=()=>{const{tenantId:t,tenant:n}=cn(),a=V({...de.tenantResourcePolicy.get(t??""),refetchInterval:Fs,enabled:!!t});return{notifications:u.useMemo(()=>{var s;return(((s=a.data)==null?void 0:s.limits)??[]).map(i=>Hs(i,t??"",(n==null?void 0:n.name)??t??"")).filter(i=>i!==null)},[t,n==null?void 0:n.name,a.data]),isLoading:a.isLoading}},Us=()=>{const t=Ks(),n=zs(),a=$s(),r=As(),{dismissed:s,dismiss:i}=Ms();return{notifications:u.useMemo(()=>[...t.notifications,...n.notifications,...a.notifications,...r.notifications].filter(l=>!Os(s,l.dismissKey)).sort((l,g)=>g.timestamp>
41l.timestamp?1:-1),[t.notifications,n.notifications,a.notifications,r.notifications,s]),dismiss:i,isLoading:t.isLoading||n.isLoading||a.isLoading||r.isLoading}},Kt={blue:"bg-blue-500",green:"bg-green-500",yellow:"bg-yellow-500",red:"bg-red-500"},Ut={blue:0,green:1,yellow:2,red:3},Vs=t=>t.reduce((n,a)=>Ut[a.color]>Ut[n]?a.color:n,"green");function Vt(){const{notifications:t,dismiss:n}=Us(),{currentUser:a}=ft(),r=pt(),s=t.length,i=s>0?Vs(t):null,o=`${s} notification${s!==1?"s":""}`,l=a!=null&&a.email?`${o} for ${a.email}`:o,g=s>0?t[0].shortTitle:"Notifications";return s>0?e.jsxs(dn,{children:[e.jsx(un,{asChild:!0,children:e.jsxs(A,{variant:"icon",title:l,"aria-label":l,"data-cy":"notifications-button",className:"relative gap-1.5 rounded-md border border-border px-2.5",size:"sm",children:[e.jsx(Fa,{className:"size-4"}),e.jsx("span",{className:"text-xs font-medium leading-none",children:g}),s>1&&e.jsx("span",{className:"text-xs font-medium leading-none text-muted-foreground",children:s}),i&&e.jsx("span",{className:D("absolute -top-0.5 -right-0.5 size-2.5 rounded-full border-2 border-background",Kt[i])})]})}),e.jsx(mn,{className:"w-80",align:"end",children:t.map((m,j)=>e.jsxs(rt,{variant:"interactive",className:"flex cursor-pointer items-start gap-2 px-3 py-2",onClick:()=>m.onClick?m.onClick():r({to:m.url}),children:[e.jsx("span",{className:D("mt-1.5 size-2 shrink-0 rounded-full",Kt[m.color])}),e.jsxs("div",{className:"min-w-0 flex-1",title:m.message,children:[e.jsx("p",{className:"truncate text-sm font-medium",children:m.title}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:m.message})]}),m.dismissKey?e.jsx(Zn,{children:e.jsxs(ea,{children:[e.jsx(ta,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":`Dismiss ${m.title}`,className:"mt-0.5 shrink-0 rounded-sm p-0.5 text-muted-foreground hover:text-foreground",onPointerDown:c=>{c.preventDefault(),c.stopPropagation()},onClick:c=>{c.preventDefault(),c.stopPropagation(),m.dismissKey&&n(m.dismissKey)},children:e.jsx(na,{className:"size-3.5"})})}),e.jsx(aa,{children:"Dismiss"})]})}):null]},`${m.title}-${m.timestamp}`))})]}):null}function In(t){var r;const n=V({queryKey:["tenant-home-route",t],queryFn:async()=>{if(!t)return{hasWorkflows:!1};try{const s=await xt.workflowList(t,{limit:1});return{hasWorkflows:s.data.rows&&s.data.rows.length>0}}catch{return{hasWorkflows:!0}}},enabled:!!t,staleTime:6e4,retry:!1});return{homeRoute:((r=n.data)==null?void 0:r.hasWorkflows)??!0?N.tenantRunsRoute.to:N.tenantOverviewRoute.to,isLoading:n.isLoading}}const Gs=(t,n)=>{switch(t){case"/tenants/:tenant/events":return"Events";case"/tenants/:tenant/filters":return"Filters";case"/tenants/:tenant/webhooks":return"Webhooks";case"/tenants/:tenant/rate-limits":return"Rate Limits";case"/tenants/:tenant/scheduled":return"Scheduled Runs";case"/tenants/:tenant/cron-jobs":return"Cron Jobs";case"/tenants/:tenant/tasks":return"Tasks";case"/tenants/:tenant/tasks/:workflow":return"Task Detail";case"/tenants/:tenant/runs":return"Runs";case"/tenants/:tenant/runs/:run":return"Run Detail";case"/tenants/:tenant/task-runs/:run":return"Task Run Detail";case"/tenants/:tenant/workers":return"Workers";case"/tenants/:tenant/workers/all":return"All Workers";case"/tenants/:tenant/workers/:worker":return"Worker Detail";case"/tenants/:tenant/managed-workers":return"Managed Workers";case"/tenants/:tenant/managed-workers/create":return"Create";case"/tenants/:tenant/managed-workers/demo-template":return"Demo Template";case"/tenants/:tenant/managed-workers/:managed-worker":return"Managed Worker Detail";case"/tenants/:tenant/settings/overview":return"General";case"/tenants/:tenant/settings/resource-limits":return"Resource Limits";case"/tenants/:tenant/settings/api-tokens":return"API Tokens";case"/tenants/:tenant/settings/github":return"GitHub";case"/tenants/:tenant/settings/members":return"Members";case"/tenants/:tenant/settings/alerting":return"Alerting";case"/tenants/:tenant/settings/billing-and-limits":return"Billing & Limits";case"/tenants/:tenant/settings/ingestors":return"Ingestors";case"/tenants/:tenant/settings/integrations":return"Integrations";
41case"/tenants/:tenant/settings/organization":return n?"Organization":"Tenants";case"/tenants/:tenant/workflow-runs":case"/tenants/:tenant/workflow-runs/:run":case"/tenants/:tenant/":case"/tenants/:tenant/workflows":case"/tenants/:tenant/workflows/:workflow":case"/tenants/:tenant/settings":return"";default:const a=t;throw new Error(`Unhandled tenanted path: ${a}`)}},Qs=t=>{switch(t){case"/organizations/:organization/settings":return"General";case"/organizations/:organization/settings/team":return"Team";case"/organizations/:organization/settings/tenants":return"Tenants";case"/organizations/:organization/settings/tokens":return"Management Tokens";case"/organizations/:organization/settings/regions":return"Available Regions";case"/organizations/:organization/settings/sso":return"SSO";case"/organizations/:organization/settings/audit-log":case"/organizations/:organization/settings/compliance":return"Compliance";case"/organizations/:organization/settings/billing":return"Billing & Usage";default:const n=t;throw new Error(`Unhandled organization path: ${n}`)}};function qs(t,n){const a=t.replace(/\/+$/,"").replace(`/organizations/${n}`,"/organizations/:organization");let r;try{r=Qs(a)}catch{return[]}return[{label:"Home"},{label:"Settings",href:`/organizations/${n}/settings`},{label:r,isCurrentPage:!0}]}function Ys(t,n,a){const s=("/"+t.join("/")).replace(`/tenants/${n}`,"/tenants/:tenant");try{return Gs(s,a)||null}catch{return null}}function Xs(t,n,a){const r=`/tenants/${a}`;return n===0?r:r+"/"+t.slice(2,n+1).join("/")}function Js(t,n,a){const r=[];if(t.includes("/auth")||t.includes("/onboarding"))return r;if(t.startsWith("/organizations/")){const l=n==null?void 0:n.organization;return l?qs(t,l):r}if(!t.startsWith("/tenants/"))return r;const s=n==null?void 0:n.tenant;if(!s)return r;r.push({label:"Home",href:`/tenants/${s}/runs`});const i=t.split("/").filter(Boolean),o=i.slice(2);for(let l=0;l<o.length;l++){const g=Xs(i,2+l,s),h=l===o.length-1,m=o[l];let j=null;if(n!=null&&n.workflow&&m===n.workflow?j=n.workflow:n!=null&&n.run&&m===n.run?j=n.run:n!=null&&n.worker&&m===n.worker?j=n.worker:n!=null&&n["managed-worker"]&&m===n["managed-worker"]&&(j=n["managed-worker"]),j){r.push({label:j,href:h?void 0:g,isCurrentPage:h});continue}const c=Ys(i.slice(0,2+l+1),s,a??!1);if(c)r.push({label:c,href:h?void 0:g,isCurrentPage:h});else{const v=o[l].split("-").map(C=>C.charAt(0).toUpperCase()+C.slice(1)).join(" ");r.push({label:v,href:h?void 0:g,isCurrentPage:h})}}return r}function Zs(){const t=hn(),n=sa(),a=gn({strict:!1}),r=Object.entries(a).reduce((v,[C,L])=>(L!==void 0&&(v[C]=L),v),{}),{isControlPlaneEnabled:s}=ke(),{tenantId:i}=Ne(),o=r.tenant??i,{homeRoute:l}=In(o),g=n.matches.some(v=>v.routeId==="/tenants/$tenant"),m=t.pathname.split("/").filter(Boolean).length>2;if(g&&m&&n.matches.length===3)return[];const c=Js(t.pathname,r,s);return c.length>0&&c[0].label==="Home"&&o&&(c[0].href=l.replace(":tenant",o)),c}const st=[{value:"light",label:"Light",icon:xs},{value:"dark",label:"Dark",icon:fs},{value:"system",label:"System",icon:hs}];function Gt({user:t}){const[n,a]=pn.useState(!1),{logoutMutation:r}=gt(),{theme:s,setTheme:i}=ra(),o=vt();if(!t)return null;const l=t.name||t.email,g=st.find(m=>m.value===s)??st[2],h=g.icon;return e.jsxs(dn,{open:n,onOpenChange:a,children:[e.jsx(un,{asChild:!0,children:e.jsxs(A,{variant:"outline",size:"sm","aria-label":"Open account menu",className:D("justify-between gap-2 bg-muted/20 shadow-none hover:bg-muted/30",n&&"bg-muted/30"),children:[e.jsx(is,{className:"size-4"}),e.jsx("span",{className:"max-w-32 truncate text-sm font-medium",children:l}),e.jsx(ia,{className:"size-3.5 text-muted-foreground"})]})}),e.jsxs(mn,{align:"end",className:"w-64",children:[e.jsxs("div",{className:"px-2 py-1.5",children:[e.jsx("p",{className:"truncate text-sm font-semibold",children:t.name||t.email}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:t.email})]}),e.jsx(Mt,{}),e.jsxs(la,{children:[e.jsxs(ca,{className:"cursor-pointer",children:[e.jsx(h,{className:"mr-2 size-4"}),"Theme: ",g.label]}),e.jsx(da,{children:st.map(m=>e.jsxs(rt,{variant:"interactive",className:"cursor-pointer",onClick:()=>i(m.value),children:[e.jsx(m.icon,{className:"mr-2 size-4"}),m.label,s===m.value&&e.jsx(ua,{className:"ml-auto size-4"})]},m.value))})]}),!o&&e.jsxs(e.Fragment,{children:[e.jsx(Mt,{}),e.jsxs(rt,{variant:"interactive",className:"cursor-pointer",onClick:()=>r.mutate(),disabled:r.isPending,children:[e.jsx(ma,{className:"mr-2 size-4"}),r.isPending?"Logging out...":"Log out",e.jsx(ha,{children:"â§âQ"})]})]})]})]})}function eo({user:t,tenantMemberships:n,onboardingActive:a}){const{toggleSidebarOpen:r,isWide:s,sidebarWidth:i,collapsed:o,setCollapsed:l}=oa(),g=Zs(),h=pt(),m=fn(),c=gn({strict:!1}).tenant,{homeRoute:v}=In(c),C=!!m({to:N.tenantRoute.to,params:c?{tenant:c}:void 0,fuzzy:!0}),L=()=>
41{if(C&&c){h({to:v,params:{tenant:c}});return}h({to:N.authenticatedRoute.to})},z=()=>{if(!s){L();return}l(!o)},{isControlPlaneEnabled:F}=ke(),{tenant:P}=Ne(),R=!!t&&(n==null?void 0:n.length)>0&&!!P;return e.jsxs("header",{className:D("h-16 w-full bg-background",a?"z-[120]":"z-50"),children:[e.jsxs("div",{className:"flex h-16 items-center px-4 md:hidden",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(A,{variant:"icon",onClick:()=>r(),"aria-label":"Toggle sidebar",size:"icon",children:e.jsx(us,{className:"size-4"})}),e.jsx("button",{type:"button",onClick:L,"aria-label":"Go to Runs",className:"rounded-sm outline-none ring-offset-background focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:e.jsx(Re,{variant:"mark",className:"h-5 w-5"})})]}),e.jsxs("div",{className:"flex ml-auto items-center justify-end gap-2",children:[e.jsx(Vt,{}),R&&(F?e.jsx(Ft,{memberships:n}):e.jsx(Bt,{memberships:n})),e.jsx(Gt,{user:t})]})]}),e.jsxs("div",{className:"hidden h-16 md:grid md:grid-cols-[var(--v1-sidebar-width)_minmax(0,1fr)_auto] md:items-center",style:i?{"--v1-sidebar-width":`${i}px`}:void 0,children:[e.jsx("div",{className:D("flex h-16 items-center",o?"justify-center":"pl-6"),children:o?e.jsx("button",{type:"button",onClick:z,"aria-label":"Expand sidebar",className:"rounded-sm outline-none ring-offset-background focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:e.jsx(Re,{variant:"mark",className:"h-5 w-5"})}):e.jsxs("button",{type:"button",onClick:z,"aria-label":"Collapse sidebar",className:"flex items-center gap-2 rounded-sm outline-none ring-offset-background focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:[e.jsx(Re,{variant:"mark",className:"h-4 w-4"}),e.jsx(Re,{variant:"wordmark",className:"h-4 w-auto"})]})}),e.jsx("div",{className:"min-w-0 px-8",children:!a&&g.length>0&&e.jsx(Ba,{children:e.jsx(Wa,{children:g.map((I,w)=>e.jsxs(pn.Fragment,{children:[w>0&&e.jsx(Ha,{}),e.jsx(Ka,{children:I.isCurrentPage?e.jsx(Ua,{children:I.label}):e.jsx(Va,{asChild:!0,children:e.jsx(Le,{to:I.href,children:I.label})})})]},w))})})}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pr-4",children:[e.jsx(Vt,{}),R&&(F?e.jsx(Ft,{memberships:n}):e.jsx(Bt,{memberships:n})),e.jsx(Gt,{user:t})]})]})]})}const Qt=["mousedown","mousemove","keypress","scroll","touchstart","click"];function to(t={}){const{timeoutMs:n=-1,throttleMs:a=1e3,onInactive:r}=t,s=n>0,i=u.useRef(r);u.useEffect(()=>{i.current=r});const o=u.useRef(null),l=u.useRef(null),g=u.useCallback(()=>{o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{var m;(m=i.current)==null||m.call(i)},n)},[n]),h=u.useCallback(()=>{l.current||(l.current=setTimeout(()=>{l.current=null},a),g())},[a,g]);return u.useEffect(()=>{if(s)return g(),Qt.forEach(m=>{document.addEventListener(m,h,!0)}),()=>{o.current&&clearTimeout(o.current),l.current&&clearTimeout(l.current),Qt.forEach(m=>{document.removeEventListener(m,h,!0)})}},[s,n,a,g,h]),{}}const no={python:{name:"Python",installExample:"pip install hatchet-sdk",installAlternatives:"with Poetry that is `poetry add hatchet-sdk`, with uv `uv add hatchet-sdk`, with Pipenv `pipenv install hatchet-sdk`",frameworks:"FastAPI, Django or Flask",connect:"Create the client with `from hatchet_sdk import Hatchet` then `hatchet = Hatchet()`. It reads `HATCHET_CLIENT_TOKEN` from the environment.",refDoc:"https://docs.hatchet.run/llms/reference/python.md",embeddedLater:"For faster local iteration you can later use `Hatchet.from_embedded()` (a full engine in-process, no server or token). See https://docs.hatchet.run/llms/v1/embedded.md"},typescript:{name:"TypeScript",installExample:"npm install @hatchet-dev/typescript-sdk",installAlternatives:"with pnpm that is `pnpm add @hatchet-dev/typescript-sdk`, with Yarn `yarn add @hatchet-dev/typescript-sdk`, with Bun `bun add @hatchet-dev/typescript-sdk`",frameworks:"Next.js, Express or NestJS",connect:"Create the client with `import { Hatchet } from '@hatchet-dev/typescript-sdk'` then `const hatchet = Hatchet.init()`. It reads `HATCHET_CLIENT_TOKEN` from the environment.",refDoc:"https://docs.hatchet.run/llms/reference/typescript.md",embeddedLater:"For faster local iteration you can later use `HatchetEmbeddedClient.init()` from `@hatchet-dev/typescript-sdk/v1/embedded` (a full engine in-process, no server or token). See https://docs.hatchet.run/llms/v1/embedded.md"},go:{name:"Go",installExample:"go get github.com/hatchet-dev/hatchet/sdks/go",installAlternatives:"inside a Go workspace or a vendored module, follow that setup (for example run `go mod vendor` afterwards)",frameworks:"a net/http, Gin or Echo service",connect:"Create the client with `hatchet.NewClient()`. It reads `HATCHET_CLIENT_TOKEN` from the environment.",refDoc:"https://docs.hatchet.run/llms/reference/go.md",embeddedLater:"For faster local iteration you can later use `hatchet.WithEmbedded()` with a blank import of `github.com/hatchet-dev/hatchet-embedded` (a full engine in-process, no server or token). See https://docs.hatchet.run/llms/v1/embedded.md"}},Se="https://docs.hatchet.run/llms/v1",we={durable:{label:"Durable execution",description:"Long-running work that sleeps or waits for events and survives restarts.",guidance:"Durable execution: use a durable task with durable sleeps and/or wait-for-event steps so the work survives worker restarts and resumes where it left off.",doc:`${Se}/durable-execution.md`,docPath:"/v1/durable-execution"},dag:{label:"DAG / Pipeline",description:"Multi-step workflows where tasks depend on the output of earlier tasks.",guidance:"DAG / pipeline: model the work as a workflow of tasks with explicit parent dependencies, passing each parent output to the tasks that depend on it.",doc:`${Se}/directed-acyclic-graphs.md`,docPath:"/v1/directed-acyclic-graphs"}
41,background:{label:"Background task",description:"Offload work from a request path and run it reliably with retries.",guidance:"Background task: a task with typed input and output that my application triggers without waiting on it, with sensible retries and a timeout.",doc:`${Se}/running-your-task.md`,docPath:"/v1/running-your-task"},cron:{label:"Cron job",description:"Work that runs on a recurring schedule.",guidance:"Cron job: run the workflow on a cron schedule (start with every 5 minutes), and show me how to change the schedule and see upcoming runs.",doc:`${Se}/cron-runs.md`,docPath:"/v1/cron-runs"},event:{label:"Webhooks / Event-driven",description:"Workflows triggered by events you push or by incoming webhooks.",guidance:"Webhooks / event-driven: trigger the workflow from an event (choose a clear event key), include a small script that pushes a sample event, and if the source is an external service, receive it through a Hatchet webhook.",doc:`${Se}/events.md`,docPath:"/v1/events"}},yt=["durable","dag","background","cron","event"];function ao({sdk:t,patterns:n,description:a,profileName:r}){const s=no[t],i=Be(r),o=yt.filter(h=>n.includes(h)),l=o.map(h=>`- ${we[h].label}: ${we[h].doc}`).join(` 42`),g=o.length>0?["Build it with these Hatchet patterns:",...o.map(h=>`- ${we[h].guidance}`)].join(` 43`):"Pick the Hatchet features that fit. If it needs a schedule, an event trigger, a multi-step pipeline, or durability, use the matching feature and explain the choice briefly.";return`I'm building on Hatchet using the ${s.name} SDK. Hatchet is a task orchestration platform for running background tasks, workflows, schedules, and event-driven work. 44 45My setup is already done: the Hatchet CLI is installed and I have a CLI profile named "${i}" configured with an API token for this tenant. Use that profile by name for everything below (I may have other profiles pointing at other instances, so never rely on the default). 46 47First, confirm my CLI is recent enough for these commands: run \`hatchet profile env --help\`. If that is not a recognized command, my CLI is too old, so upgrade it by re-running the install script before continuing. 48 49Read the docs first. Hatchet's documentation is available as markdown files; fetch the ones you need before writing code: 50- Docs index (lists every page and its markdown URL): https://docs.hatchet.run/llms.txt 51- ${s.name} SDK reference: ${s.refDoc} 52- Quickstart: https://docs.hatchet.run/llms/v1/quickstart.md 53- Running your task: https://docs.hatchet.run/llms/v1/running-your-task.md${l?` 54${l}`:""} 55 56Fit into my project rather than around it. Look at this directory before writing anything: if there is already an application here (for example ${s.frameworks}), follow its layout, configuration and conventions and add Hatchet to it instead of scaffolding a separate project. If the directory is empty, start a minimal project. 57 58Then build the task below, connecting to my LIVE Hatchet instance (do not use a local or embedded engine for this first run): 59 601. Add the Hatchet SDK with the dependency manager this project already uses. For example: \`${s.installExample}\` (${s.installAlternatives}). Check for an existing manifest or lockfile first, and do not introduce a second package manager. 612. Connect to my instance. ${s.connect} Do not read, print, or hardcode my token. Load my credentials from the "${i}" CLI profile before running any Hatchet process, using this two-step form: \`env_block=$(hatchet profile env --name "${i}") || exit $?\` and then \`eval "$env_block"\`. Do not shorten it to a single \`eval "$(...)"\`: command substitution discards the exit code, so a failed profile lookup would silently leave stale or missing credentials. This exports HATCHET_CLIENT_TOKEN and the correct TLS setting for that profile's instance to the SDK, so you never handle the token directly. Run it in the same shell as every worker and script below. 623. Use the \`hatchet\` CLI throughout to check status and inspect runs as you go (run \`hatchet --help\` to discover the available commands). The exported variables are for the SDK only: the CLI does not read HATCHET_CLIENT_TOKEN, and without a profile it opens an interactive picker that fails in a non-interactive shell. So pass \`--profile "${i}"\` on every \`hatchet\` command that talks to my instance (for example \`hatchet worker list --profile "${i}"\` or \`hatchet runs list --profile "${i}"\`). 63 64Here is what I want to build: ${a.trim()} 65 66${g} 67 68Design the smallest Hatchet workflow in ${s.name} that accomplishes this. 69 70Finally, start a worker connected to my live instance and trigger a run. Confirm the run completes and instruct the user to navigate back to the dashboard when done. 71 72Once this works, if I want faster local iteration: ${s.embeddedLater}`}const so="hatchet:preferred-sdk",Tn="python";function qt(t){return typeof t=="string"&&t in kn?t:Tn}function oo(){const[t,n]=Ve(so,Tn);return[qt(t),a=>n(qt(a))]}const q="focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ring-offset-background",Sn="bg-muted ring-1 ring-border/50 rounded-lg p-0 gap-0.5 dark:bg-muted/20 dark:ring-inset",dt=`rounded-lg h-full text-muted-foreground data-[state=active]:ring-1 data-[state=active]:ring-border data-[state=active]:bg-background dark:data-[state=active]:bg-muted/70 dark:data-[state=active]:shadow-lg dark:ring-inset ${q}`;function ro({value:t,onChange:n}){return e.jsx(xn,{value:t,onValueChange:a=>n(a),className:"w-fit",children:e.jsx(bn,{className:Sn,children:Object.values(kn).map(a=>e.jsx(it,{value:a.value,className:dt,children:a.label},a.value))})})}const io="data-[state=unchecked]:hover:border-brand/50 data-[state=checked]:border-brand data-[state=checked]:hover:border-brand data-[state=checked]:bg-brand/10",Yt={path:"Choose path",usecase:"Use case & SDK",setup:"Set up CLI",runagent:"Run agent",runtask:"Run task",finish:"Finish"},fe="https://docs.hatchet.run",lo={python:{label:"Python SDK reference",href:`${fe}/reference/python`},typescript:{label:"TypeScript SDK reference",href:`${fe}/reference/typescript`},go:{label:"Go SDK reference",href:`${fe}/reference/go`}},co={simple:{label:"Running your task",href:`${fe}/v1/running-your-task`},scheduled:{label:"Scheduled runs",href:`${fe}/v1/scheduled-runs`}};function uo({sdk:t,useCase:n,patterns:a,path:r}){const s=[lo[t]];return r==="agent"?(yt.filter(i=>
72a.includes(i)).forEach(i=>s.push({label:we[i].label,href:`${fe}${we[i].docPath}`})),s.push({label:"MCP server reference",href:`${fe}/reference/cli/mcp`})):s.push(co[n]),s.push({label:"Embedded mode for local iteration",href:`${fe}/v1/embedded`}),s}const le="bg-muted/20 ring-1 ring-border/50 ring-inset px-1";function Ae({done:t,waiting:n,ready:a}){return e.jsx("div",{className:"flex items-center gap-3 rounded-lg border border-border/50 bg-muted/20 p-4",children:a?e.jsxs(e.Fragment,{children:[e.jsx(pa,{className:"size-5 text-foreground"}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:t})]}):e.jsxs(e.Fragment,{children:[e.jsx(Xe,{className:"size-5"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:n})]})})}function mo(t){return t==="agent"?["path","usecase","setup","runagent","finish"]:t==="manual"?["path","usecase","setup","runtask","finish"]:["path"]}function ho({tenantName:t,tenantId:n,path:a,step:r,onNavigate:s,patterns:i,onPatternsChange:o,description:l,onDescriptionChange:g,sdk:h,onSdkChange:m,useCase:j,onUseCaseChange:c,onConfirmSelection:v,profileToken:C,isGeneratingProfileToken:L,profileTokenError:z,onGenerateProfileToken:F,canGenerateToken:P,hasApiToken:R,authDisabled:I,authDisabledToken:w,progress:k,onFinish:H,onPromptGenerated:G,onStepChangeEvent:Y}){const B=(t==null?void 0:t.trim())||"local",[y,p]=u.useState(Te.native.value),E=u.useMemo(()=>mo(a),[a]),M=r&&E.includes(r)?r:E[0],_=a==="agent"&&l.trim().length===0&&E.indexOf(M)>E.indexOf("usecase")?"usecase":M,X=_!=="path"&&_!=="usecase";u.useEffect(()=>{X&&v()},[X]);const se=(f,te=a)=>{f!=="path"&&f!=="usecase"&&v(),f!==_&&(Y==null||Y(Yt[f])),s({path:te,step:f})},K=f=>{se("usecase",f)},O=u.useMemo(()=>ao({sdk:h,patterns:i,description:l,profileName:B}),[h,i,l,B]),oe=e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"text-sm font-medium",children:"Optional: install the Hatchet MCP"}),e.jsx(ie,{className:le,code:"hatchet mcp install",language:"shell",copy:!0})]}),b=D("inline-flex w-fit items-center gap-1 text-sm underline hover:text-foreground",q),T=k.completedRun&&n?e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:[e.jsxs(Le,{to:N.tenantRunRoute.to,params:{tenant:n,run:k.completedRun.runId},target:"_blank",rel:"noopener noreferrer",className:b,children:["View the task run",e.jsx(et,{className:"size-3"})]}),k.completedRun.workerId?e.jsxs(Le,{to:N.tenantWorkerRoute.to,params:{tenant:n,worker:k.completedRun.workerId},target:"_blank",rel:"noopener noreferrer",className:b,children:["View the worker",e.jsx(et,{className:"size-3"})]}):null]}):null,re={usecase:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-sm font-medium",children:"What are you building?"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"We'll customize your prompt for getting your co
72ding agent onboarded."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"SDK"}),e.jsx(ro,{value:h,onChange:m})]}),a==="manual"?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Template"}),e.jsx(ts,{value:j,onValueChange:f=>c(f),className:"grid-cols-1 gap-3 lg:grid-cols-2",children:Object.values(Ja).map(f=>e.jsx(ns,{value:f.value,className:io,children:e.jsxs("div",{children:[e.jsx("span",{className:"block text-sm font-medium",children:f.label}),e.jsx("span",{className:"mt-1 block text-sm text-muted-foreground",children:f.description})]})},f.value))})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("p",{id:"onboarding-patterns",className:"text-sm font-medium",children:"Patterns"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pick any that apply. Your agent will build with these Hatchet features."})]}),e.jsx("div",{role:"group","aria-labelledby":"onboarding-patterns",className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:yt.map(f=>{const te=i.includes(f);return e.jsxs("button",{type:"button","aria-pressed":te,onClick:()=>o(te?i.filter(ae=>ae!==f):[...i,f]),className:D("rounded-lg border p-4 text-left",q,te?"border-brand bg-brand/10":"border-border/50 bg-muted/20 hover:border-brand/50"),children:[e.jsx("span",{className:"block text-sm font-medium",children:we[f].label}),e.jsx("span",{className:"mt-1 block text-sm text-muted-foreground",children:we[f].description})]},f)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"onboarding-description",className:"text-sm font-medium",children:"Describe your use case"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Required. The more specific you are, the better the first result."})]}),e.jsx(ga,{id:"onboarding-description",value:l,onChange:f=>g(f.target.value),placeholder:"e.g. process uploaded CSVs and email a summary when done",rows:3,className:q})]})]})]}),setup:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Set up the CLI"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Install the CLI and connect a profile to this tenant."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"text-sm font-medium",children:"Install the CLI"}),e.jsxs(xn,{value:y,onValueChange:f=>p(f),className:"w-full",children:[e.jsxs(bn,{className:D("mt-2",Sn),children:[e.jsx(it,{value:Te.native.value,className:dt,children:"curl"}),e.jsx(it,{value:Te.homebrew.value,className:dt,children:"Homebrew"})]}),e.jsxs(_t,{value:Te.native.value,className:`mt-4 space-y-3 rounded-sm ${q}`,children:[e.jsx("p",{className:"text-sm",children:e.jsx("b",{children:"MacOS, Linux, WSL"})}),e.jsx(ie,{className:le,code:"curl -fsSL https://install.hatchet.run/install.sh | bash",language:"shell",copy:!0})]}),e.jsxs(_t,{value:Te.homebrew.value,className:`mt-4 space-y-3 rounded-sm ${q}`,children:[e.jsx("p",{className:"text-sm",children:e.jsx("b",{children:"MacOS"})}),e.jsx(ie,{className:le,code:"brew install hatchet-dev/hatchet/hatchet --cask",language:"shell",copy:!0})]})]}),e.jsx("p",{className:"text-sm",children:"Confirm it installed:"}),e.jsx(ie,{className:le,code:"hatchet --version",language:"shell",copy:!0})]}),e.jsxs("div",{className:"space-y-3 border-t border-border/50 pt-4",children:[e.jsx("h4",{className:"text-sm font-medium",children:"Set up your profile"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"A profile connects the CLI to this tenant."}),I?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm",children:"Auth is disabled on this instance, so use the built-in token below."}),e.jsx(ie,{className:le,code:`hatchet profile add --name "${Be(B)}" --token "${w??"<token>"}"`,language:"shell",copy:!0})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(A,{variant:"outline",size:"default",className:D("w-fit gap-2",q),onClick:F,disabled:L||!P,children:[L&&e.jsx(Xe,{}),"Generate a token for this command"]}),C&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"This token is only shown once. Copy it now."})]}),z&&e.jsx("div",{className:"text-sm text-red-500",children:z}),R&&!C&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"This tenant already has an API token. If this machine does not have a CLI profile for it yet, generate a token above and run the command it gives you."}),C&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm",children:"The
72n run:"}),e.jsx(ie,{className:le,code:`hatchet profile add --name "${Be(B)}" --token "${Be(C)}"`,language:"shell",copy:!0})]})]})]})]}),path:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-1",children:e.jsx("h3",{className:"text-sm font-medium",children:"Choose your preferred setup"})}),e.jsxs("div",{className:"rounded-lg border border-brand/60 bg-brand/5 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(os,{className:"mt-0.5 size-6 shrink-0 text-brand"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h4",{className:"text-sm font-medium",children:"With your coding agent (recommended)"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Let your coding agent scaffold, run, and debug for you."})]})]}),e.jsxs(A,{variant:"default",size:"sm",className:D("w-fit gap-2",q),onClick:()=>K("agent"),children:["Set up my agent",e.jsx(tt,{className:"size-3"})]})]}),e.jsxs("div",{className:"rounded-lg border border-border/50 bg-muted/20 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(vs,{className:"mt-0.5 size-5 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h4",{className:"text-sm font-medium",children:"Manual setup"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Scaffold a project, start a worker, and run a task yourself."})]})]}),e.jsx(A,{variant:"secondary",size:"sm",className:D("w-fit gap-2",q),onClick:()=>K("manual"),children:"Manual setup"})]})]}),runagent:e.jsxs(e.Fragment,{children:[oe,e.jsxs("div",{className:"space-y-1 border-t border-border/50 pt-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Run your agent"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Here's a sample prompt for your coding agent. You can customize it to fit your needs."})]}),e.jsx(ie,{className:`${le} whitespace-pre-wrap`,code:O,language:"text",maxHeight:"220px",copy:!0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No need to refresh, we're watching for your worker and run."}),e.jsx(Ae,{ready:k.workerConnected,done:"Worker connected",waiting:"Waiting for a worker to connect..."}),e.jsx(Ae,{ready:k.runCompleted,done:"Task run completed",waiting:"Waiting for a task to run..."}),T]}),runtask:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Run a task"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Scaffold a project, start a worker, then trigger a run and watch it complete."})]}),e.jsx("p",{className:"text-sm",children:"Scaffold the project:"}),e.jsx(ie,{className:le,code:qa({useCase:j,language:h}),language:"shell",copy:!0}),e.jsx("p",{className:"text-sm",children:"Start a dev worker:"}),e.jsx(ie,{className:le,code:Ya(B),language:"shell",copy:!0}),e.jsx(Ae,{ready:k.workerConnected,done:"Worker connected",waiting:"Waiting for the worker to connect..."}),e.jsx("p",{className:"text-sm",children:"Trigger a run:"}),e.jsx(ie,{className:le,code:Xa(j,B),language:"shell",copy:!0}),e.jsx(Ae,{ready:k.runCompleted,done:"Run completed",waiting:"Waiting for the run to complete..."}),T]}),finish:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-sm font-medium",children:"You're set up"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your worker is connected and running tasks against this tenant."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"text-sm font-medium",children:"Learn more"}),e.jsx("ul",{className:"space-y-2",children:uo({sdk:h,useCase:j,patterns:i,path:a}).map(f=>e.jsx("li",{children:e.jsxs("a",{href:f.href,target:"_blank",rel:"noopener noreferrer",className:"inline-flex w-fit items-center gap-1 text-sm underline hover:text-foreground",children:[f.label,e.jsx(et,{className:"size-3"})]})},f.href))})]})]})},ne=E.indexOf(_),d=E[ne+1],S=()=>{const f=E[ne-1];f&&s({path:a,step:f})},U=()=>{d&&(d==="runagent"&&G(i,h),se(d))},J=f=>{switch(f){case"usecase":return a==="manual"||l.trim().length>0;case"setup":return R;case"runagent":case"runtask":return k.runCompleted;default:return!0}},Z=J(_),Oe=E.findIndex(f=>!J(f)),Je=Oe===-1?E.length-1:Oe,ee=_!=="path"&&_!=="finish"&&!!d&&Z;return e.jsxs("div",{className:"space-y-4",children:[e.jsx("ol",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground",children:E.map((f,te)=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>se(f),disabled:te>Je,"aria-current":f===_?"step":void 0,className:D("font-medium transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:text-muted-foreground",q,f===_&&"text-foreground font-semibold",f!==_&&te<ne&&"text-foreground"),children:[te+1,". ",Yt[f]]})},f))}),e.jsxs("div",{className:"rounded-md p-4 bg-muted/20 ring-1 ring-border/50 ring-inset space-y-4",children:[re[_],e.jsxs("div",{className:"flex items-center justify-between border-t border-border/50 pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ga,{icon:e.jsx(cs,{className:"size-5 text-foreground"}),align:"start",side:"top",className:"text-muted-foreground"}),ne>0&&e.jsxs(A,{variant:"ghost",size:"sm",className:`gap-1 text-muted-foreground ${q}`,onClick:S,children:[e.jsx(fa,{className:"size-3"}),"Back"]}),a==="manual"&&_!=="finish"&&e.jsx(A,{variant:"ghost",size:"sm",className:`text-muted-foreground underline ${q}`,onClick:()=>K("agent"),children:"Switch to the agent setup"})]}),ee&&e.jsxs(A,{variant:"default",size:"sm",className:D("gap-1",q),onClick:U,children:["Next",e.jsx(tt,{className:"size-3"})]}),_==="finish"&&e.jsxs(A,{variant:"default",size:"sm",className:D("gap-1",q),disabled:!k.runCompleted,hoverText:k.runCompleted?void 0:"Waiting for a worker to connect and execute a task.",onClick:H,children:["Start exploring",e.jsx(tt,{className:"size-3"})]})]})]})]})}const go=["worker:list","v1:workflow-run:list","v1:task-run:metrics","v1-task:metrics","queue-metrics:get:step-run"],Xt=`${100*365*24*60*60}s`,fo=t=>`hatchet:onboarding-agent:${t}`;function po({onClose:t,path:n,step:a,onNavigate:r}){var O,oe;const{tenant:s,tenantId:i}=Ne(),{currentUser:o}=ft(),l=vt(),{meta:g}=vn(),h=g&&"authDisabledToken"in g?g.authDisabledToken:void 0,{capture:m}=bt(),j=xa(),c=ut(),[v,C]=oo(),[L,z]=u.useState(),[F,P]=u.useState(),R=u.useRef(null),[I,w]=Ve(Za(i??"unknown"),null),k=u.useMemo(()=>at(I),[I]),[H,G]=Ve(fo(i??"unknown"),{}),Y=()=>w(b=>{const T=at(b);
72return T.selectionConfirmedAt?T:{...T,selectionConfirmedAt:new Date().toISOString()}}),B=as(i,k.selectionConfirmedAt??void 0),p=(((oe=(O=V({...de.tokens.list(i??""),enabled:!!i,refetchInterval:b=>{var T,re;return(((re=(T=b.state.data)==null?void 0:T.rows)==null?void 0:re.length)??0)>0?!1:2e3}}).data)==null?void 0:O.rows)==null?void 0:oe.length)??0)>0||!!L||l,E=u.useCallback(()=>{go.forEach(b=>{c.invalidateQueries({queryKey:[b]})}),t()},[c,t]),M=u.useMemo(()=>{var T;const b=(T=o==null?void 0:o.name)==null?void 0:T.trim();return b?`${b}'s token`:""},[o==null?void 0:o.name]),Q=Pe({mutationKey:["api-token:create:profile",i],mutationFn:async b=>(await xt.apiTokenCreate(i,b)).data,onSuccess:b=>{z(b.token),P(void 0),c.invalidateQueries({queryKey:["api-token:list"]}),m("onboarding_token_generated",{tenant_id:i,user_email:o==null?void 0:o.email,token_name:`${M||"Local"} (CLI profile)`,expires_in:Xt,source:"onboarding_modal_profile_step"})},onError:()=>{P("Failed to generate token. Please try again.")}}),_=()=>{P(void 0),Q.mutate({name:M?`${M} (CLI)`:"CLI token",expiresIn:Xt})},X=b=>{C(b),m("onboarding_language_selected",{tenant_id:i,user_email:o==null?void 0:o.email,language:b,source:"onboarding_modal"})},se=b=>{w(T=>es(at(T),b)),m("onboarding_use_case_selected",{tenant_id:i,user_email:o==null?void 0:o.email,use_case:b,source:"onboarding_modal"})},K=u.useRef(!1);return u.useEffect(()=>{K.current||(K.current=!0,m("onboarding_modal_opened",{tenant_id:i,user_email:o==null?void 0:o.email}))},[m,i,o==null?void 0:o.email]),u.useEffect(()=>{var b;(b=R.current)==null||b.focus()},[]),u.useEffect(()=>{const b=T=>{T.key!=="Escape"||T.defaultPrevented||(T.preventDefault(),E())};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[E]),e.jsx("div",{ref:R,role:"dialog","aria-label":"Run your first task",tabIndex:-1,className:"absolute inset-0 z-[110] overflow-y-auto bg-background outline-none",children:e.jsx("div",{className:"flex min-h-full items-center justify-center p-6",children:e.jsxs("div",{className:"flex w-full flex-col items-center",children:[e.jsx(ln,{title:"Run your first task",description:"Connect a locally running worker and run your first task.",className:"max-w-3xl",children:e.jsx(ho,{tenantName:s==null?void 0:s.name,tenantId:i,path:n,step:a,onNavigate:r,patterns:H.patterns??[],onPatternsChange:b=>G(T=>({...T,patterns:b})),description:H.description??"",onDescriptionChange:b=>G(T=>({...T,description:b})),sdk:v,onSdkChange:X,useCase:k.useCase,onUseCaseChange:se,onConfirmSelection:Y,profileToken:L,isGeneratingProfileToken:Q.isPending,profileTokenError:F,onGenerateProfileToken:_,canGenerateToken:j,hasApiToken:p,authDisabled:l,authDisabledToken:h,progress:B,onFinish:E,onPromptGenerated:(b,T)=>{m("onboarding_prompt_generated",{tenant_id:i,user_email:o==null?void 0:o.email,patterns:b,sdk:T,source:"onboarding_modal"})},onStepChangeEvent:b=>{m("onboarding_tab_changed",{tenant_id:i,user_email:o==null?void 0:o.email,tab:b,source:"onboarding_modal"})}})}),e.jsx("div",{className:"mt-4 flex justify-center",children:e.jsx(A,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:E,hoverText:"Your progress is saved. You can reopen this anytime from the overview page.",children:"Skip for now"})})]})})})}async function Vo(t){const{isControlPlaneEnabled:n}=await Ia();return await lt.fetchQuery(La(n)),{isControlPlaneEnabled:n}}function xo(){var Nt,Ct,It,Tt,St,Et;const{tenant:t,organizationId:n}=Ne(),{meta:a}=vn(),{capture:r}=bt(),{currentUser:s,error:i,isLoading:o}=ft(),[l,g]=ba(Ta),[h,m]=u.useState(()=>{try{return localStorage.getItem("auth-disabled-banner-dismissed")==="true"}catch{return!1}}),[j,c]=u.useState(!1),[v,C]=u.useState(!1),[L,z]=u.useState(),[F,P]=u.useState([]),[R,I]=u.useState(),[w,k]=u.useState(),[H,G]=u.useState(!1),[Y,B]=u.useState(!1),y=va({from:"/"}),p=pt(),E=ya({from:ja.id,shouldThrow:!1}),M=E==null?void 0:E.params.tenant,Q=!!E,_=u.useCallback(({path:x,step:$})=>{M&&p({to:N.tenantOnboardingRoute.to,params:{tenant:M},search:{...x?{path:x}:{},step:$}})},[p,M]),X=u.useCallback(()=>{M&&p({to:N.tenantOverviewRoute.to,params:{tenant:M}})},[p,M]),K=hn().pathname,O=fn(),oe=!!O({to:N.authLoginRoute.to})||!!O({to:N.authRegisterRoute.to}),b=!!O({to:N.tenantRoute.to,fuzzy:!0}),T=!!O({to:N.organizationsRoute.to,fuzzy:!0}),re=!!O({to:N.tenantsRoute.to}),ne=!!O({to:N.onboardingVerifyRoute.to}
72),d=!!O({to:N.onboardingInvitesRoute.to}),S=!!O({to:N.onboardingCreateTenantRoute.to}),U=!!O({to:N.onboardingCreateOrganizationRoute.to}),J=!!O({to:N.onboardingNoTenantsRoute.to}),Z=ne||d||S||U||J,{userUpdateLogoutMutation:Oe}=wa(),Je=Pe({...Oe(),onSettled:()=>{lt.clear(),p({to:N.authLoginRoute.to})}}),{pendingInvitesQuery:ee}=jn(),{isLoaded:f,isFetching:te,organizations:ae,tenantMemberships:W}=gt(),{canBill:jt,isControlPlaneEnabled:xe}=ke(),En=mt(),wt=(Ct=(Nt=ae==null?void 0:ae.find(x=>{var $;return($=x.tenants)==null?void 0:$.some(be=>{var ue;return be.id===((ue=t==null?void 0:t.metadata)==null?void 0:ue.id)})}))==null?void 0:Nt.metadata)==null?void 0:Ct.id,Rn=V({...En.organizationGetQuery(wt),enabled:!!wt&&xe}),Ln=xe?((It=Rn.data)==null?void 0:It.inactivity_timeout)??-1:-1,me=V({...de.controlPlane.billing(n||""),enabled:xe&&jt&&!!n,retry:!1});to({timeoutMs:Ln,onInactive:()=>{Je.mutate()}});const Pn=Qa({user:s,memberships:W});u.useEffect(()=>{var Ce;const x=i,$=()=>{K!=="/"&&!K.startsWith("/onboarding/")&&!K.startsWith("/auth/")&&sessionStorage.setItem(nt,K)};if(T||re)return;if(!o&&!s&&!oe){$(),p({to:N.authLoginRoute.to,replace:!0});return}if((x==null?void 0:x.status)===401||(x==null?void 0:x.status)===403){$(),p({to:N.authLoginRoute.to,replace:!0});return}if(s&&!s.emailVerified&&!ne){p({to:N.onboardingVerifyRoute.to,replace:!0});return}const be=ee.isSuccess?ee.data:null,ue=ee.isSuccess&&!Z&&f&&!te,Me=xe&&f&&(ae==null?void 0:ae.length)===0,_e=ue&&((W==null?void 0:W.length)??0)===0&&be&&be.inviteCount>0;if(!d&&_e){p({to:N.onboardingInvitesRoute.to,replace:!0});return}else if(ue&&Me){$(),p({to:N.onboardingCreateOrganizationRoute.to,replace:!0});return}else if(ue&&xe&&ae&&ae.length>0&&W.length===0){$(),p({to:N.onboardingNoTenantsRoute.to,replace:!0});return}else if(ue&&W.length===0){$(),p({to:N.onboardingCreateTenantRoute.to,replace:!0});return}if(K==="/"&&W&&W.length>0){const Rt=sessionStorage.getItem(nt);if(Rt){sessionStorage.removeItem(nt),p({to:Rt,replace:!0});return}const Ze=l==null?void 0:l.metadata.id,Lt=Ze?(Ce=W.find(ze=>{var $e;return(($e=ze.tenant)==null?void 0:$e.metadata.id)===Ze}))==null?void 0:Ce.tenant:void 0;Ze&&!Lt&&(g(void 0),y.isControlPlaneEnabled&&localStorage.removeItem(zt));const Ie=Lt??W[0].tenant;Ie&&(y.isControlPlaneEnabled&&localStorage.setItem(zt,JSON.stringify(Ie)),xt.workflowList(Ie.metadata.id,{limit:1}).then(ze=>{const $e=ze.data.rows&&ze.data.rows.length>0;p({to:$e?N.tenantRunsRoute.to:N.tenantOverviewRoute.to,params:{tenant:Ie.metadata.id},replace:!0})}).catch(()=>{p({to:N.tenantRunsRoute.to,params:{tenant:Ie.metadata.id},replace:!0})}))}},[t==null?void 0:t.metadata.id,s,ee,W,t==null?void 0:t.version,i,o,p,l,K,T,re,ne,d,Z,oe,g,xe,f,te,ae,U,S,y.isControlPlaneEnabled]),u.useEffect(()=>je.on("create-new-tenant",({defaultOrganizationId:x,allTenantTags:$})=>{z(x),P($??[]),c(!0)}),[]),u.useEffect(()=>je.on("create-tenant-invite",x=>{I(x)}),[]),u.useEffect(()=>je.on("create-organization-invite",({organizationId:x,organizationName:$})=>{k({organizationId:x,organizationName:$})}),[]),u.useEffect(()=>je.on("open-invite-modal",()=>{B(!0)}),[]);const kt=(((Tt=V({...de.tenantResourcePolicy.get((t==null?void 0:t.metadata.id)??""),refetchInterval:2*6e4,enabled:xe&&jt&&!!(t!=null&&t.metadata.id)}).data)==null?void 0:Tt.limits)??[]).some(x=>wn(x)!=="ok");return u.useEffect(()=>{var _e,Ce;if(!kt||!n||Q||me.isPending)return;const x=me.error,$=(x==null?void 0:x.status)===404||((_e=x==null?void 0:x.response)==null?void 0:_e.status)===404;if(me.isError&&!$)return;const be=$||(Ce=me.data)==null?void 0:Ce.currentSubscription,ue=!be||be.plan===on.Free,Me=Ea(n);!ue||localStorage.getItem(Me)||(localStorage.setItem(Me,new Date().toISOString()),G(!0),r("welcome_modal_shown",{tenant_id:t==null?void 0:t.metadata.id,source:"approaching_limit"}))},[t==null?void 0:t.metadata.id,n,r,kt,Q,(St=me.data)==null?void 0:St.currentSubscription,me.error,me.isError,me.isPending]),u.useEffect(()=>{var x;!d&&ee.isSuccess&&!ee.isFetching&&(((x=ee.data)==null?void 0:x.inviteCount)??0)>0&&((W==null?void 0:W.length)??0)>0&&B(!0)},[ee.isSuccess,ee.isFetching,(Et=ee.data)==null?void 0:Et.invite
72Count,d,W==null?void 0:W.length]),s?e.jsxs(Na,{user:s,children:[e.jsx(ws,{banner:a&&"authDisabled"in a&&a.authDisabled&&!h?e.jsx(ks,{onDismiss:()=>{try{localStorage.setItem("auth-disabled-banner-dismissed","true")}catch{}m(!0)}}):void 0,header:e.jsx(eo,{user:s,tenantMemberships:W||[],onboardingActive:Q}),overlay:E?e.jsx(po,{path:E.search.path??null,step:E.search.step,onNavigate:_,onClose:X},M):void 0,footer:void 0,contentScroll:!b,children:e.jsx(Ca,{context:Pn})}),e.jsx(Qe,{open:j,onOpenChange:x=>{c(x),x||C(!1)},children:e.jsxs(qe,{className:D(rn,"max-h-[85vh] overflow-y-auto",v?"max-w-2xl":"max-w-xl"),children:[e.jsx(Ye,{className:"sr-only",children:v?"Upgrade to Pay as you Go":"Create a new tenant"}),e.jsx(Sa,{framed:!0,defaultOrganizationId:L,allTenantTags:F,onGateChange:C,onUpgradeNavigate:()=>{z(void 0),P([]),C(!1),c(!1)},afterSave:x=>{z(void 0),P([]),c(!1);const $=x.type==="cloud"?x.tenant.id:x.tenant.metadata.id;x.type==="cloud"&<.prefetchQuery(de.controlPlane.subscriptionPlans()),p({to:N.tenantOverviewRoute.to,params:{tenant:$}})}})]})}),R&&e.jsx(Is,{tenantId:R.tenantId,organizationId:R.organizationId,defaultEmail:R.defaultEmail,onClose:()=>I(void 0),onCreated:(x,$)=>{je.emit("tenant-invite-created",{tenantId:x,invite:$})}}),w&&e.jsx(Ss,{organizationId:w.organizationId,organizationName:w.organizationName,onClose:()=>k(void 0),onCreated:x=>{je.emit("organization-invite-created",{organizationId:w.organizationId,invite:x})}}),e.jsx(Rs,{tenantId:t==null?void 0:t.metadata.id,organizationId:n,open:H,onClose:()=>G(!1)}),e.jsx(Ra,{isOpen:Y,onClose:()=>B(!1)})]}):e.jsx(ka,{})}function Go(){return e.jsx(xo,{})}export{Go as default,Vo as loader}; 73//# sourceMappingURL=authenticated-DzLqRUXS.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.