@qratilabs/qrati-connect 2.18.0 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/element/{DSkNPSoA.js → DF6wxpU6.js} +1 -1
- package/element/{CpXF8hSs.js → DqcL5k27.js} +3 -3
- package/element/iwsjnFxy.js +4 -0
- package/element/web.es.js +2 -2
- package/package.json +1 -1
- package/react/B-2DDVYT.js +4 -0
- package/react/{1jkPzAQP.js → BquInWJV.js} +1 -1
- package/react/{DOvusjaa.js → CPHleA8G.js} +1 -1
- package/react/DVSPOKgN.js +1 -0
- package/react/{D-4Pgq2O.js → DVXalHm5.js} +1 -1
- package/react/index.cjs +1 -1
- package/react/index.mjs +2 -2
- package/react/{DXcoSfgy.js → jnuTAcnJ.js} +4 -4
- package/umd/web.umd.js +1 -1
- package/element/Bxj0_YIt.js +0 -4
- package/react/By2LZrpb.js +0 -4
- package/react/sndEiRn7.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [2.18.0](https://github.com/qrati-labs/qrati-connect-ts/compare/v2.17.0...v2.18.0) (2026-05-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* ensure safe image URLs for event markers in GoogleMapsView, MapboxView, and OpenStreetMapView components ([da8d4a0](https://github.com/qrati-labs/qrati-connect-ts/commit/da8d4a0f3fb44444d52a9173f28d42b542808242))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* enhance folder view functionality and integrate heat layer for event visualization ([06157ba](https://github.com/qrati-labs/qrati-connect-ts/commit/06157baa8e81a61a95c753e968097bddbb738a57))
|
|
12
|
+
* implement FolderTreeSidebar component for hierarchical folder navigation and integrate into map view ([9a748bd](https://github.com/qrati-labs/qrati-connect-ts/commit/9a748bdfb249554ec68454cf2615063f68c5290a))
|
|
13
|
+
* implement useFolderMap hook for hierarchical folder structure and event mapping ([f48e758](https://github.com/qrati-labs/qrati-connect-ts/commit/f48e758d71231c734d13245f6fefe5b8c127adc8))
|
|
14
|
+
|
|
1
15
|
# [2.17.0](https://github.com/qrati-labs/qrati-connect-ts/compare/v2.16.0...v2.17.0) (2026-05-08)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Lt as e,Q as t,V as r,lt as o,p as l,rt as s,u as i}from"./DQpZuO_g.js";var n=o(()=>import("./cFiX5XpH.js")),a=o(()=>import("./
|
|
1
|
+
import{Lt as e,Q as t,V as r,lt as o,p as l,rt as s,u as i}from"./DQpZuO_g.js";var n=o(()=>import("./cFiX5XpH.js")),a=o(()=>import("./iwsjnFxy.js")),c=o(()=>import("./C2wSnFgo.js")),d=o(()=>import("./DqcL5k27.js")),p=()=>/* @__PURE__ */t("div",{class:"flex h-full items-center justify-center",children:/* @__PURE__ */t("div",{class:"text-center",children:[
|
|
2
2
|
/* @__PURE__ */t("svg",{xmlns:"http://www.w3.org/2000/svg",class:"text-muted-foreground mx-auto mb-3 size-10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5",children:[/* @__PURE__ */t("path",{d:"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7z"}),/* @__PURE__ */t("circle",{cx:"12",cy:"9",r:"2.5"})]}),
|
|
3
3
|
/* @__PURE__ */t("p",{class:"text-foreground",children:"No location data available."}),
|
|
4
4
|
/* @__PURE__ */t("p",{class:"text-muted-foreground mt-1 text-xs",children:"Events need location data to appear on the map."})]})}),m=()=>/* @__PURE__ */t("div",{class:"flex h-full items-center justify-center",children:/* @__PURE__ */t("div",{class:"border-primary size-8 animate-spin rounded-full border-4 border-t-transparent"})}),g=({events:o,isLoading:g=!1})=>{const{organization:x}=l(),h=i(),u=x?.integrationSettings??{},f=u.mapProvider??"openstreetmap",v=e(e=>{h(r.GALLERY(e))},[h]);if("openstreetmap_free"===f)/* @__PURE__ */return t("div",{class:"relative mt-3 h-screen sm:mt-6",children:/* @__PURE__ */t(s,{fallback:/* @__PURE__ */t(m,{}),children:/* @__PURE__ */t(n,{onExplore:v,logoUrl:x?.logoUrl})})});const y=u.mapTilerApiKey??"",b=u.googleMapsApiKey??"",w=u.mapboxApiKey??"",j=o.filter(e=>"number"==typeof e.location?.x&&"number"==typeof e.location?.y);/* @__PURE__ */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./hOIsfHC7.js";import{B as t,Ht as r,Mt as n,Pt as o,Q as s,X as i,g as l,jt as a,p as c,r as u,zt as d}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 b}from"./DeIGxYF9.js";var v={top:60,bottom:60,left:276,right:60},x="#fb8500",w=new p,L=(e,t,n)=>{r(/* @__PURE__ */s(i,{client:w,children:/* @__PURE__ */s(u,{children:/* @__PURE__ */s(m,{event:e,onExplore:n})})}),t)},z=e=>{const t=document.createElement("div");t.style.cssText=`\n background:${y(e.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=e.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(e.eventCount),t.appendChild(r),t.appendChild(n),t},C=({apiKey:r,is3D:i,onExplore:u,logoUrl:p})=>{const m=a(null),y=a(null),w=a(null),C=a(i),E=a([]),k=a([]),_=a(null),T=a(!1),j=a(!1),
|
|
2
|
-
/* @__PURE__ */s(b,{positionClass:"absolute top-3 left-16 z-[1000]",folderTree:P,activeFolderId:U,setActiveFolderId:
|
|
3
|
-
/* @__PURE__ */s("button",{type:"button",onClick:()=>B(e=>!e),class:"bg-background hover:bg-foreground/10 absolute top-4 right-4 z-[1000] rounded-xl px-3 py-2 text-xs font-semibold shadow-lg backdrop-blur-sm",children:
|
|
1
|
+
import{r as e}from"./hOIsfHC7.js";import{B as t,Ht as r,Mt as n,Pt as o,Q as s,X as i,g as l,jt as a,p as c,r as u,zt as d}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 b}from"./DeIGxYF9.js";var v={top:60,bottom:60,left:276,right:60},x="#fb8500",w=new p,L=(e,t,n)=>{r(/* @__PURE__ */s(i,{client:w,children:/* @__PURE__ */s(u,{children:/* @__PURE__ */s(m,{event:e,onExplore:n})})}),t)},z=e=>{const t=document.createElement("div");t.style.cssText=`\n background:${y(e.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=e.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(e.eventCount),t.appendChild(r),t.appendChild(n),t},C=({apiKey:r,is3D:i,onExplore:u,logoUrl:p})=>{const m=a(null),y=a(null),w=a(null),C=a(i),E=a([]),k=a([]),_=a(null),T=a(!1),j=a(!1),F=a(null),[S,B]=o(i),Z=n(()=>(()=>{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})(),[]),[D,M]=o(!1),[I,O]=o(!0),{folderTree:P,activeFolderId:U,activeFolder:A,visibleEvents:R,setActiveFolderId:W,isLoadingEvents:q}=h(),{organization:J}=c(),N=()=>{E.current.forEach(e=>e.remove()),E.current=[]},$=()=>{k.current.forEach(e=>e.remove()),k.current=[]},H=(e,t)=>{const r=t?"visible":"none";for(const n of["heatmap","event-clusters","cluster-count","unclustered-point"])e.getLayer(n)&&e.setLayoutProperty(n,"visibility",r)};return d(()=>{if(!m.current||y.current)return;let n,o=!1;return(async()=>{try{const s=(await import("./CzSmu5XM.js").then(t=>/* @__PURE__ */e(t.default,1))).default;if(o)return;if(!m.current)return;s.accessToken=r;const i=Z?.center??[0,20],l=Z?.zoom??3,a=new s.Map({container:m.current,style:"mapbox://styles/mapbox/streets-v12",center:i,zoom:l,minZoom:0,pitch:0,bearing:0,renderWorldCopies:!1,antialias:!0,projection:C.current?"globe":"mercator"});y.current=a,w.current=s,a.on("load",()=>{if(o)return;const e=a.getStyle()?.layers??[];let t,r;for(const n of e){const e=n;"symbol"===e.type&&e.layout?.["text-field"]&&!t&&(t=n.id),"building"!==e["source-layer"]||r||(r=e.source)}r&&!a.getLayer("3d-buildings")&&a.addLayer({id:"3d-buildings",source:r,"source-layer":"building",filter:["has","render_height"],type:"fill-extrusion",minzoom:14,paint:{"fill-extrusion-color":["interpolate",["linear"],["get","render_height"],0,"lightgray",200,"royalblue",400,"lightblue"],"fill-extrusion-height":["interpolate",["linear"],["zoom"],14,0,15,["get","render_height"]],"fill-extrusion-base":["case",["has","render_min_height"],["get","render_min_height"],0],"fill-extrusion-opacity":.6}},t),a.addSource("all-events",{type:"geojson",data:{type:"FeatureCollection",features:[]},cluster:!0,clusterRadius:50,clusterMaxZoom:14}),a.addSource("heat-events",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),a.addLayer({id:"heatmap",type:"heatmap",source:"heat-events",layout:{visibility:"none"},paint:{"heatmap-weight":["interpolate",["linear"],["get","views"],0,0,200,1],"heatmap-intensity":["interpolate",["linear"],["zoom"],0,1,9,3],"heatmap-color":["interpolate",["linear"],["heatmap-density"],0,"rgba(33,102,172,0)",.2,"rgb(103,169,207)",.4,"rgb(209,229,240)",.6,"rgb(253,219,199)",.8,"rgb(239,138,98)",1,"rgb(178,24,43)"],"heatmap-radius":["interpolate",["linear"],["zoom"],0,4,9,30],"heatmap-opacity":["interpolate",["linear"],["zoom"],6,.85,11,0]}}),a.addLayer({id:"event-clusters",type:"circle",source:"all-events",layout:{visibility:"none"},filter:["has","point_count"],paint:{"circle-color":["step",["get","point_count"],x,10,"#e63946",30,"#9b2226"],"circle-radius":["step",["get","point_count"],16,10,20,30,26],"circle-stroke-width":2,"circle-stroke-color":"#fff"}}),a.addLayer({id:"cluster-count",type:"symbol",source:"all-events",layout:{visibility:"none","text-field":"{point_count_abbreviated}","text-size":12},paint:{"text-color":"#fff"}}),a.addLayer({id:"unclustered-point",type:"circle",source:"all-events",layout:{visibility:"none"},filter:["!",["has","point_count"]],paint:{"circle-radius":7,"circle-color":x,"circle-stroke-color":"#fff","circle-stroke-width":2}}),a.on("click","event-clusters",e=>{const t=a.queryRenderedFeatures(e.point,{layers:["event-clusters"]});if(!t.length)return;const r=t[0].properties?.cluster_id,n=a.getSource("all-events");r&&n?.getClusterExpansionZoom&&n.getClusterExpansionZoom(r,(e,r)=>{e||"number"!=typeof r||a.easeTo({center:t[0].geometry.coordinates,zoom:r,duration:600})})}),a.on("click","unclustered-point",e=>{const t=e.features?.[0];if(!t)return;const r=t.geometry.coordinates.slice(0,2),n=t.properties??{},o={_id:n._id,slug:n.slug,name:n.name,views:n.views,location:{x:r[0],y:r[1],label:n.label},contents:n.thumbnailUrl?[{thumbnailUrl:n.thumbnailUrl}]:[]};F.current&&(F.current.remove(),F.current=null);const i=document.createElement("div");L(o,i,u);const l=new s.Popup({closeButton:!0,closeOnClick:!1,maxWidth:"none",offset:[0,-10]}).setLngLat(r).setDOMContent(i).addTo(a);F.current=l,l.on("close",()=>{F.current===l&&(F.current=null)})}),a.on("click",e=>{!a.queryRenderedFeatures(e.point,{layers:["event-clusters","unclustered-point"]}).length&&F.current&&(F.current.remove(),F.current=null)}),a.on("mouseenter","event-clusters",()=>{a.getCanvas().style.cursor="pointer"}),a.on("mouseleave","event-clusters",()=>{a.getCanvas().style.cursor=""}),a.on("mouseenter","unclustered-point",()=>{a.getCanvas().style.cursor="pointer"}),a.on("mouseleave","unclustered-point",()=>{a.getCanvas().style.cursor=""}),M(!0),O(!1)});const c=()=>{_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{try{const e=a.getCenter();sessionStorage.setItem(t,JSON.stringify({center:[e.lng,e.lat],zoom:a.getZoom()}))}catch{}},250)};a.on("zoomend",c),a.on("moveend",c),n=()=>{N(),$(),F.current&&(F.current.remove(),F.current=null),_.current&&clearTimeout(_.current),a.off("zoomend",c),a.off("moveend",c),a.remove(),y.current=null,w.current=null}}finally{o||O(!1)}})(),()=>{o=!0,n?.()}},[r]),d(()=>{if(!D)return;const e=y.current,t=w.current;if(e&&t)if(N(),$(),null===U&&P.length>0){H(e,!1);const r=n=>{for(const o of n)if(o.centroid){const r=z(o);r.addEventListener("click",()=>W(o.folder._id));const n=new t.Marker({element:r,anchor:"center"}).setLngLat([o.centroid[0],o.centroid[1]]).addTo(e);E.current.push(n)}else o.children.length>0&&r(o.children)};r(P)}else if(0===P.length&&null===U){if(0===R.length)return;const r=R.map(e=>({type:"Feature",geometry:{type:"Point",coordinates:[e.location.x,e.location.y]},properties:{_id:e._id,slug:e.slug,name:e.name,views:e.views??0,label:e.location?.label??"",thumbnailUrl:e.contents?.[0]?.thumbnailUrl??""}})),n={type:"FeatureCollection",features:r};if(e.getSource("all-events")?.setData(n),e.getSource("heat-events")?.setData({...n,features:r.map(e=>({...e,properties:{views:e.properties.views}}))}),H(e,!0),!j.current&&(j.current=!0,!Z)){const r=new t.LngLatBounds;R.forEach(e=>r.extend([e.location.x,e.location.y])),r.isEmpty()||e.fitBounds(r,{padding:v,maxZoom:8,duration:800})}}else{if(0===R.length)return;H(e,!1);const r=A?.color||x,n=new t.LngLatBounds;R.forEach(o=>{const s=o.location.x,i=o.location.y;n.extend([s,i]);const l=((e,t)=>{const r=document.createElement("div");if(r.style.cssText=`\n width:36px;height:36px;cursor:pointer;\n background:${e};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 `,t){const e=document.createElement("img");e.src=f(t)??"",e.style.cssText="width:24px;height:24px;border-radius:50%;object-fit:cover;transform:rotate(45deg);",r.appendChild(e)}return r})(r,p);l.addEventListener("click",()=>{F.current&&(F.current.remove(),F.current=null);const r=document.createElement("div");L(o,r,u);const n=new t.Popup({closeButton:!0,closeOnClick:!1,maxWidth:"none",offset:[0,-40]}).setLngLat([s,i]).setDOMContent(r).addTo(e);F.current=n,n.on("close",()=>{F.current===n&&(F.current=null)})});const a=new t.Marker({element:l}).setLngLat([s,i]).addTo(e);k.current.push(a)})}},[U,P,R,D,u,p,W,A,Z]),d(()=>{if(!D)return;const e=y.current;if(!e)return;if(!T.current&&Z)return void(T.current=!0);T.current=!0;const t={padding:v,duration:3e3,essential:!0},r=w.current;if(r)if(U){const n=g(P,U);if(!n?.folder.boundary?.length)return;const o=new r.LngLatBounds;for(const e of n.folder.boundary)o.extend([e.x,e.y]);o.isEmpty()||e.fitBounds(o,{...t,maxZoom:14})}else if(P.length>0){const n=new r.LngLatBounds,o=e=>{for(const t of e)t.centroid?n.extend([t.centroid[0],t.centroid[1]]):o(t.children)};o(P),n.isEmpty()||e.fitBounds(n,{...t,maxZoom:8})}},[U,P,D,Z]),d(()=>{y.current&&(C.current=S,y.current.setProjection(S?"globe":"mercator"),y.current.easeTo({pitch:0,bearing:0,duration:600}))},[S]),/* @__PURE__ */s("div",{class:"relative h-screen w-full sm:h-[calc(100vh-4rem)]",style:l(J),children:[
|
|
2
|
+
/* @__PURE__ */s(b,{positionClass:"absolute top-3 left-16 z-[1000]",folderTree:P,activeFolderId:U,setActiveFolderId:W}),
|
|
3
|
+
/* @__PURE__ */s("button",{type:"button",onClick:()=>B(e=>!e),class:"bg-background hover:bg-foreground/10 absolute top-4 right-4 z-[1000] rounded-xl px-3 py-2 text-xs font-semibold shadow-lg backdrop-blur-sm",children:S?"2D":"3D"}),q&&/* @__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"})}),I&&/* @__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…"})]})}),
|
|
4
4
|
/* @__PURE__ */s("div",{ref:m,class:"size-full"})]})};export{C as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{r as e}from"./hOIsfHC7.js";import{B as t,Ht as r,Mt as n,Pt as o,Q as s,X as i,g as l,jt as a,p as c,r as u,zt as d}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 b}from"./DeIGxYF9.js";var v={top:60,bottom:60,left:276,right:60},x="#fb8500",w=new p,L=(e,t,n)=>{r(/* @__PURE__ */s(i,{client:w,children:/* @__PURE__ */s(u,{children:/* @__PURE__ */s(m,{event:e,onExplore:n})})}),t)},z=e=>{const t=document.createElement("div");t.style.cssText=`\n background:${y(e.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=e.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(e.eventCount),t.appendChild(r),t.appendChild(n),t},C=({apiKey:r,is3D:i,onExplore:u,logoUrl:p})=>{const m=a(null),y=a(null),w=a(null),C=a(i),E=a([]),k=a([]),_=a(null),j=a(!1),T=a(!1),F=a(null),[S,B]=o(i),Z=n(()=>(()=>{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})(),[]),[D,M]=o(!1),[I,O]=o(!0),{folderTree:P,activeFolderId:U,activeFolder:A,visibleEvents:R,setActiveFolderId:W,isLoadingEvents:$}=h(),{organization:q}=c(),J=()=>{E.current.forEach(e=>e.remove()),E.current=[]},N=()=>{k.current.forEach(e=>e.remove()),k.current=[]},H=(e,t)=>{const r=t?"visible":"none";for(const n of["heatmap","event-clusters","cluster-count","unclustered-point"])e.getLayer(n)&&e.setLayoutProperty(n,"visibility",r)};return d(()=>{if(!m.current||y.current)return;let n,o=!1;return(async()=>{try{const s=(await import("./CIcND0Dg.js").then(t=>/* @__PURE__ */e(t.default,1))).default;if(o)return;if(!m.current)return;const i=Z?.center??[0,20],l=Z?.zoom??3,a=new s.Map({container:m.current,style:`https://api.maptiler.com/maps/streets-v2/style.json?key=${r}`,center:i,zoom:l,minZoom:0,pitch:0,bearing:0,renderWorldCopies:!1,projection:C.current?{type:"globe"}:{type:"mercator"},canvasContextAttributes:{antialias:!0}});y.current=a,w.current=s,a.on("load",()=>{if(o)return;const e=a.getStyle()?.layers??[];let t,r;for(const n of e){const e=n;"symbol"===e.type&&e.layout?.["text-field"]&&!t&&(t=n.id),"building"!==e["source-layer"]||r||(r=e.source)}r&&!a.getLayer("3d-buildings")&&a.addLayer({id:"3d-buildings",source:r,"source-layer":"building",filter:["has","render_height"],type:"fill-extrusion",minzoom:2,paint:{"fill-extrusion-color":["interpolate",["linear"],["get","render_height"],0,"lightgray",200,"royalblue",400,"lightblue"],"fill-extrusion-height":["interpolate",["linear"],["zoom"],14,0,15,["get","render_height"]],"fill-extrusion-base":["case",["has","render_min_height"],["get","render_min_height"],0],"fill-extrusion-opacity":.6}},t),a.addSource("all-events",{type:"geojson",data:{type:"FeatureCollection",features:[]},cluster:!0,clusterRadius:50,clusterMaxZoom:14}),a.addSource("heat-events",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),a.addLayer({id:"heatmap",type:"heatmap",source:"heat-events",layout:{visibility:"none"},paint:{"heatmap-weight":["interpolate",["linear"],["get","views"],0,0,200,1],"heatmap-intensity":["interpolate",["linear"],["zoom"],0,1,9,3],"heatmap-color":["interpolate",["linear"],["heatmap-density"],0,"rgba(33,102,172,0)",.2,"rgb(103,169,207)",.4,"rgb(209,229,240)",.6,"rgb(253,219,199)",.8,"rgb(239,138,98)",1,"rgb(178,24,43)"],"heatmap-radius":["interpolate",["linear"],["zoom"],0,4,9,30],"heatmap-opacity":["interpolate",["linear"],["zoom"],6,.85,11,0]}}),a.addLayer({id:"event-clusters",type:"circle",source:"all-events",layout:{visibility:"none"},filter:["has","point_count"],paint:{"circle-color":["step",["get","point_count"],x,10,"#e63946",30,"#9b2226"],"circle-radius":["step",["get","point_count"],16,10,20,30,26],"circle-stroke-width":2,"circle-stroke-color":"#fff"}}),a.addLayer({id:"cluster-count",type:"symbol",source:"all-events",layout:{visibility:"none","text-field":"{point_count_abbreviated}","text-size":12},paint:{"text-color":"#fff"}}),a.addLayer({id:"unclustered-point",type:"circle",source:"all-events",layout:{visibility:"none"},filter:["!",["has","point_count"]],paint:{"circle-radius":7,"circle-color":x,"circle-stroke-color":"#fff","circle-stroke-width":2}}),a.on("click","event-clusters",e=>{const t=a.queryRenderedFeatures(e.point,{layers:["event-clusters"]});if(!t.length)return;const r=t[0].properties?.cluster_id,n=a.getSource("all-events");r&&n?.getClusterExpansionZoom&&n.getClusterExpansionZoom(r,(e,r)=>{e||"number"!=typeof r||a.easeTo({center:t[0].geometry.coordinates,zoom:r,duration:600})})}),a.on("click","unclustered-point",e=>{const t=e.features?.[0];if(!t)return;const r=t.geometry.coordinates.slice(0,2),n=t.properties??{},o={_id:n._id,slug:n.slug,name:n.name,views:n.views,location:{x:r[0],y:r[1],label:n.label},contents:n.thumbnailUrl?[{thumbnailUrl:n.thumbnailUrl}]:[]};F.current&&(F.current.remove(),F.current=null);const i=document.createElement("div");L(o,i,u);const l=new s.Popup({closeButton:!0,closeOnClick:!1,maxWidth:"none",offset:[0,-10]}).setLngLat(r).setDOMContent(i).addTo(a);F.current=l,l.on("close",()=>{F.current===l&&(F.current=null)})}),a.on("click",e=>{!a.queryRenderedFeatures(e.point,{layers:["event-clusters","unclustered-point"]}).length&&F.current&&(F.current.remove(),F.current=null)}),a.on("mouseenter","event-clusters",()=>{a.getCanvas().style.cursor="pointer"}),a.on("mouseleave","event-clusters",()=>{a.getCanvas().style.cursor=""}),a.on("mouseenter","unclustered-point",()=>{a.getCanvas().style.cursor="pointer"}),a.on("mouseleave","unclustered-point",()=>{a.getCanvas().style.cursor=""}),M(!0),O(!1)});const c=()=>{_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{try{const e=a.getCenter();sessionStorage.setItem(t,JSON.stringify({center:[e.lng,e.lat],zoom:a.getZoom()}))}catch{}},250)};a.on("zoomend",c),a.on("moveend",c),n=()=>{J(),N(),_.current&&clearTimeout(_.current),a.off("zoomend",c),a.off("moveend",c),a.remove(),y.current=null,w.current=null}}finally{o||O(!1)}})(),()=>{o=!0,n?.()}},[r]),d(()=>{if(!D)return;const e=y.current,t=w.current;if(e&&t)if(J(),N(),null===U&&P.length>0){H(e,!1);const r=n=>{for(const o of n)if(o.centroid){const r=z(o);r.addEventListener("click",()=>W(o.folder._id));const n=new t.Marker({element:r,anchor:"center"}).setLngLat([o.centroid[0],o.centroid[1]]).addTo(e);E.current.push(n)}else o.children.length>0&&r(o.children)};r(P)}else if(0===P.length&&null===U){if(0===R.length)return;const r=R.map(e=>({type:"Feature",geometry:{type:"Point",coordinates:[e.location.x,e.location.y]},properties:{_id:e._id,slug:e.slug,name:e.name,views:e.views??0,label:e.location?.label??"",thumbnailUrl:e.contents?.[0]?.thumbnailUrl??""}})),n={type:"FeatureCollection",features:r};if(e.getSource("all-events")?.setData(n),e.getSource("heat-events")?.setData({...n,features:r.map(e=>({...e,properties:{views:e.properties.views}}))}),H(e,!0),!T.current&&(T.current=!0,!Z)){const r=new t.LngLatBounds;R.forEach(e=>r.extend([e.location.x,e.location.y])),r.isEmpty()||e.fitBounds(r,{padding:v,maxZoom:8,duration:800})}}else{if(0===R.length)return;H(e,!1);const r=A?.color||x,n=new t.LngLatBounds;R.forEach(o=>{const s=o.location.x,i=o.location.y;n.extend([s,i]);const l=((e,t)=>{const r=document.createElement("div");if(r.style.cssText=`\n width:36px;height:36px;cursor:pointer;\n background:${e};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 `,t){const e=document.createElement("img");e.src=f(t)??"",e.style.cssText="width:24px;height:24px;border-radius:50%;object-fit:cover;transform:rotate(45deg);",r.appendChild(e)}return r})(r,p);l.addEventListener("click",()=>{F.current&&(F.current.remove(),F.current=null);const r=document.createElement("div");L(o,r,u);const n=new t.Popup({closeButton:!0,closeOnClick:!1,maxWidth:"none",offset:[0,-40]}).setLngLat([s,i]).setDOMContent(r).addTo(e);F.current=n,n.on("close",()=>{F.current===n&&(F.current=null)})});const a=new t.Marker({element:l}).setLngLat([s,i]).addTo(e);k.current.push(a)})}},[U,P,R,D,u,p,W,A,Z]),d(()=>{if(!D)return;const e=y.current;if(!e)return;if(!j.current&&Z)return void(j.current=!0);j.current=!0;const t={padding:v,duration:3e3,essential:!0};if(U){const r=g(P,U);if(!r?.folder.boundary?.length)return;const n=w.current;if(!n)return;const o=new n.LngLatBounds;for(const e of r.folder.boundary)o.extend([e.x,e.y]);o.isEmpty()||e.fitBounds(o,{...t,maxZoom:14})}else if(P.length>0){const r=w.current;if(!r)return;const n=new r.LngLatBounds,o=e=>{for(const t of e)t.centroid?n.extend([t.centroid[0],t.centroid[1]]):o(t.children)};o(P),n.isEmpty()||e.fitBounds(n,{...t,maxZoom:8})}},[U,P,D,Z]),d(()=>{y.current&&(C.current=S,y.current.setProjection(S?{type:"globe"}:{type:"mercator"}),y.current.easeTo({pitch:0,bearing:0,duration:600}))},[S]),/* @__PURE__ */s("div",{class:"relative h-screen w-full sm:h-[calc(100vh-4rem)]",style:l(q),children:[
|
|
2
|
+
/* @__PURE__ */s(b,{positionClass:"absolute top-3 left-16 z-[1000]",folderTree:P,activeFolderId:U,setActiveFolderId:W}),
|
|
3
|
+
/* @__PURE__ */s("button",{type:"button",onClick:()=>B(e=>!e),class:"bg-background hover:bg-foreground/10 absolute top-4 right-4 z-[1000] rounded-xl px-3 py-2 text-xs font-semibold shadow-lg backdrop-blur-sm",children:S?"2D":"3D"}),$&&/* @__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"})}),I&&/* @__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…"})]})}),
|
|
4
|
+
/* @__PURE__ */s("div",{ref:m,class:"size-full"})]})};export{C as default};
|
package/element/web.es.js
CHANGED
|
@@ -10,7 +10,7 @@ import{r as e,t}from"./hOIsfHC7.js";import{A as r,Bt as n,C as o,D as a,E as i,F
|
|
|
10
10
|
return S(Ke.Provider,{value:n,children:e})},Xe=({eventSlug:e})=>{const{props:t}=ne(),r=t?.organizationId,{isLoading:n,data:a,isError:i,error:s}=m({queryKey:[`event-data-${r??""}-${e??""}`],queryFn:async()=>{try{const t=await oe.get(o.EVENT_DATA,{searchParams:e?{eventSlug:e}:void 0,headers:{"x-org-id":r}}).json();if(t.error)throw new Error(t.error);return t.data}catch(t){throw new Error(t instanceof Error?t.message:String(t)||"Failed to fetch event data")}},enabled:!!r&&!!e});return{loading:n,event:a?.event,ads:a?.ads,gamConfig:a?.gamConfig,parameters:a?.parameters,isError:i,error:s}},$e=({title:e,description:t,iconSvg:r,className:n})=>{const{props:{emptyStateImage:o},organization:a}=ne();/* @__PURE__ */
|
|
11
11
|
return S("div",{className:V("mx-auto flex w-full max-w-md flex-col items-center justify-center gap-8",n),children:[a?.integrationSettings?.showLogo?/* @__PURE__ */S("img",{className:"h-44 w-auto",src:a?.logoUrl||"/images/qrati-logo.svg"}):o?/* @__PURE__ */S("img",{className:"h-44 w-auto",src:o,alt:e}):r?/* @__PURE__ */S("div",{className:"text-primary h-44 w-auto",children:r}):null,/* @__PURE__ */S("div",{className:"space-y-2",children:[
|
|
12
12
|
/* @__PURE__ */S(Me,{variant:"h4",align:"center",children:e}),"string"==typeof t&&/* @__PURE__ */S(Me,{variant:"body2",color:"muted",align:"center",children:t}),"string"!=typeof t&&t]})]})},et=()=>{const{t:e}=Qe(),t=X(),r=ue(),{initializing:n,organization:o,loadingUser:a,user:i,signout:s}=ne();/* @__PURE__ */
|
|
13
|
-
return S("div",n||a?{className:"my-2 flex justify-end",children:/* @__PURE__ */S(He,{className:"h-9 w-64"})}:{className:"mx-auto mb-4",children:[!i&&/* @__PURE__ */S("div",{className:"flex justify-end gap-4",children:/* @__PURE__ */S(ee,{to:`${P.LOGIN}?ref=${encodeURIComponent(t.pathname)}`,children:/* @__PURE__ */S(je,{children:
|
|
13
|
+
return S("div",n||a?{className:"my-2 flex justify-end",children:/* @__PURE__ */S(He,{className:"h-9 w-64"})}:{className:"mx-auto mb-4",children:[!i&&/* @__PURE__ */S("div",{className:"flex justify-end gap-4",children:/* @__PURE__ */S(ee,{to:`${P.LOGIN}?ref=${encodeURIComponent(t.pathname)}`,children:/* @__PURE__ */S(je,{children:"Login"})})}),i&&/* @__PURE__ */S("div",{className:"mt-2 flex items-center justify-end gap-4",children:[/* @__PURE__ */S(Me,{variant:"h5",children:i.name}),!o.customAuth&&/* @__PURE__ */S("button",{onClick:async()=>{await s(),r(P.PUBLIC_EVENTS)},children:/* @__PURE__ */S(Be,{name:"material-symbols:exit-to-app-rounded",color:"error"})})]})]})},tt=()=>{const e=ue();/* @__PURE__ */
|
|
14
14
|
return S("button",{type:"button",onClick:()=>{window.history.length>1?e(-1):e(P.PUBLIC_EVENTS,{state:{internalNavigation:!0}})},className:"text-primary absolute top-0 left-0",children:/* @__PURE__ */S(Be,{name:"material-symbols:arrow-back-rounded",size:"lg"})})},rt=()=>{const{user:e,organization:t,signout:r}=ne(),n=t?.integrationSettings?.hideQratiBranding;/* @__PURE__ */
|
|
15
15
|
return S("div",{className:"pt-16 sm:pt-24",children:[t&&!t.customAuth&&/* @__PURE__ */S("div",{className:"mx-auto py-2",children:[!e&&/* @__PURE__ */S(Me,{variant:"h6",align:"center",children:[
|
|
16
16
|
/* @__PURE__ */S(ee,{className:"text-primary hover:underline",to:P.LOGIN,children:"Login"})," ","•"," ",
|
|
@@ -256,7 +256,7 @@ return S("div",{className:"mt-3 space-y-6 sm:mt-6",children:["content"===r&&f.le
|
|
|
256
256
|
return S("div",{className:"space-y-4",children:[t===p[0]&&/* @__PURE__ */S(Me,{variant:"h3",className:"mb-4",children:["Events (",c.length,")"]}),
|
|
257
257
|
/* @__PURE__ */S("div",{className:"flex items-center justify-between gap-3",children:[/* @__PURE__ */S("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */S("span",{className:"inline-block size-2 rounded-full",style:{backgroundColor:r.color||"#9ca3af"}}),/* @__PURE__ */S(Me,{variant:"h5",className:"text-sm sm:text-base",children:r.pathLabel})]}),/* @__PURE__ */S(Me,{variant:"body2",color:"muted",children:[n.length," ",1===n.length?"result":"results"]})]}),
|
|
258
258
|
/* @__PURE__ */S("div",{className:"grid grid-cols-1 gap-4 gap-y-6 sm:grid-cols-2 lg:grid-cols-3",children:n.map(e=>/* @__PURE__ */S(C,{event:e},e._id))})]},`event-folder-${t}`)}):p.map(e=>{const r=g[e]||[];/* @__PURE__ */
|
|
259
|
-
return S("div",{className:"space-y-4",children:[e===p[0]&&/* @__PURE__ */S(Me,{variant:"h3",className:"mb-4",children:["Contents (",u?.totalContentCount||d.length,") Events (",u?.totalEventCount||m.length,")"]}),/* @__PURE__ */S("div",{className:"space-y-6",children:r.map(e=>/* @__PURE__ */S("div",{className:"space-y-3",children:[/* @__PURE__ */S(C,{event:e.event}),/* @__PURE__ */S("div",{className:"grid grid-cols-3 gap-3",children:e.contents.map(r=>/* @__PURE__ */S(Ac,{content:r,timestampField:"captureTime",submittedQuery:t,onClick:()=>b(e.event._id,r._id)},r._id))})]},`content-event-${e.event._id}`))})]},`content-folder-${e}`)})),"content"===r&&i&&!o&&/* @__PURE__ */S("div",{ref:_,className:"h-4 w-full","aria-hidden":"true"}),"content"===r&&i&&n&&s>1&&!o&&/* @__PURE__ */S("div",{className:"flex justify-center pt-2",children:/* @__PURE__ */S(Be,{name:"eos-icons:loading",className:"text-2xl"})}),"event"===r&&i&&a&&!o&&/* @__PURE__ */S("div",{className:"flex justify-center pt-2",children:/* @__PURE__ */S("button",{type:"button",disabled:n,className:"bg-primary text-primary-foreground disabled:bg-muted rounded px-4 py-2 text-sm font-medium disabled:cursor-not-allowed",onClick:l,children:n?"Loading...":"Load More"})})]})},Lc=$(()=>import("./
|
|
259
|
+
return S("div",{className:"space-y-4",children:[e===p[0]&&/* @__PURE__ */S(Me,{variant:"h3",className:"mb-4",children:["Contents (",u?.totalContentCount||d.length,") Events (",u?.totalEventCount||m.length,")"]}),/* @__PURE__ */S("div",{className:"space-y-6",children:r.map(e=>/* @__PURE__ */S("div",{className:"space-y-3",children:[/* @__PURE__ */S(C,{event:e.event}),/* @__PURE__ */S("div",{className:"grid grid-cols-3 gap-3",children:e.contents.map(r=>/* @__PURE__ */S(Ac,{content:r,timestampField:"captureTime",submittedQuery:t,onClick:()=>b(e.event._id,r._id)},r._id))})]},`content-event-${e.event._id}`))})]},`content-folder-${e}`)})),"content"===r&&i&&!o&&/* @__PURE__ */S("div",{ref:_,className:"h-4 w-full","aria-hidden":"true"}),"content"===r&&i&&n&&s>1&&!o&&/* @__PURE__ */S("div",{className:"flex justify-center pt-2",children:/* @__PURE__ */S(Be,{name:"eos-icons:loading",className:"text-2xl"})}),"event"===r&&i&&a&&!o&&/* @__PURE__ */S("div",{className:"flex justify-center pt-2",children:/* @__PURE__ */S("button",{type:"button",disabled:n,className:"bg-primary text-primary-foreground disabled:bg-muted rounded px-4 py-2 text-sm font-medium disabled:cursor-not-allowed",onClick:l,children:n?"Loading...":"Load More"})})]})},Lc=$(()=>import("./DF6wxpU6.js")),Nc={grid:{icon:/* @__PURE__ */S("svg",{xmlns:"http://www.w3.org/2000/svg",className:"size-full text-inherit",width:24,height:24,viewBox:"0 0 24 24",children:/* @__PURE__ */S("path",{fill:"currentColor",d:"M5 11q-.825 0-1.412-.587T3 9V5q0-.825.588-1.412T5 3h4q.825 0 1.413.588T11 5v4q0 .825-.587 1.413T9 11zm0 10q-.825 0-1.412-.587T3 19v-4q0-.825.588-1.412T5 13h4q.825 0 1.413.588T11 15v4q0 .825-.587 1.413T9 21zm10-10q-.825 0-1.412-.587T13 9V5q0-.825.588-1.412T15 3h4q.825 0 1.413.588T21 5v4q0 .825-.587 1.413T19 11zm0 10q-.825 0-1.412-.587T13 19v-4q0-.825.588-1.412T15 13h4q.825 0 1.413.588T21 15v4q0 .825-.587 1.413T19 21zM5 9h4V5H5zm10 0h4V5h-4zm0 10h4v-4h-4zM5 19h4v-4H5zM9 9"})})},map:{icon:/* @__PURE__ */S("svg",{xmlns:"http://www.w3.org/2000/svg",className:"size-full text-inherit",width:24,height:24,viewBox:"0 0 24 24",children:/* @__PURE__ */S("path",{fill:"currentColor",d:"M14.35 20.775L9 18.9l-4.65 1.8q-.25.1-.488.063t-.437-.163t-.312-.337T3 19.775V5.75q0-.325.188-.575T3.7 4.8l4.65-1.575q.15-.05.313-.075T9 3.125t.338.025t.312.075L15 5.1l4.65-1.8q.25-.1.488-.062t.437.162t.313.338t.112.487V18.25q0 .325-.187.575t-.513.375l-4.65 1.575q-.15.05-.312.075t-.338.025t-.337-.025t-.313-.075M14 18.55V6.85l-4-1.4v11.7zm2 0l3-1V5.7l-3 1.15zM5 18.3l3-1.15V5.45l-3 1zM16 6.85v11.7zm-8-1.4v11.7z"})})}},Ic=Object.keys(Nc).map(e=>({icon:Nc[e].icon,value:e})),Pc=()=>{const e=W().folderId??"",t=ne(),{folders:r,organization:n}=t,a=t.props?.organizationId,i=!1!==n?.integrationSettings?.enableGlobalSearch,s=((e,t)=>{const[r,n]=E(""),[a,i]=E("event"),[s,l]=E(1),[c,d]=E(!1),[u,p]=E(""),[h,m]=E(!1),[g,f]=E([]),[v,w]=E([]),[b,_]=E(null),x=Y(0),C=Y(null),k=Y(null),S=y(()=>`org-inline-search-gallery-${e||"default"}`,[e]);ve(()=>{if(!e||!r)return;const t=++x.current;(async()=>{d(!0),p("");try{const n="event"===a?o.SEARCH_EVENTS:o.SEARCH_CONTENTS,i=await oe.get(n,{timeout:6e4,headers:{"x-org-id":e},searchParams:{query:r,page:String(s),limit:"event"===a?"12":"8"}}).json();if(t!==x.current)return;const l=i?.data||[];console.log("next data ",l);const c=i?.meta?.totalPages||0;m((i?.meta?.currentPage||0)<c),"event"===a?f(e=>1===s?l:[...e,...l]):(_({totalContentCount:i?.meta?.totalContentCount,totalEventCount:i?.meta?.totalEventCount}),w(e=>1===s?l:[...e,...l]))}catch(n){if(t!==x.current)return;p(n?.message||"Failed to search")}finally{t===x.current&&d(!1)}})()},[e,s,r,a]);const A=y(()=>{const e={};return g.forEach(t=>{const r=t.folderId||"root";e[r]||(e[r]=[]),e[r].push(t)}),Object.values(e).forEach(e=>{e.sort((e,t)=>(e.name||"").localeCompare(t.name||"",void 0,{sensitivity:"base"}))}),e},[g]),M=y(()=>{const e=/* @__PURE__ */new Map,t=/* @__PURE__ */new Set;return v.forEach(r=>{if(!r?._id||t.has(r._id))return;t.add(r._id);const n=r.event?._id||r.eventId;n&&r.event&&(e.has(n)||e.set(n,{event:r.event,contents:[]}),e.get(n)?.contents.push({...r}))}),Array.from(e.values()).sort((e,t)=>(e.event?.name||"").localeCompare(t.event?.name||"",void 0,{sensitivity:"base"}))},[v]),L=y(()=>{const e={};return M.forEach(t=>{const r=t.event?.folderId||"root";e[r]||(e[r]=[]),e[r].push(t)}),e},[M]),N=y(()=>{const e=Object.keys("event"===a?A:L);return e.sort((e,r)=>{if("root"===e)return-1;if("root"===r)return 1;const n=bc(t,e).map(e=>e.name).join("/"),o=bc(t,r).map(e=>e.name).join("/");return n.localeCompare(o)}),e},[L,A,t,a]),I=y(()=>{if("content"!==a)return[];const e=[];return N.forEach(t=>{(L[t]||[]).forEach(t=>{t.contents.forEach(r=>{e.push({event:t.event,content:r})})})}),e},[N,L,a]);return ve(()=>{const e=k.current;if("content"!==a||!r||0===I.length||!e)return C.current?.destroy?.(),void(C.current=null);const t=new ze({gallery:e,children:"a.pswp-item",counter:!1,bgOpacity:1,wheelToZoom:!0,pinchToClose:!0,zoom:!1,pswpModule:De});return C.current=t,t.init(),()=>{C.current?.destroy?.(),C.current=null}},[I.length,S,r,a]),{handleSearch:(e,t)=>{l(1),p(""),m(!1),f([]),w([]),_(null),i(t),n(e)},clearSearch:()=>{n(""),p(""),m(!1),l(1),f([]),w([]),_(null)},isSearchActive:r.length>0,submittedQuery:r,submittedSearchType:a,isLoading:c,errorMessage:u,hasMore:h,page:s,setPage:l,eventResults:g,contentResults:v,contentMeta:b,activeFolderKeys:N,eventGroupsByFolder:A,contentGroups:M,contentGroupsByFolder:L,flattenedContentMedia:I,lightboxRef:C,galleryElementRef:k,galleryId:S,openMediaInLightbox:(e,t)=>{if(!C.current?.loadAndOpen)return;const r=I.findIndex(r=>r.event._id===e&&r.content._id===t);r>=0&&C.current.loadAndOpen(r)}}})(a,r||[]),l=!0===n?.integrationSettings?.enableMapView,[c,d]=E(()=>{if(!a)return"grid";try{return sessionStorage.getItem(`qrati-view-mode-${a}`)||"grid"}catch{return"grid"}}),{data:u,isLoading:p}=m({queryKey:[`public-events-map-${a}`,e||"all-folders"],enabled:l&&"map"===c,staleTime:3e5,queryFn:async()=>{const t=e.length>0?{folderId:e,limit:500,sort:"-views"}:{includeAllFolders:"true",limit:500,sort:"-views",contentLimit:3};return(await oe.get(o.PUBLIC_EVENTS,{headers:{"x-org-id":a},searchParams:t}).json()).data}}),h=y(()=>{if("undefined"==typeof window)return null;if(window.history.state?.internalNavigation)return null;try{const e=new URLSearchParams(window.location?.search??"");let t=e.get("event"),r=e.get("page");if(!t&&!r&&window.location?.hash){const e=window.location.hash.split("?");if(e.length>1){const n=new URLSearchParams(e[1]);t=n.get("event"),r=n.get("page")}}if(t){if(r)switch(r.toLowerCase()){case"upload":return P.UPLOAD(t);case"curate":return P.CURATE(t);case"leaderboard":return P.LEADERBOARD(t);default:return P.GALLERY(t)}return P.GALLERY(t)}}catch(Md){console.error("Error parsing URL parameters:",Md)}return null},[]),g=(r??[]).filter(t=>t.parentFolderId===(e?.length>0?e:null)||t.parentFolderId===(e?.length>0?e:void 0)),{isLoading:f,data:v}=m({queryKey:[`public-events-${a}`,e],queryFn:async()=>(await oe.get(o.PUBLIC_EVENTS,{headers:{"x-org-id":a},searchParams:{folderId:e,sort:"-createdAt"}}).json()).data});return h?/* @__PURE__ */S(D,{to:h,replace:!0}):/* @__PURE__ */S(I,f||!n?{children:[n?.navigationSettings?.enableNavbar&&/* @__PURE__ */S(et,{}),/* @__PURE__ */S("div",{className:"min-h-screen w-full",children:[
|
|
260
260
|
/* @__PURE__ */S(kc,{organization:n}),
|
|
261
261
|
/* @__PURE__ */S("div",{className:"mt-4 grid grid-cols-2 gap-3 md:grid-cols-3 lg:grid-cols-4 lg:gap-6",children:Array.from({length:4}).map((e,t)=>/* @__PURE__ */S(He,{className:"h-24 rounded"},`folder-${t}`))}),
|
|
262
262
|
/* @__PURE__ */S("div",{className:"mt-4 grid grid-cols-1 gap-4 sm:grid-cols-3",children:Array.from({length:6}).map((e,t)=>/* @__PURE__ */S("div",{className:"space-y-4",children:[/* @__PURE__ */S(He,{className:"h-72 overflow-hidden rounded sm:h-80"}),/* @__PURE__ */S(He,{className:"h-6 w-64 rounded"})]},t))})]})]}:{children:[n?.navigationSettings?.enableNavbar&&/* @__PURE__ */S(et,{}),
|
package/package.json
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{n as e}from"./Bto__AIV.js";import{At as t,Ct as r,Et as n,V as o,et as s,g as i,jt as l,p as a,r as c,wt as u,y as d}from"./CybQW90i.js";import{t as p}from"./BhV55-yN.js";import{a as m,i as f,n as g,o as y,r as h,t as b}from"./DVHopcEy.js";var v={top:60,bottom:60,left:276,right:60},x="#fb8500",w=new p,L=(e,t,r)=>{l(/* @__PURE__ */d(s,{client:w,children:/* @__PURE__ */d(c,{children:/* @__PURE__ */d(m,{event:e,onExplore:r})})}),t)},C=e=>{const t=document.createElement("div");t.style.cssText=`\n background:${h(e.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=e.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(e.eventCount),t.appendChild(r),t.appendChild(n),t},z=({apiKey:s,is3D:l,onExplore:c,logoUrl:p})=>{const m=r(null),h=r(null),w=r(null),z=r(l),E=r([]),k=r([]),_=r(null),j=r(!1),T=r(!1),F=r(null),[S,B]=n(l),Z=u(()=>(()=>{try{const e=sessionStorage.getItem(o);if(!e)return null;const t=JSON.parse(e);if(Array.isArray(t?.center)&&"number"==typeof t.zoom)return t}catch{}return null})(),[]),[D,A]=n(!1),[I,M]=n(!0),{folderTree:O,activeFolderId:U,activeFolder:P,visibleEvents:R,setActiveFolderId:W,isLoadingEvents:$}=y(),{organization:q}=a(),J=()=>{E.current.forEach(e=>e.remove()),E.current=[]},N=()=>{k.current.forEach(e=>e.remove()),k.current=[]},K=(e,t)=>{const r=t?"visible":"none";for(const n of["heatmap","event-clusters","cluster-count","unclustered-point"])e.getLayer(n)&&e.setLayoutProperty(n,"visibility",r)};return t(()=>{if(!m.current||h.current)return;let t,r=!1;return(async()=>{try{const n=(await import("./C8D6WaBQ.js").then(t=>/* @__PURE__ */e(t.default,1))).default;if(r)return;if(!m.current)return;const i=Z?.center??[0,20],l=Z?.zoom??3,a=new n.Map({container:m.current,style:`https://api.maptiler.com/maps/streets-v2/style.json?key=${s}`,center:i,zoom:l,minZoom:0,pitch:0,bearing:0,renderWorldCopies:!1,projection:z.current?{type:"globe"}:{type:"mercator"},canvasContextAttributes:{antialias:!0}});h.current=a,w.current=n,a.on("load",()=>{if(r)return;const e=a.getStyle()?.layers??[];let t,o;for(const r of e){const e=r;"symbol"===e.type&&e.layout?.["text-field"]&&!t&&(t=r.id),"building"!==e["source-layer"]||o||(o=e.source)}o&&!a.getLayer("3d-buildings")&&a.addLayer({id:"3d-buildings",source:o,"source-layer":"building",filter:["has","render_height"],type:"fill-extrusion",minzoom:2,paint:{"fill-extrusion-color":["interpolate",["linear"],["get","render_height"],0,"lightgray",200,"royalblue",400,"lightblue"],"fill-extrusion-height":["interpolate",["linear"],["zoom"],14,0,15,["get","render_height"]],"fill-extrusion-base":["case",["has","render_min_height"],["get","render_min_height"],0],"fill-extrusion-opacity":.6}},t),a.addSource("all-events",{type:"geojson",data:{type:"FeatureCollection",features:[]},cluster:!0,clusterRadius:50,clusterMaxZoom:14}),a.addSource("heat-events",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),a.addLayer({id:"heatmap",type:"heatmap",source:"heat-events",layout:{visibility:"none"},paint:{"heatmap-weight":["interpolate",["linear"],["get","views"],0,0,200,1],"heatmap-intensity":["interpolate",["linear"],["zoom"],0,1,9,3],"heatmap-color":["interpolate",["linear"],["heatmap-density"],0,"rgba(33,102,172,0)",.2,"rgb(103,169,207)",.4,"rgb(209,229,240)",.6,"rgb(253,219,199)",.8,"rgb(239,138,98)",1,"rgb(178,24,43)"],"heatmap-radius":["interpolate",["linear"],["zoom"],0,4,9,30],"heatmap-opacity":["interpolate",["linear"],["zoom"],6,.85,11,0]}}),a.addLayer({id:"event-clusters",type:"circle",source:"all-events",layout:{visibility:"none"},filter:["has","point_count"],paint:{"circle-color":["step",["get","point_count"],x,10,"#e63946",30,"#9b2226"],"circle-radius":["step",["get","point_count"],16,10,20,30,26],"circle-stroke-width":2,"circle-stroke-color":"#fff"}}),a.addLayer({id:"cluster-count",type:"symbol",source:"all-events",layout:{visibility:"none","text-field":"{point_count_abbreviated}","text-size":12},paint:{"text-color":"#fff"}}),a.addLayer({id:"unclustered-point",type:"circle",source:"all-events",layout:{visibility:"none"},filter:["!",["has","point_count"]],paint:{"circle-radius":7,"circle-color":x,"circle-stroke-color":"#fff","circle-stroke-width":2}}),a.on("click","event-clusters",e=>{const t=a.queryRenderedFeatures(e.point,{layers:["event-clusters"]});if(!t.length)return;const r=t[0].properties?.cluster_id,n=a.getSource("all-events");r&&n?.getClusterExpansionZoom&&n.getClusterExpansionZoom(r,(e,r)=>{e||"number"!=typeof r||a.easeTo({center:t[0].geometry.coordinates,zoom:r,duration:600})})}),a.on("click","unclustered-point",e=>{const t=e.features?.[0];if(!t)return;const r=t.geometry.coordinates.slice(0,2),o=t.properties??{},s={_id:o._id,slug:o.slug,name:o.name,views:o.views,location:{x:r[0],y:r[1],label:o.label},contents:o.thumbnailUrl?[{thumbnailUrl:o.thumbnailUrl}]:[]};F.current&&(F.current.remove(),F.current=null);const i=document.createElement("div");L(s,i,c);const l=new n.Popup({closeButton:!0,closeOnClick:!1,maxWidth:"none",offset:[0,-10]}).setLngLat(r).setDOMContent(i).addTo(a);F.current=l,l.on("close",()=>{F.current===l&&(F.current=null)})}),a.on("click",e=>{!a.queryRenderedFeatures(e.point,{layers:["event-clusters","unclustered-point"]}).length&&F.current&&(F.current.remove(),F.current=null)}),a.on("mouseenter","event-clusters",()=>{a.getCanvas().style.cursor="pointer"}),a.on("mouseleave","event-clusters",()=>{a.getCanvas().style.cursor=""}),a.on("mouseenter","unclustered-point",()=>{a.getCanvas().style.cursor="pointer"}),a.on("mouseleave","unclustered-point",()=>{a.getCanvas().style.cursor=""}),A(!0),M(!1)});const u=()=>{_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{try{const e=a.getCenter();sessionStorage.setItem(o,JSON.stringify({center:[e.lng,e.lat],zoom:a.getZoom()}))}catch{}},250)};a.on("zoomend",u),a.on("moveend",u),t=()=>{J(),N(),_.current&&clearTimeout(_.current),a.off("zoomend",u),a.off("moveend",u),a.remove(),h.current=null,w.current=null}}finally{r||M(!1)}})(),()=>{r=!0,t?.()}},[s]),t(()=>{if(!D)return;const e=h.current,t=w.current;if(e&&t)if(J(),N(),null===U&&O.length>0){K(e,!1);const r=n=>{for(const o of n)if(o.centroid){const r=C(o);r.addEventListener("click",()=>W(o.folder._id));const n=new t.Marker({element:r,anchor:"center"}).setLngLat([o.centroid[0],o.centroid[1]]).addTo(e);E.current.push(n)}else o.children.length>0&&r(o.children)};r(O)}else if(0===O.length&&null===U){if(0===R.length)return;const r=R.map(e=>({type:"Feature",geometry:{type:"Point",coordinates:[e.location.x,e.location.y]},properties:{_id:e._id,slug:e.slug,name:e.name,views:e.views??0,label:e.location?.label??"",thumbnailUrl:e.contents?.[0]?.thumbnailUrl??""}})),n={type:"FeatureCollection",features:r};if(e.getSource("all-events")?.setData(n),e.getSource("heat-events")?.setData({...n,features:r.map(e=>({...e,properties:{views:e.properties.views}}))}),K(e,!0),!T.current&&(T.current=!0,!Z)){const r=new t.LngLatBounds;R.forEach(e=>r.extend([e.location.x,e.location.y])),r.isEmpty()||e.fitBounds(r,{padding:v,maxZoom:8,duration:800})}}else{if(0===R.length)return;K(e,!1);const r=P?.color||x,n=new t.LngLatBounds;R.forEach(o=>{const s=o.location.x,i=o.location.y;n.extend([s,i]);const l=((e,t)=>{const r=document.createElement("div");if(r.style.cssText=`\n width:36px;height:36px;cursor:pointer;\n background:${e};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 `,t){const e=document.createElement("img");e.src=f(t)??"",e.style.cssText="width:24px;height:24px;border-radius:50%;object-fit:cover;transform:rotate(45deg);",r.appendChild(e)}return r})(r,p);l.addEventListener("click",()=>{F.current&&(F.current.remove(),F.current=null);const r=document.createElement("div");L(o,r,c);const n=new t.Popup({closeButton:!0,closeOnClick:!1,maxWidth:"none",offset:[0,-40]}).setLngLat([s,i]).setDOMContent(r).addTo(e);F.current=n,n.on("close",()=>{F.current===n&&(F.current=null)})});const a=new t.Marker({element:l}).setLngLat([s,i]).addTo(e);k.current.push(a)})}},[U,O,R,D,c,p,W,P,Z]),t(()=>{if(!D)return;const e=h.current;if(!e)return;if(!j.current&&Z)return void(j.current=!0);j.current=!0;const t={padding:v,duration:3e3,essential:!0};if(U){const r=g(O,U);if(!r?.folder.boundary?.length)return;const n=w.current;if(!n)return;const o=new n.LngLatBounds;for(const e of r.folder.boundary)o.extend([e.x,e.y]);o.isEmpty()||e.fitBounds(o,{...t,maxZoom:14})}else if(O.length>0){const r=w.current;if(!r)return;const n=new r.LngLatBounds,o=e=>{for(const t of e)t.centroid?n.extend([t.centroid[0],t.centroid[1]]):o(t.children)};o(O),n.isEmpty()||e.fitBounds(n,{...t,maxZoom:8})}},[U,O,D,Z]),t(()=>{h.current&&(z.current=S,h.current.setProjection(S?{type:"globe"}:{type:"mercator"}),h.current.easeTo({pitch:0,bearing:0,duration:600}))},[S]),/* @__PURE__ */d("div",{class:"relative h-screen w-full sm:h-[calc(100vh-4rem)]",style:i(q),children:[
|
|
2
|
+
/* @__PURE__ */d(b,{positionClass:"absolute top-3 left-16 z-[1000]",folderTree:O,activeFolderId:U,setActiveFolderId:W}),
|
|
3
|
+
/* @__PURE__ */d("button",{type:"button",onClick:()=>B(e=>!e),class:"bg-background hover:bg-foreground/10 absolute top-4 right-4 z-[1000] rounded-xl px-3 py-2 text-xs font-semibold shadow-lg backdrop-blur-sm",children:S?"2D":"3D"}),$&&/* @__PURE__ */d("div",{class:"absolute inset-0 z-10 flex items-center justify-center bg-white/60",children:/* @__PURE__ */d("div",{class:"border-primary size-10 animate-spin rounded-full border-4 border-t-transparent"})}),I&&/* @__PURE__ */d("div",{class:"absolute inset-0 z-20 flex items-center justify-center bg-white/85",children:/* @__PURE__ */d("div",{class:"flex flex-col items-center gap-3",children:[/* @__PURE__ */d("div",{class:"border-primary size-10 animate-spin rounded-full border-4 border-t-transparent"}),/* @__PURE__ */d("p",{class:"text-sm font-medium text-slate-700",children:"Loading map…"})]})}),
|
|
4
|
+
/* @__PURE__ */d("div",{ref:m,class:"size-full"})]})};export{z as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./YdJqOiJV.js");var r=e.z(()=>Promise.resolve().then(()=>require("./BqkodWNb.js"))),t=e.z(()=>Promise.resolve().then(()=>require("./
|
|
1
|
+
const e=require("./YdJqOiJV.js");var r=e.z(()=>Promise.resolve().then(()=>require("./BqkodWNb.js"))),t=e.z(()=>Promise.resolve().then(()=>require("./DVSPOKgN.js"))),o=e.z(()=>Promise.resolve().then(()=>require("./DoEAn-0B.js"))),l=e.z(()=>Promise.resolve().then(()=>require("./DVXalHm5.js"))),s=()=>e.u("div",{class:"flex h-full items-center justify-center",children:e.u("div",{class:"text-center",children:[e.u("svg",{xmlns:"http://www.w3.org/2000/svg",class:"text-muted-foreground mx-auto mb-3 size-10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5",children:[e.u("path",{d:"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7z"}),e.u("circle",{cx:"12",cy:"9",r:"2.5"})]}),e.u("p",{class:"text-foreground",children:"No location data available."}),e.u("p",{class:"text-muted-foreground mt-1 text-xs",children:"Events need location data to appear on the map."})]})}),i=()=>e.u("div",{class:"flex h-full items-center justify-center",children:e.u("div",{class:"border-primary size-8 animate-spin rounded-full border-4 border-t-transparent"})});exports.default=({events:n,isLoading:a=!1})=>{const{organization:u}=e.useSession(),c=e.useNavigate(),d=u?.integrationSettings??{},p=d.mapProvider??"openstreetmap",m=e.q(r=>{c(e.PAGE_ROUTES.GALLERY(r))},[c]);if("openstreetmap_free"===p)return e.u("div",{class:"relative mt-3 h-screen sm:mt-6",children:e.u(e.P,{fallback:e.u(i,{}),children:e.u(r,{onExplore:m,logoUrl:u?.logoUrl})})});const g=d.mapTilerApiKey??"",h=d.googleMapsApiKey??"",x=d.mapboxApiKey??"",f=n.filter(e=>"number"==typeof e.location?.x&&"number"==typeof e.location?.y);return e.u("div",{class:"relative mt-3 h-screen sm:mt-6",children:a?e.u(i,{}):"openstreetmap"===p&&!g||"google"===p&&!h||"mapbox"===p&&!x?e.u("div",{class:"flex h-full items-center justify-center",children:e.u("div",{class:"text-center",children:[e.u("svg",{xmlns:"http://www.w3.org/2000/svg",class:"text-muted-foreground mx-auto mb-3 size-10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5",children:[e.u("path",{d:"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7z"}),e.u("circle",{cx:"12",cy:"9",r:"2.5"})]}),e.u("p",{class:"text-foreground",children:"API key is required to display the map."}),e.u("p",{class:"text-muted-foreground mt-1 text-xs",children:"Provide a map API key in your organization settings."})]})}):0===f.length?e.u(s,{}):e.u(e.P,{fallback:e.u(i,{}),children:["openstreetmap"===p&&e.u(t,{is3D:!1,apiKey:g,onExplore:m,logoUrl:u?.logoUrl}),"mapbox"===p&&e.u(l,{onExplore:m,apiKey:x,is3D:!1,logoUrl:u?.logoUrl}),"google"===p&&e.u(o,{apiKey:h,onExplore:m,logoUrl:u?.logoUrl})]})})};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{H as e,Ot as t,X as r,Z as o,p as l,u as s,y as i}from"./CybQW90i.js";var n=o(()=>import("./DCXtW9qz.js")),a=o(()=>import("./
|
|
1
|
+
import{H as e,Ot as t,X as r,Z as o,p as l,u as s,y as i}from"./CybQW90i.js";var n=o(()=>import("./DCXtW9qz.js")),a=o(()=>import("./B-2DDVYT.js")),c=o(()=>import("./yv7A6fzU.js")),d=o(()=>import("./jnuTAcnJ.js")),p=()=>/* @__PURE__ */i("div",{class:"flex h-full items-center justify-center",children:/* @__PURE__ */i("div",{class:"text-center",children:[
|
|
2
2
|
/* @__PURE__ */i("svg",{xmlns:"http://www.w3.org/2000/svg",class:"text-muted-foreground mx-auto mb-3 size-10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5",children:[/* @__PURE__ */i("path",{d:"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7z"}),/* @__PURE__ */i("circle",{cx:"12",cy:"9",r:"2.5"})]}),
|
|
3
3
|
/* @__PURE__ */i("p",{class:"text-foreground",children:"No location data available."}),
|
|
4
4
|
/* @__PURE__ */i("p",{class:"text-muted-foreground mt-1 text-xs",children:"Events need location data to appear on the map."})]})}),m=()=>/* @__PURE__ */i("div",{class:"flex h-full items-center justify-center",children:/* @__PURE__ */i("div",{class:"border-primary size-8 animate-spin rounded-full border-4 border-t-transparent"})}),g=({events:o,isLoading:g=!1})=>{const{organization:x}=l(),h=s(),u=x?.integrationSettings??{},f=u.mapProvider??"openstreetmap",v=t(t=>{h(e.GALLERY(t))},[h]);if("openstreetmap_free"===f)/* @__PURE__ */return i("div",{class:"relative mt-3 h-screen sm:mt-6",children:/* @__PURE__ */i(r,{fallback:/* @__PURE__ */i(m,{}),children:/* @__PURE__ */i(n,{onExplore:v,logoUrl:x?.logoUrl})})});const y=u.mapTilerApiKey??"",b=u.googleMapsApiKey??"",w=u.mapboxApiKey??"",j=o.filter(e=>"number"==typeof e.location?.x&&"number"==typeof e.location?.y);/* @__PURE__ */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./CH5eh9L8.js"),t=require("./YdJqOiJV.js"),r=require("./1jCdh7RC.js"),n=require("./CiT4o63a.js");var o={top:60,bottom:60,left:276,right:60},i="#fb8500",s=new r.QueryClient,l=(e,r,o)=>{t.R(t.u(t.QueryClientProvider,{client:s,children:t.u(t.MemoryRouter,{children:t.u(n.EventPreviewCard,{event:e,onExplore:o})})}),r)},c=e=>{const t=document.createElement("div");t.style.cssText=`\n background:${n.safeCssColor(e.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=e.folder.name;const o=document.createElement("span");return o.style.cssText="background:rgba(0,0,0,0.18);border-radius:10px;padding:1px 5px;font-size:10px;",o.textContent=String(e.eventCount),t.appendChild(r),t.appendChild(o),t};exports.default=({apiKey:r,is3D:s,onExplore:a,logoUrl:u})=>{const d=t.A(null),p=t.A(null),m=t.A(null),f=t.A(s),g=t.A([]),y=t.A([]),h=t.A(null),b=t.A(!1),v=t.A(!1),x=t.A(null),[w,E]=t.d(s),C=t.T(()=>(()=>{try{const e=sessionStorage.getItem(t.MAP_STATE_SESSION_STORAGE_PARAM);if(!e)return null;const r=JSON.parse(e);if(Array.isArray(r?.center)&&"number"==typeof r.zoom)return r}catch{}return null})(),[]),[_,L]=t.d(!1),[A,S]=t.d(!0),{folderTree:z,activeFolderId:T,activeFolder:k,visibleEvents:j,setActiveFolderId:F,isLoadingEvents:M}=n.useFolderMap(),{organization:P}=t.useSession(),O=()=>{g.current.forEach(e=>e.remove()),g.current=[]},B=()=>{y.current.forEach(e=>e.remove()),y.current=[]},I=(e,t)=>{const r=t?"visible":"none";for(const n of["heatmap","event-clusters","cluster-count","unclustered-point"])e.getLayer(n)&&e.setLayoutProperty(n,"visibility",r)};return t.y(()=>{if(!d.current||p.current)return;let n,o=!1;return(async()=>{try{const s=(await Promise.resolve().then(()=>e.__toESM(require("./BvVjd_UK.js").default,1))).default;if(o)return;if(!d.current)return;const c=C?.center??[0,20],u=C?.zoom??3,g=new s.Map({container:d.current,style:`https://api.maptiler.com/maps/streets-v2/style.json?key=${r}`,center:c,zoom:u,minZoom:0,pitch:0,bearing:0,renderWorldCopies:!1,projection:f.current?{type:"globe"}:{type:"mercator"},canvasContextAttributes:{antialias:!0}});p.current=g,m.current=s,g.on("load",()=>{if(o)return;const e=g.getStyle()?.layers??[];let t,r;for(const n of e){const e=n;"symbol"===e.type&&e.layout?.["text-field"]&&!t&&(t=n.id),"building"!==e["source-layer"]||r||(r=e.source)}r&&!g.getLayer("3d-buildings")&&g.addLayer({id:"3d-buildings",source:r,"source-layer":"building",filter:["has","render_height"],type:"fill-extrusion",minzoom:2,paint:{"fill-extrusion-color":["interpolate",["linear"],["get","render_height"],0,"lightgray",200,"royalblue",400,"lightblue"],"fill-extrusion-height":["interpolate",["linear"],["zoom"],14,0,15,["get","render_height"]],"fill-extrusion-base":["case",["has","render_min_height"],["get","render_min_height"],0],"fill-extrusion-opacity":.6}},t),g.addSource("all-events",{type:"geojson",data:{type:"FeatureCollection",features:[]},cluster:!0,clusterRadius:50,clusterMaxZoom:14}),g.addSource("heat-events",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),g.addLayer({id:"heatmap",type:"heatmap",source:"heat-events",layout:{visibility:"none"},paint:{"heatmap-weight":["interpolate",["linear"],["get","views"],0,0,200,1],"heatmap-intensity":["interpolate",["linear"],["zoom"],0,1,9,3],"heatmap-color":["interpolate",["linear"],["heatmap-density"],0,"rgba(33,102,172,0)",.2,"rgb(103,169,207)",.4,"rgb(209,229,240)",.6,"rgb(253,219,199)",.8,"rgb(239,138,98)",1,"rgb(178,24,43)"],"heatmap-radius":["interpolate",["linear"],["zoom"],0,4,9,30],"heatmap-opacity":["interpolate",["linear"],["zoom"],6,.85,11,0]}}),g.addLayer({id:"event-clusters",type:"circle",source:"all-events",layout:{visibility:"none"},filter:["has","point_count"],paint:{"circle-color":["step",["get","point_count"],i,10,"#e63946",30,"#9b2226"],"circle-radius":["step",["get","point_count"],16,10,20,30,26],"circle-stroke-width":2,"circle-stroke-color":"#fff"}}),g.addLayer({id:"cluster-count",type:"symbol",source:"all-events",layout:{visibility:"none","text-field":"{point_count_abbreviated}","text-size":12},paint:{"text-color":"#fff"}}),g.addLayer({id:"unclustered-point",type:"circle",source:"all-events",layout:{visibility:"none"},filter:["!",["has","point_count"]],paint:{"circle-radius":7,"circle-color":i,"circle-stroke-color":"#fff","circle-stroke-width":2}}),g.on("click","event-clusters",e=>{const t=g.queryRenderedFeatures(e.point,{layers:["event-clusters"]});if(!t.length)return;const r=t[0].properties?.cluster_id,n=g.getSource("all-events");r&&n?.getClusterExpansionZoom&&n.getClusterExpansionZoom(r,(e,r)=>{e||"number"!=typeof r||g.easeTo({center:t[0].geometry.coordinates,zoom:r,duration:600})})}),g.on("click","unclustered-point",e=>{const t=e.features?.[0];if(!t)return;const r=t.geometry.coordinates.slice(0,2),n=t.properties??{},o={_id:n._id,slug:n.slug,name:n.name,views:n.views,location:{x:r[0],y:r[1],label:n.label},contents:n.thumbnailUrl?[{thumbnailUrl:n.thumbnailUrl}]:[]};x.current&&(x.current.remove(),x.current=null);const i=document.createElement("div");l(o,i,a);const c=new s.Popup({closeButton:!0,closeOnClick:!1,maxWidth:"none",offset:[0,-10]}).setLngLat(r).setDOMContent(i).addTo(g);x.current=c,c.on("close",()=>{x.current===c&&(x.current=null)})}),g.on("click",e=>{!g.queryRenderedFeatures(e.point,{layers:["event-clusters","unclustered-point"]}).length&&x.current&&(x.current.remove(),x.current=null)}),g.on("mouseenter","event-clusters",()=>{g.getCanvas().style.cursor="pointer"}),g.on("mouseleave","event-clusters",()=>{g.getCanvas().style.cursor=""}),g.on("mouseenter","unclustered-point",()=>{g.getCanvas().style.cursor="pointer"}),g.on("mouseleave","unclustered-point",()=>{g.getCanvas().style.cursor=""}),L(!0),S(!1)});const y=()=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{try{const e=g.getCenter();sessionStorage.setItem(t.MAP_STATE_SESSION_STORAGE_PARAM,JSON.stringify({center:[e.lng,e.lat],zoom:g.getZoom()}))}catch{}},250)};g.on("zoomend",y),g.on("moveend",y),n=()=>{O(),B(),h.current&&clearTimeout(h.current),g.off("zoomend",y),g.off("moveend",y),g.remove(),p.current=null,m.current=null}}finally{o||S(!1)}})(),()=>{o=!0,n?.()}},[r]),t.y(()=>{if(!_)return;const e=p.current,t=m.current;if(e&&t)if(O(),B(),null===T&&z.length>0){I(e,!1);const r=n=>{for(const o of n)if(o.centroid){const r=c(o);r.addEventListener("click",()=>F(o.folder._id));const n=new t.Marker({element:r,anchor:"center"}).setLngLat([o.centroid[0],o.centroid[1]]).addTo(e);g.current.push(n)}else o.children.length>0&&r(o.children)};r(z)}else if(0===z.length&&null===T){if(0===j.length)return;const r=j.map(e=>({type:"Feature",geometry:{type:"Point",coordinates:[e.location.x,e.location.y]},properties:{_id:e._id,slug:e.slug,name:e.name,views:e.views??0,label:e.location?.label??"",thumbnailUrl:e.contents?.[0]?.thumbnailUrl??""}})),n={type:"FeatureCollection",features:r};if(e.getSource("all-events")?.setData(n),e.getSource("heat-events")?.setData({...n,features:r.map(e=>({...e,properties:{views:e.properties.views}}))}),I(e,!0),!v.current&&(v.current=!0,!C)){const r=new t.LngLatBounds;j.forEach(e=>r.extend([e.location.x,e.location.y])),r.isEmpty()||e.fitBounds(r,{padding:o,maxZoom:8,duration:800})}}else{if(0===j.length)return;I(e,!1);const r=k?.color||i,o=new t.LngLatBounds;j.forEach(i=>{const s=i.location.x,c=i.location.y;o.extend([s,c]);const d=((e,t)=>{const r=document.createElement("div");if(r.style.cssText=`\n width:36px;height:36px;cursor:pointer;\n background:${e};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 `,t){const e=document.createElement("img");e.src=n.safeImageUrl(t)??"",e.style.cssText="width:24px;height:24px;border-radius:50%;object-fit:cover;transform:rotate(45deg);",r.appendChild(e)}return r})(r,u);d.addEventListener("click",()=>{x.current&&(x.current.remove(),x.current=null);const r=document.createElement("div");l(i,r,a);const n=new t.Popup({closeButton:!0,closeOnClick:!1,maxWidth:"none",offset:[0,-40]}).setLngLat([s,c]).setDOMContent(r).addTo(e);x.current=n,n.on("close",()=>{x.current===n&&(x.current=null)})});const p=new t.Marker({element:d}).setLngLat([s,c]).addTo(e);y.current.push(p)})}},[T,z,j,_,a,u,F,k,C]),t.y(()=>{if(!_)return;const e=p.current;if(!e)return;if(!b.current&&C)return void(b.current=!0);b.current=!0;const t={padding:o,duration:3e3,essential:!0};if(T){const r=n.findNodeById(z,T);if(!r?.folder.boundary?.length)return;const o=m.current;if(!o)return;const i=new o.LngLatBounds;for(const e of r.folder.boundary)i.extend([e.x,e.y]);i.isEmpty()||e.fitBounds(i,{...t,maxZoom:14})}else if(z.length>0){const r=m.current;if(!r)return;const n=new r.LngLatBounds,o=e=>{for(const t of e)t.centroid?n.extend([t.centroid[0],t.centroid[1]]):o(t.children)};o(z),n.isEmpty()||e.fitBounds(n,{...t,maxZoom:8})}},[T,z,_,C]),t.y(()=>{p.current&&(f.current=w,p.current.setProjection(w?{type:"globe"}:{type:"mercator"}),p.current.easeTo({pitch:0,bearing:0,duration:600}))},[w]),t.u("div",{class:"relative h-screen w-full sm:h-[calc(100vh-4rem)]",style:t.getStyleObject(P),children:[t.u(n.FolderTreeSidebar,{positionClass:"absolute top-3 left-16 z-[1000]",folderTree:z,activeFolderId:T,setActiveFolderId:F}),t.u("button",{type:"button",onClick:()=>E(e=>!e),class:"bg-background hover:bg-foreground/10 absolute top-4 right-4 z-[1000] rounded-xl px-3 py-2 text-xs font-semibold shadow-lg backdrop-blur-sm",children:w?"2D":"3D"}),M&&t.u("div",{class:"absolute inset-0 z-10 flex items-center justify-center bg-white/60",children:t.u("div",{class:"border-primary size-10 animate-spin rounded-full border-4 border-t-transparent"})}),A&&t.u("div",{class:"absolute inset-0 z-20 flex items-center justify-center bg-white/85",children:t.u("div",{class:"flex flex-col items-center gap-3",children:[t.u("div",{class:"border-primary size-10 animate-spin rounded-full border-4 border-t-transparent"}),t.u("p",{class:"text-sm font-medium text-slate-700",children:"Loading map…"})]})}),t.u("div",{ref:d,class:"size-full"})]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./CH5eh9L8.js"),t=require("./YdJqOiJV.js"),r=require("./1jCdh7RC.js"),n=require("./CiT4o63a.js");var o={top:60,bottom:60,left:276,right:60},i="#fb8500",s=new r.QueryClient,l=(e,r,o)=>{t.R(t.u(t.QueryClientProvider,{client:s,children:t.u(t.MemoryRouter,{children:t.u(n.EventPreviewCard,{event:e,onExplore:o})})}),r)},c=e=>{const t=document.createElement("div");t.style.cssText=`\n background:${n.safeCssColor(e.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=e.folder.name;const o=document.createElement("span");return o.style.cssText="background:rgba(0,0,0,0.18);border-radius:10px;padding:1px 5px;font-size:10px;",o.textContent=String(e.eventCount),t.appendChild(r),t.appendChild(o),t};exports.default=({apiKey:r,is3D:s,onExplore:a,logoUrl:u})=>{const d=t.A(null),p=t.A(null),m=t.A(null),f=t.A(s),g=t.A([]),y=t.A([]),h=t.A(null),b=t.A(!1),v=t.A(!1),x=t.A(null),[w,E]=t.d(s),C=t.T(()=>(()=>{try{const e=sessionStorage.getItem(t.MAP_STATE_SESSION_STORAGE_PARAM);if(!e)return null;const r=JSON.parse(e);if(Array.isArray(r?.center)&&"number"==typeof r.zoom)return r}catch{}return null})(),[]),[_,L]=t.d(!1),[S,A]=t.d(!0),{folderTree:T,activeFolderId:z,activeFolder:k,visibleEvents:j,setActiveFolderId:F,isLoadingEvents:M}=n.useFolderMap(),{organization:P}=t.useSession(),O=()=>{g.current.forEach(e=>e.remove()),g.current=[]},q=()=>{y.current.forEach(e=>e.remove()),y.current=[]},B=(e,t)=>{const r=t?"visible":"none";for(const n of["heatmap","event-clusters","cluster-count","unclustered-point"])e.getLayer(n)&&e.setLayoutProperty(n,"visibility",r)};return t.y(()=>{if(!d.current||p.current)return;let n,o=!1;return(async()=>{try{const s=(await Promise.resolve().then(()=>e.__toESM(require("./I7IwY3sd.js").default,1))).default;if(o)return;if(!document.querySelector("link[data-qrati-mapbox-css]")){const e=document.createElement("link");e.rel="stylesheet",e.href="https://api.mapbox.com/mapbox-gl-js/v3.20.0/mapbox-gl.css",e.setAttribute("data-qrati-mapbox-css",""),document.head.appendChild(e)}if(!d.current)return;s.accessToken=r;const c=C?.center??[0,20],u=C?.zoom??3,g=new s.Map({container:d.current,style:"mapbox://styles/mapbox/streets-v12",center:c,zoom:u,minZoom:0,pitch:0,bearing:0,renderWorldCopies:!1,antialias:!0,projection:f.current?"globe":"mercator"});p.current=g,m.current=s,g.on("load",()=>{if(o)return;const e=g.getStyle()?.layers??[];let t,r;for(const n of e){const e=n;"symbol"===e.type&&e.layout?.["text-field"]&&!t&&(t=n.id),"building"!==e["source-layer"]||r||(r=e.source)}r&&!g.getLayer("3d-buildings")&&g.addLayer({id:"3d-buildings",source:r,"source-layer":"building",filter:["has","render_height"],type:"fill-extrusion",minzoom:14,paint:{"fill-extrusion-color":["interpolate",["linear"],["get","render_height"],0,"lightgray",200,"royalblue",400,"lightblue"],"fill-extrusion-height":["interpolate",["linear"],["zoom"],14,0,15,["get","render_height"]],"fill-extrusion-base":["case",["has","render_min_height"],["get","render_min_height"],0],"fill-extrusion-opacity":.6}},t),g.addSource("all-events",{type:"geojson",data:{type:"FeatureCollection",features:[]},cluster:!0,clusterRadius:50,clusterMaxZoom:14}),g.addSource("heat-events",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),g.addLayer({id:"heatmap",type:"heatmap",source:"heat-events",layout:{visibility:"none"},paint:{"heatmap-weight":["interpolate",["linear"],["get","views"],0,0,200,1],"heatmap-intensity":["interpolate",["linear"],["zoom"],0,1,9,3],"heatmap-color":["interpolate",["linear"],["heatmap-density"],0,"rgba(33,102,172,0)",.2,"rgb(103,169,207)",.4,"rgb(209,229,240)",.6,"rgb(253,219,199)",.8,"rgb(239,138,98)",1,"rgb(178,24,43)"],"heatmap-radius":["interpolate",["linear"],["zoom"],0,4,9,30],"heatmap-opacity":["interpolate",["linear"],["zoom"],6,.85,11,0]}}),g.addLayer({id:"event-clusters",type:"circle",source:"all-events",layout:{visibility:"none"},filter:["has","point_count"],paint:{"circle-color":["step",["get","point_count"],i,10,"#e63946",30,"#9b2226"],"circle-radius":["step",["get","point_count"],16,10,20,30,26],"circle-stroke-width":2,"circle-stroke-color":"#fff"}}),g.addLayer({id:"cluster-count",type:"symbol",source:"all-events",layout:{visibility:"none","text-field":"{point_count_abbreviated}","text-size":12},paint:{"text-color":"#fff"}}),g.addLayer({id:"unclustered-point",type:"circle",source:"all-events",layout:{visibility:"none"},filter:["!",["has","point_count"]],paint:{"circle-radius":7,"circle-color":i,"circle-stroke-color":"#fff","circle-stroke-width":2}}),g.on("click","event-clusters",e=>{const t=g.queryRenderedFeatures(e.point,{layers:["event-clusters"]});if(!t.length)return;const r=t[0].properties?.cluster_id,n=g.getSource("all-events");r&&n?.getClusterExpansionZoom&&n.getClusterExpansionZoom(r,(e,r)=>{e||"number"!=typeof r||g.easeTo({center:t[0].geometry.coordinates,zoom:r,duration:600})})}),g.on("click","unclustered-point",e=>{const t=e.features?.[0];if(!t)return;const r=t.geometry.coordinates.slice(0,2),n=t.properties??{},o={_id:n._id,slug:n.slug,name:n.name,views:n.views,location:{x:r[0],y:r[1],label:n.label},contents:n.thumbnailUrl?[{thumbnailUrl:n.thumbnailUrl}]:[]};x.current&&(x.current.remove(),x.current=null);const i=document.createElement("div");l(o,i,a);const c=new s.Popup({closeButton:!0,closeOnClick:!1,maxWidth:"none",offset:[0,-10]}).setLngLat(r).setDOMContent(i).addTo(g);x.current=c,c.on("close",()=>{x.current===c&&(x.current=null)})}),g.on("click",e=>{!g.queryRenderedFeatures(e.point,{layers:["event-clusters","unclustered-point"]}).length&&x.current&&(x.current.remove(),x.current=null)}),g.on("mouseenter","event-clusters",()=>{g.getCanvas().style.cursor="pointer"}),g.on("mouseleave","event-clusters",()=>{g.getCanvas().style.cursor=""}),g.on("mouseenter","unclustered-point",()=>{g.getCanvas().style.cursor="pointer"}),g.on("mouseleave","unclustered-point",()=>{g.getCanvas().style.cursor=""}),L(!0),A(!1)});const y=()=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{try{const e=g.getCenter();sessionStorage.setItem(t.MAP_STATE_SESSION_STORAGE_PARAM,JSON.stringify({center:[e.lng,e.lat],zoom:g.getZoom()}))}catch{}},250)};g.on("zoomend",y),g.on("moveend",y),n=()=>{O(),q(),x.current&&(x.current.remove(),x.current=null),h.current&&clearTimeout(h.current),g.off("zoomend",y),g.off("moveend",y),g.remove(),p.current=null,m.current=null}}finally{o||A(!1)}})(),()=>{o=!0,n?.()}},[r]),t.y(()=>{if(!_)return;const e=p.current,t=m.current;if(e&&t)if(O(),q(),null===z&&T.length>0){B(e,!1);const r=n=>{for(const o of n)if(o.centroid){const r=c(o);r.addEventListener("click",()=>F(o.folder._id));const n=new t.Marker({element:r,anchor:"center"}).setLngLat([o.centroid[0],o.centroid[1]]).addTo(e);g.current.push(n)}else o.children.length>0&&r(o.children)};r(T)}else if(0===T.length&&null===z){if(0===j.length)return;const r=j.map(e=>({type:"Feature",geometry:{type:"Point",coordinates:[e.location.x,e.location.y]},properties:{_id:e._id,slug:e.slug,name:e.name,views:e.views??0,label:e.location?.label??"",thumbnailUrl:e.contents?.[0]?.thumbnailUrl??""}})),n={type:"FeatureCollection",features:r};if(e.getSource("all-events")?.setData(n),e.getSource("heat-events")?.setData({...n,features:r.map(e=>({...e,properties:{views:e.properties.views}}))}),B(e,!0),!v.current&&(v.current=!0,!C)){const r=new t.LngLatBounds;j.forEach(e=>r.extend([e.location.x,e.location.y])),r.isEmpty()||e.fitBounds(r,{padding:o,maxZoom:8,duration:800})}}else{if(0===j.length)return;B(e,!1);const r=k?.color||i,o=new t.LngLatBounds;j.forEach(i=>{const s=i.location.x,c=i.location.y;o.extend([s,c]);const d=((e,t)=>{const r=document.createElement("div");if(r.style.cssText=`\n width:36px;height:36px;cursor:pointer;\n background:${e};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 `,t){const e=document.createElement("img");e.src=n.safeImageUrl(t)??"",e.style.cssText="width:24px;height:24px;border-radius:50%;object-fit:cover;transform:rotate(45deg);",r.appendChild(e)}return r})(r,u);d.addEventListener("click",()=>{x.current&&(x.current.remove(),x.current=null);const r=document.createElement("div");l(i,r,a);const n=new t.Popup({closeButton:!0,closeOnClick:!1,maxWidth:"none",offset:[0,-40]}).setLngLat([s,c]).setDOMContent(r).addTo(e);x.current=n,n.on("close",()=>{x.current===n&&(x.current=null)})});const p=new t.Marker({element:d}).setLngLat([s,c]).addTo(e);y.current.push(p)})}},[z,T,j,_,a,u,F,k,C]),t.y(()=>{if(!_)return;const e=p.current;if(!e)return;if(!b.current&&C)return void(b.current=!0);b.current=!0;const t={padding:o,duration:3e3,essential:!0},r=m.current;if(r)if(z){const o=n.findNodeById(T,z);if(!o?.folder.boundary?.length)return;const i=new r.LngLatBounds;for(const e of o.folder.boundary)i.extend([e.x,e.y]);i.isEmpty()||e.fitBounds(i,{...t,maxZoom:14})}else if(T.length>0){const n=new r.LngLatBounds,o=e=>{for(const t of e)t.centroid?n.extend([t.centroid[0],t.centroid[1]]):o(t.children)};o(T),n.isEmpty()||e.fitBounds(n,{...t,maxZoom:8})}},[z,T,_,C]),t.y(()=>{p.current&&(f.current=w,p.current.setProjection(w?"globe":"mercator"),p.current.easeTo({pitch:0,bearing:0,duration:600}))},[w]),t.u("div",{class:"relative h-screen w-full sm:h-[calc(100vh-4rem)]",style:t.getStyleObject(P),children:[t.u(n.FolderTreeSidebar,{positionClass:"absolute top-3 left-16 z-[1000]",folderTree:T,activeFolderId:z,setActiveFolderId:F}),t.u("button",{type:"button",onClick:()=>E(e=>!e),class:"bg-background hover:bg-foreground/10 absolute top-4 right-4 z-[1000] rounded-xl px-3 py-2 text-xs font-semibold shadow-lg backdrop-blur-sm",children:w?"2D":"3D"}),M&&t.u("div",{class:"absolute inset-0 z-10 flex items-center justify-center bg-white/60",children:t.u("div",{class:"border-primary size-10 animate-spin rounded-full border-4 border-t-transparent"})}),S&&t.u("div",{class:"absolute inset-0 z-20 flex items-center justify-center bg-white/85",children:t.u("div",{class:"flex flex-col items-center gap-3",children:[t.u("div",{class:"border-primary size-10 animate-spin rounded-full border-4 border-t-transparent"}),t.u("p",{class:"text-sm font-medium text-slate-700",children:"Loading map…"})]})}),t.u("div",{ref:d,class:"size-full"})]})};
|
|
1
|
+
const e=require("./CH5eh9L8.js"),t=require("./YdJqOiJV.js"),r=require("./1jCdh7RC.js"),n=require("./CiT4o63a.js");var o={top:60,bottom:60,left:276,right:60},i="#fb8500",s=new r.QueryClient,l=(e,r,o)=>{t.R(t.u(t.QueryClientProvider,{client:s,children:t.u(t.MemoryRouter,{children:t.u(n.EventPreviewCard,{event:e,onExplore:o})})}),r)},c=e=>{const t=document.createElement("div");t.style.cssText=`\n background:${n.safeCssColor(e.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=e.folder.name;const o=document.createElement("span");return o.style.cssText="background:rgba(0,0,0,0.18);border-radius:10px;padding:1px 5px;font-size:10px;",o.textContent=String(e.eventCount),t.appendChild(r),t.appendChild(o),t};exports.default=({apiKey:r,is3D:s,onExplore:a,logoUrl:u})=>{const d=t.A(null),p=t.A(null),m=t.A(null),f=t.A(s),g=t.A([]),y=t.A([]),h=t.A(null),b=t.A(!1),v=t.A(!1),x=t.A(null),[w,E]=t.d(s),_=t.T(()=>(()=>{try{const e=sessionStorage.getItem(t.MAP_STATE_SESSION_STORAGE_PARAM);if(!e)return null;const r=JSON.parse(e);if(Array.isArray(r?.center)&&"number"==typeof r.zoom)return r}catch{}return null})(),[]),[C,L]=t.d(!1),[S,A]=t.d(!0),{folderTree:T,activeFolderId:z,activeFolder:k,visibleEvents:j,setActiveFolderId:F,isLoadingEvents:M}=n.useFolderMap(),{organization:P}=t.useSession(),O=()=>{g.current.forEach(e=>e.remove()),g.current=[]},B=()=>{y.current.forEach(e=>e.remove()),y.current=[]},I=(e,t)=>{const r=t?"visible":"none";for(const n of["heatmap","event-clusters","cluster-count","unclustered-point"])e.getLayer(n)&&e.setLayoutProperty(n,"visibility",r)};return t.y(()=>{if(!d.current||p.current)return;let n,o=!1;return(async()=>{try{const s=(await Promise.resolve().then(()=>e.__toESM(require("./I7IwY3sd.js").default,1))).default;if(o)return;if(!d.current)return;s.accessToken=r;const c=_?.center??[0,20],u=_?.zoom??3,g=new s.Map({container:d.current,style:"mapbox://styles/mapbox/streets-v12",center:c,zoom:u,minZoom:0,pitch:0,bearing:0,renderWorldCopies:!1,antialias:!0,projection:f.current?"globe":"mercator"});p.current=g,m.current=s,g.on("load",()=>{if(o)return;const e=g.getStyle()?.layers??[];let t,r;for(const n of e){const e=n;"symbol"===e.type&&e.layout?.["text-field"]&&!t&&(t=n.id),"building"!==e["source-layer"]||r||(r=e.source)}r&&!g.getLayer("3d-buildings")&&g.addLayer({id:"3d-buildings",source:r,"source-layer":"building",filter:["has","render_height"],type:"fill-extrusion",minzoom:14,paint:{"fill-extrusion-color":["interpolate",["linear"],["get","render_height"],0,"lightgray",200,"royalblue",400,"lightblue"],"fill-extrusion-height":["interpolate",["linear"],["zoom"],14,0,15,["get","render_height"]],"fill-extrusion-base":["case",["has","render_min_height"],["get","render_min_height"],0],"fill-extrusion-opacity":.6}},t),g.addSource("all-events",{type:"geojson",data:{type:"FeatureCollection",features:[]},cluster:!0,clusterRadius:50,clusterMaxZoom:14}),g.addSource("heat-events",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),g.addLayer({id:"heatmap",type:"heatmap",source:"heat-events",layout:{visibility:"none"},paint:{"heatmap-weight":["interpolate",["linear"],["get","views"],0,0,200,1],"heatmap-intensity":["interpolate",["linear"],["zoom"],0,1,9,3],"heatmap-color":["interpolate",["linear"],["heatmap-density"],0,"rgba(33,102,172,0)",.2,"rgb(103,169,207)",.4,"rgb(209,229,240)",.6,"rgb(253,219,199)",.8,"rgb(239,138,98)",1,"rgb(178,24,43)"],"heatmap-radius":["interpolate",["linear"],["zoom"],0,4,9,30],"heatmap-opacity":["interpolate",["linear"],["zoom"],6,.85,11,0]}}),g.addLayer({id:"event-clusters",type:"circle",source:"all-events",layout:{visibility:"none"},filter:["has","point_count"],paint:{"circle-color":["step",["get","point_count"],i,10,"#e63946",30,"#9b2226"],"circle-radius":["step",["get","point_count"],16,10,20,30,26],"circle-stroke-width":2,"circle-stroke-color":"#fff"}}),g.addLayer({id:"cluster-count",type:"symbol",source:"all-events",layout:{visibility:"none","text-field":"{point_count_abbreviated}","text-size":12},paint:{"text-color":"#fff"}}),g.addLayer({id:"unclustered-point",type:"circle",source:"all-events",layout:{visibility:"none"},filter:["!",["has","point_count"]],paint:{"circle-radius":7,"circle-color":i,"circle-stroke-color":"#fff","circle-stroke-width":2}}),g.on("click","event-clusters",e=>{const t=g.queryRenderedFeatures(e.point,{layers:["event-clusters"]});if(!t.length)return;const r=t[0].properties?.cluster_id,n=g.getSource("all-events");r&&n?.getClusterExpansionZoom&&n.getClusterExpansionZoom(r,(e,r)=>{e||"number"!=typeof r||g.easeTo({center:t[0].geometry.coordinates,zoom:r,duration:600})})}),g.on("click","unclustered-point",e=>{const t=e.features?.[0];if(!t)return;const r=t.geometry.coordinates.slice(0,2),n=t.properties??{},o={_id:n._id,slug:n.slug,name:n.name,views:n.views,location:{x:r[0],y:r[1],label:n.label},contents:n.thumbnailUrl?[{thumbnailUrl:n.thumbnailUrl}]:[]};x.current&&(x.current.remove(),x.current=null);const i=document.createElement("div");l(o,i,a);const c=new s.Popup({closeButton:!0,closeOnClick:!1,maxWidth:"none",offset:[0,-10]}).setLngLat(r).setDOMContent(i).addTo(g);x.current=c,c.on("close",()=>{x.current===c&&(x.current=null)})}),g.on("click",e=>{!g.queryRenderedFeatures(e.point,{layers:["event-clusters","unclustered-point"]}).length&&x.current&&(x.current.remove(),x.current=null)}),g.on("mouseenter","event-clusters",()=>{g.getCanvas().style.cursor="pointer"}),g.on("mouseleave","event-clusters",()=>{g.getCanvas().style.cursor=""}),g.on("mouseenter","unclustered-point",()=>{g.getCanvas().style.cursor="pointer"}),g.on("mouseleave","unclustered-point",()=>{g.getCanvas().style.cursor=""}),L(!0),A(!1)});const y=()=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{try{const e=g.getCenter();sessionStorage.setItem(t.MAP_STATE_SESSION_STORAGE_PARAM,JSON.stringify({center:[e.lng,e.lat],zoom:g.getZoom()}))}catch{}},250)};g.on("zoomend",y),g.on("moveend",y),n=()=>{O(),B(),x.current&&(x.current.remove(),x.current=null),h.current&&clearTimeout(h.current),g.off("zoomend",y),g.off("moveend",y),g.remove(),p.current=null,m.current=null}}finally{o||A(!1)}})(),()=>{o=!0,n?.()}},[r]),t.y(()=>{if(!C)return;const e=p.current,t=m.current;if(e&&t)if(O(),B(),null===z&&T.length>0){I(e,!1);const r=n=>{for(const o of n)if(o.centroid){const r=c(o);r.addEventListener("click",()=>F(o.folder._id));const n=new t.Marker({element:r,anchor:"center"}).setLngLat([o.centroid[0],o.centroid[1]]).addTo(e);g.current.push(n)}else o.children.length>0&&r(o.children)};r(T)}else if(0===T.length&&null===z){if(0===j.length)return;const r=j.map(e=>({type:"Feature",geometry:{type:"Point",coordinates:[e.location.x,e.location.y]},properties:{_id:e._id,slug:e.slug,name:e.name,views:e.views??0,label:e.location?.label??"",thumbnailUrl:e.contents?.[0]?.thumbnailUrl??""}})),n={type:"FeatureCollection",features:r};if(e.getSource("all-events")?.setData(n),e.getSource("heat-events")?.setData({...n,features:r.map(e=>({...e,properties:{views:e.properties.views}}))}),I(e,!0),!v.current&&(v.current=!0,!_)){const r=new t.LngLatBounds;j.forEach(e=>r.extend([e.location.x,e.location.y])),r.isEmpty()||e.fitBounds(r,{padding:o,maxZoom:8,duration:800})}}else{if(0===j.length)return;I(e,!1);const r=k?.color||i,o=new t.LngLatBounds;j.forEach(i=>{const s=i.location.x,c=i.location.y;o.extend([s,c]);const d=((e,t)=>{const r=document.createElement("div");if(r.style.cssText=`\n width:36px;height:36px;cursor:pointer;\n background:${e};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 `,t){const e=document.createElement("img");e.src=n.safeImageUrl(t)??"",e.style.cssText="width:24px;height:24px;border-radius:50%;object-fit:cover;transform:rotate(45deg);",r.appendChild(e)}return r})(r,u);d.addEventListener("click",()=>{x.current&&(x.current.remove(),x.current=null);const r=document.createElement("div");l(i,r,a);const n=new t.Popup({closeButton:!0,closeOnClick:!1,maxWidth:"none",offset:[0,-40]}).setLngLat([s,c]).setDOMContent(r).addTo(e);x.current=n,n.on("close",()=>{x.current===n&&(x.current=null)})});const p=new t.Marker({element:d}).setLngLat([s,c]).addTo(e);y.current.push(p)})}},[z,T,j,C,a,u,F,k,_]),t.y(()=>{if(!C)return;const e=p.current;if(!e)return;if(!b.current&&_)return void(b.current=!0);b.current=!0;const t={padding:o,duration:3e3,essential:!0},r=m.current;if(r)if(z){const o=n.findNodeById(T,z);if(!o?.folder.boundary?.length)return;const i=new r.LngLatBounds;for(const e of o.folder.boundary)i.extend([e.x,e.y]);i.isEmpty()||e.fitBounds(i,{...t,maxZoom:14})}else if(T.length>0){const n=new r.LngLatBounds,o=e=>{for(const t of e)t.centroid?n.extend([t.centroid[0],t.centroid[1]]):o(t.children)};o(T),n.isEmpty()||e.fitBounds(n,{...t,maxZoom:8})}},[z,T,C,_]),t.y(()=>{p.current&&(f.current=w,p.current.setProjection(w?"globe":"mercator"),p.current.easeTo({pitch:0,bearing:0,duration:600}))},[w]),t.u("div",{class:"relative h-screen w-full sm:h-[calc(100vh-4rem)]",style:t.getStyleObject(P),children:[t.u(n.FolderTreeSidebar,{positionClass:"absolute top-3 left-16 z-[1000]",folderTree:T,activeFolderId:z,setActiveFolderId:F}),t.u("button",{type:"button",onClick:()=>E(e=>!e),class:"bg-background hover:bg-foreground/10 absolute top-4 right-4 z-[1000] rounded-xl px-3 py-2 text-xs font-semibold shadow-lg backdrop-blur-sm",children:w?"2D":"3D"}),M&&t.u("div",{class:"absolute inset-0 z-10 flex items-center justify-center bg-white/60",children:t.u("div",{class:"border-primary size-10 animate-spin rounded-full border-4 border-t-transparent"})}),S&&t.u("div",{class:"absolute inset-0 z-20 flex items-center justify-center bg-white/85",children:t.u("div",{class:"flex flex-col items-center gap-3",children:[t.u("div",{class:"border-primary size-10 animate-spin rounded-full border-4 border-t-transparent"}),t.u("p",{class:"text-sm font-medium text-slate-700",children:"Loading map…"})]})}),t.u("div",{ref:d,class:"size-full"})]})};
|