import{r as u}from"./react.dcf569d1.js";import{G as c,O as i}from"./index.5fa92bd5.js";import{h}from"./index.a5de5d12.js";let p={},n={};function m(t){const o=h(t);let e=p[o];if(!e||e.expires<Date.now()){const s={pp:-1};t&&(t.type&&(s.type=t.type),t.tags&&(s.tag$=`{${t.tags.join(",")}}`)),e={promise:c().get({path:"/api/v1/current-user/groups",query:s}).then(({items:r})=>(r.forEach(a=>n[a.id]=a.name),r)).catch(r=>(console.debug(`fetchGroups ${String(r)}`),[])),expires:Date.now()+3e6,ob:new i(`Groups:${o}`)},p[o]=e,e.promise.then(r=>{e.ob.$notify("update",r)})}return e}function y(t){const[o,e]=u.exports.useState([]);return u.exports.useEffect(()=>{const s=m(t);return s.promise.then(r=>e(r)),s.ob.$observe("update",r=>e(r))},[t]),o}async function G(t){if(!t)return"";if(t in n)return n[t];try{const{name:o}=await c().get(`/api/v1/group/${t}`);return n[t]=o,o}catch{return""}}export{G as g,y as u};
