import t,{useEffect as e}from"react";import{CortexApi as o}from"../api/CortexApi.js";import n from"../node_modules/lodash/noop.js";const r=t.createContext({context:void 0,setContext:n}),a=async(t,e)=>{if("string"==typeof t&&!t.startsWith("http"))return c(t,e);return await o.proxyFetch(t,e)},c=window.fetch,i=({children:n,monkeyPatchFetch:i=!0})=>{const[s,d]=t.useState(!0),[h,w]=t.useState();return e((()=>{(async()=>{try{const t=await o.getContext();w(t)}finally{d(!1)}})()}),[]),e((()=>(window.rawFetch=c,window.fetch=i?a:c,()=>{window.fetch=c})),[i]),s?null:t.createElement(r.Provider,{value:{context:h,setContext:w}},n)};export{r as PluginContext,i as default};
//# sourceMappingURL=PluginContextProvider.js.map
