diff --git a/spinifex/services/spinifexui/frontend/dist/assets/_id7.js b/spinifex/services/spinifexui/frontend/dist/assets/_id7.js index 2d850f2c6..15dbb9240 100644 --- a/spinifex/services/spinifexui/frontend/dist/assets/_id7.js +++ b/spinifex/services/spinifexui/frontend/dist/assets/_id7.js @@ -1 +1 @@ -import{n as e,o as t,r as n,t as r}from"./compiler-runtime.js";import{t as i}from"./useNavigate.js";import{$t as a,nn as o}from"./auth.js";import{t as s}from"./createLucideIcon.js";import{c,i as l,n as u,s as d,t as f}from"./select.js";import{t as p}from"./trash-2.js";import{t as m}from"./button.js";import{t as h}from"./certificate-import-dialog.js";import{O as g,w as _}from"./ec2.js";import{_ as v,a as y,d as b,f as x,g as S,h as C,o as w,r as T,s as E,t as D,u as O}from"./elbv2.js";import{i as k,n as A,o as j,r as M,s as N,t as P,u as F}from"./elbv22.js";import{Ln as I,Qt as L,Xn as R,_n as ee,en as z,fn as te,gn as B,hn as V,l as H,ln as U,mn as ne,nn as W,on as G,pn as re,vn as ie}from"./index.js";import{a as K,i as q,l as J,n as Y,o as ae,r as oe,s as se,t as ce}from"./alert-dialog.js";import{t as le}from"./delete-confirmation-dialog.js";import{n as X,t as Z}from"./detail-row.js";import{t as ue}from"./state-badge.js";import{c as de,i as fe,n as pe,o as me,s as he,t as ge}from"./elbv23.js";import{n as _e,r as ve,t as ye}from"./tags-editor.js";import{i as be,n as xe,r as Se,t as Ce}from"./tabs.js";var we=s(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),Te=r(),Q=t(n(),1),$=e(),Ee=80,De=443;function Oe(e){let t=e.CertificateArn?.split(`/`).pop()??e.CertificateArn??``;return e.DomainName?`${e.DomainName} · ${t}`:t}function ke(e){let t=(0,Te.c)(59),{form:n,protocols:r,targetGroups:i,certificates:a,sslPolicies:o}=e,s;t[0]===a?s=t[1]:(s=a===void 0?[]:a,t[0]=a,t[1]=s);let l=s,p;t[2]===o?p=t[3]:(p=o===void 0?[]:o,t[2]=o,t[3]=p);let g=p,{control:_,register:v,getValues:y,setValue:b,formState:x}=n,{errors:S}=x,[C,w]=(0,Q.useState)(!1),T;t[4]===_?T=t[5]:(T={control:_,name:`protocol`},t[4]=_,t[5]=T);let E=ee(T),D=E===`HTTPS`,O;t[6]===E?O=t[7]:(O=he(E),t[6]=E,t[7]=O);let k=O,A;t[8]!==y||t[9]!==b?(A=e=>{if(!e)return;let t=y(`port`);he(e)?(t===Ee&&b(`port`,De),e===`HTTPS`?y(`sslPolicy`)||b(`sslPolicy`,ge):b(`sslPolicy`,void 0)):(t===De&&b(`port`,Ee),b(`certificateArn`,void 0),b(`sslPolicy`,void 0))},t[8]=y,t[9]=b,t[10]=A):A=t[10];let j=A,M;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(W,{children:(0,$.jsx)(`label`,{htmlFor:`listener-protocol`,children:`Protocol`})}),t[11]=M):M=t[11];let N;t[12]!==j||t[13]!==r?(N=e=>{let{field:t}=e;return(0,$.jsxs)(f,{onValueChange:e=>{t.onChange(e),j(e)},value:t.value,children:[(0,$.jsx)(d,{className:`w-full`,id:`listener-protocol`,children:(0,$.jsx)(c,{})}),(0,$.jsx)(u,{children:r.map(Ne)})]})},t[12]=j,t[13]=r,t[14]=N):N=t[14];let P;t[15]!==_||t[16]!==N?(P=(0,$.jsxs)(L,{children:[M,(0,$.jsx)(ne,{control:_,name:`protocol`,render:N})]}),t[15]=_,t[16]=N,t[17]=P):P=t[17];let F;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(W,{children:(0,$.jsx)(`label`,{htmlFor:`listener-port`,children:`Port`})}),t[18]=F):F=t[18];let R=!!S.port,te=k?`443`:`80`,B;t[19]===v?B=t[20]:(B=v(`port`,{valueAsNumber:!0}),t[19]=v,t[20]=B);let V;t[21]!==R||t[22]!==te||t[23]!==B?(V=(0,$.jsx)(I,{"aria-invalid":R,id:`listener-port`,inputMode:`numeric`,placeholder:te,type:`number`,...B}),t[21]=R,t[22]=te,t[23]=B,t[24]=V):V=t[24];let H;t[25]===S.port?H=t[26]:(H=(0,$.jsx)(z,{errors:[S.port]}),t[25]=S.port,t[26]=H);let U;t[27]!==V||t[28]!==H?(U=(0,$.jsxs)(L,{children:[F,V,H]}),t[27]=V,t[28]=H,t[29]=U):U=t[29];let G;t[30]!==l||t[31]!==_||t[32]!==S.certificateArn||t[33]!==C||t[34]!==D||t[35]!==k||t[36]!==b||t[37]!==g?(G=k&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(L,{children:[(0,$.jsx)(W,{children:(0,$.jsx)(`label`,{htmlFor:`listener-certificate`,children:`Certificate`})}),(0,$.jsx)(ne,{control:_,name:`certificateArn`,render:e=>{let{field:t}=e;return(0,$.jsxs)(f,{onValueChange:t.onChange,value:t.value??``,children:[(0,$.jsx)(d,{"aria-invalid":!!S.certificateArn,className:`w-full`,id:`listener-certificate`,children:(0,$.jsx)(c,{placeholder:`Select certificate`})}),(0,$.jsx)(u,{children:l.map(Me)})]})}}),(0,$.jsx)(z,{errors:[S.certificateArn]}),(0,$.jsxs)(`div`,{className:`mt-1 flex items-center justify-between`,children:[l.length===0&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No certificates imported yet.`}),(0,$.jsx)(m,{className:`ml-auto`,onClick:()=>w(!0),size:`sm`,type:`button`,variant:`ghost`,children:`Import certificate…`})]})]}),D&&(0,$.jsxs)(L,{children:[(0,$.jsx)(W,{children:(0,$.jsx)(`label`,{htmlFor:`listener-ssl-policy`,children:`Security policy`})}),(0,$.jsx)(ne,{control:_,name:`sslPolicy`,render:e=>{let{field:t}=e;return(0,$.jsxs)(f,{onValueChange:t.onChange,value:t.value??`ELBSecurityPolicy-2016-08`,children:[(0,$.jsx)(d,{className:`w-full`,id:`listener-ssl-policy`,children:(0,$.jsx)(c,{})}),(0,$.jsx)(u,{children:g.map(je)})]})}})]}),(0,$.jsx)(h,{onImported:e=>b(`certificateArn`,e,{shouldValidate:!0}),onOpenChange:w,open:C})]}),t[30]=l,t[31]=_,t[32]=S.certificateArn,t[33]=C,t[34]=D,t[35]=k,t[36]=b,t[37]=g,t[38]=G):G=t[38];let re;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(W,{children:(0,$.jsx)(`label`,{htmlFor:`listener-default-tg`,children:`Default target group`})}),t[39]=re):re=t[39];let ie;t[40]!==S.defaultTargetGroupArn||t[41]!==i?(ie=e=>{let{field:t}=e;return(0,$.jsxs)(f,{onValueChange:t.onChange,value:t.value??``,children:[(0,$.jsx)(d,{"aria-invalid":!!S.defaultTargetGroupArn,className:`w-full`,id:`listener-default-tg`,children:(0,$.jsx)(c,{placeholder:`Select target group`})}),(0,$.jsx)(u,{children:i.map(Ae)})]})},t[40]=S.defaultTargetGroupArn,t[41]=i,t[42]=ie):ie=t[42];let K;t[43]!==_||t[44]!==ie?(K=(0,$.jsx)(ne,{control:_,name:`defaultTargetGroupArn`,render:ie}),t[43]=_,t[44]=ie,t[45]=K):K=t[45];let q;t[46]===S.defaultTargetGroupArn?q=t[47]:(q=(0,$.jsx)(z,{errors:[S.defaultTargetGroupArn]}),t[46]=S.defaultTargetGroupArn,t[47]=q);let J;t[48]===i.length?J=t[49]:(J=i.length===0&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`No target groups available in this VPC. Create one first.`}),t[48]=i.length,t[49]=J);let Y;t[50]!==K||t[51]!==q||t[52]!==J?(Y=(0,$.jsxs)(L,{children:[re,K,q,J]}),t[50]=K,t[51]=q,t[52]=J,t[53]=Y):Y=t[53];let ae;return t[54]!==P||t[55]!==U||t[56]!==G||t[57]!==Y?(ae=(0,$.jsxs)($.Fragment,{children:[P,U,G,Y]}),t[54]=P,t[55]=U,t[56]=G,t[57]=Y,t[58]=ae):ae=t[58],ae}function Ae(e){return(0,$.jsxs)(l,{value:e.TargetGroupArn??``,children:[e.TargetGroupName,` · `,e.Protocol,`:`,e.Port]},e.TargetGroupArn)}function je(e){return(0,$.jsx)(l,{value:e.Name??``,children:e.Name},e.Name)}function Me(e){return(0,$.jsx)(l,{value:e.CertificateArn??``,children:Oe(e)},e.CertificateArn)}function Ne(e){return(0,$.jsx)(l,{value:e,children:e},e)}function Pe({listenerArn:e,targetGroups:t}){let{data:n}=R(P(e)),r=T(),i=x(),a=E(),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(),[u,d]=(0,Q.useState)(),f=n.Rules??[],h=new Map;for(let e of t)e.TargetGroupArn&&e.TargetGroupName&&h.set(e.TargetGroupArn,e.TargetGroupName);return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[r.error&&(0,$.jsx)(U,{error:r.error,msg:`Failed to create rule`}),i.error&&(0,$.jsx)(U,{error:i.error,msg:`Failed to modify rule`}),a.error&&(0,$.jsx)(U,{error:a.error,msg:`Failed to delete rule`}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[f.length,` rule`,f.length===1?``:`s`,` (including default)`]}),(0,$.jsx)(m,{onClick:()=>s(!0),size:`sm`,children:`Add rule`})]}),(0,$.jsx)(`div`,{className:`overflow-x-auto rounded-lg border bg-card`,children:(0,$.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{className:`border-b text-left text-muted-foreground`,children:[(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Priority`}),(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Conditions`}),(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Forward to`}),(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:(0,$.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,$.jsx)(`tbody`,{children:f.map(e=>(0,$.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,$.jsx)(`td`,{className:`px-4 py-2`,children:e.Priority}),(0,$.jsx)(`td`,{className:`px-4 py-2 text-xs`,children:Fe(e.Conditions,e.IsDefault===!0)}),(0,$.jsx)(`td`,{className:`px-4 py-2 text-xs`,children:Le(e,h)}),(0,$.jsx)(`td`,{className:`px-4 py-2 text-right`,children:e.IsDefault===!0?(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Edit via listener`}):(0,$.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,$.jsx)(m,{"aria-label":`Edit rule ${e.Priority}`,onClick:()=>l(e),size:`sm`,variant:`ghost`,children:(0,$.jsx)(we,{className:`size-4`})}),(0,$.jsx)(m,{"aria-label":`Delete rule ${e.Priority}`,onClick:()=>d(e),size:`sm`,variant:`ghost`,children:(0,$.jsx)(p,{className:`size-4`})})]})})]},e.RuleArn??e.Priority??`default`))})]})}),(0,$.jsx)(ze,{isPending:r.isPending,mode:`add`,onOpenChange:s,onSubmit:async t=>{try{await r.mutateAsync({listenerArn:e,priority:t.priority,conditions:t.conditions.map(Re),forwardTargetGroupArn:t.forwardTargetGroupArn}),s(!1)}catch{}},open:o,targetGroups:t}),(0,$.jsx)(ze,{initialRule:c,isPending:i.isPending,mode:`edit`,onOpenChange:e=>!e&&l(void 0),onSubmit:async t=>{if(c?.RuleArn)try{await i.mutateAsync({ruleArn:c.RuleArn,listenerArn:e,conditions:t.conditions.map(Re),forwardTargetGroupArn:t.forwardTargetGroupArn}),l(void 0)}catch{}},open:c!==void 0,targetGroups:t}),(0,$.jsx)(le,{description:u?`Delete rule with priority ${u.Priority}? This cannot be undone.`:``,isPending:a.isPending,onConfirm:async()=>{if(u?.RuleArn)try{await a.mutateAsync({ruleArn:u.RuleArn,listenerArn:e})}finally{d(void 0)}},onOpenChange:e=>!e&&d(void 0),open:u!==void 0,title:`Delete rule`})]})}function Fe(e,t){return t?`default`:!e||e.length===0?`—`:e.map(e=>{let t=Ie(e);return`${e.Field}: ${t.join(`, `)}`}).join(` AND `)}function Ie(e){if(e.Field===void 0)return e.Values??[];switch(e.Field){case`host-header`:return e.HostHeaderConfig?.Values??e.Values??[];case`path-pattern`:return e.PathPatternConfig?.Values??e.Values??[];case`http-header`:{let t=e.HttpHeaderConfig?.HttpHeaderName??`?`;return(e.HttpHeaderConfig?.Values??[]).map(e=>`${t}=${e}`)}case`http-request-method`:return e.HttpRequestMethodConfig?.Values??[];case`source-ip`:return e.SourceIpConfig?.Values??[];case`query-string`:return(e.QueryStringConfig?.Values??[]).map(e=>e.Key?`${e.Key}=${e.Value??``}`:e.Value??``);default:return e.Values??[]}}function Le(e,t){let n=e.Actions?.[0];return n?n.Type===`forward`&&n.TargetGroupArn?t.get(n.TargetGroupArn)??n.TargetGroupArn:n.Type??`—`:`—`}function Re(e){let t=e.rawValues.split(/[\n,]/).map(e=>e.trim()).filter(e=>e.length>0);return e.field===`query-string`?{field:e.field,values:[],queryStringPairs:t.map(e=>{let t=e.indexOf(`=`);return t===-1?{value:e}:{key:e.slice(0,t),value:e.slice(t+1)}})}:{field:e.field,values:t,httpHeaderName:e.httpHeaderName}}function ze({open:e,onOpenChange:t,onSubmit:n,isPending:r,targetGroups:i,mode:a,initialRule:o}){let s=[{field:`path-pattern`,rawValues:``}],p=B({resolver:re(fe),defaultValues:{priority:1,conditions:s,forwardTargetGroupArn:``}}),{fields:h,append:g,remove:_}=V({control:p.control,name:`conditions`});(0,Q.useEffect)(()=>{if(a===`add`){e||p.reset({priority:1,conditions:s,forwardTargetGroupArn:``});return}if(!o)return;let t=Number(o.Priority??1),n=o.Conditions?.map(e=>We(e))??s;p.reset({priority:Number.isFinite(t)?t:1,conditions:n.length>0?n:s,forwardTargetGroupArn:o.Actions?.[0]?.TargetGroupArn??``})},[o,e,a]);let v=p.handleSubmit(n);return(0,$.jsx)(ce,{onOpenChange:t,open:e,children:(0,$.jsxs)(q,{className:`grid-cols-[minmax(0,1fr)]`,style:{maxWidth:`40rem`,width:`calc(100vw - 2rem)`},children:[(0,$.jsxs)(se,{children:[(0,$.jsx)(J,{children:a===`add`?`Add rule`:`Edit rule`}),(0,$.jsx)(K,{children:`Routing rules match incoming requests and forward them to a target group. Rules evaluate in priority order; the listener default applies when no rule matches.`})]}),(0,$.jsxs)(`form`,{className:`min-w-0 space-y-4`,onSubmit:e=>{e.preventDefault(),v()},children:[(0,$.jsxs)(L,{children:[(0,$.jsx)(W,{children:(0,$.jsx)(`label`,{htmlFor:`rule-priority`,children:`Priority`})}),(0,$.jsx)(I,{"aria-invalid":!!p.formState.errors.priority,id:`rule-priority`,inputMode:`numeric`,type:`number`,...p.register(`priority`,{valueAsNumber:!0})}),(0,$.jsx)(z,{errors:[p.formState.errors.priority]})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(W,{children:`Conditions`}),(0,$.jsx)(m,{disabled:h.length>=5,onClick:()=>g({field:`path-pattern`,rawValues:``}),size:`sm`,type:`button`,variant:`outline`,children:`Add condition`})]}),h.map((e,t)=>(0,$.jsx)(Be,{form:p,index:t,onRemove:h.length>1?()=>_(t):void 0},e.id))]}),(0,$.jsxs)(L,{children:[(0,$.jsx)(W,{children:(0,$.jsx)(`label`,{htmlFor:`rule-forward-tg`,children:`Forward to target group`})}),(0,$.jsx)(ne,{control:p.control,name:`forwardTargetGroupArn`,render:({field:e})=>(0,$.jsxs)(f,{onValueChange:e.onChange,value:e.value??``,children:[(0,$.jsx)(d,{"aria-invalid":!!p.formState.errors.forwardTargetGroupArn,className:`w-full`,id:`rule-forward-tg`,children:(0,$.jsx)(c,{placeholder:`Select target group`})}),(0,$.jsx)(u,{children:i.map(e=>(0,$.jsxs)(l,{value:e.TargetGroupArn??``,children:[e.TargetGroupName,` · `,e.Protocol,`:`,e.Port]},e.TargetGroupArn))})]})}),(0,$.jsx)(z,{errors:[p.formState.errors.forwardTargetGroupArn]})]})]}),(0,$.jsxs)(ae,{children:[(0,$.jsx)(oe,{disabled:r,children:`Cancel`}),(0,$.jsx)(Y,{disabled:r,onClick:v,children:Ge(a,r)})]})]})})}function Be(e){let t=(0,Te.c)(54),{form:n,index:r,onRemove:i}=e,a,o,s,h,g,_,v,y,b,x;if(t[0]!==n||t[1]!==r||t[2]!==i){let e=n.watch(`conditions.${r}.field`);s=n.formState.errors.conditions?.[r],y=`space-y-2 rounded-md border p-3`;let S=`rule-cond-${r}-field`,C;t[13]===S?C=t[14]:(C=(0,$.jsx)(W,{children:(0,$.jsx)(`label`,{htmlFor:S,children:`Type`})}),t[13]=S,t[14]=C);let w=`conditions.${r}.field`,T;t[15]===r?T=t[16]:(T=e=>{let{field:t}=e;return(0,$.jsxs)(f,{onValueChange:t.onChange,value:t.value,children:[(0,$.jsx)(d,{className:`w-full`,id:`rule-cond-${r}-field`,children:(0,$.jsx)(c,{})}),(0,$.jsxs)(u,{children:[(0,$.jsx)(l,{value:`path-pattern`,children:`Path pattern`}),(0,$.jsx)(l,{value:`host-header`,children:`Host header`}),(0,$.jsx)(l,{value:`http-header`,children:`HTTP header`}),(0,$.jsx)(l,{value:`http-request-method`,children:`HTTP method`}),(0,$.jsx)(l,{value:`source-ip`,children:`Source IP CIDR`}),(0,$.jsx)(l,{value:`query-string`,children:`Query string`})]})]})},t[15]=r,t[16]=T);let E;t[17]!==n.control||t[18]!==w||t[19]!==T?(E=(0,$.jsx)(ne,{control:n.control,name:w,render:T}),t[17]=n.control,t[18]=w,t[19]=T,t[20]=E):E=t[20];let D;t[21]!==E||t[22]!==C?(D=(0,$.jsxs)(`div`,{className:`flex-1`,children:[C,E]}),t[21]=E,t[22]=C,t[23]=D):D=t[23];let O;t[24]!==r||t[25]!==i?(O=i&&(0,$.jsx)(m,{"aria-label":`Remove condition ${r+1}`,className:`self-end`,onClick:i,size:`sm`,type:`button`,variant:`ghost`,children:(0,$.jsx)(p,{className:`size-4`})}),t[24]=r,t[25]=i,t[26]=O):O=t[26],t[27]!==D||t[28]!==O?(b=(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[D,O]}),t[27]=D,t[28]=O,t[29]=b):b=t[29],x=e===`http-header`&&(0,$.jsxs)(L,{children:[(0,$.jsx)(W,{children:(0,$.jsx)(`label`,{htmlFor:`rule-cond-${r}-hdr-name`,children:`Header name`})}),(0,$.jsx)(I,{"aria-invalid":!!s?.httpHeaderName,id:`rule-cond-${r}-hdr-name`,placeholder:`X-Tenant`,...n.register(`conditions.${r}.httpHeaderName`)}),(0,$.jsx)(z,{errors:[s?.httpHeaderName]})]}),o=L;let k=`rule-cond-${r}-values`,A;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(comma or newline separated, max 5)`}),t[30]=A):A=t[30],t[31]===k?v=t[32]:(v=(0,$.jsx)(W,{children:(0,$.jsxs)(`label`,{htmlFor:k,children:[`Values`,` `,A]})}),t[31]=k,t[32]=v),a=I,h=!!s?.rawValues,g=`rule-cond-${r}-values`,_=Ve(e),t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=h,t[7]=g,t[8]=_,t[9]=v,t[10]=y,t[11]=b,t[12]=x}else a=t[3],o=t[4],s=t[5],h=t[6],g=t[7],_=t[8],v=t[9],y=t[10],b=t[11],x=t[12];let S;t[33]!==n||t[34]!==r?(S=n.register(`conditions.${r}.rawValues`),t[33]=n,t[34]=r,t[35]=S):S=t[35];let C;t[36]!==a||t[37]!==h||t[38]!==g||t[39]!==_||t[40]!==S?(C=(0,$.jsx)(a,{"aria-invalid":h,id:g,placeholder:_,...S}),t[36]=a,t[37]=h,t[38]=g,t[39]=_,t[40]=S,t[41]=C):C=t[41];let w=s?.rawValues,T;t[42]===w?T=t[43]:(T=(0,$.jsx)(z,{errors:[w]}),t[42]=w,t[43]=T);let E;t[44]!==o||t[45]!==T||t[46]!==v||t[47]!==C?(E=(0,$.jsxs)(o,{children:[v,C,T]}),t[44]=o,t[45]=T,t[46]=v,t[47]=C,t[48]=E):E=t[48];let D;return t[49]!==E||t[50]!==y||t[51]!==b||t[52]!==x?(D=(0,$.jsxs)(`div`,{className:y,children:[b,x,E]}),t[49]=E,t[50]=y,t[51]=b,t[52]=x,t[53]=D):D=t[53],D}function Ve(e){switch(e){case`path-pattern`:return`/api/*`;case`host-header`:return`*.example.com`;case`http-header`:return`acme`;case`http-request-method`:return`GET, POST`;case`source-ip`:return`10.0.0.0/8`;case`query-string`:return`key=value`;default:return``}}var He=new Set([`host-header`,`path-pattern`,`http-header`,`http-request-method`,`source-ip`,`query-string`]);function Ue(e){return e!==void 0&&He.has(e)}function We(e){let t=Ie(e);return{field:Ue(e.Field)?e.Field:`path-pattern`,httpHeaderName:e.HttpHeaderConfig?.HttpHeaderName,rawValues:t.join(`, `)}}function Ge(e,t){return t?e===`add`?`Adding…`:`Saving…`:e===`add`?`Add rule`:`Save changes`}function Ke(e){return{protocol:me(e),port:80,defaultTargetGroupArn:``}}function qe(e){if(e.Protocol!==`HTTPS`)return`—`;let t=e.Certificates?.[0]?.CertificateArn?.split(`/`).pop(),n=e.SslPolicy;return t&&n?`${n} · ${t}`:n??t??`—`}function Je({loadBalancerArn:e,vpcId:t,lbType:n}){let r=de(n),{data:i}=R(A(e)),{data:a}=R(F),{data:o}=R(ie),{data:s}=R(j),c=D(),l=y(),u=O(),[d,f]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(),[_,v]=(0,Q.useState)(),[b,x]=(0,Q.useState)(),S=i.Listeners??[],C=a.TargetGroups??[],w=C.filter(e=>e.VpcId===t),T=o.CertificateSummaryList??[],E=s.SslPolicies??[],k=new Map;for(let e of C)e.TargetGroupArn&&e.TargetGroupName&&k.set(e.TargetGroupArn,e.TargetGroupName);let M=e=>{let t=e.DefaultActions?.[0];if(!t)return`—`;if(t.Type===`forward`&&t.TargetGroupArn){let e=k.get(t.TargetGroupArn);return e?`forward → ${e}`:`forward → ${t.TargetGroupArn}`}return t.Type??`—`};return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[c.error&&(0,$.jsx)(U,{error:c.error,msg:`Failed to create listener`}),u.error&&(0,$.jsx)(U,{error:u.error,msg:`Failed to modify listener`}),l.error&&(0,$.jsx)(U,{error:l.error,msg:`Failed to delete listener`}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[S.length,` listener`,S.length===1?``:`s`]}),(0,$.jsx)(m,{onClick:()=>f(!0),size:`sm`,children:`Add listener`})]}),S.length===0?(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:`No listeners configured.`}):(0,$.jsx)(`div`,{className:`overflow-x-auto rounded-lg border bg-card`,children:(0,$.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{className:`border-b text-left text-muted-foreground`,children:[(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Protocol`}),(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Port`}),(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`TLS`}),(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Default action`}),(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Listener ARN`}),(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:(0,$.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,$.jsx)(`tbody`,{children:S.map(e=>{let t=e.ListenerArn??``,n=b===t;return(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,$.jsx)(`td`,{className:`px-4 py-2`,children:e.Protocol}),(0,$.jsx)(`td`,{className:`px-4 py-2`,children:e.Port}),(0,$.jsx)(`td`,{className:`px-4 py-2 text-xs`,children:qe(e)}),(0,$.jsx)(`td`,{className:`px-4 py-2 text-xs`,children:M(e)}),(0,$.jsx)(`td`,{className:`px-4 py-2 font-mono text-xs`,children:t}),(0,$.jsx)(`td`,{className:`px-4 py-2 text-right`,children:(0,$.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,$.jsx)(m,{"aria-label":`${n?`Hide`:`Show`} rules for listener ${e.Protocol}:${e.Port}`,onClick:()=>x(n?void 0:t),size:`sm`,variant:`ghost`,children:n?`Hide rules`:`Rules`}),(0,$.jsx)(m,{"aria-label":`Edit listener ${e.Protocol}:${e.Port}`,onClick:()=>g(e),size:`sm`,variant:`ghost`,children:(0,$.jsx)(we,{className:`size-4`})}),(0,$.jsx)(m,{"aria-label":`Delete listener ${e.Protocol}:${e.Port}`,onClick:()=>v(e),size:`sm`,variant:`ghost`,children:(0,$.jsx)(p,{className:`size-4`})})]})})]}),n&&t&&(0,$.jsx)(`tr`,{className:`border-b bg-muted/30 last:border-0`,children:(0,$.jsx)(`td`,{className:`px-4 py-3`,colSpan:6,children:(0,$.jsx)(Pe,{listenerArn:t,targetGroups:w})})})]},t)})})]})}),(0,$.jsx)(Ye,{certificates:T,isPending:c.isPending,lbType:n,onOpenChange:f,onSubmit:async t=>{try{await c.mutateAsync({loadBalancerArn:e,protocol:t.protocol,port:t.port,defaultTargetGroupArn:t.defaultTargetGroupArn,certificateArn:t.certificateArn,sslPolicy:t.sslPolicy}),f(!1)}catch{}},open:d,protocols:r,sslPolicies:E,targetGroups:w}),(0,$.jsx)(Xe,{certificates:T,isPending:u.isPending,listener:h,onOpenChange:e=>!e&&g(void 0),onSubmit:async t=>{if(h?.ListenerArn)try{await u.mutateAsync({listenerArn:h.ListenerArn,loadBalancerArn:e,protocol:t.protocol,port:t.port,defaultTargetGroupArn:t.defaultTargetGroupArn,certificateArn:t.certificateArn,sslPolicy:t.sslPolicy}),g(void 0)}catch{}},protocols:r,sslPolicies:E,targetGroups:w}),(0,$.jsx)(le,{description:_?`Delete listener ${_.Protocol}:${_.Port}? This cannot be undone.`:``,isPending:l.isPending,onConfirm:async()=>{if(_?.ListenerArn)try{await l.mutateAsync(_.ListenerArn)}finally{v(void 0)}},onOpenChange:e=>!e&&v(void 0),open:_!==void 0,title:`Delete listener`})]})}function Ye(e){let t=(0,Te.c)(42),{open:n,onOpenChange:r,lbType:i,protocols:a,targetGroups:o,certificates:s,sslPolicies:c,isPending:l,onSubmit:u}=e,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=re(pe),t[0]=d):d=t[0];let f;t[1]===i?f=t[2]:(f=Ke(i),t[1]=i,t[2]=f);let p;t[3]===f?p=t[4]:(p={resolver:d,defaultValues:f},t[3]=f,t[4]=p);let m=B(p),h,g;t[5]!==m||t[6]!==i||t[7]!==n?(h=()=>{n||m.reset(Ke(i))},g=[n,m,i],t[5]=m,t[6]=i,t[7]=n,t[8]=h,t[9]=g):(h=t[8],g=t[9]),(0,Q.useEffect)(h,g);let _;t[10]!==m||t[11]!==u?(_=m.handleSubmit(u),t[10]=m,t[11]=u,t[12]=_):_=t[12];let v=_,y;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(y={maxWidth:`32rem`,width:`calc(100vw - 2rem)`},t[13]=y):y=t[13];let b;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsxs)(se,{children:[(0,$.jsx)(J,{children:`Add listener`}),(0,$.jsx)(K,{children:`Listeners forward incoming traffic to a default target group.`})]}),t[14]=b):b=t[14];let x;t[15]===v?x=t[16]:(x=e=>{e.preventDefault(),v()},t[15]=v,t[16]=x);let S;t[17]!==s||t[18]!==m||t[19]!==a||t[20]!==c||t[21]!==o?(S=(0,$.jsx)(ke,{certificates:s,form:m,protocols:a,sslPolicies:c,targetGroups:o}),t[17]=s,t[18]=m,t[19]=a,t[20]=c,t[21]=o,t[22]=S):S=t[22];let C;t[23]!==S||t[24]!==x?(C=(0,$.jsx)(`form`,{className:`min-w-0 space-y-4`,onSubmit:x,children:S}),t[23]=S,t[24]=x,t[25]=C):C=t[25];let w;t[26]===l?w=t[27]:(w=(0,$.jsx)(oe,{disabled:l,children:`Cancel`}),t[26]=l,t[27]=w);let T=l?`Adding…`:`Add listener`,E;t[28]!==v||t[29]!==l||t[30]!==T?(E=(0,$.jsx)(Y,{disabled:l,onClick:v,children:T}),t[28]=v,t[29]=l,t[30]=T,t[31]=E):E=t[31];let D;t[32]!==w||t[33]!==E?(D=(0,$.jsxs)(ae,{children:[w,E]}),t[32]=w,t[33]=E,t[34]=D):D=t[34];let O;t[35]!==C||t[36]!==D?(O=(0,$.jsxs)(q,{className:`grid-cols-[minmax(0,1fr)]`,style:y,children:[b,C,D]}),t[35]=C,t[36]=D,t[37]=O):O=t[37];let k;return t[38]!==r||t[39]!==n||t[40]!==O?(k=(0,$.jsx)(ce,{onOpenChange:r,open:n,children:O}),t[38]=r,t[39]=n,t[40]=O,t[41]=k):k=t[41],k}function Xe(e){let t=(0,Te.c)(38),{listener:n,onOpenChange:r,protocols:i,targetGroups:a,certificates:o,sslPolicies:s,isPending:c,onSubmit:l}=e,u=n!==void 0,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d={resolver:re(pe),defaultValues:{protocol:`HTTP`,port:80,defaultTargetGroupArn:``}},t[0]=d):d=t[0];let f=B(d),p,m;t[1]!==f||t[2]!==n||t[3]!==i?(p=()=>{if(!n)return;let e=i.find(e=>e===n.Protocol)??i[0]??`HTTP`,t=he(e);f.reset({protocol:e,port:n.Port??80,defaultTargetGroupArn:n.DefaultActions?.[0]?.TargetGroupArn??``,certificateArn:t?n.Certificates?.[0]?.CertificateArn:void 0,sslPolicy:e===`HTTPS`?n.SslPolicy:void 0})},m=[n,f,i],t[1]=f,t[2]=n,t[3]=i,t[4]=p,t[5]=m):(p=t[4],m=t[5]),(0,Q.useEffect)(p,m);let h;t[6]!==f||t[7]!==l?(h=f.handleSubmit(l),t[6]=f,t[7]=l,t[8]=h):h=t[8];let g=h,_;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_={maxWidth:`32rem`,width:`calc(100vw - 2rem)`},t[9]=_):_=t[9];let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsxs)(se,{children:[(0,$.jsx)(J,{children:`Edit listener`}),(0,$.jsx)(K,{children:`Update port, protocol, or default target group. Changes apply without dropping the listener.`})]}),t[10]=v):v=t[10];let y;t[11]===g?y=t[12]:(y=e=>{e.preventDefault(),g()},t[11]=g,t[12]=y);let b;t[13]!==o||t[14]!==f||t[15]!==i||t[16]!==s||t[17]!==a?(b=(0,$.jsx)(ke,{certificates:o,form:f,protocols:i,sslPolicies:s,targetGroups:a}),t[13]=o,t[14]=f,t[15]=i,t[16]=s,t[17]=a,t[18]=b):b=t[18];let x;t[19]!==y||t[20]!==b?(x=(0,$.jsx)(`form`,{className:`min-w-0 space-y-4`,onSubmit:y,children:b}),t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;t[22]===c?S=t[23]:(S=(0,$.jsx)(oe,{disabled:c,children:`Cancel`}),t[22]=c,t[23]=S);let C=c?`Saving…`:`Save changes`,w;t[24]!==g||t[25]!==c||t[26]!==C?(w=(0,$.jsx)(Y,{disabled:c,onClick:g,children:C}),t[24]=g,t[25]=c,t[26]=C,t[27]=w):w=t[27];let T;t[28]!==S||t[29]!==w?(T=(0,$.jsxs)(ae,{children:[S,w]}),t[28]=S,t[29]=w,t[30]=T):T=t[30];let E;t[31]!==T||t[32]!==x?(E=(0,$.jsxs)(q,{className:`grid-cols-[minmax(0,1fr)]`,style:_,children:[v,x,T]}),t[31]=T,t[32]=x,t[33]=E):E=t[33];let D;return t[34]!==r||t[35]!==u||t[36]!==E?(D=(0,$.jsx)(ce,{onOpenChange:r,open:u,children:E}),t[34]=r,t[35]=u,t[36]=E,t[37]=D):D=t[37],D}function Ze(e,t){if(e.length!==t.length)return!1;let n=new Set(t);return e.every(e=>n.has(e))}function Qe(e){let t=(0,Te.c)(46),{available:n,current:r,onSubmit:i,isPending:a,error:o,isSuccess:s}=e,c;t[0]===r?c=t[1]:(c=[...r],t[0]=r,t[1]=c);let l=c,[u,d]=(0,Q.useState)(l),f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=e=>{d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},t[2]=f):f=t[2];let p=f,h;t[3]===l?h=t[4]:(h=()=>d(l),t[3]=l,t[4]=h);let g=h,_;t[5]!==l||t[6]!==u?(_=Ze(u,l),t[5]=l,t[6]=u,t[7]=_):_=t[7];let v=!_,y=u.length===0,b;t[8]!==v||t[9]!==y||t[10]!==i||t[11]!==u?(b=e=>{e.preventDefault(),!(!v||y)&&i(u)},t[8]=v,t[9]=y,t[10]=i,t[11]=u,t[12]=b):b=t[12];let x;t[13]===o?x=t[14]:(x=o&&(0,$.jsx)(`div`,{className:`mb-4 rounded-md border border-destructive bg-destructive/10 p-3 text-sm text-destructive`,role:`alert`,children:o.message||`Failed to update security groups`}),t[13]=o,t[14]=x);let S;t[15]!==v||t[16]!==s?(S=s&&!v&&(0,$.jsx)(`div`,{className:`mb-4 rounded-md border border-emerald-500 bg-emerald-500/10 p-3 text-sm text-emerald-700 dark:text-emerald-400`,role:`status`,children:`Security groups updated.`}),t[15]=v,t[16]=s,t[17]=S):S=t[17];let C;t[18]!==n||t[19]!==u?(C=n.length===0?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No security groups in this VPC.`}):n.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,$.jsx)(`input`,{"aria-label":`Security group ${e.GroupId} (${e.GroupName})`,checked:u.includes(e.GroupId??``),onChange:()=>p(e.GroupId??``),type:`checkbox`}),(0,$.jsxs)(`span`,{className:`font-mono`,children:[e.GroupId,` (`,e.GroupName,`)`]})]},e.GroupId)),t[18]=n,t[19]=u,t[20]=C):C=t[20];let w;t[21]===y?w=t[22]:(w=y&&(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:`At least one security group is required.`}),t[21]=y,t[22]=w);let T;t[23]!==C||t[24]!==w?(T=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 p-4`,children:[C,w]}),t[23]=C,t[24]=w,t[25]=T):T=t[25];let E=v?`Unsaved changes`:`No changes`,D;t[26]===E?D=t[27]:(D=(0,$.jsx)(`span`,{className:`mr-auto text-xs text-muted-foreground`,children:E}),t[26]=E,t[27]=D);let O=a||!v,k;t[28]!==g||t[29]!==O?(k=(0,$.jsx)(m,{disabled:O,onClick:g,size:`sm`,type:`button`,variant:`secondary`,children:`Reset`}),t[28]=g,t[29]=O,t[30]=k):k=t[30];let A=a||!v||y,j=a?`Saving…`:`Save changes`,M;t[31]!==A||t[32]!==j?(M=(0,$.jsx)(m,{disabled:A,size:`sm`,type:`submit`,children:j}),t[31]=A,t[32]=j,t[33]=M):M=t[33];let N;t[34]!==D||t[35]!==k||t[36]!==M?(N=(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t p-4`,children:[D,k,M]}),t[34]=D,t[35]=k,t[36]=M,t[37]=N):N=t[37];let P;t[38]!==T||t[39]!==N?(P=(0,$.jsxs)(`div`,{className:`rounded-lg border bg-card`,children:[T,N]}),t[38]=T,t[39]=N,t[40]=P):P=t[40];let F;return t[41]!==P||t[42]!==b||t[43]!==x||t[44]!==S?(F=(0,$.jsxs)(`form`,{onSubmit:b,children:[x,S,P]}),t[41]=P,t[42]=b,t[43]=x,t[44]=S,t[45]=F):F=t[45],F}function $e(e,t){if(e.length!==t.length)return!1;let n=new Set(t);return e.every(e=>n.has(e))}function et(e){let t=o(e.Tags),n=e.AvailabilityZone?` · ${e.AvailabilityZone}`:``,r=e.CidrBlock?` (${e.CidrBlock})`:``;return`${e.SubnetId}${t?` — ${t}`:``}${r}${n}`}function tt(e){let t=(0,Te.c)(47),{available:n,current:r,onSubmit:i,isPending:a,error:o,isSuccess:s}=e,c;t[0]===r?c=t[1]:(c=[...r],t[0]=r,t[1]=c);let l=c,[u,d]=(0,Q.useState)(l),f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=e=>{d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},t[2]=f):f=t[2];let p=f,h;t[3]===l?h=t[4]:(h=()=>d(l),t[3]=l,t[4]=h);let g=h,_;t[5]!==l||t[6]!==u?(_=$e(u,l),t[5]=l,t[6]=u,t[7]=_):_=t[7];let v=!_,y=u.length===0,b;t[8]!==v||t[9]!==y||t[10]!==i||t[11]!==u?(b=e=>{e.preventDefault(),!(!v||y)&&i(u)},t[8]=v,t[9]=y,t[10]=i,t[11]=u,t[12]=b):b=t[12];let x;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(`div`,{className:`mb-4 rounded-md border border-amber-500 bg-amber-500/10 p-3 text-sm text-amber-700 dark:text-amber-400`,role:`note`,children:`Applying a subnet change re-homes the load balancer by relaunching its underlying system VM. Expect a brief data-plane interruption while it restarts.`}),t[13]=x):x=t[13];let S;t[14]===o?S=t[15]:(S=o&&(0,$.jsx)(`div`,{className:`mb-4 rounded-md border border-destructive bg-destructive/10 p-3 text-sm text-destructive`,role:`alert`,children:o.message||`Failed to update subnets`}),t[14]=o,t[15]=S);let C;t[16]!==v||t[17]!==s?(C=s&&!v&&(0,$.jsx)(`div`,{className:`mb-4 rounded-md border border-emerald-500 bg-emerald-500/10 p-3 text-sm text-emerald-700 dark:text-emerald-400`,role:`status`,children:`Subnets updated.`}),t[16]=v,t[17]=s,t[18]=C):C=t[18];let w;t[19]!==n||t[20]!==u?(w=n.length===0?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No subnets in this VPC.`}):n.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,$.jsx)(`input`,{"aria-label":`Subnet ${e.SubnetId}`,checked:u.includes(e.SubnetId??``),onChange:()=>p(e.SubnetId??``),type:`checkbox`}),(0,$.jsx)(`span`,{className:`font-mono`,children:et(e)})]},e.SubnetId)),t[19]=n,t[20]=u,t[21]=w):w=t[21];let T;t[22]===y?T=t[23]:(T=y&&(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:`At least one subnet is required.`}),t[22]=y,t[23]=T);let E;t[24]!==T||t[25]!==w?(E=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 p-4`,children:[w,T]}),t[24]=T,t[25]=w,t[26]=E):E=t[26];let D=v?`Unsaved changes`:`No changes`,O;t[27]===D?O=t[28]:(O=(0,$.jsx)(`span`,{className:`mr-auto text-xs text-muted-foreground`,children:D}),t[27]=D,t[28]=O);let k=a||!v,A;t[29]!==g||t[30]!==k?(A=(0,$.jsx)(m,{disabled:k,onClick:g,size:`sm`,type:`button`,variant:`secondary`,children:`Reset`}),t[29]=g,t[30]=k,t[31]=A):A=t[31];let j=a||!v||y,M=a?`Saving…`:`Save changes`,N;t[32]!==j||t[33]!==M?(N=(0,$.jsx)(m,{disabled:j,size:`sm`,type:`submit`,children:M}),t[32]=j,t[33]=M,t[34]=N):N=t[34];let P;t[35]!==O||t[36]!==A||t[37]!==N?(P=(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t p-4`,children:[O,A,N]}),t[35]=O,t[36]=A,t[37]=N,t[38]=P):P=t[38];let F;t[39]!==E||t[40]!==P?(F=(0,$.jsxs)(`div`,{className:`rounded-lg border bg-card`,children:[E,P]}),t[39]=E,t[40]=P,t[41]=F):F=t[41];let I;return t[42]!==F||t[43]!==b||t[44]!==S||t[45]!==C?(I=(0,$.jsxs)(`form`,{onSubmit:b,children:[x,S,C,F]}),t[42]=F,t[43]=b,t[44]=S,t[45]=C,t[46]=I):I=t[46],I}function nt({arn:e}){let t=i(),{data:n}=R(k(e)),{data:r}=R(M(e)),{data:s}=R(N([e])),{data:c}=R(g),{data:l}=R(_),u=w(),d=b(),f=v(),h=C(),y=S(),[x,T]=(0,Q.useState)(!1),E=n.LoadBalancers?.[0];if(!E?.LoadBalancerArn)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(te,{to:`/ec2/describe-load-balancers`,children:`Back to load balancers`}),(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:`Load balancer not found.`})]});let D=async()=>{try{await u.mutateAsync(e),t({to:`/ec2/describe-load-balancers`})}finally{T(!1)}},O=c.Subnets??[],A=e=>{let t=O.find(t=>t.SubnetId===e);if(!t)return e;let n=o(t.Tags),r=t.CidrBlock?` (${t.CidrBlock})`:``;return n?`${e} — ${n}${r}`:`${e}${r}`},j=r.Attributes??[],P=s?.TagDescriptions?.find(t=>t.ResourceArn===e)?.Tags??[],F=(E.SecurityGroups??[]).filter(e=>e!==void 0),I=(l.SecurityGroups??[]).filter(e=>e.VpcId===E.VpcId),L=O.filter(e=>e.VpcId===E.VpcId),ee=(E.AvailabilityZones??[]).map(e=>e.SubnetId).filter(e=>e!==void 0),z=E.Type===`network`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(te,{to:`/ec2/describe-load-balancers`,children:`Back to load balancers`}),u.error&&(0,$.jsx)(U,{error:u.error,msg:`Failed to delete load balancer`}),(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsx)(G,{actions:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(m,{onClick:()=>T(!0),size:`sm`,variant:`destructive`,children:[(0,$.jsx)(p,{className:`size-4`}),`Delete`]}),(0,$.jsx)(ue,{state:E.State?.Code})]}),subtitle:`Load Balancer Details`,title:E.LoadBalancerName??E.LoadBalancerArn}),(0,$.jsxs)(Ce,{defaultValue:`overview`,children:[(0,$.jsxs)(xe,{children:[(0,$.jsx)(be,{value:`overview`,children:`Overview`}),(0,$.jsx)(be,{value:`listeners`,children:`Listeners`}),(0,$.jsx)(be,{value:`subnets`,children:`Subnets`}),!z&&(0,$.jsx)(be,{value:`security-groups`,children:`Security groups`}),(0,$.jsx)(be,{value:`attributes`,children:`Attributes`}),(0,$.jsx)(be,{value:`tags`,children:`Tags`})]}),(0,$.jsxs)(Se,{value:`overview`,children:[(0,$.jsxs)(X,{children:[(0,$.jsx)(X.Header,{children:`Load balancer`}),(0,$.jsxs)(X.Content,{children:[(0,$.jsx)(Z,{label:`ARN`,value:E.LoadBalancerArn}),(0,$.jsx)(Z,{label:`DNS name`,value:E.DNSName}),(0,$.jsx)(Z,{label:`State`,value:E.State?.Reason?`${E.State.Code} — ${E.State.Reason}`:E.State?.Code}),(0,$.jsx)(Z,{label:`Type`,value:E.Type}),(0,$.jsx)(Z,{label:`Scheme`,value:E.Scheme}),(0,$.jsx)(Z,{label:`IP address type`,value:E.IpAddressType}),(0,$.jsx)(Z,{label:`VPC`,value:E.VpcId}),(0,$.jsx)(Z,{label:`Created at`,value:a(E.CreatedTime)})]})]}),(0,$.jsxs)(X,{children:[(0,$.jsx)(X.Header,{children:`Availability zones`}),(0,$.jsx)(X.Content,{children:(E.AvailabilityZones??[]).map(e=>(0,$.jsx)(Z,{label:e.ZoneName??`—`,value:e.SubnetId?A(e.SubnetId):void 0},`${e.ZoneName}-${e.SubnetId}`))})]}),(E.SecurityGroups??[]).length>0&&(0,$.jsxs)(X,{children:[(0,$.jsx)(X.Header,{children:`Security groups`}),(0,$.jsx)(X.Content,{children:(E.SecurityGroups??[]).map(e=>(0,$.jsx)(Z,{label:`Security group`,value:e},e))})]})]}),(0,$.jsx)(Se,{value:`listeners`,children:(0,$.jsx)(Je,{lbType:z?`network`:`application`,loadBalancerArn:e,vpcId:E.VpcId})}),(0,$.jsx)(Se,{value:`subnets`,children:(0,$.jsx)(tt,{available:L,current:ee,error:y.error,isPending:y.isPending,isSuccess:y.isSuccess,onSubmit:t=>y.mutate({loadBalancerArn:e,subnetIds:t})})}),!z&&(0,$.jsx)(Se,{value:`security-groups`,children:(0,$.jsx)(Qe,{available:I,current:F,error:h.error,isPending:h.isPending,isSuccess:h.isSuccess,onSubmit:t=>h.mutate({loadBalancerArn:e,securityGroupIds:t})})}),(0,$.jsx)(Se,{value:`attributes`,children:(0,$.jsx)(_e,{attributes:j,error:d.error,isPending:d.isPending,isSuccess:d.isSuccess,onSubmit:t=>{d.mutate({loadBalancerArn:e,attributes:t})},specs:ve})}),(0,$.jsx)(Se,{value:`tags`,children:(0,$.jsx)(ye,{error:f.error,isPending:f.isPending,isSuccess:f.isSuccess,onSubmit:t=>f.mutate({resourceArn:e,tags:t,initialKeys:P.map(e=>e.Key??``).filter(e=>e.length>0)}),tags:P})})]})]}),(0,$.jsx)(le,{description:`Are you sure you want to delete load balancer "${E.LoadBalancerName??E.LoadBalancerArn}"? This action cannot be undone.`,isPending:u.isPending,onConfirm:D,onOpenChange:T,open:x,title:`Delete load balancer`})]})}function rt(){let e=(0,Te.c)(2),{id:t}=H.useParams(),n=decodeURIComponent(t),r;return e[0]===n?r=e[1]:(r=(0,$.jsx)(nt,{arn:n}),e[0]=n,e[1]=r),r}export{rt as component}; \ No newline at end of file +import{n as e,o as t,r as n,t as r}from"./compiler-runtime.js";import{t as i}from"./useNavigate.js";import{$t as a,nn as o}from"./auth.js";import{t as s}from"./createLucideIcon.js";import{c,i as l,n as u,s as d,t as f}from"./select.js";import{t as p}from"./trash-2.js";import{t as m}from"./button.js";import{t as h}from"./certificate-import-dialog.js";import{O as g,w as _}from"./ec2.js";import{_ as v,a as y,d as b,f as x,g as S,h as C,o as w,r as T,s as E,t as D,u as O}from"./elbv2.js";import{i as k,n as A,o as j,r as M,s as N,t as P,u as F}from"./elbv22.js";import{Ln as I,Qt as L,Xn as R,_n as ee,en as z,fn as B,gn as V,hn as H,l as U,ln as W,mn as te,nn as G,on as K,pn as q,vn as ne}from"./index.js";import{a as J,i as Y,l as re,n as ie,o as ae,r as oe,s as se,t as ce}from"./alert-dialog.js";import{t as le}from"./delete-confirmation-dialog.js";import{n as X,t as Z}from"./detail-row.js";import{t as ue}from"./state-badge.js";import{c as de,i as fe,n as pe,o as me,s as he,t as ge}from"./elbv23.js";import{n as _e,r as ve,t as ye}from"./tags-editor.js";import{i as be,n as xe,r as Se,t as Ce}from"./tabs.js";var we=s(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),Te=r(),Q=t(n(),1),$=e(),Ee=80,De=443,Oe=[],ke=[];function Ae(e){let t=e.CertificateArn?.split(`/`).pop()??e.CertificateArn??``;return e.DomainName?`${e.DomainName} · ${t}`:t}function je(e){let t=(0,Te.c)(55),{form:n,protocols:r,targetGroups:i,certificates:a,sslPolicies:o}=e,s=a===void 0?Oe:a,l=o===void 0?ke:o,{control:p,register:g,getValues:_,setValue:v,formState:y}=n,{errors:b}=y,[x,S]=(0,Q.useState)(!1),C;t[0]===p?C=t[1]:(C={control:p,name:`protocol`},t[0]=p,t[1]=C);let w=ee(C),T=w===`HTTPS`,E;t[2]===w?E=t[3]:(E=he(w),t[2]=w,t[3]=E);let D=E,O;t[4]!==_||t[5]!==v?(O=e=>{if(!e)return;let t=_(`port`);he(e)?(t===Ee&&v(`port`,De),e===`HTTPS`?_(`sslPolicy`)||v(`sslPolicy`,ge):v(`sslPolicy`,void 0)):(t===De&&v(`port`,Ee),v(`certificateArn`,void 0),v(`sslPolicy`,void 0))},t[4]=_,t[5]=v,t[6]=O):O=t[6];let k=O,A;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(G,{children:(0,$.jsx)(`label`,{htmlFor:`listener-protocol`,children:`Protocol`})}),t[7]=A):A=t[7];let j;t[8]!==k||t[9]!==r?(j=e=>{let{field:t}=e;return(0,$.jsxs)(f,{onValueChange:e=>{t.onChange(e),k(e)},value:t.value,children:[(0,$.jsx)(d,{className:`w-full`,id:`listener-protocol`,children:(0,$.jsx)(c,{})}),(0,$.jsx)(u,{children:r.map(Fe)})]})},t[8]=k,t[9]=r,t[10]=j):j=t[10];let M;t[11]!==p||t[12]!==j?(M=(0,$.jsxs)(L,{children:[A,(0,$.jsx)(te,{control:p,name:`protocol`,render:j})]}),t[11]=p,t[12]=j,t[13]=M):M=t[13];let N;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(G,{children:(0,$.jsx)(`label`,{htmlFor:`listener-port`,children:`Port`})}),t[14]=N):N=t[14];let P=!!b.port,F=D?`443`:`80`,R;t[15]===g?R=t[16]:(R=g(`port`,{valueAsNumber:!0}),t[15]=g,t[16]=R);let B;t[17]!==P||t[18]!==F||t[19]!==R?(B=(0,$.jsx)(I,{"aria-invalid":P,id:`listener-port`,inputMode:`numeric`,placeholder:F,type:`number`,...R}),t[17]=P,t[18]=F,t[19]=R,t[20]=B):B=t[20];let V;t[21]===b.port?V=t[22]:(V=(0,$.jsx)(z,{errors:[b.port]}),t[21]=b.port,t[22]=V);let H;t[23]!==B||t[24]!==V?(H=(0,$.jsxs)(L,{children:[N,B,V]}),t[23]=B,t[24]=V,t[25]=H):H=t[25];let U;t[26]!==s||t[27]!==p||t[28]!==b.certificateArn||t[29]!==x||t[30]!==T||t[31]!==D||t[32]!==v||t[33]!==l?(U=D&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(L,{children:[(0,$.jsx)(G,{children:(0,$.jsx)(`label`,{htmlFor:`listener-certificate`,children:`Certificate`})}),(0,$.jsx)(te,{control:p,name:`certificateArn`,render:e=>{let{field:t}=e;return(0,$.jsxs)(f,{onValueChange:t.onChange,value:t.value??``,children:[(0,$.jsx)(d,{"aria-invalid":!!b.certificateArn,className:`w-full`,id:`listener-certificate`,children:(0,$.jsx)(c,{placeholder:`Select certificate`})}),(0,$.jsx)(u,{children:s.map(Pe)})]})}}),(0,$.jsx)(z,{errors:[b.certificateArn]}),(0,$.jsxs)(`div`,{className:`mt-1 flex items-center justify-between`,children:[s.length===0&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No certificates imported yet.`}),(0,$.jsx)(m,{className:`ml-auto`,onClick:()=>S(!0),size:`sm`,type:`button`,variant:`ghost`,children:`Import certificate…`})]})]}),T&&(0,$.jsxs)(L,{children:[(0,$.jsx)(G,{children:(0,$.jsx)(`label`,{htmlFor:`listener-ssl-policy`,children:`Security policy`})}),(0,$.jsx)(te,{control:p,name:`sslPolicy`,render:e=>{let{field:t}=e;return(0,$.jsxs)(f,{onValueChange:t.onChange,value:t.value??`ELBSecurityPolicy-2016-08`,children:[(0,$.jsx)(d,{className:`w-full`,id:`listener-ssl-policy`,children:(0,$.jsx)(c,{})}),(0,$.jsx)(u,{children:l.map(Ne)})]})}})]}),(0,$.jsx)(h,{onImported:e=>v(`certificateArn`,e,{shouldValidate:!0}),onOpenChange:S,open:x})]}),t[26]=s,t[27]=p,t[28]=b.certificateArn,t[29]=x,t[30]=T,t[31]=D,t[32]=v,t[33]=l,t[34]=U):U=t[34];let W;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(G,{children:(0,$.jsx)(`label`,{htmlFor:`listener-default-tg`,children:`Default target group`})}),t[35]=W):W=t[35];let K;t[36]!==b.defaultTargetGroupArn||t[37]!==i?(K=e=>{let{field:t}=e;return(0,$.jsxs)(f,{onValueChange:t.onChange,value:t.value??``,children:[(0,$.jsx)(d,{"aria-invalid":!!b.defaultTargetGroupArn,className:`w-full`,id:`listener-default-tg`,children:(0,$.jsx)(c,{placeholder:`Select target group`})}),(0,$.jsx)(u,{children:i.map(Me)})]})},t[36]=b.defaultTargetGroupArn,t[37]=i,t[38]=K):K=t[38];let q;t[39]!==p||t[40]!==K?(q=(0,$.jsx)(te,{control:p,name:`defaultTargetGroupArn`,render:K}),t[39]=p,t[40]=K,t[41]=q):q=t[41];let ne;t[42]===b.defaultTargetGroupArn?ne=t[43]:(ne=(0,$.jsx)(z,{errors:[b.defaultTargetGroupArn]}),t[42]=b.defaultTargetGroupArn,t[43]=ne);let J;t[44]===i.length?J=t[45]:(J=i.length===0&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`No target groups available in this VPC. Create one first.`}),t[44]=i.length,t[45]=J);let Y;t[46]!==q||t[47]!==ne||t[48]!==J?(Y=(0,$.jsxs)(L,{children:[W,q,ne,J]}),t[46]=q,t[47]=ne,t[48]=J,t[49]=Y):Y=t[49];let re;return t[50]!==H||t[51]!==U||t[52]!==Y||t[53]!==M?(re=(0,$.jsxs)($.Fragment,{children:[M,H,U,Y]}),t[50]=H,t[51]=U,t[52]=Y,t[53]=M,t[54]=re):re=t[54],re}function Me(e){return(0,$.jsxs)(l,{value:e.TargetGroupArn??``,children:[e.TargetGroupName,` · `,e.Protocol,`:`,e.Port]},e.TargetGroupArn)}function Ne(e){return(0,$.jsx)(l,{value:e.Name??``,children:e.Name},e.Name)}function Pe(e){return(0,$.jsx)(l,{value:e.CertificateArn??``,children:Ae(e)},e.CertificateArn)}function Fe(e){return(0,$.jsx)(l,{value:e,children:e},e)}function Ie({listenerArn:e,targetGroups:t}){let{data:n}=R(P(e)),r=T(),i=x(),a=E(),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(),[u,d]=(0,Q.useState)(),f=n.Rules??[],h=new Map;for(let e of t)e.TargetGroupArn&&e.TargetGroupName&&h.set(e.TargetGroupArn,e.TargetGroupName);return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[r.error&&(0,$.jsx)(W,{error:r.error,msg:`Failed to create rule`}),i.error&&(0,$.jsx)(W,{error:i.error,msg:`Failed to modify rule`}),a.error&&(0,$.jsx)(W,{error:a.error,msg:`Failed to delete rule`}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[f.length,` rule`,f.length===1?``:`s`,` (including default)`]}),(0,$.jsx)(m,{onClick:()=>s(!0),size:`sm`,children:`Add rule`})]}),(0,$.jsx)(`div`,{className:`overflow-x-auto rounded-lg border bg-card`,children:(0,$.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{className:`border-b text-left text-muted-foreground`,children:[(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Priority`}),(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Conditions`}),(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Forward to`}),(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:(0,$.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,$.jsx)(`tbody`,{children:f.map(e=>(0,$.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,$.jsx)(`td`,{className:`px-4 py-2`,children:e.Priority}),(0,$.jsx)(`td`,{className:`px-4 py-2 text-xs`,children:Le(e.Conditions,e.IsDefault===!0)}),(0,$.jsx)(`td`,{className:`px-4 py-2 text-xs`,children:ze(e,h)}),(0,$.jsx)(`td`,{className:`px-4 py-2 text-right`,children:e.IsDefault===!0?(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Edit via listener`}):(0,$.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,$.jsx)(m,{"aria-label":`Edit rule ${e.Priority}`,onClick:()=>l(e),size:`sm`,variant:`ghost`,children:(0,$.jsx)(we,{className:`size-4`})}),(0,$.jsx)(m,{"aria-label":`Delete rule ${e.Priority}`,onClick:()=>d(e),size:`sm`,variant:`ghost`,children:(0,$.jsx)(p,{className:`size-4`})})]})})]},e.RuleArn??e.Priority??`default`))})]})}),(0,$.jsx)(Ve,{isPending:r.isPending,mode:`add`,onOpenChange:s,onSubmit:async t=>{try{await r.mutateAsync({listenerArn:e,priority:t.priority,conditions:t.conditions.map(Be),forwardTargetGroupArn:t.forwardTargetGroupArn}),s(!1)}catch{}},open:o,targetGroups:t}),(0,$.jsx)(Ve,{initialRule:c,isPending:i.isPending,mode:`edit`,onOpenChange:e=>!e&&l(void 0),onSubmit:async t=>{if(c?.RuleArn)try{await i.mutateAsync({ruleArn:c.RuleArn,listenerArn:e,conditions:t.conditions.map(Be),forwardTargetGroupArn:t.forwardTargetGroupArn}),l(void 0)}catch{}},open:c!==void 0,targetGroups:t}),(0,$.jsx)(le,{description:u?`Delete rule with priority ${u.Priority}? This cannot be undone.`:``,isPending:a.isPending,onConfirm:async()=>{if(u?.RuleArn)try{await a.mutateAsync({ruleArn:u.RuleArn,listenerArn:e})}finally{d(void 0)}},onOpenChange:e=>!e&&d(void 0),open:u!==void 0,title:`Delete rule`})]})}function Le(e,t){return t?`default`:!e||e.length===0?`—`:e.map(e=>{let t=Re(e);return`${e.Field}: ${t.join(`, `)}`}).join(` AND `)}function Re(e){if(e.Field===void 0)return e.Values??[];switch(e.Field){case`host-header`:return e.HostHeaderConfig?.Values??e.Values??[];case`path-pattern`:return e.PathPatternConfig?.Values??e.Values??[];case`http-header`:{let t=e.HttpHeaderConfig?.HttpHeaderName??`?`;return(e.HttpHeaderConfig?.Values??[]).map(e=>`${t}=${e}`)}case`http-request-method`:return e.HttpRequestMethodConfig?.Values??[];case`source-ip`:return e.SourceIpConfig?.Values??[];case`query-string`:return(e.QueryStringConfig?.Values??[]).map(e=>e.Key?`${e.Key}=${e.Value??``}`:e.Value??``);default:return e.Values??[]}}function ze(e,t){let n=e.Actions?.[0];return n?n.Type===`forward`&&n.TargetGroupArn?t.get(n.TargetGroupArn)??n.TargetGroupArn:n.Type??`—`:`—`}function Be(e){let t=e.rawValues.split(/[\n,]/).map(e=>e.trim()).filter(e=>e.length>0);return e.field===`query-string`?{field:e.field,values:[],queryStringPairs:t.map(e=>{let t=e.indexOf(`=`);return t===-1?{value:e}:{key:e.slice(0,t),value:e.slice(t+1)}})}:{field:e.field,values:t,httpHeaderName:e.httpHeaderName}}function Ve({open:e,onOpenChange:t,onSubmit:n,isPending:r,targetGroups:i,mode:a,initialRule:o}){let s=[{field:`path-pattern`,rawValues:``}],p=V({resolver:q(fe),defaultValues:{priority:1,conditions:s,forwardTargetGroupArn:``}}),{fields:h,append:g,remove:_}=H({control:p.control,name:`conditions`});(0,Q.useEffect)(()=>{if(a===`add`){e||p.reset({priority:1,conditions:s,forwardTargetGroupArn:``});return}if(!o)return;let t=Number(o.Priority??1),n=o.Conditions?.map(e=>Ke(e))??s;p.reset({priority:Number.isFinite(t)?t:1,conditions:n.length>0?n:s,forwardTargetGroupArn:o.Actions?.[0]?.TargetGroupArn??``})},[o,e,a]);let v=p.handleSubmit(n);return(0,$.jsx)(ce,{onOpenChange:t,open:e,children:(0,$.jsxs)(Y,{className:`grid-cols-[minmax(0,1fr)]`,style:{maxWidth:`40rem`,width:`calc(100vw - 2rem)`},children:[(0,$.jsxs)(se,{children:[(0,$.jsx)(re,{children:a===`add`?`Add rule`:`Edit rule`}),(0,$.jsx)(J,{children:`Routing rules match incoming requests and forward them to a target group. Rules evaluate in priority order; the listener default applies when no rule matches.`})]}),(0,$.jsxs)(`form`,{className:`min-w-0 space-y-4`,onSubmit:e=>{e.preventDefault(),v()},children:[(0,$.jsxs)(L,{children:[(0,$.jsx)(G,{children:(0,$.jsx)(`label`,{htmlFor:`rule-priority`,children:`Priority`})}),(0,$.jsx)(I,{"aria-invalid":!!p.formState.errors.priority,id:`rule-priority`,inputMode:`numeric`,type:`number`,...p.register(`priority`,{valueAsNumber:!0})}),(0,$.jsx)(z,{errors:[p.formState.errors.priority]})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(G,{children:`Conditions`}),(0,$.jsx)(m,{disabled:h.length>=5,onClick:()=>g({field:`path-pattern`,rawValues:``}),size:`sm`,type:`button`,variant:`outline`,children:`Add condition`})]}),h.map((e,t)=>(0,$.jsx)(He,{form:p,index:t,onRemove:h.length>1?()=>_(t):void 0},e.id))]}),(0,$.jsxs)(L,{children:[(0,$.jsx)(G,{children:(0,$.jsx)(`label`,{htmlFor:`rule-forward-tg`,children:`Forward to target group`})}),(0,$.jsx)(te,{control:p.control,name:`forwardTargetGroupArn`,render:({field:e})=>(0,$.jsxs)(f,{onValueChange:e.onChange,value:e.value??``,children:[(0,$.jsx)(d,{"aria-invalid":!!p.formState.errors.forwardTargetGroupArn,className:`w-full`,id:`rule-forward-tg`,children:(0,$.jsx)(c,{placeholder:`Select target group`})}),(0,$.jsx)(u,{children:i.map(e=>(0,$.jsxs)(l,{value:e.TargetGroupArn??``,children:[e.TargetGroupName,` · `,e.Protocol,`:`,e.Port]},e.TargetGroupArn))})]})}),(0,$.jsx)(z,{errors:[p.formState.errors.forwardTargetGroupArn]})]})]}),(0,$.jsxs)(ae,{children:[(0,$.jsx)(oe,{disabled:r,children:`Cancel`}),(0,$.jsx)(ie,{disabled:r,onClick:v,children:qe(a,r)})]})]})})}function He(e){let t=(0,Te.c)(54),{form:n,index:r,onRemove:i}=e,a,o,s,h,g,_,v,y,b,x;if(t[0]!==n||t[1]!==r||t[2]!==i){let e=n.watch(`conditions.${r}.field`);s=n.formState.errors.conditions?.[r],y=`space-y-2 rounded-md border p-3`;let S=`rule-cond-${r}-field`,C;t[13]===S?C=t[14]:(C=(0,$.jsx)(G,{children:(0,$.jsx)(`label`,{htmlFor:S,children:`Type`})}),t[13]=S,t[14]=C);let w=`conditions.${r}.field`,T;t[15]===r?T=t[16]:(T=e=>{let{field:t}=e;return(0,$.jsxs)(f,{onValueChange:t.onChange,value:t.value,children:[(0,$.jsx)(d,{className:`w-full`,id:`rule-cond-${r}-field`,children:(0,$.jsx)(c,{})}),(0,$.jsxs)(u,{children:[(0,$.jsx)(l,{value:`path-pattern`,children:`Path pattern`}),(0,$.jsx)(l,{value:`host-header`,children:`Host header`}),(0,$.jsx)(l,{value:`http-header`,children:`HTTP header`}),(0,$.jsx)(l,{value:`http-request-method`,children:`HTTP method`}),(0,$.jsx)(l,{value:`source-ip`,children:`Source IP CIDR`}),(0,$.jsx)(l,{value:`query-string`,children:`Query string`})]})]})},t[15]=r,t[16]=T);let E;t[17]!==n.control||t[18]!==w||t[19]!==T?(E=(0,$.jsx)(te,{control:n.control,name:w,render:T}),t[17]=n.control,t[18]=w,t[19]=T,t[20]=E):E=t[20];let D;t[21]!==E||t[22]!==C?(D=(0,$.jsxs)(`div`,{className:`flex-1`,children:[C,E]}),t[21]=E,t[22]=C,t[23]=D):D=t[23];let O;t[24]!==r||t[25]!==i?(O=i&&(0,$.jsx)(m,{"aria-label":`Remove condition ${r+1}`,className:`self-end`,onClick:i,size:`sm`,type:`button`,variant:`ghost`,children:(0,$.jsx)(p,{className:`size-4`})}),t[24]=r,t[25]=i,t[26]=O):O=t[26],t[27]!==D||t[28]!==O?(b=(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[D,O]}),t[27]=D,t[28]=O,t[29]=b):b=t[29],x=e===`http-header`&&(0,$.jsxs)(L,{children:[(0,$.jsx)(G,{children:(0,$.jsx)(`label`,{htmlFor:`rule-cond-${r}-hdr-name`,children:`Header name`})}),(0,$.jsx)(I,{"aria-invalid":!!s?.httpHeaderName,id:`rule-cond-${r}-hdr-name`,placeholder:`X-Tenant`,...n.register(`conditions.${r}.httpHeaderName`)}),(0,$.jsx)(z,{errors:[s?.httpHeaderName]})]}),o=L;let k=`rule-cond-${r}-values`,A;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(comma or newline separated, max 5)`}),t[30]=A):A=t[30],t[31]===k?v=t[32]:(v=(0,$.jsx)(G,{children:(0,$.jsxs)(`label`,{htmlFor:k,children:[`Values`,` `,A]})}),t[31]=k,t[32]=v),a=I,h=!!s?.rawValues,g=`rule-cond-${r}-values`,_=Ue(e),t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=h,t[7]=g,t[8]=_,t[9]=v,t[10]=y,t[11]=b,t[12]=x}else a=t[3],o=t[4],s=t[5],h=t[6],g=t[7],_=t[8],v=t[9],y=t[10],b=t[11],x=t[12];let S;t[33]!==n||t[34]!==r?(S=n.register(`conditions.${r}.rawValues`),t[33]=n,t[34]=r,t[35]=S):S=t[35];let C;t[36]!==a||t[37]!==h||t[38]!==g||t[39]!==_||t[40]!==S?(C=(0,$.jsx)(a,{"aria-invalid":h,id:g,placeholder:_,...S}),t[36]=a,t[37]=h,t[38]=g,t[39]=_,t[40]=S,t[41]=C):C=t[41];let w=s?.rawValues,T;t[42]===w?T=t[43]:(T=(0,$.jsx)(z,{errors:[w]}),t[42]=w,t[43]=T);let E;t[44]!==o||t[45]!==T||t[46]!==v||t[47]!==C?(E=(0,$.jsxs)(o,{children:[v,C,T]}),t[44]=o,t[45]=T,t[46]=v,t[47]=C,t[48]=E):E=t[48];let D;return t[49]!==E||t[50]!==y||t[51]!==b||t[52]!==x?(D=(0,$.jsxs)(`div`,{className:y,children:[b,x,E]}),t[49]=E,t[50]=y,t[51]=b,t[52]=x,t[53]=D):D=t[53],D}function Ue(e){switch(e){case`path-pattern`:return`/api/*`;case`host-header`:return`*.example.com`;case`http-header`:return`acme`;case`http-request-method`:return`GET, POST`;case`source-ip`:return`10.0.0.0/8`;case`query-string`:return`key=value`;default:return``}}var We=new Set([`host-header`,`path-pattern`,`http-header`,`http-request-method`,`source-ip`,`query-string`]);function Ge(e){return e!==void 0&&We.has(e)}function Ke(e){let t=Re(e);return{field:Ge(e.Field)?e.Field:`path-pattern`,httpHeaderName:e.HttpHeaderConfig?.HttpHeaderName,rawValues:t.join(`, `)}}function qe(e,t){return t?e===`add`?`Adding…`:`Saving…`:e===`add`?`Add rule`:`Save changes`}function Je(e){return{protocol:me(e),port:80,defaultTargetGroupArn:``}}function Ye(e){if(e.Protocol!==`HTTPS`)return`—`;let t=e.Certificates?.[0]?.CertificateArn?.split(`/`).pop(),n=e.SslPolicy;return t&&n?`${n} · ${t}`:n??t??`—`}function Xe({loadBalancerArn:e,vpcId:t,lbType:n}){let r=de(n),{data:i}=R(A(e)),{data:a}=R(F),{data:o}=R(ne),{data:s}=R(j),c=D(),l=y(),u=O(),[d,f]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(),[_,v]=(0,Q.useState)(),[b,x]=(0,Q.useState)(),S=i.Listeners??[],C=a.TargetGroups??[],w=C.filter(e=>e.VpcId===t),T=o.CertificateSummaryList??[],E=s.SslPolicies??[],k=new Map;for(let e of C)e.TargetGroupArn&&e.TargetGroupName&&k.set(e.TargetGroupArn,e.TargetGroupName);let M=e=>{let t=e.DefaultActions?.[0];if(!t)return`—`;if(t.Type===`forward`&&t.TargetGroupArn){let e=k.get(t.TargetGroupArn);return e?`forward → ${e}`:`forward → ${t.TargetGroupArn}`}return t.Type??`—`};return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[c.error&&(0,$.jsx)(W,{error:c.error,msg:`Failed to create listener`}),u.error&&(0,$.jsx)(W,{error:u.error,msg:`Failed to modify listener`}),l.error&&(0,$.jsx)(W,{error:l.error,msg:`Failed to delete listener`}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[S.length,` listener`,S.length===1?``:`s`]}),(0,$.jsx)(m,{onClick:()=>f(!0),size:`sm`,children:`Add listener`})]}),S.length===0?(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:`No listeners configured.`}):(0,$.jsx)(`div`,{className:`overflow-x-auto rounded-lg border bg-card`,children:(0,$.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{className:`border-b text-left text-muted-foreground`,children:[(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Protocol`}),(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Port`}),(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`TLS`}),(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Default action`}),(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Listener ARN`}),(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:(0,$.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,$.jsx)(`tbody`,{children:S.map(e=>{let t=e.ListenerArn??``,n=b===t;return(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,$.jsx)(`td`,{className:`px-4 py-2`,children:e.Protocol}),(0,$.jsx)(`td`,{className:`px-4 py-2`,children:e.Port}),(0,$.jsx)(`td`,{className:`px-4 py-2 text-xs`,children:Ye(e)}),(0,$.jsx)(`td`,{className:`px-4 py-2 text-xs`,children:M(e)}),(0,$.jsx)(`td`,{className:`px-4 py-2 font-mono text-xs`,children:t}),(0,$.jsx)(`td`,{className:`px-4 py-2 text-right`,children:(0,$.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,$.jsx)(m,{"aria-label":`${n?`Hide`:`Show`} rules for listener ${e.Protocol}:${e.Port}`,onClick:()=>x(n?void 0:t),size:`sm`,variant:`ghost`,children:n?`Hide rules`:`Rules`}),(0,$.jsx)(m,{"aria-label":`Edit listener ${e.Protocol}:${e.Port}`,onClick:()=>g(e),size:`sm`,variant:`ghost`,children:(0,$.jsx)(we,{className:`size-4`})}),(0,$.jsx)(m,{"aria-label":`Delete listener ${e.Protocol}:${e.Port}`,onClick:()=>v(e),size:`sm`,variant:`ghost`,children:(0,$.jsx)(p,{className:`size-4`})})]})})]}),n&&t&&(0,$.jsx)(`tr`,{className:`border-b bg-muted/30 last:border-0`,children:(0,$.jsx)(`td`,{className:`px-4 py-3`,colSpan:6,children:(0,$.jsx)(Ie,{listenerArn:t,targetGroups:w})})})]},t)})})]})}),(0,$.jsx)(Ze,{certificates:T,isPending:c.isPending,lbType:n,onOpenChange:f,onSubmit:async t=>{try{await c.mutateAsync({loadBalancerArn:e,protocol:t.protocol,port:t.port,defaultTargetGroupArn:t.defaultTargetGroupArn,certificateArn:t.certificateArn,sslPolicy:t.sslPolicy}),f(!1)}catch{}},open:d,protocols:r,sslPolicies:E,targetGroups:w}),(0,$.jsx)(Qe,{certificates:T,isPending:u.isPending,listener:h,onOpenChange:e=>!e&&g(void 0),onSubmit:async t=>{if(h?.ListenerArn)try{await u.mutateAsync({listenerArn:h.ListenerArn,loadBalancerArn:e,protocol:t.protocol,port:t.port,defaultTargetGroupArn:t.defaultTargetGroupArn,certificateArn:t.certificateArn,sslPolicy:t.sslPolicy}),g(void 0)}catch{}},protocols:r,sslPolicies:E,targetGroups:w}),(0,$.jsx)(le,{description:_?`Delete listener ${_.Protocol}:${_.Port}? This cannot be undone.`:``,isPending:l.isPending,onConfirm:async()=>{if(_?.ListenerArn)try{await l.mutateAsync(_.ListenerArn)}finally{v(void 0)}},onOpenChange:e=>!e&&v(void 0),open:_!==void 0,title:`Delete listener`})]})}function Ze(e){let t=(0,Te.c)(42),{open:n,onOpenChange:r,lbType:i,protocols:a,targetGroups:o,certificates:s,sslPolicies:c,isPending:l,onSubmit:u}=e,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=q(pe),t[0]=d):d=t[0];let f;t[1]===i?f=t[2]:(f=Je(i),t[1]=i,t[2]=f);let p;t[3]===f?p=t[4]:(p={resolver:d,defaultValues:f},t[3]=f,t[4]=p);let m=V(p),h,g;t[5]!==m||t[6]!==i||t[7]!==n?(h=()=>{n||m.reset(Je(i))},g=[n,m,i],t[5]=m,t[6]=i,t[7]=n,t[8]=h,t[9]=g):(h=t[8],g=t[9]),(0,Q.useEffect)(h,g);let _;t[10]!==m||t[11]!==u?(_=m.handleSubmit(u),t[10]=m,t[11]=u,t[12]=_):_=t[12];let v=_,y;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(y={maxWidth:`32rem`,width:`calc(100vw - 2rem)`},t[13]=y):y=t[13];let b;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsxs)(se,{children:[(0,$.jsx)(re,{children:`Add listener`}),(0,$.jsx)(J,{children:`Listeners forward incoming traffic to a default target group.`})]}),t[14]=b):b=t[14];let x;t[15]===v?x=t[16]:(x=e=>{e.preventDefault(),v()},t[15]=v,t[16]=x);let S;t[17]!==s||t[18]!==m||t[19]!==a||t[20]!==c||t[21]!==o?(S=(0,$.jsx)(je,{certificates:s,form:m,protocols:a,sslPolicies:c,targetGroups:o}),t[17]=s,t[18]=m,t[19]=a,t[20]=c,t[21]=o,t[22]=S):S=t[22];let C;t[23]!==S||t[24]!==x?(C=(0,$.jsx)(`form`,{className:`min-w-0 space-y-4`,onSubmit:x,children:S}),t[23]=S,t[24]=x,t[25]=C):C=t[25];let w;t[26]===l?w=t[27]:(w=(0,$.jsx)(oe,{disabled:l,children:`Cancel`}),t[26]=l,t[27]=w);let T=l?`Adding…`:`Add listener`,E;t[28]!==v||t[29]!==l||t[30]!==T?(E=(0,$.jsx)(ie,{disabled:l,onClick:v,children:T}),t[28]=v,t[29]=l,t[30]=T,t[31]=E):E=t[31];let D;t[32]!==w||t[33]!==E?(D=(0,$.jsxs)(ae,{children:[w,E]}),t[32]=w,t[33]=E,t[34]=D):D=t[34];let O;t[35]!==C||t[36]!==D?(O=(0,$.jsxs)(Y,{className:`grid-cols-[minmax(0,1fr)]`,style:y,children:[b,C,D]}),t[35]=C,t[36]=D,t[37]=O):O=t[37];let k;return t[38]!==r||t[39]!==n||t[40]!==O?(k=(0,$.jsx)(ce,{onOpenChange:r,open:n,children:O}),t[38]=r,t[39]=n,t[40]=O,t[41]=k):k=t[41],k}function Qe(e){let t=(0,Te.c)(38),{listener:n,onOpenChange:r,protocols:i,targetGroups:a,certificates:o,sslPolicies:s,isPending:c,onSubmit:l}=e,u=n!==void 0,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d={resolver:q(pe),defaultValues:{protocol:`HTTP`,port:80,defaultTargetGroupArn:``}},t[0]=d):d=t[0];let f=V(d),p,m;t[1]!==f||t[2]!==n||t[3]!==i?(p=()=>{if(!n)return;let e=i.find(e=>e===n.Protocol)??i[0]??`HTTP`,t=he(e);f.reset({protocol:e,port:n.Port??80,defaultTargetGroupArn:n.DefaultActions?.[0]?.TargetGroupArn??``,certificateArn:t?n.Certificates?.[0]?.CertificateArn:void 0,sslPolicy:e===`HTTPS`?n.SslPolicy:void 0})},m=[n,f,i],t[1]=f,t[2]=n,t[3]=i,t[4]=p,t[5]=m):(p=t[4],m=t[5]),(0,Q.useEffect)(p,m);let h;t[6]!==f||t[7]!==l?(h=f.handleSubmit(l),t[6]=f,t[7]=l,t[8]=h):h=t[8];let g=h,_;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_={maxWidth:`32rem`,width:`calc(100vw - 2rem)`},t[9]=_):_=t[9];let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsxs)(se,{children:[(0,$.jsx)(re,{children:`Edit listener`}),(0,$.jsx)(J,{children:`Update port, protocol, or default target group. Changes apply without dropping the listener.`})]}),t[10]=v):v=t[10];let y;t[11]===g?y=t[12]:(y=e=>{e.preventDefault(),g()},t[11]=g,t[12]=y);let b;t[13]!==o||t[14]!==f||t[15]!==i||t[16]!==s||t[17]!==a?(b=(0,$.jsx)(je,{certificates:o,form:f,protocols:i,sslPolicies:s,targetGroups:a}),t[13]=o,t[14]=f,t[15]=i,t[16]=s,t[17]=a,t[18]=b):b=t[18];let x;t[19]!==y||t[20]!==b?(x=(0,$.jsx)(`form`,{className:`min-w-0 space-y-4`,onSubmit:y,children:b}),t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;t[22]===c?S=t[23]:(S=(0,$.jsx)(oe,{disabled:c,children:`Cancel`}),t[22]=c,t[23]=S);let C=c?`Saving…`:`Save changes`,w;t[24]!==g||t[25]!==c||t[26]!==C?(w=(0,$.jsx)(ie,{disabled:c,onClick:g,children:C}),t[24]=g,t[25]=c,t[26]=C,t[27]=w):w=t[27];let T;t[28]!==S||t[29]!==w?(T=(0,$.jsxs)(ae,{children:[S,w]}),t[28]=S,t[29]=w,t[30]=T):T=t[30];let E;t[31]!==T||t[32]!==x?(E=(0,$.jsxs)(Y,{className:`grid-cols-[minmax(0,1fr)]`,style:_,children:[v,x,T]}),t[31]=T,t[32]=x,t[33]=E):E=t[33];let D;return t[34]!==r||t[35]!==u||t[36]!==E?(D=(0,$.jsx)(ce,{onOpenChange:r,open:u,children:E}),t[34]=r,t[35]=u,t[36]=E,t[37]=D):D=t[37],D}function $e(e,t){if(e.length!==t.length)return!1;let n=new Set(t);return e.every(e=>n.has(e))}function et(e){let t=(0,Te.c)(46),{available:n,current:r,onSubmit:i,isPending:a,error:o,isSuccess:s}=e,c;t[0]===r?c=t[1]:(c=[...r],t[0]=r,t[1]=c);let l=c,[u,d]=(0,Q.useState)(l),f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=e=>{d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},t[2]=f):f=t[2];let p=f,h;t[3]===l?h=t[4]:(h=()=>d(l),t[3]=l,t[4]=h);let g=h,_;t[5]!==l||t[6]!==u?(_=$e(u,l),t[5]=l,t[6]=u,t[7]=_):_=t[7];let v=!_,y=u.length===0,b;t[8]!==v||t[9]!==y||t[10]!==i||t[11]!==u?(b=e=>{e.preventDefault(),!(!v||y)&&i(u)},t[8]=v,t[9]=y,t[10]=i,t[11]=u,t[12]=b):b=t[12];let x;t[13]===o?x=t[14]:(x=o&&(0,$.jsx)(`div`,{className:`mb-4 rounded-md border border-destructive bg-destructive/10 p-3 text-sm text-destructive`,role:`alert`,children:o.message||`Failed to update security groups`}),t[13]=o,t[14]=x);let S;t[15]!==v||t[16]!==s?(S=s&&!v&&(0,$.jsx)(`div`,{className:`mb-4 rounded-md border border-emerald-500 bg-emerald-500/10 p-3 text-sm text-emerald-700 dark:text-emerald-400`,role:`status`,children:`Security groups updated.`}),t[15]=v,t[16]=s,t[17]=S):S=t[17];let C;t[18]!==n||t[19]!==u?(C=n.length===0?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No security groups in this VPC.`}):n.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,$.jsx)(`input`,{"aria-label":`Security group ${e.GroupId} (${e.GroupName})`,checked:u.includes(e.GroupId??``),onChange:()=>p(e.GroupId??``),type:`checkbox`}),(0,$.jsxs)(`span`,{className:`font-mono`,children:[e.GroupId,` (`,e.GroupName,`)`]})]},e.GroupId)),t[18]=n,t[19]=u,t[20]=C):C=t[20];let w;t[21]===y?w=t[22]:(w=y&&(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:`At least one security group is required.`}),t[21]=y,t[22]=w);let T;t[23]!==C||t[24]!==w?(T=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 p-4`,children:[C,w]}),t[23]=C,t[24]=w,t[25]=T):T=t[25];let E=v?`Unsaved changes`:`No changes`,D;t[26]===E?D=t[27]:(D=(0,$.jsx)(`span`,{className:`mr-auto text-xs text-muted-foreground`,children:E}),t[26]=E,t[27]=D);let O=a||!v,k;t[28]!==g||t[29]!==O?(k=(0,$.jsx)(m,{disabled:O,onClick:g,size:`sm`,type:`button`,variant:`secondary`,children:`Reset`}),t[28]=g,t[29]=O,t[30]=k):k=t[30];let A=a||!v||y,j=a?`Saving…`:`Save changes`,M;t[31]!==A||t[32]!==j?(M=(0,$.jsx)(m,{disabled:A,size:`sm`,type:`submit`,children:j}),t[31]=A,t[32]=j,t[33]=M):M=t[33];let N;t[34]!==D||t[35]!==k||t[36]!==M?(N=(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t p-4`,children:[D,k,M]}),t[34]=D,t[35]=k,t[36]=M,t[37]=N):N=t[37];let P;t[38]!==T||t[39]!==N?(P=(0,$.jsxs)(`div`,{className:`rounded-lg border bg-card`,children:[T,N]}),t[38]=T,t[39]=N,t[40]=P):P=t[40];let F;return t[41]!==P||t[42]!==b||t[43]!==x||t[44]!==S?(F=(0,$.jsxs)(`form`,{onSubmit:b,children:[x,S,P]}),t[41]=P,t[42]=b,t[43]=x,t[44]=S,t[45]=F):F=t[45],F}function tt(e,t){if(e.length!==t.length)return!1;let n=new Set(t);return e.every(e=>n.has(e))}function nt(e){let t=o(e.Tags),n=e.AvailabilityZone?` · ${e.AvailabilityZone}`:``,r=e.CidrBlock?` (${e.CidrBlock})`:``;return`${e.SubnetId}${t?` — ${t}`:``}${r}${n}`}function rt(e){let t=(0,Te.c)(47),{available:n,current:r,onSubmit:i,isPending:a,error:o,isSuccess:s}=e,c;t[0]===r?c=t[1]:(c=[...r],t[0]=r,t[1]=c);let l=c,[u,d]=(0,Q.useState)(l),f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=e=>{d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},t[2]=f):f=t[2];let p=f,h;t[3]===l?h=t[4]:(h=()=>d(l),t[3]=l,t[4]=h);let g=h,_;t[5]!==l||t[6]!==u?(_=tt(u,l),t[5]=l,t[6]=u,t[7]=_):_=t[7];let v=!_,y=u.length===0,b;t[8]!==v||t[9]!==y||t[10]!==i||t[11]!==u?(b=e=>{e.preventDefault(),!(!v||y)&&i(u)},t[8]=v,t[9]=y,t[10]=i,t[11]=u,t[12]=b):b=t[12];let x;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(`div`,{className:`mb-4 rounded-md border border-amber-500 bg-amber-500/10 p-3 text-sm text-amber-700 dark:text-amber-400`,role:`note`,children:`Applying a subnet change re-homes the load balancer by relaunching its underlying system VM. Expect a brief data-plane interruption while it restarts.`}),t[13]=x):x=t[13];let S;t[14]===o?S=t[15]:(S=o&&(0,$.jsx)(`div`,{className:`mb-4 rounded-md border border-destructive bg-destructive/10 p-3 text-sm text-destructive`,role:`alert`,children:o.message||`Failed to update subnets`}),t[14]=o,t[15]=S);let C;t[16]!==v||t[17]!==s?(C=s&&!v&&(0,$.jsx)(`div`,{className:`mb-4 rounded-md border border-emerald-500 bg-emerald-500/10 p-3 text-sm text-emerald-700 dark:text-emerald-400`,role:`status`,children:`Subnets updated.`}),t[16]=v,t[17]=s,t[18]=C):C=t[18];let w;t[19]!==n||t[20]!==u?(w=n.length===0?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No subnets in this VPC.`}):n.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,$.jsx)(`input`,{"aria-label":`Subnet ${e.SubnetId}`,checked:u.includes(e.SubnetId??``),onChange:()=>p(e.SubnetId??``),type:`checkbox`}),(0,$.jsx)(`span`,{className:`font-mono`,children:nt(e)})]},e.SubnetId)),t[19]=n,t[20]=u,t[21]=w):w=t[21];let T;t[22]===y?T=t[23]:(T=y&&(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:`At least one subnet is required.`}),t[22]=y,t[23]=T);let E;t[24]!==T||t[25]!==w?(E=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 p-4`,children:[w,T]}),t[24]=T,t[25]=w,t[26]=E):E=t[26];let D=v?`Unsaved changes`:`No changes`,O;t[27]===D?O=t[28]:(O=(0,$.jsx)(`span`,{className:`mr-auto text-xs text-muted-foreground`,children:D}),t[27]=D,t[28]=O);let k=a||!v,A;t[29]!==g||t[30]!==k?(A=(0,$.jsx)(m,{disabled:k,onClick:g,size:`sm`,type:`button`,variant:`secondary`,children:`Reset`}),t[29]=g,t[30]=k,t[31]=A):A=t[31];let j=a||!v||y,M=a?`Saving…`:`Save changes`,N;t[32]!==j||t[33]!==M?(N=(0,$.jsx)(m,{disabled:j,size:`sm`,type:`submit`,children:M}),t[32]=j,t[33]=M,t[34]=N):N=t[34];let P;t[35]!==O||t[36]!==A||t[37]!==N?(P=(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t p-4`,children:[O,A,N]}),t[35]=O,t[36]=A,t[37]=N,t[38]=P):P=t[38];let F;t[39]!==E||t[40]!==P?(F=(0,$.jsxs)(`div`,{className:`rounded-lg border bg-card`,children:[E,P]}),t[39]=E,t[40]=P,t[41]=F):F=t[41];let I;return t[42]!==F||t[43]!==b||t[44]!==S||t[45]!==C?(I=(0,$.jsxs)(`form`,{onSubmit:b,children:[x,S,C,F]}),t[42]=F,t[43]=b,t[44]=S,t[45]=C,t[46]=I):I=t[46],I}function it({arn:e}){let t=i(),{data:n}=R(k(e)),{data:r}=R(M(e)),{data:s}=R(N([e])),{data:c}=R(g),{data:l}=R(_),u=w(),d=b(),f=v(),h=C(),y=S(),[x,T]=(0,Q.useState)(!1),E=n.LoadBalancers?.[0];if(!E?.LoadBalancerArn)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(B,{to:`/ec2/describe-load-balancers`,children:`Back to load balancers`}),(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:`Load balancer not found.`})]});let D=async()=>{try{await u.mutateAsync(e),t({to:`/ec2/describe-load-balancers`})}finally{T(!1)}},O=c.Subnets??[],A=e=>{let t=O.find(t=>t.SubnetId===e);if(!t)return e;let n=o(t.Tags),r=t.CidrBlock?` (${t.CidrBlock})`:``;return n?`${e} — ${n}${r}`:`${e}${r}`},j=r.Attributes??[],P=s?.TagDescriptions?.find(t=>t.ResourceArn===e)?.Tags??[],F=(E.SecurityGroups??[]).filter(e=>e!==void 0),I=(l.SecurityGroups??[]).filter(e=>e.VpcId===E.VpcId),L=O.filter(e=>e.VpcId===E.VpcId),ee=(E.AvailabilityZones??[]).map(e=>e.SubnetId).filter(e=>e!==void 0),z=E.Type===`network`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(B,{to:`/ec2/describe-load-balancers`,children:`Back to load balancers`}),u.error&&(0,$.jsx)(W,{error:u.error,msg:`Failed to delete load balancer`}),(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsx)(K,{actions:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(m,{onClick:()=>T(!0),size:`sm`,variant:`destructive`,children:[(0,$.jsx)(p,{className:`size-4`}),`Delete`]}),(0,$.jsx)(ue,{state:E.State?.Code})]}),subtitle:`Load Balancer Details`,title:E.LoadBalancerName??E.LoadBalancerArn}),(0,$.jsxs)(Ce,{defaultValue:`overview`,children:[(0,$.jsxs)(xe,{children:[(0,$.jsx)(be,{value:`overview`,children:`Overview`}),(0,$.jsx)(be,{value:`listeners`,children:`Listeners`}),(0,$.jsx)(be,{value:`subnets`,children:`Subnets`}),!z&&(0,$.jsx)(be,{value:`security-groups`,children:`Security groups`}),(0,$.jsx)(be,{value:`attributes`,children:`Attributes`}),(0,$.jsx)(be,{value:`tags`,children:`Tags`})]}),(0,$.jsxs)(Se,{value:`overview`,children:[(0,$.jsxs)(X,{children:[(0,$.jsx)(X.Header,{children:`Load balancer`}),(0,$.jsxs)(X.Content,{children:[(0,$.jsx)(Z,{label:`ARN`,value:E.LoadBalancerArn}),(0,$.jsx)(Z,{label:`DNS name`,value:E.DNSName}),(0,$.jsx)(Z,{label:`State`,value:E.State?.Reason?`${E.State.Code} — ${E.State.Reason}`:E.State?.Code}),(0,$.jsx)(Z,{label:`Type`,value:E.Type}),(0,$.jsx)(Z,{label:`Scheme`,value:E.Scheme}),(0,$.jsx)(Z,{label:`IP address type`,value:E.IpAddressType}),(0,$.jsx)(Z,{label:`VPC`,value:E.VpcId}),(0,$.jsx)(Z,{label:`Created at`,value:a(E.CreatedTime)})]})]}),(0,$.jsxs)(X,{children:[(0,$.jsx)(X.Header,{children:`Availability zones`}),(0,$.jsx)(X.Content,{children:(E.AvailabilityZones??[]).map(e=>(0,$.jsx)(Z,{label:e.ZoneName??`—`,value:e.SubnetId?A(e.SubnetId):void 0},`${e.ZoneName}-${e.SubnetId}`))})]}),(E.SecurityGroups??[]).length>0&&(0,$.jsxs)(X,{children:[(0,$.jsx)(X.Header,{children:`Security groups`}),(0,$.jsx)(X.Content,{children:(E.SecurityGroups??[]).map(e=>(0,$.jsx)(Z,{label:`Security group`,value:e},e))})]})]}),(0,$.jsx)(Se,{value:`listeners`,children:(0,$.jsx)(Xe,{lbType:z?`network`:`application`,loadBalancerArn:e,vpcId:E.VpcId})}),(0,$.jsx)(Se,{value:`subnets`,children:(0,$.jsx)(rt,{available:L,current:ee,error:y.error,isPending:y.isPending,isSuccess:y.isSuccess,onSubmit:t=>y.mutate({loadBalancerArn:e,subnetIds:t})})}),!z&&(0,$.jsx)(Se,{value:`security-groups`,children:(0,$.jsx)(et,{available:I,current:F,error:h.error,isPending:h.isPending,isSuccess:h.isSuccess,onSubmit:t=>h.mutate({loadBalancerArn:e,securityGroupIds:t})})}),(0,$.jsx)(Se,{value:`attributes`,children:(0,$.jsx)(_e,{attributes:j,error:d.error,isPending:d.isPending,isSuccess:d.isSuccess,onSubmit:t=>{d.mutate({loadBalancerArn:e,attributes:t})},specs:ve})}),(0,$.jsx)(Se,{value:`tags`,children:(0,$.jsx)(ye,{error:f.error,isPending:f.isPending,isSuccess:f.isSuccess,onSubmit:t=>f.mutate({resourceArn:e,tags:t,initialKeys:P.map(e=>e.Key??``).filter(e=>e.length>0)}),tags:P})})]})]}),(0,$.jsx)(le,{description:`Are you sure you want to delete load balancer "${E.LoadBalancerName??E.LoadBalancerArn}"? This action cannot be undone.`,isPending:u.isPending,onConfirm:D,onOpenChange:T,open:x,title:`Delete load balancer`})]})}function at(){let e=(0,Te.c)(2),{id:t}=U.useParams(),n=decodeURIComponent(t),r;return e[0]===n?r=e[1]:(r=(0,$.jsx)(it,{arn:n}),e[0]=n,e[1]=r),r}export{at as component}; \ No newline at end of file diff --git a/spinifex/services/spinifexui/frontend/dist/assets/target-group-form.js b/spinifex/services/spinifexui/frontend/dist/assets/target-group-form.js index aca7c941a..a529e6aaf 100644 --- a/spinifex/services/spinifexui/frontend/dist/assets/target-group-form.js +++ b/spinifex/services/spinifexui/frontend/dist/assets/target-group-form.js @@ -1 +1 @@ -import{n as e,t}from"./compiler-runtime.js";import{nn as ee}from"./auth.js";import{c as te,i as ne,n as re,s as ie,t as ae}from"./select.js";import{t as oe}from"./plus.js";import{t as se}from"./trash-2.js";import{t as ce}from"./button.js";import{Ln as n,Qt as r,_n as le,an as ue,en as i,in as de,mn as fe,nn as a,rn as pe}from"./index.js";var me=t(),o=e();function he(e){let t=(0,me.c)(147),{form:ee,vpcs:ne,allowedProtocols:he}=e,ve;t[0]===he?ve=t[1]:(ve=he===void 0?[`HTTP`,`HTTPS`,`TCP`,`UDP`,`TLS`,`TCP_UDP`]:he,t[0]=he,t[1]=ve);let ye=ve,{control:s,register:c,setValue:l,getValues:u,formState:be}=ee,{errors:d}=be,xe;t[2]===s?xe=t[3]:(xe={control:s,name:`tags`},t[2]=s,t[3]=xe);let Se=le(xe),Ce;t[4]===s?Ce=t[5]:(Ce={control:s,name:`protocol`},t[4]=s,t[5]=Ce);let we=le(Ce),f=we===`HTTP`||we===`HTTPS`,Te;t[6]===l?Te=t[7]:(Te=e=>{e&&(l(`protocol`,e),l(`healthCheck.protocol`,e===`HTTP`||e===`HTTPS`?`HTTP`:`TCP`))},t[6]=l,t[7]=Te);let Ee=Te,De;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(De=(0,o.jsx)(a,{children:(0,o.jsx)(`label`,{htmlFor:`tg-name`,children:`Name`})}),t[8]=De):De=t[8];let Oe=!!d.name,p;t[9]===c?p=t[10]:(p=c(`name`),t[9]=c,t[10]=p);let m;t[11]!==Oe||t[12]!==p?(m=(0,o.jsx)(n,{"aria-invalid":Oe,id:`tg-name`,placeholder:`my-target-group`,...p}),t[11]=Oe,t[12]=p,t[13]=m):m=t[13];let h;t[14]===d.name?h=t[15]:(h=(0,o.jsx)(i,{errors:[d.name]}),t[14]=d.name,t[15]=h);let g;t[16]!==m||t[17]!==h?(g=(0,o.jsxs)(r,{children:[De,m,h]}),t[16]=m,t[17]=h,t[18]=g):g=t[18];let ke;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,o.jsx)(a,{children:(0,o.jsx)(`label`,{htmlFor:`tg-protocol`,children:`Protocol`})}),t[19]=ke):ke=t[19];let _;t[20]!==ye||t[21]!==Ee?(_=e=>{let{field:t}=e;return(0,o.jsxs)(ae,{onValueChange:Ee,value:t.value,children:[(0,o.jsx)(ie,{className:`w-full`,id:`tg-protocol`,children:(0,o.jsx)(te,{})}),(0,o.jsx)(re,{children:ye.map(_e)})]})},t[20]=ye,t[21]=Ee,t[22]=_):_=t[22];let v;t[23]!==s||t[24]!==_?(v=(0,o.jsxs)(r,{children:[ke,(0,o.jsx)(fe,{control:s,name:`protocol`,render:_})]}),t[23]=s,t[24]=_,t[25]=v):v=t[25];let Ae;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=(0,o.jsx)(a,{children:(0,o.jsx)(`label`,{htmlFor:`tg-port`,children:`Port`})}),t[26]=Ae):Ae=t[26];let je=!!d.port,y;t[27]===c?y=t[28]:(y=c(`port`,{valueAsNumber:!0}),t[27]=c,t[28]=y);let b;t[29]!==je||t[30]!==y?(b=(0,o.jsx)(n,{"aria-invalid":je,id:`tg-port`,inputMode:`numeric`,placeholder:`80`,type:`number`,...y}),t[29]=je,t[30]=y,t[31]=b):b=t[31];let x;t[32]===d.port?x=t[33]:(x=(0,o.jsx)(i,{errors:[d.port]}),t[32]=d.port,t[33]=x);let S;t[34]!==b||t[35]!==x?(S=(0,o.jsxs)(r,{children:[Ae,b,x]}),t[34]=b,t[35]=x,t[36]=S):S=t[36];let Me;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(Me=(0,o.jsx)(a,{children:(0,o.jsx)(`label`,{htmlFor:`tg-vpc`,children:`VPC`})}),t[37]=Me):Me=t[37];let C;t[38]!==d.vpcId||t[39]!==ne?(C=e=>{let{field:t}=e;return(0,o.jsxs)(ae,{onValueChange:e=>t.onChange(e),value:t.value??``,children:[(0,o.jsx)(ie,{"aria-invalid":!!d.vpcId,className:`w-full`,id:`tg-vpc`,children:(0,o.jsx)(te,{placeholder:`Select VPC`})}),(0,o.jsx)(re,{children:ne.map(ge)})]})},t[38]=d.vpcId,t[39]=ne,t[40]=C):C=t[40];let w;t[41]!==s||t[42]!==C?(w=(0,o.jsx)(fe,{control:s,name:`vpcId`,render:C}),t[41]=s,t[42]=C,t[43]=w):w=t[43];let T;t[44]===d.vpcId?T=t[45]:(T=(0,o.jsx)(i,{errors:[d.vpcId]}),t[44]=d.vpcId,t[45]=T);let E;t[46]!==w||t[47]!==T?(E=(0,o.jsxs)(r,{children:[Me,w,T]}),t[46]=w,t[47]=T,t[48]=E):E=t[48];let Ne;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=(0,o.jsx)(ue,{className:`text-left text-sm font-medium text-muted-foreground hover:text-foreground`,render:(0,o.jsx)(`button`,{"aria-label":`Health check settings`,type:`button`}),children:`Health check settings`}),t[49]=Ne):Ne=t[49];let D;t[50]!==d.healthCheck?.path||t[51]!==f||t[52]!==c?(D=f&&(0,o.jsxs)(r,{children:[(0,o.jsx)(a,{children:(0,o.jsx)(`label`,{htmlFor:`hc-path`,children:`Path`})}),(0,o.jsx)(n,{"aria-invalid":!!d.healthCheck?.path,id:`hc-path`,placeholder:`/`,...c(`healthCheck.path`)}),(0,o.jsx)(i,{errors:[d.healthCheck?.path]})]}),t[50]=d.healthCheck?.path,t[51]=f,t[52]=c,t[53]=D):D=t[53];let Pe;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=(0,o.jsx)(a,{children:(0,o.jsx)(`label`,{htmlFor:`hc-port`,children:`Port`})}),t[54]=Pe):Pe=t[54];let Fe=!!d.healthCheck?.port,O;t[55]===c?O=t[56]:(O=c(`healthCheck.port`),t[55]=c,t[56]=O);let k;t[57]!==Fe||t[58]!==O?(k=(0,o.jsx)(n,{"aria-invalid":Fe,id:`hc-port`,placeholder:`traffic-port or numeric`,...O}),t[57]=Fe,t[58]=O,t[59]=k):k=t[59];let Ie=d.healthCheck?.port,A;t[60]===Ie?A=t[61]:(A=(0,o.jsx)(i,{errors:[Ie]}),t[60]=Ie,t[61]=A);let j;t[62]!==k||t[63]!==A?(j=(0,o.jsxs)(r,{children:[Pe,k,A]}),t[62]=k,t[63]=A,t[64]=j):j=t[64];let Le;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(Le=(0,o.jsx)(a,{children:(0,o.jsx)(`label`,{htmlFor:`hc-interval`,children:`Interval (seconds)`})}),t[65]=Le):Le=t[65];let Re=!!d.healthCheck?.intervalSeconds,M;t[66]===c?M=t[67]:(M=c(`healthCheck.intervalSeconds`,{valueAsNumber:!0}),t[66]=c,t[67]=M);let N;t[68]!==Re||t[69]!==M?(N=(0,o.jsx)(n,{"aria-invalid":Re,id:`hc-interval`,inputMode:`numeric`,type:`number`,...M}),t[68]=Re,t[69]=M,t[70]=N):N=t[70];let ze=d.healthCheck?.intervalSeconds,P;t[71]===ze?P=t[72]:(P=(0,o.jsx)(i,{errors:[ze]}),t[71]=ze,t[72]=P);let F;t[73]!==N||t[74]!==P?(F=(0,o.jsxs)(r,{children:[Le,N,P]}),t[73]=N,t[74]=P,t[75]=F):F=t[75];let Be;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(Be=(0,o.jsx)(a,{children:(0,o.jsx)(`label`,{htmlFor:`hc-timeout`,children:`Timeout (seconds)`})}),t[76]=Be):Be=t[76];let Ve=!!d.healthCheck?.timeoutSeconds,I;t[77]===c?I=t[78]:(I=c(`healthCheck.timeoutSeconds`,{valueAsNumber:!0}),t[77]=c,t[78]=I);let L;t[79]!==Ve||t[80]!==I?(L=(0,o.jsx)(n,{"aria-invalid":Ve,id:`hc-timeout`,inputMode:`numeric`,type:`number`,...I}),t[79]=Ve,t[80]=I,t[81]=L):L=t[81];let He=d.healthCheck?.timeoutSeconds,R;t[82]===He?R=t[83]:(R=(0,o.jsx)(i,{errors:[He]}),t[82]=He,t[83]=R);let z;t[84]!==L||t[85]!==R?(z=(0,o.jsxs)(r,{children:[Be,L,R]}),t[84]=L,t[85]=R,t[86]=z):z=t[86];let Ue;t[87]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(0,o.jsx)(a,{children:(0,o.jsx)(`label`,{htmlFor:`hc-healthy`,children:`Healthy threshold`})}),t[87]=Ue):Ue=t[87];let We=!!d.healthCheck?.healthyThresholdCount,B;t[88]===c?B=t[89]:(B=c(`healthCheck.healthyThresholdCount`,{valueAsNumber:!0}),t[88]=c,t[89]=B);let V;t[90]!==We||t[91]!==B?(V=(0,o.jsx)(n,{"aria-invalid":We,id:`hc-healthy`,inputMode:`numeric`,type:`number`,...B}),t[90]=We,t[91]=B,t[92]=V):V=t[92];let Ge=d.healthCheck?.healthyThresholdCount,H;t[93]===Ge?H=t[94]:(H=(0,o.jsx)(i,{errors:[Ge]}),t[93]=Ge,t[94]=H);let U;t[95]!==V||t[96]!==H?(U=(0,o.jsxs)(r,{children:[Ue,V,H]}),t[95]=V,t[96]=H,t[97]=U):U=t[97];let Ke;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=(0,o.jsx)(a,{children:(0,o.jsx)(`label`,{htmlFor:`hc-unhealthy`,children:`Unhealthy threshold`})}),t[98]=Ke):Ke=t[98];let qe=!!d.healthCheck?.unhealthyThresholdCount,W;t[99]===c?W=t[100]:(W=c(`healthCheck.unhealthyThresholdCount`,{valueAsNumber:!0}),t[99]=c,t[100]=W);let G;t[101]!==qe||t[102]!==W?(G=(0,o.jsx)(n,{"aria-invalid":qe,id:`hc-unhealthy`,inputMode:`numeric`,type:`number`,...W}),t[101]=qe,t[102]=W,t[103]=G):G=t[103];let Je=d.healthCheck?.unhealthyThresholdCount,K;t[104]===Je?K=t[105]:(K=(0,o.jsx)(i,{errors:[Je]}),t[104]=Je,t[105]=K);let q;t[106]!==G||t[107]!==K?(q=(0,o.jsxs)(r,{children:[Ke,G,K]}),t[106]=G,t[107]=K,t[108]=q):q=t[108];let J;t[109]!==d.healthCheck?.matcher||t[110]!==f||t[111]!==c?(J=f&&(0,o.jsxs)(r,{children:[(0,o.jsx)(a,{children:(0,o.jsx)(`label`,{htmlFor:`hc-matcher`,children:`Matcher (HTTP codes)`})}),(0,o.jsx)(n,{"aria-invalid":!!d.healthCheck?.matcher,id:`hc-matcher`,placeholder:`200 or 200-299 or 200,201`,...c(`healthCheck.matcher`)}),(0,o.jsx)(i,{errors:[d.healthCheck?.matcher]})]}),t[109]=d.healthCheck?.matcher,t[110]=f,t[111]=c,t[112]=J):J=t[112];let Y;t[113]!==D||t[114]!==j||t[115]!==F||t[116]!==z||t[117]!==U||t[118]!==q||t[119]!==J?(Y=(0,o.jsxs)(pe,{children:[Ne,(0,o.jsxs)(de,{className:`mt-3 space-y-4 border-l-2 border-muted pl-4`,children:[D,j,F,z,U,q,J]})]}),t[113]=D,t[114]=j,t[115]=F,t[116]=z,t[117]=U,t[118]=q,t[119]=J,t[120]=Y):Y=t[120];let Ye;t[121]===Symbol.for(`react.memo_cache_sentinel`)?(Ye=(0,o.jsx)(a,{children:`Tags`}),t[121]=Ye):Ye=t[121];let X;if(t[122]!==u||t[123]!==c||t[124]!==l||t[125]!==Se){let e;t[127]!==u||t[128]!==c||t[129]!==l?(e=(e,t)=>(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(n,{placeholder:`Key`,...c(`tags.${t}.key`)}),(0,o.jsx)(n,{placeholder:`Value`,...c(`tags.${t}.value`)}),(0,o.jsx)(ce,{onClick:()=>l(`tags`,u(`tags`).filter((e,ee)=>ee!==t)),size:`icon`,type:`button`,variant:`ghost`,children:(0,o.jsx)(se,{className:`size-3.5`})})]},t),t[127]=u,t[128]=c,t[129]=l,t[130]=e):e=t[130],X=Se.map(e),t[122]=u,t[123]=c,t[124]=l,t[125]=Se,t[126]=X}else X=t[126];let Z;t[131]!==u||t[132]!==l?(Z=()=>l(`tags`,[...u(`tags`),{key:``,value:``}]),t[131]=u,t[132]=l,t[133]=Z):Z=t[133];let Xe;t[134]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=(0,o.jsx)(oe,{className:`size-3.5`}),t[134]=Xe):Xe=t[134];let Q;t[135]===Z?Q=t[136]:(Q=(0,o.jsxs)(ce,{onClick:Z,size:`sm`,type:`button`,variant:`outline`,children:[Xe,`Add tag`]}),t[135]=Z,t[136]=Q);let $;t[137]!==X||t[138]!==Q?($=(0,o.jsxs)(r,{children:[Ye,(0,o.jsxs)(`div`,{className:`space-y-2`,children:[X,Q]})]}),t[137]=X,t[138]=Q,t[139]=$):$=t[139];let Ze;return t[140]!==g||t[141]!==v||t[142]!==S||t[143]!==E||t[144]!==Y||t[145]!==$?(Ze=(0,o.jsxs)(o.Fragment,{children:[g,v,S,E,Y,$]}),t[140]=g,t[141]=v,t[142]=S,t[143]=E,t[144]=Y,t[145]=$,t[146]=Ze):Ze=t[146],Ze}function ge(e){let t=ee(e.Tags);return(0,o.jsx)(ne,{value:e.VpcId??``,children:t?`${e.VpcId} (${t})`:`${e.VpcId} (${e.CidrBlock})`},e.VpcId)}function _e(e){return(0,o.jsx)(ne,{value:e,children:e},e)}export{he as t}; \ No newline at end of file +import{n as e,t}from"./compiler-runtime.js";import{nn as ee}from"./auth.js";import{c as te,i as ne,n as re,s as ie,t as ae}from"./select.js";import{t as oe}from"./plus.js";import{t as se}from"./trash-2.js";import{t as ce}from"./button.js";import{Ln as n,Qt as r,_n as le,an as ue,en as i,in as de,mn as fe,nn as a,rn as pe}from"./index.js";var me=t(),o=e(),he=[`HTTP`,`HTTPS`,`TCP`,`UDP`,`TLS`,`TCP_UDP`];function ge(e){let t=(0,me.c)(145),{form:ee,vpcs:ne,allowedProtocols:ge}=e,ye=ge===void 0?he:ge,{control:s,register:c,setValue:l,getValues:u,formState:be}=ee,{errors:d}=be,xe;t[0]===s?xe=t[1]:(xe={control:s,name:`tags`},t[0]=s,t[1]=xe);let Se=le(xe),Ce;t[2]===s?Ce=t[3]:(Ce={control:s,name:`protocol`},t[2]=s,t[3]=Ce);let we=le(Ce),f=we===`HTTP`||we===`HTTPS`,Te;t[4]===l?Te=t[5]:(Te=e=>{e&&(l(`protocol`,e),l(`healthCheck.protocol`,e===`HTTP`||e===`HTTPS`?`HTTP`:`TCP`))},t[4]=l,t[5]=Te);let Ee=Te,De;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(De=(0,o.jsx)(a,{children:(0,o.jsx)(`label`,{htmlFor:`tg-name`,children:`Name`})}),t[6]=De):De=t[6];let Oe=!!d.name,p;t[7]===c?p=t[8]:(p=c(`name`),t[7]=c,t[8]=p);let m;t[9]!==Oe||t[10]!==p?(m=(0,o.jsx)(n,{"aria-invalid":Oe,id:`tg-name`,placeholder:`my-target-group`,...p}),t[9]=Oe,t[10]=p,t[11]=m):m=t[11];let h;t[12]===d.name?h=t[13]:(h=(0,o.jsx)(i,{errors:[d.name]}),t[12]=d.name,t[13]=h);let g;t[14]!==h||t[15]!==m?(g=(0,o.jsxs)(r,{children:[De,m,h]}),t[14]=h,t[15]=m,t[16]=g):g=t[16];let ke;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,o.jsx)(a,{children:(0,o.jsx)(`label`,{htmlFor:`tg-protocol`,children:`Protocol`})}),t[17]=ke):ke=t[17];let _;t[18]!==ye||t[19]!==Ee?(_=e=>{let{field:t}=e;return(0,o.jsxs)(ae,{onValueChange:Ee,value:t.value,children:[(0,o.jsx)(ie,{className:`w-full`,id:`tg-protocol`,children:(0,o.jsx)(te,{})}),(0,o.jsx)(re,{children:ye.map(ve)})]})},t[18]=ye,t[19]=Ee,t[20]=_):_=t[20];let v;t[21]!==s||t[22]!==_?(v=(0,o.jsxs)(r,{children:[ke,(0,o.jsx)(fe,{control:s,name:`protocol`,render:_})]}),t[21]=s,t[22]=_,t[23]=v):v=t[23];let Ae;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=(0,o.jsx)(a,{children:(0,o.jsx)(`label`,{htmlFor:`tg-port`,children:`Port`})}),t[24]=Ae):Ae=t[24];let je=!!d.port,y;t[25]===c?y=t[26]:(y=c(`port`,{valueAsNumber:!0}),t[25]=c,t[26]=y);let b;t[27]!==je||t[28]!==y?(b=(0,o.jsx)(n,{"aria-invalid":je,id:`tg-port`,inputMode:`numeric`,placeholder:`80`,type:`number`,...y}),t[27]=je,t[28]=y,t[29]=b):b=t[29];let x;t[30]===d.port?x=t[31]:(x=(0,o.jsx)(i,{errors:[d.port]}),t[30]=d.port,t[31]=x);let S;t[32]!==b||t[33]!==x?(S=(0,o.jsxs)(r,{children:[Ae,b,x]}),t[32]=b,t[33]=x,t[34]=S):S=t[34];let Me;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(Me=(0,o.jsx)(a,{children:(0,o.jsx)(`label`,{htmlFor:`tg-vpc`,children:`VPC`})}),t[35]=Me):Me=t[35];let C;t[36]!==d.vpcId||t[37]!==ne?(C=e=>{let{field:t}=e;return(0,o.jsxs)(ae,{onValueChange:e=>t.onChange(e),value:t.value??``,children:[(0,o.jsx)(ie,{"aria-invalid":!!d.vpcId,className:`w-full`,id:`tg-vpc`,children:(0,o.jsx)(te,{placeholder:`Select VPC`})}),(0,o.jsx)(re,{children:ne.map(_e)})]})},t[36]=d.vpcId,t[37]=ne,t[38]=C):C=t[38];let w;t[39]!==s||t[40]!==C?(w=(0,o.jsx)(fe,{control:s,name:`vpcId`,render:C}),t[39]=s,t[40]=C,t[41]=w):w=t[41];let T;t[42]===d.vpcId?T=t[43]:(T=(0,o.jsx)(i,{errors:[d.vpcId]}),t[42]=d.vpcId,t[43]=T);let E;t[44]!==w||t[45]!==T?(E=(0,o.jsxs)(r,{children:[Me,w,T]}),t[44]=w,t[45]=T,t[46]=E):E=t[46];let Ne;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=(0,o.jsx)(ue,{className:`text-left text-sm font-medium text-muted-foreground hover:text-foreground`,render:(0,o.jsx)(`button`,{"aria-label":`Health check settings`,type:`button`}),children:`Health check settings`}),t[47]=Ne):Ne=t[47];let D;t[48]!==d.healthCheck?.path||t[49]!==f||t[50]!==c?(D=f&&(0,o.jsxs)(r,{children:[(0,o.jsx)(a,{children:(0,o.jsx)(`label`,{htmlFor:`hc-path`,children:`Path`})}),(0,o.jsx)(n,{"aria-invalid":!!d.healthCheck?.path,id:`hc-path`,placeholder:`/`,...c(`healthCheck.path`)}),(0,o.jsx)(i,{errors:[d.healthCheck?.path]})]}),t[48]=d.healthCheck?.path,t[49]=f,t[50]=c,t[51]=D):D=t[51];let Pe;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=(0,o.jsx)(a,{children:(0,o.jsx)(`label`,{htmlFor:`hc-port`,children:`Port`})}),t[52]=Pe):Pe=t[52];let Fe=!!d.healthCheck?.port,O;t[53]===c?O=t[54]:(O=c(`healthCheck.port`),t[53]=c,t[54]=O);let k;t[55]!==Fe||t[56]!==O?(k=(0,o.jsx)(n,{"aria-invalid":Fe,id:`hc-port`,placeholder:`traffic-port or numeric`,...O}),t[55]=Fe,t[56]=O,t[57]=k):k=t[57];let Ie=d.healthCheck?.port,A;t[58]===Ie?A=t[59]:(A=(0,o.jsx)(i,{errors:[Ie]}),t[58]=Ie,t[59]=A);let j;t[60]!==k||t[61]!==A?(j=(0,o.jsxs)(r,{children:[Pe,k,A]}),t[60]=k,t[61]=A,t[62]=j):j=t[62];let Le;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(Le=(0,o.jsx)(a,{children:(0,o.jsx)(`label`,{htmlFor:`hc-interval`,children:`Interval (seconds)`})}),t[63]=Le):Le=t[63];let Re=!!d.healthCheck?.intervalSeconds,M;t[64]===c?M=t[65]:(M=c(`healthCheck.intervalSeconds`,{valueAsNumber:!0}),t[64]=c,t[65]=M);let N;t[66]!==Re||t[67]!==M?(N=(0,o.jsx)(n,{"aria-invalid":Re,id:`hc-interval`,inputMode:`numeric`,type:`number`,...M}),t[66]=Re,t[67]=M,t[68]=N):N=t[68];let ze=d.healthCheck?.intervalSeconds,P;t[69]===ze?P=t[70]:(P=(0,o.jsx)(i,{errors:[ze]}),t[69]=ze,t[70]=P);let F;t[71]!==N||t[72]!==P?(F=(0,o.jsxs)(r,{children:[Le,N,P]}),t[71]=N,t[72]=P,t[73]=F):F=t[73];let Be;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(Be=(0,o.jsx)(a,{children:(0,o.jsx)(`label`,{htmlFor:`hc-timeout`,children:`Timeout (seconds)`})}),t[74]=Be):Be=t[74];let Ve=!!d.healthCheck?.timeoutSeconds,I;t[75]===c?I=t[76]:(I=c(`healthCheck.timeoutSeconds`,{valueAsNumber:!0}),t[75]=c,t[76]=I);let L;t[77]!==Ve||t[78]!==I?(L=(0,o.jsx)(n,{"aria-invalid":Ve,id:`hc-timeout`,inputMode:`numeric`,type:`number`,...I}),t[77]=Ve,t[78]=I,t[79]=L):L=t[79];let He=d.healthCheck?.timeoutSeconds,R;t[80]===He?R=t[81]:(R=(0,o.jsx)(i,{errors:[He]}),t[80]=He,t[81]=R);let z;t[82]!==L||t[83]!==R?(z=(0,o.jsxs)(r,{children:[Be,L,R]}),t[82]=L,t[83]=R,t[84]=z):z=t[84];let Ue;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(0,o.jsx)(a,{children:(0,o.jsx)(`label`,{htmlFor:`hc-healthy`,children:`Healthy threshold`})}),t[85]=Ue):Ue=t[85];let We=!!d.healthCheck?.healthyThresholdCount,B;t[86]===c?B=t[87]:(B=c(`healthCheck.healthyThresholdCount`,{valueAsNumber:!0}),t[86]=c,t[87]=B);let V;t[88]!==We||t[89]!==B?(V=(0,o.jsx)(n,{"aria-invalid":We,id:`hc-healthy`,inputMode:`numeric`,type:`number`,...B}),t[88]=We,t[89]=B,t[90]=V):V=t[90];let Ge=d.healthCheck?.healthyThresholdCount,H;t[91]===Ge?H=t[92]:(H=(0,o.jsx)(i,{errors:[Ge]}),t[91]=Ge,t[92]=H);let U;t[93]!==V||t[94]!==H?(U=(0,o.jsxs)(r,{children:[Ue,V,H]}),t[93]=V,t[94]=H,t[95]=U):U=t[95];let Ke;t[96]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=(0,o.jsx)(a,{children:(0,o.jsx)(`label`,{htmlFor:`hc-unhealthy`,children:`Unhealthy threshold`})}),t[96]=Ke):Ke=t[96];let qe=!!d.healthCheck?.unhealthyThresholdCount,W;t[97]===c?W=t[98]:(W=c(`healthCheck.unhealthyThresholdCount`,{valueAsNumber:!0}),t[97]=c,t[98]=W);let G;t[99]!==qe||t[100]!==W?(G=(0,o.jsx)(n,{"aria-invalid":qe,id:`hc-unhealthy`,inputMode:`numeric`,type:`number`,...W}),t[99]=qe,t[100]=W,t[101]=G):G=t[101];let Je=d.healthCheck?.unhealthyThresholdCount,K;t[102]===Je?K=t[103]:(K=(0,o.jsx)(i,{errors:[Je]}),t[102]=Je,t[103]=K);let q;t[104]!==G||t[105]!==K?(q=(0,o.jsxs)(r,{children:[Ke,G,K]}),t[104]=G,t[105]=K,t[106]=q):q=t[106];let J;t[107]!==d.healthCheck?.matcher||t[108]!==f||t[109]!==c?(J=f&&(0,o.jsxs)(r,{children:[(0,o.jsx)(a,{children:(0,o.jsx)(`label`,{htmlFor:`hc-matcher`,children:`Matcher (HTTP codes)`})}),(0,o.jsx)(n,{"aria-invalid":!!d.healthCheck?.matcher,id:`hc-matcher`,placeholder:`200 or 200-299 or 200,201`,...c(`healthCheck.matcher`)}),(0,o.jsx)(i,{errors:[d.healthCheck?.matcher]})]}),t[107]=d.healthCheck?.matcher,t[108]=f,t[109]=c,t[110]=J):J=t[110];let Y;t[111]!==D||t[112]!==j||t[113]!==F||t[114]!==z||t[115]!==U||t[116]!==q||t[117]!==J?(Y=(0,o.jsxs)(pe,{children:[Ne,(0,o.jsxs)(de,{className:`mt-3 space-y-4 border-l-2 border-muted pl-4`,children:[D,j,F,z,U,q,J]})]}),t[111]=D,t[112]=j,t[113]=F,t[114]=z,t[115]=U,t[116]=q,t[117]=J,t[118]=Y):Y=t[118];let Ye;t[119]===Symbol.for(`react.memo_cache_sentinel`)?(Ye=(0,o.jsx)(a,{children:`Tags`}),t[119]=Ye):Ye=t[119];let X;if(t[120]!==u||t[121]!==c||t[122]!==l||t[123]!==Se){let e;t[125]!==u||t[126]!==c||t[127]!==l?(e=(e,t)=>(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(n,{placeholder:`Key`,...c(`tags.${t}.key`)}),(0,o.jsx)(n,{placeholder:`Value`,...c(`tags.${t}.value`)}),(0,o.jsx)(ce,{onClick:()=>l(`tags`,u(`tags`).filter((e,ee)=>ee!==t)),size:`icon`,type:`button`,variant:`ghost`,children:(0,o.jsx)(se,{className:`size-3.5`})})]},t),t[125]=u,t[126]=c,t[127]=l,t[128]=e):e=t[128],X=Se.map(e),t[120]=u,t[121]=c,t[122]=l,t[123]=Se,t[124]=X}else X=t[124];let Z;t[129]!==u||t[130]!==l?(Z=()=>l(`tags`,[...u(`tags`),{key:``,value:``}]),t[129]=u,t[130]=l,t[131]=Z):Z=t[131];let Xe;t[132]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=(0,o.jsx)(oe,{className:`size-3.5`}),t[132]=Xe):Xe=t[132];let Q;t[133]===Z?Q=t[134]:(Q=(0,o.jsxs)(ce,{onClick:Z,size:`sm`,type:`button`,variant:`outline`,children:[Xe,`Add tag`]}),t[133]=Z,t[134]=Q);let $;t[135]!==X||t[136]!==Q?($=(0,o.jsxs)(r,{children:[Ye,(0,o.jsxs)(`div`,{className:`space-y-2`,children:[X,Q]})]}),t[135]=X,t[136]=Q,t[137]=$):$=t[137];let Ze;return t[138]!==g||t[139]!==v||t[140]!==S||t[141]!==E||t[142]!==Y||t[143]!==$?(Ze=(0,o.jsxs)(o.Fragment,{children:[g,v,S,E,Y,$]}),t[138]=g,t[139]=v,t[140]=S,t[141]=E,t[142]=Y,t[143]=$,t[144]=Ze):Ze=t[144],Ze}function _e(e){let t=ee(e.Tags);return(0,o.jsx)(ne,{value:e.VpcId??``,children:t?`${e.VpcId} (${t})`:`${e.VpcId} (${e.CidrBlock})`},e.VpcId)}function ve(e){return(0,o.jsx)(ne,{value:e,children:e},e)}export{ge as t}; \ No newline at end of file diff --git a/spinifex/services/spinifexui/frontend/oxlint.config.ts b/spinifex/services/spinifexui/frontend/oxlint.config.ts index 9ec244d2a..507bf2ef3 100644 --- a/spinifex/services/spinifexui/frontend/oxlint.config.ts +++ b/spinifex/services/spinifexui/frontend/oxlint.config.ts @@ -25,7 +25,6 @@ export default defineConfig({ "@tanstack/router/create-route-property-order": "error", "@tanstack/router/route-param-names": "error", "react/jsx-handler-names": "off", - "react/no-object-type-as-default-prop": "off", "eslint/complexity": "off", "eslint/func-style": [ "error", diff --git a/spinifex/services/spinifexui/frontend/src/components/elbv2/listener-form.tsx b/spinifex/services/spinifexui/frontend/src/components/elbv2/listener-form.tsx index 4f61b1afe..adc451686 100644 --- a/spinifex/services/spinifexui/frontend/src/components/elbv2/listener-form.tsx +++ b/spinifex/services/spinifexui/frontend/src/components/elbv2/listener-form.tsx @@ -35,6 +35,8 @@ interface ListenerFormProps { const HTTP_PORT = 80 const HTTPS_PORT = 443 +const EMPTY_CERTIFICATES: CertificateSummary[] = [] +const EMPTY_SSL_POLICIES: SslPolicy[] = [] function certLabel(cert: CertificateSummary): string { const id = cert.CertificateArn?.split("/").pop() ?? cert.CertificateArn ?? "" @@ -45,8 +47,8 @@ export function ListenerForm({ form, protocols, targetGroups, - certificates = [], - sslPolicies = [], + certificates = EMPTY_CERTIFICATES, + sslPolicies = EMPTY_SSL_POLICIES, }: ListenerFormProps) { const { control, diff --git a/spinifex/services/spinifexui/frontend/src/components/elbv2/target-group-form.tsx b/spinifex/services/spinifexui/frontend/src/components/elbv2/target-group-form.tsx index 01fa855e5..c9314b1ee 100644 --- a/spinifex/services/spinifexui/frontend/src/components/elbv2/target-group-form.tsx +++ b/spinifex/services/spinifexui/frontend/src/components/elbv2/target-group-form.tsx @@ -27,10 +27,19 @@ interface TargetGroupFormProps { allowedProtocols?: readonly string[] } +const DEFAULT_ALLOWED_PROTOCOLS = [ + "HTTP", + "HTTPS", + "TCP", + "UDP", + "TLS", + "TCP_UDP", +] as const + export function TargetGroupForm({ form, vpcs, - allowedProtocols = ["HTTP", "HTTPS", "TCP", "UDP", "TLS", "TCP_UDP"], + allowedProtocols = DEFAULT_ALLOWED_PROTOCOLS, }: TargetGroupFormProps) { const { control,