Liferay.Loader.define("commerce-frontend-js@4.0.75/utilities/hooks",["module","exports","require","@frontend-taglib-clay$clayui/loading-indicator","liferay!frontend-js-react-web$react","../components/add_to_cart/constants","./cookies","./eventsDefinitions","./modules"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.useLiferayModule=function useLiferayModule(e,t=o.default){const[n,a]=(0,r.useState)(e?t:null);return(0,r.useEffect)((()=>{e&&(0,c.getComponentByModuleUrl)(e).then((e=>{a((()=>e))}))}),[e]),n},t.useCommerceAccount=function useCommerceAccount(e){const[t,n]=(0,r.useState)(e);return(0,r.useEffect)((()=>{function handleAccountUpdate(e){t.id!==e.id&&n(e)}return Liferay.on(d.CURRENT_ACCOUNT_UPDATED,handleAccountUpdate),()=>{Liferay.detach(d.CURRENT_ACCOUNT_UPDATED,handleAccountUpdate)}}),[t]),t},t.useCommerceCart=function useCommerceCart(t,n){const[o,a]=(0,r.useState)(t);return(0,r.useEffect)((()=>{function handleOrderUpdate({order:t}){o.id!==t.id&&(a(t),n&&t.orderUUID&&e.setValue(n,t.orderUUID))}return Liferay.on(d.CURRENT_ORDER_UPDATED,handleOrderUpdate),()=>{Liferay.detach(d.CURRENT_ORDER_UPDATED,handleOrderUpdate)}}),[o,n]),o};var o=_interopRequireDefault(n("@frontend-taglib-clay$clayui/loading-indicator")),r=n("liferay!frontend-js-react-web$react"),a=n("../components/add_to_cart/constants"),u=_interopRequireDefault(n("./cookies")),d=n("./eventsDefinitions"),c=n("./modules");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const e=new u.default(a.GUEST_COMMERCE_ORDER_COOKIE_IDENTIFIER)}}));
//# sourceMappingURL=hooks.js.map