module.exports=[8731,a=>{"use strict";var b=a.i(87924),c=a.i(72131);let d=(0,c.createContext)(null);a.s(["SystemProvider",0,function({children:a}){let[e,f]=(0,c.useState)(null),[g,h]=(0,c.useState)(!1),[i,j]=(0,c.useState)(""),[k,l]=(0,c.useState)(""),m=async a=>{j("");try{let b=a?.length?`/api/system?modules=${a.join(",")}`:"/api/system",c=await fetch(b,{cache:"no-store"}),d=await c.json();if(!c.ok)throw Error(d.error||"Unable to load records");a?.length?f(a=>a?{...a,...d}:d):f(d)}catch(a){j(a instanceof Error?a.message:"Unable to load records")}};(0,c.useEffect)(()=>{m()},[]);let n=async(a,b="Saved")=>{h(!0),j(""),l("");try{let c=await fetch("/api/system",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(a)}),d=await c.json();if(!c.ok)throw Error(d.error||"Unable to save record");let e="string"==typeof a.action?a.action:"";return await m((/^parking-/.test(e)?["parking"]:/^(ticket-|general-cost)/.test(e)?["maintenance-tickets"]:/^announcement/.test(e)?["announcements"]:/^(role-|user-|reminder-)/.test(e)?["users"]:/^(school-|course-)/.test(e)?["schools-courses"]:null)??void 0),l(b),window.setTimeout(()=>l(""),3e3),d}catch(a){return j(a instanceof Error?a.message:"Unable to save record"),null}finally{h(!1)}};return(0,b.jsx)(d.Provider,{value:{data:e,busy:g,error:i,notice:k,load:m,save:n},children:a})},"useSystem",0,function(){let a=(0,c.useContext)(d);if(!a)throw Error("useSystem must be used within a SystemProvider");return a}])}];

//# sourceMappingURL=app_SystemContext_tsx_13iwp3j._.js.map