/*! 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.apm_bundle_jsonpfunction=window.apm_bundle_jsonpfunction||[]).push([[18,20],{1049:function(e,t,a){"use strict";a.r(t);var s=a(1),n=a.n(s),i=a(19),l=a.n(i);let r,o;!function(e){e._ID="_id",e._INDEX="_index",e._SOURCE="_source",e._TYPE="_type",e.STRING="string",e.TEXT="text",e.MATCH_ONLY_TEXT="match_only_text",e.KEYWORD="keyword",e.VERSION="version",e.BOOLEAN="boolean",e.OBJECT="object",e.DATE="date",e.DATE_NANOS="date_nanos",e.DATE_RANGE="date_range",e.GEO_POINT="geo_point",e.GEO_SHAPE="geo_shape",e.FLOAT="float",e.HALF_FLOAT="half_float",e.SCALED_FLOAT="scaled_float",e.DOUBLE="double",e.INTEGER="integer",e.LONG="long",e.SHORT="short",e.UNSIGNED_LONG="unsigned_long",e.AGGREGATE_METRIC_DOUBLE="aggregate_metric_double",e.FLOAT_RANGE="float_range",e.DOUBLE_RANGE="double_range",e.INTEGER_RANGE="integer_range",e.LONG_RANGE="long_range",e.NESTED="nested",e.BYTE="byte",e.IP="ip",e.IP_RANGE="ip_range",e.ATTACHMENT="attachment",e.TOKEN_COUNT="token_count",e.MURMUR3="murmur3",e.HISTOGRAM="histogram"}(r||(r={})),function(e){e._SOURCE="_source",e.ATTACHMENT="attachment",e.BOOLEAN="boolean",e.DATE="date",e.DATE_RANGE="date_range",e.GEO_POINT="geo_point",e.GEO_SHAPE="geo_shape",e.IP="ip",e.IP_RANGE="ip_range",e.MURMUR3="murmur3",e.NUMBER="number",e.NUMBER_RANGE="number_range",e.STRING="string",e.UNKNOWN="unknown",e.CONFLICT="conflict",e.OBJECT="object",e.NESTED="nested",e.HISTOGRAM="histogram",e.MISSING="missing"}(o||(o={}));class kbn_field_type_KbnFieldType{constructor(e={}){l()(this,"name",void 0),l()(this,"sortable",void 0),l()(this,"filterable",void 0),l()(this,"esTypes",void 0),this.name=e.name||o.UNKNOWN,this.sortable=e.sortable||!1,this.filterable=e.filterable||!1,this.esTypes=Object.freeze((e.esTypes||[]).slice())}}new kbn_field_type_KbnFieldType({name:o.UNKNOWN});const u=(new kbn_field_type_KbnFieldType({name:o.STRING,sortable:!0,filterable:!0,esTypes:[r.STRING,r.TEXT,r.MATCH_ONLY_TEXT,r.KEYWORD,r.VERSION,r._TYPE,r._ID]}),new kbn_field_type_KbnFieldType({name:o.NUMBER,sortable:!0,filterable:!0,esTypes:[r.FLOAT,r.HALF_FLOAT,r.SCALED_FLOAT,r.DOUBLE,r.INTEGER,r.LONG,r.UNSIGNED_LONG,r.SHORT,r.BYTE,r.TOKEN_COUNT,r.AGGREGATE_METRIC_DOUBLE]}),new kbn_field_type_KbnFieldType({name:o.NUMBER_RANGE,sortable:!0,filterable:!0,esTypes:[r.FLOAT_RANGE,r.DOUBLE_RANGE,r.INTEGER_RANGE,r.LONG_RANGE]}),new kbn_field_type_KbnFieldType({name:o.DATE,sortable:!0,filterable:!0,esTypes:[r.DATE,r.DATE_NANOS]}),new kbn_field_type_KbnFieldType({name:o.DATE_RANGE,sortable:!0,filterable:!0,esTypes:[r.DATE_RANGE]}),new kbn_field_type_KbnFieldType({name:o.IP,sortable:!0,filterable:!0,esTypes:[r.IP]}),new kbn_field_type_KbnFieldType({name:o.IP_RANGE,sortable:!0,filterable:!0,esTypes:[r.IP_RANGE]}),new kbn_field_type_KbnFieldType({name:o.BOOLEAN,sortable:!0,filterable:!0,esTypes:[r.BOOLEAN]}),new kbn_field_type_KbnFieldType({name:o.OBJECT,esTypes:[r.OBJECT]}),new kbn_field_type_KbnFieldType({name:o.NESTED,esTypes:[r.NESTED]}),new kbn_field_type_KbnFieldType({name:o.GEO_POINT,esTypes:[r.GEO_POINT]}),new kbn_field_type_KbnFieldType({name:o.GEO_SHAPE,esTypes:[r.GEO_SHAPE]}),new kbn_field_type_KbnFieldType({name:o.ATTACHMENT,esTypes:[r.ATTACHMENT]}),new kbn_field_type_KbnFieldType({name:o.MURMUR3,esTypes:[r.MURMUR3]}),new kbn_field_type_KbnFieldType({name:o._SOURCE,esTypes:[r._SOURCE]}),new kbn_field_type_KbnFieldType({name:o.HISTOGRAM,filterable:!0,esTypes:[r.HISTOGRAM]}),new kbn_field_type_KbnFieldType({name:o.CONFLICT}),{META_FIELDS:"metaFields",DOC_HIGHLIGHT:"doc_table:highlight",QUERY_STRING_OPTIONS:"query:queryString:options",QUERY_ALLOW_LEADING_WILDCARDS:"query:allowLeadingWildcards",SEARCH_QUERY_LANGUAGE:"search:queryLanguage",SORT_OPTIONS:"sort:options",COURIER_IGNORE_FILTER_IF_FIELD_NOT_IN_INDEX:"courier:ignoreFilterIfFieldNotInIndex",COURIER_SET_REQUEST_PREFERENCE:"courier:setRequestPreference",COURIER_CUSTOM_REQUEST_PREFERENCE:"courier:customRequestPreference",COURIER_MAX_CONCURRENT_SHARD_REQUESTS:"courier:maxConcurrentShardRequests",SEARCH_INCLUDE_FROZEN:"search:includeFrozen",SEARCH_TIMEOUT:"search:timeout",HISTOGRAM_BAR_TARGET:"histogram:barTarget",HISTOGRAM_MAX_BARS:"histogram:maxBars",HISTORY_LIMIT:"history:limit",TIMEPICKER_REFRESH_INTERVAL_DEFAULTS:"timepicker:refreshIntervalDefaults",TIMEPICKER_QUICK_RANGES:"timepicker:quickRanges",TIMEPICKER_TIME_DEFAULTS:"timepicker:timeDefaults",FILTERS_PINNED_BY_DEFAULT:"filters:pinnedByDefault",FILTERS_EDITOR_SUGGEST_VALUES:"filterEditor:suggestValues",AUTOCOMPLETE_USE_TIMERANGE:"autocomplete:useTimeRange",AUTOCOMPLETE_VALUE_SUGGESTION_METHOD:"autocomplete:valueSuggestionMethod",DATE_FORMAT:"dateFormat",DATEFORMAT_TZ:"dateFormat:tz"});var d=a(47),c=a.n(d),m=a(17),b=a(37),p=a(39),g=a(0),f=a(23),_=a(484),E=a(477);var T=a(476),O=a(38);const j=({areExamples:e,buckets:t,dataView:a,field:i,sampledValuesCount:l,color:r=y(),"data-test-subj":o,onAddFilter:u,overrideFieldTopValueBar:d})=>{if(null==t||!t.length)return null;const c=a.getFormatterForField(i),b=v(S(t),l),p=t.some((e=>!Number.isInteger(e.count/l)));return Object(O.jsx)("div",{"data-test-subj":e?"unifiedFieldStats-exampleValueBuckets":"unifiedFieldStats-topValueBuckets"},Object(O.jsx)("div",{"data-test-subj":`${o}-topValues`},t.map(((e,t)=>{const a=e.key,n=c.convert(a);return Object(O.jsx)(s.Fragment,{key:a},t>0&&Object(O.jsx)(m.EuiSpacer,{size:"s"}),Object(O.jsx)(T.default,{field:i,fieldValue:a,formattedFieldValue:n,formattedPercentage:h(e.count,l,p),progressValue:F(e.count,l),count:e.count,color:r,"data-test-subj":o,onAddFilter:u,overrideFieldTopValueBar:d}))})),b>0&&Object(O.jsx)(n.a.Fragment,null,Object(O.jsx)(m.EuiSpacer,{size:"s"}),Object(O.jsx)(T.default,{type:"other",field:i,fieldValue:void 0,formattedPercentage:h(b,l,p),progressValue:F(b,l),count:b,color:r,"data-test-subj":o,onAddFilter:u,overrideFieldTopValueBar:d}))))},y=()=>Object(m.euiPaletteColorBlind)()[1],h=(e,t,a)=>t>0?`${(Math.round(e/t*1e3)/10).toFixed(a?1:0)}%`:"",F=(e,t)=>t>0?e/t:0,S=e=>(null==e?void 0:e.reduce(((e,t)=>t.count+e),0))||0,v=(e,t)=>t&&e?t-e:0,x=({message:e})=>Object(O.jsx)(m.EuiText,{size:"s"},e),A=({dataView:e,field:t,numberSummary:a,"data-test-subj":s})=>{if(!a||!R(a))return null;const n=e.getFormatterForField(t),i=[{key:"min",label:g.i18n.translate("unifiedFieldList.fieldStats.numberSummary.minLabel",{defaultMessage:"min"}),value:n.convert(a.minValue,"text")},{key:"max",label:g.i18n.translate("unifiedFieldList.fieldStats.numberSummary.maxLabel",{defaultMessage:"max"}),value:n.convert(a.maxValue,"text")}],l=[{field:"label",name:"",align:m.LEFT_ALIGNMENT},{field:"value",name:"",render:e=>Object(O.jsx)("strong",null,e),align:m.RIGHT_ALIGNMENT}],r=g.i18n.translate("unifiedFieldList.fieldStats.numberSummary.summaryTableTitle",{defaultMessage:"Summary"});return Object(O.jsx)(m.EuiBasicTable,{compressed:!0,items:i,columns:l,tableCaption:r,"data-test-subj":`${s}-numberSummary`,responsive:!1,css:Object(O.css)("& .euiTableHeaderCell{",Object(m.euiScreenReaderOnly)(),";}& .euiTableRowCell{border-top:none;}","")})};function R(e){return"number"==typeof(null==e?void 0:e.minValue)&&"number"==typeof(null==e?void 0:e.maxValue)}class error_boundary_ErrorBoundary extends n.a.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?null:this.props.children}}const N=({services:e,query:t,dslQuery:i,filters:l,fromDate:d,toDate:T,dataViewOrDataViewId:h,field:F,color:N=y(),"data-test-subj":I="fieldStats",overrideMissingContent:D,overrideFooter:L,onAddFilter:k,overrideFieldTopValueBar:G,onStateChange:w})=>{const{fieldFormats:M,uiSettings:C,charts:V,dataViews:U,data:B}=e,[P,z]=Object(s.useState)({isLoading:!1}),[H,K]=Object(s.useState)(null),$=Object(s.useRef)(null),Y=Object(s.useRef)(!1),W=Object(s.useCallback)((e=>{Y.current||z(e)}),[z,Y]);Object(s.useEffect)((function(){w&&w(P)}),[w,P]);const Q=Object(s.useCallback)((e=>{Y.current||K(e)}),[K,Y]);Object(s.useEffect)((()=>{!async function(){var e;if(!Y.current)try{var s;const n="string"==typeof h?await U.get(h):h;if(Q(n),P.isLoading)return;W((e=>({...e,isLoading:!0}))),null===(s=$.current)||void 0===s||s.abort(),$.current=new AbortController;const r=await(async e=>{const{loadFieldStats:t}=await a.e(21).then(a.bind(null,1047));return await t(e)})({services:{data:B},dataView:n,field:F,fromDate:d,toDate:T,dslQuery:null!=i?i:Object(f.buildEsQuery)(n,null!=t?t:[],null!=l?l:[],(e=C,{allowLeadingWildcards:e.get(u.QUERY_ALLOW_LEADING_WILDCARDS),queryStringOptions:e.get(u.QUERY_STRING_OPTIONS),ignoreFilterIfFieldNotInIndex:e.get(u.COURIER_IGNORE_FILTER_IF_FIELD_NOT_IN_INDEX),dateFormatTZ:e.get("dateFormat:tz")})),abortController:$.current});$.current=null,W((e=>({...e,isLoading:!1,totalDocuments:r.totalDocuments,sampledDocuments:r.sampledDocuments,sampledValues:r.sampledValues,histogram:r.histogram,topValues:r.topValues,numberSummary:r.numberSummary})))}catch(e){W((e=>({...e,isLoading:!1})))}}()}),[h,F,i,t,l,d,T,e]),Object(s.useEffect)((()=>()=>{var e;Y.current=!0,null===(e=$.current)||void 0===e||e.abort()}),[]);const q=V.theme.useChartsTheme(),X=V.theme.useChartsBaseTheme(),J=Object(s.useMemo)((()=>{var e;return N?{...q,barSeriesStyle:{...q.barSeriesStyle,rect:{...(null===(e=q.barSeriesStyle)||void 0===e?void 0:e.rect)||{},fill:N}}}:q}),[q,N]),{isLoading:Z,histogram:ee,topValues:te,numberSummary:ae,sampledValues:se,sampledDocuments:ne,totalDocuments:ie}=P;let le=!!P.histogram;const re=c.a.parse(d),oe=c.a.parse(T),ue=S(null==te?void 0:te.buckets),de=v(ue,se);ue&&ee&&ee.buckets.length&&te&&te.buckets.length&&(le=de/ue>.9);const[ce,me]=Object(s.useState)(le);if(Z)return Object(O.jsx)(m.EuiLoadingSpinner,null);if(!H)return null;const be=H.getFormatterForField(F);let pe=Object(O.jsx)(n.a.Fragment,null);function ge(e){const t="unifiedFieldStats-statsFooter-docsCount",a=ie?Object(O.jsx)(m.EuiText,{color:"subdued",size:"xs","data-test-subj":`${I}-statsFooter`},ne&&ne{me("histogram"===e)},idSelected:ce?"histogram":"topValues"}),Object(O.jsx)(m.EuiSpacer,{size:"xs"})):"date"===F.type?pe=Object(O.jsx)(m.EuiTitle,{size:"xxxs"},Object(O.jsx)("h6",null,g.i18n.translate("unifiedFieldList.fieldStats.fieldTimeDistributionLabel",{defaultMessage:"Time distribution"}))):te&&te.buckets.length&&(pe=Object(O.jsx)(m.EuiTitle,{size:"xxxs"},Object(O.jsx)("h6",null,Object(_.c)(F)?g.i18n.translate("unifiedFieldList.fieldStats.examplesLabel",{defaultMessage:"Examples"}):g.i18n.translate("unifiedFieldList.fieldStats.topValuesLabel",{defaultMessage:"Top values"})))),ee&&ee.buckets.length){const e=g.i18n.translate("unifiedFieldList.fieldStats.countLabel",{defaultMessage:"Count"});if("date"===F.type)return ge(Object(O.jsx)("div",{"data-test-subj":"unifiedFieldStats-timeDistribution"},Object(O.jsx)("div",{"data-test-subj":`${I}-histogram`},Object(O.jsx)(p.Chart,{size:{height:200,width:268}},Object(O.jsx)(p.Tooltip,{type:p.TooltipType.None}),Object(O.jsx)(p.Settings,{theme:J,baseTheme:X,xDomain:re&&oe?{min:re.valueOf(),max:oe.valueOf(),minInterval:Math.round((oe.valueOf()-re.valueOf())/10)}:void 0}),Object(O.jsx)(p.Axis,{id:"key",position:p.Position.Bottom,tickFormat:re&&oe?Object(p.niceTimeFormatter)([re.valueOf(),oe.valueOf()]):void 0,showOverlappingTicks:!0}),Object(O.jsx)(p.HistogramBarSeries,{data:ee.buckets,id:e,xAccessor:"key",yAccessors:["count"],xScaleType:p.ScaleType.Time,yScaleType:p.ScaleType.Linear,timeZone:"local"})))));if(ce||!te||!te.buckets.length)return ge(Object(O.jsx)("div",{"data-test-subj":"unifiedFieldStats-histogram"},Object(O.jsx)(p.Chart,{"data-test-subj":`${I}-histogram`,size:{height:200,width:"100%"}},Object(O.jsx)(p.Tooltip,{type:p.TooltipType.None}),Object(O.jsx)(p.Settings,{rotation:90,theme:J,baseTheme:X}),Object(O.jsx)(p.Axis,{id:"key",position:p.Position.Left,showOverlappingTicks:!0,tickFormat:e=>be.convert(e)}),Object(O.jsx)(p.HistogramBarSeries,{data:ee.buckets,id:e,xAccessor:"key",yAccessors:["count"],xScaleType:p.ScaleType.Linear,yScaleType:p.ScaleType.Linear}))))}return te&&te.buckets.length?ge(Object(O.jsx)(j,{areExamples:Object(_.c)(F),buckets:te.buckets,dataView:H,field:F,sampledValuesCount:se,color:N,"data-test-subj":I,onAddFilter:k,overrideFieldTopValueBar:G})):null};t.default=e=>Object(O.jsx)(error_boundary_ErrorBoundary,null,Object(O.jsx)(N,e))},476:function(e,t,a){"use strict";a.r(t);var s=a(81),n=a.n(s),i=(a(1),a(17)),l=a(0),r=a(38),o={name:"5iz1wr",styles:"width:48px"},u={name:"ovk77c",styles:"min-width:0"};t.default=({"data-test-subj":e,onAddFilter:t,overrideFieldTopValueBar:a,...s})=>{var d,c,m,b;const p=a?a(s):{},{field:g,type:f,fieldValue:_,formattedFieldValue:E,formattedPercentage:T,progressValue:O,count:j,color:y,textProps:h={}}={...s,...p},F=null!==(d=null==g||null===(c=g.subType)||void 0===c||null===(m=c.multi)||void 0===m?void 0:m.parent)&&void 0!==d?d:g.name;return Object(r.jsx)(i.EuiFlexGroup,{alignItems:"stretch",gutterSize:"s",responsive:!1,"data-test-subj":`${e}-topValues-bucket`},Object(r.jsx)(i.EuiFlexItem,{grow:1,css:u},Object(r.jsx)(i.EuiFlexGroup,{alignItems:"stretch",gutterSize:"s",responsive:!1},Object(r.jsx)(i.EuiFlexItem,{grow:!0,className:"eui-textTruncate","data-test-subj":`${e}-topValues-formattedFieldValue`},(null!==(b=null==E?void 0:E.length)&&void 0!==b?b:0)>0?Object(r.jsx)(i.EuiToolTip,{content:E,delay:"long"},Object(r.jsx)(i.EuiText,n()({size:"xs",className:"eui-textTruncate",color:"subdued"},h),E)):Object(r.jsx)(i.EuiText,{size:"xs"},"other"===f?l.i18n.translate("unifiedFieldList.fieldStats.otherDocsLabel",{defaultMessage:"Other"}):""===E?l.i18n.translate("unifiedFieldList.fieldStats.emptyStringValueLabel",{defaultMessage:"(empty)"}):"-")),Object(r.jsx)(i.EuiFlexItem,{grow:!1,"data-test-subj":`${e}-topValues-formattedPercentage`},Object(r.jsx)(i.EuiToolTip,{content:l.i18n.translate("unifiedFieldList.fieldStats.bucketPercentageTooltip",{defaultMessage:"{formattedPercentage} ({count, plural, one {# record} other {# records}})",values:{formattedPercentage:T,count:j}}),delay:"long"},Object(r.jsx)(i.EuiText,{size:"xs",textAlign:"left",color:y},T)))),Object(r.jsx)(i.EuiProgress,{value:O,max:1,size:"s",color:"other"===f?"subdued":y,"aria-label":`${E} (${T})`})),t&&g.filterable&&Object(r.jsx)(i.EuiFlexItem,{grow:!1},"other"===f?Object(r.jsx)("div",{css:o}):Object(r.jsx)("div",null,Object(r.jsx)(i.EuiButtonIcon,{iconSize:"s",iconType:"plusInCircle",onClick:()=>t(g,_,"+"),"aria-label":l.i18n.translate("unifiedFieldList.fieldStats.filterValueButtonAriaLabel",{defaultMessage:'Filter for {field}: "{value}"',values:{value:E,field:F}}),"data-test-subj":`plus-${F}-${_}`,style:{minHeight:"auto",minWidth:"auto",paddingRight:2,paddingLeft:2,paddingTop:0,paddingBottom:0}}),Object(r.jsx)(i.EuiButtonIcon,{iconSize:"s",iconType:"minusInCircle",onClick:()=>t(g,_,"-"),"aria-label":l.i18n.translate("unifiedFieldList.fieldStats.filterOutValueButtonAriaLabel",{defaultMessage:'Filter out {field}: "{value}"',values:{value:E,field:F}}),"data-test-subj":`minus-${F}-${_}`,style:{minHeight:"auto",minWidth:"auto",paddingTop:0,paddingBottom:0,paddingRight:2,paddingLeft:2}}))))}},477:function(e,t,a){"use strict";a.d(t,"a",(function(){return u})),a.d(t,"d",(function(){return d})),a.d(t,"c",(function(){return m})),a.d(t,"b",(function(){return b}));var s=a(47),n=a.n(s),i=a(484);const l=5e3,r=10,o=100;function u({dataViewPattern:e,timeFieldName:t,fromDate:a,toDate:s,dslQuery:n,runtimeMappings:i,aggs:l,fields:r,size:o}){const u=t?[{range:{[t]:{gte:a,lte:s,format:"strict_date_optional_time"}}},n]:[n];return 1===(null==r?void 0:r.length)&&u.push({exists:r[0]}),{index:e,body:{query:{bool:{filter:u}},aggs:l,fields:r,runtime_mappings:i,_source:(null==r||!r.length)&&void 0},track_total_hits:!0,size:null!=o?o:0}}async function d({searchHandler:e,dataView:t,field:a,fromDate:s,toDate:o,size:u}){return a.aggregatable?"geo_point"===a.type||"geo_shape"===a.type?await async function(e,t,a){try{const s=a.getFormatterForField(t);return await g(e,t,a,s)}catch(e){return console.error(e),{}}}(e,a,t):c(a)?"histogram"===a.type?await p(e,a,!1):b(a)?await async function(e,t){const a={sample:{sampler:{shard_size:l},aggs:{min_max_summary:{filter:{exists:{field:t.name}},aggs:{min:{min:{field:t.name}},max:{max:{field:t.name}}}}}}},s=await e({aggs:a}),n=s.aggregations.sample.min_max_summary.min.value,i=s.aggregations.sample.min_max_summary.max.value,r=s.aggregations.sample.doc_count;return{totalDocuments:_(s),sampledDocuments:r,sampledValues:r,numberSummary:{minValue:n,maxValue:i}}}(e,a):"number"===a.type?await p(e,a):"date"===a.type?await async function(e,t,a){const s=n.a.parse(a.fromDate),i=n.a.parse(a.toDate);if(!s)throw Error("Invalid fromDate value");if(!i)throw Error("Invalid toDate value");const l=Math.round((i.valueOf()-s.valueOf())/10);if(l<1)return{totalDocuments:0,histogram:{buckets:[]}};const r=`${l}ms`,o={histo:{date_histogram:{...f(t),fixed_interval:r}}},u=await e({aggs:o});return{totalDocuments:_(u),histogram:{buckets:u.aggregations.histo.buckets.map((e=>({count:e.doc_count,key:e.key})))}}}(e,a,{fromDate:s,toDate:o}):await async function(e,t,a=r){const s=f(t),n={sample:{sampler:{shard_size:l},aggs:{sample_count:{value_count:{...s}},top_values:{terms:{...s,size:a,shard_size:a<=10?25:void 0}}}}},i=await e({aggs:n}),o={buckets:i.aggregations.sample.top_values.buckets.map((e=>({count:e.doc_count,key:e.key})))};return{totalDocuments:_(i),sampledDocuments:i.aggregations.sample.doc_count,sampledValues:E(o,i.aggregations.sample.top_values.sum_other_doc_count)||i.aggregations.sample.sample_count.value,topValues:o}}(e,a,u):{}:Object(i.a)(a)?await g(e,a,t):{}}function c(e){return!("document"===e.type||e.type.includes("range")||"geo_point"===e.type||"geo_shape"===e.type||"murmur3"===e.type||"attachment"===e.type)}function m(e){return e.aggregatable&&c(e)||Object(i.c)(e)}function b(e){return"counter"===e.timeSeriesMetric}async function p(e,t,a=!0){const s=f(t),n={min_value:{min:{field:t.name}},max_value:{max:{field:t.name}},sample_count:{value_count:{...s}}},i={sample:{sampler:{shard_size:l},aggs:{...n}}},o={sample:{sampler:{shard_size:l},aggs:{...n,top_values:{terms:{...s,size:r}}}}},u=await e({aggs:a?o:i}),d=u.aggregations.sample.min_value.value,c=u.aggregations.sample.max_value.value,m="top_values"in u.aggregations.sample?u.aggregations.sample.top_values:{buckets:[],sum_other_doc_count:0},b={buckets:m.buckets.map((e=>({count:e.doc_count,key:e.key})))};let p=(c-d)/10;if(Number.isInteger(d)&&Number.isInteger(c)&&(p=Math.ceil(p)),0===p)return{totalDocuments:_(u),sampledValues:E(b,m.sum_other_doc_count)||u.aggregations.sample.sample_count.value,sampledDocuments:u.aggregations.sample.doc_count,topValues:b,histogram:a?{buckets:[]}:{buckets:[{count:u.aggregations.sample.doc_count,key:d}]}};const g={sample:{sampler:{shard_size:l},aggs:{histo:{histogram:{field:t.name,interval:p}}}}},T=await e({aggs:g});return{totalDocuments:_(u),sampledDocuments:u.aggregations.sample.doc_count,sampledValues:E(b,m.sum_other_doc_count)||u.aggregations.sample.sample_count.value,histogram:{buckets:T.aggregations.sample.histo.buckets.map((e=>({count:e.doc_count,key:e.key})))},topValues:b}}async function g(e,t,a,s){try{const n=f(t),l={size:o,fields:[n]},u=await e(l),d=Object(i.b)({hits:u.hits.hits,field:t,dataView:a,count:r},s);return{totalDocuments:_(u),sampledDocuments:d.sampledDocuments,sampledValues:d.sampledValues,topValues:{buckets:d.buckets}}}catch(e){return console.error(e),{}}}function f(e){return e.scripted?{script:{lang:e.lang,source:e.script}}:{field:e.name}}const _=e=>{var t,a;return null!==(t=null!==(a=e.hits.total.value)&&void 0!==a?a:e.hits.total)&&void 0!==t?t:0};function E(e,t){var a;return((null==e||null===(a=e.buckets)||void 0===a?void 0:a.reduce(((e,t)=>t.count+e),0))||0)+(t||0)}},484:function(e,t,a){"use strict";a.d(t,"a",(function(){return i})),a.d(t,"c",(function(){return l})),a.d(t,"b",(function(){return r}));var s=a(9);const n=["_type","_source"];const i=e=>"_score"!==e.name&&["string","text","keyword","version","ip","number","geo_point","geo_shape"].includes(e.type),l=e=>!e.aggregatable&&i(e)||"geo_point"===e.type||"geo_shape"===e.type;function r(e,t){if(e=Object(s.defaults)(e,{count:5}),!i(e.field))throw new Error(`Analysis is not available this field type: "${e.field.type}". Field name: "${e.field.name}"`);const a=(l=e.hits,r=e.field,o=e.dataView,Object(s.map)(l,(function(e){return function(e,t,a){var i;const l={};function r(e,n=""){for(const[i,o]of Object.entries(e)){const e=n+i,u=null==t?void 0:t.fields.getByName(e);if(!1===(null==a?void 0:a.shallow)){const t="nested"===(null==u?void 0:u.type);if(Array.isArray(o)&&!t){o.forEach((t=>Object(s.isPlainObject)(t)&&r(t,e+".")));continue}}else if(void 0!==l[e])continue;const d=u&&"conflict"!==u.type,c=!Object(s.isPlainObject)(o);d||c?l[e]?Array.isArray(l[e])?l[e].push(o):l[e]=[l[e],o]:l[e]=o:r(o,e+".")}}return r(e.fields||{}),!1!==(null==a?void 0:a.source)&&e._source?r(e._source):null!=a&&a.includeIgnoredValues&&e.ignored_field_values&&Object.entries(e.ignored_field_values).forEach((([e,t])=>{l[e]?Array.isArray(l[e])?l[e]=[...l[e],...t]:l[e]=[l[e],...t]:l[e]=t})),null==t||null===(i=t.metaFields)||void 0===i||i.forEach((t=>{n.includes(t)||"_"!==t.charAt(0)||(l[t]=e[t])})),new Proxy(l,{ownKeys:e=>Reflect.ownKeys(e).sort(((e,a)=>{var s,n;const i=null==t||null===(s=t.metaFields)||void 0===s?void 0:s.includes(String(e)),l=null==t||null===(n=t.metaFields)||void 0===n?void 0:n.includes(String(a));return i&&l?String(e).localeCompare(String(a)):i?1:l?-1:String(e).localeCompare(String(a))}))})}(e,o,{includeIgnoredValues:!0})[r.name]})));var l,r,o;const{groups:u,sampledValues:d}=function(e,t){const a={};let n=0;return e.forEach((function(e){if(Object(s.isObject)(e)&&!Array.isArray(e))throw new Error("Analysis is not available for object fields.");let i,l=0;const r={};i=Array.isArray(e)?e:null==e?[]:[e],i.forEach((e=>{const s=t?t.convert(e):e;r[s]||(a.hasOwnProperty(s)?a[s].count++:a[s]={key:s,count:1,order:l++},r[s]=!0,n++)}))})),{groups:a,sampledValues:n}}(a,t);return{buckets:Object(s.sortBy)(u,["count","order"]).reverse().slice(0,e.count).map((e=>Object(s.pick)(e,["key","count"]))),sampledValues:d,sampledDocuments:e.hits.length}}}}]);