"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[1804],{21837(H,y,e){e.d(y,{l:()=>u});var l=e(16111),D=e(67055),L=e(5989),f=e(22361),d=e(29318),S=e(4376),g=e(62139),A=e(81917),v=e(22762),P=e(19500),o=e(51795),K,p,F,C,U;async function M(t){if(!K().getBooleanValue(p.PluginsUseMTPluginSettings,!1))return n(t,!1);const a=await F(t);if(!a)return C("PluginSettings: falling back to refetching legacy plugin settings",{pluginId:t}),n(t,!1);if(a.spec.pluginJson.type!=="app")return U()(a.spec);const i=await r(t,!1);return U()(a.spec,i)}const n=(0,f.hH)(P.hy,{invalidate:!0,cacheKeyFn:o.nb}),r=(0,f.hH)(P.U7,{invalidate:!0,cacheKeyFn:o.et});function s(t,a){return(0,g.oW)("PluginSettings: updating legacy plugin settings",{pluginId:t}),(0,d.AI)().post(`/api/plugins/${t}/settings`,a,{validatePath:!0}).catch(i=>((0,g.bG)("PluginSettings: updating legacy plugin settings failed",i,{pluginId:t}),Promise.reject(i)))}async function c(t,a){const i=(0,v.yf)(a),h=(0,v.Qo)(a),m={apiVersion:`${t}/${(0,o.L0)()}`,kind:"Settings",spec:i,secure:h},{metadata:V,...$}=await r(t,!1),T=[{op:"test",path:"/metadata/resourceVersion",value:V.resourceVersion},...(0,l.UD)($,m)];return(0,g.oW)("PluginSettings: updating plugin settings",{pluginId:t}),await(0,d.AI)().patch(`/apis/${t}/${(0,o.L0)()}/namespaces/${(0,o.U)()}/app/instance`,T,{validatePath:!0,headers:{"Content-Type":"application/json-patch+json"}}).catch(j=>((0,g.bG)("PluginSettings: updating plugin settings failed",j,{pluginId:t}),Promise.reject(j)))}async function u(t,a){if(!(0,D.Y)().getBooleanValue(L.ZJ.PluginsUseMTPluginSettings,!1))return await s(t,a),n(t,!1);const i=await(0,S.E2)(t);if(!i)return(0,g.oW)("PluginSettings: falling back to updating legacy plugin settings",{pluginId:t}),await s(t,a),n(t,!1);if(i.spec.pluginJson.type!=="app")return(0,A.T)()(i.spec);const h=await c(t,a),m=(0,o.et)(t);return(0,f.ih)(m,h),(0,A.T)()(i.spec,h)}},41804(H,y,e){e.r(y),e.d(y,{clearLoggerRegistry:()=>l.lQ,defineFeatureEvents:()=>D.v,getDataSourceInstance:()=>g.Hf,getDataSourceInstanceSettings:()=>S.oN,getLogger:()=>l.tZ,getPluginSettings:()=>L.xA,initializeLoggersRegistry:()=>l.r_,registerRuntimeDataSourceInstance:()=>g.mz,reloadDataSourceInstanceSettings:()=>S.H4,setLogger:()=>l.Br,updateAppPluginSettings:()=>f.l,useDataSourceInstance:()=>M,useDataSourceInstanceSettings:()=>C,usePluginSettings:()=>d.U});var l=e(36755),D=e(75398),L=e(19500),f=e(21837),d=e(63446),S=e(74304),g=e(93480),A=e(55501),v=e(16817),P,o,K;function p(n){return JSON.stringify(n??null)}function F(n){if(!n)return p(null);const{filter:r,...s}=n;return p(s)}function C(n){const r=p(n),{loading:s,error:c,value:u}=(0,v.A)(()=>(0,S.oN)(n),[r]);return{isLoading:s,error:c,settings:u}}function U(n){const r=F(n),s=n?.filter,c=P(()=>s?Date.now():null,[s]),{loading:u,error:t,value:a}=o(()=>K(n),[r,c]);return{isLoading:u,error:t,items:a??[]}}function M(n){const r=p(n),{loading:s,error:c,value:u}=(0,v.A)(()=>(0,g.Hf)(n),[r]);return{isLoading:s,error:c,dataSource:u}}}}]);

//# sourceMappingURL=1804-react19.638faddbe8ef82e5be7b.js.map