{"version":3,"file":"static/js/65822.fc1c93e5.chunk.js","mappings":"+JAsBO,MAAMA,EAAc,SACzBC,GAEI,IADJC,EAAWC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,GA0Bd,OAxBAG,EAAAA,EAAAA,kBAAgB,KAEPC,EAAAA,EAAAA,IAAaN,IAoBnBC,GAEI,CAELM,UACF,KACF,C","sources":["newhooks/generic/useEventbus.tsx"],"sourcesContent":["import { useLayoutEffect } from 'react';\nimport type {\n TUseEventBusKey,\n TUseEventbusProps\n} from 'utils/generic/event-bus';\nimport { fireEvent, initEventBus } from 'utils/generic/event-bus';\n\n// event type in order to (listen to) or (fire) // Here we can use any type for payload\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\nexport enum CasinoEvent {\n CasinoGamesRendered = 'CasinoGamesRendered'\n}\n\n/**\n * Hook allows fire and list events between components\n * @param events - events is object with subscribed callbacks where key is eventName, fire on Subject Observable subscribed event\n * @param deps - dependencies for onEvent\n * @returns Function (fireEvent callback)\n */\n// Here we can use any type for dependencies\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const useEventbus = (\n events?: TUseEventbusProps,\n deps: any[] = []\n) => {\n useLayoutEffect(() => {\n // skip useEffect if onEvent is empty\n return initEventBus(events);\n\n // console.log('subscribe', events);\n //\n // if (!events || !Object.values(events).length) {\n // return;\n // }\n //\n // // subscribe to the Subject Observable\n // const subscription = eventbusSubject.subscribe(({ key, id, payload }) => {\n // events[key as keyof TUseEventbusProps]?.(\n // id,\n // payload\n // );\n // });\n //\n // // we should unsubscribe after component's unmount to remove extra subscribes\n // return () => {\n // subscription.unsubscribe();\n // };\n }, deps);\n\n return {\n // on fireEvent, we should push the event into the eventbus subject's observer\n fireEvent\n };\n};\n\n// import { useEffect, useId, useLayoutEffect } from 'react';\n//\n// import {\n// fireEvent,\n// initEventBus,\n// TUseEventbusProps,\n// EVENT_BUS_LOCAL_STORE\n// } from 'utils/generic/event-bus';\n//\n// export enum CasinoEvent {\n// CasinoGamesRendered = 'CasinoGamesRendered'\n// }\n//\n// /**\n// * Hook allows fire and list events between components\n// * @param events - events is object with subscribed callbacks where key is eventName, fire on Subject Observable subscribed event\n// * @param deps - dependencies for onEvent\n// * @returns Function (fireEvent callback)\n// */\n// // Here we can use any type for dependencies\n// // eslint-disable-next-line @typescript-eslint/no-explicit-any\n// export const useEventbus = (\n// events?: TUseEventbusProps,\n// deps: any[] = []\n// ) => {\n// useLayoutEffect(() => {\n// return initEventBus(events);\n// }, [deps]);\n// // const id = useRef(ridGenerator.gCustom());\n//\n// // const id = useId();\n// //\n// // const isAlreadyRegistered = id in EVENT_BUS_LOCAL_STORE;\n// // const isDependencyChanged = isAlreadyRegistered\n// // ? JSON.stringify(deps) !== JSON.stringify(EVENT_BUS_LOCAL_STORE[id].deps)\n// // : false;\n//\n// // if (!isAlreadyRegistered || isDependencyChanged) {\n// // if (isAlreadyRegistered) {\n// // EVENT_BUS_LOCAL_STORE[id]?.clean();\n// // delete EVENT_BUS_LOCAL_STORE[id];\n// // }\n// //\n// // const clean = initEventBus(events);\n// //\n// // if (typeof clean === 'function') {\n// // console.log('register');\n// //\n// // EVENT_BUS_LOCAL_STORE[id] = { deps, clean };\n// // }\n// // }\n// //\n// // useEffect(() => {\n// // return () => {\n// // console.log('unrgister');\n// // EVENT_BUS_LOCAL_STORE[id]?.clean();\n// // delete EVENT_BUS_LOCAL_STORE[id];\n// // };\n// // }, []);\n//\n// return {\n// // on fireEvent, we should push the event into the eventbus subject's observer\n// fireEvent\n// };\n// };\n"],"names":["useEventbus","events","deps","arguments","length","undefined","useLayoutEffect","initEventBus","fireEvent"],"sourceRoot":""}