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