import{ao as n,M as i,ah as u,aQ as B,L as F,a_ as c,aw as f,b9 as _,at as x,c0 as G,by as R,bv as E,aI as d,bb as k,cb as U,c8 as p}from"./app-k0jcl5PQ.js";import{m as C}from"./BUELddOb.chunk.js";const V="_avatar_rpeug_1",M={avatar:V};function H(e){const{imageUrl:t,initials:a}=e,o={};return t&&(o.backgroundImage=`url('${t}')`),n.jsx("div",{className:M.avatar,style:o,children:t?n.jsx(n.Fragment,{children:" "}):a})}const L="_svgContainer_kq46n_1",D="_selection_kq46n_5",P="_expander_kq46n_8",z="_iconContainer_kq46n_14",A="_icon_kq46n_14",Q="_bubble_kq46n_30",W="_spinnerContainer_kq46n_46",J="_remove_kq46n_51",K="_removeBubble_kq46n_60",s={svgContainer:L,selection:D,expander:P,iconContainer:z,icon:A,bubble:Q,spinnerContainer:W,remove:J,removeBubble:K},O=F.encloseNamespace("shared.inputSelection");function X(e){var t;switch(e.typeId){case i.Classroom:return"text-teal-hover";case i.ClassroomGroup:return`text-${C((t=e.metadata)==null?void 0:t.colour)}-hover`}}function $(e){var a;let t=`${s.svgContainer} ${s.icon}`;return e.typeId===i.Classroom?t+=" text-teal":t+=` text-${C((a=e.metadata)==null?void 0:a.colour)}`,t}function Y(e){var o;const t=X(e.selection),a=e.selection.typeId===i.Classroom;if(!e.canExpand){if(!e.selection.typeId||e.selection.typeId===i.User){const r=e.selection;return n.jsx("div",{className:s.svgContainer,children:n.jsx(H,{imageUrl:(o=r.avatar)==null?void 0:o.url,initials:u.getInitials(e.selection.name,e.selection.surname)})})}return n.jsx(B,{title:O(a?"emptyClassroom":"emptyGroup"),children:n.jsx("div",{className:`align-items-center border border-white bg-white ${s.iconContainer}`,children:n.jsx(c,{className:$(e.selection),svg:a?f:_})})})}return e.hasExpanded?n.jsx("div",{className:`d-flex align-items-center text-white ${s.spinnerContainer} ${s.svgContainer}`,children:n.jsx(R,{as:"div",size:"sm",animation:"border",role:"status"})}):n.jsxs(n.Fragment,{children:[n.jsx(x,{className:`align-items-center cursor-pointer text-white border border-white rounded-circle ${s.expander} ${t}`,onClick:e.onClickExpand,children:n.jsx(c,{svg:G,className:`d-flex align-items-center ${s.svgContainer}`})}),n.jsx("div",{className:`align-items-center border border-white bg-white ${s.iconContainer}`,children:n.jsx(c,{className:$(e.selection),svg:a?f:_})})]})}function m(e){var t;if(!e.typeId)return"ultramarine";switch(e.typeId){case i.User:return typeof e.userType=="number"?e.userType===2?"ultramarine":"indigo":e.userType===U.Learner?"ultramarine":"indigo";case i.Classroom:return"teal";case i.ClassroomGroup:return C((t=e.metadata)==null?void 0:t.colour)}}function ne(e){var v,g,h;const t=E.isType(e.selection,i.Classroom),a=E.isType(e.selection,i.ClassroomGroup),o=e.onClickExpand&&(t||a),r=!!((v=e.selection.users||e.selection.enrolments)!=null&&v.count),y=!!((h=(g=e.selection.users)==null?void 0:g.data)!=null&&h.length),[N,S]=d.useState(!1),[I,w]=d.useState(o&&r);d.useEffect(()=>{w(o&&r)},[o,r]);function T(){S(!0),e.onClickExpand(e.selection.id)}if(y){const q=e.selection,l=m(e.selection);return n.jsxs("div",{className:`d-flex align-items-center flex-wrap me-1 mt-1 pb-1 ps-1 pe-4 position-relative border-${l} text-${l} ${s.bubble}`,children:[q.users.data.map(b=>n.jsx(j,{selection:b,colourVariant:l,hasStudentExperience:e.hasStudentExperience},`${b.id}:${e.selection.id}`)),n.jsx(x,{className:`cursor-pointer position-absolute text-${l} ${s.removeBubble}`,onClick:()=>e.onClickRemove(e.selection),children:n.jsx(c,{svg:k,className:`d-flex align-items-center ${s.svgContainer}`})})]})}return n.jsx(j,{selection:e.selection,canExpand:I,hasExpanded:N,onClickExpand:T,onClickRemove:e.onClickRemove,colourVariant:m(e.selection),hasStudentExperience:e.hasStudentExperience})}function j(e){const t=e.colourVariant||m(e.selection);let a=e.selection.name;return e.selection.typeId===i.User&&(a=e.hasStudentExperience?u.getDisplayName(e.selection):u.getFullName(e.selection)),n.jsxs("div",{className:`${s.selection} bg-${t} rounded-pill text-${t} d-flex align-items-center me-1 mt-1 overflow-hidden`,children:[!e.hideExpander&&n.jsx(Y,{canExpand:e.canExpand,hasExpanded:e.hasExpanded,onClickExpand:e.onClickExpand,selection:e.selection}),n.jsx("span",{className:"mx-1 text-white text-truncate",children:a}),p.isFunction(e.onClickRemove)&&n.jsx(x,{className:`d-flex align-items-center cursor-pointer align-self-stretch text-white ${s.remove}`,onClick:()=>e.onClickRemove(e.selection),children:n.jsx(c,{svg:k,className:`d-flex align-items-center ${s.svgContainer}`})})]})}export{ne as I,j as a};
//# sourceMappingURL=CovT_itD.chunk.js.map
