(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[9782],{"./public/app/features/dashboard/dashgrid/SeriesVisibilityConfigFactory.ts":(e,t,s)=>{"use strict";s.d(t,{N:()=>a});var i=s("./packages/grafana-data/src/index.ts"),n=s("./packages/grafana-ui/src/index.ts");const o="hideSeriesFrom",r=(0,i.isSystemOverrideWithRef)(o);function a(e,t,s,i){const{overrides:o}=s,a=e,h=o.findIndex(r);if(h<0){if(t===n.SeriesVisibilityChangeMode.ToggleSelection){const e=l([a]);return Object.assign({},s,{overrides:[...s.overrides,e]})}const e=l(u(i,a));return Object.assign({},s,{overrides:[...s.overrides,e]})}const g=Array.from(o),[m]=g.splice(h,1);if(t===n.SeriesVisibilityChangeMode.ToggleSelection){const e=d(m);if(e[0]===a&&1===e.length)return Object.assign({},s,{overrides:g});const t=l([a]);return Object.assign({},s,{overrides:[...g,t]})}const f=c(m,a);return p(f,i)?Object.assign({},s,{overrides:g}):Object.assign({},s,{overrides:[...g,f]})}function l(e,t=i.ByNamesMatcherMode.exclude,s){var n;return s=null!==(n=s)&&void 0!==n?n:{id:"custom.hideFrom",value:{viz:!0,legend:!1,tooltip:!1}},{__systemRef:o,matcher:{id:i.FieldMatcherID.byNames,options:{mode:t,names:e,prefix:t===i.ByNamesMatcherMode.exclude?"All except:":void 0,readOnly:!0}},properties:[Object.assign({},s,{value:{viz:!0,legend:!1,tooltip:!1}})]}}const c=(e,t,s=i.ByNamesMatcherMode.exclude)=>{const n=e.properties.find((e=>"custom.hideFrom"===e.id)),o=d(e),r=o.findIndex((e=>e===t));return r<0?o.push(t):o.splice(r,1),l(o,s,n)},d=e=>{var t;const s=null===(t=e.matcher.options)||void 0===t?void 0:t.names;return Array.isArray(s)?s:[]},p=(e,t)=>d(e).length===u(t).length,u=(e,t)=>{const s=new Set;for(const n of e)for(const o of n.fields){if(o.type!==i.FieldType.number)continue;const r=(0,i.getFieldDisplayName)(o,n,e);r!==t&&s.add(r)}return Array.from(s)}},"./public/app/features/explore/Wrapper.tsx":(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>Ms});var i=s("./node_modules/react/index.js"),n=s("./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("./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("./node_modules/@emotion/css/dist/emotion-css.esm.js"),x=s("./node_modules/redux/es/redux.js"),v=s("./node_modules/react-virtualized-auto-sizer/dist/index.esm.js"),y=s("./node_modules/emotion/dist/emotion.esm.js"),b=s("./public/app/features/explore/state/query.ts"),w=s("./public/app/features/explore/state/time.ts"),S=s("./node_modules/tinycolor2/tinycolor.js"),j=s.n(S);const C=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 T=s("./node_modules/react/jsx-runtime.js");const R=({timeInMs:e,className:t,humanize:s})=>(0,T.jsx)("span",{className:`elapsed-time ${t}`,children:I(e,s)}),I=(e,t=!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`},k=({resetKey:e,humanize:t,className:s})=>{const[n,o]=(0,i.useState)(0);return C((()=>o(n+150)),150),(0,i.useEffect)((()=>o(0)),[e]),(0,T.jsx)(R,{timeInMs:n,className:s,humanize:t})};var z;function N(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class F extends i.PureComponent{constructor(e){super(e),N(this,"liveEndDiv",null),N(this,"scrollContainerRef",i.createRef()),N(this,"onScroll",(e=>{const{isPaused:t,onPause:s}=this.props,{scrollTop:i,clientHeight:n,scrollHeight:o}=e.currentTarget;o-(i+n)>=5&&!t&&s()})),N(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: ${j()(e.colors.info.transparent).setAlpha(.25).toString()};
    animation: fade 1s ease-out 1s 1 normal forwards;
    @keyframes fade {
      from {
        background-color: ${j()(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,T.jsxs)("div",{children:[(0,T.jsx)("table",{className:o.fullWidth,children:(0,T.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,T.jsxs)("tr",{className:(0,f.cx)(a,o.logsRowFade),children:[(0,T.jsx)("td",{className:(0,f.cx)(l),children:(0,d.dateTimeFormat)(e.timeEpochMs,{timeZone:t})}),(0,T.jsx)("td",{className:(0,f.cx)(c),children:e.hasAnsi?(0,T.jsx)(r.LogMessageAnsi,{value:e.raw}):e.entry})]},e.uid))),(0,T.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,T.jsxs)("div",{className:o.logsRowsIndicator,children:[(0,T.jsxs)(r.Button,{variant:"secondary",onClick:n?i:s,className:o.button,children:[(0,T.jsx)(r.Icon,{name:n?"play":"pause"})," ",n?"Resume":"Pause"]}),(0,T.jsxs)(r.Button,{variant:"secondary",onClick:this.props.stopLive,className:o.button,children:[z||(z=(0,T.jsx)(r.Icon,{name:"square-shape",size:"lg",type:"mono"})),"  Exit live mode"]}),n||(0,T.jsxs)("span",{children:["Last line received: ",(0,T.jsx)(k,{resetKey:this.props.logRows,humanize:!0})," ago"]})]})]})}}const D=(0,r.withTheme2)(F);var L=s("./node_modules/lodash/lodash.js"),O=s("./packages/grafana-schema/src/index.ts"),M=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};
  `}),A=(0,i.memo)((function(e){const t=(0,r.useStyles2)(E),{label:s,value:i}=e;return(0,T.jsxs)("div",{className:t.metaItem,children:[s&&(0,T.jsxs)("span",{className:t.metaLabel,children:[s,":"]}),(0,T.jsx)("span",{className:t.metaValue,children:i})]})})),P=(0,i.memo)((function(e){const t=(0,r.useStyles2)(E),{metaItems:s}=e;return(0,T.jsx)("div",{className:t.metaContainer,children:s.map(((e,t)=>(0,T.jsx)(A,{label:e.label,value:e.value},`${t}-${e.label}`)))})}));var B;const q=i.memo((({meta:e,dedupStrategy:t,dedupCount:s,showDetectedFields:i,clearDetectedFields:n,hasUnescapedContent:o,forceEscape:a,onEscapeNewlines:l,logRows:c})=>{const p=[...e];return t!==d.LogsDedupStrategy.none&&p.push({label:"Dedup count",value:s,kind:d.LogsMetaKind.Number}),c.some((e=>e.entry.length>$.n))&&p.push({label:"Info",value:"Logs with more than 100,000 characters could not be parsed and highlighted",kind:d.LogsMetaKind.String}),(null==i?void 0:i.length)>0&&p.push({label:"Showing only detected fields",value:H(i,d.LogsMetaKind.LabelsMap)},{label:"",value:(0,T.jsx)(r.Button,{variant:"secondary",size:"sm",onClick:n,children:"Show all detected fields"})}),o&&p.push({label:"Your logs might have incorrectly escaped content",value:(0,T.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,T.jsxs)(r.Button,{variant:"secondary",size:"sm",onClick:l,children:[(0,T.jsxs)("span",{children:[a?"Remove escaping":"Escape newlines"," "]}),B||(B=(0,T.jsx)(r.Icon,{name:"exclamation-triangle",className:"muted",size:"sm"}))]})})}),(0,T.jsx)(T.Fragment,{children:p&&(0,T.jsx)(P,{metaItems:p.map((e=>({label:e.label,value:"kind"in e?H(e.value,e.kind):e.value})))})})}));function H(e,t){return t===d.LogsMetaKind.LabelsMap?(0,T.jsx)("span",{className:"logs-meta-item__labels",children:(0,T.jsx)(r.LogLabels,{labels:e})}):t===d.LogsMetaKind.Error?(0,T.jsx)("span",{className:"logs-meta-item__error",children:e}):e}var _;function Q({pages:e,currentPageIndex:t,oldestLogsFirst:s,timeZone:i,loading:n,changeTime:o}){const a=e=>`${(0,d.dateTimeFormat)(e,{format:d.systemDateFormats.interval.second,timeZone:i})}`,l=(e,i)=>{if(t===i&&n)return _||(_=(0,T.jsx)(r.Spinner,{}));return`${a(s?e.logsRange.from:e.logsRange.to)} — ${a(s?e.logsRange.to:e.logsRange.from)}`},c=(0,r.useTheme2)(),p=Z(c,n);return(0,T.jsx)(r.CustomScrollbar,{autoHide:!0,children:(0,T.jsx)("div",{className:p.pagesWrapper,"data-testid":"logsNavigationPages",children:(0,T.jsx)("div",{className:p.pagesContainer,children:e.map(((e,s)=>(0,T.jsxs)("div",{"data-testid":`page${s+1}`,className:p.page,onClick:()=>!n&&o({from:e.queryRange.from,to:e.queryRange.to}),children:[(0,T.jsx)("div",{className:(0,y.cx)(p.line,{selectedBg:t===s})}),(0,T.jsx)("div",{className:(0,y.cx)(p.time,{selectedText:t===s}),children:l(e,s)})]},e.queryRange.to)))})})})}q.displayName="LogsMetaRow";const Z=(e,t)=>({pagesWrapper:y.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:y.css`
      display: flex;
      padding: 0;
      flex-direction: column;
    `,page:y.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:y.css`
      width: 3px;
      height: 100%;
      align-items: center;
      background: ${e.colors.text.secondary};
    `,time:y.css`
      width: 60px;
      min-height: 80px;
      font-size: ${e.v1.typography.size.sm};
      padding-left: ${e.spacing(.5)};
      display: flex;
      align-items: center;
    `});var W,U,V;function G({absoluteRange:e,logsSortOrder:t,timeZone:s,loading:n,onChangeTime:o,scrollToTopLogs:a,visibleRange:l,queries:c,clearCache:p,addResultsToCache:u}){const[h,g]=(0,i.useState)([]),[m,f]=(0,i.useState)(0),x=(0,i.useRef)(),v=(0,i.useRef)(),y=(0,i.useRef)(0),b=t===d.LogsSortOrder.Ascending,w=0===m,S=m===h.length-1,j=(0,r.useTheme2)(),C=Y(j,b,n);(0,i.useEffect)((()=>{const s={logsRange:l,queryRange:e};let i=[];if((0,L.isEqual)(v.current,e)&&(0,L.isEqual)(x.current,c)){g((e=>(i=e.filter((e=>!(0,L.isEqual)(s.queryRange,e.queryRange))),i=[...i,s].sort(((e,s)=>I(e,s,t))),i)));const n=i.findIndex((t=>t.queryRange.to===e.to));f(n)}else p(),g([s]),f(0),x.current=c,y.current=e.to-e.from;u()}),[l,e,t,c,p,u]),(0,i.useEffect)((()=>()=>p()),[]);const R=({from:e,to:t})=>{v.current={from:e,to:t},o({from:e,to:t})},I=(e,t,s)=>s===d.LogsSortOrder.Ascending?e.queryRange.to>t.queryRange.to?1:-1:e.queryRange.to>t.queryRange.to?-1:1,k=(0,T.jsx)(r.Button,{"data-testid":"olderLogsButton",className:C.navButton,variant:"secondary",onClick:()=>{R(S?{from:l.from-y.current,to:l.from}:{from:h[m+1].queryRange.from,to:h[m+1].queryRange.to})},disabled:n,children:(0,T.jsxs)("div",{className:C.navButtonContent,children:[n?W||(W=(0,T.jsx)(r.Spinner,{})):(0,T.jsx)(r.Icon,{name:b?"angle-up":"angle-down",size:"lg"}),"Older logs"]})}),z=(0,T.jsx)(r.Button,{"data-testid":"newerLogsButton",className:C.navButton,variant:"secondary",onClick:()=>{w||R({from:h[m-1].queryRange.from,to:h[m-1].queryRange.to})},disabled:n||w,children:(0,T.jsxs)("div",{className:C.navButtonContent,children:[n&&(U||(U=(0,T.jsx)(r.Spinner,{}))),w||n?null:(0,T.jsx)(r.Icon,{name:b?"angle-down":"angle-up",size:"lg"}),w?"Start of range":"Newer logs"]})});return(0,T.jsxs)("div",{className:C.navContainer,children:[b?k:z,(0,T.jsx)(Q,{pages:h,currentPageIndex:m,oldestLogsFirst:b,timeZone:s,loading:n,changeTime:R}),b?z:k,(0,T.jsx)(r.Button,{"data-testid":"scrollToTop",className:C.scrollToTopButton,variant:"secondary",onClick:a,title:"Scroll to top",children:V||(V=(0,T.jsx)(r.Icon,{name:"arrow-up",size:"lg"}))})]})}const K=(0,i.memo)(G),Y=(e,t,s)=>({navContainer:y.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:y.css`
      width: 58px;
      height: 68px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      line-height: 1;
    `,navButtonContent:y.css`
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      width: 100%;
      height: 100%;
      white-space: normal;
    `,scrollToTopButton:y.css`
      width: 40px;
      height: 40px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      margin-top: ${e.spacing(1)};
    `});var J=s("./packages/grafana-runtime/src/index.ts"),X=s("./public/app/core/app_events.ts"),ee=s("./public/app/plugins/panel/timeseries/config.ts"),te=s("./node_modules/react-use/esm/usePrevious.js"),se=s("./public/app/features/dashboard/dashgrid/SeriesVisibilityConfigFactory.ts");function ie({data:e,height:t,width:s,timeZone:n,absoluteRange:o,onChangeTime:a,loadingState:l,annotations:c,onHiddenSeriesChanged:p,splitOpenFn:u,tooltipDisplayMode:h=O.f3.Single}){const g=(0,r.useTheme2)(),[m,x]=(0,i.useState)(!1),[v,y]=(0,i.useState)(1),b=(0,te.Z)(e),w=(0,i.useRef)(0);e&&b&&!(0,d.compareArrayValues)(b,e,d.compareDataFrameStructures)&&w.current++;const S=v+w.current,[j,C]=(0,i.useState)({defaults:{color:{mode:d.FieldColorModeId.PaletteClassic},custom:{drawStyle:O.l8.Line,fillOpacity:0,pointSize:5}},overrides:[]}),R=(0,r.useStyles2)(ne),I={from:(0,d.dateTime)(o.from),to:(0,d.dateTime)(o.to),raw:{from:(0,d.dateTime)(o.from),to:(0,d.dateTime)(o.to)}},k=(0,i.useMemo)((()=>{const t=(0,d.createFieldConfigRegistry)((0,ee.F)(ee.r),"Explore");return(0,d.applyFieldOverrides)({fieldConfig:j,data:e,timeZone:n,replaceVariables:e=>e,theme:g,fieldConfigRegistry:t})}),[j,e,n,g]);(0,i.useEffect)((()=>{if(p){const e=[];k.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))})),p(e)}}),[k,p]);const z=m?k:k.slice(0,20),N={eventBus:X.Z,onSplitOpen:u,onToggleSeriesVisibility(t,s){y((e=>e+1)),C((0,se.N)(t,s,j,e))}};return(0,T.jsxs)(r.PanelContextProvider,{value:N,children:[k.length>20&&!m&&(0,T.jsxs)("div",{className:(0,f.cx)([R.timeSeriesDisclaimer]),children:[(0,T.jsx)(r.Icon,{className:R.disclaimerIcon,name:"exclamation-triangle"}),"Showing only 20 time series. ",(0,T.jsx)("span",{className:(0,f.cx)([R.showAllTimeSeries]),onClick:()=>{w.current++,x(!0)},children:`Show all ${k.length}`})]}),(0,T.jsx)(J.PanelRenderer,{data:{series:z,timeRange:I,structureRev:S,state:l,annotations:c},pluginId:"timeseries",title:"",width:s,height:t,onChangeTimeRange:a,options:{tooltip:{mode:h},legend:{displayMode:O.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(...e){super(...e),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 t=e&&e.target;if(t){const e=t.checked;this.setState({showLabels:e}),u.Z.set(re,e)}})),oe(this,"onChangeTime",(e=>{const t=e&&e.target;if(t){const e=t.checked;this.setState({showTime:e}),u.Z.set(ae,e)}})),oe(this,"onChangewrapLogMessage",(e=>{const t=e&&e.target;if(t){const e=t.checked;this.setState({wrapLogMessage:e}),u.Z.set(le,e)}})),oe(this,"onChangePrettifyLogMessage",(e=>{const t=e&&e.target;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.default)((e=>!!e.some((e=>e.hasUnescapedContent))))),oe(this,"dedupRows",(0,c.default)(((e,t)=>{const s=(0,M.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.default)(((e,t)=>(0,M.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:C,prettifyLogMessage:R,dedupStrategy:I,hiddenLogLevels:k,logsSortOrder:z,isFlipping:N,showDetectedFields:F,forceEscape:D}=this.state,M=ue(v,C),$=t&&t.length>0,E=this.checkUnescapedContent(t),A=this.filterRows(t,k),{dedupedRows:P,dedupCount:B}=this.dedupRows(A,I),H=h?`Scanning ${d.rangeUtil.describeTimeRange(h)}`:"Scanning...";return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)("div",{className:M.infoText,children:"This datasource does not support full-range histograms. The graph is based on the logs seen in the response."}),i&&i.length?(0,T.jsx)(ie,{data:i,height:150,width:e,tooltipDisplayMode:O.f3.Multi,absoluteRange:n||m,timeZone:p,loadingState:a,onChangeTime:f,onHiddenSeriesChanged:this.onToggleLogLevel}):void 0,(0,T.jsxs)("div",{className:M.logOptions,ref:this.topLogsRef,children:[(0,T.jsxs)(r.InlineFieldRow,{children:[(0,T.jsx)(r.InlineField,{label:"Time",transparent:!0,children:(0,T.jsx)(r.InlineSwitch,{value:j,onChange:this.onChangeTime,transparent:!0})}),(0,T.jsx)(r.InlineField,{label:"Unique labels",transparent:!0,children:(0,T.jsx)(r.InlineSwitch,{value:S,onChange:this.onChangeLabels,transparent:!0})}),(0,T.jsx)(r.InlineField,{label:"Wrap lines",transparent:!0,children:(0,T.jsx)(r.InlineSwitch,{value:C,onChange:this.onChangewrapLogMessage,transparent:!0})}),(0,T.jsx)(r.InlineField,{label:"Prettify JSON",transparent:!0,children:(0,T.jsx)(r.InlineSwitch,{value:R,onChange:this.onChangePrettifyLogMessage,transparent:!0})}),(0,T.jsx)(r.InlineField,{label:"Dedup",transparent:!0,children:(0,T.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:M.radioButtons})})]}),(0,T.jsx)(r.Button,{variant:"secondary",disabled:N,title:z===d.LogsSortOrder.Ascending?"Change to newest first":"Change to oldest first","aria-label":"Flip results order",className:M.flipButton,onClick:this.onChangeLogsSortOrder,children:N?"Flipping...":"Flip results order"})]}),(0,T.jsx)(q,{logRows:t,meta:s||[],dedupStrategy:I,dedupCount:B,hasUnescapedContent:E,forceEscape:D,showDetectedFields:F,onEscapeNewlines:this.onEscapeNewlines,clearDetectedFields:this.clearDetectedFields}),(0,T.jsxs)("div",{className:M.logsSection,children:[(0,T.jsx)("div",{className:M.logRows,children:(0,T.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:D,wrapLogMessage:C,prettifyLogMessage:R,timeZone:p,getFieldLinks:x,logsSortOrder:z,showDetectedFields:F,onClickShowDetectedField:this.showDetectedField,onClickHideDetectedField:this.hideDetectedField})}),(0,T.jsx)(K,{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&&!$&&!u&&(0,T.jsxs)("div",{className:M.noData,children:["No logs found.",(0,T.jsx)(r.Button,{size:"xs",fill:"text",onClick:this.onClickScan,children:"Scan for older logs"})]}),u&&(0,T.jsxs)("div",{className:M.noData,children:[(0,T.jsx)("span",{children:H}),(0,T.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};
    `,flipButton: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("./node_modules/react-transition-group/esm/CSSTransition.js");const ge=(0,c.default)((()=>({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,T.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,b.sQ)({exploreId:e,isPaused:!0}))}),[e,t]),o=(0,i.useCallback)((()=>{t((0,b.sQ)({exploreId:e,isPaused:!1}))}),[e,t]),a=(0,i.useCallback)((()=>{s(),t((0,w.oz)(e,r.RefreshPicker.offOption.value)),t((0,b.aA)(e))}),[e,t,s]),l=(0,i.useCallback)((()=>{t((0,w.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(...e){super(...e),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 null!=s&&s.getLogRowContext?s.getLogRowContext(e,t):[]})),ve(this,"showContextToggle",(e=>{const{datasourceInstance:t}=this.props;return!(null==t||!t.showContextToggle)&&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:f,isLive:x,exploreId:v,addResultsToCache:b,clearCache:w}=this.props;if(!s)return null;const S=y.css`
      & > div {
        overflow: visible;
        & > div {
          overflow: visible;
        }
      }
    `;return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(me,{visible:x,children:(0,T.jsx)(r.Collapse,{label:"Logs",loading:!1,isOpen:!0,children:(0,T.jsx)(fe,{exploreId:v,children:e=>(0,T.jsx)(D,{logRows:s,timeZone:u,stopLive:e.stop,isPaused:this.props.isPaused,onPause:e.pause,onResume:e.resume})})})}),(0,T.jsx)(me,{visible:!x,children:(0,T.jsx)(r.Collapse,{label:"Logs",loading:e,isOpen:!0,className:S,children:(0,T.jsx)(pe,{logRows:s,logsMeta:i,logsSeries:n,logsQueries:o,width:f,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(v),clearCache:()=>w(v)})})})]})}}const be={updateTimeRange:w.cD,splitOpen:a.bW,addResultsToCache:b.K8,clearCache:b.LK},we=(0,n.connect)((function(e,{exploreId:t}){const s=e.explore[t],{logsResult:i,loading:n,scanning:o,datasourceInstance:r,isLive:a,isPaused:l,range:c,absoluteRange:d}=s,p=(0,m.Z)(e.user);return{loading:n,logRows:null==i?void 0:i.rows,logsMeta:null==i?void 0:i.meta,logsSeries:null==i?void 0:i.series,logsQueries:null==i?void 0:i.queries,visibleRange:null==i?void 0:i.visibleRange,scanning:o,timeZone:p,datasourceInstance:r,isLive:a,isPaused:l,range:c,absoluteRange:d}}),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("./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=({exploreId:e})=>{const t=(0,n.useDispatch)(),{getQueries:s,getDatasourceInstanceSettings:o,getQueryResponse:r,getHistory:a,getEventBridge:l}=(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.name)}))}})(e)),[e]),c=(0,n.useSelector)(s),p=(0,n.useSelector)(o),u=(0,n.useSelector)(r),h=(0,n.useSelector)(a),g=(0,n.useSelector)(l),m=(0,i.useCallback)((()=>{t((0,b.aA)(e))}),[t,e]),f=(0,i.useCallback)((s=>{t((0,b.PM)({queries:s,exploreId:e})),s.length<c.length&&m()}),[t,e,m,c]),x=(0,i.useCallback)((e=>{f([...c,Object.assign({},e,{refId:(0,je.Hs)(c)})])}),[f,c]);return(0,T.jsx)(Ce.l,{dsSettings:p,queries:c,onQueriesChange:f,onAddQuery:x,onRunQueries:m,data:u,app:d.CoreApp.Explore,history:h,eventBus:g})};var ze=s("./public/app/core/config.ts"),Ne=s("./public/app/core/constants.ts");const Fe={splitOpen:a.bW},De=(0,n.connect)((function(e,{exploreId:t}){const s=e.explore[t],{loading:i,tableResult:n,range:o}=s;return{loading:!(n&&n.length>0)&&i,tableResult:n,range:o}}),Fe);class Le 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(){const{loading:e,onCellFilterAdded:t,tableResult:s,width:i,splitOpen:n,range:o,ariaLabel:a}=this.props,l=this.getTableHeight(),c=i-2*ze.vc.theme.panelPadding-Ne.QO,d=null==s?void 0:s.length;if(s&&s.length)for(const e of s.fields)e.getLinks=t=>(0,xe.a)({field:e,rowIndex:t.valueRowIndex,splitOpenFn:n,range:o});return(0,T.jsx)(r.Collapse,{label:"Table",loading:e,isOpen:!0,children:d?(0,T.jsx)(r.Table,{ariaLabel:a,data:s,width:c,height:l,onCellFilterAdded:t}):(0,T.jsx)(P,{metaItems:[{value:"0 series returned"}]})})}}const Oe=De(Le);var Me=s("./public/app/types/events.ts"),$e=s("./public/app/store/store.ts"),Ee=s("./public/app/core/actions/index.ts"),Ae=s("./public/app/core/copy/appNotification.ts");const Pe=(0,r.stylesFactory)((e=>({container:f.css`
      padding-left: ${e.spacing.sm};
      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};
    `}))),Be=[{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:l}=e,c=(0,r.useTheme)(),d=Pe(c),p=Be.find((e=>e.value===t));return(0,T.jsxs)("div",{className:d.container,children:[(0,T.jsx)(r.Field,{label:"History time span",description:"Select the period of time for which Grafana will save your query history",className:"space-between",children:(0,T.jsx)("div",{className:d.input,children:(0,T.jsx)(r.Select,{menuShouldPortal:!0,value:p,options:Be,onChange:n})})}),(0,T.jsx)(r.Field,{label:"Default active tab",description:" ",className:"space-between",children:(0,T.jsxs)("div",{className:d.switch,children:[(0,T.jsx)(r.Switch,{value:s,onChange:o}),(0,T.jsx)("div",{className:d.label,children:"Change the default active tab from “Query history” to “Starred”"})]})}),(0,T.jsx)(r.Field,{label:"Data source behaviour",description:" ",className:"space-between",children:(0,T.jsxs)("div",{className:d.switch,children:[(0,T.jsx)(r.Switch,{value:i,onChange:a}),(0,T.jsx)("div",{className:d.label,children:"Only show queries for data source currently active in Explore"})]})}),(0,T.jsx)("div",{className:f.css`
          font-weight: ${c.typography.weight.bold};
        `,children:"Clear query history"}),(0,T.jsx)("div",{className:f.css`
          margin-bottom: ${c.spacing.sm};
        `,children:"Delete all of your query history, permanently."}),(0,T.jsx)(r.Button,{variant:"destructive",onClick:()=>{X.Z.publish(new Me.VJ({title:"Delete",text:"Are you sure you want to permanently delete your query history?",yesText:"Delete",icon:"trash-alt",onConfirm:()=>{l(),(0,$e.WI)((0,Ee.$l)((0,Ae.AT)("Query history deleted")))}}))},children:"Clear query history"})]})}var He=s("./public/app/core/utils/shortLinks.ts"),_e=s("./public/app/features/explore/state/history.ts"),Qe=s("./public/app/features/explore/state/datasource.ts");const Ze={changeDatasource:Qe.zU,updateRichHistory:_e.u5,setQueries:b.KO},We=(0,n.connect)((function(e,{exploreId:t}){const s=e.explore,{datasourceInstance:i}=s[t];return{exploreId:t,datasourceInstance:i}}),Ze),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,J.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)},C=()=>{m(!1),v(s.comment)},R=(0,T.jsxs)("div",{className:S.updateCommentContainer,"aria-label":x?"Update comment form":"Add comment form",children:[(0,T.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,T.jsxs)("div",{className:S.commentButtonRow,children:[(0,T.jsx)(r.Button,{onClick:j,"aria-label":"Submit button",children:"Save comment"}),(0,T.jsx)(r.Button,{variant:"secondary",onClick:C,children:"Cancel"})]})]}),I=(0,T.jsxs)("div",{className:S.queryActionButtons,children:[(0,T.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,T.jsx)(r.IconButton,{name:"copy",onClick:()=>{const e=s.queries.map((e=>(0,l.OH)(e,y))).join("\n");(0,g.n9)(e),(0,$e.WI)((0,Ee.$l)((0,Ae.AT)("Query copied to clipboard")))},title:"Copy query to clipboard"}),!o&&(0,T.jsx)(r.IconButton,{name:"share-alt",onClick:async()=>{const e=(0,l.t2)(s);await(0,He.L)(e)},title:"Copy shortened link to clipboard"}),(0,T.jsx)(r.IconButton,{name:"trash-alt",title:"Delete query",onClick:()=>{s.starred?X.Z.publish(new Me.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,$e.WI)((0,Ee.$l)((0,Ae.AT)("Query deleted")))}})):(a(s.ts,"delete"),(0,$e.WI)((0,Ee.$l)((0,Ae.AT)("Query deleted"))))}}),(0,T.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,T.jsxs)("div",{className:S.queryCard,onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||e.ctrlKey)&&j(),"Escape"===e.key&&C()},children:[(0,T.jsxs)("div",{className:S.cardRow,children:[(0,T.jsxs)("div",{className:S.datasourceContainer,children:[(0,T.jsx)("img",{src:n,"aria-label":"Data source icon"}),(0,T.jsx)("div",{"aria-label":"Data source name",children:o?"Data source does not exist anymore":s.datasourceName})]}),I]}),(0,T.jsxs)("div",{className:(0,f.cx)(S.cardRow),children:[(0,T.jsxs)("div",{className:S.queryContainer,children:[s.queries.map(((e,t)=>{const s=(0,l.OH)(e,y);return(0,T.jsx)("div",{"aria-label":"Query text",className:S.queryRow,children:s},`${e}-${t}`)})),!h&&s.comment&&(0,T.jsx)("div",{"aria-label":"Query comment",className:S.comment,children:s.comment}),h&&R]}),!h&&(0,T.jsx)("div",{className:S.runButton,children:(0,T.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("./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-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};
      }
    `,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),j=(0,L.uniqBy)(n,"datasourceName").map((e=>e.datasourceName)),C=(0,l.DR)(j);(0,Ke.Z)((()=>{b(x)}),300,[x]),(0,i.useEffect)((()=>{f((0,l.ZX)(n,a,t.map((e=>e.value)),y,h))}),[h,n,a,t,y]);const R=(0,l.k4)(m,a);return(0,T.jsxs)("div",{className:S.container,children:[(0,T.jsx)("div",{className:S.containerSlider,children:(0,T.jsxs)("div",{className:S.slider,children:[Ge||(Ge=(0,T.jsx)("div",{className:"label-slider",children:"Filter history"})),(0,T.jsx)("div",{className:"label-slider",children:(0,l.bQ)(h[0])}),(0,T.jsx)("div",{className:"slider",children:(0,T.jsx)(r.RangeSlider,{tooltipAlwaysVisible:!1,min:0,max:d,value:h,orientation:"vertical",formatTooltipResult:l.bQ,reverse:!0,onAfterChange:g})}),(0,T.jsx)("div",{className:"label-slider",children:(0,l.bQ)(h[1])})]})}),(0,T.jsxs)("div",{className:S.containerContent,children:[(0,T.jsxs)("div",{className:S.selectors,children:[!c&&(0,T.jsx)("div",{"aria-label":"Filter datasources",className:S.multiselect,children:(0,T.jsx)(r.MultiSelect,{menuShouldPortal:!0,options:C,value:t,placeholder:"Filter queries for data sources(s)",onChange:s})}),(0,T.jsx)("div",{className:S.filterInput,children:(0,T.jsx)(r.FilterInput,{placeholder:"Search queries",value:x,onChange:e=>{v(e)}})}),(0,T.jsx)("div",{"aria-label":"Sort queries",className:S.sort,children:(0,T.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,T.jsxs)("div",{children:[(0,T.jsxs)("div",{className:S.heading,children:[e," ",(0,T.jsxs)("span",{className:S.queries,children:[R[e].length," queries"]})]}),R[e].map((e=>{const t=C.findIndex((t=>t.label===e.datasourceName));return(0,T.jsx)(Ve,{query:e,exploreId:p,dsImg:C[t].imgUrl,isRemoved:C[t].isRemoved},e.ts)}))]},e))),(0,T.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),y=(0,L.uniqBy)(n,"datasourceName").map((e=>e.datasourceName)),b=(0,l.DR)(y);return(0,Ke.Z)((()=>{f(h)}),300,[h]),(0,i.useEffect)((()=>{const e=n.filter((e=>!0===e.starred));u((0,l.ZX)(e,a,t.map((e=>e.value)),m))}),[n,a,t,m]),(0,T.jsx)("div",{className:v.container,children:(0,T.jsxs)("div",{className:v.containerContent,children:[(0,T.jsxs)("div",{className:v.selectors,children:[!c&&(0,T.jsx)("div",{"aria-label":"Filter datasources",className:v.multiselect,children:(0,T.jsx)(r.MultiSelect,{menuShouldPortal:!0,options:b,value:t,placeholder:"Filter queries for specific data sources(s)",onChange:s})}),(0,T.jsx)("div",{className:v.filterInput,children:(0,T.jsx)(r.FilterInput,{placeholder:"Search queries",value:h,onChange:e=>{g(e)}})}),(0,T.jsx)("div",{"aria-label":"Sort queries",className:v.sort,children:(0,T.jsx)(r.Select,{menuShouldPortal:!0,options:it,value:it.filter((e=>e.value===a)),placeholder:"Sort queries by",onChange:e=>o(e.value)})})]}),p.map((e=>{const t=b.findIndex((t=>t.label===e.datasourceName));return(0,T.jsx)(Ve,{query:e,exploreId:d,dsImg:b[t].imgUrl,isRemoved:b[t].isRemoved},e.ts)})),(0,T.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,T.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,T.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,T.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,T.jsx)(r.TabbedContainer,{tabs:p,onClose:c,defaultTab:d,closeIconTooltip:"Close query history"})}}const ot=(0,r.withTheme)(nt);var rt=s("./node_modules/re-resizable/lib/index.js");const at=f.keyframes`
  0% {
    transform: translateY(400px);
  }

  100% {
    transform: translateY(0px);
  }
`,lt=(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 ${at};
    `,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 ct(e){const{width:t,children:s,onResize:i}=e,n=(0,r.useTheme2)(),o=lt(n),a=`${t+31.5}px`;return(0,T.jsx)(rt.Resizable,{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 dt={deleteRichHistory:_e.ik};const pt=(0,n.connect)((function(e,{exploreId:t}){const s=e.explore,i=s[t],{datasourceInstance:n}=i,o=u.Z.getBool(l.hO.starredTabAsFirstTab,!1)?st.Starred:st.RichHistory,{richHistory:r}=s;return{richHistory:r,firstTab:o,activeDatasourceInstance:null==n?void 0:n.name}}),dt)((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,T.jsx)(ct,{width:o,onResize:(e,t,i)=>{s(Number(i.style.height.slice(0,-2)))},children:(0,T.jsx)(ot,{richHistory:n,firstTab:r,activeDatasourceInstance:a,exploreId:l,deleteRichHistory:c,onClose:d,height:t})})}));var ut=s("./public/app/features/inspector/InspectJSONTab.tsx"),ht=s("./public/app/features/inspector/QueryInspector.tsx"),gt=s("./public/app/features/inspector/InspectStatsTab.tsx"),mt=s("./public/app/features/inspector/InspectDataTab.tsx"),ft=s("./public/app/features/inspector/InspectErrorTab.tsx");const xt={runQueries:b.aA},vt=(0,n.connect)((function(e,{exploreId:t}){const s=e.explore[t],{loading:i,queryResponse:n}=s;return{loading:i,queryResponse:n}}),xt)((function(e){var t;const{loading:s,width:i,onClose:n,queryResponse:o}=e,a=(null==o?void 0:o.series)||[],l=null==o?void 0:o.error,c={label:"Stats",value:"stats",icon:"chart-line",content:(0,T.jsx)(gt.f,{data:o,timeZone:null==o||null===(t=o.request)||void 0===t?void 0:t.timezone})},d={label:"JSON",value:"json",icon:"brackets-curly",content:(0,T.jsx)(ut.W,{data:o,onClose:n})},p={label:"Data",value:"data",icon:"database",content:(0,T.jsx)(mt.E,{data:a,isLoading:s,options:{withTransforms:!1,withFieldConfig:!1}})},u=[c,{label:"Query",value:"query",icon:"info-circle",content:(0,T.jsx)(ht.D,{data:a,onRefreshQuery:()=>e.runQueries(e.exploreId)})},d,p];if(l){const e={label:"Error",value:"error",icon:"exclamation-triangle",content:(0,T.jsx)(ft.l,{error:l})};u.push(e)}return(0,T.jsx)(ct,{width:i,onResize:()=>{},children:(0,T.jsx)(r.TabbedContainer,{tabs:u,onClose:n,closeIconTooltip:"Close query inspector"})})}));var yt=s("./node_modules/classnames/index.js"),bt=s.n(yt),wt=s("./public/app/features/profile/state/reducers.ts");function St(e){const{onClick:t,isSynced:s}=e;return(0,T.jsx)(r.Tooltip,{content:()=>{const{isSynced:t}=e,s=t?"Unsync all views":"Sync all views to this time range";return(0,T.jsx)(T.Fragment,{children:s})},placement:"bottom",children:(0,T.jsx)(r.ToolbarButton,{icon:"link",variant:s?"active":"default","aria-label":s?"Synced times":"Unsynced times",onClick:t})})}var jt=s("./public/app/core/components/TimePicker/TimePickerWithHistory.tsx"),Ct=s("./public/app/core/utils/timePicker.ts");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}class Rt extends i.Component{constructor(...e){super(...e),Tt(this,"onMoveTimePicker",(e=>{const{range:t,onChangeTime:s,timeZone:i}=this.props,{from:n,to:o}=(0,Ct.e)(e,t);s({from:(0,d.dateTimeForTimeZone)(i,n),to:(0,d.dateTimeForTimeZone)(i,o)})})),Tt(this,"onMoveForward",(()=>this.onMoveTimePicker(1))),Tt(this,"onMoveBack",(()=>this.onMoveTimePicker(-1))),Tt(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})})),Tt(this,"onZoom",(()=>{const{range:e,onChangeTime:t,timeZone:s}=this.props,{from:i,to:n}=(0,Ct.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,T.jsx)(St,{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,T.jsx)(jt.a,Object.assign({},d,{timeSyncButton:c,isSynced:n,onChange:this.onChangeTimePicker,onChangeTimeZone:a,onChangeFiscalYearStartMonth:l}))}}function It(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,T.jsxs)(r.ButtonGroup,{children:[(0,T.jsx)(r.Tooltip,{content:n&&!o?(0,T.jsx)(T.Fragment,{children:"Pause the live stream"}):(0,T.jsx)(T.Fragment,{children:"Start live stream your logs"}),placement:"bottom",children:(0,T.jsx)(r.ToolbarButton,{iconOnly:l,variant:c,icon:!n||o?"play":"pause",onClick:d,children:n&&o?"Paused":"Live"})}),(0,T.jsx)(he.Z,{mountOnEnter:!0,unmountOnExit:!0,timeout:100,in:n,classNames:{enter:kt.stopButtonEnter,enterActive:kt.stopButtonEnterActive,exit:kt.stopButtonExit,exitActive:kt.stopButtonExitActive},children:(0,T.jsx)(r.Tooltip,{content:(0,T.jsx)(T.Fragment,{children:"Stop and exit the live stream"}),placement:"bottom",children:(0,T.jsx)(r.ToolbarButton,{variant:c,onClick:a,icon:"square-shape"})})})]})}const kt={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 zt=s("./public/app/features/dashboard/services/TimeSrv.ts");function Nt(e){const{isSmall:t,loading:s,onRun:i,onChangeRefreshInterval:n,refreshInterval:o,showDropdown:a,isLive:l}=e,c=(0,zt.$t)().getValidIntervals(r.defaultIntervals);let d;return l?null:(t||(d=s?"Cancel":"Run query"),(0,T.jsx)(r.RefreshPicker,{onIntervalChanged:n,value:o,isLoading:s,text:d,intervals:c,isLive:l,onRefresh:()=>i(s),noIntervalPicker:!a,primary:!0}))}var Ft,Dt=s("./public/app/core/utils/kbn.ts"),Lt=s("./public/app/features/dashboard/services/DashboardSrv.ts"),Ot=s("./public/app/features/dashboard/state/reducers.ts"),Mt=s("./public/app/core/services/context_srv.ts");const $t={setDashboardQueriesToUpdateOnLoad:Ot.gq},Et=(0,n.connect)((function(e,{exploreId:t}){const s=e.explore,i=Ie(e),{datasourceInstance:n,queries:o,originPanelId:r}=s[t],a=["Editor","Admin"];return ze.ZP.viewersCanEdit&&a.push("Viewer"),{exploreId:t,datasourceInstance:n,queries:o,originPanelId:r,splitted:i,canEdit:a.some((e=>Mt.Vt.hasRole(e)))}}),$t)((({originPanelId:e,setDashboardQueriesToUpdateOnLoad:t,queries:s,splitted:i,canEdit:n})=>{const o=e&&Number.isInteger(e);if(i||!o)return null;const a=e=>e.map((e=>(delete e.context,delete e.key,e))),l=async({withChanges:i=!1}={})=>{const n=(0,Lt.h4)().getCurrent();if(!n)return;const o=Dt.Z.slugifyForUrl(n.title);i&&t({panelId:e,queries:a(s)});const r={};i||n.panelInEdit?r.editPanel=e:n.panelInView&&(r.viewPanel=e),J.locationService.push(d.urlUtil.renderUrl(`/d/${n.uid}/:${o}`,r))};return(0,T.jsxs)(r.ButtonGroup,{children:[(0,T.jsx)(r.Tooltip,{content:"Return to panel",placement:"bottom",children:(0,T.jsx)(r.ToolbarButton,{"data-testid":"returnButton",title:"Return to panel",onClick:()=>l(),children:Ft||(Ft=(0,T.jsx)(r.Icon,{name:"arrow-left"}))})}),n&&(0,T.jsx)(r.ButtonSelect,{"data-testid":"returnButtonWithChanges",options:[{label:"Return to panel with changes",value:""}],onChange:()=>l({withChanges:!0})})]})}));function At(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class Pt extends i.PureComponent{constructor(...e){super(...e),At(this,"onChangeDatasource",(async e=>{this.props.changeDatasource(this.props.exploreId,e.uid,{importQueries:!0})})),At(this,"onClearAll",(()=>{this.props.clearAll(this.props.exploreId)})),At(this,"onRunQuery",((e=!1)=>{const{runQueries:t,cancelQueries:s,exploreId:i}=this.props;return e?s(i):t(i)})),At(this,"onChangeRefreshInterval",(e=>{const{changeRefreshInterval:t,exploreId:s}=this.props;t(s,e)})),At(this,"onChangeTimeSync",(()=>{const{syncTimes:e,exploreId:t}=this.props;e(t)}))}render(){const{datasourceMissing:e,closeSplit:t,exploreId:s,loading:i,range:n,timeZone:o,fiscalYearStartMonth:a,splitted:l,syncedTimes:c,refreshInterval:d,onChangeTime:p,split:u,hasLiveOption:h,isLive:g,isPaused:m,containerWidth:x,onChangeTimeZone:v,onChangeFiscalYearStartMonth:y}=this.props,b=(l?x<700:x<800)||!1,w=l||x<1210;return(0,T.jsxs)("div",{className:l?"explore-toolbar splitted":"explore-toolbar",children:[(0,T.jsx)("div",{className:"explore-toolbar-item",children:(0,T.jsxs)("div",{className:"explore-toolbar-header",children:[(0,T.jsx)("div",{className:"explore-toolbar-header-title",children:"left"===s&&(0,T.jsxs)("span",{className:"navbar-page-btn",children:[(0,T.jsx)(r.Icon,{name:"compass",size:"lg",className:f.css`
                      margin-right: 6px;
                      margin-bottom: 3px;
                    `}),"Explore"]})}),l&&(0,T.jsx)(r.IconButton,{title:"Close split pane",className:"explore-toolbar-header-close",onClick:()=>t(s),name:"times"})]})}),(0,T.jsx)("div",{className:"explore-toolbar-item",children:(0,T.jsxs)("div",{className:"explore-toolbar-content",children:[e?null:(0,T.jsx)("div",{className:"explore-toolbar-content-item",children:(0,T.jsx)("div",{className:bt()("explore-ds-picker",b?"explore-ds-picker--small":""),children:(0,T.jsx)(J.DataSourcePicker,{onChange:this.onChangeDatasource,current:this.props.datasourceName,hideTextValue:b})})}),(0,T.jsxs)(r.ToolbarButtonRow,{children:[(0,T.jsx)(Et,{exploreId:s}),"left"!==s||l?null:(0,T.jsx)(r.ToolbarButton,{iconOnly:l,title:"Split",onClick:()=>u(),icon:"columns",disabled:g,children:"Split"}),(0,T.jsx)(r.Tooltip,{content:"Copy shortened link to the executed query",placement:"bottom",children:(0,T.jsx)(r.ToolbarButton,{icon:"share-alt",onClick:()=>(0,He.L)(window.location.href),"aria-label":"Copy shortened link to the executed query"})}),!g&&(0,T.jsx)(Rt,{exploreId:s,range:n,timeZone:o,fiscalYearStartMonth:a,onChangeTime:p,splitted:l,syncedTimes:c,onChangeTimeSync:this.onChangeTimeSync,hideText:w,onChangeTimeZone:v,onChangeFiscalYearStartMonth:y}),!g&&(0,T.jsx)(r.ToolbarButton,{title:"Clear all",onClick:this.onClearAll,icon:"trash-alt",iconOnly:l,children:"Clear all"}),(0,T.jsx)(Nt,{refreshInterval:d,onChangeRefreshInterval:this.onChangeRefreshInterval,isSmall:l||w,isLive:g,loading:i||g&&!m,onRun:this.onRunQuery,showDropdown:!g}),d&&(0,T.jsx)(r.SetInterval,{func:this.onRunQuery,interval:d,loading:i}),h&&(0,T.jsx)(fe,{exploreId:s,children:e=>(0,T.jsx)(It,{splitted:l,isLive:g,isPaused:m,start:e.start,pause:e.pause,resume:e.resume,stop:e.stop})})]})]})})]})}}const Bt={changeDatasource:Qe.zU,changeRefreshInterval:w.oz,clearAll:b.It,cancelQueries:b.ci,runQueries:b.aA,closeSplit:a.YV,split:a.bW,syncTimes:w.mG,onChangeTimeZone:wt.YT,onChangeFiscalYearStartMonth:wt.rf},qt=(0,n.connect)(((e,{exploreId:t})=>{var s;const i=e.explore.syncedTimes,n=e.explore[t],{datasourceInstance:o,datasourceMissing:r,range:a,refreshInterval:l,loading:c,isLive:d,isPaused:p,containerWidth:u}=n,h=!(null==o||null===(s=o.meta)||void 0===s||!s.streaming);return{datasourceMissing:r,datasourceName:null==o?void 0:o.name,loading:c,range:a,timeZone:(0,m.Z)(e.user),fiscalYearStartMonth:(0,m.i)(e.user),splitted:Ie(e),refreshInterval:l,hasLiveOption:h,isLive:d,isPaused:p,syncedTimes:i,containerWidth:u}}),Bt)(Pt);var Ht,_t,Qt=s("./public/app/core/core.ts");const Zt=()=>{const e=(0,r.useTheme2)(),t=Qt.Vt.hasPermission(Re.bW.DataSourcesCreate)&&Qt.Vt.hasPermission(Re.bW.DataSourcesWrite),s=(0,T.jsxs)(T.Fragment,{children:[Ht||(Ht=(0,T.jsx)(r.Icon,{name:"rocket"})),(0,T.jsx)(T.Fragment,{children:" ProTip: You can also define data sources through configuration files. "}),_t||(_t=(0,T.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,T.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,T.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 Wt(e){const t=(e=>({containerMargin:f.css`
      margin-top: ${e.spacing(2)};
    `}))((0,r.useTheme2)());return(0,T.jsx)("div",{className:t.containerMargin,children:(0,T.jsxs)(r.HorizontalGroup,{children:[!e.addQueryRowButtonHidden&&(0,T.jsx)(r.Button,{variant:"secondary","aria-label":"Add row button",onClick:e.onClickAddQueryRowButton,disabled:e.addQueryRowButtonDisabled,icon:"plus",children:"Add query"}),(0,T.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,T.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 Ut,Vt=s("./packages/grafana-ui/src/components/Table/types.ts"),Gt=s("./node_modules/react-use/esm/useToggle.js"),Kt=s("./public/app/plugins/panel/nodeGraph/NodeGraph.tsx"),Yt=s("./public/app/plugins/panel/nodeGraph/useCategorizeFrames.ts");const Jt=e=>({warningText:f.css`
    label: warningText;
    font-size: ${e.typography.bodySmall.fontSize};
    color: ${e.colors.text.secondary};
  `});const Xt={splitOpen:a.bW},es=(0,n.connect)((function(e,{exploreId:t}){return{range:e.explore[t].range}}),Xt)((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)(Jt),p=(0,d.applyFieldOverrides)({fieldConfig:{defaults:{},overrides:[]},data:s,replaceVariables:e=>e,theme:l}),{nodes:u}=(0,Yt.Y)(p),[h,g]=(0,Gt.Z)(!1),m=o&&(null===(t=u[0])||void 0===t?void 0:t.length)>1e3?(0,T.jsxs)("span",{className:c.warningText,children:[" (",u[0].length," nodes, can be slow to load)"]}):null;return(0,T.jsx)(r.Collapse,{label:(0,T.jsxs)("span",{children:["Node graph",m," ",Ut||(Ut=(0,T.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,T.jsx)("div",{style:{height:o?500:600},children:(0,T.jsx)(Kt.E,{dataFrames:p,getLinks:a})})})}));var ts=s("./node_modules/react-transition-group/esm/Transition.js");const ss=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,T.jsx)(ts.ZP,{in:e.in,timeout:e.duration,unmountOnExit:e.unmountOnExit||!1,onExited:e.onExited,children:i=>(0,T.jsx)("div",{style:Object.assign({},t,s[i]),children:e.children})})},is=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,T.jsx)(ss,{in:n,duration:o,children:(0,T.jsx)(r.Alert,{severity:"error",title:a,className:c,children:l})})};function ns(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,T.jsx)(is,{queryError:s})}var os,rs=s("./packages/jaeger-ui-components/src/index.ts");const as=["cluster","hostname","namespace","pod"];function ls(e,t){const{tags:s,filterByTraceID:i,filterBySpanID:n}=t,o=null!=s&&s.length?s:as;let r=`{${[...e.process.tags,...e.tags].reduce(((e,t)=>(o.includes(t.key)&&e.push(`${t.key}="${t.value}"`),e)),[]).join(", ")}}`;return i&&e.traceID&&(r+=` |="${e.traceID}"`),n&&e.spanID&&(r+=` |="${e.spanID}"`),r}function cs(e,t){const s=null!=t&&t.spanStartTimeShift?Math.floor(e.startTime/1e3+d.rangeUtil.intervalToMs(t.spanStartTimeShift)):Math.floor(e.startTime/1e3),i=(0,d.dateTime)(s),n=(e.startTime+e.duration)/1e3;let o=null!=t&&t.spanEndTimeShift?Math.floor(n+d.rangeUtil.intervalToMs(t.spanEndTimeShift)):Math.floor(n);s===o&&o++;const r=(0,d.dateTime)(o);return{from:i,to:r,raw:{from:i,to:r}}}const ds={Popover({children:e,content:t,overlayClassName:s}){const n=(0,i.useRef)(null);return(0,T.jsx)(r.PopoverController,{content:t,hideAfter:300,children:(t,o,a)=>(0,T.jsxs)(T.Fragment,{children:[n.current&&(0,T.jsx)(r.Popover,Object.assign({},a,{referenceElement:n.current,wrapperClassName:s,onMouseLeave:o,onMouseEnter:t})),i.cloneElement(e,{ref:n,onMouseEnter:t,onMouseLeave:o})]})})},Tooltip:({children:e,title:t})=>(0,T.jsx)(r.Tooltip,{content:t,children:e}),Icon:()=>null,Dropdown:()=>null,Menu:()=>null,MenuItem:()=>null,Button:({onClick:e,children:t,className:s})=>(0,T.jsx)(r.Button,{variant:"secondary",onClick:e,className:s,children:t}),Divider:function({className:e}){const t=ps((0,r.useTheme)());return(0,T.jsx)("div",{style:{},className:bt()(t.Divider,e)})},Input:e=>(0,T.jsx)(r.Input,Object.assign({},e)),InputGroup:({children:e,className:t,style:s})=>(0,T.jsx)("span",{className:t,style:s,children:e})},ps=(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 us(e,t){return e.filter((e=>e.hasChildren)).length===t.size}function hs(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 gs(){return{}}function ms(e){var t,s,o;const{expandOne:a,collapseOne:l,childrenToggle:c,collapseAll:p,childrenHiddenIDs:u,expandAll:h}=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(us(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(us(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:g,toggleDetail:f,detailLogItemToggle:x,detailLogsToggle:v,detailProcessToggle:y,detailReferencesToggle:b,detailTagsToggle:w,detailWarningsToggle:S,detailStackTracesToggle:j}=function(){const[e,t]=(0,i.useState)(new Map),s=(0,i.useCallback)((function(s){const i=new Map(e);i.has(s)?i.delete(s):i.set(s,new rs.kt),t(i)}),[e]),n=(0,i.useCallback)((function(s,i){const n=e.get(s);if(!n)return;const o=n.toggleLogItem(i),r=new Map(e);return r.set(s,o),t(r)}),[e]);return{detailStates:e,toggleDetail:s,detailLogItemToggle:n,detailLogsToggle:(0,i.useCallback)((s=>hs("logs",e,t)(s)),[e]),detailWarningsToggle:(0,i.useCallback)((s=>hs("warnings",e,t)(s)),[e]),detailStackTracesToggle:(0,i.useCallback)((s=>hs("stackTraces",e,t)(s)),[e]),detailReferencesToggle:(0,i.useCallback)((s=>hs("references",e,t)(s)),[e]),detailProcessToggle:(0,i.useCallback)((s=>hs("process",e,t)(s)),[e]),detailTagsToggle:(0,i.useCallback)((s=>hs("tags",e,t)(s)),[e])}}(),{removeHoverIndentGuideId:C,addHoverIndentGuideId:R,hoverIndentGuideIds:I}=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:k,updateViewRangeTime:z,updateNextViewRangeTime:N}=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})}))}),[]);return{viewRange:e,updateViewRangeTime:(0,i.useCallback)((function(e,s){const i={current:[e,s]};t((e=>Object.assign({},e,{time:i})))}),[]),updateNextViewRangeTime:s}}(),[F,D]=(0,i.useState)(.25),[L,O]=(0,i.useState)(!1),M=(0,i.useMemo)((()=>function(e){const t=e[0];if(!t)return null;let s=1===t.fields.length?t.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.serviceName]||(s[i.serviceName]={serviceName:i.serviceName,tags:i.serviceTags})}return{traceID:t.get(0).traceID,processes:s,spans:t.toArray().map((e=>{var t;return Object.assign({},e,{duration:1e3*e.duration,startTime:1e3*e.startTime,processID:e.serviceName,flags:0,references:e.parentSpanID?[{refType:"CHILD_OF",spanID:e.parentSpanID,traceID:e.traceID}]:void 0,logs:(null===(t=e.logs)||void 0===t?void 0:t.map((e=>Object.assign({},e,{timestamp:1e3*e.timestamp}))))||[]})}))}}(t);return(0,rs.R1)(s)}(e.dataFrames)),[e.dataFrames]),{search:$,setSearch:E,spanFindMatches:A}=function(e){const[t,s]=(0,i.useState)(""),n=(0,i.useMemo)((()=>t&&e?(0,rs.rZ)(t,e):void 0),[t,e]);return{search:t,setSearch:s,spanFindMatches:n}}(null==M?void 0:M.spans),P=(0,n.useSelector)((t=>{var s,i;return null===(s=t.explore[e.exploreId])||void 0===s||null===(i=s.datasourceInstance)||void 0===i?void 0:i.name})),B=null===(t=(0,Se.ak)().getInstanceSettings(P))||void 0===t||null===(s=t.jsonData)||void 0===s?void 0:s.tracesToLogs,q=(0,n.useSelector)((e=>(0,m.Z)(e.user))),H=(0,r.useTheme)(),_=(0,i.useMemo)((()=>({type:H.isDark?rs.f8.Dark:rs.f8.Light,servicesColorPalette:r.colors,components:{TraceName:{fontSize:H.typography.size.lg}}})),[H]),Q=(0,i.useMemo)((()=>({childrenHiddenIDs:u,detailStates:g,hoverIndentGuideIds:I,shouldScrollToFirstUiFindMatch:!1,spanNameColumnWidth:F,traceID:null==M?void 0:M.traceID})),[u,g,I,F,null==M?void 0:M.traceID]),Z=(0,i.useMemo)((()=>function(e,t){if(null==t||!t.datasourceUid)return;const s=(0,Se.ak)().getInstanceSettings(t.datasourceUid);return s?function(i){const n={title:s.name,url:"",internal:{datasourceUid:s.uid,datasourceName:s.name,query:{expr:ls(i,t),refId:""}}},o=(0,d.mapInternalLinkToExplore)({link:n,internalLink:n.internal,scopedVars:{},range:cs(i,t),field:{},onClickFn:e,replaceVariables:(0,J.getTemplateSrv)().replace.bind((0,J.getTemplateSrv)())});return{href:o.href,onClick:o.onClick,content:os||(os=(0,T.jsx)(r.Icon,{name:"gf-logs",title:"Explore the logs for this in split view"}))}}:void 0}(e.splitOpenFn,B)),[e.splitOpenFn,B]),W=document.getElementsByClassName("scrollbar-view")[0],U=(0,i.useCallback)((()=>O(!L)),[L]);return null!==(o=e.dataFrames)&&void 0!==o&&o.length&&M?(0,T.jsx)(rs.f6,{value:_,children:(0,T.jsxs)(rs.DE.Provider,{value:ds,children:[(0,T.jsx)(rs.T2,{canCollapse:!1,clearSearch:gs,focusUiFindMatches:gs,hideMap:!1,hideSummary:!1,nextResult:gs,onSlimViewClicked:U,onTraceGraphViewClicked:gs,prevResult:gs,resultCount:0,slimView:L,textFilter:null,trace:M,traceGraphView:!1,updateNextViewRangeTime:N,updateViewRangeTime:z,viewRange:k,searchValue:$,onSearchValueChange:E,hideSearchButtons:!0,timeZone:q}),(0,T.jsx)(rs.Ox,{registerAccessors:gs,scrollToFirstVisibleSpan:gs,findMatchesIDs:A,trace:M,traceTimeline:Q,updateNextViewRangeTime:N,updateViewRangeTime:z,viewRange:k,focusSpan:gs,createLinkToExternalSpan:gs,setSpanNameColumnWidth:D,collapseAll:p,collapseOne:l,expandAll:h,expandOne:a,childrenToggle:c,clearShouldScrollToFirstUiFindMatch:gs,detailLogItemToggle:x,detailLogsToggle:v,detailWarningsToggle:S,detailStackTracesToggle:j,detailReferencesToggle:b,detailProcessToggle:y,detailTagsToggle:w,detailToggle:f,setTrace:gs,addHoverIndentGuideId:R,removeHoverIndentGuideId:C,linksGetter:gs,uiFind:$,createSpanLink:Z,scrollElement:W})]})}):null}function fs(e){const{dataFrames:t,splitOpenFn:s,exploreId:i}=e;return(0,T.jsx)(r.Collapse,{label:"Trace View",isOpen:!0,children:(0,T.jsx)(ms,{exploreId:i,dataFrames:t,splitOpenFn:s})})}var xs;function vs(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}var ys;!function(e){e[e.RichHistory=0]="RichHistory",e[e.QueryInspector=1]="QueryInspector"}(ys||(ys={}));class bs extends i.PureComponent{constructor(e){super(e),vs(this,"onChangeTime",(e=>{const{updateTimeRange:t,exploreId:s}=this.props;t({exploreId:s,rawRange:e})})),vs(this,"onClickExample",(e=>{this.props.setQueries(this.props.exploreId,[e])})),vs(this,"onCellFilterAdded",(e=>{const{value:t,key:s,operator:i}=e;i===Vt.PT&&this.onClickFilterLabel(s,t),i===Vt.tE&&this.onClickFilterOutLabel(s,t)})),vs(this,"onClickFilterLabel",((e,t)=>{this.onModifyQueries({type:"ADD_FILTER",key:e,value:t})})),vs(this,"onClickFilterOutLabel",((e,t)=>{this.onModifyQueries({type:"ADD_FILTER_OUT",key:e,value:t})})),vs(this,"onClickAddQueryRowButton",(()=>{const{exploreId:e,queryKeys:t}=this.props;this.props.addQueryRow(e,t.length)})),vs(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)}})),vs(this,"onResize",(e=>{this.props.changeSize(this.props.exploreId,e)})),vs(this,"onStartScanning",(()=>{this.props.scanStart(this.props.exploreId)})),vs(this,"onStopScanning",(()=>{this.props.scanStopAction({exploreId:this.props.exploreId})})),vs(this,"onUpdateTimeRange",(e=>{const{exploreId:t,updateTimeRange:s}=this.props;s({exploreId:t,absoluteRange:e})})),vs(this,"toggleShowRichHistory",(()=>{this.setState((e=>({openDrawer:e.openDrawer===ys.RichHistory?void 0:ys.RichHistory})))})),vs(this,"toggleShowQueryInspector",(()=>{this.setState((e=>({openDrawer:e.openDrawer===ys.QueryInspector?void 0:ys.QueryInspector})))})),vs(this,"getNodeGraphDataFrames",(0,c.default)((e=>e.filter((e=>{var t;return"nodeGraph"===(null===(t=e.meta)||void 0===t?void 0:t.preferredVisualisationType)}))))),this.state={openDrawer:void 0}}renderEmptyState(){return xs||(xs=(0,T.jsx)("div",{className:"explore-container",children:(0,T.jsx)(Zt,{})}))}renderGraphPanel(e){const{graphResult:t,absoluteRange:s,timeZone:i,splitOpen:n,queryResponse:o,loading:a,theme:l}=this.props,c=parseInt(l.spacing(2).slice(0,-2),10);return(0,T.jsx)(r.Collapse,{label:"Graph",loading:a,isOpen:!0,children:(0,T.jsx)(ie,{data:t,height:400,width:e-c,absoluteRange:s,onChangeTime:this.onUpdateTimeRange,timeZone:i,annotations:o.annotations,splitOpenFn:n,loadingState:o.state})})}renderTablePanel(e){const{exploreId:t,datasourceInstance:s}=this.props;return(0,T.jsx)(Oe,{ariaLabel:p.wl.pages.Explore.General.table,width:e,exploreId:t,onCellFilterAdded:null!=s&&s.modifyQuery?this.onCellFilterAdded:void 0})}renderLogsPanel(e){const{exploreId:t,syncedTimes:s,theme:i,queryResponse:n}=this.props,o=parseInt(i.spacing(2).slice(0,-2),10);return(0,T.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,T.jsx)(es,{dataFrames:this.getNodeGraphDataFrames(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,T.jsx)(fs,{exploreId:s,dataFrames:i,splitOpenFn:t})}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}=this.props,{openDrawer:g}=this.state,m=(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),x=n&&n.state!==d.LoadingState.NotStarted,y=g===ys.RichHistory,b=g===ys.QueryInspector;return(0,T.jsxs)(r.CustomScrollbar,{autoHeightMin:"100%",children:[(0,T.jsx)(qt,{exploreId:s,onChangeTime:this.onChangeTime}),t?this.renderEmptyState():null,e&&(0,T.jsxs)("div",{className:"explore-container",children:[(0,T.jsxs)("div",{className:(0,f.cx)("panel-container",m.queryContainer),children:[(0,T.jsx)(ke,{exploreId:s}),(0,T.jsx)(Wt,{addQueryRowButtonDisabled:o,addQueryRowButtonHidden:!1,richHistoryButtonActive:y,queryInspectorButtonActive:b,onClickAddQueryRowButton:this.onClickAddQueryRowButton,onClickRichHistoryButton:this.toggleShowRichHistory,onClickQueryInspectorButton:this.toggleShowQueryInspector}),(0,T.jsx)(ns,{exploreId:s})]}),(0,T.jsx)(v.Z,{onResize:this.onResize,disableHeight:!0,children:({width:e})=>0===e?null:(0,T.jsx)("main",{className:(0,f.cx)(m.exploreMain),style:{width:e},children:(0,T.jsxs)(r.ErrorBoundaryAlert,{children:[x&&(0,T.jsxs)(T.Fragment,{children:[l&&i&&(0,T.jsx)(r.ErrorBoundaryAlert,{children:this.renderGraphPanel(e)}),c&&(0,T.jsx)(r.ErrorBoundaryAlert,{children:this.renderTablePanel(e)}),p&&(0,T.jsx)(r.ErrorBoundaryAlert,{children:this.renderLogsPanel(e)}),h&&(0,T.jsx)(r.ErrorBoundaryAlert,{children:this.renderNodeGraphPanel()}),u&&(0,T.jsx)(r.ErrorBoundaryAlert,{children:this.renderTraceViewPanel()})]}),y&&(0,T.jsx)(pt,{width:e,exploreId:s,onClose:this.toggleShowRichHistory}),b&&(0,T.jsx)(vt,{exploreId:s,width:e,onClose:this.toggleShowQueryInspector})]})})})]})]})}}const ws={changeSize:h.qN,modifyQueries:b.sK,scanStart:b.EA,scanStopAction:b.P4,setQueries:b.KO,updateTimeRange:w.cD,addQueryRow:b.CS,splitOpen:a.bW},Ss=(0,n.connect)((function(e,{exploreId:t}){const s=e.explore,{syncedTimes:i}=s,n=s[t],o=(0,m.Z)(e.user),{datasourceInstance:r,datasourceMissing:a,queryKeys:l,isLive:c,graphResult:d,logsResult:p,showLogs:u,showMetrics:h,showTable:g,showTrace:f,absoluteRange:x,queryResponse:v,showNodeGraph:y,loading:b}=n;return{datasourceInstance:r,datasourceMissing:a,queryKeys:l,isLive:c,graphResult:d,logsResult:null!=p?p:void 0,absoluteRange:x,queryResponse:v,syncedTimes:i,timeZone:o,showLogs:u,showMetrics:h,showTable:g,showTrace:f,showNodeGraph:y,loading:b}}),ws),js=(0,x.compose)(Ss,r.withTheme2)(bs);function Cs(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class Ts extends i.PureComponent{constructor(e){super(e),Cs(this,"el",void 0),Cs(this,"exploreEvents",void 0),Cs(this,"refreshExplore",(e=>{const{exploreId:t,urlQuery:s}=this.props;s!==e&&s!==a.IS[t]&&this.props.refreshExplore(t,s)})),Cs(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}=this.props,l=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,l,this.exploreEvents,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,T.jsx)("div",{className:e,ref:this.getRef,"data-testid":p.wl.pages.Explore.General.container,children:this.props.initialized&&(0,T.jsx)(js,{exploreId:this.props.exploreId})})}}const Rs=(0,c.default)(g.Z8),Is=(0,c.default)(g.vP);const ks={initializeExplore:h.CK,refreshExplore:h.Om,cleanupPaneAction:a.Jt},zs=(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}=i||{},d=r||u.Z.get((0,g.I$)(e.user.orgId)),p=Rs(a),h=l?Is(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:d,initialQueries:p,initialRange:h,originPanelId:c}}),ks)(Ts);var Ns=s("./public/app/core/components/Branding/Branding.tsx"),Fs=s("./public/app/core/selectors/navModel.ts");const Ds={resetExploreAction:a.WK,richHistoryUpdatedAction:a.ZU},Ls=(0,n.connect)((e=>({navModel:(0,Fs.h)(e.navIndex,"explore"),exploreState:e.explore})),Ds);class Os extends i.PureComponent{componentWillUnmount(){this.props.resetExploreAction({})}componentDidMount(){a.IS.left=void 0,a.IS.right=void 0;const e=(0,l.ub)();this.props.richHistoryUpdatedAction({richHistory:e})}componentDidUpdate(){var e,t,s,i;const{left:n,right:o}=this.props.queryParams,r=Boolean(n)&&Boolean(o)?`${null===(e=this.props.exploreState.left.datasourceInstance)||void 0===e?void 0:e.name} | ${null===(t=this.props.exploreState.right)||void 0===t||null===(s=t.datasourceInstance)||void 0===s?void 0:s.name}`:`${null===(i=this.props.exploreState.left.datasourceInstance)||void 0===i?void 0:i.name}`,a=`${this.props.navModel.main.text} - ${r} - ${Ns.c.AppTitle}`;document.title=a}render(){const{left:e,right:t}=this.props.queryParams,s=Boolean(e)&&Boolean(t);return(0,T.jsx)("div",{className:"page-scrollbar-wrapper",children:(0,T.jsxs)("div",{className:"explore-wrapper",children:[(0,T.jsx)(r.ErrorBoundaryAlert,{style:"page",children:(0,T.jsx)(zs,{split:s,exploreId:o.K.left,urlQuery:e})}),s&&(0,T.jsx)(r.ErrorBoundaryAlert,{style:"page",children:(0,T.jsx)(zs,{split:s,exploreId:o.K.right,urlQuery:t})})]})})}}const Ms=Ls(Os)},"./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)}}},"./node_modules/re-resizable/lib/index.js":function(e,t,s){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var s in t)t.hasOwnProperty(s)&&(e[s]=t[s])})(e,t)},function(e,t){function s(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(s.prototype=t.prototype,new s)}),o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var t,s=1,i=arguments.length;s<i;s++)for(var n in t=arguments[s])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)},r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s in e)Object.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var l=r(s("./node_modules/react/index.js")),c=s("./node_modules/re-resizable/lib/resizer.js"),d=a(s("./node_modules/fast-memoize/src/index.js")),p={width:"auto",height:"auto"},u=d.default((function(e,t,s){return Math.max(Math.min(e,s),t)})),h=d.default((function(e,t){return Math.round(e/t)*t})),g=d.default((function(e,t){return new RegExp(e,"i").test(t)})),m=d.default((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})),f=d.default((function(e,t){return e.substr(e.length-t.length,t.length)===t})),x=d.default((function(e){return"auto"===(e=e.toString())||f(e,"px")||f(e,"%")||f(e,"vh")||f(e,"vw")||f(e,"vmax")||f(e,"vmin")?e:e+"px"})),v=function(e,t){if(e&&"string"==typeof e){if(f(e,"%"))return t*(s=Number(e.replace("%",""))/100);if(f(e,"vw")){var s=Number(e.replace("vw",""))/100;return window.innerWidth*s}if(f(e,"vh")){s=Number(e.replace("vh",""))/100;return window.innerHeight*s}}return e},y=d.default((function(e,t,s,i,n){return t=v(t,e.width),s=v(s,e.height),i=v(i,e.width),n=v(n,e.height),{maxWidth:void 0===t?void 0:Number(t),maxHeight:void 0===s?void 0:Number(s),minWidth:void 0===i?void 0:Number(i),minHeight:void 0===n?void 0:Number(n)}})),b=["style","className","grid","snap","bounds","size","defaultSize","minWidth","minHeight","maxWidth","maxHeight","lockAspectRatio","lockAspectRatioExtraWidth","lockAspectRatioExtraHeight","enable","handleStyles","handleClasses","handleWrapperStyle","handleWrapperClass","children","onResizeStart","onResize","onResizeStop","handleComponent","scale","resizeRatio","snapGap"],w="__resizable_base__",S=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.resizableTop=0,s.targetLeft=0,s.targetTop=0,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"}},s.onResizeStart=s.onResizeStart.bind(s),s.onMouseMove=s.onMouseMove.bind(s),s.onMouseUp=s.onMouseUp.bind(s),s}return n(t,e),Object.defineProperty(t.prototype,"parentNode",{get:function(){return this.resizable?this.resizable.parentNode:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"propsSize",{get:function(){return this.props.size||this.props.defaultSize||p},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"base",{get:function(){var e=this.parentNode;if(e)for(var t=0,s=[].slice.call(e.children);t<s.length;t++){var i=s[t];if(i instanceof HTMLElement&&i.classList.contains(w))return i}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){var e=0,t=0;if("undefined"!=typeof window&&this.resizable){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:!0,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]&&f(e.propsSize[t].toString(),"%")){if(f(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 x(e.state[t])};return{width:t&&void 0!==t.width&&!this.state.isResizing?x(t.width):s("width"),height:t&&void 0!==t.height&&!this.state.isResizing?x(t.height):s("height")}},enumerable:!0,configurable:!0}),t.prototype.getParentSize=function(){if(!this.base||!this.parentNode)return{width:window.innerWidth,height:window.innerHeight};var e=!1,t=this.parentNode.style.flexWrap,s=this.base.style.minWidth;"wrap"!==t&&(e=!0,this.parentNode.style.flexWrap="wrap"),this.base.style.position="relative",this.base.style.minWidth="100%";var i={width:this.base.offsetWidth,height:this.base.offsetHeight};return this.base.style.position="absolute",e&&(this.parentNode.style.flexWrap=t),this.base.style.minWidth=s,i},t.prototype.bindEvents=function(){"undefined"!=typeof window&&(window.addEventListener("mouseup",this.onMouseUp),window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("mouseleave",this.onMouseUp),window.addEventListener("touchmove",this.onMouseMove),window.addEventListener("touchend",this.onMouseUp))},t.prototype.unbindEvents=function(){"undefined"!=typeof window&&(window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseleave",this.onMouseUp),window.removeEventListener("touchmove",this.onMouseMove),window.removeEventListener("touchend",this.onMouseUp))},t.prototype.componentDidMount=function(){if(this.resizable){var e=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});var t=this.parentNode;if(t instanceof HTMLElement&&!this.base){var s=document.createElement("div");s.style.width="100%",s.style.height="100%",s.style.position="absolute",s.style.transform="scale(0, 0)",s.style.left="0",s.style.flex="0",s.classList?s.classList.add(w):s.className+=w,t.appendChild(s)}}},t.prototype.componentWillUnmount=function(){if("undefined"!=typeof window){this.unbindEvents();var e=this.parentNode;if(!this.base||!e)return;if(!(e instanceof HTMLElement&&this.base instanceof Node))return;e.removeChild(this.base)}},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){if("parent"===this.props.bounds){var s=this.parentNode;if(s instanceof HTMLElement){var i=s.offsetWidth+(this.parentLeft-this.resizableLeft),n=s.offsetHeight+(this.parentTop-this.resizableTop);e=e&&e<i?e:i,t=t&&t<n?t:n}}else if("window"===this.props.bounds){if("undefined"!=typeof window){i=window.innerWidth-this.resizableLeft,n=window.innerHeight-this.resizableTop;e=e&&e<i?e:i,t=t&&t<n?t:n}}else if(this.props.bounds instanceof HTMLElement){i=this.props.bounds.offsetWidth+(this.targetLeft-this.resizableLeft),n=this.props.bounds.offsetHeight+(this.targetTop-this.resizableTop);e=e&&e<i?e:i,t=t&&t<n?t:n}return{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,m=d||0;return g("right",o)&&(p=r.width+(e-r.x)*i/s,l&&(u=(p-m)/this.ratio+h)),g("left",o)&&(p=r.width-(e-r.x)*i/s,l&&(u=(p-m)/this.ratio+h)),g("bottom",o)&&(u=r.height+(t-r.y)*i/s,l&&(p=(u-h)*this.ratio+m)),g("top",o)&&(u=r.height-(t-r.y)*i/s,l&&(p=(u-h)*this.ratio+m)),{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,h=r||0,g=a||0;if(o){var m=(d-h)*this.ratio+g,f=(p-h)*this.ratio+g,x=(l-g)/this.ratio+h,v=(c-g)/this.ratio+h,y=Math.max(l,m),b=Math.min(c,f),w=Math.max(d,x),S=Math.min(p,v);e=u(e,y,b),t=u(t,w,S)}else e=u(e,l,c),t=u(t,d,p);return{newWidth:e,newHeight:t}},t.prototype.setBoundingClientRect=function(){if("parent"===this.props.bounds){var e=this.parentNode;if(e instanceof HTMLElement){var t=e.getBoundingClientRect();this.parentLeft=t.left,this.parentTop=t.top}}if(this.props.bounds instanceof HTMLElement){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;this.resizableLeft=n,this.resizableTop=o}},t.prototype.onResizeStart=function(e,t){if(this.resizable){var s,i=0,n=0;if(e.nativeEvent instanceof MouseEvent){if(i=e.nativeEvent.clientX,n=e.nativeEvent.clientY,3===e.nativeEvent.which)return}else e.nativeEvent instanceof TouchEvent&&(i=e.nativeEvent.touches[0].clientX,n=e.nativeEvent.touches[0].clientY);if(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 r=window.getComputedStyle(this.resizable);if("auto"!==r.flexBasis){var a=this.parentNode;if(a){var l=window.getComputedStyle(a).flexDirection;this.flexDir=l.startsWith("row")?"row":"column",s=r.flexBasis}}this.setBoundingClientRect(),this.bindEvents();var c={original:{x:i,y:n,width:this.size.width,height:this.size.height},isResizing:!0,backgroundStyle:o(o({},this.state.backgroundStyle),{cursor:window.getComputedStyle(e.target).cursor||"auto"}),direction:t,flexBasis:s};this.setState(c)}},t.prototype.onMouseMove=function(e){if(this.state.isResizing&&this.resizable){var t=this.props,s=t.maxWidth,i=t.maxHeight,n=t.minWidth,o=t.minHeight,r=e instanceof MouseEvent?e.clientX:e.touches[0].clientX,a=e instanceof MouseEvent?e.clientY:e.touches[0].clientY,l=this.state,c=l.direction,d=l.original,p=l.width,u=l.height,g=this.getParentSize(),x=y(g,s,i,n,o);s=x.maxWidth,i=x.maxHeight,n=x.minWidth,o=x.minHeight;var v=this.calculateNewSizeFromDirection(r,a),b=v.newHeight,w=v.newWidth,S=this.calculateNewMaxFromBoundary(s,i),j=this.calculateNewSizeFromAspectRatio(w,b,{width:S.maxWidth,height:S.maxHeight},{width:n,height:o});if(w=j.newWidth,b=j.newHeight,this.props.grid){var C=h(w,this.props.grid[0]),T=h(b,this.props.grid[1]),R=this.props.snapGap||0;w=0===R||Math.abs(C-w)<=R?C:w,b=0===R||Math.abs(T-b)<=R?T:b}this.props.snap&&this.props.snap.x&&(w=m(w,this.props.snap.x,this.props.snapGap)),this.props.snap&&this.props.snap.y&&(b=m(b,this.props.snap.y,this.props.snapGap));var I={width:w-d.width,height:b-d.height};if(p&&"string"==typeof p)if(f(p,"%"))w=w/g.width*100+"%";else if(f(p,"vw")){w=w/window.innerWidth*100+"vw"}else if(f(p,"vh")){w=w/window.innerHeight*100+"vh"}if(u&&"string"==typeof u)if(f(u,"%"))b=b/g.height*100+"%";else if(f(u,"vw")){b=b/window.innerWidth*100+"vw"}else if(f(u,"vh")){b=b/window.innerHeight*100+"vh"}var k={width:this.createSizeForCssProperty(w,"width"),height:this.createSizeForCssProperty(b,"height")};"row"===this.flexDir?k.flexBasis=k.width:"column"===this.flexDir&&(k.flexBasis=k.height),this.setState(k),this.props.onResize&&this.props.onResize(e,c,this.resizable,I)}},t.prototype.onMouseUp=function(e){var t=this.state,s=t.isResizing,i=t.direction,n=t.original;if(s&&this.resizable){var r={width:this.size.width-n.width,height:this.size.height-n.height};this.props.onResizeStop&&this.props.onResizeStop(e,i,this.resizable,r),this.props.size&&this.setState(this.props.size),this.unbindEvents(),this.setState({isResizing:!1,backgroundStyle:o(o({},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,i=t.handleStyles,n=t.handleClasses,o=t.handleWrapperStyle,r=t.handleWrapperClass,a=t.handleComponent;if(!s)return null;var d=Object.keys(s).map((function(t){return!1!==s[t]?l.createElement(c.Resizer,{key:t,direction:t,onResizeStart:e.onResizeStart,replaceStyles:i&&i[t],className:n&&n[t]},a&&a[t]?a[t]:null):null}));return l.createElement("span",{className:r,style:o},d)},t.prototype.render=function(){var e=this,t=Object.keys(this.props).reduce((function(t,s){return-1!==b.indexOf(s)||(t[s]=e.props[s]),t}),{}),s=o(o(o({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});return this.state.flexBasis&&(s.flexBasis=this.state.flexBasis),l.createElement("div",o({ref:this.ref,style:s,className:this.props.className},t),this.state.isResizing&&l.createElement("div",{style:this.state.backgroundStyle}),this.props.children,this.renderResizer())},t.defaultProps={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}(l.PureComponent);t.Resizable=S},"./node_modules/re-resizable/lib/resizer.js":function(e,t,s){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var s in t)t.hasOwnProperty(s)&&(e[s]=t[s])})(e,t)},function(e,t){function s(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(s.prototype=t.prototype,new s)}),o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var t,s=1,i=arguments.length;s<i;s++)for(var n in t=arguments[s])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)},r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s in e)Object.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});var a=r(s("./node_modules/react/index.js")),l={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"}},c=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 n(t,e),t.prototype.render=function(){return a.createElement("div",{className:this.props.className||"",style:o(o({position:"absolute",userSelect:"none"},l[this.props.direction]),this.props.replaceStyles||{}),onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart},this.props.children)},t}(a.PureComponent);t.Resizer=c},"./node_modules/react-use/esm/usePrevious.js":(e,t,s)=>{"use strict";s.d(t,{Z:()=>n});var i=s("./node_modules/react/index.js");function n(e){var t=(0,i.useRef)();return(0,i.useEffect)((function(){t.current=e})),t.current}}}]);
//# sourceMappingURL=explore.8128b05ac04b15cbf98d.js.map