"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[2859,2976,9136],{6857:(T,d,a)=>{a.d(d,{EmbeddedDashboard:()=>v});var s=a(74848),r=a(22803),e=a(96540),M=a(93407),o=a(60),E=a(37e3),l=a(20968),f=a(29675),c=a(11817),O=a(44608),h=a(61491),D=a(44172);function v(t){const n=(0,D.sP)(),{dashboard:_,loadError:P}=n.useState();return(0,e.useEffect)(()=>(n.loadDashboard({uid:t.uid,route:h.DashboardRoutes.Embedded}),()=>{n.clearState()}),[n,t.uid]),P?(0,s.jsx)(E.F,{severity:"error",title:(0,c.t)("dashboard.errors.failed-to-load","Failed to load dashboard"),children:(0,O.q6)(P)}):_?(0,s.jsx)(A,{model:_,...t}):(0,s.jsx)(l.y,{})}function A({model:t,initialState:n,onStateChange:_}){const[P,m]=(0,e.useState)(!1),{controls:i,body:u}=t.useState(),g=(0,f.of)(U);return(0,e.useEffect)(()=>{if(m(!0),n){const I=new URLSearchParams(n);o.Go.syncStateFromSearchParams(t,I)}return t.activate()},[t]),C(_,t),P?(0,s.jsxs)("div",{className:(0,r.cx)(g.canvas,i&&g.canvasWithControls),children:[i&&(0,s.jsx)("div",{className:g.controlsWrapper,children:(0,s.jsx)(i.Component,{model:i})}),(0,s.jsx)("div",{className:g.body,children:(0,s.jsx)(u.Component,{model:u})})]}):null}function C(t,n){(0,e.useEffect)(()=>{if(!t)return;let _="";const P=n.subscribeToEvent(o.bZ,m=>{if(m.payload.changedObject.urlSync){const i=o.Go.getUrlState(n),u=M.kM.renderUrl("",i);_!==u&&(_=u,t(u))}});return()=>P.unsubscribe()},[n,t])}function U(t){return{canvas:(0,r.css)({label:"canvas-content",display:"grid",gridTemplateAreas:`
        "panels"`,gridTemplateColumns:"1fr",gridTemplateRows:"1fr",flexBasis:"100%",flexGrow:1}),canvasWithControls:(0,r.css)({gridTemplateAreas:`
        "controls"
        "panels"`,gridTemplateRows:"auto 1fr"}),body:(0,r.css)({label:"body",flexGrow:1,display:"flex",gap:"8px",gridArea:"panels",marginBottom:t.spacing(2)}),controlsWrapper:(0,r.css)({display:"flex",flexDirection:"column",flexGrow:0,gridArea:"controls",padding:t.spacing(2,0,2,2)})}}},26088:(T,d,a)=>{a.r(d),a.d(d,{EmbeddedDashboardTestPage:()=>l,default:()=>f});var s=a(74848),r=a(96540),e=a(80426),M=a(90231),o=a(54122),E=a(6857);function l(){const[c,O]=(0,r.useState)("?from=now-5m&to=now");return(0,s.jsxs)(o.Y,{navId:"dashboards/browse",pageNav:{text:"Embedding dashboard",subTitle:"Showing dashboard: Panel Tests - Pie chart"},layout:e.k.Canvas,children:[(0,s.jsxs)(M.a,{paddingY:2,children:["Internal url state: ",c]}),(0,s.jsx)(E.EmbeddedDashboard,{uid:"lVE-2YFMz",initialState:c,onStateChange:O})]})}const f=l},3824:(T,d,a)=>{a.r(d),a.d(d,{default:()=>c});var s=a(74848),r=a(96540),e=a(54148),M=a(98437),o=a(53027),E=a(54122),l=a(61491),f=a(86983);function c(){const[O,h]=(0,r.useState)(null),{datasourceUid:D}=(0,e.g)(),v=(0,l.useDispatch)();return(0,r.useEffect)(()=>{if(!(0,M.l)().getInstanceSettings(D)){h("Data source not found");return}v((0,f.Ub)(D)),o.Ny.replace("/dashboard/new")},[D,v]),O?(0,s.jsx)(E.Y,{navId:"dashboards",children:(0,s.jsx)(E.Y.Contents,{children:(0,s.jsxs)("div",{children:['Data source with UID "',D,'" not found.']})})}):null}}}]);

//# sourceMappingURL=DashboardPage.0492fcae259f72e4a5ea.js.map