@odigos/ui-kit 0.0.249 → 0.0.251

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 (140) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/docs/api-context.md +687 -0
  3. package/lib/chunks/connections-scope-CneIqjeg.js +1 -0
  4. package/lib/chunks/flow-CQi_KYfs.js +49 -0
  5. package/lib/chunks/helpers-K1tnyqhm.js +19 -0
  6. package/lib/chunks/{index-CRKgHzab.js → index-Dv0RvKAp.js} +8 -8
  7. package/lib/chunks/source-instrument-form-context-C79I_5cH.js +1 -0
  8. package/lib/chunks/{ui-components-DODwSdKu.js → ui-components-BKrLf2tx.js} +214 -214
  9. package/lib/chunks/use-odigos-api-CDHW7ekQ.js +5 -0
  10. package/lib/chunks/vendor-BFqT13Me.js +1 -0
  11. package/lib/components/_v2/segment/index.d.ts +4 -2
  12. package/lib/components/v2.js +1 -1
  13. package/lib/components.js +1 -1
  14. package/lib/constants/strings/index.d.ts +7 -0
  15. package/lib/constants.js +1 -1
  16. package/lib/containers/_v2/_drawers/add-action-drawer/index.d.ts +0 -2
  17. package/lib/containers/_v2/_drawers/add-destination-drawer/form-column/index.d.ts +1 -5
  18. package/lib/containers/_v2/_drawers/add-destination-drawer/index.d.ts +0 -6
  19. package/lib/containers/_v2/_drawers/add-destination-drawer/lists-filters/index.d.ts +2 -1
  20. package/lib/containers/_v2/_drawers/add-rule-drawer/index.d.ts +0 -2
  21. package/lib/containers/_v2/_drawers/add-source-drawer/index.d.ts +1 -4
  22. package/lib/containers/_v2/_drawers/edit-action-drawer/index.d.ts +0 -3
  23. package/lib/containers/_v2/_drawers/edit-config-drawer/index.d.ts +1 -3
  24. package/lib/containers/_v2/_drawers/edit-destination-drawer/index.d.ts +0 -5
  25. package/lib/containers/_v2/_drawers/edit-rule-drawer/index.d.ts +0 -3
  26. package/lib/containers/_v2/_drawers/edit-source-drawer/debug/index.d.ts +1 -2
  27. package/lib/containers/_v2/_drawers/edit-source-drawer/index.d.ts +3 -14
  28. package/lib/containers/_v2/_drawers/edit-source-drawer/overview/containers-card/index.d.ts +1 -2
  29. package/lib/containers/_v2/_drawers/edit-source-drawer/overview/index.d.ts +0 -2
  30. package/lib/containers/_v2/_drawers/edit-source-drawer/peers/index.d.ts +1 -6
  31. package/lib/containers/_v2/_drawers/edit-source-drawer/profiling/index.d.ts +1 -15
  32. package/lib/containers/_v2/_drawers/edit-source-drawer/sampling/index.d.ts +8 -0
  33. package/lib/containers/_v2/_drawers/edit-source-drawer/sampling/rule-row.d.ts +8 -0
  34. package/lib/containers/_v2/_drawers/edit-source-drawer/tabs.d.ts +1 -0
  35. package/lib/containers/_v2/_drawers/system-drawer/describe/index.d.ts +1 -8
  36. package/lib/containers/_v2/_drawers/system-drawer/diagnose/index.d.ts +1 -4
  37. package/lib/containers/_v2/_drawers/system-drawer/index.d.ts +1 -4
  38. package/lib/containers/_v2/_drawers/system-drawer/tokens/index.d.ts +1 -2
  39. package/lib/containers/_v2/_forms/add-destination-form/index.d.ts +1 -2
  40. package/lib/containers/_v2/_modals/add-data-stream-modal/index.d.ts +0 -3
  41. package/lib/containers/_v2/_modals/edit-data-stream-modal/index.d.ts +0 -2
  42. package/lib/containers/_v2/_modals/sampling-onboarding-modal/types.d.ts +1 -4
  43. package/lib/containers/_v2/central-connections/index.d.ts +1 -12
  44. package/lib/containers/_v2/onboarding/index.d.ts +0 -8
  45. package/lib/containers/_v2/overview/columns/column/head.d.ts +1 -1
  46. package/lib/containers/_v2/overview/columns/column/index.d.ts +2 -1
  47. package/lib/containers/_v2/overview/columns/index.d.ts +1 -8
  48. package/lib/containers/_v2/overview/data-stream-select/index.d.ts +1 -10
  49. package/lib/containers/_v2/overview/drawers/index.d.ts +2 -29
  50. package/lib/containers/_v2/overview/index.d.ts +2 -8
  51. package/lib/containers/_v2/overview/multi-source-control/index.d.ts +1 -5
  52. package/lib/containers/_v2/pipeline-collectors/index.d.ts +0 -7
  53. package/lib/containers/_v2/pipeline-collectors/pods-info/index.d.ts +1 -2
  54. package/lib/containers/_v2/pipeline-collectors/pods-info/pod-drawer/index.d.ts +1 -2
  55. package/lib/containers/_v2/sampling-rules/helpers.d.ts +2 -0
  56. package/lib/containers/_v2/sampling-rules/types.d.ts +2 -16
  57. package/lib/containers/_v2/settings/index.d.ts +0 -9
  58. package/lib/containers/service-map/index.d.ts +4 -2
  59. package/lib/containers/v2.js +197 -166
  60. package/lib/containers.js +7 -7
  61. package/lib/contexts/index.d.ts +1 -0
  62. package/lib/contexts/odigos-api/capabilities.d.ts +38 -0
  63. package/lib/contexts/odigos-api/client.d.ts +22 -0
  64. package/lib/contexts/odigos-api/connections-scope.d.ts +18 -0
  65. package/lib/contexts/odigos-api/hooks/use-actions-api.d.ts +26 -0
  66. package/lib/contexts/odigos-api/hooks/use-collectors-api.d.ts +25 -0
  67. package/lib/contexts/odigos-api/hooks/use-config-api.d.ts +24 -0
  68. package/lib/contexts/odigos-api/hooks/use-data-streams-api.d.ts +26 -0
  69. package/lib/contexts/odigos-api/hooks/use-describe-api.d.ts +33 -0
  70. package/lib/contexts/odigos-api/hooks/use-destinations-api.d.ts +50 -0
  71. package/lib/contexts/odigos-api/hooks/use-instrumentation-rules-api.d.ts +35 -0
  72. package/lib/contexts/odigos-api/hooks/use-k8s-manifest-api.d.ts +14 -0
  73. package/lib/contexts/odigos-api/hooks/use-metrics-api.d.ts +13 -0
  74. package/lib/contexts/odigos-api/hooks/use-namespace-api.d.ts +30 -0
  75. package/lib/contexts/odigos-api/hooks/use-profiling-api.d.ts +17 -0
  76. package/lib/contexts/odigos-api/hooks/use-sampling-api.d.ts +39 -0
  77. package/lib/contexts/odigos-api/hooks/use-service-map-api.d.ts +13 -0
  78. package/lib/contexts/odigos-api/hooks/use-snapshots-api.d.ts +13 -0
  79. package/lib/contexts/odigos-api/hooks/use-sources-api.d.ts +75 -0
  80. package/lib/contexts/odigos-api/hooks/use-tokens-api.d.ts +12 -0
  81. package/lib/contexts/odigos-api/index.d.ts +37 -0
  82. package/lib/contexts/odigos-api/internal/notify.d.ts +49 -0
  83. package/lib/contexts/odigos-api/internal/source-payloads.d.ts +53 -0
  84. package/lib/contexts/odigos-api/platform-helpers.d.ts +98 -0
  85. package/lib/contexts/odigos-api/provider.d.ts +28 -0
  86. package/lib/contexts/odigos-api/runner.d.ts +32 -0
  87. package/lib/contexts/odigos-api/types.d.ts +831 -0
  88. package/lib/contexts/odigos-api/use-api-for-connections.d.ts +43 -0
  89. package/lib/contexts/odigos-api/use-api-query.d.ts +130 -0
  90. package/lib/contexts/odigos-api/use-odigos-api.d.ts +103 -0
  91. package/lib/contexts/odigos-api.js +1 -0
  92. package/lib/contexts/odigos-context.d.ts +2 -2
  93. package/lib/contexts/storybook-context.d.ts +2 -2
  94. package/lib/contexts.js +1 -1
  95. package/lib/functions.js +1 -1
  96. package/lib/hooks.js +1 -1
  97. package/lib/icons/destinations/open-telemetry-logo/index.d.ts +2 -1
  98. package/lib/snippets/_v2/sampling-rule-form-sections/preset-with-custom-input.d.ts +1 -1
  99. package/lib/snippets/v2.js +1 -1
  100. package/lib/snippets.js +1 -49
  101. package/lib/store/index.d.ts +0 -1
  102. package/lib/store/useDrawerStore.d.ts +6 -1
  103. package/lib/store.js +1 -1
  104. package/lib/theme.js +1 -1
  105. package/lib/types/actions/index.d.ts +0 -5
  106. package/lib/types/common/index.d.ts +29 -4
  107. package/lib/types/destinations/index.d.ts +0 -10
  108. package/lib/types/index.d.ts +0 -1
  109. package/lib/types/instrumentation-rules/index.d.ts +0 -5
  110. package/lib/types/namespaces/index.d.ts +0 -5
  111. package/lib/types/pipeline-collectors/index.d.ts +0 -5
  112. package/lib/types/snapshot/index.d.ts +0 -2
  113. package/lib/types/sources/index.d.ts +0 -30
  114. package/lib/types/tokens/index.d.ts +0 -6
  115. package/lib/types/workload/index.d.ts +46 -22
  116. package/lib/types.js +1 -1
  117. package/lib/visuals.js +1 -1
  118. package/package.json +31 -22
  119. package/lib/chunks/helpers-IEFhGXc7.js +0 -19
  120. package/lib/chunks/source-instrument-form-context-DjIHPYQJ.js +0 -1
  121. package/lib/chunks/vendor-Be0cOokr.js +0 -1
  122. package/lib/mock-data/actions/index.d.ts +0 -2
  123. package/lib/mock-data/config/index.d.ts +0 -3
  124. package/lib/mock-data/connections/index.d.ts +0 -2
  125. package/lib/mock-data/describe/index.d.ts +0 -3
  126. package/lib/mock-data/destinations/index.d.ts +0 -4
  127. package/lib/mock-data/index.d.ts +0 -15
  128. package/lib/mock-data/instrumentation-instances/index.d.ts +0 -2
  129. package/lib/mock-data/instrumentation-rules/index.d.ts +0 -2
  130. package/lib/mock-data/namespaces/index.d.ts +0 -2
  131. package/lib/mock-data/pipeline-collectors/index.d.ts +0 -6
  132. package/lib/mock-data/profiling/index.d.ts +0 -8
  133. package/lib/mock-data/service-map/index.d.ts +0 -4
  134. package/lib/mock-data/snapshot/index.d.ts +0 -5
  135. package/lib/mock-data/sources/index.d.ts +0 -4
  136. package/lib/mock-data/sources/yamls.d.ts +0 -22
  137. package/lib/mock-data/tokens/index.d.ts +0 -2
  138. package/lib/mock-data/traces/index.d.ts +0 -2
  139. package/lib/store/useEntityStore.d.ts +0 -24
  140. package/lib/types/k8s-manifest/index.d.ts +0 -2
@@ -1,9 +1,5 @@
1
1
  import { ProgrammingLanguages } from '../common';
2
- import type { DescribeSource } from '../describe';
3
- import type { PeerSources } from '../service-map';
4
- import type { Workload, WorkloadId } from '../workload';
5
2
  import { K8sResourceKind, OtelDistroName } from '../enum';
6
- import type { InstrumentationInstanceComponent } from '../instrumentation-instances';
7
3
  export interface PersistSourceInput {
8
4
  [clusterId: string]: {
9
5
  namespace: string;
@@ -13,9 +9,6 @@ export interface PersistSourceInput {
13
9
  currentStreamName: string;
14
10
  }[];
15
11
  }
16
- export type PersistSourcesFunc = (payload: PersistSourceInput) => Promise<{
17
- error?: string;
18
- } | undefined>;
19
12
  export interface SourceFormData {
20
13
  otelServiceName?: string;
21
14
  currentStreamName?: string;
@@ -24,26 +17,6 @@ export interface SourceFormData {
24
17
  version?: string;
25
18
  otelDistroName?: OtelDistroName | null;
26
19
  }
27
- export type UpdateSourceFunc = (sourceId: WorkloadId, payload: SourceFormData) => Promise<void>;
28
- export type FetchSourceByIdFunc = (id: WorkloadId, bypassPaginationLoader?: boolean) => Promise<Workload | undefined>;
29
- export type FetchSourceDescribeFunc = (req: WorkloadId) => Promise<{
30
- data?: {
31
- describeSource: DescribeSource;
32
- };
33
- }>;
34
- export type FetchSourceLibrariesFunc = (req: WorkloadId) => Promise<{
35
- data?: {
36
- instrumentationInstanceComponents: InstrumentationInstanceComponent[];
37
- };
38
- }>;
39
- export type FetchPeerSourcesFunc = (serviceName: string) => Promise<{
40
- data?: {
41
- peerSources: PeerSources;
42
- };
43
- }>;
44
- export type RestartWorkloadsFunc = (sourceIds: WorkloadId[]) => Promise<void>;
45
- export type RestartPodFunc = (namespace: string, name: string) => Promise<void>;
46
- export type RecoverFromRollbackFunc = (sourceId: WorkloadId) => Promise<void>;
47
20
  export interface ProfilingSlots {
48
21
  activeKeys: string[];
49
22
  keysWithData: string[];
@@ -62,6 +35,3 @@ export interface EnableProfilingResult {
62
35
  maxSlots?: number;
63
36
  activeSlots?: number;
64
37
  }
65
- export type EnableProfilingFunc = (source: WorkloadId) => Promise<EnableProfilingResult | undefined>;
66
- export type FetchProfilingSlotsFunc = () => Promise<ProfilingSlots | undefined>;
67
- export type FetchSourceProfilingFunc = (source: WorkloadId) => Promise<SourceProfilingResult | undefined>;
@@ -5,9 +5,3 @@ export interface TokenPayload {
5
5
  issuedAt: number;
6
6
  expiresAt: number;
7
7
  }
8
- export type UpdateTokenFunc = (newToken: string) => Promise<{
9
- error?: string;
10
- data?: {
11
- updateApiToken: boolean;
12
- } | null;
13
- } | undefined>;
@@ -1,13 +1,11 @@
1
1
  import type { ProgrammingLanguages } from '../common';
2
+ import type { HeadSamplingOperationMatcher, TailSamplingOperationMatcher } from '../sampling';
2
3
  import { K8sResourceKind, OtelDistroName, DesiredStateProgress } from '../enum';
3
4
  export interface WorkloadId {
4
5
  namespace: string;
5
6
  name: string;
6
7
  kind: K8sResourceKind | '';
7
8
  }
8
- interface WorkloadFilter extends Partial<WorkloadId> {
9
- markedForInstrumentation?: boolean;
10
- }
11
9
  export interface DesiredConditionStatus {
12
10
  name?: string;
13
11
  status?: DesiredStateProgress;
@@ -67,24 +65,21 @@ export interface K8sWorkloadContainerOverrides {
67
65
  otelDistroName?: OtelDistroName | null;
68
66
  runtimeInfo?: K8sWorkloadRuntimeInfoContainer | null;
69
67
  }
70
- export declare enum K8sWorkloadContainerAgentConfigTracesHeadSamplingCheckConditionOperator {
71
- Equals = "equals",
72
- NotEquals = "notEquals",
73
- EndWith = "endWith",
74
- StartWith = "startWith"
75
- }
76
- export interface K8sWorkloadContainerAgentConfigTracesHeadSamplingCheckCondition {
77
- key: string;
78
- operator: K8sWorkloadContainerAgentConfigTracesHeadSamplingCheckConditionOperator;
79
- value: string;
68
+ export declare enum K8sWorkloadContainerAgentConfigTracesHeadSamplingSpanMetricsMode {
69
+ SampledSpansOnly = "sampled_spans_only",
70
+ AllSpans = "all_spans"
80
71
  }
81
- export interface K8sWorkloadContainerAgentConfigTracesHeadSamplingCheck {
82
- conditions?: K8sWorkloadContainerAgentConfigTracesHeadSamplingCheckCondition[] | null;
83
- percentage: number;
72
+ export interface K8sWorkloadContainerAgentConfigTracesHeadSamplingNoisyOperation {
73
+ ruleId: string;
74
+ name?: string | null;
75
+ disabled: boolean;
76
+ operation?: HeadSamplingOperationMatcher | null;
77
+ percentageAtMost?: number | null;
84
78
  }
85
79
  export interface K8sWorkloadContainerAgentConfigTracesHeadSampling {
86
- checks?: K8sWorkloadContainerAgentConfigTracesHeadSamplingCheck[] | null;
87
- fallbackPercentage: number;
80
+ dryRun?: boolean | null;
81
+ spanMetricsMode?: K8sWorkloadContainerAgentConfigTracesHeadSamplingSpanMetricsMode | null;
82
+ noisyOperations?: K8sWorkloadContainerAgentConfigTracesHeadSamplingNoisyOperation[] | null;
88
83
  }
89
84
  export interface K8sWorkloadContainerAgentConfigTraces {
90
85
  headSampling?: K8sWorkloadContainerAgentConfigTracesHeadSampling | null;
@@ -92,6 +87,37 @@ export interface K8sWorkloadContainerAgentConfigTraces {
92
87
  export interface K8sWorkloadContainerAgentConfig {
93
88
  traces?: K8sWorkloadContainerAgentConfigTraces | null;
94
89
  }
90
+ export interface K8sWorkloadContainerCollectorConfigTailSamplingNoisyOperation {
91
+ ruleId: string;
92
+ name?: string | null;
93
+ disabled: boolean;
94
+ operation?: HeadSamplingOperationMatcher | null;
95
+ percentageAtMost?: number | null;
96
+ }
97
+ export interface K8sWorkloadContainerCollectorConfigTailSamplingHighlyRelevantOperation {
98
+ ruleId: string;
99
+ name?: string | null;
100
+ disabled: boolean;
101
+ error: boolean;
102
+ durationAtLeastMs?: number | null;
103
+ operation?: TailSamplingOperationMatcher | null;
104
+ percentageAtLeast?: number | null;
105
+ }
106
+ export interface K8sWorkloadContainerCollectorConfigTailSamplingCostReductionRule {
107
+ ruleId: string;
108
+ name?: string | null;
109
+ disabled: boolean;
110
+ operation?: TailSamplingOperationMatcher | null;
111
+ percentageAtMost: number;
112
+ }
113
+ export interface K8sWorkloadContainerCollectorConfigTailSampling {
114
+ noisyOperations?: K8sWorkloadContainerCollectorConfigTailSamplingNoisyOperation[] | null;
115
+ highlyRelevantOperations?: K8sWorkloadContainerCollectorConfigTailSamplingHighlyRelevantOperation[] | null;
116
+ costReductionRules?: K8sWorkloadContainerCollectorConfigTailSamplingCostReductionRule[] | null;
117
+ }
118
+ export interface K8sWorkloadContainerCollectorConfig {
119
+ tailSampling?: K8sWorkloadContainerCollectorConfigTailSampling | null;
120
+ }
95
121
  export interface K8sWorkloadPodContainerProcessAttribute {
96
122
  name: string;
97
123
  value: string;
@@ -107,6 +133,8 @@ export interface K8sWorkloadContainer {
107
133
  runtimeInfo?: K8sWorkloadRuntimeInfoContainer | null;
108
134
  agentEnabled?: K8sWorkloadAgentEnabledContainer | null;
109
135
  overrides?: K8sWorkloadContainerOverrides | null;
136
+ agentConfig?: K8sWorkloadContainerAgentConfig | null;
137
+ collectorConfig?: K8sWorkloadContainerCollectorConfig | null;
110
138
  }
111
139
  export interface K8sWorkloadPodContainerProcess {
112
140
  healthy?: boolean | null;
@@ -173,7 +201,3 @@ export interface Workload {
173
201
  numberOfInstances?: number | null;
174
202
  autoRollback?: K8sWorkloadAutoRollback | null;
175
203
  }
176
- export type GetWorkloads = (filter: WorkloadFilter) => Promise<{
177
- workloads: Workload[];
178
- }>;
179
- export {};
package/lib/types.js CHANGED
@@ -1 +1 @@
1
- export{q as ActionKeyTypes,r as ActionType,eK as AddNodeTypes,eL as AgentInjectedReason,eM as BooleanOperation,aj as CodeAttributesKeyTypes,eN as ConditionType,eO as Crud,K as CustomInstrumentationsKeyTypes,b2 as DesiredStateProgress,eP as DestinationTypes,eQ as EdgeTypes,E as EntityTypes,a7 as ExtractionDataFormat,H as FieldTypes,L as GolangCustomProbe,J as HeadersCollectionKeyTypes,dP as InputTypes,eR as InstallationMethod,O as InstrumentationRuleType,eS as IntrumentationStatus,M as JavaCustomProbe,eT as JsonOperation,Y as K8sAttributesFrom,Q as K8sResourceKind,eU as K8sWorkloadContainerAgentConfigTracesHeadSamplingCheckConditionOperator,eV as ListDirection,N as NodeTypes,eW as NumberOperation,eX as OtelDistroName,eY as OtherEntityTypes,b7 as OtherStatus,aI as OtherStatusType,al as PayloadCollectionKeyTypes,P as PlatformType,eZ as PodContainerLifecycleStatus,e_ as PodContainerStatus,e$ as PodPhase,f0 as Profile,bq as ProgrammingLanguages,f1 as SIGNAL_KEY_TO_TYPE,f2 as SIGNAL_TYPE_TO_KEY,f3 as SignalKey,B as SignalType,f4 as SortDirection,S as StatusType,f5 as StringOperation,T as Tier,f6 as WorkloadRolloutReason,ds as WorkloadRolloutStatus}from"./chunks/ui-components-DODwSdKu.js";import"react/jsx-runtime";import"styled-components";import"./icons.js";import"zustand";import"react";import"javascript-time-ago";import"./chunks/vendor-Be0cOokr.js";import"prism-react-renderer";import"react-error-boundary";import"react-dom";import"virtua";
1
+ export{v as ActionKeyTypes,w as ActionType,eO as AddNodeTypes,eP as AgentInjectedReason,eQ as BooleanOperation,at as CodeAttributesKeyTypes,eR as ConditionType,Y as Crud,Q as CustomInstrumentationsKeyTypes,ba as DesiredStateProgress,eS as DestinationTypes,eT as EdgeTypes,E as EntityTypes,ai as ExtractionDataFormat,L as FieldTypes,R as GolangCustomProbe,O as HeadersCollectionKeyTypes,dU as InputTypes,eU as InstallationMethod,eV as InstallationStatus,V as InstrumentationRuleType,eW as IntrumentationStatus,U as JavaCustomProbe,eX as JsonOperation,a7 as K8sAttributesFrom,W as K8sResourceKind,eY as K8sWorkloadContainerAgentConfigTracesHeadSamplingSpanMetricsMode,eZ as ListDirection,b as NodeTypes,e_ as NumberOperation,e$ as OtelDistroName,f0 as OtherEntityTypes,bf as OtherStatus,aS as OtherStatusType,av as PayloadCollectionKeyTypes,P as PlatformType,f1 as PodContainerLifecycleStatus,f2 as PodContainerStatus,f3 as PodPhase,f4 as Profile,by as ProgrammingLanguages,f5 as SIGNAL_KEY_TO_TYPE,f6 as SIGNAL_TYPE_TO_KEY,f7 as SignalKey,H as SignalType,f8 as SortDirection,S as StatusType,f9 as StringOperation,c as Tier,fa as WorkloadRolloutReason,dx as WorkloadRolloutStatus}from"./chunks/ui-components-BKrLf2tx.js";import"react/jsx-runtime";import"styled-components";import"./icons.js";import"zustand";import"react";import"javascript-time-ago";import"javascript-time-ago/locale/en";import"prism-react-renderer";import"./chunks/vendor-BFqT13Me.js";import"zustand/middleware";import"react-error-boundary";import"react-dom";import"virtua";
package/lib/visuals.js CHANGED
@@ -1 +1 @@
1
- export{f7 as VISUAL_ODIGOS_LOGO_HEIGHT,f8 as VISUAL_ODIGOS_LOGO_WIDTH,eH as VisualGreenRings,f9 as VisualOdigosLogo,c0 as VisualPurpleRings}from"./chunks/ui-components-DODwSdKu.js";import"react/jsx-runtime";import"styled-components";import"./icons.js";import"zustand";import"react";import"javascript-time-ago";import"./chunks/vendor-Be0cOokr.js";import"prism-react-renderer";import"react-error-boundary";import"react-dom";import"virtua";
1
+ export{fb as VISUAL_ODIGOS_LOGO_HEIGHT,fc as VISUAL_ODIGOS_LOGO_WIDTH,eM as VisualGreenRings,fd as VisualOdigosLogo,c8 as VisualPurpleRings}from"./chunks/ui-components-BKrLf2tx.js";import"react/jsx-runtime";import"styled-components";import"./icons.js";import"zustand";import"react";import"javascript-time-ago";import"javascript-time-ago/locale/en";import"prism-react-renderer";import"./chunks/vendor-BFqT13Me.js";import"zustand/middleware";import"react-error-boundary";import"react-dom";import"virtua";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odigos/ui-kit",
3
- "version": "0.0.249",
3
+ "version": "0.0.251",
4
4
  "author": "Odigos",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -61,6 +61,11 @@
61
61
  "import": "./lib/contexts.js",
62
62
  "require": "./lib/contexts.js"
63
63
  },
64
+ "./contexts/odigos-api": {
65
+ "types": "./lib/contexts/odigos-api/index.d.ts",
66
+ "import": "./lib/contexts/odigos-api.js",
67
+ "require": "./lib/contexts/odigos-api.js"
68
+ },
64
69
  "./functions": {
65
70
  "types": "./lib/functions/index.d.ts",
66
71
  "import": "./lib/functions.js",
@@ -103,52 +108,56 @@
103
108
  }
104
109
  },
105
110
  "peerDependencies": {
106
- "react": "19.2.5",
107
- "react-dom": "19.2.5",
111
+ "@apollo/client": "^3.13.9",
112
+ "graphql": "^16.13.2",
113
+ "react": "19.2.7",
114
+ "react-dom": "19.2.7",
108
115
  "styled-components": "6.3.12"
109
116
  },
110
117
  "dependencies": {
111
- "@xyflow/react": "^12.10.2",
118
+ "@xyflow/react": "^12.11.0",
112
119
  "elkjs": "^0.11.1",
113
120
  "javascript-time-ago": "^2.6.4",
114
121
  "lottie-react": "^2.4.1",
115
122
  "prism-react-renderer": "^2.4.1",
116
- "react": "19.2.5",
117
- "react-dom": "19.2.5",
118
- "react-error-boundary": "^6.1.1",
123
+ "react": "19.2.7",
124
+ "react-dom": "19.2.7",
125
+ "react-error-boundary": "^6.1.2",
119
126
  "styled-components": "6.3.12",
120
127
  "virtua": "^0.49.1",
121
- "zustand": "^5.0.13"
128
+ "zustand": "^5.0.14"
122
129
  },
123
130
  "devDependencies": {
124
- "@babel/core": "^7.29.0",
125
- "@babel/preset-env": "^7.29.5",
126
- "@babel/preset-react": "^7.28.5",
127
- "@babel/preset-typescript": "^7.28.5",
131
+ "@apollo/client": "^3.13.9",
132
+ "@babel/core": "^7.29.7",
133
+ "@babel/preset-env": "^7.29.7",
134
+ "@babel/preset-react": "^7.29.7",
135
+ "@babel/preset-typescript": "^7.29.7",
128
136
  "@eslint/eslintrc": "^3.3.5",
129
- "@rollup/plugin-commonjs": "^29.0.2",
137
+ "@rollup/plugin-commonjs": "^29.0.3",
130
138
  "@rollup/plugin-json": "^6.1.0",
131
139
  "@rollup/plugin-node-resolve": "^16.0.3",
132
140
  "@rollup/plugin-terser": "^1.0.0",
133
141
  "@rollup/plugin-typescript": "^12.3.0",
134
142
  "@storybook/addon-webpack5-compiler-babel": "^4.0.1",
135
- "@storybook/react-webpack5": "10.3.6",
136
- "@types/node": "^25.6.2",
137
- "@types/react": "^19.2.14",
143
+ "@storybook/react-webpack5": "10.4.5",
144
+ "@types/node": "^25.9.3",
145
+ "@types/react": "^19.2.17",
138
146
  "@types/react-dom": "^19.2.3",
139
- "@typescript-eslint/eslint-plugin": "^8.59.2",
140
- "@typescript-eslint/parser": "^8.59.2",
147
+ "@typescript-eslint/eslint-plugin": "^8.61.0",
148
+ "@typescript-eslint/parser": "^8.61.0",
141
149
  "babel-loader": "^10.1.1",
142
150
  "babel-plugin-styled-components": "^2.1.4",
143
151
  "eslint": "^9.39.4",
144
152
  "eslint-plugin-react": "^7.37.5",
145
- "eslint-plugin-storybook": "10.3.6",
146
- "postcss": "^8.5.14",
147
- "rollup": "^4.60.3",
153
+ "eslint-plugin-storybook": "10.4.5",
154
+ "graphql": "^16.13.2",
155
+ "postcss": "^8.5.15",
156
+ "rollup": "^4.62.0",
148
157
  "rollup-plugin-filesize": "^10.0.0",
149
158
  "rollup-plugin-postcss": "^4.0.2",
150
159
  "rollup-plugin-visualizer": "^7.0.1",
151
- "storybook": "10.3.6",
160
+ "storybook": "10.4.5",
152
161
  "typescript": "^5.9.3"
153
162
  }
154
163
  }
@@ -1,19 +0,0 @@
1
- import{jsx as e,Fragment as t,jsxs as r}from"react/jsx-runtime";import{useMemo as n,useContext as o,createContext as a,Fragment as s}from"react";import{t as i,T as u,P as l,u as c,a as p,b as d,c as f}from"./ui-components-DODwSdKu.js";import h from"styled-components";const m=a({platformType:l.K8s,tier:u.Community,version:"v0.0.0"}),v=({children:t,platformType:r,tier:o,version:a})=>{const s=n(()=>({platformType:r,tier:o,version:a}),[r,o,a]);return e(m.Provider,{value:s,children:t})},g=(e,t)=>!t||i(e)>=i(t),y=e=>{const t=o(m),r=g(t.version,e),n=t.platformType===l.Vm;return{...t,isVersionSupported:r,isVm:n,isEnterprise:t.tier===u.Onprem}};function x(){return{sources:[],namespaces:[],languages:[]}}function k(e){return!e||!e.sources?.length&&!e.namespaces?.length&&!e.languages?.length}function S(e){return e?{sources:e.sources?[...e.sources]:[],namespaces:e.namespaces?[...e.namespaces]:[],languages:e.languages?[...e.languages]:[]}:{sources:[],namespaces:[],languages:[]}}function A(e){return null==e||0===e}function T(e){return{name:"",notes:"",disabled:!1,ruleType:"Relevance",sourceScopes:{sources:[],namespaces:[],languages:[]},operationType:"all",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:"",durationPreset:"500",customDurationMs:"",keepErrors:!1,percentageMode:"costReduction"===e?"sample":"all",percentagePreset:"0",customPercentage:""}}function P(e){return k(e.sourceScopes)?null:e.sourceScopes}function R(e){return P(e)}function b(e){if("all"===e.percentageMode)return null;if("custom"===e.percentagePreset){const t=parseFloat(e.customPercentage);return isNaN(t)?null:t}return parseFloat(e.percentagePreset)}function M(e){if("custom"===e.durationPreset){const t=parseFloat(e.customDurationMs);return isNaN(t)?null:t}return parseInt(e.durationPreset,10)}function D(e){return{httpServer:{[e.routeType]:e.route||null,method:e.method||null}}}function I(e){return"all"===e.operationType?null:"httpServer"===e.operationType?D(e):"httpClient"===e.operationType?{httpClient:{serverAddress:e.serverAddress||null,["route"===e.routeType?"templatedPath":"templatedPathPrefix"]:e.route||null,method:e.method||null}}:null}function $(e){return"all"===e.operationType?null:"httpServer"===e.operationType?D(e):"kafkaConsumer"===e.operationType?{kafkaConsumer:{kafkaTopic:e.kafkaTopic||null}}:"kafkaProducer"===e.operationType?{kafkaProducer:{kafkaTopic:e.kafkaTopic||null}}:null}function C(e){return{ruleId:"",name:e.name||null,disabled:!1,notes:e.notes||null,sourceScopes:P(e),percentageAtMost:b(e),operation:I(e)}}function E(e){return{ruleId:"",name:e.name||null,disabled:!1,notes:e.notes||null,sourceScopes:P(e),error:e.keepErrors,durationAtLeastMs:"Duration"===e.ruleType?M(e):null,percentageAtLeast:b(e),operation:$(e)}}function w(e){return{ruleId:"",name:e.name||null,disabled:!1,notes:e.notes||null,sourceScopes:P(e),percentageAtMost:b(e)??0,operation:$(e)}}function L(e){return{name:e.name||null,disabled:e.disabled,sourceScopes:R(e),operation:I(e),percentageAtMost:b(e),notes:e.notes||null}}function O(e){return{name:e.name||null,disabled:e.disabled,sourceScopes:R(e),error:"Error"===e.ruleType,durationAtLeastMs:"Duration"===e.ruleType?M(e):null,operation:$(e),percentageAtLeast:b(e),notes:e.notes||null}}function N(e){return{name:e.name||null,disabled:e.disabled,sourceScopes:R(e),operation:$(e),percentageAtMost:b(e)??0,notes:e.notes||null}}const H=["5000","1000","500","100","50"],K=["50","25","10","1","0.5","0.1","0"];function j(e){if(null==e)return{percentageMode:"all",percentagePreset:"0",customPercentage:""};const t=K.find(t=>Number(t)===e);return t?{percentageMode:"sample",percentagePreset:t,customPercentage:""}:{percentageMode:"sample",percentagePreset:"custom",customPercentage:String(e)}}function z(e){if(!e)return{operationType:"all",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:""};const t=e;if(t.httpServer){return{operationType:"httpServer",routeType:t.httpServer.routePrefix?"routePrefix":"route",route:t.httpServer.route||t.httpServer.routePrefix||"",serverAddress:"",method:t.httpServer.method||"",kafkaTopic:""}}return t.kafkaConsumer?{operationType:"kafkaConsumer",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:t.kafkaConsumer.kafkaTopic||""}:t.kafkaProducer?{operationType:"kafkaProducer",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:t.kafkaProducer.kafkaTopic||""}:{operationType:"all",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:""}}function F(e){const t=T(),r=S(e.rule.sourceScopes);const n=function(e){return"highlyRelevant"!==e.category?"Relevance":e.rule.error?"Error":null!=e.rule.durationAtLeastMs?"Duration":"Relevance"}(e);let o,a,s={durationPreset:"500",customDurationMs:""},i=!1;switch(e.category){case"noisy":o=function(e){const t=e.rule.operation;if(!t)return{operationType:"all",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:""};if(t.httpServer)return{operationType:"httpServer",routeType:t.httpServer.routePrefix?"routePrefix":"route",route:t.httpServer.route||t.httpServer.routePrefix||"",serverAddress:"",method:t.httpServer.method||"",kafkaTopic:""};if(t.httpClient)return{operationType:"httpClient",routeType:t.httpClient.templatedPathPrefix?"routePrefix":"route",route:t.httpClient.templatedPath||t.httpClient.templatedPathPrefix||"",serverAddress:t.httpClient.serverAddress||"",method:t.httpClient.method||"",kafkaTopic:""};return{operationType:"all",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:""}}(e),a=A(u=e.rule.percentageAtMost)?{percentageMode:"all",percentagePreset:"0",customPercentage:""}:j(u);break;case"highlyRelevant":o=z(e.rule.operation),a=j(e.rule.percentageAtLeast),s=function(e){if(null==e)return{durationPreset:"500",customDurationMs:""};const t=H.find(t=>Number(t)===e);return t?{durationPreset:t,customDurationMs:""}:{durationPreset:"custom",customDurationMs:String(e)}}(e.rule.durationAtLeastMs),i=e.rule.error;break;case"costReduction":o=z(e.rule.operation),a=j(e.rule.percentageAtMost)}var u;return{...t,name:e.rule.name||"",notes:e.rule.notes||"",disabled:e.rule.disabled,ruleType:n,sourceScopes:r,...o,...s,keepErrors:i,...a}}var X;!function(e){e.Default="default",e.Action="action",e.Endpoint="endpoint",e.Scope="scope",e.Duration="duration"}(X||(X={}));const J=[X.Action,X.Endpoint,X.Scope,X.Duration],V=h.span`
2
- font-family: ${({theme:e,$isMono:t})=>t?e.font_family.secondary:e.font_family.primary};
3
- font-size: ${({theme:e})=>e.v2.text.size.xxs}px;
4
- line-height: 20px;
5
- color: ${({theme:e,$variant:t})=>{const r=e.v2.colors;switch(t){case"action":return r.green[400];case"endpoint":return r.purple[300];case"scope":return r.yellow[400];case"duration":return r.orange[600];default:return r.white[500]}}};
6
- `,B=h.span`
7
- display: inline;
8
- cursor: help;
9
- text-decoration: underline dotted;
10
- text-underline-offset: 3px;
11
- `,W=h.div`
12
- display: flex;
13
- flex-direction: column;
14
- gap: 4px;
15
- background-color: ${({theme:e})=>e.v2.colors.black[500]};
16
- border-radius: 4px;
17
- padding: 8px;
18
- max-width: 300px;
19
- `,_=({items:t,children:n})=>{const{popupRef:o,popupOpen:a,setPopupOpen:s,popupPosition:i,handlePosition:u}=c({positionMode:"viewport",defaultClientHeight:48,defaultClientwidth:240}),l=e=>{u(e.clientX,e.clientY),s("mouseleave"!==e.type)};return r(B,{onMouseEnter:l,onMouseMove:l,onMouseLeave:l,children:[n,e(p,{ref:o,isOpen:a,top:i.top,left:i.left,asPortal:!0,style:{backgroundColor:"transparent",border:"none"},borderRadius:"0",padding:"0",maxWidth:"300px",children:e(W,{children:t.map((t,r)=>e(d,{size:f.XXXS,children:t},r))})})]})},q=({parts:n})=>{const o=n.map(e=>({...e,text:e.text.trim()})).filter(e=>e.text.length>0);return e(t,{children:o.map((n,o)=>{const a=e(V,{$variant:n.variant,$isMono:J.includes(n.variant),children:n.text});return r(s,{children:[0!==o&&e(t,{children:" "}),n.tooltipItems?.length?e(_,{items:n.tooltipItems,children:a}):a]},`${n.variant}-${o}`)})})};var G;!function(e){e.Noisy="noisy",e.HighlyRelevant="highly-relevant",e.CostReduction="cost-reduction"}(G||(G={}));const Y=[{value:G.Noisy,label:"1. Noisy Operations",tooltip:"Rules that reduce noise from high-volume, low-value operations"},{value:G.HighlyRelevant,label:"2. Highly Relevant Operations",tooltip:"Rules that prioritize important traces for retention"},{value:G.CostReduction,label:"3. Cost Reduction",tooltip:"Rules that optimize costs by sampling less critical data"}],Q={[G.Noisy]:"This is the most efficient way to sample (with Head Sampling). Prefer to use it where possible.",[G.HighlyRelevant]:'Any trace from the "Noisy Operations" category is sampled prior to checking highly relevance.',[G.CostReduction]:"Cost reduction rules use Tail Sampling to drop traces that are unlikely to be useful for debugging or monitoring."},U={[G.Noisy]:"Noisy Operations rules list",[G.HighlyRelevant]:"Highly Relevant Operations rules list",[G.CostReduction]:"Cost Reduction rules list"},Z={[G.Noisy]:"noisy",[G.HighlyRelevant]:"highlyRelevant",[G.CostReduction]:"costReduction"};function ee(e){const t=e.kind?String(e.kind).toLowerCase():"deployment";return e.namespace&&e.name?`${t} '${e.name}' in namespace '${e.namespace}'`:e.name?`${t} '${e.name}'`:e.namespace?`any service in namespace '${e.namespace}'`:""}function te(e){return`any service in namespace '${e}'`}function re(e){return`${e} services`}function ne(e){const t=function(e){if(!e)return[];const t=[];for(const r of e.sources??[]){const e=ee(r);e&&t.push(e)}for(const r of e.namespaces??[])r&&t.push(te(r));for(const r of e.languages??[])r&&t.push(re(r));return t}(e);if(!t.length)return[{text:" in ",variant:X.Default},{text:"any service in the cluster",variant:X.Scope}];const r=[{text:" in ",variant:X.Default}],n=t.slice(0,2),o=t.slice(2);return n.forEach((e,t)=>{t>0&&r.push({text:", ",variant:X.Default}),r.push({text:e,variant:X.Scope})}),o.length>0&&r.push({text:` + ${o.length} more`,variant:X.Default,tooltipItems:o}),r}function oe(e,t){const r=(n=e).startsWith("/")?n.slice(1):n;var n;return t?`${t} /${r}`:`/${r}`}function ae(e){const t=e.method;return e.route?[{text:" for server endpoint ",variant:X.Default},{text:oe(e.route,t),variant:X.Endpoint}]:e.routePrefix?[{text:" for endpoints under ",variant:X.Default},{text:oe(e.routePrefix,t),variant:X.Endpoint}]:[]}function se(e){const t=[];if(A(e.percentageAtMost)?t.push({text:"Drop all traces",variant:X.Action}):(t.push({text:`Keep at most ${e.percentageAtMost}%`,variant:X.Action}),t.push({text:" of traces",variant:X.Default})),e.operation){const r=e.operation.httpServer,n=r?function(e){const t=e.method;return e.route?[{text:" where the root span is ",variant:X.Default},{text:oe(e.route,t),variant:X.Endpoint}]:e.routePrefix?[{text:" where the root span is under ",variant:X.Default},{text:oe(e.routePrefix,t),variant:X.Endpoint}]:[]}(r):[];n.length>0&&t.push(...n);const o=e.operation.httpClient,a=o?.templatedPath||o?.templatedPathPrefix,s=o?.serverAddress;if((a||s)&&0===n.length){const e=o?.method,r=a&&s?`${s}/${a}`:a||s;t.push({text:" to ",variant:X.Default}),e?t.push({text:`${e} /${r}`,variant:X.Endpoint}):t.push({text:`/${r}`,variant:X.Endpoint})}}else t.push({text:" on ",variant:X.Default}),t.push({text:"any operation",variant:X.Endpoint});return t.push(...ne(e.sourceScopes)),t}function ie(e){const t=[];if(null!=e.percentageAtLeast?(t.push({text:`Keep ${e.percentageAtLeast}%`,variant:X.Action}),t.push({text:" of traces",variant:X.Default})):t.push({text:"Keep all traces",variant:X.Action}),e.operation){const r=e.operation.httpServer;r&&t.push(...ae(r))}else t.push({text:" on ",variant:X.Default}),t.push({text:"any operation",variant:X.Endpoint});return t.push(...ne(e.sourceScopes)),!e.error&&null!=e.durationAtLeastMs&&e.durationAtLeastMs>0&&(t.push({text:" with duration > ",variant:X.Default}),t.push({text:`${e.durationAtLeastMs}ms`,variant:X.Duration})),t}function ue(e){const t=[];if(t.push({text:`Keep at most ${e.percentageAtMost}%`,variant:X.Action}),t.push({text:" of traces",variant:X.Default}),e.operation){const r=e.operation.httpServer,n=r?ae(r):[];n.length>0&&t.push(...n);const o=e.operation.kafkaConsumer?.kafkaTopic;o&&0===n.length&&(t.push({text:" from ",variant:X.Default}),t.push({text:`topic '${o}'`,variant:X.Endpoint}))}else t.push({text:" on ",variant:X.Default}),t.push({text:"any operation",variant:X.Endpoint});return t.push(...ne(e.sourceScopes)),t}function le(e){return e.error?"Error":null!=e.durationAtLeastMs?"Duration":"Relevance"}function ce(e,t,r){const n=Z[t],o=[];for(const a of e)switch(t){case G.Noisy:for(const e of a.noisyOperations)r?.has(e.ruleId)||o.push({ruleId:e.ruleId,samplingId:a.id,name:e.name??null,disabled:e.disabled,notes:e.notes??null,summary:se(e),category:n});break;case G.HighlyRelevant:for(const e of a.highlyRelevantOperations)r?.has(e.ruleId)||o.push({ruleId:e.ruleId,samplingId:a.id,name:e.name??null,disabled:e.disabled,notes:e.notes??null,summary:ie(e),category:n,typeBadge:le(e)});break;case G.CostReduction:for(const e of a.costReductionRules)r?.has(e.ruleId)||o.push({ruleId:e.ruleId,samplingId:a.id,name:e.name??null,disabled:e.disabled,notes:e.notes??null,summary:ue(e),category:n})}return o}function pe(e,t){switch(e){case"noisy":return se(t);case"highlyRelevant":return ie(t);case"costReduction":return ue(t)}}function de(e,t,r,n){for(const o of e)if(o.id===t)switch(n){case"noisy":{const e=o.noisyOperations.find(e=>e.ruleId===r);if(e)return{category:"noisy",samplingId:o.id,rule:e};break}case"highlyRelevant":{const e=o.highlyRelevantOperations.find(e=>e.ruleId===r);if(e)return{category:"highlyRelevant",samplingId:o.id,rule:e};break}case"costReduction":{const e=o.costReductionRules.find(e=>e.ruleId===r);if(e)return{category:"costReduction",samplingId:o.id,rule:e};break}}return null}function fe(e,t){const r=de(e,t.samplingId,t.rule.ruleId,t.category);return r?{...r,summary:pe(r.category,r.rule)}:null}function he(e,t){const r=de(e,t.samplingId,t.ruleId,t.category);return r?{...r,summary:pe(r.category,r.rule)}:null}function me(e){if(!e)return null;const t=(e.sources??[]).map(e=>`${e.namespace}/${e.kind}/${e.name}`).sort(),r=(e.namespaces??[]).slice().sort(),n=(e.languages??[]).slice().sort();return t.length||r.length||n.length?[t.join("|"),r.join("|"),n.join("|")].join("::"):null}function ve(e){return null==e?null:e}function ge(e,t){return JSON.stringify({sourceScopes:me(e),operation:ve(t)})}function ye(e,t,r,n){return JSON.stringify({sourceScopes:me(e),error:t??!1,durationAtLeastMs:(o=r,null==o?null:o),operation:ve(n)});var o}function xe(e,t){return JSON.stringify({sourceScopes:me(e),operation:ve(t)})}function ke(e,t,r,n){switch(t){case"noisy":{const t=ge(r.sourceScopes,r.operation);for(const r of e)for(const e of r.noisyOperations)if((!n||e.ruleId!==n)&&ge(e.sourceScopes,e.operation)===t)return e.ruleId;return null}case"highlyRelevant":{const t=ye(r.sourceScopes,r.error,r.durationAtLeastMs,r.operation);for(const r of e)for(const e of r.highlyRelevantOperations)if((!n||e.ruleId!==n)&&ye(e.sourceScopes,e.error,e.durationAtLeastMs,e.operation)===t)return e.ruleId;return null}case"costReduction":{const t=xe(r.sourceScopes,r.operation);for(const r of e)for(const e of r.costReductionRules)if((!n||e.ruleId!==n)&&xe(e.sourceScopes,e.operation)===t)return e.ruleId;return null}}}function Se(e){if(!e||!e.enabled)return[{text:"Auto rule is ",variant:X.Default},{text:"disabled",variant:X.Action}];return[{text:`Keep ${e.keepPercentage??0}%`,variant:X.Action},{text:" of ",variant:X.Default},{text:"traces for kubelet health probes in the entire cluster",variant:X.Scope}]}function Ae(e){return!0===e.error&&k(e.sourceScopes)&&!e.operation&&(null==e.percentageAtLeast||100===e.percentageAtLeast)}function Te(e){for(const t of e){const e=t.highlyRelevantOperations.find(Ae);if(e)return{rule:e,samplingId:t.id}}return null}function Pe(e){return!e||e.disabled?[{text:"Auto rule is ",variant:X.Default},{text:"disabled",variant:X.Action}]:[{text:"Keep all traces",variant:X.Action},{text:" of ",variant:X.Default},{text:"error traces across the entire cluster",variant:X.Scope}]}function Re(e){return k(e.sourceScopes)&&!e.operation}function be(e){for(const t of e){const e=t.costReductionRules.find(Re);if(e)return{rule:e,samplingId:t.id}}return null}function Me(e){return!e||e.disabled?[{text:" is ",variant:X.Default},{text:"disabled",variant:X.Action}]:[{text:`Keep at most ${e.percentageAtMost}%`,variant:X.Action},{text:" of ",variant:X.Default},{text:"traces across the entire cluster",variant:X.Scope}]}export{A,ue as B,q as C,ie as D,se as E,w as F,E as G,C as H,v as O,G as S,Me as a,Pe as b,g as c,Se as d,be as e,Te as f,T as g,ce as h,k as i,N as j,O as k,L as l,x as m,S as n,he as o,pe as p,Z as q,fe as r,ke as s,Y as t,y as u,F as v,Q as w,U as x,X as y,ne as z};
@@ -1 +0,0 @@
1
- import{jsx as e}from"react/jsx-runtime";import{useState as t,useCallback as a,useMemo as r,useContext as n,createContext as s,useRef as o,useEffect as i}from"react";import{o as l,p as d,A as c,q as u,r as m,s as p,v as h,w as f,x as g,j as v,y as b,z as y,B as E,C as D,G as S,H as k,I as C,J as A,K as F,L as I,M as w,O as N,Q as x,T as R,E as P}from"./ui-components-DODwSdKu.js";import{n as O,m as T,i as L,b as M,a as U,d as j,v as K,g as q,u as G}from"./helpers-IEFhGXc7.js";const V={type:"",disabled:!1,name:"",notes:"",signals:[],fields:{}},_=s(null),H="All row fields are required",z="At least one row is required",J=(e,t)=>!!e&&t.every(t=>{const a=e[t];return Array.isArray(a)?a.length>0:!("string"==typeof(r=a)?!r.trim():p(r));var r}),Q=({children:n})=>{const[s,o]=t(null),i=l(V),f=a(e=>{i.resetFormData(),i.handleErrorChange(void 0,void 0,{}),e?.type&&i.handleFormChange("type",e.type),o(e)},[]),g=a(e=>{var t;i.resetFormData((({type:e,name:t,notes:a,disabled:r,signals:n,fields:s})=>({type:e,name:t||"",notes:a||"",disabled:!!r,signals:n??[],fields:s??{}}))(e)),i.handleErrorChange(void 0,void 0,{}),o((t=e.type,c.find(e=>e.type===t)??null))},[]),v=a(()=>{if(!s)return{errorMessage:"No action type selected",preparedFormData:d(V)};const e=(e=>{const t=d(e),a=t.fields||{},r=a[u.UrlTemplatizationRulesGroups];r?.length&&(a[u.UrlTemplatizationRulesGroups]=r.map(e=>({...e,templatizationRules:(e.templatizationRules||[]).filter(e=>!!e.template?.trim())})));const n=a[u.AttributeNamesToDelete];n?.length&&(a[u.AttributeNamesToDelete]=n.filter(e=>!!e?.trim()));const s=a[u.Renames];s&&(a[u.Renames]=Object.fromEntries(Object.entries(s).filter(([e,t])=>!!e?.trim()&&!!t?.trim())));const o=a[u.ExtractAttribute];return o?.extractions?.length&&(a[u.ExtractAttribute]={extractions:o.extractions.map(e=>({targetAttributeName:e.targetAttributeName?.trim()||"",lookupKey:e.lookupKey?.trim()||"",dataFormat:e.dataFormat||"",regex:e.regex?.trim()||""})).filter(e=>!!(e.targetAttributeName||e.lookupKey||e.dataFormat||e.regex))}),t.fields=a,t})(i.formData),t={};p(e.signals)&&(t.signals=h.FIELD_IS_REQUIRED),s.type&&Object.assign(t,((e,t,a)=>{const r={},n=t.fields||{},s=a.fields||{};switch(e){case m.K8sAttributes:{const e=!(n[u.CollectContainerAttributes]||n[u.CollectReplicaSetAttributes]||n[u.CollectWorkloadId]||n[u.CollectClusterId]),t=!n[u.LabelsAttributes]?.length,a=!n[u.AnnotationsAttributes]?.length;e&&t&&a&&(r[u.CollectContainerAttributes]="Enable at least one option or add a label/annotation row");const s=n[u.LabelsAttributes];s?.some(e=>!J(e,["labelKey","attributeKey","fromSources"]))&&(r[u.LabelsAttributes]=H);const o=n[u.AnnotationsAttributes];o?.some(e=>!J(e,["annotationKey","attributeKey","fromSources"]))&&(r[u.AnnotationsAttributes]=H);break}case m.AddClusterInfo:{const e=n[u.ClusterAttributes];e?.length?e.some(e=>!J(e,["attributeName","attributeStringValue"]))&&(r[u.ClusterAttributes]=H):r[u.ClusterAttributes]=z;break}case m.DeleteAttributes:{const e=s[u.AttributeNamesToDelete]||[],t=n[u.AttributeNamesToDelete]||[];t.length?e.length>t.length&&(r[u.AttributeNamesToDelete]=H):r[u.AttributeNamesToDelete]=e.length?H:z;break}case m.RenameAttributes:{const e=Object.entries(s[u.Renames]||{}),t=Object.entries(n[u.Renames]||{}),a=e.some(([e,t])=>!e?.trim()||!t?.trim());t.length?a&&(r[u.Renames]=H):r[u.Renames]=e.length?H:z;break}case m.PiiMasking:{const e=n[u.PiiCategories];e?.length||(r[u.PiiCategories]="Select at least one attribute to mask");break}case m.URLTemplatization:{const e=n[u.UrlTemplatizationRulesGroups];(!e?.length||e.some(e=>!e.templatizationRules?.length))&&(r[u.UrlTemplatizationRulesGroups]="Each rule group needs at least one non-blank template");break}case m.ExtractAttribute:{const e=n[u.ExtractAttribute]?.extractions||[],t=s[u.ExtractAttribute]?.extractions||[];if(e.length)if(e.some(e=>{if(!e.targetAttributeName?.trim())return!0;const t=!!e.regex?.trim(),a=!!e.lookupKey?.trim();return a!==!!e.dataFormat||t===a}))r[u.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 a=e.targetAttributeName?.trim()||"";return!!t.has(a)||(t.add(a),!1)})&&(r[u.ExtractAttribute]="Each new span attribute name must be unique")}else r[u.ExtractAttribute]=t.length?H:z;break}}return r})(s.type,e,i.formData)),i.handleErrorChange(void 0,void 0,t);return{errorMessage:Object.keys(t).length>0?"Invalid form values":void 0,preparedFormData:e}},[i,s]),b=r(()=>({selectedOption:s,onSelectOption:f,loadAction:g,genericForm:i,validateFormData:v}),[s,f,g,i,v]);return e(_.Provider,{value:b,children:n})},W=()=>{const e=n(_);if(!e)throw new Error("useActionFormContext must be used within an ActionFormContextProvider");return e},$={name:""},B=s(null),X=({children:n,defaultExcludeName:s=""})=>{const{dataStreams:i}=f(),[c,u]=t(void 0),[m,p]=t(s),[v,b]=t(void 0),[y,E]=t(null),D=o(null),S=l($),k=a(e=>{S.resetFormData({name:e}),S.handleErrorChange(void 0,void 0,{}),u(void 0),p(e),b(e),E(null),D.current=null},[]),C=a(()=>{const e=d(S.formData),t=(e=>{const t={};return e.name?g(e.name)||(t.name=h.ILLEGAL_K8S_LABEL):t.name=h.FIELD_IS_REQUIRED,t})(e);S.handleErrorChange(void 0,void 0,t);const a=Object.keys(t).length>0?h.REQUIRED_FIELDS:void 0;return u(a),{errorMessage:a,preparedFormData:e}},[S]),A=a(async e=>{const{errorMessage:t,preparedFormData:a}=C();if(t)return;const r=i.find(e=>e.name===a.name&&e.name!==m);if(r)return D.current=e,void E({preparedFormData:a,existingName:r.name,editingName:v});await e(a)},[C,i,m,v]),F=a(async()=>{const e=D.current,t=y?.preparedFormData;D.current=null,E(null),e&&t&&await e(t)},[y]),I=a(()=>{D.current=null,E(null)},[]),w=r(()=>({genericForm:S,loadDataStream:k,editingName:v,validateFormData:C,requestSubmit:A,pendingMerge:y,confirmMerge:F,cancelMerge:I,errorMessage:c,excludeName:m,setExcludeName:p}),[S,k,v,C,A,y,F,I,c,m]);return e(B.Provider,{value:w,children:n})},Y=()=>{const e=n(B);if(!e)throw new Error("useDataStreamFormContext must be used within a DataStreamFormContextProvider");return e},Z={type:"",name:"",currentStreamName:"",disabled:!1,exportedSignals:{logs:!1,metrics:!1,traces:!1,profiles:!1},fields:[]},ee={activeForm:null,onChangeActiveForm:()=>{},loadDestination:()=>{},genericForm:void 0,validateFormData:()=>({isOk:!1,preparedFormData:d(Z)}),unsavedDestinations:[],thisUnsavedDestination:void 0,setUnsavedDestinations:()=>{},addUnsavedDestination:()=>{},updateUnsavedDestination:()=>{},deleteUnsavedDestination:()=>{}},te=s(ee),ae=e=>e.filter(e=>!!e).map(e=>{const{name:t,componentType:a,componentProperties:r,displayName:n,initialValue:s,renderCondition:o}=e,i=a===k.Dropdown,l=D(r,{});return{componentType:a,renderCondition:o,name:t,title:n,value:s,placeholder:l.placeholder||(i?"Select an option":void 0),options:i&&Array.isArray(l.values)?l.values.map(e=>({id:e,label:e})):void 0,...l}}),re=({children:n})=>{const{selectedStreamName:s}=f(),o=v(e=>e.destinations),[c,u]=t(null),[m,g]=t(ee.unsavedDestinations),k=r(()=>"number"==typeof c?.unsavedIdx?m[c.unsavedIdx]:void 0,[c,m]),C=a((e,t)=>{c&&(g(t=>[...t,{...e,option:c.option}]),u(t?e=>e?{...e,listType:b.UNSAVED,unsavedIdx:m.length}:null:null))},[c,m.length]),A=a((e,t,a)=>{c&&(g(a=>a.map((a,r)=>r===e?{...a,...t,option:c.option}:a)),u(a?e=>e?{...e,listType:b.UNSAVED}:null:null))},[c]),F=a(e=>{g(t=>t.filter((t,a)=>a!==e)),u(null)},[]),I=l({...Z,currentStreamName:s});i(()=>{if(!c)return;if(k)return void I.resetFormData({...k.formData});if(c.listType===b.EXISTS&&c.option.id){const e=o.find(e=>e.id===c.option.id);if(e)return void I.resetFormData({type:e.destinationType.type,name:e.name||e.destinationType.displayName,currentStreamName:s,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);I.resetFormData({type:c.option.type,name:c.option.displayName,currentStreamName:s,disabled:!1,exportedSignals:{logs:e.includes(E.Logs),metrics:e.includes(E.Metrics),traces:e.includes(E.Traces),profiles:e.includes(E.Profiles)},fields:c.dynamicFields.map(e=>({key:e.name,value:e.value}))})},[c,k]);const w=a(e=>{I.resetFormData(),I.handleErrorChange(void 0,void 0,{}),u(e?{...e,dynamicFields:e.option?.fields?ae(e.option.fields):[]}:null)},[]),N=a((e,t)=>{let a;for(const r of t){const t=r.items.find(t=>t.type===e.destinationType.type);if(t){a=t;break}}const r=D(e.fields,{}),n={id:e.id,type:e.destinationType.type,displayName:e.name||e.destinationType.displayName,selected:!0,testConnectionSupported:a?.testConnectionSupported??!1,supportedSignals:e.destinationType.supportedSignals,fields:a?a.fields.map(e=>({...e,initialValue:r[e.name]??e.initialValue})):[]},s=ae(n.fields);u({listType:b.EXISTS,option:n,dynamicFields:s})},[]),x=a(()=>{const e=d(I.formData),t={};c?.dynamicFields.forEach(({name:a,required:r})=>{if(r){const r=e.fields.find(e=>e.key===a)?.value;p(r)&&(t[a]=h.FIELD_IS_REQUIRED)}});return S(e.exportedSignals).length||(t.exportedSignals=h.FIELD_IS_REQUIRED),I.handleErrorChange(void 0,void 0,t),{errorMessage:0===Object.keys(t).length?void 0:"Invalid form values",preparedFormData:e}},[I,c]);return e(te.Provider,{value:{activeForm:c,onChangeActiveForm:w,loadDestination:N,genericForm:I,validateFormData:x,unsavedDestinations:m,thisUnsavedDestination:k,setUnsavedDestinations:g,addUnsavedDestination:C,updateUnsavedDestination:A,deleteUnsavedDestination:F},children:n})},ne=()=>n(te),se={disabled:!1,ruleName:"",notes:"",sourceScopes:T(),workloads:null,instrumentationLibraries:null,payloadCollection:null,codeAttributes:null,headersCollection:null,customInstrumentations:null},oe=s(null),ie=({children:n,sourceOptions:s=[],namespaceOptions:o=[]})=>{const[i,c]=t(null),u=l(se),m=a(e=>{u.resetFormData(),u.handleErrorChange(void 0,void 0,{}),c(e)},[]),p=a(e=>{var t;u.resetFormData((({ruleName:e,notes:t,disabled:a,sourceScopes:r,instrumentationLibraries:n,payloadCollection:s,codeAttributes:o,headersCollection:i,customInstrumentations:l})=>({ruleName:e||"",notes:t||"",disabled:!!a,sourceScopes:O(r),workloads:null,instrumentationLibraries:n??null,payloadCollection:s??null,codeAttributes:o??null,headersCollection:i??null,customInstrumentations:l??null}))(e)),u.handleErrorChange(void 0,void 0,{}),c((t=e.type,C.find(e=>e.type===t)??null))},[]),h=a(()=>{if(!i)return{errorMessage:"No rule type selected",preparedFormData:d(se)};const e=(e=>{const t=d(e),a={...t,sourceScopes:L(t.sourceScopes)?null:t.sourceScopes,workloads:null};return a.headersCollection?.[A.HeaderKeys]?.length&&(a.headersCollection[A.HeaderKeys]=a.headersCollection[A.HeaderKeys].map(e=>e.trim()).filter(e=>e)),a.customInstrumentations?.[F.Golang]?.length&&(a.customInstrumentations[F.Golang]=a.customInstrumentations[F.Golang].map(e=>new I(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})),a.customInstrumentations?.[F.Java]?.length&&(a.customInstrumentations[F.Java]=a.customInstrumentations[F.Java].map(e=>new w(e.className,e.methodName)).filter(e=>{return t=e,!(!t.className?.trim()&&!t.methodName?.trim());var t})),a})(u.formData),t=((e,t)=>{const a={};switch(e){case N.CodeAttributes:Object.values(t.codeAttributes||{}).some(e=>null!=e)||(a.codeAttributes="Code attributes are required");break;case N.PayloadCollection:Object.values(t.payloadCollection||{}).some(e=>null!=e)||(a.payloadCollection="Payload collection are required");break;case N.HeadersCollection:t.headersCollection?.[A.HeaderKeys]?.length||(a.headersCollection="Header keys are required");break;case N.CustomInstrumentation:{const e=t.customInstrumentations?.[F.Golang]||[],r=t.customInstrumentations?.[F.Java]||[];if(!e.length&&!r.length){a.customInstrumentations="Custom instrumentation are required";break}const n=e.findIndex(e=>!new I(e.packageName,e.functionName,e.receiverName,e.receiverMethodName).Verify());if(-1!==n){a.customInstrumentations=`Golang probe #${n+1} is invalid: provide a package name plus either a function name OR both a receiver name and receiver method name`;break}const s=r.findIndex(e=>!new w(e.className,e.methodName).Verify());if(-1!==s){a.customInstrumentations=`Java probe #${s+1} is invalid: both class name and method name are required`;break}break}}return a})(i.type,e);return u.handleErrorChange(void 0,void 0,t),{errorMessage:Object.keys(t).length>0?"Invalid form values":void 0,preparedFormData:e}},[u,i]),f=r(()=>({selectedOption:i,onSelectOption:m,loadRule:p,genericForm:u,validateFormData:h,sourceOptions:s,namespaceOptions:o}),[i,m,p,u,h,s,o]);return e(oe.Provider,{value:f,children:n})},le=()=>{const e=n(oe);if(!e)throw new Error("useRuleFormContext must be used within a RuleFormContextProvider");return e};var de;!function(e){e.Create="create",e.View="view",e.EditAutoNoisy="edit-auto-noisy",e.EditAutoCostReduction="edit-auto-cost-reduction",e.EditAutoHighlyRelevant="edit-auto-highly-relevant"}(de||(de={}));const ce=s(null),ue=["50","25","10","1"];function me(e){const t=String(e);return ue.includes(t)?t:"custom"}const pe=({category:n,sourceOptions:s=[],namespaceOptions:o=[],children:d})=>{const{formData:c,handleFormChange:u,resetFormData:m}=l(q(n)),[p,h]=t(null);i(()=>{m(q(n)),h(null)},[n]);const f=a(e=>{h(null),u(void 0,void 0,{...c,...e})},[c,u]),g=a(()=>{m(q(n)),h(null)},[n,m]),v=r(()=>({formType:de.Create,category:n,formData:c,handleChange:f,resetForm:g,duplicateWarning:p,setDuplicateWarning:h,sourceOptions:s,namespaceOptions:o}),[n,c,f,g,p,s,o]);return e(ce.Provider,{value:v,children:d})},he=({data:n,defaultEditMode:s,sourceOptions:d=[],namespaceOptions:c=[],children:u})=>{const[m,p]=t(!1),{formData:h,handleFormChange:f,resetFormData:g}=l(void 0),v=o(null),[b,y]=t(null);i(()=>{n!==v.current&&(v.current=n,n&&s?(g(K(n)),y(null),p(!0)):(p(!1),y(null)))},[n,s]);const E=a(e=>{y(null),f(void 0,void 0,{...h,...e})},[h,f]),D=a(()=>{n&&(g(K(n)),y(null),p(!0))},[n,g]),S=a(()=>{p(!1),y(null)},[]),k=r(()=>({formType:de.View,data:n,isEditing:m,formData:h,handleChange:E,handleEdit:D,handleCancelEdit:S,duplicateWarning:b,setDuplicateWarning:y,sourceOptions:d,namespaceOptions:c}),[n,m,h,E,D,S,b,d,c]);return e(ce.Provider,{value:k,children:u})};function fe(e){const[a,n]=t(()=>0===e?"all":"sample"),[s,o]=t(()=>me(e)),[l,d]=t(()=>"custom"===me(e)?String(e):"");i(()=>{n(0===e?"all":"sample");const t=me(e);o(t),d("custom"===t?String(e):"")},[e]);const c=r(()=>"all"===a?0:"custom"===s?Number(l)||0:Number(s),[a,s,l]);return{percentageMode:a,setPercentageMode:n,percentagePreset:s,setPercentagePreset:o,customPercentage:l,setCustomPercentage:d,resolvedPercentage:c}}const ge=({enabled:a,keepPercentage:n,children:s})=>{const[o,l]=t(a),d=fe(n);i(()=>{l(a)},[a]);const c=r(()=>j({enabled:o,keepPercentage:d.resolvedPercentage}),[o,d.resolvedPercentage]),u=r(()=>({formType:de.EditAutoNoisy,localEnabled:o,setLocalEnabled:l,...d,summary:c}),[o,d,c]);return e(ce.Provider,{value:u,children:s})},ve=({enabled:a,dropPercentage:n,children:s})=>{const[o,l]=t(a),d=fe(n);i(()=>{l(a)},[a]);const c=r(()=>U(o?{disabled:!1,percentageAtMost:d.resolvedPercentage}:null),[o,d.resolvedPercentage]),u=r(()=>({formType:de.EditAutoCostReduction,localEnabled:o,setLocalEnabled:l,...d,summary:c}),[o,d,c]);return e(ce.Provider,{value:u,children:s})},be=({enabled:a,children:n})=>{const[s,o]=t(a);i(()=>{o(a)},[a]);const l=r(()=>M(s?{disabled:!1}:null),[s]),d=r(()=>({formType:de.EditAutoHighlyRelevant,localEnabled:s,setLocalEnabled:o,summary:l}),[s,l]);return e(ce.Provider,{value:d,children:n})},ye=t=>{switch(t.formType){case de.Create:return e(pe,{...t});case de.View:return e(he,{...t});case de.EditAutoNoisy:return e(ge,{...t});case de.EditAutoCostReduction:return e(ve,{...t});case de.EditAutoHighlyRelevant:return e(be,{...t})}};function Ee(e){const t=n(ce);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 De={otelServiceName:"",currentStreamName:""},Se=s(null),ke=({children:n})=>{const[s,o]=t(void 0),i=l(De),c=a(e=>{i.resetFormData((({serviceName:e,id:t})=>({otelServiceName:e||t.name||"",currentStreamName:""}))(e)),i.handleErrorChange(void 0,void 0,{}),o(void 0)},[]),u=a(()=>{const e=d(i.formData);return i.handleErrorChange(void 0,void 0,{}),o(void 0),{errorMessage:void 0,preparedFormData:e}},[i]),m=r(()=>({loadSource:c,genericForm:i,validateFormData:u,errorMessage:s}),[c,i,u,s]);return e(Se.Provider,{value:m,children:n})},Ce=()=>{const e=n(Se);if(!e)throw new Error("useSourceEditFormContext must be used within a SourceEditFormContextProvider");return e},Ae=new Set([x.StaticPod]),Fe=e=>{const t=e.workloads.filter(({selected:e})=>e).length,a=e.workloads.length;return{selectedCount:t,isAllSourced:t>0&&t===a,isSomeSourced:t>0&&t<a,isFutureApps:e.selected||!1}},Ie=(e,t,a)=>{if(t&&!e.name.toLowerCase().includes(t.toLowerCase()))return!1;if(a.showOnlySelected){const{isAllSourced:t,isSomeSourced:a,isFutureApps:r}=Fe(e);return t||a||r}return!0},we=(e,t,a)=>!(t&&!e.name.toLowerCase().includes(t.toLowerCase()))&&(!a.showOnlySelected||e.selected),Ne=s({snapshots:null,setSnapshots:()=>{},isFetching:!1,setIsFetching:()=>{},formData:[],handleSourceChange:()=>{},handleSelectAll:()=>{},formDiff:{},isFormDirty:!1}),xe=({children:n,selectedConnectionIds:s,initialInputs:o})=>{const{tier:l}=G(),c=l===R.Onprem,{selectedStreamName:u}=f(),[m,p]=t(!1),[h,g]=t(null),[v,b]=t([]);i(()=>{h&&b(e=>{const t=((e,t)=>d(((e,t)=>e.clusters.filter(({clusterId:e})=>!t||t.includes(e)))(e,t)))(h,s);return t.map(t=>{const a=e?.find(e=>e.clusterId===t.clusterId),r=a??t;if(o?.[t.clusterId]){const e=o[t.clusterId],a=d(r);return e.forEach(e=>{const t=a.namespaces.find(t=>t.name===e.namespace);if(t)if(e.name&&e.kind){const a=t.workloads.find(t=>t.name===e.name&&t.kind===e.kind);a&&(a.selected=e.selected)}else t.selected=e.selected,e.selected&&t.workloads.forEach(e=>{Ae.has(e.kind)&&!c||(e.selected=!0)})}),a}return r})})},[h,s,o]);const{formDiff:y,isFormDirty:E}=r(()=>{const e=((e,t,a)=>{const r={};return e.forEach(e=>{e.namespaces.forEach(n=>{const s=t.find(t=>t.clusterId===e.clusterId)?.namespaces.find(e=>e.name===n.name),o=n.selected||!1;if(o!==s?.selected)r[e.clusterId]||(r[e.clusterId]=[]),r[e.clusterId].push({namespace:n.name,selected:o,currentStreamName:a}),o?r[e.clusterId]=r[e.clusterId].filter(e=>e.namespace!==n.name||e.namespace===n.name&&(!e.name||!e.kind)):n.workloads.forEach(t=>{t.selected&&r[e.clusterId].push({namespace:n.name,name:t.name,kind:t.kind,selected:!0,currentStreamName:a})});else{const t=((e,t,a)=>{const r=[];return t.workloads.forEach(n=>{const s=e?.workloads.find(e=>e.name===n.name&&e.kind===n.kind);n.selected!==s?.selected&&r.push({namespace:t.name,name:n.name,kind:n.kind,selected:n.selected||!1,currentStreamName:a})}),r})(s,n,a);t.length>0&&(r[e.clusterId]||(r[e.clusterId]=[]),r[e.clusterId].push(...t))}})}),r})(v,h?.clusters||[],u);return{formDiff:e,isFormDirty:Object.keys(e).length>0}},[v,h,u]),D=a(e=>!c&&Ae.has(e),[c]),S=a(({clusterId:e,workloadId:t,selected:a,auto:r})=>{b(n=>{const s=d(n),o=s.findIndex(t=>t.clusterId===e);if(-1===o)return s;const i=s[o].namespaces.findIndex(e=>e.name===t.namespace);if(-1===i)return s;if(t.kind&&t.name){const e=s[o].namespaces[i].workloads.findIndex(e=>e.name===t.name&&e.kind===t.kind);if(-1===e)return s;const r="boolean"==typeof a?a:!s[o].namespaces[i].workloads[e].selected;if(s[o].namespaces[i].workloads[e].selected=r,r){s[o].namespaces[i].workloads.filter(e=>!D(e.kind)).every(e=>e.selected)&&(s[o].namespaces[i].selected=!0)}else s[o].namespaces[i].selected=!1}else{const e="boolean"==typeof r?r:!s[o].namespaces[i].selected;s[o].namespaces[i].selected=e,e?s[o].namespaces[i].workloads.forEach(e=>{D(e.kind)||(e.selected=!0)}):"boolean"!=typeof a||a||s[o].namespaces[i].workloads.forEach(e=>{e.selected=!1})}return s})},[D]),k=a(({clusterId:e,namespaceName:t,boolean:a,searchText:r="",searchBy:n="",filters:s})=>{b(o=>{const i=d(o),l=n===P.Namespace?r:"",c=n===P.Source?r:"",u=!!l||!!c||!!s?.showOnlySelected;return i.forEach((r,n)=>{e&&r.clusterId!==e||r.namespaces.forEach(({name:e,workloads:r},o)=>{if(!t||e===t)if(u)if(t){r.forEach((e,t)=>{a&&D(e.kind)||we(e,c,s||{showOnlySelected:!1})&&(i[n].namespaces[o].workloads[t].selected=a)});const e=i[n].namespaces[o].workloads.filter(e=>!D(e.kind)).every(e=>e.selected);i[n].namespaces[o].selected=e}else{if(!Ie(i[n].namespaces[o],l,s||{showOnlySelected:!1}))return;i[n].namespaces[o].selected=a,r.forEach((e,t)=>{a&&D(e.kind)||(i[n].namespaces[o].workloads[t].selected=a)})}else i[n].namespaces[o].selected=a,r.forEach((e,t)=>{a&&D(e.kind)||(i[n].namespaces[o].workloads[t].selected=a)})})}),i})},[D]);return e(Ne.Provider,{value:{snapshots:h,setSnapshots:g,isFetching:m,setIsFetching:p,formData:v,handleSourceChange:S,handleSelectAll:k,formDiff:y,isFormDirty:E},children:n})},Re=()=>n(Ne);export{Q as A,X as D,Ae as E,ie as R,de as S,re as a,ye as b,ke as c,xe as d,Y as e,ne as f,le as g,Ee as h,Ce as i,Re as j,we as k,Ie as l,Fe as m,W as u};