1import{a8 as X,dQ as se,eb as fe,W as ie,dV as he,em as ge,e7 as pe,dR as be,db as t,dc as l,h as ye,P as J,ec as _e,e6 as Te}from"./index-CmSfgMPc.js";import{b1 as ae,aq as xe,e as Z,au as Se,p as we,aj as De,C as ne,aE as oe,g as Q,as as Ce,ap as Pe,u as ve,s as Ae,A as Re,r as ze,D as Ie}from"./ui-u4xJzAJX.js";import{P as Ee}from"./Page-DJs2_DnW.js";import{H as Oe}from"./HeaderBreadcrumbs-C37Lb678.js";import{a as Me,T as Fe,c as Ne}from"./TableRowActionCheckbox-bF_IpQeh.js";import{S as ke}from"./Scrollbar-Cgp18_Bb.js";import{u as He,e as qe}from"./useTable-D_wBxHhD.js";import{O as Be}from"./TeamTableRow-l-npqMgb.js";import{c as We,b as je,f as Qe,o as $e,a as Ke,R as Le,F as Ue}from"./FormProvider-DnDUJPhm.js";import{D as Ge}from"./DeleteTeamConfirmationDialog-CKqprD3q.js";import{u as Ve}from"./UserMetaContext-BTaeNtT8.js";import{t as Ye,n as Ze}from"./teamOnboarding-BcJyiWig.js";import"./media-UejkmJrh.js";import"./editor-WYCba1gG.js";import"./auth-CAQqEDmo.js";import"./Breadcrumbs-DLl0Yyid.js";import"./ArrowBack-DW5Rw6nZ.js";import"./simplebar-react.esm-BEXqbx-c.js";import"./index-DTVaLiQt.js";import"./ScrollRootContext-D4rEBX8N.js";import"./createAvatar-CgGTnP9k.js";import"./UserRoleLabel-Du0SWkPB.js";import"./Label-CRbSig1w.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new e.Error().stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="dd09cd5c-00e0-45fd-a952-2391fc2f9c65",e._sentryDebugIdIdentifier="sentry-dbid-dd09cd5c-00e0-45fd-a952-2391fc2f9c65")}catch{}})();function Je(e){return Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.data)?e.data:[]}function Xe(){const e=X.c(3),{user:a}=se();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=["organizations"],e[0]=i):i=e[0];let o;return e[1]!==a?(o={queryKey:i,queryFn:async()=>{const c=await ie.get(`/user/${a.db_user_id}/organizations`);return{data:Je(c.data)}}},e[1]=a,e[2]=o):o=e[2],fe(o)}const et=[{id:"name",label:"Team",align:"left"},{id:"organization_name",label:"Organization",align:"left"},{id:"coach_count",label:"Coaches",align:"left"},{id:"player_count",label:"players",align:"left"},{id:"role_name",label:"My role",align:"left"},{id:""}],tt=({open:e,close:a,organizationId:i})=>{var g,p,b,S,y,R;const o=_e(),{user:d}=se(),{setUserMeta:c}=Ve(),f=Te({mutationFn:r=>ie.post("/team",r),onSuccess:r=>{var _;const s=(_=r.data)==null?void 0:_.team_id;s!=null&&c(Ye(s),Ze()).catch(T=>{console.error("Could not activate team onboarding",T)}),o.invalidateQueries({queryKey:["organization_teams"]}),o.invalidateQueries({queryKey:[d==null?void 0:d.db_user_id,"available_teams"]}),a()}}),A=We().shape({name:je().required("Team name is required")}),h=Qe({resolver:$e(A),defaultValues:{name:"",addAsAdmin:!0}}),{handleSubmit:$,formState:{isSubmitting:x}}=h;return t(Ie,{fullWidth:!0,maxWidth:"xs",open:e,onClose:a,children:l(Ue,{methods:h,onSubmit:$(async r=>{try{await f.mutateAsync({...r,organizationId:i,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone??null})}catch(s){console.error(s)}}),children:[t(ve,{children:"Create New Team"}),l(Ae,{dividers:!0,children:[t(Ke,{name:"name",label:"Team Name"}),t(Le,{name:"addAsAdmin",label:"Add your account as team admin"})," ",f.isError&&t(Re,{severity:"error",sx:{mt:2},action:((b=(p=(g=f.error)==null?void 0:g.response)==null?void 0:p.data)==null?void 0:b.code)==="TEAM_LIMIT"?t(Q,{color:"inherit",size:"small",variant:"outlined",href:J.pickSubscription,children:"Upgrade"}):void 0,children:((R=(y=(S=f.error)==null?void 0:S.response)==null?void 0:y.data)==null?void 0:R.error)??"Something went wrong. Please try again."})]}),l(ze,{children:[t(Q,{sx:{boxShadow:"none"},variant:"outlined",color:"inherit",onClick:a,children:"Cancel"}),t(Q,{loading:x,type:"submit",sx:{boxShadow:"none"},variant:"contained",children:"Create Team"})]})]})})};function at(){var ee,te;const e=X.c(46),[a,i]=ae.useState(!1),[o,d]=ae.useState(!1),{checkPermissions:c}=he(),{themeStretch:f}=ge(),A=pe();let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n=>{i(n)},e[0]=h):h=e[0];const $=h;let x;e[1]!==A?(x=n=>{A(J.settings.team(n))},e[1]=A,e[2]=x):x=e[2];const I=x,g=Xe(),p=(ee=g==null?void 0:g.data)==null?void 0:ee.data;let b;e[3]!==p?(b=Array.isArray(p)?p:[],e[3]=p,e[4]=b):b=e[4];const S=b,y=be(),R=((te=y==null?void 0:y.data)==null?void 0:te.data)??[];let r;if(e[5]!==c||e[6]!==S){let n;e[8]!==c?(n=(v,ue)=>v||c({organizationId:ue.organization_id,permissions:["EDIT_ORG"]})||v,e[8]=c,e[9]=n):n=e[9],r=S.reduce(n,!1),e[5]=c,e[6]=S,e[7]=r}else r=e[7];const s=r,_=s==null?void 0:s.organization_id,T=R;let E;e[10]===Symbol.for("react.memo_cache_sentinel")?(E={defaultOrderBy:"role_name",defaultRowsPerPage:20},e[10]=E):E=e[10];const{page:u,order:re,orderBy:le,rowsPerPage:m,selected:ce,onSort:me,onChangePage:K,onChangeRowsPerPage:L}=He(E),z=T,de=52,U=z.length===0,G=g.isPending||y.isPending;let O;e[11]!==_||e[12]!==o?(O=o&&_!=null&&t(tt,{organizationId:_,open:o,close:()=>{d(!1)}}),e[11]=_,e[12]=o,e[13]=O):O=e[13];let M;e[14]!==a?(M=a&&t(Ge,{team:a,open:a,close:()=>{i(!1)}}),e[14]=a,e[15]=M):M=e[15];let F;e[16]===Symbol.for("react.memo_cache_sentinel")?(F=t(Oe,{heading:"Teams",links:[{name:"Settings",href:J.settings.teams},{name:"Teams"}]}),e[16]=F):F=e[16];let N;e[17]===Symbol.for("react.memo_cache_sentinel")?(N={maxWidth:800},e[17]=N):N=e[17];let k;e[18]===Symbol.for("react.memo_cache_sentinel")?(k={position:"relative"},e[18]=k):k=e[18];const V=xe;let H;e[19]!==I?(H=n=>{var v;return t(Be,{row:n,canManage:((v=n.permissions)==null?void 0:v.some(nt))??!1,onDeleteRow:()=>$(n),onEditRow:()=>I(n.team_id)},n.team_id)}
1,e[19]=I,e[20]=H):H=e[20];const Y=z.slice(u*m,u*m+m).map(H);let w;e[21]!==u||e[22]!==m||e[23]!==T.length?(w=qe(u,m,T.length),e[21]=u,e[22]=m,e[23]=T.length,e[24]=w):w=e[24];let D;e[25]!==w?(D=t(Fe,{height:de,emptyRows:w}),e[25]=w,e[26]=D):D=e[26];let C;e[27]!==s?(C=s?t(Z,{onClick:()=>{d(!0)},sx:{cursor:"pointer"},children:"Create your first team"}):"No teams found *",e[27]=s,e[28]=C):C=e[28];let P;e[29]!==U||e[30]!==G||e[31]!==C?(P=t(Ne,{isLoading:G,isNotFound:U,title:C}),e[29]=U,e[30]=G,e[31]=C,e[32]=P):P=e[32];let q;e[33]!==V||e[34]!==Y||e[35]!==D||e[36]!==P?(q=l(V,{children:[Y,D,P]}),e[33]=V,e[34]=Y,e[35]=D,e[36]=P,e[37]=q):q=e[37];let B;e[38]===Symbol.for("react.memo_cache_sentinel")?(B={position:"relative"},e[38]=B):B=e[38];let W;e[39]===Symbol.for("react.memo_cache_sentinel")?(W=[20,100,500],e[39]=W):W=e[39];let j;return e[40]!==z.length||e[41]!==K||e[42]!==L||e[43]!==u||e[44]!==m?(j=t(Z,{sx:B,children:t(Se,{rowsPerPageOptions:W,component:"div",count:z.length,rowsPerPage:m,page:u,onPageChange:K,onRowsPerPageChange:L})}),e[40]=z.length,e[41]=K,e[42]=L,e[43]=u,e[44]=m,e[45]=j):j=e[45],l(Ee,{title:"Teams",children:[O,M,l(we,{maxWidth:f?!1:"lg",children:[F,s&&l(De,{sx:{mb:4,maxWidth:800},direction:{xs:"column",sm:"row"},alignItems:{sm:"flex-end"},justifyContent:{sm:"space-between"},spacing:2,children:[l(ne,{sx:{color:it,bgcolor:st,boxShadow:"none",flex:1,width:"100%",maxWidth:{sm:200},px:3,py:2},children:[t(oe,{sx:ot,variant:"subtitle2",children:"Your Teams"}),t(oe,{variant:"h5",children:R.length})]}),t(Z,{sx:{mt:{xs:0,sm:0}},children:t(Q,{variant:"contained",onClick:()=>d(!0),startIcon:t(ye,{icon:"eva:plus-circle-outline"}),sx:{boxShadow:"none"},children:"Create New Team"})})]}),l(ne,{sx:N,children:[t(ke,{children:t(Ce,{sx:k,children:l(Pe,{size:"small",children:[t(Me,{order:re,orderBy:le,headLabel:et,rowCount:T.length,numSelected:ce.length,onSort:me}),q]})})}),j]})]})]})}function nt(e){return["EDIT_TEAM","EDIT_ORG"].includes(e.permission_name)}function ot(e){return{color:e.palette.grey[600],mb:1}}function st(e){return e.palette.grey[100]}function it(e){return e.palette.grey[800]}function It(){const e=X.c(1);let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=t(at,{}),e[0]=a):a=e[0],a}export{It as default}; 2//# sourceMappingURL=_auth.dashboard.settings.teams._index-9aMA_lbO.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.