{
  "version": 3,
  "sources": ["../../src/utils/ComponentFactory.ts"],
  "sourcesContent": ["import { UITagsEnum } from 'constants/UITags.enum';\nimport { safeWindow } from 'constants/window.constants';\nimport type { IEventBus } from 'lib/sdkDappUi';\n\nexport interface CreateEventBusUIElementType extends HTMLElement {\n  getEventBus: () => Promise<IEventBus | null>;\n}\n\nexport type CreateComponentType = <T = CreateEventBusUIElementType>({\n  name,\n  anchor\n}: {\n  name: `${UITagsEnum}`;\n  anchor?: HTMLElement;\n}) => Promise<T>;\n\nexport class ComponentFactory {\n  private static createComponent: CreateComponentType = async <\n    T = CreateEventBusUIElementType\n  >({\n    name,\n    anchor\n  }: {\n    name: `${UITagsEnum}`;\n    anchor?: HTMLElement;\n  }) => {\n    const webComponent = safeWindow?.customElements?.get(name);\n\n    if (!webComponent) {\n      return null as T;\n    }\n\n    const element = safeWindow.document.createElement(name);\n    const rootElement = anchor || safeWindow.document.body;\n    rootElement.appendChild(element);\n    await customElements.whenDefined(name);\n\n    return element as T;\n  };\n\n  static get create() {\n    return this.createComponent;\n  }\n\n  static set create(customCreateFunction: CreateComponentType) {\n    this.createComponent = customCreateFunction;\n  }\n}\n"],
  "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAA2B,sCAepB,MAAMF,CAAiB,CAwB5B,WAAW,QAAS,CAClB,OAAO,KAAK,eACd,CAEA,WAAW,OAAOG,EAA2C,CAC3D,KAAK,gBAAkBA,CACzB,CACF,CA/BaH,EACI,gBAAuC,MAEpD,CACA,KAAAI,EACA,OAAAC,CACF,IAGM,CAGJ,GAAI,CAFiB,cAAY,gBAAgB,IAAID,CAAI,EAGvD,OAAO,KAGT,MAAME,EAAU,aAAW,SAAS,cAAcF,CAAI,EAEtD,OADoBC,GAAU,aAAW,SAAS,MACtC,YAAYC,CAAO,EAC/B,MAAM,eAAe,YAAYF,CAAI,EAE9BE,CACT",
  "names": ["ComponentFactory_exports", "__export", "ComponentFactory", "__toCommonJS", "import_window", "customCreateFunction", "name", "anchor", "element"]
}
