@odigos/ui-kit 0.0.244 → 0.0.246

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 (65) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/lib/chunks/helpers-BFZzc68M.js +19 -0
  3. package/lib/chunks/index-BrSebk-Z.js +155 -0
  4. package/lib/chunks/source-instrument-form-context-n8N3zC_-.js +1 -0
  5. package/lib/chunks/ui-components-DNrEjxrR.js +1635 -0
  6. package/lib/components/_v2/cards/section-card/index.d.ts +3 -1
  7. package/lib/components/_v2/input-table/dynamic-field/index.d.ts +1 -0
  8. package/lib/components/_v2/input-table/types.d.ts +2 -1
  9. package/lib/components/_v2/table/styled.d.ts +7 -1
  10. package/lib/components/_v2/table/table-columns/index.d.ts +2 -0
  11. package/lib/components/_v2/table/table-rows/index.d.ts +2 -0
  12. package/lib/components/_v2/typography/index.d.ts +8 -4
  13. package/lib/components/_v2/typography-truncatable/index.d.ts +18 -10
  14. package/lib/components/styled.d.ts +4 -1
  15. package/lib/components/v2.js +1 -1
  16. package/lib/components.js +1 -1
  17. package/lib/constants/index.d.ts +1 -0
  18. package/lib/constants/regex.d.ts +40 -0
  19. package/lib/constants/sampling/index.d.ts +5 -0
  20. package/lib/constants.js +1 -1
  21. package/lib/containers/_v2/_drawers/edit-source-drawer/{yaml-files → debug}/index.d.ts +2 -2
  22. package/lib/containers/_v2/_drawers/index.d.ts +1 -0
  23. package/lib/containers/_v2/_drawers/regex-tester-drawer/highlighter.d.ts +20 -0
  24. package/lib/containers/_v2/_drawers/regex-tester-drawer/index.d.ts +13 -0
  25. package/lib/containers/_v2/_forms/add-action-form/custom-fields/extract-attribute/index.d.ts +5 -0
  26. package/lib/containers/_v2/central-connections/index.d.ts +1 -2
  27. package/lib/containers/_v2/overview/columns/index.d.ts +1 -2
  28. package/lib/containers/_v2/overview/drawers/index.d.ts +4 -1
  29. package/lib/containers/_v2/overview/index.d.ts +0 -2
  30. package/lib/containers/_v2/pipeline-collectors/index.d.ts +3 -3
  31. package/lib/containers/_v2/pipeline-collectors/pods-info/index.d.ts +2 -2
  32. package/lib/containers/_v2/sampling-rules/helpers.d.ts +2 -1
  33. package/lib/containers/_v2/sampling-rules/rules-table/index.d.ts +1 -2
  34. package/lib/containers/_v2/sampling-rules/types.d.ts +0 -2
  35. package/lib/containers/_v2/settings/index.d.ts +0 -1
  36. package/lib/containers/service-map/index.d.ts +0 -1
  37. package/lib/containers/v2.js +255 -126
  38. package/lib/containers.js +7 -4
  39. package/lib/contexts/rule-form-context.d.ts +13 -4
  40. package/lib/contexts.js +1 -1
  41. package/lib/functions/index.d.ts +1 -0
  42. package/lib/functions/instrumentation-rule-source-scopes/index.d.ts +76 -0
  43. package/lib/functions.js +1 -1
  44. package/lib/hooks/index.d.ts +1 -0
  45. package/lib/hooks/useInstrumentationRuleFormData.d.ts +2 -2
  46. package/lib/hooks/useOverflow.d.ts +26 -0
  47. package/lib/hooks.js +1 -1
  48. package/lib/snippets/_v2/index.d.ts +1 -0
  49. package/lib/snippets/_v2/instrumentation-rule-form-sections/index.d.ts +1 -0
  50. package/lib/snippets/_v2/instrumentation-rule-form-sections/instrumentation-preview.d.ts +10 -0
  51. package/lib/snippets/_v2/rich-title/index.d.ts +5 -1
  52. package/lib/snippets/_v2/sampling-rule-form-sections/source-scope.d.ts +18 -8
  53. package/lib/snippets/v2.js +1 -1
  54. package/lib/snippets.js +2 -2
  55. package/lib/store.js +1 -1
  56. package/lib/theme.js +1 -1
  57. package/lib/types/actions/index.d.ts +19 -2
  58. package/lib/types/instrumentation-rules/index.d.ts +14 -0
  59. package/lib/types.js +1 -1
  60. package/lib/visuals.js +1 -1
  61. package/package.json +1 -1
  62. package/lib/chunks/helpers-aJJ1GhqS.js +0 -19
  63. package/lib/chunks/index-BnOPIhIp.js +0 -149
  64. package/lib/chunks/source-instrument-form-context-5GXsAhJd.js +0 -1
  65. package/lib/chunks/ui-components-Dnqp-MQm.js +0 -1592
@@ -1,149 +0,0 @@
1
- import{ah as e,a2 as a,H as t,Z as l,_ as r,dL as i,V as n,au as s,a7 as o,X as d,C as c,$ as u,a3 as p,dM as h,T as g,F as m,R as v,U as f,a6 as b,aq as y,dN as x,dO as S,aB as C,dP as k,b as T,dQ as w,aa as $,c as P,dR as M,dS as A,dT as L,dU as O,dV as z,dW as D,dX as X,ct as I,dY as R,dZ as N,d_ as B,d$ as E,e0 as H,bG as V,a1 as j,e1 as q,e2 as U,e3 as G,e4 as J,e5 as K,e6 as W,e7 as F,e8 as Y,e9 as Z,ea as _,eb as Q,ar as ee,ec as ae,ed as te,ee as le,ef as re,eg as ie,bt as ne,eh as se,ei as oe,ej as de,ek as ce,el as ue,em as pe,en as he,eo as ge,a0 as me,ep as ve,eq as fe,er as be,es as ye,n as xe,et as Se,S as Ce,eu as ke,ev as Te,ew as we,ex as $e,ey as Pe,d8 as Me,ag as Ae,bj as Le,p as Oe,d3 as ze,W as De,ez as Xe,b4 as Ie,at as Re,a4 as Ne,f as Be,ax as Ee,dk as He,b3 as Ve,b9 as je,b2 as qe,bJ as Ue,aK as Ge,eA as Je}from"./ui-components-Dnqp-MQm.js";import{jsx as Ke,jsxs as We,Fragment as Fe}from"react/jsx-runtime";import{u as Ye,w as Ze,x as _e,C as Qe,y as ea,z as aa,A as ta,B as la,D as ra,E as ia,F as na}from"./helpers-aJJ1GhqS.js";import{OdigosLogoTextCentral as sa,OdigosLogoTextEnterprise as oa,OdigosLogoTextCommunity as da,OdigosLogoTextColoredCentral as ca,OdigosLogoTextColoredEnterprise as ua,OdigosLogoTextColoredCommunity as pa,EditIcon as ha,ArrowLeftIcon as ga,ArrowRightIcon as ma,VSquareIcon as va,VIcon as fa,CopyIcon as ba,YamlIcon as ya}from"../icons.js";import{useCallback as xa,useMemo as Sa,useState as Ca,useRef as ka,useEffect as Ta,forwardRef as wa,useImperativeHandle as $a}from"react";import Pa from"styled-components";const Ma=({isOpen:t,onClose:l,onDeny:r,onApprove:i})=>Ke(e,{title:"Discard changes?",description:"You have unsaved changes.\nIf you cancel now, your changes won't be saved.",isOpen:t,onClose:l,denyButton:{label:"Keep editing",variant:a.Secondary,onClick:()=>{r?.(),l()}},approveButton:{label:"Discard changes",variant:a.Primary,onClick:()=>{i?.(),l()}}}),Aa=({isOpen:t,onClose:l,onDeny:r,onApprove:i,action:n="delete",target:s,description:o,overrideApproveButtonLabel:d,overrideDenyButtonLabel:c})=>{const u=n.charAt(0).toUpperCase()+n.substring(1),p=s?.endsWith("s")?"these":"this";return Ke(e,{title:`${u}${s?` ${s}`:""}?`,description:o??`Are you sure you want to ${n}${s?` ${p} ${s}`:""}?`,isOpen:t,onClose:l,denyButton:{label:c??"Go back",variant:a.Secondary,onClick:()=>{r?.(),l()}},approveButton:{label:d??u,variant:a.Primary,onClick:()=>{i?.(),l()}}})},La=({componentType:e,inputType:a,name:g,label:m,tooltip:v,badge:f,placeholder:b,required:y,disabled:x,value:S,setValue:C,errorMessage:k,warnMessage:T,helpMessage:w,dropdownOptions:$,dropdownNoSearch:P,dropdownNoCheckbox:M,timeUnits:A,timeDefaultUnit:L})=>{switch(e){case t.Input:return Ke(p,{name:g,type:a,label:m,tooltip:v,badge:f,placeholder:b,required:y,disabled:x,value:S??"",onChange:e=>{const t=e.target.value;C(a===h.Number?""===t?null:Number(t):t)},errorMessage:k,warnMessage:T,helpMessage:w},g);case t.MultiInput:return Ke(u,{name:g,label:m,tooltip:v,badge:f,placeholder:b,required:y,disabled:x,values:Array.isArray(S)?S:c(S,[]),setValues:e=>C(e),errorMessage:k,warnMessage:T,helpMessage:w},g);case t.KeyValuePair:return Ke(d,{name:g,label:m,tooltip:v,badge:f,required:y,disabled:x,limitFieldsPerRow:2,columns:[{keyName:"key",label:"Key"},{keyName:"value",label:"Value"}],values:Array.isArray(S)?S:c(S,[]),setValues:e=>C(e),errorMessage:k,warnMessage:T,helpMessage:w},g);case t.TextArea:return Ke(o,{name:g,label:m,tooltip:v,badge:f,required:y,disabled:x,placeholder:b,value:S??"",onChange:e=>C(e.target.value),errorMessage:k,warnMessage:T,helpMessage:w},g);case t.Dropdown:return Ke(s,{name:g,label:m,tooltip:v,badge:f,placeholder:b,required:y,disabled:x,withSearch:!P,options:$?.map(e=>({id:e.id||"",label:e.label||"",withCheckbox:!M}))||[],values:S?[String(S)]:[],setValues:e=>C(e[0]),errorMessage:k,warnMessage:T,helpMessage:w},g);case t.Checkbox:return Ke(n,{name:g,label:m,tooltip:v,badge:f,value:!0===S||"true"===S,onChange:e=>C(e),disabled:x,errorMessage:k,warnMessage:T,helpMessage:w},g);case t.Time:return Ke(i,{name:g,label:m,tooltip:v,badge:f,placeholder:b,required:y,disabled:x,value:S??"",setValue:e=>C(e),units:A,defaultUnit:L,errorMessage:k,warnMessage:T,helpMessage:w},g);case t.Toggle:return Ke(l,{name:g,labelAlign:r.Right,label:m,tooltip:v,badge:f,value:!0===S||"true"===S,onChange:e=>C(e),disabled:x,errorMessage:k,warnMessage:T,helpMessage:w},g);default:return null}},Oa=({size:e=200,central:a=!1,useInline:t=!1})=>{const{tier:l}=Ye();if(t){if(a)return Ke(sa,{size:e});switch(l){case g.Community:return Ke(da,{size:e});case g.Onprem:return Ke(oa,{size:e});default:return null}}if(a)return Ke(ca,{size:e});switch(l){case g.Community:return Ke(pa,{size:e});case g.Onprem:return Ke(ua,{size:e});default:return null}},za=[{value:"50",label:"50%"},{value:"25",label:"25%"},{value:"10",label:"10%"},{value:"1",label:"1%"},{value:"custom",label:"Custom"}],Da=[{value:"10",label:"10%"},{value:"1",label:"1%"},{value:"0.5",label:"0.5%"},{value:"0.1",label:"0.1%"},{value:"custom",label:"Custom"}],Xa=[{value:"5000",label:"5s"},{value:"1000",label:"1s"},{value:"500",label:"500ms"},{value:"100",label:"100ms"},{value:"50",label:"50ms"},{value:"custom",label:"Custom"}],Ia=({description:e,options:a,selected:t,onSelect:l,customName:r,customLabel:i,customPlaceholder:n,customValue:s,onCustomChange:o,customInputType:d=h.Number,customMin:c,customMax:u})=>We(m,{$gap:16,$alignItems:"flex-end",children:[We(v,{$gap:6,children:[Ke(f,{label:e}),Ke(b,{options:a,selected:t,setSelected:l})]}),"custom"===t&&Ke(p,{name:r,label:i,placeholder:n,type:d,value:s,onChange:o,width:160,min:c,max:u})]}),Ra=()=>{},Na=e=>e.readOnly?Ke(Ba,{rule:e.rule}):Ke(Ea,{ruleType:e.ruleType,formState:e.formState,onChange:e.onChange}),Ba=({rule:e})=>{const a=null!=e.durationAtLeastMs;return e.error?Ke(y,{richTitle:{title:x},children:Ke(l,{name:"sampling-view-toggle-keep-errors",onChange:Ra,value:!0,size:C.S,label:S,labelAlign:r.Right})}):a?Ke(y,{richTitle:{title:k},children:We("div",{children:[Ke(T,{size:P.XXXS,color:$.Secondary,children:w}),Ke(T,{size:P.XS,children:`${e.durationAtLeastMs}ms`})]})}):null},Ea=({ruleType:e,formState:a,onChange:t})=>{const i=xa(e=>t({durationPreset:e}),[t]),n=xa(e=>t({customDurationMs:e.target.value}),[t]);return"Error"===e?Ke(y,{richTitle:{title:x,subTitle:M},children:Ke(l,{name:"sampling-toggle-keep-errors",value:!0,onChange:Ra,size:C.S,label:S,labelAlign:r.Right})}):"Duration"===e?Ke(y,{richTitle:{title:k,subTitle:A},children:Ke(Ia,{description:w,options:Xa,selected:a.durationPreset,onSelect:i,customName:"sampling-input-custom-duration",customLabel:L,customPlaceholder:"200ms",customValue:a.customDurationMs,onCustomChange:n})}):null},Ha=Pa.div`
2
- display: flex;
3
- gap: 32px;
4
- `,Va=Pa.div`
5
- display: flex;
6
- flex-direction: column;
7
- gap: 4px;
8
- `,ja=Pa.div`
9
- display: flex;
10
- flex-wrap: wrap;
11
- align-items: flex-end;
12
- gap: 16px;
13
- `,qa=Pa.div`
14
- display: flex;
15
- align-items: flex-end;
16
- gap: 16px;
17
- padding: 12px 16px;
18
- border-radius: 8px;
19
- background-color: ${({theme:e})=>e.v2.colors.black[500]};
20
- `,Ua=Pa.div`
21
- display: flex;
22
- align-items: flex-end;
23
- gap: 10px;
24
- flex: 1;
25
- `,Ga=Pa.div`
26
- display: flex;
27
- align-items: center;
28
- height: 32px;
29
- `,Ja=Pa.div`
30
- display: flex;
31
- align-items: flex-end;
32
- gap: 16px;
33
- margin-bottom: 12px;
34
- `,Ka="Any",Wa="Kafka topic",Fa=()=>Ke("div",{style:{marginBottom:"8px"},children:Ke(T,{size:P.XS,weight:500,children:"And"})}),Ya=[{value:"all",label:"All Operations"},{value:"httpServer",label:"HTTP Server"},{value:"httpClient",label:"HTTP Client"}],Za=[{value:"all",label:"All Operations"},{value:"httpServer",label:"HTTP Server"},{value:"kafkaConsumer",label:"Kafka Consumer"},{value:"kafkaProducer",label:"Kafka Producer"}],_a=[{id:"",label:Ka},{id:"GET",label:"GET"},{id:"POST",label:"POST"},{id:"PUT",label:"PUT"},{id:"DELETE",label:"DELETE"},{id:"PATCH",label:"PATCH"}];const Qa=e=>e.readOnly?Ke(et,{data:e.data}):Ke(at,{category:e.category,formState:e.formState,onChange:e.onChange}),et=({data:e})=>{const a=Sa(()=>function(e){if("noisy"===e.category){const a=e.rule.operation;if(a?.httpServer)return[{id:"type",title:J,value:G},{id:"route",title:B,value:a.httpServer.route||a.httpServer.routePrefix||K},{id:"method",title:q,value:a.httpServer.method||Ka}];if(a?.httpClient){const e=[{id:"type",title:J,value:W}];return a.httpClient.serverAddress&&e.push({id:"serverAddress",title:"Server address",value:a.httpClient.serverAddress}),e.push({id:"route",title:B,value:a.httpClient.templatedPath||a.httpClient.templatedPathPrefix||K}),e.push({id:"method",title:q,value:a.httpClient.method||Ka}),e}return[{id:"type",title:J,value:F}]}const a=e.rule.operation;return a?.httpServer?[{id:"type",title:J,value:G},{id:"route",title:B,value:a.httpServer.route||a.httpServer.routePrefix||K},{id:"method",title:q,value:a.httpServer.method||Ka}]:a?.kafkaConsumer?[{id:"type",title:J,value:Y},{id:"topic",title:Wa,value:a.kafkaConsumer.kafkaTopic||K}]:a?.kafkaProducer?[{id:"type",title:J,value:Z},{id:"topic",title:Wa,value:a.kafkaProducer.kafkaTopic||K}]:[{id:"type",title:J,value:F}]}(e),[e]);return Ke(y,{richTitle:{title:O},children:Ke(Ha,{children:a.map(({id:e,title:a,value:t})=>We(Va,{children:[Ke(T,{size:P.XXXS,color:$.Secondary,nowrap:!0,children:a}),Ke(T,{size:P.XS,nowrap:!0,children:t})]},e))})})},at=({category:e,formState:t,onChange:l})=>{const r=Sa(()=>"noisy"===e?Ya:Za,[e]),i=xa(e=>l({operationType:e,route:"",serverAddress:"",method:"",kafkaTopic:""}),[l]),n=xa(e=>a=>{a&&l({routeType:e,route:""})},[l]),s=xa(e=>l({route:e.target.value}),[l]),o=xa(e=>l({serverAddress:e.target.value}),[l]),d=xa(e=>l({method:e[0]||""}),[l]),c=xa(e=>l({kafkaTopic:e.target.value}),[l]),u="httpServer"===t.operationType||"httpClient"===t.operationType,h="kafkaConsumer"===t.operationType||"kafkaProducer"===t.operationType,g="httpClient"===t.operationType?N:B,m="httpClient"===t.operationType?E:H;return We(y,{richTitle:{title:`2. ${O}`,subTitle:z},children:[Ke(v,{$alignItems:"flex-start",children:Ke(b,{options:r,selected:t.operationType,setSelected:i})}),u&&We(ja,{children:["httpClient"===t.operationType&&We(Ja,{children:[Ke(p,{name:"sampling-input-server-address",label:X,placeholder:D,value:t.serverAddress,onChange:o}),Ke(Fa,{})]}),We(qa,{children:[We(Ua,{children:[Ke(Ga,{children:Ke(I,{"data-id":"sampling-radio-route",value:"route"===t.routeType,onChange:n("route")})}),Ke(p,{name:"sampling-input-route",label:g,placeholder:R,value:"route"===t.routeType?t.route:"",onChange:s,disabled:"route"!==t.routeType})]}),We(Ua,{children:[Ke(Ga,{children:Ke(I,{"data-id":"sampling-radio-route-prefix",value:"routePrefix"===t.routeType,onChange:n("routePrefix")})}),Ke(p,{name:"sampling-input-route-prefix",label:m,placeholder:R,value:"routePrefix"===t.routeType?t.route:"",onChange:s,disabled:"routePrefix"!==t.routeType})]})]}),We(Ja,{children:[Ke(Fa,{}),Ke(V,{label:q,items:_a,selectedIds:[t.method||""],setSelectedIds:e=>d(e),buttonProps:{"data-id":"sampling-btn-method",label:_a.find(e=>e.id===t.method)?.label||Ka,size:j.S,variant:a.Secondary}})]})]}),h&&Ke(p,{name:"sampling-input-kafka-topic",label:U,placeholder:"Type kafka topic",value:t.kafkaTopic,onChange:c,width:"320px"})]})},tt=[{value:"all",label:"Drop All"},{value:"sample",label:"Sample"}],lt=[{value:"all",label:"Keep All"},{value:"sample",label:"Sample"}];const rt=e=>e.readOnly?Ke(it,{data:e.data}):Ke(nt,{category:e.category,formState:e.formState,onChange:e.onChange}),it=({data:e})=>{const a=Sa(()=>function(e){switch(e.category){case"highlyRelevant":return null!=e.rule.percentageAtLeast?{title:Q,method:le,description:ae,value:`${e.rule.percentageAtLeast}%`}:{title:Q,method:ie,description:null,value:null};case"noisy":return Ze(e.rule.percentageAtMost)?{title:Q,method:re,description:null,value:null}:{title:Q,method:le,description:te,value:`${e.rule.percentageAtMost}%`};case"costReduction":return{title:Q,method:le,description:te,value:`${e.rule.percentageAtMost}%`}}}(e),[e]),t=[{id:"method",title:q,value:a.method},...null!=a.description?[{id:"value",title:a.description,value:a.value}]:[]];return Ke(y,{richTitle:{title:a.title},children:Ke(Ha,{children:t.map(({id:e,title:a,value:t})=>We(Va,{children:[Ke(T,{size:P.XXXS,color:$.Secondary,nowrap:!0,children:a}),Ke(T,{size:P.XS,nowrap:!0,children:t})]},e))})})},nt=({category:e,formState:a,onChange:t})=>{const l="highlyRelevant"===e,r=l?lt:tt,i=`${l?4:3}. ${Q}`,n=_[e],s=l?ae:te,o="noisy"===e?Da:za,d=xa(e=>t({percentageMode:e}),[t]),c=xa(e=>t({percentagePreset:e}),[t]),u=xa(e=>t({customPercentage:e.target.value}),[t]);return We(y,{richTitle:{title:i,subTitle:n},children:["costReduction"!==e&&Ke(v,{$alignItems:"flex-start",children:Ke(b,{options:r,selected:a.percentageMode,setSelected:d})}),("costReduction"===e||"sample"===a.percentageMode)&&Ke(Ia,{description:s,options:o,selected:a.percentagePreset,onSelect:c,customName:"sampling-input-custom-percentage",customLabel:ee,customPlaceholder:"5%",customValue:a.customPercentage,onCustomChange:u,customInputType:h.Decimal,customMin:0,customMax:100})]})},st=Pa.div`
35
- display: flex;
36
- align-items: flex-end;
37
- gap: 16px;
38
- `,ot=Pa.div`
39
- width: 280px;
40
- flex-shrink: 0;
41
- `,dt=Pa.div`
42
- flex: 1;
43
- min-width: 0;
44
- `;function ct(e){return"highlyRelevant"===e.category?e.rule.error?"Error":null!=e.rule.durationAtLeastMs?"Duration":"Relevance":he[e.category]}const ut=e=>e.readOnly?Ke(pt,{data:e.data}):Ke(ht,{formState:e.formState,onChange:e.onChange}),pt=({data:e})=>{const a=Sa(()=>[{id:"name",title:se,value:e.rule.name||ne},{id:"type",title:oe,value:ct(e)}],[e]),t=e.rule.notes||K;return We(y,{children:[Ke(Ha,{children:a.map(({id:e,title:a,value:t})=>We(Va,{children:[Ke(T,{size:P.XXXS,color:$.Secondary,nowrap:!0,children:a}),Ke(T,{size:P.XS,nowrap:!0,children:t})]},e))}),We(Va,{children:[Ke(T,{size:P.XXXS,color:$.Secondary,children:de}),Ke(T,{size:P.XS,children:t})]})]})},ht=({formState:e,onChange:a})=>{const t=xa(e=>a({name:e.target.value}),[a]),l=xa(e=>a({notes:e.target.value}),[a]);return Ke(y,{children:We(st,{children:[Ke(ot,{children:Ke(p,{name:"sampling-input-rule-name",label:se,tooltip:"Optional. Give this rule a name for easier identification.",placeholder:ce,value:e.name,onChange:t})}),Ke(dt,{children:Ke(p,{name:"sampling-input-note",label:de,tooltip:pe,placeholder:ue,value:e.notes,onChange:l})})]})})},gt=[{value:"Relevance",label:"Relevance"},{value:"Error",label:"Error"},{value:"Duration",label:"Duration"}],mt=({formState:e,onChange:a})=>{const t=xa(e=>a({ruleType:e,keepErrors:"Error"===e}),[a]);return Ke(y,{richTitle:{title:`3. ${oe}`,subTitle:ge},children:Ke(v,{$alignItems:"flex-start",children:Ke(b,{options:gt,selected:e.ruleType,setSelected:t})})})},vt=Pa.div`
45
- display: flex;
46
- align-items: center;
47
- gap: 24px;
48
- padding: 8px 16px;
49
- border-radius: 12px;
50
- background-color: ${({theme:e})=>e.v2.colors.silver[800]};
51
- `,ft=Pa.div`
52
- flex: 1;
53
- min-width: 0;
54
- white-space: pre;
55
- overflow-x: auto;
56
- `,bt=({title:e,summary:t,onEdit:l,renderAction:r})=>{const i=Sa(()=>{const a=[];return e&&(a.push({text:e,variant:_e.Default}),a.push({text:" - ",variant:_e.Default})),a.push(...t),a},[e,t]);return We(vt,{children:[Ke(ft,{children:Ke(Qe,{parts:i})}),r&&r(),l&&Ke(me,{"data-id":"sampling-btn-edit-auto-rule",label:ve,rightIcon:ha,variant:a.Text,size:j.S,onClick:l})]})},yt=e=>{const a=Sa(()=>{if(e.readOnly)return e.summary;switch(e.category){case"noisy":return ta(ia(e.formState));case"highlyRelevant":return aa(ra(e.formState));case"costReduction":return ea(la(e.formState))}},[e]);if(e.readOnly)return Ke(bt,{title:fe,summary:a,renderAction:e.renderAction});const t=1===a.length&&"default"===a[0].variant;return Ke(bt,{title:t?be:fe,summary:t?[]:a,renderAction:e.renderAction})},xt=Pa.div`
57
- display: flex;
58
- flex-wrap: wrap;
59
- gap: 8px;
60
- `,St=Pa.div`
61
- display: flex;
62
- align-items: center;
63
- gap: 8px;
64
- padding: 8px 12px;
65
- border-radius: 8px;
66
- cursor: pointer;
67
- background: ${({theme:e,$selected:a})=>a?e.v2.colors.silver[700]:e.v2.colors.silver[900]};
68
- border: 1px solid ${({theme:e,$selected:a})=>a?e.v2.colors.silver[500]:e.v2.colors.silver[800]};
69
-
70
- &:hover {
71
- background: ${({theme:e})=>e.v2.colors.silver[700]};
72
- }
73
- `,Ct=Pa.div`
74
- display: flex;
75
- width: 32px;
76
- height: 32px;
77
- justify-content: center;
78
- align-items: center;
79
- flex-shrink: 0;
80
- `,kt=Pa.div`
81
- display: flex;
82
- flex-direction: column;
83
- gap: 4px;
84
- `,Tt=Pa.div`
85
- display: flex;
86
- align-items: center;
87
- gap: 8px;
88
- padding: 8px;
89
- border-radius: 8px;
90
- background-color: ${({theme:e})=>e.v2.colors.silver[900]};
91
- `,wt=Pa.div`
92
- display: flex;
93
- width: 24px;
94
- height: 24px;
95
- justify-content: center;
96
- align-items: center;
97
- flex-shrink: 0;
98
- `,$t={[Le.JavaScript]:"Node.js",[Le.DotNet]:".NET",[Le.Php]:"PHP",[Le.Java]:"Java",[Le.Go]:"Go",[Le.Python]:"Python",[Le.Ruby]:"Ruby",[Le.Rust]:"Rust"},Pt=[Le.Python,Le.Java,Le.JavaScript,Le.DotNet,Le.Php,Le.Ruby,Le.Go].map(e=>({id:e,label:$t[e]??e.charAt(0).toUpperCase()+e.slice(1),Icon:Ae(e)})),Mt=[{value:"all",label:"Entire Cluster"},{value:"source",label:"Specific Source"},{value:"namespace",label:"Specific Namespace"},{value:"language",label:"Specific Programming Language"}];function At(e){const a=$t[e];return a||e.charAt(0).toUpperCase()+e.slice(1)}const Lt=e=>e.readOnly?Ke(Ot,{scopes:e.scopes}):Ke(zt,{formState:e.formState,onChange:e.onChange,sourceOptions:e.sourceOptions,namespaceOptions:e.namespaceOptions}),Ot=({scopes:e})=>{if(na(e))return Ke(y,{richTitle:{title:ye},children:Ke(xe,{status:Ce.Default,message:Se,fullWidth:!0})});const a=e.sources??[],t=e.namespaces??[],l=e.languages??[];return Ke(y,{richTitle:{title:ye},children:We(kt,{children:[a.map((e,a)=>{const t=[e.namespace,e.kind,e.name].filter(Boolean),l=t.length?t.join(" / "):ke;return Ke(Tt,{children:Ke(T,{size:P.XS,color:$.Primary,children:l})},`src-${a}`)}),t.map((e,a)=>Ke(Tt,{children:Ke(T,{size:P.XS,color:$.Primary,children:e})},`ns-${a}`)),l.map((e,a)=>{const t=Ae(e);return We(Tt,{children:[t&&Ke(wt,{children:Ke(t,{size:18})}),Ke(T,{size:P.XS,color:$.Primary,children:At(e)})]},`lang-${a}`)})]})})},zt=({formState:e,onChange:a,sourceOptions:t=[],namespaceOptions:l=[]})=>{const[r,i]=Ca(()=>{return(a=e.sourceScopes).sources.length>0?"source":a.namespaces.length>0?"namespace":a.languages.length>0?"language":"all";var a}),{sources:s,namespaces:o,languages:d}=e.sourceScopes,c=s.length>0||o.length>0||d.length>0,u=Sa(()=>Mt.map(e=>({...e,disabled:"all"===e.value&&c})),[c]),p=Sa(()=>s.map(e=>{return a=e.namespace,t=e.kind,l=e.name,`${a}/${t}/${l}`;var a,t,l}),[s]),h=Sa(()=>[...o],[o]),g=Sa(()=>new Set(d),[d]),m=xa(e=>{i(e)},[]),f=xa(t=>{const l=t.map(e=>function(e){const a=e.split("/");return 3!==a.length?null:{namespace:a[0],kind:a[1],name:a[2]}}(e)).filter(e=>null!==e).map(e=>({namespace:e.namespace,kind:e.kind,name:e.name}));a({sourceScopes:{...e.sourceScopes,sources:l}})},[e.sourceScopes,a]),x=xa(t=>{a({sourceScopes:{...e.sourceScopes,namespaces:t}})},[e.sourceScopes,a]),S=xa(t=>{const l=e.sourceScopes.languages,r=l.includes(t)?l.filter(e=>e!==t):[...l,t];a({sourceScopes:{...e.sourceScopes,languages:r}})},[e.sourceScopes,a]);return We(y,{richTitle:{title:`1. ${ye}`,subTitle:Te},children:[Ke(xe,!c&&"all"===r?{status:Ce.Default,message:Se,fullWidth:!0,smallIcon:!0}:{status:Ce.Info,message:we,fullWidth:!0,smallIcon:!0}),Ke(v,{$alignItems:"flex-start",children:Ke(b,{options:u,selected:r,setSelected:m})}),"source"===r&&Ke($e,{multiple:!0,"data-id":"sampling-autocomplete-source",options:t,value:p,onSelect:f,placeholder:Pe}),"namespace"===r&&Ke($e,{multiple:!0,"data-id":"sampling-autocomplete-namespace",options:l,value:h,onSelect:x,placeholder:"Search namespace"}),"language"===r&&Ke(xt,{children:Pt.map(({id:e,label:a,Icon:t})=>{const l=g.has(e);return We(St,{$selected:l,onClick:()=>S(e),children:[Ke(n,{name:`sampling-scope-lang-${e}`,size:Me.S,value:l,onChange:()=>S(e)}),Ke(Ct,{children:Ke(t,{size:20})}),Ke(T,{size:P.XS,nowrap:!0,children:a})]},e)})})]})},Dt=(e,a)=>!a?.length||!!a?.find(a=>a===e),Xt=({title:e="Signals",required:a,errorMessage:t,allowedSignals:l,selectedSignals:r,setSelectedSignals:i,disabled:s})=>{const[o,d]=Ca(1===r.length),c=ka(JSON.stringify(r));Ta(()=>{let e=Oe(r).filter(e=>Dt(e,l));e.length||(e=ze.filter(({id:e})=>Dt(e,l)).map(({id:e})=>e));const a=JSON.stringify(e);c.current!==a&&(c.current=a,i(e),d(1===e.length))},[l,r]);return We(v,{$gap:12,children:[Ke(f,{label:e,required:a}),Ke(m,{$gap:12,children:ze.map(e=>{const a=Dt(e.id,l),t=((e,a)=>!!a?.find(a=>a===e))(e.id,r);return a?Ke(n,{label:e.value,disabled:s||!a||o&&t,value:t,onChange:a=>((e,a)=>{const t=e,l=a?[...r,t]:r.filter(e=>e!==t);i(l),d(1===l.length)})(e.id,a)},e.id):null})}),Ke(De,{errorMessage:t})]})},It=({minSupportedVersion:a,currentVersion:t})=>Ke(e,{isOpen:!0,onClose:()=>{},relativeToParent:!0,visual:()=>Ke(Xe,{scale:2.4,icon:()=>Ke("svg",{xmlns:"http://www.w3.org/2000/svg",width:"22",height:"21",viewBox:"0 0 22 21",fill:"none",children:Ke("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:"Upgrade Required",description:`To use this feature, please upgrade to Odigos v${a} or later.\nCurrent version: ${t}.`}),Rt=Pa.div`
99
- display: flex;
100
- flex-direction: column;
101
- justify-content: flex-end;
102
- width: ${({$width:e})=>e};
103
- gap: ${({$columnHasHeader:e})=>e?"0":"12px"};
104
- `,Nt=Pa.div`
105
- display: flex;
106
- align-items: center;
107
- min-height: 24px;
108
- padding: 12px;
109
- border-radius: 16px 16px 0 0;
110
- background-color: ${({theme:e})=>e.v2.colors.silver[800]};
111
- `,Bt=Pa.div`
112
- display: flex;
113
- flex-direction: column;
114
- gap: ${({$gap:e})=>e}px;
115
- padding: 12px 12px 0 12px;
116
- width: calc(100% - 24px);
117
- height: ${({$heightOffset:e,$columnHasHeader:a})=>`calc(100vh - 180px - ${e}px ${a?"- 48px":""})`};
118
- border-radius: ${({$columnHasHeader:e,$isLeft:a,$isRight:t})=>e?a?"0 0 0 16px":t?"0 16px 0 0":"0":a?"16px 0 0 16px":t?"0 16px 16px 0":"16px"};
119
- background-color: ${({theme:e})=>e.v2.colors.silver[900]};
120
- overflow-y: auto;
121
- overflow-x: hidden;
122
- `,Et=({isLeft:e,isRight:a,heightOffset:t=0,width:l,header:r,list:i})=>We(Rt,{$width:l,$columnHasHeader:!!r,children:[r&&Ke(Nt,{children:r}),Ke(Bt,{$gap:8,$isLeft:e,$isRight:a,$heightOffset:t,$columnHasHeader:!!r,children:i.length?i.length>1?Ke(Ie,{gap:8,elements:i}):Ke(Fe,{children:i[0]}):Ke(Re,{$height:"100%",children:Ke(Ne,{})})})]}),Ht="75vw",Vt=Pa.div`
123
- display: flex;
124
- flex-direction: column;
125
- border-radius: 16px;
126
- background-color: ${({theme:e})=>e.v2.colors.silver[1e3]};
127
- overflow: hidden;
128
- `,jt=Pa.div`
129
- display: flex;
130
- gap: 12px;
131
- padding: 16px 16px 0 16px;
132
- background-color: ${({theme:e})=>e.v2.colors.silver[1e3]};
133
- position: sticky;
134
- top: 0;
135
- `,qt=Pa.div`
136
- padding: 12px 12px 0 12px;
137
- `,Ut=Pa.div`
138
- display: flex;
139
- gap: 12px;
140
- padding: 16px;
141
- `,Gt=Pa.div`
142
- padding: 5vh 10vw;
143
- border-radius: 12px;
144
- background-color: ${({theme:e})=>e.v2.colors.silver[800]};
145
- `,Jt=wa(({isOpen:t,withOverlay:l,disableAnimation:r,onClose:i,onBack:n,onNext:s,nextIsSkip:o,onSave:d,disableSave:c,connectionIds:u,header:p,subHeader:h,leftColumn:g,rightColumn:m,search:v,filters:f,errorMessage:b,isFormDirty:y,hideDirtyNote:x,isFetching:S,progress:C},k)=>{const[T,w]=Ca(!1),[$,M]=Ca(!1),[A,L]=Ca(void 0);$a(k,()=>({clearErrors:()=>L(void 0)}));const O=$,z=xa(()=>{y&&!T?w(!0):(w(!1),i?.())},[y,T,i]),D=c||$||"boolean"==typeof y&&!y,X=xa(async()=>{M(!0);const e=await d();M(!1),!1!==e&&(e?.error?L(e.error):(u?.setValue([]),i?.()))},[d,u,i]),I=!!v||!!u||!!f,R=!!h,N=(I?48:0)+(R?50:0),B=Sa(()=>S?{status:Ce.Info,message:"Fetching Data..."}:$&&!C?{status:Ce.Info,message:"Saving Changes..."}:A||b?{status:Ce.Error,message:A||b}:"boolean"==typeof y&&y&&!x?{status:Ce.Info,message:'The values don\'t reflect the current configurations of the selected clusters.\n"Save" will override the current configurations.'}:"boolean"!=typeof y||y||x?void 0:{status:Ce.Success,message:"The values reflect the current configuration of the selected cluster."},[S,$,C,A,b,y,x]),E=Sa(()=>n?{label:"Back",leftIcon:ga,variant:a.Secondary,onClick:n}:{label:"Cancel",variant:a.Secondary,onClick:z,disabled:O},[n,z,O]),[H,V]=Ca(!1),j=Sa(()=>s?o?{"data-id":"wide-drawer-skip",label:"Skip",rightIcon:ma,variant:a.Secondary,onClick:()=>V(!0)}:{"data-id":"wide-drawer-next",label:"Next",rightIcon:ma,variant:a.Primary,onClick:s}:{"data-id":"wide-drawer-save",label:"Save",variant:a.Primary,onClick:X,disabled:D},[s,o,X,D]);return We(Be,{width:Ht,isOpen:t,disableAnimation:r,hideOverlay:!$&&!l,header:{...p,onClose:i?z:void 0,onCloseDisabled:O},footer:{note:B,actions:[E,j]},children:[$?Ke(Re,{$height:"calc(100vh - 136px)",children:Ke(Gt,{children:Ke(Ee,{titleSize:P.S,subTitleSize:P.XXXS,withGradient:!0,withSpinner:!0,...C})})}):We(Vt,{children:[I&&We(jt,{children:[u&&Ke(He,{icon:va,title:"Selected Clusters",badge:{label:u.value.length}}),v&&Ke(Ve,{width:"100%",...v}),f]}),R&&Ke(qt,{children:Ke(He,{icon:h.icon,title:h.title,subTitle:h.description,badge:h.badge})}),We(Ut,{children:[Ke(Et,{isLeft:!0,heightOffset:N,...g}),Ke(Et,{isRight:!0,heightOffset:N,...m})]})]}),Ke(Ma,{isOpen:T,onClose:()=>w(!1),onApprove:z}),Ke(e,{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:H,onClose:()=>V(!1),denyButton:{label:"Go Back",variant:a.Secondary,onClick:()=>V(!1)},approveButton:{label:"Skip",variant:a.Primary,onClick:()=>{s?.(),V(!1)}}})]})});Jt.displayName=Jt.name;const Kt=Pa.div`
146
- padding: 0 24px;
147
- border-radius: 12px;
148
- background-color: ${({$codeBgColor:e})=>e||"transparent"};
149
- `,Wt=({title:e="YAML",yaml:t,defaultOpen:l,fullHeight:r,bgTint:i="1000",codeBgColor:n})=>{const{clickCopy:s,isCopied:o}=je(),d=Sa(()=>t?[{id:Ue(),type:qe.Button,buttonProps:{variant:a.Text,size:j.S,leftIcon:o?fa:ba,onClick:()=>s(t||""),disabled:o}}]:[],[t,o]);return Ke(Ge,{bgTint:i,richTitle:{icon:ya,title:e},actions:d,withCollapse:!0,collapseIsDefaultOpen:l,fullHeight:r,children:Ke(Kt,{$codeBgColor:n,children:t?Ke(Je,{code:t,language:"yaml",theme:"duotoneDark"}):Ke(Re,{children:Ke(Ne,{title:"YAML not found",subTitle:"The YAML for this resource is not available"})})})})};export{bt as A,Ma as C,La as D,Da as N,Qa as O,Ia as P,ut as R,Xt as S,It as U,Jt as W,Wt as Y,za as a,yt as b,Lt as c,mt as d,Na as e,rt as f,Aa as g,Oa as h,Ht as i,Xa as j};
@@ -1 +0,0 @@
1
- import{jsx as e}from"react/jsx-runtime";import{useState as t,useCallback as a,useMemo as n,useContext as r,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 v,j as g,y,z as b,B as D,C,G as E,H as S,I as k,J as F,K as I,L as w,M as A,O as N,Q as R,T as P,E as T}from"./ui-components-Dnqp-MQm.js";import{b as x,a as O,d as L,v as M,g as U,u as j}from"./helpers-aJJ1GhqS.js";const G={type:"",disabled:!1,name:"",notes:"",signals:[],fields:{}},K=s(null),V="All row fields are required",_="At least one row is required",q=(e,t)=>!!e&&t.every(t=>{const a=e[t];return Array.isArray(a)?a.length>0:!("string"==typeof(n=a)?!n.trim():p(n));var n}),H=({children:r})=>{const[s,o]=t(null),i=l(G),f=a(e=>{i.resetFormData(),i.handleErrorChange(void 0,void 0,{}),e?.type&&i.handleFormChange("type",e.type),o(e)},[]),v=a(e=>{var t;i.resetFormData((({type:e,name:t,notes:a,disabled:n,signals:r,fields:s})=>({type:e,name:t||"",notes:a||"",disabled:!!n,signals:r??[],fields:s??{}}))(e)),i.handleErrorChange(void 0,void 0,{}),o((t=e.type,c.find(e=>e.type===t)??null))},[]),g=a(()=>{if(!s)return{errorMessage:"No action type selected",preparedFormData:d(G)};const e=(e=>{const t=d(e),a=t.fields||{},n=a[u.UrlTemplatizationRulesGroups];n?.length&&(a[u.UrlTemplatizationRulesGroups]=n.map(e=>({...e,templatizationRules:(e.templatizationRules||[]).filter(e=>!!e.template?.trim())})));const r=a[u.AttributeNamesToDelete];r?.length&&(a[u.AttributeNamesToDelete]=r.filter(e=>!!e?.trim()));const s=a[u.Renames];return s&&(a[u.Renames]=Object.fromEntries(Object.entries(s).filter(([e,t])=>!!e?.trim()&&!!t?.trim()))),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 n={},r=t.fields||{},s=a.fields||{};switch(e){case m.K8sAttributes:{const e=!(r[u.CollectContainerAttributes]||r[u.CollectReplicaSetAttributes]||r[u.CollectWorkloadId]||r[u.CollectClusterId]),t=!r[u.LabelsAttributes]?.length,a=!r[u.AnnotationsAttributes]?.length;e&&t&&a&&(n[u.CollectContainerAttributes]="Enable at least one option or add a label/annotation row");const s=r[u.LabelsAttributes];s?.some(e=>!q(e,["labelKey","attributeKey","fromSources"]))&&(n[u.LabelsAttributes]=V);const o=r[u.AnnotationsAttributes];o?.some(e=>!q(e,["annotationKey","attributeKey","fromSources"]))&&(n[u.AnnotationsAttributes]=V);break}case m.AddClusterInfo:{const e=r[u.ClusterAttributes];e?.length?e.some(e=>!q(e,["attributeName","attributeStringValue"]))&&(n[u.ClusterAttributes]=V):n[u.ClusterAttributes]=_;break}case m.DeleteAttributes:{const e=s[u.AttributeNamesToDelete]||[],t=r[u.AttributeNamesToDelete]||[];t.length?e.length>t.length&&(n[u.AttributeNamesToDelete]=V):n[u.AttributeNamesToDelete]=e.length?V:_;break}case m.RenameAttributes:{const e=Object.entries(s[u.Renames]||{}),t=Object.entries(r[u.Renames]||{}),a=e.some(([e,t])=>!e?.trim()||!t?.trim());t.length?a&&(n[u.Renames]=V):n[u.Renames]=e.length?V:_;break}case m.PiiMasking:{const e=r[u.PiiCategories];e?.length||(n[u.PiiCategories]="Select at least one attribute to mask");break}case m.URLTemplatization:{const e=r[u.UrlTemplatizationRulesGroups];(!e?.length||e.some(e=>!e.templatizationRules?.length))&&(n[u.UrlTemplatizationRulesGroups]="Each rule group needs at least one non-blank template");break}}return n})(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]),y=n(()=>({selectedOption:s,onSelectOption:f,loadAction:v,genericForm:i,validateFormData:g}),[s,f,v,i,g]);return e(K.Provider,{value:y,children:r})},z=()=>{const e=r(K);if(!e)throw new Error("useActionFormContext must be used within an ActionFormContextProvider");return e},J={name:""},Q=s(null),W=({children:r,defaultExcludeName:s=""})=>{const{dataStreams:i}=f(),[c,u]=t(void 0),[m,p]=t(s),[g,y]=t(void 0),[b,D]=t(null),C=o(null),E=l(J),S=a(e=>{E.resetFormData({name:e}),E.handleErrorChange(void 0,void 0,{}),u(void 0),p(e),y(e),D(null),C.current=null},[]),k=a(()=>{const e=d(E.formData),t=(e=>{const t={};return e.name?v(e.name)||(t.name=h.ILLEGAL_K8S_LABEL):t.name=h.FIELD_IS_REQUIRED,t})(e);E.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}},[E]),F=a(async e=>{const{errorMessage:t,preparedFormData:a}=k();if(t)return;const n=i.find(e=>e.name===a.name&&e.name!==m);if(n)return C.current=e,void D({preparedFormData:a,existingName:n.name,editingName:g});await e(a)},[k,i,m,g]),I=a(async()=>{const e=C.current,t=b?.preparedFormData;C.current=null,D(null),e&&t&&await e(t)},[b]),w=a(()=>{C.current=null,D(null)},[]),A=n(()=>({genericForm:E,loadDataStream:S,editingName:g,validateFormData:k,requestSubmit:F,pendingMerge:b,confirmMerge:I,cancelMerge:w,errorMessage:c,excludeName:m,setExcludeName:p}),[E,S,g,k,F,b,I,w,c,m]);return e(Q.Provider,{value:A,children:r})},$=()=>{const e=r(Q);if(!e)throw new Error("useDataStreamFormContext must be used within a DataStreamFormContextProvider");return e},B={type:"",name:"",currentStreamName:"",disabled:!1,exportedSignals:{logs:!1,metrics:!1,traces:!1,profiles:!1},fields:[]},X={activeForm:null,onChangeActiveForm:()=>{},loadDestination:()=>{},genericForm:void 0,validateFormData:()=>({isOk:!1,preparedFormData:d(B)}),unsavedDestinations:[],thisUnsavedDestination:void 0,setUnsavedDestinations:()=>{},addUnsavedDestination:()=>{},updateUnsavedDestination:()=>{},deleteUnsavedDestination:()=>{}},Y=s(X),Z=e=>e.filter(e=>!!e).map(e=>{const{name:t,componentType:a,componentProperties:n,displayName:r,initialValue:s,renderCondition:o}=e,i=a===S.Dropdown,l=C(n,{});return{componentType:a,renderCondition:o,name:t,title:r,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}}),ee=({children:r})=>{const{selectedStreamName:s}=f(),o=g(e=>e.destinations),[c,u]=t(null),[m,v]=t(X.unsavedDestinations),S=n(()=>"number"==typeof c?.unsavedIdx?m[c.unsavedIdx]:void 0,[c,m]),k=a((e,t)=>{c&&(v(t=>[...t,{...e,option:c.option}]),u(t?e=>e?{...e,listType:y.UNSAVED,unsavedIdx:m.length}:null:null))},[c,m.length]),F=a((e,t,a)=>{c&&(v(a=>a.map((a,n)=>n===e?{...a,...t,option:c.option}:a)),u(a?e=>e?{...e,listType:y.UNSAVED}:null:null))},[c]),I=a(e=>{v(t=>t.filter((t,a)=>a!==e)),u(null)},[]),w=l({...B,currentStreamName:s});i(()=>{if(!c)return;if(S)return void w.resetFormData({...S.formData});if(c.listType===y.EXISTS&&c.option.id){const e=o.find(e=>e.id===c.option.id);if(e)return void w.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=b(c.option.supportedSignals);w.resetFormData({type:c.option.type,name:c.option.displayName,currentStreamName:s,disabled:!1,exportedSignals:{logs:e.includes(D.Logs),metrics:e.includes(D.Metrics),traces:e.includes(D.Traces),profiles:e.includes(D.Profiles)},fields:c.dynamicFields.map(e=>({key:e.name,value:e.value}))})},[c,S]);const A=a(e=>{w.resetFormData(),w.handleErrorChange(void 0,void 0,{}),u(e?{...e,dynamicFields:e.option?.fields?Z(e.option.fields):[]}:null)},[]),N=a((e,t)=>{let a;for(const n of t){const t=n.items.find(t=>t.type===e.destinationType.type);if(t){a=t;break}}const n=C(e.fields,{}),r={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:n[e.name]??e.initialValue})):[]},s=Z(r.fields);u({listType:y.EXISTS,option:r,dynamicFields:s})},[]),R=a(()=>{const e=d(w.formData),t={};c?.dynamicFields.forEach(({name:a,required:n})=>{if(n){const n=e.fields.find(e=>e.key===a)?.value;p(n)&&(t[a]=h.FIELD_IS_REQUIRED)}});return E(e.exportedSignals).length||(t.exportedSignals=h.FIELD_IS_REQUIRED),w.handleErrorChange(void 0,void 0,t),{errorMessage:0===Object.keys(t).length?void 0:"Invalid form values",preparedFormData:e}},[w,c]);return e(Y.Provider,{value:{activeForm:c,onChangeActiveForm:A,loadDestination:N,genericForm:w,validateFormData:R,unsavedDestinations:m,thisUnsavedDestination:S,setUnsavedDestinations:v,addUnsavedDestination:k,updateUnsavedDestination:F,deleteUnsavedDestination:I},children:r})},te=()=>r(Y),ae={disabled:!1,ruleName:"",notes:"",workloads:null,instrumentationLibraries:null,payloadCollection:null,codeAttributes:null,headersCollection:null,customInstrumentations:null},ne=s(null),re=({children:r})=>{const[s,o]=t(null),i=l(ae),c=a(e=>{i.resetFormData(),i.handleErrorChange(void 0,void 0,{}),o(e)},[]),u=a(e=>{var t;i.resetFormData((({ruleName:e,notes:t,disabled:a,workloads:n,instrumentationLibraries:r,payloadCollection:s,codeAttributes:o,headersCollection:i,customInstrumentations:l})=>({ruleName:e||"",notes:t||"",disabled:!!a,workloads:n??null,instrumentationLibraries:r??null,payloadCollection:s??null,codeAttributes:o??null,headersCollection:i??null,customInstrumentations:l??null}))(e)),i.handleErrorChange(void 0,void 0,{}),o((t=e.type,k.find(e=>e.type===t)??null))},[]),m=a(()=>{if(!s)return{errorMessage:"No rule type selected",preparedFormData:d(ae)};const e=(e=>{const t=d(e);return t.headersCollection?.[F.HeaderKeys]?.length&&(t.headersCollection[F.HeaderKeys]=t.headersCollection[F.HeaderKeys].map(e=>e.trim()).filter(e=>e)),t.customInstrumentations?.[I.Golang]?.length&&(t.customInstrumentations[I.Golang]=t.customInstrumentations[I.Golang].map(e=>new w(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})),t.customInstrumentations?.[I.Java]?.length&&(t.customInstrumentations[I.Java]=t.customInstrumentations[I.Java].map(e=>new A(e.className,e.methodName)).filter(e=>{return t=e,!(!t.className?.trim()&&!t.methodName?.trim());var t})),t})(i.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?.[F.HeaderKeys]?.length||(a.headersCollection="Header keys are required");break;case N.CustomInstrumentation:{const e=t.customInstrumentations?.[I.Golang]||[],n=t.customInstrumentations?.[I.Java]||[];if(!e.length&&!n.length){a.customInstrumentations="Custom instrumentation are required";break}const r=e.findIndex(e=>!new w(e.packageName,e.functionName,e.receiverName,e.receiverMethodName).Verify());if(-1!==r){a.customInstrumentations=`Golang probe #${r+1} is invalid: provide a package name plus either a function name OR both a receiver name and receiver method name`;break}const s=n.findIndex(e=>!new A(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})(s.type,e);return i.handleErrorChange(void 0,void 0,t),{errorMessage:Object.keys(t).length>0?"Invalid form values":void 0,preparedFormData:e}},[i,s]),p=n(()=>({selectedOption:s,onSelectOption:c,loadRule:u,genericForm:i,validateFormData:m}),[s,c,u,i,m]);return e(ne.Provider,{value:p,children:r})},se=()=>{const e=r(ne);if(!e)throw new Error("useRuleFormContext must be used within a RuleFormContextProvider");return e};var oe;!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"}(oe||(oe={}));const ie=s(null),le=["50","25","10","1"];function de(e){const t=String(e);return le.includes(t)?t:"custom"}const ce=({category:r,sourceOptions:s=[],namespaceOptions:o=[],children:d})=>{const{formData:c,handleFormChange:u,resetFormData:m}=l(U(r)),[p,h]=t(null);i(()=>{m(U(r)),h(null)},[r]);const f=a(e=>{h(null),u(void 0,void 0,{...c,...e})},[c,u]),v=a(()=>{m(U(r)),h(null)},[r,m]),g=n(()=>({formType:oe.Create,category:r,formData:c,handleChange:f,resetForm:v,duplicateWarning:p,setDuplicateWarning:h,sourceOptions:s,namespaceOptions:o}),[r,c,f,v,p,s,o]);return e(ie.Provider,{value:g,children:d})},ue=({data:r,defaultEditMode:s,sourceOptions:d=[],namespaceOptions:c=[],children:u})=>{const[m,p]=t(!1),{formData:h,handleFormChange:f,resetFormData:v}=l(void 0),g=o(null),[y,b]=t(null);i(()=>{r!==g.current&&(g.current=r,r&&s?(v(M(r)),b(null),p(!0)):(p(!1),b(null)))},[r,s]);const D=a(e=>{b(null),f(void 0,void 0,{...h,...e})},[h,f]),C=a(()=>{r&&(v(M(r)),b(null),p(!0))},[r,v]),E=a(()=>{p(!1),b(null)},[]),S=n(()=>({formType:oe.View,data:r,isEditing:m,formData:h,handleChange:D,handleEdit:C,handleCancelEdit:E,duplicateWarning:y,setDuplicateWarning:b,sourceOptions:d,namespaceOptions:c}),[r,m,h,D,C,E,y,d,c]);return e(ie.Provider,{value:S,children:u})};function me(e){const[a,r]=t(()=>0===e?"all":"sample"),[s,o]=t(()=>de(e)),[l,d]=t(()=>"custom"===de(e)?String(e):"");i(()=>{r(0===e?"all":"sample");const t=de(e);o(t),d("custom"===t?String(e):"")},[e]);const c=n(()=>"all"===a?0:"custom"===s?Number(l)||0:Number(s),[a,s,l]);return{percentageMode:a,setPercentageMode:r,percentagePreset:s,setPercentagePreset:o,customPercentage:l,setCustomPercentage:d,resolvedPercentage:c}}const pe=({enabled:a,keepPercentage:r,children:s})=>{const[o,l]=t(a),d=me(r);i(()=>{l(a)},[a]);const c=n(()=>L({enabled:o,keepPercentage:d.resolvedPercentage}),[o,d.resolvedPercentage]),u=n(()=>({formType:oe.EditAutoNoisy,localEnabled:o,setLocalEnabled:l,...d,summary:c}),[o,d,c]);return e(ie.Provider,{value:u,children:s})},he=({enabled:a,dropPercentage:r,children:s})=>{const[o,l]=t(a),d=me(r);i(()=>{l(a)},[a]);const c=n(()=>O(o?{disabled:!1,percentageAtMost:d.resolvedPercentage}:null),[o,d.resolvedPercentage]),u=n(()=>({formType:oe.EditAutoCostReduction,localEnabled:o,setLocalEnabled:l,...d,summary:c}),[o,d,c]);return e(ie.Provider,{value:u,children:s})},fe=({enabled:a,children:r})=>{const[s,o]=t(a);i(()=>{o(a)},[a]);const l=n(()=>x(s?{disabled:!1}:null),[s]),d=n(()=>({formType:oe.EditAutoHighlyRelevant,localEnabled:s,setLocalEnabled:o,summary:l}),[s,l]);return e(ie.Provider,{value:d,children:r})},ve=t=>{switch(t.formType){case oe.Create:return e(ce,{...t});case oe.View:return e(ue,{...t});case oe.EditAutoNoisy:return e(pe,{...t});case oe.EditAutoCostReduction:return e(he,{...t});case oe.EditAutoHighlyRelevant:return e(fe,{...t})}};function ge(e){const t=r(ie);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 ye={otelServiceName:"",currentStreamName:""},be=s(null),De=({children:r})=>{const[s,o]=t(void 0),i=l(ye),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=n(()=>({loadSource:c,genericForm:i,validateFormData:u,errorMessage:s}),[c,i,u,s]);return e(be.Provider,{value:m,children:r})},Ce=()=>{const e=r(be);if(!e)throw new Error("useSourceEditFormContext must be used within a SourceEditFormContextProvider");return e},Ee=new Set([R.StaticPod]),Se=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}},ke=(e,t,a)=>{if(t&&!e.name.toLowerCase().includes(t.toLowerCase()))return!1;if(a.showOnlySelected){const{isAllSourced:t,isSomeSourced:a,isFutureApps:n}=Se(e);return t||a||n}return!0},Fe=(e,t,a)=>!(t&&!e.name.toLowerCase().includes(t.toLowerCase()))&&(!a.showOnlySelected||e.selected),Ie=s({snapshots:null,setSnapshots:()=>{},isFetching:!1,setIsFetching:()=>{},formData:[],handleSourceChange:()=>{},handleSelectAll:()=>{},formDiff:{},isFormDirty:!1}),we=({children:r,selectedConnectionIds:s,initialInputs:o})=>{const{tier:l}=j(),c=l===P.Onprem,{selectedStreamName:u}=f(),[m,p]=t(!1),[h,v]=t(null),[g,y]=t([]);i(()=>{h&&y(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),n=a??t;if(o?.[t.clusterId]){const e=o[t.clusterId],a=d(n);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=>{Ee.has(e.kind)&&!c||(e.selected=!0)})}),a}return n})})},[h,s,o]);const{formDiff:b,isFormDirty:D}=n(()=>{const e=((e,t,a)=>{const n={};return e.forEach(e=>{e.namespaces.forEach(r=>{const s=t.find(t=>t.clusterId===e.clusterId)?.namespaces.find(e=>e.name===r.name),o=r.selected||!1;if(o!==s?.selected)n[e.clusterId]||(n[e.clusterId]=[]),n[e.clusterId].push({namespace:r.name,selected:o,currentStreamName:a}),o?n[e.clusterId]=n[e.clusterId].filter(e=>e.namespace!==r.name||e.namespace===r.name&&(!e.name||!e.kind)):r.workloads.forEach(t=>{t.selected&&n[e.clusterId].push({namespace:r.name,name:t.name,kind:t.kind,selected:!0,currentStreamName:a})});else{const t=((e,t,a)=>{const n=[];return t.workloads.forEach(r=>{const s=e?.workloads.find(e=>e.name===r.name&&e.kind===r.kind);r.selected!==s?.selected&&n.push({namespace:t.name,name:r.name,kind:r.kind,selected:r.selected||!1,currentStreamName:a})}),n})(s,r,a);t.length>0&&(n[e.clusterId]||(n[e.clusterId]=[]),n[e.clusterId].push(...t))}})}),n})(g,h?.clusters||[],u);return{formDiff:e,isFormDirty:Object.keys(e).length>0}},[g,h,u]),C=a(e=>!c&&Ee.has(e),[c]),E=a(({clusterId:e,workloadId:t,selected:a,auto:n})=>{y(r=>{const s=d(r),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 n="boolean"==typeof a?a:!s[o].namespaces[i].workloads[e].selected;if(s[o].namespaces[i].workloads[e].selected=n,n){s[o].namespaces[i].workloads.filter(e=>!C(e.kind)).every(e=>e.selected)&&(s[o].namespaces[i].selected=!0)}else s[o].namespaces[i].selected=!1}else{const e="boolean"==typeof n?n:!s[o].namespaces[i].selected;s[o].namespaces[i].selected=e,e?s[o].namespaces[i].workloads.forEach(e=>{C(e.kind)||(e.selected=!0)}):"boolean"!=typeof a||a||s[o].namespaces[i].workloads.forEach(e=>{e.selected=!1})}return s})},[C]),S=a(({clusterId:e,namespaceName:t,boolean:a,searchText:n="",searchBy:r="",filters:s})=>{y(o=>{const i=d(o),l=r===T.Namespace?n:"",c=r===T.Source?n:"",u=!!l||!!c||!!s?.showOnlySelected;return i.forEach((n,r)=>{e&&n.clusterId!==e||n.namespaces.forEach(({name:e,workloads:n},o)=>{if(!t||e===t)if(u)if(t){n.forEach((e,t)=>{a&&C(e.kind)||Fe(e,c,s||{showOnlySelected:!1})&&(i[r].namespaces[o].workloads[t].selected=a)});const e=i[r].namespaces[o].workloads.filter(e=>!C(e.kind)).every(e=>e.selected);i[r].namespaces[o].selected=e}else{if(!ke(i[r].namespaces[o],l,s||{showOnlySelected:!1}))return;i[r].namespaces[o].selected=a,n.forEach((e,t)=>{a&&C(e.kind)||(i[r].namespaces[o].workloads[t].selected=a)})}else i[r].namespaces[o].selected=a,n.forEach((e,t)=>{a&&C(e.kind)||(i[r].namespaces[o].workloads[t].selected=a)})})}),i})},[C]);return e(Ie.Provider,{value:{snapshots:h,setSnapshots:v,isFetching:m,setIsFetching:p,formData:g,handleSourceChange:E,handleSelectAll:S,formDiff:b,isFormDirty:D},children:r})},Ae=()=>r(Ie);export{H as A,W as D,Ee as E,re as R,oe as S,ee as a,ve as b,De as c,we as d,$ as e,te as f,se as g,ge as h,Ce as i,Ae as j,Fe as k,ke as l,Se as m,z as u};