import{C as e,Dt as t,I as n,It as r,Q as i,S as a,T as o,Wt as s,Y as c,bt as l,cn as u,j as d,k as f,mt as p,w as m}from"./_plugin-vue_export-helper-BVhEvvHC.js";import{An as h,ar as g,bn as _,ln as v}from"./src-CD6Jsigc.js";import{r as y,t as b}from"./axios-DSyjHw-i.js";import{m as x}from"./useApi-CROJJdhE-bFLQvr8j.js";import{t as S}from"./EditTeam-Bqx7jfEv.js";n(),l(),s();var C={class:`h-full w-full`},w={key:0,class:`flex h-full w-full items-center justify-center text-muted-foreground`},T={key:1,class:`m-6 flex flex-col gap-4 rounded-md border border-destructive/40 bg-destructive/10 p-4 text-destructive`},E={class:`flex items-start gap-3`},D={class:`space-y-1`},O={class:`font-bold`},k={class:`text-sm`},A=d({__name:`DataTeamsEdit`,setup(n){let{t:s}=y({useScope:`global`}),l=x(),d=0;typeof l.params.id==`string`?d=parseInt(l.params.id):Array.isArray(l.params.id)&&(d=parseInt(l.params.id[0]));let A=t(null),j=t(),M=t([]),N=t(0),P=t(!0),F=t(null);function I(e){return b.isAxiosError(e)?(typeof e.response?.data==`string`?e.response.data:e.message)||s(`team.load.error.description`):e instanceof Error?e.message:s(`team.load.error.description`)}async function L(e){return(await b.get(`teams/${e}`)).data}async function R(e){return(await b.get(`teams/${e}/scores`)).data}async function z(){return(await b.get(`season/current/id`)).data}async function B(){try{return(await b.get(`season`)).data??[]}catch(e){return console.error(`Could not load seasons`,e),[]}}async function V(){P.value=!0,F.value=null;try{let[e,t,n,r]=await Promise.all([z(),L(d),R(d),B()]);N.value=e,A.value=t,j.value=n,M.value=r}catch(e){console.error(e),F.value=I(e)}finally{P.value=!1}}return c(V),(t,n)=>(i(),o(`div`,C,[P.value?(i(),o(`div`,w,[f(r(h),{class:`mr-2 h-5 w-5 animate-spin`}),a(`span`,null,u(r(s)(`team.load.loading`)),1)])):F.value?(i(),o(`div`,T,[a(`div`,E,[f(r(v),{class:`mt-0.5 h-5 w-5 shrink-0`}),a(`div`,D,[a(`p`,O,u(r(s)(`team.load.error.title`)),1),a(`p`,k,u(F.value),1)])]),f(r(g),{class:`w-fit`,variant:`outline`,onClick:V},{default:p(()=>[f(r(_),{class:`h-4 w-4`}),a(`span`,null,u(r(s)(`button.retry`)),1)]),_:1})])):A.value!==null&&j.value!==void 0?(i(),e(S,{key:2,team:A.value,scores:j.value,seasons:M.value,"current-season":N.value},null,8,[`team`,`scores`,`seasons`,`current-season`])):m(``,!0)]))}});export{A as default};