elasticsearchPlugin.088f0f9cf1a569c3df3c.js 123 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. (self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[9897],{75054:(e,t,s)=>{"use strict";s.r(t),s.d(t,{plugin:()=>ks});var i=s(43215),n=s(36636),r=s(68404),a=s(69783);const l=(e,t,s)=>(0,r.useCallback)((i=>{e(s(t,i))}),[e,t,s]),o=(0,r.createContext)(void 0),u=()=>{const e=(0,r.useContext)(o);if(!e)throw new Error("Use DispatchContext first.");return e},c=e=>({name:e,pipelineAgg:""}),d=e=>`var${Math.max(0,...e.map((e=>{var t;return parseInt((null===(t=e.name.match("^var(\\d+)$"))||void 0===t?void 0:t[1])||"0",10)})))+1}`,h=e=>{var t;return"ewma"===(null===(t=e.settings)||void 0===t?void 0:t.model)},p=e=>{var t;return"holt"===(null===(t=e.settings)||void 0===t?void 0:t.model)},g=e=>{var t;return"holt_winters"===(null===(t=e.settings)||void 0===t?void 0:t.model)},m=e=>{var t;return["holt","ewma","holt_winters"].includes((null===(t=e.settings)||void 0===t?void 0:t.model)||"")},v=e=>I[e.type].requiresField,f=e=>I[e.type].isPipelineAgg,b=e=>I[e.type].supportsMultipleBucketPaths,y=e=>I[e.type].supportsMissing,x=e=>I[e.type].hasSettings,j=e=>I[e.type].supportsInlineScript,E=["count","avg","sum","min","max","extended_stats","percentiles","cardinality","raw_document","raw_data","logs","moving_avg","moving_fn","derivative","serial_diff","cumulative_sum","bucket_script","rate","top_metrics"],I={count:{label:"Count",requiresField:!1,isPipelineAgg:!1,supportsMissing:!1,supportsMultipleBucketPaths:!1,hasSettings:!1,hasMeta:!1,supportsInlineScript:!1,defaults:{}},avg:{label:"Average",requiresField:!0,supportsInlineScript:!0,supportsMissing:!0,isPipelineAgg:!1,supportsMultipleBucketPaths:!1,hasSettings:!0,hasMeta:!1,defaults:{}},sum:{label:"Sum",requiresField:!0,supportsInlineScript:!0,supportsMissing:!0,isPipelineAgg:!1,supportsMultipleBucketPaths:!1,hasSettings:!0,hasMeta:!1,defaults:{}},max:{label:"Max",requiresField:!0,supportsInlineScript:!0,supportsMissing:!0,isPipelineAgg:!1,supportsMultipleBucketPaths:!1,hasSettings:!0,hasMeta:!1,defaults:{}},min:{label:"Min",requiresField:!0,supportsInlineScript:!0,supportsMissing:!0,isPipelineAgg:!1,supportsMultipleBucketPaths:!1,hasSettings:!0,hasMeta:!1,defaults:{}},extended_stats:{label:"Extended Stats",requiresField:!0,supportsMissing:!0,supportsInlineScript:!0,isPipelineAgg:!1,supportsMultipleBucketPaths:!1,hasSettings:!0,hasMeta:!0,defaults:{meta:{std_deviation_bounds_lower:!0,std_deviation_bounds_upper:!0}}},percentiles:{label:"Percentiles",requiresField:!0,supportsMissing:!0,supportsInlineScript:!0,isPipelineAgg:!1,supportsMultipleBucketPaths:!1,hasSettings:!0,hasMeta:!1,defaults:{settings:{percents:["25","50","75","95","99"]}}},cardinality:{label:"Unique Count",requiresField:!0,supportsMissing:!0,isPipelineAgg:!1,supportsMultipleBucketPaths:!1,hasSettings:!0,supportsInlineScript:!1,hasMeta:!1,defaults:{}},moving_avg:{label:"Moving Average",requiresField:!0,isPipelineAgg:!0,versionRange:">=2.0.0 <8.0.0",supportsMissing:!1,supportsMultipleBucketPaths:!1,hasSettings:!0,supportsInlineScript:!1,hasMeta:!1,defaults:{settings:{model:"simple",window:"5"}}},moving_fn:{label:"Moving Function",requiresField:!0,isPipelineAgg:!0,supportsMultipleBucketPaths:!1,supportsInlineScript:!1,supportsMissing:!1,hasMeta:!1,hasSettings:!0,versionRange:">=7.0.0",defaults:{}},derivative:{label:"Derivative",requiresField:!0,isPipelineAgg:!0,versionRange:">=2.0.0",supportsMissing:!1,supportsMultipleBucketPaths:!1,hasSettings:!0,supportsInlineScript:!1,hasMeta:!1,defaults:{}},serial_diff:{label:"Serial Difference",requiresField:!0,isPipelineAgg:!0,versionRange:">=2.0.0",supportsMissing:!1,supportsMultipleBucketPaths:!1,hasSettings:!0,supportsInlineScript:!1,hasMeta:!1,defaults:{settings:{lag:"1"}}},cumulative_sum:{label:"Cumulative Sum",requiresField:!0,isPipelineAgg:!0,versionRange:">=2.0.0",supportsMissing:!1,supportsMultipleBucketPaths:!1,hasSettings:!0,supportsInlineScript:!1,hasMeta:!1,defaults:{}},bucket_script:{label:"Bucket Script",requiresField:!1,isPipelineAgg:!0,supportsMissing:!1,supportsMultipleBucketPaths:!0,versionRange:">=2.0.0",hasSettings:!0,supportsInlineScript:!1,hasMeta:!1,defaults:{pipelineVariables:[c(d([]))]}},raw_document:{label:"Raw Document (legacy)",requiresField:!1,isSingleMetric:!0,isPipelineAgg:!1,supportsMissing:!1,supportsMultipleBucketPaths:!1,hasSettings:!0,supportsInlineScript:!1,hasMeta:!1,defaults:{settings:{size:"500"}}},raw_data:{label:"Raw Data",requiresField:!1,isSingleMetric:!0,isPipelineAgg:!1,supportsMissing:!1,supportsMultipleBucketPaths:!1,hasSettings:!0,supportsInlineScript:!1,hasMeta:!1,defaults:{settings:{size:"500"}}},logs:{label:"Logs",requiresField:!1,isPipelineAgg:!1,supportsMissing:!1,supportsMultipleBucketPaths:!1,hasSettings:!0,isSingleMetric:!0,supportsInlineScript:!1,hasMeta:!1,defaults:{settings:{limit:"500"}}},top_metrics:{label:"Top Metrics",xpack:!0,requiresField:!1,isPipelineAgg:!1,supportsMissing:!1,supportsMultipleBucketPaths:!1,hasSettings:!0,supportsInlineScript:!1,versionRange:">=7.7.0",hasMeta:!1,defaults:{settings:{order:"desc"}}},rate:{label:"Rate",xpack:!0,versionRange:">=7.10.0",requiresField:!0,isPipelineAgg:!1,supportsMissing:!1,supportsMultipleBucketPaths:!1,hasSettings:!0,supportsInlineScript:!0,hasMeta:!1,defaults:{}}},w={moving_avg:[{label:"window",default:5},{label:"model",default:"simple"},{label:"predict"},{label:"minimize",default:!1}],moving_fn:[{label:"window",default:5},{label:"script"}],derivative:[{label:"unit"}],serial_diff:[{label:"lag"}],cumulative_sum:[{label:"format"}],bucket_script:[]},_=(e,t)=>{const s=t.filter((t=>{var s;return b(t)?null===(s=t.pipelineVariables)||void 0===s?void 0:s.some((t=>t.pipelineAgg===e.id)):v(t)&&e.id===t.field}));return[...s,...s.flatMap((e=>_(e,t)))]},S=[{label:"Avg",value:"avg"},{label:"Min",value:"min"},{label:"Max",value:"max"},{label:"Sum",value:"sum"},{label:"Count",value:"count"},{label:"Std Dev",value:"std_deviation"},{label:"Std Dev Upper",value:"std_deviation_bounds_upper"},{label:"Std Dev Lower",value:"std_deviation_bounds_lower"}],O=[{label:"Simple",value:"simple"},{label:"Linear",value:"linear"},{label:"Exponentially Weighted",value:"ewma"},{label:"Holt Linear",value:"holt"},{label:"Holt Winters",value:"holt_winters"}],A="@HIGHLIGHT@",N="@/HIGHLIGHT@";function $(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"1";return{type:"count",id:e}}function F(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"1";return{type:"date_histogram",id:e,settings:{interval:"auto"}}}const R=(e,t)=>e.find((e=>e.id===t));function k(e,t){var s;return!(null==e||null===(s=e.metrics)||void 0===s||!s.some((e=>e.type===t)))}var D=s(10129);const C=e=>v(e)?`${I[e.type].label} ${e.field}`:I[e.type].label,T=e=>Object.entries(e).reduce(((e,t)=>{let[s,i]=t;if(null==i)return Object.assign({},e);if(Array.isArray(i)&&0===i.length)return Object.assign({},e);if(0===(null==i?void 0:i.length))return Object.assign({},e);if(!Array.isArray(i)&&"object"==typeof i){const t=T(i);return 0===Object.keys(t).length?Object.assign({},e):Object.assign({},e,{[s]:t})}return Object.assign({},e,{[s]:i})}),{}),L=e=>{const t=e.match(/^(\d+)/);return t?t[1]:void 0},M=e=>{var t,s,i,n;return("object"==typeof(null===(t=e.settings)||void 0===t?void 0:t.script)?null===(s=e.settings)||void 0===s||null===(i=s.script)||void 0===i?void 0:i.inline:null===(n=e.settings)||void 0===n?void 0:n.script)||""},P=e=>{if("string"==typeof e)return(0,D.valid)(e)||"5.0.0";switch(e){case 2:return"2.0.0";case 56:return"5.6.0";case 60:return"6.0.0";case 70:return"7.0.0";default:return"5.0.0"}},V=e=>!!(0,D.gte)(e,"7.10.0");var q=s(53772);const B=(0,q.PH)("@metrics/add"),U=(0,q.PH)("@metrics/remove"),G=(0,q.PH)("@metrics/toggle_visibility"),z=(0,q.PH)("@metrics/change_field"),H=(0,q.PH)("@metrics/change_type"),W=(0,q.PH)("@metrics/change_attr"),Q=(0,q.PH)("@metrics/change_setting"),K=(0,q.PH)("@metrics/change_meta"),X=(0,q.PH)("init"),J=(0,q.PH)("change_query"),Y=(0,q.PH)("change_alias_pattern"),Z=(e,t)=>J.match(t)?t.payload:X.match(t)?e||"":e,ee=(e,t)=>Y.match(t)?t.payload:X.match(t)?e||"":e,te={terms:{label:"Terms",requiresField:!0,defaultSettings:{min_doc_count:"1",size:"10",order:"desc",orderBy:"_term"}},filters:{label:"Filters",requiresField:!1,defaultSettings:{filters:[{label:"",query:"*"}]}},geohash_grid:{label:"Geo Hash Grid",requiresField:!0,defaultSettings:{precision:"3"}},date_histogram:{label:"Date Histogram",requiresField:!0,defaultSettings:{interval:"auto",min_doc_count:"0",trimEdges:"0",timeZone:i.InternalTimeZones.utc}},histogram:{label:"Histogram",requiresField:!0,defaultSettings:{interval:"1000",min_doc_count:"0"}}},se=[{label:"Term value",value:"_term"},{label:"Doc Count",value:"_count"}],ie=[{label:"Top",value:"desc"},{label:"Bottom",value:"asc"}],ne=[{label:"No limit",value:"0"},{label:"1",value:"1"},{label:"2",value:"2"},{label:"3",value:"3"},{label:"5",value:"5"},{label:"10",value:"10"},{label:"15",value:"15"},{label:"20",value:"20"}],re=(0,q.PH)("@bucketAggs/add"),ae=(0,q.PH)("@bucketAggs/remove"),le=(0,q.PH)("@bucketAggs/change_type"),oe=(0,q.PH)("@bucketAggs/change_field"),ue=(0,q.PH)("@bucketAggs/change_setting"),ce=(e,t)=>{if(B.match(t))return[...e,$(t.payload)];if(U.match(t)){const s=e.find((e=>e.id===t.payload)),i=[s,..._(s,e)],n=e.filter((e=>!i.some((t=>t.id===e.id))));return 0===n.length?[$("1")]:n}return H.match(t)?e.filter((e=>!I[t.payload.type].isSingleMetric||e.id===t.payload.id)).map((e=>e.id!==t.payload.id?e:Object.assign({id:e.id,type:t.payload.type},I[t.payload.type].defaults))):z.match(t)?e.map((e=>{if(e.id!==t.payload.id)return e;const s=Object.assign({},e,{field:t.payload.field});return f(e)?Object.assign({},s,{pipelineAgg:t.payload.field}):s})):G.match(t)?e.map((e=>e.id!==t.payload?e:Object.assign({},e,{hide:!e.hide}))):Q.match(t)?e.map((e=>{if(e.id!==t.payload.metric.id)return e;if(x(e)){const s=T(Object.assign({},e.settings,{[t.payload.settingName]:t.payload.newValue}));return Object.assign({},e,{settings:Object.assign({},s)})}return e})):K.match(t)?e.map((e=>e.id!==t.payload.metric.id?e:(e=>I[e.type].hasMeta)(e)?Object.assign({},e,{meta:Object.assign({},e.meta,{[t.payload.meta]:t.payload.newValue})}):e)):W.match(t)?e.map((e=>e.id!==t.payload.metric.id?e:Object.assign({},e,{[t.payload.attribute]:t.payload.newValue}))):X.match(t)?null!=e&&e.length?e:[$("1")]:e};var de=s(45916);const he=(0,r.createContext)(void 0),pe=(0,r.createContext)(void 0),ge=(0,r.createContext)(void 0),me=e=>{let{children:t,onChange:s,onRunQuery:i,query:n,datasource:a,range:u}=e;const c=(0,r.useCallback)((e=>{s(e),i()}),[s,i]),d=(h={query:Z,alias:ee,metrics:ce,bucketAggs:(p=a.timeField,(e,t)=>{if(re.match(t)){const s={id:t.payload,type:"terms",settings:te.terms.defaultSettings},i=e[e.length-1];return"date_histogram"===(null==i?void 0:i.type)?[...e.slice(0,e.length-1),s,i]:[...e,s]}return ae.match(t)?e.filter((e=>e.id!==t.payload)):le.match(t)?e.map((e=>e.id!==t.payload.id?e:{id:e.id,type:t.payload.newType,settings:te[t.payload.newType].defaultSettings})):oe.match(t)?e.map((e=>e.id!==t.payload.id?e:Object.assign({},e,{field:t.payload.newField}))):H.match(t)?I[t.payload.type].isSingleMetric?[]:0===e.length?[Object.assign({},F("2"),{field:p})]:e:ue.match(t)?e.map((e=>{if(e.id!==t.payload.bucketAgg.id)return e;const s=T(Object.assign({},e.settings,{[t.payload.settingName]:t.payload.newValue}));return Object.assign({},e,{settings:Object.assign({},s)})})):X.match(t)?null!=e&&e.length?e:[Object.assign({},F("2"),{field:p})]:e})},(e,t)=>{const s={};for(const i in h)s[i]=h[i](e[i],t);return s});var h,p;const g=l((e=>c(Object.assign({},n,e,{timeField:a.timeField}))),n,d);return n.metrics&&n.bucketAggs&&void 0!==n.query?(0,de.jsx)(he.Provider,{value:a,children:(0,de.jsx)(pe.Provider,{value:n,children:(0,de.jsx)(ge.Provider,{value:u,children:(0,de.jsx)(o.Provider,{value:g,children:t})})})}):(g(X()),null)},ve=e=>()=>{const t=(0,r.useContext)(e);if(!t)throw new Error("use ElasticsearchProvider first.");return t},fe=ve(pe),be=ve(he),ye=ve(ge),xe=e=>e.id,je=e=>parseInt(e,10),Ee=["iconName","onClick","className","label"];const Ie=n.css`
  2. clip: rect(0 0 0 0);
  3. clip-path: inset(50%);
  4. height: 1px;
  5. overflow: hidden;
  6. position: absolute;
  7. white-space: nowrap;
  8. width: 1px;
  9. `,we=e=>{let{iconName:t,onClick:s,className:i,label:r}=e,l=function(e,t){if(null==e)return{};var s,i,n={},r=Object.keys(e);for(i=0;i<r.length;i++)s=r[i],t.indexOf(s)>=0||(n[s]=e[s]);return n}(e,Ee);return(0,de.jsxs)("button",Object.assign({className:(0,n.cx)("gf-form-label gf-form-label--btn query-part",i),onClick:s},l,{children:[(0,de.jsx)("span",{className:Ie,children:r}),(0,de.jsx)(a.Icon,{name:t,"aria-hidden":"true"})]}))};var _e=s(82897);const Se=e=>{let{children:t,label:s,onRemoveClick:i,onHideClick:n,hidden:r=!1}=e;const l=(0,a.useStyles2)(Oe);return(0,de.jsxs)(a.InlineFieldRow,{children:[(0,de.jsx)(a.InlineSegmentGroup,{children:(0,de.jsxs)(a.InlineLabel,{width:17,as:"div",children:[(0,de.jsx)("span",{children:s}),(0,de.jsxs)("span",{className:l.iconWrapper,children:[n&&(0,de.jsx)(a.IconButton,{name:r?"eye-slash":"eye",onClick:n,size:"sm","aria-pressed":r,"aria-label":"hide metric",className:l.icon}),(0,de.jsx)(a.IconButton,{name:"trash-alt",size:"sm",className:l.icon,onClick:i||_e.noop,disabled:!i,"aria-label":"remove metric"})]})]})}),t]})},Oe=e=>({iconWrapper:n.css`
  10. display: flex;
  11. `,icon:n.css`
  12. color: ${e.colors.text.secondary};
  13. margin-left: ${e.spacing(.25)};
  14. `});var Ae=s(58788);const Ne=e=>te[e.type].requiresField,$e=["date_histogram","histogram","terms","filters","geohash_grid"],Fe=e=>{if(t=e,E.includes(t))return"cardinality"===e?[]:["number"];var t;if((e=>$e.includes(e))(e))switch(e){case"date_histogram":return["date"];case"geohash_grid":return["geo_point"];case"histogram":return["number"];default:return[]}return[]},Re=e=>{let{text:t}=e;return{label:t,value:t}},ke=e=>{const t=be(),s=ye(),i=Array.isArray(e)?e:Fe(e);let n;return async e=>(n||(n=await(0,Ae.n)(t.getFields(i,s))),n.filter((t=>{let{text:s}=t;return void 0===e||s.includes(e)})).map(Re))},De=n.css`
  15. min-width: 150px;
  16. `,Ce=e=>{let{label:t,children:s,hidden:i=!1}=e;const[l,o]=(0,r.useState)(!1),u=((e,t)=>({wrapper:n.css`
  17. max-width: 500px;
  18. display: flex;
  19. flex-direction: column;
  20. `,settingsWrapper:n.css`
  21. padding-top: ${e.spacing(.5)};
  22. `,icon:n.css`
  23. margin-right: ${e.spacing(.5)};
  24. `,button:n.css`
  25. justify-content: start;
  26. ${t&&n.css`
  27. color: ${e.colors.text.disabled};
  28. `}
  29. `}))((0,a.useTheme2)(),i);return(0,de.jsx)(a.InlineSegmentGroup,{children:(0,de.jsxs)("div",{className:(0,n.cx)(u.wrapper),children:[(0,de.jsxs)("button",{className:(0,n.cx)("gf-form-label query-part",u.button,De),onClick:()=>o(!l),"aria-expanded":l,children:[(0,de.jsx)(a.Icon,{name:l?"angle-down":"angle-right","aria-hidden":"true",className:u.icon}),t]}),l&&(0,de.jsx)("div",{className:u.settingsWrapper,children:s})]})})},Te=e=>{let{options:t,value:s,onChange:i}=e;const[n,a]=(0,r.useState)(((e,t)=>{return void 0===t||e.some((s=t,e=>{let{value:t}=e;return t===s}))?e:[...e,{value:t,label:t}];var s})(t,s));return{onCreateOption:e=>{var t;t=e,a([...n,{value:t,label:t}]),i({value:e})},onChange:i,allowCustomValue:!0,options:n,value:s}},Le=[{label:"auto",value:"auto"},{label:"10s",value:"10s"},{label:"1m",value:"1m"},{label:"5m",value:"5m"},{label:"10m",value:"10m"},{label:"20m",value:"20m"},{label:"1h",value:"1h"},{label:"1d",value:"1d"}],Me=(e,t,s)=>{var i;return!s.some((i=e,e=>{let{value:t}=e;return t===i}))&&e.trim().length>0},Pe=(e,t)=>{var s;return(null===(s=e.value)||void 0===s?void 0:s.startsWith(t))||!1},Ve=e=>{var t,s,n,l,o,c,d,h,p,g;let{bucketAgg:m}=e;const v=u(),{current:f}=(0,r.useRef)((0,_e.uniqueId)("es-date_histogram-"));return(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(a.InlineField,Object.assign({label:"Interval"},Ze,{children:(0,de.jsx)(a.Select,Object.assign({inputId:(0,_e.uniqueId)("es-date_histogram-interval"),isValidNewOption:Me,filterOption:Pe},Te({options:Le,value:(null===(t=m.settings)||void 0===t?void 0:t.interval)||(null===(s=te.date_histogram.defaultSettings)||void 0===s?void 0:s.interval),onChange:e=>{let{value:t}=e;return v(ue({bucketAgg:m,settingName:"interval",newValue:t}))}})))})),(0,de.jsx)(a.InlineField,Object.assign({label:"Min Doc Count"},Ze,{children:(0,de.jsx)(a.Input,{id:`${f}-min_doc_count`,onBlur:e=>v(ue({bucketAgg:m,settingName:"min_doc_count",newValue:e.target.value})),defaultValue:(null===(n=m.settings)||void 0===n?void 0:n.min_doc_count)||(null===(l=te.date_histogram.defaultSettings)||void 0===l?void 0:l.min_doc_count)})})),(0,de.jsx)(a.InlineField,Object.assign({label:"Trim Edges"},Ze,{tooltip:"Trim the edges on the timeseries datapoints",children:(0,de.jsx)(a.Input,{id:`${f}-trime_edges`,onBlur:e=>v(ue({bucketAgg:m,settingName:"trimEdges",newValue:e.target.value})),defaultValue:(null===(o=m.settings)||void 0===o?void 0:o.trimEdges)||(null===(c=te.date_histogram.defaultSettings)||void 0===c?void 0:c.trimEdges)})})),(0,de.jsx)(a.InlineField,Object.assign({label:"Offset"},Ze,{tooltip:"Change the start value of each bucket by the specified positive (+) or negative offset (-) duration, such as 1h for an hour, or 1d for a day",children:(0,de.jsx)(a.Input,{id:`${f}-offset`,onBlur:e=>v(ue({bucketAgg:m,settingName:"offset",newValue:e.target.value})),defaultValue:(null===(d=m.settings)||void 0===d?void 0:d.offset)||(null===(h=te.date_histogram.defaultSettings)||void 0===h?void 0:h.offset)})})),(0,de.jsx)(a.InlineField,Object.assign({label:"Timezone"},Ze,{children:(0,de.jsx)(a.TimeZonePicker,{value:(null===(p=m.settings)||void 0===p?void 0:p.timeZone)||(null===(g=te.date_histogram.defaultSettings)||void 0===g?void 0:g.timeZone),includeInternal:[i.InternalTimeZones.utc],onChange:e=>{v(ue({bucketAgg:m,settingName:"timeZone",newValue:e}))}})}))]})},qe=e=>{let{index:t,onAdd:s,onRemove:i,elements:r}=e;return(0,de.jsxs)("div",{className:n.css`
  30. display: flex;
  31. `,children:[0===t&&(0,de.jsx)(we,{iconName:"plus",onClick:s,label:"add"}),r.length>=2&&(0,de.jsx)(we,{iconName:"minus",onClick:i,label:"remove"})]})},Be=(0,q.PH)("@bucketAggregations/filter/add"),Ue=(0,q.PH)("@bucketAggregations/filter/remove"),Ge=(0,q.PH)("@bucketAggregations/filter/change"),ze=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;return Be.match(t)?[...e,{label:"",query:"*"}]:Ue.match(t)?e.slice(0,t.payload).concat(e.slice(t.payload+1)):Ge.match(t)?e.map(((e,s)=>s!==t.payload.index?e:t.payload.filter)):e},He=e=>{var t,s,i,o;let{bucketAgg:c}=e;const{current:d}=(0,r.useRef)((0,_e.uniqueId)("es-filters-")),h=u(),p=l((e=>h(ue({bucketAgg:c,settingName:"filters",newValue:e}))),null===(t=c.settings)||void 0===t?void 0:t.filters,ze);return(0,r.useEffect)((()=>{var e,t;null!==(e=c.settings)&&void 0!==e&&null!==(t=e.filters)&&void 0!==t&&t.length||p(Be())}),[p,null===(s=c.settings)||void 0===s||null===(i=s.filters)||void 0===i?void 0:i.length]),(0,de.jsx)(de.Fragment,{children:(0,de.jsx)("div",{className:n.css`
  32. display: flex;
  33. flex-direction: column;
  34. `,children:null===(o=c.settings)||void 0===o?void 0:o.filters.map(((e,t)=>{var s;return(0,de.jsxs)("div",{className:n.css`
  35. display: flex;
  36. `,children:[(0,de.jsx)(a.InlineField,{label:"Query",labelWidth:8,children:(0,de.jsx)("div",{className:n.css`
  37. width: 150px;
  38. `,children:(0,de.jsx)(a.QueryField,{placeholder:"Lucene Query",portalOrigin:"elasticsearch",onBlur:()=>{},onChange:s=>p(Ge({index:t,filter:Object.assign({},e,{query:s})})),query:e.query})})}),(0,de.jsx)(a.InlineField,{label:"Label",labelWidth:8,children:(0,de.jsx)(a.Input,{width:16,id:`${d}-label-${t}`,placeholder:"Label",onBlur:s=>p(Ge({index:t,filter:Object.assign({},e,{label:s.target.value})})),defaultValue:e.label})}),(0,de.jsx)(qe,{index:t,elements:(null===(s=c.settings)||void 0===s?void 0:s.filters)||[],onAdd:()=>p(Be()),onRemove:()=>p(Ue(t))})]},t)}))})})},We=e=>{var t,s,i,n,l,o,c,d,h,p;let{bucketAgg:g}=e;const{metrics:m}=fe(),v=Je(m),{current:f}=(0,r.useRef)((0,_e.uniqueId)("es-terms-")),b=u();return(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(a.InlineField,Object.assign({label:"Order"},Ze,{children:(0,de.jsx)(a.Select,{inputId:`${f}-order`,onChange:e=>b(ue({bucketAgg:g,settingName:"order",newValue:e.value})),options:ie,value:(null===(t=g.settings)||void 0===t?void 0:t.order)||(null===(s=te.terms.defaultSettings)||void 0===s?void 0:s.order)})})),(0,de.jsx)(a.InlineField,Object.assign({label:"Size"},Ze,{children:(0,de.jsx)(a.Select,Object.assign({inputId:`${f}-size`},Te({options:ne,value:(null===(i=g.settings)||void 0===i?void 0:i.size)||(null===(n=te.terms.defaultSettings)||void 0===n?void 0:n.size),onChange(e){let{value:t}=e;b(ue({bucketAgg:g,settingName:"size",newValue:t}))}})))})),(0,de.jsx)(a.InlineField,Object.assign({label:"Min Doc Count"},Ze,{children:(0,de.jsx)(a.Input,{id:`${f}-min_doc_count`,onBlur:e=>b(ue({bucketAgg:g,settingName:"min_doc_count",newValue:e.target.value})),defaultValue:(null===(l=g.settings)||void 0===l?void 0:l.min_doc_count)||(null===(o=te.terms.defaultSettings)||void 0===o?void 0:o.min_doc_count)})})),(0,de.jsx)(a.InlineField,Object.assign({label:"Order By"},Ze,{children:(0,de.jsx)(a.Select,{inputId:`${f}-order_by`,onChange:e=>b(ue({bucketAgg:g,settingName:"orderBy",newValue:e.value})),options:v,value:(null===(c=g.settings)||void 0===c?void 0:c.orderBy)||(null===(d=te.terms.defaultSettings)||void 0===d?void 0:d.orderBy)})})),(0,de.jsx)(a.InlineField,Object.assign({label:"Missing"},Ze,{children:(0,de.jsx)(a.Input,{id:`${f}-missing`,onBlur:e=>b(ue({bucketAgg:g,settingName:"missing",newValue:e.target.value})),defaultValue:(null===(h=g.settings)||void 0===h?void 0:h.missing)||(null===(p=te.terms.defaultSettings)||void 0===p?void 0:p.missing)})}))]})};function Qe(e){if(!e.meta)return[];return Object.keys(e.meta).filter((t=>{var s;return null===(s=e.meta)||void 0===s?void 0:s[t]})).map((t=>{let s=t;return"std_deviation_bounds_lower"===t&&(s="std_lower"),"std_deviation_bounds_upper"===t&&(s="std_upper"),{label:`${C(e)} (${s})`,value:`${e.id}[${s}]`}}))}function Ke(e){var t;return null!==(t=e.settings)&&void 0!==t&&t.percents?e.settings.percents.map((t=>{const s=/^\d+\.\d+/.test(`${t}`)?t:`${t}.0`;return{label:`${C(e)} (${t})`,value:`${e.id}[${s}]`}})):[]}function Xe(e){return"top_metrics"!==e.type&&!f(e)}const Je=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const t=e.filter(Xe).flatMap((e=>"extended_stats"===e.type?Qe(e):"percentiles"===e.type?Ke(e):{label:C(e),value:e.id}));return[...se,...t]},Ye=e=>t=>t.value===e,Ze={labelWidth:16},et=e=>{var t,s,i,n,l,o;let{bucketAgg:c}=e;const{current:d}=(0,r.useRef)((0,_e.uniqueId)("es-setting-")),h=u(),p=(e=>{const{metrics:t}=fe();switch(e.type){case"terms":{var s,i,n,r;const l=(null===(s=e.settings)||void 0===s?void 0:s.order)||"desc",o=(null===(i=e.settings)||void 0===i?void 0:i.size)||"10",u=parseInt((null===(n=e.settings)||void 0===n?void 0:n.min_doc_count)||"0",10),c=(null===(r=e.settings)||void 0===r?void 0:r.orderBy)||"_term";let d="";var a;if("0"!==o)d=`${null===(a=ie.find(Ye(l)))||void 0===a?void 0:a.label} ${o}, `;u>0&&(d+=`Min Doc Count: ${u}, `),d+="Order by: ";const h=se.find(Ye(c));if(h)d+=h.label;else{const e=null==t?void 0:t.find((e=>e.id===L(c)));d+=e?C(e):"metric not found"}return"0"===o&&(d+=` (${l})`),d}case"histogram":{var l,o;const t=(null===(l=e.settings)||void 0===l?void 0:l.interval)||1e3,s=(null===(o=e.settings)||void 0===o?void 0:o.min_doc_count)||1;return`Interval: ${t}${s>0?`, Min Doc Count: ${s}`:""}`}case"filters":var u,c;return`Filter Queries (${((null===(u=e.settings)||void 0===u?void 0:u.filters)||(null===(c=te.filters.defaultSettings)||void 0===c?void 0:c.filters)).length})`;case"geohash_grid":var d;return`Precision: ${Math.max(Math.min(parseInt((null===(d=e.settings)||void 0===d?void 0:d.precision)||"5",10),12),1)}`;case"date_histogram":{var h,p,g;const t=(null===(h=e.settings)||void 0===h?void 0:h.interval)||"auto",s=(null===(p=e.settings)||void 0===p?void 0:p.min_doc_count)||0,i=(null===(g=e.settings)||void 0===g?void 0:g.trimEdges)||0;let n=`Interval: ${t}`;return s>0&&(n+=`, Min Doc Count: ${s}`),i>0&&(n+=`, Trim edges: ${i}`),n}default:return"Settings"}})(c);return(0,de.jsxs)(Ce,{label:p,children:["terms"===c.type&&(0,de.jsx)(We,{bucketAgg:c}),"date_histogram"===c.type&&(0,de.jsx)(Ve,{bucketAgg:c}),"filters"===c.type&&(0,de.jsx)(He,{bucketAgg:c}),"geohash_grid"===c.type&&(0,de.jsx)(a.InlineField,Object.assign({label:"Precision"},Ze,{children:(0,de.jsx)(a.Input,{id:`${d}-geohash_grid-precision`,onBlur:e=>h(ue({bucketAgg:c,settingName:"precision",newValue:e.target.value})),defaultValue:(null===(t=c.settings)||void 0===t?void 0:t.precision)||(null===(s=te[c.type].defaultSettings)||void 0===s?void 0:s.precision)})})),"histogram"===c.type&&(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(a.InlineField,Object.assign({label:"Interval"},Ze,{children:(0,de.jsx)(a.Input,{id:`${d}-histogram-interval`,onBlur:e=>h(ue({bucketAgg:c,settingName:"interval",newValue:e.target.value})),defaultValue:(null===(i=c.settings)||void 0===i?void 0:i.interval)||(null===(n=te[c.type].defaultSettings)||void 0===n?void 0:n.interval)})})),(0,de.jsx)(a.InlineField,Object.assign({label:"Min Doc Count"},Ze,{children:(0,de.jsx)(a.Input,{id:`${d}-histogram-min_doc_count`,onBlur:e=>h(ue({bucketAgg:c,settingName:"min_doc_count",newValue:e.target.value})),defaultValue:(null===(l=c.settings)||void 0===l?void 0:l.min_doc_count)||(null===(o=te[c.type].defaultSettings)||void 0===o?void 0:o.min_doc_count)})}))]})]})},tt=Object.entries(te).map((e=>{let[t,{label:s}]=e;return{label:s,value:t}})),st=e=>{let{value:t}=e;const s=u(),i=ke(t.type);return(0,de.jsxs)(de.Fragment,{children:[(0,de.jsxs)(a.InlineSegmentGroup,{children:[(0,de.jsx)(a.Segment,{className:De,options:tt,onChange:e=>s(le({id:t.id,newType:e.value})),value:(n=t,{label:te[n.type].label,value:n.type})}),Ne(t)&&(0,de.jsx)(a.SegmentAsync,{className:De,loadOptions:i,onChange:e=>s(oe({id:t.id,newField:e.value})),placeholder:"Select Field",value:t.field})]}),(0,de.jsx)(et,{bucketAgg:t})]});var n},it=e=>{let{nextId:t}=e;const s=u(),{bucketAggs:i}=fe(),n=(null==i?void 0:i.length)||0;return(0,de.jsx)(de.Fragment,{children:i.map(((e,i)=>(0,de.jsxs)(Se,{label:0===i?"Group By":"Then By",onRemoveClick:n>1&&(()=>s(ae(e.id))),children:[(0,de.jsx)(st,{value:e}),0===i&&(0,de.jsx)(we,{iconName:"plus",onClick:()=>s(re(t)),label:"add"})]},`${e.type}-${e.id}`)))})},nt=n.css`
  39. white-space: nowrap;
  40. `,rt=e=>({label:C(e),value:e}),at=e=>{let{options:t,onChange:s,className:i,value:r}=e;const l=t.find((e=>e.id===r));return(0,de.jsx)(a.Segment,{className:(0,n.cx)(i,nt),options:(o=t,o.map(rt)),onChange:s,placeholder:"Select Metric",value:l?rt(l):void 0});var o};function lt(e){let{label:t,settingName:s,metric:i,placeholder:n,tooltip:l}=e;const o=u(),[c]=(0,r.useState)((0,_e.uniqueId)("es-field-id-")),d=i.settings;let h=(null==d?void 0:d[s])||"";return"script"===s&&(h=M(i)),(0,de.jsx)(a.InlineField,{label:t,labelWidth:16,tooltip:l,children:(0,de.jsx)(a.Input,{id:c,placeholder:n,onBlur:e=>o(Q({metric:i,settingName:s,newValue:e.target.value})),defaultValue:h})})}const ot=(0,q.PH)("@pipelineVariables/add"),ut=(0,q.PH)("@pipelineVariables/remove"),ct=(0,q.PH)("@pipelineVariables/rename"),dt=(0,q.PH)("@pipelineVariables/change_metric"),ht=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;return ot.match(t)?[...e,c(d(e))]:ut.match(t)?e.slice(0,t.payload).concat(e.slice(t.payload+1)):ct.match(t)?e.map(((e,s)=>s!==t.payload.index?e:Object.assign({},e,{name:t.payload.newName}))):dt.match(t)?e.map(((e,s)=>s!==t.payload.index?e:Object.assign({},e,{pipelineAgg:t.payload.newMetric}))):e};var pt;const gt=e=>{var t;let{value:s,previousMetrics:i}=e;const o=u(),c=l((e=>o(W({metric:s,attribute:"pipelineVariables",newValue:e}))),s.pipelineVariables,ht);return(0,r.useEffect)((()=>{var e;null!==(e=s.pipelineVariables)&&void 0!==e&&e.length||c(ot())}),[c,null===(t=s.pipelineVariables)||void 0===t?void 0:t.length]),(0,de.jsxs)(de.Fragment,{children:[(0,de.jsxs)("div",{className:n.css`
  41. display: flex;
  42. `,children:[pt||(pt=(0,de.jsx)(a.InlineLabel,{width:16,children:"Variables"})),(0,de.jsx)("div",{className:n.css`
  43. display: grid;
  44. grid-template-columns: 1fr auto;
  45. row-gap: 4px;
  46. margin-bottom: 4px;
  47. `,children:s.pipelineVariables.map(((e,t)=>(0,de.jsxs)(r.Fragment,{children:[(0,de.jsxs)("div",{className:n.css`
  48. display: grid;
  49. column-gap: 4px;
  50. grid-template-columns: auto auto;
  51. `,children:[(0,de.jsx)(a.Input,{"aria-label":"Variable name",defaultValue:e.name,placeholder:"Variable Name",onBlur:e=>c(ct({newName:e.target.value,index:t}))}),(0,de.jsx)(at,{onChange:e=>c(dt({newMetric:e.value.id,index:t})),options:i,value:e.pipelineAgg})]}),(0,de.jsx)(qe,{index:t,elements:s.pipelineVariables||[],onAdd:()=>c(ot()),onRemove:()=>c(ut(t))})]},(0,_e.uniqueId)("es-bs-"))))})]}),(0,de.jsx)(lt,{label:"Script",metric:s,settingName:"script",tooltip:"Elasticsearch v5.0 and above: Scripting language is Painless. Use params.<var> to reference a variable. Elasticsearch pre-v5.0: Scripting language is per default Groovy if not changed. For Groovy use <var> to reference a variable.",placeholder:"params.var1 / params.var2"})]})},mt=e=>{var t,s,i,n,l,o,c,d,m,v,f,b;let{metric:y}=e;const x=u(),{current:j}=(0,r.useRef)((0,_e.uniqueId)("es-moving-avg-"));return(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(a.InlineField,{label:"Model",labelWidth:16,children:(0,de.jsx)(a.Select,{inputId:`${j}-model`,onChange:e=>x(Q({metric:y,settingName:"model",newValue:e.value})),options:O,value:null===(t=y.settings)||void 0===t?void 0:t.model})}),(0,de.jsx)(lt,{label:"Window",settingName:"window",metric:y,placeholder:"5"}),(0,de.jsx)(lt,{label:"Predict",settingName:"predict",metric:y}),(h(y)||p(y)||g(y))&&(0,de.jsx)(a.InlineField,{label:"Alpha",labelWidth:16,children:(0,de.jsx)(a.Input,{id:`${j}-alpha`,onBlur:e=>{var t;return x(Q({metric:y,settingName:"settings",newValue:Object.assign({},null===(t=y.settings)||void 0===t?void 0:t.settings,{alpha:e.target.value})}))},defaultValue:null===(s=y.settings)||void 0===s||null===(i=s.settings)||void 0===i?void 0:i.alpha})}),(p(y)||g(y))&&(0,de.jsx)(a.InlineField,{label:"Beta",labelWidth:16,children:(0,de.jsx)(a.Input,{id:`${j}-beta`,onBlur:e=>{var t;return x(Q({metric:y,settingName:"settings",newValue:Object.assign({},null===(t=y.settings)||void 0===t?void 0:t.settings,{beta:e.target.value})}))},defaultValue:null===(n=y.settings)||void 0===n||null===(l=n.settings)||void 0===l?void 0:l.beta})}),g(y)&&(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(a.InlineField,{label:"Gamma",labelWidth:16,children:(0,de.jsx)(a.Input,{id:`${j}-gamma`,onBlur:e=>{var t;return x(Q({metric:y,settingName:"settings",newValue:Object.assign({},null===(t=y.settings)||void 0===t?void 0:t.settings,{gamma:e.target.value})}))},defaultValue:null===(o=y.settings)||void 0===o||null===(c=o.settings)||void 0===c?void 0:c.gamma})}),(0,de.jsx)(a.InlineField,{label:"Period",labelWidth:16,children:(0,de.jsx)(a.Input,{id:`${j}-period`,onBlur:e=>{var t;return x(Q({metric:y,settingName:"settings",newValue:Object.assign({},null===(t=y.settings)||void 0===t?void 0:t.settings,{period:e.target.value})}))},defaultValue:null===(d=y.settings)||void 0===d||null===(m=d.settings)||void 0===m?void 0:m.period})}),(0,de.jsx)(a.InlineField,{label:"Pad",labelWidth:16,children:(0,de.jsx)(a.InlineSwitch,{id:`${j}-pad`,onChange:e=>{var t;return x(Q({metric:y,settingName:"settings",newValue:Object.assign({},null===(t=y.settings)||void 0===t?void 0:t.settings,{pad:e.target.checked})}))},checked:!(null===(v=y.settings)||void 0===v||null===(f=v.settings)||void 0===f||!f.pad)})})]}),(h(y)||p(y)||g(y))&&(0,de.jsx)(a.InlineField,{label:"Minimize",labelWidth:16,children:(0,de.jsx)(a.InlineSwitch,{id:`${j}-minimize`,onChange:e=>x(Q({metric:y,settingName:"minimize",newValue:e.target.checked})),checked:!(null===(b=y.settings)||void 0===b||!b.minimize)})})]})},vt=e=>({value:e,label:e}),ft=e=>{var t,s,i,r;let{metric:l}=e;const o=u(),c=ke(["number","date"]),d=ke(l.type);return(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(a.InlineField,{label:"Metrics",labelWidth:16,children:(0,de.jsx)(a.AsyncMultiSelect,{onChange:e=>o(Q({metric:l,settingName:"metrics",newValue:e.map((e=>e.value))})),loadOptions:d,value:null===(t=l.settings)||void 0===t||null===(s=t.metrics)||void 0===s?void 0:s.map(vt),closeMenuOnSelect:!1,defaultOptions:!0})}),(0,de.jsx)(a.InlineField,{label:"Order",labelWidth:16,children:(0,de.jsx)(a.Select,{onChange:e=>o(Q({metric:l,settingName:"order",newValue:e.value})),options:ie,value:null===(i=l.settings)||void 0===i?void 0:i.order})}),(0,de.jsx)(a.InlineField,{label:"Order By",labelWidth:16,className:n.css`
  52. & > div {
  53. width: 100%;
  54. }
  55. `,children:(0,de.jsx)(a.SegmentAsync,{className:n.css`
  56. margin-right: 0;
  57. `,loadOptions:c,onChange:e=>o(Q({metric:l,settingName:"orderBy",newValue:e.value})),placeholder:"Select Field",value:null===(r=l.settings)||void 0===r?void 0:r.orderBy})})]})},bt={labelWidth:16},yt=e=>{var t,s,i,n,l,o,c;let{metric:d,previousMetrics:h}=e;const{current:p}=(0,r.useRef)((0,_e.uniqueId)("es-setting-")),g=u(),m=(e=>{var t,s,i;switch(e.type){case"cardinality":var n;return`Precision threshold: ${(null===(n=e.settings)||void 0===n?void 0:n.precision_threshold)||""}`;case"percentiles":var r;return null!==(t=e.settings)&&void 0!==t&&t.percents&&(null===(s=e.settings)||void 0===s||null===(i=s.percents)||void 0===i?void 0:i.length)>=1?`Values: ${null===(r=e.settings)||void 0===r?void 0:r.percents}`:"Percents: Default";case"extended_stats":{const t=Object.entries(e.meta||{}).map((e=>{var t;let[s,i]=e;return i&&(null===(t=S.find((e=>t=>t.value===e)(s)))||void 0===t?void 0:t.label)})).filter(Boolean);return`Stats: ${t.length>0?t.join(", "):"None selected"}`}case"raw_document":case"raw_data":var a;return`Size: ${(null===(a=e.settings)||void 0===a?void 0:a.size)||500}`;default:return"Options"}})(d),v=fe();return(0,de.jsxs)(Ce,{label:m,hidden:d.hide,children:["derivative"===d.type&&(0,de.jsx)(lt,{label:"Unit",metric:d,settingName:"unit"}),"serial_diff"===d.type&&(0,de.jsx)(lt,{label:"Lag",metric:d,settingName:"lag",placeholder:"1"}),"cumulative_sum"===d.type&&(0,de.jsx)(lt,{label:"Format",metric:d,settingName:"format"}),"moving_avg"===d.type&&(0,de.jsx)(mt,{metric:d}),"moving_fn"===d.type&&(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(lt,{label:"Window",metric:d,settingName:"window"}),(0,de.jsx)(lt,{label:"Script",metric:d,settingName:"script"}),(0,de.jsx)(lt,{label:"Shift",metric:d,settingName:"shift"})]}),"top_metrics"===d.type&&(0,de.jsx)(ft,{metric:d}),"bucket_script"===d.type&&(0,de.jsx)(gt,{value:d,previousMetrics:h}),("raw_data"===d.type||"raw_document"===d.type)&&(0,de.jsx)(a.InlineField,Object.assign({label:"Size"},bt,{children:(0,de.jsx)(a.Input,{id:`ES-query-${v.refId}_metric-${d.id}-size`,onBlur:e=>g(Q({metric:d,settingName:"size",newValue:e.target.value})),defaultValue:null!==(t=null===(s=d.settings)||void 0===s?void 0:s.size)&&void 0!==t?t:null===(i=I.raw_data.defaults.settings)||void 0===i?void 0:i.size})})),"logs"===d.type&&(0,de.jsx)(lt,{label:"Limit",metric:d,settingName:"limit",placeholder:"500"}),"cardinality"===d.type&&(0,de.jsx)(lt,{label:"Precision Threshold",metric:d,settingName:"precision_threshold"}),"extended_stats"===d.type&&(0,de.jsxs)(de.Fragment,{children:[S.map((e=>{var t,s,i;return(0,de.jsx)(xt,{stat:e,onChange:t=>g(K({metric:d,meta:e.value,newValue:t})),value:void 0!==(null===(t=d.meta)||void 0===t?void 0:t[e.value])?!(null===(s=d.meta)||void 0===s||!s[e.value]):!(null===(i=I.extended_stats.defaults.meta)||void 0===i||!i[e.value])},e.value)})),(0,de.jsx)(lt,{label:"Sigma",metric:d,settingName:"sigma",placeholder:"3"})]}),"percentiles"===d.type&&(0,de.jsx)(a.InlineField,Object.assign({label:"Percentiles"},bt,{children:(0,de.jsx)(a.Input,{id:`${p}-percentiles-percents`,onBlur:e=>g(Q({metric:d,settingName:"percents",newValue:e.target.value.split(",").filter(Boolean)})),defaultValue:(null===(n=d.settings)||void 0===n?void 0:n.percents)||(null===(l=I.percentiles.defaults.settings)||void 0===l?void 0:l.percents),placeholder:"1,5,25,50,75,95,99"})})),"rate"===d.type&&(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(a.InlineField,Object.assign({label:"Unit"},bt,{"data-testid":"unit-select",children:(0,de.jsx)(a.Select,{id:`ES-query-${v.refId}_metric-${d.id}-unit`,onChange:e=>g(Q({metric:d,settingName:"unit",newValue:e.value})),options:[{value:"second",label:"Second"},{value:"minute",label:"Minute"},{value:"hour",label:"Hour"},{value:"day",label:"Day"},{value:"week",label:"Week"},{value:"month",label:"Month"},{value:"quarter",label:"Quarter"},{value:"Year",label:"Year"}],value:null===(o=d.settings)||void 0===o?void 0:o.unit})})),(0,de.jsx)(a.InlineField,Object.assign({label:"Mode"},bt,{"data-testid":"mode-select",children:(0,de.jsx)(a.Select,{id:`ES-query-${v.refId}_metric-${d.id}-mode`,onChange:e=>g(Q({metric:d,settingName:"mode",newValue:e.value})),options:[{value:"sum",label:"Sum"},{value:"value_count",label:"Value count"}],value:null===(c=d.settings)||void 0===c?void 0:c.unit})}))]}),j(d)&&(0,de.jsx)(lt,{label:"Script",metric:d,settingName:"script",placeholder:"_value * 1"}),y(d)&&(0,de.jsx)(lt,{label:"Missing",metric:d,settingName:"missing",tooltip:"The missing parameter defines how documents that are missing a value should be treated. By default they will be ignored but it is also possible to treat them as if they had a value"})]})},xt=e=>{let{stat:t,onChange:s,value:i}=e;const[n]=(0,r.useState)((0,_e.uniqueId)("es-field-id-"));return(0,r.createElement)(a.InlineField,Object.assign({label:t.label},bt,{key:t.value}),(0,de.jsx)(a.InlineSwitch,{id:n,onChange:e=>s(e.target.checked),value:i}))},jt=e=>!I[e.type].isPipelineAgg,Et=function(e,t){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const i=e.some(jt);return Object.entries(I).filter((e=>{let[s,{versionRange:i="*"}]=e;return(0,D.satisfies)(t,i)})).filter((e=>{let[t,s]=e;return i||!s.isPipelineAgg})).filter((e=>{let[t,i]=e;return!i.xpack||s})).map((e=>{let[t,{label:s}]=e;return{label:s,value:t}}))},It=e=>{let{value:t}=e;const s=(i=(0,a.useTheme2)(),{color:(l=!!t.hide)&&n.css`
  58. &,
  59. &:hover,
  60. label,
  61. a {
  62. color: ${l?i.colors.text.disabled:i.colors.text.primary};
  63. }
  64. `});var i,l;const o=be(),c=fe(),d=u(),h=ke(t.type),p=(0,r.useCallback)((async()=>{const e=await h();return j(t)?[{label:"None"},...e]:e}),[h,t]),g=c.metrics.slice(0,c.metrics.findIndex((e=>e.id===t.id)));return(0,de.jsxs)(de.Fragment,{children:[(0,de.jsxs)(a.InlineSegmentGroup,{children:[(0,de.jsx)(a.Segment,{className:(0,n.cx)(s.color,De),options:Et(g,o.esVersion,o.xpack),onChange:e=>d(H({id:t.id,type:e.value})),value:(m=t,{label:I[m.type].label,value:m.type})}),v(t)&&!f(t)&&(0,de.jsx)(a.SegmentAsync,{className:(0,n.cx)(s.color,De),loadOptions:p,onChange:e=>d(z({id:t.id,field:e.value})),placeholder:"Select Field",value:t.field}),f(t)&&!b(t)&&(0,de.jsx)(at,{className:(0,n.cx)(s.color,De),onChange:e=>{var s;return d(z({id:t.id,field:null===(s=e.value)||void 0===s?void 0:s.id}))},options:g,value:t.field})]}),x(t)&&(0,de.jsx)(yt,{metric:t,previousMetrics:g})]});var m},wt=e=>{let{nextId:t}=e;const s=u(),{metrics:i}=fe(),n=(null==i?void 0:i.length)||0;return(0,de.jsx)(de.Fragment,{children:null==i?void 0:i.map(((e,i)=>(0,de.jsxs)(Se,{label:`Metric (${e.id})`,hidden:e.hide,onHideClick:()=>s(G(e.id)),onRemoveClick:n>1&&(()=>s(U(e.id))),children:[(0,de.jsx)(It,{value:e}),!I[e.type].isSingleMetric&&0===i&&(0,de.jsx)(we,{iconName:"plus",onClick:()=>s(B(t)),label:"add"})]},`${e.type}-${e.id}`)))})};var _t,St;const Ot=e=>({root:n.css`
  65. display: flex;
  66. `,queryFieldWrapper:n.css`
  67. flex-grow: 1;
  68. margin: 0 ${e.spacing(.5)} ${e.spacing(.5)} 0;
  69. `}),At=e=>{var t,s,i;let{value:n}=e;const l=u(),o=(()=>{const{metrics:e,bucketAggs:t}=fe();return(0,r.useMemo)((()=>(Math.max(...[...(null==e?void 0:e.map(xe))||["0"],...(null==t?void 0:t.map(xe))||["0"]].map(je))+1).toString()),[e,t])})(),c=(0,a.useStyles2)(Ot),d="date_histogram"===(null===(t=n.bucketAggs)||void 0===t||null===(s=t.slice(-1)[0])||void 0===s?void 0:s.type),h=null===(i=n.metrics)||void 0===i?void 0:i.every((e=>!I[e.type].isSingleMetric));return(0,de.jsxs)(de.Fragment,{children:[(0,de.jsxs)("div",{className:c.root,children:[St||(St=(0,de.jsx)(a.InlineLabel,{width:17,children:"Query"})),(0,de.jsx)("div",{className:c.queryFieldWrapper,children:(0,de.jsx)(a.QueryField,{query:n.query,onBlur:()=>{},onChange:e=>l(J(e)),placeholder:"Lucene Query",portalOrigin:"elasticsearch"})}),(0,de.jsx)(a.InlineField,{label:"Alias",labelWidth:15,disabled:!d,tooltip:"Aliasing only works for timeseries queries (when the last group is 'Date Histogram'). For all other query types this field is ignored.",children:(0,de.jsx)(a.Input,{id:`ES-query-${n.refId}_alias`,placeholder:"Alias Pattern",onBlur:e=>l(Y(e.currentTarget.value)),defaultValue:n.alias})})]}),(0,de.jsx)(wt,{nextId:o}),h&&(0,de.jsx)(it,{nextId:o})]})};var Nt=s(47472),$t=s(78837),Ft=s(20002),Rt=s(90923);const{FormField:kt,Switch:Dt}=a.LegacyForms,Ct=(0,a.stylesFactory)((()=>({firstRow:n.css`
  70. display: flex;
  71. `,nameField:n.css`
  72. flex: 2;
  73. `,regexField:n.css`
  74. flex: 3;
  75. `,row:n.css`
  76. display: flex;
  77. align-items: baseline;
  78. `,urlField:n.css`
  79. flex: 1;
  80. `,urlDisplayLabelField:n.css`
  81. flex: 1;
  82. `}))),Tt=e=>{const{value:t,onChange:s,onDelete:i,suggestions:n,className:l}=e,o=Ct(),[u,c]=function(e){const[t,s]=(0,r.useState)(!!e),i=(0,Ft.Z)(e);return(0,r.useEffect)((()=>{i||!e||t||s(!0),i&&!e&&t&&s(!1)}),[i,e,t]),[t,s]}(t.datasourceUid),d=e=>i=>{s(Object.assign({},t,{[e]:i.currentTarget.value}))};return(0,de.jsxs)("div",{className:l,children:[(0,de.jsxs)("div",{className:o.firstRow+" gf-form",children:[(0,de.jsx)(kt,{className:o.nameField,labelWidth:6,inputWidth:null,label:"Field",type:"text",value:t.field,tooltip:"Can be exact field name or a regex pattern that will match on the field name.",onChange:d("field")}),(0,de.jsx)(a.Button,{variant:"destructive",title:"Remove field",icon:"times",onClick:e=>{e.preventDefault(),i()}})]}),(0,de.jsxs)("div",{className:"gf-form",children:[(0,de.jsx)(kt,{label:u?"Query":"URL",labelWidth:6,inputEl:(0,de.jsx)(a.DataLinkInput,{placeholder:u?"${__value.raw}":"http://example.com/${__value.raw}",value:t.url||"",onChange:e=>s(Object.assign({},t,{url:e})),suggestions:n}),className:o.urlField}),(0,de.jsx)(kt,{className:o.urlDisplayLabelField,inputWidth:null,label:"URL Label",type:"text",value:t.urlDisplayLabel,onChange:d("urlDisplayLabel"),tooltip:"Use to override the button label."})]}),(0,de.jsxs)("div",{className:o.row,children:[(0,de.jsx)(Dt,{labelClass:"width-6",label:"Internal link",checked:u,onChange:()=>{u&&s(Object.assign({},t,{datasourceUid:void 0})),c(!u)}}),u&&(0,de.jsx)(Rt.DataSourcePicker,{tracing:!0,onChange:e=>{s(Object.assign({},t,{datasourceUid:e.uid}))},current:t.datasourceUid})]})]})};var Lt;const Mt=e=>({infoText:n.css`
  83. padding-bottom: ${e.spacing(2)};
  84. color: ${e.colors.text.secondary};
  85. `,dataLink:n.css`
  86. margin-bottom: ${e.spacing(1)};
  87. `}),Pt=e=>{const{value:t,onChange:s}=e,r=(0,a.useStyles2)(Mt);return(0,de.jsxs)(de.Fragment,{children:[Lt||(Lt=(0,de.jsx)("h3",{className:"page-heading",children:"Data links"})),(0,de.jsx)("div",{className:r.infoText,children:"Add links to existing fields. Links will be shown in log row details next to the field value."}),t&&t.length>0&&(0,de.jsx)("div",{className:"gf-form-group",children:t.map(((e,n)=>(0,de.jsx)(Tt,{className:r.dataLink,value:e,onChange:e=>{const i=[...t];i.splice(n,1,e),s(i)},onDelete:()=>{const e=[...t];e.splice(n,1),s(e)},suggestions:[{value:i.DataLinkBuiltInVars.valueRaw,label:"Raw value",documentation:"Raw value of the field",origin:i.VariableOrigin.Value}]},n)))}),(0,de.jsx)(a.Button,{type:"button",variant:"secondary",className:n.css`
  88. margin-right: 10px;
  89. `,icon:"plus",onClick:e=>{e.preventDefault();const i=[...t||[],{field:"",url:""}];s(i)},children:"Add"})]})},Vt=e=>{var t;const s=P(e.jsonData.esVersion);return Object.assign({},e,{jsonData:Object.assign({},e.jsonData,{timeField:e.jsonData.timeField||"@timestamp",esVersion:s,maxConcurrentShardRequests:e.jsonData.maxConcurrentShardRequests||Xt(s),logMessageField:e.jsonData.logMessageField||"",logLevelField:e.jsonData.logLevelField||"",includeFrozen:null!==(t=e.jsonData.includeFrozen)&&void 0!==t&&t})})},qt=e=>Boolean(e);var Bt;const Ut=[{label:"No pattern",value:"none"},{label:"Hourly",value:"Hourly",example:"[logstash-]YYYY.MM.DD.HH"},{label:"Daily",value:"Daily",example:"[logstash-]YYYY.MM.DD"},{label:"Weekly",value:"Weekly",example:"[logstash-]GGGG.WW"},{label:"Monthly",value:"Monthly",example:"[logstash-]YYYY.MM"},{label:"Yearly",value:"Yearly",example:"[logstash-]YYYY"}],Gt=[{label:"7.10+",value:"7.10.0"},{label:"8.0+",value:"8.0.0",description:"support for Elasticsearch 8 is currently experimental"}],zt=e=>{var t;let{value:s,onChange:i}=e;const n=Gt.find((e=>e.value===s.jsonData.esVersion)),r=!n&&(0,D.valid)(s.jsonData.esVersion)?{label:s.jsonData.esVersion,value:s.jsonData.esVersion}:void 0;return(0,de.jsx)(de.Fragment,{children:(0,de.jsxs)(a.FieldSet,{label:"Elasticsearch details",children:[(0,de.jsx)(a.InlineField,{label:"Index name",labelWidth:26,children:(0,de.jsx)(a.Input,{id:"es_config_indexName",value:s.database||"",onChange:Ht("database",s,i),width:24,placeholder:"es-index-name",required:!0})}),(0,de.jsx)(a.InlineField,{label:"Pattern",labelWidth:26,children:(0,de.jsx)(a.Select,{inputId:"es_config_indexPattern",value:Ut.find((e=>e.value===(void 0===s.jsonData.interval?"none":s.jsonData.interval))),options:Ut,onChange:Kt(s,i),width:24})}),(0,de.jsx)(a.InlineField,{label:"Time field name",labelWidth:26,children:(0,de.jsx)(a.Input,{id:"es_config_timeField",value:s.jsonData.timeField||"",onChange:Wt("timeField",s,i),width:24,placeholder:"@timestamp",required:!0})}),(0,de.jsx)(a.InlineField,{label:"ElasticSearch version",labelWidth:26,children:(0,de.jsx)(a.Select,{inputId:"es_config_version",options:[r,...Gt].filter(qt),onChange:e=>{const t=function(e,t){if(5===e&&(0,D.lt)(t,"7.0.0"))return 256;if(256===e&&(0,D.gte)(t,"7.0.0"))return 5;return e||Xt(t)}(s.jsonData.maxConcurrentShardRequests,e.value);i(Object.assign({},s,{jsonData:Object.assign({},s.jsonData,{esVersion:e.value,maxConcurrentShardRequests:t})}))},value:n||r,width:24})}),(0,D.gte)(s.jsonData.esVersion,"5.6.0")&&(0,de.jsx)(a.InlineField,{label:"Max concurrent Shard Requests",labelWidth:26,children:(0,de.jsx)(a.Input,{id:"es_config_shardRequests",value:s.jsonData.maxConcurrentShardRequests||"",onChange:Wt("maxConcurrentShardRequests",s,i),width:24})}),(0,de.jsx)(a.InlineField,{label:"Min time interval",labelWidth:26,tooltip:(0,de.jsxs)(de.Fragment,{children:["A lower limit for the auto group by time interval. Recommended to be set to write frequency, for example"," ",Bt||(Bt=(0,de.jsx)("code",{children:"1m"}))," if your data is written every minute."]}),error:"Value is not valid, you can use number with time unit specifier: y, M, w, d, h, m, s",invalid:!!s.jsonData.timeInterval&&!/^\d+(ms|[Mwdhmsy])$/.test(s.jsonData.timeInterval),children:(0,de.jsx)(a.Input,{id:"es_config_minTimeInterval",value:s.jsonData.timeInterval||"",onChange:Wt("timeInterval",s,i),width:24,placeholder:"10s"})}),(0,de.jsx)(a.InlineField,{label:"X-Pack enabled",labelWidth:26,children:(0,de.jsx)(a.InlineSwitch,{id:"es_config_xpackEnabled",checked:s.jsonData.xpack||!1,onChange:Qt("xpack",s,i)})}),(0,D.gte)(s.jsonData.esVersion,"6.6.0")&&s.jsonData.xpack&&(0,de.jsx)(a.InlineField,{label:"Include Frozen Indices",labelWidth:26,children:(0,de.jsx)(a.InlineSwitch,{id:"es_config_frozenIndices",checked:null!==(t=s.jsonData.includeFrozen)&&void 0!==t&&t,onChange:Qt("includeFrozen",s,i)})})]})})},Ht=(e,t,s)=>i=>{s(Object.assign({},t,{[e]:i.currentTarget.value}))},Wt=(e,t,s)=>i=>{s(Object.assign({},t,{jsonData:Object.assign({},t.jsonData,{[e]:i.currentTarget.value})}))},Qt=(e,t,s)=>i=>{s(Object.assign({},t,{jsonData:Object.assign({},t.jsonData,{[e]:i.currentTarget.checked})}))},Kt=(e,t)=>s=>{const{database:i}=e,n="none"===s.value?void 0:s.value;if(!i||0===i.length||i.startsWith("[logstash-]")){let s="";if(void 0!==n){const e=Ut.find((e=>e.value===n));var r;if(e)s=null!==(r=e.example)&&void 0!==r?r:""}t(Object.assign({},e,{database:s,jsonData:Object.assign({},e.jsonData,{interval:n})}))}else t(Object.assign({},e,{jsonData:Object.assign({},e.jsonData,{interval:n})}))};function Xt(e){return(0,D.gte)(e,"7.0.0")?5:256}const Jt=e=>{const{value:t,onChange:s}=e,i=e=>i=>{s(Object.assign({},t,{[e]:i.currentTarget.value}))};return(0,de.jsxs)(a.FieldSet,{label:"Logs",children:[(0,de.jsx)(a.InlineField,{label:"Message field name",labelWidth:22,children:(0,de.jsx)(a.Input,{id:"es_logs-config_logMessageField",value:t.logMessageField,onChange:i("logMessageField"),placeholder:"_source",width:24})}),(0,de.jsx)(a.InlineField,{label:"Level field name",labelWidth:22,children:(0,de.jsx)(a.Input,{id:"es_logs-config_logLevelField",value:t.logLevelField,onChange:i("logLevelField"),width:24})})]})};var Yt,Zt;var es=s(26702),ts=s(22322),ss=s(2937),is=s(10010),ns=s(76913),rs=s(44998),as=s(75954),ls=s(18906),os=s(11590),us=s(31359),cs=s(7166),ds=s(65660),hs=s(90845);const ps=`${A}([^@]+)${N}`;class gs{constructor(e,t){var s,i,n;n=()=>{const e=[];for(let t=0;t<this.response.responses.length;t++){const s=this.response.responses[t],i=this.targets[t];if(s.error)throw this.getErrorFromElasticResponse(this.response,s.error);if(s.hits&&s.hits.hits.length>0&&this.processHits(s.hits,e,i),s.aggregations){const i=s.aggregations,n=this.targets[t],r=[],a=new ds.Z;a.refId=n.refId,this.processBuckets(i,n,r,a,{},0),this.trimDatapoints(r,n),this.nameSeries(r,n);for(let t=0;t<r.length;t++)e.push(r[t]);a.rows.length>0&&e.push(a)}}return{data:e}},(i="processResponseToSeries")in(s=this)?Object.defineProperty(s,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):s[i]=n,this.targets=e,this.response=t,this.targets=e,this.response=t}processMetrics(e,t,s,i){let n;for(let o=0;o<t.metrics.length;o++){const u=t.metrics[o];if(!u.hide)switch(u.type){case"count":n={datapoints:[],metric:"count",props:i,refId:t.refId};for(let t=0;t<e.buckets.length;t++){const s=e.buckets[t],i=s.doc_count;n.datapoints.push([i,s.key])}s.push(n);break;case"percentiles":{if(0===e.buckets.length)break;const r=e.buckets[0][u.id].values;for(const a in r){n={datapoints:[],metric:"p"+a,props:i,field:u.field,refId:t.refId};for(let t=0;t<e.buckets.length;t++){const s=e.buckets[t],i=s[u.id].values;n.datapoints.push([i[a],s.key])}s.push(n)}break}case"extended_stats":for(const r in u.meta)if(u.meta[r]){n={datapoints:[],metric:r,props:i,field:u.field,refId:t.refId};for(let t=0;t<e.buckets.length;t++){const s=e.buckets[t],i=s[u.id];i.std_deviation_bounds_upper=i.std_deviation_bounds.upper,i.std_deviation_bounds_lower=i.std_deviation_bounds.lower,n.datapoints.push([i[r],s.key])}s.push(n)}break;case"top_metrics":var r,a;if(null!==(r=u.settings)&&void 0!==r&&null!==(a=r.metrics)&&void 0!==a&&a.length)for(const r of null===(l=u.settings)||void 0===l?void 0:l.metrics){var l;n={datapoints:[],metric:u.type,props:i,refId:t.refId,field:r};for(let t=0;t<e.buckets.length;t++){const s=e.buckets[t],i=s[u.id].top.map((e=>e.metrics[r]?e.metrics[r]:null)),a=[i[i.length-1],s.key];n.datapoints.push(a)}s.push(n)}break;default:n={datapoints:[],metric:u.type,metricId:u.id,props:i,refId:t.refId},v(u)&&(n.field=u.field);for(let t=0;t<e.buckets.length;t++){const s=e.buckets[t],i=s[u.id];void 0!==i&&(i.normalized_value?n.datapoints.push([i.normalized_value,s.key]):n.datapoints.push([i.value,s.key]))}s.push(n)}}}processAggregationDocs(e,t,s,i,n){if(0===i.columns.length){for(const e of(0,_e.keys)(n))i.addColumn({text:e,filterable:!0});i.addColumn({text:t.field,filterable:!0})}const r=(e,t,s)=>{i.addColumn({text:t}),e.push(s)},a=(0,_e.isArray)(e.buckets)?e.buckets:[e.buckets];for(const e of a){const t=[];for(const e of(0,_e.values)(n))t.push(e);t.push(e.key);for(const i of s.metrics||[])switch(i.type){case"count":r(t,this.getMetricName(i.type),e.doc_count);break;case"extended_stats":for(const s in i.meta){if(!i.meta[s])continue;const n=e[i.id];n.std_deviation_bounds_upper=n.std_deviation_bounds.upper,n.std_deviation_bounds_lower=n.std_deviation_bounds.lower,r(t,this.getMetricName(s),n[s])}break;case"percentiles":{const s=e[i.id].values;for(const e in s)r(t,`p${e} ${i.field}`,s[e]);break}case"top_metrics":{var l;const s=this.getMetricName(i.type);if(null!==(l=i.settings)&&void 0!==l&&l.metrics)for(const n of i.settings.metrics){r(t,i.settings.metrics.length>1?`${s} ${n}`:s,e[i.id].top[0].metrics[n])}break}default:{let n=this.getMetricName(i.type);(0,_e.filter)(s.metrics,{type:i.type}).length>1&&(v(i)&&(n+=" "+i.field),"bucket_script"===i.type&&(n=M(i))),r(t,n,e[i.id].value);break}}i.rows.push(t)}}processBuckets(e,t,s,i,n,r){let a,l,o,u;const c=t.bucketAggs.length-1;for(u in e)if(l=(0,_e.find)(t.bucketAggs,{id:u}),o=e[u],l)if(r===c)"date_histogram"===l.type?this.processMetrics(o,t,s,n):this.processAggregationDocs(o,l,t,i,n);else for(const e in o.buckets)a=o.buckets[e],n=(0,_e.clone)(n),void 0!==a.key?n[l.field]=a.key:n.filter=e,a.key_as_string&&(n[l.field]=a.key_as_string),this.processBuckets(a,t,s,i,n,r+1)}getMetricName(e){const t=Object.entries(I).filter((t=>{let[s]=t;return s===e})).map((e=>{let[t,s]=e;return s}))[0];if(t)return t.label;const s=S.find((t=>t.value===e));return s?s.label:e}getSeriesName(e,t,s){let i=this.getMetricName(e.metric);if(t.alias){const s=/\{\{([\s\S]+?)\}\}/g;return t.alias.replace(s,((t,s,n)=>{const r=s||n;return 0===r.indexOf("term ")?e.props[r.substring(5)]:void 0!==e.props[r]?e.props[r]:"metric"===r?i:"field"===r?e.field||"":t}))}if(e.metric in w)if(e.metric&&function(e){return!!I[e].supportsMultipleBucketPaths}(e.metric)){const s=(0,_e.find)(t.metrics,{id:e.metricId});if(s&&s.settings.script){i=M(s);for(const e of s.pipelineVariables){const s=(0,_e.find)(t.metrics,{id:e.pipelineAgg});s&&(i=i.replace("params."+e.name,C(s)))}}else i="Unset"}else{const s=(0,_e.find)(t.metrics,{id:e.field});s?i+=" "+C(s):i="Unset"}else e.field&&(i+=" "+e.field);if(0===(0,_e.keys)(e.props).length)return i;let n="";for(const t in e.props)n+=e.props[t]+" ";return s?n.trim()+" "+i:n.trim()}nameSeries(e,t){var s;const i=(0,_e.uniq)((0,_e.map)(e,"metric")).length,n=(null===(s=t.metrics)||void 0===s?void 0:s.filter((e=>"top_metrics"===e.type))).some((e=>{var t,s;return((null==e||null===(t=e.settings)||void 0===t||null===(s=t.metrics)||void 0===s?void 0:s.length)||0)>1}));for(let s=0;s<e.length;s++){const r=e[s];r.target=this.getSeriesName(r,t,i>1||n)}}processHits(e,t,s){const i="number"==typeof e.total?e.total:e.total.value,n={target:s.refId,type:"docs",refId:s.refId,datapoints:[],total:i,filterable:!0};let r,a,l,o;for(o=0;o<e.hits.length;o++){if(a=e.hits[o],l={_id:a._id,_type:a._type,_index:a._index,sort:a.sort,highlight:a.highlight},a._source)for(r in a._source)l[r]=a._source[r];for(r in a.fields)l[r]=a.fields[r];n.datapoints.push(l)}t.push(n)}trimDatapoints(e,t){const s=(0,_e.find)(t.bucketAggs,{type:"date_histogram"});if(s&&s.settings&&s.settings.trimEdges){const t=s.settings.trimEdges;for(const s in e){const i=e[s];i.datapoints.length>2*t&&(i.datapoints=i.datapoints.slice(t,i.datapoints.length-t))}}}getErrorFromElasticResponse(e,t){const s={};return s.data=JSON.stringify(t,null,4),t.root_cause&&t.root_cause.length>0&&t.root_cause[0].reason?s.message=t.root_cause[0].reason:s.message=t.reason||"Unknown elastic error response",e.$$config&&(s.config=e.$$config),s}getTimeSeries(){return this.targets.some((e=>k(e,"raw_data")))?this.processResponseToDataFrames(!1):this.processResponseToSeries()}getLogs(e,t){return this.processResponseToDataFrames(!0,e,t)}processResponseToDataFrames(e,t,s){const n=[];for(let a=0;a<this.response.responses.length;a++){const l=this.response.responses[a];if(l.error)throw this.getErrorFromElasticResponse(this.response,l.error);if(l.hits){const{propNames:i,docs:o}=ms(l.hits.hits),u=o.length?vs(i.map(bs(o)),e,this.targets[0].timeField,t,s):vs([],e);e&&fs(u,"logs");for(const e of o){if(s&&(e.level=e[s]),e.highlight){var r;const t=new RegExp(ps,"g"),s=new RegExp(ps),i=Object.keys(e.highlight).flatMap((i=>e.highlight[i].flatMap((e=>{const i=e.match(t);return i?i.map((e=>{const t=e.match(s);return t&&t[1]||null})):[]})))).filter(_e.identity),n=null!==(r=u.meta)&&void 0!==r&&r.searchWords?(0,_e.uniq)([...u.meta.searchWords,...i]):[...i];u.meta=u.meta?Object.assign({},u.meta,{searchWords:n}):{searchWords:n}}u.add(e)}const c=this.targets[a];u.refId=c.refId,n.push(u)}if(l.aggregations){const t=l.aggregations,s=this.targets[a],r=[],o=new ds.Z;if(this.processBuckets(t,s,r,o,{},0),this.trimDatapoints(r,s),this.nameSeries(r,s),o.rows.length>0){const e=(0,i.toDataFrame)(o);e.refId=s.refId,n.push(e)}for(let t=0;t<r.length;t++){let a=(0,i.toDataFrame)(r[t]);e&&fs(a,"graph"),a.refId=s.refId,n.push(a)}}}return{data:n}}}const ms=e=>{const t=[];let s=[];for(const i of e){const e=i._source?(0,hs.default)(i._source):{},n=Object.assign({_id:i._id,_type:i._type,_index:i._index,sort:i.sort,highlight:i.highlight,_source:Object.assign({},e)},e);for(const e of Object.keys(n))-1===s.indexOf(e)&&s.push(e);t.push(n)}return s.sort(),{docs:t,propNames:s}},vs=(e,t,s,n,r)=>{const a=new i.MutableDataFrame({fields:[]});if(s&&a.addField({config:{filterable:!0},name:s,type:i.FieldType.time}),n){const e=a.addField({name:n,type:i.FieldType.string});a.setParser(e,(e=>e||""))}if(r){const e=a.addField({name:"level",type:i.FieldType.string});a.setParser(e,(e=>e||""))}const l=a.fields.map((e=>e.name));for(const[s,i]of e){if(l.includes(s))continue;if(!t&&"_source"===s)continue;const e=a.addField({config:{filterable:!0},name:s,type:i});a.setParser(e,(e=>e||""))}return a},fs=(e,t)=>{let s=e;s.meta?s.meta.preferredVisualisationType=t:s.meta={preferredVisualisationType:t}},bs=e=>t=>{var s;return[t,ys(null===(s=e.find((e=>void 0!==e[t])))||void 0===s?void 0:s[t])]},ys=e=>{switch(typeof e){case"number":return i.FieldType.number;case"string":return i.FieldType.string;default:return i.FieldType.other}};const xs={Hourly:{startOf:"hour",amount:"hours"},Daily:{startOf:"day",amount:"days"},Weekly:{startOf:"isoWeek",amount:"weeks"},Monthly:{startOf:"month",amount:"months"},Yearly:{startOf:"year",amount:"years"}};class js{constructor(e,t){var s,i,n;n="en",(i="dateLocale")in(s=this)?Object.defineProperty(s,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):s[i]=n,this.pattern=e,this.interval=t}getIndexForToday(){return this.interval?(0,i.toUtc)().locale(this.dateLocale).format(this.pattern):this.pattern}getIndexList(e,t){if(!this.interval)return this.pattern;const s=xs[this.interval],n=(0,i.dateTime)(e||(0,i.dateTime)(t).add(-7,s.amount)).utc().startOf(s.startOf),r=(0,i.dateTime)(t||(0,i.dateTime)(e).add(7,s.amount)).utc().startOf(s.startOf).valueOf(),a=[];for(;n.valueOf()<=r;)a.push(n.locale(this.dateLocale).format(this.pattern)),n.add(1,s.amount);return a}}class Es extends i.LanguageProvider{constructor(e,t){var s,i,n;super(),n=void 0,(i="datasource")in(s=this)?Object.defineProperty(s,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):s[i]=n,this.datasource=e,Object.assign(this,t)}importFromAbstractQuery(e){return{metrics:[{id:"1",type:"logs"}],query:this.getElasticsearchQuery(e.labelMatchers),refId:e.refId}}getElasticsearchQuery(e){return e.map((e=>{switch(e.operator){case i.AbstractLabelOperator.Equal:return e.name+':"'+e.value+'"';case i.AbstractLabelOperator.NotEqual:return"NOT "+e.name+':"'+e.value+'"';case i.AbstractLabelOperator.EqualRegEx:return e.name+":/"+e.value+"/";case i.AbstractLabelOperator.NotEqualRegEx:return"NOT "+e.name+":/"+e.value+"/"}})).join(" AND ")}}function Is(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class ws{constructor(e){Is(this,"timeField",void 0),Is(this,"esVersion",void 0),this.timeField=e.timeField,this.esVersion=e.esVersion}getRangeFilter(){const e={};return e[this.timeField]={gte:"$timeFrom",lte:"$timeTo",format:"epoch_millis"},e}buildTermsAgg(e,t,s){var i;if(t.terms={field:e.field},!e.settings)return t;const n=null!==(i=e.settings)&&void 0!==i&&i.size?parseInt(e.settings.size,10):500;if(t.terms.size=0===n?500:n,void 0!==e.settings.orderBy){t.terms.order={},"_term"===e.settings.orderBy&&(0,D.gte)(this.esVersion,"6.0.0")?t.terms.order._key=e.settings.order:t.terms.order[e.settings.orderBy]=e.settings.order;const i=L(e.settings.orderBy);if(i)for(let n of s.metrics||[])if(n.id===i){"count"===n.type?t.terms.order={_count:e.settings.order}:v(n)&&(t.aggs={},t.aggs[n.id]={[n.type]:{field:n.field}});break}}return void 0!==e.settings.min_doc_count&&(t.terms.min_doc_count=parseInt(e.settings.min_doc_count,10),isNaN(t.terms.min_doc_count)&&(t.terms.min_doc_count=e.settings.min_doc_count)),e.settings.missing&&(t.terms.missing=e.settings.missing),t}getDateHistogramAgg(e){const t={},s=e.settings||{};t.field=e.field||this.timeField,t.min_doc_count=s.min_doc_count||0,t.extended_bounds={min:"$timeFrom",max:"$timeTo"},t.format="epoch_millis",s.timeZone&&s.timeZone!==i.InternalTimeZones.utc&&(t.time_zone=s.timeZone),""!==s.offset&&(t.offset=s.offset);const n="auto"===s.interval?"$__interval":s.interval;return(0,D.gte)(this.esVersion,"8.0.0")?t.fixed_interval=n:t.interval=n,t}getHistogramAgg(e){const t={},s=e.settings||{};return t.interval=s.interval,t.field=e.field,t.min_doc_count=s.min_doc_count||0,t}getFiltersAgg(e){const t={};for(let{query:i,label:n}of(null===(s=e.settings)||void 0===s?void 0:s.filters)||[]){var s;t[n||i]={query_string:{query:i,analyze_wildcard:!0}}}return t}documentQuery(e,t){return e.size=t,e.sort=[{[this.timeField]:{order:"desc",unmapped_type:"boolean"}},{_doc:{order:"desc"}}],(0,D.lt)(this.esVersion,"5.0.0")&&(e.fields=["*","_source"]),e.script_fields={},e}addAdhocFilters(e,t){if(!t)return;let s,i,n,r;for(s=0;s<t.length;s++)switch(i=t[s],n={},n[i.key]=i.value,r={},r[i.key]={query:i.value},i.operator){case"=":e.query.bool.must||(e.query.bool.must=[]),e.query.bool.must.push({match_phrase:r});break;case"!=":e.query.bool.must_not||(e.query.bool.must_not=[]),e.query.bool.must_not.push({match_phrase:r});break;case"<":n[i.key]={lt:i.value},e.query.bool.filter.push({range:n});break;case">":n[i.key]={gt:i.value},e.query.bool.filter.push({range:n});break;case"=~":e.query.bool.filter.push({regexp:n});break;case"!~":e.query.bool.filter.push({bool:{must_not:{regexp:n}}})}}build(e,t){var s,i,n,r,a,l,o,u,c;let d,h,p,g,y;e.metrics=e.metrics||[$()],e.bucketAggs=e.bucketAggs||[F()],e.timeField=this.timeField;const j={size:0,query:{bool:{filter:[{range:this.getRangeFilter()}]}}};if(e.query&&""!==e.query&&(j.query.bool.filter=[...j.query.bool.filter,{query_string:{analyze_wildcard:!0,query:e.query}}]),this.addAdhocFilters(j,t),0===e.bucketAggs.length&&(d=e.metrics[0],!d||"raw_document"!==d.type&&"raw_data"!==d.type))throw{message:"Invalid query"};if("raw_document"===(null===(s=e.metrics)||void 0===s||null===(i=s[0])||void 0===i?void 0:i.type)||"raw_data"===(null===(n=e.metrics)||void 0===n||null===(r=n[0])||void 0===r?void 0:r.type)){var E;d=e.metrics[0];const t=null!==(E=d.settings)&&void 0!==E&&E.size?parseInt(d.settings.size,10):500;return this.documentQuery(j,t||500)}for(y=j,h=0;h<e.bucketAggs.length;h++){const t=e.bucketAggs[h],s={};switch(t.type){case"date_histogram":s.date_histogram=this.getDateHistogramAgg(t);break;case"histogram":s.histogram=this.getHistogramAgg(t);break;case"filters":s.filters={filters:this.getFiltersAgg(t)};break;case"terms":this.buildTermsAgg(t,s,e);break;case"geohash_grid":var I;s.geohash_grid={field:t.field,precision:null===(I=t.settings)||void 0===I?void 0:I.precision}}y.aggs=y.aggs||{},y.aggs[t.id]=s,y=s}for(y.aggs={},h=0;h<e.metrics.length;h++){if(d=e.metrics[h],"count"===d.type)continue;const t={};let s={};if(f(d))if(b(d)){if(!d.pipelineVariables)continue;for(s={buckets_path:{}},p=0;p<d.pipelineVariables.length;p++)if(g=d.pipelineVariables[p],g.name&&g.pipelineAgg&&/^\d*$/.test(g.pipelineAgg)){const t=R(e.metrics,g.pipelineAgg);t&&("count"===t.type?s.buckets_path[g.name]="_count":s.buckets_path[g.name]=g.pipelineAgg)}}else{if(!d.field||!/^\d*$/.test(d.field))continue;{const t=R(e.metrics,d.field);t&&(s="count"===t.type?{buckets_path:"_count"}:{buckets_path:d.field})}}else v(d)&&(s={field:d.field});if(x(d))switch(Object.entries(d.settings||{}).filter((e=>{let[t,s]=e;return null!==s})).forEach((e=>{let[t,i]=e;s[t]="script"===t?this.buildScript(M(d)):i})),d.type){case"moving_avg":s=Object.assign({},s,void 0!==(null===(a=s)||void 0===a?void 0:a.window)&&{window:this.toNumber(s.window)},void 0!==(null===(l=s)||void 0===l?void 0:l.predict)&&{predict:this.toNumber(s.predict)},m(d)&&{settings:Object.assign({},s.settings,Object.fromEntries(Object.entries(s.settings||{}).filter((e=>{let[t]=e;return["alpha","beta","gamma","period"].includes(t)})).filter((e=>{let[t,s]=e;return void 0!==s})).map((e=>{let[t,s]=e;return[t,this.toNumber(s)]}))))});break;case"serial_diff":s=Object.assign({},s,void 0!==s.lag&&{lag:this.toNumber(s.lag)});break;case"top_metrics":var w,_;if(s={metrics:null===(o=d.settings)||void 0===o||null===(u=o.metrics)||void 0===u?void 0:u.map((e=>({field:e}))),size:1},null!==(c=d.settings)&&void 0!==c&&c.orderBy)s.sort=[{[null===(w=d.settings)||void 0===w?void 0:w.orderBy]:null===(_=d.settings)||void 0===_?void 0:_.order}]}t[d.type]=s,y.aggs[d.id]=t}return j}buildScript(e){return(0,D.gte)(this.esVersion,"5.6.0")?e:{inline:e}}toNumber(e){const t=parseFloat(`${e}`);return isNaN(t)?e:t}getTermsQuery(e){const t={size:0,query:{bool:{filter:[{range:this.getRangeFilter()}]}}};e.query&&t.query.bool.filter.push({query_string:{analyze_wildcard:!0,query:e.query}});let s=500;e.size&&(s=e.size),t.aggs={1:{terms:{field:e.field,size:s,order:{}}}};const{orderBy:i="key",order:n=("doc_count"===i?"desc":"asc")}=e;if(["asc","desc"].indexOf(n)<0)throw{message:`Invalid query sort order ${n}`};switch(i){case"key":case"term":const e=(0,D.gte)(this.esVersion,"6.0.0")?"_key":"_term";t.aggs[1].terms.order[e]=n;break;case"doc_count":t.aggs[1].terms.order._count=n;break;default:throw{message:`Invalid query sort type ${i}`}}return t}getLogsQuery(e,t,s){let i={size:0,query:{bool:{filter:[{range:this.getRangeFilter()}]}}};return this.addAdhocFilters(i,s),e.query&&i.query.bool.filter.push({query_string:{analyze_wildcard:!0,query:e.query}}),i=this.documentQuery(i,t),Object.assign({},i,{aggs:this.build(e,null).aggs,highlight:{fields:{"*":{}},pre_tags:[A],post_tags:[N],fragment_size:2147483647}})}}function _s(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}const Ss=["_index","_type","_id","_source","_size","_field_names","_ignored","_routing","_meta"];class Os extends i.DataSourceApi{constructor(e){var t,s;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(0,cs.J)();super(e),_s(this,"basicAuth",void 0),_s(this,"withCredentials",void 0),_s(this,"url",void 0),_s(this,"name",void 0),_s(this,"index",void 0),_s(this,"timeField",void 0),_s(this,"esVersion",void 0),_s(this,"xpack",void 0),_s(this,"interval",void 0),_s(this,"maxConcurrentShardRequests",void 0),_s(this,"queryBuilder",void 0),_s(this,"indexPattern",void 0),_s(this,"logMessageField",void 0),_s(this,"logLevelField",void 0),_s(this,"dataLinks",void 0),_s(this,"languageProvider",void 0),_s(this,"includeFrozen",void 0),_s(this,"isProxyAccess",void 0),_s(this,"getLogRowContext",(async(e,t)=>{var s;const n=e.dataFrame.fields.find((e=>"sort"===e.name)),r=(null==n?void 0:n.values.get(e.rowIndex))||[e.timeEpochMs],a="FORWARD"===(null==t?void 0:t.direction)?"asc":"desc",l="FORWARD"===(null==t?void 0:t.direction)?this.getQueryHeader("query_then_fetch",(0,i.dateTime)(e.timeEpochMs)):this.getQueryHeader("query_then_fetch",void 0,(0,i.dateTime)(e.timeEpochMs)),o=null!==(s=null==t?void 0:t.limit)&&void 0!==s?s:10,u=[l,JSON.stringify({size:o,query:{bool:{filter:[{range:{[this.timeField]:{["FORWARD"===(null==t?void 0:t.direction)?"gte":"lte"]:e.timeEpochMs,format:"epoch_millis"}}}]}},sort:[{[this.timeField]:a},{_doc:a}],search_after:r})].join("\n")+"\n",c=this.getMultiSearchUrl(),d=await(0,Ae.n)(this.post(c,u)),h=[{refId:`${e.dataFrame.refId}`,metrics:[{type:"logs",id:"1"}]}],p=new gs(h,function(e,t){if("desc"===t)return e;const s=e.responses[0];return Object.assign({},e,{responses:[Object.assign({},s,{hits:Object.assign({},s.hits,{hits:s.hits.hits.reverse()})})]})}(d,a)),g=p.getLogs(this.logMessageField,this.logLevelField),m=(0,_e.first)(g.data);if(!m)return{data:[]};const v=m.fields.find((e=>e.name===this.timeField)),f=m.fields.find((e=>e.name===this.logMessageField));return v&&f?{data:[Object.assign({},m,{fields:[...m.fields,Object.assign({},v,{name:"ts"}),Object.assign({},f,{name:"line"})]})]}:g})),this.templateSrv=n,this.basicAuth=e.basicAuth,this.withCredentials=e.withCredentials,this.url=e.url,this.name=e.name,this.index=null!==(t=e.database)&&void 0!==t?t:"",this.isProxyAccess="proxy"===e.access;const r=e.jsonData||{};this.timeField=r.timeField,this.esVersion=P(r.esVersion),this.xpack=Boolean(r.xpack),this.indexPattern=new js(this.index,r.interval),this.interval=r.timeInterval,this.maxConcurrentShardRequests=r.maxConcurrentShardRequests,this.queryBuilder=new ws({timeField:this.timeField,esVersion:this.esVersion}),this.logMessageField=r.logMessageField||"",this.logLevelField=r.logLevelField||"",this.dataLinks=r.dataLinks||[],this.includeFrozen=null!==(s=r.includeFrozen)&&void 0!==s&&s,""===this.logMessageField&&(this.logMessageField=void 0),""===this.logLevelField&&(this.logLevelField=void 0),this.languageProvider=new Es(this)}request(e,t,s,i){if(!this.isProxyAccess){const e=new Error("Browser access mode in the Elasticsearch datasource is no longer available. Switch to server access mode.");return(0,es._)((()=>e))}if(!V(this.esVersion)){const e=new Error("Support for Elasticsearch versions after their end-of-life (currently versions < 7.10) was removed.");return(0,es._)((()=>e))}const n={url:this.url+"/"+t,method:e,data:s,headers:i};return(this.basicAuth||this.withCredentials)&&(n.withCredentials=!0),this.basicAuth&&(n.headers={Authorization:this.basicAuth}),(0,Rt.getBackendSrv)().fetch(n).pipe((0,is.U)((e=>(e.data.$$config=e.config,e.data))),(0,ns.K)((e=>{if(e.data){var t,s,i;const n=null!==(t=null!==(s=null===(i=e.data.error)||void 0===i?void 0:i.reason)&&void 0!==s?s:e.data.message)&&void 0!==t?t:"Unknown error";return(0,es._)({message:"Elasticsearch error: "+n,error:e.data.error})}return(0,es._)(e)})))}async importFromAbstractQueries(e){return e.map((e=>this.languageProvider.importFromAbstractQuery(e)))}get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(0,i.getDefaultTimeRange)(),s=this.indexPattern.getIndexList(t.from,t.to);Array.isArray(s)||(s=[this.indexPattern.getIndexForToday()]);const n=s.map((t=>t+e));return this.requestAllIndices(n)}requestAllIndices(e){const t=e.length;return(0,ts.R)({initialState:0,condition:e=>e<Math.min(t,7),iterate:e=>e+1}).pipe((0,rs.z)((s=>this.request("GET",e[t-s-1]).pipe((0,ns.K)((e=>(0,ss.of)({err:e})))))),(0,as.n)((e=>{var t;return 404===(null==e||null===(t=e.err)||void 0===t?void 0:t.status)})),(0,ls.T)((()=>"Could not find an available index for this time range.")),(0,os.P)(),(0,is.U)((e=>{if(e.err)throw e.err;return e})))}post(e,t){return this.request("POST",e,t,{"Content-Type":"application/x-ndjson"})}annotationQuery(e){const t=e.annotation,s=t.timeField||"@timestamp",n=t.timeEndField||null,r=t.query,a=t.tagsField||"tags",l=t.textField||null,o=[],u={};if(u[s]={from:e.range.from.valueOf(),to:e.range.to.valueOf(),format:"epoch_millis"},o.push({range:u}),n){const t={};t[n]={from:e.range.from.valueOf(),to:e.range.to.valueOf(),format:"epoch_millis"},o.push({range:t})}const c=this.interpolateLuceneQuery(r),d={bool:{filter:[{bool:{should:o,minimum_should_match:1}}]}};c&&d.bool.filter.push({query_string:{query:c}});const h={query:d,size:1e4};(0,D.lt)(this.esVersion,"5.0.0")&&(h.fields=[s,"_source"]);const p={search_type:"query_then_fetch",ignore_unavailable:!0};t.index?p.index=t.index:p.index=this.indexPattern.getIndexList(e.range.from,e.range.to);const g=JSON.stringify(p)+"\n"+JSON.stringify(h)+"\n";return(0,Ae.n)(this.post("_msearch",g).pipe((0,is.U)((e=>{const r=[],o=e.responses[0].hits.hits,u=(e,t)=>{if(!t)return;const s=t.split(".");let i=e;for(let e=0;e<s.length;e++)if(i=i[s[e]],!i)return console.log("could not find field in annotation: ",t),"";return i};for(let e=0;e<o.length;e++){const c=o[e]._source;let d=u(c,s);if(void 0!==o[e].fields){const t=o[e].fields;((0,_e.isString)(t[s])||(0,_e.isNumber)(t[s]))&&(d=t[s])}const h={annotation:t,time:(0,i.toUtc)(d).valueOf(),text:u(c,l),tags:u(c,a)};if(n){const e=u(c,n);e&&(h.timeEnd=(0,i.toUtc)(e).valueOf())}if(t.titleField){const e=u(c,t.titleField);e&&(h.text=e+"\n"+h.text)}"string"==typeof h.tags&&(h.tags=h.tags.split(",")),r.push(h)}return r}))))}interpolateLuceneQuery(e,t){return this.templateSrv.replace(e,t,"lucene")}interpolateVariablesInQueries(e,t){const s=e=>{var s,i;return"filters"===e.type?Object.assign({},e,{settings:Object.assign({},e.settings,{filters:null===(s=e.settings)||void 0===s||null===(i=s.filters)||void 0===i?void 0:i.map((e=>Object.assign({},e,{query:this.interpolateLuceneQuery(e.query,t)||"*"})))})}):e},i=e.map((e=>{var i;return Object.assign({},e,{datasource:this.getRef(),query:this.interpolateLuceneQuery(e.query||"",t),bucketAggs:null===(i=e.bucketAggs)||void 0===i?void 0:i.map(s)})}));return JSON.parse(this.templateSrv.replace(JSON.stringify(i),t))}testDatasource(){return(0,Ae.n)(this.getFields(["date"]).pipe((0,rs.z)((e=>(0,_e.find)(e,{text:this.timeField})?(0,ss.of)({status:"success",message:"Index OK. Time field name OK."}):(0,ss.of)({status:"error",message:"No date field named "+this.timeField+" found"}))),(0,ns.K)((e=>(console.error(e),e.message?(0,ss.of)({status:"error",message:e.message}):(0,ss.of)({status:"error",message:e.status}))))))}getQueryHeader(e,t,s){const i={search_type:e,ignore_unavailable:!0,index:this.indexPattern.getIndexList(t,s)};return(0,D.satisfies)(this.esVersion,">=5.6.0 <7.0.0")&&(i.max_concurrent_shard_requests=this.maxConcurrentShardRequests),JSON.stringify(i)}getQueryDisplayText(e){const t=e.metrics,s=e.bucketAggs;let i="";return e.query&&(i+="Query: "+e.query+", "),i+="Metrics: ",i+=null==t?void 0:t.reduce(((e,t)=>{let s=I[t.type].label+"(";return v(t)&&(s+=t.field),b(t)&&(s+=M(t).replace(new RegExp("params.","g"),"")),s+="), ",`${e} ${s}`}),""),i+=null==s?void 0:s.reduce(((e,t,s)=>{let i="";return 0===s&&(i+=" Group by: "),i+=te[t.type].label+"(",Ne(t)&&(i+=t.field),`${e} ${i}), `}),""),e.alias&&(i+="Alias: "+e.alias),i}showContextToggle(){return(0,D.gte)(this.esVersion,"5.0.0")}getLogsVolumeDataProvider(e){if(!e.targets.some((e=>{var t;return 1===(null===(t=e.metrics)||void 0===t?void 0:t.length)&&"logs"===e.metrics[0].type})))return;const t=(0,_e.cloneDeep)(e);return t.targets=t.targets.map((e=>{var t;const s=[],n=null!==(t=this.timeField)&&void 0!==t?t:"@timestamp";this.logLevelField&&s.push({id:"2",type:"terms",settings:{min_doc_count:"0",size:"0",order:"desc",orderBy:"_count",missing:i.LogLevel.unknown},field:this.logLevelField}),s.push({id:"3",type:"date_histogram",settings:{interval:"auto",min_doc_count:"0",trimEdges:"0"},field:n});return{refId:e.refId,query:e.query,metrics:[{type:"count",id:"1"}],timeField:n,bucketAggs:s}})),(0,us.Bz)(this,t,{range:e.range,targets:e.targets,extractLevel:e=>(0,i.getLogLevelFromKey)(e.name||"")})}query(e){let t="";const s=this.interpolateVariablesInQueries((0,_e.cloneDeep)(e.targets),e.scopedVars),i=[];let n=s.some((e=>k(e,"logs")));const r=this.templateSrv.getAdhocFilters(this.name),a=[];for(const n of s){if(n.hide)continue;let s;if(k(n,"logs")){var l,o,u;n.bucketAggs=[F()];const e=null===(l=n.metrics)||void 0===l?void 0:l.find((e=>"logs"===e.type)),t=null!==(o=e.settings)&&void 0!==o&&o.limit?parseInt(null===(u=e.settings)||void 0===u?void 0:u.limit,10):500;a.push(t),n.metrics=[],s=this.queryBuilder.getLogsQuery(n,t,r)}else a.push(),n.alias&&(n.alias=this.interpolateLuceneQuery(n.alias,e.scopedVars)),s=this.queryBuilder.build(n,r);const c=JSON.stringify(s),d=0===s.size&&(0,D.lt)(this.esVersion,"5.0.0")?"count":"query_then_fetch";t+=this.getQueryHeader(d,e.range.from,e.range.to)+"\n",t+=c+"\n",i.push(n)}if(0===i.length)return(0,ss.of)({data:[]});t=t.replace(/"\$timeFrom"/g,e.range.from.valueOf().toString()),t=t.replace(/"\$timeTo"/g,e.range.to.valueOf().toString()),t=this.templateSrv.replace(t,e.scopedVars);const c=this.getMultiSearchUrl();return this.post(c,t).pipe((0,is.U)((e=>{const t=new gs(i,e);if(n){const e=t.getLogs(this.logMessageField,this.logLevelField);return e.data.forEach(((e,t)=>{!function(e,t,s){s&&(e.meta=Object.assign({},e.meta,{limit:s}));if(!t.length)return;for(const s of e.fields){const e=t.filter((e=>new RegExp(e.field).test(s.name)));0!==e.length&&(s.config=s.config||{},s.config.links=[...(s.config.links,e.map(As))])}}(e,this.dataLinks,a[t])})),e}return t.getTimeSeries()})))}isMetadataField(e){return Ss.includes(e)}getFields(e,t){const s={float:"number",double:"number",integer:"number",long:"number",date:"date",date_nanos:"date",string:"string",text:"string",scaled_float:"number",nested:"nested",histogram:"number"};return this.get("/_mapping",t).pipe((0,is.U)((t=>{const i=(t,i)=>!this.isMetadataField(i)&&(!e||0===e.length||(e.includes(t.type)||e.includes(s[t.type]))),n=[],r={};function a(e){for(const t in e){const s=e[t];if((0,_e.isObject)(s.properties)&&(n.push(t),a(s.properties)),(0,_e.isObject)(s.fields)&&(n.push(t),a(s.fields)),(0,_e.isString)(s.type)){const e=n.concat(t).join(".");i(s,t)&&(r[e]={text:e,type:s.type})}}n.pop()}for(const e in t){const s=t[e];if(s&&s.mappings){const e=s.mappings;if((0,D.lt)(this.esVersion,"7.0.0"))for(const t in e){a(e[t].properties)}else{a(e.properties)}}}return(0,_e.map)(r,(e=>e))})))}getTerms(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(0,i.getDefaultTimeRange)();const s=(0,D.gte)(this.esVersion,"5.0.0")?"query_then_fetch":"count",n=this.getQueryHeader(s,t.from,t.to);let r=JSON.stringify(this.queryBuilder.getTermsQuery(e));r=r.replace(/\$timeFrom/g,t.from.valueOf().toString()),r=r.replace(/\$timeTo/g,t.to.valueOf().toString()),r=n+"\n"+r+"\n";const a=this.getMultiSearchUrl();return this.post(a,r).pipe((0,is.U)((e=>{if(!e.responses[0].aggregations)return[];const t=e.responses[0].aggregations[1].buckets;return(0,_e.map)(t,(e=>({text:e.key_as_string||e.key,value:e.key})))})))}getMultiSearchUrl(){const e=new URLSearchParams;return(0,D.gte)(this.esVersion,"7.0.0")&&this.maxConcurrentShardRequests&&e.append("max_concurrent_shard_requests",`${this.maxConcurrentShardRequests}`),(0,D.gte)(this.esVersion,"6.6.0")&&this.xpack&&this.includeFrozen&&e.append("ignore_throttled","false"),("_msearch?"+e.toString()).replace(/\?$/,"")}metricFindQuery(e,t){const s=null==t?void 0:t.range,i=JSON.parse(e);if(e){if("fields"===i.find)return i.type=this.interpolateLuceneQuery(i.type),(0,Ae.n)(this.getFields(i.type,s));if("terms"===i.find)return i.field=this.interpolateLuceneQuery(i.field),i.query=this.interpolateLuceneQuery(i.query),(0,Ae.n)(this.getTerms(i,s))}return Promise.resolve([])}getTagKeys(){return(0,Ae.n)(this.getFields())}getTagValues(e){return(0,Ae.n)(this.getTerms({field:e.key}))}targetContainsTemplate(e){if(this.templateSrv.containsTemplate(e.query)||this.templateSrv.containsTemplate(e.alias))return!0;for(const t of e.bucketAggs)if(this.templateSrv.containsTemplate(t.field)||this.objectContainsTemplate(t.settings))return!0;for(const t of e.metrics)if(this.templateSrv.containsTemplate(t.field)||this.objectContainsTemplate(t.settings)||this.objectContainsTemplate(t.meta))return!0;return!1}isPrimitive(e){return null==e||!!["string","number","boolean"].some((e=>"boolean"===e))}objectContainsTemplate(e){if(!e)return!1;for(const t of Object.keys(e))if(this.isPrimitive(e[t])){if(this.templateSrv.containsTemplate(e[t]))return!0}else if(Array.isArray(e[t])){for(const s of e[t])if(this.objectContainsTemplate(s))return!0}else if(this.objectContainsTemplate(e[t]))return!0;return!1}}function As(e){const t=(0,Rt.getDataSourceSrv)();if(e.datasourceUid){var s;const i=t.getInstanceSettings(e.datasourceUid);return{title:e.urlDisplayLabel||"",url:"",internal:{query:{query:e.url},datasourceUid:e.datasourceUid,datasourceName:null!==(s=null==i?void 0:i.name)&&void 0!==s?s:"Data source not found"}}}return{title:e.urlDisplayLabel||"",url:e.url}}class Ns{}var $s,Fs,Rs;Rs="partials/annotations.editor.html",(Fs="templateUrl")in($s=Ns)?Object.defineProperty($s,Fs,{value:Rs,enumerable:!0,configurable:!0,writable:!0}):$s[Fs]=Rs;const ks=new i.DataSourcePlugin(Os).setQueryEditor((e=>{let{query:t,onChange:s,onRunQuery:n,datasource:r,range:l}=e;return V(r.esVersion)?(0,de.jsx)(me,{datasource:r,onChange:s,onRunQuery:n,query:t,range:l||(0,i.getDefaultTimeRange)(),children:(0,de.jsx)(At,{value:t})}):_t||(_t=(0,de.jsx)(a.Alert,{title:"Support for Elasticsearch versions after their end-of-life (currently versions < 7.10) was removed"}))})).setConfigEditor((e=>{const t=(0,r.useRef)("direct"===e.options.access),{options:s,onOptionsChange:i}=e,n=Vt(s);(0,r.useEffect)((()=>{(e=>!!(0,D.valid)(e.jsonData.esVersion)&&!!e.jsonData.timeField&&!!e.jsonData.maxConcurrentShardRequests&&void 0!==e.jsonData.logMessageField&&void 0!==e.jsonData.logLevelField)(s)||i(Vt(s))}),[]);const l=V(n.jsonData.esVersion);return(0,de.jsxs)(de.Fragment,{children:["direct"===n.access&&(Yt||(Yt=(0,de.jsx)(a.Alert,{title:"Error",severity:"error",children:"Browser access mode in the Elasticsearch datasource is no longer available. Switch to server access mode."}))),!l&&(Zt||(Zt=(0,de.jsx)(a.Alert,{title:"Deprecation notice",severity:"error",children:"Support for Elasticsearch versions after their end-of-life (currently versions < 7.10) was removed"}))),(0,de.jsx)(a.DataSourceHttpSettings,{defaultUrl:"http://localhost:9200",dataSourceConfig:n,showAccessOptions:t.current,onChange:i,sigV4AuthToggleEnabled:$t.vc.sigV4AuthEnabled,renderSigV4Editor:(0,de.jsx)(Nt.SIGV4ConnectionConfig,Object.assign({},e))}),(0,de.jsx)(zt,{value:n,onChange:i}),(0,de.jsx)(Jt,{value:n.jsonData,onChange:e=>i(Object.assign({},n,{jsonData:e}))}),(0,de.jsx)(Pt,{value:n.jsonData.dataLinks,onChange:e=>{i(Object.assign({},n,{jsonData:Object.assign({},n.jsonData,{dataLinks:e})}))}})]})})).setAnnotationQueryCtrl(Ns)},20002:(e,t,s)=>{"use strict";s.d(t,{Z:()=>n});var i=s(68404);function n(e){var t=(0,i.useRef)();return(0,i.useEffect)((function(){t.current=e})),t.current}},98616:(e,t,s)=>{var i,n=s(68404),r=(i=n)&&"object"==typeof i&&"default"in i?i.default:i,a=s(69783),l=s(43215),o=s(82897),u=function(){return(u=Object.assign||function(e){for(var t,s=1,i=arguments.length;s<i;s++)for(var n in t=arguments[s])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function c(e,t,s,i){return new(s||(s=Promise))((function(n,r){function a(e){try{o(i.next(e))}catch(e){r(e)}}function l(e){try{o(i.throw(e))}catch(e){r(e)}}function o(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(a,l)}o((i=i.apply(e,t||[])).next())}))}function d(e,t){var s,i,n,r,a={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return r={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function l(r){return function(l){return function(r){if(s)throw new TypeError("Generator is already executing.");for(;a;)try{if(s=1,i&&(n=2&r[0]?i.return:r[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,r[1])).done)return n;switch(i=0,n&&(r=[2&r[0],n.value]),r[0]){case 0:case 1:n=r;break;case 4:return a.label++,{value:r[1],done:!1};case 5:a.label++,i=r[1],r=[0];continue;case 7:r=a.ops.pop(),a.trys.pop();continue;default:if(!((n=(n=a.trys).length>0&&n[n.length-1])||6!==r[0]&&2!==r[0])){a=0;continue}if(3===r[0]&&(!n||r[1]>n[0]&&r[1]<n[3])){a.label=r[1];break}if(6===r[0]&&a.label<n[1]){a.label=n[1],n=r;break}if(n&&a.label<n[2]){a.label=n[2],a.ops.push(r);break}n[2]&&a.ops.pop(),a.trys.pop();continue}r=t.call(e,a)}catch(e){r=[6,e],i=0}finally{s=n=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,l])}}}function h(e,t){var s="function"==typeof Symbol&&e[Symbol.iterator];if(!s)return e;var i,n,r=s.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){n={error:e}}finally{try{i&&!i.done&&(s=r.return)&&s.call(r)}finally{if(n)throw n.error}}return a}var p,g=["af-south-1","ap-east-1","ap-northeast-1","ap-northeast-2","ap-northeast-3","ap-south-1","ap-southeast-1","ap-southeast-2","ca-central-1","cn-north-1","cn-northwest-1","eu-central-1","eu-north-1","eu-west-1","eu-west-2","eu-west-3","me-south-1","sa-east-1","us-east-1","us-east-2","us-gov-east-1","us-gov-west-1","us-iso-east-1","us-isob-east-1","us-west-1","us-west-2"];(p=t._e||(t._e={})).Keys="keys",p.Credentials="credentials",p.Default="default",p.EC2IAMRole="ec2_iam_role",p.ARN="arn";var m,v=[{label:"Workspace IAM Role",value:t._e.EC2IAMRole},{label:"AWS SDK Default",value:t._e.Default},{label:"Access & secret key",value:t._e.Keys},{label:"Credentials file",value:t._e.Credentials}],f=function(e){return{value:e,label:e}},b=function(e){var s,i,o,c,d,p,m,b,y,x=h(n.useState((e.standardRegions||g).map(f)),2),j=x[0],E=x[1],I=e.loadRegions,w=e.onOptionsChange,_=e.skipHeader,S=void 0!==_&&_,O=e.skipEndpoint,A=void 0!==O&&O,N=e.options,$=N.jsonData.profile;void 0===$&&($=N.database);var F=window.grafanaBootData.settings,R=null!==(s=F.awsAllowedAuthProviders)&&void 0!==s?s:[t._e.Default,t._e.Keys,t._e.Credentials],k=null===(i=F.awsAssumeRoleEnabled)||void 0===i||i,D=v.find((function(e){return e.value===N.jsonData.authType}));return n.useEffect((function(){!D&&R.length&&w(u(u({},N),{jsonData:u(u({},N.jsonData),{authType:R[0]})}))}),[D,N,w]),n.useEffect((function(){I&&I().then((function(e){return E(e.map(f))}))}),[I]),r.createElement(a.FieldSet,{label:S?"":"Connection Details","data-testid":"connection-config"},r.createElement(a.InlineField,{label:"Authentication Provider",labelWidth:28,tooltip:"Specify which AWS credentials chain to use."},r.createElement(a.Select,{"aria-label":"Authentication Provider",className:"width-30",value:D,options:v.filter((function(e){return R.includes(e.value)})),defaultValue:N.jsonData.authType,onChange:function(t){l.onUpdateDatasourceJsonDataOptionSelect(e,"authType")(t)},menuShouldPortal:!0})),"credentials"===N.jsonData.authType&&r.createElement(a.InlineField,{label:"Credentials Profile Name",labelWidth:28,tooltip:"Credentials profile name, as specified in ~/.aws/credentials, leave blank for default."},r.createElement(a.Input,{"aria-label":"Credentials Profile Name",className:"width-30",placeholder:"default",value:$,onChange:l.onUpdateDatasourceJsonDataOption(e,"profile")})),"keys"===N.jsonData.authType&&r.createElement(r.Fragment,null,r.createElement(a.InlineField,{label:"Access Key ID",labelWidth:28},(null===(o=e.options.secureJsonFields)||void 0===o?void 0:o.accessKey)?r.createElement(a.ButtonGroup,{className:"width-30"},r.createElement(a.Input,{disabled:!0,placeholder:"Configured"}),r.createElement(a.ToolbarButton,{icon:"edit",tooltip:"Edit Access Key ID",type:"button",onClick:l.onUpdateDatasourceResetOption(e,"accessKey")})):r.createElement(a.Input,{"aria-label":"Access Key ID",className:"width-30",value:null!==(d=null===(c=N.secureJsonData)||void 0===c?void 0:c.accessKey)&&void 0!==d?d:"",onChange:l.onUpdateDatasourceSecureJsonDataOption(e,"accessKey")})),r.createElement(a.InlineField,{label:"Secret Access Key",labelWidth:28},(null===(p=e.options.secureJsonFields)||void 0===p?void 0:p.secretKey)?r.createElement(a.ButtonGroup,{className:"width-30"},r.createElement(a.Input,{disabled:!0,placeholder:"Configured"}),r.createElement(a.ToolbarButton,{icon:"edit",type:"button",tooltip:"Edit Secret Access Key",onClick:l.onUpdateDatasourceResetOption(e,"secretKey")})):r.createElement(a.Input,{"aria-label":"Secret Access Key",className:"width-30",value:null!==(b=null===(m=N.secureJsonData)||void 0===m?void 0:m.secretKey)&&void 0!==b?b:"",onChange:l.onUpdateDatasourceSecureJsonDataOption(e,"secretKey")}))),k&&r.createElement(r.Fragment,null,r.createElement(a.InlineField,{label:"Assume Role ARN",labelWidth:28,tooltip:"Optionally, specify the ARN of a role to assume. Specifying a role here will ensure that the selected authentication provider is used to assume the specified role rather than using the credentials directly. Leave blank if you don't need to assume a role at all"},r.createElement(a.Input,{"aria-label":"Assume Role ARN",className:"width-30",placeholder:"arn:aws:iam:*",value:N.jsonData.assumeRoleArn||"",onChange:l.onUpdateDatasourceJsonDataOption(e,"assumeRoleArn")})),r.createElement(a.InlineField,{label:"External ID",labelWidth:28,tooltip:"If you are assuming a role in another account, that has been created with an external ID, specify the external ID here."},r.createElement(a.Input,{"aria-label":"External ID",className:"width-30",placeholder:"External ID",value:N.jsonData.externalId||"",onChange:l.onUpdateDatasourceJsonDataOption(e,"externalId")}))),!A&&r.createElement(a.InlineField,{label:"Endpoint",labelWidth:28,tooltip:"Optionally, specify a custom endpoint for the service"},r.createElement(a.Input,{"aria-label":"Endpoint",className:"width-30",placeholder:null!==(y=e.defaultEndpoint)&&void 0!==y?y:"https://{service}.{region}.amazonaws.com",value:N.jsonData.endpoint||"",onChange:l.onUpdateDatasourceJsonDataOption(e,"endpoint")})),r.createElement(a.InlineField,{label:"Default Region",labelWidth:28,tooltip:"Specify the region, such as for US West (Oregon) use ` us-west-2 ` as the region."},r.createElement(a.Select,{"aria-label":"Default Region",className:"width-30",value:j.find((function(e){return e.value===N.jsonData.defaultRegion})),options:j,defaultValue:N.jsonData.defaultRegion,allowCustomValue:!0,onChange:l.onUpdateDatasourceJsonDataOptionSelect(e,"defaultRegion"),formatCreateLabel:function(e){return"Use region: "+e},menuShouldPortal:!0})),e.children)};function y(e){var t=this,s=h(n.useState(e.value||e.default||null),2),i=s[0],l=s[1],p=h(n.useState(i?[i]:[]),2),g=p[0],m=p[1],v=h(n.useState(e.dependencies),2),f=v[0],b=v[1],y=h(n.useState(!1),2),x=y[0],j=y[1],E=h(n.useState(!1),2),I=E[0],w=E[1],_=n.useMemo((function(){var t=[{label:"default ("+e.default+")",value:"__default",description:"Default value set in the data source"}];return e.value&&"__default"!==e.value&&t.push({label:e.value,value:e.value}),t}),[e.default,e.value]),S=h(n.useState(e.default?_:[]),2),O=S[0],A=S[1];return n.useEffect((function(){void 0!==e.resources&&m(e.resources)}),[e.resources]),n.useEffect((function(){var t=e.default?_:[];g.length?(g.forEach((function(e){var s="string"==typeof e?e:e.value;t.find((function(e){return e.value===s}))||("string"==typeof e?t.push({label:e,value:e}):t.push(e))})),A(t)):A([])}),[g,_,e.default]),n.useEffect((function(){o.isEqual(e.dependencies,f)||(w(!1),l(null),e.onChange(null),b(e.dependencies))}),[e,f]),r.createElement(a.InlineField,{label:e.label,labelWidth:e.labelWidth,tooltip:e.tooltip,hidden:e.hidden},r.createElement("div",{"data-testid":e["data-testid"],title:e.title},r.createElement(a.Select,u({},e,{"aria-label":e.label,options:O,onChange:function(t){e.onChange(t),t.value&&l(t.value)},isLoading:x,className:e.className||"min-width-6",onOpenMenu:function(){return e.fetch&&c(t,void 0,void 0,(function(){return d(this,(function(s){switch(s.label){case 0:j(!0),s.label=1;case 1:return s.trys.push([1,,3,4]),[4,c(t,void 0,void 0,(function(){var t;return d(this,(function(s){switch(s.label){case 0:return I?[2]:e.saveOptions?[4,e.saveOptions()]:[3,2];case 1:s.sent(),s.label=2;case 2:return s.trys.push([2,,4,5]),[4,e.fetch()];case 3:return t=s.sent(),m(t),[3,5];case 4:return w(!0),[7];case 5:return[2]}}))}))];case 2:return s.sent(),[3,4];case 3:return j(!1),[7];case 4:return[2]}}))}))},menuShouldPortal:!0}))))}(m=t.rB||(t.rB={}))[m.Previous=0]="Previous",m[m.Null=1]="Null",m[m.Value=2]="Value";var x=[{label:"Previous Value",value:t.rB.Previous},{label:"NULL",value:t.rB.Null},{label:"Value",value:t.rB.Value}];function j(e){return"string"==typeof e?e:e.map((function(e){return function(e){return"'"+String(e).replace(/'/g,"''")+"'"}(e)})).join(",")}t.ConnectionConfig=b,t.SIGV4ConnectionConfig=function(e){var t,s,i,n,a=e.onOptionsChange,l=e.options,o={onOptionsChange:function(e){var t,s,i,n,r=u(u({},l),{jsonData:u(u({},l.jsonData),{sigV4AuthType:e.jsonData.authType,sigV4Profile:e.jsonData.profile,sigV4AssumeRoleArn:e.jsonData.assumeRoleArn,sigV4ExternalId:e.jsonData.externalId,sigV4Region:e.jsonData.defaultRegion,sigV4Endpoint:e.jsonData.endpoint}),secureJsonFields:{sigV4AccessKey:null===(t=e.secureJsonFields)||void 0===t?void 0:t.accessKey,sigV4SecretKey:null===(s=e.secureJsonFields)||void 0===s?void 0:s.secretKey},secureJsonData:{sigV4AccessKey:null===(i=e.secureJsonData)||void 0===i?void 0:i.accessKey,sigV4SecretKey:null===(n=e.secureJsonData)||void 0===n?void 0:n.secretKey}});a(r)},options:u(u({},l),{jsonData:u(u({},l.jsonData),{authType:l.jsonData.sigV4AuthType,profile:l.jsonData.sigV4Profile,assumeRoleArn:l.jsonData.sigV4AssumeRoleArn,externalId:l.jsonData.sigV4ExternalId,defaultRegion:l.jsonData.sigV4Region,endpoint:l.jsonData.sigV4Endpoint}),secureJsonFields:{accessKey:null===(t=l.secureJsonFields)||void 0===t?void 0:t.sigV4AccessKey,secretKey:null===(s=l.secureJsonFields)||void 0===s?void 0:s.sigV4SecretKey},secureJsonData:{accessKey:null===(i=l.secureJsonData)||void 0===i?void 0:i.sigV4AccessKey,secretKey:null===(n=l.secureJsonData)||void 0===n?void 0:n.sigV4SecretKey}})};return r.createElement(r.Fragment,null,r.createElement("div",{className:"gf-form"},r.createElement("h6",null,"SigV4 Auth Details")),r.createElement(b,u({},o,{skipHeader:!0,skipEndpoint:!0})))}},47472:(e,t,s)=>{"use strict";e.exports=s(98616)},15101:(e,t,s)=>{"use strict";const i=s(79584),n=Symbol("max"),r=Symbol("length"),a=Symbol("lengthCalculator"),l=Symbol("allowStale"),o=Symbol("maxAge"),u=Symbol("dispose"),c=Symbol("noDisposeOnSet"),d=Symbol("lruList"),h=Symbol("cache"),p=Symbol("updateAgeOnGet"),g=()=>1;const m=(e,t,s)=>{const i=e[h].get(t);if(i){const t=i.value;if(v(e,t)){if(b(e,i),!e[l])return}else s&&(e[p]&&(i.value.now=Date.now()),e[d].unshiftNode(i));return t.value}},v=(e,t)=>{if(!t||!t.maxAge&&!e[o])return!1;const s=Date.now()-t.now;return t.maxAge?s>t.maxAge:e[o]&&s>e[o]},f=e=>{if(e[r]>e[n])for(let t=e[d].tail;e[r]>e[n]&&null!==t;){const s=t.prev;b(e,t),t=s}},b=(e,t)=>{if(t){const s=t.value;e[u]&&e[u](s.key,s.value),e[r]-=s.length,e[h].delete(s.key),e[d].removeNode(t)}};class y{constructor(e,t,s,i,n){this.key=e,this.value=t,this.length=s,this.now=i,this.maxAge=n||0}}const x=(e,t,s,i)=>{let n=s.value;v(e,n)&&(b(e,s),e[l]||(n=void 0)),n&&t.call(i,n.value,n.key,e)};e.exports=class{constructor(e){if("number"==typeof e&&(e={max:e}),e||(e={}),e.max&&("number"!=typeof e.max||e.max<0))throw new TypeError("max must be a non-negative number");this[n]=e.max||1/0;const t=e.length||g;if(this[a]="function"!=typeof t?g:t,this[l]=e.stale||!1,e.maxAge&&"number"!=typeof e.maxAge)throw new TypeError("maxAge must be a number");this[o]=e.maxAge||0,this[u]=e.dispose,this[c]=e.noDisposeOnSet||!1,this[p]=e.updateAgeOnGet||!1,this.reset()}set max(e){if("number"!=typeof e||e<0)throw new TypeError("max must be a non-negative number");this[n]=e||1/0,f(this)}get max(){return this[n]}set allowStale(e){this[l]=!!e}get allowStale(){return this[l]}set maxAge(e){if("number"!=typeof e)throw new TypeError("maxAge must be a non-negative number");this[o]=e,f(this)}get maxAge(){return this[o]}set lengthCalculator(e){"function"!=typeof e&&(e=g),e!==this[a]&&(this[a]=e,this[r]=0,this[d].forEach((e=>{e.length=this[a](e.value,e.key),this[r]+=e.length}))),f(this)}get lengthCalculator(){return this[a]}get length(){return this[r]}get itemCount(){return this[d].length}rforEach(e,t){t=t||this;for(let s=this[d].tail;null!==s;){const i=s.prev;x(this,e,s,t),s=i}}forEach(e,t){t=t||this;for(let s=this[d].head;null!==s;){const i=s.next;x(this,e,s,t),s=i}}keys(){return this[d].toArray().map((e=>e.key))}values(){return this[d].toArray().map((e=>e.value))}reset(){this[u]&&this[d]&&this[d].length&&this[d].forEach((e=>this[u](e.key,e.value))),this[h]=new Map,this[d]=new i,this[r]=0}dump(){return this[d].map((e=>!v(this,e)&&{k:e.key,v:e.value,e:e.now+(e.maxAge||0)})).toArray().filter((e=>e))}dumpLru(){return this[d]}set(e,t,s){if((s=s||this[o])&&"number"!=typeof s)throw new TypeError("maxAge must be a number");const i=s?Date.now():0,l=this[a](t,e);if(this[h].has(e)){if(l>this[n])return b(this,this[h].get(e)),!1;const a=this[h].get(e).value;return this[u]&&(this[c]||this[u](e,a.value)),a.now=i,a.maxAge=s,a.value=t,this[r]+=l-a.length,a.length=l,this.get(e),f(this),!0}const p=new y(e,t,l,i,s);return p.length>this[n]?(this[u]&&this[u](e,t),!1):(this[r]+=p.length,this[d].unshift(p),this[h].set(e,this[d].head),f(this),!0)}has(e){if(!this[h].has(e))return!1;const t=this[h].get(e).value;return!v(this,t)}get(e){return m(this,e,!0)}peek(e){return m(this,e,!1)}pop(){const e=this[d].tail;return e?(b(this,e),e.value):null}del(e){b(this,this[h].get(e))}load(e){this.reset();const t=Date.now();for(let s=e.length-1;s>=0;s--){const i=e[s],n=i.e||0;if(0===n)this.set(i.k,i.v);else{const e=n-t;e>0&&this.set(i.k,i.v,e)}}}prune(){this[h].forEach(((e,t)=>m(this,t,!1)))}}},57734:(e,t,s)=>{const i=Symbol("SemVer ANY");class n{static get ANY(){return i}constructor(e,t){if(t=r(t),e instanceof n){if(e.loose===!!t.loose)return e;e=e.value}u("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===i?this.value="":this.value=this.operator+this.semver.version,u("comp",this)}parse(e){const t=this.options.loose?a[l.COMPARATORLOOSE]:a[l.COMPARATOR],s=e.match(t);if(!s)throw new TypeError(`Invalid comparator: ${e}`);this.operator=void 0!==s[1]?s[1]:"","="===this.operator&&(this.operator=""),s[2]?this.semver=new c(s[2],this.options.loose):this.semver=i}toString(){return this.value}test(e){if(u("Comparator.test",e,this.options.loose),this.semver===i||e===i)return!0;if("string"==typeof e)try{e=new c(e,this.options)}catch(e){return!1}return o(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof n))throw new TypeError("a Comparator is required");if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),""===this.operator)return""===this.value||new d(e.value,t).test(this.value);if(""===e.operator)return""===e.value||new d(this.value,t).test(e.semver);const s=!(">="!==this.operator&&">"!==this.operator||">="!==e.operator&&">"!==e.operator),i=!("<="!==this.operator&&"<"!==this.operator||"<="!==e.operator&&"<"!==e.operator),r=this.semver.version===e.semver.version,a=!(">="!==this.operator&&"<="!==this.operator||">="!==e.operator&&"<="!==e.operator),l=o(this.semver,"<",e.semver,t)&&(">="===this.operator||">"===this.operator)&&("<="===e.operator||"<"===e.operator),u=o(this.semver,">",e.semver,t)&&("<="===this.operator||"<"===this.operator)&&(">="===e.operator||">"===e.operator);return s||i||r&&a||l||u}}e.exports=n;const r=s(24996),{re:a,t:l}=s(67886),o=s(61434),u=s(11183),c=s(98823),d=s(258)},258:(e,t,s)=>{class i{constructor(e,t){if(t=r(t),e instanceof i)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new i(e.raw,t);if(e instanceof a)return this.raw=e.value,this.set=[[e]],this.format(),this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e,this.set=e.split("||").map((e=>this.parseRange(e.trim()))).filter((e=>e.length)),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${e}`);if(this.set.length>1){const e=this.set[0];if(this.set=this.set.filter((e=>!g(e[0]))),0===this.set.length)this.set=[e];else if(this.set.length>1)for(const e of this.set)if(1===e.length&&m(e[0])){this.set=[e];break}}this.format()}format(){return this.range=this.set.map((e=>e.join(" ").trim())).join("||").trim(),this.range}toString(){return this.range}parseRange(e){e=e.trim();const t=`parseRange:${Object.keys(this.options).join(",")}:${e}`,s=n.get(t);if(s)return s;const i=this.options.loose,r=i?u[c.HYPHENRANGELOOSE]:u[c.HYPHENRANGE];e=e.replace(r,O(this.options.includePrerelease)),l("hyphen replace",e),e=e.replace(u[c.COMPARATORTRIM],d),l("comparator trim",e);let o=(e=(e=(e=e.replace(u[c.TILDETRIM],h)).replace(u[c.CARETTRIM],p)).split(/\s+/).join(" ")).split(" ").map((e=>f(e,this.options))).join(" ").split(/\s+/).map((e=>S(e,this.options)));i&&(o=o.filter((e=>(l("loose invalid filter",e,this.options),!!e.match(u[c.COMPARATORLOOSE]))))),l("range list",o);const m=new Map,v=o.map((e=>new a(e,this.options)));for(const e of v){if(g(e))return[e];m.set(e.value,e)}m.size>1&&m.has("")&&m.delete("");const b=[...m.values()];return n.set(t,b),b}intersects(e,t){if(!(e instanceof i))throw new TypeError("a Range is required");return this.set.some((s=>v(s,t)&&e.set.some((e=>v(e,t)&&s.every((s=>e.every((e=>s.intersects(e,t)))))))))}test(e){if(!e)return!1;if("string"==typeof e)try{e=new o(e,this.options)}catch(e){return!1}for(let t=0;t<this.set.length;t++)if(A(this.set[t],e,this.options))return!0;return!1}}e.exports=i;const n=new(s(15101))({max:1e3}),r=s(24996),a=s(57734),l=s(11183),o=s(98823),{re:u,t:c,comparatorTrimReplace:d,tildeTrimReplace:h,caretTrimReplace:p}=s(67886),g=e=>"<0.0.0-0"===e.value,m=e=>""===e.value,v=(e,t)=>{let s=!0;const i=e.slice();let n=i.pop();for(;s&&i.length;)s=i.every((e=>n.intersects(e,t))),n=i.pop();return s},f=(e,t)=>(l("comp",e,t),e=j(e,t),l("caret",e),e=y(e,t),l("tildes",e),e=I(e,t),l("xrange",e),e=_(e,t),l("stars",e),e),b=e=>!e||"x"===e.toLowerCase()||"*"===e,y=(e,t)=>e.trim().split(/\s+/).map((e=>x(e,t))).join(" "),x=(e,t)=>{const s=t.loose?u[c.TILDELOOSE]:u[c.TILDE];return e.replace(s,((t,s,i,n,r)=>{let a;return l("tilde",e,t,s,i,n,r),b(s)?a="":b(i)?a=`>=${s}.0.0 <${+s+1}.0.0-0`:b(n)?a=`>=${s}.${i}.0 <${s}.${+i+1}.0-0`:r?(l("replaceTilde pr",r),a=`>=${s}.${i}.${n}-${r} <${s}.${+i+1}.0-0`):a=`>=${s}.${i}.${n} <${s}.${+i+1}.0-0`,l("tilde return",a),a}))},j=(e,t)=>e.trim().split(/\s+/).map((e=>E(e,t))).join(" "),E=(e,t)=>{l("caret",e,t);const s=t.loose?u[c.CARETLOOSE]:u[c.CARET],i=t.includePrerelease?"-0":"";return e.replace(s,((t,s,n,r,a)=>{let o;return l("caret",e,t,s,n,r,a),b(s)?o="":b(n)?o=`>=${s}.0.0${i} <${+s+1}.0.0-0`:b(r)?o="0"===s?`>=${s}.${n}.0${i} <${s}.${+n+1}.0-0`:`>=${s}.${n}.0${i} <${+s+1}.0.0-0`:a?(l("replaceCaret pr",a),o="0"===s?"0"===n?`>=${s}.${n}.${r}-${a} <${s}.${n}.${+r+1}-0`:`>=${s}.${n}.${r}-${a} <${s}.${+n+1}.0-0`:`>=${s}.${n}.${r}-${a} <${+s+1}.0.0-0`):(l("no pr"),o="0"===s?"0"===n?`>=${s}.${n}.${r}${i} <${s}.${n}.${+r+1}-0`:`>=${s}.${n}.${r}${i} <${s}.${+n+1}.0-0`:`>=${s}.${n}.${r} <${+s+1}.0.0-0`),l("caret return",o),o}))},I=(e,t)=>(l("replaceXRanges",e,t),e.split(/\s+/).map((e=>w(e,t))).join(" ")),w=(e,t)=>{e=e.trim();const s=t.loose?u[c.XRANGELOOSE]:u[c.XRANGE];return e.replace(s,((s,i,n,r,a,o)=>{l("xRange",e,s,i,n,r,a,o);const u=b(n),c=u||b(r),d=c||b(a),h=d;return"="===i&&h&&(i=""),o=t.includePrerelease?"-0":"",u?s=">"===i||"<"===i?"<0.0.0-0":"*":i&&h?(c&&(r=0),a=0,">"===i?(i=">=",c?(n=+n+1,r=0,a=0):(r=+r+1,a=0)):"<="===i&&(i="<",c?n=+n+1:r=+r+1),"<"===i&&(o="-0"),s=`${i+n}.${r}.${a}${o}`):c?s=`>=${n}.0.0${o} <${+n+1}.0.0-0`:d&&(s=`>=${n}.${r}.0${o} <${n}.${+r+1}.0-0`),l("xRange return",s),s}))},_=(e,t)=>(l("replaceStars",e,t),e.trim().replace(u[c.STAR],"")),S=(e,t)=>(l("replaceGTE0",e,t),e.trim().replace(u[t.includePrerelease?c.GTE0PRE:c.GTE0],"")),O=e=>(t,s,i,n,r,a,l,o,u,c,d,h,p)=>`${s=b(i)?"":b(n)?`>=${i}.0.0${e?"-0":""}`:b(r)?`>=${i}.${n}.0${e?"-0":""}`:a?`>=${s}`:`>=${s}${e?"-0":""}`} ${o=b(u)?"":b(c)?`<${+u+1}.0.0-0`:b(d)?`<${u}.${+c+1}.0-0`:h?`<=${u}.${c}.${d}-${h}`:e?`<${u}.${c}.${+d+1}-0`:`<=${o}`}`.trim(),A=(e,t,s)=>{for(let s=0;s<e.length;s++)if(!e[s].test(t))return!1;if(t.prerelease.length&&!s.includePrerelease){for(let s=0;s<e.length;s++)if(l(e[s].semver),e[s].semver!==a.ANY&&e[s].semver.prerelease.length>0){const i=e[s].semver;if(i.major===t.major&&i.minor===t.minor&&i.patch===t.patch)return!0}return!1}return!0}},98823:(e,t,s)=>{const i=s(11183),{MAX_LENGTH:n,MAX_SAFE_INTEGER:r}=s(14658),{re:a,t:l}=s(67886),o=s(24996),{compareIdentifiers:u}=s(44718);class c{constructor(e,t){if(t=o(t),e instanceof c){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if("string"!=typeof e)throw new TypeError(`Invalid Version: ${e}`);if(e.length>n)throw new TypeError(`version is longer than ${n} characters`);i("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;const s=e.trim().match(t.loose?a[l.LOOSE]:a[l.FULL]);if(!s)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+s[1],this.minor=+s[2],this.patch=+s[3],this.major>r||this.major<0)throw new TypeError("Invalid major version");if(this.minor>r||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>r||this.patch<0)throw new TypeError("Invalid patch version");s[4]?this.prerelease=s[4].split(".").map((e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t<r)return t}return e})):this.prerelease=[],this.build=s[5]?s[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(i("SemVer.compare",this.version,this.options,e),!(e instanceof c)){if("string"==typeof e&&e===this.version)return 0;e=new c(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof c||(e=new c(e,this.options)),u(this.major,e.major)||u(this.minor,e.minor)||u(this.patch,e.patch)}comparePre(e){if(e instanceof c||(e=new c(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{const s=this.prerelease[t],n=e.prerelease[t];if(i("prerelease compare",t,s,n),void 0===s&&void 0===n)return 0;if(void 0===n)return 1;if(void 0===s)return-1;if(s!==n)return u(s,n)}while(++t)}compareBuild(e){e instanceof c||(e=new c(e,this.options));let t=0;do{const s=this.build[t],n=e.build[t];if(i("prerelease compare",t,s,n),void 0===s&&void 0===n)return 0;if(void 0===n)return 1;if(void 0===s)return-1;if(s!==n)return u(s,n)}while(++t)}inc(e,t){switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t),this.inc("pre",t);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t),this.inc("pre",t);break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":if(0===this.prerelease.length)this.prerelease=[0];else{let e=this.prerelease.length;for(;--e>=0;)"number"==typeof this.prerelease[e]&&(this.prerelease[e]++,e=-2);-1===e&&this.prerelease.push(0)}t&&(0===u(this.prerelease[0],t)?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw new Error(`invalid increment argument: ${e}`)}return this.format(),this.raw=this.version,this}}e.exports=c},21320:(e,t,s)=>{const i=s(89944);e.exports=(e,t)=>{const s=i(e.trim().replace(/^[=v]+/,""),t);return s?s.version:null}},61434:(e,t,s)=>{const i=s(96556),n=s(53580),r=s(20412),a=s(5383),l=s(89352),o=s(93957);e.exports=(e,t,s,u)=>{switch(t){case"===":return"object"==typeof e&&(e=e.version),"object"==typeof s&&(s=s.version),e===s;case"!==":return"object"==typeof e&&(e=e.version),"object"==typeof s&&(s=s.version),e!==s;case"":case"=":case"==":return i(e,s,u);case"!=":return n(e,s,u);case">":return r(e,s,u);case">=":return a(e,s,u);case"<":return l(e,s,u);case"<=":return o(e,s,u);default:throw new TypeError(`Invalid operator: ${t}`)}}},27523:(e,t,s)=>{const i=s(98823),n=s(89944),{re:r,t:a}=s(67886);e.exports=(e,t)=>{if(e instanceof i)return e;if("number"==typeof e&&(e=String(e)),"string"!=typeof e)return null;let s=null;if((t=t||{}).rtl){let t;for(;(t=r[a.COERCERTL].exec(e))&&(!s||s.index+s[0].length!==e.length);)s&&t.index+t[0].length===s.index+s[0].length||(s=t),r[a.COERCERTL].lastIndex=t.index+t[1].length+t[2].length;r[a.COERCERTL].lastIndex=-1}else s=e.match(r[a.COERCE]);return null===s?null:n(`${s[2]}.${s[3]||"0"}.${s[4]||"0"}`,t)}},23159:(e,t,s)=>{const i=s(98823);e.exports=(e,t,s)=>{const n=new i(e,s),r=new i(t,s);return n.compare(r)||n.compareBuild(r)}},22219:(e,t,s)=>{const i=s(24804);e.exports=(e,t)=>i(e,t,!0)},24804:(e,t,s)=>{const i=s(98823);e.exports=(e,t,s)=>new i(e,s).compare(new i(t,s))},99233:(e,t,s)=>{const i=s(89944),n=s(96556);e.exports=(e,t)=>{if(n(e,t))return null;{const s=i(e),n=i(t),r=s.prerelease.length||n.prerelease.length,a=r?"pre":"",l=r?"prerelease":"";for(const e in s)if(("major"===e||"minor"===e||"patch"===e)&&s[e]!==n[e])return a+e;return l}}},96556:(e,t,s)=>{const i=s(24804);e.exports=(e,t,s)=>0===i(e,t,s)},20412:(e,t,s)=>{const i=s(24804);e.exports=(e,t,s)=>i(e,t,s)>0},5383:(e,t,s)=>{const i=s(24804);e.exports=(e,t,s)=>i(e,t,s)>=0},64451:(e,t,s)=>{const i=s(98823);e.exports=(e,t,s,n)=>{"string"==typeof s&&(n=s,s=void 0);try{return new i(e instanceof i?e.version:e,s).inc(t,n).version}catch(e){return null}}},89352:(e,t,s)=>{const i=s(24804);e.exports=(e,t,s)=>i(e,t,s)<0},93957:(e,t,s)=>{const i=s(24804);e.exports=(e,t,s)=>i(e,t,s)<=0},89292:(e,t,s)=>{const i=s(98823);e.exports=(e,t)=>new i(e,t).major},83209:(e,t,s)=>{const i=s(98823);e.exports=(e,t)=>new i(e,t).minor},53580:(e,t,s)=>{const i=s(24804);e.exports=(e,t,s)=>0!==i(e,t,s)},89944:(e,t,s)=>{const{MAX_LENGTH:i}=s(14658),{re:n,t:r}=s(67886),a=s(98823),l=s(24996);e.exports=(e,t)=>{if(t=l(t),e instanceof a)return e;if("string"!=typeof e)return null;if(e.length>i)return null;if(!(t.loose?n[r.LOOSE]:n[r.FULL]).test(e))return null;try{return new a(e,t)}catch(e){return null}}},39908:(e,t,s)=>{const i=s(98823);e.exports=(e,t)=>new i(e,t).patch},86058:(e,t,s)=>{const i=s(89944);e.exports=(e,t)=>{const s=i(e,t);return s&&s.prerelease.length?s.prerelease:null}},88816:(e,t,s)=>{const i=s(24804);e.exports=(e,t,s)=>i(t,e,s)},97987:(e,t,s)=>{const i=s(23159);e.exports=(e,t)=>e.sort(((e,s)=>i(s,e,t)))},62651:(e,t,s)=>{const i=s(258);e.exports=(e,t,s)=>{try{t=new i(t,s)}catch(e){return!1}return t.test(e)}},67815:(e,t,s)=>{const i=s(23159);e.exports=(e,t)=>e.sort(((e,s)=>i(e,s,t)))},22692:(e,t,s)=>{const i=s(89944);e.exports=(e,t)=>{const s=i(e,t);return s?s.version:null}},10129:(e,t,s)=>{const i=s(67886);e.exports={re:i.re,src:i.src,tokens:i.t,SEMVER_SPEC_VERSION:s(14658).SEMVER_SPEC_VERSION,SemVer:s(98823),compareIdentifiers:s(44718).compareIdentifiers,rcompareIdentifiers:s(44718).rcompareIdentifiers,parse:s(89944),valid:s(22692),clean:s(21320),inc:s(64451),diff:s(99233),major:s(89292),minor:s(83209),patch:s(39908),prerelease:s(86058),compare:s(24804),rcompare:s(88816),compareLoose:s(22219),compareBuild:s(23159),sort:s(67815),rsort:s(97987),gt:s(20412),lt:s(89352),eq:s(96556),neq:s(53580),gte:s(5383),lte:s(93957),cmp:s(61434),coerce:s(27523),Comparator:s(57734),Range:s(258),satisfies:s(62651),toComparators:s(64967),maxSatisfying:s(14521),minSatisfying:s(84305),minVersion:s(78674),validRange:s(82819),outside:s(67423),gtr:s(8406),ltr:s(89018),intersects:s(26208),simplifyRange:s(98181),subset:s(71610)}},14658:e=>{const t=Number.MAX_SAFE_INTEGER||9007199254740991;e.exports={SEMVER_SPEC_VERSION:"2.0.0",MAX_LENGTH:256,MAX_SAFE_INTEGER:t,MAX_SAFE_COMPONENT_LENGTH:16}},11183:e=>{const t="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};e.exports=t},44718:e=>{const t=/^[0-9]+$/,s=(e,s)=>{const i=t.test(e),n=t.test(s);return i&&n&&(e=+e,s=+s),e===s?0:i&&!n?-1:n&&!i?1:e<s?-1:1};e.exports={compareIdentifiers:s,rcompareIdentifiers:(e,t)=>s(t,e)}},24996:e=>{const t=["includePrerelease","loose","rtl"];e.exports=e=>e?"object"!=typeof e?{loose:!0}:t.filter((t=>e[t])).reduce(((e,t)=>(e[t]=!0,e)),{}):{}},67886:(e,t,s)=>{const{MAX_SAFE_COMPONENT_LENGTH:i}=s(14658),n=s(11183),r=(t=e.exports={}).re=[],a=t.src=[],l=t.t={};let o=0;const u=(e,t,s)=>{const i=o++;n(e,i,t),l[e]=i,a[i]=t,r[i]=new RegExp(t,s?"g":void 0)};u("NUMERICIDENTIFIER","0|[1-9]\\d*"),u("NUMERICIDENTIFIERLOOSE","[0-9]+"),u("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),u("MAINVERSION",`(${a[l.NUMERICIDENTIFIER]})\\.(${a[l.NUMERICIDENTIFIER]})\\.(${a[l.NUMERICIDENTIFIER]})`),u("MAINVERSIONLOOSE",`(${a[l.NUMERICIDENTIFIERLOOSE]})\\.(${a[l.NUMERICIDENTIFIERLOOSE]})\\.(${a[l.NUMERICIDENTIFIERLOOSE]})`),u("PRERELEASEIDENTIFIER",`(?:${a[l.NUMERICIDENTIFIER]}|${a[l.NONNUMERICIDENTIFIER]})`),u("PRERELEASEIDENTIFIERLOOSE",`(?:${a[l.NUMERICIDENTIFIERLOOSE]}|${a[l.NONNUMERICIDENTIFIER]})`),u("PRERELEASE",`(?:-(${a[l.PRERELEASEIDENTIFIER]}(?:\\.${a[l.PRERELEASEIDENTIFIER]})*))`),u("PRERELEASELOOSE",`(?:-?(${a[l.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${a[l.PRERELEASEIDENTIFIERLOOSE]})*))`),u("BUILDIDENTIFIER","[0-9A-Za-z-]+"),u("BUILD",`(?:\\+(${a[l.BUILDIDENTIFIER]}(?:\\.${a[l.BUILDIDENTIFIER]})*))`),u("FULLPLAIN",`v?${a[l.MAINVERSION]}${a[l.PRERELEASE]}?${a[l.BUILD]}?`),u("FULL",`^${a[l.FULLPLAIN]}$`),u("LOOSEPLAIN",`[v=\\s]*${a[l.MAINVERSIONLOOSE]}${a[l.PRERELEASELOOSE]}?${a[l.BUILD]}?`),u("LOOSE",`^${a[l.LOOSEPLAIN]}$`),u("GTLT","((?:<|>)?=?)"),u("XRANGEIDENTIFIERLOOSE",`${a[l.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),u("XRANGEIDENTIFIER",`${a[l.NUMERICIDENTIFIER]}|x|X|\\*`),u("XRANGEPLAIN",`[v=\\s]*(${a[l.XRANGEIDENTIFIER]})(?:\\.(${a[l.XRANGEIDENTIFIER]})(?:\\.(${a[l.XRANGEIDENTIFIER]})(?:${a[l.PRERELEASE]})?${a[l.BUILD]}?)?)?`),u("XRANGEPLAINLOOSE",`[v=\\s]*(${a[l.XRANGEIDENTIFIERLOOSE]})(?:\\.(${a[l.XRANGEIDENTIFIERLOOSE]})(?:\\.(${a[l.XRANGEIDENTIFIERLOOSE]})(?:${a[l.PRERELEASELOOSE]})?${a[l.BUILD]}?)?)?`),u("XRANGE",`^${a[l.GTLT]}\\s*${a[l.XRANGEPLAIN]}$`),u("XRANGELOOSE",`^${a[l.GTLT]}\\s*${a[l.XRANGEPLAINLOOSE]}$`),u("COERCE",`(^|[^\\d])(\\d{1,${i}})(?:\\.(\\d{1,${i}}))?(?:\\.(\\d{1,${i}}))?(?:$|[^\\d])`),u("COERCERTL",a[l.COERCE],!0),u("LONETILDE","(?:~>?)"),u("TILDETRIM",`(\\s*)${a[l.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",u("TILDE",`^${a[l.LONETILDE]}${a[l.XRANGEPLAIN]}$`),u("TILDELOOSE",`^${a[l.LONETILDE]}${a[l.XRANGEPLAINLOOSE]}$`),u("LONECARET","(?:\\^)"),u("CARETTRIM",`(\\s*)${a[l.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",u("CARET",`^${a[l.LONECARET]}${a[l.XRANGEPLAIN]}$`),u("CARETLOOSE",`^${a[l.LONECARET]}${a[l.XRANGEPLAINLOOSE]}$`),u("COMPARATORLOOSE",`^${a[l.GTLT]}\\s*(${a[l.LOOSEPLAIN]})$|^$`),u("COMPARATOR",`^${a[l.GTLT]}\\s*(${a[l.FULLPLAIN]})$|^$`),u("COMPARATORTRIM",`(\\s*)${a[l.GTLT]}\\s*(${a[l.LOOSEPLAIN]}|${a[l.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",u("HYPHENRANGE",`^\\s*(${a[l.XRANGEPLAIN]})\\s+-\\s+(${a[l.XRANGEPLAIN]})\\s*$`),u("HYPHENRANGELOOSE",`^\\s*(${a[l.XRANGEPLAINLOOSE]})\\s+-\\s+(${a[l.XRANGEPLAINLOOSE]})\\s*$`),u("STAR","(<|>)?=?\\s*\\*"),u("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),u("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")},8406:(e,t,s)=>{const i=s(67423);e.exports=(e,t,s)=>i(e,t,">",s)},26208:(e,t,s)=>{const i=s(258);e.exports=(e,t,s)=>(e=new i(e,s),t=new i(t,s),e.intersects(t))},89018:(e,t,s)=>{const i=s(67423);e.exports=(e,t,s)=>i(e,t,"<",s)},14521:(e,t,s)=>{const i=s(98823),n=s(258);e.exports=(e,t,s)=>{let r=null,a=null,l=null;try{l=new n(t,s)}catch(e){return null}return e.forEach((e=>{l.test(e)&&(r&&-1!==a.compare(e)||(r=e,a=new i(r,s)))})),r}},84305:(e,t,s)=>{const i=s(98823),n=s(258);e.exports=(e,t,s)=>{let r=null,a=null,l=null;try{l=new n(t,s)}catch(e){return null}return e.forEach((e=>{l.test(e)&&(r&&1!==a.compare(e)||(r=e,a=new i(r,s)))})),r}},78674:(e,t,s)=>{const i=s(98823),n=s(258),r=s(20412);e.exports=(e,t)=>{e=new n(e,t);let s=new i("0.0.0");if(e.test(s))return s;if(s=new i("0.0.0-0"),e.test(s))return s;s=null;for(let t=0;t<e.set.length;++t){const n=e.set[t];let a=null;n.forEach((e=>{const t=new i(e.semver.version);switch(e.operator){case">":0===t.prerelease.length?t.patch++:t.prerelease.push(0),t.raw=t.format();case"":case">=":a&&!r(t,a)||(a=t);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${e.operator}`)}})),!a||s&&!r(s,a)||(s=a)}return s&&e.test(s)?s:null}},67423:(e,t,s)=>{const i=s(98823),n=s(57734),{ANY:r}=n,a=s(258),l=s(62651),o=s(20412),u=s(89352),c=s(93957),d=s(5383);e.exports=(e,t,s,h)=>{let p,g,m,v,f;switch(e=new i(e,h),t=new a(t,h),s){case">":p=o,g=c,m=u,v=">",f=">=";break;case"<":p=u,g=d,m=o,v="<",f="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(l(e,t,h))return!1;for(let s=0;s<t.set.length;++s){const i=t.set[s];let a=null,l=null;if(i.forEach((e=>{e.semver===r&&(e=new n(">=0.0.0")),a=a||e,l=l||e,p(e.semver,a.semver,h)?a=e:m(e.semver,l.semver,h)&&(l=e)})),a.operator===v||a.operator===f)return!1;if((!l.operator||l.operator===v)&&g(e,l.semver))return!1;if(l.operator===f&&m(e,l.semver))return!1}return!0}},98181:(e,t,s)=>{const i=s(62651),n=s(24804);e.exports=(e,t,s)=>{const r=[];let a=null,l=null;const o=e.sort(((e,t)=>n(e,t,s)));for(const e of o){i(e,t,s)?(l=e,a||(a=e)):(l&&r.push([a,l]),l=null,a=null)}a&&r.push([a,null]);const u=[];for(const[e,t]of r)e===t?u.push(e):t||e!==o[0]?t?e===o[0]?u.push(`<=${t}`):u.push(`${e} - ${t}`):u.push(`>=${e}`):u.push("*");const c=u.join(" || "),d="string"==typeof t.raw?t.raw:String(t);return c.length<d.length?c:t}},71610:(e,t,s)=>{const i=s(258),n=s(57734),{ANY:r}=n,a=s(62651),l=s(24804),o=(e,t,s)=>{if(e===t)return!0;if(1===e.length&&e[0].semver===r){if(1===t.length&&t[0].semver===r)return!0;e=s.includePrerelease?[new n(">=0.0.0-0")]:[new n(">=0.0.0")]}if(1===t.length&&t[0].semver===r){if(s.includePrerelease)return!0;t=[new n(">=0.0.0")]}const i=new Set;let o,d,h,p,g,m,v;for(const t of e)">"===t.operator||">="===t.operator?o=u(o,t,s):"<"===t.operator||"<="===t.operator?d=c(d,t,s):i.add(t.semver);if(i.size>1)return null;if(o&&d){if(h=l(o.semver,d.semver,s),h>0)return null;if(0===h&&(">="!==o.operator||"<="!==d.operator))return null}for(const e of i){if(o&&!a(e,String(o),s))return null;if(d&&!a(e,String(d),s))return null;for(const i of t)if(!a(e,String(i),s))return!1;return!0}let f=!(!d||s.includePrerelease||!d.semver.prerelease.length)&&d.semver,b=!(!o||s.includePrerelease||!o.semver.prerelease.length)&&o.semver;f&&1===f.prerelease.length&&"<"===d.operator&&0===f.prerelease[0]&&(f=!1);for(const e of t){if(v=v||">"===e.operator||">="===e.operator,m=m||"<"===e.operator||"<="===e.operator,o)if(b&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===b.major&&e.semver.minor===b.minor&&e.semver.patch===b.patch&&(b=!1),">"===e.operator||">="===e.operator){if(p=u(o,e,s),p===e&&p!==o)return!1}else if(">="===o.operator&&!a(o.semver,String(e),s))return!1;if(d)if(f&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===f.major&&e.semver.minor===f.minor&&e.semver.patch===f.patch&&(f=!1),"<"===e.operator||"<="===e.operator){if(g=c(d,e,s),g===e&&g!==d)return!1}else if("<="===d.operator&&!a(d.semver,String(e),s))return!1;if(!e.operator&&(d||o)&&0!==h)return!1}return!(o&&m&&!d&&0!==h)&&(!(d&&v&&!o&&0!==h)&&(!b&&!f))},u=(e,t,s)=>{if(!e)return t;const i=l(e.semver,t.semver,s);return i>0?e:i<0||">"===t.operator&&">="===e.operator?t:e},c=(e,t,s)=>{if(!e)return t;const i=l(e.semver,t.semver,s);return i<0?e:i>0||"<"===t.operator&&"<="===e.operator?t:e};e.exports=(e,t,s={})=>{if(e===t)return!0;e=new i(e,s),t=new i(t,s);let n=!1;e:for(const i of e.set){for(const e of t.set){const t=o(i,e,s);if(n=n||null!==t,t)continue e}if(n)return!1}return!0}},64967:(e,t,s)=>{const i=s(258);e.exports=(e,t)=>new i(e,t).set.map((e=>e.map((e=>e.value)).join(" ").trim().split(" ")))},82819:(e,t,s)=>{const i=s(258);e.exports=(e,t)=>{try{return new i(e,t).range||"*"}catch(e){return null}}},81389:e=>{"use strict";e.exports=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}},79584:(e,t,s)=>{"use strict";function i(e){var t=this;if(t instanceof i||(t=new i),t.tail=null,t.head=null,t.length=0,e&&"function"==typeof e.forEach)e.forEach((function(e){t.push(e)}));else if(arguments.length>0)for(var s=0,n=arguments.length;s<n;s++)t.push(arguments[s]);return t}function n(e,t,s){var i=t===e.head?new l(s,null,t,e):new l(s,t,t.next,e);return null===i.next&&(e.tail=i),null===i.prev&&(e.head=i),e.length++,i}function r(e,t){e.tail=new l(t,e.tail,null,e),e.head||(e.head=e.tail),e.length++}function a(e,t){e.head=new l(t,null,e.head,e),e.tail||(e.tail=e.head),e.length++}function l(e,t,s,i){if(!(this instanceof l))return new l(e,t,s,i);this.list=i,this.value=e,t?(t.next=this,this.prev=t):this.prev=null,s?(s.prev=this,this.next=s):this.next=null}e.exports=i,i.Node=l,i.create=i,i.prototype.removeNode=function(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");var t=e.next,s=e.prev;return t&&(t.prev=s),s&&(s.next=t),e===this.head&&(this.head=t),e===this.tail&&(this.tail=s),e.list.length--,e.next=null,e.prev=null,e.list=null,t},i.prototype.unshiftNode=function(e){if(e!==this.head){e.list&&e.list.removeNode(e);var t=this.head;e.list=this,e.next=t,t&&(t.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}},i.prototype.pushNode=function(e){if(e!==this.tail){e.list&&e.list.removeNode(e);var t=this.tail;e.list=this,e.prev=t,t&&(t.next=e),this.tail=e,this.head||(this.head=e),this.length++}},i.prototype.push=function(){for(var e=0,t=arguments.length;e<t;e++)r(this,arguments[e]);return this.length},i.prototype.unshift=function(){for(var e=0,t=arguments.length;e<t;e++)a(this,arguments[e]);return this.length},i.prototype.pop=function(){if(this.tail){var e=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}},i.prototype.shift=function(){if(this.head){var e=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}},i.prototype.forEach=function(e,t){t=t||this;for(var s=this.head,i=0;null!==s;i++)e.call(t,s.value,i,this),s=s.next},i.prototype.forEachReverse=function(e,t){t=t||this;for(var s=this.tail,i=this.length-1;null!==s;i--)e.call(t,s.value,i,this),s=s.prev},i.prototype.get=function(e){for(var t=0,s=this.head;null!==s&&t<e;t++)s=s.next;if(t===e&&null!==s)return s.value},i.prototype.getReverse=function(e){for(var t=0,s=this.tail;null!==s&&t<e;t++)s=s.prev;if(t===e&&null!==s)return s.value},i.prototype.map=function(e,t){t=t||this;for(var s=new i,n=this.head;null!==n;)s.push(e.call(t,n.value,this)),n=n.next;return s},i.prototype.mapReverse=function(e,t){t=t||this;for(var s=new i,n=this.tail;null!==n;)s.push(e.call(t,n.value,this)),n=n.prev;return s},i.prototype.reduce=function(e,t){var s,i=this.head;if(arguments.length>1)s=t;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");i=this.head.next,s=this.head.value}for(var n=0;null!==i;n++)s=e(s,i.value,n),i=i.next;return s},i.prototype.reduceReverse=function(e,t){var s,i=this.tail;if(arguments.length>1)s=t;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");i=this.tail.prev,s=this.tail.value}for(var n=this.length-1;null!==i;n--)s=e(s,i.value,n),i=i.prev;return s},i.prototype.toArray=function(){for(var e=new Array(this.length),t=0,s=this.head;null!==s;t++)e[t]=s.value,s=s.next;return e},i.prototype.toArrayReverse=function(){for(var e=new Array(this.length),t=0,s=this.tail;null!==s;t++)e[t]=s.value,s=s.prev;return e},i.prototype.slice=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var s=new i;if(t<e||t<0)return s;e<0&&(e=0),t>this.length&&(t=this.length);for(var n=0,r=this.head;null!==r&&n<e;n++)r=r.next;for(;null!==r&&n<t;n++,r=r.next)s.push(r.value);return s},i.prototype.sliceReverse=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var s=new i;if(t<e||t<0)return s;e<0&&(e=0),t>this.length&&(t=this.length);for(var n=this.length,r=this.tail;null!==r&&n>t;n--)r=r.prev;for(;null!==r&&n>e;n--,r=r.prev)s.push(r.value);return s},i.prototype.splice=function(e,t,...s){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var i=0,r=this.head;null!==r&&i<e;i++)r=r.next;var a=[];for(i=0;r&&i<t;i++)a.push(r.value),r=this.removeNode(r);null===r&&(r=this.tail),r!==this.head&&r!==this.tail&&(r=r.prev);for(i=0;i<s.length;i++)r=n(this,r,s[i]);return a},i.prototype.reverse=function(){for(var e=this.head,t=this.tail,s=e;null!==s;s=s.prev){var i=s.prev;s.prev=s.next,s.next=i}return this.head=t,this.tail=e,this};try{s(81389)(i)}catch(e){}}}]);
  90. //# sourceMappingURL=elasticsearchPlugin.088f0f9cf1a569c3df3c.js.map