1import{a9 as J,dR as se,ec as fe,X as ie,dW as he,en as ge,e8 as pe,dS as be,dc as t,dd as l,h as ye,P as Z,ed as _e,e7 as Te}from"./index--83fOlxX.js";import{b1 as ae,aq as xe,e as Y,au as Se,p as we,aj as De,C as ne,aE as oe,g as $,as as Ce,ap as Pe,u as ve,s as Ae,A as Re,r as ze,D as Ie}from"./ui-NzJGZCOf.js";import{P as Ee}from"./Page-sZlrZlHc.js";import{H as Oe}from"./HeaderBreadcrumbs-Da2g3DEq.js";import{a as Me,T as Fe,c as Ne}from"./TableRowActionCheckbox-BYpoypk2.js";import{S as ke}from"./Scrollbar-DmvNz4Lf.js";import{u as He,e as qe}from"./useTable-BBkMR8E8.js";import{O as Be}from"./TeamTableRow-2H3i5qbt.js";import{c as We,b as je,f as $e,o as Ke,a as Le,R as Qe,F as Ue}from"./FormProvider-hbZ5gvCG.js";import{D as Ge}from"./DeleteTeamConfirmationDialog-CR8m2CBJ.js";import{u as Ve}from"./UserMetaContext-DqUmMFuh.js";import{t as Xe,n as Ye}from"./teamOnboarding-DawPnPDG.js";import"./media-CfhA99EZ.js";import"./editor-BBDzBLhk.js";import"./auth-Vr3hANQi.js";import"./Breadcrumbs-B2ggCnrY.js";import"./ArrowBack-CUS5WKy0.js";import"./simplebar-react.esm-DfTctRp7.js";import"./index-BX-Rff7I.js";import"./ScrollRootContext-CkNS2d25.js";import"./createAvatar-CSWNX66E.js";import"./UserRoleLabel-Bs--lqtB.js";import"./Label-CJGVkcgn.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]="bfb832c3-a5df-4168-b5f7-32d2da32e00f",e._sentryDebugIdIdentifier="sentry-dbid-bfb832c3-a5df-4168-b5f7-32d2da32e00f")}catch{}})();function Ze(e){return Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.data)?e.data:[]}function Je(){const e=J.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:Ze(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(Xe(s),Ye()).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=$e({resolver:Ke(A),defaultValues:{name:"",addAsAdmin:!0}}),{handleSubmit:K,formState:{isSubmitting:x}}=h;return t(Ie,{fullWidth:!0,maxWidth:"xs",open:e,onClose:a,children:l(Ue,{methods:h,onSubmit:K(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(Le,{name:"name",label:"Team Name"}),t(Qe,{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($,{color:"inherit",size:"small",variant:"outlined",href:Z.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($,{sx:{boxShadow:"none"},variant:"outlined",color:"inherit",onClick:a,children:"Cancel"}),t($,{loading:x,type:"submit",sx:{boxShadow:"none"},variant:"contained",children:"Create Team"})]})]})})};function at(){var ee,te;const e=J.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 K=h;let x;e[1]!==A?(x=n=>{A(Z.settings.team(n))},e[1]=A,e[2]=x):x=e[2];const I=x,g=Je(),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:L,onChangeRowsPerPage:Q}=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:Z.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:()=>K(n),onEditRow:()=>I(n.team_id)},n.team_id)}
1,e[19]=I,e[20]=H):H=e[20];const X=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(Y,{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]!==X||e[35]!==D||e[36]!==P?(q=l(V,{children:[X,D,P]}),e[33]=V,e[34]=X,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]!==L||e[42]!==Q||e[43]!==u||e[44]!==m?(j=t(Y,{sx:B,children:t(Se,{rowsPerPageOptions:W,component:"div",count:z.length,rowsPerPage:m,page:u,onPageChange:L,onRowsPerPageChange:Q})}),e[40]=z.length,e[41]=L,e[42]=Q,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(Y,{sx:{mt:{xs:0,sm:0}},children:t($,{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=J.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-weOJD3lD.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.