Liferay.Loader.define("commerce-frontend-js@4.0.52/components/compare_checkbox/CompareCheckbox",["module","exports","require","@frontend-taglib-clay$clayui/form","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../utilities/eventsDefinitions"],(function(e,t,r){var a;window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=r("@frontend-taglib-clay$clayui/form"),i=((a=r("liferay!frontend-js-react-web$prop-types"))&&a.__esModule,function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var r={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var i=a?Object.getOwnPropertyDescriptor(e,n):null;i&&(i.get||i.set)?Object.defineProperty(r,n,i):r[n]=e[n]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react"))),o=r("../../utilities/eventsDefinitions");function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}function f({disabled:e,inCompare:t,itemId:r,label:a,onUpdate:l,pictureUrl:f}){const[c,d]=(0,i.useState)(t),[u,s]=(0,i.useState)(e),p=(0,i.useCallback)((({disabled:e=!0})=>{s(e),l({disabled:e,inCompare:c})}),[c,l]),b=(0,i.useCallback)((({id:e})=>{e===r&&d((()=>(l({disabled:u,inCompare:false}),false)))}),[u,r,l]);return(0,i.useEffect)((()=>(Liferay.on(o.ITEM_REMOVED_FROM_COMPARE,b),Liferay.on(o.PRODUCT_COMPARISON_TOGGLED,p),()=>{Liferay.detach(o.ITEM_REMOVED_FROM_COMPARE,b),Liferay.detach(o.PRODUCT_COMPARISON_TOGGLED,p)})),[b,p]),i.default.createElement(n.ClayCheckbox,{"aria-label":a,checked:c,className:"compare-checkbox-component",disabled:u&&!c,label:a,onChange:()=>d((e=>(Liferay.fire(o.TOGGLE_ITEM_IN_PRODUCT_COMPARISON,{id:r,thumbnail:f}),!e)))})}f.defaultProps={disabled:!1,inCompare:!1,label:"",onUpdate:()=>{},pictureUrl:""};var c=f;t.default=c}}));
//# sourceMappingURL=CompareCheckbox.js.map