import{defineProperty as e}from"../../../../../../_virtual/_rollupPluginBabelHelpers.js";import n,{useRef as t,useMemo as o,createRef as r}from"react";import i from"../../../../Chips/Chips.js";import a from"../../../../Flex/Flex.js";import l from"../../../../DialogContentContainer/DialogContentContainer.js";import c from"../../../../Dialog/Dialog.js";import s from"../../../../../hooks/useItemsOverflow/useItemsOverflow.js";import d from"./MultiSelectedValues.module.scss.js";import u from"classnames";import m from"../Trigger/DropdownChip.js";function p(p){var f=p.selectedItems,g=p.onRemove,h=p.renderInput,v=p.disabled,C=p.readOnly,w=t(null),D=t(null),b=o((function(){return f.map((function(){return r()}))}),[f]),y=s({containerRef:w,itemRefs:b,gap:4,deductedSpaceRef:D,minVisibleCount:1===f.length?1:0}),E=y.visibleCount,j=y.hasMeasured,k=o((function(){var e=f.length>E?f.slice(E):[];return{hiddenItems:e,hiddenCount:e.length}}),[f,E]),x=k.hiddenItems,I=k.hiddenCount,N=o((function(){return function(){return n.createElement(l,null,n.createElement(a,{direction:"column",gap:"xs",align:"start",className:d.hiddenChipsDialog},x.map((function(e){return n.createElement(m,{key:"dropdown-chip-dialog-".concat(e.value),item:e,onDelete:function(){return g(e)},className:d.dialogChip,disabled:v,readOnly:C})}))))}}),[x,g,v,C]),O=o((function(){return f.map((function(t,o){var r=E>o;return n.createElement("div",{key:"dropdown-chip-visible-".concat(t.value),ref:b[o],className:u(e({},d.hiddenChip,!r)),"aria-hidden":!r,"data-testid":"dropdown-chip-".concat(t.value)},n.createElement(m,{item:t,onDelete:function(){return g(t)},disabled:v,readOnly:C}))}))}),[f,E,g,b,v,C]);return(null==f?void 0:f.length)?n.createElement(a,{align:"center",wrap:!1,gap:"xs",ref:w,className:u(d.containerWrapper,e(e({},d.singleChip,1===f.length),d.measuring,!j))},O,n.createElement(a,{ref:D,gap:"xs"},I>0&&n.createElement("div",{onClick:function(e){e.stopPropagation()},onKeyDown:function(e){e.stopPropagation()},onMouseDown:function(e){e.stopPropagation()}},n.createElement(c,{content:N,showTrigger:["click","enter"],hideTrigger:["clickoutside","enter"],position:"bottom",moveBy:{main:4},hideWhenReferenceHidden:!0,addKeyboardHideShowTriggersByDefault:!0},n.createElement(i,{label:"+ ".concat(I),readOnly:!0,noMargin:!0,ariaLabel:"+".concat(I,". ").concat(f.length-I," items are visible out of ").concat(f.length),"data-testid":"dropdown-overflow-counter",className:d.overflowCounter,onClick:function(){},onMouseDown:function(e){e.preventDefault()}}))),h&&n.createElement("div",{className:d.inputWrapper},h()))):null}export{p as default};
//# sourceMappingURL=MultiSelectedValues.js.map
