import{r as o,Y as E,c as p,j as i,E as R,a as f,x}from"../assets/ErrorMessage-ZIN41_Pk.js";import{P}from"../assets/PowersList-BKiWwXkD.js";import"../styles.js";const g="Failed to sync with registry. Using cached powers.";function y(){const{callApi:e}=o.useContext(E),[a,s]=o.useState(!0),[t,c]=o.useState([]),[n,u]=o.useState(),m=o.useCallback(async()=>{s(!0);try{const{powers:r}=await e("listRecommendedPowers");c(r)}catch(r){u(r)}finally{s(!1)}},[e]),w=o.useCallback(async()=>{s(!0);try{const{error:r,success:d,usedCachedData:l}=await e("syncKiroRecommendedRepo");if(!d&&l)throw new Error(r)}catch(r){const d=r instanceof Error?r.message:String(r);await e("showMessage","error",d||g)}await m()},[e,m]);return o.useEffect(()=>{w()},[w]),{isLoading:a,recommendedPowers:t,recommendedPowersError:n}}function h(){const e=p.c(5),{isLoading:a,recommendedPowers:s,recommendedPowersError:t}=y();if(t){let n;return e[0]!==t?(n=i.jsx(R,{error:t}),e[0]=t,e[1]=n):n=e[1],n}let c;return e[2]!==a||e[3]!==s?(c=!a&&i.jsx(P,{powers:s}),e[2]=a,e[3]=s,e[4]=c):c=e[4],c}f.createRoot(document.getElementById("root")).render(i.jsx(o.StrictMode,{children:i.jsx(x,{editorApi:window.vscode,children:i.jsx(h,{})})}));
