{"version":3,"file":"index.mjs","sources":["../../../packages/map/index.ts"],"sourcesContent":["import mitt from \"mitt\";\r\nimport { defineComponent, h, onMounted, provide, ref } from \"vue\";\r\nimport type { MapEvents } from \"~/utils/emitter\";\r\nimport { useApiLoader } from \"~/use/apiLoader\";\r\nimport { useEvent } from \"~/use/event\";\r\nimport { EVENTS, NATIVE_EVENTS, PROPS, useControls, useInit, useWatch } from \"./use\";\r\n\r\nexport const TdtMap = defineComponent({\r\n  name: \"TdtMap\",\r\n  props: PROPS,\r\n  emits: EVENTS,\r\n  setup(props, { emit, slots }) {\r\n    const tdtMap = ref<T.Map>();\r\n    const mapEmitter = mitt<MapEvents>();\r\n    provide(\"mapRoot\", tdtMap);\r\n    provide(\"mapEmitter\", mapEmitter);\r\n\r\n    const tdtMapRef = h<\"div\">(\"div\", {\r\n      class: \"tdt-map\",\r\n      style: \"width:100%;height:100%\",\r\n      id: props.mid\r\n    });\r\n\r\n    onMounted(async () => {\r\n      await useApiLoader(props.loadConfig);\r\n      tdtMap.value = useInit(props, tdtMapRef.el as HTMLElement);\r\n      useEvent({ events: NATIVE_EVENTS, emit, instance: tdtMap.value });\r\n      useWatch({ props, instance: tdtMap.value });\r\n      useControls(props, tdtMap.value, emit);\r\n      emit(\"init\", tdtMap.value);\r\n      mapEmitter.emit(\"mapInit\", tdtMap.value);\r\n    });\r\n\r\n    return () =>\r\n      h(\r\n        \"div\",\r\n        {\r\n          class: \"tdt-map-container\",\r\n          style: \"width:100%;height:100%\"\r\n        },\r\n        [tdtMapRef, slots.default?.()]\r\n      );\r\n  }\r\n});\r\n\r\nexport type TdtMapInstance = InstanceType<typeof TdtMap>;\r\n"],"names":["TdtMap","defineComponent","PROPS","EVENTS","props","emit","slots","tdtMap","ref","mapEmitter","mitt","provide","tdtMapRef","h","onMounted","useApiLoader","useInit","useEvent","NATIVE_EVENTS","useWatch","useControls","_a"],"mappings":";;;;;;;;AAOO,MAAMA,IAASC,EAAgB;AAAA,EACpC,MAAM;AAAA,EACN,OAAOC;AAAA,EACP,OAAOC;AAAA,EACP,MAAMC,GAAO,EAAE,MAAAC,GAAM,OAAAC,KAAS;AAC5B,UAAMC,IAASC,EAAW,GACpBC,IAAaC,EAAgB;AACnC,IAAAC,EAAQ,WAAWJ,CAAM,GACzBI,EAAQ,cAAcF,CAAU;AAE1B,UAAAG,IAAYC,EAAS,OAAO;AAAA,MAChC,OAAO;AAAA,MACP,OAAO;AAAA,MACP,IAAIT,EAAM;AAAA,IAAA,CACX;AAED,WAAAU,EAAU,YAAY;AACd,YAAAC,EAAaX,EAAM,UAAU,GACnCG,EAAO,QAAQS,EAAQZ,GAAOQ,EAAU,EAAiB,GACzDK,EAAS,EAAE,QAAQC,GAAe,MAAAb,GAAM,UAAUE,EAAO,OAAO,GAChEY,EAAS,EAAE,OAAAf,GAAO,UAAUG,EAAO,OAAO,GAC9Ba,EAAAhB,GAAOG,EAAO,OAAOF,CAAI,GAChCA,EAAA,QAAQE,EAAO,KAAK,GACdE,EAAA,KAAK,WAAWF,EAAO,KAAK;AAAA,IAAA,CACxC,GAEM;;AACL,aAAAM;AAAA,QACE;AAAA,QACA;AAAA,UACE,OAAO;AAAA,UACP,OAAO;AAAA,QACT;AAAA,QACA,CAACD,IAAWS,IAAAf,EAAM,YAAN,gBAAAe,EAAA,KAAAf,EAAiB;AAAA,MAC/B;AAAA;AAAA,EAAA;AAEN,CAAC;"}