"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/jsx-runtime.js"),o=require("react"),S=require("../../icons/CloseCircleFilled.js"),W=require("../../utils/index.js"),y=require("../Spinner/index.js"),a=require("./styles.js");function I({id:m,className:C,label:t,value:u,variant:p,icon:f,disabled:i=!1,isLoading:n=!1,selected:r=!1,showClose:x=!1,onClick:j,onRemove:d,...c}){const R=a.getChipVariant(p),[E,l]=o.useState(0),s=o.useRef(null);o.useEffect(()=>{s.current&&l(s.current.offsetWidth)},[s,p,r,t]);function q(v){v.stopPropagation(),!i&&!n&&d?d(u||t):j(u||t)}function k(){r&&x||!n&&!i&&j(u||t)}const h=W.getId(c["data-testid"]);return e.jsxRuntimeExports.jsx(R,{id:m||t,className:C||t,ref:s,onClick:k,disabled:i,selected:r,showClose:x,isLoading:n,"data-testid":h(),"data-trackid":c["data-trackid"],"aria-label":c["aria-label"]||t,"aria-selected":r,children:n&&!i?e.jsxRuntimeExports.jsx(a.SpinnerWrapper,{width:E,selected:r,children:e.jsxRuntimeExports.jsx(y.Spinner,{size:"XS",variant:r?"inverse":"secondary"})}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[f&&e.jsxRuntimeExports.jsx(a.IconWrapper,{children:f}),t,r&&x&&e.jsxRuntimeExports.jsx(a.CloseButton,{"aria-label":"close-button",selected:r,disabled:i,onClick:q,"data-testid":h("close-button"),children:e.jsxRuntimeExports.jsx(S.default,{})})]})})}exports.Chip=I;
