import{i as e,o as t}from"./button-DJ30HgDO.js";import{n}from"./use-runtime-config-CkwqDzno.js";var r=()=>({isAuthenticated:n().authenticated}),i=t(e(),1);function a(e){let[t,n]=(0,i.useState)(null),[a,o]=(0,i.useState)(!1),[s,c]=(0,i.useState)(null),{isAuthenticated:l}=r(),u=(0,i.useCallback)(e,[e]);return(0,i.useEffect)(()=>{if(l){let e=new AbortController,t=!1;return(async()=>{o(!0),c(null);try{let r=await u(e.signal);t||n(r)}catch(e){t||(c(e instanceof Error?e:Error(String(e))),n(null))}finally{t||o(!1)}})(),()=>{t=!0,e.abort()}}},[l,u]),{data:t,isLoading:a,error:s,refetch:(0,i.useCallback)(()=>{o(!0),c(null);let t=new AbortController;e(t.signal).then(e=>{n(e)}).catch(e=>{t.signal.aborted||(c(e instanceof Error?e:Error(String(e))),n(null))}).finally(()=>{o(!1)})},[e])}}export{r as n,a as t};