{"version":3,"file":"index-CA-fGQdA.js","sources":["../../src/scripts/helpers/eventBus/EventBus.ts","../../src/scripts/helpers/eventBus/index.ts"],"sourcesContent":["declare class EventBus {\n constructor();\n subscribe(\n eventType: string,\n callback: () => void\n ): {\n unsubscribe: () => void;\n };\n publish(eventType: string, arg?: symbol): void;\n}\n\nexport type Subscriptions = {\n [key: string]: {\n [key: symbol]: (arg: symbol) => void;\n };\n};\n\nfunction EventBus() {\n const subscriptions: Subscriptions = {};\n\n const subscribe = (eventType: string, callback: () => void) => {\n const id = Symbol('id');\n if (!subscriptions[eventType]) subscriptions[eventType] = {};\n subscriptions[eventType][id] = callback;\n return {\n unsubscribe: function unsubscribe() {\n delete subscriptions[eventType][id];\n if (Object.getOwnPropertySymbols(subscriptions[eventType]).length === 0) {\n delete subscriptions[eventType];\n }\n }\n };\n };\n\n const publish = (eventType: string, arg: symbol) => {\n if (!subscriptions[eventType]) return;\n Object.getOwnPropertySymbols(subscriptions[eventType]).forEach(key =>\n subscriptions[eventType][key](arg)\n );\n };\n\n return { subscribe, publish };\n}\n\nexport default EventBus;\n","import _EventBus from './EventBus';\n\nexport const EventBus = _EventBus;\nexport const EventBusSingleton = new _EventBus();\n"],"names":["EventBus","subscriptions","eventType","callback","id","arg","key","EventBusSingleton","_EventBus"],"mappings":"AAiBA,SAASA,GAAW,CAClB,MAAMC,EAA+B,CAAC,EAuB/B,MAAA,CAAE,UArBS,CAACC,EAAmBC,IAAyB,CACvD,MAAAC,EAAK,OAAO,IAAI,EAClB,OAACH,EAAcC,CAAS,IAAiBD,EAAAC,CAAS,EAAI,CAAC,GAC7CD,EAAAC,CAAS,EAAEE,CAAE,EAAID,EACxB,CACL,YAAa,UAAuB,CAC3B,OAAAF,EAAcC,CAAS,EAAEE,CAAE,EAC9B,OAAO,sBAAsBH,EAAcC,CAAS,CAAC,EAAE,SAAW,GACpE,OAAOD,EAAcC,CAAS,CAChC,CAEJ,CACF,EASoB,QAPJ,CAACA,EAAmBG,IAAgB,CAC7CJ,EAAcC,CAAS,GAC5B,OAAO,sBAAsBD,EAAcC,CAAS,CAAC,EAAE,WACrDD,EAAcC,CAAS,EAAEI,CAAG,EAAED,CAAG,CACnC,CACF,CAE4B,CAC9B,CCvCa,MAAAE,EAAoB,IAAIC"}