⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.72
Server IP:
41.128.143.86
Server:
Linux host.raqmix.cloud 6.8.0-1025-azure #30~22.04.1-Ubuntu SMP Wed Mar 12 15:28:20 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.3.23
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
proc
/
self
/
root
/
usr
/
share
/
grafana
/
public
/
build
/
View File Name :
explore.476912733278e2a99729.js
"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[9604],{2864:(Gt,Ae,d)=>{d.d(Ae,{h:()=>V,j:()=>N});var h=d(91890),t=d(44836);function V(X){switch(X){case h.CC.Logfmt:return{label:(0,t.t)("correlations.trans-details.logfmt-label","Logfmt"),value:h.CC.Logfmt,description:(0,t.t)("correlations.trans-details.logfmt-description","Parse provided field with logfmt to get variables"),expressionDetails:{show:!1},mapValueDetails:{show:!1}};case h.CC.Regex:return{label:(0,t.t)("correlations.trans-details.regex-label","Regular expression"),value:h.CC.Regex,description:(0,t.t)("correlations.trans-details.regex-description","Field will be parsed with regex. Use named capture groups to return multiple variables, or a single unnamed capture group to add variable to named map value. Regex is case insensitive."),expressionDetails:{show:!0,required:!0,helpText:(0,t.t)("correlations.trans-details.regex-expression","Use capture groups to extract a portion of the field.")},mapValueDetails:{show:!0,required:!1,helpText:(0,t.t)("correlations.trans-details.regex-map-values","Defines the name of the variable if the capture group is not named.")}};default:return{label:X,value:X,expressionDetails:{show:!1},mapValueDetails:{show:!1}}}}const N=()=>Object.values(h.CC).map(X=>{const Ce=V(X);return{label:Ce.label,value:Ce.value,description:Ce.description}})},88322:(Gt,Ae,d)=>{d.r(Ae),d.d(Ae,{default:()=>Ri});var h=d(32196),t=d(96540),V=d(32264),N=d(40845),X=d(66602),Ce=d(58720),ke=d(76888),qt=d(25249),O=d(80348),oo=d(24180),Je=d(2739),so=function(e,o){e===void 0&&(e=!0);var n=(0,t.useCallback)(function(s){var a=typeof e=="function"?e():!0;if(a)return s.preventDefault(),o&&(s.returnValue=o),o},[e,o]);(0,t.useEffect)(function(){if(e)return(0,Je.on)(window,"beforeunload",n),function(){return(0,Je.AU)(window,"beforeunload",n)}},[e,n])};const Kt=so;var ao=d(64305),vt=d(23596),P=d(14110),ro=d(66864),he=d(56034),ie=d(14578),j=d(55852),Xe=d(37390);const io=({onSave:e,onDiscard:o,onCancel:n,message:s})=>t.createElement(Xe.a,{isOpen:!0,title:"Unsaved changes to correlation",onDismiss:n,icon:"exclamation-triangle",className:(0,h.css)({width:"600px"})},t.createElement("h5",null,s),t.createElement(Xe.a.ButtonRow,null,t.createElement(j.$n,{variant:"secondary",onClick:n,fill:"outline"},"Cancel"),t.createElement(j.$n,{variant:"destructive",onClick:o},"Continue without saving"),t.createElement(j.$n,{variant:"primary",onClick:e},"Save correlation")));var te=d(2543),lo=(e=>(e.SOURCE_TARGET_CHANGE="cause the query in the right pane to be re-ran and links added to that data",e.FULL_QUERY_LOSS="lose the changed query",e.FULL_CORR_LOSS="cause the correlation in progress to be lost",e.INVALID_VAR="remove the variables, and your changed query may no longer be valid",e))(lo||{});const co=(e,o,n,s)=>{const a=(0,te.template)("<%= actionStr %> will <%= consequenceStr %>. Would you like to save before continuing?");let r="",i="";if(e===O.CORRELATION_EDITOR_POST_CONFIRM_ACTION.CLOSE_PANE)if(r="Closing the pane",o)if(n)i="cause the correlation in progress to be lost";else if(s)i="cause the query in the right pane to be re-ran and links added to that data";else return;else if(n)i="cause the correlation in progress to be lost";else if(s)i="lose the changed query";else return;else if(e===O.CORRELATION_EDITOR_POST_CONFIRM_ACTION.CHANGE_DATASOURCE)if(r="Changing the datasource",o)if(n)i="cause the correlation in progress to be lost";else return;else if(s)i="lose the changed query";else return;else if(e===O.CORRELATION_EDITOR_POST_CONFIRM_ACTION.CLOSE_EDITOR)if(r="Closing the editor",n)i="cause the correlation in progress to be lost";else if(s)i="remove the variables, and your changed query may no longer be valid";else return;return a({actionStr:r,consequenceStr:i})};var uo=d(324),Ne=d(62860),be=d(62256),G=d(29436),q=d(23994),J=d(9955);const po=({panes:e})=>{const o=(0,O.useDispatch)(),n=(0,N.of)(ho),s=(0,O.useSelector)(J.vC),a=(0,O.useSelector)(J.st),[r,i]=(0,t.useState)(void 0);Kt(s?.correlationDirty||!1,"Save correlation?"),Kt(!s?.correlationDirty&&s?.queryEditorDirty||!1,"The query editor was changed. Save correlation before continuing?"),(0,t.useEffect)(()=>{if(s?.isExiting){const{correlationDirty:u,queryEditorDirty:f}=s;let g,y;s.postConfirmAction?(g=s.postConfirmAction.isActionLeft,y=s.postConfirmAction.action):(y=O.CORRELATION_EDITOR_POST_CONFIRM_ACTION.CLOSE_EDITOR,g=!1);const v=co(y,g,u,f);if(v!==void 0)i(v);else if(y===O.CORRELATION_EDITOR_POST_CONFIRM_ACTION.CHANGE_DATASOURCE&&s.postConfirmAction){const{exploreId:b,changeDatasourceUid:E}=s?.postConfirmAction;b&&E&&(o((0,Ne.wh)({exploreId:b,datasource:E,options:{importQueries:!0}})),o((0,G.am)({isExiting:!1})))}else if(y===O.CORRELATION_EDITOR_POST_CONFIRM_ACTION.CLOSE_PANE&&s.postConfirmAction){const{exploreId:b}=s?.postConfirmAction;b!==void 0&&(o((0,G.J8)(b)),o((0,G.am)({isExiting:!1})))}else y===O.CORRELATION_EDITOR_POST_CONFIRM_ACTION.CLOSE_EDITOR&&o((0,G.am)({editorMode:!1}))}},[s,o,a]),(0,ao.A)(()=>{o((0,G.am)({editorMode:!1,isExiting:!1,correlationDirty:!1,label:void 0,description:void 0,canSave:!1})),e.forEach(u=>{o((0,be.nE)({exploreId:u[0],correlationEditorHelperData:void 0})),o((0,q.Od)({exploreId:u[0]}))})});const l=()=>{o((0,G.am)({editorMode:!0,isExiting:!1,correlationDirty:!1,label:void 0,description:void 0,canSave:!1})),e.forEach(u=>{o((0,be.nE)({exploreId:u[0],correlationEditorHelperData:void 0})),o((0,q.Od)({exploreId:u[0]}))})},c=u=>{i(void 0),o((0,G.J8)(u)),(0,P.rR)("grafana_explore_split_view_closed")},m=(u,f)=>{i(void 0),o((0,Ne.wh)({exploreId:u,datasource:f,options:{importQueries:!0}}))},p=u=>{if(o((0,uo.v)(s?.label,s?.description,s?.transformations)),!u&&s?.postConfirmAction!==void 0){const{exploreId:f,action:g,changeDatasourceUid:y}=s?.postConfirmAction;g===O.CORRELATION_EDITOR_POST_CONFIRM_ACTION.CLOSE_PANE?(c(f),l()):g===O.CORRELATION_EDITOR_POST_CONFIRM_ACTION.CHANGE_DATASOURCE&&y!==void 0&&((0,Ne.wh)({exploreId:f,datasource:y}),l())}else o((0,G.am)({editorMode:!1,correlationDirty:!1,isExiting:!1}))};return t.createElement(t.Fragment,null,t.createElement(oo.XG,{message:u=>u.pathname!=="/explore"&&s?.editorMode&&s?.correlationDirty?"You have unsaved correlation data. Continue?":!0}),r!==void 0&&t.createElement(io,{onDiscard:()=>{if(s?.postConfirmAction!==void 0){const{exploreId:u,action:f,changeDatasourceUid:g}=s?.postConfirmAction;f===O.CORRELATION_EDITOR_POST_CONFIRM_ACTION.CLOSE_PANE?c(u):f===O.CORRELATION_EDITOR_POST_CONFIRM_ACTION.CHANGE_DATASOURCE&&g!==void 0&&m(u,g),o((0,G.am)({isExiting:!1}))}else o((0,G.am)({editorMode:!1,correlationDirty:!1,isExiting:!1}))},onCancel:()=>{o((0,G.am)({isExiting:!1})),i(void 0)},onSave:()=>{p(!1)},message:r}),t.createElement("div",{className:n.correlationEditorTop},t.createElement(ro.Gy,{spacing:"md",justify:"flex-end"},t.createElement(he.m,{content:"Correlations editor in Explore is an experimental feature."},t.createElement(ie.I,{className:n.iconColor,name:"info-circle",size:"xl"})),t.createElement(j.$n,{variant:"secondary",disabled:!s?.canSave,fill:"outline",className:s?.canSave?n.buttonColor:n.disabledButtonColor,onClick:()=>{p(!0)}},"Save"),t.createElement(j.$n,{variant:"secondary",fill:"outline",className:n.buttonColor,icon:"times",onClick:()=>{o((0,G.am)({isExiting:!0})),(0,P.rR)("grafana_explore_correlation_editor_exit_pressed")}},"Exit correlation editor"))))},ho=e=>{const o=e.colors.getContrastText(e.colors.primary.main),n=vt.lighten(e.colors.primary.main,.1),s=vt.darken(e.colors.primary.main,.2),a=vt.darken(o,.2);return{correlationEditorTop:(0,h.css)({backgroundColor:e.colors.primary.main,marginTop:"3px",padding:e.spacing(1)}),iconColor:(0,h.css)({color:o}),buttonColor:(0,h.css)({color:o,borderColor:o,"&:hover":{color:o,borderColor:o,backgroundColor:n}}),disabledButtonColor:(0,h.css)({color:`${a} !important`,backgroundColor:`${s} !important`})}};var Et=d(1503),_e=d(16233),et=d(14678);const mo=()=>{const[e,o]=(0,t.useState)([]),{query:n}=(0,Et.useKBar)(),s=(0,O.useDispatch)(),a=(0,O.useSelector)(J.Qb),r=(0,O.useSelector)(J.pF),i=_e.TP.hasPermission(O.AccessControlAction.DataSourcesWrite);return(0,t.useEffect)(()=>{const l=Object.keys(a),c={name:"Explore",priority:Et.Priority.HIGH+1},m=[];if(r)m.push({id:"explore/run-query-left",name:"Run query (left)",keywords:"query left",perform:()=>{s((0,q.Od)({exploreId:l[0]}))},section:c}),a[1],m.push({id:"explore/run-query-right",name:"Run query (right)",keywords:"query right",perform:()=>{s((0,q.Od)({exploreId:l[1]}))},section:c}),m.push({id:"explore/split-view-close-left",name:"Close split view left",keywords:"split",perform:()=>{s((0,G.J8)(l[0]))},section:c}),m.push({id:"explore/split-view-close-right",name:"Close split view right",keywords:"split",perform:()=>{s((0,G.J8)(l[1]))},section:c});else{const p=Object.values(a).some(u=>u?.datasourceInstance?.uid===et.uv);V.$.featureToggles.correlations&&i&&!p&&m.push({id:"explore/correlations-editor",name:"Correlations editor",perform:()=>{s((0,G.am)({editorMode:!0})),s((0,q.Od)({exploreId:l[0]}))},section:c}),m.push({id:"explore/run-query",name:"Run query",keywords:"query",perform:()=>{s((0,q.Od)({exploreId:l[0]}))},section:c}),m.push({id:"explore/split-view-open",name:"Open split view",keywords:"split",perform:()=>{s((0,G.ve)())},section:c})}o(m)},[a,r,n,s,i]),(0,Et.useRegisterActions)(n?e:[],[e,n]),null};var me=d(69733),go=d(18226),tt=d(13544),nt=d(40276),Be=d(87490),ze=d(41811),fo=d(70713),Y=d(9557),le=d(39070),He=d(19347),bt=d(52494),ot=d(88407),We=d(11401),yo=d(48543),st=d(32901),Zt=d(42941),vo=d(23535),Eo=function(e){var o=(0,vo.A)({x:0,y:0}),n=o[0],s=o[1];return(0,t.useEffect)(function(){var a=function(){e.current&&s({x:e.current.scrollLeft,y:e.current.scrollTop})};return e.current&&(0,Je.on)(e.current,"scroll",a,{capture:!1,passive:!0}),function(){e.current&&(0,Je.AU)(e.current,"scroll",a)}},[e]),n};const bo=Eo,Yt=(0,t.createContext)(void 0),xo=({children:e})=>{const[o,n]=(0,t.useState)([]),s=(0,t.useCallback)(({title:r,icon:i,ref:l})=>{const c=(0,te.uniqueId)(`${r}-${i}_`);return n(m=>[...m,{id:c,title:r,icon:i,ref:l}].sort((u,f)=>{if(u.ref&&f.ref){const g=u.ref.compareDocumentPosition(f.ref);if(g===Node.DOCUMENT_POSITION_PRECEDING)return 1;if(g===Node.DOCUMENT_POSITION_FOLLOWING)return-1}return 0})),c},[]),a=(0,t.useCallback)(r=>{n(i=>i.filter(l=>l.id!==r))},[]);return t.createElement(Yt.Provider,{value:{outlineItems:o,register:s,unregister:a}},e)};function Jt(){const e=(0,t.useContext)(Yt);if(!e)throw new Error("useContentOutlineContext must be used within a ContentOutlineContextProvider");return e}var So=d(8887);function Xt({title:e,icon:o,tooltip:n,className:s,isActive:a,...r}){const i=(0,N.of)(Ro),l=(0,h.cx)(i.button,s),c=t.createElement("button",{className:(0,h.cx)(l,{[i.active]:a}),"aria-label":n,...r},Co(o),e);return n?t.createElement(he.m,{content:n,placement:"bottom"},c):c}function Co(e){return e?(0,So.n6)(e)?t.createElement(ie.I,{name:e,size:"lg"}):e:null}const Ro=e=>({button:(0,h.css)({label:"content-outline-item-button",display:"flex",flexGrow:1,alignItems:"center",height:e.spacing(e.components.height.md),padding:e.spacing(0,1),gap:e.spacing(1),color:e.colors.text.secondary,background:"transparent",border:"none",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap","&:hover":{color:e.colors.text.primary,background:e.colors.background.secondary,textDecoration:"underline"}}),active:(0,h.css)({backgroundColor:e.colors.background.secondary,borderTopRightRadius:e.shape.radius.default,borderBottomRightRadius:e.shape.radius.default,position:"relative","&::before":{backgroundImage:e.colors.gradients.brandVertical,borderRadius:e.shape.radius.default,content:'" "',display:"block",height:"100%",position:"absolute",transform:"translateX(-50%)",width:e.spacing(.5),left:"2px"}})}),wo=e=>({wrapper:(0,h.css)({label:"wrapper",position:"relative",display:"flex",justifyContent:"center",marginRight:e.spacing(1),height:"100%",backgroundColor:e.colors.background.primary}),content:(0,h.css)({label:"content",top:0}),buttonStyles:(0,h.css)({textAlign:"left",width:"100%",padding:e.spacing(0,1.5)})});function To({scroller:e,panelId:o}){const{outlineItems:n}=Jt(),[s,a]=(0,Zt.A)(!1),[r,i]=(0,t.useState)(n[0]?.id),l=(0,N.of)(f=>wo(f)),c=(0,t.useRef)(e||null),{y:m}=bo(c),p=(f,g)=>{let y=0,v=f;do y+=v?.offsetTop||0,v=v?.offsetParent;while(v&&v!==e);e?.scroll({top:y,behavior:"smooth"}),(0,P.rR)("explore_toolbar_contentoutline_clicked",{item:"select_section",type:g})},u=()=>{a(),(0,P.rR)("explore_toolbar_contentoutline_clicked",{item:"outline",type:s?"minimize":"expand"})};return(0,t.useEffect)(()=>{const f=n.find(g=>{const y=g?.ref?.getBoundingClientRect().top;return y?y>=0:!1});f&&i(f.id)},[n,m]),t.createElement(bt._,{className:l.wrapper,id:o},t.createElement(nt.E,null,t.createElement("div",{className:l.content},t.createElement(Xt,{title:s?"Collapse outline":void 0,icon:s?"angle-left":"angle-right",onClick:u,tooltip:s?void 0:"Expand content outline",className:l.buttonStyles,"aria-expanded":s}),n.map(f=>t.createElement(Xt,{key:f.id,title:s?f.title:void 0,className:l.buttonStyles,icon:f.icon,onClick:()=>p(f.ref,f.title),tooltip:s?void 0:f.title,isActive:r===f.id})))))}function ge({title:e,icon:o,children:n,className:s}){const{register:a,unregister:r}=Jt(),i=(0,t.useRef)(null);return(0,t.useEffect)(()=>{const l=a({title:e,icon:o,ref:i.current});return()=>r(l)},[e,o,a,r]),t.createElement("div",{className:s,ref:i},n)}var _t=d(49785),en=d(16817),Ve=d(42418),at=d(82762),Qe=d(67061),xe=d(88575),Ue=d(10354),rt=d(10860),Me=d(29158),Lo=d(91605),xt=d(67023),Io=d(18380),Fo=d(23257),Oo=d.n(Fo),Do=d(60029),tn=d(16504),Re=d(88323),St=d(2864);const nn=({label:e,tooltipText:o})=>t.createElement(Qe.B,{gap:1,direction:"row",wrap:"wrap",alignItems:"flex-start"},t.createElement(Do.J,null,e),t.createElement(he.m,{content:o},t.createElement(ie.I,{name:"info-circle",size:"sm"}))),Ao=({onSave:e,onCancel:o,fieldList:n,transformationToEdit:s})=>{const[a,r]=(0,t.useState)(void 0),[i,l]=(0,t.useState)({}),[c,m]=(0,t.useState)({mapValueDetails:{show:!1},expressionDetails:{show:!1}}),[p,u]=(0,t.useState)(!1),[f,g]=(0,t.useState)(!1),{getValues:y,control:v,register:b,watch:E}=(0,_t.mN)({defaultValues:(0,t.useMemo)(()=>{if(s){const R=n[s?.field];r(R),s?.expression&&u(!0);const S=(0,St.h)(s?.type);m({mapValueDetails:S.mapValueDetails,expressionDetails:S.expressionDetails});const L=(0,xt.k)({type:s?.type,expression:s?.expression,mapValue:s?.mapValue},R||"",s?.field);return l({...L}),g(!0),{type:s?.type,field:s?.field,mapValue:s?.mapValue,expression:s?.expression}}else return},[n,s])}),C=(0,t.useId)();return(0,t.useEffect)(()=>{const R=E(S=>{const L=S.expression;let I=!1;if(L!==void 0){I=!0;try{new RegExp(L)}catch{I=!1}}else I=!c.expressionDetails.show;u(I);let H=[];if(S.type){const z=(0,xt.k)({type:S.type,expression:I?L:"",mapValue:S.mapValue},n[S.field]||"",S.field);H=Object.keys(z),l(H.length>0?{...z}:{})}H.length===0||!I?g(!1):g(!0)});return()=>R.unsubscribe()},[n,c.expressionDetails.show,E]),t.createElement(Xe.a,{isOpen:!0,title:`${s?"Edit":"Add"} transformation`,onDismiss:o,className:(0,h.css)({width:"700px"})},t.createElement("p",null,"A transformation extracts variables out of a single field. These variables will be available along with your field variables."),t.createElement(xe.D,{label:"Field"},t.createElement(tn.e,{control:v,render:({field:{onChange:R,ref:S,...L}})=>t.createElement(Re.l6,{...L,onChange:I=>{I.value&&(R(I.value),r(n[I.value]))},options:Object.entries(n).map(I=>({label:I[0],value:I[0]})),"aria-label":"field"}),name:"field"})),a&&t.createElement(t.Fragment,null,t.createElement("pre",null,t.createElement(Oo(),{textToHighlight:a,searchWords:[p?y("expression")??"":""],autoEscape:!1})),t.createElement(xe.D,{label:"Type"},t.createElement(tn.e,{control:v,render:({field:{onChange:R,ref:S,...L}})=>t.createElement(Re.l6,{...L,onChange:I=>{R(I.value);const H=(0,St.h)(I.value);m({mapValueDetails:H.mapValueDetails,expressionDetails:H.expressionDetails})},options:(0,St.j)(),"aria-label":"type"}),name:"type"})),c.expressionDetails.show&&t.createElement(xe.D,{label:c.expressionDetails.helpText?t.createElement(nn,{label:"Expression",tooltipText:c.expressionDetails.helpText}):"Expression",htmlFor:`${C}-expression`,required:c.expressionDetails.required},t.createElement(Ue.p,{...b("expression"),id:`${C}-expression`})),c.mapValueDetails.show&&t.createElement(xe.D,{label:c.mapValueDetails.helpText?t.createElement(nn,{label:"Variable Name",tooltipText:c.mapValueDetails.helpText}):"Variable Name",htmlFor:`${C}-mapValue`},t.createElement(Ue.p,{...b("mapValue"),id:`${C}-mapValue`})),Object.entries(i).length>0&&t.createElement(t.Fragment,null,"This transformation will add the following variables:",t.createElement("pre",null,Object.entries(i).map(R=>`\${${R[0]}} = ${R[1]?.value} `)))),t.createElement(Xe.a.ButtonRow,null,t.createElement(j.$n,{variant:"secondary",onClick:o,fill:"outline"},"Cancel"),t.createElement(j.$n,{variant:"primary",onClick:()=>e(y()),disabled:!f},s?"Edit transformation":"Add transformation to correlation")))},No=({exploreId:e,correlations:o})=>{const n=(0,O.useDispatch)(),s=(0,N.of)(zo),a=(0,O.useSelector)(J.Qb),r=Object.values(a),{value:i,loading:l}=(0,en.A)(async()=>await(0,Io.tZ)(r[0],r[1]),[r[0]?.datasourceInstance,r[0]?.queries[0].datasource,r[1]?.datasourceInstance,r[1]?.queries[0].datasource]),{register:c,watch:m,getValues:p,setValue:u}=(0,_t.mN)(),[f,g]=(0,t.useState)(!1),[y,v]=(0,t.useState)(!1),[b,E]=(0,t.useState)(!1),[C,R]=(0,t.useState)([]),[S,L]=(0,t.useState)(void 0),I=(0,O.useSelector)(J.vC),H=(0,t.useId)();return(0,t.useEffect)(()=>(n((0,G.am)({canSave:!0})),()=>{n((0,G.am)({canSave:!1}))}),[n]),(0,t.useEffect)(()=>{!l&&i!==void 0&&!I?.correlationDirty&&p("label")!==""&&u("label",i)},[I?.correlationDirty,i,p,l,u]),(0,t.useEffect)(()=>{const z=m($=>{let D=I?.correlationDirty||!1,T=$.description||"";!D&&($.label!==i||T!=="")?D=!0:D&&$.label===i&&T.trim()===""&&(D=!1),n((0,G.am)({label:$.label,description:$.description,correlationDirty:D}))});return()=>z.unsubscribe()},[I?.correlationDirty,i,n,m]),(0,t.useEffect)(()=>{const z=!I?.correlationDirty&&C.length>0?!0:I?.correlationDirty;n((0,G.am)({transformations:C,correlationDirty:z}));let $={};C.forEach(D=>{const T=(0,xt.k)({type:D.type,expression:D.expression,mapValue:D.mapValue},o.vars[D.field],D.field);Object.keys(T).forEach(k=>{$[k]=T[k]?.value})}),n((0,be.nE)({exploreId:e,correlationEditorHelperData:{resultField:o.resultField,origVars:o.origVars,vars:{...o.origVars,...$}}}))},[n,C]),t.createElement(t.Fragment,null,b&&t.createElement(Ao,{onCancel:()=>{L(void 0),E(!1)},onSave:z=>{if(S!==void 0){const $=[...C];$[S]=z,R($),L(void 0)}else R([...C,z]);E(!1)},fieldList:o.origVars,transformationToEdit:S!==void 0?C[S]:void 0}),t.createElement(Ve.F,{title:"Correlation details",severity:"info"},"The correlation link will appear by the ",t.createElement("code",null,o.resultField)," field. You can use the following variables to set up your correlations:",t.createElement("pre",null,Object.entries(o.vars).map(z=>`\${${z[0]}} = ${z[1]} `)),t.createElement(at.S,{collapsible:!0,isOpen:f,onToggle:()=>{g(!f)},label:t.createElement(Qe.B,{gap:1,direction:"row",wrap:"wrap",alignItems:"center"},"Label / Description",!f&&!l&&t.createElement("span",{className:s.labelCollapseDetails},`Label: ${p("label")||i}`))},t.createElement(xe.D,{label:"Label",htmlFor:`${H}-label`},t.createElement(Ue.p,{...c("label"),id:`${H}-label`,onBlur:()=>{p("label")===""&&i!==void 0&&u("label",i)}})),t.createElement(xe.D,{label:"Description",htmlFor:`${H}-description`},t.createElement(Ue.p,{...c("description"),id:`${H}-description`}))),t.createElement(at.S,{collapsible:!0,isOpen:y,onToggle:()=>{v(!y)},label:t.createElement(Qe.B,{gap:1,direction:"row",wrap:"wrap",alignItems:"center"},"Transformations",t.createElement(he.m,{content:"A transformation extracts one or more variables out of a single field."},t.createElement(ie.I,{name:"info-circle",size:"sm"})))},t.createElement(j.$n,{variant:"secondary",fill:"outline",onClick:()=>{E(!0)},className:s.transformationAction},"Add transformation"),C.map((z,$)=>{const{type:D,field:T,expression:k,mapValue:Z}=z,W=[(Z??"").length>0?`Variable name: ${Z}`:void 0,(k??"").length>0?t.createElement(t.Fragment,null,"Expression: ",t.createElement("code",null,k)):void 0].filter(ue=>ue);return t.createElement(rt.Z,{key:`trans-${$}`},t.createElement(rt.Z.Heading,null,T,": ",D),W.length>0&&t.createElement(rt.Z.Meta,{className:s.transformationMeta},W),t.createElement(rt.Z.SecondaryActions,null,t.createElement(Me.K,{key:"edit",name:"edit","aria-label":"edit transformation",onClick:()=>{L($),E(!0)}}),t.createElement(Lo.e,{"aria-label":"delete transformation",onConfirm:()=>R(C.filter((ue,w)=>$!==w)),closeOnConfirm:!0})))}))))},zo=e=>({labelCollapseDetails:(0,h.css)({marginLeft:e.spacing(2),...e.typography.bodySmall,fontStyle:"italic"}),transformationAction:(0,h.css)({marginBottom:e.spacing(2)}),transformationMeta:(0,h.css)({alignItems:"baseline"})});var we=d(47232),Ho=d(24308),Mo=d(79041),Se=d(91052),Po=d(15162),$o=d(33368);function ko({width:e,height:o,timeZone:n,state:s,pluginId:a,frames:r,absoluteRange:i,splitOpenFn:l,eventBus:c}){const m=(0,t.useMemo)(()=>({from:(0,we.KQ)(i.from),to:(0,we.KQ)(i.to),raw:{from:(0,we.KQ)(i.from),to:(0,we.KQ)(i.to)}}),[i.from,i.to]),p=(0,Po.d4)(a),f={dataLinkPostProcessor:(0,$o.h)(l,m),eventBus:c,eventsScope:"explore"};return t.createElement(Mo.XF,{value:f},t.createElement(Se.NR,{title:p.name,width:e,height:o,loadingState:s},(g,y)=>t.createElement(Ho.m,{data:{series:r,state:s,timeRange:m},pluginId:a,title:"",width:g,height:y,timeZone:n})))}var je=d(41987),K=d(52622),on=d(60734),Bo=d(40961),Wo=function(){var e=function(o,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(s,a){s.__proto__=a}||function(s,a){for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(s[r]=a[r])},e(o,n)};return function(o,n){e(o,n);function s(){this.constructor=o}o.prototype=n===null?Object.create(n):(s.prototype=n.prototype,new s)}}(),_=function(){return _=Object.assign||function(e){for(var o,n=1,s=arguments.length;n
"u"?void 0:Number(s),maxHeight:typeof a>"u"?void 0:Number(a),minWidth:typeof r>"u"?void 0:Number(r),minHeight:typeof i>"u"?void 0:Number(i)}},Ko=["as","style","className","grid","snap","bounds","boundsByDirection","size","defaultSize","minWidth","minHeight","maxWidth","maxHeight","lockAspectRatio","lockAspectRatioExtraWidth","lockAspectRatioExtraHeight","enable","handleStyles","handleClasses","handleWrapperStyle","handleWrapperClass","children","onResizeStart","onResize","onResizeStop","handleComponent","scale","resizeRatio","snapGap"],cn="__resizable_base__",dn=function(e){Uo(o,e);function o(n){var s=e.call(this,n)||this;return s.ratio=1,s.resizable=null,s.parentLeft=0,s.parentTop=0,s.resizableLeft=0,s.resizableRight=0,s.resizableTop=0,s.resizableBottom=0,s.targetLeft=0,s.targetTop=0,s.appendBase=function(){if(!s.resizable||!s.window)return null;var a=s.parentNode;if(!a)return null;var r=s.window.document.createElement("div");return r.style.width="100%",r.style.height="100%",r.style.position="absolute",r.style.transform="scale(0, 0)",r.style.left="0",r.style.flex="0 0 100%",r.classList?r.classList.add(cn):r.className+=cn,a.appendChild(r),r},s.removeBase=function(a){var r=s.parentNode;r&&r.removeChild(a)},s.ref=function(a){a&&(s.resizable=a)},s.state={isResizing:!1,width:typeof(s.propsSize&&s.propsSize.width)>"u"?"auto":s.propsSize&&s.propsSize.width,height:typeof(s.propsSize&&s.propsSize.height)>"u"?"auto":s.propsSize&&s.propsSize.height,direction:"right",original:{x:0,y:0,width:0,height:0},backgroundStyle:{height:"100%",width:"100%",backgroundColor:"rgba(0,0,0,0)",cursor:"auto",opacity:0,position:"fixed",zIndex:9999,top:"0",left:"0",bottom:"0",right:"0"},flexBasis:void 0},s.onResizeStart=s.onResizeStart.bind(s),s.onMouseMove=s.onMouseMove.bind(s),s.onMouseUp=s.onMouseUp.bind(s),s}return Object.defineProperty(o.prototype,"parentNode",{get:function(){return this.resizable?this.resizable.parentNode:null},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"window",{get:function(){return!this.resizable||!this.resizable.ownerDocument?null:this.resizable.ownerDocument.defaultView},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"propsSize",{get:function(){return this.props.size||this.props.defaultSize||jo},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"size",{get:function(){var n=0,s=0;if(this.resizable&&this.window){var a=this.resizable.offsetWidth,r=this.resizable.offsetHeight,i=this.resizable.style.position;i!=="relative"&&(this.resizable.style.position="relative"),n=this.resizable.style.width!=="auto"?this.resizable.offsetWidth:a,s=this.resizable.style.height!=="auto"?this.resizable.offsetHeight:r,this.resizable.style.position=i}return{width:n,height:s}},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sizeStyle",{get:function(){var n=this,s=this.props.size,a=function(l){if(typeof n.state[l]>"u"||n.state[l]==="auto")return"auto";if(n.propsSize&&n.propsSize[l]&&n.propsSize[l].toString().endsWith("%")){if(n.state[l].toString().endsWith("%"))return n.state[l].toString();var c=n.getParentSize(),m=Number(n.state[l].toString().replace("px","")),p=m/c[l]*100;return p+"%"}return Ct(n.state[l])},r=s&&typeof s.width<"u"&&!this.state.isResizing?Ct(s.width):a("width"),i=s&&typeof s.height<"u"&&!this.state.isResizing?Ct(s.height):a("height");return{width:r,height:i}},enumerable:!1,configurable:!0}),o.prototype.getParentSize=function(){if(!this.parentNode)return this.window?{width:this.window.innerWidth,height:this.window.innerHeight}:{width:0,height:0};var n=this.appendBase();if(!n)return{width:0,height:0};var s=!1,a=this.parentNode.style.flexWrap;a!=="wrap"&&(s=!0,this.parentNode.style.flexWrap="wrap"),n.style.position="relative",n.style.minWidth="100%",n.style.minHeight="100%";var r={width:n.offsetWidth,height:n.offsetHeight};return s&&(this.parentNode.style.flexWrap=a),this.removeBase(n),r},o.prototype.bindEvents=function(){this.window&&(this.window.addEventListener("mouseup",this.onMouseUp),this.window.addEventListener("mousemove",this.onMouseMove),this.window.addEventListener("mouseleave",this.onMouseUp),this.window.addEventListener("touchmove",this.onMouseMove,{capture:!0,passive:!1}),this.window.addEventListener("touchend",this.onMouseUp))},o.prototype.unbindEvents=function(){this.window&&(this.window.removeEventListener("mouseup",this.onMouseUp),this.window.removeEventListener("mousemove",this.onMouseMove),this.window.removeEventListener("mouseleave",this.onMouseUp),this.window.removeEventListener("touchmove",this.onMouseMove,!0),this.window.removeEventListener("touchend",this.onMouseUp))},o.prototype.componentDidMount=function(){if(!(!this.resizable||!this.window)){var n=this.window.getComputedStyle(this.resizable);this.setState({width:this.state.width||this.size.width,height:this.state.height||this.size.height,flexBasis:n.flexBasis!=="auto"?n.flexBasis:void 0})}},o.prototype.componentWillUnmount=function(){this.window&&this.unbindEvents()},o.prototype.createSizeForCssProperty=function(n,s){var a=this.propsSize&&this.propsSize[s];return this.state[s]==="auto"&&this.state.original[s]===n&&(typeof a>"u"||a==="auto")?"auto":n},o.prototype.calculateNewMaxFromBoundary=function(n,s){var a=this.props.boundsByDirection,r=this.state.direction,i=a&&Pe("left",r),l=a&&Pe("top",r),c,m;if(this.props.bounds==="parent"){var p=this.parentNode;p&&(c=i?this.resizableRight-this.parentLeft:p.offsetWidth+(this.parentLeft-this.resizableLeft),m=l?this.resizableBottom-this.parentTop:p.offsetHeight+(this.parentTop-this.resizableTop))}else this.props.bounds==="window"?this.window&&(c=i?this.resizableRight:this.window.innerWidth-this.resizableLeft,m=l?this.resizableBottom:this.window.innerHeight-this.resizableTop):this.props.bounds&&(c=i?this.resizableRight-this.targetLeft:this.props.bounds.offsetWidth+(this.targetLeft-this.resizableLeft),m=l?this.resizableBottom-this.targetTop:this.props.bounds.offsetHeight+(this.targetTop-this.resizableTop));return c&&Number.isFinite(c)&&(n=n&&n
"u"?10:r.width,u=typeof a.width>"u"||a.width<0?n:a.width,f=typeof r.height>"u"?10:r.height,g=typeof a.height>"u"||a.height<0?s:a.height,y=c||0,v=m||0;if(l){var b=(f-y)*this.ratio+v,E=(g-y)*this.ratio+v,C=(p-v)/this.ratio+y,R=(u-v)/this.ratio+y,S=Math.max(p,b),L=Math.min(u,E),I=Math.max(f,C),H=Math.min(g,R);n=lt(n,S,L),s=lt(s,I,H)}else n=lt(n,p,u),s=lt(s,f,g);return{newWidth:n,newHeight:s}},o.prototype.setBoundingClientRect=function(){if(this.props.bounds==="parent"){var n=this.parentNode;if(n){var s=n.getBoundingClientRect();this.parentLeft=s.left,this.parentTop=s.top}}if(this.props.bounds&&typeof this.props.bounds!="string"){var a=this.props.bounds.getBoundingClientRect();this.targetLeft=a.left,this.targetTop=a.top}if(this.resizable){var r=this.resizable.getBoundingClientRect(),i=r.left,l=r.top,c=r.right,m=r.bottom;this.resizableLeft=i,this.resizableRight=c,this.resizableTop=l,this.resizableBottom=m}},o.prototype.onResizeStart=function(n,s){if(!(!this.resizable||!this.window)){var a=0,r=0;if(n.nativeEvent&&Go(n.nativeEvent)?(a=n.nativeEvent.clientX,r=n.nativeEvent.clientY):n.nativeEvent&&ct(n.nativeEvent)&&(a=n.nativeEvent.touches[0].clientX,r=n.nativeEvent.touches[0].clientY),this.props.onResizeStart&&this.resizable){var i=this.props.onResizeStart(n,s,this.resizable);if(i===!1)return}this.props.size&&(typeof this.props.size.height<"u"&&this.props.size.height!==this.state.height&&this.setState({height:this.props.size.height}),typeof this.props.size.width<"u"&&this.props.size.width!==this.state.width&&this.setState({width:this.props.size.width})),this.ratio=typeof this.props.lockAspectRatio=="number"?this.props.lockAspectRatio:this.size.width/this.size.height;var l,c=this.window.getComputedStyle(this.resizable);if(c.flexBasis!=="auto"){var m=this.parentNode;if(m){var p=this.window.getComputedStyle(m).flexDirection;this.flexDir=p.startsWith("row")?"row":"column",l=c.flexBasis}}this.setBoundingClientRect(),this.bindEvents();var u={original:{x:a,y:r,width:this.size.width,height:this.size.height},isResizing:!0,backgroundStyle:fe(fe({},this.state.backgroundStyle),{cursor:this.window.getComputedStyle(n.target).cursor||"auto"}),direction:s,flexBasis:l};this.setState(u)}},o.prototype.onMouseMove=function(n){var s=this;if(!(!this.state.isResizing||!this.resizable||!this.window)){if(this.window.TouchEvent&&ct(n))try{n.preventDefault(),n.stopPropagation()}catch{}var a=this.props,r=a.maxWidth,i=a.maxHeight,l=a.minWidth,c=a.minHeight,m=ct(n)?n.touches[0].clientX:n.clientX,p=ct(n)?n.touches[0].clientY:n.clientY,u=this.state,f=u.direction,g=u.original,y=u.width,v=u.height,b=this.getParentSize(),E=qo(b,this.window.innerWidth,this.window.innerHeight,r,i,l,c);r=E.maxWidth,i=E.maxHeight,l=E.minWidth,c=E.minHeight;var C=this.calculateNewSizeFromDirection(m,p),R=C.newHeight,S=C.newWidth,L=this.calculateNewMaxFromBoundary(r,i);this.props.snap&&this.props.snap.x&&(S=ln(S,this.props.snap.x,this.props.snapGap)),this.props.snap&&this.props.snap.y&&(R=ln(R,this.props.snap.y,this.props.snapGap));var I=this.calculateNewSizeFromAspectRatio(S,R,{width:L.maxWidth,height:L.maxHeight},{width:l,height:c});if(S=I.newWidth,R=I.newHeight,this.props.grid){var H=rn(S,this.props.grid[0]),z=rn(R,this.props.grid[1]),$=this.props.snapGap||0;S=$===0||Math.abs(H-S)<=$?H:S,R=$===0||Math.abs(z-R)<=$?z:R}var D={width:S-g.width,height:R-g.height};if(y&&typeof y=="string"){if(y.endsWith("%")){var T=S/b.width*100;S=T+"%"}else if(y.endsWith("vw")){var k=S/this.window.innerWidth*100;S=k+"vw"}else if(y.endsWith("vh")){var Z=S/this.window.innerHeight*100;S=Z+"vh"}}if(v&&typeof v=="string"){if(v.endsWith("%")){var T=R/b.height*100;R=T+"%"}else if(v.endsWith("vw")){var k=R/this.window.innerWidth*100;R=k+"vw"}else if(v.endsWith("vh")){var Z=R/this.window.innerHeight*100;R=Z+"vh"}}var W={width:this.createSizeForCssProperty(S,"width"),height:this.createSizeForCssProperty(R,"height")};this.flexDir==="row"?W.flexBasis=W.width:this.flexDir==="column"&&(W.flexBasis=W.height),(0,Bo.flushSync)(function(){s.setState(W)}),this.props.onResize&&this.props.onResize(n,f,this.resizable,D)}},o.prototype.onMouseUp=function(n){var s=this.state,a=s.isResizing,r=s.direction,i=s.original;if(!(!a||!this.resizable)){var l={width:this.size.width-i.width,height:this.size.height-i.height};this.props.onResizeStop&&this.props.onResizeStop(n,r,this.resizable,l),this.props.size&&this.setState(this.props.size),this.unbindEvents(),this.setState({isResizing:!1,backgroundStyle:fe(fe({},this.state.backgroundStyle),{cursor:"auto"})})}},o.prototype.updateSize=function(n){this.setState({width:n.width,height:n.height})},o.prototype.renderResizer=function(){var n=this,s=this.props,a=s.enable,r=s.handleStyles,i=s.handleClasses,l=s.handleWrapperStyle,c=s.handleWrapperClass,m=s.handleComponent;if(!a)return null;var p=Object.keys(a).map(function(u){return a[u]!==!1?t.createElement(Qo,{key:u,direction:u,onResizeStart:n.onResizeStart,replaceStyles:r&&r[u],className:i&&i[u]},m&&m[u]?m[u]:null):null});return t.createElement("div",{className:c,style:l},p)},o.prototype.render=function(){var n=this,s=Object.keys(this.props).reduce(function(i,l){return Ko.indexOf(l)!==-1||(i[l]=n.props[l]),i},{}),a=fe(fe(fe({position:"relative",userSelect:this.state.isResizing?"none":"auto"},this.props.style),this.sizeStyle),{maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight,minWidth:this.props.minWidth,minHeight:this.props.minHeight,boxSizing:"border-box",flexShrink:0});this.state.flexBasis&&(a.flexBasis=this.state.flexBasis);var r=this.props.as||"div";return t.createElement(r,fe({ref:this.ref,style:a,className:this.props.className},s),this.state.isResizing&&t.createElement("div",{style:this.state.backgroundStyle}),this.props.children,this.renderResizer())},o.defaultProps={as:"div",onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},enable:{top:!0,right:!0,bottom:!0,left:!0,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},style:{},grid:[1,1],lockAspectRatio:!1,lockAspectRatioExtraWidth:0,lockAspectRatioExtraHeight:0,scale:1,resizeRatio:1,snapGap:0},o}(t.PureComponent),Zo=d(69144);function un(e){const{width:o,children:n,onResize:s}=e,a=(0,N.$j)(),r=(0,N.of)(Jo),i=(0,Zo.l)(a),l=`${o+31.5}px`;return t.createElement(dn,{className:(0,h.cx)(r.fixed,r.container,r.drawerActive),defaultSize:{width:l,height:`${a.components.horizontalDrawer.defaultHeight}px`},handleClasses:{top:i.dragHandleHorizontal},enable:{top:!0,right:!1,bottom:!1,left:!1,topRight:!1,bottomRight:!1,bottomLeft:!1,topLeft:!1},maxHeight:"100vh",maxWidth:l,minWidth:l,onResize:s},n)}const Yo=e=>(0,h.keyframes)` 0% { transform: translateY(${e.components.horizontalDrawer.defaultHeight}px); } 100% { transform: translateY(0px); } `,Jo=e=>({fixed:(0,h.css)({position:"fixed !important"}),container:(0,h.css)({bottom:0,background:e.colors.background.primary,borderTop:`1px solid ${e.colors.border.weak}`,margin:e.spacing(0,-2,0,-2),boxShadow:e.shadows.z3,zIndex:e.zIndex.navbarFixed}),drawerActive:(0,h.css)({opacity:1,animation:`0.5s ease-out ${Yo(e)}`})});var Xo=d(61453),_o=d(82344),es=d(61396),ts=d(32067),ns=d(90820);function os(e){const{width:o,onClose:n,queryResponse:s,timeZone:a,isMixed:r,exploreId:i}=e,[l,c]=(0,t.useState)({withTransforms:!1,withFieldConfig:!0}),m=s?.series||[];let p=s?.errors;!p?.length&&s?.error&&(p=[s.error]),(0,t.useEffect)(()=>{(0,P.rR)("grafana_explore_query_inspector_opened")},[]);const u={label:"Stats",value:"stats",icon:"chart-line",content:t.createElement(ts.N,{data:s,timeZone:s?.request?.timezone??K.vp})},f={label:"JSON",value:"json",icon:"brackets-curly",content:t.createElement(es.w,{data:s,onClose:n})},g={label:"Data",value:"data",icon:"database",content:t.createElement(Xo.q,{data:m,dataName:"Explore",isLoading:s.state===le.Gu.Loading,options:l,timeZone:a,app:je.Jk.Explore,formattedDataDescription:"Matches the format in the panel",onOptionsChange:c})},y={label:"Query",value:"query",icon:"info-circle",content:t.createElement(ns.e,{instanceId:r?(0,et.qM)(0,(0,Be.uq)(i)):(0,Be.uq)(i),data:s,onRefreshQuery:()=>e.runQueries({exploreId:i})})},v=[u,y,f,g];if(p?.length){const b={label:"Error",value:"error",icon:"exclamation-triangle",content:t.createElement(_o.y,{errors:p})};v.push(b)}return t.createElement(un,{width:o},t.createElement(on.q,{tabs:v,onClose:n,closeIconTooltip:"Close query inspector"}))}function ss(e,{exploreId:o}){const s=e.explore.panes[o],{queryResponse:a}=s;return{queryResponse:a}}const as={runQueries:q.Od},rs=(0,me.connect)(ss,as)(os);var is=d(67570),ls=d(95247),ae=d(27746),pn=d(19727),ut=d(11134),cs=d(75269),x=d(44836),ds=d(51612),Rt=d(76698),ce=d(64756),wt=d(10096),hn=d(81862),mn=d(85858),us=d(25573),gn=d(80582);function ps(e){const{onClick:o,isSynced:n}=e,s=()=>{const{isSynced:a}=e,r=a?"Unsync all views":"Sync all views to this time range";return t.createElement(t.Fragment,null,r)};return t.createElement(he.m,{content:s,placement:"bottom"},t.createElement(ae.I,{icon:"link",variant:n?"active":"canvas","aria-label":n?"Synced times":"Unsynced times",onClick:o}))}class hs extends t.Component{constructor(){super(...arguments),this.onMoveTimePicker=o=>{const{range:n,onChangeTime:s,timeZone:a}=this.props,{from:r,to:i}=(0,gn.Wb)(o,n),l={from:(0,we.oZ)(a,r),to:(0,we.oZ)(a,i)};s(l)},this.onMoveForward=()=>this.onMoveTimePicker(1),this.onMoveBack=()=>this.onMoveTimePicker(-1),this.onChangeTimePicker=o=>{const n=mn.isMathString(o.raw.from)?o.raw.from:o.from,s=mn.isMathString(o.raw.to)?o.raw.to:o.to;this.props.onChangeTime({from:n,to:s}),(0,P.rR)("grafana_explore_time_picker_time_range_changed",{timeRangeFrom:n,timeRangeTo:s})},this.onZoom=()=>{const{range:o,onChangeTime:n,timeZone:s}=this.props,{from:a,to:r}=(0,gn.Zk)(o,2),i={from:(0,we.oZ)(s,a),to:(0,we.oZ)(s,r)};n(i)}}render(){const{range:o,timeZone:n,fiscalYearStartMonth:s,splitted:a,syncedTimes:r,onChangeTimeSync:i,hideText:l,onChangeTimeZone:c,onChangeFiscalYearStartMonth:m}=this.props,p=a?t.createElement(ps,{onClick:i,isSynced:r}):void 0,u={value:o,timeZone:n,fiscalYearStartMonth:s,onMoveBackward:this.onMoveBack,onMoveForward:this.onMoveForward,onZoom:this.onZoom,hideText:l};return t.createElement(us.m,{isOnCanvas:!0,...u,timeSyncButton:p,isSynced:r,widthOverride:a?window.innerWidth/2:void 0,onChange:this.onChangeTimePicker,onChangeTimeZone:c,onChangeFiscalYearStartMonth:m})}}var fn=d(86634);function ms(e){const{start:o,pause:n,resume:s,isLive:a,isPaused:r,stop:i,splitted:l}=e,c=a&&!r?"active":"canvas",m=a?r?s:n:o;return t.createElement(pn.e,null,t.createElement(he.m,{content:a&&!r?t.createElement(t.Fragment,null,"Pause the live stream"):t.createElement(t.Fragment,null,"Start live stream your logs"),placement:"bottom"},t.createElement(ae.I,{iconOnly:l,variant:c,icon:!a||r?"play":"pause",onClick:m},a&&r?"Paused":"Live")),t.createElement(fn.A,{mountOnEnter:!0,unmountOnExit:!0,timeout:100,in:a,classNames:{enter:pt.stopButtonEnter,enterActive:pt.stopButtonEnterActive,exit:pt.stopButtonExit,exitActive:pt.stopButtonExitActive}},t.createElement(he.m,{content:t.createElement(t.Fragment,null,"Stop and exit the live stream"),placement:"bottom"},t.createElement(ae.I,{variant:c,onClick:i,icon:"square-shape"}))))}const pt={stopButtonEnter:(0,h.css)({label:"stopButtonEnter",width:0,opacity:0,overflow:"hidden"}),stopButtonEnterActive:(0,h.css)({label:"stopButtonEnterActive",opacity:1,width:"32px"}),stopButtonExit:(0,h.css)({label:"stopButtonExit",width:"32px",opacity:1,overflow:"hidden"}),stopButtonExitActive:(0,h.css)({label:"stopButtonExitActive",opacity:0,width:0})};var $e=d(38138),gs=d(59093),fs=d(15068),Tt=d(83122),Lt=d(7030),Ie=d(96192);const ys={key:"copy-link",label:(0,x.t)("explore.toolbar.copy-shortened-link","Copy shortened URL"),icon:"share-alt",getUrl:()=>{},shorten:!0,absTime:!1};function vs(){const e=(0,O.useSelector)(J.Qb),[o,n]=(0,t.useState)(!1),[s,a]=(0,t.useState)(ys),r=(c,m,p)=>{c?((0,Lt.V)(p||d.g.location.href),(0,P.rR)("grafana_explore_shortened_link_clicked",{isAbsoluteTime:m})):((0,Be.uJ)(p!==void 0?`${window.location.protocol}//${window.location.host}${V.$.appSubUrl}${p}`:d.g.location.href),(0,P.rR)("grafana_explore_copy_link_clicked",{isAbsoluteTime:m}))},i=[{key:"normal",label:(0,x.t)("explore.toolbar.copy-links-normal-category","Normal URL links"),items:[{key:"copy-shortened-link",icon:"link",label:(0,x.t)("explore.toolbar.copy-shortened-link","Copy shortened URL"),getUrl:()=>{},shorten:!0,absTime:!1},{key:"copy-link",icon:"link",label:(0,x.t)("explore.toolbar.copy-link","Copy URL"),getUrl:()=>{},shorten:!1,absTime:!1}]},{key:"timesync",label:(0,x.t)("explore.toolbar.copy-links-absolute-category","Time-sync URL links (share with time range intact)"),items:[{key:"copy-short-link-abs-time",icon:"clock-nine",label:(0,x.t)("explore.toolbar.copy-shortened-link-abs-time","Copy Absolute Shortened URL"),shorten:!0,getUrl:()=>(0,Ie._O)(e),absTime:!0},{key:"copy-link-abs-time",icon:"clock-nine",label:(0,x.t)("explore.toolbar.copy-link-abs-time","Copy Absolute Shortened URL"),shorten:!1,getUrl:()=>(0,Ie._O)(e),absTime:!0}]}],l=t.createElement($e.W,null,i.map(c=>t.createElement(gs.r,{key:c.key,label:c.label},c.items.map(m=>t.createElement($e.W.Item,{key:m.key,label:m.label,icon:m.icon,onClick:()=>{const p=m.getUrl();r(m.shorten,m.absTime,p),a(m)}})))));return t.createElement(fs.U,null,t.createElement(Qe.B,{gap:0,direction:"row",alignItems:"center",wrap:"nowrap"},t.createElement(ae.I,{tooltip:s.label,icon:s.icon,iconOnly:!0,narrow:!0,onClick:()=>{const c=s.getUrl();r(s.shorten,s.absTime,c)},"aria-label":(0,x.t)("explore.toolbar.copy-shortened-link","Copy shortened URL")}),t.createElement(Tt.m,{overlay:l,placement:"bottom-end",onVisibleChange:n},t.createElement(ae.I,{narrow:!0,isOpen:o,"aria-label":(0,x.t)("explore.toolbar.copy-shortened-link-menu","Open copy link options")}))))}var Es=d(1933),bs=d(74135),xs=d(4402),Ss=d(24401),Cs=d(30973);const Rs=(0,t.lazy)(()=>d.e(4787).then(d.bind(d,74787)).then(({AddToDashboard:e})=>({default:e})));function ws(e){const{exploreId:o,splitted:n}=e,[s,a]=(0,t.useState)(),[r,i]=(0,t.useState)(!1),l=Ts(e),c=Ls(l),m=(0,J.qq)(o),p=(0,O.useSelector)(m)?.queries?.length;if(c.length<=1)return _e.TP.hasPermission(O.AccessControlAction.DashboardsCreate)||_e.TP.hasPermission(O.AccessControlAction.DashboardsWrite)?t.createElement(t.Suspense,{fallback:null},t.createElement(Rs,{exploreId:o})):null;const u=t.createElement(Cs.w,{extensions:c,onSelect:a});return t.createElement(t.Fragment,null,t.createElement(Tt.m,{onVisibleChange:i,placement:"bottom-start",overlay:u},t.createElement(ae.I,{"aria-label":"Add",icon:"plus",disabled:!p,variant:"canvas",isOpen:r},n?" ":"Add")),!!s&&!!s.path&&t.createElement(Ss.s,{path:s.path,title:s.title,onDismiss:()=>a(void 0)}))}function Ts(e){const{exploreId:o,timeZone:n}=e,a=(0,O.useSelector)(J.vC)?.editorMode||!1,{queries:r,queryResponse:i,range:l}=(0,O.useSelector)((0,J.qq)(o)),c=(0,O.useSelector)((0,J.Jr)(o)),m=r.map(f=>f?.datasource?.uid).filter(f=>f!==void 0),p=[...new Set(m)].length,u=_e.TP.hasPermission(O.AccessControlAction.DataSourcesWrite);return(0,t.useMemo)(()=>({exploreId:o,targets:r,data:i,timeRange:l.raw,timeZone:(0,Es.O)({timeZone:n}),shouldShowAddCorrelation:V.$.featureToggles.correlations===!0&&u&&!a&&c&&p===1}),[o,r,i,l.raw,n,u,a,c,p])}function Ls(e){return(0,t.useMemo)(()=>{const{extensions:o}=(0,xs.Kf)({extensionPointId:bs.S.ExploreToolbarAction,context:e,limitPerPlugin:3});return o},[e])}var de=d(89224);function Is(e){const o=(0,O.useDispatch)(),n=(0,t.useCallback)(()=>{o((0,q.qk)({exploreId:e,isPaused:!0}))},[e,o]),s=(0,t.useCallback)(()=>{o((0,q.qk)({exploreId:e,isPaused:!1}))},[e,o]),a=(0,t.useCallback)(()=>{n(),o((0,de.hO)({exploreId:e,refreshInterval:ut.cC.offOption.value})),o((0,q.Od)({exploreId:e}))},[e,o,n]),r=(0,t.useCallback)(()=>{o((0,de.hO)({exploreId:e,refreshInterval:ut.cC.liveOption.value}))},[e,o]),i=(0,t.useCallback)(()=>{o((0,q.rR)({exploreId:e}))},[e,o]);return{pause:n,resume:s,stop:a,start:r,clear:i}}function yn(e){const o=Is(e.exploreId);return e.children(o)}const Fs=(e,o)=>({rotateIcon:(0,h.css)({"> div > svg":{transform:"rotate(180deg)"}}),toolbarButton:(0,h.css)({display:"flex",justifyContent:"center",marginRight:e.spacing(.5),width:o&&e.spacing(6)})});function Os({exploreId:e,onChangeTime:o,onContentOutlineToogle:n,isContentOutlineOpen:s}){const a=(0,ce.wA)(),r=(0,ce.d4)(J.pF),i=(0,N.of)(Fs,r),l=(0,ce.d4)(F=>(0,st.O)(F.user)),c=(0,ce.d4)(F=>(0,st.q)(F.user)),{refreshInterval:m,datasourceInstance:p,range:u,isLive:f,isPaused:g,syncedTimes:y}=(0,ce.d4)(F=>({...(0,te.pick)(F.explore.panes[e],"refreshInterval","datasourceInstance","range","isLive","isPaused"),syncedTimes:F.explore.syncedTimes}),me.shallowEqual),v=(0,ce.d4)((0,q.h1)(e)),b=(0,ce.d4)(F=>F.explore.largerExploreId===e),E=(0,ce.d4)(F=>r||F.explore.panes[e].containerWidth<1210),C=(0,ce.d4)(F=>F.explore.panes[e].containerWidth<(r?700:800)),R=(0,ce.d4)(J.K6),S=(0,ce.d4)(J.vC),L=S?.editorMode||!1,I=(0,ce.d4)((0,J.Jr)(e)),H=(0,t.useMemo)(()=>I&&b||!I&&!b,[I,b]),z=v?(0,x.t)("explore.toolbar.refresh-picker-cancel","Cancel"):(0,x.t)("explore.toolbar.refresh-picker-run","Run query"),$=async F=>{L?S?.correlationDirty||S?.queryEditorDirty?a((0,G.am)({isExiting:!0,postConfirmAction:{exploreId:e,action:Rt.IW.CHANGE_DATASOURCE,changeDatasourceUid:F.uid,isActionLeft:I}})):(I&&R.forEach(Q=>{a((0,be.nE)({exploreId:Q[0],correlationEditorHelperData:void 0}))}),a((0,Ne.wh)({exploreId:e,datasource:F.uid,options:{importQueries:!0}}))):a((0,Ne.wh)({exploreId:e,datasource:F.uid,options:{importQueries:!0}}))},D=(F=!1)=>a(F?(0,q.hS)(e):(0,q.Od)({exploreId:e})),T=F=>a((0,hn.Cj)(F)),k=()=>{a((0,G.ve)()),(0,P.rR)("grafana_explore_split_view_opened",{origin:"menu"})},Z=()=>{L?S?.correlationDirty||S?.queryEditorDirty?a((0,G.am)({isExiting:!0,postConfirmAction:{exploreId:e,action:Rt.IW.CLOSE_PANE,isActionLeft:I}})):(R.forEach(F=>{a((0,be.nE)({exploreId:F[0],correlationEditorHelperData:void 0}))}),a((0,G.J8)(e)),(0,P.rR)("grafana_explore_split_view_closed")):(a((0,G.J8)(e)),(0,P.rR)("grafana_explore_split_view_closed"))},W=()=>{a(b?(0,G.JA)():(0,G.tP)({exploreId:e}))},ue=()=>{a((0,de.iO)(e))},w=F=>a((0,hn.c1)(F)),A=F=>{a((0,de.hO)({exploreId:e,refreshInterval:F}))},M=[t.createElement(vs,{key:"share"}),t.createElement("div",{style:{flex:1},key:"spacer0"})];return t.createElement("div",null,m&&t.createElement(is.u,{func:D,interval:m,loading:v}),t.createElement("div",null,t.createElement(cs.H,{actions:M})),t.createElement(ls.d,{"aria-label":(0,x.t)("explore.toolbar.aria-label","Explore toolbar"),leftItems:[V.$.featureToggles.exploreContentOutline&&t.createElement(ae.I,{key:"content-outline",variant:"canvas",tooltip:"Content outline",icon:"list-ui-alt",iconOnly:r,onClick:n,"aria-expanded":s,"aria-controls":s?"content-outline-container":void 0,className:i.toolbarButton},"Outline"),t.createElement(ds.s,{key:`${e}-ds-picker`,mixed:!L,onChange:$,current:p?.getRef(),hideTextValue:C,width:C?8:void 0})].filter(Boolean),forceShowLeftItems:!0},[r?t.createElement(pn.e,{key:"split-controls"},t.createElement(ae.I,{variant:"canvas",tooltip:b?(0,x.t)("explore.toolbar.split-narrow","Narrow pane"):(0,x.t)("explore.toolbar.split-widen","Widen pane"),onClick:W,icon:b?"gf-movepane-left":"gf-movepane-right",iconOnly:!0,className:(0,h.cx)(H&&i.rotateIcon)}),t.createElement(ae.I,{tooltip:(0,x.t)("explore.toolbar.split-close-tooltip","Close split pane"),onClick:Z,icon:"times",variant:"canvas"},t.createElement(x.x6,{i18nKey:"explore.toolbar.split-close"}," Close "))):t.createElement(ae.I,{variant:"canvas",key:"split",tooltip:(0,x.t)("explore.toolbar.split-tooltip","Split the pane"),onClick:k,icon:"columns",disabled:f},t.createElement(x.x6,{i18nKey:"explore.toolbar.split-title"},"Split")),t.createElement(ws,{splitted:r,key:"toolbar-extension-point",exploreId:e,timeZone:l}),!f&&t.createElement(hs,{key:"timeControls",exploreId:e,range:u,timeZone:l,fiscalYearStartMonth:c,onChangeTime:o,splitted:r,syncedTimes:y,onChangeTimeSync:ue,hideText:E,onChangeTimeZone:T,onChangeFiscalYearStartMonth:w}),t.createElement(ut.cC,{key:"refreshPicker",onIntervalChanged:A,value:m,isLoading:v,text:E?void 0:z,tooltip:E?z:void 0,intervals:wt.TP.getValidIntervals(ut.cb),isLive:f,onRefresh:()=>D(v),noIntervalPicker:f,primary:!0,width:(E?35:108)+"px"}),p?.meta.streaming&&t.createElement(yn,{key:"liveControls",exploreId:e},F=>{const Q={...F,start:()=>{(0,P.rR)("grafana_explore_logs_live_tailing_clicked",{datasourceType:p?.type}),F.start()}};return t.createElement(ms,{splitted:r,isLive:f,isPaused:g,start:Q.start,pause:Q.pause,resume:Q.resume,stop:Q.stop})})].filter(Boolean)))}var Ds=d(85194);function ht(e,o={}){(0,P.rR)(`grafana_flamegraph_${e}`,{app:je.Jk.Unknown,grafana_version:V.$.buildInfo.version,...o})}const As=e=>{const o=(0,N.of)(n=>Ns(n));return t.createElement("div",{className:o.container},t.createElement(Ds.A,{data:e.dataFrames[0],stickyHeader:!0,getTheme:()=>V.$.theme2,onTableSymbolClick:()=>ht("table_item_selected"),onViewSelected:n=>ht("view_selected",{view:n}),onTextAlignSelected:n=>ht("text_align_selected",{align:n}),onTableSort:n=>ht("table_sort_selected",{sort:n}),disableCollapsing:!V.$.featureToggles.flameGraphItemCollapsing}))},Ns=e=>({container:(0,h.css)({background:e.colors.background.primary,display:"flow-root",padding:e.spacing(0,1,1,1),border:`1px solid ${e.components.panel.borderColor}`,borderRadius:e.shape.radius.default})});var zs=d(72519),vn=d(84140),It=d(72724),Hs=d(85492),Ms=d(77020),Te=d(91002),Ps=d(10940),$s=d(97814);const En=150,ks=({resetKey:e,humanize:o,className:n})=>{const[s,a]=(0,t.useState)(0);return(0,Ps.A)(()=>a(s+En),En),(0,t.useEffect)(()=>a(0),[e]),t.createElement($s.g,{timeInMs:s,className:n,humanize:o})};var Bs=d(34028);const Ws=e=>({logsRowsLive:(0,h.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:(0,h.css)` label: logs-row-fresh; color: ${e.colors.text}; background-color: ${(0,vn.A)(e.colors.info.transparent).setAlpha(.25).toString()}; animation: fade 1s ease-out 1s 1 normal forwards; @keyframes fade { from { background-color: ${(0,vn.A)(e.colors.info.transparent).setAlpha(.25).toString()}; } to { background-color: transparent; } } `,logsRowsIndicator:(0,h.css)` font-size: ${e.typography.h6.fontSize}; padding-top: ${e.spacing(1)}; display: flex; align-items: center; `,button:(0,h.css)` margin-right: ${e.spacing(1)}; `,fullWidth:(0,h.css)` width: 100%; `});class Vs extends t.PureComponent{constructor(o){super(o),this.liveEndDiv=null,this.scrollContainerRef=t.createRef(),this.onScroll=n=>{const{isPaused:s,onPause:a}=this.props,{scrollTop:r,clientHeight:i,scrollHeight:l}=n.currentTarget;l-(r+i)>=5&&!s&&a()},this.rowsToRender=()=>{const{isPaused:n}=this.props;let{logRowsToRender:s=[]}=this.state;return n||(s=(0,Te.oR)(s,K.uH.Ascending).slice(-100)),s},this.state={logRowsToRender:o.logRows}}static getDerivedStateFromProps(o,n){return o.isPaused&&o.clearedAtIndex?{logRowsToRender:(0,Bs.pg)(o.clearedAtIndex,n.logRowsToRender)}:o.isPaused?null:{logRowsToRender:o.logRows}}render(){const{theme:o,timeZone:n,onPause:s,onResume:a,onClear:r,isPaused:i}=this.props,l=Ws(o),{logsRow:c,logsRowLocalTime:m,logsRowMessage:p}=(0,Ms.D)(o);return t.createElement("div",null,t.createElement("table",{className:l.fullWidth},t.createElement("tbody",{onScroll:i?void 0:this.onScroll,className:l.logsRowsLive,ref:this.scrollContainerRef},this.rowsToRender().map(u=>t.createElement("tr",{className:(0,h.cx)(c,l.logsRowFade),key:u.uid},t.createElement("td",{className:m},(0,It.LE)(u.timeEpochMs,{timeZone:n})),t.createElement("td",{className:p},u.hasAnsi?t.createElement(Hs.$,{value:u.raw}):u.entry))),t.createElement("tr",{ref:u=>{this.liveEndDiv=u,this.liveEndDiv&&this.scrollContainerRef.current?.scrollTo&&!i&&this.scrollContainerRef.current?.scrollTo(0,this.scrollContainerRef.current.scrollHeight)}}))),t.createElement("div",{className:l.logsRowsIndicator},t.createElement(j.$n,{icon:i?"play":"pause",variant:"secondary",onClick:i?a:s,className:l.button},i?"Resume":"Pause"),t.createElement(j.$n,{icon:"trash-alt",variant:"secondary",onClick:r,className:l.button},"Clear logs"),t.createElement(j.$n,{icon:"square-shape",variant:"secondary",onClick:this.props.stopLive,className:l.button},"Exit live mode"),i||this.rowsToRender().length>0&&t.createElement("span",null,"Last line received: ",t.createElement(ks,{resetKey:this.props.logRows,humanize:!0})," ago")))}}const Qs=(0,N.cV)(Vs);var bn=d(69129),xn=d(76885),Ge=d(65879),mt=d(94354),Us=d(39268),ye=d(14186),Fe=d(15292),ne=d(33390),Sn=d(81073);const js=({children:e,loading:o,loadMoreLogs:n,range:s,rows:a,scrollElement:r,sortOrder:i,timeZone:l})=>{const[c,m]=(0,t.useState)(!1),[p,u]=(0,t.useState)(!1),[f,g]=(0,t.useState)(!1),[y,v]=(0,t.useState)(!1),b=(0,t.useRef)(a),E=(0,t.useRef)(r?.scrollTop||0);(0,t.useEffect)(()=>{m(!1),u(!1)},[s,a,i]),(0,t.useEffect)(()=>{o||(g(!1),v(!1))},[o]),(0,t.useEffect)(()=>{y&&r&&r.scrollTo(0,r.scrollHeight-r.clientHeight)},[y,r]),(0,t.useEffect)(()=>{a!==b.current&&a.length===b.current.length&&(f||y)&&(i===K.uH.Descending&&y?u(!0):i===K.uH.Ascending&&f&&m(!0)),b.current=a},[y,a,i,f]),(0,t.useEffect)(()=>{if(!r||!n)return;function S(H){if(!r||!n||!a.length||o||!V.$.featureToggles.logsInfiniteScrolling)return;H.stopImmediatePropagation();const z=Ks(H,r,E.current);E.current=r.scrollTop,z!==0&&(z===-1?L():I())}function L(){const H=Zs(Rn(a),s,l,i);if(!H){m(!0);return}m(!1),n?.(H),g(!0),(0,P.rR)("grafana_logs_infinite_scrolling",{direction:"top",sort_order:i})}function I(){const H=Ys(Rn(a),s,l,i);if(!H){u(!0);return}u(!1),n?.(H),v(!0),(0,P.rR)("grafana_logs_infinite_scrolling",{direction:"bottom",sort_order:i})}return r.addEventListener("scroll",S),r.addEventListener("wheel",S),()=>{r.removeEventListener("scroll",S),r.removeEventListener("wheel",S)}},[n,o,s,a,r,i,l]);const C=i===K.uH.Descending&&(0,Ge.isRelativeTime)(s.raw.to),R=i===K.uH.Ascending&&(0,Ge.isRelativeTime)(s.raw.to);return t.createElement(t.Fragment,null,f&&t.createElement(Sn.I,{adjective:i===K.uH.Descending?"newer":"older"}),!C&&c&&Cn,e,!R&&p&&Cn,y&&t.createElement(Sn.I,{adjective:i===K.uH.Descending?"older":"newer"}))},Gs={messageContainer:(0,h.css)({textAlign:"center",padding:.25})},Cn=t.createElement("div",{className:Gs.messageContainer,"data-testid":"end-of-range"},"End of the selected time range.");var qs=(e=>(e[e.Top=-1]="Top",e[e.Bottom=1]="Bottom",e[e.NoScroll=0]="NoScroll",e))(qs||{});function Ks(e,o,n){if(o.scrollHeight<=o.clientHeight)return 0;const s=e instanceof WheelEvent?e.deltaY:o.scrollTop-n;if(s===0)return 0;const a=s<0?-1:1;return(a===-1?o.scrollTop:o.scrollHeight-o.scrollTop-o.clientHeight)<=1?a:0}function Rn(e){const o=e[0].timeEpochMs,n=e[e.length-1].timeEpochMs;return n
gt?Tn(e,o,n):void 0):Math.abs(o.from.valueOf()-e.from)>gt?wn(e,o):void 0}function Ys(e,o,n,s){return s===K.uH.Descending?Math.abs(o.from.valueOf()-e.from)>gt?wn(e,o):void 0:(o=Ft(o,n),o.to.valueOf()-e.to>gt?Tn(e,o,n):void 0)}function Ft(e,o){return(0,Ge.isRelativeTimeRange)(e.raw)?(0,Ge.convertRawToRange)(e.raw,o):e}var Le=d(99140),Ln=d(14647),Js=d(81166),Ot=d(69147),In=d(80252);function Xs({feedbackUrl:e}){const o=(0,N.of)(_s);return t.createElement(Qe.B,null,t.createElement("a",{href:e,className:o.link,title:"The logs table is new, please let us know how we can improve it",target:"_blank",rel:"noreferrer noopener"},t.createElement(ie.I,{name:"comment-alt-message"})," Give feedback"))}function _s(e){return{link:(0,h.css)({color:e.colors.text.secondary,fontSize:e.typography.bodySmall.fontSize,":hover":{color:e.colors.text.link}})}}var ea=d(4213),ta=d.n(ea),Fn=d(75505),On=d(2514),Dn=d(80287),na=d(93463),oa=d(40455);const An=e=>({metaContainer:(0,h.css)({flex:1,color:e.colors.text.secondary,marginBottom:e.spacing(2),minWidth:"30%",display:"flex",flexWrap:"wrap"}),metaItem:(0,h.css)({marginRight:e.spacing(2),marginTop:e.spacing(.5),display:"flex",alignItems:"center",[".logs-meta-item__error"]:{color:e.colors.error.text}}),metaLabel:(0,h.css)({marginRight:`calc(${e.spacing(2)} / 2)`,fontSize:e.typography.bodySmall.fontSize,fontWeight:e.typography.fontWeightMedium}),metaValue:(0,h.css)({fontFamily:e.typography.fontFamilyMonospace,fontSize:e.typography.bodySmall.fontSize})}),sa=(0,t.memo)(function(o){const n=(0,N.of)(An),{label:s,value:a}=o;return t.createElement("div",{"data-testid":"meta-info-text-item",className:n.metaItem},s&&t.createElement("span",{className:n.metaLabel},s,":"),t.createElement("span",{className:n.metaValue},a))}),Dt=(0,t.memo)(function(o){const n=(0,N.of)(An),{metaItems:s}=o;return t.createElement("div",{className:n.metaContainer,"data-testid":"meta-info-text"},s.map((a,r)=>t.createElement(sa,{key:`${r}-${a.label}`,label:a.label,value:a.value})))});var Nn=d(14236),ft=d(90708),qe=d(11261),zn=d(41260),At=d(77093);function aa(e){const{timeZone:o,splitOpen:n,range:s,logsSortOrder:a,width:r,dataFrame:i,columnsWithMeta:l,logsFrame:c}=e,[m,p]=(0,t.useState)(void 0),u=c?.timeField.index,f=(0,t.useCallback)(y=>{if(!y.length)return y;const v=(0,Nn.ES)(y,u,a===K.uH.Descending),[b]=(0,ft.we)({data:[v],timeZone:o,theme:V.$.theme2,replaceVariables:E=>E,fieldConfig:{defaults:{custom:{}},overrides:[]}});for(const E of b.fields)E.getLinks=C=>(0,Ie.QL)({field:E,rowIndex:C.valueRowIndex,splitOpenFn:n,range:s,dataFrame:v}),E.config={...E.config,custom:{inspect:!0,filterable:!0,width:ca(E),...E.config.custom},filterable:ra(E,c?.bodyField.name??"",c?.timeField.name??"")},E.type=E.type===qe.PU.string?(0,Nn.dF)(E)??qe.PU.string:E.type;return b},[a,o,n,s,c?.bodyField.name,c?.timeField.name,u]);if((0,t.useEffect)(()=>{(async()=>{if(!c?.timeField.name||!c?.bodyField.name){p(void 0);return}const v=Hn(i);let b=ia(l);const E=la(b);if(E?v.push(E):v.push({id:"organize",options:{indexByName:{[c.bodyField.name]:0,[c.timeField.name]:1},includeByName:{[c.bodyField.name]:!0,[c.timeField.name]:!0}}}),v.length>0){const C=await(0,Fn.s)((0,On.m)(v,[i])),R=f(C[0]);p(R)}else p(f(i))})()},[l,i,a,f,c?.bodyField.name,c?.timeField.name]),!m)return null;const g=y=>{const{value:v,key:b,operator:E}=y,{onClickFilterLabel:C,onClickFilterOutLabel:R}=e;!C||!R||(E===ot.mc&&C(b,v,i),E===ot.Zi&&R(b,v,i))};return t.createElement(At.X,{data:m,width:r,onCellFilterAdded:e.onClickFilterLabel&&e.onClickFilterOutLabel?g:void 0,height:e.height,footerOptions:{show:!0,reducer:["count"],countRows:!0}})}const ra=(e,o,n)=>!(!o||!n||o===e.name||n===e.name||e.config.links?.length);function Hn(e){return e.fields.filter(o=>{const n=o.typeInfo?.frame==="json.RawMessage"&&o.name==="labels"&&e?.meta?.type!==zn.m.LogLines,s=o.name==="labels"&&o.type===qe.PU.other&&e?.meta?.type===zn.m.LogLines;return n||s}).flatMap(o=>[{id:"extractFields",options:{format:"json",keepTime:!1,replace:!1,source:o.name}}])}function ia(e){let o={};return Object.keys(e).filter(n=>e[n].active).forEach(n=>{const s=e[n].index;s!==void 0&&(o[n]=s)}),o}function la(e){let o={};for(const n in e)o[n]=!0;return Object.keys(e).length>0?{id:"organize",options:{indexByName:e,includeByName:o}}:null}function ca(e){if(e.type===qe.PU.time)return 200}const da=()=>({metaContainer:(0,h.css)` flex: 1; display: flex; flex-wrap: wrap; `});var ua=(e=>(e.Text="text",e.Json="json",e.CSV="csv",e))(ua||{});const Mn=t.memo(({meta:e,dedupStrategy:o,dedupCount:n,displayedFields:s,clearDetectedFields:a,hasUnescapedContent:r,forceEscape:i,onEscapeNewlines:l,logRows:c})=>{const m=(0,N.of)(da),p=async g=>{switch((0,P.rR)("grafana_logs_download_logs_clicked",{app:je.Jk.Explore,format:g,area:"logs-meta-row"}),g){case"text":(0,Dn.Zy)({meta:e,rows:c},"Explore");break;case"json":const y=(0,Te.Dg)(c),v=new Blob([JSON.stringify(y)],{type:"application/json;charset=utf-8"}),b=`Explore-logs-${(0,It.LE)(new Date)}.json`;ta()(v,b);break;case"csv":const E=new Map;c.forEach(C=>{C.dataFrame?.refId&&!E.has(C.dataFrame?.refId)&&E.set(C.dataFrame?.refId,C.dataFrame)}),E.forEach(async C=>{const R=Hn(C);R.push({id:"organize",options:{excludeByName:{labels:!0,labelTypes:!0}}});const S=await(0,Fn.s)((0,On.m)(R,[C]));(0,Dn.EM)(S[0],`Explore-logs-${C.refId}`)})}},u=[...e];o!==K.fY.none&&u.push({label:"Deduplication count",value:n,kind:Y.tG.Number}),c.some(g=>g.entry.length>oa.S)&&u.push({label:"Info",value:"Logs with more than 100,000 characters could not be parsed and highlighted",kind:Y.tG.String}),s?.length>0&&u.push({label:"Showing only selected fields",value:Pn(s,Y.tG.LabelsMap)},{label:"",value:t.createElement(j.$n,{variant:"secondary",size:"sm",onClick:a},"Show original line")}),r&&u.push({label:"Your logs might have incorrectly escaped content",value:t.createElement(he.m,{content:"Fix incorrectly escaped newline and tab sequences in log lines. Manually review the results to confirm that the replacements are correct.",placement:"right"},t.createElement(j.$n,{variant:"secondary",size:"sm",onClick:l},i?"Remove escaping":"Escape newlines"))});const f=t.createElement($e.W,null,t.createElement($e.W.Item,{label:"txt",onClick:()=>p("text")}),t.createElement($e.W.Item,{label:"json",onClick:()=>p("json")}),t.createElement($e.W.Item,{label:"csv",onClick:()=>p("csv")}));return t.createElement(t.Fragment,null,u&&t.createElement("div",{className:m.metaContainer},t.createElement(Dt,{metaItems:u.map(g=>({label:g.label,value:"kind"in g?Pn(g.value,g.kind):g.value}))}),t.createElement(Tt.m,{overlay:f},t.createElement(ae.I,{isOpen:!1,variant:"canvas",icon:"download-alt"},"Download"))))});Mn.displayName="LogsMetaRow";function Pn(e,o){return o===Y.tG.LabelsMap?t.createElement(na.A,{labels:e}):o===Y.tG.Error?t.createElement("span",{className:"logs-meta-item__error"},e):e}var Nt=d(62930),pa=d(57571),ha=d(42994);function ma({pages:e,currentPageIndex:o,oldestLogsFirst:n,timeZone:s,loading:a,onClick:r}){const i=p=>`${(0,It.LE)(p,{format:ha.WC.interval.second,timeZone:s})}`,l=(p,u)=>{if(o===u&&a)return t.createElement(Nt.y,null);const f=i(n?p.logsRange.from:p.logsRange.to),g=i(n?p.logsRange.to:p.logsRange.from);return`${f} \u2014 ${g}`},c=(0,N.$j)(),m=ga(c,a);return t.createElement(nt.E,{autoHide:!0},t.createElement("div",{className:m.pagesWrapper,"data-testid":"logsNavigationPages"},t.createElement("div",{className:m.pagesContainer},e.map((p,u)=>t.createElement("button",{type:"button","data-testid":`page${u+1}`,className:(0,h.cx)((0,j.my)(c),m.page),key:p.queryRange.to,onClick:()=>{r(p,u+1)},disabled:a},t.createElement("div",{className:(0,h.cx)(m.line,{selectedBg:o===u})}),t.createElement("div",{className:(0,h.cx)(m.time,{selectedText:o===u})},l(p,u)))))))}const ga=(e,o)=>({pagesWrapper:(0,h.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:(0,h.css)` display: flex; padding: 0; flex-direction: column; `,page:(0,h.css)` display: flex; margin: ${e.spacing(2)} 0; cursor: ${o?"auto":"pointer"}; white-space: normal; .selectedBg { background: ${e.colors.primary.main}; } .selectedText { color: ${e.colors.primary.main}; } `,line:(0,h.css)` width: 3px; height: 100%; align-items: center; background: ${e.colors.text.secondary}; `,time:(0,h.css)` width: 60px; min-height: 80px; font-size: ${e.v1.typography.size.sm}; padding-left: ${e.spacing(.5)}; display: flex; align-items: center; `});function fa({absoluteRange:e,logsSortOrder:o,timeZone:n,loading:s,onChangeTime:a,scrollToTopLogs:r,visibleRange:i,queries:l,clearCache:c,addResultsToCache:m}){const[p,u]=(0,t.useState)([]),f=(0,t.useRef)(),g=(0,t.useRef)(),y=(0,t.useRef)(0),v=(0,t.useMemo)(()=>p.findIndex(D=>D.queryRange.to===e.to),[e.to,p]),b=o===K.uH.Ascending,E=b?v===p.length-1:v===0,C=b?v===0:v===p.length-1,R=(0,N.$j)(),S=va(R,b);(0,t.useEffect)(()=>{const D={logsRange:i,queryRange:e};let T=[];!(0,te.isEqual)(g.current,e)||!(0,te.isEqual)(f.current,l)?(c(),u([D]),f.current=l,y.current=e.to-e.from):u(k=>(T=k.filter(Z=>!(0,te.isEqual)(D.queryRange,Z.queryRange)),T=[...T,D].sort((Z,W)=>I(Z,W,o)),T))},[i,e,o,l,c,m]);const L=(0,t.useCallback)(({from:D,to:T})=>{m(),g.current={from:D,to:T},a({from:D,to:T})},[a,m]),I=(D,T,k)=>k===K.uH.Ascending?D.queryRange.to>T.queryRange.to?1:-1:D.queryRange.to>T.queryRange.to?-1:1,H=t.createElement(j.$n,{"data-testid":"olderLogsButton",className:S.navButton,variant:"secondary",onClick:()=>{if((0,P.rR)("grafana_explore_logs_pagination_clicked",{pageType:"olderLogsButton"}),C)L({from:i.from-y.current,to:i.from});else{const D=b?-1:1;L({from:p[v+D].queryRange.from,to:p[v+D].queryRange.to})}r()},disabled:s},t.createElement("div",{className:S.navButtonContent},s?t.createElement(Nt.y,null):t.createElement(ie.I,{name:b?"angle-up":"angle-down",size:"lg"}),"Older logs")),z=t.createElement(j.$n,{"data-testid":"newerLogsButton",className:S.navButton,variant:"secondary",onClick:()=>{if((0,P.rR)("grafana_explore_logs_pagination_clicked",{pageType:"newerLogsButton"}),!E){const D=b?1:-1;L({from:p[v+D].queryRange.from,to:p[v+D].queryRange.to})}r()},disabled:s||E},t.createElement("div",{className:S.navButtonContent},s&&t.createElement(Nt.y,null),E||s?null:t.createElement(ie.I,{name:b?"angle-down":"angle-up",size:"lg"}),E?"Start of range":"Newer logs")),$=(0,t.useCallback)((D,T)=>{(0,P.rR)("grafana_explore_logs_pagination_clicked",{pageType:"page",pageNumber:T}),L({from:D.queryRange.from,to:D.queryRange.to}),r()},[L,r]);return t.createElement("div",{className:S.navContainer},!V.$.featureToggles.logsInfiniteScrolling&&t.createElement(t.Fragment,null,b?H:z,t.createElement(ma,{pages:p,currentPageIndex:v,oldestLogsFirst:b,timeZone:n,loading:s,onClick:$}),b?z:H),t.createElement(j.$n,{"data-testid":"scrollToTop",className:S.scrollToTopButton,variant:"secondary",onClick:r,title:"Scroll to top"},t.createElement(ie.I,{name:"arrow-up",size:"lg"})))}const ya=(0,t.memo)(fa),va=(e,o)=>{const n=`calc(100vh - 2*${e.spacing(2)} - 2*${pa.l}px)`;return{navContainer:(0,h.css)` max-height: ${n}; display: flex; flex-direction: column; ${V.$.featureToggles.logsInfiniteScrolling?"justify-content: flex-end;":`justify-content: ${o?"flex-start":"space-between"};`} position: sticky; top: ${e.spacing(2)}; right: 0; `,navButton:(0,h.css)` width: 58px; height: 68px; display: flex; flex-direction: column; justify-content: center; align-items: center; line-height: 1; `,navButtonContent:(0,h.css)` display: flex; flex-direction: column; justify-content: center; align-items: center; width: 100%; height: 100%; white-space: normal; `,scrollToTopButton:(0,h.css)` width: 40px; height: 40px; display: flex; flex-direction: column; justify-content: center; align-items: center; margin-top: ${e.spacing(1)}; `}};var $n=d(98101);function Ea(e){return{searchWrap:(0,h.css)({padding:`${e.spacing(.4)} 0 ${e.spacing(.4)} ${e.spacing(.4)}`})}}function ba(e){const o=(0,N.$j)(),n=Ea(o);return t.createElement(xe.D,{className:n.searchWrap},t.createElement(Ue.p,{value:e.value,type:"text",placeholder:"Search fields by name",onChange:e.onChange}))}var zt=d(75494);function xa(e){return{empty:(0,h.css)({marginBottom:e.spacing(2),marginLeft:e.spacing(1.75),fontSize:e.typography.fontSize})}}function kn(){const e=(0,N.$j)(),o=xa(e);return t.createElement("div",{className:o.empty},"No fields")}var Sa=d(10880);function Ca(e){return{dragIcon:(0,h.css)({cursor:"drag",marginLeft:e.spacing(1),opacity:.4}),labelCount:(0,h.css)({marginLeft:e.spacing(.5),marginRight:e.spacing(.5),appearance:"none",background:"none",border:"none",fontSize:e.typography.pxToRem(11),opacity:.6}),contentWrap:(0,h.css)({display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"}),checkboxLabel:(0,h.css)({"> span":{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",maxWidth:"100%"}})}}function Bn(e){const o=(0,N.$j)(),n=Ca(o);if(e.labels[e.label])return t.createElement(t.Fragment,null,t.createElement("div",{className:n.contentWrap},t.createElement(Sa.S,{className:n.checkboxLabel,label:e.label,onChange:e.onChange,checked:e.labels[e.label]?.active??!1}),e.showCount&&t.createElement("button",{className:n.labelCount,onClick:e.onChange},e.labels[e.label]?.percentOfLinesWithLabel,"%")),e.draggable&&t.createElement(ie.I,{"aria-label":"Drag and drop icon",title:"Drag and drop to reorder",name:"draggabledots",size:"lg",className:n.dragIcon}))}function Wn(e){return{wrap:(0,h.css)({marginTop:e.spacing(1),marginBottom:e.spacing(1),display:"flex",background:e.colors.background.primary}),dragging:(0,h.css)({background:e.colors.background.secondary}),columnWrapper:(0,h.css)({marginBottom:e.spacing(1.5),paddingLeft:e.spacing(.5)})}}function Ra(e){return(o,n)=>{const s=e[o],a=e[n];return s.index!=null&&a.index!=null?s.index-a.index:0}}const wa=e=>{const{reorderColumn:o,labels:n,valueFilter:s,toggleColumn:a}=e,r=(0,N.$j)(),i=Wn(r),l=Object.keys(n).filter(p=>s(p)),c=p=>{p.destination&&o(p.source.index,p.destination.index)},m=p=>{const u=n[p];if(u)return`${p} appears in ${u?.percentOfLinesWithLabel}% of log lines`};return l.length?t.createElement(zt.JY,{onDragEnd:c},t.createElement(zt.gL,{droppableId:"order-fields",direction:"vertical"},p=>t.createElement("div",{className:i.columnWrapper,...p.droppableProps,ref:p.innerRef},l.sort(Ra(n)).map((u,f)=>t.createElement(zt.sx,{draggableId:u,key:u,index:f},(g,y)=>t.createElement("div",{className:(0,h.cx)(i.wrap,y.isDragging?i.dragging:void 0),ref:g.innerRef,...g.draggableProps,...g.dragHandleProps,title:m(u)},t.createElement(Bn,{label:u,onChange:()=>a(u),labels:n,draggable:!0})))),p.placeholder))):t.createElement(kn,null)},Ta=new Intl.Collator(void 0,{sensitivity:"base"});function La(e){return(o,n)=>{const s=e[o],a=e[n];return s!=null&&a!=null?+(a.type==="TIME_FIELD")-+(s.type==="TIME_FIELD")||+(a.type==="BODY_FIELD")-+(s.type==="BODY_FIELD")||Ta.compare(o,n):0}}const Ia=e=>{const{labels:o,valueFilter:n,toggleColumn:s}=e,a=(0,N.$j)(),r=Wn(a),i=Object.keys(o).filter(l=>n(l));return i.length?t.createElement("div",{className:r.columnWrapper},i.sort(La(o)).map((l,c)=>t.createElement("div",{key:l,className:r.wrap,title:`${l} appears in ${o[l]?.percentOfLinesWithLabel}% of log lines`},t.createElement(Bn,{showCount:!0,label:l,onChange:()=>s(l),labels:o})))):t.createElement(kn,null)};function Fa(e){return{sidebarWrap:(0,h.css)({overflowY:"scroll",height:"calc(100% - 50px)","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}),columnHeaderButton:(0,h.css)({appearance:"none",background:"none",border:"none",fontSize:e.typography.pxToRem(11)}),columnHeader:(0,h.css)({display:"flex",justifyContent:"space-between",fontSize:e.typography.h6.fontSize,background:e.colors.background.secondary,position:"sticky",top:0,left:0,paddingTop:e.spacing(.75),paddingRight:e.spacing(.75),paddingBottom:e.spacing(.75),paddingLeft:e.spacing(1.5),zIndex:3,marginBottom:e.spacing(2)})}}const Oa=e=>{const o=(0,N.$j)(),n=Fa(o);return t.createElement("div",{className:n.sidebarWrap},t.createElement(t.Fragment,null,t.createElement("div",{className:n.columnHeader},"Selected fields",t.createElement("button",{onClick:e.clear,className:n.columnHeaderButton},"Reset")),t.createElement(wa,{reorderColumn:e.reorderColumn,toggleColumn:e.toggleColumn,labels:e.filteredColumnsWithMeta??e.columnsWithMeta,valueFilter:s=>e.columnsWithMeta[s]?.active??!1,id:"selected-fields"}),t.createElement("div",{className:n.columnHeader},"Fields"),t.createElement(Ia,{toggleColumn:e.toggleColumn,labels:e.filteredColumnsWithMeta??e.columnsWithMeta,valueFilter:s=>!e.columnsWithMeta[s]?.active})))};var Vn=d(53076);const Da=new Vn.A({intraMode:1,intraIns:1,intraSub:1,intraTrn:1,intraDel:1});function Qn(e,o,n){const[s,a,r]=Da.search(e,o,0,1e5);let i=[],l=new Set;if(s&&r){const c=(m,p)=>{p&&l.add(m)};for(let m=0;m
w.refId===f)??o[0]),v=(0,t.useCallback)(w=>{const A=e.panelState?.columns;return A&&Object.values(A).forEach((M,F)=>{w[M]&&(w[M].active=!0,w[M].index=F)}),w},[e.panelState?.columns]),b=(0,$n.O)(g);(0,t.useEffect)(()=>{if(b?.timeField.name&&b?.bodyField.name&&!a){const w={0:b?.timeField.name??"",1:b?.bodyField.name??""};n({columns:Object.values(w),visualisationType:"table",labelFieldName:b?.getLabelFieldName()??void 0})}},[b,a,n]),(0,t.useEffect)(()=>{const w=o.find(A=>A.refId===f)??o[0];w&&y(w)},[o,f]),(0,t.useEffect)(()=>{if(!r||!l)return;let w={...l},A=!1;Object.keys(r).forEach(M=>{w[M]&&w[M].active!==r[M].active&&(w[M]=r[M],A=!0)}),A&&c(w)},[r,l]),(0,t.useEffect)(()=>{if(!g.length)return;const w=g?g.length:0,A=(0,$n.O)(g),M=A?.getLogFrameLabelsAsLabels(),F=[];A&&F.push(...A.extraFields.filter(ee=>!ee?.config?.custom?.hidden)),A?.severityField&&F.push(A?.severityField),A?.bodyField&&F.push(A?.bodyField),A?.timeField&&F.push(A?.timeField);const Q=new Map;let B={};M?.length&&w&&(M.forEach(ee=>{Object.keys(ee).forEach(pe=>{if(Q.has(pe)){const re=Q.get(pe);re&&(re?.active?Q.set(pe,{percentOfLinesWithLabel:re.percentOfLinesWithLabel+1,active:!0,index:re.index}):Q.set(pe,{percentOfLinesWithLabel:re.percentOfLinesWithLabel+1,active:!1,index:void 0}))}else Q.set(pe,{percentOfLinesWithLabel:1,active:!1,index:void 0})})}),B=Object.fromEntries(Q),Object.keys(B).forEach(ee=>{B[ee].percentOfLinesWithLabel=Ht(B[ee].percentOfLinesWithLabel,w)})),F.forEach(ee=>{const U=B[ee.name]?.active,pe=B[ee.name]?.index;U&&pe!==void 0?B[ee.name]={percentOfLinesWithLabel:Ht(ee.values.filter(re=>re!=null).length,w),active:!0,index:pe}:B[ee.name]={percentOfLinesWithLabel:Ht(ee.values.filter(re=>re!=null).length,w),active:!1,index:void 0}}),B=v(B),Object.keys(B).filter(ee=>B[ee].active).length===0&&(A?.bodyField?.name&&(B[A.bodyField.name].active=!0),A?.timeField?.name&&(B[A.timeField.name].active=!0)),A?.bodyField?.name&&A?.timeField?.name&&(B[A.bodyField.name].type="BODY_FIELD",B[A.timeField.name].type="TIME_FIELD"),i(B)},[g,v]);const[E,C]=(0,t.useState)(220),R=e.width-E;if(!r)return null;function S(w){if(r){const A=!r[w]?.active,M=Object.keys(r).filter(Q=>r[Q]?.active)?.length,F={columnAction:A?"add":"remove",columnCount:A?M+1:M-1,datasourceType:e.datasourceType};(0,P.rR)("grafana_explore_logs_table_column_filter_clicked",F)}}function L(w){(0,P.rR)("grafana_explore_logs_table_text_search_result_count",{resultCount:w,datasourceType:e.datasourceType??"unknown"})}const I=()=>{const w={...r};let A=0;Object.keys(w).forEach(M=>{const F=!!w[M].type;w[M].active=F,w[M].index=F?A++:void 0}),i(w)},H=(w,A)=>{if(w===A)return;const M={...r},F=Object.keys(M).filter(B=>M[B].active).map(B=>({fieldName:B,index:M[B].index??0})).sort((B,Ee)=>B.index-Ee.index),[Q]=F.splice(w,1);F.splice(A,0,Q),F.forEach((B,Ee)=>{M[B.fieldName].index=Ee}),i(M),z(M)};function z(w){const A=Object.keys(w).filter(B=>w[B]?.active).sort((B,Ee)=>{const ee=w[B],U=w[Ee];return ee.index!==void 0&&U.index!==void 0?ee.index-U.index:0}),M=Object.assign({},A),F={0:b?.timeField.name??"",1:b?.bodyField.name??""},Q={...e.panelState,columns:Object.keys(M).length?M:F,refId:g.refId,visualisationType:"table",labelFieldName:b?.getLabelFieldName()??void 0};n(Q)}const $=w=>{if(!r||!(w in r)){console.warn("failed to get column",r);return}const A=Object.keys(r).filter(Q=>r[Q].active).length,M=r[w].active?void 0:!0;let F;if(M?F={...r,[w]:{...r[w],active:M,index:A}}:F={...r,[w]:{...r[w],active:!1,index:void 0}},S(w),i(F),l){const Q=!l[w]?.active;let B;Q?B={...l,[w]:{...l[w],active:Q,index:A}}:B={...l,[w]:{...l[w],active:!1,index:void 0}},c(B)}z(F)},D=w=>{const A=w[0];let M={},F=0;A.forEach(Q=>{Q in r&&(M[Q]=r[Q],F++)}),c(M),L(F)},T=w=>{Qn(Object.keys(r),w,D)},k=w=>{const A=w.currentTarget?.value;p(A),A?T(A):c(void 0)},Z=w=>{o.find(M=>M.refId===w.value)&&y(o.find(M=>M.refId===w.value)??o[0]),e.updatePanelState({refId:w.value,labelFieldName:b?.getLabelFieldName()??void 0})},W=Na(e.theme,u,E),ue=(w,A,M)=>{const F=Number(M.style.width.slice(0,-2));isNaN(F)||C(F)};return t.createElement(t.Fragment,null,t.createElement("div",null,o.length>1&&t.createElement("div",null,t.createElement(ye.I,{label:"Select query",htmlFor:"explore_logs_table_frame_selector",labelWidth:22,tooltip:"Select a query to visualize in the table."},t.createElement(Re.l6,{inputId:"explore_logs_table_frame_selector","aria-label":"Select query by name",value:g.refId,options:o.map(w=>({label:w.refId,value:w.refId})),onChange:Z})))),t.createElement("div",{className:W.wrapper},t.createElement(dn,{enable:{right:!0},handleClasses:{right:W.rzHandle},onResize:ue},t.createElement("section",{className:W.sidebar},t.createElement(ba,{value:m,onChange:k}),t.createElement(Oa,{reorderColumn:H,toggleColumn:$,filteredColumnsWithMeta:l,columnsWithMeta:r,clear:I}))),t.createElement(aa,{logsFrame:b,onClickFilterLabel:e.onClickFilterLabel,onClickFilterOutLabel:e.onClickFilterOutLabel,logsSortOrder:e.logsSortOrder,range:e.range,splitOpen:e.splitOpen,timeZone:e.timeZone,width:R,dataFrame:g,columnsWithMeta:r,height:u})))}const Ht=(e,o)=>Math.ceil(100*e/o);function Na(e,o,n){return{wrapper:(0,h.css)({display:"flex"}),sidebar:(0,h.css)({height:o,fontSize:e.typography.pxToRem(11),overflowY:"hidden",width:n,paddingRight:e.spacing(3)}),rzHandle:(0,h.css)({background:e.colors.secondary.main,transition:"0.3s background ease-in-out",position:"relative",height:"50% !important",width:`${e.spacing(1)} !important`,top:"25% !important",right:`${e.spacing(1)} !important`,cursor:"grab",borderRadius:e.shape.radius.pill,["&:hover"]:{background:e.colors.secondary.shade}})}}const Un=()=>Math.max(window.innerHeight-500,500);function Mt(e){const[o,n]=(0,t.useState)(!1),s=100,{error:a,title:r,suggestedAction:i,onSuggestedAction:l,onRemove:c,severity:m="warning"}=e,p=a?.message||a?.data?.message||"",u=!o&&p.length>s,f=(0,N.$j)(),g=za(f);return t.createElement("div",{className:g.supplementaryErrorContainer},t.createElement(Ve.F,{title:r,severity:m,onRemove:c},t.createElement("div",{className:g.suggestedActionWrapper},u?t.createElement(j.$n,{variant:"secondary",size:"xs",onClick:()=>{n(!0)}},"Show details"):p,i&&l&&t.createElement("div",{className:g.suggestedActionWrapper},t.createElement(j.$n,{variant:"primary",size:"xs",onClick:l},i)))))}const za=e=>({supplementaryErrorContainer:(0,h.css)({width:"50%",minWidth:`${e.breakpoints.values.sm}px`,margin:"0 auto"}),suggestedActionWrapper:(0,h.css)({height:e.spacing(6),button:{position:"absolute",right:e.spacing(2),top:e.spacing(7)}})});var Ha=d(9791);function Ma(e){const{width:o,timeZone:n,splitOpen:s,onUpdateTimeRange:a,onHiddenSeriesChanged:r,allLogsVolumeMaximum:i}=e,l=(0,N.$j)(),c=(0,N.of)(Pa),m=parseInt(l.spacing(2).slice(0,-2),10),p=150,u=e.logsVolumeData,f=(0,Te.Dm)(u?.data);let g=f?`${f.name}`:"";(0,Te.e3)(u.data)&&(g=[g,"This datasource does not support full-range histograms. The graph below is based on the logs seen in the response."].filter(te.identity).join(". "));let y=t.createElement("span",null,g);return u.state===le.Gu.Streaming&&(y=t.createElement(t.Fragment,null,y,t.createElement(he.m,{content:"Streaming"},t.createElement(ie.I,{name:"circle-mono",size:"md",className:c.streaming,"data-testid":"logs-volume-streaming"})))),t.createElement("div",{style:{height:p},className:c.contentContainer},t.createElement(Ha.k,{vizLegendOverrides:{calcs:["sum"]},graphStyle:"lines",loadingState:u.state??le.Gu.Done,data:u.data,height:p,width:o-m*2,absoluteRange:e.absoluteRange,onChangeTime:a,timeZone:n,splitOpenFn:s,tooltipDisplayMode:K.$N.Multi,onHiddenSeriesChanged:r,anchorToZero:!0,yAxisMaximum:i,eventBus:e.eventBus,annotations:e.annotations}),y&&t.createElement("div",{className:c.extraInfoContainer},y))}const Pa=e=>({extraInfoContainer:(0,h.css)` display: flex; justify-content: end; position: absolute; right: 5px; top: -10px; font-size: ${e.typography.bodySmall.fontSize}; color: ${e.colors.text.secondary}; `,contentContainer:(0,h.css)` display: flex; align-items: center; justify-content: center; position: relative; `,streaming:(0,h.css)` color: ${e.colors.success.text}; `});function $a(e){return!e||!e.error&&!e.errors?!1:(e.error?[e.error]:e.errors||[]).some(n=>(`${n.message||n.data?.message}`?.toLowerCase()).includes("timeout"))}const ka=({logsVolumeData:e,absoluteRange:o,onUpdateTimeRange:n,width:s,onLoadLogsVolume:a,onHiddenSeriesChanged:r,eventBus:i,splitOpen:l,timeZone:c,onClose:m})=>{const{logVolumes:p,maximumValue:u,maximumRange:f,annotations:g}=(0,t.useMemo)(()=>{let R=-1/0;const S=e?.data.filter(D=>D.meta?.dataTopic!==K.QR.Annotations),L=e?.data.filter(D=>D.meta?.dataTopic===K.QR.Annotations)||[],I=(0,te.sortBy)(S||[],"meta.custom.datasourceName"),H=(0,te.groupBy)(I,"meta.custom.datasourceName"),z=(0,te.mapValues)(H,D=>{const T=(0,Te.oT)(D);return R=Math.max(R,T.maximum),T.dataFrames}),$=(0,Te.Dx)((0,te.flatten)(Object.values(z)));return{maximumValue:R,maximumRange:$,logVolumes:z,annotations:L}},[e]),y=(0,N.of)(Ba),v=Object.keys(p).length,b=Object.values(p).some(R=>{const S=Wa(R,o);return!(0,Te.e3)(R)&&S&&S<1}),E=$a(e),C={from:Math.max(o.from,f.from),to:Math.min(o.to,f.to)};return e?.state===le.Gu.Loading?t.createElement("span",null,"Loading..."):E?t.createElement(Mt,{title:"The logs volume query has timed out",severity:"info",suggestedAction:"Retry",onSuggestedAction:a,onRemove:m}):e?.error!==void 0?t.createElement(Mt,{error:e.error,title:"Failed to load log volume for this query"}):v===0?t.createElement("div",{className:y.alertContainer},t.createElement(Ve.F,{severity:"info",title:"No logs volume available"},"No volume information available for the current queries and time range.")):t.createElement("div",{className:y.listContainer},Object.keys(p).map((R,S)=>{const L={data:p[R]};return t.createElement(Ma,{key:S,absoluteRange:C,allLogsVolumeMaximum:u,width:s,logsVolumeData:L,onUpdateTimeRange:n,timeZone:c,splitOpen:l,onLoadLogsVolume:a,onHiddenSeriesChanged:v>1?()=>{}:r,eventBus:i,annotations:g})}),b&&t.createElement("div",{className:y.extraInfoContainer},t.createElement(ye.I,{label:"Reload log volume",transparent:!0},t.createElement(j.$n,{size:"xs",icon:"sync",variant:"secondary",onClick:a,id:"reload-volume"}))))},Ba=e=>({listContainer:(0,h.css)` padding-top: 10px; `,extraInfoContainer:(0,h.css)` display: flex; justify-content: end; position: absolute; right: 5px; top: 5px; `,oldInfoText:(0,h.css)` font-size: ${e.typography.bodySmall.fontSize}; color: ${e.colors.text.secondary}; `,alertContainer:(0,h.css)` width: 50%; min-width: ${e.breakpoints.values.sm}px; margin: 0 auto; `});function Wa(e,o){const n=e&&e[0]&&e[0].meta?.custom?.absoluteRange;return n?(o.from-o.to)/(n.from-n.to):void 0}var oe=d(97186);const Va=[K.fY.none,K.fY.exact,K.fY.numbers,K.fY.signature],Pt=()=>ne.A.get(oe.r)==="table"?"table":"logs";class Qa extends t.PureComponent{constructor(o){super(o),this.topLogsRef=(0,t.createRef)(),this.state={showLabels:ne.A.getBool(oe.$.showLabels,!1),showTime:ne.A.getBool(oe.$.showTime,!0),wrapLogMessage:ne.A.getBool(oe.$.wrapLogMessage,!0),prettifyLogMessage:ne.A.getBool(oe.$.prettifyLogMessage,!1),dedupStrategy:K.fY.none,hiddenLogLevels:[],logsSortOrder:ne.A.get(oe.$.logsSortOrder)||K.uH.Descending,isFlipping:!1,displayedFields:[],forceEscape:!1,contextOpen:!1,contextRow:void 0,tableFrame:void 0,visualisationType:this.props.panelState?.logs?.visualisationType??Pt(),logsContainer:void 0},this.updatePanelState=n=>{const s=(0,Le.Gu)().explore.panes[this.props.exploreId];s?.panelsState&&(0,Le.JD)((0,be.EA)(this.props.exploreId,"logs",{...s.panelsState.logs,columns:n.columns??this.props.panelState?.logs?.columns,visualisationType:n.visualisationType??this.state.visualisationType,labelFieldName:n.labelFieldName,refId:n.refId??this.props.panelState?.logs?.refId}))},this.onLogRowHover=n=>{n?this.props.eventBus.publish(new bn.b_({point:{time:n.timeEpochMs}})):this.props.eventBus.publish(new bn.ql)},this.onLogsContainerRef=n=>{this.setState({logsContainer:n})},this.onChangeLogsSortOrder=()=>{this.setState({isFlipping:!0}),this.flipOrderTimer=window.setTimeout(()=>{this.setState(n=>{const s=n.logsSortOrder===K.uH.Descending?K.uH.Ascending:K.uH.Descending;return ne.A.set(oe.$.logsSortOrder,s),{logsSortOrder:s}})},0),this.cancelFlippingTimer=window.setTimeout(()=>this.setState({isFlipping:!1}),1e3)},this.onEscapeNewlines=()=>{this.setState(n=>({forceEscape:!n.forceEscape}))},this.onChangeVisualisation=n=>{this.setState(()=>({visualisationType:n}));const s={...this.props.panelState?.logs,visualisationType:n};this.updatePanelState(s),(0,P.rR)("grafana_explore_logs_visualisation_changed",{newVisualizationType:n,datasourceType:this.props.datasourceType??"unknown"})},this.onChangeDedup=n=>{(0,P.rR)("grafana_explore_logs_deduplication_clicked",{deduplicationType:n,datasourceType:this.props.datasourceType}),this.setState({dedupStrategy:n})},this.onChangeLabels=n=>{const{target:s}=n;if(s){const a=s.checked;this.setState({showLabels:a}),ne.A.set(oe.$.showLabels,a)}},this.onChangeTime=n=>{const{target:s}=n;if(s){const a=s.checked;this.setState({showTime:a}),ne.A.set(oe.$.showTime,a)}},this.onChangeWrapLogMessage=n=>{const{target:s}=n;if(s){const a=s.checked;this.setState({wrapLogMessage:a}),ne.A.set(oe.$.wrapLogMessage,a)}},this.onChangePrettifyLogMessage=n=>{const{target:s}=n;if(s){const a=s.checked;this.setState({prettifyLogMessage:a}),ne.A.set(oe.$.prettifyLogMessage,a)}},this.onToggleLogLevel=n=>{const s=n.map(a=>(0,Te.EK)(a));this.setState({hiddenLogLevels:s})},this.onToggleLogsVolumeCollapse=n=>{this.props.onSetLogsVolumeEnabled(!n),(0,P.rR)("grafana_explore_logs_histogram_toggle_clicked",{datasourceType:this.props.datasourceType,type:n?"close":"open"})},this.onClickScan=n=>{n.preventDefault(),this.props.onStartScanning&&(this.props.onStartScanning(),(0,P.rR)("grafana_explore_logs_scanning_button_clicked",{type:"start",datasourceType:this.props.datasourceType}))},this.onClickStopScan=n=>{n.preventDefault(),this.props.onStopScanning&&this.props.onStopScanning()},this.showField=n=>{this.state.displayedFields.indexOf(n)===-1&&this.setState(a=>({displayedFields:a.displayedFields.concat(n)}))},this.hideField=n=>{this.state.displayedFields.indexOf(n)>-1&&this.setState(a=>({displayedFields:a.displayedFields.filter(r=>n!==r)}))},this.clearDetectedFields=()=>{this.setState(n=>({displayedFields:[]}))},this.onCloseContext=()=>{this.setState({contextOpen:!1,contextRow:void 0})},this.onOpenContext=(n,s)=>{this.setState({contextOpen:!0,contextRow:n}),(0,P.rR)("grafana_explore_logs_log_context_opened",{datasourceType:n.datasourceType,logRowUid:n.uid}),this.onCloseContext=()=>{this.setState({contextOpen:!1,contextRow:void 0}),(0,P.rR)("grafana_explore_logs_log_context_closed",{datasourceType:n.datasourceType,logRowUid:n.uid}),s()}},this.onPermalinkClick=async n=>{if(n.rowId===void 0)return;const s=(0,In.m)((0,Le.Gu)().explore.panes[this.props.exploreId]);s.panelsState={...this.props.panelState,logs:{id:n.uid,visualisationType:this.state.visualisationType??Pt()}},s.range=this.getPermalinkRange(n);const a=(0,xn.Pp)(s),r=/.*(?=\/explore)/.exec(`${window.location.href}`)[0],i=xn.kM.renderUrl(`${r}/explore`,{left:a});await(0,Lt.V)(i),(0,P.rR)("grafana_explore_logs_permalink_clicked",{datasourceType:n.datasourceType??"unknown",logRowUid:n.uid,logRowLevel:n.logLevel})},this.scrollIntoView=n=>{if(V.$.featureToggles.logsInfiniteScrolling){this.state.logsContainer&&(this.topLogsRef.current?.scrollIntoView(),this.state.logsContainer.scroll({behavior:"smooth",top:this.state.logsContainer.scrollTop+n.getBoundingClientRect().top-window.innerHeight/2}));return}const{scrollElement:s}=this.props;s&&s.scroll({behavior:"smooth",top:s.scrollTop+n.getBoundingClientRect().top-window.innerHeight/2})},this.checkUnescapedContent=(0,ze.A)(n=>!!n.some(s=>s.hasUnescapedContent)),this.dedupRows=(0,ze.A)((n,s)=>{const a=(0,Ot.M0)(n,s),r=a.reduce((i,l)=>l.duplicates?i+l.duplicates:i,0);return{dedupedRows:a,dedupCount:r}}),this.filterRows=(0,ze.A)((n,s)=>(0,Ot.ct)(n,new Set(s))),this.createNavigationRange=(0,ze.A)(n=>{if(!n||n.length===0)return;const s=n[0].timeEpochMs,a=n[n.length-1].timeEpochMs;return a
{V.$.featureToggles.logsInfiniteScrolling&&this.state.logsContainer&&this.state.logsContainer.scroll({behavior:"auto",top:0}),this.topLogsRef.current?.scrollIntoView()},this.logsVolumeEventBus=o.eventBus.newScopedBus("logsvolume",{onlyLocal:!1})}componentWillUnmount(){this.flipOrderTimer&&window.clearTimeout(this.flipOrderTimer),this.cancelFlippingTimer&&window.clearTimeout(this.cancelFlippingTimer),(this.props?.panelState?.logs?.columns||this.props?.panelState?.logs?.refId||this.props?.panelState?.logs?.labelFieldName)&&(0,Le.JD)((0,be.EA)(this.props.exploreId,"logs",{...this.props.panelState?.logs,columns:void 0,visualisationType:this.state.visualisationType,labelFieldName:void 0,refId:void 0}))}componentDidUpdate(o){if(this.props.loading&&!o.loading&&this.props.panelState?.logs?.id&&(delete this.props.panelState.logs.id,(0,Le.JD)((0,be.EA)(this.props.exploreId,"logs",{...this.props.panelState}))),this.props.panelState?.logs?.visualisationType!==o.panelState?.logs?.visualisationType){const n=this.props.panelState?.logs?.visualisationType??Pt();this.setState({visualisationType:n}),ne.A.set(oe.r,n)}}getPermalinkRange(o){const n={from:new Date(this.props.absoluteRange.from).toISOString(),to:new Date(this.props.absoluteRange.to).toISOString()};if(!V.$.featureToggles.logsInfiniteScrolling)return n;const s=this.props.logRows.filter(r=>r.dataFrame.refId===o.dataFrame.refId),a=s[s.indexOf(o)-1];return o.timeEpochMs>this.props.absoluteRange.to&&!a?{from:new Date(this.props.absoluteRange.from).toISOString(),to:new Date(o.timeEpochMs+1).toISOString()}:{from:new Date(this.props.absoluteRange.from).toISOString(),to:new Date(a?a.timeEpochMs:this.props.absoluteRange.to).toISOString()}}render(){const{width:o,splitOpen:n,logRows:s,logsMeta:a,logsVolumeEnabled:r,logsVolumeData:i,loadLogsVolumeData:l,loading:c=!1,onClickFilterLabel:m,onClickFilterOutLabel:p,timeZone:u,scanning:f,scanRange:g,showContextToggle:y,absoluteRange:v,onChangeTime:b,getFieldLinks:E,theme:C,logsQueries:R,clearCache:S,addResultsToCache:L,exploreId:I,getRowContext:H,getLogRowContextUi:z,getRowContextQuery:$,loadMoreLogs:D}=this.props,{showLabels:T,showTime:k,wrapLogMessage:Z,prettifyLogMessage:W,dedupStrategy:ue,hiddenLogLevels:w,logsSortOrder:A,isFlipping:M,displayedFields:F,forceEscape:Q,contextOpen:B,contextRow:Ee}=this.state,ee=Un(),U=ja(C,Z,ee),pe=s&&s.length>0,re=this.checkUnescapedContent(s),Ti=this.filterRows(s,w),{dedupedRows:Li,dedupCount:Ii}=this.dedupRows(Ti,ue),Fi=this.createNavigationRange(s),Oi=g?`Scanning ${Ge.describeTimeRange(g)}`:"Scanning...";return t.createElement(t.Fragment,null,H&&Ee&&t.createElement(Js.V,{open:B,row:Ee,onClose:this.onCloseContext,getRowContext:(Ye,Di)=>H(Ye,Ee,Di),getRowContextQuery:$,getLogRowContextUi:z,logsSortOrder:A,timeZone:u}),t.createElement(Se.NR,{title:"Logs volume",collapsible:!0,collapsed:!r,onToggleCollapse:this.onToggleLogsVolumeCollapse},r&&t.createElement(ka,{absoluteRange:v,width:o,logsVolumeData:i,onUpdateTimeRange:b,timeZone:u,splitOpen:n,onLoadLogsVolume:l,onHiddenSeriesChanged:this.onToggleLogLevel,eventBus:this.logsVolumeEventBus,onClose:()=>this.onToggleLogsVolumeCollapse(!0)})),t.createElement(Se.NR,{titleItems:[V.$.featureToggles.logsExploreTableVisualisation?this.state.visualisationType==="logs"?null:t.createElement(Se.NR.TitleItem,{title:"Feedback",key:"A"},t.createElement(Xs,{feedbackUrl:"https://forms.gle/5YyKdRQJ5hzq4c289"})):null],title:"Logs",actions:t.createElement(t.Fragment,null,V.$.featureToggles.logsExploreTableVisualisation&&t.createElement("div",{className:U.visualisationType},t.createElement(mt.z,{className:U.visualisationTypeRadio,options:[{label:"Logs",value:"logs",description:"Show results in logs visualisation"},{label:"Table",value:"table",description:"Show results in table visualisation"}],size:"sm",value:this.state.visualisationType,onChange:this.onChangeVisualisation}))),loadingState:c?le.Gu.Loading:le.Gu.Done},t.createElement("div",{className:U.stickyNavigation},this.state.visualisationType!=="table"&&t.createElement("div",{className:U.logOptions},t.createElement(Us.C,null,t.createElement(ye.I,{label:"Time",className:U.horizontalInlineLabel,transparent:!0},t.createElement(Fe.K,{value:k,onChange:this.onChangeTime,className:U.horizontalInlineSwitch,transparent:!0,id:`show-time_${I}`})),t.createElement(ye.I,{label:"Unique labels",className:U.horizontalInlineLabel,transparent:!0},t.createElement(Fe.K,{value:T,onChange:this.onChangeLabels,className:U.horizontalInlineSwitch,transparent:!0,id:`unique-labels_${I}`})),t.createElement(ye.I,{label:"Wrap lines",className:U.horizontalInlineLabel,transparent:!0},t.createElement(Fe.K,{value:Z,onChange:this.onChangeWrapLogMessage,className:U.horizontalInlineSwitch,transparent:!0,id:`wrap-lines_${I}`})),t.createElement(ye.I,{label:"Prettify JSON",className:U.horizontalInlineLabel,transparent:!0},t.createElement(Fe.K,{value:W,onChange:this.onChangePrettifyLogMessage,className:U.horizontalInlineSwitch,transparent:!0,id:`prettify_${I}`})),t.createElement(ye.I,{label:"Deduplication",className:U.horizontalInlineLabel,transparent:!0},t.createElement(mt.z,{options:Va.map(Ye=>({label:(0,te.capitalize)(Ye),value:Ye,description:Y._C[Ye]})),value:ue,onChange:this.onChangeDedup,className:U.radioButtons}))),t.createElement("div",null,t.createElement(ye.I,{label:"Display results",className:U.horizontalInlineLabel,transparent:!0,disabled:M||c},t.createElement(mt.z,{options:[{label:"Newest first",value:K.uH.Descending,description:"Show results newest to oldest"},{label:"Oldest first",value:K.uH.Ascending,description:"Show results oldest to newest"}],value:A,onChange:this.onChangeLogsSortOrder,className:U.radioButtons})))),t.createElement("div",{ref:this.topLogsRef}),t.createElement(Mn,{logRows:s,meta:a||[],dedupStrategy:ue,dedupCount:Ii,hasUnescapedContent:re,forceEscape:Q,displayedFields:F,onEscapeNewlines:this.onEscapeNewlines,clearDetectedFields:this.clearDetectedFields})),t.createElement("div",{className:(0,h.cx)(U.logsSection,this.state.visualisationType==="table"?U.logsTable:void 0)},this.state.visualisationType==="table"&&pe&&t.createElement("div",{className:U.logRows,"data-testid":"logRowsTable"},t.createElement(Aa,{logsSortOrder:this.state.logsSortOrder,range:this.props.range,splitOpen:this.props.splitOpen,timeZone:u,width:o-80,logsFrames:this.props.logsFrames??[],onClickFilterLabel:m,onClickFilterOutLabel:p,panelState:this.props.panelState?.logs,theme:C,updatePanelState:this.updatePanelState,datasourceType:this.props.datasourceType})),this.state.visualisationType==="logs"&&pe&&t.createElement("div",{className:V.$.featureToggles.logsInfiniteScrolling?U.scrollableLogRows:U.logRows,"data-testid":"logRows",ref:this.onLogsContainerRef},t.createElement(js,{loading:c,loadMoreLogs:D,range:this.props.range,timeZone:u,rows:s,scrollElement:this.state.logsContainer,sortOrder:A},t.createElement(Ln.k,{logRows:s,deduplicatedRows:Li,dedupStrategy:ue,onClickFilterLabel:m,onClickFilterOutLabel:p,showContextToggle:y,getRowContextQuery:$,showLabels:T,showTime:k,enableLogDetails:!0,forceEscape:Q,wrapLogMessage:Z,prettifyLogMessage:W,timeZone:u,getFieldLinks:E,logsSortOrder:A,displayedFields:F,onClickShowField:this.showField,onClickHideField:this.hideField,app:je.Jk.Explore,onLogRowHover:this.onLogRowHover,onOpenContext:this.onOpenContext,onPermalinkClick:this.onPermalinkClick,permalinkedRowId:this.props.panelState?.logs?.id,scrollIntoView:this.scrollIntoView,isFilterLabelActive:this.props.isFilterLabelActive,containerRendered:!!this.state.logsContainer,onClickFilterValue:this.props.onClickFilterValue,onClickFilterOutValue:this.props.onClickFilterOutValue}))),!c&&!pe&&!f&&t.createElement("div",{className:U.logRows},t.createElement("div",{className:U.noData},"No logs found.",t.createElement(j.$n,{size:"sm",variant:"secondary",onClick:this.onClickScan},"Scan for older logs"))),f&&t.createElement("div",{className:U.logRows},t.createElement("div",{className:U.noData},t.createElement("span",null,Oi),t.createElement(j.$n,{size:"sm",variant:"secondary",onClick:this.onClickStopScan},"Stop scan"))),t.createElement(ya,{logsSortOrder:A,visibleRange:Fi??v,absoluteRange:v,timeZone:u,onChangeTime:b,loading:c,queries:R??[],scrollToTopLogs:this.scrollToTopLogs,addResultsToCache:L,clearCache:S}))))}}const Ua=(0,N.cV)(Qa),ja=(e,o,n)=>({noData:(0,h.css)({"& > *":{marginLeft:"0.5em"}}),logOptions:(0,h.css)({display:"flex",justifyContent:"space-between",alignItems:"baseline",flexWrap:"wrap",backgroundColor:e.colors.background.primary,padding:`${e.spacing(1)} ${e.spacing(2)}`,borderRadius:e.shape.radius.default,margin:`${e.spacing(0,0,1)}`,border:`1px solid ${e.colors.border.medium}`}),headerButton:(0,h.css)({margin:`${e.spacing(.5,0,0,1)}`}),horizontalInlineLabel:(0,h.css)({"& > label":{marginRight:"0"}}),horizontalInlineSwitch:(0,h.css)({padding:`0 ${e.spacing(1)} 0 0`}),radioButtons:(0,h.css)({margin:"0"}),logsSection:(0,h.css)({display:"flex",flexDirection:"row",justifyContent:"space-between"}),logsTable:(0,h.css)({maxHeight:`${n}px`}),scrollableLogRows:(0,h.css)({overflowY:"scroll",width:"100%",maxHeight:"75vh"}),logRows:(0,h.css)({overflowX:`${o?"unset":"scroll"}`,overflowY:"visible",width:"100%"}),visualisationType:(0,h.css)({display:"flex",flex:"1",justifyContent:"space-between"}),visualisationTypeRadio:(0,h.css)({margin:`0 0 0 ${e.spacing(1)}`}),stickyNavigation:(0,h.css)({overflow:"visible",...V.$.featureToggles.logsInfiniteScrolling&&{marginBottom:"0px"}})}),$t=500,kt=100,Ga=(0,ze.A)(()=>({logsEnter:(0,h.css)` label: logsEnter; position: absolute; opacity: 0; height: auto; width: 100%; `,logsEnterActive:(0,h.css)` label: logsEnterActive; opacity: 1; transition: opacity ${$t}ms ease-out ${kt}ms; `,logsExit:(0,h.css)` label: logsExit; position: absolute; opacity: 1; height: auto; width: 100%; `,logsExitActive:(0,h.css)` label: logsExitActive; opacity: 0; transition: opacity ${$t}ms ease-out ${kt}ms; `}));function jn(e){const{visible:o,children:n}=e,s=Ga();return t.createElement(fn.A,{in:o,mountOnEnter:!0,unmountOnExit:!0,timeout:$t+kt,classNames:{enter:s.logsEnter,enterActive:s.logsEnterActive,exit:s.logsExit,exitActive:s.logsExitActive}},n)}class qa extends t.PureComponent{constructor(){super(...arguments),this.state={dsInstances:{}},this.onChangeTime=o=>{const{exploreId:n,updateTimeRange:s}=this.props;s({exploreId:n,absoluteRange:o})},this.loadMoreLogs=o=>{const{exploreId:n,loadMoreLogs:s}=this.props;s({exploreId:n,absoluteRange:o})},this.getLogRowContext=async(o,n,s)=>{const{logsQueries:a}=this.props;if(!n.dataFrame.refId||!this.state.dsInstances[n.dataFrame.refId])return Promise.resolve([]);const r=this.state.dsInstances[n.dataFrame.refId];if(!(0,Y.Ol)(r))return Promise.resolve([]);const i=this.getQuery(a,n,r);return i?r.getLogRowContext(o,s,i):Promise.resolve([])},this.getLogRowContextQuery=async(o,n,s=!0)=>{const{logsQueries:a}=this.props;if(!o.dataFrame.refId||!this.state.dsInstances[o.dataFrame.refId])return Promise.resolve(null);const r=this.state.dsInstances[o.dataFrame.refId];if(!(0,Y.Ol)(r))return Promise.resolve(null);const i=this.getQuery(a,o,r);return i&&r.getLogRowContextQuery?r.getLogRowContextQuery(o,n,i,s):Promise.resolve(null)},this.getLogRowContextUi=(o,n)=>{const{logsQueries:s}=this.props;if(!o.dataFrame.refId||!this.state.dsInstances[o.dataFrame.refId])return t.createElement(t.Fragment,null);const a=this.state.dsInstances[o.dataFrame.refId];if(!(0,Y.Ol)(a))return t.createElement(t.Fragment,null);const r=this.getQuery(s,o,a);return r&&(0,Y.wj)(a)&&a.getLogRowContextUi?a.getLogRowContextUi(o,n,r):t.createElement(t.Fragment,null)},this.showContextToggle=o=>!o?.dataFrame.refId||!this.state.dsInstances[o.dataFrame.refId]?!1:(0,Y.Ol)(this.state.dsInstances[o.dataFrame.refId]),this.getFieldLinks=(o,n,s)=>{const{splitOpenFn:a,range:r}=this.props;return(0,Ie.QL)({field:o,rowIndex:n,splitOpenFn:a,range:r,dataFrame:s})},this.logDetailsFilterAvailable=()=>Object.values(this.state.dsInstances).some(o=>o?.modifyQuery||(0,Y._0)(o)||(0,Y.FP)(o)),this.filterValueAvailable=()=>Object.values(this.state.dsInstances).some(o=>(0,Y._0)(o)&&o?.getSupportedQueryModifications().includes("ADD_STRING_FILTER")),this.filterOutValueAvailable=()=>Object.values(this.state.dsInstances).some(o=>(0,Y._0)(o)&&o?.getSupportedQueryModifications().includes("ADD_STRING_FILTER_OUT")),this.addResultsToCache=()=>{this.props.addResultsToCache(this.props.exploreId)},this.clearCache=()=>{this.props.clearCache(this.props.exploreId)}}componentDidMount(){this.updateDataSourceInstances()}componentDidUpdate(o){o.logsQueries!==this.props.logsQueries&&this.updateDataSourceInstances()}updateDataSourceInstances(){const{logsQueries:o,datasourceInstance:n}=this.props;if(!o||!n)return;const s={};if(n.uid!==et.uv){o.forEach(({refId:r})=>{s[r]=n}),this.setState({dsInstances:s});return}const a=[];for(const r of o){if(!r.datasource)continue;(!s[r.refId]||s[r.refId].uid!==r.datasource.uid)&&a.push(new Promise(l=>{(0,He.l)().get(r.datasource).then(c=>{l({ds:c,refId:r.refId})})}))}a.length&&Promise.all(a).then(r=>{r.forEach(({ds:i,refId:l})=>{s[l]=i}),this.setState({dsInstances:s})})}getQuery(o,n,s){return(o??[]).find(a=>a.refId===n.dataFrame.refId&&a.datasource!=null&&a.datasource.type===s.type)}render(){const{loading:o,loadingState:n,logRows:s,logsMeta:a,logsSeries:r,logsQueries:i,loadSupplementaryQueryData:l,setSupplementaryQueryEnabled:c,onClickFilterLabel:m,onClickFilterOutLabel:p,onStartScanning:u,onStopScanning:f,absoluteRange:g,timeZone:y,visibleRange:v,scanning:b,range:E,width:C,splitOpenFn:R,isLive:S,exploreId:L,logsVolume:I,scrollElement:H}=this.props;return s?t.createElement(t.Fragment,null,t.createElement(jn,{visible:S},t.createElement(at.S,{label:"Logs",loading:!1,isOpen:!0},t.createElement(yn,{exploreId:L},z=>t.createElement(Qs,{logRows:s,timeZone:y,stopLive:z.stop,isPaused:this.props.isPaused,onPause:z.pause,onResume:z.resume,onClear:z.clear,clearedAtIndex:this.props.clearedAtIndex})))),t.createElement(jn,{visible:!S},t.createElement(Ua,{exploreId:L,datasourceType:this.props.datasourceInstance?.type,logRows:s,logsMeta:a,logsSeries:r,logsVolumeEnabled:I.enabled,onSetLogsVolumeEnabled:z=>c(L,z,Y.cF.LogsVolume),logsVolumeData:I.data,logsQueries:i,width:C,splitOpen:R,loading:o,loadingState:n,loadLogsVolumeData:()=>l(L,Y.cF.LogsVolume),onChangeTime:this.onChangeTime,loadMoreLogs:this.loadMoreLogs,onClickFilterLabel:this.logDetailsFilterAvailable()?m:void 0,onClickFilterOutLabel:this.logDetailsFilterAvailable()?p:void 0,onStartScanning:u,onStopScanning:f,absoluteRange:g,visibleRange:v,timeZone:y,scanning:b,scanRange:E.raw,showContextToggle:this.showContextToggle,getRowContext:this.getLogRowContext,getRowContextQuery:this.getLogRowContextQuery,getLogRowContextUi:this.getLogRowContextUi,getFieldLinks:this.getFieldLinks,addResultsToCache:this.addResultsToCache,clearCache:this.clearCache,eventBus:this.props.eventBus,panelState:this.props.panelState,logsFrames:this.props.logsFrames,scrollElement:H,isFilterLabelActive:this.logDetailsFilterAvailable()?this.props.isFilterLabelActive:void 0,range:E,onClickFilterValue:this.filterValueAvailable()?this.props.onClickFilterValue:void 0,onClickFilterOutValue:this.filterOutValueAvailable()?this.props.onClickFilterOutValue:void 0}))):null}}function Ka(e,{exploreId:o}){const s=e.explore.panes[o],{logsResult:a,scanning:r,datasourceInstance:i,isLive:l,isPaused:c,clearedAtIndex:m,range:p,absoluteRange:u,supplementaryQueries:f}=s,g=(0,q.h1)(o)(e),y=s.panelsState,v=(0,st.O)(e.user),b=f[Y.cF.LogsVolume];return{loading:g,logRows:a?.rows,logsMeta:a?.meta,logsSeries:a?.series,logsQueries:a?.queries,visibleRange:a?.visibleRange,scanning:r,timeZone:v,datasourceInstance:i,isLive:l,isPaused:c,clearedAtIndex:m,range:p,absoluteRange:u,logsVolume:b,panelState:y,logsFrames:s.queryResponse.logsFrames}}const Za={updateTimeRange:de.GH,loadMoreLogs:de.zY,addResultsToCache:q.He,clearCache:q.IL,loadSupplementaryQueryData:q.Az,setSupplementaryQueryEnabled:q.TO},Ya=(0,me.connect)(Ka,Za)(qa);function Ja(e){const{queryResponse:o,timeZone:n,enabled:s,setLogsSampleEnabled:a,datasourceInstance:r,queries:i,splitOpen:l}=e,c=(0,N.of)(Xa),m=f=>{a(f),(0,P.rR)("grafana_explore_logs_sample_toggle_clicked",{datasourceType:r?.type??"unknown",type:f?"open":"close"})},p=()=>{if(!r||!(0,Y.Nc)(r,Y.cF.LogsSample))return null;const f=i.map(y=>r.getSupplementaryQuery({type:Y.cF.LogsSample},y)).filter(y=>!!y);if(!f.length)return null;const g=()=>{l({queries:f,datasourceUid:r.uid}),(0,P.rR)("grafana_explore_logs_sample_split_button_clicked",{datasourceType:r?.type??"unknown",queriesCount:f.length})};return t.createElement(j.$n,{size:"sm",className:c.logSamplesButton,onClick:g},"Open logs in split view")};let u;if(o===void 0)u=null;else if(o.error!==void 0)u=t.createElement(Mt,{error:o.error,title:"Failed to load logs sample for this query"});else if(o.state===le.Gu.Loading)u=t.createElement("span",null,"Logs sample is loading...");else if(o.data.length===0||o.data.every(f=>f.length===0))u=t.createElement("span",null,"No logs sample data.");else{const f=(0,Ot.HT)(o.data);u=t.createElement(t.Fragment,null,t.createElement(p,null),t.createElement("div",{className:c.logContainer},t.createElement(Ln.k,{logRows:f.rows,dedupStrategy:K.fY.none,showLabels:ne.A.getBool(oe.$.showLabels,!1),showTime:ne.A.getBool(oe.$.showTime,!0),wrapLogMessage:ne.A.getBool(oe.$.wrapLogMessage,!0),prettifyLogMessage:ne.A.getBool(oe.$.prettifyLogMessage,!1),timeZone:n,enableLogDetails:!0})))}return o?.state!==le.Gu.NotStarted?t.createElement(at.S,{label:t.createElement("div",null,"Logs sample",t.createElement(he.m,{content:"Show log lines that contributed to visualized metrics"},t.createElement(ie.I,{name:"info-circle",className:c.infoTooltip}))),isOpen:s,collapsible:!0,onToggle:m},u):null}const Xa=e=>({logSamplesButton:(0,h.css)` position: absolute; top: ${e.spacing(1)}; right: ${e.spacing(1)}; `,logContainer:(0,h.css)` overflow: scroll; `,infoTooltip:(0,h.css)` margin-left: ${e.spacing(1)}; `}),_a=()=>{const e=(0,N.of)(er);return t.createElement(t.Fragment,null,t.createElement(bt._,{"data-testid":"explore-no-data",className:e.wrapper},t.createElement("span",{className:e.message},"No data")))},er=e=>({wrapper:(0,h.css)({label:"no-data-card",padding:e.spacing(3),background:e.colors.background.primary,borderRadius:e.shape.radius.default,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flexGrow:1}),message:(0,h.css)({fontSize:e.typography.h2.fontSize,padding:e.spacing(4),color:e.colors.text.disabled})});var tr=d(76442);function nr(e){return(0,h.css)({maxWidth:`${e.breakpoints.values.lg}px`,marginTop:e.spacing(2),alignSelf:"center"})}const or=()=>{const e=(0,N.of)(nr),o=wt.TP.hasPermission(O.AccessControlAction.DataSourcesCreate)&&wt.TP.hasPermission(O.AccessControlAction.DataSourcesWrite),n="Explore requires at least one data source. Once you have added a data source, you can query it here.",s=t.createElement(t.Fragment,null,t.createElement(ie.I,{name:"rocket"}),t.createElement(t.Fragment,null," ProTip: You can also define data sources through configuration files. "),t.createElement("a",{href:"http://docs.grafana.org/administration/provisioning/?utm_source=explore#data-sources",target:"_blank",rel:"noreferrer",className:"text-link"},"Learn more")),a=t.createElement(j.z9,{size:"lg",href:"datasources/new",icon:"database",disabled:!o},"Add data source");return t.createElement(tr.c,{callToActionElement:a,className:e,footer:s,message:n})};var Bt=d(52908),sr=d(95511),ar=d(94382);const rr=e=>({warningText:(0,h.css)` label: warningText; display: flex; align-items: center; font-size: ${e.typography.bodySmall.fontSize}; color: ${e.colors.text.secondary}; `});function ir(e){const{dataFrames:o,range:n,splitOpenFn:s,withTraceView:a,datasourceType:r}=e,i=(0,Ie.JQ)(n,s),l=(0,N.$j)(),c=(0,N.of)(rr),m=(0,ft.we)({fieldConfig:{defaults:{},overrides:[]},data:o,replaceVariables:S=>S,theme:l}),{nodes:p}=(0,ar.d)(m),[u,f]=(0,Zt.A)(!0),g=()=>{f(),(0,P.rR)("grafana_traces_node_graph_panel_clicked",{datasourceType:r,grafana_version:V.$.buildInfo.version,isExpanded:!open})},{height:y}=(0,Bt.A)(),v=(0,t.useRef)(null),[b,E]=(0,t.useState)(250);(0,t.useEffect)(()=>{if(v.current){const{top:S}=v.current.getBoundingClientRect();E(S)}},[v]);const C=y-b-32,R=a&&p[0]?.length>1e3?t.createElement("span",{className:c.warningText}," (",p[0].length," nodes, can be slow to load)"):null;return t.createElement(Se.NR,{title:"Node graph",titleItems:R,collapsible:!!a,collapsed:a?u:!1,onToggleCollapse:a?g:void 0},t.createElement("div",{ref:v,style:a?{height:500}:{minHeight:600,height:C}},t.createElement(sr.F,{dataFrames:m,getLinks:i})))}function lr(e,{exploreId:o}){return{range:e.explore.panes[o].range}}const cr=(0,me.connect)(lr,{})(ir);var Ke=d(1081),dr=d(21969),Gn=d(31193),ur=d(44932);const pr=e=>{const o=(0,J.qq)(e);return{getQueries:(0,Ke.Mz)(o,n=>n.queries),getQueryResponse:(0,Ke.Mz)(o,n=>n.queryResponse),getHistory:(0,Ke.Mz)(o,n=>n.history),getEventBridge:(0,Ke.Mz)(o,n=>n.eventBridge),getDatasourceInstanceSettings:(0,Ke.Mz)(o,n=>(0,Gn.tR)().getInstanceSettings(n.datasourceInstance?.uid))}},hr=({exploreId:e})=>{const o=(0,O.useDispatch)(),{getQueries:n,getDatasourceInstanceSettings:s,getQueryResponse:a,getHistory:r,getEventBridge:i}=(0,t.useMemo)(()=>pr(e),[e]),l=(0,O.useSelector)(n),c=(0,O.useSelector)(s),m=(0,O.useSelector)(a),p=(0,O.useSelector)(r),u=(0,O.useSelector)(i),f=(0,t.useCallback)(()=>{o((0,q.Od)({exploreId:e}))},[o,e]),g=(0,t.useCallback)(C=>{o((0,q.bO)({exploreId:e,queries:C}))},[o,e]),y=(0,t.useCallback)(C=>{g([...l,{...C,refId:(0,dr.W3)(l)}])},[g,l]),v=()=>{(0,P.rR)("grafana_explore_query_row_copy")},b=()=>{(0,P.rR)("grafana_explore_query_row_remove")},E=C=>{(0,P.rR)("grafana_query_row_toggle",C===void 0?{}:{queryEnabled:C})};return t.createElement(ur.L,{dsSettings:c,queries:l,onQueriesChange:g,onAddQuery:y,onRunQueries:f,onQueryCopied:v,onQueryRemoved:b,onQueryToggled:E,data:m,app:je.Jk.Explore,history:p,eventBus:u})};var yt=d(72574),Wt=d(2913),mr=d(15054),gr=d(91793),fr=d(9651),yr=d(9663),qn=d(57408);const Ze={wrapper:(0,h.css)` height: 100%; overflow: scroll; `,switchWrapper:(0,h.css)` display: flex; flex-direction: row; margin-bottom: 0; `,switchLabel:(0,h.css)` margin-left: 15px; margin-bottom: 0; `,switch:(0,h.css)` margin-left: 10px; `,resultCount:(0,h.css)` margin-bottom: 4px; `,header:(0,h.css)` display: flex; justify-content: space-between; align-items: center; padding: 10px 0; font-size: 12px; line-height: 1.25; `},vr=480,Er=2,br=e=>{const{tableResult:o}=e,n=(0,te.cloneDeep)(o),s=(0,t.useRef)(null),a=n.fields.filter(g=>g.name.includes("Value")),r=(0,qn.E)(n),{width:i}=(0,Bt.A)(),[l,c]=(0,t.useState)(i<=vr||a.length>Er),m=()=>{c(!l);const g={isExpanded:!l};(0,P.rR)("grafana_explore_prometheus_instant_query_ui_raw_toggle_expand",g)};(0,t.useEffect)(()=>{s.current?.resetAfterIndex(0,!0)},[l]);const p=g=>{if(g<10){let b=0;for(let E=0;E
{if(!y)return 32;const E=r[g];return 1.5*32+(Object.keys(E).length-a.length)*22},f=`isExpandedView ${(0,t.useId)()}`;return t.createElement("section",null,t.createElement("header",{className:Ze.header},t.createElement(xe.D,{className:Ze.switchWrapper,label:"Expand results",htmlFor:"isExpandedView"},t.createElement("div",{className:Ze.switch},t.createElement(Fe.d,{onChange:m,id:f,value:l,label:"Expand results"}))),t.createElement("div",{className:Ze.resultCount},"Result series: ",r.length)),t.createElement("div",{role:"table"},t.createElement(t.Fragment,null,a.length>1&&!l&&t.createElement(fr.d,{valueLabels:a,expanded:l}),t.createElement(gr._m,{ref:s,itemCount:r.length,className:Ze.wrapper,itemSize:g=>u(g,l),height:p(r.length),width:"100%"},({index:g,style:y})=>{let v;return l&&(v=a.filter(b=>{const E=r[g][b.name];return E&&E!==qn.M})),t.createElement("div",{role:"row",style:{...y,overflow:"hidden"}},t.createElement(yr.Ay,{isExpandedView:l,valueLabels:v,totalNumberOfValues:a.length,listKey:r[g].__name__,listItemData:r[g]}))}))))};function xr(e,{exploreId:o}){const s=e.explore.panes[o],{tableResult:a,rawPrometheusResult:r,range:i,queryResponse:l}=s,c=r?[r]:[],m=(a?.length??0)>0&&r?a:c;return{loading:l.state,tableResult:m,range:i}}const Sr=(0,me.connect)(xr,{});class Cr extends t.PureComponent{constructor(o){super(o),this.onChangeResultsStyle=n=>{this.setState({resultsStyle:n})},this.renderLabel=()=>{const n=(0,h.css)({display:"flex",justifyContent:"space-between",flex:"1"}),s=Rt.jH.map(a=>({value:a,label:a[0].toUpperCase()+a.slice(1).replace(/_/," ")}));return t.createElement("div",{className:n},t.createElement(mt.z,{onClick:()=>{const a={state:this.state.resultsStyle===O.TABLE_RESULTS_STYLE.table?O.TABLE_RESULTS_STYLE.raw:O.TABLE_RESULTS_STYLE.table};(0,P.rR)("grafana_explore_prometheus_instant_query_ui_toggle_clicked",a)},size:"sm",options:s,value:this.state?.resultsStyle,onChange:this.onChangeResultsStyle}))},o.showRawPrometheus&&(this.state={resultsStyle:O.TABLE_RESULTS_STYLE.raw})}getTableHeight(){const{tableResult:o}=this.props;return!o||o.length===0?200:Math.max(Math.min(600,o[0].length*35)+35)}render(){const{loading:o,onCellFilterAdded:n,tableResult:s,width:a,splitOpenFn:r,range:i,ariaLabel:l,timeZone:c}=this.props,m=this.getTableHeight(),p=a-Wt.$W.theme.panelPadding*2-mr.IZ;let u=s;const f=(0,Ie.YV)(r,i);u?.length&&(u=(0,ft.we)({data:u,timeZone:c,theme:Wt.$W.theme2,replaceVariables:(0,yt.w)().replace.bind((0,yt.w)()),fieldConfig:{defaults:{},overrides:[]},dataLinkPostProcessor:f}));const g=u?.filter(E=>!!E&&E.length!==0),y=this.state.resultsStyle===O.TABLE_RESULTS_STYLE.raw?"Raw":"Table",v=this.state?.resultsStyle!==void 0?this.renderLabel():"Table",b=!this.state?.resultsStyle||this.state?.resultsStyle===O.TABLE_RESULTS_STYLE.table;return t.createElement(Se.NR,{title:y,actions:v,loadingState:o},g?.length&&t.createElement(t.Fragment,null,b&&t.createElement(At.X,{ariaLabel:l,data:g[0],width:p,height:m,onCellFilterAdded:n}),this.state?.resultsStyle===O.TABLE_RESULTS_STYLE.raw&&t.createElement(br,{tableResult:g[0]})),!g?.length&&t.createElement(Dt,{metaItems:[{value:"0 series returned"}]}))}}const Rr=Sr(Cr);var wr=d(22669);const Tr=e=>{const o={transition:`opacity ${e.duration}ms linear`,opacity:0},n={exited:{opacity:0,display:"none"},entering:{opacity:0},entered:{opacity:1},exiting:{opacity:0}};return t.createElement(wr.Ay,{in:e.in,timeout:e.duration,unmountOnExit:e.unmountOnExit||!1,onExited:e.onExited},s=>t.createElement("div",{style:{...o,...n[s]}},e.children))},Lr=e=>{const{queryError:o}=e,n=!!o,s=n?100:10,a=o?"Query error":"Unknown error",r=o?.message||o?.data?.message||null;return t.createElement(Tr,{in:n,duration:s},t.createElement(Ve.F,{severity:"error",title:a,topSpacing:2},r))};function Ir(e){const o=(0,O.useSelector)(s=>s.explore.panes[e.exploreId].queryResponse),n=o?.state===le.Gu.Error?o?.error:void 0;return n?.refId?null:t.createElement(Lr,{queryError:n})}var ve=d(72433),se=d(81523),Fr=d(47097),Kn=d(67647),Oe=d(3591),Or=d(21744),Dr=d(39558),Vt=d(82467),Qt=d(3169),De=d(28444);function Ar(e,{exploreId:o}){const n=e.explore,{datasourceInstance:s}=n.panes[o];return{exploreId:o,datasourceInstance:s}}const Nr={changeDatasource:Ne.wh,deleteHistoryItem:ve.VM,commentHistoryItem:ve.H9,starHistoryItem:ve.sh,setQueries:q.Rk},zr=(0,me.connect)(Ar,Nr),Hr=e=>{const o="240px",n="170px",s=e.colors.background.secondary;return{queryCard:(0,h.css)` position: relative; display: flex; flex-direction: column; border: 1px solid ${e.colors.border.weak}; margin: ${e.spacing(1)} 0; background-color: ${s}; border-radius: ${e.shape.radius.default}; .starred { color: ${e.v1.palette.orange}; } `,cardRow:(0,h.css)` display: flex; align-items: center; justify-content: space-between; padding: ${e.spacing(1)}; border-bottom: none; :first-of-type { border-bottom: 1px solid ${e.colors.border.weak}; padding: ${e.spacing(.5,1)}; } img { height: ${e.typography.fontSize}px; max-width: ${e.typography.fontSize}px; margin-right: ${e.spacing(1)}; } `,queryActionButtons:(0,h.css)` max-width: ${n}; display: flex; justify-content: flex-end; font-size: ${e.typography.size.base}; button { margin-left: ${e.spacing(1)}; } `,queryContainer:(0,h.css)` font-weight: ${e.typography.fontWeightMedium}; width: calc(100% - ${o}); `,updateCommentContainer:(0,h.css)` width: calc(100% + ${o}); margin-top: ${e.spacing(1)}; `,comment:(0,h.css)` overflow-wrap: break-word; font-size: ${e.typography.bodySmall.fontSize}; font-weight: ${e.typography.fontWeightRegular}; margin-top: ${e.spacing(.5)}; `,commentButtonRow:(0,h.css)` > * { margin-top: ${e.spacing(1)}; margin-right: ${e.spacing(1)}; } `,textArea:(0,h.css)` width: 100%; `,runButton:(0,h.css)` max-width: ${n}; display: flex; justify-content: flex-end; button { height: auto; padding: ${e.spacing(.5,2)}; line-height: 1.4; span { white-space: normal !important; } } `,loader:(0,h.css)` position: absolute; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background-color: ${e.colors.background.secondary}; `}};function Mr(e){const{queryHistoryItem:o,commentHistoryItem:n,starHistoryItem:s,deleteHistoryItem:a,changeDatasource:r,exploreId:i,datasourceInstance:l,setQueries:c}=e,[m,p]=(0,t.useState)(!1),[u,f]=(0,t.useState)(o.comment),{value:g,loading:y}=(0,en.A)(async()=>{let T;try{T=await(0,He.l)().get(o.datasourceUid)}catch{}return{datasourceInstance:T,queries:await Promise.all(o.queries.map(async k=>{let Z;if(T?.meta.mixed)try{Z=await(0,He.l)().get(k.datasource)}catch{}else Z=T;return{query:k,datasource:Z}}))}},[o.datasourceUid,o.queries]),v=(0,N.of)(Hr),b=async()=>{const T=o.queries,k=o.datasourceUid!==l?.uid;k&&await r({exploreId:i,datasource:o.datasourceUid}),c(i,T),(0,P.rR)("grafana_explore_query_history_run",{queryHistoryEnabled:V.$.queryHistoryEnabled,differentDataSource:k})},E=async()=>{const T=[...o.queries.map(Z=>Z.datasource?.type||"unknown")];if((0,P.rR)("grafana_explore_query_history_copy_query",{datasources:T,mixed:!!g?.datasourceInstance?.meta.mixed}),y||!g)return;const k=g.queries.map(Z=>(0,se.Ax)(Z.query,Z.datasource)).join(` `);(0,Be.uJ)(k),(0,Le.JD)((0,Vt.dx)((0,Qt.tZ)((0,x.t)("explore.rich-history-notification.query-copied","Query copied to clipboard"))))},C=async()=>{const T=(0,se.U3)(o);await(0,Lt.V)(T)},R=()=>{const T=k=>{a(k),(0,Le.JD)((0,Vt.dx)((0,Qt.tZ)((0,x.t)("explore.rich-history-notification.query-deleted","Query deleted")))),(0,P.rR)("grafana_explore_query_history_deleted",{queryHistoryEnabled:V.$.queryHistoryEnabled})};o.starred?(0,Oe.J7)().publish(new De.bY({title:(0,x.t)("explore.rich-history-card.delete-query-confirmation-title","Delete"),text:(0,x.t)("explore.rich-history-card.delete-starred-query-confirmation-text","Are you sure you want to permanently delete your starred query?"),yesText:(0,x.t)("explore.rich-history-card.confirm-delete","Delete"),icon:"trash-alt",onConfirm:()=>T(o.id)})):T(o.id)},S=()=>{s(o.id,!o.starred),(0,P.rR)("grafana_explore_query_history_starred",{queryHistoryEnabled:V.$.queryHistoryEnabled,newValue:!o.starred})},L=()=>p(!m),I=()=>{n(o.id,u),p(!1),(0,P.rR)("grafana_explore_query_history_commented",{queryHistoryEnabled:V.$.queryHistoryEnabled})},H=()=>{p(!1),f(o.comment)},z=T=>{T.key==="Enter"&&(T.shiftKey||T.ctrlKey)&&I(),T.key==="Escape"&&H()},$=t.createElement("div",{className:v.updateCommentContainer,"aria-label":u?(0,x.t)("explore.rich-history-card.update-comment-form","Update comment form"):(0,x.t)("explore.rich-history-card.add-comment-form","Add comment form")},t.createElement(Or.f,{onKeyDown:z,value:u,placeholder:u?void 0:(0,x.t)("explore.rich-history-card.optional-description","An optional description of what the query does."),onChange:T=>f(T.currentTarget.value),className:v.textArea}),t.createElement("div",{className:v.commentButtonRow},t.createElement(j.$n,{onClick:I},t.createElement(x.x6,{i18nKey:"explore.rich-history-card.save-comment"},"Save comment")),t.createElement(j.$n,{variant:"secondary",onClick:H},t.createElement(x.x6,{i18nKey:"explore.rich-history-card.cancel"},"Cancel")))),D=t.createElement("div",{className:v.queryActionButtons},t.createElement(Me.K,{name:"comment-alt",onClick:L,tooltip:o.comment?.length>0?(0,x.t)("explore.rich-history-card.edit-comment-tooltip","Edit comment"):(0,x.t)("explore.rich-history-card.add-comment-tooltip","Add comment")}),t.createElement(Me.K,{name:"copy",onClick:E,tooltip:(0,x.t)("explore.rich-history-card.copy-query-tooltip","Copy query to clipboard")}),g?.datasourceInstance&&t.createElement(Me.K,{name:"share-alt",onClick:C,tooltip:t.createElement(x.x6,{i18nKey:"explore.rich-history-card.copy-shortened-link-tooltip"},"Copy shortened link to clipboard")}),t.createElement(Me.K,{name:"trash-alt",title:(0,x.t)("explore.rich-history-card.delete-query-title","Delete query"),tooltip:(0,x.t)("explore.rich-history-card.delete-query-tooltip","Delete query"),onClick:R}),t.createElement(Me.K,{name:o.starred?"favorite":"star",iconType:o.starred?"mono":"default",onClick:S,tooltip:o.starred?(0,x.t)("explore.rich-history-card.unstar-query-tooltip","Unstar query"):(0,x.t)("explore.rich-history-card.star-query-tooltip","Star query")}));return t.createElement("div",{className:v.queryCard},t.createElement("div",{className:v.cardRow},t.createElement(Zn,{dsApi:g?.datasourceInstance,size:"sm"}),D),t.createElement("div",{className:(0,h.cx)(v.cardRow)},t.createElement("div",{className:v.queryContainer},g?.queries.map((T,k)=>t.createElement($r,{query:T,key:`${T}-${k}`,showDsInfo:g?.datasourceInstance?.meta.mixed})),!m&&o.comment&&t.createElement("div",{"aria-label":(0,x.t)("explore.rich-history-card.query-comment-label","Query comment"),className:v.comment},o.comment),m&&$),!m&&t.createElement("div",{className:v.runButton},t.createElement(j.$n,{variant:"secondary",onClick:b,disabled:!g?.datasourceInstance||g.queries.some(T=>!T.datasource)},l?.uid===o.datasourceUid?t.createElement(x.x6,{i18nKey:"explore.rich-history-card.run-query-button"},"Run query"):t.createElement(x.x6,{i18nKey:"explore.rich-history-card.switch-datasource-button"},"Switch data source and run query")))),y&&t.createElement(Dr._,{text:(0,x.t)("explore.rich-history-card.loading-text","loading..."),className:v.loader}))}const Pr=e=>({queryRow:(0,h.css)` border-top: 1px solid ${e.colors.border.weak}; display: flex; flex-direction: row; padding: 4px 0px; gap: 4px; :first-child { border-top: none; } `,dsInfoContainer:(0,h.css)` display: flex; align-items: center; `,queryText:(0,h.css)` word-break: break-all; `}),$r=({query:e,showDsInfo:o=!1})=>{const n=(0,N.of)(Pr);return t.createElement("div",{className:n.queryRow},o&&t.createElement("div",{className:n.dsInfoContainer},t.createElement(Zn,{dsApi:e.datasource,size:"md"}),": "),t.createElement("span",{"aria-label":(0,x.t)("explore.rich-history-card.query-text-label","Query text"),className:n.queryText},(0,se.Ax)(e.query,e.datasource)))},kr=e=>o=>(0,h.css)` display: flex; align-items: center; font-size: ${o.typography[e==="sm"?"bodySmall":"body"].fontSize}; font-weight: ${o.typography.fontWeightMedium}; white-space: nowrap; `;function Zn({dsApi:e,size:o}){const n=(0,t.useCallback)(a=>kr(o)(a),[o]),s=(0,N.of)(n);return t.createElement("div",{className:s},t.createElement("img",{src:e?.meta.info.logos.small||"public/img/icn-datasource.svg",alt:e?.type||(0,x.t)("explore.rich-history-card.datasource-not-exist","Data source does not exist anymore"),"aria-label":(0,x.t)("explore.rich-history-card.datasource-icon-label","Data source icon")}),t.createElement("div",{"aria-label":(0,x.t)("explore.rich-history-card.datasource-name-label","Data source name")},e?.name||(0,x.t)("explore.rich-history-card.datasource-not-exist","Data source does not exist anymore")))}const Yn=zr(Mr),Br=(e,o)=>({container:(0,h.css)` display: flex; `,labelSlider:(0,h.css)` font-size: ${e.typography.bodySmall.fontSize}; &:last-of-type { margin-top: ${e.spacing(3)}; } &:first-of-type { font-weight: ${e.typography.fontWeightMedium}; margin-bottom: ${e.spacing(2)}; } `,containerContent:(0,h.css)` /* 134px is based on the width of the Query history tabs bar, so the content is aligned to right side of the tab */ width: calc(100% - 134px); `,containerSlider:(0,h.css)` width: 129px; margin-right: ${e.spacing(1)}; `,fixedSlider:(0,h.css)` position: fixed; `,slider:(0,h.css)` bottom: 10px; height: ${o-180}px; width: 129px; padding: ${e.spacing(1)} 0; `,selectors:(0,h.css)` display: flex; justify-content: space-between; flex-wrap: wrap; `,filterInput:(0,h.css)` margin-bottom: ${e.spacing(1)}; `,multiselect:(0,h.css)` width: 100%; margin-bottom: ${e.spacing(1)}; `,sort:(0,h.css)` width: 170px; `,sessionName:(0,h.css)` display: flex; align-items: flex-start; justify-content: flex-start; margin-top: ${e.spacing(3)}; h4 { margin: 0 10px 0 0; } `,heading:(0,h.css)` font-size: ${e.typography.h4.fontSize}; margin: ${e.spacing(2,.25,1,.25)}; `,footer:(0,h.css)` height: 60px; display: flex; justify-content: center; align-items: center; font-weight: ${e.typography.fontWeightLight}; font-size: ${e.typography.bodySmall.fontSize}; a { font-weight: ${e.typography.fontWeightMedium}; margin-left: ${e.spacing(.25)}; } `,queries:(0,h.css)` font-size: ${e.typography.bodySmall.fontSize}; font-weight: ${e.typography.fontWeightRegular}; margin-left: ${e.spacing(.5)}; `});function Wr(e){const{queries:o,totalQueries:n,loading:s,richHistorySearchFilters:a,updateFilters:r,clearRichHistoryResults:i,loadMoreRichHistory:l,richHistorySettings:c,exploreId:m,height:p,activeDatasourceInstance:u}=e,f=(0,N.of)(Br,p),g=(0,se.TR)();if((0,t.useEffect)(()=>{const E=!c.activeDatasourceOnly&&c.lastUsedDatasourceFilters?c.lastUsedDatasourceFilters:[u],C={search:"",sortOrder:se.xB.Descending,datasourceFilters:E,from:0,to:c.retentionPeriod,starred:!1};return r(C),()=>{i()}},[]),!a)return t.createElement("span",null,t.createElement(x.x6,{i18nKey:"explore.rich-history-queries-tab.loading"},"Loading..."),";");const y=(0,se.x8)(o,a.sortOrder),v=Xn(),b=o.length&&o.length!==n;return t.createElement("div",{className:f.container},t.createElement("div",{className:f.containerSlider},t.createElement("div",{className:f.fixedSlider},t.createElement("div",{className:f.labelSlider},t.createElement(x.x6,{i18nKey:"explore.rich-history-queries-tab.filter-history"},"Filter history")),t.createElement("div",{className:f.labelSlider},(0,se.IA)(a.from)),t.createElement("div",{className:f.slider},t.createElement(Fr.F,{tooltipAlwaysVisible:!1,min:0,max:c.retentionPeriod,value:[a.from,a.to],orientation:"vertical",formatTooltipResult:se.IA,reverse:!0,onAfterChange:E=>{r({from:E[0],to:E[1]})}})),t.createElement("div",{className:f.labelSlider},(0,se.IA)(a.to)))),t.createElement("div",{className:f.containerContent,"data-testid":"query-history-queries-tab"},t.createElement("div",{className:f.selectors},!c.activeDatasourceOnly&&t.createElement(Re.KF,{className:f.multiselect,options:g.map(E=>({value:E.name,label:E.name})),value:a.datasourceFilters,placeholder:(0,x.t)("explore.rich-history-queries-tab.filter-placeholder","Filter queries for data sources(s)"),"aria-label":(0,x.t)("explore.rich-history-queries-tab.filter-aria-label","Filter queries for data sources(s)"),onChange:E=>{r({datasourceFilters:E.map(C=>C.value)})}}),t.createElement("div",{className:f.filterInput},t.createElement(Kn.Z,{escapeRegex:!1,placeholder:(0,x.t)("explore.rich-history-queries-tab.search-placeholder","Search queries"),value:a.search,onChange:E=>r({search:E})})),t.createElement("div",{"aria-label":(0,x.t)("explore.rich-history-queries-tab.sort-aria-label","Sort queries"),className:f.sort},t.createElement(Re.l6,{value:v.filter(E=>E.value===a.sortOrder),options:v,placeholder:(0,x.t)("explore.rich-history-queries-tab.sort-placeholder","Sort queries by"),onChange:E=>r({sortOrder:E.value})}))),s&&t.createElement("span",null,t.createElement(x.x6,{i18nKey:"explore.rich-history-queries-tab.loading-results"},"Loading results...")),!s&&Object.keys(y).map(E=>t.createElement("div",{key:E},t.createElement("div",{className:f.heading},E," ",t.createElement("span",{className:f.queries},b?t.createElement(x.x6,{i18nKey:"explore.rich-history-queries-tab.displaying-partial-queries",defaults:"Displaying {{ count }} queries",values:{count:y[E].length}}):t.createElement(x.x6,{i18nKey:"explore.rich-history-queries-tab.displaying-queries",defaults:"{{ count }} queries",values:{count:y[E].length}}))),y[E].map(C=>t.createElement(Yn,{queryHistoryItem:C,key:C.id,exploreId:m})))),b?t.createElement("div",null,t.createElement(x.x6,{i18nKey:"explore.rich-history-queries-tab.showing-queries",defaults:"Showing {{ shown }} of {{ total }} <0>Load more0>",values:{shown:o.length,total:n},components:[t.createElement(j.$n,{onClick:l,key:"loadMoreButton"},"Load more")]})):null,t.createElement("div",{className:f.footer},V.$.queryHistoryEnabled?"":(0,x.t)("explore.rich-history-queries-tab.history-local","The history is local to your browser and is not shared with others."))))}var Vr=d(53919);const Qr=e=>({container:(0,h.css)` font-size: ${e.typography.bodySmall.fontSize}; `,spaceBetween:(0,h.css)` margin-bottom: ${e.spacing(3)}; `,input:(0,h.css)` max-width: 200px; `,bold:(0,h.css)` font-weight: ${e.typography.fontWeightBold}; `,bottomMargin:(0,h.css)` margin-bottom: ${e.spacing(1)}; `}),Jn=[{value:2,label:(0,x.t)("explore.rich-history-settings-tab.retention-period.2-days","2 days")},{value:5,label:(0,x.t)("explore.rich-history-settings-tab.retention-period.5-days","5 days")},{value:7,label:(0,x.t)("explore.rich-history-settings-tab.retention-period.1-week","1 week")},{value:14,label:(0,x.t)("explore.rich-history-settings-tab.retention-period.2-weeks","2 weeks")}];function Ur(e){const{retentionPeriod:o,starredTabAsFirstTab:n,activeDatasourceOnly:s,onChangeRetentionPeriod:a,toggleStarredTabAsFirstTab:r,toggleactiveDatasourceOnly:i,deleteRichHistory:l}=e,c=(0,N.of)(Qr),m=Jn.find(u=>u.value===o),p=()=>{(0,Oe.J7)().publish(new De.bY({title:(0,x.t)("explore.rich-history-settings-tab.delete-title","Delete"),text:(0,x.t)("explore.rich-history-settings-tab.delete-confirm-text","Are you sure you want to permanently delete your query history?"),yesText:(0,x.t)("explore.rich-history-settings-tab.delete-confirm","Delete"),icon:"trash-alt",onConfirm:()=>{l(),(0,Le.JD)((0,Vt.dx)((0,Qt.tZ)((0,x.t)("explore.rich-history-settings-tab.query-history-deleted","Query history deleted"))))}}))};return t.createElement("div",{className:c.container},(0,We.g)().changeRetention?t.createElement(xe.D,{label:(0,x.t)("explore.rich-history-settings-tab.history-time-span","History time span"),description:(0,x.t)("explore.rich-history-settings-tab.history-time-span-description","Select the period of time for which Grafana will save your query history. Up to {{MAX_HISTORY_ITEMS}} entries will be stored.",{MAX_HISTORY_ITEMS:Vr.$H})},t.createElement("div",{className:c.input},t.createElement(Re.l6,{value:m,options:Jn,onChange:a}))):t.createElement(Ve.F,{severity:"info",title:(0,x.t)("explore.rich-history-settings-tab.history-time-span","History time span")},(0,x.t)("explore.rich-history-settings-tab.alert-info","Grafana will keep entries up to {{optionLabel}}.Starred entries won't be deleted.",{optionLabel:m?.label})),t.createElement(ye.I,{label:(0,x.t)("explore.rich-history-settings-tab.change-default-tab","Change the default active tab from \u201CQuery history\u201D to \u201CStarred\u201D"),className:c.spaceBetween},t.createElement(Fe.K,{id:"explore-query-history-settings-default-active-tab",value:n,onChange:r})),(0,We.g)().onlyActiveDataSource&&t.createElement(ye.I,{label:(0,x.t)("explore.rich-history-settings-tab.only-show-active-datasource","Only show queries for data source currently active in Explore"),className:c.spaceBetween},t.createElement(Fe.K,{id:"explore-query-history-settings-data-source-behavior",value:s,onChange:i})),(0,We.g)().clearHistory&&t.createElement("div",null,t.createElement("div",{className:c.bold},t.createElement(x.x6,{i18nKey:"explore.rich-history-settings-tab.clear-query-history"},"Clear query history")),t.createElement("div",{className:c.bottomMargin},t.createElement(x.x6,{i18nKey:"explore.rich-history-settings-tab.clear-history-info"},"Delete all of your query history, permanently.")),t.createElement(j.$n,{variant:"destructive",onClick:p},t.createElement(x.x6,{i18nKey:"explore.rich-history-settings-tab.clear-query-history-button"},"Clear query history"))))}const jr=e=>({container:(0,h.css)` display: flex; `,containerContent:(0,h.css)` width: 100%; `,selectors:(0,h.css)` display: flex; justify-content: space-between; flex-wrap: wrap; `,multiselect:(0,h.css)` width: 100%; margin-bottom: ${e.spacing(1)}; `,filterInput:(0,h.css)` margin-bottom: ${e.spacing(1)}; `,sort:(0,h.css)` width: 170px; `,footer:(0,h.css)` height: 60px; display: flex; justify-content: center; align-items: center; font-weight: ${e.typography.fontWeightLight}; font-size: ${e.typography.bodySmall.fontSize}; a { font-weight: ${e.typography.fontWeightMedium}; margin-left: ${e.spacing(.25)}; } `});function Gr(e){const{updateFilters:o,clearRichHistoryResults:n,loadMoreRichHistory:s,activeDatasourceInstance:a,richHistorySettings:r,queries:i,totalQueries:l,loading:c,richHistorySearchFilters:m,exploreId:p}=e,u=(0,N.of)(jr),f=(0,se.TR)();if((0,t.useEffect)(()=>{const y=r.activeDatasourceOnly&&r.lastUsedDatasourceFilters?r.lastUsedDatasourceFilters:[a],v={search:"",sortOrder:se.xB.Descending,datasourceFilters:y,from:0,to:r.retentionPeriod,starred:!0};return o(v),()=>{n()}},[]),!m)return t.createElement("span",null,t.createElement(x.x6,{i18nKey:"explore.rich-history-starred-tab.loading"},"Loading..."),";");const g=Xn();return t.createElement("div",{className:u.container},t.createElement("div",{className:u.containerContent},t.createElement("div",{className:u.selectors},!r.activeDatasourceOnly&&t.createElement(Re.KF,{className:u.multiselect,options:f.map(y=>({value:y.name,label:y.name})),value:m.datasourceFilters,placeholder:(0,x.t)("explore.rich-history-starred-tab.filter-queries-placeholder","Filter queries for data sources(s)"),"aria-label":(0,x.t)("explore.rich-history-starred-tab.filter-queries-aria-label","Filter queries for data sources(s)"),onChange:y=>{o({datasourceFilters:y.map(v=>v.value)})}}),t.createElement("div",{className:u.filterInput},t.createElement(Kn.Z,{escapeRegex:!1,placeholder:(0,x.t)("explore.rich-history-starred-tab.search-queries-placeholder","Search queries"),value:m.search,onChange:y=>o({search:y})})),t.createElement("div",{"aria-label":(0,x.t)("explore.rich-history-starred-tab.sort-queries-aria-label","Sort queries"),className:u.sort},t.createElement(Re.l6,{value:g.filter(y=>y.value===m.sortOrder),options:g,placeholder:(0,x.t)("explore.rich-history-starred-tab.sort-queries-placeholder","Sort queries by"),onChange:y=>o({sortOrder:y.value})}))),c&&t.createElement("span",null,t.createElement(x.x6,{i18nKey:"explore.rich-history-starred-tab.loading-results"},"Loading results...")),!c&&i.map(y=>t.createElement(Yn,{queryHistoryItem:y,key:y.id,exploreId:p})),i.length&&i.length!==l?t.createElement("div",null,t.createElement(x.x6,{i18nKey:"explore.rich-history-starred-tab.showing-queries",defaults:"Showing {{ shown }} of {{ total }} <0>Load more0>",values:{shown:i.length,total:l},components:[t.createElement(j.$n,{onClick:s,key:"loadMoreButton"},"Load more")]})):null,t.createElement("div",{className:u.footer},V.$.queryHistoryEnabled?"":(0,x.t)("explore.rich-history-starred-tab.local-history-message","The history is local to your browser and is not shared with others."))))}var Ut=(e=>(e.RichHistory="Query history",e.Starred="Starred",e.Settings="Settings",e))(Ut||{});const Xn=()=>[{label:(0,x.t)("explore.rich-history.newest-first","Newest first"),value:se.xB.Descending},{label:(0,x.t)("explore.rich-history.oldest-first","Oldest first"),value:se.xB.Ascending},{label:(0,x.t)("explore.rich-history.datasource-a-z","Data source A-Z"),value:se.xB.DatasourceAZ},{label:(0,x.t)("explore.rich-history.datasource-z-a","Data source Z-A"),value:se.xB.DatasourceZA}].filter(e=>(0,We.g)().availableFilters.includes(e.value));function qr(e){const{richHistory:o,richHistoryTotal:n,height:s,exploreId:a,deleteRichHistory:r,onClose:i,firstTab:l,activeDatasourceInstance:c}=e,[m,p]=(0,t.useState)(!1),u=L=>{e.updateHistorySettings({...e.richHistorySettings,...L})},f=L=>{const I={...e.richHistorySearchFilters,...L,page:1};e.updateHistorySearchFilters(e.exploreId,I),g()},g=(0,te.debounce)(()=>{e.loadRichHistory(e.exploreId),p(!0)},300),y=L=>{L.value!==void 0&&u({retentionPeriod:L.value})},v=()=>u({starredTabAsFirstTab:!e.richHistorySettings.starredTabAsFirstTab}),b=()=>u({activeDatasourceOnly:!e.richHistorySettings.activeDatasourceOnly});(0,t.useEffect)(()=>{p(!1)},[o]);const E={label:(0,x.t)("explore.rich-history.query-history","Query history"),value:"Query history",content:t.createElement(Wr,{queries:o,totalQueries:n||0,loading:m,updateFilters:f,clearRichHistoryResults:()=>e.clearRichHistoryResults(e.exploreId),loadMoreRichHistory:()=>e.loadMoreRichHistory(e.exploreId),activeDatasourceInstance:c,richHistorySettings:e.richHistorySettings,richHistorySearchFilters:e.richHistorySearchFilters,exploreId:a,height:s}),icon:"history"},C={label:(0,x.t)("explore.rich-history.starred","Starred"),value:"Starred",content:t.createElement(Gr,{queries:o,totalQueries:n||0,loading:m,activeDatasourceInstance:c,updateFilters:f,clearRichHistoryResults:()=>e.clearRichHistoryResults(e.exploreId),loadMoreRichHistory:()=>e.loadMoreRichHistory(e.exploreId),richHistorySettings:e.richHistorySettings,richHistorySearchFilters:e.richHistorySearchFilters,exploreId:a}),icon:"star"},R={label:(0,x.t)("explore.rich-history.settings","Settings"),value:"Settings",content:t.createElement(Ur,{retentionPeriod:e.richHistorySettings.retentionPeriod,starredTabAsFirstTab:e.richHistorySettings.starredTabAsFirstTab,activeDatasourceOnly:e.richHistorySettings.activeDatasourceOnly,onChangeRetentionPeriod:y,toggleStarredTabAsFirstTab:v,toggleactiveDatasourceOnly:b,deleteRichHistory:r}),icon:"sliders-v-alt"};let S=[E,C,R];return t.createElement(on.q,{tabs:S,onClose:i,defaultTab:l,closeIconTooltip:(0,x.t)("explore.rich-history.close-tooltip","Close query history")})}function Kr(e,{exploreId:o}){const n=e.explore,s=n.panes[o],a=s.richHistorySearchFilters,r=n.richHistorySettings,{datasourceInstance:i}=s,l=r?.starredTabAsFirstTab?Ut.Starred:Ut.RichHistory,{richHistory:c,richHistoryTotal:m}=s;return{richHistory:c,richHistoryTotal:m,firstTab:l,activeDatasourceInstance:i.name,richHistorySettings:r,richHistorySearchFilters:a}}const Zr={initRichHistory:ve.PA,loadRichHistory:ve.jX,loadMoreRichHistory:ve.Uu,clearRichHistoryResults:ve.wk,updateHistorySettings:ve.fP,updateHistorySearchFilters:ve.Bj,deleteRichHistory:ve.s1},Yr=(0,me.connect)(Kr,Zr);function Jr(e){const o=(0,N.$j)(),[n,s]=(0,t.useState)(o.components.horizontalDrawer.defaultHeight),{richHistory:a,richHistoryTotal:r,width:i,firstTab:l,activeDatasourceInstance:c,exploreId:m,deleteRichHistory:p,initRichHistory:u,loadRichHistory:f,loadMoreRichHistory:g,clearRichHistoryResults:y,richHistorySettings:v,updateHistorySettings:b,richHistorySearchFilters:E,updateHistorySearchFilters:C,onClose:R}=e;return(0,t.useEffect)(()=>{u(),(0,P.rR)("grafana_explore_query_history_opened",{queryHistoryEnabled:V.$.queryHistoryEnabled})},[u]),v?t.createElement(un,{width:i,onResize:(S,L,I)=>{s(Number(I.style.height.slice(0,-2)))}},t.createElement(qr,{richHistory:a,richHistoryTotal:r,firstTab:l,activeDatasourceInstance:c,exploreId:m,onClose:R,height:n,deleteRichHistory:p,richHistorySettings:v,richHistorySearchFilters:E,updateHistorySettings:b,updateHistorySearchFilters:C,loadRichHistory:f,loadMoreRichHistory:g,clearRichHistoryResults:y})):t.createElement("span",null,t.createElement(x.x6,{i18nKey:"explore.rich-history-container.loading"},"Loading..."))}const Xr=Yr(Jr);var _r=d(13390);const ei=e=>({containerMargin:(0,h.css)({display:"flex",flexWrap:"wrap",gap:e.spacing(1),marginTop:e.spacing(2)})});function ti(e){const o=(0,N.$j)(),n=ei(o);return t.createElement("div",{className:n.containerMargin},!e.addQueryRowButtonHidden&&t.createElement(ae.I,{variant:"canvas","aria-label":(0,x.t)("explore.secondary-actions.query-add-button-aria-label","Add query"),onClick:e.onClickAddQueryRowButton,disabled:e.addQueryRowButtonDisabled,icon:"plus"},t.createElement(x.x6,{i18nKey:"explore.secondary-actions.query-add-button"},"Add query")),!e.richHistoryRowButtonHidden&&t.createElement(ae.I,{variant:e.richHistoryButtonActive?"active":"canvas","aria-label":(0,x.t)("explore.secondary-actions.query-history-button-aria-label","Query history"),onClick:e.onClickRichHistoryButton,"data-testid":_r.X.QueryTab.queryHistoryButton,icon:"history"},t.createElement(x.x6,{i18nKey:"explore.secondary-actions.query-history-button"},"Query history")),t.createElement(ae.I,{variant:e.queryInspectorButtonActive?"active":"canvas","aria-label":(0,x.t)("explore.secondary-actions.query-inspector-button-aria-label","Query inspector"),onClick:e.onClickQueryInspectorButton,icon:"info-circle"},t.createElement(x.x6,{i18nKey:"explore.secondary-actions.query-inspector-button"},"Query inspector")))}var _n=d(65885);function ni(e,{exploreId:o}){const s=e.explore.panes[o],{tableResult:a,range:r}=s,i=(0,q.h1)(o);return{loading:a&&a.length>0?!1:i,tableResult:a,range:r}}const oi=(0,me.connect)(ni,{});class eo extends t.PureComponent{constructor(){super(...arguments),this.hasSubFrames=o=>o.fields.some(n=>n.type===qe.PU.nestedFrames)}getTableHeight(o,n){return o===0?200:Math.min(600,Math.max(o*36,n?300:0)+40+46)}getTableTitle(o,n,s){let a=n.name;return!a&&(o?.length??0)>1&&(a=n.refId||`${s}`),a?t.createElement(x.x6,{i18nKey:"explore.table.title-with-name"},"Table - ",{name:a}):(0,x.t)("explore.table.title","Table")}render(){const{loading:o,onCellFilterAdded:n,tableResult:s,width:a,splitOpenFn:r,range:i,ariaLabel:l,timeZone:c,theme:m}=this.props;let p=(0,_n.gy)(s)?(0,_n.S5)(s):s;const u=(0,Ie.YV)(r,i);p?.length&&(p=(0,ft.we)({data:p,timeZone:c,theme:Wt.$W.theme2,replaceVariables:(0,yt.w)().replace.bind((0,yt.w)()),fieldConfig:{defaults:{},overrides:[]},dataLinkPostProcessor:u}));const f=p?.filter(g=>!!g&&g.length!==0);return t.createElement(t.Fragment,null,f&&f.length===0&&t.createElement(Se.NR,{title:(0,x.t)("explore.table.title","Table"),width:a,height:200},()=>t.createElement(Dt,{metaItems:[{value:(0,x.t)("explore.table.no-data","0 series returned")}]})),f&&f.length>0&&t.createElement("div",{className:(0,h.css)({display:"flex",flexDirection:"column",gap:m.spacing(1)})},f.map((g,y)=>t.createElement(Se.NR,{key:g.refId||`table-${y}`,title:this.getTableTitle(p,g,y),width:a,height:this.getTableHeight(g.length,this.hasSubFrames(g)),loadingState:o?le.Gu.Loading:void 0},(v,b)=>t.createElement(At.X,{ariaLabel:l,data:g,width:v,height:b,onCellFilterAdded:n})))))}}const Pi=(0,N.cV)(eo),si=(0,N.cV)(oi(eo));var ai=d(46923),ri=d(35090);function ii(e){const o=e.dataFrames[0],{dataFrames:n,splitOpenFn:s,exploreId:a,scrollElement:r}=e,i=(0,t.useMemo)(()=>(0,ri.L)(o),[o]),l=(0,O.useSelector)(c=>c.explore.panes[e.exploreId]?.datasourceInstance??void 0);return i?t.createElement(Se.NR,{padding:"none",title:"Trace"},t.createElement(ai.V,{exploreId:a,dataFrames:n,splitOpenFn:s,scrollElement:r,traceProp:i,datasource:l})):null}const li=e=>({exploreMain:(0,h.css)({label:"exploreMain",position:"relative",marginTop:"21px",display:"flex",flexDirection:"column",gap:e.spacing(1)}),queryContainer:(0,h.css)({label:"queryContainer",padding:e.spacing(1)}),exploreContainer:(0,h.css)({label:"exploreContainer",display:"flex",flexDirection:"column",paddingRight:e.spacing(2),marginBottom:e.spacing(2)}),left:(0,h.css)({marginBottom:e.spacing(2)}),wrapper:(0,h.css)({position:"absolute",top:0,left:e.spacing(2),right:0,bottom:0,display:"flex"})});var ci=(e=>(e[e.RichHistory=0]="RichHistory",e[e.QueryInspector=1]="QueryInspector",e))(ci||{});class di extends t.PureComponent{constructor(o){super(o),this.memoizedGetNodeGraphDataFrames=(0,ze.A)(yo.BR),this.onChangeTime=n=>{const{updateTimeRange:s,exploreId:a}=this.props;s({exploreId:a,rawRange:n})},this.onClickExample=n=>{this.props.setQueries(this.props.exploreId,[n])},this.onCellFilterAdded=n=>{const{value:s,key:a,operator:r}=n;r===ot.mc&&this.onClickFilterLabel(a,s),r===ot.Zi&&this.onClickFilterOutLabel(a,s)},this.onContentOutlineToogle=()=>{this.setState(n=>((0,P.rR)("explore_toolbar_contentoutline_clicked",{item:"outline",type:n.contentOutlineVisible?"close":"open"}),{contentOutlineVisible:!n.contentOutlineVisible}))},this.isFilterLabelActive=async(n,s,a)=>{const r=this.props.queries.find(l=>l.refId===a);if(!r)return!1;const i=await(0,He.l)().get(r.datasource);return!!((0,Y.FP)(i)&&i.queryHasFilter(r,{key:n,value:s.toString()}))},this.onClickFilterLabel=(n,s,a)=>{this.onModifyQueries({type:"ADD_FILTER",options:{key:n,value:s.toString()},frame:a},a?.refId)},this.onClickFilterOutLabel=(n,s,a)=>{this.onModifyQueries({type:"ADD_FILTER_OUT",options:{key:n,value:s.toString()},frame:a},a?.refId)},this.onClickFilterValue=(n,s)=>{this.onModifyQueries({type:"ADD_STRING_FILTER",options:{value:n.toString()}},s)},this.onClickFilterOutValue=(n,s)=>{this.onModifyQueries({type:"ADD_STRING_FILTER_OUT",options:{value:n.toString()}},s)},this.onClickAddQueryRowButton=()=>{const{exploreId:n,queryKeys:s}=this.props;this.props.addQueryRow(n,s.length)},this.onModifyQueries=(n,s)=>{const a=async(r,i)=>{if(s&&s!==r.refId)return r;const{datasource:l}=r;if(l==null)return r;const c=await(0,He.l)().get(l),m=["ADD_FILTER","ADD_FILTER_OUT"];return(0,Y.FP)(c)&&m.includes(i.type)?c.toggleQueryFilter(r,{type:i.type==="ADD_FILTER"?"FILTER_FOR":"FILTER_OUT",options:i.options??{},frame:i.frame}):c.modifyQuery?c.modifyQuery(r,i):r};this.props.modifyQueries(this.props.exploreId,n,a)},this.onResize=n=>{this.props.changeSize(this.props.exploreId,n)},this.onStartScanning=()=>{this.props.scanStart(this.props.exploreId)},this.onStopScanning=()=>{this.props.scanStopAction({exploreId:this.props.exploreId})},this.onUpdateTimeRange=n=>{const{exploreId:s,updateTimeRange:a}=this.props;a({exploreId:s,absoluteRange:n})},this.toggleShowRichHistory=()=>{this.setState(n=>({openDrawer:n.openDrawer===0?void 0:0}))},this.toggleShowQueryInspector=()=>{this.setState(n=>({openDrawer:n.openDrawer===1?void 0:1}))},this.onSplitOpen=n=>async s=>{if(this.props.splitOpen(s),s&&this.props.datasourceInstance){const a=(await(0,He.l)().get(s.datasourceUid)).type,r=this.props.datasourceInstance.uid===et.uv?(0,te.get)(this.props.queries,"0.datasource.type"):this.props.datasourceInstance.type,i={origin:"panel",panelType:n,source:r,target:a,exploreId:this.props.exploreId};(0,P.rR)("grafana_explore_split_view_opened",i)}},this.state={openDrawer:void 0,contentOutlineVisible:!1},this.graphEventBus=o.eventBus.newScopedBus("graph",{onlyLocal:!1}),this.logsEventBus=o.eventBus.newScopedBus("logs",{onlyLocal:!1})}renderEmptyState(o){return t.createElement("div",{className:(0,h.cx)(o)},t.createElement(or,null))}renderNoData(){return t.createElement(_a,null)}renderCustom(o){const{timeZone:n,queryResponse:s,absoluteRange:a,eventBus:r}=this.props,i=(0,te.groupBy)(s?.customFrames,"meta.preferredVisualisationPluginId");return Object.entries(i).map(([l,c],m)=>t.createElement(ge,{title:l,icon:"plug",key:m},t.createElement(ko,{key:m,timeZone:n,pluginId:l,frames:c,state:s.state,absoluteRange:a,height:400,width:o,splitOpenFn:this.onSplitOpen(l),eventBus:r})))}renderGraphPanel(o){const{graphResult:n,absoluteRange:s,timeZone:a,queryResponse:r,showFlameGraph:i}=this.props;return t.createElement(ge,{title:"Graph",icon:"graph-bar"},t.createElement(zs.y,{data:n,height:i?180:400,width:o,absoluteRange:s,timeZone:a,onChangeTime:this.onUpdateTimeRange,annotations:r.annotations,splitOpenFn:this.onSplitOpen("graph"),loadingState:r.state,eventBus:this.graphEventBus}))}renderTablePanel(o){const{exploreId:n,timeZone:s}=this.props;return t.createElement(ge,{title:"Table",icon:"table"},t.createElement(si,{ariaLabel:tt.Tp.pages.Explore.General.table,width:o,exploreId:n,onCellFilterAdded:this.onCellFilterAdded,timeZone:s,splitOpenFn:this.onSplitOpen("table")}))}renderRawPrometheus(o){const{exploreId:n,datasourceInstance:s,timeZone:a}=this.props;return t.createElement(ge,{title:"Raw Prometheus",icon:"gf-prometheus"},t.createElement(Rr,{showRawPrometheus:!0,ariaLabel:tt.Tp.pages.Explore.General.table,width:o,exploreId:n,onCellFilterAdded:s?.modifyQuery?this.onCellFilterAdded:void 0,timeZone:a,splitOpenFn:this.onSplitOpen("table")}))}renderLogsPanel(o){const{exploreId:n,syncedTimes:s,theme:a,queryResponse:r}=this.props,i=parseInt(a.spacing(2).slice(0,-2),10),l=(0,h.css)({display:"flex",flexDirection:"column",gap:a.spacing(1)});return t.createElement(ge,{title:"Logs",icon:"gf-logs",className:l},t.createElement(Ya,{exploreId:n,loadingState:r.state,syncedTimes:s,width:o-i,onClickFilterLabel:this.onClickFilterLabel,onClickFilterOutLabel:this.onClickFilterOutLabel,onStartScanning:this.onStartScanning,onStopScanning:this.onStopScanning,eventBus:this.logsEventBus,splitOpenFn:this.onSplitOpen("logs"),scrollElement:this.scrollElement,isFilterLabelActive:this.isFilterLabelActive,onClickFilterValue:this.onClickFilterValue,onClickFilterOutValue:this.onClickFilterOutValue}))}renderLogsSamplePanel(){const{logsSample:o,timeZone:n,setSupplementaryQueryEnabled:s,exploreId:a,datasourceInstance:r,queries:i}=this.props;return t.createElement(ge,{title:"Logs Sample",icon:"gf-logs"},t.createElement(Ja,{queryResponse:o.data,timeZone:n,enabled:o.enabled,queries:i,datasourceInstance:r,splitOpen:this.onSplitOpen("logsSample"),setLogsSampleEnabled:l=>s(a,l,Y.cF.LogsSample)}))}renderNodeGraphPanel(){const{exploreId:o,showTrace:n,queryResponse:s,datasourceInstance:a}=this.props,r=a?a?.type:"unknown";return t.createElement(ge,{title:"Node Graph",icon:"code-branch"},t.createElement(cr,{dataFrames:this.memoizedGetNodeGraphDataFrames(s.series),exploreId:o,withTraceView:n,datasourceType:r,splitOpenFn:this.onSplitOpen("nodeGraph")}))}renderFlameGraphPanel(){const{queryResponse:o}=this.props;return t.createElement(ge,{title:"Flame Graph",icon:"fire"},t.createElement(As,{dataFrames:o.flameGraphFrames}))}renderTraceViewPanel(){const{queryResponse:o,exploreId:n}=this.props,s=o.series.filter(a=>a.meta?.preferredVisualisationType==="trace");return s.length&&t.createElement(ge,{title:"Traces",icon:"file-alt"},t.createElement(ii,{exploreId:n,dataFrames:s,splitOpenFn:this.onSplitOpen("traceView"),scrollElement:this.scrollElement}))}render(){const{datasourceInstance:o,exploreId:n,graphResult:s,queryResponse:a,isLive:r,theme:i,showMetrics:l,showTable:c,showRawPrometheus:m,showLogs:p,showTrace:u,showCustom:f,showNodeGraph:g,showFlameGraph:y,timeZone:v,showLogsSample:b,correlationEditorDetails:E,correlationEditorHelperData:C}=this.props,{openDrawer:R,contentOutlineVisible:S}=this.state,L=li(i),I=a&&a.state!==le.Gu.NotStarted,H=R===0,z=!(0,We.g)().queryHistoryAvailable,$=R===1,D=a.state===le.Gu.Done&&[a.logsFrames,a.graphFrames,a.nodeGraphFrames,a.flameGraphFrames,a.tableFrames,a.rawPrometheusFrames,a.traceFrames,a.customFrames].every(W=>W.length===0);let T;const k=E?.editorMode;return!!(k||E?.correlationDirty)&&C!==void 0&&(T=t.createElement(No,{exploreId:n,correlations:C})),t.createElement(xo,null,t.createElement(Os,{exploreId:n,onChangeTime:this.onChangeTime,onContentOutlineToogle:this.onContentOutlineToogle,isContentOutlineOpen:S}),t.createElement("div",{style:{position:"relative",height:"100%",paddingLeft:i.spacing(2)}},t.createElement("div",{className:L.wrapper},S&&t.createElement("div",{className:L.left},t.createElement(To,{scroller:this.scrollElement,panelId:`content-outline-container-${n}`})),t.createElement(nt.E,{testId:tt.Tp.pages.Explore.General.scrollView,scrollRefCallback:W=>this.scrollElement=W||void 0,hideHorizontalTrack:!0},t.createElement("div",{className:L.exploreContainer},o?t.createElement(t.Fragment,null,t.createElement(ge,{title:"Queries",icon:"arrow"},t.createElement(bt._,{className:L.queryContainer},T,t.createElement(hr,{exploreId:n}),t.createElement(ti,{addQueryRowButtonDisabled:r||k&&o.meta.mixed,addQueryRowButtonHidden:!1,richHistoryRowButtonHidden:z,richHistoryButtonActive:H,queryInspectorButtonActive:$,onClickAddQueryRowButton:this.onClickAddQueryRowButton,onClickRichHistoryButton:this.toggleShowRichHistory,onClickQueryInspectorButton:this.toggleShowQueryInspector}),t.createElement(Ir,{exploreId:n}))),t.createElement(fo.Ay,{onResize:this.onResize,disableHeight:!0},({width:W})=>W===0?null:t.createElement("main",{className:(0,h.cx)(L.exploreMain),style:{width:W}},t.createElement(X.Xw,null,I&&t.createElement(t.Fragment,null,l&&s&&t.createElement(X.Xw,null,this.renderGraphPanel(W)),m&&t.createElement(X.Xw,null,this.renderRawPrometheus(W)),c&&t.createElement(X.Xw,null,this.renderTablePanel(W)),p&&t.createElement(X.Xw,null,this.renderLogsPanel(W)),g&&t.createElement(X.Xw,null,this.renderNodeGraphPanel()),y&&t.createElement(X.Xw,null,this.renderFlameGraphPanel()),u&&t.createElement(X.Xw,null,this.renderTraceViewPanel()),b&&t.createElement(X.Xw,null,this.renderLogsSamplePanel()),f&&t.createElement(X.Xw,null,this.renderCustom(W)),D&&t.createElement(X.Xw,null,this.renderNoData())),H&&t.createElement(Xr,{width:W,exploreId:n,onClose:this.toggleShowRichHistory}),$&&t.createElement(rs,{exploreId:n,width:W,onClose:this.toggleShowQueryInspector,timeZone:v,isMixed:o.meta.mixed||!1}))))):this.renderEmptyState(L.exploreContainer))))))}}function ui(e,{exploreId:o}){const n=e.explore,{syncedTimes:s}=n,a=n.panes[o],r=(0,st.O)(e.user),{datasourceInstance:i,queryKeys:l,queries:c,isLive:m,graphResult:p,tableResult:u,logsResult:f,showLogs:g,showMetrics:y,showTable:v,showTrace:b,showCustom:E,absoluteRange:C,queryResponse:R,showNodeGraph:S,showFlameGraph:L,showRawPrometheus:I,supplementaryQueries:H,correlationEditorHelperData:z}=a,$=(0,q.h1)(o)(e),D=H[Y.cF.LogsSample],T=!!(D.dataProvider!==void 0&&!f&&(p||u));return{datasourceInstance:i,queryKeys:l,queries:c,isLive:m,graphResult:p,logsResult:f??void 0,absoluteRange:C,queryResponse:R,syncedTimes:s,timeZone:r,showLogs:g,showMetrics:y,showTable:v,showTrace:b,showCustom:E,showNodeGraph:S,showRawPrometheus:I,showFlameGraph:L,splitted:(0,J.pF)(e),loading:$,logsSample:D,showLogsSample:T,correlationEditorHelperData:z,correlationEditorDetails:n.correlationEditorDetails}}const pi={changeSize:be.QZ,modifyQueries:q.PD,scanStart:q.GI,scanStopAction:q.q9,setQueries:q.Rk,updateTimeRange:de.GH,addQueryRow:q._0,splitOpen:G.ve,setSupplementaryQueryEnabled:q.TO},hi=(0,me.connect)(ui,pi),mi=(0,N.cV)(hi(di)),gi=(0,h.css)({label:"explorePaneContainer",display:"flex",flexDirection:"column",minWidth:"600px",height:"100%"});function fi({exploreId:e}){Ei(e);const o=(0,t.useRef)(new go.o),n=(0,t.useRef)(null);return(0,t.useEffect)(()=>{const s=o.current;return()=>s.removeAllListeners()},[]),t.createElement(nt.E,{hideVerticalTrack:!0},t.createElement("div",{className:gi,ref:n,"data-testid":tt.Tp.pages.Explore.General.container},t.createElement(mi,{exploreId:e,eventBus:o.current})))}function yi(e,o){return{pane:e.explore.panes[o.exploreId]}}const vi=(0,me.connect)(yi)(fi);function Ei(e){const o=(0,t.useMemo)(()=>(0,J.qq)(e),[e]),n=(0,t.useRef)();n.current=(0,O.useSelector)(o),(0,t.useEffect)(()=>()=>{(0,Be._u)(n.current?.querySubscription)},[])}var to=d(19361),no=d(15961);function bi(e){const o=(0,t.useRef)();o.current=(0,qt.C)("explore");const n=(0,t.useRef)((0,Gn.tR)());(0,t.useEffect)(()=>{if(!e.panes||typeof e.panes!="string")return;let s;try{s=JSON.parse(e.panes)}catch{return}typeof s!="object"||s===null||Promise.allSettled(Object.values(s).map(a=>!a||typeof a!="object"||!(0,no.C)("datasource",a)||!a.datasource||typeof a.datasource!="string"?Promise.reject():n.current.get(a.datasource))).then(a=>a.filter(no.s).map(r=>r.value)).then(a=>{if(!o.current)return;const r=a.map(i=>i.name);if(r.length===0){d.g.document.title=`${o.current.main.text} - ${to.M.AppTitle}`;return}d.g.document.title=`${o.current.main.text} - ${r.join(" | ")} - ${to.M.AppTitle}`})},[e.panes])}function xi(){const{keybindings:e}=(0,ke.Il)(),o=(0,O.useDispatch)();(0,t.useEffect)(()=>{e.setupTimeRangeBindings(!1);const n=[];return n.push((0,Oe.J7)().subscribe(De.Rh,()=>{o((0,de.$_)())})),n.push((0,Oe.J7)().subscribe(De.Io,s=>{o((0,de.Iy)(s.payload.direction))})),n.push((0,Oe.J7)().subscribe(De.U0,s=>{o((0,de.ke)(s.payload.scale))})),n.push((0,Oe.J7)().subscribe(De.Bt,()=>{o((0,de.Xk)())})),n.push((0,Oe.J7)().subscribe(De.VZ,()=>{o((0,de.GA)())})),()=>{n.forEach(s=>s.unsubscribe())}},[o,e])}const Si=e=>{const o=(0,O.useDispatch)(),{width:n}=(0,Bt.A)(),s=(0,O.useSelector)(J.K6),a=(0,O.useSelector)(J.pF),[r,i]=(0,t.useState)(.5),l=(0,O.useSelector)(p=>p.explore),c=p=>{const u=n/2,f=(0,te.inRange)(p,u-100,u+100);o(f?(0,G.nD)({largerExploreId:void 0}):(0,G.nD)({largerExploreId:p>u?s[1][0]:s[0][0]})),i(p/n)};let m=0;return a&&(!l.evenSplitPanes&&l.maxedExploreId?m=l.maxedExploreId===s[1][0]?n-e:e:l.evenSplitPanes?m=Math.floor(n/2):r!==void 0&&(m=n*r)),{updateSplitSize:c,widthCalc:m}};function Ci(){const{location:e}=(0,ke.Il)();(0,t.useEffect)(()=>{const o=e.getSearchObject();(o.from||o.to)&&e.partial({from:void 0,to:void 0},!0)},[e])}const jt=200;function Ri(e){const o=(0,N.of)(wi),n=(0,N.$j)();Ci(),(0,In.s)(e.queryParams),bi(e.queryParams);const{chrome:s}=(0,ke.Il)(),a=(0,qt.C)("explore"),{updateSplitSize:r,widthCalc:i}=Si(jt),l=(0,O.useSelector)(J.K6),c=(0,O.useSelector)(J.pF),m=(0,O.useSelector)(J.vC),p=V.$.featureToggles.correlations&&(m?.editorMode||!1);return(0,t.useEffect)(()=>{s.update({sectionNav:a})},[s,a]),xi(),t.createElement("div",{className:(0,h.cx)(o.pageScrollbarWrapper,{[o.correlationsEditorIndicator]:p})},t.createElement(mo,null),p&&t.createElement(po,{panes:l}),t.createElement(Ce.g,{splitOrientation:"vertical",paneSize:i,minSize:jt,maxSize:jt*-1,primary:"second",splitVisible:c,parentStyle:p?{height:`calc(100% - ${n.spacing(6)}`}:{},paneStyle:{overflow:"auto",display:"flex",flexDirection:"column"},onDragFinished:u=>u&&r(u)},l.map(([u])=>t.createElement(X.Xw,{key:u,style:"page"},t.createElement(vi,{exploreId:u})))))}const wi=e=>({pageScrollbarWrapper:(0,h.css)({width:"100%",flexGrow:1,minHeight:0,height:"100%",position:"relative"}),correlationsEditorIndicator:(0,h.css)({borderLeft:`4px solid ${e.colors.primary.main}`,borderRight:`4px solid ${e.colors.primary.main}`,borderBottom:`4px solid ${e.colors.primary.main}`,overflow:"scroll"})})},10940:(Gt,Ae,d)=>{d.d(Ae,{A:()=>V});var h=d(96540),t=function(N,X){var Ce=(0,h.useRef)(function(){});(0,h.useEffect)(function(){Ce.current=N}),(0,h.useEffect)(function(){if(X!==null){var ke=setInterval(function(){return Ce.current()},X||0);return function(){return clearInterval(ke)}}},[X])};const V=t}}]); //# sourceMappingURL=explore.476912733278e2a99729.js.map