/*! Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one or more contributor license agreements. * Licensed under the Elastic License 2.0; you may not use this file except in compliance with the Elastic License 2.0. */ (window.ml_bundle_jsonpfunction=window.ml_bundle_jsonpfunction||[]).push([[1],{136:function(e,t,r){"use strict";r.d(t,"c",(function(){return x})),r.d(t,"a",(function(){return b})),r.d(t,"b",(function(){return g}));var a=r(7),i=r(39),n=r.n(i),l=r(46),o=r.n(l);const{duration:s}=n.a;var c=r(41),u=r(13),d=r(69),p=r(43);const m=o.a.unitsDesc,f=m.indexOf("w"),h=function(){const e=[[s(500,"ms"),s(100,"ms")],[s(5,"second"),s(1,"second")],[s(10,"second"),s(5,"second")],[s(15,"second"),s(10,"second")],[s(30,"second"),s(15,"second")],[s(1,"minute"),s(30,"second")],[s(5,"minute"),s(1,"minute")],[s(10,"minute"),s(5,"minute")],[s(15,"minute"),s(10,"minute")],[s(30,"minute"),s(10,"minute")],[s(1,"hour"),s(30,"minute")],[s(2,"hour"),s(1,"hour")],[s(4,"hour"),s(2,"hour")],[s(6,"hour"),s(4,"hour")],[s(8,"hour"),s(6,"hour")],[s(12,"hour"),s(8,"hour")],[s(24,"hour"),s(12,"hour")],[s(2,"d"),s(1,"d")],[s(4,"d"),s(2,"d")],[s(1,"week"),s(4,"d")],[s(1,"month"),s(1,"week")],[s(1,"year"),s(1,"month")],[1/0,s(1,"year")]].slice(0).reverse();function t(e,t,r){return function(a,i){const l=function(a,i){const l=i/a;let o;for(let a=0;ar){if(e===1/0)return t;const a=e.asMilliseconds(),i=t.asMilliseconds();return Math.abs(a-r)<=Math.abs(i)?e:t}}),!0),lessThan:t(e,(function(e,t,r){if(t=1&&Math.floor(a)===a){if(t<=f)continue;return{value:a,unit:r,expression:a+r}}}const t=e.as("ms");return{value:t,unit:"ms",expression:t+"ms"}}(e);e.esValue=r.value,e.esUnit=r.unit,e.expression=r.expression,e.overflow=t>e&&n.a.duration(e-t);const a=n.a.normalizeUnits(r.unit);return 1===r.value?e.description=a:e.description=`${r.value} ${a}s`,e}function y(e){return e&&"isValid"in e&&e.isValid()}function g(e,t,r=!1){const a=t.asMilliseconds(),i=Math.floor(e.min.valueOf()/a)*a;let l=Math.ceil(e.max.valueOf()/a)*a;return!1===r&&(l-=1),{min:n()(i),max:n()(l)}}b.prototype.setBarTarget=function(e){this.barTarget=e},b.prototype.setMaxBars=function(e){this.maxBars=e},b.prototype.setBounds=function(e){if(!e)return this.clearBounds();let t;t=Object(a.isPlainObject)(e)?[e.min,e.max]:Array.isArray(e)?e:[];const r=Object(a.sortBy)(t.map(Object(a.ary)(n.a,1)),Number);if(2!==r.length||!r.every(y))throw this.clearBounds(),new Error("invalid bounds set: "+e);if(this._lb=r.shift(),this._ub=r.pop(),this.getDuration().asSeconds()<0)throw new TypeError("Intervals must be positive")},b.prototype.clearBounds=function(){this._lb=this._ub=null},b.prototype.hasBounds=function(){return y(this._ub)&&y(this._lb)},b.prototype.getBounds=function(){if(this.hasBounds())return{min:this._lb,max:this._ub}},b.prototype.getDuration=function(){if(this.hasBounds())return n.a.duration(this._ub-this._lb,"ms")},b.prototype.setInterval=function(e){this.originalInterval=e;let t=e;if(t&&"auto"!==t){if(Object(a.isString)(t)&&(e=t,t=Object(c.a)(t),0==+t&&(t=null)),!n.a.isDuration(t))throw new TypeError('"'+e+'" is not a valid interval.');this._i=t}else this._i="auto"},b.prototype.getInterval=function(){const e=this,t=e.getDuration();return v(function(r){if(!e.hasBounds())return r;const i=e.maxBars;let n;return t/r>i?(n=h.lessThan(i,t),+n==+r?r:(v(r,t),Object(a.assign)(n,{preScaled:r,scale:r/n,scaled:!0}))):r}(function(){const r=e._i;return n.a.isDuration(r)?r:h.near(e.barTarget,t)}()),t)},b.prototype.getIntervalToNearestMultiple=function(e){const t=this.getInterval(),r=t.asSeconds(),a=r%e;if(0===a)return t;let i=a>e/2?r+e-a:r-a;i=0===i?e:i;const l=n.a.duration(i,"seconds");v(l,this.getDuration());const o=t.preScaled;return void 0!==o&&o=0;r--){const a=t[r];if(!a[0]||e>=n.a.duration(a[0]))return a[1]}return this._timeBucketsConfig.dateFormat},b.prototype.getScaledDateFormatter=function(){return new(Object(u.e)().getType(p.FIELD_FORMAT_IDS.DATE))({pattern:this.getScaledDateFormat()},this._timeBucketsConfig)}},153:function(e,t,r){"use strict";r.d(t,"c",(function(){return x})),r.d(t,"d",(function(){return v})),r.d(t,"a",(function(){return y})),r.d(t,"b",(function(){return g}));var a=r(2),i=r(28),n=r(6),l=r(15),o=r(40),s=r(98),c=r(4);const u=n.i18n.translate("xpack.ml.controls.selectSeverity.warningLabel",{defaultMessage:"warning"}),d=n.i18n.translate("xpack.ml.controls.selectSeverity.minorLabel",{defaultMessage:"minor"}),p=n.i18n.translate("xpack.ml.controls.selectSeverity.majorLabel",{defaultMessage:"major"}),m=n.i18n.translate("xpack.ml.controls.selectSeverity.criticalLabel",{defaultMessage:"critical"}),f={[u]:s.g.LOW,[d]:s.g.MINOR,[p]:s.g.MAJOR,[m]:s.g.CRITICAL},h=[{val:s.g.LOW,display:u,color:Object(s.A)(s.g.LOW)},{val:s.g.MINOR,display:d,color:Object(s.A)(s.g.MINOR)},{val:s.g.MAJOR,display:p,color:Object(s.A)(s.g.MAJOR)},{val:s.g.CRITICAL,display:m,color:Object(s.A)(s.g.CRITICAL)}];function x(e){let t=h.find((t=>t.val===e));return void 0===t&&(t=h[0]),t}const b=h[0],v=()=>Object(o.c)("mlSelectSeverity",b),y=({classNames:e}={classNames:""})=>{const[t,r]=v();return Object(c.jsx)(g,{severity:t,onChange:r})},g=({classNames:e="",severity:t,onChange:r,compressed:o})=>{const s=Object(a.useMemo)((()=>h.map((({color:e,display:t,val:r})=>({value:t,inputDisplay:Object(c.jsx)(a.Fragment,null,Object(c.jsx)(i.EuiHealth,{color:e,style:{lineHeight:"inherit"}},t)),dropdownDisplay:Object(c.jsx)(a.Fragment,null,Object(c.jsx)(i.EuiHealth,{color:e,style:{lineHeight:"inherit"}},t),Object(c.jsx)(i.EuiSpacer,{size:"xs"}),Object(c.jsx)(i.EuiText,{size:"xs",color:"subdued"},Object(c.jsx)("p",null,Object(c.jsx)(l.FormattedMessage,{id:"xpack.ml.controls.selectSeverity.scoreDetailsDescription",defaultMessage:"score {value} and above",values:{value:r}}))))})))),[]);return Object(c.jsx)(i.EuiSuperSelect,{prepend:n.i18n.translate("xpack.ml.explorer.severityThresholdLabel",{defaultMessage:"Severity"}),"data-test-subj":"mlAnomalySeverityThresholdControls",className:e,hasDividers:!0,options:s,valueOfSelected:t.display,onChange:e=>{r(x(f[e]))},compressed:!0})}},166:function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var a=r(5),i=r.n(a),n=r(106),l=r(129),o=r(112);const s=new class FieldFormatService{constructor(){i()(this,"indexPatternIdsByJob",{}),i()(this,"formatsByJob",{})}async populateFormats(e){(await Promise.all(e.map((async e=>{const t=o.a.getJob(e);return{jobId:e,dataViewId:await Object(l.c)(t.datafeed_config.indices.join(","))}})))).forEach((({jobId:e,dataViewId:t})=>{null!==t&&(this.indexPatternIdsByJob[e]=t)}));const t=e.map((e=>Promise.all([this.getFormatsForJob(e)])));try{return(await Promise.all(t)).forEach(((t,r)=>{this.formatsByJob[e[r]]=t[0]})),this.formatsByJob}catch(e){return console.log("Error populating field formats:",e),{formats:{},error:e}}}getFieldFormat(e,t){if(this.formatsByJob.hasOwnProperty(e))return this.formatsByJob[e][t]}getFormatsForJob(e){return new Promise(((t,r)=>{const a=o.a.getJob(e).analysis_config.detectors||[],i=[],s=this.indexPatternIdsByJob[e];void 0!==s?Object(l.b)(s).then((e=>{const r=e.fields;a.forEach((t=>{const a=Object(n.s)(t.function);if(void 0!==t.field_name&&"cardinality"!==a){const a=r.getByName(t.field_name);void 0!==a&&(i[t.detector_index]=e.getFormatterForField(a))}})),t(i)})).catch((e=>{r(e)})):t(i)}))}}},179:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));const a=e=>t=>{t.currentTarget.blur(),e()}},185:function(e,t,r){"use strict";r.d(t,"b",(function(){return d})),r.d(t,"d",(function(){return p})),r.d(t,"a",(function(){return m})),r.d(t,"c",(function(){return f})),r.d(t,"e",(function(){return h})),r.d(t,"f",(function(){return x})),r.d(t,"g",(function(){return b})),r.d(t,"h",(function(){return g})),r.d(t,"i",(function(){return j})),r.d(t,"o",(function(){return O})),r.d(t,"p",(function(){return k})),r.d(t,"j",(function(){return I})),r.d(t,"m",(function(){return T})),r.d(t,"k",(function(){return S})),r.d(t,"l",(function(){return w})),r.d(t,"n",(function(){return M}));var a=r(131),i=r.n(a),n=r(98),l=r(116),o=r(39),s=r.n(o),c=r(117),u=r(1);const d=7,p=5,m=10,f=100;function h(e=[],t){let r=1/0,a=-1/0;e.forEach((e=>{let t=e.value;const i=Array.isArray(e.actual)?e.actual[0]:e.actual,n=Array.isArray(e.typical)?e.typical[0]:e.typical;null===t&&void 0!==e.anomalyScore&&void 0!==e.actual&&(t=i),void 0!==e.anomalyScore&&void 0!==i?(r=Math.min(r,t,i,n),a=Math.max(a,t,i,n)):(r=Math.min(r,t),a=Math.max(a,t))}));const i={max:a,min:r};if(i.max===i.min){const e=.05*i.max;i.max+=e,i.min-=e}return"count"===t&&i.min<0&&(i.min=0),i}function x(e,t,r,a=1.5){const i=e.reduce(((t,r,a)=>{const i=e[a-1],n=e[a+1];return(void 0===i||i&&null===i.value)&&null!==r.value&&(void 0===n||n&&null===n.value)&&t.push(r),t}),[]),n=(t.select(".values-dots").empty()?t.append("g").classed("values-dots",!0):t.select(".values-dots")).selectAll("circle").data(i);n.enter().append("circle").attr("r",a),n.attr("cx",r.x()).attr("cy",r.y()),n.exit().remove()}function b(e,t){if(void 0===e||void 0===e.selectAll)throw new Error("Missing selection parameter");e.selectAll(".tick text").text((function(){const e=i.a.select(this.parentNode),r=e.node().getBBox().width,a=i.a.transform(e.attr("transform")).translate[0];if(a-r/2>=0&&a+r/2<=t)return this.textContent;e.remove()}))}const v=!0,y=!0;function g(e){let t=c.b.SINGLE_METRIC;if("lat_long"===e.functionDescription||void 0!==e.mapData)return c.b.GEO_MAP;if(v&&"rare"===e.functionDescription&&!1===e.entityFields.some((e=>"over"===e.fieldType))?t=c.b.EVENT_DISTRIBUTION:y&&"rare"!==e.functionDescription&&e.entityFields.some((e=>"over"===e.fieldType))&&null!==e.metricFunction&&(t=c.b.POPULATION_DISTRIBUTION),(t===c.b.EVENT_DISTRIBUTION||t===c.b.POPULATION_DISTRIBUTION)&&void 0!==e.datafeedConfig&&void 0!==e.datafeedConfig.script_fields){const r=Object.keys(e.datafeedConfig.script_fields),a=e.entityFields.map((e=>e.fieldName));e.metricFieldName&&a.push(e.metricFieldName),!0==(void 0!==a.find((e=>r.includes(e))))&&(t=c.b.SINGLE_METRIC)}return t}async function j(e,t,r){const a=s()(t.plotEarliest).toISOString(),i=s()(t.plotLatest).toISOString();let n;return t.entityFields.length>0&&(n={},t.entityFields.forEach((e=>{n[e.fieldName]=e.fieldValue}))),await e.getUrl({page:u.b.SINGLE_METRIC_VIEWER,pageState:{jobIds:[t.jobId],refreshInterval:{display:"Off",pause:!0,value:0},timeRange:r,zoom:{from:a,to:i},detectorIndex:t.detectorIndex,entities:n,query:{query_string:{analyze_wildcard:!0,query:"*"}}}},{absolute:!0})}function O(e){return!0===e.isMultiBucketAnomaly}function k(e){return!0===e.isMultiBucketAnomaly}function I(e){const t=void 0!==e.multiBucketImpact?Object(n.w)(e.multiBucketImpact):0;return new Array(5).fill("■ ",0,t).fill("□ ",t).join("")}function T(e,t){return e/(1.75*Object(l.a)(s()().format(t),!1))}const E={NEXT:"next",PREVIOUS:"previous"};function S(e,t,r,a){if(t<=0)throw Error("tickInterval must be larger than 0.");const i=[e];function n(e,l){let o,s;switch(l){case E.PREVIOUS:o=e-t,s=o>=r;break;case E.NEXT:o=e+t,s=o<=a}s&&(i.push(o),n(o,l))}return n(e,E.PREVIOUS),n(e,E.NEXT),i.sort(),i}const _=60;function w({detectorLabel:e,entityFields:t}){return e.length+t.map((e=>`${e.fieldName} ${e.fieldValue}`)).join(" ").length>_}function M(e,t,r,a){function n(e){return function(t){switch(e){case E.PREVIOUS:return t-r;case E.NEXT:return t+r}}}function l(t,r){const o=function(t){const r=n(t),a=function(t){const n=e.selectAll(".tick").filter((e=>e===t));if(0===n.length||0===n[0].length)return!1;const l=i.a.selectAll(n[0]),o=l.select("text").node();if(null===o)return a(r(t));const s=o.getBBox().width,c=function(e){const t=/translate\(\s*([^\s,)]+)([ ,]([^\s,)]+))?\)/.exec(e);return Array.isArray(t)&&t.length>=2?Number(t[1]):NaN}(l.attr("transform"));return{tick:l,ts:t,xMinOffset:c-(s/2+15),xMaxOffset:c+(s/2+15)}};return a}(r),s=o(t);if(!1===s)return;const c=o(n(r)(t));!1!==c&&(c.xMinOffset<0||c.xMaxOffset>a||c.xMaxOffset>s.xMinOffset&&r===E.PREVIOUS||c.xMinOffset(e=e?+e:100,Object(l.jsx)(n.EuiFlexGroup,{justifyContent:"spaceEvenly"},Object(l.jsx)(n.EuiFlexItem,{grow:!1},Object(l.jsx)("div",{style:{height:`${e}px`},"data-test-subj":"mlLoadingIndicator"},Object(l.jsx)(n.EuiLoadingChart,{size:"xl",mono:!0}),t&&Object(l.jsx)(i.a.Fragment,null,Object(l.jsx)(n.EuiSpacer,{size:"s"}),Object(l.jsx)("div",null,t))))))},246:function(e,t,r){"use strict";r(247);var a=r(248);r.d(t,"a",(function(){return a.b}))},277:function(e,t,r){"use strict";r.d(t,"a",(function(){return u}));var a=r(2),i=r(28),n=r(68),l=r(72),o=r(9),s=r(4),c={name:"11zs6m0",styles:"width:100%;height:100%;display:flex;flex:1 1 100%;z-index:1;min-height:0"};function u({layerList:e,mapEmbeddableInput:t,renderTooltipContent:r}){const[u,d]=Object(a.useState)(),p=Object(a.useRef)(null),m=Object(a.useRef)(),{services:{embeddable:f,maps:h}}=Object(o.d)(),x=f?f.getEmbeddableFactory(n.MAP_SAVED_OBJECT_TYPE):void 0;return Object(a.useEffect)((()=>{!async function(){u&&!Object(l.isErrorEmbeddable)(u)&&Array.isArray(e)&&Array.isArray(m.current)&&u.setLayerList([...m.current,...e])}()}),[u,e]),Object(a.useEffect)((()=>{!async function(){if(!x)return void console.error("Map embeddable not found.");const e={id:Object(i.htmlIdGenerator)()(),attributes:{title:""},filters:[],hidePanelTitles:!0,viewMode:l.ViewMode.VIEW,isLayerTOCOpen:!1,hideFilterActions:!0,mapSettings:{disableInteractive:!1,hideToolbarOverlay:!1,hideLayerControl:!1,hideViewControl:!1,initialLocation:n.INITIAL_LOCATION.AUTO_FIT_TO_BOUNDS,autoFitToDataBounds:!0}},t=await x.create(e);if(t&&!Object(l.isErrorEmbeddable)(t)){const e=h?await h.createLayerDescriptors.createBasemapLayerDescriptor():null;e&&(m.current=[e],await t.setLayerList(m.current))}d(t)}()}),[]),Object(a.useEffect)((()=>{u&&!Object(l.isErrorEmbeddable)(u)&&void 0!==t&&u.updateInput(t)}),[u,t]),Object(a.useEffect)((()=>{u&&!Object(l.isErrorEmbeddable)(u)&&void 0!==r&&u.setRenderTooltipContent(r)}),[u,r]),Object(a.useEffect)((()=>{p.current&&u&&u.render(p.current)}),[u,p]),f?h?Object(s.jsx)("div",{"data-test-subj":"mlEmbeddedMapContent",css:c,ref:p}):(console.error("Maps start plugin not found"),null):(console.error("Embeddable start plugin not found"),null)}},351:function(e,t,r){"use strict";r.d(t,"a",(function(){return ie})),r(635);var a=r(2),i=r.n(a),n=r(28),l=r(4),o=r(185),s=r(131),c=r.n(s),u=r(89),d=r.n(u),p=r(39),m=r.n(p),f=r(6),h=r(98),x=r(110),b=r(145),v=r(245),y=r(166),g=r(117);const j="rgba(0, 0, 0, 0)";class explorer_chart_distribution_ExplorerChartDistribution extends i.a.Component{componentDidMount(){this.renderChart()}componentDidUpdate(){this.renderChart()}renderChart(){const{tooManyBuckets:e,tooltipService:t,timeBuckets:r,showSelectedInterval:a,onPointerUpdate:i,chartTheme:n,cursor:l}=this.props,s=this.rootNode,u=this.props.seriesConfig,p=this.props.severity;if(void 0===u||!1===Array.isArray(u.chartData))return;const v=y.a.getFieldFormat(u.jobId,u.detectorIndex);let O=0;const k=170,I=Object(o.h)(u),T={top:10,right:0,bottom:30,left:0};I===g.b.POPULATION_DISTRIBUTION&&(T.left=60);let E,S=null,_=null,w=null;const M=I===g.b.EVENT_DISTRIBUTION?"entity":"value";let N=u.chartData.find((e=>void 0!==e.anomalyScore));N=N&&N.entity;var A;A=function({chartData:e,functionDescription:t}){const r=d()(".ml-explorer-chart"),a=c.a.select(s).select(".content-wrapper");a.select("svg").remove();const i=r.width(),n=k+T.top+T.bottom,l=a.append("svg").classed("ml-explorer-chart-svg",!0).attr("width",i).attr("height",n),p=c.a.nest().key((e=>e.entity)).entries(e).sort(((e,t)=>t.values.length-e.values.length)).filter(((e,t)=>I!==g.b.EVENT_DISTRIBUTION||t<30||e.key===N)).map((e=>e.key));if(e=e.filter((e=>p.includes(e.entity))),I===g.b.POPULATION_DISTRIBUTION){const r=e.filter((e=>e.entity===N)),{min:a,max:i}=Object(o.e)(r,t);e=e.filter((e=>e.value<=i)),_=c.a.scale.linear().range([k,0]).domain([a<0?a:0,i]).nice()}else{if(I!==g.b.EVENT_DISTRIBUTION)throw`chartType '${I}' not supported`;{const e=5;_=c.a.scale.ordinal().rangePoints([e,k-e]).domain(p)}}const m=c.a.svg.axis().scale(_).orient("left").innerTickSize(0).outerTickSize(0).tickPadding(10);let f=0;const h=l.append("g").attr("class","temp-axis-label tick"),x=I===g.b.POPULATION_DISTRIBUTION?_.ticks():p;return h.selectAll("text.temp.axis").data(x).enter().append("text").text((e=>void 0!==v?v.convert(e,"text"):I===g.b.POPULATION_DISTRIBUTION?_.tickFormat()(e):e)).each((function(){f=Math.max(this.getBBox().width+m.tickPadding(),f)})).remove(),c.a.select(".temp-axis-label").remove(),(I===g.b.POPULATION_DISTRIBUTION||I===g.b.EVENT_DISTRIBUTION&&p.length<=10)&&(T.left=Math.max(f,40)),O=i-T.left-T.right,S=c.a.time.scale().range([0,O]).domain([u.plotEarliest,u.plotLatest]),w=c.a.svg.line().x((e=>S(e.date))).y((e=>_(e[M]))).defined((e=>null!==e.value)),E=l.append("g").attr("class","line-chart").attr("transform","translate("+T.left+","+T.top+")"),e}(u),E.append("rect").attr("x",0).attr("y",0).attr("height",k).attr("width",O).style("stroke","#cccccc").style("fill","none").style("stroke-width",1),function(){const t={min:m()(u.plotEarliest),max:m()(u.plotLatest)};r.setBounds(t),r.setInterval("auto");const a=r.getScaledDateFormat(),i=Math.max(u.selectedEarliest,u.plotEarliest),n=u.selectedLatest-u.selectedEarliest+1,l=c.a.svg.axis().scale(S).orient("bottom").innerTickSize(-170).outerTickSize(0).tickPadding(10).tickFormat((e=>m()(e).format(a))),s=!0===e||n>=u.plotLatest-u.plotEarliest;if(!1===s){const e=Object(o.k)(i,n,u.plotEarliest,u.plotLatest);l.tickValues(e)}else l.ticks(Object(o.m)(O,a));const d=c.a.svg.axis().scale(_).orient("left").innerTickSize(0).outerTickSize(0).tickPadding(10);void 0!==v&&d.tickFormat((e=>v.convert(e,"text")));const p=E.append("g"),f=p.append("g").attr("class","x axis").attr("transform","translate(0,170)").call(l);p.append("g").attr("class","y axis").call(d),I===g.b.EVENT_DISTRIBUTION&&p.select(".y").selectAll("text").each((function(e){c.a.select(this).classed("ml-explorer-chart-axis-emphasis",e===N)})),!1===s&&Object(o.n)(f,i,n,O)}(),function(){if(!1===a)return;const e=Math.max(u.selectedEarliest,u.plotEarliest),t=Math.min(u.selectedLatest,u.plotLatest),r=S(t)-S(e);E.append("rect").attr("class","selected-interval").attr("x",S(new Date(e))+2).attr("y",2).attr("rx",3).attr("ry",3).attr("width",r-4).attr("height",166)}(),function(e){var t,r,a;e.append("rect").attr("x",0).attr("y",0).attr("height",k).attr("width",O).on("mouseout",(function(){i({chartId:"ml-anomaly-chart-metric",scale:"time",smHorizontalValue:null,smVerticalValue:null,type:"Out",unit:void 0})})).on("mousemove",(function(){const e=c.a.mouse(this);i({chartId:"ml-anomaly-chart-metric",scale:"time",smHorizontalValue:null,smVerticalValue:null,type:"Over",unit:void 0,x:1e3*m()(S.invert(e[0])).unix()})})).style("fill",j);const o=l&&"Over"===l.type&&l.x>=u.plotEarliest&&l.x<=u.plotLatest?[l.x]:[],s=e.append("g").attr("class","ml-anomaly-chart-cursor").selectAll(".ml-anomaly-chart-cursor-line").data(o);s.enter().append("path").attr("class","ml-anomaly-chart-cursor-line").attr("d",(e=>{const t=S(e);return`M${t},170 ${t},0`})).style("stroke",`${null!==(t=n.crosshair.line.stroke)&&void 0!==t?t:"black"}`).style("stroke-width",`${null!==(r=n.crosshair.line.strokeWidth)&&void 0!==r?r:"1"}px`).style("stroke-dasharray",null!==(a=n.crosshair.line.dash)&&void 0!==a?a:"4,4"),s.exit().remove()}(E),function(e,t,r,a=1.5){const i=(t.select(".values-dots").empty()?t.append("g").classed("values-dots",!0):t.select(".values-dots")).selectAll("circle").data(e);i.enter().append("circle").classed("values-dots-circle",!0).classed("values-dots-circle-blur",(e=>e.entity!==N)).attr("r",(e=>e.entity===N?1.5*a:a)),i.attr("cx",r.x()).attr("cy",r.y()),i.exit().remove()}(A,E,w),function(e){const r=E.append("g").attr("class","chart-markers").selectAll(".metric-value").data(e.filter((e=>null!==e.value)));r.exit().remove(),r.enter().append("circle").attr("r",7).on("mouseover",(function(e){!function(e,r){const a=[{label:Object(x.c)(e.date)}],i=u.detectorLabel;if(void 0!==e.entity&&a.push({label:f.i18n.translate("xpack.ml.explorer.distributionChart.entityLabel",{defaultMessage:"entity"}),value:e.entity,seriesIdentifier:{key:i},valueAccessor:"entity"}),void 0!==e.anomalyScore){const t=parseInt(e.anomalyScore),r=Object(h.y)(t);a.push({label:f.i18n.translate("xpack.ml.explorer.distributionChart.anomalyScoreLabel",{defaultMessage:"anomaly score"}),value:r,color:Object(h.A)(t),seriesIdentifier:{key:i},valueAccessor:"anomaly_score"}),I!==g.b.EVENT_DISTRIBUTION&&(a.push({label:f.i18n.translate("xpack.ml.explorer.distributionChart.valueLabel",{defaultMessage:"value"}),value:Object(b.b)(e.value,u.functionDescription,v),seriesIdentifier:{key:i},valueAccessor:"value"}),void 0!==e.numberOfCauses&&1!==e.numberOfCauses||a.push({label:f.i18n.translate("xpack.ml.explorer.distributionChart.typicalLabel",{defaultMessage:"typical"}),value:Object(b.b)(e.typical,u.functionDescription,v),seriesIdentifier:{key:i},valueAccessor:"typical"}),void 0!==e.byFieldName&&void 0!==e.numberOfCauses&&a.push({label:f.i18n.translate("xpack.ml.explorer.distributionChart.unusualByFieldValuesLabel",{defaultMessage:"{ numberOfCauses, plural, one {# unusual {byFieldName} value} other {#{plusSign} unusual {byFieldName} values}}",values:{numberOfCauses:e.numberOfCauses,byFieldName:e.byFieldName,plusSign:e.numberOfCauses<10?"":"+"}}),seriesIdentifier:{key:i},valueAccessor:"numberOfCauses"}))}else I!==g.b.EVENT_DISTRIBUTION&&a.push({label:f.i18n.translate("xpack.ml.explorer.distributionChart.valueWithoutAnomalyScoreLabel",{defaultMessage:"value"}),value:Object(b.b)(e.value,u.functionDescription,v),seriesIdentifier:{key:i},valueAccessor:"value"});void 0!==e.scheduledEvents&&e.scheduledEvents.forEach(((t,r)=>{a.push({label:f.i18n.translate("xpack.ml.timeSeriesExplorer.timeSeriesChart.scheduledEventsLabel",{defaultMessage:"scheduled event{counter}",values:{counter:e.scheduledEvents.length>1?` #${r+1}`:""}}),value:t,seriesIdentifier:{key:i},valueAccessor:`scheduled_events_${r+1}`})})),t.show(a,r,{x:21,y:14})}(e,this)})).on("mouseout",(()=>t.hide())),r.attr("cx",(e=>S(e.date))).attr("cy",(e=>_(e[M]))).attr("class",(e=>{let t="metric-value";return void 0!==e.anomalyScore&&Number(e.anomalyScore)>=p&&(t+=" anomaly-marker ",t+=Object(h.C)(e.anomalyScore).id),t}));const a=E.select(".chart-markers").selectAll(".scheduled-event-marker").data(e.filter((e=>void 0!==e.scheduledEvents)));a.exit().remove(),a.enter().append("rect").attr("width",14).attr("height",5).attr("class","scheduled-event-marker").attr("rx",1).attr("ry",1),a.attr("x",(e=>S(e.date)-7)).attr("y",(e=>_(e[M])-2.5))}(A)}shouldComponentUpdate(){return!0}setRef(e){this.rootNode=e}render(){const{seriesConfig:e}=this.props;if(void 0===e)return null;const t=e.loading;return Object(l.jsx)("div",{className:"ml-explorer-chart",ref:this.setRef.bind(this)},t&&Object(l.jsx)(v.a,{height:215}),!t&&Object(l.jsx)("div",{className:"content-wrapper"}))}}const O="ml-explorer-chart-content-wrapper";class explorer_chart_single_metric_ExplorerChartSingleMetric extends i.a.Component{componentDidMount(){this.renderChart()}componentDidUpdate(){this.renderChart()}renderChart(){const{tooManyBuckets:e,tooltipService:t,timeBuckets:r,showSelectedInterval:a,onPointerUpdate:i,chartTheme:n,cursor:l}=this.props,s=this.rootNode,u=this.props.seriesConfig,p=this.props.severity;if(void 0===u||!1===Array.isArray(u.chartData))return;const v=y.a.getFieldFormat(u.jobId,u.detectorIndex);let g=0;const k=170,I={top:10,right:0,bottom:30,left:60};let T,E=null,S=null,_=null;var w;function M(e,r){const a=[{label:Object(x.c)(e.date)}],i=u.detectorLabel;if(void 0!==e.anomalyScore){const t=parseInt(e.anomalyScore);a.push({label:f.i18n.translate("xpack.ml.explorer.singleMetricChart.anomalyScoreLabel",{defaultMessage:"anomaly score"}),value:Object(h.y)(t),color:Object(h.A)(t),seriesIdentifier:{key:i},valueAccessor:"anomaly_score"}),!0===Object(o.p)(e)&&a.push({label:f.i18n.translate("xpack.ml.explorer.singleMetricChart.multiBucketImpactLabel",{defaultMessage:"multi-bucket impact"}),value:Object(o.j)(e),seriesIdentifier:{key:i},valueAccessor:"multi_bucket_impact"}),void 0!==e.actual&&"rare"!==u.functionDescription?(a.push({label:f.i18n.translate("xpack.ml.explorer.singleMetricChart.actualLabel",{defaultMessage:"actual"}),value:Object(b.b)(e.actual,u.functionDescription,v),seriesIdentifier:{key:i},valueAccessor:"actual"}),a.push({label:f.i18n.translate("xpack.ml.explorer.singleMetricChart.typicalLabel",{defaultMessage:"typical"}),value:Object(b.b)(e.typical,u.functionDescription,v),seriesIdentifier:{key:i},valueAccessor:"typical"})):(a.push({label:f.i18n.translate("xpack.ml.explorer.singleMetricChart.valueLabel",{defaultMessage:"value"}),value:Object(b.b)(e.value,u.functionDescription,v),seriesIdentifier:{key:i},valueAccessor:"value"}),void 0!==e.byFieldName&&void 0!==e.numberOfCauses&&a.push({label:f.i18n.translate("xpack.ml.explorer.distributionChart.unusualByFieldValuesLabel",{defaultMessage:"{ numberOfCauses, plural, one {# unusual {byFieldName} value} other {#{plusSign} unusual {byFieldName} values}}",values:{numberOfCauses:e.numberOfCauses,byFieldName:e.byFieldName,plusSign:e.numberOfCauses<10?"":"+"}}),seriesIdentifier:{key:i},valueAccessor:"numberOfCauses"}))}else a.push({label:f.i18n.translate("xpack.ml.explorer.singleMetricChart.valueWithoutAnomalyScoreLabel",{defaultMessage:"value"}),value:Object(b.b)(e.value,u.functionDescription,v),seriesIdentifier:{key:i},valueAccessor:"value"});void 0!==e.scheduledEvents&&a.push({label:f.i18n.translate("xpack.ml.explorer.singleMetricChart.scheduledEventsLabel",{defaultMessage:"Scheduled events"}),value:e.scheduledEvents,seriesIdentifier:{key:i},valueAccessor:"scheduledEvents"}),t.show(a,r,{x:3*o.b,y:2*o.b})}!function(e){const t=d()(".ml-explorer-chart"),r=c.a.select(s).select(`.${O}`);r.select("svg").remove();const a=t.width(),i=k+I.top+I.bottom,n=r.append("svg").classed("ml-explorer-chart-svg",!0).attr("width",a).attr("height",i);S=c.a.scale.linear().range([k,0]).domain([e.min,e.max]).nice();const l=c.a.svg.axis().scale(S).orient("left").innerTickSize(0).outerTickSize(0).tickPadding(10);let o=0;n.append("g").attr("class","temp-axis-label tick").selectAll("text.temp.axis").data(S.ticks()).enter().append("text").text((e=>void 0!==v?v.convert(e,"text"):S.tickFormat()(e))).each((function(){o=Math.max(this.getBBox().width+l.tickPadding(),o)})).remove(),c.a.select(".temp-axis-label").remove(),I.left=Math.max(o,40),g=a-I.left-I.right,E=c.a.time.scale().range([0,g]).domain([u.plotEarliest,u.plotLatest]),_=c.a.svg.line().x((e=>E(e.date))).y((e=>S(e.value))).defined((e=>null!==e.value)),T=n.append("g").attr("class","line-chart").attr("transform","translate("+I.left+","+I.top+")")}(u.chartLimits),w=u.chartData,T.append("rect").attr("x",0).attr("y",0).attr("height",k).attr("width",g).style("stroke","#cccccc").style("fill","none").style("stroke-width",1),function(){const t={min:m()(u.plotEarliest),max:m()(u.plotLatest)};r.setBounds(t),r.setInterval("auto");const a=r.getScaledDateFormat(),i=Math.max(u.selectedEarliest,u.plotEarliest),n=u.selectedLatest-u.selectedEarliest+1,l=c.a.svg.axis().scale(E).orient("bottom").innerTickSize(-170).outerTickSize(0).tickPadding(10).tickFormat((e=>m()(e).format(a))),s=!0===e||n>=u.plotLatest-u.plotEarliest;if(!1===s){const e=Object(o.k)(i,n,u.plotEarliest,u.plotLatest);l.tickValues(e)}else l.ticks(Object(o.m)(g,a));const d=c.a.svg.axis().scale(S).orient("left").innerTickSize(0).outerTickSize(0).tickPadding(10);void 0!==v&&d.tickFormat((e=>v.convert(e,"text")));const p=T.append("g"),f=p.append("g").attr("class","x axis").attr("transform","translate(0,170)").call(l);p.append("g").attr("class","y axis").call(d),!1===s&&Object(o.n)(f,i,n,g)}(),function(){if(!1===a)return;const e=Math.max(u.selectedEarliest,u.plotEarliest),t=Math.min(u.selectedLatest,u.plotLatest),r=E(t)-E(e);T.append("rect").attr("class","selected-interval").attr("x",E(new Date(e))+2).attr("y",2).attr("rx",3).attr("ry",3).attr("width",r-4).attr("height",166)}(),function(e){var t,r,a;e.append("rect").attr("x",0).attr("y",0).attr("height",k).attr("width",g).on("mouseout",(function(){i({chartId:"ml-anomaly-chart-metric",scale:"time",smHorizontalValue:null,smVerticalValue:null,type:"Out",unit:void 0})})).on("mousemove",(function(){const e=c.a.mouse(this);i&&i({chartId:"ml-anomaly-chart-metric",scale:"time",smHorizontalValue:null,smVerticalValue:null,type:"Over",unit:void 0,x:1e3*m()(E.invert(e[0])).unix()})})).style("fill",j);const o=l&&"Over"===l.type&&l.x>=u.plotEarliest&&l.x<=u.plotLatest?[l.x]:[],s=e.append("g").attr("class","ml-anomaly-chart-cursor").selectAll(".ml-anomaly-chart-cursor-line").data(o);s.enter().append("path").attr("class","ml-anomaly-chart-cursor-line").attr("d",(e=>{const t=E(e);return`M${t},170 ${t},0`})).style("stroke",`${null!==(t=n.crosshair.line.stroke)&&void 0!==t?t:"black"}`).style("stroke-width",`${null!==(r=n.crosshair.line.strokeWidth)&&void 0!==r?r:"1"}px`).style("stroke-dasharray",null!==(a=n.crosshair.line.dash)&&void 0!==a?a:"4,4"),s.exit().remove()}(T),function(e){T.append("path").attr("class","values-line").attr("d",_(e))}(w),Object(o.f)(w,T,_),function(e){const r=T.append("g").attr("class","chart-markers").selectAll(".metric-value").data(e.filter((e=>(null!==e.value||"number"==typeof e.anomalyScore)&&!Object(o.o)(e))));r.exit().remove(),r.enter().append("circle").attr("r",o.b).on("mouseover",(function(e){M(e,this)})).on("mouseout",(()=>t.hide()));const a=e=>void 0!==e.anomalyScore&&Number(e.anomalyScore)>=p;r.attr("cx",(e=>E(e.date))).attr("cy",(e=>S(e.value))).attr("class",(e=>{let t="metric-value";return a(e)&&(t+=` anomaly-marker ${Object(h.C)(e.anomalyScore).id}`),t}));const i=T.select(".chart-markers").selectAll(".multi-bucket").data(e.filter((e=>a(e)&&!0===Object(o.o)(e))));i.exit().remove(),i.enter().append("path").attr("d",c.a.svg.symbol().size(o.c).type("cross")).attr("transform",(e=>`translate(${E(e.date)}, ${S(e.value)})`)).attr("class",(e=>`anomaly-marker multi-bucket ${Object(h.C)(e.anomalyScore).id}`)).on("mouseover",(function(e){M(e,this)})).on("mouseout",(()=>t.hide()));const n=T.select(".chart-markers").selectAll(".scheduled-event-marker").data(e.filter((e=>void 0!==e.scheduledEvents)));n.exit().remove(),n.enter().append("rect").attr("width",2*o.b).attr("height",o.d).attr("class","scheduled-event-marker").attr("rx",1).attr("ry",1),n.attr("x",(e=>E(e.date)-o.b)).attr("y",(e=>S(e.value)-o.d/2))}(w)}shouldComponentUpdate(){return!0}setRef(e){this.rootNode=e}render(){const{seriesConfig:e}=this.props;if(void 0===e)return null;const t=e.loading;return Object(l.jsx)("div",{className:"ml-explorer-chart",ref:this.setRef.bind(this)},t&&Object(l.jsx)(v.a,{height:215}),!t&&Object(l.jsx)("div",{className:O}))}}function k({entity:e}){return Object(l.jsx)("span",{className:"ml-explorer-chart-label-badge"},Object(l.jsx)(n.EuiBadge,{color:"hollow",className:"ml-reset-font-weight"},e.fieldName," ",Object(l.jsx)("strong",null,e.fieldValue)))}r(640),r(645);const I={[g.b.EVENT_DISTRIBUTION]:f.i18n.translate("xpack.ml.explorer.charts.infoTooltip.chartEventDistributionDescription",{defaultMessage:"The gray dots depict the approximate distribution of occurrences over time for a sample of {byFieldValuesParam} with more frequent event types at the top and rarer ones at the bottom.",values:{byFieldValuesParam:"by_field_values"}}),[g.b.POPULATION_DISTRIBUTION]:f.i18n.translate("xpack.ml.explorer.charts.infoTooltip.chartPopulationDistributionDescription",{defaultMessage:"The gray dots depict the approximate distribution of values over time for a sample of {overFieldValuesParam}.",values:{overFieldValuesParam:"over_field_values"}})};function T({toolTipData:e}){return Object(l.jsx)("dl",{className:"mlDescriptionList"},e.map((({title:e,description:t})=>Object(l.jsx)(i.a.Fragment,{key:`${e} ${t}`},Object(l.jsx)("dt",{className:"mlDescriptionList__title"},e),Object(l.jsx)("dd",{className:"mlDescriptionList__description"},t)))))}const E=({jobId:e,aggregationInterval:t,chartFunction:r,chartType:a,entityFields:o=[]})=>{const s=I[a],c=[{title:f.i18n.translate("xpack.ml.explorer.charts.infoTooltip.jobIdTitle",{defaultMessage:"job ID"}),description:e},{title:f.i18n.translate("xpack.ml.explorer.charts.infoTooltip.aggregationIntervalTitle",{defaultMessage:"aggregation interval"}),description:t},{title:f.i18n.translate("xpack.ml.explorer.charts.infoTooltip.chartFunctionTitle",{defaultMessage:"chart function"}),description:r}];return o.forEach((e=>{c.push({title:e.fieldName,description:e.fieldValue})})),Object(l.jsx)("div",{className:"ml-explorer-chart-info-tooltip"},Object(l.jsx)(T,{toolTipData:c}),s&&Object(l.jsx)(i.a.Fragment,null,Object(l.jsx)(n.EuiSpacer,{size:"s"}),Object(l.jsx)("div",{className:"ml-explorer-chart-description"},s)))};var S=r(15),_=r(179);r(650);const w=({onFilter:e,influencerFieldName:t,influencerFieldValue:r})=>Object(l.jsx)(i.a.Fragment,null,Object(l.jsx)(n.EuiToolTip,{content:Object(l.jsx)(S.FormattedMessage,{id:"xpack.ml.entityFilter.addFilterTooltip",defaultMessage:"Add filter"})},Object(l.jsx)(n.EuiButtonIcon,{size:"s",className:"filter-button",onClick:Object(_.a)((()=>{e({influencerFieldName:t,influencerFieldValue:r,action:h.m.ADD})})),iconType:"plusInCircle","aria-label":f.i18n.translate("xpack.ml.entityFilter.addFilterAriaLabel",{defaultMessage:"Add filter for {influencerFieldName} {influencerFieldValue}",values:{influencerFieldName:t,influencerFieldValue:r}})})),Object(l.jsx)(n.EuiToolTip,{content:Object(l.jsx)(S.FormattedMessage,{id:"xpack.ml.entityFilter.removeFilterTooltip",defaultMessage:"Remove filter"})},Object(l.jsx)(n.EuiButtonIcon,{size:"s",className:"filter-button",onClick:Object(_.a)((()=>{e({influencerFieldName:t,influencerFieldValue:r,action:h.m.REMOVE})})),iconType:"minusInCircle","aria-label":f.i18n.translate("xpack.ml.entityFilter.removeFilterAriaLabel",{defaultMessage:"Remove filter for {influencerFieldName} {influencerFieldValue}",values:{influencerFieldName:t,influencerFieldValue:r}})})));function M({detectorLabel:e,entityFields:t,infoTooltip:r,wrapLabel:o=!1,onSelectEntity:s}){const c=!0===o||0===t.length||0===e.length?Object(l.jsx)(i.a.Fragment,null," "):Object(l.jsx)(i.a.Fragment,null," – "),u=Object(a.useCallback)((({influencerFieldName:e,influencerFieldValue:t,action:r})=>s(e,t,r)),[s]),d=t.map((e=>{const t=`${r.chartFunction}-${e.fieldName}-${e.fieldType}-${e.fieldValue}`;return Object(l.jsx)(a.Fragment,{key:`badge-wrapper-${t}`},Object(l.jsx)(k,{entity:e}),void 0!==s&&Object(l.jsx)(w,{onFilter:u,influencerFieldName:e.fieldName,influencerFieldValue:e.fieldValue}))})),p=Object(l.jsx)("span",{className:"ml-explorer-chart-info-icon"},Object(l.jsx)(n.EuiIconTip,{className:"ml-explorer-chart-eui-icon-tip",content:Object(l.jsx)(E,r),position:"top",size:"s"}));return Object(l.jsx)(i.a.Fragment,null,Object(l.jsx)("span",{className:"ml-explorer-chart-label"},Object(l.jsx)("span",{className:"ml-explorer-chart-label-detector"},e,c),o&&p,!o&&Object(l.jsx)(i.a.Fragment,null,d," ",p)),o&&Object(l.jsx)("span",{className:"ml-explorer-chart-label-badges"},d))}var N=r(120),A=r(246),F=r(21),C=r(9),L=r(165),B=r(68),D=r(83);const R=({errorMessagesByType:e})=>{if(!e||0===Object.keys(e).length)return null;const t=Object.keys(e).map((t=>Object(l.jsx)(n.EuiCallOut,{color:"warning",size:"s",key:t},Object(l.jsx)(S.FormattedMessage,{id:"xpack.ml.explorerCharts.errorCallOutMessage",defaultMessage:"You can't view anomaly charts for {jobs} because {reason}.",values:{jobs:[...e[t]].join(", "),reason:t}}))));return Object(l.jsx)(i.a.Fragment,null,t,Object(l.jsx)(n.EuiSpacer,{size:"m"}))};var V=r(197);const P="Feature",U="Point";function z(e,t){const r=[];for(let i=0;iNumber(e))).reverse();r.push({type:P,geometry:{type:U,coordinates:e},properties:{record_score:Math.floor(n.record_score),[t]:e.map((e=>Number(e.toFixed(2))))}})}}return r}const $=e=>({id:"anomalies_typical_layer",label:"Typical",sourceDescriptor:{id:"b7486535-171b-4d3b-bb2e-33c1a0a2854e",type:"GEOJSON_FILE",__featureCollection:{features:z(e,"typical_point"),type:"FeatureCollection"}},visible:!0,style:{type:"VECTOR",properties:{fillColor:{type:"STATIC",options:{color:"#98A2B2"}},lineColor:{type:"STATIC",options:{color:"#fff"}},lineWidth:{type:"STATIC",options:{size:2}},iconSize:{type:"STATIC",options:{size:6}}}},type:B.LAYER_TYPE.GEOJSON_VECTOR}),G=e=>({id:"anomalies_actual_layer",label:"Actual",sourceDescriptor:{id:"b7486535-171b-4d3b-bb2e-33c1a0a2854d",type:"GEOJSON_FILE",__fields:[{name:"record_score",type:"number"}],__featureCollection:{features:z(e,"actual_point"),type:"FeatureCollection"}},visible:!0,style:{type:"VECTOR",properties:{fillColor:{type:B.STYLE_TYPE.DYNAMIC,options:{customColorRamp:h.r,field:{name:"record_score",origin:B.FIELD_ORIGIN.SOURCE},useCustomColorRamp:!0}},lineColor:{type:"STATIC",options:{color:"#fff"}},lineWidth:{type:"STATIC",options:{size:2}},iconSize:{type:"STATIC",options:{size:6}}}},type:B.LAYER_TYPE.GEOJSON_VECTOR});var J=r(277);function H({seriesConfig:e}){const[t,r]=Object(a.useState)([]);return Object(a.useEffect)((()=>{e.mapData&&e.mapData.length>0&&r([G(e.mapData),$(e.mapData)])}),[e]),Object(l.jsx)("div",{"data-test-subj":"xpack.ml.explorer.embeddedMap",style:{width:"100%",height:300}},Object(l.jsx)(J.a,{layerList:t}))}var Y=r(88),W=r(66),q=r(29),X=r.n(q),K=r(116);const Q=f.i18n.translate("xpack.ml.explorer.charts.tooManyBucketsDescription",{defaultMessage:"This selection contains too many buckets to be displayed. You should shorten the time range of the view or narrow the selection in the timeline."}),Z=f.i18n.translate("xpack.ml.explorer.charts.openInSingleMetricViewerButtonLabel",{defaultMessage:"Open in Single Metric Viewer"}),ee=f.i18n.translate("xpack.ml.explorer.charts.mapsPluginMissingMessage",{defaultMessage:"maps or embeddable start plugin not found"}),te=f.i18n.translate("xpack.ml.explorer.charts.openInMapsPluginMessage",{defaultMessage:"Open in Maps"});function re(e){const{jobId:t,detectorLabel:r,entityFields:a}=e;return`${t}_${r}_${a.map((e=>`${e.fieldName}/${e.fieldValue}`)).join(",")}`}function ae({series:e,severity:t,tooManyBuckets:r,wrapLabel:s,mlLocator:c,timeBuckets:u,timefilter:d,timeRange:p,onSelectEntity:m,recentlyAccessed:f,tooManyBucketsCalloutMsg:x,showSelectedInterval:b,chartsService:v}){var y;const[j,O]=Object(a.useState)(""),[k,I]=Object(a.useState)(""),{services:{share:T,application:{navigateToApp:E}}}=Object(C.d)(),_=Object(a.useCallback)((async()=>{const{queryString:t,query:r}=function(e){var t;const r=null===(t=e.entityFields)||void 0===t?void 0:t.map((({fieldName:e,fieldValue:t})=>Object(K.d)(e,t))).join(" or ");return{query:{language:N.b.KUERY,query:r},queryString:r}}(e),a=Object(L.c)(e.jobId),i=T.url.locators.get(D.MAPS_APP_LOCATOR);return await i.getLocation({initialLayers:a,timeRange:null!=p?p:null==d?void 0:d.getTime(),...void 0!==t?{query:r}:{}})}),[null==e?void 0:e.jobId,p]);Object(a.useEffect)((()=>{let t=!1;return(async()=>{let r=p;const a=null==d?void 0:d.getActiveBounds();if(!p&&a&&(r={from:a.min.toISOString(),to:a.max.toISOString()}),!t&&e.functionDescription!==h.n.LAT_LONG)try{const t=await Object(o.i)(c,e,r);O(t)}catch(e){O("")}})(),()=>{t=!0}}),[c,e,p]),Object(a.useEffect)((function(){let t=!1;if(e&&Object(o.h)(e)===g.b.GEO_MAP){const e=async()=>{try{const e=await _();t||I(null==e?void 0:e.path)}catch(e){console.error(e),I("")}};e().catch(console.error)}return()=>{t=!0}}),[e]);const w=Object(a.useRef)(null),{euiTheme:F}=Object(n.useEuiTheme)(),R=v.theme.useChartsTheme(),P=Object(Y.useActiveCursor)(v.activeCursor,w,{isDateHistogram:!0}),U=null===(y=X()(v.activeCursor.activeCursor$))||void 0===y?void 0:y.cursor,z=Object(a.useCallback)((()=>{f&&Object(V.a)("timeseriesexplorer",e.jobId,j,f)}),[j,f]),{detectorLabel:$,entityFields:G}=e,J=Object(o.h)(e);let q=Object(l.jsx)(i.a.Fragment,null,$);if(J===g.b.EVENT_DISTRIBUTION){const t=e.entityFields.find((e=>"by"===e.fieldType));void 0!==t&&(q=Object(l.jsx)(i.a.Fragment,null,Object(l.jsx)(S.FormattedMessage,{id:"xpack.ml.explorer.charts.detectorLabel",defaultMessage:'{detectorLabel}{br}y-axis event distribution split by "{fieldName}"',values:{detectorLabel:$,br:Object(l.jsx)("br",null),fieldName:t.fieldName}})),s=!0)}return Object(l.jsx)(i.a.Fragment,null,Object(l.jsx)("div",{style:{width:0,height:0}},Object(l.jsx)(W.Chart,{ref:w},Object(l.jsx)(W.Settings,{noResults:Object(l.jsx)("div",null),width:0,height:0}),Object(l.jsx)(W.BarSeries,{id:"count",xAccessor:"x",yAccessors:["y"],data:[]}))),Object(l.jsx)(n.EuiFlexGroup,{justifyContent:"spaceBetween"},Object(l.jsx)(n.EuiFlexItem,{grow:!1},Object(l.jsx)(M,{detectorLabel:q,entityFields:G,infoTooltip:{...e.infoTooltip,chartType:J},wrapLabel:s,onSelectEntity:m})),Object(l.jsx)(n.EuiFlexItem,{grow:!1},Object(l.jsx)("div",{css:Object(l.css)("padding:",F.size.xs,";","")},r&&Object(l.jsx)(n.EuiIconTip,{content:null!=x?x:Q,position:"top",size:"s",type:"warning",color:"warning"}),j&&Object(l.jsx)(n.EuiToolTip,{position:"top",content:Z},Object(l.jsx)(n.EuiButtonEmpty,{iconSide:"right",iconType:"visLine",size:"xs",href:j,onClick:z},Object(l.jsx)(S.FormattedMessage,{id:"xpack.ml.explorer.charts.viewLabel",defaultMessage:"View"}))),J===g.b.GEO_MAP&&k?Object(l.jsx)(n.EuiToolTip,{position:"top",content:te},Object(l.jsx)(n.EuiButtonEmpty,{iconSide:"right",iconType:"logoMaps",size:"xs",onClick:async()=>{await E(B.APP_ID,{path:k})}},Object(l.jsx)(S.FormattedMessage,{id:"xpack.ml.explorer.charts.viewInMapsLabel",defaultMessage:"View"}))):null))),J===g.b.GEO_MAP?Object(l.jsx)(A.a,null,(t=>Object(l.jsx)(H,{seriesConfig:e,tooltipService:t}))):J===g.b.EVENT_DISTRIBUTION||J===g.b.POPULATION_DISTRIBUTION?Object(l.jsx)(A.a,null,(a=>Object(l.jsx)(explorer_chart_distribution_ExplorerChartDistribution,{timeBuckets:u,tooManyBuckets:r,seriesConfig:e,severity:t,tooltipService:a,showSelectedInterval:b,onPointerUpdate:P,chartTheme:R,cursor:U}))):J===g.b.SINGLE_METRIC?Object(l.jsx)(A.a,null,(a=>Object(l.jsx)(explorer_chart_single_metric_ExplorerChartSingleMetric,{timeBuckets:u,tooManyBuckets:r,seriesConfig:e,severity:t,tooltipService:a,showSelectedInterval:b,onPointerUpdate:P,chartTheme:R,cursor:U}))):void 0)}const ie=Object(F.withKibana)((({chartsPerRow:e,seriesToPlot:t,severity:r,tooManyBuckets:a,kibana:s,errorMessages:c,mlLocator:u,timeBuckets:d,timefilter:p,timeRange:m,onSelectEntity:f,tooManyBucketsCalloutMsg:h,showSelectedInterval:x,chartsService:b})=>{const{services:{chrome:{recentlyAccessed:v},embeddable:y,maps:g}}=s;let j;y&&g||(j=[],t.forEach((e=>{"lat_long"===e.functionDescription?void 0===c[ee]?c[ee]=new Set([e.jobId]):c[ee].add(e.jobId):j.push(e)})));const O=void 0!==j?j:t,k=1===e?"calc(100% - 20px)":"auto",I=1===e?0:e,T=O.some((e=>Object(o.l)(e)));return Object(l.jsx)(i.a.Fragment,null,Object(l.jsx)(R,{errorMessagesByType:c}),Object(l.jsx)(n.EuiFlexGrid,{columns:I,gutterSize:"m","data-test-subj":"mlExplorerChartsContainer"},O.length>0&&O.map((e=>Object(l.jsx)(n.EuiFlexItem,{key:re(e),className:"ml-explorer-chart-container",style:{minWidth:k}},Object(l.jsx)(ae,{series:e,severity:r,tooManyBuckets:a,wrapLabel:T,mlLocator:u,timeBuckets:d,timefilter:p,timeRange:m,onSelectEntity:f,recentlyAccessed:v,tooManyBucketsCalloutMsg:h,showSelectedInterval:x,chartsService:b}))))))}))},635:function(e,t,r){switch(window.__kbnThemeTag__){case"v8dark":return r(636);case"v8light":return r(638)}},636:function(e,t,r){var a=r(103),i=r(637);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);a(i,{insert:"head",singleton:!1}),e.exports=i.locals||{}},637:function(e,t,r){(t=r(104)(!1)).push([e.i,".ml-explorer-chart-eui-icon-tip{max-width:none}.ml-explorer-chart-label-badges{align-items:center;display:flex;margin-top:4px}.ml-reset-font-weight{font-weight:400}.ml-explorer-chart-container{overflow:hidden}.ml-explorer-chart-container .ml-explorer-chart-svg{font-family:Inter UI,-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;font-size:12px}.ml-explorer-chart-container .ml-explorer-chart-svg .line-chart rect{fill:#1d1e24;opacity:1}.ml-explorer-chart-container .ml-explorer-chart-svg .line-chart rect.selected-interval{fill:#c8c8c81a;stroke:#98a2b3;stroke-width:2px;stroke-opacity:.8}.ml-explorer-chart-container .ml-explorer-chart-svg .line-chart rect.scheduled-event-marker{stroke-width:1px;stroke:#98a2b3;fill:#343741;pointer-events:none}.ml-explorer-chart-container .axis line,.ml-explorer-chart-container .axis path{fill:none;stroke:#343741;shape-rendering:crispEdges}.ml-explorer-chart-container .axis .tick line.ml-tick-emphasis{stroke:#0003}.ml-explorer-chart-container .axis text{fill:#98a2b3}.ml-explorer-chart-container .axis .tick line{stroke:#343741;stroke-width:1px}.ml-explorer-chart-container .values-line{fill:none;stroke:#36a2ef;stroke-width:2}.ml-explorer-chart-container .values-dots circle,.ml-explorer-chart-container .values-dots-circle{fill:#36a2ef;stroke-width:0}.ml-explorer-chart-container .values-dots circle.values-dots-circle-blur{fill:#535966}.ml-explorer-chart-container .metric-value{fill:#0000;stroke:#36a2ef;stroke-width:0;opacity:1}.ml-explorer-chart-container .anomaly-marker{stroke-width:1px;stroke:#535966}.ml-explorer-chart-container .anomaly-marker:hover{stroke-width:6px;stroke:#36a2ef}.ml-explorer-chart-container .anomaly-marker.critical{fill:#fe5050}.ml-explorer-chart-container .anomaly-marker.major{fill:#fba740}.ml-explorer-chart-container .anomaly-marker.minor{fill:#fdec25}.ml-explorer-chart-container .anomaly-marker.warning{fill:#8bc8fb}.ml-explorer-chart-container .anomaly-marker.low{fill:#d2e9f7}.ml-explorer-chart-container .anomaly-marker:hover,.ml-explorer-chart-container .metric-value:hover{stroke-width:6px;stroke-opacity:.65}.ml-explorer-chart{overflow:hidden}.ml-explorer-chart-content-wrapper{height:215px}.ml-explorer-chart-axis-emphasis{font-weight:700}",""]),e.exports=t},638:function(e,t,r){var a=r(103),i=r(639);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);a(i,{insert:"head",singleton:!1}),e.exports=i.locals||{}},639:function(e,t,r){(t=r(104)(!1)).push([e.i,".ml-explorer-chart-eui-icon-tip{max-width:none}.ml-explorer-chart-label-badges{align-items:center;display:flex;margin-top:4px}.ml-reset-font-weight{font-weight:400}.ml-explorer-chart-container{overflow:hidden}.ml-explorer-chart-container .ml-explorer-chart-svg{font-family:Inter UI,-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;font-size:12px}.ml-explorer-chart-container .ml-explorer-chart-svg .line-chart rect{fill:#fff;opacity:1}.ml-explorer-chart-container .ml-explorer-chart-svg .line-chart rect.selected-interval{fill:#c8c8c81a;stroke:#69707d;stroke-width:2px;stroke-opacity:.8}.ml-explorer-chart-container .ml-explorer-chart-svg .line-chart rect.scheduled-event-marker{stroke-width:1px;stroke:#69707d;fill:#d3dae6;pointer-events:none}.ml-explorer-chart-container .axis line,.ml-explorer-chart-container .axis path{fill:none;stroke:#d3dae6;shape-rendering:crispEdges}.ml-explorer-chart-container .axis .tick line.ml-tick-emphasis{stroke:#0003}.ml-explorer-chart-container .axis text{fill:#69707d}.ml-explorer-chart-container .axis .tick line{stroke:#d3dae6;stroke-width:1px}.ml-explorer-chart-container .values-line{fill:none;stroke:#07c;stroke-width:2}.ml-explorer-chart-container .values-dots circle,.ml-explorer-chart-container .values-dots-circle{fill:#07c;stroke-width:0}.ml-explorer-chart-container .values-dots circle.values-dots-circle-blur{fill:#98a2b3}.ml-explorer-chart-container .metric-value{fill:#0000;stroke:#07c;stroke-width:0;opacity:1}.ml-explorer-chart-container .anomaly-marker{stroke-width:1px;stroke:#98a2b3}.ml-explorer-chart-container .anomaly-marker:hover{stroke-width:6px;stroke:#07c}.ml-explorer-chart-container .anomaly-marker.critical{fill:#fe5050}.ml-explorer-chart-container .anomaly-marker.major{fill:#fba740}.ml-explorer-chart-container .anomaly-marker.minor{fill:#fdec25}.ml-explorer-chart-container .anomaly-marker.warning{fill:#8bc8fb}.ml-explorer-chart-container .anomaly-marker.low{fill:#d2e9f7}.ml-explorer-chart-container .anomaly-marker:hover,.ml-explorer-chart-container .metric-value:hover{stroke-width:6px;stroke-opacity:.65}.ml-explorer-chart{overflow:hidden}.ml-explorer-chart-content-wrapper{height:215px}.ml-explorer-chart-axis-emphasis{font-weight:700}",""]),e.exports=t},640:function(e,t,r){switch(window.__kbnThemeTag__){case"v8dark":return r(641);case"v8light":return r(643)}},641:function(e,t,r){var a=r(103),i=r(642);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);a(i,{insert:"head",singleton:!1}),e.exports=i.locals||{}},642:function(e,t,r){(t=r(104)(!1)).push([e.i,".ml-explorer-chart-eui-icon-tip{max-width:none}.ml-explorer-chart-label-badges{align-items:center;display:flex;margin-top:4px}",""]),e.exports=t},643:function(e,t,r){var a=r(103),i=r(644);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);a(i,{insert:"head",singleton:!1}),e.exports=i.locals||{}},644:function(e,t,r){(t=r(104)(!1)).push([e.i,".ml-explorer-chart-eui-icon-tip{max-width:none}.ml-explorer-chart-label-badges{align-items:center;display:flex;margin-top:4px}",""]),e.exports=t},645:function(e,t,r){switch(window.__kbnThemeTag__){case"v8dark":return r(646);case"v8light":return r(648)}},646:function(e,t,r){var a=r(103),i=r(647);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);a(i,{insert:"head",singleton:!1}),e.exports=i.locals||{}},647:function(e,t,r){(t=r(104)(!1)).push([e.i,".ml-explorer-chart-info-tooltip{max-width:384px}.ml-explorer-chart-description{font-size:12px;font-style:italic}.ml-explorer-chart-info-tooltip .mlDescriptionList>*{margin-top:4px}.ml-explorer-chart-info-tooltip .mlDescriptionList{display:grid;grid-template-columns:max-content auto}.ml-explorer-chart-info-tooltip .mlDescriptionList .mlDescriptionList__title{color:#fff;font-size:12px;font-weight:400;grid-column-start:1;white-space:nowrap}.ml-explorer-chart-info-tooltip .mlDescriptionList .mlDescriptionList__description{color:#fff;font-size:12px;font-weight:700;grid-column-start:2;max-width:256px;padding-left:8px}",""]),e.exports=t},648:function(e,t,r){var a=r(103),i=r(649);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);a(i,{insert:"head",singleton:!1}),e.exports=i.locals||{}},649:function(e,t,r){(t=r(104)(!1)).push([e.i,".ml-explorer-chart-info-tooltip{max-width:384px}.ml-explorer-chart-description{font-size:12px;font-style:italic}.ml-explorer-chart-info-tooltip .mlDescriptionList>*{margin-top:4px}.ml-explorer-chart-info-tooltip .mlDescriptionList{display:grid;grid-template-columns:max-content auto}.ml-explorer-chart-info-tooltip .mlDescriptionList .mlDescriptionList__title{color:#fff;font-size:12px;font-weight:400;grid-column-start:1;white-space:nowrap}.ml-explorer-chart-info-tooltip .mlDescriptionList .mlDescriptionList__description{color:#fff;font-size:12px;font-weight:700;grid-column-start:2;max-width:256px;padding-left:8px}",""]),e.exports=t},650:function(e,t,r){switch(window.__kbnThemeTag__){case"v8dark":return r(651);case"v8light":return r(653)}},651:function(e,t,r){var a=r(103),i=r(652);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);a(i,{insert:"head",singleton:!1}),e.exports=i.locals||{}},652:function(e,t,r){(t=r(104)(!1)).push([e.i,".filter-button{height:16px;opacity:.5;transform:translateY(-1px);width:16px}.filter-button .euiIcon{height:12px;width:12px}.filter-button:hover{opacity:1}",""]),e.exports=t},653:function(e,t,r){var a=r(103),i=r(654);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);a(i,{insert:"head",singleton:!1}),e.exports=i.locals||{}},654:function(e,t,r){(t=r(104)(!1)).push([e.i,".filter-button{height:16px;opacity:.5;transform:translateY(-1px);width:16px}.filter-button .euiIcon{height:12px;width:12px}.filter-button:hover{opacity:1}",""]),e.exports=t}}]);