"use strict";var e=require("@babel/runtime/helpers/slicedToArray"),t=require("react"),r=require("prop-types"),i=require("@material-ui/core"),n=require("react/jsx-runtime");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=a(e),s=a(r),u=i.makeStyles({checkBox:{color:"grey",paddingLeft:0},formControl:{width:function(e){return e.size}},listItemPrimaryText:{color:"#fff"},paper:{backgroundColor:"#414141"}});function c(e){var r=e.options,a=e.currentValues,s=e.title,c=e.size,o=e.renderValue,d=e.onChange,f=t.useState([]),m=l.default(f,2),p=m[0],x=m[1],h=t.useState(!1),y=l.default(h,2),g=y[0],j=y[1],q=t.useState(!1),k=l.default(q,2),C=k[0],v=k[1],b=u({size:c});t.useEffect((function(){x(a.filter((function(e){return r.includes(e)})))}),[a,r]);return n.jsxs(i.FormControl,{className:b.formControl,children:[n.jsx(i.InputLabel,{shrink:!0,htmlFor:"c-owp-multi-select-".concat(s),children:s}),n.jsxs(i.Select,{className:b.select,MenuProps:{classes:{paper:b.paper}},multiple:!0,displayEmpty:!0,fullWidth:!0,value:p,inputProps:{name:"c-owp-multi-select-".concat(s),id:"c-owp-multi-select-".concat(s)},renderValue:function(e){return o(e.length)},open:g,onOpen:function(){j(!0),v(!1)},onClose:function(){j(!1),C&&d(p),v(!1)},onChange:function(e){var t=e.target.value;x(t.includes("all")?[]:t),v(!0)},children:[n.jsxs(i.MenuItem,{value:"all",children:[n.jsx(i.Checkbox,{checked:!0,indeterminate:p.length>0,className:b.checkBox}),n.jsx(i.ListItemText,{primary:o(0),classes:{primary:b.listItemPrimaryText}})]},"all"),n.jsx(i.Divider,{}),r.map((function(e){return n.jsxs(i.MenuItem,{value:e,children:[n.jsx(i.Checkbox,{checked:p.indexOf(e)>-1,className:b.checkBox}),n.jsx(i.ListItemText,{primary:e,classes:{primary:b.listItemPrimaryText}})]},e)}))]})]})}c.propTypes={options:s.default.arrayOf(s.default.string).isRequired,currentValues:s.default.arrayOf(s.default.string).isRequired,title:s.default.string.isRequired,size:s.default.number.isRequired,renderValue:s.default.func.isRequired,onChange:s.default.func.isRequired},module.exports=c;
//# sourceMappingURL=MultiSelect.js.map
