1import{C as me,j as t,b as ve,d as be,g as ye,f as we,S as ke,M as je,D as Ne,T as Ce,a as Se,G as Re,c as Le}from"./index-BaBmYp2h.js";import{r as a}from"./react-ClG9dB6U.js";import{m as q}from"./mapbox-Cop9OUBP.js";const G=300,Me=340,B=10,P=8;function Ee(e,c,g){if(!c)return{style:{left:e.x,top:e.y-B,transform:"translate(-50%, -100%)"},arrowDir:"down",arrowOffset:0};const s=g??Me,h=e.y-s-B>=P,l=e.y+B+s<=c.height-P;if(!h&&!l){const o=e.x+B+G<=c.width-P?"right":"left",i=o==="right"?e.x+B:e.x-B-G;let m=e.y-s/2;return m=Math.max(P,Math.min(m,c.height-P-s)),{style:{left:i,top:m},arrowDir:o==="right"?"left":"right",arrowOffset:e.y-m-s/2}}const n=!h,f=n?e.y+B:e.y-B,d=n?"0%":"-100%";let u=e.x;return e.x-G/2<P?u=P+G/2:e.x+G/2>c.width-P&&(u=c.width-P-G/2),{style:{left:u,top:f,transform:`translate(-50%, ${d})`},arrowDir:n?"up":"down",arrowOffset:e.x-u}}function ce({event:e,onClose:c,tagColorMap:g={},anchorPos:s,containerSize:h,mode:l="click",isInterested:n,onToggleInterest:f}){const d=a.useRef(null),u=a.useRef(null),[x,o]=a.useState(!1),[i,m]=a.useState(0),[A,w]=a.useState(),k=window.innerWidth<640,S=l==="hover";a.useEffect(()=>{if(S)return;function j(_){_.key==="Escape"&&c()}function T(_){d.current&&!d.current.contains(_.target)&&c()}return document.addEventListener("keydown",j),document.addEventListener("pointerdown",T),()=>{document.removeEventListener("keydown",j),document.removeEventListener("pointerdown",T)}},[c,S]),a.useEffect(()=>{function j(T){var _;(_=u.current)!=null&&_.contains(T.target)||o(!1)}return x&&document.addEventListener("pointerdown",j),()=>{document.removeEventListener("pointerdown",j)}},[x]),a.useEffect(()=>{o(!1),m(0),w(void 0)},[e.id]),a.useLayoutEffect(()=>{if(k||!d.current)return;const j=d.current.offsetHeight;j!==A&&w(j);const T=d.current.offsetTop;T<P?m(P-T):m(0)},[s,e.id,k,A]);function z(){if(k||!d.current)return;w(d.current.offsetHeight);const j=d.current.offsetTop;j<P&&m(P-j)}const $=e.costAmount?`$${e.costAmount}`:me[e.costType]??e.costType,R=k?"absolute bottom-0 left-0 right-0 rounded-t-2xl bg-white dark:bg-[#1a1328] shadow-2xl shadow-violet-500/5 ring-1 ring-violet-200/50 dark:ring-violet-500/15 dark:shadow-violet-900/30 max-h-[62dvh] flex flex-col animate-slide-up":"absolute rounded-xl bg-white dark:bg-[#1a1328] shadow-2xl shadow-violet-500/5 ring-1 ring-violet-200/50 dark:ring-violet-500/15 dark:shadow-violet-900/30 w-[300px] max-h-[50vh] flex flex-col",{style:O,arrowDir:M,arrowOffset:H}=k?{style:void 0,arrowDir:"down",arrowOffset:0}:Ee(s,h??null,A),W=O&&i>0?{...O,top:(O.top||0)+i}:O,U=S?"absolute inset-0 z-[9998] pointer-events-none":`absolute inset-0 z-[9999] bg-black/10${k?"":" touch-none"}`;return t.jsx("div",{className:U,children:t.jsxs("div",{ref:d,className:`${R}${S?" pointer-events-auto":""}`,style:W,children:[!S&&t.jsx("button",{onClick:c,"aria-label":"Close",className:`absolute top-2 right-2 z-10 shrink-0 size-9 flex items-center justify-center rounded-full transition-colors ${e.imageUrl?"bg-black/50 hover:bg-black/60 active:bg-black/70 text-white backdrop-blur-sm":"bg-gray-200 hover:bg-gray-300 active:bg-gray-400 dark:bg-white/15 dark:hover:bg-white/25 dark:active:bg-white/30 text-gray-600 hover:text-gray-800 dark:text-gray-300 dark:hover:text-gray-100"}`,children:t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:t.jsx("path",{d:"M3 3l10 10M13 3L3 13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})}),e.imageUrl&&t.jsx("img",{src:e.imageUrl,alt:e.title,onLoad:z,className:"w-full rounded-t-2xl sm:rounded-t-xl object-cover h-28 shrink-0 bg-gray-50 dark:bg-surface-900"}),t.jsx("div",{className:"flex-1 overflow-y-auto overscroll-contain touch-auto min-h-0",children:t.jsxs("div",{className:"p-3 space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("h2",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 leading-snug flex-1",children:e.title}),!S&&t.jsxs("div",{ref:u,className:"relative shrink-0",children:[t.jsx("button",{onClick:()=>o(j=>!j),"aria-label":"Add to calendar",className:"size-8 rounded-full flex items-center justify-center border border-violet-300 bg-vi
1olet-50 text-violet-500 hover:bg-violet-100 hover:text-violet-600 hover:border-violet-400 dark:border-violet-500/30 dark:bg-violet-500/10 dark:text-violet-400 dark:hover:bg-violet-500/20 dark:hover:text-violet-300 transition-colors",children:t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),x&&t.jsxs("div",{className:"absolute top-full right-0 mt-1 w-52 rounded-md border border-gray-200 bg-white shadow-lg z-10 overflow-hidden dark:border-[#2d2540] dark:bg-surface-800",children:[t.jsxs("button",{onClick:()=>{window.open(ve(e),"_blank","noopener"),o(!1)},className:"w-full flex items-center gap-3 px-3 py-2.5 text-left text-xs text-gray-700 hover:bg-gray-50 dark:text-gray-300 dark:hover:bg-violet-500/10",children:[t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",fill:"#4285F4"}),t.jsx("rect",{x:"3",y:"3",width:"18",height:"5",rx:"1",fill:"#1a73e8"}),t.jsx("text",{x:"12",y:"17",textAnchor:"middle",fontSize:"9",fontWeight:"bold",fill:"white",fontFamily:"sans-serif",children:"G"})]}),"Google Calendar"]}),t.jsxs("button",{onClick:()=>{be(e.id,`${e.title.replace(/[^a-z0-9]+/gi,"-").toLowerCase()}.ics`),o(!1)},className:"w-full flex items-center gap-3 px-3 py-2.5 text-left text-xs text-gray-700 hover:bg-gray-50 border-t border-gray-100 dark:text-gray-300 dark:hover:bg-violet-500/10 dark:border-[#2d2540]",children:[t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5 shrink-0 text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),"Apple / Outlook / Other (.ics)"]})]})]})]}),e.tags.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:e.tags.map(j=>t.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${ye(g[j])}`,children:j},j))}),t.jsxs("dl",{className:"space-y-1 text-xs",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-16 shrink-0 text-gray-500 dark:text-violet-300/60",children:"Date"}),t.jsx("dd",{className:"text-gray-800 dark:text-gray-200",children:new Date(e.startTime).toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"})})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-16 shrink-0 text-gray-500 dark:text-violet-300/60",children:"Time"}),t.jsx("dd",{className:"text-gray-800 dark:text-gray-200",children:we(e.startTime,e.endTime)})]}),e.venueName&&t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-16 shrink-0 text-gray-500 dark:text-violet-300/60",children:"Venue"}),t.jsx("dd",{className:"text-gray-800 dark:text-gray-200",children:e.venueLat&&e.venueLng?t.jsx("a",{href:`https://www.google.com/maps?q=${e.venueLat},${e.venueLng}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline dark:text-blue-400",children:e.venueName}):e.venueName})]}),e.costType!=="unknown"&&t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-16 shrink-0 text-gray-500 dark:text-violet-300/60",children:"Cost"}),t.jsx("dd",{className:"text-gray-800 dark:text-gray-200",children:$})]})]}),!S&&e.description&&t.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 leading-relaxed line-clamp-4 whitespace-pre-line",children:e.description})]})}),!S&&t.jsxs("div",{className:`shrink-0 border-t border-violet-100 dark:border-[#2d2540] p-3 space-y-1.5${k?" pb-[max(0.75rem,env(safe-area-inset-bottom))]":""}`,children:[f&&t.jsxs("button",{onClick:()=>f(e.id),className:`w-full flex items-center justify-center gap-1.5 rounded-md border px-3 py-1.5 text-xs font-medium transition-colors ${n?"border-blue-200 bg-blue-50 text-blue-600 hover:bg-blue-100 dar
1k:border-blue-500/30 dark:bg-blue-500/10 dark:text-blue-400 dark:hover:bg-blue-500/20":"border-violet-200/60 text-gray-700 hover:bg-violet-50/50 hover:border-violet-300 dark:border-[#2d2540] dark:text-gray-300 dark:hover:bg-violet-500/10 dark:hover:border-violet-500/30"}`,children:[t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5 shrink-0",viewBox:"0 0 24 24",fill:n?"currentColor":"none",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})}),"Interested"]}),t.jsxs("div",{className:"flex gap-1.5",children:[t.jsx(ke,{event:e}),e.sourceUrl&&t.jsx("a",{href:e.sourceUrl,target:"_blank",rel:"noopener noreferrer",className:"flex flex-1 items-center justify-center gap-1.5 rounded-md bg-gradient-to-r from-violet-600 to-purple-500 px-3 py-1.5 text-xs font-medium text-white hover:from-violet-500 hover:to-purple-400 shadow-lg shadow-violet-600/25",children:"View event page â"})]})]}),!k&&M==="down"&&t.jsx("div",{className:"absolute -bottom-[6px] w-3 h-[7px] bg-white dark:bg-[#1a1328]",style:{left:`calc(50% + ${H}px)`,transform:"translateX(-50%)",clipPath:"polygon(0% 0%, 50% 100%, 100% 0%)"}}),!k&&M==="up"&&t.jsx("div",{className:"absolute -top-[6px] w-3 h-[7px] bg-white dark:bg-[#1a1328]",style:{left:`calc(50% + ${H}px)`,transform:"translateX(-50%)",clipPath:"polygon(0% 100%, 50% 0%, 100% 100%)"}}),!k&&M==="left"&&t.jsx("div",{className:"absolute -left-[6px] w-[7px] h-3 bg-white dark:bg-[#1a1328]",style:{to
1p:`calc(50% + ${H}px)`,transform:"translateY(-50%)",clipPath:"polygon(100% 0%, 0% 50%, 100% 100%)"}}),!k&&M==="right"&&t.jsx("div",{className:"absolute -right-[6px] w-[7px] h-3 bg-white dark:bg-[#1a1328]",style:{top:`calc(50% + ${H}px)`,transform:"translateY(-50%)",clipPath:"polygon(0% 0%, 100% 50%, 0% 100%)"}})]})})}q.accessToken="pk.eyJ1IjoiandlZzI5IiwiYSI6ImNtbmQwMWxkZjBhdnoyb29scWNvNGt6aHIifQ.KRUA73JZ2y2Rfb7GggG4yg";const ue=[-74.0059,40.7128],de=11,X={latMin:40.4774,latMax:40.9176,lngMin:-74.2591,lngMax:-73.7004},Q=40,Pe=12,he={type:"FeatureCollection",features:[]};function Te(e,c){return e>=X.latMin&&e<=X.latMax&&c>=X.lngMin&&c<=X.lngMax}function De(e,c,g,s){const h=document.createElement("canvas"),l=window.devicePixelRatio||1;h.width=e*l,h.height=e*l;const n=h.getContext("2d");n.scale(l,l);const f=e/2,d=e/2,u=e/2-s,x=u*.4,o=5;n.beginPath();for(let i=0;i<o*2;i++){const m=Math.PI*i/o-Math.PI/2,A=i%2===0?u:x,w=f+A*Math.cos(m),k=d+A*Math.sin(m);i===0?n.moveTo(w,k):n.lineTo(w,k)}return n.closePath(),n.fillStyle=c,n.fill(),n.strokeStyle=g,n.lineWidth=s,n.stroke(),n.getImageData(0,0,h.width,h.height)}function ee(e,c){const g=new Map;for(const s of e){if(s.venueLat==null||s.venueLng==null)continue;const h=parseFloat(s.venueLat),l=parseFloat(s.venueLng);if(isNaN(h)||isNaN(l))continue;const n=`${h},${l}`,f=g.get(n);f?f.ids.push(s.id):g.set(n,{lat:h,lng:l,ids:[s.id]})}return{type:"FeatureCollection",features:Array.from(g.values()).map(({lat:s,lng:h,ids:l})=>({type:"Feature",geometry:{type:"Point",coordinates:[h,s]},properties:{eventIds:JSON.stringify(l),eventCount:l.length,hasInterested:l.length===1&&!!(c!=null&&c.has(l[0]))}}))}}function fe(e,c,g,s){const h=g.project(e),l=c.length,n=[];for(let f=0;f<l;f++){let d;if(l<=10){const o=2*Math.PI*f/l-Math.PI/2;d={x:h.x+Q*Math.cos(o),y:h.y+Q*Math.sin(o)}}else{const o=f*.6,i=Q+Pe*o;d={x:h.x+i*Math.cos(o),y:h.y+i*Math.sin(o)}}const u=g.unproject([d.x,d.y]),x=[u.lng,u.lat];n.push({type:"Feature",geometry:{type:"Point",coordinates:x},properties:{eventId:c[f],isInterested:!!(s!=null&&s.has(c[f]))}}),n.push({type:"Feature",geometry:{type:"LineString",coordinates:[e,x]},properties:{}})}return{type:"FeatureCollection",features:n}}function Ae({events:e,tagColorMap:c,loading:g,interestedIds:s,onToggleInterest:h}){const l=a.useRef(null),n=a.useRef(null),f=a.useRef(e),d=a.useRef(s),u=a.useRef(!1),[x,o]=a.useState(null),[i,m]=a.useState(null),[A,w]=a.useState(null),[k,S]=a.useState(null),[z,$]=a.useState(null),R=a.useRef(null),[O,M]=a.useState(!!g),[H,W]=a.useState(!1),U=a.useRef(!1),j=a.useRef(null),T=a.useRef(null),_=a.useRef(null),Y=a.useRef(()=>{}),te=a.useRef(()=>{});a.useEffect(()=>{if(g)M(!0),W(!1);else if(O){W(!0);const p=setTimeout(()=>M(!1),500);return()=>clearTimeout(p)}},[g]),f.current=e,d.current=s;function J(){S(null),$(null),R.current&&(clearTimeout(R.current),R.current=null)}function re(p){var D,E,C;const v=(D=p.features)==null?void 0:D[0];if(!v)return;const r=(E=v.properties)==null?void 0:E.eventIds,L=JSON.parse(r),b=v.geometry.coordinates;if(L.length===1){Y.current();const F=f.current.find(N=>N.id===L[0]);if(F){J(),o(F),m({x:p.point.x,y:p.point.y});const N=(C=l.current)==null?void 0:C.getBoundingClientRect();N&&w({width:N.width,height:N.height})}}else J(),o(null),m(null),Y.current(),te.current(b,r,L)}function oe(p){var b,D,E;const v=(b=p.features)==null?void 0:b[0];if(!v)return;const r=(D=v.properties)==null?void 0:D.eventId,L=f.current.find(C=>C.id===r);if(L){J(),o(L),m({x:p.point.x,y:p.point.y});const C=(E=l.current)==null?void 0:E.getBoundingClientRect();C&&w({width:C.width,height:C.height})}}function ne(p){var D,E,C,F;R.current&&(clearTimeout(R.current),R.current=null);const v=(D=p.features)==null?void 0:D[0];if(!v||((E=v.properties)==null?void 0:E.eventCount)>1)return;const L=JSON.parse((C=v.properties)==null?void 0:C.eventIds),b=f.current.find(N=>N.id===L[0]);if(b){S(b),$({x:p.point.x,y:p.point.y});const N=(F=l.current)==null?void 0:F.getBoundingClientRect();N&&w({width:N.width,height:N.height})}}function se(p){var b,D,E;R.current&&(clearTimeout(R.current),R.current=null);const v=(b=p.features)==null?void 0:b[0];if(!v)return;const r=(D=v.properties)==null?void 0:D.eventId,L=f.current.find(C=>C.id===r);if(L){S(L),$({x:p.point.x,y:p.point.y});const C=(E=l.current)==null?void 0:E.getBoundingClientRect();C&&w({width:C.width,height:C.height})}}function V(){R.current=setTimeout(()=>{S(null),$(null)},100)}return a.useEffect(()=>{if(!l.current||n.current)return;const v=document.documentElement.classList.contains("dark")?"mapbox://styles/mapbox/dark-v11":"mapbox://styles/mapbox/light-v11",r=new q.Map({container:l.current,style:v,center:ue,zoom:de});
1r.addControl(new q.NavigationControl,"bottom-right");const L=new q.GeolocateControl({positionOptions:{enableHighAccuracy:!0},trackUserLocation:!0,showUserHeading:!0});return r.addControl(L,"bottom-right"),L.on("geolocate",b=>{Te(b.coords.latitude,b.coords.longitude)||r.flyTo({center:ue,zoom:de})}),n.current=r,r.on("load",()=>{u.current=!0;let b=!1;const E=De(32,"#3b82f6","#ffffff",1);r.addImage("star-interested",E,{pixelRatio:window.devicePixelRatio||1}),r.addSource("events",{type:"geojson",data:ee(f.current,d.current),cluster:!0,clusterMaxZoom:14,clusterRadius:50,clusterProperties:{totalEvents:["+",["get","eventCount"]]}}),r.addLayer({id:"clusters",type:"circle",source:"events",filter:["has","point_count"],paint:{"circle-color":["step",["get","totalEvents"],"#6366f1",10,"#8b5cf6",30,"#a855f7"],"circle-radius":["step",["get","totalEvents"],22,10,30,30,38],"circle-opacity":.9}}),r.addLayer({id:"cluster-count",type:"symbol",source:"events",filter:["has","point_count"],layout:{"text-field":["to-string",["get","totalEvents"]],"text-size":13,"text-font":["DIN Offc Pro Medium","Arial Unicode MS Bold"]},paint:{"text-color":"#ffffff"}}),r.addLayer({id:"unclustered-point",type:"circle",source:"events",filter:["all",["!",["has","point_count"]],["!=",["get","hasInterested"],!0]],paint:{"circle-color":["case",[">",["get","eventCount"],1],"#4f46e5","#6366f1"],"circle-radius":["case",[">",["get","eventCount"],1],14,8],"circle-stroke-width":["case",[">",["get","eventCount"],1],2.5,2],"circle-stroke-color":"#ffffff","circle-opacity":.95}}),r.addLayer({id:"unclustered-interested",type:"symbol",source:"events",filter:["all",["!",["has","point_count"]],["==",["get","hasInterested"],!0]],layout:{"icon-image":"star-interested","icon-size":1,"icon-allow-overlap":!0}}),r.addLayer({id:"unclustered-count",type:"symbol",source:"events",filter:["all",["!",["has","point_count"]],[">",["get","eventCount"],1]],layout:{"text-field":["to-string",["get","eventCount"]],"text-size":11,"text-font":["DIN Offc Pro Medium","Arial Unicode MS Bold"]},paint:{"text-color":"#ffffff"}}),r.addSource("spider",{type:"geojson",data:he}),r.addLayer({id:"spider-legs",type:"line",source:"spider",filter:["==",["geometry-type"],"LineString"],paint:{"line-color":"#6366f1","line-width":1.5,"line-opacity":.4}}),r.addLayer({id:"spider-point",type:"circle",source:"spider",filter:["all",["==",["geometry-type"],"Point"],["!=",["get","isInterested"],!0]],paint:{"circle-color":"#6366f1","circle-radius":8,"circle-stroke-width":2,"circle-stroke-color":"#ffffff","circle-opacity":.95}}),r.addLayer({id:"spider-point-interested",type:"symbol",source:"spider",filter:["all",["==",["geometry-type"],"Point"],["==",["get","isInterested"],!0]],layout:{"icon-image":"star-interested","icon-size":1,"icon-allow-overlap":!0}});function C(y,I,Z){const K=fe(y,Z,r,d.current);r.getSource("spider").setData(K),T.current=y,_.current=Z,j.current=I,U.current=!0,r.setFilter("unclustered-point",["all",["!",["has","point_count"]],["!=",["get","hasInterested"],!0],["!=",["get","eventIds"],I]]),r.setFilter("unclustered-interested",["all",["!",["has","point_count"]],["==",["get","hasInterested"],!0],["!=",["get","eventIds"],I]]),r.setFilter("unclustered-count",["all",["!",["has","point_count"]],[">",["get","eventCount"],1],["!=",["get","eventIds"],I]])}function F(){U.current&&(r.getSource("spider").setData(he),U.current=!1,j.current=null,T.current=null,_.current=null,r.setFilter("unclustered-point",["all",["!",["has","point_count"]],["!=",["get","hasInterested"],!0]]),r.setFilter("unclustered-interested",["all",["!",["has","point_count"]],["==",["get","hasInterested"],!0]]),r.setFilter("unclustered-count",["all",["!",["has","point_count"]],[">",["get","eventCount"],1]]))}Y.current=F,te.current=C,r.on("click","clusters",y=>{var ae,le;b=!0;const I=(ae=y.features)==null?void 0:ae[0];if(!I)return;const Z=(le=I.properties)==null?void 0:le.cluster_id,K=I.geometry.coordinates;r.getSource("events").getClusterExpansionZoom(Z,(xe,ie)=>{xe||ie==null||r.easeTo({center:K,zoom:ie})})}),r.on("click","unclustered-point",y=>{b=!0,re(y)}),r.on("click","unclustered-interested",y=>{b=!0,re(y)}
1),r.on("click","spider-point",y=>{b=!0,oe(y)}),r.on("click","spider-point-interested",y=>{b=!0,oe(y)}),r.on("click",()=>{setTimeout(()=>{b||(F(),o(null),m(null),J()),b=!1},0)}),r.on("dragstart",()=>{F(),window.innerWidth<640||(o(null),m(null)),S(null),$(null),R.current&&(clearTimeout(R.current),R.current=null)}),r.on("zoomstart",()=>{F()});const N=window.matchMedia("(hover: hover)").matches;r.on("mouseenter","unclustered-point",y=>{r.getCanvas().style.cursor="pointer",N&&ne(y)}),r.on("mouseenter","unclustered-interested",y=>{r.getCanvas().style.cursor="pointer",N&&ne(y)}),r.on("mouseleave","unclustered-point",()=>{r.getCanvas().style.cursor="",N&&V()}),r.on("mouseleave","unclustered-interested",()=>{r.getCanvas().style.cursor="",N&&V()}),r.on("mouseenter","spider-point",y=>{r.getCanvas().style.cursor="pointer",N&&se(y)}),r.on("mouseenter","spider-point-interested",y=>{r.getCanvas().style.cursor="pointer",N&&se(y)}),r.on("mouseleave","spider-point",()=>{r.getCanvas().style.cursor="",N&&V()}),r.on("mouseleave","spider-point-interested",()=>{r.getCanvas().style.cursor="",N&&V()}),r.on("mouseenter","clusters",()=>{r.getCanvas().style.cursor="pointer"}),r.on("mouseleave","clusters",()=>{r.getCanvas().style.cursor=""}),L.trigger()}),()=>{r.remove(),n.current=null,u.current=!1}},[]),a.useEffect(()=>{var v;const p=n.current;!p||!u.current||((v=p.getSource("events"))==null||v.setData(ee(e,d.current)),Y.current())},[e]),a.useEffect(()=>{var v;const p=n.current;if(!(!p||!u.current)&&((v=p.getSource("events"))==null||v.setData(ee(f.current,s)),U.current&&T.current&&_.current)){const r=fe(T.current,_.current,p,s);p.getSource("spider").setData(r)}},[s]),t.jsxs("div",{className:"relative h-full w-full",children:[t.jsx("div",{ref:l,className:"h-full w-full"}),O&&t.jsx("div",{className:`z-10 pointer-events-none transition-opacity duration-500 ${H?"opacity-0":"opacity-100"}`,children:t.jsx(je,{})}),!x&&k&&z&&t.jsx(ce,{event:k,onClose:()=>{S(null),$(null)},tagColorMap:c,anchorPos:z,containerSize:A,mode:"hover",isInterested:s==null?void 0:s.has(k.id),onToggleInterest:h}),x&&i&&t.jsx(ce,{event:x,onClose:()=>{o(null),m(null)},tagColorMap:c,anchorPos:i,containerSize:A,mode:"click",isInterested:s==null?void 0:s.has(x.id),onToggleInterest:h})]})}const ge={search:"",borough:"",cost:"",tags:[],from:"",to:""};function $e(e){return e.search===""&&e.borough===""&&e.cost===""&&e.tags.length===0&&e.from===""&&e.to===""}function _e(e){return{search:e.search||void 0,borough:e.borough||void 0,cost:e.cost||void 0,tags:e.tags.length>0?e.tags:void 0,from:e.from||void 0,to:e.to||void 0}}function pe(e){return new Date(e+"T00:00:00").toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Fe({filters:e,allTags:c,discovery:g,onChange:s}){const[h,l]=a.useState(!1);function n(o,i){s({...e,[o]:i})}function f(){s(ge)}const d=!$e(e),u=[];e.search&&u.push({label:`"${e.search}"`,onRemove:()=>n("search","")}),e.borough&&u.push({label:e.borough,onRemove:()=>n("borough","")}),e.cost&&u.push({label:e.cost.charAt(0).toUpperCase()+e.cost.slice(1),onRemove:()=>n("cost","")}),e.tags.forEach(o=>u.push({label:o,onRemove:()=>n("tags",e.tags.filter(i=>i!==o))})),e.from&&u.push({label:`From ${pe(e.from)}`,onRemove:()=>n("from","")}),e.to&&u.push({label:`Until ${pe(e.to)}`,onRemove:()=>n("to","")});const x="rounded-lg border border-violet-200/60 dark:border-[#2d2540] bg-white dark:bg-surface-800 text-sm text-gray-700 dark:text-gray-300 focus:outline-none focus:ring-2 focus:ring-violet-500 focus:border-transparent hover:border-violet-300 dark:hover:border-violet-500/30 transition-colors";return t.jsxs("div",{className:"absolute top-3 left-3 right-3 z-20 md:right-auto md:w-[540px] pointer-events-none",children:[t.jsx("div",{className:"rounded-xl bg-white/90 dark:bg-surface-900/90 backdrop-blur-xl border border-violet-200/30 dark:border-violet-500/10 shadow-lg px-3 py-2.5 pointer-events-auto",children:t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx(Ne,{value:e.search,onChange:o=>s({...e,search:o}),className:"flex-1 min-w-[120px]"}),t.jsxs("button",{onClick:()=>l(o=>!o),className:`md:hidden flex items-center gap-1.5 ${x} px-3 py-2 font-medium pointer-events-auto ${h||d?"border-violet-400 bg-vi
1olet-50 text-violet-700 dark:border-violet-500 dark:bg-violet-900/20 dark:text-violet-300":"text-gray-600 dark:text-gray-300"}`,children:[t.jsx("svg",{className:"h-4 w-4 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 6h18M6 12h12M9 18h6"})}),"Filters",d?` (${u.length})`:""]}),t.jsxs("div",{className:`${h?"flex":"hidden"} md:flex flex-wrap items-center gap-2 w-full md:w-auto`,children:[t.jsxs("div",{className:"relative",children:[t.jsxs("select",{value:e.borough,onChange:o=>n("borough",o.target.value),className:`${x} pl-3 pr-8 py-2 appearance-none cursor-pointer ${e.borough?"border-violet-400 bg-violet-50 text-violet-700 dark:border-violet-500 dark:bg-violet-900/20 dark:text-violet-300":""}`,children:[t.jsx("option",{value:"",children:"All boroughs"}),((g==null?void 0:g.boroughs)??[]).map(({value:o,label:i})=>t.jsx("option",{value:o,children:i},o))]}),t.jsx("svg",{className:"pointer-events-none absolute right-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-gray-400 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),t.jsxs("div",{className:"relative",children:[t.jsxs("select",{value:e.cost,onChange:o=>n("cost",o.target.value),className:`${x} pl-3 pr-8 py-2 appearance-none cursor-pointer ${e.cost?"border-violet-400 bg-violet-50 text-violet-700 dark:border-violet-500 dark:bg-violet-900/20 dark:text-violet-300":""}`,children:[t.jsx("option",{value:"",children:"Any cost"}),((g==null?void 0:g.costs)??[]).map(({value:o,label:i})=>t.jsx("option",{value:o,children:i},o))]}),t.jsx("svg",{className:"pointer-events-none absolute right-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-gray-400 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),t.jsx(Ce,{allTags:c,selectedTags:e.tags,onChange:o=>n("tags",o),buttonClassName:x}),t.jsx(Se,{from:e.from,to:e.to,onChange:({from:o,to:i})=>s({...e,from:o,to:i}),buttonClassName:x}),d&&t.jsxs("button",{onClick:f,className:"flex items-center gap-1 rounded-lg px-3 py-2 text-sm font-medium text-gray-500 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:[t.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}),"Clear"]})]})]})}),u.length>0&&t.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5 pointer-events-auto",children:u.map((o,i)=>t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-violet-100 text-violet-700 dark:bg-violet-900/30 dark:text-violet-300 px-3 py-1 text-xs font-medium shadow-sm",children:[o.label,t.jsx("button",{onClick:o.onRemove,"aria-label":"Remove filter",className:"ml-0.5 hover:text-violet-900 dark:hover:text-violet-100 leading-none",children:"Ã"})]},i))})]})}function He({allTags:e=[],discovery:c,interestedIds:g,onToggleInterest:s}){const[h,l]=a.useState([]),[n,f]=a.useState(!0),[d,u]=a.useState(null),[x,o]=a.useState(null),[i,m]=a.useState(ge);a.useEffect(()=>{let w=!1;async function k(){f(!0),u(null);try{let z=0;const $=[];let R=null;const O=_e(i);for(;;){const M=await Le.public.events({...O,q:i.search||void 0,search:void 0,hasCoordinates:!0,limit:100,offset:z});if(w)return;if($.push(...M.events),z+=M.events.length,R=M.gate,!M.hasMore||M.events.length===0)break}w||(l($),o(R))}catch(S){w||u(S.message)}finally{w||f(!1)}}return k(),()=>{w=!0}},[i]);const A=Object.fromEntries(e.map(w=>[w.name,w.color]));return t.jsxs("div",{className:"relative h-full w-full",children:[t.jsx(Ae,{events:h,tagColorMap:A,loading:n,interestedIds:g,onToggleInterest:s}),t.jsx(Fe,{filters:i,allTags:e,discovery:c,onChange:m}),x&&!n&&t.jsx("div",{className:"absolute bottom-4 left-3 right-3 z-20 sm:left-auto sm:right-4 sm:w-80",children:t.jsx(Re,{gate:x})}),d&&t.jsx("div",{className:"absolute bottom-16 left-1/2 -translate-x-1/2 z-20 rounded-lg bg-red-50 dark:bg-red-900/30 border border-red-200 dark:border-red-700 px-4 py-2 text-sm text-red-700 dark:text-red-400 shadow whitespace-nowrap",children:d})]})}export{He as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.