@odigos/ui-kit 0.0.290 → 0.0.292

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.
Files changed (96) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/lib/chunks/{helpers-esDVvrTt.js → helpers-BGOJ3YRA.js} +1 -1
  3. package/lib/chunks/index-BIET8cd3.js +338 -0
  4. package/lib/chunks/source-instrument-form-context-BmNrVjHW.js +5 -0
  5. package/lib/chunks/{ui-components-DvoeDBMI.js → ui-components-DLJJffgA.js} +385 -252
  6. package/lib/components/_cards/text-card/index.d.ts +1 -0
  7. package/lib/components/charts/bar-chart/index.d.ts +14 -0
  8. package/lib/components/charts/index.d.ts +1 -0
  9. package/lib/components/island/index.d.ts +10 -1
  10. package/lib/components.js +1 -1
  11. package/lib/constants/common.d.ts +2 -0
  12. package/lib/constants/index.d.ts +2 -0
  13. package/lib/constants/insights/common.d.ts +15 -0
  14. package/lib/constants/insights/detection.d.ts +19 -0
  15. package/lib/{containers/insights/settings-and-configurations/panels/guardrails/constants.d.ts → constants/insights/guardrails.d.ts} +22 -13
  16. package/lib/constants/insights/index.d.ts +5 -0
  17. package/lib/{containers/insights/settings-and-configurations/panels/learning/constants.d.ts → constants/insights/learning.d.ts} +4 -27
  18. package/lib/{containers/insights/settings-and-configurations/panels/system/constants.d.ts → constants/insights/system.d.ts} +2 -6
  19. package/lib/constants.js +1 -1
  20. package/lib/containers/_drawers/index.d.ts +1 -0
  21. package/lib/containers/{insights/settings-and-configurations/panels/detection → _drawers}/risk-model-drawer/default-catalog.d.ts +1 -1
  22. package/lib/containers/{insights/settings-and-configurations/panels/detection → _drawers}/risk-model-drawer/helpers.d.ts +2 -2
  23. package/lib/containers/{insights/settings-and-configurations/panels/detection → _drawers}/risk-model-drawer/index.d.ts +3 -3
  24. package/lib/containers/_forms/index.d.ts +1 -0
  25. package/lib/containers/_forms/insights/detection-policy-form/index.d.ts +12 -0
  26. package/lib/containers/{insights/settings-and-configurations/panels/detection → _forms/insights/detection-policy-form}/mappers.d.ts +1 -1
  27. package/lib/containers/{insights/settings-and-configurations/panels/detection → _forms/insights/detection-policy-form}/signal-weights-panel.d.ts +1 -1
  28. package/lib/containers/{insights/settings-and-configurations/panels/detection → _forms/insights/detection-policy-form}/signal-weights.d.ts +2 -2
  29. package/lib/containers/_forms/insights/guardrail-form/extra-section.d.ts +15 -0
  30. package/lib/containers/{insights/settings-and-configurations/panels/guardrails → _forms/insights/guardrail-form}/facet-section.d.ts +1 -1
  31. package/lib/containers/_forms/insights/guardrail-form/index.d.ts +23 -0
  32. package/lib/containers/{insights/settings-and-configurations/panels/guardrails → _forms/insights/guardrail-form}/mappers.d.ts +3 -1
  33. package/lib/containers/_forms/insights/guardrail-form/types.d.ts +17 -0
  34. package/lib/containers/_forms/insights/index.d.ts +4 -0
  35. package/lib/containers/_forms/insights/learning-policy-form/index.d.ts +12 -0
  36. package/lib/containers/{insights/settings-and-configurations/panels/learning → _forms/insights/learning-policy-form}/mappers.d.ts +3 -3
  37. package/lib/containers/_forms/insights/learning-policy-form/options.d.ts +11 -0
  38. package/lib/containers/{insights/settings-and-configurations/panels/learning → _forms/insights/learning-policy-form}/types.d.ts +1 -1
  39. package/lib/containers/_forms/insights/system-settings-form/index.d.ts +9 -0
  40. package/lib/containers/_forms/insights/system-settings-form/mappers.d.ts +11 -0
  41. package/lib/containers/_forms/insights/system-settings-form/types.d.ts +11 -0
  42. package/lib/containers/insights/findings/drawer/helpers.d.ts +3 -9
  43. package/lib/containers/insights/findings/helpers.d.ts +19 -2
  44. package/lib/containers/insights/insights-context.d.ts +0 -20
  45. package/lib/containers/insights/settings-and-configurations/panels/detection/helpers.d.ts +28 -0
  46. package/lib/containers/insights/settings-and-configurations/panels/guardrails/helpers.d.ts +30 -0
  47. package/lib/containers/insights/settings-and-configurations/panels/learning/helpers.d.ts +46 -0
  48. package/lib/containers/insights/settings-and-configurations/panels/panel.d.ts +44 -0
  49. package/lib/containers/insights/transactions/drawer/baselines/data-drawer/index.d.ts +8 -0
  50. package/lib/containers/insights/transactions/drawer/baselines/helpers.d.ts +4 -0
  51. package/lib/containers/insights/transactions/drawer/observations/data-drawer/index.d.ts +8 -0
  52. package/lib/containers.js +1834 -2146
  53. package/lib/contexts/index.d.ts +1 -0
  54. package/lib/contexts/insights/detection-override-form-context.d.ts +44 -0
  55. package/lib/contexts/insights/detection-policy-form-context.d.ts +29 -0
  56. package/lib/contexts/insights/guardrail-form-context.d.ts +67 -0
  57. package/lib/contexts/insights/index.d.ts +6 -0
  58. package/lib/contexts/insights/learning-override-form-context.d.ts +45 -0
  59. package/lib/contexts/insights/learning-policy-form-context.d.ts +34 -0
  60. package/lib/contexts/insights/system-settings-form-context.d.ts +28 -0
  61. package/lib/contexts/odigos-api/hooks/use-insights-api.d.ts +6 -1
  62. package/lib/contexts/odigos-api/types.d.ts +2 -1
  63. package/lib/contexts.js +1 -1
  64. package/lib/functions.js +1 -1
  65. package/lib/hooks.js +1 -1
  66. package/lib/snippets/index.d.ts +0 -1
  67. package/lib/snippets.js +1 -1
  68. package/lib/store.js +1 -1
  69. package/lib/theme.js +1 -1
  70. package/lib/types/insights/index.d.ts +43 -2
  71. package/lib/types.js +1 -1
  72. package/lib/visuals.js +1 -1
  73. package/package.json +1 -1
  74. package/lib/chunks/index-lV6RFSE-.js +0 -351
  75. package/lib/chunks/source-instrument-form-context-B9BHhgvw.js +0 -5
  76. package/lib/containers/insights/settings-and-configurations/content-panel/index.d.ts +0 -11
  77. package/lib/containers/insights/settings-and-configurations/panels/detection/constants.d.ts +0 -40
  78. package/lib/containers/insights/settings-and-configurations/panels/detection/create-override-panel.d.ts +0 -14
  79. package/lib/containers/insights/settings-and-configurations/panels/detection/mock.d.ts +0 -4
  80. package/lib/containers/insights/settings-and-configurations/panels/detection/policies-menu.d.ts +0 -10
  81. package/lib/containers/insights/settings-and-configurations/panels/detection/policy-editor.d.ts +0 -8
  82. package/lib/containers/insights/settings-and-configurations/panels/detection/policy-list-item.d.ts +0 -8
  83. package/lib/containers/insights/settings-and-configurations/panels/guardrails/create-panel.d.ts +0 -13
  84. package/lib/containers/insights/settings-and-configurations/panels/guardrails/edit-panel.d.ts +0 -10
  85. package/lib/containers/insights/settings-and-configurations/panels/guardrails/guardrail-list-item.d.ts +0 -8
  86. package/lib/containers/insights/settings-and-configurations/panels/guardrails/guardrails-menu.d.ts +0 -9
  87. package/lib/containers/insights/settings-and-configurations/panels/guardrails/types.d.ts +0 -10
  88. package/lib/containers/insights/settings-and-configurations/panels/learning/create-override-panel.d.ts +0 -21
  89. package/lib/containers/insights/settings-and-configurations/panels/learning/policies-menu.d.ts +0 -10
  90. package/lib/containers/insights/settings-and-configurations/panels/learning/policy-editor.d.ts +0 -9
  91. package/lib/containers/insights/settings-and-configurations/panels/learning/policy-list-item.d.ts +0 -8
  92. package/lib/snippets/code-modal/index.d.ts +0 -9
  93. package/lib/snippets/trace-modal/index.d.ts +0 -8
  94. /package/lib/containers/{insights/settings-and-configurations/panels/detection → _drawers}/risk-model-drawer/constants.d.ts +0 -0
  95. /package/lib/containers/{insights/settings-and-configurations/panels/detection → _forms/insights/detection-policy-form}/risk-levels.d.ts +0 -0
  96. /package/lib/containers/{insights/settings-and-configurations/panels/detection → _forms/insights/detection-policy-form}/types.d.ts +0 -0
@@ -1,351 +0,0 @@
1
- import{jsx as e,jsxs as t,Fragment as a}from"react/jsx-runtime";import r,{css as l,useTheme as n}from"styled-components";import i,{useMemo as o,useRef as s,useCallback as c,useState as d,memo as u,useEffect as p,Fragment as h,forwardRef as g,useImperativeHandle as m}from"react";import"@xyflow/react/dist/style.css";import{Handle as v,Position as f,getSmoothStepPath as b,BaseEdge as y,EdgeLabelRenderer as x,MarkerType as $,ReactFlowProvider as C,useNodesState as k,useEdgesState as w,ReactFlow as S,Background as T,useReactFlow as M}from"@xyflow/react";import{D as A,c as P,F as O,d as L,e as E,f as I,g as N,h as R,B as V,i as z,j as D,k as X,C as _,N as H,W as B,u as j,M as q,I as U,l as G,m as K,n as W,o as F,p as Y,V as J,q as Z,r as Q,s as ee,v as te,w as ae,x as re,y as le,z as ne,E as ie,G as oe,H as se,J as ce,K as de,L as ue,O as pe,S as he,Q as ge,U as me,X as ve,Y as fe,Z as be,_ as ye,$ as xe,a0 as $e,a1 as Ce,a2 as ke,a3 as we,a4 as Se,a5 as Te,a6 as Me,a7 as Ae,a8 as Pe,a9 as Oe,aa as Le,ab as Ee,T as Ie,ac as Ne,ad as Re,ae as Ve,af as ze,ag as De,ah as Xe,ai as _e,aj as He,ak as Be,al as je,am as qe,an as Ue,ao as Ge,b as Ke,ap as We,aq as Fe,ar as Ye,as as Je,at as Ze,au as Qe,av as et,aw as tt,ax as at,ay as rt,az as lt,aA as nt,aB as it,aC as ot,aD as st,aE as ct,aF as dt,aG as ut,aH as pt,aI as ht,aJ as gt,aK as mt,aL as vt,aM as ft,aN as bt,aO as yt,aP as xt,aQ as $t,aR as Ct,aS as kt,aT as wt,aU as St,aV as Tt,aW as Mt,aX as At,aY as Pt,aZ as Ot,a_ as Lt,a$ as Et,b0 as It,b1 as Nt,b2 as Rt,b3 as Vt,b4 as zt,b5 as Dt,b6 as Xt,b7 as _t,R as Ht,b8 as Bt,A as jt,b9 as qt}from"./ui-components-DvoeDBMI.js";import{UserIcon as Ut,DestinationIcon as Gt,HomeIcon as Kt,XIcon as Wt,VIcon as Ft,TrashIcon as Yt,PlusIcon as Jt,VSquareIcon as Zt,XSquareIcon as Qt,EditIcon as ea,OdigosLogoTextCentral as ta,OdigosLogoTextEnterprise as aa,OdigosLogoTextCommunity as ra,OdigosLogoTextColoredCentral as la,OdigosLogoTextColoredEnterprise as na,OdigosLogoTextColoredCommunity as ia,ArrowLeftIcon as oa,ArrowRightIcon as sa,CopyIcon as ca,YamlIcon as da}from"../icons.js";import{i as ua,m as pa,u as ha,n as ga,a as ma,C as va,b as fa,d as ba,e as ya,f as xa,g as $a,h as Ca,j as ka,k as wa}from"./helpers-esDVvrTt.js";const Sa=/^[a-zA-Z]$/,Ta=new Set(["*","+","?"]),Ma=new Set(["^","$"]),Aa={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"},Pa=r.div`
2
- padding: 8px 16px;
3
- border-radius: 6px;
4
- border: 1px solid ${({theme:e})=>e.v2.colors.silver[500]};
5
- background: ${({theme:e})=>e.v2.colors.black[500]};
6
- font-family: ${({theme:e})=>e.font_family.code};
7
- font-size: 12px;
8
- line-height: 20px;
9
- color: ${({theme:e})=>e.v2.colors.white[500]};
10
- word-break: break-all;
11
- white-space: pre-wrap;
12
- user-select: text;
13
-
14
- /* Wraps the background tightly to each visual fragment when a colored
15
- token gets split across two visual lines. Without this the highlight
16
- stretches all the way to the right edge of the container. */
17
- & > span {
18
- box-decoration-break: clone;
19
- -webkit-box-decoration-break: clone;
20
- }
21
- `,Oa=r.span`
22
- background: ${({$kind:e})=>Aa[e]};
23
- `,La=({pattern:t,"data-id":a})=>{const r=o(()=>(e=>{const t=[];let a=0,r=!1;const l=(e,a)=>{const r=t[t.length-1];r&&r.kind===a?r.text+=e:t.push({text:e,kind:a})};for(;a<e.length;){const t=e[a];if(r){if("]"===t){l("]","class-bracket"),r=!1,a++;continue}if("\\"===t&&a+1<e.length){l(e.slice(a,a+2),"class-content"),a+=2;continue}l(t,"class-content"),a++}else{if("("===t&&"?"===e[a+1]){let t=2;const r=e[a+2];if(":"===r||"="===r||"!"===r)t=3;else if("<"===r){const r=e[a+3];if("="===r||"!"===r)t=4;else{const r=e.indexOf(">",a+2);-1!==r&&(t=r-a+1)}}l(e.slice(a,a+t),"group"),a+=t;continue}if("("!==t&&")"!==t)if("["!==t)if(Ta.has(t)||Ma.has(t))l(t,"anchor-quantifier"),a++;else{if("{"===t){const t=e.indexOf("}",a);if(t>a&&/^\{\d+,?\d*\}$/.test(e.slice(a,t+1))){l(e.slice(a,t+1),"anchor-quantifier"),a=t+1;continue}}if("\\"===t&&a+1<e.length){const t=e[a+1];Sa.test(t)?l(e.slice(a,a+2),"anchor-quantifier"):l(e.slice(a,a+2),"literal"),a+=2;continue}"|"!==t?(l(t,"literal"),a++):(l("|","alternation"),a++)}else"^"===e[a+1]?(l("[^","class-bracket"),a+=2):(l("[","class-bracket"),a++),r=!0;else l(t,"group"),a++}}return t})(t),[t]);return e(Pa,t?{"data-id":a,children:r.map((t,a)=>e(Oa,{$kind:t.kind,children:t.text},a))}:{"data-id":a,children:" "})},Ea="rgba(102, 191, 255, 0.5)",Ia=l`
24
- font-family: ${({theme:e})=>e.font_family.code};
25
- font-size: 12px;
26
- line-height: 20px;
27
- letter-spacing: 0;
28
- white-space: pre-wrap;
29
- word-wrap: break-word;
30
- overflow-wrap: break-word;
31
- /* tab-size keeps tabs visually consistent across the two layers — some
32
- browsers default to 8 on a textarea but 4 on a div. */
33
- -moz-tab-size: 4;
34
- tab-size: 4;
35
- margin: 0;
36
- `,Na=r.div`
37
- position: relative;
38
- width: 100%;
39
- min-height: ${({$minHeight:e})=>e}px;
40
- border-radius: 6px;
41
- border: 1px solid ${({theme:e})=>e.v2.colors.silver[500]};
42
- background: ${({theme:e})=>e.v2.colors.black[500]};
43
-
44
- &:hover,
45
- &:focus-within {
46
- border-color: ${({theme:e})=>e.v2.colors.silver[300]};
47
- }
48
- `,Ra=r.div`
49
- ${Ia}
50
- position: absolute;
51
- inset: 0;
52
- padding: 12px;
53
- pointer-events: none;
54
- color: transparent;
55
- overflow: hidden;
56
-
57
- /* Mandatory for backgrounds that wrap across visual lines. */
58
- & > span {
59
- box-decoration-break: clone;
60
- -webkit-box-decoration-break: clone;
61
- }
62
- `,Va=r.textarea`
63
- ${Ia}
64
- position: relative;
65
- z-index: 1;
66
- display: block;
67
- width: 100%;
68
- min-height: ${({$minHeight:e})=>e}px;
69
- padding: 12px;
70
- border: 0;
71
- background: transparent;
72
- outline: none;
73
- resize: vertical;
74
- color: ${({theme:e})=>e.v2.colors.white[500]};
75
- caret-color: ${({theme:e})=>e.v2.colors.white[500]};
76
- box-sizing: border-box;
77
-
78
- &::placeholder {
79
- color: ${({theme:e})=>e.v2.colors.silver[600]};
80
- }
81
- `,za=e=>({before:e,matchPre:"",capture:"",matchPost:"",after:""}),Da=({regex:a,value:r,onChange:l,minHeight:n=240,...i})=>{const d=s(null),u=s(null),p=o(()=>((e,t)=>{if(!e||!t)return za(t);let a;try{a=new RegExp(e)}catch{return za(t)}const r=a.exec(t);if(!r)return za(t);const l=r.index,n=r.index+r[0].length;if(r.length<2||null==r[1])return{before:t.slice(0,l),matchPre:"",capture:t.slice(l,n),matchPost:"",after:t.slice(n)};const i=r[0].indexOf(r[1]),o=i>=0?l+i:l,s=o+r[1].length;return{before:t.slice(0,l),matchPre:t.slice(l,o),capture:t.slice(o,s),matchPost:t.slice(s,n),after:t.slice(n)}})(a,r),[a,r]),h=c(()=>{d.current&&u.current&&(d.current.scrollTop=u.current.scrollTop,d.current.scrollLeft=u.current.scrollLeft)},[]);return t(Na,{$minHeight:n,children:[t(Ra,{ref:d,"aria-hidden":!0,children:[p.before,e("span",{style:{background:Ea},children:p.matchPre}),e("span",{style:{background:"rgba(102, 242, 102, 0.5)"},children:p.capture}),e("span",{style:{background:Ea},children:p.matchPost}),p.after,r.endsWith("\n")?" ":""]}),e(Va,{ref:u,$minHeight:n,value:r,onChange:e=>l(e.target.value),onScroll:h,spellCheck:!1,...i})]})},Xa=r.div`
82
- flex: 1;
83
- min-height: 0;
84
- overflow-y: auto;
85
- `,_a=r.div`
86
- background: ${({theme:e})=>e.v2.colors.silver[900]};
87
- border-radius: 8px;
88
- padding: 8px;
89
- display: flex;
90
- flex-direction: column;
91
- gap: 12px;
92
- `,Ha=r.div`
93
- padding: 8px 16px;
94
- border-radius: 8px;
95
- background: ${({theme:e})=>e.v2.colors.silver[800]};
96
- font-family: ${({theme:e})=>e.font_family.code};
97
- font-size: 12px;
98
- line-height: 20px;
99
- color: ${({theme:e,$tone:t})=>"error"===t?e.v2.colors.red[500]:"match"===t?e.v2.colors.white[500]:e.v2.colors.silver[200]};
100
- word-break: break-all;
101
- white-space: pre-wrap;
102
- user-select: text;
103
- `,Ba=({isOpen:a,regex:r,onClose:l,initialTestString:n=""})=>{const[i,s]=d(n),c=o(()=>((e,t)=>{if(!e)return{ok:!0,isMatch:!1,message:P.RESULT_EMPTY_REGEX};if(!t)return{ok:!0,isMatch:!1,message:P.RESULT_EMPTY_INPUT};let a;try{a=new RegExp(e)}catch(e){return{ok:!1,message:e instanceof Error?e.message:P.RESULT_INVALID_REGEX_FALLBACK}}const r=a.exec(t);return r?{ok:!0,isMatch:!0,message:r.length>1?r[1]:r[0]}:{ok:!0,isMatch:!1,message:P.RESULT_NO_MATCH}})(r,i),[r,i]),u=c.ok?c.isMatch?"match":"neutral":"error";return e(A,{isOpen:a,header:{title:P.TITLE,onClose:()=>{s(""),l()}},children:e(Xa,{children:t(_a,{children:[t(O,{$gap:6,children:[e(L,{label:P.REGEX_LABEL}),e(La,{pattern:r,"data-id":"regex-tester-regex"}),!r&&e(E,{size:N.XXS,color:I.Secondary,children:P.REGEX_EMPTY_HINT})]}),t(O,{$gap:6,children:[t(R,{$width:"100%",$justifyContent:"space-between",$alignItems:"center",children:[e(L,{label:P.TEST_STRING_LABEL}),e(V,{"data-id":"regex-tester-unescape",label:P.UNESCAPE_LABEL,tooltip:P.UNESCAPE_TOOLTIP,variant:D.Secondary,size:z.S,onClick:()=>s(e=>(e=>{let t="";for(let a=0;a<e.length;a++){if("\\"===e[a]&&a+1<e.length){const r=e[a+1],l="n"===r?"\n":"t"===r?"\t":"r"===r?"\r":'"'===r?'"':"'"===r?"'":"\\"===r?"\\":null;if(null!=l){t+=l,a++;continue}}t+=e[a]}return t})(e)),disabled:(p=i,!/\\["'\\nrt]/.test(p))})]}),e(Da,{name:"regex-tester-test-string","data-id":"regex-tester-test-string",placeholder:P.TEST_STRING_PLACEHOLDER,regex:r,value:i,onChange:s,minHeight:240}),e(X,{helpMessage:P.TEST_STRING_HELP})]}),t(O,{$gap:8,children:[e(L,{label:P.RESULT_LABEL}),e(Ha,{$tone:u,"data-id":"regex-tester-result",children:c.message}),c.ok&&c.isMatch&&e(E,{size:N.XXS,color:I.Secondary,children:P.RESULT_CAPTURE_HINT})]})]})})});var p},ja=r.div`
104
- display: grid;
105
- grid-template-rows: ${({$open:e})=>e?"1fr":"0fr"};
106
- opacity: ${({$open:e})=>e?1:0};
107
- margin-bottom: ${({$open:e,$gapCancelPx:t})=>e?"0":`-${t}px`};
108
- transition:
109
- grid-template-rows ${220}ms ease,
110
- opacity ${220}ms ease ${({$open:e,$delayInMs:t})=>e?`${t}ms`:"0ms"},
111
- margin-bottom ${220}ms ease;
112
- pointer-events: ${({$open:e})=>e?"auto":"none"};
113
-
114
- > .animated-collapse-inner {
115
- overflow: hidden;
116
- min-height: 0;
117
- }
118
- `,qa=({open:t,children:a,delayInMs:r=0,gapCancelPx:l=0})=>e(ja,{$open:t,$delayInMs:r,$gapCancelPx:l,"aria-hidden":!t,children:e("div",{className:"animated-collapse-inner",children:a})}),Ua=r.div`
119
- box-sizing: border-box;
120
- min-width: 109px;
121
- max-width: 160px;
122
- padding: 12px;
123
- border-radius: 8px;
124
- display: flex;
125
- flex-direction: column;
126
- gap: 8px;
127
- background-color: ${({theme:e})=>e.v2.colors.silver[1e3]};
128
- border: 1px
129
- ${({theme:e,$isRoot:t,$isVirtual:a})=>t?`solid ${e.v2.colors.purple[400]}`:a?`dashed ${e.v2.colors.silver[300]}`:`solid ${e.v2.colors.silver[200]}`};
130
- opacity: ${({$isVirtual:e,$isRoot:t})=>e&&!t?.85:1};
131
- `,Ga=r.div`
132
- display: flex;
133
- align-items: center;
134
- gap: 4px;
135
- min-width: 0;
136
- `,Ka=r.div`
137
- flex-shrink: 0;
138
- width: 16px;
139
- height: 16px;
140
- display: flex;
141
- align-items: center;
142
- justify-content: center;
143
- `,Wa={visibility:"hidden"},Fa=u(({data:r})=>{const l=n(),{service:i,namespace:o,isVirtual:s,isRoot:c,isAttacker:d,isUser:u}=r,p=((e,t)=>"user"===e?Ut:t?Gt:Kt)(i,s),h=c?l.v2.colors.purple[400]:l.v2.colors.silver[200],g=c?I.Link:I.Secondary,m=o?`${o}/${i}`:i,b=s?"virtual":"-";return t(a,{children:[e(v,d||u?{type:"source",position:f.Bottom,style:Wa}:{type:"source",position:f.Top,style:Wa}),e(v,d||u?{type:"target",position:f.Right,style:Wa}:{type:"target",position:f.Left,style:Wa}),t(Ua,{$isRoot:c,$isVirtual:s,children:[t(Ga,{children:[e(Ka,{children:e(p,{size:16,fill:h})}),e(E,{size:N.XXXS,color:g,nowrap:!0,children:m})]}),e(E,{size:N.XXXS,color:g,nowrap:!0,children:b})]})]})});Fa.displayName=Fa.name;const Ya="0;0.5;1",Ja=u(({id:r,sourceX:l,sourceY:i,targetX:s,targetY:c,sourcePosition:d,targetPosition:u,markerEnd:p,style:h,data:g})=>{const m=n(),[v]=b({sourceX:l,sourceY:i,targetX:s,targetY:c,sourcePosition:d,targetPosition:u}),f=`${r}__blast-radius-motion`,$=!!g?.isAttacker,C="string"==typeof h?.stroke?h.stroke:$?m.v2.colors.red[500]:m.v2.colors.silver[400],k=$?m.v2.colors.red[700]:m.v2.colors.silver[600],w=$?m.v2.colors.red[400]:m.v2.colors.silver[200],{travelDuration:S,ballCount:T}=o(()=>{const e=Math.hypot(s-l,c-i),t=((e,t)=>{if("undefined"==typeof document)return t;const a=document.createElementNS("http://www.w3.org/2000/svg","path");return a.setAttribute("d",e),a.getTotalLength()||t})(v,e);return{travelDuration:Math.max(1.2,t/100),ballCount:Math.min(10,Math.max(3,Math.round(t/72)))}},[v,l,i,s,c]),M=`${S.toFixed(3)}s`;return t(a,{children:[e(y,{id:r,path:v,markerEnd:p,style:{...h,stroke:C,strokeWidth:1}}),e(x,{children:t("svg",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},children:[e("path",{id:f,d:v,fill:"none",stroke:"none"}),Array.from({length:T}).map((a,r)=>{const l=`-${(S/T*r).toFixed(3)}s`;return t("circle",{r:0,fill:k,children:[e("animateMotion",{dur:M,begin:l,repeatCount:"indefinite",children:e("mpath",{href:`#${f}`})}),e("animate",{attributeName:"r",dur:M,begin:l,repeatCount:"indefinite",keyTimes:Ya,values:"0;3.5;3.5"}),e("animate",{attributeName:"fill",dur:M,begin:l,repeatCount:"indefinite",keyTimes:Ya,values:`${k};${w};${w}`})]},r)})]})})]})});var Za,Qa;Ja.displayName=Ja.name,(e=>{e.Service="blast-radius-service"})(Za||(Za={})),(e=>{e.Animated="blast-radius-animated"})(Qa||(Qa={}));const er=(e,t)=>{const a=(e||"").trim();return a?`${a}/${t}`:t},tr=e=>er(e.namespace,e.service),ar="user",rr=(e,t,a)=>{const r=new Set(e),l=[...e];for(;l.length;){const e=l.shift();for(const n of a.get(e)??[])n===t||r.has(n)||(r.add(n),l.push(n))}return r},lr=(e,t,a)=>{const r=new Map;if(!e.length)return r;const l=[];for(let t=0;t<e.length;t+=6)l.push(e.slice(t,t+6));const n=-72*(l.length-1)/2;return l.forEach((e,l)=>{const i=n+72*l;e.forEach((e,l)=>{const n=t+a*(l+1)*160;r.set(e,{x:n,y:i})})}),r},nr=(e,t,a)=>{const r=t.map(e=>a.get(e)).filter(e=>!!e);if(!r.length)return{x:0,y:72};const l={x:r.reduce((e,t)=>e+t.x,0)/r.length,y:r.reduce((e,t)=>e+t.y,0)/r.length+72},n=new Set([...a.entries()].filter(([t])=>t!==e).map(([,e])=>`${e.x},${e.y}`));let i=l;for(;n.has(`${i.x},${i.y}`);)i={x:i.x,y:i.y+72};return i},ir=r.div`
144
- position: relative;
145
- width: 100%;
146
- height: 286px;
147
- border-radius: 8px;
148
- overflow: hidden;
149
- background-color: ${({theme:e})=>e.v2.colors.silver[1e3]};
150
-
151
- .react-flow__attribution {
152
- visibility: hidden;
153
- }
154
-
155
- * {
156
- transition: none;
157
- }
158
- `,or={[Za.Service]:Fa},sr={[Qa.Animated]:Ja},cr={duration:300,padding:.2,includeHiddenNodes:!0,maxZoom:1},dr=({trigger:e})=>{const{fitView:t}=M(),a=s(!0);return p(()=>{a.current?a.current=!1:e>0&&requestAnimationFrame(()=>t(cr))},[e,t]),null},ur=({subgraph:a})=>{const r=n(),[l,i,s]=k([]),[c,u,h]=w([]),[g,m]=d(0),[v,f]=d(null),b=o(()=>{const e=a.nodes.map(e=>`${e.namespace||""}/${e.service}:${e.isVirtual?1:0}`).join("|"),t=a.edges.map(e=>`${e.clientNamespace||""}/${e.clientService}->${e.serverNamespace||""}/${e.serverService}`).join("|");return`${(e=>`${e.root.namespace||""}/${e.root.service}`)(a)}::${e}::${t}`},[a]);p(()=>{const e=((e,t)=>{const a=t.find(t=>t.service===ar&&t.id!==e);return a?.id??null})(tr(a.root),a.nodes.map(e=>({id:tr(e),service:e.service}))),t=((e,t)=>{const a=tr(e.root);return e.nodes.map(e=>{const r=tr(e);return{id:r,type:Za.Service,position:{x:0,y:0},data:{service:e.service,namespace:e.namespace||"",isVirtual:e.isVirtual,isRoot:r===a,isAttacker:r===t,isUser:e.service===ar},measured:{width:120,height:58}}})})(a,e),l=new Set(t.map(e=>e.id)),n=((e,t,a,r)=>{const l=t.v2.colors.silver[400],n=t.v2.colors.red[500],i=tr(e.root);return e.edges.flatMap(e=>{const t=(e=>er(e.clientNamespace,e.clientService))(e),o=(e=>er(e.serverNamespace,e.serverService))(e);if(!a.has(t)||!a.has(o))return[];const s=!!r&&(t===r&&o===i||t===i&&o===r),c=s?n:l;return[{id:`${t}->${o}`,type:"smoothstep",source:t,target:o,data:{isAttacker:s},markerEnd:{type:$.ArrowClosed,color:c,width:16,height:16},style:{stroke:c,strokeWidth:1}}]})})(a,r,l,e),o=((e,t)=>{if(!e.length)return{nodes:e,edges:t};const a=(e.find(e=>e.data.isRoot)??e[0]).id,r=e.find(e=>e.data.isAttacker)?.id??null,l=new Map,n=new Map,i=new Map;for(const t of e)l.set(t.id,[]),n.set(t.id,[]),i.set(t.id,[]);for(const e of t)l.get(e.source)?.push(e.target),n.get(e.target)?.push(e.source),i.get(e.source)?.push(e.target),i.get(e.target)?.push(e.source);const o=rr((n.get(a)??[]).filter(e=>e!==r),a,i),s=rr((l.get(a)??[]).filter(e=>e!==r&&!o.has(e)),a,i);r&&(o.delete(r),s.delete(r));const c=((e,t)=>{const a=new Map([[e,0]]),r=[e];for(;r.length;){const e=r.shift(),l=(a.get(e)??0)+1;for(const n of t.get(e)??[])a.has(n)||(a.set(n,l),r.push(n))}return a})(a,i),d=[...o].sort((e,t)=>{const a=(c.get(t)??0)-(c.get(e)??0);return 0!==a?a:e.localeCompare(t)}),u=[...s].filter(e=>!o.has(e)).sort((e,t)=>{const a=(c.get(e)??0)-(c.get(t)??0);return 0!==a?a:e.localeCompare(t)});for(const t of e)t.id===a||t.id===r||o.has(t.id)||s.has(t.id)||d.push(t.id);const p=new Map([[a,{x:0,y:0}]]);for(const[e,t]of lr(d,0,-1))p.set(e,t);for(const[e,t]of lr(u,0,1))p.set(e,t);return r&&p.set(r,nr(r,i.get(r)??[],p)),{nodes:e.map(e=>({...e,position:p.get(e.id)??e.position})),edges:t}})(t,n);i(o.nodes),u(o.edges),f(null),m(e=>e+1)},[b,a,r,i,u]);const y=o(()=>v?c.map(e=>{if(e.source===v||e.target===v)return{...e,type:Qa.Animated};const t={opacity:.3};return{...e,style:{...e.style,...t},labelStyle:{...e.labelStyle,...t},labelBgStyle:{...e.labelBgStyle,...t}}}):c,[c,v]);return e(ir,{children:t(S,{nodes:l,edges:y,nodeTypes:or,edgeTypes:sr,onNodesChange:s,onEdgesChange:h,onNodeMouseEnter:(e,t)=>f(t.id),onNodeMouseLeave:()=>f(null),nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnDrag:!0,zoomOnScroll:!0,minZoom:.4,maxZoom:1.5,proOptions:{hideAttribution:!0},children:[e(T,{color:r.v2.colors.silver[600],gap:17,size:1}),e(dr,{trigger:g})]})})},pr=({blastRadius:t})=>t?.nodes?.length?e(C,{children:e(ur,{subgraph:t})}):e(_,{children:e(H,{subTitle:"No blast-radius neighborhood for this service yet."})}),hr=({isOpen:t,onClose:a,onDeny:r,onApprove:l})=>e(B,{title:"Discard changes?",description:"You have unsaved changes.\nIf you cancel now, your changes won't be saved.",isOpen:t,onClose:a,denyButton:{label:"Keep editing",variant:D.Secondary,onClick:()=>{r?.(),a()}},approveButton:{label:"Discard changes",variant:D.Primary,onClick:()=>{l?.(),a()}}}),gr=r.div`
159
- display: flex;
160
- flex-direction: column;
161
- gap: 12px;
162
- width: 70vw;
163
- height: 70vh;
164
- padding: 12px;
165
- overflow: auto;
166
- `,mr=r.div`
167
- display: flex;
168
- align-items: center;
169
- justify-content: space-between;
170
- width: 100%;
171
- `,vr=({isOpen:a,onClose:r,language:l,code:n,...i})=>{const{CopyButton:o}=j();return e(q,{isOpen:a,onClose:r,children:t(gr,{children:[t(mr,{children:[e(E,{size:N.XS,children:"JSON view"}),e(U,{icon:t=>e(Wt,{...t}),size:G.L,onClick:r})]}),l&&n?e(K,{fullHeight:!0,overflow:"auto",children:t(R,{$width:"100%",$alignItems:"flex-start",$justifyContent:"space-between",children:[e(W,{language:l,code:n,...i}),e(o,{value:n})]})}):e(H,{})]})})},fr=({isOpen:t,onClose:a,onViewConnector:r})=>e(B,{isOpen:t,onClose:a,visual:()=>e(J,{scale:1.2,icon:Ft}),title:Y.CLOUD_CONNECTOR_CREATED_MODAL_TITLE,description:Y.CLOUD_CONNECTOR_CREATED_MODAL_DESC,denyButton:{label:F.STAY_ON_CONNECTIONS,variant:D.Secondary,onClick:a},approveButton:{label:F.GO_TO_CONNECTOR_OVERVIEW,variant:D.Primary,onClick:r??a}}),br=({isOpen:t,onClose:a,onDeny:r,onApprove:l,action:n="delete",target:i,description:o,overrideApproveButtonLabel:s,overrideDenyButtonLabel:c})=>{const d=n.charAt(0).toUpperCase()+n.substring(1),u=i?.endsWith("s")?"these":"this";return e(B,{title:`${d}${i?` ${i}`:""}?`,description:o??`Are you sure you want to ${n}${i?` ${u} ${i}`:""}?`,isOpen:t,onClose:a,denyButton:{label:c??"Go back",variant:D.Secondary,onClick:()=>{r?.(),a()}},approveButton:{label:s??d,variant:D.Primary,onClick:()=>{l?.(),a()}}})},yr=({componentType:t,inputType:a,name:r,label:l,tooltip:n,badge:i,placeholder:o,required:s,disabled:c,value:d,setValue:u,errorMessage:p,warnMessage:h,helpMessage:g,dropdownOptions:m,dropdownNoSearch:v,dropdownNoCheckbox:f,timeUnits:b,timeDefaultUnit:y,toggleSize:x=te.L,keyLabel:$,valueLabel:C})=>{switch(t){case Z.Input:return e(ce,{name:r,type:a,label:l,tooltip:n,badge:i,placeholder:o,required:s,disabled:c,value:d??"",onChange:e=>{const t=e.target.value;u(a===de.Number?""===t?null:Number(t):t)},errorMessage:p,warnMessage:h,helpMessage:g},r);case Z.MultiInput:return e(se,{name:r,label:l,tooltip:n,badge:i,placeholder:o,required:s,disabled:c,values:Array.isArray(d)?d:oe(d,[]),setValues:e=>u(e),errorMessage:p,warnMessage:h,helpMessage:g,plain:!0},r);case Z.KeyValuePair:return e(ie,{name:r,label:l,tooltip:n,badge:i,required:s,disabled:c,limitFieldsPerRow:2,columns:[{keyName:"key",label:$||"Key",placeholder:$||"Key"},{keyName:"value",label:C||"Value",placeholder:C||"Value"}],values:Array.isArray(d)?d:oe(d,[]),setValues:e=>u(e),errorMessage:p,warnMessage:h,helpMessage:g},r);case Z.TextArea:return e(ne,{name:r,label:l,tooltip:n,badge:i,required:s,disabled:c,placeholder:o,value:d??"",onChange:e=>u(e.target.value),errorMessage:p,warnMessage:h,helpMessage:g},r);case Z.Dropdown:return e(le,{name:r,label:l,tooltip:n,badge:i,placeholder:o,required:s,disabled:c,withSearch:!v,options:m?.map(e=>({id:e.id||"",label:e.label||"",withCheckbox:!f}))||[],values:d?[String(d)]:[],setValues:e=>u(e[0]),errorMessage:p,warnMessage:h,helpMessage:g},r);case Z.Checkbox:return e(re,{name:r,label:l,tooltip:n,badge:i,value:!0===d||"true"===d,onChange:e=>u(e),disabled:c,errorMessage:p,warnMessage:h,helpMessage:g},r);case Z.Time:return e(ae,{name:r,label:l,tooltip:n,badge:i,placeholder:o,required:s,disabled:c,value:d??"",setValue:e=>u(e),units:b,defaultUnit:y,errorMessage:p,warnMessage:h,helpMessage:g},r);case Z.Toggle:return e(Q,{name:r,size:x,labelAlign:ee.Right,label:l,tooltip:n,badge:i,value:!0===d||"true"===d,onChange:e=>u(e),disabled:c,errorMessage:p,warnMessage:h,helpMessage:g},r);default:return null}},xr=r.div`
172
- display: flex;
173
- flex-wrap: wrap;
174
- gap: 8px;
175
- `,$r=r.div`
176
- display: flex;
177
- align-items: center;
178
- gap: 8px;
179
- padding: 8px 12px;
180
- border-radius: 8px;
181
- cursor: pointer;
182
- background: ${({theme:e,$selected:t})=>t?e.v2.colors.silver[700]:e.v2.colors.silver[800]};
183
- border: 1px solid ${({theme:e,$selected:t})=>t?e.v2.colors.silver[500]:e.v2.colors.silver[750]};
184
-
185
- &:hover {
186
- background: ${({theme:e})=>e.v2.colors.silver[700]};
187
- }
188
- `,Cr=r.div`
189
- display: flex;
190
- width: 32px;
191
- height: 32px;
192
- justify-content: center;
193
- align-items: center;
194
- flex-shrink: 0;
195
- `,kr=r.div`
196
- display: flex;
197
- flex-direction: column;
198
- gap: 12px;
199
- `,wr=r.div`
200
- display: flex;
201
- flex-wrap: wrap;
202
- gap: 6px;
203
- `,Sr=r.div`
204
- display: flex;
205
- align-items: center;
206
- gap: 8px;
207
- &::before,
208
- &::after {
209
- content: '';
210
- flex: 1;
211
- height: 1px;
212
- background-color: ${({theme:e})=>e.v2.colors.silver[700]};
213
- }
214
- `,Tr=r.div`
215
- padding: 2px 10px;
216
- border-radius: 999px;
217
- background-color: ${({theme:e})=>e.v2.colors.silver[700]};
218
- border: 1px solid ${({theme:e})=>e.v2.colors.silver[600]};
219
- `,Mr={[xe.JavaScript]:"Node.js",[xe.DotNet]:".NET",[xe.Php]:"PHP",[xe.Java]:"Java",[xe.Go]:"Go",[xe.Python]:"Python",[xe.Ruby]:"Ruby",[xe.Rust]:"Rust"},Ar=[xe.Python,xe.Java,xe.JavaScript,xe.DotNet,xe.Php,xe.Ruby,xe.Go],Pr=[{value:"all",label:"Entire Cluster"},{value:"source",label:"Specific Source"},{value:"namespace",label:"Specific Namespace"},{value:"language",label:"Specific Programming Language"}];function Or(e){return Mr[e]||e.charAt(0).toUpperCase()+e.slice(1)}function Lr(e){return null!=e?`${e}. ${Oe}`:Oe}const Er=({readOnly:t,...a})=>e(t?Rr:zr,{...a}),Ir=({title:a,count:r,children:l})=>t(O,{$gap:6,children:[t(R,{$gap:8,$alignItems:"center",children:[e(E,{size:N.XS,color:I.Primary,nowrap:!0,children:a}),r>1&&e(E,{size:N.XXS,color:I.Secondary,nowrap:!0,children:`(${Ae})`})]}),e(wr,{children:l})]}),Nr=()=>{const t=n();return e(Sr,{children:e(Tr,{children:e(E,{size:N.XXS,color:t.v2.colors.white[500],nowrap:!0,children:Pe})})})},Rr=({scopes:a,titleNumber:r,title:l,subTitle:n,icon:o,bgTint:s="900",entireClusterWarningMessage:c})=>{const d=l??Lr(r),u={icon:o,title:d,subTitle:n,alignItems:n||o?"flex-start":void 0};if(ua(a))return e(K,{bgTint:s,richTitle:u,withCollapse:!0,collapseIsDefaultOpen:!0,children:t(O,{$gap:8,children:[e(ue,{status:he.Default,message:pe,fullWidth:!0}),c&&e(ue,{status:he.Warning,message:c,fullWidth:!0,smallIcon:!0})]})});const p=a.sources??[],h=a.namespaces??[],g=a.languages??[],m=[];p.length&&m.push({kind:"sources",node:e(Ir,{title:ge,count:p.length,children:p.map((t,a)=>{const r=[t.namespace,t.kind,t.name].filter(Boolean),l=r.length?r.join(" / "):ve;return e(me,{label:l},`src-${a}-${l}`)})})}),h.length&&m.push({kind:"namespaces",node:e(Ir,{title:fe,count:h.length,children:h.map((t,a)=>e(me,{label:t},`ns-${a}-${t}`))})}),g.length&&m.push({kind:"languages",node:e(Ir,{title:be,count:g.length,children:g.map((t,a)=>{const r=$e(t);return e(me,{label:Or(t),leftIcon:r},`lang-${a}-${t}`)})})});const v=n??(m.length>1?ye:void 0);return e(K,{bgTint:s,richTitle:{icon:o,title:d,subTitle:v,alignItems:v||o?"flex-start":void 0},withCollapse:!0,collapseIsDefaultOpen:!0,children:e(K,{bgTint:"800",children:e(kr,{children:m.map((a,r)=>t(i.Fragment,{children:[r>0&&e(Nr,{}),a.node]},a.kind))})})})},Vr=(e,t="all")=>e.sources.length>0?"source":e.namespaces.length>0?"namespace":e.languages.length>0?"language":t,zr=({scopes:r,onChange:l,sourceOptions:n=[],namespaceOptions:i=[],supportedLanguages:s,titleNumber:u,title:h,subTitle:g,icon:m,dataIdPrefix:v="source-scope",slim:f,disabled:b,hideLogicNote:y,hideEntireClusterNote:x,entireClusterWarningMessage:$,defaultScopeTab:C="all"})=>{const k=r??pa(),[w,S]=d(()=>Vr(k,C)),{sources:T,namespaces:M,languages:A}=k,P=T.length>0||M.length>0||A.length>0;p(()=>{P&&"all"===w&&S(Vr(k,C))},[C,P,w,k]);const L=o(()=>Pr.map(e=>"language"===e.value&&0===s?.length?null:{...e,disabled:"all"===e.value&&P}).filter(Boolean),[P]),R=o(()=>T.map(e=>`${e.namespace}/${e.kind}/${e.name}`),[T]),V=o(()=>[...M],[M]),z=o(()=>new Set(A),[A]),D=c(e=>{S(e)},[]),X=c(e=>{const t=e.map(e=>(e=>{const t=e.split("/");return 3!==t.length?null:{namespace:t[0],kind:t[1],name:t[2]}})(e)).filter(e=>null!=e).map(e=>({namespace:e.namespace,kind:e.kind,name:e.name}));l({...k,sources:t})},[k,l]),_=c(e=>{l({...k,namespaces:e})},[k,l]),H=c(e=>{const t=k.languages,a=t.includes(e)?t.filter(t=>t!==e):[...t,e];l({...k,languages:a})},[k,l]),B=!P&&"all"===w,j=(s||Ar).map(e=>({id:e,label:Mr[e]??e.charAt(0).toUpperCase()+e.slice(1),Icon:$e(e)})),q=h??Lr(u),U=g??ke;return e(Ce,{richTitle:f?{icon:m,title:q,titleSize:N.XS,titleColor:I.Secondary,tooltip:U,alignItems:m?"flex-start":void 0}:{icon:m,title:q,subTitle:U,subTitleWrap:!0,alignItems:m||U?"flex-start":void 0},backgroundColor:f?"transparent":void 0,padding:f?0:void 0,children:t(O,{$gap:16,children:[B?t(a,{children:[!x&&e(ue,{status:he.Default,message:pe,fullWidth:!0,smallIcon:!0}),$&&e(ue,{status:he.Warning,message:$,fullWidth:!0,smallIcon:!0})]}):!y&&e(ue,{status:he.Info,message:ye,fullWidth:!0,smallIcon:!0}),e(O,{$alignItems:"flex-start",children:e(we,{options:L,selected:w,setSelected:D,disabled:b})}),"source"===w&&e(Se,{multiple:!0,"data-id":`${v}-autocomplete-source`,options:n,value:R,onSelect:X,placeholder:Te,disabled:b}),"namespace"===w&&e(Se,{multiple:!0,"data-id":`${v}-autocomplete-namespace`,options:i,value:V,onSelect:_,placeholder:"Search namespace",disabled:b}),"language"===w&&j.length>0&&e(xr,{children:j.map(({id:a,label:r,Icon:l})=>{const n=z.has(a);return t($r,{$selected:n,onClick:()=>H(a),children:[e(re,{name:`${v}-lang-${a}`,size:Me.S,value:n,onChange:()=>H(a),disabled:b}),e(Cr,{children:e(l,{size:20})}),e(E,{size:N.XS,nowrap:!0,children:r})]},a)})})]})})},Dr=e=>{if(null!=e){if(!Array.isArray(e)&&"object"==typeof e)return Object.entries(e).map(([e,t])=>({id:e,label:null==t?e:String(t)}));if(Array.isArray(e))return e.map(e=>"string"==typeof e?{id:e,label:e}:e)}},Xr=e=>{if(!Array.isArray(e)||e.length<3)return;const[t,a,r]=e;return e=>{const l=null==e?.[t]?"":String(e[t]);switch(a){case"=":case"==":case"===":return l===r;case"!=":case"!==":return l!==r;default:return!0}}},_r=e=>{if(Array.isArray(e))return e.map(e=>{const t=e;return{keyName:String(t.keyName??t.name??""),label:t.label??t.displayName,tooltip:t.tooltip,placeholder:t.placeholder,helpMessage:t.helpMessage,componentType:t.componentType,options:Dr(t.options??t.values),fullRow:t.fullRow,defaultValue:t.defaultValue,withRegexTester:t.withRegexTester,separator:t.separator,copyByColumn:t.copyByColumn,renderCondition:Xr(t.renderCondition)}})},Hr=e=>{if(Array.isArray(e))return e.map(e=>{if("string"==typeof e)return{id:e,label:e};const t=e;return{id:String(t.id??t.keyName??t.name??""),label:t.label??t.displayName??String(t.id??""),tooltip:t.tooltip,fields:Array.isArray(t.fields)?t.fields.map(Br):void 0}})},Br=e=>{const t="string"==typeof e.componentProperties?oe(e.componentProperties,{}):e.componentProps||{};return{name:e.name,componentType:e.componentType,inputType:e.inputType??t.inputType??t.type,title:e.displayName,tooltip:t.tooltip,placeholder:t.placeholder,helpMessage:t.helpMessage,required:t.required,initialValue:e.initialValue,renderCondition:e.renderCondition,options:Dr(t.options??t.values),itemWrapperKey:t.itemWrapperKey,columns:_r(t.columns),limitFieldsPerRow:t.limitFieldsPerRow,variant:t.variant,wrapKey:t.wrapKey,checkboxOptions:Hr(t.options??t.values),checkedValue:t.checkedValue??"true",valueMode:t.valueMode??"object",fields:Array.isArray(t.fields)?t.fields.map(Br):void 0,addLabel:t.addLabel,itemLabel:t.itemLabel,keyLabel:t.titleKey??t.keyLabel,valueLabel:t.titleValue??t.valueLabel,persistAs:t.persistAs}},jr=e=>{const t=e.initialValue;if(void 0!==t&&""!==t)return e.componentType===Z.CheckboxList?"array"===e.valueMode?oe(t,[]):oe(t,{}):e.componentType!==Z.MultiInput&&e.componentType!==Z.MultiTabledInput||!e.wrapKey?e.componentType===Z.MultiInput||e.componentType===Z.MultiTabledInput?oe(t,[]):e.componentType===Z.SourceScopes?"null"===t||"{}"===t?pa():ga(oe(t,null)):e.componentType===Z.Toggle||e.componentType===Z.Checkbox?"true"===t:t:{[e.wrapKey]:oe(t,[])}},qr=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),Ur=e=>Array.isArray(e)?e:[],Gr=e=>{const t={};return e.forEach(e=>{t[String(e.key??"")]=String(e.value??"")}),t},Kr=e=>qr(e)?Object.entries(e).map(([e,t])=>({key:e,value:String(t??"")})):[],Wr=({field:t,value:a,setValue:r,errorMessage:l,disabled:n})=>{const[i,o]=d(()=>Kr(a));return p(()=>{const e=qr(a)?a:{};((e,t)=>{const a=Object.keys(e),r=Object.keys(t);return a.length===r.length&&a.every(a=>Object.prototype.hasOwnProperty.call(t,a)&&t[a]===e[a])})(Gr(i),e)||o(Kr(a))},[a]),e(ie,{name:t.name,label:t.title,tooltip:t.tooltip,helpMessage:t.helpMessage,required:t.required,disabled:n,limitFieldsPerRow:2,columns:[{keyName:"key",label:t.keyLabel||"Key",placeholder:t.keyLabel||"Key"},{keyName:"value",label:t.valueLabel||"Value",placeholder:t.valueLabel||"Value"}],values:i,setValues:e=>{o(e),r(Gr(e))},errorMessage:l})},Fr=({field:r,value:l,setValue:n,errorMessage:i,disabled:o,keyValuePersistAs:s,sourceOptions:c,namespaceOptions:u})=>{const{name:p,componentType:h,inputType:g,title:m,tooltip:v,placeholder:f,helpMessage:b,required:y,initialValue:x,options:$,itemWrapperKey:C,columns:k,limitFieldsPerRow:w,variant:S,wrapKey:T,checkboxOptions:M}=r,[A,P]=d({open:!1,value:""});if(h===Z.SourceScopes)return e(Er,{scopes:ga(l),onChange:e=>n(e),sourceOptions:c,namespaceOptions:u,dataIdPrefix:`dynamic-field-${p}`,slim:!0});if(h===Z.CheckboxList&&"array"===r.valueMode){const a=Ur(l),r=(e,t)=>n(t?[...a.filter(t=>t!==e),e]:a.filter(t=>t!==e));return t(O,{$gap:12,children:[m&&e(L,{label:m,tooltip:v,required:y}),e(O,{$gap:8,children:(M||[]).map(t=>{const l=e(re,{name:t.id,label:t.label,value:a.includes(t.id),disabled:o,onChange:e=>r(t.id,e)},t.id);return t.tooltip?e(Ie,{text:t.tooltip,withIcon:!0,children:l},t.id):l})}),e(X,{errorMessage:i,helpMessage:b})]})}if(h===Z.CheckboxList){const a=qr(l)?l:{},c=(e=>"emptyObject"!==e.checkedValue||{})(r),d=e=>"emptyObject"===r.checkedValue?qr(e):!!e;return t(O,{$gap:12,children:[m&&e(E,{size:N.XS,color:I.Secondary,nowrap:!0,children:m}),e(O,{$gap:12,children:(M||[]).map(r=>{const l=a[r.id],i=d(l),u=qr(l)?l:{},h=e(re,{label:r.label,value:i,disabled:o,onChange:e=>n({...a,[r.id]:e?qr(l)?l:c:null})}),g=r.tooltip?e(Ie,{text:r.tooltip,withIcon:!0,children:h}):h,m=i&&r.fields?.length?e(O,{$gap:12,$padding:"0 0 0 24px",children:r.fields.map(t=>e(Fr,{field:t,value:u[t.name],setValue:e=>n({...a,[r.id]:{...u,[t.name]:e}}),disabled:o,keyValuePersistAs:s},`${p}-${r.id}-${t.name}`))}):null;return t(O,{$gap:12,children:[g,m]},r.id)})}),e(X,{errorMessage:i,helpMessage:b})]})}if(h===Z.MultiTabledInput){const r=Ur(T?l?.[T]:l),s=e=>n(T?{...qr(l)?l:{},[T]:e}:e),c=(k||[]).some(e=>e.withRegexTester);return t(a,{children:[e("cards"===S?Ne:ie,{name:p,label:m,tooltip:v,helpMessage:b,required:y,disabled:o,columns:k||[],limitFieldsPerRow:w,values:r,setValues:s,errorMessage:i,onTestRegex:c?e=>P({open:!0,value:e}):void 0}),c&&e(Ba,{isOpen:A.open,regex:A.value,onClose:()=>P({open:!1,value:""})})]})}if(h===Z.MultiInput&&T){const t=Ur(l?.[T]);return e(se,{name:p,label:m,tooltip:v,helpMessage:b,required:y,disabled:o,placeholder:f,values:t,setValues:e=>n({...qr(l)?l:{},[T]:e}),errorMessage:i})}if(h===Z.MultiInput&&C){const t=Ur(l).map(e=>String(e?.[C]??""));return e(se,{name:p,label:m,tooltip:v,helpMessage:b,required:y,disabled:o,placeholder:f,values:t,setValues:e=>n(e.map(e=>({[C]:e}))),errorMessage:i})}return h===Z.KeyValuePair?"map"===(r.persistAs??s)?e(Wr,{field:r,value:l,setValue:n,errorMessage:i,disabled:o}):e(yr,{componentType:h,name:p,label:m,tooltip:v,helpMessage:b,disabled:o,required:y,errorMessage:i,keyLabel:r.keyLabel,valueLabel:r.valueLabel,value:l??[],setValue:n}):e(yr,{componentType:h,inputType:g,name:p,label:m,tooltip:v,helpMessage:b,disabled:o,required:y,placeholder:f,errorMessage:i,dropdownOptions:$,value:(null==l?x:l)??"",setValue:n})},Yr=({field:r,value:l,setValue:i,disabled:o,keyValuePersistAs:s,sourceOptions:c,namespaceOptions:d})=>{const u=n(),p=Ur(l),g=p.length?p:[{}],m=r.fields||[],v=e=>i(e);return t(a,{children:[g.map((a,l)=>t(h,{children:[e(Ee,{}),t(O,{$gap:12,children:[t(R,{$justifyContent:"space-between",$alignItems:"center",children:[e(L,{label:`${r.itemLabel||r.title||"Item"} ${l+1}`}),e(V,{leftIcon:()=>e(Yt,{fill:u.v2.colors.red[500]}),variant:D.Secondary,size:z.S,onClick:()=>(e=>{const t=g.filter((t,a)=>a!==e);v(t)})(l),disabled:o||1===g.length})]}),m.map(t=>e(Fr,{field:t,value:a[t.name],setValue:e=>((e,t,a)=>v(g.map((r,l)=>l===e?{...r,[t]:a}:r)))(l,t.name,e),disabled:o,keyValuePersistAs:s,sourceOptions:c,namespaceOptions:d},`${r.name}-group-${l}-${t.name}`))]})]},`${r.name}-group-${l}`)),e(V,{variant:D.Secondary,label:r.addLabel||"Add",leftIcon:Jt,onClick:()=>v([...g,{}]),disabled:o}),e(Ee,{})]})},Jr=({field:a,value:r,setValue:l,errorMessage:n,disabled:i})=>t(O,{$gap:12,children:[a.title&&e(L,{label:a.title,tooltip:a.tooltip,required:a.required}),e(O,{$gap:8,children:(a.checkboxOptions||[]).map(t=>{const a=e(re,{name:t.id,label:t.label,value:!0===r?.[t.id],disabled:i,onChange:e=>l(t.id,e)},t.id);return t.tooltip?e(Ie,{text:t.tooltip,withIcon:!0,children:a},t.id):a})}),e(X,{errorMessage:n,helpMessage:a.helpMessage})]}),Zr=({signals:t,fields:r,value:l,setValue:n,formErrors:i,disabled:o,seedInitialValues:s,keyValuePersistAs:c="map",sourceOptions:d,namespaceOptions:u})=>{const{isK8s:h}=ha(),g=(r||[]).filter(e=>!!e).map(e=>Br(e));return p(()=>{if(!s)return;const e=l||{},t={};g.forEach(a=>{if(a.componentType===Z.SourceScopes&&!h)return;const r=a.componentType===Z.SourceScopes?jr(a)??pa():jr(a);if(void 0===r)return;if(a.componentType===Z.CheckboxList&&"flatFields"===a.valueMode&&qr(r))return void Object.entries(r).forEach(([a,r])=>{void 0!==e[a]&&null!==e[a]||(t[a]=r)});const l=e[a.name];if(a.componentType===Z.SourceScopes){if(void 0!==l)return}else if(null!=l)return;t[a.name]=qr(r)&&qr(t[a.name])?{...t[a.name],...r}:r}),Object.entries(t).forEach(([e,t])=>n(e,t))},[]),e(a,{children:g.map((a,r)=>{const s=Object.entries(l||{}).map(([e,t])=>({name:e,key:e,value:t}));if(a.renderCondition&&!Le(a.renderCondition,t,s))return null;if(a.componentType===Z.SourceScopes&&!h)return null;const p=l?.[a.name],g=`${a.name}-${r}`;if(a.componentType===Z.FieldGroup)return e(Yr,{field:a,value:p,setValue:e=>n(a.name,e),disabled:o,keyValuePersistAs:c,sourceOptions:d,namespaceOptions:u},g);if(a.componentType===Z.CheckboxList&&"flatFields"===a.valueMode){const t=a.checkboxOptions?.map(e=>i[e.id]).find(Boolean);return e(Jr,{field:a,value:l||{},setValue:n,errorMessage:t,disabled:o},g)}return e(Fr,{field:a,value:p,setValue:e=>n(a.name,e),errorMessage:i[a.name],disabled:o,keyValuePersistAs:c,sourceOptions:d,namespaceOptions:u},g)})})},Qr=Zr,el=({isEnabled:t,setIsEnabled:a,fieldDisabled:r})=>{const l=n();return e(we,{options:[{icon:Zt,label:"Enable",value:!0,selectedBgColor:l.v2.colors.green[1e3],selectedBorderColor:l.v2.colors.green[400],selectedTextColor:l.v2.colors.green[400]},{icon:Qt,label:"Disable",value:!1,selectedBgColor:l.v2.colors.red[1e3],selectedBorderColor:l.v2.colors.red[500],selectedTextColor:l.v2.colors.red[400]}],size:Re.S,selected:t,setSelected:a,disabled:r})},tl=r.div`
220
- display: flex;
221
- align-items: center;
222
- gap: 24px;
223
- padding: 8px 16px;
224
- border-radius: 12px;
225
- background-color: ${({theme:e})=>e.v2.colors.silver[800]};
226
- `,al=r.div`
227
- flex: 1;
228
- min-width: 0;
229
- white-space: pre;
230
- overflow-x: auto;
231
- `,rl=({title:a,summary:r,onEdit:l,renderAction:n})=>{const i=o(()=>{const e=[];return a&&(e.push({text:a,variant:ma.Default}),e.push({text:" - ",variant:ma.Default})),e.push(...r),e},[a,r]);return t(tl,{children:[e(al,{children:e(va,{parts:i})}),n&&n(),l&&e(V,{"data-id":"sampling-btn-edit-auto-rule",label:Ve,rightIcon:ea,variant:D.Text,size:z.S,onClick:l})]})},ll={[qe.HttpRequest]:"HTTP request",[qe.HttpResponse]:"HTTP response",[qe.DbQuery]:"DB query",[qe.Messaging]:"messaging"};function nl(e,t,a){return 1===e?t:a??`${t}s`}function il(e,t){const a=[],r=e.slice(0,3),l=e.slice(3);return r.forEach((e,r)=>{r>0&&a.push({text:", ",variant:ma.Default}),a.push({text:e,variant:t})}),l.length>0&&a.push({text:` + ${l.length} more`,variant:ma.Default,tooltipItems:l}),a}const ol=({option:t,formState:a,renderAction:r})=>{const l=o(()=>{const e=function(e,t){switch(e){case De.CodeAttributes:return(e=>{const t=Object.values(Ue).filter(t=>!!e.codeAttributes?.[t]).map(e=>Ge(e).toLowerCase());return t.length?[{text:"Collect",variant:ma.Action},{text:" ",variant:ma.Default},...il(t,ma.Endpoint)]:null})(t);case De.PayloadCollection:return(e=>{const t=Object.values(qe).filter(t=>null!=e.payloadCollection?.[t]).map(e=>ll[e]);return t.length?[{text:"Collect",variant:ma.Action},{text:" ",variant:ma.Default},...il(t,ma.Endpoint)]:null})(t);case De.HeadersCollection:return(e=>{const t=(e.headersCollection?.[je.HeaderKeys]??[]).map(e=>e.trim()).filter(e=>e.length>0);if(!t.length)return null;const a=nl(t.length,"HTTP header");return[{text:`Collect ${t.length} ${a}`,variant:ma.Action},{text:"",variant:ma.Default,tooltipItems:t}]})(t);case De.CustomInstrumentation:return(e=>{const t=(e.customInstrumentations?.[Xe.Java]??[]).map(e=>new _e(e.className,e.methodName)).filter(e=>e.Verify()),a=(e.customInstrumentations?.[Xe.Golang]??[]).map(e=>new He(e.packageName,e.functionName,e.receiverName,e.receiverMethodName)).filter(e=>e.Verify()),r=(e.customInstrumentations?.[Xe.Php]??[]).map(e=>new Be(e.className,e.functionName)).filter(e=>e.Verify());if(!(t.length+a.length+r.length))return null;const l=[];t.length&&l.push(`${t.length} Java ${nl(t.length,"probe")}`),a.length&&l.push(`${a.length} Go ${nl(a.length,"probe")}`),r.length&&l.push(`${r.length} PHP ${nl(r.length,"probe")}`);const n=[...t.map(e=>`Java: ${e.toString()}`),...a.map(e=>`Go: ${e.toString()}`),...r.map(e=>`PHP: ${e.toString()}`)];return[{text:`Apply ${l.join(" + ")}`,variant:ma.Action},{text:"",variant:ma.Default,tooltipItems:n}]})(t);case De.NetworkMetrics:return[{text:"Collect",variant:ma.Action},{text:" ",variant:ma.Default},{text:"network flow and TCP stats metrics",variant:ma.Endpoint}];default:return null}}(t?.type,a);return e?[...e,...fa(a.sourceScopes)]:[]},[t?.type,a]),n=0===l.length;return e(rl,{title:n?ze:"Instrumentation Rule Preview",summary:l,renderAction:r})},sl=({size:t=200,central:a=!1,useInline:r=!1})=>{const{tier:l}=ha();if(r){if(a)return e(ta,{size:t});switch(l){case Ke.Community:return e(ra,{size:t});case Ke.Onprem:return e(aa,{size:t});default:return null}}if(a)return e(la,{size:t});switch(l){case Ke.Community:return e(ia,{size:t});case Ke.Onprem:return e(na,{size:t});default:return null}},cl=[{value:"50",label:"50%"},{value:"25",label:"25%"},{value:"10",label:"10%"},{value:"1",label:"1%"},{value:"custom",label:"Custom"}],dl=[{value:"10",label:"10%"},{value:"1",label:"1%"},{value:"0.5",label:"0.5%"},{value:"0.1",label:"0.1%"},{value:"custom",label:"Custom"}],ul=[{value:"5000",label:"5s"},{value:"1000",label:"1s"},{value:"500",label:"500ms"},{value:"100",label:"100ms"},{value:"50",label:"50ms"},{value:"custom",label:"Custom"}],pl=({description:a,options:r,selected:l,onSelect:n,customName:i,customLabel:o,customPlaceholder:s,customValue:c,onCustomChange:d,customInputType:u=de.Number,customMin:p,customMax:h})=>t(O,{$gap:6,children:[e(L,{label:a}),t(R,{$gap:8,$alignItems:"flex-end",children:[e(we,{options:r,selected:l,setSelected:n}),"custom"===l&&e(ce,{name:i,label:o,placeholder:s,type:u,value:c,onChange:d,width:160,min:p,max:h})]})]}),hl=()=>{},gl=t=>t.readOnly?e(ml,{rule:t.rule}):e(vl,{ruleType:t.ruleType,formState:t.formState,onChange:t.onChange}),ml=({rule:a})=>{const r=null!=a.durationAtLeastMs;return a.error?e(Ce,{richTitle:{title:We},children:e(Q,{name:"sampling-view-toggle-keep-errors",onChange:hl,value:!0,size:te.S,label:Fe,labelAlign:ee.Right})}):r?e(Ce,{richTitle:{title:Ye},children:t("div",{children:[e(E,{size:N.XXXS,color:I.Secondary,children:Je}),e(E,{size:N.XS,children:`${a.durationAtLeastMs}ms`})]})}):null},vl=({ruleType:t,formState:a,onChange:r})=>{const l=c(e=>r({durationPreset:e}),[r]),n=c(e=>r({customDurationMs:e.target.value}),[r]);return"Duration"===t?e(Ce,{richTitle:{title:Ye,subTitle:Ze},children:e(pl,{description:Je,options:ul,selected:a.durationPreset,onSelect:l,customName:"sampling-input-custom-duration",customLabel:Qe,customPlaceholder:"200ms",customValue:a.customDurationMs,onCustomChange:n})}):null},fl=r.div`
232
- display: flex;
233
- gap: 32px;
234
- `,bl=r.div`
235
- display: flex;
236
- flex-direction: column;
237
- gap: 4px;
238
- `,yl=r.div`
239
- display: flex;
240
- flex-wrap: wrap;
241
- align-items: flex-end;
242
- gap: 16px;
243
- `,xl=r.div`
244
- display: flex;
245
- align-items: flex-end;
246
- gap: 16px;
247
- padding: 12px 16px;
248
- border-radius: 8px;
249
- background-color: ${({theme:e})=>e.v2.colors.black[500]};
250
- `,$l=r.div`
251
- display: flex;
252
- align-items: flex-end;
253
- gap: 10px;
254
- flex: 1;
255
- `,Cl=r.div`
256
- display: flex;
257
- align-items: center;
258
- height: 32px;
259
- `,kl=r.div`
260
- display: flex;
261
- align-items: flex-end;
262
- gap: 16px;
263
- margin-bottom: 12px;
264
- `,wl="Any",Sl="Kafka topic",Tl=()=>e("div",{style:{marginBottom:"8px"},children:e(E,{size:N.XS,weight:500,children:"And"})}),Ml=[{value:"all",label:"All Operations"},{value:"httpServer",label:"HTTP Server"},{value:"httpClient",label:"HTTP Client"}],Al=[{value:"all",label:"All Operations"},{value:"httpServer",label:"HTTP Server"},{value:"kafkaConsumer",label:"Kafka Consumer"},{value:"kafkaProducer",label:"Kafka Producer"}],Pl=[{id:"",label:wl},{id:"GET",label:"GET"},{id:"POST",label:"POST"},{id:"PUT",label:"PUT"},{id:"DELETE",label:"DELETE"},{id:"PATCH",label:"PATCH"}],Ol=t=>t.readOnly?e(Ll,{data:t.data}):e(El,{category:t.category,formState:t.formState,onChange:t.onChange}),Ll=({data:a})=>{const r=o(()=>(e=>{if("noisy"===e.category){const t=e.rule.operation;if(t?.httpServer)return[{id:"type",title:gt,value:ht},{id:"route",title:ot,value:t.httpServer.route||t.httpServer.routePrefix||mt},{id:"method",title:ut,value:t.httpServer.method||wl}];if(t?.httpClient){const e=[{id:"type",title:gt,value:vt}];return t.httpClient.serverAddress&&e.push({id:"serverAddress",title:"Server address",value:t.httpClient.serverAddress}),e.push({id:"route",title:ot,value:t.httpClient.templatedPath||t.httpClient.templatedPathPrefix||mt}),e.push({id:"method",title:ut,value:t.httpClient.method||wl}),e}return[{id:"type",title:gt,value:ft}]}const t=e.rule.operation;return t?.httpServer?[{id:"type",title:gt,value:ht},{id:"route",title:ot,value:t.httpServer.route||t.httpServer.routePrefix||mt},{id:"method",title:ut,value:t.httpServer.method||wl}]:t?.kafkaConsumer?[{id:"type",title:gt,value:bt},{id:"topic",title:Sl,value:t.kafkaConsumer.kafkaTopic||mt}]:t?.kafkaProducer?[{id:"type",title:gt,value:yt},{id:"topic",title:Sl,value:t.kafkaProducer.kafkaTopic||mt}]:[{id:"type",title:gt,value:ft}]})(a),[a]);return e(Ce,{richTitle:{title:et},children:e(fl,{children:r.map(({id:a,title:r,value:l})=>t(bl,{children:[e(E,{size:N.XXXS,color:I.Secondary,nowrap:!0,children:r}),e(E,{size:N.XS,nowrap:!0,children:l})]},a))})})},El=({category:a,formState:r,onChange:l})=>{const n=o(()=>"noisy"===a?Ml:Al,[a]),i=c(e=>l({operationType:e,route:"",serverAddress:"",method:"",kafkaTopic:""}),[l]),s=c(e=>t=>{t&&l({routeType:e,route:""})},[l]),d=c(e=>l({route:e.target.value}),[l]),u=c(e=>l({serverAddress:e.target.value}),[l]),p=c(e=>l({method:e[0]||""}),[l]),h=c(e=>l({kafkaTopic:e.target.value}),[l]),g="httpServer"===r.operationType||"httpClient"===r.operationType,m="kafkaConsumer"===r.operationType||"kafkaProducer"===r.operationType,v="httpClient"===r.operationType?it:ot,f="httpClient"===r.operationType?st:ct;return t(Ce,{richTitle:{title:`2. ${et}`,subTitle:tt},children:[e(O,{$alignItems:"flex-start",children:e(we,{options:n,selected:r.operationType,setSelected:i})}),g&&t(yl,{children:["httpClient"===r.operationType&&t(kl,{children:[e(ce,{name:"sampling-input-server-address",label:rt,placeholder:at,value:r.serverAddress,onChange:u}),e(Tl,{})]}),t(xl,{children:[t($l,{children:[e(Cl,{children:e(lt,{"data-id":"sampling-radio-route",value:"route"===r.routeType,onChange:s("route")})}),e(ce,{name:"sampling-input-route",label:v,placeholder:nt,value:"route"===r.routeType?r.route:"",onChange:d,disabled:"route"!==r.routeType})]}),t($l,{children:[e(Cl,{children:e(lt,{"data-id":"sampling-radio-route-prefix",value:"routePrefix"===r.routeType,onChange:s("routePrefix")})}),e(ce,{name:"sampling-input-route-prefix",label:f,placeholder:nt,value:"routePrefix"===r.routeType?r.route:"",onChange:d,disabled:"routePrefix"!==r.routeType})]})]}),t(kl,{children:[e(Tl,{}),e(dt,{label:ut,items:Pl,selectedIds:[r.method||""],setSelectedIds:e=>p(e),buttonProps:{"data-id":"sampling-btn-method",label:Pl.find(e=>e.id===r.method)?.label||wl,size:z.S,variant:D.Secondary}})]})]}),m&&e(ce,{name:"sampling-input-kafka-topic",label:pt,placeholder:"Type kafka topic",value:r.kafkaTopic,onChange:h,width:"320px"})]})},Il=[{value:"all",label:"Drop All"},{value:"sample",label:"Sample"}],Nl=[{value:"all",label:"Keep All"},{value:"sample",label:"Sample"}],Rl=t=>t.readOnly?e(Vl,{data:t.data}):e(zl,{category:t.category,formState:t.formState,onChange:t.onChange}),Vl=({data:a})=>{const r=o(()=>(e=>{switch(e.category){case"highlyRelevant":return null!=e.rule.percentageAtLeast?{title:$t,method:wt,description:Ct,value:`${e.rule.percentageAtLeast}%`}:{title:$t,method:Tt,description:null,value:null};case"noisy":return ba(e.rule.percentageAtMost)?{title:$t,method:St,description:null,value:null}:{title:$t,method:wt,description:kt,value:`${e.rule.percentageAtMost}%`};case"costReduction":return{title:$t,method:wt,description:kt,value:`${e.rule.percentageAtMost}%`}}})(a),[a]),l=[{id:"method",title:ut,value:r.method},...null!=r.description?[{id:"value",title:r.description,value:r.value}]:[]];return e(Ce,{richTitle:{title:r.title},children:e(fl,{children:l.map(({id:a,title:r,value:l})=>t(bl,{children:[e(E,{size:N.XXXS,color:I.Secondary,nowrap:!0,children:r}),e(E,{size:N.XS,nowrap:!0,children:l})]},a))})})},zl=({category:a,formState:r,onChange:l})=>{const n="highlyRelevant"===a,i=n?Nl:Il,o=`${n?4:3}. ${$t}`,s=xt[a],d=n?Ct:kt,u="noisy"===a?dl:cl,p=c(e=>l({percentageMode:e}),[l]),h=c(e=>l({percentagePreset:e}),[l]),g=c(e=>l({customPercentage:e.target.value}),[l]);return t(Ce,{richTitle:{title:o,subTitle:s},children:["costReduction"!==a&&e(O,{$alignItems:"flex-start",children:e(we,{options:i,selected:r.percentageMode,setSelected:p})}),("costReduction"===a||"sample"===r.percentageMode)&&e(pl,{description:d,options:u,selected:r.percentagePreset,onSelect:h,customName:"sampling-input-custom-percentage",customPlaceholder:"5%",customValue:r.customPercentage,onCustomChange:g,customInputType:de.Decimal,customMin:0,customMax:100})]})},Dl=r.div`
265
- display: flex;
266
- align-items: flex-end;
267
- gap: 16px;
268
- `,Xl=r.div`
269
- width: 280px;
270
- flex-shrink: 0;
271
- `,_l=r.div`
272
- flex: 1;
273
- min-width: 0;
274
- `;function Hl(e){return"highlyRelevant"===e.category?e.rule.error?"Error":null!=e.rule.durationAtLeastMs?"Duration":"Relevance":Nt[e.category]}const Bl=t=>t.readOnly?e(jl,{data:t.data}):e(ql,{formState:t.formState,onChange:t.onChange}),jl=({data:a})=>{const r=o(()=>[{id:"name",title:At,value:a.rule.name||Mt},{id:"type",title:Pt,value:Hl(a)}],[a]),l=a.rule.notes||mt;return t(Ce,{children:[e(fl,{children:r.map(({id:a,title:r,value:l})=>t(bl,{children:[e(E,{size:N.XXXS,color:I.Secondary,nowrap:!0,children:r}),e(E,{size:N.XS,nowrap:!0,children:l})]},a))}),t(bl,{children:[e(E,{size:N.XXXS,color:I.Secondary,children:Ot}),e(E,{size:N.XS,children:l})]})]})},ql=({formState:a,onChange:r})=>{const l=c(e=>r({name:e.target.value}),[r]),n=c(e=>r({notes:e.target.value}),[r]);return e(Ce,{children:t(Dl,{children:[e(Xl,{children:e(ce,{name:"sampling-input-rule-name",label:At,tooltip:"Optional. Give this rule a name for easier identification.",placeholder:Lt,value:a.name,onChange:l})}),e(_l,{children:e(ce,{name:"sampling-input-note",label:Ot,tooltip:It,placeholder:Et,value:a.notes,onChange:n})})]})})},Ul=[{value:"Relevance",label:"Relevance"},{value:"Error",label:"Error"},{value:"Duration",label:"Duration"}],Gl=({formState:t,onChange:a})=>{const r=c(e=>a({ruleType:e,keepErrors:"Error"===e}),[a]);return e(Ce,{richTitle:{title:`3. ${Pt}`,subTitle:Rt},children:e(O,{$alignItems:"flex-start",children:e(we,{options:Ul,selected:t.ruleType,setSelected:r})})})},Kl=t=>{const a=o(()=>{if(t.readOnly)return t.summary;switch(t.category){case"noisy":return $a(wa(t.formState));case"highlyRelevant":return xa(ka(t.formState));case"costReduction":return ya(Ca(t.formState))}},[t]);if(t.readOnly)return e(rl,{title:Vt,summary:a,renderAction:t.renderAction});const r=1===a.length&&"default"===a[0].variant;return e(rl,{title:r?ze:Vt,summary:r?[]:a,renderAction:t.renderAction})},Wl=(e,t)=>!t?.length||!!t?.find(t=>t===e),Fl=({title:a="Signals",required:r,errorMessage:l,allowedSignals:n,selectedSignals:i,setSelectedSignals:o,disabled:c})=>{const[u,h]=d(1===i.length),g=s(JSON.stringify(i));return p(()=>{let e=zt(i).filter(e=>Wl(e,n));e.length||(e=Dt.filter(({id:e})=>Wl(e,n)).map(({id:e})=>e));const t=JSON.stringify(e);g.current!==t&&(g.current=t,o(e),h(1===e.length))},[n,i]),t(O,{$gap:12,children:[e(L,{label:a,required:r}),e(R,{$gap:12,children:Dt.map(t=>{const a=Wl(t.id,n),r=((e,t)=>!!t?.find(t=>t===e))(t.id,i);return a?e(re,{label:t.value,disabled:c||!a||u&&r,value:r,onChange:e=>((e,t)=>{const a=e,r=t?[...i,a]:i.filter(e=>e!==a);o(r),h(1===r.length)})(t.id,e)},t.id):null})}),e(X,{errorMessage:l})]})},Yl=({minSupportedVersion:t,currentVersion:a})=>e(B,{isOpen:!0,onClose:()=>{},relativeToParent:!0,visual:()=>e(J,{scale:2.4,icon:()=>e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"22",height:"21",viewBox:"0 0 22 21",fill:"none",children:e("path",{fill:"#151618",d:"M9.4844 0.730003C9.99694 -0.243259 11.4076 -0.24341 11.92 0.730003L11.9685 0.831353L14.3039 6.22012L20.153 6.77755C21.3553 6.89211 21.841 8.38683 20.9358 9.18621L16.5314 13.0731L17.8091 18.8079C18.0716 19.9868 16.8005 20.9109 15.7605 20.2969L10.7017 17.3093L5.64282 20.2969C4.60289 20.9104 3.33173 19.9866 3.59427 18.8079L4.87192 13.0741L0.468608 9.18621C-0.43662 8.38693 0.0482932 6.8924 1.25029 6.77755L7.09837 6.22012L9.43588 0.831353L9.4844 0.730003ZM8.55284 7.02876C8.35287 7.48992 7.9179 7.80589 7.41751 7.85357L2.03952 8.36571L6.09027 11.941C6.46691 12.2737 6.63296 12.7852 6.5237 13.2758L5.34956 18.5459L10.0008 15.8009L10.1669 15.7179C10.5087 15.574 10.8945 15.5741 11.2364 15.7179L11.4036 15.8009L16.0538 18.5459L14.8807 13.2758C14.7714 12.7851 14.9374 12.2737 15.3141 11.941L19.3627 8.36571L13.9858 7.85357C13.4855 7.80587 13.0505 7.4899 12.8505 7.02876L10.7017 2.07342L8.55284 7.02876Z"})})}),title:Y.UPGRADE_REQUIRED,description:`${Y.UPGRADE_TO_USE_FEATURE(t)}\n${Y.CURRENT_VERSION(a)}`}),Jl=r.div`
275
- display: flex;
276
- flex-direction: column;
277
- justify-content: flex-end;
278
- width: ${({$width:e})=>e};
279
- gap: ${({$columnHasHeader:e})=>e?"0":"12px"};
280
- `,Zl=r.div`
281
- display: flex;
282
- align-items: center;
283
- min-height: 24px;
284
- padding: 12px;
285
- border-radius: 16px 16px 0 0;
286
- background-color: ${({theme:e})=>e.v2.colors.silver[800]};
287
- `,Ql=r.div`
288
- display: flex;
289
- flex-direction: column;
290
- gap: ${({$gap:e})=>e}px;
291
- padding: 12px 12px 0 12px;
292
- width: 100%;
293
- height: ${({$heightOffset:e,$columnHasHeader:t})=>`calc(100vh - 180px - ${e}px ${t?"- 48px":""})`};
294
- border-radius: ${({$columnHasHeader:e,$isLeft:t,$isRight:a})=>e?t?"0 0 0 16px":a?"0 16px 0 0":"0":t?"16px 0 0 16px":a?"0 16px 16px 0":"16px"};
295
- background-color: ${({theme:e})=>e.v2.colors.silver[900]};
296
- overflow-y: auto;
297
- overflow-x: hidden;
298
- `,en=({isLeft:r,isRight:l,heightOffset:n=0,width:i,header:o,list:s})=>t(Jl,{$width:i,$columnHasHeader:!!o,children:[o&&e(Zl,{children:o}),e(Ql,{$gap:8,$isLeft:r,$isRight:l,$heightOffset:n,$columnHasHeader:!!o,children:s.length?s.length>1?e(Xt,{gap:8,elements:s}):e(a,{children:s[0]}):e(_,{$height:"100%",children:e(H,{})})})]}),tn="75vw",an=r.div`
299
- display: flex;
300
- flex-direction: column;
301
- border-radius: 16px;
302
- background-color: ${({theme:e})=>e.v2.colors.silver[1e3]};
303
- overflow: hidden;
304
- `,rn=r.div`
305
- display: flex;
306
- gap: 12px;
307
- padding: 16px 16px 0 16px;
308
- background-color: ${({theme:e})=>e.v2.colors.silver[1e3]};
309
- position: sticky;
310
- top: 0;
311
- `,ln=r.div`
312
- padding: 12px 12px 0 12px;
313
- `,nn=r.div`
314
- display: flex;
315
- gap: 12px;
316
- padding: 16px;
317
- `,on=r.div`
318
- padding: 5vh 10vw;
319
- border-radius: 12px;
320
- background-color: ${({theme:e})=>e.v2.colors.silver[800]};
321
- `,sn=g(({isOpen:a,withOverlay:r,disableAnimation:l,onClose:n,onBack:i,onNext:s,nextIsSkip:u,onSave:p,disableSave:h,connectionIds:g,header:v,subHeader:f,leftColumn:b,rightColumn:y,search:x,filters:$,errorMessage:C,isFormDirty:k,allowSaveWhenPristine:w,hideDirtyNote:S,forcedNote:T,isFetching:M,progress:P},O)=>{const[L,E]=d(!1),[I,R]=d(!1),[V,z]=d(void 0);m(O,()=>({clearErrors:()=>z(void 0)}));const X=I,H=c(()=>{k&&!L?E(!0):(E(!1),n?.())},[k,L,n]),j=h||I||!w&&"boolean"==typeof k&&!k,q=c(async()=>{R(!0);const e=await p();R(!1),!1!==e&&(e?.error?z(e.error):(g?.setValue([]),n?.()))},[p,g,n]),U=!!x||!!g||!!$,G=!!f,K=(U?48:0)+(G?50:0),W=o(()=>T||(M?{status:he.Info,message:"Fetching Data..."}:I&&!P?{status:he.Info,message:"Saving Changes..."}:V||C?{status:he.Error,message:V||C}:"boolean"!=typeof k||S?void 0:k?{status:he.Info,message:'The values don\'t reflect the current configurations of the selected clusters.\n"Save" will override the current configurations.'}:{status:he.Success,message:"The values reflect the current configuration of the selected cluster."}),[M,I,P,V,C,k,S,T]),F=o(()=>i?{label:"Back",leftIcon:oa,variant:D.Secondary,onClick:i}:{label:"Cancel",variant:D.Secondary,onClick:H,disabled:X},[i,H,X]),[Y,J]=d(!1),Z=o(()=>s?u?{"data-id":"wide-drawer-skip",label:"Skip",rightIcon:sa,variant:D.Secondary,onClick:()=>J(!0)}:{"data-id":"wide-drawer-next",label:"Next",rightIcon:sa,variant:D.Primary,onClick:s}:{"data-id":"wide-drawer-save",label:"Save",variant:D.Primary,onClick:q,disabled:j},[s,u,q,j]);return t(A,{width:tn,isOpen:a,disableAnimation:l,hideOverlay:!I&&!r,header:{...v,onClose:n?H:void 0,onCloseDisabled:X},footer:{note:W,actions:[F,Z]},children:[I?e(_,{$height:"calc(100vh - 136px)",children:e(on,{children:e(_t,{titleSize:N.S,subTitleSize:N.XXXS,withGradient:!0,withSpinner:!0,...P})})}):t(an,{children:[U&&t(rn,{children:[g&&e(Ht,{icon:Zt,title:"Selected Clusters",badge:{label:g.value.length}}),x&&e(Bt,{...x,width:x.width??"100%"}),$]}),G&&e(ln,{children:e(Ht,{icon:f.icon,title:f.title,subTitle:f.description,badge:f.badge})}),t(nn,{children:[e(en,{isLeft:!0,heightOffset:K,...b}),e(en,{isRight:!0,heightOffset:K,...y})]})]}),e(hr,{isOpen:L,onClose:()=>E(!1),onApprove:H}),e(B,{title:"Skip setup?",description:"Without completing setup, Odigos won't be able to collect and send your telemetry data. This may interrupt your data flow and limit the platform's ability to provide value.",isOpen:Y,onClose:()=>J(!1),denyButton:{label:"Go Back",variant:D.Secondary,onClick:()=>J(!1)},approveButton:{label:"Skip",variant:D.Primary,onClick:()=>{s?.(),J(!1)}}})]})});sn.displayName=sn.name;const cn=r.div`
322
- padding: 0 24px;
323
- border-radius: 12px;
324
- background-color: ${({$codeBgColor:e})=>e||"transparent"};
325
- `,dn=r.div`
326
- display: flex;
327
- flex-direction: column;
328
- gap: 8px;
329
- width: 100%;
330
- padding: 8px;
331
- border: 1px solid ${({theme:e})=>e.v2.colors.silver[700]};
332
- border-radius: 12px;
333
- background-color: ${({theme:e})=>e.v2.colors.silver[900]};
334
- `,un=r.div`
335
- display: flex;
336
- align-items: center;
337
- gap: 4px;
338
- width: 100%;
339
- `,pn=r.div`
340
- flex: 1;
341
- min-width: 0;
342
- `,hn=r.div`
343
- width: 100%;
344
- max-height: 180px;
345
- overflow: auto;
346
- padding: 0 12px;
347
-
348
- pre {
349
- margin: 0;
350
- }
351
- `,gn=({title:a="YAML",yaml:r,defaultOpen:l,fullHeight:n,bgTint:i="1000",codeBgColor:s,compact:c})=>{const{clickCopy:d,isCopied:u,CopyButton:p}=j(),h=o(()=>r?[{id:qt(),type:jt.Button,buttonProps:{variant:D.Text,size:z.S,leftIcon:u?Ft:ca,onClick:()=>d(r||""),disabled:u}}]:[],[r,u]);return c?t(dn,{children:[t(un,{children:[e(da,{size:16}),e(pn,{children:e(E,{size:N.XXS,color:I.Primary,children:a})}),r&&e(p,{value:r})]}),r?e(hn,{children:e(W,{code:r,language:"yaml",theme:"duotoneDark"})}):e(H,{title:"YAML not found",subTitle:"The YAML for this resource is not available"})]}):e(K,{bgTint:i,richTitle:{icon:da,title:a},actions:h,withCollapse:!0,collapseIsDefaultOpen:l,fullHeight:n,children:e(cn,{$codeBgColor:s,children:r?e(W,{code:r,language:"yaml",theme:"duotoneDark"}):e(_,{children:e(H,{title:"YAML not found",subTitle:"The YAML for this resource is not available"})})})})};export{qa as A,pr as B,hr as C,ul as D,el as E,ol as I,dl as N,sl as O,cl as P,Bl as R,Kl as S,Yl as U,tn as W,gn as Y,vr as a,fr as b,br as c,gl as d,Qr as e,yr as f,Zr as g,Ol as h,Rl as i,pl as j,Gl as k,Fl as l,Er as m,sn as n,Ba as o,rl as p};
@@ -1,5 +0,0 @@
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,ba as l,bb as d,p as u,S,bc as m,bd as E,be as I,P as T,bf as p,bg as _,bh as f,bi as N,bj as y,bk as A,bl as R,bm as O,bn as g,bo as G,bp as h,bq as v,br as C,bs as L,bt as D,bu as P,bv as w,b4 as U,bw as b,bx as F,q as k,by as H,bz as M,bA as x,bB as V,bC as Y,bD as K,G as B,bE as $,bF as W,al as j,ah as q,aj as Q,ai as z,ak as J,ag as X,bG as Z,b as ee}from"./ui-components-DvoeDBMI.js";import{i as te,n as re,m as ae,l as ne,o as oe,p as se,v as ie,q as ce,u as le}from"./helpers-esDVvrTt.js";import{ApolloProvider as de,useLazyQuery as ue,useApolloClient as Se,useQuery as me}from"@apollo/client/react";import{ErrorLink as Ee}from"@apollo/client/link/error";import{SetContextLink as Ie}from"@apollo/client/link/context";import{getMainDefinition as Te}from"@apollo/client/utilities";import{CombinedGraphQLErrors as pe,ServerError as _e}from"@apollo/client/errors";import{HttpLink as fe,ApolloLink as Ne,ApolloClient as ye,InMemoryCache as Ae,gql as Re}from"@apollo/client";const Oe=e=>{if(!e)return!1;const t=e.toLowerCase();return t.includes("authentication required")||t.includes("authentication expired")||t.includes("http 401")},ge=a(null),Ge=()=>{const e=r(ge);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},he=({apolloConfig:r,operations:a,context:n,children:o})=>{const s=t(()=>(e=>{const t=new fe({uri:e.httpUrl,credentials:e.credentials??"same-origin"}),r=new Ee(({error:t})=>{pe.is(t)?t.errors.some(e=>Oe(e.message))&&e.onAuthError?.():(_e.is(t)&&401===t.statusCode||Oe(t.message))&&e.onAuthError?.()}),a=new Ie(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=Ne.from(n);e.wsLink&&(o=Ne.split(({query:e})=>{const t=Te(e);return"OperationDefinition"===t.kind&&"subscription"===t.operation},e.wsLink,o));const s=e.defaultFetchPolicies;return new ye({link:o,cache:new Ae({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(de,{client:s,children:e(ge.Provider,{value:i,children:o})})},ve=ge,Ce=e=>e.map(e=>`${e.id}:${e.odigosVersion}:${e.type}`).join(","),Le=(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}},De=({connections:r,connectionIds:a,children:n})=>{const o=Ge(),s=t(()=>({operations:o.operations,context:Le(o.context,r,a),apolloConfig:o.apolloConfig}),[o.operations,o.context,o.apolloConfig,Ce(r),a?.join(",")]);return e(ve.Provider,{value:s,children:n})},Pe=(e,t)=>{if(e)return"string"==typeof e?e:m(e,t)},we=e=>{const{addNotification:t}=l(),r=(r,a,n,o,s)=>t({type:r,title:a,message:n,crdType:e,target:Pe(o,e),hideFromHistory:s});return{notify:r,notifyError:(e,t,a)=>r(S.Error,e,t,a),notifySuccess:(e,t,a)=>r(S.Success,e,t,a),notifyPending:(e,t)=>r(S.Default,"Pending",e,t,!0),notifyReadonly:()=>{t({type:S.Warning,title:u.READONLY,message:d.READONLY_WARNING,hideFromHistory:!0})}}},Ue=e=>{e({type:S.Warning,title:u.READONLY,message:d.READONLY_WARNING,hideFromHistory:!0})},be=e=>({error:e,results:[],allSucceeded:!1,anySucceeded:!1,successCount:0,failureCount:0}),Fe=(e,t)=>{if(e)return"function"==typeof e?e(t):e},ke=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)},He=(e,t)=>e.client??t,Me=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(He(t,e),r,a)}catch(e){return{error:ke(e)}}const o=Fe(t.document,a);if(!o)return{error:"Query operation not supported in this context"};const s=t.transformVariables?t.transformVariables(r,a):r,i=He(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?ke(e.error):void 0}}catch(e){return{error:ke(e)}}},xe=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(He(t,e),r,a)}catch(e){return{error:ke(e)}}const n=Fe(t.document,a);if(!n)return{error:"Mutation operation not supported in this context"};const o=t.transformVariables?t.transformVariables(r,a):r,s=He(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:ke(e)}}},Ve=async(e,t,r,a,n)=>{if(!t)return be("Multi fetch operation not configured");if(!r.length)return be("No proxy ids supplied for multi fetch");const o=He(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=ke(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 Me(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}},Ye=Re`
2
- query OdigosApiNoop {
3
- __typename
4
- }
5
- `,Ke=(e,t)=>{if(e)return"function"==typeof e?e(t):e},Be=(e,t)=>e[t],$e=(e,t,r)=>{if(void 0!==t)return e?.transformResult?e.transformResult(t,r):t},We=(e,t,r)=>{if(!e)return;const a=e.transformVariables;return a?a(t,r):t},je=(e,r,a)=>{const{operations:o,context:i}=Ge(),c=Be(o,e),l=t(()=>Ke(c?.document,i),[c,i]),d=t(()=>We(c,r,i),[c,r,i]),u=!c||!l,S=!!c?.canRun&&!c.canRun(i),m=a?.skip||u||S,E=me(l??Ye,{variables:d,skip:m,pollInterval:a?.pollInterval,fetchPolicy:a?.fetchPolicy??"cache-and-network",notifyOnNetworkStatusChange:a?.notifyOnNetworkStatusChange,client:c?.client}),I=t(()=>{if(!m)return $e(c,E.data,i)},[c,i,E.data,m]);s(()=>{m||void 0===I||a?.onCompleted?.(I)},[m,I,a?.onCompleted]),s(()=>{E.error&&a?.onError?.(E.error)},[E.error,a?.onError]);const T=n(async()=>{if(m)return{data:void 0};const e=await E.refetch();return{data:$e(c,e.data,i)}},[c,i,E,m]);return{data:I,loading:!m&&E.loading,error:E.error,refetch:T,unsupported:u}},qe=(e,r)=>{const{operations:a,context:o}=Ge(),s=Be(a,e),i=t(()=>Ke(s?.document,o),[s,o]),c=!s||!i,[l,d]=ue(i??Ye,{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=We(s,e,o),r=await l({variables:t});return r.error?{error:r.error}:{data:$e(s,r.data,o)}},[s,o,l,c]),data:t(()=>$e(s,d.data,o),[s,o,d.data]),loading:d.loading,error:d.error,called:d.called,unsupported:c}},Qe=(e,r)=>{const{operations:a,context:s}=Ge(),i=Se(),c=Be(a,e),l=t(()=>Ke(c?.document,s),[c,s]),d=!c||!l,[u,S]=o({loading:!1,called:!1}),m=n(()=>S({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=We(c,e,s),a=c?.client??i;S(e=>({...e,loading:!0,called:!0}));try{const e=await a.mutate({mutation:l,variables:t}),n=$e(c,e.data,s);if(S({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 S({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:m}]},ze=[],Je=(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}},Xe=(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}},Ze={filter:{markedForInstrumentation:!0}},et=[],tt=e=>{const t=e.markedForInstrumentation?.markedForInstrumentation;return"boolean"==typeof t?e:{...e,markedForInstrumentation:{...e.markedForInstrumentation??{markedForInstrumentation:!0},markedForInstrumentation:!0}}},rt=e=>{let t=!1;const r=e.map(e=>{const r=tt(e);return r!==e&&(t=!0),r});return t?r:e},at=[],nt=[],ot=[],st=(e,t)=>{const r=Se(),{notifyError:a,notifySuccess:n,notifyReadonly:o}=we(O.Finding),s=async()=>{e.GET_INSIGHTS_FINDINGS&&await Me(r,e.GET_INSIGHTS_FINDINGS,void 0,t)},i=async()=>{e.GET_INSIGHTS_ANOMALIES&&await Me(r,e.GET_INSIGHTS_ANOMALIES,void 0,t)},c=async()=>{e.GET_INSIGHTS_TRANSACTIONS&&await Me(r,e.GET_INSIGHTS_TRANSACTIONS,void 0,t)},l=async()=>{if(!e.GET_INSIGHTS_POLICIES)return;const a="function"==typeof e.GET_INSIGHTS_POLICIES.document?e.GET_INSIGHTS_POLICIES.document(t):e.GET_INSIGHTS_POLICIES.document;a?await r.refetchQueries({include:[a]}):await Me(r,e.GET_INSIGHTS_POLICIES,void 0,t)},d=async()=>{e.GET_INSIGHTS_LEARNING_POLICIES&&await Me(r,e.GET_INSIGHTS_LEARNING_POLICIES,void 0,t)},u=async()=>{e.GET_INSIGHTS_GUARDRAILS&&await Me(r,e.GET_INSIGHTS_GUARDRAILS,void 0,t)},S=async()=>{e.GET_INSIGHTS_GUARDRAIL_VIOLATIONS&&await Me(r,e.GET_INSIGHTS_GUARDRAIL_VIOLATIONS,void 0,t)};return{useServices:e=>je("GET_INSIGHTS_SERVICES",void 0,e),useTransactions:(e,t)=>je("GET_INSIGHTS_TRANSACTIONS",e,t),useTransaction:(e,t)=>je("GET_INSIGHTS_TRANSACTION",e,t),useBaseline:(e,t)=>je("GET_INSIGHTS_BASELINE",e,t),useObservations:(e,t)=>je("GET_INSIGHTS_OBSERVATIONS",e,t),useObservation:(e,t)=>je("GET_INSIGHTS_OBSERVATION",e,t),useFindings:(e,t)=>je("GET_INSIGHTS_FINDINGS",e,t),useAnomalies:(e,t)=>je("GET_INSIGHTS_ANOMALIES",e,t),useAnomaly:(e,t)=>je("GET_INSIGHTS_ANOMALY",e,t),usePolicies:e=>je("GET_INSIGHTS_POLICIES",void 0,e),useLearningPolicies:e=>je("GET_INSIGHTS_LEARNING_POLICIES",void 0,e),useGuardrails:e=>je("GET_INSIGHTS_GUARDRAILS",void 0,e),useGuardrailViolations:(e,t)=>je("GET_INSIGHTS_GUARDRAIL_VIOLATIONS",e,t),useGuardrailViolation:(e,t)=>je("GET_INSIGHTS_GUARDRAIL_VIOLATION",e,t),useServiceProfile:(e,t)=>je("GET_INSIGHTS_SERVICE_PROFILE",e,t),useBlastRadius:(e,t)=>je("GET_INSIGHTS_BLAST_RADIUS",e,t),useCatalog:e=>je("GET_INSIGHTS_CATALOG",void 0,e),useSystemSettings:e=>je("GET_INSIGHTS_SYSTEM_SETTINGS",void 0,e),useStorageHealth:e=>je("GET_INSIGHTS_STORAGE_HEALTH",void 0,e),getServices:e.GET_INSIGHTS_SERVICES?async()=>Me(r,e.GET_INSIGHTS_SERVICES,void 0,t):void 0,getTransactions:e.GET_INSIGHTS_TRANSACTIONS?async a=>Me(r,e.GET_INSIGHTS_TRANSACTIONS,a,t):void 0,getTransaction:e.GET_INSIGHTS_TRANSACTION?async a=>Me(r,e.GET_INSIGHTS_TRANSACTION,a,t):void 0,getFindings:e.GET_INSIGHTS_FINDINGS?async a=>Me(r,e.GET_INSIGHTS_FINDINGS,a,t):void 0,getAnomalies:e.GET_INSIGHTS_ANOMALIES?async a=>Me(r,e.GET_INSIGHTS_ANOMALIES,a,t):void 0,getAnomaly:e.GET_INSIGHTS_ANOMALY?async a=>Me(r,e.GET_INSIGHTS_ANOMALY,a,t):void 0,getPolicies:e.GET_INSIGHTS_POLICIES?async()=>Me(r,e.GET_INSIGHTS_POLICIES,void 0,t):void 0,getLearningPolicies:e.GET_INSIGHTS_LEARNING_POLICIES?async()=>Me(r,e.GET_INSIGHTS_LEARNING_POLICIES,void 0,t):void 0,getGuardrails:e.GET_INSIGHTS_GUARDRAILS?async()=>Me(r,e.GET_INSIGHTS_GUARDRAILS,void 0,t):void 0,getGuardrailViolation:e.GET_INSIGHTS_GUARDRAIL_VIOLATION?async a=>Me(r,e.GET_INSIGHTS_GUARDRAIL_VIOLATION,a,t):void 0,getServiceProfile:e.GET_INSIGHTS_SERVICE_PROFILE?async a=>Me(r,e.GET_INSIGHTS_SERVICE_PROFILE,a,t):void 0,getBlastRadius:e.GET_INSIGHTS_BLAST_RADIUS?async a=>Me(r,e.GET_INSIGHTS_BLAST_RADIUS,a,t):void 0,getCatalog:e.GET_INSIGHTS_CATALOG?async()=>Me(r,e.GET_INSIGHTS_CATALOG,void 0,t):void 0,getSystemSettings:e.GET_INSIGHTS_SYSTEM_SETTINGS?async()=>Me(r,e.GET_INSIGHTS_SYSTEM_SETTINGS,void 0,t):void 0,getStorageHealth:e.GET_INSIGHTS_STORAGE_HEALTH?async()=>Me(r,e.GET_INSIGHTS_STORAGE_HEALTH,void 0,t):void 0,promoteBaselineClass:e.PROMOTE_INSIGHTS_BASELINE_CLASS?async s=>{if(t.isReadonly)return o();const{data:i,error:c}=await xe(r,e.PROMOTE_INSIGHTS_BASELINE_CLASS,s,t);return c?a(E.Update,c):n(E.Update,"Successfully promoted baseline class"),{data:i,error:c}}:void 0,resetBaselineClass:e.RESET_INSIGHTS_BASELINE_CLASS?async(s,i)=>{if(t.isReadonly)return o();const{error:c}=await xe(r,e.RESET_INSIGHTS_BASELINE_CLASS,{transactionId:s,class:i},t);return c?a(E.Update,c):n(E.Update,"Successfully reset baseline class"),c?{error:c}:void 0}:void 0,resetTransactionBaselines:e.RESET_INSIGHTS_TRANSACTION_BASELINES?async s=>{if(t.isReadonly)return o();const{error:i}=await xe(r,e.RESET_INSIGHTS_TRANSACTION_BASELINES,{transactionId:s},t);return i?a(E.Update,i):n(E.Update,"Successfully reset transaction baselines"),i?{error:i}:void 0}:void 0,promoteTransactionBaselines:e.PROMOTE_INSIGHTS_TRANSACTION_BASELINES?async s=>{if(t.isReadonly)return o();const{error:i}=await xe(r,e.PROMOTE_INSIGHTS_TRANSACTION_BASELINES,{transactionId:s},t);return i?a(E.Update,i):(n(E.Update,"Successfully promoted transaction baselines"),await Promise.all([c(),u()])),i?{error:i}:void 0}:void 0,bulkPromoteTransactions:e.BULK_PROMOTE_INSIGHTS_TRANSACTIONS?async s=>{if(t.isReadonly)return o();const i={transactionIds:s},{data:l,error:d}=await xe(r,e.BULK_PROMOTE_INSIGHTS_TRANSACTIONS,i,t);return d?a(E.Update,d):(n(E.Update,`Successfully promoted ${l?.promoted??s.length} transactions`),await Promise.all([c(),u()])),{data:l,error:d}}:void 0,forcePromoteService:e.FORCE_PROMOTE_INSIGHTS_SERVICE?async s=>{if(t.isReadonly)return o();const{error:i}=await xe(r,e.FORCE_PROMOTE_INSIGHTS_SERVICE,s,t);return i?a(E.Update,i):(n(E.Update,"Successfully force-promoted service transactions"),await Promise.all([c(),u()])),i?{error:i}:void 0}:void 0,enableTransactionGuardrail:e.ENABLE_INSIGHTS_TRANSACTION_GUARDRAIL?async s=>{if(t.isReadonly)return o();const{error:i}=await xe(r,e.ENABLE_INSIGHTS_TRANSACTION_GUARDRAIL,s,t);return i?a(E.Update,i):(n(E.Update,"Successfully enabled transaction guardrail"),await u()),i?{error:i}:void 0}:void 0,disableTransactionGuardrail:e.DISABLE_INSIGHTS_TRANSACTION_GUARDRAIL?async s=>{if(t.isReadonly)return o();const{error:i}=await xe(r,e.DISABLE_INSIGHTS_TRANSACTION_GUARDRAIL,s,t);return i?a(E.Update,i):(n(E.Update,"Successfully disabled transaction guardrail"),await u()),i?{error:i}:void 0}:void 0,deleteTransaction:e.DELETE_INSIGHTS_TRANSACTION?async l=>{if(t.isReadonly)return o();const{error:d}=await xe(r,e.DELETE_INSIGHTS_TRANSACTION,{transactionId:l},t);return d?a(E.Delete,d):(n(E.Delete,"Successfully deleted transaction"),await Promise.all([c(),s(),i()])),d?{error:d}:void 0}:void 0,bulkDeleteTransactions:e.BULK_DELETE_INSIGHTS_TRANSACTIONS?async l=>{if(t.isReadonly)return o();const d={transactionIds:l},{data:u,error:S}=await xe(r,e.BULK_DELETE_INSIGHTS_TRANSACTIONS,d,t);return S?a(E.Delete,S):(n(E.Delete,`Successfully deleted ${u?.deleted??l.length} transactions`),await Promise.all([c(),s(),i()])),{data:u,error:S}}:void 0,upsertPolicy:e.UPSERT_INSIGHTS_POLICY?async s=>{if(t.isReadonly)return o();const{data:i,error:c}=await xe(r,e.UPSERT_INSIGHTS_POLICY,{policy:s},t);return c?a(E.Update,c):(n(E.Update,`Successfully saved policy "${s.name}"`),await l()),{data:i,error:c}}:void 0,deletePolicy:e.DELETE_INSIGHTS_POLICY?async(s,i)=>{if(t.isReadonly)return o();const{error:c}=await xe(r,e.DELETE_INSIGHTS_POLICY,{scope:s,scopeKey:i},t);return c?a(E.Delete,c):(n(E.Delete,"Successfully deleted policy"),await l()),c?{error:c}:void 0}:void 0,upsertLearningPolicy:e.UPSERT_INSIGHTS_LEARNING_POLICY?async s=>{if(t.isReadonly)return o();const{data:i,error:c}=await xe(r,e.UPSERT_INSIGHTS_LEARNING_POLICY,{policy:s},t);return c?a(E.Update,c):(n(E.Update,"Successfully saved learning policy"),await d()),{data:i,error:c}}:void 0,deleteLearningPolicy:e.DELETE_INSIGHTS_LEARNING_POLICY?async(s,i,c)=>{if(t.isReadonly)return o();const{error:l}=await xe(r,e.DELETE_INSIGHTS_LEARNING_POLICY,{class:s,scope:i,scopeKey:c},t);return l?a(E.Delete,l):(n(E.Delete,"Successfully deleted learning policy"),await d()),l?{error:l}:void 0}:void 0,resolveAnomaly:e.RESOLVE_INSIGHTS_ANOMALY?async c=>{if(t.isReadonly)return o();const{error:l}=await xe(r,e.RESOLVE_INSIGHTS_ANOMALY,c,t);return l?a(E.Update,l):(n(E.Update,`Successfully ${c.resolution}ed anomaly`),await Promise.all([i(),s()])),l?{error:l}:void 0}:void 0,bulkResolveAnomalies:e.BULK_RESOLVE_INSIGHTS_ANOMALIES?async(c,l)=>{if(t.isReadonly)return o();const d={resolution:c,items:l},{data:u,error:S}=await xe(r,e.BULK_RESOLVE_INSIGHTS_ANOMALIES,d,t);return S?a(E.Update,S):(n(E.Update,`Successfully ${c}ed ${u?.resolved??l.length} anomalies`),await Promise.all([i(),s()])),{data:u,error:S}}:void 0,upsertGuardrail:e.UPSERT_INSIGHTS_GUARDRAIL?async s=>{if(t.isReadonly)return o();const{data:i,error:c}=await xe(r,e.UPSERT_INSIGHTS_GUARDRAIL,{guardrail:s},t);return c?a(E.Update,c):(n(E.Update,"Successfully saved guardrail"),await u()),{data:i,error:c}}:void 0,deleteGuardrail:e.DELETE_INSIGHTS_GUARDRAIL?async s=>{if(t.isReadonly)return o();const{error:i}=await xe(r,e.DELETE_INSIGHTS_GUARDRAIL,{scopeKey:s},t);return i?a(E.Delete,i):(n(E.Delete,"Successfully deleted guardrail"),await u()),i?{error:i}:void 0}:void 0,seedGuardrail:e.SEED_INSIGHTS_GUARDRAIL?async s=>{if(t.isReadonly)return o();const{error:i}=await xe(r,e.SEED_INSIGHTS_GUARDRAIL,{seed:s},t);return i?a(E.Create,i):(n(E.Create,"Successfully seeded guardrail"),await u()),i?{error:i}:void 0}:void 0,allowViolation:e.ALLOW_INSIGHTS_GUARDRAIL_VIOLATION?async i=>{if(t.isReadonly)return o();const{error:c}=await xe(r,e.ALLOW_INSIGHTS_GUARDRAIL_VIOLATION,{action:i},t);return c?a(E.Update,c):(n(E.Update,"Successfully allowed violation"),await Promise.all([S(),s()])),c?{error:c}:void 0}:void 0,dismissViolation:e.DISMISS_INSIGHTS_GUARDRAIL_VIOLATION?async i=>{if(t.isReadonly)return o();const{error:c}=await xe(r,e.DISMISS_INSIGHTS_GUARDRAIL_VIOLATION,{action:i},t);return c?a(E.Update,c):(n(E.Update,"Successfully dismissed violation"),await Promise.all([S(),s()])),c?{error:c}:void 0}:void 0,reopenViolation:e.REOPEN_INSIGHTS_GUARDRAIL_VIOLATION?async i=>{if(t.isReadonly)return o();const{error:c}=await xe(r,e.REOPEN_INSIGHTS_GUARDRAIL_VIOLATION,{action:i},t);return c?a(E.Update,c):(n(E.Update,"Successfully reopened violation"),await Promise.all([S(),s()])),c?{error:c}:void 0}:void 0,updateSystemSettings:e.UPDATE_INSIGHTS_SYSTEM_SETTINGS?async s=>{if(t.isReadonly)return o();const{data:i,error:c}=await xe(r,e.UPDATE_INSIGHTS_SYSTEM_SETTINGS,{settings:s},t);return c?a(E.Update,c):(n(E.Update,"Successfully updated system settings"),await(async()=>{e.GET_INSIGHTS_SYSTEM_SETTINGS&&await Me(r,e.GET_INSIGHTS_SYSTEM_SETTINGS,void 0,t)})()),{data:i,error:c}}:void 0}},it=[],ct=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}},lt=[],dt=[],ut=(e,t)=>({...e,fields:e.fields.filter(({value:e})=>void 0!==e),currentStreamName:t}),St=[],mt=[],Et=()=>{const{operations:e,context:r}=Ge(),a=Se(),o=((e,r)=>{const a=Se(),{notifyError:o,notifySuccess:s,notifyPending:i,notifyReadonly:c}=we(I.Source),{selectedStreamName:l}=p(),{setProgress:d,resetProgress:u}=_(),{setConfiguredSources:S,setConfiguredFutureApps:m}=f(),T=(e,t)=>{const{progress:r}=_.getState();e>0&&d(N.Instrumenting,{total:(r[N.Instrumenting]?.total||0)+e,current:r[N.Instrumenting]?.current||0}),t>0&&d(N.Uninstrumenting,{total:(r[N.Uninstrumenting]?.total||0)+t,current:r[N.Uninstrumenting]?.current||0})},R=n(async()=>{const{error:t}=await Me(a,e.GET_WORKLOADS,Ze,r);t&&o(E.Read,t)},[a,e.GET_WORKLOADS,r,o]);return{useSources:()=>{const e=je("GET_WORKLOADS",Ze,{fetchPolicy:"cache-first"}),r=e.data?.workloads;return{items:t(()=>r?rt(r):et,[r]),loading:e.loading,refetch:R}},fetchAll:R,fetchByTargets:async(t,n)=>{const s=!!n?.slim,i=t.map(e=>y(e,I.Source)).filter(e=>e.namespace&&e.name&&e.kind);if(0===i.length)return;if(i.length>50)return void await R();const c=s&&e.GET_WORKLOADS_BY_IDS_SLIM?e.GET_WORKLOADS_BY_IDS_SLIM:e.GET_WORKLOADS_BY_IDS,{error:l}=await Me(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(E.Read,l):await R()},fetchById:async t=>{const{data:n,error:s}=await Me(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(E.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?tt(i):void 0},fetchLibraries:async t=>Me(a,e.GET_SOURCE_LIBRARIES,t,r),fetchPeerSources:async t=>Me(a,e.GET_PEER_SOURCES,{serviceName:t},r),usePeerSources:(e,t)=>je("GET_PEER_SOURCES",e,t),useInstrumentationInstructions:(e,t)=>je("GET_INSTRUMENTATION_INSTRUCTIONS",e,{...t,skip:t?.skip||!e?.name}),persist:async(t,n)=>{if(r.isReadonly)return c();const{data:s}=await Me(a,e.GET_WORKLOADS,Ze,r,"cache-first"),d=rt(s?.workloads??et),{payload:I,isEmpty:p}=Je(t,d,l,T),{payload:_,isEmpty:f}=Xe(n,l);let y=!1;p||(y=!0,i("Persisting sources...")),f||y||i("Persisting namespaces...");const{error:A}=await xe(a,e.PERSIST_SOURCES,I,r);if(A&&(u(N.Instrumenting),u(N.Uninstrumenting),o(E.Update,A)),e.PERSIST_NAMESPACES){const{error:t}=await xe(a,e.PERSIST_NAMESPACES,_,r);t&&o(E.Update,t)}S({}),m({})},persistV2:async t=>{if(r.isReadonly)return c(),{error:"readonly"};const n=[];for(const[o,s]of Object.entries(t)){const t={sources:[]},i={namespaces:[]};for(const e of s)e.name&&e.kind?t.sources.push(e):i.namespaces.push(e);const c=o&&o!==A?{...r,proxyID:o}:r,l=e=>o&&o!==A?`${o}: ${e}`:e;if(i.namespaces.length>0&&e.PERSIST_NAMESPACES){const{error:t}=await xe(a,e.PERSIST_NAMESPACES,i,c);t&&n.push(l(t))}if(t.sources.length>0){const{error:r}=await xe(a,e.PERSIST_SOURCES,t,c);r&&n.push(l(r))}}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:S}=await xe(a,e.UPDATE_SOURCE,d,r);S?o(E.Update,S,t):u?.updateK8sActualSource&&s(E.Update,`Successfully updated "${t.name}" source`,t)},restartWorkloads:async t=>{if(r.isReadonly)return c();i("Restarting sources...");const{data:n,error:l}=await xe(a,e.RESTART_WORKLOADS,{sourceIds:t},r);l?o(E.Update,l):n?.restartWorkloads&&s(E.Update,`Successfully restarted ${t.length} sources`)},restartPod:async(t,n)=>{if(r.isReadonly)return c();i("Restarting pod...");const{data:l,error:d}=await xe(a,e.RESTART_POD,{namespace:t,name:n},r);d?o(E.Update,d):l?.restartPod&&s(E.Update,`Successfully restarted pod ${t}/${n}`)},recoverFromRollback:async t=>{if(r.isReadonly)return c();i("Recovering from rollback...");const{data:n,error:l}=await xe(a,e.RECOVER_FROM_ROLLBACK,{sourceId:t},r);l?o(E.Update,l,t):n?.recoverFromRollbackForWorkload&&s(E.Update,"Successfully triggered recovery from rollback")}}})(e,r),i=((e,t)=>{const r=Se(),{notifyError:a,notifySuccess:n,notifyReadonly:o}=we(I.Destination),{selectedStreamName:s}=p(),i=async()=>{const{error:n}=await Me(r,e.GET_DESTINATIONS,void 0,t);n&&a(E.Read,n)};return{useDestinations:()=>{const e=je("GET_DESTINATIONS",void 0,{fetchPolicy:"cache-first"});return{items:e.data?.computePlatform?.destinations??e.data?.destinations??dt,loading:e.loading,refetch:i}},useDestinationCategories:()=>{const e=je("GET_DESTINATION_CATEGORIES",void 0);return{data:e.data,loading:e.loading}},usePotentialDestinations:()=>{const e=je("GET_POTENTIAL_DESTINATIONS",void 0);return{data:e.data,loading:e.loading}},fetchAll:i,testConnection:async a=>{const{data:n}=await xe(r,e.TEST_DESTINATION_CONNECTION,{destination:ut(a,s)},t);return n},create:async c=>{if(t.isReadonly)return o();const{error:l}=await xe(r,e.CREATE_DESTINATION,{destination:ut(c,s)},t);l?a(E.Create,l):(n(E.Create,`Successfully created "${c.type}" destination`),await i())},update:async(c,l)=>{if(t.isReadonly)return o();const{data:d,error:u}=await xe(r,e.UPDATE_DESTINATION,{id:c,destination:ut(l,s)},t);u?a(E.Update,u,c):d?.updateDestination&&(n(E.Update,`Successfully updated "${l.type}" destination`,c),await i())},remove:async c=>{if(t.isReadonly)return o();const{data:l}=await Me(r,e.GET_DESTINATIONS,void 0,t,"cache-first"),d=l?.computePlatform?.destinations??l?.destinations??dt,u=d.find(e=>g(e)===c)?.destinationType?.type,{error:S}=await xe(r,e.DELETE_DESTINATION,{id:c,currentStreamName:s},t);S?a(E.Delete,S,c):(n(E.Delete,`Successfully deleted "${u??c}" destination`,c),await i())}}})(e,r),c=((e,r)=>{const a=Se(),{notifyError:n,notifySuccess:o,notifyReadonly:s}=we(I.Action),i=async()=>{const{error:t}=await Me(a,e.GET_ACTIONS,void 0,r);t&&n(E.Read,t)};return{useActions:()=>{const e=je("GET_ACTIONS",void 0,{fetchPolicy:"cache-first"});return{items:e.data?.computePlatform?.actions??e.data?.actions??at,loading:e.loading,refetch:i}},useActionTypes:()=>{const e=je("GET_ACTION_TYPES",void 0,{fetchPolicy:"cache-first"});return{options:t(()=>R(e.data)||nt,[e.data]),loading:e.loading}},fetchAll:i,create:async t=>{if(r.isReadonly)return s(),{error:d.READONLY_WARNING};if(!e.CREATE_ACTION)return{error:"Action creation is not supported"};const{error:c}=await xe(a,e.CREATE_ACTION,{action:t},r);return c?n(E.Create,c):(o(E.Create,`Successfully created "${t.type}" action`),await i()),c?{error:c}:void 0},update:async(t,c)=>{if(r.isReadonly)return s();if(!e.UPDATE_ACTION)return;const{error:l}=await xe(a,e.UPDATE_ACTION,{id:t,action:c},r);l?n(E.Update,l,t):(o(E.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 xe(a,e.DELETE_ACTION,{id:t,actionType:c},r);l?n(E.Delete,l,t):(o(E.Delete,`Successfully deleted "${c}" action`,t),await i())}}})(e,r),u=((e,r)=>{const a=Se(),{notifyError:n,notifySuccess:o,notifyReadonly:s}=we(I.InstrumentationRule),i=async()=>{const{error:t}=await Me(a,e.GET_INSTRUMENTATION_RULES,void 0,r);t&&n(E.Read,t)};return{useRules:()=>{const e=je("GET_INSTRUMENTATION_RULES",void 0,{fetchPolicy:"cache-first"});return{items:t(()=>(e.data?.computePlatform?.instrumentationRules??e.data?.instrumentationRules??[]).map(P),[e.data]),loading:e.loading,refetch:i}},useRuleTypes:()=>{const e=je("GET_INSTRUMENTATION_RULE_TYPES",void 0,{fetchPolicy:"cache-first"});return{options:t(()=>D(e.data)||mt,[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 xe(a,e.CREATE_INSTRUMENTATION_RULE,{instrumentationRule:L(t)},r);l?n(E.Create,l):(o(E.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 xe(a,e.UPDATE_INSTRUMENTATION_RULE,{ruleId:t,instrumentationRule:L(c)},r);d?n(E.Update,d,t):(o(E.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 xe(a,e.DELETE_INSTRUMENTATION_RULE,{ruleId:t},r);l?n(E.Delete,l,t):(o(E.Delete,`Successfully deleted${c?` "${c}"`:""} rule`,t),await i())}}})(e,r),m=((e,t)=>{const r=Se(),{addNotification:a}=l(),{setDataStreams:n}=p(),o=(e,t)=>a({type:S.Error,title:e,message:t}),i=async()=>{const{data:a,error:s}=await Me(r,e.GET_DATA_STREAMS,void 0,t);if(s)o(E.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 Ue(a);const{error:s}=await xe(r,e.CREATE_DATA_STREAM,{stream:n},t);s?o(E.Create,s):await i()}:void 0;return{useDataStreams:()=>{const e=je("GET_DATA_STREAMS",void 0,{fetchPolicy:"cache-first"}),t=e.data?.computePlatform?.dataStreams??e.data?.dataStreams??lt;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 Ue(a);const{error:c}=await xe(r,e.UPDATE_DATA_STREAM,{id:n,dataStream:s},t);c?o(E.Update,c):await i()},remove:async n=>{if(t.isReadonly)return Ue(a);const{error:s}=await xe(r,e.DELETE_DATA_STREAM,{id:n},t);s?o(E.Delete,s):await i()}}})(e,r),O=((e,t)=>{const r=Se(),{notifyError:a,notifyReadonly:n}=we(I.Namespace),o=async()=>{const n=await Me(r,e.GET_NAMESPACES_WITH_WORKLOADS,void 0,t);return n.error&&a(E.Read,n.error),n};return{useNamespaces:e=>{const t=je("GET_NAMESPACES_WITH_WORKLOADS",void 0,{fetchPolicy:"cache-and-network",skip:e?.skip});return{items:t.data?.namespaces??it,loading:t.loading,refetch:o}},fetchAll:o,persist:async o=>{if(t.isReadonly)return n();const{error:s}=await xe(r,e.PERSIST_NAMESPACES,o,t);return s&&a(E.Update,s),s?{error:s}:void 0}}})(e,r),w=((e,t)=>{const r=Se(),{notifyError:a}=we(I.Source);return{fetch:async n=>{const o=await Me(r,e.GET_K8S_MANIFEST,n,t);return o.error&&a(E.Read,o.error),o}}})(e,r),U=((e,t)=>{const r=Se(),{notifyError:a,notifySuccess:n,notifyReadonly:o}=we(I.Source);return{useEffectiveConfig:(e,t)=>je("GET_EFFECTIVE_CONFIG",e,t),useConfigYamls:e=>je("GET_CONFIG_YAMLS",void 0,e),getEffectiveConfig:async a=>e.GET_EFFECTIVE_CONFIG?Me(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 xe(r,c,i,t)):({error:l}=await Ve(r,c,s,i,t)),l&&a(E.Update,l),l?{error:l}:void 0}:void 0,getConfigYamls:e.GET_CONFIG_YAMLS?async()=>Me(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 xe(r,e.UPDATE_LOCAL_UI_CONFIG,{config:s},t);return i?a(E.Update,i):n(E.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 xe(r,e.RESET_LOCAL_UI_CONFIG_TO_FACTORY_DEFAULTS,void 0,t);return s?a(E.Update,s):n(E.Update,"Local UI configuration reset to factory defaults"),s?{error:s}:void 0}:void 0}})(e,r),b=((e,t)=>{const r=Se(),{apolloConfig:a}=Ge();return{fetchDescribeOdigos:e.GET_DESCRIBE_ODIGOS?async()=>Me(r,e.GET_DESCRIBE_ODIGOS,void 0,t):void 0,fetchDescribeSource:e.GET_DESCRIBE_SOURCE?async a=>Me(r,e.GET_DESCRIBE_SOURCE,a,t):void 0,downloadDiagnose:e.GET_DIAGNOSE?async(n,o)=>{const s=await Me(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),F=((e,t)=>{const r=Se(),{notifyError:a,notifyReadonly:n}=we(I.Source),o=async()=>{e.GET_TOKENS&&await Me(r,e.GET_TOKENS,void 0,t)};return{useTokens:()=>{const e=je("GET_TOKENS",void 0,{fetchPolicy:"cache-first"});return{items:e.data??ze,loading:e.loading,refetch:o}},updateToken:e.UPDATE_TOKEN?async o=>{if(t.isReadonly)return n();const{error:s}=await xe(r,e.UPDATE_TOKEN,{token:o},t);return s&&a(E.Update,s),s?{error:s}:void 0}:void 0}})(e,r),k=((e,t)=>{const r=Se();return{useMetrics:e=>je("GET_METRICS",void 0,e),fetch:async()=>Me(r,e.GET_METRICS,void 0,t)}})(e,r),H=((e,t)=>{const r=Se();return{useServiceMap:e=>je("GET_SERVICE_MAP",void 0,e),fetch:e.GET_SERVICE_MAP?async()=>Me(r,e.GET_SERVICE_MAP,void 0,t):void 0}})(e,r),M=((e,t)=>{const r=Se();return{useSlots:e=>je("GET_PROFILING_SLOTS",void 0,e),useSourceProfiling:(e,t)=>je("GET_SOURCE_PROFILING",e,t),useHotFunctions:(e,t)=>je("GET_PROFILE_HOT_FUNCTIONS",e,t),fetchSlots:e.GET_PROFILING_SLOTS?async()=>Me(r,e.GET_PROFILING_SLOTS,void 0,t):void 0,fetchSourceProfiling:e.GET_SOURCE_PROFILING?async a=>Me(r,e.GET_SOURCE_PROFILING,a,t):void 0,enableProfiling:e.ENABLE_SOURCE_PROFILING?async a=>xe(r,e.ENABLE_SOURCE_PROFILING,a,t):void 0,fetchHotFunctions:e.GET_PROFILE_HOT_FUNCTIONS?async a=>Me(r,e.GET_PROFILE_HOT_FUNCTIONS,a,t):void 0,clearProfileCache:e.CLEAR_PROFILE_CACHE?async()=>xe(r,e.CLEAR_PROFILE_CACHE,void 0,t):void 0}})(e,r),x=((e,t)=>{const r=Se();return{useGatewayInfo:e=>je("GET_GATEWAY_INFO",void 0,e),useGatewayPods:e=>je("GET_GATEWAY_PODS",void 0,e),useNodeCollectorInfo:e=>je("GET_NODE_COLLECTOR_INFO",void 0,e),useNodeCollectorPods:e=>je("GET_NODE_COLLECTOR_PODS",void 0,e),usePodInfo:(e,t)=>je("GET_COLLECTOR_POD_INFO",e,t),getGatewayInfo:e.GET_GATEWAY_INFO?async()=>Me(r,e.GET_GATEWAY_INFO,void 0,t):void 0,getGatewayPods:e.GET_GATEWAY_PODS?async()=>Me(r,e.GET_GATEWAY_PODS,void 0,t):void 0,getNodeCollectorInfo:e.GET_NODE_COLLECTOR_INFO?async()=>Me(r,e.GET_NODE_COLLECTOR_INFO,void 0,t):void 0,getNodeCollectorPods:e.GET_NODE_COLLECTOR_PODS?async()=>Me(r,e.GET_NODE_COLLECTOR_PODS,void 0,t):void 0,getExtendedPodInfo:e.GET_COLLECTOR_POD_INFO?async(a,n)=>Me(r,e.GET_COLLECTOR_POD_INFO,{namespace:a,name:n},t):void 0}})(e,r),V=((e,t)=>{const r=Se(),{notifyError:a,notifySuccess:n,notifyReadonly:o}=we(I.SamplingRule),s=async()=>{e.GET_SAMPLING_RULES&&await Me(r,e.GET_SAMPLING_RULES,void 0,t)},i=(e,i)=>e?async c=>{if(t.isReadonly)return o();const{error:l}=await xe(r,e,c,t);return l?a(i,l):(n(E.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 xe(r,e,{samplingId:l.samplingId,ruleId:c,rule:l.rule},t);return d?a(i,d):(n(E.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 xe(r,e,{samplingId:c,ruleId:i},t);return l?a(E.Delete,l):(n(E.Delete,"Successfully deleted sampling rule"),await s()),l?{error:l}:void 0}:void 0;return{useSamplingRules:()=>{const e=je("GET_SAMPLING_RULES",void 0,{fetchPolicy:"cache-first"});return{items:e.data?.computePlatform?.samplingRules??e.data?.samplingRules??ot,k8sHealthProbesConfig:e.data?.computePlatform?.k8sHealthProbesConfig??e.data?.k8sHealthProbesConfig??null,loading:e.loading,refetch:s}},fetchAll:e.GET_SAMPLING_RULES?async()=>Me(r,e.GET_SAMPLING_RULES,void 0,t):void 0,createNoisy:i(e.CREATE_NOISY_OPERATION_RULE,E.Create),updateNoisy:c(e.UPDATE_NOISY_OPERATION_RULE,E.Update),deleteNoisy:l(e.DELETE_NOISY_OPERATION_RULE),createHighlyRelevant:i(e.CREATE_HIGHLY_RELEVANT_OPERATION_RULE,E.Create),updateHighlyRelevant:c(e.UPDATE_HIGHLY_RELEVANT_OPERATION_RULE,E.Update),deleteHighlyRelevant:l(e.DELETE_HIGHLY_RELEVANT_OPERATION_RULE),createCostReduction:i(e.CREATE_COST_REDUCTION_RULE,E.Create),updateCostReduction:c(e.UPDATE_COST_REDUCTION_RULE,E.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 xe(r,e.UPDATE_LOCAL_UI_SAMPLING_CONFIG,{config:{k8sHealthProbesSampling:n}},t);return i?a(E.Update,i):await s(),i?{error:i}:void 0}:void 0}})(e,r),Y=((e,t)=>{const r=Se(),{notifyError:a,notifySuccess:n,notifyReadonly:o}=we(I.Recommendation),s=async()=>{e.GET_RECOMMENDATIONS&&await Me(r,e.GET_RECOMMENDATIONS,void 0,t)};return{useRecommendations:()=>{const e=je("GET_RECOMMENDATIONS",void 0,{fetchPolicy:"cache-first"});return{items:e.data?.computePlatform?.recommendations??e.data?.recommendations??St,loading:e.loading,refetch:s}},fetchAll:e.GET_RECOMMENDATIONS?async()=>Me(r,e.GET_RECOMMENDATIONS,void 0,t):void 0,setDismissed:e.SET_RECOMMENDATION_DISMISSED?async(i,c)=>{if(t.isReadonly)return o(),{error:d.READONLY_WARNING};const{error:l}=await xe(r,e.SET_RECOMMENDATION_DISMISSED,{name:i,dismissed:c},t);return l?a(E.Update,l):(n(E.Update,c?v:C),await s()),l?{error:l}:void 0}:void 0,applyRemediation:e.APPLY_RECOMMENDATION_REMEDIATION?async(i,c)=>{if(t.isReadonly)return o(),{error:d.READONLY_WARNING};const{data:l,error:u}=await xe(r,e.APPLY_RECOMMENDATION_REMEDIATION,{recommendationType:i,remediationType:c},t),S=u||!l?.applyRecommendationRemediation;return S?a(E.Update,u||G):(n(E.Update,h),await s()),S?{error:u||G}:void 0}:void 0}})(e,r),K=((e,r)=>{const a=Se();return{useSnapshots:()=>{const e=r.proxyID,a=!!e,o=je("GET_ALL_CLUSTER_SNAPSHOTS",void 0,{fetchPolicy:"cache-and-network",skip:a}),s=je("GET_CLUSTER_SNAPSHOT",e?{clusterId:e}:void 0,{fetchPolicy:"cache-and-network",skip:!a}),i=t(()=>a?ct(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:ct(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()=>Me(a,e.GET_ALL_CLUSTER_SNAPSHOTS,void 0,r):void 0,getClusterSnapshot:e.GET_CLUSTER_SNAPSHOT?async t=>Me(a,e.GET_CLUSTER_SNAPSHOT,{clusterId:t},r):void 0}})(e,r);return{sourcesApi:o,destinationsApi:i,actionsApi:c,instrumentationRulesApi:u,dataStreamsApi:m,namespacesApi:O,k8sManifestApi:w,configApi:U,describeApi:b,tokensApi:F,metricsApi:k,serviceMapApi:H,profilingApi:M,collectorsApi:x,samplingApi:V,recommendationsApi:Y,snapshotsApi:K,insightsApi:st(e,r),capabilities:t(()=>((e,t)=>{const r=t.platformType===T.K8s,a=r,n=r,o=t.platformType===T.Vm,s=!o,i=!(t.platformType===T.Connector);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,canFetchInstrumentationInstructions:!!e.GET_INSTRUMENTATION_INSTRUCTIONS,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,canManageActions:i&&!!e.GET_ACTIONS,canCreateAction:i&&!!e.CREATE_ACTION,canFetchActionTypes:i&&!!e.GET_ACTION_TYPES,canManageInstrumentationRules:i&&!!e.GET_INSTRUMENTATION_RULES,canCreateInstrumentationRule:i&&!!e.CREATE_INSTRUMENTATION_RULE,canFetchInstrumentationRuleTypes:i&&!!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,canManageInsightsPolicies:!!e.GET_INSIGHTS_POLICIES,canFetchInsights:!!e.GET_INSIGHTS_FINDINGS,canManageRecommendations:a&&!!e.GET_RECOMMENDATIONS}})(e,r),[e,r]),resetCache:n(async()=>{await a.cache.reset()},[a])}},It={type:"",disabled:!1,name:"",notes:"",signals:[],fields:{}},Tt=a(null),pt=e=>e?.length?e.map(e=>!e.fromSources?.length&&e.from?{...e,fromSources:[e.from]}:e):e,_t=(e,t)=>{const r=U(e??{}),a=r[F.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[F.LabelsAttributes]&&(r[F.LabelsAttributes]=pt(r[F.LabelsAttributes])),r[F.AnnotationsAttributes]&&(r[F.AnnotationsAttributes]=pt(r[F.AnnotationsAttributes])),r[F.UrlTemplatizationRulesGroups]&&(r[F.UrlTemplatizationRulesGroups]=(n=r[F.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===k.SourceScopes).map(e=>e.name));return void 0!==r[F.Scopes]&&o.add(F.Scopes),o.forEach(e=>{const t=e;r[t]=re(r[t])}),r},ft="All row fields are required",Nt="At least one row is required",yt=(e,t)=>!!e&&t.every(t=>{const r=e[t];return Array.isArray(r)?r.length>0:!("string"==typeof(a=r)?!a.trim():M(a));var a}),At=({children:r,sourceOptions:a=[],namespaceOptions:s=[]})=>{const[i,c]=o(null),l=w(It),u=n(e=>{l.resetFormData(),l.handleErrorChange(void 0,void 0,{}),e?.type&&l.handleFormChange("type",e.type),c(e)},[]),S=n((e,t)=>{const r=t??(a=e.type,b.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:_t(o,s)}))(e,r)),l.handleErrorChange(void 0,void 0,{}),c(r)},[]),m=n(()=>{if(!i)return{errorMessage:"No action type selected",preparedFormData:U(It)};const e=((e,t)=>{const r=U(e),a=r.fields||{},n=a[F.UrlTemplatizationRulesGroups];n?.length&&(a[F.UrlTemplatizationRulesGroups]=n.map(e=>({...e,templatizationRules:(e.templatizationRules||[]).filter(e=>!!e.template?.trim())})));const o=a[F.AttributeNamesToDelete];o?.length&&(a[F.AttributeNamesToDelete]=o.filter(e=>!!e?.trim()));const s=a[F.Renames];if(s){const e=Array.isArray(s)?s.map(e=>[e?.key??"",e?.value??""]):Object.entries(s);a[F.Renames]=Object.fromEntries(e.filter(([e,t])=>!!e?.trim()&&!!t?.trim()))}const i=new Set((t?.fields||[]).filter(e=>e.componentType===k.SourceScopes).map(e=>e.name));void 0!==a[F.Scopes]&&i.add(F.Scopes),i.forEach(e=>{const t=a[e];void 0!==t&&(a[e]=te(t)?null:t)});const c=a[F.ExtractAttribute];return c?.extractions?.length&&(a[F.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 M(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 H.K8sAttributes:{const e=!(n[F.CollectContainerAttributes]||n[F.CollectReplicaSetAttributes]||n[F.CollectWorkloadId]||n[F.CollectClusterId]),t=!n[F.LabelsAttributes]?.length,r=!n[F.AnnotationsAttributes]?.length;e&&t&&r&&(a[F.CollectContainerAttributes]="Enable at least one option or add a label/annotation row");const o=n[F.LabelsAttributes];o?.some(e=>!yt(e,["labelKey","attributeKey","fromSources"]))&&(a[F.LabelsAttributes]=ft);const s=n[F.AnnotationsAttributes];s?.some(e=>!yt(e,["annotationKey","attributeKey","fromSources"]))&&(a[F.AnnotationsAttributes]=ft);break}case H.AddClusterInfo:{const e=n[F.ClusterAttributes];e?.length?e.some(e=>!yt(e,["attributeName","attributeStringValue"]))&&(a[F.ClusterAttributes]=ft):a[F.ClusterAttributes]=Nt;break}case H.DeleteAttributes:{const e=o[F.AttributeNamesToDelete]||[],t=n[F.AttributeNamesToDelete]||[];t.length?e.length>t.length&&(a[F.AttributeNamesToDelete]=ft):a[F.AttributeNamesToDelete]=e.length?ft:Nt;break}case H.RenameAttributes:{const e=Object.entries(o[F.Renames]||{}),t=Object.entries(n[F.Renames]||{}),r=e.some(([e,t])=>!e?.trim()||!t?.trim());t.length?r&&(a[F.Renames]=ft):a[F.Renames]=e.length?ft:Nt;break}case H.PiiMasking:{const e=n[F.PiiCategories];e?.length||(a[F.PiiCategories]="Select at least one attribute to mask");break}case H.URLTemplatization:{const e=n[F.UrlTemplatizationRulesGroups];(!e?.length||e.some(e=>!e.templatizationRules?.length))&&(a[F.UrlTemplatizationRulesGroups]="Each rule group needs at least one non-blank template");break}case H.ExtractAttribute:{const e=n[F.ExtractAttribute]?.extractions||[],t=o[F.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[F.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[F.ExtractAttribute]="Each new span attribute name must be unique")}else a[F.ExtractAttribute]=t.length?ft:Nt;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]),E=t(()=>({selectedOption:i,onSelectOption:u,loadAction:S,genericForm:l,validateFormData:m,sourceOptions:a,namespaceOptions:s}),[i,u,S,l,m,a,s]);return e(Tt.Provider,{value:E,children:r})},Rt=()=>{const e=r(Tt);if(!e)throw new Error("useActionFormContext must be used within an ActionFormContextProvider");return e},Ot={provider:"",permission:"",customCapabilities:{},authMethod:"",setupMethod:"",accountId:"",credentials:{},accessToken:"",secretId:"",name:""},gt=a(null),Gt=({children:r,providers:a=[]})=>{const o=w(Ot),s=n(()=>{const e=U(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(gt.Provider,{value:i,children:r})},ht=()=>{const e=r(gt);if(!e)throw new Error("useCloudConnectorFormContext must be used within a CloudConnectorFormContextProvider");return e},vt={name:""},Ct=a(null),Lt=({children:r,defaultExcludeName:a=""})=>{const{dataStreams:s}=p(),[c,l]=o(void 0),[u,S]=o(a),[m,E]=o(void 0),[I,T]=o(null),_=i(null),f=w(vt),N=n(e=>{f.resetFormData({name:e}),f.handleErrorChange(void 0,void 0,{}),l(void 0),S(e),E(e),T(null),_.current=null},[]),y=n(()=>{const e=U(f.formData),t=(e=>{const t={};return e.name?x(e.name)||(t.name=d.ILLEGAL_K8S_LABEL):t.name=d.FIELD_IS_REQUIRED,t})(e);f.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}},[f]),A=n(async e=>{const{errorMessage:t,preparedFormData:r}=y();if(t)return;const a=s.find(e=>e.name===r.name&&e.name!==u);if(a)return _.current=e,void T({preparedFormData:r,existingName:a.name,editingName:m});await e(r)},[y,s,u,m]),R=n(async()=>{const e=_.current,t=I?.preparedFormData;_.current=null,T(null),e&&t&&await e(t)},[I]),O=n(()=>{_.current=null,T(null)},[]),g=t(()=>({genericForm:f,loadDataStream:N,editingName:m,validateFormData:y,requestSubmit:A,pendingMerge:I,confirmMerge:R,cancelMerge:O,errorMessage:c,excludeName:u,setExcludeName:S}),[f,N,m,y,A,I,R,O,c,u]);return e(Ct.Provider,{value:g,children:r})},Dt=()=>{const e=r(Ct);if(!e)throw new Error("useDataStreamFormContext must be used within a DataStreamFormContextProvider");return e},Pt={type:"",name:"",currentStreamName:"",disabled:!1,exportedSignals:{logs:!1,metrics:!1,traces:!1,profiles:!1},fields:[]},wt={activeForm:null,onChangeActiveForm:()=>{},loadDestination:()=>{},genericForm:void 0,validateFormData:()=>({isOk:!1,preparedFormData:U(Pt)}),unsavedDestinations:[],thisUnsavedDestination:void 0,setUnsavedDestinations:()=>{},addUnsavedDestination:()=>{},updateUnsavedDestination:()=>{},deleteUnsavedDestination:()=>{}},Ut=a(wt),bt=e=>e.filter(e=>!!e).map(e=>{const{name:t,componentType:r,componentProperties:a,displayName:n,initialValue:o,renderCondition:s}=e,i=r===k.Dropdown,c=B(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}}),Ft=({children:r})=>{const{selectedStreamName:a}=p(),{items:i}=Et().destinationsApi.useDestinations(),[c,l]=o(null),[u,S]=o(wt.unsavedDestinations),m=t(()=>"number"==typeof c?.unsavedIdx?u[c.unsavedIdx]:void 0,[c,u]),E=n((e,t)=>{c&&(S(t=>[...t,{...e,option:c.option}]),l(t?e=>e?{...e,listType:V.UNSAVED,unsavedIdx:u.length}:null:null))},[c,u.length]),I=n((e,t,r)=>{c&&(S(r=>r.map((r,a)=>a===e?{...r,...t,option:c.option}:r)),l(r?e=>e?{...e,listType:V.UNSAVED}:null:null))},[c]),T=n(e=>{S(t=>t.filter((t,r)=>r!==e)),l(null)},[]),_=w({...Pt,currentStreamName:a});s(()=>{if(!c)return;if(m)return void _.resetFormData({...m.formData});if(c.listType===V.EXISTS&&c.option.id){const e=i.find(e=>e.id===c.option.id);if(e)return void _.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=Y(c.option.supportedSignals);_.resetFormData({type:c.option.type,name:c.option.displayName,currentStreamName:a,disabled:!1,exportedSignals:{logs:e.includes(K.Logs),metrics:e.includes(K.Metrics),traces:e.includes(K.Traces),profiles:e.includes(K.Profiles)},fields:c.dynamicFields.map(e=>({key:e.name,value:e.value}))})},[c,m]);const f=n(e=>{_.resetFormData(),_.handleErrorChange(void 0,void 0,{}),l(e?{...e,dynamicFields:e.option?.fields?bt(e.option.fields):[]}:null)},[]),N=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=B(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=bt(n.fields);l({listType:V.EXISTS,option:n,dynamicFields:o})},[]),y=n(()=>{const e=U(_.formData),t={};return c?.dynamicFields.forEach(({name:r,required:a})=>{if(a){const a=e.fields.find(e=>e.key===r)?.value;M(a)&&(t[r]=d.FIELD_IS_REQUIRED)}}),$(e.exportedSignals).length||(t.exportedSignals=d.FIELD_IS_REQUIRED),_.handleErrorChange(void 0,void 0,t),{errorMessage:0===Object.keys(t).length?void 0:"Invalid form values",preparedFormData:e}},[_,c]);return e(Ut.Provider,{value:{activeForm:c,onChangeActiveForm:f,loadDestination:N,genericForm:_,validateFormData:y,unsavedDestinations:u,thisUnsavedDestination:m,setUnsavedDestinations:S,addUnsavedDestination:E,updateUnsavedDestination:I,deleteUnsavedDestination:T},children:r})},kt=()=>r(Ut),Ht={disabled:!1,ruleName:"",notes:"",sourceScopes:ae(),workloads:null,instrumentationLibraries:null,payloadCollection:null,codeAttributes:null,headersCollection:null,customInstrumentations:null,networkMetrics:null},Mt=a(null),xt=({children:r,sourceOptions:a=[],namespaceOptions:s=[]})=>{const[i,c]=o(null),l=w(Ht),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:re(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,W.find(e=>e.type===r)??null))},[]),S=n(()=>{if(!i)return{errorMessage:"No rule type selected",preparedFormData:U(Ht)};const e=((e,t)=>{const r=U(e),{workloads:a,...n}=r,o={...n,sourceScopes:te(r.sourceScopes)?null:r.sourceScopes,...a?.length?{workloads:a}:{}};return o.headersCollection?.[j.HeaderKeys]?.length&&(o.headersCollection[j.HeaderKeys]=o.headersCollection[j.HeaderKeys].map(e=>e.trim()).filter(e=>e)),o.customInstrumentations?.[q.Golang]?.length&&(o.customInstrumentations[q.Golang]=o.customInstrumentations[q.Golang].map(e=>new Q(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})),o.customInstrumentations?.[q.Java]?.length&&(o.customInstrumentations[q.Java]=o.customInstrumentations[q.Java].map(e=>new z(e.className,e.methodName)).filter(e=>{return t=e,!(!t.className?.trim()&&!t.methodName?.trim());var t})),o.customInstrumentations?.[q.Php]?.length&&(o.customInstrumentations[q.Php]=o.customInstrumentations[q.Php].map(e=>new J(e.className,e.functionName)).filter(e=>{return t=e,!(!t.className?.trim()&&!t.functionName?.trim());var t})),t===X.NetworkMetrics&&(o.networkMetrics=!0),o})(l.formData,i.type),t=((e,t)=>{const r={};switch(e){case X.CodeAttributes:Object.values(t.codeAttributes||{}).some(e=>null!=e)||(r.codeAttributes="Code attributes are required");break;case X.PayloadCollection:Object.values(t.payloadCollection||{}).some(e=>null!=e)||(r.payloadCollection="Payload collection are required");break;case X.HeadersCollection:t.headersCollection?.[j.HeaderKeys]?.length||(r.headersCollection="Header keys are required");break;case X.CustomInstrumentation:{const e=t.customInstrumentations?.[q.Golang]||[],a=t.customInstrumentations?.[q.Java]||[],n=t.customInstrumentations?.[q.Php]||[];if(!e.length&&!a.length&&!n.length){r.customInstrumentations="Custom instrumentation are required";break}const o=e.findIndex(e=>!new Q(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 z(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 J(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]),m=t(()=>({selectedOption:i,onSelectOption:d,loadRule:u,genericForm:l,validateFormData:S,sourceOptions:a,namespaceOptions:s}),[i,d,u,l,S,a,s]);return e(Mt.Provider,{value:m,children:r})},Vt=()=>{const e=r(Mt);if(!e)throw new Error("useRuleFormContext must be used within a RuleFormContextProvider");return e};var Yt;(e=>{e.Create="create",e.View="view",e.EditAutoNoisy="edit-auto-noisy",e.EditAutoCostReduction="edit-auto-cost-reduction",e.EditAutoHighlyRelevant="edit-auto-highly-relevant"})(Yt||(Yt={}));const Kt=a(null),Bt=["50","25","10","1"];function $t(e){const t=String(e);return Bt.includes(t)?t:"custom"}const Wt=({category:r,sourceOptions:a=[],namespaceOptions:i=[],children:c})=>{const{formData:l,handleFormChange:d,resetFormData:u}=w(ce(r)),[S,m]=o(null);s(()=>{u(ce(r)),m(null)},[r]);const E=n(e=>{m(null),d(void 0,void 0,{...l,...e})},[l,d]),I=n(()=>{u(ce(r)),m(null)},[r,u]),T=t(()=>({formType:Yt.Create,category:r,formData:l,handleChange:E,resetForm:I,duplicateWarning:S,setDuplicateWarning:m,sourceOptions:a,namespaceOptions:i}),[r,l,E,I,S,a,i]);return e(Kt.Provider,{value:T,children:c})},jt=({data:r,defaultEditMode:a,sourceOptions:c=[],namespaceOptions:l=[],children:d})=>{const[u,S]=o(!1),{formData:m,handleFormChange:E,resetFormData:I}=w(void 0),T=i(null),[p,_]=o(null);s(()=>{r!==T.current&&(T.current=r,r&&a?(I(ie(r)),_(null),S(!0)):(S(!1),_(null)))},[r,a]);const f=n(e=>{_(null),E(void 0,void 0,{...m,...e})},[m,E]),N=n(()=>{r&&(I(ie(r)),_(null),S(!0))},[r,I]),y=n(()=>{S(!1),_(null)},[]),A=t(()=>({formType:Yt.View,data:r,isEditing:u,formData:m,handleChange:f,handleEdit:N,handleCancelEdit:y,duplicateWarning:p,setDuplicateWarning:_,sourceOptions:c,namespaceOptions:l}),[r,u,m,f,N,y,p,c,l]);return e(Kt.Provider,{value:A,children:d})};function qt(e){const[r,a]=o(()=>0===e?"all":"sample"),[n,i]=o(()=>$t(e)),[c,l]=o(()=>"custom"===$t(e)?String(e):"");s(()=>{a(0===e?"all":"sample");const t=$t(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 Qt=({enabled:r,keepPercentage:a,children:n})=>{const[i,c]=o(r),l=qt(a);s(()=>{c(r)},[r]);const d=t(()=>se({enabled:i,keepPercentage:l.resolvedPercentage}),[i,l.resolvedPercentage]),u=t(()=>({formType:Yt.EditAutoNoisy,localEnabled:i,setLocalEnabled:c,...l,summary:d}),[i,l,d]);return e(Kt.Provider,{value:u,children:n})},zt=({enabled:r,dropPercentage:a,children:n})=>{const[i,c]=o(r),l=qt(a);s(()=>{c(r)},[r]);const d=t(()=>oe(i?{disabled:!1,percentageAtMost:l.resolvedPercentage}:null),[i,l.resolvedPercentage]),u=t(()=>({formType:Yt.EditAutoCostReduction,localEnabled:i,setLocalEnabled:c,...l,summary:d}),[i,l,d]);return e(Kt.Provider,{value:u,children:n})},Jt=({enabled:r,children:a})=>{const[n,i]=o(r);s(()=>{i(r)},[r]);const c=t(()=>ne(n?{disabled:!1}:null),[n]),l=t(()=>({formType:Yt.EditAutoHighlyRelevant,localEnabled:n,setLocalEnabled:i,summary:c}),[n,c]);return e(Kt.Provider,{value:l,children:a})},Xt=t=>{switch(t.formType){case Yt.Create:return e(Wt,{...t});case Yt.View:return e(jt,{...t});case Yt.EditAutoNoisy:return e(Qt,{...t});case Yt.EditAutoCostReduction:return e(zt,{...t});case Yt.EditAutoHighlyRelevant:return e(Jt,{...t})}};function Zt(e){const t=r(Kt);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 er={otelServiceName:"",currentStreamName:""},tr=a(null),rr=({children:r})=>{const[a,s]=o(void 0),i=w(er),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=U(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(tr.Provider,{value:d,children:r})},ar=()=>{const e=r(tr);if(!e)throw new Error("useSourceEditFormContext must be used within a SourceEditFormContextProvider");return e},nr=new Set([Z.StaticPod]),or=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}},sr=(e,t,r)=>{if(t&&!e.name.toLowerCase().includes(t.toLowerCase()))return!1;if(r.showOnlySelected){const{isAllSourced:t,isSomeSourced:r,isFutureApps:a}=or(e);return t||r||a}return!0},ir=(e,t,r)=>!(t&&!e.name.toLowerCase().includes(t.toLowerCase()))&&(!r.showOnlySelected||e.selected),cr=a({snapshots:null,setSnapshots:()=>{},isFetching:!1,setIsFetching:()=>{},formData:[],handleSourceChange:()=>{},handleSelectAll:()=>{},formDiff:{},isFormDirty:!1}),lr=(e,t)=>`${e}\0${t}`,dr=(e,t,r,a)=>`${e}\0${t}\0${r}/${a}`,ur=(e,t)=>e.name===t.name&&e.kind===t.kind&&(e.region??"")===(t.region??""),Sr=(e,t,r)=>{const a=[];return t.workloads.forEach(n=>{const o=e?.workloads.find(e=>ur(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},mr=({children:r,selectedConnectionIds:a,initialInputs:c})=>{const{tier:l}=le(),d=l===ee.Onprem,{capabilities:u}=Et(),S=u.canInstrumentNamespaces,{selectedStreamName:m}=p(),[E,T]=o(!1),[_,f]=o(null),[N,y]=o([]),A=i(new Set),R=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&&A.current.add(lr(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&&A.current.add(dr(t.clusterId,e.name,r.kind,r.name))}))})})},[]);s(()=>{_&&y(e=>{const t=((e,t)=>U(((e,t)=>e.clusters.filter(({clusterId:e})=>!t||t.includes(e)))(e,t)))(_,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(lr(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(dr(e.clusterId,t.name,a.kind,a.name));return n&&s?{...a,selected:n.selected}:a})}})}})(t,r,A.current);if(c?.[t.clusterId]){const e=c[t.clusterId],r=U(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=>{nr.has(e.kind)&&!d||(e.selected=!0)})}),r}return a})})},[_,a,c]);const{formDiff:O,isFormDirty:g}=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=Sr(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=Sr(s,o,r);t.length>0&&(n[e.clusterId]||(n[e.clusterId]=[]),n[e.clusterId].push(...t))}})}),n})(N,_?.clusters||[],m,S);return{formDiff:e,isFormDirty:Object.keys(e).length>0}},[N,_,m,S]),G=n(e=>!d&&nr.has(e),[d]),h=n(({clusterId:e,workloadId:t,selected:r,auto:a})=>{y(n=>{const o=U(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=>ur(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,S&&(a?o[s].namespaces[i].workloads.filter(e=>!G(e.kind)).every(e=>e.selected)&&(o[s].namespaces[i].selected=!0):o[s].namespaces[i].selected=!1)}else if(S){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=>{G(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&&G(t.kind)||(t.selected=e)})}return R(n,o),o})},[G,S,R]),v=n(({clusterId:e,namespaceName:t,boolean:r,searchText:a="",searchBy:n="",filters:o})=>{y(s=>{const i=U(s),c=n===I.Namespace?a:"",l=n===I.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&&G(e.kind)||ir(e,l,o||{showOnlySelected:!1})&&(i[n].namespaces[s].workloads[t].selected=r)}),S){const e=i[n].namespaces[s].workloads.filter(e=>!G(e.kind)).every(e=>e.selected);i[n].namespaces[s].selected=e}}else{if(!sr(i[n].namespaces[s],c,o||{showOnlySelected:!1}))return;S&&(i[n].namespaces[s].selected=r),a.forEach((e,t)=>{r&&G(e.kind)||(i[n].namespaces[s].workloads[t].selected=r)})}else S&&(i[n].namespaces[s].selected=r),a.forEach((e,t)=>{r&&G(e.kind)||(i[n].namespaces[s].workloads[t].selected=r)})})}),R(s,i),i})},[G,S,R]);return e(cr.Provider,{value:{snapshots:_,setSnapshots:f,isFetching:E,setIsFetching:T,formData:N,handleSourceChange:h,handleSelectAll:v,formDiff:O,isFormDirty:g},children:r})},Er=()=>r(cr);export{At as A,Gt as C,Lt as D,nr as E,De as O,xt as R,Yt as S,Ve as a,Ft as b,he as c,Xt as d,rr as e,mr as f,Je as g,Rt as h,qe as i,Qe as j,je as k,ht as l,Dt as m,kt as n,Et as o,Xe as p,Vt as q,xe as r,Zt as s,ar as t,Ge as u,Er as v,ir as w,sr as x,or as y};
@@ -1,11 +0,0 @@
1
- import { type FC, type ReactNode } from 'react';
2
- import type { SVG } from '../../../../types';
3
- export interface SettingsContentPanelProps {
4
- icon?: SVG;
5
- title: string;
6
- /** Optional count badge shown next to the title. */
7
- count?: number;
8
- description?: string;
9
- children: ReactNode;
10
- }
11
- export declare const SettingsContentPanel: FC<SettingsContentPanelProps>;