web-interface.assets.bb8c8232-6580.a3571135bc30cbf98b5f.js Maven / Gradle / Ivy
"use strict";(()=>{(self.webpackChunkgraylog_web_interface=self.webpackChunkgraylog_web_interface||[]).push([["bb8c8232-6580"],{"/Ol8rEWQ":(ae,k,n)=>{n.d(k,{A:()=>s});var e=n("pmX897Fv"),O=n.n(e),u=n("DjJvgDaP"),R=n.n(u),y=R()(O());y.push([ae.id,`.hxxn_4IgOk3oqslCoAdQ {
margin: 0;
padding: 0;
}
.hxxn_4IgOk3oqslCoAdQ li:not(:last-child) {
float: left;
}
.hxxn_4IgOk3oqslCoAdQ li:not(:last-child):after {
content: ',';
margin-right: 5px;
}
.hxxn_4IgOk3oqslCoAdQ li:last-child:after {
content: '.';
}`,"",{version:3,sources:["webpack://./src/components/rules/RuleForm.css"],names:[],mappings:"AAAA;IACI,SAAS;IACT,UAAU;AACd;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,YAAY;IACZ,iBAAiB;AACrB;;AAEA;IACI,YAAY;AAChB",sourcesContent:[`:local(.usedInPipelines) {
margin: 0;
padding: 0;
}
:local(.usedInPipelines li:not(:last-child)) {
float: left;
}
:local(.usedInPipelines li:not(:last-child):after) {
content: ',';
margin-right: 5px;
}
:local(.usedInPipelines li:last-child:after) {
content: '.';
}`],sourceRoot:""}]),y.locals={usedInPipelines:"hxxn_4IgOk3oqslCoAdQ"};const s=y},LyhA1BK7:(ae,k,n)=>{n.d(k,{A:()=>s});var e=n("pmX897Fv"),O=n.n(e),u=n("DjJvgDaP"),R=n.n(u),y=R()(O());y.push([ae.id,`.GK5Fq9huwx0guzXrFmik {
cursor: pointer;
}
.TzEAPhf4Re6KmSyAYQ1d {
width: 300px;
}
.g4E3NZFXSWkM7c1h9LO9 {
margin-top: 5px;
}
.pJ8c7V4hX4P_StB2BSDe {
margin-top: 10px;
}
.A0hFOwg_AvLq3l3F0WWj {
white-space: pre-wrap;
}
.kuhUyffF6SE7SPLOqMeP {
width: 1%;
}`,"",{version:3,sources:["webpack://./src/components/rules/rule-helper/RuleHelper.css"],names:[],mappings:"AAAA;IACI,eAAe;AACnB;;AAEA;IACI,YAAY;AAChB;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,gBAAgB;AACpB;;AAEA;IACI,qBAAqB;AACzB;;AAEA;IACI,SAAS;AACb",sourcesContent:[`:local(.clickableRow) {
cursor: pointer;
}
:local(.functionTableCell) {
width: 300px;
}
:local(.marginQuickReferenceText) {
margin-top: 5px;
}
:local(.marginTab) {
margin-top: 10px;
}
:local(.exampleFunction) {
white-space: pre-wrap;
}
:local(.adjustedTableCellWidth) {
width: 1%;
}`],sourceRoot:""}]),y.locals={clickableRow:"GK5Fq9huwx0guzXrFmik",functionTableCell:"TzEAPhf4Re6KmSyAYQ1d",marginQuickReferenceText:"g4E3NZFXSWkM7c1h9LO9",marginTab:"pJ8c7V4hX4P_StB2BSDe",exampleFunction:"A0hFOwg_AvLq3l3F0WWj",adjustedTableCellWidth:"kuhUyffF6SE7SPLOqMeP"};const s=y},HQjpSCKK:(ae,k,n)=>{n.d(k,{A:()=>s});var e=n("Z7aTuO5B"),O=n("+Ej1FZHV"),u=n("F3uT4N0K"),R=n("IOI9nV80");const y=({alwaysShowCaret:l,bsSize:w,buttonTitle:D,children:H,closeOnSelect:K,disabled:m,dropdownZIndex:p,onToggle:o,title:r})=>{const[C,I]=(0,e.useState)(!1),V=()=>{typeof o=="function"&&o(!C),I(z=>!z)};return e.createElement(u.A,{show:C,closeOnSelect:K,dropdownZIndex:p,alwaysShowCaret:l,toggleChild:e.createElement("div",{className:`dropdown btn-group ${C?"open":""}`},e.createElement(O.A,{bsSize:w,className:"dropdown-toggle","aria-label":D,title:D,disabled:m},r," ",e.createElement(R.In,{name:"arrow_drop_down"}))),placement:"bottom",onToggle:V},typeof H=="function"?H({toggleDropdown:V}):H)};y.defaultProps={alwaysShowCaret:!1,bsSize:void 0,buttonTitle:void 0,closeOnSelect:!0,disabled:!1,dropdownZIndex:void 0,onToggle:void 0};const s=y},SfPIQIJE:(ae,k,n)=>{n.d(k,{A:()=>H});var e=n("Z7aTuO5B"),O=n("J6y4/h8P"),u=n("rIl5IEuP"),R=n("ty2gyrHp"),y=n("IOI9nV80"),s=n("NV1/EHMi");const l=(0,O.default)(u.ButtonToolbar)`
margin-bottom: 10px;
`,w=(0,O.default)(u.Button)(({theme:K})=>(0,O.css)`
font-family: ${K.fonts.family.navigation};
font-size: ${K.fonts.size.navigation};
color: ${K.colors.variant.darker.default};
&:hover,
&:focus {
background: inherit;
text-decoration: none;
}
&:hover {
color: inherit;
${(0,s.WS)(K)}
}
&.active {
color: ${K.colors.global.textDefault};
${(0,s.at)(K)}
&:hover,
&:focus {
${(0,s.at)(K)}
}
`);w.displayName="Button";const H=({items:K})=>e.createElement(l,null,K.map(({path:m,title:p,permissions:o,exactPathMatch:r})=>m?e.createElement(y.Wj,{permissions:o!=null?o:[],key:m},e.createElement(R.m,{to:m,relativeActive:!r},e.createElement(w,{bsStyle:"link"},e.createElement(s.Ay,null,p)))):null))},ZspbpBGx:(ae,k,n)=>{n.d(k,{A:()=>l});var e=n("Z7aTuO5B"),O=n("SfPIQIJE"),u=n("d4kzUuQm"),R=n("rIl5IEuP");const y=[{title:"Manage pipelines",path:u.Ay.SYSTEM.PIPELINES.OVERVIEW,exactPathMatch:!0},{title:"Manage rules",path:u.Ay.SYSTEM.PIPELINES.RULES},{title:"Simulator",path:u.Ay.SYSTEM.PIPELINES.SIMULATOR}],l=()=>e.createElement(R.Row,null,e.createElement(O.A,{items:y}))},"8/L0uEJc":(ae,k,n)=>{n.d(k,{A:()=>K});var e=n("ii0bleBb"),O=n.n(e),u=n("Z7aTuO5B"),R=n("ty2gyrHp"),y=n("rIl5IEuP"),s=n("xS8q27Jr"),l=Object.defineProperty,w=(m,p,o)=>p in m?l(m,p,{enumerable:!0,configurable:!0,writable:!0,value:o}):m[p]=o,D=(m,p,o)=>(w(m,typeof p!="symbol"?p+"":p,o),o);class H extends u.Component{constructor(){super(...arguments),D(this,"_refreshExtractorRoutes",p=>{this.newExtractorRoutes=s.A.getNewExtractorRoutes(p.message.source_node_id,p.message.source_input_id,p.fieldName,p.message.index,p.message.id)}),D(this,"_formatExtractorMenuItem",p=>u.createElement(R.m,{key:`menu-item-${p}`,to:this.newExtractorRoutes[p]},u.createElement(y.MenuItem,null,s.A.getReadableExtractorTypeName(p))))}UNSAFE_componentWillMount(){this._refreshExtractorRoutes(this.props)}UNSAFE_componentWillReceiveProps(p){this._refreshExtractorRoutes(p)}render(){const{fieldName:p,message:o}=this.props;return typeof o.fields[p]=="string"?u.createElement("div",{className:"message-field-actions pull-right"},u.createElement(y.DropdownButton,{pullRight:!0,bsSize:"xsmall",title:"Select extractor type",key:1,id:`select-extractor-type-dropdown-field-${p}`},s.A.EXTRACTOR_TYPES.map(C=>this._formatExtractorMenuItem(C)))):u.createElement("div",{className:"message-field-actions pull-right"},u.createElement(y.DropdownButton,{pullRight:!0,bsSize:"xsmall",title:"Select extractor type",key:1,id:`select-extractor-type-dropdown-field-${p}`},u.createElement(y.MenuItem,{key:"select-extractor-type-disabled",disabled:!0},"Extractors can only be used with string fields.")))}}D(H,"propTypes",{fieldName:O().string.isRequired,message:O().object.isRequired});const K=H},wzrLaWZc:(ae,k,n)=>{n.d(k,{A:()=>se});var e=n("ii0bleBb"),O=n.n(e),u=n("Z7aTuO5B"),R=n("VPaD/Np4"),y=n.n(R),s=n("rIl5IEuP"),l=n("TJOheZRu"),w=n("ty2gyrHp"),D=n("IOI9nV80"),H=n("Wh5iba66"),K=n("J6y4/h8P"),m=n("nxMFMmDQ"),p=Object.defineProperty,o=(x,E,g)=>E in x?p(x,E,{enumerable:!0,configurable:!0,writable:!0,value:g}):x[E]=g,r=(x,E,g)=>(o(x,typeof E!="symbol"?E+"":E,g),g);const C=K.default.span(({theme:x})=>(0,K.css)`
margin-right: 8px;
font-family: ${x.fonts.family.monospace};
`);class I extends u.Component{constructor(E){super(E),r(this,"_shouldShowTerms",()=>{const{messageTerms:g}=this.state;return g.size!==0}),r(this,"_getFormattedTerms",()=>{const{messageTerms:g}=this.state;return g.map(b=>u.createElement(C,{key:b},b))}),r(this,"_getFormattedFieldActions",()=>{const{customFieldActions:g,fieldName:b,message:ne}=this.props;return g?u.cloneElement(g,{fieldName:b,message:ne}):null}),this.state={messageTerms:y().List()}}render(){const{fieldName:E,renderForDisplay:g}=this.props,b=E===m.Zv||E===m.TW?"message-field":"";return u.createElement("dd",{className:b,key:`${E}dd`},this._getFormattedFieldActions(),u.createElement("div",{className:"field-value"},g(E)),this._shouldShowTerms()&&u.createElement(s.Alert,{bsStyle:"info",onDismiss:()=>this.setState({messageTerms:y().Map()})},"Field terms: \xA0",this._getFormattedTerms()))}}r(I,"propTypes",{message:O().object.isRequired,fieldName:O().string.isRequired,renderForDisplay:O().func.isRequired,customFieldActions:O().node}),r(I,"defaultProps",{customFieldActions:void 0});const V=I;var z=n("8/L0uEJc");const ge=[m.TW,"level"],ue=({message:x,value:E,fieldName:g,customFieldActions:b,renderForDisplay:ne})=>{const le=ge.indexOf(g)!==-1?x.fields[g]:E;return u.createElement("span",null,u.createElement("dt",{key:`${g}Title`},g),u.createElement(V,{key:`${g}Description`,message:x,fieldName:g,fieldValue:le,renderForDisplay:ne,customFieldActions:b}))};ue.propTypes={customFieldActions:O().node,fieldName:O().string.isRequired,message:O().object.isRequired,renderForDisplay:O().func.isRequired,value:O().any.isRequired},ue.defaultProps={customFieldActions:void 0};const we=ue;var ct=n("E9JT2cEW"),Ke=Object.defineProperty,We=(x,E,g)=>E in x?Ke(x,E,{enumerable:!0,configurable:!0,writable:!0,value:g}):x[E]=g,Pe=(x,E,g)=>(We(x,typeof E!="symbol"?E+"":E,g),g);class ye extends u.Component{constructor(){super(...arguments),Pe(this,"_formatFields",E=>Object.keys(E).sort().map(g=>u.createElement(we,{key:g,...this.props,fieldName:g,value:E[g]})))}render(){const{message:E}=this.props,{_id:g,...b}=E.fields,ne=E.formatted_fields||b,le=this._formatFields(ne);return u.createElement(D.D2,{className:"message-details-fields"},le)}}Pe(ye,"propTypes",{customFieldActions:O().node,message:O().object.isRequired,renderForDisplay:O().func.isRequired}),Pe(ye,"defaultProps",{customFieldActions:void 0});const je=ye;var He=n("Y2DdPzXi"),Ie=n("d4kzUuQm"),Ve=n("RCNj0OY4"),dt=Object.defineProperty,ze=(x,E,g)=>E in x?dt(x,E,{enumerable:!0,configurable:!0,writable:!0,value:g}):x[E]=g,me=(x,E,g)=>(ze(x,typeof E!="symbol"?E+"":E,g),g);class ve extends u.Component{constructor(){super(...arguments),me(this,"_inputName",E=>{const{inputs:g}=this.props,b=g.get(E);return b?u.createElement("span",{style:{wordBreak:"break-word"}},b.title):"deleted input"}),me(this,"_nodeName",E=>{const{nodes:g}=this.props,b=g.get(E);let ne;if(b){const le=Ie.Ay.node(E),ce=u.createElement(u.Fragment,null,u.createElement(D.In,{name:"fork_right"}),"\xA0",u.createElement("span",{style:{wordBreak:"break-word"}},b.short_node_id),"\xA0/\xA0",u.createElement("span",{style:{wordBreak:"break-word"}},b.hostname));ne=Ve.A.isCloud()?ce:u.createElement("a",{href:le},ce)}else ne=u.createElement("span",{style:{wordBreak:"break-word"}},"stopped node");return ne}),me(this,"_formatMessageActions",()=>{const{message:E,customFieldActions:g}=this.props;if(!g)return u.createElement(s.ButtonGroup,{className:"pull-right",bsSize:"small"});const b=E.index?Ie.Ay.message_show(E.index,E.id):"#";return u.createElement(s.ButtonGroup,{className:"pull-right",bsSize:"small"},u.createElement(s.Button,{href:b},"Permalink"),u.createElement(D.bL,{title:"Copy ID",bsSize:"small",text:E.id}))}),me(this,"_getStreamLinks",E=>{const{streams:g,message:b}=this.props;return b.streams?b.streams.map(le=>u.createElement("li",{key:le.id},u.createElement(H.A,{stream:le}))):E.map(le=>{const ce=g.get(le);return ce!==void 0?u.createElement("li",{key:ce.id},u.createElement(H.A,{stream:ce})):null})})}render(){const{renderForDisplay:E,nodes:g,message:b,customFieldActions:ne}=this.props,le=y().Set(b.stream_ids),ce=this._getStreamLinks(le),Oe=b.source_radio_id?u.createElement("span",null,"via ",u.createElement("em",null,this._inputName(b.source_radio_input_id))," on radio ",this._nodeName(b.source_radio_id)):null,Se=b.fields.timestamp,Ge=[u.createElement("dt",{key:`dt-${Se}`},"Timestamp"),u.createElement("dd",{key:`dd-${Se}`},u.createElement(D.Dc,{dateTime:Se}))],Le=b.source_input_id&&b.source_node_id&&g?u.createElement("div",null,u.createElement("dt",null,"Received by"),u.createElement("dd",null,u.createElement("em",null,this._inputName(b.source_input_id))," ","on ",this._nodeName(b.source_node_id),Oe&&u.createElement("br",null),Oe)):null,Qe=b.index?u.createElement(w.N,{to:Ie.Ay.message_show(b.index,b.id)},b.id):u.createElement("span",null,b.id," ",u.createElement(s.Label,{bsStyle:"warning"},"Not stored"));return u.createElement("div",null,u.createElement(s.Row,{className:"row-sm"},u.createElement(s.Col,{md:12},this._formatMessageActions(),u.createElement(He.A,null,u.createElement(D.In,{name:"mail"}),"\xA0",Qe))),u.createElement(s.Row,null,u.createElement(s.Col,{md:3},u.createElement(D.D2,null,Ge,Le,u.createElement("dt",null,"Stored in index"),u.createElement("dd",null,b.index?b.index:"Message is not stored"),le.size>0&&u.createElement("dt",null,"Routed into streams"),le.size>0&&u.createElement("dd",{className:"stream-list"},u.createElement("ul",null,ce)))),u.createElement(s.Col,{md:9},u.createElement("div",null,u.createElement(je,{message:b,renderForDisplay:E,customFieldActions:ne})))))}}me(ve,"propTypes",{renderForDisplay:O().func.isRequired,inputs:O().object,nodes:O().object,message:O().object.isRequired,streams:O().object,customFieldActions:O().node}),me(ve,"defaultProps",{inputs:void 0,nodes:void 0,streams:void 0,customFieldActions:void 0});const Je=ve;var mt=Object.defineProperty,Ye=(x,E,g)=>E in x?mt(x,E,{enumerable:!0,configurable:!0,writable:!0,value:g}):x[E]=g,he=(x,E,g)=>(Ye(x,typeof E!="symbol"?E+"":E,g),g);class be extends u.Component{constructor(E){super(E),he(this,"_getImmutableProps",g=>({streams:g.streams?y().Map(g.streams):g.streams,nodes:g.nodes?y().Map(g.nodes):g.nodes})),he(this,"renderForDisplay",g=>{const{message:b}=this.props;return l.A.stringify(b.fields[g])}),this.state=this._getImmutableProps(E)}UNSAFE_componentWillReceiveProps(E){this.setState(this._getImmutableProps(E))}render(){const{inputs:E,message:g}=this.props,{streams:b,nodes:ne}=this.state;return u.createElement(s.Row,{className:"content"},u.createElement(s.Col,{md:12},u.createElement(Je,{...this.props,message:g,inputs:E,streams:b,nodes:ne,renderForDisplay:this.renderForDisplay,showTimestamp:!0})))}}he(be,"propTypes",{message:O().object.isRequired,inputs:O().object,streams:O().object,nodes:O().object}),he(be,"defaultProps",{inputs:void 0,nodes:void 0,streams:void 0});const se=be},DHbpw63n:(ae,k,n)=>{n.r(k),n.d(k,{default:()=>Dn});var e=n("Z7aTuO5B"),O=n("yAXMqwrl"),u=n("8fnsnG21"),R=n("IOI9nV80"),y=n("ii0bleBb"),s=n.n(y),l=n("rIl5IEuP"),w=n("E+CaPsQD"),D=n("MdYBRjRJ"),H=n("8OvTct/Z"),K=n("0t7Ye+61"),m=n("/7OuCFNo"),p=n("d4kzUuQm"),o=n("v4GbOr/o"),r=n("J6y4/h8P"),C=n("Jg5wVMAu"),I=n.n(C),V=n("DUKaTDO2"),z=n("jAGDuYSC"),ge=n("eFxcQyPT"),ue=n("U1Iufsob"),we=n("6dLKCZdN");const ct=t=>{sessionStorage.setItem("rule_source_code",t)},Ke=()=>sessionStorage.getItem("rule_source_code"),We=()=>{sessionStorage.removeItem("rule_source_code")},Pe=async t=>{try{const c=await(0,ge.Ay)("POST",(0,D.H3)(ue.A.RuleBuilderController.create().url),t);return z.A.success(`Rule "${t.title}" created successfully`),c}catch(c){return z.A.error(`Creating the Rule Builder Rule failed with status: ${c}`,"Could not Create the Rule Builder Rule."),null}},ye=async t=>{const{source:c,errors:i,...d}=t;try{await(0,ge.Ay)("PUT",(0,D.H3)(ue.A.RuleBuilderController.update(t.id).url),d),z.A.success(`Rule "${t.title}" updated successfully`)}catch(L){z.A.error(`Updating the Rule Builder Rule failed with status: ${L}`,"Could not Update the Rule Builder Rule.")}},je=async t=>{const{source:c,...i}=t;return(0,ge.Ay)("POST",(0,D.H3)(ue.A.RuleBuilderController.validate().url),i)},He=async(t="")=>(0,ge.Ay)("GET",(0,D.H3)(ue.A.RulesController.get(t).url)),Ie=async()=>(0,ge.Ay)("GET",(0,D.H3)(ue.A.RuleBuilderController.listConditionsDict().url)),Ve=async()=>(0,ge.Ay)("GET",(0,D.H3)(ue.A.RuleBuilderController.listActionsDict().url)),ze=()=>{const{ruleId:t}=(0,we.A)(),c=t!=="new",{data:i,refetch:d,isFetching:L}=(0,V.useQuery)(["rule"],()=>He(t),{enabled:c,onError:N=>{z.A.error(`Loading Rule Builder Rule failed with status: ${N}`,"Could not load Rule Builder Rule.")}}),{data:P,refetch:a,isFetching:T}=(0,V.useQuery)(["conditions"],Ie,{onError:N=>{z.A.error(`Loading Rule Builder Conditions list failed with status: ${N}`,"Could not load Rule Builder Conditions list.")},keepPreviousData:!0}),{data:f,refetch:h,isFetching:W}=(0,V.useQuery)(["actions"],Ve,{onError:N=>{z.A.error(`Loading Rule Builder Actions list failed with status: ${N}`,"Could not load Rule Builder Actions list.")},keepPreviousData:!0});return{isLoadingRule:L,isLoadingConditionsDict:T,isLoadingActionsDict:W,conditionsDict:P,actionsDict:f,rule:c?i:null,refetchRule:d,refetchConditionsDict:a,refetchActionsDict:h,createRule:Pe,updateRule:ye,fetchValidateRule:je}},me=e.createContext(null),ve=()=>{try{const t=(0,e.useContext)(me);if(!t)throw new Error("useRuleBuilder must be used within a RuleBuilderProvider");return t}catch{return{useHighlightedOutput:["",()=>{}]}}},Je=me,Ye=({children:t})=>{const[c,i]=(0,e.useState)(void 0),d=(0,e.useMemo)(()=>({useHighlightedOutput:[c,i]}),[c]);return e.createElement(Je.Provider,{value:d},t)};var he=n("HhRuy6uH"),be=n("HQjpSCKK"),se=(t=>(t.Boolean="java.lang.Boolean",t.Message="org.graylog2.plugin.Message",t.Number="java.lang.Long",t.Object="java.lang.Object",t.String="java.lang.String",t.Void="java.lang.Void",t.DateTime="org.joda.time.DateTime",t.DateTimeZone="org.joda.time.DateTimeZone",t.DateTimeFormatter="org.joda.time.format.DateTimeFormatter",t))(se||{});const x=null,E=s().arrayOf(s().shape({variableName:s().string.isRequired,variableType:s().string,stepOrder:s().number.isRequired,blockId:s().string})),g=s().shape({function:s().string.isRequired,params:s().objectOf(s().oneOfType([s().string,s().number,s().bool])).isRequired,output:s().string,errors:s().arrayOf(s().string)}),b=s().shape({name:s().string.isRequired,pure:s().bool.isRequired,return_type:s().string.isRequired,params:s().arrayOf(s().shape({type:s().string.isRequired,transformed_type:s().string.isRequired,name:s().string.isRequired,optional:s().bool.isRequired,rule_builder_variable:s().bool.isRequired,description:s().string})).isRequired,description:s().string,rule_builder_enabled:s().bool.isRequired,rule_builder_title:s().string}),ne=r.default.span(({theme:t})=>(0,r.css)`
color: ${t.colors.variant.info};
font-weight: bold;
`),le=(0,r.default)(l.Label)(({theme:t})=>(0,r.css)`
margin-left: ${t.spacings.xs};
`),ce=(0,r.default)(l.Row)(({theme:t,$hovered:c})=>(0,r.css)`
cursor: pointer;
display: flex;
align-items: center;
margin: 0;
height: ${t.spacings.xl};
background-color: ${c?t.colors.table.row.backgroundHover:"transparent"};
border-left: solid 1px ${t.colors.gray[80]};
`),Oe=(0,r.default)(l.Button)(({theme:t,$negate:c})=>(0,r.css)`
opacity: ${c?"1":"0.3"};
margin-right: ${t.spacings.sm};
`),Se=r.default.h5`
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
`,Ge=r.default.p(({theme:t})=>(0,r.css)`
color: ${t.colors.variant.danger};
font-size: 0.75rem;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
margin: 0;
`),Le=r.default.div`
display: flex;
align-items: center;
justify-content: end;
`,Qe=(0,r.default)(R.K0)(({theme:t})=>(0,r.css)`
margin-right: ${t.spacings.xs};
`),Ze=({block:t,negatable:c,onEdit:i,onDelete:d,onNegate:L,onDuplicate:P,onInsertAbove:a,onInsertBelow:T,returnType:f,type:h})=>{var W,N;const[F,U]=(0,e.useState)(!1),[J,Q]=(0,e.useState)(!1),[$,S]=ve().useHighlightedOutput,v=()=>{Q(X=>!X),U(!J)},B=(X=>{switch(X){case se.Number:return"Number";default:return X==null?void 0:X.slice(((X==null?void 0:X.lastIndexOf("."))||0)+1)}})(f),_=(X,fe="")=>fe.split(/('\$.*?')/).map(te=>te===`'$${X}'`?e.createElement(ne,null,te):te).map((te,Ce)=>e.createElement(e.Fragment,{key:Ce},te)),Y=(W=t==null?void 0:t.errors)==null?void 0:W.join(", ");return e.createElement(ce,{onMouseEnter:()=>U(!0),onMouseLeave:J?void 0:()=>U(!1),$hovered:F},e.createElement(l.Col,{xs:9,md:10},e.createElement(l.Row,null,e.createElement(l.Col,{xs:10,md:9},e.createElement(Se,{title:t==null?void 0:t.step_title},c&&e.createElement(Oe,{bsStyle:"primary",bsSize:"xs",$negate:t==null?void 0:t.negate,onClick:X=>{X.target.blur(),L()}},"Not"),$?_($,t==null?void 0:t.step_title):t==null?void 0:t.step_title,((N=t==null?void 0:t.errors)==null?void 0:N.length)>0&&e.createElement(Ge,{title:Y},Y))),(t==null?void 0:t.outputvariable)&&e.createElement(l.Col,{xs:2,md:3},e.createElement(l.Label,{bsStyle:"primary",onMouseEnter:()=>S(t.outputvariable),onMouseLeave:()=>S(void 0)},`$${t.outputvariable}`),B&&e.createElement(le,{bsStyle:"default"},B)))),e.createElement(l.Col,{xs:3,md:2,className:"text-right"},F&&h==="condition"&&e.createElement(Le,null,e.createElement(R.K0,{name:"edit_square",onClick:i,title:"Edit"}),e.createElement(R.K0,{name:"delete",onClick:d,title:"Delete"})),F&&h==="action"&&e.createElement(Le,null,e.createElement(Qe,{name:"edit_square",onClick:i,title:"Edit"}),e.createElement(be.A,{title:he.$N,buttonTitle:he.qE,bsSize:"xsmall",onToggle:v,dropdownZIndex:1e3},e.createElement(l.MenuItem,{onClick:i},"Edit"),e.createElement(l.MenuItem,{onClick:()=>{P(),v()}},"Duplicate"),e.createElement(l.MenuItem,{divider:!0}),e.createElement(l.MenuItem,{onClick:a},"Insert above"),e.createElement(l.MenuItem,{onClick:T},"Insert below"),e.createElement(l.MenuItem,{divider:!0}),e.createElement(l.MenuItem,{onClick:d,variant:"danger"},"Delete")))))};Ze.propTypes={block:g,onDelete:s().func.isRequired,onEdit:s().func.isRequired,negatable:s().bool,onNegate:s().func.isRequired},Ze.defaultProps={block:void 0,negatable:!1,returnType:void 0};const Mt=Ze;var pt=n("UiXZqrDE");const Nt=[se.String,se.Object,se.Number,se.Boolean],ke=({param:t,functionName:c,blockId:i,order:d,outputVariableList:L,blockType:P,resetField:a})=>{const[T,f]=(0,e.useState)(void 0),[h,W]=(0,pt.useField)(t.name);(0,e.useEffect)(()=>{f(void 0)},[c]);const N=_=>typeof _<"u"&&_!==null,F=_=>typeof _=="string"&&_.startsWith("$"),U=()=>!(!t.rule_builder_variable||d===0),J=_=>N(_)&&F(_)?"Fields starting with '$' are not allowed.":null,Q=_=>{f(_),a(t.name)},$=()=>L.filter(_=>_.blockId===i||_.stepOrder>=d?!1:t.type===se.Object?!0:_.variableType===t.type),S=()=>!U()||$().length<=0?null:e.createElement(l.Button,{onClick:()=>Q("select")},"Use output from previous steps"),v=()=>!U()||$().length<=0||!Nt.includes(t.type)?!1:T==="select"?!0:typeof T<"u"?!1:!W.initialValue||W.initialValue===""||F(W.initialValue),A=_=>_.optional?e.createElement(e.Fragment,null,_.name," ",e.createElement(R.Bt,null)):_.name;if(v())return e.createElement(R.o$,{type:"select",key:`${c}_${t.name}`,name:t.name,label:A(t),required:!t.optional,buttonAfter:e.createElement(l.Button,{onClick:()=>Q("custom")},`Set custom ${t.name}`),help:t.description,...h},e.createElement("option",{key:"placeholder",value:""},"Select output from list"),$().map(({variableName:_,stepOrder:Y})=>e.createElement("option",{key:`option-${_}`,value:_},`Output from step ${Y+1} (${_})`)));const B=`No previous action returns type ${t.type.slice(t.type.lastIndexOf(".")+1)}`;switch(t.type){case se.String:case se.Object:return e.createElement(R.o$,{type:"text",key:`${c}_${t.name}`,name:t.name,label:A(t),required:!t.optional,validate:J,buttonAfter:S(),help:t.description,...h});case se.Number:return e.createElement(R.o$,{type:"number",key:`${c}_${t.name}`,name:t.name,label:A(t),required:!t.optional,buttonAfter:S(),help:t.description,...h});case se.Boolean:return e.createElement(e.Fragment,null,e.createElement(l.ControlLabel,{className:"col-sm-3"},A(t)),e.createElement(R.o$,{type:"checkbox",key:`${c}_${t.name}`,name:t.name,label:h.value?"true":"false",help:t.description,checked:h.value,buttonAfter:S(),...h}));default:return P==="action"?e.createElement(R.o$,{type:"select",key:`${c}_${t.name}`,name:t.name,label:A(t),required:!t.optional,help:!$().length&&t.optional?B:t.description,error:!$().length&&!t.optional?B:void 0,...h},e.createElement("option",{key:"placeholder",value:""},"Select output from list"),$().map(({variableName:_,stepOrder:Y})=>e.createElement("option",{key:`option-${_}`,value:_},`Output from step ${Y+1} (${_})`))):null}};ke.propTypes={param:s().shape({type:s().string.isRequired,transformed_type:s().string.isRequired,name:s().string.isRequired,optional:s().bool.isRequired,rule_builder_variable:s().bool.isRequired,description:s().string}).isRequired,blockId:s().string,functionName:s().string.isRequired,order:s().number.isRequired,outputVariableList:E,resetField:s().func.isRequired},ke.defaultProps={blockId:void 0,outputVariableList:[]};const Ut=ke,xt=(0,r.default)(l.Row)(({theme:t})=>(0,r.css)`
margin-top: ${t.spacings.xs};
`),Ft=r.default.p(({theme:t})=>(0,r.css)`
color: ${t.colors.variant.danger};
margin-top: ${t.spacings.xs};
margin-bottom: ${t.spacings.xs};
`),Xe=({objectWithErrors:t})=>{var c;return!t||!t.errors||!(t.errors.length>0)?null:e.createElement(xt,null,e.createElement(l.Col,{md:12},(c=t==null?void 0:t.errors)==null?void 0:c.map(i=>e.createElement(l.Row,{key:i},e.createElement(l.Col,{md:12},e.createElement(Ft,null,i))))))};Xe.propTypes={objectWithErrors:s().shape({errors:s().arrayOf(s().string)})},Xe.defaultProps={objectWithErrors:void 0};const Et=Xe;var $t=n("dFpwyWHg"),gt=n.n($t),wt=n("C2ikvoS0"),ft=n.n(wt),Kt=n("1IntWRSu"),ht=n.n(Kt),Wt=n("8nGWeFnd"),vt=n.n(Wt),jt=n("TeAcaicX"),_t=n.n(jt),Ht=n("eE3+5goe"),Rt=n.n(Ht),Be=n("LyhA1BK7"),_e={};_e.styleTagTransform=Rt(),_e.setAttributes=vt(),_e.insert=ht().bind(null,"head"),_e.domAPI=ft(),_e.insertStyleElement=_t();var Bn=gt()(Be.A,_e);const re=Be.A&&Be.A.locals?Be.A.locals:void 0,Ct=t=>t.replace(/^.*\.(.*?)$/,"$1"),qe=t=>{const c=t.params.map(i=>i.optional?`[${i.name}]`:i.name);return`${t.name}(${c.join(", ")}) : ${Ct(t.return_type)}`},et=({entries:t,expanded:c,onFunctionClick:i})=>{const d=P=>P.params.map(a=>e.createElement("tr",{key:a.name},e.createElement("td",{className:re.adjustedTableCellWidth},a.name),e.createElement("td",{className:re.adjustedTableCellWidth},Ct(a.type)),e.createElement("td",{className:`${re.adjustedTableCellWidth} text-centered`},a.optional?null:e.createElement(R.In,{name:"check"})),e.createElement("td",null,a.description))),L=P=>P?P.map(a=>{let T=null;return c[a.name]&&(T=e.createElement("tr",null,e.createElement("td",{colSpan:2},e.createElement(l.Table,{condensed:!0,striped:!0,hover:!0},e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Parameter"),e.createElement("th",null,"Type"),e.createElement("th",null,"Required"),e.createElement("th",null,"Description"))),e.createElement("tbody",null,d(a)))))),e.createElement("tbody",{key:a.name},i?e.createElement("tr",{onClick:()=>i(a.name),className:re.clickableRow},e.createElement("td",{className:re.functionTableCell},e.createElement("code",null,qe(a))),e.createElement("td",null,a.description)):e.createElement("tr",null,e.createElement("td",{className:re.functionTableCell},e.createElement("code",null,qe(a))),e.createElement("td",null,a.description)),T)}):[];return e.createElement(l.Table,{condensed:!0},e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Function"),e.createElement("th",null,"Description"))),L(t))};et.propTypes={entries:s().arrayOf(b).isRequired,expanded:s().objectOf(s().bool),onFunctionClick:s().func},et.defaultProps={expanded:{},onFunctionClick:void 0};const tt=et,Vt=r.default.p(({theme:t})=>(0,r.css)`
color: ${t.colors.gray[50]};
`),zt=r.default.div(({theme:t})=>(0,r.css)`
border-left: 1px solid ${t.colors.gray[90]};
border-right: 1px solid ${t.colors.gray[90]};
border-bottom: 1px solid ${t.colors.gray[90]};
border-radius: 0 0 10px 10px;
padding: ${t.spacings.md};
`),Jt=(0,r.default)(l.Row)(({theme:t})=>(0,r.css)`
margin-bottom: ${t.spacings.md};
`),Yt=r.default.p(({theme:t})=>(0,r.css)`
margin-bottom: ${t.spacings.xxs};
`),Gt=(0,r.default)(l.Row)(({theme:t})=>(0,r.css)`
margin-top: ${t.spacings.xxs};
margin-bottom: ${t.spacings.xxs};
`),Qt=r.default.p(({theme:t,$isSelected:c})=>(0,r.css)`
color: ${c?t.colors.gray[90]:t.colors.gray[50]};
margin-bottom: ${t.spacings.xxs};
font-size: 0.75rem;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
`),nt=({existingBlock:t,onAdd:c,onCancel:i,onSelect:d,onUpdate:L,options:P,order:a,outputVariableList:T,selectedBlockDict:f,type:h})=>{const[W,N]=(0,e.useState)({}),{pathname:F}=(0,K.A)(),U=(0,H.A)();(0,e.useEffect)(()=>{const v={};f&&f.params.forEach(A=>{const B=(t==null?void 0:t.function)===f.name?t==null?void 0:t.params[A.name]:void 0;B||A.type===se.Boolean&&typeof B=="boolean"?v[A.name]=B:v[A.name]=A.default_value}),N(v)},[f,t]);const J=(v,A)=>{U(h==="condition"?o.g.PIPELINE_RULE_BUILDER.NEW_CONDITION_SELECTED:o.g.PIPELINE_RULE_BUILDER.NEW_ACTION_SELECTED,{app_pathname:(0,D.i)(F),app_section:"pipeline-rule-builder",app_action_value:`select-${h}`,event_details:{option:v}}),A(),d(v)},Q=(v,A)=>{A(v,null)},$=v=>{t?(U(h==="condition"?o.g.PIPELINE_RULE_BUILDER.UPDATE_CONDITION_CLICKED:o.g.PIPELINE_RULE_BUILDER.UPDATE_ACTION_CLICKED,{app_pathname:(0,D.i)(F),app_section:"pipeline-rule-builder",app_action_value:`update-${h}-button`}),L(v,f==null?void 0:f.name)):(U(h==="condition"?o.g.PIPELINE_RULE_BUILDER.ADD_CONDITION_CLICKED:o.g.PIPELINE_RULE_BUILDER.ADD_ACTION_CLICKED,{app_pathname:(0,D.i)(F),app_section:"pipeline-rule-builder",app_action_value:`add-${h}-button`}),c(v))},S=(v,A)=>e.createElement(e.Fragment,null,e.createElement(Yt,null,v.label),v.description&&e.createElement(Qt,{$isSelected:A},v.description));return e.createElement(l.Row,null,e.createElement(l.Col,{md:12},e.createElement(pt.Formik,{enableReinitialize:!0,onSubmit:$,initialValues:W},({resetForm:v,setFieldValue:A,isValid:B})=>e.createElement(R.mK,null,e.createElement(Gt,null,e.createElement(l.Col,{md:12},e.createElement(R.l6,{id:`existingBlock-select-${h}`,name:`existingBlock-select-${h}`,placeholder:`Add ${h}`,options:P,optionRenderer:S,clearable:!1,matchProp:"label",autoFocus:!0,onChange:_=>J(_,v),value:(f==null?void 0:f.name)||""}))),f&&e.createElement(zt,null,e.createElement(Jt,null,e.createElement(l.Col,{md:12},e.createElement("h5",null,(t==null?void 0:t.step_title)||f.rule_builder_name,e.createElement(R.N,{trigger:"click",rootClose:!0,placement:"right",title:"Function Syntax Help",width:700,overlay:e.createElement(tt,{entries:[f],expanded:{[f.name]:!0}})},e.createElement(l.Button,{bsStyle:"link"},e.createElement(R.In,{name:"help",title:"Function Syntax Help","data-testid":"funcSyntaxHelpIcon"})))),e.createElement(Vt,null,f.description))),f.params.map(_=>e.createElement(l.Row,{key:`${a}_${_.name}`},e.createElement(Ut,{param:_,functionName:f.name,order:a,blockId:t==null?void 0:t.id,outputVariableList:T,blockType:h,resetField:Y=>Q(Y,A)}))),e.createElement(Et,{objectWithErrors:t}),e.createElement(R.hP,{bsSize:"small",disabledSubmit:!B,submitButtonText:t?"Update":"Add",submitButtonType:"submit",onCancel:()=>{v(),i()}}))))))};nt.propTypes={existingBlock:g,onAdd:s().func.isRequired,onCancel:s().func.isRequired,onSelect:s().func.isRequired,onUpdate:s().func.isRequired,options:s().arrayOf(s().shape({label:s().string,value:s().any})).isRequired,order:s().number.isRequired,outputVariableList:E,selectedBlockDict:b,type:s().oneOf(["action","condition"]).isRequired},nt.defaultProps={existingBlock:void 0,outputVariableList:void 0,selectedBlockDict:void 0};const At=nt,lt=(t,c)=>t==null?void 0:t.find(i=>i.name===c),Zt=t=>{try{return JSON.parse(t),t}catch{try{const c=`{"${t.trim().replace(/^\s*\n/gm,"").replace(/"/g,'\\"').split(`
`).map(i=>i.trim().split(":").map(d=>d.trim())).filter(i=>i[0]&&i[1]).map(i=>`${i[0].replace(/\\"/g,"").trim()}":"${i.slice(1).join(":").trim()}`).join('","')}"}`;return JSON.parse(c),c}catch{return JSON.stringify({message:t})}}},De=t=>{var c,i,d,L,P,a;return!!(((i=(c=t==null?void 0:t.rule_builder)==null?void 0:c.errors)==null?void 0:i.length)>0||(L=(d=t==null?void 0:t.rule_builder)==null?void 0:d.actions)!=null&&L.some(T=>{var f;return((f=T.errors)==null?void 0:f.length)>0})||(a=(P=t==null?void 0:t.rule_builder)==null?void 0:P.conditions)!=null&&a.some(T=>{var f;return((f=T.errors)==null?void 0:f.length)>0}))},kt=r.default.div(({theme:t})=>(0,r.css)`
padding-top: ${t.spacings.xxs};
`),st=({type:t,blockDict:c,block:i,order:d,outputVariableList:L,addBlock:P,updateBlock:a,deleteBlock:T})=>{const[f,h]=(0,e.useState)(void 0),[W,N]=(0,e.useState)(!1),[F,U]=(0,e.useState)(void 0),[J,Q]=(0,e.useState)(void 0),{pathname:$}=(0,K.A)(),S=(0,H.A)();(0,e.useEffect)(()=>{i&&h(lt(c,i.function))},[i,c]);const v=Z=>{const oe={newFunctionName:f.name,newParams:{},toggleNegate:!1},{newFunctionName:$e,newParams:Tn,toggleNegate:On}={...oe,...Z},Ln={function:$e,params:{}};let Ae;return i&&$e===i.function?Ae=i:Ae=Ln,On&&(Ae.negate=!Ae.negate),{...Ae,params:{...Ae.params,...Tn}}},A=()=>{N(!1),h(i?c.find(Z=>Z.name===i.function):void 0)},B=()=>{U(void 0),Q(void 0)},_=()=>{A(),B()},Y=Z=>{P(t,v({newParams:Z})),_()},X=()=>{S(t==="condition"?o.g.PIPELINE_RULE_BUILDER.DELETE_CONDITION_CLICKED:o.g.PIPELINE_RULE_BUILDER.DELETE_ACTION_CLICKED,{app_pathname:(0,D.i)($),app_section:"pipeline-rule-builder",app_action_value:`delete-${t}-button`}),T(d,t)},fe=()=>{S(t==="condition"?o.g.PIPELINE_RULE_BUILDER.EDIT_CONDITION_CLICKED:o.g.PIPELINE_RULE_BUILDER.EDIT_ACTION_CLICKED,{app_pathname:(0,D.i)($),app_section:"pipeline-rule-builder",app_action_value:`edit-${t}-button`}),N(!0)},Ee=()=>{S(o.g.PIPELINE_RULE_BUILDER.NEGATE_CONDITION_CLICKED,{app_pathname:(0,D.i)($),app_section:"pipeline-rule-builder",app_action_value:`negate-${t}-button`}),a(d,t,v({toggleNegate:!0}))},q=async()=>{S(o.g.PIPELINE_RULE_BUILDER.DUPLICATE_ACTION_CLICKED,{app_pathname:(0,D.i)($),app_section:"pipeline-rule-builder",app_action_value:`duplicate-${t}`});const Z={...i,outputvariable:null};P(t,Z,d+1)},te=Z=>{if(F){const oe={id:"",function:J.name,params:Z,outputvariable:null};P(t,oe,F==="above"?d:d+1)}_()},Ce=()=>{S(o.g.PIPELINE_RULE_BUILDER.INSERT_ABOVE_ACTION_CLICKED,{app_pathname:(0,D.i)($),app_section:"pipeline-rule-builder",app_action_value:`insert-above-${t}`}),U("above")},Fe=()=>{S(o.g.PIPELINE_RULE_BUILDER.INSERT_BELOW_ACTION_CLICKED,{app_pathname:(0,D.i)($),app_section:"pipeline-rule-builder",app_action_value:`insert-below-${t}`}),U("below")},Te=(Z,oe)=>{a(d,t,v({newFunctionName:oe,newParams:Z})),_()},M=Z=>{h(c.find(oe=>oe.name===Z))},j=Z=>{Q(c.find(oe=>oe.name===Z))},G=()=>t==="condition",ee=c.map(({name:Z,description:oe,rule_builder_name:$e})=>({label:$e,value:Z,description:oe})),de=!i||W;return e.createElement(kt,null,de?e.createElement(At,{existingBlock:i,onAdd:Y,onCancel:_,onUpdate:Te,onSelect:M,order:d,options:ee,outputVariableList:L,selectedBlockDict:f,type:t}):e.createElement(e.Fragment,null,e.createElement(Mt,{block:i,onDelete:X,onEdit:fe,onNegate:Ee,onDuplicate:q,onInsertAbove:Ce,onInsertBelow:Fe,returnType:f==null?void 0:f.return_type,negatable:G(),type:t}),!!F&&e.createElement(l.Modal,{show:!0,title:"insert rule action",bsSize:"lg",enforceFocus:!0,onHide:B},e.createElement(l.Modal.Header,{closeButton:!0},e.createElement(l.Modal.Title,null,"Insert new action ",F," action N\xB0",d+1)),e.createElement(l.Modal.Body,null,e.createElement(At,{onAdd:te,onCancel:_,onUpdate:Te,onSelect:j,order:F==="above"?d:d+1,options:ee,outputVariableList:L,selectedBlockDict:J,type:t})))))};st.propTypes={type:s().oneOf(["action","condition"]).isRequired,blockDict:s().arrayOf(b).isRequired,block:g,order:s().number.isRequired,outputVariableList:E,addBlock:s().func.isRequired,updateBlock:s().func.isRequired,deleteBlock:s().func.isRequired},st.defaultProps={block:void 0,outputVariableList:void 0};const Me=st;var Xt=n("ty2gyrHp"),pe=n("sRNsEgBM");let Ne;const Mn=`message: test
source: unknown
`,Ue=(0,e.createContext)(void 0);var ie=(t=>(t.Simple="Simple",t.KeyValue="KeyValue",t.JSON="JSON",t))(ie||{});const qt=(t,c)=>{switch(c){case"JSON":case"KeyValue":return Zt(t);case"Simple":default:return JSON.stringify({message:t})}},en=(t,c=()=>{},i=()=>{})=>{let d;t!=null&&t.id?d=pe.z.update(t):d=pe.z.save(t),d.then(c).catch(i)},ot=({children:t,usedInPipelines:c,rule:i})=>{const d=(0,e.useRef)(void 0),[,L]=(0,e.useState)(!1),[P,a]=(0,e.useState)(i==null?void 0:i.source),[T,f]=(0,e.useState)(i==null?void 0:i.description),[h,W]=(0,e.useState)(""),[N,F]=(0,e.useState)(null);(0,e.useEffect)(()=>{const S=Ke();a(S||(i==null?void 0:i.source)),f(i==null?void 0:i.description),We(),i!=null&&i.simulator_message&&W(i==null?void 0:i.simulator_message)},[i]);const U=(0,e.useCallback)(S=>{var v,A;const B=S.map(_=>({row:_.line-1,column:_.position_in_line-1,text:_.reason,type:"error"}));(A=(v=d==null?void 0:d.current)==null?void 0:v.editor)==null||A.getSession().setAnnotations(B)},[]),J=(0,e.useCallback)(S=>{var v,A;const B={...i,source:(A=(v=d==null?void 0:d.current)==null?void 0:v.editor)==null?void 0:A.getSession().getValue(),simulator_message:h,description:T};pe.z.parse(B,S)},[i,T,h]),Q=(0,e.useCallback)((S,v,A=h,B=F)=>{const _=qt(A,v);pe.z.simulate(_,S,B)},[h,F]);(0,e.useEffect)(()=>{var S,v;d!=null&&d.current&&((v=(S=d==null?void 0:d.current)==null?void 0:S.editor)==null||v.session.setOption("useWorker",!1))});const $=(0,e.useMemo)(()=>{const S=(B=()=>{})=>{var _,Y;const X={...i,source:(Y=(_=d==null?void 0:d.current)==null?void 0:_.editor)==null?void 0:Y.getSession().getValue(),simulator_message:h,description:T};pe.z.parse(X,()=>B(X))},v=(B=()=>{},_=()=>{})=>{S(Y=>en(Y,B,_))},A=B=>{a(B),Ne&&(clearTimeout(Ne),Ne=null),Ne=setTimeout(()=>{J(_=>{U(_||[])})},500)};return{rule:{...i,description:T,source:P,simulator_message:h},description:T,handleDescription:f,handleSavePipelineRule:v,ruleSourceRef:d,usedInPipelines:c,onAceLoaded:()=>L(!0),ruleSource:P,onChangeSource:A,simulateRule:Q,rawMessageToSimulate:h,setRawMessageToSimulate:W,ruleSimulationResult:N,setRuleSimulationResult:F}},[T,U,i,P,c,J,Q,h,N]);return e.createElement(Ue.Provider,{value:$},t)};ot.propTypes={children:s().node.isRequired,usedInPipelines:s().array,rule:s().shape({id:s().string,title:s().string,description:s().string,source:s().string,simulator_message:s().string})},ot.defaultProps={usedInPipelines:[],rule:{description:"",source:"",simulator_message:""}};var xe=n("/Ol8rEWQ"),Re={};Re.styleTagTransform=Rt(),Re.setAttributes=vt(),Re.insert=ht().bind(null,"head"),Re.domAPI=ft(),Re.insertStyleElement=_t();var Nn=gt()(xe.A,Re);const tn=xe.A&&xe.A.locals?xe.A.locals:void 0,Pt=({create:t})=>{const{usedInPipelines:c}=(0,e.useContext)(Ue);if(t)return null;const i=()=>c.map(d=>e.createElement("li",{key:d.id},e.createElement(Xt.N,{to:p.Ay.SYSTEM.PIPELINES.PIPELINE(d.id)},d.title)));return e.createElement(l.Input,{id:"used-in-pipelines",label:"Used in pipelines",help:"Pipelines that use this rule in one or more of their stages."},e.createElement("div",{className:"form-control-static"},c.length===0?"This rule is not being used in any pipelines.":e.createElement("ul",{className:tn.usedInPipelines},i())))};Pt.propTypes={create:s().bool.isRequired};const yt=Pt,nn=({rule:t,onChange:c})=>{const i=L=>{c({...t,title:L.target.value})},d=L=>{c({...t,description:L.target.value})};return e.createElement("fieldset",null,e.createElement(l.Row,null,e.createElement(l.Col,{xs:6},e.createElement(l.Input,{type:"text",id:"title",label:"Title",value:t.title,onChange:i,autoFocus:!0,required:!0,help:"Rule title."})),e.createElement(l.Col,{xs:6},e.createElement(l.Input,{type:"textarea",id:"description",label:"Description",value:t.description,onChange:d,rows:1,help:"Rule description (optional)."}))),e.createElement(yt,{create:!!t}))};var ln=n("gqVHlIxA"),sn=n("VVS+7KXv");const on=r.default.div`
word-break: break-all;
overflow-wrap: break-word;
white-space: pre-wrap;
max-height: 500px;
`,rn=({show:t,onHide:c,onNavigateAway:i,rule:d})=>{const L=(0,m.A)(),{pathname:P}=(0,K.A)(),a=(0,H.A)();return e.createElement(ln.A,{showModal:t,onHide:c,bsSize:"large"},e.createElement(l.Modal.Header,{closeButton:!0},e.createElement(l.Modal.Title,null,d.title||"")),e.createElement(l.Modal.Body,null,e.createElement("pre",null,e.createElement(on,null,d.source||""))),e.createElement(l.Modal.Footer,null,e.createElement(l.Button,{type:"button",bsStyle:"success",onClick:async()=>{a(o.g.PIPELINE_RULE_BUILDER.CREATE_NEW_RULE_FROM_CODE_CLICKED,{app_pathname:(0,D.i)(P),app_section:"convert-rule-builder-to-source-code-modal",app_action_value:"create-new-rule-from-code-button"}),ct(d.source||""),await i(d),L.push(p.Ay.SYSTEM.PIPELINES.RULE("new"))}},"Create new Rule from Code"),e.createElement(l.Button,{type:"button",bsStyle:"info",onClick:()=>{a(o.g.PIPELINE_RULE_BUILDER.COPY_CODE_AND_CLOSE_CLICKED,{app_pathname:(0,D.i)(P),app_section:"convert-rule-builder-to-source-code-modal",app_action_value:"copy-rule-code-and-close-button"}),(0,sn.A)(d.source),z.A.success("Rule source code copied to clipboard!"),c()}},"Copy & Close")))};var an=n("wzrLaWZc");const un=(0,r.default)(l.Button)(({theme:t})=>(0,r.css)`
margin-left: ${t.spacings.xs};
`),cn=r.default.div(({theme:t})=>(0,r.css)`
padding: ${t.spacings.sm};
`),It=r.default.span`
color: #aaa;
`,bt=r.default.div(({theme:t})=>(0,r.css)`
margin-bottom: ${t.spacings.xs};
`),St=r.default.div(({$highlighted:t,theme:c})=>(0,r.css)`
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
color: ${t?c.colors.variant.info:"inherit"};
font-weight: ${t?"bold":"inherit"};
`),dn=(0,r.default)(l.FormGroup)(({theme:t})=>(0,r.css)`
margin-bottom: ${t.spacings.xl};
`),rt=({rule:t,onSaveMessage:c})=>{var i,d;const{rule:L,simulateRule:P,rawMessageToSimulate:a,setRawMessageToSimulate:T,ruleSimulationResult:f,setRuleSimulationResult:h}=(0,e.useContext)(Ue),[W]=ve().useHighlightedOutput,{pathname:N}=(0,K.A)(),F=(0,H.A)(),[U,J]=(0,e.useState)(ie.JSON),[Q,$]=(0,e.useState)(void 0);(0,e.useEffect)(()=>()=>{h(null)},[h]),(0,e.useEffect)(()=>{De(t)?h(null):t&&P(t,U)},[t,h,P,U]);const S=!!(t!=null&&t.rule_builder),v=De(t)?"Could not run the rule simulation. Please fix the rule builder errors.":void 0,A=Object.keys((f==null?void 0:f.simulator_condition_variables)||{}).sort((q,te)=>Number(q)-Number(te)),B=()=>{switch(U){case ie.Simple:return"simple message field";case ie.KeyValue:return`message: test
source: unknown
`;case ie.JSON:return`{
message: test
source: unknown
}`;default:return"simple message field"}},_=()=>{if($(void 0),U===ie.JSON)try{JSON.parse(a)}catch{$("Invalid JSON!")}},Y=q=>{J(q),$(void 0)},X=q=>{T(q.target.value),c(q.target.value)},fe=()=>{F(o.g.PIPELINE_RULE_BUILDER.RUN_RULE_SIMULATION_CLICKED,{app_pathname:(0,D.i)(N),app_section:"pipeline-rule-simulation",app_action_value:"run-rule-simulation-button",event_details:{is_rule_builder:S}}),_(),P(t||L,U)},Ee=()=>{F(o.g.PIPELINE_RULE_BUILDER.RESET_RULE_SIMULATION_CLICKED,{app_pathname:(0,D.i)(N),app_section:"pipeline-rule-simulation",app_action_value:"reset-rule-simulation-button",event_details:{is_rule_builder:S}}),$(void 0),T(""),c(null),h(null)};return e.createElement(dn,null,e.createElement(l.ControlLabel,null,"Rule Simulation ",e.createElement("small",{className:"text-muted"},"(Optional)")),e.createElement("div",null,e.createElement(l.ButtonGroup,null,e.createElement(l.Button,{active:U===ie.JSON,onClick:()=>Y(ie.JSON)},"JSON"),e.createElement(l.Button,{active:U===ie.KeyValue,onClick:()=>Y(ie.KeyValue)},"Key Value"),e.createElement(l.Button,{active:U===ie.Simple,onClick:()=>Y(ie.Simple)},"Simple Message")),e.createElement(l.Input,{id:"message",type:"textarea",placeholder:B(),value:a,onChange:X,title:"Simple message field, Key-Value pairs or JSON",help:"Enter a normal string to simulate the message field, Key-Value pairs or a JSON to simulate the whole message.",error:v||Q,rows:4}),e.createElement(l.Button,{bsStyle:"info",bsSize:"xsmall",disabled:!a||!!v,onClick:fe},"Run rule simulation"),e.createElement(un,{bsStyle:"default",bsSize:"xsmall",onClick:Ee},"Reset"),a&&f&&e.createElement(e.Fragment,null,e.createElement(cn,null,e.createElement(an.A,{message:f})),S&&e.createElement(e.Fragment,null,A.length>0&&e.createElement(bt,{"data-testid":"conditions-output"},e.createElement("label",{htmlFor:"simulation_conditions_output"},"Conditions Output"),A.map(q=>e.createElement(St,{key:q},e.createElement(It,null,q),": ",JSON.stringify(f==null?void 0:f.simulator_condition_variables[q])))),((i=f==null?void 0:f.simulator_action_variables)==null?void 0:i.length)>0&&e.createElement(bt,{"data-testid":"actions-output"},e.createElement("label",{htmlFor:"simulation_actions_output"},"Actions Output"),(d=f==null?void 0:f.simulator_action_variables)==null?void 0:d.map(q=>{const te=Object.entries(q)[0];return e.createElement(St,{key:te[0],$highlighted:W===te[0],title:JSON.stringify(te[1])},e.createElement(It,null,"$",te[0]),": ",JSON.stringify(te[1]))}))))))};rt.propTypes={rule:s().object,onSaveMessage:s().func},rt.defaultProps={rule:void 0,onSaveMessage:()=>{}};const Dt=rt,mn=(0,r.default)(l.Col)`
margin-top: 50px;
`,Tt=(0,r.default)(l.Panel)(({theme:t})=>(0,r.css)`
background-color: ${t.colors.global.contentBackground};
border: 0;
box-shadow: none;
margin-bottom: 0;
`),Ot=(0,r.default)(l.Panel.Heading)(({theme:t})=>(0,r.css)`
display: flex;
justify-content: space-between;
background-color: ${t.colors.table.row.backgroundAlt} !important;
border: 0;
`),pn=r.default.div`
display: flex;
.radio {
margin: 0 8px;
}
`,Lt=(0,r.default)(l.Panel.Body)`
border: 0;
padding: 0;
`,En=t=>{var c,i,d;const L=((d=(i=(c=t.rule_builder)==null?void 0:c.actions)==null?void 0:i.map(P=>{var a;return Number(((a=P==null?void 0:P.outputvariable)==null?void 0:a.replace("output_",""))||0)}))==null?void 0:d.sort((P,a)=>P-a))||[];return L[L.length-1]||0},gn=()=>{const{rule:t,conditionsDict:c,actionsDict:i,createRule:d,updateRule:L,fetchValidateRule:P}=ze(),[a,T]=(0,e.useState)({description:"",title:"",rule_builder:{operator:"AND",conditions:[],actions:[]}}),[f,h]=(0,e.useState)(null),[W,N]=(0,e.useState)(null),[F]=(0,e.useState)(!0),[U]=(0,e.useState)(!0),[J,Q]=(0,e.useState)(0);(0,e.useEffect)(()=>{t&&(T(t),Q(En(t)))},[t]);const $=(0,m.A)(),{pathname:S}=(0,K.A)(),v=(0,H.A)(),A=(M,j)=>{const G=M,ee=lt(i,M.function);return(ee==null?void 0:ee.return_type)!==se.Void&&!G.outputvariable&&(G.outputvariable=`output_${j}`,Q(j)),G},B=a.rule_builder.conditions.length,_=a.rule_builder.actions.length,Y=M=>P(M).then(j=>{T({...M,rule_builder:j.rule_builder,source:j.source})}).catch(()=>T(M)),X=async M=>{const j={...a,simulator_message:M};T(j)},fe=async M=>{v(M==="AND"?o.g.PIPELINE_RULE_BUILDER.OPERATOR_AND_CLICKED:o.g.PIPELINE_RULE_BUILDER.OPERATOR_OR_CLICKED,{app_pathname:(0,D.i)(S),app_section:"pipeline-rules",app_action_value:"cancel-button"});const j={...a,rule_builder:{...a.rule_builder,operator:M}};await Y(j)},Ee=async(M,j,G)=>{let ee;const de=new(I())().toString();if(M==="condition"){const Z=a.rule_builder.conditions;Z.splice(G||Z.length,0,{...j,id:de}),ee={...a,rule_builder:{...a.rule_builder,conditions:Z}}}else{const Z=A(j,J+1),oe=a.rule_builder.actions;oe.splice(Number.isInteger(G)?G:oe.length,0,{...Z,id:de}),ee={...a,rule_builder:{...a.rule_builder,actions:oe}}}await Y(ee)},q=async(M,j,G)=>{let ee;if(j==="condition"){const de=[...a.rule_builder.conditions];de[M]=G,ee={...a,rule_builder:{...a.rule_builder,conditions:de}}}else{const de=[...a.rule_builder.actions];de[M]=A(G,J+1),ee={...a,rule_builder:{...a.rule_builder,actions:de}}}await Y(ee)},te=async(M,j)=>{let G;if(j==="condition"){const ee=[...a.rule_builder.conditions];ee.splice(M,1),G={...a,rule_builder:{...a.rule_builder,conditions:ee}}}else{const ee=[...a.rule_builder.actions];ee.splice(M,1),G={...a,rule_builder:{...a.rule_builder,actions:ee}}}await Y(G)},Ce=()=>{v(o.g.PIPELINE_RULE_BUILDER.CANCEL_CLICKED,{app_pathname:(0,D.i)(S),app_section:"pipeline-rules",app_action_value:"cancel-button"}),$.push(p.Ay.SYSTEM.PIPELINES.RULES)},Fe=async(M,j=!1)=>{if(M==null||M.preventDefault(),t)v(j?o.g.PIPELINE_RULE_BUILDER.UPDATE_RULE_AND_CLOSE_CLICKED:o.g.PIPELINE_RULE_BUILDER.UPDATE_RULE_CLICKED,{app_pathname:(0,D.i)(S),app_section:"pipeline-rules",app_action_value:j?"update-rule-and-close-button":"update-rule-button"}),await L(a),j&&Ce();else{v(o.g.PIPELINE_RULE_BUILDER.ADD_RULE_CLICKED,{app_pathname:(0,D.i)(S),app_section:"pipeline-rules",app_action_value:"add-rule-button"});const G=await d(a);G!=null&&G.id&&$.replace(`${p.Ay.SYSTEM.PIPELINES.RULE(G==null?void 0:G.id)}?rule_builder=true`)}},Te=()=>a.rule_builder.actions.map((M,j)=>{var G;return{variableName:M.outputvariable?`$${M.outputvariable}`:null,variableType:(G=lt(i,M.function))==null?void 0:G.return_type,stepOrder:j,blockId:M.id}}).filter(({variableName:M})=>M!==null);return e.createElement(Ye,null,e.createElement("form",{onSubmit:M=>Fe(M,!0)},e.createElement(l.Row,{className:"content"},e.createElement(l.Col,{xs:12},e.createElement(nn,{rule:a,onChange:T})),e.createElement(l.Col,{xs:8},e.createElement("label",{htmlFor:"rule_builder"},"Rule Builder"),e.createElement(Tt,{expanded:F},e.createElement(Ot,null,e.createElement(l.Panel.Title,{toggle:!0},"When"),e.createElement(pn,null,e.createElement(l.Radio,{checked:a.rule_builder.operator==="AND",onChange:()=>fe("AND")},"and"),e.createElement(l.Radio,{checked:a.rule_builder.operator==="OR",onChange:()=>fe("OR")},"or"))),e.createElement(l.Panel.Collapse,null,e.createElement(Lt,null,a.rule_builder.conditions.map((M,j)=>e.createElement(Me,{key:j,blockDict:c||[],block:M,order:j,type:"condition",addBlock:Ee,updateBlock:q,deleteBlock:()=>h({orderIndex:j,type:"condition"})})),e.createElement(Me,{blockDict:c||[],order:B,type:"condition",addBlock:Ee,updateBlock:q,deleteBlock:()=>h({orderIndex:B,type:"condition"})})))),e.createElement("br",null),e.createElement(Tt,{expanded:U},e.createElement(Ot,null,e.createElement(l.Panel.Title,{toggle:!0},"Then")),e.createElement(l.Panel.Collapse,null,e.createElement(Lt,null,a.rule_builder.actions.map((M,j)=>e.createElement(Me,{key:j,blockDict:i||[],block:M,order:j,type:"action",outputVariableList:Te(),addBlock:Ee,updateBlock:q,deleteBlock:()=>h({orderIndex:j,type:"action"})})),e.createElement(Me,{blockDict:i||[],order:_,type:"action",outputVariableList:Te(),addBlock:Ee,updateBlock:q,deleteBlock:()=>h({orderIndex:_,type:"action"})})))),e.createElement(Et,{objectWithErrors:a.rule_builder})),e.createElement(l.Col,{xs:4},e.createElement(Dt,{rule:a,onSaveMessage:X})),e.createElement(mn,{xs:12},e.createElement(R.hP,{disabledSubmit:De(a),submitButtonText:t?"Update rule & close":"Create rule",centerCol:t&&e.createElement(e.Fragment,null,e.createElement(l.Button,{type:"button",bsStyle:"info",onClick:Fe,disabled:De(a)},"Update rule"),e.createElement(l.Button,{bsStyle:"info",title:"Convert Rule Builder to Source Code",disabled:De(a),onClick:()=>{v(o.g.PIPELINE_RULE_BUILDER.CONVERT_TO_SOURCE_CODE_CLICKED,{app_pathname:(0,D.i)(S),app_section:"pipeline-rules",app_action_value:"convert-rule-builder-to-source-code-button"}),N(a)}},"Convert to Source Code")),onCancel:Ce}))),f&&e.createElement(R.TM,{title:`Delete ${f.type}`,show:!0,onConfirm:()=>{te(f.orderIndex,f.type),h(null)},onCancel:()=>h(null)},e.createElement(e.Fragment,null,"Are you sure you want to delete ",e.createElement("strong",null,f.type," N\xB0 ",f.orderIndex+1),"?")),W&&e.createElement(rn,{show:!0,onNavigateAway:L,onHide:()=>N(null),rule:W})))},fn=r.default.div`
& .source-code-editor div {
border-color: ${({theme:t})=>t.colors.input.border};
border-radius: 0;
& .ace_editor {
border-radius: 0;
}
}
& .ace_tooltip.ace-graylog {
background-color: ${({theme:t})=>t.colors.global.background};
padding: 4px;
padding-left: 0;
line-height: 1.5;
}
`,it=({create:t})=>{const{description:c,handleDescription:i,handleSavePipelineRule:d,ruleSourceRef:L,onAceLoaded:P,onChangeSource:a,ruleSource:T}=(0,e.useContext)(Ue),[f,h]=(0,e.useState)(!1),[W,N]=(0,e.useState)(""),F=(0,m.A)(),U=A=>{var B;if((B=A==null?void 0:A.responseMessage)!=null&&B.includes("duplicate key error")){const _=A.responseMessage.match(/title: "(.*)"/i)[1];N(`Rule title "${_}" already exists!`)}},J=()=>{N(""),h(!1),F.push(p.Ay.SYSTEM.PIPELINES.RULES)},Q=A=>{h(!1),A.preventDefault(),d(J,U)},$=()=>{d(A=>{N(""),h(!1),F.push(p.Ay.SYSTEM.PIPELINES.RULE(A.id))},U)},S=A=>{h(!0),i(A.target.value)},v=A=>{N(""),h(!0),a(A)};return e.createElement("form",{onSubmit:Q},e.createElement("fieldset",null,e.createElement(l.FormGroup,{id:"ruleTitleInformation"},e.createElement(l.ControlLabel,null,"Title"),e.createElement(l.FormControl.Static,null,"You can set the rule title in the rule source. See the quick reference for more information.")),f&&e.createElement(R.Oj,{question:"Do you really want to abandon this page and lose your changes? This action cannot be undone."}),e.createElement(l.Input,{type:"textarea",id:"description",label:"Description",value:c,onChange:S,autoFocus:!0,rows:1,help:"Rule description (optional)."}),e.createElement(yt,{create:t}),e.createElement(l.Input,{id:"rule-source-editor",label:"Rule source",help:"Rule source, see quick reference for more information.",error:W},e.createElement(fn,null,e.createElement(R.Qb,{id:`source${t?"-create":"-edit"}`,mode:"pipeline",onLoad:P,onChange:v,value:T,innerRef:L}))),e.createElement(Dt,null)),e.createElement(l.Row,null,e.createElement(l.Col,{md:12},e.createElement(R.hP,{submitButtonText:t?"Create rule":"Update rule & close",centerCol:!t&&e.createElement(l.Button,{type:"button",bsStyle:"info",onClick:$},"Update rule"),onCancel:J}))))};it.propTypes={create:s().bool},it.defaultProps={create:!1};const hn=it;var vn=n("QdZ7Yq43"),_n=n("7dh0vSOR"),Rn=n("XyJ0Mvpg");const Cn=`rule "function howto"
when
has_field("transaction_date")
then
// the following date format assumes there's no time zone in the string
let new_date = parse_date(to_string($message.transaction_date), "yyyy-MM-dd HH:mm:ss");
set_field("transaction_year", new_date.year);
end`,at=({functionDescriptors:t,paginationQueryParameter:c,hideExampleTab:i})=>{const[d,L]=(0,e.useState)({}),[P,a]=(0,e.useState)(c.page),[T,f]=(0,e.useState)(10),[h,W]=(0,e.useState)(void 0);(0,e.useEffect)(()=>{pe.z.loadFunctions()},[]);const N=S=>{const v=vn.A.clone(d);v[S]=!v[S],L(v)},F=(S,v)=>{a(S),f(v)},U=S=>{if(c.resetPage(),!t)return;if(S.length<=0){W(t),a(1);return}const v=t.filter(A=>{const B=RegExp(S);return B.test(qe(A))||B.test(A.description)});W(v),a(1)},J=()=>{c.resetPage(),W(t),a(1)};if(!t)return e.createElement(R.y$,null);const Q=h||t,$=Q.slice((P-1)*T,P*T);return e.createElement(l.Panel,{header:"Rules quick reference"},e.createElement(l.Row,{className:"row-sm rule-ref-descriptions"},e.createElement(l.Col,{md:12},e.createElement("p",{className:re.marginQuickReferenceText},"Read the ",e.createElement(_n.A,{page:w.A.PAGES.PIPELINE_RULES,text:"full documentation"})," ","to gain a better understanding of how Graylog pipeline rules work."))),e.createElement(l.Row,{className:"row-sm"},i?e.createElement(l.Col,{sm:12},e.createElement(R.B9,{onSearch:U,topMargin:0,onReset:J}),e.createElement("div",{className:`table-responsive ${re.marginTab} ref-rule`},e.createElement(R.OW,{totalItems:Q.length,pageSize:T,onChange:F,showPageSizeSelect:!1},e.createElement(tt,{entries:$,expanded:d,onFunctionClick:N})))):e.createElement(l.Col,{md:12},e.createElement(l.Tabs,{id:"functionsHelper",defaultActiveKey:1,animation:!1},e.createElement(l.Tab,{eventKey:1,title:"Functions"},e.createElement(l.Row,{className:"rule-ref-descriptions"},e.createElement(l.Col,{sm:12},e.createElement("p",{className:re.marginTab},"This is a list of all available functions in pipeline rules. Click on a row to see more information about the function parameters."))),e.createElement(l.Row,null,e.createElement(l.Col,{sm:12},e.createElement(R.B9,{onSearch:U,label:"Filter rules",topMargin:0,onReset:J}),e.createElement("div",{className:`table-responsive ${re.marginTab} ref-rule`},e.createElement(R.OW,{totalItems:Q.length,pageSize:T,onChange:F,showPageSizeSelect:!1},e.createElement(tt,{entries:$,expanded:d,onFunctionClick:N})))))),e.createElement(l.Tab,{eventKey:2,title:"Example"},e.createElement("p",{className:re.marginTab},"Do you want to see how a pipeline rule looks like? Take a look at this example:"),e.createElement("pre",{className:`${re.marginTab} ${re.exampleFunction}`},Cn))))))};at.propTypes={functionDescriptors:s().array,paginationQueryParameter:s().object.isRequired,hideExampleTab:s().bool},at.defaultProps={functionDescriptors:void 0,hideExampleTab:!1};const An=(0,u.A)((0,Rn.A)(at),{ruleStore:pe.J},({ruleStore:t})=>({...t}));var Pn=n("ZspbpBGx");const ut=({create:t,title:c,isRuleBuilder:i})=>{const[d,L]=(0,e.useState)(!1),P=(0,m.A)(),{pathname:a}=(0,K.A)(),T=(0,H.A)();let f;return t?f="Create pipeline rule":f=e.createElement("span",null,"Pipeline rule ",e.createElement("em",null,c)),e.createElement("div",null,e.createElement(Pn.A,null),e.createElement(R.zY,{title:f,actions:i&&t?e.createElement(l.Button,{bsStyle:"success",bsSize:"small",onClick:()=>{T(o.g.PIPELINE_RULE_BUILDER.USE_SOURCE_CODE_EDITOR_CLICKED,{app_pathname:(0,D.i)(a),app_section:"pipeline-rules",app_action_value:"source-code-editor-button"}),L(!0)}},"Use Source Code Editor"):void 0,documentationLink:{title:"Pipeline rules documentation",path:w.A.PAGES.PIPELINE_RULES}},e.createElement("span",null,"Rules are a way of applying changes to messages in Graylog. A rule consists of a condition and a list"," ","of actions."," ","Graylog evaluates the condition against a message and executes the actions if the condition is satisfied.")),i?e.createElement(gn,null):e.createElement(l.Row,{className:"content"},e.createElement(l.Col,{md:6},e.createElement(hn,{create:t})),e.createElement(l.Col,{md:6},e.createElement(An,null))),d&&e.createElement(l.BootstrapModalConfirm,{showModal:!0,title:"Switch to Source Code Editor",onConfirm:()=>{T(o.g.PIPELINE_RULE_BUILDER.SWITCH_TO_SOURCE_CODE_EDITOR_CONFIRM_CLICKED,{app_pathname:(0,D.i)(a),app_section:"pipeline-rules",app_action_value:"confirm-button"}),P.push(p.Ay.SYSTEM.PIPELINES.RULE("new")),L(!1)},onCancel:()=>{T(o.g.PIPELINE_RULE_BUILDER.SWITCH_TO_SOURCE_CODE_EDITOR_CANCEL_CLICKED,{app_pathname:(0,D.i)(a),app_section:"pipeline-rules",app_action_value:"cancel-button"}),L(!1)}},e.createElement("div",null,"You are about to leave this page and go to the Source Code Editor."),e.createElement("div",null,"Make sure you have no unsaved changes.")))};ut.propTypes={title:s().string,create:s().bool,isRuleBuilder:s().bool},ut.defaultProps={title:"",create:!1,isRuleBuilder:!1};const yn=ut;var In=n("brbjQOmY"),Bt=n("RU4i+ZYB");function bn(t,c){var i;return(i=t==null?void 0:t.rules)==null?void 0:i.filter(d=>d.id===c)[0]}function Sn(t=[],c=""){return t.filter(i=>i.stages.some(d=>d.rules.indexOf(c)!==-1))}const Dn=()=>{const{ruleId:t}=(0,O.useParams)(),c=(0,u.P)(pe.J),i=(0,u.P)(Bt.Z,({pipelines:J})=>J),[d,L]=(0,e.useState)(!0),[P,a]=(0,e.useState)(void 0),T=(0,m.A)(),{rule_builder:f}=(0,In.A)(),h=f==="true",W=t==="new",N=(P==null?void 0:P.title)||"",F=W?"New pipeline rule":`Pipeline rule ${N}`,U=W?[]:Sn(i,N);return(0,e.useEffect)(()=>{a(bn(c,t))},[t,c]),(0,e.useEffect)(()=>{W?L(!1):(Bt.l.list(),pe.z.get(t).then(()=>{},J=>{J.status===404&&T.push(p.Ay.SYSTEM.PIPELINES.RULES)}),L(!(P&&i)))},[P,T,W,t,i]),d?e.createElement(R.y$,{text:"Loading Rule Details..."}):e.createElement(R.Qc,{title:F},e.createElement(ot,{usedInPipelines:U,rule:P},e.createElement(yn,{create:W,isRuleBuilder:h,title:N})))}},"RU4i+ZYB":(ae,k,n)=>{n.d(k,{Z:()=>p,l:()=>K});var e=n("JnTtTRmZ"),O=n.n(e),u=n("VPaD/Np4"),R=n.n(u),y=n("jAGDuYSC"),s=n("MdYBRjRJ"),l=n("U1Iufsob"),w=n("eFxcQyPT"),D=n("gyRmhZSW"),H=n("IA3Ku5lS");const K=(0,H.rN)("core.Pipelines",()=>O().createActions({delete:{asyncResult:!0},list:{asyncResult:!0},listPaginated:{asyncResult:!0},get:{asyncResult:!0},save:{asyncResult:!0},update:{asyncResult:!0},parse:{asyncResult:!0}})),m=o=>{y.A.error(`Fetching pipelines failed with status: ${o.message}`,"Could not retrieve processing pipelines")},p=(0,H.Bv)("core.Pipelines",()=>O().createStore({listenables:[K],pipelines:void 0,getInitialState(){return{pipelines:this.pipelines}},_updatePipelinesState(o){this.pipelines?this.pipelines.some(C=>C.id===o.id)?this.pipelines=this.pipelines.map(C=>C.id===o.id?o:C):this.pipelines.push(o):this.pipelines=[o],this.trigger({pipelines:this.pipelines})},list(){const o=(0,s.H3)(l.A.PipelinesController.list().url);return(0,w.Ay)("GET",o).then(r=>{this.pipelines=r,this.trigger({pipelines:r})},m)},listPaginated({page:o,perPage:r,query:C}){const I=(0,D.A)(l.A.PipelinesController.paginatedList().url,o,r,C),V=(0,w.Ay)("GET",(0,s.H3)(I)).then(z=>({list:R().List(z.pipelines),pagination:{page:z.page,perPage:z.per_page,query:z.query,count:z.count,total:z.total}}));return V.catch(m),K.listPaginated.promise(V),V},get(o){const r=V=>{y.A.error(`Fetching pipeline failed with status: ${V.message}`,`Could not retrieve processing pipeline "${o}"`)},C=(0,s.H3)(l.A.PipelinesController.get(o).url);(0,w.Ay)("GET",C).then(this._updatePipelinesState,r)},save(o){const r=z=>{y.A.error(`Saving pipeline failed with status: ${z.message}`,"Could not save processing pipeline")},C=(0,s.H3)(l.A.PipelinesController.create().url),I={title:o.title,description:o.description,source:o.source},V=(0,w.Ay)("POST",C,I);V.then(z=>{this._updatePipelinesState(z),y.A.success(`Pipeline "${I.title}" created successfully`)},r),K.save.promise(V)},update(o){const r=z=>{y.A.error(`Updating pipeline failed with status: ${z.message}`,"Could not update processing pipeline")},C=(0,s.H3)(l.A.PipelinesController.update(o.id).url),I={id:o.id,title:o.title,description:o.description,source:o.source},V=(0,w.Ay)("PUT",C,I);V.then(z=>{this._updatePipelinesState(z),y.A.success(`Pipeline "${I.title}" updated successfully`)},r),K.update.promise(V)},delete(o){const r=V=>{y.A.error(`Deleting pipeline failed with status: ${V.message}`,`Could not delete processing pipeline "${o}"`)},C=(0,s.H3)(l.A.PipelinesController.delete(o).url),I=(0,w.Ay)("DELETE",C).then(()=>{const V=this.pipelines||[];this.pipelines=V.filter(z=>z.id!==o),this.trigger({pipelines:this.pipelines}),y.A.success(`Pipeline "${o}" deleted successfully`)},r);return K.delete.promise(I),I},parse(o,r){const C=(0,s.H3)(l.A.PipelinesController.parse().url),I={title:o.title,description:o.description,source:o.source};return(0,w.Ay)("POST",C,I).then(()=>{r([])},V=>{V.status===400&&r(V.additional.body)})}}))},sRNsEgBM:(ae,k,n)=>{n.d(k,{J:()=>K,z:()=>H});var e=n("JnTtTRmZ"),O=n.n(e),u=n("4E3oowBb"),R=n("jAGDuYSC"),y=n("MdYBRjRJ"),s=n("gyRmhZSW"),l=n("U1Iufsob"),w=n("eFxcQyPT"),D=n("IA3Ku5lS");const H=(0,D.rN)("core.Rules",()=>O().createActions({delete:{asyncResult:!0},list:{asyncResult:!0},get:{asyncResult:!0},save:{asyncResult:!0},update:{asyncResult:!0},parse:{asyncResult:!0},simulate:{asyncResult:!0},multiple:{asyncResult:!0},loadFunctions:{asyncResult:!0},loadMetricsConfig:{asyncResult:!0},updateMetricsConfig:{asyncResult:!0},listPaginated:{asyncResult:!0}})),K=(0,D.Bv)("core.Rules",()=>O().createStore({listenables:[H],rules:void 0,rulesContext:void 0,functionDescriptors:void 0,metricsConfig:void 0,getInitialState(){return{rules:this.rules,rulesContext:this.rulesContext,functionDescriptors:this.functionDescriptors,metricsConfig:this.metricsConfig}},_updateRulesState(m){this.rules?this.rules.some(o=>o.id===m.id)?this.rules=this.rules.map(o=>o.id===m.id?m:o):this.rules.push(m):this.rules=[m],this.trigger({rules:this.rules,functionDescriptors:this.functionDescriptors})},_updateFunctionDescriptors(m){m&&(this.functionDescriptors=m.sort((p,o)=>(0,u.j)(p.name,o.name))),this.trigger({rules:this.rules,functionDescriptors:this.functionDescriptors})},list(){const m=o=>{R.A.error(`Fetching rules failed with status: ${o.message}`,"Could not retrieve processing rules")},p=(0,y.H3)(l.A.RulesController.list().url);return(0,w.Ay)("GET",p).then(o=>{this.rules=o,this.trigger({rules:o,functionDescriptors:this.functionDescriptors})},m)},listPaginated({page:m,perPage:p,query:o}){const r=(0,s.A)(l.A.RulesController.paginatedList().url,m,p,o),C=(0,w.Ay)("GET",(0,y.H3)(r)).then(I=>({list:I.rules,context:I.context,pagination:{count:I.count,total:I.total,page:I.page,perPage:I.per_page,query:I.query}}));return C.catch(I=>{(!I.additional||I.additional.status!==404)&&R.A.error(`Loading rules list failed with status: ${I}`,"Could not load rules.")}),H.listPaginated.promise(C),C},get(m){const p=C=>{R.A.error(`Fetching rule "${m}" failed with status: ${C.message}`,`Could not retrieve processing rule "${m}"`)},o=(0,y.H3)(l.A.RulesController.get(m).url),r=(0,w.Ay)("GET",o);return r.then(this._updateRulesState,p),H.get.promise(r),r},save(m){const p=I=>{R.A.error(`Saving rule "${m.title}" failed with status: ${I.message}`,`Could not save processing rule "${m.title}"`)},o=(0,y.H3)(l.A.RulesController.create().url),r={title:m.title,description:m.description,source:m.source,simulator_message:m.simulator_message},C=(0,w.Ay)("POST",o,r);return C.then(I=>(this._updateRulesState(I),R.A.success(`Rule "${I.title}" created successfully`),I),p),H.save.promise(C),C},update(m){const p=I=>{R.A.error(`Updating rule "${m.title}" failed with status: ${I.message}`,`Could not update processing rule "${m.title}"`)},o=(0,y.H3)(l.A.RulesController.update(m.id).url),r={id:m.id,title:m.title,description:m.description,source:m.source,simulator_message:m.simulator_message},C=(0,w.Ay)("PUT",o,r);return C.then(I=>(this._updateRulesState(I),R.A.success(`Rule "${I.title}" updated successfully`),I),p),H.update.promise(C),C},delete(m){const p=C=>{R.A.error(`Deleting rule "${m.title}" failed with status: ${C.message}`,`Could not delete processing rule "${m.title}"`)},o=(0,y.H3)(l.A.RulesController.delete(m.id).url),r=(0,w.Ay)("DELETE",o).then(()=>{var C;this.rules=(C=this.rules)==null?void 0:C.filter(I=>I.id!==m.id),this.trigger({rules:this.rules,functionDescriptors:this.functionDescriptors}),R.A.success(`Rule "${m.title}" was deleted successfully`)},p);return H.delete.promise(r),r},parse(m,p){const o=(0,y.H3)(l.A.RulesController.parse().url),r={title:m.title,description:m.description,source:m.source};return(0,w.Ay)("POST",o,r).then(C=>(p([]),C),C=>{C.status===400&&p(C.additional.body)})},simulate(m,p,o){const r=(0,y.H3)(p!=null&&p.rule_builder?l.A.RuleBuilderController.simulate().url:l.A.RulesController.simulate().url),C={message:m,rule_source:void 0,rule_builder_dto:void 0};if(p!=null&&p.rule_builder){const{source:I,...V}=p;C.rule_builder_dto={title:V.title,description:V.description,rule_builder:V.rule_builder}}else C.rule_source={title:p.title,description:p.description,source:p.source};return(0,w.Ay)("POST",r,C).then(o,()=>{})},multiple(m,p){const o=(0,y.H3)(l.A.RulesController.multiple().url),r=(0,w.Ay)("POST",o,{rules:m});return r.then(p),r},loadFunctions(){if(this.functionDescriptors)return;const m=(0,y.H3)(l.A.RulesController.functions().url);return(0,w.Ay)("GET",m).then(this._updateFunctionDescriptors)},loadMetricsConfig(){const m=(0,y.H3)(l.A.RulesController.metricsConfig().url),p=(0,w.Ay)("GET",m);p.then(o=>{this.metricsConfig=o,this.trigger({rules:this.rules,functionDescriptors:this.functionDescriptors,metricsConfig:this.metricsConfig})},o=>{R.A.error(`Couldn't load rule metrics config: ${o.message}`,"Couldn't load rule metrics config")}),H.loadMetricsConfig.promise(p)},updateMetricsConfig(m){const p=(0,y.H3)(l.A.RulesController.metricsConfig().url),o=(0,w.Ay)("PUT",p,m);o.then(r=>{this.metricsConfig=r,this.trigger({rules:this.rules,functionDescriptors:this.functionDescriptors,metricsConfig:this.metricsConfig}),R.A.success("Successfully updated rule metrics config")},r=>{R.A.error(`Couldn't update rule metrics config: ${r.message}`,"Couldn't update rule metrics config")}),H.updateMetricsConfig.promise(o)}}))}}]);})();
//# sourceMappingURL=bb8c8232-6580.a3571135bc30cbf98b5f.js.map
© 2015 - 2024 Weber Informatics LLC | Privacy Policy