@mapvx/web-js 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (397) hide show
  1. package/LICENSE.md +19 -0
  2. package/README.md +257 -0
  3. package/dist/cjs/assets/icons.js +87 -0
  4. package/dist/cjs/assets/icons.js.map +1 -0
  5. package/dist/cjs/assets/route_animation_icon.svg +15 -0
  6. package/dist/cjs/assets/user-dot-icon.svg +3 -0
  7. package/dist/cjs/config/sdkConfig.js +3 -0
  8. package/dist/cjs/config/sdkConfig.js.map +1 -0
  9. package/dist/cjs/controllers/routeController.js +1054 -0
  10. package/dist/cjs/controllers/routeController.js.map +1 -0
  11. package/dist/cjs/domain/models/_internal.js +15 -0
  12. package/dist/cjs/domain/models/_internal.js.map +1 -0
  13. package/dist/cjs/domain/models/_rtl.js +10 -0
  14. package/dist/cjs/domain/models/_rtl.js.map +1 -0
  15. package/dist/cjs/domain/models/animation.js +63 -0
  16. package/dist/cjs/domain/models/animation.js.map +1 -0
  17. package/dist/cjs/domain/models/banner.js +24 -0
  18. package/dist/cjs/domain/models/banner.js.map +1 -0
  19. package/dist/cjs/domain/models/categories.js +25 -0
  20. package/dist/cjs/domain/models/categories.js.map +1 -0
  21. package/dist/cjs/domain/models/cityFilterOption.js +3 -0
  22. package/dist/cjs/domain/models/cityFilterOption.js.map +1 -0
  23. package/dist/cjs/domain/models/configuration.js +3 -0
  24. package/dist/cjs/domain/models/configuration.js.map +1 -0
  25. package/dist/cjs/domain/models/cssCustomization.js +3 -0
  26. package/dist/cjs/domain/models/cssCustomization.js.map +1 -0
  27. package/dist/cjs/domain/models/fitOptions.js +3 -0
  28. package/dist/cjs/domain/models/fitOptions.js.map +1 -0
  29. package/dist/cjs/domain/models/innerFloors.js +3 -0
  30. package/dist/cjs/domain/models/innerFloors.js.map +1 -0
  31. package/dist/cjs/domain/models/institution.js +44 -0
  32. package/dist/cjs/domain/models/institution.js.map +1 -0
  33. package/dist/cjs/domain/models/latLng.js +3 -0
  34. package/dist/cjs/domain/models/latLng.js.map +1 -0
  35. package/dist/cjs/domain/models/location.js +3 -0
  36. package/dist/cjs/domain/models/location.js.map +1 -0
  37. package/dist/cjs/domain/models/loggeable.js +52 -0
  38. package/dist/cjs/domain/models/loggeable.js.map +1 -0
  39. package/dist/cjs/domain/models/mapCamera.js +3 -0
  40. package/dist/cjs/domain/models/mapCamera.js.map +1 -0
  41. package/dist/cjs/domain/models/mapConfig.js +15 -0
  42. package/dist/cjs/domain/models/mapConfig.js.map +1 -0
  43. package/dist/cjs/domain/models/marker.js +400 -0
  44. package/dist/cjs/domain/models/marker.js.map +1 -0
  45. package/dist/cjs/domain/models/multilanguage.js +18 -0
  46. package/dist/cjs/domain/models/multilanguage.js.map +1 -0
  47. package/dist/cjs/domain/models/openingHours.js +3 -0
  48. package/dist/cjs/domain/models/openingHours.js.map +1 -0
  49. package/dist/cjs/domain/models/place.js +101 -0
  50. package/dist/cjs/domain/models/place.js.map +1 -0
  51. package/dist/cjs/domain/models/platform.js +3 -0
  52. package/dist/cjs/domain/models/platform.js.map +1 -0
  53. package/dist/cjs/domain/models/popover.js +3 -0
  54. package/dist/cjs/domain/models/popover.js.map +1 -0
  55. package/dist/cjs/domain/models/product.js +3 -0
  56. package/dist/cjs/domain/models/product.js.map +1 -0
  57. package/dist/cjs/domain/models/property.js +104 -0
  58. package/dist/cjs/domain/models/property.js.map +1 -0
  59. package/dist/cjs/domain/models/route.js +166 -0
  60. package/dist/cjs/domain/models/route.js.map +1 -0
  61. package/dist/cjs/domain/models/routeConfiguration.js +80 -0
  62. package/dist/cjs/domain/models/routeConfiguration.js.map +1 -0
  63. package/dist/cjs/domain/models/routeInstance.js +30 -0
  64. package/dist/cjs/domain/models/routeInstance.js.map +1 -0
  65. package/dist/cjs/domain/models/routeStyle.js +3 -0
  66. package/dist/cjs/domain/models/routeStyle.js.map +1 -0
  67. package/dist/cjs/domain/models/transport.js +22 -0
  68. package/dist/cjs/domain/models/transport.js.map +1 -0
  69. package/dist/cjs/domain/ports/ICache.js +3 -0
  70. package/dist/cjs/domain/ports/ICache.js.map +1 -0
  71. package/dist/cjs/domain/ports/IHttpClient.js +3 -0
  72. package/dist/cjs/domain/ports/IHttpClient.js.map +1 -0
  73. package/dist/cjs/domain/ports/ILogger.js +23 -0
  74. package/dist/cjs/domain/ports/ILogger.js.map +1 -0
  75. package/dist/cjs/domain/ports/index.js +10 -0
  76. package/dist/cjs/domain/ports/index.js.map +1 -0
  77. package/dist/cjs/index.js +76 -0
  78. package/dist/cjs/index.js.map +1 -0
  79. package/dist/cjs/infrastructure/cache/CacheManager.js +236 -0
  80. package/dist/cjs/infrastructure/cache/CacheManager.js.map +1 -0
  81. package/dist/cjs/infrastructure/cache/LRUCache.js +153 -0
  82. package/dist/cjs/infrastructure/cache/LRUCache.js.map +1 -0
  83. package/dist/cjs/infrastructure/cache/PersistentCache.js +160 -0
  84. package/dist/cjs/infrastructure/cache/PersistentCache.js.map +1 -0
  85. package/dist/cjs/infrastructure/cache/cacheConfig.js +70 -0
  86. package/dist/cjs/infrastructure/cache/cacheConfig.js.map +1 -0
  87. package/dist/cjs/infrastructure/http/FetchHttpClient.js +75 -0
  88. package/dist/cjs/infrastructure/http/FetchHttpClient.js.map +1 -0
  89. package/dist/cjs/infrastructure/logging/CountlyLogger.js +78 -0
  90. package/dist/cjs/infrastructure/logging/CountlyLogger.js.map +1 -0
  91. package/dist/cjs/interfaces/cache.js +3 -0
  92. package/dist/cjs/interfaces/cache.js.map +1 -0
  93. package/dist/cjs/interfaces/healthResponse.js +3 -0
  94. package/dist/cjs/interfaces/healthResponse.js.map +1 -0
  95. package/dist/cjs/interfaces/institutionResponse.js +3 -0
  96. package/dist/cjs/interfaces/institutionResponse.js.map +1 -0
  97. package/dist/cjs/interfaces/metadata.js +3 -0
  98. package/dist/cjs/interfaces/metadata.js.map +1 -0
  99. package/dist/cjs/interfaces/placeResponse.js +3 -0
  100. package/dist/cjs/interfaces/placeResponse.js.map +1 -0
  101. package/dist/cjs/interfaces/routeCacheResponse.js +3 -0
  102. package/dist/cjs/interfaces/routeCacheResponse.js.map +1 -0
  103. package/dist/cjs/interfaces/routeResponse.js +3 -0
  104. package/dist/cjs/interfaces/routeResponse.js.map +1 -0
  105. package/dist/cjs/interfaces/styleResponse.js +3 -0
  106. package/dist/cjs/interfaces/styleResponse.js.map +1 -0
  107. package/dist/cjs/logger/logger.js +91 -0
  108. package/dist/cjs/logger/logger.js.map +1 -0
  109. package/dist/cjs/logger/rollbar.js +24 -0
  110. package/dist/cjs/logger/rollbar.js.map +1 -0
  111. package/dist/cjs/map/map.js +1457 -0
  112. package/dist/cjs/map/map.js.map +1 -0
  113. package/dist/cjs/repository/repository.js +574 -0
  114. package/dist/cjs/repository/repository.js.map +1 -0
  115. package/dist/cjs/repository/requester.js +590 -0
  116. package/dist/cjs/repository/requester.js.map +1 -0
  117. package/dist/cjs/sdk.js +351 -0
  118. package/dist/cjs/sdk.js.map +1 -0
  119. package/dist/cjs/utils/error.js +20 -0
  120. package/dist/cjs/utils/error.js.map +1 -0
  121. package/dist/cjs/utils/images.js +26 -0
  122. package/dist/cjs/utils/images.js.map +1 -0
  123. package/dist/cjs/utils/nav-functions.js +150 -0
  124. package/dist/cjs/utils/nav-functions.js.map +1 -0
  125. package/dist/cjs/utils/opening-hours-helper.js +911 -0
  126. package/dist/cjs/utils/opening-hours-helper.js.map +1 -0
  127. package/dist/cjs/utils/route-utils.js +58 -0
  128. package/dist/cjs/utils/route-utils.js.map +1 -0
  129. package/dist/cjs/utils/update-css.js +77 -0
  130. package/dist/cjs/utils/update-css.js.map +1 -0
  131. package/dist/cjs/utils/utils.js +105 -0
  132. package/dist/cjs/utils/utils.js.map +1 -0
  133. package/dist/es/assets/icons.d.ts +86 -0
  134. package/dist/es/assets/icons.d.ts.map +1 -0
  135. package/dist/es/assets/icons.js +83 -0
  136. package/dist/es/assets/icons.js.map +1 -0
  137. package/dist/es/assets/route_animation_icon.svg +15 -0
  138. package/dist/es/assets/user-dot-icon.svg +3 -0
  139. package/dist/es/config/sdkConfig.d.ts +105 -0
  140. package/dist/es/config/sdkConfig.d.ts.map +1 -0
  141. package/dist/es/config/sdkConfig.js +2 -0
  142. package/dist/es/config/sdkConfig.js.map +1 -0
  143. package/dist/es/controllers/routeController.d.ts +161 -0
  144. package/dist/es/controllers/routeController.d.ts.map +1 -0
  145. package/dist/es/controllers/routeController.js +1050 -0
  146. package/dist/es/controllers/routeController.js.map +1 -0
  147. package/dist/es/domain/models/_internal.d.ts +21 -0
  148. package/dist/es/domain/models/_internal.d.ts.map +1 -0
  149. package/dist/es/domain/models/_internal.js +11 -0
  150. package/dist/es/domain/models/_internal.js.map +1 -0
  151. package/dist/es/domain/models/_rtl.d.ts +7 -0
  152. package/dist/es/domain/models/_rtl.d.ts.map +1 -0
  153. package/dist/es/domain/models/_rtl.js +7 -0
  154. package/dist/es/domain/models/_rtl.js.map +1 -0
  155. package/dist/es/domain/models/animation.d.ts +161 -0
  156. package/dist/es/domain/models/animation.d.ts.map +1 -0
  157. package/dist/es/domain/models/animation.js +58 -0
  158. package/dist/es/domain/models/animation.js.map +1 -0
  159. package/dist/es/domain/models/banner.d.ts +64 -0
  160. package/dist/es/domain/models/banner.d.ts.map +1 -0
  161. package/dist/es/domain/models/banner.js +20 -0
  162. package/dist/es/domain/models/banner.js.map +1 -0
  163. package/dist/es/domain/models/categories.d.ts +157 -0
  164. package/dist/es/domain/models/categories.d.ts.map +1 -0
  165. package/dist/es/domain/models/categories.js +20 -0
  166. package/dist/es/domain/models/categories.js.map +1 -0
  167. package/dist/es/domain/models/cityFilterOption.d.ts +15 -0
  168. package/dist/es/domain/models/cityFilterOption.d.ts.map +1 -0
  169. package/dist/es/domain/models/cityFilterOption.js +2 -0
  170. package/dist/es/domain/models/cityFilterOption.js.map +1 -0
  171. package/dist/es/domain/models/configuration.d.ts +523 -0
  172. package/dist/es/domain/models/configuration.d.ts.map +1 -0
  173. package/dist/es/domain/models/configuration.js +2 -0
  174. package/dist/es/domain/models/configuration.js.map +1 -0
  175. package/dist/es/domain/models/cssCustomization.d.ts +63 -0
  176. package/dist/es/domain/models/cssCustomization.d.ts.map +1 -0
  177. package/dist/es/domain/models/cssCustomization.js +2 -0
  178. package/dist/es/domain/models/cssCustomization.js.map +1 -0
  179. package/dist/es/domain/models/fitOptions.d.ts +175 -0
  180. package/dist/es/domain/models/fitOptions.d.ts.map +1 -0
  181. package/dist/es/domain/models/fitOptions.js +2 -0
  182. package/dist/es/domain/models/fitOptions.js.map +1 -0
  183. package/dist/es/domain/models/innerFloors.d.ts +42 -0
  184. package/dist/es/domain/models/innerFloors.d.ts.map +1 -0
  185. package/dist/es/domain/models/innerFloors.js +2 -0
  186. package/dist/es/domain/models/innerFloors.js.map +1 -0
  187. package/dist/es/domain/models/institution.d.ts +64 -0
  188. package/dist/es/domain/models/institution.d.ts.map +1 -0
  189. package/dist/es/domain/models/institution.js +40 -0
  190. package/dist/es/domain/models/institution.js.map +1 -0
  191. package/dist/es/domain/models/latLng.d.ts +14 -0
  192. package/dist/es/domain/models/latLng.d.ts.map +1 -0
  193. package/dist/es/domain/models/latLng.js +2 -0
  194. package/dist/es/domain/models/latLng.js.map +1 -0
  195. package/dist/es/domain/models/location.d.ts +10 -0
  196. package/dist/es/domain/models/location.d.ts.map +1 -0
  197. package/dist/es/domain/models/location.js +2 -0
  198. package/dist/es/domain/models/location.js.map +1 -0
  199. package/dist/es/domain/models/loggeable.d.ts +43 -0
  200. package/dist/es/domain/models/loggeable.d.ts.map +1 -0
  201. package/dist/es/domain/models/loggeable.js +48 -0
  202. package/dist/es/domain/models/loggeable.js.map +1 -0
  203. package/dist/es/domain/models/mapCamera.d.ts +109 -0
  204. package/dist/es/domain/models/mapCamera.d.ts.map +1 -0
  205. package/dist/es/domain/models/mapCamera.js +2 -0
  206. package/dist/es/domain/models/mapCamera.js.map +1 -0
  207. package/dist/es/domain/models/mapConfig.d.ts +238 -0
  208. package/dist/es/domain/models/mapConfig.d.ts.map +1 -0
  209. package/dist/es/domain/models/mapConfig.js +12 -0
  210. package/dist/es/domain/models/mapConfig.js.map +1 -0
  211. package/dist/es/domain/models/marker.d.ts +301 -0
  212. package/dist/es/domain/models/marker.d.ts.map +1 -0
  213. package/dist/es/domain/models/marker.js +396 -0
  214. package/dist/es/domain/models/marker.js.map +1 -0
  215. package/dist/es/domain/models/multilanguage.d.ts +27 -0
  216. package/dist/es/domain/models/multilanguage.d.ts.map +1 -0
  217. package/dist/es/domain/models/multilanguage.js +14 -0
  218. package/dist/es/domain/models/multilanguage.js.map +1 -0
  219. package/dist/es/domain/models/openingHours.d.ts +30 -0
  220. package/dist/es/domain/models/openingHours.d.ts.map +1 -0
  221. package/dist/es/domain/models/openingHours.js +2 -0
  222. package/dist/es/domain/models/openingHours.js.map +1 -0
  223. package/dist/es/domain/models/place.d.ts +167 -0
  224. package/dist/es/domain/models/place.d.ts.map +1 -0
  225. package/dist/es/domain/models/place.js +97 -0
  226. package/dist/es/domain/models/place.js.map +1 -0
  227. package/dist/es/domain/models/platform.d.ts +6 -0
  228. package/dist/es/domain/models/platform.d.ts.map +1 -0
  229. package/dist/es/domain/models/platform.js +2 -0
  230. package/dist/es/domain/models/platform.js.map +1 -0
  231. package/dist/es/domain/models/popover.d.ts +14 -0
  232. package/dist/es/domain/models/popover.d.ts.map +1 -0
  233. package/dist/es/domain/models/popover.js +2 -0
  234. package/dist/es/domain/models/popover.js.map +1 -0
  235. package/dist/es/domain/models/product.d.ts +36 -0
  236. package/dist/es/domain/models/product.d.ts.map +1 -0
  237. package/dist/es/domain/models/product.js +2 -0
  238. package/dist/es/domain/models/product.js.map +1 -0
  239. package/dist/es/domain/models/property.d.ts +172 -0
  240. package/dist/es/domain/models/property.d.ts.map +1 -0
  241. package/dist/es/domain/models/property.js +100 -0
  242. package/dist/es/domain/models/property.js.map +1 -0
  243. package/dist/es/domain/models/route.d.ts +199 -0
  244. package/dist/es/domain/models/route.d.ts.map +1 -0
  245. package/dist/es/domain/models/route.js +160 -0
  246. package/dist/es/domain/models/route.js.map +1 -0
  247. package/dist/es/domain/models/routeConfiguration.d.ts +140 -0
  248. package/dist/es/domain/models/routeConfiguration.d.ts.map +1 -0
  249. package/dist/es/domain/models/routeConfiguration.js +75 -0
  250. package/dist/es/domain/models/routeConfiguration.js.map +1 -0
  251. package/dist/es/domain/models/routeInstance.d.ts +52 -0
  252. package/dist/es/domain/models/routeInstance.d.ts.map +1 -0
  253. package/dist/es/domain/models/routeInstance.js +26 -0
  254. package/dist/es/domain/models/routeInstance.js.map +1 -0
  255. package/dist/es/domain/models/routeStyle.d.ts +47 -0
  256. package/dist/es/domain/models/routeStyle.d.ts.map +1 -0
  257. package/dist/es/domain/models/routeStyle.js +2 -0
  258. package/dist/es/domain/models/routeStyle.js.map +1 -0
  259. package/dist/es/domain/models/transport.d.ts +176 -0
  260. package/dist/es/domain/models/transport.d.ts.map +1 -0
  261. package/dist/es/domain/models/transport.js +18 -0
  262. package/dist/es/domain/models/transport.js.map +1 -0
  263. package/dist/es/domain/ports/ICache.d.ts +70 -0
  264. package/dist/es/domain/ports/ICache.d.ts.map +1 -0
  265. package/dist/es/domain/ports/ICache.js +2 -0
  266. package/dist/es/domain/ports/ICache.js.map +1 -0
  267. package/dist/es/domain/ports/IHttpClient.d.ts +77 -0
  268. package/dist/es/domain/ports/IHttpClient.d.ts.map +1 -0
  269. package/dist/es/domain/ports/IHttpClient.js +2 -0
  270. package/dist/es/domain/ports/IHttpClient.js.map +1 -0
  271. package/dist/es/domain/ports/ILogger.d.ts +61 -0
  272. package/dist/es/domain/ports/ILogger.d.ts.map +1 -0
  273. package/dist/es/domain/ports/ILogger.js +19 -0
  274. package/dist/es/domain/ports/ILogger.js.map +1 -0
  275. package/dist/es/domain/ports/index.d.ts +9 -0
  276. package/dist/es/domain/ports/index.d.ts.map +1 -0
  277. package/dist/es/domain/ports/index.js +6 -0
  278. package/dist/es/domain/ports/index.js.map +1 -0
  279. package/dist/es/index.d.ts +58 -0
  280. package/dist/es/index.d.ts.map +1 -0
  281. package/dist/es/index.js +48 -0
  282. package/dist/es/index.js.map +1 -0
  283. package/dist/es/infrastructure/cache/CacheManager.d.ts +106 -0
  284. package/dist/es/infrastructure/cache/CacheManager.d.ts.map +1 -0
  285. package/dist/es/infrastructure/cache/CacheManager.js +232 -0
  286. package/dist/es/infrastructure/cache/CacheManager.js.map +1 -0
  287. package/dist/es/infrastructure/cache/LRUCache.d.ts +70 -0
  288. package/dist/es/infrastructure/cache/LRUCache.d.ts.map +1 -0
  289. package/dist/es/infrastructure/cache/LRUCache.js +149 -0
  290. package/dist/es/infrastructure/cache/LRUCache.js.map +1 -0
  291. package/dist/es/infrastructure/cache/PersistentCache.d.ts +58 -0
  292. package/dist/es/infrastructure/cache/PersistentCache.d.ts.map +1 -0
  293. package/dist/es/infrastructure/cache/PersistentCache.js +156 -0
  294. package/dist/es/infrastructure/cache/PersistentCache.js.map +1 -0
  295. package/dist/es/infrastructure/cache/cacheConfig.d.ts +51 -0
  296. package/dist/es/infrastructure/cache/cacheConfig.d.ts.map +1 -0
  297. package/dist/es/infrastructure/cache/cacheConfig.js +66 -0
  298. package/dist/es/infrastructure/cache/cacheConfig.js.map +1 -0
  299. package/dist/es/infrastructure/http/FetchHttpClient.d.ts +41 -0
  300. package/dist/es/infrastructure/http/FetchHttpClient.d.ts.map +1 -0
  301. package/dist/es/infrastructure/http/FetchHttpClient.js +71 -0
  302. package/dist/es/infrastructure/http/FetchHttpClient.js.map +1 -0
  303. package/dist/es/infrastructure/logging/CountlyLogger.d.ts +47 -0
  304. package/dist/es/infrastructure/logging/CountlyLogger.d.ts.map +1 -0
  305. package/dist/es/infrastructure/logging/CountlyLogger.js +74 -0
  306. package/dist/es/infrastructure/logging/CountlyLogger.js.map +1 -0
  307. package/dist/es/interfaces/cache.d.ts +5 -0
  308. package/dist/es/interfaces/cache.d.ts.map +1 -0
  309. package/dist/es/interfaces/cache.js +2 -0
  310. package/dist/es/interfaces/cache.js.map +1 -0
  311. package/dist/es/interfaces/healthResponse.d.ts +17 -0
  312. package/dist/es/interfaces/healthResponse.d.ts.map +1 -0
  313. package/dist/es/interfaces/healthResponse.js +2 -0
  314. package/dist/es/interfaces/healthResponse.js.map +1 -0
  315. package/dist/es/interfaces/institutionResponse.d.ts +12 -0
  316. package/dist/es/interfaces/institutionResponse.d.ts.map +1 -0
  317. package/dist/es/interfaces/institutionResponse.js +2 -0
  318. package/dist/es/interfaces/institutionResponse.js.map +1 -0
  319. package/dist/es/interfaces/metadata.d.ts +7 -0
  320. package/dist/es/interfaces/metadata.d.ts.map +1 -0
  321. package/dist/es/interfaces/metadata.js +2 -0
  322. package/dist/es/interfaces/metadata.js.map +1 -0
  323. package/dist/es/interfaces/placeResponse.d.ts +50 -0
  324. package/dist/es/interfaces/placeResponse.d.ts.map +1 -0
  325. package/dist/es/interfaces/placeResponse.js +2 -0
  326. package/dist/es/interfaces/placeResponse.js.map +1 -0
  327. package/dist/es/interfaces/routeCacheResponse.d.ts +13 -0
  328. package/dist/es/interfaces/routeCacheResponse.d.ts.map +1 -0
  329. package/dist/es/interfaces/routeCacheResponse.js +2 -0
  330. package/dist/es/interfaces/routeCacheResponse.js.map +1 -0
  331. package/dist/es/interfaces/routeResponse.d.ts +42 -0
  332. package/dist/es/interfaces/routeResponse.d.ts.map +1 -0
  333. package/dist/es/interfaces/routeResponse.js +2 -0
  334. package/dist/es/interfaces/routeResponse.js.map +1 -0
  335. package/dist/es/interfaces/styleResponse.d.ts +5 -0
  336. package/dist/es/interfaces/styleResponse.d.ts.map +1 -0
  337. package/dist/es/interfaces/styleResponse.js +2 -0
  338. package/dist/es/interfaces/styleResponse.js.map +1 -0
  339. package/dist/es/logger/logger.d.ts +14 -0
  340. package/dist/es/logger/logger.d.ts.map +1 -0
  341. package/dist/es/logger/logger.js +84 -0
  342. package/dist/es/logger/logger.js.map +1 -0
  343. package/dist/es/logger/rollbar.d.ts +4 -0
  344. package/dist/es/logger/rollbar.d.ts.map +1 -0
  345. package/dist/es/logger/rollbar.js +20 -0
  346. package/dist/es/logger/rollbar.js.map +1 -0
  347. package/dist/es/map/map.d.ts +598 -0
  348. package/dist/es/map/map.d.ts.map +1 -0
  349. package/dist/es/map/map.js +1430 -0
  350. package/dist/es/map/map.js.map +1 -0
  351. package/dist/es/repository/repository.d.ts +65 -0
  352. package/dist/es/repository/repository.d.ts.map +1 -0
  353. package/dist/es/repository/repository.js +570 -0
  354. package/dist/es/repository/repository.js.map +1 -0
  355. package/dist/es/repository/requester.d.ts +169 -0
  356. package/dist/es/repository/requester.d.ts.map +1 -0
  357. package/dist/es/repository/requester.js +586 -0
  358. package/dist/es/repository/requester.js.map +1 -0
  359. package/dist/es/sdk.d.ts +279 -0
  360. package/dist/es/sdk.d.ts.map +1 -0
  361. package/dist/es/sdk.js +346 -0
  362. package/dist/es/sdk.js.map +1 -0
  363. package/dist/es/utils/error.d.ts +8 -0
  364. package/dist/es/utils/error.d.ts.map +1 -0
  365. package/dist/es/utils/error.js +16 -0
  366. package/dist/es/utils/error.js.map +1 -0
  367. package/dist/es/utils/images.d.ts +8 -0
  368. package/dist/es/utils/images.d.ts.map +1 -0
  369. package/dist/es/utils/images.js +22 -0
  370. package/dist/es/utils/images.js.map +1 -0
  371. package/dist/es/utils/nav-functions.d.ts +85 -0
  372. package/dist/es/utils/nav-functions.d.ts.map +1 -0
  373. package/dist/es/utils/nav-functions.js +143 -0
  374. package/dist/es/utils/nav-functions.js.map +1 -0
  375. package/dist/es/utils/opening-hours-helper.d.ts +395 -0
  376. package/dist/es/utils/opening-hours-helper.d.ts.map +1 -0
  377. package/dist/es/utils/opening-hours-helper.js +906 -0
  378. package/dist/es/utils/opening-hours-helper.js.map +1 -0
  379. package/dist/es/utils/route-utils.d.ts +28 -0
  380. package/dist/es/utils/route-utils.d.ts.map +1 -0
  381. package/dist/es/utils/route-utils.js +54 -0
  382. package/dist/es/utils/route-utils.js.map +1 -0
  383. package/dist/es/utils/update-css.d.ts +12 -0
  384. package/dist/es/utils/update-css.d.ts.map +1 -0
  385. package/dist/es/utils/update-css.js +73 -0
  386. package/dist/es/utils/update-css.js.map +1 -0
  387. package/dist/es/utils/utils.d.ts +39 -0
  388. package/dist/es/utils/utils.d.ts.map +1 -0
  389. package/dist/es/utils/utils.js +97 -0
  390. package/dist/es/utils/utils.js.map +1 -0
  391. package/dist/umd/index.js +16874 -0
  392. package/dist/umd/index.js.map +1 -0
  393. package/dist/umd/styles.css +107 -0
  394. package/dist/umd/styles.css.map +1 -0
  395. package/dist/umd/styles.js +37 -0
  396. package/dist/umd/styles.js.map +1 -0
  397. package/package.json +198 -0
@@ -0,0 +1,1430 @@
1
+ import maplibregl, { LngLatBounds, Map, NavigationControl, setRTLTextPlugin, } from "maplibre-gl";
2
+ // Flag to track if cached-tile protocol has been registered
3
+ let cachedTileProtocolRegistered = false;
4
+ /**
5
+ * Deep clone helper that works in all environments.
6
+ * Uses structuredClone if available, otherwise falls back to JSON serialization.
7
+ * @param obj The object to clone
8
+ * @returns A deep clone of the object
9
+ */
10
+ function deepClone(obj) {
11
+ if (obj === undefined || obj === null) {
12
+ return obj;
13
+ }
14
+ if (typeof structuredClone === "function") {
15
+ return structuredClone(obj);
16
+ }
17
+ return JSON.parse(JSON.stringify(obj));
18
+ }
19
+ /**
20
+ * Register a custom protocol for cached tiles that routes requests through the main thread.
21
+ * This allows the service worker to intercept and cache tile requests.
22
+ */
23
+ function registerCachedTileProtocol() {
24
+ if (cachedTileProtocolRegistered)
25
+ return;
26
+ maplibregl.addProtocol("cached-tile", (params, abortController) => {
27
+ // Convert cached-tile:// URL back to https://
28
+ const url = params.url.replace("cached-tile://", "https://");
29
+ return fetch(url, { signal: abortController.signal })
30
+ .then((response) => {
31
+ if (!response.ok) {
32
+ throw new Error(`HTTP error! status: ${response.status}`);
33
+ }
34
+ return response.arrayBuffer();
35
+ })
36
+ .then((data) => ({ data }));
37
+ });
38
+ cachedTileProtocolRegistered = true;
39
+ }
40
+ /**
41
+ * Converts a PaddingValue to pixels based on the container and viewport dimensions.
42
+ * @param value The padding value (number or string with unit)
43
+ * @param dimension The reference dimension in pixels (container width/height)
44
+ * @returns The padding value in pixels
45
+ */
46
+ function parsePaddingValue(value, dimension) {
47
+ if (value === undefined) {
48
+ return 0;
49
+ }
50
+ if (typeof value === "number") {
51
+ return value;
52
+ }
53
+ const match = value.match(/^(-?\d*\.?\d+)(px|%|vh|vw)?$/);
54
+ if (!match) {
55
+ return 0;
56
+ }
57
+ const numericValue = parseFloat(match[1]);
58
+ const unit = match[2] || "px";
59
+ switch (unit) {
60
+ case "px":
61
+ return numericValue;
62
+ case "%":
63
+ return (numericValue / 100) * dimension;
64
+ case "vh":
65
+ return (numericValue / 100) * window.innerHeight;
66
+ case "vw":
67
+ return (numericValue / 100) * window.innerWidth;
68
+ default:
69
+ return numericValue;
70
+ }
71
+ }
72
+ /**
73
+ * Converts PaddingOptions with mixed units to MapLibre's pixel-based padding format.
74
+ * @param padding The padding options with optional fields and mixed units
75
+ * @param containerWidth The map container width in pixels
76
+ * @param containerHeight The map container height in pixels
77
+ * @returns Padding object with all values in pixels
78
+ */
79
+ function convertPaddingToPixels(padding, containerWidth, containerHeight) {
80
+ if (!padding) {
81
+ return { top: 0, bottom: 0, left: 0, right: 0 };
82
+ }
83
+ return {
84
+ top: parsePaddingValue(padding.top, containerHeight),
85
+ bottom: parsePaddingValue(padding.bottom, containerHeight),
86
+ left: parsePaddingValue(padding.left, containerWidth),
87
+ right: parsePaddingValue(padding.right, containerWidth),
88
+ };
89
+ }
90
+ import { userLocationDataUrl } from "../assets/icons";
91
+ import { RouteController } from "../controllers/routeController";
92
+ import { rtlLanguages } from "../domain/models/_rtl";
93
+ import { InternalAnimationConfig, InternalAnimationDrawingConfig, } from "../domain/models/animation";
94
+ import { Loggeable } from "../domain/models/loggeable";
95
+ import { DEFAULT_TILE_CACHE_CONFIG, } from "../domain/models/mapConfig";
96
+ import { MarkerAttribute } from "../domain/models/marker";
97
+ import { MVXRoute } from "../domain/models/route";
98
+ import { InternalDrawRouteConfiguration, InternalGetRouteConfiguration, } from "../domain/models/routeConfiguration";
99
+ import { Repository } from "../repository/repository";
100
+ import { getBoundingBox } from "../utils/utils";
101
+ import { extractStepCoordinates } from "../utils/route-utils";
102
+ /**
103
+ * Class to interact with the map.
104
+ * @category Map
105
+ * @hidden
106
+ */
107
+ export class InternalMapVXMap extends Loggeable {
108
+ /**
109
+ * Creates a new map instance with the parameters specified in mapConfig and assigns it to the provided HTML container.
110
+ * @param mapConfig Configuration parameters for the map.
111
+ * @param container Container where the assignment of the created map is required.
112
+ * @param parentPlace Parent place required for map floor mapping, along with the display of subplaces.
113
+ * @param token The token provided for the creation and fetching of map information.
114
+ * @returns A new instance of MapVXMap.
115
+ */
116
+ constructor(mapConfig, container, token) {
117
+ var _a, _b;
118
+ super();
119
+ this.potentialParentPlaces = [];
120
+ this.innerFloors = [];
121
+ this.subPlaces = [];
122
+ this.currentFloor = "";
123
+ this.baseFilters = {};
124
+ this.markers = [];
125
+ this.enableHover = false;
126
+ this.hoveredId = "unselected";
127
+ this.failedTiles = new Set();
128
+ this.geoLocation = navigator.geolocation;
129
+ if (rtlLanguages.includes((_a = mapConfig.lang) !== null && _a !== void 0 ? _a : "")) {
130
+ this.setRTLSupport();
131
+ }
132
+ this.repository = new Repository(token, (_b = mapConfig.lang) !== null && _b !== void 0 ? _b : "en", mapConfig.apiUrl, undefined, mapConfig.mapvxRequestContext);
133
+ this.token = token;
134
+ this.parentPlaceId = mapConfig.parentPlaceId;
135
+ this.routeController = new RouteController(this);
136
+ this.userLocationMarker = undefined;
137
+ this.watchPositionID = undefined;
138
+ this.onFloorChange = mapConfig.onFloorChange;
139
+ this.onParentPlaceChange = mapConfig.onParentPlaceChange;
140
+ // Merge tile cache config with defaults
141
+ this.tileCacheConfig = Object.assign(Object.assign({}, DEFAULT_TILE_CACHE_CONFIG), mapConfig.tileCache);
142
+ if (mapConfig.parentPlaceId != null) {
143
+ this.initialPlaceDetailSetUp(mapConfig.parentPlaceId, mapConfig.authToken);
144
+ }
145
+ if (mapConfig.otherPotentialParentPlacesIds &&
146
+ mapConfig.otherPotentialParentPlacesIds.length > 0) {
147
+ this.loadOtherPotentialParentPlaces(mapConfig.otherPotentialParentPlacesIds);
148
+ }
149
+ this.enableHover = mapConfig.enableHover || false;
150
+ this.initialMapStyleSetUp(mapConfig, container);
151
+ }
152
+ setRTLSupport() {
153
+ setRTLTextPlugin("https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.3.0/dist/mapbox-gl-rtl-text.js", false).catch(() => {
154
+ // RTL support may fail in some browsers - this is expected
155
+ });
156
+ }
157
+ /**
158
+ * Transform style sources to use cached-tile:// protocol for tile URLs.
159
+ * This enables the service worker to intercept and cache tile requests.
160
+ * @param style The original style specification
161
+ * @returns A new style with transformed tile URLs
162
+ */
163
+ transformStyleForCaching(style) {
164
+ if (!style) {
165
+ return style;
166
+ }
167
+ const transformedStyle = deepClone(style);
168
+ if (transformedStyle === null || transformedStyle === void 0 ? void 0 : transformedStyle.sources) {
169
+ for (const sourceKey of Object.keys(transformedStyle.sources)) {
170
+ const source = transformedStyle.sources[sourceKey];
171
+ // Transform vector and raster tile sources
172
+ // Only transform source.tiles (actual tile URLs), NOT source.url (TileJSON metadata URL)
173
+ // source.url points to a TileJSON file that returns JSON, not binary tile data
174
+ if (source.tiles && Array.isArray(source.tiles)) {
175
+ source.tiles = source.tiles.map((tileUrl) => {
176
+ if (tileUrl.startsWith("https://")) {
177
+ return tileUrl.replace("https://", "cached-tile://");
178
+ }
179
+ return tileUrl;
180
+ });
181
+ }
182
+ }
183
+ }
184
+ return transformedStyle;
185
+ }
186
+ initialPlaceDetailSetUp(parentPlaceId, withBearerToken) {
187
+ if (withBearerToken) {
188
+ this.repository
189
+ .fetchAndParseAnyPlaceDetail(parentPlaceId, withBearerToken)
190
+ .then((place) => {
191
+ this.changeParentPlaceTo(place);
192
+ this.potentialParentPlaces.push(place);
193
+ })
194
+ .catch(console.error);
195
+ return;
196
+ }
197
+ this.repository
198
+ .fetchAndParsePlaceDetail(parentPlaceId)
199
+ .then((place) => {
200
+ this.changeParentPlaceTo(place);
201
+ this.potentialParentPlaces.push(place);
202
+ })
203
+ .catch(console.error);
204
+ }
205
+ loadOtherPotentialParentPlaces(ids) {
206
+ Promise.all(ids.map((id) => this.repository.fetchAndParsePlaceDetail(id)))
207
+ .then((places) => {
208
+ this.potentialParentPlaces.push(...places);
209
+ })
210
+ .catch(console.error);
211
+ }
212
+ subPlacesLoad(parentPlaceId) {
213
+ this.repository
214
+ .fetchAndParseSubPlaces(parentPlaceId)
215
+ .then((subPlaces) => {
216
+ this.subPlaces = subPlaces;
217
+ })
218
+ .catch(console.error);
219
+ }
220
+ initialMapStyleSetUp(mapConfig, container) {
221
+ if (mapConfig.institutionId && mapConfig.authToken) {
222
+ this.repository
223
+ .fetchAndParseAnyMapStyle(mapConfig.institutionId, mapConfig.authToken)
224
+ .then((style) => {
225
+ return this.onMapStyleLoaded(mapConfig, container, style);
226
+ })
227
+ .catch(console.error);
228
+ return;
229
+ }
230
+ this.repository
231
+ .fetchAndParseMapStyle(mapConfig.parentPlaceId)
232
+ .then((style) => {
233
+ return this.onMapStyleLoaded(mapConfig, container, style);
234
+ })
235
+ .catch(console.error);
236
+ }
237
+ onMapStyleLoaded(mapConfig, container, style) {
238
+ var _a, _b, _c;
239
+ // Determine if service worker caching should be enabled
240
+ const useServiceWorkerCaching = this.tileCacheConfig.enabled && this.tileCacheConfig.persistToServiceWorker;
241
+ // Register cached-tile protocol only if service worker caching is enabled
242
+ if (useServiceWorkerCaching) {
243
+ registerCachedTileProtocol();
244
+ }
245
+ // Transform tile URLs only if service worker caching is enabled
246
+ const finalStyle = useServiceWorkerCaching ? this.transformStyleForCaching(style) : style;
247
+ const mapOptions = {
248
+ container,
249
+ style: finalStyle,
250
+ center: mapConfig.center,
251
+ zoom: mapConfig.zoom,
252
+ pitch: (_a = mapConfig.pitch) !== null && _a !== void 0 ? _a : 0,
253
+ attributionControl: false,
254
+ maplibreLogo: false,
255
+ bearingSnap: (_b = mapConfig.bearingSnap) !== null && _b !== void 0 ? _b : 0,
256
+ cancelPendingTileRequestsWhileZooming: false,
257
+ // Use configured maxTiles for MapLibre's memory cache
258
+ maxTileCacheSize: this.tileCacheConfig.maxTiles,
259
+ };
260
+ if (mapConfig.maxZoom)
261
+ mapOptions.maxZoom = mapConfig.maxZoom;
262
+ if (mapConfig.minZoom)
263
+ mapOptions.minZoom = mapConfig.minZoom;
264
+ if (mapConfig.maxBounds && mapConfig.maxBounds.length > 1) {
265
+ const boundingBox = getBoundingBox(mapConfig.maxBounds);
266
+ mapOptions.maxBounds = new LngLatBounds([boundingBox[0].lng, boundingBox[0].lat], [boundingBox[1].lng, boundingBox[1].lat]);
267
+ }
268
+ this.map = new Map(mapOptions);
269
+ this.map.addControl(new NavigationControl({
270
+ showCompass: mapConfig.showCompass !== undefined ? mapConfig.showCompass : true,
271
+ showZoom: mapConfig.showZoom !== undefined ? mapConfig.showZoom : true,
272
+ }), (_c = mapConfig.navigationPosition) !== null && _c !== void 0 ? _c : "top-right");
273
+ this.map.on("load", () => {
274
+ var _a;
275
+ this.whenStyleUpdates(style);
276
+ if (mapConfig.lang)
277
+ this.setLayersForLanguage(mapConfig.lang);
278
+ (_a = mapConfig.onMapReady) === null || _a === void 0 ? void 0 : _a.call(mapConfig);
279
+ this.onHover();
280
+ this.subscribeToFailedTiles();
281
+ });
282
+ this.map.on("zoomend", () => {
283
+ var _a;
284
+ (_a = mapConfig.onZoomEnd) === null || _a === void 0 ? void 0 : _a.call(mapConfig, this.getZoomLevel());
285
+ });
286
+ this.map.on("rotate", () => {
287
+ var _a;
288
+ (_a = mapConfig.onRotate) === null || _a === void 0 ? void 0 : _a.call(mapConfig, this.map.getBearing());
289
+ });
290
+ this.defaultClickListener();
291
+ return this.map;
292
+ }
293
+ setBaseFilters(style) {
294
+ if (!style)
295
+ return;
296
+ const publicPlaceFilter = ["==", ["get", "public_place"], true];
297
+ style.layers
298
+ .filter((layer) => layer.id.startsWith("indoor-"))
299
+ .forEach((layer) => {
300
+ const baseFilter = this.baseFilters[layer.id];
301
+ if (baseFilter != null) {
302
+ const finalFilter = ["all", baseFilter, publicPlaceFilter];
303
+ this.map.setFilter(layer.id, finalFilter);
304
+ }
305
+ else {
306
+ this.map.setFilter(layer.id, publicPlaceFilter);
307
+ }
308
+ switch (layer.type) {
309
+ case "line":
310
+ case "symbol":
311
+ case "fill-extrusion":
312
+ case "fill":
313
+ if (layer.filter != null) {
314
+ this.baseFilters[layer.id] = layer.filter;
315
+ }
316
+ break;
317
+ default:
318
+ break;
319
+ }
320
+ });
321
+ }
322
+ setLayersForLanguage(lang) {
323
+ var _a, _b;
324
+ // outdoor layers
325
+ const layersName = [
326
+ "aerodrome_label",
327
+ "mountain_peak",
328
+ "park",
329
+ "place",
330
+ "poi",
331
+ "transportation_name",
332
+ "water_name",
333
+ "waterway",
334
+ ];
335
+ const layers = (_b = (_a = this.map.getStyle()) === null || _a === void 0 ? void 0 : _a.layers) !== null && _b !== void 0 ? _b : [];
336
+ const layersIds = layers
337
+ .filter((layer) => {
338
+ var _a;
339
+ return layer.type === "symbol" &&
340
+ layer.source === "openmaptiles" &&
341
+ layersName.includes((_a = layer["source-layer"]) !== null && _a !== void 0 ? _a : "");
342
+ })
343
+ .map((layer) => {
344
+ return layer.id;
345
+ });
346
+ layersIds.forEach((id) => {
347
+ try {
348
+ const property = this.map.getLayoutProperty(id, "symbol-placement");
349
+ this.map.setLayoutProperty(id, "text-field", [
350
+ "case",
351
+ ["has", `name:${lang}`],
352
+ ["get", `name:${lang}`],
353
+ [
354
+ "format",
355
+ ["get", "name:latin"],
356
+ property === "line" ? " " : "\n",
357
+ ["get", "name:nonlatin"],
358
+ ],
359
+ ]);
360
+ }
361
+ catch (error) {
362
+ // Layer language update may fail if layer doesn't exist
363
+ }
364
+ });
365
+ // indoor layers
366
+ const indoorLayerIds = layers
367
+ .filter((layer) => {
368
+ var _a;
369
+ return layer.type === "symbol" &&
370
+ layer.source === "indoorequal" &&
371
+ ((_a = layer.layout) === null || _a === void 0 ? void 0 : _a["text-field"]) !== undefined;
372
+ })
373
+ .map((layer) => {
374
+ return layer.id;
375
+ });
376
+ indoorLayerIds.forEach((id) => {
377
+ try {
378
+ this.map.setLayoutProperty(id, "text-field", [
379
+ "case",
380
+ ["has", `name:${lang}`],
381
+ ["get", `name:${lang}`],
382
+ ["get", "name"],
383
+ ]);
384
+ }
385
+ catch (error) {
386
+ // Layer language update may fail if layer doesn't exist
387
+ }
388
+ });
389
+ }
390
+ /**
391
+ * Add values to identify the client.
392
+ * @param segmentation The pair values to use as segmentation.
393
+ * @returns The segmentation with the added values.
394
+ */
395
+ prepareSegmentation(segmentation) {
396
+ var _a;
397
+ return Object.assign(Object.assign({}, segmentation), { token: this.token, parentPlaceId: (_a = this.parentPlaceId) !== null && _a !== void 0 ? _a : "None" });
398
+ }
399
+ destroyMap() {
400
+ this.map.remove();
401
+ this.unsubscribeFromFailedTiles();
402
+ }
403
+ clearTileCache() {
404
+ try {
405
+ // Clear the failed tiles tracking set
406
+ this.failedTiles.clear();
407
+ // Force MapLibre to reload all visible tiles by triggering a repaint
408
+ // Note: MapLibre doesn't expose a direct cache clear method, so we
409
+ // trigger a style refresh which causes tiles to be re-requested
410
+ if (this.map) {
411
+ this.map.triggerRepaint();
412
+ }
413
+ this.logEvent("clearTileCache");
414
+ }
415
+ catch (error) {
416
+ // Tile cache clear may fail if cache doesn't exist
417
+ }
418
+ }
419
+ getCurrentFloor() {
420
+ var _a;
421
+ return (_a = this.currentFloor) !== null && _a !== void 0 ? _a : "";
422
+ }
423
+ /**
424
+ * Performs changes when parent place is updated
425
+ * @param place new parent place
426
+ * @param updateStyle defines if new parent place style must be set
427
+ */
428
+ changeParentPlaceTo(place, updateStyle = false, onStyleReady) {
429
+ var _a, _b, _c, _d, _e, _f;
430
+ this.parentPlace = place;
431
+ this.parentPlaceId = place === null || place === void 0 ? void 0 : place.mapvxId;
432
+ this.innerFloors = (_b = (_a = place === null || place === void 0 ? void 0 : place.innerFloors) === null || _a === void 0 ? void 0 : _a.sort((a, b) => a.index - b.index)) !== null && _b !== void 0 ? _b : [];
433
+ this.currentFloor =
434
+ (_f = (_d = (_c = this.innerFloors.find((floor) => floor.defaultFloor)) === null || _c === void 0 ? void 0 : _c.key) !== null && _d !== void 0 ? _d : (_e = this.innerFloors[0]) === null || _e === void 0 ? void 0 : _e.key) !== null && _f !== void 0 ? _f : "";
435
+ if (place) {
436
+ this.subPlacesLoad(place.mapvxId);
437
+ }
438
+ if (updateStyle) {
439
+ this.repository
440
+ .fetchAndParseMapStyle(place === null || place === void 0 ? void 0 : place.mapvxId)
441
+ .then((style) => {
442
+ const useServiceWorkerCaching = this.tileCacheConfig.enabled && this.tileCacheConfig.persistToServiceWorker;
443
+ const finalStyle = useServiceWorkerCaching ? this.transformStyleForCaching(style) : style;
444
+ this.map.setStyle(finalStyle);
445
+ this.whenStyleUpdates(finalStyle);
446
+ onStyleReady === null || onStyleReady === void 0 ? void 0 : onStyleReady();
447
+ })
448
+ .catch(console.error);
449
+ }
450
+ }
451
+ /**
452
+ * Update the parent place and the current floor.
453
+ * Does not update layers, markers, etc.
454
+ * @param parentPlaceId
455
+ * @param floorId
456
+ * @throws A error if the parent place is not one of the allowed places to show.
457
+ */
458
+ updatePlaceAndFloor(parentPlaceId, floorId) {
459
+ var _a, _b, _c, _d, _e;
460
+ const place = this.potentialParentPlaces.find((place) => place.mapvxId === parentPlaceId);
461
+ this.parentPlace = place;
462
+ this.parentPlaceId = place === null || place === void 0 ? void 0 : place.mapvxId;
463
+ this.innerFloors = (_a = place === null || place === void 0 ? void 0 : place.innerFloors.sort((a, b) => a.index - b.index)) !== null && _a !== void 0 ? _a : [];
464
+ this.currentFloor =
465
+ (_e = (_c = floorId !== null && floorId !== void 0 ? floorId : (_b = this.innerFloors.find((floor) => floor.defaultFloor)) === null || _b === void 0 ? void 0 : _b.key) !== null && _c !== void 0 ? _c : (_d = this.innerFloors[0]) === null || _d === void 0 ? void 0 : _d.key) !== null && _e !== void 0 ? _e : "";
466
+ }
467
+ updateParentPlaceAndFloor(parentPlaceId, floorId, options) {
468
+ var _a, _b, _c, _d;
469
+ try {
470
+ this.updatePlaceAndFloor(parentPlaceId, floorId);
471
+ this.filterByFloorKey(this.currentFloor);
472
+ (_a = this.onParentPlaceChange) === null || _a === void 0 ? void 0 : _a.call(this, parentPlaceId);
473
+ (_b = this.onFloorChange) === null || _b === void 0 ? void 0 : _b.call(this, (_c = this.currentFloor) !== null && _c !== void 0 ? _c : "");
474
+ this.logEvent("updateParentPlaceAndFloor");
475
+ (_d = options === null || options === void 0 ? void 0 : options.onComplete) === null || _d === void 0 ? void 0 : _d.call(options);
476
+ }
477
+ catch (error) {
478
+ // Parent place/floor update may fail
479
+ }
480
+ }
481
+ setLang(lang) {
482
+ this.repository.setLang(lang);
483
+ }
484
+ setParentPlace(place, updateStyle, onStyleReady) {
485
+ this.changeParentPlaceTo(place, updateStyle, onStyleReady);
486
+ }
487
+ /**
488
+ * Removes current parent place and updates style to default
489
+ */
490
+ removeParentPlace() {
491
+ this.changeParentPlaceTo(undefined, true);
492
+ }
493
+ /**
494
+ * Applies filters and changes to layers according to given style.
495
+ * Expected to be called every time a new style is loaded
496
+ * @param newStyle
497
+ */
498
+ whenStyleUpdates(newStyle) {
499
+ if (newStyle) {
500
+ this.setBaseFilters(newStyle);
501
+ }
502
+ this.routeController.addSourcesAndLayers();
503
+ this.filterByFloorKey(this.currentFloor);
504
+ }
505
+ addMarker(marker) {
506
+ var _a, _b;
507
+ try {
508
+ // Check if a marker with the same ID already exists and remove it
509
+ if (marker.id) {
510
+ const existingMarkerIndex = this.markers.findIndex((m) => m.id === marker.id);
511
+ if (existingMarkerIndex !== -1) {
512
+ const existingMarker = this.markers[existingMarkerIndex];
513
+ existingMarker.remove();
514
+ this.markers.splice(existingMarkerIndex, 1);
515
+ this.logEvent("removeMarker", {
516
+ markerId: marker.id,
517
+ reason: "duplicate",
518
+ });
519
+ }
520
+ }
521
+ const markerCreated = new MarkerAttribute(marker);
522
+ const isOutdoor = !this.parentPlace ||
523
+ ((_b = (_a = this.innerFloors.find((floor) => floor.key === this.currentFloor)) === null || _a === void 0 ? void 0 : _a.reachableFromGPS) !== null && _b !== void 0 ? _b : false);
524
+ markerCreated.changeFloor(this.currentFloor, this.map, isOutdoor);
525
+ this.markers.push(markerCreated);
526
+ this.logEvent("addMarker");
527
+ return markerCreated.id;
528
+ }
529
+ catch (error) {
530
+ throw new Error("Failed to add marker");
531
+ }
532
+ }
533
+ updateMarker(markerConfig) {
534
+ var _a;
535
+ try {
536
+ const marker = this.markers.find((e) => e.id === markerConfig.id);
537
+ if (marker !== undefined) {
538
+ marker.updateIcon(markerConfig);
539
+ }
540
+ this.logEvent("updateMarker");
541
+ return (_a = marker === null || marker === void 0 ? void 0 : marker.id) !== null && _a !== void 0 ? _a : "";
542
+ }
543
+ catch (error) {
544
+ throw new Error("Failed to update marker");
545
+ }
546
+ }
547
+ updateMarkerPosition(markerId, newPosition) {
548
+ try {
549
+ const marker = this.markers.find((e) => e.id === markerId);
550
+ if (marker !== undefined) {
551
+ marker.setLngLat(newPosition);
552
+ }
553
+ this.logEvent("updateMarkerPosition");
554
+ }
555
+ catch (error) {
556
+ throw new Error("Failed to update marker position");
557
+ }
558
+ }
559
+ showMarker(markerId) {
560
+ try {
561
+ const marker = this.markers.find((e) => e.id === markerId);
562
+ if (marker !== null && this.map) {
563
+ marker === null || marker === void 0 ? void 0 : marker.show(this.map);
564
+ }
565
+ this.logEvent("showMarker");
566
+ }
567
+ catch (error) {
568
+ // Show marker may fail if marker doesn't exist
569
+ }
570
+ }
571
+ hideMarker(markerId) {
572
+ try {
573
+ const marker = this.markers.find((e) => e.id === markerId);
574
+ if (marker !== null) {
575
+ marker === null || marker === void 0 ? void 0 : marker.hide();
576
+ }
577
+ this.logEvent("hideMarker");
578
+ }
579
+ catch (error) {
580
+ // Hide marker may fail if marker doesn't exist
581
+ }
582
+ }
583
+ removeMarker(markerId) {
584
+ try {
585
+ const marker = this.markers.find((e) => e.id === markerId);
586
+ if (marker !== null) {
587
+ marker === null || marker === void 0 ? void 0 : marker.remove();
588
+ this.markers = this.markers.filter((e) => e.id !== markerId);
589
+ }
590
+ this.logEvent("removeMarker");
591
+ }
592
+ catch (error) {
593
+ throw new Error("Failed to remove marker");
594
+ }
595
+ }
596
+ removeAllMarkers() {
597
+ try {
598
+ this.markers.forEach((marker) => {
599
+ marker.remove();
600
+ });
601
+ this.markers = [];
602
+ this.logEvent("removeAllMarkers");
603
+ }
604
+ catch (error) {
605
+ throw new Error("Failed to remove all markers");
606
+ }
607
+ }
608
+ /**
609
+ * Use it to change the current layer
610
+ * @param floorKey floor id
611
+ */
612
+ filterByFloorKey(floorKey) {
613
+ this.currentFloor = floorKey;
614
+ const floorKeyString = floorKey !== null && floorKey !== void 0 ? floorKey : "";
615
+ if (this.innerFloors.every((floor) => floor.key !== floorKey) && floorKey !== "") {
616
+ this.logEvent("invalidFloorKey", { floorKey: floorKeyString });
617
+ }
618
+ this.updateFiltersTo(floorKeyString);
619
+ this.updateMarkersTo(floorKeyString);
620
+ this.routeController.updateRouteLayers(floorKeyString);
621
+ this.routeController.updateRouteMarkerVisibility(floorKeyString);
622
+ }
623
+ getContainer() {
624
+ return this.map.getContainer();
625
+ }
626
+ updateMarkersTo(floorId) {
627
+ var _a, _b;
628
+ const isOutdoor = !this.parentPlace ||
629
+ ((_b = (_a = this.innerFloors.find((floor) => floor.key === floorId)) === null || _a === void 0 ? void 0 : _a.reachableFromGPS) !== null && _b !== void 0 ? _b : false);
630
+ this.markers.forEach((e) => {
631
+ e.changeFloor(floorId, this.map, isOutdoor);
632
+ });
633
+ }
634
+ updateFiltersTo(floorId) {
635
+ var _a, _b, _c, _d;
636
+ if (!this.map)
637
+ return;
638
+ const layers = (_b = (_a = this.map.getStyle()) === null || _a === void 0 ? void 0 : _a.layers) !== null && _b !== void 0 ? _b : [];
639
+ layers
640
+ .filter((l) => l.id.startsWith("base-indoor-"))
641
+ .forEach((l) => {
642
+ this.map.removeLayer(l.id);
643
+ });
644
+ const baseFloorId = (_c = this.innerFloors.find((floor) => floor.key === floorId)) === null || _c === void 0 ? void 0 : _c.baseFloor;
645
+ const indoorLayers = layers.filter((layer) => layer.id.startsWith("indoor-"));
646
+ if (baseFloorId != undefined) {
647
+ const firstLayerId = (_d = indoorLayers[0]) === null || _d === void 0 ? void 0 : _d.id;
648
+ indoorLayers
649
+ .filter((layer) => layer.type !== "fill-extrusion")
650
+ .forEach((layer) => {
651
+ const baseLayer = deepClone(layer);
652
+ baseLayer.id = "base-" + layer.id;
653
+ this.baseFilters[baseLayer.id] = this.baseFilters[layer.id];
654
+ this.map.addLayer(baseLayer, firstLayerId);
655
+ this.applyLayerFilters(baseLayer, baseFloorId);
656
+ });
657
+ }
658
+ indoorLayers.forEach((layer) => {
659
+ this.applyLayerFilters(layer, floorId);
660
+ });
661
+ }
662
+ applyLayerFilters(layer, floorId) {
663
+ var _a;
664
+ let baseFilter = this.baseFilters[layer.id];
665
+ const floorIdString = floorId !== null && floorId !== void 0 ? floorId : "";
666
+ const floorFilter = [
667
+ "any",
668
+ ["in", floorIdString, ["get", "floor_key"]],
669
+ ];
670
+ const publicPlaceFilter = ["==", ["get", "public_place"], true];
671
+ const subPlaceFilter = [
672
+ "!",
673
+ ["in", (_a = this.parentPlaceId) !== null && _a !== void 0 ? _a : "noRef", ["get", "is_subplace"]],
674
+ ];
675
+ const showInFloorFilter = [
676
+ "in",
677
+ floorIdString,
678
+ ["get", "show_in_floor"],
679
+ ];
680
+ let basicFilters = publicPlaceFilter;
681
+ if (this.parentPlaceId != null) {
682
+ basicFilters = ["any", floorFilter, publicPlaceFilter];
683
+ }
684
+ const customFilters = [
685
+ "all",
686
+ basicFilters,
687
+ ["any", subPlaceFilter, showInFloorFilter],
688
+ ];
689
+ if (layer.id.includes("hover")) {
690
+ baseFilter = ["in", this.hoveredId, ["get", "ref"]];
691
+ }
692
+ else if (!layer.id.includes("colored") &&
693
+ (layer.type == "fill" || layer.type === "fill-extrusion")) {
694
+ customFilters.push(["!", ["in", this.hoveredId, ["get", "ref"]]]);
695
+ }
696
+ if (baseFilter != null) {
697
+ const finalFilter = ["all", baseFilter, customFilters];
698
+ this.map.setFilter(layer.id, finalFilter);
699
+ }
700
+ else {
701
+ this.map.setFilter(layer.id, customFilters);
702
+ }
703
+ }
704
+ /**
705
+ * Floors of the parent place
706
+ * @returns Inner floors of the parent place
707
+ */
708
+ getInnerFloors() {
709
+ return this.innerFloors;
710
+ }
711
+ updateCamera(newCamera, callback) {
712
+ void this.map.once("moveend", callback);
713
+ this.map.easeTo(Object.assign({}, newCamera));
714
+ }
715
+ setMaxZoom(zoomLvl, options) {
716
+ var _a;
717
+ this.map.setMaxZoom(zoomLvl);
718
+ (_a = options === null || options === void 0 ? void 0 : options.onComplete) === null || _a === void 0 ? void 0 : _a.call(options);
719
+ }
720
+ setMinZoom(zoomLvl, options) {
721
+ var _a;
722
+ this.map.setMinZoom(zoomLvl);
723
+ (_a = options === null || options === void 0 ? void 0 : options.onComplete) === null || _a === void 0 ? void 0 : _a.call(options);
724
+ }
725
+ isInsideBounds(point) {
726
+ const mapBounds = this.map.getMaxBounds();
727
+ if (mapBounds != null) {
728
+ return mapBounds.contains(point);
729
+ }
730
+ return true;
731
+ }
732
+ setMaxBounds(coordinates, options) {
733
+ var _a;
734
+ if (coordinates.length > 1) {
735
+ const boundingBox = getBoundingBox(coordinates);
736
+ this.map.setMaxBounds(new LngLatBounds([boundingBox[0].lng, boundingBox[0].lat], [boundingBox[1].lng, boundingBox[1].lat]));
737
+ }
738
+ (_a = options === null || options === void 0 ? void 0 : options.onComplete) === null || _a === void 0 ? void 0 : _a.call(options);
739
+ }
740
+ fitCoordinates(coordinates, options) {
741
+ if (coordinates.length === 0) {
742
+ return;
743
+ }
744
+ const onComplete = options === null || options === void 0 ? void 0 : options.onComplete;
745
+ if (coordinates.length === 1) {
746
+ const [coord] = coordinates;
747
+ if (onComplete) {
748
+ void this.map.once("moveend", onComplete);
749
+ }
750
+ this.map.setCenter({
751
+ lat: coord.lat,
752
+ lng: coord.lng,
753
+ });
754
+ }
755
+ else {
756
+ let minLat;
757
+ let minLng;
758
+ let maxLat;
759
+ let maxLng;
760
+ for (const coord of coordinates) {
761
+ const { lat, lng } = coord;
762
+ minLat = minLat === undefined ? lat : Math.min(minLat, lat);
763
+ minLng = minLng === undefined ? lng : Math.min(minLng, lng);
764
+ maxLat = maxLat === undefined ? lat : Math.max(maxLat, lat);
765
+ maxLng = maxLng === undefined ? lng : Math.max(maxLng, lng);
766
+ }
767
+ const bounds = [
768
+ minLng !== null && minLng !== void 0 ? minLng : 0,
769
+ minLat !== null && minLat !== void 0 ? minLat : 0,
770
+ maxLng !== null && maxLng !== void 0 ? maxLng : 0,
771
+ maxLat !== null && maxLat !== void 0 ? maxLat : 0,
772
+ ];
773
+ // Get container dimensions for percentage-based padding calculations
774
+ const container = this.map.getContainer();
775
+ const containerWidth = container.clientWidth;
776
+ const containerHeight = container.clientHeight;
777
+ // Convert padding values with units to pixels
778
+ const padding = convertPaddingToPixels(options === null || options === void 0 ? void 0 : options.padding, containerWidth, containerHeight);
779
+ const fitOptions = Object.assign(Object.assign({}, options), { padding });
780
+ const bearing = this.map.getBearing();
781
+ const pitch = this.map.getPitch();
782
+ fitOptions.bearing = fitOptions.bearing !== undefined ? fitOptions.bearing : bearing;
783
+ fitOptions.pitch = fitOptions.pitch !== undefined ? fitOptions.pitch : pitch;
784
+ if (onComplete) {
785
+ void this.map.once("moveend", onComplete);
786
+ }
787
+ this.map.fitBounds(bounds, fitOptions);
788
+ }
789
+ }
790
+ fitRouteByPlace(route, placeId, options) {
791
+ // Filter steps that belong to the specified place
792
+ const stepsInPlace = route.steps.filter((step) => step.startInsidePlace === placeId || step.endInsidePlace === placeId);
793
+ if (stepsInPlace.length === 0) {
794
+ return;
795
+ }
796
+ // Extract all coordinates from the filtered steps
797
+ const coords = stepsInPlace.flatMap((step) => extractStepCoordinates(step));
798
+ if (coords.length > 0) {
799
+ this.fitCoordinates(coords, options);
800
+ }
801
+ }
802
+ getZoomLevel() {
803
+ return this.map.getZoom();
804
+ }
805
+ updateFloor(floorId, options) {
806
+ var _a, _b;
807
+ try {
808
+ this.filterByFloorKey(floorId);
809
+ (_a = this.onFloorChange) === null || _a === void 0 ? void 0 : _a.call(this, floorId);
810
+ this.logEvent("updateFloor", { floorId });
811
+ (_b = options === null || options === void 0 ? void 0 : options.onComplete) === null || _b === void 0 ? void 0 : _b.call(options);
812
+ }
813
+ catch (error) {
814
+ // Floor update may fail
815
+ }
816
+ }
817
+ updatePlaceAndFloorForRouting(placeId, floorId) {
818
+ var _a;
819
+ try {
820
+ this.updatePlaceAndFloor(placeId, floorId);
821
+ this.updateFiltersTo(floorId);
822
+ this.updateMarkersTo(floorId);
823
+ (_a = this.onFloorChange) === null || _a === void 0 ? void 0 : _a.call(this, floorId);
824
+ this.logEvent("updatePlaceAndFloorForRouting", { floorId });
825
+ }
826
+ catch (error) {
827
+ // Place/floor update for routing may fail
828
+ }
829
+ }
830
+ async addRoute(config, drawConfig = {}) {
831
+ try {
832
+ this.logEvent("addRoute");
833
+ const fetchRouteConfig = new InternalGetRouteConfiguration(config);
834
+ const drawRouteConfig = new InternalDrawRouteConfiguration(drawConfig);
835
+ const route = await this.repository.fetchAndParseRoute(fetchRouteConfig);
836
+ this.routeController.addRoute(route, drawRouteConfig);
837
+ return route;
838
+ }
839
+ catch (error) {
840
+ throw new Error("Error: Failed to add route");
841
+ }
842
+ }
843
+ updateRouteProgress(routeId, position, behindStyle = { type: "Solid", color: "#757575" }) {
844
+ try {
845
+ const behindConfig = new InternalDrawRouteConfiguration({
846
+ routeStyle: behindStyle,
847
+ });
848
+ this.routeController.updateRouteProgress(routeId, position, behindConfig);
849
+ }
850
+ catch (error) {
851
+ // Update may fail if route doesn't exist
852
+ }
853
+ }
854
+ removeRoute(routeId) {
855
+ try {
856
+ this.logEvent("removeRoute");
857
+ this.routeController.removeRoute(routeId);
858
+ }
859
+ catch (error) {
860
+ // Remove route may fail if no route exists
861
+ }
862
+ }
863
+ removeRouteById(routeId) {
864
+ try {
865
+ this.logEvent("removeRouteById");
866
+ this.routeController.removeRoute(routeId);
867
+ }
868
+ catch (error) {
869
+ // Remove route may fail if route doesn't exist
870
+ }
871
+ }
872
+ removeAllRoutes() {
873
+ try {
874
+ this.logEvent("removeAllRoutes");
875
+ this.routeController.removeAllRoutes();
876
+ }
877
+ catch (error) {
878
+ // Remove all routes may fail
879
+ }
880
+ }
881
+ getActiveRouteIds() {
882
+ return this.routeController.getRouteIds();
883
+ }
884
+ addPopOver(popOverConfig) {
885
+ const placeId = popOverConfig.placeId;
886
+ if (placeId !== undefined) {
887
+ const pointedPlace = this.subPlaces.find((subplace) => {
888
+ return subplace.clientId === placeId || subplace.mapvxId === placeId;
889
+ });
890
+ if (pointedPlace !== undefined) {
891
+ new maplibregl.Popup()
892
+ .setLngLat(pointedPlace.position)
893
+ .setHTML(pointedPlace.title)
894
+ .addTo(this.map);
895
+ }
896
+ }
897
+ return "";
898
+ }
899
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
900
+ removePopOver(id) {
901
+ throw Error("Not implemented");
902
+ }
903
+ startClickListener(callback) {
904
+ this.clickCallback = callback;
905
+ }
906
+ stopClickListener() {
907
+ this.clickCallback = undefined;
908
+ }
909
+ defaultClickListener() {
910
+ this.map.on("click", async (e) => {
911
+ var _a, _b;
912
+ const features = this.map.queryRenderedFeatures(e.point);
913
+ // Filter room features by current floor
914
+ const roomFeatures = features.filter((feature) => { var _a; return feature.properties.class === "room" && ((_a = feature.properties) === null || _a === void 0 ? void 0 : _a.floor_key) === this.currentFloor; });
915
+ const touchedFeature = roomFeatures[0];
916
+ const ref = touchedFeature === null || touchedFeature === void 0 ? void 0 : touchedFeature.properties.ref;
917
+ if (ref != null && typeof ref === "string" && ref.length > 0) {
918
+ console.log("touchedFeature", ref);
919
+ // First, search in current subPlaces
920
+ let clickedPlace = this.subPlaces.find((subPlace) => subPlace.mapvxId === ref);
921
+ // If not found, search in subplaces of potential parent places
922
+ if (clickedPlace === undefined) {
923
+ for (const potentialParentPlace of this.potentialParentPlaces) {
924
+ const cachedSubPlaces = this.repository.getCachedSubPlaces(potentialParentPlace.mapvxId);
925
+ if (cachedSubPlaces) {
926
+ clickedPlace = cachedSubPlaces.find((subPlace) => subPlace.mapvxId === ref);
927
+ if (clickedPlace !== undefined) {
928
+ break;
929
+ }
930
+ }
931
+ }
932
+ }
933
+ // As last resort, search in general cache
934
+ if (clickedPlace === undefined) {
935
+ const cachedPlaces = this.repository.getCachedPlaces([ref]);
936
+ if (cachedPlaces.length === 0) {
937
+ console.log("fetching place detail from server", ref);
938
+ clickedPlace = await this.repository.fetchAndParsePlaceDetail(ref);
939
+ }
940
+ else {
941
+ console.log("using cached place detail", ref);
942
+ clickedPlace = cachedPlaces === null || cachedPlaces === void 0 ? void 0 : cachedPlaces[0];
943
+ }
944
+ }
945
+ console.log("clickedPlace", clickedPlace === null || clickedPlace === void 0 ? void 0 : clickedPlace.title);
946
+ const clickedPlaceId = (_b = (_a = clickedPlace === null || clickedPlace === void 0 ? void 0 : clickedPlace.mapvxId) !== null && _a !== void 0 ? _a : clickedPlace === null || clickedPlace === void 0 ? void 0 : clickedPlace.clientId) !== null && _b !== void 0 ? _b : "";
947
+ if (clickedPlace !== undefined && this.clickCallback) {
948
+ this.clickCallback(clickedPlaceId);
949
+ }
950
+ }
951
+ });
952
+ }
953
+ onHover() {
954
+ if (!this.enableHover)
955
+ return;
956
+ this.map.on("mousemove", "hoverable", (e) => {
957
+ var _a;
958
+ const feature = (_a = e.features) === null || _a === void 0 ? void 0 : _a.find((feature) => { var _a, _b; return ((_a = feature.properties.ref) === null || _a === void 0 ? void 0 : _a.length) > 0 && ((_b = feature.properties) === null || _b === void 0 ? void 0 : _b.floor_key) === this.currentFloor; });
959
+ const ref = feature === null || feature === void 0 ? void 0 : feature.properties.ref;
960
+ if (ref != null && typeof ref === "string" && ref.length > 0) {
961
+ this.hoveredId = ref;
962
+ this.updateFiltersTo(this.currentFloor);
963
+ }
964
+ else if (ref === undefined && this.hoveredId !== "unselected") {
965
+ this.hoveredId = "unselected";
966
+ this.updateFiltersTo(this.currentFloor);
967
+ }
968
+ });
969
+ // When the mouse leaves the state-fill layer, update the feature state of the
970
+ // previously hovered feature.
971
+ this.map.on("mouseleave", "hoverable", () => {
972
+ this.hoveredId = "unselected";
973
+ this.updateFiltersTo(this.currentFloor);
974
+ });
975
+ }
976
+ setPlacesAsSelected(placeIds, color) {
977
+ try {
978
+ if (!this.hasLayer("indoor-colored-places")) {
979
+ this.createColoredPlacesLayer();
980
+ }
981
+ const basicFilter = this.createBasicFilters();
982
+ const coloredPlacesFilters = placeIds.map((id) => {
983
+ const filter = ["==", ["get", "ref"], id];
984
+ return filter;
985
+ });
986
+ const placeFilter = ["any", ...coloredPlacesFilters];
987
+ const condition = ["all", placeFilter, basicFilter];
988
+ this.map.setFilter("indoor-colored-places", condition);
989
+ this.baseFilters["indoor-colored-places"] = placeFilter;
990
+ if (color !== undefined) {
991
+ const layer = this.map.getLayer("indoor-colored-places");
992
+ switch (layer === null || layer === void 0 ? void 0 : layer.type) {
993
+ case "fill":
994
+ this.map.setPaintProperty("indoor-colored-places", "fill-color", color);
995
+ break;
996
+ case "fill-extrusion":
997
+ this.map.setPaintProperty("indoor-colored-places", "fill-extrusion-color", color);
998
+ break;
999
+ default:
1000
+ break;
1001
+ }
1002
+ }
1003
+ }
1004
+ catch (error) {
1005
+ // Place selection may fail if layer doesn't exist
1006
+ }
1007
+ }
1008
+ is3DStyle() {
1009
+ const layers = this.map.getStyle().layers;
1010
+ return layers.some((layer) => layer.type === "fill-extrusion");
1011
+ }
1012
+ createColoredPlacesLayer() {
1013
+ if (this.is3DStyle()) {
1014
+ const layer = {
1015
+ id: "indoor-colored-places",
1016
+ type: "fill-extrusion",
1017
+ source: "indoorequal",
1018
+ "source-layer": "area",
1019
+ filter: ["all", ["has", "ref"], ["==", ["get", "ref"], "unselected"]],
1020
+ paint: {
1021
+ "fill-extrusion-height": 2.5,
1022
+ "fill-extrusion-color": "#276EF1",
1023
+ "fill-extrusion-opacity": 0.8,
1024
+ },
1025
+ };
1026
+ this.map.addLayer(layer);
1027
+ }
1028
+ else {
1029
+ const layer = {
1030
+ id: "indoor-colored-places",
1031
+ type: "fill",
1032
+ source: "indoorequal",
1033
+ "source-layer": "area",
1034
+ filter: ["all", ["has", "ref"], ["==", ["get", "ref"], "unselected"]],
1035
+ paint: {
1036
+ "fill-color": "#276EF1",
1037
+ },
1038
+ };
1039
+ this.map.addLayer(layer);
1040
+ }
1041
+ }
1042
+ createBasicFilters() {
1043
+ var _a, _b;
1044
+ const publicPlaceFilter = ["==", ["get", "public_place"], true];
1045
+ const subPlaceFilter = [
1046
+ "!",
1047
+ ["in", (_a = this.parentPlaceId) !== null && _a !== void 0 ? _a : "noRef", ["get", "is_subplace"]],
1048
+ ];
1049
+ const floorId = (_b = this.currentFloor) !== null && _b !== void 0 ? _b : "noRef";
1050
+ const floorFilter = ["in", floorId, ["get", "floor_key"]];
1051
+ const showInFloorFilter = [
1052
+ "in",
1053
+ floorId,
1054
+ ["get", "show_in_floor"],
1055
+ ];
1056
+ let basicFilters = publicPlaceFilter;
1057
+ if (this.parentPlaceId != null) {
1058
+ basicFilters = ["any", floorFilter, publicPlaceFilter];
1059
+ }
1060
+ const customFilters = [
1061
+ "all",
1062
+ basicFilters,
1063
+ ["any", subPlaceFilter, showInFloorFilter],
1064
+ ];
1065
+ return customFilters;
1066
+ }
1067
+ hasLayer(layerId) {
1068
+ const layer = this.map.getLayer(layerId);
1069
+ return layer !== undefined;
1070
+ }
1071
+ clearColoredPlaces() {
1072
+ if (this.hasLayer("indoor-colored-places")) {
1073
+ const condition = ["==", ["get", "ref"], "unselected"];
1074
+ this.baseFilters["indoor-colored-places"] = condition;
1075
+ this.map.setFilter("indoor-colored-places", condition);
1076
+ }
1077
+ }
1078
+ async startAnimateRoute(routeConfig, drawConfig = {}, animationConfig = {}) {
1079
+ try {
1080
+ let route;
1081
+ if (routeConfig instanceof MVXRoute) {
1082
+ route = routeConfig;
1083
+ }
1084
+ else {
1085
+ const fetchRouteConfig = new InternalGetRouteConfiguration(routeConfig);
1086
+ route = await this.repository.fetchAndParseRoute(fetchRouteConfig);
1087
+ }
1088
+ const drawRouteConfig = new InternalAnimationDrawingConfig(drawConfig);
1089
+ const animationRouteConfig = new InternalAnimationConfig(animationConfig);
1090
+ this.routeController.startAnimating(route, drawRouteConfig, animationRouteConfig);
1091
+ return route;
1092
+ }
1093
+ catch (error) {
1094
+ throw new Error("Error: Failed to start animating route");
1095
+ }
1096
+ }
1097
+ async startAnimateRouteV2(routeConfig, drawConfig = {}, animationConfig = {}) {
1098
+ try {
1099
+ let route;
1100
+ if (routeConfig instanceof MVXRoute) {
1101
+ route = routeConfig;
1102
+ }
1103
+ else {
1104
+ const fetchRouteConfig = new InternalGetRouteConfiguration(routeConfig);
1105
+ route = await this.repository.fetchAndParseRouteV2(fetchRouteConfig);
1106
+ }
1107
+ const drawRouteConfig = new InternalAnimationDrawingConfig(drawConfig);
1108
+ const animationRouteConfig = new InternalAnimationConfig(animationConfig);
1109
+ this.routeController.startAnimating(route, drawRouteConfig, animationRouteConfig);
1110
+ return route;
1111
+ }
1112
+ catch (error) {
1113
+ throw new Error("Error: Failed to start animating route");
1114
+ }
1115
+ }
1116
+ pauseAnimateRoute(routeId) {
1117
+ try {
1118
+ this.routeController.pauseAnimation(routeId);
1119
+ this.logEvent("pauseAnimateRoute");
1120
+ }
1121
+ catch (error) {
1122
+ // Pause animation may fail if no animation is running
1123
+ }
1124
+ }
1125
+ resumeAnimateRoute(routeId) {
1126
+ try {
1127
+ this.routeController.resumeAnimation(routeId);
1128
+ this.logEvent("resumeAnimateRoute");
1129
+ }
1130
+ catch (error) {
1131
+ // Resume animation may fail if no animation is paused
1132
+ }
1133
+ }
1134
+ restartAnimateRoute(routeId) {
1135
+ try {
1136
+ this.routeController.restartAnimation(routeId);
1137
+ this.logEvent("restartAnimateRoute");
1138
+ }
1139
+ catch (error) {
1140
+ // Restart animation may fail if no animation exists
1141
+ }
1142
+ }
1143
+ stopAnimateRoute() {
1144
+ this.logWarning(new Error("Not implemented"), {
1145
+ functionName: "stopAnimateRoute",
1146
+ });
1147
+ }
1148
+ async addStepAnimation(routeConfig, drawConfig = {}, animationConfig = {}) {
1149
+ try {
1150
+ let route;
1151
+ if (routeConfig instanceof MVXRoute) {
1152
+ route = routeConfig;
1153
+ }
1154
+ else {
1155
+ const fetchRouteConfig = new InternalGetRouteConfiguration(routeConfig);
1156
+ route = await this.repository.fetchAndParseRoute(fetchRouteConfig);
1157
+ }
1158
+ const drawRouteConfig = new InternalAnimationDrawingConfig(drawConfig);
1159
+ const animationRouteConfig = new InternalAnimationConfig(animationConfig);
1160
+ this.routeController.addStepAnimation(route, drawRouteConfig, animationRouteConfig);
1161
+ this.logEvent("addStepAnimation");
1162
+ return route;
1163
+ }
1164
+ catch (error) {
1165
+ throw new Error("Error: Failed to add step animation");
1166
+ }
1167
+ }
1168
+ async addStepAnimationV2(routeConfig, drawConfig = {}, animationConfig = {}) {
1169
+ try {
1170
+ let route;
1171
+ if (routeConfig instanceof MVXRoute) {
1172
+ route = routeConfig;
1173
+ }
1174
+ else {
1175
+ const fetchRouteConfig = new InternalGetRouteConfiguration(routeConfig);
1176
+ route = await this.repository.fetchAndParseRouteV2(fetchRouteConfig);
1177
+ }
1178
+ const drawRouteConfig = new InternalAnimationDrawingConfig(drawConfig);
1179
+ const animationRouteConfig = new InternalAnimationConfig(animationConfig);
1180
+ this.routeController.addStepAnimation(route, drawRouteConfig, animationRouteConfig);
1181
+ this.logEvent("addStepAnimationV2");
1182
+ return route;
1183
+ }
1184
+ catch (error) {
1185
+ throw new Error("Error: Failed to add step animation");
1186
+ }
1187
+ }
1188
+ nextStepAnimation(routeId) {
1189
+ try {
1190
+ this.routeController.nextStepAnimation(routeId);
1191
+ this.logEvent("nextStepAnimation");
1192
+ }
1193
+ catch (error) {
1194
+ throw new Error("Error: Failed to animate step");
1195
+ }
1196
+ }
1197
+ previousStepAnimation(routeId) {
1198
+ try {
1199
+ this.routeController.previousStepAnimation(routeId);
1200
+ this.logEvent("previousStepAnimation");
1201
+ }
1202
+ catch (error) {
1203
+ const errorMessage = error instanceof Error ? error.message : String(error);
1204
+ throw new Error("Error: Failed to prepare to animate previous step, " + errorMessage);
1205
+ }
1206
+ }
1207
+ centerOnCurrentStepAnimation(routeId) {
1208
+ try {
1209
+ this.routeController.centerOnCurrentStep(routeId);
1210
+ this.logEvent("centerOnCurrentStepAnimation");
1211
+ }
1212
+ catch (error) {
1213
+ const errorMessage = error instanceof Error ? error.message : String(error);
1214
+ throw new Error("Error: Failed to center on current step animation, " + errorMessage);
1215
+ }
1216
+ }
1217
+ addUserLocationTracking(enableHighAccuracy, geoLocation, icon) {
1218
+ const initialCoordinate = {
1219
+ lat: 0.0,
1220
+ lng: 0.0,
1221
+ };
1222
+ let markerIcon;
1223
+ if (icon != null) {
1224
+ markerIcon = icon;
1225
+ }
1226
+ else {
1227
+ const image = new Image(40, 40);
1228
+ image.src = userLocationDataUrl;
1229
+ markerIcon = image;
1230
+ }
1231
+ const markerConfig = {
1232
+ coordinate: initialCoordinate,
1233
+ icon: markerIcon,
1234
+ text: "",
1235
+ };
1236
+ const marker = new MarkerAttribute(markerConfig);
1237
+ marker.addToMap(this.map);
1238
+ this.userLocationMarker = marker;
1239
+ const updateMarker = (position) => {
1240
+ marker.setLngLat([position.coords.longitude, position.coords.latitude]);
1241
+ };
1242
+ this.geoLocation = geoLocation !== null && geoLocation !== void 0 ? geoLocation : navigator.geolocation;
1243
+ this.watchPositionID = this.geoLocation.watchPosition(updateMarker, (error) => {
1244
+ console.error("Error getting user location:", error);
1245
+ }, {
1246
+ enableHighAccuracy: enableHighAccuracy,
1247
+ });
1248
+ }
1249
+ removeUserLocationTracking() {
1250
+ if (this.userLocationMarker !== undefined) {
1251
+ this.userLocationMarker.remove();
1252
+ this.userLocationMarker = undefined;
1253
+ // Check if watchPosition ID is valid and stop tracking
1254
+ if (this.watchPositionID) {
1255
+ this.geoLocation.clearWatch(this.watchPositionID);
1256
+ this.watchPositionID = undefined;
1257
+ }
1258
+ }
1259
+ }
1260
+ getBearing() {
1261
+ return this.map.getBearing();
1262
+ }
1263
+ addBorderToPlaces(placeIds, color, width) {
1264
+ try {
1265
+ if (!this.hasLayer("indoor-bordered-places")) {
1266
+ this.createBorderedPlacesLayer();
1267
+ }
1268
+ const basicFilter = this.createBasicFilters();
1269
+ const coloredPlacesFilters = placeIds.map((id) => {
1270
+ const filter = ["==", ["get", "ref"], id];
1271
+ return filter;
1272
+ });
1273
+ const placeFilter = ["any", ...coloredPlacesFilters];
1274
+ const condition = ["all", placeFilter, basicFilter];
1275
+ this.map.setFilter("indoor-bordered-places", condition);
1276
+ this.baseFilters["indoor-bordered-places"] = placeFilter;
1277
+ if (color !== undefined && width !== undefined) {
1278
+ this.map.setPaintProperty("indoor-bordered-places", "line-color", color);
1279
+ this.map.setPaintProperty("indoor-bordered-places", "line-width", width);
1280
+ }
1281
+ }
1282
+ catch (error) {
1283
+ throw new Error("Failed to add border to places");
1284
+ }
1285
+ }
1286
+ createBorderedPlacesLayer() {
1287
+ const layer = {
1288
+ id: "indoor-bordered-places",
1289
+ type: "line",
1290
+ source: "indoorequal",
1291
+ "source-layer": "area",
1292
+ filter: ["all", ["has", "ref"], ["==", ["get", "ref"], "unselected"]],
1293
+ paint: {
1294
+ "line-color": "#276EF1",
1295
+ "line-width": 4,
1296
+ },
1297
+ };
1298
+ this.map.addLayer(layer);
1299
+ }
1300
+ clearBorderedPlaces() {
1301
+ if (this.hasLayer("indoor-bordered-places")) {
1302
+ const condition = ["==", ["get", "ref"], "unselected"];
1303
+ this.baseFilters["indoor-bordered-places"] = condition;
1304
+ this.map.setFilter("indoor-bordered-places", condition);
1305
+ }
1306
+ }
1307
+ onWebGLContextLost(e) {
1308
+ var _a, _b;
1309
+ e.originalEvent.preventDefault();
1310
+ console.warn("Contexto WebGL perdido 😢");
1311
+ // Intentar restaurar el contexto automáticamente
1312
+ const canvas = (_a = this === null || this === void 0 ? void 0 : this.map) === null || _a === void 0 ? void 0 : _a.getCanvas();
1313
+ const gl = (canvas === null || canvas === void 0 ? void 0 : canvas.getContext("webgl")) || (canvas === null || canvas === void 0 ? void 0 : canvas.getContext("webgl2"));
1314
+ if (gl && gl.isContextLost()) {
1315
+ canvas.addEventListener("webglcontextrestored", () => {
1316
+ console.debug("Contexto WebGL restaurado, forzando re-render");
1317
+ this.map.triggerRepaint(); // forzar repaint
1318
+ this.failedTiles.clear();
1319
+ }, { once: true });
1320
+ const ext = gl.getExtension("WEBGL_lose_context");
1321
+ (_b = ext === null || ext === void 0 ? void 0 : ext.restoreContext) === null || _b === void 0 ? void 0 : _b.call(ext); // si aplica
1322
+ }
1323
+ }
1324
+ onWebGLContextRestored() {
1325
+ console.debug("Evento webglcontextrestored recibido, haciendo map.redraw()");
1326
+ this.map.redraw(); // fuerza un redraw síncrono [oai_citation:0‡maplibre.org](https://www.maplibre.org/maplibre-gl-js/docs/API/classes/Map/?utm_source=chatgpt.com)
1327
+ this.failedTiles.clear();
1328
+ }
1329
+ onSourceData(e) {
1330
+ var _a;
1331
+ // Only track tiles that actually failed to load (not aborted or never loaded)
1332
+ if (e.source.type === "vector" && e.sourceId === "indoorequal" && e.tile && !e.isSourceLoaded) {
1333
+ // Check if tile has an error state before adding to retry queue
1334
+ // Access state property safely as it may not always be available
1335
+ const tileState = (_a = e.tile) === null || _a === void 0 ? void 0 : _a.state;
1336
+ if (tileState === "errored" || tileState === "expired") {
1337
+ this.failedTiles.add(e.tile);
1338
+ }
1339
+ }
1340
+ }
1341
+ onSourceDataAbort(e) {
1342
+ // Remove aborted tiles from retry queue as they shouldn't be retried
1343
+ if (e.source.type === "vector" && e.sourceId === "indoorequal" && e.tile) {
1344
+ this.failedTiles.delete(e.tile);
1345
+ }
1346
+ }
1347
+ subscribeToFailedTiles() {
1348
+ if (this.retryTimer)
1349
+ return;
1350
+ // Store bound functions for proper cleanup
1351
+ this.boundOnSourceData = this.onSourceData.bind(this);
1352
+ this.boundOnSourceDataAbort = this.onSourceDataAbort.bind(this);
1353
+ this.boundOnWebGLContextLost = this.onWebGLContextLost.bind(this);
1354
+ this.boundOnWebGLContextRestored = this.onWebGLContextRestored.bind(this);
1355
+ this.retryTimer = setInterval(() => {
1356
+ if (!this.map.getSource("indoorequal")) {
1357
+ this.failedTiles.clear();
1358
+ return;
1359
+ }
1360
+ const source = this.map.getSource("indoorequal");
1361
+ if (!source || source.type !== "vector") {
1362
+ this.failedTiles.clear();
1363
+ return;
1364
+ }
1365
+ // Process tiles and remove invalid ones
1366
+ const tilesToRetry = [];
1367
+ const tilesToRemove = [];
1368
+ this.failedTiles.forEach((tile) => {
1369
+ // Check if tile is still valid before attempting reload
1370
+ if (!tile || tile.state === "unloaded" || tile.state === "loading") {
1371
+ tilesToRemove.push(tile);
1372
+ return;
1373
+ }
1374
+ // Only retry tiles that are in an error state
1375
+ if (tile.state === "errored" || tile.state === "expired") {
1376
+ tilesToRetry.push(tile);
1377
+ }
1378
+ else {
1379
+ // Tile is in a valid state, remove from retry queue
1380
+ tilesToRemove.push(tile);
1381
+ }
1382
+ });
1383
+ // Remove invalid tiles from the set
1384
+ tilesToRemove.forEach((tile) => this.failedTiles.delete(tile));
1385
+ // Attempt to reload valid failed tiles
1386
+ tilesToRetry.forEach((tile) => {
1387
+ try {
1388
+ // Verify tile still exists and is in a retryable state
1389
+ if (tile && (tile.state === "errored" || tile.state === "expired")) {
1390
+ source.loadTile(tile);
1391
+ }
1392
+ }
1393
+ catch (error) {
1394
+ // If reload fails, remove tile from retry queue - this is expected
1395
+ this.failedTiles.delete(tile);
1396
+ }
1397
+ });
1398
+ }, 1000);
1399
+ this.map.on("sourcedata", this.boundOnSourceData);
1400
+ this.map.on("sourcedataabort", this.boundOnSourceDataAbort);
1401
+ // Escucha el evento de contexto perdido
1402
+ this.map.on("webglcontextlost", this.boundOnWebGLContextLost);
1403
+ // Adicional: escucha evento restauración
1404
+ this.map.on("webglcontextrestored", this.boundOnWebGLContextRestored);
1405
+ }
1406
+ unsubscribeFromFailedTiles() {
1407
+ if (this.retryTimer) {
1408
+ clearInterval(this.retryTimer);
1409
+ this.retryTimer = undefined;
1410
+ }
1411
+ if (this.boundOnSourceData) {
1412
+ this.map.off("sourcedata", this.boundOnSourceData);
1413
+ this.boundOnSourceData = undefined;
1414
+ }
1415
+ if (this.boundOnSourceDataAbort) {
1416
+ this.map.off("sourcedataabort", this.boundOnSourceDataAbort);
1417
+ this.boundOnSourceDataAbort = undefined;
1418
+ }
1419
+ if (this.boundOnWebGLContextLost) {
1420
+ this.map.off("webglcontextlost", this.boundOnWebGLContextLost);
1421
+ this.boundOnWebGLContextLost = undefined;
1422
+ }
1423
+ if (this.boundOnWebGLContextRestored) {
1424
+ this.map.off("webglcontextrestored", this.boundOnWebGLContextRestored);
1425
+ this.boundOnWebGLContextRestored = undefined;
1426
+ }
1427
+ this.failedTiles.clear();
1428
+ }
1429
+ }
1430
+ //# sourceMappingURL=map.js.map