Liferay.Loader.define("@liferay/fragment-collection-filter-category@1.0.26/js/SelectCategory.es",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/drop-down","@liferay/fragment-renderer-collection-filter-impl","frontend-js-web","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function SelectCategory({assetCategories:e,enableDropdown:t,fragmentEntryLinkId:r,showSearch:c,singleSelection:u=!1}){const[f,d]=(0,i.useState)((()=>{const e=(0,n.getCollectionFilterValue)("category",r);return Array.isArray(e)?e:e?[e]:[]})),[s,y]=(0,i.useState)(e),[g,p]=(0,i.useState)(""),[b,m]=(0,i.useState)(!1);(0,i.useEffect)((()=>{y(g?e.filter((e=>-1!==e.label.toLowerCase().indexOf(g.toLowerCase()))):e)}),[g,e]);const onSelectedClick=(e,t)=>{e&&u?((0,n.setCollectionFilterValue)("category",r,[t]),d([t])):d(e?[...f,t]:f.filter((e=>e!==t)))},h=u?[{items:s.map((e=>({label:e.label,type:"radio",value:e.id}))),name:"categoryId",onChange:e=>onSelectedClick(!0,e),type:"radiogroup",value:null==f?void 0:f[0]}]:s.map((e=>({checked:f.includes(e.id),label:e.label,onChange:t=>onSelectedClick(t,e.id),type:"checkbox"})));let w=Liferay.Language.get("select");var C;1===f.length?w=(null===(C=e.find((e=>f[0]===e.id)))||void 0===C?void 0:C.label)||w:f.length>1&&(w=(0,o.sub)(Liferay.Language.get("x-selected"),f.length));return i.default.createElement(l.ClayDropDownWithItems,{active:b,footerContent:u?null:i.default.createElement(a.default,{onClick:()=>(0,n.setCollectionFilterValue)("category",r,f),size:"sm"},Liferay.Language.get("apply")),items:h,onActiveChange:e=>{m(!!t&&e)},onSearchValueChange:p,searchValue:g,searchable:c,trigger:i.default.createElement("button",{className:"form-control form-control-select form-control-sm text-left w-100"},w)})};var a=_interopRequireDefault(r("@frontend-taglib-clay$clayui/button")),l=r("@frontend-taglib-clay$clayui/drop-down"),n=r("@liferay/fragment-renderer-collection-filter-impl"),o=r("frontend-js-web"),i=(_interopRequireDefault(r("liferay!frontend-js-react-web$prop-types")),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={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in e)if(Object.prototype.hasOwnProperty.call(e,l)){var n=a?Object.getOwnPropertyDescriptor(e,l):null;n&&(n.get||n.set)?Object.defineProperty(r,l,n):r[l]=e[l]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react")));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}}}));
//# sourceMappingURL=SelectCategory.es.js.map