@qratilabs/qrati-connect 2.18.0 → 2.19.1

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 (43) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/element/{cFiX5XpH.js → 9hFRKQTz.js} +1 -1
  3. package/element/{C2wSnFgo.js → BDfS178N.js} +1 -1
  4. package/element/{DQpZuO_g.js → BPJdmb-n.js} +19 -11
  5. package/element/{CpXF8hSs.js → BcbTpgCL.js} +3 -3
  6. package/element/{BWpGYu6o.js → Bthg7jjx.js} +1 -1
  7. package/element/CJHwaZlF.js +4 -0
  8. package/element/{s-uFfVs8.js → CRkKvdFk.js} +1 -1
  9. package/element/{BJKp8z_Y.js → D2Ekv0BO.js} +1 -1
  10. package/element/{B3PnczgW.js → DPCT8N8u.js} +1 -1
  11. package/element/{DSkNPSoA.js → DcYOBkni.js} +1 -1
  12. package/element/{DeIGxYF9.js → rfpQMFBA.js} +1 -1
  13. package/element/web.es.js +44 -44
  14. package/package.json +1 -1
  15. package/react/{Dk1n-dCc.js → -pPiIksh.js} +1 -1
  16. package/react/{1jkPzAQP.js → 3ELkYr5x.js} +1 -1
  17. package/react/{DVHopcEy.js → A5j-APoo.js} +1 -1
  18. package/react/{DCXtW9qz.js → BUvxnH1l.js} +1 -1
  19. package/react/{BhV55-yN.js → Bec5xeLU.js} +1 -1
  20. package/react/{Dmc8pfx-.js → Bv-kIUzA.js} +1 -1
  21. package/react/{DoEAn-0B.js → BxRpgZYF.js} +1 -1
  22. package/react/{QvDJYu5_.js → C5ddJD1C.js} +1 -1
  23. package/react/{D-4Pgq2O.js → C8gjgLEP.js} +1 -1
  24. package/react/{EHEuvqs8.js → CBlgNA7o.js} +1 -1
  25. package/react/{CiT4o63a.js → CC-KD1vv.js} +1 -1
  26. package/react/CcHquimJ.js +1 -0
  27. package/react/D25CQslU.js +4 -0
  28. package/react/{A--57d8I.js → DSpGEHWU.js} +1 -1
  29. package/react/{1jCdh7RC.js → Denx3bSB.js} +1 -1
  30. package/react/{CybQW90i.js → DpdtQZDC.js} +19 -11
  31. package/react/{DXcoSfgy.js → Dx3fTflu.js} +4 -4
  32. package/react/{BqXlcEUy.js → GqoKkUUo.js} +1 -1
  33. package/react/{BqkodWNb.js → QIpqvNGH.js} +1 -1
  34. package/react/{yv7A6fzU.js → Vri3EOjK.js} +1 -1
  35. package/react/{DOvusjaa.js → _Zgp2alp.js} +1 -1
  36. package/react/e-di_fDQ.js +1 -0
  37. package/react/index.cjs +1 -1
  38. package/react/index.mjs +13 -13
  39. package/umd/web.umd.js +1 -1
  40. package/element/Bxj0_YIt.js +0 -4
  41. package/react/By2LZrpb.js +0 -4
  42. package/react/YdJqOiJV.js +0 -1
  43. package/react/sndEiRn7.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,29 @@
1
+ # [2.19.0](https://github.com/qrati-labs/qrati-connect-ts/compare/v2.18.0...v2.19.0) (2026-05-12)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * uncomment localized login button for improved accessibility ([cfbb22a](https://github.com/qrati-labs/qrati-connect-ts/commit/cfbb22a9664a3b8d49fd662a9ce68936294591a6))
7
+
8
+
9
+ ### Features
10
+
11
+ * add Mapbox and Maplibre CSS imports for improved styling in map components ([6c71f13](https://github.com/qrati-labs/qrati-connect-ts/commit/6c71f133b74ed03942db7afd51ddd921572ae313))
12
+
13
+ # [2.18.0](https://github.com/qrati-labs/qrati-connect-ts/compare/v2.17.0...v2.18.0) (2026-05-12)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * ensure safe image URLs for event markers in GoogleMapsView, MapboxView, and OpenStreetMapView components ([da8d4a0](https://github.com/qrati-labs/qrati-connect-ts/commit/da8d4a0f3fb44444d52a9173f28d42b542808242))
19
+
20
+
21
+ ### Features
22
+
23
+ * enhance folder view functionality and integrate heat layer for event visualization ([06157ba](https://github.com/qrati-labs/qrati-connect-ts/commit/06157baa8e81a61a95c753e968097bddbb738a57))
24
+ * implement FolderTreeSidebar component for hierarchical folder navigation and integrate into map view ([9a748bd](https://github.com/qrati-labs/qrati-connect-ts/commit/9a748bdfb249554ec68454cf2615063f68c5290a))
25
+ * implement useFolderMap hook for hierarchical folder structure and event mapping ([f48e758](https://github.com/qrati-labs/qrati-connect-ts/commit/f48e758d71231c734d13245f6fefe5b8c127adc8))
26
+
1
27
  # [2.17.0](https://github.com/qrati-labs/qrati-connect-ts/compare/v2.16.0...v2.17.0) (2026-05-08)
2
28
 
3
29
 
@@ -1,3 +1,3 @@
1
- import{r as e}from"./hOIsfHC7.js";import{B as r,Ht as t,Mt as n,Pt as o,Q as a,X as i,g as s,jt as c,p as l,r as d,zt as u}from"./DQpZuO_g.js";import{t as p}from"./BWpGYu6o.js";import{a as m,i as f,n as g,o as h,r as y,t as x}from"./DeIGxYF9.js";var b=[[90,-180],[-90,180]],v=[20,0],L="#fb8500",w={topLeft:[276,60],bottomRight:[60,60]},z=new p,T=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),B=({onExplore:p,logoUrl:B})=>{const j=c(null),k=c(null),O=c(null),C=c(null),S=c(null),Z=c(null),I=c(null),R=c(!1),E=c(!1),A=n(()=>(()=>{try{const e=sessionStorage.getItem(r);if(!e)return null;const t=JSON.parse(e);if("number"==typeof t?.center?.lat&&"number"==typeof t?.center?.lng&&"number"==typeof t?.zoom)return t}catch{}return null})(),[]),[F,$]=o(!0),[G,M]=o(!1),{folderTree:N,activeFolderId:V,activeFolder:q,visibleEvents:J,setActiveFolderId:P,isLoadingEvents:H}=h(),{organization:W}=l();return u(()=>{if(!j.current||k.current)return;let t,n=!1;return(async()=>{try{const o=await import("./CMbOX_GS.js").then(r=>/* @__PURE__ */e(r.default,1));if(n)return;if("undefined"!=typeof window&&(window.L=o),await Promise.all([import("./BxbCvlCo.js").then(r=>/* @__PURE__ */e(r.default,1)),import("./Cdux6g1i.js")]),n)return;const a=window.L??o;if(!j.current)return;const i=o.map(j.current,{center:A?.center?[A.center.lat??v[0],A.center.lng??v[1]]:v,zoom:A?.zoom??3,minZoom:3,zoomControl:!0,worldCopyJump:!1,maxBounds:o.latLngBounds(b),maxBoundsViscosity:1});o.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:"&copy; OpenStreetMap contributors",maxZoom:19,noWrap:!0}).addTo(i);const s=o.layerGroup().addTo(i),c="function"==typeof a.heatLayer?a.heatLayer([],{radius:30,blur:30,maxZoom:10,minOpacity:.35}):null;c?.addTo(i);const l="function"==typeof a.markerClusterGroup?a.markerClusterGroup({chunkedLoading:!0,showCoverageOnHover:!1,spiderfyOnMaxZoom:!0,zoomToBoundsOnClick:!0,maxClusterRadius:48}):o.layerGroup();l.addTo(i);const d=()=>{I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{try{sessionStorage.setItem(r,JSON.stringify({center:i.getCenter(),zoom:i.getZoom()}))}catch{}},250)};let u;i.on("zoomend",d),i.on("moveend",d),k.current=i,O.current=a,C.current=s,Z.current=c,S.current=l,"undefined"!=typeof ResizeObserver&&j.current&&(u=new ResizeObserver(()=>i.invalidateSize(!1)),u.observe(j.current)),requestAnimationFrame(()=>i.invalidateSize(!1)),M(!0),$(!1),t=()=>{u?.disconnect(),I.current&&clearTimeout(I.current),i.off("zoomend",d),i.off("moveend",d),i.remove(),O.current=null,k.current=null,C.current=null,Z.current=null,S.current=null}}finally{n||$(!1)}})(),()=>{n=!0,t?.()}},[A]),u(()=>{if(!G)return;const e=O.current;if(!e)return;const r=k.current;if(C.current?.clearLayers(),S.current?.clearLayers(),null===V&&N.length>0){r&&Z.current&&(Z.current.setLatLngs?.([]),r.hasLayer(Z.current)&&r.removeLayer(Z.current));const t=r=>{for(const n of r)if(n.centroid){const[r,t]=n.centroid,o=e.divIcon({className:"",html:`<div style="transform:translate(-50%,-50%);background:${y(n.color,L)};color:#fff;border-radius:20px;padding:5px 10px;font-size:12px;font-weight:600;white-space:nowrap;box-shadow:0 2px 8px rgba(0,0,0,0.25);border:2px solid rgba(255,255,255,0.4);cursor:pointer;display:inline-flex;align-items:center;gap:6px;"><span>${T(n.folder.name)}</span><span style="background:rgba(0,0,0,0.18);border-radius:10px;padding:1px 5px;font-size:10px;">${n.eventCount}</span></div>`,iconSize:[0,0],iconAnchor:[0,0]});e.marker([t,r],{icon:o}).on("click",()=>P(n.folder._id)).addTo(C.current)}else n.children.length>0&&t(n.children)};t(N)}else{if(0===J.length)return;const n=0===N.length&&null===V,o=y(q?.color,L);if(r&&Z.current&&(n&&!r.hasLayer(Z.current)?Z.current.addTo(r):n||(Z.current.setLatLngs?.([]),r.hasLayer(Z.current)&&r.removeLayer(Z.current))),J.forEach(r=>{const n=r.location.x,s=r.location.y,c=e.divIcon({className:"qrati-leaflet-marker-wrapper",html:`<div style="width:36px;height:36px;cursor:pointer;background:${o};border-radius:50% 50% 50% 0;transform:rotate(-45deg);border:2px solid white;box-shadow:0 2px 8px rgba(0,0,0,0.3);display:flex;align-items:center;justify-content:center;overflow:hidden;">${f(B)?`<img src="${f(B)}" style="width:24px;height:24px;border-radius:50%;object-fit:cover;transform:rotate(45deg);" />`:""}</div>`,iconSize:[36,36],iconAnchor:[18,36],popupAnchor:[0,-36]}),l=e.marker([s,n],{icon:c}),u=document.createElement("div");u.style.width="fit-content",((e,r,n)=>{t(/* @__PURE__ */a(i,{client:z,children:/* @__PURE__ */a(d,{children:/* @__PURE__ */a(m,{event:e,onExplore:n})})}),r)})(r,u,p),l.bindPopup(u,{closeButton:!0,maxWidth:256}),S.current?.addLayer(l)}),n&&Z.current){const e=J.reduce((e,r)=>Math.max(e,r.views??0),1),r=J.map(e=>[e.location.y,e.location.x,e.views??1]);Z.current.setOptions?.({radius:30,blur:30,maxZoom:10,minOpacity:.35,max:e}),Z.current.setLatLngs?.(r)}if(n&&!E.current&&r&&(E.current=!0,!A)){const t=e.latLngBounds([]);J.forEach(e=>t.extend([e.location.y,e.location.x])),t.isValid()&&r.fitBounds(t,{paddingTopLeft:w.topLeft,paddingBottomRight:w.bottomRight,maxZoom:8})}}},[V,N,J,G,p,B,P,q,A]),u(()=>{if(!G)return;const e=k.current,r=O.current;if(!e||!r)return;if(!R.current&&A)return void(R.current=!0);R.current=!0;const t={paddingTopLeft:w.topLeft,paddingBottomRight:w.bottomRight,duration:3,easeLinearity:1};if(V){const n=g(N,V);if(!n?.folder.boundary?.length)return;const o=r.latLngBounds([]);for(const e of n.folder.boundary)o.extend([e.y,e.x]);o.isValid()&&e.flyToBounds(o,{...t,maxZoom:14})}else{const n=r.latLngBounds([]),o=e=>{for(const r of e)r.centroid?n.extend([r.centroid[1],r.centroid[0]]):o(r.children)};o(N),n.isValid()&&e.flyToBounds(n,{...t,maxZoom:8})}},[V,N,G,A]),/* @__PURE__ */a("div",{class:"relative h-screen w-full sm:h-[calc(100vh-4rem)]",style:s(W),children:[
1
+ import{r as e}from"./hOIsfHC7.js";import{B as r,Ht as t,Mt as n,Pt as o,Q as a,X as i,g as s,jt as c,p as l,r as d,zt as u}from"./BPJdmb-n.js";import{t as p}from"./Bthg7jjx.js";import{a as m,i as f,n as g,o as h,r as y,t as x}from"./rfpQMFBA.js";var b=[[90,-180],[-90,180]],v=[20,0],L="#fb8500",w={topLeft:[276,60],bottomRight:[60,60]},z=new p,T=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),B=({onExplore:p,logoUrl:B})=>{const j=c(null),k=c(null),O=c(null),C=c(null),S=c(null),Z=c(null),I=c(null),R=c(!1),E=c(!1),A=n(()=>(()=>{try{const e=sessionStorage.getItem(r);if(!e)return null;const t=JSON.parse(e);if("number"==typeof t?.center?.lat&&"number"==typeof t?.center?.lng&&"number"==typeof t?.zoom)return t}catch{}return null})(),[]),[F,$]=o(!0),[G,M]=o(!1),{folderTree:N,activeFolderId:V,activeFolder:q,visibleEvents:J,setActiveFolderId:P,isLoadingEvents:H}=h(),{organization:W}=l();return u(()=>{if(!j.current||k.current)return;let t,n=!1;return(async()=>{try{const o=await import("./CMbOX_GS.js").then(r=>/* @__PURE__ */e(r.default,1));if(n)return;if("undefined"!=typeof window&&(window.L=o),await Promise.all([import("./BxbCvlCo.js").then(r=>/* @__PURE__ */e(r.default,1)),import("./Cdux6g1i.js")]),n)return;const a=window.L??o;if(!j.current)return;const i=o.map(j.current,{center:A?.center?[A.center.lat??v[0],A.center.lng??v[1]]:v,zoom:A?.zoom??3,minZoom:3,zoomControl:!0,worldCopyJump:!1,maxBounds:o.latLngBounds(b),maxBoundsViscosity:1});o.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:"&copy; OpenStreetMap contributors",maxZoom:19,noWrap:!0}).addTo(i);const s=o.layerGroup().addTo(i),c="function"==typeof a.heatLayer?a.heatLayer([],{radius:30,blur:30,maxZoom:10,minOpacity:.35}):null;c?.addTo(i);const l="function"==typeof a.markerClusterGroup?a.markerClusterGroup({chunkedLoading:!0,showCoverageOnHover:!1,spiderfyOnMaxZoom:!0,zoomToBoundsOnClick:!0,maxClusterRadius:48}):o.layerGroup();l.addTo(i);const d=()=>{I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{try{sessionStorage.setItem(r,JSON.stringify({center:i.getCenter(),zoom:i.getZoom()}))}catch{}},250)};let u;i.on("zoomend",d),i.on("moveend",d),k.current=i,O.current=a,C.current=s,Z.current=c,S.current=l,"undefined"!=typeof ResizeObserver&&j.current&&(u=new ResizeObserver(()=>i.invalidateSize(!1)),u.observe(j.current)),requestAnimationFrame(()=>i.invalidateSize(!1)),M(!0),$(!1),t=()=>{u?.disconnect(),I.current&&clearTimeout(I.current),i.off("zoomend",d),i.off("moveend",d),i.remove(),O.current=null,k.current=null,C.current=null,Z.current=null,S.current=null}}finally{n||$(!1)}})(),()=>{n=!0,t?.()}},[A]),u(()=>{if(!G)return;const e=O.current;if(!e)return;const r=k.current;if(C.current?.clearLayers(),S.current?.clearLayers(),null===V&&N.length>0){r&&Z.current&&(Z.current.setLatLngs?.([]),r.hasLayer(Z.current)&&r.removeLayer(Z.current));const t=r=>{for(const n of r)if(n.centroid){const[r,t]=n.centroid,o=e.divIcon({className:"",html:`<div style="transform:translate(-50%,-50%);background:${y(n.color,L)};color:#fff;border-radius:20px;padding:5px 10px;font-size:12px;font-weight:600;white-space:nowrap;box-shadow:0 2px 8px rgba(0,0,0,0.25);border:2px solid rgba(255,255,255,0.4);cursor:pointer;display:inline-flex;align-items:center;gap:6px;"><span>${T(n.folder.name)}</span><span style="background:rgba(0,0,0,0.18);border-radius:10px;padding:1px 5px;font-size:10px;">${n.eventCount}</span></div>`,iconSize:[0,0],iconAnchor:[0,0]});e.marker([t,r],{icon:o}).on("click",()=>P(n.folder._id)).addTo(C.current)}else n.children.length>0&&t(n.children)};t(N)}else{if(0===J.length)return;const n=0===N.length&&null===V,o=y(q?.color,L);if(r&&Z.current&&(n&&!r.hasLayer(Z.current)?Z.current.addTo(r):n||(Z.current.setLatLngs?.([]),r.hasLayer(Z.current)&&r.removeLayer(Z.current))),J.forEach(r=>{const n=r.location.x,s=r.location.y,c=e.divIcon({className:"qrati-leaflet-marker-wrapper",html:`<div style="width:36px;height:36px;cursor:pointer;background:${o};border-radius:50% 50% 50% 0;transform:rotate(-45deg);border:2px solid white;box-shadow:0 2px 8px rgba(0,0,0,0.3);display:flex;align-items:center;justify-content:center;overflow:hidden;">${f(B)?`<img src="${f(B)}" style="width:24px;height:24px;border-radius:50%;object-fit:cover;transform:rotate(45deg);" />`:""}</div>`,iconSize:[36,36],iconAnchor:[18,36],popupAnchor:[0,-36]}),l=e.marker([s,n],{icon:c}),u=document.createElement("div");u.style.width="fit-content",((e,r,n)=>{t(/* @__PURE__ */a(i,{client:z,children:/* @__PURE__ */a(d,{children:/* @__PURE__ */a(m,{event:e,onExplore:n})})}),r)})(r,u,p),l.bindPopup(u,{closeButton:!0,maxWidth:256}),S.current?.addLayer(l)}),n&&Z.current){const e=J.reduce((e,r)=>Math.max(e,r.views??0),1),r=J.map(e=>[e.location.y,e.location.x,e.views??1]);Z.current.setOptions?.({radius:30,blur:30,maxZoom:10,minOpacity:.35,max:e}),Z.current.setLatLngs?.(r)}if(n&&!E.current&&r&&(E.current=!0,!A)){const t=e.latLngBounds([]);J.forEach(e=>t.extend([e.location.y,e.location.x])),t.isValid()&&r.fitBounds(t,{paddingTopLeft:w.topLeft,paddingBottomRight:w.bottomRight,maxZoom:8})}}},[V,N,J,G,p,B,P,q,A]),u(()=>{if(!G)return;const e=k.current,r=O.current;if(!e||!r)return;if(!R.current&&A)return void(R.current=!0);R.current=!0;const t={paddingTopLeft:w.topLeft,paddingBottomRight:w.bottomRight,duration:3,easeLinearity:1};if(V){const n=g(N,V);if(!n?.folder.boundary?.length)return;const o=r.latLngBounds([]);for(const e of n.folder.boundary)o.extend([e.y,e.x]);o.isValid()&&e.flyToBounds(o,{...t,maxZoom:14})}else{const n=r.latLngBounds([]),o=e=>{for(const r of e)r.centroid?n.extend([r.centroid[1],r.centroid[0]]):o(r.children)};o(N),n.isValid()&&e.flyToBounds(n,{...t,maxZoom:8})}},[V,N,G,A]),/* @__PURE__ */a("div",{class:"relative h-screen w-full sm:h-[calc(100vh-4rem)]",style:s(W),children:[
2
2
  /* @__PURE__ */a(x,{positionClass:"absolute top-3 left-16 z-[1000]",folderTree:N,activeFolderId:V,setActiveFolderId:P}),H&&/* @__PURE__ */a("div",{class:"absolute inset-0 z-10 flex items-center justify-center bg-white/60",children:/* @__PURE__ */a("div",{class:"border-primary size-10 animate-spin rounded-full border-4 border-t-transparent"})}),F&&/* @__PURE__ */a("div",{class:"absolute inset-0 z-20 flex items-center justify-center bg-white/85",children:/* @__PURE__ */a("div",{class:"flex flex-col items-center gap-3",children:[/* @__PURE__ */a("div",{class:"border-primary size-10 animate-spin rounded-full border-4 border-t-transparent"}),/* @__PURE__ */a("p",{class:"text-sm font-medium text-slate-700",children:"Loading map…"})]})}),
3
3
  /* @__PURE__ */a("div",{ref:j,class:"h-full w-full rounded-xl border border-slate-200"})]})};export{B as default};
@@ -1,3 +1,3 @@
1
- import{B as t,Ht as e,Mt as r,Pt as n,Q as s,X as o,g as i,jt as a,p as c,r as l,zt as u}from"./DQpZuO_g.js";import{t as h}from"./BWpGYu6o.js";import{a as p,i as d,n as f,o as m,r as g,t as y}from"./DeIGxYF9.js";var{getOwnPropertyNames:b,getOwnPropertySymbols:w}=Object,{hasOwnProperty:x}=Object.prototype;function k(t,e){return function(r,n,s){return t(r,n,s)&&e(r,n,s)}}function E(t){return function(e,r,n){if(!e||!r||"object"!=typeof e||"object"!=typeof r)return t(e,r,n);const{cache:s}=n,o=s.get(e),i=s.get(r);if(o&&i)return o===r&&i===e;s.set(e,r),s.set(r,e);const a=t(e,r,n);return s.delete(e),s.delete(r),a}}function v(t){return b(t).concat(w(t))}var M=Object.hasOwn||((t,e)=>x.call(t,e));function A(t,e){return t===e||!t&&!e&&t!=t&&e!=e}var{getOwnPropertyDescriptor:C,keys:_}=Object;function j(t,e){return t.byteLength===e.byteLength&&N(new Uint8Array(t),new Uint8Array(e))}function L(t,e,r){let n=t.length;if(e.length!==n)return!1;for(;n-- >0;)if(!r.equals(t[n],e[n],n,n,t,e,r))return!1;return!0}function I(t,e){return t.byteLength===e.byteLength&&N(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function O(t,e){return A(t.getTime(),e.getTime())}function q(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function T(t,e){return t===e}function P(t,e,r){const n=t.size;if(n!==e.size)return!1;if(!n)return!0;const s=new Array(n),o=t.entries();let i,a,c=0;for(;(i=o.next())&&!i.done;){const n=e.entries();let o=!1,l=0;for(;(a=n.next())&&!a.done;){if(s[l]){l++;continue}const n=i.value,u=a.value;if(r.equals(n[0],u[0],c,l,t,e,r)&&r.equals(n[1],u[1],n[0],u[0],t,e,r)){o=s[l]=!0;break}l++}if(!o)return!1;c++}return!0}var S=A;function z(t,e,r){const n=_(t);let s=n.length;if(_(e).length!==s)return!1;for(;s-- >0;)if(!$(t,e,r,n[s]))return!1;return!0}function U(t,e,r){const n=v(t);let s,o,i,a=n.length;if(v(e).length!==a)return!1;for(;a-- >0;){if(s=n[a],!$(t,e,r,s))return!1;if(o=C(t,s),i=C(e,s),(o||i)&&(!o||!i||o.configurable!==i.configurable||o.enumerable!==i.enumerable||o.writable!==i.writable))return!1}return!0}function Z(t,e){return A(t.valueOf(),e.valueOf())}function B(t,e){return t.source===e.source&&t.flags===e.flags}function F(t,e,r){const n=t.size;if(n!==e.size)return!1;if(!n)return!0;const s=new Array(n),o=t.values();let i,a;for(;(i=o.next())&&!i.done;){const n=e.values();let o=!1,c=0;for(;(a=n.next())&&!a.done;){if(!s[c]&&r.equals(i.value,a.value,i.value,a.value,t,e,r)){o=s[c]=!0;break}c++}if(!o)return!1}return!0}function N(t,e){let r=t.byteLength;if(e.byteLength!==r||t.byteOffset!==e.byteOffset)return!1;for(;r-- >0;)if(t[r]!==e[r])return!1;return!0}function D(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function $(t,e,r,n){return!("_owner"!==n&&"__o"!==n&&"__v"!==n||!t.$$typeof&&!e.$$typeof)||M(e,n)&&r.equals(t[n],e[n],n,n,t,e,r)}var R={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},G=Object.prototype.toString;var V=K();function K(t={}){const{circular:e=!1,createInternalComparator:r,createState:n,strict:s=!1}=t,o=function({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:r,areDatesEqual:n,areErrorsEqual:s,areFunctionsEqual:o,areMapsEqual:i,areNumbersEqual:a,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:h,areTypedArraysEqual:p,areUrlsEqual:d,unknownTagComparators:f}){return function(m,g,y){if(m===g)return!0;if(null==m||null==g)return!1;const b=typeof m;if(b!==typeof g)return!1;if("object"!==b)return"number"===b?a(m,g,y):"function"===b&&o(m,g,y);const w=m.constructor;if(w!==g.constructor)return!1;if(w===Object)return c(m,g,y);if(Array.isArray(m))return e(m,g,y);if(w===Date)return n(m,g,y);if(w===RegExp)return u(m,g,y);if(w===Map)return i(m,g,y);if(w===Set)return h(m,g,y);const x=G.call(m);if("[object Date]"===x)return n(m,g,y);if("[object RegExp]"===x)return u(m,g,y);if("[object Map]"===x)return i(m,g,y);if("[object Set]"===x)return h(m,g,y);if("[object Object]"===x)return"function"!=typeof m.then&&"function"!=typeof g.then&&c(m,g,y);if("[object URL]"===x)return d(m,g,y);if("[object Error]"===x)return s(m,g,y);if("[object Arguments]"===x)return c(m,g,y);if(R[x])return p(m,g,y);if("[object ArrayBuffer]"===x)return t(m,g,y);if("[object DataView]"===x)return r(m,g,y);if("[object Boolean]"===x||"[object Number]"===x||"[object String]"===x)return l(m,g,y);if(f){let t=f[x];if(!t){const e=null!=(k=m)?k[Symbol.toStringTag]:void 0;e&&(t=f[e])}if(t)return t(m,g,y)}var k;return!1}}(function({circular:t,createCustomConfig:e,strict:r}){let n={areArrayBuffersEqual:j,areArraysEqual:r?U:L,areDataViewsEqual:I,areDatesEqual:O,areErrorsEqual:q,areFunctionsEqual:T,areMapsEqual:r?k(P,U):P,areNumbersEqual:S,areObjectsEqual:r?U:z,arePrimitiveWrappersEqual:Z,areRegExpsEqual:B,areSetsEqual:r?k(F,U):F,areTypedArraysEqual:r?k(N,U):N,areUrlsEqual:D,unknownTagComparators:void 0};if(e&&(n=Object.assign({},n,e(n))),t){const t=E(n.areArraysEqual),e=E(n.areMapsEqual),r=E(n.areObjectsEqual),s=E(n.areSetsEqual);n=Object.assign({},n,{areArraysEqual:t,areMapsEqual:e,areObjectsEqual:r,areSetsEqual:s})}return n}(t));return function({circular:t,comparator:e,createState:r,equals:n,strict:s}){if(r)return function(o,i){const{cache:a=(t?/* @__PURE__ */new WeakMap:void 0),meta:c}=r();return e(o,i,{cache:a,equals:n,meta:c,strict:s})};if(t)return function(t,r){return e(t,r,{cache:/* @__PURE__ */new WeakMap,equals:n,meta:void 0,strict:s})};const o={cache:void 0,equals:n,meta:void 0,strict:s};return function(t,r){return e(t,r,o)}}({circular:e,comparator:o,createState:n,equals:r?r(o):(i=o,function(t,e,r,n,s,o,a){return i(t,e,a)}),strict:s});var i}K({strict:!0}),K({circular:!0}),K({circular:!0,strict:!0}),K({createInternalComparator:()=>A}),K({strict:!0,createInternalComparator:()=>A}),K({circular:!0,createInternalComparator:()=>A}),K({circular:!0,createInternalComparator:()=>A,strict:!0});var W=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],X=class t{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[r,n]=new Uint8Array(e,0,2);if(219!==r)throw new Error("Data does not appear to be in a KDBush format.");const s=n>>4;if(1!==s)throw new Error(`Got v${s} data when expected v1.`);const o=W[15&n];if(!o)throw new Error("Unrecognized array type.");const[i]=new Uint16Array(e,2,1),[a]=new Uint32Array(e,4,1);return new t(a,i,o,e)}constructor(t,e=64,r=Float64Array,n){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const s=W.indexOf(this.ArrayType),o=2*t*this.ArrayType.BYTES_PER_ELEMENT,i=t*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-i%8)%8;if(s<0)throw new Error(`Unexpected typed array class: ${r}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+i+a,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+o+i+a),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+i+a,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+s]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t)}add(t,e){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return H(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:o,nodeSize:i}=this,a=[0,s.length-1,0],c=[];for(;a.length;){const l=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=i){for(let i=h;i<=u;i++){const a=o[2*i],l=o[2*i+1];a>=t&&a<=r&&l>=e&&l<=n&&c.push(s[i])}continue}const p=h+u>>1,d=o[2*p],f=o[2*p+1];d>=t&&d<=r&&f>=e&&f<=n&&c.push(s[p]),(0===l?t<=d:e<=f)&&(a.push(h),a.push(p-1),a.push(1-l)),(0===l?r>=d:n>=f)&&(a.push(p+1),a.push(u),a.push(1-l))}return c}within(t,e,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:s,nodeSize:o}=this,i=[0,n.length-1,0],a=[],c=r*r;for(;i.length;){const l=i.pop()||0,u=i.pop()||0,h=i.pop()||0;if(u-h<=o){for(let r=h;r<=u;r++)tt(s[2*r],s[2*r+1],t,e)<=c&&a.push(n[r]);continue}const p=h+u>>1,d=s[2*p],f=s[2*p+1];tt(d,f,t,e)<=c&&a.push(n[p]),(0===l?t-r<=d:e-r<=f)&&(i.push(h),i.push(p-1),i.push(1-l)),(0===l?t+r>=d:e+r>=f)&&(i.push(p+1),i.push(u),i.push(1-l))}return a}};function H(t,e,r,n,s,o){if(s-n<=r)return;const i=n+s>>1;J(t,e,i,n,s,o),H(t,e,r,n,i-1,1-o),H(t,e,r,i+1,s,1-o)}function J(t,e,r,n,s,o){for(;s>n;){if(s-n>600){const i=s-n+1,a=r-n+1,c=Math.log(i),l=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*l*(i-l)/i)*(a-i/2<0?-1:1);J(t,e,r,Math.max(n,Math.floor(r-a*l/i+u)),Math.min(s,Math.floor(r+(i-a)*l/i+u)),o)}const i=e[2*r+o];let a=n,c=s;for(Y(t,e,n,r),e[2*s+o]>i&&Y(t,e,n,s);a<c;){for(Y(t,e,a,c),a++,c--;e[2*a+o]<i;)a++;for(;e[2*c+o]>i;)c--}e[2*n+o]===i?Y(t,e,n,c):(c++,Y(t,e,c,s)),c<=r&&(n=c+1),r<=c&&(s=c-1)}}function Y(t,e,r,n){Q(t,r,n),Q(e,2*r,2*n),Q(e,2*r+1,2*n+1)}function Q(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function tt(t,e,r,n){const s=t-r,o=e-n;return s*s+o*o}var et,rt={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},nt=Math.fround||(et=new Float32Array(1),t=>(et[0]=+t,et[0])),st=class{constructor(t){this.options=Object.assign(Object.create(rt),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:r,maxZoom:n}=this.options;e&&console.time("total time");const s=`prepare ${t.length} points`;e&&console.time(s),this.points=t;const o=[];for(let a=0;a<t.length;a++){const e=t[a];if(!e.geometry)continue;const[r,n]=e.geometry.coordinates,s=nt(at(r)),i=nt(ct(n));o.push(s,i,1/0,a,-1,1),this.options.reduce&&o.push(0)}let i=this.trees[n+1]=this._createTree(o);e&&console.timeEnd(s);for(let a=n;a>=r;a--){const t=+Date.now();i=this.trees[a]=this._createTree(this._cluster(i,a)),e&&console.log("z%d: %d clusters in %dms",a,i.numItems,+Date.now()-t)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let r=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let s=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)r=-180,s=180;else if(r>s){const t=this.getClusters([r,n,180,o],e),i=this.getClusters([-180,n,s,o],e);return t.concat(i)}const i=this.trees[this._limitZoom(e)],a=i.range(at(r),ct(o),at(s),ct(n)),c=i.data,l=[];for(const u of a){const t=this.stride*u;l.push(c[t+5]>1?ot(c,t,this.clusterProps):this.points[c[t+3]])}return l}getChildren(t){const e=this._getOriginId(t),r=this._getOriginZoom(t),n="No cluster with the specified id.",s=this.trees[r];if(!s)throw new Error(n);const o=s.data;if(e*this.stride>=o.length)throw new Error(n);const i=this.options.radius/(this.options.extent*Math.pow(2,r-1)),a=o[e*this.stride],c=o[e*this.stride+1],l=s.within(a,c,i),u=[];for(const h of l){const e=h*this.stride;o[e+4]===t&&u.push(o[e+5]>1?ot(o,e,this.clusterProps):this.points[o[e+3]])}if(0===u.length)throw new Error(n);return u}getLeaves(t,e,r){e=e||10,r=r||0;const n=[];return this._appendLeaves(n,t,e,r,0),n}getTile(t,e,r){const n=this.trees[this._limitZoom(t)],s=Math.pow(2,t),{extent:o,radius:i}=this.options,a=i/o,c=(r-a)/s,l=(r+1+a)/s,u={features:[]};return this._addTileFeatures(n.range((e-a)/s,c,(e+1+a)/s,l),n.data,e,r,s,u),0===e&&this._addTileFeatures(n.range(1-a/s,c,1,l),n.data,s,r,s,u),e===s-1&&this._addTileFeatures(n.range(0,c,a/s,l),n.data,-1,r,s,u),u.features.length?u:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e<=this.options.maxZoom;){const r=this.getChildren(t);if(e++,1!==r.length)break;t=r[0].properties.cluster_id}return e}_appendLeaves(t,e,r,n,s){const o=this.getChildren(e);for(const i of o){const e=i.properties;if(e&&e.cluster?s+e.point_count<=n?s+=e.point_count:s=this._appendLeaves(t,e.cluster_id,r,n,s):s<n?s++:t.push(i),t.length===r)break}return s}_createTree(t){const e=new X(t.length/this.stride|0,this.options.nodeSize,Float32Array);for(let r=0;r<t.length;r+=this.stride)e.add(t[r],t[r+1]);return e.finish(),e.data=t,e}_addTileFeatures(t,e,r,n,s,o){for(const i of t){const t=i*this.stride,a=e[t+5]>1;let c,l,u;if(a)c=it(e,t,this.clusterProps),l=e[t],u=e[t+1];else{const r=this.points[e[t+3]];c=r.properties;const[n,s]=r.geometry.coordinates;l=at(n),u=ct(s)}const h={type:1,geometry:[[Math.round(this.options.extent*(l*s-r)),Math.round(this.options.extent*(u*s-n))]],tags:c};let p;p=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==p&&(h.id=p),o.features.push(h)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:r,extent:n,reduce:s,minPoints:o}=this.options,i=r/(n*Math.pow(2,e)),a=t.data,c=[],l=this.stride;for(let u=0;u<a.length;u+=l){if(a[u+2]<=e)continue;a[u+2]=e;const r=a[u],n=a[u+1],h=t.within(a[u],a[u+1],i),p=a[u+5];let d=p;for(const t of h){const r=t*l;a[r+2]>e&&(d+=a[r+5])}if(d>p&&d>=o){let t,o=r*p,i=n*p,f=-1;const m=(u/l<<5)+(e+1)+this.points.length;for(const r of h){const n=r*l;if(a[n+2]<=e)continue;a[n+2]=e;const c=a[n+5];o+=a[n]*c,i+=a[n+1]*c,a[n+4]=m,s&&(t||(t=this._map(a,u,!0),f=this.clusterProps.length,this.clusterProps.push(t)),s(t,this._map(a,n)))}a[u+4]=m,c.push(o/d,i/d,1/0,m,-1,d),s&&c.push(f)}else{for(let t=0;t<l;t++)c.push(a[u+t]);if(d>1)for(const t of h){const r=t*l;if(!(a[r+2]<=e)){a[r+2]=e;for(let t=0;t<l;t++)c.push(a[r+t])}}}}return c}_getOriginId(t){return t-this.points.length>>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,r){if(t[e+5]>1){const n=this.clusterProps[t[e+6]];return r?Object.assign({},n):n}const n=this.points[t[e+3]].properties,s=this.options.map(n);return r&&s===n?Object.assign({},s):s}};function ot(t,e,r){return{type:"Feature",id:t[e+3],properties:it(t,e,r),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),lt(t[e+1])]}};var n}function it(t,e,r){const n=t[e+5],s=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+6],i=-1===o?{}:Object.assign({},r[o]);return Object.assign(i,{cluster:!0,cluster_id:t[e+3],point_count:n,point_count_abbreviated:s})}function at(t){return t/360+.5}function ct(t){const e=Math.sin(t*Math.PI/180),r=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return r<0?0:r>1?1:r}function lt(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}var ut=class{static isAdvancedMarkerAvailable(t){return google.maps.marker&&!0===t.getMapCapabilities().isAdvancedMarkersAvailable}static isAdvancedMarker(t){return google.maps.marker&&t instanceof google.maps.marker.AdvancedMarkerElement}static setMap(t,e){this.isAdvancedMarker(t)?t.map=e:t.setMap(e)}static getPosition(t){if(this.isAdvancedMarker(t)){if(t.position){if(t.position instanceof google.maps.LatLng)return t.position;if(Number.isFinite(t.position.lat)&&Number.isFinite(t.position.lng))return new google.maps.LatLng(t.position.lat,t.position.lng)}return new google.maps.LatLng(null)}return t.getPosition()}static getVisible(t){return!!this.isAdvancedMarker(t)||t.getVisible()}},ht=class{constructor({markers:t,position:e}){this.markers=[],t&&(this.markers=t),e&&(e instanceof google.maps.LatLng?this._position=e:this._position=new google.maps.LatLng(e))}get bounds(){if(0===this.markers.length&&!this._position)return;const t=new google.maps.LatLngBounds(this._position,this._position);for(const e of this.markers)t.extend(ut.getPosition(e));return t}get position(){return this._position||this.bounds.getCenter()}get count(){return this.markers.filter(t=>ut.getVisible(t)).length}push(t){this.markers.push(t)}delete(){this.marker&&(ut.setMap(this.marker,null),this.marker=void 0),this.markers.length=0}};function pt(t,e="assertion failed"){if(null==t)throw Error(e)}var dt,ft=class{constructor({maxZoom:t=16}){this.maxZoom=t}noop({markers:t}){return mt(t)}},mt=t=>t.map(t=>new ht({position:ut.getPosition(t),markers:[t]})),gt=class extends ft{constructor(t){var{maxZoom:e,radius:r=60}=t,n=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(t);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(t,n[s])&&(r[n[s]]=t[n[s]])}return r}(t,["maxZoom","radius"]);super({maxZoom:e}),this.markers=[],this.clusters=[],this.state={zoom:-1},this.superCluster=new st(Object.assign({maxZoom:this.maxZoom,radius:r},n))}calculate(t){let e=!1,r=t.map.getZoom();pt(r),r=Math.round(r);const n={zoom:r};if(!V(t.markers,this.markers)){e=!0,this.markers=[...t.markers];const r=this.markers.map(t=>{const e=ut.getPosition(t);return{type:"Feature",geometry:{type:"Point",coordinates:[e.lng(),e.lat()]},properties:{marker:t}}});this.superCluster.load(r)}return e||(this.state.zoom<=this.maxZoom||n.zoom<=this.maxZoom)&&(e=!V(this.state,n)),this.state=n,0===t.markers.length?(this.clusters=[],{clusters:this.clusters,changed:e}):(e&&(this.clusters=this.cluster(t)),{clusters:this.clusters,changed:e})}cluster({map:t}){const e=t.getZoom();return pt(e),this.superCluster.getClusters([-180,-90,180,90],Math.round(e)).map(t=>this.transformCluster(t))}transformCluster({geometry:{coordinates:[t,e]},properties:r}){if(r.cluster)return new ht({markers:this.superCluster.getLeaves(r.cluster_id,1/0).map(t=>t.properties.marker),position:{lat:e,lng:t}});const n=r.marker;return new ht({markers:[n],position:ut.getPosition(n)})}},yt=class{constructor(t,e){this.markers={sum:t.length};const r=e.map(t=>t.count),n=r.reduce((t,e)=>t+e,0);this.clusters={count:e.length,markers:{mean:n/e.length,sum:n,min:Math.min(...r),max:Math.max(...r)}}}},bt=class{render({count:t,position:e},r,n){const s=`<svg fill="${t>Math.max(10,r.clusters.markers.mean)?"#ff0000":"#0000ff"}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 240" width="50" height="50">\n<circle cx="120" cy="120" opacity=".6" r="70" />\n<circle cx="120" cy="120" opacity=".3" r="90" />\n<circle cx="120" cy="120" opacity=".2" r="110" />\n<text x="50%" y="50%" style="fill:#fff" text-anchor="middle" font-size="50" dominant-baseline="middle" font-family="roboto,arial,sans-serif">${t}</text>\n</svg>`,o=`Cluster of ${t} markers`,i=Number(google.maps.Marker.MAX_ZINDEX)+t;if(ut.isAdvancedMarkerAvailable(n)){const t=(new DOMParser).parseFromString(s,"image/svg+xml").documentElement;t.setAttribute("transform","translate(0 25)");const r={map:n,position:e,zIndex:i,title:o,content:t};return new google.maps.marker.AdvancedMarkerElement(r)}const a={position:e,zIndex:i,title:o,icon:{url:`data:image/svg+xml;base64,${btoa(s)}`,anchor:new google.maps.Point(25,25)}};return new google.maps.Marker(a)}},wt=class t{constructor(){!function(t,e){for(let r in e.prototype)t.prototype[r]=e.prototype[r]}(t,google.maps.OverlayView)}};!function(t){t.CLUSTERING_BEGIN="clusteringbegin",t.CLUSTERING_END="clusteringend",t.CLUSTER_CLICK="click",t.GMP_CLICK="gmp-click"}(dt||(dt={}));var xt=(t,e,r)=>{e.bounds&&r.fitBounds(e.bounds)},kt=class extends wt{constructor({map:t,markers:e=[],algorithmOptions:r={},algorithm:n=new gt(r),renderer:s=new bt,onClusterClick:o=xt}){super(),this.map=null,this.idleListener=null,this.markers=[...e],this.clusters=[],this.algorithm=n,this.renderer=s,this.onClusterClick=o,t&&this.setMap(t)}addMarker(t,e){this.markers.includes(t)||(this.markers.push(t),e||this.render())}addMarkers(t,e){t.forEach(t=>{this.addMarker(t,!0)}),e||this.render()}removeMarker(t,e){const r=this.markers.indexOf(t);return-1!==r&&(ut.setMap(t,null),this.markers.splice(r,1),e||this.render(),!0)}removeMarkers(t,e){let r=!1;return t.forEach(t=>{r=this.removeMarker(t,!0)||r}),r&&!e&&this.render(),r}clearMarkers(t){this.markers.length=0,t||this.render()}render(){const t=this.getMap();if(t instanceof google.maps.Map&&t.getProjection()){google.maps.event.trigger(this,dt.CLUSTERING_BEGIN,this);const{clusters:e,changed:r}=this.algorithm.calculate({markers:this.markers,map:t,mapCanvasProjection:this.getProjection()});if(r||null==r){const t=/* @__PURE__ */new Set;for(const n of e)1==n.markers.length&&t.add(n.markers[0]);const r=[];for(const e of this.clusters)null!=e.marker&&(1==e.markers.length?t.has(e.marker)||ut.setMap(e.marker,null):r.push(e.marker));this.clusters=e,this.renderClusters(),requestAnimationFrame(()=>r.forEach(t=>ut.setMap(t,null)))}google.maps.event.trigger(this,dt.CLUSTERING_END,this)}}onAdd(){const t=this.getMap();pt(t),this.idleListener=t.addListener("idle",this.render.bind(this)),this.render()}onRemove(){this.idleListener&&google.maps.event.removeListener(this.idleListener),this.reset()}reset(){this.markers.forEach(t=>ut.setMap(t,null)),this.clusters.forEach(t=>t.delete()),this.clusters=[]}renderClusters(){const t=new yt(this.markers,this.clusters),e=this.getMap();this.clusters.forEach(r=>{if(1===r.markers.length)r.marker=r.markers[0];else if(r.marker=this.renderer.render(r,t,e),r.markers.forEach(t=>ut.setMap(t,null)),this.onClusterClick){const t=ut.isAdvancedMarker(r.marker)?dt.GMP_CLICK:dt.CLUSTER_CLICK;r.marker.addListener(t,t=>{google.maps.event.trigger(this,dt.CLUSTER_CLICK,r),this.onClusterClick(t,r,e)})}ut.setMap(r.marker,e)})}},Et={top:60,bottom:60,left:276,right:60},vt="#fb8500",Mt=new h,At=(t,r,n)=>{e(/* @__PURE__ */s(o,{client:Mt,children:/* @__PURE__ */s(l,{children:/* @__PURE__ */s(p,{event:t,onExplore:n})})}),r)},Ct=t=>{const e=document.createElement("div");e.style.cssText=`\n background:${g(t.color,"#fb8500")};color:#fff;border-radius:20px;padding:5px 10px;\n font-size:12px;font-weight:600;white-space:nowrap;cursor:pointer;\n box-shadow:0 2px 8px rgba(0,0,0,0.25);border:2px solid rgba(255,255,255,0.4);\n display:inline-flex;align-items:center;gap:6px;\n `;const r=document.createElement("span");r.textContent=t.folder.name;const n=document.createElement("span");return n.style.cssText="background:rgba(0,0,0,0.18);border-radius:10px;padding:1px 5px;font-size:10px;",n.textContent=String(t.eventCount),e.appendChild(r),e.appendChild(n),e},_t=(t,e)=>{const r=document.createElement("div");if(r.style.cssText=`\n width:36px;height:36px;cursor:pointer;\n background:${t};border-radius:50% 50% 50% 0;transform:rotate(-45deg);\n border:2px solid white;box-shadow:0 2px 8px rgba(0,0,0,0.3);\n display:flex;align-items:center;justify-content:center;overflow:hidden;\n `,e){const t=document.createElement("img");t.src=d(e)??"",t.style.cssText="width:24px;height:24px;border-radius:50%;object-fit:cover;transform:rotate(45deg);",r.appendChild(t)}return r},jt=({apiKey:e,onExplore:o,logoUrl:l})=>{const h=a(null),p=a(null),d=a(null),g=a(null),b=a([]),w=a([]),x=a(null),k=a(null),E=a(!1),v=a(!1),M=r(()=>(()=>{try{const e=sessionStorage.getItem(t);if(!e)return null;const r=JSON.parse(e);if(Array.isArray(r?.center)&&"number"==typeof r.zoom)return r}catch{}return null})(),[]),[A,C]=n(!1),[_,j]=n(!0),{folderTree:L,activeFolderId:I,activeFolder:O,visibleEvents:q,setActiveFolderId:T,isLoadingEvents:P}=m(),{organization:S}=c(),z=()=>{b.current.forEach(t=>{t.map=null}),b.current=[]},U=()=>{x.current&&(x.current.clearMarkers(),x.current=null),w.current.forEach(t=>{t.map=null}),w.current=[]};return u(()=>{if(!h.current||p.current)return;let r=!1;return(async()=>{try{const{setOptions:n,importLibrary:s}=await import("./DgGPkDRT.js");if(r)return;if(n({key:e,v:"weekly"}),await Promise.all([s("maps"),s("marker"),s("visualization")]),r||!h.current)return;const o=window.google.maps;d.current=o;const i=M?.center?{lng:M.center[0],lat:M.center[1]}:{lat:20,lng:0},a=M?.zoom??3,c=new o.Map(h.current,{mapId:"DEMO_MAP_ID",renderingType:"VECTOR",mapTypeId:"roadmap",center:i,zoom:a,mapTypeControl:!1,streetViewControl:!1});p.current=c,g.current=new o.InfoWindow({maxWidth:280}),k.current=new o.visualization.HeatmapLayer({data:[],map:null,radius:30,opacity:.8});const l=()=>{try{const e=c.getCenter();if(!e)return;sessionStorage.setItem(t,JSON.stringify({center:[e.lng(),e.lat()],zoom:c.getZoom()}))}catch{}};c.addListener("idle",l),j(!1),C(!0)}finally{r||j(!1)}})(),()=>{r=!0,z(),U(),k.current&&(k.current.setMap(null),k.current=null),g.current?.close(),p.current=null,d.current=null}},[e]),u(()=>{if(!A)return;const t=p.current,e=d.current;if(t&&e)if(z(),U(),g.current?.close(),null===I&&L.length>0){k.current?.setMap(null);const r=n=>{for(const s of n)if(s.centroid){const r=Ct(s),n=new e.marker.AdvancedMarkerElement({map:t,position:{lng:s.centroid[0],lat:s.centroid[1]},content:r,gmpClickable:!0});n.addListener("click",()=>T(s.folder._id)),b.current.push(n)}else s.children.length>0&&r(s.children)};r(L)}else{const r=0===L.length&&null===I;if(0===q.length)return;if(r){const r=[],n=q.map(n=>{const s=n.location.y,i=n.location.x;r.push({location:new e.LatLng(s,i),weight:(n.views||0)+1});const a=_t(vt,l),c=new e.marker.AdvancedMarkerElement({map:t,position:{lat:s,lng:i},content:a,gmpClickable:!0});return c.addListener("click",()=>{const e=document.createElement("div");At(n,e,o),g.current.close(),g.current.setContent(e),g.current.open({anchor:c,map:t})}),c});if(w.current=n,x.current=new kt({markers:n,map:t,renderer:{render:({count:t,position:r})=>{const n=document.createElement("div"),s=t<10?28:t<30?34:40;return n.style.cssText=`\n width:${s}px;height:${s}px;border-radius:50%;cursor:pointer;\n background:${vt};color:#fff;\n display:flex;align-items:center;justify-content:center;\n font-size:13px;font-weight:700;\n box-shadow:0 2px 8px rgba(0,0,0,0.3);\n border:2px solid rgba(255,255,255,0.6);\n `,n.textContent=String(t),new e.marker.AdvancedMarkerElement({position:r,content:n,gmpClickable:!0,zIndex:Number(e.Marker?.MAX_ZINDEX??0)+t})}}}),k.current&&(k.current.setData(r),k.current.setMap(t)),!v.current&&(v.current=!0,!M)){const r=new e.LatLngBounds;q.forEach(t=>r.extend({lat:t.location.y,lng:t.location.x})),r.isEmpty()||t.fitBounds(r,Et)}}else{k.current?.setMap(null);const r=O?.color||vt,n=new e.LatLngBounds;q.forEach(s=>{const i=s.location.y,a=s.location.x;n.extend({lat:i,lng:a});const c=_t(r,l),u=new e.marker.AdvancedMarkerElement({map:t,position:{lat:i,lng:a},content:c,gmpClickable:!0});u.addListener("click",()=>{const e=document.createElement("div");At(s,e,o),g.current.close(),g.current.setContent(e),g.current.open({anchor:u,map:t})}),w.current.push(u)})}}},[I,L,q,A,o,l,T,O,M]),u(()=>{if(!A)return;const t=p.current,e=d.current;if(t&&e)if(E.current||!M){if(E.current=!0,I){const r=f(L,I);if(!r?.folder.boundary?.length)return;const n=new e.LatLngBounds;for(const t of r.folder.boundary)n.extend({lat:t.y,lng:t.x});n.isEmpty()||t.fitBounds(n,{...Et,maxZoom:14})}else if(L.length>0){const r=new e.LatLngBounds,n=t=>{for(const e of t)e.centroid?r.extend({lng:e.centroid[0],lat:e.centroid[1]}):n(e.children)};n(L),r.isEmpty()||t.fitBounds(r,{...Et,maxZoom:8})}}else E.current=!0},[I,L,A,M]),/* @__PURE__ */s("div",{class:"relative h-screen w-full sm:h-[calc(100vh-4rem)]",style:i(S),children:[
1
+ import{B as t,Ht as e,Mt as r,Pt as n,Q as s,X as o,g as i,jt as a,p as c,r as l,zt as u}from"./BPJdmb-n.js";import{t as h}from"./Bthg7jjx.js";import{a as p,i as d,n as f,o as m,r as g,t as y}from"./rfpQMFBA.js";var{getOwnPropertyNames:b,getOwnPropertySymbols:w}=Object,{hasOwnProperty:x}=Object.prototype;function k(t,e){return function(r,n,s){return t(r,n,s)&&e(r,n,s)}}function E(t){return function(e,r,n){if(!e||!r||"object"!=typeof e||"object"!=typeof r)return t(e,r,n);const{cache:s}=n,o=s.get(e),i=s.get(r);if(o&&i)return o===r&&i===e;s.set(e,r),s.set(r,e);const a=t(e,r,n);return s.delete(e),s.delete(r),a}}function v(t){return b(t).concat(w(t))}var M=Object.hasOwn||((t,e)=>x.call(t,e));function A(t,e){return t===e||!t&&!e&&t!=t&&e!=e}var{getOwnPropertyDescriptor:C,keys:_}=Object;function j(t,e){return t.byteLength===e.byteLength&&N(new Uint8Array(t),new Uint8Array(e))}function L(t,e,r){let n=t.length;if(e.length!==n)return!1;for(;n-- >0;)if(!r.equals(t[n],e[n],n,n,t,e,r))return!1;return!0}function I(t,e){return t.byteLength===e.byteLength&&N(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function O(t,e){return A(t.getTime(),e.getTime())}function q(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function T(t,e){return t===e}function P(t,e,r){const n=t.size;if(n!==e.size)return!1;if(!n)return!0;const s=new Array(n),o=t.entries();let i,a,c=0;for(;(i=o.next())&&!i.done;){const n=e.entries();let o=!1,l=0;for(;(a=n.next())&&!a.done;){if(s[l]){l++;continue}const n=i.value,u=a.value;if(r.equals(n[0],u[0],c,l,t,e,r)&&r.equals(n[1],u[1],n[0],u[0],t,e,r)){o=s[l]=!0;break}l++}if(!o)return!1;c++}return!0}var S=A;function z(t,e,r){const n=_(t);let s=n.length;if(_(e).length!==s)return!1;for(;s-- >0;)if(!$(t,e,r,n[s]))return!1;return!0}function U(t,e,r){const n=v(t);let s,o,i,a=n.length;if(v(e).length!==a)return!1;for(;a-- >0;){if(s=n[a],!$(t,e,r,s))return!1;if(o=C(t,s),i=C(e,s),(o||i)&&(!o||!i||o.configurable!==i.configurable||o.enumerable!==i.enumerable||o.writable!==i.writable))return!1}return!0}function Z(t,e){return A(t.valueOf(),e.valueOf())}function B(t,e){return t.source===e.source&&t.flags===e.flags}function F(t,e,r){const n=t.size;if(n!==e.size)return!1;if(!n)return!0;const s=new Array(n),o=t.values();let i,a;for(;(i=o.next())&&!i.done;){const n=e.values();let o=!1,c=0;for(;(a=n.next())&&!a.done;){if(!s[c]&&r.equals(i.value,a.value,i.value,a.value,t,e,r)){o=s[c]=!0;break}c++}if(!o)return!1}return!0}function N(t,e){let r=t.byteLength;if(e.byteLength!==r||t.byteOffset!==e.byteOffset)return!1;for(;r-- >0;)if(t[r]!==e[r])return!1;return!0}function D(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function $(t,e,r,n){return!("_owner"!==n&&"__o"!==n&&"__v"!==n||!t.$$typeof&&!e.$$typeof)||M(e,n)&&r.equals(t[n],e[n],n,n,t,e,r)}var R={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},G=Object.prototype.toString;var V=K();function K(t={}){const{circular:e=!1,createInternalComparator:r,createState:n,strict:s=!1}=t,o=function({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:r,areDatesEqual:n,areErrorsEqual:s,areFunctionsEqual:o,areMapsEqual:i,areNumbersEqual:a,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:h,areTypedArraysEqual:p,areUrlsEqual:d,unknownTagComparators:f}){return function(m,g,y){if(m===g)return!0;if(null==m||null==g)return!1;const b=typeof m;if(b!==typeof g)return!1;if("object"!==b)return"number"===b?a(m,g,y):"function"===b&&o(m,g,y);const w=m.constructor;if(w!==g.constructor)return!1;if(w===Object)return c(m,g,y);if(Array.isArray(m))return e(m,g,y);if(w===Date)return n(m,g,y);if(w===RegExp)return u(m,g,y);if(w===Map)return i(m,g,y);if(w===Set)return h(m,g,y);const x=G.call(m);if("[object Date]"===x)return n(m,g,y);if("[object RegExp]"===x)return u(m,g,y);if("[object Map]"===x)return i(m,g,y);if("[object Set]"===x)return h(m,g,y);if("[object Object]"===x)return"function"!=typeof m.then&&"function"!=typeof g.then&&c(m,g,y);if("[object URL]"===x)return d(m,g,y);if("[object Error]"===x)return s(m,g,y);if("[object Arguments]"===x)return c(m,g,y);if(R[x])return p(m,g,y);if("[object ArrayBuffer]"===x)return t(m,g,y);if("[object DataView]"===x)return r(m,g,y);if("[object Boolean]"===x||"[object Number]"===x||"[object String]"===x)return l(m,g,y);if(f){let t=f[x];if(!t){const e=null!=(k=m)?k[Symbol.toStringTag]:void 0;e&&(t=f[e])}if(t)return t(m,g,y)}var k;return!1}}(function({circular:t,createCustomConfig:e,strict:r}){let n={areArrayBuffersEqual:j,areArraysEqual:r?U:L,areDataViewsEqual:I,areDatesEqual:O,areErrorsEqual:q,areFunctionsEqual:T,areMapsEqual:r?k(P,U):P,areNumbersEqual:S,areObjectsEqual:r?U:z,arePrimitiveWrappersEqual:Z,areRegExpsEqual:B,areSetsEqual:r?k(F,U):F,areTypedArraysEqual:r?k(N,U):N,areUrlsEqual:D,unknownTagComparators:void 0};if(e&&(n=Object.assign({},n,e(n))),t){const t=E(n.areArraysEqual),e=E(n.areMapsEqual),r=E(n.areObjectsEqual),s=E(n.areSetsEqual);n=Object.assign({},n,{areArraysEqual:t,areMapsEqual:e,areObjectsEqual:r,areSetsEqual:s})}return n}(t));return function({circular:t,comparator:e,createState:r,equals:n,strict:s}){if(r)return function(o,i){const{cache:a=(t?/* @__PURE__ */new WeakMap:void 0),meta:c}=r();return e(o,i,{cache:a,equals:n,meta:c,strict:s})};if(t)return function(t,r){return e(t,r,{cache:/* @__PURE__ */new WeakMap,equals:n,meta:void 0,strict:s})};const o={cache:void 0,equals:n,meta:void 0,strict:s};return function(t,r){return e(t,r,o)}}({circular:e,comparator:o,createState:n,equals:r?r(o):(i=o,function(t,e,r,n,s,o,a){return i(t,e,a)}),strict:s});var i}K({strict:!0}),K({circular:!0}),K({circular:!0,strict:!0}),K({createInternalComparator:()=>A}),K({strict:!0,createInternalComparator:()=>A}),K({circular:!0,createInternalComparator:()=>A}),K({circular:!0,createInternalComparator:()=>A,strict:!0});var W=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],X=class t{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[r,n]=new Uint8Array(e,0,2);if(219!==r)throw new Error("Data does not appear to be in a KDBush format.");const s=n>>4;if(1!==s)throw new Error(`Got v${s} data when expected v1.`);const o=W[15&n];if(!o)throw new Error("Unrecognized array type.");const[i]=new Uint16Array(e,2,1),[a]=new Uint32Array(e,4,1);return new t(a,i,o,e)}constructor(t,e=64,r=Float64Array,n){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const s=W.indexOf(this.ArrayType),o=2*t*this.ArrayType.BYTES_PER_ELEMENT,i=t*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-i%8)%8;if(s<0)throw new Error(`Unexpected typed array class: ${r}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+i+a,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+o+i+a),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+i+a,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+s]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t)}add(t,e){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return H(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:o,nodeSize:i}=this,a=[0,s.length-1,0],c=[];for(;a.length;){const l=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=i){for(let i=h;i<=u;i++){const a=o[2*i],l=o[2*i+1];a>=t&&a<=r&&l>=e&&l<=n&&c.push(s[i])}continue}const p=h+u>>1,d=o[2*p],f=o[2*p+1];d>=t&&d<=r&&f>=e&&f<=n&&c.push(s[p]),(0===l?t<=d:e<=f)&&(a.push(h),a.push(p-1),a.push(1-l)),(0===l?r>=d:n>=f)&&(a.push(p+1),a.push(u),a.push(1-l))}return c}within(t,e,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:s,nodeSize:o}=this,i=[0,n.length-1,0],a=[],c=r*r;for(;i.length;){const l=i.pop()||0,u=i.pop()||0,h=i.pop()||0;if(u-h<=o){for(let r=h;r<=u;r++)tt(s[2*r],s[2*r+1],t,e)<=c&&a.push(n[r]);continue}const p=h+u>>1,d=s[2*p],f=s[2*p+1];tt(d,f,t,e)<=c&&a.push(n[p]),(0===l?t-r<=d:e-r<=f)&&(i.push(h),i.push(p-1),i.push(1-l)),(0===l?t+r>=d:e+r>=f)&&(i.push(p+1),i.push(u),i.push(1-l))}return a}};function H(t,e,r,n,s,o){if(s-n<=r)return;const i=n+s>>1;J(t,e,i,n,s,o),H(t,e,r,n,i-1,1-o),H(t,e,r,i+1,s,1-o)}function J(t,e,r,n,s,o){for(;s>n;){if(s-n>600){const i=s-n+1,a=r-n+1,c=Math.log(i),l=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*l*(i-l)/i)*(a-i/2<0?-1:1);J(t,e,r,Math.max(n,Math.floor(r-a*l/i+u)),Math.min(s,Math.floor(r+(i-a)*l/i+u)),o)}const i=e[2*r+o];let a=n,c=s;for(Y(t,e,n,r),e[2*s+o]>i&&Y(t,e,n,s);a<c;){for(Y(t,e,a,c),a++,c--;e[2*a+o]<i;)a++;for(;e[2*c+o]>i;)c--}e[2*n+o]===i?Y(t,e,n,c):(c++,Y(t,e,c,s)),c<=r&&(n=c+1),r<=c&&(s=c-1)}}function Y(t,e,r,n){Q(t,r,n),Q(e,2*r,2*n),Q(e,2*r+1,2*n+1)}function Q(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function tt(t,e,r,n){const s=t-r,o=e-n;return s*s+o*o}var et,rt={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},nt=Math.fround||(et=new Float32Array(1),t=>(et[0]=+t,et[0])),st=class{constructor(t){this.options=Object.assign(Object.create(rt),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:r,maxZoom:n}=this.options;e&&console.time("total time");const s=`prepare ${t.length} points`;e&&console.time(s),this.points=t;const o=[];for(let a=0;a<t.length;a++){const e=t[a];if(!e.geometry)continue;const[r,n]=e.geometry.coordinates,s=nt(at(r)),i=nt(ct(n));o.push(s,i,1/0,a,-1,1),this.options.reduce&&o.push(0)}let i=this.trees[n+1]=this._createTree(o);e&&console.timeEnd(s);for(let a=n;a>=r;a--){const t=+Date.now();i=this.trees[a]=this._createTree(this._cluster(i,a)),e&&console.log("z%d: %d clusters in %dms",a,i.numItems,+Date.now()-t)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let r=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let s=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)r=-180,s=180;else if(r>s){const t=this.getClusters([r,n,180,o],e),i=this.getClusters([-180,n,s,o],e);return t.concat(i)}const i=this.trees[this._limitZoom(e)],a=i.range(at(r),ct(o),at(s),ct(n)),c=i.data,l=[];for(const u of a){const t=this.stride*u;l.push(c[t+5]>1?ot(c,t,this.clusterProps):this.points[c[t+3]])}return l}getChildren(t){const e=this._getOriginId(t),r=this._getOriginZoom(t),n="No cluster with the specified id.",s=this.trees[r];if(!s)throw new Error(n);const o=s.data;if(e*this.stride>=o.length)throw new Error(n);const i=this.options.radius/(this.options.extent*Math.pow(2,r-1)),a=o[e*this.stride],c=o[e*this.stride+1],l=s.within(a,c,i),u=[];for(const h of l){const e=h*this.stride;o[e+4]===t&&u.push(o[e+5]>1?ot(o,e,this.clusterProps):this.points[o[e+3]])}if(0===u.length)throw new Error(n);return u}getLeaves(t,e,r){e=e||10,r=r||0;const n=[];return this._appendLeaves(n,t,e,r,0),n}getTile(t,e,r){const n=this.trees[this._limitZoom(t)],s=Math.pow(2,t),{extent:o,radius:i}=this.options,a=i/o,c=(r-a)/s,l=(r+1+a)/s,u={features:[]};return this._addTileFeatures(n.range((e-a)/s,c,(e+1+a)/s,l),n.data,e,r,s,u),0===e&&this._addTileFeatures(n.range(1-a/s,c,1,l),n.data,s,r,s,u),e===s-1&&this._addTileFeatures(n.range(0,c,a/s,l),n.data,-1,r,s,u),u.features.length?u:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e<=this.options.maxZoom;){const r=this.getChildren(t);if(e++,1!==r.length)break;t=r[0].properties.cluster_id}return e}_appendLeaves(t,e,r,n,s){const o=this.getChildren(e);for(const i of o){const e=i.properties;if(e&&e.cluster?s+e.point_count<=n?s+=e.point_count:s=this._appendLeaves(t,e.cluster_id,r,n,s):s<n?s++:t.push(i),t.length===r)break}return s}_createTree(t){const e=new X(t.length/this.stride|0,this.options.nodeSize,Float32Array);for(let r=0;r<t.length;r+=this.stride)e.add(t[r],t[r+1]);return e.finish(),e.data=t,e}_addTileFeatures(t,e,r,n,s,o){for(const i of t){const t=i*this.stride,a=e[t+5]>1;let c,l,u;if(a)c=it(e,t,this.clusterProps),l=e[t],u=e[t+1];else{const r=this.points[e[t+3]];c=r.properties;const[n,s]=r.geometry.coordinates;l=at(n),u=ct(s)}const h={type:1,geometry:[[Math.round(this.options.extent*(l*s-r)),Math.round(this.options.extent*(u*s-n))]],tags:c};let p;p=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==p&&(h.id=p),o.features.push(h)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:r,extent:n,reduce:s,minPoints:o}=this.options,i=r/(n*Math.pow(2,e)),a=t.data,c=[],l=this.stride;for(let u=0;u<a.length;u+=l){if(a[u+2]<=e)continue;a[u+2]=e;const r=a[u],n=a[u+1],h=t.within(a[u],a[u+1],i),p=a[u+5];let d=p;for(const t of h){const r=t*l;a[r+2]>e&&(d+=a[r+5])}if(d>p&&d>=o){let t,o=r*p,i=n*p,f=-1;const m=(u/l<<5)+(e+1)+this.points.length;for(const r of h){const n=r*l;if(a[n+2]<=e)continue;a[n+2]=e;const c=a[n+5];o+=a[n]*c,i+=a[n+1]*c,a[n+4]=m,s&&(t||(t=this._map(a,u,!0),f=this.clusterProps.length,this.clusterProps.push(t)),s(t,this._map(a,n)))}a[u+4]=m,c.push(o/d,i/d,1/0,m,-1,d),s&&c.push(f)}else{for(let t=0;t<l;t++)c.push(a[u+t]);if(d>1)for(const t of h){const r=t*l;if(!(a[r+2]<=e)){a[r+2]=e;for(let t=0;t<l;t++)c.push(a[r+t])}}}}return c}_getOriginId(t){return t-this.points.length>>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,r){if(t[e+5]>1){const n=this.clusterProps[t[e+6]];return r?Object.assign({},n):n}const n=this.points[t[e+3]].properties,s=this.options.map(n);return r&&s===n?Object.assign({},s):s}};function ot(t,e,r){return{type:"Feature",id:t[e+3],properties:it(t,e,r),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),lt(t[e+1])]}};var n}function it(t,e,r){const n=t[e+5],s=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+6],i=-1===o?{}:Object.assign({},r[o]);return Object.assign(i,{cluster:!0,cluster_id:t[e+3],point_count:n,point_count_abbreviated:s})}function at(t){return t/360+.5}function ct(t){const e=Math.sin(t*Math.PI/180),r=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return r<0?0:r>1?1:r}function lt(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}var ut=class{static isAdvancedMarkerAvailable(t){return google.maps.marker&&!0===t.getMapCapabilities().isAdvancedMarkersAvailable}static isAdvancedMarker(t){return google.maps.marker&&t instanceof google.maps.marker.AdvancedMarkerElement}static setMap(t,e){this.isAdvancedMarker(t)?t.map=e:t.setMap(e)}static getPosition(t){if(this.isAdvancedMarker(t)){if(t.position){if(t.position instanceof google.maps.LatLng)return t.position;if(Number.isFinite(t.position.lat)&&Number.isFinite(t.position.lng))return new google.maps.LatLng(t.position.lat,t.position.lng)}return new google.maps.LatLng(null)}return t.getPosition()}static getVisible(t){return!!this.isAdvancedMarker(t)||t.getVisible()}},ht=class{constructor({markers:t,position:e}){this.markers=[],t&&(this.markers=t),e&&(e instanceof google.maps.LatLng?this._position=e:this._position=new google.maps.LatLng(e))}get bounds(){if(0===this.markers.length&&!this._position)return;const t=new google.maps.LatLngBounds(this._position,this._position);for(const e of this.markers)t.extend(ut.getPosition(e));return t}get position(){return this._position||this.bounds.getCenter()}get count(){return this.markers.filter(t=>ut.getVisible(t)).length}push(t){this.markers.push(t)}delete(){this.marker&&(ut.setMap(this.marker,null),this.marker=void 0),this.markers.length=0}};function pt(t,e="assertion failed"){if(null==t)throw Error(e)}var dt,ft=class{constructor({maxZoom:t=16}){this.maxZoom=t}noop({markers:t}){return mt(t)}},mt=t=>t.map(t=>new ht({position:ut.getPosition(t),markers:[t]})),gt=class extends ft{constructor(t){var{maxZoom:e,radius:r=60}=t,n=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(t);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(t,n[s])&&(r[n[s]]=t[n[s]])}return r}(t,["maxZoom","radius"]);super({maxZoom:e}),this.markers=[],this.clusters=[],this.state={zoom:-1},this.superCluster=new st(Object.assign({maxZoom:this.maxZoom,radius:r},n))}calculate(t){let e=!1,r=t.map.getZoom();pt(r),r=Math.round(r);const n={zoom:r};if(!V(t.markers,this.markers)){e=!0,this.markers=[...t.markers];const r=this.markers.map(t=>{const e=ut.getPosition(t);return{type:"Feature",geometry:{type:"Point",coordinates:[e.lng(),e.lat()]},properties:{marker:t}}});this.superCluster.load(r)}return e||(this.state.zoom<=this.maxZoom||n.zoom<=this.maxZoom)&&(e=!V(this.state,n)),this.state=n,0===t.markers.length?(this.clusters=[],{clusters:this.clusters,changed:e}):(e&&(this.clusters=this.cluster(t)),{clusters:this.clusters,changed:e})}cluster({map:t}){const e=t.getZoom();return pt(e),this.superCluster.getClusters([-180,-90,180,90],Math.round(e)).map(t=>this.transformCluster(t))}transformCluster({geometry:{coordinates:[t,e]},properties:r}){if(r.cluster)return new ht({markers:this.superCluster.getLeaves(r.cluster_id,1/0).map(t=>t.properties.marker),position:{lat:e,lng:t}});const n=r.marker;return new ht({markers:[n],position:ut.getPosition(n)})}},yt=class{constructor(t,e){this.markers={sum:t.length};const r=e.map(t=>t.count),n=r.reduce((t,e)=>t+e,0);this.clusters={count:e.length,markers:{mean:n/e.length,sum:n,min:Math.min(...r),max:Math.max(...r)}}}},bt=class{render({count:t,position:e},r,n){const s=`<svg fill="${t>Math.max(10,r.clusters.markers.mean)?"#ff0000":"#0000ff"}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 240" width="50" height="50">\n<circle cx="120" cy="120" opacity=".6" r="70" />\n<circle cx="120" cy="120" opacity=".3" r="90" />\n<circle cx="120" cy="120" opacity=".2" r="110" />\n<text x="50%" y="50%" style="fill:#fff" text-anchor="middle" font-size="50" dominant-baseline="middle" font-family="roboto,arial,sans-serif">${t}</text>\n</svg>`,o=`Cluster of ${t} markers`,i=Number(google.maps.Marker.MAX_ZINDEX)+t;if(ut.isAdvancedMarkerAvailable(n)){const t=(new DOMParser).parseFromString(s,"image/svg+xml").documentElement;t.setAttribute("transform","translate(0 25)");const r={map:n,position:e,zIndex:i,title:o,content:t};return new google.maps.marker.AdvancedMarkerElement(r)}const a={position:e,zIndex:i,title:o,icon:{url:`data:image/svg+xml;base64,${btoa(s)}`,anchor:new google.maps.Point(25,25)}};return new google.maps.Marker(a)}},wt=class t{constructor(){!function(t,e){for(let r in e.prototype)t.prototype[r]=e.prototype[r]}(t,google.maps.OverlayView)}};!function(t){t.CLUSTERING_BEGIN="clusteringbegin",t.CLUSTERING_END="clusteringend",t.CLUSTER_CLICK="click",t.GMP_CLICK="gmp-click"}(dt||(dt={}));var xt=(t,e,r)=>{e.bounds&&r.fitBounds(e.bounds)},kt=class extends wt{constructor({map:t,markers:e=[],algorithmOptions:r={},algorithm:n=new gt(r),renderer:s=new bt,onClusterClick:o=xt}){super(),this.map=null,this.idleListener=null,this.markers=[...e],this.clusters=[],this.algorithm=n,this.renderer=s,this.onClusterClick=o,t&&this.setMap(t)}addMarker(t,e){this.markers.includes(t)||(this.markers.push(t),e||this.render())}addMarkers(t,e){t.forEach(t=>{this.addMarker(t,!0)}),e||this.render()}removeMarker(t,e){const r=this.markers.indexOf(t);return-1!==r&&(ut.setMap(t,null),this.markers.splice(r,1),e||this.render(),!0)}removeMarkers(t,e){let r=!1;return t.forEach(t=>{r=this.removeMarker(t,!0)||r}),r&&!e&&this.render(),r}clearMarkers(t){this.markers.length=0,t||this.render()}render(){const t=this.getMap();if(t instanceof google.maps.Map&&t.getProjection()){google.maps.event.trigger(this,dt.CLUSTERING_BEGIN,this);const{clusters:e,changed:r}=this.algorithm.calculate({markers:this.markers,map:t,mapCanvasProjection:this.getProjection()});if(r||null==r){const t=/* @__PURE__ */new Set;for(const n of e)1==n.markers.length&&t.add(n.markers[0]);const r=[];for(const e of this.clusters)null!=e.marker&&(1==e.markers.length?t.has(e.marker)||ut.setMap(e.marker,null):r.push(e.marker));this.clusters=e,this.renderClusters(),requestAnimationFrame(()=>r.forEach(t=>ut.setMap(t,null)))}google.maps.event.trigger(this,dt.CLUSTERING_END,this)}}onAdd(){const t=this.getMap();pt(t),this.idleListener=t.addListener("idle",this.render.bind(this)),this.render()}onRemove(){this.idleListener&&google.maps.event.removeListener(this.idleListener),this.reset()}reset(){this.markers.forEach(t=>ut.setMap(t,null)),this.clusters.forEach(t=>t.delete()),this.clusters=[]}renderClusters(){const t=new yt(this.markers,this.clusters),e=this.getMap();this.clusters.forEach(r=>{if(1===r.markers.length)r.marker=r.markers[0];else if(r.marker=this.renderer.render(r,t,e),r.markers.forEach(t=>ut.setMap(t,null)),this.onClusterClick){const t=ut.isAdvancedMarker(r.marker)?dt.GMP_CLICK:dt.CLUSTER_CLICK;r.marker.addListener(t,t=>{google.maps.event.trigger(this,dt.CLUSTER_CLICK,r),this.onClusterClick(t,r,e)})}ut.setMap(r.marker,e)})}},Et={top:60,bottom:60,left:276,right:60},vt="#fb8500",Mt=new h,At=(t,r,n)=>{e(/* @__PURE__ */s(o,{client:Mt,children:/* @__PURE__ */s(l,{children:/* @__PURE__ */s(p,{event:t,onExplore:n})})}),r)},Ct=t=>{const e=document.createElement("div");e.style.cssText=`\n background:${g(t.color,"#fb8500")};color:#fff;border-radius:20px;padding:5px 10px;\n font-size:12px;font-weight:600;white-space:nowrap;cursor:pointer;\n box-shadow:0 2px 8px rgba(0,0,0,0.25);border:2px solid rgba(255,255,255,0.4);\n display:inline-flex;align-items:center;gap:6px;\n `;const r=document.createElement("span");r.textContent=t.folder.name;const n=document.createElement("span");return n.style.cssText="background:rgba(0,0,0,0.18);border-radius:10px;padding:1px 5px;font-size:10px;",n.textContent=String(t.eventCount),e.appendChild(r),e.appendChild(n),e},_t=(t,e)=>{const r=document.createElement("div");if(r.style.cssText=`\n width:36px;height:36px;cursor:pointer;\n background:${t};border-radius:50% 50% 50% 0;transform:rotate(-45deg);\n border:2px solid white;box-shadow:0 2px 8px rgba(0,0,0,0.3);\n display:flex;align-items:center;justify-content:center;overflow:hidden;\n `,e){const t=document.createElement("img");t.src=d(e)??"",t.style.cssText="width:24px;height:24px;border-radius:50%;object-fit:cover;transform:rotate(45deg);",r.appendChild(t)}return r},jt=({apiKey:e,onExplore:o,logoUrl:l})=>{const h=a(null),p=a(null),d=a(null),g=a(null),b=a([]),w=a([]),x=a(null),k=a(null),E=a(!1),v=a(!1),M=r(()=>(()=>{try{const e=sessionStorage.getItem(t);if(!e)return null;const r=JSON.parse(e);if(Array.isArray(r?.center)&&"number"==typeof r.zoom)return r}catch{}return null})(),[]),[A,C]=n(!1),[_,j]=n(!0),{folderTree:L,activeFolderId:I,activeFolder:O,visibleEvents:q,setActiveFolderId:T,isLoadingEvents:P}=m(),{organization:S}=c(),z=()=>{b.current.forEach(t=>{t.map=null}),b.current=[]},U=()=>{x.current&&(x.current.clearMarkers(),x.current=null),w.current.forEach(t=>{t.map=null}),w.current=[]};return u(()=>{if(!h.current||p.current)return;let r=!1;return(async()=>{try{const{setOptions:n,importLibrary:s}=await import("./DgGPkDRT.js");if(r)return;if(n({key:e,v:"weekly"}),await Promise.all([s("maps"),s("marker"),s("visualization")]),r||!h.current)return;const o=window.google.maps;d.current=o;const i=M?.center?{lng:M.center[0],lat:M.center[1]}:{lat:20,lng:0},a=M?.zoom??3,c=new o.Map(h.current,{mapId:"DEMO_MAP_ID",renderingType:"VECTOR",mapTypeId:"roadmap",center:i,zoom:a,mapTypeControl:!1,streetViewControl:!1});p.current=c,g.current=new o.InfoWindow({maxWidth:280}),k.current=new o.visualization.HeatmapLayer({data:[],map:null,radius:30,opacity:.8});const l=()=>{try{const e=c.getCenter();if(!e)return;sessionStorage.setItem(t,JSON.stringify({center:[e.lng(),e.lat()],zoom:c.getZoom()}))}catch{}};c.addListener("idle",l),j(!1),C(!0)}finally{r||j(!1)}})(),()=>{r=!0,z(),U(),k.current&&(k.current.setMap(null),k.current=null),g.current?.close(),p.current=null,d.current=null}},[e]),u(()=>{if(!A)return;const t=p.current,e=d.current;if(t&&e)if(z(),U(),g.current?.close(),null===I&&L.length>0){k.current?.setMap(null);const r=n=>{for(const s of n)if(s.centroid){const r=Ct(s),n=new e.marker.AdvancedMarkerElement({map:t,position:{lng:s.centroid[0],lat:s.centroid[1]},content:r,gmpClickable:!0});n.addListener("click",()=>T(s.folder._id)),b.current.push(n)}else s.children.length>0&&r(s.children)};r(L)}else{const r=0===L.length&&null===I;if(0===q.length)return;if(r){const r=[],n=q.map(n=>{const s=n.location.y,i=n.location.x;r.push({location:new e.LatLng(s,i),weight:(n.views||0)+1});const a=_t(vt,l),c=new e.marker.AdvancedMarkerElement({map:t,position:{lat:s,lng:i},content:a,gmpClickable:!0});return c.addListener("click",()=>{const e=document.createElement("div");At(n,e,o),g.current.close(),g.current.setContent(e),g.current.open({anchor:c,map:t})}),c});if(w.current=n,x.current=new kt({markers:n,map:t,renderer:{render:({count:t,position:r})=>{const n=document.createElement("div"),s=t<10?28:t<30?34:40;return n.style.cssText=`\n width:${s}px;height:${s}px;border-radius:50%;cursor:pointer;\n background:${vt};color:#fff;\n display:flex;align-items:center;justify-content:center;\n font-size:13px;font-weight:700;\n box-shadow:0 2px 8px rgba(0,0,0,0.3);\n border:2px solid rgba(255,255,255,0.6);\n `,n.textContent=String(t),new e.marker.AdvancedMarkerElement({position:r,content:n,gmpClickable:!0,zIndex:Number(e.Marker?.MAX_ZINDEX??0)+t})}}}),k.current&&(k.current.setData(r),k.current.setMap(t)),!v.current&&(v.current=!0,!M)){const r=new e.LatLngBounds;q.forEach(t=>r.extend({lat:t.location.y,lng:t.location.x})),r.isEmpty()||t.fitBounds(r,Et)}}else{k.current?.setMap(null);const r=O?.color||vt,n=new e.LatLngBounds;q.forEach(s=>{const i=s.location.y,a=s.location.x;n.extend({lat:i,lng:a});const c=_t(r,l),u=new e.marker.AdvancedMarkerElement({map:t,position:{lat:i,lng:a},content:c,gmpClickable:!0});u.addListener("click",()=>{const e=document.createElement("div");At(s,e,o),g.current.close(),g.current.setContent(e),g.current.open({anchor:u,map:t})}),w.current.push(u)})}}},[I,L,q,A,o,l,T,O,M]),u(()=>{if(!A)return;const t=p.current,e=d.current;if(t&&e)if(E.current||!M){if(E.current=!0,I){const r=f(L,I);if(!r?.folder.boundary?.length)return;const n=new e.LatLngBounds;for(const t of r.folder.boundary)n.extend({lat:t.y,lng:t.x});n.isEmpty()||t.fitBounds(n,{...Et,maxZoom:14})}else if(L.length>0){const r=new e.LatLngBounds,n=t=>{for(const e of t)e.centroid?r.extend({lng:e.centroid[0],lat:e.centroid[1]}):n(e.children)};n(L),r.isEmpty()||t.fitBounds(r,{...Et,maxZoom:8})}}else E.current=!0},[I,L,A,M]),/* @__PURE__ */s("div",{class:"relative h-screen w-full sm:h-[calc(100vh-4rem)]",style:i(S),children:[
2
2
  /* @__PURE__ */s(y,{positionClass:"absolute top-3 left-16 z-[1000]",folderTree:L,activeFolderId:I,setActiveFolderId:T}),P&&/* @__PURE__ */s("div",{class:"absolute inset-0 z-10 flex items-center justify-center bg-white/60",children:/* @__PURE__ */s("div",{class:"border-primary size-10 animate-spin rounded-full border-4 border-t-transparent"})}),_&&/* @__PURE__ */s("div",{class:"absolute inset-0 z-20 flex items-center justify-center bg-white/85",children:/* @__PURE__ */s("div",{class:"flex flex-col items-center gap-3",children:[/* @__PURE__ */s("div",{class:"border-primary size-10 animate-spin rounded-full border-4 border-t-transparent"}),/* @__PURE__ */s("p",{class:"text-sm font-medium text-slate-700",children:"Loading map…"})]})}),
3
3
  /* @__PURE__ */s("div",{ref:h,class:"size-full"})]})};export{jt as default};