/*! Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one or more contributor license agreements. * Licensed under the Elastic License 2.0; you may not use this file except in compliance with the Elastic License 2.0. */ (window.spaces_bundle_jsonpfunction=window.spaces_bundle_jsonpfunction||[]).push([[10],{151:function(e,s,t){"use strict";t.r(s),t.d(s,"SpaceListInternal",(function(){return b}));var a=t(6),c=t.n(a),n=t(5),i=t(1),l=t(2),o=t(37),u=t(7),p=t(9),r=t(14),j=t(0);const d=Object(i.lazy)((()=>Object(p.a)().then((e=>({default:e}))))),b=({namespaces:e,displayLimit:s=5,behaviorContext:t,listOnClick:a=(()=>{}),cursorStyle:p})=>{const{spacesDataPromise:b}=Object(r.b)(),[x,f]=Object(i.useState)(!1),[O,g]=Object(i.useState)();if(Object(i.useEffect)((()=>{b.then((e=>{g(e)}))}),[b]),!O)return null;const h=e.includes(u.a),m=e.filter((e=>e===u.f)).length;let S,E=null;if(h)S=[{id:u.a,name:l.i18n.translate("xpack.spaces.spaceList.allSpacesLabel",{defaultMessage:"* All spaces"}),initials:"*",color:"#D3DAE6"}];else{const a=e.filter((e=>e!==u.f)),c=[],i=[];a.forEach((e=>{const s=O.spacesMap.get(e);void 0===s?c.push({id:e,name:e}):"outside-space"!==t&&s.isActiveSpace||(s.isFeatureDisabled?i.push(s):c.push(s))}));const l=[...c,...i];S=x||!s?l:l.slice(0,s),s&&l.length>s&&(E=x?Object(j.jsx)(n.EuiButtonEmpty,{size:"xs",onClick:()=>f(!1),style:{alignSelf:"center"}},Object(j.jsx)(o.FormattedMessage,{id:"xpack.spaces.spaceList.showLessSpacesLink",defaultMessage:"show less"})):Object(j.jsx)(n.EuiButtonEmpty,{size:"xs",onClick:()=>f(!0),style:{alignSelf:"center"}},Object(j.jsx)(o.FormattedMessage,{id:"xpack.spaces.spaceList.showMoreSpacesLink",defaultMessage:"+{count} more",values:{count:l.length+m-S.length}})))}const k=!h&&(x||null===E)&&m>0?Object(j.jsx)(n.EuiFlexItem,{grow:!1},Object(j.jsx)(n.EuiToolTip,{content:Object(j.jsx)(o.FormattedMessage,{id:"xpack.spaces.spaceList.unauthorizedSpacesCountLabel",defaultMessage:"You don't have permission to view these spaces."})},Object(j.jsx)(n.EuiBadge,{color:"#DDD"},"+",m))):null,L={style:p?{cursor:p}:void 0};return Object(j.jsx)(i.Suspense,{fallback:Object(j.jsx)(n.EuiLoadingSpinner,null)},Object(j.jsx)(n.EuiFlexGroup,{wrap:!0,responsive:!1,gutterSize:"xs"},S.map((e=>{const s=e.isFeatureDisabled;return Object(j.jsx)(n.EuiFlexItem,{grow:!1,key:e.id},Object(j.jsx)(d,c()({space:e,isDisabled:s,size:"s",onClick:a,onKeyPress:a},L)))})),k,E))}}}]);