(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[9782],{"./public/app/features/explore/Wrapper.tsx":(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>fi});var i=s("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js"),n=s("./.yarn/__virtual__/react-redux-virtual-7ad20a440e/3/opt/drone/yarncache/react-redux-npm-7.2.6-134f5ed64d-0bf142ce0d.zip/node_modules/react-redux/es/index.js"),o=s("./public/app/types/explore.ts"),r=s("./packages/grafana-ui/src/index.ts"),a=s("./public/app/features/explore/state/main.ts"),l=s("./public/app/core/utils/richHistory.ts"),c=s("../../opt/drone/yarncache/memoize-one-npm-6.0.0-8b2a2cd020-f185ea69f7.zip/node_modules/memoize-one/dist/memoize-one.esm.js"),d=s("./packages/grafana-data/src/index.ts"),p=s("./packages/grafana-e2e-selectors/src/index.ts"),u=s("./public/app/core/store.ts"),h=s("./public/app/features/explore/state/explorePane.ts"),g=s("./public/app/core/utils/explore.ts"),m=s("./public/app/features/profile/state/selectors.ts"),f=s("./.yarn/__virtual__/@emotion-css-virtual-72c314ddb1/3/opt/drone/yarncache/@emotion-css-npm-11.7.1-25ff8755a7-ac1f56656f.zip/node_modules/@emotion/css/dist/emotion-css.esm.js"),x=s("../../opt/drone/yarncache/redux-npm-4.1.2-04cdbe7a08-6a839cee5b.zip/node_modules/redux/es/redux.js"),v=s("./.yarn/__virtual__/react-virtualized-auto-sizer-virtual-b5ab366cb0/3/opt/drone/yarncache/react-virtualized-auto-sizer-npm-1.0.6-50869b8392-81270e9d32.zip/node_modules/react-virtualized-auto-sizer/dist/index.esm.js"),y=s("./public/app/features/explore/state/query.ts"),b=s("./public/app/features/explore/state/time.ts"),w=s("../../opt/drone/yarncache/tinycolor2-npm-1.4.2-462ba30c26-57ed262e08.zip/node_modules/tinycolor2/tinycolor.js"),S=s.n(w);const j=function(e,t){var s=(0,i.useRef)((function(){}));(0,i.useEffect)((function(){s.current=e})),(0,i.useEffect)((function(){if(null!==t){var e=setInterval((function(){return s.current()}),t||0);return function(){return clearInterval(e)}}}),[t])};var C=s("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/jsx-runtime.js");const T=e=>{let{timeInMs:t,className:s,humanize:i}=e;return(0,C.jsx)("span",{className:`elapsed-time ${s}`,children:R(t,i)})},R=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const s=e/1e3;if(!t)return`${s.toFixed(1)}s`;const i=(0,d.toDuration)(s,"seconds"),n=i.hours(),o=i.minutes(),r=i.seconds();return n?`${n}h ${o}m ${r}s`:o?`${o}m ${r}s`:`${r}s`},I=e=>{let{resetKey:t,humanize:s,className:n}=e;const[o,r]=(0,i.useState)(0);return j((()=>r(o+150)),150),(0,i.useEffect)((()=>r(0)),[t]),(0,C.jsx)(T,{timeInMs:o,className:n,humanize:s})};var k;function z(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class D extends i.PureComponent{constructor(e){super(e),z(this,"liveEndDiv",null),z(this,"scrollContainerRef",i.createRef()),z(this,"onScroll",(e=>{const{isPaused:t,onPause:s}=this.props,{scrollTop:i,clientHeight:n,scrollHeight:o}=e.currentTarget;o-(i+n)>=5&&!t&&s()})),z(this,"rowsToRender",(()=>{const{isPaused:e}=this.props;let{logRowsToRender:t=[]}=this.state;return e||(t=t.slice(-100)),t})),this.state={logRowsToRender:e.logRows}}static getDerivedStateFromProps(e,t){return e.isPaused?null:{logRowsToRender:e.logRows}}render(){const{theme:e,timeZone:t,onPause:s,onResume:i,isPaused:n}=this.props,o=(e=>({logsRowsLive:f.css`
    label: logs-rows-live;
    font-family: ${e.typography.fontFamilyMonospace};
    font-size: ${e.typography.bodySmall.fontSize};
    display: flex;
    flex-flow: column nowrap;
    height: 60vh;
    overflow-y: scroll;
    :first-child {
      margin-top: auto !important;
    }
  `,logsRowFade:f.css`
    label: logs-row-fresh;
    color: ${e.colors.text};
    background-color: ${S()(e.colors.info.transparent).setAlpha(.25).toString()};
    animation: fade 1s ease-out 1s 1 normal forwards;
    @keyframes fade {
      from {
        background-color: ${S()(e.colors.info.transparent).setAlpha(.25).toString()};
      }
      to {
        background-color: transparent;
      }
    }
  `,logsRowsIndicator:f.css`
    font-size: ${e.typography.h6.fontSize};
    padding-top: ${e.spacing(1)};
    display: flex;
    align-items: center;
  `,button:f.css`
    margin-right: ${e.spacing(1)};
  `,fullWidth:f.css`
    width: 100%;
  `}))(e),{logsRow:a,logsRowLocalTime:l,logsRowMessage:c}=(0,r.getLogRowStyles)(e);return(0,C.jsxs)("div",{children:[(0,C.jsx)("table",{className:o.fullWidth,children:(0,C.jsxs)("tbody",{onScroll:n?void 0:this.onScroll,className:(0,f.cx)(["logs-rows",o.logsRowsLive]),ref:this.scrollContainerRef,children:[this.rowsToRender().map((e=>(0,C.jsxs)("tr",{className:(0,f.cx)(a,o.logsRowFade),children:[(0,C.jsx)("td",{className:(0,f.cx)(l),children:(0,d.dateTimeFormat)(e.timeEpochMs,{timeZone:t})}),(0,C.jsx)("td",{className:(0,f.cx)(c),children:e.hasAnsi?(0,C.jsx)(r.LogMessageAnsi,{value:e.raw}):e.entry})]},e.uid))),(0,C.jsx)("tr",{ref:e=>{var t;(this.liveEndDiv=e,this.liveEndDiv&&!n)&&(null===(t=this.scrollContainerRef.current)||void 0===t||t.scrollTo(0,this.scrollContainerRef.current.scrollHeight))}})]})}),(0,C.jsxs)("div",{className:o.logsRowsIndicator,children:[(0,C.jsxs)(r.Button,{variant:"secondary",onClick:n?i:s,className:o.button,children:[(0,C.jsx)(r.Icon,{name:n?"play":"pause"})," ",n?"Resume":"Pause"]}),(0,C.jsxs)(r.Button,{variant:"secondary",onClick:this.props.stopLive,className:o.button,children:[k||(k=(0,C.jsx)(r.Icon,{name:"square-shape",size:"lg",type:"mono"})),"  Exit live mode"]}),n||(0,C.jsxs)("span",{children:["Last line received: ",(0,C.jsx)(I,{resetKey:this.props.logRows,humanize:!0})," ago"]})]})]})}}const F=(0,r.withTheme2)(D);var L=s("../../opt/drone/yarncache/lodash-npm-4.17.21-6382451519-eb835a2e51.zip/node_modules/lodash/lodash.js"),N=s("./packages/grafana-schema/src/index.ts"),O=s("./public/app/core/logs_model.ts"),$=s("./packages/grafana-ui/src/components/Logs/LogRowMessage.tsx");const E=e=>({metaContainer:f.css`
    flex: 1;
    color: ${e.colors.text.secondary};
    margin-bottom: ${e.spacing(2)};
    min-width: 30%;
    display: flex;
    flex-wrap: wrap;
  `,metaItem:f.css`
    margin-right: ${e.spacing(2)};
    margin-top: ${e.spacing(.5)};
    display: flex;
    align-items: baseline;

    .logs-meta-item__error {
      color: ${e.colors.error.text};
    }
  `,metaLabel:f.css`
    margin-right: calc(${e.spacing(2)} / 2);
    font-size: ${e.typography.bodySmall.fontSize};
    font-weight: ${e.typography.fontWeightMedium};
  `,metaValue:f.css`
    font-family: ${e.typography.fontFamilyMonospace};
    font-size: ${e.typography.bodySmall.fontSize};
  `}),M=(0,i.memo)((function(e){const t=(0,r.useStyles2)(E),{label:s,value:i}=e;return(0,C.jsxs)("div",{className:t.metaItem,children:[s&&(0,C.jsxs)("span",{className:t.metaLabel,children:[s,":"]}),(0,C.jsx)("span",{className:t.metaValue,children:i})]})})),B=(0,i.memo)((function(e){const t=(0,r.useStyles2)(E),{metaItems:s}=e;return(0,C.jsx)("div",{className:t.metaContainer,children:s.map(((e,t)=>(0,C.jsx)(M,{label:e.label,value:e.value},`${t}-${e.label}`)))})}));var P;const A=i.memo((e=>{let{meta:t,dedupStrategy:s,dedupCount:i,showDetectedFields:n,clearDetectedFields:o,hasUnescapedContent:a,forceEscape:l,onEscapeNewlines:c,logRows:p}=e;const u=[...t];return s!==d.LogsDedupStrategy.none&&u.push({label:"Dedup count",value:i,kind:d.LogsMetaKind.Number}),p.some((e=>e.entry.length>$.n))&&u.push({label:"Info",value:"Logs with more than 100,000 characters could not be parsed and highlighted",kind:d.LogsMetaKind.String}),(null==n?void 0:n.length)>0&&u.push({label:"Showing only detected fields",value:q(n,d.LogsMetaKind.LabelsMap)},{label:"",value:(0,C.jsx)(r.Button,{variant:"secondary",size:"sm",onClick:o,children:"Show all detected fields"})}),a&&u.push({label:"Your logs might have incorrectly escaped content",value:(0,C.jsx)(r.Tooltip,{content:"We suggest to try to fix the escaping of your log lines first. This is an experimental feature, your logs might not be correctly escaped.",placement:"right",children:(0,C.jsxs)(r.Button,{variant:"secondary",size:"sm",onClick:c,children:[(0,C.jsxs)("span",{children:[l?"Remove escaping":"Escape newlines"," "]}),P||(P=(0,C.jsx)(r.Icon,{name:"exclamation-triangle",className:"muted",size:"sm"}))]})})}),(0,C.jsx)(C.Fragment,{children:u&&(0,C.jsx)(B,{metaItems:u.map((e=>({label:e.label,value:"kind"in e?q(e.value,e.kind):e.value})))})})}));function q(e,t){return t===d.LogsMetaKind.LabelsMap?(0,C.jsx)("span",{className:"logs-meta-item__labels",children:(0,C.jsx)(r.LogLabels,{labels:e})}):t===d.LogsMetaKind.Error?(0,C.jsx)("span",{className:"logs-meta-item__error",children:e}):e}var Z;function _(e){let{pages:t,currentPageIndex:s,oldestLogsFirst:i,timeZone:n,loading:o,changeTime:a}=e;const l=e=>`${(0,d.dateTimeFormat)(e,{format:d.systemDateFormats.interval.second,timeZone:n})}`,c=(e,t)=>{if(s===t&&o)return Z||(Z=(0,C.jsx)(r.Spinner,{}));return`${l(i?e.logsRange.from:e.logsRange.to)} — ${l(i?e.logsRange.to:e.logsRange.from)}`},p=(0,r.useTheme2)(),u=H(p,o);return(0,C.jsx)(r.CustomScrollbar,{autoHide:!0,children:(0,C.jsx)("div",{className:u.pagesWrapper,"data-testid":"logsNavigationPages",children:(0,C.jsx)("div",{className:u.pagesContainer,children:t.map(((e,t)=>(0,C.jsxs)("div",{"data-testid":`page${t+1}`,className:u.page,onClick:()=>!o&&a({from:e.queryRange.from,to:e.queryRange.to}),children:[(0,C.jsx)("div",{className:(0,f.cx)(u.line,{selectedBg:s===t})}),(0,C.jsx)("div",{className:(0,f.cx)(u.time,{selectedText:s===t}),children:c(e,t)})]},e.queryRange.to)))})})})}A.displayName="LogsMetaRow";const H=(e,t)=>({pagesWrapper:f.css`
      height: 100%;
      padding-left: ${e.spacing(.5)};
      display: flex;
      flex-direction: column;
      overflow-y: scroll;
      &::after {
        content: '';
        display: block;
        background: repeating-linear-gradient(
          135deg,
          ${e.colors.background.primary},
          ${e.colors.background.primary} 5px,
          ${e.colors.background.secondary} 5px,
          ${e.colors.background.secondary} 15px
        );
        width: 3px;
        height: inherit;
        margin-bottom: 8px;
      }
    `,pagesContainer:f.css`
      display: flex;
      padding: 0;
      flex-direction: column;
    `,page:f.css`
      display: flex;
      margin: ${e.spacing(2)} 0;
      cursor: ${t?"auto":"pointer"};
      white-space: normal;
      .selectedBg {
        background: ${e.colors.primary.main};
      }
      .selectedText {
        color: ${e.colors.primary.main};
      }
    `,line:f.css`
      width: 3px;
      height: 100%;
      align-items: center;
      background: ${e.colors.text.secondary};
    `,time:f.css`
      width: 60px;
      min-height: 80px;
      font-size: ${e.v1.typography.size.sm};
      padding-left: ${e.spacing(.5)};
      display: flex;
      align-items: center;
    `});var Q,W,U;function V(e){let{absoluteRange:t,logsSortOrder:s,timeZone:n,loading:o,onChangeTime:a,scrollToTopLogs:l,visibleRange:c,queries:p,clearCache:u,addResultsToCache:h}=e;const[g,m]=(0,i.useState)([]),[f,x]=(0,i.useState)(0),v=(0,i.useRef)(),y=(0,i.useRef)(),b=(0,i.useRef)(0),w=s===d.LogsSortOrder.Ascending,S=w?f===g.length-1:0===f,j=w?0===f:f===g.length-1,T=(0,r.useTheme2)(),R=K(T,w,o);(0,i.useEffect)((()=>{const e={logsRange:c,queryRange:t};let i=[];if((0,L.isEqual)(y.current,t)&&(0,L.isEqual)(v.current,p)){m((t=>(i=t.filter((t=>!(0,L.isEqual)(e.queryRange,t.queryRange))),i=[...i,e].sort(((e,t)=>k(e,t,s))),i)));const n=i.findIndex((e=>e.queryRange.to===t.to));x(n)}else u(),m([e]),x(0),v.current=p,b.current=t.to-t.from;h()}),[c,t,s,p,u,h]),(0,i.useEffect)((()=>{u()}),[]);const I=e=>{let{from:t,to:s}=e;y.current={from:t,to:s},a({from:t,to:s})},k=(e,t,s)=>s===d.LogsSortOrder.Ascending?e.queryRange.to>t.queryRange.to?1:-1:e.queryRange.to>t.queryRange.to?-1:1,z=(0,C.jsx)(r.Button,{"data-testid":"olderLogsButton",className:R.navButton,variant:"secondary",onClick:()=>{if(j)I({from:c.from-b.current,to:c.from});else{const e=w?-1:1;I({from:g[f+e].queryRange.from,to:g[f+e].queryRange.to})}},disabled:o,children:(0,C.jsxs)("div",{className:R.navButtonContent,children:[o?Q||(Q=(0,C.jsx)(r.Spinner,{})):(0,C.jsx)(r.Icon,{name:w?"angle-up":"angle-down",size:"lg"}),"Older logs"]})}),D=(0,C.jsx)(r.Button,{"data-testid":"newerLogsButton",className:R.navButton,variant:"secondary",onClick:()=>{if(!S){const e=w?1:-1;I({from:g[f+e].queryRange.from,to:g[f+e].queryRange.to})}},disabled:o||S,children:(0,C.jsxs)("div",{className:R.navButtonContent,children:[o&&(W||(W=(0,C.jsx)(r.Spinner,{}))),S||o?null:(0,C.jsx)(r.Icon,{name:w?"angle-down":"angle-up",size:"lg"}),S?"Start of range":"Newer logs"]})});return(0,C.jsxs)("div",{className:R.navContainer,children:[w?z:D,(0,C.jsx)(_,{pages:g,currentPageIndex:f,oldestLogsFirst:w,timeZone:n,loading:o,changeTime:I}),w?D:z,(0,C.jsx)(r.Button,{"data-testid":"scrollToTop",className:R.scrollToTopButton,variant:"secondary",onClick:l,title:"Scroll to top",children:U||(U=(0,C.jsx)(r.Icon,{name:"arrow-up",size:"lg"}))})]})}const G=(0,i.memo)(V),K=(e,t,s)=>({navContainer:f.css`
      max-height: 95vh;
      display: flex;
      flex-direction: column;
      justify-content: ${t?"flex-start":"space-between"};
      position: sticky;
      top: ${e.spacing(2)};
      right: 0;
    `,navButton:f.css`
      width: 58px;
      height: 68px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      line-height: 1;
    `,navButtonContent:f.css`
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      width: 100%;
      height: 100%;
      white-space: normal;
    `,scrollToTopButton:f.css`
      width: 40px;
      height: 40px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      margin-top: ${e.spacing(1)};
    `});var Y=s("./packages/grafana-runtime/src/index.ts"),J=s("./public/app/core/app_events.ts"),X=s("./public/app/plugins/panel/timeseries/config.ts"),ee=s("./.yarn/__virtual__/react-use-virtual-00326e70ba/3/opt/drone/yarncache/react-use-npm-17.3.2-a032cbeb01-7379460f51.zip/node_modules/react-use/esm/usePrevious.js"),te=s("./public/app/features/dashboard/dashgrid/SeriesVisibilityConfigFactory.ts"),se=s("../../opt/drone/yarncache/immer-npm-9.0.7-27041ef228-3655ad64bf.zip/node_modules/immer/dist/immer.esm.js");function ie(e){let{data:t,height:s,width:n,timeZone:o,absoluteRange:a,onChangeTime:l,loadingState:c,annotations:p,onHiddenSeriesChanged:u,splitOpenFn:h,graphStyle:g,tooltipDisplayMode:m=N.f3.Single}=e;const x=(0,r.useTheme2)(),[v,y]=(0,i.useState)(!1),[b,w]=(0,i.useState)(1),S=(0,ee.Z)(t),j=(0,i.useRef)(0);t&&S&&!(0,d.compareArrayValues)(S,t,d.compareDataFrameStructures)&&j.current++;const T=b+j.current,[R,I]=(0,i.useState)({defaults:{color:{mode:d.FieldColorModeId.PaletteClassic},custom:{drawStyle:N.l8.Line,fillOpacity:0,pointSize:5}},overrides:[]}),k=(0,r.useStyles2)(ne),z={from:(0,d.dateTime)(a.from),to:(0,d.dateTime)(a.to),raw:{from:(0,d.dateTime)(a.from),to:(0,d.dateTime)(a.to)}},D=(0,i.useMemo)((()=>{const e=(0,d.createFieldConfigRegistry)((0,X.F)(X.r),"Explore"),s=function(e,t){return(0,se.ZP)(e,(e=>{void 0===e.defaults.custom&&(e.defaults.custom={});const{custom:s}=e.defaults;switch(void 0===s.stacking&&(s.stacking={group:"A"}),t){case"lines":s.drawStyle=N.l8.Line,s.stacking.mode=N.o0.None,s.fillOpacity=0;break;case"bars":s.drawStyle=N.l8.Bars,s.stacking.mode=N.o0.None,s.fillOpacity=100;break;case"points":s.drawStyle=N.l8.Points,s.stacking.mode=N.o0.None,s.fillOpacity=0;break;case"stacked_lines":s.drawStyle=N.l8.Line,s.stacking.mode=N.o0.Normal,s.fillOpacity=100;break;case"stacked_bars":s.drawStyle=N.l8.Bars,s.stacking.mode=N.o0.Normal,s.fillOpacity=100;break;default:throw new Error(`Invalid graph-style: ${t}`)}}))}(R,g);return(0,d.applyFieldOverrides)({fieldConfig:s,data:t,timeZone:o,replaceVariables:e=>e,theme:x,fieldConfigRegistry:e})}),[R,g,t,o,x]);(0,i.useEffect)((()=>{if(u){const e=[];D.forEach((t=>{t.fields.map((e=>{var t,s,i;return null===(t=e.config)||void 0===t||null===(s=t.custom)||void 0===s||null===(i=s.hideFrom)||void 0===i?void 0:i.viz})).every(L.identity)&&e.push((0,d.getFrameDisplayName)(t))})),u(e)}}),[D,u]);const F=v?D:D.slice(0,20),O={eventBus:J.Z,onSplitOpen:h,onToggleSeriesVisibility(e,s){w((e=>e+1)),I((0,te.N)(e,s,R,t))}};return(0,C.jsxs)(r.PanelContextProvider,{value:O,children:[D.length>20&&!v&&(0,C.jsxs)("div",{className:(0,f.cx)([k.timeSeriesDisclaimer]),children:[(0,C.jsx)(r.Icon,{className:k.disclaimerIcon,name:"exclamation-triangle"}),"Showing only 20 time series. ",(0,C.jsx)("span",{className:(0,f.cx)([k.showAllTimeSeries]),onClick:()=>{j.current++,y(!0)},children:`Show all ${D.length}`})]}),(0,C.jsx)(Y.PanelRenderer,{data:{series:F,timeRange:z,structureRev:T,state:c,annotations:p},pluginId:"timeseries",title:"",width:n,height:s,onChangeTimeRange:l,timeZone:o,options:{tooltip:{mode:m,sort:N.As.None},legend:{displayMode:N.jK.List,placement:"bottom",calcs:[]}}})]})}const ne=e=>({timeSeriesDisclaimer:f.css`
    label: time-series-disclaimer;
    width: 300px;
    margin: ${e.spacing(1)} auto;
    padding: 10px 0;
    border-radius: ${e.spacing(2)};
    text-align: center;
    background-color: ${e.colors.background.primary};
  `,disclaimerIcon:f.css`
    label: disclaimer-icon;
    color: ${e.colors.warning.main};
    margin-right: ${e.spacing(.5)};
  `,showAllTimeSeries:f.css`
    label: show-all-time-series;
    cursor: pointer;
    color: ${e.colors.text.link};
  `});function oe(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}const re="grafana.explore.logs.showLabels",ae="grafana.explore.logs.showTime",le="grafana.explore.logs.wrapLogMessage",ce="grafana.explore.logs.prettifyLogMessage";class de extends i.PureComponent{constructor(){super(...arguments),oe(this,"flipOrderTimer",void 0),oe(this,"cancelFlippingTimer",void 0),oe(this,"topLogsRef",(0,i.createRef)()),oe(this,"state",{showLabels:u.Z.getBool(re,!1),showTime:u.Z.getBool(ae,!0),wrapLogMessage:u.Z.getBool(le,!0),prettifyLogMessage:u.Z.getBool(ce,!1),dedupStrategy:d.LogsDedupStrategy.none,hiddenLogLevels:[],logsSortOrder:null,isFlipping:!1,showDetectedFields:[],forceEscape:!1}),oe(this,"onChangeLogsSortOrder",(()=>{this.setState({isFlipping:!0}),this.flipOrderTimer=window.setTimeout((()=>{this.setState((e=>null===e.logsSortOrder||e.logsSortOrder===d.LogsSortOrder.Descending?{logsSortOrder:d.LogsSortOrder.Ascending}:{logsSortOrder:d.LogsSortOrder.Descending}))}),0),this.cancelFlippingTimer=window.setTimeout((()=>this.setState({isFlipping:!1})),1e3)})),oe(this,"onEscapeNewlines",(()=>{this.setState((e=>({forceEscape:!e.forceEscape})))})),oe(this,"onChangeDedup",(e=>{this.setState({dedupStrategy:e})})),oe(this,"onChangeLabels",(e=>{const{target:t}=e;if(t){const e=t.checked;this.setState({showLabels:e}),u.Z.set(re,e)}})),oe(this,"onChangeTime",(e=>{const{target:t}=e;if(t){const e=t.checked;this.setState({showTime:e}),u.Z.set(ae,e)}})),oe(this,"onChangewrapLogMessage",(e=>{const{target:t}=e;if(t){const e=t.checked;this.setState({wrapLogMessage:e}),u.Z.set(le,e)}})),oe(this,"onChangePrettifyLogMessage",(e=>{const{target:t}=e;if(t){const e=t.checked;this.setState({prettifyLogMessage:e}),u.Z.set(ce,e)}})),oe(this,"onToggleLogLevel",(e=>{const t=e.map((e=>d.LogLevel[e]));this.setState({hiddenLogLevels:t})})),oe(this,"onClickScan",(e=>{e.preventDefault(),this.props.onStartScanning&&this.props.onStartScanning()})),oe(this,"onClickStopScan",(e=>{e.preventDefault(),this.props.onStopScanning&&this.props.onStopScanning()})),oe(this,"showDetectedField",(e=>{-1===this.state.showDetectedFields.indexOf(e)&&this.setState((t=>({showDetectedFields:t.showDetectedFields.concat(e)})))})),oe(this,"hideDetectedField",(e=>{this.state.showDetectedFields.indexOf(e)>-1&&this.setState((t=>({showDetectedFields:t.showDetectedFields.filter((t=>e!==t))})))})),oe(this,"clearDetectedFields",(()=>{this.setState((e=>({showDetectedFields:[]})))})),oe(this,"checkUnescapedContent",(0,c.Z)((e=>!!e.some((e=>e.hasUnescapedContent))))),oe(this,"dedupRows",(0,c.Z)(((e,t)=>{const s=(0,O.UW)(e,t),i=s.reduce(((e,t)=>t.duplicates?e+t.duplicates:e),0);return{dedupedRows:s,dedupCount:i}}))),oe(this,"filterRows",(0,c.Z)(((e,t)=>(0,O.nu)(e,new Set(t))))),oe(this,"scrollToTopLogs",(()=>{var e;return null===(e=this.topLogsRef.current)||void 0===e?void 0:e.scrollIntoView()}))}componentWillUnmount(){this.flipOrderTimer&&window.clearTimeout(this.flipOrderTimer),this.cancelFlippingTimer&&window.clearTimeout(this.cancelFlippingTimer)}render(){const{width:e,logRows:t,logsMeta:s,logsSeries:i,visibleRange:n,loading:o=!1,loadingState:a,onClickFilterLabel:l,onClickFilterOutLabel:c,timeZone:p,scanning:u,scanRange:h,showContextToggle:g,absoluteRange:m,onChangeTime:f,getFieldLinks:x,theme:v,logsQueries:y,clearCache:b,addResultsToCache:w}=this.props,{showLabels:S,showTime:j,wrapLogMessage:T,prettifyLogMessage:R,dedupStrategy:I,hiddenLogLevels:k,logsSortOrder:z,isFlipping:D,showDetectedFields:F,forceEscape:O}=this.state,$=ue(v,T),E=t&&t.length>0,M=this.checkUnescapedContent(t),B=this.filterRows(t,k),{dedupedRows:P,dedupCount:q}=this.dedupRows(B,I),Z=h?`Scanning ${d.rangeUtil.describeTimeRange(h)}`:"Scanning...";return(0,C.jsxs)(C.Fragment,{children:[i&&i.length?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("div",{className:$.infoText,children:"This datasource does not support full-range histograms. The graph is based on the logs seen in the response."}),(0,C.jsx)(ie,{graphStyle:"lines",data:i,height:150,width:e,tooltipDisplayMode:N.f3.Multi,absoluteRange:n||m,timeZone:p,loadingState:a,onChangeTime:f,onHiddenSeriesChanged:this.onToggleLogLevel})]}):void 0,(0,C.jsxs)("div",{className:$.logOptions,ref:this.topLogsRef,children:[(0,C.jsxs)(r.InlineFieldRow,{children:[(0,C.jsx)(r.InlineField,{label:"Time",transparent:!0,children:(0,C.jsx)(r.InlineSwitch,{value:j,onChange:this.onChangeTime,transparent:!0,id:"show-time"})}),(0,C.jsx)(r.InlineField,{label:"Unique labels",transparent:!0,children:(0,C.jsx)(r.InlineSwitch,{value:S,onChange:this.onChangeLabels,transparent:!0,id:"unique-labels"})}),(0,C.jsx)(r.InlineField,{label:"Wrap lines",transparent:!0,children:(0,C.jsx)(r.InlineSwitch,{value:T,onChange:this.onChangewrapLogMessage,transparent:!0,id:"wrap-lines"})}),(0,C.jsx)(r.InlineField,{label:"Prettify JSON",transparent:!0,children:(0,C.jsx)(r.InlineSwitch,{value:R,onChange:this.onChangePrettifyLogMessage,transparent:!0,id:"prettify"})}),(0,C.jsx)(r.InlineField,{label:"Dedup",transparent:!0,children:(0,C.jsx)(r.RadioButtonGroup,{options:Object.values(d.LogsDedupStrategy).map((e=>({label:(0,L.capitalize)(e),value:e,description:d.LogsDedupDescription[e]}))),value:I,onChange:this.onChangeDedup,className:$.radioButtons})})]}),(0,C.jsx)("div",{children:(0,C.jsx)(r.Button,{variant:"secondary",disabled:D,title:z===d.LogsSortOrder.Ascending?"Change to newest first":"Change to oldest first","aria-label":"Flip results order",className:$.headerButton,onClick:this.onChangeLogsSortOrder,children:D?"Flipping...":"Flip results order"})})]}),(0,C.jsx)(A,{logRows:t,meta:s||[],dedupStrategy:I,dedupCount:q,hasUnescapedContent:M,forceEscape:O,showDetectedFields:F,onEscapeNewlines:this.onEscapeNewlines,clearDetectedFields:this.clearDetectedFields}),(0,C.jsxs)("div",{className:$.logsSection,children:[(0,C.jsx)("div",{className:$.logRows,children:(0,C.jsx)(r.LogRows,{logRows:t,deduplicatedRows:P,dedupStrategy:I,getRowContext:this.props.getRowContext,onClickFilterLabel:l,onClickFilterOutLabel:c,showContextToggle:g,showLabels:S,showTime:j,enableLogDetails:!0,forceEscape:O,wrapLogMessage:T,prettifyLogMessage:R,timeZone:p,getFieldLinks:x,logsSortOrder:z,showDetectedFields:F,onClickShowDetectedField:this.showDetectedField,onClickHideDetectedField:this.hideDetectedField})}),(0,C.jsx)(G,{logsSortOrder:z,visibleRange:null!=n?n:m,absoluteRange:m,timeZone:p,onChangeTime:f,loading:o,queries:null!=y?y:[],scrollToTopLogs:this.scrollToTopLogs,addResultsToCache:w,clearCache:b})]}),!o&&!E&&!u&&(0,C.jsxs)("div",{className:$.noData,children:["No logs found.",(0,C.jsx)(r.Button,{size:"xs",fill:"text",onClick:this.onClickScan,children:"Scan for older logs"})]}),u&&(0,C.jsxs)("div",{className:$.noData,children:[(0,C.jsx)("span",{children:Z}),(0,C.jsx)(r.Button,{size:"xs",fill:"text",onClick:this.onClickStopScan,children:"Stop scan"})]})]})}}const pe=(0,r.withTheme2)(de),ue=(e,t)=>({noData:f.css`
      > * {
        margin-left: 0.5em;
      }
    `,logOptions:f.css`
      display: flex;
      justify-content: space-between;
      align-items: baseline;
      flex-wrap: wrap;
      background-color: ${e.colors.background.primary};
      padding: ${e.spacing(1,2)};
      border-radius: ${e.shape.borderRadius()};
      margin: ${e.spacing(2,0,1)};
      border: 1px solid ${e.colors.border.medium};
    `,headerButton:f.css`
      margin: ${e.spacing(.5,0,0,1)};
    `,radioButtons:f.css`
      margin: 0 ${e.spacing(1)};
    `,logsSection:f.css`
      display: flex;
      flex-direction: row;
      justify-content: space-between;
    `,logRows:f.css`
      overflow-x: ${t?"unset":"scroll"};
      overflow-y: visible;
      width: 100%;
    `,infoText:f.css`
      font-size: ${e.typography.size.sm};
      color: ${e.colors.text.secondary};
    `});var he=s("./.yarn/__virtual__/react-transition-group-virtual-8df824fae8/3/opt/drone/yarncache/react-transition-group-npm-4.4.2-5052c30656-b67bf5b3e8.zip/node_modules/react-transition-group/esm/CSSTransition.js");const ge=(0,c.Z)((()=>({logsEnter:f.css`
      label: logsEnter;
      position: absolute;
      opacity: 0;
      height: auto;
      width: 100%;
    `,logsEnterActive:f.css`
      label: logsEnterActive;
      opacity: 1;
      transition: opacity ${500}ms ease-out ${100}ms;
    `,logsExit:f.css`
      label: logsExit;
      position: absolute;
      opacity: 1;
      height: auto;
      width: 100%;
    `,logsExitActive:f.css`
      label: logsExitActive;
      opacity: 0;
      transition: opacity ${500}ms ease-out ${100}ms;
    `})));function me(e){const{visible:t,children:s}=e,i=ge();return(0,C.jsx)(he.Z,{in:t,mountOnEnter:!0,unmountOnExit:!0,timeout:600,classNames:{enter:i.logsEnter,enterActive:i.logsEnterActive,exit:i.logsExit,exitActive:i.logsExitActive},children:s})}function fe(e){const t=function(e){const t=(0,n.useDispatch)(),s=(0,i.useCallback)((()=>{t((0,y.sQ)({exploreId:e,isPaused:!0}))}),[e,t]),o=(0,i.useCallback)((()=>{t((0,y.sQ)({exploreId:e,isPaused:!1}))}),[e,t]),a=(0,i.useCallback)((()=>{s(),t((0,b.oz)(e,r.RefreshPicker.offOption.value)),t((0,y.aA)(e))}),[e,t,s]),l=(0,i.useCallback)((()=>{t((0,b.oz)(e,r.RefreshPicker.liveOption.value))}),[e,t]);return{pause:s,resume:o,stop:a,start:l}}(e.exploreId);return e.children(t)}var xe=s("./public/app/features/explore/utils/links.ts");function ve(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class ye extends i.PureComponent{constructor(){super(...arguments),ve(this,"onChangeTime",(e=>{const{exploreId:t,updateTimeRange:s}=this.props;s({exploreId:t,absoluteRange:e})})),ve(this,"getLogRowContext",(async(e,t)=>{const{datasourceInstance:s}=this.props;return(0,d.hasLogsContextSupport)(s)?s.getLogRowContext(e,t):[]})),ve(this,"showContextToggle",(e=>{const{datasourceInstance:t}=this.props;return!!(0,d.hasLogsContextSupport)(t)&&t.showContextToggle(e)})),ve(this,"getFieldLinks",((e,t)=>{const{splitOpen:s,range:i}=this.props;return(0,xe.a)({field:e,rowIndex:t,splitOpenFn:s,range:i})}))}render(){const{loading:e,loadingState:t,logRows:s,logsMeta:i,logsSeries:n,logsQueries:o,onClickFilterLabel:a,onClickFilterOutLabel:l,onStartScanning:c,onStopScanning:d,absoluteRange:p,timeZone:u,visibleRange:h,scanning:g,range:m,width:x,isLive:v,exploreId:y,addResultsToCache:b,clearCache:w}=this.props;if(!s)return null;const S=f.css`
      & > div {
        overflow: visible;
        & > div {
          overflow: visible;
        }
      }
    `;return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(me,{visible:v,children:(0,C.jsx)(r.Collapse,{label:"Logs",loading:!1,isOpen:!0,children:(0,C.jsx)(fe,{exploreId:y,children:e=>(0,C.jsx)(F,{logRows:s,timeZone:u,stopLive:e.stop,isPaused:this.props.isPaused,onPause:e.pause,onResume:e.resume})})})}),(0,C.jsx)(me,{visible:!v,children:(0,C.jsx)(r.Collapse,{label:"Logs",loading:e,isOpen:!0,className:S,children:(0,C.jsx)(pe,{logRows:s,logsMeta:i,logsSeries:n,logsQueries:o,width:x,loading:e,loadingState:t,onChangeTime:this.onChangeTime,onClickFilterLabel:a,onClickFilterOutLabel:l,onStartScanning:c,onStopScanning:d,absoluteRange:p,visibleRange:h,timeZone:u,scanning:g,scanRange:m.raw,showContextToggle:this.showContextToggle,getRowContext:this.getLogRowContext,getFieldLinks:this.getFieldLinks,addResultsToCache:()=>b(y),clearCache:()=>w(y)})})})]})}}const be={updateTimeRange:b.cD,splitOpen:a.bW,addResultsToCache:y.K8,clearCache:y.LK},we=(0,n.connect)((function(e,t){let{exploreId:s}=t;const i=e.explore[s],{logsResult:n,loading:o,scanning:r,datasourceInstance:a,isLive:l,isPaused:c,range:d,absoluteRange:p,logsVolumeDataProvider:u,logsVolumeData:h}=i,g=(0,m.Z)(e.user);return{loading:o,logRows:null==n?void 0:n.rows,logsMeta:null==n?void 0:n.meta,logsSeries:null==n?void 0:n.series,logsQueries:null==n?void 0:n.queries,visibleRange:null==n?void 0:n.visibleRange,scanning:r,timeZone:g,datasourceInstance:a,isLive:l,isPaused:c,range:d,absoluteRange:p,logsVolumeDataProvider:u,logsVolumeData:h}}),be)(ye);var Se=s("./public/app/features/plugins/datasource_srv.ts"),je=s("./public/app/core/utils/query.ts"),Ce=s("./public/app/features/query/components/QueryEditorRows.tsx"),Te=s("../../opt/drone/yarncache/reselect-npm-4.1.5-bc046e41ae-54c13c1e79.zip/node_modules/reselect/es/index.js"),Re=s("./public/app/types/index.ts");const Ie=e=>Boolean(e.explore[Re.Kd.left]&&e.explore[Re.Kd.right]),ke=e=>{let{exploreId:t}=e;const s=(0,n.useDispatch)(),{getQueries:o,getDatasourceInstanceSettings:r,getQueryResponse:a,getHistory:l,getEventBridge:c}=(0,i.useMemo)((()=>(e=>{const t=(e=>t=>t.explore[e])(e);return{getQueries:(0,Te.P1)(t,(e=>e.queries)),getQueryResponse:(0,Te.P1)(t,(e=>e.queryResponse)),getHistory:(0,Te.P1)(t,(e=>e.history)),getEventBridge:(0,Te.P1)(t,(e=>e.eventBridge)),getDatasourceInstanceSettings:(0,Te.P1)(t,(e=>{var t;return(0,Se.ak)().getInstanceSettings(null===(t=e.datasourceInstance)||void 0===t?void 0:t.uid)}))}})(t)),[t]),p=(0,n.useSelector)(o),u=(0,n.useSelector)(r),h=(0,n.useSelector)(a),g=(0,n.useSelector)(l),m=(0,n.useSelector)(c),f=(0,i.useCallback)((()=>{s((0,y.aA)(t))}),[s,t]),x=(0,i.useCallback)((e=>{s((0,y.PM)({queries:e,exploreId:t})),e.length<p.length&&f()}),[s,t,f,p]),v=(0,i.useCallback)((e=>{x([...p,Object.assign({},e,{refId:(0,je.Hs)(p)})])}),[x,p]);return(0,C.jsx)(Ce.l,{dsSettings:u,queries:p,onQueriesChange:x,onAddQuery:v,onRunQueries:f,data:h,app:d.CoreApp.Explore,history:g,eventBus:m})};var ze=s("./public/app/core/config.ts"),De=s("./public/app/core/constants.ts");const Fe={splitOpen:a.bW},Le=(0,n.connect)((function(e,t){let{exploreId:s}=t;const i=e.explore[s],{loading:n,tableResult:o,range:r}=i;return{loading:!(o&&o.length>0)&&n,tableResult:o,range:r}}),Fe);class Ne extends i.PureComponent{getTableHeight(){const{tableResult:e}=this.props;return e&&0!==e.length?Math.max(Math.min(600,35*e.length)+35):200}render(){var e,t;const{loading:s,onCellFilterAdded:i,tableResult:n,width:o,splitOpen:a,range:l,ariaLabel:c,timeZone:p}=this.props,u=this.getTableHeight(),h=o-2*ze.vc.theme.panelPadding-De.QO;let g=n;if(null!==(e=g)&&void 0!==e&&e.length){g=(0,d.applyFieldOverrides)({data:[g],timeZone:p,theme:ze.vc.theme2,replaceVariables:e=>e,fieldConfig:{defaults:{},overrides:[]}})[0];for(const e of g.fields)e.getLinks=t=>(0,xe.a)({field:e,rowIndex:t.valueRowIndex,splitOpenFn:a,range:l,dataFrame:g})}return(0,C.jsx)(r.Collapse,{label:"Table",loading:s,isOpen:!0,children:null!==(t=g)&&void 0!==t&&t.length?(0,C.jsx)(r.Table,{ariaLabel:c,data:g,width:h,height:u,onCellFilterAdded:i}):(0,C.jsx)(B,{metaItems:[{value:"0 series returned"}]})})}}const Oe=Le(Ne);var $e=s("./public/app/types/events.ts"),Ee=s("./public/app/store/store.ts"),Me=s("./public/app/core/actions/index.ts"),Be=s("./public/app/core/copy/appNotification.ts");const Pe=(0,r.stylesFactory)((e=>({container:f.css`
      font-size: ${e.typography.size.sm};
      .space-between {
        margin-bottom: ${e.spacing.lg};
      }
    `,input:f.css`
      max-width: 200px;
    `,switch:f.css`
      display: flex;
      align-items: center;
    `,label:f.css`
      margin-left: ${e.spacing.md};
    `}))),Ae=[{value:2,label:"2 days"},{value:5,label:"5 days"},{value:7,label:"1 week"},{value:14,label:"2 weeks"}];function qe(e){const{retentionPeriod:t,starredTabAsFirstTab:s,activeDatasourceOnly:i,onChangeRetentionPeriod:n,toggleStarredTabAsFirstTab:o,toggleactiveDatasourceOnly:a,deleteRichHistory:c}=e,d=(0,r.useTheme)(),p=Pe(d),u=Ae.find((e=>e.value===t));return(0,C.jsxs)("div",{className:p.container,children:[(0,C.jsx)(r.Field,{label:"History time span",description:`Select the period of time for which Grafana will save your query history. Up to ${l.H6} entries will be stored.`,className:"space-between",children:(0,C.jsx)("div",{className:p.input,children:(0,C.jsx)(r.Select,{menuShouldPortal:!0,value:u,options:Ae,onChange:n})})}),(0,C.jsx)(r.Field,{label:"Default active tab",description:" ",className:"space-between",children:(0,C.jsxs)("div",{className:p.switch,children:[(0,C.jsx)(r.Switch,{value:s,onChange:o}),(0,C.jsx)("div",{className:p.label,children:"Change the default active tab from “Query history” to “Starred”"})]})}),(0,C.jsx)(r.Field,{label:"Data source behaviour",description:" ",className:"space-between",children:(0,C.jsxs)("div",{className:p.switch,children:[(0,C.jsx)(r.Switch,{value:i,onChange:a}),(0,C.jsx)("div",{className:p.label,children:"Only show queries for data source currently active in Explore"})]})}),(0,C.jsx)("div",{className:f.css`
          font-weight: ${d.typography.weight.bold};
        `,children:"Clear query history"}),(0,C.jsx)("div",{className:f.css`
          margin-bottom: ${d.spacing.sm};
        `,children:"Delete all of your query history, permanently."}),(0,C.jsx)(r.Button,{variant:"destructive",onClick:()=>{J.Z.publish(new $e.VJ({title:"Delete",text:"Are you sure you want to permanently delete your query history?",yesText:"Delete",icon:"trash-alt",onConfirm:()=>{c(),(0,Ee.WI)((0,Me.$l)((0,Be.AT)("Query history deleted")))}}))},children:"Clear query history"})]})}var Ze=s("./public/app/core/utils/shortLinks.ts"),_e=s("./public/app/features/explore/state/history.ts"),He=s("./public/app/features/explore/state/datasource.ts");const Qe={changeDatasource:He.zU,updateRichHistory:_e.u5,setQueries:y.KO},We=(0,n.connect)((function(e,t){let{exploreId:s}=t;const i=e.explore,{datasourceInstance:n}=i[s];return{exploreId:s,datasourceInstance:n}}),Qe),Ue=(0,r.stylesFactory)(((e,t)=>{const s="240px",i="170px",n=e.colors.bg2;return{queryCard:f.css`
      display: flex;
      flex-direction: column;
      border: 1px solid ${e.colors.border1};
      margin: ${e.spacing.sm} 0;
      background-color: ${n};
      border-radius: ${e.border.radius.sm};
      .starred {
        color: ${e.palette.orange};
      }
    `,cardRow:f.css`
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: ${e.spacing.sm};
      border-bottom: none;
      :first-of-type {
        border-bottom: 1px solid ${e.colors.border1};
        padding: ${e.spacing.xs} ${e.spacing.sm};
      }
      img {
        height: ${e.typography.size.base};
        max-width: ${e.typography.size.base};
        margin-right: ${e.spacing.sm};
      }
    `,datasourceContainer:f.css`
      display: flex;
      align-items: center;
      font-size: ${e.typography.size.sm};
      font-weight: ${e.typography.weight.semibold};
    `,queryActionButtons:f.css`
      max-width: ${i};
      display: flex;
      justify-content: flex-end;
      font-size: ${e.typography.size.base};
      button {
        margin-left: ${e.spacing.sm};
      }
    `,queryContainer:f.css`
      font-weight: ${e.typography.weight.semibold};
      width: calc(100% - ${s});
    `,queryRow:f.css`
      border-top: 1px solid ${e.colors.border1};
      word-break: break-all;
      padding: 4px 2px;
      :first-child {
        border-top: none;
        padding: 0 0 4px 0;
      }
    `,updateCommentContainer:f.css`
      width: calc(100% + ${s});
      margin-top: ${e.spacing.sm};
    `,comment:f.css`
      overflow-wrap: break-word;
      font-size: ${e.typography.size.sm};
      font-weight: ${e.typography.weight.regular};
      margin-top: ${e.spacing.xs};
    `,commentButtonRow:f.css`
      > * {
        margin-right: ${e.spacing.sm};
      }
    `,textArea:f.css`
      width: 100%;
    `,runButton:f.css`
      max-width: ${i};
      display: flex;
      justify-content: flex-end;
      button {
        height: auto;
        padding: ${e.spacing.xs} ${e.spacing.md};
        line-height: 1.4;
        span {
          white-space: normal !important;
        }
      }
    `}}));const Ve=We((function(e){var t;const{query:s,dsImg:n,isRemoved:o,updateRichHistory:a,changeDatasource:c,exploreId:d,datasourceInstance:p,setQueries:u}=e,[h,m]=(0,i.useState)(!1),[x,v]=(0,i.useState)(s.comment),[y,b]=(0,i.useState)(void 0);(0,i.useEffect)((()=>{(async()=>{const e=await(0,Y.getDataSourceSrv)().get(s.datasourceName);b(e)})()}),[s.datasourceName]);const w=(0,r.useTheme)(),S=Ue(w,o),j=()=>{a(s.ts,"comment",x),m(!1)},T=()=>{m(!1),v(s.comment)},R=(0,C.jsxs)("div",{className:S.updateCommentContainer,"aria-label":x?"Update comment form":"Add comment form",children:[(0,C.jsx)(r.TextArea,{value:x,placeholder:x?void 0:"An optional description of what the query does.",onChange:e=>v(e.currentTarget.value),className:S.textArea}),(0,C.jsxs)("div",{className:S.commentButtonRow,children:[(0,C.jsx)(r.Button,{onClick:j,"aria-label":"Submit button",children:"Save comment"}),(0,C.jsx)(r.Button,{variant:"secondary",onClick:T,children:"Cancel"})]})]}),I=(0,C.jsxs)("div",{className:S.queryActionButtons,children:[(0,C.jsx)(r.IconButton,{name:"comment-alt",onClick:()=>m(!h),title:(null===(t=s.comment)||void 0===t?void 0:t.length)>0?"Edit comment":"Add comment"}),(0,C.jsx)(r.IconButton,{name:"copy",onClick:()=>{const e=s.queries.map((e=>(0,l.OH)(e,y))).join("\n");(0,g.n9)(e),(0,Ee.WI)((0,Me.$l)((0,Be.AT)("Query copied to clipboard")))},title:"Copy query to clipboard"}),!o&&(0,C.jsx)(r.IconButton,{name:"share-alt",onClick:async()=>{const e=(0,l.t2)(s);await(0,Ze.L)(e)},title:"Copy shortened link to clipboard"}),(0,C.jsx)(r.IconButton,{name:"trash-alt",title:"Delete query",onClick:()=>{s.starred?J.Z.publish(new $e.VJ({title:"Delete",text:"Are you sure you want to permanently delete your starred query?",yesText:"Delete",icon:"trash-alt",onConfirm:()=>{a(s.ts,"delete"),(0,Ee.WI)((0,Me.$l)((0,Be.AT)("Query deleted")))}})):(a(s.ts,"delete"),(0,Ee.WI)((0,Me.$l)((0,Be.AT)("Query deleted"))))}}),(0,C.jsx)(r.IconButton,{name:s.starred?"favorite":"star",iconType:s.starred?"mono":"default",onClick:()=>{a(s.ts,"starred")},title:s.starred?"Unstar query":"Star query"})]});return(0,C.jsxs)("div",{className:S.queryCard,onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||e.ctrlKey)&&j(),"Escape"===e.key&&T()},children:[(0,C.jsxs)("div",{className:S.cardRow,children:[(0,C.jsxs)("div",{className:S.datasourceContainer,children:[(0,C.jsx)("img",{src:n,"aria-label":"Data source icon"}),(0,C.jsx)("div",{"aria-label":"Data source name",children:o?"Data source does not exist anymore":s.datasourceName})]}),I]}),(0,C.jsxs)("div",{className:(0,f.cx)(S.cardRow),children:[(0,C.jsxs)("div",{className:S.queryContainer,children:[s.queries.map(((e,t)=>{const s=(0,l.OH)(e,y);return(0,C.jsx)("div",{"aria-label":"Query text",className:S.queryRow,children:s},`${e}-${t}`)})),!h&&s.comment&&(0,C.jsx)("div",{"aria-label":"Query comment",className:S.comment,children:s.comment}),h&&R]}),!h&&(0,C.jsx)("div",{className:S.runButton,children:(0,C.jsx)(r.Button,{variant:"secondary",onClick:async()=>{const e=s.queries;s.datasourceName!==(null==p?void 0:p.name)?(await c(d,s.datasourceName,{importQueries:!0}),u(d,e)):u(d,e)},disabled:o,children:(null==p?void 0:p.name)===s.datasourceName?"Run query":"Switch data source and run query"})})]})]})}));var Ge,Ke=s("./.yarn/__virtual__/react-use-virtual-00326e70ba/3/opt/drone/yarncache/react-use-npm-17.3.2-a032cbeb01-7379460f51.zip/node_modules/react-use/esm/useDebounce.js");const Ye=(0,r.stylesFactory)(((e,t)=>{const s=e.isLight?e.palette.gray5:e.palette.dark4,i=t-180+"px";return{container:f.css`
      display: flex;
      .label-slider {
        font-size: ${e.typography.size.sm};
        &:last-of-type {
          margin-top: ${e.spacing.lg};
        }
        &:first-of-type {
          font-weight: ${e.typography.weight.semibold};
          margin-bottom: ${e.spacing.md};
        }
      }
    `,containerContent:f.css`
      width: calc(${"100% - 134px"});
    `,containerSlider:f.css`
      width: 129px;
      margin-right: ${e.spacing.sm};
      .slider {
        bottom: 10px;
        height: ${i};
        width: 129px;
        padding: ${e.spacing.sm} 0;
      }
    `,slider:f.css`
      position: fixed;
    `,selectors:f.css`
      display: flex;
      justify-content: space-between;
      flex-wrap: wrap;
    `,filterInput:f.css`
      margin-bottom: ${e.spacing.sm};
    `,multiselect:f.css`
      width: 100%;
      margin-bottom: ${e.spacing.sm};
      .gf-form-select-box__multi-value {
        background-color: ${s};
        padding: ${e.spacing.xxs} ${e.spacing.xs} ${e.spacing.xxs} ${e.spacing.sm};
        border-radius: ${e.border.radius.sm};
      }
    `,sort:f.css`
      width: 170px;
    `,sessionName:f.css`
      display: flex;
      align-items: flex-start;
      justify-content: flex-start;
      margin-top: ${e.spacing.lg};
      h4 {
        margin: 0 10px 0 0;
      }
    `,heading:f.css`
      font-size: ${e.typography.heading.h4};
      margin: ${e.spacing.md} ${e.spacing.xxs} ${e.spacing.sm} ${e.spacing.xxs};
    `,footer:f.css`
      height: 60px;
      margin: ${e.spacing.lg} auto;
      display: flex;
      justify-content: center;
      font-weight: ${e.typography.weight.light};
      font-size: ${e.typography.size.sm};
      a {
        font-weight: ${e.typography.weight.semibold};
        margin-left: ${e.spacing.xxs};
      }
    `,queries:f.css`
      font-size: ${e.typography.size.sm};
      font-weight: ${e.typography.weight.regular};
      margin-left: ${e.spacing.xs};
    `}}));function Je(e){const{datasourceFilters:t,onSelectDatasourceFilters:s,queries:n,onChangeSortOrder:o,sortOrder:a,activeDatasourceOnly:c,retentionPeriod:d,exploreId:p,height:u}=e,[h,g]=(0,i.useState)([0,d]),[m,f]=(0,i.useState)([[],[]]),[x,v]=(0,i.useState)(""),[y,b]=(0,i.useState)(""),w=(0,r.useTheme)(),S=Ye(w,u);(0,Ke.Z)((()=>{b(x)}),300,[x]),(0,i.useEffect)((()=>{const e=(0,L.uniqBy)(n,"datasourceName").map((e=>e.datasourceName)),s=(0,l.DR)(e);f([(0,l.ZX)(n,a,t.map((e=>e.value)),y,h),s])}),[h,n,a,t,y]);const[j,T]=m,R=(0,l.k4)(j,a);return(0,C.jsxs)("div",{className:S.container,children:[(0,C.jsx)("div",{className:S.containerSlider,children:(0,C.jsxs)("div",{className:S.slider,children:[Ge||(Ge=(0,C.jsx)("div",{className:"label-slider",children:"Filter history"})),(0,C.jsx)("div",{className:"label-slider",children:(0,l.bQ)(h[0])}),(0,C.jsx)("div",{className:"slider",children:(0,C.jsx)(r.RangeSlider,{tooltipAlwaysVisible:!1,min:0,max:d,value:h,orientation:"vertical",formatTooltipResult:l.bQ,reverse:!0,onAfterChange:g})}),(0,C.jsx)("div",{className:"label-slider",children:(0,l.bQ)(h[1])})]})}),(0,C.jsxs)("div",{className:S.containerContent,children:[(0,C.jsxs)("div",{className:S.selectors,children:[!c&&(0,C.jsx)("div",{"aria-label":"Filter datasources",className:S.multiselect,children:(0,C.jsx)(r.MultiSelect,{menuShouldPortal:!0,options:T,value:t,placeholder:"Filter queries for data sources(s)",onChange:s})}),(0,C.jsx)("div",{className:S.filterInput,children:(0,C.jsx)(r.FilterInput,{placeholder:"Search queries",value:x,onChange:e=>{v(e)}})}),(0,C.jsx)("div",{"aria-label":"Sort queries",className:S.sort,children:(0,C.jsx)(r.Select,{menuShouldPortal:!0,value:it.filter((e=>e.value===a)),options:it,placeholder:"Sort queries by",onChange:e=>o(e.value)})})]}),Object.keys(R).map((e=>(0,C.jsxs)("div",{children:[(0,C.jsxs)("div",{className:S.heading,children:[e," ",(0,C.jsxs)("span",{className:S.queries,children:[R[e].length," queries"]})]}),R[e].map((e=>{const t=T.findIndex((t=>t.label===e.datasourceName));return(0,C.jsx)(Ve,{query:e,exploreId:p,dsImg:T[t].imgUrl,isRemoved:T[t].isRemoved},e.ts)}))]},e))),(0,C.jsx)("div",{className:S.footer,children:"The history is local to your browser and is not shared with others."})]})]})}const Xe=(0,r.stylesFactory)((e=>{const t=e.isLight?e.palette.gray5:e.palette.dark4;return{container:f.css`
      display: flex;
    `,containerContent:f.css`
      width: 100%;
    `,selectors:f.css`
      display: flex;
      justify-content: space-between;
      flex-wrap: wrap;
    `,multiselect:f.css`
      width: 100%;
      margin-bottom: ${e.spacing.sm};
      .gf-form-select-box__multi-value {
        background-color: ${t};
        padding: ${e.spacing.xxs} ${e.spacing.xs} ${e.spacing.xxs} ${e.spacing.sm};
        border-radius: ${e.border.radius.sm};
      }
    `,filterInput:f.css`
      margin-bottom: ${e.spacing.sm};
    `,sort:f.css`
      width: 170px;
    `,footer:f.css`
      height: 60px;
      margin-top: ${e.spacing.lg};
      display: flex;
      justify-content: center;
      font-weight: ${e.typography.weight.light};
      font-size: ${e.typography.size.sm};
      a {
        font-weight: ${e.typography.weight.semibold};
        margin-left: ${e.spacing.xxs};
      }
    `}}));function et(e){const{datasourceFilters:t,onSelectDatasourceFilters:s,queries:n,onChangeSortOrder:o,sortOrder:a,activeDatasourceOnly:c,exploreId:d}=e,[p,u]=(0,i.useState)([[],[]]),[h,g]=(0,i.useState)(""),[m,f]=(0,i.useState)(""),x=(0,r.useTheme)(),v=Xe(x);(0,Ke.Z)((()=>{f(h)}),300,[h]),(0,i.useEffect)((()=>{const e=(0,L.uniqBy)(n,"datasourceName").map((e=>e.datasourceName)),s=(0,l.DR)(e),i=n.filter((e=>!0===e.starred));u([(0,l.ZX)(i,a,t.map((e=>e.value)),m),s])}),[n,a,t,m]);const[y,b]=p;return(0,C.jsx)("div",{className:v.container,children:(0,C.jsxs)("div",{className:v.containerContent,children:[(0,C.jsxs)("div",{className:v.selectors,children:[!c&&(0,C.jsx)("div",{"aria-label":"Filter datasources",className:v.multiselect,children:(0,C.jsx)(r.MultiSelect,{menuShouldPortal:!0,options:b,value:t,placeholder:"Filter queries for specific data sources(s)",onChange:s})}),(0,C.jsx)("div",{className:v.filterInput,children:(0,C.jsx)(r.FilterInput,{placeholder:"Search queries",value:h,onChange:e=>{g(e)}})}),(0,C.jsx)("div",{"aria-label":"Sort queries",className:v.sort,children:(0,C.jsx)(r.Select,{menuShouldPortal:!0,options:it,value:it.filter((e=>e.value===a)),placeholder:"Sort queries by",onChange:e=>o(e.value)})})]}),y.map((e=>{const t=b.findIndex((t=>t.label===e.datasourceName));return(0,C.jsx)(Ve,{query:e,exploreId:d,dsImg:b[t].imgUrl,isRemoved:b[t].isRemoved},e.ts)})),(0,C.jsx)("div",{className:v.footer,children:"The history is local to your browser and is not shared with others."})]})})}function tt(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}let st;!function(e){e.RichHistory="Query history",e.Starred="Starred",e.Settings="Settings"}(st||(st={}));const it=[{label:"Newest first",value:l.As.Descending},{label:"Oldest first",value:l.As.Ascending},{label:"Data source A-Z",value:l.As.DatasourceAZ},{label:"Data source Z-A",value:l.As.DatasourceZA}];class nt extends i.PureComponent{constructor(e){super(e),tt(this,"onChangeRetentionPeriod",(e=>{void 0!==e.value&&(this.setState({retentionPeriod:e.value}),u.Z.set(l.hO.retentionPeriod,e.value))})),tt(this,"toggleStarredTabAsFirstTab",(()=>{const e=!this.state.starredTabAsFirstTab;this.setState({starredTabAsFirstTab:e}),u.Z.set(l.hO.starredTabAsFirstTab,e)})),tt(this,"toggleActiveDatasourceOnly",(()=>{const e=!this.state.activeDatasourceOnly;this.setState({activeDatasourceOnly:e}),u.Z.set(l.hO.activeDatasourceOnly,e)})),tt(this,"onSelectDatasourceFilters",(e=>{try{u.Z.setObject(l.hO.datasourceFilters,e)}catch(e){console.error(e)}this.setState({datasourceFilters:e})})),tt(this,"onChangeSortOrder",(e=>this.setState({sortOrder:e}))),this.state={sortOrder:l.As.Descending,datasourceFilters:u.Z.getObject(l.hO.datasourceFilters,[]),retentionPeriod:u.Z.getObject(l.hO.retentionPeriod,7),starredTabAsFirstTab:u.Z.getBool(l.hO.starredTabAsFirstTab,!1),activeDatasourceOnly:u.Z.getBool(l.hO.activeDatasourceOnly,!0)}}updateFilters(){this.state.activeDatasourceOnly&&this.props.activeDatasourceInstance?this.onSelectDatasourceFilters([{label:this.props.activeDatasourceInstance,value:this.props.activeDatasourceInstance}]):this.onSelectDatasourceFilters(this.state.datasourceFilters)}componentDidMount(){this.updateFilters()}componentDidUpdate(e,t){this.props.activeDatasourceInstance===e.activeDatasourceInstance&&this.state.activeDatasourceOnly===t.activeDatasourceOnly||this.updateFilters()}render(){const{datasourceFilters:e,sortOrder:t,activeDatasourceOnly:s,retentionPeriod:i}=this.state,{richHistory:n,height:o,exploreId:a,deleteRichHistory:l,onClose:c,firstTab:d}=this.props;let p=[{label:"Query history",value:st.RichHistory,content:(0,C.jsx)(Je,{queries:n,sortOrder:t,datasourceFilters:e,activeDatasourceOnly:s,retentionPeriod:i,onChangeSortOrder:this.onChangeSortOrder,onSelectDatasourceFilters:this.onSelectDatasourceFilters,exploreId:a,height:o}),icon:"history"},{label:"Starred",value:st.Starred,content:(0,C.jsx)(et,{queries:n,sortOrder:t,datasourceFilters:e,activeDatasourceOnly:s,onChangeSortOrder:this.onChangeSortOrder,onSelectDatasourceFilters:this.onSelectDatasourceFilters,exploreId:a}),icon:"star"},{label:"Settings",value:st.Settings,content:(0,C.jsx)(qe,{retentionPeriod:this.state.retentionPeriod,starredTabAsFirstTab:this.state.starredTabAsFirstTab,activeDatasourceOnly:this.state.activeDatasourceOnly,onChangeRetentionPeriod:this.onChangeRetentionPeriod,toggleStarredTabAsFirstTab:this.toggleStarredTabAsFirstTab,toggleactiveDatasourceOnly:this.toggleActiveDatasourceOnly,deleteRichHistory:l}),icon:"sliders-v-alt"}];return(0,C.jsx)(r.TabbedContainer,{tabs:p,onClose:c,defaultTab:d,closeIconTooltip:"Close query history"})}}const ot=(0,r.withTheme)(nt);var rt,at=(rt=function(e,t){return rt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])},rt(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function s(){this.constructor=e}rt(e,t),e.prototype=null===t?Object.create(t):(s.prototype=t.prototype,new s)}),lt=function(){return lt=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},lt.apply(this,arguments)},ct={top:{width:"100%",height:"10px",top:"-5px",left:"0px",cursor:"row-resize"},right:{width:"10px",height:"100%",top:"0px",right:"-5px",cursor:"col-resize"},bottom:{width:"100%",height:"10px",bottom:"-5px",left:"0px",cursor:"row-resize"},left:{width:"10px",height:"100%",top:"0px",left:"-5px",cursor:"col-resize"},topRight:{width:"20px",height:"20px",position:"absolute",right:"-10px",top:"-10px",cursor:"ne-resize"},bottomRight:{width:"20px",height:"20px",position:"absolute",right:"-10px",bottom:"-10px",cursor:"se-resize"},bottomLeft:{width:"20px",height:"20px",position:"absolute",left:"-10px",bottom:"-10px",cursor:"sw-resize"},topLeft:{width:"20px",height:"20px",position:"absolute",left:"-10px",top:"-10px",cursor:"nw-resize"}},dt=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onMouseDown=function(e){t.props.onResizeStart(e,t.props.direction)},t.onTouchStart=function(e){t.props.onResizeStart(e,t.props.direction)},t}return at(t,e),t.prototype.render=function(){return i.createElement("div",{className:this.props.className||"",style:lt(lt({position:"absolute",userSelect:"none"},ct[this.props.direction]),this.props.replaceStyles||{}),onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart},this.props.children)},t}(i.PureComponent),pt=s("../../opt/drone/yarncache/fast-memoize-npm-2.5.2-f42a7c6940-79fa759719.zip/node_modules/fast-memoize/src/index.js"),ut=s.n(pt),ht=function(){var e=function(t,s){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])},e(t,s)};return function(t,s){if("function"!=typeof s&&null!==s)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function i(){this.constructor=t}e(t,s),t.prototype=null===s?Object.create(s):(i.prototype=s.prototype,new i)}}(),gt=function(){return gt=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},gt.apply(this,arguments)},mt={width:"auto",height:"auto"},ft=ut()((function(e,t,s){return Math.max(Math.min(e,s),t)})),xt=ut()((function(e,t){return Math.round(e/t)*t})),vt=ut()((function(e,t){return new RegExp(e,"i").test(t)})),yt=function(e){return Boolean(e.touches&&e.touches.length)},bt=ut()((function(e,t,s){void 0===s&&(s=0);var i=t.reduce((function(s,i,n){return Math.abs(i-e)<Math.abs(t[s]-e)?n:s}),0),n=Math.abs(t[i]-e);return 0===s||n<s?t[i]:e})),wt=ut()((function(e,t){return e.substr(e.length-t.length,t.length)===t})),St=ut()((function(e){return"auto"===(e=e.toString())||wt(e,"px")||wt(e,"%")||wt(e,"vh")||wt(e,"vw")||wt(e,"vmax")||wt(e,"vmin")?e:e+"px"})),jt=function(e,t,s,i){if(e&&"string"==typeof e){if(wt(e,"px"))return Number(e.replace("px",""));if(wt(e,"%"))return t*(Number(e.replace("%",""))/100);if(wt(e,"vw"))return s*(Number(e.replace("vw",""))/100);if(wt(e,"vh"))return i*(Number(e.replace("vh",""))/100)}return e},Ct=ut()((function(e,t,s,i,n,o,r){return i=jt(i,e.width,t,s),n=jt(n,e.height,t,s),o=jt(o,e.width,t,s),r=jt(r,e.height,t,s),{maxWidth:void 0===i?void 0:Number(i),maxHeight:void 0===n?void 0:Number(n),minWidth:void 0===o?void 0:Number(o),minHeight:void 0===r?void 0:Number(r)}})),Tt=["as","style","className","grid","snap","bounds","boundsByDirection","size","defaultSize","minWidth","minHeight","maxWidth","maxHeight","lockAspectRatio","lockAspectRatioExtraWidth","lockAspectRatioExtraHeight","enable","handleStyles","handleClasses","handleWrapperStyle","handleWrapperClass","children","onResizeStart","onResize","onResizeStop","handleComponent","scale","resizeRatio","snapGap"],Rt="__resizable_base__",It=function(e){function t(t){var s=e.call(this,t)||this;return s.ratio=1,s.resizable=null,s.parentLeft=0,s.parentTop=0,s.resizableLeft=0,s.resizableRight=0,s.resizableTop=0,s.resizableBottom=0,s.targetLeft=0,s.targetTop=0,s.appendBase=function(){if(!s.resizable||!s.window)return null;var e=s.parentNode;if(!e)return null;var t=s.window.document.createElement("div");return t.style.width="100%",t.style.height="100%",t.style.position="absolute",t.style.transform="scale(0, 0)",t.style.left="0",t.style.flex="0",t.classList?t.classList.add(Rt):t.className+=Rt,e.appendChild(t),t},s.removeBase=function(e){var t=s.parentNode;t&&t.removeChild(e)},s.ref=function(e){e&&(s.resizable=e)},s.state={isResizing:!1,width:void 0===(s.propsSize&&s.propsSize.width)?"auto":s.propsSize&&s.propsSize.width,height:void 0===(s.propsSize&&s.propsSize.height)?"auto":s.propsSize&&s.propsSize.height,direction:"right",original:{x:0,y:0,width:0,height:0},backgroundStyle:{height:"100%",width:"100%",backgroundColor:"rgba(0,0,0,0)",cursor:"auto",opacity:0,position:"fixed",zIndex:9999,top:"0",left:"0",bottom:"0",right:"0"},flexBasis:void 0},s.onResizeStart=s.onResizeStart.bind(s),s.onMouseMove=s.onMouseMove.bind(s),s.onMouseUp=s.onMouseUp.bind(s),s}return ht(t,e),Object.defineProperty(t.prototype,"parentNode",{get:function(){return this.resizable?this.resizable.parentNode:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"window",{get:function(){return this.resizable&&this.resizable.ownerDocument?this.resizable.ownerDocument.defaultView:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"propsSize",{get:function(){return this.props.size||this.props.defaultSize||mt},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){var e=0,t=0;if(this.resizable&&this.window){var s=this.resizable.offsetWidth,i=this.resizable.offsetHeight,n=this.resizable.style.position;"relative"!==n&&(this.resizable.style.position="relative"),e="auto"!==this.resizable.style.width?this.resizable.offsetWidth:s,t="auto"!==this.resizable.style.height?this.resizable.offsetHeight:i,this.resizable.style.position=n}return{width:e,height:t}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sizeStyle",{get:function(){var e=this,t=this.props.size,s=function(t){if(void 0===e.state[t]||"auto"===e.state[t])return"auto";if(e.propsSize&&e.propsSize[t]&&wt(e.propsSize[t].toString(),"%")){if(wt(e.state[t].toString(),"%"))return e.state[t].toString();var s=e.getParentSize();return Number(e.state[t].toString().replace("px",""))/s[t]*100+"%"}return St(e.state[t])};return{width:t&&void 0!==t.width&&!this.state.isResizing?St(t.width):s("width"),height:t&&void 0!==t.height&&!this.state.isResizing?St(t.height):s("height")}},enumerable:!1,configurable:!0}),t.prototype.getParentSize=function(){if(!this.parentNode)return this.window?{width:this.window.innerWidth,height:this.window.innerHeight}:{width:0,height:0};var e=this.appendBase();if(!e)return{width:0,height:0};var t=!1,s=this.parentNode.style.flexWrap;"wrap"!==s&&(t=!0,this.parentNode.style.flexWrap="wrap"),e.style.position="relative",e.style.minWidth="100%";var i={width:e.offsetWidth,height:e.offsetHeight};return t&&(this.parentNode.style.flexWrap=s),this.removeBase(e),i},t.prototype.bindEvents=function(){this.window&&(this.window.addEventListener("mouseup",this.onMouseUp),this.window.addEventListener("mousemove",this.onMouseMove),this.window.addEventListener("mouseleave",this.onMouseUp),this.window.addEventListener("touchmove",this.onMouseMove,{capture:!0,passive:!1}),this.window.addEventListener("touchend",this.onMouseUp))},t.prototype.unbindEvents=function(){this.window&&(this.window.removeEventListener("mouseup",this.onMouseUp),this.window.removeEventListener("mousemove",this.onMouseMove),this.window.removeEventListener("mouseleave",this.onMouseUp),this.window.removeEventListener("touchmove",this.onMouseMove,!0),this.window.removeEventListener("touchend",this.onMouseUp))},t.prototype.componentDidMount=function(){if(this.resizable&&this.window){var e=this.window.getComputedStyle(this.resizable);this.setState({width:this.state.width||this.size.width,height:this.state.height||this.size.height,flexBasis:"auto"!==e.flexBasis?e.flexBasis:void 0})}},t.prototype.componentWillUnmount=function(){this.window&&this.unbindEvents()},t.prototype.createSizeForCssProperty=function(e,t){var s=this.propsSize&&this.propsSize[t];return"auto"!==this.state[t]||this.state.original[t]!==e||void 0!==s&&"auto"!==s?e:"auto"},t.prototype.calculateNewMaxFromBoundary=function(e,t){var s,i,n=this.props.boundsByDirection,o=this.state.direction,r=n&&vt("left",o),a=n&&vt("top",o);if("parent"===this.props.bounds){var l=this.parentNode;l&&(s=r?this.resizableRight-this.parentLeft:l.offsetWidth+(this.parentLeft-this.resizableLeft),i=a?this.resizableBottom-this.parentTop:l.offsetHeight+(this.parentTop-this.resizableTop))}else"window"===this.props.bounds?this.window&&(s=r?this.resizableRight:this.window.innerWidth-this.resizableLeft,i=a?this.resizableBottom:this.window.innerHeight-this.resizableTop):this.props.bounds&&(s=r?this.resizableRight-this.targetLeft:this.props.bounds.offsetWidth+(this.targetLeft-this.resizableLeft),i=a?this.resizableBottom-this.targetTop:this.props.bounds.offsetHeight+(this.targetTop-this.resizableTop));return s&&Number.isFinite(s)&&(e=e&&e<s?e:s),i&&Number.isFinite(i)&&(t=t&&t<i?t:i),{maxWidth:e,maxHeight:t}},t.prototype.calculateNewSizeFromDirection=function(e,t){var s=this.props.scale||1,i=this.props.resizeRatio||1,n=this.state,o=n.direction,r=n.original,a=this.props,l=a.lockAspectRatio,c=a.lockAspectRatioExtraHeight,d=a.lockAspectRatioExtraWidth,p=r.width,u=r.height,h=c||0,g=d||0;return vt("right",o)&&(p=r.width+(e-r.x)*i/s,l&&(u=(p-g)/this.ratio+h)),vt("left",o)&&(p=r.width-(e-r.x)*i/s,l&&(u=(p-g)/this.ratio+h)),vt("bottom",o)&&(u=r.height+(t-r.y)*i/s,l&&(p=(u-h)*this.ratio+g)),vt("top",o)&&(u=r.height-(t-r.y)*i/s,l&&(p=(u-h)*this.ratio+g)),{newWidth:p,newHeight:u}},t.prototype.calculateNewSizeFromAspectRatio=function(e,t,s,i){var n=this.props,o=n.lockAspectRatio,r=n.lockAspectRatioExtraHeight,a=n.lockAspectRatioExtraWidth,l=void 0===i.width?10:i.width,c=void 0===s.width||s.width<0?e:s.width,d=void 0===i.height?10:i.height,p=void 0===s.height||s.height<0?t:s.height,u=r||0,h=a||0;if(o){var g=(d-u)*this.ratio+h,m=(p-u)*this.ratio+h,f=(l-h)/this.ratio+u,x=(c-h)/this.ratio+u,v=Math.max(l,g),y=Math.min(c,m),b=Math.max(d,f),w=Math.min(p,x);e=ft(e,v,y),t=ft(t,b,w)}else e=ft(e,l,c),t=ft(t,d,p);return{newWidth:e,newHeight:t}},t.prototype.setBoundingClientRect=function(){if("parent"===this.props.bounds){var e=this.parentNode;if(e){var t=e.getBoundingClientRect();this.parentLeft=t.left,this.parentTop=t.top}}if(this.props.bounds&&"string"!=typeof this.props.bounds){var s=this.props.bounds.getBoundingClientRect();this.targetLeft=s.left,this.targetTop=s.top}if(this.resizable){var i=this.resizable.getBoundingClientRect(),n=i.left,o=i.top,r=i.right,a=i.bottom;this.resizableLeft=n,this.resizableRight=r,this.resizableTop=o,this.resizableBottom=a}},t.prototype.onResizeStart=function(e,t){if(this.resizable&&this.window){var s,i=0,n=0;if(e.nativeEvent&&function(e){return Boolean((e.clientX||0===e.clientX)&&(e.clientY||0===e.clientY))}(e.nativeEvent)?(i=e.nativeEvent.clientX,n=e.nativeEvent.clientY):e.nativeEvent&&yt(e.nativeEvent)&&(i=e.nativeEvent.touches[0].clientX,n=e.nativeEvent.touches[0].clientY),this.props.onResizeStart)if(this.resizable)if(!1===this.props.onResizeStart(e,t,this.resizable))return;this.props.size&&(void 0!==this.props.size.height&&this.props.size.height!==this.state.height&&this.setState({height:this.props.size.height}),void 0!==this.props.size.width&&this.props.size.width!==this.state.width&&this.setState({width:this.props.size.width})),this.ratio="number"==typeof this.props.lockAspectRatio?this.props.lockAspectRatio:this.size.width/this.size.height;var o=this.window.getComputedStyle(this.resizable);if("auto"!==o.flexBasis){var r=this.parentNode;if(r){var a=this.window.getComputedStyle(r).flexDirection;this.flexDir=a.startsWith("row")?"row":"column",s=o.flexBasis}}this.setBoundingClientRect(),this.bindEvents();var l={original:{x:i,y:n,width:this.size.width,height:this.size.height},isResizing:!0,backgroundStyle:gt(gt({},this.state.backgroundStyle),{cursor:this.window.getComputedStyle(e.target).cursor||"auto"}),direction:t,flexBasis:s};this.setState(l)}},t.prototype.onMouseMove=function(e){if(this.state.isResizing&&this.resizable&&this.window){if(this.window.TouchEvent&&yt(e))try{e.preventDefault(),e.stopPropagation()}catch(e){}var t=this.props,s=t.maxWidth,i=t.maxHeight,n=t.minWidth,o=t.minHeight,r=yt(e)?e.touches[0].clientX:e.clientX,a=yt(e)?e.touches[0].clientY:e.clientY,l=this.state,c=l.direction,d=l.original,p=l.width,u=l.height,h=this.getParentSize(),g=Ct(h,this.window.innerWidth,this.window.innerHeight,s,i,n,o);s=g.maxWidth,i=g.maxHeight,n=g.minWidth,o=g.minHeight;var m=this.calculateNewSizeFromDirection(r,a),f=m.newHeight,x=m.newWidth,v=this.calculateNewMaxFromBoundary(s,i),y=this.calculateNewSizeFromAspectRatio(x,f,{width:v.maxWidth,height:v.maxHeight},{width:n,height:o});if(x=y.newWidth,f=y.newHeight,this.props.grid){var b=xt(x,this.props.grid[0]),w=xt(f,this.props.grid[1]),S=this.props.snapGap||0;x=0===S||Math.abs(b-x)<=S?b:x,f=0===S||Math.abs(w-f)<=S?w:f}this.props.snap&&this.props.snap.x&&(x=bt(x,this.props.snap.x,this.props.snapGap)),this.props.snap&&this.props.snap.y&&(f=bt(f,this.props.snap.y,this.props.snapGap));var j={width:x-d.width,height:f-d.height};if(p&&"string"==typeof p)if(wt(p,"%"))x=x/h.width*100+"%";else if(wt(p,"vw")){x=x/this.window.innerWidth*100+"vw"}else if(wt(p,"vh")){x=x/this.window.innerHeight*100+"vh"}if(u&&"string"==typeof u)if(wt(u,"%"))f=f/h.height*100+"%";else if(wt(u,"vw")){f=f/this.window.innerWidth*100+"vw"}else if(wt(u,"vh")){f=f/this.window.innerHeight*100+"vh"}var C={width:this.createSizeForCssProperty(x,"width"),height:this.createSizeForCssProperty(f,"height")};"row"===this.flexDir?C.flexBasis=C.width:"column"===this.flexDir&&(C.flexBasis=C.height),this.setState(C),this.props.onResize&&this.props.onResize(e,c,this.resizable,j)}},t.prototype.onMouseUp=function(e){var t=this.state,s=t.isResizing,i=t.direction,n=t.original;if(s&&this.resizable){var o={width:this.size.width-n.width,height:this.size.height-n.height};this.props.onResizeStop&&this.props.onResizeStop(e,i,this.resizable,o),this.props.size&&this.setState(this.props.size),this.unbindEvents(),this.setState({isResizing:!1,backgroundStyle:gt(gt({},this.state.backgroundStyle),{cursor:"auto"})})}},t.prototype.updateSize=function(e){this.setState({width:e.width,height:e.height})},t.prototype.renderResizer=function(){var e=this,t=this.props,s=t.enable,n=t.handleStyles,o=t.handleClasses,r=t.handleWrapperStyle,a=t.handleWrapperClass,l=t.handleComponent;if(!s)return null;var c=Object.keys(s).map((function(t){return!1!==s[t]?i.createElement(dt,{key:t,direction:t,onResizeStart:e.onResizeStart,replaceStyles:n&&n[t],className:o&&o[t]},l&&l[t]?l[t]:null):null}));return i.createElement("div",{className:a,style:r},c)},t.prototype.render=function(){var e=this,t=Object.keys(this.props).reduce((function(t,s){return-1!==Tt.indexOf(s)||(t[s]=e.props[s]),t}),{}),s=gt(gt(gt({position:"relative",userSelect:this.state.isResizing?"none":"auto"},this.props.style),this.sizeStyle),{maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight,minWidth:this.props.minWidth,minHeight:this.props.minHeight,boxSizing:"border-box",flexShrink:0});this.state.flexBasis&&(s.flexBasis=this.state.flexBasis);var n=this.props.as||"div";return i.createElement(n,gt({ref:this.ref,style:s,className:this.props.className},t),this.state.isResizing&&i.createElement("div",{style:this.state.backgroundStyle}),this.props.children,this.renderResizer())},t.defaultProps={as:"div",onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},enable:{top:!0,right:!0,bottom:!0,left:!0,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},style:{},grid:[1,1],lockAspectRatio:!1,lockAspectRatioExtraWidth:0,lockAspectRatioExtraHeight:0,scale:1,resizeRatio:1,snapGap:0},t}(i.PureComponent);const kt=f.keyframes`
  0% {
    transform: translateY(400px);
  }

  100% {
    transform: translateY(0px);
  }
`,zt=(0,r.stylesFactory)((e=>({container:f.css`
      position: fixed !important;
      bottom: 0;
      background: ${e.colors.background.primary};
      border-top: 1px solid ${e.colors.border.weak};
      margin: ${e.spacing(0,-2,0,-2)};
      box-shadow: ${e.shadows.z3};
      z-index: ${e.zIndex.sidemenu};
    `,drawerActive:f.css`
      opacity: 1;
      animation: 0.5s ease-out ${kt};
    `,rzHandle:f.css`
      background: ${e.colors.secondary.main};
      transition: 0.3s background ease-in-out;
      position: relative;
      width: 200px !important;
      height: 7px !important;
      left: calc(50% - 100px) !important;
      top: -4px !important;
      cursor: grab;
      border-radius: 4px;
      &:hover {
        background: ${e.colors.secondary.shade};
      }
    `})));function Dt(e){const{width:t,children:s,onResize:i}=e,n=(0,r.useTheme2)(),o=zt(n),a=`${t+31.5}px`;return(0,C.jsx)(It,{className:(0,f.cx)(o.container,o.drawerActive),defaultSize:{width:a,height:"400px"},handleClasses:{top:o.rzHandle},enable:{top:!0,right:!1,bottom:!1,left:!1,topRight:!1,bottomRight:!1,bottomLeft:!1,topLeft:!1},maxHeight:"100vh",maxWidth:a,minWidth:a,onResize:i,children:s})}const Ft={deleteRichHistory:_e.ik},Lt=(0,n.connect)((function(e,t){let{exploreId:s}=t;const i=e.explore,n=i[s],{datasourceInstance:o}=n,r=u.Z.getBool(l.hO.starredTabAsFirstTab,!1)?st.Starred:st.RichHistory,{richHistory:a}=i;return{richHistory:a,firstTab:r,activeDatasourceInstance:null==o?void 0:o.name}}),Ft);const Nt=Lt((function(e){const[t,s]=(0,i.useState)(400),{richHistory:n,width:o,firstTab:r,activeDatasourceInstance:a,exploreId:l,deleteRichHistory:c,onClose:d}=e;return(0,C.jsx)(Dt,{width:o,onResize:(e,t,i)=>{s(Number(i.style.height.slice(0,-2)))},children:(0,C.jsx)(ot,{richHistory:n,firstTab:r,activeDatasourceInstance:a,exploreId:l,deleteRichHistory:c,onClose:d,height:t})})}));var Ot=s("./public/app/features/inspector/InspectJSONTab.tsx"),$t=s("./public/app/features/inspector/QueryInspector.tsx"),Et=s("./public/app/features/inspector/InspectStatsTab.tsx"),Mt=s("./public/app/features/inspector/InspectDataTab.tsx"),Bt=s("./public/app/features/inspector/InspectErrorTab.tsx");const Pt={runQueries:y.aA},At=(0,n.connect)((function(e,t){let{exploreId:s}=t;const i=e.explore[s],{loading:n,queryResponse:o}=i;return{loading:n,queryResponse:o}}),Pt)((function(e){var t;const{loading:s,width:i,onClose:n,queryResponse:o,timeZone:a}=e,l=(null==o?void 0:o.series)||[],c=null==o?void 0:o.error,d={label:"Stats",value:"stats",icon:"chart-line",content:(0,C.jsx)(Et.f,{data:o,timeZone:null==o||null===(t=o.request)||void 0===t?void 0:t.timezone})},p={label:"JSON",value:"json",icon:"brackets-curly",content:(0,C.jsx)(Ot.W,{data:o,onClose:n})},u={label:"Data",value:"data",icon:"database",content:(0,C.jsx)(Mt.E,{data:l,isLoading:s,options:{withTransforms:!1,withFieldConfig:!1},timeZone:a})},h=[d,{label:"Query",value:"query",icon:"info-circle",content:(0,C.jsx)($t.D,{data:l,onRefreshQuery:()=>e.runQueries(e.exploreId)})},p,u];if(c){const e={label:"Error",value:"error",icon:"exclamation-triangle",content:(0,C.jsx)(Bt.l,{error:c})};h.push(e)}return(0,C.jsx)(Dt,{width:i,onResize:()=>{},children:(0,C.jsx)(r.TabbedContainer,{tabs:h,onClose:n,closeIconTooltip:"Close query inspector"})})}));var qt=s("./public/app/features/profile/state/reducers.ts");function Zt(e){const{onClick:t,isSynced:s}=e;return(0,C.jsx)(r.Tooltip,{content:()=>{const{isSynced:t}=e,s=t?"Unsync all views":"Sync all views to this time range";return(0,C.jsx)(C.Fragment,{children:s})},placement:"bottom",children:(0,C.jsx)(r.ToolbarButton,{icon:"link",variant:s?"active":"default","aria-label":s?"Synced times":"Unsynced times",onClick:t})})}var _t=s("./public/app/core/components/TimePicker/TimePickerWithHistory.tsx"),Ht=s("./public/app/core/utils/timePicker.ts");function Qt(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class Wt extends i.Component{constructor(){super(...arguments),Qt(this,"onMoveTimePicker",(e=>{const{range:t,onChangeTime:s,timeZone:i}=this.props,{from:n,to:o}=(0,Ht.e)(e,t);s({from:(0,d.dateTimeForTimeZone)(i,n),to:(0,d.dateTimeForTimeZone)(i,o)})})),Qt(this,"onMoveForward",(()=>this.onMoveTimePicker(1))),Qt(this,"onMoveBack",(()=>this.onMoveTimePicker(-1))),Qt(this,"onChangeTimePicker",(e=>{const t=d.dateMath.isMathString(e.raw.from)?e.raw.from:e.from,s=d.dateMath.isMathString(e.raw.to)?e.raw.to:e.to;this.props.onChangeTime({from:t,to:s})})),Qt(this,"onZoom",(()=>{const{range:e,onChangeTime:t,timeZone:s}=this.props,{from:i,to:n}=(0,Ht.h)(e,2);t({from:(0,d.dateTimeForTimeZone)(s,i),to:(0,d.dateTimeForTimeZone)(s,n)})}))}render(){const{range:e,timeZone:t,fiscalYearStartMonth:s,splitted:i,syncedTimes:n,onChangeTimeSync:o,hideText:r,onChangeTimeZone:a,onChangeFiscalYearStartMonth:l}=this.props,c=i?(0,C.jsx)(Zt,{onClick:o,isSynced:n}):void 0,d={value:e,timeZone:t,fiscalYearStartMonth:s,onMoveBackward:this.onMoveBack,onMoveForward:this.onMoveForward,onZoom:this.onZoom,hideText:r};return(0,C.jsx)(_t.a,Object.assign({},d,{timeSyncButton:c,isSynced:n,onChange:this.onChangeTimePicker,onChangeTimeZone:a,onChangeFiscalYearStartMonth:l}))}}function Ut(e){const{start:t,pause:s,resume:i,isLive:n,isPaused:o,stop:a,splitted:l}=e,c=n&&!o?"active":"default",d=n?o?i:s:t;return(0,C.jsxs)(r.ButtonGroup,{children:[(0,C.jsx)(r.Tooltip,{content:n&&!o?(0,C.jsx)(C.Fragment,{children:"Pause the live stream"}):(0,C.jsx)(C.Fragment,{children:"Start live stream your logs"}),placement:"bottom",children:(0,C.jsx)(r.ToolbarButton,{iconOnly:l,variant:c,icon:!n||o?"play":"pause",onClick:d,children:n&&o?"Paused":"Live"})}),(0,C.jsx)(he.Z,{mountOnEnter:!0,unmountOnExit:!0,timeout:100,in:n,classNames:{enter:Vt.stopButtonEnter,enterActive:Vt.stopButtonEnterActive,exit:Vt.stopButtonExit,exitActive:Vt.stopButtonExitActive},children:(0,C.jsx)(r.Tooltip,{content:(0,C.jsx)(C.Fragment,{children:"Stop and exit the live stream"}),placement:"bottom",children:(0,C.jsx)(r.ToolbarButton,{variant:c,onClick:a,icon:"square-shape"})})})]})}const Vt={stopButtonEnter:f.css`
    label: stopButtonEnter;
    width: 0;
    opacity: 0;
    overflow: hidden;
  `,stopButtonEnterActive:f.css`
    label: stopButtonEnterActive;
    opacity: 1;
    width: 32px;
  `,stopButtonExit:f.css`
    label: stopButtonExit;
    width: 32px;
    opacity: 1;
    overflow: hidden;
  `,stopButtonExitActive:f.css`
    label: stopButtonExitActive;
    opacity: 0;
    width: 0;
  `};var Gt=s("./public/app/features/dashboard/services/TimeSrv.ts");function Kt(e){const{isSmall:t,loading:s,onRun:i,onChangeRefreshInterval:n,refreshInterval:o,showDropdown:a,isLive:l}=e,c=(0,Gt.$t)().getValidIntervals(r.defaultIntervals);let d=s?"Cancel":"Run query",p="108px";return l?null:(t&&(d=void 0,p="35px"),(0,C.jsx)(r.RefreshPicker,{onIntervalChanged:n,value:o,isLoading:s,text:d,intervals:c,isLive:l,onRefresh:()=>i(s),noIntervalPicker:!a,primary:!0,width:p}))}var Yt,Jt=s("./public/app/core/utils/kbn.ts"),Xt=s("./public/app/features/dashboard/services/DashboardSrv.ts"),es=s("./public/app/features/dashboard/state/reducers.ts"),ts=s("./public/app/core/services/context_srv.ts");const ss={setDashboardQueriesToUpdateOnLoad:es.gq},is=(0,n.connect)((function(e,t){let{exploreId:s}=t;const i=e.explore,n=Ie(e),{datasourceInstance:o,queries:r,originPanelId:a}=i[s],l=["Editor","Admin"];return ze.ZP.viewersCanEdit&&l.push("Viewer"),{exploreId:s,datasourceInstance:o,queries:r,originPanelId:a,splitted:n,canEdit:l.some((e=>ts.Vt.hasRole(e)))}}),ss),ns=is((e=>{let{originPanelId:t,setDashboardQueriesToUpdateOnLoad:s,queries:i,splitted:n,canEdit:o}=e;const a=t&&Number.isInteger(t);if(n||!a)return null;const l=e=>e.map((e=>(delete e.context,delete e.key,e))),c=async function(){let{withChanges:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const n=(0,Xt.h4)(),o=n.getCurrent();if(!o)return;const r=Jt.Z.slugifyForUrl(o.title);e&&s({panelId:t,queries:l(i)});const a={};e||o.panelInEdit?a.editPanel=t:o.panelInView&&(a.viewPanel=t),Y.locationService.push(d.urlUtil.renderUrl(`/d/${o.uid}/:${r}`,a))};return(0,C.jsxs)(r.ButtonGroup,{children:[(0,C.jsx)(r.Tooltip,{content:"Return to panel",placement:"bottom",children:(0,C.jsx)(r.ToolbarButton,{"data-testid":"returnButton",title:"Return to panel",onClick:()=>c(),children:Yt||(Yt=(0,C.jsx)(r.Icon,{name:"arrow-left"}))})}),o&&(0,C.jsx)(r.ButtonSelect,{"data-testid":"returnButtonWithChanges",options:[{label:"Return to panel with changes",value:""}],onChange:()=>c({withChanges:!0})})]})}));var os=s("./public/app/features/dashboard/components/DashNav/DashNavButton.tsx");function rs(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class as extends i.PureComponent{constructor(){var e;super(...arguments),e=this,rs(this,"onChangeDatasource",(async e=>{this.props.changeDatasource(this.props.exploreId,e.uid,{importQueries:!0})})),rs(this,"onRunQuery",(function(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{runQueries:s,cancelQueries:i,exploreId:n}=e.props;return t?i(n):s(n)})),rs(this,"onChangeRefreshInterval",(e=>{const{changeRefreshInterval:t,exploreId:s}=this.props;t(s,e)})),rs(this,"onChangeTimeSync",(()=>{const{syncTimes:e,exploreId:t}=this.props;e(t)}))}render(){const{datasourceMissing:e,closeSplit:t,exploreId:s,loading:i,range:n,timeZone:a,fiscalYearStartMonth:l,splitted:c,syncedTimes:d,refreshInterval:p,onChangeTime:u,split:h,hasLiveOption:g,isLive:m,isPaused:f,containerWidth:x,onChangeTimeZone:v,onChangeFiscalYearStartMonth:y}=this.props,b=(c?x<700:x<800)||!1,w=c||x<1210;return(0,C.jsx)(r.PageToolbar,{title:s===o.K.left?"Explore":void 0,pageIcon:s===o.K.left?"compass":void 0,leftItems:[s===o.K.left&&(0,C.jsx)(os.u,{tooltip:"Copy shortened link",icon:"share-alt",onClick:()=>(0,Ze.L)(window.location.href),"aria-label":"Copy shortened link"},"share"),!e&&(0,C.jsx)(Y.DataSourcePicker,{onChange:this.onChangeDatasource,current:this.props.datasourceName,hideTextValue:b,width:b?8:void 0},`${s}-ds-picker`)].filter(Boolean),children:(0,C.jsxs)(r.ToolbarButtonRow,{children:[(0,C.jsx)(ns,{exploreId:s}),c?(0,C.jsx)(r.ToolbarButton,{title:"Close split pane",onClick:()=>t(s),icon:"times",children:"Close"}):(0,C.jsx)(r.ToolbarButton,{title:"Split",onClick:()=>h(),icon:"columns",disabled:m,children:"Split"}),!m&&(0,C.jsx)(Wt,{exploreId:s,range:n,timeZone:a,fiscalYearStartMonth:l,onChangeTime:u,splitted:c,syncedTimes:d,onChangeTimeSync:this.onChangeTimeSync,hideText:w,onChangeTimeZone:v,onChangeFiscalYearStartMonth:y}),(0,C.jsx)(Kt,{refreshInterval:p,onChangeRefreshInterval:this.onChangeRefreshInterval,isSmall:c||w,isLive:m,loading:i||m&&!f,onRun:this.onRunQuery,showDropdown:!m}),p&&(0,C.jsx)(r.SetInterval,{func:this.onRunQuery,interval:p,loading:i}),g&&(0,C.jsx)(fe,{exploreId:s,children:e=>(0,C.jsx)(Ut,{splitted:c,isLive:m,isPaused:f,start:e.start,pause:e.pause,resume:e.resume,stop:e.stop})})]})})}}const ls={changeDatasource:He.zU,changeRefreshInterval:b.oz,cancelQueries:y.ci,runQueries:y.aA,closeSplit:a.YV,split:a.bW,syncTimes:b.mG,onChangeTimeZone:qt.YT,onChangeFiscalYearStartMonth:qt.rf},cs=(0,n.connect)(((e,t)=>{var s;let{exploreId:i}=t;const{syncedTimes:n}=e.explore,o=e.explore[i],{datasourceInstance:r,datasourceMissing:a,range:l,refreshInterval:c,loading:d,isLive:p,isPaused:u,containerWidth:h}=o,g=!(null==r||null===(s=r.meta)||void 0===s||!s.streaming);return{datasourceMissing:a,datasourceName:null==r?void 0:r.name,loading:d,range:l,timeZone:(0,m.Z)(e.user),fiscalYearStartMonth:(0,m.i)(e.user),splitted:Ie(e),refreshInterval:c,hasLiveOption:g,isLive:p,isPaused:u,syncedTimes:n,containerWidth:h}}),ls)(as);var ds,ps,us=s("./public/app/core/core.ts");const hs=()=>{const e=(0,r.useTheme2)(),t=us.Vt.hasPermission(Re.bW.DataSourcesCreate)&&us.Vt.hasPermission(Re.bW.DataSourcesWrite),s=(0,C.jsxs)(C.Fragment,{children:[ds||(ds=(0,C.jsx)(r.Icon,{name:"rocket"})),(0,C.jsx)(C.Fragment,{children:" ProTip: You can also define data sources through configuration files. "}),ps||(ps=(0,C.jsx)("a",{href:"http://docs.grafana.org/administration/provisioning/#datasources?utm_source=explore",target:"_blank",rel:"noreferrer",className:"text-link",children:"Learn more"}))]}),i=(0,C.jsx)(r.LinkButton,{size:"lg",href:"datasources/new",icon:"database",disabled:!t,children:"Add data source"}),n=f.css`
    max-width: ${e.breakpoints.values.lg}px;
    margin-top: ${e.spacing(2)};
    align-self: center;
  `;return(0,C.jsx)(r.CallToActionCard,{callToActionElement:i,className:n,footer:s,message:"Explore requires at least one data source. Once you have added a data source, you can query it here."})};function gs(e){const t=(e=>({containerMargin:f.css`
      margin-top: ${e.spacing(2)};
    `}))((0,r.useTheme2)());return(0,C.jsx)("div",{className:t.containerMargin,children:(0,C.jsxs)(r.HorizontalGroup,{children:[!e.addQueryRowButtonHidden&&(0,C.jsx)(r.Button,{variant:"secondary","aria-label":"Add row button",onClick:e.onClickAddQueryRowButton,disabled:e.addQueryRowButtonDisabled,icon:"plus",children:"Add query"}),(0,C.jsx)(r.Button,{variant:"secondary","aria-label":"Rich history button",className:(0,f.cx)({"explore-active-button":e.richHistoryButtonActive}),onClick:e.onClickRichHistoryButton,icon:"history",children:"Query history"}),(0,C.jsx)(r.Button,{variant:"secondary","aria-label":"Query inspector button",className:(0,f.cx)({"explore-active-button":e.queryInspectorButtonActive}),onClick:e.onClickQueryInspectorButton,icon:"info-circle",children:"Inspector"})]})})}var ms,fs=s("./packages/grafana-ui/src/components/Table/types.ts"),xs=s("./.yarn/__virtual__/react-use-virtual-00326e70ba/3/opt/drone/yarncache/react-use-npm-17.3.2-a032cbeb01-7379460f51.zip/node_modules/react-use/esm/useToggle.js"),vs=s("./public/app/plugins/panel/nodeGraph/NodeGraph.tsx"),ys=s("./public/app/plugins/panel/nodeGraph/useCategorizeFrames.ts");const bs=e=>({warningText:f.css`
    label: warningText;
    font-size: ${e.typography.bodySmall.fontSize};
    color: ${e.colors.text.secondary};
  `});const ws={splitOpen:a.bW},Ss=(0,n.connect)((function(e,t){let{exploreId:s}=t;return{range:e.explore[s].range}}),ws)((function(e){var t;const{dataFrames:s,range:i,splitOpen:n,withTraceView:o}=e,a=(0,xe.u)(i,n),l=(0,r.useTheme2)(),c=(0,r.useStyles2)(bs),p=(0,d.applyFieldOverrides)({fieldConfig:{defaults:{},overrides:[]},data:s,replaceVariables:e=>e,theme:l}),{nodes:u}=(0,ys.Y)(p),[h,g]=(0,xs.Z)(!1),m=o&&(null===(t=u[0])||void 0===t?void 0:t.length)>1e3?(0,C.jsxs)("span",{className:c.warningText,children:[" (",u[0].length," nodes, can be slow to load)"]}):null;return(0,C.jsx)(r.Collapse,{label:(0,C.jsxs)("span",{children:["Node graph",m," ",ms||(ms=(0,C.jsx)(r.Badge,{text:"Beta",color:"blue",icon:"rocket",tooltip:"This visualization is in beta"}))]}),collapsible:o,isOpen:!o||h,onToggle:o?()=>g():void 0,children:(0,C.jsx)("div",{style:{height:o?500:600},children:(0,C.jsx)(vs.E,{dataFrames:p,getLinks:a})})})}));var js=s("./.yarn/__virtual__/react-transition-group-virtual-8df824fae8/3/opt/drone/yarncache/react-transition-group-npm-4.4.2-5052c30656-b67bf5b3e8.zip/node_modules/react-transition-group/esm/Transition.js");const Cs=e=>{const t={transition:`opacity ${e.duration}ms linear`,opacity:0},s={exited:{opacity:0,display:"none"},entering:{opacity:0},entered:{opacity:1},exiting:{opacity:0}};return(0,C.jsx)(js.ZP,{in:e.in,timeout:e.duration,unmountOnExit:e.unmountOnExit||!1,onExited:e.onExited,children:i=>(0,C.jsx)("div",{style:Object.assign({},t,s[i]),children:e.children})})},Ts=e=>{var t;const{queryError:s}=e,i=(0,r.useTheme2)(),n=!!s,o=n?100:10,a=s?"Query error":"Unknown error",l=(null==s?void 0:s.message)||(null==s||null===(t=s.data)||void 0===t?void 0:t.message)||null,c=f.css`
    margin-top: ${i.spacing(2)};
  `;return(0,C.jsx)(Cs,{in:n,duration:o,children:(0,C.jsx)(r.Alert,{severity:"error",title:a,className:c,children:l})})};function Rs(e){const t=(0,n.useSelector)((t=>{var s;return null===(s=t.explore[e.exploreId])||void 0===s?void 0:s.queryResponse})),s=(null==t?void 0:t.state)===d.LoadingState.Error?null==t?void 0:t.error:void 0;return(0,C.jsx)(Ts,{queryError:s})}var Is,ks,zs=s("./packages/jaeger-ui-components/src/index.ts");function Ds(e){let{splitOpenFn:t,traceToLogsOptions:s,dataFrame:i}=e;return i&&1!==i.fields.length&&i.fields.some((e=>{var t;return Boolean(null===(t=e.config.links)||void 0===t?void 0:t.length)}))?function(e){const s=i.fields.find((e=>{var t;return Boolean(null===(t=e.config.links)||void 0===t?void 0:t.length)}));try{const n=(0,xe.a)({field:s,rowIndex:e.dataFrameRowIndex,splitOpenFn:t,range:Ls(e),dataFrame:i});return{href:n[0].href,onClick:n[0].onClick,content:Is||(Is=(0,C.jsx)(r.Icon,{name:"gf-logs",title:"Explore the logs for this in split view"}))}}catch(e){return void console.error(e)}}:function(e,t){if(null==t||!t.datasourceUid)return;const s=(0,Se.ak)().getInstanceSettings(t.datasourceUid);if(!s)return;return function(i){const n=function(e,t){const{tags:s,filterByTraceID:i,filterBySpanID:n,mapTagNamesEnabled:o,mappedTags:r}=t,a=o&&null!=r&&r.length?r:null!=s&&s.length?s:Fs,l=[...e.process.tags,...e.tags].reduce(((e,t)=>{if(o){const s=a.find((e=>e.key===t.key));s&&e.push(`${s.value?s.value:s.key}="${t.value}"`)}else a.includes(t.key)&&e.push(`${t.key}="${t.value}"`);return e}),[]);if(!l.length)return;let c=`{${l.join(", ")}}`;i&&e.traceID&&(c+=` |="${e.traceID}"`);n&&e.spanID&&(c+=` |="${e.spanID}"`);return c}(i,t);if(!n)return;const o={title:s.name,url:"",internal:{datasourceUid:s.uid,datasourceName:s.name,query:{expr:n,refId:""}}},a=(0,d.mapInternalLinkToExplore)({link:o,internalLink:o.internal,scopedVars:{},range:Ls(i,{startMs:t.spanStartTimeShift?d.rangeUtil.intervalToMs(t.spanStartTimeShift):0,endMs:t.spanEndTimeShift?d.rangeUtil.intervalToMs(t.spanEndTimeShift):0}),field:{},onClickFn:e,replaceVariables:(0,Y.getTemplateSrv)().replace.bind((0,Y.getTemplateSrv)())});return{href:a.href,onClick:a.onClick,content:ks||(ks=(0,C.jsx)(r.Icon,{name:"gf-logs",title:"Explore the logs for this in split view"}))}}}(t,s)}const Fs=["cluster","hostname","namespace","pod"];function Ls(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{startMs:0,endMs:0};const s=Math.floor(e.startTime/1e3+t.startMs),i=(0,d.dateTime)(s),n=(e.startTime+e.duration)/1e3;let o=Math.floor(n+t.endMs);s===o&&o++;const r=(0,d.dateTime)(o);return{from:i,to:r,raw:{from:i,to:r}}}var Ns=s("../../opt/drone/yarncache/classnames-npm-2.3.1-f2ae0a8d3c-14db8889d5.zip/node_modules/classnames/index.js"),Os=s.n(Ns);const $s={Popover(e){let{children:t,content:s,overlayClassName:n}=e;const o=(0,i.useRef)(null);return(0,C.jsx)(r.PopoverController,{content:s,hideAfter:300,children:(e,s,a)=>(0,C.jsxs)(C.Fragment,{children:[o.current&&(0,C.jsx)(r.Popover,Object.assign({},a,{referenceElement:o.current,wrapperClassName:n,onMouseLeave:s,onMouseEnter:e})),i.cloneElement(t,{ref:o,onMouseEnter:e,onMouseLeave:s})]})})},Tooltip(e){let{children:t,title:s}=e;return(0,C.jsx)(r.Tooltip,{content:s,children:t})},Icon:()=>null,Dropdown:()=>null,Menu:()=>null,MenuItem:()=>null,Button(e){let{onClick:t,children:s,className:i}=e;return(0,C.jsx)(r.Button,{variant:"secondary",onClick:t,className:i,children:s})},Divider:function(e){let{className:t}=e;const s=Es((0,r.useTheme)());return(0,C.jsx)("div",{style:{},className:Os()(s.Divider,t)})},Input:e=>(0,C.jsx)(r.Input,Object.assign({},e)),InputGroup(e){let{children:t,className:s,style:i}=e;return(0,C.jsx)("span",{className:s,style:i,children:t})}},Es=(0,r.stylesFactory)((e=>({Divider:f.css`
      display: inline-block;
      background: ${e.isDark?"#242424":"#e8e8e8"};
      width: 1px;
      height: 0.9em;
      margin: 0 8px;
      vertical-align: middle;
    `})));function Ms(e,t){return e.filter((e=>e.hasChildren)).length===t.size}function Bs(e,t,s){return i=>{const n=t.get(i);if(!n)return;let o;o="tags"===e?n.toggleTags():"process"===e?n.toggleProcess():"warnings"===e?n.toggleWarnings():"references"===e?n.toggleReferences():"stackTraces"===e?n.toggleStackTraces():n.toggleLogs();const r=new Map(t);r.set(i,o),s(r)}}function Ps(){return{}}function As(e){var t,s,o;const r=e.dataFrames[0],{expandOne:a,collapseOne:l,childrenToggle:c,collapseAll:p,childrenHiddenIDs:u,expandAll:g}=function(){const[e,t]=(0,i.useState)(new Set),s=(0,i.useCallback)((function(s){if(0===e.size)return;let i=-1,n=!0;const o=s.reduce(((e,t)=>(t.depth<=i&&(n=!0),n&&e.has(t.spanID)&&(e.delete(t.spanID),n=!1,i=t.depth),e)),new Set(e));t(o)}),[e]),n=(0,i.useCallback)((function(s){if(Ms(s,e))return;let i;const n=s.reduce(((e,t)=>(i&&t.depth<=i.depth?(e.add(i.spanID),t.hasChildren&&(i=t)):t.hasChildren&&!e.has(t.spanID)&&(i=t),e)),new Set(e));i&&n.add(i.spanID),t(n)}),[e]),o=(0,i.useCallback)((function(){t(new Set)}),[]),r=(0,i.useCallback)((function(s){if(Ms(s,e))return;const i=s.reduce(((e,t)=>(t.hasChildren&&e.add(t.spanID),e)),new Set);t(i)}),[e]),a=(0,i.useCallback)((function(s){const i=new Set(e);e.has(s)?i.delete(s):i.add(s),t(i)}),[e]);return{childrenHiddenIDs:e,expandOne:s,collapseOne:n,expandAll:o,collapseAll:r,childrenToggle:a}}(),{detailStates:f,toggleDetail:x,detailLogItemToggle:v,detailLogsToggle:y,detailProcessToggle:b,detailReferencesToggle:w,detailTagsToggle:S,detailWarningsToggle:j,detailStackTracesToggle:T}=function(e){const[t,s]=(0,i.useState)(new Map);(0,i.useEffect)((()=>{s(new Map)}),[e,s]);const n=(0,i.useCallback)((function(e){const i=new Map(t);i.has(e)?i.delete(e):i.set(e,new zs.kt),s(i)}),[t]),o=(0,i.useCallback)((function(e,i){const n=t.get(e);if(!n)return;const o=n.toggleLogItem(i),r=new Map(t);return r.set(e,o),s(r)}),[t]);return{detailStates:t,toggleDetail:n,detailLogItemToggle:o,detailLogsToggle:(0,i.useCallback)((e=>Bs("logs",t,s)(e)),[t]),detailWarningsToggle:(0,i.useCallback)((e=>Bs("warnings",t,s)(e)),[t]),detailStackTracesToggle:(0,i.useCallback)((e=>Bs("stackTraces",t,s)(e)),[t]),detailReferencesToggle:(0,i.useCallback)((e=>Bs("references",t,s)(e)),[t]),detailProcessToggle:(0,i.useCallback)((e=>Bs("process",t,s)(e)),[t]),detailTagsToggle:(0,i.useCallback)((e=>Bs("tags",t,s)(e)),[t])}}(r),{removeHoverIndentGuideId:R,addHoverIndentGuideId:I,hoverIndentGuideIds:k}=function(){const[e,t]=(0,i.useState)(new Set);return{hoverIndentGuideIds:e,addHoverIndentGuideId:(0,i.useCallback)((function(e){t((t=>{const s=new Set(t);return s.add(e),s}))}),[]),removeHoverIndentGuideId:(0,i.useCallback)((function(e){t((t=>{const s=new Set(t);return s.delete(e),s}))}),[])}}(),{viewRange:z,updateViewRangeTime:D,updateNextViewRangeTime:F}=function(){const[e,t]=(0,i.useState)({time:{current:[0,1]}}),s=(0,i.useCallback)((function(e){t((t=>{const s=Object.assign({},t.time,e);return Object.assign({},t,{time:s})}))}),[]),n=(0,i.useCallback)((function(e,s){const i={current:[e,s]};t((e=>Object.assign({},e,{time:i})))}),[]);return{viewRange:e,updateViewRangeTime:n,updateNextViewRangeTime:s}}(),[L,N]=(0,i.useState)(.25),[O,$]=(0,i.useState)(!1),E=(0,i.useMemo)((()=>function(e){if(!e)return null;let t=1===e.fields.length?e.fields[0].values.get(0):function(e){const t=new d.DataFrameView(e),s={};for(let e=0;e<t.length;e++){const i=t.get(e);s[i.spanID]||(s[i.spanID]={serviceName:i.serviceName,tags:i.serviceTags})}return{traceID:t.get(0).traceID,processes:s,spans:t.toArray().map(((e,t)=>{var s;return Object.assign({},e,{duration:1e3*e.duration,startTime:1e3*e.startTime,processID:e.spanID,flags:0,references:e.parentSpanID?[{refType:"CHILD_OF",spanID:e.parentSpanID,traceID:e.traceID}]:void 0,logs:(null===(s=e.logs)||void 0===s?void 0:s.map((e=>Object.assign({},e,{timestamp:1e3*e.timestamp}))))||[],dataFrameRowIndex:t})}))}}(e);return(0,zs.R1)(t)}(r)),[r]),{search:M,setSearch:B,spanFindMatches:P}=function(e){const[t,s]=(0,i.useState)(""),n=(0,i.useMemo)((()=>t&&e?(0,zs.rZ)(t,e):void 0),[t,e]);return{search:t,setSearch:s,spanFindMatches:n}}(null==E?void 0:E.spans),A=(0,n.useSelector)((t=>{var s,i;return null!==(s=null===(i=t.explore[e.exploreId])||void 0===i?void 0:i.datasourceInstance)&&void 0!==s?s:void 0})),[q,Z]=function(e){const t=(0,n.useSelector)((t=>{var s;return null===(s=t.explore[e.exploreId])||void 0===s?void 0:s.panelsState.trace})),s=null==t?void 0:t.spanId,i=(0,n.useDispatch)(),o=s=>i((0,h.km)(e.exploreId,"trace",Object.assign({},t,{spanId:s}))),r=(0,n.useSelector)((t=>{var s;return null===(s=t.explore[e.exploreId])||void 0===s?void 0:s.queries.find((t=>t.refId===e.refId))}));return[s,(t,i)=>{var n,a;const l={title:"Deep link to this span",url:"",internal:{datasourceUid:null===(n=e.datasource)||void 0===n?void 0:n.uid,datasourceName:null===(a=e.datasource)||void 0===a?void 0:a.name,query:r,panelsState:{trace:{spanId:i}}}};return(0,d.mapInternalLinkToExplore)({link:l,internalLink:l.internal,scopedVars:{},range:{},field:{},onClickFn:()=>o(s===i?void 0:i),replaceVariables:(0,Y.getTemplateSrv)().replace.bind((0,Y.getTemplateSrv)())})}]}({refId:null==r?void 0:r.refId,exploreId:e.exploreId,datasource:A}),_=(0,i.useMemo)((()=>({childrenHiddenIDs:u,detailStates:f,hoverIndentGuideIds:k,shouldScrollToFirstUiFindMatch:!1,spanNameColumnWidth:L,traceID:null==E?void 0:E.traceID})),[u,f,k,L,null==E?void 0:E.traceID]),H=null===(t=(0,Se.ak)().getInstanceSettings(null==A?void 0:A.name))||void 0===t||null===(s=t.jsonData)||void 0===s?void 0:s.tracesToLogs,Q=(0,i.useMemo)((()=>Ds({splitOpenFn:e.splitOpenFn,traceToLogsOptions:H,dataFrame:r})),[e.splitOpenFn,H,r]),W=(0,i.useCallback)((()=>$(!O)),[O]),U=(0,n.useSelector)((e=>(0,m.Z)(e.user)));return null!==(o=e.dataFrames)&&void 0!==o&&o.length&&E?(0,C.jsxs)(zs.DE.Provider,{value:$s,children:[(0,C.jsx)(zs.T2,{canCollapse:!1,clearSearch:Ps,focusUiFindMatches:Ps,hideMap:!1,hideSummary:!1,nextResult:Ps,onSlimViewClicked:W,onTraceGraphViewClicked:Ps,prevResult:Ps,resultCount:0,slimView:O,textFilter:null,trace:E,traceGraphView:!1,updateNextViewRangeTime:F,updateViewRangeTime:D,viewRange:z,searchValue:M,onSearchValueChange:B,hideSearchButtons:!0,timeZone:U}),(0,C.jsx)(zs.Ox,{registerAccessors:Ps,scrollToFirstVisibleSpan:Ps,findMatchesIDs:P,trace:E,traceTimeline:_,updateNextViewRangeTime:F,updateViewRangeTime:D,viewRange:z,focusSpan:Ps,createLinkToExternalSpan:Ps,setSpanNameColumnWidth:N,collapseAll:p,collapseOne:l,expandAll:g,expandOne:a,childrenToggle:c,clearShouldScrollToFirstUiFindMatch:Ps,detailLogItemToggle:v,detailLogsToggle:y,detailWarningsToggle:j,detailStackTracesToggle:T,detailReferencesToggle:w,detailProcessToggle:b,detailTagsToggle:S,detailToggle:x,setTrace:Ps,addHoverIndentGuideId:I,removeHoverIndentGuideId:R,linksGetter:Ps,uiFind:M,createSpanLink:Q,scrollElement:e.scrollElement,focusedSpanId:q,createFocusSpanLink:Z})]}):null}function qs(e){const{dataFrames:t,splitOpenFn:s,exploreId:i,scrollElement:n}=e;return(0,C.jsx)(r.Collapse,{label:"Trace View",isOpen:!0,children:(0,C.jsx)(As,{exploreId:i,dataFrames:t,splitOpenFn:s,scrollElement:n})})}var Zs,_s;function Hs(e){var t;const[s,n]=(0,i.useState)(!1),o=e.error.message||(null===(t=e.error.data)||void 0===t?void 0:t.message)||"",a=!s&&o.length>100;return(0,C.jsx)(r.Alert,{title:"Failed to load log volume for this query",severity:"warning",children:a?(0,C.jsx)(r.Button,{variant:"secondary",size:"xs",onClick:()=>{n(!0)},children:"Show details"}):o})}function Qs(e){const{width:t,logsVolumeData:s,absoluteRange:i,timeZone:n,splitOpen:o,onUpdateTimeRange:a,onLoadLogsVolume:l}=e,c=(0,r.useTheme2)(),p=(0,r.useStyles2)(Ws),u=parseInt(c.spacing(2).slice(0,-2),10);let h;if(!s)return null;if(null!=s&&s.error)return(0,C.jsx)(Hs,{error:null==s?void 0:s.error});(null==s?void 0:s.state)===d.LoadingState.Loading?h=Zs||(Zs=(0,C.jsx)("span",{children:"Log volume is loading..."})):null!=s&&s.data&&(h=s.data.length>0?(0,C.jsx)(ie,{graphStyle:"lines",loadingState:d.LoadingState.Done,data:s.data,height:150,width:t-u,absoluteRange:i,onChangeTime:a,timeZone:n,splitOpenFn:o,tooltipDisplayMode:r.TooltipDisplayMode.Multi}):_s||(_s=(0,C.jsx)("span",{children:"No volume data."})));const g=function(e,t){var s,i;const n=e&&e.data[0]&&(null===(s=e.data[0].meta)||void 0===s||null===(i=s.custom)||void 0===i?void 0:i.absoluteRange);return n?(t.from-t.to)/(n.from-n.to):void 0}(s,i);let m;return void 0!==g&&g<1&&(m=(0,C.jsx)(r.InlineField,{label:"Reload log volume",transparent:!0,children:(0,C.jsx)(r.Button,{size:"xs",icon:"sync",variant:"secondary",onClick:l,id:"reload-volume"})})),(0,C.jsxs)(r.Collapse,{label:"Log volume",isOpen:!0,loading:(null==s?void 0:s.state)===d.LoadingState.Loading,children:[(0,C.jsx)("div",{style:{height:150},className:p.contentContainer,children:h}),(0,C.jsx)("div",{className:p.zoomInfoContainer,children:m})]})}const Ws=()=>({zoomInfoContainer:f.css`
      display: flex;
      justify-content: end;
      position: absolute;
      right: 5px;
      top: 5px;
    `,contentContainer:f.css`
      display: flex;
      align-items: center;
      justify-content: center;
    `});const Us=Re.f0.map((e=>({value:e,label:e[0].toUpperCase()+e.slice(1).replace(/_/," ")}))),Vs=(0,f.css)({display:"flex",justifyContent:"space-between"});function Gs(e){const{graphStyle:t,onChangeGraphStyle:s}=e;return(0,C.jsxs)("div",{className:Vs,children:["Graph",(0,C.jsx)(r.RadioButtonGroup,{size:"sm",options:Us,value:t,onChange:s})]})}var Ks,Ys=s("./public/app/plugins/panel/nodeGraph/utils.ts");function Js(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}var Xs;!function(e){e[e.RichHistory=0]="RichHistory",e[e.QueryInspector=1]="QueryInspector"}(Xs||(Xs={}));class ei extends i.PureComponent{constructor(e){super(e),Js(this,"scrollElement",void 0),Js(this,"absoluteTimeUnsubsciber",void 0),Js(this,"onChangeTime",(e=>{const{updateTimeRange:t,exploreId:s}=this.props;t({exploreId:s,rawRange:e})})),Js(this,"onClickExample",(e=>{this.props.setQueries(this.props.exploreId,[e])})),Js(this,"onCellFilterAdded",(e=>{const{value:t,key:s,operator:i}=e;i===fs.PT&&this.onClickFilterLabel(s,t),i===fs.tE&&this.onClickFilterOutLabel(s,t)})),Js(this,"onClickFilterLabel",((e,t)=>{this.onModifyQueries({type:"ADD_FILTER",key:e,value:t})})),Js(this,"onClickFilterOutLabel",((e,t)=>{this.onModifyQueries({type:"ADD_FILTER_OUT",key:e,value:t})})),Js(this,"onClickAddQueryRowButton",(()=>{const{exploreId:e,queryKeys:t}=this.props;this.props.addQueryRow(e,t.length)})),Js(this,"onMakeAbsoluteTime",(()=>{const{makeAbsoluteTime:e}=this.props;e()})),Js(this,"onModifyQueries",((e,t)=>{const{datasourceInstance:s}=this.props;if(null!=s&&s.modifyQuery){const i=(e,t)=>s.modifyQuery(e,t);this.props.modifyQueries(this.props.exploreId,e,i,t)}})),Js(this,"onResize",(e=>{this.props.changeSize(this.props.exploreId,e)})),Js(this,"onStartScanning",(()=>{this.props.scanStart(this.props.exploreId)})),Js(this,"onStopScanning",(()=>{this.props.scanStopAction({exploreId:this.props.exploreId})})),Js(this,"onUpdateTimeRange",(e=>{const{exploreId:t,updateTimeRange:s}=this.props;s({exploreId:t,absoluteRange:e})})),Js(this,"onChangeGraphStyle",(e=>{const{exploreId:t,changeGraphStyle:s}=this.props;s(t,e)})),Js(this,"toggleShowRichHistory",(()=>{this.setState((e=>({openDrawer:e.openDrawer===Xs.RichHistory?void 0:Xs.RichHistory})))})),Js(this,"toggleShowQueryInspector",(()=>{this.setState((e=>({openDrawer:e.openDrawer===Xs.QueryInspector?void 0:Xs.QueryInspector})))})),Js(this,"memoizedGetNodeGraphDataFrames",(0,c.Z)(Ys.Ee)),this.state={openDrawer:void 0}}componentDidMount(){this.absoluteTimeUnsubsciber=J.Z.subscribe($e.QI,this.onMakeAbsoluteTime)}componentWillUnmount(){var e;null===(e=this.absoluteTimeUnsubsciber)||void 0===e||e.unsubscribe()}renderEmptyState(){return Ks||(Ks=(0,C.jsx)("div",{className:"explore-container",children:(0,C.jsx)(hs,{})}))}renderGraphPanel(e){const{graphResult:t,absoluteRange:s,timeZone:i,splitOpen:n,queryResponse:o,loading:a,theme:l,graphStyle:c}=this.props,d=parseInt(l.spacing(2).slice(0,-2),10),p=(0,C.jsx)(Gs,{graphStyle:c,onChangeGraphStyle:this.onChangeGraphStyle});return(0,C.jsx)(r.Collapse,{label:p,loading:a,isOpen:!0,children:(0,C.jsx)(ie,{graphStyle:c,data:t,height:400,width:e-d,absoluteRange:s,onChangeTime:this.onUpdateTimeRange,timeZone:i,annotations:o.annotations,splitOpenFn:n,loadingState:o.state})})}renderLogsVolume(e){const{logsVolumeData:t,exploreId:s,loadLogsVolumeData:i,absoluteRange:n,timeZone:o,splitOpen:r}=this.props;return(0,C.jsx)(Qs,{absoluteRange:n,width:e,logsVolumeData:t,onUpdateTimeRange:this.onUpdateTimeRange,timeZone:o,splitOpen:r,onLoadLogsVolume:()=>i(s)})}renderTablePanel(e){const{exploreId:t,datasourceInstance:s,timeZone:i}=this.props;return(0,C.jsx)(Oe,{ariaLabel:p.wl.pages.Explore.General.table,width:e,exploreId:t,onCellFilterAdded:null!=s&&s.modifyQuery?this.onCellFilterAdded:void 0,timeZone:i})}renderLogsPanel(e){const{exploreId:t,syncedTimes:s,theme:i,queryResponse:n}=this.props,o=parseInt(i.spacing(2).slice(0,-2),10);return(0,C.jsx)(we,{exploreId:t,loadingState:n.state,syncedTimes:s,width:e-o,onClickFilterLabel:this.onClickFilterLabel,onClickFilterOutLabel:this.onClickFilterOutLabel,onStartScanning:this.onStartScanning,onStopScanning:this.onStopScanning})}renderNodeGraphPanel(){const{exploreId:e,showTrace:t,queryResponse:s}=this.props;return(0,C.jsx)(Ss,{dataFrames:this.memoizedGetNodeGraphDataFrames(s.series),exploreId:e,withTraceView:t})}renderTraceViewPanel(){const{queryResponse:e,splitOpen:t,exploreId:s}=this.props,i=e.series.filter((e=>{var t;return"trace"===(null===(t=e.meta)||void 0===t?void 0:t.preferredVisualisationType)}));return i.length&&(0,C.jsx)(qs,{exploreId:s,dataFrames:i,splitOpenFn:t,scrollElement:this.scrollElement})}render(){const{datasourceInstance:e,datasourceMissing:t,exploreId:s,graphResult:i,queryResponse:n,isLive:o,theme:a,showMetrics:l,showTable:c,showLogs:p,showTrace:u,showNodeGraph:h,timeZone:g}=this.props,{openDrawer:m}=this.state,x=(e=>({exploreMain:f.css`
      label: exploreMain;
      // Is needed for some transition animations to work.
      position: relative;
      margin-top: 21px;
    `,button:f.css`
      label: button;
      margin: 1em 4px 0 0;
    `,queryContainer:f.css`
      label: queryContainer;
      // Need to override normal css class and don't want to count on ordering of the classes in html.
      height: auto !important;
      flex: unset !important;
      display: unset !important;
      padding: ${e.spacing(1)};
    `}))(a),y=n&&n.state!==d.LoadingState.NotStarted,b=m===Xs.RichHistory,w=m===Xs.QueryInspector;return(0,C.jsxs)(r.CustomScrollbar,{autoHeightMin:"100%",scrollRefCallback:e=>this.scrollElement=e||void 0,children:[(0,C.jsx)(cs,{exploreId:s,onChangeTime:this.onChangeTime}),t?this.renderEmptyState():null,e&&(0,C.jsxs)("div",{className:"explore-container",children:[(0,C.jsxs)("div",{className:(0,f.cx)("panel-container",x.queryContainer),children:[(0,C.jsx)(ke,{exploreId:s}),(0,C.jsx)(gs,{addQueryRowButtonDisabled:o,addQueryRowButtonHidden:!1,richHistoryButtonActive:b,queryInspectorButtonActive:w,onClickAddQueryRowButton:this.onClickAddQueryRowButton,onClickRichHistoryButton:this.toggleShowRichHistory,onClickQueryInspectorButton:this.toggleShowQueryInspector}),(0,C.jsx)(Rs,{exploreId:s})]}),(0,C.jsx)(v.Z,{onResize:this.onResize,disableHeight:!0,children:e=>{let{width:t}=e;return 0===t?null:(0,C.jsx)("main",{className:(0,f.cx)(x.exploreMain),style:{width:t},children:(0,C.jsxs)(r.ErrorBoundaryAlert,{children:[y&&(0,C.jsxs)(C.Fragment,{children:[l&&i&&(0,C.jsx)(r.ErrorBoundaryAlert,{children:this.renderGraphPanel(t)}),(0,C.jsx)(r.ErrorBoundaryAlert,{children:this.renderLogsVolume(t)}),c&&(0,C.jsx)(r.ErrorBoundaryAlert,{children:this.renderTablePanel(t)}),p&&(0,C.jsx)(r.ErrorBoundaryAlert,{children:this.renderLogsPanel(t)}),h&&(0,C.jsx)(r.ErrorBoundaryAlert,{children:this.renderNodeGraphPanel()}),u&&(0,C.jsx)(r.ErrorBoundaryAlert,{children:this.renderTraceViewPanel()})]}),b&&(0,C.jsx)(Nt,{width:t,exploreId:s,onClose:this.toggleShowRichHistory}),w&&(0,C.jsx)(At,{exploreId:s,width:t,onClose:this.toggleShowQueryInspector,timeZone:g})]})})}})]})]})}}const ti={changeSize:h.qN,changeGraphStyle:h.Rl,modifyQueries:y.sK,scanStart:y.EA,scanStopAction:y.P4,setQueries:y.KO,updateTimeRange:b.cD,makeAbsoluteTime:b.F9,loadLogsVolumeData:y.QH,addQueryRow:y.CS,splitOpen:a.bW},si=(0,n.connect)((function(e,t){let{exploreId:s}=t;const i=e.explore,{syncedTimes:n}=i,o=i[s],r=(0,m.Z)(e.user),{datasourceInstance:a,datasourceMissing:l,queryKeys:c,isLive:d,graphResult:p,logsVolumeData:u,logsResult:h,showLogs:g,showMetrics:f,showTable:x,showTrace:v,absoluteRange:y,queryResponse:b,showNodeGraph:w,loading:S,graphStyle:j}=o;return{datasourceInstance:a,datasourceMissing:l,queryKeys:c,isLive:d,graphResult:p,logsVolumeData:u,logsResult:null!=h?h:void 0,absoluteRange:y,queryResponse:b,syncedTimes:n,timeZone:r,showLogs:g,showMetrics:f,showTable:x,showTrace:v,showNodeGraph:w,loading:S,graphStyle:j}}),ti),ii=(0,x.compose)(si,r.withTheme2)(ei);function ni(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class oi extends i.PureComponent{constructor(e){super(e),ni(this,"el",void 0),ni(this,"exploreEvents",void 0),ni(this,"refreshExplore",(e=>{const{exploreId:t,urlQuery:s}=this.props;s!==e&&s!==a.IS[t]&&this.props.refreshExplore(t,s)})),ni(this,"getRef",(e=>{this.el=e})),this.exploreEvents=new d.EventBusSrv,this.state={openDrawer:void 0}}componentDidMount(){var e,t;const{initialized:s,exploreId:i,initialDatasource:n,initialQueries:o,initialRange:r,originPanelId:a,panelsState:l}=this.props,c=null!==(e=null===(t=this.el)||void 0===t?void 0:t.offsetWidth)&&void 0!==e?e:0;s||this.props.initializeExplore(i,n,o,r,c,this.exploreEvents,l,a)}componentWillUnmount(){this.exploreEvents.removeAllListeners(),this.props.cleanupPaneAction({exploreId:this.props.exploreId})}componentDidUpdate(e){this.refreshExplore(e.urlQuery)}render(){const e=this.props.split?"explore explore-split":"explore";return(0,C.jsx)("div",{className:e,ref:this.getRef,"data-testid":p.wl.pages.Explore.General.container,children:this.props.initialized&&(0,C.jsx)(ii,{exploreId:this.props.exploreId})})}}const ri=(0,c.Z)(g.Z8),ai=(0,c.Z)(g.vP);const li={initializeExplore:h.CK,refreshExplore:h.Om,cleanupPaneAction:a.Jt},ci=(0,n.connect)((function(e,t){var s;const i=(0,g.J5)(t.urlQuery),n=(0,m.Z)(e.user),o=(0,m.i)(e.user),{datasource:r,queries:a,range:l,originPanelId:c,panelsState:d}=i||{},p=r||u.Z.get((0,g.I$)(e.user.orgId)),h=ri(a),f=l?ai(l,n,o):(0,g.OQ)(n,g.UI,o);return{initialized:null===(s=e.explore[t.exploreId])||void 0===s?void 0:s.initialized,initialDatasource:p,initialQueries:h,initialRange:f,originPanelId:c,panelsState:d}}),li),di=ci(oi);var pi=s("./public/app/core/components/Branding/Branding.tsx"),ui=s("./public/app/core/selectors/navModel.ts");const hi={resetExploreAction:a.WK,richHistoryUpdatedAction:a.ZU},gi=(0,n.connect)((e=>({navModel:(0,ui.h)(e.navIndex,"explore"),exploreState:e.explore})),hi);class mi extends i.PureComponent{componentWillUnmount(){this.props.resetExploreAction({})}componentDidMount(){a.IS.left=void 0,a.IS.right=void 0;const e=Y.locationService.getSearchObject();(e.from||e.to)&&Y.locationService.partial({from:void 0,to:void 0},!0);const t=(0,l.ub)();this.props.richHistoryUpdatedAction({richHistory:t})}componentDidUpdate(e){var t,s,i,n;const{left:o,right:r}=this.props.queryParams,a=Boolean(o)&&Boolean(r)?`${null===(t=this.props.exploreState.left.datasourceInstance)||void 0===t?void 0:t.name} | ${null===(s=this.props.exploreState.right)||void 0===s||null===(i=s.datasourceInstance)||void 0===i?void 0:i.name}`:`${null===(n=this.props.exploreState.left.datasourceInstance)||void 0===n?void 0:n.name}`,l=`${this.props.navModel.main.text} - ${a} - ${pi.c.AppTitle}`;document.title=l}render(){const{left:e,right:t}=this.props.queryParams,s=Boolean(e)&&Boolean(t);return(0,C.jsx)("div",{className:"page-scrollbar-wrapper",children:(0,C.jsxs)("div",{className:"explore-wrapper",children:[(0,C.jsx)(r.ErrorBoundaryAlert,{style:"page",children:(0,C.jsx)(di,{split:s,exploreId:o.K.left,urlQuery:e})}),s&&(0,C.jsx)(r.ErrorBoundaryAlert,{style:"page",children:(0,C.jsx)(di,{split:s,exploreId:o.K.right,urlQuery:t})})]})})}}const fi=gi(mi)},"./.yarn/__virtual__/react-use-virtual-00326e70ba/3/opt/drone/yarncache/react-use-npm-17.3.2-a032cbeb01-7379460f51.zip/node_modules/react-use/esm/usePrevious.js":(e,t,s)=>{"use strict";s.d(t,{Z:()=>n});var i=s("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js");function n(e){var t=(0,i.useRef)();return(0,i.useEffect)((function(){t.current=e})),t.current}},"../../opt/drone/yarncache/fast-memoize-npm-2.5.2-f42a7c6940-79fa759719.zip/node_modules/fast-memoize/src/index.js":e=>{function t(e,t,s,i){var n,o=null==(n=i)||"number"==typeof n||"boolean"==typeof n?i:s(i),r=t.get(o);return void 0===r&&(r=e.call(this,i),t.set(o,r)),r}function s(e,t,s){var i=Array.prototype.slice.call(arguments,3),n=s(i),o=t.get(n);return void 0===o&&(o=e.apply(this,i),t.set(n,o)),o}function i(e,t,s,i,n){return s.bind(t,e,i,n)}function n(e,n){return i(e,this,1===e.length?t:s,n.cache.create(),n.serializer)}function o(){return JSON.stringify(arguments)}function r(){this.cache=Object.create(null)}r.prototype.has=function(e){return e in this.cache},r.prototype.get=function(e){return this.cache[e]},r.prototype.set=function(e,t){this.cache[e]=t};var a={create:function(){return new r}};e.exports=function(e,t){var s=t&&t.cache?t.cache:a,i=t&&t.serializer?t.serializer:o;return(t&&t.strategy?t.strategy:n)(e,{cache:s,serializer:i})},e.exports.strategies={variadic:function(e,t){return i(e,this,s,t.cache.create(),t.serializer)},monadic:function(e,s){return i(e,this,t,s.cache.create(),s.serializer)}}}}]);
//# sourceMappingURL=explore.cd4ada1146b53ad3284f.js.map