@odigos/ui-kit 0.0.282 → 0.0.283

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.283](https://github.com/odigos-io/ui-kit/compare/ui-kit-v0.0.282...ui-kit-v0.0.283) (2026-08-04)
4
+
5
+
6
+ ### Features
7
+
8
+ * add concurrent agent actions to source drawer ([#1159](https://github.com/odigos-io/ui-kit/issues/1159)) ([8a9c2db](https://github.com/odigos-io/ui-kit/commit/8a9c2dbb322ad2e32dc0f32e095cf8c0168faf19))
9
+ * enable VM source Profiling tab with flame-graph API parity ([#1117](https://github.com/odigos-io/ui-kit/issues/1117)) ([715ae9e](https://github.com/odigos-io/ui-kit/commit/715ae9edf72032bb0065c489a6d9f1fd32e47962))
10
+
3
11
  ## [0.0.282](https://github.com/odigos-io/ui-kit/compare/ui-kit-v0.0.281...ui-kit-v0.0.282) (2026-08-04)
4
12
 
5
13
 
@@ -1,4 +1,4 @@
1
- import{jsx as e,Fragment as t,jsxs as r}from"react/jsx-runtime";import{Fragment as n,useMemo as o,useContext as a,createContext as s}from"react";import{T as i,t as u,b as l,P as c}from"./ui-components-Dcg3x769.js";import p from"styled-components";var d;(e=>{e.Default="default",e.Action="action",e.Endpoint="endpoint",e.Scope="scope",e.Duration="duration"})(d||(d={}));const f=[d.Action,d.Endpoint,d.Scope,d.Duration],h=p.span`
1
+ import{jsx as e,Fragment as t,jsxs as r}from"react/jsx-runtime";import{Fragment as n,useMemo as o,useContext as a,createContext as s}from"react";import{T as i,t as u,b as l,P as c}from"./ui-components-DLU_wMXv.js";import p from"styled-components";var d;(e=>{e.Default="default",e.Action="action",e.Endpoint="endpoint",e.Scope="scope",e.Duration="duration"})(d||(d={}));const f=[d.Action,d.Endpoint,d.Scope,d.Duration],h=p.span`
2
2
  font-family: ${({theme:e,$isMono:t})=>t?e.font_family.secondary:e.font_family.primary};
3
3
  font-size: ${({theme:e})=>e.v2.text.size.xxs}px;
4
4
  line-height: 20px;
@@ -1,4 +1,4 @@
1
- import{jsx as e,jsxs as a,Fragment as t}from"react/jsx-runtime";import{D as l,c as r,F as n,d as i,e as o,f as s,g as c,h as d,B as u,i as p,j as h,k as g,W as m,l as v,m as b,V as f,n as y,o as x,p as C,q as k,r as S,C as T,s as $,u as w,I as M,v as A,w as O,x as L,y as P,z as E,N as I,E as R,S as N,G as V,H as D,U as z,J as X,K as H,L as _,M as B,O as q,Q as j,X as K,Y as U,Z as G,_ as F,$ as W,a0 as J,a1 as Y,a2 as Z,a3 as Q,a4 as ee,T as ae,a5 as te,a6 as le,a7 as re,a8 as ne,a9 as ie,aa as oe,ab as se,ac as ce,ad as de,ae as ue,af as pe,ag as he,ah as ge,b as me,ai as ve,aj as be,ak as fe,al as ye,am as xe,an as Ce,ao as ke,ap as Se,aq as Te,ar as $e,as as we,at as Me,au as Ae,av as Oe,aw as Le,ax as Pe,ay as Ee,az as Ie,aA as Re,aB as Ne,aC as Ve,aD as De,aE as ze,aF as Xe,aG as He,aH as _e,aI as Be,aJ as qe,aK as je,aL as Ke,aM as Ue,aN as Ge,aO as Fe,aP as We,aQ as Je,aR as Ye,aS as Ze,aT as Qe,aU as ea,aV as aa,aW as ta,aX as la,aY as ra,aZ as na,a_ as ia,a$ as oa,b0 as sa,b1 as ca,b2 as da,R as ua,b3 as pa,b4 as ha,A as ga,b5 as ma,b6 as va}from"./ui-components-Dcg3x769.js";import{VIcon as ba,TrashIcon as fa,PlusIcon as ya,VSquareIcon as xa,XSquareIcon as Ca,EditIcon as ka,OdigosLogoTextCentral as Sa,OdigosLogoTextEnterprise as Ta,OdigosLogoTextCommunity as $a,OdigosLogoTextColoredCentral as wa,OdigosLogoTextColoredEnterprise as Ma,OdigosLogoTextColoredCommunity as Aa,ArrowLeftIcon as Oa,ArrowRightIcon as La,CopyIcon as Pa,YamlIcon as Ea}from"../icons.js";import Ia,{useMemo as Ra,useRef as Na,useCallback as Va,useState as Da,useEffect as za,Fragment as Xa,forwardRef as Ha,useImperativeHandle as _a}from"react";import Ba,{css as qa,useTheme as ja}from"styled-components";import{i as Ka,m as Ua,u as Ga,n as Fa,a as Wa,C as Ja,b as Ya,d as Za,e as Qa,f as et,g as at,h as tt,j as lt,k as rt}from"./helpers-CAVGqyMb.js";const nt=/^[a-zA-Z]$/,it=new Set(["*","+","?"]),ot=new Set(["^","$"]),st={group:"rgba(102, 242, 102, 0.5)","anchor-quantifier":"rgba(102, 191, 255, 0.5)","class-bracket":"rgba(255, 153, 153, 0.5)","class-content":"rgba(178, 1, 1, 0.5)",alternation:"rgba(255, 153, 153, 0.5)",literal:"transparent"},ct=Ba.div`
1
+ import{jsx as e,jsxs as a,Fragment as t}from"react/jsx-runtime";import{D as l,c as r,F as n,d as i,e as o,f as s,g as c,h as d,B as u,i as p,j as h,k as g,W as m,l as v,m as b,V as f,n as y,o as x,p as C,q as k,r as S,C as T,s as $,u as w,I as M,v as A,w as O,x as L,y as P,z as E,N as I,E as R,S as N,G as V,H as D,U as z,J as X,K as H,L as _,M as B,O as q,Q as j,X as K,Y as U,Z as G,_ as F,$ as W,a0 as J,a1 as Y,a2 as Z,a3 as Q,a4 as ee,T as ae,a5 as te,a6 as le,a7 as re,a8 as ne,a9 as ie,aa as oe,ab as se,ac as ce,ad as de,ae as ue,af as pe,ag as he,ah as ge,b as me,ai as ve,aj as be,ak as fe,al as ye,am as xe,an as Ce,ao as ke,ap as Se,aq as Te,ar as $e,as as we,at as Me,au as Ae,av as Oe,aw as Le,ax as Pe,ay as Ee,az as Ie,aA as Re,aB as Ne,aC as Ve,aD as De,aE as ze,aF as Xe,aG as He,aH as _e,aI as Be,aJ as qe,aK as je,aL as Ke,aM as Ue,aN as Ge,aO as Fe,aP as We,aQ as Je,aR as Ye,aS as Ze,aT as Qe,aU as ea,aV as aa,aW as ta,aX as la,aY as ra,aZ as na,a_ as ia,a$ as oa,b0 as sa,b1 as ca,b2 as da,R as ua,b3 as pa,b4 as ha,A as ga,b5 as ma,b6 as va}from"./ui-components-DLU_wMXv.js";import{VIcon as ba,TrashIcon as fa,PlusIcon as ya,VSquareIcon as xa,XSquareIcon as Ca,EditIcon as ka,OdigosLogoTextCentral as Sa,OdigosLogoTextEnterprise as Ta,OdigosLogoTextCommunity as $a,OdigosLogoTextColoredCentral as wa,OdigosLogoTextColoredEnterprise as Ma,OdigosLogoTextColoredCommunity as Aa,ArrowLeftIcon as Oa,ArrowRightIcon as La,CopyIcon as Pa,YamlIcon as Ea}from"../icons.js";import Ia,{useMemo as Ra,useRef as Na,useCallback as Va,useState as Da,useEffect as za,Fragment as Xa,forwardRef as Ha,useImperativeHandle as _a}from"react";import Ba,{css as qa,useTheme as ja}from"styled-components";import{i as Ka,m as Ua,u as Ga,n as Fa,a as Wa,C as Ja,b as Ya,d as Za,e as Qa,f as et,g as at,h as tt,j as lt,k as rt}from"./helpers-BfXS2wve.js";const nt=/^[a-zA-Z]$/,it=new Set(["*","+","?"]),ot=new Set(["^","$"]),st={group:"rgba(102, 242, 102, 0.5)","anchor-quantifier":"rgba(102, 191, 255, 0.5)","class-bracket":"rgba(255, 153, 153, 0.5)","class-content":"rgba(178, 1, 1, 0.5)",alternation:"rgba(255, 153, 153, 0.5)",literal:"transparent"},ct=Ba.div`
2
2
  padding: 8px 16px;
3
3
  border-radius: 6px;
4
4
  border: 1px solid ${({theme:e})=>e.v2.colors.silver[500]};
@@ -0,0 +1,5 @@
1
+ import{jsx as e}from"react/jsx-runtime";import{useMemo as t,useContext as r,createContext as a,useCallback as n,useState as o,useEffect as s,useRef as i}from"react";import{t as c,b7 as l,b8 as d,m as u,S as m,b9 as p,ba as f,bb as E,P as y,bc as h,bd as S,be as T,bf as g,bg as _,bh as I,bi as A,bj as R,bk as v,bl as C,bm as N,aZ as O,bn as D,bo as b,n as w,bp as P,bq as L,br as k,bs as F,bt as G,bu as U,v as M,bv as x,bw as H,ae as K,aa as W,ac as $,ab as V,ad as Y,a9 as j,bx as q,b as B}from"./ui-components-DLU_wMXv.js";import{i as Q,n as z,m as J,l as X,o as Z,p as ee,v as te,q as re,u as ae}from"./helpers-BfXS2wve.js";import{ApolloProvider as ne,useLazyQuery as oe,useApolloClient as se,useQuery as ie}from"@apollo/client/react";import{ErrorLink as ce}from"@apollo/client/link/error";import{SetContextLink as le}from"@apollo/client/link/context";import{getMainDefinition as de}from"@apollo/client/utilities";import{CombinedGraphQLErrors as ue,ServerError as me}from"@apollo/client/errors";import{HttpLink as pe,ApolloLink as fe,ApolloClient as Ee,InMemoryCache as ye,gql as he}from"@apollo/client";const Se=e=>{if(!e)return!1;const t=e.toLowerCase();return t.includes("authentication required")||t.includes("authentication expired")||t.includes("http 401")},Te=a(null),ge=()=>{const e=r(Te);if(!e)throw new Error("[ui-kit] useOdigosApi() / useXxxApi() called outside of <OdigosApiProvider>. Make sure the host app mounts the provider at its layout level.");return e},_e=({apolloConfig:r,operations:a,context:n,children:o})=>{const s=t(()=>(e=>{const t=new pe({uri:e.httpUrl,credentials:e.credentials??"same-origin"}),r=new ce(({error:t})=>{ue.is(t)?t.errors.some(e=>Se(e.message))&&e.onAuthError?.():(me.is(t)&&401===t.statusCode||Se(t.message))&&e.onAuthError?.()}),a=new le(async t=>{const r={...t.headers};if(e.authHeader){const t=await e.authHeader();Object.assign(r,t)}return e.csrfHeader&&Object.assign(r,e.csrfHeader()),{headers:r}}),n=[];e.additionalLinks?.length&&n.push(...e.additionalLinks),n.push(a,r,t);let o=fe.from(n);e.wsLink&&(o=fe.split(({query:e})=>{const t=de(e);return"OperationDefinition"===t.kind&&"subscription"===t.operation},e.wsLink,o));const s=e.defaultFetchPolicies;return new Ee({link:o,cache:new ye({typePolicies:e.cacheTypePolicies}),defaultOptions:{watchQuery:{fetchPolicy:s?.watchQuery??"cache-and-network"},query:{fetchPolicy:s?.query??"cache-first"},mutate:{fetchPolicy:s?.mutate??"network-only"}}})})(r),[r.httpUrl,r.wsLink,r.credentials,r.clientKey]),i=t(()=>({operations:a,context:n,apolloConfig:r}),[a,n,r]);return e(ne,{client:s,children:e(Te.Provider,{value:i,children:o})})},Ie=Te,Ae=e=>e.map(e=>`${e.id}:${e.odigosVersion}:${e.type}`).join(","),Re=(e,t,r)=>{const a=t.length?t.map(e=>e.id):r??[],n={...e,connectionIds:a};if(!t.length||c(e.version)>0)return n;const o=t[0];return{...n,version:o.odigosVersion||e.version,platformType:o.type??e.platformType}},ve=({connections:r,connectionIds:a,children:n})=>{const o=ge(),s=t(()=>({operations:o.operations,context:Re(o.context,r,a),apolloConfig:o.apolloConfig}),[o.operations,o.context,o.apolloConfig,Ae(r),a?.join(",")]);return e(Ie.Provider,{value:s,children:n})},Ce=(e,t)=>{if(e)return"string"==typeof e?e:p(e,t)},Ne=e=>{const{addNotification:t}=l(),r=(r,a,n,o,s)=>t({type:r,title:a,message:n,crdType:e,target:Ce(o,e),hideFromHistory:s});return{notify:r,notifyError:(e,t,a)=>r(m.Error,e,t,a),notifySuccess:(e,t,a)=>r(m.Success,e,t,a),notifyPending:(e,t)=>r(m.Default,"Pending",e,t,!0),notifyReadonly:()=>{t({type:m.Warning,title:u.READONLY,message:d.READONLY_WARNING,hideFromHistory:!0})}}},Oe=e=>{e({type:m.Warning,title:u.READONLY,message:d.READONLY_WARNING,hideFromHistory:!0})},De=e=>({error:e,results:[],allSucceeded:!1,anySucceeded:!1,successCount:0,failureCount:0}),be=(e,t)=>{if(e)return"function"==typeof e?e(t):e},we=e=>{if(!e)return"Unknown error";if(e instanceof Error)return e.cause instanceof Error?e.cause.message:e.message;if("object"==typeof e){const t=e;return t.cause?.message||t.message||String(e)}return String(e)},Pe=(e,t)=>e.client??t,Le=async(e,t,r,a,n)=>{if(!t)return{error:"Query operation not configured"};if(t.canRun&&!t.canRun(a))return{data:void 0};if(t.run)try{return await t.run(Pe(t,e),r,a)}catch(e){return{error:we(e)}}const o=be(t.document,a);if(!o)return{error:"Query operation not supported in this context"};const s=t.transformVariables?t.transformVariables(r,a):r,i=Pe(t,e);try{const e=await i.query({query:o,variables:s,fetchPolicy:n??"network-only"});return{data:t.transformResult?t.transformResult(e.data,a):e.data,error:e.error?we(e.error):void 0}}catch(e){return{error:we(e)}}},ke=async(e,t,r,a)=>{if(!t)return{error:"Mutation operation not configured"};if(t.canRun&&!t.canRun(a))return{error:"Mutation operation not supported in this context"};if(t.run)try{return await t.run(Pe(t,e),r,a)}catch(e){return{error:we(e)}}const n=be(t.document,a);if(!n)return{error:"Mutation operation not supported in this context"};const o=t.transformVariables?t.transformVariables(r,a):r,s=Pe(t,e);try{const e=await s.mutate({mutation:n,variables:o});return{data:t.transformResult?t.transformResult(e.data,a):e.data,error:void 0}}catch(e){return{error:we(e)}}},Fe=async(e,t,r,a,n)=>{if(!t)return De("Multi fetch operation not configured");if(!r.length)return De("No proxy ids supplied for multi fetch");const o=Pe(t,e);if(t.transformVariablesMulti&&(t.documentMulti||t.document)){const e=t.transformVariablesMulti(r,a,n),s=[];for(const r of e)try{const e=await o.query({query:r.document,variables:r.variables,fetchPolicy:"network-only"});t.transformMultiResult?t.transformMultiResult(e.data,n).forEach(e=>s.push(e)):r.proxyIDs.forEach(t=>{s.push({proxyID:t,success:!e.error,data:e.data,error:e.error?.message})})}catch(e){const t=we(e);r.proxyIDs.forEach(e=>s.push({proxyID:e,success:!1,error:t}))}const i=s.filter(e=>e.success).length,c=s.length-i,l=Array.from(new Set(s.filter(e=>!!e.error).map(e=>e.error)));return{results:s,allSucceeded:0===c,anySucceeded:i>0,successCount:i,failureCount:c,error:l.length?l.join(", "):void 0}}const s=await Promise.all(r.map(async r=>{const o={...n,proxyID:r},s=await Le(e,t,a,o);return{proxyID:r,success:!s.error,data:s.data,error:s.error}})),i=s.filter(e=>e.success).length,c=s.length-i,l=Array.from(new Set(s.filter(e=>!!e.error).map(e=>e.error)));return{results:s,allSucceeded:0===c,anySucceeded:i>0,successCount:i,failureCount:c,error:l.length?l.join(", "):void 0}},Ge=he`
2
+ query OdigosApiNoop {
3
+ __typename
4
+ }
5
+ `,Ue=(e,t)=>{if(e)return"function"==typeof e?e(t):e},Me=(e,t)=>e[t],xe=(e,t,r)=>{if(void 0!==t)return e?.transformResult?e.transformResult(t,r):t},He=(e,t,r)=>{if(!e)return;const a=e.transformVariables;return a?a(t,r):t},Ke=(e,r,a)=>{const{operations:o,context:i}=ge(),c=Me(o,e),l=t(()=>Ue(c?.document,i),[c,i]),d=t(()=>He(c,r,i),[c,r,i]),u=!c||!l,m=!!c?.canRun&&!c.canRun(i),p=a?.skip||u||m,f=ie(l??Ge,{variables:d,skip:p,pollInterval:a?.pollInterval,fetchPolicy:a?.fetchPolicy??"cache-and-network",notifyOnNetworkStatusChange:a?.notifyOnNetworkStatusChange,client:c?.client}),E=t(()=>{if(!p)return xe(c,f.data,i)},[c,i,f.data,p]);s(()=>{p||void 0===E||a?.onCompleted?.(E)},[p,E,a?.onCompleted]),s(()=>{f.error&&a?.onError?.(f.error)},[f.error,a?.onError]);const y=n(async()=>{if(p)return{data:void 0};const e=await f.refetch();return{data:xe(c,e.data,i)}},[c,i,f,p]);return{data:E,loading:!p&&f.loading,error:f.error,refetch:y,unsupported:u}},We=(e,r)=>{const{operations:a,context:o}=ge(),s=Me(a,e),i=t(()=>Ue(s?.document,o),[s,o]),c=!s||!i,[l,d]=oe(i??Ge,{fetchPolicy:r?.fetchPolicy??"network-only",notifyOnNetworkStatusChange:r?.notifyOnNetworkStatusChange,client:s?.client});return{execute:n(async e=>{if(c)return{error:void 0};if(s?.canRun&&!s.canRun(o))return{data:void 0};const t=He(s,e,o),r=await l({variables:t});return r.error?{error:r.error}:{data:xe(s,r.data,o)}},[s,o,l,c]),data:t(()=>xe(s,d.data,o),[s,o,d.data]),loading:d.loading,error:d.error,called:d.called,unsupported:c}},$e=(e,r)=>{const{operations:a,context:s}=ge(),i=se(),c=Me(a,e),l=t(()=>Ue(c?.document,s),[c,s]),d=!c||!l,[u,m]=o({loading:!1,called:!1}),p=n(()=>m({loading:!1,called:!1}),[]);return[n(async e=>{if(d||!l)return{error:void 0};if(c?.canRun&&!c.canRun(s))return{data:void 0};const t=He(c,e,s),a=c?.client??i;m(e=>({...e,loading:!0,called:!0}));try{const e=await a.mutate({mutation:l,variables:t}),n=xe(c,e.data,s);if(m({data:n,loading:!1,error:void 0,called:!0}),r?.refetchQueries){const e=a.refetchQueries({include:r.refetchQueries});r?.awaitRefetchQueries&&await e}return void 0!==n&&r?.onCompleted?.(n),{data:n}}catch(e){const t=e;return m({data:void 0,loading:!1,error:t,called:!0}),r?.onError?.(t),{error:t}}},[c,s,i,l,d,r]),{data:u.data,loading:u.loading,error:u.error,called:u.called,unsupported:d,reset:p}]},Ve=[],Ye=(e,t,r,a)=>{let n=!0;const o={sources:[]};for(const[s,i]of Object.entries(e)){if(!i.length)continue;n=!1;const e=i.map(({id:e,selected:t,currentStreamName:a})=>({namespace:e.namespace,name:e.name,kind:e.kind,selected:void 0!==t&&t,currentStreamName:a||r}));let c=0,l=0;for(const r of e){const e=t.find(e=>e.id.namespace===s&&e.id.name===r.name&&e.id.kind===r.kind),a=e?.dataStreamNames||[];r.selected&&!e?c++:!r.selected&&e&&a.length<=1&&l++}a(c,l),o.sources.push(...e)}return{payload:o,isEmpty:n}},je=(e,t)=>{let r=!0;const a={namespaces:[]};for(const[n,{selected:o,currentStreamName:s}]of Object.entries(e))"boolean"==typeof o&&(r=!1,a.namespaces.push({namespace:n,selected:o,currentStreamName:s||t}));return{payload:a,isEmpty:r}},qe={filter:{markedForInstrumentation:!0}},Be=[],Qe=e=>{const t=e.markedForInstrumentation?.markedForInstrumentation;return"boolean"==typeof t?e:{...e,markedForInstrumentation:{...e.markedForInstrumentation??{markedForInstrumentation:!0},markedForInstrumentation:!0}}},ze=e=>{let t=!1;const r=e.map(e=>{const r=Qe(e);return r!==e&&(t=!0),r});return t?r:e},Je=[],Xe=[],Ze=[],et=[],tt=e=>{if(e)return{clusters:[e],totalNamespaces:e.namespaces?.length??0,totalWorkloads:(e.namespaces??[]).reduce((e,t)=>e+(t.workloads?.length??0),0),lastUpdated:e.timestamp}},rt=[],at=[],nt=(e,t)=>({...e,fields:e.fields.filter(({value:e})=>void 0!==e),currentStreamName:t}),ot=[],st=()=>{const{operations:e,context:r}=ge(),a=se(),o=((e,r)=>{const a=se(),{notifyError:o,notifySuccess:s,notifyPending:i,notifyReadonly:c}=Ne(E.Source),{selectedStreamName:l}=h(),{setProgress:d,resetProgress:u}=S(),{setConfiguredSources:m,setConfiguredFutureApps:p}=T(),y=(e,t)=>{const{progress:r}=S.getState();e>0&&d(g.Instrumenting,{total:(r[g.Instrumenting]?.total||0)+e,current:r[g.Instrumenting]?.current||0}),t>0&&d(g.Uninstrumenting,{total:(r[g.Uninstrumenting]?.total||0)+t,current:r[g.Uninstrumenting]?.current||0})},I=n(async()=>{const{error:t}=await Le(a,e.GET_WORKLOADS,qe,r);t&&o(f.Read,t)},[a,e.GET_WORKLOADS,r,o]);return{useSources:()=>{const e=Ke("GET_WORKLOADS",qe,{fetchPolicy:"cache-first"}),r=e.data?.workloads;return{items:t(()=>r?ze(r):Be,[r]),loading:e.loading,refetch:I}},fetchAll:I,fetchByTargets:async(t,n)=>{const s=!!n?.slim,i=t.map(e=>_(e,E.Source)).filter(e=>e.namespace&&e.name&&e.kind);if(0===i.length)return;if(i.length>50)return void await I();const c=s&&e.GET_WORKLOADS_BY_IDS_SLIM?e.GET_WORKLOADS_BY_IDS_SLIM:e.GET_WORKLOADS_BY_IDS,{error:l}=await Le(a,c,{ids:i.map(({namespace:e,kind:t,name:r,region:a})=>({namespace:e,kind:t,name:r,region:a||void 0}))},r);l?o(f.Read,l):await I()},fetchById:async t=>{const{data:n,error:s}=await Le(a,e.GET_WORKLOADS_BY_IDS,{ids:[{namespace:t.namespace,kind:t.kind,name:t.name,...t.region?{region:t.region}:{}}]},r);if(s)return void o(f.Read,s);const i=n?.workloadsByIds?.find(e=>e.id.namespace===t.namespace&&e.id.kind===t.kind&&e.id.name===t.name&&(e.id.region??"")===(t.region??""));return i?Qe(i):void 0},fetchLibraries:async t=>Le(a,e.GET_SOURCE_LIBRARIES,t,r),fetchPeerSources:async t=>Le(a,e.GET_PEER_SOURCES,{serviceName:t},r),usePeerSources:(e,t)=>Ke("GET_PEER_SOURCES",e,t),persist:async(t,n)=>{if(r.isReadonly)return c();const{data:s}=await Le(a,e.GET_WORKLOADS,qe,r,"cache-first"),d=ze(s?.workloads??Be),{payload:E,isEmpty:h}=Ye(t,d,l,y),{payload:S,isEmpty:T}=je(n,l);let _=!1;h||(_=!0,i("Persisting sources...")),T||_||i("Persisting namespaces...");const{error:I}=await ke(a,e.PERSIST_SOURCES,E,r);if(I&&(u(g.Instrumenting),u(g.Uninstrumenting),o(f.Update,I)),e.PERSIST_NAMESPACES){const{error:t}=await ke(a,e.PERSIST_NAMESPACES,S,r);t&&o(f.Update,t)}m({}),p({})},persistV2:async t=>{if(r.isReadonly)return c(),{error:"readonly"};const n=[];for(const[,o]of Object.entries(t)){const t={sources:[]},s={namespaces:[]};for(const e of o)e.name&&e.kind?t.sources.push(e):s.namespaces.push(e);if(s.namespaces.length>0&&e.PERSIST_NAMESPACES){const{error:t}=await ke(a,e.PERSIST_NAMESPACES,s,r);t&&n.push(t)}if(t.sources.length>0){const{error:o}=await ke(a,e.PERSIST_SOURCES,t,r);o&&n.push(o)}}return n.length?{error:n.join(", ")}:void 0},update:async(t,n)=>{if(r.isReadonly)return c();i("Updating source...");const d={sourceId:t,patchSourceRequest:{...n,currentStreamName:l}},{data:u,error:m}=await ke(a,e.UPDATE_SOURCE,d,r);m?o(f.Update,m,t):u?.updateK8sActualSource&&s(f.Update,`Successfully updated "${t.name}" source`,t)},restartWorkloads:async t=>{if(r.isReadonly)return c();i("Restarting sources...");const{data:n,error:l}=await ke(a,e.RESTART_WORKLOADS,{sourceIds:t},r);l?o(f.Update,l):n?.restartWorkloads&&s(f.Update,`Successfully restarted ${t.length} sources`)},restartPod:async(t,n)=>{if(r.isReadonly)return c();i("Restarting pod...");const{data:l,error:d}=await ke(a,e.RESTART_POD,{namespace:t,name:n},r);d?o(f.Update,d):l?.restartPod&&s(f.Update,`Successfully restarted pod ${t}/${n}`)},recoverFromRollback:async t=>{if(r.isReadonly)return c();i("Recovering from rollback...");const{data:n,error:l}=await ke(a,e.RECOVER_FROM_ROLLBACK,{sourceId:t},r);l?o(f.Update,l,t):n?.recoverFromRollbackForWorkload&&s(f.Update,"Successfully triggered recovery from rollback")}}})(e,r),i=((e,t)=>{const r=se(),{notifyError:a,notifySuccess:n,notifyReadonly:o}=Ne(E.Destination),{selectedStreamName:s}=h(),i=async()=>{const{error:n}=await Le(r,e.GET_DESTINATIONS,void 0,t);n&&a(f.Read,n)};return{useDestinations:()=>{const e=Ke("GET_DESTINATIONS",void 0,{fetchPolicy:"cache-first"});return{items:e.data?.computePlatform?.destinations??e.data?.destinations??at,loading:e.loading,refetch:i}},useDestinationCategories:()=>{const e=Ke("GET_DESTINATION_CATEGORIES",void 0);return{data:e.data,loading:e.loading}},usePotentialDestinations:()=>{const e=Ke("GET_POTENTIAL_DESTINATIONS",void 0);return{data:e.data,loading:e.loading}},fetchAll:i,testConnection:async a=>{const{data:n}=await ke(r,e.TEST_DESTINATION_CONNECTION,{destination:nt(a,s)},t);return n},create:async c=>{if(t.isReadonly)return o();const{error:l}=await ke(r,e.CREATE_DESTINATION,{destination:nt(c,s)},t);l?a(f.Create,l):(n(f.Create,`Successfully created "${c.type}" destination`),await i())},update:async(c,l)=>{if(t.isReadonly)return o();const{data:d,error:u}=await ke(r,e.UPDATE_DESTINATION,{id:c,destination:nt(l,s)},t);u?a(f.Update,u,c):d?.updateDestination&&(n(f.Update,`Successfully updated "${l.type}" destination`,c),await i())},remove:async c=>{if(t.isReadonly)return o();const{data:l}=await Le(r,e.GET_DESTINATIONS,void 0,t,"cache-first"),d=l?.computePlatform?.destinations??l?.destinations??at,u=d.find(e=>A(e)===c)?.destinationType?.type,{error:m}=await ke(r,e.DELETE_DESTINATION,{id:c,currentStreamName:s},t);m?a(f.Delete,m,c):(n(f.Delete,`Successfully deleted "${u??c}" destination`,c),await i())}}})(e,r),c=((e,r)=>{const a=se(),{notifyError:n,notifySuccess:o,notifyReadonly:s}=Ne(E.Action),i=async()=>{const{error:t}=await Le(a,e.GET_ACTIONS,void 0,r);t&&n(f.Read,t)};return{useActions:()=>{const e=Ke("GET_ACTIONS",void 0,{fetchPolicy:"cache-first"});return{items:e.data?.computePlatform?.actions??e.data?.actions??Je,loading:e.loading,refetch:i}},useActionTypes:()=>{const e=Ke("GET_ACTION_TYPES",void 0,{fetchPolicy:"cache-first"});return{options:t(()=>I(e.data)||Xe,[e.data]),loading:e.loading}},fetchAll:i,create:async t=>{if(r.isReadonly)return s();if(!e.CREATE_ACTION)return;const{error:c}=await ke(a,e.CREATE_ACTION,{action:t},r);c?n(f.Create,c):(o(f.Create,`Successfully created "${t.type}" action`),await i())},update:async(t,c)=>{if(r.isReadonly)return s();if(!e.UPDATE_ACTION)return;const{error:l}=await ke(a,e.UPDATE_ACTION,{id:t,action:c},r);l?n(f.Update,l,t):(o(f.Update,`Successfully updated "${c.type}" action`,t),await i())},remove:async(t,c)=>{if(r.isReadonly)return s();if(!e.DELETE_ACTION)return;const{error:l}=await ke(a,e.DELETE_ACTION,{id:t,actionType:c},r);l?n(f.Delete,l,t):(o(f.Delete,`Successfully deleted "${c}" action`,t),await i())}}})(e,r),d=((e,r)=>{const a=se(),{notifyError:n,notifySuccess:o,notifyReadonly:s}=Ne(E.InstrumentationRule),i=async()=>{const{error:t}=await Le(a,e.GET_INSTRUMENTATION_RULES,void 0,r);t&&n(f.Read,t)};return{useRules:()=>{const e=Ke("GET_INSTRUMENTATION_RULES",void 0,{fetchPolicy:"cache-first"});return{items:t(()=>(e.data?.computePlatform?.instrumentationRules??e.data?.instrumentationRules??[]).map(C),[e.data]),loading:e.loading,refetch:i}},useRuleTypes:()=>{const e=Ke("GET_INSTRUMENTATION_RULE_TYPES",void 0,{fetchPolicy:"cache-first"});return{options:t(()=>v(e.data)||ot,[e.data]),loading:e.loading}},fetchAll:i,create:async(t,c)=>{if(r.isReadonly)return s();if(!e.CREATE_INSTRUMENTATION_RULE)return;const{error:l}=await ke(a,e.CREATE_INSTRUMENTATION_RULE,{instrumentationRule:R(t)},r);l?n(f.Create,l):(o(f.Create,`Successfully created${c?` "${c}"`:""} rule`),await i())},update:async(t,c,l)=>{if(r.isReadonly)return s();if(!e.UPDATE_INSTRUMENTATION_RULE)return;const{error:d}=await ke(a,e.UPDATE_INSTRUMENTATION_RULE,{ruleId:t,instrumentationRule:R(c)},r);d?n(f.Update,d,t):(o(f.Update,`Successfully updated${l?` "${l}"`:""} rule`,t),await i())},remove:async(t,c)=>{if(r.isReadonly)return s();if(!e.DELETE_INSTRUMENTATION_RULE)return;const{error:l}=await ke(a,e.DELETE_INSTRUMENTATION_RULE,{ruleId:t},r);l?n(f.Delete,l,t):(o(f.Delete,`Successfully deleted${c?` "${c}"`:""} rule`,t),await i())}}})(e,r),u=((e,t)=>{const r=se(),{addNotification:a}=l(),{setDataStreams:n}=h(),o=(e,t)=>a({type:m.Error,title:e,message:t}),i=async()=>{const{data:a,error:s}=await Le(r,e.GET_DATA_STREAMS,void 0,t);if(s)o(f.Read,s);else if(a){const e=a.computePlatform?.dataStreams??a.dataStreams??[];n(e)}},c=e.CREATE_DATA_STREAM?async n=>{if(t.isReadonly)return Oe(a);const{error:s}=await ke(r,e.CREATE_DATA_STREAM,{stream:n},t);s?o(f.Create,s):await i()}:void 0;return{useDataStreams:()=>{const e=Ke("GET_DATA_STREAMS",void 0,{fetchPolicy:"cache-first"}),t=e.data?.computePlatform?.dataStreams??e.data?.dataStreams??rt;return s(()=>{n(t)},[JSON.stringify(t.map(e=>e.name))]),{items:t,loading:e.loading,refetch:i}},fetchAll:i,create:c,update:async(n,s)=>{if(t.isReadonly)return Oe(a);const{error:c}=await ke(r,e.UPDATE_DATA_STREAM,{id:n,dataStream:s},t);c?o(f.Update,c):await i()},remove:async n=>{if(t.isReadonly)return Oe(a);const{error:s}=await ke(r,e.DELETE_DATA_STREAM,{id:n},t);s?o(f.Delete,s):await i()}}})(e,r),p=((e,t)=>{const r=se(),{notifyError:a,notifyReadonly:n}=Ne(E.Namespace),o=async()=>{const n=await Le(r,e.GET_NAMESPACES_WITH_WORKLOADS,void 0,t);return n.error&&a(f.Read,n.error),n};return{useNamespaces:e=>{const t=Ke("GET_NAMESPACES_WITH_WORKLOADS",void 0,{fetchPolicy:"cache-and-network",skip:e?.skip});return{items:t.data?.namespaces??et,loading:t.loading,refetch:o}},fetchAll:o,persist:async o=>{if(t.isReadonly)return n();const{error:s}=await ke(r,e.PERSIST_NAMESPACES,o,t);return s&&a(f.Update,s),s?{error:s}:void 0}}})(e,r),N=((e,t)=>{const r=se(),{notifyError:a}=Ne(E.Source);return{fetch:async n=>{const o=await Le(r,e.GET_K8S_MANIFEST,n,t);return o.error&&a(f.Read,o.error),o}}})(e,r),O=((e,t)=>{const r=se(),{notifyError:a,notifySuccess:n,notifyReadonly:o}=Ne(E.Source);return{useEffectiveConfig:(e,t)=>Ke("GET_EFFECTIVE_CONFIG",e,t),useConfigYamls:e=>Ke("GET_CONFIG_YAMLS",void 0,e),getEffectiveConfig:async a=>e.GET_EFFECTIVE_CONFIG?Le(r,e.GET_EFFECTIVE_CONFIG,{id:a},t):{error:"GET_EFFECTIVE_CONFIG not configured"},applyConfigurations:e.UPDATE_REMOTE_CONFIG?async(n,s)=>{if(t.isReadonly)return o();if(!s.length)return{error:"No connections selected"};const i={formData:n,connectionIds:s},c=e.UPDATE_REMOTE_CONFIG;let l;return 1===s.length?({error:l}=await ke(r,c,i,t)):({error:l}=await Fe(r,c,s,i,t)),l&&a(f.Update,l),l?{error:l}:void 0}:void 0,getConfigYamls:e.GET_CONFIG_YAMLS?async()=>Le(r,e.GET_CONFIG_YAMLS,void 0,t):void 0,updateLocalUiConfig:e.UPDATE_LOCAL_UI_CONFIG?async s=>{if(t.isReadonly)return o();const{error:i}=await ke(r,e.UPDATE_LOCAL_UI_CONFIG,{config:s},t);return i?a(f.Update,i):n(f.Update,"Local UI configuration updated successfully"),i?{error:i}:void 0}:void 0,resetLocalUiConfigToDefaults:e.RESET_LOCAL_UI_CONFIG_TO_FACTORY_DEFAULTS?async()=>{if(t.isReadonly)return o();const{error:s}=await ke(r,e.RESET_LOCAL_UI_CONFIG_TO_FACTORY_DEFAULTS,void 0,t);return s?a(f.Update,s):n(f.Update,"Local UI configuration reset to factory defaults"),s?{error:s}:void 0}:void 0}})(e,r),D=((e,t)=>{const r=se(),{apolloConfig:a}=ge();return{fetchDescribeOdigos:e.GET_DESCRIBE_ODIGOS?async()=>Le(r,e.GET_DESCRIBE_ODIGOS,void 0,t):void 0,fetchDescribeSource:e.GET_DESCRIBE_SOURCE?async a=>Le(r,e.GET_DESCRIBE_SOURCE,a,t):void 0,downloadDiagnose:e.GET_DIAGNOSE?async(n,o)=>{const s=await Le(r,e.GET_DIAGNOSE,{input:n,dryRun:o?.dryRun??!1},t),i=s?.data?.stats?.fileCount??0;return!s.error&&i>0&&!o?.dryRun&&await(async e=>{const t=(e=>{try{return new URL("/diagnose/download",e).toString()}catch{return null}})(e.httpUrl);if(t)try{const[r,a]=await Promise.all([Promise.resolve(e.authHeader?.()??{}),Promise.resolve(e.csrfHeader?.()??{})]),n=await fetch(t,{credentials:e.credentials??"same-origin",headers:{...r,...a}});if(!n.ok)throw new Error(`Failed to download diagnose archive: ${n.status} ${n.statusText}`);((e,t)=>{if("undefined"==typeof document)return;const r=URL.createObjectURL(e),a=document.createElement("a");a.href=r,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r)})(await n.blob(),`odigos-diagnose-${Date.now()}.tar.gz`)}catch(e){}})(a),s}:void 0}})(e,r),b=((e,t)=>{const r=se(),{notifyError:a,notifyReadonly:n}=Ne(E.Source),o=async()=>{e.GET_TOKENS&&await Le(r,e.GET_TOKENS,void 0,t)};return{useTokens:()=>{const e=Ke("GET_TOKENS",void 0,{fetchPolicy:"cache-first"});return{items:e.data??Ve,loading:e.loading,refetch:o}},updateToken:e.UPDATE_TOKEN?async o=>{if(t.isReadonly)return n();const{error:s}=await ke(r,e.UPDATE_TOKEN,{token:o},t);return s&&a(f.Update,s),s?{error:s}:void 0}:void 0}})(e,r),w=((e,t)=>{const r=se();return{useMetrics:e=>Ke("GET_METRICS",void 0,e),fetch:async()=>Le(r,e.GET_METRICS,void 0,t)}})(e,r),P=((e,t)=>{const r=se();return{useServiceMap:e=>Ke("GET_SERVICE_MAP",void 0,e),fetch:e.GET_SERVICE_MAP?async()=>Le(r,e.GET_SERVICE_MAP,void 0,t):void 0}})(e,r),L=((e,t)=>{const r=se();return{useSlots:e=>Ke("GET_PROFILING_SLOTS",void 0,e),useSourceProfiling:(e,t)=>Ke("GET_SOURCE_PROFILING",e,t),useHotFunctions:(e,t)=>Ke("GET_PROFILE_HOT_FUNCTIONS",e,t),fetchSlots:e.GET_PROFILING_SLOTS?async()=>Le(r,e.GET_PROFILING_SLOTS,void 0,t):void 0,fetchSourceProfiling:e.GET_SOURCE_PROFILING?async a=>Le(r,e.GET_SOURCE_PROFILING,a,t):void 0,enableProfiling:e.ENABLE_SOURCE_PROFILING?async a=>ke(r,e.ENABLE_SOURCE_PROFILING,a,t):void 0,fetchHotFunctions:e.GET_PROFILE_HOT_FUNCTIONS?async a=>Le(r,e.GET_PROFILE_HOT_FUNCTIONS,a,t):void 0,clearProfileCache:e.CLEAR_PROFILE_CACHE?async()=>ke(r,e.CLEAR_PROFILE_CACHE,void 0,t):void 0}})(e,r),k=((e,t)=>{const r=se();return{useGatewayInfo:e=>Ke("GET_GATEWAY_INFO",void 0,e),useGatewayPods:e=>Ke("GET_GATEWAY_PODS",void 0,e),useNodeCollectorInfo:e=>Ke("GET_NODE_COLLECTOR_INFO",void 0,e),useNodeCollectorPods:e=>Ke("GET_NODE_COLLECTOR_PODS",void 0,e),usePodInfo:(e,t)=>Ke("GET_COLLECTOR_POD_INFO",e,t),getGatewayInfo:e.GET_GATEWAY_INFO?async()=>Le(r,e.GET_GATEWAY_INFO,void 0,t):void 0,getGatewayPods:e.GET_GATEWAY_PODS?async()=>Le(r,e.GET_GATEWAY_PODS,void 0,t):void 0,getNodeCollectorInfo:e.GET_NODE_COLLECTOR_INFO?async()=>Le(r,e.GET_NODE_COLLECTOR_INFO,void 0,t):void 0,getNodeCollectorPods:e.GET_NODE_COLLECTOR_PODS?async()=>Le(r,e.GET_NODE_COLLECTOR_PODS,void 0,t):void 0,getExtendedPodInfo:e.GET_COLLECTOR_POD_INFO?async(a,n)=>Le(r,e.GET_COLLECTOR_POD_INFO,{namespace:a,name:n},t):void 0}})(e,r),F=((e,t)=>{const r=se(),{notifyError:a,notifySuccess:n,notifyReadonly:o}=Ne(E.SamplingRule),s=async()=>{e.GET_SAMPLING_RULES&&await Le(r,e.GET_SAMPLING_RULES,void 0,t)},i=(e,i)=>e?async c=>{if(t.isReadonly)return o();const{error:l}=await ke(r,e,c,t);return l?a(i,l):(n(f.Create,"Successfully created sampling rule"),await s()),l?{error:l}:void 0}:void 0,c=(e,i)=>e?async(c,l)=>{if(t.isReadonly)return o();const{error:d}=await ke(r,e,{samplingId:l.samplingId,ruleId:c,rule:l.rule},t);return d?a(i,d):(n(f.Update,"Successfully updated sampling rule"),await s()),d?{error:d}:void 0}:void 0,l=e=>e?async(i,c)=>{if(t.isReadonly)return o();const{error:l}=await ke(r,e,{samplingId:c,ruleId:i},t);return l?a(f.Delete,l):(n(f.Delete,"Successfully deleted sampling rule"),await s()),l?{error:l}:void 0}:void 0;return{useSamplingRules:()=>{const e=Ke("GET_SAMPLING_RULES",void 0,{fetchPolicy:"cache-first"});return{items:e.data?.computePlatform?.samplingRules??e.data?.samplingRules??Ze,k8sHealthProbesConfig:e.data?.computePlatform?.k8sHealthProbesConfig??e.data?.k8sHealthProbesConfig??null,loading:e.loading,refetch:s}},fetchAll:e.GET_SAMPLING_RULES?async()=>Le(r,e.GET_SAMPLING_RULES,void 0,t):void 0,createNoisy:i(e.CREATE_NOISY_OPERATION_RULE,f.Create),updateNoisy:c(e.UPDATE_NOISY_OPERATION_RULE,f.Update),deleteNoisy:l(e.DELETE_NOISY_OPERATION_RULE),createHighlyRelevant:i(e.CREATE_HIGHLY_RELEVANT_OPERATION_RULE,f.Create),updateHighlyRelevant:c(e.UPDATE_HIGHLY_RELEVANT_OPERATION_RULE,f.Update),deleteHighlyRelevant:l(e.DELETE_HIGHLY_RELEVANT_OPERATION_RULE),createCostReduction:i(e.CREATE_COST_REDUCTION_RULE,f.Create),updateCostReduction:c(e.UPDATE_COST_REDUCTION_RULE,f.Update),deleteCostReduction:l(e.DELETE_COST_REDUCTION_RULE),updateK8sHealthProbesConfig:e.UPDATE_LOCAL_UI_SAMPLING_CONFIG?async n=>{if(t.isReadonly)return o();const{error:i}=await ke(r,e.UPDATE_LOCAL_UI_SAMPLING_CONFIG,{config:{k8sHealthProbesSampling:n}},t);return i?a(f.Update,i):await s(),i?{error:i}:void 0}:void 0}})(e,r),G=((e,r)=>{const a=se();return{useSnapshots:()=>{const e=r.proxyID,a=!!e,o=Ke("GET_ALL_CLUSTER_SNAPSHOTS",void 0,{fetchPolicy:"cache-and-network",skip:a}),s=Ke("GET_CLUSTER_SNAPSHOT",e?{clusterId:e}:void 0,{fetchPolicy:"cache-and-network",skip:!a}),i=t(()=>a?tt(s.data):o.data,[a,s.data,o.data]),c=a?s.loading:o.loading,l=n(async()=>{if(!a)return o.refetch();const{data:e}=await s.refetch();return{data:tt(e)}},[a,o.refetch,s.refetch]);return{data:i,loading:c,pending:c&&!i,unsupported:a?s.unsupported:o.unsupported,refetch:l}},getAllClusterSnapshots:e.GET_ALL_CLUSTER_SNAPSHOTS?async()=>Le(a,e.GET_ALL_CLUSTER_SNAPSHOTS,void 0,r):void 0,getClusterSnapshot:e.GET_CLUSTER_SNAPSHOT?async t=>Le(a,e.GET_CLUSTER_SNAPSHOT,{clusterId:t},r):void 0}})(e,r);return{sourcesApi:o,destinationsApi:i,actionsApi:c,instrumentationRulesApi:d,dataStreamsApi:u,namespacesApi:p,k8sManifestApi:N,configApi:O,describeApi:D,tokensApi:b,metricsApi:w,serviceMapApi:P,profilingApi:L,collectorsApi:k,samplingApi:F,snapshotsApi:G,capabilities:t(()=>((e,t)=>{const r=t.platformType===y.K8s,a=r,n=r,o=t.platformType===y.Vm,s=!o;return{canBulkPersistSources:s&&!!e.PERSIST_SOURCES,canInstrumentNamespaces:n&&!!e.PERSIST_NAMESPACES,canFetchSnapshots:a&&!!e.GET_ALL_CLUSTER_SNAPSHOTS,canRecoverFromRollback:a&&!!e.RECOVER_FROM_ROLLBACK,canRestartWorkloads:a&&!!e.RESTART_WORKLOADS,canFetchPeerSources:!!e.GET_PEER_SOURCES,canFetchSourceLibraries:!!e.GET_SOURCE_LIBRARIES,canFetchK8sManifest:a&&!!e.GET_K8S_MANIFEST,canCreateDestination:!!e.CREATE_DESTINATION,canTestConnection:s&&!!e.TEST_DESTINATION_CONNECTION,canFetchDestinationCategories:!!e.GET_DESTINATION_CATEGORIES,canFetchPotentialDestinations:s&&!!e.GET_POTENTIAL_DESTINATIONS,canCreateAction:!!e.CREATE_ACTION,canFetchActionTypes:!!e.GET_ACTION_TYPES,canCreateInstrumentationRule:!!e.CREATE_INSTRUMENTATION_RULE,canFetchInstrumentationRuleTypes:!!e.GET_INSTRUMENTATION_RULE_TYPES,canApplyEffectiveConfig:s&&!!e.UPDATE_REMOTE_CONFIG,canFetchEffectiveConfig:!!e.GET_EFFECTIVE_CONFIG,canFetchConfigYamls:!!e.GET_CONFIG_YAMLS,canFetchProfiling:a&&!!e.GET_PROFILING_SLOTS||o&&(!!e.GET_SOURCE_PROFILING||!!e.GET_PROFILE_HOT_FUNCTIONS),canFetchCollectorInfo:a&&!!e.GET_GATEWAY_INFO,canManageSamplingRules:!!e.GET_SAMPLING_RULES}})(e,r),[e,r]),resetCache:n(async()=>{await a.cache.reset()},[a])}},it={type:"",disabled:!1,name:"",notes:"",signals:[],fields:{}},ct=a(null),lt=e=>e?.length?e.map(e=>!e.fromSources?.length&&e.from?{...e,fromSources:[e.from]}:e):e,dt=(e,t)=>{const r=O(e??{}),a=r[b.ExtractAttribute];var n;a?.extractions?.length&&(a.extractions=a.extractions.map(e=>{const t=e;return{...t,method:t.method||(t.regex?.trim()?"regex":"preset")}})),r[b.LabelsAttributes]&&(r[b.LabelsAttributes]=lt(r[b.LabelsAttributes])),r[b.AnnotationsAttributes]&&(r[b.AnnotationsAttributes]=lt(r[b.AnnotationsAttributes])),r[b.UrlTemplatizationRulesGroups]&&(r[b.UrlTemplatizationRulesGroups]=(n=r[b.UrlTemplatizationRulesGroups],n?.length?n.map(e=>{const t=e.filterK8sWorkloadKind,r=e.filterK8sWorkloadName;return e.workloadFilters?.length||!t&&!r?e:{...e,workloadFilters:[{kind:t,name:r||void 0}]}}):n));const o=new Set((t?.fields||[]).filter(e=>e.componentType===w.SourceScopes).map(e=>e.name));return void 0!==r[b.Scopes]&&o.add(b.Scopes),o.forEach(e=>{const t=e;r[t]=z(r[t])}),r},ut="All row fields are required",mt="At least one row is required",pt=(e,t)=>!!e&&t.every(t=>{const r=e[t];return Array.isArray(r)?r.length>0:!("string"==typeof(a=r)?!a.trim():L(a));var a}),ft=({children:r,sourceOptions:a=[],namespaceOptions:s=[]})=>{const[i,c]=o(null),l=N(it),u=n(e=>{l.resetFormData(),l.handleErrorChange(void 0,void 0,{}),e?.type&&l.handleFormChange("type",e.type),c(e)},[]),m=n((e,t)=>{const r=t??(a=e.type,D.find(e=>e.type===a)??null);var a;l.resetFormData((({type:e,name:t,notes:r,disabled:a,signals:n,fields:o},s)=>({type:e,name:t||"",notes:r||"",disabled:!!a,signals:n??[],fields:dt(o,s)}))(e,r)),l.handleErrorChange(void 0,void 0,{}),c(r)},[]),p=n(()=>{if(!i)return{errorMessage:"No action type selected",preparedFormData:O(it)};const e=((e,t)=>{const r=O(e),a=r.fields||{},n=a[b.UrlTemplatizationRulesGroups];n?.length&&(a[b.UrlTemplatizationRulesGroups]=n.map(e=>({...e,templatizationRules:(e.templatizationRules||[]).filter(e=>!!e.template?.trim())})));const o=a[b.AttributeNamesToDelete];o?.length&&(a[b.AttributeNamesToDelete]=o.filter(e=>!!e?.trim()));const s=a[b.Renames];if(s){const e=Array.isArray(s)?s.map(e=>[e?.key??"",e?.value??""]):Object.entries(s);a[b.Renames]=Object.fromEntries(e.filter(([e,t])=>!!e?.trim()&&!!t?.trim()))}const i=new Set((t?.fields||[]).filter(e=>e.componentType===w.SourceScopes).map(e=>e.name));void 0!==a[b.Scopes]&&i.add(b.Scopes),i.forEach(e=>{const t=a[e];void 0!==t&&(a[e]=Q(t)?null:t)});const c=a[b.ExtractAttribute];return c?.extractions?.length&&(a[b.ExtractAttribute]={extractions:c.extractions.map(e=>{const t=e,r=t.method||(t.regex?.trim()?"regex":"preset"),a=t.targetAttributeName?.trim()||"";if("regex"===r)return{targetAttributeName:a,lookupKey:"",regex:t.regex?.trim()||""};const n={targetAttributeName:a,lookupKey:t.lookupKey?.trim()||"",regex:""};return t.dataFormat&&(n.dataFormat=t.dataFormat),n}).filter(e=>!!(e.targetAttributeName||e.lookupKey||e.dataFormat||e.regex))}),r.fields=a,r})(l.formData,i),t={};return L(e.signals)&&(t.signals=d.FIELD_IS_REQUIRED),i.type&&Object.assign(t,((e,t,r)=>{const a={},n=t.fields||{},o=r.fields||{};switch(e){case P.K8sAttributes:{const e=!(n[b.CollectContainerAttributes]||n[b.CollectReplicaSetAttributes]||n[b.CollectWorkloadId]||n[b.CollectClusterId]),t=!n[b.LabelsAttributes]?.length,r=!n[b.AnnotationsAttributes]?.length;e&&t&&r&&(a[b.CollectContainerAttributes]="Enable at least one option or add a label/annotation row");const o=n[b.LabelsAttributes];o?.some(e=>!pt(e,["labelKey","attributeKey","fromSources"]))&&(a[b.LabelsAttributes]=ut);const s=n[b.AnnotationsAttributes];s?.some(e=>!pt(e,["annotationKey","attributeKey","fromSources"]))&&(a[b.AnnotationsAttributes]=ut);break}case P.AddClusterInfo:{const e=n[b.ClusterAttributes];e?.length?e.some(e=>!pt(e,["attributeName","attributeStringValue"]))&&(a[b.ClusterAttributes]=ut):a[b.ClusterAttributes]=mt;break}case P.DeleteAttributes:{const e=o[b.AttributeNamesToDelete]||[],t=n[b.AttributeNamesToDelete]||[];t.length?e.length>t.length&&(a[b.AttributeNamesToDelete]=ut):a[b.AttributeNamesToDelete]=e.length?ut:mt;break}case P.RenameAttributes:{const e=Object.entries(o[b.Renames]||{}),t=Object.entries(n[b.Renames]||{}),r=e.some(([e,t])=>!e?.trim()||!t?.trim());t.length?r&&(a[b.Renames]=ut):a[b.Renames]=e.length?ut:mt;break}case P.PiiMasking:{const e=n[b.PiiCategories];e?.length||(a[b.PiiCategories]="Select at least one attribute to mask");break}case P.URLTemplatization:{const e=n[b.UrlTemplatizationRulesGroups];(!e?.length||e.some(e=>!e.templatizationRules?.length))&&(a[b.UrlTemplatizationRulesGroups]="Each rule group needs at least one non-blank template");break}case P.ExtractAttribute:{const e=n[b.ExtractAttribute]?.extractions||[],t=o[b.ExtractAttribute]?.extractions||[];if(e.length)if(e.some(e=>{if(!e.targetAttributeName?.trim())return!0;const t=!!e.regex?.trim(),r=!!e.lookupKey?.trim();return r!==!!e.dataFormat||t===r}))a[b.ExtractAttribute]="Each row needs a target attribute name and either a regex or both lookup key and data format";else{const t=new Set;e.some(e=>{const r=e.targetAttributeName?.trim()||"";return!!t.has(r)||(t.add(r),!1)})&&(a[b.ExtractAttribute]="Each new span attribute name must be unique")}else a[b.ExtractAttribute]=t.length?ut:mt;break}}return a})(i.type,e,l.formData)),l.handleErrorChange(void 0,void 0,t),{errorMessage:Object.keys(t).length>0?"Invalid form values":void 0,preparedFormData:e}},[l,i]),f=t(()=>({selectedOption:i,onSelectOption:u,loadAction:m,genericForm:l,validateFormData:p,sourceOptions:a,namespaceOptions:s}),[i,u,m,l,p,a,s]);return e(ct.Provider,{value:f,children:r})},Et=()=>{const e=r(ct);if(!e)throw new Error("useActionFormContext must be used within an ActionFormContextProvider");return e},yt={provider:"",permission:"",customCapabilities:{},authMethod:"",setupMethod:"",accountId:"",credentials:{},accessToken:"",secretId:"",name:""},ht=a(null),St=({children:r,providers:a=[]})=>{const o=N(yt),s=n(()=>{const e=O(o.formData);return e.provider?e.permission?{errorMessage:void 0,preparedFormData:e}:{errorMessage:"Please select a permission level",preparedFormData:e}:{errorMessage:"Please select a provider",preparedFormData:e}},[o]),i=t(()=>({providers:a,genericForm:o,validateFormData:s}),[a,o,s]);return e(ht.Provider,{value:i,children:r})},Tt=()=>{const e=r(ht);if(!e)throw new Error("useCloudConnectorFormContext must be used within a CloudConnectorFormContextProvider");return e},gt={name:""},_t=a(null),It=({children:r,defaultExcludeName:a=""})=>{const{dataStreams:s}=h(),[c,l]=o(void 0),[u,m]=o(a),[p,f]=o(void 0),[E,y]=o(null),S=i(null),T=N(gt),g=n(e=>{T.resetFormData({name:e}),T.handleErrorChange(void 0,void 0,{}),l(void 0),m(e),f(e),y(null),S.current=null},[]),_=n(()=>{const e=O(T.formData),t=(e=>{const t={};return e.name?k(e.name)||(t.name=d.ILLEGAL_K8S_LABEL):t.name=d.FIELD_IS_REQUIRED,t})(e);T.handleErrorChange(void 0,void 0,t);const r=Object.keys(t).length>0?d.REQUIRED_FIELDS:void 0;return l(r),{errorMessage:r,preparedFormData:e}},[T]),I=n(async e=>{const{errorMessage:t,preparedFormData:r}=_();if(t)return;const a=s.find(e=>e.name===r.name&&e.name!==u);if(a)return S.current=e,void y({preparedFormData:r,existingName:a.name,editingName:p});await e(r)},[_,s,u,p]),A=n(async()=>{const e=S.current,t=E?.preparedFormData;S.current=null,y(null),e&&t&&await e(t)},[E]),R=n(()=>{S.current=null,y(null)},[]),v=t(()=>({genericForm:T,loadDataStream:g,editingName:p,validateFormData:_,requestSubmit:I,pendingMerge:E,confirmMerge:A,cancelMerge:R,errorMessage:c,excludeName:u,setExcludeName:m}),[T,g,p,_,I,E,A,R,c,u]);return e(_t.Provider,{value:v,children:r})},At=()=>{const e=r(_t);if(!e)throw new Error("useDataStreamFormContext must be used within a DataStreamFormContextProvider");return e},Rt={type:"",name:"",currentStreamName:"",disabled:!1,exportedSignals:{logs:!1,metrics:!1,traces:!1,profiles:!1},fields:[]},vt={activeForm:null,onChangeActiveForm:()=>{},loadDestination:()=>{},genericForm:void 0,validateFormData:()=>({isOk:!1,preparedFormData:O(Rt)}),unsavedDestinations:[],thisUnsavedDestination:void 0,setUnsavedDestinations:()=>{},addUnsavedDestination:()=>{},updateUnsavedDestination:()=>{},deleteUnsavedDestination:()=>{}},Ct=a(vt),Nt=e=>e.filter(e=>!!e).map(e=>{const{name:t,componentType:r,componentProperties:a,displayName:n,initialValue:o,renderCondition:s}=e,i=r===w.Dropdown,c=M(a,{});return{componentType:r,renderCondition:s,name:t,title:n,value:o,placeholder:c.placeholder||(i?"Select an option":void 0),options:i&&Array.isArray(c.values)?c.values.map(e=>({id:e,label:e})):void 0,...c}}),Ot=({children:r})=>{const{selectedStreamName:a}=h(),{items:i}=st().destinationsApi.useDestinations(),[c,l]=o(null),[u,m]=o(vt.unsavedDestinations),p=t(()=>"number"==typeof c?.unsavedIdx?u[c.unsavedIdx]:void 0,[c,u]),f=n((e,t)=>{c&&(m(t=>[...t,{...e,option:c.option}]),l(t?e=>e?{...e,listType:F.UNSAVED,unsavedIdx:u.length}:null:null))},[c,u.length]),E=n((e,t,r)=>{c&&(m(r=>r.map((r,a)=>a===e?{...r,...t,option:c.option}:r)),l(r?e=>e?{...e,listType:F.UNSAVED}:null:null))},[c]),y=n(e=>{m(t=>t.filter((t,r)=>r!==e)),l(null)},[]),S=N({...Rt,currentStreamName:a});s(()=>{if(!c)return;if(p)return void S.resetFormData({...p.formData});if(c.listType===F.EXISTS&&c.option.id){const e=i.find(e=>e.id===c.option.id);if(e)return void S.resetFormData({type:e.destinationType.type,name:e.name||e.destinationType.displayName,currentStreamName:a,disabled:!!e.disabled,exportedSignals:{logs:!!e.exportedSignals?.logs,metrics:!!e.exportedSignals?.metrics,traces:!!e.exportedSignals?.traces,profiles:!!e.exportedSignals?.profiles},fields:c.dynamicFields.map(e=>({key:e.name,value:e.value}))})}const e=G(c.option.supportedSignals);S.resetFormData({type:c.option.type,name:c.option.displayName,currentStreamName:a,disabled:!1,exportedSignals:{logs:e.includes(U.Logs),metrics:e.includes(U.Metrics),traces:e.includes(U.Traces),profiles:e.includes(U.Profiles)},fields:c.dynamicFields.map(e=>({key:e.name,value:e.value}))})},[c,p]);const T=n(e=>{S.resetFormData(),S.handleErrorChange(void 0,void 0,{}),l(e?{...e,dynamicFields:e.option?.fields?Nt(e.option.fields):[]}:null)},[]),g=n((e,t)=>{let r;for(const a of t){const t=a.items.find(t=>t.type===e.destinationType.type);if(t){r=t;break}}const a=M(e.fields,{}),n={id:e.id,type:e.destinationType.type,displayName:e.name||e.destinationType.displayName,selected:!0,testConnectionSupported:r?.testConnectionSupported??!1,supportedSignals:e.destinationType.supportedSignals,fields:r?r.fields.map(e=>({...e,initialValue:a[e.name]??e.initialValue})):[]},o=Nt(n.fields);l({listType:F.EXISTS,option:n,dynamicFields:o})},[]),_=n(()=>{const e=O(S.formData),t={};return c?.dynamicFields.forEach(({name:r,required:a})=>{if(a){const a=e.fields.find(e=>e.key===r)?.value;L(a)&&(t[r]=d.FIELD_IS_REQUIRED)}}),x(e.exportedSignals).length||(t.exportedSignals=d.FIELD_IS_REQUIRED),S.handleErrorChange(void 0,void 0,t),{errorMessage:0===Object.keys(t).length?void 0:"Invalid form values",preparedFormData:e}},[S,c]);return e(Ct.Provider,{value:{activeForm:c,onChangeActiveForm:T,loadDestination:g,genericForm:S,validateFormData:_,unsavedDestinations:u,thisUnsavedDestination:p,setUnsavedDestinations:m,addUnsavedDestination:f,updateUnsavedDestination:E,deleteUnsavedDestination:y},children:r})},Dt=()=>r(Ct),bt={disabled:!1,ruleName:"",notes:"",sourceScopes:J(),workloads:null,instrumentationLibraries:null,payloadCollection:null,codeAttributes:null,headersCollection:null,customInstrumentations:null,networkMetrics:null},wt=a(null),Pt=({children:r,sourceOptions:a=[],namespaceOptions:s=[]})=>{const[i,c]=o(null),l=N(bt),d=n(e=>{l.resetFormData(),l.handleErrorChange(void 0,void 0,{}),c(e)},[]),u=n((e,t)=>{var r;l.resetFormData((({ruleName:e,notes:t,disabled:r,sourceScopes:a,instrumentationLibraries:n,payloadCollection:o,codeAttributes:s,headersCollection:i,customInstrumentations:c,networkMetrics:l,workloads:d})=>({ruleName:e||"",notes:t||"",disabled:!!r,sourceScopes:z(a),workloads:d??null,instrumentationLibraries:n??null,payloadCollection:o??null,codeAttributes:s??null,headersCollection:i??null,customInstrumentations:c??null,networkMetrics:l??null}))(e)),l.handleErrorChange(void 0,void 0,{}),c(t??(r=e.type,H.find(e=>e.type===r)??null))},[]),m=n(()=>{if(!i)return{errorMessage:"No rule type selected",preparedFormData:O(bt)};const e=(e=>{const t=O(e),{workloads:r,...a}=t,n={...a,sourceScopes:Q(t.sourceScopes)?null:t.sourceScopes,...r?.length?{workloads:r}:{}};return n.headersCollection?.[K.HeaderKeys]?.length&&(n.headersCollection[K.HeaderKeys]=n.headersCollection[K.HeaderKeys].map(e=>e.trim()).filter(e=>e)),n.customInstrumentations?.[W.Golang]?.length&&(n.customInstrumentations[W.Golang]=n.customInstrumentations[W.Golang].map(e=>new $(e.packageName,e.functionName,e.receiverName,e.receiverMethodName)).filter(e=>{return t=e,!!(t.packageName?.trim()||t.functionName?.trim()||t.receiverName?.trim()||t.receiverMethodName?.trim());var t})),n.customInstrumentations?.[W.Java]?.length&&(n.customInstrumentations[W.Java]=n.customInstrumentations[W.Java].map(e=>new V(e.className,e.methodName)).filter(e=>{return t=e,!(!t.className?.trim()&&!t.methodName?.trim());var t})),n.customInstrumentations?.[W.Php]?.length&&(n.customInstrumentations[W.Php]=n.customInstrumentations[W.Php].map(e=>new Y(e.className,e.functionName)).filter(e=>{return t=e,!(!t.className?.trim()&&!t.functionName?.trim());var t})),n})(l.formData),t=((e,t)=>{const r={};switch(e){case j.CodeAttributes:Object.values(t.codeAttributes||{}).some(e=>null!=e)||(r.codeAttributes="Code attributes are required");break;case j.PayloadCollection:Object.values(t.payloadCollection||{}).some(e=>null!=e)||(r.payloadCollection="Payload collection are required");break;case j.HeadersCollection:t.headersCollection?.[K.HeaderKeys]?.length||(r.headersCollection="Header keys are required");break;case j.CustomInstrumentation:{const e=t.customInstrumentations?.[W.Golang]||[],a=t.customInstrumentations?.[W.Java]||[],n=t.customInstrumentations?.[W.Php]||[];if(!e.length&&!a.length&&!n.length){r.customInstrumentations="Custom instrumentation are required";break}const o=e.findIndex(e=>!new $(e.packageName,e.functionName,e.receiverName,e.receiverMethodName).Verify());if(-1!==o){r.customInstrumentations=`Golang probe #${o+1} is invalid: provide a package name plus either a function name OR both a receiver name and receiver method name`;break}const s=a.findIndex(e=>!new V(e.className,e.methodName).Verify());if(-1!==s){r.customInstrumentations=`Java probe #${s+1} is invalid: both class name and method name are required`;break}const i=n.findIndex(e=>!new Y(e.className,e.functionName).Verify());if(-1!==i){r.customInstrumentations=`PHP probe #${i+1} is invalid: function name is required`;break}break}}return r})(i.type,e);return l.handleErrorChange(void 0,void 0,t),{errorMessage:Object.keys(t).length>0?"Invalid form values":void 0,preparedFormData:e}},[l,i]),p=t(()=>({selectedOption:i,onSelectOption:d,loadRule:u,genericForm:l,validateFormData:m,sourceOptions:a,namespaceOptions:s}),[i,d,u,l,m,a,s]);return e(wt.Provider,{value:p,children:r})},Lt=()=>{const e=r(wt);if(!e)throw new Error("useRuleFormContext must be used within a RuleFormContextProvider");return e};var kt;(e=>{e.Create="create",e.View="view",e.EditAutoNoisy="edit-auto-noisy",e.EditAutoCostReduction="edit-auto-cost-reduction",e.EditAutoHighlyRelevant="edit-auto-highly-relevant"})(kt||(kt={}));const Ft=a(null),Gt=["50","25","10","1"];function Ut(e){const t=String(e);return Gt.includes(t)?t:"custom"}const Mt=({category:r,sourceOptions:a=[],namespaceOptions:i=[],children:c})=>{const{formData:l,handleFormChange:d,resetFormData:u}=N(re(r)),[m,p]=o(null);s(()=>{u(re(r)),p(null)},[r]);const f=n(e=>{p(null),d(void 0,void 0,{...l,...e})},[l,d]),E=n(()=>{u(re(r)),p(null)},[r,u]),y=t(()=>({formType:kt.Create,category:r,formData:l,handleChange:f,resetForm:E,duplicateWarning:m,setDuplicateWarning:p,sourceOptions:a,namespaceOptions:i}),[r,l,f,E,m,a,i]);return e(Ft.Provider,{value:y,children:c})},xt=({data:r,defaultEditMode:a,sourceOptions:c=[],namespaceOptions:l=[],children:d})=>{const[u,m]=o(!1),{formData:p,handleFormChange:f,resetFormData:E}=N(void 0),y=i(null),[h,S]=o(null);s(()=>{r!==y.current&&(y.current=r,r&&a?(E(te(r)),S(null),m(!0)):(m(!1),S(null)))},[r,a]);const T=n(e=>{S(null),f(void 0,void 0,{...p,...e})},[p,f]),g=n(()=>{r&&(E(te(r)),S(null),m(!0))},[r,E]),_=n(()=>{m(!1),S(null)},[]),I=t(()=>({formType:kt.View,data:r,isEditing:u,formData:p,handleChange:T,handleEdit:g,handleCancelEdit:_,duplicateWarning:h,setDuplicateWarning:S,sourceOptions:c,namespaceOptions:l}),[r,u,p,T,g,_,h,c,l]);return e(Ft.Provider,{value:I,children:d})};function Ht(e){const[r,a]=o(()=>0===e?"all":"sample"),[n,i]=o(()=>Ut(e)),[c,l]=o(()=>"custom"===Ut(e)?String(e):"");s(()=>{a(0===e?"all":"sample");const t=Ut(e);i(t),l("custom"===t?String(e):"")},[e]);const d=t(()=>"all"===r?0:"custom"===n?Number(c)||0:Number(n),[r,n,c]);return{percentageMode:r,setPercentageMode:a,percentagePreset:n,setPercentagePreset:i,customPercentage:c,setCustomPercentage:l,resolvedPercentage:d}}const Kt=({enabled:r,keepPercentage:a,children:n})=>{const[i,c]=o(r),l=Ht(a);s(()=>{c(r)},[r]);const d=t(()=>ee({enabled:i,keepPercentage:l.resolvedPercentage}),[i,l.resolvedPercentage]),u=t(()=>({formType:kt.EditAutoNoisy,localEnabled:i,setLocalEnabled:c,...l,summary:d}),[i,l,d]);return e(Ft.Provider,{value:u,children:n})},Wt=({enabled:r,dropPercentage:a,children:n})=>{const[i,c]=o(r),l=Ht(a);s(()=>{c(r)},[r]);const d=t(()=>Z(i?{disabled:!1,percentageAtMost:l.resolvedPercentage}:null),[i,l.resolvedPercentage]),u=t(()=>({formType:kt.EditAutoCostReduction,localEnabled:i,setLocalEnabled:c,...l,summary:d}),[i,l,d]);return e(Ft.Provider,{value:u,children:n})},$t=({enabled:r,children:a})=>{const[n,i]=o(r);s(()=>{i(r)},[r]);const c=t(()=>X(n?{disabled:!1}:null),[n]),l=t(()=>({formType:kt.EditAutoHighlyRelevant,localEnabled:n,setLocalEnabled:i,summary:c}),[n,c]);return e(Ft.Provider,{value:l,children:a})},Vt=t=>{switch(t.formType){case kt.Create:return e(Mt,{...t});case kt.View:return e(xt,{...t});case kt.EditAutoNoisy:return e(Kt,{...t});case kt.EditAutoCostReduction:return e(Wt,{...t});case kt.EditAutoHighlyRelevant:return e($t,{...t})}};function Yt(e){const t=r(Ft);if(!t)throw new Error("useSamplingRulesFormContext must be used within a SamplingRulesFormProvider");if(e&&t.formType!==e)throw new Error(`Expected formType "${e}" but found "${t.formType}"`);return t}const jt={otelServiceName:"",currentStreamName:""},qt=a(null),Bt=({children:r})=>{const[a,s]=o(void 0),i=N(jt),c=n(e=>{i.resetFormData((({serviceName:e,id:t})=>({otelServiceName:e||t.name||"",currentStreamName:""}))(e)),i.handleErrorChange(void 0,void 0,{}),s(void 0)},[]),l=n(()=>{const e=O(i.formData);return i.handleErrorChange(void 0,void 0,{}),s(void 0),{errorMessage:void 0,preparedFormData:e}},[i]),d=t(()=>({loadSource:c,genericForm:i,validateFormData:l,errorMessage:a}),[c,i,l,a]);return e(qt.Provider,{value:d,children:r})},Qt=()=>{const e=r(qt);if(!e)throw new Error("useSourceEditFormContext must be used within a SourceEditFormContextProvider");return e},zt=new Set([q.StaticPod]),Jt=e=>{const t=e.workloads.filter(({selected:e})=>e).length,r=e.workloads.length;return{selectedCount:t,isAllSourced:t>0&&t===r,isSomeSourced:t>0&&t<r,isFutureApps:e.selected||!1}},Xt=(e,t,r)=>{if(t&&!e.name.toLowerCase().includes(t.toLowerCase()))return!1;if(r.showOnlySelected){const{isAllSourced:t,isSomeSourced:r,isFutureApps:a}=Jt(e);return t||r||a}return!0},Zt=(e,t,r)=>!(t&&!e.name.toLowerCase().includes(t.toLowerCase()))&&(!r.showOnlySelected||e.selected),er=a({snapshots:null,setSnapshots:()=>{},isFetching:!1,setIsFetching:()=>{},formData:[],handleSourceChange:()=>{},handleSelectAll:()=>{},formDiff:{},isFormDirty:!1}),tr=(e,t)=>`${e}\0${t}`,rr=(e,t,r,a)=>`${e}\0${t}\0${r}/${a}`,ar=(e,t)=>e.name===t.name&&e.kind===t.kind&&(e.region??"")===(t.region??""),nr=(e,t,r)=>{const a=[];return t.workloads.forEach(n=>{const o=e?.workloads.find(e=>ar(e,n));n.selected!==o?.selected&&a.push({namespace:t.name,name:n.name,kind:n.kind,region:n.region||void 0,selected:n.selected||!1,currentStreamName:r})}),a},or=({children:r,selectedConnectionIds:a,initialInputs:c})=>{const{tier:l}=ae(),d=l===B.Onprem,{capabilities:u}=st(),m=u.canInstrumentNamespaces,{selectedStreamName:p}=h(),[f,y]=o(!1),[S,T]=o(null),[g,_]=o([]),I=i(new Set),A=n((e,t)=>{t.forEach(t=>{const r=e.find(e=>e.clusterId===t.clusterId);r&&t.namespaces.forEach(e=>{const a=r.namespaces.find(t=>t.name===e.name);a&&(a.selected!==e.selected&&I.current.add(tr(t.clusterId,e.name)),e.workloads.forEach(r=>{const n=a.workloads.find(e=>e.name===r.name&&e.kind===r.kind);n&&n.selected!==r.selected&&I.current.add(rr(t.clusterId,e.name,r.kind,r.name))}))})})},[]);s(()=>{S&&_(e=>{const t=((e,t)=>O(((e,t)=>e.clusters.filter(({clusterId:e})=>!t||t.includes(e)))(e,t)))(S,a);return t.map(t=>{const r=e?.find(e=>e.clusterId===t.clusterId),a=((e,t,r)=>{if(!t)return e;const a=new Map(t.namespaces.map(e=>[e.name,e]));return{...e,namespaces:e.namespaces.map(t=>{const n=a.get(t.name);if(!n)return t;const o=new Map(n.workloads.map(e=>[`${e.kind}/${e.name}`,e])),s=r.has(tr(e.clusterId,t.name));return{...t,selected:s?n.selected:t.selected,workloads:t.workloads.map(a=>{const n=o.get(`${a.kind}/${a.name}`),s=r.has(rr(e.clusterId,t.name,a.kind,a.name));return n&&s?{...a,selected:n.selected}:a})}})}})(t,r,I.current);if(c?.[t.clusterId]){const e=c[t.clusterId],r=O(a);return e.forEach(e=>{const t=r.namespaces.find(t=>t.name===e.namespace);if(t)if(e.name&&e.kind){const r=t.workloads.find(t=>t.name===e.name&&t.kind===e.kind);r&&(r.selected=e.selected)}else t.selected=e.selected,e.selected&&t.workloads.forEach(e=>{zt.has(e.kind)&&!d||(e.selected=!0)})}),r}return a})})},[S,a,c]);const{formDiff:R,isFormDirty:v}=t(()=>{const e=((e,t,r,a)=>{const n={};return e.forEach(e=>{e.namespaces.forEach(o=>{const s=t.find(t=>t.clusterId===e.clusterId)?.namespaces.find(e=>e.name===o.name);if(!a){const t=nr(s,o,r);return void(t.length>0&&(n[e.clusterId]||(n[e.clusterId]=[]),n[e.clusterId].push(...t)))}const i=o.selected||!1;if(i!==s?.selected)n[e.clusterId]||(n[e.clusterId]=[]),n[e.clusterId].push({namespace:o.name,selected:i,currentStreamName:r}),i?n[e.clusterId]=n[e.clusterId].filter(e=>e.namespace!==o.name||e.namespace===o.name&&(!e.name||!e.kind)):o.workloads.forEach(t=>{t.selected&&n[e.clusterId].push({namespace:o.name,name:t.name,kind:t.kind,region:t.region||void 0,selected:!0,currentStreamName:r})});else{const t=nr(s,o,r);t.length>0&&(n[e.clusterId]||(n[e.clusterId]=[]),n[e.clusterId].push(...t))}})}),n})(g,S?.clusters||[],p,m);return{formDiff:e,isFormDirty:Object.keys(e).length>0}},[g,S,p,m]),C=n(e=>!d&&zt.has(e),[d]),N=n(({clusterId:e,workloadId:t,selected:r,auto:a})=>{_(n=>{const o=O(n),s=o.findIndex(t=>t.clusterId===e);if(-1===s)return o;const i=o[s].namespaces.findIndex(e=>e.name===t.namespace);if(-1===i)return o;if(t.kind&&t.name){const e=o[s].namespaces[i].workloads.findIndex(e=>ar(e,{name:t.name,kind:t.kind,region:t.region}));if(-1===e)return o;const a="boolean"==typeof r?r:!o[s].namespaces[i].workloads[e].selected;o[s].namespaces[i].workloads[e].selected=a,m&&(a?o[s].namespaces[i].workloads.filter(e=>!C(e.kind)).every(e=>e.selected)&&(o[s].namespaces[i].selected=!0):o[s].namespaces[i].selected=!1)}else if(m){const e="boolean"==typeof a?a:!o[s].namespaces[i].selected;o[s].namespaces[i].selected=e,e?o[s].namespaces[i].workloads.forEach(e=>{C(e.kind)||(e.selected=!0)}):"boolean"!=typeof r||r||o[s].namespaces[i].workloads.forEach(e=>{e.selected=!1})}else{const e="boolean"==typeof r?r:"boolean"!=typeof a||a;o[s].namespaces[i].workloads.forEach(t=>{e&&C(t.kind)||(t.selected=e)})}return A(n,o),o})},[C,m,A]),D=n(({clusterId:e,namespaceName:t,boolean:r,searchText:a="",searchBy:n="",filters:o})=>{_(s=>{const i=O(s),c=n===E.Namespace?a:"",l=n===E.Source?a:"",d=!!c||!!l||!!o?.showOnlySelected;return i.forEach((a,n)=>{e&&a.clusterId!==e||a.namespaces.forEach(({name:e,workloads:a},s)=>{if(!t||e===t)if(d)if(t){if(a.forEach((e,t)=>{r&&C(e.kind)||Zt(e,l,o||{showOnlySelected:!1})&&(i[n].namespaces[s].workloads[t].selected=r)}),m){const e=i[n].namespaces[s].workloads.filter(e=>!C(e.kind)).every(e=>e.selected);i[n].namespaces[s].selected=e}}else{if(!Xt(i[n].namespaces[s],c,o||{showOnlySelected:!1}))return;m&&(i[n].namespaces[s].selected=r),a.forEach((e,t)=>{r&&C(e.kind)||(i[n].namespaces[s].workloads[t].selected=r)})}else m&&(i[n].namespaces[s].selected=r),a.forEach((e,t)=>{r&&C(e.kind)||(i[n].namespaces[s].workloads[t].selected=r)})})}),A(s,i),i})},[C,m,A]);return e(er.Provider,{value:{snapshots:S,setSnapshots:T,isFetching:f,setIsFetching:y,formData:g,handleSourceChange:N,handleSelectAll:D,formDiff:R,isFormDirty:v},children:r})},sr=()=>r(er);export{ft as A,St as C,It as D,zt as E,ve as O,Pt as R,kt as S,Fe as a,Ot as b,_e as c,Vt as d,Bt as e,or as f,Ye as g,Et as h,We as i,$e as j,Ke as k,Tt as l,At as m,Dt as n,st as o,je as p,Lt as q,ke as r,Yt as s,Qt as t,ge as u,sr as v,Zt as w,Xt as x,Jt as y};