"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[9136],{21468:(Se,W,o)=>{o.d(W,{X:()=>e,d:()=>U});const e=()=>({type:"query",query:{params:["A","5m","now"]},reducer:{type:"avg",params:[]},evaluator:{type:"gt",params:[null]},operator:{type:"and"}}),U=async(v,I,O,k)=>{if(I.length===0)return"Could not find any metric queries";if(v&&v.length)return"Transformations are not supported in alert queries";let E=0,L=0;for(const G of I){const V=G.datasource||k,m=await O.get(V);m.meta.alerting?m.targetContainsTemplate&&m.targetContainsTemplate(G)&&L++:E++}return E===I.length?"The datasource does not support alerting queries":L===I.length?"Template variables are not supported in alert queries":""}},24669:(Se,W,o)=>{o.r(W),o.d(W,{default:()=>ps});var e=o(96540),U=o(16817),v=o(32264),I=o(64388),O=o(36830),k=o(39419),E=o(80348),L=o(72255);function G({match:a,route:t,queryParams:n,history:s}){const r=(0,L.sP)(),{dashboard:i,isLoading:c,loadError:l}=r.useState(),d=s.location.state?.routeReloadCounter;return(0,e.useEffect)(()=>(t.routeName===E.DashboardRoutes.Normal&&a.params.type==="snapshot"?r.loadSnapshot(a.params.slug):r.loadDashboard({uid:a.params.uid??"",route:t.routeName,urlFolderUid:n.folderUid}),()=>{r.clearState()}),[r,a.params.uid,t.routeName,n.folderUid,d,a.params.slug,a.params.type]),i?e.createElement(i.Component,{model:i}):e.createElement(O.Y,{layout:I.k.Canvas,"data-testid":"dashboard-scene-page"},c&&e.createElement(k.A,null),l&&e.createElement("h2",null,l))}const V=G;var m=o(32196),y=o(69733),$=o(71733),h=o(13544),b=o(12131),S=o(40845),Ce=o(82467),St=o(7392),Ct=o(76888),Te=o(3169);function Tt(a){switch(a.kiosk){case"tv":return E.KioskMode.TV;case"1":case!0:return E.KioskMode.Full;default:return null}}var De=o(17422),Ne=o(6473),xe=o(14110),H=o(42418),Dt=o(61680);const Nt="grafana.angularDeprecation.dashboardNotice.isDismissed";function xt(a){return Nt+"."+a}function Mt({dashboardUid:a}){return e.createElement(Dt.b,{storageKey:xt(a),defaultValue:!1},(t,n)=>t?null:e.createElement("div",null,e.createElement(H.F,{severity:"warning",title:"This dashboard depends on Angular, which is deprecated and will stop working in future releases of Grafana.",onRemove:()=>{(0,xe.rR)("angular_deprecation_notice_dismissed"),n(!0)}},e.createElement("div",{className:"markdown-html"},e.createElement("ul",null,e.createElement("li",null,e.createElement("a",{href:"https://grafana.com/docs/grafana/latest/developers/angular_deprecation/",className:"external-link",target:"_blank",rel:"noreferrer"},"Read our deprecation notice and migration advice.")))))))}var gs=o(53652);function fs(a){const t=a.match.params.slug??"",n=useAsync(()=>getGrafanaStorage().list("content/"+t),[t]),s=t.length>0?`g/${t}/`:"g/",r=Me(t),i=()=>n.value?n.value.fields[0].values.map(d=>{let u=d;const p=u.indexOf(".")<0,g=!p&&u.endsWith(".json"),f=`${s}${u}`;return React.createElement(Card,{key:u,href:p||g?f:void 0},React.createElement(Card.Heading,null,u),React.createElement(Card.Figure,null,React.createElement(Icon,{name:p?"folder":g?"gf-grid":"file-alt",size:"sm"})))}):n.loading?React.createElement(Spinner,null):React.createElement("div",null,"?"),c=Ie();return React.createElement(Page,{navModel:c,pageNav:r},i())}function Me(a){const t=a.split("/");let n=[],s="g",r;for(let i=0;i<t.length;i++)s+=`/${t[i]}`,n.push({text:t[i],url:s,parentItem:r}),r=n[n.length-1];return r}function Ie(){return{main:{text:"C:"},node:{text:"Content",url:"/g"}}}const vs=null;var w=o(28444),Re=o(72401),It=o(75096),z=o(37390),Ae=o(10354),Q=o(14578),Z=o(40276),Le=o(36974),Rt=o(48889),we=o(17706);const At=()=>{const a=(0,S.of)(Lt),[t,n]=(0,e.useState)(""),s=(0,E.useSelector)(l=>l.dashboard.getModel()),r=(0,e.useMemo)(()=>(0,we.nr)(),[]),i=(0,e.useMemo)(()=>(0,we.CO)(r,t),[r,t]),c=()=>{b.Ny.partial({addWidget:null})};return e.createElement(z.a,{title:"Select widget type",closeOnEscape:!0,closeOnBackdropClick:!0,isOpen:!0,className:a.modal,onClickBackdrop:c,onDismiss:c},e.createElement(Ae.p,{type:"search",autoFocus:!0,className:a.searchInput,value:t,prefix:e.createElement(Q.I,{name:"search"}),placeholder:"Search widget",onChange:l=>{n(l.currentTarget.value)}}),e.createElement(Z.E,null,e.createElement("div",{className:a.grid},i.map((l,d)=>e.createElement(Rt.f,{disabled:!1,key:l.id,isCurrent:!1,plugin:l,onClick:u=>{const p=(0,Le.ob)(s,l.id);b.Ny.partial({editPanel:p,addWidget:null})}})))))},Lt=a=>({modal:(0,m.css)`
    width: 65%;
    max-width: 960px;

    ${a.breakpoints.down("md")} {
      width: 100%;
    }
  `,searchInput:(0,m.css)`
    margin-bottom: ${a.spacing(2)};
  `,grid:(0,m.css)`
    display: grid;
    grid-gap: ${a.spacing(1)};
  `});var wt=o(16495),Ft=o(59757),Ot=o(9980),X=o(2543),se=o(24180),Fe=o(71678),$t=o(28138),q=o(16233),Ut=o(40996),P=o(55852),Vt=o(57767),zt=o(43535),Bt=o(88861);const Oe=({panel:a,folderUid:t,isUnsavedPrompt:n,onDismiss:s,onConfirm:r,onDiscard:i})=>{const[c,l]=(0,e.useState)(""),d=(0,U.A)(async()=>{const D=await(0,Vt.xV)(a.libraryPanel.uid);return D.length>0?D.map(R=>R.title):[]},[a.libraryPanel.uid]),[u,p]=(0,e.useState)([]);(0,Ut.A)(()=>d.value?p(d.value.filter(D=>D.toLowerCase().includes(c.toLowerCase()))):p([]),300,[d.value,c]);const{saveLibraryPanel:g}=(0,Bt.b)(),f=(0,S.of)(zt.o),N=(0,e.useCallback)(()=>{i()},[i]),T=n?"Unsaved library panel changes":"Save library panel";return e.createElement(z.a,{title:T,icon:"save",onDismiss:s,isOpen:!0},e.createElement("div",null,e.createElement("p",{className:f.textInfo},"This update will affect ",e.createElement("strong",null,a.libraryPanel.meta?.connectedDashboards," ",a.libraryPanel.meta?.connectedDashboards===1?"dashboard":"dashboards","."),"The following dashboards using the panel will be affected:"),e.createElement(Ae.p,{className:f.dashboardSearch,prefix:e.createElement(Q.I,{name:"search"}),placeholder:"Search affected dashboards",value:c,onChange:D=>l(D.currentTarget.value)}),d.loading?e.createElement("p",null,"Loading connected dashboards..."):e.createElement("table",{className:f.myTable},e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Dashboard name"))),e.createElement("tbody",null,u.map((D,R)=>e.createElement("tr",{key:`dashrow-${R}`},e.createElement("td",null,D))))),e.createElement(z.a.ButtonRow,null,e.createElement(P.$n,{variant:"secondary",onClick:s,fill:"outline"},"Cancel"),n&&e.createElement(P.$n,{variant:"destructive",onClick:N},"Discard"),e.createElement(P.$n,{onClick:()=>{g(a,t).then(()=>{r()})}},"Update all"))))};var Wt=o(98365),Gt=o(33390),$e=o(19752),re=o(79971),Ue=o(80095),F=o(53466);function Ht(a,t){return async n=>{const s=t.initEditPanel(a);n((0,F.GU)({panel:s,sourcePanel:a}))}}function Ve(){return async(a,t)=>{const{getPanel:n}=t().panelEditor;n().configRev=0,a((0,F.MJ)(!0))}}function Qt(a,t){return n=>{if(a.libraryPanel?.uid===void 0||!t)return;const s=a.getSaveModel();for(const r of t.panels){if(Kt(a,r))continue;r.restoreModel({...s,...(0,X.pick)(r,"gridPos","id")});const i=r.plugin?.meta.id!==a.plugin?.meta.id;r.plugin=a.plugin,r.configRev++,i&&(r.generateNewKey(),n((0,Ue.XM)({key:r.key,plugin:r.plugin}))),setTimeout(()=>{r.getQueryRunner().useLastResultFrom(a.getQueryRunner())},20)}a.repeat&&setTimeout(()=>t.processRepeats(),20)}}function Kt(a,t){return!!(t.libraryPanel?.uid!==a.libraryPanel.uid||t.id&&t.id===a.id||t.repeatPanelId)}function kt(){return async(a,t)=>{const n=t().dashboard.getModel(),{getPanel:s,getSourcePanel:r,shouldDiscardChanges:i}=t().panelEditor,c=s();n&&n.exitPanelEditor();const l=r();if(Jt(c)&&!i){const d=c.getSaveModel(),u=l.type!==c.type;a(Qt(c,n)),l.restoreModel(d),l.configRev++,u&&(l.plugin=c.plugin,l.generateNewKey(),await a((0,Ue.XM)({key:l.key,plugin:c.plugin}))),setTimeout(()=>{l.getQueryRunner().useLastResultFrom(c.getQueryRunner()),l.render(),c.hasSavedPanelEditChange&&!c.hasChanged&&(l.configRev=0)},20)}l.isNew&&(i?n&&(0,$e.FC)(n,l,!0):delete l.isNew),a((0,re.O6)(c.key)),a((0,F.Ox)())}}function Jt(a){return a.hasChanged||a.hasSavedPanelEditChange||a.isAngularPlugin()}function oe(a){return(t,n)=>{const s={...n().panelEditor.ui,...a};t((0,F.fR)(s));try{Gt.A.setObject(F.wi,s)}catch(r){console.error(r)}}}var jt=o(78050);const Yt=({dashboard:a,onSaveSuccess:t,onDiscard:n,onDismiss:s})=>e.createElement(z.a,{isOpen:!0,title:"Unsaved changes",onDismiss:s,icon:"exclamation-triangle",className:(0,m.css)`
        width: 500px;
      `},e.createElement("h5",null,"Do you want to save your changes?"),e.createElement(z.a.ButtonRow,null,e.createElement(P.$n,{variant:"secondary",onClick:s,fill:"outline"},"Cancel"),e.createElement(P.$n,{variant:"destructive",onClick:n},"Discard"),e.createElement(jt.C,{dashboard:a,onSaveSuccess:t}))),ze=e.memo(({dashboard:a})=>{const[t,n]=(0,e.useState)({original:null}),s=(0,E.useDispatch)(),{original:r,originalPath:i}=t,{showModal:c,hideModal:l}=(0,e.useContext)(Fe.wE);(0,e.useEffect)(()=>{const u=setTimeout(()=>{const g=b.Ny.getLocation().pathname,f=a.getSaveModelCloneOld();n({originalPath:g,original:f})},1e3),p=$t.l.subscribe(w.Eu,()=>{const g=a.getSaveModelCloneOld();n({originalPath:i,original:g})});return()=>{clearTimeout(u),p.unsubscribe()}},[a,i]),(0,e.useEffect)(()=>{const u=p=>{Be(a,r)||Ge(a,r)&&(p.preventDefault(),p.returnValue="")};return window.addEventListener("beforeunload",u),()=>window.removeEventListener("beforeunload",u)},[a,r]);const d=u=>{const p=a.panelInEdit,g=new URLSearchParams(u.search);return p&&p.libraryPanel&&p.hasChanged&&!g.has("editPanel")?(c(Oe,{isUnsavedPrompt:!0,panel:a.panelInEdit,folderUid:a.meta.folderUid??"",onConfirm:()=>{l(),_(u)},onDiscard:()=>{s(Ve()),_(u),l()},onDismiss:l}),!1):i===u.pathname||!r?(p&&!g.has("editPanel")&&s(kt()),!0):Be(a,r)||!Ge(a,r)?!0:(c(Yt,{dashboard:a,onSaveSuccess:()=>{l(),_(u)},onDiscard:()=>{n({...t,original:null}),l(),_(u)},onDismiss:l}),!1)};return e.createElement(se.XG,{when:!0,message:d})});ze.displayName="DashboardPrompt";function _(a){a&&setTimeout(()=>b.Ny.push(a),10)}function Be(a,t){if(!t||t.version===0||!q.TP.isSignedIn||!a)return!0;const{canSave:n,fromScript:s,fromFile:r}=a.meta;return!q.TP.isEditor&&!n?!0:!n||s||r}function We(a){const t=new Wt.G(a);t.expandRows();const n=t.getSaveModelClone();if(delete n.time,delete n.refresh,n.schemaVersion=0,delete n.timezone,n.panels=[],n.templating?.list)for(const s of n.templating.list)delete s.current,delete s.options,delete s.filters;return n}function Ge(a,t){if(a.hasUnsavedChanges())return!0;const n=We(a.getSaveModelCloneOld()),s=We(t),r=(0,X.find)(n.nav,{type:"timepicker"}),i=(0,X.find)(s.nav,{type:"timepicker"});r&&i&&(r.now=i.now);const c=JSON.stringify(n,null),l=JSON.stringify(s,null);return c!==l}var Zt=o(92107),M=o(16560),le=o(40334),ie=o(70713),He=o(41987),Qe=o(87978),ee=o(67061),Xt=o(86460),ce=o(63021),J=o(40675),qt=o(62930),te=o(88575),_t=o(88323),de=o(10534),ea=o(32372),B=o(66864),j=o(15292),ta=o(4213),aa=o.n(ta),na=o(72724),ae=o(83195),sa=o(2619),ra=o(64468),K=o(74856),oa=o(34214),Ke=o(79999),ke=o(18803),Y=(a=>(a[a.Support=0]="Support",a[a.Data=1]="Data",a))(Y||{}),ne=(a=>(a[a.PanelSnapshot=0]="PanelSnapshot",a[a.GithubComment=1]="GithubComment",a))(ne||{});class la extends sa.Q{constructor(t){super({panel:t,panelTitle:t.replaceVariables(t.title,void 0,"text")||"Panel",currentTab:0,showMessage:1,snapshotText:"",markdownText:"",randomize:{},snapshotUpdate:0,options:[{label:"GitHub comment",description:"Copy and paste this message into a GitHub issue or comment",value:1},{label:"Panel support snapshot",description:"Dashboard JSON used to help troubleshoot visualization issues",value:0}]}),this.onCurrentTabChange=n=>{this.setState({currentTab:n})},this.onShowMessageChange=n=>{this.setState({showMessage:n.value})},this.onGetMarkdownForClipboard=()=>{const{markdownText:n}=this.state,s=Math.pow(1024,2)*1.5;return n.length>s?(this.setState({error:{title:"Copy to clipboard failed",message:"Snapshot is too large, consider download and attaching a file instead"}}),""):n},this.onDownloadDashboard=()=>{const{snapshotText:n,panelTitle:s}=this.state,r=new Blob([n],{type:"text/plain"}),i=`debug-${s}-${(0,na.LE)(new Date)}.json.txt`;aa()(r,i)},this.onSetSnapshotText=n=>{this.setState({snapshotText:n})},this.onToggleRandomize=n=>{const{randomize:s}=this.state;this.setState({randomize:{...s,[n]:!s[n]}})},this.onPreviewDashboard=()=>{const{snapshot:n}=this.state;n&&((0,Ke.OI)({meta:{},dashboard:n}),o.g.open(v.$.appUrl+"dashboard/new","_blank"))}}async buildDebugDashboard(){const{panel:t,randomize:n,snapshotUpdate:s}=this.state,r=await(0,ke.E_)(t,n,(0,K.jG)().timeRange()),i=JSON.stringify(r,null,2),c=(0,ke.jD)(t,i),l=(0,ae.cN)((0,ae.j_)("bytes")(i?.length??0));let d;if(!t.isAngularPlugin())try{const u=new oa.G(r,{isEmbedded:!0});d=(0,ra.EH)(u).state.body}catch(u){console.log("Error creating scene:",u)}this.setState({snapshot:r,snapshotText:i,markdownText:c,snapshotSize:l,snapshotUpdate:s+1,scene:d})}}function ia({panel:a,plugin:t,onClose:n}){const s=(0,S.of)(ca),r=(0,e.useMemo)(()=>new la(a),[a]),{currentTab:i,loading:c,error:l,options:d,showMessage:u,snapshotSize:p,markdownText:g,snapshotText:f,randomize:N,panelTitle:T,scene:D}=r.useState();if((0,e.useEffect)(()=>{r.buildDebugDashboard()},[r,t,N]),!t)return null;const R=[{label:"Snapshot",value:Y.Support},{label:"Data",value:Y.Data}],A=v.$.supportBundlesEnabled&&q.TP.hasPermission(E.AccessControlAction.ActionSupportBundlesCreate);return e.createElement(Qe._,{title:"Get help with this panel",size:"lg",onClose:n,subtitle:e.createElement(ee.B,{direction:"column",gap:1},e.createElement(ee.B,{direction:"row",gap:1},e.createElement(Xt.y,{featureState:He.Ay.beta}),e.createElement("a",{href:"https://grafana.com/docs/grafana/latest/troubleshooting/",target:"blank",className:"external-link",rel:"noopener noreferrer"},"Troubleshooting docs ",e.createElement(Q.I,{name:"external-link-alt"}))),e.createElement("span",{className:"muted"},"To request troubleshooting help, send a snapshot of this panel to Grafana Labs Technical Support. The snapshot contains query response data and panel settings."),A&&e.createElement("span",{className:"muted"},"You can also retrieve a support bundle containing information concerning your Grafana instance and configured datasources in the ",e.createElement("a",{href:"/support-bundles"},"support bundles section"),".")),tabs:e.createElement(ce.U,null,R.map((x,hs)=>e.createElement(J.o,{key:`${x.value}-${hs}`,label:x.label,active:x.value===i,onChangeTab:()=>r.onCurrentTabChange(x.value)})))},c&&e.createElement(qt.y,null),l&&e.createElement(H.F,{title:l.title},l.message),i===Y.Data&&e.createElement("div",{className:s.code},e.createElement("div",{className:s.opts},e.createElement(te.D,{label:"Template",className:s.field},e.createElement(_t.l6,{options:d,value:u,onChange:r.onShowMessageChange})),u===ne.GithubComment?e.createElement(de.b,{icon:"copy",getText:r.onGetMarkdownForClipboard},"Copy to clipboard"):e.createElement(P.$n,{icon:"download-alt",onClick:r.onDownloadDashboard},"Download (",p,")")),e.createElement(ie.Ay,{disableWidth:!0},({height:x})=>e.createElement(ea.B,{width:"100%",height:x,language:u===ne.GithubComment?"markdown":"json",showLineNumbers:!0,showMiniMap:!0,value:u===ne.GithubComment?g:f,readOnly:!1,onBlur:r.onSetSnapshotText}))),i===Y.Support&&e.createElement(e.Fragment,null,e.createElement(te.D,{label:"Randomize data",description:"Modify the original data to hide sensitve information.  Note the lengths will stay the same, and duplicate values will be equal."},e.createElement(B.Gy,null,e.createElement(j.K,{label:"Labels",id:"randomize-labels",showLabel:!0,value:!!N.labels,onChange:()=>r.onToggleRandomize("labels")}),e.createElement(j.K,{label:"Field names",id:"randomize-field-names",showLabel:!0,value:!!N.names,onChange:()=>r.onToggleRandomize("names")}),e.createElement(j.K,{label:"String values",id:"randomize-string-values",showLabel:!0,value:!!N.values,onChange:()=>r.onToggleRandomize("values")}))),e.createElement(te.D,{label:"Support snapshot",description:`Panel: ${T}`},e.createElement(ee.B,null,e.createElement(P.$n,{icon:"download-alt",onClick:r.onDownloadDashboard},"Dashboard (",p,")"),e.createElement(de.b,{icon:"github",getText:r.onGetMarkdownForClipboard,title:"Copy a complete GitHub comment to the clipboard"},"Copy to clipboard"),e.createElement(P.$n,{onClick:r.onPreviewDashboard,variant:"secondary",title:"Open support snapshot dashboard in a new tab"},"Preview"))),e.createElement(ie.Ay,{disableWidth:!0},({height:x})=>e.createElement("div",{style:{height:x,overflow:"auto"}},D&&e.createElement(D.Component,{model:D})))))}const ca=a=>({code:(0,m.css)`
    flex-grow: 1;
    height: 100%;
    overflow: scroll;
  `,field:(0,m.css)`
    width: 100%;
  `,opts:(0,m.css)`
    display: flex;
    display: flex;
    width: 100%;
    flex-grow: 0;
    align-items: center;
    justify-content: flex-end;

    button {
      margin-left: 8px;
    }
  `});var ue=o(39070);const me=(a,t,n)=>{const s=(0,e.useRef)(),[r,i]=(0,e.useState)();return(0,e.useEffect)(()=>{let c=-1,l=0;return s.current=a.getQueryRunner().getData({withTransforms:t.withTransforms,withFieldConfig:!1}).subscribe({next:d=>{if(n){if(c===d.structureRev){const u=Date.now();if(u-l<1e4)return;l=u}c=d.structureRev??-1}i(d)}}),()=>{s.current&&s.current.unsubscribe()}},[a,t.withTransforms]),{data:r,isLoading:r?.state===ue.Gu.Loading,hasSeries:r?!!r.series:!1,hasError:!!(r&&(r.error||r?.errors?.length||r.state===ue.Gu.Error))}};var Je=o(72574),pe=o(44836),da=o(61453),ua=o(82344),ma=o(61396);const pa=({data:a,metadataDatasource:t})=>!t||!t.components?.MetadataInspector?e.createElement(pe.x6,{i18nKey:"dashboard.inspect-meta.no-inspector"},"No Metadata Inspector"):e.createElement(t.components.MetadataInspector,{datasource:t,data:a.series});var ha=o(32067),ga=o(90820);const fa=({panel:a,plugin:t,dashboard:n,tabs:s,data:r,isDataLoading:i,dataOptions:c,metadataDatasource:l,defaultTab:d,onDataOptionsChange:u,onClose:p})=>{const[g,f]=(0,e.useState)(d??M.q.Data);if(!t)return null;let N=va(r),T=g;s.find(A=>A.value===g)||(T=M.q.JSON);const D=(0,Je.w)().replace(a.title,a.scopedVars,"text")||"Panel",R=(0,pe.t)("dashboard.inspect.title","Inspect: {{panelTitle}}",{panelTitle:D});return e.createElement(Qe._,{title:R,subtitle:r&&Ea(r),onClose:p,tabs:e.createElement(ce.U,null,s.map((A,x)=>e.createElement(J.o,{key:`${A.value}-${x}`,label:A.label,active:A.value===T,onChangeTab:()=>f(A.value||M.q.Data)})))},T===M.q.Data&&e.createElement(da.q,{dataName:a.getDisplayTitle(),panelPluginId:a.type,fieldConfig:a.fieldConfig,hasTransformations:!!a.transformations?.length,data:r&&r.series,isLoading:i,options:c,onOptionsChange:u,timeZone:n.timezone,app:He.Jk.Dashboard}),r&&T===M.q.Meta&&e.createElement(pa,{data:r,metadataDatasource:l}),T===M.q.JSON&&e.createElement(ma.w,{panel:a,dashboard:n,data:r,onClose:p}),T===M.q.Error&&e.createElement(ua.y,{errors:N}),r&&T===M.q.Stats&&e.createElement(ha.N,{data:r,timeZone:n.getTimezone()}),r&&T===M.q.Query&&e.createElement(ga.e,{data:r,onRefreshQuery:()=>a.refresh()}))};function va(a){let t=a?.errors??[];return a?.error&&!t.includes(a.error)&&(t=[a.error,...t]),!t.length&&a?.state===ue.Gu.Error?[{message:"Error loading data"}]:t}function Ea(a){const{request:t}=a;if(!t||(0,X.isEmpty)(t))return"";const n=t.targets.length,s=t.endTime?t.endTime-t.startTime:0,r=(0,ae.cN)((0,ae.j_)("ms")(s));return e.createElement(pe.x6,{i18nKey:"dashboard.inspect.subtitle"},{queryCount:n}," queries with total query time of ",{formatted:r})}var je=o(65123);const ya=({panel:a,dashboard:t,plugin:n})=>{const s=(0,se.zy)(),r=new URLSearchParams(s.search).get("inspectTab"),[i,c]=(0,e.useState)({withTransforms:r===M.q.Error,withFieldConfig:!0}),{data:l,isLoading:d,hasError:u}=me(a,i,!1),p=(0,je.sd)(l),g=(0,je.kx)(a,t,n,u,p),f=()=>{b.Ny.partial({inspect:null,inspectTab:null})};return n?r===M.q.Help?e.createElement(ia,{panel:a,plugin:n,onClose:f}):e.createElement(fa,{dashboard:t,panel:a,plugin:n,defaultTab:r,tabs:g,data:l,isDataLoading:d,dataOptions:i,onDataOptionsChange:c,metadataDatasource:p,onClose:f}):null},ba=(a,t)=>{const n=(0,le.U)(a,t.panel);return n?{plugin:n.plugin}:{plugin:null}},Pa=(0,y.connect)(ba)(ya);var Ye=o(64423),Ze=o(94354),he=o(27746),Sa=o(15068),Xe=o(3911),Ca=o(75269),qe=o(58720),Ta=o(10096),ge=o(12470),fe=o(56034),Da=o(20601),Na=o(13344);const xa=a=>{const t=(0,e.useMemo)(()=>Da.B.get(a.variable.type).picker,[a.variable]);return a.variable?e.createElement("div",{className:"gf-form"},e.createElement(Ma,{variable:a.variable}),a.variable.hide!==ge.zL.hideVariable&&t&&e.createElement(t,{variable:a.variable,readOnly:a.readOnly??!1})):e.createElement("div",null,"Couldn't load variable")};function Ma({variable:a}){const t=(0,e.useMemo)(()=>a.label||a.name,[a]);if(a.hide!==ge.zL.dontHide)return null;const n=Na.qz+a.id;return a.description?e.createElement(fe.m,{content:a.description,placement:"bottom"},e.createElement("label",{className:"gf-form-label gf-form-label--variable","data-testid":h.Tp.pages.Dashboard.SubMenu.submenuItemLabels(t),htmlFor:n},t)):e.createElement("label",{className:"gf-form-label gf-form-label--variable","data-testid":h.Tp.pages.Dashboard.SubMenu.submenuItemLabels(t),htmlFor:n},t)}const _e=({variables:a,readOnly:t})=>{const[n,s]=(0,e.useState)([]);return(0,e.useEffect)(()=>{s(a.filter(r=>r.hide!==ge.zL.hideVariable))},[a]),n.length===0?null:e.createElement(e.Fragment,null,n.map(r=>e.createElement("div",{key:r.id,className:"submenu-item gf-form-inline","data-testid":h.Tp.pages.Dashboard.SubMenu.submenuItem},e.createElement(xa,{variable:r,readOnly:t}))))};var Ia=o(81862),Ra=o(58807),et=o(82792),ve=o(87421),Aa=o(39569),La=o(62367),wa=o(70497),Fa=o(14183),Oa=o(19727),$a=o(41394);const tt=a=>t=>t.plugins.panels[a]||(0,$a.$)(`Panel plugin not found (${a})`,!0),Ee=({panel:a})=>{const t=(0,E.useDispatch)(),n=(0,E.useSelector)(tt(a.type)),s=(0,E.useSelector)(l=>l.panelEditor.ui.isPanelOptionsVisible),r=(0,E.useSelector)(l=>l.panelEditor.isVizPickerOpen),i=()=>{t((0,F.eK)(!r))},c=()=>{t(oe({isPanelOptionsVisible:!s}))};return n?e.createElement("div",{className:at.wrapper},e.createElement(Oa.e,null,e.createElement(he.I,{className:at.vizButton,tooltip:"Click to change visualization",imgSrc:n.meta.info.logos.small,isOpen:r,onClick:i,"data-testid":h.Tp.components.PanelEditor.toggleVizPicker,"aria-label":"Change Visualization",variant:"canvas",fullWidth:!0},n.meta.name),e.createElement(he.I,{tooltip:s?"Close options pane":"Show options pane",icon:s?"angle-right":"angle-left",onClick:c,variant:"canvas","data-testid":h.Tp.components.PanelEditor.toggleVizOptions,"aria-label":s?"Close options pane":"Show options pane"}))):null};Ee.displayName="VisualizationTab";const at={wrapper:(0,m.css)`
    display: flex;
    flex-direction: column;
  `,vizButton:(0,m.css)`
    text-align: left;
  `};var Ua=o(78685),Va=o(67647),nt=o(15054),st=o(14792),za=o(68313),Ba=o(96227),rt=o(96374);const Wa=({onConfirm:a,onDismiss:t,panel:n})=>{const s=(0,et.X)(n),r=`${s?"Changing":"Replace with"} library panel`,i=`${s?"Changing":"Replacing with a"} library panel will remove any changes since last save.`;return e.createElement(rt.u,{onConfirm:a,onDismiss:t,confirmText:s?"Change":"Replace",title:r,body:i,dismissText:"Cancel",isOpen:!0})};var Ga=o(83791);const Ha=({panel:a,searchQuery:t,isWidget:n=!1})=>{const[s,r]=(0,e.useState)(!1),[i,c]=(0,e.useState)(void 0),[l,d]=(0,e.useState)([]),u=(0,e.useCallback)(D=>{d(D.map(R=>R.id))},[d]),p=(0,st.UA)().getCurrent(),g=(0,E.useDispatch)(),f=async()=>{i&&(c(void 0),g((0,re.Xk)(a,i)))},N=()=>r(!0),T=()=>c(void 0);return e.createElement(B.gW,{spacing:"md"},!a.libraryPanel&&e.createElement(B.gW,{align:"center"},e.createElement(P.$n,{icon:"plus",onClick:N,variant:"secondary",fullWidth:!0},"Create new library panel")),e.createElement(za.$,{onChange:u,isWidget:n}),e.createElement("div",{className:Qa.libraryPanelsView},e.createElement(Ga.y,{currentPanelId:a.libraryPanel?.uid,searchString:t,panelFilter:l,onClickCard:c,showSecondaryActions:!0,isWidget:n})),s&&e.createElement(Ba.o,{panel:a,onDismiss:()=>r(!1),initialFolderUid:p?.meta.folderUid,isOpen:s}),i&&e.createElement(Wa,{panel:a,onDismiss:T,onConfirm:f}))},Qa={libraryPanelsView:(0,m.css)`
    width: 100%;
  `};var Ka=o(56707),ot=o(86292),C=o(32696);const lt=({panel:a,data:t})=>{const n=(0,E.useSelector)(tt(a.type)),[s,r]=(0,e.useState)(""),i=!!n.meta.skipDataQuery,c=!!(i&&v.$.featureToggles.vizAndWidgetSplit),l=c?nt.MM:nt.wV,d=c?C.__.Widgets:C.__.Visualizations,[u,p]=(0,Ua.A)(l,d),g=(0,E.useDispatch)(),f=(0,S.of)(ka),N=(0,e.useRef)(null),T=(0,e.useCallback)(x=>{g((0,re.gW)({panel:a,...x})),x.withModKey||g((0,F.eK)(!1))},[g,a]),D=()=>{g((0,F.eK)(!1))};if(!n)return null;const R=[{label:"Visualizations",value:C.__.Visualizations},{label:"Suggestions",value:C.__.Suggestions},{label:"Library panels",value:C.__.LibraryPanels,description:"Reusable panels you can share between multiple dashboards."}],A=[{label:"Widgets",value:C.__.Widgets},{label:"Library panels",value:C.__.LibraryPanels,description:"Reusable panels you can share between multiple dashboards."}];return e.createElement("div",{className:f.openWrapper},e.createElement("div",{className:f.formBox},e.createElement("div",{className:f.searchRow},e.createElement(Va.Z,{value:s,onChange:r,ref:N,autoFocus:!0,placeholder:"Search for..."}),e.createElement(P.$n,{title:"Close",variant:"secondary",icon:"angle-up",className:f.closeButton,"aria-label":h.Tp.components.PanelEditor.toggleVizPicker,onClick:D})),e.createElement(te.D,{className:f.customFieldMargin},e.createElement(Ze.z,{options:c?A:R,value:u,onChange:p,fullWidth:!0}))),e.createElement("div",{className:f.scrollWrapper},e.createElement(Z.E,{autoHeightMin:"100%"},e.createElement("div",{className:f.scrollContent},u===C.__.Visualizations&&e.createElement(ot.G,{pluginId:n.meta.id,onChange:T,searchQuery:s}),u===C.__.Widgets&&e.createElement(ot.G,{pluginId:n.meta.id,onChange:T,searchQuery:s,isWidget:!0}),u===C.__.Suggestions&&e.createElement(Ka.a,{onChange:T,searchQuery:s,panel:a,data:t}),u===C.__.LibraryPanels&&e.createElement(Ha,{searchQuery:s,panel:a,key:"Panel Library",isWidget:i})))))};lt.displayName="VisualizationSelectPane";const ka=a=>({icon:(0,m.css)`
      color: ${a.v1.palette.gray33};
    `,wrapper:(0,m.css)`
      display: flex;
      flex-direction: column;
      flex: 1 1 0;
      height: 100%;
    `,vizButton:(0,m.css)`
      text-align: left;
    `,scrollWrapper:(0,m.css)`
      flex-grow: 1;
      min-height: 0;
    `,scrollContent:(0,m.css)`
      padding: ${a.spacing(1)};
    `,openWrapper:(0,m.css)`
      display: flex;
      flex-direction: column;
      flex: 1 1 100%;
      height: 100%;
      background: ${a.colors.background.primary};
      border: 1px solid ${a.colors.border.weak};
    `,searchRow:(0,m.css)`
      display: flex;
      margin-bottom: ${a.spacing(1)};
    `,closeButton:(0,m.css)`
      margin-left: ${a.spacing(1)};
    `,customFieldMargin:(0,m.css)`
      margin-bottom: ${a.spacing(1)};
    `,formBox:(0,m.css)`
      padding: ${a.spacing(1)};
      padding-bottom: 0;
    `}),Ja=({plugin:a,panel:t,onFieldConfigsChange:n,onPanelOptionsChanged:s,onPanelConfigChange:r,dashboard:i,instanceState:c})=>{const l=(0,S.of)(ja),d=(0,E.useSelector)(p=>p.panelEditor.isVizPickerOpen),{data:u}=me(t,{withTransforms:!0,withFieldConfig:!1},!0);return e.createElement("div",{className:l.wrapper,"aria-label":h.Tp.components.PanelEditor.OptionsPane.content},!d&&e.createElement(e.Fragment,null,e.createElement("div",{className:l.vizButtonWrapper},e.createElement(Ee,{panel:t})),e.createElement("div",{className:l.optionsWrapper},e.createElement(Fa.Ff,{panel:t,dashboard:i,plugin:a,instanceState:c,data:u,onFieldConfigsChange:n,onPanelOptionsChanged:s,onPanelConfigChange:r}))),d&&e.createElement(lt,{panel:t,data:u}))},ja=a=>({wrapper:(0,m.css)`
      height: 100%;
      width: 100%;
      display: flex;
      flex: 1 1 0;
      flex-direction: column;
      padding: 0;
    `,optionsWrapper:(0,m.css)`
      flex-grow: 1;
      min-height: 0;
    `,vizButtonWrapper:(0,m.css)`
      padding: 0 ${a.spacing(2,2)} 0;
    `,legacyOptions:(0,m.css)`
      label: legacy-options;
      .panel-options-grid {
        display: flex;
        flex-direction: column;
      }
      .panel-options-group {
        margin-bottom: 0;
      }
      .panel-options-group__body {
        padding: ${a.spacing(2)} 0;
      }

      .section {
        display: block;
        margin: ${a.spacing(2)} 0;

        &:first-child {
          margin-top: 0;
        }
      }
    `});var it=o(3591),Ya=o(91052),Za=o(20726),Xa=o(36663),qa=(a=>(a.Error="Error",a.Info="Info",a.Links="Links",a))(qa||{});class _a extends e.Component{constructor(){super(...arguments),this.timeSrv=(0,K.jG)(),this.getInfoMode=()=>{const{panel:t,error:n}=this.props;if(n)return"Error";if(t.description)return"Info";if(t.links&&t.links.length)return"Links"},this.getInfoContent=()=>{const{panel:t}=this.props,n=t.description||"",s=(0,Je.w)().replace(n,t.scopedVars),r=(0,Xa.G)(s),i=this.props.links&&this.props.links.getLinks(t.replaceVariables);return e.createElement("div",{className:"panel-info-content markdown-html"},e.createElement("div",{dangerouslySetInnerHTML:{__html:r}}),i&&i.length>0&&e.createElement("ul",{className:"panel-info-corner-links"},i.map((c,l)=>e.createElement("li",{key:l},e.createElement("a",{className:"panel-info-corner-links__item",href:c.href,target:c.target},c.title)))))},this.onClickError=()=>{b.Ny.partial({inspect:this.props.panel.id,inspectTab:M.q.Error})}}renderCornerType(t,n,s){const r=t==="Error"?"error":"info",i=`panel-info-corner panel-info-corner--${t.toLowerCase()}`,c=h.Tp.components.Panels.Panel.headerCornerInfo(t.toLowerCase());return e.createElement(fe.m,{content:n,placement:"top-start",theme:r,interactive:!0},e.createElement("button",{type:"button",className:i,onClick:s,"aria-label":c},e.createElement("i",{"aria-hidden":!0,className:"fa"}),e.createElement("span",{className:"panel-info-corner-inner"})))}render(){const{error:t}=this.props,n=this.getInfoMode();return n?n==="Error"&&t?this.renderCornerType(n,t,this.onClickError):n==="Info"||n==="Links"?this.renderCornerType(n,this.getInfoContent):null:null}}const en=_a;function tn({width:a,height:t,panel:n,dashboard:s}){const{data:r}=me(n,{withTransforms:!0,withFieldConfig:!1},!1),[i,c]=(0,e.useState)({frameIndex:0,showHeader:!0,showTypeIcons:!0});if((0,e.useEffect)(()=>{const d=(0,K.jG)(),u=n.events.subscribe(it._,()=>{const p=(0,$e.nk)(n,d.timeRange());n.runAllPanelQueries({dashboardUID:s.uid,dashboardTimezone:s.getTimezone(),timeData:p,width:a})});return()=>{u.unsubscribe()}},[n,s,a]),!r)return null;const l=r?.errors?r.errors.length>1?"Multiple errors found. Click for more details":r.errors[0].message:r?.error?.message;return e.createElement(Ya.NR,{width:a,height:t,padding:"none"},(d,u)=>e.createElement(e.Fragment,null,e.createElement(en,{panel:n,error:l}),e.createElement(Za.m,{title:"Raw data",pluginId:"table",width:d,height:u,data:r,options:i,onOptionsChange:c})))}var ct=o(69731),ye=o(8984),an=o(40980),nn=o(18226),sn=o(7376),rn=o(19347),on=o(7521),ln=o(16930),be=o(17172),cn=o(82702),dt=o(55907);class dn extends e.PureComponent{constructor(){super(...arguments),this.state={stateHistoryItems:[]},this.clearHistory=async()=>{const{dashboard:t,panelId:n,onRefresh:s}=this.props;await(0,be.AI)().post("/api/annotations/mass-delete",{dashboardId:t.id,panelId:n}),this.setState({stateHistoryItems:[]}),s()}}componentDidMount(){const{dashboard:t,panelId:n}=this.props;(0,be.AI)().get(`/api/annotations?dashboardId=${t.id}&panelId=${n}&limit=50&type=alert`,{},`state-history-${t.id}-${n}`).then(s=>{const r=s.map(i=>({stateModel:dt.A.getStateDisplayModel(i.newState),time:t.formatDate(i.time,"MMM D, YYYY HH:mm:ss"),info:dt.A.getAlertAnnotationInfo(i)}));this.setState({stateHistoryItems:r})})}render(){const{stateHistoryItems:t}=this.state;return e.createElement("div",null,t.length>0&&e.createElement("div",{className:"p-b-1"},e.createElement("span",{className:"muted"},"Last 50 state changes"),e.createElement(cn.Z,{onConfirm:this.clearHistory,confirmVariant:"destructive",confirmText:"Clear"},e.createElement(P.$n,{className:(0,m.css)`
                  direction: ltr;
                `,variant:"destructive",icon:"trash-alt"},"Clear history"))),e.createElement("ol",{className:"alert-rule-list"},t.length>0?t.map((n,s)=>e.createElement("li",{className:"alert-rule-item",key:`${n.time}-${s}`},e.createElement("div",{className:`alert-rule-item__icon ${n.stateModel.stateClass}`},e.createElement(Q.I,{name:n.stateModel.iconClass,size:"xl"})),e.createElement("div",{className:"alert-rule-item__body"},e.createElement("div",{className:"alert-rule-item__header"},e.createElement("p",{className:"alert-rule-item__name"},n.alertName),e.createElement("div",{className:"alert-rule-item__text"},e.createElement("span",{className:`${n.stateModel.stateClass}`},n.stateModel.text))),n.info),e.createElement("div",{className:"alert-rule-item__time"},n.time))):e.createElement("i",null,"No state changes recorded")))}}const un=dn;var ut=o(39558),mn=o(24022);class pn extends e.PureComponent{constructor(){super(...arguments),this.state={isLoading:!1,allNodesExpanded:null,testRuleResponse:{}},this.setFormattedJson=t=>{this.formattedJson=t},this.getTextForClipboard=()=>JSON.stringify(this.formattedJson,null,2),this.onToggleExpand=()=>{this.setState(t=>({...t,allNodesExpanded:!this.state.allNodesExpanded}))},this.getNrOfOpenNodes=()=>this.state.allNodesExpanded===null?3:this.state.allNodesExpanded?20:1,this.renderExpandCollapse=()=>{const{allNodesExpanded:t}=this.state,n=e.createElement(e.Fragment,null,e.createElement(Q.I,{name:"minus-circle"})," Collapse All"),s=e.createElement(e.Fragment,null,e.createElement(Q.I,{name:"plus-circle"})," Expand All");return t?n:s}}componentDidMount(){this.testRule()}async testRule(){const{dashboard:t,panel:n}=this.props,s=t.getSaveModelCloneOld();s.panels=s.panels.map(c=>c.id===n.id?n.getSaveModel():c);const r={dashboard:s,panelId:n.id};this.setState({isLoading:!0});const i=await(0,be.AI)().post("/api/alerts/test",r);this.setState({isLoading:!1,testRuleResponse:i})}render(){const{testRuleResponse:t,isLoading:n}=this.state,s=(0,P.my)(this.props.theme);if(n===!0)return e.createElement(ut._,{text:"Evaluating rule"});const r=this.getNrOfOpenNodes();return e.createElement(e.Fragment,null,e.createElement("div",{className:"pull-right"},e.createElement(B.Gy,{spacing:"md"},e.createElement("button",{type:"button",className:s,onClick:this.onToggleExpand},this.renderExpandCollapse()),e.createElement(de.b,{getText:this.getTextForClipboard,icon:"copy"},"Copy to Clipboard"))),e.createElement(mn.B,{json:t,open:r,onDidRender:this.setFormattedJson}))}}const hn=(0,S.cV)(pn);var gn=o(21468);class fn extends e.PureComponent{constructor(){super(...arguments),this.state={validationMessage:"",showStateHistory:!1,showDeleteConfirmation:!1,showTestRule:!1},this.onAngularPanelUpdated=()=>{this.forceUpdate()},this.onAddAlert=()=>{this.panelCtrl?._enableAlert(),this.component?.digest(),this.forceUpdate()},this.onToggleModal=t=>{const n=this.state[t];this.setState({...this.state,[t]:!n})},this.renderTestRule=()=>{if(!this.state.showTestRule)return null;const{panel:t,dashboard:n}=this.props,s=()=>this.onToggleModal("showTestRule");return e.createElement(z.a,{isOpen:!0,icon:"bug",title:"Testing rule",onDismiss:s,onClickBackdrop:s},e.createElement(hn,{panel:t,dashboard:n}))},this.renderDeleteConfirmation=()=>{if(!this.state.showDeleteConfirmation)return null;const{panel:t}=this.props,n=()=>this.onToggleModal("showDeleteConfirmation");return e.createElement(rt.u,{isOpen:!0,icon:"trash-alt",title:"Delete",body:e.createElement("div",null,"Are you sure you want to delete this alert rule?",e.createElement("br",null),e.createElement("small",null,"You need to save dashboard for the delete to take effect.")),confirmText:"Delete alert",onDismiss:n,onConfirm:()=>{delete t.alert,t.thresholds=[],this.panelCtrl&&(this.panelCtrl.alertState=null,this.panelCtrl.render()),this.component?.digest(),n()}})},this.renderStateHistory=()=>{if(!this.state.showStateHistory)return null;const{panel:t,dashboard:n}=this.props,s=()=>this.onToggleModal("showStateHistory");return e.createElement(z.a,{isOpen:!0,icon:"history",title:"State history",onDismiss:s,onClickBackdrop:s},e.createElement(un,{dashboard:n,panelId:t.id,onRefresh:()=>this.panelCtrl?.refresh()}))}}async componentDidMount(){v.$.angularSupportEnabled?(await Promise.all([o.e(7982),o.e(587)]).then(o.bind(o,9244)),this.loadAlertTab()):alert("Angular support disabled, legacy alerting cannot function without angular support")}componentDidUpdate(t){this.loadAlertTab()}componentWillUnmount(){this.component&&this.component.destroy()}async loadAlertTab(){const{panel:t,angularPanelComponent:n}=this.props;if(!this.element||this.component)return;if(n){const l=n.getScope();if(!l.$$childHead){setTimeout(()=>{this.forceUpdate()});return}this.panelCtrl=l.$$childHead.ctrl}else this.panelCtrl=this.getReactAlertPanelCtrl();const s=(0,sn.E)(),r="<alert-tab />",i={ctrl:this.panelCtrl};this.component=s.load(this.element,i,r);const c=await(0,gn.d)(t.transformations,t.targets,(0,rn.l)(),t.datasource);c&&this.setState({validationMessage:c})}getReactAlertPanelCtrl(){return{panel:this.props.panel,events:new nn.o,render:()=>{this.props.panel.render()}}}render(){const{alert:t,transformations:n}=this.props.panel,{validationMessage:s}=this.state,r=n&&n.length>0;if(!t&&s)return e.createElement(ln.c,{message:s});const i={title:"Panel has no alert rule defined",buttonIcon:"bell",onClick:this.onAddAlert,buttonTitle:"Create Alert"};return e.createElement(e.Fragment,null,e.createElement(Z.E,{autoHeightMin:"100%"},e.createElement(B.mc,{padding:"md"},e.createElement("div",{"data-testid":h.Tp.components.AlertTab.content},t&&r&&e.createElement(H.F,{severity:E.AppNotificationSeverity.Error,title:"Transformations are not supported in alert queries"}),e.createElement("div",{ref:c=>this.element=c}),t&&e.createElement(B.Gy,null,e.createElement(P.$n,{onClick:()=>this.onToggleModal("showStateHistory"),variant:"secondary"},"State history"),e.createElement(P.$n,{onClick:()=>this.onToggleModal("showTestRule"),variant:"secondary"},"Test rule"),e.createElement(P.$n,{onClick:()=>this.onToggleModal("showDeleteConfirmation"),variant:"destructive"},"Delete")),!t&&!s&&e.createElement(on.A,{...i})))),this.renderTestRule(),this.renderDeleteConfirmation(),this.renderStateHistory())}}const vn=(a,t)=>({angularPanelComponent:(0,le.U)(a,t.panel)?.angularComponent}),En={},yn=(0,y.connect)(vn,En)(fn);var bn=o(76885),mt=o(25027),Pn=o(63066);const pt=({dashboard:a,panel:t,className:n})=>{const s=(0,E.useSelector)(d=>d.templating),r=(0,se.zy)(),{loading:i,value:c}=(0,U.A)(()=>(0,Pn.mp)(t,a),[t,a,s]);if(i)return e.createElement(P.$n,{disabled:!0},"New alert rule");if(!c)return e.createElement(H.F,{severity:"info",title:"No alerting capable query found"},"Cannot create alerts from this panel because no query to an alerting capable datasource is found.");const l=bn.kM.renderUrl("alerting/new",{defaults:JSON.stringify(c),returnTo:r.pathname+r.search});return e.createElement(P.z9,{icon:"bell",onClick:()=>(0,mt.fH)(mt.le.alertRuleFromPanel),href:l,className:n,"data-testid":"create-alert-rule-button"},"New alert rule")};var Sn=o(82422),ht=o(27747),Cn=o(75471);const Tn=({dashboard:a,panel:t})=>{const n=(0,S.of)(Dn),{errors:s,loading:r,rules:i}=(0,ht.S)({dashboardUID:a.uid,panelId:t.id,poll:!0}),c=(0,Cn.Wd)("grafana"),l=q.TP.hasPermission(c.create),d=s.length?e.createElement(H.F,{title:"Errors loading rules",severity:"error"},s.map((u,p)=>e.createElement("div",{key:p},"Failed to load Grafana rules state: ",u.message||"Unknown error."))):null;return r&&!i.length?e.createElement("div",{className:n.innerWrapper},d,e.createElement(ut._,{text:"Loading rules..."})):i.length?e.createElement(Z.E,{autoHeightMin:"100%"},e.createElement("div",{className:n.innerWrapper},d,e.createElement(Sn.s,{rules:i}),!!a.meta.canSave&&l&&e.createElement(pt,{className:n.newButton,panel:t,dashboard:a}))):e.createElement("div",{"data-testid":h.Tp.components.PanelAlertTabContent.content,className:n.noRulesWrapper},d,!!a.uid&&e.createElement(e.Fragment,null,e.createElement("p",null,"There are no alert rules linked to this panel."),!!a.meta.canSave&&l&&e.createElement(pt,{panel:t,dashboard:a})),!a.uid&&!!a.meta.canSave&&e.createElement(H.F,{severity:"info",title:"Dashboard not saved"},"Dashboard must be saved before alerts can be added."))},Dn=a=>({newButton:(0,m.css)`
    margin-top: ${a.spacing(3)};
  `,innerWrapper:(0,m.css)`
    padding: ${a.spacing(2)};
  `,noRulesWrapper:(0,m.css)`
    margin: ${a.spacing(2)};
    background-color: ${a.colors.background.secondary};
    padding: ${a.spacing(3)};
  `}),Nn=v.$.unifiedAlertingEnabled?Tn:yn,xn=({panel:a,dashboard:t,...n})=>{const{rules:s,loading:r}=(0,ht.S)({panelId:a.id,dashboardUID:t.uid});return e.createElement(J.o,{...n,counter:r?null:s.length})};var Mn=o(57120),In=o(22391),Rn=o(47311),Pe=o(31193),An=o(37464);class Ln extends e.PureComponent{constructor(t){super(t),this.updateLastUsedDatasource=n=>{(0,Rn.tw)(n)},this.onRunQueries=()=>{this.props.panel.refresh()},this.onOpenQueryInspector=()=>{b.Ny.partial({inspect:this.props.panel.id,inspectTab:"query"})},this.onOptionsChange=n=>{const{panel:s}=this.props;s.updateQueries(n),n.dataSource.uid!==s.datasource?.uid&&setTimeout(this.onRunQueries,10),this.forceUpdate()}}buildQueryOptions(t){const n=t.datasource??{default:!0},s=(0,Pe.tR)().getInstanceSettings(n);return this.updateLastUsedDatasource(n),{cacheTimeout:s?.meta.queryOptions?.cacheTimeout?t.cacheTimeout:void 0,dataSource:{default:s?.isDefault,type:s?.type,uid:s?.uid},queryCachingTTL:s?.cachingConfig?.enabled?t.queryCachingTTL:void 0,queries:t.targets,maxDataPoints:t.maxDataPoints,minInterval:t.interval,timeRange:{from:t.timeFrom,shift:t.timeShift,hide:t.hideTimeOverride}}}async componentDidMount(){const{panel:t}=this.props;if(!t.datasource){let n;const s=(0,st.UA)().getCurrent()?.uid??"",r=(0,Le.CW)(s);r?.datasourceUid!==null&&(n=(0,Pe.tR)().getInstanceSettings(r?.datasourceUid)),n||(n=(0,Pe.tR)().getInstanceSettings(null)),t.datasource=(0,In.p$)(n),this.forceUpdate()}}render(){const{panel:t}=this.props;if(!t.datasource)return null;const n=this.buildQueryOptions(t);return e.createElement(An.g,{options:n,queryRunner:t.getQueryRunner(),onRunQueries:this.onRunQueries,onOpenQueryInspector:this.onOpenQueryInspector,onOptionsChange:this.onOptionsChange})}}const gt=e.memo(({panel:a,dashboard:t,tabs:n,onChangeTab:s})=>{const r=(0,ct.C)(),i=(0,S.of)(Fn),c=(0,e.useCallback)(d=>{let u="panel_editor_tabs_changed";v.$.featureToggles.transformationsRedesign&&(u="transformations_redesign_"+u),d.active||(0,xe.rR)(u,{tab_id:d.id}),s(d)},[s]);(0,e.useEffect)(()=>{const d=new Ye.yU;return d.add(a.events.subscribe(w.zq,r)),d.add(a.events.subscribe(w.JI,r)),()=>d.unsubscribe()},[a,t,r]);const l=n.find(d=>d.active);return n.length===0?null:e.createElement("div",{className:i.wrapper},e.createElement(ce.U,{className:i.tabBar,hideBorder:!0},n.map(d=>d.id===C.M8.Alert?wn(d,a,t,c):e.createElement(J.o,{key:d.id,label:d.text,active:d.active,onChangeTab:()=>c(d),icon:(0,ye.toIconName)(d.icon),counter:ft(a,d)}))),e.createElement(an.J,{className:i.tabContent},l.id===C.M8.Query&&e.createElement(Ln,{panel:a,queries:a.targets}),l.id===C.M8.Alert&&e.createElement(Nn,{panel:a,dashboard:t}),l.id===C.M8.Transform&&e.createElement(Mn.o,{panel:a})))});gt.displayName="PanelEditorTabs";function ft(a,t){switch(t.id){case C.M8.Query:return a.targets.length;case C.M8.Alert:return a.alert?1:0;case C.M8.Transform:return(a.getTransformations()??[]).length}return null}function wn(a,t,n,s){return!v.$.alertingEnabled&&!v.$.unifiedAlertingEnabled?null:v.$.unifiedAlertingEnabled?e.createElement(xn,{key:a.id,label:a.text,active:a.active,onChangeTab:()=>s(a),icon:(0,ye.toIconName)(a.icon),panel:t,dashboard:n}):v.$.alertingEnabled?e.createElement(J.o,{key:a.id,label:a.text,active:a.active,onChangeTab:()=>s(a),icon:(0,ye.toIconName)(a.icon),counter:ft(t,a)}):null}const Fn=a=>({wrapper:(0,m.css)`
      display: flex;
      flex-direction: column;
      height: 100%;
    `,tabBar:(0,m.css)`
      padding-left: ${a.spacing(2)};
    `,tabContent:(0,m.css)`
      padding: 0;
      display: flex;
      flex-direction: column;
      flex: 1;
      min-height: 0;
      background: ${a.colors.background.primary};
      border: 1px solid ${a.components.panel.borderColor};
      border-left: none;
      border-bottom: none;
      border-top-right-radius: ${a.shape.borderRadius(1.5)};
    `});var On=o(95689),$n=o(54612);const Un=(a,t)=>{const n=a.panelEditor.getPanel(),s=(0,le.U)(a,n);return{panel:n,plugin:s?.plugin,instanceState:s?.instanceState,initDone:a.panelEditor.initDone,uiState:a.panelEditor.ui,tableViewEnabled:a.panelEditor.tableViewEnabled,variables:(0,ve.SS)(t.dashboard.uid,a)}},Vn={initPanelEditor:Ht,discardPanelChanges:Ve,updatePanelEditorUIState:oe,updateTimeZoneForSession:Ia.Cj,toggleTableView:F.kw,notifyApp:Ce.dx},zn=(0,y.connect)(Un,Vn);class Bn extends e.PureComponent{constructor(){super(...arguments),this.state={showSaveLibraryPanelModal:!1},this.triggerForceUpdate=()=>{this.forceUpdate()},this.onBack=()=>{b.Ny.partial({editPanel:null,tab:null,showCategory:null})},this.onDiscard=()=>{this.props.discardPanelChanges(),this.onBack()},this.onSaveDashboard=()=>{Ta.lE.publish(new w.S8({component:wa.$,props:{dashboard:this.props.dashboard}}))},this.onSaveLibraryPanel=async()=>{(0,et.X)(this.props.panel)&&this.setState({showSaveLibraryPanelModal:!0})},this.onChangeTab=t=>{b.Ny.partial({tab:t.id})},this.onFieldConfigChange=t=>{this.props.panel.updateFieldConfig({...t})},this.onPanelOptionsChanged=t=>{this.props.panel.updateOptions(t)},this.onPanelConfigChanged=(t,n)=>{this.props.panel.setProperty(t,n),this.props.panel.render(),this.forceUpdate()},this.onDisplayModeChange=t=>{const{updatePanelEditorUIState:n}=this.props;this.props.tableViewEnabled&&this.props.toggleTableView(),n({mode:t})},this.onToggleTableView=()=>{this.props.toggleTableView()},this.onGoBackToDashboard=()=>{b.Ny.partial({editPanel:null,tab:null,showCategory:null})},this.onConfirmAndDismissLibarayPanelModel=()=>{this.setState({showSaveLibraryPanelModal:!1})}}componentDidMount(){this.props.initPanelEditor(this.props.sourcePanel,this.props.dashboard)}componentDidUpdate(){const{panel:t,initDone:n}=this.props;n&&!this.eventSubs&&(this.eventSubs=new Ye.yU,this.eventSubs.add(t.events.subscribe(w.PR,this.triggerForceUpdate)))}componentWillUnmount(){this.eventSubs?.unsubscribe()}renderPanel(t,n){const{dashboard:s,panel:r,uiState:i,tableViewEnabled:c,theme:l}=this.props;return e.createElement("div",{className:t.mainPaneWrapper,key:"panel"},this.renderPanelToolbar(t),e.createElement("div",{className:t.panelWrapper},e.createElement(ie.Ay,null,({width:d,height:u})=>{if(d<3||u<3)return null;if(n&&(u-=l.spacing.gridSize*2),c)return e.createElement(tn,{width:d,height:u,panel:r,dashboard:s});const p=(0,$n.A)(i.mode,d,u,r);return e.createElement("div",{className:t.centeringContainer,style:{width:d,height:u}},e.createElement("div",{style:p,"data-panelid":r.id},e.createElement(Aa.L,{key:r.key,stateKey:r.key,dashboard:s,panel:r,isEditing:!0,isViewing:!1,lazy:!1,width:p.width,height:p.height})))})))}renderPanelAndEditor(t,n){const{panel:s,dashboard:r,plugin:i,tab:c}=this.props,l=(0,On.a)(c,i),d=l.length===0,u=this.renderPanel(n,d);return l.length===0?e.createElement("div",{className:n.onlyPanel},u):e.createElement(qe.g,{splitOrientation:"horizontal",maxSize:-200,paneSize:t.topPaneSize,primary:"first",secondaryPaneStyle:{minHeight:0},onDragFinished:p=>{p&&oe({topPaneSize:p/window.innerHeight})}},u,e.createElement("div",{className:n.tabsWrapper,"aria-label":h.Tp.components.PanelEditor.DataPane.content,key:"panel-editor-tabs"},e.createElement(gt,{key:s.key,panel:s,dashboard:r,tabs:l,onChangeTab:this.onChangeTab})))}renderTemplateVariables(t){const{variables:n}=this.props;return n.length?e.createElement("div",{className:t.variablesWrapper},e.createElement(_e,{variables:n})):null}renderPanelToolbar(t){const{dashboard:n,uiState:s,variables:r,updateTimeZoneForSession:i,panel:c,tableViewEnabled:l}=this.props;return e.createElement("div",{className:t.panelToolbar},e.createElement(B.Gy,{justify:r.length>0?"space-between":"flex-end",align:"flex-start"},this.renderTemplateVariables(t),e.createElement(ee.B,{gap:1},e.createElement(j.K,{label:"Table view",showLabel:!0,id:"table-view",value:l,onClick:this.onToggleTableView,"aria-label":h.Tp.components.PanelEditor.toggleTableView}),e.createElement(Ze.z,{value:s.mode,options:C.Nt,onChange:this.onDisplayModeChange}),e.createElement(La.$,{dashboard:n,onChangeTimeZone:i,isOnCanvas:!0}),!s.isPanelOptionsVisible&&e.createElement(Ee,{panel:c}))))}renderEditorActions(){const t="sm";let n=[e.createElement(P.$n,{onClick:this.onDiscard,title:"Undo all changes",key:"discard",size:t,variant:"destructive",fill:"outline"},"Discard"),this.props.panel.libraryPanel?e.createElement(P.$n,{onClick:this.onSaveLibraryPanel,variant:"primary",size:t,title:"Apply changes and save library panel",key:"save-panel"},"Save library panel"):e.createElement(P.$n,{onClick:this.onSaveDashboard,title:"Apply changes and save dashboard",key:"save",size:t,variant:"secondary"},"Save"),e.createElement(P.$n,{onClick:this.onBack,variant:"primary",title:"Apply changes and go back to dashboard","data-testid":h.Tp.components.PanelEditor.applyButton,key:"apply",size:t},"Apply")];return this.props.panel.libraryPanel&&(n.splice(1,0,e.createElement(Fe.$s,{key:"unlink-controller"},({showModal:s,hideModal:r})=>e.createElement(he.I,{onClick:()=>{s(Ra.l,{onConfirm:()=>{this.props.panel.unlinkLibraryPanel(),this.forceUpdate()},onDismiss:r,isOpen:!0})},title:"Disconnects this panel from the library panel so that you can edit it regularly.",key:"unlink"},"Unlink"))),n.pop()),n}renderOptionsPane(){const{plugin:t,dashboard:n,panel:s,instanceState:r}=this.props;return t?e.createElement(Ja,{plugin:t,dashboard:n,panel:s,instanceState:r,onFieldConfigsChange:this.onFieldConfigChange,onPanelOptionsChanged:this.onPanelOptionsChanged,onPanelConfigChange:this.onPanelConfigChanged}):e.createElement("div",null)}render(){const{initDone:t,uiState:n,theme:s,sectionNav:r,pageNav:i,className:c,updatePanelEditorUIState:l}=this.props,d=Gn(s,this.props);return t?e.createElement(O.Y,{navModel:r,pageNav:i,"aria-label":h.Tp.components.PanelEditor.General.content,layout:I.k.Custom,className:c},e.createElement(Ca.H,{actions:e.createElement(Sa.U,{alignment:"right"},this.renderEditorActions())}),e.createElement("div",{className:d.wrapper},e.createElement("div",{className:d.verticalSplitPanesWrapper},n.isPanelOptionsVisible?e.createElement(qe.g,{splitOrientation:"vertical",maxSize:-300,paneSize:n.rightPaneSize,primary:"second",onDragFinished:u=>{u&&l({rightPaneSize:u/window.innerWidth})}},this.renderPanelAndEditor(n,d),this.renderOptionsPane()):this.renderPanelAndEditor(n,d)),this.state.showSaveLibraryPanelModal&&e.createElement(Oe,{panel:this.props.panel,folderUid:this.props.dashboard.meta.folderUid??"",onConfirm:this.onConfirmAndDismissLibarayPanelModel,onDiscard:this.onDiscard,onDismiss:this.onConfirmAndDismissLibarayPanelModel}))):null}}const Wn=(0,S.cV)(zn(Bn)),Gn=(0,Xe.N)((a,t)=>{const{uiState:n}=t,s=a.spacing(2);return{wrapper:(0,m.css)({width:"100%",flexGrow:1,minHeight:0,display:"flex",paddingTop:a.spacing(2)}),verticalSplitPanesWrapper:(0,m.css)`
      display: flex;
      flex-direction: column;
      height: 100%;
      width: 100%;
      position: relative;
    `,mainPaneWrapper:(0,m.css)`
      display: flex;
      flex-direction: column;
      height: 100%;
      width: 100%;
      padding-right: ${n.isPanelOptionsVisible?0:s};
    `,variablesWrapper:(0,m.css)`
      label: variablesWrapper;
      display: flex;
      flex-grow: 1;
      flex-wrap: wrap;
      gap: ${a.spacing(1,2)};
    `,panelWrapper:(0,m.css)`
      flex: 1 1 0;
      min-height: 0;
      width: 100%;
      padding-left: ${s};
    `,tabsWrapper:(0,m.css)`
      height: 100%;
      width: 100%;
    `,panelToolbar:(0,m.css)`
      display: flex;
      padding: 0 0 ${s} ${s};
      justify-content: space-between;
      flex-wrap: wrap;
    `,angularWarning:(0,m.css)`
      display: flex;
      height: theme.spacing(4);
      align-items: center;
    `,toolbarLeft:(0,m.css)`
      padding-left: ${a.spacing(1)};
    `,centeringContainer:(0,m.css)`
      display: flex;
      justify-content: center;
      align-items: center;
      position: relative;
      flex-direction: column;
    `,onlyPanel:(0,m.css)`
      height: 100%;
      position: absolute;
      overflow: hidden;
      width: 100%;
    `}});var Hn=o(1702),Qn=o(39268),Kn=o(14186),kn=o(89963),Jn=o(37168);const jn=({annotation:a,events:t,onEnabledChanged:n})=>{const[s,r]=(0,e.useState)(!1),i=(0,S.of)(Yn),c=()=>(0,Jn.Dh)().cancel(a);return(0,e.useEffect)(()=>{const l=t.getStream(w.xc).subscribe({next:u=>{u.payload===a&&r(!0)}}),d=t.getStream(w.yj).subscribe({next:u=>{u.payload===a&&r(!1)}});return()=>{l.unsubscribe(),d.unsubscribe()}}),e.createElement("div",{key:a.name,className:i.annotation},e.createElement(Qn.C,null,e.createElement(Kn.I,{label:a.name,disabled:s,"data-testid":h.Tp.pages.Dashboard.SubMenu.Annotations.annotationLabel(a.name)},e.createElement(j.K,{label:a.name,value:a.enable,onChange:()=>n(a),disabled:s,"data-testid":h.Tp.pages.Dashboard.SubMenu.Annotations.annotationToggle(a.name)})),e.createElement("div",{className:i.indicator},e.createElement(kn.I,{loading:s,onCancel:c}))))};function Yn(a){return{annotation:(0,m.css)`
      display: inline-block;
      margin-right: ${a.spacing(1)};

      .fa-caret-down {
        font-size: 75%;
        padding-left: ${a.spacing(1)};
      }

      .gf-form-inline .gf-form {
        margin-bottom: 0;
      }
    `,indicator:(0,m.css)`
      align-self: center;
      padding: 0 ${a.spacing(.5)};
    `}}const Zn=({annotations:a,onAnnotationChanged:t,events:n})=>{const[s,r]=(0,e.useState)([]);return(0,e.useEffect)(()=>{r(a.filter(i=>i.hide!==!0))},[a]),s.length===0?null:e.createElement("div",{"data-testid":h.Tp.pages.Dashboard.SubMenu.Annotations.annotationsWrapper},s.map(i=>e.createElement(jn,{events:n,annotation:i,onEnabledChanged:t,key:i.name})))};var Xn=o(94701),qn=o(80997),_n=o(4588),es=o(6923),vt=o(52424);const ts=({dashboard:a,links:t})=>{const n=(0,ct.C)();return(0,Xn.A)(()=>{const s=a.events.subscribe(it.sR,n);return()=>s.unsubscribe()}),t.length?e.createElement(e.Fragment,null,t.map((s,r)=>{const i=(0,es.mQ)().getAnchorInfo(s),c=`${s.title}-$${r}`;if(s.type==="dashboards")return e.createElement(vt.aK,{key:c,link:s,linkInfo:i,dashboardUID:a.uid});const l=_n.G[s.icon],d=e.createElement(vt.Zx,{href:(0,qn.Jf)(i.href),target:s.targetBlank?"_blank":void 0,rel:"noreferrer","data-testid":h.Tp.components.DashboardLinks.link,icon:l},i.title);return e.createElement("div",{key:c,"data-testid":h.Tp.components.DashboardLinks.container},s.tooltip?e.createElement(fe.m,{content:i.tooltip},d):d)})):null};class as extends e.PureComponent{constructor(){super(...arguments),this.onAnnotationStateChanged=t=>{for(let n=0;n<this.props.dashboard.annotations.list.length;n++){const s=this.props.dashboard.annotations.list[n];if(s.name===t.name){s.enable=!s.enable;break}}this.props.dashboard.startRefresh(),this.forceUpdate()},this.disableSubmitOnEnter=t=>{t.preventDefault()}}render(){const{dashboard:t,variables:n,links:s,annotations:r,theme:i}=this.props,c=ss(i);if(!t.isSubMenuVisible())return null;const l=t.meta.isSnapshot??!1;return e.createElement("div",{className:c.submenu},e.createElement("form",{"aria-label":"Template variables",className:c.formStyles,onSubmit:this.disableSubmitOnEnter},e.createElement(_e,{variables:n,readOnly:l})),e.createElement(Zn,{annotations:r,onAnnotationChanged:this.onAnnotationStateChanged,events:t.events}),e.createElement("div",{className:c.spacer}),t&&e.createElement(ts,{dashboard:t,links:s}))}}const ns=(a,t)=>{const{uid:n}=t.dashboard,s=(0,ve.nx)(n,a);return{variables:(0,ve.pi)(n,s.variables)}},ss=(0,Xe.N)(a=>({formStyles:(0,m.css)`
      display: flex;
      flex-wrap: wrap;
      display: contents;
    `,submenu:(0,m.css)`
      display: flex;
      flex-direction: row;
      flex-wrap: wrap;
      align-content: flex-start;
      align-items: flex-start;
      gap: ${a.spacing(1)} ${a.spacing(2)};
      padding: 0 0 ${a.spacing(1)} 0;
    `,spacer:(0,m.css)({flexGrow:1})})),Et=(0,S.cV)((0,y.connect)(ns)(as));Et.displayName="SubMenu";var rs=o(2118),os=o(61582),ls=o(3673);const is=a=>({initPhase:a.dashboard.initPhase,initError:a.dashboard.initError,dashboard:a.dashboard.getModel(),navIndex:a.navIndex}),cs={initDashboard:Ke.vR,cleanUpDashboardAndVariables:ls.Bz,notifyApp:Ce.dx,cancelVariables:Re.Y7,templateVarsChangedInUrl:Re.Hn},ds=(0,y.connect)(is,cs);class yt extends e.PureComponent{constructor(){super(...arguments),this.forceRouteReloadCounter=0,this.state=this.getCleanState(),this.updateLiveTimer=()=>{let t;this.props.dashboard?.liveNow&&(t=(0,K.jG)().timeRange()),os.a.setLiveTimeRange(t)},this.setScrollRef=t=>{this.setState({scrollElement:t})},this.onCloseShareModal=()=>{b.Ny.partial({shareView:null})}}getCleanState(){return{editPanel:null,viewPanel:null,showLoadingState:!1,panelNotFound:!1,editPanelAccessDenied:!1}}componentDidMount(){this.initDashboard(),this.forceRouteReloadCounter=this.props.history.location.state?.routeReloadCounter||0}componentWillUnmount(){this.closeDashboard()}closeDashboard(){this.props.cleanUpDashboardAndVariables(),this.setState(this.getCleanState())}initDashboard(){const{dashboard:t,match:n,queryParams:s}=this.props;t&&this.closeDashboard(),this.props.initDashboard({urlSlug:n.params.slug,urlUid:n.params.uid,urlType:n.params.type,urlFolderUid:s.folderUid,panelType:s.panelType,routeName:this.props.route.routeName,fixUrl:!0,accessToken:n.params.accessToken,keybindingSrv:this.context.keybindings}),setTimeout(this.updateLiveTimer,250)}componentDidUpdate(t,n){const{dashboard:s,match:r,templateVarsChangedInUrl:i}=this.props,c=this.props.history.location.state?.routeReloadCounter;if(s){if(t.match.params.uid!==r.params.uid||c!==void 0&&this.forceRouteReloadCounter!==c){this.initDashboard(),this.forceRouteReloadCounter=c;return}if(t.location.search!==this.props.location.search){const l=t.queryParams,d=this.props.queryParams;(d?.from!==l?.from||d?.to!==l?.to)&&((0,K.jG)().updateTimeRangeFromUrl(),this.updateLiveTimer()),!l?.refresh&&d?.refresh&&(0,K.jG)().setAutoRefresh(d.refresh);const u=(0,It.Wz)(this.props.queryParams,t.queryParams);u&&i(s.uid,u)}this.state.editPanel&&!n.editPanel&&(Ne.t.setEditingState(!0),this.props.dashboard?.events.publish(new w.sL(this.state.editPanel.id))),!this.state.editPanel&&n.editPanel&&(Ne.t.setEditingState(!1),this.props.dashboard?.events.publish(new w.i0(n.editPanel.id))),this.state.editPanelAccessDenied&&(this.props.notifyApp((0,Te.gi)("Permission to edit panel denied")),b.Ny.partial({editPanel:null})),this.state.panelNotFound&&(this.props.notifyApp((0,Te.gi)("Panel not found")),b.Ny.partial({editPanel:null,viewPanel:null}))}}static getDerivedStateFromProps(t,n){const{dashboard:s,queryParams:r}=t,i=r.editPanel,c=r.viewPanel;if(!s)return n;const l={...n};if(!n.editPanel&&i){const d=s.getPanelByUrlId(i);d?s.canEditPanel(d)?(l.editPanel=d,l.rememberScrollTop=n.scrollElement?.scrollTop):l.editPanelAccessDenied=!0:l.panelNotFound=!0}else n.editPanel&&!i&&(l.editPanel=null,l.updateScrollTop=n.rememberScrollTop);if(!n.viewPanel&&c){const d=s.getPanelByUrlId(c);d?(s.initViewPanel(d),l.viewPanel=d,l.rememberScrollTop=n.scrollElement?.scrollTop,l.updateScrollTop=0):l.panelNotFound=!0}else n.viewPanel&&!c&&(s.exitViewPanel(n.viewPanel),l.viewPanel=null,l.updateScrollTop=n.rememberScrollTop);return(n.panelNotFound||n.editPanelAccessDenied&&!i)&&(l.panelNotFound=!1,l.editPanelAccessDenied=!1),us(t,l)}getInspectPanel(){const{dashboard:t,queryParams:n}=this.props,s=n.inspect;if(!t||!s)return null;const r=t.getPanelById(parseInt(s,10));return r||null}render(){const{dashboard:t,initError:n,queryParams:s}=this.props,{editPanel:r,viewPanel:i,updateScrollTop:c,pageNav:l,sectionNav:d}=this.state,u=Tt(this.props.queryParams);if(!t||!l||!d)return e.createElement(Ot.P,{initPhase:this.props.initPhase});const p=this.getInspectPanel(),g=!r&&!u&&!this.props.queryParams.editview,f=u!==E.KioskMode.Full&&!s.editview,N=(0,m.cx)({"panel-in-fullscreen":!!i,"page-hidden":!!(s.editview||r)});return t.meta.dashboardNotFound?e.createElement(O.Y,{navId:"dashboards/browse",layout:I.k.Canvas,pageNav:{text:"Not found"}},e.createElement(St.L,{entity:"Dashboard"})):e.createElement(e.Fragment,null,e.createElement(O.Y,{navModel:d,pageNav:l,layout:I.k.Canvas,className:N,scrollRef:this.setScrollRef,scrollTop:c},f&&e.createElement("header",{"data-testid":h.Tp.pages.Dashboard.DashNav.navV2},e.createElement(wt.U,{dashboard:t,title:t.title,folderTitle:t.meta.folderTitle,isFullscreen:!!i,kioskMode:u,hideTimePicker:t.timepicker.hidden})),e.createElement(ze,{dashboard:t}),n&&e.createElement(Ft.y,null),g&&e.createElement("section",{"aria-label":h.Tp.pages.Dashboard.SubMenu.submenu},e.createElement(Et,{dashboard:t,annotations:t.annotations.list,links:t.links})),v.$.featureToggles.angularDeprecationUI&&t.hasAngularPlugins()&&t.uid!==null&&e.createElement(Mt,{dashboardUid:t.uid}),e.createElement(rs.N,{dashboard:t,isEditable:!!t.meta.canEdit,viewPanel:i,editPanel:r}),p&&e.createElement(Pa,{dashboard:t,panel:p}),s.shareView&&e.createElement(Hn.ShareModal,{dashboard:t,onDismiss:this.onCloseShareModal})),r&&e.createElement(Wn,{dashboard:t,sourcePanel:r,tab:this.props.queryParams.tab,sectionNav:d,pageNav:l}),s.editview&&e.createElement(Zt.s,{dashboard:t,editview:s.editview,pageNav:l,sectionNav:d}),s.addWidget&&v.$.featureToggles.vizAndWidgetSplit&&e.createElement(At,null))}}yt.contextType=Ct.YE;function us(a,t){const{dashboard:n,navIndex:s}=a;if(!n)return t;let r=t.pageNav,i=t.sectionNav;(!r||n.title!==r.text||n.meta.folderUrl!==r.parentItem?.url)&&(r={text:n.title,url:$.I.getUrlForPartial(a.history.location,{editview:null,editPanel:null,viewPanel:null})});const{folderUid:c}=n.meta;if(c&&r){const l=(0,De.tc)(s,`folder-dashboards-${c}`).main;l.id!=="not-found"&&(r={...r,parentItem:l})}if(a.route.routeName===E.DashboardRoutes.Path){i=Ie();const l=Me(a.match.params.slug);l?.parentItem&&(l.parentItem=l.parentItem)}else i=(0,De.tc)(a.navIndex,"dashboards/browse");return(t.editPanel||t.viewPanel)&&(r={...r,text:`${t.editPanel?"Edit":"View"} panel`,parentItem:r,url:void 0}),t.pageNav===r&&t.sectionNav===i?t:{...t,pageNav:r,sectionNav:i}}const bt=(0,S.cV)(yt);bt.displayName="DashboardPage";const Pt=ds(bt);function ms(a){if(v.$.featureToggles.dashboardScene||a.queryParams.scenes)return e.createElement(V,{...a});const t=(0,L.sP)(),n=!!(a.route.routeName===E.DashboardRoutes.Home||a.route.routeName===E.DashboardRoutes.Normal&&a.match.params.uid),s=(0,U.A)(async()=>a.match.params.type==="snapshot"?null:t.fetchDashboard({route:a.route.routeName,uid:a.match.params.uid??""}),[a.match.params.uid,a.route.routeName]);return v.$.featureToggles.dashboardSceneForViewers?s.loading?null:s.value&&!(s.value.meta.canEdit||s.value.meta.canMakeEditable)&&n?e.createElement(V,{...a}):e.createElement(Pt,{...a}):e.createElement(Pt,{...a})}const ps=ms},53652:(Se,W,o)=>{o.d(W,{E:()=>E,o:()=>G});var e=o(89667),U=o(57875),v=o(17172),I=o(32264),O=o(27677);class k{constructor(){}async get(m){const y=`api/storage/read/${m}`.replace("//","/");return(0,v.AI)().get(y)}async list(m){let y="api/storage/list/";m&&(y+=m+"/");const $=await(0,v.AI)().get(y);if($?.data){const h=(0,e.or)($);for(const b of h.fields)b.display=(0,U.J)({field:b,theme:I.$.theme2});return h}}async createFolder(m){const y=await(0,v.AI)().post("/api/storage/createFolder",JSON.stringify({path:m}));return y.success?{}:{error:y.message??"unknown error"}}async deleteFolder(m){const y=await(0,v.AI)().post("/api/storage/deleteFolder",JSON.stringify(m));return y.success?{}:{error:y.message??"unknown error"}}async deleteFile(m){const y=await(0,v.AI)().post(`/api/storage/delete/${m.path}`);return y.success?{}:{error:y.message??"unknown error"}}async delete(m){return m.isFolder?this.deleteFolder({path:m.path,force:!0}):this.deleteFile({path:m.path})}async upload(m,y,$){const h=new FormData;h.append("folder",m),h.append("file",y),h.append("overwriteExistingFile",String($));const b=await fetch("/api/storage/upload",{method:"POST",body:h});let S=await b.json();return S||(S={}),S.status=b.status,S.statusText=b.statusText,b.status!==200&&!S.err&&(S.err=!0),S}async write(m,y){return O.IB.post(`/api/storage/write/${m}`,y)}async getConfig(){return(0,v.AI)().get("/api/storage/config")}async getOptions(m){return(0,v.AI)().get(`/api/storage/options/${m}`)}}function E(V,m){const $=V.toLowerCase().trim();return m.map(b=>b.trim().toLowerCase()).includes($)}let L;function G(){return L||(L=new k),L}}}]);

//# sourceMappingURL=DashboardPageProxy.9a6d60e5cac89c11c71c.js.map