web-mojo 2.2.100 → 2.2.102

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 (195) hide show
  1. package/CHANGELOG.md +598 -0
  2. package/README.md +2 -2
  3. package/dist/admin-models.cjs.js +2 -0
  4. package/dist/admin-models.cjs.js.map +1 -0
  5. package/dist/admin-models.es.js +2 -0
  6. package/dist/admin-models.es.js.map +1 -0
  7. package/dist/admin.cjs.js +1 -1
  8. package/dist/admin.css +42 -0
  9. package/dist/admin.es.js +1 -1
  10. package/dist/auth.cjs.js +1 -1
  11. package/dist/auth.es.js +1 -1
  12. package/dist/charts.cjs.js +1 -1
  13. package/dist/charts.cjs.js.map +1 -1
  14. package/dist/charts.css +897 -1
  15. package/dist/charts.es.js +1 -1
  16. package/dist/charts.es.js.map +1 -1
  17. package/dist/chat.css +96 -0
  18. package/dist/chunks/AssistantPanelView-CMRTtoqS.js +2 -0
  19. package/dist/chunks/AssistantPanelView-CMRTtoqS.js.map +1 -0
  20. package/dist/chunks/AssistantPanelView-CaVkWhVD.js +2 -0
  21. package/dist/chunks/AssistantPanelView-CaVkWhVD.js.map +1 -0
  22. package/dist/chunks/ChatView-B73uox2v.js +2 -0
  23. package/dist/chunks/ChatView-B73uox2v.js.map +1 -0
  24. package/dist/chunks/ChatView-W8daOwIo.js +2 -0
  25. package/dist/chunks/ChatView-W8daOwIo.js.map +1 -0
  26. package/dist/chunks/Collection-BZlmtcuL.js +2 -0
  27. package/dist/chunks/Collection-BZlmtcuL.js.map +1 -0
  28. package/dist/chunks/Collection-Bwoq6muu.js +2 -0
  29. package/dist/chunks/Collection-Bwoq6muu.js.map +1 -0
  30. package/dist/chunks/ContextMenu-BPPtuqKk.js +2 -0
  31. package/dist/chunks/ContextMenu-BPPtuqKk.js.map +1 -0
  32. package/dist/chunks/ContextMenu-q76hjQb6.js +2 -0
  33. package/dist/chunks/ContextMenu-q76hjQb6.js.map +1 -0
  34. package/dist/chunks/DataView-BbrwHMV4.js +2 -0
  35. package/dist/chunks/{DataView-6lhf855r.js.map → DataView-BbrwHMV4.js.map} +1 -1
  36. package/dist/chunks/DataView-k-7wmk5_.js +2 -0
  37. package/dist/chunks/{DataView-Bb83ww5U.js.map → DataView-k-7wmk5_.js.map} +1 -1
  38. package/dist/chunks/FormView-DPSuwWMq.js +3 -0
  39. package/dist/chunks/{FormView-DEROOklJ.js.map → FormView-DPSuwWMq.js.map} +1 -1
  40. package/dist/chunks/FormView-Dcy7XOtC.js +3 -0
  41. package/dist/chunks/{FormView-UmvPskWT.js.map → FormView-Dcy7XOtC.js.map} +1 -1
  42. package/dist/chunks/ListView-DHC-yBIw.js +2 -0
  43. package/dist/chunks/ListView-DHC-yBIw.js.map +1 -0
  44. package/dist/chunks/ListView-iGBsD4a7.js +2 -0
  45. package/dist/chunks/ListView-iGBsD4a7.js.map +1 -0
  46. package/dist/chunks/MetricsCountryMapView-CAD9wR_T.js +2 -0
  47. package/dist/chunks/MetricsCountryMapView-CAD9wR_T.js.map +1 -0
  48. package/dist/chunks/MetricsCountryMapView-Dzk3Yrzx.js +2 -0
  49. package/dist/chunks/MetricsCountryMapView-Dzk3Yrzx.js.map +1 -0
  50. package/dist/chunks/Modal-DBJU16cc.js +3 -0
  51. package/dist/chunks/Modal-DBJU16cc.js.map +1 -0
  52. package/dist/chunks/Modal-DuULCMFZ.js +3 -0
  53. package/dist/chunks/Modal-DuULCMFZ.js.map +1 -0
  54. package/dist/chunks/Passkeys-CGRZ8ZMv.js +2 -0
  55. package/dist/chunks/{Passkeys-CIRjqi7n.js.map → Passkeys-CGRZ8ZMv.js.map} +1 -1
  56. package/dist/chunks/Passkeys-Dr8-oSm9.js +2 -0
  57. package/dist/chunks/{Passkeys-BPV1gNkR.js.map → Passkeys-Dr8-oSm9.js.map} +1 -1
  58. package/dist/chunks/TokenManager-CFsr1qUV.js +2 -0
  59. package/dist/chunks/TokenManager-CFsr1qUV.js.map +1 -0
  60. package/dist/chunks/TokenManager-CHQxK_e5.js +2 -0
  61. package/dist/chunks/TokenManager-CHQxK_e5.js.map +1 -0
  62. package/dist/chunks/User-DNQhdBtI.js +2 -0
  63. package/dist/chunks/User-DNQhdBtI.js.map +1 -0
  64. package/dist/chunks/User-Dg7xpYEI.js +2 -0
  65. package/dist/chunks/User-Dg7xpYEI.js.map +1 -0
  66. package/dist/chunks/UserProfileView-B5nczdfw.js +2 -0
  67. package/dist/chunks/UserProfileView-B5nczdfw.js.map +1 -0
  68. package/dist/chunks/UserProfileView-Bpz3VZmP.js +2 -0
  69. package/dist/chunks/UserProfileView-Bpz3VZmP.js.map +1 -0
  70. package/dist/chunks/View-C5n3sIFi.js +2 -0
  71. package/dist/chunks/View-C5n3sIFi.js.map +1 -0
  72. package/dist/chunks/View-Yazho7OL.js +2 -0
  73. package/dist/chunks/View-Yazho7OL.js.map +1 -0
  74. package/dist/chunks/WebApp-CeiDNV6L.js +2 -0
  75. package/dist/chunks/WebApp-CeiDNV6L.js.map +1 -0
  76. package/dist/chunks/WebApp-irKlhuFX.js +2 -0
  77. package/dist/chunks/WebApp-irKlhuFX.js.map +1 -0
  78. package/dist/chunks/admin-BkxeK68u.js +2 -0
  79. package/dist/chunks/admin-BkxeK68u.js.map +1 -0
  80. package/dist/chunks/admin-vjoNbv_1.js +2 -0
  81. package/dist/chunks/admin-vjoNbv_1.js.map +1 -0
  82. package/dist/chunks/exportChart-DbsHDCxw.js +2 -0
  83. package/dist/chunks/exportChart-DbsHDCxw.js.map +1 -0
  84. package/dist/chunks/exportChart-Dk8D_du5.js +2 -0
  85. package/dist/chunks/exportChart-Dk8D_du5.js.map +1 -0
  86. package/dist/chunks/index-BNjCQA7q.js +2 -0
  87. package/dist/chunks/{index-CSmG_P2r.js.map → index-BNjCQA7q.js.map} +1 -1
  88. package/dist/chunks/index-DBsIDOAa.js +2 -0
  89. package/dist/chunks/{index-uo77m1wt.js.map → index-DBsIDOAa.js.map} +1 -1
  90. package/dist/chunks/{version-CRfGMZSI.js → version-B0cBv8MN.js} +2 -2
  91. package/dist/chunks/{version-CRfGMZSI.js.map → version-B0cBv8MN.js.map} +1 -1
  92. package/dist/chunks/{version-D-5X69D6.js → version-DtqCY0ZY.js} +2 -2
  93. package/dist/chunks/{version-D-5X69D6.js.map → version-DtqCY0ZY.js.map} +1 -1
  94. package/dist/core.css +306 -0
  95. package/dist/css/web-mojo.css +1 -1
  96. package/dist/docit.cjs.js +1 -1
  97. package/dist/docit.cjs.js.map +1 -1
  98. package/dist/docit.es.js +1 -1
  99. package/dist/docit.es.js.map +1 -1
  100. package/dist/index.cjs.js +1 -1
  101. package/dist/index.cjs.js.map +1 -1
  102. package/dist/index.es.js +1 -1
  103. package/dist/index.es.js.map +1 -1
  104. package/dist/lightbox.cjs.js +1 -1
  105. package/dist/lightbox.cjs.js.map +1 -1
  106. package/dist/lightbox.es.js +1 -1
  107. package/dist/lightbox.es.js.map +1 -1
  108. package/dist/map.cjs.js +1 -1
  109. package/dist/map.cjs.js.map +1 -1
  110. package/dist/map.es.js +1 -1
  111. package/dist/map.es.js.map +1 -1
  112. package/dist/portal.css +86 -0
  113. package/dist/timeline.cjs.js +1 -1
  114. package/dist/timeline.cjs.js.map +1 -1
  115. package/dist/timeline.es.js +1 -1
  116. package/dist/timeline.es.js.map +1 -1
  117. package/dist/user-profile.cjs.js +1 -1
  118. package/dist/user-profile.es.js +1 -1
  119. package/dist/web-mojo.lite.iife.js +4185 -3872
  120. package/dist/web-mojo.lite.iife.js.map +1 -1
  121. package/dist/web-mojo.lite.iife.min.js +301 -323
  122. package/dist/web-mojo.lite.iife.min.js.map +1 -1
  123. package/package.json +7 -2
  124. package/dist/chunks/AssistantPanelView-CZhZmVSG.js +0 -2
  125. package/dist/chunks/AssistantPanelView-CZhZmVSG.js.map +0 -1
  126. package/dist/chunks/AssistantPanelView-WFHYQjq7.js +0 -2
  127. package/dist/chunks/AssistantPanelView-WFHYQjq7.js.map +0 -1
  128. package/dist/chunks/ChatView-Bj3Tvx7a.js +0 -2
  129. package/dist/chunks/ChatView-Bj3Tvx7a.js.map +0 -1
  130. package/dist/chunks/ChatView-Uoqp80PU.js +0 -2
  131. package/dist/chunks/ChatView-Uoqp80PU.js.map +0 -1
  132. package/dist/chunks/Collection-C39Oy2q0.js +0 -2
  133. package/dist/chunks/Collection-C39Oy2q0.js.map +0 -1
  134. package/dist/chunks/Collection-CyK0u557.js +0 -2
  135. package/dist/chunks/Collection-CyK0u557.js.map +0 -1
  136. package/dist/chunks/ContextMenu-D-C7V6J6.js +0 -2
  137. package/dist/chunks/ContextMenu-D-C7V6J6.js.map +0 -1
  138. package/dist/chunks/ContextMenu-hjqR1pGW.js +0 -2
  139. package/dist/chunks/ContextMenu-hjqR1pGW.js.map +0 -1
  140. package/dist/chunks/DataView-6lhf855r.js +0 -2
  141. package/dist/chunks/DataView-Bb83ww5U.js +0 -2
  142. package/dist/chunks/Dialog-B0r9puaZ.js +0 -3
  143. package/dist/chunks/Dialog-B0r9puaZ.js.map +0 -1
  144. package/dist/chunks/Dialog-GzCkpMad.js +0 -3
  145. package/dist/chunks/Dialog-GzCkpMad.js.map +0 -1
  146. package/dist/chunks/FormView-DEROOklJ.js +0 -3
  147. package/dist/chunks/FormView-UmvPskWT.js +0 -3
  148. package/dist/chunks/ListView-D_hOtfWZ.js +0 -2
  149. package/dist/chunks/ListView-D_hOtfWZ.js.map +0 -1
  150. package/dist/chunks/ListView-Jkke6pU1.js +0 -2
  151. package/dist/chunks/ListView-Jkke6pU1.js.map +0 -1
  152. package/dist/chunks/MetricsCountryMapView-UdvJWArx.js +0 -2
  153. package/dist/chunks/MetricsCountryMapView-UdvJWArx.js.map +0 -1
  154. package/dist/chunks/MetricsCountryMapView-jLWCL6Hm.js +0 -2
  155. package/dist/chunks/MetricsCountryMapView-jLWCL6Hm.js.map +0 -1
  156. package/dist/chunks/MetricsMiniChartWidget-CV-McxOl.js +0 -2
  157. package/dist/chunks/MetricsMiniChartWidget-CV-McxOl.js.map +0 -1
  158. package/dist/chunks/MetricsMiniChartWidget-DG0DeDuR.js +0 -2
  159. package/dist/chunks/MetricsMiniChartWidget-DG0DeDuR.js.map +0 -1
  160. package/dist/chunks/MiniPieChart-B3sM4Bjv.js +0 -2
  161. package/dist/chunks/MiniPieChart-B3sM4Bjv.js.map +0 -1
  162. package/dist/chunks/MiniPieChart-DL5Rynvm.js +0 -2
  163. package/dist/chunks/MiniPieChart-DL5Rynvm.js.map +0 -1
  164. package/dist/chunks/MiniSeriesChart-C4DPVbU_.js +0 -2
  165. package/dist/chunks/MiniSeriesChart-C4DPVbU_.js.map +0 -1
  166. package/dist/chunks/MiniSeriesChart-DdNMLwfh.js +0 -2
  167. package/dist/chunks/MiniSeriesChart-DdNMLwfh.js.map +0 -1
  168. package/dist/chunks/Modal-jWZGSSOo.js +0 -2
  169. package/dist/chunks/Modal-jWZGSSOo.js.map +0 -1
  170. package/dist/chunks/Modal-xSaurlfZ.js +0 -2
  171. package/dist/chunks/Modal-xSaurlfZ.js.map +0 -1
  172. package/dist/chunks/Passkeys-BPV1gNkR.js +0 -2
  173. package/dist/chunks/Passkeys-CIRjqi7n.js +0 -2
  174. package/dist/chunks/TokenManager-CKgK0MIz.js +0 -2
  175. package/dist/chunks/TokenManager-CKgK0MIz.js.map +0 -1
  176. package/dist/chunks/TokenManager-Cu0YmxAx.js +0 -2
  177. package/dist/chunks/TokenManager-Cu0YmxAx.js.map +0 -1
  178. package/dist/chunks/UserProfileView-BXT8COCF.js +0 -2
  179. package/dist/chunks/UserProfileView-BXT8COCF.js.map +0 -1
  180. package/dist/chunks/UserProfileView-Slj-9C__.js +0 -2
  181. package/dist/chunks/UserProfileView-Slj-9C__.js.map +0 -1
  182. package/dist/chunks/WebApp-CXkNqtZX.js +0 -2
  183. package/dist/chunks/WebApp-CXkNqtZX.js.map +0 -1
  184. package/dist/chunks/WebApp-m6YeJFWY.js +0 -2
  185. package/dist/chunks/WebApp-m6YeJFWY.js.map +0 -1
  186. package/dist/chunks/WebSocketClient-BQAZr8C4.js +0 -2
  187. package/dist/chunks/WebSocketClient-BQAZr8C4.js.map +0 -1
  188. package/dist/chunks/WebSocketClient-YR5d82h8.js +0 -2
  189. package/dist/chunks/WebSocketClient-YR5d82h8.js.map +0 -1
  190. package/dist/chunks/admin-CpLR06pX.js +0 -2
  191. package/dist/chunks/admin-CpLR06pX.js.map +0 -1
  192. package/dist/chunks/admin-JtLeoEHZ.js +0 -2
  193. package/dist/chunks/admin-JtLeoEHZ.js.map +0 -1
  194. package/dist/chunks/index-CSmG_P2r.js +0 -2
  195. package/dist/chunks/index-uo77m1wt.js +0 -2
@@ -0,0 +1,2 @@
1
+ import{V as t}from"./View-C5n3sIFi.js";import{C as e}from"./Collection-Bwoq6muu.js";class ListViewItem extends t{constructor(t={}){super({className:"list-view-item",...t}),this.selected=!1,this.index=t.index??0,this.listView=t.listView??null,this.template||(this.template='\n <div class="list-item-content" data-action="select">\n {{#model}}\n {{#id}}<span class="item-id">{{id}}</span>{{/id}}\n {{#name}}<span class="item-name">{{name}}</span>{{/name}}\n {{#title}}<span class="item-title">{{title}}</span>{{/title}}\n {{#label}}<span class="item-label">{{label}}</span>{{/label}}\n {{#description}}<p class="item-description">{{description}}</p>{{/description}}\n {{/model}}\n {{^model}}\n <span class="item-empty">No data</span>\n {{/model}}\n </div>\n ')}async onActionSelect(t,e){t.stopPropagation(),this.selected?this.deselect():this.select()}select(){this.selected||(this.selected=!0,this.addClass("selected"),this.emit("item:select",{item:this,model:this.model,index:this.index,data:this.model?.toJSON?this.model.toJSON():this.model}),this.listView&&this.listView.emit("item:select",{item:this,model:this.model,index:this.index,data:this.model?.toJSON?this.model.toJSON():this.model}))}deselect(){this.selected&&(this.selected=!1,this.removeClass("selected"),this.emit("item:deselect",{item:this,model:this.model,index:this.index,data:this.model?.toJSON?this.model.toJSON():this.model}),this.listView&&this.listView.emit("item:deselect",{item:this,model:this.model,index:this.index,data:this.model?.toJSON?this.model.toJSON():this.model}))}async onActionDefault(t,e,i){this.emit("item:click",{item:this,model:this.model,index:this.index,action:t,data:this.model?.toJSON?this.model.toJSON():this.model}),this.listView&&this.listView.emit("item:click",{item:this,model:this.model,index:this.index,action:t,data:this.model?.toJSON?this.model.toJSON():this.model})}setIndex(t){return this.index=t,this.element.setAttribute("data-index",t),this}setSelected(t){return t?this.select():this.deselect(),this}async destroy(){this.listView=null,await super.destroy()}}class ListView extends t{constructor(t={}){super({className:"list-view",template:'\n <div class="list-view-container">\n {{#loading}}\n <div class="list-loading">\n <div class="spinner-border spinner-border-sm" role="status">\n <span class="visually-hidden">Loading...</span>\n </div>\n Loading...\n </div>\n {{/loading}}\n {{^loading}}\n {{#isEmpty}}\n <div class="list-empty">\n {{emptyMessage}}\n </div>\n {{/isEmpty}}\n {{^isEmpty}}\n <div class="list-items" data-container="items"></div>\n {{/isEmpty}}\n {{/loading}}\n </div>\n ',...t}),this.collection=null,this.itemViews=/* @__PURE__ */new Map,this.selectedItems=/* @__PURE__ */new Set,this.itemTemplate=t.itemTemplate||null,this.itemClass=t.itemClass||ListViewItem,this.selectionMode=t.selectionMode||"none",this.emptyMessage=t.emptyMessage||"No items to display",this.loading=!1,this.isEmpty=!0}async onInit(){this._initCollection(this.options.collection||this.options.Collection)}_initCollection(t){if(t)if(t instanceof e)this.setCollection(t);else if("function"==typeof t){const e=new t;this.setCollection(e)}else if(Array.isArray(t)){const i=new e(t);this.setCollection(i)}}setCollection(t){return this.collection===t||(this.collection&&(this.collection.off("add",this._onModelsAdded,this),this.collection.off("remove",this._onModelsRemoved,this),this.collection.off("reset",this._onCollectionReset,this),this.collection.off("fetch:start",this._onFetchStart,this),this.collection.off("fetch:end",this._onFetchEnd,this)),this.collection=t,this.options.defaultQuery&&!this.options.collectionParams&&(this.collection.params={...this.collection.params,...this.options.defaultQuery}),this.options.collectionParams&&(this.collection.params={...this.collection.params,...this.options.collectionParams}),this.collection&&(this.collection.on("add",this._onModelsAdded,this),this.collection.on("remove",this._onModelsRemoved,this),this.collection.on("reset",this._onCollectionReset,this),this.collection.on("fetch:start",this._onFetchStart,this),this.collection.on("fetch:end",this._onFetchEnd,this),!this.collection.restEnabled||this.collection.lastFetchTime||this.collection.options?.preloaded?this._buildItems():this.loading=!0)),this}async _renderChildren(){await super._renderChildren();const t=this.getChildElement("items");t&&this.forEachItem((e,i)=>{t.appendChild(e.element),e.render(!1)})}_buildItems(){if(this._clearItems(),!this.collection||this.collection.isEmpty())return this.isEmpty=!0,void this.emit("list:empty");this.isEmpty=!1,this.collection.forEach((t,e)=>{this._createItemView(t,e)}),this.emit("list:loaded",{count:this.collection.length()}),this.isMounted()&&this.render()}_createItemView(t,e){if(this.itemViews.has(t.id))return;const i=new this.itemClass({model:t,index:e,listView:this,template:this.itemTemplate});return this.itemViews.set(t.id,i),i.on("item:select",this._onItemSelect.bind(this)),i.on("item:deselect",this._onItemDeselect.bind(this)),i}_clearItems(){this.forEachItem(t=>{this.removeChild(t.id)}),this.itemViews.clear(),this.selectedItems.clear()}_onModelsAdded(t){const{models:e}=t;e.forEach(t=>{const e=this.collection.models.indexOf(t);this._createItemView(t,e)}),this.isEmpty=this.collection.isEmpty(),!this.loading&&this.isMounted()&&this.render()}_onModelsRemoved(t){const{models:e}=t;e.forEach(t=>{const e=this.itemViews.get(t.id);e&&(this.removeChild(e.id),this.itemViews.delete(t.id),this.selectedItems.delete(t.id))}),this.isEmpty=this.collection.isEmpty(),!this.loading&&this.isMounted()&&this.render(),this.isEmpty&&this.emit("list:empty")}_onCollectionReset(t){this._buildItems()}_onFetchStart(){this.loading=!0,this.isMounted()&&this.render()}_onFetchEnd(){this.loading=!1,this.isMounted()&&this.render()}_onItemSelect(t){const{model:e,item:i}=t;"none"!==this.selectionMode?("single"===this.selectionMode&&(this.itemViews.forEach((t,i)=>{i!==e.id&&t.selected&&t.deselect()}),this.selectedItems.clear()),this.selectedItems.add(e.id),this.emit("selection:change",{selected:Array.from(this.selectedItems),item:i,model:e})):i.deselect()}_onItemDeselect(t){const{model:e}=t;this.selectedItems.delete(e.id),this.emit("selection:change",{selected:Array.from(this.selectedItems),item:t.item,model:e})}getSelectedItems(){const t=[];return this.selectedItems.forEach(e=>{const i=this.itemViews.get(e);i&&t.push({view:i,model:i.model,data:i.model?.toJSON?i.model.toJSON():i.model})}),t}forEachItem(t,e){if("function"!=typeof t)throw new TypeError("Callback must be a function");let i=0;return this.itemViews.forEach((s,o)=>{t.call(e,s,s.model,i++)}),this}clearSelection(){this.forEachItem(t=>{t.selected&&t.deselect()}),this.selectedItems.clear(),this.emit("selection:change",{selected:[]})}selectItem(t){const e=this.itemViews.get(t);return e&&e.select(),this}deselectItem(t){const e=this.itemViews.get(t);return e&&e.deselect(),this}setItemTemplate(t,e=!1){return this.itemTemplate=t,e&&this.itemViews.size>0&&this.forEachItem(e=>{e.setTemplate(t),e.isMounted()&&e.render()}),this}async onAfterMount(){await super.onAfterMount(),!this.collection||!this.options.fetchOnMount&&this.collection.lastFetchTime||this.collection.fetch()}async refresh(){if(this.collection&&this.collection.restEnabled)return await this.collection.fetch();this._buildItems()}async destroy(){this.collection&&(this.collection.off("add",this._onModelsAdded,this),this.collection.off("remove",this._onModelsRemoved,this),this.collection.off("reset",this._onCollectionReset,this),this.collection.off("fetch:start",this._onFetchStart,this),this.collection.off("fetch:end",this._onFetchEnd,this)),this._clearItems(),await super.destroy()}}export{ListViewItem as L,ListView as a};
2
+ //# sourceMappingURL=ListView-DHC-yBIw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ListView-DHC-yBIw.js","sources":["../../src/core/views/list/ListViewItem.js","../../src/core/views/list/ListView.js"],"sourcesContent":["/**\n * ListViewItem - Individual item view for ListView\n *\n * Each item is its own View with its own model, allowing for\n * independent re-rendering when the model changes.\n *\n * Events:\n * - 'item:click' - Emitted when item is clicked\n * - 'item:select' - Emitted when item is selected\n * - 'item:deselect' - Emitted when item is deselected\n *\n * @example\n * const item = new ListViewItem({\n * model: userModel,\n * template: '<div class=\"user-item\">{{name}} - {{email}}</div>'\n * });\n */\n\nimport View from '@core/View.js';\n\nclass ListViewItem extends View {\n constructor(options = {}) {\n super({\n className: 'list-view-item',\n ...options\n });\n\n // Item-specific properties\n this.selected = false;\n this.index = options.index ?? 0;\n this.listView = options.listView ?? null;\n\n // Default template if none provided\n if (!this.template) {\n this.template = `\n <div class=\"list-item-content\" data-action=\"select\">\n {{#model}}\n {{#id}}<span class=\"item-id\">{{id}}</span>{{/id}}\n {{#name}}<span class=\"item-name\">{{name}}</span>{{/name}}\n {{#title}}<span class=\"item-title\">{{title}}</span>{{/title}}\n {{#label}}<span class=\"item-label\">{{label}}</span>{{/label}}\n {{#description}}<p class=\"item-description\">{{description}}</p>{{/description}}\n {{/model}}\n {{^model}}\n <span class=\"item-empty\">No data</span>\n {{/model}}\n </div>\n `;\n }\n }\n\n /**\n * Handle item selection action\n */\n async onActionSelect(event, _element) {\n event.stopPropagation();\n\n if (this.selected) {\n this.deselect();\n } else {\n this.select();\n }\n }\n\n /**\n * Select this item\n */\n select() {\n if (this.selected) return;\n\n this.selected = true;\n this.addClass('selected');\n\n // Emit selection event with item data\n this.emit('item:select', {\n item: this,\n model: this.model,\n index: this.index,\n data: this.model?.toJSON ? this.model.toJSON() : this.model\n });\n\n // Notify parent ListView if available\n if (this.listView) {\n this.listView.emit('item:select', {\n item: this,\n model: this.model,\n index: this.index,\n data: this.model?.toJSON ? this.model.toJSON() : this.model\n });\n }\n }\n\n /**\n * Deselect this item\n */\n deselect() {\n if (!this.selected) return;\n\n this.selected = false;\n this.removeClass('selected');\n\n // Emit deselection event\n this.emit('item:deselect', {\n item: this,\n model: this.model,\n index: this.index,\n data: this.model?.toJSON ? this.model.toJSON() : this.model\n });\n\n // Notify parent ListView if available\n if (this.listView) {\n this.listView.emit('item:deselect', {\n item: this,\n model: this.model,\n index: this.index,\n data: this.model?.toJSON ? this.model.toJSON() : this.model\n });\n }\n }\n\n /**\n * Handle click events on the item\n */\n async onActionDefault(action, _event, _element) {\n // Emit click event for any action not specifically handled\n this.emit('item:click', {\n item: this,\n model: this.model,\n index: this.index,\n action: action,\n data: this.model?.toJSON ? this.model.toJSON() : this.model\n });\n\n // Notify parent ListView if available\n if (this.listView) {\n this.listView.emit('item:click', {\n item: this,\n model: this.model,\n index: this.index,\n action: action,\n data: this.model?.toJSON ? this.model.toJSON() : this.model\n });\n }\n }\n\n /**\n * Set the item's index in the list\n */\n setIndex(index) {\n this.index = index;\n this.element.setAttribute('data-index', index);\n return this;\n }\n\n /**\n * Update the item's selection state\n */\n setSelected(selected) {\n if (selected) {\n this.select();\n } else {\n this.deselect();\n }\n return this;\n }\n\n /**\n * Override destroy to clean up references\n */\n async destroy() {\n // Remove reference to parent ListView\n this.listView = null;\n\n // Call parent destroy\n await super.destroy();\n }\n}\n\nexport default ListViewItem;\n","/**\n * ListView - Visual list component for Collections\n *\n * Manages a collection of ListViewItem views, each with its own model.\n * When a model changes, only its corresponding ListViewItem re-renders.\n *\n * Events:\n * - 'item:click' - Emitted when any item is clicked\n * - 'item:select' - Emitted when an item is selected\n * - 'item:deselect' - Emitted when an item is deselected\n * - 'selection:change' - Emitted when selection changes\n * - 'list:empty' - Emitted when list becomes empty\n * - 'list:loaded' - Emitted when list is populated\n *\n * @example\n * // Basic usage with custom item template\n * const listView = new ListView({\n * collection: userCollection,\n * itemTemplate: '<div class=\"user-item\">{{name}} - {{email}}</div>',\n * selectionMode: 'single'\n * });\n *\n * // Custom template with model fields\n * const productList = new ListView({\n * collection: productCollection,\n * itemTemplate: `\n * <div class=\"product-card\" data-action=\"select\">\n * <h4>{{name}}</h4>\n * <p class=\"price\">{{price|currency}}</p>\n * <p>{{description|truncate(100)}}</p>\n * </div>\n * `,\n * selectionMode: 'multiple'\n * });\n *\n * // Using custom item class with template\n * const customList = new ListView({\n * collection: myCollection,\n * itemClass: CustomListItem, // Your custom ListViewItem subclass\n * itemTemplate: '<div>{{title}}</div>', // Passed as 'template' to itemClass constructor\n * selectionMode: 'none'\n * });\n *\n * // Dynamic template update\n * listView.setItemTemplate('<div class=\"compact\">{{name}}</div>', true);\n */\n\nimport View from '@core/View.js';\nimport Collection from '@core/Collection.js';\nimport ListViewItem from './ListViewItem.js';\n\nclass ListView extends View {\n constructor(options = {}) {\n super({\n className: 'list-view',\n template: `\n <div class=\"list-view-container\">\n {{#loading}}\n <div class=\"list-loading\">\n <div class=\"spinner-border spinner-border-sm\" role=\"status\">\n <span class=\"visually-hidden\">Loading...</span>\n </div>\n Loading...\n </div>\n {{/loading}}\n {{^loading}}\n {{#isEmpty}}\n <div class=\"list-empty\">\n {{emptyMessage}}\n </div>\n {{/isEmpty}}\n {{^isEmpty}}\n <div class=\"list-items\" data-container=\"items\"></div>\n {{/isEmpty}}\n {{/loading}}\n </div>\n `,\n ...options\n });\n\n // ListView specific properties\n this.collection = null;\n this.itemViews = new Map(); // Map of model.id -> ListViewItem\n this.selectedItems = new Set(); // Set of selected item IDs\n\n // Configuration\n this.itemTemplate = options.itemTemplate || null; // Template passed to each item's view\n this.itemClass = options.itemClass || ListViewItem; // Class for creating item views\n this.selectionMode = options.selectionMode || 'none'; // none, single, multiple\n this.emptyMessage = options.emptyMessage || 'No items to display';\n this.loading = false;\n this.isEmpty = true;\n\n }\n\n /**\n * Override onInit to set up initial state\n */\n async onInit() {\n // Initial render will happen automatically\n this._initCollection(this.options.collection || this.options.Collection);\n }\n\n\n /**\n * Initialize the collection\n */\n _initCollection(collectionOrClass) {\n if (!collectionOrClass) {\n console.log('Collection not provided');\n return;\n };\n\n // Check if it's already a Collection instance\n if (collectionOrClass instanceof Collection) {\n this.setCollection(collectionOrClass);\n }\n // Check if it's a Collection class\n else if (typeof collectionOrClass === 'function') {\n const collection = new collectionOrClass();\n this.setCollection(collection);\n }\n // Check if it's an array of data — Collection's signature is\n // (options, data); first arg may be the array itself.\n else if (Array.isArray(collectionOrClass)) {\n const collection = new Collection(collectionOrClass);\n this.setCollection(collection);\n }\n }\n\n /**\n * Set the collection for this list view\n */\n setCollection(collection) {\n if (this.collection === collection) return this;\n\n // Clean up old collection listeners\n if (this.collection) {\n this.collection.off('add', this._onModelsAdded, this);\n this.collection.off('remove', this._onModelsRemoved, this);\n this.collection.off('reset', this._onCollectionReset, this);\n this.collection.off('fetch:start', this._onFetchStart, this);\n this.collection.off('fetch:end', this._onFetchEnd, this);\n }\n\n this.collection = collection;\n\n if (this.options.defaultQuery && !this.options.collectionParams) {\n this.collection.params = { ...this.collection.params, ...this.options.defaultQuery };\n }\n\n if (this.options.collectionParams) {\n this.collection.params = { ...this.collection.params, ...this.options.collectionParams };\n }\n\n // Set up new collection listeners\n if (this.collection) {\n this.collection.on('add', this._onModelsAdded, this);\n this.collection.on('remove', this._onModelsRemoved, this);\n this.collection.on('reset', this._onCollectionReset, this);\n this.collection.on('fetch:start', this._onFetchStart, this);\n this.collection.on('fetch:end', this._onFetchEnd, this);\n\n // If collection needs an initial fetch, show loading state instead of empty state\n if (this.collection.restEnabled && !this.collection.lastFetchTime && !this.collection.options?.preloaded) {\n this.loading = true;\n } else {\n // Build items for existing models\n this._buildItems();\n }\n }\n\n return this;\n }\n\n async _renderChildren() {\n await super._renderChildren();\n const itemsContainer = this.getChildElement(\"items\");\n if (!itemsContainer) {\n // console.warn('ListView: items container not found');\n return;\n }\n this.forEachItem((item, index) => {\n itemsContainer.appendChild(item.element);\n item.render(false);\n });\n }\n\n /**\n * Build item views for all models in collection\n */\n _buildItems() {\n // Clear existing items\n this._clearItems();\n\n if (!this.collection || this.collection.isEmpty()) {\n this.isEmpty = true;\n this.emit('list:empty');\n return;\n }\n\n this.isEmpty = false;\n\n // Create item views for each model\n this.collection.forEach((model, index) => {\n this._createItemView(model, index);\n });\n\n this.emit('list:loaded', { count: this.collection.length() });\n\n // Render if already mounted\n if (this.isMounted()) {\n this.render();\n }\n }\n\n /**\n * Create an item view for a model\n * The itemTemplate is passed as the template option to the itemClass constructor\n */\n _createItemView(model, index) {\n // Don't create duplicate views\n if (this.itemViews.has(model.id)) return;\n\n const itemView = new this.itemClass({\n model: model,\n index: index,\n listView: this,\n template: this.itemTemplate, // Pass the itemTemplate to the item view\n });\n\n // Store the item view\n this.itemViews.set(model.id, itemView);\n\n // Set up item event listeners\n itemView.on('item:select', this._onItemSelect.bind(this));\n itemView.on('item:deselect', this._onItemDeselect.bind(this));\n\n return itemView;\n }\n\n /**\n * Clear all item views\n */\n _clearItems() {\n this.forEachItem(itemView => {\n this.removeChild(itemView.id);\n });\n this.itemViews.clear();\n this.selectedItems.clear();\n }\n\n /**\n * Handle models added to collection\n */\n _onModelsAdded(event) {\n const { models } = event;\n\n models.forEach(model => {\n const index = this.collection.models.indexOf(model);\n this._createItemView(model, index);\n });\n\n this.isEmpty = this.collection.isEmpty();\n\n // Re-render to show new items\n if (!this.loading && this.isMounted()) {\n this.render();\n }\n }\n\n /**\n * Handle models removed from collection\n */\n _onModelsRemoved(event) {\n const { models } = event;\n\n models.forEach(model => {\n const itemView = this.itemViews.get(model.id);\n if (itemView) {\n this.removeChild(itemView.id);\n this.itemViews.delete(model.id);\n this.selectedItems.delete(model.id);\n }\n });\n\n this.isEmpty = this.collection.isEmpty();\n\n // Re-render to update display\n if (!this.loading && this.isMounted()) {\n this.render();\n }\n\n if (this.isEmpty) {\n this.emit('list:empty');\n }\n }\n\n /**\n * Handle collection reset\n */\n _onCollectionReset(_event) {\n this._buildItems();\n }\n\n /**\n * Handle fetch start\n */\n _onFetchStart() {\n this.loading = true;\n if (this.isMounted()) {\n this.render();\n }\n }\n\n /**\n * Handle fetch end\n */\n _onFetchEnd() {\n this.loading = false;\n if (this.isMounted()) {\n this.render();\n }\n }\n\n /**\n * Handle item selection\n */\n _onItemSelect(event) {\n const { model, item } = event;\n\n if (this.selectionMode === 'none') {\n item.deselect();\n return;\n }\n\n if (this.selectionMode === 'single') {\n // Deselect all other items\n this.itemViews.forEach((view, id) => {\n if (id !== model.id && view.selected) {\n view.deselect();\n }\n });\n this.selectedItems.clear();\n }\n\n this.selectedItems.add(model.id);\n\n this.emit('selection:change', {\n selected: Array.from(this.selectedItems),\n item: item,\n model: model\n });\n }\n\n /**\n * Handle item deselection\n */\n _onItemDeselect(event) {\n const { model } = event;\n\n this.selectedItems.delete(model.id);\n\n this.emit('selection:change', {\n selected: Array.from(this.selectedItems),\n item: event.item,\n model: model\n });\n }\n\n /**\n * Get selected items\n */\n getSelectedItems() {\n const selected = [];\n this.selectedItems.forEach(id => {\n const itemView = this.itemViews.get(id);\n if (itemView) {\n selected.push({\n view: itemView,\n model: itemView.model,\n data: itemView.model?.toJSON ? itemView.model.toJSON() : itemView.model\n });\n }\n });\n return selected;\n }\n\n /**\n * Iterate over each item view in the list\n * @param {function} callback - Function to execute for each item (itemView, model, index)\n * @param {object} thisArg - Optional value to use as this when executing callback\n * @returns {ListView} Returns the ListView for chaining\n */\n forEachItem(callback, thisArg) {\n if (typeof callback !== 'function') {\n throw new TypeError('Callback must be a function');\n }\n\n let index = 0;\n this.itemViews.forEach((itemView, modelId) => {\n callback.call(thisArg, itemView, itemView.model, index++);\n });\n\n return this;\n }\n\n /**\n * Clear selection\n */\n clearSelection() {\n this.forEachItem(itemView => {\n if (itemView.selected) {\n itemView.deselect();\n }\n });\n this.selectedItems.clear();\n\n this.emit('selection:change', {\n selected: []\n });\n }\n\n /**\n * Select item by model ID\n */\n selectItem(modelId) {\n const itemView = this.itemViews.get(modelId);\n if (itemView) {\n itemView.select();\n }\n return this;\n }\n\n /**\n * Deselect item by model ID\n */\n deselectItem(modelId) {\n const itemView = this.itemViews.get(modelId);\n if (itemView) {\n itemView.deselect();\n }\n return this;\n }\n\n /**\n * Set or update the item template\n * @param {string} template - New template string for items\n * @param {boolean} rerender - Whether to re-render existing items with new template\n * @returns {ListView} Returns the ListView for chaining\n */\n setItemTemplate(template, rerender = false) {\n this.itemTemplate = template;\n\n if (rerender && this.itemViews.size > 0) {\n // Update template for all existing item views\n this.forEachItem((itemView) => {\n itemView.setTemplate(template);\n if (itemView.isMounted()) {\n itemView.render();\n }\n });\n }\n\n return this;\n }\n\n async onAfterMount() {\n await super.onAfterMount();\n if (this.collection && (this.options.fetchOnMount || !this.collection.lastFetchTime)) {\n this.collection.fetch();\n }\n }\n\n /**\n * Refresh the list (re-fetch if collection supports it)\n */\n async refresh() {\n if (this.collection && this.collection.restEnabled) {\n return await this.collection.fetch();\n }\n this._buildItems();\n }\n\n /**\n * Override destroy to clean up\n */\n async destroy() {\n // Clean up collection listeners\n if (this.collection) {\n this.collection.off('add', this._onModelsAdded, this);\n this.collection.off('remove', this._onModelsRemoved, this);\n this.collection.off('reset', this._onCollectionReset, this);\n this.collection.off('fetch:start', this._onFetchStart, this);\n this.collection.off('fetch:end', this._onFetchEnd, this);\n }\n\n // Clear items\n this._clearItems();\n\n // Call parent destroy\n await super.destroy();\n }\n}\n\nexport default ListView;\n"],"names":["ListViewItem","View","constructor","options","super","className","this","selected","index","listView","template","onActionSelect","event","_element","stopPropagation","deselect","select","addClass","emit","item","model","data","toJSON","removeClass","onActionDefault","action","_event","setIndex","element","setAttribute","setSelected","destroy","ListView","collection","itemViews","Map","selectedItems","Set","itemTemplate","itemClass","selectionMode","emptyMessage","loading","isEmpty","onInit","_initCollection","Collection","collectionOrClass","setCollection","Array","isArray","off","_onModelsAdded","_onModelsRemoved","_onCollectionReset","_onFetchStart","_onFetchEnd","defaultQuery","collectionParams","params","on","restEnabled","lastFetchTime","preloaded","_buildItems","_renderChildren","itemsContainer","getChildElement","forEachItem","appendChild","render","_clearItems","forEach","_createItemView","count","length","isMounted","has","id","itemView","set","_onItemSelect","bind","_onItemDeselect","removeChild","clear","models","indexOf","get","delete","view","add","from","getSelectedItems","push","callback","thisArg","TypeError","modelId","call","clearSelection","selectItem","deselectItem","setItemTemplate","rerender","size","setTemplate","onAfterMount","fetchOnMount","fetch","refresh"],"mappings":"oFAoBA,MAAMA,qBAAqBC,EACzB,WAAAC,CAAYC,EAAU,IACpBC,MAAM,CACJC,UAAW,oBACRF,IAILG,KAAKC,UAAW,EAChBD,KAAKE,MAAQL,EAAQK,OAAS,EAC9BF,KAAKG,SA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AAKiE,oBAGCnE,MAAM2B,SACd"}
@@ -0,0 +1,2 @@
1
+ "use strict";const t=require("./View-Yazho7OL.js"),e=require("./Collection-BZlmtcuL.js");class ListViewItem extends t.View{constructor(t={}){super({className:"list-view-item",...t}),this.selected=!1,this.index=t.index??0,this.listView=t.listView??null,this.template||(this.template='\n <div class="list-item-content" data-action="select">\n {{#model}}\n {{#id}}<span class="item-id">{{id}}</span>{{/id}}\n {{#name}}<span class="item-name">{{name}}</span>{{/name}}\n {{#title}}<span class="item-title">{{title}}</span>{{/title}}\n {{#label}}<span class="item-label">{{label}}</span>{{/label}}\n {{#description}}<p class="item-description">{{description}}</p>{{/description}}\n {{/model}}\n {{^model}}\n <span class="item-empty">No data</span>\n {{/model}}\n </div>\n ')}async onActionSelect(t,e){t.stopPropagation(),this.selected?this.deselect():this.select()}select(){this.selected||(this.selected=!0,this.addClass("selected"),this.emit("item:select",{item:this,model:this.model,index:this.index,data:this.model?.toJSON?this.model.toJSON():this.model}),this.listView&&this.listView.emit("item:select",{item:this,model:this.model,index:this.index,data:this.model?.toJSON?this.model.toJSON():this.model}))}deselect(){this.selected&&(this.selected=!1,this.removeClass("selected"),this.emit("item:deselect",{item:this,model:this.model,index:this.index,data:this.model?.toJSON?this.model.toJSON():this.model}),this.listView&&this.listView.emit("item:deselect",{item:this,model:this.model,index:this.index,data:this.model?.toJSON?this.model.toJSON():this.model}))}async onActionDefault(t,e,i){this.emit("item:click",{item:this,model:this.model,index:this.index,action:t,data:this.model?.toJSON?this.model.toJSON():this.model}),this.listView&&this.listView.emit("item:click",{item:this,model:this.model,index:this.index,action:t,data:this.model?.toJSON?this.model.toJSON():this.model})}setIndex(t){return this.index=t,this.element.setAttribute("data-index",t),this}setSelected(t){return t?this.select():this.deselect(),this}async destroy(){this.listView=null,await super.destroy()}}class ListView extends t.View{constructor(t={}){super({className:"list-view",template:'\n <div class="list-view-container">\n {{#loading}}\n <div class="list-loading">\n <div class="spinner-border spinner-border-sm" role="status">\n <span class="visually-hidden">Loading...</span>\n </div>\n Loading...\n </div>\n {{/loading}}\n {{^loading}}\n {{#isEmpty}}\n <div class="list-empty">\n {{emptyMessage}}\n </div>\n {{/isEmpty}}\n {{^isEmpty}}\n <div class="list-items" data-container="items"></div>\n {{/isEmpty}}\n {{/loading}}\n </div>\n ',...t}),this.collection=null,this.itemViews=/* @__PURE__ */new Map,this.selectedItems=/* @__PURE__ */new Set,this.itemTemplate=t.itemTemplate||null,this.itemClass=t.itemClass||ListViewItem,this.selectionMode=t.selectionMode||"none",this.emptyMessage=t.emptyMessage||"No items to display",this.loading=!1,this.isEmpty=!0}async onInit(){this._initCollection(this.options.collection||this.options.Collection)}_initCollection(t){if(t)if(t instanceof e.Collection)this.setCollection(t);else if("function"==typeof t){const e=new t;this.setCollection(e)}else if(Array.isArray(t)){const i=new e.Collection(t);this.setCollection(i)}}setCollection(t){return this.collection===t||(this.collection&&(this.collection.off("add",this._onModelsAdded,this),this.collection.off("remove",this._onModelsRemoved,this),this.collection.off("reset",this._onCollectionReset,this),this.collection.off("fetch:start",this._onFetchStart,this),this.collection.off("fetch:end",this._onFetchEnd,this)),this.collection=t,this.options.defaultQuery&&!this.options.collectionParams&&(this.collection.params={...this.collection.params,...this.options.defaultQuery}),this.options.collectionParams&&(this.collection.params={...this.collection.params,...this.options.collectionParams}),this.collection&&(this.collection.on("add",this._onModelsAdded,this),this.collection.on("remove",this._onModelsRemoved,this),this.collection.on("reset",this._onCollectionReset,this),this.collection.on("fetch:start",this._onFetchStart,this),this.collection.on("fetch:end",this._onFetchEnd,this),!this.collection.restEnabled||this.collection.lastFetchTime||this.collection.options?.preloaded?this._buildItems():this.loading=!0)),this}async _renderChildren(){await super._renderChildren();const t=this.getChildElement("items");t&&this.forEachItem((e,i)=>{t.appendChild(e.element),e.render(!1)})}_buildItems(){if(this._clearItems(),!this.collection||this.collection.isEmpty())return this.isEmpty=!0,void this.emit("list:empty");this.isEmpty=!1,this.collection.forEach((t,e)=>{this._createItemView(t,e)}),this.emit("list:loaded",{count:this.collection.length()}),this.isMounted()&&this.render()}_createItemView(t,e){if(this.itemViews.has(t.id))return;const i=new this.itemClass({model:t,index:e,listView:this,template:this.itemTemplate});return this.itemViews.set(t.id,i),i.on("item:select",this._onItemSelect.bind(this)),i.on("item:deselect",this._onItemDeselect.bind(this)),i}_clearItems(){this.forEachItem(t=>{this.removeChild(t.id)}),this.itemViews.clear(),this.selectedItems.clear()}_onModelsAdded(t){const{models:e}=t;e.forEach(t=>{const e=this.collection.models.indexOf(t);this._createItemView(t,e)}),this.isEmpty=this.collection.isEmpty(),!this.loading&&this.isMounted()&&this.render()}_onModelsRemoved(t){const{models:e}=t;e.forEach(t=>{const e=this.itemViews.get(t.id);e&&(this.removeChild(e.id),this.itemViews.delete(t.id),this.selectedItems.delete(t.id))}),this.isEmpty=this.collection.isEmpty(),!this.loading&&this.isMounted()&&this.render(),this.isEmpty&&this.emit("list:empty")}_onCollectionReset(t){this._buildItems()}_onFetchStart(){this.loading=!0,this.isMounted()&&this.render()}_onFetchEnd(){this.loading=!1,this.isMounted()&&this.render()}_onItemSelect(t){const{model:e,item:i}=t;"none"!==this.selectionMode?("single"===this.selectionMode&&(this.itemViews.forEach((t,i)=>{i!==e.id&&t.selected&&t.deselect()}),this.selectedItems.clear()),this.selectedItems.add(e.id),this.emit("selection:change",{selected:Array.from(this.selectedItems),item:i,model:e})):i.deselect()}_onItemDeselect(t){const{model:e}=t;this.selectedItems.delete(e.id),this.emit("selection:change",{selected:Array.from(this.selectedItems),item:t.item,model:e})}getSelectedItems(){const t=[];return this.selectedItems.forEach(e=>{const i=this.itemViews.get(e);i&&t.push({view:i,model:i.model,data:i.model?.toJSON?i.model.toJSON():i.model})}),t}forEachItem(t,e){if("function"!=typeof t)throw new TypeError("Callback must be a function");let i=0;return this.itemViews.forEach((s,o)=>{t.call(e,s,s.model,i++)}),this}clearSelection(){this.forEachItem(t=>{t.selected&&t.deselect()}),this.selectedItems.clear(),this.emit("selection:change",{selected:[]})}selectItem(t){const e=this.itemViews.get(t);return e&&e.select(),this}deselectItem(t){const e=this.itemViews.get(t);return e&&e.deselect(),this}setItemTemplate(t,e=!1){return this.itemTemplate=t,e&&this.itemViews.size>0&&this.forEachItem(e=>{e.setTemplate(t),e.isMounted()&&e.render()}),this}async onAfterMount(){await super.onAfterMount(),!this.collection||!this.options.fetchOnMount&&this.collection.lastFetchTime||this.collection.fetch()}async refresh(){if(this.collection&&this.collection.restEnabled)return await this.collection.fetch();this._buildItems()}async destroy(){this.collection&&(this.collection.off("add",this._onModelsAdded,this),this.collection.off("remove",this._onModelsRemoved,this),this.collection.off("reset",this._onCollectionReset,this),this.collection.off("fetch:start",this._onFetchStart,this),this.collection.off("fetch:end",this._onFetchEnd,this)),this._clearItems(),await super.destroy()}}exports.ListView=ListView,exports.ListViewItem=ListViewItem;
2
+ //# sourceMappingURL=ListView-iGBsD4a7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ListView-iGBsD4a7.js","sources":["../../src/core/views/list/ListViewItem.js","../../src/core/views/list/ListView.js"],"sourcesContent":["/**\n * ListViewItem - Individual item view for ListView\n *\n * Each item is its own View with its own model, allowing for\n * independent re-rendering when the model changes.\n *\n * Events:\n * - 'item:click' - Emitted when item is clicked\n * - 'item:select' - Emitted when item is selected\n * - 'item:deselect' - Emitted when item is deselected\n *\n * @example\n * const item = new ListViewItem({\n * model: userModel,\n * template: '<div class=\"user-item\">{{name}} - {{email}}</div>'\n * });\n */\n\nimport View from '@core/View.js';\n\nclass ListViewItem extends View {\n constructor(options = {}) {\n super({\n className: 'list-view-item',\n ...options\n });\n\n // Item-specific properties\n this.selected = false;\n this.index = options.index ?? 0;\n this.listView = options.listView ?? null;\n\n // Default template if none provided\n if (!this.template) {\n this.template = `\n <div class=\"list-item-content\" data-action=\"select\">\n {{#model}}\n {{#id}}<span class=\"item-id\">{{id}}</span>{{/id}}\n {{#name}}<span class=\"item-name\">{{name}}</span>{{/name}}\n {{#title}}<span class=\"item-title\">{{title}}</span>{{/title}}\n {{#label}}<span class=\"item-label\">{{label}}</span>{{/label}}\n {{#description}}<p class=\"item-description\">{{description}}</p>{{/description}}\n {{/model}}\n {{^model}}\n <span class=\"item-empty\">No data</span>\n {{/model}}\n </div>\n `;\n }\n }\n\n /**\n * Handle item selection action\n */\n async onActionSelect(event, _element) {\n event.stopPropagation();\n\n if (this.selected) {\n this.deselect();\n } else {\n this.select();\n }\n }\n\n /**\n * Select this item\n */\n select() {\n if (this.selected) return;\n\n this.selected = true;\n this.addClass('selected');\n\n // Emit selection event with item data\n this.emit('item:select', {\n item: this,\n model: this.model,\n index: this.index,\n data: this.model?.toJSON ? this.model.toJSON() : this.model\n });\n\n // Notify parent ListView if available\n if (this.listView) {\n this.listView.emit('item:select', {\n item: this,\n model: this.model,\n index: this.index,\n data: this.model?.toJSON ? this.model.toJSON() : this.model\n });\n }\n }\n\n /**\n * Deselect this item\n */\n deselect() {\n if (!this.selected) return;\n\n this.selected = false;\n this.removeClass('selected');\n\n // Emit deselection event\n this.emit('item:deselect', {\n item: this,\n model: this.model,\n index: this.index,\n data: this.model?.toJSON ? this.model.toJSON() : this.model\n });\n\n // Notify parent ListView if available\n if (this.listView) {\n this.listView.emit('item:deselect', {\n item: this,\n model: this.model,\n index: this.index,\n data: this.model?.toJSON ? this.model.toJSON() : this.model\n });\n }\n }\n\n /**\n * Handle click events on the item\n */\n async onActionDefault(action, _event, _element) {\n // Emit click event for any action not specifically handled\n this.emit('item:click', {\n item: this,\n model: this.model,\n index: this.index,\n action: action,\n data: this.model?.toJSON ? this.model.toJSON() : this.model\n });\n\n // Notify parent ListView if available\n if (this.listView) {\n this.listView.emit('item:click', {\n item: this,\n model: this.model,\n index: this.index,\n action: action,\n data: this.model?.toJSON ? this.model.toJSON() : this.model\n });\n }\n }\n\n /**\n * Set the item's index in the list\n */\n setIndex(index) {\n this.index = index;\n this.element.setAttribute('data-index', index);\n return this;\n }\n\n /**\n * Update the item's selection state\n */\n setSelected(selected) {\n if (selected) {\n this.select();\n } else {\n this.deselect();\n }\n return this;\n }\n\n /**\n * Override destroy to clean up references\n */\n async destroy() {\n // Remove reference to parent ListView\n this.listView = null;\n\n // Call parent destroy\n await super.destroy();\n }\n}\n\nexport default ListViewItem;\n","/**\n * ListView - Visual list component for Collections\n *\n * Manages a collection of ListViewItem views, each with its own model.\n * When a model changes, only its corresponding ListViewItem re-renders.\n *\n * Events:\n * - 'item:click' - Emitted when any item is clicked\n * - 'item:select' - Emitted when an item is selected\n * - 'item:deselect' - Emitted when an item is deselected\n * - 'selection:change' - Emitted when selection changes\n * - 'list:empty' - Emitted when list becomes empty\n * - 'list:loaded' - Emitted when list is populated\n *\n * @example\n * // Basic usage with custom item template\n * const listView = new ListView({\n * collection: userCollection,\n * itemTemplate: '<div class=\"user-item\">{{name}} - {{email}}</div>',\n * selectionMode: 'single'\n * });\n *\n * // Custom template with model fields\n * const productList = new ListView({\n * collection: productCollection,\n * itemTemplate: `\n * <div class=\"product-card\" data-action=\"select\">\n * <h4>{{name}}</h4>\n * <p class=\"price\">{{price|currency}}</p>\n * <p>{{description|truncate(100)}}</p>\n * </div>\n * `,\n * selectionMode: 'multiple'\n * });\n *\n * // Using custom item class with template\n * const customList = new ListView({\n * collection: myCollection,\n * itemClass: CustomListItem, // Your custom ListViewItem subclass\n * itemTemplate: '<div>{{title}}</div>', // Passed as 'template' to itemClass constructor\n * selectionMode: 'none'\n * });\n *\n * // Dynamic template update\n * listView.setItemTemplate('<div class=\"compact\">{{name}}</div>', true);\n */\n\nimport View from '@core/View.js';\nimport Collection from '@core/Collection.js';\nimport ListViewItem from './ListViewItem.js';\n\nclass ListView extends View {\n constructor(options = {}) {\n super({\n className: 'list-view',\n template: `\n <div class=\"list-view-container\">\n {{#loading}}\n <div class=\"list-loading\">\n <div class=\"spinner-border spinner-border-sm\" role=\"status\">\n <span class=\"visually-hidden\">Loading...</span>\n </div>\n Loading...\n </div>\n {{/loading}}\n {{^loading}}\n {{#isEmpty}}\n <div class=\"list-empty\">\n {{emptyMessage}}\n </div>\n {{/isEmpty}}\n {{^isEmpty}}\n <div class=\"list-items\" data-container=\"items\"></div>\n {{/isEmpty}}\n {{/loading}}\n </div>\n `,\n ...options\n });\n\n // ListView specific properties\n this.collection = null;\n this.itemViews = new Map(); // Map of model.id -> ListViewItem\n this.selectedItems = new Set(); // Set of selected item IDs\n\n // Configuration\n this.itemTemplate = options.itemTemplate || null; // Template passed to each item's view\n this.itemClass = options.itemClass || ListViewItem; // Class for creating item views\n this.selectionMode = options.selectionMode || 'none'; // none, single, multiple\n this.emptyMessage = options.emptyMessage || 'No items to display';\n this.loading = false;\n this.isEmpty = true;\n\n }\n\n /**\n * Override onInit to set up initial state\n */\n async onInit() {\n // Initial render will happen automatically\n this._initCollection(this.options.collection || this.options.Collection);\n }\n\n\n /**\n * Initialize the collection\n */\n _initCollection(collectionOrClass) {\n if (!collectionOrClass) {\n console.log('Collection not provided');\n return;\n };\n\n // Check if it's already a Collection instance\n if (collectionOrClass instanceof Collection) {\n this.setCollection(collectionOrClass);\n }\n // Check if it's a Collection class\n else if (typeof collectionOrClass === 'function') {\n const collection = new collectionOrClass();\n this.setCollection(collection);\n }\n // Check if it's an array of data — Collection's signature is\n // (options, data); first arg may be the array itself.\n else if (Array.isArray(collectionOrClass)) {\n const collection = new Collection(collectionOrClass);\n this.setCollection(collection);\n }\n }\n\n /**\n * Set the collection for this list view\n */\n setCollection(collection) {\n if (this.collection === collection) return this;\n\n // Clean up old collection listeners\n if (this.collection) {\n this.collection.off('add', this._onModelsAdded, this);\n this.collection.off('remove', this._onModelsRemoved, this);\n this.collection.off('reset', this._onCollectionReset, this);\n this.collection.off('fetch:start', this._onFetchStart, this);\n this.collection.off('fetch:end', this._onFetchEnd, this);\n }\n\n this.collection = collection;\n\n if (this.options.defaultQuery && !this.options.collectionParams) {\n this.collection.params = { ...this.collection.params, ...this.options.defaultQuery };\n }\n\n if (this.options.collectionParams) {\n this.collection.params = { ...this.collection.params, ...this.options.collectionParams };\n }\n\n // Set up new collection listeners\n if (this.collection) {\n this.collection.on('add', this._onModelsAdded, this);\n this.collection.on('remove', this._onModelsRemoved, this);\n this.collection.on('reset', this._onCollectionReset, this);\n this.collection.on('fetch:start', this._onFetchStart, this);\n this.collection.on('fetch:end', this._onFetchEnd, this);\n\n // If collection needs an initial fetch, show loading state instead of empty state\n if (this.collection.restEnabled && !this.collection.lastFetchTime && !this.collection.options?.preloaded) {\n this.loading = true;\n } else {\n // Build items for existing models\n this._buildItems();\n }\n }\n\n return this;\n }\n\n async _renderChildren() {\n await super._renderChildren();\n const itemsContainer = this.getChildElement(\"items\");\n if (!itemsContainer) {\n // console.warn('ListView: items container not found');\n return;\n }\n this.forEachItem((item, index) => {\n itemsContainer.appendChild(item.element);\n item.render(false);\n });\n }\n\n /**\n * Build item views for all models in collection\n */\n _buildItems() {\n // Clear existing items\n this._clearItems();\n\n if (!this.collection || this.collection.isEmpty()) {\n this.isEmpty = true;\n this.emit('list:empty');\n return;\n }\n\n this.isEmpty = false;\n\n // Create item views for each model\n this.collection.forEach((model, index) => {\n this._createItemView(model, index);\n });\n\n this.emit('list:loaded', { count: this.collection.length() });\n\n // Render if already mounted\n if (this.isMounted()) {\n this.render();\n }\n }\n\n /**\n * Create an item view for a model\n * The itemTemplate is passed as the template option to the itemClass constructor\n */\n _createItemView(model, index) {\n // Don't create duplicate views\n if (this.itemViews.has(model.id)) return;\n\n const itemView = new this.itemClass({\n model: model,\n index: index,\n listView: this,\n template: this.itemTemplate, // Pass the itemTemplate to the item view\n });\n\n // Store the item view\n this.itemViews.set(model.id, itemView);\n\n // Set up item event listeners\n itemView.on('item:select', this._onItemSelect.bind(this));\n itemView.on('item:deselect', this._onItemDeselect.bind(this));\n\n return itemView;\n }\n\n /**\n * Clear all item views\n */\n _clearItems() {\n this.forEachItem(itemView => {\n this.removeChild(itemView.id);\n });\n this.itemViews.clear();\n this.selectedItems.clear();\n }\n\n /**\n * Handle models added to collection\n */\n _onModelsAdded(event) {\n const { models } = event;\n\n models.forEach(model => {\n const index = this.collection.models.indexOf(model);\n this._createItemView(model, index);\n });\n\n this.isEmpty = this.collection.isEmpty();\n\n // Re-render to show new items\n if (!this.loading && this.isMounted()) {\n this.render();\n }\n }\n\n /**\n * Handle models removed from collection\n */\n _onModelsRemoved(event) {\n const { models } = event;\n\n models.forEach(model => {\n const itemView = this.itemViews.get(model.id);\n if (itemView) {\n this.removeChild(itemView.id);\n this.itemViews.delete(model.id);\n this.selectedItems.delete(model.id);\n }\n });\n\n this.isEmpty = this.collection.isEmpty();\n\n // Re-render to update display\n if (!this.loading && this.isMounted()) {\n this.render();\n }\n\n if (this.isEmpty) {\n this.emit('list:empty');\n }\n }\n\n /**\n * Handle collection reset\n */\n _onCollectionReset(_event) {\n this._buildItems();\n }\n\n /**\n * Handle fetch start\n */\n _onFetchStart() {\n this.loading = true;\n if (this.isMounted()) {\n this.render();\n }\n }\n\n /**\n * Handle fetch end\n */\n _onFetchEnd() {\n this.loading = false;\n if (this.isMounted()) {\n this.render();\n }\n }\n\n /**\n * Handle item selection\n */\n _onItemSelect(event) {\n const { model, item } = event;\n\n if (this.selectionMode === 'none') {\n item.deselect();\n return;\n }\n\n if (this.selectionMode === 'single') {\n // Deselect all other items\n this.itemViews.forEach((view, id) => {\n if (id !== model.id && view.selected) {\n view.deselect();\n }\n });\n this.selectedItems.clear();\n }\n\n this.selectedItems.add(model.id);\n\n this.emit('selection:change', {\n selected: Array.from(this.selectedItems),\n item: item,\n model: model\n });\n }\n\n /**\n * Handle item deselection\n */\n _onItemDeselect(event) {\n const { model } = event;\n\n this.selectedItems.delete(model.id);\n\n this.emit('selection:change', {\n selected: Array.from(this.selectedItems),\n item: event.item,\n model: model\n });\n }\n\n /**\n * Get selected items\n */\n getSelectedItems() {\n const selected = [];\n this.selectedItems.forEach(id => {\n const itemView = this.itemViews.get(id);\n if (itemView) {\n selected.push({\n view: itemView,\n model: itemView.model,\n data: itemView.model?.toJSON ? itemView.model.toJSON() : itemView.model\n });\n }\n });\n return selected;\n }\n\n /**\n * Iterate over each item view in the list\n * @param {function} callback - Function to execute for each item (itemView, model, index)\n * @param {object} thisArg - Optional value to use as this when executing callback\n * @returns {ListView} Returns the ListView for chaining\n */\n forEachItem(callback, thisArg) {\n if (typeof callback !== 'function') {\n throw new TypeError('Callback must be a function');\n }\n\n let index = 0;\n this.itemViews.forEach((itemView, modelId) => {\n callback.call(thisArg, itemView, itemView.model, index++);\n });\n\n return this;\n }\n\n /**\n * Clear selection\n */\n clearSelection() {\n this.forEachItem(itemView => {\n if (itemView.selected) {\n itemView.deselect();\n }\n });\n this.selectedItems.clear();\n\n this.emit('selection:change', {\n selected: []\n });\n }\n\n /**\n * Select item by model ID\n */\n selectItem(modelId) {\n const itemView = this.itemViews.get(modelId);\n if (itemView) {\n itemView.select();\n }\n return this;\n }\n\n /**\n * Deselect item by model ID\n */\n deselectItem(modelId) {\n const itemView = this.itemViews.get(modelId);\n if (itemView) {\n itemView.deselect();\n }\n return this;\n }\n\n /**\n * Set or update the item template\n * @param {string} template - New template string for items\n * @param {boolean} rerender - Whether to re-render existing items with new template\n * @returns {ListView} Returns the ListView for chaining\n */\n setItemTemplate(template, rerender = false) {\n this.itemTemplate = template;\n\n if (rerender && this.itemViews.size > 0) {\n // Update template for all existing item views\n this.forEachItem((itemView) => {\n itemView.setTemplate(template);\n if (itemView.isMounted()) {\n itemView.render();\n }\n });\n }\n\n return this;\n }\n\n async onAfterMount() {\n await super.onAfterMount();\n if (this.collection && (this.options.fetchOnMount || !this.collection.lastFetchTime)) {\n this.collection.fetch();\n }\n }\n\n /**\n * Refresh the list (re-fetch if collection supports it)\n */\n async refresh() {\n if (this.collection && this.collection.restEnabled) {\n return await this.collection.fetch();\n }\n this._buildItems();\n }\n\n /**\n * Override destroy to clean up\n */\n async destroy() {\n // Clean up collection listeners\n if (this.collection) {\n this.collection.off('add', this._onModelsAdded, this);\n this.collection.off('remove', this._onModelsRemoved, this);\n this.collection.off('reset', this._onCollectionReset, this);\n this.collection.off('fetch:start', this._onFetchStart, this);\n this.collection.off('fetch:end', this._onFetchEnd, this);\n }\n\n // Clear items\n this._clearItems();\n\n // Call parent destroy\n await super.destroy();\n }\n}\n\nexport default ListView;\n"],"names":["ListViewItem","View","constructor","options","super","className","this","selected","index","listView","template","onActionSelect","event","_element","stopPropagation","deselect","select","addClass","emit","item","model","data","toJSON","removeClass","onActionDefault","action","_event","setIndex","element","setAttribute","setSelected","destroy","ListView","collection","itemViews","Map","selectedItems","Set","itemTemplate","itemClass","selectionMode","emptyMessage","loading","isEmpty","onInit","_initCollection","Collection","collectionOrClass","setCollection","Array","isArray","off","_onModelsAdded","_onModelsRemoved","_onCollectionReset","_onFetchStart","_onFetchEnd","defaultQuery","collectionParams","params","on","restEnabled","lastFetchTime","preloaded","_buildItems","_renderChildren","itemsContainer","getChildElement","forEachItem","appendChild","render","_clearItems","forEach","_createItemView","count","length","isMounted","has","id","itemView","set","_onItemSelect","bind","_onItemDeselect","removeChild","clear","models","indexOf","get","delete","view","add","from","getSelectedItems","push","callback","thisArg","TypeError","modelId","call","clearSelection","selectItem","deselectItem","setItemTemplate","rerender","size","setTemplate","onAfterMount","fetchOnMount","fetch","refresh"],"mappings":"yFAoBA,MAAMA,qBAAqBC,EAAAA,KACzB,WAAAC,CAAYC,EAAU,IACpBC,MAAM,CACJC,UAAW,oBACRF,IAILG,KAAKC,UAAW,EAChBD,KAAKE,MAAQL,EAAQK,OAAS,EAC9BF,KAAKG,SAAWN,EAAQM,UAAY,KAG/BH,KAAKI,WACRJ,KAAKI,SAAW,+lBAepB,CAKA,oBAAMC,CAAeC,EAAOC,GAC1BD,EAAME,kBAEFR,KAAKC,SACPD,KAAKS,WAELT,KAAKU,QAET,CAKA,MAAAA,GACMV,KAAKC,WAETD,KAAKC,UAAW,EAChBD,KAAKW,SAAS,YAGdX,KAAKY,KAAK,cAAe,CACvBC,KAAMb,KACNc,MAAOd,KAAKc,MACZZ,MAAOF,KAAKE,MACZa,KA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AWzE,KAAK4B,UAAUsD,IAAIU,GAIpC,OAHInB,GACFA,EAAS/D,SAEJV,IACT,CAKA,YAAAgG,CAAaJ,GACX,MAAMnB,EAAWzE,KAAK4B,UAAUsD,IAAIU,GAIpC,OAHInB,GACFA,EAAShE,WAEJT,IACT,CAQA,eAAAiG,CAAgB7F,EAAU8F,GAAW,GAanC,OAZAlG,KAAKgC,aAAe5B,EAEhB8F,GAAYlG,KAAK4B,UAAUuE,KAAO,GAEpCnG,KAAK8D,YAAaW,IAChBA,EAAS2B,YAAYhG,GACjBqE,EAASH,aACXG,EAAST,WAKRhE,IACT,CAEA,kBAAMqG,SACIvG,MAAMuG,gBACRrG,KAAK2B,aAAe3B,KAAKH,QAAQyG,cAAiBtG,KAAK2B,WAAW6B,eAClExD,KAAK2B,WAAW4E,OAExB,CAKA,aAAMC,GACJ,GAAIxG,KAAK2B,YAAc3B,KAAK2B,WAAW4B,YACrC,aAAavD,KAAK2B,WAAW4E,QAE/BvG,KAAK0D,aACP,CAKA,aAAMjC,GAEAzB,KAAK2B,aACP3B,KAAK2B,WAAWkB,IAAI,MAAO7C,KAAK8C,eAAgB9C,MAChDA,KAAK2B,WAAWkB,IAAI,SAAU7C,KAAK+C,iBAAkB/C,MACrDA,KAAK2B,WAAWkB,IAAI,QAAS7C,KAAKgD,mBAAoBhD,MACtDA,KAAK2B,WAAWkB,IAAI,cAAe7C,KAAKiD,cAAejD,MACvDA,KAAK2B,WAAWkB,IAAI,YAAa7C,KAAKkD,YAAalD,OAIrDA,KAAKiE,oBAGCnE,MAAM2B,SACd"}
@@ -0,0 +1,2 @@
1
+ import{V as a}from"./View-C5n3sIFi.js";class MapView extends a{constructor(a={}){super({className:"map-view",...a}),this.markers=a.markers||[],this.center=a.center||null,this.zoom=a.zoom||13,this.height=a.height||400,this.showZoomControl=!1!==a.showZoomControl,this.tileLayer=a.tileLayer||"osm",this.showLeafletBranding=!0===a.showLeafletBranding,this.showLayerControl=!0===a.showLayerControl,this.layerOptions=a.layerOptions||{osm:"OSM",satellite:"Satellite",terrain:"Terrain",dark:"Dark",light:"Light",watercolor:"Watercolor",bw:"B/W",streets:"Streets"};const t=!1!==a.interactive;this.interactive=t,this.scrollZoom=void 0!==a.scrollZoom?!!a.scrollZoom:t,this.dragPan=void 0!==a.dragPan?!!a.dragPan:t,this.doubleClickZoom=void 0!==a.doubleClickZoom?!!a.doubleClickZoom:t,this.keyboard=void 0!==a.keyboard?!!a.keyboard:t,this.touchZoom=void 0!==a.touchZoom?!!a.touchZoom:t,this.map=null,this.leafletMarkers=[],this._tileLayer=null,this.template='\n <div class="map-container">\n <div id="map-{{id}}" style="height: {{height}}px; width: 100%; border-radius: 0.375rem; border: 1px solid #dee2e6;"></div>\n </div>\n '}async onAfterRender(){await this.loadLeaflet(),await this.initializeMap()}async loadLeaflet(){if(window.L)return;const a=new Promise(a=>{const t=document.createElement("link");t.rel="stylesheet",t.href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css",t.onload=a,t.onerror=a,document.head.appendChild(t)}),t=new Promise((a,t)=>{const e=document.createElement("script");e.src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js",e.onload=a,e.onerror=t,document.head.appendChild(e)});await Promise.all([a,t])}getTileLayerUrl(){const a={osm:{url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",attribution:"© OpenStreetMap contributors",maxZoom:19},satellite:{url:"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",attribution:"© Esri",maxZoom:19},terrain:{url:"https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png",attribution:"© OpenTopoMap contributors",maxZoom:17},dark:{url:"https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png",attribution:"© OpenStreetMap contributors © CARTO",maxZoom:20},light:{url:"https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png",attribution:"© OpenStreetMap contributors © CARTO",maxZoom:20},watercolor:{url:"https://tiles.stadiamaps.com/tiles/stamen_watercolor/{z}/{x}/{y}.jpg",attribution:"© Stadia Maps © Stamen Design © OpenStreetMap contributors",maxZoom:16},bw:{url:"https://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}{r}.png",attribution:"© OpenStreetMap contributors © CARTO",maxZoom:20},streets:{url:"https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png",attribution:"© OpenStreetMap contributors © CARTO",maxZoom:20}};return a[this.tileLayer]||a.osm}async initializeMap(){const a=this.element.querySelector(`#map-${this.id}`);if(!a||!window.L)return;let t=this.center;if(!t&&this.markers.length>0&&(t=[this.markers[0].lat,this.markers[0].lng]),t||(t=[0,0]),this.map=window.L.map(a,{center:t,zoom:this.zoom,zoomControl:this.showZoomControl,scrollWheelZoom:this.scrollZoom,dragging:this.dragPan,doubleClickZoom:this.doubleClickZoom,keyboard:this.keyboard,touchZoom:this.touchZoom,boxZoom:this.interactive,tap:this.interactive}),this.map&&this.map.attributionControl&&!1===this.showLeafletBranding)try{this.map.attributionControl.setPrefix("")}catch(n){}const e=this.getTileLayerUrl();if(this._tileLayer=window.L.tileLayer(e.url,{attribution:e.attribution,maxZoom:e.maxZoom}).addTo(this.map),this.showLayerControl){const t=a.parentElement||this.element.querySelector(".map-container");if(t){t.style.position=t.style.position||"relative";const a=document.createElement("select");a.className="form-select form-select-sm",a.style.position="absolute",a.style.top="8px",a.style.right="8px",a.style.zIndex="1000",a.style.maxWidth="180px",a.setAttribute("aria-label","Map tile layer"),Object.entries(this.layerOptions||{}).forEach(([t,e])=>{const n=document.createElement("option");n.value=t,n.textContent=e,t===this.tileLayer&&(n.selected=!0),a.appendChild(n)}),a.addEventListener("change",()=>this.setTileLayer(a.value)),t.appendChild(a)}}this.addMarkers(this.markers),this.markers.length>1&&this.fitBounds(),setTimeout(()=>{this.map&&this.map.invalidateSize()},300)}addMarkers(a){this.map&&Array.isArray(a)&&a.forEach(a=>{const{lat:t,lng:e,popup:n,icon:l}=a;if(!t||!e)return;const i={};l&&(i.icon=window.L.icon(l));const s=window.L.marker([t,e],i).addTo(this.map);n&&s.bindPopup(n),this.leafletMarkers.push(s)})}fitBounds(){if(!this.map||0===this.leafletMarkers.length)return;const a=new window.L.featureGroup(this.leafletMarkers);this.map.fitBounds(a.getBounds().pad(.1))}updateMarkers(a){this.clearMarkers(),this.markers=a,this.addMarkers(a),a.length>1?this.fitBounds():1===a.length&&this.map.setView([a[0].lat,a[0].lng],this.zoom)}clearMarkers(){this.leafletMarkers.forEach(a=>{this.map.removeLayer(a)}),this.leafletMarkers=[]}setView(a,t,e=null){this.map&&this.map.setView([a,t],e||this.zoom)}setZoom(a){this.map&&this.map.setZoom(a)}setTileLayer(a){if(!this.map)return;const t=this.tileLayer;this.tileLayer=a||this.tileLayer;const e=this.getTileLayerUrl();try{this._tileLayer&&this.map.removeLayer(this._tileLayer)}catch(n){}this._tileLayer=window.L.tileLayer(e.url,{attribution:e.attribution,maxZoom:e.maxZoom}).addTo(this.map),this.tileLayer=a||t,setTimeout(()=>{try{this.map.invalidateSize()}catch(n){}},150)}async onBeforeDestroy(){this.map&&(this.map.remove(),this.map=null),await super.onBeforeDestroy()}static async showAsDialog(a={}){const t=new MapView(a),e={title:"Map View",header:!0,body:t,size:"lg",centered:!1,...a.dialogOptions||{}};await t.init(),await t.getApp().showDialog(e)}}const t=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,default:MapView},Symbol.toStringTag,{value:"Module"}));class MapLibreView extends a{constructor(a={}){super({className:"maplibre-view",...a}),this.markers=a.markers||[],this.center=a.center||null,this.zoom=a.zoom||13,this.height=a.height||400,this.pitch=a.pitch||0,this.bearing=a.bearing||0,this.mapStyle=a.style||"streets",this.showNavigationControl=!1!==a.showNavigationControl,this.autoFitBounds=!1!==a.autoFitBounds;const t=!1!==a.interactive;this.interactive=t,this.scrollZoom=void 0!==a.scrollZoom?!!a.scrollZoom:t,this.dragPan=void 0!==a.dragPan?!!a.dragPan:t,this.doubleClickZoom=void 0!==a.doubleClickZoom?!!a.doubleClickZoom:t,this.keyboard=void 0!==a.keyboard?!!a.keyboard:t,this.touchZoom=void 0!==a.touchZoom?!!a.touchZoom:t,this.map=null,this.mapMarkers=[],this.pendingMarkers=[...this.markers],this.lineSources=a.lineSources||[],this.pendingLineData=/* @__PURE__ */new Map,this.template='\n <div class="maplibre-container">\n <div id="maplibre-{{id}}" style="height: {{height}}px; width: 100%; border-radius: 0.375rem; border: 1px solid #dee2e6;"></div>\n </div>\n '}async onAfterRender(){await this.loadMapLibre(),await this.initializeMap()}async loadMapLibre(){if(window.maplibregl)return;const a=document.createElement("link");return a.rel="stylesheet",a.href="https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.css",document.head.appendChild(a),new Promise((a,t)=>{const e=document.createElement("script");e.src="https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.js",e.onload=a,e.onerror=t,document.head.appendChild(e)})}getMapStyle(){const a={streets:"https://demotiles.maplibre.org/style.json",dark:{version:8,sources:{osm:{type:"raster",tiles:["https://a.tile.openstreetmap.org/{z}/{x}/{y}.png"],tileSize:256,attribution:"© OpenStreetMap contributors"}},layers:[{id:"osm",type:"raster",source:"osm"}],glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf"},light:{version:8,sources:{osm:{type:"raster",tiles:["https://a.tile.openstreetmap.org/{z}/{x}/{y}.png"],tileSize:256,attribution:"© OpenStreetMap contributors"}},layers:[{id:"osm",type:"raster",source:"osm"}],glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf"},satellite:{version:8,sources:{satellite:{type:"raster",tiles:["https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"],tileSize:256,attribution:"© Esri"}},layers:[{id:"satellite",type:"raster",source:"satellite"}],glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf"},terrain:{version:8,sources:{terrain:{type:"raster",tiles:["https://a.tile.opentopomap.org/{z}/{x}/{y}.png"],tileSize:256,attribution:"© OpenTopoMap contributors"}},layers:[{id:"terrain",type:"raster",source:"terrain"}],glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf"}};return a[this.mapStyle]||a.streets}async initializeMap(){const a=this.element.querySelector(`#maplibre-${this.id}`);if(!a||!window.maplibregl)return;let t=this.center;!t&&this.markers.length>0&&(t=[this.markers[0].lng,this.markers[0].lat]),t||(t=[0,0]),this.map=new window.maplibregl.Map({container:a,style:this.getMapStyle(),center:t,zoom:this.zoom,pitch:this.pitch,bearing:this.bearing,interactive:this.interactive,scrollZoom:this.scrollZoom,dragPan:this.dragPan,doubleClickZoom:this.doubleClickZoom,keyboard:this.keyboard,touchZoomRotate:this.touchZoom}),this.showNavigationControl&&this.map.addControl(new window.maplibregl.NavigationControl,"top-right"),this.map.on("load",()=>{const a=this.pendingMarkers.length?this.pendingMarkers:this.markers;this.updateMarkers(a),this.lineSources.forEach(a=>this.addLineSource(a)),this.pendingLineData.forEach(a=>this.addLineSource(a)),this.pendingLineData.clear()})}addMarkers(a){this.map&&Array.isArray(a)?a.forEach(a=>{const{lng:t,lat:e,popup:n,color:l,icon:i,size:s}=a;if(!t||!e)return;const r=document.createElement("div");r.className="maplibre-marker";const o=Number(s)||30;r.style.width=`${o}px`,r.style.height=`${o}px`,r.style.borderRadius="50%",r.style.backgroundColor=l||"#3b82f6",r.style.border="3px solid white",r.style.boxShadow="0 2px 4px rgba(0,0,0,0.3)",r.style.cursor="pointer",r.style.display="flex",r.style.alignItems="center",r.style.justifyContent="center",i&&(r.innerHTML=`<i class="${i}" style="color: white;"></i>`);const m=new window.maplibregl.Marker({element:r}).setLngLat([t,e]).addTo(this.map);if(n){const a=new window.maplibregl.Popup({offset:25}).setHTML(n);m.setPopup(a)}this.mapMarkers.push(m)}):this.pendingMarkers=Array.isArray(a)?a:[]}fitBounds(){if(!this.map||0===this.markers.length)return;const a=new window.maplibregl.LngLatBounds;this.markers.forEach(t=>{a.extend([t.lng,t.lat])}),this.map.fitBounds(a,{padding:50,maxZoom:15})}updateMarkers(a){const t=Array.isArray(a)?a:[];this.markers=t,this.pendingMarkers=t,this.map&&(this.clearMarkers(),this.addMarkers(t),this.autoFitBounds&&t.length>1?this.fitBounds():1===t.length&&this.map&&this.map.flyTo({center:[t[0].lng,t[0].lat],zoom:this.zoom}))}clearMarkers(){this.mapMarkers.forEach(a=>{a.remove()}),this.mapMarkers=[]}addLineSource({id:a,data:t,paint:e,layout:n}){if(!a||!t)return;const l=`${a}-source`;this.map?(this.map.getLayer(a)&&this.map.removeLayer(a),this.map.getSource(l)&&this.map.removeSource(l),this.map.addSource(l,{type:"geojson",data:t}),this.map.addLayer({id:a,type:"line",source:l,paint:{"line-color":"#3b82f6","line-width":2,"line-opacity":.6,...e},layout:{"line-cap":"round","line-join":"round",...n}})):this.pendingLineData.set(a,{id:a,data:t,paint:e,layout:n})}updateLineSource(a,{data:t,paint:e,layout:n}={}){if(!a||!t)return;const l=`${a}-source`;this.map?this.map.getSource(l)?(this.map.getSource(l).setData(t),(e||n)&&(e&&Object.entries(e).forEach(([t,e])=>{this.map.setPaintProperty(a,t,e)}),n&&Object.entries(n).forEach(([t,e])=>{this.map.setLayoutProperty(a,t,e)}))):this.addLineSource({id:a,data:t,paint:e,layout:n}):this.pendingLineData.set(a,{id:a,data:t,paint:e,layout:n})}setView(a,t,e=null){this.map&&this.map.flyTo({center:[a,t],zoom:e||this.zoom})}setZoom(a){this.map&&this.map.setZoom(a)}setPitch(a){this.map&&this.map.setPitch(a)}setBearing(a){this.map&&this.map.setBearing(a)}async onBeforeDestroy(){this.map&&(this.map.remove(),this.map=null),await super.onBeforeDestroy()}}const e=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,default:MapLibreView},Symbol.toStringTag,{value:"Module"})),n={AD:{name:"Andorra",lat:42.54859834854764,lng:1.5802243611232873},AE:{name:"United Arab Emirates",lat:24.18250292309135,lng:54.27920525789581},AF:{name:"Afghanistan",lat:34.13402601376932,lng:66.59216131095278},AG:{name:"Antigua and Barbuda",lat:17.07146759372967,lng:-61.78530823226373},AI:{name:"Anguilla",lat:18.222874004219086,lng:-63.06008343771806},AL:{name:"Albania",lat:41.14165894891656,lng:20.061082767269493},AM:{name:"Armenia",lat:40.17841274230679,lng:45.05490831965259},AO:{name:"Angola",lat:-12.167424062667942,lng:17.651768783079},AQ:{name:"Antarctica",lat:-77.16987521415838,lng:-177.56451613408842},AR:{name:"Argentina",lat:-35.697270518120085,lng:-64.53238503843076},AS:{name:"American Samoa",lat:-14.305711987770538,lng:-170.7007316174498},AT:{name:"Austria",lat:47.631858269895794,lng:13.797778364631036},AU:{name:"Australia",lat:-25.697337673983082,lng:134.02277170916162},AW:{name:"Aruba",lat:12.515625722992898,lng:-69.97564014284046},AZ:{name:"Azerbaijan",lat:40.3920509942049,lng:48.634592670644324},BA:{name:"Bosnia and Herzegovina",lat:44.14415356126429,lng:17.83467240787538},BB:{name:"Barbados",lat:13.183219369337529,lng:-59.557383949150285},BD:{name:"Bangladesh",lat:23.673728665121,lng:90.43212562608613},BE:{name:"Belgium",lat:50.6182138854095,lng:4.675010154696485},BF:{name:"Burkina Faso",lat:12.108709036312737,lng:-1.6932816211842325},BG:{name:"Bulgaria",lat:42.82043677302438,lng:25.251739122561908},BH:{name:"Bahrain",lat:26.04798501537066,lng:50.540695402276775},BI:{name:"Burundi",lat:-3.261251993278643,lng:29.88518227845293},BJ:{name:"Benin",lat:9.503013199615893,lng:2.305714528830206},BL:{name:"Saint Barthelemy",lat:17.90561691241738,lng:-62.83051610005156},BM:{name:"Bermuda",lat:32.315067430740726,lng:-64.7458500599169},BN:{name:"Brunei Darussalam",lat:4.543205889917609,lng:114.6430958360464},BO:{name:"Bolivia",lat:-16.7312488393574,lng:-64.45209597511206},BQ:{name:"Bonaire",lat:12.180844982440338,lng:-68.29350445958761},BQ:{name:"Saba",lat:17.632512616389718,lng:-63.23739481909494},BQ:{name:"Saint Eustatius",lat:17.4919042294197,lng:-62.978230589445026},BR:{name:"Brazil",lat:-11.524630416426652,lng:-54.355206608256424},BS:{name:"Bahamas",lat:24.72162633646784,lng:-78.07275370060313},BT:{name:"Bhutan",lat:27.42163933959824,lng:90.46716647173861},BV:{name:"Bouvet Island",lat:-54.42316679395248,lng:3.411969465057627},BW:{name:"Botswana",lat:-22.236609002062902,lng:23.85779956995608},BY:{name:"Belarus",lat:53.46791374543163,lng:27.964252054715104},BZ:{name:"Belize",lat:17.24252476647155,lng:-88.68273510023441},CA:{name:"Canada",lat:57.550480044655636,lng:-98.41680517868062},CC:{name:"Cocos Islands",lat:-12.171249450199545,lng:96.83688767323002},CD:{name:"Congo DRC",lat:-3.338629596207896,lng:23.419827574282188},CF:{name:"Central African Republic",lat:6.331390033944319,lng:20.520743419397256},CG:{name:"Congo",lat:-.7294391595233845,lng:14.879732849491393},CH:{name:"Switzerland",lat:46.73678128684938,lng:8.286928794895285},CI:{name:"Côte d'Ivoire",lat:7.536779279421307,lng:-5.571710194917734},CK:{name:"Cook Islands",lat:-21.222613253399842,lng:-159.78768870952257},CL:{name:"Chile",lat:-37.82938283049967,lng:-70.76863431739216},CM:{name:"Cameroon",lat:6.294168487480992,lng:12.948474142398263},CN:{name:"China",lat:38.07325481105728,lng:104.69113855849604},CO:{name:"Colombia",lat:4.187753877352739,lng:-72.6445066243485},CR:{name:"Costa Rica",lat:9.863467407406214,lng:-84.14673625701816},CU:{name:"Cuba",lat:21.476176522869448,lng:-79.69817857618705},CV:{name:"Cabo Verde",lat:15.076411518651643,lng:-23.63401005900474},CW:{name:"Curacao",lat:12.199996647939832,lng:-68.96939768599042},CX:{name:"Christmas Island",lat:-10.446440802183416,lng:105.70209512200549},CY:{name:"Cyprus",lat:35.11700416345239,lng:33.375346009199205},CZ:{name:"Czech Republic",lat:49.74917370930982,lng:15.383273292023533},DE:{name:"Germany",lat:51.08304539800482,lng:10.426171427430804},DJ:{name:"Djibouti",lat:11.750235727618804,lng:42.613496898789506},DK:{name:"Denmark",lat:56.00118817971057,lng:9.378670542409406},DM:{name:"Dominica",lat:15.429269860940513,lng:-61.360471946942994},DO:{name:"Dominican Republic",lat:18.77954818522993,lng:-70.43495198520012},DZ:{name:"Algeria",lat:28.350969744889056,lng:2.6558464719769135},EC:{name:"Ecuador",lat:-1.5642721388853116,lng:-78.4630326109714},EE:{name:"Estonia",lat:58.648108311231034,lng:25.916870250633806},EG:{name:"Egypt",lat:26.60517034450628,lng:30.240135435012338},ER:{name:"Eritrea",lat:15.005533147667684,lng:39.2672401449901},ES:{name:"Spain",lat:40.365008336683836,lng:-3.6516251409956983},ES:{name:"Canarias",lat:28.297665106525546,lng:-16.53799441021647},ET:{name:"Ethiopia",lat:8.729389557048396,lng:39.914902886544276},FI:{name:"Finland",lat:65.01578959749911,lng:25.65738433454702},FJ:{name:"Fiji",lat:-17.822470952336204,lng:177.98144613732626},FK:{name:"Falkland Islands",lat:-51.75901312766726,lng:-58.746646363799854},FM:{name:"Micronesia",lat:6.8789448129255435,lng:158.2291899444527},FO:{name:"Faroe Islands",lat:62.130896281495346,lng:-6.9811060913122835},FR:{name:"France",lat:46.6423682169416,lng:2.1940236627886227},GA:{name:"Gabon",lat:-.628448459921234,lng:11.839410898545754},GB:{name:"United Kingdom",lat:53.97844735080214,lng:-2.852943909329258},GD:{name:"Grenada",lat:12.112926656338907,lng:-61.67937937204098},GE:{name:"Georgia",lat:42.17986277737226,lng:43.378866534112234},GF:{name:"French Guiana",lat:3.857429742497078,lng:-53.32232307156624},GG:{name:"Guernsey",lat:49.45870771378872,lng:-2.576392582891568},GH:{name:"Ghana",lat:7.94530467243628,lng:-1.219233362526581},GI:{name:"Gibraltar",lat:36.14022671336082,lng:-5.345549484594358},GL:{name:"Greenland",lat:74.16847218965994,lng:-42.07567788066985},GM:{name:"Gambia",lat:13.428617959189328,lng:-15.383380385869662},GN:{name:"Guinea",lat:10.255986541378112,lng:-10.986948848040218},GP:{name:"Guadeloupe",lat:16.24420002705553,lng:-61.54382262282755},GQ:{name:"Equatorial Guinea",lat:1.5954643936590733,lng:10.425456672353823},GR:{name:"Greece",lat:39.42012261727978,lng:23.110368936161876},GS:{name:"South Georgia and South Sandwich Islands",lat:-54.37666443862139,lng:-36.77509575898928},GT:{name:"Guatemala",lat:15.820878515352684,lng:-90.31219349119617},GU:{name:"Guam",lat:13.445430479945276,lng:144.78024458298802},GW:{name:"Guinea-Bissau",lat:11.980075324820504,lng:-14.980186756910847},GY:{name:"Guyana",lat:4.68211981385056,lng:-58.91352612754667},HM:{name:"Heard Island and McDonald Islands",lat:-53.084170035513736,lng:73.49298560844045},HN:{name:"Honduras",lat:14.740370695750006,lng:-86.49251679006962},HR:{name:"Croatia",lat:44.91192100856702,lng:16.625761129583374},HT:{name:"Haiti",lat:18.883520486983567,lng:-72.89291379842},HU:{name:"Hungary",lat:47.22527332486294,lng:19.39620048366142},ID:{name:"Indonesia",lat:.15591979959037652,lng:113.96538246847302},IE:{name:"Ireland",lat:53.30489539816495,lng:-8.241128545554096},IL:{name:"Israel",lat:31.513542220043195,lng:35.027923472437024},IM:{name:"Isle of Man",lat:54.22855301008011,lng:-4.532995055468449},IN:{name:"India",lat:23.586300567746722,lng:81.17300408530181},IO:{name:"British Indian Ocean Territory",lat:-7.323548444385743,lng:72.43501618476016},IQ:{name:"Iraq",lat:33.105075667527906,lng:43.832529181056884},IR:{name:"Iran",lat:32.906023742890056,lng:54.237077001065444},IS:{name:"Iceland",lat:65.12360920205514,lng:-19.05682967106099},IT:{name:"Italy",lat:42.98201127614267,lng:12.763657166123137},JE:{name:"Jersey",lat:49.215396925724306,lng:-2.1291601162653575},JM:{name:"Jamaica",lat:18.12207889341651,lng:-77.30358894542778},JO:{name:"Jordan",lat:31.387064884449156,lng:36.95728884547246},JP:{name:"Japan",lat:36.76738832597829,lng:137.46934234351835},KE:{name:"Kenya",lat:.6899182318376179,lng:37.95309411262371},KG:{name:"Kyrgyzstan",lat:41.35698905438358,lng:74.17532903468319},KH:{name:"Cambodia",lat:12.699186865507775,lng:105.03973078680701},KI:{name:"Kiribati",lat:1.8676673749241066,lng:-157.39024189323504},KM:{name:"Comoros",lat:-11.658861474508491,lng:43.34826587429403},KN:{name:"Saint Kitts and Nevis",lat:17.314736299587768,lng:-62.74560385895787},KP:{name:"North Korea",lat:40.19198091470839,lng:127.3379805653744},KR:{name:"South Korea",lat:36.402386712544114,lng:127.76224551357649},KW:{name:"Kuwait",lat:29.281360965443092,lng:47.56311109320184},KY:{name:"Cayman Islands",lat:19.311231805620288,lng:-81.25203208977878},KZ:{name:"Kazakhstan",lat:47.641465195176835,lng:66.3759193479301},LA:{name:"Laos",lat:18.117282736873282,lng:103.76375899026448},LB:{name:"Lebanon",lat:33.91160170722086,lng:35.89651946324749},LC:{name:"Saint Lucia",lat:13.895749185129906,lng:-60.9689510935251},LI:{name:"Liechtenstein",lat:47.14627562133036,lng:9.547674672376376},LK:{name:"Sri Lanka",lat:7.696630939329944,lng:80.66931169770622},LR:{name:"Liberia",lat:6.52012979398834,lng:-9.258988935497618},LS:{name:"Lesotho",lat:-29.60168116924817,lng:28.24475317864227},LT:{name:"Lithuania",lat:55.29437393417175,lng:23.946021605013534},LU:{name:"Luxembourg",lat:49.77523454542369,lng:6.103230338458876},LV:{name:"Latvia",lat:56.813853047554154,lng:24.693671325654403},LY:{name:"Libya",lat:27.202915771690794,lng:17.91133392454237},MA:{name:"Morocco",lat:28.687598134979325,lng:-8.817212587250811},MC:{name:"Monaco",lat:43.74798224995656,lng:7.412820873271196},MD:{name:"Moldova",lat:47.0725674580696,lng:28.391111865941348},ME:{name:"Montenegro",lat:42.73694835210454,lng:19.29505087156758},MF:{name:"Saint Martin",lat:18.078012113224464,lng:-63.06678525361946},MG:{name:"Madagascar",lat:-19.04163612493041,lng:46.68493466832544},MH:{name:"Marshall Islands",lat:7.307929900994344,lng:168.72016025351076},MK:{name:"North Macedonia",lat:41.59402890143112,lng:21.70998923872772},ML:{name:"Mali",lat:17.168146208584837,lng:-4.346399841781153},MM:{name:"Myanmar",lat:19.901227931399873,lng:97.08892285397344},MN:{name:"Mongolia",lat:47.08644454604851,lng:103.3987360327455},MP:{name:"Northern Mariana Islands",lat:15.178063516432115,lng:145.74119737203134},MQ:{name:"Martinique",lat:14.642697353597645,lng:-61.01432380875083},MR:{name:"Mauritania",lat:20.466731212820022,lng:-10.495079045035716},MS:{name:"Montserrat",lat:16.735363391460357,lng:-62.18693281256255},MT:{name:"Malta",lat:35.890522650899314,lng:14.441922442508494},MU:{name:"Mauritius",lat:-20.28142317475198,lng:57.56415671066546},MV:{name:"Maldives",lat:-.6065577168009924,lng:73.10076245140479},MW:{name:"Malawi",lat:-13.128986464184024,lng:34.23441182298881},MX:{name:"Mexico",lat:23.87436068093592,lng:-101.55399731630118},MY:{name:"Malaysia",lat:3.6716608556387857,lng:114.63330303992869},MZ:{name:"Mozambique",lat:-17.525230309488748,lng:35.208577031290176},NA:{name:"Namibia",lat:-21.90858163281473,lng:18.16451345845268},NC:{name:"New Caledonia",lat:-21.33003372660827,lng:165.50767040438612},NE:{name:"Niger",lat:17.08105392407292,lng:8.86863247002646},NF:{name:"Norfolk Island",lat:-29.037654445046282,lng:167.95259597483337},NG:{name:"Nigeria",lat:9.61029352034213,lng:8.147714845256194},NI:{name:"Nicaragua",lat:12.893566631930554,lng:-85.016088327669},NL:{name:"Netherlands",lat:52.134054128923886,lng:5.554136426128487},NO:{name:"Norway",lat:64.97775882947745,lng:16.670259272390894},NP:{name:"Nepal",lat:28.300920699755657,lng:84.1338898313567},NR:{name:"Nauru",lat:-.5221021440668993,lng:166.92937633139178},NU:{name:"Niue",lat:-19.05230921680393,lng:-169.86878106699083},NZ:{name:"New Zealand",lat:-43.82765432544426,lng:170.69035541428696},OM:{name:"Oman",lat:20.7242833183209,lng:55.841088119829},PA:{name:"Panama",lat:8.439536749576892,lng:-80.14428761482796},PE:{name:"Peru",lat:-8.522717984240291,lng:-74.11416196781884},PF:{name:"French Polynesia",lat:-17.674684080120677,lng:-149.40041671099763},PG:{name:"Papua New Guinea",lat:-7.156912819152135,lng:144.8348942994695},PH:{name:"Philippines",lat:15.586542251094242,lng:121.82208941416745},PK:{name:"Pakistan",lat:30.116188371410882,lng:69.08835090769651},PL:{name:"Poland",lat:52.06848055692473,lng:19.43573279234468},PM:{name:"Saint Pierre and Miquelon",lat:46.95153913615198,lng:-56.32465353437558},PN:{name:"Pitcairn",lat:-24.366121747565458,lng:-128.3149848627581},PR:{name:"Puerto Rico",lat:18.216224086610914,lng:-66.49425339593509},PS:{name:"Palestinian Territory",lat:31.930818736453883,lng:35.24251184154588},PT:{name:"Portugal",lat:39.67529214702138,lng:-7.933662183874006},PW:{name:"Palau",lat:7.534775852547396,lng:134.57965086721052},PY:{name:"Paraguay",lat:-23.42190559259428,lng:-58.38906357428651},QA:{name:"Qatar",lat:25.318528486425386,lng:51.19794918743203},RE:{name:"Réunion",lat:-21.119825460665105,lng:55.54393506194689},RO:{name:"Romania",lat:45.82454894397586,lng:25.094158201563292},RS:{name:"Serbia",lat:44.02679870131969,lng:20.85677444395745},RU:{name:"Russian Federation",lat:59.039434214106194,lng:98.6704990698032},RW:{name:"Rwanda",lat:-2.014687460047154,lng:29.919439681764082},SA:{name:"Saudi Arabia",lat:24.136038144757897,lng:44.600958178225596},SB:{name:"Solomon Islands",lat:-9.613104734596515,lng:160.16475795033884},SC:{name:"Seychelles",lat:-4.660002318822744,lng:55.47250789595527},SD:{name:"Sudan",lat:15.67060230984256,lng:29.951458283594064},SE:{name:"Sweden",lat:62.73420986108448,lng:17.062431988004956},SG:{name:"Singapore",lat:1.3528251890006349,lng:103.81025757634053},SH:{name:"Saint Helena",lat:-15.962963318340398,lng:-5.717391620813109},SI:{name:"Slovenia",lat:46.13759229564504,lng:14.890636899973781},SJ:{name:"Svalbard",lat:78.57318936469626,lng:16.036378851505283},SK:{name:"Slovakia",lat:48.69808390520484,lng:19.581015362490966},SL:{name:"Sierra Leone",lat:8.561330384750587,lng:-11.78656695731115},SM:{name:"San Marino",lat:43.942820729097896,lng:12.461278349581722},SN:{name:"Senegal",lat:14.228861491763402,lng:-14.610875368352305},SO:{name:"Somalia",lat:6.524534573103924,lng:45.40037867243972},SR:{name:"Suriname",lat:4.098723595920171,lng:-55.855514311561286},SS:{name:"South Sudan",lat:7.657782041763295,lng:30.3851856901788},ST:{name:"Sao Tome and Principe",lat:.22744704294793774,lng:6.606158796857607},SV:{name:"El Salvador",lat:13.758041517055418,lng:-88.85911489238985},SX:{name:"Sint Maarten",lat:18.03942608463078,lng:-63.06883135915303},SY:{name:"Syria",lat:35.09751106058316,lng:38.5117323139514},SZ:{name:"Eswatini",lat:-26.562540935608702,lng:31.510685746082007},TC:{name:"Turks and Caicos Islands",lat:21.799865427483745,lng:-71.74058946811508},TD:{name:"Chad",lat:15.283493546654503,lng:18.427113900363025},TF:{name:"Juan De Nova Island",lat:-17.06449193630804,lng:42.74374761089645},TF:{name:"French Southern Territories",lat:-49.26329687105643,lng:69.54686984724839},TF:{name:"Glorioso Islands",lat:-11.566224871643417,lng:47.290948081543384},TG:{name:"Togo",lat:8.660743037717811,lng:.8990857571109684},TH:{name:"Thailand",lat:13.66222784745538,lng:101.08675116214552},TJ:{name:"Tajikistan",lat:38.56933138382972,lng:70.94215281065698},TK:{name:"Tokelau",lat:-9.195174767256544,lng:-171.85265950722743},TL:{name:"Timor-Leste",lat:-8.809894630601962,lng:125.95024049562659},TM:{name:"Turkmenistan",lat:39.06069118001429,lng:58.4577357627054},TN:{name:"Tunisia",lat:34.08636179565723,lng:9.65587551697984},TO:{name:"Tonga",lat:-21.15927212823853,lng:-175.20415878511247},TR:{name:"Turkey",lat:38.93207363123396,lng:35.56886764076691},TT:{name:"Trinidad and Tobago",lat:10.415515638298093,lng:-61.37236579976247},TV:{name:"Tuvalu",lat:-8.514701506447222,lng:179.217833977593},TZ:{name:"Tanzania",lat:-6.355794440041147,lng:34.81832206060381},UA:{name:"Ukraine",lat:48.657532515563794,lng:31.27377208442636},UG:{name:"Uganda",lat:1.2821729218416205,lng:32.34371768463123},UM:{name:"United States Minor Outlying Islands",lat:19.302045812215958,lng:166.63800339749642},US:{name:"United States",lat:38.8208089190304,lng:-96.33161660829639},UY:{name:"Uruguay",lat:-32.78195043831093,lng:-56.01919523458085},UZ:{name:"Uzbekistan",lat:41.4879065244633,lng:63.8548297593985},VA:{name:"Vatican City",lat:41.90402351316735,lng:12.451312917026133},VC:{name:"Saint Vincent and the Grenadines",lat:13.254808122970651,lng:-61.193766354393034},VE:{name:"Venezuela",lat:7.148324760507107,lng:-66.36492135985132},VG:{name:"British Virgin Islands",lat:18.42195819619707,lng:-64.62406519257699},VI:{name:"US Virgin Islands",lat:17.738009708772523,lng:-64.76155341409797},VN:{name:"Vietnam",lat:16.517347170839393,lng:105.91338832758704},VU:{name:"Vanuatu",lat:-15.189132121699332,lng:166.84912735669738},WF:{name:"Wallis and Futuna",lat:-14.283442307826677,lng:-178.12735555777184},WS:{name:"Samoa",lat:-13.634252953274622,lng:-172.44107655740137},YE:{name:"Yemen",lat:16.001392616307445,lng:47.46815793206386},YT:{name:"Mayotte",lat:-12.824468416301052,lng:45.128142327031064},ZA:{name:"South Africa",lat:-28.55361930679731,lng:24.75252746489084},ZM:{name:"Zambia",lat:-13.162832953186246,lng:27.75521363430896},ZW:{name:"Zimbabwe",lat:-18.92700121981475,lng:29.717829640720844}};class MetricsCountryMapView extends a{constructor(a={}){const t=a.height||320;super({className:"metrics-country-map-view",...a}),this.endpoint=a.endpoint||"/api/metrics/fetch",this.account=a.account||"global",this.category=a.category||null,this.slugs=a.slugs||null,this.granularity=a.granularity||"days",this.maxCountries=a.maxCountries||12,this.metricLabel=a.metricLabel||"Events",this.height=t,this.mapStyle=a.mapStyle||"dark",this.mapOptions=a.mapOptions||{},this.showRoutes=!1!==a.showRoutes,this.routeOrigin=a.routeOrigin||{lng:-77.346,lat:38.958,name:"Reston, VA"},this._refreshing=!1}async getTemplate(){return`\n <div class="metrics-country-map">\n <div class="map-container mb-3" data-container="${this.id}-map" style="height:${this.height}px"></div>\n <div class="map-legend small" data-region="legend"></div>\n </div>\n `}async onInit(){this.statusEl=document.createElement("div"),this.statusEl.className="text-muted small px-3 pb-2",this.element.appendChild(this.statusEl),this.mapView=new MapLibreView({containerId:`${this.id}-map`,height:this.height,style:this.mapStyle,zoom:this.mapOptions.zoom??1.3,center:this.mapOptions.center||[10,20],pitch:this.mapOptions.pitch??20,bearing:this.mapOptions.bearing??0,showNavigationControl:this.mapOptions.showNavigationControl??!0,autoFitBounds:this.mapOptions.autoFitBounds??!1,interactive:this.mapOptions.interactive,scrollZoom:this.mapOptions.scrollZoom,dragPan:this.mapOptions.dragPan,doubleClickZoom:this.mapOptions.doubleClickZoom,keyboard:this.mapOptions.keyboard,touchZoom:this.mapOptions.touchZoom}),this.addChild(this.mapView),await this.refresh()}async refresh(){if(!this._refreshing){this._refreshing=!0,this.setStatus("Loading hotspots…");try{const a=await this.fetchMetrics();await this.applyMetrics(a),this.setStatus("")}catch(a){console.error("MetricsCountryMapView refresh error",a),this.setStatus("Unable to load country metrics.")}finally{this._refreshing=!1}}}async fetchMetrics(){const a=this.getApp()?.rest;if(!a)throw new Error("REST client unavailable");const t={account:this.account,granularity:this.granularity,with_labels:!0};if(this.category&&(t.category=this.category),this.slugs){const a=Array.isArray(this.slugs)?this.slugs:[this.slugs];t["slugs[]"]=a}const e=await a.GET(this.endpoint,t);if(!e.success||!e.data?.status)throw new Error(e.data?.error||"Metrics API error");return e.data.data}async applyMetrics(a){const t=a?.data||{},e=a?.labels||[],l=[];if(Object.entries(t).forEach(([a,t])=>{const e=t.reduce((a,t)=>a+(Number(t)||0),0);if(!e)return;const i=n[a.toUpperCase()];i&&l.push({code:a.toUpperCase(),total:e,values:t,centroid:i})}),!l.length)return this.mapView.updateMarkers([]),this.renderLegend([]),void this.setStatus("No country data available for the selected range.");l.sort((a,t)=>t.total-a.total);const i=l.slice(0,this.maxCountries),s=i[0]?.total||1,r=i.map(a=>{const t=a.total/s,e=Math.round(18+24*t);return{lng:a.centroid.lng,lat:a.centroid.lat,size:e,color:this.getMarkerColor(t),popup:`\n <div class="text-center">\n <strong>${a.centroid.name}</strong><br/>\n <span class="text-muted">${a.total.toLocaleString()} ${this.metricLabel}</span>\n </div>\n `}});this.showRoutes&&this.routeOrigin?.lng&&this.routeOrigin?.lat&&r.push({lng:this.routeOrigin.lng,lat:this.routeOrigin.lat,size:26,color:"#0d6efd",icon:"bi bi-broadcast-pin",popup:`\n <div class="text-center">\n <strong>${this.routeOrigin.name||"Operations Hub"}</strong><br/>\n <span class="text-muted">Origin</span>\n </div>\n `}),this.mapView.updateMarkers(r),this.renderLegend(i,e),this.showRoutes&&this.renderRoutes(i,s)}getMarkerColor(a){const t=[255,193,7],e=[32,201,151].map((e,n)=>Math.round(e+(t[n]-e)*a));return`rgba(${e[0]}, ${e[1]}, ${e[2]}, 0.9)`}renderLegend(a){const t=this.element.querySelector('[data-region="legend"]');if(!t)return;if(!a.length)return void(t.innerHTML="");const e=a[0]?.total||1,n=a.map(a=>{const t=(a.total/e*100).toFixed(0);return`\n <div class="d-flex justify-content-between align-items-center py-1 border-top">\n <div>\n <span class="fw-semibold">${a.centroid.name}</span>\n <span class="text-muted ms-1">(${a.code})</span>\n </div>\n <div class="text-end">\n <div class="fw-semibold">${a.total.toLocaleString()}</div>\n <small class="text-muted">${t}% of top</small>\n </div>\n </div>\n `}).join("");t.innerHTML=n}renderRoutes(a,t){const e=this.routeOrigin||null;if(!(e&&e.lng&&e.lat&&this.mapView))return;const n={type:"FeatureCollection",features:a.map(a=>({type:"Feature",geometry:{type:"LineString",coordinates:[[e.lng,e.lat],[a.centroid.lng,a.centroid.lat]]},properties:{total:a.total,intensity:a.total/t}}))};this.mapView.lineSources=this.mapView.lineSources.filter(a=>a.id!==`${this.id}-routes`),this.mapView.updateLineSource(`${this.id}-routes`,{data:n,paint:{"line-color":["interpolate",["linear"],["get","intensity"],0,"rgba(32, 201, 151, 0.6)",1,"rgba(255, 193, 7, 0.95)"],"line-width":["interpolate",["linear"],["get","intensity"],0,1.75,1,6],"line-opacity":["interpolate",["linear"],["get","intensity"],0,.45,1,.95]}})}setStatus(a){this.statusEl&&(this.statusEl.textContent=a||"",this.statusEl.style.display=a?"block":"none")}}export{MapView as M,MapLibreView as a,MetricsCountryMapView as b,t as c,e as d};
2
+ //# sourceMappingURL=MetricsCountryMapView-CAD9wR_T.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetricsCountryMapView-CAD9wR_T.js","sources":["../../src/extensions/map/MapView.js","../../src/extensions/map/MapLibreView.js","../../src/extensions/map/countryCentroids.js","../../src/extensions/map/MetricsCountryMapView.js"],"sourcesContent":["/**\n * MapView - Interactive map component using Leaflet\n *\n * Features:\n * - Display single or multiple markers\n * - Auto-zoom to fit markers\n * - Customizable marker popups\n * - Support for different tile layers\n *\n * @example\n * const mapView = new MapView({\n * markers: [\n * { lat: 37.422, lng: -122.084, popup: 'Mountain View, CA' }\n * ],\n * zoom: 10,\n * height: 400\n * });\n */\n\nimport View from '@core/View.js';\n\nclass MapView extends View {\n constructor(options = {}) {\n super({\n className: 'map-view',\n ...options\n });\n\n this.markers = options.markers || [];\n this.center = options.center || null;\n this.zoom = options.zoom || 13;\n this.height = options.height || 400;\n this.showZoomControl = options.showZoomControl !== false;\n this.tileLayer = options.tileLayer || 'osm'; // 'osm', 'satellite', 'terrain'\n this.showLeafletBranding = options.showLeafletBranding === true;\n this.showLayerControl = options.showLayerControl === true;\n this.layerOptions = options.layerOptions || {\n osm: 'OSM',\n satellite: 'Satellite',\n terrain: 'Terrain',\n dark: 'Dark',\n light: 'Light',\n watercolor: 'Watercolor',\n bw: 'B/W',\n streets: 'Streets'\n };\n\n // Interaction toggles. `interactive` is the master switch; granular\n // flags override individual handlers when set.\n const interactive = options.interactive !== false;\n this.interactive = interactive;\n this.scrollZoom = options.scrollZoom !== undefined ? !!options.scrollZoom : interactive;\n this.dragPan = options.dragPan !== undefined ? !!options.dragPan : interactive;\n this.doubleClickZoom = options.doubleClickZoom !== undefined ? !!options.doubleClickZoom : interactive;\n this.keyboard = options.keyboard !== undefined ? !!options.keyboard : interactive;\n this.touchZoom = options.touchZoom !== undefined ? !!options.touchZoom : interactive;\n\n this.map = null;\n this.leafletMarkers = [];\n this._tileLayer = null;\n\n this.template = `\n <div class=\"map-container\">\n <div id=\"map-{{id}}\" style=\"height: {{height}}px; width: 100%; border-radius: 0.375rem; border: 1px solid #dee2e6;\"></div>\n </div>\n `;\n }\n\n async onAfterRender() {\n await this.loadLeaflet();\n await this.initializeMap();\n }\n\n async loadLeaflet() {\n // Check if Leaflet is already loaded\n if (window.L) return;\n\n // Load Leaflet CSS and wait for it\n const cssLoaded = new Promise((resolve) => {\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.css';\n link.onload = resolve;\n link.onerror = resolve; // Continue even if CSS fails\n document.head.appendChild(link);\n });\n\n // Load Leaflet JS\n const jsLoaded = new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.src = 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.js';\n script.onload = resolve;\n script.onerror = reject;\n document.head.appendChild(script);\n });\n\n // Wait for both CSS and JS to load\n await Promise.all([cssLoaded, jsLoaded]);\n }\n\n getTileLayerUrl() {\n const tileLayers = {\n // Standard street maps\n osm: {\n url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',\n attribution: '© OpenStreetMap contributors',\n maxZoom: 19\n },\n\n // Satellite imagery\n satellite: {\n url: 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',\n attribution: '© Esri',\n maxZoom: 19\n },\n\n // Terrain and topographic\n terrain: {\n url: 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png',\n attribution: '© OpenTopoMap contributors',\n maxZoom: 17\n },\n\n // Dark mode styles\n dark: {\n url: 'https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png',\n attribution: '© OpenStreetMap contributors © CARTO',\n maxZoom: 20\n },\n\n // Light/minimal styles\n light: {\n url: 'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png',\n attribution: '© OpenStreetMap contributors © CARTO',\n maxZoom: 20\n },\n\n // Watercolor artistic style\n watercolor: {\n url: 'https://tiles.stadiamaps.com/tiles/stamen_watercolor/{z}/{x}/{y}.jpg',\n attribution: '© Stadia Maps © Stamen Design © OpenStreetMap contributors',\n maxZoom: 16\n },\n\n // Black and white\n bw: {\n url: 'https://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}{r}.png',\n attribution: '© OpenStreetMap contributors © CARTO',\n maxZoom: 20\n },\n\n // Streets with labels\n streets: {\n url: 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png',\n attribution: '© OpenStreetMap contributors © CARTO',\n maxZoom: 20\n }\n };\n\n return tileLayers[this.tileLayer] || tileLayers.osm;\n }\n\n async initializeMap() {\n const mapElement = this.element.querySelector(`#map-${this.id}`);\n if (!mapElement || !window.L) return;\n\n // Determine map center\n let mapCenter = this.center;\n if (!mapCenter && this.markers.length > 0) {\n // Use first marker as center\n mapCenter = [this.markers[0].lat, this.markers[0].lng];\n }\n if (!mapCenter) {\n // Default to world view\n mapCenter = [0, 0];\n }\n\n // Create map\n this.map = window.L.map(mapElement, {\n center: mapCenter,\n zoom: this.zoom,\n zoomControl: this.showZoomControl,\n scrollWheelZoom: this.scrollZoom,\n dragging: this.dragPan,\n doubleClickZoom: this.doubleClickZoom,\n keyboard: this.keyboard,\n touchZoom: this.touchZoom,\n boxZoom: this.interactive,\n tap: this.interactive\n });\n // Optionally hide Leaflet branding/prefix (removes Leaflet link/flag in attribution control)\n if (this.map && this.map.attributionControl && this.showLeafletBranding === false) {\n try { this.map.attributionControl.setPrefix(''); } catch (e) {}\n }\n\n // Add tile layer\n const tileConfig = this.getTileLayerUrl();\n this._tileLayer = window.L.tileLayer(tileConfig.url, {\n attribution: tileConfig.attribution,\n maxZoom: tileConfig.maxZoom\n }).addTo(this.map);\n\n // Optional built-in tile layer selector UI\n if (this.showLayerControl) {\n const container = mapElement.parentElement || this.element.querySelector('.map-container');\n if (container) {\n container.style.position = container.style.position || 'relative';\n const selector = document.createElement('select');\n selector.className = 'form-select form-select-sm';\n selector.style.position = 'absolute';\n selector.style.top = '8px';\n selector.style.right = '8px';\n selector.style.zIndex = '1000';\n selector.style.maxWidth = '180px';\n selector.setAttribute('aria-label', 'Map tile layer');\n\n // Populate options\n Object.entries(this.layerOptions || {}).forEach(([key, label]) => {\n const opt = document.createElement('option');\n opt.value = key;\n opt.textContent = label;\n if (key === this.tileLayer) opt.selected = true;\n selector.appendChild(opt);\n });\n\n selector.addEventListener('change', () => this.setTileLayer(selector.value));\n container.appendChild(selector);\n }\n }\n\n // Add markers\n this.addMarkers(this.markers);\n\n // Auto-fit bounds if multiple markers\n if (this.markers.length > 1) {\n this.fitBounds();\n }\n\n // Fix tile rendering issues by invalidating size after a delay\n // This ensures the container has proper dimensions and CSS is applied\n setTimeout(() => {\n if (this.map) {\n this.map.invalidateSize();\n }\n }, 300);\n }\n\n addMarkers(markers) {\n if (!this.map || !Array.isArray(markers)) return;\n\n markers.forEach(markerData => {\n const { lat, lng, popup, icon } = markerData;\n\n if (!lat || !lng) return;\n\n const markerOptions = {};\n\n // Custom icon if provided\n if (icon) {\n markerOptions.icon = window.L.icon(icon);\n }\n\n const marker = window.L.marker([lat, lng], markerOptions).addTo(this.map);\n\n // Add popup if provided\n if (popup) {\n marker.bindPopup(popup);\n }\n\n this.leafletMarkers.push(marker);\n });\n }\n\n fitBounds() {\n if (!this.map || this.leafletMarkers.length === 0) return;\n\n const group = new window.L.featureGroup(this.leafletMarkers);\n this.map.fitBounds(group.getBounds().pad(0.1));\n }\n\n updateMarkers(newMarkers) {\n // Clear existing markers\n this.clearMarkers();\n\n // Add new markers\n this.markers = newMarkers;\n this.addMarkers(newMarkers);\n\n // Fit bounds if multiple markers\n if (newMarkers.length > 1) {\n this.fitBounds();\n } else if (newMarkers.length === 1) {\n this.map.setView([newMarkers[0].lat, newMarkers[0].lng], this.zoom);\n }\n }\n\n clearMarkers() {\n this.leafletMarkers.forEach(marker => {\n this.map.removeLayer(marker);\n });\n this.leafletMarkers = [];\n }\n\n setView(lat, lng, zoom = null) {\n if (!this.map) return;\n this.map.setView([lat, lng], zoom || this.zoom);\n }\n\n setZoom(zoom) {\n if (!this.map) return;\n this.map.setZoom(zoom);\n }\n\n setTileLayer(key) {\n if (!this.map) return;\n // Resolve tile layer config using the same logic as getTileLayerUrl\n const original = this.tileLayer;\n this.tileLayer = key || this.tileLayer;\n const tileConfig = this.getTileLayerUrl();\n try {\n if (this._tileLayer) {\n this.map.removeLayer(this._tileLayer);\n }\n } catch (e) {\n // ignore if layer already removed\n }\n this._tileLayer = window.L.tileLayer(tileConfig.url, {\n attribution: tileConfig.attribution,\n maxZoom: tileConfig.maxZoom\n }).addTo(this.map);\n // Keep property in sync\n this.tileLayer = key || original;\n\n // Nudge map to ensure proper redraw\n setTimeout(() => {\n try { this.map.invalidateSize(); } catch (e) {}\n }, 150);\n }\n\n async onBeforeDestroy() {\n if (this.map) {\n this.map.remove();\n this.map = null;\n }\n await super.onBeforeDestroy();\n }\n\n static async showAsDialog(options = {}) {\n const view = new MapView(options);\n const dopts = options.dialogOptions || {};\n const dialogOptions = {\n title: \"Map View\",\n header: true,\n body: view,\n size: 'lg',\n centered: false,\n ...dopts\n }\n await view.init();\n await view.getApp().showDialog(dialogOptions);\n }\n}\n\nexport default MapView;\n","/**\n * MapLibreView - Interactive vector map component using MapLibre GL JS\n * \n * MapLibre GL is better for:\n * - Vector tiles and custom styling\n * - 3D terrain and buildings\n * - High-performance rendering\n * - Heat maps and data visualizations\n * - Complex animations\n * \n * Use MapView (Leaflet) for simple marker maps.\n * Use MapLibreView for advanced visualizations.\n * \n * @example\n * const mapView = new MapLibreView({\n * markers: [\n * { lng: -122.084, lat: 37.422, popup: 'Mountain View, CA' }\n * ],\n * style: 'streets', // 'streets', 'satellite', 'dark', 'light'\n * zoom: 10,\n * height: 400\n * });\n */\n\nimport View from '@core/View.js';\n\nclass MapLibreView extends View {\n constructor(options = {}) {\n super({\n className: 'maplibre-view',\n ...options\n });\n\n this.markers = options.markers || [];\n this.center = options.center || null;\n this.zoom = options.zoom || 13;\n this.height = options.height || 400;\n this.pitch = options.pitch || 0; // 0-60 degrees (3D tilt)\n this.bearing = options.bearing || 0; // 0-360 degrees (rotation)\n this.mapStyle = options.style || 'streets'; // 'streets', 'satellite', 'dark', 'light', 'terrain'\n this.showNavigationControl = options.showNavigationControl !== false;\n this.autoFitBounds = options.autoFitBounds !== false;\n\n // Interaction toggles. `interactive` is the master switch; granular\n // flags override individual handlers when set.\n const interactive = options.interactive !== false;\n this.interactive = interactive;\n this.scrollZoom = options.scrollZoom !== undefined ? !!options.scrollZoom : interactive;\n this.dragPan = options.dragPan !== undefined ? !!options.dragPan : interactive;\n this.doubleClickZoom = options.doubleClickZoom !== undefined ? !!options.doubleClickZoom : interactive;\n this.keyboard = options.keyboard !== undefined ? !!options.keyboard : interactive;\n this.touchZoom = options.touchZoom !== undefined ? !!options.touchZoom : interactive;\n \n this.map = null;\n this.mapMarkers = [];\n this.pendingMarkers = [...this.markers];\n this.lineSources = options.lineSources || [];\n this.pendingLineData = new Map();\n\n this.template = `\n <div class=\"maplibre-container\">\n <div id=\"maplibre-{{id}}\" style=\"height: {{height}}px; width: 100%; border-radius: 0.375rem; border: 1px solid #dee2e6;\"></div>\n </div>\n `;\n }\n\n async onAfterRender() {\n await this.loadMapLibre();\n await this.initializeMap();\n }\n\n async loadMapLibre() {\n // Check if MapLibre is already loaded\n if (window.maplibregl) return;\n\n // Load MapLibre CSS\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = 'https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.css';\n document.head.appendChild(link);\n\n // Load MapLibre JS\n return new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.src = 'https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.js';\n script.onload = resolve;\n script.onerror = reject;\n document.head.appendChild(script);\n });\n }\n\n getMapStyle() {\n const styles = {\n streets: 'https://demotiles.maplibre.org/style.json',\n dark: {\n version: 8,\n sources: {\n osm: {\n type: 'raster',\n tiles: ['https://a.tile.openstreetmap.org/{z}/{x}/{y}.png'],\n tileSize: 256,\n attribution: '© OpenStreetMap contributors'\n }\n },\n layers: [{\n id: 'osm',\n type: 'raster',\n source: 'osm'\n }],\n glyphs: 'https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf'\n },\n light: {\n version: 8,\n sources: {\n osm: {\n type: 'raster',\n tiles: ['https://a.tile.openstreetmap.org/{z}/{x}/{y}.png'],\n tileSize: 256,\n attribution: '© OpenStreetMap contributors'\n }\n },\n layers: [{\n id: 'osm',\n type: 'raster',\n source: 'osm'\n }],\n glyphs: 'https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf'\n },\n satellite: {\n version: 8,\n sources: {\n satellite: {\n type: 'raster',\n tiles: ['https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}'],\n tileSize: 256,\n attribution: '© Esri'\n }\n },\n layers: [{\n id: 'satellite',\n type: 'raster',\n source: 'satellite'\n }],\n glyphs: 'https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf'\n },\n terrain: {\n version: 8,\n sources: {\n terrain: {\n type: 'raster',\n tiles: ['https://a.tile.opentopomap.org/{z}/{x}/{y}.png'],\n tileSize: 256,\n attribution: '© OpenTopoMap contributors'\n }\n },\n layers: [{\n id: 'terrain',\n type: 'raster',\n source: 'terrain'\n }],\n glyphs: 'https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf'\n }\n };\n\n return styles[this.mapStyle] || styles.streets;\n }\n\n async initializeMap() {\n const mapElement = this.element.querySelector(`#maplibre-${this.id}`);\n if (!mapElement || !window.maplibregl) return;\n\n // Determine map center\n let mapCenter = this.center;\n if (!mapCenter && this.markers.length > 0) {\n // Use first marker as center (MapLibre uses [lng, lat])\n mapCenter = [this.markers[0].lng, this.markers[0].lat];\n }\n if (!mapCenter) {\n // Default to world view\n mapCenter = [0, 0];\n }\n\n // Create map\n this.map = new window.maplibregl.Map({\n container: mapElement,\n style: this.getMapStyle(),\n center: mapCenter,\n zoom: this.zoom,\n pitch: this.pitch,\n bearing: this.bearing,\n interactive: this.interactive,\n scrollZoom: this.scrollZoom,\n dragPan: this.dragPan,\n doubleClickZoom: this.doubleClickZoom,\n keyboard: this.keyboard,\n touchZoomRotate: this.touchZoom\n });\n\n // Add navigation control\n if (this.showNavigationControl) {\n this.map.addControl(new window.maplibregl.NavigationControl(), 'top-right');\n }\n\n // Wait for map to load before adding markers\n this.map.on('load', () => {\n const initialMarkers = this.pendingMarkers.length ? this.pendingMarkers : this.markers;\n this.updateMarkers(initialMarkers);\n this.lineSources.forEach(source => this.addLineSource(source));\n this.pendingLineData.forEach(source => this.addLineSource(source));\n this.pendingLineData.clear();\n });\n }\n\n addMarkers(markers) {\n if (!this.map || !Array.isArray(markers)) {\n this.pendingMarkers = Array.isArray(markers) ? markers : [];\n return;\n }\n\n markers.forEach(markerData => {\n const { lng, lat, popup, color, icon, size } = markerData;\n \n if (!lng || !lat) return;\n\n // Create marker element\n const el = document.createElement('div');\n el.className = 'maplibre-marker';\n const markerSize = Number(size) || 30;\n el.style.width = `${markerSize}px`;\n el.style.height = `${markerSize}px`;\n el.style.borderRadius = '50%';\n el.style.backgroundColor = color || '#3b82f6';\n el.style.border = '3px solid white';\n el.style.boxShadow = '0 2px 4px rgba(0,0,0,0.3)';\n el.style.cursor = 'pointer';\n el.style.display = 'flex';\n el.style.alignItems = 'center';\n el.style.justifyContent = 'center';\n\n // Optional icon\n if (icon) {\n el.innerHTML = `<i class=\"${icon}\" style=\"color: white;\"></i>`;\n }\n\n // Create marker\n const marker = new window.maplibregl.Marker({ element: el })\n .setLngLat([lng, lat])\n .addTo(this.map);\n\n // Add popup if provided\n if (popup) {\n const mapPopup = new window.maplibregl.Popup({ offset: 25 })\n .setHTML(popup);\n marker.setPopup(mapPopup);\n }\n\n this.mapMarkers.push(marker);\n });\n }\n\n fitBounds() {\n if (!this.map || this.markers.length === 0) return;\n\n const bounds = new window.maplibregl.LngLatBounds();\n \n this.markers.forEach(marker => {\n bounds.extend([marker.lng, marker.lat]);\n });\n\n this.map.fitBounds(bounds, {\n padding: 50,\n maxZoom: 15\n });\n }\n\n updateMarkers(newMarkers) {\n const markers = Array.isArray(newMarkers) ? newMarkers : [];\n this.markers = markers;\n this.pendingMarkers = markers;\n if (!this.map) return;\n\n this.clearMarkers();\n this.addMarkers(markers);\n\n if (this.autoFitBounds && markers.length > 1) {\n this.fitBounds();\n } else if (markers.length === 1 && this.map) {\n this.map.flyTo({\n center: [markers[0].lng, markers[0].lat],\n zoom: this.zoom\n });\n }\n }\n\n clearMarkers() {\n this.mapMarkers.forEach(marker => {\n marker.remove();\n });\n this.mapMarkers = [];\n }\n\n addLineSource({ id, data, paint, layout }) {\n if (!id || !data) return;\n\n const sourceId = `${id}-source`;\n\n if (!this.map) {\n this.pendingLineData.set(id, { id, data, paint, layout });\n return;\n }\n\n if (this.map.getLayer(id)) {\n this.map.removeLayer(id);\n }\n if (this.map.getSource(sourceId)) {\n this.map.removeSource(sourceId);\n }\n\n this.map.addSource(sourceId, {\n type: 'geojson',\n data\n });\n\n this.map.addLayer({\n id,\n type: 'line',\n source: sourceId,\n paint: {\n 'line-color': '#3b82f6',\n 'line-width': 2,\n 'line-opacity': 0.6,\n ...paint\n },\n layout: {\n 'line-cap': 'round',\n 'line-join': 'round',\n ...layout\n }\n });\n }\n\n updateLineSource(id, { data, paint, layout } = {}) {\n if (!id || !data) return;\n const sourceId = `${id}-source`;\n if (!this.map) {\n this.pendingLineData.set(id, { id, data, paint, layout });\n return;\n }\n if (this.map.getSource(sourceId)) {\n this.map.getSource(sourceId).setData(data);\n if (paint || layout) {\n if (paint) {\n Object.entries(paint).forEach(([key, value]) => {\n this.map.setPaintProperty(id, key, value);\n });\n }\n if (layout) {\n Object.entries(layout).forEach(([key, value]) => {\n this.map.setLayoutProperty(id, key, value);\n });\n }\n }\n } else {\n this.addLineSource({ id, data, paint, layout });\n }\n }\n\n setView(lng, lat, zoom = null) {\n if (!this.map) return;\n this.map.flyTo({\n center: [lng, lat],\n zoom: zoom || this.zoom\n });\n }\n\n setZoom(zoom) {\n if (!this.map) return;\n this.map.setZoom(zoom);\n }\n\n setPitch(pitch) {\n if (!this.map) return;\n this.map.setPitch(pitch);\n }\n\n setBearing(bearing) {\n if (!this.map) return;\n this.map.setBearing(bearing);\n }\n\n async onBeforeDestroy() {\n if (this.map) {\n this.map.remove();\n this.map = null;\n }\n await super.onBeforeDestroy();\n }\n}\n\nexport default MapLibreView;\n","// Auto-generated from countries.geojson - do not edit manually.\nexport const COUNTRY_CENTROIDS = {\n \"AD\": { name: \"Andorra\", lat: 42.54859834854764, lng: 1.5802243611232873 },\n \"AE\": { name: \"United Arab Emirates\", lat: 24.18250292309135, lng: 54.27920525789581 },\n \"AF\": { name: \"Afghanistan\", lat: 34.13402601376932, lng: 66.59216131095278 },\n \"AG\": { name: \"Antigua and Barbuda\", lat: 17.07146759372967, lng: -61.78530823226373 },\n \"AI\": { name: \"Anguilla\", lat: 18.222874004219086, lng: -63.06008343771806 },\n \"AL\": { name: \"Albania\", lat: 41.14165894891656, lng: 20.061082767269493 },\n \"AM\": { name: \"Armenia\", lat: 40.17841274230679, lng: 45.05490831965259 },\n \"AO\": { name: \"Angola\", lat: -12.167424062667942, lng: 17.651768783079 },\n \"AQ\": { name: \"Antarctica\", lat: -77.16987521415838, lng: -177.56451613408842 },\n \"AR\": { name: \"Argentina\", lat: -35.697270518120085, lng: -64.53238503843076 },\n \"AS\": { name: \"American Samoa\", lat: -14.305711987770538, lng: -170.7007316174498 },\n \"AT\": { name: \"Austria\", lat: 47.631858269895794, lng: 13.797778364631036 },\n \"AU\": { name: \"Australia\", lat: -25.697337673983082, lng: 134.02277170916162 },\n \"AW\": { name: \"Aruba\", lat: 12.515625722992898, lng: -69.97564014284046 },\n \"AZ\": { name: \"Azerbaijan\", lat: 40.3920509942049, lng: 48.634592670644324 },\n \"BA\": { name: \"Bosnia and Herzegovina\", lat: 44.14415356126429, lng: 17.83467240787538 },\n \"BB\": { name: \"Barbados\", lat: 13.183219369337529, lng: -59.557383949150285 },\n \"BD\": { name: \"Bangladesh\", lat: 23.673728665121, lng: 90.43212562608613 },\n \"BE\": { name: \"Belgium\", lat: 50.6182138854095, lng: 4.675010154696485 },\n \"BF\": { name: \"Burkina Faso\", lat: 12.108709036312737, lng: -1.6932816211842325 },\n \"BG\": { name: \"Bulgaria\", lat: 42.82043677302438, lng: 25.251739122561908 },\n \"BH\": { name: \"Bahrain\", lat: 26.04798501537066, lng: 50.540695402276775 },\n \"BI\": { name: \"Burundi\", lat: -3.261251993278643, lng: 29.88518227845293 },\n \"BJ\": { name: \"Benin\", lat: 9.503013199615893, lng: 2.305714528830206 },\n \"BL\": { name: \"Saint Barthelemy\", lat: 17.90561691241738, lng: -62.83051610005156 },\n \"BM\": { name: \"Bermuda\", lat: 32.315067430740726, lng: -64.7458500599169 },\n \"BN\": { name: \"Brunei Darussalam\", lat: 4.543205889917609, lng: 114.6430958360464 },\n \"BO\": { name: \"Bolivia\", lat: -16.7312488393574, lng: -64.45209597511206 },\n \"BQ\": { name: \"Bonaire\", lat: 12.180844982440338, lng: -68.29350445958761 },\n \"BQ\": { name: \"Saba\", lat: 17.632512616389718, lng: -63.23739481909494 },\n \"BQ\": { name: \"Saint Eustatius\", lat: 17.4919042294197, lng: -62.978230589445026 },\n \"BR\": { name: \"Brazil\", lat: -11.524630416426652, lng: -54.355206608256424 },\n \"BS\": { name: \"Bahamas\", lat: 24.72162633646784, lng: -78.07275370060313 },\n \"BT\": { name: \"Bhutan\", lat: 27.42163933959824, lng: 90.46716647173861 },\n \"BV\": { name: \"Bouvet Island\", lat: -54.42316679395248, lng: 3.411969465057627 },\n \"BW\": { name: \"Botswana\", lat: -22.236609002062902, lng: 23.85779956995608 },\n \"BY\": { name: \"Belarus\", lat: 53.46791374543163, lng: 27.964252054715104 },\n \"BZ\": { name: \"Belize\", lat: 17.24252476647155, lng: -88.68273510023441 },\n \"CA\": { name: \"Canada\", lat: 57.550480044655636, lng: -98.41680517868062 },\n \"CC\": { name: \"Cocos Islands\", lat: -12.171249450199545, lng: 96.83688767323002 },\n \"CD\": { name: \"Congo DRC\", lat: -3.338629596207896, lng: 23.419827574282188 },\n \"CF\": { name: \"Central African Republic\", lat: 6.331390033944319, lng: 20.520743419397256 },\n \"CG\": { name: \"Congo\", lat: -0.7294391595233845, lng: 14.879732849491393 },\n \"CH\": { name: \"Switzerland\", lat: 46.73678128684938, lng: 8.286928794895285 },\n \"CI\": { name: \"Côte d'Ivoire\", lat: 7.536779279421307, lng: -5.571710194917734 },\n \"CK\": { name: \"Cook Islands\", lat: -21.222613253399842, lng: -159.78768870952257 },\n \"CL\": { name: \"Chile\", lat: -37.82938283049967, lng: -70.76863431739216 },\n \"CM\": { name: \"Cameroon\", lat: 6.294168487480992, lng: 12.948474142398263 },\n \"CN\": { name: \"China\", lat: 38.07325481105728, lng: 104.69113855849604 },\n \"CO\": { name: \"Colombia\", lat: 4.187753877352739, lng: -72.6445066243485 },\n \"CR\": { name: \"Costa Rica\", lat: 9.863467407406214, lng: -84.14673625701816 },\n \"CU\": { name: \"Cuba\", lat: 21.476176522869448, lng: -79.69817857618705 },\n \"CV\": { name: \"Cabo Verde\", lat: 15.076411518651643, lng: -23.63401005900474 },\n \"CW\": { name: \"Curacao\", lat: 12.199996647939832, lng: -68.96939768599042 },\n \"CX\": { name: \"Christmas Island\", lat: -10.446440802183416, lng: 105.70209512200549 },\n \"CY\": { name: \"Cyprus\", lat: 35.11700416345239, lng: 33.375346009199205 },\n \"CZ\": { name: \"Czech Republic\", lat: 49.74917370930982, lng: 15.383273292023533 },\n \"DE\": { name: \"Germany\", lat: 51.08304539800482, lng: 10.426171427430804 },\n \"DJ\": { name: \"Djibouti\", lat: 11.750235727618804, lng: 42.613496898789506 },\n \"DK\": { name: \"Denmark\", lat: 56.00118817971057, lng: 9.378670542409406 },\n \"DM\": { name: \"Dominica\", lat: 15.429269860940513, lng: -61.360471946942994 },\n \"DO\": { name: \"Dominican Republic\", lat: 18.77954818522993, lng: -70.43495198520012 },\n \"DZ\": { name: \"Algeria\", lat: 28.350969744889056, lng: 2.6558464719769135 },\n \"EC\": { name: \"Ecuador\", lat: -1.5642721388853116, lng: -78.4630326109714 },\n \"EE\": { name: \"Estonia\", lat: 58.648108311231034, lng: 25.916870250633806 },\n \"EG\": { name: \"Egypt\", lat: 26.60517034450628, lng: 30.240135435012338 },\n \"ER\": { name: \"Eritrea\", lat: 15.005533147667684, lng: 39.2672401449901 },\n \"ES\": { name: \"Spain\", lat: 40.365008336683836, lng: -3.6516251409956983 },\n \"ES\": { name: \"Canarias\", lat: 28.297665106525546, lng: -16.53799441021647 },\n \"ET\": { name: \"Ethiopia\", lat: 8.729389557048396, lng: 39.914902886544276 },\n \"FI\": { name: \"Finland\", lat: 65.01578959749911, lng: 25.65738433454702 },\n \"FJ\": { name: \"Fiji\", lat: -17.822470952336204, lng: 177.98144613732626 },\n \"FK\": { name: \"Falkland Islands\", lat: -51.75901312766726, lng: -58.746646363799854 },\n \"FM\": { name: \"Micronesia\", lat: 6.8789448129255435, lng: 158.2291899444527 },\n \"FO\": { name: \"Faroe Islands\", lat: 62.130896281495346, lng: -6.9811060913122835 },\n \"FR\": { name: \"France\", lat: 46.6423682169416, lng: 2.1940236627886227 },\n \"GA\": { name: \"Gabon\", lat: -0.628448459921234, lng: 11.839410898545754 },\n \"GB\": { name: \"United Kingdom\", lat: 53.97844735080214, lng: -2.852943909329258 },\n \"GD\": { name: \"Grenada\", lat: 12.112926656338907, lng: -61.67937937204098 },\n \"GE\": { name: \"Georgia\", lat: 42.17986277737226, lng: 43.378866534112234 },\n \"GF\": { name: \"French Guiana\", lat: 3.857429742497078, lng: -53.32232307156624 },\n \"GG\": { name: \"Guernsey\", lat: 49.45870771378872, lng: -2.576392582891568 },\n \"GH\": { name: \"Ghana\", lat: 7.94530467243628, lng: -1.219233362526581 },\n \"GI\": { name: \"Gibraltar\", lat: 36.14022671336082, lng: -5.345549484594358 },\n \"GL\": { name: \"Greenland\", lat: 74.16847218965994, lng: -42.07567788066985 },\n \"GM\": { name: \"Gambia\", lat: 13.428617959189328, lng: -15.383380385869662 },\n \"GN\": { name: \"Guinea\", lat: 10.255986541378112, lng: -10.986948848040218 },\n \"GP\": { name: \"Guadeloupe\", lat: 16.24420002705553, lng: -61.54382262282755 },\n \"GQ\": { name: \"Equatorial Guinea\", lat: 1.5954643936590733, lng: 10.425456672353823 },\n \"GR\": { name: \"Greece\", lat: 39.42012261727978, lng: 23.110368936161876 },\n \"GS\": { name: \"South Georgia and South Sandwich Islands\", lat: -54.37666443862139, lng: -36.77509575898928 },\n \"GT\": { name: \"Guatemala\", lat: 15.820878515352684, lng: -90.31219349119617 },\n \"GU\": { name: \"Guam\", lat: 13.445430479945276, lng: 144.78024458298802 },\n \"GW\": { name: \"Guinea-Bissau\", lat: 11.980075324820504, lng: -14.980186756910847 },\n \"GY\": { name: \"Guyana\", lat: 4.68211981385056, lng: -58.91352612754667 },\n \"HM\": { name: \"Heard Island and McDonald Islands\", lat: -53.084170035513736, lng: 73.49298560844045 },\n \"HN\": { name: \"Honduras\", lat: 14.740370695750006, lng: -86.49251679006962 },\n \"HR\": { name: \"Croatia\", lat: 44.91192100856702, lng: 16.625761129583374 },\n \"HT\": { name: \"Haiti\", lat: 18.883520486983567, lng: -72.89291379842 },\n \"HU\": { name: \"Hungary\", lat: 47.22527332486294, lng: 19.39620048366142 },\n \"ID\": { name: \"Indonesia\", lat: 0.15591979959037652, lng: 113.96538246847302 },\n \"IE\": { name: \"Ireland\", lat: 53.30489539816495, lng: -8.241128545554096 },\n \"IL\": { name: \"Israel\", lat: 31.513542220043195, lng: 35.027923472437024 },\n \"IM\": { name: \"Isle of Man\", lat: 54.22855301008011, lng: -4.532995055468449 },\n \"IN\": { name: \"India\", lat: 23.586300567746722, lng: 81.17300408530181 },\n \"IO\": { name: \"British Indian Ocean Territory\", lat: -7.323548444385743, lng: 72.43501618476016 },\n \"IQ\": { name: \"Iraq\", lat: 33.105075667527906, lng: 43.832529181056884 },\n \"IR\": { name: \"Iran\", lat: 32.906023742890056, lng: 54.237077001065444 },\n \"IS\": { name: \"Iceland\", lat: 65.12360920205514, lng: -19.05682967106099 },\n \"IT\": { name: \"Italy\", lat: 42.98201127614267, lng: 12.763657166123137 },\n \"JE\": { name: \"Jersey\", lat: 49.215396925724306, lng: -2.1291601162653575 },\n \"JM\": { name: \"Jamaica\", lat: 18.12207889341651, lng: -77.30358894542778 },\n \"JO\": { name: \"Jordan\", lat: 31.387064884449156, lng: 36.95728884547246 },\n \"JP\": { name: \"Japan\", lat: 36.76738832597829, lng: 137.46934234351835 },\n \"KE\": { name: \"Kenya\", lat: 0.6899182318376179, lng: 37.95309411262371 },\n \"KG\": { name: \"Kyrgyzstan\", lat: 41.35698905438358, lng: 74.17532903468319 },\n \"KH\": { name: \"Cambodia\", lat: 12.699186865507775, lng: 105.03973078680701 },\n \"KI\": { name: \"Kiribati\", lat: 1.8676673749241066, lng: -157.39024189323504 },\n \"KM\": { name: \"Comoros\", lat: -11.658861474508491, lng: 43.34826587429403 },\n \"KN\": { name: \"Saint Kitts and Nevis\", lat: 17.314736299587768, lng: -62.74560385895787 },\n \"KP\": { name: \"North Korea\", lat: 40.19198091470839, lng: 127.3379805653744 },\n \"KR\": { name: \"South Korea\", lat: 36.402386712544114, lng: 127.76224551357649 },\n \"KW\": { name: \"Kuwait\", lat: 29.281360965443092, lng: 47.56311109320184 },\n \"KY\": { name: \"Cayman Islands\", lat: 19.311231805620288, lng: -81.25203208977878 },\n \"KZ\": { name: \"Kazakhstan\", lat: 47.641465195176835, lng: 66.3759193479301 },\n \"LA\": { name: \"Laos\", lat: 18.117282736873282, lng: 103.76375899026448 },\n \"LB\": { name: \"Lebanon\", lat: 33.91160170722086, lng: 35.89651946324749 },\n \"LC\": { name: \"Saint Lucia\", lat: 13.895749185129906, lng: -60.9689510935251 },\n \"LI\": { name: \"Liechtenstein\", lat: 47.14627562133036, lng: 9.547674672376376 },\n \"LK\": { name: \"Sri Lanka\", lat: 7.696630939329944, lng: 80.66931169770622 },\n \"LR\": { name: \"Liberia\", lat: 6.52012979398834, lng: -9.258988935497618 },\n \"LS\": { name: \"Lesotho\", lat: -29.60168116924817, lng: 28.24475317864227 },\n \"LT\": { name: \"Lithuania\", lat: 55.29437393417175, lng: 23.946021605013534 },\n \"LU\": { name: \"Luxembourg\", lat: 49.77523454542369, lng: 6.103230338458876 },\n \"LV\": { name: \"Latvia\", lat: 56.813853047554154, lng: 24.693671325654403 },\n \"LY\": { name: \"Libya\", lat: 27.202915771690794, lng: 17.91133392454237 },\n \"MA\": { name: \"Morocco\", lat: 28.687598134979325, lng: -8.817212587250811 },\n \"MC\": { name: \"Monaco\", lat: 43.74798224995656, lng: 7.412820873271196 },\n \"MD\": { name: \"Moldova\", lat: 47.0725674580696, lng: 28.391111865941348 },\n \"ME\": { name: \"Montenegro\", lat: 42.73694835210454, lng: 19.29505087156758 },\n \"MF\": { name: \"Saint Martin\", lat: 18.078012113224464, lng: -63.06678525361946 },\n \"MG\": { name: \"Madagascar\", lat: -19.04163612493041, lng: 46.68493466832544 },\n \"MH\": { name: \"Marshall Islands\", lat: 7.307929900994344, lng: 168.72016025351076 },\n \"MK\": { name: \"North Macedonia\", lat: 41.59402890143112, lng: 21.70998923872772 },\n \"ML\": { name: \"Mali\", lat: 17.168146208584837, lng: -4.346399841781153 },\n \"MM\": { name: \"Myanmar\", lat: 19.901227931399873, lng: 97.08892285397344 },\n \"MN\": { name: \"Mongolia\", lat: 47.08644454604851, lng: 103.3987360327455 },\n \"MP\": { name: \"Northern Mariana Islands\", lat: 15.178063516432115, lng: 145.74119737203134 },\n \"MQ\": { name: \"Martinique\", lat: 14.642697353597645, lng: -61.01432380875083 },\n \"MR\": { name: \"Mauritania\", lat: 20.466731212820022, lng: -10.495079045035716 },\n \"MS\": { name: \"Montserrat\", lat: 16.735363391460357, lng: -62.18693281256255 },\n \"MT\": { name: \"Malta\", lat: 35.890522650899314, lng: 14.441922442508494 },\n \"MU\": { name: \"Mauritius\", lat: -20.28142317475198, lng: 57.56415671066546 },\n \"MV\": { name: \"Maldives\", lat: -0.6065577168009924, lng: 73.10076245140479 },\n \"MW\": { name: \"Malawi\", lat: -13.128986464184024, lng: 34.23441182298881 },\n \"MX\": { name: \"Mexico\", lat: 23.87436068093592, lng: -101.55399731630118 },\n \"MY\": { name: \"Malaysia\", lat: 3.6716608556387857, lng: 114.63330303992869 },\n \"MZ\": { name: \"Mozambique\", lat: -17.525230309488748, lng: 35.208577031290176 },\n \"NA\": { name: \"Namibia\", lat: -21.90858163281473, lng: 18.16451345845268 },\n \"NC\": { name: \"New Caledonia\", lat: -21.33003372660827, lng: 165.50767040438612 },\n \"NE\": { name: \"Niger\", lat: 17.08105392407292, lng: 8.86863247002646 },\n \"NF\": { name: \"Norfolk Island\", lat: -29.037654445046282, lng: 167.95259597483337 },\n \"NG\": { name: \"Nigeria\", lat: 9.61029352034213, lng: 8.147714845256194 },\n \"NI\": { name: \"Nicaragua\", lat: 12.893566631930554, lng: -85.016088327669 },\n \"NL\": { name: \"Netherlands\", lat: 52.134054128923886, lng: 5.554136426128487 },\n \"NO\": { name: \"Norway\", lat: 64.97775882947745, lng: 16.670259272390894 },\n \"NP\": { name: \"Nepal\", lat: 28.300920699755657, lng: 84.1338898313567 },\n \"NR\": { name: \"Nauru\", lat: -0.5221021440668993, lng: 166.92937633139178 },\n \"NU\": { name: \"Niue\", lat: -19.05230921680393, lng: -169.86878106699083 },\n \"NZ\": { name: \"New Zealand\", lat: -43.82765432544426, lng: 170.69035541428696 },\n \"OM\": { name: \"Oman\", lat: 20.7242833183209, lng: 55.841088119829 },\n \"PA\": { name: \"Panama\", lat: 8.439536749576892, lng: -80.14428761482796 },\n \"PE\": { name: \"Peru\", lat: -8.522717984240291, lng: -74.11416196781884 },\n \"PF\": { name: \"French Polynesia\", lat: -17.674684080120677, lng: -149.40041671099763 },\n \"PG\": { name: \"Papua New Guinea\", lat: -7.156912819152135, lng: 144.8348942994695 },\n \"PH\": { name: \"Philippines\", lat: 15.586542251094242, lng: 121.82208941416745 },\n \"PK\": { name: \"Pakistan\", lat: 30.116188371410882, lng: 69.08835090769651 },\n \"PL\": { name: \"Poland\", lat: 52.06848055692473, lng: 19.43573279234468 },\n \"PM\": { name: \"Saint Pierre and Miquelon\", lat: 46.95153913615198, lng: -56.32465353437558 },\n \"PN\": { name: \"Pitcairn\", lat: -24.366121747565458, lng: -128.3149848627581 },\n \"PR\": { name: \"Puerto Rico\", lat: 18.216224086610914, lng: -66.49425339593509 },\n \"PS\": { name: \"Palestinian Territory\", lat: 31.930818736453883, lng: 35.24251184154588 },\n \"PT\": { name: \"Portugal\", lat: 39.67529214702138, lng: -7.933662183874006 },\n \"PW\": { name: \"Palau\", lat: 7.534775852547396, lng: 134.57965086721052 },\n \"PY\": { name: \"Paraguay\", lat: -23.42190559259428, lng: -58.38906357428651 },\n \"QA\": { name: \"Qatar\", lat: 25.318528486425386, lng: 51.19794918743203 },\n \"RE\": { name: \"Réunion\", lat: -21.119825460665105, lng: 55.54393506194689 },\n \"RO\": { name: \"Romania\", lat: 45.82454894397586, lng: 25.094158201563292 },\n \"RS\": { name: \"Serbia\", lat: 44.02679870131969, lng: 20.85677444395745 },\n \"RU\": { name: \"Russian Federation\", lat: 59.039434214106194, lng: 98.6704990698032 },\n \"RW\": { name: \"Rwanda\", lat: -2.014687460047154, lng: 29.919439681764082 },\n \"SA\": { name: \"Saudi Arabia\", lat: 24.136038144757897, lng: 44.600958178225596 },\n \"SB\": { name: \"Solomon Islands\", lat: -9.613104734596515, lng: 160.16475795033884 },\n \"SC\": { name: \"Seychelles\", lat: -4.660002318822744, lng: 55.47250789595527 },\n \"SD\": { name: \"Sudan\", lat: 15.67060230984256, lng: 29.951458283594064 },\n \"SE\": { name: \"Sweden\", lat: 62.73420986108448, lng: 17.062431988004956 },\n \"SG\": { name: \"Singapore\", lat: 1.3528251890006349, lng: 103.81025757634053 },\n \"SH\": { name: \"Saint Helena\", lat: -15.962963318340398, lng: -5.717391620813109 },\n \"SI\": { name: \"Slovenia\", lat: 46.13759229564504, lng: 14.890636899973781 },\n \"SJ\": { name: \"Svalbard\", lat: 78.57318936469626, lng: 16.036378851505283 },\n \"SK\": { name: \"Slovakia\", lat: 48.69808390520484, lng: 19.581015362490966 },\n \"SL\": { name: \"Sierra Leone\", lat: 8.561330384750587, lng: -11.78656695731115 },\n \"SM\": { name: \"San Marino\", lat: 43.942820729097896, lng: 12.461278349581722 },\n \"SN\": { name: \"Senegal\", lat: 14.228861491763402, lng: -14.610875368352305 },\n \"SO\": { name: \"Somalia\", lat: 6.524534573103924, lng: 45.40037867243972 },\n \"SR\": { name: \"Suriname\", lat: 4.098723595920171, lng: -55.855514311561286 },\n \"SS\": { name: \"South Sudan\", lat: 7.657782041763295, lng: 30.3851856901788 },\n \"ST\": { name: \"Sao Tome and Principe\", lat: 0.22744704294793774, lng: 6.606158796857607 },\n \"SV\": { name: \"El Salvador\", lat: 13.758041517055418, lng: -88.85911489238985 },\n \"SX\": { name: \"Sint Maarten\", lat: 18.03942608463078, lng: -63.06883135915303 },\n \"SY\": { name: \"Syria\", lat: 35.09751106058316, lng: 38.5117323139514 },\n \"SZ\": { name: \"Eswatini\", lat: -26.562540935608702, lng: 31.510685746082007 },\n \"TC\": { name: \"Turks and Caicos Islands\", lat: 21.799865427483745, lng: -71.74058946811508 },\n \"TD\": { name: \"Chad\", lat: 15.283493546654503, lng: 18.427113900363025 },\n \"TF\": { name: \"Juan De Nova Island\", lat: -17.06449193630804, lng: 42.74374761089645 },\n \"TF\": { name: \"French Southern Territories\", lat: -49.26329687105643, lng: 69.54686984724839 },\n \"TF\": { name: \"Glorioso Islands\", lat: -11.566224871643417, lng: 47.290948081543384 },\n \"TG\": { name: \"Togo\", lat: 8.660743037717811, lng: 0.8990857571109684 },\n \"TH\": { name: \"Thailand\", lat: 13.66222784745538, lng: 101.08675116214552 },\n \"TJ\": { name: \"Tajikistan\", lat: 38.56933138382972, lng: 70.94215281065698 },\n \"TK\": { name: \"Tokelau\", lat: -9.195174767256544, lng: -171.85265950722743 },\n \"TL\": { name: \"Timor-Leste\", lat: -8.809894630601962, lng: 125.95024049562659 },\n \"TM\": { name: \"Turkmenistan\", lat: 39.06069118001429, lng: 58.4577357627054 },\n \"TN\": { name: \"Tunisia\", lat: 34.08636179565723, lng: 9.65587551697984 },\n \"TO\": { name: \"Tonga\", lat: -21.15927212823853, lng: -175.20415878511247 },\n \"TR\": { name: \"Turkey\", lat: 38.93207363123396, lng: 35.56886764076691 },\n \"TT\": { name: \"Trinidad and Tobago\", lat: 10.415515638298093, lng: -61.37236579976247 },\n \"TV\": { name: \"Tuvalu\", lat: -8.514701506447222, lng: 179.217833977593 },\n \"TZ\": { name: \"Tanzania\", lat: -6.355794440041147, lng: 34.81832206060381 },\n \"UA\": { name: \"Ukraine\", lat: 48.657532515563794, lng: 31.27377208442636 },\n \"UG\": { name: \"Uganda\", lat: 1.2821729218416205, lng: 32.34371768463123 },\n \"UM\": { name: \"United States Minor Outlying Islands\", lat: 19.302045812215958, lng: 166.63800339749642 },\n \"US\": { name: \"United States\", lat: 38.8208089190304, lng: -96.33161660829639 },\n \"UY\": { name: \"Uruguay\", lat: -32.78195043831093, lng: -56.01919523458085 },\n \"UZ\": { name: \"Uzbekistan\", lat: 41.4879065244633, lng: 63.8548297593985 },\n \"VA\": { name: \"Vatican City\", lat: 41.90402351316735, lng: 12.451312917026133 },\n \"VC\": { name: \"Saint Vincent and the Grenadines\", lat: 13.254808122970651, lng: -61.193766354393034 },\n \"VE\": { name: \"Venezuela\", lat: 7.148324760507107, lng: -66.36492135985132 },\n \"VG\": { name: \"British Virgin Islands\", lat: 18.42195819619707, lng: -64.62406519257699 },\n \"VI\": { name: \"US Virgin Islands\", lat: 17.738009708772523, lng: -64.76155341409797 },\n \"VN\": { name: \"Vietnam\", lat: 16.517347170839393, lng: 105.91338832758704 },\n \"VU\": { name: \"Vanuatu\", lat: -15.189132121699332, lng: 166.84912735669738 },\n \"WF\": { name: \"Wallis and Futuna\", lat: -14.283442307826677, lng: -178.12735555777184 },\n \"WS\": { name: \"Samoa\", lat: -13.634252953274622, lng: -172.44107655740137 },\n \"YE\": { name: \"Yemen\", lat: 16.001392616307445, lng: 47.46815793206386 },\n \"YT\": { name: \"Mayotte\", lat: -12.824468416301052, lng: 45.128142327031064 },\n \"ZA\": { name: \"South Africa\", lat: -28.55361930679731, lng: 24.75252746489084 },\n \"ZM\": { name: \"Zambia\", lat: -13.162832953186246, lng: 27.75521363430896 },\n \"ZW\": { name: \"Zimbabwe\", lat: -18.92700121981475, lng: 29.717829640720844 },\n};\n\nexport function getCountryCentroid(code) {\n if (!code) return null;\n return COUNTRY_CENTROIDS[code.toUpperCase()] || null;\n}\n\nexport function getCountryCentroids() {\n return COUNTRY_CENTROIDS;\n}","import View from '@core/View.js';\nimport MapLibreView from './MapLibreView.js';\nimport { COUNTRY_CENTROIDS } from './countryCentroids.js';\n\nclass MetricsCountryMapView extends View {\n constructor(options = {}) {\n const mapHeight = options.height || 320;\n super({\n className: 'metrics-country-map-view',\n ...options\n });\n\n this.endpoint = options.endpoint || '/api/metrics/fetch';\n this.account = options.account || 'global';\n this.category = options.category || null;\n this.slugs = options.slugs || null;\n this.granularity = options.granularity || 'days';\n this.maxCountries = options.maxCountries || 12;\n this.metricLabel = options.metricLabel || 'Events';\n this.height = mapHeight;\n this.mapStyle = options.mapStyle || 'dark';\n this.mapOptions = options.mapOptions || {};\n this.showRoutes = options.showRoutes !== false;\n this.routeOrigin = options.routeOrigin || { lng: -77.346, lat: 38.958, name: 'Reston, VA' };\n this._refreshing = false;\n }\n\n async getTemplate() {\n return `\n <div class=\"metrics-country-map\">\n <div class=\"map-container mb-3\" data-container=\"${this.id}-map\" style=\"height:${this.height}px\"></div>\n <div class=\"map-legend small\" data-region=\"legend\"></div>\n </div>\n `;\n }\n\n async onInit() {\n this.statusEl = document.createElement('div');\n this.statusEl.className = 'text-muted small px-3 pb-2';\n this.element.appendChild(this.statusEl);\n\n this.mapView = new MapLibreView({\n containerId: `${this.id}-map`,\n height: this.height,\n style: this.mapStyle,\n zoom: this.mapOptions.zoom ?? 1.3,\n center: this.mapOptions.center || [10, 20],\n pitch: this.mapOptions.pitch ?? 20,\n bearing: this.mapOptions.bearing ?? 0,\n showNavigationControl: this.mapOptions.showNavigationControl ?? true,\n autoFitBounds: this.mapOptions.autoFitBounds ?? false,\n interactive: this.mapOptions.interactive,\n scrollZoom: this.mapOptions.scrollZoom,\n dragPan: this.mapOptions.dragPan,\n doubleClickZoom: this.mapOptions.doubleClickZoom,\n keyboard: this.mapOptions.keyboard,\n touchZoom: this.mapOptions.touchZoom\n });\n this.addChild(this.mapView);\n await this.refresh();\n }\n\n async refresh() {\n if (this._refreshing) return;\n this._refreshing = true;\n this.setStatus('Loading hotspots…');\n try {\n const metrics = await this.fetchMetrics();\n await this.applyMetrics(metrics);\n this.setStatus('');\n } catch (error) {\n console.error('MetricsCountryMapView refresh error', error);\n this.setStatus('Unable to load country metrics.');\n } finally {\n this._refreshing = false;\n }\n }\n\n async fetchMetrics() {\n const rest = this.getApp()?.rest;\n if (!rest) {\n throw new Error('REST client unavailable');\n }\n const params = {\n account: this.account,\n granularity: this.granularity,\n with_labels: true\n };\n if (this.category) params.category = this.category;\n if (this.slugs) {\n const slugsArray = Array.isArray(this.slugs) ? this.slugs : [this.slugs];\n params['slugs[]'] = slugsArray;\n }\n\n const response = await rest.GET(this.endpoint, params);\n if (!response.success || !response.data?.status) {\n throw new Error(response.data?.error || 'Metrics API error');\n }\n return response.data.data;\n }\n\n async applyMetrics(data) {\n const metrics = data?.data || {};\n const labels = data?.labels || [];\n const entries = [];\n\n Object.entries(metrics).forEach(([iso, series]) => {\n const total = series.reduce((sum, value) => sum + (Number(value) || 0), 0);\n if (!total) return;\n const centroid = COUNTRY_CENTROIDS[iso.toUpperCase()];\n if (!centroid) return;\n entries.push({\n code: iso.toUpperCase(),\n total,\n values: series,\n centroid\n });\n });\n\n if (!entries.length) {\n this.mapView.updateMarkers([]);\n this.renderLegend([]);\n this.setStatus('No country data available for the selected range.');\n return;\n }\n\n entries.sort((a, b) => b.total - a.total);\n const topEntries = entries.slice(0, this.maxCountries);\n const maxValue = topEntries[0]?.total || 1;\n\n const markers = topEntries.map(entry => {\n const intensity = entry.total / maxValue;\n const markerSize = Math.round(18 + intensity * 24);\n return {\n lng: entry.centroid.lng,\n lat: entry.centroid.lat,\n size: markerSize,\n color: this.getMarkerColor(intensity),\n popup: `\n <div class=\"text-center\">\n <strong>${entry.centroid.name}</strong><br/>\n <span class=\"text-muted\">${entry.total.toLocaleString()} ${this.metricLabel}</span>\n </div>\n `\n };\n });\n\n if (this.showRoutes && this.routeOrigin?.lng && this.routeOrigin?.lat) {\n markers.push({\n lng: this.routeOrigin.lng,\n lat: this.routeOrigin.lat,\n size: 26,\n color: '#0d6efd',\n icon: 'bi bi-broadcast-pin',\n popup: `\n <div class=\"text-center\">\n <strong>${this.routeOrigin.name || 'Operations Hub'}</strong><br/>\n <span class=\"text-muted\">Origin</span>\n </div>\n `\n });\n }\n\n this.mapView.updateMarkers(markers);\n this.renderLegend(topEntries, labels);\n if (this.showRoutes) {\n this.renderRoutes(topEntries, maxValue);\n }\n }\n\n getMarkerColor(intensity) {\n const start = [32, 201, 151]; // teal\n const end = [255, 193, 7]; // amber\n const mix = start.map((value, idx) =>\n Math.round(value + (end[idx] - value) * intensity)\n );\n return `rgba(${mix[0]}, ${mix[1]}, ${mix[2]}, 0.9)`;\n }\n\n renderLegend(entries) {\n const legendEl = this.element.querySelector('[data-region=\"legend\"]');\n if (!legendEl) return;\n if (!entries.length) {\n legendEl.innerHTML = '';\n return;\n }\n\n const maxValue = entries[0]?.total || 1;\n const rows = entries.map(entry => {\n const percent = ((entry.total / maxValue) * 100).toFixed(0);\n return `\n <div class=\"d-flex justify-content-between align-items-center py-1 border-top\">\n <div>\n <span class=\"fw-semibold\">${entry.centroid.name}</span>\n <span class=\"text-muted ms-1\">(${entry.code})</span>\n </div>\n <div class=\"text-end\">\n <div class=\"fw-semibold\">${entry.total.toLocaleString()}</div>\n <small class=\"text-muted\">${percent}% of top</small>\n </div>\n </div>\n `;\n }).join('');\n\n legendEl.innerHTML = rows;\n }\n\n renderRoutes(entries, maxValue) {\n const origin = this.routeOrigin || null;\n if (!origin || !origin.lng || !origin.lat || !this.mapView) return;\n\n const features = entries.map(entry => ({\n type: 'Feature',\n geometry: {\n type: 'LineString',\n coordinates: [\n [origin.lng, origin.lat],\n [entry.centroid.lng, entry.centroid.lat]\n ]\n },\n properties: {\n total: entry.total,\n intensity: entry.total / maxValue\n }\n }));\n\n const geojson = {\n type: 'FeatureCollection',\n features\n };\n\n const paint = {\n 'line-color': [\n 'interpolate',\n ['linear'],\n ['get', 'intensity'],\n 0,\n 'rgba(32, 201, 151, 0.6)',\n 1,\n 'rgba(255, 193, 7, 0.95)'\n ],\n 'line-width': [\n 'interpolate',\n ['linear'],\n ['get', 'intensity'],\n 0,\n 1.75,\n 1,\n 6\n ],\n 'line-opacity': [\n 'interpolate',\n ['linear'],\n ['get', 'intensity'],\n 0,\n 0.45,\n 1,\n 0.95\n ]\n };\n\n this.mapView.lineSources = this.mapView.lineSources.filter(src => src.id !== `${this.id}-routes`);\n this.mapView.updateLineSource(`${this.id}-routes`, {\n data: geojson,\n paint\n });\n }\n\n setStatus(message) {\n if (!this.statusEl) return;\n this.statusEl.textContent = message || '';\n this.statusEl.style.display = message ? 'block' : 'none';\n }\n\n}\n\nexport default MetricsCountryMapView;\n"],"names":["MapView","View","constructor","options","super","className","this","markers","center","zoom","height","showZoomControl","tileLayer","showLeafletBranding","showLayerControl","layerOptions","osm","satellite","terrain","dark","light","watercolor","bw","streets","interactive","scrollZoom","dragPan","doubleClickZoom","keyboard","touchZoom","map","leafletMarkers","_tileLayer","template","onAfterRender","loadLeaflet","initializeMap","window","L","cssLoaded","Promise","resolve","link","document","createElement","rel","href","onload","onerror","head","appendChild","jsLoaded","reject","script","src","all","getTileLayerUrl","tileLayers","url","attribution","maxZoom","mapElement","element","querySelector","id","mapCenter","length","lat","lng","zoomControl","scrollWheelZoom","dragging","boxZoom","tap","attributionControl","setPrefix","e","tileConfig","addTo","container","parentElement","style","position","selector","top","right","zIndex","maxWidth","setAttribute","Object","entries","forEach","key","label","opt","value","textContent","selected","addEventListener","setTileLayer","addMarkers","fitBounds","setTimeout","invalidateSize","Array","isArray","markerData","popup","icon","markerOptions","marker","bindPopup","push","group","featureGroup","getBounds","pad","updateMarkers","newMarkers","clearMarkers","setView","removeLayer","setZoom","original","onBeforeDestroy","remove","showAsDialog","view","dialogOptions","title","header","body","size","centered","init","getApp","showDialog","MapLibreView","pitch","bearing","mapStyle","showNavigationControl","autoFitBounds","mapMarkers","pendingMarkers","lineSources","pendingLineData","Map","loadMapLibre","maplibregl","getMapStyle","styles","version","sources","type","tiles","tileSize","layers","source","glyphs","touchZoomRotate","addControl","NavigationControl","on","initialMarkers","addLineSource","clear","color","el","markerSize","Number","width","borderRadius","backgroundColor","border","boxShadow","cursor","display","alignItems","justifyContent","innerHTML","Marker","setLngLat","mapPopup","Popup","offset","setHTML","setPopup","bounds","LngLatBounds","extend","padding","flyTo","data","paint","layout","sourceId","getLayer","getSource","removeSource","addSource","addLayer","set","updateLineSource","setData","setPaintProperty","setLayoutProperty","setPitch","setBearing","COUNTRY_CENTROIDS","AD","name","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","YE","YT","ZA","ZM","ZW","MetricsCountryMapView","mapHeight","endpoint","account","category","slugs","granularity","maxCountries","metricLabel","mapOptions","showRoutes","routeOrigin","_refreshing","getTemplate","onInit","statusEl","mapView","containerId","addChild","refresh","setStatus","metrics","fetchMetrics","applyMetrics","error","console","rest","Error","params","with_labels","slugsArray","response","GET","success","status","labels","iso","series","total","reduce","sum","centroid","toUpperCase","code","values","renderLegend","sort","a","b","topEntries","slice","maxValue","entry","intensity","Math","round","getMarkerColor","toLocaleString","renderRoutes","end","mix","idx","legendEl","rows","percent","toFixed","join","origin","geojson","features","geometry","coordinates","properties","filter","message"],"mappings":"uCAqBA,MAAMA,gBAAgBC,EAClB,WAAAC,CAAYC,EAAU,IAClBC,MAAM,CACFC,UAAW,cACRF,IAGPG,KAAKC,QAAUJ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