Liferay.Loader.define("@liferay/object-js-components-web@1.0.33/components/Select/MultipleSelect",["module","exports","require","@frontend-taglib-clay$clayui/multi-select","liferay!frontend-js-react-web$react","./BaseSelect","./CheckBoxItem","./index.scss"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.MultipleSelect=function MultipleSelect(e){let{options:t,selectAllOption:r,setOptions:a}=e,i=function _objectWithoutProperties(e,t){if(null==e)return{};var r,n,c=function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,n,c={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(c[r]=e[r]);return c}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(c[r]=e[r])}return c}(e,["options","selectAllOption","setOptions"]);const[u,f]=(0,c.useState)(!1),[s,d]=(0,c.useState)(!1),[p,b]=(0,c.useState)([]);return(0,c.useEffect)((()=>{if(r){let e=!1;const r=t.find((t=>(void 0===t.checked&&(e=!0),void 0!==t.checked&&!t.checked)));e||r||f(!0)}}),[t,r]),(0,c.useEffect)((()=>{const e=t.filter((({checked:e,label:t})=>{if(e)return{label:t}}));e&&b(e)}),[t]),c.default.createElement(o.BaseSelect,_extends({},i,{dropdownActive:s,setDropdownActive:d,trigger:c.default.createElement(n.default,_extends({items:p,onClick:()=>d((e=>!e)),onInput:()=>{},onItemsChange:e=>{!e.length&&f&&f(!1);const r=null==t?void 0:t.map((t=>{const r=e.find((e=>e.label===t.label));return _objectSpread(_objectSpread({},t),{},r?{checked:!0}:{checked:!1})}));r&&a(r)},onKeyDown:e=>e.preventDefault()},i))}),c.default.createElement(c.default.Fragment,null,r&&c.default.createElement(l.CheckboxItem,{checked:u,label:Liferay.Language.get("select-all"),onChange:({target:{checked:e}})=>{a(t.map((t=>_objectSpread(_objectSpread({},t),{},{checked:e})))),f(e)}}),t.map((({checked:e,label:r,value:n},o)=>c.default.createElement(l.CheckboxItem,{checked:e,key:o,label:r,onChange:({target:{checked:e}})=>{a(t.map((t=>t.label===r&&t.value===n?_objectSpread(_objectSpread({},t),{},{checked:e}):t))),e||f(e)}})))))};var n=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(r("@frontend-taglib-clay$clayui/multi-select")),c=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var c in e)if(Object.prototype.hasOwnProperty.call(e,c)){var o=n?Object.getOwnPropertyDescriptor(e,c):null;o&&(o.get||o.set)?Object.defineProperty(r,c,o):r[c]=e[c]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react")),o=r("./BaseSelect"),l=r("./CheckBoxItem");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _extends(){return(_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r("./index.scss")}}));
//# sourceMappingURL=MultipleSelect.js.map